Skip to main content

DriverRing

Struct DriverRing 

Source
pub struct DriverRing<M, const N: usize, const R: usize> { /* private fields */ }
Expand description

The driver’s half of one split virtqueue in shared memory.

N bounds the queue’s size and R a chain’s regions; both are storage the value carries inline, so the queue allocates nothing. One owner: every operation takes &mut self, and there is no lock.

§What the driver trusts

Nothing the device wrote, and nothing it can write. The descriptor table is never read back: the free list, each chain’s links and its room are kept here, so a device that rewrites a descriptor changes nothing the driver does. A used entry is checked before it is believed — the head must be a chain the device holds, the length no more than the chain’s writable bytes, and the used index no further ahead than chains are outstanding. A device that fails any of them has stopped being a device: the queue refuses every operation from then on (DriverRingError::UsedIndex, DriverRingError::UsedEntry) until it is reset, which is also what the driver owes the device.

The profile is the protocol’s: direct descriptors only, no indirect tables, no event indices, and the two suppression flags.

Implementations§

Source§

impl<M: SharedMemory + Clone + Debug, const N: usize, const R: usize> DriverRing<M, N, R>

Source

pub fn new( memory: M, 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 configures a size, says where the parts are (set_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 set_addresses( &mut self, addresses: RingAddresses, ) -> Result<(), QueueError<DriverRingError>>

Where the queue’s parts are. Taken while the queue is not ready and the device holds nothing, and checked when the queue is made ready.

Source

pub const fn addresses(&self) -> RingAddresses

The addresses the queue was given: what the transport is told.

Source

pub const fn outstanding(&self) -> u16

Chains the device holds: published and not yet taken back.

Source

pub const fn free_descriptors(&self) -> u16

Descriptors no chain holds.

Trait Implementations§

Source§

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

Source§

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

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

impl<M: SharedMemory + Clone + Debug, const N: usize, const R: usize> DriverQueue for DriverRing<M, N, R>

Source§

type Chain = DriverChain<M, R>

Driver-owned command and descriptor resources.
Source§

type Reclaimed = ReclaimedChains<M, N, R>

Owned collection of chains reclaimed by reset.
Source§

type Error = DriverRingError

Concrete transport failure.
Source§

fn publish( &mut self, chain: Self::Chain, ) -> Result<PublishedChain, PublishError<Self::Chain, Self::Error>>

Publish a complete chain or return it unchanged on pre-publication backpressure. Read more
Source§

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

Consume one used entry and recover the corresponding driver chain. Read more
Source§

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

Disable used-ring notifications before draining completions. Read more
Source§

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

Enable used-ring notifications and atomically recheck for missed completions. Read more
Source§

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

Invalidate the old epoch and recover every chain still owned by the queue. Read more
Source§

impl<M: SharedMemory + Clone + Debug, const N: usize, const R: usize> QueueControl for DriverRing<M, N, R>

Source§

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

Making the queue ready checks the layout. The first time after it was sized or placed it also clears both rings’ headers, because the memory may have held a queue before: do that before the transport is told the queue is live, while the memory is still only the driver’s. A queue made not ready and ready again is a pause, and resumes where it was.

Source§

type Error = DriverRingError

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§

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

Source§

fn state(&self) -> QueueState

Return a coherent queue-state snapshot. Read more

Auto Trait Implementations§

§

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

§

impl<M, const N: usize, const R: usize> RefUnwindSafe for DriverRing<M, N, R>
where M: RefUnwindSafe,

§

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

§

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

§

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

§

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

§

impl<M, const N: usize, const R: usize> UnwindSafe for DriverRing<M, N, R>
where M: 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.