Skip to content

Commit fd27849

Browse files
vadimp-nvidiadavem330
authored andcommitted
mlxsw: core_hwmon: Introduce slot parameter in hwmon interfaces
Add 'slot' parameter to 'mlxsw_hwmon_dev' structure. Use this parameter in mlxsw_reg_mtmp_pack(), mlxsw_reg_mtbr_pack(), mlxsw_reg_mgpir_pack() and mlxsw_reg_mtmp_slot_index_set() routines. For main board it'll always be zero, for line cards it'll be set to the physical slot number in modular systems. Signed-off-by: Vadim Pasternak <[email protected]> Reviewed-by: Jiri Pirko <[email protected]> Signed-off-by: Ido Schimmel <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent b890ad4 commit fd27849

File tree

1 file changed

+20
-10
lines changed

1 file changed

+20
-10
lines changed

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

+20-10
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ struct mlxsw_hwmon_dev {
5050
unsigned int attrs_count;
5151
u8 sensor_count;
5252
u8 module_sensor_max;
53+
u8 slot_index;
5354
};
5455

5556
struct mlxsw_hwmon {
@@ -72,7 +73,8 @@ static ssize_t mlxsw_hwmon_temp_show(struct device *dev,
7273

7374
index = mlxsw_hwmon_get_attr_index(mlxsw_hwmon_attr->type_index,
7475
mlxsw_hwmon_dev->module_sensor_max);
75-
mlxsw_reg_mtmp_pack(mtmp_pl, 0, index, false, false);
76+
mlxsw_reg_mtmp_pack(mtmp_pl, mlxsw_hwmon_dev->slot_index, index, false,
77+
false);
7678
err = mlxsw_reg_query(mlxsw_hwmon->core, MLXSW_REG(mtmp), mtmp_pl);
7779
if (err) {
7880
dev_err(mlxsw_hwmon->bus_info->dev, "Failed to query temp sensor\n");
@@ -96,7 +98,8 @@ static ssize_t mlxsw_hwmon_temp_max_show(struct device *dev,
9698

9799
index = mlxsw_hwmon_get_attr_index(mlxsw_hwmon_attr->type_index,
98100
mlxsw_hwmon_dev->module_sensor_max);
99-
mlxsw_reg_mtmp_pack(mtmp_pl, 0, index, false, false);
101+
mlxsw_reg_mtmp_pack(mtmp_pl, mlxsw_hwmon_dev->slot_index, index, false,
102+
false);
100103
err = mlxsw_reg_query(mlxsw_hwmon->core, MLXSW_REG(mtmp), mtmp_pl);
101104
if (err) {
102105
dev_err(mlxsw_hwmon->bus_info->dev, "Failed to query temp sensor\n");
@@ -128,6 +131,7 @@ static ssize_t mlxsw_hwmon_temp_rst_store(struct device *dev,
128131
index = mlxsw_hwmon_get_attr_index(mlxsw_hwmon_attr->type_index,
129132
mlxsw_hwmon_dev->module_sensor_max);
130133

134+
mlxsw_reg_mtmp_slot_index_set(mtmp_pl, mlxsw_hwmon_dev->slot_index);
131135
mlxsw_reg_mtmp_sensor_index_set(mtmp_pl, index);
132136
err = mlxsw_reg_query(mlxsw_hwmon->core, MLXSW_REG(mtmp), mtmp_pl);
133137
if (err)
@@ -245,7 +249,7 @@ static int mlxsw_hwmon_module_temp_get(struct device *dev,
245249
int err;
246250

247251
module = mlxsw_hwmon_attr->type_index - mlxsw_hwmon_dev->sensor_count;
248-
mlxsw_reg_mtmp_pack(mtmp_pl, 0,
252+
mlxsw_reg_mtmp_pack(mtmp_pl, mlxsw_hwmon_dev->slot_index,
249253
MLXSW_REG_MTMP_MODULE_INDEX_MIN + module, false,
250254
false);
251255
err = mlxsw_reg_query(mlxsw_hwmon->core, MLXSW_REG(mtmp), mtmp_pl);
@@ -285,8 +289,8 @@ static ssize_t mlxsw_hwmon_module_temp_fault_show(struct device *dev,
285289
int err;
286290

287291
module = mlxsw_hwmon_attr->type_index - mlxsw_hwmon_dev->sensor_count;
288-
mlxsw_reg_mtbr_pack(mtbr_pl, 0, MLXSW_REG_MTBR_BASE_MODULE_INDEX + module,
289-
1);
292+
mlxsw_reg_mtbr_pack(mtbr_pl, mlxsw_hwmon_dev->slot_index,
293+
MLXSW_REG_MTBR_BASE_MODULE_INDEX + module, 1);
290294
err = mlxsw_reg_query(mlxsw_hwmon->core, MLXSW_REG(mtbr), mtbr_pl);
291295
if (err) {
292296
dev_err(dev, "Failed to query module temperature sensor\n");
@@ -326,7 +330,8 @@ static int mlxsw_hwmon_module_temp_critical_get(struct device *dev,
326330
int err;
327331

328332
module = mlxsw_hwmon_attr->type_index - mlxsw_hwmon_dev->sensor_count;
329-
err = mlxsw_env_module_temp_thresholds_get(mlxsw_hwmon->core, 0,
333+
err = mlxsw_env_module_temp_thresholds_get(mlxsw_hwmon->core,
334+
mlxsw_hwmon_dev->slot_index,
330335
module, SFP_TEMP_HIGH_WARN,
331336
p_temp);
332337
if (err) {
@@ -362,7 +367,8 @@ static int mlxsw_hwmon_module_temp_emergency_get(struct device *dev,
362367
int err;
363368

364369
module = mlxsw_hwmon_attr->type_index - mlxsw_hwmon_dev->sensor_count;
365-
err = mlxsw_env_module_temp_thresholds_get(mlxsw_hwmon->core, 0,
370+
err = mlxsw_env_module_temp_thresholds_get(mlxsw_hwmon->core,
371+
mlxsw_hwmon_dev->slot_index,
366372
module, SFP_TEMP_HIGH_ALARM,
367373
p_temp);
368374
if (err) {
@@ -609,6 +615,8 @@ static int mlxsw_hwmon_temp_init(struct mlxsw_hwmon_dev *mlxsw_hwmon_dev)
609615
for (i = 0; i < mlxsw_hwmon_dev->sensor_count; i++) {
610616
char mtmp_pl[MLXSW_REG_MTMP_LEN] = {0};
611617

618+
mlxsw_reg_mtmp_slot_index_set(mtmp_pl,
619+
mlxsw_hwmon_dev->slot_index);
612620
mlxsw_reg_mtmp_sensor_index_set(mtmp_pl, i);
613621
err = mlxsw_reg_query(mlxsw_hwmon->core, MLXSW_REG(mtmp),
614622
mtmp_pl);
@@ -678,7 +686,7 @@ static int mlxsw_hwmon_module_init(struct mlxsw_hwmon_dev *mlxsw_hwmon_dev)
678686
u8 module_sensor_max;
679687
int i, err;
680688

681-
mlxsw_reg_mgpir_pack(mgpir_pl, 0);
689+
mlxsw_reg_mgpir_pack(mgpir_pl, mlxsw_hwmon_dev->slot_index);
682690
err = mlxsw_reg_query(mlxsw_hwmon->core, MLXSW_REG(mgpir), mgpir_pl);
683691
if (err)
684692
return err;
@@ -730,7 +738,7 @@ static int mlxsw_hwmon_gearbox_init(struct mlxsw_hwmon_dev *mlxsw_hwmon_dev)
730738
u8 gbox_num;
731739
int err;
732740

733-
mlxsw_reg_mgpir_pack(mgpir_pl, 0);
741+
mlxsw_reg_mgpir_pack(mgpir_pl, mlxsw_hwmon_dev->slot_index);
734742
err = mlxsw_reg_query(mlxsw_hwmon->core, MLXSW_REG(mgpir), mgpir_pl);
735743
if (err)
736744
return err;
@@ -746,7 +754,8 @@ static int mlxsw_hwmon_gearbox_init(struct mlxsw_hwmon_dev *mlxsw_hwmon_dev)
746754
while (index < max_index) {
747755
sensor_index = index % mlxsw_hwmon_dev->module_sensor_max +
748756
MLXSW_REG_MTMP_GBOX_INDEX_MIN;
749-
mlxsw_reg_mtmp_pack(mtmp_pl, 0, sensor_index, true, true);
757+
mlxsw_reg_mtmp_pack(mtmp_pl, mlxsw_hwmon_dev->slot_index,
758+
sensor_index, true, true);
750759
err = mlxsw_reg_write(mlxsw_hwmon->core,
751760
MLXSW_REG(mtmp), mtmp_pl);
752761
if (err) {
@@ -797,6 +806,7 @@ int mlxsw_hwmon_init(struct mlxsw_core *mlxsw_core,
797806
mlxsw_hwmon->core = mlxsw_core;
798807
mlxsw_hwmon->bus_info = mlxsw_bus_info;
799808
mlxsw_hwmon->line_cards[0].hwmon = mlxsw_hwmon;
809+
mlxsw_hwmon->line_cards[0].slot_index = 0;
800810

801811
err = mlxsw_hwmon_temp_init(&mlxsw_hwmon->line_cards[0]);
802812
if (err)

0 commit comments

Comments
 (0)