From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 130EAA0093; Fri, 10 Dec 2021 11:59:38 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 956404014F; Fri, 10 Dec 2021 11:59:37 +0100 (CET) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by mails.dpdk.org (Postfix) with ESMTP id C0ABE40041 for ; Fri, 10 Dec 2021 11:59:35 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1639133976; x=1670669976; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=K3XJfyOJpZEs2fsITEAeqnt2O16bOCsodGElPmeHUJA=; b=hR3+VKOSG8YfX6neFgNWCiPa5bU+5LjzmSNBkqjCGMHboQ+IIoSls4xi yie5bBdymjMv72G6u9s8awqPMdlbScc36OnGE4hw6OvfJ0RjMXRNV68tk 2lMMsWunip7LiZVLArCjuyFHBsgNfM8pT1c3PFQue+1ufm/IFKIJ/Rja1 P7tdNig7gvDG4FviwwB7NDqrnVDQyUkZtfvgE6q5yrZrDoqhj5TNvikLy Fzj4jRWCpsrWsrkqKT033bc9lnxDE2hFSoEem73eNMbrjI1KIyy5bGSK1 ExnT4DQH1F+TmWxhXY86k7gfiG+jVzZy0tWDh5b0CppWlc66Y7Pm0JMOE A==; X-IronPort-AV: E=McAfee;i="6200,9189,10193"; a="235839349" X-IronPort-AV: E=Sophos;i="5.88,195,1635231600"; d="scan'208";a="235839349" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Dec 2021 02:59:34 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.88,195,1635231600"; d="scan'208";a="516717681" Received: from silpixa00401086.ir.intel.com (HELO localhost.localdomain) ([10.55.129.110]) by orsmga008.jf.intel.com with ESMTP; 10 Dec 2021 02:59:33 -0800 From: Ciara Loftus To: dev@dpdk.org Cc: Ciara Loftus Subject: [RFC PATCH] net/af_xdp: use libxdp if available Date: Fri, 10 Dec 2021 10:58:53 +0000 Message-Id: <20211210105853.38161-1-ciara.loftus@intel.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org 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 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. [1] https://github.com/libbpf/libbpf/commit/277846bc6c15 Signed-off-by: Ciara Loftus --- doc/guides/nics/af_xdp.rst | 4 +-- doc/guides/rel_notes/release_22_03.rst | 4 +++ drivers/net/af_xdp/compat.h | 4 +++ drivers/net/af_xdp/meson.build | 45 +++++++++++++++++++++----- drivers/net/af_xdp/rte_eth_af_xdp.c | 1 - 5 files changed, 46 insertions(+), 12 deletions(-) diff --git a/doc/guides/nics/af_xdp.rst b/doc/guides/nics/af_xdp.rst index c9d0e1ad6c..966f713c11 100644 --- a/doc/guides/nics/af_xdp.rst +++ b/doc/guides/nics/af_xdp.rst @@ -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 - /tools/lib/bpf; +* Both libxdp 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; diff --git a/doc/guides/rel_notes/release_22_03.rst b/doc/guides/rel_notes/release_22_03.rst index 6d99d1eaa9..acf0f66fa8 100644 --- a/doc/guides/rel_notes/release_22_03.rst +++ b/doc/guides/rel_notes/release_22_03.rst @@ -55,6 +55,10 @@ New Features Also, make sure to start the actual text at the margin. ======================================================= +* **Update AF_XDP PMD** + + * Added libxdp support. + Removed Items ------------- diff --git a/drivers/net/af_xdp/compat.h b/drivers/net/af_xdp/compat.h index 3880dc7dd7..245df1b109 100644 --- a/drivers/net/af_xdp/compat.h +++ b/drivers/net/af_xdp/compat.h @@ -2,7 +2,11 @@ * Copyright(c) 2020 Intel Corporation. */ +#ifdef RTE_LIBRTE_AF_XDP_PMD_LIBXDP +#include +#else #include +#endif #include #include diff --git a/drivers/net/af_xdp/meson.build b/drivers/net/af_xdp/meson.build index 3ed2b29784..dc4f53352e 100644 --- a/drivers/net/af_xdp/meson.build +++ b/drivers/net/af_xdp/meson.build @@ -9,19 +9,48 @@ endif sources = files('rte_eth_af_xdp.c') +xdp_dep = dependency('libxdp', required: false, method: 'pkg-config') +if not xdp_dep.found() + xdp_dep = cc.find_library('xdp', required: false) +endif + 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') + dpdk_conf.set('RTE_LIBRTE_AF_XDP_PMD_LIBXDP', 1) + dpdk_conf.set('RTE_LIBRTE_AF_XDP_PMD_SHARED_UMEM', 1) + 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() + dpdk_conf.set('RTE_LIBRTE_AF_XDP_PMD_SHARED_UMEM', 1) + 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"' -endif + reason = 'missing header, "linux/if_xdp.h"' +endif \ No newline at end of file diff --git a/drivers/net/af_xdp/rte_eth_af_xdp.c b/drivers/net/af_xdp/rte_eth_af_xdp.c index 96c2c9d939..5d89bebb01 100644 --- a/drivers/net/af_xdp/rte_eth_af_xdp.c +++ b/drivers/net/af_xdp/rte_eth_af_xdp.c @@ -16,7 +16,6 @@ #include #include "af_xdp_deps.h" #include -#include #include #include -- 2.17.1