On Tue, Sep 12, 2023 at 11:01 AM Cindy Lu lulu@redhat.com wrote:
In VDUSE_GET_RECONNECT_INFO, the Userspace App can get the map size and The number of mapping memory pages from the kernel. The userspace App can use this information to map the pages.
Signed-off-by: Cindy Lu lulu@redhat.com
drivers/vdpa/vdpa_user/vduse_dev.c | 15 +++++++++++++++ include/uapi/linux/vduse.h | 15 +++++++++++++++ 2 files changed, 30 insertions(+)
diff --git a/drivers/vdpa/vdpa_user/vduse_dev.c b/drivers/vdpa/vdpa_user/vduse_dev.c index 680b23dbdde2..c99f99892b5c 100644 --- a/drivers/vdpa/vdpa_user/vduse_dev.c +++ b/drivers/vdpa/vdpa_user/vduse_dev.c @@ -1368,6 +1368,21 @@ static long vduse_dev_ioctl(struct file *file, unsigned int cmd, ret = 0; break; }
case VDUSE_GET_RECONNECT_INFO: {
struct vduse_reconnect_mmap_info info;
ret = -EFAULT;
if (copy_from_user(&info, argp, sizeof(info)))
break;
info.size = PAGE_SIZE;
info.max_index = dev->vq_num + 1;
if (copy_to_user(argp, &info, sizeof(info)))
break;
ret = 0;
break;
} default: ret = -ENOIOCTLCMD; break;
diff --git a/include/uapi/linux/vduse.h b/include/uapi/linux/vduse.h index d585425803fd..ce55e34f63d7 100644 --- a/include/uapi/linux/vduse.h +++ b/include/uapi/linux/vduse.h @@ -356,4 +356,19 @@ struct vhost_reconnect_vring { _Bool avail_wrap_counter; };
+/**
- struct vduse_reconnect_mmap_info
- @size: mapping memory size, always page_size here
- @max_index: the number of pages allocated in kernel,just
- use for check
- */
+struct vduse_reconnect_mmap_info {
__u32 size;
__u32 max_index;
+};
One thing I didn't understand is that, aren't the things we used to store connection info belong to uAPI? If not, how can we make sure the connections work across different vendors/implementations. If yes, where?
Thanks
+#define VDUSE_GET_RECONNECT_INFO \
_IOWR(VDUSE_BASE, 0x1b, struct vduse_reconnect_mmap_info)
#endif /* _UAPI_VDUSE_H_ */
2.34.3