net/ark: add performance optimizations
[dpdk.git] / drivers / net / af_xdp / compat.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2020 Intel Corporation.
3  */
4
5 #ifdef RTE_NET_AF_XDP_LIBXDP
6 #include <xdp/xsk.h>
7 #else
8 #include <bpf/xsk.h>
9 #endif
10 #include <linux/version.h>
11 #include <poll.h>
12
13 #if KERNEL_VERSION(5, 10, 0) <= LINUX_VERSION_CODE && \
14         defined(RTE_NET_AF_XDP_SHARED_UMEM)
15 #define ETH_AF_XDP_SHARED_UMEM 1
16 #endif
17
18 #ifdef ETH_AF_XDP_SHARED_UMEM
19 static __rte_always_inline int
20 create_shared_socket(struct xsk_socket **xsk_ptr,
21                           const char *ifname,
22                           __u32 queue_id, struct xsk_umem *umem,
23                           struct xsk_ring_cons *rx,
24                           struct xsk_ring_prod *tx,
25                           struct xsk_ring_prod *fill,
26                           struct xsk_ring_cons *comp,
27                           const struct xsk_socket_config *config)
28 {
29         return xsk_socket__create_shared(xsk_ptr, ifname, queue_id, umem, rx,
30                                                 tx, fill, comp, config);
31 }
32 #else
33 static __rte_always_inline int
34 create_shared_socket(struct xsk_socket **xsk_ptr __rte_unused,
35                           const char *ifname __rte_unused,
36                           __u32 queue_id __rte_unused,
37                           struct xsk_umem *umem __rte_unused,
38                           struct xsk_ring_cons *rx __rte_unused,
39                           struct xsk_ring_prod *tx __rte_unused,
40                           struct xsk_ring_prod *fill __rte_unused,
41                           struct xsk_ring_cons *comp __rte_unused,
42                           const struct xsk_socket_config *config __rte_unused)
43 {
44         return -1;
45 }
46 #endif
47
48 #ifdef XDP_USE_NEED_WAKEUP
49 static int
50 tx_syscall_needed(struct xsk_ring_prod *q)
51 {
52         return xsk_ring_prod__needs_wakeup(q);
53 }
54 #else
55 static int
56 tx_syscall_needed(struct xsk_ring_prod *q __rte_unused)
57 {
58         return 1;
59 }
60 #endif