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: Vadim Pasternak <vadimp@mellanox.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Vadim Pasternak 2019-05-29 11:47:22 +03:00 committed by David S. Miller
parent 984aec7521
commit e4e93d6d86
3 changed files with 33 additions and 74 deletions

View File

@ -92,33 +92,20 @@ int mlxsw_env_module_temp_thresholds_get(struct mlxsw_core *core, int module,
u16 temp;
} temp_thresh;
char mcia_pl[MLXSW_REG_MCIA_LEN] = {0};
char mtbr_pl[MLXSW_REG_MTBR_LEN] = {0};
u16 module_temp;
char mtmp_pl[MLXSW_REG_MTMP_LEN];
unsigned int module_temp;
bool qsfp;
int err;
mlxsw_reg_mtbr_pack(mtbr_pl, MLXSW_REG_MTBR_BASE_MODULE_INDEX + module,
1);
err = mlxsw_reg_query(core, MLXSW_REG(mtbr), mtbr_pl);
mlxsw_reg_mtmp_pack(mtmp_pl, MLXSW_REG_MTMP_MODULE_INDEX_MIN + module,
false, false);
err = mlxsw_reg_query(core, MLXSW_REG(mtmp), mtmp_pl);
if (err)
return err;
/* Don't read temperature thresholds for module with no valid info. */
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:
mlxsw_reg_mtmp_unpack(mtmp_pl, &module_temp, NULL, NULL);
if (!module_temp) {
*temp = 0;
return 0;
default:
/* Do not consider thresholds for zero temperature. */
if (MLXSW_REG_MTMP_TEMP_TO_MC(module_temp) == 0) {
*temp = 0;
return 0;
}
break;
}
/* Read Free Side Device Temperature Thresholds from page 03h

View File

@ -214,38 +214,18 @@ static ssize_t mlxsw_hwmon_module_temp_show(struct device *dev,
struct mlxsw_hwmon_attr *mlwsw_hwmon_attr =
container_of(attr, struct mlxsw_hwmon_attr, dev_attr);
struct mlxsw_hwmon *mlxsw_hwmon = mlwsw_hwmon_attr->hwmon;
char mtbr_pl[MLXSW_REG_MTBR_LEN] = {0};
u16 temp;
char mtmp_pl[MLXSW_REG_MTMP_LEN];
unsigned int temp;
u8 module;
int err;
module = mlwsw_hwmon_attr->type_index - mlxsw_hwmon->sensor_count;
mlxsw_reg_mtbr_pack(mtbr_pl, MLXSW_REG_MTBR_BASE_MODULE_INDEX + module,
1);
err = mlxsw_reg_query(mlxsw_hwmon->core, MLXSW_REG(mtbr), mtbr_pl);
if (err) {
dev_err(dev, "Failed to query module temperature sensor\n");
mlxsw_reg_mtmp_pack(mtmp_pl, MLXSW_REG_MTMP_MODULE_INDEX_MIN + module,
false, false);
err = mlxsw_reg_query(mlxsw_hwmon->core, MLXSW_REG(mtmp), mtmp_pl);
if (err)
return err;
}
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;
}
mlxsw_reg_mtmp_unpack(mtmp_pl, &temp, NULL, NULL);
return sprintf(buf, "%u\n", temp);
}

View File

@ -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 *thermal = tz->parent;
struct device *dev = thermal->bus_info->dev;
char mtbr_pl[MLXSW_REG_MTBR_LEN];
u16 temp;
char mtmp_pl[MLXSW_REG_MTMP_LEN];
unsigned int temp;
int err;
/* Read module temperature. */
mlxsw_reg_mtbr_pack(mtbr_pl, MLXSW_REG_MTBR_BASE_MODULE_INDEX +
tz->module, 1);
err = mlxsw_reg_query(thermal->core, MLXSW_REG(mtbr), mtbr_pl);
if (err)
return err;
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:
mlxsw_reg_mtmp_pack(mtmp_pl, MLXSW_REG_MTMP_MODULE_INDEX_MIN +
tz->module, false, false);
err = mlxsw_reg_query(thermal->core, MLXSW_REG(mtmp), mtmp_pl);
if (err) {
/* Do not return error - in case of broken module's sensor
* it will cause error message flooding.
*/
temp = 0;
break;
default:
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;
*p_temp = (int) temp;
return 0;
}
mlxsw_reg_mtmp_unpack(mtmp_pl, &temp, NULL, NULL);
*p_temp = (int) temp;
if (!temp)
return 0;
/* Update trip points. */
mlxsw_thermal_module_trips_update(dev, thermal->core, tz);
return 0;
}