This is a Linux-specific PMD, thus the following prerequisites apply:
* A Linux Kernel (version > v4.18) with XDP sockets configuration enabled;
-* libbpf (within kernel version > v5.1-rc4) with latest af_xdp support installed,
- User can install libbpf via `make install_lib` && `make install_headers` in
- <kernel src tree>/tools/lib/bpf;
+* Both libxdp >=v1.2.2 and libbpf libraries installed, or, libbpf <=v0.6.0
* A Kernel bound interface to attach to;
* For need_wakeup feature, it requires kernel version later than v5.3-rc1;
* For PMD zero copy, it requires kernel version later than v5.4-rc1;
NAPI context from a watchdog timer instead of from softirqs. More information
on this feature can be found at [1].
- [1] https://lwn.net/Articles/837010/
\ No newline at end of file
+ [1] https://lwn.net/Articles/837010/
* Copyright(c) 2020 Intel Corporation.
*/
+#ifdef RTE_NET_AF_XDP_LIBXDP
+#include <xdp/xsk.h>
+#else
#include <bpf/xsk.h>
+#endif
#include <linux/version.h>
#include <poll.h>
#if KERNEL_VERSION(5, 10, 0) <= LINUX_VERSION_CODE && \
- defined(RTE_LIBRTE_AF_XDP_PMD_SHARED_UMEM)
+ defined(RTE_NET_AF_XDP_SHARED_UMEM)
#define ETH_AF_XDP_SHARED_UMEM 1
#endif
sources = files('rte_eth_af_xdp.c')
+xdp_dep = dependency('libxdp', version : '>=1.2.2', required: false, method: 'pkg-config')
bpf_dep = dependency('libbpf', required: false, method: 'pkg-config')
if not bpf_dep.found()
bpf_dep = cc.find_library('bpf', required: false)
endif
-if bpf_dep.found() and cc.has_header('bpf/xsk.h') and cc.has_header('linux/if_xdp.h')
- ext_deps += bpf_dep
- bpf_ver_dep = dependency('libbpf', version : '>=0.2.0',
- required: false, method: 'pkg-config')
- if bpf_ver_dep.found()
- dpdk_conf.set('RTE_LIBRTE_AF_XDP_PMD_SHARED_UMEM', 1)
+if cc.has_header('linux/if_xdp.h')
+ if xdp_dep.found() and cc.has_header('xdp/xsk.h')
+ if bpf_dep.found() and cc.has_header('bpf/bpf.h')
+ cflags += ['-DRTE_NET_AF_XDP_LIBXDP']
+ cflags += ['-DRTE_NET_AF_XDP_SHARED_UMEM']
+ ext_deps += xdp_dep
+ ext_deps += bpf_dep
+ else
+ build = false
+ reason = 'missing dependency, libbpf'
+ endif
+ elif bpf_dep.found() and cc.has_header('bpf/xsk.h') and cc.has_header('bpf/bpf.h')
+ # libxdp not found. Rely solely on libbpf for xsk functionality
+ # which is only available in versions <= v0.6.0.
+ bpf_ver_dep = dependency('libbpf', version : '<=0.6.0',
+ required: false, method: 'pkg-config')
+ if bpf_ver_dep.found()
+ ext_deps += bpf_dep
+ bpf_shumem_ver_dep = dependency('libbpf', version : '>=0.2.0',
+ required: false, method: 'pkg-config')
+ if bpf_shumem_ver_dep.found()
+ cflags += ['-DRTE_NET_AF_XDP_SHARED_UMEM']
+ endif
+ else
+ build = false
+ reason = 'missing dependency, "libxdp" or "libbpf <= v0.6.0"'
+ endif
+ else
+ build = false
+ reason = 'missing dependency, "libxdp" and "libbpf"'
endif
else
build = false
- reason = 'missing dependency, "libbpf"'
+ reason = 'missing header, "linux/if_xdp.h"'
endif