diff mbox series

[5/6] vDPA: answer num of queue pairs = 1 to userspace when VIRTIO_NET_F_MQ == 0

Message ID 20220602023845.2596397-6-lingshan.zhu@intel.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series ifcvf/vDPA: support query device config space through netlink | expand

Checks

Context Check Description
netdev/tree_selection success Not a local patch

Commit Message

Zhu, Lingshan June 2, 2022, 2:38 a.m. UTC
If VIRTIO_NET_F_MQ == 0, the virtio device should have one queue pair,
so when userspace querying queue pair numbers, it should return mq=1
than zero

Signed-off-by: Zhu Lingshan <lingshan.zhu@intel.com>
---
 drivers/vdpa/vdpa.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Jason Wang June 2, 2022, 7:38 a.m. UTC | #1
On Thu, Jun 2, 2022 at 10:48 AM Zhu Lingshan <lingshan.zhu@intel.com> wrote:
>
> If VIRTIO_NET_F_MQ == 0, the virtio device should have one queue pair,
> so when userspace querying queue pair numbers, it should return mq=1
> than zero

Spec said:

"max_virtqueue_pairs only exists if VIRTIO_NET_F_MQ is set"

So we are probably fine.

Thanks

>
> Signed-off-by: Zhu Lingshan <lingshan.zhu@intel.com>
> ---
>  drivers/vdpa/vdpa.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/vdpa/vdpa.c b/drivers/vdpa/vdpa.c
> index 030d96bdeed2..50a11ece603e 100644
> --- a/drivers/vdpa/vdpa.c
> +++ b/drivers/vdpa/vdpa.c
> @@ -818,9 +818,10 @@ static int vdpa_dev_net_mq_config_fill(struct vdpa_device *vdev,
>         u16 val_u16;
>
>         if ((features & BIT_ULL(VIRTIO_NET_F_MQ)) == 0)
> -               return 0;
> +               val_u16 = 1;
> +       else
> +               val_u16 = le16_to_cpu((__force __le16)config->max_virtqueue_pairs);
>
> -       val_u16 = le16_to_cpu(config->max_virtqueue_pairs);
>         return nla_put_u16(msg, VDPA_ATTR_DEV_NET_CFG_MAX_VQP, val_u16);
>  }
>
> --
> 2.31.1
>
Zhu, Lingshan June 6, 2022, 8:21 a.m. UTC | #2
On 6/2/2022 3:38 PM, Jason Wang wrote:
> On Thu, Jun 2, 2022 at 10:48 AM Zhu Lingshan <lingshan.zhu@intel.com> wrote:
>> If VIRTIO_NET_F_MQ == 0, the virtio device should have one queue pair,
>> so when userspace querying queue pair numbers, it should return mq=1
>> than zero
> Spec said:
>
> "max_virtqueue_pairs only exists if VIRTIO_NET_F_MQ is set"
>
> So we are probably fine.
I thinks it is asking how many queue 
pairs(VDPA_ATTR_DEV_NET_CFG_MAX_VQP), so answering 0 may not be correct.

Thanks,
Zhu Lingshan
>
> Thanks
>
>> Signed-off-by: Zhu Lingshan <lingshan.zhu@intel.com>
>> ---
>>   drivers/vdpa/vdpa.c | 5 +++--
>>   1 file changed, 3 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/vdpa/vdpa.c b/drivers/vdpa/vdpa.c
>> index 030d96bdeed2..50a11ece603e 100644
>> --- a/drivers/vdpa/vdpa.c
>> +++ b/drivers/vdpa/vdpa.c
>> @@ -818,9 +818,10 @@ static int vdpa_dev_net_mq_config_fill(struct vdpa_device *vdev,
>>          u16 val_u16;
>>
>>          if ((features & BIT_ULL(VIRTIO_NET_F_MQ)) == 0)
>> -               return 0;
>> +               val_u16 = 1;
>> +       else
>> +               val_u16 = le16_to_cpu((__force __le16)config->max_virtqueue_pairs);
>>
>> -       val_u16 = le16_to_cpu(config->max_virtqueue_pairs);
>>          return nla_put_u16(msg, VDPA_ATTR_DEV_NET_CFG_MAX_VQP, val_u16);
>>   }
>>
>> --
>> 2.31.1
>>
Jason Wang June 7, 2022, 6:14 a.m. UTC | #3
On Mon, Jun 6, 2022 at 4:22 PM Zhu, Lingshan <lingshan.zhu@intel.com> wrote:
>
>
>
> On 6/2/2022 3:38 PM, Jason Wang wrote:
> > On Thu, Jun 2, 2022 at 10:48 AM Zhu Lingshan <lingshan.zhu@intel.com> wrote:
> >> If VIRTIO_NET_F_MQ == 0, the virtio device should have one queue pair,
> >> so when userspace querying queue pair numbers, it should return mq=1
> >> than zero
> > Spec said:
> >
> > "max_virtqueue_pairs only exists if VIRTIO_NET_F_MQ is set"
> >
> > So we are probably fine.
> I thinks it is asking how many queue
> pairs(VDPA_ATTR_DEV_NET_CFG_MAX_VQP), so answering 0 may not be correct.
>
> Thanks,
> Zhu Lingshan

Please add the result of the userspace vdpa tool before and after this
patch in the changlog in next version.

Thanks

> >
> > Thanks
> >
> >> Signed-off-by: Zhu Lingshan <lingshan.zhu@intel.com>
> >> ---
> >>   drivers/vdpa/vdpa.c | 5 +++--
> >>   1 file changed, 3 insertions(+), 2 deletions(-)
> >>
> >> diff --git a/drivers/vdpa/vdpa.c b/drivers/vdpa/vdpa.c
> >> index 030d96bdeed2..50a11ece603e 100644
> >> --- a/drivers/vdpa/vdpa.c
> >> +++ b/drivers/vdpa/vdpa.c
> >> @@ -818,9 +818,10 @@ static int vdpa_dev_net_mq_config_fill(struct vdpa_device *vdev,
> >>          u16 val_u16;
> >>
> >>          if ((features & BIT_ULL(VIRTIO_NET_F_MQ)) == 0)
> >> -               return 0;
> >> +               val_u16 = 1;
> >> +       else
> >> +               val_u16 = le16_to_cpu((__force __le16)config->max_virtqueue_pairs);
> >>
> >> -       val_u16 = le16_to_cpu(config->max_virtqueue_pairs);
> >>          return nla_put_u16(msg, VDPA_ATTR_DEV_NET_CFG_MAX_VQP, val_u16);
> >>   }
> >>
> >> --
> >> 2.31.1
> >>
>
Zhu, Lingshan June 7, 2022, 8:40 a.m. UTC | #4
On 6/7/2022 2:14 PM, Jason Wang wrote:
> On Mon, Jun 6, 2022 at 4:22 PM Zhu, Lingshan <lingshan.zhu@intel.com> wrote:
>>
>>
>> On 6/2/2022 3:38 PM, Jason Wang wrote:
>>> On Thu, Jun 2, 2022 at 10:48 AM Zhu Lingshan <lingshan.zhu@intel.com> wrote:
>>>> If VIRTIO_NET_F_MQ == 0, the virtio device should have one queue pair,
>>>> so when userspace querying queue pair numbers, it should return mq=1
>>>> than zero
>>> Spec said:
>>>
>>> "max_virtqueue_pairs only exists if VIRTIO_NET_F_MQ is set"
>>>
>>> So we are probably fine.
>> I thinks it is asking how many queue
>> pairs(VDPA_ATTR_DEV_NET_CFG_MAX_VQP), so answering 0 may not be correct.
>>
>> Thanks,
>> Zhu Lingshan
> Please add the result of the userspace vdpa tool before and after this
> patch in the changlog in next version.
sure!
>
> Thanks
>
>>> Thanks
>>>
>>>> Signed-off-by: Zhu Lingshan <lingshan.zhu@intel.com>
>>>> ---
>>>>    drivers/vdpa/vdpa.c | 5 +++--
>>>>    1 file changed, 3 insertions(+), 2 deletions(-)
>>>>
>>>> diff --git a/drivers/vdpa/vdpa.c b/drivers/vdpa/vdpa.c
>>>> index 030d96bdeed2..50a11ece603e 100644
>>>> --- a/drivers/vdpa/vdpa.c
>>>> +++ b/drivers/vdpa/vdpa.c
>>>> @@ -818,9 +818,10 @@ static int vdpa_dev_net_mq_config_fill(struct vdpa_device *vdev,
>>>>           u16 val_u16;
>>>>
>>>>           if ((features & BIT_ULL(VIRTIO_NET_F_MQ)) == 0)
>>>> -               return 0;
>>>> +               val_u16 = 1;
>>>> +       else
>>>> +               val_u16 = le16_to_cpu((__force __le16)config->max_virtqueue_pairs);
>>>>
>>>> -       val_u16 = le16_to_cpu(config->max_virtqueue_pairs);
>>>>           return nla_put_u16(msg, VDPA_ATTR_DEV_NET_CFG_MAX_VQP, val_u16);
>>>>    }
>>>>
>>>> --
>>>> 2.31.1
>>>>
diff mbox series

Patch

diff --git a/drivers/vdpa/vdpa.c b/drivers/vdpa/vdpa.c
index 030d96bdeed2..50a11ece603e 100644
--- a/drivers/vdpa/vdpa.c
+++ b/drivers/vdpa/vdpa.c
@@ -818,9 +818,10 @@  static int vdpa_dev_net_mq_config_fill(struct vdpa_device *vdev,
 	u16 val_u16;
 
 	if ((features & BIT_ULL(VIRTIO_NET_F_MQ)) == 0)
-		return 0;
+		val_u16 = 1;
+	else
+		val_u16 = le16_to_cpu((__force __le16)config->max_virtqueue_pairs);
 
-	val_u16 = le16_to_cpu(config->max_virtqueue_pairs);
 	return nla_put_u16(msg, VDPA_ATTR_DEV_NET_CFG_MAX_VQP, val_u16);
 }