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

[Celestica]: Add support for Blackstone platform #262

Merged
Merged
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
a321385
[platform/cel]: add blackstone device
Sep 14, 2021
09dd00e
[device/celestica]: add blackstone device cel_blackstone-r0
Sep 14, 2021
545b41e
[device/celestica-blackstone]: disable services in pmon
Sep 14, 2021
e05d0dd
[platform/cel-blackstone]: fix sonic_platform package_dir
Sep 15, 2021
de61c7a
[build]: fix bug for compile sonic-platform-common caused by enable p…
LuiSzee Apr 28, 2021
e1bd6eb
[platform/cel-blackstone]: fix missing debain files
Sep 15, 2021
f607f61
[platform/cel-blackstone]: fix invalid init file
Sep 15, 2021
0cf6ff2
[platform/cel-blackstone]: fix invalid init file
Sep 15, 2021
4b6efef
[platform/cel-blackstone]: add rule to make all kernel module
Sep 15, 2021
7fb722e
[platform/cel-blackstone]: diable incomplete init command
Sep 15, 2021
1deee18
[platform/cel-blackstone]: update mapping on fpga driver follow fpga …
Sep 17, 2021
469d4fb
[platform/cel-blackstone]: enable switch_cpld init
Sep 21, 2021
e481061
[platform/cel-blackstone]: update platform_sensors follow ipmi sensors
Sep 24, 2021
318b145
[device/celestica-blackstone]: update psuutil follow BMC spec
Sep 24, 2021
c133492
[device/celestica-blackstone]: fix typo on eeprom plugin
Sep 24, 2021
4d90910
[platform/cel-blackstone]: Update FPGA driver follow FPGA rev0.2 spec
Sep 27, 2021
487f0b8
[platform/cel-blackstone]: fix invalid param in FPGA driver
Sep 27, 2021
62e6580
[platform/cel-blackstone]: fix invalid buses in FPGA driver
Sep 27, 2021
f7b0da1
[platform/cel-blackstone]: update init script to enable i2c mapping
Sep 27, 2021
118fa02
[device/celestica-blackstone]: disable cpld2 in switch cpld driver
Sep 28, 2021
b580af1
[platform/cel-blackstone]: remove unuse command on switch CPLD driver
Sep 28, 2021
5aa86cb
[platform/cel-blackstone]: remove cpld2 command from switch cpld driver
Sep 28, 2021
93d287b
[platform/cel-blackstone]: change driver name from switch cpld to mis…
Sep 28, 2021
9077d96
[platform/cel-blackstone]: remove unused variable in misc cpld driver
Sep 28, 2021
656c763
[platform/cel-blackstone]: remove unused coment on misc cpld driver
Sep 29, 2021
deef22e
Merge pull request #1779 from mudsut4ke/202012.7eb6abdc_blackstone-de…
Sep 29, 2021
ba29efb
Revert "[device/celestica-blackstone]: fix typo on eeprom plugin"
Sep 29, 2021
775b3ff
Revert "[device/celestica-blackstone]: update psuutil follow BMC spec"
Sep 29, 2021
d8bf94e
[device/celestica-blackstone]: update psuutil follow lastest BMC spec
Sep 29, 2021
58b2cfa
[device/celestica]: remove unuse files in plugin
Oct 7, 2021
c3b379f
[platform/cel-blackstone]: update misc cpld name device name
Oct 27, 2021
1cafe03
[platform/cel-blackstone]: update FPGA driver to support BMC I2C
Oct 27, 2021
cb591d2
[device/celestica-blackstone]: Platform API code initialization
Nov 5, 2021
490756d
[platform/cel-blackstone]: initialize platform APIs
Nov 11, 2021
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
@@ -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
1 change: 1 addition & 0 deletions device/celestica/x86_64-cel_blackstone-r0/default_sku
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Blackstone t1
1 change: 1 addition & 0 deletions device/celestica/x86_64-cel_blackstone-r0/installer.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CONSOLE_SPEED=115200
13 changes: 13 additions & 0 deletions device/celestica/x86_64-cel_blackstone-r0/platform_components.json
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 device/celestica/x86_64-cel_blackstone-r0/plugins/eeprom.py
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 device/celestica/x86_64-cel_blackstone-r0/plugins/psuutil.py
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
235 changes: 235 additions & 0 deletions device/celestica/x86_64-cel_blackstone-r0/plugins/sfputil.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,235 @@
#!/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:
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)

try:
import time
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 = 33
zswallow marked this conversation as resolved.
Show resolved Hide resolved
QSFP_PORT_START = 1
QSFP_PORT_END = 32

EEPROM_OFFSET = 1
PORT_INFO_PATH = '/sys/devices/platform/cls-xcvr'

_port_name = ""
_port_to_eeprom_mapping = {}
_port_to_i2cbus_mapping = {
1: 17,
2: 18,
3: 15,
4: 16,
5: 21,
6: 20,
7: 38,
8: 19,
9: 35,
10: 34,
11: 37,
12: 33,
13: 32,
14: 36,
15: 22,
16: 31,
17: 24,
18: 30,
19: 27,
20: 23,
21: 28,
22: 25,
23: 12,
24: 29,
25: 26,
26: 13,
27: 7,
28: 14,
29: 9,
30: 11,
31: 10,
32: 8,
33: 1,
34: 2
}

@property
def port_start(self):
return self.PORT_START

@property
def port_end(self):
return self.PORT_END

@property
def qsfp_ports(self):
return []

@property
def osfp_ports(self):
return list(range(self.QSFP_PORT_START, self.QSFP_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):
if port_num in self.osfp_ports:
self._port_name = "QSFPDD" + str(port_num - self.QSFP_PORT_START + 1)
else:
self._port_name = "SFP" + str(port_num)
return self._port_name

# def get_eeprom_dom_raw(self, port_num):
# if port_num in self.osfp_ports:
# # QSFP DOM EEPROM is also at addr 0x50 and thus also stored in eeprom_ifraw
# return None
# else:
# # Read dom eeprom at addr 0x51
# return self._read_eeprom_devid(port_num, self.DOM_EEPROM_ADDR, 256)

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_eeprom_mapping[x] = eeprom_path.format(self.port_to_i2cbus_mapping[x])
SfpUtilBase.__init__(self)

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"
reg_path = "/".join([self.PORT_INFO_PATH, port_name, sysfs_filename])

# Read status
try:
reg_file = open(reg_path)
content = reg_file.readline().rstrip()
reg_value = int(content)
except IOError as e:
print("Error: unable to open file: %s" % str(e))
return False

# Module present is active low
if reg_value == 0:
return True

return False

def get_low_power_mode(self, port_num):
# Check for invalid QSFP port_num
if port_num not in self.osfp_ports:
return False

try:
port_name = self.get_port_name(port_num)
reg_file = open(
"/".join([self.PORT_INFO_PATH, port_name, "qsfp_lpmode"]), "r+")
except IOError as e:
print("Error: unable to open file: %s" % str(e))
return False

# Read status
content = reg_file.readline().rstrip()
reg_value = int(content, 16)
# ModPrsL is active low
if reg_value == 0:
return False

return True

def set_low_power_mode(self, port_num, lpmode):
# Check for invalid QSFP port_num
if port_num not in self.osfp_ports:
return False

try:
port_name = self.get_port_name(port_num)
reg_file = open(
"/".join([self.PORT_INFO_PATH, port_name, "qsfp_lpmode"]), "r+")
except IOError as e:
print("Error: unable to open file: %s" % str(e))
return False

content = hex(lpmode)

reg_file.seek(0)
reg_file.write(content)
reg_file.close()

return True

def reset(self, port_num):
# Check for invalid QSFP port_num
if port_num not in self.osfp_ports:
return False

try:
port_name = self.get_port_name(port_num)
reg_file = open(
"/".join([self.PORT_INFO_PATH, port_name, "qsfp_resetL"]), "w")
except IOError as e:
print("Error: unable to open file: %s" % str(e))
return False

# Convert our register value back to a hex string and write back
reg_file.seek(0)
reg_file.write(hex(0))
reg_file.close()

# 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
try:
reg_file = open(
"/".join([self.PORT_INFO_PATH, port_name, "qsfp_resetL"]), "w")
except IOError as e:
print("Error: unable to open file: %s" % str(e))
return False

reg_file.seek(0)
reg_file.write(hex(1))
reg_file.close()

return True

def get_transceiver_change_event(self, timeout=0):
"""
TBD: When the feature request.
"""
raise NotImplementedError
Loading