Article View: linux.kernel.netdev
Article #27027[PATCH net-next v2 11/15] net/mlx5e: Receive into XDP-only memory providers
From: Björn Töpel
Date: Fri, 04 Dec 2026 16:27
Date: Fri, 04 Dec 2026 16:27
194 lines
16481 bytes
16481 bytes
mlx5 still refuses queue restarts with an XDP program, and its page
pools take no provider next to XDP.
Let striding RQs with a program take XDP-only providers, and accept
queue restarts with one, as other providers refuse XDP. Binds on the
cyclic RQ fail, as it would spin on a short FILL ring.
While a queue has such a provider, refuse with -EBUSY:
- a switch to the cyclic RQ;
- PTP RX, TX port timestamps and HTB offload, as queue restarts clone
no channel under them, so unbind would fail and binds fail with
-EOPNOTSUPP;
- growing the RQs of a device that is down, which would fail the next
open.
A devlink eswitch mode change bypasses these checks, leaving the queue
on system pages that the socket drops.
At MTU 1500, the linear RQ puts one packet per 4 KiB chunk. The
nonlinear RQ puts every byte in fragments, so its head reaches the
socket only with metadata. A bind or unbind pauses all channels
briefly.
Signed-off-by: Björn Töpel <bjorn@kernel.org>
---
Notes (v2changes):
Changes in v2:
- Move the skip of the wait for posted WQEs to patch 10, and use the
net/mlx5e prefix.
- Let only striding RQs take XDP-only providers. The cyclic RQ posts
whole bulks only, and would spin on a short FILL ring (Sashiko).
- Refuse a switch from the striding RQ to the cyclic one, PTP RX, TX
port timestamps and HTB offload while a queue has such a provider,
and growing the RQs while the device is down (Sashiko).
- The message covers the nonlinear RQ and its empty heads (Sashiko),
and says what users see.
.../net/ethernet/mellanox/mlx5/core/en_main.c | 62 ++++++++++++++++++-
.../net/ethernet/mellanox/mlx5/core/en_rx.c | 10 +--
2 files changed, 64 insertions(+), 8 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
index a76ba297c9a9..74a2ae37a587 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
@@ -1012,6 +1012,13 @@ static int mlx5e_alloc_rq(struct mlx5e_params *params,
pp_params.order = pool_order;
pp_params.flags = PP_FLAG_DMA_MAP | PP_FLAG_DMA_SYNC_DEV;
+ /* Trap and PTP RQs use queue 0 too, without a program. A
+ * cyclic RQ posts whole bulks only, and would spin in NAPI
+ * on a short FILL ring.
+ */
+ if (params->xdp_prog &&
+ rq->wq_type == MLX5_WQ_TYPE_LINKED_LIST_STRIDING_RQ)
+ pp_params.flags |= PP_FLAG_ALLOW_XDP_ONLY_NETMEM;
pp_params.pool_size = pool_size;
pp_params.nid = node;
pp_params.dev = rq->pdev;
@@ -3609,6 +3616,46 @@ int mlx5e_safe_switch_params(struct mlx5e_priv *priv,
bool old_first;
int err;
+ /* An XDP-only memory provider takes a striding RQ, and the socket
+ * that installed it would lose its queue without a word, also when
+ * the device opens later
+ */
+ if (priv->channels.params.rq_wq_type ==
+ MLX5_WQ_TYPE_LINKED_LIST_STRIDING_RQ &&
+ params->rq_wq_type != MLX5_WQ_TYPE_LINKED_LIST_STRIDING_RQ &&
+ mlx5e_has_xdp_only_mp(priv, priv->netdev->real_num_rx_queues)) {
+ netdev_warn(priv->netdev,
+ "Cannot leave the striding RQ while a queue has an XDP-only memory provider\n");
+ return -EBUSY;
+ }
+
+ /* mlx5e_queue_mem_alloc() clones no channel while PTP is on, so the
+ * provider of any queue could not go: its unbind restarts the queue
+ */
+ if (((params->ptp_rx && !priv->channels.params.ptp_rx) ||
+ (MLX5E_GET_PFLAG(params, MLX5E_PFLAG_TX_PORT_TS) &&
+ !MLX5E_GET_PFLAG(&priv->channels.params,
+ MLX5E_PFLAG_TX_PORT_TS))) &&
+ mlx5e_has_xdp_only_mp(priv, priv->netdev->real_num_rx_queues)) {
+ netdev_warn(priv->netdev,
+ "Cannot turn on PTP while a queue has an XDP-only memory provider\n");
+ return -EBUSY;
+ }
+
+ /* Closed channels open no RQ that would let the provider check a
+ * larger page pool, so the device would fail to open later
+ */
+ if (!test_bit(MLX5E_STATE_OPENED, &priv->state) &&
+ params->rq_wq_type == MLX5_WQ_TYPE_LINKED_LIST_STRIDING_RQ &&
+ mlx5e_mpwqe_get_log_rq_size(priv->mdev, params, NULL) >
+ mlx5e_mpwqe_get_log_rq_size(priv->mdev, &priv->channels.params,
+ NULL) &&
+ mlx5e_has_xdp_only_mp(priv, priv->netdev->real_num_rx_queues)) {
+ netdev_warn(priv->netdev,
+ "Cannot grow the RQs while the device is down and a queue has an XDP-only memory provider\n");
+ return -EBUSY;
+ }
+
reset &= test_bit(MLX5E_STATE_OPENED, &priv->state);
if (!reset)
return mlx5e_switch_priv_params(priv, params, preactivate, context);
@@ -4166,11 +4213,21 @@ static int mlx5e_setup_tc(struct net_device *dev, enum tc_setup_type type,
err = mlx5e_setup_tc_mqprio(priv, type_data);
mutex_unlock(&priv->state_lock);
return err;
- case TC_SETUP_QDISC_HTB:
+ case TC_SETUP_QDISC_HTB: {
+ struct tc_htb_qopt_offload *htb_qopt = type_data;
+
+ /* As for PTP, see mlx5e_safe_switch_params() */
+ if (htb_qopt->command == TC_HTB_CREATE &&
+ mlx5e_has_xdp_only_mp(priv, dev->real_num_rx_queues)) {
+ NL_SET_ERR_MSG_MOD(htb_qopt->extack,
+ "Cannot offload HTB while a queue has an XDP-only memory provider");
+ return -EBUSY;
+ }
mutex_lock(&priv->state_lock);
err = mlx5e_htb_setup_tc(priv, type_data);
mutex_unlock(&priv->state_lock);
return err;
+ }
default:
return -EOPNOTSUPP;
}
@@ -5872,10 +5929,9 @@ static int mlx5e_queue_mem_alloc(struct net_device *dev,
if (MLX5E_GET_PFLAG(&chs->params, MLX5E_PFLAG_TX_PORT_TS) ||
chs->params.ptp_rx ||
- chs->params.xdp_prog ||
priv->htb) {
netdev_err(priv->netdev,
- "Cloning channels with Port/rx PTP, XDP or HTB is not supported\n");
+ "Cloning channels with Port/rx PTP or HTB is not supported\n");
err = -EOPNOTSUPP;
goto unlock;
}
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c b/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
index 1586cb2404c0..43a382fcd3ad 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
@@ -327,7 +327,7 @@ static void *mlx5e_mpwqe_get_linear_page_frag(struct mlx5e_rq *rq)
frag_offset = li->frag_page.frags << MLX5E_XDP_LOG_MAX_LINEAR_SZ;
WARN_ON(frag_offset >= BIT(rq->mpwqe.page_shift));
- return netmem_address(li->frag_page.netmem) + frag_offset;
+ return xdp_netmem_address(li->frag_page.netmem) + frag_offset;
}
static inline int mlx5e_get_rx_frag(struct mlx5e_rq *rq,
@@ -1585,7 +1585,7 @@ mlx5e_skb_from_cqe_linear(struct mlx5e_rq *rq, struct mlx5e_wqe_frag_info *wi,
dma_addr_t addr;
u32 frag_size;
- va = netmem_address(frag_page->netmem) + wi->offset;
+ va = xdp_netmem_address(frag_page->netmem) + wi->offset;
data = va + rx_headroom;
frag_size = MLX5_SKB_FRAG_SZ(rx_headroom + cqe_bcnt);
@@ -1640,7 +1640,7 @@ mlx5e_skb_from_cqe_nonlinear(struct mlx5e_rq *rq, struct mlx5e_wqe_frag_info *wi
frag_page = wi->frag_page;
- va = netmem_address(frag_page->netmem) + wi->offset;
+ va = xdp_netmem_address(frag_page->netmem) + wi->offset;
frag_consumed_bytes = min_t(u32, frag_info->frag_size, cqe_bcnt);
addr = page_pool_get_dma_addr_netmem(frag_page->netmem);
@@ -1940,7 +1940,7 @@ mlx5e_skb_from_cqe_mpwrq_nonlinear(struct mlx5e_rq *rq, struct mlx5e_mpw_info *w
prog = rcu_dereference(rq->xdp_prog);
- head_addr = netmem_address(head_page->netmem) + head_offset;
+ head_addr = xdp_netmem_address(head_page->netmem) + head_offset;
if (prog) {
/* area for bpf_xdp_[store|load]_bytes */
@@ -2114,7 +2114,7 @@ mlx5e_skb_from_cqe_mpwrq_linear(struct mlx5e_rq *rq, struct mlx5e_mpw_info *wi,
return NULL;
}
- va = netmem_address(frag_page->netmem) + head_offset;
+ va = xdp_netmem_address(frag_page->netmem) + head_offset;
data = va + rx_headroom;
frag_size = MLX5_SKB_FRAG_SZ(rx_headroom + cqe_bcnt);
--
2.56.1
Technical Details
Message-ID:
<20261204162723.755897-12-bjorn@kernel.org>Path:
mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!2.eu.feeder.erje.net!feeder.erje.net!feeder1-2.proxad.net!proxad.net!feeder1-1.proxad.net!193.141.40.65.MISMATCH!npeer.as286.net!npeer-ng0.as286.net!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-377493-linux-kernel-netdev=dewy.ruReferences:
<20261204162723.755897-1-bjorn@kernel.org>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!2.eu.feeder.erje.net!feeder.erje.net!feeder1-2.proxad.net!proxad.net!feeder1-1.proxad.net!193.141.40.65.MISMATCH!npeer.as286.net!npeer-ng0.as286.net!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-377493-linux-kernel-netdev=dewy.ru From: bjorn@kernel.org (Björn Töpel) Newsgroups: linux.kernel.netdev Subject: [PATCH net-next v2 11/15] net/mlx5e: Receive into XDP-only memory providers Date: Fri, 4 Dec 2026 17:27:16 +0100 Organization: Usenet Network Message-ID: <20261204162723.755897-12-bjorn@kernel.org> References: <20261204162723.755897-1-bjorn@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="2806533"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:oSuLHtar6UMNy76uTyuMdwiI20Y= sha256:2TWpTIOiH1WRmCJAPvpX+7gI/xO1n4c9v1jDRyqQ3dY= sha1:xYDlUcfVDMZjsXL5S6oQ06yIX+c= sha256:6MlzOZni+31YHmz0Eh6pIfDzW4KBG/V6JecDr5hHbIU= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id 05B59117C67; Fri, 4 Dec 2026 19:29:34 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.642 X-Spam-Status: No, score=-3.642 tagged_above=-9999 required=6.31 tests=[DKIMWL_WL_HIGH=-0.142, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id zxKLTDyH8thv; Fri, 4 Dec 2026 19:29:31 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-377493-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) by mail.dewy.ru (Postfix) with ESMTPS id 02A0D117C66; Fri, 4 Dec 2026 19:29:22 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by tor.lore.kernel.org (Postfix) with ESMTP id E0E662AB1A; Fri, 4 Dec 2026 16:29:20 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796401759; b=QxpcmOQXRaNrOC9k6fWNWFXHlzgVwY8+6i9ssDGs3FEAsCUu2a9CLV5q4N84xSqrjAIB OvU9ss5elYJQl+TJbmyJGIjTCdqShvXYb39hNlZb4lOc+ABH13pk/WuYKoOUZy3AdkrtN rwcxfGH83iL2zgouylPZS3NCrxN70XNqoTnXqj2EcfjC+5pfqCYxl01Le2JlxdRgMBGEx +TliKQJlW6Qh6KwZ0JZkWFh6HQO2i+/co6oSG5avd8qXTnQ9OEKW10BMgE3hXgRtETTXw Ie40C8KCocytG7HABmqOErmHq9Y5dZC8/b4vNDfjfYz2pZqy51kv05Fra7uL56S1hbw== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796401759; h=X-Original-To:Received:Received:DKIM-Signature:From:To:Cc:Subject: Date:Message-ID:X-Mailer:In-Reply-To:References:X-Mailing-List: List-Id:List-Post:List-Help:List-Subscribe:List-Unsubscribe: List-Owner:Precedence:MIME-Version:Content-Type: Content-Transfer-Encoding; bh=N7ZlgbNc9W13tlpx+3GZW1X3juSAKEZ0DU3GNPvm/g0=; b=DkXmHs1huvmpyh+z1zoijuEbfeWl0BT+6AJU5+R7DXcscuXXGNwuMFR4JSE6BnZTREJX EWUB/nTD9RpVR//3RhI5xp8FZXlStdj7LoaaelReCDHqCGqqzxTuFDNZ39bPFLMpBq+kb WQbplziHBnJiy9nKyX5YLmDVWAzkfrmVBcg0+lJH1BMJvVtKDZuE2xfZkxIgy2n8MewE/ wygjf1Fmb2u9nAyQErSOZDM7I2Q7KC8WdtiiviKNEXswJMNDGU0PutbSMaPiHajilTPvA br3f1f4m/4BA4ax2YAg7ZtzLZVP8GD/fzdO0G1gdseJ2+vISSx3OuHZjoZ6KurJX9zw== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b="RY9/J6ag"; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5091B606A683; Fri, 4 Dec 2026 16:29:19 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=RY9/J6ag X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796401758; b=nucffXls7zAFsc5wLJKT/4yLM7gx5U/NSQiV75hRlppQZbFMj90r4rAgyzAzDk1qiTBo NKonCb73FqTrXPtNWnUHKPMVOIPyiQZq34njkt389ks5vOmesFdnWW+U8Fw7hR2LRL56w fgiJ9EsXXZEKZNm4AsoHPuD5X5/a1zo8gcTeDQMU0cD7/sNdvUpciImNinD1nxRR5xGzK Kq5QCSzXEba8p8yopt6fBS+z3KzqWNTMHjlUKou3owcVwrlBUtUHbgjHmvrU2Ucc+lESh XbmlZCx0pyQzqp8LNWGOPSxCZgh5SwAQz6yWFOdudnuovut9RCgv8JRI6CeKGUPXh1w== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796401758; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Type: Content-Transfer-Encoding; bh=N7ZlgbNc9W13tlpx+3GZW1X3juSAKEZ0DU3GNPvm/g0=; b=jWW0wn6W27CZKRRx0yNyaQvUzoNAtv6gRw4Dh07otUGfAYTYzSZhmn1irTr+pxvbxSNn Ia3LE4JXdMwgCSIPLhElUI6XyLK/AV9WjMgmeHx11hKGBQHmj7r/Z3w9UpvV9jk28pk/C 1qrfqHtRkyFN36GhDCG43m42jWTOgfkqXpNptaRiIxt1zqU2q9dlKHgMP4eBD4uypJc61 9x5goWqZZgu2duzDxx4TPTX4CkvL2q/dHG3HuXorw3xxBRdc/pmF9iwmGPDciVAm0jZgd kCzAehkYYqDlzZwd5OuAPvL349TijHnjA0yYN29eP5tAKLSRjE738IfVwPVsyLvF9iQ== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b="RY9/J6ag"; arc=none smtp.remote-ip=100.103.45.18 X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6E92C606A330; Fri, 4 Dec 2026 16:29:18 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id B19F71F0092C; Fri, 4 Dec 2026 16:29:09 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796401758; bh=N7ZlgbNc9W13tlpx+3GZW1X3juSAKEZ0DU3GNPvm/g0=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=RY9/J6agiZWY839x9n9+A3RiO6G4JMBRkRAcY27J9MbYpDnqG3jD0qWfdar2WHSpe veLnQdWvu4SgUdrEfislDUSlqeuf2YKD3tG1IPB1cGdRCtRzuxkMWwPcUA0Jojssn3 ZjQWwi8qnuSBrt6PZVhA5yXuzIusb62gwAFUp50+vkNOiHawZ3zsu6VPikkW6zA16p qfLADGZrZa31RZ9Y7oBItmzLqdt6fKrAnXHjv0C2Ja2iaBaksmVpYZxZX2/ECwaiyl oevPg/pC2Cj0Pu1Tey6k6ByAXL2RB9O2x9jHWGKnduXHsLn7Jzowfr8Df75/q0JKn4 IzWi0N33cwZxA== X-Cc: Björn Töpel <bjorn@kernel.org>, Simon Horman <horms@kernel.org>, Stanislav Fomichev <sdf@fomichev.me>, Martin KaFai Lau <martin.lau@linux.dev>, Song Liu <song@kernel.org>, Yonghong Song <yonghong.song@linux.dev>, Jiri Olsa <jolsa@kernel.org>, Emil Tsalapatis <emil@etsalapatis.com>, Ihor Solodrai <ihor.solodrai@linux.dev>, David Wei <dw@davidwei.uk>, Tao Cui <cuitao@kylinos.cn>, linux-kernel@vger.kernel.org, kernel-team@meta.com, "Mike Marciniszyn (Meta)" <mike.marciniszyn@gmail.com>, linux-rdma@vger.kernel.org, linux-kselftest@vger.kernel.org, Shuah Khan <skhan@linuxfoundation.org>, Randy Dunlap <rdunlap@infradead.org>, linux-doc@vger.kernel.org X-Mailer: git-send-email 2.56.1 X-In-Reply-To: <20261204162723.755897-1-bjorn@kernel.org> X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list