mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH net] net/mlx5: E-switch, Restore host PF enable for ECPF that isn't E-switch manager
@ 2026-11-04 18:47 Tariq Toukan
  0 siblings, 0 replies; only message in thread
From: Tariq Toukan @ 2026-11-04 18:47 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,
	Moshe Shemesh, Parav Pandit, Saeed Mahameed, Shay Drory,
	Tariq Toukan

From: Shay Drory <shayd@nvidia.com>

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@nvidia.com>
Reviewed-by: Moshe Shemesh <moshe@nvidia.com>
Reviewed-by: Mark Bloch <mbloch@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
---
 .../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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-11-04 18:49 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-04 18:47 [PATCH net] net/mlx5: E-switch, Restore host PF enable for ECPF that isn't E-switch manager Tariq Toukan

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®