Skip to main content

Module in_order

Module in_order 

Source
Expand description

In-order completion discipline layered on top of a VirtioQueue.

Some devices (notably virtio-net) require that the used ring be published strictly in the order descriptors were consumed from the available ring, even though work may complete out of order (e.g. a network backend that finishes packets in a different order, or descriptors that are dropped early). This makes the outstanding set exactly the contiguous [used_index, avail_index) range, which enables a simple cursor-based save/restore.

This is deliberately a side helper whose methods borrow a VirtioQueue, rather than being baked into the queue itself. Devices that do not need in-order completion (virtio-blk, virtio-vsock, …) never instantiate it and pay nothing — the queue’s hot path is untouched. It uses only the queue’s public API, mirroring QEMU’s virtqueue_ordered_fill/virtqueue_ordered_flush (used_elems): consumed descriptors are recorded in consumption order, completions fill their slot (possibly out of order), and only the contiguous filled prefix is published to the used ring, in order.

Structs§

InOrderCompletion
Enforces in-order used-ring publication for a single VirtioQueue.