numam-dpdk/drivers/net/af_xdp/compat.h
Ciara Loftus 89233c081c net/af_xdp: fix build with Linux < 5.4
Prior to this change, two implementations of rx_syscall_handler
existed although only one was needed (for the zero copy path which
is only available from kernel 5.4 and onwards). Remove the second
definition from compat.h and move the first definition back to where
it is called in the Rx function. Doing this removes a build warning
on kernels before 5.4 which complained about the second function
being defined but not used.

Fixes: 2aa51cdd55 ("net/af_xdp: fix trigger for syscall on Tx")

Signed-off-by: Ciara Loftus <ciara.loftus@intel.com>
2021-05-11 16:11:26 +02:00

57 lines
1.4 KiB
C

/* SPDX-License-Identifier: BSD-3-Clause
* Copyright(c) 2020 Intel Corporation.
*/
#include <bpf/xsk.h>
#include <linux/version.h>
#include <poll.h>
#if KERNEL_VERSION(5, 10, 0) <= LINUX_VERSION_CODE && \
defined(RTE_LIBRTE_AF_XDP_PMD_SHARED_UMEM)
#define ETH_AF_XDP_SHARED_UMEM 1
#endif
#ifdef ETH_AF_XDP_SHARED_UMEM
static __rte_always_inline int
create_shared_socket(struct xsk_socket **xsk_ptr,
const char *ifname,
__u32 queue_id, struct xsk_umem *umem,
struct xsk_ring_cons *rx,
struct xsk_ring_prod *tx,
struct xsk_ring_prod *fill,
struct xsk_ring_cons *comp,
const struct xsk_socket_config *config)
{
return xsk_socket__create_shared(xsk_ptr, ifname, queue_id, umem, rx,
tx, fill, comp, config);
}
#else
static __rte_always_inline int
create_shared_socket(struct xsk_socket **xsk_ptr __rte_unused,
const char *ifname __rte_unused,
__u32 queue_id __rte_unused,
struct xsk_umem *umem __rte_unused,
struct xsk_ring_cons *rx __rte_unused,
struct xsk_ring_prod *tx __rte_unused,
struct xsk_ring_prod *fill __rte_unused,
struct xsk_ring_cons *comp __rte_unused,
const struct xsk_socket_config *config __rte_unused)
{
return -1;
}
#endif
#ifdef XDP_USE_NEED_WAKEUP
static int
tx_syscall_needed(struct xsk_ring_prod *q)
{
return xsk_ring_prod__needs_wakeup(q);
}
#else
static int
tx_syscall_needed(struct xsk_ring_prod *q __rte_unused)
{
return 1;
}
#endif