Skip to content

Commit c5447c7

Browse files
mark-blochSaeed Mahameed
authored andcommitted
net/mlx5: E-Switch, Reload IB interface when switching devlink modes
Up until this point it wasn't possible to activate IB representors when switching to switchdev mode, remove this limitation. We trigger reload of the PF IB interface in order to make sure that already allocated resources are invalid and new resources will be opened correctly with all the limitations of switchdev mode applied (only raw packet capabilities, without RoCE). We also move the remove/add to a place where the E-Switch mode is set/unset to better control when to trigger this action, this will allow the IB side to start in the correct mode. For better code reuse, create a function which reloads an interface and export it. Signed-off-by: Mark Bloch <[email protected]> Reviewed-by: Or Gerlitz <[email protected]> Signed-off-by: Leon Romanovsky <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]>
1 parent b5ca15a commit c5447c7

File tree

4 files changed

+26
-17
lines changed

4 files changed

+26
-17
lines changed

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,14 @@ void mlx5_unregister_interface(struct mlx5_interface *intf)
337337
}
338338
EXPORT_SYMBOL(mlx5_unregister_interface);
339339

340+
void mlx5_reload_interface(struct mlx5_core_dev *mdev, int protocol)
341+
{
342+
mutex_lock(&mlx5_intf_mutex);
343+
mlx5_remove_dev_by_protocol(mdev, protocol);
344+
mlx5_add_dev_by_protocol(mdev, protocol);
345+
mutex_unlock(&mlx5_intf_mutex);
346+
}
347+
340348
void *mlx5_get_protocol_dev(struct mlx5_core_dev *mdev, int protocol)
341349
{
342350
struct mlx5_priv *priv = &mdev->priv;

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

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1619,10 +1619,14 @@ int mlx5_eswitch_enable_sriov(struct mlx5_eswitch *esw, int nvfs, int mode)
16191619
esw_info(esw->dev, "E-Switch enable SRIOV: nvfs(%d) mode (%d)\n", nvfs, mode);
16201620
esw->mode = mode;
16211621

1622-
if (mode == SRIOV_LEGACY)
1622+
if (mode == SRIOV_LEGACY) {
16231623
err = esw_create_legacy_fdb_table(esw, nvfs + 1);
1624-
else
1624+
} else {
1625+
mlx5_reload_interface(esw->dev, MLX5_INTERFACE_PROTOCOL_IB);
1626+
16251627
err = esw_offloads_init(esw, nvfs + 1);
1628+
}
1629+
16261630
if (err)
16271631
goto abort;
16281632

@@ -1644,12 +1648,17 @@ int mlx5_eswitch_enable_sriov(struct mlx5_eswitch *esw, int nvfs, int mode)
16441648

16451649
abort:
16461650
esw->mode = SRIOV_NONE;
1651+
1652+
if (mode == SRIOV_OFFLOADS)
1653+
mlx5_reload_interface(esw->dev, MLX5_INTERFACE_PROTOCOL_IB);
1654+
16471655
return err;
16481656
}
16491657

16501658
void mlx5_eswitch_disable_sriov(struct mlx5_eswitch *esw)
16511659
{
16521660
struct esw_mc_addr *mc_promisc;
1661+
int old_mode;
16531662
int nvports;
16541663
int i;
16551664

@@ -1675,7 +1684,11 @@ void mlx5_eswitch_disable_sriov(struct mlx5_eswitch *esw)
16751684
else if (esw->mode == SRIOV_OFFLOADS)
16761685
esw_offloads_cleanup(esw, nvports);
16771686

1687+
old_mode = esw->mode;
16781688
esw->mode = SRIOV_NONE;
1689+
1690+
if (old_mode == SRIOV_OFFLOADS)
1691+
mlx5_reload_interface(esw->dev, MLX5_INTERFACE_PROTOCOL_IB);
16791692
}
16801693

16811694
int mlx5_eswitch_init(struct mlx5_core_dev *dev)

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

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -827,14 +827,9 @@ int esw_offloads_init(struct mlx5_eswitch *esw, int nvports)
827827
{
828828
int err;
829829

830-
/* disable PF RoCE so missed packets don't go through RoCE steering */
831-
mlx5_dev_list_lock();
832-
mlx5_remove_dev_by_protocol(esw->dev, MLX5_INTERFACE_PROTOCOL_IB);
833-
mlx5_dev_list_unlock();
834-
835830
err = esw_create_offloads_fdb_tables(esw, nvports);
836831
if (err)
837-
goto create_fdb_err;
832+
return err;
838833

839834
err = esw_create_offloads_table(esw);
840835
if (err)
@@ -859,12 +854,6 @@ int esw_offloads_init(struct mlx5_eswitch *esw, int nvports)
859854
create_ft_err:
860855
esw_destroy_offloads_fdb_tables(esw);
861856

862-
create_fdb_err:
863-
/* enable back PF RoCE */
864-
mlx5_dev_list_lock();
865-
mlx5_add_dev_by_protocol(esw->dev, MLX5_INTERFACE_PROTOCOL_IB);
866-
mlx5_dev_list_unlock();
867-
868857
return err;
869858
}
870859

@@ -882,9 +871,7 @@ static int esw_offloads_stop(struct mlx5_eswitch *esw)
882871
}
883872

884873
/* enable back PF RoCE */
885-
mlx5_dev_list_lock();
886-
mlx5_add_dev_by_protocol(esw->dev, MLX5_INTERFACE_PROTOCOL_IB);
887-
mlx5_dev_list_unlock();
874+
mlx5_reload_interface(esw->dev, MLX5_INTERFACE_PROTOCOL_IB);
888875

889876
return err;
890877
}

drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,4 +201,5 @@ static inline int mlx5_lag_is_lacp_owner(struct mlx5_core_dev *dev)
201201
int mlx5_lag_allow(struct mlx5_core_dev *dev);
202202
int mlx5_lag_forbid(struct mlx5_core_dev *dev);
203203

204+
void mlx5_reload_interface(struct mlx5_core_dev *mdev, int protocol);
204205
#endif /* __MLX5_CORE_H__ */

0 commit comments

Comments
 (0)