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 of32768
).
Fields§
§descriptor_table: Mapped<[Descriptor]>
§available_ring: Mapped<AvailableRing>
§used_ring: Mapped<UsedRing>
Implementations§
Source§impl Virtqueue
impl Virtqueue
pub fn new<M>(queue_size: u16, mapper: &M) -> Virtqueuewhere
M: Mapper,
Sourcepub fn push_descriptor(&mut self, index: u16, descriptor: Descriptor)
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.
Sourcepub fn make_descriptor_available(&mut self, index: u16)
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.
pub fn alloc_descriptor(&mut self) -> Option<u16>
pub fn free_descriptor(&mut self, index: u16)
Auto Trait Implementations§
impl Freeze for Virtqueue
impl RefUnwindSafe for Virtqueue
impl !Send for Virtqueue
impl !Sync for Virtqueue
impl Unpin for Virtqueue
impl UnwindSafe for Virtqueue
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more