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 42BF7A0503 for ; Fri, 6 May 2022 13:03:52 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3BD574014F; Fri, 6 May 2022 13:03:52 +0200 (CEST) Received: from us-smtp-delivery-74.mimecast.com (us-smtp-delivery-74.mimecast.com [170.10.129.74]) by mails.dpdk.org (Postfix) with ESMTP id 002824069F for ; Fri, 6 May 2022 13:03:50 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1651835030; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Dy5J9WtjRn92hzKaK6nymAfEzoIFVC34pJUDW20CsFI=; b=TuRJZYpw9xv0VjXRUAcwtVPZfMnkzahWG+XSOoaOS+W16QhpS1IIbqYa2YfDF9Y1/gI0xT GWnA2oWgUgGDPhKsjVZJjOe2FbxK535mwgXJQKBhN1Wta1lHMVZkdZi66y8+XIzgNa2ohy DJxX84Y7hg68KSpg49iEjKB1zmYBIqg= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-423-1JD37SlLNPGM0NRytz_C6g-1; Fri, 06 May 2022 07:03:47 -0400 X-MC-Unique: 1JD37SlLNPGM0NRytz_C6g-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 53312380390B; Fri, 6 May 2022 11:03:47 +0000 (UTC) Received: from rh.redhat.com (unknown [10.39.195.180]) by smtp.corp.redhat.com (Postfix) with ESMTP id EB1511121315; Fri, 6 May 2022 11:03:44 +0000 (UTC) From: Kevin Traynor To: ciara.loftus@intel.com, stable@dpdk.org Cc: bluca@debian.org, christian.ehrhardt@canonical.com, xuemingl@nvidia.com Subject: [PATCH 21.11 1/2] net/af_xdp: use libxdp if available Date: Fri, 6 May 2022 12:03:36 +0100 Message-Id: <20220506110337.267796-2-ktraynor@redhat.com> In-Reply-To: <20220506110337.267796-1-ktraynor@redhat.com> References: <20220506110337.267796-1-ktraynor@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=ktraynor@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org From: Ciara Loftus [ upstream commit fa4dfda5fe9c3483944955986b60f4d536c4a8bc ] 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 --- doc/guides/nics/af_xdp.rst | 6 ++--- drivers/net/af_xdp/compat.h | 6 ++++- drivers/net/af_xdp/meson.build | 39 +++++++++++++++++++++++------ drivers/net/af_xdp/rte_eth_af_xdp.c | 1 - 4 files changed, 39 insertions(+), 13 deletions(-) diff --git a/doc/guides/nics/af_xdp.rst b/doc/guides/nics/af_xdp.rst index c9d0e1ad6c..db02ea1984 100644 --- a/doc/guides/nics/af_xdp.rst +++ b/doc/guides/nics/af_xdp.rst @@ -44,7 +44,5 @@ 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 >=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; @@ -144,3 +142,3 @@ Limitations 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/ diff --git a/drivers/net/af_xdp/compat.h b/drivers/net/af_xdp/compat.h index 3880dc7dd7..bf40c6572e 100644 --- a/drivers/net/af_xdp/compat.h +++ b/drivers/net/af_xdp/compat.h @@ -3,10 +3,14 @@ */ +#ifdef RTE_NET_AF_XDP_LIBXDP +#include +#else #include +#endif #include #include #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 diff --git a/drivers/net/af_xdp/meson.build b/drivers/net/af_xdp/meson.build index 3ed2b29784..93e895eab9 100644 --- a/drivers/net/af_xdp/meson.build +++ b/drivers/net/af_xdp/meson.build @@ -10,4 +10,5 @@ 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() @@ -15,13 +16,37 @@ if not bpf_dep.found() 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 diff --git a/drivers/net/af_xdp/rte_eth_af_xdp.c b/drivers/net/af_xdp/rte_eth_af_xdp.c index 80aa55fb22..0366211243 100644 --- a/drivers/net/af_xdp/rte_eth_af_xdp.c +++ b/drivers/net/af_xdp/rte_eth_af_xdp.c @@ -17,5 +17,4 @@ #include "af_xdp_deps.h" #include -#include #include -- 2.34.1