Commit | Line | Data |
---|---|---|
dac09149 BT |
1 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ |
2 | /* | |
c0c77d8f BT |
3 | * if_xdp: XDP socket user-space interface |
4 | * Copyright(c) 2018 Intel Corporation. | |
5 | * | |
c0c77d8f BT |
6 | * Author(s): Björn Töpel <bjorn.topel@intel.com> |
7 | * Magnus Karlsson <magnus.karlsson@intel.com> | |
8 | */ | |
9 | ||
10 | #ifndef _LINUX_IF_XDP_H | |
11 | #define _LINUX_IF_XDP_H | |
12 | ||
13 | #include <linux/types.h> | |
14 | ||
965a9909 MK |
15 | /* Options for the sxdp_flags field */ |
16 | #define XDP_SHARED_UMEM 1 | |
17 | ||
18 | struct sockaddr_xdp { | |
19 | __u16 sxdp_family; | |
ad75646c | 20 | __u16 sxdp_flags; |
965a9909 MK |
21 | __u32 sxdp_ifindex; |
22 | __u32 sxdp_queue_id; | |
23 | __u32 sxdp_shared_umem_fd; | |
965a9909 MK |
24 | }; |
25 | ||
b3a9e0be BT |
26 | struct xdp_ring_offset { |
27 | __u64 producer; | |
28 | __u64 consumer; | |
29 | __u64 desc; | |
30 | }; | |
31 | ||
32 | struct xdp_mmap_offsets { | |
33 | struct xdp_ring_offset rx; | |
34 | struct xdp_ring_offset tx; | |
35 | struct xdp_ring_offset fr; /* Fill */ | |
36 | struct xdp_ring_offset cr; /* Completion */ | |
37 | }; | |
38 | ||
c0c77d8f | 39 | /* XDP socket options */ |
b3a9e0be BT |
40 | #define XDP_MMAP_OFFSETS 1 |
41 | #define XDP_RX_RING 2 | |
42 | #define XDP_TX_RING 3 | |
43 | #define XDP_UMEM_REG 4 | |
44 | #define XDP_UMEM_FILL_RING 5 | |
45 | #define XDP_UMEM_COMPLETION_RING 6 | |
46 | #define XDP_STATISTICS 7 | |
c0c77d8f BT |
47 | |
48 | struct xdp_umem_reg { | |
49 | __u64 addr; /* Start of packet data area */ | |
50 | __u64 len; /* Length of packet data area */ | |
51 | __u32 frame_size; /* Frame size */ | |
52 | __u32 frame_headroom; /* Frame head room */ | |
53 | }; | |
54 | ||
af75d9e0 MK |
55 | struct xdp_statistics { |
56 | __u64 rx_dropped; /* Dropped for reasons other than invalid desc */ | |
57 | __u64 rx_invalid_descs; /* Dropped due to invalid descriptor */ | |
58 | __u64 tx_invalid_descs; /* Dropped due to invalid descriptor */ | |
59 | }; | |
60 | ||
423f3832 | 61 | /* Pgoff for mmaping the rings */ |
b9b6b68e | 62 | #define XDP_PGOFF_RX_RING 0 |
f6145903 | 63 | #define XDP_PGOFF_TX_RING 0x80000000 |
423f3832 | 64 | #define XDP_UMEM_PGOFF_FILL_RING 0x100000000 |
fe230832 | 65 | #define XDP_UMEM_PGOFF_COMPLETION_RING 0x180000000 |
423f3832 | 66 | |
b3a9e0be | 67 | /* Rx/Tx descriptor */ |
b9b6b68e BT |
68 | struct xdp_desc { |
69 | __u32 idx; | |
70 | __u32 len; | |
71 | __u16 offset; | |
72 | __u8 flags; | |
73 | __u8 padding[5]; | |
74 | }; | |
75 | ||
b3a9e0be | 76 | /* UMEM descriptor is __u32 */ |
423f3832 | 77 | |
c0c77d8f | 78 | #endif /* _LINUX_IF_XDP_H */ |