15 #include <sys/types.h>
25 #define LPORT_NAME_LEN 32
26 #define LPORT_FRAME_SIZE 2048
27 #define LPORT_MBUF_OVERHEAD sizeof(struct pkt_buf)
28 #define LPORT_DATA_HEADROOM XDP_PACKET_HEADROOM
29 #define LPORT_DFLT_RX_NUM_DESCS XSK_RING_CONS__DEFAULT_NUM_DESCS
30 #define LPORT_DFLT_TX_NUM_DESCS (XSK_RING_CONS__DEFAULT_NUM_DESCS * 2)
31 #define LPORT_FRAME_SHIFT 11
32 #define LPORT_DFLT_START_QUEUE_IDX 0
33 #define LPORT_DFLT_QUEUE_COUNT 1
34 #define LPORT_RX_BATCH_SIZE 256
35 #define LPORT_TX_BATCH_SIZE 256
37 typedef int (*buf_alloc_t)(
void *arg,
void **bufs, uint16_t nb_pkts);
38 typedef void (*buf_free_t)(
void *arg,
void **bufs, uint16_t nb_pkts);
39 typedef void (*buf_set_len_t)(
void *buf,
int len);
40 typedef void (*buf_set_data_len_t)(
void *buf,
int len);
41 typedef void (*buf_set_data_t)(
void *buf, uint64_t off);
42 typedef void (*buf_reset_t)(
void *buf, uint32_t buf_len,
size_t headroom);
43 typedef void **(*buf_inc_ptr_t)(
void **buf);
44 typedef uint16_t (*buf_get_data_len_t)(
void *buf);
45 typedef uint64_t (*buf_get_data_t)(
void *buf);
46 typedef uint64_t (*buf_get_addr_t)(
void *buf);
47 typedef uint16_t (*buf_rx_burst_t)(
void *arg,
void **bufs, uint16_t nb_pkts);
48 typedef uint16_t (*buf_tx_burst_t)(
void *arg,
void **bufs, uint16_t nb_pkts);
50 typedef struct lport_buf_mgmt {
51 buf_alloc_t buf_alloc;
53 buf_set_len_t buf_set_len;
54 buf_set_data_len_t buf_set_data_len;
55 buf_set_data_t buf_set_data;
56 buf_reset_t buf_reset;
57 buf_get_data_len_t buf_get_data_len;
58 buf_get_data_t buf_get_data;
59 buf_get_addr_t buf_get_addr;
60 buf_inc_ptr_t buf_inc_ptr;
63 size_t pool_header_sz;
65 buf_rx_burst_t buf_rx_burst;
66 buf_tx_burst_t buf_tx_burst;
70 typedef struct lport_cfg {
71 char name[LPORT_NAME_LEN];
72 char ifname[LPORT_NAME_LEN];
73 char pmd_name[LPORT_NAME_LEN];
80 uint16_t busy_timeout;
88 lport_buf_mgmt_t buf_mgmt;
92 #define LPORT_UNPRIVILEGED (1 << 0)
93 #define LPORT_FORCE_WAKEUP (1 << 1)
94 #define LPORT_SKB_MODE (1 << 2)
95 #define LPORT_BUSY_POLLING (1 << 3)
96 #define LPORT_SHARED_UMEM (1 << 4)
97 #define LPORT_USER_MANAGED_BUFFERS (1 << 5)
98 #define LPORT_UMEM_UNALIGNED_BUFFERS (1 << 6)
100 typedef struct lport_stats {
112 uint64_t rx_ring_empty;
113 uint64_t rx_buf_alloc;
114 uint64_t rx_busypoll_wakeup;
115 uint64_t rx_poll_wakeup;
116 uint64_t rx_rcvd_count;
117 uint64_t rx_burst_called;
118 #if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 9, 0)
119 uint64_t rx_ring_full;
120 uint64_t rx_fill_ring_empty;
121 uint64_t tx_ring_empty;
124 uint64_t fq_add_count;
125 uint64_t fq_alloc_failed;
126 uint64_t fq_buf_freed;
129 uint64_t tx_kick_failed;
130 uint64_t tx_kick_again;
131 uint64_t tx_ring_full;
135 uint64_t cq_buf_freed;
struct lport_cfg lport_cfg_t