Skip to content

Commit d30bed2

Browse files
vadimp-nvidiakuba-moo
authored andcommitted
mlxsw: reg: Extend MTMP register with new slot number field
Extend MTMP (Management Temperature Register) with new field specifying the slot index. The purpose of this field is to support access to MTMP register for reading temperature sensors on modular systems. For non-modular systems the 'sensor_index' uniquely identifies the cage sensors, while 'slot_index' is always 0. For modular systems the sensors are identified by: - 'slot_index', specifying the slot index, where line card is located; - 'sensor_index', specifying cage sensor within the line card. Signed-off-by: Vadim Pasternak <[email protected]> Reviewed-by: Jiri Pirko <[email protected]> Signed-off-by: Ido Schimmel <[email protected]> Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 590032a commit d30bed2

File tree

4 files changed

+19
-11
lines changed

4 files changed

+19
-11
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ int mlxsw_env_module_temp_thresholds_get(struct mlxsw_core *core, int module,
177177
int page;
178178
int err;
179179

180-
mlxsw_reg_mtmp_pack(mtmp_pl, MLXSW_REG_MTMP_MODULE_INDEX_MIN + module,
180+
mlxsw_reg_mtmp_pack(mtmp_pl, 0, MLXSW_REG_MTMP_MODULE_INDEX_MIN + module,
181181
false, false);
182182
err = mlxsw_reg_query(core, MLXSW_REG(mtmp), mtmp_pl);
183183
if (err)

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

+6-5
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ static ssize_t mlxsw_hwmon_temp_show(struct device *dev,
6666

6767
index = mlxsw_hwmon_get_attr_index(mlxsw_hwmon_attr->type_index,
6868
mlxsw_hwmon->module_sensor_max);
69-
mlxsw_reg_mtmp_pack(mtmp_pl, index, false, false);
69+
mlxsw_reg_mtmp_pack(mtmp_pl, 0, index, false, false);
7070
err = mlxsw_reg_query(mlxsw_hwmon->core, MLXSW_REG(mtmp), mtmp_pl);
7171
if (err) {
7272
dev_err(mlxsw_hwmon->bus_info->dev, "Failed to query temp sensor\n");
@@ -89,7 +89,7 @@ static ssize_t mlxsw_hwmon_temp_max_show(struct device *dev,
8989

9090
index = mlxsw_hwmon_get_attr_index(mlxsw_hwmon_attr->type_index,
9191
mlxsw_hwmon->module_sensor_max);
92-
mlxsw_reg_mtmp_pack(mtmp_pl, index, false, false);
92+
mlxsw_reg_mtmp_pack(mtmp_pl, 0, index, false, false);
9393
err = mlxsw_reg_query(mlxsw_hwmon->core, MLXSW_REG(mtmp), mtmp_pl);
9494
if (err) {
9595
dev_err(mlxsw_hwmon->bus_info->dev, "Failed to query temp sensor\n");
@@ -232,8 +232,9 @@ static int mlxsw_hwmon_module_temp_get(struct device *dev,
232232
int err;
233233

234234
module = mlxsw_hwmon_attr->type_index - mlxsw_hwmon->sensor_count;
235-
mlxsw_reg_mtmp_pack(mtmp_pl, MLXSW_REG_MTMP_MODULE_INDEX_MIN + module,
236-
false, false);
235+
mlxsw_reg_mtmp_pack(mtmp_pl, 0,
236+
MLXSW_REG_MTMP_MODULE_INDEX_MIN + module, false,
237+
false);
237238
err = mlxsw_reg_query(mlxsw_hwmon->core, MLXSW_REG(mtmp), mtmp_pl);
238239
if (err) {
239240
dev_err(dev, "Failed to query module temperature\n");
@@ -721,7 +722,7 @@ static int mlxsw_hwmon_gearbox_init(struct mlxsw_hwmon *mlxsw_hwmon)
721722
while (index < max_index) {
722723
sensor_index = index % mlxsw_hwmon->module_sensor_max +
723724
MLXSW_REG_MTMP_GBOX_INDEX_MIN;
724-
mlxsw_reg_mtmp_pack(mtmp_pl, sensor_index, true, true);
725+
mlxsw_reg_mtmp_pack(mtmp_pl, 0, sensor_index, true, true);
725726
err = mlxsw_reg_write(mlxsw_hwmon->core,
726727
MLXSW_REG(mtmp), mtmp_pl);
727728
if (err) {

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ static int mlxsw_thermal_get_temp(struct thermal_zone_device *tzdev,
271271
int temp;
272272
int err;
273273

274-
mlxsw_reg_mtmp_pack(mtmp_pl, 0, false, false);
274+
mlxsw_reg_mtmp_pack(mtmp_pl, 0, 0, false, false);
275275

276276
err = mlxsw_reg_query(thermal->core, MLXSW_REG(mtmp), mtmp_pl);
277277
if (err) {
@@ -431,7 +431,7 @@ mlxsw_thermal_module_temp_and_thresholds_get(struct mlxsw_core *core,
431431
int err;
432432

433433
/* Read module temperature and thresholds. */
434-
mlxsw_reg_mtmp_pack(mtmp_pl, sensor_index, false, false);
434+
mlxsw_reg_mtmp_pack(mtmp_pl, 0, sensor_index, false, false);
435435
err = mlxsw_reg_query(core, MLXSW_REG(mtmp), mtmp_pl);
436436
if (err) {
437437
/* Set temperature and thresholds to zero to avoid passing
@@ -576,7 +576,7 @@ static int mlxsw_thermal_gearbox_temp_get(struct thermal_zone_device *tzdev,
576576
int err;
577577

578578
index = MLXSW_REG_MTMP_GBOX_INDEX_MIN + tz->module;
579-
mlxsw_reg_mtmp_pack(mtmp_pl, index, false, false);
579+
mlxsw_reg_mtmp_pack(mtmp_pl, 0, index, false, false);
580580

581581
err = mlxsw_reg_query(thermal->core, MLXSW_REG(mtmp), mtmp_pl);
582582
if (err)

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

+9-2
Original file line numberDiff line numberDiff line change
@@ -9721,6 +9721,12 @@ MLXSW_ITEM32(reg, mtcap, sensor_count, 0x00, 0, 7);
97219721

97229722
MLXSW_REG_DEFINE(mtmp, MLXSW_REG_MTMP_ID, MLXSW_REG_MTMP_LEN);
97239723

9724+
/* reg_mtmp_slot_index
9725+
* Slot index (0: Main board).
9726+
* Access: Index
9727+
*/
9728+
MLXSW_ITEM32(reg, mtmp, slot_index, 0x00, 16, 4);
9729+
97249730
#define MLXSW_REG_MTMP_MODULE_INDEX_MIN 64
97259731
#define MLXSW_REG_MTMP_GBOX_INDEX_MIN 256
97269732
/* reg_mtmp_sensor_index
@@ -9810,11 +9816,12 @@ MLXSW_ITEM32(reg, mtmp, temperature_threshold_lo, 0x10, 0, 16);
98109816
*/
98119817
MLXSW_ITEM_BUF(reg, mtmp, sensor_name, 0x18, MLXSW_REG_MTMP_SENSOR_NAME_SIZE);
98129818

9813-
static inline void mlxsw_reg_mtmp_pack(char *payload, u16 sensor_index,
9814-
bool max_temp_enable,
9819+
static inline void mlxsw_reg_mtmp_pack(char *payload, u8 slot_index,
9820+
u16 sensor_index, bool max_temp_enable,
98159821
bool max_temp_reset)
98169822
{
98179823
MLXSW_REG_ZERO(mtmp, payload);
9824+
mlxsw_reg_mtmp_slot_index_set(payload, slot_index);
98189825
mlxsw_reg_mtmp_sensor_index_set(payload, sensor_index);
98199826
mlxsw_reg_mtmp_mte_set(payload, max_temp_enable);
98209827
mlxsw_reg_mtmp_mtr_set(payload, max_temp_reset);

0 commit comments

Comments
 (0)