net/mlx5: Support enable_eth devlink dev param
Enable user to disable Ethernet auxiliary device so that when it is not required, user can disable it. For example, $ devlink dev param set pci/0000:06:00.0 \ name enable_eth value false cmode driverinit $ devlink dev reload pci/0000:06:00.0 At this point devlink instance do not create mlx5_core.eth.2 auxiliary device for the Ethernet functionality. Signed-off-by: Parav Pandit <parav@nvidia.com> Reviewed-by: Leon Romanovsky <leonro@nvidia.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Родитель
6f35723864
Коммит
a17beb28ed
|
@ -53,7 +53,7 @@ static bool is_eth_rep_supported(struct mlx5_core_dev *dev)
|
|||
return true;
|
||||
}
|
||||
|
||||
static bool is_eth_supported(struct mlx5_core_dev *dev)
|
||||
bool mlx5_eth_supported(struct mlx5_core_dev *dev)
|
||||
{
|
||||
if (!IS_ENABLED(CONFIG_MLX5_CORE_EN))
|
||||
return false;
|
||||
|
@ -105,6 +105,17 @@ static bool is_eth_supported(struct mlx5_core_dev *dev)
|
|||
return true;
|
||||
}
|
||||
|
||||
static bool is_eth_enabled(struct mlx5_core_dev *dev)
|
||||
{
|
||||
union devlink_param_value val;
|
||||
int err;
|
||||
|
||||
err = devlink_param_driverinit_value_get(priv_to_devlink(dev),
|
||||
DEVLINK_PARAM_GENERIC_ID_ENABLE_ETH,
|
||||
&val);
|
||||
return err ? false : val.vbool;
|
||||
}
|
||||
|
||||
static bool is_vnet_supported(struct mlx5_core_dev *dev)
|
||||
{
|
||||
if (!IS_ENABLED(CONFIG_MLX5_VDPA_NET))
|
||||
|
@ -201,13 +212,15 @@ enum {
|
|||
static const struct mlx5_adev_device {
|
||||
const char *suffix;
|
||||
bool (*is_supported)(struct mlx5_core_dev *dev);
|
||||
bool (*is_enabled)(struct mlx5_core_dev *dev);
|
||||
} mlx5_adev_devices[] = {
|
||||
[MLX5_INTERFACE_PROTOCOL_VNET] = { .suffix = "vnet",
|
||||
.is_supported = &is_vnet_supported },
|
||||
[MLX5_INTERFACE_PROTOCOL_IB] = { .suffix = "rdma",
|
||||
.is_supported = &is_ib_supported },
|
||||
[MLX5_INTERFACE_PROTOCOL_ETH] = { .suffix = "eth",
|
||||
.is_supported = &is_eth_supported },
|
||||
.is_supported = &mlx5_eth_supported,
|
||||
.is_enabled = &is_eth_enabled },
|
||||
[MLX5_INTERFACE_PROTOCOL_ETH_REP] = { .suffix = "eth-rep",
|
||||
.is_supported = &is_eth_rep_supported },
|
||||
[MLX5_INTERFACE_PROTOCOL_IB_REP] = { .suffix = "rdma-rep",
|
||||
|
@ -308,6 +321,14 @@ int mlx5_attach_device(struct mlx5_core_dev *dev)
|
|||
if (!priv->adev[i]) {
|
||||
bool is_supported = false;
|
||||
|
||||
if (mlx5_adev_devices[i].is_enabled) {
|
||||
bool enabled;
|
||||
|
||||
enabled = mlx5_adev_devices[i].is_enabled(dev);
|
||||
if (!enabled)
|
||||
continue;
|
||||
}
|
||||
|
||||
if (mlx5_adev_devices[i].is_supported)
|
||||
is_supported = mlx5_adev_devices[i].is_supported(dev);
|
||||
|
||||
|
@ -360,6 +381,14 @@ void mlx5_detach_device(struct mlx5_core_dev *dev)
|
|||
if (!priv->adev[i])
|
||||
continue;
|
||||
|
||||
if (mlx5_adev_devices[i].is_enabled) {
|
||||
bool enabled;
|
||||
|
||||
enabled = mlx5_adev_devices[i].is_enabled(dev);
|
||||
if (!enabled)
|
||||
goto skip_suspend;
|
||||
}
|
||||
|
||||
adev = &priv->adev[i]->adev;
|
||||
/* Auxiliary driver was unbind manually through sysfs */
|
||||
if (!adev->dev.driver)
|
||||
|
@ -447,12 +476,21 @@ static void delete_drivers(struct mlx5_core_dev *dev)
|
|||
if (!priv->adev[i])
|
||||
continue;
|
||||
|
||||
if (mlx5_adev_devices[i].is_enabled) {
|
||||
bool enabled;
|
||||
|
||||
enabled = mlx5_adev_devices[i].is_enabled(dev);
|
||||
if (!enabled)
|
||||
goto del_adev;
|
||||
}
|
||||
|
||||
if (mlx5_adev_devices[i].is_supported && !delete_all)
|
||||
is_supported = mlx5_adev_devices[i].is_supported(dev);
|
||||
|
||||
if (is_supported)
|
||||
continue;
|
||||
|
||||
del_adev:
|
||||
del_adev(&priv->adev[i]->adev);
|
||||
priv->adev[i] = NULL;
|
||||
}
|
||||
|
|
|
@ -596,6 +596,52 @@ static void mlx5_devlink_set_params_init_values(struct devlink *devlink)
|
|||
#endif
|
||||
}
|
||||
|
||||
static const struct devlink_param enable_eth_param =
|
||||
DEVLINK_PARAM_GENERIC(ENABLE_ETH, BIT(DEVLINK_PARAM_CMODE_DRIVERINIT),
|
||||
NULL, NULL, NULL);
|
||||
|
||||
static int mlx5_devlink_eth_param_register(struct devlink *devlink)
|
||||
{
|
||||
struct mlx5_core_dev *dev = devlink_priv(devlink);
|
||||
union devlink_param_value value;
|
||||
int err;
|
||||
|
||||
if (!mlx5_eth_supported(dev))
|
||||
return 0;
|
||||
|
||||
err = devlink_param_register(devlink, &enable_eth_param);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
value.vbool = true;
|
||||
devlink_param_driverinit_value_set(devlink,
|
||||
DEVLINK_PARAM_GENERIC_ID_ENABLE_ETH,
|
||||
value);
|
||||
devlink_param_publish(devlink, &enable_eth_param);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void mlx5_devlink_eth_param_unregister(struct devlink *devlink)
|
||||
{
|
||||
struct mlx5_core_dev *dev = devlink_priv(devlink);
|
||||
|
||||
if (!mlx5_eth_supported(dev))
|
||||
return;
|
||||
|
||||
devlink_param_unpublish(devlink, &enable_eth_param);
|
||||
devlink_param_unregister(devlink, &enable_eth_param);
|
||||
}
|
||||
|
||||
static int mlx5_devlink_auxdev_params_register(struct devlink *devlink)
|
||||
{
|
||||
return mlx5_devlink_eth_param_register(devlink);
|
||||
}
|
||||
|
||||
static void mlx5_devlink_auxdev_params_unregister(struct devlink *devlink)
|
||||
{
|
||||
mlx5_devlink_eth_param_unregister(devlink);
|
||||
}
|
||||
|
||||
#define MLX5_TRAP_DROP(_id, _group_id) \
|
||||
DEVLINK_TRAP_GENERIC(DROP, DROP, _id, \
|
||||
DEVLINK_TRAP_GROUP_GENERIC_ID_##_group_id, \
|
||||
|
@ -654,6 +700,10 @@ int mlx5_devlink_register(struct devlink *devlink)
|
|||
mlx5_devlink_set_params_init_values(devlink);
|
||||
devlink_params_publish(devlink);
|
||||
|
||||
err = mlx5_devlink_auxdev_params_register(devlink);
|
||||
if (err)
|
||||
goto auxdev_reg_err;
|
||||
|
||||
err = mlx5_devlink_traps_register(devlink);
|
||||
if (err)
|
||||
goto traps_reg_err;
|
||||
|
@ -661,6 +711,8 @@ int mlx5_devlink_register(struct devlink *devlink)
|
|||
return 0;
|
||||
|
||||
traps_reg_err:
|
||||
mlx5_devlink_auxdev_params_unregister(devlink);
|
||||
auxdev_reg_err:
|
||||
devlink_params_unregister(devlink, mlx5_devlink_params,
|
||||
ARRAY_SIZE(mlx5_devlink_params));
|
||||
params_reg_err:
|
||||
|
@ -671,6 +723,7 @@ params_reg_err:
|
|||
void mlx5_devlink_unregister(struct devlink *devlink)
|
||||
{
|
||||
mlx5_devlink_traps_unregister(devlink);
|
||||
mlx5_devlink_auxdev_params_unregister(devlink);
|
||||
devlink_params_unpublish(devlink);
|
||||
devlink_params_unregister(devlink, mlx5_devlink_params,
|
||||
ARRAY_SIZE(mlx5_devlink_params));
|
||||
|
|
|
@ -272,4 +272,7 @@ static inline u32 mlx5_sriov_get_vf_total_msix(struct pci_dev *pdev)
|
|||
|
||||
return MLX5_CAP_GEN_MAX(dev, num_total_dynamic_vf_msix);
|
||||
}
|
||||
|
||||
bool mlx5_eth_supported(struct mlx5_core_dev *dev);
|
||||
|
||||
#endif /* __MLX5_CORE_H__ */
|
||||
|
|
Загрузка…
Ссылка в новой задаче