[devices]: Add Broadcom XLR/GTS (BCM9COMX2XMC) support for Tomahawk switch (BCM956960K) (#2682)

These patches add support for the Broadcom XMC card (XLR/GTS). At this moment
only Tomahawk switch (BCM956960K) is supported. Add
device/broadcom/x86_64-bcm_xlr-r0 and
platform/broadcom/sonic-platform-modules-brcm-xlr-gts files
This commit is contained in:
Olivier Singla 2019-06-09 15:09:31 -04:00 committed by lguohan
parent 3d2955a184
commit 708999ad61
25 changed files with 1528 additions and 1 deletions

View File

@ -0,0 +1,77 @@
portmap_1=1:100
portmap_2=5:100
portmap_3=9:100
portmap_4=13:100
portmap_5=17:100
portmap_6=21:100
portmap_7=25:100
portmap_8=29:100
portmap_34=33:100
portmap_35=37:100
portmap_36=41:100
portmap_37=45:100
portmap_38=49:100
portmap_39=53:100
portmap_40=57:100
portmap_41=61:100
portmap_68=65:100
portmap_69=69:100
portmap_70=73:100
portmap_71=77:100
portmap_72=81:100
portmap_73=85:100
portmap_74=89:100
portmap_75=93:100
portmap_102=97:100
portmap_103=101:100
portmap_104=105:100
portmap_105=109:100
portmap_106=113:100
portmap_107=117:100
portmap_108=121:100
portmap_109=125:100
oversubscribe_mode=1
portmap_66=129:10
portmap_100=131:10
pbmp_xport_xe=0x3fd000000ff4000003fc000001fe
portmap_33=132:10
portmap_67=133:10
portmap_101=134:10
portmap_135=135:10
xgxs_tx_lane_map_ce18=0x1032
xgxs_rx_lane_map_ce18=0x1032
xgxs_rx_lane_map_ce19=0x2301
xgxs_rx_lane_map_ce20=0x2301
xgxs_rx_lane_map_ce21=0x2301
xgxs_rx_lane_map_ce22=0x2301
xgxs_rx_lane_map_ce23=0x2301
xgxs_rx_lane_map_ce24=0x2301
xgxs_rx_lane_map_ce25=0x2301
xgxs_rx_lane_map_ce26=0x2301
xgxs_rx_lane_map_ce27=0x2301
xgxs_rx_lane_map_ce28=0x2301
phy_xaui_rx_polarity_flip_ce4=0x2
phy_xaui_tx_polarity_flip_ce5=0x8
phy_xaui_rx_polarity_flip_ce5=0x5
phy_xaui_rx_polarity_flip_ce6=0x2
phy_xaui_tx_polarity_flip_ce7=0x8
phy_xaui_tx_polarity_flip_ce8=0x8
phy_xaui_rx_polarity_flip_ce8=0x8
phy_xaui_tx_polarity_flip_ce10=0x8
phy_xaui_rx_polarity_flip_ce10=0x1
phy_xaui_rx_polarity_flip_ce11=0x2
phy_xaui_tx_polarity_flip_ce19=0x2
phy_xaui_rx_polarity_flip_ce19=0x3
phy_xaui_tx_polarity_flip_ce20=0x8
phy_xaui_rx_polarity_flip_ce21=0x4
phy_xaui_tx_polarity_flip_ce22=0x8
phy_xaui_rx_polarity_flip_ce22=0x8
phy_xaui_rx_polarity_flip_ce23=0x4
phy_xaui_rx_polarity_flip_ce24=0x4
phy_xaui_tx_polarity_flip_ce25=0x8
phy_xaui_rx_polarity_flip_ce25=0x8
phy_xaui_rx_polarity_flip_ce26=0x4
phy_xaui_tx_polarity_flip_ce27=0x8
phy_xaui_rx_polarity_flip_ce27=0x8
l2xmsg_mode=1
fpem_mem_entries=32768

View File

@ -0,0 +1,33 @@
# name lanes alias index speed
Ethernet0 1,2,3,4 Ethernet1/0/1 0 100000
Ethernet4 5,6,7,8 Ethernet1/0/5 1 100000
Ethernet8 9,10,11,12 Ethernet1/0/9 2 100000
Ethernet12 13,14,15,16 Ethernet1/0/13 3 100000
Ethernet16 17,18,19,20 Ethernet1/0/17 4 100000
Ethernet20 21,22,23,24 Ethernet1/0/21 5 100000
Ethernet24 25,26,27,28 Ethernet1/0/25 6 100000
Ethernet28 29,30,31,32 Ethernet1/0/29 7 100000
Ethernet32 33,34,35,36 Ethernet1/0/33 8 100000
Ethernet36 37,38,39,40 Ethernet1/0/37 9 100000
Ethernet40 41,42,43,44 Ethernet1/0/41 10 100000
Ethernet44 45,46,47,48 Ethernet1/0/45 11 100000
Ethernet48 49,50,51,52 Ethernet1/0/49 12 100000
Ethernet52 53,54,55,56 Ethernet1/0/53 13 100000
Ethernet56 57,58,59,60 Ethernet1/0/57 14 100000
Ethernet60 61,62,63,64 Ethernet1/0/61 15 100000
Ethernet64 65,66,67,68 Ethernet1/0/65 16 100000
Ethernet68 69,70,71,72 Ethernet1/0/69 17 100000
Ethernet72 73,74,75,76 Ethernet1/0/73 18 100000
Ethernet76 77,78,79,80 Ethernet1/0/77 19 100000
Ethernet80 81,82,83,84 Ethernet1/0/81 20 100000
Ethernet84 85,86,87,88 Ethernet1/0/85 21 100000
Ethernet88 89,90,91,92 Ethernet1/0/89 22 100000
Ethernet92 93,94,95,96 Ethernet1/0/93 23 100000
Ethernet96 97,98,99,100 Ethernet1/0/97 24 100000
Ethernet100 101,102,103,104 Ethernet1/0/101 25 100000
Ethernet104 105,106,107,108 Ethernet1/0/105 26 100000
Ethernet108 109,110,111,112 Ethernet1/0/109 27 100000
Ethernet112 113,114,115,116 Ethernet1/0/113 28 100000
Ethernet116 117,118,119,120 Ethernet1/0/117 29 100000
Ethernet120 121,122,123,124 Ethernet1/0/121 30 100000
Ethernet124 125,126,127,128 Ethernet1/0/125 31 100000

View File

@ -0,0 +1 @@
SAI_INIT_CONFIG_FILE=/usr/share/sonic/hwsku/config_th_32x100.bcm

View File

@ -0,0 +1 @@
bcm_xlr t1

View File

@ -0,0 +1,9 @@
if [ -d /sys/devices/pci0000:00/0000:00:13.0 ]; then
CONSOLE_PORT=0x3e8
CONSOLE_DEV=2
else
CONSOLE_PORT=0x3f8
CONSOLE_DEV=0
fi
ONIE_PLATFORM_EXTRA_CMDLINE_LINUX="libata.dma=0 libata.noacpi=1"
CONSOLE_SPEED=115200

View File

@ -0,0 +1,29 @@
#!/usr/bin/env python
#############################################################################
# Broadcom XLR/GTS 'eeprom' support
#
# 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
#
# Note: the file /etc/sys_eeprom.bin is generated by the script
# brcm-xlr-gts-create-eeprom-file.py
#############################################################################
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 = "/etc/sys_eeprom.bin"
super(board, self).__init__(self.eeprom_path, 0, '', False, True)
def serial_number_str(self, e):
"""Return service tag instead of serial number"""
return "No service tag"

View File

@ -0,0 +1,41 @@
#!/usr/bin/env python
import os.path
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):
PsuBase.__init__(self)
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 0
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
"""
return False
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
"""
return False

View File

@ -0,0 +1,50 @@
#!/usr/bin/env python
try:
import time
import os
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 = 52
_port_to_eeprom_mapping = {}
@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 port_to_eeprom_mapping(self):
return self._port_to_eeprom_mapping
def __init__(self):
SfpUtilBase.__init__(self)
def get_presence(self, port_num):
return False
def get_low_power_mode(self, port_num):
raise NotImplementedError
def set_low_power_mode(self, port_num, lpmode):
raise NotImplementedError
def reset(self, port_num):
raise NotImplementedError
def get_transceiver_change_event(self, timeout=0):
raise NotImplementedError

View File

@ -38,6 +38,7 @@ $(SONIC_ONE_IMAGE)_LAZY_INSTALLS += $(DELL_S6000_PLATFORM_MODULE) \
$(QUANTA_IX1B_32X_PLATFORM_MODULE) \
$(MITAC_LY1200_32X_PLATFORM_MODULE) \
$(ALPHANETWORKS_SNH60A0_320FV2_PLATFORM_MODULE) \
$(ALPHANETWORKS_SNH60B0_640F_PLATFORM_MODULE)
$(ALPHANETWORKS_SNH60B0_640F_PLATFORM_MODULE) \
$(BRCM_XLR_GTS_PLATFORM_MODULE)
$(SONIC_ONE_IMAGE)_DOCKERS += $(SONIC_INSTALL_DOCKER_IMAGES)
SONIC_INSTALLERS += $(SONIC_ONE_IMAGE)

View File

@ -0,0 +1,15 @@
# Broadcom XLR/GTS Platform modules
BRCM_XLR_GTS_PLATFORM_MODULE_VERSION = 1.0
export BRCM_XLR_GTS_PLATFORM_MODULE_VERSION
BRCM_XLR_GTS_PLATFORM_MODULE = sonic-platform-brcm-xlr-gts_$(BRCM_XLR_GTS_PLATFORM_MODULE_VERSION)_amd64.deb
$(BRCM_XLR_GTS_PLATFORM_MODULE)_SRC_PATH = $(PLATFORM_PATH)/sonic-platform-modules-brcm-xlr-gts
$(BRCM_XLR_GTS_PLATFORM_MODULE)_DEPENDS += $(LINUX_HEADERS) $(LINUX_HEADERS_COMMON)
$(BRCM_XLR_GTS_PLATFORM_MODULE)_PLATFORM = x86_64-bcm_xlr-r0
SONIC_MAKE_DEBS += $(BRCM_XLR_GTS_PLATFORM_MODULE)
export BRCM_XLR_GTS_PLATFORM_MODULE
SONIC_STRETCH_DEBS += $(BRCM_XLR_GTS_PLATFORM_MODULE)

View File

@ -11,6 +11,7 @@ include $(PLATFORM_PATH)/platform-modules-cel.mk
include $(PLATFORM_PATH)/platform-modules-delta.mk
include $(PLATFORM_PATH)/platform-modules-quanta.mk
#include $(PLATFORM_PATH)/platform-modules-mitac.mk
include $(PLATFORM_PATH)/platform-modules-brcm-xlr-gts.mk
include $(PLATFORM_PATH)/docker-syncd-brcm.mk
include $(PLATFORM_PATH)/docker-syncd-brcm-rpc.mk
include $(PLATFORM_PATH)/docker-saiserver-brcm.mk

View File

@ -0,0 +1,14 @@
SHELL = /bin/bash
.ONESHELL:
.SHELLFLAGS += -e
MAIN_TARGET = $(BRCM_XLR_GTS_PLATFORM_MODULE)
$(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% :
# Build the package
export PYBUILD_INSTALL_ARGS_python2=--install-scripts=/dev/null
dpkg-buildpackage -rfakeroot -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS)
mv $(addprefix ../, $* $(EXTRA_TARGETS)) $(DEST)/
$(addprefix $(DEST)/, $(EXTRA_TARGETS)): $(DEST)/% : $(DEST)/$(MAIN_TARGET)

View File

@ -0,0 +1,11 @@
[Unit]
Description=Broadcom XLR/GTS platform setup
Before=systemd-logind docker.service
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/bin/brcm-xlr-gts-platform-setup
[Install]
WantedBy=multi-user.target

View File

@ -0,0 +1,5 @@
sonic-platform-brcm-xlr-gts (1.0) unstable;
* Initial release
-- Olivier Singla <olivier.singla@broadcom.com> Thursday, 14 Feb 2019 11:11:11 -0800

View File

@ -0,0 +1 @@
9

View File

@ -0,0 +1,27 @@
Source: sonic-platform-brcm-xlr-gts
Section: main
Priority: extra
Maintainer: Olivier Singla <olivier.singla@broadcom.com>
Build-Depends:
dh-python,
debhelper (>= 9.0.0),
python-all,
python(>=2.7-3~),
python-setuptools,
python3(>=3.2),
python3-setuptools,
bzip2
Standards-Version: 1.0.0
X-Python-Version: >= 2.7
X-Python3-Version: >= 3.2
XS-Python-Version: >= 2.7
XS-Python3-Version: >= 3.2
Package: sonic-platform-brcm-xlr-gts
Architecture: amd64
Depends:
${python:Depends},
${misc:Depends},
python(>=2.7),
i2c-tools
Description: Miscellaneous XLR scripts and tools

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,2 @@
sonic-platform-brcm-xlr-gts_1.0_amd64.buildinfo main extra
sonic-platform-brcm-xlr-gts_1.0_amd64.deb main extra

View File

@ -0,0 +1,31 @@
#!/usr/bin/make -f
include /usr/share/dpkg/pkg-info.mk
BIN_FILES := brcm-xlr-gts-platform-setup brcm-xlr-gts-create-eeprom-file.py
RULE_FILES :=
SERVICE_FILES := sonic-platform-brcm-xlr-gts.service
USR_SBIN_FILES := brcm-xlr-gts-platform-setup brcm-xlr-gts-create-eeprom-file.py
BASE_DIR := $(shell pwd)
MODULE_SRC := $(BASE_DIR)/src
TEST_DIR := $(BASE_DIR)/tests
BIN_SRC := $(addprefix $(BASE_DIR)/utils/,$(BIN_FILES))
SERVICE_SRC := $(addprefix $(BASE_DIR)/confs/,$(SERVICE_FILES))
USRLOCALSBIN_SRC := $(addprefix $(BASE_DIR)/utils/,$(USR_SBIN_FILES))
%:
dh $@ --with python2,python3,systemd --buildsystem=pybuild
override_dh_auto_install:
dh_installdirs -p$(DEB_SOURCE) lib/systemd/system
cp $(SERVICE_SRC) debian/$(DEB_SOURCE)/lib/systemd/system
dh_installdirs -p$(DEB_SOURCE) usr/bin
cp $(BIN_SRC) debian/$(DEB_SOURCE)/usr/bin
dh_systemd_enable sonic-platform-brcm-xlr-gts.service
override_dh_clean:
dh_clean
print-%:
@echo $($*)

View File

@ -0,0 +1,12 @@
#!/usr/bin/env python
from setuptools import setup
import os
setup(
name='platform-xlr-gts',
version='%s' % os.environ.get('BRCM_XLR_GTS_PLATFORM_MODULE_VERSION', '1.0'),
description='Module to initialize Broadcom XLR/GTS platforms',
packages=[],
)

View File

@ -0,0 +1,13 @@
ccflags-y := -Werror
#ifeq ($(ARISTA_SCD_DRIVER_CONFIG),m)
#obj-$(ARISTA_SCD_DRIVER_CONFIG) += scd.o
#else
#KBUILD_EXTRA_SYMBOLS += $(EXTRA_SYMBOLS)
#endif
#obj-m += scd-hwmon.o
#obj-m += crow-fan-driver.o
#obj-m += raven-fan-driver.o
#obj-m += rook-led-driver.o
#obj-m += rook-fan-cpld.o

View File

@ -0,0 +1,9 @@
#!/bin/bash
#
# This script provides a simple helper to test if the initscripts for all
# platforms work.
# It runs in simulation mode and don't actually initialize anything but still
# checks most of the codepaths
#
echo "Nothing to do!"

View File

@ -0,0 +1,105 @@
#!/usr/bin/python
# Since the XLR/GTS cards do not have an EEPROM, we create a file which
# will be use like an EEPROM.
import sys
import struct
from ctypes import *
import os
TLV_CODE_PRODUCT_NAME = 0x21
TLV_CODE_SERIAL_NUMBER = 0x23
TLV_CODE_MAC_BASE = 0x24
TLV_CODE_PLATFORM_NAME = 0x28
TLV_CODE_ONIE_VERSION = 0x29
TLV_CODE_MANUF_NAME = 0x2B
TLV_CODE_CRC_32 = 0xFE
def getmac(interface):
try:
mac = open('/sys/class/net/'+interface+'/address').readline()
except:
mac = "00:00:00:00:00:00"
return mac[0:17]
class TLVINFO_HEADER(Structure):
_fields_ = [("signature", c_char*8),
("version", c_ubyte),
("totallen", c_ushort)]
def dump(self):
return struct.pack('8s', self.signature) + \
struct.pack('B', self.version) + \
struct.pack('>H', self.totallen)
class TLVINFO_DATA:
data = [];
def add_tlv_str(self, type, value):
self.data.append(struct.pack('B', type) + struct.pack('B', len(value)) + value.encode())
def add_tlv_mac(self, type, value):
self.data.append(struct.pack('B', type) + struct.pack('B', len(value)))
for v in value:
self.data.append(struct.pack('B', int(v, 16)))
def dump(self):
r = '';
for m in self.data:
r += bytes(m)
return r + struct.pack('B', TLV_CODE_CRC_32) + struct.pack('B', 4)
def crc32(crc, p, len):
crc = 0xffffffff & ~crc
for i in range(len):
crc = crc ^ p[i]
for j in range(8):
crc = (crc >> 1) ^ (0xedb88320 & -(crc & 1))
return 0xffffffff & ~crc
def crc(header, data):
r = '';
for m in header:
r += bytes(m)
for m in data:
r += bytes(m)
c = crc32(0, bytearray(r), len(r))
s = struct.pack('>I', c)
return s
def main():
tlvinfo_header = TLVINFO_HEADER('TlvInfo', 1, 0)
tlvinfo_data = TLVINFO_DATA()
tlvinfo_data.add_tlv_str(TLV_CODE_SERIAL_NUMBER, 'S/N')
onie_machine = os.popen("cat /host/machine.conf | grep 'onie_machine=' | sed 's/onie_machine=//'").read().strip()
if onie_machine == 'bcm_xlr':
tlvinfo_data.add_tlv_str(TLV_CODE_PRODUCT_NAME, 'BCM9COMX2XMC')
else:
tlvinfo_data.add_tlv_str(TLV_CODE_PRODUCT_NAME, 'Unknown')
tlvinfo_data.add_tlv_str(TLV_CODE_MANUF_NAME, 'Broadcom')
eth0_mac_str = getmac('eth0')
eth0_mac = eth0_mac_str.split(':')
tlvinfo_data.add_tlv_mac(TLV_CODE_MAC_BASE, eth0_mac)
brcm_dev = os.popen("lspci | grep -m1 'Ethernet controller: Broadcom ' | grep 'Device' | sed 's/(.*//' | awk '{print $NF}'").read().strip()
if brcm_dev == 'b960':
tlvinfo_data.add_tlv_str(TLV_CODE_PLATFORM_NAME, 'BCM956960K')
onie_version = os.popen("cat /host/machine.conf | grep 'onie_version' | sed 's/onie_version=//'").read().strip()
tlvinfo_data.add_tlv_str(TLV_CODE_ONIE_VERSION, onie_version)
tlvinfo_header.totallen = len(tlvinfo_data.dump())+4;
try:
f = open('/etc/sys_eeprom.bin', 'w+')
f.write(tlvinfo_header.dump())
f.write(tlvinfo_data.dump())
f.write(crc(tlvinfo_header.dump(), tlvinfo_data.dump()))
f.close()
except:
print('Unable to write file /etc/sys_eeprom.bin')
if __name__== "__main__":
main()

View File

@ -0,0 +1,23 @@
#!/bin/sh
. /host/machine.conf
# We boot SONiC from an XMC card : identify the switch at run-time and update the SKU
if [ "${onie_machine}" = "bcm_xlr" ]; then
grep "HandleLidSwitch=ignore" /etc/systemd/logind.conf > /dev/null
if [ ! $? = 0 ]; then
echo "HandleLidSwitch=ignore" >> /etc/systemd/logind.conf
echo "IdleAction=ignore" >> /etc/systemd/logind.conf
systemctl is-active --quiet systemd-logind
if [ $? = 0 ]; then
systemctl restart systemd-logind
fi
fi
/usr/bin/brcm-xlr-gts-create-eeprom-file.py
brcm_sw=$(lspci | grep -m1 "Ethernet controller: Broadcom " | grep "Device" | sed 's/(.*//' | awk '{print $NF}')
case "$brcm_sw" in
b960)
echo "BCM956960K t1" > /usr/share/sonic/device/${onie_platform}/default_sku
;;
esac
fi