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

[platform/broadcom] Add Celestica Silverstone-DP platform module #117

Merged
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# name lanes alias index speed
Ethernet0 0,1 QSFP1 1 100000
Ethernet4 2,3 QSFP2 2 100000
Ethernet8 4,5 QSFP3 3 100000
Ethernet12 6,7 QSFP4 4 100000
Ethernet16 8,9 QSFP5 5 100000
Ethernet20 10,11 QSFP6 6 100000
Ethernet24 12,13 QSFP7 7 100000
Ethernet28 14,15 QSFP8 8 100000
Ethernet32 16,17 QSFP9 9 100000
Ethernet36 18,19 QSFP10 10 100000
Ethernet40 20,21 QSFP11 11 100000
Ethernet44 22,23 QSFP12 12 100000
Ethernet48 24,25 QSFP13 13 100000
Ethernet52 26,27 QSFP14 14 100000
Ethernet56 28,29 QSFP15 15 100000
Ethernet60 30,31 QSFP16 16 100000
Ethernet64 32,33 QSFP17 17 100000
Ethernet68 34,35 QSFP18 18 100000
Ethernet72 36,37 QSFP19 19 100000
Ethernet76 38,39 QSFP20 20 100000
Ethernet80 40,41 QSFP21 21 100000
Ethernet84 42,43 QSFP22 22 100000
Ethernet88 44,45 QSFP23 23 100000
Ethernet92 46,47 QSFP24 24 100000
Ethernet96 88,89,90,91,92,93,94,95 QSFPDD1 25 400000
Ethernet100 80,81,82,83,84,85,86,87 QSFPDD2 26 400000
Ethernet104 72,73,74,75,76,77,78,79 QSFPDD3 27 400000
Ethernet108 64,65,66,67,68,69,70,71 QSFPDD4 28 400000
Ethernet112 56,57,58,59,60,61,62,63 QSFPDD5 29 400000
Ethernet116 48,49,50,51,52,53,54,55 QSFPDD6 30 400000
1 change: 1 addition & 0 deletions device/celestica/x86_64-cel_silverstone_dp-r0/default_sku
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Silverstone-DP t1
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_silverstone_dp-r0/plugins/eeprom.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env python

#############################################################################
# Celestica Silverstone-DP
#
# 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)

94 changes: 94 additions & 0 deletions device/celestica/x86_64-cel_silverstone_dp-r0/plugins/psuutil.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
#!/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")


# TODO: update ipmi command to get PSU statuses.
# user sdr entity 10 and filter psu1/psu2_status for discrete.

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

def __init__(self):
self.ipmi_raw = "docker exec -ti pmon 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
215 changes: 215 additions & 0 deletions device/celestica/x86_64-cel_silverstone_dp-r0/plugins/sfputil.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,215 @@
#!/usr/bin/env python
#
# Platform-specific SFP transceiver interface for SONiC
# This plugin supports QSFP-DD, QSFP.

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"""
""" Silverstone-DP EVT does not have SFP port """

PORT_START = 1
PORT_END = 30
OSFP_PORT_START = 25
OSFP_PORT_END = 30
QSFP_PORT_START = 1
QSFP_PORT_END = 24

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

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

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

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

@property
def qsfp_ports(self):
return range(self.QSFP_PORT_START, self.QSFP_PORT_END + 1)

@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 = "QSFP" + str(port_num - self.QSFP_PORT_START + 1)
return self._port_name

def get_eeprom_dom_raw(self, port_num):
if port_num in self.osfp_ports:
return None
elif port_num in self.osfp_ports:
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"
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 and port_num not in self.qsfp_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 and port_num not in self.qsfp_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 and port_num not in self.qsfp_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
3 changes: 2 additions & 1 deletion platform/broadcom/one-image.mk
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ $(SONIC_ONE_IMAGE)_LAZY_INSTALLS += $(DELL_S6000_PLATFORM_MODULE) \
$(ALPHANETWORKS_SNH60B0_640F_PLATFORM_MODULE) \
$(BRCM_XLR_GTS_PLATFORM_MODULE) \
$(DELTA_AG9032V2A_PLATFORM_MODULE) \
$(JUNIPER_QFX5210_PLATFORM_MODULE)
$(JUNIPER_QFX5210_PLATFORM_MODULE) \
$(CEL_SILVERSTONE-DP_PLATFORM_MODULE)
ifeq ($(INSTALL_DEBUG_TOOLS),y)
$(SONIC_ONE_IMAGE)_DOCKERS += $(SONIC_INSTALL_DOCKER_DBG_IMAGES)
$(SONIC_ONE_IMAGE)_DOCKERS += $(filter-out $(patsubst %-$(DBG_IMAGE_MARK).gz,%.gz, $(SONIC_INSTALL_DOCKER_DBG_IMAGES)), $(SONIC_INSTALL_DOCKER_IMAGES))
Expand Down
Loading