[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL V2 10/25] vhost: Track number of descs in SVQDescState
From: |
Jason Wang |
Subject: |
[PULL V2 10/25] vhost: Track number of descs in SVQDescState |
Date: |
Wed, 20 Jul 2022 17:02:58 +0800 |
From: Eugenio Pérez <eperezma@redhat.com>
A guest's buffer continuos on GPA may need multiple descriptors on
qemu's VA, so SVQ should track its length sepparatedly.
Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
---
hw/virtio/vhost-shadow-virtqueue.c | 4 ++--
hw/virtio/vhost-shadow-virtqueue.h | 6 ++++++
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/hw/virtio/vhost-shadow-virtqueue.c
b/hw/virtio/vhost-shadow-virtqueue.c
index e4c09e2..8314405 100644
--- a/hw/virtio/vhost-shadow-virtqueue.c
+++ b/hw/virtio/vhost-shadow-virtqueue.c
@@ -257,6 +257,7 @@ static int vhost_svq_add(VhostShadowVirtqueue *svq, const
struct iovec *out_sg,
}
svq->desc_state[qemu_head].elem = elem;
+ svq->desc_state[qemu_head].ndescs = ndescs;
vhost_svq_kick(svq);
return 0;
}
@@ -418,8 +419,7 @@ static VirtQueueElement
*vhost_svq_get_buf(VhostShadowVirtqueue *svq,
return NULL;
}
- num = svq->desc_state[used_elem.id].elem->in_num +
- svq->desc_state[used_elem.id].elem->out_num;
+ num = svq->desc_state[used_elem.id].ndescs;
last_used_chain = vhost_svq_last_desc_of_chain(svq, num, used_elem.id);
svq->desc_next[last_used_chain] = svq->free_head;
svq->free_head = used_elem.id;
diff --git a/hw/virtio/vhost-shadow-virtqueue.h
b/hw/virtio/vhost-shadow-virtqueue.h
index d646c35..5c7e7cb 100644
--- a/hw/virtio/vhost-shadow-virtqueue.h
+++ b/hw/virtio/vhost-shadow-virtqueue.h
@@ -17,6 +17,12 @@
typedef struct SVQDescState {
VirtQueueElement *elem;
+
+ /*
+ * Number of descriptors exposed to the device. May or may not match
+ * guest's
+ */
+ unsigned int ndescs;
} SVQDescState;
/* Shadow virtqueue to relay notifications */
--
2.7.4
- [PULL V2 00/25] Net patches, Jason Wang, 2022/07/20
- [PULL V2 01/25] vhost: move descriptor translation to vhost_svq_vring_write_descs, Jason Wang, 2022/07/20
- [PULL V2 02/25] virtio-net: Expose MAC_TABLE_ENTRIES, Jason Wang, 2022/07/20
- [PULL V2 03/25] virtio-net: Expose ctrl virtqueue logic, Jason Wang, 2022/07/20
- [PULL V2 04/25] vdpa: Avoid compiler to squash reads to used idx, Jason Wang, 2022/07/20
- [PULL V2 06/25] vhost: Move vhost_svq_kick call to vhost_svq_add, Jason Wang, 2022/07/20
- [PULL V2 07/25] vhost: Check for queue full at vhost_svq_add, Jason Wang, 2022/07/20
- [PULL V2 08/25] vhost: Decouple vhost_svq_add from VirtQueueElement, Jason Wang, 2022/07/20
- [PULL V2 09/25] vhost: Add SVQDescState, Jason Wang, 2022/07/20
- [PULL V2 10/25] vhost: Track number of descs in SVQDescState,
Jason Wang <=
- [PULL V2 11/25] vhost: add vhost_svq_push_elem, Jason Wang, 2022/07/20
- [PULL V2 05/25] vhost: Reorder vhost_svq_kick, Jason Wang, 2022/07/20
- [PULL V2 17/25] vdpa: manual forward CVQ buffers, Jason Wang, 2022/07/20
- [PULL V2 15/25] vdpa: Export vhost_vdpa_dma_map and unmap calls, Jason Wang, 2022/07/20
- [PULL V2 19/25] vdpa: Extract get features part from vhost_vdpa_get_max_queue_pairs, Jason Wang, 2022/07/20
- [PULL V2 22/25] softmmu/runstate.c: add RunStateTransition support form COLO to PRELAUNCH, Jason Wang, 2022/07/20
- [PULL V2 12/25] vhost: Expose vhost_svq_add, Jason Wang, 2022/07/20
- [PULL V2 14/25] vhost: Add svq avail_handler callback, Jason Wang, 2022/07/20