BPF List
 help / color / mirror / Atom feed
From: "Björn Töpel" <bjorn@kernel.org>
To: "David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@kernel.org>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Willem de Bruijn <willemb@google.com>,
	Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Jesper Dangaard Brouer <hawk@kernel.org>,
	John Fastabend <john.fastabend@gmail.com>,
	Andrii Nakryiko <andrii@kernel.org>,
	Eduard Zingerman <eddyz87@gmail.com>,
	Kumar Kartikeya Dwivedi <memxor@gmail.com>,
	Nikolay Aleksandrov <razor@blackwall.org>,
	Andrew Lunn <andrew+netdev@lunn.ch>,
	Ilias Apalodimas <ilias.apalodimas@linaro.org>,
	Magnus Karlsson <magnus.karlsson@intel.com>,
	Maciej Fijalkowski <maciej.fijalkowski@intel.com>,
	Donald Hunter <donald.hunter@gmail.com>,
	Alexander Duyck <alexanderduyck@fb.com>,
	Saeed Mahameed <saeedm@nvidia.com>,
	Tariq Toukan <tariqt@nvidia.com>, Mark Bloch <mbloch@nvidia.com>,
	Leon Romanovsky <leon@kernel.org>, Shuah Khan <shuah@kernel.org>,
	Jonathan Corbet <corbet@lwn.net>,
	netdev@vger.kernel.org, bpf@vger.kernel.org
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
Subject: [PATCH net-next v2 10/15] net/mlx5e: Handle restarts with XDP-only providers
Date: Fri,  4 Dec 2026 17:27:15 +0100	[thread overview]
Message-ID: <20261204162723.755897-11-bjorn@kernel.org> (raw)
In-Reply-To: <20261204162723.755897-1-bjorn@kernel.org>

An XDP-only provider backs an RQ with UMEM chunks that come back only
through that queue. Currently, mlx5 assumes that an RQ can always get
more pages, which does not hold across a channel restart.

While a queue has such a provider:
- skip its RQ, as the XSK RQ already is, in the wait for posted WQEs
  on activation. FILL may stay empty, so the wait would time out and
  the health reporter could turn off the ICOSQ;
- close the old channels of a switch before the new ones run, as the
  old RQs hold the buffers that the new ones need, and their last puts
  must not overlap the new NAPIs.

A channel switch, as for an MTU change, then stops traffic on every
channel while it runs, as without tis_tir_td_order.

Nothing installs such a provider on mlx5 before the next patch.

Signed-off-by: Björn Töpel <bjorn@kernel.org>
---

Notes (v2changes):
    Changes in v2:
    - Split out of v1 patch 12, which skipped the wait for the minimum of
      posted WQEs.
    - Close the old channels of a switch before the new ones run
      (Sashiko).
    - The message says that every channel stops while a switch runs, and
      that closing the old channels first also keeps the last puts of the
      old buffers off the NAPIs of the new ones.

 .../net/ethernet/mellanox/mlx5/core/en_main.c | 36 ++++++++++++++++---
 1 file changed, 32 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
index 54f4f5a097c8..a76ba297c9a9 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
@@ -3102,6 +3102,14 @@ static int mlx5e_wait_channels_min_rx_wqes(struct mlx5e_channels *chs)
 		if (test_bit(MLX5E_CHANNEL_STATE_XSK, c->state))
 			continue;
 
+		/* An RQ that an XDP-only provider backs fills from the FILL
+		 * ring of its socket, which stays empty until the socket
+		 * gets its chunks back, so a queue that restarts under a
+		 * slow reader would never meet the bound.
+		 */
+		if (netif_rxq_has_xdp_only_mp(c->netdev, c->ix))
+			continue;
+
 		err |= mlx5e_wait_for_min_rx_wqes(&c->rq, timeout);
 
 		/* Don't wait on the XSK RQ, because the newer xdpsock sample
@@ -3528,11 +3536,29 @@ static void mlx5e_close_channels_xsk(struct mlx5e_channels *chs)
 	}
 }
 
+static bool mlx5e_has_xdp_only_mp(struct mlx5e_priv *priv, unsigned int n)
+{
+	unsigned int i;
+
+	for (i = 0; i < n; i++)
+		if (netif_rxq_has_xdp_only_mp(priv->netdev, i))
+			return true;
+	return false;
+}
+
+static bool mlx5e_close_old_first(struct mlx5e_priv *priv,
+				  struct mlx5e_channels *chs)
+{
+	if (mlx5e_has_xdp_only_mp(priv, priv->netdev->real_num_rx_queues))
+		return true;
+	return !MLX5_CAP_GEN(priv->mdev, tis_tir_td_order);
+}
+
 static int mlx5e_switch_priv_channels(struct mlx5e_priv *priv,
 				      struct mlx5e_channels *old_chs,
 				      struct mlx5e_channels *new_chs,
 				      mlx5e_fp_preactivate preactivate,
-				      void *context)
+				      void *context, bool old_first)
 {
 	struct net_device *netdev = priv->netdev;
 	int carrier_ok;
@@ -3557,7 +3583,7 @@ static int mlx5e_switch_priv_channels(struct mlx5e_priv *priv,
 	}
 
 	mlx5e_set_xdp_feature(priv);
-	if (!MLX5_CAP_GEN(priv->mdev, tis_tir_td_order))
+	if (old_first)
 		mlx5e_close_channels(old_chs);
 	else
 		mlx5e_close_channels_xsk(old_chs);
@@ -3580,6 +3606,7 @@ int mlx5e_safe_switch_params(struct mlx5e_priv *priv,
 			     void *context, bool reset)
 {
 	struct mlx5e_channels *old_chs, *new_chs;
+	bool old_first;
 	int err;
 
 	reset &= test_bit(MLX5E_STATE_OPENED, &priv->state);
@@ -3602,13 +3629,14 @@ int mlx5e_safe_switch_params(struct mlx5e_priv *priv,
 		goto err_cancel_selq;
 
 	*old_chs = priv->channels;
+	old_first = mlx5e_close_old_first(priv, old_chs);
 
 	err = mlx5e_switch_priv_channels(priv, old_chs, new_chs,
-					 preactivate, context);
+					 preactivate, context, old_first);
 	if (err)
 		goto err_close;
 
-	if (MLX5_CAP_GEN(priv->mdev, tis_tir_td_order))
+	if (!old_first)
 		mlx5e_close_channels(old_chs);
 
 	kfree(new_chs);
-- 
2.56.1


  parent reply	other threads:[~2026-12-04 16:29 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-04 16:27 [PATCH net-next v2 00/15] xsk: Return UMEM chunks explicitly Björn Töpel
2026-12-04 16:27 ` [PATCH net-next v2 01/15] xdp: Let memory providers expose net_iovs to XDP Björn Töpel
2026-12-04 16:27 ` [PATCH net-next v2 02/15] net: Add memory providers that only feed XDP Björn Töpel
2026-12-04 16:27 ` [PATCH net-next v2 03/15] page_pool: Let memory providers take back net_iovs Björn Töpel
2026-12-04 16:27 ` [PATCH net-next v2 04/15] xdp: Run programs on XDP-only buffers Björn Töpel
2026-12-04 16:27 ` [PATCH net-next v2 05/15] xsk: Back a queue's page pools with UMEM chunks Björn Töpel
2026-12-04 16:27 ` [PATCH net-next v2 06/15] xsk: Deliver packets and return chunks explicitly Björn Töpel
2026-12-04 16:27 ` [PATCH net-next v2 07/15] xsk: Receive with explicit chunk return Björn Töpel
2026-12-04 16:27 ` [PATCH net-next v2 08/15] xsk: Drop references of a run of buffers at once Björn Töpel
2026-12-04 16:27 ` [PATCH net-next v2 09/15] eth: fbnic: Receive into XDP-only memory providers Björn Töpel
2026-12-04 22:34   ` Alexander Duyck
2026-12-04 16:27 ` Björn Töpel [this message]
2026-12-04 16:27 ` [PATCH net-next v2 11/15] net/mlx5e: " Björn Töpel
2026-12-04 16:27 ` [PATCH net-next v2 12/15] net/mlx5e: Release XDP-only pages earlier Björn Töpel
2026-12-04 16:27 ` [PATCH net-next v2 13/15] net/mlx5e: Test for XDP-only pages per RQ Björn Töpel
2026-12-04 16:27 ` [PATCH net-next v2 14/15] selftests: net: xsk: Test explicit chunk return Björn Töpel
2026-12-04 16:27 ` [PATCH net-next v2 15/15] Documentation: xsk: Describe " Björn Töpel

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=20261204162723.755897-11-bjorn@kernel.org \
    --to=bjorn@kernel.org \
    --cc=alexanderduyck@fb.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=corbet@lwn.net \
    --cc=cuitao@kylinos.cn \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=donald.hunter@gmail.com \
    --cc=dw@davidwei.uk \
    --cc=eddyz87@gmail.com \
    --cc=edumazet@kernel.org \
    --cc=emil@etsalapatis.com \
    --cc=hawk@kernel.org \
    --cc=horms@kernel.org \
    --cc=ihor.solodrai@linux.dev \
    --cc=ilias.apalodimas@linaro.org \
    --cc=john.fastabend@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=kernel-team@meta.com \
    --cc=kuba@kernel.org \
    --cc=leon@kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=maciej.fijalkowski@intel.com \
    --cc=magnus.karlsson@intel.com \
    --cc=martin.lau@linux.dev \
    --cc=mbloch@nvidia.com \
    --cc=memxor@gmail.com \
    --cc=mike.marciniszyn@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=razor@blackwall.org \
    --cc=rdunlap@infradead.org \
    --cc=saeedm@nvidia.com \
    --cc=sdf@fomichev.me \
    --cc=shuah@kernel.org \
    --cc=skhan@linuxfoundation.org \
    --cc=song@kernel.org \
    --cc=tariqt@nvidia.com \
    --cc=willemb@google.com \
    --cc=yonghong.song@linux.dev \
    /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