[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC PATCH v9 07/23] vhost: add vhost_svq_push_elem
From: |
Eugenio Pérez |
Subject: |
[RFC PATCH v9 07/23] vhost: add vhost_svq_push_elem |
Date: |
Wed, 6 Jul 2022 20:39:52 +0200 |
This function allows external SVQ users to return guest's available
buffers.
Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
---
hw/virtio/vhost-shadow-virtqueue.h | 2 ++
hw/virtio/vhost-shadow-virtqueue.c | 16 ++++++++++++++++
2 files changed, 18 insertions(+)
diff --git a/hw/virtio/vhost-shadow-virtqueue.h
b/hw/virtio/vhost-shadow-virtqueue.h
index 91c31715d9..0fbdd69153 100644
--- a/hw/virtio/vhost-shadow-virtqueue.h
+++ b/hw/virtio/vhost-shadow-virtqueue.h
@@ -88,6 +88,8 @@ typedef struct VhostShadowVirtqueue {
bool vhost_svq_valid_features(uint64_t features, Error **errp);
+void vhost_svq_push_elem(VhostShadowVirtqueue *svq,
+ const VirtQueueElement *elem, uint32_t len);
void vhost_svq_set_svq_kick_fd(VhostShadowVirtqueue *svq, int svq_kick_fd);
void vhost_svq_set_svq_call_fd(VhostShadowVirtqueue *svq, int call_fd);
void vhost_svq_get_vring_addr(const VhostShadowVirtqueue *svq,
diff --git a/hw/virtio/vhost-shadow-virtqueue.c
b/hw/virtio/vhost-shadow-virtqueue.c
index be64e0b85c..2fc5789b73 100644
--- a/hw/virtio/vhost-shadow-virtqueue.c
+++ b/hw/virtio/vhost-shadow-virtqueue.c
@@ -410,6 +410,22 @@ static VirtQueueElement
*vhost_svq_get_buf(VhostShadowVirtqueue *svq,
return g_steal_pointer(&svq->ring_id_maps[used_elem.id]);
}
+/**
+ * Push an element to SVQ, returning it to the guest.
+ */
+void vhost_svq_push_elem(VhostShadowVirtqueue *svq,
+ const VirtQueueElement *elem, uint32_t len)
+{
+ virtqueue_push(svq->vq, elem, len);
+ if (svq->next_guest_avail_elem) {
+ /*
+ * Avail ring was full when vhost_svq_flush was called, so it's a
+ * good moment to make more descriptors available if possible.
+ */
+ vhost_handle_guest_kick(svq);
+ }
+}
+
static void vhost_svq_flush(VhostShadowVirtqueue *svq,
bool check_for_avail_queue)
{
--
2.31.1
- [RFC PATCH v9 01/23] vhost: Return earlier if used buffers overrun, (continued)
[RFC PATCH v9 06/23] virtio-net: Expose ctrl virtqueue logic, Eugenio Pérez, 2022/07/06
[RFC PATCH v9 02/23] vhost: move descriptor translation to vhost_svq_vring_write_descs, Eugenio Pérez, 2022/07/06
[RFC PATCH v9 07/23] vhost: add vhost_svq_push_elem,
Eugenio Pérez <=
[RFC PATCH v9 08/23] vhost: Decouple vhost_svq_add_split from VirtQueueElement, Eugenio Pérez, 2022/07/06
[RFC PATCH v9 03/23] vdpa: delay set_vring_ready after DRIVER_OK, Eugenio Pérez, 2022/07/06