[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC PATCH v7 09/25] vhost: move descriptor translation to vhost_svq_vri
From: |
Eugenio Pérez |
Subject: |
[RFC PATCH v7 09/25] vhost: move descriptor translation to vhost_svq_vring_write_descs |
Date: |
Wed, 13 Apr 2022 18:31:50 +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 a2531d5874..f874374651 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++) {
@@ -150,6 +156,7 @@ static void vhost_vring_write_descs(VhostShadowVirtqueue
*svq, hwaddr *sg,
}
svq->free_head = le16_to_cpu(svq->desc_next[last]);
+ return true;
}
static bool vhost_svq_add_split(VhostShadowVirtqueue *svq,
@@ -169,21 +176,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
- Re: [RFC PATCH v7 04/25] util: Return void on iova_tree_remove, (continued)
- [RFC PATCH v7 05/25] hw/virtio: Replace g_memdup() by g_memdup2(), Eugenio Pérez, 2022/04/13
- [RFC PATCH v7 06/25] vdpa: Send all updates in memory listener commit, Eugenio Pérez, 2022/04/13
- [RFC PATCH v7 08/25] vdpa: Add x-svq to NetdevVhostVDPAOptions, Eugenio Pérez, 2022/04/13
- [RFC PATCH v7 09/25] vhost: move descriptor translation to vhost_svq_vring_write_descs,
Eugenio Pérez <=
- [RFC PATCH v7 10/25] vdpa: Fix index calculus at vhost_vdpa_svqs_start, Eugenio Pérez, 2022/04/13
- [RFC PATCH v7 07/25] vhost: Add reference counting to vhost_iova_tree, Eugenio Pérez, 2022/04/13
- [RFC PATCH v7 11/25] virtio-net: Expose ctrl virtqueue logic, Eugenio Pérez, 2022/04/13
- [RFC PATCH v7 12/25] vdpa: Extract get features part from vhost_vdpa_get_max_queue_pairs, Eugenio Pérez, 2022/04/13
- [RFC PATCH v7 13/25] virtio: Make virtqueue_alloc_element non-static, Eugenio Pérez, 2022/04/13
- [RFC PATCH v7 03/25] vdpa: Fix bad index calculus at vhost_vdpa_get_vring_base, Eugenio Pérez, 2022/04/13