sonic-buildimage/platform/broadcom/docker-syncd-brcm/start.sh
RAMA CHANDRA REDDY GADDAM 6370d64b3d [broadcom]: Check for broadcom platform sdk init ready during syncd start. (#2931)
- What I did
During boot/reload time, wait in a loop to check for bcm initialization.
Break the loop, once sdk is ready to process the 'bcmcmd' request (or) loop count reached the maximum value.

- How I did it
In the existing implementation during syncd start process will sleep for a fixed time (3 secs)
for sdk initialization to happen. But the time taken for sdk initialization is varying for different platforms.
To fix this issue, the syncd start process wait in a loop and check whether sdk is ready to process 'bcmcmd' command.

- How to verify it
Check for syncd process status and interface status.
Check for syslogs and no failures related to syncd should be present.
2019-06-19 01:25:37 -07:00

59 lines
1.5 KiB
Bash
Executable File

#!/usr/bin/env bash
PLATFORM_DIR=/usr/share/sonic/platform
HWSKU_DIR=/usr/share/sonic/hwsku
SYNCD_SOCKET_FILE=/var/run/sswsyncd/sswsyncd.socket
# Function: wait until syncd has created the socket for bcmcmd to connect to
wait_syncd() {
while true; do
if [ -e ${SYNCD_SOCKET_FILE} ]; then
break
fi
sleep 1
done
# wait until bcm sdk is ready to get a request
counter=0
while true; do
/usr/bin/bcmcmd -t 1 "show unit" | grep BCM >/dev/null 2>&1
rv=$?
if [ $rv -eq 0 ]; then
break
fi
counter=$((counter+1))
if [ $counter -ge 60 ]; then
echo "syncd is not ready to take commands after $counter re-tries; Exiting!"
break
fi
sleep 1
done
}
# Remove stale files if they exist
rm -f /var/run/rsyslogd.pid
rm -f ${SYNCD_SOCKET_FILE}
supervisorctl start rsyslogd
mkdir -p /etc/sai.d/
# Create/Copy the sai.profile to /etc/sai.d/sai.profile
if [ -f $HWSKU_DIR/sai.profile.j2 ]; then
sonic-cfggen -d -t $HWSKU_DIR/sai.profile.j2 > /etc/sai.d/sai.profile
else
if [ -f $HWSKU_DIR/sai.profile ]; then
cp $HWSKU_DIR/sai.profile /etc/sai.d/sai.profile
fi
fi
supervisorctl start syncd
# If this platform has an initialization file for the Broadcom LED microprocessor, load it
if [[ -r ${PLATFORM_DIR}/led_proc_init.soc && ! -f /var/warmboot/warm-starting ]]; then
wait_syncd
supervisorctl start ledinit
fi