[PATCH net 0/3] net/mlx5: Preserve speed and state across vport modify commands

Tariq Toukan posted 3 patches 1 month, 1 week ago
drivers/infiniband/hw/mlx5/main.c             |  5 ++-
.../net/ethernet/mellanox/mlx5/core/en_rep.c  | 20 ++++++---
.../mellanox/mlx5/core/esw/adj_vport.c        | 22 ++++++++++
.../mellanox/mlx5/core/eswitch_offloads.c     |  4 ++
.../net/ethernet/mellanox/mlx5/core/lag/lag.c |  2 +
.../net/ethernet/mellanox/mlx5/core/vport.c   | 44 +++++++++++++++----
include/linux/mlx5/vport.h                    |  3 +-
7 files changed, 84 insertions(+), 16 deletions(-)
[PATCH net 0/3] net/mlx5: Preserve speed and state across vport modify commands
Posted by Tariq Toukan 1 month, 1 week ago
Hi,

The firmware vport modify command bundles both admin state and max tx
speed in a single operation, which requires each side to preserve the
other field when it only intends to change one.

When modifying max tx speed, the driver already queries the current
admin state and passes it back to avoid overwriting it. However, this
query and the subsequent modify were not atomic, a state change
between the two could cause the modify to overwrite the new state with
a stale value. The fix holds esw->state_lock across the query-modify
sequence.

When support for setting max tx speed via the vport modify command was
introduced, the existing admin state modify path was not updated to
preserve the current speed. As a result, the firmware interprets the
zero speed field as an intentional reset. The fix adds a speed query
before the state modify and passes the result back in the command.

To support that, mlx5_query_vport_max_tx_speed() had to be fixed first:
it was returning zero whenever the vport was DOWN, which was correct
for the query_port_speed verb but would defeat the purpose of querying
before a state modify. The DOWN-to-zero logic is moved to the
verb-layer caller so the function returns the raw firmware value.

Patch #1  holds esw->state_lock across the state query and modify in
          the speed modify path
Patch #2  moves the vport DOWN zero mapping to the verb-layer caller
          so the query returns the raw firmware value
Patch #3  queries current max tx speed before modifying vport state to
          preserve it

Regards,
Tariq

Mark Bloch (1):
  net/mlx5: E-Switch, use state lock for vport state changes

Or Har-Toov (2):
  net/mlx5: Move vport DOWN state check out of
    mlx5_query_vport_max_tx_speed()
  net/mlx5: E-Switch, preserve max tx speed on vport state modification

 drivers/infiniband/hw/mlx5/main.c             |  5 ++-
 .../net/ethernet/mellanox/mlx5/core/en_rep.c  | 20 ++++++---
 .../mellanox/mlx5/core/esw/adj_vport.c        | 22 ++++++++++
 .../mellanox/mlx5/core/eswitch_offloads.c     |  4 ++
 .../net/ethernet/mellanox/mlx5/core/lag/lag.c |  2 +
 .../net/ethernet/mellanox/mlx5/core/vport.c   | 44 +++++++++++++++----
 include/linux/mlx5/vport.h                    |  3 +-
 7 files changed, 84 insertions(+), 16 deletions(-)


base-commit: 24ef02f934eeb48830cff6b739abc3c62b1d107b
-- 
2.44.0
Re: [PATCH net 0/3] net/mlx5: Preserve speed and state across vport modify commands
Posted by Simon Horman 1 month, 1 week ago
On Sun, Aug 16, 2026 at 09:50:12AM +0300, Tariq Toukan wrote:
> Hi,
> 
> The firmware vport modify command bundles both admin state and max tx
> speed in a single operation, which requires each side to preserve the
> other field when it only intends to change one.
> 
> When modifying max tx speed, the driver already queries the current
> admin state and passes it back to avoid overwriting it. However, this
> query and the subsequent modify were not atomic, a state change
> between the two could cause the modify to overwrite the new state with
> a stale value. The fix holds esw->state_lock across the query-modify
> sequence.
> 
> When support for setting max tx speed via the vport modify command was
> introduced, the existing admin state modify path was not updated to
> preserve the current speed. As a result, the firmware interprets the
> zero speed field as an intentional reset. The fix adds a speed query
> before the state modify and passes the result back in the command.
> 
> To support that, mlx5_query_vport_max_tx_speed() had to be fixed first:
> it was returning zero whenever the vport was DOWN, which was correct
> for the query_port_speed verb but would defeat the purpose of querying
> before a state modify. The DOWN-to-zero logic is moved to the
> verb-layer caller so the function returns the raw firmware value.
> 
> Patch #1  holds esw->state_lock across the state query and modify in
>           the speed modify path
> Patch #2  moves the vport DOWN zero mapping to the verb-layer caller
>           so the query returns the raw firmware value
> Patch #3  queries current max tx speed before modifying vport state to
>           preserve it

For the series:

Reviewed-by: Simon Horman <horms@kernel.org>