Struct SplitVirtqueue

Source
pub struct SplitVirtqueue<'a, 'b, const MAX_QUEUE_SIZE: usize> { /* private fields */ }
Expand description

A VirtIO split Virtqueue.

For documentation on Virtqueues in general, please see the Virtqueue trait documentation.

A split Virtqueue is split into separate memory areas, namely:

Each of these areas must be located physically-contiguous in guest-memory and have different alignment constraints.

This is in constrast to packed Virtqueues, which use memory regions that are read and written by both the VirtIO device (host) and VirtIO driver (guest).

Implementations§

Source§

impl<'a, 'b, const MAX_QUEUE_SIZE: usize> SplitVirtqueue<'a, 'b, MAX_QUEUE_SIZE>

Source

pub fn new( descriptors: &'a mut VirtqueueDescriptors<MAX_QUEUE_SIZE>, available_ring: &'a mut VirtqueueAvailableRing<MAX_QUEUE_SIZE>, used_ring: &'a mut VirtqueueUsedRing<MAX_QUEUE_SIZE>, ) -> Self

Source

pub fn set_client(&self, client: &'a dyn SplitVirtqueueClient<'b>)

Source

pub fn set_transport(&self, transport: &'a dyn VirtIOTransport)

Set the underlying VirtIOTransport. This must be done prior to initialization.

Source

pub fn queue_number(&self) -> Option<u32>

Get the queue number associated with this Virtqueue.

Prior to initialization the SplitVirtqueue does not have an associated queue number and will return None.

Source

pub fn free_descriptor_count(&self) -> usize

Get the number of free descriptor slots in the descriptor table.

This takes into account the negotiated maximum queue length.

Source

pub fn used_descriptor_chains_count(&self) -> usize

Get the number of (unprocessed) descriptor chains in the Virtqueue’s used ring.

Source

pub fn provide_buffer_chain( &self, buffer_chain: &mut [Option<VirtqueueBuffer<'b>>], ) -> Result<(), ErrorCode>

Provide a single chain of buffers to the device.

This method will iterate over the passed slice until it encounters the first None. It will first validate that the number of buffers can be inserted into its descriptor table, and if not return Err(ErrorCode::NOMEM). If sufficient space is available, it takes the passed buffers out of the provided Options until encountering the first None and shares this buffer chain with the device.

When the device has finished processing the passed buffer chain, it is returned to the client either through the SplitVirtqueueClient::buffer_chain_ready callback, or can be retrieved through the SplitVirtqueue::pop_used_buffer_chain method.

Source

pub fn pop_used_buffer_chain( &self, ) -> Option<([Option<VirtqueueBuffer<'b>>; MAX_QUEUE_SIZE], usize)>

Attempt to take a buffer chain out of the Virtqueue used ring.

Returns None if the used ring is empty.

Source

pub fn enable_used_callbacks(&self)

Disable callback delivery for the SplitVirtqueueClient::buffer_chain_ready method on the registered client.

Source

pub fn disable_used_callbacks(&self)

Enable callback delivery for the SplitVirtqueueClient::buffer_chain_ready method on the registered client.

Callback delivery is enabled by default. If this is not desired, call this method prior to registering a client.

Trait Implementations§

Source§

impl<const MAX_QUEUE_SIZE: usize> Virtqueue for SplitVirtqueue<'_, '_, MAX_QUEUE_SIZE>

Source§

fn used_interrupt(&self)

Interrupt indicating that a VirtIO device may have placed a buffer into this Virtqueue’s used ring. Read more
Source§

fn physical_addresses(&self) -> VirtqueueAddresses

The physical addresses of the Virtqueue descriptors, available and used ring. Read more
Source§

fn negotiate_queue_size(&self, max_elements: usize) -> usize

Negotiate the number of used descriptors in the Virtqueue. Read more
Source§

fn initialize(&self, queue_number: u32, _queue_elements: usize)

Initialize the Virtqueue. Read more

Auto Trait Implementations§

§

impl<'a, 'b, const MAX_QUEUE_SIZE: usize> !Freeze for SplitVirtqueue<'a, 'b, MAX_QUEUE_SIZE>

§

impl<'a, 'b, const MAX_QUEUE_SIZE: usize> !RefUnwindSafe for SplitVirtqueue<'a, 'b, MAX_QUEUE_SIZE>

§

impl<'a, 'b, const MAX_QUEUE_SIZE: usize> !Send for SplitVirtqueue<'a, 'b, MAX_QUEUE_SIZE>

§

impl<'a, 'b, const MAX_QUEUE_SIZE: usize> !Sync for SplitVirtqueue<'a, 'b, MAX_QUEUE_SIZE>

§

impl<'a, 'b, const MAX_QUEUE_SIZE: usize> Unpin for SplitVirtqueue<'a, 'b, MAX_QUEUE_SIZE>

§

impl<'a, 'b, const MAX_QUEUE_SIZE: usize> !UnwindSafe for SplitVirtqueue<'a, 'b, MAX_QUEUE_SIZE>

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.