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] Adjust dynamic minimum fan speed algorithm #4476

Merged
merged 2 commits into from
Apr 28, 2020
Merged
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
53 changes: 13 additions & 40 deletions platform/mellanox/mlnx-platform-api/sonic_platform/device_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,22 @@
'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}
}
Expand All @@ -38,22 +26,14 @@
'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}
}
Expand All @@ -62,10 +42,6 @@
'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},
}
Expand All @@ -74,28 +50,25 @@
'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},
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -551,16 +551,11 @@ def check_module_temperature_trustable(cls):
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
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,9 @@ def execute(self, thermal_info_dict):
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(':')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,25 +78,20 @@ def is_match(self, thermal_info_dict):

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
if trust_state != MinCoolingLevelChangeCondition.trust_state:
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -482,22 +482,17 @@ 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)

Thermal.check_module_temperature_trustable = MagicMock(return_value='untrust')
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

Expand All @@ -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)