Skip to main content

NetQueueHeader

Struct NetQueueHeader 

Source
#[repr(C)]
pub struct NetQueueHeader {
Show 21 fields pub magic: u32, pub abi: u16, pub flags: u16, pub qid: u16, pub frame_size: u16, pub slots: u16, pub reserved0: u16, pub features: AtomicU64, pub rx: NetRing, pub tx: NetRing, pub rx_bitmap: [AtomicU64; 4], pub tx_bitmap: [AtomicU64; 4], pub rx_dropped: AtomicU64, pub tx_dropped: AtomicU64, pub irq_count: AtomicU64, pub poll_count: AtomicU64, pub epoch: AtomicU32, pub link: AtomicU32, pub speed_mbps: AtomicU32, pub mtu: AtomicU32, pub reserved: [u8; 64],
}
Expand description

Header of a shared network queue.

The structure is placed at offset 0 of the mapped region. It contains only atomics and plain integers so it has the same layout in kernel and userspace.

Fields§

§magic: u32§abi: u16§flags: u16§qid: u16§frame_size: u16§slots: u16§reserved0: u16§features: AtomicU64

Negotiated features::* bits.

§rx: NetRing§tx: NetRing§rx_bitmap: [AtomicU64; 4]

Slot allocation bitmaps (bit set = slot owned).

§tx_bitmap: [AtomicU64; 4]§rx_dropped: AtomicU64§tx_dropped: AtomicU64§irq_count: AtomicU64§poll_count: AtomicU64§epoch: AtomicU32

Device generation; bumped on hotplug/reset.

§link: AtomicU32

link_flags::*.

§speed_mbps: AtomicU32

Last observed link speed in Mbps (0 = unknown).

§mtu: AtomicU32

Maximum transmission unit (IP payload).

§reserved: [u8; 64]

Implementations§

Source§

impl NetQueueHeader

Source

pub unsafe fn init( ptr: *mut Self, qid: u16, features: u64, mtu: u32, epoch: u32, )

Initialise a raw header in place.

§Safety

ptr must point to at least NET_QUEUE_SIZE writable bytes aligned to 8 bytes.

Source

pub fn is_valid(&self) -> bool

Source

pub fn as_ptr(&self) -> *mut u8

Source

pub unsafe fn rx_descs(&self) -> *mut NetFrameDesc

§Safety

self must be the header of a valid NET_QUEUE_SIZE region.

Source

pub unsafe fn tx_descs(&self) -> *mut NetFrameDesc

§Safety

self must be the header of a valid NET_QUEUE_SIZE region.

Source

pub unsafe fn rx_slot(&self, slot: u32) -> *mut u8

§Safety

self must be the header of a valid NET_QUEUE_SIZE region.

Source

pub unsafe fn tx_slot(&self, slot: u32) -> *mut u8

§Safety

self must be the header of a valid NET_QUEUE_SIZE region.

Source

pub fn alloc_rx_slot(&self) -> Option<u32>

Allocate a free RX slot.

Source

pub fn free_rx_slot(&self, slot: u32)

Release an RX slot previously returned by alloc_rx_slot.

Source

pub fn alloc_tx_slot(&self) -> Option<u32>

Allocate a free TX slot.

Source

pub fn free_tx_slot(&self, slot: u32)

Release a TX slot previously returned by alloc_tx_slot.

Source

pub unsafe fn rx_push(&self, desc: NetFrameDesc) -> bool

Publish an RX descriptor (kernel/device side).

§Safety

self must be a valid header and the caller must be the single RX producer.

Source

pub unsafe fn rx_pop(&self) -> Option<NetFrameDesc>

Consume an RX descriptor (stack side).

§Safety

self must be a valid header and the caller must be the single RX consumer.

Source

pub unsafe fn tx_push(&self, desc: NetFrameDesc) -> bool

Publish a TX descriptor (stack side).

§Safety

self must be a valid header and the caller must be the single TX producer.

Source

pub unsafe fn tx_pop(&self) -> Option<NetFrameDesc>

Consume a TX descriptor (kernel/device side).

§Safety

self must be a valid header and the caller must be the single TX consumer.

Auto Trait Implementations§

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.

§

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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.