Skip to main content

Module net

Module net 

Source
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/tail counters, 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 end

Re-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 u64 bits so the ABI does not depend on bitflags.
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.
NetFrameDesc
One frame descriptor, 16 bytes.
NetLinkInfo
Result of SYS_NET_LINK.
NetQueueHeader
Header of a shared network queue.
NetQueueInfo
Result of SYS_NET_QUEUE_INFO.
NetQueueMap
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.