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 | 15 | /* Options for the sxdp_flags field */ |
173d3adb BT |
16 | #define XDP_SHARED_UMEM (1 << 0) |
17 | #define XDP_COPY (1 << 1) /* Force copy-mode */ | |
18 | #define XDP_ZEROCOPY (1 << 2) /* Force zero-copy mode */ | |
965a9909 MK |
19 | |
20 | struct sockaddr_xdp { | |
21 | __u16 sxdp_family; | |
ad75646c | 22 | __u16 sxdp_flags; |
965a9909 MK |
23 | __u32 sxdp_ifindex; |
24 | __u32 sxdp_queue_id; | |
25 | __u32 sxdp_shared_umem_fd; | |
965a9909 MK |
26 | }; |
27 | ||
b3a9e0be BT |
28 | struct xdp_ring_offset { |
29 | __u64 producer; | |
30 | __u64 consumer; | |
31 | __u64 desc; | |
32 | }; | |
33 | ||
34 | struct xdp_mmap_offsets { | |
35 | struct xdp_ring_offset rx; | |
36 | struct xdp_ring_offset tx; | |
37 | struct xdp_ring_offset fr; /* Fill */ | |
38 | struct xdp_ring_offset cr; /* Completion */ | |
39 | }; | |
40 | ||
c0c77d8f | 41 | /* XDP socket options */ |
b3a9e0be BT |
42 | #define XDP_MMAP_OFFSETS 1 |
43 | #define XDP_RX_RING 2 | |
44 | #define XDP_TX_RING 3 | |
45 | #define XDP_UMEM_REG 4 | |
46 | #define XDP_UMEM_FILL_RING 5 | |
47 | #define XDP_UMEM_COMPLETION_RING 6 | |
48 | #define XDP_STATISTICS 7 | |
2640d3c8 | 49 | #define XDP_OPTIONS 8 |
c0c77d8f BT |
50 | |
51 | struct xdp_umem_reg { | |
52 | __u64 addr; /* Start of packet data area */ | |
53 | __u64 len; /* Length of packet data area */ | |
bbff2f32 BT |
54 | __u32 chunk_size; |
55 | __u32 headroom; | |
c0c77d8f BT |
56 | }; |
57 | ||
af75d9e0 MK |
58 | struct xdp_statistics { |
59 | __u64 rx_dropped; /* Dropped for reasons other than invalid desc */ | |
60 | __u64 rx_invalid_descs; /* Dropped due to invalid descriptor */ | |
61 | __u64 tx_invalid_descs; /* Dropped due to invalid descriptor */ | |
62 | }; | |
63 | ||
2640d3c8 MM |
64 | struct xdp_options { |
65 | __u32 flags; | |
66 | }; | |
67 | ||
68 | /* Flags for the flags field of struct xdp_options */ | |
69 | #define XDP_OPTIONS_ZEROCOPY (1 << 0) | |
70 | ||
423f3832 | 71 | /* Pgoff for mmaping the rings */ |
b9b6b68e | 72 | #define XDP_PGOFF_RX_RING 0 |
f6145903 | 73 | #define XDP_PGOFF_TX_RING 0x80000000 |
a5a16e43 GU |
74 | #define XDP_UMEM_PGOFF_FILL_RING 0x100000000ULL |
75 | #define XDP_UMEM_PGOFF_COMPLETION_RING 0x180000000ULL | |
423f3832 | 76 | |
b3a9e0be | 77 | /* Rx/Tx descriptor */ |
b9b6b68e | 78 | struct xdp_desc { |
bbff2f32 | 79 | __u64 addr; |
b9b6b68e | 80 | __u32 len; |
bbff2f32 | 81 | __u32 options; |
b9b6b68e BT |
82 | }; |
83 | ||
bbff2f32 | 84 | /* UMEM descriptor is __u64 */ |
423f3832 | 85 | |
c0c77d8f | 86 | #endif /* _LINUX_IF_XDP_H */ |