|
XenevaOS
|
#include <stdint.h>

Go to the source code of this file.
Classes | |
| struct | NetRingHdr |
| struct | NetsrvAttach |
| struct | NetsrvStats |
Macros | |
| #define | NETSRV_RING_MAGIC 0x3154454Eu /* 'NET1' */ |
| #define | NETSRV_SLOTS 32 /* per ring, a power of two */ |
| #define | NETSRV_SLOT_SIZE 2048 |
| #define | NETSRV_SLOT_HDR 8 |
| #define | NETSRV_MAX_FRAME (NETSRV_SLOT_SIZE - NETSRV_SLOT_HDR) |
| #define | NETSRV_TX_OFFSET 4096 |
| #define | NETSRV_RX_OFFSET (NETSRV_TX_OFFSET + NETSRV_SLOTS * NETSRV_SLOT_SIZE) |
| #define | NETSRV_RING_BYTES (NETSRV_RX_OFFSET + NETSRV_SLOTS * NETSRV_SLOT_SIZE) |
| #define | NETSRV_IOC_ATTACH 0x5501 /* arg: NetsrvAttach */ |
| #define | NETSRV_IOC_DETACH 0x5502 |
| #define | NETSRV_IOC_STATS 0x5503 /* arg: NetsrvStats */ |
| #define | NETSRV_OK 0 |
| #define | NETSRV_E_PERM -1 |
| #define | NETSRV_E_INVAL -2 |
| #define | NETSRV_E_BUSY -3 |
| #define NETSRV_E_BUSY -3 |
| #define NETSRV_E_INVAL -2 |
| #define NETSRV_E_PERM -1 |
| #define NETSRV_IOC_ATTACH 0x5501 /* arg: NetsrvAttach */ |
| #define NETSRV_IOC_DETACH 0x5502 |
| #define NETSRV_IOC_STATS 0x5503 /* arg: NetsrvStats */ |
| #define NETSRV_MAX_FRAME (NETSRV_SLOT_SIZE - NETSRV_SLOT_HDR) |
| #define NETSRV_OK 0 |
| #define NETSRV_RING_BYTES (NETSRV_RX_OFFSET + NETSRV_SLOTS * NETSRV_SLOT_SIZE) |
| #define NETSRV_RING_MAGIC 0x3154454Eu /* 'NET1' */ |
netsrv.h – shared kernel/user ABI between the kernel network proxy (KernelAA64/Net/netproxy.c) and a user-space NIC server (Process/netsrv).
The server allocates one DMA buffer through /dev/hwdev, lays a NetRingHdr at its start followed by two rings of fixed-size frame slots, and passes the buffer's physical address to /dev/netsrv (NETSRV_IOC_ATTACH). The kernel only accepts a buffer that is one of the caller's own DMA allocations. The kernel then registers the adapters "e1000" and "virtio-net" (what the in-kernel driver registered) and the network stack cannot tell the difference.
TX ring: kernel produces (tx_head), server consumes (tx_tail) RX ring: server produces (rx_head), kernel consumes (rx_tail)
head/tail are free-running slot counters. A slot is a u32 frame length, a u32 pad, then the Ethernet frame. The kernel never trusts a length read from the ring and copies a frame out before parsing it.
| #define NETSRV_RX_OFFSET (NETSRV_TX_OFFSET + NETSRV_SLOTS * NETSRV_SLOT_SIZE) |
| #define NETSRV_SLOT_HDR 8 |
| #define NETSRV_SLOT_SIZE 2048 |
| #define NETSRV_SLOTS 32 /* per ring, a power of two */ |
| #define NETSRV_TX_OFFSET 4096 |