#[repr(C)]pub struct Descriptor {
pub addr: u64,
pub len: u32,
pub id: u16,
pub flags: u16,
}Fields§
§addr: u64Physical address of the buffer.
len: u32Length of the buffer in bytes. For used descriptors, this contains bytes written by device.
id: u16Buffer ID - used to correlate completions with submissions. All descriptors in a chain share the same ID.
flags: u16Flags (NEXT, WRITE, INDIRECT, AVAIL, USED).
Implementations§
Source§impl Descriptor
impl Descriptor
pub const ALIGN: usize = 16
pub const SIZE: usize
pub const ADDR_OFFSET: usize
pub const LEN_OFFSET: usize
pub const ID_OFFSET: usize
pub const FLAGS_OFFSET: usize
pub fn new(addr: u64, len: u32, id: u16, flags: DescFlags) -> Self
Sourcepub fn is_avail(&self, wrap: bool) -> bool
pub fn is_avail(&self, wrap: bool) -> bool
Did the driver make this descriptor available in the current driver round?
Sourcepub fn is_used(&self, wrap: bool) -> bool
pub fn is_used(&self, wrap: bool) -> bool
Did the device mark this descriptor used in the current device round?
Sourcepub fn is_writable(&self) -> bool
pub fn is_writable(&self) -> bool
Is this descriptor writable by the device?
Sourcepub fn mark_avail(&mut self, wrap: bool)
pub fn mark_avail(&mut self, wrap: bool)
Mark descriptor as available according to the driver’s wrap bit. As per the packed-virtqueue description:
- set AVAIL bit to
driver_wrap - set USED bit to
!driver_wrap(inverse)
Sourcepub fn mark_used(&mut self, wrap: bool)
pub fn mark_used(&mut self, wrap: bool)
Mark descriptor as used according to the device’s wrap bit. As per spec: set both USED and AVAIL bits to match device_wrap
Sourcepub fn write_release<M: MemOps>(
&self,
mem: &M,
addr: u64,
) -> Result<(), M::Error>
pub fn write_release<M: MemOps>( &self, mem: &M, addr: u64, ) -> Result<(), M::Error>
Write a descriptor to memory with release semantics for flags at the given base pointer
This is the primary synchronization point for publishing descriptors.
§Invariant
The caller must ensure that addr is valid for writes of Descriptor
Trait Implementations§
Source§impl Clone for Descriptor
impl Clone for Descriptor
Source§fn clone(&self) -> Descriptor
fn clone(&self) -> Descriptor
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for Descriptor
Source§impl Debug for Descriptor
impl Debug for Descriptor
impl Eq for Descriptor
Source§impl From<&Descriptor> for BufferElement
impl From<&Descriptor> for BufferElement
Source§fn from(desc: &Descriptor) -> Self
fn from(desc: &Descriptor) -> Self
Source§impl Hash for Descriptor
impl Hash for Descriptor
Source§impl PartialEq for Descriptor
impl PartialEq for Descriptor
Source§fn eq(&self, other: &Descriptor) -> bool
fn eq(&self, other: &Descriptor) -> bool
self and other values to be equal, and is used by ==.impl Pod for Descriptor
impl StructuralPartialEq for Descriptor
Auto Trait Implementations§
impl Freeze for Descriptor
impl RefUnwindSafe for Descriptor
impl Send for Descriptor
impl Sync for Descriptor
impl Unpin for Descriptor
impl UnsafeUnpin for Descriptor
impl UnwindSafe for Descriptor
Blanket Implementations§
impl<T> AnyBitPattern for Twhere
T: Pod,
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
Source§impl<T> CheckedBitPattern for Twhere
T: AnyBitPattern,
impl<T> CheckedBitPattern for Twhere
T: AnyBitPattern,
Source§type Bits = T
type Bits = T
Self must have the same layout as the specified Bits except for
the possible invalid bit patterns being checked during
is_valid_bit_pattern.Source§fn is_valid_bit_pattern(_bits: &T) -> bool
fn is_valid_bit_pattern(_bits: &T) -> bool
bits
as &Self.