Skip to content

Commit

Permalink
Add gbsyncd container for Credo gearbox chips
Browse files Browse the repository at this point in the history
  • Loading branch information
byu343 committed Jul 15, 2021
1 parent c508a10 commit a9d80e7
Show file tree
Hide file tree
Showing 10 changed files with 138 additions and 1 deletion.
1 change: 1 addition & 0 deletions platform/broadcom/rules.dep
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ include $(PLATFORM_PATH)/one-aboot.dep
include $(PLATFORM_PATH)/libsaithrift-dev.dep
include $(PLATFORM_PATH)/docker-syncd-brcm-dnx.dep
include $(PLATFORM_PATH)/docker-syncd-brcm-dnx-rpc.dep
include $(PLATFORM_PATH)/../components/docker-gbsyncd-credo.dep
1 change: 1 addition & 0 deletions platform/broadcom/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ include $(PLATFORM_PATH)/one-aboot.mk
include $(PLATFORM_PATH)/libsaithrift-dev.mk
include $(PLATFORM_PATH)/docker-syncd-brcm-dnx.mk
include $(PLATFORM_PATH)/docker-syncd-brcm-dnx-rpc.mk
include $(PLATFORM_PATH)/../components/docker-gbsyncd-credo.mk

BCMCMD = bcmcmd
$(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"
Expand Down
12 changes: 12 additions & 0 deletions platform/components/docker-gbsyncd-credo.dep
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
DPATH := $($(DOCKER_GBSYNCD_BASE)_PATH)
DEP_FILES := $(SONIC_COMMON_FILES_LIST)
DEP_FILES += platform/components/docker-gbsyncd-credo.mk
DEP_FILES += platform/components/docker-gbsyncd-credo.dep
DEP_FILES += $(SONIC_COMMON_BASE_FILES_LIST)
DEP_FILES += $(shell git ls-files $(DPATH))

$(DOCKER_GBSYNCD_BASE)_CACHE_MODE := GIT_CONTENT_SHA
$(DOCKER_GBSYNCD_BASE)_DEP_FLAGS := $(SONIC_COMMON_FLAGS_LIST)
$(DOCKER_GBSYNCD_BASE)_DEP_FILES := $(DEP_FILES)

$(eval $(call add_dbg_docker,$(DOCKER_GBSYNCD_BASE),$(DOCKER_GBSYNCD_BASE_DBG)))
10 changes: 10 additions & 0 deletions platform/components/docker-gbsyncd-credo.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
DOCKER_GBSYNCD_PLATFORM_CODE = credo

LIBSAI_CREDO = libsai-credo_1.0_amd64.deb
$(LIBSAI_CREDO)_URL =

ifneq ($($(LIBSAI_CREDO)_URL),)
include $(PLATFORM_PATH)/../template/docker-gbsyncd-base.mk
SONIC_ONLINE_DEBS += $(LIBSAI_CREDO)
$(DOCKER_GBSYNCD_BASE)_DEPENDS += $(SYNCD) $(LIBSAI_CREDO)
endif
40 changes: 40 additions & 0 deletions platform/components/docker-gbsyncd-credo/Dockerfile.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
FROM docker-config-engine-buster

ARG docker_container_name
RUN [ -f /etc/rsyslog.conf ] && sed -ri "s/%syslogtag%/$docker_container_name#%syslogtag%/;" /etc/rsyslog.conf

## Make apt-get non-interactive
ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get update

RUN apt-get install -f -y iproute2 libcap2-bin libprotobuf-dev

COPY \
{% for deb in docker_gbsyncd_credo_debs.split(' ') -%}
{% if 'libsaibcm' not in deb -%}
debs/{{ deb }}{{' '}}
{%- endif %}
{%- endfor -%}
debs/

RUN dpkg -i \
{% for deb in docker_gbsyncd_credo_debs.split(' ') -%}
{% if 'libsaibcm' not in deb -%}
debs/{{ deb }}{{' '}}
{%- endif %}
{%- endfor %}

COPY ["docker-init.sh", "/usr/bin/"]
COPY ["start.sh", "/usr/bin/"]

COPY ["critical_processes.j2", "/usr/share/sonic/templates"]
COPY ["supervisord.conf.j2", "/usr/share/sonic/templates"]

COPY ["files/supervisor-proc-exit-listener", "/usr/bin"]

## Clean up
RUN apt-get clean -y; apt-get autoclean -y; apt-get autoremove -y
RUN rm -rf /debs

ENTRYPOINT ["/usr/bin/docker-init.sh"]
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
program:syncd
16 changes: 16 additions & 0 deletions platform/components/docker-gbsyncd-credo/docker-init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#! /bin/sh

GB_CONFIG=/usr/share/sonic/hwsku/gearbox_config.json

if [ ! -f $GB_CONFIG ]; then
exit 0
fi

CFGGEN_ARG="-j $GB_CONFIG"

mkdir -p /etc/supervisor/conf.d/

sonic-cfggen $CFGGEN_ARG -t /usr/share/sonic/templates/supervisord.conf.j2 > /etc/supervisor/conf.d/supervisord.conf
sonic-cfggen $CFGGEN_ARG -t /usr/share/sonic/templates/critical_processes.j2 > /etc/supervisor/critical_processes

exec /usr/local/bin/supervisord
14 changes: 14 additions & 0 deletions platform/components/docker-gbsyncd-credo/start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env bash

HWSKU_DIR=/usr/share/sonic/hwsku

mkdir -p /etc/sai.d/

# Create/Copy the pai.profile to /etc/sai.d/pai.profile
if [ -f $HWSKU_DIR/pai.profile.j2 ]; then
sonic-cfggen -d -t $HWSKU_DIR/pai.profile.j2 > /etc/sai.d/pai.profile
else
if [ -f $HWSKU_DIR/pai.profile ]; then
cp $HWSKU_DIR/pai.profile /etc/sai.d/pai.profile
fi
fi
42 changes: 42 additions & 0 deletions platform/components/docker-gbsyncd-credo/supervisord.conf.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
[supervisord]
logfile_maxbytes=1MB
logfile_backups=2
nodaemon=true

[eventlistener:dependent-startup]
command=python3 -m supervisord_dependent_startup
autostart=true
autorestart=unexpected
startretries=0
exitcodes=0,3
events=PROCESS_STATE

[program:rsyslogd]
command=/usr/sbin/rsyslogd -n -iNONE
priority=1
autostart=false
autorestart=unexpected
stdout_logfile=syslog
stderr_logfile=syslog
dependent_startup=true

[program:start]
command=/usr/bin/start.sh
priority=2
autostart=false
autorestart=false
startsecs=0
stdout_logfile=syslog
stderr_logfile=syslog
dependent_startup=true
dependent_startup_wait_for=rsyslogd:running

[program:syncd]
command=/usr/bin/syncd -s -p /etc/sai.d/pai.profile -x /usr/share/sonic/hwsku/context_config.json -g 1
priority=3
autostart=false
autorestart=false
stdout_logfile=syslog
stderr_logfile=syslog
dependent_startup=true
dependent_startup_wait_for=start:exited
2 changes: 1 addition & 1 deletion platform/template/docker-gbsyncd-base.mk
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ DOCKER_GBSYNCD_BASE_STEM = docker-gbsyncd-$(DOCKER_GBSYNCD_PLATFORM_CODE)
DOCKER_GBSYNCD_BASE = $(DOCKER_GBSYNCD_BASE_STEM).gz
DOCKER_GBSYNCD_BASE_DBG = $(DOCKER_GBSYNCD_BASE_STEM)-$(DBG_IMAGE_MARK).gz

$(DOCKER_GBSYNCD_BASE)_PATH = $(PLATFORM_PATH)/docker-gbsyncd-$(DOCKER_GBSYNCD_PLATFORM_CODE)
$(DOCKER_GBSYNCD_BASE)_PATH = $(PLATFORM_PATH)/../components/docker-gbsyncd-$(DOCKER_GBSYNCD_PLATFORM_CODE)

$(DOCKER_GBSYNCD_BASE)_FILES += $(SUPERVISOR_PROC_EXIT_LISTENER_SCRIPT)

Expand Down

0 comments on commit a9d80e7

Please sign in to comment.