pub struct Ring {Show 16 fields
pub id: u64,
pub owner_pid: u32,
pub sq_mapping_cap_id: CapId,
pub sq_frame: PhysFrame,
pub sq_virt: u64,
pub cq_mapping_cap_id: CapId,
pub cq_frame: PhysFrame,
pub cq_virt: u64,
pub entries: u32,
pub in_flight: AtomicU32,
pub destroyed: AtomicU32,
pub cq_lock: SpinLock<()>,
pub completion_backlog: SpinLock<Vec<AsyncCqe>>,
pub sq_order: u8,
pub cq_order: u8,
pub wq: WaitQueue,
}Expand description
A shared submission/completion ring for a single process.
Fields§
§id: u64Opaque handle returned to userspace.
owner_pid: u32Process that owns this ring (by PID).
sq_mapping_cap_id: CapIdStable mapping capability for the SQ pages.
sq_frame: PhysFramePhysical frame backing the SQ page.
sq_virt: u64Kernel virtual address of the SQ metadata header.
cq_mapping_cap_id: CapIdStable mapping capability for the CQ pages.
cq_frame: PhysFramePhysical frame backing the CQ page.
cq_virt: u64Kernel virtual address of the CQ metadata header.
entries: u32Number of entries (power of two, min 2, max MAX_IN_FLIGHT).
in_flight: AtomicU32Number of in-flight operations (not yet completed).
destroyed: AtomicU32Whether this ring has been destroyed (no new ops accepted).
cq_lock: SpinLock<()>Lock for pushing completions.
completion_backlog: SpinLock<Vec<AsyncCqe>>Completions retained temporarily when the visible CQ is full.
sq_order: u8Order used for SQ allocation.
cq_order: u8Order used for CQ allocation.
wq: WaitQueueWait queue for tasks blocked on this ring.
Implementations§
Source§impl Ring
impl Ring
Sourcepub fn create(pid: u32, entries: u32) -> Result<u64, RingError>
pub fn create(pid: u32, entries: u32) -> Result<u64, RingError>
Create a new ring and map it into the calling process’s address space.
Sourcepub fn map_into_process(
&self,
addr_space: &AddressSpace,
) -> Result<AsyncRingMapping, &'static str>
pub fn map_into_process( &self, addr_space: &AddressSpace, ) -> Result<AsyncRingMapping, &'static str>
Map the SQ and CQ buffers into the provided address space.
fn contiguous_phys_addrs(&self, frame: PhysFrame, page_count: usize) -> Vec<u64>
Sourcepub fn sq_advance_head(&self, count: u32)
pub fn sq_advance_head(&self, count: u32)
Advance the SQ head after processing submissions.
Sourcepub fn cq_advance_tail(&self, count: u32)
pub fn cq_advance_tail(&self, count: u32)
Advance the CQ tail after pushing completions.
Sourcepub unsafe fn sqe_at(&self, index: u32) -> *const AsyncSqe
pub unsafe fn sqe_at(&self, index: u32) -> *const AsyncSqe
Get a pointer to the SQE at the given index.
Sourcepub unsafe fn cqe_at(&self, index: u32) -> *mut AsyncCqe
pub unsafe fn cqe_at(&self, index: u32) -> *mut AsyncCqe
Get a mutable pointer to the CQE at the given index.
pub(crate) fn sq_meta(&self) -> &RingMeta
pub(crate) fn cq_meta(&self) -> &RingMeta
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Ring
impl !RefUnwindSafe for Ring
impl Send for Ring
impl Sync for Ring
impl Unpin for Ring
impl UnsafeUnpin for Ring
impl UnwindSafe for Ring
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more