Re: [PATCH 12/21] vhost-vdpa: introduce uAPI to get the number of virtqueue groups

From: Jason Wang
Date: Wed Dec 30 2020 - 01:51:26 EST



On 2020/12/29 下午8:24, Eli Cohen wrote:
On Wed, Dec 16, 2020 at 02:48:09PM +0800, Jason Wang wrote:
Follows the vDPA support for multiple address spaces, this patch
introduce uAPI for the userspace to know the number of virtqueue
groups supported by the vDPA device.
Can you explain what exactly you mean be userspace?


It's the userspace that uses the uAPI introduced in this patch.


Is it just qemu or
is it destined to the virtio_net driver run by the qemu process?


It could be Qemu, DPDK or other userspace program.

The guest virtio-net driver will not use this but talks to the virtio device emulated by Qemu.


Also can you say for what purpose?


This can be used for facilitate the checking of whether the control vq could be supported.

E.g if the device support less than 2 groups, qemu won't advertise control vq.

Yes, #groups could be inferred from GET_VRING_GROUP. But it's not straightforward as this.

Thanks



Signed-off-by: Jason Wang <jasowang@xxxxxxxxxx>
---
drivers/vhost/vdpa.c | 4 ++++
include/uapi/linux/vhost.h | 3 +++
2 files changed, 7 insertions(+)

diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c
index 060d5b5b7e64..1ba5901b28e7 100644
--- a/drivers/vhost/vdpa.c
+++ b/drivers/vhost/vdpa.c
@@ -536,6 +536,10 @@ static long vhost_vdpa_unlocked_ioctl(struct file *filep,
case VHOST_VDPA_GET_VRING_NUM:
r = vhost_vdpa_get_vring_num(v, argp);
break;
+ case VHOST_VDPA_GET_GROUP_NUM:
+ r = copy_to_user(argp, &v->vdpa->ngroups,
+ sizeof(v->vdpa->ngroups));
+ break;
case VHOST_SET_LOG_BASE:
case VHOST_SET_LOG_FD:
r = -ENOIOCTLCMD;
diff --git a/include/uapi/linux/vhost.h b/include/uapi/linux/vhost.h
index 59c6c0fbaba1..8a4e6e426bbf 100644
--- a/include/uapi/linux/vhost.h
+++ b/include/uapi/linux/vhost.h
@@ -145,4 +145,7 @@
/* Get the valid iova range */
#define VHOST_VDPA_GET_IOVA_RANGE _IOR(VHOST_VIRTIO, 0x78, \
struct vhost_vdpa_iova_range)
+/* Get the number of virtqueue groups. */
+#define VHOST_VDPA_GET_GROUP_NUM _IOR(VHOST_VIRTIO, 0x79, unsigned int)
+
#endif
--
2.25.1