DPDK patches and discussions
 help / color / mirror / Atom feed
* [RFC PATCH 1/3] net/af_xdp: simplify libbpf version checking in meson
@ 2022-07-21 12:14 Ciara Loftus
  2022-07-21 12:14 ` [RFC PATCH 2/3] net/af_xdp: determine libbpf version by checking for symbols Ciara Loftus
  2022-07-21 12:14 ` [RFC PATCH 3/3] net/af_xdp: use autoconf file instead of cflags Ciara Loftus
  0 siblings, 2 replies; 3+ messages in thread
From: Ciara Loftus @ 2022-07-21 12:14 UTC (permalink / raw)
  To: dev; +Cc: andrew.rybchenko, Ciara Loftus

Test if the libbpf version is >= v0.7.0 at the beginning of the meson
build. Later when we want to check if the version is <= v0.6.0 just use
the inverse of the first check ie. ! >= v0.7.0.

Signed-off-by: Ciara Loftus <ciara.loftus@intel.com>
---
 drivers/net/af_xdp/meson.build | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/net/af_xdp/meson.build b/drivers/net/af_xdp/meson.build
index 1e0de23705..c90ab10a7b 100644
--- a/drivers/net/af_xdp/meson.build
+++ b/drivers/net/af_xdp/meson.build
@@ -9,10 +9,14 @@ endif
 
 sources = files('rte_eth_af_xdp.c')
 
+bpf_ver_dep = false
+
 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)
+else
+    bpf_ver_dep = dependency('libbpf', version : '>=0.7.0', required: false, method: 'pkg-config')
 endif
 
 if cc.has_header('linux/if_xdp.h')
@@ -22,8 +26,6 @@ if cc.has_header('linux/if_xdp.h')
             cflags += ['-DRTE_NET_AF_XDP_SHARED_UMEM']
             ext_deps += xdp_dep
             ext_deps += bpf_dep
-            bpf_ver_dep = dependency('libbpf', version : '>=0.7.0',
-                                 required: false, method: 'pkg-config')
             if bpf_ver_dep.found()
                 cflags += ['-DRTE_NET_AF_XDP_LIBBPF_OBJ_OPEN']
             endif
@@ -33,10 +35,8 @@ if cc.has_header('linux/if_xdp.h')
         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()
+        # which is only available in versions < v0.7.0.
+        if not bpf_ver_dep.found()
             ext_deps += bpf_dep
             bpf_shumem_ver_dep = dependency('libbpf', version : '>=0.2.0',
                             required: false, method: 'pkg-config')
-- 
2.25.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [RFC PATCH 2/3] net/af_xdp: determine libbpf version by checking for symbols
  2022-07-21 12:14 [RFC PATCH 1/3] net/af_xdp: simplify libbpf version checking in meson Ciara Loftus
@ 2022-07-21 12:14 ` Ciara Loftus
  2022-07-21 12:14 ` [RFC PATCH 3/3] net/af_xdp: use autoconf file instead of cflags Ciara Loftus
  1 sibling, 0 replies; 3+ messages in thread
From: Ciara Loftus @ 2022-07-21 12:14 UTC (permalink / raw)
  To: dev; +Cc: andrew.rybchenko, Ciara Loftus

Instead of using pkg-config to query the version of the libbpf library,
search for symbols in the library and use their presence or absence to
determine what version of the library is being linked.

Suggested-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
Signed-off-by: Ciara Loftus <ciara.loftus@intel.com>
---
 drivers/net/af_xdp/meson.build | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/drivers/net/af_xdp/meson.build b/drivers/net/af_xdp/meson.build
index c90ab10a7b..d91545f9c3 100644
--- a/drivers/net/af_xdp/meson.build
+++ b/drivers/net/af_xdp/meson.build
@@ -15,8 +15,12 @@ xdp_dep = dependency('libxdp', version : '>=1.2.2', required: false, method: 'pk
 bpf_dep = dependency('libbpf', required: false, method: 'pkg-config')
 if not bpf_dep.found()
     bpf_dep = cc.find_library('bpf', required: false)
-else
-    bpf_ver_dep = dependency('libbpf', version : '>=0.7.0', required: false, method: 'pkg-config')
+endif
+
+libbpf070 = false
+
+if bpf_dep.found() and cc.has_header('bpf/bpf.h') and cc.has_header_symbol('bpf/bpf.h', 'bpf_btf_load')
+    libbpf070 = true
 endif
 
 if cc.has_header('linux/if_xdp.h')
@@ -26,7 +30,7 @@ if cc.has_header('linux/if_xdp.h')
             cflags += ['-DRTE_NET_AF_XDP_SHARED_UMEM']
             ext_deps += xdp_dep
             ext_deps += bpf_dep
-            if bpf_ver_dep.found()
+            if libbpf070
                 cflags += ['-DRTE_NET_AF_XDP_LIBBPF_OBJ_OPEN']
             endif
         else
@@ -36,11 +40,10 @@ if cc.has_header('linux/if_xdp.h')
     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.7.0.
-        if not bpf_ver_dep.found()
+        if not libbpf070
             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()
+            bpf_shumem_ver_dep = cc.has_header_symbol('bpf/bpf.h', 'bpf_prog_bind_map')
+            if bpf_shumem_ver_dep
                 cflags += ['-DRTE_NET_AF_XDP_SHARED_UMEM']
             endif
         else
-- 
2.25.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [RFC PATCH 3/3] net/af_xdp: use autoconf file instead of cflags
  2022-07-21 12:14 [RFC PATCH 1/3] net/af_xdp: simplify libbpf version checking in meson Ciara Loftus
  2022-07-21 12:14 ` [RFC PATCH 2/3] net/af_xdp: determine libbpf version by checking for symbols Ciara Loftus
@ 2022-07-21 12:14 ` Ciara Loftus
  1 sibling, 0 replies; 3+ messages in thread
From: Ciara Loftus @ 2022-07-21 12:14 UTC (permalink / raw)
  To: dev; +Cc: andrew.rybchenko, Ciara Loftus

Generate af_xdp_autoconf.h which contains the different features
detected by the meson build instead of using cflags.

Suggested-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
Signed-off-by: Ciara Loftus <ciara.loftus@intel.com>
---
 drivers/net/af_xdp/compat.h    |  8 +++++---
 drivers/net/af_xdp/meson.build | 15 ++++++++-------
 2 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/drivers/net/af_xdp/compat.h b/drivers/net/af_xdp/compat.h
index 28ea64aeaa..e1f8ead7c8 100644
--- a/drivers/net/af_xdp/compat.h
+++ b/drivers/net/af_xdp/compat.h
@@ -2,7 +2,9 @@
  * Copyright(c) 2020 Intel Corporation.
  */
 
-#ifdef RTE_NET_AF_XDP_LIBXDP
+#include "af_xdp_autoconf.h"
+
+#ifdef HAVE_LIBXDP
 #include <xdp/xsk.h>
 #else
 #include <bpf/xsk.h>
@@ -12,7 +14,7 @@
 #include <poll.h>
 
 #if KERNEL_VERSION(5, 10, 0) <= LINUX_VERSION_CODE && \
-	defined(RTE_NET_AF_XDP_SHARED_UMEM)
+	defined(HAVE_LIBBPF_SHARED_UMEM)
 #define ETH_AF_XDP_SHARED_UMEM 1
 #endif
 
@@ -60,7 +62,7 @@ tx_syscall_needed(struct xsk_ring_prod *q __rte_unused)
 }
 #endif
 
-#ifdef RTE_NET_AF_XDP_LIBBPF_OBJ_OPEN
+#ifdef HAVE_LIBBPF_OBJ_OPEN
 static int load_program(const char *prog_path, struct bpf_object **obj)
 {
 	struct bpf_program *prog;
diff --git a/drivers/net/af_xdp/meson.build b/drivers/net/af_xdp/meson.build
index d91545f9c3..d1f6febbca 100644
--- a/drivers/net/af_xdp/meson.build
+++ b/drivers/net/af_xdp/meson.build
@@ -23,15 +23,17 @@ if bpf_dep.found() and cc.has_header('bpf/bpf.h') and cc.has_header_symbol('bpf/
     libbpf070 = true
 endif
 
+config = configuration_data()
+
 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']
+            config.set('HAVE_LIBXDP', 1)
+            config.set('HAVE_LIBBPF_SHARED_UMEM', 1)
             ext_deps += xdp_dep
             ext_deps += bpf_dep
             if libbpf070
-                cflags += ['-DRTE_NET_AF_XDP_LIBBPF_OBJ_OPEN']
+                config.set('HAVE_LIBBPF_OBJ_OPEN', 1)
             endif
         else
             build = false
@@ -42,10 +44,7 @@ if cc.has_header('linux/if_xdp.h')
         # which is only available in versions < v0.7.0.
         if not libbpf070
             ext_deps += bpf_dep
-            bpf_shumem_ver_dep = cc.has_header_symbol('bpf/bpf.h', 'bpf_prog_bind_map')
-            if bpf_shumem_ver_dep
-                cflags += ['-DRTE_NET_AF_XDP_SHARED_UMEM']
-            endif
+            config.set('HAVE_LIBBPF_SHARED_UMEM', cc.has_header_symbol('bpf/bpf.h', 'bpf_prog_bind_map'))
         else
             build = false
             reason = 'missing dependency, "libxdp" or "libbpf <= v0.6.0"'
@@ -58,3 +57,5 @@ else
     build = false
     reason = 'missing header, "linux/if_xdp.h"'
 endif
+
+configure_file(output : 'af_xdp_autoconf.h', configuration : config)
-- 
2.25.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-07-21 12:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-21 12:14 [RFC PATCH 1/3] net/af_xdp: simplify libbpf version checking in meson Ciara Loftus
2022-07-21 12:14 ` [RFC PATCH 2/3] net/af_xdp: determine libbpf version by checking for symbols Ciara Loftus
2022-07-21 12:14 ` [RFC PATCH 3/3] net/af_xdp: use autoconf file instead of cflags Ciara Loftus

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).