Blame view
include/net/xdp_sock.h
2.42 KB
dac09149d xsk: clean up SPD... |
1 2 |
/* SPDX-License-Identifier: GPL-2.0 */ /* AF_XDP internal functions |
c0c77d8fb xsk: add user mem... |
3 |
* Copyright(c) 2018 Intel Corporation. |
c0c77d8fb xsk: add user mem... |
4 5 6 7 |
*/ #ifndef _LINUX_XDP_SOCK_H #define _LINUX_XDP_SOCK_H |
e61e62b9e xsk: moved struct... |
8 9 |
#include <linux/workqueue.h> #include <linux/if_xdp.h> |
c0c77d8fb xsk: add user mem... |
10 |
#include <linux/mutex.h> |
ac98d8aab xsk: wire upp Tx ... |
11 |
#include <linux/spinlock.h> |
e61e62b9e xsk: moved struct... |
12 |
#include <linux/mm.h> |
c0c77d8fb xsk: add user mem... |
13 |
#include <net/sock.h> |
b9b6b68e8 xsk: add Rx queue... |
14 15 |
struct net_device; struct xsk_queue; |
a71506a4f xsk: Move driver ... |
16 |
struct xdp_buff; |
e61e62b9e xsk: moved struct... |
17 |
|
e61e62b9e xsk: moved struct... |
18 |
struct xdp_umem { |
7f7ffa4e9 xsk: Move addrs f... |
19 |
void *addrs; |
93ee30f3e xsk: i40e: get ri... |
20 |
u64 size; |
e61e62b9e xsk: moved struct... |
21 |
u32 headroom; |
2b43470ad xsk: Introduce AF... |
22 |
u32 chunk_size; |
1c1efc2af xsk: Create and f... |
23 |
u32 chunks; |
8ef4e27eb xsk: Rearrange in... |
24 |
u32 npgs; |
e61e62b9e xsk: moved struct... |
25 |
struct user_struct *user; |
e61e62b9e xsk: moved struct... |
26 |
refcount_t users; |
77cd0d7b3 xsk: add support ... |
27 |
u8 flags; |
173d3adb6 xsk: add zero-cop... |
28 |
bool zc; |
8ef4e27eb xsk: Rearrange in... |
29 30 |
struct page **pgs; int id; |
921b68692 xsk: Enable shari... |
31 |
struct list_head xsk_dma_list; |
537cf4e3c xsk: Fix umem cle... |
32 |
struct work_struct work; |
e61e62b9e xsk: moved struct... |
33 |
}; |
c0c77d8fb xsk: add user mem... |
34 |
|
d817991cc xsk: Restructure/... |
35 36 |
struct xsk_map { struct bpf_map map; |
d817991cc xsk: Restructure/... |
37 38 39 |
spinlock_t lock; /* Synchronize map updates */ struct xdp_sock *xsk_map[]; }; |
c0c77d8fb xsk: add user mem... |
40 41 42 |
struct xdp_sock { /* struct sock must be the first member of struct xdp_sock */ struct sock sk; |
8ef4e27eb xsk: Rearrange in... |
43 |
struct xsk_queue *rx ____cacheline_aligned_in_smp; |
b9b6b68e8 xsk: add Rx queue... |
44 |
struct net_device *dev; |
c0c77d8fb xsk: add user mem... |
45 |
struct xdp_umem *umem; |
fbfc504a2 bpf: introduce ne... |
46 |
struct list_head flush_node; |
c4655761d xsk: i40e: ice: i... |
47 |
struct xsk_buff_pool *pool; |
965a99098 xsk: add support ... |
48 |
u16 queue_id; |
ac98d8aab xsk: wire upp Tx ... |
49 |
bool zc; |
455302d1c xdp: fix hang whi... |
50 51 52 53 54 |
enum { XSK_READY = 0, XSK_BOUND, XSK_UNBOUND, } state; |
8ef4e27eb xsk: Rearrange in... |
55 |
|
fada7fdc8 bpf: Allow bpf_ma... |
56 |
struct xsk_queue *tx ____cacheline_aligned_in_smp; |
a5aa8e529 xsk: Move xsk_tx_... |
57 |
struct list_head tx_list; |
bf0bdd134 xdp: fix race on ... |
58 59 |
/* Protects generic receive. */ spinlock_t rx_lock; |
8aa5a3357 xsk: Add new stat... |
60 61 |
/* Statistics */ |
c497176cb xsk: add Rx recei... |
62 |
u64 rx_dropped; |
8aa5a3357 xsk: Add new stat... |
63 |
u64 rx_queue_full; |
0402acd68 xsk: remove AF_XD... |
64 65 66 |
struct list_head map_list; /* Protects map_list */ spinlock_t map_list_lock; |
8ef4e27eb xsk: Rearrange in... |
67 68 |
/* Protects multiple processes in the control path */ struct mutex mutex; |
7361f9c3d xsk: Move fill an... |
69 70 |
struct xsk_queue *fq_tmp; /* Only as tmp storage before bind */ struct xsk_queue *cq_tmp; /* Only as tmp storage before bind */ |
c0c77d8fb xsk: add user mem... |
71 |
}; |
c497176cb xsk: add Rx recei... |
72 |
#ifdef CONFIG_XDP_SOCKETS |
902540342 xsk: expose xdp_u... |
73 |
|
a71506a4f xsk: Move driver ... |
74 |
int xsk_generic_rcv(struct xdp_sock *xs, struct xdp_buff *xdp); |
e312b9e70 xsk: Make xskmap ... |
75 76 |
int __xsk_map_redirect(struct xdp_sock *xs, struct xdp_buff *xdp); void __xsk_map_flush(void); |
d817991cc xsk: Restructure/... |
77 78 79 80 81 82 83 84 85 86 87 88 89 |
static inline struct xdp_sock *__xsk_map_lookup_elem(struct bpf_map *map, u32 key) { struct xsk_map *m = container_of(map, struct xsk_map, map); struct xdp_sock *xs; if (key >= map->max_entries) return NULL; xs = READ_ONCE(m->xsk_map[key]); return xs; } |
0402acd68 xsk: remove AF_XD... |
90 |
|
c497176cb xsk: add Rx recei... |
91 |
#else |
a71506a4f xsk: Move driver ... |
92 |
|
c497176cb xsk: add Rx recei... |
93 94 95 96 |
static inline int xsk_generic_rcv(struct xdp_sock *xs, struct xdp_buff *xdp) { return -ENOTSUPP; } |
a71506a4f xsk: Move driver ... |
97 |
static inline int __xsk_map_redirect(struct xdp_sock *xs, struct xdp_buff *xdp) |
f5bd91388 net: xsk: add a s... |
98 |
{ |
a71506a4f xsk: Move driver ... |
99 |
return -EOPNOTSUPP; |
f5bd91388 net: xsk: add a s... |
100 |
} |
a71506a4f xsk: Move driver ... |
101 |
static inline void __xsk_map_flush(void) |
f5bd91388 net: xsk: add a s... |
102 103 |
{ } |
a71506a4f xsk: Move driver ... |
104 105 |
static inline struct xdp_sock *__xsk_map_lookup_elem(struct bpf_map *map, u32 key) |
1661d3466 ethtool: don't al... |
106 107 108 |
{ return NULL; } |
c497176cb xsk: add Rx recei... |
109 |
#endif /* CONFIG_XDP_SOCKETS */ |
c0c77d8fb xsk: add user mem... |
110 |
#endif /* _LINUX_XDP_SOCK_H */ |