[PATCH net-next v2 10/15] net/mlx5e: Handle restarts with XDP-only providers

From: Björn Töpel

Date: Fri Dec 04 2026 - 11:29:12 EST


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@xxxxxxxxxx>
---

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