Skip to content

Commit 79e0882

Browse files
committed
Merge branch 'mlxsw-hwmon-and-thermal-extensions'
Ido Schimmel says: ==================== mlxsw: hwmon and thermal extensions Vadim says: This patchset contains various improvements to hwmon and thermal code in mlxsw. The most significant improvement is the ability to read modules' temperature attributes (input, fault, critical and emergency thresholds) as well as fans' fault indication. These new attributes will improve the ability to monitor the system. Patches #1-#4 add the necessary device registers and APIs to read modules' temperature attributes and fans' fault indication. Patches #5-torvalds#8 perform small improvements in hwmon and thermal code such as using a more indicative name for cooling devices. Patch torvalds#9 exposes fans' fault indication via hwmon. Patch torvalds#10 exposes modules' temperature attributes via hwmon. Patch torvalds#11 adds an hwmon label to modules' temperature sensor. This helps to parse the output of utilities such as "sensors". Patch torvalds#12 allows to bind an external cooling device ("mlxreg-fan") to mlxsw thermal zone. This will allow the mlxsw thermal zone to change the cooling level of cooling devices not programmed via switch registers. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 03b9674 + 97cd342 commit 79e0882

File tree

9 files changed

+617
-65
lines changed

9 files changed

+617
-65
lines changed

drivers/net/ethernet/mellanox/mlxsw/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# SPDX-License-Identifier: GPL-2.0
22
obj-$(CONFIG_MLXSW_CORE) += mlxsw_core.o
33
mlxsw_core-objs := core.o core_acl_flex_keys.o \
4-
core_acl_flex_actions.o
4+
core_acl_flex_actions.o core_env.o
55
mlxsw_core-$(CONFIG_MLXSW_CORE_HWMON) += core_hwmon.o
66
mlxsw_core-$(CONFIG_MLXSW_CORE_THERMAL) += core_thermal.o
77
obj-$(CONFIG_MLXSW_PCI) += mlxsw_pci.o

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,7 @@ struct mlxsw_bus_info {
344344
struct mlxsw_fw_rev fw_rev;
345345
u8 vsd[MLXSW_CMD_BOARDINFO_VSD_LEN];
346346
u8 psid[MLXSW_CMD_BOARDINFO_PSID_LEN];
347+
u8 low_frequency;
347348
};
348349

349350
struct mlxsw_hwmon;
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
// SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0
2+
/* Copyright (c) 2018 Mellanox Technologies. All rights reserved */
3+
4+
#include <linux/kernel.h>
5+
#include <linux/err.h>
6+
7+
#include "core.h"
8+
#include "core_env.h"
9+
#include "item.h"
10+
#include "reg.h"
11+
12+
static int mlxsw_env_validate_cable_ident(struct mlxsw_core *core, int id,
13+
bool *qsfp)
14+
{
15+
char eeprom_tmp[MLXSW_REG_MCIA_EEPROM_SIZE];
16+
char mcia_pl[MLXSW_REG_MCIA_LEN];
17+
u8 ident;
18+
int err;
19+
20+
mlxsw_reg_mcia_pack(mcia_pl, id, 0, MLXSW_REG_MCIA_PAGE0_LO_OFF, 0, 1,
21+
MLXSW_REG_MCIA_I2C_ADDR_LOW);
22+
err = mlxsw_reg_query(core, MLXSW_REG(mcia), mcia_pl);
23+
if (err)
24+
return err;
25+
mlxsw_reg_mcia_eeprom_memcpy_from(mcia_pl, eeprom_tmp);
26+
ident = eeprom_tmp[0];
27+
switch (ident) {
28+
case MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_SFP:
29+
*qsfp = false;
30+
break;
31+
case MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_QSFP: /* fall-through */
32+
case MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_QSFP_PLUS: /* fall-through */
33+
case MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_QSFP28: /* fall-through */
34+
case MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_QSFP_DD:
35+
*qsfp = true;
36+
break;
37+
default:
38+
return -EINVAL;
39+
}
40+
41+
return 0;
42+
}
43+
44+
int mlxsw_env_module_temp_thresholds_get(struct mlxsw_core *core, int module,
45+
int off, int *temp)
46+
{
47+
char eeprom_tmp[MLXSW_REG_MCIA_EEPROM_SIZE];
48+
union {
49+
u8 buf[MLXSW_REG_MCIA_TH_ITEM_SIZE];
50+
u16 temp;
51+
} temp_thresh;
52+
char mcia_pl[MLXSW_REG_MCIA_LEN] = {0};
53+
char mtbr_pl[MLXSW_REG_MTBR_LEN] = {0};
54+
u16 module_temp;
55+
bool qsfp;
56+
int err;
57+
58+
mlxsw_reg_mtbr_pack(mtbr_pl, MLXSW_REG_MTBR_BASE_MODULE_INDEX + module,
59+
1);
60+
err = mlxsw_reg_query(core, MLXSW_REG(mtbr), mtbr_pl);
61+
if (err)
62+
return err;
63+
64+
/* Don't read temperature thresholds for module with no valid info. */
65+
mlxsw_reg_mtbr_temp_unpack(mtbr_pl, 0, &module_temp, NULL);
66+
switch (module_temp) {
67+
case MLXSW_REG_MTBR_BAD_SENS_INFO: /* fall-through */
68+
case MLXSW_REG_MTBR_NO_CONN: /* fall-through */
69+
case MLXSW_REG_MTBR_NO_TEMP_SENS: /* fall-through */
70+
case MLXSW_REG_MTBR_INDEX_NA:
71+
*temp = 0;
72+
return 0;
73+
default:
74+
/* Do not consider thresholds for zero temperature. */
75+
if (!MLXSW_REG_MTMP_TEMP_TO_MC(module_temp)) {
76+
*temp = 0;
77+
return 0;
78+
}
79+
break;
80+
}
81+
82+
/* Read Free Side Device Temperature Thresholds from page 03h
83+
* (MSB at lower byte address).
84+
* Bytes:
85+
* 128-129 - Temp High Alarm (SFP_TEMP_HIGH_ALARM);
86+
* 130-131 - Temp Low Alarm (SFP_TEMP_LOW_ALARM);
87+
* 132-133 - Temp High Warning (SFP_TEMP_HIGH_WARN);
88+
* 134-135 - Temp Low Warning (SFP_TEMP_LOW_WARN);
89+
*/
90+
91+
/* Validate module identifier value. */
92+
err = mlxsw_env_validate_cable_ident(core, module, &qsfp);
93+
if (err)
94+
return err;
95+
96+
if (qsfp)
97+
mlxsw_reg_mcia_pack(mcia_pl, module, 0,
98+
MLXSW_REG_MCIA_TH_PAGE_NUM,
99+
MLXSW_REG_MCIA_TH_PAGE_OFF + off,
100+
MLXSW_REG_MCIA_TH_ITEM_SIZE,
101+
MLXSW_REG_MCIA_I2C_ADDR_LOW);
102+
else
103+
mlxsw_reg_mcia_pack(mcia_pl, module, 0,
104+
MLXSW_REG_MCIA_PAGE0_LO,
105+
off, MLXSW_REG_MCIA_TH_ITEM_SIZE,
106+
MLXSW_REG_MCIA_I2C_ADDR_HIGH);
107+
108+
err = mlxsw_reg_query(core, MLXSW_REG(mcia), mcia_pl);
109+
if (err)
110+
return err;
111+
112+
mlxsw_reg_mcia_eeprom_memcpy_from(mcia_pl, eeprom_tmp);
113+
memcpy(temp_thresh.buf, eeprom_tmp, MLXSW_REG_MCIA_TH_ITEM_SIZE);
114+
*temp = temp_thresh.temp * 1000;
115+
116+
return 0;
117+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/* SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0 */
2+
/* Copyright (c) 2018 Mellanox Technologies. All rights reserved */
3+
4+
#ifndef _MLXSW_CORE_ENV_H
5+
#define _MLXSW_CORE_ENV_H
6+
7+
int mlxsw_env_module_temp_thresholds_get(struct mlxsw_core *core, int module,
8+
int off, int *temp);
9+
10+
#endif

0 commit comments

Comments
 (0)