Skip to content

Commit

Permalink
PDE migration to bullseye (sonic-net#10836)
Browse files Browse the repository at this point in the history
#### Why I did it
Upgrade docker-pde to bullseye

#### How to verify it
Check Azp status
  • Loading branch information
geans-pin authored and skbarista committed Aug 17, 2022
1 parent ca5bbe1 commit 89851c1
Show file tree
Hide file tree
Showing 34 changed files with 280 additions and 15 deletions.
7 changes: 3 additions & 4 deletions dockers/docker-pde/Dockerfile.j2
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM docker-config-engine-buster-{{DOCKER_USERNAME}}:{{DOCKER_USERTAG}}
FROM docker-config-engine-bullseye-{{DOCKER_USERNAME}}:{{DOCKER_USERTAG}}

ARG docker_container_name
ENV PYTHONPATH=/usr/share/sonic/platform
Expand All @@ -20,8 +20,7 @@ RUN apt-get update && apt-get install -y ipmitool telnet busybox kmod libpcap-de
RUN apt-get install -y bzip2 curl ioping openssl bc sysstat

# Packages for PDDF

RUN apt-get install -y python-jsonschema
RUN apt-get install -y python3-jsonschema i2c-tools

RUN pip3 install pytest pexpect

Expand Down Expand Up @@ -89,7 +88,7 @@ COPY ["stress-sfp-i2c.py", "/home/pde"]
COPY ["supervisord.conf", "/etc/supervisor/conf.d/"]
COPY ["syseeprom.py", "/usr/bin/"]
COPY ["docker_init.sh", "/usr/bin/"]
COPY ["cancun_files/cancun_4.5.0/*", "cancun_files/cancun_6.6.1/*", "cancun_files/cancun_4.3.0/*", "/usr/lib/cancun/"]
COPY ["cancun_files/cancun_4.6.0/*", "cancun_files/cancun_6.9.1/*", "cancun_files/cancun_4.8.0/*", "/usr/lib/cancun/"]
COPY ["syncd_init_common.sh", "/usr/bin/"]

ENTRYPOINT ["/usr/bin/docker_init.sh"]
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
18 changes: 13 additions & 5 deletions dockers/docker-pde/docker_init.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env bash

set -x

start_bcm()
Expand All @@ -10,6 +11,8 @@ start_bcm()

PLATFORM_DIR=/usr/share/sonic/platform
HWSKU_DIR=/usr/share/sonic/hwsku
# Default use python3 version
SONIC_PLATFORM_API_PYTHON_VERSION=3

mkdir -p /etc/sai.d/

Expand All @@ -20,23 +23,28 @@ fi
. /usr/bin/syncd_init_common.sh
config_syncd

# If the sonic-platform package is not installed, try to install it
pip show sonic-platform > /dev/null 2>&1
# If the Python 3 sonic-platform package is not installed, try to install it
python3 -c "import sonic_platform" > /dev/null 2>&1 || pip3 show sonic-platform > /dev/null 2>&1
if [ $? -ne 0 ]; then
SONIC_PLATFORM_WHEEL="/usr/share/sonic/platform/sonic_platform-1.0-py2-none-any.whl"
SONIC_PLATFORM_WHEEL="/usr/share/sonic/platform/sonic_platform-1.0-py3-none-any.whl"
echo "sonic-platform package not installed, attempting to install..."
if [ -e ${SONIC_PLATFORM_WHEEL} ]; then
pip install ${SONIC_PLATFORM_WHEEL}
pip3 install ${SONIC_PLATFORM_WHEEL}
if [ $? -eq 0 ]; then
echo "Successfully installed ${SONIC_PLATFORM_WHEEL}"
SONIC_PLATFORM_API_PYTHON_VERSION=3
else
echo "Error: Failed to install ${SONIC_PLATFORM_WHEEL}"
fi
else
echo "Error: Unable to locate ${SONIC_PLATFORM_WHEEL}"
fi
else
SONIC_PLATFORM_API_PYTHON_VERSION=3
fi

start_bcm

exec /usr/bin/supervisord
exec /usr/local/bin/supervisord


254 changes: 254 additions & 0 deletions dockers/docker-pde/syncd_init_common.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,254 @@
#!/usr/bin/env bash

CMD_SYNCD=/usr/bin/syncd

# dsserve: domain socket server for stdio
CMD_DSSERVE=/usr/bin/dsserve
CMD_DSSERVE_ARGS="$CMD_SYNCD --diag"

ENABLE_SAITHRIFT=0

PLATFORM_DIR=/usr/share/sonic/platform
HWSKU_DIR=/usr/share/sonic/hwsku

SONIC_ASIC_TYPE=$(sonic-cfggen -y /etc/sonic/sonic_version.yml -v asic_type)

if [ -x $CMD_DSSERVE ]; then
CMD=$CMD_DSSERVE
CMD_ARGS=$CMD_DSSERVE_ARGS
else
CMD=$CMD_SYNCD
CMD_ARGS=
fi

# Use temporary view between init and apply
CMD_ARGS+=" -u"

case "$(cat /proc/cmdline)" in
*SONIC_BOOT_TYPE=fastfast*)
if [ -e /var/warmboot/warm-starting ]; then
FASTFAST_REBOOT='yes'
fi
;;
*SONIC_BOOT_TYPE=fast*|*fast-reboot*)
FAST_REBOOT='yes'
;;
*)
FAST_REBOOT='no'
FASTFAST_REBOOT='no'
;;
esac


function check_warm_boot()
{
# FIXME: if we want to continue start option approach, then we need to add
# code here to support redis database query.
# SYSTEM_WARM_START=`sonic-db-cli STATE_DB hget "WARM_RESTART_ENABLE_TABLE|system" enable`
# SERVICE_WARM_START=`sonic-db-cli STATE_DB hget "WARM_RESTART_ENABLE_TABLE|${SERVICE}" enable`
# SYSTEM_WARM_START could be empty, always make WARM_BOOT meaningful.
# if [[ x"$SYSTEM_WARM_START" == x"true" ]] || [[ x"$SERVICE_WARM_START" == x"true" ]]; then
# WARM_BOOT="true"
# else
WARM_BOOT="false"
# fi
}


function set_start_type()
{
if [ x"$WARM_BOOT" == x"true" ]; then
CMD_ARGS+=" -t warm"
elif [ x"$FAST_REBOOT" == x"yes" ]; then
CMD_ARGS+=" -t fast"
elif [ x"$FASTFAST_REBOOT" == x"yes" ]; then
CMD_ARGS+=" -t fastfast"
fi
}


config_syncd_bcm()
{
PLATFORM_COMMON_DIR=/usr/share/sonic/device/x86_64-broadcom_common
PLT_CONFIG_BCM=$(find $HWSKU_DIR -name '*.bcm')

if [ ! -z "$PLT_CONFIG_BCM" ]; then
cp -f $HWSKU_DIR/*.config.bcm /tmp
cp -f /etc/sai.d/sai.profile /tmp
CONFIG_BCM=$(find /tmp -name '*.bcm')
SAI_PROFILE=$(find /tmp -name 'sai.profile')
sed -i 's+/usr/share/sonic/hwsku+/tmp+g' $SAI_PROFILE

#Get first three characters of chip id
readline=$(grep '0x14e4' /proc/linux-kernel-bde)
chip_id=${readline#*0x14e4:0x}
chip_id=${chip_id::3}
COMMON_CONFIG_BCM=$(find $PLATFORM_COMMON_DIR/x86_64-broadcom_${chip_id} -name '*.bcm')

if [ -f $PLATFORM_COMMON_DIR/x86_64-broadcom_${chip_id}/*.bcm ]; then
for file in $CONFIG_BCM; do
echo "" >> $file
echo "# Start of chip common properties" >> $file
while read line
do
line=$( echo $line | xargs )
if [ ! -z "$line" ];then
if [ "${line::1}" == '#' ];then
echo $line >> $file
else
sedline=${line%=*}
if grep -q $sedline $file ;then
echo "Keep the config $(grep $sedline $file) in $file"
else
echo $line >> $file
fi
fi
fi
done < $COMMON_CONFIG_BCM
echo "# End of chip common properties" >> $file
done
echo "Merging $PLT_CONFIG_BCM with $COMMON_CONFIG_BCM, merge files stored in $CONFIG_BCM"
fi
#sync the file system
sync

# copy the final config.bcm and sai.profile to the shared folder for 'show tech'
cp -f /tmp/sai.profile /var/run/sswsyncd/
cp -f /tmp/*.bcm /var/run/sswsyncd/
fi

if [ -f "/tmp/sai.profile" ]; then
CMD_ARGS+=" -p /tmp/sai.profile"
elif [ -f "/etc/sai.d/sai.profile" ]; then
CMD_ARGS+=" -p /etc/sai.d/sai.profile"
else
CMD_ARGS+=" -p $HWSKU_DIR/sai.profile"
fi

[ -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
}

config_syncd_mlnx()
{
CMD_ARGS+=" -p /tmp/sai.profile"

[ -e /dev/sxdevs/sxcdev ] || ( mkdir -p /dev/sxdevs && mknod /dev/sxdevs/sxcdev c 231 193 )

# Read MAC address
MAC_ADDRESS="$(sonic-cfggen -d -v DEVICE_METADATA.localhost.mac)"

# Write MAC address into /tmp/profile file.
cat $HWSKU_DIR/sai.profile > /tmp/sai.profile
echo "DEVICE_MAC_ADDRESS=$MAC_ADDRESS" >> /tmp/sai.profile
echo "SAI_WARM_BOOT_WRITE_FILE=/var/warmboot/" >> /tmp/sai.profile
}

config_syncd_centec()
{
CMD_ARGS+=" -p $HWSKU_DIR/sai.profile"

[ -e /dev/linux_dal ] || mknod /dev/linux_dal c 198 0
[ -e /dev/net/tun ] || ( mkdir -p /dev/net && mknod /dev/net/tun c 10 200 )
}

config_syncd_cavium()
{
CMD_ARGS+=" -p $HWSKU_DIR/sai.profile -d"

export XP_ROOT=/usr/bin/

# Wait until redis-server starts
until [ $(sonic-db-cli PING | grep -c PONG) -gt 0 ]; do
sleep 1
done
}

config_syncd_marvell()
{
CMD_ARGS+=" -p $HWSKU_DIR/sai.profile"

[ -e /dev/net/tun ] || ( mkdir -p /dev/net && mknod /dev/net/tun c 10 200 )
}

config_syncd_barefoot()
{
PROFILE_FILE="$HWSKU_DIR/sai.profile"
if [ ! -f $PROFILE_FILE ]; then
# default profile file
PROFILE_FILE="/tmp/sai.profile"
echo "SAI_KEY_WARM_BOOT_WRITE_FILE=/var/warmboot/sai-warmboot.bin" > $PROFILE_FILE
echo "SAI_KEY_WARM_BOOT_READ_FILE=/var/warmboot/sai-warmboot.bin" >> $PROFILE_FILE
fi
CMD_ARGS+=" -p $PROFILE_FILE"

# Check and load SDE profile
P4_PROFILE=$(sonic-cfggen -d -v 'DEVICE_METADATA["localhost"]["p4_profile"]')
if [[ -n "$P4_PROFILE" ]]; then
if [[ ( -d /opt/bfn/install_${P4_PROFILE} ) && ( -L /opt/bfn/install || ! -e /opt/bfn/install ) ]]; then
ln -srfn /opt/bfn/install_${P4_PROFILE} /opt/bfn/install
fi
fi
export PYTHONHOME=/opt/bfn/install/
export PYTHONPATH=/opt/bfn/install/
export ONIE_PLATFORM=`grep onie_platform /etc/machine.conf | awk 'BEGIN { FS = "=" } ; { print $2 }'`
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/bfn/install/lib/platform/$ONIE_PLATFORM:/opt/bfn/install/lib:/opt/bfn/install/lib/tofinopd/switch
./opt/bfn/install/bin/dma_setup.sh
}

config_syncd_nephos()
{
CMD_ARGS+=" -p $HWSKU_DIR/sai.profile"
}

config_syncd_vs()
{
CMD_ARGS+=" -p $HWSKU_DIR/sai.profile"
}

config_syncd_innovium()
{
CMD_ARGS+=" -p $HWSKU_DIR/sai.profile"
ulimit -s 65536
export II_ROOT="/var/log/invm"
export II_APPEND_LOG=1
mkdir -p $II_ROOT
}

config_syncd()
{
check_warm_boot

if [ "$SONIC_ASIC_TYPE" == "broadcom" ]; then
config_syncd_bcm
elif [ "$SONIC_ASIC_TYPE" == "mellanox" ]; then
config_syncd_mlnx
elif [ "$SONIC_ASIC_TYPE" == "cavium" ]; then
config_syncd_cavium
elif [ "$SONIC_ASIC_TYPE" == "centec" ]; then
config_syncd_centec
elif [ "$SONIC_ASIC_TYPE" == "marvell" ]; then
config_syncd_marvell
elif [ "$SONIC_ASIC_TYPE" == "barefoot" ]; then
config_syncd_barefoot
elif [ "$SONIC_ASIC_TYPE" == "nephos" ]; then
config_syncd_nephos
elif [ "$SONIC_ASIC_TYPE" == "vs" ]; then
config_syncd_vs
elif [ "$SONIC_ASIC_TYPE" == "innovium" ]; then
config_syncd_innovium
else
echo "Unknown ASIC type $SONIC_ASIC_TYPE"
exit 1
fi

set_start_type

if [ ${ENABLE_SAITHRIFT} == 1 ]; then
CMD_ARGS+=" -r -m $HWSKU_DIR/port_config.ini"
fi

[ -r $PLATFORM_DIR/syncd.conf ] && . $PLATFORM_DIR/syncd.conf
}

16 changes: 10 additions & 6 deletions platform/broadcom/docker-pde.mk
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,20 @@ ifeq ($(PDDF_SUPPORT), y)
$(DOCKER_PDE)_PYTHON_WHEELS += $(PDDF_PLATFORM_API_BASE_PY3)
endif
$(DOCKER_PDE)_PYTHON_WHEELS += $(SONIC_DAEMON_BASE_PY3)
$(DOCKER_PDE)_DBG_DEPENDS = $($(DOCKER_CONFIG_ENGINE_BUSTER)_DBG_DEPENDS)
$(DOCKER_PDE)_DBG_IMAGE_PACKAGES = $($(DOCKER_CONFIG_ENGINE_BUSTER)_DBG_IMAGE_PACKAGES)
$(DOCKER_PDE)_LOAD_DOCKERS = $(DOCKER_CONFIG_ENGINE_BUSTER)
$(DOCKER_PDE)_DBG_DEPENDS = $($(DOCKER_CONFIG_ENGINE_BULLSEYE)_DBG_DEPENDS)
$(DOCKER_PDE)_DBG_IMAGE_PACKAGES = $($(DOCKER_CONFIG_ENGINE_BULLSEYE)_DBG_IMAGE_PACKAGES)
$(DOCKER_PDE)_LOAD_DOCKERS = $(DOCKER_CONFIG_ENGINE_BULLSEYE)

SONIC_DOCKER_IMAGES += $(DOCKER_PDE)
SONIC_BUSTER_DOCKERS += $(DOCKER_PDE)
SONIC_BULLSEYE_DOCKERS += $(DOCKER_PDE)
SONIC_INSTALL_DOCKER_IMAGES += $(DOCKER_PDE)
SONIC_BUSTER_DBG_DOCKERS += $(DOCKER_PDE_DBG)
SONIC_BULLSEYE_DBG_DOCKERS += $(DOCKER_PDE_DBG)
SONIC_DOCKER_DBG_IMAGES += $(DOCKER_PDE_DBG)
SONIC_INSTALL_DOCKER_DBG_IMAGES += $(DOCKER_PDE_DBG)

$(DOCKER_PDE)_VERSION = 1.0.0
$(DOCKER_PDE)_PACKAGE_NAME = pde

$(DOCKER_PDE)_CONTAINER_NAME = pde
$(DOCKER_PDE)_RUN_OPT += --privileged -t
$(DOCKER_PDE)_RUN_OPT += -v /etc/sonic:/etc/sonic:ro
Expand All @@ -35,12 +38,13 @@ $(DOCKER_PDE)_RUN_OPT += -v /usr/lib/python2.7/dist-packages:/usr/share/sonic/cl

$(DOCKER_PDE)_RUN_OPT += -v /usr/local/lib/python3.7/dist-packages/utilities_common:/usr/local/lib/python3.7/dist-packages/utilities_common:ro
$(DOCKER_PDE)_RUN_OPT += -v /var/log/syslog:/var/log/syslog:ro
$(DOCKER_PDE)_RUN_OPT += -v /var/log/ramfs:/var/log/ramfs:ro
$(DOCKER_PDE)_RUN_OPT += -v /lib/modules:/lib/modules:ro
$(DOCKER_PDE)_RUN_OPT += -v /boot:/boot:ro
$(DOCKER_PDE)_RUN_OPT += -v /var/log/ramfs:/var/log/ramfs:ro
$(DOCKER_PDE)_RUN_OPT += -v /usr/share/sonic/device/x86_64-broadcom_common:/usr/share/sonic/device/x86_64-broadcom_common:ro
$(DOCKER_PDE)_RUN_OPT += -v /usr/share/sonic/device/pddf:/usr/share/sonic/device/pddf:ro

$(DOCKER_PDE)_RUN_OPT += -v /usr/share/sonic/device/x86_64-broadcom_common:/usr/share/sonic/device/x86_64-broadcom_common:ro
$(DOCKER_PDE)_BASE_IMAGE_FILES += pde-test:/usr/local/bin/pde-test
$(DOCKER_PDE)_BASE_IMAGE_FILES += pde-bench:/usr/local/bin/pde-bench
$(DOCKER_PDE)_BASE_IMAGE_FILES += pde-stress:/usr/local/bin/pde-stress
Expand Down

0 comments on commit 89851c1

Please sign in to comment.