#[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: AtomicU64Negotiated 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: AtomicU32Device generation; bumped on hotplug/reset.
link: AtomicU32link_flags::*.
speed_mbps: AtomicU32Last observed link speed in Mbps (0 = unknown).
mtu: AtomicU32Maximum transmission unit (IP payload).
reserved: [u8; 64]Implementations§
Source§impl NetQueueHeader
impl NetQueueHeader
Sourcepub unsafe fn init(
ptr: *mut Self,
qid: u16,
features: u64,
mtu: u32,
epoch: u32,
)
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.
pub fn is_valid(&self) -> bool
pub fn as_ptr(&self) -> *mut u8
Sourcepub unsafe fn rx_descs(&self) -> *mut NetFrameDesc
pub unsafe fn rx_descs(&self) -> *mut NetFrameDesc
§Safety
self must be the header of a valid NET_QUEUE_SIZE region.
Sourcepub unsafe fn tx_descs(&self) -> *mut NetFrameDesc
pub unsafe fn tx_descs(&self) -> *mut NetFrameDesc
§Safety
self must be the header of a valid NET_QUEUE_SIZE region.
Sourcepub unsafe fn rx_slot(&self, slot: u32) -> *mut u8
pub unsafe fn rx_slot(&self, slot: u32) -> *mut u8
§Safety
self must be the header of a valid NET_QUEUE_SIZE region.
Sourcepub unsafe fn tx_slot(&self, slot: u32) -> *mut u8
pub unsafe fn tx_slot(&self, slot: u32) -> *mut u8
§Safety
self must be the header of a valid NET_QUEUE_SIZE region.
Sourcepub fn alloc_rx_slot(&self) -> Option<u32>
pub fn alloc_rx_slot(&self) -> Option<u32>
Allocate a free RX slot.
Sourcepub fn free_rx_slot(&self, slot: u32)
pub fn free_rx_slot(&self, slot: u32)
Release an RX slot previously returned by alloc_rx_slot.
Sourcepub fn alloc_tx_slot(&self) -> Option<u32>
pub fn alloc_tx_slot(&self) -> Option<u32>
Allocate a free TX slot.
Sourcepub fn free_tx_slot(&self, slot: u32)
pub fn free_tx_slot(&self, slot: u32)
Release a TX slot previously returned by alloc_tx_slot.
Sourcepub unsafe fn rx_push(&self, desc: NetFrameDesc) -> bool
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.
Sourcepub unsafe fn rx_pop(&self) -> Option<NetFrameDesc>
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.
Sourcepub unsafe fn tx_push(&self, desc: NetFrameDesc) -> bool
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.
Sourcepub unsafe fn tx_pop(&self) -> Option<NetFrameDesc>
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.