Skip to content

Commit bca955f

Browse files
authored
[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
1 parent bf05eea commit bca955f

File tree

5 files changed

+43
-13
lines changed

5 files changed

+43
-13
lines changed

platform/broadcom/docker-saiserver-brcm.mk

+7-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,13 @@
33
DOCKER_SAISERVER_BRCM = docker-saiserver$(SAITHRIFT_VER)-brcm.gz
44
$(DOCKER_SAISERVER_BRCM)_PATH = $(PLATFORM_PATH)/docker-saiserver-brcm
55
$(DOCKER_SAISERVER_BRCM)_DEPENDS += $(SAISERVER)
6-
$(DOCKER_SAISERVER_BRCM)_FILES += $(DSSERVE) $(BCMCMD)
6+
7+
# Use syncd_init_common.sh to init hardware platform
8+
SYNCD_INIT_COMMON_SCRIPT = syncd_init_common.sh
9+
$(SYNCD_INIT_COMMON_SCRIPT)_PATH = $(SRC_PATH)/sonic-sairedis/syncd/scripts
10+
SONIC_COPY_FILES += $(SYNCD_INIT_COMMON_SCRIPT)
11+
12+
$(DOCKER_SAISERVER_BRCM)_FILES += $(DSSERVE) $(BCMCMD) $(SYNCD_INIT_COMMON_SCRIPT)
713
$(DOCKER_SAISERVER_BRCM)_LOAD_DOCKERS += $(DOCKER_CONFIG_ENGINE_BULLSEYE)
814
SONIC_DOCKER_IMAGES += $(DOCKER_SAISERVER_BRCM)
915
SONIC_BULLSEYE_DOCKERS += $(DOCKER_SAISERVER_BRCM)

platform/broadcom/docker-saiserver-brcm/Dockerfile.j2

+3
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,10 @@ debs/
2626
RUN apt-get install -yf kmod
2727

2828
COPY ["files/dsserve", "files/bcmcmd", "start.sh", "bcmsh", "/usr/bin/"]
29+
COPY ["saiserver_start.sh", "/usr/bin/"]
30+
COPY ["files/syncd_init_common.sh", "/usr/bin/"]
2931
RUN chmod +x /usr/bin/dsserve /usr/bin/bcmcmd
32+
RUN chmod +x /usr/bin/saiserver_start.sh /usr/bin/syncd_init_common.sh
3033

3134
COPY ["supervisord.conf", "/etc/supervisor/conf.d/"]
3235

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/usr/bin/env bash
2+
# Copy from src/sonic-sairedis/syncd/scripts/syncd_start.sh
3+
# Re-use the structure for syncd setup
4+
# Use it to start saiserver
5+
# Script to start syncd using supervisord
6+
#
7+
8+
# Source the file that holds common code for systemd and supervisord
9+
. /usr/bin/syncd_init_common.sh
10+
11+
get_saiserver_param()
12+
{
13+
IFS=' ' read -r -a array <<< "$CMD_ARGS"
14+
for index in "${!array[@]}"
15+
do
16+
#echo "$index ${array[index]}"
17+
if [[ "${array[index]}" == *"-p"* ]]; then
18+
SAI_PROFILE="${array[index+1]}"
19+
fi
20+
if [[ "${array[index]}" == *"-m"* ]]; then
21+
PORT_CONFIG="${array[index+1]}"
22+
fi
23+
done
24+
}
25+
26+
ENABLE_SAITHRIFT=1
27+
config_syncd
28+
get_saiserver_param
29+
30+
echo exec /usr/sbin/saiserver -p ${SAI_PROFILE} -f ${PORT_CONFIG}
31+
exec /usr/sbin/saiserver -p ${SAI_PROFILE} -f ${PORT_CONFIG}
32+
#exec ${CMD} ${CMD_ARGS}

platform/broadcom/docker-saiserver-brcm/start.sh

-11
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
11
#!/usr/bin/env bash
22
HWSKU_DIR=/usr/share/sonic/hwsku
33

4-
start_bcm()
5-
{
6-
[ -e /dev/linux-bcm-knet ] || mknod /dev/linux-bcm-knet c 122 0
7-
[ -e /dev/linux-user-bde ] || mknod /dev/linux-user-bde c 126 0
8-
[ -e /dev/linux-kernel-bde ] || mknod /dev/linux-kernel-bde c 127 0
9-
}
10-
114
generate_profile()
125
{
136
# 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()
3528
}
3629

3730
rm -f /var/run/rsyslogd.pid
38-
3931
supervisorctl start rsyslogd
40-
4132
generate_profile
42-
start_bcm
43-
4433
supervisorctl start saiserver

platform/broadcom/docker-saiserver-brcm/supervisord.conf

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ stdout_logfile=syslog
2020
stderr_logfile=syslog
2121

2222
[program:saiserver]
23-
command=/usr/sbin/saiserver -p /etc/sai.d/sai.profile -f /usr/share/sonic/hwsku/port_config.ini
23+
command=/usr/bin/saiserver_start.sh
2424
priority=3
2525
autostart=false
2626
autorestart=false

0 commit comments

Comments
 (0)