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

mlxsw: core: Reduce buffer size in transactions for SFP modules temperature readout

Obtain SFP modules temperatures through MTMP register instead of MTBR
register, because the first one utilizes shorter transaction buffer size
for request. It improves performance in case low frequency interface
(I2C) is used for communication with a chip.
Signed-off-by: default avatarVadim Pasternak <vadimp@mellanox.com>
Acked-by: default avatarJiri Pirko <jiri@mellanox.com>
Signed-off-by: default avatarIdo Schimmel <idosch@mellanox.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 984aec75
...@@ -92,34 +92,21 @@ int mlxsw_env_module_temp_thresholds_get(struct mlxsw_core *core, int module, ...@@ -92,34 +92,21 @@ int mlxsw_env_module_temp_thresholds_get(struct mlxsw_core *core, int module,
u16 temp; u16 temp;
} temp_thresh; } temp_thresh;
char mcia_pl[MLXSW_REG_MCIA_LEN] = {0}; char mcia_pl[MLXSW_REG_MCIA_LEN] = {0};
char mtbr_pl[MLXSW_REG_MTBR_LEN] = {0}; char mtmp_pl[MLXSW_REG_MTMP_LEN];
u16 module_temp; unsigned int module_temp;
bool qsfp; bool qsfp;
int err; int err;
mlxsw_reg_mtbr_pack(mtbr_pl, MLXSW_REG_MTBR_BASE_MODULE_INDEX + module, mlxsw_reg_mtmp_pack(mtmp_pl, MLXSW_REG_MTMP_MODULE_INDEX_MIN + module,
1); false, false);
err = mlxsw_reg_query(core, MLXSW_REG(mtbr), mtbr_pl); err = mlxsw_reg_query(core, MLXSW_REG(mtmp), mtmp_pl);
if (err) if (err)
return err; return err;
mlxsw_reg_mtmp_unpack(mtmp_pl, &module_temp, NULL, NULL);
/* Don't read temperature thresholds for module with no valid info. */ if (!module_temp) {
mlxsw_reg_mtbr_temp_unpack(mtbr_pl, 0, &module_temp, NULL);
switch (module_temp) {
case MLXSW_REG_MTBR_BAD_SENS_INFO: /* fall-through */
case MLXSW_REG_MTBR_NO_CONN: /* fall-through */
case MLXSW_REG_MTBR_NO_TEMP_SENS: /* fall-through */
case MLXSW_REG_MTBR_INDEX_NA:
*temp = 0;
return 0;
default:
/* Do not consider thresholds for zero temperature. */
if (MLXSW_REG_MTMP_TEMP_TO_MC(module_temp) == 0) {
*temp = 0; *temp = 0;
return 0; return 0;
} }
break;
}
/* Read Free Side Device Temperature Thresholds from page 03h /* Read Free Side Device Temperature Thresholds from page 03h
* (MSB at lower byte address). * (MSB at lower byte address).
......
...@@ -214,38 +214,18 @@ static ssize_t mlxsw_hwmon_module_temp_show(struct device *dev, ...@@ -214,38 +214,18 @@ static ssize_t mlxsw_hwmon_module_temp_show(struct device *dev,
struct mlxsw_hwmon_attr *mlwsw_hwmon_attr = struct mlxsw_hwmon_attr *mlwsw_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 = mlwsw_hwmon_attr->hwmon;
char mtbr_pl[MLXSW_REG_MTBR_LEN] = {0}; char mtmp_pl[MLXSW_REG_MTMP_LEN];
u16 temp; unsigned int temp;
u8 module; u8 module;
int err; int err;
module = mlwsw_hwmon_attr->type_index - mlxsw_hwmon->sensor_count; module = mlwsw_hwmon_attr->type_index - mlxsw_hwmon->sensor_count;
mlxsw_reg_mtbr_pack(mtbr_pl, MLXSW_REG_MTBR_BASE_MODULE_INDEX + module, mlxsw_reg_mtmp_pack(mtmp_pl, MLXSW_REG_MTMP_MODULE_INDEX_MIN + module,
1); false, false);
err = mlxsw_reg_query(mlxsw_hwmon->core, MLXSW_REG(mtbr), mtbr_pl); err = mlxsw_reg_query(mlxsw_hwmon->core, MLXSW_REG(mtmp), mtmp_pl);
if (err) { if (err)
dev_err(dev, "Failed to query module temperature sensor\n");
return err; return err;
} mlxsw_reg_mtmp_unpack(mtmp_pl, &temp, NULL, NULL);
mlxsw_reg_mtbr_temp_unpack(mtbr_pl, 0, &temp, NULL);
/* Update status and temperature cache. */
switch (temp) {
case MLXSW_REG_MTBR_NO_CONN: /* fall-through */
case MLXSW_REG_MTBR_NO_TEMP_SENS: /* fall-through */
case MLXSW_REG_MTBR_INDEX_NA:
temp = 0;
break;
case MLXSW_REG_MTBR_BAD_SENS_INFO:
/* Untrusted cable is connected. Reading temperature from its
* sensor is faulty.
*/
temp = 0;
break;
default:
temp = MLXSW_REG_MTMP_TEMP_TO_MC(temp);
break;
}
return sprintf(buf, "%u\n", temp); return sprintf(buf, "%u\n", temp);
} }
......
...@@ -449,39 +449,31 @@ static int mlxsw_thermal_module_temp_get(struct thermal_zone_device *tzdev, ...@@ -449,39 +449,31 @@ static int mlxsw_thermal_module_temp_get(struct thermal_zone_device *tzdev,
struct mlxsw_thermal_module *tz = tzdev->devdata; struct mlxsw_thermal_module *tz = tzdev->devdata;
struct mlxsw_thermal *thermal = tz->parent; struct mlxsw_thermal *thermal = tz->parent;
struct device *dev = thermal->bus_info->dev; struct device *dev = thermal->bus_info->dev;
char mtbr_pl[MLXSW_REG_MTBR_LEN]; char mtmp_pl[MLXSW_REG_MTMP_LEN];
u16 temp; unsigned int temp;
int err; int err;
/* Read module temperature. */ /* Read module temperature. */
mlxsw_reg_mtbr_pack(mtbr_pl, MLXSW_REG_MTBR_BASE_MODULE_INDEX + mlxsw_reg_mtmp_pack(mtmp_pl, MLXSW_REG_MTMP_MODULE_INDEX_MIN +
tz->module, 1); tz->module, false, false);
err = mlxsw_reg_query(thermal->core, MLXSW_REG(mtbr), mtbr_pl); err = mlxsw_reg_query(thermal->core, MLXSW_REG(mtmp), mtmp_pl);
if (err) if (err) {
return err; /* Do not return error - in case of broken module's sensor
* it will cause error message flooding.
mlxsw_reg_mtbr_temp_unpack(mtbr_pl, 0, &temp, NULL); */
/* Update temperature. */
switch (temp) {
case MLXSW_REG_MTBR_NO_CONN: /* fall-through */
case MLXSW_REG_MTBR_NO_TEMP_SENS: /* fall-through */
case MLXSW_REG_MTBR_INDEX_NA: /* fall-through */
case MLXSW_REG_MTBR_BAD_SENS_INFO:
temp = 0; temp = 0;
break; *p_temp = (int) temp;
default: return 0;
temp = MLXSW_REG_MTMP_TEMP_TO_MC(temp);
/* Reset all trip point. */
mlxsw_thermal_module_trips_reset(tz);
/* Update trip points. */
err = mlxsw_thermal_module_trips_update(dev, thermal->core,
tz);
if (err)
return err;
break;
} }
mlxsw_reg_mtmp_unpack(mtmp_pl, &temp, NULL, NULL);
*p_temp = (int) temp; *p_temp = (int) temp;
if (!temp)
return 0;
/* Update trip points. */
mlxsw_thermal_module_trips_update(dev, thermal->core, tz);
return 0; return 0;
} }
......
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