[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 12/22] vhost: Add vhost_svq_inject
From: |
Eugenio Pérez |
Subject: |
[PATCH 12/22] vhost: Add vhost_svq_inject |
Date: |
Fri, 8 Jul 2022 12:50:03 +0200 |
This allows qemu to inject buffers to the device.
Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
---
hw/virtio/vhost-shadow-virtqueue.h | 2 ++
hw/virtio/vhost-shadow-virtqueue.c | 37 ++++++++++++++++++++++++++++++
2 files changed, 39 insertions(+)
diff --git a/hw/virtio/vhost-shadow-virtqueue.h
b/hw/virtio/vhost-shadow-virtqueue.h
index 855fa82e3e..09b87078af 100644
--- a/hw/virtio/vhost-shadow-virtqueue.h
+++ b/hw/virtio/vhost-shadow-virtqueue.h
@@ -84,6 +84,8 @@ bool vhost_svq_valid_features(uint64_t features, Error
**errp);
void vhost_svq_push_elem(VhostShadowVirtqueue *svq,
const VirtQueueElement *elem, uint32_t len);
+int vhost_svq_inject(VhostShadowVirtqueue *svq, const struct iovec *iov,
+ size_t out_num, size_t in_num, void *opaque);
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 2b0a268655..4d59954f1b 100644
--- a/hw/virtio/vhost-shadow-virtqueue.c
+++ b/hw/virtio/vhost-shadow-virtqueue.c
@@ -282,6 +282,43 @@ static bool vhost_svq_add_element(VhostShadowVirtqueue
*svq,
return ok;
}
+/**
+ * Inject a chain of buffers to the device
+ *
+ * @svq: Shadow VirtQueue
+ * @iov: I/O vector
+ * @out_num: Number of front out descriptors
+ * @in_num: Number of last input descriptors
+ * @opaque: Contextual data to store in descriptor
+ *
+ * Return 0 on success, -ENOMEM if cannot inject
+ */
+int vhost_svq_inject(VhostShadowVirtqueue *svq, const struct iovec *iov,
+ size_t out_num, size_t in_num, void *opaque)
+{
+ bool ok;
+ size_t num = out_num + in_num;
+
+ /*
+ * All vhost_svq_inject calls are controlled by qemu so we won't hit this
+ * assertions.
+ */
+ assert(out_num || in_num);
+
+ if (unlikely(num > vhost_svq_available_slots(svq))) {
+ error_report("Injecting in a full queue");
+ return -ENOMEM;
+ }
+
+ ok = vhost_svq_add(svq, iov, out_num, iov + out_num, in_num, opaque);
+ if (unlikely(!ok)) {
+ return -EINVAL;
+ }
+
+ vhost_svq_kick(svq);
+ return 0;
+}
+
/**
* Forward available buffers.
*
--
2.31.1
- [PATCH 02/22] vhost: move descriptor translation to vhost_svq_vring_write_descs, (continued)
- [PATCH 02/22] vhost: move descriptor translation to vhost_svq_vring_write_descs, Eugenio Pérez, 2022/07/08
- [PATCH 03/22] vdpa: Clean vhost_vdpa_dev_start(dev, false), Eugenio Pérez, 2022/07/08
- [PATCH 04/22] virtio-net: Expose ctrl virtqueue logic, Eugenio Pérez, 2022/07/08
- [PATCH 06/22] vhost: Reorder vhost_svq_last_desc_of_chain, Eugenio Pérez, 2022/07/08
- [PATCH 05/22] vhost: Decouple vhost_svq_add_split from VirtQueueElement, Eugenio Pérez, 2022/07/08
- [PATCH 07/22] vhost: Add SVQElement, Eugenio Pérez, 2022/07/08
- [PATCH 08/22] vhost: Move last chain id to SVQ element, Eugenio Pérez, 2022/07/08
- [PATCH 11/22] vhost: add vhost_svq_push_elem, Eugenio Pérez, 2022/07/08
- [PATCH 10/22] vdpa: Small rename of error labels, Eugenio Pérez, 2022/07/08
- [PATCH 09/22] vhost: Add opaque member to SVQElement, Eugenio Pérez, 2022/07/08
- [PATCH 12/22] vhost: Add vhost_svq_inject,
Eugenio Pérez <=
- [PATCH 13/22] vhost: add vhost_svq_poll, Eugenio Pérez, 2022/07/08
- [PATCH 16/22] vhost: add detach SVQ operation, Eugenio Pérez, 2022/07/08
- [PATCH 18/22] vdpa: manual forward CVQ buffers, Eugenio Pérez, 2022/07/08
- [PATCH 15/22] vhost: Add svq avail_handler callback, Eugenio Pérez, 2022/07/08
- [PATCH 17/22] vdpa: Export vhost_vdpa_dma_map and unmap calls, Eugenio Pérez, 2022/07/08
- [PATCH 19/22] vdpa: Buffer CVQ support on shadow virtqueue, Eugenio Pérez, 2022/07/08
- [PATCH 20/22] vdpa: Extract get features part from vhost_vdpa_get_max_queue_pairs, Eugenio Pérez, 2022/07/08
- [PATCH 14/22] vhost: Add custom used buffer callback, Eugenio Pérez, 2022/07/08
- [PATCH 21/22] vdpa: Add device migration blocker, Eugenio Pérez, 2022/07/08
- [PATCH 22/22] vdpa: Add x-svq to NetdevVhostVDPAOptions, Eugenio Pérez, 2022/07/08