]> git.droids-corp.org - dpdk.git/commitdiff
net/af_xdp: use libxdp if available
authorCiara Loftus <ciara.loftus@intel.com>
Fri, 28 Jan 2022 09:50:29 +0000 (09:50 +0000)
committerFerruh Yigit <ferruh.yigit@intel.com>
Tue, 1 Feb 2022 10:08:00 +0000 (11:08 +0100)
AF_XDP support is deprecated in libbpf since v0.7.0 [1]. The libxdp library
now provides the functionality which once was in libbpf and which the
AF_XDP PMD relies on. This commit updates the AF_XDP meson build to use the
libxdp library if a version >= v1.2.2 is available. If it is not available,
only versions of libbpf prior to v0.7.0 are allowed, as they still contain
the required AF_XDP functionality.

libbpf still remains a dependency even if libxdp is present, as we use
libbpf APIs for program loading.

The minimum required kernel version for libxdp for use with AF_XDP is v5.3.
For the library to be fully-featured, a kernel v5.10 or newer is
recommended. The full compatibility information can be found in the libxdp
README.

v1.2.2 of libxdp includes an important fix required for linking with DPDK
which is why this version or greater is required. Meson uses pkg-config to
verify the version of libxdp on the system, so it is necessary that the
library is discoverable using pkg-config in order for the PMD to use it. To
verify this, you can run: pkg-config --modversion libxdp

[1] https://github.com/libbpf/libbpf/commit/277846bc6c15

Signed-off-by: Ciara Loftus <ciara.loftus@intel.com>
doc/guides/nics/af_xdp.rst
doc/guides/rel_notes/release_22_03.rst
drivers/net/af_xdp/compat.h
drivers/net/af_xdp/meson.build
drivers/net/af_xdp/rte_eth_af_xdp.c

index c9d0e1ad6c57e2413314971459a2a0f9c851c68e..db02ea1984943f830cf8ead8c045ec4a87094b27 100644 (file)
@@ -43,9 +43,7 @@ Prerequisites
 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;
@@ -143,4 +141,4 @@ Limitations
   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/
index a3e280715e9cefef01fde662a16cf5ec40c75079..ab7ff9b16cea4bcba0c39ada77499f7c3d50e905 100644 (file)
@@ -62,6 +62,10 @@ New Features
   The new mode is activated with ``--huge-unlink=never``
   and has security implications, refer to the user and programmer guides.
 
+* **Updated AF_XDP PMD**
+
+  * Added support for libxdp >=v1.2.2.
+
 * **Updated Cisco enic driver.**
 
   * Added rte_flow support for matching GENEVE packets.
index 3880dc7dd7f5b42b67ff6e0e6d31a4966f31a8bd..bf40c6572e886f9f36e7df468bfd24ad1308d091 100644 (file)
@@ -2,12 +2,16 @@
  * 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
 
index 3ed2b29784aacba141a165a83457472e89ca12f0..93e895eab98f3a696009829c871e9e018ab36012 100644 (file)
@@ -9,19 +9,44 @@ 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
index b3ed704b36c951150e61de54991acd5e76b784c9..1b6192fa443ae3ee631b09fb703f5b082df791ad 100644 (file)
@@ -16,7 +16,6 @@
 #include <linux/sockios.h>
 #include "af_xdp_deps.h"
 #include <bpf/bpf.h>
-#include <bpf/xsk.h>
 
 #include <rte_ethdev.h>
 #include <ethdev_driver.h>