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