mlxsw: reg: Extend MTBR register with new slot number field
authorVadim Pasternak <vadimp@nvidia.com>
Mon, 11 Apr 2022 14:46:51 +0000 (17:46 +0300)
committerJakub Kicinski <kuba@kernel.org>
Tue, 12 Apr 2022 16:51:38 +0000 (09:51 -0700)
Extend MTBR (Management Temperature Bulk Register) with new field
specifying the slot number. The purpose of this field is to support
access to MTBR register for reading temperature sensors on modular
system. For non-modular systems the 'sensor_index' uniquely identifies
the cage sensors. For modular systems the sensors are identified by two
indexes:
- 'slot_index', specifying the slot number, where line card is located;
- 'sensor_index', specifying cage sensor within the line card.

Signed-off-by: Vadim Pasternak <vadimp@nvidia.com>
Reviewed-by: Jiri Pirko <jiri@nvidia.com>
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/mellanox/mlxsw/core_env.c
drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c
drivers/net/ethernet/mellanox/mlxsw/reg.h

index 3103fef..0c1306d 100644 (file)
@@ -660,8 +660,8 @@ static int mlxsw_env_module_has_temp_sensor(struct mlxsw_core *mlxsw_core,
        u16 temp;
        int err;
 
-       mlxsw_reg_mtbr_pack(mtbr_pl, MLXSW_REG_MTBR_BASE_MODULE_INDEX + module,
-                           1);
+       mlxsw_reg_mtbr_pack(mtbr_pl, 0,
+                           MLXSW_REG_MTBR_BASE_MODULE_INDEX + module, 1);
        err = mlxsw_reg_query(mlxsw_core, MLXSW_REG(mtbr), mtbr_pl);
        if (err)
                return err;
index 71ca3b5..f4bc711 100644 (file)
@@ -271,8 +271,8 @@ static ssize_t mlxsw_hwmon_module_temp_fault_show(struct device *dev,
        int err;
 
        module = mlxsw_hwmon_attr->type_index - mlxsw_hwmon->sensor_count;
-       mlxsw_reg_mtbr_pack(mtbr_pl, MLXSW_REG_MTBR_BASE_MODULE_INDEX + module,
-                           1);
+       mlxsw_reg_mtbr_pack(mtbr_pl, 0,
+                           MLXSW_REG_MTBR_BASE_MODULE_INDEX + module, 1);
        err = mlxsw_reg_query(mlxsw_hwmon->core, MLXSW_REG(mtbr), mtbr_pl);
        if (err) {
                dev_err(dev, "Failed to query module temperature sensor\n");
index 5de77d6..958df69 100644 (file)
@@ -9887,6 +9887,12 @@ MLXSW_ITEM_BIT_ARRAY(reg, mtwe, sensor_warning, 0x0, 0x10, 1);
 
 MLXSW_REG_DEFINE(mtbr, MLXSW_REG_MTBR_ID, MLXSW_REG_MTBR_LEN);
 
+/* reg_mtbr_slot_index
+ * Slot index (0: Main board).
+ * Access: Index
+ */
+MLXSW_ITEM32(reg, mtbr, slot_index, 0x00, 16, 4);
+
 /* reg_mtbr_base_sensor_index
  * Base sensors index to access (0 - ASIC sensor, 1-63 - ambient sensors,
  * 64-127 are mapped to the SFP+/QSFP modules sequentially).
@@ -9919,10 +9925,11 @@ MLXSW_ITEM32_INDEXED(reg, mtbr, rec_max_temp, MLXSW_REG_MTBR_BASE_LEN, 16,
 MLXSW_ITEM32_INDEXED(reg, mtbr, rec_temp, MLXSW_REG_MTBR_BASE_LEN, 0, 16,
                     MLXSW_REG_MTBR_REC_LEN, 0x00, false);
 
-static inline void mlxsw_reg_mtbr_pack(char *payload, u16 base_sensor_index,
-                                      u8 num_rec)
+static inline void mlxsw_reg_mtbr_pack(char *payload, u8 slot_index,
+                                      u16 base_sensor_index, u8 num_rec)
 {
        MLXSW_REG_ZERO(mtbr, payload);
+       mlxsw_reg_mtbr_slot_index_set(payload, slot_index);
        mlxsw_reg_mtbr_base_sensor_index_set(payload, base_sensor_index);
        mlxsw_reg_mtbr_num_rec_set(payload, num_rec);
 }