[Mellanox] Adopt single way to get fan direction for all ASIC types (#7386)
#### Why I did it Adopt a single way to get fan direction for all ASIC types. It depends on hw-mgmt V.7.0010.2000.2303. Depends on https://github.com/Azure/sonic-buildimage/pull/7419 #### How I did it Originally, the get_direction was implemented by fetching and parsing `/var/run/hw-management/system/fan_dir` on the Spectrum-2 and the Spectrum-3 systems. It isn't supported on the Spectrum system. Now, it is implemented by fetching `/var/run/hw-management/thermal/fanX_dir` for all the platforms. Signed-off-by: Stephen Sun <stephens@nvidia.com>
This commit is contained in:
parent
853c214951
commit
b2286a24dc
@ -10,7 +10,7 @@ DEVICE_DATA = {
|
|||||||
'drawer_num': 4,
|
'drawer_num': 4,
|
||||||
'drawer_type': 'real',
|
'drawer_type': 'real',
|
||||||
'fan_num_per_drawer': 2,
|
'fan_num_per_drawer': 2,
|
||||||
'support_fan_direction': False,
|
'support_fan_direction': True,
|
||||||
'hot_swappable': True
|
'hot_swappable': True
|
||||||
},
|
},
|
||||||
'psus': {
|
'psus': {
|
||||||
@ -31,7 +31,7 @@ DEVICE_DATA = {
|
|||||||
'drawer_num': 4,
|
'drawer_num': 4,
|
||||||
'drawer_type': 'real',
|
'drawer_type': 'real',
|
||||||
'fan_num_per_drawer': 1,
|
'fan_num_per_drawer': 1,
|
||||||
'support_fan_direction': False,
|
'support_fan_direction': True,
|
||||||
'hot_swappable': True
|
'hot_swappable': True
|
||||||
},
|
},
|
||||||
'psus': {
|
'psus': {
|
||||||
@ -52,7 +52,7 @@ DEVICE_DATA = {
|
|||||||
'drawer_num': 1,
|
'drawer_num': 1,
|
||||||
'drawer_type': 'virtual',
|
'drawer_type': 'virtual',
|
||||||
'fan_num_per_drawer': 4,
|
'fan_num_per_drawer': 4,
|
||||||
'support_fan_direction': False,
|
'support_fan_direction': True,
|
||||||
'hot_swappable': False
|
'hot_swappable': False
|
||||||
},
|
},
|
||||||
'psus': {
|
'psus': {
|
||||||
@ -73,7 +73,7 @@ DEVICE_DATA = {
|
|||||||
'drawer_num': 4,
|
'drawer_num': 4,
|
||||||
'drawer_type': 'real',
|
'drawer_type': 'real',
|
||||||
'fan_num_per_drawer': 2,
|
'fan_num_per_drawer': 2,
|
||||||
'support_fan_direction': False,
|
'support_fan_direction': True,
|
||||||
'hot_swappable': True
|
'hot_swappable': True
|
||||||
},
|
},
|
||||||
'psus': {
|
'psus': {
|
||||||
@ -94,7 +94,7 @@ DEVICE_DATA = {
|
|||||||
'drawer_num': 1,
|
'drawer_num': 1,
|
||||||
'drawer_type': 'virtual',
|
'drawer_type': 'virtual',
|
||||||
'fan_num_per_drawer': 4,
|
'fan_num_per_drawer': 4,
|
||||||
'support_fan_direction': False,
|
'support_fan_direction': True,
|
||||||
'hot_swappable': False
|
'hot_swappable': False
|
||||||
},
|
},
|
||||||
'psus': {
|
'psus': {
|
||||||
|
@ -22,8 +22,10 @@ PWM_MAX = 255
|
|||||||
|
|
||||||
FAN_PATH = "/var/run/hw-management/thermal/"
|
FAN_PATH = "/var/run/hw-management/thermal/"
|
||||||
CONFIG_PATH = "/var/run/hw-management/config"
|
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"
|
COOLING_STATE_PATH = "/var/run/hw-management/thermal/cooling_cur_state"
|
||||||
|
|
||||||
class Fan(FanBase):
|
class Fan(FanBase):
|
||||||
|
@ -14,6 +14,7 @@ try:
|
|||||||
from sonic_platform_base.fan_drawer_base import FanDrawerBase
|
from sonic_platform_base.fan_drawer_base import FanDrawerBase
|
||||||
from sonic_platform_base.fan_base import FanBase
|
from sonic_platform_base.fan_base import FanBase
|
||||||
from .led import FanLed, SharedLed
|
from .led import FanLed, SharedLed
|
||||||
|
from .utils import read_int_from_file
|
||||||
except ImportError as e:
|
except ImportError as e:
|
||||||
raise ImportError (str(e) + "- required module not found")
|
raise ImportError (str(e) + "- required module not found")
|
||||||
|
|
||||||
@ -51,14 +52,14 @@ class MellanoxFanDrawer(FanDrawerBase):
|
|||||||
return FanBase.FAN_DIRECTION_NOT_APPLICABLE
|
return FanBase.FAN_DIRECTION_NOT_APPLICABLE
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from .fan import FAN_DIR
|
from .fan import FAN_DIR, FAN_DIR_VALUE_INTAKE, FAN_DIR_VALUE_EXHAUST
|
||||||
with open(FAN_DIR, 'r') as fan_dir:
|
fan_dir = read_int_from_file(FAN_DIR.format(self._index), raise_exception=True)
|
||||||
fan_dir_bits = int(fan_dir.read())
|
if fan_dir == FAN_DIR_VALUE_INTAKE:
|
||||||
fan_mask = 1 << self._index - 1
|
|
||||||
if fan_dir_bits & fan_mask:
|
|
||||||
return FanBase.FAN_DIRECTION_INTAKE
|
return FanBase.FAN_DIRECTION_INTAKE
|
||||||
else:
|
elif fan_dir == FAN_DIR_VALUE_EXHAUST:
|
||||||
return FanBase.FAN_DIRECTION_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:
|
except (ValueError, IOError) as e:
|
||||||
raise RuntimeError("Failed to read fan direction status to {}".format(repr(e)))
|
raise RuntimeError("Failed to read fan direction status to {}".format(repr(e)))
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user