diff --git a/platform/mellanox/mlnx-platform-api/sonic_platform/device_data.py b/platform/mellanox/mlnx-platform-api/sonic_platform/device_data.py index f006281c51..35b1f14d5b 100644 --- a/platform/mellanox/mlnx-platform-api/sonic_platform/device_data.py +++ b/platform/mellanox/mlnx-platform-api/sonic_platform/device_data.py @@ -2,34 +2,22 @@ DEVICE_DATA = { 'x86_64-mlnx_msn2700-r0': { 'thermal': { 'minimum_table': { - "p2c_trust": {"-127:40":13, "41:120":15}, - "p2c_untrust": {"-127:25":13, "26:30":14 , "31:35":15, "36:120":16}, - "c2p_trust": {"-127:20":13, "21:25":14 , "26:30":15, "31:120":16}, - "c2p_untrust": {"-127:20":13, "21:25":14 , "26:30":15, "31:120":16}, - "unk_trust": {"-127:20":13, "21:25":14 , "26:30":15, "31:120":16}, - "unk_untrust": {"-127:20":13, "21:25":14 , "26:30":15, "31:120":16} + "unk_trust": {"-127:30":13, "31:40":14 , "41:120":15}, + "unk_untrust": {"-127:25":13, "26:30":14 , "31:35":15, "36:120":16} } } }, 'x86_64-mlnx_msn2740-r0': { 'thermal': { 'minimum_table': { - "p2c_trust": {"-127:120":13}, - "p2c_untrust": {"-127:35":13, "36:40":14 , "41:120":15}, - "c2p_trust": {"-127:120":13}, - "c2p_untrust": {"-127:15":13, "16:30":14 , "31:35":15, "36:120":17}, "unk_trust": {"-127:120":13}, - "unk_untrust": {"-127:15":13, "16:30":14 , "31:35":15, "36:120":17}, + "unk_untrust": {"-127:15":13, "16:25":14 , "26:30":15, "31:120":17}, } } }, 'x86_64-mlnx_msn2100-r0': { 'thermal': { 'minimum_table': { - "p2c_trust": {"-127:120":12}, - "p2c_untrust": {"-127:15":12, "16:25":13, "26:30":14, "31:35":15, "36:120":16}, - "c2p_trust": {"-127:40":12, "41:120":13}, - "c2p_untrust": {"-127:40":12, "41:120":13}, "unk_trust": {"-127:40":12, "41:120":13}, "unk_untrust": {"-127:15":12, "16:25":13, "26:30":14, "31:35":15, "36:120":16} } @@ -38,22 +26,14 @@ DEVICE_DATA = { 'x86_64-mlnx_msn2410-r0': { 'thermal': { 'minimum_table': { - "p2c_trust": {"-127:40":13, "41:120":15}, - "p2c_untrust": {"-127:25":13, "26:30":14 , "31:35":15, "36:120":16}, - "c2p_trust": {"-127:20":13, "21:25":14 , "26:30":15, "31:120":16}, - "c2p_untrust": {"-127:20":13, "21:25":14 , "26:30":15, "31:120":16}, - "unk_trust": {"-127:20":13, "21:25":14 , "26:30":15, "31:120":16}, - "unk_untrust": {"-127:20":13, "21:25":14 , "26:30":15, "31:120":16} + "unk_trust": {"-127:30":13, "31:40":14 , "41:120":15}, + "unk_untrust": {"-127:25":13, "26:30":14 , "31:35":15, "36:120":16} } } }, 'x86_64-mlnx_msn2010-r0': { 'thermal': { 'minimum_table': { - "p2c_trust": {"-127:120":12}, - "p2c_untrust": {"-127:15":12, "16:20":13, "21:30":14, "31:35":15, "36:120":16}, - "c2p_trust": {"-127:120":12}, - "c2p_untrust": {"-127:20":12, "21:25":13 , "26:30":14, "31:35":15, "36:120":16}, "unk_trust": {"-127:120":12}, "unk_untrust": {"-127:15":12, "16:20":13 , "21:30":14, "31:35":15, "36:120":16} } @@ -62,10 +42,6 @@ DEVICE_DATA = { 'x86_64-mlnx_msn3700-r0': { 'thermal': { 'minimum_table': { - "p2c_trust": {"-127:25":12, "26:40":13 , "41:120":14}, - "p2c_untrust": {"-127:15":12, "16:30":13 , "31:35":14, "36:40":15, "41:120":16}, - "c2p_trust": {"-127:25":12, "26:40":13 , "41:120":14}, - "c2p_untrust": {"-127:25":12, "26:40":13 , "41:120":14}, "unk_trust": {"-127:25":12, "26:40":13 , "41:120":14}, "unk_untrust": {"-127:15":12, "16:30":13 , "31:35":14, "36:40":15, "41:120":16}, } @@ -74,28 +50,25 @@ DEVICE_DATA = { 'x86_64-mlnx_msn3700c-r0': { 'thermal': { 'minimum_table': { - "p2c_trust": {"-127:25":12, "26:40":13 , "41:120":14}, - "p2c_untrust": {"-127:15":12, "16:30":13 , "31:35":14, "36:40":15, "41:120":16}, - "c2p_trust": {"-127:25":12, "26:40":13 , "41:120":14}, - "c2p_untrust": {"-127:25":12, "26:40":13 , "41:120":14}, - "unk_trust": {"-127:25":12, "26:40":13 , "41:120":14}, - "unk_untrust": {"-127:15":12, "16:30":13 , "31:35":14, "36:40":15, "41:120":16}, + "unk_trust": {"-127:40":12, "41:120":13}, + "unk_untrust": {"-127:10":12, "11:20":13 , "21:30":14, "31:35":15, "36:120":16}, } } }, 'x86_64-mlnx_msn3800-r0': { 'thermal': { 'minimum_table': { - "p2c_trust": {"-127:35":12, "36:120":13}, - "p2c_untrust": {"-127:0":12, "1:10":13 , "11:15":14, "16:20":15, "21:35":16, "36:120":17}, - "c2p_trust": {"-127:30":12, "31:40":13 , "41:120":14}, - "c2p_untrust": {"-127:20":12, "21:30":13 , "31:35":14, "36:40":15, "41:120":16}, "unk_trust": {"-127:30":12, "31:40":13 , "41:120":14}, "unk_untrust": {"-127:0":12, "1:10":13 , "11:15":14, "16:20":15, "21:35":16, "36:120":17}, } } }, 'x86_64-mlnx_msn4700-r0': { - + 'thermal': { + 'minimum_table': { + "unk_trust": {"-127:120":16}, + "unk_untrust": {"-127:120":16}, + } + } } } \ No newline at end of file diff --git a/platform/mellanox/mlnx-platform-api/sonic_platform/thermal.py b/platform/mellanox/mlnx-platform-api/sonic_platform/thermal.py index a9c11848f5..d4b9d56dc1 100644 --- a/platform/mellanox/mlnx-platform-api/sonic_platform/thermal.py +++ b/platform/mellanox/mlnx-platform-api/sonic_platform/thermal.py @@ -567,16 +567,11 @@ class Thermal(ThermalBase): return 'trust' @classmethod - def get_air_flow_direction(cls): + def get_min_amb_temperature(cls): fan_ambient_path = join(HW_MGMT_THERMAL_ROOT, THERMAL_DEV_FAN_AMBIENT) port_ambient_path = join(HW_MGMT_THERMAL_ROOT, THERMAL_DEV_PORT_AMBIENT) # if there is any exception, let it raise fan_ambient_temp = int(cls._read_generic_file(fan_ambient_path, 0)) port_ambient_temp = int(cls._read_generic_file(port_ambient_path, 0)) - if fan_ambient_temp > port_ambient_temp: - return 'p2c', fan_ambient_temp - elif fan_ambient_temp < port_ambient_temp: - return 'c2p', port_ambient_temp - else: - return 'unk', fan_ambient_temp + return fan_ambient_temp if fan_ambient_temp < port_ambient_temp else port_ambient_temp diff --git a/platform/mellanox/mlnx-platform-api/sonic_platform/thermal_actions.py b/platform/mellanox/mlnx-platform-api/sonic_platform/thermal_actions.py index 1f8292763d..3a4d5f2a8a 100644 --- a/platform/mellanox/mlnx-platform-api/sonic_platform/thermal_actions.py +++ b/platform/mellanox/mlnx-platform-api/sonic_platform/thermal_actions.py @@ -154,10 +154,9 @@ class ChangeMinCoolingLevelAction(ThermalPolicyActionBase): if chassis.platform_name not in DEVICE_DATA or 'thermal' not in DEVICE_DATA[chassis.platform_name] or 'minimum_table' not in DEVICE_DATA[chassis.platform_name]['thermal']: Fan.min_cooling_level = ChangeMinCoolingLevelAction.UNKNOWN_SKU_COOLING_LEVEL else: - air_flow_dir = MinCoolingLevelChangeCondition.air_flow_dir trust_state = MinCoolingLevelChangeCondition.trust_state temperature = MinCoolingLevelChangeCondition.temperature - minimum_table = DEVICE_DATA[chassis.platform_name]['thermal']['minimum_table']['{}_{}'.format(air_flow_dir, trust_state)] + minimum_table = DEVICE_DATA[chassis.platform_name]['thermal']['minimum_table']['unk_{}'.format(trust_state)] for key, cooling_level in minimum_table.items(): temp_range = key.split(':') diff --git a/platform/mellanox/mlnx-platform-api/sonic_platform/thermal_conditions.py b/platform/mellanox/mlnx-platform-api/sonic_platform/thermal_conditions.py index 6bd2d28286..94e18a2e00 100644 --- a/platform/mellanox/mlnx-platform-api/sonic_platform/thermal_conditions.py +++ b/platform/mellanox/mlnx-platform-api/sonic_platform/thermal_conditions.py @@ -78,14 +78,13 @@ class AllPsuPresenceCondition(PsuCondition): class MinCoolingLevelChangeCondition(ThermalPolicyConditionBase): trust_state = None - air_flow_dir = None temperature = None def is_match(self, thermal_info_dict): from .thermal import Thermal trust_state = Thermal.check_module_temperature_trustable() - air_flow_dir, temperature = Thermal.get_air_flow_direction() + temperature = Thermal.get_min_amb_temperature() temperature = temperature / 1000 change_cooling_level = False @@ -93,10 +92,6 @@ class MinCoolingLevelChangeCondition(ThermalPolicyConditionBase): MinCoolingLevelChangeCondition.trust_state = trust_state change_cooling_level = True - if air_flow_dir != MinCoolingLevelChangeCondition.air_flow_dir: - MinCoolingLevelChangeCondition.air_flow_dir = air_flow_dir - change_cooling_level = True - if temperature != MinCoolingLevelChangeCondition.temperature: MinCoolingLevelChangeCondition.temperature = temperature change_cooling_level = True diff --git a/platform/mellanox/mlnx-platform-api/tests/test_thermal_policy.py b/platform/mellanox/mlnx-platform-api/tests/test_thermal_policy.py index 835d7a495b..87fac359b2 100644 --- a/platform/mellanox/mlnx-platform-api/tests/test_thermal_policy.py +++ b/platform/mellanox/mlnx-platform-api/tests/test_thermal_policy.py @@ -482,10 +482,9 @@ def test_dynamic_minimum_policy(thermal_manager): condition = policy.conditions[MinCoolingLevelChangeCondition] action = policy.actions[ChangeMinCoolingLevelAction] Thermal.check_module_temperature_trustable = MagicMock(return_value='trust') - Thermal.get_air_flow_direction = MagicMock(return_value=('p2c', 35000)) + Thermal.get_min_amb_temperature = MagicMock(return_value=35000) assert condition.is_match(None) assert MinCoolingLevelChangeCondition.trust_state == 'trust' - assert MinCoolingLevelChangeCondition.air_flow_dir == 'p2c' assert MinCoolingLevelChangeCondition.temperature == 35 assert not condition.is_match(None) @@ -493,11 +492,7 @@ def test_dynamic_minimum_policy(thermal_manager): assert condition.is_match(None) assert MinCoolingLevelChangeCondition.trust_state == 'untrust' - Thermal.get_air_flow_direction = MagicMock(return_value=('c2p', 35000)) - assert condition.is_match(None) - assert MinCoolingLevelChangeCondition.air_flow_dir == 'c2p' - - Thermal.get_air_flow_direction = MagicMock(return_value=('c2p', 25000)) + Thermal.get_min_amb_temperature = MagicMock(return_value=25000) assert condition.is_match(None) assert MinCoolingLevelChangeCondition.temperature == 25 @@ -515,5 +510,5 @@ def test_dynamic_minimum_policy(thermal_manager): chassis.platform_name = 'x86_64-mlnx_msn2700-r0' action.execute(thermal_info_dict) - assert Fan.min_cooling_level == 4 - Fan.set_cooling_level.assert_called_with(4, 5) + assert Fan.min_cooling_level == 3 + Fan.set_cooling_level.assert_called_with(3, 5)