Skip to content

Commit 733d3e5

Browse files
ogerlitzSaeed Mahameed
authored andcommitted
net/mlx5e: Avoid dealing with vport representors if not being e-switch manager
In smartnic env, the host (PF) driver might not be an e-switch manager, hence the switchdev mode representors are running on the embedded cpu (EC) and not at the host. As such, we should avoid dealing with vport representors if not being esw manager. While here, make sure to disallow eswitch switchdev related setups through devlink if we are not esw managers. Fixes: cb67b83 ('net/mlx5e: Introduce SRIOV VF representors') Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com> Reviewed-by: Eli Cohen <eli@mellanox.com> Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
1 parent 0efc856 commit 733d3e5

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

drivers/net/ethernet/mellanox/mlx5/core/en_main.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2846,7 +2846,7 @@ void mlx5e_activate_priv_channels(struct mlx5e_priv *priv)
28462846
mlx5e_activate_channels(&priv->channels);
28472847
netif_tx_start_all_queues(priv->netdev);
28482848

2849-
if (MLX5_VPORT_MANAGER(priv->mdev))
2849+
if (MLX5_ESWITCH_MANAGER(priv->mdev))
28502850
mlx5e_add_sqs_fwd_rules(priv);
28512851

28522852
mlx5e_wait_channels_min_rx_wqes(&priv->channels);
@@ -2857,7 +2857,7 @@ void mlx5e_deactivate_priv_channels(struct mlx5e_priv *priv)
28572857
{
28582858
mlx5e_redirect_rqts_to_drop(priv);
28592859

2860-
if (MLX5_VPORT_MANAGER(priv->mdev))
2860+
if (MLX5_ESWITCH_MANAGER(priv->mdev))
28612861
mlx5e_remove_sqs_fwd_rules(priv);
28622862

28632863
/* FIXME: This is a W/A only for tx timeout watch dog false alarm when
@@ -4597,7 +4597,7 @@ static void mlx5e_build_nic_netdev(struct net_device *netdev)
45974597
mlx5e_set_netdev_dev_addr(netdev);
45984598

45994599
#if IS_ENABLED(CONFIG_MLX5_ESWITCH)
4600-
if (MLX5_VPORT_MANAGER(mdev))
4600+
if (MLX5_ESWITCH_MANAGER(mdev))
46014601
netdev->switchdev_ops = &mlx5e_switchdev_ops;
46024602
#endif
46034603

@@ -4753,7 +4753,7 @@ static void mlx5e_nic_enable(struct mlx5e_priv *priv)
47534753

47544754
mlx5e_enable_async_events(priv);
47554755

4756-
if (MLX5_VPORT_MANAGER(priv->mdev))
4756+
if (MLX5_ESWITCH_MANAGER(priv->mdev))
47574757
mlx5e_register_vport_reps(priv);
47584758

47594759
if (netdev->reg_state != NETREG_REGISTERED)
@@ -4788,7 +4788,7 @@ static void mlx5e_nic_disable(struct mlx5e_priv *priv)
47884788

47894789
queue_work(priv->wq, &priv->set_rx_mode_work);
47904790

4791-
if (MLX5_VPORT_MANAGER(priv->mdev))
4791+
if (MLX5_ESWITCH_MANAGER(priv->mdev))
47924792
mlx5e_unregister_vport_reps(priv);
47934793

47944794
mlx5e_disable_async_events(priv);
@@ -4972,7 +4972,7 @@ static void *mlx5e_add(struct mlx5_core_dev *mdev)
49724972
return NULL;
49734973

49744974
#ifdef CONFIG_MLX5_ESWITCH
4975-
if (MLX5_VPORT_MANAGER(mdev)) {
4975+
if (MLX5_ESWITCH_MANAGER(mdev)) {
49764976
rpriv = mlx5e_alloc_nic_rep_priv(mdev);
49774977
if (!rpriv) {
49784978
mlx5_core_warn(mdev, "Failed to alloc NIC rep priv data\n");

drivers/net/ethernet/mellanox/mlx5/core/en_rep.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -823,7 +823,7 @@ bool mlx5e_is_uplink_rep(struct mlx5e_priv *priv)
823823
struct mlx5e_rep_priv *rpriv = priv->ppriv;
824824
struct mlx5_eswitch_rep *rep;
825825

826-
if (!MLX5_CAP_GEN(priv->mdev, vport_group_manager))
826+
if (!MLX5_ESWITCH_MANAGER(priv->mdev))
827827
return false;
828828

829829
rep = rpriv->rep;

drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1079,8 +1079,8 @@ static int mlx5_devlink_eswitch_check(struct devlink *devlink)
10791079
if (MLX5_CAP_GEN(dev, port_type) != MLX5_CAP_PORT_TYPE_ETH)
10801080
return -EOPNOTSUPP;
10811081

1082-
if (!MLX5_CAP_GEN(dev, vport_group_manager))
1083-
return -EOPNOTSUPP;
1082+
if(!MLX5_ESWITCH_MANAGER(dev))
1083+
return -EPERM;
10841084

10851085
if (dev->priv.eswitch->mode == SRIOV_NONE)
10861086
return -EOPNOTSUPP;

0 commit comments

Comments
 (0)