mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH net] net/mlx5: Lag, only cache max_tx_speed that FW has not accepted
@ 2026-10-04  7:02 Tariq Toukan
  2026-10-04  7:08 ` netdev-bot+sinfo
  2026-10-05  7:42 ` netdev-bot+sashiko
  0 siblings, 2 replies; 3+ messages in thread
From: Tariq Toukan @ 2026-10-04  7:02 UTC (permalink / raw)
  To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
	netdev, Paolo Abeni
  Cc: Gal Pressman, Leon Romanovsky, open list, linux-rdma, Mark Bloch,
	Or Har-Toov, Saeed Mahameed, Shay Drory, Tariq Toukan

From: Or Har-Toov <ohartoov@nvidia.com>

vport->agg_max_tx_speed caches a max_tx_speed that could not be pushed
to FW, to be applied by mlx5_esw_vport_enable() once the vport comes up.

mlx5_lag_modify_device_vports_speed() also wrote it for enabled vports,
unconditionally, before even attempting the FW push. If that push
failed, the cache still claimed speed had been applied, even though FW
might still hold the old value. That unconfirmed value could then leak
out: mlx5_esw_vport_enable() replays it if the vport is later disabled
and re-enabled with no LAG update in between.

Write the cache only where FW does not hold the value: when the vport
is disabled and cannot be modified, and when the push itself failed.
Clear it once FW has accepted the value, so a superseded speed is not
replayed over a newer one. A vport whose push succeeded therefore keeps
no cached speed, and relies on FW retaining the programmed value.

This was raised in the AI review of v1 of "net/mlx5: Lag, reset vport
speed on teardown". It is unrelated to that patch, so it is fixed here
separately.

Link: https://lore.kernel.org/all/20260915015118.875210-1-kuba@kernel.org/
Fixes: c6df9a65cbb0 ("net/mlx5: Skip disabled vports when setting max TX speed")
Signed-off-by: Or Har-Toov <ohartoov@nvidia.com>
Reviewed-by: Mark Bloch <mbloch@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
---
 drivers/net/ethernet/mellanox/mlx5/core/eswitch.c |  2 ++
 drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c | 12 ++++++++----
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
index fc197d1dc9df..f8c220bf7b5c 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
@@ -951,6 +951,8 @@ static void mlx5_esw_vport_set_max_tx_speed(struct mlx5_eswitch *esw,
 		mlx5_core_dbg(esw->dev,
 			      "Failed to set vport %d speed %d, err=%d\n",
 			      vport->vport, vport->agg_max_tx_speed, ret);
+	else
+		vport->agg_max_tx_speed = 0;
 }
 
 int mlx5_esw_vport_enable(struct mlx5_eswitch *esw, struct mlx5_vport *vport,
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c b/drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c
index 3b34bec559e0..7cee78cb47df 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c
@@ -1502,17 +1502,21 @@ static void mlx5_lag_modify_device_vports_speed(struct mlx5_core_dev *mdev,
 		if (vport->vport == MLX5_VPORT_UPLINK)
 			continue;
 
-		vport->agg_max_tx_speed = speed;
-
-		if (!vport->enabled)
+		if (!vport->enabled) {
+			vport->agg_max_tx_speed = speed;
 			continue;
+		}
 
 		ret = mlx5_modify_vport_max_tx_speed(mdev, op_mod,
 						     vport->vport, true, speed);
-		if (ret)
+		if (ret) {
 			mlx5_core_dbg(mdev,
 				      "Failed to set vport %d speed %d, err=%d\n",
 				      vport->vport, speed, ret);
+			vport->agg_max_tx_speed = speed;
+		} else {
+			vport->agg_max_tx_speed = 0;
+		}
 	}
 	mutex_unlock(&esw->state_lock);
 }

base-commit: 6dc989ea46b96ce170840174b4a38c4a387fb005
-- 
2.44.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-10-05  7:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-04  7:02 [PATCH net] net/mlx5: Lag, only cache max_tx_speed that FW has not accepted Tariq Toukan
2026-10-04  7:08 ` netdev-bot+sinfo
2026-10-05  7:42 ` netdev-bot+sashiko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®