[RFC 5/8] virtio-net: in-order handling
Jonah Palmer <[email protected]> Thu, 21 Mar 2024 11:57:14 -0400
| Newsgroups | dev.linux.lists.virtio-fs,org.nongnu.qemu-devel |
|---|---|
| Message-ID | <[email protected]> |
Implements in-order handling for the virtio-net device. Since virtio-net utilizes batching for its Rx VirtQueue, the device is responsible for calling virtqueue_flush once it has completed its batching operation. Note: ----- It's unclear if this implementation is really necessary to "guarantee" that used VirtQueueElements are put on the used ring in-order since, by design, virtio-net already does this with its Rx VirtQueue. Signed-off-by: Jonah Palmer <[email protected]> --- hw/net/virtio-net.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 9959f1932b..b0375f7e5e 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -2069,7 +2069,11 @@ static ssize_t virtio_net_receive_rcu(NetClientState *nc, const uint8_t *buf, for (j = 0; j < i; j++) { /* signal other side */ - virtqueue_fill(q->rx_vq, elems[j], lens[j], j); + if (virtio_vdev_has_feature(vdev, VIRTIO_F_IN_ORDER)) { + virtqueue_order_element(q->rx_vq, elems[j], lens[j], j, 0); + } else { + virtqueue_fill(q->rx_vq, elems[j], lens[j], j); + } g_free(elems[j]); } -- 2.39.3