Skip to content

Commit 068094d

Browse files
Wirut GetbamrungLuiSzee
andauthored
[Celestica]: Add support for Blackstone platform (#262)
* [platform/cel]: add blackstone device * [device/celestica]: add blackstone device cel_blackstone-r0 * [device/celestica-blackstone]: disable services in pmon * [platform/cel-blackstone]: fix sonic_platform package_dir * [build]: fix bug for compile sonic-platform-common caused by enable pytest (sonic-net#7431) Co-authored-by: Shi Lei <shil@centecnetworks.com> * [platform/cel-blackstone]: fix missing debain files * [platform/cel-blackstone]: fix invalid init file * [platform/cel-blackstone]: fix invalid init file * [platform/cel-blackstone]: add rule to make all kernel module * [platform/cel-blackstone]: update mapping on fpga driver follow fpga spec * [platform/cel-blackstone]: enable switch_cpld init * [platform/cel-blackstone]: update platform_sensors follow ipmi sensors * [device/celestica-blackstone]: update psuutil follow BMC spec * [device/celestica-blackstone]: fix typo on eeprom plugin * [platform/cel-blackstone]: Update FPGA driver follow FPGA rev0.2 spec * [platform/cel-blackstone]: fix invalid param in FPGA driver * [platform/cel-blackstone]: fix invalid buses in FPGA driver * [platform/cel-blackstone]: update init script to enable i2c mapping * [device/celestica-blackstone]: disable cpld2 in switch cpld driver * [platform/cel-blackstone]: remove unuse command on switch CPLD driver * [platform/cel-blackstone]: remove cpld2 command from switch cpld driver * [platform/cel-blackstone]: change driver name from switch cpld to misc cpld * [platform/cel-blackstone]: remove unused variable in misc cpld driver * [platform/cel-blackstone]: remove unused coment on misc cpld driver * Revert "[device/celestica-blackstone]: fix typo on eeprom plugin" This reverts commit c133492. * Revert "[device/celestica-blackstone]: update psuutil follow BMC spec" This reverts commit 318b145. * [device/celestica-blackstone]: update psuutil follow lastest BMC spec * [device/celestica]: remove unuse files in plugin * [platform/cel-blackstone]: update misc cpld name device name * [platform/cel-blackstone]: update misc_cpld device name * [platform/cel-blackstone]: update misc_cpld driver version * [platform/cel-blackstone]: update misc_cpld init command * [platform/cel-blackstone]: update FPGA driver to support BMC I2C * [platform/cel-blackstone]: update FPGA driver to support BMC I2C * [platform/cel-blackstone]: update i2c devices driver init command * [device/celestica-blackstone]: Platform API code initialization * [device/celestica-blackstone]: update necessary chassis apis * [platform/cel-blackstone]: add platform api installer * [platform/cel]: update missing apis installer command * [device/celestica-blackstone]: update sfputil follow hw spec * [device/celestica-blackstone]: update skip_syseepromd config for pmon * [platform/cel-blackstone]: initialize platform APIs * [device/celestica-blackstone]: update necessary chassis apis * [platform/cel-blackstone]: add platform api installer * [platform/cel]: update missing apis installer command * [device/celestica-blackstone]: update sfputil follow hw spec * [device/celestica-blackstone]: update skip_syseepromd config for pmon * [platform/cel]: update api installer script Co-authored-by: LuiSzee <luisze9512@gmail.com> Co-authored-by: Shi Lei <shil@centecnetworks.com>
1 parent 7eb6abd commit 068094d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+8902
-2
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# name lanes alias index speed
2+
Ethernet0 1,2,3,4,5,6,7,8 OSFP1 1 400000
3+
Ethernet8 9,10,11,12,13,14,15,16 OSFP2 2 400000
4+
Ethernet16 17,18,19,20,21,22,23,24 OSFP3 3 400000
5+
Ethernet24 25,26,27,28,29,30,31,32 OSFP4 4 400000
6+
Ethernet32 33,34,35,36,37,38,39,40 OSFP5 5 400000
7+
Ethernet40 41,42,43,44,45,46,47,48 OSFP6 6 400000
8+
Ethernet48 49,50,51,52,53,54,55,56 OSFP7 7 400000
9+
Ethernet56 57,58,59,60,61,62,63,64 OSFP8 8 400000
10+
Ethernet64 65,66,67,68,69,70,71,72 OSFP9 9 400000
11+
Ethernet72 73,74,75,76,77,78,79,80 OSFP10 10 400000
12+
Ethernet80 81,82,83,84,85,86,87,88 OSFP11 11 400000
13+
Ethernet88 89,90,91,92,93,94,95,96 OSFP12 12 400000
14+
Ethernet96 97,98,99,100,101,102,103,104 OSFP13 13 400000
15+
Ethernet104 105,106,107,108,109,110,111,112 OSFP14 14 400000
16+
Ethernet112 113,114,115,116,117,118,119,120 OSFP15 15 400000
17+
Ethernet120 121,122,123,124,125,126,127,128 OSFP16 16 400000
18+
Ethernet128 129,130,131,132,133,134,135,136 OSFP17 17 400000
19+
Ethernet136 137,138,139,140,141,142,143,144 OSFP18 18 400000
20+
Ethernet144 145,146,147,148,149,150,151,152 OSFP19 19 400000
21+
Ethernet152 153,154,155,156,157,158,159,160 OSFP20 20 400000
22+
Ethernet160 161,162,163,164,165,166,167,168 OSFP21 21 400000
23+
Ethernet168 169,170,171,172,173,174,175,176 OSFP22 22 400000
24+
Ethernet176 177,178,179,180,181,182,183,184 OSFP23 23 400000
25+
Ethernet184 185,186,187,188,189,190,191,192 OSFP24 24 400000
26+
Ethernet192 193,194,195,196,197,198,199,200 OSFP25 25 400000
27+
Ethernet200 201,202,203,204,205,206,207,208 OSFP26 26 400000
28+
Ethernet208 209,210,211,212,213,214,215,216 OSFP27 27 400000
29+
Ethernet216 217,218,219,220,221,222,223,224 OSFP28 28 400000
30+
Ethernet224 225,226,227,228,229,230,231,232 OSFP29 29 400000
31+
Ethernet232 233,234,235,236,237,238,239,240 OSFP30 30 400000
32+
Ethernet240 241,242,243,244,245,246,247,248 OSFP31 31 400000
33+
Ethernet248 249,250,251,252,253,254,255,256 OSFP32 32 400000
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Blackstone t1
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
CONSOLE_SPEED=115200
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"chassis": {
3+
"Blackstone": {
4+
"component": {
5+
"BIOS": { },
6+
"CPLD1": { },
7+
"CPLD2": { },
8+
"CPLD3": { },
9+
"CPLD4": { }
10+
}
11+
}
12+
}
13+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env python
2+
3+
#############################################################################
4+
# Celestica Blackstone
5+
#
6+
# Platform and model specific eeprom subclass, inherits from the base class,
7+
# and provides the followings:
8+
# - the eeprom format definition
9+
# - specific encoder/decoder if there is special need
10+
#############################################################################
11+
12+
try:
13+
from sonic_eeprom import eeprom_tlvinfo
14+
except ImportError as e:
15+
raise ImportError(str(e) + "- required module not found")
16+
17+
18+
class board(eeprom_tlvinfo.TlvInfoDecoder):
19+
20+
def __init__(self, name, path, cpld_root, ro):
21+
self.eeprom_path = "/sys/class/i2c-adapter/i2c-0/0-0056/eeprom"
22+
super(board, self).__init__(self.eeprom_path, 0, '', True)
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
#############################################################################
2+
# Celestica Blackstone
3+
#
4+
# Platform-specific PSU status interface for SONiC
5+
# provides the followings:
6+
# - Number of PSUs
7+
# - Operational status of PSUs
8+
# - Presence status of PSUs
9+
#############################################################################
10+
11+
try:
12+
import sys
13+
import subprocess
14+
from sonic_psu.psu_base import PsuBase
15+
except ImportError as e:
16+
raise ImportError(str(e) + "- required module not found")
17+
18+
# BMC IPMI config
19+
IPMI_RAW_COMMAND = "ipmitool raw"
20+
IPMI_SENSOR_NETFN = "0x04"
21+
IPMI_EVENT_CMD = "0x2b"
22+
IPMI_SENSOR_MAPPING = {
23+
1: "9",
24+
2: "10"
25+
}
26+
IPMI_PSU_PRESENCE_BIT = 0
27+
IPMI_PSU_FAILURE_BIT = 1
28+
IPMI_PSU_INPUT_LOST_BIT = 3
29+
30+
# PSUs config
31+
NUM_OF_PSUS = 2
32+
33+
34+
class PsuUtil(PsuBase):
35+
"""Platform-specific PSUutil class"""
36+
37+
def __init__(self):
38+
PsuBase.__init__(self)
39+
40+
def _run_command(self, command):
41+
proc = subprocess.Popen(
42+
command, shell=True, universal_newlines=True, stdout=subprocess.PIPE)
43+
(out, err) = proc.communicate()
44+
if proc.returncode != 0:
45+
print("PSUutil Error: cannot get PSUs data from BMC")
46+
sys.exit(proc.returncode)
47+
48+
return out
49+
50+
def get_num_psus(self):
51+
"""
52+
Retrieves the number of PSUs available on the device
53+
:return: An integer, the number of PSUs available on the device
54+
"""
55+
return NUM_OF_PSUS
56+
57+
def get_psu_status(self, index):
58+
"""
59+
Retrieves the operational status of power supply unit (PSU) defined
60+
by 1-based index <index>
61+
:param index: An integer, 1-based index of the PSU of which to query status
62+
:return: Boolean, True if PSU is operating properly, False if PSU is faulty
63+
"""
64+
psu_status_cmd = " ".join(
65+
[IPMI_RAW_COMMAND, IPMI_SENSOR_NETFN, IPMI_EVENT_CMD, IPMI_SENSOR_MAPPING.get(index)])
66+
res = self._run_command(psu_status_cmd)
67+
68+
status_byte = res.split()[1]
69+
failure_detected = (int(status_byte, 16) >> IPMI_PSU_FAILURE_BIT) & 1
70+
input_lost = (int(status_byte, 16) >> IPMI_PSU_INPUT_LOST_BIT) & 1
71+
72+
return False if (failure_detected or input_lost) else True
73+
74+
def get_psu_presence(self, index):
75+
"""
76+
Retrieves the presence status of power supply unit (PSU) defined
77+
by 1-based index <index>
78+
:param index: An integer, 1-based index of the PSU of which to query status
79+
:return: Boolean, True if PSU is plugged, False if not
80+
"""
81+
psu_status_cmd = " ".join(
82+
[IPMI_RAW_COMMAND, IPMI_SENSOR_NETFN, IPMI_EVENT_CMD, IPMI_SENSOR_MAPPING.get(index)])
83+
84+
res = self._run_command(psu_status_cmd)
85+
status_byte = res.split()[1]
86+
presence = (int(status_byte, 16) >> IPMI_PSU_PRESENCE_BIT) & 1
87+
88+
return presence or False
Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
#!/usr/bin/env python
2+
3+
#############################################################################
4+
# Celestica Blackstone
5+
#
6+
# Platform and model specific sfp subclass, inherits from the base class,
7+
# and provides the followings:
8+
# - sfputil show presence
9+
#############################################################################
10+
11+
try:
12+
import time
13+
from os import path
14+
from sonic_sfp.sfputilbase import SfpUtilBase
15+
except ImportError as e:
16+
raise ImportError('%s - required module not found' % str(e))
17+
18+
19+
class SfpUtil(SfpUtilBase):
20+
'''Platform-specific SfpUtil class'''
21+
22+
PORT_START = 1
23+
PORT_END = 32
24+
25+
QSFPDD_PORT_START = 1
26+
QSFPDD_PORT_END = 32
27+
EEPROM_OFFSET = 15
28+
29+
PORT_INFO_PATH = '/sys/devices/platform/cls-xcvr'
30+
_port_to_eeprom_mapping = {}
31+
_port_to_i2cbus_mapping = {}
32+
33+
@property
34+
def port_start(self):
35+
return self.PORT_START
36+
37+
@property
38+
def port_end(self):
39+
return self.PORT_END
40+
41+
@property
42+
def osfp_ports(self):
43+
return list(range(self.QSFPDD_PORT_START, self.QSFPDD_PORT_END + 1))
44+
45+
@property
46+
def port_to_eeprom_mapping(self):
47+
return self._port_to_eeprom_mapping
48+
49+
@property
50+
def port_to_i2cbus_mapping(self):
51+
return self._port_to_i2cbus_mapping
52+
53+
def get_port_name(self, port_num):
54+
return 'QSFPDD{}'.format(port_num) if port_num in self.osfp_ports else 'SFP+{}' + str(port_num - self.QSFPDD_PORT_END)
55+
56+
def __init__(self):
57+
# Override port_to_eeprom_mapping for class initialization
58+
eeprom_path = '/sys/bus/i2c/devices/i2c-{0}/{0}-0050/eeprom'
59+
60+
for x in range(self.PORT_START, self.PORT_END+1):
61+
self.port_to_i2cbus_mapping[x] = (x + self.EEPROM_OFFSET) - 1
62+
self.port_to_eeprom_mapping[x] = eeprom_path.format(
63+
self.port_to_i2cbus_mapping[x])
64+
SfpUtilBase.__init__(self)
65+
66+
def _read_val(self, path):
67+
ret = ''
68+
try:
69+
with open(path, 'r') as f:
70+
ret = f.readline()
71+
except IOError as e:
72+
print('Error: unable to open file: %s' % str(e))
73+
return ret
74+
75+
def _write_val(self, path, val):
76+
try:
77+
with open(path, 'w') as f:
78+
f.write(val)
79+
except IOError as e:
80+
print('Error: unable to write file: %s' % str(e))
81+
return False
82+
return True
83+
84+
def get_presence(self, port_num):
85+
86+
# Check for invalid port_num
87+
if port_num not in list(range(self.port_start, self.port_end + 1)):
88+
return False
89+
90+
# Get path for access port presence status
91+
port_name = self.get_port_name(port_num)
92+
sysfs_filename = 'qsfp_modprsL' if port_num in self.osfp_ports else 'sfp_modabs'
93+
94+
# Read status
95+
status = self._read_val(path.join(
96+
self.PORT_INFO_PATH, port_name, sysfs_filename))
97+
98+
# Module present is active low
99+
return True if int(status) == 0 else False
100+
101+
def get_low_power_mode(self, port_num):
102+
103+
# Check for invalid QSFP-DD port_num
104+
if port_num not in self.osfp_ports:
105+
return False
106+
107+
# Read status
108+
port_name = self.get_port_name(port_num)
109+
status = self._read_val(path.join(
110+
self.PORT_INFO_PATH, port_name, 'qsfp_lpmode'))
111+
112+
# LPmode is active high
113+
return True if int(status, 16) == 1 else False
114+
115+
def set_low_power_mode(self, port_num, lpmode):
116+
117+
# Check for invalid QSFP-DD port_num
118+
if port_num not in self.osfp_ports:
119+
return False
120+
121+
return self._write_val(path.join(self.PORT_INFO_PATH, self.get_port_name(port_num), 'qsfp_lpmode'), hex(lpmode))
122+
123+
def reset(self, port_num):
124+
125+
# Check for invalid QSFP-DD port_num
126+
if port_num not in self.osfp_ports:
127+
return False
128+
129+
sysfs_path = path.join(self.PORT_INFO_PATH,
130+
self.get_port_name(port_num), 'qsfp_resetL')
131+
132+
self._write_val(sysfs_path, hex(0))
133+
134+
# Sleep 1 second to allow it to settle
135+
time.sleep(1)
136+
137+
# Flip the bit back high and write back to the register to take port out of reset
138+
self._write_val(sysfs_path, hex(1))
139+
140+
return True
141+
142+
def get_transceiver_change_event(self, timeout=0):
143+
'''
144+
TBD: When the feature request.
145+
'''
146+
raise NotImplementedError
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"skip_fancontrol": true,
3+
"skip_ledd": true,
4+
"skip_pcied": true,
5+
"skip_psud": true,
6+
"skip_syseepromd": false,
7+
"skip_thermalctld": true,
8+
"skip_xcvrd": true
9+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
from . import chassis
2+
from . import platform

0 commit comments

Comments
 (0)