From: Mark Bloch Apply devlink default eswitch mode for mlx5 devices after successful device initialization while holding the devlink instance lock. At this point the devlink instance is registered and the mlx5 devlink operations are available, so the default eswitch mode can be applied to the matching PCI devlink handle. Signed-off-by: Mark Bloch Reviewed-by: Shay Drori Reviewed-by: Moshe Shemesh Signed-off-by: Tariq Toukan --- drivers/net/ethernet/mellanox/mlx5/core/main.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/main.c b/drivers/net/ethernet/mellanox/mlx5/core/main.c index 0c6e4efe38c8..4528097f3d84 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/main.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/main.c @@ -1391,6 +1391,21 @@ static void mlx5_unload(struct mlx5_core_dev *dev) mlx5_free_bfreg(dev, &dev->priv.bfreg); } +static void mlx5_devl_apply_default_esw_mode(struct mlx5_core_dev *dev) +{ + struct devlink *devlink = priv_to_devlink(dev); + int err; + + if (!MLX5_ESWITCH_MANAGER(dev)) + return; + + devl_assert_locked(devlink); + err = devl_apply_default_esw_mode(devlink); + if (err) + mlx5_core_warn(dev, "Couldn't apply default eswitch mode, err %d\n", + err); +} + int mlx5_init_one_devl_locked(struct mlx5_core_dev *dev) { bool light_probe = mlx5_dev_is_lightweight(dev); @@ -1437,6 +1452,7 @@ int mlx5_init_one_devl_locked(struct mlx5_core_dev *dev) mlx5_core_err(dev, "mlx5_hwmon_dev_register failed with error code %d\n", err); mutex_unlock(&dev->intf_state_mutex); + mlx5_devl_apply_default_esw_mode(dev); return 0; err_register: @@ -1538,6 +1554,7 @@ int mlx5_load_one_devl_locked(struct mlx5_core_dev *dev, bool recovery) goto err_attach; mutex_unlock(&dev->intf_state_mutex); + mlx5_devl_apply_default_esw_mode(dev); return 0; err_attach: -- 2.44.0