pub struct Layout { /* private fields */ }Expand description
Layout of a packed virtqueue ring in shared memory.
Describes the memory addresses for the descriptor table and event suppression
structures. Use from_base to compute the layout from a
base address, or query_size to determine memory requirements.
§Memory Layout
The packed ring consists of:
- Descriptor table:
num_descs× 16 bytes, aligned to 16 bytes - Driver event suppression: 4 bytes, aligned to 4 bytes
- Device event suppression: 4 bytes, aligned to 4 bytes
Implementations§
Source§impl Layout
impl Layout
Sourcepub const unsafe fn from_base(
base: u64,
num_descs: NonZeroU16,
) -> Result<Self, RingError>
pub const unsafe fn from_base( base: u64, num_descs: NonZeroU16, ) -> Result<Self, RingError>
Create a Layout from a base address and number of descriptors.
The base address must be aligned to Descriptor::ALIGN.
The number of descriptors must be a power of 2.
The memory region starting at base must be at least Layout::query_size(num_descs) bytes.
§Safety
basemust be valid forLayout::query_size(num_descs)bytes.basemust be aligned toDescriptor::ALIGN.- Memory must remain valid for the lifetime of the ring.
Sourcepub const fn desc_table_addr(&self) -> u64
pub const fn desc_table_addr(&self) -> u64
Packed ring descriptor table base in shared memory.
Sourcepub const fn desc_table_len(&self) -> u16
pub const fn desc_table_len(&self) -> u16
Number of descriptors in the ring.
Sourcepub const fn drv_evt_addr(&self) -> u64
pub const fn drv_evt_addr(&self) -> u64
Driver-written event suppression area in shared memory.
Sourcepub const fn dev_evt_addr(&self) -> u64
pub const fn dev_evt_addr(&self) -> u64
Device-written event suppression area in shared memory.
Sourcepub const fn query_size(num_descs: usize) -> usize
pub const fn query_size(num_descs: usize) -> usize
Calculate the memory size needed for a ring with num_descs descriptors,
accounting for alignment requirements.