1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* AF_XDP internal functions
3 * Copyright(c) 2018 Intel Corporation.
6 #ifndef _LINUX_XDP_SOCK_H
7 #define _LINUX_XDP_SOCK_H
10 #include <linux/workqueue.h>
11 #include <linux/if_xdp.h>
12 #include <linux/mutex.h>
13 #include <linux/spinlock.h>
17 #define XDP_UMEM_SG_FLAG (1 << 1)
30 struct user_struct *user;
36 struct list_head xsk_dma_list;
37 struct work_struct work;
42 spinlock_t lock; /* Synchronize map updates */
44 struct xdp_sock __rcu *xsk_map[];
48 /* struct sock must be the first member of struct xdp_sock */
50 struct xsk_queue *rx ____cacheline_aligned_in_smp;
51 struct net_device *dev;
52 struct xdp_umem *umem;
53 struct list_head flush_node;
54 struct xsk_buff_pool *pool;
64 struct xsk_queue *tx ____cacheline_aligned_in_smp;
65 struct list_head tx_list;
66 /* Protects generic receive. */
73 /* When __xsk_generic_xmit() must return before it sees the EOP descriptor for the current
74 * packet, the partially built skb is saved here so that packet building can resume in next
75 * call of __xsk_generic_xmit().
79 struct list_head map_list;
80 /* Protects map_list */
81 spinlock_t map_list_lock;
82 /* Protects multiple processes in the control path */
84 struct xsk_queue *fq_tmp; /* Only as tmp storage before bind */
85 struct xsk_queue *cq_tmp; /* Only as tmp storage before bind */
88 #ifdef CONFIG_XDP_SOCKETS
90 int xsk_generic_rcv(struct xdp_sock *xs, struct xdp_buff *xdp);
91 int __xsk_map_redirect(struct xdp_sock *xs, struct xdp_buff *xdp);
92 void __xsk_map_flush(void);
96 static inline int xsk_generic_rcv(struct xdp_sock *xs, struct xdp_buff *xdp)
101 static inline int __xsk_map_redirect(struct xdp_sock *xs, struct xdp_buff *xdp)
106 static inline void __xsk_map_flush(void)
110 #endif /* CONFIG_XDP_SOCKETS */
112 #endif /* _LINUX_XDP_SOCK_H */