Documentation
¶
Overview ¶
Package afxdp implements pktkit.L2Device over Linux AF_XDP sockets, providing kernel-bypass Ethernet frame I/O via shared memory ring buffers.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrNoBuffers = errors.New("afxdp: no free TX buffers") ErrClosed = errors.New("afxdp: device closed") )
Errors returned by Device operations.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// Interface is the network interface name (e.g. "eth0").
Interface string
// QueueID is the NIC hardware queue to bind to (usually 0).
QueueID int
// RingSize is the size of each ring buffer (must be a power of 2).
// Default: 2048.
RingSize int
// FrameSize is the size of each UMEM frame in bytes.
// Default: 4096.
FrameSize int
// NumFrames is the total number of UMEM frames.
// Default: 4096. Half are used for RX, half for TX.
NumFrames int
// Copy forces XDP_COPY mode. By default the driver tries zero-copy
// first and falls back to copy mode if the NIC doesn't support it.
Copy bool
// XSKMapFD, if > 0, uses an existing XSKMAP instead of loading a
// BPF program automatically. The caller is responsible for loading
// their own XDP program and creating the map.
XSKMapFD int
// Flags are additional XDP socket bind flags (e.g. unix.XDP_USE_NEED_WAKEUP).
Flags uint16
}
Config configures an AF_XDP device.
type Device ¶
type Device struct {
// contains filtered or unexported fields
}
Device is an L2 network device backed by a Linux AF_XDP socket. It implements pktkit.L2Device.
func New ¶
New creates a new AF_XDP device bound to the given interface and queue. It sets up UMEM, ring buffers, and optionally loads a minimal XDP BPF program.
func (*Device) Done ¶
func (d *Device) Done() <-chan struct{}
Done returns a channel that is closed when the device is shut down.
func (*Device) HWAddr ¶
func (d *Device) HWAddr() net.HardwareAddr
HWAddr returns the hardware (MAC) address of the underlying interface.
func (*Device) SetHandler ¶
SetHandler sets the callback invoked for each received Ethernet frame.
func (*Device) Statistics ¶
func (d *Device) Statistics() (unix.XDPStatistics, error)
Statistics returns AF_XDP socket statistics.