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