Skip to content
/ linux Public

Commit b691602

Browse files
vadimp-nvidiakuba-moo
authored andcommitted
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: Vadim Pasternak <vadimp@nvidia.com> Signed-off-by: Ido Schimmel <idosch@nvidia.com> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 7cb85d3 commit b691602

File tree

4 files changed

+29
-12
lines changed

4 files changed

+29
-12
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1060,12 +1060,12 @@ int mlxsw_env_init(struct mlxsw_core *mlxsw_core, struct mlxsw_env **p_env)
10601060
u8 module_count;
10611061
int i, err;
10621062

1063-
mlxsw_reg_mgpir_pack(mgpir_pl);
1063+
mlxsw_reg_mgpir_pack(mgpir_pl, 0);
10641064
err = mlxsw_reg_query(mlxsw_core, MLXSW_REG(mgpir), mgpir_pl);
10651065
if (err)
10661066
return err;
10671067

1068-
mlxsw_reg_mgpir_unpack(mgpir_pl, NULL, NULL, NULL, &module_count);
1068+
mlxsw_reg_mgpir_unpack(mgpir_pl, NULL, NULL, NULL, &module_count, NULL);
10691069

10701070
env = kzalloc(struct_size(env, module_info, module_count), GFP_KERNEL);
10711071
if (!env)

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -656,13 +656,13 @@ static int mlxsw_hwmon_module_init(struct mlxsw_hwmon *mlxsw_hwmon)
656656
u8 module_sensor_max;
657657
int i, err;
658658

659-
mlxsw_reg_mgpir_pack(mgpir_pl);
659+
mlxsw_reg_mgpir_pack(mgpir_pl, 0);
660660
err = mlxsw_reg_query(mlxsw_hwmon->core, MLXSW_REG(mgpir), mgpir_pl);
661661
if (err)
662662
return err;
663663

664664
mlxsw_reg_mgpir_unpack(mgpir_pl, NULL, NULL, NULL,
665-
&module_sensor_max);
665+
&module_sensor_max, NULL);
666666

667667
/* Add extra attributes for module temperature. Sensor index is
668668
* assigned to sensor_count value, while all indexed before
@@ -707,12 +707,13 @@ static int mlxsw_hwmon_gearbox_init(struct mlxsw_hwmon *mlxsw_hwmon)
707707
u8 gbox_num;
708708
int err;
709709

710-
mlxsw_reg_mgpir_pack(mgpir_pl);
710+
mlxsw_reg_mgpir_pack(mgpir_pl, 0);
711711
err = mlxsw_reg_query(mlxsw_hwmon->core, MLXSW_REG(mgpir), mgpir_pl);
712712
if (err)
713713
return err;
714714

715-
mlxsw_reg_mgpir_unpack(mgpir_pl, &gbox_num, &device_type, NULL, NULL);
715+
mlxsw_reg_mgpir_unpack(mgpir_pl, &gbox_num, &device_type, NULL, NULL,
716+
NULL);
716717
if (device_type != MLXSW_REG_MGPIR_DEVICE_TYPE_GEARBOX_DIE ||
717718
!gbox_num)
718719
return 0;

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -746,13 +746,13 @@ mlxsw_thermal_modules_init(struct device *dev, struct mlxsw_core *core,
746746
char mgpir_pl[MLXSW_REG_MGPIR_LEN];
747747
int i, err;
748748

749-
mlxsw_reg_mgpir_pack(mgpir_pl);
749+
mlxsw_reg_mgpir_pack(mgpir_pl, 0);
750750
err = mlxsw_reg_query(core, MLXSW_REG(mgpir), mgpir_pl);
751751
if (err)
752752
return err;
753753

754754
mlxsw_reg_mgpir_unpack(mgpir_pl, NULL, NULL, NULL,
755-
&thermal->tz_module_num);
755+
&thermal->tz_module_num, NULL);
756756

757757
thermal->tz_module_arr = kcalloc(thermal->tz_module_num,
758758
sizeof(*thermal->tz_module_arr),
@@ -837,13 +837,13 @@ mlxsw_thermal_gearboxes_init(struct device *dev, struct mlxsw_core *core,
837837
int i;
838838
int err;
839839

840-
mlxsw_reg_mgpir_pack(mgpir_pl);
840+
mlxsw_reg_mgpir_pack(mgpir_pl, 0);
841841
err = mlxsw_reg_query(core, MLXSW_REG(mgpir), mgpir_pl);
842842
if (err)
843843
return err;
844844

845845
mlxsw_reg_mgpir_unpack(mgpir_pl, &gbox_num, &device_type, NULL,
846-
NULL);
846+
NULL, NULL);
847847
if (device_type != MLXSW_REG_MGPIR_DEVICE_TYPE_GEARBOX_DIE ||
848848
!gbox_num)
849849
return 0;

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

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11362,6 +11362,12 @@ enum mlxsw_reg_mgpir_device_type {
1136211362
MLXSW_REG_MGPIR_DEVICE_TYPE_GEARBOX_DIE,
1136311363
};
1136411364

11365+
/* mgpir_slot_index
11366+
* Slot index (0: Main board).
11367+
* Access: Index
11368+
*/
11369+
MLXSW_ITEM32(reg, mgpir, slot_index, 0x00, 28, 4);
11370+
1136511371
/* mgpir_device_type
1136611372
* Access: RO
1136711373
*/
@@ -11379,21 +11385,29 @@ MLXSW_ITEM32(reg, mgpir, devices_per_flash, 0x00, 16, 8);
1137911385
*/
1138011386
MLXSW_ITEM32(reg, mgpir, num_of_devices, 0x00, 0, 8);
1138111387

11388+
/* mgpir_num_of_slots
11389+
* Number of slots in the system.
11390+
* Access: RO
11391+
*/
11392+
MLXSW_ITEM32(reg, mgpir, num_of_slots, 0x04, 8, 8);
11393+
1138211394
/* mgpir_num_of_modules
1138311395
* Number of modules.
1138411396
* Access: RO
1138511397
*/
1138611398
MLXSW_ITEM32(reg, mgpir, num_of_modules, 0x04, 0, 8);
1138711399

11388-
static inline void mlxsw_reg_mgpir_pack(char *payload)
11400+
static inline void mlxsw_reg_mgpir_pack(char *payload, u8 slot_index)
1138911401
{
1139011402
MLXSW_REG_ZERO(mgpir, payload);
11403+
mlxsw_reg_mgpir_slot_index_set(payload, slot_index);
1139111404
}
1139211405

1139311406
static inline void
1139411407
mlxsw_reg_mgpir_unpack(char *payload, u8 *num_of_devices,
1139511408
enum mlxsw_reg_mgpir_device_type *device_type,
11396-
u8 *devices_per_flash, u8 *num_of_modules)
11409+
u8 *devices_per_flash, u8 *num_of_modules,
11410+
u8 *num_of_slots)
1139711411
{
1139811412
if (num_of_devices)
1139911413
*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,
1140411418
mlxsw_reg_mgpir_devices_per_flash_get(payload);
1140511419
if (num_of_modules)
1140611420
*num_of_modules = mlxsw_reg_mgpir_num_of_modules_get(payload);
11421+
if (num_of_slots)
11422+
*num_of_slots = mlxsw_reg_mgpir_num_of_slots_get(payload);
1140711423
}
1140811424

1140911425
/* MFDE - Monitoring FW Debug Register

0 commit comments

Comments
 (0)