Messages in this thread Patch in this message | | | From | Cindy Lu <> | Subject | [PATCH v2 4/5] vduse: update the vq_info in ioctl | Date | Tue, 21 Nov 2023 15:30:49 +0800 |
| |
In VDUSE_VQ_GET_INFO, the driver will sync the last_avail_idx with reconnect info, After mapping the reconnect pages to userspace The userspace App will update the reconnect_time in struct vhost_reconnect_vring, If this is not 0 then it means this vq is reconnected and will update the last_avail_idx
Signed-off-by: Cindy Lu <lulu@redhat.com> --- drivers/vdpa/vdpa_user/vduse_dev.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-)
diff --git a/drivers/vdpa/vdpa_user/vduse_dev.c b/drivers/vdpa/vdpa_user/vduse_dev.c index d0fe9a7e86ab..6bc5fc2b88cc 100644 --- a/drivers/vdpa/vdpa_user/vduse_dev.c +++ b/drivers/vdpa/vdpa_user/vduse_dev.c @@ -1209,6 +1209,9 @@ static long vduse_dev_ioctl(struct file *file, unsigned int cmd, struct vduse_vq_info vq_info; struct vduse_virtqueue *vq; u32 index; + struct vdpa_reconnect_info *area; + struct vhost_reconnect_vring *vq_reconnect; + struct vhost_reconnect_data *dev_reconnect; ret = -EFAULT; if (copy_from_user(&vq_info, argp, sizeof(vq_info))) @@ -1225,6 +1228,12 @@ static long vduse_dev_ioctl(struct file *file, unsigned int cmd, vq_info.device_addr = vq->device_addr; vq_info.num = vq->num; + area = &dev->reconnect_info; + dev_reconnect = (struct vhost_reconnect_data *)area->vaddr; + + area = &vq->reconnect_info; + vq_reconnect = (struct vhost_reconnect_vring *)area->vaddr; + if (dev->driver_features & BIT_ULL(VIRTIO_F_RING_PACKED)) { vq_info.packed.last_avail_counter = vq->state.packed.last_avail_counter; @@ -1234,9 +1243,22 @@ static long vduse_dev_ioctl(struct file *file, unsigned int cmd, vq->state.packed.last_used_counter; vq_info.packed.last_used_idx = vq->state.packed.last_used_idx; - } else + /*check if the vq is reconnect, if yes then update the last_avail_idx*/ + if (dev_reconnect->reconnected != 0) { + vq_info.packed.last_avail_idx = + vq_reconnect->last_avail_idx; + vq_info.packed.last_avail_counter = + vq_reconnect->avail_wrap_counter; + } + } else { vq_info.split.avail_index = vq->state.split.avail_index; + /*check if the vq is reconnect, if yes then update the last_avail_idx*/ + if (dev_reconnect->reconnected != 0) { + vq_info.split.avail_index = + vq_reconnect->last_avail_idx; + } + } vq_info.ready = vq->ready; -- 2.34.3
| |