Skip to main content

DeviceRing

Struct DeviceRing 

Source
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>

Source

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.

Source

pub fn into_memory(self) -> M

The memory the queue is in, given back: the queue is over.

Source

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.

Source

pub const fn addresses(&self) -> RingAddresses

The addresses the queue was given.

Source

pub const fn in_flight(&self) -> u16

Chains the device holds: taken and not yet used.

Trait Implementations§

Source§

impl<M: Debug, E: Debug, const N: usize, const R: usize> Debug for DeviceRing<M, E, N, R>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<M, E, const N: usize, const R: usize> DeviceQueue for DeviceRing<M, E, N, R>

Source§

type Chain = DeviceRingChain<M, E, R>

Owned consumed-chain type.
Source§

type Error = DeviceRingError

Concrete transport failure.
Source§

fn pop_available( &mut self, ) -> Result<Option<Self::Chain>, QueueError<Self::Error>>

Consume one available descriptor chain. Read more
Source§

fn complete( &mut self, chain: Self::Chain, used: UsedLength, ) -> Result<NotificationHint, QueueError<Self::Error>>

Publish one chain completion and consume its ownership token. Read more
Source§

fn disable_available_notifications( &mut self, ) -> Result<(), QueueError<Self::Error>>

Disable available-ring notifications before draining work. Read more
Source§

fn enable_available_notifications( &mut self, ) -> Result<NotificationRecheck, QueueError<Self::Error>>

Enable available-ring notifications and atomically recheck for missed work. Read more
Source§

fn reset( &mut self, next_epoch: QueueEpoch, ) -> Result<(), QueueError<Self::Error>>

Invalidate all consumed chains from the old epoch and return the queue to its base state. Read more
Source§

impl<M, E, const N: usize, const R: usize> QueueControl for DeviceRing<M, E, N, R>

Source§

type Error = DeviceRingError

Concrete transport configuration error.
Source§

fn configure(&mut self, size: QueueSize) -> Result<(), QueueError<Self::Error>>

Configure queue size while the queue is not ready. Read more
Source§

fn set_ready(&mut self, ready: bool) -> Result<(), QueueError<Self::Error>>

Enable or disable queue descriptor processing. Read more
Source§

impl<M, E, const N: usize, const R: usize> QueuePort for DeviceRing<M, E, N, R>

Source§

fn state(&self) -> QueueState

Return a coherent queue-state snapshot. Read more

Auto Trait Implementations§

§

impl<M, E, const N: usize, const R: usize> Freeze for DeviceRing<M, E, N, R>
where M: Freeze, E: Freeze,

§

impl<M, E, const N: usize, const R: usize> RefUnwindSafe for DeviceRing<M, E, N, R>

§

impl<M, E, const N: usize, const R: usize> Send for DeviceRing<M, E, N, R>
where M: Send, E: Send,

§

impl<M, E, const N: usize, const R: usize> Sync for DeviceRing<M, E, N, R>
where M: Sync, E: Sync,

§

impl<M, E, const N: usize, const R: usize> Unpin for DeviceRing<M, E, N, R>
where M: Unpin, E: Unpin,

§

impl<M, E, const N: usize, const R: usize> UnsafeUnpin for DeviceRing<M, E, N, R>
where M: UnsafeUnpin, E: UnsafeUnpin,

§

impl<M, E, const N: usize, const R: usize> UnwindSafe for DeviceRing<M, E, N, R>
where M: UnwindSafe, E: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.