Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
'drawer_num': 4,
'drawer_type': 'real',
'fan_num_per_drawer': 2,
'support_fan_direction': False,
'support_fan_direction': True,
'hot_swappable': True
},
'psus': {
Expand All @@ -31,7 +31,7 @@
'drawer_num': 4,
'drawer_type': 'real',
'fan_num_per_drawer': 1,
'support_fan_direction': False,
'support_fan_direction': True,
'hot_swappable': True
},
'psus': {
Expand All @@ -52,7 +52,7 @@
'drawer_num': 1,
'drawer_type': 'virtual',
'fan_num_per_drawer': 4,
'support_fan_direction': False,
'support_fan_direction': True,
'hot_swappable': False
},
'psus': {
Expand All @@ -73,7 +73,7 @@
'drawer_num': 4,
'drawer_type': 'real',
'fan_num_per_drawer': 2,
'support_fan_direction': False,
'support_fan_direction': True,
'hot_swappable': True
},
'psus': {
Expand All @@ -94,7 +94,7 @@
'drawer_num': 1,
'drawer_type': 'virtual',
'fan_num_per_drawer': 4,
'support_fan_direction': False,
'support_fan_direction': True,
'hot_swappable': False
},
'psus': {
Expand Down
6 changes: 4 additions & 2 deletions platform/mellanox/mlnx-platform-api/sonic_platform/fan.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@

FAN_PATH = "/var/run/hw-management/thermal/"
CONFIG_PATH = "/var/run/hw-management/config"
# fan_dir isn't supported on Spectrum 1. It is supported on Spectrum 2 and later switches
FAN_DIR = "/var/run/hw-management/system/fan_dir"

FAN_DIR = "/var/run/hw-management/thermal/fan{}_dir"
FAN_DIR_VALUE_EXHAUST = 0
FAN_DIR_VALUE_INTAKE = 1
COOLING_STATE_PATH = "/var/run/hw-management/thermal/cooling_cur_state"

class Fan(FanBase):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from sonic_platform_base.fan_drawer_base import FanDrawerBase
from sonic_platform_base.fan_base import FanBase
from .led import FanLed, SharedLed
from .utils import read_int_from_file
except ImportError as e:
raise ImportError (str(e) + "- required module not found")

Expand Down Expand Up @@ -51,14 +52,14 @@ def get_direction(self):
return FanBase.FAN_DIRECTION_NOT_APPLICABLE

try:
from .fan import FAN_DIR
with open(FAN_DIR, 'r') as fan_dir:
fan_dir_bits = int(fan_dir.read())
fan_mask = 1 << self._index - 1
if fan_dir_bits & fan_mask:
return FanBase.FAN_DIRECTION_INTAKE
else:
return FanBase.FAN_DIRECTION_EXHAUST
from .fan import FAN_DIR, FAN_DIR_VALUE_INTAKE, FAN_DIR_VALUE_EXHAUST
fan_dir = read_int_from_file(FAN_DIR.format(self._index), raise_exception=True)
if fan_dir == FAN_DIR_VALUE_INTAKE:
return FanBase.FAN_DIRECTION_INTAKE
elif fan_dir == FAN_DIR_VALUE_EXHAUST:
return FanBase.FAN_DIRECTION_EXHAUST
else:
raise RuntimeError("Got wrong value {} for fan direction {}".format(fan_dir, self._index))
except (ValueError, IOError) as e:
raise RuntimeError("Failed to read fan direction status to {}".format(repr(e)))

Expand Down