pub struct DeviceRing<M, E, const N: usize, const R: usize> { /* private fields */ }Expand description
The device’s half of one split virtqueue in shared memory.
N bounds the queue’s size and R a chain’s descriptors; both are
storage carried inline, so the queue allocates nothing. E is the cell
the queue and every chain it hands out share, so that a reset reaches a
chain the device still holds: an Rc<AtomicU64> where there is a heap, a
&'static AtomicU64 where there is not. The queue sets it; its value
before DeviceRing::new does not matter.
§What the device trusts
Nothing the driver wrote. Every index is checked against the queue’s
size, a chain is walked at most size descriptors with a visited set so
a loop ends, every span must lie in memory the device may reach for its
direction, and a chain is read once: the walk snapshots each
descriptor, and the ports then use the snapshot, so a driver that
rewrites a descriptor after publishing it changes nothing the device
does. A chain that is malformed is not an error of the queue. It is
handed up like any other, its io says why, and the
device completes it with a used length of zero, as the protocol’s
command-chain rules require.
The profile is the protocol’s: direct descriptors only, no indirect tables, no event indices, and the two suppression flags.
Implementations§
Source§impl<M, E, const N: usize, const R: usize> DeviceRing<M, E, N, R>
impl<M, E, const N: usize, const R: usize> DeviceRing<M, E, N, R>
Sourcepub fn new(
memory: M,
current: E,
max_size: QueueSize,
max_chain_descriptors: u16,
) -> Option<Self>
pub fn new( memory: M, current: E, max_size: QueueSize, max_chain_descriptors: u16, ) -> Option<Self>
A queue in memory of at most max_size descriptors, whose chains
are at most max_chain_descriptors long. Unconfigured: the driver
sets its size and addresses and makes it ready.
None when the limits do not fit: a queue no larger than N, and a
chain of two descriptors at least, no longer than R or the queue.
Sourcepub fn into_memory(self) -> M
pub fn into_memory(self) -> M
The memory the queue is in, given back: the queue is over.
Sourcepub fn set_addresses(
&mut self,
addresses: RingAddresses,
) -> Result<(), QueueError<DeviceRingError>>
pub fn set_addresses( &mut self, addresses: RingAddresses, ) -> Result<(), QueueError<DeviceRingError>>
Where the driver says the queue’s parts are. Taken while the queue is not ready, and checked when it is made so.
Sourcepub const fn addresses(&self) -> RingAddresses
pub const fn addresses(&self) -> RingAddresses
The addresses the queue was given.