Skip to content

Commit 23dad7c

Browse files
stephenxsmssonicbld
authored andcommitted
[Mellanox] Support per PSU slope value for PSU power threshold (sonic-net#13757)
- Why I did it Support per PSU slope value for PSU power threshold according to hardware team requirement - How I did it Pass the PSU number as a parameter when fetching the slope value of PSU. - How to verify it Running regression and manual test Signed-off-by: Stephen Sun <stephens@nvidia.com>
1 parent 1d155b8 commit 23dad7c

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

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

+4-2
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ class Psu(FixedPsu):
220220
FAN_AMBIENT_TEMP = os.path.join(PSU_PATH, "thermal/fan_amb")
221221
AMBIENT_TEMP_CRITICAL_THRESHOLD = os.path.join(PSU_PATH, "config/amb_tmp_crit_limit")
222222
AMBIENT_TEMP_WARNING_THRESHOLD = os.path.join(PSU_PATH, "config/amb_tmp_warn_limit")
223-
PSU_POWER_SLOPE = os.path.join(PSU_PATH, "config/psu_power_slope")
223+
PSU_POWER_SLOPE = os.path.join(PSU_PATH, "config/psu{}_power_slope")
224224

225225
shared_led = None
226226

@@ -245,6 +245,8 @@ def __init__(self, psu_index):
245245
self.psu_temp = os.path.join(PSU_PATH, 'thermal/psu{}_temp'.format(self.index))
246246
self.psu_temp_threshold = os.path.join(PSU_PATH, 'thermal/psu{}_temp_max'.format(self.index))
247247

248+
self.psu_power_slope = os.path.join(PSU_PATH, self.PSU_POWER_SLOPE.format(self.index))
249+
248250
from .fan import PsuFan
249251
self._fan_list.append(PsuFan(psu_index, 1, self))
250252

@@ -529,7 +531,7 @@ def _get_psu_power_threshold(self, temp_threshold_path):
529531
if ambient_temp < temp_threshold:
530532
power_threshold = power_max_capacity
531533
else:
532-
slope = utils.read_int_from_file(Psu.PSU_POWER_SLOPE)
534+
slope = utils.read_int_from_file(self.psu_power_slope)
533535
power_threshold = power_max_capacity - (ambient_temp - temp_threshold) * slope
534536
if power_threshold <= 0:
535537
logger.log_warning('Got negative PSU power threshold {} for {}'.format(power_threshold, self.get_name()))

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ def test_psu_power_threshold(self, mock_read_int_from_file):
172172
psu.psu_power_max_capacity: 100000000,
173173
psu.AMBIENT_TEMP_CRITICAL_THRESHOLD: 65000,
174174
psu.AMBIENT_TEMP_WARNING_THRESHOLD: 55000,
175-
psu.PSU_POWER_SLOPE: 2000
175+
psu.psu_power_slope: 2000
176176
}
177177
normal_data = {
178178
psu.PORT_AMBIENT_TEMP: 55000,

0 commit comments

Comments
 (0)