[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL v2 23/61] virtio: virtqueue_pop - VIRTIO_F_IN_ORDER support
From: |
Michael S. Tsirkin |
Subject: |
[PULL v2 23/61] virtio: virtqueue_pop - VIRTIO_F_IN_ORDER support |
Date: |
Tue, 23 Jul 2024 06:57:11 -0400 |
From: Jonah Palmer <jonah.palmer@oracle.com>
Add VIRTIO_F_IN_ORDER feature support in virtqueue_split_pop and
virtqueue_packed_pop.
VirtQueueElements popped from the available/descritpor ring are added to
the VirtQueue's used_elems array in-order and in the same fashion as
they would be added the used and descriptor rings, respectively.
This will allow us to keep track of the current order, what elements
have been written, as well as an element's essential data after being
processed.
Reviewed-by: Eugenio PĂ©rez <eperezma@redhat.com>
Signed-off-by: Jonah Palmer <jonah.palmer@oracle.com>
Message-Id: <20240710125522.4168043-3-jonah.palmer@oracle.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
hw/virtio/virtio.c | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
index 583a224163..98eb601b09 100644
--- a/hw/virtio/virtio.c
+++ b/hw/virtio/virtio.c
@@ -1505,7 +1505,7 @@ static void *virtqueue_alloc_element(size_t sz, unsigned
out_num, unsigned in_nu
static void *virtqueue_split_pop(VirtQueue *vq, size_t sz)
{
- unsigned int i, head, max;
+ unsigned int i, head, max, idx;
VRingMemoryRegionCaches *caches;
MemoryRegionCache indirect_desc_cache;
MemoryRegionCache *desc_cache;
@@ -1629,6 +1629,13 @@ static void *virtqueue_split_pop(VirtQueue *vq, size_t
sz)
elem->in_sg[i] = iov[out_num + i];
}
+ if (virtio_vdev_has_feature(vdev, VIRTIO_F_IN_ORDER)) {
+ idx = (vq->last_avail_idx - 1) % vq->vring.num;
+ vq->used_elems[idx].index = elem->index;
+ vq->used_elems[idx].len = elem->len;
+ vq->used_elems[idx].ndescs = elem->ndescs;
+ }
+
vq->inuse++;
trace_virtqueue_pop(vq, elem, elem->in_num, elem->out_num);
@@ -1762,6 +1769,13 @@ static void *virtqueue_packed_pop(VirtQueue *vq, size_t
sz)
elem->index = id;
elem->ndescs = (desc_cache == &indirect_desc_cache) ? 1 : elem_entries;
+
+ if (virtio_vdev_has_feature(vdev, VIRTIO_F_IN_ORDER)) {
+ vq->used_elems[vq->last_avail_idx].index = elem->index;
+ vq->used_elems[vq->last_avail_idx].len = elem->len;
+ vq->used_elems[vq->last_avail_idx].ndescs = elem->ndescs;
+ }
+
vq->last_avail_idx += elem->ndescs;
vq->inuse += elem->ndescs;
--
MST
- [PULL v2 11/61] hw/cxl/cxl-mailbox-utils: Add support for feature commands (8.2.9.6), (continued)
- [PULL v2 11/61] hw/cxl/cxl-mailbox-utils: Add support for feature commands (8.2.9.6), Michael S. Tsirkin, 2024/07/23
- [PULL v2 12/61] hw/cxl/cxl-mailbox-utils: Add device patrol scrub control feature, Michael S. Tsirkin, 2024/07/23
- [PULL v2 13/61] hw/cxl/cxl-mailbox-utils: Add device DDR5 ECS control feature, Michael S. Tsirkin, 2024/07/23
- [PULL v2 14/61] hw/cxl: Support firmware updates, Michael S. Tsirkin, 2024/07/23
- [PULL v2 15/61] MAINTAINERS: Add myself as a VT-d reviewer, Michael S. Tsirkin, 2024/07/23
- [PULL v2 16/61] virtio-snd: add max size bounds check in input cb, Michael S. Tsirkin, 2024/07/23
- [PULL v2 17/61] virtio-snd: check for invalid param shift operands, Michael S. Tsirkin, 2024/07/23
- [PULL v2 18/61] intel_iommu: fix FRCD construction macro, Michael S. Tsirkin, 2024/07/23
- [PULL v2 19/61] intel_iommu: move VTD_FRCD_PV and VTD_FRCD_PP declarations, Michael S. Tsirkin, 2024/07/23
- [PULL v2 20/61] intel_iommu: fix type of the mask field in VTDIOTLBPageInvInfo, Michael S. Tsirkin, 2024/07/23
- [PULL v2 23/61] virtio: virtqueue_pop - VIRTIO_F_IN_ORDER support,
Michael S. Tsirkin <=
- [PULL v2 21/61] intel_iommu: make type match, Michael S. Tsirkin, 2024/07/23
- [PULL v2 22/61] virtio: Add bool to VirtQueueElement, Michael S. Tsirkin, 2024/07/23
- [PULL v2 24/61] virtio: virtqueue_ordered_fill - VIRTIO_F_IN_ORDER support, Michael S. Tsirkin, 2024/07/23
- [PULL v2 25/61] virtio: virtqueue_ordered_flush - VIRTIO_F_IN_ORDER support, Michael S. Tsirkin, 2024/07/23
- [PULL v2 26/61] vhost,vhost-user: Add VIRTIO_F_IN_ORDER to vhost feature bits, Michael S. Tsirkin, 2024/07/23
- [PULL v2 27/61] virtio: Add VIRTIO_F_IN_ORDER property definition, Michael S. Tsirkin, 2024/07/23
- [PULL v2 28/61] contrib/vhost-user-blk: fix overflowing expression, Michael S. Tsirkin, 2024/07/23
- [PULL v2 29/61] hw/pci: Fix SR-IOV VF number calculation, Michael S. Tsirkin, 2024/07/23
- [PULL v2 30/61] pcie_sriov: Ensure PF and VF are mutually exclusive, Michael S. Tsirkin, 2024/07/23
- [PULL v2 31/61] pcie_sriov: Check PCI Express for SR-IOV PF, Michael S. Tsirkin, 2024/07/23