Commit b691602c authored by Vadim Pasternak's avatar Vadim Pasternak Committed by Jakub Kicinski

mlxsw: reg: Extend MGPIR register with new slot fields

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: default avatarVadim Pasternak <vadimp@nvidia.com>
Signed-off-by: default avatarIdo Schimmel <idosch@nvidia.com>
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 7cb85d3c
...@@ -1060,12 +1060,12 @@ int mlxsw_env_init(struct mlxsw_core *mlxsw_core, struct mlxsw_env **p_env) ...@@ -1060,12 +1060,12 @@ int mlxsw_env_init(struct mlxsw_core *mlxsw_core, struct mlxsw_env **p_env)
u8 module_count; u8 module_count;
int i, err; 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); err = mlxsw_reg_query(mlxsw_core, MLXSW_REG(mgpir), mgpir_pl);
if (err) if (err)
return 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); env = kzalloc(struct_size(env, module_info, module_count), GFP_KERNEL);
if (!env) if (!env)
......
...@@ -656,13 +656,13 @@ static int mlxsw_hwmon_module_init(struct mlxsw_hwmon *mlxsw_hwmon) ...@@ -656,13 +656,13 @@ static int mlxsw_hwmon_module_init(struct mlxsw_hwmon *mlxsw_hwmon)
u8 module_sensor_max; u8 module_sensor_max;
int i, err; 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); err = mlxsw_reg_query(mlxsw_hwmon->core, MLXSW_REG(mgpir), mgpir_pl);
if (err) if (err)
return err; return err;
mlxsw_reg_mgpir_unpack(mgpir_pl, NULL, NULL, NULL, 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 /* Add extra attributes for module temperature. Sensor index is
* assigned to sensor_count value, while all indexed before * assigned to sensor_count value, while all indexed before
...@@ -707,12 +707,13 @@ static int mlxsw_hwmon_gearbox_init(struct mlxsw_hwmon *mlxsw_hwmon) ...@@ -707,12 +707,13 @@ static int mlxsw_hwmon_gearbox_init(struct mlxsw_hwmon *mlxsw_hwmon)
u8 gbox_num; u8 gbox_num;
int err; 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); err = mlxsw_reg_query(mlxsw_hwmon->core, MLXSW_REG(mgpir), mgpir_pl);
if (err) if (err)
return 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 || if (device_type != MLXSW_REG_MGPIR_DEVICE_TYPE_GEARBOX_DIE ||
!gbox_num) !gbox_num)
return 0; return 0;
......
...@@ -746,13 +746,13 @@ mlxsw_thermal_modules_init(struct device *dev, struct mlxsw_core *core, ...@@ -746,13 +746,13 @@ mlxsw_thermal_modules_init(struct device *dev, struct mlxsw_core *core,
char mgpir_pl[MLXSW_REG_MGPIR_LEN]; char mgpir_pl[MLXSW_REG_MGPIR_LEN];
int i, err; 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); err = mlxsw_reg_query(core, MLXSW_REG(mgpir), mgpir_pl);
if (err) if (err)
return err; return err;
mlxsw_reg_mgpir_unpack(mgpir_pl, NULL, NULL, NULL, 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, thermal->tz_module_arr = kcalloc(thermal->tz_module_num,
sizeof(*thermal->tz_module_arr), sizeof(*thermal->tz_module_arr),
...@@ -837,13 +837,13 @@ mlxsw_thermal_gearboxes_init(struct device *dev, struct mlxsw_core *core, ...@@ -837,13 +837,13 @@ mlxsw_thermal_gearboxes_init(struct device *dev, struct mlxsw_core *core,
int i; int i;
int err; 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); err = mlxsw_reg_query(core, MLXSW_REG(mgpir), mgpir_pl);
if (err) if (err)
return err; return err;
mlxsw_reg_mgpir_unpack(mgpir_pl, &gbox_num, &device_type, NULL, mlxsw_reg_mgpir_unpack(mgpir_pl, &gbox_num, &device_type, NULL,
NULL); NULL, NULL);
if (device_type != MLXSW_REG_MGPIR_DEVICE_TYPE_GEARBOX_DIE || if (device_type != MLXSW_REG_MGPIR_DEVICE_TYPE_GEARBOX_DIE ||
!gbox_num) !gbox_num)
return 0; return 0;
......
...@@ -11362,6 +11362,12 @@ enum mlxsw_reg_mgpir_device_type { ...@@ -11362,6 +11362,12 @@ enum mlxsw_reg_mgpir_device_type {
MLXSW_REG_MGPIR_DEVICE_TYPE_GEARBOX_DIE, 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 /* mgpir_device_type
* Access: RO * Access: RO
*/ */
...@@ -11379,21 +11385,29 @@ MLXSW_ITEM32(reg, mgpir, devices_per_flash, 0x00, 16, 8); ...@@ -11379,21 +11385,29 @@ MLXSW_ITEM32(reg, mgpir, devices_per_flash, 0x00, 16, 8);
*/ */
MLXSW_ITEM32(reg, mgpir, num_of_devices, 0x00, 0, 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 /* mgpir_num_of_modules
* Number of modules. * Number of modules.
* Access: RO * Access: RO
*/ */
MLXSW_ITEM32(reg, mgpir, num_of_modules, 0x04, 0, 8); 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_ZERO(mgpir, payload);
mlxsw_reg_mgpir_slot_index_set(payload, slot_index);
} }
static inline void static inline void
mlxsw_reg_mgpir_unpack(char *payload, u8 *num_of_devices, mlxsw_reg_mgpir_unpack(char *payload, u8 *num_of_devices,
enum mlxsw_reg_mgpir_device_type *device_type, 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) if (num_of_devices)
*num_of_devices = mlxsw_reg_mgpir_num_of_devices_get(payload); *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, ...@@ -11404,6 +11418,8 @@ mlxsw_reg_mgpir_unpack(char *payload, u8 *num_of_devices,
mlxsw_reg_mgpir_devices_per_flash_get(payload); mlxsw_reg_mgpir_devices_per_flash_get(payload);
if (num_of_modules) if (num_of_modules)
*num_of_modules = mlxsw_reg_mgpir_num_of_modules_get(payload); *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 /* MFDE - Monitoring FW Debug Register
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment