Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Mellanox] Remove thermal zone related code and replace with new one #199

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion platform/mellanox/mlnx-platform-api/sonic_platform/fan.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,10 @@ def get_target_speed(self):
"""
try:
# Get PSU fan target speed according to current system cooling level
cooling_level = utils.read_int_from_file('/run/hw-management/thermal/cooling_cur_state', log_func=None)
pwm = utils.read_int_from_file('/run/hw-management/thermal/pwm1', log_func=None)
if pwm >= PWM_MAX:
pwm = PWM_MAX - 1
cooling_level = int(pwm / PWM_MAX * 10)
return int(self.PSU_FAN_SPEED[cooling_level], 16)
except Exception:
return self.get_speed()
Expand Down
22 changes: 6 additions & 16 deletions platform/mellanox/mlnx-platform-api/sonic_platform/thermal.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@
{
"name": "ASIC",
"temperature": "asic",
"high_threshold": "mlxsw/temp_trip_hot",
"high_critical_threshold": "mlxsw/temp_trip_crit"
"high_threshold": "asic_temp_emergency",
"high_critical_threshold": "asic_temp_trip_crit"
},
{
"name": "Ambient Port Side Temp",
Expand Down Expand Up @@ -105,8 +105,8 @@
{
"name": "Gearbox {} Temp",
"temperature": "gearbox{}_temp_input",
"high_threshold": "mlxsw-gearbox{}/temp_trip_hot",
"high_critical_threshold": "mlxsw-gearbox{}/temp_trip_crit",
"high_threshold": "gearbox{}_temp_emergency",
"high_critical_threshold": "gearbox{}_temp_trip_crit",
"type": "indexable"
},
{
Expand Down Expand Up @@ -135,8 +135,8 @@
'linecard thermals': {
"name": "Gearbox {} Temp",
"temperature": "gearbox{}_temp_input",
"high_threshold": "mlxsw-gearbox{}/temp_trip_hot",
"high_critical_threshold": "mlxsw-gearbox{}/temp_trip_crit",
"high_threshold": "gearbox{}_temp_emergency",
"high_critical_threshold": "gearbox{}_temp_trip_crit",
"type": "indexable"
}
}
Expand Down Expand Up @@ -268,16 +268,6 @@ def _check_thermal_sysfs_existence(file_path):


class Thermal(ThermalBase):
thermal_algorithm_status = False
# Expect cooling level, used for caching the cooling level value before commiting to hardware
expect_cooling_level = None
# Expect cooling state
expect_cooling_state = None
# Last committed cooling level
last_set_cooling_level = None
last_set_cooling_state = None
last_set_psu_cooling_level = None

def __init__(self, name, temp_file, high_th_file, high_crit_th_file, position):
"""
index should be a string for category ambient and int for other categories
Expand Down
13 changes: 1 addition & 12 deletions platform/mellanox/mlnx-platform-api/tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2021-2022 NVIDIA CORPORATION & AFFILIATES.
# Copyright (c) 2021-2023 NVIDIA CORPORATION & AFFILIATES.
# Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -42,14 +42,3 @@ def auto_recover_mock():
utils.read_str_from_file = origin_read_str_from_file
utils.write_file = origin_write_file
utils.read_float_from_file = origin_read_float_from_file


@pytest.fixture(scope='function', autouse=True)
def auto_reset_cooling_level():
from sonic_platform.thermal import Thermal
yield
Thermal.expect_cooling_level = None
Thermal.expect_cooling_state = None
Thermal.last_set_cooling_level = None
Thermal.last_set_cooling_state = None
Thermal.last_set_psu_cooling_level = None
4 changes: 2 additions & 2 deletions platform/mellanox/mlnx-platform-api/tests/test_fan_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ def test_psu_fan_basic(self, mock_path_exists, mock_powergood, mock_presence, mo
assert fan.get_presence() is False
mock_path_exists.return_value = True
assert fan.get_presence() is True
mock_read_int.return_value = 7
assert fan.get_target_speed() == 70
mock_read_int.return_value = int(255 / 10 * 7)
assert fan.get_target_speed() == 60
mock_read_int.return_value = FAN_DIR_VALUE_INTAKE
assert fan.get_direction() == Fan.FAN_DIRECTION_INTAKE
mock_read_int.return_value = FAN_DIR_VALUE_EXHAUST
Expand Down