Skip to content

Commit befc204

Browse files
odmykodavem330
authored andcommitted
mlxsw: core_env: Read module temperature thresholds using MTMP register
Currently, module temperature thresholds are obtained from Management Cable Info Access (MCIA) register by specifying the thresholds offsets within module EEPROM layout. This data does not pass validation and in some cases can be unreliable. For example, due to some problem with the module. Add support for a new feature provided by Management Temperature (MTMP) register for sanitization of temperature thresholds values. Extend mlxsw_env_module_temp_thresholds_get() to get temperature thresholds through MTMP field 'max_operational_temperature' - if it is not zero, feature is supported. Otherwise fallback to old method and get the thresholds through MCIA. 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 314dbb1 commit befc204

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,14 +125,14 @@ mlxsw_env_query_module_eeprom(struct mlxsw_core *mlxsw_core, int module,
125125
int mlxsw_env_module_temp_thresholds_get(struct mlxsw_core *core, int module,
126126
int off, int *temp)
127127
{
128+
unsigned int module_temp, module_crit, module_emerg;
128129
char eeprom_tmp[MLXSW_REG_MCIA_EEPROM_SIZE];
129130
union {
130131
u8 buf[MLXSW_REG_MCIA_TH_ITEM_SIZE];
131132
u16 temp;
132133
} temp_thresh;
133134
char mcia_pl[MLXSW_REG_MCIA_LEN] = {0};
134135
char mtmp_pl[MLXSW_REG_MTMP_LEN];
135-
unsigned int module_temp;
136136
bool qsfp, cmis;
137137
int page;
138138
int err;
@@ -142,12 +142,21 @@ 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, NULL, NULL);
145+
mlxsw_reg_mtmp_unpack(mtmp_pl, &module_temp, NULL, &module_crit,
146+
&module_emerg, NULL);
146147
if (!module_temp) {
147148
*temp = 0;
148149
return 0;
149150
}
150151

152+
/* Validate if threshold reading is available through MTMP register,
153+
* otherwise fallback to read through MCIA.
154+
*/
155+
if (module_emerg) {
156+
*temp = off == SFP_TEMP_HIGH_WARN ? module_crit : module_emerg;
157+
return 0;
158+
}
159+
151160
/* Read Free Side Device Temperature Thresholds from page 03h
152161
* (MSB at lower byte address).
153162
* Bytes:

0 commit comments

Comments
 (0)