DPDK-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Marat Khalili <qm2k21@gmail.com>
To: Konstantin Ananyev <konstantin.ananyev@huawei.com>,
	Marat Khalili <qm2k21@gmail.com>
Cc: dev@dpdk.org, stephen@networkplumber.org
Subject: [PATCH 4/9] bpf: add callback flag to skip multi-thread check
Date: Sun, 11 Oct 2026 18:21:52 +0000	[thread overview]
Message-ID: <20261011182158.124246-5-qm2k21@gmail.com> (raw)
In-Reply-To: <20261011182158.124246-1-qm2k21@gmail.com>

Add RTE_BPF_ETH_F_SKIP_MT_CHECK flag allowing callers to bypass the
suitability check when installing BPF packet callbacks.

This allows overriding rejections in cases where the port or queue is
configured with multi-thread capabilities (such as MT_LOCKFREE),
but the application guarantees that only one dataplane thread
accesses the queue at a time.

Update the unit test to verify that callback installation succeeds
when this flag is specified.

Signed-off-by: Marat Khalili <qm2k21@gmail.com>
---
 app/test/test_bpf.c      | 20 ++++++++++++++++++++
 lib/bpf/bpf_pkt.c        |  8 +++++---
 lib/bpf/rte_bpf_ethdev.h |  5 ++++-
 3 files changed, 29 insertions(+), 4 deletions(-)

diff --git a/app/test/test_bpf.c b/app/test/test_bpf.c
index 02523984b5..0ab8aa8759 100644
--- a/app/test/test_bpf.c
+++ b/app/test/test_bpf.c
@@ -4692,7 +4692,27 @@ test_bpf_elf_tx_mt_lockfree(load_elf_image_t load_elf_image)
 		goto fail;
 	}
 
+	/* Tx installation must succeed when check is skipped with flag */
+	ret = rte_bpf_eth_tx_install(port, 0, bpf, RTE_BPF_ETH_F_SKIP_MT_CHECK);
+	if (ret != 0) {
+		printf("%s@%d: expected rte_bpf_eth_tx_install with SKIP_MT_CHECK to succeed, got %d\n",
+		       __func__, __LINE__, ret);
+		ret = TEST_FAILED;
+		goto fail;
+	}
+	rte_bpf_eth_tx_unload(port, 0);
+	bpf = NULL;
+
 	/* Rx installation on the same port must still succeed */
+	bpf = load_elf_image(app_test_bpf_filter_o, app_test_bpf_filter_o_len, "filter",
+			     NULL, 0, &prog_arg);
+	if (bpf == NULL) {
+		printf("%s@%d: failed to load BPF filter image\n",
+		       __func__, __LINE__);
+		ret = TEST_FAILED;
+		goto fail;
+	}
+
 	ret = rte_bpf_eth_rx_install(port, 0, bpf, 0);
 	if (ret != 0) {
 		printf("%s@%d: expected rte_bpf_eth_rx_install to succeed, got %d\n",
diff --git a/lib/bpf/bpf_pkt.c b/lib/bpf/bpf_pkt.c
index eab85f7417..7ee16cfa69 100644
--- a/lib/bpf/bpf_pkt.c
+++ b/lib/bpf/bpf_pkt.c
@@ -614,9 +614,11 @@ bpf_eth_elf_install(struct bpf_eth_cbh *cbh, uint16_t port, uint16_t queue,
 	if (bpf->prm.nb_prog_arg != 1)
 		return -EINVAL;
 
-	rc = bpf_eth_check_mt(cbh, port, queue);
-	if (rc != 0)
-		return rc;
+	if ((flags & RTE_BPF_ETH_F_SKIP_MT_CHECK) == 0) {
+		rc = bpf_eth_check_mt(cbh, port, queue);
+		if (rc != 0)
+			return rc;
+	}
 
 	if (cbh->type == BPF_ETH_RX)
 		frx = select_rx_callback(bpf->prm.prog_arg[0].type, flags);
diff --git a/lib/bpf/rte_bpf_ethdev.h b/lib/bpf/rte_bpf_ethdev.h
index cf3b4048f0..7a9f87e6cb 100644
--- a/lib/bpf/rte_bpf_ethdev.h
+++ b/lib/bpf/rte_bpf_ethdev.h
@@ -13,7 +13,8 @@
  * - in the data plane, it expects only one thread per port/queue pair at a time.
  *   Calling RX/TX burst functions concurrently on the same queue (e.g. when using
  *   RTE_ETH_TX_OFFLOAD_MT_LOCKFREE, shared RX queues, or multi-threaded
- *   software PMDs) is not supported.
+ *   software PMDs) is not supported and will be rejected at installation time
+ *   unless overridden by RTE_BPF_ETH_F_SKIP_MT_CHECK.
  * - in the control plane, it is not MT safe, i.e. it is not allowed to do
  *   load/unload for the same port/queue from different threads in parallel.
  * - though it allows load/unload at runtime
@@ -37,6 +38,8 @@ extern "C" {
 enum {
 	RTE_BPF_ETH_F_NONE = 0,
 	RTE_BPF_ETH_F_JIT  = 0x1, /**< use compiled into native ISA code */
+	RTE_BPF_ETH_F_SKIP_MT_CHECK = 0x2,
+	/**< skip check for concurrent data plane thread usage */
 };
 
 /**
-- 
2.43.0


  parent reply	other threads:[~2026-10-11 18:23 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-11 18:21 [PATCH 0/9] bpf: clean up and document ethdev callback synchronization Marat Khalili
2026-10-11 18:21 ` [PATCH 1/9] bpf: document packet callback unload sequence Marat Khalili
2026-10-11 18:21 ` [PATCH 2/9] bpf: document ethdev callback threading limitations Marat Khalili
2026-10-11 18:21 ` [PATCH 3/9] bpf: reject Tx callback installation with MT_LOCKFREE Marat Khalili
2026-10-11 18:21 ` Marat Khalili [this message]
2026-10-11 19:48   ` [PATCH 4/9] bpf: add callback flag to skip multi-thread check Stephen Hemminger
2026-10-11 20:12     ` Marat Khalili
2026-10-11 18:21 ` [PATCH 5/9] bpf: remove redundant memory barrier on unload Marat Khalili
2026-10-11 19:50   ` Stephen Hemminger
2026-10-11 20:14     ` Marat Khalili
2026-10-11 18:21 ` [PATCH 6/9] bpf: simplify callback inuse tracking to boolean flag Marat Khalili
2026-10-11 19:51   ` Stephen Hemminger
2026-10-11 20:17     ` Marat Khalili
2026-10-11 18:21 ` [PATCH 7/9] bpf: reformat packet callback unload diagram Marat Khalili
2026-10-11 18:21 ` [PATCH 8/9] bpf: use relaxed stores for callback inuse tracking Marat Khalili
2026-10-11 19:52   ` Stephen Hemminger
2026-10-11 20:24     ` Marat Khalili
2026-10-11 18:21 ` [PATCH 9/9] bpf: make callback handle atomic with relaxed access Marat Khalili
2026-10-11 19:54   ` Stephen Hemminger
2026-10-11 20:31     ` Marat Khalili
2026-10-11 20:29 ` [RFC] bpf: fix callback unload with concurrent Tx burst Stephen Hemminger
2026-10-12 21:09 ` [PATCH v2 0/9] bpf: clean up and document ethdev callback synchronization Marat Khalili
2026-10-12 21:09   ` [PATCH v2 1/9] bpf: document packet callback unload sequence Marat Khalili
2026-10-12 21:09   ` [PATCH v2 2/9] bpf: document ethdev callback threading limitations Marat Khalili
2026-10-12 21:44     ` Stephen Hemminger
2026-10-12 21:09   ` [PATCH v2 3/9] bpf: reject Tx callback installation with MT_LOCKFREE Marat Khalili
2026-10-12 21:09   ` [PATCH v2 4/9] bpf: remove redundant memory barrier on unload Marat Khalili
2026-10-12 21:09   ` [PATCH v2 5/9] bpf: simplify callback inuse tracking to boolean flag Marat Khalili
2026-10-12 21:09   ` [PATCH v2 6/9] bpf: reformat packet callback unload diagram Marat Khalili
2026-10-12 21:09   ` [PATCH v2 7/9] bpf: use relaxed accesses for callback inuse tracking Marat Khalili
2026-10-12 21:09   ` [PATCH v2 8/9] bpf: make callback handle atomic with relaxed access Marat Khalili
2026-10-12 21:09   ` [PATCH v2 9/9] bpf: add callback flag to skip multi-thread check Marat Khalili
2026-10-13 16:55     ` Stephen Hemminger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261011182158.124246-5-qm2k21@gmail.com \
    --to=qm2k21@gmail.com \
    --cc=dev@dpdk.org \
    --cc=konstantin.ananyev@huawei.com \
    --cc=stephen@networkplumber.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox