1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
//! # afxdp-rs
//!
//! A Rust library for using AF_XDP (XSK) Linux sockets.
//!
//! For information on AF_XDP, see the Linux kernel [docs](https://www.kernel.org/doc/html/latest/networking/af_xdp.html).
//!
//! This implementation is focused on routing, switching and other high packet rate use cases. This implies:
//! * It must be possible to receive packets on one NIC and write them out any another (shared umem or shared MMAP area)
//! * It is appropriate to dedicate threads or cores to packet processing tasks
//! * There is a focus on low latency
//!
//! Several example programs exist in the [examples/](https://github.com/aterlo/afxdp-rs/tree/master/examples) directory.
/// Buf is the trait that is used to represent a packet buffer.
/// BufMMap is the primary implementation of [Buf](crate::buf::Buf) for use with AF_XDP sockets.
/// BufPool is a trait which represents a pool of buffers.
/// BufPoolVec is an implementation of the [BufPool](crate::buf_pool::BufPool) trait based on Vec.
/// BufVec is an implementation of the [Buf](crate::buf::Buf) trait that is easier to use in tests because it doesn't require the
/// all of the AF_XDP infrastructure to be configured.
/// MMapArea is a region of memory that is shared with one or more NICs via one or more [UMem](crate::umem::Umem)s.
/// The Socket module represents an AF_XDP (XSK) socket which is used to transmit or receive packets.
/// The Umem module represents a shared memory area shared with the NIC and one or more sockets (shared Umem).
/// Utilities
/// PENDING_LEN is the size of the circular buffer used when reading from and writing to the socket.
pub const PENDING_LEN: usize = 4096;
/// AF_XDP_RESERVED is the number of bytes reserved at the front of the buffer for the driver. Note this is different
/// from user configurable headroom.
pub const AF_XDP_RESERVED: u64 = 256;