Skip to content

Commit 2fccf06

Browse files
authored
[gearbox] Add gbsyncd container for Credo gearbox chips (sonic-net#8144)
This change is to add a gbsyncd container to accommodate the syncd process and the SAI libraries for the Credo gearbox chips. How I did it This container works similar to the existing Broadcom syncd container. Its main difference is that the SAI-related dynamic libraries are replaced by the ones for Credo gearbox chips, and the container only reacts to SAI events for the gearbox chips. The SAI libraries will be provided by the package libsai-credo_1.0_amd64.deb. For the image build, the added container will be built and included in the Broadcom platform image, after $(LIBSAI_CREDO)_URL = is replaced to the correct value. For now, as $(LIBSAI_CREDO)_URL is empty, the container build is skipped in the image build. After the container is included in the image, in the runtime, the container will begin with checking the existence of /usr/share/sonic/hwsku/gearbox_config.json; if that file is not provided, the container will exit by itself. Therefore, for platforms unrelated to the Credo chips, as long as they are not providing the file, they will not be affected by this change.
1 parent e5a6446 commit 2fccf06

15 files changed

+177
-5
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
gbsyncd.service.j2

files/build_templates/gbsyncd.service.j2

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[Unit]
2-
Description=gbsyncd service
2+
Description={{docker_container_name}} service
33
Requires=database.service updategraph.service
44
ConditionPathExists=!/usr/share/sonic/hwsku/gearbox_config.json
55
After=database.service updategraph.service
@@ -12,6 +12,8 @@ Before=ntp-config.service
1212
[Service]
1313
User=root
1414
Environment=sonic_asic_platform={{ sonic_asic_platform }}
15+
Environment=gbsyncd_platform={{ docker_container_name }}
16+
ExecCondition=/usr/bin/gbsyncd-platform.sh
1517
ExecStartPre=/usr/local/bin/gbsyncd.sh start
1618
ExecStart=/usr/local/bin/gbsyncd.sh wait
1719
ExecStop=/usr/local/bin/gbsyncd.sh stop

files/build_templates/sonic_debian_extension.j2

+1
Original file line numberDiff line numberDiff line change
@@ -794,6 +794,7 @@ sudo LANG=C cp $SCRIPTS_DIR/swss.sh $FILESYSTEM_ROOT/usr/local/bin/swss.sh
794794
sudo LANG=C cp $SCRIPTS_DIR/syncd.sh $FILESYSTEM_ROOT/usr/local/bin/syncd.sh
795795
sudo LANG=C cp $SCRIPTS_DIR/syncd_common.sh $FILESYSTEM_ROOT/usr/local/bin/syncd_common.sh
796796
sudo LANG=C cp $SCRIPTS_DIR/gbsyncd.sh $FILESYSTEM_ROOT/usr/local/bin/gbsyncd.sh
797+
sudo LANG=C cp $SCRIPTS_DIR/gbsyncd-platform.sh $FILESYSTEM_ROOT/usr/bin/gbsyncd-platform.sh
797798
sudo LANG=C cp $SCRIPTS_DIR/bgp.sh $FILESYSTEM_ROOT/usr/local/bin/bgp.sh
798799
sudo LANG=C cp $SCRIPTS_DIR/teamd.sh $FILESYSTEM_ROOT/usr/local/bin/teamd.sh
799800
sudo LANG=C cp $SCRIPTS_DIR/lldp.sh $FILESYSTEM_ROOT/usr/local/bin/lldp.sh

files/scripts/gbsyncd-platform.sh

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/bin/bash
2+
# Check the gbsyncd platform defined on the device matching the service,
3+
# or otherwise skip starting the service
4+
5+
SERVICE="$gbsyncd_platform"
6+
PLATFORM=${PLATFORM:-`sonic-cfggen -H -v DEVICE_METADATA.localhost.platform`}
7+
DEVPATH="/usr/share/sonic/device"
8+
CONFIGFILE="${DEVPATH}/${PLATFORM}/gbsyncd.ini"
9+
10+
if [ ! -f "$CONFIGFILE" ]; then
11+
if [ gbsyncd = "$SERVICE" ]; then
12+
exit 0
13+
fi
14+
exit 1
15+
fi
16+
17+
while IFS="=" read -r key value; do
18+
case "$key" in
19+
platform)
20+
if [ "$value" = "$SERVICE" ]; then
21+
exit 0
22+
fi
23+
;;
24+
esac
25+
done < "$CONFIGFILE"
26+
27+
exit 1

files/scripts/gbsyncd.sh

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ function stopplatform2() {
2121
OP=$1
2222
DEV=$2
2323

24-
SERVICE="gbsyncd"
24+
SERVICE="$gbsyncd_platform"
2525
PEER="swss"
26-
DEBUGLOG="/tmp/swss-gbsyncd-debug$DEV.log"
27-
LOCKFILE="/tmp/swss-gbsyncd-lock$DEV"
26+
DEBUGLOG="/tmp/swss-$SERVICE-debug$DEV.log"
27+
LOCKFILE="/tmp/swss-$SERVICE-lock$DEV"
2828
NAMESPACE_PREFIX="asic"
2929
if [ "$DEV" ]; then
3030
NET_NS="$NAMESPACE_PREFIX$DEV" #name of the network namespace

platform/broadcom/rules.dep

+1
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,4 @@ include $(PLATFORM_PATH)/one-aboot.dep
2727
include $(PLATFORM_PATH)/libsaithrift-dev.dep
2828
include $(PLATFORM_PATH)/docker-syncd-brcm-dnx.dep
2929
include $(PLATFORM_PATH)/docker-syncd-brcm-dnx-rpc.dep
30+
include $(PLATFORM_PATH)/../components/docker-gbsyncd-credo.dep

platform/broadcom/rules.mk

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ include $(PLATFORM_PATH)/one-aboot.mk
2727
include $(PLATFORM_PATH)/libsaithrift-dev.mk
2828
include $(PLATFORM_PATH)/docker-syncd-brcm-dnx.mk
2929
include $(PLATFORM_PATH)/docker-syncd-brcm-dnx-rpc.mk
30+
include $(PLATFORM_PATH)/../components/docker-gbsyncd-credo.mk
3031

3132
BCMCMD = bcmcmd
3233
$(BCMCMD)_URL = "https://sonicstorage.blob.core.windows.net/packages/20190307/bcmcmd?sv=2015-04-05&sr=b&sig=sUdbU7oVbh5exbXXHVL5TDFBTWDDBASHeJ8Cp0B0TIc%3D&se=2038-05-06T22%3A34%3A19Z&sp=r"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
DPATH := $($(DOCKER_GBSYNCD_BASE)_PATH)
2+
DEP_FILES := $(SONIC_COMMON_FILES_LIST)
3+
DEP_FILES += platform/components/docker-gbsyncd-credo.mk
4+
DEP_FILES += platform/components/docker-gbsyncd-credo.dep
5+
DEP_FILES += $(SONIC_COMMON_BASE_FILES_LIST)
6+
DEP_FILES += $(shell git ls-files $(DPATH))
7+
8+
$(DOCKER_GBSYNCD_BASE)_CACHE_MODE := GIT_CONTENT_SHA
9+
$(DOCKER_GBSYNCD_BASE)_DEP_FLAGS := $(SONIC_COMMON_FLAGS_LIST)
10+
$(DOCKER_GBSYNCD_BASE)_DEP_FILES := $(DEP_FILES)
11+
12+
$(eval $(call add_dbg_docker,$(DOCKER_GBSYNCD_BASE),$(DOCKER_GBSYNCD_BASE_DBG)))
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
DOCKER_GBSYNCD_PLATFORM_CODE = credo
2+
3+
LIBSAI_CREDO = libsaicredo_0.5.1-alpha.2_amd64.deb
4+
$(LIBSAI_CREDO)_URL =
5+
LIBSAI_CREDO_OWL = libsaicredo-owl_0.5.1-alpha.2_amd64.deb
6+
$(LIBSAI_CREDO_OWL)_URL =
7+
8+
ifneq ($($(LIBSAI_CREDO)_URL),)
9+
include $(PLATFORM_PATH)/../template/docker-gbsyncd-base.mk
10+
$(DOCKER_GBSYNCD_BASE)_CONTAINER_NAME = gbsyncd-$(DOCKER_GBSYNCD_PLATFORM_CODE)
11+
$(DOCKER_GBSYNCD_BASE)_PATH = $(PLATFORM_PATH)/../components/docker-gbsyncd-$(DOCKER_GBSYNCD_PLATFORM_CODE)
12+
SONIC_ONLINE_DEBS += $(LIBSAI_CREDO) $(LIBSAI_CREDO_OWL)
13+
$(DOCKER_GBSYNCD_BASE)_DEPENDS += $(SYNCD) $(LIBSAI_CREDO) $(LIBSAI_CREDO_OWL)
14+
endif
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
FROM docker-config-engine-buster
2+
3+
ARG docker_container_name
4+
RUN [ -f /etc/rsyslog.conf ] && sed -ri "s/%syslogtag%/$docker_container_name#%syslogtag%/;" /etc/rsyslog.conf
5+
6+
## Make apt-get non-interactive
7+
ENV DEBIAN_FRONTEND=noninteractive
8+
9+
RUN apt-get update
10+
11+
RUN apt-get install -f -y iproute2 libcap2-bin libprotobuf-dev
12+
13+
COPY \
14+
{% for deb in docker_gbsyncd_credo_debs.split(' ') -%}
15+
{% if 'libsaibcm' not in deb -%}
16+
debs/{{ deb }}{{' '}}
17+
{%- endif %}
18+
{%- endfor -%}
19+
debs/
20+
21+
RUN dpkg -i \
22+
{% for deb in docker_gbsyncd_credo_debs.split(' ') -%}
23+
{% if 'libsaibcm' not in deb -%}
24+
debs/{{ deb }}{{' '}}
25+
{%- endif %}
26+
{%- endfor %}
27+
28+
COPY ["docker-init.sh", "/usr/bin/"]
29+
COPY ["start.sh", "/usr/bin/"]
30+
31+
COPY ["critical_processes.j2", "/usr/share/sonic/templates"]
32+
COPY ["supervisord.conf.j2", "/usr/share/sonic/templates"]
33+
34+
COPY ["files/supervisor-proc-exit-listener", "/usr/bin"]
35+
36+
## Clean up
37+
RUN apt-get clean -y; apt-get autoclean -y; apt-get autoremove -y
38+
RUN rm -rf /debs
39+
40+
ENTRYPOINT ["/usr/bin/docker-init.sh"]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
program:syncd
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#! /bin/sh
2+
3+
GB_CONFIG=/usr/share/sonic/hwsku/gearbox_config.json
4+
5+
if [ ! -f $GB_CONFIG ]; then
6+
exit 0
7+
fi
8+
9+
CFGGEN_ARG="-j $GB_CONFIG"
10+
11+
mkdir -p /etc/supervisor/conf.d/
12+
13+
sonic-cfggen $CFGGEN_ARG -t /usr/share/sonic/templates/supervisord.conf.j2 > /etc/supervisor/conf.d/supervisord.conf
14+
sonic-cfggen $CFGGEN_ARG -t /usr/share/sonic/templates/critical_processes.j2 > /etc/supervisor/critical_processes
15+
16+
exec /usr/local/bin/supervisord
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/env bash
2+
3+
HWSKU_DIR=/usr/share/sonic/hwsku
4+
5+
mkdir -p /etc/sai.d/
6+
7+
# Create/Copy the psai.profile to /etc/sai.d/psai.profile
8+
if [ -f $HWSKU_DIR/psai.profile.j2 ]; then
9+
sonic-cfggen -d -t $HWSKU_DIR/psai.profile.j2 > /etc/sai.d/psai.profile
10+
else
11+
if [ -f $HWSKU_DIR/psai.profile ]; then
12+
cp $HWSKU_DIR/psai.profile /etc/sai.d/psai.profile
13+
fi
14+
fi
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
[supervisord]
2+
logfile_maxbytes=1MB
3+
logfile_backups=2
4+
nodaemon=true
5+
6+
[eventlistener:dependent-startup]
7+
command=python3 -m supervisord_dependent_startup
8+
autostart=true
9+
autorestart=unexpected
10+
startretries=0
11+
exitcodes=0,3
12+
events=PROCESS_STATE
13+
14+
[program:rsyslogd]
15+
command=/usr/sbin/rsyslogd -n -iNONE
16+
priority=1
17+
autostart=false
18+
autorestart=unexpected
19+
stdout_logfile=syslog
20+
stderr_logfile=syslog
21+
dependent_startup=true
22+
23+
[program:start]
24+
command=/usr/bin/start.sh
25+
priority=2
26+
autostart=false
27+
autorestart=false
28+
startsecs=0
29+
stdout_logfile=syslog
30+
stderr_logfile=syslog
31+
dependent_startup=true
32+
dependent_startup_wait_for=rsyslogd:running
33+
34+
[program:syncd]
35+
environment=CREDO_DEVICE_PATH=/usr/lib
36+
command=/usr/bin/syncd -s -p /etc/sai.d/psai.profile -x /usr/share/sonic/hwsku/context_config.json -g 1
37+
priority=3
38+
autostart=false
39+
autorestart=false
40+
stdout_logfile=syslog
41+
stderr_logfile=syslog
42+
dependent_startup=true
43+
dependent_startup_wait_for=start:exited

platform/template/docker-gbsyncd-base.mk

-1
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,3 @@ $(DOCKER_GBSYNCD_BASE)_CONTAINER_NAME = gbsyncd
2727
$(DOCKER_GBSYNCD_BASE)_RUN_OPT += --net=host --privileged -t
2828
$(DOCKER_GBSYNCD_BASE)_RUN_OPT += -v /host/machine.conf:/etc/machine.conf
2929
$(DOCKER_GBSYNCD_BASE)_RUN_OPT += -v /etc/sonic:/etc/sonic:ro
30-

0 commit comments

Comments
 (0)