From 44ff7400abd530be18f001977e0f23cd5bbda83f Mon Sep 17 00:00:00 2001 From: "Richard.Yu" Date: Sun, 1 Jan 2023 13:47:44 +0800 Subject: [PATCH] [Cherry-pick][SAIServer]Upgrade SAI server init script (#13175) Why I did it why In order to apply different config across different platform, and use the code with a unified format, reuse syncd init script to init saiserver. How I did it how Reuse syncd init script How to verify it Test Test in DUT s6000 and dx010 with sonic 202205 --- platform/broadcom/docker-saiserver-brcm.mk | 8 ++++- .../docker-saiserver-brcm/Dockerfile.j2 | 3 ++ .../docker-saiserver-brcm/saiserver_start.sh | 32 +++++++++++++++++++ .../broadcom/docker-saiserver-brcm/start.sh | 11 ------- .../docker-saiserver-brcm/supervisord.conf | 2 +- 5 files changed, 43 insertions(+), 13 deletions(-) create mode 100755 platform/broadcom/docker-saiserver-brcm/saiserver_start.sh diff --git a/platform/broadcom/docker-saiserver-brcm.mk b/platform/broadcom/docker-saiserver-brcm.mk index f4f9cdd42a49..92e533bf69b5 100644 --- a/platform/broadcom/docker-saiserver-brcm.mk +++ b/platform/broadcom/docker-saiserver-brcm.mk @@ -3,7 +3,13 @@ DOCKER_SAISERVER_BRCM = docker-saiserver$(SAITHRIFT_VER)-brcm.gz $(DOCKER_SAISERVER_BRCM)_PATH = $(PLATFORM_PATH)/docker-saiserver-brcm $(DOCKER_SAISERVER_BRCM)_DEPENDS += $(SAISERVER) -$(DOCKER_SAISERVER_BRCM)_FILES += $(DSSERVE) $(BCMCMD) + +# Use syncd_init_common.sh to init hardware platform +SYNCD_INIT_COMMON_SCRIPT = syncd_init_common.sh +$(SYNCD_INIT_COMMON_SCRIPT)_PATH = $(SRC_PATH)/sonic-sairedis/syncd/scripts +SONIC_COPY_FILES += $(SYNCD_INIT_COMMON_SCRIPT) + +$(DOCKER_SAISERVER_BRCM)_FILES += $(DSSERVE) $(BCMCMD) $(SYNCD_INIT_COMMON_SCRIPT) $(DOCKER_SAISERVER_BRCM)_LOAD_DOCKERS += $(DOCKER_CONFIG_ENGINE_BUSTER) SONIC_DOCKER_IMAGES += $(DOCKER_SAISERVER_BRCM) SONIC_BUSTER_DOCKERS += $(DOCKER_SAISERVER_BRCM) diff --git a/platform/broadcom/docker-saiserver-brcm/Dockerfile.j2 b/platform/broadcom/docker-saiserver-brcm/Dockerfile.j2 index 2fe765febcf3..3f1b9717fea6 100644 --- a/platform/broadcom/docker-saiserver-brcm/Dockerfile.j2 +++ b/platform/broadcom/docker-saiserver-brcm/Dockerfile.j2 @@ -26,7 +26,10 @@ debs/ RUN apt-get install -yf kmod COPY ["files/dsserve", "files/bcmcmd", "start.sh", "bcmsh", "/usr/bin/"] +COPY ["saiserver_start.sh", "/usr/bin/"] +COPY ["files/syncd_init_common.sh", "/usr/bin/"] RUN chmod +x /usr/bin/dsserve /usr/bin/bcmcmd +RUN chmod +x /usr/bin/saiserver_start.sh /usr/bin/syncd_init_common.sh COPY ["supervisord.conf", "/etc/supervisor/conf.d/"] diff --git a/platform/broadcom/docker-saiserver-brcm/saiserver_start.sh b/platform/broadcom/docker-saiserver-brcm/saiserver_start.sh new file mode 100755 index 000000000000..06fcf6c3f3ae --- /dev/null +++ b/platform/broadcom/docker-saiserver-brcm/saiserver_start.sh @@ -0,0 +1,32 @@ +#!/usr/bin/env bash +# Copy from src/sonic-sairedis/syncd/scripts/syncd_start.sh +# Re-use the structure for syncd setup +# Use it to start saiserver +# Script to start syncd using supervisord +# + +# Source the file that holds common code for systemd and supervisord +. /usr/bin/syncd_init_common.sh + +get_saiserver_param() +{ + IFS=' ' read -r -a array <<< "$CMD_ARGS" + for index in "${!array[@]}" + do + #echo "$index ${array[index]}" + if [[ "${array[index]}" == *"-p"* ]]; then + SAI_PROFILE="${array[index+1]}" + fi + if [[ "${array[index]}" == *"-m"* ]]; then + PORT_CONFIG="${array[index+1]}" + fi + done +} + +ENABLE_SAITHRIFT=1 +config_syncd +get_saiserver_param + +echo exec /usr/sbin/saiserver -p ${SAI_PROFILE} -f ${PORT_CONFIG} +exec /usr/sbin/saiserver -p ${SAI_PROFILE} -f ${PORT_CONFIG} +#exec ${CMD} ${CMD_ARGS} diff --git a/platform/broadcom/docker-saiserver-brcm/start.sh b/platform/broadcom/docker-saiserver-brcm/start.sh index 81813b57ff9d..6a395866c15d 100755 --- a/platform/broadcom/docker-saiserver-brcm/start.sh +++ b/platform/broadcom/docker-saiserver-brcm/start.sh @@ -1,13 +1,6 @@ #!/usr/bin/env bash HWSKU_DIR=/usr/share/sonic/hwsku -start_bcm() -{ - [ -e /dev/linux-bcm-knet ] || mknod /dev/linux-bcm-knet c 122 0 - [ -e /dev/linux-user-bde ] || mknod /dev/linux-user-bde c 126 0 - [ -e /dev/linux-kernel-bde ] || mknod /dev/linux-kernel-bde c 127 0 -} - generate_profile() { # There are two ways to specify the contents of the SAI_INIT_CONFIG_FILE and they are mutually exclusive @@ -35,10 +28,6 @@ generate_profile() } rm -f /var/run/rsyslogd.pid - supervisorctl start rsyslogd - generate_profile -start_bcm - supervisorctl start saiserver diff --git a/platform/broadcom/docker-saiserver-brcm/supervisord.conf b/platform/broadcom/docker-saiserver-brcm/supervisord.conf index 3574cd782b78..d20dac89141b 100644 --- a/platform/broadcom/docker-saiserver-brcm/supervisord.conf +++ b/platform/broadcom/docker-saiserver-brcm/supervisord.conf @@ -20,7 +20,7 @@ stdout_logfile=syslog stderr_logfile=syslog [program:saiserver] -command=/usr/sbin/saiserver -p /etc/sai.d/sai.profile -f /usr/share/sonic/hwsku/port_config.ini +command=/usr/bin/saiserver_start.sh priority=3 autostart=false autorestart=false