Skip to content

Commit f11a323

Browse files
vadimp-nvidiadavem330
authored andcommitted
mlxsw: core_thermal: Add interfaces for line card initialization and de-initialization
Add callback functions for line card thermal area initialization and de-initialization. Each line card is associated with the relevant thermal area, which may contain thermal zones for cages and gearboxes found on this line card. The line card thermal initialization / de-initialization APIs are to be called when line card is set to active / inactive state by got_active() / got_inactive() callbacks from line card state machine. For example thermal zone for module #9 located at line card #7 will have type: mlxsw-lc7-module9. And thermal zone for gearbox #2 located at line card #5 will have type: mlxsw-lc5-gearbox2. Signed-off-by: Vadim Pasternak <[email protected]> Signed-off-by: Ido Schimmel <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 06a0fc4 commit f11a323

File tree

1 file changed

+74
-0
lines changed

1 file changed

+74
-0
lines changed

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

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ struct mlxsw_thermal_area {
9090
struct mlxsw_thermal_module *tz_gearbox_arr;
9191
u8 tz_gearbox_num;
9292
u8 slot_index;
93+
bool active;
9394
};
9495

9596
struct mlxsw_thermal {
@@ -913,6 +914,64 @@ mlxsw_thermal_gearboxes_fini(struct mlxsw_thermal *thermal,
913914
kfree(area->tz_gearbox_arr);
914915
}
915916

917+
static void
918+
mlxsw_thermal_got_active(struct mlxsw_core *mlxsw_core, u8 slot_index,
919+
void *priv)
920+
{
921+
struct mlxsw_thermal *thermal = priv;
922+
struct mlxsw_thermal_area *linecard;
923+
int err;
924+
925+
linecard = &thermal->line_cards[slot_index];
926+
927+
if (linecard->active)
928+
return;
929+
930+
linecard->slot_index = slot_index;
931+
err = mlxsw_thermal_modules_init(thermal->bus_info->dev, thermal->core,
932+
thermal, linecard);
933+
if (err) {
934+
dev_err(thermal->bus_info->dev, "Failed to configure thermal objects for line card modules in slot %d\n",
935+
slot_index);
936+
return;
937+
}
938+
939+
err = mlxsw_thermal_gearboxes_init(thermal->bus_info->dev,
940+
thermal->core, thermal, linecard);
941+
if (err) {
942+
dev_err(thermal->bus_info->dev, "Failed to configure thermal objects for line card gearboxes in slot %d\n",
943+
slot_index);
944+
goto err_thermal_linecard_gearboxes_init;
945+
}
946+
947+
linecard->active = true;
948+
949+
return;
950+
951+
err_thermal_linecard_gearboxes_init:
952+
mlxsw_thermal_modules_fini(thermal, linecard);
953+
}
954+
955+
static void
956+
mlxsw_thermal_got_inactive(struct mlxsw_core *mlxsw_core, u8 slot_index,
957+
void *priv)
958+
{
959+
struct mlxsw_thermal *thermal = priv;
960+
struct mlxsw_thermal_area *linecard;
961+
962+
linecard = &thermal->line_cards[slot_index];
963+
if (!linecard->active)
964+
return;
965+
linecard->active = false;
966+
mlxsw_thermal_gearboxes_fini(thermal, linecard);
967+
mlxsw_thermal_modules_fini(thermal, linecard);
968+
}
969+
970+
static struct mlxsw_linecards_event_ops mlxsw_thermal_event_ops = {
971+
.got_active = mlxsw_thermal_got_active,
972+
.got_inactive = mlxsw_thermal_got_inactive,
973+
};
974+
916975
int mlxsw_thermal_init(struct mlxsw_core *core,
917976
const struct mlxsw_bus_info *bus_info,
918977
struct mlxsw_thermal **p_thermal)
@@ -1018,14 +1077,25 @@ int mlxsw_thermal_init(struct mlxsw_core *core,
10181077
if (err)
10191078
goto err_thermal_gearboxes_init;
10201079

1080+
err = mlxsw_linecards_event_ops_register(core,
1081+
&mlxsw_thermal_event_ops,
1082+
thermal);
1083+
if (err)
1084+
goto err_linecards_event_ops_register;
1085+
10211086
err = thermal_zone_device_enable(thermal->tzdev);
10221087
if (err)
10231088
goto err_thermal_zone_device_enable;
10241089

1090+
thermal->line_cards[0].active = true;
10251091
*p_thermal = thermal;
10261092
return 0;
10271093

10281094
err_thermal_zone_device_enable:
1095+
mlxsw_linecards_event_ops_unregister(thermal->core,
1096+
&mlxsw_thermal_event_ops,
1097+
thermal);
1098+
err_linecards_event_ops_register:
10291099
mlxsw_thermal_gearboxes_fini(thermal, &thermal->line_cards[0]);
10301100
err_thermal_gearboxes_init:
10311101
mlxsw_thermal_modules_fini(thermal, &thermal->line_cards[0]);
@@ -1049,6 +1119,10 @@ void mlxsw_thermal_fini(struct mlxsw_thermal *thermal)
10491119
{
10501120
int i;
10511121

1122+
thermal->line_cards[0].active = false;
1123+
mlxsw_linecards_event_ops_unregister(thermal->core,
1124+
&mlxsw_thermal_event_ops,
1125+
thermal);
10521126
mlxsw_thermal_gearboxes_fini(thermal, &thermal->line_cards[0]);
10531127
mlxsw_thermal_modules_fini(thermal, &thermal->line_cards[0]);
10541128
if (thermal->tzdev) {

0 commit comments

Comments
 (0)