[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC PATCH v4 04/20] vhost: move descriptor translation to vhost_svq_vri
From: |
Eugenio Pérez |
Subject: |
[RFC PATCH v4 04/20] vhost: move descriptor translation to vhost_svq_vring_write_descs |
Date: |
Thu, 31 Mar 2022 20:03:54 +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 v4 00/20] Net Control VQ support with asid in vDPA SVQ, Eugenio Pérez, 2022/03/31
- [RFC PATCH v4 01/20] vhost: Fix bad return of descriptors, Eugenio Pérez, 2022/03/31
- [RFC PATCH v4 02/20] util: Return void on iova_tree_remove, Eugenio Pérez, 2022/03/31
- [RFC PATCH v4 03/20] vdpa: Add x-svq to NetdevVhostVDPAOptions, Eugenio Pérez, 2022/03/31
- [RFC PATCH v4 04/20] vhost: move descriptor translation to vhost_svq_vring_write_descs,
Eugenio Pérez <=
- [RFC PATCH v4 05/20] vdpa: Fix index calculus at vhost_vdpa_svqs_start, Eugenio Pérez, 2022/03/31
- [RFC PATCH v4 06/20] virtio-net: use g_memdup2() instead of unsafe g_memdup(), Eugenio Pérez, 2022/03/31
- [RFC PATCH v4 07/20] virtio-net: Expose ctrl virtqueue logic, Eugenio Pérez, 2022/03/31
- [RFC PATCH v4 08/20] vdpa: Extract get geatures part from vhost_vdpa_get_max_queue_pairs, Eugenio Pérez, 2022/03/31
- [RFC PATCH v4 09/20] virtio: Make virtqueue_alloc_element non-static, Eugenio Pérez, 2022/03/31
- [RFC PATCH v4 10/20] vhost: Add SVQElement, Eugenio Pérez, 2022/03/31
- [RFC PATCH v4 11/20] vhost: Add custom used buffer callback, Eugenio Pérez, 2022/03/31
- [RFC PATCH v4 12/20] vdpa: control virtqueue support on shadow virtqueue, Eugenio Pérez, 2022/03/31
- [RFC PATCH v4 13/20] vhost: Add vhost_iova_tree_find, Eugenio Pérez, 2022/03/31
- [RFC PATCH v4 14/20] vdpa: Add map/unmap operation callback to SVQ, Eugenio Pérez, 2022/03/31