1
2
3
4
5
6
7
8
9
10 #ifndef _LINUX_IF_XDP_H
11 #define _LINUX_IF_XDP_H
12
13 #include <linux/types.h>
14
15
16 #define XDP_SHARED_UMEM (1 << 0)
17 #define XDP_COPY (1 << 1)
18 #define XDP_ZEROCOPY (1 << 2)
19
20
21
22
23
24
25
26
27 #define XDP_USE_NEED_WAKEUP (1 << 3)
28
29
30 #define XDP_UMEM_UNALIGNED_CHUNK_FLAG (1 << 0)
31
32 struct sockaddr_xdp {
33 __u16 sxdp_family;
34 __u16 sxdp_flags;
35 __u32 sxdp_ifindex;
36 __u32 sxdp_queue_id;
37 __u32 sxdp_shared_umem_fd;
38 };
39
40
41 #define XDP_RING_NEED_WAKEUP (1 << 0)
42
43 struct xdp_ring_offset {
44 __u64 producer;
45 __u64 consumer;
46 __u64 desc;
47 __u64 flags;
48 };
49
50 struct xdp_mmap_offsets {
51 struct xdp_ring_offset rx;
52 struct xdp_ring_offset tx;
53 struct xdp_ring_offset fr;
54 struct xdp_ring_offset cr;
55 };
56
57
58 #define XDP_MMAP_OFFSETS 1
59 #define XDP_RX_RING 2
60 #define XDP_TX_RING 3
61 #define XDP_UMEM_REG 4
62 #define XDP_UMEM_FILL_RING 5
63 #define XDP_UMEM_COMPLETION_RING 6
64 #define XDP_STATISTICS 7
65 #define XDP_OPTIONS 8
66
67 struct xdp_umem_reg {
68 __u64 addr;
69 __u64 len;
70 __u32 chunk_size;
71 __u32 headroom;
72 __u32 flags;
73 };
74
75 struct xdp_statistics {
76 __u64 rx_dropped;
77 __u64 rx_invalid_descs;
78 __u64 tx_invalid_descs;
79 };
80
81 struct xdp_options {
82 __u32 flags;
83 };
84
85
86 #define XDP_OPTIONS_ZEROCOPY (1 << 0)
87
88
89 #define XDP_PGOFF_RX_RING 0
90 #define XDP_PGOFF_TX_RING 0x80000000
91 #define XDP_UMEM_PGOFF_FILL_RING 0x100000000ULL
92 #define XDP_UMEM_PGOFF_COMPLETION_RING 0x180000000ULL
93
94
95 #define XSK_UNALIGNED_BUF_OFFSET_SHIFT 48
96 #define XSK_UNALIGNED_BUF_ADDR_MASK \
97 ((1ULL << XSK_UNALIGNED_BUF_OFFSET_SHIFT) - 1)
98
99
100 struct xdp_desc {
101 __u64 addr;
102 __u32 len;
103 __u32 options;
104 };
105
106
107
108 #endif