mlxsw: reg: Extend MGPIR register with new slot fields
authorVadim Pasternak <vadimp@nvidia.com>
Mon, 11 Apr 2022 14:46:55 +0000 (17:46 +0300)
committerJakub Kicinski <kuba@kernel.org>
Tue, 12 Apr 2022 16:51:39 +0000 (09:51 -0700)
Extend MGPIR (Management General Peripheral Information Register) with
new fields specifying the slot number and number of the slots available
on system. The purpose of these fields is:
- to support access to MPGIR register on modular system for getting the
  number of cages, equipped on the line card, inserted at specified
  slot. In case slot number is set zero, MGPIR will provide the
  information for the main board. For Top of the Rack (non-modular)
  system it will provide the same as before.
- to provide the number of slots supported by system. This data is
  relevant only in case slot number is set zero.

Signed-off-by: Vadim Pasternak <vadimp@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/core_thermal.c
drivers/net/ethernet/mellanox/mlxsw/reg.h

index 8cee3e317a5bcce6d4c3d90fc48569126f534af7..8b4205c098d2969f54ae301bbf0ba7ff0d078ad0 100644 (file)
@@ -1060,12 +1060,12 @@ int mlxsw_env_init(struct mlxsw_core *mlxsw_core, struct mlxsw_env **p_env)
        u8 module_count;
        int i, err;
 
-       mlxsw_reg_mgpir_pack(mgpir_pl);
+       mlxsw_reg_mgpir_pack(mgpir_pl, 0);
        err = mlxsw_reg_query(mlxsw_core, MLXSW_REG(mgpir), mgpir_pl);
        if (err)
                return err;
 
-       mlxsw_reg_mgpir_unpack(mgpir_pl, NULL, NULL, NULL, &module_count);
+       mlxsw_reg_mgpir_unpack(mgpir_pl, NULL, NULL, NULL, &module_count, NULL);
 
        env = kzalloc(struct_size(env, module_info, module_count), GFP_KERNEL);
        if (!env)
index f4bc711a16cfbd52f94e91a59751007bfc36751f..2bc4c45568956315b4c22d4c28207f6674107be6 100644 (file)
@@ -656,13 +656,13 @@ static int mlxsw_hwmon_module_init(struct mlxsw_hwmon *mlxsw_hwmon)
        u8 module_sensor_max;
        int i, err;
 
-       mlxsw_reg_mgpir_pack(mgpir_pl);
+       mlxsw_reg_mgpir_pack(mgpir_pl, 0);
        err = mlxsw_reg_query(mlxsw_hwmon->core, MLXSW_REG(mgpir), mgpir_pl);
        if (err)
                return err;
 
        mlxsw_reg_mgpir_unpack(mgpir_pl, NULL, NULL, NULL,
-                              &module_sensor_max);
+                              &module_sensor_max, NULL);
 
        /* Add extra attributes for module temperature. Sensor index is
         * assigned to sensor_count value, while all indexed before
@@ -707,12 +707,13 @@ static int mlxsw_hwmon_gearbox_init(struct mlxsw_hwmon *mlxsw_hwmon)
        u8 gbox_num;
        int err;
 
-       mlxsw_reg_mgpir_pack(mgpir_pl);
+       mlxsw_reg_mgpir_pack(mgpir_pl, 0);
        err = mlxsw_reg_query(mlxsw_hwmon->core, MLXSW_REG(mgpir), mgpir_pl);
        if (err)
                return err;
 
-       mlxsw_reg_mgpir_unpack(mgpir_pl, &gbox_num, &device_type, NULL, NULL);
+       mlxsw_reg_mgpir_unpack(mgpir_pl, &gbox_num, &device_type, NULL, NULL,
+                              NULL);
        if (device_type != MLXSW_REG_MGPIR_DEVICE_TYPE_GEARBOX_DIE ||
            !gbox_num)
                return 0;
index 65ab04e3297220ddf07c3dc268205629882e6568..adb2820430b1e0004c400797bd646ff5f0231b08 100644 (file)
@@ -746,13 +746,13 @@ mlxsw_thermal_modules_init(struct device *dev, struct mlxsw_core *core,
        char mgpir_pl[MLXSW_REG_MGPIR_LEN];
        int i, err;
 
-       mlxsw_reg_mgpir_pack(mgpir_pl);
+       mlxsw_reg_mgpir_pack(mgpir_pl, 0);
        err = mlxsw_reg_query(core, MLXSW_REG(mgpir), mgpir_pl);
        if (err)
                return err;
 
        mlxsw_reg_mgpir_unpack(mgpir_pl, NULL, NULL, NULL,
-                              &thermal->tz_module_num);
+                              &thermal->tz_module_num, NULL);
 
        thermal->tz_module_arr = kcalloc(thermal->tz_module_num,
                                         sizeof(*thermal->tz_module_arr),
@@ -837,13 +837,13 @@ mlxsw_thermal_gearboxes_init(struct device *dev, struct mlxsw_core *core,
        int i;
        int err;
 
-       mlxsw_reg_mgpir_pack(mgpir_pl);
+       mlxsw_reg_mgpir_pack(mgpir_pl, 0);
        err = mlxsw_reg_query(core, MLXSW_REG(mgpir), mgpir_pl);
        if (err)
                return err;
 
        mlxsw_reg_mgpir_unpack(mgpir_pl, &gbox_num, &device_type, NULL,
-                              NULL);
+                              NULL, NULL);
        if (device_type != MLXSW_REG_MGPIR_DEVICE_TYPE_GEARBOX_DIE ||
            !gbox_num)
                return 0;
index 5bf8ad32cb8efff7b178ac74f62002c09040580c..f0c90e66aa327c06e45a317edec7a8ae5fae246e 100644 (file)
@@ -11362,6 +11362,12 @@ enum mlxsw_reg_mgpir_device_type {
        MLXSW_REG_MGPIR_DEVICE_TYPE_GEARBOX_DIE,
 };
 
+/* mgpir_slot_index
+ * Slot index (0: Main board).
+ * Access: Index
+ */
+MLXSW_ITEM32(reg, mgpir, slot_index, 0x00, 28, 4);
+
 /* mgpir_device_type
  * Access: RO
  */
@@ -11379,21 +11385,29 @@ MLXSW_ITEM32(reg, mgpir, devices_per_flash, 0x00, 16, 8);
  */
 MLXSW_ITEM32(reg, mgpir, num_of_devices, 0x00, 0, 8);
 
+/* mgpir_num_of_slots
+ * Number of slots in the system.
+ * Access: RO
+ */
+MLXSW_ITEM32(reg, mgpir, num_of_slots, 0x04, 8, 8);
+
 /* mgpir_num_of_modules
  * Number of modules.
  * Access: RO
  */
 MLXSW_ITEM32(reg, mgpir, num_of_modules, 0x04, 0, 8);
 
-static inline void mlxsw_reg_mgpir_pack(char *payload)
+static inline void mlxsw_reg_mgpir_pack(char *payload, u8 slot_index)
 {
        MLXSW_REG_ZERO(mgpir, payload);
+       mlxsw_reg_mgpir_slot_index_set(payload, slot_index);
 }
 
 static inline void
 mlxsw_reg_mgpir_unpack(char *payload, u8 *num_of_devices,
                       enum mlxsw_reg_mgpir_device_type *device_type,
-                      u8 *devices_per_flash, u8 *num_of_modules)
+                      u8 *devices_per_flash, u8 *num_of_modules,
+                      u8 *num_of_slots)
 {
        if (num_of_devices)
                *num_of_devices = mlxsw_reg_mgpir_num_of_devices_get(payload);
@@ -11404,6 +11418,8 @@ mlxsw_reg_mgpir_unpack(char *payload, u8 *num_of_devices,
                                mlxsw_reg_mgpir_devices_per_flash_get(payload);
        if (num_of_modules)
                *num_of_modules = mlxsw_reg_mgpir_num_of_modules_get(payload);
+       if (num_of_slots)
+               *num_of_slots = mlxsw_reg_mgpir_num_of_slots_get(payload);
 }
 
 /* MFDE - Monitoring FW Debug Register