Skip to content

Commit 20d885d

Browse files
[Mellanox] Add new thermal sensors for SN5600 (#12671)
- Why I did it Add new thermal sensors for SN5600 - How I did it Add new thermal sensors for SN5600: PCH and SODIMM - How to verify it Manual test
1 parent 39ebf80 commit 20d885d

File tree

3 files changed

+45
-4
lines changed

3 files changed

+45
-4
lines changed

platform/mellanox/mlnx-platform-api/sonic_platform/device_data.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,12 @@
167167
}
168168
},
169169
'x86_64-nvidia_sn5600-r0': {
170+
'thermal': {
171+
"capability": {
172+
"comex_amb": False,
173+
"pch_temp": True
174+
}
175+
}
170176
}
171177
}
172178

@@ -225,6 +231,11 @@ def get_gearbox_count(cls, sysfs_folder):
225231
def get_cpu_thermal_count(cls):
226232
return len(glob.glob('run/hw-management/thermal/cpu_core[!_]'))
227233

234+
@classmethod
235+
@utils.read_only_cache()
236+
def get_sodimm_thermal_count(cls):
237+
return len(glob.glob('/run/hw-management/thermal/sodimm*_temp_input'))
238+
228239
@classmethod
229240
@utils.read_only_cache()
230241
def get_minimum_table(cls):

platform/mellanox/mlnx-platform-api/sonic_platform/thermal.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,18 @@
119119
"name": "Ambient Switch Board Temp",
120120
"temperature": "swb_amb",
121121
"default_present": False
122+
},
123+
{
124+
"name": "PCH Temp",
125+
"temperature": "pch_temp",
126+
"default_present": False
127+
},
128+
{
129+
"name": "SODIMM {} Temp",
130+
"temperature": "sodimm{}_temp_input",
131+
"high_threshold": "sodimm{}_temp_max",
132+
"high_critical_threshold": "sodimm{}_temp_crit",
133+
"type": "indexable",
122134
}
123135
],
124136
'linecard thermals': {
@@ -161,6 +173,8 @@ def initialize_chassis_thermals():
161173
count = DeviceDataManager.get_gearbox_count('/run/hw-management/config')
162174
elif 'CPU Core' in rule['name']:
163175
count = DeviceDataManager.get_cpu_thermal_count()
176+
elif 'SODIMM' in rule['name']:
177+
count = DeviceDataManager.get_sodimm_thermal_count()
164178
if count == 0:
165179
logger.log_debug('Failed to get thermal object count for {}'.format(rule['name']))
166180
continue
@@ -524,7 +538,7 @@ def monitor_asic_themal_zone(cls):
524538
else:
525539
cls.expect_cooling_state = None
526540

527-
541+
528542
class RemovableThermal(Thermal):
529543
def __init__(self, name, temp_file, high_th_file, high_crit_th_file, position, presence_cb):
530544
super(RemovableThermal, self).__init__(name, temp_file, high_th_file, high_crit_th_file, position)

platform/mellanox/mlnx-platform-api/tests/test_thermal.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ class TestThermal:
3838
@mock.patch('os.path.exists', mock.MagicMock(return_value=True))
3939
@mock.patch('sonic_platform.device_data.DeviceDataManager.get_gearbox_count', mock.MagicMock(return_value=2))
4040
@mock.patch('sonic_platform.device_data.DeviceDataManager.get_cpu_thermal_count', mock.MagicMock(return_value=2))
41+
@mock.patch('sonic_platform.device_data.DeviceDataManager.get_sodimm_thermal_count', mock.MagicMock(return_value=2))
4142
@mock.patch('sonic_platform.device_data.DeviceDataManager.get_platform_name', mock.MagicMock(return_value='x86_64-mlnx_msn2700-r0'))
4243
def test_chassis_thermal(self):
4344
from sonic_platform.thermal import THERMAL_NAMING_RULE
@@ -48,6 +49,7 @@ def test_chassis_thermal(self):
4849
thermal_dict = {thermal.get_name(): thermal for thermal in thermal_list}
4950
gearbox_thermal_rule = None
5051
cpu_thermal_rule = None
52+
sodimm_thermal_rule = None
5153
for rule in THERMAL_NAMING_RULE['chassis thermals']:
5254
thermal_type = rule.get('type', 'single')
5355
if thermal_type == 'single':
@@ -69,9 +71,12 @@ def test_chassis_thermal(self):
6971
gearbox_thermal_rule = rule
7072
elif 'CPU Core' in rule['name']:
7173
cpu_thermal_rule = rule
74+
elif 'SODIMM' in rule['name']:
75+
sodimm_thermal_rule = rule
7276

7377
gearbox_thermal_count = 0
7478
cpu_thermal_count = 0
79+
sodimm_thermal_count = 0
7580
for thermal in thermal_list:
7681
if 'Gearbox' in thermal.get_name():
7782
start_index = gearbox_thermal_rule.get('start_index', 1)
@@ -89,21 +94,32 @@ def test_chassis_thermal(self):
8994
assert cpu_thermal_rule['high_threshold'].format(start_index) in thermal.high_threshold
9095
assert cpu_thermal_rule['high_critical_threshold'].format(start_index) in thermal.high_critical_threshold
9196
cpu_thermal_count += 1
97+
elif 'SODIMM' in thermal.get_name():
98+
start_index = sodimm_thermal_rule.get('start_index', 1)
99+
start_index += sodimm_thermal_count
100+
assert thermal.get_name() == sodimm_thermal_rule['name'].format(start_index)
101+
assert sodimm_thermal_rule['temperature'].format(start_index) in thermal.temperature
102+
assert sodimm_thermal_rule['high_threshold'].format(start_index) in thermal.high_threshold
103+
assert sodimm_thermal_rule['high_critical_threshold'].format(start_index) in thermal.high_critical_threshold
104+
sodimm_thermal_count += 1
92105

93106
assert gearbox_thermal_count == 2
94107
assert cpu_thermal_count == 2
108+
assert sodimm_thermal_count == 2
95109

96110
@mock.patch('sonic_platform.device_data.DeviceDataManager.get_platform_name', mock.MagicMock(return_value='x86_64-nvidia_sn2201-r0'))
97-
@mock.patch('sonic_platform.device_data.DeviceDataManager.get_thermal_capability', mock.MagicMock(return_value={'comex_amb': False, 'cpu_amb': True, 'swb_amb': True}))
98-
def test_chassis_thermal_includes(self):
111+
@mock.patch('sonic_platform.device_data.DeviceDataManager.get_thermal_capability')
112+
def test_chassis_thermal_includes(self, mock_capability):
99113
from sonic_platform.thermal import THERMAL_NAMING_RULE
114+
thermal_capability = {'comex_amb': False, 'cpu_amb': True, 'swb_amb': True}
115+
mock_capability.return_value = thermal_capability
100116
chassis = Chassis()
101117
thermal_list = chassis.get_all_thermals()
102118
assert thermal_list
103119
thermal_dict = {thermal.get_name(): thermal for thermal in thermal_list}
104120
for rule in THERMAL_NAMING_RULE['chassis thermals']:
105121
default_present = rule.get('default_present', True)
106-
if not default_present:
122+
if not default_present and thermal_capability.get(rule['temperature']):
107123
thermal_name = rule['name']
108124
assert thermal_name in thermal_dict
109125

0 commit comments

Comments
 (0)