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 8D93143699 for ; Thu, 7 Dec 2023 12:21:54 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8730E42F0D; Thu, 7 Dec 2023 12:21:54 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mails.dpdk.org (Postfix) with ESMTP id 4A78A42F06 for ; Thu, 7 Dec 2023 12:21:53 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1701948112; 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=VcKGal1s6VXX5UPdO+D38jb3rKcBvlF4PX0HwKpw9tk=; b=Q8nrBPUXIUqjrtyeHQEoC3ot4lAfGzQGYURtprox5JCWd2+GWcBfOoqnGlWtsNYYWnrgTj eBQ1M6o+ZrLybPzmyZzSX7M5YfM41Qy/Oacu46A2Z+OdfkFrm5yPc4SswLbx3toF9pazoJ 0kLz56tCK5WNI/Kg78EMJti8QtZGELo= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-592-mBcJ9INpNLuxaFK8AKQo3g-1; Thu, 07 Dec 2023 06:21:51 -0500 X-MC-Unique: mBcJ9INpNLuxaFK8AKQo3g-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 360D98352A1; Thu, 7 Dec 2023 11:21:51 +0000 (UTC) Received: from rh.Home (unknown [10.39.192.7]) by smtp.corp.redhat.com (Postfix) with ESMTP id E2AFDC185A5; Thu, 7 Dec 2023 11:21:49 +0000 (UTC) From: Kevin Traynor To: Ciara Loftus Cc: Andrew Rybchenko , Ferruh Yigit , dpdk stable Subject: patch 'net/af_xdp: make compatible with libbpf 0.8.0' has been queued to stable release 21.11.6 Date: Thu, 7 Dec 2023 11:21:14 +0000 Message-ID: <20231207112116.769502-22-ktraynor@redhat.com> In-Reply-To: <20231207112116.769502-1-ktraynor@redhat.com> References: <20231207112116.769502-1-ktraynor@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 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 Hi, FYI, your patch has been queued to stable release 21.11.6 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 12/12/23. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. This will indicate if there was any rebasing needed to apply to the stable branch. If there were code changes for rebasing (ie: not only metadata diffs), please double check that the rebase was correctly done. Queued patches are on a temporary branch at: https://github.com/kevintraynor/dpdk-stable This queued commit can be viewed at: https://github.com/kevintraynor/dpdk-stable/commit/770e7c27240d09571a62627c3bc90b8e6e9f6024 Thanks. Kevin --- >From 770e7c27240d09571a62627c3bc90b8e6e9f6024 Mon Sep 17 00:00:00 2001 From: Ciara Loftus Date: Thu, 6 Oct 2022 09:26:54 +0300 Subject: [PATCH] net/af_xdp: make compatible with libbpf 0.8.0 [ upstream commit 1eb1846b1a2caaf77d0697747d3ecd1272ce0bfc ] 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 Reviewed-by: Ferruh Yigit --- drivers/net/af_xdp/meson.build | 8 ++++++ drivers/net/af_xdp/rte_eth_af_xdp.c | 38 ++++++++++++++++++++++++++++- 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/drivers/net/af_xdp/meson.build b/drivers/net/af_xdp/meson.build index 1e0de23705..2605086d0c 100644 --- a/drivers/net/af_xdp/meson.build +++ b/drivers/net/af_xdp/meson.build @@ -56,2 +56,10 @@ else reason = 'missing header, "linux/if_xdp.h"' endif + +if build + 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 9918d3c5fd..6bc7178fc5 100644 --- a/drivers/net/af_xdp/rte_eth_af_xdp.c +++ b/drivers/net/af_xdp/rte_eth_af_xdp.c @@ -859,7 +859,41 @@ eth_stats_reset(struct rte_eth_dev *dev) } +#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 + #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wdeprecated-declarations" +static int link_xdp_prog_with_dev(int ifindex, int fd, __u32 flags) +{ + return bpf_set_link_xdp_fd(ifindex, fd, flags); +} + static void remove_xdp_program(struct pmd_internals *internals) @@ -878,4 +912,6 @@ remove_xdp_program(struct pmd_internals *internals) #pragma GCC diagnostic pop +#endif + static void xdp_umem_destroy(struct xsk_umem_info *umem) @@ -1190,5 +1226,5 @@ 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) { -- 2.43.0 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2023-12-07 11:19:00.123229717 +0000 +++ 0022-net-af_xdp-make-compatible-with-libbpf-0.8.0.patch 2023-12-07 11:18:59.651874009 +0000 @@ -1 +1 @@ -From 1eb1846b1a2caaf77d0697747d3ecd1272ce0bfc Mon Sep 17 00:00:00 2001 +From 770e7c27240d09571a62627c3bc90b8e6e9f6024 Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit 1eb1846b1a2caaf77d0697747d3ecd1272ce0bfc ] + @@ -16,4 +18,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 +++++++++++++++++++++++++- - 3 files changed, 46 insertions(+), 1 deletion(-) + drivers/net/af_xdp/meson.build | 8 ++++++ + drivers/net/af_xdp/rte_eth_af_xdp.c | 38 ++++++++++++++++++++++++++++- + 2 files changed, 45 insertions(+), 1 deletion(-) @@ -21,13 +21,0 @@ -diff --git a/doc/guides/rel_notes/release_22_11.rst b/doc/guides/rel_notes/release_22_11.rst -index 5fbac5cfc1..aef2d622dd 100644 ---- a/doc/guides/rel_notes/release_22_11.rst -+++ b/doc/guides/rel_notes/release_22_11.rst -@@ -101,4 +101,8 @@ New Features - directly to the kernel without software involvement. - -+* **Updated AF_XDP driver.** -+ -+ * Made compatible with libbpf v0.8.0 (when used with libxdp). -+ - * **Updated Intel iavf driver.** - @@ -35 +23 @@ -index 9d5ffab96b..858047989e 100644 +index 1e0de23705..2605086d0c 100644 @@ -38,3 +26,5 @@ -@@ -65,3 +65,8 @@ if build - cflags += ['-DRTE_NET_AF_XDP_LIBBPF_OBJ_OPEN'] - endif +@@ -56,2 +56,10 @@ else + reason = 'missing header, "linux/if_xdp.h"' + endif ++ ++if build @@ -46 +36 @@ - endif ++endif @@ -48 +38 @@ -index f7c2321a18..b6ec9bf490 100644 +index 9918d3c5fd..6bc7178fc5 100644 @@ -51 +41 @@ -@@ -867,4 +867,38 @@ eth_stats_reset(struct rte_eth_dev *dev) +@@ -859,7 +859,41 @@ eth_stats_reset(struct rte_eth_dev *dev) @@ -82,0 +73,3 @@ + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wdeprecated-declarations" + @@ -88 +81 @@ - static int + static void @@ -90,2 +83,2 @@ -@@ -887,4 +921,6 @@ remove_xdp_program(struct pmd_internals *internals) - } +@@ -878,4 +912,6 @@ remove_xdp_program(struct pmd_internals *internals) + #pragma GCC diagnostic pop @@ -97 +90 @@ -@@ -1206,5 +1242,5 @@ load_custom_xdp_prog(const char *prog_path, int if_index, struct bpf_map **map) +@@ -1190,5 +1226,5 @@ load_custom_xdp_prog(const char *prog_path, int if_index, struct bpf_map **map)