|
|
586cba |
From 2bdea90bfbce3b8d5bfa86178a942a470b85b835 Mon Sep 17 00:00:00 2001
|
|
|
586cba |
From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= <eperezma@redhat.com>
|
|
|
586cba |
Date: Thu, 21 Jul 2022 15:38:55 +0200
|
|
|
586cba |
Subject: [PATCH 07/32] vhost: move descriptor translation to
|
|
|
586cba |
vhost_svq_vring_write_descs
|
|
|
586cba |
MIME-Version: 1.0
|
|
|
586cba |
Content-Type: text/plain; charset=UTF-8
|
|
|
586cba |
Content-Transfer-Encoding: 8bit
|
|
|
586cba |
|
|
|
586cba |
RH-Author: Eugenio Pérez <eperezma@redhat.com>
|
|
|
586cba |
RH-MergeRequest: 108: Net Control Virtqueue shadow Support
|
|
|
586cba |
RH-Commit: [7/27] 5533c72065e4ebf8ea7db966c976a3b29bdafb82 (eperezmartin/qemu-kvm)
|
|
|
586cba |
RH-Bugzilla: 1939363
|
|
|
586cba |
RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
|
|
|
586cba |
RH-Acked-by: Cindy Lu <lulu@redhat.com>
|
|
|
586cba |
RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
|
|
|
586cba |
|
|
|
586cba |
Bugzilla: https://bugzilla.redhat.com/1939363
|
|
|
586cba |
|
|
|
586cba |
Upstream Status: git://git.qemu.org/qemu.git
|
|
|
586cba |
|
|
|
586cba |
commit 009c2549bb9dc7f7061009eb87f2a53d4b364983
|
|
|
586cba |
Author: Eugenio Pérez <eperezma@redhat.com>
|
|
|
586cba |
Date: Wed Jul 20 08:59:26 2022 +0200
|
|
|
586cba |
|
|
|
586cba |
vhost: move descriptor translation to vhost_svq_vring_write_descs
|
|
|
586cba |
|
|
|
586cba |
It's done for both in and out descriptors so it's better placed here.
|
|
|
586cba |
|
|
|
586cba |
Acked-by: Jason Wang <jasowang@redhat.com>
|
|
|
586cba |
Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
|
|
|
586cba |
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
|
|
|
586cba |
Signed-off-by: Jason Wang <jasowang@redhat.com>
|
|
|
586cba |
|
|
|
586cba |
Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
|
|
|
586cba |
---
|
|
|
586cba |
hw/virtio/vhost-shadow-virtqueue.c | 38 +++++++++++++++++++++---------
|
|
|
586cba |
1 file changed, 27 insertions(+), 11 deletions(-)
|
|
|
586cba |
|
|
|
586cba |
diff --git a/hw/virtio/vhost-shadow-virtqueue.c b/hw/virtio/vhost-shadow-virtqueue.c
|
|
|
586cba |
index 06d0bb39d9..3fbda1e3d4 100644
|
|
|
586cba |
--- a/hw/virtio/vhost-shadow-virtqueue.c
|
|
|
586cba |
+++ b/hw/virtio/vhost-shadow-virtqueue.c
|
|
|
586cba |
@@ -122,17 +122,35 @@ static bool vhost_svq_translate_addr(const VhostShadowVirtqueue *svq,
|
|
|
586cba |
return true;
|
|
|
586cba |
}
|
|
|
586cba |
|
|
|
586cba |
-static void vhost_vring_write_descs(VhostShadowVirtqueue *svq, hwaddr *sg,
|
|
|
586cba |
- const struct iovec *iovec, size_t num,
|
|
|
586cba |
- bool more_descs, bool write)
|
|
|
586cba |
+/**
|
|
|
586cba |
+ * Write descriptors to SVQ vring
|
|
|
586cba |
+ *
|
|
|
586cba |
+ * @svq: The shadow virtqueue
|
|
|
586cba |
+ * @sg: Cache for hwaddr
|
|
|
586cba |
+ * @iovec: The iovec from the guest
|
|
|
586cba |
+ * @num: iovec length
|
|
|
586cba |
+ * @more_descs: True if more descriptors come in the chain
|
|
|
586cba |
+ * @write: True if they are writeable descriptors
|
|
|
586cba |
+ *
|
|
|
586cba |
+ * Return true if success, false otherwise and print error.
|
|
|
586cba |
+ */
|
|
|
586cba |
+static bool vhost_svq_vring_write_descs(VhostShadowVirtqueue *svq, hwaddr *sg,
|
|
|
586cba |
+ const struct iovec *iovec, size_t num,
|
|
|
586cba |
+ bool more_descs, bool write)
|
|
|
586cba |
{
|
|
|
586cba |
uint16_t i = svq->free_head, last = svq->free_head;
|
|
|
586cba |
unsigned n;
|
|
|
586cba |
uint16_t flags = write ? cpu_to_le16(VRING_DESC_F_WRITE) : 0;
|
|
|
586cba |
vring_desc_t *descs = svq->vring.desc;
|
|
|
586cba |
+ bool ok;
|
|
|
586cba |
|
|
|
586cba |
if (num == 0) {
|
|
|
586cba |
- return;
|
|
|
586cba |
+ return true;
|
|
|
586cba |
+ }
|
|
|
586cba |
+
|
|
|
586cba |
+ ok = vhost_svq_translate_addr(svq, sg, iovec, num);
|
|
|
586cba |
+ if (unlikely(!ok)) {
|
|
|
586cba |
+ return false;
|
|
|
586cba |
}
|
|
|
586cba |
|
|
|
586cba |
for (n = 0; n < num; n++) {
|
|
|
586cba |
@@ -150,6 +168,7 @@ static void vhost_vring_write_descs(VhostShadowVirtqueue *svq, hwaddr *sg,
|
|
|
586cba |
}
|
|
|
586cba |
|
|
|
586cba |
svq->free_head = le16_to_cpu(svq->desc_next[last]);
|
|
|
586cba |
+ return true;
|
|
|
586cba |
}
|
|
|
586cba |
|
|
|
586cba |
static bool vhost_svq_add_split(VhostShadowVirtqueue *svq,
|
|
|
586cba |
@@ -169,21 +188,18 @@ static bool vhost_svq_add_split(VhostShadowVirtqueue *svq,
|
|
|
586cba |
return false;
|
|
|
586cba |
}
|
|
|
586cba |
|
|
|
586cba |
- ok = vhost_svq_translate_addr(svq, sgs, elem->out_sg, elem->out_num);
|
|
|
586cba |
+ ok = vhost_svq_vring_write_descs(svq, sgs, elem->out_sg, elem->out_num,
|
|
|
586cba |
+ elem->in_num > 0, false);
|
|
|
586cba |
if (unlikely(!ok)) {
|
|
|
586cba |
return false;
|
|
|
586cba |
}
|
|
|
586cba |
- vhost_vring_write_descs(svq, sgs, elem->out_sg, elem->out_num,
|
|
|
586cba |
- elem->in_num > 0, false);
|
|
|
586cba |
-
|
|
|
586cba |
|
|
|
586cba |
- ok = vhost_svq_translate_addr(svq, sgs, elem->in_sg, elem->in_num);
|
|
|
586cba |
+ ok = vhost_svq_vring_write_descs(svq, sgs, elem->in_sg, elem->in_num, false,
|
|
|
586cba |
+ true);
|
|
|
586cba |
if (unlikely(!ok)) {
|
|
|
586cba |
return false;
|
|
|
586cba |
}
|
|
|
586cba |
|
|
|
586cba |
- vhost_vring_write_descs(svq, sgs, elem->in_sg, elem->in_num, false, true);
|
|
|
586cba |
-
|
|
|
586cba |
/*
|
|
|
586cba |
* Put the entry in the available array (but don't update avail->idx until
|
|
|
586cba |
* they do sync).
|
|
|
586cba |
--
|
|
|
586cba |
2.31.1
|
|
|
586cba |
|