Skip to main content

Ring

Struct Ring 

Source
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: u64

Opaque handle returned to userspace.

§owner_pid: u32

Process that owns this ring (by PID).

§sq_mapping_cap_id: CapId

Stable mapping capability for the SQ pages.

§sq_frame: PhysFrame

Physical frame backing the SQ page.

§sq_virt: u64

Kernel virtual address of the SQ metadata header.

§cq_mapping_cap_id: CapId

Stable mapping capability for the CQ pages.

§cq_frame: PhysFrame

Physical frame backing the CQ page.

§cq_virt: u64

Kernel virtual address of the CQ metadata header.

§entries: u32

Number of entries (power of two, min 2, max MAX_IN_FLIGHT).

§in_flight: AtomicU32

Number of in-flight operations (not yet completed).

§destroyed: AtomicU32

Whether 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: u8

Order used for SQ allocation.

§cq_order: u8

Order used for CQ allocation.

§wq: WaitQueue

Wait queue for tasks blocked on this ring.

Implementations§

Source§

impl Ring

Source

pub fn create(pid: u32, entries: u32) -> Result<u64, RingError>

Create a new ring and map it into the calling process’s address space.

Source

pub fn map_into_process( &self, addr_space: &AddressSpace, ) -> Result<AsyncRingMapping, &'static str>

Map the SQ and CQ buffers into the provided address space.

Source

fn contiguous_phys_addrs(&self, frame: PhysFrame, page_count: usize) -> Vec<u64>

Source

pub fn sq_tail(&self) -> u32

Read the SQ tail (written by userspace, read by kernel).

Source

pub fn sq_head(&self) -> u32

Read the SQ head (written by kernel, read by userspace).

Source

pub fn sq_advance_head(&self, count: u32)

Advance the SQ head after processing submissions.

Source

pub fn cq_advance_tail(&self, count: u32)

Advance the CQ tail after pushing completions.

Source

pub fn cq_head(&self) -> u32

Read the CQ head (written by userspace after consuming).

Source

pub unsafe fn sqe_at(&self, index: u32) -> *const AsyncSqe

Get a pointer to the SQE at the given index.

Source

pub unsafe fn cqe_at(&self, index: u32) -> *mut AsyncCqe

Get a mutable pointer to the CQE at the given index.

Source

pub fn destroy(&self)

Mark the ring as destroyed (no new submissions accepted).

Source

pub(crate) fn sq_meta(&self) -> &RingMeta

Source

pub(crate) fn cq_meta(&self) -> &RingMeta

Trait Implementations§

Source§

impl Drop for Ring

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

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> 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
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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.