Commit a11e1ec1 authored by Vadim Pasternak's avatar Vadim Pasternak Committed by David S. Miller

mlxsw: core_env: Split module power mode setting to a separate function

Move the code that applies the module power mode to the device to a
separate function. This function will be invoked by the next patch to
set the power mode on transceiver modules found on a line card when the
line card becomes active.
Signed-off-by: default avatarVadim Pasternak <vadimp@nvidia.com>
Signed-off-by: default avatarIdo Schimmel <idosch@nvidia.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 7b261af9
...@@ -648,25 +648,16 @@ static int __mlxsw_env_set_module_power_mode(struct mlxsw_core *mlxsw_core, ...@@ -648,25 +648,16 @@ static int __mlxsw_env_set_module_power_mode(struct mlxsw_core *mlxsw_core,
return err; return err;
} }
int static int
mlxsw_env_set_module_power_mode(struct mlxsw_core *mlxsw_core, u8 slot_index, mlxsw_env_set_module_power_mode_apply(struct mlxsw_core *mlxsw_core,
u8 module, u8 slot_index, u8 module,
enum ethtool_module_power_mode_policy policy, enum ethtool_module_power_mode_policy policy,
struct netlink_ext_ack *extack) struct netlink_ext_ack *extack)
{ {
struct mlxsw_env *mlxsw_env = mlxsw_core_env(mlxsw_core);
struct mlxsw_env_module_info *module_info; struct mlxsw_env_module_info *module_info;
bool low_power; bool low_power;
int err = 0; int err = 0;
if (policy != ETHTOOL_MODULE_POWER_MODE_POLICY_HIGH &&
policy != ETHTOOL_MODULE_POWER_MODE_POLICY_AUTO) {
NL_SET_ERR_MSG_MOD(extack, "Unsupported power mode policy");
return -EOPNOTSUPP;
}
mutex_lock(&mlxsw_env->line_cards_lock);
err = __mlxsw_env_validate_module_type(mlxsw_core, slot_index, module); err = __mlxsw_env_validate_module_type(mlxsw_core, slot_index, module);
if (err) { if (err) {
NL_SET_ERR_MSG_MOD(extack, NL_SET_ERR_MSG_MOD(extack,
...@@ -691,7 +682,29 @@ mlxsw_env_set_module_power_mode(struct mlxsw_core *mlxsw_core, u8 slot_index, ...@@ -691,7 +682,29 @@ mlxsw_env_set_module_power_mode(struct mlxsw_core *mlxsw_core, u8 slot_index,
out_set_policy: out_set_policy:
module_info->power_mode_policy = policy; module_info->power_mode_policy = policy;
out: out:
return err;
}
int
mlxsw_env_set_module_power_mode(struct mlxsw_core *mlxsw_core, u8 slot_index,
u8 module,
enum ethtool_module_power_mode_policy policy,
struct netlink_ext_ack *extack)
{
struct mlxsw_env *mlxsw_env = mlxsw_core_env(mlxsw_core);
int err;
if (policy != ETHTOOL_MODULE_POWER_MODE_POLICY_HIGH &&
policy != ETHTOOL_MODULE_POWER_MODE_POLICY_AUTO) {
NL_SET_ERR_MSG_MOD(extack, "Unsupported power mode policy");
return -EOPNOTSUPP;
}
mutex_lock(&mlxsw_env->line_cards_lock);
err = mlxsw_env_set_module_power_mode_apply(mlxsw_core, slot_index,
module, policy, extack);
mutex_unlock(&mlxsw_env->line_cards_lock); mutex_unlock(&mlxsw_env->line_cards_lock);
return err; return err;
} }
EXPORT_SYMBOL(mlxsw_env_set_module_power_mode); EXPORT_SYMBOL(mlxsw_env_set_module_power_mode);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment