Skip to content

Commit 314dbb1

Browse files
odmykodavem330
authored andcommitted
mlxsw: reg: Extend MTMP register with new threshold field
Extend Management Temperature (MTMP) register with new field specifying the maximum temperature threshold. Extend mlxsw_reg_mtmp_unpack() function with two extra arguments, providing high and maximum temperature thresholds. For modules, these thresholds correspond to critical and emergency thresholds that are read from the module's EEPROM. Signed-off-by: Mykola Kostenok <[email protected]> Acked-by: Vadim Pasternak <[email protected]> Signed-off-by: Ido Schimmel <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 0521a26 commit 314dbb1

File tree

4 files changed

+26
-8
lines changed

4 files changed

+26
-8
lines changed

drivers/net/ethernet/mellanox/mlxsw/core_env.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ int mlxsw_env_module_temp_thresholds_get(struct mlxsw_core *core, int module,
142142
err = mlxsw_reg_query(core, MLXSW_REG(mtmp), mtmp_pl);
143143
if (err)
144144
return err;
145-
mlxsw_reg_mtmp_unpack(mtmp_pl, &module_temp, NULL, NULL);
145+
mlxsw_reg_mtmp_unpack(mtmp_pl, &module_temp, NULL, NULL, NULL, NULL);
146146
if (!module_temp) {
147147
*temp = 0;
148148
return 0;

drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ static ssize_t mlxsw_hwmon_temp_show(struct device *dev,
7272
dev_err(mlxsw_hwmon->bus_info->dev, "Failed to query temp sensor\n");
7373
return err;
7474
}
75-
mlxsw_reg_mtmp_unpack(mtmp_pl, &temp, NULL, NULL);
75+
mlxsw_reg_mtmp_unpack(mtmp_pl, &temp, NULL, NULL, NULL, NULL);
7676
return sprintf(buf, "%d\n", temp);
7777
}
7878

@@ -95,7 +95,7 @@ static ssize_t mlxsw_hwmon_temp_max_show(struct device *dev,
9595
dev_err(mlxsw_hwmon->bus_info->dev, "Failed to query temp sensor\n");
9696
return err;
9797
}
98-
mlxsw_reg_mtmp_unpack(mtmp_pl, NULL, &temp_max, NULL);
98+
mlxsw_reg_mtmp_unpack(mtmp_pl, NULL, &temp_max, NULL, NULL, NULL);
9999
return sprintf(buf, "%d\n", temp_max);
100100
}
101101

@@ -239,7 +239,7 @@ static int mlxsw_hwmon_module_temp_get(struct device *dev,
239239
dev_err(dev, "Failed to query module temperature\n");
240240
return err;
241241
}
242-
mlxsw_reg_mtmp_unpack(mtmp_pl, p_temp, NULL, NULL);
242+
mlxsw_reg_mtmp_unpack(mtmp_pl, p_temp, NULL, NULL, NULL, NULL);
243243

244244
return 0;
245245
}

drivers/net/ethernet/mellanox/mlxsw/core_thermal.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ static int mlxsw_thermal_get_temp(struct thermal_zone_device *tzdev,
281281
dev_err(dev, "Failed to query temp sensor\n");
282282
return err;
283283
}
284-
mlxsw_reg_mtmp_unpack(mtmp_pl, &temp, NULL, NULL);
284+
mlxsw_reg_mtmp_unpack(mtmp_pl, &temp, NULL, NULL, NULL, NULL);
285285
if (temp > 0)
286286
mlxsw_thermal_tz_score_update(thermal, tzdev, thermal->trips,
287287
temp);
@@ -442,7 +442,7 @@ static int mlxsw_thermal_module_temp_get(struct thermal_zone_device *tzdev,
442442
*p_temp = (int) temp;
443443
return 0;
444444
}
445-
mlxsw_reg_mtmp_unpack(mtmp_pl, &temp, NULL, NULL);
445+
mlxsw_reg_mtmp_unpack(mtmp_pl, &temp, NULL, NULL, NULL, NULL);
446446
*p_temp = temp;
447447

448448
if (!temp)
@@ -560,7 +560,7 @@ static int mlxsw_thermal_gearbox_temp_get(struct thermal_zone_device *tzdev,
560560
if (err)
561561
return err;
562562

563-
mlxsw_reg_mtmp_unpack(mtmp_pl, &temp, NULL, NULL);
563+
mlxsw_reg_mtmp_unpack(mtmp_pl, &temp, NULL, NULL, NULL, NULL);
564564
if (temp > 0)
565565
mlxsw_thermal_tz_score_update(thermal, tzdev, tz->trips, temp);
566566

drivers/net/ethernet/mellanox/mlxsw/reg.h

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9463,6 +9463,14 @@ MLXSW_ITEM32(reg, mtmp, sensor_index, 0x00, 0, 12);
94639463
((s16)((GENMASK(15, 0) + (v_) + 1) \
94649464
* 125)); })
94659465

9466+
/* reg_mtmp_max_operational_temperature
9467+
* The highest temperature in the nominal operational range. Reading is in
9468+
* 0.125 Celsius degrees units.
9469+
* In case of module this is SFF critical temperature threshold.
9470+
* Access: RO
9471+
*/
9472+
MLXSW_ITEM32(reg, mtmp, max_operational_temperature, 0x04, 16, 16);
9473+
94669474
/* reg_mtmp_temperature
94679475
* Temperature reading from the sensor. Reading is in 0.125 Celsius
94689476
* degrees units.
@@ -9541,7 +9549,9 @@ static inline void mlxsw_reg_mtmp_pack(char *payload, u16 sensor_index,
95419549
}
95429550

95439551
static inline void mlxsw_reg_mtmp_unpack(char *payload, int *p_temp,
9544-
int *p_max_temp, char *sensor_name)
9552+
int *p_max_temp, int *p_temp_hi,
9553+
int *p_max_oper_temp,
9554+
char *sensor_name)
95459555
{
95469556
s16 temp;
95479557

@@ -9553,6 +9563,14 @@ static inline void mlxsw_reg_mtmp_unpack(char *payload, int *p_temp,
95539563
temp = mlxsw_reg_mtmp_max_temperature_get(payload);
95549564
*p_max_temp = MLXSW_REG_MTMP_TEMP_TO_MC(temp);
95559565
}
9566+
if (p_temp_hi) {
9567+
temp = mlxsw_reg_mtmp_temperature_threshold_hi_get(payload);
9568+
*p_temp_hi = MLXSW_REG_MTMP_TEMP_TO_MC(temp);
9569+
}
9570+
if (p_max_oper_temp) {
9571+
temp = mlxsw_reg_mtmp_max_operational_temperature_get(payload);
9572+
*p_max_oper_temp = MLXSW_REG_MTMP_TEMP_TO_MC(temp);
9573+
}
95569574
if (sensor_name)
95579575
mlxsw_reg_mtmp_sensor_name_memcpy_from(payload, sensor_name);
95589576
}

0 commit comments

Comments
 (0)