Skip to content

Commit f152b41

Browse files
mellanoxbmcdavem330
authored andcommitted
mlxsw: core: Add support for temperature thresholds reading for QSFP-DD transceivers
Allow QSFP-DD transceivers temperature thresholds reading for hardware monitoring and thermal control. For this type, the thresholds are located in page 02h according to the "Module and Lane Thresholds" description from Common Management Interface Specification. Signed-off-by: Vadim Pasternak <[email protected]> Signed-off-by: Ido Schimmel <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 6af496a commit f152b41

File tree

2 files changed

+23
-10
lines changed

2 files changed

+23
-10
lines changed

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

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#include "reg.h"
1212

1313
static int mlxsw_env_validate_cable_ident(struct mlxsw_core *core, int id,
14-
bool *qsfp)
14+
bool *qsfp, bool *cmis)
1515
{
1616
char eeprom_tmp[MLXSW_REG_MCIA_EEPROM_SIZE];
1717
char mcia_pl[MLXSW_REG_MCIA_LEN];
@@ -25,15 +25,19 @@ static int mlxsw_env_validate_cable_ident(struct mlxsw_core *core, int id,
2525
return err;
2626
mlxsw_reg_mcia_eeprom_memcpy_from(mcia_pl, eeprom_tmp);
2727
ident = eeprom_tmp[0];
28+
*cmis = false;
2829
switch (ident) {
2930
case MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_SFP:
3031
*qsfp = false;
3132
break;
3233
case MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_QSFP: /* fall-through */
3334
case MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_QSFP_PLUS: /* fall-through */
34-
case MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_QSFP28: /* fall-through */
35+
case MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_QSFP28:
36+
*qsfp = true;
37+
break;
3538
case MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_QSFP_DD:
3639
*qsfp = true;
40+
*cmis = true;
3741
break;
3842
default:
3943
return -EINVAL;
@@ -117,7 +121,8 @@ int mlxsw_env_module_temp_thresholds_get(struct mlxsw_core *core, int module,
117121
char mcia_pl[MLXSW_REG_MCIA_LEN] = {0};
118122
char mtmp_pl[MLXSW_REG_MTMP_LEN];
119123
unsigned int module_temp;
120-
bool qsfp;
124+
bool qsfp, cmis;
125+
int page;
121126
int err;
122127

123128
mlxsw_reg_mtmp_pack(mtmp_pl, MLXSW_REG_MTMP_MODULE_INDEX_MIN + module,
@@ -141,21 +146,28 @@ int mlxsw_env_module_temp_thresholds_get(struct mlxsw_core *core, int module,
141146
*/
142147

143148
/* Validate module identifier value. */
144-
err = mlxsw_env_validate_cable_ident(core, module, &qsfp);
149+
err = mlxsw_env_validate_cable_ident(core, module, &qsfp, &cmis);
145150
if (err)
146151
return err;
147152

148-
if (qsfp)
149-
mlxsw_reg_mcia_pack(mcia_pl, module, 0,
150-
MLXSW_REG_MCIA_TH_PAGE_NUM,
153+
if (qsfp) {
154+
/* For QSFP/CMIS module-defined thresholds are located in page
155+
* 02h, otherwise in page 03h.
156+
*/
157+
if (cmis)
158+
page = MLXSW_REG_MCIA_TH_PAGE_CMIS_NUM;
159+
else
160+
page = MLXSW_REG_MCIA_TH_PAGE_NUM;
161+
mlxsw_reg_mcia_pack(mcia_pl, module, 0, page,
151162
MLXSW_REG_MCIA_TH_PAGE_OFF + off,
152163
MLXSW_REG_MCIA_TH_ITEM_SIZE,
153164
MLXSW_REG_MCIA_I2C_ADDR_LOW);
154-
else
165+
} else {
155166
mlxsw_reg_mcia_pack(mcia_pl, module, 0,
156167
MLXSW_REG_MCIA_PAGE0_LO,
157168
off, MLXSW_REG_MCIA_TH_ITEM_SIZE,
158169
MLXSW_REG_MCIA_I2C_ADDR_HIGH);
170+
}
159171

160172
err = mlxsw_reg_query(core, MLXSW_REG(mcia), mcia_pl);
161173
if (err)
@@ -252,16 +264,16 @@ int mlxsw_env_get_module_eeprom(struct net_device *netdev,
252264
{
253265
int offset = ee->offset;
254266
unsigned int read_size;
267+
bool qsfp, cmis;
255268
int i = 0;
256-
bool qsfp;
257269
int err;
258270

259271
if (!ee->len)
260272
return -EINVAL;
261273

262274
memset(data, 0, ee->len);
263275
/* Validate module identifier value. */
264-
err = mlxsw_env_validate_cable_ident(mlxsw_core, module, &qsfp);
276+
err = mlxsw_env_validate_cable_ident(mlxsw_core, module, &qsfp, &cmis);
265277
if (err)
266278
return err;
267279

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8605,6 +8605,7 @@ MLXSW_ITEM32(reg, mcia, size, 0x08, 0, 16);
86058605
#define MLXSW_REG_MCIA_PAGE0_LO_OFF 0xa0
86068606
#define MLXSW_REG_MCIA_TH_ITEM_SIZE 2
86078607
#define MLXSW_REG_MCIA_TH_PAGE_NUM 3
8608+
#define MLXSW_REG_MCIA_TH_PAGE_CMIS_NUM 2
86088609
#define MLXSW_REG_MCIA_PAGE0_LO 0
86098610
#define MLXSW_REG_MCIA_TH_PAGE_OFF 0x80
86108611
#define MLXSW_REG_MCIA_EEPROM_CMIS_FLAT_MEMORY BIT(7)

0 commit comments

Comments
 (0)