DPDK patches and discussions
 help / color / mirror / Atom feed
From: Ciara Loftus <ciara.loftus@intel.com>
To: dev@dpdk.org
Cc: andrew.rybchenko@oktetlabs.ru, Ciara Loftus <ciara.loftus@intel.com>
Subject: [RFC PATCH 2/3] net/af_xdp: determine libbpf version by checking for symbols
Date: Thu, 21 Jul 2022 12:14:14 +0000	[thread overview]
Message-ID: <20220721121415.1709202-2-ciara.loftus@intel.com> (raw)
In-Reply-To: <20220721121415.1709202-1-ciara.loftus@intel.com>

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


  reply	other threads:[~2022-07-21 12:14 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2022-07-21 12:14 ` [RFC PATCH 3/3] net/af_xdp: use autoconf file instead of cflags Ciara Loftus

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220721121415.1709202-2-ciara.loftus@intel.com \
    --to=ciara.loftus@intel.com \
    --cc=andrew.rybchenko@oktetlabs.ru \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).