From e024c7e838fc4e4315f61b1eeb0f147b0353f708 Mon Sep 17 00:00:00 2001
From: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
Date: Thu, 6 Oct 2022 09:26:51 +0300
Subject: [PATCH] net/af_xdp: avoid version-based check for shared UMEM

[ upstream commit e024c7e838fc4e4315f61b1eeb0f147b0353f708 ]


Check for xsk_socket__create_shared() function instead.

Signed-off-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
Reviewed-by: Ferruh Yigit <ferruh.yigit@xilinx.com>
---
 drivers/net/af_xdp/meson.build | 21 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)

diff --git a/drivers/net/af_xdp/meson.build b/drivers/net/af_xdp/meson.build
index fa011c357d..a01a67c7e7 100644
--- a/drivers/net/af_xdp/meson.build
+++ b/drivers/net/af_xdp/meson.build
@@ -19,7 +19,6 @@ endif
 if cc.has_header('linux/if_xdp.h')
     if xdp_dep.found() and cc.has_header('xdp/xsk.h')
         cflags += ['-DRTE_NET_AF_XDP_LIBXDP']
-        cflags += ['-DRTE_NET_AF_XDP_SHARED_UMEM']
         ext_deps += xdp_dep
         if bpf_dep.found() and cc.has_header('bpf/bpf.h')
             ext_deps += bpf_dep
@@ -39,11 +38,6 @@ if cc.has_header('linux/if_xdp.h')
                                  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 ' + libxdp_ver + '" or "libbpf <= v0.6.0"'
@@ -56,3 +50,18 @@ else
     build = false
     reason = 'missing header, "linux/if_xdp.h"'
 endif
+
+if build
+  xsk_check_prefix = '''
+#ifdef RTE_NET_AF_XDP_LIBXDP
+#include <xdp/xsk.h>
+#else
+#include <bpf/xsk.h>
+#endif
+  '''
+
+  if cc.has_function('xsk_socket__create_shared', prefix : xsk_check_prefix,
+                     dependencies : ext_deps)
+      cflags += ['-DRTE_NET_AF_XDP_SHARED_UMEM']
+  endif
+endif
-- 
2.33.0

