Expand description
Shared-memory network queue ABI.
This module is the single source of truth for the layout that the kernel
and a userspace networking strate share. It is deliberately independent
of the device model: any NIC (e1000, virtio-net, vmxnet3, …) can expose a
NetQueueHeader region and let the stack drive its rings directly.
Design rules:
- one producer and one consumer per direction (RX and TX);
- free-running
head/tailcounters, power-of-two ring size; - frame slots live in a pool inside the same mapped region;
- slot ownership is tracked by a bitmap, not by a free list, so the consumer can release a slot without another ring;
- no allocation, no lock, no syscall once the region is mapped.
Layout (all offsets stable, region is page-aligned):
0x0000 NetQueueHeader
0x0100 RX descriptors (NET_RING_SLOTS × 16 bytes)
0x1100 TX descriptors (NET_RING_SLOTS × 16 bytes)
0x2100 statistics / reserved
0x3000 RX frame pool (NET_POOL_SLOTS × 2048 bytes)
0x83000 TX frame pool (NET_POOL_SLOTS × 2048 bytes)
0x103000 endRe-exports§
use core::sync::atomic::AtomicU32;🔒use core::sync::atomic::AtomicU64;🔒use core::sync::atomic::Ordering;🔒
Modules§
- event
- Event kinds delivered to a bound IPC port.
- fd_
flags - Frame descriptor flags.
- features
- Negotiated device features. Kept as plain
u64bits so the ABI does not depend onbitflags. - link_
flags - Link flags returned by
SYS_NET_LINK.
Structs§
- NetEvent
- Event delivered to a port bound with
SYS_NET_IRQ_BIND. - NetFrame
- One entry of a batched RX/TX request.
- NetFrame
Desc - One frame descriptor, 16 bytes.
- NetLink
Info - Result of
SYS_NET_LINK. - NetQueue
Header - Header of a shared network queue.
- NetQueue
Info - Result of
SYS_NET_QUEUE_INFO. - NetQueue
Map - Result of
SYS_NET_QUEUE_MAP. - NetRing
- A single-producer / single-consumer descriptor ring.
- NetStats
- Queue statistics.
Constants§
- NET_
FRAME_ SIZE - A frame slot is a fixed 2 KiB cell (enough for a 1514-byte frame plus headroom and a future 1500-byte jumbo-lite path).
- NET_
POOL_ SLOTS - Number of frame slots in each pool (must be a multiple of 64).
- NET_
QUEUE_ ABI - Current ABI revision.
- NET_
QUEUE_ HDR_ SIZE - NET_
QUEUE_ MAGIC "STNQ"little-endian.- NET_
QUEUE_ SIZE - NET_
RING_ SLOTS - Number of descriptors in each direction (must be a power of two).
- NET_
RX_ DESC_ OFF - NET_
RX_ POOL_ OFF - NET_
STATS_ OFF - NET_
TX_ DESC_ OFF - NET_
TX_ POOL_ OFF
Functions§
- bitmap_
alloc - Allocate the first zero bit of a 256-bit bitmap.
- bitmap_
free - Clear a bit in a 256-bit bitmap.