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

[device/Celestica] Introduce Silverstone2 platform module #4451

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# name lanes alias index speed
Ethernet0 33,34,35,36,37,38,39,40 QSFPDD1 1 400000
Ethernet8 41,42,43,44,45,46,47,48 QSFPDD2 2 400000
Ethernet16 49,50,51,52,53,54,55,56 QSFPDD3 3 400000
Ethernet24 57,58,59,60,61,62,63,64 QSFPDD4 4 400000
Ethernet32 65,66,67,68,69,70,71,72 QSFPDD5 5 400000
Ethernet40 73,74,75,76,77,78,79,80 QSFPDD6 6 400000
Ethernet48 81,82,83,84,85,86,87,88 QSFPDD7 7 400000
Ethernet56 89,90,91,92,93,94,95,96 QSFPDD8 8 400000
Ethernet64 1,2,3,4,5,6,7,8 QSFPDD9 9 400000
Ethernet72 9,10,11,12,13,14,15,16 QSFPDD10 10 400000
Ethernet80 17,18,19,20,21,22,23,24 QSFPDD11 11 400000
Ethernet88 25,26,27,28,29,30,31,32 QSFPDD12 12 400000
Ethernet96 97,98,99,100,101,102,103,104 QSFPDD13 13 400000
Ethernet104 105,106,107,108,109,110,111,112 QSFPDD14 14 400000
Ethernet112 113,114,115,116,117,118,119,120 QSFPDD15 15 400000
Ethernet120 121,122,123,124,125,126,127,128 QSFPDD16 16 400000
Ethernet128 129,130,131,132,133,134,135,136 QSFPDD17 17 400000
Ethernet136 137,138,139,140,141,142,143,144 QSFPDD18 18 400000
Ethernet144 145,146,147,148,149,150,151,152 QSFPDD19 19 400000
Ethernet152 153,154,155,156,157,158,159,160 QSFPDD20 20 400000
Ethernet160 225,226,227,228,229,230,231,232 QSFPDD21 21 400000
Ethernet168 233,234,235,236,237,238,239,240 QSFPDD22 22 400000
Ethernet176 241,242,243,244,245,246,247,248 QSFPDD23 23 400000
Ethernet184 249,250,251,252,253,254,255,256 QSFPDD24 24 400000
Ethernet192 161,162,163,164,165,166,167,168 QSFPDD25 25 400000
Ethernet200 169,170,171,172,173,174,175,176 QSFPDD26 26 400000
Ethernet208 177,178,179,180,181,182,183,184 QSFPDD27 27 400000
Ethernet216 185,186,187,188,189,190,191,192 QSFPDD28 28 400000
Ethernet224 193,194,195,196,197,198,199,200 QSFPDD29 29 400000
Ethernet232 201,202,203,204,205,206,207,208 QSFPDD30 30 400000
Ethernet240 209,210,211,212,213,214,215,216 QSFPDD31 31 400000
Ethernet248 217,218,219,220,221,222,223,224 QSFPDD32 32 400000
1 change: 1 addition & 0 deletions device/celestica/x86_64-cel_silverstone2-r0/default_sku
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Silverstone2 t1
1 change: 1 addition & 0 deletions device/celestica/x86_64-cel_silverstone2-r0/installer.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CONSOLE_SPEED=115200
23 changes: 23 additions & 0 deletions device/celestica/x86_64-cel_silverstone2-r0/plugins/eeprom.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env python

#############################################################################
# Celestica Silverstone2
#
# 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, 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)

91 changes: 91 additions & 0 deletions device/celestica/x86_64-cel_silverstone2-r0/plugins/psuutil.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
#!/usr/bin/env python

import os.path
import subprocess
import sys
import re

try:
from sonic_psu.psu_base import PsuBase
except ImportError as e:
raise ImportError (str(e) + "- required module not found")


class PsuUtil(PsuBase):
"""Platform-specific PSUutil class"""

def __init__(self):
self.ipmi_raw = "ipmitool raw 0x4 0x2d"
self.psu1_id = "0x2f"
self.psu2_id = "0x39"
PsuBase.__init__(self)

def run_command(self, command):
proc = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE)
(out, err) = proc.communicate()

if proc.returncode != 0:
sys.exit(proc.returncode)

return out

def find_value(self, in_string):
result = re.search("^.+ ([0-9a-f]{2}) .+$", in_string)
if result:
return result.group(1)
else:
return result

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 2

def get_psu_status(self, index):
"""
Retrieves the oprational 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
"""
if index is None:
return False

psu_id = self.psu1_id if index == 1 else self.psu2_id
res_string = self.run_command(self.ipmi_raw + ' ' + psu_id)
status_byte = self.find_value(res_string)

if status_byte is None:
return False

failure_detected = (int(status_byte, 16) >> 1) & 1
input_lost = (int(status_byte, 16) >> 3) & 1
if failure_detected or input_lost:
return False
else:
return 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
"""
if index is None:
return False

psu_id = self.psu1_id if index == 1 else self.psu2_id
res_string = self.run_command(self.ipmi_raw + ' ' + psu_id)
status_byte = self.find_value(res_string)

if status_byte is None:
return False

presence = ( int(status_byte, 16) >> 0 ) & 1
if presence:
return True
else:
return False
217 changes: 217 additions & 0 deletions device/celestica/x86_64-cel_silverstone2-r0/plugins/sfputil.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,217 @@
#!/usr/bin/env python
#
# Platform-specific SFP transceiver interface for SONiC
# This plugin supports QSFP-DD, QSFP and SFP.

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 = 34
OSFP_PORT_START = 1
OSFP_PORT_END = 32
SFP_PORT_START = 33
SFP_PORT_END = 34

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

_port_name = ""
_port_to_eeprom_mapping = {}
_port_to_i2cbus_mapping = {
1: 15,
2: 16,
3: 17,
4: 18,
5: 19,
6: 20,
7: 21,
8: 22,
9: 23,
10: 24,
11: 25,
12: 26,
13: 27,
14: 28,
15: 29,
16: 30,
17: 31,
18: 32,
19: 33,
20: 34,
21: 35,
22: 36,
23: 37,
24: 38,
25: 39,
26: 40,
27: 41,
28: 42,
29: 43,
30: 44,
31: 45,
32: 46,
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 range(self.OSFP_PORT_START, self.OSFP_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.OSFP_PORT_START + 1)
else:
self._port_name = "SFP+" + str(port_num - self.SFP_PORT_START + 1)
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 k,v in self._port_to_i2cbus_mapping.items():
self._port_to_eeprom_mapping[k] = eeprom_path.format(v)
SfpUtilBase.__init__(self)

def get_presence(self, port_num):
# Check for invalid port_num
if port_num not in 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"]))
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)
# low power mode is active high
if reg_value == 0:
return False

return True

def set_low_power_mode(self, port_num, lpmode):
# Check for invalid 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 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
"""
raise NotImplementedError
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"skip_ledd": true
}
1 change: 1 addition & 0 deletions platform/broadcom/one-image.mk
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ $(SONIC_ONE_IMAGE)_LAZY_INSTALLS += $(DELL_S6000_PLATFORM_MODULE) \
$(DELTA_AG9032V2A_PLATFORM_MODULE) \
$(JUNIPER_QFX5210_PLATFORM_MODULE) \
$(CEL_SILVERSTONE_PLATFORM_MODULE) \
$(CEL_SILVERSTONE2_PLATFORM_MODULE) \
$(JUNIPER_QFX5200_PLATFORM_MODULE) \
$(DELTA_AGC032_PLATFORM_MODULE)
ifeq ($(INSTALL_DEBUG_TOOLS),y)
Expand Down
Loading