[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC PATCH v6 07/23] vhost: move descriptor translation to vhost_svq_vri
From: |
Eugenio Pérez |
Subject: |
[RFC PATCH v6 07/23] vhost: move descriptor translation to vhost_svq_vring_write_descs |
Date: |
Mon, 11 Apr 2022 16:50:10 +0200 |
It's done for both in and out descriptors so it's better placed here.
Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
---
hw/virtio/vhost-shadow-virtqueue.c | 26 +++++++++++++++-----------
1 file changed, 15 insertions(+), 11 deletions(-)
diff --git a/hw/virtio/vhost-shadow-virtqueue.c
b/hw/virtio/vhost-shadow-virtqueue.c
index c17506df20..bcb5f3aae9 100644
--- a/hw/virtio/vhost-shadow-virtqueue.c
+++ b/hw/virtio/vhost-shadow-virtqueue.c
@@ -122,17 +122,23 @@ static bool vhost_svq_translate_addr(const
VhostShadowVirtqueue *svq,
return true;
}
-static void vhost_vring_write_descs(VhostShadowVirtqueue *svq, hwaddr *sg,
- const struct iovec *iovec, size_t num,
- bool more_descs, bool write)
+static bool vhost_svq_vring_write_descs(VhostShadowVirtqueue *svq, hwaddr *sg,
+ const struct iovec *iovec, size_t num,
+ bool more_descs, bool write)
{
uint16_t i = svq->free_head, last = svq->free_head;
unsigned n;
uint16_t flags = write ? cpu_to_le16(VRING_DESC_F_WRITE) : 0;
vring_desc_t *descs = svq->vring.desc;
+ bool ok;
if (num == 0) {
- return;
+ return true;
+ }
+
+ ok = vhost_svq_translate_addr(svq, sg, iovec, num);
+ if (unlikely(!ok)) {
+ return false;
}
for (n = 0; n < num; n++) {
@@ -149,6 +155,7 @@ static void vhost_vring_write_descs(VhostShadowVirtqueue
*svq, hwaddr *sg,
}
svq->free_head = le16_to_cpu(descs[last].next);
+ return true;
}
static bool vhost_svq_add_split(VhostShadowVirtqueue *svq,
@@ -168,21 +175,18 @@ static bool vhost_svq_add_split(VhostShadowVirtqueue *svq,
return false;
}
- ok = vhost_svq_translate_addr(svq, sgs, elem->out_sg, elem->out_num);
+ ok = vhost_svq_vring_write_descs(svq, sgs, elem->out_sg, elem->out_num,
+ elem->in_num > 0, false);
if (unlikely(!ok)) {
return false;
}
- vhost_vring_write_descs(svq, sgs, elem->out_sg, elem->out_num,
- elem->in_num > 0, false);
-
- ok = vhost_svq_translate_addr(svq, sgs, elem->in_sg, elem->in_num);
+ ok = vhost_svq_vring_write_descs(svq, sgs, elem->in_sg, elem->in_num,
false,
+ true);
if (unlikely(!ok)) {
return false;
}
- vhost_vring_write_descs(svq, sgs, elem->in_sg, elem->in_num, false, true);
-
/*
* Put the entry in the available array (but don't update avail->idx until
* they do sync).
--
2.27.0
- [RFC PATCH v6 00/23] Net Control VQ support with asid in vDPA SVQ, Eugenio Pérez, 2022/04/11
- [RFC PATCH v6 01/23] vdpa: Add missing tracing to batch mapping functions, Eugenio Pérez, 2022/04/11
- [RFC PATCH v6 03/23] util: Return void on iova_tree_remove, Eugenio Pérez, 2022/04/11
- [RFC PATCH v6 05/23] vhost: Fix bad return of descriptors to SVQ, Eugenio Pérez, 2022/04/11
- [RFC PATCH v6 04/23] hw/virtio: Replace g_memdup() by g_memdup2(), Eugenio Pérez, 2022/04/11
- [RFC PATCH v6 02/23] vdpa: Fix bad index calculus at vhost_vdpa_get_vring_base, Eugenio Pérez, 2022/04/11
- [RFC PATCH v6 06/23] vdpa: Add x-svq to NetdevVhostVDPAOptions, Eugenio Pérez, 2022/04/11
- [RFC PATCH v6 07/23] vhost: move descriptor translation to vhost_svq_vring_write_descs,
Eugenio Pérez <=
- [RFC PATCH v6 09/23] virtio-net: Expose ctrl virtqueue logic, Eugenio Pérez, 2022/04/11
- [RFC PATCH v6 11/23] virtio: Make virtqueue_alloc_element non-static, Eugenio Pérez, 2022/04/11
- [RFC PATCH v6 10/23] vdpa: Extract get features part from vhost_vdpa_get_max_queue_pairs, Eugenio Pérez, 2022/04/11
- [RFC PATCH v6 13/23] vhost: Add custom used buffer callback, Eugenio Pérez, 2022/04/11
- [RFC PATCH v6 08/23] vdpa: Fix index calculus at vhost_vdpa_svqs_start, Eugenio Pérez, 2022/04/11
- [RFC PATCH v6 14/23] vdpa: control virtqueue support on shadow virtqueue, Eugenio Pérez, 2022/04/11
- [RFC PATCH v6 15/23] vhost: Add vhost_iova_tree_find, Eugenio Pérez, 2022/04/11
- [RFC PATCH v6 18/23] vdpa: add NetClientState->start() callback, Eugenio Pérez, 2022/04/11
- [RFC PATCH v6 12/23] vhost: Add SVQElement, Eugenio Pérez, 2022/04/11
- [RFC PATCH v6 21/23] vhost: Make possible to check for device exclusive vq group, Eugenio Pérez, 2022/04/11