net/mlx5: Lag, only cache max_tx_speed that FW has not accepted
Subsystems (4)
Tariq Toukan
maintainerPATCH 1/1 net/mlx5: Lag, only cache max_tx_speed that FW has not accepted
From: Or Har-Toov <[email protected]>
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.
--- 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(-)
drivers/net/ethernet/mellanox/mlx5/core/eswitch.c +2 -0
@@ -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,
drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c +8 -4
@@ -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
Signature · 1 line
2.44.0
[email protected]
AI reviewThis is an automated message. This series looks like a fix, but its commit messages seem to be missing some information:
Hi!
This is an automated message. This series looks like a fix, but its commit messages seem to be missing some information:
- Whether the issue was actually triggered, or is only theoretical (e.g. found by code inspection). If it was triggered please include the symptoms, like the stack trace or error messages.
- What hardware the change was tested on. For driver fixes please mention the device (and if relevant firmware version) used for testing, or say that the change was not tested on real hardware.
Please do not repost the series just to address the above. Instead, reply to this email with the missing information, so that reviewers can take it into account. If the series needs another revision for other reasons, please include the information in the commit messages then.
The evaluation is done by an LLM so it may be wrong, if you think that is the case please reply and explain.
[email protected]
AI reviewThank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [High] net/mlx5: rate limit dropped due to zeroed max TX speed fallback cache --
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] net/mlx5: rate limit dropped due to zeroed max TX speed fallback cache --
commit e0ff80bc97aeb275a4ecdbc780d58984bb55ac36
Author: Or Har-Toov <[email protected]>
net/mlx5: Lag, only cache max_tx_speed that FW has not accepted
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.
drivers/net/ethernet/mellanox/mlx5/core/eswitch.c static void mlx5_esw_vport_set_max_tx_speed(struct mlx5_eswitch *esw, · line 956
Quoted 11 lines
drivers/net/ethernet/mellanox/mlx5/core/eswitch.c +2
-0@@ -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; }
[Severity: High]
This patch sets agg_max_tx_speed to 0 on a successful push, but multiple fallback paths in the driver rely on this variable containing the actual configured speed if a query fails.
For example, in mlx5_modify_vport_admin_state() in drivers/net/ethernet/mellanox/mlx5/core/vport.c, if the query for the max TX speed fails, the code falls back to the cache:
err = mlx5_query_vport_max_tx_speed(mdev, opmod, vport,
other_vport, &speed, NULL);
if (err) {
#ifdef CONFIG_MLX5_ESWITCH
struct mlx5_vport *esw_vport;
esw_vport = mlx5_eswitch_get_vport(mdev->priv.eswitch,
vport);
speed = IS_ERR(esw_vport) ? 0 :
esw_vport->agg_max_tx_speed;
...
MLX5_SET(modify_vport_state_in, in, max_tx_speed, speed);If a max TX speed was successfully configured, this patch clears agg_max_tx_speed to 0. If a later admin state modification triggers mlx5_modify_vport_admin_state() and the query fails, won't this fallback logic read 0 and inadvertently un-limit the vport by pushing 0 to the firmware?
A similar fallback path that relies on this cache exists in mlx5_esw_adj_vport_modify() in drivers/net/ethernet/mellanox/mlx5/core/esw/adj_vport.c.
Quoted 18 lines
drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c +3
-3@@ -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);
drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c static void mlx5_lag_modify_device_vports_speed(struct mlx5_core_dev *mdev, · line 1520
Quoted 10 lines
drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c +5
-1-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 ; + } }
[Severity: High]
Since this successfully clears the cache to 0, wouldn't it break the fallback mechanisms mentioned above?
Additionally, this logic appears to overload 0 to mean "no cached value". As seen in mlx5_esw_vport_enable() in drivers/net/ethernet/mellanox/mlx5/core/eswitch.c:
if (vport->agg_max_tx_speed)
mlx5_esw_vport_set_max_tx_speed(esw, vport);If a user explicitly configures a speed of 0 (unlimited) while the vport is disabled, wouldn't the cache value be 0, preventing the unlimited setting from being applied when the vport is later enabled?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Quoted 51 lines · On 05/10/2026 10:03, [email protected] wrote:
External email: Use caution opening links or attachments
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] net/mlx5: rate limit dropped due to zeroed max TX speed fallback cache --commit
e0ff80bc97aeb275a4ecdbc780d58984bb55ac36
Author: Or Har-Toov <[email protected]>net/mlx5: Lag, only cache
max_tx_speedthat FW has not accepted
vport->agg_max_tx_speedcaches amax_tx_speedthat could not be pushed to FW, to be applied bymlx5_esw_vport_enable()once the vport comes up.drivers/net/ethernet/mellanox/mlx5/core/eswitch.c static void mlx5_esw_vport_set_max_tx_speed(struct mlx5_eswitch *esw, · line 956
Quoted 11 lines
drivers/net/ethernet/mellanox/mlx5/core/eswitch.c +2
-0@@ -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; }[Severity: High]
This patch setsagg_max_tx_speedto 0 on a successful push, but multiple fallback paths in the driver rely on this variable containing the actual configured speed if a query fails.For example, in
mlx5_modify_vport_admin_state()indrivers/net/ethernet/mellanox/mlx5/core/vport.c, if the query for the max TX speed fails, the code falls back to the cache:err = mlx5_query_vport_max_tx_speed(mdev, opmod, vport, other_vport, &speed, NULL); if (err) { #ifdef CONFIG_MLX5_ESWITCH struct mlx5_vport *esw_vport; esw_vport = mlx5_eswitch_get_vport(mdev->priv.eswitch, vport); speed = IS_ERR(esw_vport) ? 0 : esw_vport->agg_max_tx_speed; ... MLX5_SET(modify_vport_state_in, in, max_tx_speed, speed);
Quoted 9 lines
If a max TX speed was successfully configured, this patch clears
agg_max_tx_speedto 0. If a later admin state modification triggersmlx5_modify_vport_admin_state()and the query fails, won't this fallback logic read 0 and inadvertently un-limit the vport by pushing 0 to the firmware?A similar fallback path that relies on this cache exists in
mlx5_esw_adj_vport_modify()indrivers/net/ethernet/mellanox/mlx5/core/esw/adj_vport.c.
This code was removed in Revert "net/mlx5: E-Switch, preserve max tx speed on vport state modification" -
https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net.git/commit/?id=86b785b18f8f4a6b4a7392d1e2b29d6bb095011a
Quoted 37 lines
Quoted 18 lines
drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c +3
-3@@ -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);drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c static void mlx5_lag_modify_device_vports_speed(struct mlx5_core_dev *mdev, · line 1520
Quoted 10 lines
drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c +5
-1-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 ; + } }[Severity: High]
Since this successfully clears the cache to 0, wouldn't it break the fallback mechanisms mentioned above?Additionally, this logic appears to overload 0 to mean "no cached value". As seen in
mlx5_esw_vport_enable()indrivers/net/ethernet/mellanox/mlx5/core/eswitch.c:
Quoted 7 lines
if (vport->agg_max_tx_speed) mlx5_esw_vport_set_max_tx_speed(esw, vport);If a user explicitly configures a speed of 0 (unlimited) while the vport is disabled, wouldn't the cache value be 0, preventing the unlimited setting from being applied when the vport is later enabled?
Speed 0 means unsupported and not unlimited by PRM. User can't configure max_tx_speed to be 0.
Quoted 2 lines
--
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
[email protected]
AI reviewThank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider.
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider.
Critical: 0 · High: 0 · Medium: 2 · Low: 0
If you believe none of the issues are legitimate, please reply to each issue of Medium severity or higher and explain why the AI is wrong. If any of them are legitimate and you plan to respin, please let patchwork know by including "pw-bot: cr" as a separate line at the end of your reply (one such reply per series is enough).
- [Medium] This patch breaks the query-failure fallback added by commit ad0ae7aefa7a ("net/mlx5: E-Switch, preserve max tx speed on vport…
- [Medium] The commit message does not match the code change.
--
net/mlx5: Lag, only cache max_tx_speed that FW has not accepted
This patch changes mlx5_lag_modify_device_vports_speed() so that vport->agg_max_tx_speed is written only when the vport is disabled or the FW push fails. When the push succeeds, the cache is cleared to 0. The enable-time replay in mlx5_esw_vport_set_max_tx_speed() also clears the cache on success.
Quoted 6 lines
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.
[Severity: Medium]
Does the change actually address the scenario described here?
After this patch, the failure branch in mlx5_lag_modify_device_vports_speed() still caches the speed:
if (ret) {
mlx5_core_dbg(mdev, ...);
vport->agg_max_tx_speed = speed;and mlx5_esw_vport_enable() still replays any nonzero value:
if (vport->agg_max_tx_speed) mlx5_esw_vport_set_max_tx_speed(esw, vport);
So a failed push followed by a disable and re-enable, with no LAG update in between, behaves the same before and after the patch. The third paragraph of the message keeps this on purpose.
Quoted 2 lines
Clear it once FW has accepted the value, so a superseded speed is not replayed over a newer one.
Which path could program a newer speed that a stale cache would then overwrite? Only two places write agg_max_tx_speed, and they are also the only callers of mlx5_modify_vport_max_tx_speed(). One is the LAG loop, which always overwrites the cache with the latest LAG speed. The other is the enable-time replay.
The only real change in behavior seems to be clearing the cache on success. The message doesn't mention two side effects of that:
- The query-failure fallback added by ad0ae7aefa7a ("net/mlx5: E-Switch, preserve max tx speed on vport state modification") stops working (see below).
- Vports that were programmed successfully no longer get a replay on re-enable.
Because of the Fixes: c6df9a65cbb0 tag, this change would go to stable trees even though the bug described above can still happen. Could the commit message and the Fixes tag be revisited?
Quoted 30 lines
drivers/net/ethernet/mellanox/mlx5/core/eswitch.c +2
-0@@ -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,drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c +3
-3@@ -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,
drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c static void mlx5_lag_modify_device_vports_speed(struct mlx5_core_dev *mdev, · line 1519
Quoted 10 lines
drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c +5
-1vport->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 ; + }
[Severity: Medium]
Can clearing the cache here break the query-failure fallback in mlx5_modify_vport_admin_state()?
That function, and mlx5_esw_adj_vport_modify() in esw/adj_vport.c, use agg_max_tx_speed as the last known speed when QUERY_VPORT_STATE fails:
drivers/net/ethernet/mellanox/mlx5/core/vport.c:mlx5_modify_vport_admin_state() {
...
err = mlx5_query_vport_max_tx_speed(mdev, opmod, vport,
other_vport, &speed, NULL);
if (err) {
...
speed = IS_ERR(esw_vport) ? 0 :
esw_vport->agg_max_tx_speed;
...
}
MLX5_SET(modify_vport_state_in, in, max_tx_speed, speed);
...
}With this patch, agg_max_tx_speed becomes 0 on every vport whose LAG speed was pushed successfully, either here or in the replay in mlx5_esw_vport_set_max_tx_speed().
Suppose a later admin state change on that vport hits a query failure. Wouldn't the fallback then send max_tx_speed = 0, which ad0ae7aefa7a describes as an intentional reset in FW? That would wipe the LAG aggregate speed that was just programmed:
mlx5_lag_modify_device_vports_speed()
mlx5_modify_vport_max_tx_speed() /* succeeds */
vport->agg_max_tx_speed = 0
...mlx5_modify_vport_admin_state()
mlx5_query_vport_max_tx_speed() /* fails */
speed = esw_vport->agg_max_tx_speed /* 0 */
MLX5_SET(modify_vport_state_in, in, max_tx_speed, speed)
These are the admin state changes that can reach this path:
- mlx5e_rep_open(), mlx5e_rep_close() and mlx5e_rep_change_carrier()
- mlx5_eswitch_set_vport_state()
- esw_vport_setup() and esw_vport_cleanup()
Adjacent vport connect and disconnect through mlx5_esw_adj_vport_modify() are affected the same way. After that, nothing pushes the speed again until the next LAG speed event.
Before this patch, the cache still held the programmed speed after a successful push, so the fallback rewrote the correct value.
The patch now treats agg_max_tx_speed as a pending value, but both fallback readers still treat it as the last programmed speed. Can one field serve both meanings?
Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261004070246.215239-1-tariqt%40nvidia.com
Jakub Kicinski
maintainerQuoted 3 lines · On Mon, 05 Oct 2026 07:42:28 +0000 [email protected] wrote:
- [Medium] This patch breaks the query-failure fallback added by commit
ad0ae7aefa7a("net/mlx5: E-Switch, preserve max tx speed on vport…
- [Medium] The commit message does not match the code change.
Can y'all comment please? It's been 3 days
Tariq Toukan
maintainerQuoted 6 lines · Jakub Kicinski
Quoted 3 lines · On Mon, 05 Oct 2026 07:42:28 +0000 [email protected] wrote:
- [Medium] This patch breaks the query-failure fallback added by commit
ad0ae7aefa7a("net/mlx5: E-Switch, preserve max tx speed on vport…
- [Medium] The commit message does not match the code change.Can y'all comment please? It's been 3 days
Hi Jakub,
We received 3 different emails from Sashiko bots for this single patch.
Or replied to a similar issue in another Sashiko mail, but now I see it wasn't the netdev one.
Anyway, sorry for the delay.
The fallback readers in mlx5_modify_vport_admin_state() and mlx5_esw_adj_vport_modify() were removed by 86b785b18f8f ("Revert \"net/mlx5: E-Switch, preserve max tx speed on vport state modification\""), which is now in net, so clearing the cache no longer affects them.
The second point is fair. The issue is theoretical (found by the AI review of an earlier series, not observed), and the commit message does not describe the actual change, which is to stop replaying values FW already accepted.
pw-bot: cr
Jakub Kicinski
maintainerQuoted 5 lines · On Thu, 8 Oct 2026 20:41:16 +0300 Tariq Toukan wrote:
We received 3 different emails from Sashiko bots for this single patch. Or replied to a similar issue in another Sashiko mail, but now I see it wasn't the netdev one.
Anyway, sorry for the delay.
Ugh, this is so annoying. The main sashiko instance insists on trimming the CC list, so we didn't see the Sashiko.dev email or Or's reply :( The trimming is really hugely silly, netdev patches are very often cross-posted to other MLs.
Roman, our instance has been using the full CC list form months now and I haven't received a single complaint (well, I have, but about the format of the reply and its metadata, not the CC list). Please reconsider?