Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Mellanox] Enhancement for fan led management #11

Closed
wants to merge 3 commits into from
Closed
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
52 changes: 26 additions & 26 deletions platform/mellanox/mlnx-platform-api/sonic_platform/chassis.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
from sonic_daemon_base.daemon_base import Logger
from os import listdir
from os.path import isfile, join
from glob import glob
import sys
import io
import re
Expand All @@ -29,6 +28,7 @@
MLNX_NUM_PSU = 2

GET_HWSKU_CMD = "sonic-cfggen -d -v DEVICE_METADATA.localhost.hwsku"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this one?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sku is still in use by other place, i think we should remove this one when another PR is merged.

GET_PLATFORM_CMD = "sonic-cfggen -d -v DEVICE_METADATA.localhost.platform"

EEPROM_CACHE_ROOT = '/var/cache/sonic/decode-syseeprom'
EEPROM_CACHE_FILE = 'syseeprom_cache'
Expand Down Expand Up @@ -60,6 +60,7 @@ def __init__(self):

# Initialize SKU name
self.sku_name = self._get_sku_name()
self.platform_name = self._get_platform_name()
mi = get_machine_info()
if mi is not None:
self.name = mi['onie_platform']
Expand All @@ -84,36 +85,29 @@ def initialize_psu(self):
# Initialize PSU list
self.psu_module = Psu
for index in range(MLNX_NUM_PSU):
psu = Psu(index, self.sku_name)
psu = Psu(index, self.platform_name)
self._psu_list.append(psu)


def initialize_fan(self):
from .device_data import DEVICE_DATA
from sonic_platform.fan import Fan
from sonic_platform.fan import FAN_PATH
self.fan_module = Fan
self.fan_path = FAN_PATH
# Initialize FAN list
multi_rotor_in_drawer = False
num_of_fan, num_of_drawer = self._extract_num_of_fans_and_fan_drawers()
multi_rotor_in_drawer = num_of_fan > num_of_drawer

# Fan's direction isn't supported on spectrum 1 devices for now
mst_dev_list = glob(MST_DEVICE_NAME_PATTERN)
if not mst_dev_list:
raise RuntimeError("Can't get chip type due to {} not found".format(MST_DEVICE_NAME_PATTERN))
m = re.search(MST_DEVICE_RE_PATTERN, mst_dev_list[0])
if m.group(1) == SPECTRUM1_CHIP_ID:
has_fan_dir = False
else:
has_fan_dir = True

for index in range(num_of_fan):
if multi_rotor_in_drawer:
fan = Fan(has_fan_dir, index, index/2, False, self.sku_name)
else:
fan = Fan(has_fan_dir, index, index, False, self.sku_name)
self._fan_list.append(fan)
from .fan_drawer import RealDrawer, VirtualDrawer

fan_data = DEVICE_DATA[self.platform_name]['fans']
drawer_num = fan_data['drawer_num']
drawer_type = fan_data['drawer_type']
fan_num_per_drawer = fan_data['fan_num_per_drawer']
drawer_ctor = RealDrawer if drawer_type == 'real' else VirtualDrawer
fan_index = 0
for drawer_index in range(drawer_num):
drawer = drawer_ctor(drawer_index, fan_data)
self._fan_drawer_list.append(drawer)
for index in range(fan_num_per_drawer):
fan = Fan(fan_index, drawer)
fan_index += 1
drawer._fan_list.append(fan)
self._fan_list.append(fan)


def initialize_sfp(self):
Expand Down Expand Up @@ -245,6 +239,12 @@ def _get_sku_name(self):
return out.rstrip('\n')


def _get_platform_name(self):
p = subprocess.Popen(GET_PLATFORM_CMD, shell=True, stdout=subprocess.PIPE)
out, err = p.communicate()
return out.rstrip('\n')


def _get_port_position_tuple_by_sku_name(self):
position_tuple = port_position_tuple_list[hwsku_dict_port[self.sku_name]]
return position_tuple
Expand Down
217 changes: 217 additions & 0 deletions platform/mellanox/mlnx-platform-api/sonic_platform/device_data.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,217 @@
DEVICE_DATA = {
'x86_64-mlnx_msn2700-r0': {
'thermal': {
'minimum_table': {
"p2c_trust": {"-127:40":13, "41:120":15},
"p2c_untrust": {"-127:25":13, "26:30":14 , "31:35":15, "36:120":16},
"c2p_trust": {"-127:20":13, "21:25":14 , "26:30":15, "31:120":16},
"c2p_untrust": {"-127:20":13, "21:25":14 , "26:30":15, "31:120":16},
"unk_trust": {"-127:20":13, "21:25":14 , "26:30":15, "31:120":16},
"unk_untrust": {"-127:20":13, "21:25":14 , "26:30":15, "31:120":16}
}
},
'fans': {
'drawer_num': 4,
'drawer_type': 'real',
'fan_num_per_drawer': 2,
'support_fan_direction': False,
'hot_swappable': True
},
'psus': {
'psu_num': 2,
'fan_num_per_psu': 1,
'hot_swappable': True,
'led_num': 1
}
},
'x86_64-mlnx_msn2740-r0': {
'thermal': {
'minimum_table': {
"p2c_trust": {"-127:120":13},
"p2c_untrust": {"-127:35":13, "36:40":14 , "41:120":15},
"c2p_trust": {"-127:120":13},
"c2p_untrust": {"-127:15":13, "16:30":14 , "31:35":15, "36:120":17},
"unk_trust": {"-127:120":13},
"unk_untrust": {"-127:15":13, "16:30":14 , "31:35":15, "36:120":17},
}
},
'fans': {
'drawer_num': 4,
'drawer_type': 'real',
'fan_num_per_drawer': 1,
'support_fan_direction': False,
'hot_swappable': True
},
'psus': {
'psu_num': 2,
'fan_num_per_psu': 1,
'hot_swappable': True,
'led_num': 1
}
},
'x86_64-mlnx_msn2100-r0': {
'thermal': {
'minimum_table': {
"p2c_trust": {"-127:120":12},
"p2c_untrust": {"-127:15":12, "16:25":13, "26:30":14, "31:35":15, "36:120":16},
"c2p_trust": {"-127:40":12, "41:120":13},
"c2p_untrust": {"-127:40":12, "41:120":13},
"unk_trust": {"-127:40":12, "41:120":13},
"unk_untrust": {"-127:15":12, "16:25":13, "26:30":14, "31:35":15, "36:120":16}
}
},
'fans': {
'drawer_num': 1,
'drawer_type': 'virtual',
'fan_num_per_drawer': 4,
'support_fan_direction': False,
'hot_swappable': False
},
'psus': {
'psu_num': 2,
'fan_num_per_psu': 1,
'hot_swappable': False,
'led_num': 2
}
},
'x86_64-mlnx_msn2410-r0': {
'thermal': {
'minimum_table': {
"p2c_trust": {"-127:40":13, "41:120":15},
"p2c_untrust": {"-127:25":13, "26:30":14 , "31:35":15, "36:120":16},
"c2p_trust": {"-127:20":13, "21:25":14 , "26:30":15, "31:120":16},
"c2p_untrust": {"-127:20":13, "21:25":14 , "26:30":15, "31:120":16},
"unk_trust": {"-127:20":13, "21:25":14 , "26:30":15, "31:120":16},
"unk_untrust": {"-127:20":13, "21:25":14 , "26:30":15, "31:120":16}
}
},
'fans': {
'drawer_num': 4,
'drawer_type': 'real',
'fan_num_per_drawer': 2,
'support_fan_direction': False,
'hot_swappable': True
},
'psus': {
'psu_num': 2,
'fan_num_per_psu': 1,
'hot_swappable': True,
'led_num': 1
}
},
'x86_64-mlnx_msn2010-r0': {
'thermal': {
'minimum_table': {
"p2c_trust": {"-127:120":12},
"p2c_untrust": {"-127:15":12, "16:20":13, "21:30":14, "31:35":15, "36:120":16},
"c2p_trust": {"-127:120":12},
"c2p_untrust": {"-127:20":12, "21:25":13 , "26:30":14, "31:35":15, "36:120":16},
"unk_trust": {"-127:120":12},
"unk_untrust": {"-127:15":12, "16:20":13 , "21:30":14, "31:35":15, "36:120":16}
}
},
'fans': {
'drawer_num': 1,
'drawer_type': 'virtual',
'fan_num_per_drawer': 4,
'support_fan_direction': False,
'hot_swappable': False
},
'psus': {
'psu_num': 2,
'fan_num_per_psu': 1,
'hot_swappable': False,
'led_num': 2
}
},
'x86_64-mlnx_msn3700-r0': {
'thermal': {
'minimum_table': {
"p2c_trust": {"-127:25":12, "26:40":13 , "41:120":14},
"p2c_untrust": {"-127:15":12, "16:30":13 , "31:35":14, "36:40":15, "41:120":16},
"c2p_trust": {"-127:25":12, "26:40":13 , "41:120":14},
"c2p_untrust": {"-127:25":12, "26:40":13 , "41:120":14},
"unk_trust": {"-127:25":12, "26:40":13 , "41:120":14},
"unk_untrust": {"-127:15":12, "16:30":13 , "31:35":14, "36:40":15, "41:120":16},
}
},
'fans': {
'drawer_num': 6,
'drawer_type': 'real',
'fan_num_per_drawer': 2,
'support_fan_direction': True,
'hot_swappable': True
},
'psus': {
'psu_num': 2,
'fan_num_per_psu': 1,
'hot_swappable': True,
'led_num': 1
}
},
'x86_64-mlnx_msn3700c-r0': {
'thermal': {
'minimum_table': {
"p2c_trust": {"-127:25":12, "26:40":13 , "41:120":14},
"p2c_untrust": {"-127:15":12, "16:30":13 , "31:35":14, "36:40":15, "41:120":16},
"c2p_trust": {"-127:25":12, "26:40":13 , "41:120":14},
"c2p_untrust": {"-127:25":12, "26:40":13 , "41:120":14},
"unk_trust": {"-127:25":12, "26:40":13 , "41:120":14},
"unk_untrust": {"-127:15":12, "16:30":13 , "31:35":14, "36:40":15, "41:120":16},
}
},
'fans': {
'drawer_num': 4,
'drawer_type': 'real',
'fan_num_per_drawer': 2,
'support_fan_direction': True,
'hot_swappable': True
},
'psus': {
'psu_num': 2,
'fan_num_per_psu': 1,
'hot_swappable': True,
'led_num': 1
}
},
'x86_64-mlnx_msn3800-r0': {
'thermal': {
'minimum_table': {
"p2c_trust": {"-127:35":12, "36:120":13},
"p2c_untrust": {"-127:0":12, "1:10":13 , "11:15":14, "16:20":15, "21:35":16, "36:120":17},
"c2p_trust": {"-127:30":12, "31:40":13 , "41:120":14},
"c2p_untrust": {"-127:20":12, "21:30":13 , "31:35":14, "36:40":15, "41:120":16},
"unk_trust": {"-127:30":12, "31:40":13 , "41:120":14},
"unk_untrust": {"-127:0":12, "1:10":13 , "11:15":14, "16:20":15, "21:35":16, "36:120":17},
}
},
'fans': {
'drawer_num': 3,
'drawer_type': 'real',
'fan_num_per_drawer': 1,
'support_fan_direction': True,
'hot_swappable': True
},
'psus': {
'psu_num': 2,
'fan_num_per_psu': 1,
'hot_swappable': True,
'led_num': 1
}
},
'x86_64-mlnx_msn4700-r0': {
'fans': {
'drawer_num': 6,
'drawer_type': 'real',
'fan_num_per_drawer': 2,
'support_fan_direction': True,
'hot_swappable': True
},
'psus': {
'psu_num': 2,
'fan_num_per_psu': 1,
'hot_swappable': True,
'led_num': 1
}
}
}
Loading