Commit 503310a5 authored by David S. Miller's avatar David S. Miller

Merge branch 'mlxsw-next'

Ido Schimmel says:

====================
mlxsw: Various updates

This patchset contains miscellaneous updates to mlxsw gathered over
time.

Patches #1-#2 fix recent regressions present in net-next.

Patches #3-#11 are small cleanups performed while adding line card
support in mlxsw.

Patch #12 adds the SFF-8024 Identifier Value of OSFP transceiver in
order to be able to dump their EEPROM contents over the ethtool IOCTL
interface.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 8d783197 f881c4ab
...@@ -177,17 +177,6 @@ void *mlxsw_core_driver_priv(struct mlxsw_core *mlxsw_core) ...@@ -177,17 +177,6 @@ void *mlxsw_core_driver_priv(struct mlxsw_core *mlxsw_core)
} }
EXPORT_SYMBOL(mlxsw_core_driver_priv); EXPORT_SYMBOL(mlxsw_core_driver_priv);
bool mlxsw_core_res_query_enabled(const struct mlxsw_core *mlxsw_core)
{
return mlxsw_core->driver->res_query_enabled;
}
EXPORT_SYMBOL(mlxsw_core_res_query_enabled);
bool mlxsw_core_temp_warn_enabled(const struct mlxsw_core *mlxsw_core)
{
return mlxsw_core->driver->temp_warn_enabled;
}
bool bool
mlxsw_core_fw_rev_minor_subminor_validate(const struct mlxsw_fw_rev *rev, mlxsw_core_fw_rev_minor_subminor_validate(const struct mlxsw_fw_rev *rev,
const struct mlxsw_fw_rev *req_rev) const struct mlxsw_fw_rev *req_rev)
...@@ -223,6 +212,9 @@ static int mlxsw_core_trap_groups_set(struct mlxsw_core *mlxsw_core) ...@@ -223,6 +212,9 @@ static int mlxsw_core_trap_groups_set(struct mlxsw_core *mlxsw_core)
int err; int err;
int i; int i;
if (!(mlxsw_core->bus->features & MLXSW_BUS_F_TXRX))
return 0;
for (i = 0; i < ARRAY_SIZE(mlxsw_core_trap_groups); i++) { for (i = 0; i < ARRAY_SIZE(mlxsw_core_trap_groups); i++) {
mlxsw_reg_htgt_pack(htgt_pl, mlxsw_core_trap_groups[i], mlxsw_reg_htgt_pack(htgt_pl, mlxsw_core_trap_groups[i],
MLXSW_REG_HTGT_INVALID_POLICER, MLXSW_REG_HTGT_INVALID_POLICER,
...@@ -2036,7 +2028,7 @@ static int mlxsw_core_health_init(struct mlxsw_core *mlxsw_core) ...@@ -2036,7 +2028,7 @@ static int mlxsw_core_health_init(struct mlxsw_core *mlxsw_core)
struct devlink_health_reporter *fw_fatal; struct devlink_health_reporter *fw_fatal;
int err; int err;
if (!mlxsw_core->driver->fw_fatal_enabled) if (!(mlxsw_core->bus->features & MLXSW_BUS_F_TXRX))
return 0; return 0;
fw_fatal = devlink_health_reporter_create(devlink, &mlxsw_core_health_fw_fatal_ops, fw_fatal = devlink_health_reporter_create(devlink, &mlxsw_core_health_fw_fatal_ops,
...@@ -2066,7 +2058,7 @@ static int mlxsw_core_health_init(struct mlxsw_core *mlxsw_core) ...@@ -2066,7 +2058,7 @@ static int mlxsw_core_health_init(struct mlxsw_core *mlxsw_core)
static void mlxsw_core_health_fini(struct mlxsw_core *mlxsw_core) static void mlxsw_core_health_fini(struct mlxsw_core *mlxsw_core)
{ {
if (!mlxsw_core->driver->fw_fatal_enabled) if (!(mlxsw_core->bus->features & MLXSW_BUS_F_TXRX))
return; return;
mlxsw_core_health_fw_fatal_config(mlxsw_core, false); mlxsw_core_health_fw_fatal_config(mlxsw_core, false);
...@@ -2086,7 +2078,6 @@ __mlxsw_core_bus_device_register(const struct mlxsw_bus_info *mlxsw_bus_info, ...@@ -2086,7 +2078,6 @@ __mlxsw_core_bus_device_register(const struct mlxsw_bus_info *mlxsw_bus_info,
const char *device_kind = mlxsw_bus_info->device_kind; const char *device_kind = mlxsw_bus_info->device_kind;
struct mlxsw_core *mlxsw_core; struct mlxsw_core *mlxsw_core;
struct mlxsw_driver *mlxsw_driver; struct mlxsw_driver *mlxsw_driver;
struct mlxsw_res *res;
size_t alloc_size; size_t alloc_size;
int err; int err;
...@@ -2112,8 +2103,8 @@ __mlxsw_core_bus_device_register(const struct mlxsw_bus_info *mlxsw_bus_info, ...@@ -2112,8 +2103,8 @@ __mlxsw_core_bus_device_register(const struct mlxsw_bus_info *mlxsw_bus_info,
mlxsw_core->bus_priv = bus_priv; mlxsw_core->bus_priv = bus_priv;
mlxsw_core->bus_info = mlxsw_bus_info; mlxsw_core->bus_info = mlxsw_bus_info;
res = mlxsw_driver->res_query_enabled ? &mlxsw_core->res : NULL; err = mlxsw_bus->init(bus_priv, mlxsw_core, mlxsw_driver->profile,
err = mlxsw_bus->init(bus_priv, mlxsw_core, mlxsw_driver->profile, res); &mlxsw_core->res);
if (err) if (err)
goto err_bus_init; goto err_bus_init;
...@@ -2522,6 +2513,9 @@ int mlxsw_core_trap_register(struct mlxsw_core *mlxsw_core, ...@@ -2522,6 +2513,9 @@ int mlxsw_core_trap_register(struct mlxsw_core *mlxsw_core,
char hpkt_pl[MLXSW_REG_HPKT_LEN]; char hpkt_pl[MLXSW_REG_HPKT_LEN];
int err; int err;
if (!(mlxsw_core->bus->features & MLXSW_BUS_F_TXRX))
return 0;
err = mlxsw_core_listener_register(mlxsw_core, listener, priv, err = mlxsw_core_listener_register(mlxsw_core, listener, priv,
listener->enabled_on_register); listener->enabled_on_register);
if (err) if (err)
...@@ -2551,6 +2545,9 @@ void mlxsw_core_trap_unregister(struct mlxsw_core *mlxsw_core, ...@@ -2551,6 +2545,9 @@ void mlxsw_core_trap_unregister(struct mlxsw_core *mlxsw_core,
{ {
char hpkt_pl[MLXSW_REG_HPKT_LEN]; char hpkt_pl[MLXSW_REG_HPKT_LEN];
if (!(mlxsw_core->bus->features & MLXSW_BUS_F_TXRX))
return;
if (!listener->is_event) { if (!listener->is_event) {
mlxsw_reg_hpkt_pack(hpkt_pl, listener->dis_action, mlxsw_reg_hpkt_pack(hpkt_pl, listener->dis_action,
listener->trap_id, listener->dis_trap_group, listener->trap_id, listener->dis_trap_group,
...@@ -3242,9 +3239,6 @@ int mlxsw_core_resources_query(struct mlxsw_core *mlxsw_core, char *mbox, ...@@ -3242,9 +3239,6 @@ int mlxsw_core_resources_query(struct mlxsw_core *mlxsw_core, char *mbox,
u16 id; u16 id;
int err; int err;
if (!res)
return 0;
mlxsw_cmd_mbox_zero(mbox); mlxsw_cmd_mbox_zero(mbox);
for (index = 0; index < MLXSW_CMD_QUERY_RESOURCES_MAX_QUERIES; for (index = 0; index < MLXSW_CMD_QUERY_RESOURCES_MAX_QUERIES;
......
...@@ -35,10 +35,6 @@ unsigned int mlxsw_core_max_ports(const struct mlxsw_core *mlxsw_core); ...@@ -35,10 +35,6 @@ unsigned int mlxsw_core_max_ports(const struct mlxsw_core *mlxsw_core);
void *mlxsw_core_driver_priv(struct mlxsw_core *mlxsw_core); void *mlxsw_core_driver_priv(struct mlxsw_core *mlxsw_core);
bool mlxsw_core_res_query_enabled(const struct mlxsw_core *mlxsw_core);
bool mlxsw_core_temp_warn_enabled(const struct mlxsw_core *mlxsw_core);
bool bool
mlxsw_core_fw_rev_minor_subminor_validate(const struct mlxsw_fw_rev *rev, mlxsw_core_fw_rev_minor_subminor_validate(const struct mlxsw_fw_rev *rev,
const struct mlxsw_fw_rev *req_rev); const struct mlxsw_fw_rev *req_rev);
...@@ -406,9 +402,6 @@ struct mlxsw_driver { ...@@ -406,9 +402,6 @@ struct mlxsw_driver {
u8 txhdr_len; u8 txhdr_len;
const struct mlxsw_config_profile *profile; const struct mlxsw_config_profile *profile;
bool res_query_enabled;
bool fw_fatal_enabled;
bool temp_warn_enabled;
}; };
int mlxsw_core_kvd_sizes_get(struct mlxsw_core *mlxsw_core, int mlxsw_core_kvd_sizes_get(struct mlxsw_core *mlxsw_core,
......
...@@ -87,6 +87,7 @@ mlxsw_env_validate_cable_ident(struct mlxsw_core *core, int id, bool *qsfp, ...@@ -87,6 +87,7 @@ mlxsw_env_validate_cable_ident(struct mlxsw_core *core, int id, bool *qsfp,
*qsfp = true; *qsfp = true;
break; break;
case MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_QSFP_DD: case MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_QSFP_DD:
case MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_OSFP:
*qsfp = true; *qsfp = true;
*cmis = true; *cmis = true;
break; break;
...@@ -303,6 +304,7 @@ int mlxsw_env_get_module_info(struct net_device *netdev, ...@@ -303,6 +304,7 @@ int mlxsw_env_get_module_info(struct net_device *netdev,
modinfo->eeprom_len = ETH_MODULE_SFF_8472_LEN / 2; modinfo->eeprom_len = ETH_MODULE_SFF_8472_LEN / 2;
break; break;
case MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_QSFP_DD: case MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_QSFP_DD:
case MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_OSFP:
/* Use SFF_8636 as base type. ethtool should recognize specific /* Use SFF_8636 as base type. ethtool should recognize specific
* type through the identifier value. * type through the identifier value.
*/ */
...@@ -462,9 +464,6 @@ int mlxsw_env_reset_module(struct net_device *netdev, ...@@ -462,9 +464,6 @@ int mlxsw_env_reset_module(struct net_device *netdev,
!(req & (ETH_RESET_PHY << ETH_RESET_SHARED_SHIFT))) !(req & (ETH_RESET_PHY << ETH_RESET_SHARED_SHIFT)))
return 0; return 0;
if (WARN_ON_ONCE(module >= mlxsw_env->module_count))
return -EINVAL;
mutex_lock(&mlxsw_env->module_info_lock); mutex_lock(&mlxsw_env->module_info_lock);
err = __mlxsw_env_validate_module_type(mlxsw_core, module); err = __mlxsw_env_validate_module_type(mlxsw_core, module);
...@@ -510,9 +509,6 @@ mlxsw_env_get_module_power_mode(struct mlxsw_core *mlxsw_core, u8 module, ...@@ -510,9 +509,6 @@ mlxsw_env_get_module_power_mode(struct mlxsw_core *mlxsw_core, u8 module,
u32 status_bits; u32 status_bits;
int err; int err;
if (WARN_ON_ONCE(module >= mlxsw_env->module_count))
return -EINVAL;
mutex_lock(&mlxsw_env->module_info_lock); mutex_lock(&mlxsw_env->module_info_lock);
err = __mlxsw_env_validate_module_type(mlxsw_core, module); err = __mlxsw_env_validate_module_type(mlxsw_core, module);
...@@ -620,9 +616,6 @@ mlxsw_env_set_module_power_mode(struct mlxsw_core *mlxsw_core, u8 module, ...@@ -620,9 +616,6 @@ mlxsw_env_set_module_power_mode(struct mlxsw_core *mlxsw_core, u8 module,
bool low_power; bool low_power;
int err = 0; int err = 0;
if (WARN_ON_ONCE(module >= mlxsw_env->module_count))
return -EINVAL;
if (policy != ETHTOOL_MODULE_POWER_MODE_POLICY_HIGH && if (policy != ETHTOOL_MODULE_POWER_MODE_POLICY_HIGH &&
policy != ETHTOOL_MODULE_POWER_MODE_POLICY_AUTO) { policy != ETHTOOL_MODULE_POWER_MODE_POLICY_AUTO) {
NL_SET_ERR_MSG_MOD(extack, "Unsupported power mode policy"); NL_SET_ERR_MSG_MOD(extack, "Unsupported power mode policy");
...@@ -831,9 +824,6 @@ static int mlxsw_env_temp_warn_event_register(struct mlxsw_core *mlxsw_core) ...@@ -831,9 +824,6 @@ static int mlxsw_env_temp_warn_event_register(struct mlxsw_core *mlxsw_core)
{ {
struct mlxsw_env *mlxsw_env = mlxsw_core_env(mlxsw_core); struct mlxsw_env *mlxsw_env = mlxsw_core_env(mlxsw_core);
if (!mlxsw_core_temp_warn_enabled(mlxsw_core))
return 0;
return mlxsw_core_trap_register(mlxsw_core, return mlxsw_core_trap_register(mlxsw_core,
&mlxsw_env_temp_warn_listener, &mlxsw_env_temp_warn_listener,
mlxsw_env); mlxsw_env);
...@@ -841,9 +831,6 @@ static int mlxsw_env_temp_warn_event_register(struct mlxsw_core *mlxsw_core) ...@@ -841,9 +831,6 @@ static int mlxsw_env_temp_warn_event_register(struct mlxsw_core *mlxsw_core)
static void mlxsw_env_temp_warn_event_unregister(struct mlxsw_env *mlxsw_env) static void mlxsw_env_temp_warn_event_unregister(struct mlxsw_env *mlxsw_env)
{ {
if (!mlxsw_core_temp_warn_enabled(mlxsw_env->core))
return;
mlxsw_core_trap_unregister(mlxsw_env->core, mlxsw_core_trap_unregister(mlxsw_env->core,
&mlxsw_env_temp_warn_listener, mlxsw_env); &mlxsw_env_temp_warn_listener, mlxsw_env);
} }
...@@ -922,9 +909,6 @@ mlxsw_env_module_plug_event_register(struct mlxsw_core *mlxsw_core) ...@@ -922,9 +909,6 @@ mlxsw_env_module_plug_event_register(struct mlxsw_core *mlxsw_core)
{ {
struct mlxsw_env *mlxsw_env = mlxsw_core_env(mlxsw_core); struct mlxsw_env *mlxsw_env = mlxsw_core_env(mlxsw_core);
if (!mlxsw_core_temp_warn_enabled(mlxsw_core))
return 0;
return mlxsw_core_trap_register(mlxsw_core, return mlxsw_core_trap_register(mlxsw_core,
&mlxsw_env_module_plug_listener, &mlxsw_env_module_plug_listener,
mlxsw_env); mlxsw_env);
...@@ -933,9 +917,6 @@ mlxsw_env_module_plug_event_register(struct mlxsw_core *mlxsw_core) ...@@ -933,9 +917,6 @@ mlxsw_env_module_plug_event_register(struct mlxsw_core *mlxsw_core)
static void static void
mlxsw_env_module_plug_event_unregister(struct mlxsw_env *mlxsw_env) mlxsw_env_module_plug_event_unregister(struct mlxsw_env *mlxsw_env)
{ {
if (!mlxsw_core_temp_warn_enabled(mlxsw_env->core))
return;
mlxsw_core_trap_unregister(mlxsw_env->core, mlxsw_core_trap_unregister(mlxsw_env->core,
&mlxsw_env_module_plug_listener, &mlxsw_env_module_plug_listener,
mlxsw_env); mlxsw_env);
...@@ -966,9 +947,6 @@ mlxsw_env_module_overheat_counter_get(struct mlxsw_core *mlxsw_core, u8 module, ...@@ -966,9 +947,6 @@ mlxsw_env_module_overheat_counter_get(struct mlxsw_core *mlxsw_core, u8 module,
{ {
struct mlxsw_env *mlxsw_env = mlxsw_core_env(mlxsw_core); struct mlxsw_env *mlxsw_env = mlxsw_core_env(mlxsw_core);
if (WARN_ON_ONCE(module >= mlxsw_env->module_count))
return -EINVAL;
mutex_lock(&mlxsw_env->module_info_lock); mutex_lock(&mlxsw_env->module_info_lock);
*p_counter = mlxsw_env->module_info[module].module_overheat_counter; *p_counter = mlxsw_env->module_info[module].module_overheat_counter;
mutex_unlock(&mlxsw_env->module_info_lock); mutex_unlock(&mlxsw_env->module_info_lock);
...@@ -981,9 +959,6 @@ void mlxsw_env_module_port_map(struct mlxsw_core *mlxsw_core, u8 module) ...@@ -981,9 +959,6 @@ void mlxsw_env_module_port_map(struct mlxsw_core *mlxsw_core, u8 module)
{ {
struct mlxsw_env *mlxsw_env = mlxsw_core_env(mlxsw_core); struct mlxsw_env *mlxsw_env = mlxsw_core_env(mlxsw_core);
if (WARN_ON_ONCE(module >= mlxsw_env->module_count))
return;
mutex_lock(&mlxsw_env->module_info_lock); mutex_lock(&mlxsw_env->module_info_lock);
mlxsw_env->module_info[module].num_ports_mapped++; mlxsw_env->module_info[module].num_ports_mapped++;
mutex_unlock(&mlxsw_env->module_info_lock); mutex_unlock(&mlxsw_env->module_info_lock);
...@@ -994,9 +969,6 @@ void mlxsw_env_module_port_unmap(struct mlxsw_core *mlxsw_core, u8 module) ...@@ -994,9 +969,6 @@ void mlxsw_env_module_port_unmap(struct mlxsw_core *mlxsw_core, u8 module)
{ {
struct mlxsw_env *mlxsw_env = mlxsw_core_env(mlxsw_core); struct mlxsw_env *mlxsw_env = mlxsw_core_env(mlxsw_core);
if (WARN_ON_ONCE(module >= mlxsw_env->module_count))
return;
mutex_lock(&mlxsw_env->module_info_lock); mutex_lock(&mlxsw_env->module_info_lock);
mlxsw_env->module_info[module].num_ports_mapped--; mlxsw_env->module_info[module].num_ports_mapped--;
mutex_unlock(&mlxsw_env->module_info_lock); mutex_unlock(&mlxsw_env->module_info_lock);
...@@ -1008,9 +980,6 @@ int mlxsw_env_module_port_up(struct mlxsw_core *mlxsw_core, u8 module) ...@@ -1008,9 +980,6 @@ int mlxsw_env_module_port_up(struct mlxsw_core *mlxsw_core, u8 module)
struct mlxsw_env *mlxsw_env = mlxsw_core_env(mlxsw_core); struct mlxsw_env *mlxsw_env = mlxsw_core_env(mlxsw_core);
int err = 0; int err = 0;
if (WARN_ON_ONCE(module >= mlxsw_env->module_count))
return -EINVAL;
mutex_lock(&mlxsw_env->module_info_lock); mutex_lock(&mlxsw_env->module_info_lock);
if (mlxsw_env->module_info[module].power_mode_policy != if (mlxsw_env->module_info[module].power_mode_policy !=
...@@ -1040,9 +1009,6 @@ void mlxsw_env_module_port_down(struct mlxsw_core *mlxsw_core, u8 module) ...@@ -1040,9 +1009,6 @@ void mlxsw_env_module_port_down(struct mlxsw_core *mlxsw_core, u8 module)
{ {
struct mlxsw_env *mlxsw_env = mlxsw_core_env(mlxsw_core); struct mlxsw_env *mlxsw_env = mlxsw_core_env(mlxsw_core);
if (WARN_ON_ONCE(module >= mlxsw_env->module_count))
return;
mutex_lock(&mlxsw_env->module_info_lock); mutex_lock(&mlxsw_env->module_info_lock);
mlxsw_env->module_info[module].num_ports_up--; mlxsw_env->module_info[module].num_ports_up--;
......
...@@ -57,14 +57,14 @@ static ssize_t mlxsw_hwmon_temp_show(struct device *dev, ...@@ -57,14 +57,14 @@ static ssize_t mlxsw_hwmon_temp_show(struct device *dev,
struct device_attribute *attr, struct device_attribute *attr,
char *buf) char *buf)
{ {
struct mlxsw_hwmon_attr *mlwsw_hwmon_attr = struct mlxsw_hwmon_attr *mlxsw_hwmon_attr =
container_of(attr, struct mlxsw_hwmon_attr, dev_attr); container_of(attr, struct mlxsw_hwmon_attr, dev_attr);
struct mlxsw_hwmon *mlxsw_hwmon = mlwsw_hwmon_attr->hwmon; struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_attr->hwmon;
char mtmp_pl[MLXSW_REG_MTMP_LEN]; char mtmp_pl[MLXSW_REG_MTMP_LEN];
int temp, index; int temp, index;
int err; int err;
index = mlxsw_hwmon_get_attr_index(mlwsw_hwmon_attr->type_index, index = mlxsw_hwmon_get_attr_index(mlxsw_hwmon_attr->type_index,
mlxsw_hwmon->module_sensor_max); mlxsw_hwmon->module_sensor_max);
mlxsw_reg_mtmp_pack(mtmp_pl, index, false, false); mlxsw_reg_mtmp_pack(mtmp_pl, index, false, false);
err = mlxsw_reg_query(mlxsw_hwmon->core, MLXSW_REG(mtmp), mtmp_pl); err = mlxsw_reg_query(mlxsw_hwmon->core, MLXSW_REG(mtmp), mtmp_pl);
...@@ -80,14 +80,14 @@ static ssize_t mlxsw_hwmon_temp_max_show(struct device *dev, ...@@ -80,14 +80,14 @@ static ssize_t mlxsw_hwmon_temp_max_show(struct device *dev,
struct device_attribute *attr, struct device_attribute *attr,
char *buf) char *buf)
{ {
struct mlxsw_hwmon_attr *mlwsw_hwmon_attr = struct mlxsw_hwmon_attr *mlxsw_hwmon_attr =
container_of(attr, struct mlxsw_hwmon_attr, dev_attr); container_of(attr, struct mlxsw_hwmon_attr, dev_attr);
struct mlxsw_hwmon *mlxsw_hwmon = mlwsw_hwmon_attr->hwmon; struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_attr->hwmon;
char mtmp_pl[MLXSW_REG_MTMP_LEN]; char mtmp_pl[MLXSW_REG_MTMP_LEN];
int temp_max, index; int temp_max, index;
int err; int err;
index = mlxsw_hwmon_get_attr_index(mlwsw_hwmon_attr->type_index, index = mlxsw_hwmon_get_attr_index(mlxsw_hwmon_attr->type_index,
mlxsw_hwmon->module_sensor_max); mlxsw_hwmon->module_sensor_max);
mlxsw_reg_mtmp_pack(mtmp_pl, index, false, false); mlxsw_reg_mtmp_pack(mtmp_pl, index, false, false);
err = mlxsw_reg_query(mlxsw_hwmon->core, MLXSW_REG(mtmp), mtmp_pl); err = mlxsw_reg_query(mlxsw_hwmon->core, MLXSW_REG(mtmp), mtmp_pl);
...@@ -103,9 +103,9 @@ static ssize_t mlxsw_hwmon_temp_rst_store(struct device *dev, ...@@ -103,9 +103,9 @@ static ssize_t mlxsw_hwmon_temp_rst_store(struct device *dev,
struct device_attribute *attr, struct device_attribute *attr,
const char *buf, size_t len) const char *buf, size_t len)
{ {
struct mlxsw_hwmon_attr *mlwsw_hwmon_attr = struct mlxsw_hwmon_attr *mlxsw_hwmon_attr =
container_of(attr, struct mlxsw_hwmon_attr, dev_attr); container_of(attr, struct mlxsw_hwmon_attr, dev_attr);
struct mlxsw_hwmon *mlxsw_hwmon = mlwsw_hwmon_attr->hwmon; struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_attr->hwmon;
char mtmp_pl[MLXSW_REG_MTMP_LEN] = {0}; char mtmp_pl[MLXSW_REG_MTMP_LEN] = {0};
unsigned long val; unsigned long val;
int index; int index;
...@@ -117,7 +117,7 @@ static ssize_t mlxsw_hwmon_temp_rst_store(struct device *dev, ...@@ -117,7 +117,7 @@ static ssize_t mlxsw_hwmon_temp_rst_store(struct device *dev,
if (val != 1) if (val != 1)
return -EINVAL; return -EINVAL;
index = mlxsw_hwmon_get_attr_index(mlwsw_hwmon_attr->type_index, index = mlxsw_hwmon_get_attr_index(mlxsw_hwmon_attr->type_index,
mlxsw_hwmon->module_sensor_max); mlxsw_hwmon->module_sensor_max);
mlxsw_reg_mtmp_sensor_index_set(mtmp_pl, index); mlxsw_reg_mtmp_sensor_index_set(mtmp_pl, index);
...@@ -138,13 +138,13 @@ static ssize_t mlxsw_hwmon_fan_rpm_show(struct device *dev, ...@@ -138,13 +138,13 @@ static ssize_t mlxsw_hwmon_fan_rpm_show(struct device *dev,
struct device_attribute *attr, struct device_attribute *attr,
char *buf) char *buf)
{ {
struct mlxsw_hwmon_attr *mlwsw_hwmon_attr = struct mlxsw_hwmon_attr *mlxsw_hwmon_attr =
container_of(attr, struct mlxsw_hwmon_attr, dev_attr); container_of(attr, struct mlxsw_hwmon_attr, dev_attr);
struct mlxsw_hwmon *mlxsw_hwmon = mlwsw_hwmon_attr->hwmon; struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_attr->hwmon;
char mfsm_pl[MLXSW_REG_MFSM_LEN]; char mfsm_pl[MLXSW_REG_MFSM_LEN];
int err; int err;
mlxsw_reg_mfsm_pack(mfsm_pl, mlwsw_hwmon_attr->type_index); mlxsw_reg_mfsm_pack(mfsm_pl, mlxsw_hwmon_attr->type_index);
err = mlxsw_reg_query(mlxsw_hwmon->core, MLXSW_REG(mfsm), mfsm_pl); err = mlxsw_reg_query(mlxsw_hwmon->core, MLXSW_REG(mfsm), mfsm_pl);
if (err) { if (err) {
dev_err(mlxsw_hwmon->bus_info->dev, "Failed to query fan\n"); dev_err(mlxsw_hwmon->bus_info->dev, "Failed to query fan\n");
...@@ -157,9 +157,9 @@ static ssize_t mlxsw_hwmon_fan_fault_show(struct device *dev, ...@@ -157,9 +157,9 @@ static ssize_t mlxsw_hwmon_fan_fault_show(struct device *dev,
struct device_attribute *attr, struct device_attribute *attr,
char *buf) char *buf)
{ {
struct mlxsw_hwmon_attr *mlwsw_hwmon_attr = struct mlxsw_hwmon_attr *mlxsw_hwmon_attr =
container_of(attr, struct mlxsw_hwmon_attr, dev_attr); container_of(attr, struct mlxsw_hwmon_attr, dev_attr);
struct mlxsw_hwmon *mlxsw_hwmon = mlwsw_hwmon_attr->hwmon; struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_attr->hwmon;
char fore_pl[MLXSW_REG_FORE_LEN]; char fore_pl[MLXSW_REG_FORE_LEN];
bool fault; bool fault;
int err; int err;
...@@ -169,7 +169,7 @@ static ssize_t mlxsw_hwmon_fan_fault_show(struct device *dev, ...@@ -169,7 +169,7 @@ static ssize_t mlxsw_hwmon_fan_fault_show(struct device *dev,
dev_err(mlxsw_hwmon->bus_info->dev, "Failed to query fan\n"); dev_err(mlxsw_hwmon->bus_info->dev, "Failed to query fan\n");
return err; return err;
} }
mlxsw_reg_fore_unpack(fore_pl, mlwsw_hwmon_attr->type_index, &fault); mlxsw_reg_fore_unpack(fore_pl, mlxsw_hwmon_attr->type_index, &fault);
return sprintf(buf, "%u\n", fault); return sprintf(buf, "%u\n", fault);
} }
...@@ -178,13 +178,13 @@ static ssize_t mlxsw_hwmon_pwm_show(struct device *dev, ...@@ -178,13 +178,13 @@ static ssize_t mlxsw_hwmon_pwm_show(struct device *dev,
struct device_attribute *attr, struct device_attribute *attr,
char *buf) char *buf)
{ {
struct mlxsw_hwmon_attr *mlwsw_hwmon_attr = struct mlxsw_hwmon_attr *mlxsw_hwmon_attr =
container_of(attr, struct mlxsw_hwmon_attr, dev_attr); container_of(attr, struct mlxsw_hwmon_attr, dev_attr);
struct mlxsw_hwmon *mlxsw_hwmon = mlwsw_hwmon_attr->hwmon; struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_attr->hwmon;
char mfsc_pl[MLXSW_REG_MFSC_LEN]; char mfsc_pl[MLXSW_REG_MFSC_LEN];
int err; int err;
mlxsw_reg_mfsc_pack(mfsc_pl, mlwsw_hwmon_attr->type_index, 0); mlxsw_reg_mfsc_pack(mfsc_pl, mlxsw_hwmon_attr->type_index, 0);
err = mlxsw_reg_query(mlxsw_hwmon->core, MLXSW_REG(mfsc), mfsc_pl); err = mlxsw_reg_query(mlxsw_hwmon->core, MLXSW_REG(mfsc), mfsc_pl);
if (err) { if (err) {
dev_err(mlxsw_hwmon->bus_info->dev, "Failed to query PWM\n"); dev_err(mlxsw_hwmon->bus_info->dev, "Failed to query PWM\n");
...@@ -198,9 +198,9 @@ static ssize_t mlxsw_hwmon_pwm_store(struct device *dev, ...@@ -198,9 +198,9 @@ static ssize_t mlxsw_hwmon_pwm_store(struct device *dev,
struct device_attribute *attr, struct device_attribute *attr,
const char *buf, size_t len) const char *buf, size_t len)
{ {
struct mlxsw_hwmon_attr *mlwsw_hwmon_attr = struct mlxsw_hwmon_attr *mlxsw_hwmon_attr =
container_of(attr, struct mlxsw_hwmon_attr, dev_attr); container_of(attr, struct mlxsw_hwmon_attr, dev_attr);
struct mlxsw_hwmon *mlxsw_hwmon = mlwsw_hwmon_attr->hwmon; struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_attr->hwmon;
char mfsc_pl[MLXSW_REG_MFSC_LEN]; char mfsc_pl[MLXSW_REG_MFSC_LEN];
unsigned long val; unsigned long val;
int err; int err;
...@@ -211,7 +211,7 @@ static ssize_t mlxsw_hwmon_pwm_store(struct device *dev, ...@@ -211,7 +211,7 @@ static ssize_t mlxsw_hwmon_pwm_store(struct device *dev,
if (val > 255) if (val > 255)
return -EINVAL; return -EINVAL;
mlxsw_reg_mfsc_pack(mfsc_pl, mlwsw_hwmon_attr->type_index, val); mlxsw_reg_mfsc_pack(mfsc_pl, mlxsw_hwmon_attr->type_index, val);
err = mlxsw_reg_write(mlxsw_hwmon->core, MLXSW_REG(mfsc), mfsc_pl); err = mlxsw_reg_write(mlxsw_hwmon->core, MLXSW_REG(mfsc), mfsc_pl);
if (err) { if (err) {
dev_err(mlxsw_hwmon->bus_info->dev, "Failed to write PWM\n"); dev_err(mlxsw_hwmon->bus_info->dev, "Failed to write PWM\n");
...@@ -224,14 +224,14 @@ static int mlxsw_hwmon_module_temp_get(struct device *dev, ...@@ -224,14 +224,14 @@ static int mlxsw_hwmon_module_temp_get(struct device *dev,
struct device_attribute *attr, struct device_attribute *attr,
int *p_temp) int *p_temp)
{ {
struct mlxsw_hwmon_attr *mlwsw_hwmon_attr = struct mlxsw_hwmon_attr *mlxsw_hwmon_attr =
container_of(attr, struct mlxsw_hwmon_attr, dev_attr); container_of(attr, struct mlxsw_hwmon_attr, dev_attr);
struct mlxsw_hwmon *mlxsw_hwmon = mlwsw_hwmon_attr->hwmon; struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_attr->hwmon;
char mtmp_pl[MLXSW_REG_MTMP_LEN]; char mtmp_pl[MLXSW_REG_MTMP_LEN];
u8 module; u8 module;
int err; int err;
module = mlwsw_hwmon_attr->type_index - mlxsw_hwmon->sensor_count; module = mlxsw_hwmon_attr->type_index - mlxsw_hwmon->sensor_count;
mlxsw_reg_mtmp_pack(mtmp_pl, MLXSW_REG_MTMP_MODULE_INDEX_MIN + module, mlxsw_reg_mtmp_pack(mtmp_pl, MLXSW_REG_MTMP_MODULE_INDEX_MIN + module,
false, false); false, false);
err = mlxsw_reg_query(mlxsw_hwmon->core, MLXSW_REG(mtmp), mtmp_pl); err = mlxsw_reg_query(mlxsw_hwmon->core, MLXSW_REG(mtmp), mtmp_pl);
...@@ -261,15 +261,15 @@ static ssize_t mlxsw_hwmon_module_temp_fault_show(struct device *dev, ...@@ -261,15 +261,15 @@ static ssize_t mlxsw_hwmon_module_temp_fault_show(struct device *dev,
struct device_attribute *attr, struct device_attribute *attr,
char *buf) char *buf)
{ {
struct mlxsw_hwmon_attr *mlwsw_hwmon_attr = struct mlxsw_hwmon_attr *mlxsw_hwmon_attr =
container_of(attr, struct mlxsw_hwmon_attr, dev_attr); container_of(attr, struct mlxsw_hwmon_attr, dev_attr);
struct mlxsw_hwmon *mlxsw_hwmon = mlwsw_hwmon_attr->hwmon; struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_attr->hwmon;
char mtbr_pl[MLXSW_REG_MTBR_LEN] = {0}; char mtbr_pl[MLXSW_REG_MTBR_LEN] = {0};
u8 module, fault; u8 module, fault;
u16 temp; u16 temp;
int err; int err;
module = mlwsw_hwmon_attr->type_index - mlxsw_hwmon->sensor_count; module = mlxsw_hwmon_attr->type_index - mlxsw_hwmon->sensor_count;
mlxsw_reg_mtbr_pack(mtbr_pl, MLXSW_REG_MTBR_BASE_MODULE_INDEX + module, mlxsw_reg_mtbr_pack(mtbr_pl, MLXSW_REG_MTBR_BASE_MODULE_INDEX + module,
1); 1);
err = mlxsw_reg_query(mlxsw_hwmon->core, MLXSW_REG(mtbr), mtbr_pl); err = mlxsw_reg_query(mlxsw_hwmon->core, MLXSW_REG(mtbr), mtbr_pl);
...@@ -303,13 +303,13 @@ static int mlxsw_hwmon_module_temp_critical_get(struct device *dev, ...@@ -303,13 +303,13 @@ static int mlxsw_hwmon_module_temp_critical_get(struct device *dev,
struct device_attribute *attr, struct device_attribute *attr,
int *p_temp) int *p_temp)
{ {
struct mlxsw_hwmon_attr *mlwsw_hwmon_attr = struct mlxsw_hwmon_attr *mlxsw_hwmon_attr =
container_of(attr, struct mlxsw_hwmon_attr, dev_attr); container_of(attr, struct mlxsw_hwmon_attr, dev_attr);
struct mlxsw_hwmon *mlxsw_hwmon = mlwsw_hwmon_attr->hwmon; struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_attr->hwmon;
u8 module; u8 module;
int err; int err;
module = mlwsw_hwmon_attr->type_index - mlxsw_hwmon->sensor_count; module = mlxsw_hwmon_attr->type_index - mlxsw_hwmon->sensor_count;
err = mlxsw_env_module_temp_thresholds_get(mlxsw_hwmon->core, module, err = mlxsw_env_module_temp_thresholds_get(mlxsw_hwmon->core, module,
SFP_TEMP_HIGH_WARN, p_temp); SFP_TEMP_HIGH_WARN, p_temp);
if (err) { if (err) {
...@@ -337,13 +337,13 @@ static int mlxsw_hwmon_module_temp_emergency_get(struct device *dev, ...@@ -337,13 +337,13 @@ static int mlxsw_hwmon_module_temp_emergency_get(struct device *dev,
struct device_attribute *attr, struct device_attribute *attr,
int *p_temp) int *p_temp)
{ {
struct mlxsw_hwmon_attr *mlwsw_hwmon_attr = struct mlxsw_hwmon_attr *mlxsw_hwmon_attr =
container_of(attr, struct mlxsw_hwmon_attr, dev_attr); container_of(attr, struct mlxsw_hwmon_attr, dev_attr);
struct mlxsw_hwmon *mlxsw_hwmon = mlwsw_hwmon_attr->hwmon; struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_attr->hwmon;
u8 module; u8 module;
int err; int err;
module = mlwsw_hwmon_attr->type_index - mlxsw_hwmon->sensor_count; module = mlxsw_hwmon_attr->type_index - mlxsw_hwmon->sensor_count;
err = mlxsw_env_module_temp_thresholds_get(mlxsw_hwmon->core, module, err = mlxsw_env_module_temp_thresholds_get(mlxsw_hwmon->core, module,
SFP_TEMP_HIGH_ALARM, p_temp); SFP_TEMP_HIGH_ALARM, p_temp);
if (err) { if (err) {
...@@ -373,11 +373,11 @@ mlxsw_hwmon_module_temp_label_show(struct device *dev, ...@@ -373,11 +373,11 @@ mlxsw_hwmon_module_temp_label_show(struct device *dev,
struct device_attribute *attr, struct device_attribute *attr,
char *buf) char *buf)
{ {
struct mlxsw_hwmon_attr *mlwsw_hwmon_attr = struct mlxsw_hwmon_attr *mlxsw_hwmon_attr =
container_of(attr, struct mlxsw_hwmon_attr, dev_attr); container_of(attr, struct mlxsw_hwmon_attr, dev_attr);
return sprintf(buf, "front panel %03u\n", return sprintf(buf, "front panel %03u\n",
mlwsw_hwmon_attr->type_index); mlxsw_hwmon_attr->type_index);
} }
static ssize_t static ssize_t
...@@ -385,10 +385,10 @@ mlxsw_hwmon_gbox_temp_label_show(struct device *dev, ...@@ -385,10 +385,10 @@ mlxsw_hwmon_gbox_temp_label_show(struct device *dev,
struct device_attribute *attr, struct device_attribute *attr,
char *buf) char *buf)
{ {
struct mlxsw_hwmon_attr *mlwsw_hwmon_attr = struct mlxsw_hwmon_attr *mlxsw_hwmon_attr =
container_of(attr, struct mlxsw_hwmon_attr, dev_attr); container_of(attr, struct mlxsw_hwmon_attr, dev_attr);
struct mlxsw_hwmon *mlxsw_hwmon = mlwsw_hwmon_attr->hwmon; struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_attr->hwmon;
int index = mlwsw_hwmon_attr->type_index - int index = mlxsw_hwmon_attr->type_index -
mlxsw_hwmon->module_sensor_max + 1; mlxsw_hwmon->module_sensor_max + 1;
return sprintf(buf, "gearbox %03u\n", index); return sprintf(buf, "gearbox %03u\n", index);
...@@ -655,9 +655,6 @@ static int mlxsw_hwmon_module_init(struct mlxsw_hwmon *mlxsw_hwmon) ...@@ -655,9 +655,6 @@ static int mlxsw_hwmon_module_init(struct mlxsw_hwmon *mlxsw_hwmon)
u8 module_sensor_max; u8 module_sensor_max;
int i, err; int i, err;
if (!mlxsw_core_res_query_enabled(mlxsw_hwmon->core))
return 0;
mlxsw_reg_mgpir_pack(mgpir_pl); mlxsw_reg_mgpir_pack(mgpir_pl);
err = mlxsw_reg_query(mlxsw_hwmon->core, MLXSW_REG(mgpir), mgpir_pl); err = mlxsw_reg_query(mlxsw_hwmon->core, MLXSW_REG(mgpir), mgpir_pl);
if (err) if (err)
......
...@@ -357,6 +357,10 @@ static int mlxsw_thermal_trend_get(struct thermal_zone_device *tzdev, ...@@ -357,6 +357,10 @@ static int mlxsw_thermal_trend_get(struct thermal_zone_device *tzdev,
return 0; return 0;
} }
static struct thermal_zone_params mlxsw_thermal_params = {
.no_hwmon = true,
};
static struct thermal_zone_device_ops mlxsw_thermal_ops = { static struct thermal_zone_device_ops mlxsw_thermal_ops = {
.bind = mlxsw_thermal_bind, .bind = mlxsw_thermal_bind,
.unbind = mlxsw_thermal_unbind, .unbind = mlxsw_thermal_unbind,
...@@ -388,11 +392,11 @@ static int mlxsw_thermal_module_bind(struct thermal_zone_device *tzdev, ...@@ -388,11 +392,11 @@ static int mlxsw_thermal_module_bind(struct thermal_zone_device *tzdev,
trip->min_state, trip->min_state,
THERMAL_WEIGHT_DEFAULT); THERMAL_WEIGHT_DEFAULT);
if (err < 0) if (err < 0)
goto err_bind_cooling_device; goto err_thermal_zone_bind_cooling_device;
} }
return 0; return 0;
err_bind_cooling_device: err_thermal_zone_bind_cooling_device:
for (j = i - 1; j >= 0; j--) for (j = i - 1; j >= 0; j--)
thermal_zone_unbind_cooling_device(tzdev, j, cdev); thermal_zone_unbind_cooling_device(tzdev, j, cdev);
return err; return err;
...@@ -678,7 +682,8 @@ mlxsw_thermal_module_tz_init(struct mlxsw_thermal_module *module_tz) ...@@ -678,7 +682,8 @@ mlxsw_thermal_module_tz_init(struct mlxsw_thermal_module *module_tz)
MLXSW_THERMAL_TRIP_MASK, MLXSW_THERMAL_TRIP_MASK,
module_tz, module_tz,
&mlxsw_thermal_module_ops, &mlxsw_thermal_module_ops,
NULL, 0, &mlxsw_thermal_params,
0,
module_tz->parent->polling_delay); module_tz->parent->polling_delay);
if (IS_ERR(module_tz->tzdev)) { if (IS_ERR(module_tz->tzdev)) {
err = PTR_ERR(module_tz->tzdev); err = PTR_ERR(module_tz->tzdev);
...@@ -741,9 +746,6 @@ mlxsw_thermal_modules_init(struct device *dev, struct mlxsw_core *core, ...@@ -741,9 +746,6 @@ mlxsw_thermal_modules_init(struct device *dev, struct mlxsw_core *core,
char mgpir_pl[MLXSW_REG_MGPIR_LEN]; char mgpir_pl[MLXSW_REG_MGPIR_LEN];
int i, err; int i, err;
if (!mlxsw_core_res_query_enabled(core))
return 0;
mlxsw_reg_mgpir_pack(mgpir_pl); mlxsw_reg_mgpir_pack(mgpir_pl);
err = mlxsw_reg_query(core, MLXSW_REG(mgpir), mgpir_pl); err = mlxsw_reg_query(core, MLXSW_REG(mgpir), mgpir_pl);
if (err) if (err)
...@@ -761,7 +763,7 @@ mlxsw_thermal_modules_init(struct device *dev, struct mlxsw_core *core, ...@@ -761,7 +763,7 @@ mlxsw_thermal_modules_init(struct device *dev, struct mlxsw_core *core,
for (i = 0; i < thermal->tz_module_num; i++) { for (i = 0; i < thermal->tz_module_num; i++) {
err = mlxsw_thermal_module_init(dev, core, thermal, i); err = mlxsw_thermal_module_init(dev, core, thermal, i);
if (err) if (err)
goto err_unreg_tz_module_arr; goto err_thermal_module_init;
} }
for (i = 0; i < thermal->tz_module_num; i++) { for (i = 0; i < thermal->tz_module_num; i++) {
...@@ -770,12 +772,13 @@ mlxsw_thermal_modules_init(struct device *dev, struct mlxsw_core *core, ...@@ -770,12 +772,13 @@ mlxsw_thermal_modules_init(struct device *dev, struct mlxsw_core *core,
continue; continue;
err = mlxsw_thermal_module_tz_init(module_tz); err = mlxsw_thermal_module_tz_init(module_tz);
if (err) if (err)
goto err_unreg_tz_module_arr; goto err_thermal_module_tz_init;
} }
return 0; return 0;
err_unreg_tz_module_arr: err_thermal_module_tz_init:
err_thermal_module_init:
for (i = thermal->tz_module_num - 1; i >= 0; i--) for (i = thermal->tz_module_num - 1; i >= 0; i--)
mlxsw_thermal_module_fini(&thermal->tz_module_arr[i]); mlxsw_thermal_module_fini(&thermal->tz_module_arr[i]);
kfree(thermal->tz_module_arr); kfree(thermal->tz_module_arr);
...@@ -787,9 +790,6 @@ mlxsw_thermal_modules_fini(struct mlxsw_thermal *thermal) ...@@ -787,9 +790,6 @@ mlxsw_thermal_modules_fini(struct mlxsw_thermal *thermal)
{ {
int i; int i;
if (!mlxsw_core_res_query_enabled(thermal->core))
return;
for (i = thermal->tz_module_num - 1; i >= 0; i--) for (i = thermal->tz_module_num - 1; i >= 0; i--)
mlxsw_thermal_module_fini(&thermal->tz_module_arr[i]); mlxsw_thermal_module_fini(&thermal->tz_module_arr[i]);
kfree(thermal->tz_module_arr); kfree(thermal->tz_module_arr);
...@@ -808,7 +808,7 @@ mlxsw_thermal_gearbox_tz_init(struct mlxsw_thermal_module *gearbox_tz) ...@@ -808,7 +808,7 @@ mlxsw_thermal_gearbox_tz_init(struct mlxsw_thermal_module *gearbox_tz)
MLXSW_THERMAL_TRIP_MASK, MLXSW_THERMAL_TRIP_MASK,
gearbox_tz, gearbox_tz,
&mlxsw_thermal_gearbox_ops, &mlxsw_thermal_gearbox_ops,
NULL, 0, &mlxsw_thermal_params, 0,
gearbox_tz->parent->polling_delay); gearbox_tz->parent->polling_delay);
if (IS_ERR(gearbox_tz->tzdev)) if (IS_ERR(gearbox_tz->tzdev))
return PTR_ERR(gearbox_tz->tzdev); return PTR_ERR(gearbox_tz->tzdev);
...@@ -837,9 +837,6 @@ mlxsw_thermal_gearboxes_init(struct device *dev, struct mlxsw_core *core, ...@@ -837,9 +837,6 @@ mlxsw_thermal_gearboxes_init(struct device *dev, struct mlxsw_core *core,
int i; int i;
int err; int err;
if (!mlxsw_core_res_query_enabled(core))
return 0;
mlxsw_reg_mgpir_pack(mgpir_pl); mlxsw_reg_mgpir_pack(mgpir_pl);
err = mlxsw_reg_query(core, MLXSW_REG(mgpir), mgpir_pl); err = mlxsw_reg_query(core, MLXSW_REG(mgpir), mgpir_pl);
if (err) if (err)
...@@ -866,12 +863,12 @@ mlxsw_thermal_gearboxes_init(struct device *dev, struct mlxsw_core *core, ...@@ -866,12 +863,12 @@ mlxsw_thermal_gearboxes_init(struct device *dev, struct mlxsw_core *core,
gearbox_tz->parent = thermal; gearbox_tz->parent = thermal;
err = mlxsw_thermal_gearbox_tz_init(gearbox_tz); err = mlxsw_thermal_gearbox_tz_init(gearbox_tz);
if (err) if (err)
goto err_unreg_tz_gearbox; goto err_thermal_gearbox_tz_init;
} }
return 0; return 0;
err_unreg_tz_gearbox: err_thermal_gearbox_tz_init:
for (i--; i >= 0; i--) for (i--; i >= 0; i--)
mlxsw_thermal_gearbox_tz_fini(&thermal->tz_gearbox_arr[i]); mlxsw_thermal_gearbox_tz_fini(&thermal->tz_gearbox_arr[i]);
kfree(thermal->tz_gearbox_arr); kfree(thermal->tz_gearbox_arr);
...@@ -883,9 +880,6 @@ mlxsw_thermal_gearboxes_fini(struct mlxsw_thermal *thermal) ...@@ -883,9 +880,6 @@ mlxsw_thermal_gearboxes_fini(struct mlxsw_thermal *thermal)
{ {
int i; int i;
if (!mlxsw_core_res_query_enabled(thermal->core))
return;
for (i = thermal->tz_gearbox_num - 1; i >= 0; i--) for (i = thermal->tz_gearbox_num - 1; i >= 0; i--)
mlxsw_thermal_gearbox_tz_fini(&thermal->tz_gearbox_arr[i]); mlxsw_thermal_gearbox_tz_fini(&thermal->tz_gearbox_arr[i]);
kfree(thermal->tz_gearbox_arr); kfree(thermal->tz_gearbox_arr);
...@@ -915,7 +909,7 @@ int mlxsw_thermal_init(struct mlxsw_core *core, ...@@ -915,7 +909,7 @@ int mlxsw_thermal_init(struct mlxsw_core *core,
err = mlxsw_reg_query(thermal->core, MLXSW_REG(mfcr), mfcr_pl); err = mlxsw_reg_query(thermal->core, MLXSW_REG(mfcr), mfcr_pl);
if (err) { if (err) {
dev_err(dev, "Failed to probe PWMs\n"); dev_err(dev, "Failed to probe PWMs\n");
goto err_free_thermal; goto err_reg_query;
} }
mlxsw_reg_mfcr_unpack(mfcr_pl, &freq, &tacho_active, &pwm_active); mlxsw_reg_mfcr_unpack(mfcr_pl, &freq, &tacho_active, &pwm_active);
...@@ -929,14 +923,14 @@ int mlxsw_thermal_init(struct mlxsw_core *core, ...@@ -929,14 +923,14 @@ int mlxsw_thermal_init(struct mlxsw_core *core,
err = mlxsw_reg_query(thermal->core, MLXSW_REG(mfsl), err = mlxsw_reg_query(thermal->core, MLXSW_REG(mfsl),
mfsl_pl); mfsl_pl);
if (err) if (err)
goto err_free_thermal; goto err_reg_query;
/* set the minimal RPMs to 0 */ /* set the minimal RPMs to 0 */
mlxsw_reg_mfsl_tach_min_set(mfsl_pl, 0); mlxsw_reg_mfsl_tach_min_set(mfsl_pl, 0);
err = mlxsw_reg_write(thermal->core, MLXSW_REG(mfsl), err = mlxsw_reg_write(thermal->core, MLXSW_REG(mfsl),
mfsl_pl); mfsl_pl);
if (err) if (err)
goto err_free_thermal; goto err_reg_write;
} }
} }
for (i = 0; i < MLXSW_MFCR_PWMS_MAX; i++) { for (i = 0; i < MLXSW_MFCR_PWMS_MAX; i++) {
...@@ -949,7 +943,7 @@ int mlxsw_thermal_init(struct mlxsw_core *core, ...@@ -949,7 +943,7 @@ int mlxsw_thermal_init(struct mlxsw_core *core,
if (IS_ERR(cdev)) { if (IS_ERR(cdev)) {
err = PTR_ERR(cdev); err = PTR_ERR(cdev);
dev_err(dev, "Failed to register cooling device\n"); dev_err(dev, "Failed to register cooling device\n");
goto err_unreg_cdevs; goto err_thermal_cooling_device_register;
} }
thermal->cdevs[i] = cdev; thermal->cdevs[i] = cdev;
} }
...@@ -968,43 +962,45 @@ int mlxsw_thermal_init(struct mlxsw_core *core, ...@@ -968,43 +962,45 @@ int mlxsw_thermal_init(struct mlxsw_core *core,
MLXSW_THERMAL_TRIP_MASK, MLXSW_THERMAL_TRIP_MASK,
thermal, thermal,
&mlxsw_thermal_ops, &mlxsw_thermal_ops,
NULL, 0, &mlxsw_thermal_params, 0,
thermal->polling_delay); thermal->polling_delay);
if (IS_ERR(thermal->tzdev)) { if (IS_ERR(thermal->tzdev)) {
err = PTR_ERR(thermal->tzdev); err = PTR_ERR(thermal->tzdev);
dev_err(dev, "Failed to register thermal zone\n"); dev_err(dev, "Failed to register thermal zone\n");
goto err_unreg_cdevs; goto err_thermal_zone_device_register;
} }
err = mlxsw_thermal_modules_init(dev, core, thermal); err = mlxsw_thermal_modules_init(dev, core, thermal);
if (err) if (err)
goto err_unreg_tzdev; goto err_thermal_modules_init;
err = mlxsw_thermal_gearboxes_init(dev, core, thermal); err = mlxsw_thermal_gearboxes_init(dev, core, thermal);
if (err) if (err)
goto err_unreg_modules_tzdev; goto err_thermal_gearboxes_init;
err = thermal_zone_device_enable(thermal->tzdev); err = thermal_zone_device_enable(thermal->tzdev);
if (err) if (err)
goto err_unreg_gearboxes; goto err_thermal_zone_device_enable;
*p_thermal = thermal; *p_thermal = thermal;
return 0; return 0;
err_unreg_gearboxes: err_thermal_zone_device_enable:
mlxsw_thermal_gearboxes_fini(thermal); mlxsw_thermal_gearboxes_fini(thermal);
err_unreg_modules_tzdev: err_thermal_gearboxes_init:
mlxsw_thermal_modules_fini(thermal); mlxsw_thermal_modules_fini(thermal);
err_unreg_tzdev: err_thermal_modules_init:
if (thermal->tzdev) { if (thermal->tzdev) {
thermal_zone_device_unregister(thermal->tzdev); thermal_zone_device_unregister(thermal->tzdev);
thermal->tzdev = NULL; thermal->tzdev = NULL;
} }
err_unreg_cdevs: err_thermal_zone_device_register:
err_thermal_cooling_device_register:
for (i = 0; i < MLXSW_MFCR_PWMS_MAX; i++) for (i = 0; i < MLXSW_MFCR_PWMS_MAX; i++)
if (thermal->cdevs[i]) if (thermal->cdevs[i])
thermal_cooling_device_unregister(thermal->cdevs[i]); thermal_cooling_device_unregister(thermal->cdevs[i]);
err_free_thermal: err_reg_write:
err_reg_query:
devm_kfree(dev, thermal); devm_kfree(dev, thermal);
return err; return err;
} }
......
...@@ -461,7 +461,6 @@ static struct mlxsw_driver mlxsw_m_driver = { ...@@ -461,7 +461,6 @@ static struct mlxsw_driver mlxsw_m_driver = {
.init = mlxsw_m_init, .init = mlxsw_m_init,
.fini = mlxsw_m_fini, .fini = mlxsw_m_fini,
.profile = &mlxsw_m_config_profile, .profile = &mlxsw_m_config_profile,
.res_query_enabled = true,
}; };
static const struct i2c_device_id mlxsw_m_i2c_id[] = { static const struct i2c_device_id mlxsw_m_i2c_id[] = {
......
...@@ -10037,6 +10037,7 @@ enum mlxsw_reg_mcia_eeprom_module_info_id { ...@@ -10037,6 +10037,7 @@ enum mlxsw_reg_mcia_eeprom_module_info_id {
MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_QSFP_PLUS = 0x0D, MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_QSFP_PLUS = 0x0D,
MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_QSFP28 = 0x11, MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_QSFP28 = 0x11,
MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_QSFP_DD = 0x18, MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_QSFP_DD = 0x18,
MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_OSFP = 0x19,
}; };
enum mlxsw_reg_mcia_eeprom_module_info { enum mlxsw_reg_mcia_eeprom_module_info {
...@@ -11323,24 +11324,24 @@ enum mlxsw_reg_mgpir_device_type { ...@@ -11323,24 +11324,24 @@ enum mlxsw_reg_mgpir_device_type {
MLXSW_REG_MGPIR_DEVICE_TYPE_GEARBOX_DIE, MLXSW_REG_MGPIR_DEVICE_TYPE_GEARBOX_DIE,
}; };
/* device_type /* mgpir_device_type
* Access: RO * Access: RO
*/ */
MLXSW_ITEM32(reg, mgpir, device_type, 0x00, 24, 4); MLXSW_ITEM32(reg, mgpir, device_type, 0x00, 24, 4);
/* devices_per_flash /* mgpir_devices_per_flash
* Number of devices of device_type per flash (can be shared by few devices). * Number of devices of device_type per flash (can be shared by few devices).
* Access: RO * Access: RO
*/ */
MLXSW_ITEM32(reg, mgpir, devices_per_flash, 0x00, 16, 8); MLXSW_ITEM32(reg, mgpir, devices_per_flash, 0x00, 16, 8);
/* num_of_devices /* mgpir_num_of_devices
* Number of devices of device_type. * Number of devices of device_type.
* Access: RO * Access: RO
*/ */
MLXSW_ITEM32(reg, mgpir, num_of_devices, 0x00, 0, 8); MLXSW_ITEM32(reg, mgpir, num_of_devices, 0x00, 0, 8);
/* num_of_modules /* mgpir_num_of_modules
* Number of modules. * Number of modules.
* Access: RO * Access: RO
*/ */
......
...@@ -45,52 +45,49 @@ ...@@ -45,52 +45,49 @@
#include "spectrum_ptp.h" #include "spectrum_ptp.h"
#include "spectrum_trap.h" #include "spectrum_trap.h"
#define MLXSW_SP_FWREV_MINOR 2010
#define MLXSW_SP_FWREV_SUBMINOR 1006
#define MLXSW_SP1_FWREV_MAJOR 13 #define MLXSW_SP1_FWREV_MAJOR 13
#define MLXSW_SP1_FWREV_MINOR 2010
#define MLXSW_SP1_FWREV_SUBMINOR 1006
#define MLXSW_SP1_FWREV_CAN_RESET_MINOR 1702 #define MLXSW_SP1_FWREV_CAN_RESET_MINOR 1702
static const struct mlxsw_fw_rev mlxsw_sp1_fw_rev = { static const struct mlxsw_fw_rev mlxsw_sp1_fw_rev = {
.major = MLXSW_SP1_FWREV_MAJOR, .major = MLXSW_SP1_FWREV_MAJOR,
.minor = MLXSW_SP1_FWREV_MINOR, .minor = MLXSW_SP_FWREV_MINOR,
.subminor = MLXSW_SP1_FWREV_SUBMINOR, .subminor = MLXSW_SP_FWREV_SUBMINOR,
.can_reset_minor = MLXSW_SP1_FWREV_CAN_RESET_MINOR, .can_reset_minor = MLXSW_SP1_FWREV_CAN_RESET_MINOR,
}; };
#define MLXSW_SP1_FW_FILENAME \ #define MLXSW_SP1_FW_FILENAME \
"mellanox/mlxsw_spectrum-" __stringify(MLXSW_SP1_FWREV_MAJOR) \ "mellanox/mlxsw_spectrum-" __stringify(MLXSW_SP1_FWREV_MAJOR) \
"." __stringify(MLXSW_SP1_FWREV_MINOR) \ "." __stringify(MLXSW_SP_FWREV_MINOR) \
"." __stringify(MLXSW_SP1_FWREV_SUBMINOR) ".mfa2" "." __stringify(MLXSW_SP_FWREV_SUBMINOR) ".mfa2"
#define MLXSW_SP2_FWREV_MAJOR 29 #define MLXSW_SP2_FWREV_MAJOR 29
#define MLXSW_SP2_FWREV_MINOR 2010
#define MLXSW_SP2_FWREV_SUBMINOR 1006
static const struct mlxsw_fw_rev mlxsw_sp2_fw_rev = { static const struct mlxsw_fw_rev mlxsw_sp2_fw_rev = {
.major = MLXSW_SP2_FWREV_MAJOR, .major = MLXSW_SP2_FWREV_MAJOR,
.minor = MLXSW_SP2_FWREV_MINOR, .minor = MLXSW_SP_FWREV_MINOR,
.subminor = MLXSW_SP2_FWREV_SUBMINOR, .subminor = MLXSW_SP_FWREV_SUBMINOR,
}; };
#define MLXSW_SP2_FW_FILENAME \ #define MLXSW_SP2_FW_FILENAME \
"mellanox/mlxsw_spectrum2-" __stringify(MLXSW_SP2_FWREV_MAJOR) \ "mellanox/mlxsw_spectrum2-" __stringify(MLXSW_SP2_FWREV_MAJOR) \
"." __stringify(MLXSW_SP2_FWREV_MINOR) \ "." __stringify(MLXSW_SP_FWREV_MINOR) \
"." __stringify(MLXSW_SP2_FWREV_SUBMINOR) ".mfa2" "." __stringify(MLXSW_SP_FWREV_SUBMINOR) ".mfa2"
#define MLXSW_SP3_FWREV_MAJOR 30 #define MLXSW_SP3_FWREV_MAJOR 30
#define MLXSW_SP3_FWREV_MINOR 2010
#define MLXSW_SP3_FWREV_SUBMINOR 1006
static const struct mlxsw_fw_rev mlxsw_sp3_fw_rev = { static const struct mlxsw_fw_rev mlxsw_sp3_fw_rev = {
.major = MLXSW_SP3_FWREV_MAJOR, .major = MLXSW_SP3_FWREV_MAJOR,
.minor = MLXSW_SP3_FWREV_MINOR, .minor = MLXSW_SP_FWREV_MINOR,
.subminor = MLXSW_SP3_FWREV_SUBMINOR, .subminor = MLXSW_SP_FWREV_SUBMINOR,
}; };
#define MLXSW_SP3_FW_FILENAME \ #define MLXSW_SP3_FW_FILENAME \
"mellanox/mlxsw_spectrum3-" __stringify(MLXSW_SP3_FWREV_MAJOR) \ "mellanox/mlxsw_spectrum3-" __stringify(MLXSW_SP3_FWREV_MAJOR) \
"." __stringify(MLXSW_SP3_FWREV_MINOR) \ "." __stringify(MLXSW_SP_FWREV_MINOR) \
"." __stringify(MLXSW_SP3_FWREV_SUBMINOR) ".mfa2" "." __stringify(MLXSW_SP_FWREV_SUBMINOR) ".mfa2"
static const char mlxsw_sp1_driver_name[] = "mlxsw_spectrum"; static const char mlxsw_sp1_driver_name[] = "mlxsw_spectrum";
static const char mlxsw_sp2_driver_name[] = "mlxsw_spectrum2"; static const char mlxsw_sp2_driver_name[] = "mlxsw_spectrum2";
...@@ -3630,9 +3627,6 @@ static struct mlxsw_driver mlxsw_sp1_driver = { ...@@ -3630,9 +3627,6 @@ static struct mlxsw_driver mlxsw_sp1_driver = {
.ptp_transmitted = mlxsw_sp_ptp_transmitted, .ptp_transmitted = mlxsw_sp_ptp_transmitted,
.txhdr_len = MLXSW_TXHDR_LEN, .txhdr_len = MLXSW_TXHDR_LEN,
.profile = &mlxsw_sp1_config_profile, .profile = &mlxsw_sp1_config_profile,
.res_query_enabled = true,
.fw_fatal_enabled = true,
.temp_warn_enabled = true,
}; };
static struct mlxsw_driver mlxsw_sp2_driver = { static struct mlxsw_driver mlxsw_sp2_driver = {
...@@ -3670,9 +3664,6 @@ static struct mlxsw_driver mlxsw_sp2_driver = { ...@@ -3670,9 +3664,6 @@ static struct mlxsw_driver mlxsw_sp2_driver = {
.ptp_transmitted = mlxsw_sp_ptp_transmitted, .ptp_transmitted = mlxsw_sp_ptp_transmitted,
.txhdr_len = MLXSW_TXHDR_LEN, .txhdr_len = MLXSW_TXHDR_LEN,
.profile = &mlxsw_sp2_config_profile, .profile = &mlxsw_sp2_config_profile,
.res_query_enabled = true,
.fw_fatal_enabled = true,
.temp_warn_enabled = true,
}; };
static struct mlxsw_driver mlxsw_sp3_driver = { static struct mlxsw_driver mlxsw_sp3_driver = {
...@@ -3710,9 +3701,6 @@ static struct mlxsw_driver mlxsw_sp3_driver = { ...@@ -3710,9 +3701,6 @@ static struct mlxsw_driver mlxsw_sp3_driver = {
.ptp_transmitted = mlxsw_sp_ptp_transmitted, .ptp_transmitted = mlxsw_sp_ptp_transmitted,
.txhdr_len = MLXSW_TXHDR_LEN, .txhdr_len = MLXSW_TXHDR_LEN,
.profile = &mlxsw_sp2_config_profile, .profile = &mlxsw_sp2_config_profile,
.res_query_enabled = true,
.fw_fatal_enabled = true,
.temp_warn_enabled = true,
}; };
static struct mlxsw_driver mlxsw_sp4_driver = { static struct mlxsw_driver mlxsw_sp4_driver = {
...@@ -3748,9 +3736,6 @@ static struct mlxsw_driver mlxsw_sp4_driver = { ...@@ -3748,9 +3736,6 @@ static struct mlxsw_driver mlxsw_sp4_driver = {
.ptp_transmitted = mlxsw_sp_ptp_transmitted, .ptp_transmitted = mlxsw_sp_ptp_transmitted,
.txhdr_len = MLXSW_TXHDR_LEN, .txhdr_len = MLXSW_TXHDR_LEN,
.profile = &mlxsw_sp2_config_profile, .profile = &mlxsw_sp2_config_profile,
.res_query_enabled = true,
.fw_fatal_enabled = true,
.temp_warn_enabled = true,
}; };
bool mlxsw_sp_port_dev_check(const struct net_device *dev) bool mlxsw_sp_port_dev_check(const struct net_device *dev)
......
...@@ -269,7 +269,8 @@ mlxsw_sp_span_entry_bridge_8021q(const struct net_device *br_dev, ...@@ -269,7 +269,8 @@ mlxsw_sp_span_entry_bridge_8021q(const struct net_device *br_dev,
if (!vid && WARN_ON(br_vlan_get_pvid(br_dev, &vid))) if (!vid && WARN_ON(br_vlan_get_pvid(br_dev, &vid)))
return NULL; return NULL;
if (!vid || br_vlan_get_info(br_dev, vid, &vinfo)) if (!vid || br_vlan_get_info(br_dev, vid, &vinfo) ||
!(vinfo.flags & BRIDGE_VLAN_INFO_BRENTRY))
return NULL; return NULL;
edev = br_fdb_find_port(br_dev, dmac, vid); edev = br_fdb_find_port(br_dev, dmac, vid);
......
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