[PATCH net] net/mlx5: E-switch, Restore host PF enable for ECPF that isn't E-switch manager

From: Tariq Toukan

Date: Wed Nov 04 2026 - 15:49:59 EST


From: Shay Drory <shayd@xxxxxxxxxx>

The cited commit breaks host PF enable_hca when the ECPF isn't E-switch
manager. For example, when the link layer is infiniband, the ECPF isn't
E-switch manager, so after the cited commit enable_hca is never issued
for the host PF, it stays in initializing state and fails to probe.

Fix it by checking esw_allowed() only for vport bookkeeping

Fixes: 0e6c95c98829 ("net/mlx5: Support devlink port state for host PF")
Signed-off-by: Shay Drory <shayd@xxxxxxxxxx>
Reviewed-by: Moshe Shemesh <moshe@xxxxxxxxxx>
Reviewed-by: Mark Bloch <mbloch@xxxxxxxxxx>
Signed-off-by: Tariq Toukan <tariqt@xxxxxxxxxx>
---
.../net/ethernet/mellanox/mlx5/core/eswitch.c | 24 +++++++++----------
1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
index 2d289fb1353b..dd7e33a20ab0 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
@@ -1514,13 +1514,9 @@ int mlx5_esw_pf_enable_hca(struct mlx5_core_dev *dev, u16 vport_num)
struct mlx5_vport *vport;
int err;

- if (!mlx5_core_is_ecpf(dev) || !mlx5_esw_allowed(esw))
+ if (!mlx5_core_is_ecpf(dev))
return 0;

- vport = mlx5_eswitch_get_vport(esw, vport_num);
- if (IS_ERR(vport))
- return PTR_ERR(vport);
-
/* Once vport and representor are ready, take the PF out of
* initializing state. Enabling HCA clears the iser->initializing
* bit and PF driver loading can progress.
@@ -1529,7 +1525,11 @@ int mlx5_esw_pf_enable_hca(struct mlx5_core_dev *dev, u16 vport_num)
if (err)
return err;

- vport->pf_activated = true;
+ if (mlx5_esw_allowed(esw)) {
+ vport = mlx5_eswitch_get_vport(esw, vport_num);
+ if (!IS_ERR(vport))
+ vport->pf_activated = true;
+ }

return 0;
}
@@ -1540,18 +1540,18 @@ int mlx5_esw_pf_disable_hca(struct mlx5_core_dev *dev, u16 vport_num)
struct mlx5_vport *vport;
int err;

- if (!mlx5_core_is_ecpf(dev) || !mlx5_esw_allowed(esw))
+ if (!mlx5_core_is_ecpf(dev))
return 0;

- vport = mlx5_eswitch_get_vport(esw, vport_num);
- if (IS_ERR(vport))
- return PTR_ERR(vport);
-
err = mlx5_cmd_pf_disable_hca(dev, vport_num);
if (err)
return err;

- vport->pf_activated = false;
+ if (mlx5_esw_allowed(esw)) {
+ vport = mlx5_eswitch_get_vport(esw, vport_num);
+ if (!IS_ERR(vport))
+ vport->pf_activated = false;
+ }

return 0;
}

base-commit: 647b81ddefc6364290e67bf33c89d54971f8995e
--
2.44.0