Struct Virtqueue

Source
pub struct Virtqueue {
    pub descriptor_table: Mapped<[Descriptor]>,
    pub available_ring: Mapped<AvailableRing>,
    pub used_ring: Mapped<UsedRing>,
    /* private fields */
}
Expand description

A virtqueue is the mechanism used for bulk data transport to and from Virtio devices. We use the split virtqueue representation - the first format of virtqueue supported by Virtio.

Buffers can be added to the virtqueue to make requests of the device. Devices then execute these requests, and when complete, mark the buffers as ‘used’ by the device.

A split virtqueue is comprised of three “areas”, each of which can be separately allocated:

  • The Descriptor Table (of size 16 * Queue Size)
  • The Available Ring (of size 6 + 2 * Queue Size)
  • The Used Ring (of size 6 + 8 * Queue Size) The queue size is found in a transport-specific way (and is a maximum of 32768).

Fields§

§descriptor_table: Mapped<[Descriptor]>§available_ring: Mapped<AvailableRing>§used_ring: Mapped<UsedRing>

Implementations§

Source§

impl Virtqueue

Source

pub fn new<M>(queue_size: u16, mapper: &M) -> Virtqueue
where M: Mapper,

Source

pub fn push_descriptor(&mut self, index: u16, descriptor: Descriptor)

Push a descriptor into the descriptor table, returning its index. Returns None if there is no space left in the table.

Source

pub fn make_descriptor_available(&mut self, index: u16)

Make the descriptor chain starting at index available to the device, allowing it to start servicing the described request.

Source

pub fn alloc_descriptor(&mut self) -> Option<u16>

Source

pub fn free_descriptor(&mut self, index: u16)

Auto Trait Implementations§

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.