Skip to content

Commit

Permalink
[Mellanox] Support per PSU slope value for PSU power threshold (sonic…
Browse files Browse the repository at this point in the history
…-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>
  • Loading branch information
stephenxs authored and mssonicbld committed Feb 17, 2023
1 parent 1d155b8 commit 23dad7c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions platform/mellanox/mlnx-platform-api/sonic_platform/psu.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ class Psu(FixedPsu):
FAN_AMBIENT_TEMP = os.path.join(PSU_PATH, "thermal/fan_amb")
AMBIENT_TEMP_CRITICAL_THRESHOLD = os.path.join(PSU_PATH, "config/amb_tmp_crit_limit")
AMBIENT_TEMP_WARNING_THRESHOLD = os.path.join(PSU_PATH, "config/amb_tmp_warn_limit")
PSU_POWER_SLOPE = os.path.join(PSU_PATH, "config/psu_power_slope")
PSU_POWER_SLOPE = os.path.join(PSU_PATH, "config/psu{}_power_slope")

shared_led = None

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

self.psu_power_slope = os.path.join(PSU_PATH, self.PSU_POWER_SLOPE.format(self.index))

from .fan import PsuFan
self._fan_list.append(PsuFan(psu_index, 1, self))

Expand Down Expand Up @@ -529,7 +531,7 @@ def _get_psu_power_threshold(self, temp_threshold_path):
if ambient_temp < temp_threshold:
power_threshold = power_max_capacity
else:
slope = utils.read_int_from_file(Psu.PSU_POWER_SLOPE)
slope = utils.read_int_from_file(self.psu_power_slope)
power_threshold = power_max_capacity - (ambient_temp - temp_threshold) * slope
if power_threshold <= 0:
logger.log_warning('Got negative PSU power threshold {} for {}'.format(power_threshold, self.get_name()))
Expand Down
2 changes: 1 addition & 1 deletion platform/mellanox/mlnx-platform-api/tests/test_psu.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ def test_psu_power_threshold(self, mock_read_int_from_file):
psu.psu_power_max_capacity: 100000000,
psu.AMBIENT_TEMP_CRITICAL_THRESHOLD: 65000,
psu.AMBIENT_TEMP_WARNING_THRESHOLD: 55000,
psu.PSU_POWER_SLOPE: 2000
psu.psu_power_slope: 2000
}
normal_data = {
psu.PORT_AMBIENT_TEMP: 55000,
Expand Down

0 comments on commit 23dad7c

Please sign in to comment.