diff --git a/platform/mellanox/mlnx-platform-api/sonic_platform/fan.py b/platform/mellanox/mlnx-platform-api/sonic_platform/fan.py index 9567c65ce6c8..40dadb0f4000 100644 --- a/platform/mellanox/mlnx-platform-api/sonic_platform/fan.py +++ b/platform/mellanox/mlnx-platform-api/sonic_platform/fan.py @@ -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() diff --git a/platform/mellanox/mlnx-platform-api/sonic_platform/thermal.py b/platform/mellanox/mlnx-platform-api/sonic_platform/thermal.py index 235086ca5db4..1a6b45da63ac 100644 --- a/platform/mellanox/mlnx-platform-api/sonic_platform/thermal.py +++ b/platform/mellanox/mlnx-platform-api/sonic_platform/thermal.py @@ -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", @@ -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" }, { @@ -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" } } @@ -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 diff --git a/platform/mellanox/mlnx-platform-api/tests/conftest.py b/platform/mellanox/mlnx-platform-api/tests/conftest.py index b69fdd6c75f0..56888c6512cf 100644 --- a/platform/mellanox/mlnx-platform-api/tests/conftest.py +++ b/platform/mellanox/mlnx-platform-api/tests/conftest.py @@ -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"); @@ -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 diff --git a/platform/mellanox/mlnx-platform-api/tests/test_fan_api.py b/platform/mellanox/mlnx-platform-api/tests/test_fan_api.py index 151b197e0836..bb643f211e0a 100644 --- a/platform/mellanox/mlnx-platform-api/tests/test_fan_api.py +++ b/platform/mellanox/mlnx-platform-api/tests/test_fan_api.py @@ -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