From patchwork Wed Oct 5 09:50:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Rybchenko X-Patchwork-Id: 117377 X-Patchwork-Delegate: andrew.rybchenko@oktetlabs.ru Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 07C9FA0542; Wed, 5 Oct 2022 11:50:57 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id ED461427EB; Wed, 5 Oct 2022 11:50:48 +0200 (CEST) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [91.220.146.113]) by mails.dpdk.org (Postfix) with ESMTP id 6BDE740DFB for ; Wed, 5 Oct 2022 11:50:47 +0200 (CEST) Received: by shelob.oktetlabs.ru (Postfix, from userid 115) id 165EC86; Wed, 5 Oct 2022 12:50:47 +0300 (MSK) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mail1.oktetlabs.ru X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=ALL_TRUSTED, DKIM_ADSP_DISCARD, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 Received: from aros.oktetlabs.ru (aros.oktetlabs.ru [192.168.38.17]) by shelob.oktetlabs.ru (Postfix) with ESMTP id 15E6A67; Wed, 5 Oct 2022 12:50:45 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 shelob.oktetlabs.ru 15E6A67 Authentication-Results: shelob.oktetlabs.ru/15E6A67; dkim=none; dkim-atps=neutral From: Andrew Rybchenko To: Ciara Loftus , Qi Zhang Cc: dev@dpdk.org Subject: [PATCH v3 1/6] net/af_xdp: move XDP library presence flag to right branch Date: Wed, 5 Oct 2022 12:50:32 +0300 Message-Id: <20221005095037.997006-3-andrew.rybchenko@oktetlabs.ru> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221005095037.997006-1-andrew.rybchenko@oktetlabs.ru> References: <20220624102354.1516606-1-ciara.loftus@intel.com> <20221005095037.997006-1-andrew.rybchenko@oktetlabs.ru> MIME-Version: 1.0 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 RTE_NET_AF_XDP_LIBXDP is a conditional to include xdp/xsk.h and should be set as soon as we know that the header is present. RTE_NET_AF_XDP_SHARED_UMEM is one of conditions to use xsk_socket__create_shared(). Both do not depend on libbpf and bpf/bpf.h presence. Since else branch below returns error, there is no functional changes, just style which will help on further rework. Signed-off-by: Andrew Rybchenko --- drivers/net/af_xdp/meson.build | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/af_xdp/meson.build b/drivers/net/af_xdp/meson.build index 1e0de23705..882d0b9518 100644 --- a/drivers/net/af_xdp/meson.build +++ b/drivers/net/af_xdp/meson.build @@ -17,10 +17,10 @@ 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') - cflags += ['-DRTE_NET_AF_XDP_LIBXDP'] - 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') From patchwork Wed Oct 5 09:50:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Rybchenko X-Patchwork-Id: 117378 X-Patchwork-Delegate: andrew.rybchenko@oktetlabs.ru Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 08DD7A0542; Wed, 5 Oct 2022 11:51:02 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id CDE58427F5; Wed, 5 Oct 2022 11:50:49 +0200 (CEST) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [91.220.146.113]) by mails.dpdk.org (Postfix) with ESMTP id 796C640E2D for ; Wed, 5 Oct 2022 11:50:47 +0200 (CEST) Received: by shelob.oktetlabs.ru (Postfix, from userid 115) id 36D1E87; Wed, 5 Oct 2022 12:50:47 +0300 (MSK) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mail1.oktetlabs.ru X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=ALL_TRUSTED, DKIM_ADSP_DISCARD, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 Received: from aros.oktetlabs.ru (aros.oktetlabs.ru [192.168.38.17]) by shelob.oktetlabs.ru (Postfix) with ESMTP id 41F1B69; Wed, 5 Oct 2022 12:50:45 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 shelob.oktetlabs.ru 41F1B69 Authentication-Results: shelob.oktetlabs.ru/41F1B69; dkim=none; dkim-atps=neutral From: Andrew Rybchenko To: Ciara Loftus , Qi Zhang Cc: dev@dpdk.org Subject: [PATCH v3 2/6] net/af_xdp: make it clear which libxdp version is required Date: Wed, 5 Oct 2022 12:50:33 +0300 Message-Id: <20221005095037.997006-4-andrew.rybchenko@oktetlabs.ru> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221005095037.997006-1-andrew.rybchenko@oktetlabs.ru> References: <20220624102354.1516606-1-ciara.loftus@intel.com> <20221005095037.997006-1-andrew.rybchenko@oktetlabs.ru> MIME-Version: 1.0 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 Include checked libxdp version in driver build skip reason. Signed-off-by: Andrew Rybchenko --- drivers/net/af_xdp/meson.build | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/net/af_xdp/meson.build b/drivers/net/af_xdp/meson.build index 882d0b9518..fa011c357d 100644 --- a/drivers/net/af_xdp/meson.build +++ b/drivers/net/af_xdp/meson.build @@ -9,7 +9,8 @@ endif sources = files('rte_eth_af_xdp.c') -xdp_dep = dependency('libxdp', version : '>=1.2.2', required: false, method: 'pkg-config') +libxdp_ver = '>=1.2.2' +xdp_dep = dependency('libxdp', version : libxdp_ver, 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) @@ -45,11 +46,11 @@ if cc.has_header('linux/if_xdp.h') endif else build = false - reason = 'missing dependency, "libxdp" or "libbpf <= v0.6.0"' + reason = 'missing dependency, "libxdp ' + libxdp_ver + '" or "libbpf <= v0.6.0"' endif else build = false - reason = 'missing dependency, "libxdp" and "libbpf"' + reason = 'missing dependency, "libxdp ' + libxdp_ver + '" and "libbpf"' endif else build = false From patchwork Wed Oct 5 09:50:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Rybchenko X-Patchwork-Id: 117379 X-Patchwork-Delegate: andrew.rybchenko@oktetlabs.ru Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 053A1A0542; Wed, 5 Oct 2022 11:51:07 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B035A4280E; Wed, 5 Oct 2022 11:50:50 +0200 (CEST) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [91.220.146.113]) by mails.dpdk.org (Postfix) with ESMTP id AF07040DFB for ; Wed, 5 Oct 2022 11:50:47 +0200 (CEST) Received: by shelob.oktetlabs.ru (Postfix, from userid 115) id 7D28490; Wed, 5 Oct 2022 12:50:47 +0300 (MSK) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mail1.oktetlabs.ru X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=ALL_TRUSTED, DKIM_ADSP_DISCARD, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 Received: from aros.oktetlabs.ru (aros.oktetlabs.ru [192.168.38.17]) by shelob.oktetlabs.ru (Postfix) with ESMTP id 707B274; Wed, 5 Oct 2022 12:50:45 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 shelob.oktetlabs.ru 707B274 Authentication-Results: shelob.oktetlabs.ru/707B274; dkim=none; dkim-atps=neutral From: Andrew Rybchenko To: Ciara Loftus , Qi Zhang Cc: dev@dpdk.org Subject: [PATCH v3 3/6] net/af_xdp: avoid version-based check for shared UMEM Date: Wed, 5 Oct 2022 12:50:34 +0300 Message-Id: <20221005095037.997006-5-andrew.rybchenko@oktetlabs.ru> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221005095037.997006-1-andrew.rybchenko@oktetlabs.ru> References: <20220624102354.1516606-1-ciara.loftus@intel.com> <20221005095037.997006-1-andrew.rybchenko@oktetlabs.ru> MIME-Version: 1.0 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 Check for xsk_socket__create_shared() function instead. Signed-off-by: Andrew Rybchenko --- 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 +#else +#include +#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 From patchwork Wed Oct 5 09:50:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Rybchenko X-Patchwork-Id: 117380 X-Patchwork-Delegate: andrew.rybchenko@oktetlabs.ru Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 0E6D2A0542; Wed, 5 Oct 2022 11:51:12 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A6E514282E; Wed, 5 Oct 2022 11:50:51 +0200 (CEST) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [91.220.146.113]) by mails.dpdk.org (Postfix) with ESMTP id 32F5B42685 for ; Wed, 5 Oct 2022 11:50:48 +0200 (CEST) Received: by shelob.oktetlabs.ru (Postfix, from userid 115) id CA5CC87; Wed, 5 Oct 2022 12:50:47 +0300 (MSK) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mail1.oktetlabs.ru X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=ALL_TRUSTED, DKIM_ADSP_DISCARD, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 Received: from aros.oktetlabs.ru (aros.oktetlabs.ru [192.168.38.17]) by shelob.oktetlabs.ru (Postfix) with ESMTP id 9AE897B; Wed, 5 Oct 2022 12:50:45 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 shelob.oktetlabs.ru 9AE897B Authentication-Results: shelob.oktetlabs.ru/9AE897B; dkim=none; dkim-atps=neutral From: Andrew Rybchenko To: Ciara Loftus , Qi Zhang Cc: dev@dpdk.org Subject: [PATCH v3 4/6] net/af_xdp: avoid version-based check for program load mech Date: Wed, 5 Oct 2022 12:50:35 +0300 Message-Id: <20221005095037.997006-6-andrew.rybchenko@oktetlabs.ru> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221005095037.997006-1-andrew.rybchenko@oktetlabs.ru> References: <20220624102354.1516606-1-ciara.loftus@intel.com> <20221005095037.997006-1-andrew.rybchenko@oktetlabs.ru> MIME-Version: 1.0 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 Version-based checks are bad. It is better to check for required functions. Check for bpf_object__next_program() in this case since it appears last in libbpf among functions used to load program without bpf_prog_load() which is deprecated in libbpf v0.7.0. Signed-off-by: Andrew Rybchenko --- drivers/net/af_xdp/meson.build | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/net/af_xdp/meson.build b/drivers/net/af_xdp/meson.build index a01a67c7e7..9d5ffab96b 100644 --- a/drivers/net/af_xdp/meson.build +++ b/drivers/net/af_xdp/meson.build @@ -22,11 +22,6 @@ if cc.has_header('linux/if_xdp.h') ext_deps += xdp_dep if bpf_dep.found() and cc.has_header('bpf/bpf.h') 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 else build = false reason = 'missing dependency, libbpf' @@ -64,4 +59,9 @@ if build dependencies : ext_deps) cflags += ['-DRTE_NET_AF_XDP_SHARED_UMEM'] endif + if cc.has_function('bpf_object__next_program', + prefix : '#include ', + dependencies : bpf_dep) + cflags += ['-DRTE_NET_AF_XDP_LIBBPF_OBJ_OPEN'] + endif endif From patchwork Wed Oct 5 09:50:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Rybchenko X-Patchwork-Id: 117381 X-Patchwork-Delegate: andrew.rybchenko@oktetlabs.ru Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 23862A0542; Wed, 5 Oct 2022 11:51:17 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9EE8C42905; Wed, 5 Oct 2022 11:50:52 +0200 (CEST) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [91.220.146.113]) by mails.dpdk.org (Postfix) with ESMTP id 4A0F642686 for ; Wed, 5 Oct 2022 11:50:48 +0200 (CEST) Received: by shelob.oktetlabs.ru (Postfix, from userid 115) id 0B99B7B; Wed, 5 Oct 2022 12:50:47 +0300 (MSK) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mail1.oktetlabs.ru X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=ALL_TRUSTED, DKIM_ADSP_DISCARD autolearn=no autolearn_force=no version=3.4.6 Received: from aros.oktetlabs.ru (aros.oktetlabs.ru [192.168.38.17]) by shelob.oktetlabs.ru (Postfix) with ESMTP id 553047F; Wed, 5 Oct 2022 12:50:45 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 shelob.oktetlabs.ru 553047F Authentication-Results: shelob.oktetlabs.ru/553047F; dkim=none; dkim-atps=neutral From: Andrew Rybchenko To: Ciara Loftus , Qi Zhang Cc: dev@dpdk.org Subject: [PATCH v3 5/6] net/af_xdp: log errors on XDP program removal failures Date: Wed, 5 Oct 2022 12:50:36 +0300 Message-Id: <20221005095037.997006-7-andrew.rybchenko@oktetlabs.ru> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221005095037.997006-1-andrew.rybchenko@oktetlabs.ru> References: <20220624102354.1516606-1-ciara.loftus@intel.com> <20221005095037.997006-1-andrew.rybchenko@oktetlabs.ru> MIME-Version: 1.0 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 Make it visible in logs if something goes wrong on XDP program removal failure. Signed-off-by: Andrew Rybchenko --- drivers/net/af_xdp/rte_eth_af_xdp.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/drivers/net/af_xdp/rte_eth_af_xdp.c b/drivers/net/af_xdp/rte_eth_af_xdp.c index 9957de2314..f7c2321a18 100644 --- a/drivers/net/af_xdp/rte_eth_af_xdp.c +++ b/drivers/net/af_xdp/rte_eth_af_xdp.c @@ -866,18 +866,24 @@ eth_stats_reset(struct rte_eth_dev *dev) return 0; } -static void +static int remove_xdp_program(struct pmd_internals *internals) { uint32_t curr_prog_id = 0; + int ret; - if (bpf_get_link_xdp_id(internals->if_index, &curr_prog_id, - XDP_FLAGS_UPDATE_IF_NOEXIST)) { + ret = bpf_get_link_xdp_id(internals->if_index, &curr_prog_id, + XDP_FLAGS_UPDATE_IF_NOEXIST); + if (ret != 0) { AF_XDP_LOG(ERR, "bpf_get_link_xdp_id failed\n"); - return; + return ret; } - bpf_set_link_xdp_fd(internals->if_index, -1, - XDP_FLAGS_UPDATE_IF_NOEXIST); + + ret = bpf_set_link_xdp_fd(internals->if_index, -1, + XDP_FLAGS_UPDATE_IF_NOEXIST); + if (ret != 0) + AF_XDP_LOG(ERR, "bpf_set_link_xdp_fd failed\n"); + return ret; } static void @@ -932,7 +938,8 @@ eth_dev_close(struct rte_eth_dev *dev) */ dev->data->mac_addrs = NULL; - remove_xdp_program(internals); + if (remove_xdp_program(internals) != 0) + AF_XDP_LOG(ERR, "Error while removing XDP program.\n"); if (internals->shared_umem) { struct internal_list *list; From patchwork Wed Oct 5 09:50:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Rybchenko X-Patchwork-Id: 117382 X-Patchwork-Delegate: andrew.rybchenko@oktetlabs.ru Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 83F8BA0542; Wed, 5 Oct 2022 11:51:22 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 82ABC42B6F; Wed, 5 Oct 2022 11:50:53 +0200 (CEST) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [91.220.146.113]) by mails.dpdk.org (Postfix) with ESMTP id 5DB88427EB for ; Wed, 5 Oct 2022 11:50:48 +0200 (CEST) Received: by shelob.oktetlabs.ru (Postfix, from userid 115) id 466FD5D; Wed, 5 Oct 2022 12:50:48 +0300 (MSK) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mail1.oktetlabs.ru X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=ALL_TRUSTED, DKIM_ADSP_DISCARD, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 Received: from aros.oktetlabs.ru (aros.oktetlabs.ru [192.168.38.17]) by shelob.oktetlabs.ru (Postfix) with ESMTP id 851CF5D; Wed, 5 Oct 2022 12:50:46 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 shelob.oktetlabs.ru 851CF5D Authentication-Results: shelob.oktetlabs.ru/851CF5D; dkim=none; dkim-atps=neutral From: Andrew Rybchenko To: Ciara Loftus , Qi Zhang Cc: dev@dpdk.org Subject: [PATCH v3 6/6] net/af_xdp: make compatible with libbpf v0.8.0 Date: Wed, 5 Oct 2022 12:50:37 +0300 Message-Id: <20221005095037.997006-8-andrew.rybchenko@oktetlabs.ru> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221005095037.997006-1-andrew.rybchenko@oktetlabs.ru> References: <20220624102354.1516606-1-ciara.loftus@intel.com> <20221005095037.997006-1-andrew.rybchenko@oktetlabs.ru> MIME-Version: 1.0 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 From: Ciara Loftus libbpf v0.8.0 deprecates the bpf_get_link_xdp_id() and bpf_set_link_xdp_fd() functions. Use meson to detect if bpf_xdp_attach() is available and if so, use the recommended replacement functions bpf_xdp_query_id(), bpf_xdp_attach() and bpf_xdp_detach(). Signed-off-by: Ciara Loftus Signed-off-by: Andrew Rybchenko --- doc/guides/nics/af_xdp.rst | 3 +- doc/guides/rel_notes/release_22_11.rst | 4 +++ drivers/net/af_xdp/meson.build | 5 ++++ drivers/net/af_xdp/rte_eth_af_xdp.c | 38 +++++++++++++++++++++++++- 4 files changed, 48 insertions(+), 2 deletions(-) diff --git a/doc/guides/nics/af_xdp.rst b/doc/guides/nics/af_xdp.rst index d42e0f1f79..ca23940e22 100644 --- a/doc/guides/nics/af_xdp.rst +++ b/doc/guides/nics/af_xdp.rst @@ -45,7 +45,8 @@ Prerequisites This is a Linux-specific PMD, thus the following prerequisites apply: * A Linux Kernel (version > v4.18) with XDP sockets configuration enabled; -* Both libxdp >=v1.2.2 and libbpf libraries installed, or, libbpf <=v0.6.0 +* Both libxdp >=v1.2.2 and libbpf <=v0.8.0 libraries installed, or, libbpf + <=v0.6.0. * If using libxdp, it requires an environment variable called LIBXDP_OBJECT_PATH to be set to the location of where libxdp placed its bpf object files. This is usually in /usr/local/lib/bpf or /usr/local/lib64/bpf. diff --git a/doc/guides/rel_notes/release_22_11.rst b/doc/guides/rel_notes/release_22_11.rst index 7e03388306..c1f18aecc9 100644 --- a/doc/guides/rel_notes/release_22_11.rst +++ b/doc/guides/rel_notes/release_22_11.rst @@ -78,6 +78,10 @@ New Features Added new rte_flow action which allows application to re-route packets directly to the kernel without software involvement. +* **Updated AF_XDP PMD.** + + * Made compatible with libbpf v0.8.0 (when used with libxdp). + * **Updated Intel iavf driver.** * Added flow subscription support. diff --git a/drivers/net/af_xdp/meson.build b/drivers/net/af_xdp/meson.build index 9d5ffab96b..858047989e 100644 --- a/drivers/net/af_xdp/meson.build +++ b/drivers/net/af_xdp/meson.build @@ -64,4 +64,9 @@ if build dependencies : bpf_dep) cflags += ['-DRTE_NET_AF_XDP_LIBBPF_OBJ_OPEN'] endif + if cc.has_function('bpf_xdp_attach', + prefix : '#include ', + dependencies : bpf_dep) + cflags += ['-DRTE_NET_AF_XDP_LIBBPF_XDP_ATTACH'] + endif endif diff --git a/drivers/net/af_xdp/rte_eth_af_xdp.c b/drivers/net/af_xdp/rte_eth_af_xdp.c index f7c2321a18..b6ec9bf490 100644 --- a/drivers/net/af_xdp/rte_eth_af_xdp.c +++ b/drivers/net/af_xdp/rte_eth_af_xdp.c @@ -866,6 +866,40 @@ eth_stats_reset(struct rte_eth_dev *dev) return 0; } +#ifdef RTE_NET_AF_XDP_LIBBPF_XDP_ATTACH + +static int link_xdp_prog_with_dev(int ifindex, int fd, __u32 flags) +{ + return bpf_xdp_attach(ifindex, fd, flags, NULL); +} + +static int +remove_xdp_program(struct pmd_internals *internals) +{ + uint32_t curr_prog_id = 0; + int ret; + + ret = bpf_xdp_query_id(internals->if_index, XDP_FLAGS_UPDATE_IF_NOEXIST, + &curr_prog_id); + if (ret != 0) { + AF_XDP_LOG(ERR, "bpf_xdp_query_id failed\n"); + return ret; + } + + ret = bpf_xdp_detach(internals->if_index, XDP_FLAGS_UPDATE_IF_NOEXIST, + NULL); + if (ret != 0) + AF_XDP_LOG(ERR, "bpf_xdp_detach failed\n"); + return ret; +} + +#else + +static int link_xdp_prog_with_dev(int ifindex, int fd, __u32 flags) +{ + return bpf_set_link_xdp_fd(ifindex, fd, flags); +} + static int remove_xdp_program(struct pmd_internals *internals) { @@ -886,6 +920,8 @@ remove_xdp_program(struct pmd_internals *internals) return ret; } +#endif + static void xdp_umem_destroy(struct xsk_umem_info *umem) { @@ -1205,7 +1241,7 @@ load_custom_xdp_prog(const char *prog_path, int if_index, struct bpf_map **map) } /* Link the program with the given network device */ - ret = bpf_set_link_xdp_fd(if_index, prog_fd, + ret = link_xdp_prog_with_dev(if_index, prog_fd, XDP_FLAGS_UPDATE_IF_NOEXIST); if (ret) { AF_XDP_LOG(ERR, "Failed to set prog fd %d on interface\n",