]>
Commit | Line | Data |
---|---|---|
dac09149 BT |
1 | /* SPDX-License-Identifier: GPL-2.0 */ |
2 | /* AF_XDP internal functions | |
c0c77d8f | 3 | * Copyright(c) 2018 Intel Corporation. |
c0c77d8f BT |
4 | */ |
5 | ||
6 | #ifndef _LINUX_XDP_SOCK_H | |
7 | #define _LINUX_XDP_SOCK_H | |
8 | ||
e61e62b9 BT |
9 | #include <linux/workqueue.h> |
10 | #include <linux/if_xdp.h> | |
c0c77d8f | 11 | #include <linux/mutex.h> |
e61e62b9 | 12 | #include <linux/mm.h> |
c0c77d8f BT |
13 | #include <net/sock.h> |
14 | ||
b9b6b68e BT |
15 | struct net_device; |
16 | struct xsk_queue; | |
e61e62b9 BT |
17 | |
18 | struct xdp_umem_props { | |
19 | u64 chunk_mask; | |
20 | u64 size; | |
21 | }; | |
22 | ||
8aef7340 BT |
23 | struct xdp_umem_page { |
24 | void *addr; | |
25 | }; | |
26 | ||
e61e62b9 BT |
27 | struct xdp_umem { |
28 | struct xsk_queue *fq; | |
29 | struct xsk_queue *cq; | |
8aef7340 | 30 | struct xdp_umem_page *pages; |
e61e62b9 BT |
31 | struct xdp_umem_props props; |
32 | u32 headroom; | |
33 | u32 chunk_size_nohr; | |
34 | struct user_struct *user; | |
35 | struct pid *pid; | |
36 | unsigned long address; | |
37 | refcount_t users; | |
38 | struct work_struct work; | |
8aef7340 | 39 | struct page **pgs; |
e61e62b9 BT |
40 | u32 npgs; |
41 | }; | |
c0c77d8f BT |
42 | |
43 | struct xdp_sock { | |
44 | /* struct sock must be the first member of struct xdp_sock */ | |
45 | struct sock sk; | |
b9b6b68e BT |
46 | struct xsk_queue *rx; |
47 | struct net_device *dev; | |
c0c77d8f | 48 | struct xdp_umem *umem; |
fbfc504a | 49 | struct list_head flush_node; |
965a9909 | 50 | u16 queue_id; |
f6145903 | 51 | struct xsk_queue *tx ____cacheline_aligned_in_smp; |
c0c77d8f BT |
52 | /* Protects multiple processes in the control path */ |
53 | struct mutex mutex; | |
c497176c | 54 | u64 rx_dropped; |
c0c77d8f BT |
55 | }; |
56 | ||
c497176c BT |
57 | struct xdp_buff; |
58 | #ifdef CONFIG_XDP_SOCKETS | |
59 | int xsk_generic_rcv(struct xdp_sock *xs, struct xdp_buff *xdp); | |
60 | int xsk_rcv(struct xdp_sock *xs, struct xdp_buff *xdp); | |
61 | void xsk_flush(struct xdp_sock *xs); | |
fbfc504a | 62 | bool xsk_is_setup_for_bpf_map(struct xdp_sock *xs); |
c497176c BT |
63 | #else |
64 | static inline int xsk_generic_rcv(struct xdp_sock *xs, struct xdp_buff *xdp) | |
65 | { | |
66 | return -ENOTSUPP; | |
67 | } | |
68 | ||
69 | static inline int xsk_rcv(struct xdp_sock *xs, struct xdp_buff *xdp) | |
70 | { | |
71 | return -ENOTSUPP; | |
72 | } | |
73 | ||
74 | static inline void xsk_flush(struct xdp_sock *xs) | |
75 | { | |
76 | } | |
fbfc504a BT |
77 | |
78 | static inline bool xsk_is_setup_for_bpf_map(struct xdp_sock *xs) | |
79 | { | |
80 | return false; | |
81 | } | |
c497176c BT |
82 | #endif /* CONFIG_XDP_SOCKETS */ |
83 | ||
c0c77d8f | 84 | #endif /* _LINUX_XDP_SOCK_H */ |