From c1524191c8a0aa0770288e4b5f846c87729c3bd3 Mon Sep 17 00:00:00 2001 From: Geans Pin Date: Mon, 3 May 2021 17:07:58 -0700 Subject: [PATCH 01/28] Initial commit for introducing the SONiC Platform Development Env (Resubmit PR#3778) --- Makefile.work | 19 +- dockers/docker-pde/Dockerfile.j2 | 91 +++++ dockers/docker-pde/base_image_files/pde-bench | 38 ++ .../base_image_files/pde-bench-knet | 326 ++++++++++++++++++ .../docker-pde/base_image_files/pde-stress | 27 ++ dockers/docker-pde/base_image_files/pde-test | 59 ++++ dockers/docker-pde/bench.sh | 140 ++++++++ dockers/docker-pde/docker_init.sh | 45 +++ dockers/docker-pde/stress-sfp-i2c.py | 157 +++++++++ dockers/docker-pde/supervisord.conf | 12 + dockers/docker-pde/syseeprom.py | 67 ++++ files/build_templates/docker_image_ctl.j2 | 10 + files/build_templates/pde.service.j2 | 22 ++ platform/broadcom/docker-pde.dep | 12 + platform/broadcom/docker-pde.mk | 53 +++ platform/broadcom/one-pde-image.mk | 81 +++++ platform/broadcom/sonic-pde-tests.dep | 12 + platform/broadcom/sonic-pde-tests.mk | 7 + rules/config | 2 + slave.mk | 5 + 20 files changed, 1184 insertions(+), 1 deletion(-) create mode 100644 dockers/docker-pde/Dockerfile.j2 create mode 100644 dockers/docker-pde/base_image_files/pde-bench create mode 100644 dockers/docker-pde/base_image_files/pde-bench-knet create mode 100644 dockers/docker-pde/base_image_files/pde-stress create mode 100644 dockers/docker-pde/base_image_files/pde-test create mode 100644 dockers/docker-pde/bench.sh create mode 100644 dockers/docker-pde/docker_init.sh create mode 100644 dockers/docker-pde/stress-sfp-i2c.py create mode 100644 dockers/docker-pde/supervisord.conf create mode 100644 dockers/docker-pde/syseeprom.py create mode 100644 files/build_templates/pde.service.j2 create mode 100644 platform/broadcom/docker-pde.dep create mode 100644 platform/broadcom/docker-pde.mk create mode 100644 platform/broadcom/one-pde-image.mk create mode 100644 platform/broadcom/sonic-pde-tests.dep create mode 100644 platform/broadcom/sonic-pde-tests.mk diff --git a/Makefile.work b/Makefile.work index 591ea051d98f..fcc28fac9c30 100644 --- a/Makefile.work +++ b/Makefile.work @@ -241,6 +241,7 @@ SONIC_BUILD_INSTRUCTION := make \ SONIC_IMAGE_VERSION=$(SONIC_IMAGE_VERSION) \ ENABLE_DHCP_GRAPH_SERVICE=$(ENABLE_DHCP_GRAPH_SERVICE) \ ENABLE_ZTP=$(ENABLE_ZTP) \ + ENABLE_PDE=$(ENABLE_PDE) \ SHUTDOWN_BGP_ON_START=$(SHUTDOWN_BGP_ON_START) \ INCLUDE_KUBERNETES=$(INCLUDE_KUBERNETES) \ KUBERNETES_VERSION=$(KUBERNETES_VERSION) \ @@ -271,7 +272,18 @@ SONIC_BUILD_INSTRUCTION := make \ SLAVE_DIR=$(SLAVE_DIR) \ $(SONIC_OVERRIDE_BUILD_VARS) -.PHONY: sonic-slave-build sonic-slave-bash init reset +PDESUBMODULES = src/sonic-linux-kernel \ + src/sonic-utilities \ + src/sonic-platform-common \ + src/sonic-swss-common \ + src/sonic-swss \ + src/sonic-py-swsssdk \ + src/redis-dump-load \ + src/sonic-sairedis \ + src/sonic-ztp \ + src/sonic-platform-daemons \ + src/sonic-platform-pde +.PHONY: sonic-slave-build sonic-slave-bash init initpde reset .DEFAULT_GOAL := all @@ -340,6 +352,11 @@ showtag: @echo $(SLAVE_IMAGE):$(SLAVE_TAG) @echo $(SLAVE_BASE_IMAGE):$(SLAVE_BASE_TAG) +initpde: + $(QUIET)for submodule in $(PDESUBMODULES) ; do \ + git submodule update --init --recursive $$submodule ; \ + done + $(QUIET)git submodule foreach --recursive '[ -f .git ] && echo "gitdir: $$(realpath --relative-to=. $$(cut -d" " -f2 .git))" > .git' init : @git submodule update --init --recursive @git submodule foreach --recursive '[ -f .git ] && echo "gitdir: $$(realpath --relative-to=. $$(cut -d" " -f2 .git))" > .git' diff --git a/dockers/docker-pde/Dockerfile.j2 b/dockers/docker-pde/Dockerfile.j2 new file mode 100644 index 000000000000..01e857b045ea --- /dev/null +++ b/dockers/docker-pde/Dockerfile.j2 @@ -0,0 +1,91 @@ +FROM {{ docker_pde_load_image }} + +ARG docker_container_name +ENV PYTHONPATH=/usr/share/sonic/platform + +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 + +{% if ARTIFACTORY_URL is defined and ARTIFACTORY_URL|length -%} +# Insert Artifactory URL references +COPY ["files/03_stretch_af.list", "/etc/apt/sources.list.d/"] +{%- endif %} + +# Update apt's cache of available packages +RUN apt-get update && apt-get install -y ipmitool telnet busybox kmod libpcap-dev + +# Packages for benchmark tool - nench.sh +RUN apt-get install -y bzip2 curl ioping openssl bc sysstat + +# Packages for PDDF +RUN apt-get install -y python-jsonschema i2c-tools + +RUN pip install pytest pexpect + +{% if docker_pde_debs.strip() -%} +# Copy locally-built Debian package dependencies +COPY \ +{% for deb in docker_pde_debs.split(' ') -%} +debs/{{ deb }}{{' '}} +{%- endfor -%} +/debs/ + +# Install locally-built Debian packages and implicitly install their dependencies +RUN dpkg_apt() { [ -f $1 ] && { dpkg -i $1 || apt-get -y install -f; } || return 1; }{%- for deb in docker_pde_debs.split(' ') %}; \ +dpkg_apt /debs/{{ deb }} +{%- endfor %} +{%- endif %} + +{% if docker_pde_pydebs.strip() -%} +# Copy locally-built Debian package dependencies +COPY \ +{% for deb in docker_pde_pydebs.split(' ') -%} +python-debs/{{ deb }}{{' '}} +{%- endfor -%} +/debs/ + +# Install locally-built Debian packages and implicitly install their dependencies +{%- for deb in docker_pde_pydebs.split(' ') %} +RUN dpkg_apt() { [ -f $1 ] && { dpkg -i $1 || apt-get -y install -f; } || return 1; }; dpkg_apt /debs/{{ deb }} +{%- endfor %} +{%- endif %} + +{% if docker_pde_whls.strip() -%} +# Copy locally-built Python wheel dependencies +COPY \ +{% for whl in docker_pde_whls.split(' ') -%} +python-wheels/{{ whl }}{{' '}} +{%- endfor -%} +/python-wheels/ + +# Install locally-built Python wheel dependencies +RUN pip install \ +{% for whl in docker_pde_whls.split(' ') -%} +/python-wheels/{{ whl }}{{' '}} +{%- endfor %} +{% endif %} + +{% if ARTIFACTORY_URL is defined and ARTIFACTORY_URL|length -%} +# Remove Artifactory URL references +RUN rm -f /etc/apt/sources.list.d/03_stretch_af.list && apt-get update +{%- endif %} + +# Clean up +RUN apt-get clean -y; \ + apt-get autoclean -y; \ + apt-get autoremove -y +RUN rm -rf /debs ~/.cache + +RUN mkdir -p /home/pde + +COPY ["bench.sh", "/usr/bin/"] +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 ["syncd_init_common.sh", "/usr/bin/"] + +ENTRYPOINT ["/usr/bin/docker_init.sh"] diff --git a/dockers/docker-pde/base_image_files/pde-bench b/dockers/docker-pde/base_image_files/pde-bench new file mode 100644 index 000000000000..1e2c727b02af --- /dev/null +++ b/dockers/docker-pde/base_image_files/pde-bench @@ -0,0 +1,38 @@ +#!/bin/bash + +CSV=/tmp/bench.csv + +# Make sure only root can run our script +if [ "$(id -u)" != "0" ]; then + echo "This script must be run as root" 1>&2 + exit 1 +fi + +# Start PDE if it's deactivated +if [ $(docker ps | grep -c pde) -eq 0 ]; then + pde.sh start +fi + +# Allow 5 seconds for PDE to be coming up +for t in $(seq 1 5) +do + if [ $(docker ps | grep -c pde) -gt 0 ]; then + break + fi + sleep 1 +done +if [ $(docker ps | grep -c pde) -eq 0 ]; then + echo "docker-pde is not alive, existing ..." + exit 1 +fi + +# Launch the benchmark test suite +docker exec -it pde /usr/bin/bench.sh +echo "$(docker exec -it pde cat ${CSV})" > ${CSV} + +echo "" +echo "CSV Report: ${CSV}" +echo "-----------------------------------------------------------------------" +echo "$(cat ${CSV})" +echo "-----------------------------------------------------------------------" + diff --git a/dockers/docker-pde/base_image_files/pde-bench-knet b/dockers/docker-pde/base_image_files/pde-bench-knet new file mode 100644 index 000000000000..cc75962eff35 --- /dev/null +++ b/dockers/docker-pde/base_image_files/pde-bench-knet @@ -0,0 +1,326 @@ +#!/bin/bash + +PLATF_DIR=/usr/share/sonic/platform +HWSKU_DIR=/usr/share/sonic/hwsku +PORT=Ethernet0 +LANE=1 +SPEED=0 +BCMPORT=ce0 +DURATION=5 + +PPS_128=0 +BPS_128=0 +PPS_256=0 +BPS_256=0 +PPS_512=0 +BPS_512=0 +PPS_1024=0 +BPS_1024=0 +PPS_2048=0 +BPS_2048=0 +PPS_4096=0 +BPS_4096=0 +PPS_8192=0 +BPS_8192=0 +PPS_9000=0 +BPS_9000=0 + +# SWSS is mandatory for KNET benchmark +sudo systemctl start swss +for t in $(seq 1 15) +do + if [ $(docker ps | grep -c swss) -gt 0 ]; then + break + fi + sleep 1 +done +if [ $(docker ps | grep -c swss) -eq 0 ]; then + echo "ERR: docker-swss is not alive, existing ..." + exit 1 +fi + +# Find out the PLATFORM and HWSKU +if [ ! -d ${PLATF_DIR} ]; then + name=$(grep 'onie_platform=' /host/machine.conf | cut -d '=' -f 2) + PLATF_DIR=/usr/share/sonic/device/${name} +fi + +if [ ! -d ${HWSKU_DIR} ]; then + name=$(head -1 ${PLATF_DIR}/default_sku | awk '{print $1}') + HWSKU_DIR=${PLATF_DIR}/${name} +fi + +echo "PLATFORM='${PLATF_DIR}'" +echo "HWSKU='${HWSKU_DIR}'" + +# Determine the target port for KNET benchmark +while IFS= read -r line; do + line=$(echo ${line} | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//') + if [[ ${line} = \#* ]]; then + continue + fi + port=$(echo ${line} | awk '{print $1}') + lane=$(echo ${line} | awk '{print $2}' | cut -d ',' -f 1) + speed=$(echo ${line} | awk '{print $5}') + if [ -z "${speed}" ]; then + continue + fi + if [ ${speed} -gt ${SPEED} ]; then + PORT=${port} + LANE=${lane} + SPEED=${speed} + fi +done < ${HWSKU_DIR}/port_config.ini + +echo "PORT=${PORT}" +echo "LANE=${LANE}" +echo "SPEED=${SPEED}" + +# Find out the name of the corresponding bcm port +TEMP=$(mktemp) +bcmcmd 'show pmap' | grep ${LANE} > ${TEMP} +while IFS= read -r line; do + line=$(echo ${line} | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//') + if [ $(echo ${line} | awk '{print $4}') -eq ${LANE} ]; then + BCMPORT=$(echo ${line} | awk '{print $1}') + break + fi +done < ${TEMP} +rm -f ${TEMP} + +echo "BCMPORT=${BCMPORT}" + +# SWSS: Update the LLDP rate limit +TEMP=$(mktemp) +rm -f ${TEMP}.* +docker cp swss:/etc/swss/config.d/00-copp.config.json ${TEMP}.old +if [ ! -f ${TEMP}.old ]; then + echo "Unable to get 00-copp.config.json from docker-swss" +fi + +lldp=0 +while IFS= read -r line +do + if [ $(echo $line | grep -c -E '\"COPP_TABLE:') -gt 0 ]; then + lldp=0 + fi + if [ $(echo $line | grep -c -E 'trap_ids.*,lldp') -gt 0 ]; then + lldp=1 + fi + if [ $lldp -gt 0 ]; then + if [ $(echo $line | grep -c -E '.*\"cir\"') -gt 0 ]; then + echo "${line%:*}:\"30000\"," >> ${TEMP}.new + lldp=$(expr $lldp + 1) + continue + fi + if [ $(echo $line | grep -c -E '.*\"cbs\"') -gt 0 ]; then + echo "${line%:*}:\"30000\"," >> ${TEMP}.new + lldp=$(expr $lldp + 1) + continue + fi + fi + echo "$line" >> ${TEMP}.new +done < "${TEMP}.old" + +csum1=$(md5sum ${TEMP}.old | cut -d ' ' -f 1) +csum2=$(md5sum ${TEMP}.new | cut -d ' ' -f 1) +if [ "${csum1}" != "${csum2}" ]; then + docker cp ${TEMP}.new swss:/etc/swss/config.d/00-copp.config.json + sudo config copp rx-rate 100000 + sudo config save -y + sudo config reload -y +fi + +# Disable ZTP +sudo config ztp disable -y > /dev/null 2>&1 + +# Enable the target port for benchmarking +echo "Allow 15 seconds for ${PORT} getting ready" + +for tick in $(seq 1 15); do + if [ -d /sys/class/net/${PORT} ]; then + break + fi + sleep 1 +done +sudo config interface startup ${PORT} > /dev/null 2>&1 + +# Enable MAC loopback mode to the target port +bcmcmd "port ${BCMPORT} lb=mac" > /dev/null 2>&1 + +# Get started with the loopback benchmark test +# + +# 128B +P1=$(cat /sys/class/net/${PORT}/statistics/rx_packets) +B1=$(cat /sys/class/net/${PORT}/statistics/rx_bytes) +if [ $(docker ps | grep -c pde) -gt 0 ]; then + docker exec -it pde /usr/local/bin/pktsend ${PORT} ${DURATION} 128 +else + /usr/local/bin/pktsend ${PORT} ${DURATION} 128 +fi +P2=$(cat /sys/class/net/${PORT}/statistics/rx_packets) +B2=$(cat /sys/class/net/${PORT}/statistics/rx_bytes) +NUM=$(expr ${P2} - ${P1}) +PPS=$(expr ${NUM} / ${DURATION}) +NUM=$(expr ${B2} - ${B1}) +BPS=$(expr ${NUM} / ${DURATION}) +BPS=$(expr ${BPS} / 1000000) +BPS=$(expr ${BPS} \* 8) +echo "PPS=${PPS}, BPS=${BPS}Mbps" +PPS_128=${PPS} +BPS_128=${BPS} + +# 256B +P1=$(cat /sys/class/net/${PORT}/statistics/rx_packets) +B1=$(cat /sys/class/net/${PORT}/statistics/rx_bytes) +if [ $(docker ps | grep -c pde) -gt 0 ]; then + docker exec -it pde /usr/local/bin/pktsend ${PORT} ${DURATION} 256 +else + /usr/local/bin/pktsend ${PORT} ${DURATION} 256 +fi +P2=$(cat /sys/class/net/${PORT}/statistics/rx_packets) +B2=$(cat /sys/class/net/${PORT}/statistics/rx_bytes) +NUM=$(expr ${P2} - ${P1}) +PPS=$(expr ${NUM} / ${DURATION}) +NUM=$(expr ${B2} - ${B1}) +BPS=$(expr ${NUM} / ${DURATION}) +BPS=$(expr ${BPS} / 1000000) +BPS=$(expr ${BPS} \* 8) +echo "PPS=${PPS}, BPS=${BPS}Mbps" +PPS_256=${PPS} +BPS_256=${BPS} + +# 512B +P1=$(cat /sys/class/net/${PORT}/statistics/rx_packets) +B1=$(cat /sys/class/net/${PORT}/statistics/rx_bytes) +if [ $(docker ps | grep -c pde) -gt 0 ]; then + docker exec -it pde /usr/local/bin/pktsend ${PORT} ${DURATION} 512 +else + /usr/local/bin/pktsend ${PORT} ${DURATION} 512 +fi +P2=$(cat /sys/class/net/${PORT}/statistics/rx_packets) +B2=$(cat /sys/class/net/${PORT}/statistics/rx_bytes) +NUM=$(expr ${P2} - ${P1}) +PPS=$(expr ${NUM} / ${DURATION}) +NUM=$(expr ${B2} - ${B1}) +BPS=$(expr ${NUM} / ${DURATION}) +BPS=$(expr ${BPS} / 1000000) +BPS=$(expr ${BPS} \* 8) +echo "PPS=${PPS}, BPS=${BPS}Mbps" +PPS_512=${PPS} +BPS_512=${BPS} + +# 1024B +P1=$(cat /sys/class/net/${PORT}/statistics/rx_packets) +B1=$(cat /sys/class/net/${PORT}/statistics/rx_bytes) +if [ $(docker ps | grep -c pde) -gt 0 ]; then + docker exec -it pde /usr/local/bin/pktsend ${PORT} ${DURATION} 1024 +else + /usr/local/bin/pktsend ${PORT} ${DURATION} 1024 +fi +P2=$(cat /sys/class/net/${PORT}/statistics/rx_packets) +B2=$(cat /sys/class/net/${PORT}/statistics/rx_bytes) +NUM=$(expr ${P2} - ${P1}) +PPS=$(expr ${NUM} / ${DURATION}) +NUM=$(expr ${B2} - ${B1}) +BPS=$(expr ${NUM} / ${DURATION}) +BPS=$(expr ${BPS} / 1000000) +BPS=$(expr ${BPS} \* 8) +echo "PPS=${PPS}, BPS=${BPS}Mbps" +PPS_1024=${PPS} +BPS_1024=${BPS} + +# 2048B +P1=$(cat /sys/class/net/${PORT}/statistics/rx_packets) +B1=$(cat /sys/class/net/${PORT}/statistics/rx_bytes) +if [ $(docker ps | grep -c pde) -gt 0 ]; then + docker exec -it pde /usr/local/bin/pktsend ${PORT} ${DURATION} 2048 +else + /usr/local/bin/pktsend ${PORT} ${DURATION} 2048 +fi +P2=$(cat /sys/class/net/${PORT}/statistics/rx_packets) +B2=$(cat /sys/class/net/${PORT}/statistics/rx_bytes) +NUM=$(expr ${P2} - ${P1}) +PPS=$(expr ${NUM} / ${DURATION}) +NUM=$(expr ${B2} - ${B1}) +BPS=$(expr ${NUM} / ${DURATION}) +BPS=$(expr ${BPS} / 1000000) +BPS=$(expr ${BPS} \* 8) +echo "PPS=${PPS}, BPS=${BPS}Mbps" +PPS_2048=${PPS} +BPS_2048=${BPS} + +# 4096B +P1=$(cat /sys/class/net/${PORT}/statistics/rx_packets) +B1=$(cat /sys/class/net/${PORT}/statistics/rx_bytes) +if [ $(docker ps | grep -c pde) -gt 0 ]; then + docker exec -it pde /usr/local/bin/pktsend ${PORT} ${DURATION} 4096 +else + /usr/local/bin/pktsend ${PORT} ${DURATION} 4096 +fi +P2=$(cat /sys/class/net/${PORT}/statistics/rx_packets) +B2=$(cat /sys/class/net/${PORT}/statistics/rx_bytes) +NUM=$(expr ${P2} - ${P1}) +PPS=$(expr ${NUM} / ${DURATION}) +NUM=$(expr ${B2} - ${B1}) +BPS=$(expr ${NUM} / ${DURATION}) +BPS=$(expr ${BPS} / 1000000) +BPS=$(expr ${BPS} \* 8) +echo "PPS=${PPS}, BPS=${BPS}Mbps" +PPS_4096=${PPS} +BPS_4096=${BPS} + +# 8192B +P1=$(cat /sys/class/net/${PORT}/statistics/rx_packets) +B1=$(cat /sys/class/net/${PORT}/statistics/rx_bytes) +if [ $(docker ps | grep -c pde) -gt 0 ]; then + docker exec -it pde /usr/local/bin/pktsend ${PORT} ${DURATION} 8192 +else + /usr/local/bin/pktsend ${PORT} ${DURATION} 8192 +fi +P2=$(cat /sys/class/net/${PORT}/statistics/rx_packets) +B2=$(cat /sys/class/net/${PORT}/statistics/rx_bytes) +NUM=$(expr ${P2} - ${P1}) +PPS=$(expr ${NUM} / ${DURATION}) +NUM=$(expr ${B2} - ${B1}) +BPS=$(expr ${NUM} / ${DURATION}) +BPS=$(expr ${BPS} / 1000000) +BPS=$(expr ${BPS} \* 8) +echo "PPS=${PPS}, BPS=${BPS}Mbps" +PPS_8192=${PPS} +BPS_8192=${BPS} + +# 9000B +P1=$(cat /sys/class/net/${PORT}/statistics/rx_packets) +B1=$(cat /sys/class/net/${PORT}/statistics/rx_bytes) +if [ $(docker ps | grep -c pde) -gt 0 ]; then + docker exec -it pde /usr/local/bin/pktsend ${PORT} ${DURATION} 9000 +else + /usr/local/bin/pktsend ${PORT} ${DURATION} 9000 +fi +P2=$(cat /sys/class/net/${PORT}/statistics/rx_packets) +B2=$(cat /sys/class/net/${PORT}/statistics/rx_bytes) +NUM=$(expr ${P2} - ${P1}) +PPS=$(expr ${NUM} / ${DURATION}) +NUM=$(expr ${B2} - ${B1}) +BPS=$(expr ${NUM} / ${DURATION}) +BPS=$(expr ${BPS} / 1000000) +BPS=$(expr ${BPS} \* 8) +echo "PPS=${PPS}, BPS=${BPS}Mbps" +PPS_9000=${PPS} +BPS_9000=${BPS} + +# Disable MAC loopback mode to the target port +bcmcmd "port ${BCMPORT} lb=none" > /dev/null 2>&1 + +# Generate the final report +echo "payload size,loopback pps(Pkt/s),loopback Mbps(Mbit/s)" +echo "128B,${PPS_128},${BPS_128}" +echo "256B,${PPS_256},${BPS_256}" +echo "512B,${PPS_512},${BPS_512}" +echo "1024B,${PPS_1024},${BPS_1024}" +echo "2048B,${PPS_2048},${BPS_2048}" +echo "4096B,${PPS_4096},${BPS_4096}" +echo "8192B,${PPS_8192},${BPS_8192}" +echo "9000B,${PPS_9000},${BPS_9000}" diff --git a/dockers/docker-pde/base_image_files/pde-stress b/dockers/docker-pde/base_image_files/pde-stress new file mode 100644 index 000000000000..4ee4752a8b1e --- /dev/null +++ b/dockers/docker-pde/base_image_files/pde-stress @@ -0,0 +1,27 @@ +#!/bin/bash + +# Make sure only root can run our script +if [ "$(id -u)" != "0" ]; then + echo "This script must be run as root" 1>&2 + exit 1 +fi + +# Start PDE if it's deactivated +if [ $(docker ps | grep -c pde) -eq 0 ]; then + pde.sh start +fi + +# Allow 5 seconds for PDE to be coming up +for t in $(seq 1 5) +do + if [ $(docker ps | grep -c pde) -gt 0 ]; then + break + fi +done +if [ $(docker ps | grep -c pde) -eq 0 ]; then + echo "docker-pde is not alive, existing ..." + exit 1 +fi + +# Now launch the PDE stress test +docker exec -it pde /home/pde/stress-sfp-i2c.py $* diff --git a/dockers/docker-pde/base_image_files/pde-test b/dockers/docker-pde/base_image_files/pde-test new file mode 100644 index 000000000000..046a9f067480 --- /dev/null +++ b/dockers/docker-pde/base_image_files/pde-test @@ -0,0 +1,59 @@ +#!/bin/bash + +# Make sure only root can run our script +if [ "$(id -u)" != "0" ]; then + echo "This script must be run as root" 1>&2 + exit 1 +fi + +# Make sure SWSS is deactivated +if [ $(docker ps | grep -c swss) -ne 0 ]; then + systemctl stop swss + sleep 3 +fi + +# Start PDE if it's deactivated +if [ $(docker ps | grep -c pde) -eq 0 ]; then + pde.sh start +fi + +# Allow 5 seconds for PDE to be coming up +for t in $(seq 1 5) +do + if [ $(docker ps | grep -c pde) -gt 0 ]; then + break + fi +done +if [ $(docker ps | grep -c pde) -eq 0 ]; then + echo "docker-pde is not alive, existing ..." + exit 1 +fi + +usage() +{ + echo "usage: $0 " + exit 1 +} + +if [ $# -lt 1 ] +then + usage +fi + +case $1 in +-h | help) + usage + ;; +-l | ls | list) + docker exec -it -w /usr/local/sonic_pde_tests pde ls + exit 0 + ;; +*) + ;; +esac + +# Now launch the PDE pytest +docker exec -it -w /usr/local/sonic_pde_tests pde pytest $* + +# Reactivate the SWSS +systemctl start swss diff --git a/dockers/docker-pde/bench.sh b/dockers/docker-pde/bench.sh new file mode 100644 index 000000000000..2a0951490918 --- /dev/null +++ b/dockers/docker-pde/bench.sh @@ -0,0 +1,140 @@ +#!/bin/bash + +CSV=/tmp/bench.csv + +TST_FREQ=2000 +TST_CORE=4 +TST_RAMSZ=8 +TST_DISKSZ=14 +TST_SHA=10 +TST_BZ2=30 +TST_AES=5 +TST_DISKRD=180 +TST_DISKWR=30 + +cpu_benchmark() +{ + export TIMEFORMAT='%1R' + (time dd if=/dev/zero bs=1M count=500 2> /dev/null | \ + "$@" > /dev/null ) 2>&1 +} + +# Platform Info +PLATFORM=$(grep 'onie_platform=' /host/machine.conf | cut -d '=' -f 2) +echo "Platform: ${PLATFORM}" + +if [ -d /usr/share/sonic/platform ]; then + HWSKU=$(head -1 /usr/share/sonic/platform/default_sku | awk '{print $1}') +else + HWSKU=$(head -1 /usr/share/sonic/device/${PLATFORM}/default_sku | awk '{print $1}') +fi +echo "HWSKU: ${HWSKU}" + +REVISION=$(syseeprom.py 0x27) +echo "Revision: ${REVISION}" + +# Basic Info +CPU_NAME=$(awk -F: '/model name/ {name=$2} END {print name}' /proc/cpuinfo | cut -d '@' -f 1 | sed 's/^[ \t]*//;s/[ \t]*$//') +echo "CPU NAME: ${CPU_NAME}" + +if [ $(lscpu | grep -c 'CPU max MHz') -gt 0 ]; then + CPU_FREQ=$(lscpu | grep 'CPU max MHz' | cut -d ':' -f 2 | cut -d '.' -f 1 | sed 's/^[[:space:]]*//') +else + CPU_FREQ=$(lscpu | grep 'CPU MHz' | cut -d ':' -f 2 | cut -d '.' -f 1 | sed 's/^[[:space:]]*//') +fi +echo -n "CPU FREQ: ${CPU_FREQ} MHz ........" +if [ ${CPU_FREQ} -ge ${TST_FREQ} ]; then + echo "pass" +else + echo "FAIL" +fi + +CPU_CORE=$(awk -F: '/model name/ {core++} END {print core}' /proc/cpuinfo) +echo -n "CPU CORE: ${CPU_CORE} ..............." +if [ ${CPU_CORE} -ge ${TST_CORE} ]; then + echo "pass" +else + echo "FAIL" +fi + +RAM_SIZE=$(grep MemTotal /proc/meminfo | awk '{print $2}') +RAM_SIZE=$(expr ${RAM_SIZE} / 1024) # MB +RAM_SIZE=$(expr ${RAM_SIZE} + 1023) +RAM_SIZE=$(expr ${RAM_SIZE} / 1024) # GB +echo -n "RAM SIZE: ${RAM_SIZE} GB ..........." +if [ ${RAM_SIZE} -ge ${TST_RAMSZ} ]; then + echo "pass" +else + echo "FAIL" +fi + +DISK_SIZE=$(lsblk -d | grep disk | head -1 | awk '{print $4}' | cut -d 'G' -f 1) +echo -n "DISK: ${DISK_SIZE} GB ..........." +if [ $(expr ${DISK_SIZE} \>= ${TST_DISKSZ}) -eq 1 ]; then + echo "pass" +else + echo "FAIL" +fi + +# CPU tests +SHA_TIME=$(cpu_benchmark sha256sum) +echo -n "SHA256: ${SHA_TIME} sec ........." +if [ $(echo "${SHA_TIME} <= ${TST_SHA}" | bc) -eq 1 ]; then + echo "pass" +else + echo "FAIL" +fi + +BZ2_TIME=$(cpu_benchmark bzip2) +echo -n "BZIP2: ${BZ2_TIME} sec ........." +if [ $(echo "${BZ2_TIME} <= ${TST_BZ2}" | bc) -eq 1 ]; then + echo "pass" +else + echo "FAIL" +fi + +AES_TIME=$(cpu_benchmark openssl enc -e -aes-256-cbc -pass pass:12345678 | sed '/^\*\*\* WARNING : deprecated key derivation used\.$/d;/^Using -iter or -pbkdf2 would be better\.$/d') +echo -n "AES256: ${AES_TIME} sec ........." +if [ $(echo "${AES_TIME} <= ${TST_AES}" | bc) -eq 1 ]; then + echo "pass" +else + echo "FAIL" +fi + +# Disk tests +DISK_RD=$(ioping -DRL -w 5 ./ | tail -n 2 | head -n 1 | cut -d ',' -f 4 | awk '{print $1}') +echo -n "DISK READ: ${DISK_RD} MB/s ......" +if [ $(echo "${DISK_RD} >= ${TST_DISKRD}" | bc) -eq 1 ]; then + echo "pass" +else + echo "FAIL" +fi + +rm -f dummy.bin +DISK_WR=$(dd if=/dev/zero of=dummy.bin bs=64k count=16k conv=fdatasync 2>&1 | tail -1 | awk '{print $10}') +rm -f dummy.bin +echo -n "DISK WRITE: ${DISK_WR} MB/s ......." +if [ $(echo "${DISK_WR} >= ${TST_DISKWR}" | bc) -eq 1 ]; then + echo "pass" +else + echo "FAIL" +fi + +# Report +rm -f ${CSV} +echo "Platform,HwSKU,Revision,Processor,CPU cores,Frequency(MHz),RAM(G),Disk(G),SHA256(s),bzip2(s),AES(s),sequential read(MiB/s),sequential write(MiB/s)," >> ${CSV} + +echo -n "${PLATFORM}," >> ${CSV} +echo -n "${HWSKU}," >> ${CSV} +echo -n "${REVISION}," >> ${CSV} +echo -n "${CPU_NAME}," >> ${CSV} +echo -n "${CPU_CORE}," >> ${CSV} +echo -n "${CPU_FREQ}," >> ${CSV} +echo -n "${RAM_SIZE}," >> ${CSV} +echo -n "${DISK_SIZE}," >> ${CSV} +echo -n "${SHA_TIME}," >> ${CSV} +echo -n "${BZ2_TIME}," >> ${CSV} +echo -n "${AES_TIME}," >> ${CSV} +echo -n "${DISK_RD}," >> ${CSV} +echo -n "${DISK_WR}," >> ${CSV} +echo "" >> ${CSV} diff --git a/dockers/docker-pde/docker_init.sh b/dockers/docker-pde/docker_init.sh new file mode 100644 index 000000000000..6e83fdd98aae --- /dev/null +++ b/dockers/docker-pde/docker_init.sh @@ -0,0 +1,45 @@ +#!/usr/bin/env bash + +set -x + +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 +} + +PLATFORM_DIR=/usr/share/sonic/platform +HWSKU_DIR=/usr/share/sonic/hwsku + +mkdir -p /etc/sai.d/ + +if [ -f $HWSKU_DIR/sai.profile ]; then + cp $HWSKU_DIR/sai.profile /etc/sai.d/sai.profile +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 [ $? -ne 0 ]; then + SONIC_PLATFORM_WHEEL="/usr/share/sonic/platform/sonic_platform-1.0-py2-none-any.whl" + echo "sonic-platform package not installed, attempting to install..." + if [ -e ${SONIC_PLATFORM_WHEEL} ]; then + pip install ${SONIC_PLATFORM_WHEEL} + if [ $? -eq 0 ]; then + echo "Successfully installed ${SONIC_PLATFORM_WHEEL}" + else + echo "Error: Failed to install ${SONIC_PLATFORM_WHEEL}" + fi + else + echo "Error: Unable to locate ${SONIC_PLATFORM_WHEEL}" + fi +fi + +start_bcm + +exec /usr/bin/supervisord + + diff --git a/dockers/docker-pde/stress-sfp-i2c.py b/dockers/docker-pde/stress-sfp-i2c.py new file mode 100644 index 000000000000..08247767e2e7 --- /dev/null +++ b/dockers/docker-pde/stress-sfp-i2c.py @@ -0,0 +1,157 @@ +#!/usr/bin/env python + +try: + import os + import sys + import subprocess + import time + import imp + from natsort import natsorted +except ImportError as e: + raise ImportError("%s - required module not found" % str(e)) + +HWSKU_PATH = "/usr/share/sonic/hwsku" +PLATFORM_PATH = "/usr/share/sonic/platform" + +PLATFORM_SPECIFIC_MODULE_NAME = 'sfputil' +PLATFORM_SPECIFIC_CLASS_NAME = 'SfpUtil' + +XCVR_EEPROM_TYPE_UNKNOWN = 0 +XCVR_EEPROM_TYPE_SFP = 1 +XCVR_EEPROM_TYPE_QSFP = 2 +XCVR_EEPROM_TYPE_QSFPDD = 3 +XCVR_EEPROM_TYPE_OSFP = XCVR_EEPROM_TYPE_QSFPDD + +OSFP_TYPE_ID = "18" + +# Global platform-specific sfputil class instance +platform_sfputil = None + +# Global port dictionaries +port_dict = None + +# Loads platform specific sfputil module from source +def load_platform_sfputil(): + global platform_sfputil + + if platform_sfputil is not None: + return + + try: + module_file = "/".join([PLATFORM_PATH, "plugins", PLATFORM_SPECIFIC_MODULE_NAME + ".py"]) + module = imp.load_source(PLATFORM_SPECIFIC_MODULE_NAME, module_file) + except IOError, e: + print("Failed to load platform module '%s': %s" % (PLATFORM_SPECIFIC_MODULE_NAME, str(e)), True) + + assert module is not None + + try: + platform_sfputil_class = getattr(module, PLATFORM_SPECIFIC_CLASS_NAME) + platform_sfputil = platform_sfputil_class() + except AttributeError, e: + print("Failed to instantiate '%s' class: %s" % (PLATFORM_SPECIFIC_CLASS_NAME, str(e)), True) + + assert platform_sfputil is not None + return + +# Loads platform port dictionaries +def load_platform_portdict(): + global port_dict + + if port_dict is not None: + return + + port_dict = {} + idx = 0 + file = open(HWSKU_PATH + "/port_config.ini", "r") + line = file.readline() + while line is not None and len(line) > 0: + line = line.strip() + if line.startswith("#"): + line = file.readline() + continue + list = line.split() + if len(list) >= 4: + idx = int(list[3]) + port_dict[list[0]] = { "index": str(idx) } + idx += 1 + line = file.readline() + + return port_dict + +def get_sfp_eeprom_type(port, data): + type = XCVR_EEPROM_TYPE_UNKNOWN + + if (port in platform_sfputil.osfp_ports) or (port in platform_sfputil.qsfp_ports): + if data is None: + return type + + if data[0] in OSFP_TYPE_ID: + code = 0 + for i in range(128, 222): + code += int(data[i], 16) + if (code & 0xff) == int(data[222], 16): + type = XCVR_EEPROM_TYPE_OSFP + else: + type = XCVR_EEPROM_TYPE_QSFP + else: + type = XCVR_EEPROM_TYPE_QSFP + else: + type = XCVR_EEPROM_TYPE_SFP + + return type + +# Test for SFP EEPROM +def stress_sfp_i2c_one(): + load_platform_sfputil() + load_platform_portdict() + num_sfp = 0 + for intf in natsorted(port_dict.keys()): + port = int(port_dict[intf]['index']) + if not platform_sfputil._is_valid_port(port): + continue + if platform_sfputil.get_presence(port): + num_sfp += 1 + + assert num_sfp >= 2, "2 or more SFP modules should be attached for this test" + + for intf in natsorted(port_dict.keys()): + port = int(port_dict[intf]['index']) + if not platform_sfputil._is_valid_port(port): + continue + if not platform_sfputil.get_presence(port): + continue + + data = platform_sfputil.get_eeprom_raw(port, 256) + assert data is not None, "SFP{}: unable to read EEPROM".format(port) + + code = 0 + type = get_sfp_eeprom_type(port, data) + if type == XCVR_EEPROM_TYPE_QSFPDD: + for i in range(128, 222): + code += int(data[i], 16) + assert (code & 0xff) == int(data[222], 16), "{}: check code error".format(intf) + elif type == XCVR_EEPROM_TYPE_QSFP: + for i in range(128, 191): + code += int(data[i], 16) + assert (code & 0xff) == int(data[191], 16), "{}: check code error".format(intf) + else: + for i in range(0, 63): + code += int(data[i], 16) + assert (code & 0xff) == int(data[63], 16), "{}: check code error".format(intf) + +def stress_sfp_i2c(sec=180): + print("Initiating {} seconds SFP I2C stress test...".format(sec)) + timeout = time.time() + sec + while timeout >= time.time(): + stress_sfp_i2c_one() + sys.stdout.write("#") + sys.stdout.flush() + print("\nPASS") + +if __name__ == '__main__': + sec = 180 + if len(sys.argv) >= 2: + sec = int(sys.argv[1]) + stress_sfp_i2c(sec) + diff --git a/dockers/docker-pde/supervisord.conf b/dockers/docker-pde/supervisord.conf new file mode 100644 index 000000000000..58a32d833163 --- /dev/null +++ b/dockers/docker-pde/supervisord.conf @@ -0,0 +1,12 @@ +[supervisord] +logfile_maxbytes=1MB +logfile_backups=2 +nodaemon=true + +[program:rsyslogd] +command=/bin/bash -c "rm -f /var/run/rsyslogd.pid && /usr/sbin/rsyslogd -n" +priority=1 +autostart=true +autorestart=false +stdout_logfile=syslog +stderr_logfile=syslog diff --git a/dockers/docker-pde/syseeprom.py b/dockers/docker-pde/syseeprom.py new file mode 100644 index 000000000000..d6444b8352b3 --- /dev/null +++ b/dockers/docker-pde/syseeprom.py @@ -0,0 +1,67 @@ +#!/usr/bin/python + +import sys +import imp +import subprocess +import time + +PLATFORM_SPECIFIC_MODULE_NAME = "eeprom" +PLATFORM_SPECIFIC_CLASS_NAME = "board" + +platform_eeprom = None +platform_eeprom_data = None + +# Returns path to platform and hwsku +def get_path_to_platform_and_hwsku(): + platform_path = '/usr/share/sonic/platform' + hwsku_path = '/usr/share/sonic/hwsku' + return (platform_path, hwsku_path) + +# Loads platform specific psuutil module from source +def load_platform_util(module_name, class_name): + platform_util = None + + # Get path to platform and hwsku + (platform_path, hwsku_path) = get_path_to_platform_and_hwsku() + + try: + module_file = "/".join([platform_path, "plugins", module_name + ".py"]) + module = imp.load_source(module_name, module_file) + except IOError, e: + assert False, ("Failed to load platform module '%s': %s" % (module_name, str(e))) + + try: + platform_util_class = getattr(module, class_name) + # board class of eeprom requires 4 paramerters, need special treatment here. + platform_util = platform_util_class('','','','') + except AttributeError, e: + assert False, ("Failed to instantiate '%s' class: %s" % (class_name, str(e))) + + return platform_util + +def init_platform_eeprom(): + global platform_eeprom + global platform_eeprom_data + + if platform_eeprom is None: + platform_eeprom = load_platform_util(PLATFORM_SPECIFIC_MODULE_NAME, \ + PLATFORM_SPECIFIC_CLASS_NAME) + if platform_eeprom_data is None: + platform_eeprom_data = platform_eeprom.read_eeprom() + + return platform_eeprom_data + +def main(): + e = init_platform_eeprom() + c = platform_eeprom._TLV_CODE_PLATFORM_NAME + if len(sys.argv) > 1: + c = int(sys.argv[1], 0) + v, t = platform_eeprom.get_tlv_field(e, c) + if v: + print(t[2]) + else: + print("Unknown") + +if __name__ == '__main__': + main() + diff --git a/files/build_templates/docker_image_ctl.j2 b/files/build_templates/docker_image_ctl.j2 index 7b4f91f3d5d0..f85b0721d5da 100644 --- a/files/build_templates/docker_image_ctl.j2 +++ b/files/build_templates/docker_image_ctl.j2 @@ -93,6 +93,16 @@ function preStartAction() docker cp /tmp/dump.rdb database$DEV:/var/lib/redis/ fi fi +{%- elif docker_container_name == "pde" %} + if [[ $(/bin/systemctl status swss | grep -c running) -gt 0 ]]; then + echo "Stopping SWSS before starting PDE" + systemctl stop swss + fi + + if [[ $(/bin/systemctl status watchdog-control.service | grep -c running) -gt 0 ]]; then + echo "Stopping watchdog-control.service before starting PDE" + systemctl stop watchdog-control.service + fi {%- elif docker_container_name == "snmp" %} $SONIC_DB_CLI STATE_DB HSET 'DEVICE_METADATA|localhost' chassis_serial_number $(decode-syseeprom -s) {%- else %} diff --git a/files/build_templates/pde.service.j2 b/files/build_templates/pde.service.j2 new file mode 100644 index 000000000000..f053b57ad576 --- /dev/null +++ b/files/build_templates/pde.service.j2 @@ -0,0 +1,22 @@ +[Unit] +Description=PDE container +{% if sonic_asic_platform == 'broadcom' %} +Requires=opennsl-modules.service +ConditionPathExists=!/usr/bin/swss.sh +{% endif %} + +After=updategraph.service +{% if sonic_asic_platform == 'broadcom' %} +After=opennsl-modules.service +{% endif %} + +Before= + +[Service] +User={{ sonicadmin_user }} +ExecStartPre=/usr/bin/{{ docker_container_name }}.sh start +ExecStart=/usr/bin/{{ docker_container_name }}.sh wait +ExecStop=/usr/bin/{{ docker_container_name }}.sh stop + +[Install] +WantedBy=multi-user.target diff --git a/platform/broadcom/docker-pde.dep b/platform/broadcom/docker-pde.dep new file mode 100644 index 000000000000..bc7eb8225808 --- /dev/null +++ b/platform/broadcom/docker-pde.dep @@ -0,0 +1,12 @@ + +DPATH := $($(DOCKER_PDE)_PATH) +DEP_FILES := $(SONIC_COMMON_FILES_LIST) platform/broadcom/docker-pde.mk platform/broadcom/docker-pde.dep +DEP_FILES += $(SONIC_COMMON_BASE_FILES_LIST) +DEP_FILES += $(SONIC_COMMON_DOCKER_FILES_LIST) +DEP_FILES += $(shell git ls-files $(DPATH)) + +$(DOCKER_PDE)_CACHE_MODE := GIT_CONTENT_SHA +$(DOCKER_PDE)_DEP_FLAGS := $(SONIC_COMMON_FLAGS_LIST) +$(DOCKER_PDE)_DEP_FILES := $(DEP_FILES) + +$(eval $(call add_dbg_docker,$(DOCKER_PDE),$(DOCKER_PDE_DBG))) diff --git a/platform/broadcom/docker-pde.mk b/platform/broadcom/docker-pde.mk new file mode 100644 index 000000000000..7f75e676d602 --- /dev/null +++ b/platform/broadcom/docker-pde.mk @@ -0,0 +1,53 @@ +# Docker image for SONiC Platform Development Environment (PDE) + + +ifeq ($(ENABLE_PDE), y) + +DOCKER_PDE_STEM = docker-pde +DOCKER_PDE = $(DOCKER_PDE_STEM).gz +DOCKER_PDE_DBG = $(DOCKER_PDE_STEM)-$(DBG_IMAGE_MARK).gz + +$(DOCKER_PDE)_PATH = $(DOCKERS_PATH)/$(DOCKER_PDE_STEM) + +$(DOCKER_PDE)_DEPENDS += $(PYTHON_NETIFACES) +$(DOCKER_PDE)_DEPENDS += $(SONIC_PLATFORM_PDE) $(BRCM_SAI) + +$(DOCKER_PDE_RDEPENDS += $(PYTHON_NETIFACES) + +$(DOCKER_PDE)_PYTHON_DEBS += $(SONIC_UTILS) +$(DOCKER_PDE)_PYTHON_WHEELS += $(SONIC_PLATFORM_COMMON_PY2) +ifeq ($(PDDF_SUPPORT), y) +$(DOCKER_PDE)_PYTHON_WHEELS += $(PDDF_PLATFORM_API_BASE_PY2) +endif +$(DOCKER_PDE)_PYTHON_WHEELS += $(SONIC_DAEMON_BASE_PY2) +$(DOCKER_PDE)_DBG_DEPENDS = $($(DOCKER_CONFIG_ENGINE_STRETCH)_DBG_DEPENDS) +$(DOCKER_PDE)_DBG_IMAGE_PACKAGES = $($(DOCKER_CONFIG_ENGINE_STRETCH)_DBG_IMAGE_PACKAGES) + +$(DOCKER_PDE)_LOAD_DOCKERS = $(DOCKER_CONFIG_ENGINE_STRETCH) + +SONIC_DOCKER_IMAGES += $(DOCKER_PDE) +SONIC_STRETCH_DOCKERS += $(DOCKER_PDE) +SONIC_INSTALL_DOCKER_IMAGES += $(DOCKER_PDE) + +SONIC_STRETCH_DBG_DOCKERS += $(DOCKER_PDE_DBG) +SONIC_DOCKER_DBG_IMAGES += $(DOCKER_PDE_DBG) +SONIC_INSTALL_DOCKER_DBG_IMAGES += $(DOCKER_PDE_DBG) + +$(DOCKER_PDE)_CONTAINER_NAME = pde +$(DOCKER_PDE)_RUN_OPT += --net=host --privileged -t +$(DOCKER_PDE)_RUN_OPT += -v /etc/sonic:/etc/sonic:ro +$(DOCKER_PDE)_RUN_OPT += -v /host/machine.conf:/host/machine.conf:ro +$(DOCKER_PDE)_RUN_OPT += -v /usr/lib/python2.7/dist-packages:/usr/share/sonic/classes: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 /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 +$(DOCKER_PDE)_BASE_IMAGE_FILES += pde-bench-knet:/usr/local/bin/pde-bench-knet + +endif diff --git a/platform/broadcom/one-pde-image.mk b/platform/broadcom/one-pde-image.mk new file mode 100644 index 000000000000..e8b2629c49a6 --- /dev/null +++ b/platform/broadcom/one-pde-image.mk @@ -0,0 +1,81 @@ +# sonic broadcom one image installer + +SONIC_ONE_PDE_IMAGE = sonic-broadcom-pde.bin +$(SONIC_ONE_PDE_IMAGE)_MACHINE = broadcom +$(SONIC_ONE_PDE_IMAGE)_IMAGE_TYPE = onie +$(SONIC_ONE_PDE_IMAGE)_INSTALLS += $(BRCM_OPENNSL_KERNEL) +$(SONIC_ONE_PDE_IMAGE)_INSTALLS += $(PDDF_PLATFORM_MODULE) +$(SONIC_ONE_PDE_IMAGE)_LAZY_INSTALLS += $(DELL_S6000_PLATFORM_MODULE) \ + $(DELL_Z9332F_PLATFORM_MODULE) \ + $(DELL_Z9264F_PLATFORM_MODULE) \ + $(DELL_S5212F_PLATFORM_MODULE) \ + $(DELL_S5232F_PLATFORM_MODULE) \ + $(DELL_S5248F_PLATFORM_MODULE) \ + $(DELL_S5296F_PLATFORM_MODULE) \ + $(DELL_Z9100_PLATFORM_MODULE) \ + $(DELL_S6100_PLATFORM_MODULE) \ + $(DELL_S3000_PLATFORM_MODULE) \ + $(DELL_N3248TE_PLATFORM_MODULE) \ + $(DELL_S5224F_PLATFORM_MODULE) \ + $(DELL_Z9432F_PLATFORM_MODULE) \ + $(INGRASYS_S8900_54XC_PLATFORM_MODULE) \ + $(INGRASYS_S8900_64XC_PLATFORM_MODULE) \ + $(INGRASYS_S9100_PLATFORM_MODULE) \ + $(INGRASYS_S8810_32Q_PLATFORM_MODULE) \ + $(INGRASYS_S9200_64X_PLATFORM_MODULE) \ + $(ACCTON_AS7712_32X_PLATFORM_MODULE) \ + $(ACCTON_AS5712_54X_PLATFORM_MODULE) \ + $(ACCTON_AS7816_64X_PLATFORM_MODULE) \ + $(ACCTON_AS7716_32X_PLATFORM_MODULE) \ + $(ACCTON_AS7312_54X_PLATFORM_MODULE) \ + $(ACCTON_AS7326_56X_PLATFORM_MODULE) \ + $(ACCTON_AS7716_32XB_PLATFORM_MODULE) \ + $(ACCTON_AS6712_32X_PLATFORM_MODULE) \ + $(ACCTON_AS7726_32X_PLATFORM_MODULE) \ + $(ACCTON_AS4630_54PE_PLATFORM_MODULE) \ + $(ACCTON_MINIPACK_PLATFORM_MODULE) \ + $(ACCTON_AS5812_54X_PLATFORM_MODULE) \ + $(ACCTON_AS5812_54T_PLATFORM_MODULE) \ + $(ACCTON_AS5835_54X_PLATFORM_MODULE) \ + $(ACCTON_AS9716_32D_PLATFORM_MODULE) \ + $(ACCTON_AS5835_54T_PLATFORM_MODULE) \ + $(ACCTON_AS7312_54XS_PLATFORM_MODULE) \ + $(ACCTON_AS7315_27XB_PLATFORM_MODULE) \ + $(INVENTEC_D7032Q28B_PLATFORM_MODULE) \ + $(INVENTEC_D7054Q28B_PLATFORM_MODULE) \ + $(INVENTEC_D7264Q28B_PLATFORM_MODULE) \ + $(INVENTEC_D7264_PLATFORM_MODULE) \ + $(INVENTEC_D6356_PLATFORM_MODULE) \ + $(INVENTEC_D6356J_PLATFORM_MODULE) \ + $(INVENTEC_D6332_PLATFORM_MODULE) \ + $(INVENTEC_D7332_PLATFORM_MODULE) \ + $(CEL_DX010_PLATFORM_MODULE) \ + $(CEL_HALIBURTON_PLATFORM_MODULE) \ + $(DELTA_AG9032V1_PLATFORM_MODULE) \ + $(DELTA_AG9064_PLATFORM_MODULE) \ + $(DELTA_AG5648_PLATFORM_MODULE) \ + $(DELTA_ET6248BRB_PLATFORM_MODULE) \ + $(QUANTA_IX1B_32X_PLATFORM_MODULE) \ + $(QUANTA_IX4_64X_PLATFORM_MODULE) \ + $(QUANTA_IX7_32X_PLATFORM_MODULE) \ + $(QUANTA_IX7_BWDE_32X_PLATFORM_MODULE) \ + $(QUANTA_IX7T_32X_PLATFORM_MODULE) \ + $(QUANTA_IX8_56X_PLATFORM_MODULE) \ + $(QUANTA_IX8C_56X_PLATFORM_MODULE) \ + $(QUANTA_IX8A_BWDE_56X_PLATFORM_MODULE) \ + $(QUANTA_IX8F_56X_PLATFORM_MODULE) \ + $(QUANTA_IX8T_56X_PLATFORM_MODULE) \ + $(QUANTA_IX9_32X_PLATFORM_MODULE) \ + $(MITAC_LY1200_32X_PLATFORM_MODULE) \ + $(ALPHANETWORKS_SNH60A0_320FV2_PLATFORM_MODULE) \ + $(ALPHANETWORKS_SNH60B0_640F_PLATFORM_MODULE) \ + $(ALPHANETWORKS_SNJ60B0_320F_PLATFORM_MODULE) \ + $(ALPHANETWORKS_SNJ61D0_320F_PLATFORM_MODULE) \ + $(BRCM_XLR_GTS_PLATFORM_MODULE) \ + $(DELTA_AG9032V2A_PLATFORM_MODULE) \ + $(JUNIPER_QFX5210_PLATFORM_MODULE) \ + $(CEL_SILVERSTONE_PLATFORM_MODULE) \ + $(CEL_SILVERSTONE-DP_PLATFORM_MODULE) + +$(SONIC_ONE_PDE_IMAGE)_DOCKERS += $(DOCKER_PDE) $(DOCKER_PLATFORM_MONITOR) $(DOCKER_DATABASE) +SONIC_INSTALLERS += $(SONIC_ONE_PDE_IMAGE) diff --git a/platform/broadcom/sonic-pde-tests.dep b/platform/broadcom/sonic-pde-tests.dep new file mode 100644 index 000000000000..40b99496c14d --- /dev/null +++ b/platform/broadcom/sonic-pde-tests.dep @@ -0,0 +1,12 @@ + +SPATH := $($(SONIC_PLATFORM_PDE)_SRC_PATH) +DEP_FILES := $(SONIC_COMMON_FILES_LIST) platform/broadcom/sonic-pde-tests.mk platform/broadcom/sonic-pde-tests.dep +DEP_FILES += $(SONIC_COMMON_BASE_FILES_LIST) +SMDEP_FILES := $(addprefix $(SPATH)/,$(shell cd $(SPATH) && git ls-files)) + +$(SONIC_PLATFORM_PDE)_CACHE_MODE := GIT_CONTENT_SHA +$(SONIC_PLATFORM_PDE)_DEP_FLAGS := $(SONIC_COMMON_FLAGS_LIST) +$(SONIC_PLATFORM_PDE)_DEP_FILES := $(DEP_FILES) +$(SONIC_PLATFORM_PDE)_SMDEP_FILES := $(SMDEP_FILES) +$(SONIC_PLATFORM_PDE)_SMDEP_PATHS := $(SPATH) + diff --git a/platform/broadcom/sonic-pde-tests.mk b/platform/broadcom/sonic-pde-tests.mk new file mode 100644 index 000000000000..a7482625c87e --- /dev/null +++ b/platform/broadcom/sonic-pde-tests.mk @@ -0,0 +1,7 @@ +# sonic pde package + +SONIC_PLATFORM_PDE = sonic-platform-pde_1.0_amd64.deb +$(SONIC_PLATFORM_PDE)_SRC_PATH = $(SRC_PATH)/sonic-platform-pde +$(SONIC_PLATFORM_PDE)_DEPENDS += $(BRCM_SAI) $(BRCM_SAI_DEV) $(SWIG) + +SONIC_DPKG_DEBS += $(SONIC_PLATFORM_PDE) diff --git a/rules/config b/rules/config index b45ce2152806..022e2228eb4c 100644 --- a/rules/config +++ b/rules/config @@ -51,6 +51,8 @@ DEFAULT_PASSWORD = YourPaSsWoRd # ENABLE_ZTP - installs Zero Touch Provisioning support. # ENABLE_ZTP = y +# ENABLE_PDE - Enable platform development enviroment +ENABLE_PDE = y # SHUTDOWN_BGP_ON_START - if set to y all bgp sessions will be in admin down state when # bgp service starts. # SHUTDOWN_BGP_ON_START = y diff --git a/slave.mk b/slave.mk index 9cce5392cc2c..9a253e0bc2d6 100644 --- a/slave.mk +++ b/slave.mk @@ -241,6 +241,7 @@ $(info "HTTP_PROXY" : "$(HTTP_PROXY)") $(info "HTTPS_PROXY" : "$(HTTPS_PROXY)") $(info "NO_PROXY" : "$(NO_PROXY)") $(info "ENABLE_ZTP" : "$(ENABLE_ZTP)") +$(info "ENABLE_PDE" : "$(ENABLE_PDE)") $(info "SONIC_DEBUGGING_ON" : "$(SONIC_DEBUGGING_ON)") $(info "SONIC_PROFILING_ON" : "$(SONIC_PROFILING_ON)") $(info "KERNEL_PROCURE_METHOD" : "$(KERNEL_PROCURE_METHOD)") @@ -915,6 +916,7 @@ $(addprefix $(TARGET_PATH)/, $(SONIC_INSTALLERS)) : $(TARGET_PATH)/% : \ export include_mgmt_framework="$(INCLUDE_MGMT_FRAMEWORK)" export include_iccpd="$(INCLUDE_ICCPD)" export pddf_support="$(PDDF_SUPPORT)" + export enable_pde="$(ENABLE_PDE)" export shutdown_bgp_on_start="$(SHUTDOWN_BGP_ON_START)" export default_buffer_model="$(SONIC_BUFFER_MODEL)" export include_kubernetes="$(INCLUDE_KUBERNETES)" @@ -1022,6 +1024,8 @@ $(addprefix $(TARGET_PATH)/, $(SONIC_INSTALLERS)) : $(TARGET_PATH)/% : \ DEBUG_IMG="$(INSTALL_DEBUG_TOOLS)" \ DEBUG_SRC_ARCHIVE_FILE="$(DBG_SRC_ARCHIVE_FILE)" \ + ARTIFACTORY_URL="$(ARTIFACTORY_URL)" \ + BUILD_TARGET="$@" \ USERNAME="$(USERNAME)" \ PASSWORD="$(PASSWORD)" \ IMAGE_TYPE=$($*_IMAGE_TYPE) \ @@ -1036,6 +1040,7 @@ $(addprefix $(TARGET_PATH)/, $(SONIC_INSTALLERS)) : $(TARGET_PATH)/% : \ PASSWORD="$(PASSWORD)" \ TARGET_MACHINE=$($*_MACHINE) \ IMAGE_TYPE=$($*_IMAGE_TYPE) \ + BUILD_TARGET="$@" \ SONIC_ENABLE_IMAGE_SIGNATURE="$(SONIC_ENABLE_IMAGE_SIGNATURE)" \ SIGNING_KEY="$(SIGNING_KEY)" \ SIGNING_CERT="$(SIGNING_CERT)" \ From de606bbf354afede2d39ac1db4a4c1e000581a44 Mon Sep 17 00:00:00 2001 From: Geans Pin Date: Mon, 3 May 2021 17:07:58 -0700 Subject: [PATCH 02/28] Initial commit for introducing the SONiC Platform Development Env (Resubmit PR#3778) --- Makefile.work | 19 +- dockers/docker-pde/Dockerfile.j2 | 91 +++++ dockers/docker-pde/base_image_files/pde-bench | 38 ++ .../base_image_files/pde-bench-knet | 326 ++++++++++++++++++ .../docker-pde/base_image_files/pde-stress | 27 ++ dockers/docker-pde/base_image_files/pde-test | 59 ++++ dockers/docker-pde/bench.sh | 140 ++++++++ dockers/docker-pde/docker_init.sh | 45 +++ dockers/docker-pde/stress-sfp-i2c.py | 157 +++++++++ dockers/docker-pde/supervisord.conf | 12 + dockers/docker-pde/syseeprom.py | 67 ++++ files/build_templates/docker_image_ctl.j2 | 10 + files/build_templates/pde.service.j2 | 22 ++ platform/broadcom/docker-pde.dep | 12 + platform/broadcom/docker-pde.mk | 52 +++ platform/broadcom/one-pde-image.mk | 81 +++++ platform/broadcom/sonic-pde-tests.dep | 12 + platform/broadcom/sonic-pde-tests.mk | 7 + rules/config | 2 + slave.mk | 5 + 20 files changed, 1183 insertions(+), 1 deletion(-) create mode 100644 dockers/docker-pde/Dockerfile.j2 create mode 100644 dockers/docker-pde/base_image_files/pde-bench create mode 100644 dockers/docker-pde/base_image_files/pde-bench-knet create mode 100644 dockers/docker-pde/base_image_files/pde-stress create mode 100644 dockers/docker-pde/base_image_files/pde-test create mode 100644 dockers/docker-pde/bench.sh create mode 100644 dockers/docker-pde/docker_init.sh create mode 100644 dockers/docker-pde/stress-sfp-i2c.py create mode 100644 dockers/docker-pde/supervisord.conf create mode 100644 dockers/docker-pde/syseeprom.py create mode 100644 files/build_templates/pde.service.j2 create mode 100644 platform/broadcom/docker-pde.dep create mode 100644 platform/broadcom/docker-pde.mk create mode 100644 platform/broadcom/one-pde-image.mk create mode 100644 platform/broadcom/sonic-pde-tests.dep create mode 100644 platform/broadcom/sonic-pde-tests.mk diff --git a/Makefile.work b/Makefile.work index 591ea051d98f..b099bae0391d 100644 --- a/Makefile.work +++ b/Makefile.work @@ -241,6 +241,7 @@ SONIC_BUILD_INSTRUCTION := make \ SONIC_IMAGE_VERSION=$(SONIC_IMAGE_VERSION) \ ENABLE_DHCP_GRAPH_SERVICE=$(ENABLE_DHCP_GRAPH_SERVICE) \ ENABLE_ZTP=$(ENABLE_ZTP) \ + ENABLE_PDE=$(ENABLE_PDE) \ SHUTDOWN_BGP_ON_START=$(SHUTDOWN_BGP_ON_START) \ INCLUDE_KUBERNETES=$(INCLUDE_KUBERNETES) \ KUBERNETES_VERSION=$(KUBERNETES_VERSION) \ @@ -271,7 +272,18 @@ SONIC_BUILD_INSTRUCTION := make \ SLAVE_DIR=$(SLAVE_DIR) \ $(SONIC_OVERRIDE_BUILD_VARS) -.PHONY: sonic-slave-build sonic-slave-bash init reset +PDESUBMODULES = src/sonic-linux-kernel \ + src/sonic-utilities \ + src/sonic-platform-common \ + src/sonic-swss-common \ + src/sonic-swss \ + src/sonic-py-swsssdk \ + src/redis-dump-load \ + src/sonic-sairedis \ + src/sonic-ztp \ + src/sonic-platform-daemons \ + src/sonic-platform-pde +.PHONY: sonic-slave-build sonic-slave-bash init initpde reset .DEFAULT_GOAL := all @@ -340,6 +352,11 @@ showtag: @echo $(SLAVE_IMAGE):$(SLAVE_TAG) @echo $(SLAVE_BASE_IMAGE):$(SLAVE_BASE_TAG) +initpde: + @for submodule in $(PDESUBMODULES) ; do \ + git submodule update --init --recursive $$submodule ; \ + done + @git submodule foreach --recursive '[ -f .git ] && echo "gitdir: $$(realpath --relative-to=. $$(cut -d" " -f2 .git))" > .git' init : @git submodule update --init --recursive @git submodule foreach --recursive '[ -f .git ] && echo "gitdir: $$(realpath --relative-to=. $$(cut -d" " -f2 .git))" > .git' diff --git a/dockers/docker-pde/Dockerfile.j2 b/dockers/docker-pde/Dockerfile.j2 new file mode 100644 index 000000000000..4486bcc812fa --- /dev/null +++ b/dockers/docker-pde/Dockerfile.j2 @@ -0,0 +1,91 @@ +FROM {{ docker_pde_load_image }} + +ARG docker_container_name +ENV PYTHONPATH=/usr/share/sonic/platform + +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 + +{% if ARTIFACTORY_URL is defined and ARTIFACTORY_URL|length -%} +# Insert Artifactory URL references +COPY ["files/03_stretch_af.list", "/etc/apt/sources.list.d/"] +{%- endif %} + +# Update apt's cache of available packages +RUN apt-get update && apt-get install -y ipmitool telnet busybox kmod libpcap-dev + +# Packages for benchmark tool - nench.sh +RUN apt-get install -y bzip2 curl ioping openssl bc sysstat + +# Packages for PDDF +RUN apt-get install -y python-jsonschema + +RUN pip3 install pytest pexpect + +{% if docker_pde_debs.strip() -%} +# Copy locally-built Debian package dependencies +COPY \ +{% for deb in docker_pde_debs.split(' ') -%} +debs/{{ deb }}{{' '}} +{%- endfor -%} +/debs/ + +# Install locally-built Debian packages and implicitly install their dependencies +RUN dpkg_apt() { [ -f $1 ] && { dpkg -i $1 || apt-get -y install -f; } || return 1; }{%- for deb in docker_pde_debs.split(' ') %}; \ +dpkg_apt /debs/{{ deb }} +{%- endfor %} +{%- endif %} + +{% if docker_pde_pydebs.strip() -%} +# Copy locally-built Debian package dependencies +COPY \ +{% for deb in docker_pde_pydebs.split(' ') -%} +python-debs/{{ deb }}{{' '}} +{%- endfor -%} +/debs/ + +# Install locally-built Debian packages and implicitly install their dependencies +{%- for deb in docker_pde_pydebs.split(' ') %} +RUN dpkg_apt() { [ -f $1 ] && { dpkg -i $1 || apt-get -y install -f; } || return 1; }; dpkg_apt /debs/{{ deb }} +{%- endfor %} +{%- endif %} + +{% if docker_pde_whls.strip() -%} +# Copy locally-built Python wheel dependencies +COPY \ +{% for whl in docker_pde_whls.split(' ') -%} +python-wheels/{{ whl }}{{' '}} +{%- endfor -%} +/python-wheels/ + +# Install locally-built Python wheel dependencies +RUN pip3 install \ +{% for whl in docker_pde_whls.split(' ') -%} +/python-wheels/{{ whl }}{{' '}} +{%- endfor %} +{% endif %} + +{% if ARTIFACTORY_URL is defined and ARTIFACTORY_URL|length -%} +# Remove Artifactory URL references +RUN rm -f /etc/apt/sources.list.d/03_stretch_af.list && apt-get update +{%- endif %} + +# Clean up +RUN apt-get clean -y; \ + apt-get autoclean -y; \ + apt-get autoremove -y +RUN rm -rf /debs ~/.cache + +RUN mkdir -p /home/pde + +COPY ["bench.sh", "/usr/bin/"] +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 ["syncd_init_common.sh", "/usr/bin/"] + +ENTRYPOINT ["/usr/bin/docker_init.sh"] diff --git a/dockers/docker-pde/base_image_files/pde-bench b/dockers/docker-pde/base_image_files/pde-bench new file mode 100644 index 000000000000..1e2c727b02af --- /dev/null +++ b/dockers/docker-pde/base_image_files/pde-bench @@ -0,0 +1,38 @@ +#!/bin/bash + +CSV=/tmp/bench.csv + +# Make sure only root can run our script +if [ "$(id -u)" != "0" ]; then + echo "This script must be run as root" 1>&2 + exit 1 +fi + +# Start PDE if it's deactivated +if [ $(docker ps | grep -c pde) -eq 0 ]; then + pde.sh start +fi + +# Allow 5 seconds for PDE to be coming up +for t in $(seq 1 5) +do + if [ $(docker ps | grep -c pde) -gt 0 ]; then + break + fi + sleep 1 +done +if [ $(docker ps | grep -c pde) -eq 0 ]; then + echo "docker-pde is not alive, existing ..." + exit 1 +fi + +# Launch the benchmark test suite +docker exec -it pde /usr/bin/bench.sh +echo "$(docker exec -it pde cat ${CSV})" > ${CSV} + +echo "" +echo "CSV Report: ${CSV}" +echo "-----------------------------------------------------------------------" +echo "$(cat ${CSV})" +echo "-----------------------------------------------------------------------" + diff --git a/dockers/docker-pde/base_image_files/pde-bench-knet b/dockers/docker-pde/base_image_files/pde-bench-knet new file mode 100644 index 000000000000..cc75962eff35 --- /dev/null +++ b/dockers/docker-pde/base_image_files/pde-bench-knet @@ -0,0 +1,326 @@ +#!/bin/bash + +PLATF_DIR=/usr/share/sonic/platform +HWSKU_DIR=/usr/share/sonic/hwsku +PORT=Ethernet0 +LANE=1 +SPEED=0 +BCMPORT=ce0 +DURATION=5 + +PPS_128=0 +BPS_128=0 +PPS_256=0 +BPS_256=0 +PPS_512=0 +BPS_512=0 +PPS_1024=0 +BPS_1024=0 +PPS_2048=0 +BPS_2048=0 +PPS_4096=0 +BPS_4096=0 +PPS_8192=0 +BPS_8192=0 +PPS_9000=0 +BPS_9000=0 + +# SWSS is mandatory for KNET benchmark +sudo systemctl start swss +for t in $(seq 1 15) +do + if [ $(docker ps | grep -c swss) -gt 0 ]; then + break + fi + sleep 1 +done +if [ $(docker ps | grep -c swss) -eq 0 ]; then + echo "ERR: docker-swss is not alive, existing ..." + exit 1 +fi + +# Find out the PLATFORM and HWSKU +if [ ! -d ${PLATF_DIR} ]; then + name=$(grep 'onie_platform=' /host/machine.conf | cut -d '=' -f 2) + PLATF_DIR=/usr/share/sonic/device/${name} +fi + +if [ ! -d ${HWSKU_DIR} ]; then + name=$(head -1 ${PLATF_DIR}/default_sku | awk '{print $1}') + HWSKU_DIR=${PLATF_DIR}/${name} +fi + +echo "PLATFORM='${PLATF_DIR}'" +echo "HWSKU='${HWSKU_DIR}'" + +# Determine the target port for KNET benchmark +while IFS= read -r line; do + line=$(echo ${line} | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//') + if [[ ${line} = \#* ]]; then + continue + fi + port=$(echo ${line} | awk '{print $1}') + lane=$(echo ${line} | awk '{print $2}' | cut -d ',' -f 1) + speed=$(echo ${line} | awk '{print $5}') + if [ -z "${speed}" ]; then + continue + fi + if [ ${speed} -gt ${SPEED} ]; then + PORT=${port} + LANE=${lane} + SPEED=${speed} + fi +done < ${HWSKU_DIR}/port_config.ini + +echo "PORT=${PORT}" +echo "LANE=${LANE}" +echo "SPEED=${SPEED}" + +# Find out the name of the corresponding bcm port +TEMP=$(mktemp) +bcmcmd 'show pmap' | grep ${LANE} > ${TEMP} +while IFS= read -r line; do + line=$(echo ${line} | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//') + if [ $(echo ${line} | awk '{print $4}') -eq ${LANE} ]; then + BCMPORT=$(echo ${line} | awk '{print $1}') + break + fi +done < ${TEMP} +rm -f ${TEMP} + +echo "BCMPORT=${BCMPORT}" + +# SWSS: Update the LLDP rate limit +TEMP=$(mktemp) +rm -f ${TEMP}.* +docker cp swss:/etc/swss/config.d/00-copp.config.json ${TEMP}.old +if [ ! -f ${TEMP}.old ]; then + echo "Unable to get 00-copp.config.json from docker-swss" +fi + +lldp=0 +while IFS= read -r line +do + if [ $(echo $line | grep -c -E '\"COPP_TABLE:') -gt 0 ]; then + lldp=0 + fi + if [ $(echo $line | grep -c -E 'trap_ids.*,lldp') -gt 0 ]; then + lldp=1 + fi + if [ $lldp -gt 0 ]; then + if [ $(echo $line | grep -c -E '.*\"cir\"') -gt 0 ]; then + echo "${line%:*}:\"30000\"," >> ${TEMP}.new + lldp=$(expr $lldp + 1) + continue + fi + if [ $(echo $line | grep -c -E '.*\"cbs\"') -gt 0 ]; then + echo "${line%:*}:\"30000\"," >> ${TEMP}.new + lldp=$(expr $lldp + 1) + continue + fi + fi + echo "$line" >> ${TEMP}.new +done < "${TEMP}.old" + +csum1=$(md5sum ${TEMP}.old | cut -d ' ' -f 1) +csum2=$(md5sum ${TEMP}.new | cut -d ' ' -f 1) +if [ "${csum1}" != "${csum2}" ]; then + docker cp ${TEMP}.new swss:/etc/swss/config.d/00-copp.config.json + sudo config copp rx-rate 100000 + sudo config save -y + sudo config reload -y +fi + +# Disable ZTP +sudo config ztp disable -y > /dev/null 2>&1 + +# Enable the target port for benchmarking +echo "Allow 15 seconds for ${PORT} getting ready" + +for tick in $(seq 1 15); do + if [ -d /sys/class/net/${PORT} ]; then + break + fi + sleep 1 +done +sudo config interface startup ${PORT} > /dev/null 2>&1 + +# Enable MAC loopback mode to the target port +bcmcmd "port ${BCMPORT} lb=mac" > /dev/null 2>&1 + +# Get started with the loopback benchmark test +# + +# 128B +P1=$(cat /sys/class/net/${PORT}/statistics/rx_packets) +B1=$(cat /sys/class/net/${PORT}/statistics/rx_bytes) +if [ $(docker ps | grep -c pde) -gt 0 ]; then + docker exec -it pde /usr/local/bin/pktsend ${PORT} ${DURATION} 128 +else + /usr/local/bin/pktsend ${PORT} ${DURATION} 128 +fi +P2=$(cat /sys/class/net/${PORT}/statistics/rx_packets) +B2=$(cat /sys/class/net/${PORT}/statistics/rx_bytes) +NUM=$(expr ${P2} - ${P1}) +PPS=$(expr ${NUM} / ${DURATION}) +NUM=$(expr ${B2} - ${B1}) +BPS=$(expr ${NUM} / ${DURATION}) +BPS=$(expr ${BPS} / 1000000) +BPS=$(expr ${BPS} \* 8) +echo "PPS=${PPS}, BPS=${BPS}Mbps" +PPS_128=${PPS} +BPS_128=${BPS} + +# 256B +P1=$(cat /sys/class/net/${PORT}/statistics/rx_packets) +B1=$(cat /sys/class/net/${PORT}/statistics/rx_bytes) +if [ $(docker ps | grep -c pde) -gt 0 ]; then + docker exec -it pde /usr/local/bin/pktsend ${PORT} ${DURATION} 256 +else + /usr/local/bin/pktsend ${PORT} ${DURATION} 256 +fi +P2=$(cat /sys/class/net/${PORT}/statistics/rx_packets) +B2=$(cat /sys/class/net/${PORT}/statistics/rx_bytes) +NUM=$(expr ${P2} - ${P1}) +PPS=$(expr ${NUM} / ${DURATION}) +NUM=$(expr ${B2} - ${B1}) +BPS=$(expr ${NUM} / ${DURATION}) +BPS=$(expr ${BPS} / 1000000) +BPS=$(expr ${BPS} \* 8) +echo "PPS=${PPS}, BPS=${BPS}Mbps" +PPS_256=${PPS} +BPS_256=${BPS} + +# 512B +P1=$(cat /sys/class/net/${PORT}/statistics/rx_packets) +B1=$(cat /sys/class/net/${PORT}/statistics/rx_bytes) +if [ $(docker ps | grep -c pde) -gt 0 ]; then + docker exec -it pde /usr/local/bin/pktsend ${PORT} ${DURATION} 512 +else + /usr/local/bin/pktsend ${PORT} ${DURATION} 512 +fi +P2=$(cat /sys/class/net/${PORT}/statistics/rx_packets) +B2=$(cat /sys/class/net/${PORT}/statistics/rx_bytes) +NUM=$(expr ${P2} - ${P1}) +PPS=$(expr ${NUM} / ${DURATION}) +NUM=$(expr ${B2} - ${B1}) +BPS=$(expr ${NUM} / ${DURATION}) +BPS=$(expr ${BPS} / 1000000) +BPS=$(expr ${BPS} \* 8) +echo "PPS=${PPS}, BPS=${BPS}Mbps" +PPS_512=${PPS} +BPS_512=${BPS} + +# 1024B +P1=$(cat /sys/class/net/${PORT}/statistics/rx_packets) +B1=$(cat /sys/class/net/${PORT}/statistics/rx_bytes) +if [ $(docker ps | grep -c pde) -gt 0 ]; then + docker exec -it pde /usr/local/bin/pktsend ${PORT} ${DURATION} 1024 +else + /usr/local/bin/pktsend ${PORT} ${DURATION} 1024 +fi +P2=$(cat /sys/class/net/${PORT}/statistics/rx_packets) +B2=$(cat /sys/class/net/${PORT}/statistics/rx_bytes) +NUM=$(expr ${P2} - ${P1}) +PPS=$(expr ${NUM} / ${DURATION}) +NUM=$(expr ${B2} - ${B1}) +BPS=$(expr ${NUM} / ${DURATION}) +BPS=$(expr ${BPS} / 1000000) +BPS=$(expr ${BPS} \* 8) +echo "PPS=${PPS}, BPS=${BPS}Mbps" +PPS_1024=${PPS} +BPS_1024=${BPS} + +# 2048B +P1=$(cat /sys/class/net/${PORT}/statistics/rx_packets) +B1=$(cat /sys/class/net/${PORT}/statistics/rx_bytes) +if [ $(docker ps | grep -c pde) -gt 0 ]; then + docker exec -it pde /usr/local/bin/pktsend ${PORT} ${DURATION} 2048 +else + /usr/local/bin/pktsend ${PORT} ${DURATION} 2048 +fi +P2=$(cat /sys/class/net/${PORT}/statistics/rx_packets) +B2=$(cat /sys/class/net/${PORT}/statistics/rx_bytes) +NUM=$(expr ${P2} - ${P1}) +PPS=$(expr ${NUM} / ${DURATION}) +NUM=$(expr ${B2} - ${B1}) +BPS=$(expr ${NUM} / ${DURATION}) +BPS=$(expr ${BPS} / 1000000) +BPS=$(expr ${BPS} \* 8) +echo "PPS=${PPS}, BPS=${BPS}Mbps" +PPS_2048=${PPS} +BPS_2048=${BPS} + +# 4096B +P1=$(cat /sys/class/net/${PORT}/statistics/rx_packets) +B1=$(cat /sys/class/net/${PORT}/statistics/rx_bytes) +if [ $(docker ps | grep -c pde) -gt 0 ]; then + docker exec -it pde /usr/local/bin/pktsend ${PORT} ${DURATION} 4096 +else + /usr/local/bin/pktsend ${PORT} ${DURATION} 4096 +fi +P2=$(cat /sys/class/net/${PORT}/statistics/rx_packets) +B2=$(cat /sys/class/net/${PORT}/statistics/rx_bytes) +NUM=$(expr ${P2} - ${P1}) +PPS=$(expr ${NUM} / ${DURATION}) +NUM=$(expr ${B2} - ${B1}) +BPS=$(expr ${NUM} / ${DURATION}) +BPS=$(expr ${BPS} / 1000000) +BPS=$(expr ${BPS} \* 8) +echo "PPS=${PPS}, BPS=${BPS}Mbps" +PPS_4096=${PPS} +BPS_4096=${BPS} + +# 8192B +P1=$(cat /sys/class/net/${PORT}/statistics/rx_packets) +B1=$(cat /sys/class/net/${PORT}/statistics/rx_bytes) +if [ $(docker ps | grep -c pde) -gt 0 ]; then + docker exec -it pde /usr/local/bin/pktsend ${PORT} ${DURATION} 8192 +else + /usr/local/bin/pktsend ${PORT} ${DURATION} 8192 +fi +P2=$(cat /sys/class/net/${PORT}/statistics/rx_packets) +B2=$(cat /sys/class/net/${PORT}/statistics/rx_bytes) +NUM=$(expr ${P2} - ${P1}) +PPS=$(expr ${NUM} / ${DURATION}) +NUM=$(expr ${B2} - ${B1}) +BPS=$(expr ${NUM} / ${DURATION}) +BPS=$(expr ${BPS} / 1000000) +BPS=$(expr ${BPS} \* 8) +echo "PPS=${PPS}, BPS=${BPS}Mbps" +PPS_8192=${PPS} +BPS_8192=${BPS} + +# 9000B +P1=$(cat /sys/class/net/${PORT}/statistics/rx_packets) +B1=$(cat /sys/class/net/${PORT}/statistics/rx_bytes) +if [ $(docker ps | grep -c pde) -gt 0 ]; then + docker exec -it pde /usr/local/bin/pktsend ${PORT} ${DURATION} 9000 +else + /usr/local/bin/pktsend ${PORT} ${DURATION} 9000 +fi +P2=$(cat /sys/class/net/${PORT}/statistics/rx_packets) +B2=$(cat /sys/class/net/${PORT}/statistics/rx_bytes) +NUM=$(expr ${P2} - ${P1}) +PPS=$(expr ${NUM} / ${DURATION}) +NUM=$(expr ${B2} - ${B1}) +BPS=$(expr ${NUM} / ${DURATION}) +BPS=$(expr ${BPS} / 1000000) +BPS=$(expr ${BPS} \* 8) +echo "PPS=${PPS}, BPS=${BPS}Mbps" +PPS_9000=${PPS} +BPS_9000=${BPS} + +# Disable MAC loopback mode to the target port +bcmcmd "port ${BCMPORT} lb=none" > /dev/null 2>&1 + +# Generate the final report +echo "payload size,loopback pps(Pkt/s),loopback Mbps(Mbit/s)" +echo "128B,${PPS_128},${BPS_128}" +echo "256B,${PPS_256},${BPS_256}" +echo "512B,${PPS_512},${BPS_512}" +echo "1024B,${PPS_1024},${BPS_1024}" +echo "2048B,${PPS_2048},${BPS_2048}" +echo "4096B,${PPS_4096},${BPS_4096}" +echo "8192B,${PPS_8192},${BPS_8192}" +echo "9000B,${PPS_9000},${BPS_9000}" diff --git a/dockers/docker-pde/base_image_files/pde-stress b/dockers/docker-pde/base_image_files/pde-stress new file mode 100644 index 000000000000..4ee4752a8b1e --- /dev/null +++ b/dockers/docker-pde/base_image_files/pde-stress @@ -0,0 +1,27 @@ +#!/bin/bash + +# Make sure only root can run our script +if [ "$(id -u)" != "0" ]; then + echo "This script must be run as root" 1>&2 + exit 1 +fi + +# Start PDE if it's deactivated +if [ $(docker ps | grep -c pde) -eq 0 ]; then + pde.sh start +fi + +# Allow 5 seconds for PDE to be coming up +for t in $(seq 1 5) +do + if [ $(docker ps | grep -c pde) -gt 0 ]; then + break + fi +done +if [ $(docker ps | grep -c pde) -eq 0 ]; then + echo "docker-pde is not alive, existing ..." + exit 1 +fi + +# Now launch the PDE stress test +docker exec -it pde /home/pde/stress-sfp-i2c.py $* diff --git a/dockers/docker-pde/base_image_files/pde-test b/dockers/docker-pde/base_image_files/pde-test new file mode 100644 index 000000000000..046a9f067480 --- /dev/null +++ b/dockers/docker-pde/base_image_files/pde-test @@ -0,0 +1,59 @@ +#!/bin/bash + +# Make sure only root can run our script +if [ "$(id -u)" != "0" ]; then + echo "This script must be run as root" 1>&2 + exit 1 +fi + +# Make sure SWSS is deactivated +if [ $(docker ps | grep -c swss) -ne 0 ]; then + systemctl stop swss + sleep 3 +fi + +# Start PDE if it's deactivated +if [ $(docker ps | grep -c pde) -eq 0 ]; then + pde.sh start +fi + +# Allow 5 seconds for PDE to be coming up +for t in $(seq 1 5) +do + if [ $(docker ps | grep -c pde) -gt 0 ]; then + break + fi +done +if [ $(docker ps | grep -c pde) -eq 0 ]; then + echo "docker-pde is not alive, existing ..." + exit 1 +fi + +usage() +{ + echo "usage: $0 " + exit 1 +} + +if [ $# -lt 1 ] +then + usage +fi + +case $1 in +-h | help) + usage + ;; +-l | ls | list) + docker exec -it -w /usr/local/sonic_pde_tests pde ls + exit 0 + ;; +*) + ;; +esac + +# Now launch the PDE pytest +docker exec -it -w /usr/local/sonic_pde_tests pde pytest $* + +# Reactivate the SWSS +systemctl start swss diff --git a/dockers/docker-pde/bench.sh b/dockers/docker-pde/bench.sh new file mode 100644 index 000000000000..2a0951490918 --- /dev/null +++ b/dockers/docker-pde/bench.sh @@ -0,0 +1,140 @@ +#!/bin/bash + +CSV=/tmp/bench.csv + +TST_FREQ=2000 +TST_CORE=4 +TST_RAMSZ=8 +TST_DISKSZ=14 +TST_SHA=10 +TST_BZ2=30 +TST_AES=5 +TST_DISKRD=180 +TST_DISKWR=30 + +cpu_benchmark() +{ + export TIMEFORMAT='%1R' + (time dd if=/dev/zero bs=1M count=500 2> /dev/null | \ + "$@" > /dev/null ) 2>&1 +} + +# Platform Info +PLATFORM=$(grep 'onie_platform=' /host/machine.conf | cut -d '=' -f 2) +echo "Platform: ${PLATFORM}" + +if [ -d /usr/share/sonic/platform ]; then + HWSKU=$(head -1 /usr/share/sonic/platform/default_sku | awk '{print $1}') +else + HWSKU=$(head -1 /usr/share/sonic/device/${PLATFORM}/default_sku | awk '{print $1}') +fi +echo "HWSKU: ${HWSKU}" + +REVISION=$(syseeprom.py 0x27) +echo "Revision: ${REVISION}" + +# Basic Info +CPU_NAME=$(awk -F: '/model name/ {name=$2} END {print name}' /proc/cpuinfo | cut -d '@' -f 1 | sed 's/^[ \t]*//;s/[ \t]*$//') +echo "CPU NAME: ${CPU_NAME}" + +if [ $(lscpu | grep -c 'CPU max MHz') -gt 0 ]; then + CPU_FREQ=$(lscpu | grep 'CPU max MHz' | cut -d ':' -f 2 | cut -d '.' -f 1 | sed 's/^[[:space:]]*//') +else + CPU_FREQ=$(lscpu | grep 'CPU MHz' | cut -d ':' -f 2 | cut -d '.' -f 1 | sed 's/^[[:space:]]*//') +fi +echo -n "CPU FREQ: ${CPU_FREQ} MHz ........" +if [ ${CPU_FREQ} -ge ${TST_FREQ} ]; then + echo "pass" +else + echo "FAIL" +fi + +CPU_CORE=$(awk -F: '/model name/ {core++} END {print core}' /proc/cpuinfo) +echo -n "CPU CORE: ${CPU_CORE} ..............." +if [ ${CPU_CORE} -ge ${TST_CORE} ]; then + echo "pass" +else + echo "FAIL" +fi + +RAM_SIZE=$(grep MemTotal /proc/meminfo | awk '{print $2}') +RAM_SIZE=$(expr ${RAM_SIZE} / 1024) # MB +RAM_SIZE=$(expr ${RAM_SIZE} + 1023) +RAM_SIZE=$(expr ${RAM_SIZE} / 1024) # GB +echo -n "RAM SIZE: ${RAM_SIZE} GB ..........." +if [ ${RAM_SIZE} -ge ${TST_RAMSZ} ]; then + echo "pass" +else + echo "FAIL" +fi + +DISK_SIZE=$(lsblk -d | grep disk | head -1 | awk '{print $4}' | cut -d 'G' -f 1) +echo -n "DISK: ${DISK_SIZE} GB ..........." +if [ $(expr ${DISK_SIZE} \>= ${TST_DISKSZ}) -eq 1 ]; then + echo "pass" +else + echo "FAIL" +fi + +# CPU tests +SHA_TIME=$(cpu_benchmark sha256sum) +echo -n "SHA256: ${SHA_TIME} sec ........." +if [ $(echo "${SHA_TIME} <= ${TST_SHA}" | bc) -eq 1 ]; then + echo "pass" +else + echo "FAIL" +fi + +BZ2_TIME=$(cpu_benchmark bzip2) +echo -n "BZIP2: ${BZ2_TIME} sec ........." +if [ $(echo "${BZ2_TIME} <= ${TST_BZ2}" | bc) -eq 1 ]; then + echo "pass" +else + echo "FAIL" +fi + +AES_TIME=$(cpu_benchmark openssl enc -e -aes-256-cbc -pass pass:12345678 | sed '/^\*\*\* WARNING : deprecated key derivation used\.$/d;/^Using -iter or -pbkdf2 would be better\.$/d') +echo -n "AES256: ${AES_TIME} sec ........." +if [ $(echo "${AES_TIME} <= ${TST_AES}" | bc) -eq 1 ]; then + echo "pass" +else + echo "FAIL" +fi + +# Disk tests +DISK_RD=$(ioping -DRL -w 5 ./ | tail -n 2 | head -n 1 | cut -d ',' -f 4 | awk '{print $1}') +echo -n "DISK READ: ${DISK_RD} MB/s ......" +if [ $(echo "${DISK_RD} >= ${TST_DISKRD}" | bc) -eq 1 ]; then + echo "pass" +else + echo "FAIL" +fi + +rm -f dummy.bin +DISK_WR=$(dd if=/dev/zero of=dummy.bin bs=64k count=16k conv=fdatasync 2>&1 | tail -1 | awk '{print $10}') +rm -f dummy.bin +echo -n "DISK WRITE: ${DISK_WR} MB/s ......." +if [ $(echo "${DISK_WR} >= ${TST_DISKWR}" | bc) -eq 1 ]; then + echo "pass" +else + echo "FAIL" +fi + +# Report +rm -f ${CSV} +echo "Platform,HwSKU,Revision,Processor,CPU cores,Frequency(MHz),RAM(G),Disk(G),SHA256(s),bzip2(s),AES(s),sequential read(MiB/s),sequential write(MiB/s)," >> ${CSV} + +echo -n "${PLATFORM}," >> ${CSV} +echo -n "${HWSKU}," >> ${CSV} +echo -n "${REVISION}," >> ${CSV} +echo -n "${CPU_NAME}," >> ${CSV} +echo -n "${CPU_CORE}," >> ${CSV} +echo -n "${CPU_FREQ}," >> ${CSV} +echo -n "${RAM_SIZE}," >> ${CSV} +echo -n "${DISK_SIZE}," >> ${CSV} +echo -n "${SHA_TIME}," >> ${CSV} +echo -n "${BZ2_TIME}," >> ${CSV} +echo -n "${AES_TIME}," >> ${CSV} +echo -n "${DISK_RD}," >> ${CSV} +echo -n "${DISK_WR}," >> ${CSV} +echo "" >> ${CSV} diff --git a/dockers/docker-pde/docker_init.sh b/dockers/docker-pde/docker_init.sh new file mode 100644 index 000000000000..6e83fdd98aae --- /dev/null +++ b/dockers/docker-pde/docker_init.sh @@ -0,0 +1,45 @@ +#!/usr/bin/env bash + +set -x + +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 +} + +PLATFORM_DIR=/usr/share/sonic/platform +HWSKU_DIR=/usr/share/sonic/hwsku + +mkdir -p /etc/sai.d/ + +if [ -f $HWSKU_DIR/sai.profile ]; then + cp $HWSKU_DIR/sai.profile /etc/sai.d/sai.profile +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 [ $? -ne 0 ]; then + SONIC_PLATFORM_WHEEL="/usr/share/sonic/platform/sonic_platform-1.0-py2-none-any.whl" + echo "sonic-platform package not installed, attempting to install..." + if [ -e ${SONIC_PLATFORM_WHEEL} ]; then + pip install ${SONIC_PLATFORM_WHEEL} + if [ $? -eq 0 ]; then + echo "Successfully installed ${SONIC_PLATFORM_WHEEL}" + else + echo "Error: Failed to install ${SONIC_PLATFORM_WHEEL}" + fi + else + echo "Error: Unable to locate ${SONIC_PLATFORM_WHEEL}" + fi +fi + +start_bcm + +exec /usr/bin/supervisord + + diff --git a/dockers/docker-pde/stress-sfp-i2c.py b/dockers/docker-pde/stress-sfp-i2c.py new file mode 100644 index 000000000000..08247767e2e7 --- /dev/null +++ b/dockers/docker-pde/stress-sfp-i2c.py @@ -0,0 +1,157 @@ +#!/usr/bin/env python + +try: + import os + import sys + import subprocess + import time + import imp + from natsort import natsorted +except ImportError as e: + raise ImportError("%s - required module not found" % str(e)) + +HWSKU_PATH = "/usr/share/sonic/hwsku" +PLATFORM_PATH = "/usr/share/sonic/platform" + +PLATFORM_SPECIFIC_MODULE_NAME = 'sfputil' +PLATFORM_SPECIFIC_CLASS_NAME = 'SfpUtil' + +XCVR_EEPROM_TYPE_UNKNOWN = 0 +XCVR_EEPROM_TYPE_SFP = 1 +XCVR_EEPROM_TYPE_QSFP = 2 +XCVR_EEPROM_TYPE_QSFPDD = 3 +XCVR_EEPROM_TYPE_OSFP = XCVR_EEPROM_TYPE_QSFPDD + +OSFP_TYPE_ID = "18" + +# Global platform-specific sfputil class instance +platform_sfputil = None + +# Global port dictionaries +port_dict = None + +# Loads platform specific sfputil module from source +def load_platform_sfputil(): + global platform_sfputil + + if platform_sfputil is not None: + return + + try: + module_file = "/".join([PLATFORM_PATH, "plugins", PLATFORM_SPECIFIC_MODULE_NAME + ".py"]) + module = imp.load_source(PLATFORM_SPECIFIC_MODULE_NAME, module_file) + except IOError, e: + print("Failed to load platform module '%s': %s" % (PLATFORM_SPECIFIC_MODULE_NAME, str(e)), True) + + assert module is not None + + try: + platform_sfputil_class = getattr(module, PLATFORM_SPECIFIC_CLASS_NAME) + platform_sfputil = platform_sfputil_class() + except AttributeError, e: + print("Failed to instantiate '%s' class: %s" % (PLATFORM_SPECIFIC_CLASS_NAME, str(e)), True) + + assert platform_sfputil is not None + return + +# Loads platform port dictionaries +def load_platform_portdict(): + global port_dict + + if port_dict is not None: + return + + port_dict = {} + idx = 0 + file = open(HWSKU_PATH + "/port_config.ini", "r") + line = file.readline() + while line is not None and len(line) > 0: + line = line.strip() + if line.startswith("#"): + line = file.readline() + continue + list = line.split() + if len(list) >= 4: + idx = int(list[3]) + port_dict[list[0]] = { "index": str(idx) } + idx += 1 + line = file.readline() + + return port_dict + +def get_sfp_eeprom_type(port, data): + type = XCVR_EEPROM_TYPE_UNKNOWN + + if (port in platform_sfputil.osfp_ports) or (port in platform_sfputil.qsfp_ports): + if data is None: + return type + + if data[0] in OSFP_TYPE_ID: + code = 0 + for i in range(128, 222): + code += int(data[i], 16) + if (code & 0xff) == int(data[222], 16): + type = XCVR_EEPROM_TYPE_OSFP + else: + type = XCVR_EEPROM_TYPE_QSFP + else: + type = XCVR_EEPROM_TYPE_QSFP + else: + type = XCVR_EEPROM_TYPE_SFP + + return type + +# Test for SFP EEPROM +def stress_sfp_i2c_one(): + load_platform_sfputil() + load_platform_portdict() + num_sfp = 0 + for intf in natsorted(port_dict.keys()): + port = int(port_dict[intf]['index']) + if not platform_sfputil._is_valid_port(port): + continue + if platform_sfputil.get_presence(port): + num_sfp += 1 + + assert num_sfp >= 2, "2 or more SFP modules should be attached for this test" + + for intf in natsorted(port_dict.keys()): + port = int(port_dict[intf]['index']) + if not platform_sfputil._is_valid_port(port): + continue + if not platform_sfputil.get_presence(port): + continue + + data = platform_sfputil.get_eeprom_raw(port, 256) + assert data is not None, "SFP{}: unable to read EEPROM".format(port) + + code = 0 + type = get_sfp_eeprom_type(port, data) + if type == XCVR_EEPROM_TYPE_QSFPDD: + for i in range(128, 222): + code += int(data[i], 16) + assert (code & 0xff) == int(data[222], 16), "{}: check code error".format(intf) + elif type == XCVR_EEPROM_TYPE_QSFP: + for i in range(128, 191): + code += int(data[i], 16) + assert (code & 0xff) == int(data[191], 16), "{}: check code error".format(intf) + else: + for i in range(0, 63): + code += int(data[i], 16) + assert (code & 0xff) == int(data[63], 16), "{}: check code error".format(intf) + +def stress_sfp_i2c(sec=180): + print("Initiating {} seconds SFP I2C stress test...".format(sec)) + timeout = time.time() + sec + while timeout >= time.time(): + stress_sfp_i2c_one() + sys.stdout.write("#") + sys.stdout.flush() + print("\nPASS") + +if __name__ == '__main__': + sec = 180 + if len(sys.argv) >= 2: + sec = int(sys.argv[1]) + stress_sfp_i2c(sec) + diff --git a/dockers/docker-pde/supervisord.conf b/dockers/docker-pde/supervisord.conf new file mode 100644 index 000000000000..58a32d833163 --- /dev/null +++ b/dockers/docker-pde/supervisord.conf @@ -0,0 +1,12 @@ +[supervisord] +logfile_maxbytes=1MB +logfile_backups=2 +nodaemon=true + +[program:rsyslogd] +command=/bin/bash -c "rm -f /var/run/rsyslogd.pid && /usr/sbin/rsyslogd -n" +priority=1 +autostart=true +autorestart=false +stdout_logfile=syslog +stderr_logfile=syslog diff --git a/dockers/docker-pde/syseeprom.py b/dockers/docker-pde/syseeprom.py new file mode 100644 index 000000000000..d6444b8352b3 --- /dev/null +++ b/dockers/docker-pde/syseeprom.py @@ -0,0 +1,67 @@ +#!/usr/bin/python + +import sys +import imp +import subprocess +import time + +PLATFORM_SPECIFIC_MODULE_NAME = "eeprom" +PLATFORM_SPECIFIC_CLASS_NAME = "board" + +platform_eeprom = None +platform_eeprom_data = None + +# Returns path to platform and hwsku +def get_path_to_platform_and_hwsku(): + platform_path = '/usr/share/sonic/platform' + hwsku_path = '/usr/share/sonic/hwsku' + return (platform_path, hwsku_path) + +# Loads platform specific psuutil module from source +def load_platform_util(module_name, class_name): + platform_util = None + + # Get path to platform and hwsku + (platform_path, hwsku_path) = get_path_to_platform_and_hwsku() + + try: + module_file = "/".join([platform_path, "plugins", module_name + ".py"]) + module = imp.load_source(module_name, module_file) + except IOError, e: + assert False, ("Failed to load platform module '%s': %s" % (module_name, str(e))) + + try: + platform_util_class = getattr(module, class_name) + # board class of eeprom requires 4 paramerters, need special treatment here. + platform_util = platform_util_class('','','','') + except AttributeError, e: + assert False, ("Failed to instantiate '%s' class: %s" % (class_name, str(e))) + + return platform_util + +def init_platform_eeprom(): + global platform_eeprom + global platform_eeprom_data + + if platform_eeprom is None: + platform_eeprom = load_platform_util(PLATFORM_SPECIFIC_MODULE_NAME, \ + PLATFORM_SPECIFIC_CLASS_NAME) + if platform_eeprom_data is None: + platform_eeprom_data = platform_eeprom.read_eeprom() + + return platform_eeprom_data + +def main(): + e = init_platform_eeprom() + c = platform_eeprom._TLV_CODE_PLATFORM_NAME + if len(sys.argv) > 1: + c = int(sys.argv[1], 0) + v, t = platform_eeprom.get_tlv_field(e, c) + if v: + print(t[2]) + else: + print("Unknown") + +if __name__ == '__main__': + main() + diff --git a/files/build_templates/docker_image_ctl.j2 b/files/build_templates/docker_image_ctl.j2 index 7b4f91f3d5d0..f85b0721d5da 100644 --- a/files/build_templates/docker_image_ctl.j2 +++ b/files/build_templates/docker_image_ctl.j2 @@ -93,6 +93,16 @@ function preStartAction() docker cp /tmp/dump.rdb database$DEV:/var/lib/redis/ fi fi +{%- elif docker_container_name == "pde" %} + if [[ $(/bin/systemctl status swss | grep -c running) -gt 0 ]]; then + echo "Stopping SWSS before starting PDE" + systemctl stop swss + fi + + if [[ $(/bin/systemctl status watchdog-control.service | grep -c running) -gt 0 ]]; then + echo "Stopping watchdog-control.service before starting PDE" + systemctl stop watchdog-control.service + fi {%- elif docker_container_name == "snmp" %} $SONIC_DB_CLI STATE_DB HSET 'DEVICE_METADATA|localhost' chassis_serial_number $(decode-syseeprom -s) {%- else %} diff --git a/files/build_templates/pde.service.j2 b/files/build_templates/pde.service.j2 new file mode 100644 index 000000000000..f053b57ad576 --- /dev/null +++ b/files/build_templates/pde.service.j2 @@ -0,0 +1,22 @@ +[Unit] +Description=PDE container +{% if sonic_asic_platform == 'broadcom' %} +Requires=opennsl-modules.service +ConditionPathExists=!/usr/bin/swss.sh +{% endif %} + +After=updategraph.service +{% if sonic_asic_platform == 'broadcom' %} +After=opennsl-modules.service +{% endif %} + +Before= + +[Service] +User={{ sonicadmin_user }} +ExecStartPre=/usr/bin/{{ docker_container_name }}.sh start +ExecStart=/usr/bin/{{ docker_container_name }}.sh wait +ExecStop=/usr/bin/{{ docker_container_name }}.sh stop + +[Install] +WantedBy=multi-user.target diff --git a/platform/broadcom/docker-pde.dep b/platform/broadcom/docker-pde.dep new file mode 100644 index 000000000000..bc7eb8225808 --- /dev/null +++ b/platform/broadcom/docker-pde.dep @@ -0,0 +1,12 @@ + +DPATH := $($(DOCKER_PDE)_PATH) +DEP_FILES := $(SONIC_COMMON_FILES_LIST) platform/broadcom/docker-pde.mk platform/broadcom/docker-pde.dep +DEP_FILES += $(SONIC_COMMON_BASE_FILES_LIST) +DEP_FILES += $(SONIC_COMMON_DOCKER_FILES_LIST) +DEP_FILES += $(shell git ls-files $(DPATH)) + +$(DOCKER_PDE)_CACHE_MODE := GIT_CONTENT_SHA +$(DOCKER_PDE)_DEP_FLAGS := $(SONIC_COMMON_FLAGS_LIST) +$(DOCKER_PDE)_DEP_FILES := $(DEP_FILES) + +$(eval $(call add_dbg_docker,$(DOCKER_PDE),$(DOCKER_PDE_DBG))) diff --git a/platform/broadcom/docker-pde.mk b/platform/broadcom/docker-pde.mk new file mode 100644 index 000000000000..aba1a5a356e4 --- /dev/null +++ b/platform/broadcom/docker-pde.mk @@ -0,0 +1,52 @@ +# Docker image for SONiC Platform Development Environment (PDE) + + +ifeq ($(ENABLE_PDE), y) + +DOCKER_PDE_STEM = docker-pde +DOCKER_PDE = $(DOCKER_PDE_STEM).gz +DOCKER_PDE_DBG = $(DOCKER_PDE_STEM)-$(DBG_IMAGE_MARK).gz + +$(DOCKER_PDE)_PATH = $(DOCKERS_PATH)/$(DOCKER_PDE_STEM) + +$(DOCKER_PDE)_DEPENDS += $(PYTHON_NETIFACES) +$(DOCKER_PDE)_DEPENDS += $(SONIC_PLATFORM_PDE) $(BRCM_SAI) +$(DOCKER_PDE_RDEPENDS += $(PYTHON_NETIFACES) + +$(DOCKER_PDE)_PYTHON_DEBS += $(SONIC_UTILS) +$(DOCKER_PDE)_PYTHON_WHEELS += $(SONIC_PLATFORM_COMMON_PY3) +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) + + +SONIC_DOCKER_IMAGES += $(DOCKER_PDE) +SONIC_BUSTER_DOCKERS += $(DOCKER_PDE) +SONIC_INSTALL_DOCKER_IMAGES += $(DOCKER_PDE) +SONIC_BUSTER_DBG_DOCKERS += $(DOCKER_PDE_DBG) +SONIC_DOCKER_DBG_IMAGES += $(DOCKER_PDE_DBG) +SONIC_INSTALL_DOCKER_DBG_IMAGES += $(DOCKER_PDE_DBG) + +$(DOCKER_PDE)_CONTAINER_NAME = pde +$(DOCKER_PDE)_RUN_OPT += --net=host --privileged -t +$(DOCKER_PDE)_RUN_OPT += -v /etc/sonic:/etc/sonic:ro +$(DOCKER_PDE)_RUN_OPT += -v /host/machine.conf:/host/machine.conf:ro +$(DOCKER_PDE)_RUN_OPT += -v /usr/lib/python2.7/dist-packages:/usr/share/sonic/classes:ro +$(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 /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)_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 +$(DOCKER_PDE)_BASE_IMAGE_FILES += pde-bench-knet:/usr/local/bin/pde-bench-knet + +endif diff --git a/platform/broadcom/one-pde-image.mk b/platform/broadcom/one-pde-image.mk new file mode 100644 index 000000000000..e8b2629c49a6 --- /dev/null +++ b/platform/broadcom/one-pde-image.mk @@ -0,0 +1,81 @@ +# sonic broadcom one image installer + +SONIC_ONE_PDE_IMAGE = sonic-broadcom-pde.bin +$(SONIC_ONE_PDE_IMAGE)_MACHINE = broadcom +$(SONIC_ONE_PDE_IMAGE)_IMAGE_TYPE = onie +$(SONIC_ONE_PDE_IMAGE)_INSTALLS += $(BRCM_OPENNSL_KERNEL) +$(SONIC_ONE_PDE_IMAGE)_INSTALLS += $(PDDF_PLATFORM_MODULE) +$(SONIC_ONE_PDE_IMAGE)_LAZY_INSTALLS += $(DELL_S6000_PLATFORM_MODULE) \ + $(DELL_Z9332F_PLATFORM_MODULE) \ + $(DELL_Z9264F_PLATFORM_MODULE) \ + $(DELL_S5212F_PLATFORM_MODULE) \ + $(DELL_S5232F_PLATFORM_MODULE) \ + $(DELL_S5248F_PLATFORM_MODULE) \ + $(DELL_S5296F_PLATFORM_MODULE) \ + $(DELL_Z9100_PLATFORM_MODULE) \ + $(DELL_S6100_PLATFORM_MODULE) \ + $(DELL_S3000_PLATFORM_MODULE) \ + $(DELL_N3248TE_PLATFORM_MODULE) \ + $(DELL_S5224F_PLATFORM_MODULE) \ + $(DELL_Z9432F_PLATFORM_MODULE) \ + $(INGRASYS_S8900_54XC_PLATFORM_MODULE) \ + $(INGRASYS_S8900_64XC_PLATFORM_MODULE) \ + $(INGRASYS_S9100_PLATFORM_MODULE) \ + $(INGRASYS_S8810_32Q_PLATFORM_MODULE) \ + $(INGRASYS_S9200_64X_PLATFORM_MODULE) \ + $(ACCTON_AS7712_32X_PLATFORM_MODULE) \ + $(ACCTON_AS5712_54X_PLATFORM_MODULE) \ + $(ACCTON_AS7816_64X_PLATFORM_MODULE) \ + $(ACCTON_AS7716_32X_PLATFORM_MODULE) \ + $(ACCTON_AS7312_54X_PLATFORM_MODULE) \ + $(ACCTON_AS7326_56X_PLATFORM_MODULE) \ + $(ACCTON_AS7716_32XB_PLATFORM_MODULE) \ + $(ACCTON_AS6712_32X_PLATFORM_MODULE) \ + $(ACCTON_AS7726_32X_PLATFORM_MODULE) \ + $(ACCTON_AS4630_54PE_PLATFORM_MODULE) \ + $(ACCTON_MINIPACK_PLATFORM_MODULE) \ + $(ACCTON_AS5812_54X_PLATFORM_MODULE) \ + $(ACCTON_AS5812_54T_PLATFORM_MODULE) \ + $(ACCTON_AS5835_54X_PLATFORM_MODULE) \ + $(ACCTON_AS9716_32D_PLATFORM_MODULE) \ + $(ACCTON_AS5835_54T_PLATFORM_MODULE) \ + $(ACCTON_AS7312_54XS_PLATFORM_MODULE) \ + $(ACCTON_AS7315_27XB_PLATFORM_MODULE) \ + $(INVENTEC_D7032Q28B_PLATFORM_MODULE) \ + $(INVENTEC_D7054Q28B_PLATFORM_MODULE) \ + $(INVENTEC_D7264Q28B_PLATFORM_MODULE) \ + $(INVENTEC_D7264_PLATFORM_MODULE) \ + $(INVENTEC_D6356_PLATFORM_MODULE) \ + $(INVENTEC_D6356J_PLATFORM_MODULE) \ + $(INVENTEC_D6332_PLATFORM_MODULE) \ + $(INVENTEC_D7332_PLATFORM_MODULE) \ + $(CEL_DX010_PLATFORM_MODULE) \ + $(CEL_HALIBURTON_PLATFORM_MODULE) \ + $(DELTA_AG9032V1_PLATFORM_MODULE) \ + $(DELTA_AG9064_PLATFORM_MODULE) \ + $(DELTA_AG5648_PLATFORM_MODULE) \ + $(DELTA_ET6248BRB_PLATFORM_MODULE) \ + $(QUANTA_IX1B_32X_PLATFORM_MODULE) \ + $(QUANTA_IX4_64X_PLATFORM_MODULE) \ + $(QUANTA_IX7_32X_PLATFORM_MODULE) \ + $(QUANTA_IX7_BWDE_32X_PLATFORM_MODULE) \ + $(QUANTA_IX7T_32X_PLATFORM_MODULE) \ + $(QUANTA_IX8_56X_PLATFORM_MODULE) \ + $(QUANTA_IX8C_56X_PLATFORM_MODULE) \ + $(QUANTA_IX8A_BWDE_56X_PLATFORM_MODULE) \ + $(QUANTA_IX8F_56X_PLATFORM_MODULE) \ + $(QUANTA_IX8T_56X_PLATFORM_MODULE) \ + $(QUANTA_IX9_32X_PLATFORM_MODULE) \ + $(MITAC_LY1200_32X_PLATFORM_MODULE) \ + $(ALPHANETWORKS_SNH60A0_320FV2_PLATFORM_MODULE) \ + $(ALPHANETWORKS_SNH60B0_640F_PLATFORM_MODULE) \ + $(ALPHANETWORKS_SNJ60B0_320F_PLATFORM_MODULE) \ + $(ALPHANETWORKS_SNJ61D0_320F_PLATFORM_MODULE) \ + $(BRCM_XLR_GTS_PLATFORM_MODULE) \ + $(DELTA_AG9032V2A_PLATFORM_MODULE) \ + $(JUNIPER_QFX5210_PLATFORM_MODULE) \ + $(CEL_SILVERSTONE_PLATFORM_MODULE) \ + $(CEL_SILVERSTONE-DP_PLATFORM_MODULE) + +$(SONIC_ONE_PDE_IMAGE)_DOCKERS += $(DOCKER_PDE) $(DOCKER_PLATFORM_MONITOR) $(DOCKER_DATABASE) +SONIC_INSTALLERS += $(SONIC_ONE_PDE_IMAGE) diff --git a/platform/broadcom/sonic-pde-tests.dep b/platform/broadcom/sonic-pde-tests.dep new file mode 100644 index 000000000000..40b99496c14d --- /dev/null +++ b/platform/broadcom/sonic-pde-tests.dep @@ -0,0 +1,12 @@ + +SPATH := $($(SONIC_PLATFORM_PDE)_SRC_PATH) +DEP_FILES := $(SONIC_COMMON_FILES_LIST) platform/broadcom/sonic-pde-tests.mk platform/broadcom/sonic-pde-tests.dep +DEP_FILES += $(SONIC_COMMON_BASE_FILES_LIST) +SMDEP_FILES := $(addprefix $(SPATH)/,$(shell cd $(SPATH) && git ls-files)) + +$(SONIC_PLATFORM_PDE)_CACHE_MODE := GIT_CONTENT_SHA +$(SONIC_PLATFORM_PDE)_DEP_FLAGS := $(SONIC_COMMON_FLAGS_LIST) +$(SONIC_PLATFORM_PDE)_DEP_FILES := $(DEP_FILES) +$(SONIC_PLATFORM_PDE)_SMDEP_FILES := $(SMDEP_FILES) +$(SONIC_PLATFORM_PDE)_SMDEP_PATHS := $(SPATH) + diff --git a/platform/broadcom/sonic-pde-tests.mk b/platform/broadcom/sonic-pde-tests.mk new file mode 100644 index 000000000000..a7482625c87e --- /dev/null +++ b/platform/broadcom/sonic-pde-tests.mk @@ -0,0 +1,7 @@ +# sonic pde package + +SONIC_PLATFORM_PDE = sonic-platform-pde_1.0_amd64.deb +$(SONIC_PLATFORM_PDE)_SRC_PATH = $(SRC_PATH)/sonic-platform-pde +$(SONIC_PLATFORM_PDE)_DEPENDS += $(BRCM_SAI) $(BRCM_SAI_DEV) $(SWIG) + +SONIC_DPKG_DEBS += $(SONIC_PLATFORM_PDE) diff --git a/rules/config b/rules/config index b45ce2152806..022e2228eb4c 100644 --- a/rules/config +++ b/rules/config @@ -51,6 +51,8 @@ DEFAULT_PASSWORD = YourPaSsWoRd # ENABLE_ZTP - installs Zero Touch Provisioning support. # ENABLE_ZTP = y +# ENABLE_PDE - Enable platform development enviroment +ENABLE_PDE = y # SHUTDOWN_BGP_ON_START - if set to y all bgp sessions will be in admin down state when # bgp service starts. # SHUTDOWN_BGP_ON_START = y diff --git a/slave.mk b/slave.mk index 9cce5392cc2c..9a253e0bc2d6 100644 --- a/slave.mk +++ b/slave.mk @@ -241,6 +241,7 @@ $(info "HTTP_PROXY" : "$(HTTP_PROXY)") $(info "HTTPS_PROXY" : "$(HTTPS_PROXY)") $(info "NO_PROXY" : "$(NO_PROXY)") $(info "ENABLE_ZTP" : "$(ENABLE_ZTP)") +$(info "ENABLE_PDE" : "$(ENABLE_PDE)") $(info "SONIC_DEBUGGING_ON" : "$(SONIC_DEBUGGING_ON)") $(info "SONIC_PROFILING_ON" : "$(SONIC_PROFILING_ON)") $(info "KERNEL_PROCURE_METHOD" : "$(KERNEL_PROCURE_METHOD)") @@ -915,6 +916,7 @@ $(addprefix $(TARGET_PATH)/, $(SONIC_INSTALLERS)) : $(TARGET_PATH)/% : \ export include_mgmt_framework="$(INCLUDE_MGMT_FRAMEWORK)" export include_iccpd="$(INCLUDE_ICCPD)" export pddf_support="$(PDDF_SUPPORT)" + export enable_pde="$(ENABLE_PDE)" export shutdown_bgp_on_start="$(SHUTDOWN_BGP_ON_START)" export default_buffer_model="$(SONIC_BUFFER_MODEL)" export include_kubernetes="$(INCLUDE_KUBERNETES)" @@ -1022,6 +1024,8 @@ $(addprefix $(TARGET_PATH)/, $(SONIC_INSTALLERS)) : $(TARGET_PATH)/% : \ DEBUG_IMG="$(INSTALL_DEBUG_TOOLS)" \ DEBUG_SRC_ARCHIVE_FILE="$(DBG_SRC_ARCHIVE_FILE)" \ + ARTIFACTORY_URL="$(ARTIFACTORY_URL)" \ + BUILD_TARGET="$@" \ USERNAME="$(USERNAME)" \ PASSWORD="$(PASSWORD)" \ IMAGE_TYPE=$($*_IMAGE_TYPE) \ @@ -1036,6 +1040,7 @@ $(addprefix $(TARGET_PATH)/, $(SONIC_INSTALLERS)) : $(TARGET_PATH)/% : \ PASSWORD="$(PASSWORD)" \ TARGET_MACHINE=$($*_MACHINE) \ IMAGE_TYPE=$($*_IMAGE_TYPE) \ + BUILD_TARGET="$@" \ SONIC_ENABLE_IMAGE_SIGNATURE="$(SONIC_ENABLE_IMAGE_SIGNATURE)" \ SIGNING_KEY="$(SIGNING_KEY)" \ SIGNING_CERT="$(SIGNING_CERT)" \ From d0f6bb2d9cf0603bf2a36b3de85c08e471cf0f5e Mon Sep 17 00:00:00 2001 From: Geans Pin Date: Fri, 4 Jun 2021 16:39:02 -0700 Subject: [PATCH 03/28] Fix review comment --- dockers/docker-pde/base_image_files/pde-bench | 3 +-- dockers/docker-pde/docker_init.sh | 4 +--- dockers/docker-pde/stress-sfp-i2c.py | 3 +-- platform/broadcom/sonic-pde-tests.dep | 4 +--- 4 files changed, 4 insertions(+), 10 deletions(-) diff --git a/dockers/docker-pde/base_image_files/pde-bench b/dockers/docker-pde/base_image_files/pde-bench index 1e2c727b02af..5240264e11ce 100644 --- a/dockers/docker-pde/base_image_files/pde-bench +++ b/dockers/docker-pde/base_image_files/pde-bench @@ -34,5 +34,4 @@ echo "" echo "CSV Report: ${CSV}" echo "-----------------------------------------------------------------------" echo "$(cat ${CSV})" -echo "-----------------------------------------------------------------------" - +echo "-----------------------------------------------------------------------" \ No newline at end of file diff --git a/dockers/docker-pde/docker_init.sh b/dockers/docker-pde/docker_init.sh index 6e83fdd98aae..266cc9fd0346 100644 --- a/dockers/docker-pde/docker_init.sh +++ b/dockers/docker-pde/docker_init.sh @@ -40,6 +40,4 @@ fi start_bcm -exec /usr/bin/supervisord - - +exec /usr/bin/supervisord \ No newline at end of file diff --git a/dockers/docker-pde/stress-sfp-i2c.py b/dockers/docker-pde/stress-sfp-i2c.py index 08247767e2e7..04ab85e745f1 100644 --- a/dockers/docker-pde/stress-sfp-i2c.py +++ b/dockers/docker-pde/stress-sfp-i2c.py @@ -153,5 +153,4 @@ def stress_sfp_i2c(sec=180): sec = 180 if len(sys.argv) >= 2: sec = int(sys.argv[1]) - stress_sfp_i2c(sec) - + stress_sfp_i2c(sec) \ No newline at end of file diff --git a/platform/broadcom/sonic-pde-tests.dep b/platform/broadcom/sonic-pde-tests.dep index 40b99496c14d..2e0461f19580 100644 --- a/platform/broadcom/sonic-pde-tests.dep +++ b/platform/broadcom/sonic-pde-tests.dep @@ -1,4 +1,3 @@ - SPATH := $($(SONIC_PLATFORM_PDE)_SRC_PATH) DEP_FILES := $(SONIC_COMMON_FILES_LIST) platform/broadcom/sonic-pde-tests.mk platform/broadcom/sonic-pde-tests.dep DEP_FILES += $(SONIC_COMMON_BASE_FILES_LIST) @@ -8,5 +7,4 @@ $(SONIC_PLATFORM_PDE)_CACHE_MODE := GIT_CONTENT_SHA $(SONIC_PLATFORM_PDE)_DEP_FLAGS := $(SONIC_COMMON_FLAGS_LIST) $(SONIC_PLATFORM_PDE)_DEP_FILES := $(DEP_FILES) $(SONIC_PLATFORM_PDE)_SMDEP_FILES := $(SMDEP_FILES) -$(SONIC_PLATFORM_PDE)_SMDEP_PATHS := $(SPATH) - +$(SONIC_PLATFORM_PDE)_SMDEP_PATHS := $(SPATH) \ No newline at end of file From 01d43dbacd1726ffdec53df718130f83d926f815 Mon Sep 17 00:00:00 2001 From: Geans Pin Date: Mon, 3 May 2021 17:07:58 -0700 Subject: [PATCH 04/28] Initial commit for introducing the SONiC Platform Development Env (Resubmit PR#3778) Rebase latest and Resubmit to fix conflict --- Makefile.work | 1 + dockers/docker-pde/Dockerfile.j2 | 2 ++ platform/broadcom/docker-pde.mk | 10 ---------- 3 files changed, 3 insertions(+), 10 deletions(-) diff --git a/Makefile.work b/Makefile.work index b099bae0391d..d7d3c69f45db 100644 --- a/Makefile.work +++ b/Makefile.work @@ -357,6 +357,7 @@ initpde: git submodule update --init --recursive $$submodule ; \ done @git submodule foreach --recursive '[ -f .git ] && echo "gitdir: $$(realpath --relative-to=. $$(cut -d" " -f2 .git))" > .git' + init : @git submodule update --init --recursive @git submodule foreach --recursive '[ -f .git ] && echo "gitdir: $$(realpath --relative-to=. $$(cut -d" " -f2 .git))" > .git' diff --git a/dockers/docker-pde/Dockerfile.j2 b/dockers/docker-pde/Dockerfile.j2 index 4486bcc812fa..4c37f8d45fbf 100644 --- a/dockers/docker-pde/Dockerfile.j2 +++ b/dockers/docker-pde/Dockerfile.j2 @@ -24,6 +24,7 @@ RUN apt-get install -y python-jsonschema RUN pip3 install pytest pexpect + {% if docker_pde_debs.strip() -%} # Copy locally-built Debian package dependencies COPY \ @@ -62,6 +63,7 @@ python-wheels/{{ whl }}{{' '}} # Install locally-built Python wheel dependencies RUN pip3 install \ + {% for whl in docker_pde_whls.split(' ') -%} /python-wheels/{{ whl }}{{' '}} {%- endfor %} diff --git a/platform/broadcom/docker-pde.mk b/platform/broadcom/docker-pde.mk index aba1a5a356e4..7d6aa5b726c9 100644 --- a/platform/broadcom/docker-pde.mk +++ b/platform/broadcom/docker-pde.mk @@ -1,18 +1,12 @@ # Docker image for SONiC Platform Development Environment (PDE) - - ifeq ($(ENABLE_PDE), y) - DOCKER_PDE_STEM = docker-pde DOCKER_PDE = $(DOCKER_PDE_STEM).gz DOCKER_PDE_DBG = $(DOCKER_PDE_STEM)-$(DBG_IMAGE_MARK).gz - $(DOCKER_PDE)_PATH = $(DOCKERS_PATH)/$(DOCKER_PDE_STEM) - $(DOCKER_PDE)_DEPENDS += $(PYTHON_NETIFACES) $(DOCKER_PDE)_DEPENDS += $(SONIC_PLATFORM_PDE) $(BRCM_SAI) $(DOCKER_PDE_RDEPENDS += $(PYTHON_NETIFACES) - $(DOCKER_PDE)_PYTHON_DEBS += $(SONIC_UTILS) $(DOCKER_PDE)_PYTHON_WHEELS += $(SONIC_PLATFORM_COMMON_PY3) ifeq ($(PDDF_SUPPORT), y) @@ -21,10 +15,7 @@ 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) - - SONIC_DOCKER_IMAGES += $(DOCKER_PDE) SONIC_BUSTER_DOCKERS += $(DOCKER_PDE) SONIC_INSTALL_DOCKER_IMAGES += $(DOCKER_PDE) @@ -48,5 +39,4 @@ $(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 $(DOCKER_PDE)_BASE_IMAGE_FILES += pde-bench-knet:/usr/local/bin/pde-bench-knet - endif From edfd3081c817a277576fd26d99902380cbe682a3 Mon Sep 17 00:00:00 2001 From: Geans Pin Date: Fri, 4 Jun 2021 16:39:02 -0700 Subject: [PATCH 05/28] Fix review comment --- dockers/docker-pde/base_image_files/pde-bench | 3 +-- dockers/docker-pde/docker_init.sh | 4 +--- dockers/docker-pde/stress-sfp-i2c.py | 3 +-- platform/broadcom/sonic-pde-tests.dep | 4 +--- 4 files changed, 4 insertions(+), 10 deletions(-) diff --git a/dockers/docker-pde/base_image_files/pde-bench b/dockers/docker-pde/base_image_files/pde-bench index 1e2c727b02af..5240264e11ce 100644 --- a/dockers/docker-pde/base_image_files/pde-bench +++ b/dockers/docker-pde/base_image_files/pde-bench @@ -34,5 +34,4 @@ echo "" echo "CSV Report: ${CSV}" echo "-----------------------------------------------------------------------" echo "$(cat ${CSV})" -echo "-----------------------------------------------------------------------" - +echo "-----------------------------------------------------------------------" \ No newline at end of file diff --git a/dockers/docker-pde/docker_init.sh b/dockers/docker-pde/docker_init.sh index 6e83fdd98aae..266cc9fd0346 100644 --- a/dockers/docker-pde/docker_init.sh +++ b/dockers/docker-pde/docker_init.sh @@ -40,6 +40,4 @@ fi start_bcm -exec /usr/bin/supervisord - - +exec /usr/bin/supervisord \ No newline at end of file diff --git a/dockers/docker-pde/stress-sfp-i2c.py b/dockers/docker-pde/stress-sfp-i2c.py index 08247767e2e7..04ab85e745f1 100644 --- a/dockers/docker-pde/stress-sfp-i2c.py +++ b/dockers/docker-pde/stress-sfp-i2c.py @@ -153,5 +153,4 @@ def stress_sfp_i2c(sec=180): sec = 180 if len(sys.argv) >= 2: sec = int(sys.argv[1]) - stress_sfp_i2c(sec) - + stress_sfp_i2c(sec) \ No newline at end of file diff --git a/platform/broadcom/sonic-pde-tests.dep b/platform/broadcom/sonic-pde-tests.dep index 40b99496c14d..2e0461f19580 100644 --- a/platform/broadcom/sonic-pde-tests.dep +++ b/platform/broadcom/sonic-pde-tests.dep @@ -1,4 +1,3 @@ - SPATH := $($(SONIC_PLATFORM_PDE)_SRC_PATH) DEP_FILES := $(SONIC_COMMON_FILES_LIST) platform/broadcom/sonic-pde-tests.mk platform/broadcom/sonic-pde-tests.dep DEP_FILES += $(SONIC_COMMON_BASE_FILES_LIST) @@ -8,5 +7,4 @@ $(SONIC_PLATFORM_PDE)_CACHE_MODE := GIT_CONTENT_SHA $(SONIC_PLATFORM_PDE)_DEP_FLAGS := $(SONIC_COMMON_FLAGS_LIST) $(SONIC_PLATFORM_PDE)_DEP_FILES := $(DEP_FILES) $(SONIC_PLATFORM_PDE)_SMDEP_FILES := $(SMDEP_FILES) -$(SONIC_PLATFORM_PDE)_SMDEP_PATHS := $(SPATH) - +$(SONIC_PLATFORM_PDE)_SMDEP_PATHS := $(SPATH) \ No newline at end of file From 7cd31a4ba9c1b969f39bad7579ce9e054d3e4d06 Mon Sep 17 00:00:00 2001 From: Geans Pin Date: Fri, 11 Jun 2021 16:18:48 -0700 Subject: [PATCH 06/28] Fix LGTM --- dockers/docker-pde/stress-sfp-i2c.py | 4 +--- dockers/docker-pde/syseeprom.py | 2 -- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/dockers/docker-pde/stress-sfp-i2c.py b/dockers/docker-pde/stress-sfp-i2c.py index 04ab85e745f1..cd595c52ec5c 100644 --- a/dockers/docker-pde/stress-sfp-i2c.py +++ b/dockers/docker-pde/stress-sfp-i2c.py @@ -1,9 +1,7 @@ #!/usr/bin/env python try: - import os import sys - import subprocess import time import imp from natsort import natsorted @@ -153,4 +151,4 @@ def stress_sfp_i2c(sec=180): sec = 180 if len(sys.argv) >= 2: sec = int(sys.argv[1]) - stress_sfp_i2c(sec) \ No newline at end of file + stress_sfp_i2c(sec) diff --git a/dockers/docker-pde/syseeprom.py b/dockers/docker-pde/syseeprom.py index d6444b8352b3..5f536128837a 100644 --- a/dockers/docker-pde/syseeprom.py +++ b/dockers/docker-pde/syseeprom.py @@ -2,8 +2,6 @@ import sys import imp -import subprocess -import time PLATFORM_SPECIFIC_MODULE_NAME = "eeprom" PLATFORM_SPECIFIC_CLASS_NAME = "board" From 1ebb2a8862b1f9143ae0f8b290ec7887d9023a4a Mon Sep 17 00:00:00 2001 From: Geans Pin Date: Mon, 3 May 2021 17:07:58 -0700 Subject: [PATCH 07/28] Initial commit for introducing the SONiC Platform Development Env (Resubmit PR#3778) --- Makefile.work | 19 +- dockers/docker-pde/Dockerfile.j2 | 91 +++++ dockers/docker-pde/base_image_files/pde-bench | 38 ++ .../base_image_files/pde-bench-knet | 326 ++++++++++++++++++ .../docker-pde/base_image_files/pde-stress | 27 ++ dockers/docker-pde/base_image_files/pde-test | 59 ++++ dockers/docker-pde/bench.sh | 140 ++++++++ dockers/docker-pde/docker_init.sh | 45 +++ dockers/docker-pde/stress-sfp-i2c.py | 157 +++++++++ dockers/docker-pde/supervisord.conf | 12 + dockers/docker-pde/syseeprom.py | 67 ++++ files/build_templates/docker_image_ctl.j2 | 10 + files/build_templates/pde.service.j2 | 22 ++ platform/broadcom/docker-pde.dep | 12 + platform/broadcom/docker-pde.mk | 52 +++ platform/broadcom/one-pde-image.mk | 81 +++++ platform/broadcom/sonic-pde-tests.dep | 12 + platform/broadcom/sonic-pde-tests.mk | 7 + rules/config | 2 + slave.mk | 5 + 20 files changed, 1183 insertions(+), 1 deletion(-) create mode 100644 dockers/docker-pde/Dockerfile.j2 create mode 100644 dockers/docker-pde/base_image_files/pde-bench create mode 100644 dockers/docker-pde/base_image_files/pde-bench-knet create mode 100644 dockers/docker-pde/base_image_files/pde-stress create mode 100644 dockers/docker-pde/base_image_files/pde-test create mode 100644 dockers/docker-pde/bench.sh create mode 100644 dockers/docker-pde/docker_init.sh create mode 100644 dockers/docker-pde/stress-sfp-i2c.py create mode 100644 dockers/docker-pde/supervisord.conf create mode 100644 dockers/docker-pde/syseeprom.py create mode 100644 files/build_templates/pde.service.j2 create mode 100644 platform/broadcom/docker-pde.dep create mode 100644 platform/broadcom/docker-pde.mk create mode 100644 platform/broadcom/one-pde-image.mk create mode 100644 platform/broadcom/sonic-pde-tests.dep create mode 100644 platform/broadcom/sonic-pde-tests.mk diff --git a/Makefile.work b/Makefile.work index 6577e5aebbb9..a42855a8b4f1 100644 --- a/Makefile.work +++ b/Makefile.work @@ -246,6 +246,7 @@ SONIC_BUILD_INSTRUCTION := make \ SONIC_IMAGE_VERSION=$(SONIC_IMAGE_VERSION) \ ENABLE_DHCP_GRAPH_SERVICE=$(ENABLE_DHCP_GRAPH_SERVICE) \ ENABLE_ZTP=$(ENABLE_ZTP) \ + ENABLE_PDE=$(ENABLE_PDE) \ SHUTDOWN_BGP_ON_START=$(SHUTDOWN_BGP_ON_START) \ INCLUDE_KUBERNETES=$(INCLUDE_KUBERNETES) \ KUBERNETES_VERSION=$(KUBERNETES_VERSION) \ @@ -276,7 +277,18 @@ SONIC_BUILD_INSTRUCTION := make \ SLAVE_DIR=$(SLAVE_DIR) \ $(SONIC_OVERRIDE_BUILD_VARS) -.PHONY: sonic-slave-build sonic-slave-bash init reset +PDESUBMODULES = src/sonic-linux-kernel \ + src/sonic-utilities \ + src/sonic-platform-common \ + src/sonic-swss-common \ + src/sonic-swss \ + src/sonic-py-swsssdk \ + src/redis-dump-load \ + src/sonic-sairedis \ + src/sonic-ztp \ + src/sonic-platform-daemons \ + src/sonic-platform-pde +.PHONY: sonic-slave-build sonic-slave-bash init initpde reset .DEFAULT_GOAL := all @@ -345,6 +357,11 @@ showtag: @echo $(SLAVE_IMAGE):$(SLAVE_TAG) @echo $(SLAVE_BASE_IMAGE):$(SLAVE_BASE_TAG) +initpde: + @for submodule in $(PDESUBMODULES) ; do \ + git submodule update --init --recursive $$submodule ; \ + done + @git submodule foreach --recursive '[ -f .git ] && echo "gitdir: $$(realpath --relative-to=. $$(cut -d" " -f2 .git))" > .git' init : @git submodule update --init --recursive @git submodule foreach --recursive '[ -f .git ] && echo "gitdir: $$(realpath --relative-to=. $$(cut -d" " -f2 .git))" > .git' diff --git a/dockers/docker-pde/Dockerfile.j2 b/dockers/docker-pde/Dockerfile.j2 new file mode 100644 index 000000000000..4486bcc812fa --- /dev/null +++ b/dockers/docker-pde/Dockerfile.j2 @@ -0,0 +1,91 @@ +FROM {{ docker_pde_load_image }} + +ARG docker_container_name +ENV PYTHONPATH=/usr/share/sonic/platform + +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 + +{% if ARTIFACTORY_URL is defined and ARTIFACTORY_URL|length -%} +# Insert Artifactory URL references +COPY ["files/03_stretch_af.list", "/etc/apt/sources.list.d/"] +{%- endif %} + +# Update apt's cache of available packages +RUN apt-get update && apt-get install -y ipmitool telnet busybox kmod libpcap-dev + +# Packages for benchmark tool - nench.sh +RUN apt-get install -y bzip2 curl ioping openssl bc sysstat + +# Packages for PDDF +RUN apt-get install -y python-jsonschema + +RUN pip3 install pytest pexpect + +{% if docker_pde_debs.strip() -%} +# Copy locally-built Debian package dependencies +COPY \ +{% for deb in docker_pde_debs.split(' ') -%} +debs/{{ deb }}{{' '}} +{%- endfor -%} +/debs/ + +# Install locally-built Debian packages and implicitly install their dependencies +RUN dpkg_apt() { [ -f $1 ] && { dpkg -i $1 || apt-get -y install -f; } || return 1; }{%- for deb in docker_pde_debs.split(' ') %}; \ +dpkg_apt /debs/{{ deb }} +{%- endfor %} +{%- endif %} + +{% if docker_pde_pydebs.strip() -%} +# Copy locally-built Debian package dependencies +COPY \ +{% for deb in docker_pde_pydebs.split(' ') -%} +python-debs/{{ deb }}{{' '}} +{%- endfor -%} +/debs/ + +# Install locally-built Debian packages and implicitly install their dependencies +{%- for deb in docker_pde_pydebs.split(' ') %} +RUN dpkg_apt() { [ -f $1 ] && { dpkg -i $1 || apt-get -y install -f; } || return 1; }; dpkg_apt /debs/{{ deb }} +{%- endfor %} +{%- endif %} + +{% if docker_pde_whls.strip() -%} +# Copy locally-built Python wheel dependencies +COPY \ +{% for whl in docker_pde_whls.split(' ') -%} +python-wheels/{{ whl }}{{' '}} +{%- endfor -%} +/python-wheels/ + +# Install locally-built Python wheel dependencies +RUN pip3 install \ +{% for whl in docker_pde_whls.split(' ') -%} +/python-wheels/{{ whl }}{{' '}} +{%- endfor %} +{% endif %} + +{% if ARTIFACTORY_URL is defined and ARTIFACTORY_URL|length -%} +# Remove Artifactory URL references +RUN rm -f /etc/apt/sources.list.d/03_stretch_af.list && apt-get update +{%- endif %} + +# Clean up +RUN apt-get clean -y; \ + apt-get autoclean -y; \ + apt-get autoremove -y +RUN rm -rf /debs ~/.cache + +RUN mkdir -p /home/pde + +COPY ["bench.sh", "/usr/bin/"] +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 ["syncd_init_common.sh", "/usr/bin/"] + +ENTRYPOINT ["/usr/bin/docker_init.sh"] diff --git a/dockers/docker-pde/base_image_files/pde-bench b/dockers/docker-pde/base_image_files/pde-bench new file mode 100644 index 000000000000..1e2c727b02af --- /dev/null +++ b/dockers/docker-pde/base_image_files/pde-bench @@ -0,0 +1,38 @@ +#!/bin/bash + +CSV=/tmp/bench.csv + +# Make sure only root can run our script +if [ "$(id -u)" != "0" ]; then + echo "This script must be run as root" 1>&2 + exit 1 +fi + +# Start PDE if it's deactivated +if [ $(docker ps | grep -c pde) -eq 0 ]; then + pde.sh start +fi + +# Allow 5 seconds for PDE to be coming up +for t in $(seq 1 5) +do + if [ $(docker ps | grep -c pde) -gt 0 ]; then + break + fi + sleep 1 +done +if [ $(docker ps | grep -c pde) -eq 0 ]; then + echo "docker-pde is not alive, existing ..." + exit 1 +fi + +# Launch the benchmark test suite +docker exec -it pde /usr/bin/bench.sh +echo "$(docker exec -it pde cat ${CSV})" > ${CSV} + +echo "" +echo "CSV Report: ${CSV}" +echo "-----------------------------------------------------------------------" +echo "$(cat ${CSV})" +echo "-----------------------------------------------------------------------" + diff --git a/dockers/docker-pde/base_image_files/pde-bench-knet b/dockers/docker-pde/base_image_files/pde-bench-knet new file mode 100644 index 000000000000..cc75962eff35 --- /dev/null +++ b/dockers/docker-pde/base_image_files/pde-bench-knet @@ -0,0 +1,326 @@ +#!/bin/bash + +PLATF_DIR=/usr/share/sonic/platform +HWSKU_DIR=/usr/share/sonic/hwsku +PORT=Ethernet0 +LANE=1 +SPEED=0 +BCMPORT=ce0 +DURATION=5 + +PPS_128=0 +BPS_128=0 +PPS_256=0 +BPS_256=0 +PPS_512=0 +BPS_512=0 +PPS_1024=0 +BPS_1024=0 +PPS_2048=0 +BPS_2048=0 +PPS_4096=0 +BPS_4096=0 +PPS_8192=0 +BPS_8192=0 +PPS_9000=0 +BPS_9000=0 + +# SWSS is mandatory for KNET benchmark +sudo systemctl start swss +for t in $(seq 1 15) +do + if [ $(docker ps | grep -c swss) -gt 0 ]; then + break + fi + sleep 1 +done +if [ $(docker ps | grep -c swss) -eq 0 ]; then + echo "ERR: docker-swss is not alive, existing ..." + exit 1 +fi + +# Find out the PLATFORM and HWSKU +if [ ! -d ${PLATF_DIR} ]; then + name=$(grep 'onie_platform=' /host/machine.conf | cut -d '=' -f 2) + PLATF_DIR=/usr/share/sonic/device/${name} +fi + +if [ ! -d ${HWSKU_DIR} ]; then + name=$(head -1 ${PLATF_DIR}/default_sku | awk '{print $1}') + HWSKU_DIR=${PLATF_DIR}/${name} +fi + +echo "PLATFORM='${PLATF_DIR}'" +echo "HWSKU='${HWSKU_DIR}'" + +# Determine the target port for KNET benchmark +while IFS= read -r line; do + line=$(echo ${line} | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//') + if [[ ${line} = \#* ]]; then + continue + fi + port=$(echo ${line} | awk '{print $1}') + lane=$(echo ${line} | awk '{print $2}' | cut -d ',' -f 1) + speed=$(echo ${line} | awk '{print $5}') + if [ -z "${speed}" ]; then + continue + fi + if [ ${speed} -gt ${SPEED} ]; then + PORT=${port} + LANE=${lane} + SPEED=${speed} + fi +done < ${HWSKU_DIR}/port_config.ini + +echo "PORT=${PORT}" +echo "LANE=${LANE}" +echo "SPEED=${SPEED}" + +# Find out the name of the corresponding bcm port +TEMP=$(mktemp) +bcmcmd 'show pmap' | grep ${LANE} > ${TEMP} +while IFS= read -r line; do + line=$(echo ${line} | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//') + if [ $(echo ${line} | awk '{print $4}') -eq ${LANE} ]; then + BCMPORT=$(echo ${line} | awk '{print $1}') + break + fi +done < ${TEMP} +rm -f ${TEMP} + +echo "BCMPORT=${BCMPORT}" + +# SWSS: Update the LLDP rate limit +TEMP=$(mktemp) +rm -f ${TEMP}.* +docker cp swss:/etc/swss/config.d/00-copp.config.json ${TEMP}.old +if [ ! -f ${TEMP}.old ]; then + echo "Unable to get 00-copp.config.json from docker-swss" +fi + +lldp=0 +while IFS= read -r line +do + if [ $(echo $line | grep -c -E '\"COPP_TABLE:') -gt 0 ]; then + lldp=0 + fi + if [ $(echo $line | grep -c -E 'trap_ids.*,lldp') -gt 0 ]; then + lldp=1 + fi + if [ $lldp -gt 0 ]; then + if [ $(echo $line | grep -c -E '.*\"cir\"') -gt 0 ]; then + echo "${line%:*}:\"30000\"," >> ${TEMP}.new + lldp=$(expr $lldp + 1) + continue + fi + if [ $(echo $line | grep -c -E '.*\"cbs\"') -gt 0 ]; then + echo "${line%:*}:\"30000\"," >> ${TEMP}.new + lldp=$(expr $lldp + 1) + continue + fi + fi + echo "$line" >> ${TEMP}.new +done < "${TEMP}.old" + +csum1=$(md5sum ${TEMP}.old | cut -d ' ' -f 1) +csum2=$(md5sum ${TEMP}.new | cut -d ' ' -f 1) +if [ "${csum1}" != "${csum2}" ]; then + docker cp ${TEMP}.new swss:/etc/swss/config.d/00-copp.config.json + sudo config copp rx-rate 100000 + sudo config save -y + sudo config reload -y +fi + +# Disable ZTP +sudo config ztp disable -y > /dev/null 2>&1 + +# Enable the target port for benchmarking +echo "Allow 15 seconds for ${PORT} getting ready" + +for tick in $(seq 1 15); do + if [ -d /sys/class/net/${PORT} ]; then + break + fi + sleep 1 +done +sudo config interface startup ${PORT} > /dev/null 2>&1 + +# Enable MAC loopback mode to the target port +bcmcmd "port ${BCMPORT} lb=mac" > /dev/null 2>&1 + +# Get started with the loopback benchmark test +# + +# 128B +P1=$(cat /sys/class/net/${PORT}/statistics/rx_packets) +B1=$(cat /sys/class/net/${PORT}/statistics/rx_bytes) +if [ $(docker ps | grep -c pde) -gt 0 ]; then + docker exec -it pde /usr/local/bin/pktsend ${PORT} ${DURATION} 128 +else + /usr/local/bin/pktsend ${PORT} ${DURATION} 128 +fi +P2=$(cat /sys/class/net/${PORT}/statistics/rx_packets) +B2=$(cat /sys/class/net/${PORT}/statistics/rx_bytes) +NUM=$(expr ${P2} - ${P1}) +PPS=$(expr ${NUM} / ${DURATION}) +NUM=$(expr ${B2} - ${B1}) +BPS=$(expr ${NUM} / ${DURATION}) +BPS=$(expr ${BPS} / 1000000) +BPS=$(expr ${BPS} \* 8) +echo "PPS=${PPS}, BPS=${BPS}Mbps" +PPS_128=${PPS} +BPS_128=${BPS} + +# 256B +P1=$(cat /sys/class/net/${PORT}/statistics/rx_packets) +B1=$(cat /sys/class/net/${PORT}/statistics/rx_bytes) +if [ $(docker ps | grep -c pde) -gt 0 ]; then + docker exec -it pde /usr/local/bin/pktsend ${PORT} ${DURATION} 256 +else + /usr/local/bin/pktsend ${PORT} ${DURATION} 256 +fi +P2=$(cat /sys/class/net/${PORT}/statistics/rx_packets) +B2=$(cat /sys/class/net/${PORT}/statistics/rx_bytes) +NUM=$(expr ${P2} - ${P1}) +PPS=$(expr ${NUM} / ${DURATION}) +NUM=$(expr ${B2} - ${B1}) +BPS=$(expr ${NUM} / ${DURATION}) +BPS=$(expr ${BPS} / 1000000) +BPS=$(expr ${BPS} \* 8) +echo "PPS=${PPS}, BPS=${BPS}Mbps" +PPS_256=${PPS} +BPS_256=${BPS} + +# 512B +P1=$(cat /sys/class/net/${PORT}/statistics/rx_packets) +B1=$(cat /sys/class/net/${PORT}/statistics/rx_bytes) +if [ $(docker ps | grep -c pde) -gt 0 ]; then + docker exec -it pde /usr/local/bin/pktsend ${PORT} ${DURATION} 512 +else + /usr/local/bin/pktsend ${PORT} ${DURATION} 512 +fi +P2=$(cat /sys/class/net/${PORT}/statistics/rx_packets) +B2=$(cat /sys/class/net/${PORT}/statistics/rx_bytes) +NUM=$(expr ${P2} - ${P1}) +PPS=$(expr ${NUM} / ${DURATION}) +NUM=$(expr ${B2} - ${B1}) +BPS=$(expr ${NUM} / ${DURATION}) +BPS=$(expr ${BPS} / 1000000) +BPS=$(expr ${BPS} \* 8) +echo "PPS=${PPS}, BPS=${BPS}Mbps" +PPS_512=${PPS} +BPS_512=${BPS} + +# 1024B +P1=$(cat /sys/class/net/${PORT}/statistics/rx_packets) +B1=$(cat /sys/class/net/${PORT}/statistics/rx_bytes) +if [ $(docker ps | grep -c pde) -gt 0 ]; then + docker exec -it pde /usr/local/bin/pktsend ${PORT} ${DURATION} 1024 +else + /usr/local/bin/pktsend ${PORT} ${DURATION} 1024 +fi +P2=$(cat /sys/class/net/${PORT}/statistics/rx_packets) +B2=$(cat /sys/class/net/${PORT}/statistics/rx_bytes) +NUM=$(expr ${P2} - ${P1}) +PPS=$(expr ${NUM} / ${DURATION}) +NUM=$(expr ${B2} - ${B1}) +BPS=$(expr ${NUM} / ${DURATION}) +BPS=$(expr ${BPS} / 1000000) +BPS=$(expr ${BPS} \* 8) +echo "PPS=${PPS}, BPS=${BPS}Mbps" +PPS_1024=${PPS} +BPS_1024=${BPS} + +# 2048B +P1=$(cat /sys/class/net/${PORT}/statistics/rx_packets) +B1=$(cat /sys/class/net/${PORT}/statistics/rx_bytes) +if [ $(docker ps | grep -c pde) -gt 0 ]; then + docker exec -it pde /usr/local/bin/pktsend ${PORT} ${DURATION} 2048 +else + /usr/local/bin/pktsend ${PORT} ${DURATION} 2048 +fi +P2=$(cat /sys/class/net/${PORT}/statistics/rx_packets) +B2=$(cat /sys/class/net/${PORT}/statistics/rx_bytes) +NUM=$(expr ${P2} - ${P1}) +PPS=$(expr ${NUM} / ${DURATION}) +NUM=$(expr ${B2} - ${B1}) +BPS=$(expr ${NUM} / ${DURATION}) +BPS=$(expr ${BPS} / 1000000) +BPS=$(expr ${BPS} \* 8) +echo "PPS=${PPS}, BPS=${BPS}Mbps" +PPS_2048=${PPS} +BPS_2048=${BPS} + +# 4096B +P1=$(cat /sys/class/net/${PORT}/statistics/rx_packets) +B1=$(cat /sys/class/net/${PORT}/statistics/rx_bytes) +if [ $(docker ps | grep -c pde) -gt 0 ]; then + docker exec -it pde /usr/local/bin/pktsend ${PORT} ${DURATION} 4096 +else + /usr/local/bin/pktsend ${PORT} ${DURATION} 4096 +fi +P2=$(cat /sys/class/net/${PORT}/statistics/rx_packets) +B2=$(cat /sys/class/net/${PORT}/statistics/rx_bytes) +NUM=$(expr ${P2} - ${P1}) +PPS=$(expr ${NUM} / ${DURATION}) +NUM=$(expr ${B2} - ${B1}) +BPS=$(expr ${NUM} / ${DURATION}) +BPS=$(expr ${BPS} / 1000000) +BPS=$(expr ${BPS} \* 8) +echo "PPS=${PPS}, BPS=${BPS}Mbps" +PPS_4096=${PPS} +BPS_4096=${BPS} + +# 8192B +P1=$(cat /sys/class/net/${PORT}/statistics/rx_packets) +B1=$(cat /sys/class/net/${PORT}/statistics/rx_bytes) +if [ $(docker ps | grep -c pde) -gt 0 ]; then + docker exec -it pde /usr/local/bin/pktsend ${PORT} ${DURATION} 8192 +else + /usr/local/bin/pktsend ${PORT} ${DURATION} 8192 +fi +P2=$(cat /sys/class/net/${PORT}/statistics/rx_packets) +B2=$(cat /sys/class/net/${PORT}/statistics/rx_bytes) +NUM=$(expr ${P2} - ${P1}) +PPS=$(expr ${NUM} / ${DURATION}) +NUM=$(expr ${B2} - ${B1}) +BPS=$(expr ${NUM} / ${DURATION}) +BPS=$(expr ${BPS} / 1000000) +BPS=$(expr ${BPS} \* 8) +echo "PPS=${PPS}, BPS=${BPS}Mbps" +PPS_8192=${PPS} +BPS_8192=${BPS} + +# 9000B +P1=$(cat /sys/class/net/${PORT}/statistics/rx_packets) +B1=$(cat /sys/class/net/${PORT}/statistics/rx_bytes) +if [ $(docker ps | grep -c pde) -gt 0 ]; then + docker exec -it pde /usr/local/bin/pktsend ${PORT} ${DURATION} 9000 +else + /usr/local/bin/pktsend ${PORT} ${DURATION} 9000 +fi +P2=$(cat /sys/class/net/${PORT}/statistics/rx_packets) +B2=$(cat /sys/class/net/${PORT}/statistics/rx_bytes) +NUM=$(expr ${P2} - ${P1}) +PPS=$(expr ${NUM} / ${DURATION}) +NUM=$(expr ${B2} - ${B1}) +BPS=$(expr ${NUM} / ${DURATION}) +BPS=$(expr ${BPS} / 1000000) +BPS=$(expr ${BPS} \* 8) +echo "PPS=${PPS}, BPS=${BPS}Mbps" +PPS_9000=${PPS} +BPS_9000=${BPS} + +# Disable MAC loopback mode to the target port +bcmcmd "port ${BCMPORT} lb=none" > /dev/null 2>&1 + +# Generate the final report +echo "payload size,loopback pps(Pkt/s),loopback Mbps(Mbit/s)" +echo "128B,${PPS_128},${BPS_128}" +echo "256B,${PPS_256},${BPS_256}" +echo "512B,${PPS_512},${BPS_512}" +echo "1024B,${PPS_1024},${BPS_1024}" +echo "2048B,${PPS_2048},${BPS_2048}" +echo "4096B,${PPS_4096},${BPS_4096}" +echo "8192B,${PPS_8192},${BPS_8192}" +echo "9000B,${PPS_9000},${BPS_9000}" diff --git a/dockers/docker-pde/base_image_files/pde-stress b/dockers/docker-pde/base_image_files/pde-stress new file mode 100644 index 000000000000..4ee4752a8b1e --- /dev/null +++ b/dockers/docker-pde/base_image_files/pde-stress @@ -0,0 +1,27 @@ +#!/bin/bash + +# Make sure only root can run our script +if [ "$(id -u)" != "0" ]; then + echo "This script must be run as root" 1>&2 + exit 1 +fi + +# Start PDE if it's deactivated +if [ $(docker ps | grep -c pde) -eq 0 ]; then + pde.sh start +fi + +# Allow 5 seconds for PDE to be coming up +for t in $(seq 1 5) +do + if [ $(docker ps | grep -c pde) -gt 0 ]; then + break + fi +done +if [ $(docker ps | grep -c pde) -eq 0 ]; then + echo "docker-pde is not alive, existing ..." + exit 1 +fi + +# Now launch the PDE stress test +docker exec -it pde /home/pde/stress-sfp-i2c.py $* diff --git a/dockers/docker-pde/base_image_files/pde-test b/dockers/docker-pde/base_image_files/pde-test new file mode 100644 index 000000000000..046a9f067480 --- /dev/null +++ b/dockers/docker-pde/base_image_files/pde-test @@ -0,0 +1,59 @@ +#!/bin/bash + +# Make sure only root can run our script +if [ "$(id -u)" != "0" ]; then + echo "This script must be run as root" 1>&2 + exit 1 +fi + +# Make sure SWSS is deactivated +if [ $(docker ps | grep -c swss) -ne 0 ]; then + systemctl stop swss + sleep 3 +fi + +# Start PDE if it's deactivated +if [ $(docker ps | grep -c pde) -eq 0 ]; then + pde.sh start +fi + +# Allow 5 seconds for PDE to be coming up +for t in $(seq 1 5) +do + if [ $(docker ps | grep -c pde) -gt 0 ]; then + break + fi +done +if [ $(docker ps | grep -c pde) -eq 0 ]; then + echo "docker-pde is not alive, existing ..." + exit 1 +fi + +usage() +{ + echo "usage: $0 " + exit 1 +} + +if [ $# -lt 1 ] +then + usage +fi + +case $1 in +-h | help) + usage + ;; +-l | ls | list) + docker exec -it -w /usr/local/sonic_pde_tests pde ls + exit 0 + ;; +*) + ;; +esac + +# Now launch the PDE pytest +docker exec -it -w /usr/local/sonic_pde_tests pde pytest $* + +# Reactivate the SWSS +systemctl start swss diff --git a/dockers/docker-pde/bench.sh b/dockers/docker-pde/bench.sh new file mode 100644 index 000000000000..2a0951490918 --- /dev/null +++ b/dockers/docker-pde/bench.sh @@ -0,0 +1,140 @@ +#!/bin/bash + +CSV=/tmp/bench.csv + +TST_FREQ=2000 +TST_CORE=4 +TST_RAMSZ=8 +TST_DISKSZ=14 +TST_SHA=10 +TST_BZ2=30 +TST_AES=5 +TST_DISKRD=180 +TST_DISKWR=30 + +cpu_benchmark() +{ + export TIMEFORMAT='%1R' + (time dd if=/dev/zero bs=1M count=500 2> /dev/null | \ + "$@" > /dev/null ) 2>&1 +} + +# Platform Info +PLATFORM=$(grep 'onie_platform=' /host/machine.conf | cut -d '=' -f 2) +echo "Platform: ${PLATFORM}" + +if [ -d /usr/share/sonic/platform ]; then + HWSKU=$(head -1 /usr/share/sonic/platform/default_sku | awk '{print $1}') +else + HWSKU=$(head -1 /usr/share/sonic/device/${PLATFORM}/default_sku | awk '{print $1}') +fi +echo "HWSKU: ${HWSKU}" + +REVISION=$(syseeprom.py 0x27) +echo "Revision: ${REVISION}" + +# Basic Info +CPU_NAME=$(awk -F: '/model name/ {name=$2} END {print name}' /proc/cpuinfo | cut -d '@' -f 1 | sed 's/^[ \t]*//;s/[ \t]*$//') +echo "CPU NAME: ${CPU_NAME}" + +if [ $(lscpu | grep -c 'CPU max MHz') -gt 0 ]; then + CPU_FREQ=$(lscpu | grep 'CPU max MHz' | cut -d ':' -f 2 | cut -d '.' -f 1 | sed 's/^[[:space:]]*//') +else + CPU_FREQ=$(lscpu | grep 'CPU MHz' | cut -d ':' -f 2 | cut -d '.' -f 1 | sed 's/^[[:space:]]*//') +fi +echo -n "CPU FREQ: ${CPU_FREQ} MHz ........" +if [ ${CPU_FREQ} -ge ${TST_FREQ} ]; then + echo "pass" +else + echo "FAIL" +fi + +CPU_CORE=$(awk -F: '/model name/ {core++} END {print core}' /proc/cpuinfo) +echo -n "CPU CORE: ${CPU_CORE} ..............." +if [ ${CPU_CORE} -ge ${TST_CORE} ]; then + echo "pass" +else + echo "FAIL" +fi + +RAM_SIZE=$(grep MemTotal /proc/meminfo | awk '{print $2}') +RAM_SIZE=$(expr ${RAM_SIZE} / 1024) # MB +RAM_SIZE=$(expr ${RAM_SIZE} + 1023) +RAM_SIZE=$(expr ${RAM_SIZE} / 1024) # GB +echo -n "RAM SIZE: ${RAM_SIZE} GB ..........." +if [ ${RAM_SIZE} -ge ${TST_RAMSZ} ]; then + echo "pass" +else + echo "FAIL" +fi + +DISK_SIZE=$(lsblk -d | grep disk | head -1 | awk '{print $4}' | cut -d 'G' -f 1) +echo -n "DISK: ${DISK_SIZE} GB ..........." +if [ $(expr ${DISK_SIZE} \>= ${TST_DISKSZ}) -eq 1 ]; then + echo "pass" +else + echo "FAIL" +fi + +# CPU tests +SHA_TIME=$(cpu_benchmark sha256sum) +echo -n "SHA256: ${SHA_TIME} sec ........." +if [ $(echo "${SHA_TIME} <= ${TST_SHA}" | bc) -eq 1 ]; then + echo "pass" +else + echo "FAIL" +fi + +BZ2_TIME=$(cpu_benchmark bzip2) +echo -n "BZIP2: ${BZ2_TIME} sec ........." +if [ $(echo "${BZ2_TIME} <= ${TST_BZ2}" | bc) -eq 1 ]; then + echo "pass" +else + echo "FAIL" +fi + +AES_TIME=$(cpu_benchmark openssl enc -e -aes-256-cbc -pass pass:12345678 | sed '/^\*\*\* WARNING : deprecated key derivation used\.$/d;/^Using -iter or -pbkdf2 would be better\.$/d') +echo -n "AES256: ${AES_TIME} sec ........." +if [ $(echo "${AES_TIME} <= ${TST_AES}" | bc) -eq 1 ]; then + echo "pass" +else + echo "FAIL" +fi + +# Disk tests +DISK_RD=$(ioping -DRL -w 5 ./ | tail -n 2 | head -n 1 | cut -d ',' -f 4 | awk '{print $1}') +echo -n "DISK READ: ${DISK_RD} MB/s ......" +if [ $(echo "${DISK_RD} >= ${TST_DISKRD}" | bc) -eq 1 ]; then + echo "pass" +else + echo "FAIL" +fi + +rm -f dummy.bin +DISK_WR=$(dd if=/dev/zero of=dummy.bin bs=64k count=16k conv=fdatasync 2>&1 | tail -1 | awk '{print $10}') +rm -f dummy.bin +echo -n "DISK WRITE: ${DISK_WR} MB/s ......." +if [ $(echo "${DISK_WR} >= ${TST_DISKWR}" | bc) -eq 1 ]; then + echo "pass" +else + echo "FAIL" +fi + +# Report +rm -f ${CSV} +echo "Platform,HwSKU,Revision,Processor,CPU cores,Frequency(MHz),RAM(G),Disk(G),SHA256(s),bzip2(s),AES(s),sequential read(MiB/s),sequential write(MiB/s)," >> ${CSV} + +echo -n "${PLATFORM}," >> ${CSV} +echo -n "${HWSKU}," >> ${CSV} +echo -n "${REVISION}," >> ${CSV} +echo -n "${CPU_NAME}," >> ${CSV} +echo -n "${CPU_CORE}," >> ${CSV} +echo -n "${CPU_FREQ}," >> ${CSV} +echo -n "${RAM_SIZE}," >> ${CSV} +echo -n "${DISK_SIZE}," >> ${CSV} +echo -n "${SHA_TIME}," >> ${CSV} +echo -n "${BZ2_TIME}," >> ${CSV} +echo -n "${AES_TIME}," >> ${CSV} +echo -n "${DISK_RD}," >> ${CSV} +echo -n "${DISK_WR}," >> ${CSV} +echo "" >> ${CSV} diff --git a/dockers/docker-pde/docker_init.sh b/dockers/docker-pde/docker_init.sh new file mode 100644 index 000000000000..6e83fdd98aae --- /dev/null +++ b/dockers/docker-pde/docker_init.sh @@ -0,0 +1,45 @@ +#!/usr/bin/env bash + +set -x + +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 +} + +PLATFORM_DIR=/usr/share/sonic/platform +HWSKU_DIR=/usr/share/sonic/hwsku + +mkdir -p /etc/sai.d/ + +if [ -f $HWSKU_DIR/sai.profile ]; then + cp $HWSKU_DIR/sai.profile /etc/sai.d/sai.profile +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 [ $? -ne 0 ]; then + SONIC_PLATFORM_WHEEL="/usr/share/sonic/platform/sonic_platform-1.0-py2-none-any.whl" + echo "sonic-platform package not installed, attempting to install..." + if [ -e ${SONIC_PLATFORM_WHEEL} ]; then + pip install ${SONIC_PLATFORM_WHEEL} + if [ $? -eq 0 ]; then + echo "Successfully installed ${SONIC_PLATFORM_WHEEL}" + else + echo "Error: Failed to install ${SONIC_PLATFORM_WHEEL}" + fi + else + echo "Error: Unable to locate ${SONIC_PLATFORM_WHEEL}" + fi +fi + +start_bcm + +exec /usr/bin/supervisord + + diff --git a/dockers/docker-pde/stress-sfp-i2c.py b/dockers/docker-pde/stress-sfp-i2c.py new file mode 100644 index 000000000000..08247767e2e7 --- /dev/null +++ b/dockers/docker-pde/stress-sfp-i2c.py @@ -0,0 +1,157 @@ +#!/usr/bin/env python + +try: + import os + import sys + import subprocess + import time + import imp + from natsort import natsorted +except ImportError as e: + raise ImportError("%s - required module not found" % str(e)) + +HWSKU_PATH = "/usr/share/sonic/hwsku" +PLATFORM_PATH = "/usr/share/sonic/platform" + +PLATFORM_SPECIFIC_MODULE_NAME = 'sfputil' +PLATFORM_SPECIFIC_CLASS_NAME = 'SfpUtil' + +XCVR_EEPROM_TYPE_UNKNOWN = 0 +XCVR_EEPROM_TYPE_SFP = 1 +XCVR_EEPROM_TYPE_QSFP = 2 +XCVR_EEPROM_TYPE_QSFPDD = 3 +XCVR_EEPROM_TYPE_OSFP = XCVR_EEPROM_TYPE_QSFPDD + +OSFP_TYPE_ID = "18" + +# Global platform-specific sfputil class instance +platform_sfputil = None + +# Global port dictionaries +port_dict = None + +# Loads platform specific sfputil module from source +def load_platform_sfputil(): + global platform_sfputil + + if platform_sfputil is not None: + return + + try: + module_file = "/".join([PLATFORM_PATH, "plugins", PLATFORM_SPECIFIC_MODULE_NAME + ".py"]) + module = imp.load_source(PLATFORM_SPECIFIC_MODULE_NAME, module_file) + except IOError, e: + print("Failed to load platform module '%s': %s" % (PLATFORM_SPECIFIC_MODULE_NAME, str(e)), True) + + assert module is not None + + try: + platform_sfputil_class = getattr(module, PLATFORM_SPECIFIC_CLASS_NAME) + platform_sfputil = platform_sfputil_class() + except AttributeError, e: + print("Failed to instantiate '%s' class: %s" % (PLATFORM_SPECIFIC_CLASS_NAME, str(e)), True) + + assert platform_sfputil is not None + return + +# Loads platform port dictionaries +def load_platform_portdict(): + global port_dict + + if port_dict is not None: + return + + port_dict = {} + idx = 0 + file = open(HWSKU_PATH + "/port_config.ini", "r") + line = file.readline() + while line is not None and len(line) > 0: + line = line.strip() + if line.startswith("#"): + line = file.readline() + continue + list = line.split() + if len(list) >= 4: + idx = int(list[3]) + port_dict[list[0]] = { "index": str(idx) } + idx += 1 + line = file.readline() + + return port_dict + +def get_sfp_eeprom_type(port, data): + type = XCVR_EEPROM_TYPE_UNKNOWN + + if (port in platform_sfputil.osfp_ports) or (port in platform_sfputil.qsfp_ports): + if data is None: + return type + + if data[0] in OSFP_TYPE_ID: + code = 0 + for i in range(128, 222): + code += int(data[i], 16) + if (code & 0xff) == int(data[222], 16): + type = XCVR_EEPROM_TYPE_OSFP + else: + type = XCVR_EEPROM_TYPE_QSFP + else: + type = XCVR_EEPROM_TYPE_QSFP + else: + type = XCVR_EEPROM_TYPE_SFP + + return type + +# Test for SFP EEPROM +def stress_sfp_i2c_one(): + load_platform_sfputil() + load_platform_portdict() + num_sfp = 0 + for intf in natsorted(port_dict.keys()): + port = int(port_dict[intf]['index']) + if not platform_sfputil._is_valid_port(port): + continue + if platform_sfputil.get_presence(port): + num_sfp += 1 + + assert num_sfp >= 2, "2 or more SFP modules should be attached for this test" + + for intf in natsorted(port_dict.keys()): + port = int(port_dict[intf]['index']) + if not platform_sfputil._is_valid_port(port): + continue + if not platform_sfputil.get_presence(port): + continue + + data = platform_sfputil.get_eeprom_raw(port, 256) + assert data is not None, "SFP{}: unable to read EEPROM".format(port) + + code = 0 + type = get_sfp_eeprom_type(port, data) + if type == XCVR_EEPROM_TYPE_QSFPDD: + for i in range(128, 222): + code += int(data[i], 16) + assert (code & 0xff) == int(data[222], 16), "{}: check code error".format(intf) + elif type == XCVR_EEPROM_TYPE_QSFP: + for i in range(128, 191): + code += int(data[i], 16) + assert (code & 0xff) == int(data[191], 16), "{}: check code error".format(intf) + else: + for i in range(0, 63): + code += int(data[i], 16) + assert (code & 0xff) == int(data[63], 16), "{}: check code error".format(intf) + +def stress_sfp_i2c(sec=180): + print("Initiating {} seconds SFP I2C stress test...".format(sec)) + timeout = time.time() + sec + while timeout >= time.time(): + stress_sfp_i2c_one() + sys.stdout.write("#") + sys.stdout.flush() + print("\nPASS") + +if __name__ == '__main__': + sec = 180 + if len(sys.argv) >= 2: + sec = int(sys.argv[1]) + stress_sfp_i2c(sec) + diff --git a/dockers/docker-pde/supervisord.conf b/dockers/docker-pde/supervisord.conf new file mode 100644 index 000000000000..58a32d833163 --- /dev/null +++ b/dockers/docker-pde/supervisord.conf @@ -0,0 +1,12 @@ +[supervisord] +logfile_maxbytes=1MB +logfile_backups=2 +nodaemon=true + +[program:rsyslogd] +command=/bin/bash -c "rm -f /var/run/rsyslogd.pid && /usr/sbin/rsyslogd -n" +priority=1 +autostart=true +autorestart=false +stdout_logfile=syslog +stderr_logfile=syslog diff --git a/dockers/docker-pde/syseeprom.py b/dockers/docker-pde/syseeprom.py new file mode 100644 index 000000000000..d6444b8352b3 --- /dev/null +++ b/dockers/docker-pde/syseeprom.py @@ -0,0 +1,67 @@ +#!/usr/bin/python + +import sys +import imp +import subprocess +import time + +PLATFORM_SPECIFIC_MODULE_NAME = "eeprom" +PLATFORM_SPECIFIC_CLASS_NAME = "board" + +platform_eeprom = None +platform_eeprom_data = None + +# Returns path to platform and hwsku +def get_path_to_platform_and_hwsku(): + platform_path = '/usr/share/sonic/platform' + hwsku_path = '/usr/share/sonic/hwsku' + return (platform_path, hwsku_path) + +# Loads platform specific psuutil module from source +def load_platform_util(module_name, class_name): + platform_util = None + + # Get path to platform and hwsku + (platform_path, hwsku_path) = get_path_to_platform_and_hwsku() + + try: + module_file = "/".join([platform_path, "plugins", module_name + ".py"]) + module = imp.load_source(module_name, module_file) + except IOError, e: + assert False, ("Failed to load platform module '%s': %s" % (module_name, str(e))) + + try: + platform_util_class = getattr(module, class_name) + # board class of eeprom requires 4 paramerters, need special treatment here. + platform_util = platform_util_class('','','','') + except AttributeError, e: + assert False, ("Failed to instantiate '%s' class: %s" % (class_name, str(e))) + + return platform_util + +def init_platform_eeprom(): + global platform_eeprom + global platform_eeprom_data + + if platform_eeprom is None: + platform_eeprom = load_platform_util(PLATFORM_SPECIFIC_MODULE_NAME, \ + PLATFORM_SPECIFIC_CLASS_NAME) + if platform_eeprom_data is None: + platform_eeprom_data = platform_eeprom.read_eeprom() + + return platform_eeprom_data + +def main(): + e = init_platform_eeprom() + c = platform_eeprom._TLV_CODE_PLATFORM_NAME + if len(sys.argv) > 1: + c = int(sys.argv[1], 0) + v, t = platform_eeprom.get_tlv_field(e, c) + if v: + print(t[2]) + else: + print("Unknown") + +if __name__ == '__main__': + main() + diff --git a/files/build_templates/docker_image_ctl.j2 b/files/build_templates/docker_image_ctl.j2 index 7b4f91f3d5d0..f85b0721d5da 100644 --- a/files/build_templates/docker_image_ctl.j2 +++ b/files/build_templates/docker_image_ctl.j2 @@ -93,6 +93,16 @@ function preStartAction() docker cp /tmp/dump.rdb database$DEV:/var/lib/redis/ fi fi +{%- elif docker_container_name == "pde" %} + if [[ $(/bin/systemctl status swss | grep -c running) -gt 0 ]]; then + echo "Stopping SWSS before starting PDE" + systemctl stop swss + fi + + if [[ $(/bin/systemctl status watchdog-control.service | grep -c running) -gt 0 ]]; then + echo "Stopping watchdog-control.service before starting PDE" + systemctl stop watchdog-control.service + fi {%- elif docker_container_name == "snmp" %} $SONIC_DB_CLI STATE_DB HSET 'DEVICE_METADATA|localhost' chassis_serial_number $(decode-syseeprom -s) {%- else %} diff --git a/files/build_templates/pde.service.j2 b/files/build_templates/pde.service.j2 new file mode 100644 index 000000000000..f053b57ad576 --- /dev/null +++ b/files/build_templates/pde.service.j2 @@ -0,0 +1,22 @@ +[Unit] +Description=PDE container +{% if sonic_asic_platform == 'broadcom' %} +Requires=opennsl-modules.service +ConditionPathExists=!/usr/bin/swss.sh +{% endif %} + +After=updategraph.service +{% if sonic_asic_platform == 'broadcom' %} +After=opennsl-modules.service +{% endif %} + +Before= + +[Service] +User={{ sonicadmin_user }} +ExecStartPre=/usr/bin/{{ docker_container_name }}.sh start +ExecStart=/usr/bin/{{ docker_container_name }}.sh wait +ExecStop=/usr/bin/{{ docker_container_name }}.sh stop + +[Install] +WantedBy=multi-user.target diff --git a/platform/broadcom/docker-pde.dep b/platform/broadcom/docker-pde.dep new file mode 100644 index 000000000000..bc7eb8225808 --- /dev/null +++ b/platform/broadcom/docker-pde.dep @@ -0,0 +1,12 @@ + +DPATH := $($(DOCKER_PDE)_PATH) +DEP_FILES := $(SONIC_COMMON_FILES_LIST) platform/broadcom/docker-pde.mk platform/broadcom/docker-pde.dep +DEP_FILES += $(SONIC_COMMON_BASE_FILES_LIST) +DEP_FILES += $(SONIC_COMMON_DOCKER_FILES_LIST) +DEP_FILES += $(shell git ls-files $(DPATH)) + +$(DOCKER_PDE)_CACHE_MODE := GIT_CONTENT_SHA +$(DOCKER_PDE)_DEP_FLAGS := $(SONIC_COMMON_FLAGS_LIST) +$(DOCKER_PDE)_DEP_FILES := $(DEP_FILES) + +$(eval $(call add_dbg_docker,$(DOCKER_PDE),$(DOCKER_PDE_DBG))) diff --git a/platform/broadcom/docker-pde.mk b/platform/broadcom/docker-pde.mk new file mode 100644 index 000000000000..aba1a5a356e4 --- /dev/null +++ b/platform/broadcom/docker-pde.mk @@ -0,0 +1,52 @@ +# Docker image for SONiC Platform Development Environment (PDE) + + +ifeq ($(ENABLE_PDE), y) + +DOCKER_PDE_STEM = docker-pde +DOCKER_PDE = $(DOCKER_PDE_STEM).gz +DOCKER_PDE_DBG = $(DOCKER_PDE_STEM)-$(DBG_IMAGE_MARK).gz + +$(DOCKER_PDE)_PATH = $(DOCKERS_PATH)/$(DOCKER_PDE_STEM) + +$(DOCKER_PDE)_DEPENDS += $(PYTHON_NETIFACES) +$(DOCKER_PDE)_DEPENDS += $(SONIC_PLATFORM_PDE) $(BRCM_SAI) +$(DOCKER_PDE_RDEPENDS += $(PYTHON_NETIFACES) + +$(DOCKER_PDE)_PYTHON_DEBS += $(SONIC_UTILS) +$(DOCKER_PDE)_PYTHON_WHEELS += $(SONIC_PLATFORM_COMMON_PY3) +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) + + +SONIC_DOCKER_IMAGES += $(DOCKER_PDE) +SONIC_BUSTER_DOCKERS += $(DOCKER_PDE) +SONIC_INSTALL_DOCKER_IMAGES += $(DOCKER_PDE) +SONIC_BUSTER_DBG_DOCKERS += $(DOCKER_PDE_DBG) +SONIC_DOCKER_DBG_IMAGES += $(DOCKER_PDE_DBG) +SONIC_INSTALL_DOCKER_DBG_IMAGES += $(DOCKER_PDE_DBG) + +$(DOCKER_PDE)_CONTAINER_NAME = pde +$(DOCKER_PDE)_RUN_OPT += --net=host --privileged -t +$(DOCKER_PDE)_RUN_OPT += -v /etc/sonic:/etc/sonic:ro +$(DOCKER_PDE)_RUN_OPT += -v /host/machine.conf:/host/machine.conf:ro +$(DOCKER_PDE)_RUN_OPT += -v /usr/lib/python2.7/dist-packages:/usr/share/sonic/classes:ro +$(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 /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)_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 +$(DOCKER_PDE)_BASE_IMAGE_FILES += pde-bench-knet:/usr/local/bin/pde-bench-knet + +endif diff --git a/platform/broadcom/one-pde-image.mk b/platform/broadcom/one-pde-image.mk new file mode 100644 index 000000000000..e8b2629c49a6 --- /dev/null +++ b/platform/broadcom/one-pde-image.mk @@ -0,0 +1,81 @@ +# sonic broadcom one image installer + +SONIC_ONE_PDE_IMAGE = sonic-broadcom-pde.bin +$(SONIC_ONE_PDE_IMAGE)_MACHINE = broadcom +$(SONIC_ONE_PDE_IMAGE)_IMAGE_TYPE = onie +$(SONIC_ONE_PDE_IMAGE)_INSTALLS += $(BRCM_OPENNSL_KERNEL) +$(SONIC_ONE_PDE_IMAGE)_INSTALLS += $(PDDF_PLATFORM_MODULE) +$(SONIC_ONE_PDE_IMAGE)_LAZY_INSTALLS += $(DELL_S6000_PLATFORM_MODULE) \ + $(DELL_Z9332F_PLATFORM_MODULE) \ + $(DELL_Z9264F_PLATFORM_MODULE) \ + $(DELL_S5212F_PLATFORM_MODULE) \ + $(DELL_S5232F_PLATFORM_MODULE) \ + $(DELL_S5248F_PLATFORM_MODULE) \ + $(DELL_S5296F_PLATFORM_MODULE) \ + $(DELL_Z9100_PLATFORM_MODULE) \ + $(DELL_S6100_PLATFORM_MODULE) \ + $(DELL_S3000_PLATFORM_MODULE) \ + $(DELL_N3248TE_PLATFORM_MODULE) \ + $(DELL_S5224F_PLATFORM_MODULE) \ + $(DELL_Z9432F_PLATFORM_MODULE) \ + $(INGRASYS_S8900_54XC_PLATFORM_MODULE) \ + $(INGRASYS_S8900_64XC_PLATFORM_MODULE) \ + $(INGRASYS_S9100_PLATFORM_MODULE) \ + $(INGRASYS_S8810_32Q_PLATFORM_MODULE) \ + $(INGRASYS_S9200_64X_PLATFORM_MODULE) \ + $(ACCTON_AS7712_32X_PLATFORM_MODULE) \ + $(ACCTON_AS5712_54X_PLATFORM_MODULE) \ + $(ACCTON_AS7816_64X_PLATFORM_MODULE) \ + $(ACCTON_AS7716_32X_PLATFORM_MODULE) \ + $(ACCTON_AS7312_54X_PLATFORM_MODULE) \ + $(ACCTON_AS7326_56X_PLATFORM_MODULE) \ + $(ACCTON_AS7716_32XB_PLATFORM_MODULE) \ + $(ACCTON_AS6712_32X_PLATFORM_MODULE) \ + $(ACCTON_AS7726_32X_PLATFORM_MODULE) \ + $(ACCTON_AS4630_54PE_PLATFORM_MODULE) \ + $(ACCTON_MINIPACK_PLATFORM_MODULE) \ + $(ACCTON_AS5812_54X_PLATFORM_MODULE) \ + $(ACCTON_AS5812_54T_PLATFORM_MODULE) \ + $(ACCTON_AS5835_54X_PLATFORM_MODULE) \ + $(ACCTON_AS9716_32D_PLATFORM_MODULE) \ + $(ACCTON_AS5835_54T_PLATFORM_MODULE) \ + $(ACCTON_AS7312_54XS_PLATFORM_MODULE) \ + $(ACCTON_AS7315_27XB_PLATFORM_MODULE) \ + $(INVENTEC_D7032Q28B_PLATFORM_MODULE) \ + $(INVENTEC_D7054Q28B_PLATFORM_MODULE) \ + $(INVENTEC_D7264Q28B_PLATFORM_MODULE) \ + $(INVENTEC_D7264_PLATFORM_MODULE) \ + $(INVENTEC_D6356_PLATFORM_MODULE) \ + $(INVENTEC_D6356J_PLATFORM_MODULE) \ + $(INVENTEC_D6332_PLATFORM_MODULE) \ + $(INVENTEC_D7332_PLATFORM_MODULE) \ + $(CEL_DX010_PLATFORM_MODULE) \ + $(CEL_HALIBURTON_PLATFORM_MODULE) \ + $(DELTA_AG9032V1_PLATFORM_MODULE) \ + $(DELTA_AG9064_PLATFORM_MODULE) \ + $(DELTA_AG5648_PLATFORM_MODULE) \ + $(DELTA_ET6248BRB_PLATFORM_MODULE) \ + $(QUANTA_IX1B_32X_PLATFORM_MODULE) \ + $(QUANTA_IX4_64X_PLATFORM_MODULE) \ + $(QUANTA_IX7_32X_PLATFORM_MODULE) \ + $(QUANTA_IX7_BWDE_32X_PLATFORM_MODULE) \ + $(QUANTA_IX7T_32X_PLATFORM_MODULE) \ + $(QUANTA_IX8_56X_PLATFORM_MODULE) \ + $(QUANTA_IX8C_56X_PLATFORM_MODULE) \ + $(QUANTA_IX8A_BWDE_56X_PLATFORM_MODULE) \ + $(QUANTA_IX8F_56X_PLATFORM_MODULE) \ + $(QUANTA_IX8T_56X_PLATFORM_MODULE) \ + $(QUANTA_IX9_32X_PLATFORM_MODULE) \ + $(MITAC_LY1200_32X_PLATFORM_MODULE) \ + $(ALPHANETWORKS_SNH60A0_320FV2_PLATFORM_MODULE) \ + $(ALPHANETWORKS_SNH60B0_640F_PLATFORM_MODULE) \ + $(ALPHANETWORKS_SNJ60B0_320F_PLATFORM_MODULE) \ + $(ALPHANETWORKS_SNJ61D0_320F_PLATFORM_MODULE) \ + $(BRCM_XLR_GTS_PLATFORM_MODULE) \ + $(DELTA_AG9032V2A_PLATFORM_MODULE) \ + $(JUNIPER_QFX5210_PLATFORM_MODULE) \ + $(CEL_SILVERSTONE_PLATFORM_MODULE) \ + $(CEL_SILVERSTONE-DP_PLATFORM_MODULE) + +$(SONIC_ONE_PDE_IMAGE)_DOCKERS += $(DOCKER_PDE) $(DOCKER_PLATFORM_MONITOR) $(DOCKER_DATABASE) +SONIC_INSTALLERS += $(SONIC_ONE_PDE_IMAGE) diff --git a/platform/broadcom/sonic-pde-tests.dep b/platform/broadcom/sonic-pde-tests.dep new file mode 100644 index 000000000000..40b99496c14d --- /dev/null +++ b/platform/broadcom/sonic-pde-tests.dep @@ -0,0 +1,12 @@ + +SPATH := $($(SONIC_PLATFORM_PDE)_SRC_PATH) +DEP_FILES := $(SONIC_COMMON_FILES_LIST) platform/broadcom/sonic-pde-tests.mk platform/broadcom/sonic-pde-tests.dep +DEP_FILES += $(SONIC_COMMON_BASE_FILES_LIST) +SMDEP_FILES := $(addprefix $(SPATH)/,$(shell cd $(SPATH) && git ls-files)) + +$(SONIC_PLATFORM_PDE)_CACHE_MODE := GIT_CONTENT_SHA +$(SONIC_PLATFORM_PDE)_DEP_FLAGS := $(SONIC_COMMON_FLAGS_LIST) +$(SONIC_PLATFORM_PDE)_DEP_FILES := $(DEP_FILES) +$(SONIC_PLATFORM_PDE)_SMDEP_FILES := $(SMDEP_FILES) +$(SONIC_PLATFORM_PDE)_SMDEP_PATHS := $(SPATH) + diff --git a/platform/broadcom/sonic-pde-tests.mk b/platform/broadcom/sonic-pde-tests.mk new file mode 100644 index 000000000000..a7482625c87e --- /dev/null +++ b/platform/broadcom/sonic-pde-tests.mk @@ -0,0 +1,7 @@ +# sonic pde package + +SONIC_PLATFORM_PDE = sonic-platform-pde_1.0_amd64.deb +$(SONIC_PLATFORM_PDE)_SRC_PATH = $(SRC_PATH)/sonic-platform-pde +$(SONIC_PLATFORM_PDE)_DEPENDS += $(BRCM_SAI) $(BRCM_SAI_DEV) $(SWIG) + +SONIC_DPKG_DEBS += $(SONIC_PLATFORM_PDE) diff --git a/rules/config b/rules/config index 3af8e706e0f7..5f170f810b58 100644 --- a/rules/config +++ b/rules/config @@ -51,6 +51,8 @@ DEFAULT_PASSWORD = YourPaSsWoRd # ENABLE_ZTP - installs Zero Touch Provisioning support. # ENABLE_ZTP = y +# ENABLE_PDE - Enable platform development enviroment +ENABLE_PDE = y # SHUTDOWN_BGP_ON_START - if set to y all bgp sessions will be in admin down state when # bgp service starts. # SHUTDOWN_BGP_ON_START = y diff --git a/slave.mk b/slave.mk index c35f62cb90ff..1a9ca8b6e73f 100644 --- a/slave.mk +++ b/slave.mk @@ -241,6 +241,7 @@ $(info "HTTP_PROXY" : "$(HTTP_PROXY)") $(info "HTTPS_PROXY" : "$(HTTPS_PROXY)") $(info "NO_PROXY" : "$(NO_PROXY)") $(info "ENABLE_ZTP" : "$(ENABLE_ZTP)") +$(info "ENABLE_PDE" : "$(ENABLE_PDE)") $(info "SONIC_DEBUGGING_ON" : "$(SONIC_DEBUGGING_ON)") $(info "SONIC_PROFILING_ON" : "$(SONIC_PROFILING_ON)") $(info "KERNEL_PROCURE_METHOD" : "$(KERNEL_PROCURE_METHOD)") @@ -921,6 +922,7 @@ $(addprefix $(TARGET_PATH)/, $(SONIC_INSTALLERS)) : $(TARGET_PATH)/% : \ export include_mgmt_framework="$(INCLUDE_MGMT_FRAMEWORK)" export include_iccpd="$(INCLUDE_ICCPD)" export pddf_support="$(PDDF_SUPPORT)" + export enable_pde="$(ENABLE_PDE)" export shutdown_bgp_on_start="$(SHUTDOWN_BGP_ON_START)" export default_buffer_model="$(SONIC_BUFFER_MODEL)" export include_kubernetes="$(INCLUDE_KUBERNETES)" @@ -1030,6 +1032,8 @@ $(addprefix $(TARGET_PATH)/, $(SONIC_INSTALLERS)) : $(TARGET_PATH)/% : \ DEBUG_IMG="$(INSTALL_DEBUG_TOOLS)" \ DEBUG_SRC_ARCHIVE_FILE="$(DBG_SRC_ARCHIVE_FILE)" \ + ARTIFACTORY_URL="$(ARTIFACTORY_URL)" \ + BUILD_TARGET="$@" \ USERNAME="$(USERNAME)" \ PASSWORD="$(PASSWORD)" \ IMAGE_TYPE=$($*_IMAGE_TYPE) \ @@ -1044,6 +1048,7 @@ $(addprefix $(TARGET_PATH)/, $(SONIC_INSTALLERS)) : $(TARGET_PATH)/% : \ PASSWORD="$(PASSWORD)" \ TARGET_MACHINE=$($*_MACHINE) \ IMAGE_TYPE=$($*_IMAGE_TYPE) \ + BUILD_TARGET="$@" \ SONIC_ENABLE_IMAGE_SIGNATURE="$(SONIC_ENABLE_IMAGE_SIGNATURE)" \ SIGNING_KEY="$(SIGNING_KEY)" \ SIGNING_CERT="$(SIGNING_CERT)" \ From f4bfad2586c084cd062b419ee85c69bc0dfa2c51 Mon Sep 17 00:00:00 2001 From: Geans Pin Date: Mon, 3 May 2021 17:07:58 -0700 Subject: [PATCH 08/28] Initial commit for introducing the SONiC Platform Development Env (Resubmit PR#3778) Rebase latest and Resubmit to fix conflict --- Makefile.work | 1 + dockers/docker-pde/Dockerfile.j2 | 2 ++ platform/broadcom/docker-pde.mk | 10 ---------- 3 files changed, 3 insertions(+), 10 deletions(-) diff --git a/Makefile.work b/Makefile.work index a42855a8b4f1..3cdcbd36fca7 100644 --- a/Makefile.work +++ b/Makefile.work @@ -362,6 +362,7 @@ initpde: git submodule update --init --recursive $$submodule ; \ done @git submodule foreach --recursive '[ -f .git ] && echo "gitdir: $$(realpath --relative-to=. $$(cut -d" " -f2 .git))" > .git' + init : @git submodule update --init --recursive @git submodule foreach --recursive '[ -f .git ] && echo "gitdir: $$(realpath --relative-to=. $$(cut -d" " -f2 .git))" > .git' diff --git a/dockers/docker-pde/Dockerfile.j2 b/dockers/docker-pde/Dockerfile.j2 index 4486bcc812fa..4c37f8d45fbf 100644 --- a/dockers/docker-pde/Dockerfile.j2 +++ b/dockers/docker-pde/Dockerfile.j2 @@ -24,6 +24,7 @@ RUN apt-get install -y python-jsonschema RUN pip3 install pytest pexpect + {% if docker_pde_debs.strip() -%} # Copy locally-built Debian package dependencies COPY \ @@ -62,6 +63,7 @@ python-wheels/{{ whl }}{{' '}} # Install locally-built Python wheel dependencies RUN pip3 install \ + {% for whl in docker_pde_whls.split(' ') -%} /python-wheels/{{ whl }}{{' '}} {%- endfor %} diff --git a/platform/broadcom/docker-pde.mk b/platform/broadcom/docker-pde.mk index aba1a5a356e4..7d6aa5b726c9 100644 --- a/platform/broadcom/docker-pde.mk +++ b/platform/broadcom/docker-pde.mk @@ -1,18 +1,12 @@ # Docker image for SONiC Platform Development Environment (PDE) - - ifeq ($(ENABLE_PDE), y) - DOCKER_PDE_STEM = docker-pde DOCKER_PDE = $(DOCKER_PDE_STEM).gz DOCKER_PDE_DBG = $(DOCKER_PDE_STEM)-$(DBG_IMAGE_MARK).gz - $(DOCKER_PDE)_PATH = $(DOCKERS_PATH)/$(DOCKER_PDE_STEM) - $(DOCKER_PDE)_DEPENDS += $(PYTHON_NETIFACES) $(DOCKER_PDE)_DEPENDS += $(SONIC_PLATFORM_PDE) $(BRCM_SAI) $(DOCKER_PDE_RDEPENDS += $(PYTHON_NETIFACES) - $(DOCKER_PDE)_PYTHON_DEBS += $(SONIC_UTILS) $(DOCKER_PDE)_PYTHON_WHEELS += $(SONIC_PLATFORM_COMMON_PY3) ifeq ($(PDDF_SUPPORT), y) @@ -21,10 +15,7 @@ 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) - - SONIC_DOCKER_IMAGES += $(DOCKER_PDE) SONIC_BUSTER_DOCKERS += $(DOCKER_PDE) SONIC_INSTALL_DOCKER_IMAGES += $(DOCKER_PDE) @@ -48,5 +39,4 @@ $(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 $(DOCKER_PDE)_BASE_IMAGE_FILES += pde-bench-knet:/usr/local/bin/pde-bench-knet - endif From 89d75bc6e80ceb31b195f9bdd13b79905db9dbe0 Mon Sep 17 00:00:00 2001 From: Geans Pin Date: Fri, 4 Jun 2021 16:39:02 -0700 Subject: [PATCH 09/28] Fix review comment --- dockers/docker-pde/base_image_files/pde-bench | 3 +-- dockers/docker-pde/docker_init.sh | 4 +--- dockers/docker-pde/stress-sfp-i2c.py | 3 +-- platform/broadcom/sonic-pde-tests.dep | 4 +--- 4 files changed, 4 insertions(+), 10 deletions(-) diff --git a/dockers/docker-pde/base_image_files/pde-bench b/dockers/docker-pde/base_image_files/pde-bench index 1e2c727b02af..5240264e11ce 100644 --- a/dockers/docker-pde/base_image_files/pde-bench +++ b/dockers/docker-pde/base_image_files/pde-bench @@ -34,5 +34,4 @@ echo "" echo "CSV Report: ${CSV}" echo "-----------------------------------------------------------------------" echo "$(cat ${CSV})" -echo "-----------------------------------------------------------------------" - +echo "-----------------------------------------------------------------------" \ No newline at end of file diff --git a/dockers/docker-pde/docker_init.sh b/dockers/docker-pde/docker_init.sh index 6e83fdd98aae..266cc9fd0346 100644 --- a/dockers/docker-pde/docker_init.sh +++ b/dockers/docker-pde/docker_init.sh @@ -40,6 +40,4 @@ fi start_bcm -exec /usr/bin/supervisord - - +exec /usr/bin/supervisord \ No newline at end of file diff --git a/dockers/docker-pde/stress-sfp-i2c.py b/dockers/docker-pde/stress-sfp-i2c.py index 08247767e2e7..04ab85e745f1 100644 --- a/dockers/docker-pde/stress-sfp-i2c.py +++ b/dockers/docker-pde/stress-sfp-i2c.py @@ -153,5 +153,4 @@ def stress_sfp_i2c(sec=180): sec = 180 if len(sys.argv) >= 2: sec = int(sys.argv[1]) - stress_sfp_i2c(sec) - + stress_sfp_i2c(sec) \ No newline at end of file diff --git a/platform/broadcom/sonic-pde-tests.dep b/platform/broadcom/sonic-pde-tests.dep index 40b99496c14d..2e0461f19580 100644 --- a/platform/broadcom/sonic-pde-tests.dep +++ b/platform/broadcom/sonic-pde-tests.dep @@ -1,4 +1,3 @@ - SPATH := $($(SONIC_PLATFORM_PDE)_SRC_PATH) DEP_FILES := $(SONIC_COMMON_FILES_LIST) platform/broadcom/sonic-pde-tests.mk platform/broadcom/sonic-pde-tests.dep DEP_FILES += $(SONIC_COMMON_BASE_FILES_LIST) @@ -8,5 +7,4 @@ $(SONIC_PLATFORM_PDE)_CACHE_MODE := GIT_CONTENT_SHA $(SONIC_PLATFORM_PDE)_DEP_FLAGS := $(SONIC_COMMON_FLAGS_LIST) $(SONIC_PLATFORM_PDE)_DEP_FILES := $(DEP_FILES) $(SONIC_PLATFORM_PDE)_SMDEP_FILES := $(SMDEP_FILES) -$(SONIC_PLATFORM_PDE)_SMDEP_PATHS := $(SPATH) - +$(SONIC_PLATFORM_PDE)_SMDEP_PATHS := $(SPATH) \ No newline at end of file From 1d18264e8097fedab4e14ca68f5a713daf9d7407 Mon Sep 17 00:00:00 2001 From: Geans Pin Date: Mon, 3 May 2021 17:07:58 -0700 Subject: [PATCH 10/28] Initial commit for introducing the SONiC Platform Development Env (Resubmit PR#3778) Fix conflicts --- dockers/docker-pde/Dockerfile.j2 | 1 - dockers/docker-pde/base_image_files/pde-bench | 2 +- dockers/docker-pde/docker_init.sh | 2 +- dockers/docker-pde/stress-sfp-i2c.py | 2 +- platform/broadcom/docker-pde.mk | 1 + platform/broadcom/sonic-pde-tests.dep | 2 +- 6 files changed, 5 insertions(+), 5 deletions(-) diff --git a/dockers/docker-pde/Dockerfile.j2 b/dockers/docker-pde/Dockerfile.j2 index 4c37f8d45fbf..0980706c9d18 100644 --- a/dockers/docker-pde/Dockerfile.j2 +++ b/dockers/docker-pde/Dockerfile.j2 @@ -24,7 +24,6 @@ RUN apt-get install -y python-jsonschema RUN pip3 install pytest pexpect - {% if docker_pde_debs.strip() -%} # Copy locally-built Debian package dependencies COPY \ diff --git a/dockers/docker-pde/base_image_files/pde-bench b/dockers/docker-pde/base_image_files/pde-bench index 5240264e11ce..dc22635ba900 100644 --- a/dockers/docker-pde/base_image_files/pde-bench +++ b/dockers/docker-pde/base_image_files/pde-bench @@ -34,4 +34,4 @@ echo "" echo "CSV Report: ${CSV}" echo "-----------------------------------------------------------------------" echo "$(cat ${CSV})" -echo "-----------------------------------------------------------------------" \ No newline at end of file +echo "-----------------------------------------------------------------------" diff --git a/dockers/docker-pde/docker_init.sh b/dockers/docker-pde/docker_init.sh index 266cc9fd0346..e348dfd983b1 100644 --- a/dockers/docker-pde/docker_init.sh +++ b/dockers/docker-pde/docker_init.sh @@ -40,4 +40,4 @@ fi start_bcm -exec /usr/bin/supervisord \ No newline at end of file +exec /usr/bin/supervisord diff --git a/dockers/docker-pde/stress-sfp-i2c.py b/dockers/docker-pde/stress-sfp-i2c.py index 04ab85e745f1..1737fb8f1592 100644 --- a/dockers/docker-pde/stress-sfp-i2c.py +++ b/dockers/docker-pde/stress-sfp-i2c.py @@ -153,4 +153,4 @@ def stress_sfp_i2c(sec=180): sec = 180 if len(sys.argv) >= 2: sec = int(sys.argv[1]) - stress_sfp_i2c(sec) \ No newline at end of file + stress_sfp_i2c(sec) diff --git a/platform/broadcom/docker-pde.mk b/platform/broadcom/docker-pde.mk index 7d6aa5b726c9..1c17ccf3201f 100644 --- a/platform/broadcom/docker-pde.mk +++ b/platform/broadcom/docker-pde.mk @@ -20,6 +20,7 @@ SONIC_DOCKER_IMAGES += $(DOCKER_PDE) SONIC_BUSTER_DOCKERS += $(DOCKER_PDE) SONIC_INSTALL_DOCKER_IMAGES += $(DOCKER_PDE) SONIC_BUSTER_DBG_DOCKERS += $(DOCKER_PDE_DBG) + SONIC_DOCKER_DBG_IMAGES += $(DOCKER_PDE_DBG) SONIC_INSTALL_DOCKER_DBG_IMAGES += $(DOCKER_PDE_DBG) diff --git a/platform/broadcom/sonic-pde-tests.dep b/platform/broadcom/sonic-pde-tests.dep index 2e0461f19580..2aaef7dc23f6 100644 --- a/platform/broadcom/sonic-pde-tests.dep +++ b/platform/broadcom/sonic-pde-tests.dep @@ -7,4 +7,4 @@ $(SONIC_PLATFORM_PDE)_CACHE_MODE := GIT_CONTENT_SHA $(SONIC_PLATFORM_PDE)_DEP_FLAGS := $(SONIC_COMMON_FLAGS_LIST) $(SONIC_PLATFORM_PDE)_DEP_FILES := $(DEP_FILES) $(SONIC_PLATFORM_PDE)_SMDEP_FILES := $(SMDEP_FILES) -$(SONIC_PLATFORM_PDE)_SMDEP_PATHS := $(SPATH) \ No newline at end of file +$(SONIC_PLATFORM_PDE)_SMDEP_PATHS := $(SPATH) From 7368837f670504f92549e4c8cffb619e9b73976b Mon Sep 17 00:00:00 2001 From: Geans Pin Date: Fri, 4 Jun 2021 16:39:02 -0700 Subject: [PATCH 11/28] Fix review comment --- dockers/docker-pde/base_image_files/pde-bench | 4 ++++ dockers/docker-pde/docker_init.sh | 4 ++++ dockers/docker-pde/stress-sfp-i2c.py | 4 ++++ platform/broadcom/sonic-pde-tests.dep | 4 ++++ 4 files changed, 16 insertions(+) diff --git a/dockers/docker-pde/base_image_files/pde-bench b/dockers/docker-pde/base_image_files/pde-bench index dc22635ba900..8945b8865918 100644 --- a/dockers/docker-pde/base_image_files/pde-bench +++ b/dockers/docker-pde/base_image_files/pde-bench @@ -34,4 +34,8 @@ echo "" echo "CSV Report: ${CSV}" echo "-----------------------------------------------------------------------" echo "$(cat ${CSV})" +<<<<<<< HEAD echo "-----------------------------------------------------------------------" +======= +echo "-----------------------------------------------------------------------" +>>>>>>> d0f6bb2d... Fix review comment diff --git a/dockers/docker-pde/docker_init.sh b/dockers/docker-pde/docker_init.sh index e348dfd983b1..e35ef0cbfc56 100644 --- a/dockers/docker-pde/docker_init.sh +++ b/dockers/docker-pde/docker_init.sh @@ -40,4 +40,8 @@ fi start_bcm +<<<<<<< HEAD exec /usr/bin/supervisord +======= +exec /usr/bin/supervisord +>>>>>>> d0f6bb2d... Fix review comment diff --git a/dockers/docker-pde/stress-sfp-i2c.py b/dockers/docker-pde/stress-sfp-i2c.py index 1737fb8f1592..1b9c5c4cf990 100644 --- a/dockers/docker-pde/stress-sfp-i2c.py +++ b/dockers/docker-pde/stress-sfp-i2c.py @@ -153,4 +153,8 @@ def stress_sfp_i2c(sec=180): sec = 180 if len(sys.argv) >= 2: sec = int(sys.argv[1]) +<<<<<<< HEAD stress_sfp_i2c(sec) +======= + stress_sfp_i2c(sec) +>>>>>>> d0f6bb2d... Fix review comment diff --git a/platform/broadcom/sonic-pde-tests.dep b/platform/broadcom/sonic-pde-tests.dep index 2aaef7dc23f6..a4b3dfbfdc46 100644 --- a/platform/broadcom/sonic-pde-tests.dep +++ b/platform/broadcom/sonic-pde-tests.dep @@ -7,4 +7,8 @@ $(SONIC_PLATFORM_PDE)_CACHE_MODE := GIT_CONTENT_SHA $(SONIC_PLATFORM_PDE)_DEP_FLAGS := $(SONIC_COMMON_FLAGS_LIST) $(SONIC_PLATFORM_PDE)_DEP_FILES := $(DEP_FILES) $(SONIC_PLATFORM_PDE)_SMDEP_FILES := $(SMDEP_FILES) +<<<<<<< HEAD $(SONIC_PLATFORM_PDE)_SMDEP_PATHS := $(SPATH) +======= +$(SONIC_PLATFORM_PDE)_SMDEP_PATHS := $(SPATH) +>>>>>>> d0f6bb2d... Fix review comment From ef975aa2b662f9b475e8c27e63c5a488164dd30b Mon Sep 17 00:00:00 2001 From: Geans Pin Date: Fri, 11 Jun 2021 16:18:48 -0700 Subject: [PATCH 12/28] Fix LGTM --- dockers/docker-pde/stress-sfp-i2c.py | 6 ++++-- dockers/docker-pde/syseeprom.py | 2 -- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/dockers/docker-pde/stress-sfp-i2c.py b/dockers/docker-pde/stress-sfp-i2c.py index 1b9c5c4cf990..365ecc8c74b5 100644 --- a/dockers/docker-pde/stress-sfp-i2c.py +++ b/dockers/docker-pde/stress-sfp-i2c.py @@ -1,9 +1,7 @@ #!/usr/bin/env python try: - import os import sys - import subprocess import time import imp from natsort import natsorted @@ -153,8 +151,12 @@ def stress_sfp_i2c(sec=180): sec = 180 if len(sys.argv) >= 2: sec = int(sys.argv[1]) +<<<<<<< HEAD <<<<<<< HEAD stress_sfp_i2c(sec) ======= stress_sfp_i2c(sec) >>>>>>> d0f6bb2d... Fix review comment +======= + stress_sfp_i2c(sec) +>>>>>>> 7cd31a4b... Fix LGTM diff --git a/dockers/docker-pde/syseeprom.py b/dockers/docker-pde/syseeprom.py index d6444b8352b3..5f536128837a 100644 --- a/dockers/docker-pde/syseeprom.py +++ b/dockers/docker-pde/syseeprom.py @@ -2,8 +2,6 @@ import sys import imp -import subprocess -import time PLATFORM_SPECIFIC_MODULE_NAME = "eeprom" PLATFORM_SPECIFIC_CLASS_NAME = "board" From b1ab9d5b98c184030e1d1e3a7e1fa1db477f9713 Mon Sep 17 00:00:00 2001 From: Geans Pin Date: Mon, 3 May 2021 17:07:58 -0700 Subject: [PATCH 13/28] Initial commit for introducing the SONiC Platform Development Env (Resubmit PR#3778) --- dockers/docker-pde/base_image_files/pde-bench | 8 ++++---- dockers/docker-pde/docker_init.sh | 8 ++++---- dockers/docker-pde/stress-sfp-i2c.py | 10 ++-------- dockers/docker-pde/syseeprom.py | 2 ++ platform/broadcom/docker-pde.mk | 7 +++++++ platform/broadcom/sonic-pde-tests.dep | 7 +++---- 6 files changed, 22 insertions(+), 20 deletions(-) diff --git a/dockers/docker-pde/base_image_files/pde-bench b/dockers/docker-pde/base_image_files/pde-bench index 8945b8865918..ff248134e21c 100644 --- a/dockers/docker-pde/base_image_files/pde-bench +++ b/dockers/docker-pde/base_image_files/pde-bench @@ -34,8 +34,8 @@ echo "" echo "CSV Report: ${CSV}" echo "-----------------------------------------------------------------------" echo "$(cat ${CSV})" -<<<<<<< HEAD -echo "-----------------------------------------------------------------------" -======= + + echo "-----------------------------------------------------------------------" ->>>>>>> d0f6bb2d... Fix review comment + + diff --git a/dockers/docker-pde/docker_init.sh b/dockers/docker-pde/docker_init.sh index e35ef0cbfc56..18e43b037ca5 100644 --- a/dockers/docker-pde/docker_init.sh +++ b/dockers/docker-pde/docker_init.sh @@ -40,8 +40,8 @@ fi start_bcm -<<<<<<< HEAD -exec /usr/bin/supervisord -======= + + exec /usr/bin/supervisord ->>>>>>> d0f6bb2d... Fix review comment + + diff --git a/dockers/docker-pde/stress-sfp-i2c.py b/dockers/docker-pde/stress-sfp-i2c.py index 365ecc8c74b5..dda11f980f45 100644 --- a/dockers/docker-pde/stress-sfp-i2c.py +++ b/dockers/docker-pde/stress-sfp-i2c.py @@ -151,12 +151,6 @@ def stress_sfp_i2c(sec=180): sec = 180 if len(sys.argv) >= 2: sec = int(sys.argv[1]) -<<<<<<< HEAD -<<<<<<< HEAD - stress_sfp_i2c(sec) -======= - stress_sfp_i2c(sec) ->>>>>>> d0f6bb2d... Fix review comment -======= + stress_sfp_i2c(sec) ->>>>>>> 7cd31a4b... Fix LGTM + diff --git a/dockers/docker-pde/syseeprom.py b/dockers/docker-pde/syseeprom.py index 5f536128837a..e39bc38f945e 100644 --- a/dockers/docker-pde/syseeprom.py +++ b/dockers/docker-pde/syseeprom.py @@ -3,6 +3,8 @@ import sys import imp + + PLATFORM_SPECIFIC_MODULE_NAME = "eeprom" PLATFORM_SPECIFIC_CLASS_NAME = "board" diff --git a/platform/broadcom/docker-pde.mk b/platform/broadcom/docker-pde.mk index 1c17ccf3201f..bb2c193b15be 100644 --- a/platform/broadcom/docker-pde.mk +++ b/platform/broadcom/docker-pde.mk @@ -1,4 +1,5 @@ # Docker image for SONiC Platform Development Environment (PDE) + ifeq ($(ENABLE_PDE), y) DOCKER_PDE_STEM = docker-pde DOCKER_PDE = $(DOCKER_PDE_STEM).gz @@ -7,6 +8,7 @@ $(DOCKER_PDE)_PATH = $(DOCKERS_PATH)/$(DOCKER_PDE_STEM) $(DOCKER_PDE)_DEPENDS += $(PYTHON_NETIFACES) $(DOCKER_PDE)_DEPENDS += $(SONIC_PLATFORM_PDE) $(BRCM_SAI) $(DOCKER_PDE_RDEPENDS += $(PYTHON_NETIFACES) + $(DOCKER_PDE)_PYTHON_DEBS += $(SONIC_UTILS) $(DOCKER_PDE)_PYTHON_WHEELS += $(SONIC_PLATFORM_COMMON_PY3) ifeq ($(PDDF_SUPPORT), y) @@ -15,12 +17,16 @@ 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) + SONIC_DOCKER_IMAGES += $(DOCKER_PDE) SONIC_BUSTER_DOCKERS += $(DOCKER_PDE) SONIC_INSTALL_DOCKER_IMAGES += $(DOCKER_PDE) SONIC_BUSTER_DBG_DOCKERS += $(DOCKER_PDE_DBG) + + SONIC_DOCKER_DBG_IMAGES += $(DOCKER_PDE_DBG) SONIC_INSTALL_DOCKER_DBG_IMAGES += $(DOCKER_PDE_DBG) @@ -40,4 +46,5 @@ $(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 $(DOCKER_PDE)_BASE_IMAGE_FILES += pde-bench-knet:/usr/local/bin/pde-bench-knet + endif diff --git a/platform/broadcom/sonic-pde-tests.dep b/platform/broadcom/sonic-pde-tests.dep index a4b3dfbfdc46..c049d2c8e463 100644 --- a/platform/broadcom/sonic-pde-tests.dep +++ b/platform/broadcom/sonic-pde-tests.dep @@ -1,3 +1,4 @@ + SPATH := $($(SONIC_PLATFORM_PDE)_SRC_PATH) DEP_FILES := $(SONIC_COMMON_FILES_LIST) platform/broadcom/sonic-pde-tests.mk platform/broadcom/sonic-pde-tests.dep DEP_FILES += $(SONIC_COMMON_BASE_FILES_LIST) @@ -7,8 +8,6 @@ $(SONIC_PLATFORM_PDE)_CACHE_MODE := GIT_CONTENT_SHA $(SONIC_PLATFORM_PDE)_DEP_FLAGS := $(SONIC_COMMON_FLAGS_LIST) $(SONIC_PLATFORM_PDE)_DEP_FILES := $(DEP_FILES) $(SONIC_PLATFORM_PDE)_SMDEP_FILES := $(SMDEP_FILES) -<<<<<<< HEAD -$(SONIC_PLATFORM_PDE)_SMDEP_PATHS := $(SPATH) -======= + $(SONIC_PLATFORM_PDE)_SMDEP_PATHS := $(SPATH) ->>>>>>> d0f6bb2d... Fix review comment + From 7771db9da41018a8edc2e2da5ee0d08def9fb736 Mon Sep 17 00:00:00 2001 From: Geans Pin Date: Mon, 3 May 2021 17:07:58 -0700 Subject: [PATCH 14/28] Initial commit for introducing the SONiC Platform Development Env (Resubmit PR#3778) Rebase latest and Resubmit to fix conflict --- dockers/docker-pde/Dockerfile.j2 | 1 + platform/broadcom/docker-pde.mk | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/dockers/docker-pde/Dockerfile.j2 b/dockers/docker-pde/Dockerfile.j2 index 0980706c9d18..4c37f8d45fbf 100644 --- a/dockers/docker-pde/Dockerfile.j2 +++ b/dockers/docker-pde/Dockerfile.j2 @@ -24,6 +24,7 @@ RUN apt-get install -y python-jsonschema RUN pip3 install pytest pexpect + {% if docker_pde_debs.strip() -%} # Copy locally-built Debian package dependencies COPY \ diff --git a/platform/broadcom/docker-pde.mk b/platform/broadcom/docker-pde.mk index bb2c193b15be..181e08e01131 100644 --- a/platform/broadcom/docker-pde.mk +++ b/platform/broadcom/docker-pde.mk @@ -1,5 +1,7 @@ # Docker image for SONiC Platform Development Environment (PDE) + + ifeq ($(ENABLE_PDE), y) DOCKER_PDE_STEM = docker-pde DOCKER_PDE = $(DOCKER_PDE_STEM).gz @@ -8,7 +10,6 @@ $(DOCKER_PDE)_PATH = $(DOCKERS_PATH)/$(DOCKER_PDE_STEM) $(DOCKER_PDE)_DEPENDS += $(PYTHON_NETIFACES) $(DOCKER_PDE)_DEPENDS += $(SONIC_PLATFORM_PDE) $(BRCM_SAI) $(DOCKER_PDE_RDEPENDS += $(PYTHON_NETIFACES) - $(DOCKER_PDE)_PYTHON_DEBS += $(SONIC_UTILS) $(DOCKER_PDE)_PYTHON_WHEELS += $(SONIC_PLATFORM_COMMON_PY3) ifeq ($(PDDF_SUPPORT), y) @@ -17,9 +18,10 @@ 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) + + SONIC_DOCKER_IMAGES += $(DOCKER_PDE) SONIC_BUSTER_DOCKERS += $(DOCKER_PDE) SONIC_INSTALL_DOCKER_IMAGES += $(DOCKER_PDE) @@ -46,5 +48,4 @@ $(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 $(DOCKER_PDE)_BASE_IMAGE_FILES += pde-bench-knet:/usr/local/bin/pde-bench-knet - endif From d595039faedc64e97e8eec851a8199f4058693bf Mon Sep 17 00:00:00 2001 From: Geans Pin Date: Fri, 4 Jun 2021 16:39:02 -0700 Subject: [PATCH 15/28] Fix review comment --- dockers/docker-pde/base_image_files/pde-bench | 2 ++ dockers/docker-pde/docker_init.sh | 2 ++ dockers/docker-pde/stress-sfp-i2c.py | 2 ++ platform/broadcom/sonic-pde-tests.dep | 3 ++- 4 files changed, 8 insertions(+), 1 deletion(-) diff --git a/dockers/docker-pde/base_image_files/pde-bench b/dockers/docker-pde/base_image_files/pde-bench index ff248134e21c..2ba261843778 100644 --- a/dockers/docker-pde/base_image_files/pde-bench +++ b/dockers/docker-pde/base_image_files/pde-bench @@ -36,6 +36,8 @@ echo "-----------------------------------------------------------------------" echo "$(cat ${CSV})" + echo "-----------------------------------------------------------------------" + diff --git a/dockers/docker-pde/docker_init.sh b/dockers/docker-pde/docker_init.sh index 18e43b037ca5..745ec8e3637d 100644 --- a/dockers/docker-pde/docker_init.sh +++ b/dockers/docker-pde/docker_init.sh @@ -42,6 +42,8 @@ start_bcm + exec /usr/bin/supervisord + diff --git a/dockers/docker-pde/stress-sfp-i2c.py b/dockers/docker-pde/stress-sfp-i2c.py index dda11f980f45..22dc3b881369 100644 --- a/dockers/docker-pde/stress-sfp-i2c.py +++ b/dockers/docker-pde/stress-sfp-i2c.py @@ -152,5 +152,7 @@ def stress_sfp_i2c(sec=180): if len(sys.argv) >= 2: sec = int(sys.argv[1]) + stress_sfp_i2c(sec) + diff --git a/platform/broadcom/sonic-pde-tests.dep b/platform/broadcom/sonic-pde-tests.dep index c049d2c8e463..840f9242cb37 100644 --- a/platform/broadcom/sonic-pde-tests.dep +++ b/platform/broadcom/sonic-pde-tests.dep @@ -1,4 +1,3 @@ - SPATH := $($(SONIC_PLATFORM_PDE)_SRC_PATH) DEP_FILES := $(SONIC_COMMON_FILES_LIST) platform/broadcom/sonic-pde-tests.mk platform/broadcom/sonic-pde-tests.dep DEP_FILES += $(SONIC_COMMON_BASE_FILES_LIST) @@ -9,5 +8,7 @@ $(SONIC_PLATFORM_PDE)_DEP_FLAGS := $(SONIC_COMMON_FLAGS_LIST) $(SONIC_PLATFORM_PDE)_DEP_FILES := $(DEP_FILES) $(SONIC_PLATFORM_PDE)_SMDEP_FILES := $(SMDEP_FILES) + $(SONIC_PLATFORM_PDE)_SMDEP_PATHS := $(SPATH) + From c375869dfee46210f6f469c3255fd1714bb166da Mon Sep 17 00:00:00 2001 From: Geans Pin Date: Mon, 3 May 2021 17:07:58 -0700 Subject: [PATCH 16/28] Initial commit for introducing the SONiC Platform Development Env (Resubmit PR#3778) --- Makefile.work | 2 ++ dockers/docker-pde/Dockerfile.j2 | 4 ++++ dockers/docker-pde/base_image_files/pde-bench | 2 ++ dockers/docker-pde/docker_init.sh | 6 ++++++ dockers/docker-pde/stress-sfp-i2c.py | 3 +++ dockers/docker-pde/syseeprom.py | 5 +++++ platform/broadcom/docker-pde.mk | 5 +++++ platform/broadcom/sonic-pde-tests.dep | 2 ++ 8 files changed, 29 insertions(+) diff --git a/Makefile.work b/Makefile.work index 3cdcbd36fca7..20929894c208 100644 --- a/Makefile.work +++ b/Makefile.work @@ -358,11 +358,13 @@ showtag: @echo $(SLAVE_BASE_IMAGE):$(SLAVE_BASE_TAG) initpde: + @for submodule in $(PDESUBMODULES) ; do \ git submodule update --init --recursive $$submodule ; \ done @git submodule foreach --recursive '[ -f .git ] && echo "gitdir: $$(realpath --relative-to=. $$(cut -d" " -f2 .git))" > .git' + init : @git submodule update --init --recursive @git submodule foreach --recursive '[ -f .git ] && echo "gitdir: $$(realpath --relative-to=. $$(cut -d" " -f2 .git))" > .git' diff --git a/dockers/docker-pde/Dockerfile.j2 b/dockers/docker-pde/Dockerfile.j2 index 4c37f8d45fbf..153b8364f73b 100644 --- a/dockers/docker-pde/Dockerfile.j2 +++ b/dockers/docker-pde/Dockerfile.j2 @@ -20,11 +20,13 @@ 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 pip3 install pytest pexpect + {% if docker_pde_debs.strip() -%} # Copy locally-built Debian package dependencies COPY \ @@ -62,8 +64,10 @@ python-wheels/{{ whl }}{{' '}} /python-wheels/ # Install locally-built Python wheel dependencies + RUN pip3 install \ + {% for whl in docker_pde_whls.split(' ') -%} /python-wheels/{{ whl }}{{' '}} {%- endfor %} diff --git a/dockers/docker-pde/base_image_files/pde-bench b/dockers/docker-pde/base_image_files/pde-bench index 2ba261843778..fa9fbc675b7e 100644 --- a/dockers/docker-pde/base_image_files/pde-bench +++ b/dockers/docker-pde/base_image_files/pde-bench @@ -37,7 +37,9 @@ echo "$(cat ${CSV})" + echo "-----------------------------------------------------------------------" + diff --git a/dockers/docker-pde/docker_init.sh b/dockers/docker-pde/docker_init.sh index 745ec8e3637d..e60574eaa4bd 100644 --- a/dockers/docker-pde/docker_init.sh +++ b/dockers/docker-pde/docker_init.sh @@ -40,6 +40,7 @@ fi start_bcm +<<<<<<< HEAD @@ -47,3 +48,8 @@ exec /usr/bin/supervisord +======= +exec /usr/bin/supervisord + + +>>>>>>> c1524191... Initial commit for introducing the SONiC Platform Development Env (Resubmit PR#3778) diff --git a/dockers/docker-pde/stress-sfp-i2c.py b/dockers/docker-pde/stress-sfp-i2c.py index 22dc3b881369..8f25eb1f4f0a 100644 --- a/dockers/docker-pde/stress-sfp-i2c.py +++ b/dockers/docker-pde/stress-sfp-i2c.py @@ -1,7 +1,9 @@ #!/usr/bin/env python try: + import sys + import time import imp from natsort import natsorted @@ -153,6 +155,7 @@ def stress_sfp_i2c(sec=180): sec = int(sys.argv[1]) + stress_sfp_i2c(sec) diff --git a/dockers/docker-pde/syseeprom.py b/dockers/docker-pde/syseeprom.py index e39bc38f945e..38bf83c0efed 100644 --- a/dockers/docker-pde/syseeprom.py +++ b/dockers/docker-pde/syseeprom.py @@ -2,8 +2,13 @@ import sys import imp +<<<<<<< HEAD +======= +import subprocess +import time +>>>>>>> c1524191... Initial commit for introducing the SONiC Platform Development Env (Resubmit PR#3778) PLATFORM_SPECIFIC_MODULE_NAME = "eeprom" PLATFORM_SPECIFIC_CLASS_NAME = "board" diff --git a/platform/broadcom/docker-pde.mk b/platform/broadcom/docker-pde.mk index 181e08e01131..62085f196446 100644 --- a/platform/broadcom/docker-pde.mk +++ b/platform/broadcom/docker-pde.mk @@ -2,6 +2,7 @@ + ifeq ($(ENABLE_PDE), y) DOCKER_PDE_STEM = docker-pde DOCKER_PDE = $(DOCKER_PDE_STEM).gz @@ -29,6 +30,7 @@ SONIC_BUSTER_DBG_DOCKERS += $(DOCKER_PDE_DBG) + SONIC_DOCKER_DBG_IMAGES += $(DOCKER_PDE_DBG) SONIC_INSTALL_DOCKER_DBG_IMAGES += $(DOCKER_PDE_DBG) @@ -37,6 +39,7 @@ $(DOCKER_PDE)_RUN_OPT += --net=host --privileged -t $(DOCKER_PDE)_RUN_OPT += -v /etc/sonic:/etc/sonic:ro $(DOCKER_PDE)_RUN_OPT += -v /host/machine.conf:/host/machine.conf:ro $(DOCKER_PDE)_RUN_OPT += -v /usr/lib/python2.7/dist-packages:/usr/share/sonic/classes:ro + $(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 /lib/modules:/lib/modules:ro @@ -44,8 +47,10 @@ $(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)_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 $(DOCKER_PDE)_BASE_IMAGE_FILES += pde-bench-knet:/usr/local/bin/pde-bench-knet + endif diff --git a/platform/broadcom/sonic-pde-tests.dep b/platform/broadcom/sonic-pde-tests.dep index 840f9242cb37..a6073a82e624 100644 --- a/platform/broadcom/sonic-pde-tests.dep +++ b/platform/broadcom/sonic-pde-tests.dep @@ -1,3 +1,4 @@ + SPATH := $($(SONIC_PLATFORM_PDE)_SRC_PATH) DEP_FILES := $(SONIC_COMMON_FILES_LIST) platform/broadcom/sonic-pde-tests.mk platform/broadcom/sonic-pde-tests.dep DEP_FILES += $(SONIC_COMMON_BASE_FILES_LIST) @@ -9,6 +10,7 @@ $(SONIC_PLATFORM_PDE)_DEP_FILES := $(DEP_FILES) $(SONIC_PLATFORM_PDE)_SMDEP_FILES := $(SMDEP_FILES) + $(SONIC_PLATFORM_PDE)_SMDEP_PATHS := $(SPATH) From 9714e6133e28cab2bd8ada00bde001c2fde397b2 Mon Sep 17 00:00:00 2001 From: Geans Pin Date: Fri, 4 Jun 2021 16:39:02 -0700 Subject: [PATCH 17/28] Fix review comment --- dockers/docker-pde/base_image_files/pde-bench | 2 ++ dockers/docker-pde/docker_init.sh | 6 +----- dockers/docker-pde/stress-sfp-i2c.py | 2 ++ platform/broadcom/sonic-pde-tests.dep | 3 ++- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/dockers/docker-pde/base_image_files/pde-bench b/dockers/docker-pde/base_image_files/pde-bench index fa9fbc675b7e..426c8d562df6 100644 --- a/dockers/docker-pde/base_image_files/pde-bench +++ b/dockers/docker-pde/base_image_files/pde-bench @@ -38,8 +38,10 @@ echo "$(cat ${CSV})" + echo "-----------------------------------------------------------------------" + diff --git a/dockers/docker-pde/docker_init.sh b/dockers/docker-pde/docker_init.sh index e60574eaa4bd..c62180591220 100644 --- a/dockers/docker-pde/docker_init.sh +++ b/dockers/docker-pde/docker_init.sh @@ -40,16 +40,12 @@ fi start_bcm -<<<<<<< HEAD -exec /usr/bin/supervisord +exec /usr/bin/supervisord -======= -exec /usr/bin/supervisord ->>>>>>> c1524191... Initial commit for introducing the SONiC Platform Development Env (Resubmit PR#3778) diff --git a/dockers/docker-pde/stress-sfp-i2c.py b/dockers/docker-pde/stress-sfp-i2c.py index 8f25eb1f4f0a..5e49d8e31def 100644 --- a/dockers/docker-pde/stress-sfp-i2c.py +++ b/dockers/docker-pde/stress-sfp-i2c.py @@ -156,6 +156,8 @@ def stress_sfp_i2c(sec=180): + stress_sfp_i2c(sec) + diff --git a/platform/broadcom/sonic-pde-tests.dep b/platform/broadcom/sonic-pde-tests.dep index a6073a82e624..571c18c5b903 100644 --- a/platform/broadcom/sonic-pde-tests.dep +++ b/platform/broadcom/sonic-pde-tests.dep @@ -1,4 +1,3 @@ - SPATH := $($(SONIC_PLATFORM_PDE)_SRC_PATH) DEP_FILES := $(SONIC_COMMON_FILES_LIST) platform/broadcom/sonic-pde-tests.mk platform/broadcom/sonic-pde-tests.dep DEP_FILES += $(SONIC_COMMON_BASE_FILES_LIST) @@ -11,6 +10,8 @@ $(SONIC_PLATFORM_PDE)_SMDEP_FILES := $(SMDEP_FILES) + $(SONIC_PLATFORM_PDE)_SMDEP_PATHS := $(SPATH) + From dfea080f0ed7418d0d1b9a0b7452fc957d0a9421 Mon Sep 17 00:00:00 2001 From: Geans Pin Date: Fri, 11 Jun 2021 16:18:48 -0700 Subject: [PATCH 18/28] Fix LGTM --- dockers/docker-pde/stress-sfp-i2c.py | 4 ++++ dockers/docker-pde/syseeprom.py | 7 ++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/dockers/docker-pde/stress-sfp-i2c.py b/dockers/docker-pde/stress-sfp-i2c.py index 5e49d8e31def..a1d3e3e73884 100644 --- a/dockers/docker-pde/stress-sfp-i2c.py +++ b/dockers/docker-pde/stress-sfp-i2c.py @@ -2,8 +2,10 @@ try: + import sys + import time import imp from natsort import natsorted @@ -157,7 +159,9 @@ def stress_sfp_i2c(sec=180): + stress_sfp_i2c(sec) + diff --git a/dockers/docker-pde/syseeprom.py b/dockers/docker-pde/syseeprom.py index 38bf83c0efed..c1b3d3eda52d 100644 --- a/dockers/docker-pde/syseeprom.py +++ b/dockers/docker-pde/syseeprom.py @@ -2,13 +2,10 @@ import sys import imp -<<<<<<< HEAD -======= -import subprocess -import time ->>>>>>> c1524191... Initial commit for introducing the SONiC Platform Development Env (Resubmit PR#3778) + + PLATFORM_SPECIFIC_MODULE_NAME = "eeprom" PLATFORM_SPECIFIC_CLASS_NAME = "board" From 636d58769a9941a9810a81e06a9fa4182e1546f2 Mon Sep 17 00:00:00 2001 From: Geans Pin Date: Wed, 23 Jun 2021 17:56:13 -0700 Subject: [PATCH 19/28] Fix review comment --- dockers/docker-pde/stress-sfp-i2c.py | 7 ------- 1 file changed, 7 deletions(-) diff --git a/dockers/docker-pde/stress-sfp-i2c.py b/dockers/docker-pde/stress-sfp-i2c.py index 0dded65ff315..49e558a3a42e 100644 --- a/dockers/docker-pde/stress-sfp-i2c.py +++ b/dockers/docker-pde/stress-sfp-i2c.py @@ -155,13 +155,6 @@ def stress_sfp_i2c(sec=180): sec = 180 if len(sys.argv) >= 2: sec = int(sys.argv[1]) - - - - - - - stress_sfp_i2c(sec) From 64532b397d8b3c73d69508a2a7132bfc149d6cc1 Mon Sep 17 00:00:00 2001 From: Geans Pin Date: Wed, 23 Jun 2021 18:01:40 -0700 Subject: [PATCH 20/28] Fix review comment --- dockers/docker-pde/stress-sfp-i2c.py | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/dockers/docker-pde/stress-sfp-i2c.py b/dockers/docker-pde/stress-sfp-i2c.py index 49e558a3a42e..cd595c52ec5c 100644 --- a/dockers/docker-pde/stress-sfp-i2c.py +++ b/dockers/docker-pde/stress-sfp-i2c.py @@ -1,11 +1,7 @@ #!/usr/bin/env python try: - - import sys - - import time import imp from natsort import natsorted @@ -156,9 +152,3 @@ def stress_sfp_i2c(sec=180): if len(sys.argv) >= 2: sec = int(sys.argv[1]) stress_sfp_i2c(sec) - - - - - - From 42107fe8968985bea3f011f45d8b8fdd2b711b45 Mon Sep 17 00:00:00 2001 From: Geans Pin Date: Wed, 23 Jun 2021 19:27:10 -0700 Subject: [PATCH 21/28] Remove empty lines --- dockers/docker-pde/Dockerfile.j2 | 4 ---- dockers/docker-pde/base_image_files/pde-bench | 12 ------------ dockers/docker-pde/docker_init.sh | 11 ----------- dockers/docker-pde/syseeprom.py | 4 ---- platform/broadcom/docker-pde.mk | 9 --------- platform/broadcom/sonic-pde-tests.dep | 9 --------- slave.mk | 2 +- 7 files changed, 1 insertion(+), 50 deletions(-) diff --git a/dockers/docker-pde/Dockerfile.j2 b/dockers/docker-pde/Dockerfile.j2 index ccae581639a4..0711e563c259 100644 --- a/dockers/docker-pde/Dockerfile.j2 +++ b/dockers/docker-pde/Dockerfile.j2 @@ -25,10 +25,6 @@ RUN apt-get install -y python-jsonschema RUN pip3 install pytest pexpect - - - - {% if docker_pde_debs.strip() -%} # Copy locally-built Debian package dependencies COPY \ diff --git a/dockers/docker-pde/base_image_files/pde-bench b/dockers/docker-pde/base_image_files/pde-bench index 41f9096c599d..dc22635ba900 100644 --- a/dockers/docker-pde/base_image_files/pde-bench +++ b/dockers/docker-pde/base_image_files/pde-bench @@ -34,16 +34,4 @@ echo "" echo "CSV Report: ${CSV}" echo "-----------------------------------------------------------------------" echo "$(cat ${CSV})" - - - - - - echo "-----------------------------------------------------------------------" - - - - - - diff --git a/dockers/docker-pde/docker_init.sh b/dockers/docker-pde/docker_init.sh index e2ab223ba4b9..f8e45e99d98d 100644 --- a/dockers/docker-pde/docker_init.sh +++ b/dockers/docker-pde/docker_init.sh @@ -1,5 +1,4 @@ #!/usr/bin/env bash - set -x start_bcm() @@ -40,14 +39,4 @@ fi start_bcm - - - - - exec /usr/bin/supervisord - - - - - diff --git a/dockers/docker-pde/syseeprom.py b/dockers/docker-pde/syseeprom.py index c1b3d3eda52d..5f536128837a 100644 --- a/dockers/docker-pde/syseeprom.py +++ b/dockers/docker-pde/syseeprom.py @@ -3,10 +3,6 @@ import sys import imp - - - - PLATFORM_SPECIFIC_MODULE_NAME = "eeprom" PLATFORM_SPECIFIC_CLASS_NAME = "board" diff --git a/platform/broadcom/docker-pde.mk b/platform/broadcom/docker-pde.mk index 0e0bb9d16022..7e4300217e47 100644 --- a/platform/broadcom/docker-pde.mk +++ b/platform/broadcom/docker-pde.mk @@ -1,8 +1,5 @@ # Docker image for SONiC Platform Development Environment (PDE) - - - ifeq ($(ENABLE_PDE), y) DOCKER_PDE_STEM = docker-pde DOCKER_PDE = $(DOCKER_PDE_STEM).gz @@ -23,16 +20,10 @@ $(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) - - SONIC_DOCKER_IMAGES += $(DOCKER_PDE) SONIC_BUSTER_DOCKERS += $(DOCKER_PDE) SONIC_INSTALL_DOCKER_IMAGES += $(DOCKER_PDE) SONIC_BUSTER_DBG_DOCKERS += $(DOCKER_PDE_DBG) - - - - SONIC_DOCKER_DBG_IMAGES += $(DOCKER_PDE_DBG) SONIC_INSTALL_DOCKER_DBG_IMAGES += $(DOCKER_PDE_DBG) diff --git a/platform/broadcom/sonic-pde-tests.dep b/platform/broadcom/sonic-pde-tests.dep index 9e0225829251..2aaef7dc23f6 100644 --- a/platform/broadcom/sonic-pde-tests.dep +++ b/platform/broadcom/sonic-pde-tests.dep @@ -7,13 +7,4 @@ $(SONIC_PLATFORM_PDE)_CACHE_MODE := GIT_CONTENT_SHA $(SONIC_PLATFORM_PDE)_DEP_FLAGS := $(SONIC_COMMON_FLAGS_LIST) $(SONIC_PLATFORM_PDE)_DEP_FILES := $(DEP_FILES) $(SONIC_PLATFORM_PDE)_SMDEP_FILES := $(SMDEP_FILES) - - - - - $(SONIC_PLATFORM_PDE)_SMDEP_PATHS := $(SPATH) - - - - diff --git a/slave.mk b/slave.mk index 00e47167652a..e79f42c30c7a 100644 --- a/slave.mk +++ b/slave.mk @@ -1044,7 +1044,7 @@ $(addprefix $(TARGET_PATH)/, $(SONIC_INSTALLERS)) : $(TARGET_PATH)/% : \ DEBUG_IMG="$(INSTALL_DEBUG_TOOLS)" \ DEBUG_SRC_ARCHIVE_FILE="$(DBG_SRC_ARCHIVE_FILE)" \ - BUILD_TARGET="$@" \ + BUILD_TARGET="$@" \ USERNAME="$(USERNAME)" \ PASSWORD="$(PASSWORD)" \ TARGET_MACHINE=$(dep_machine) \ From 964d61fcf6797612626514714a9bef67d309bd7b Mon Sep 17 00:00:00 2001 From: Geans Pin Date: Fri, 2 Jul 2021 00:14:05 -0700 Subject: [PATCH 22/28] Link to pde submodule --- .gitmodules | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitmodules b/.gitmodules index f8020be8bb8f..56e7594ce130 100644 --- a/.gitmodules +++ b/.gitmodules @@ -44,6 +44,9 @@ [submodule "src/sonic-platform-daemons"] path = src/sonic-platform-daemons url = https://github.com/Azure/sonic-platform-daemons +[submodule "src/sonic-platform-pde"] + path = src/sonic-platform-pde + url = https://github.com/Azure/sonic-platform-pdk-pde.git [submodule "src/sonic-frr/frr"] path = src/sonic-frr/frr url = https://github.com/Azure/sonic-frr.git From d9a5e2a81a4188147c5f1aa4c8005cfc88d7c951 Mon Sep 17 00:00:00 2001 From: Geans Pin Date: Fri, 2 Jul 2021 01:03:46 -0700 Subject: [PATCH 23/28] ADD submodule sonic-platform-pde/ --- src/sonic-platform-pde/.gitkeep | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 src/sonic-platform-pde/.gitkeep diff --git a/src/sonic-platform-pde/.gitkeep b/src/sonic-platform-pde/.gitkeep new file mode 100644 index 000000000000..e69de29bb2d1 From fbd5f2412c48c4502a778dc13bf06dd5e19d63b1 Mon Sep 17 00:00:00 2001 From: Geans Pin Date: Fri, 2 Jul 2021 15:52:23 -0700 Subject: [PATCH 24/28] fix submodule add --- .gitmodules | 2 +- src/sonic-platform-pde | 1 + src/sonic-platform-pde/.gitkeep | 0 3 files changed, 2 insertions(+), 1 deletion(-) create mode 160000 src/sonic-platform-pde delete mode 100644 src/sonic-platform-pde/.gitkeep diff --git a/.gitmodules b/.gitmodules index 56e7594ce130..8641423ebd39 100644 --- a/.gitmodules +++ b/.gitmodules @@ -46,7 +46,7 @@ url = https://github.com/Azure/sonic-platform-daemons [submodule "src/sonic-platform-pde"] path = src/sonic-platform-pde - url = https://github.com/Azure/sonic-platform-pdk-pde.git + url = https://github.com/Azure/sonic-platform-pdk-pde [submodule "src/sonic-frr/frr"] path = src/sonic-frr/frr url = https://github.com/Azure/sonic-frr.git diff --git a/src/sonic-platform-pde b/src/sonic-platform-pde new file mode 160000 index 000000000000..f18ebc297d8b --- /dev/null +++ b/src/sonic-platform-pde @@ -0,0 +1 @@ +Subproject commit f18ebc297d8b751c162dffd120d284d784aa977d diff --git a/src/sonic-platform-pde/.gitkeep b/src/sonic-platform-pde/.gitkeep deleted file mode 100644 index e69de29bb2d1..000000000000 From e4cff3ebc3fc1f90cf7ecb3ed527b8681d1cff7a Mon Sep 17 00:00:00 2001 From: Geans Pin Date: Thu, 22 Jul 2021 23:56:11 -0700 Subject: [PATCH 25/28] Fix review comment --- Makefile.work | 10 +--- platform/broadcom/docker-pde.mk | 2 +- platform/broadcom/one-pde-image.dep | 2 - platform/broadcom/one-pde-image.mk | 81 ----------------------------- platform/broadcom/rules.dep | 4 ++ platform/broadcom/rules.mk | 4 ++ rules/config | 4 +- slave.mk | 4 +- 8 files changed, 14 insertions(+), 97 deletions(-) delete mode 100644 platform/broadcom/one-pde-image.dep delete mode 100644 platform/broadcom/one-pde-image.mk diff --git a/Makefile.work b/Makefile.work index 099cbcec778c..d80086fb6ec2 100644 --- a/Makefile.work +++ b/Makefile.work @@ -289,7 +289,7 @@ PDESUBMODULES = src/sonic-linux-kernel \ src/sonic-ztp \ src/sonic-platform-daemons \ src/sonic-platform-pde -.PHONY: sonic-slave-build sonic-slave-bash init initpde reset +.PHONY: sonic-slave-build sonic-slave-bash init reset .DEFAULT_GOAL := all @@ -358,14 +358,6 @@ showtag: @echo $(SLAVE_IMAGE):$(SLAVE_TAG) @echo $(SLAVE_BASE_IMAGE):$(SLAVE_BASE_TAG) -initpde: - - @for submodule in $(PDESUBMODULES) ; do \ - git submodule update --init --recursive $$submodule ; \ - done - @git submodule foreach --recursive '[ -f .git ] && echo "gitdir: $$(realpath --relative-to=. $$(cut -d" " -f2 .git))" > .git' - - init : @git submodule update --init --recursive @git submodule foreach --recursive '[ -f .git ] && echo "gitdir: $$(realpath --relative-to=. $$(cut -d" " -f2 .git))" > .git' diff --git a/platform/broadcom/docker-pde.mk b/platform/broadcom/docker-pde.mk index 7e4300217e47..56d810467498 100644 --- a/platform/broadcom/docker-pde.mk +++ b/platform/broadcom/docker-pde.mk @@ -1,6 +1,6 @@ # Docker image for SONiC Platform Development Environment (PDE) -ifeq ($(ENABLE_PDE), y) +ifeq ($(INCLUDE_PDE), y) DOCKER_PDE_STEM = docker-pde DOCKER_PDE = $(DOCKER_PDE_STEM).gz DOCKER_PDE_DBG = $(DOCKER_PDE_STEM)-$(DBG_IMAGE_MARK).gz diff --git a/platform/broadcom/one-pde-image.dep b/platform/broadcom/one-pde-image.dep deleted file mode 100644 index 2abc8cad736f..000000000000 --- a/platform/broadcom/one-pde-image.dep +++ /dev/null @@ -1,2 +0,0 @@ -#DPKG FRK -$(SONIC_ONE_PDE_IMAGE)_CACHE_MODE := none diff --git a/platform/broadcom/one-pde-image.mk b/platform/broadcom/one-pde-image.mk deleted file mode 100644 index e8b2629c49a6..000000000000 --- a/platform/broadcom/one-pde-image.mk +++ /dev/null @@ -1,81 +0,0 @@ -# sonic broadcom one image installer - -SONIC_ONE_PDE_IMAGE = sonic-broadcom-pde.bin -$(SONIC_ONE_PDE_IMAGE)_MACHINE = broadcom -$(SONIC_ONE_PDE_IMAGE)_IMAGE_TYPE = onie -$(SONIC_ONE_PDE_IMAGE)_INSTALLS += $(BRCM_OPENNSL_KERNEL) -$(SONIC_ONE_PDE_IMAGE)_INSTALLS += $(PDDF_PLATFORM_MODULE) -$(SONIC_ONE_PDE_IMAGE)_LAZY_INSTALLS += $(DELL_S6000_PLATFORM_MODULE) \ - $(DELL_Z9332F_PLATFORM_MODULE) \ - $(DELL_Z9264F_PLATFORM_MODULE) \ - $(DELL_S5212F_PLATFORM_MODULE) \ - $(DELL_S5232F_PLATFORM_MODULE) \ - $(DELL_S5248F_PLATFORM_MODULE) \ - $(DELL_S5296F_PLATFORM_MODULE) \ - $(DELL_Z9100_PLATFORM_MODULE) \ - $(DELL_S6100_PLATFORM_MODULE) \ - $(DELL_S3000_PLATFORM_MODULE) \ - $(DELL_N3248TE_PLATFORM_MODULE) \ - $(DELL_S5224F_PLATFORM_MODULE) \ - $(DELL_Z9432F_PLATFORM_MODULE) \ - $(INGRASYS_S8900_54XC_PLATFORM_MODULE) \ - $(INGRASYS_S8900_64XC_PLATFORM_MODULE) \ - $(INGRASYS_S9100_PLATFORM_MODULE) \ - $(INGRASYS_S8810_32Q_PLATFORM_MODULE) \ - $(INGRASYS_S9200_64X_PLATFORM_MODULE) \ - $(ACCTON_AS7712_32X_PLATFORM_MODULE) \ - $(ACCTON_AS5712_54X_PLATFORM_MODULE) \ - $(ACCTON_AS7816_64X_PLATFORM_MODULE) \ - $(ACCTON_AS7716_32X_PLATFORM_MODULE) \ - $(ACCTON_AS7312_54X_PLATFORM_MODULE) \ - $(ACCTON_AS7326_56X_PLATFORM_MODULE) \ - $(ACCTON_AS7716_32XB_PLATFORM_MODULE) \ - $(ACCTON_AS6712_32X_PLATFORM_MODULE) \ - $(ACCTON_AS7726_32X_PLATFORM_MODULE) \ - $(ACCTON_AS4630_54PE_PLATFORM_MODULE) \ - $(ACCTON_MINIPACK_PLATFORM_MODULE) \ - $(ACCTON_AS5812_54X_PLATFORM_MODULE) \ - $(ACCTON_AS5812_54T_PLATFORM_MODULE) \ - $(ACCTON_AS5835_54X_PLATFORM_MODULE) \ - $(ACCTON_AS9716_32D_PLATFORM_MODULE) \ - $(ACCTON_AS5835_54T_PLATFORM_MODULE) \ - $(ACCTON_AS7312_54XS_PLATFORM_MODULE) \ - $(ACCTON_AS7315_27XB_PLATFORM_MODULE) \ - $(INVENTEC_D7032Q28B_PLATFORM_MODULE) \ - $(INVENTEC_D7054Q28B_PLATFORM_MODULE) \ - $(INVENTEC_D7264Q28B_PLATFORM_MODULE) \ - $(INVENTEC_D7264_PLATFORM_MODULE) \ - $(INVENTEC_D6356_PLATFORM_MODULE) \ - $(INVENTEC_D6356J_PLATFORM_MODULE) \ - $(INVENTEC_D6332_PLATFORM_MODULE) \ - $(INVENTEC_D7332_PLATFORM_MODULE) \ - $(CEL_DX010_PLATFORM_MODULE) \ - $(CEL_HALIBURTON_PLATFORM_MODULE) \ - $(DELTA_AG9032V1_PLATFORM_MODULE) \ - $(DELTA_AG9064_PLATFORM_MODULE) \ - $(DELTA_AG5648_PLATFORM_MODULE) \ - $(DELTA_ET6248BRB_PLATFORM_MODULE) \ - $(QUANTA_IX1B_32X_PLATFORM_MODULE) \ - $(QUANTA_IX4_64X_PLATFORM_MODULE) \ - $(QUANTA_IX7_32X_PLATFORM_MODULE) \ - $(QUANTA_IX7_BWDE_32X_PLATFORM_MODULE) \ - $(QUANTA_IX7T_32X_PLATFORM_MODULE) \ - $(QUANTA_IX8_56X_PLATFORM_MODULE) \ - $(QUANTA_IX8C_56X_PLATFORM_MODULE) \ - $(QUANTA_IX8A_BWDE_56X_PLATFORM_MODULE) \ - $(QUANTA_IX8F_56X_PLATFORM_MODULE) \ - $(QUANTA_IX8T_56X_PLATFORM_MODULE) \ - $(QUANTA_IX9_32X_PLATFORM_MODULE) \ - $(MITAC_LY1200_32X_PLATFORM_MODULE) \ - $(ALPHANETWORKS_SNH60A0_320FV2_PLATFORM_MODULE) \ - $(ALPHANETWORKS_SNH60B0_640F_PLATFORM_MODULE) \ - $(ALPHANETWORKS_SNJ60B0_320F_PLATFORM_MODULE) \ - $(ALPHANETWORKS_SNJ61D0_320F_PLATFORM_MODULE) \ - $(BRCM_XLR_GTS_PLATFORM_MODULE) \ - $(DELTA_AG9032V2A_PLATFORM_MODULE) \ - $(JUNIPER_QFX5210_PLATFORM_MODULE) \ - $(CEL_SILVERSTONE_PLATFORM_MODULE) \ - $(CEL_SILVERSTONE-DP_PLATFORM_MODULE) - -$(SONIC_ONE_PDE_IMAGE)_DOCKERS += $(DOCKER_PDE) $(DOCKER_PLATFORM_MONITOR) $(DOCKER_DATABASE) -SONIC_INSTALLERS += $(SONIC_ONE_PDE_IMAGE) diff --git a/platform/broadcom/rules.dep b/platform/broadcom/rules.dep index fd9407aeb049..74f64c362b39 100644 --- a/platform/broadcom/rules.dep +++ b/platform/broadcom/rules.dep @@ -17,6 +17,10 @@ include $(PLATFORM_PATH)/platform-modules-brcm-xlr-gts.dep include $(PLATFORM_PATH)/docker-syncd-brcm.dep include $(PLATFORM_PATH)/docker-syncd-brcm-rpc.dep include $(PLATFORM_PATH)/docker-saiserver-brcm.dep +ifeq ($(INCLUDE_PDE), y) +include $(PLATFORM_PATH)/docker-pde.dep +include $(PLATFORM_PATH)/sonic-pde-tests.dep +endif include $(PLATFORM_PATH)/one-image.dep include $(PLATFORM_PATH)/one-pde-image.dep include $(PLATFORM_PATH)/raw-image.dep diff --git a/platform/broadcom/rules.mk b/platform/broadcom/rules.mk index f7fb22a07442..2a3ac0e5f474 100644 --- a/platform/broadcom/rules.mk +++ b/platform/broadcom/rules.mk @@ -17,6 +17,10 @@ include $(PLATFORM_PATH)/platform-modules-ragile.mk include $(PLATFORM_PATH)/docker-syncd-brcm.mk include $(PLATFORM_PATH)/docker-syncd-brcm-rpc.mk include $(PLATFORM_PATH)/docker-saiserver-brcm.mk +ifeq ($(INCLUDE_PDE), y) +include $(PLATFORM_PATH)/docker-pde.mk +include $(PLATFORM_PATH)/sonic-pde-tests.mk +endif include $(PLATFORM_PATH)/one-image.mk include $(PLATFORM_PATH)/raw-image.mk include $(PLATFORM_PATH)/one-aboot.mk diff --git a/rules/config b/rules/config index 8bf99492bad1..4aa724d29cfd 100644 --- a/rules/config +++ b/rules/config @@ -51,8 +51,8 @@ DEFAULT_PASSWORD = YourPaSsWoRd # ENABLE_ZTP - installs Zero Touch Provisioning support. # ENABLE_ZTP = y -# ENABLE_PDE - Enable platform development enviroment -ENABLE_PDE = y +# INCLUDE_PDE - Enable platform development enviroment +# INCLUDE_PDE = y # SHUTDOWN_BGP_ON_START - if set to y all bgp sessions will be in admin down state when # bgp service starts. # SHUTDOWN_BGP_ON_START = y diff --git a/slave.mk b/slave.mk index e79f42c30c7a..03f03a6a6c2f 100644 --- a/slave.mk +++ b/slave.mk @@ -241,7 +241,7 @@ $(info "HTTP_PROXY" : "$(HTTP_PROXY)") $(info "HTTPS_PROXY" : "$(HTTPS_PROXY)") $(info "NO_PROXY" : "$(NO_PROXY)") $(info "ENABLE_ZTP" : "$(ENABLE_ZTP)") -$(info "ENABLE_PDE" : "$(ENABLE_PDE)") +$(info "INCLUDE_PDE" : "$(INCLUDE_PDE)") $(info "SONIC_DEBUGGING_ON" : "$(SONIC_DEBUGGING_ON)") $(info "SONIC_PROFILING_ON" : "$(SONIC_PROFILING_ON)") $(info "KERNEL_PROCURE_METHOD" : "$(KERNEL_PROCURE_METHOD)") @@ -925,7 +925,7 @@ $(addprefix $(TARGET_PATH)/, $(SONIC_INSTALLERS)) : $(TARGET_PATH)/% : \ export include_mgmt_framework="$(INCLUDE_MGMT_FRAMEWORK)" export include_iccpd="$(INCLUDE_ICCPD)" export pddf_support="$(PDDF_SUPPORT)" - export enable_pde="$(ENABLE_PDE)" + export include_pde="$(INCLUDE_PDE)" export shutdown_bgp_on_start="$(SHUTDOWN_BGP_ON_START)" export default_buffer_model="$(SONIC_BUFFER_MODEL)" export include_kubernetes="$(INCLUDE_KUBERNETES)" From 9ed8ebbc0e1b02bcc3f6edf89a3bb4a7d874a1a0 Mon Sep 17 00:00:00 2001 From: Geans Pin Date: Fri, 23 Jul 2021 00:10:14 -0700 Subject: [PATCH 26/28] Fix build err --- platform/broadcom/rules.dep | 1 - 1 file changed, 1 deletion(-) diff --git a/platform/broadcom/rules.dep b/platform/broadcom/rules.dep index 74f64c362b39..a55fe2ab95fc 100644 --- a/platform/broadcom/rules.dep +++ b/platform/broadcom/rules.dep @@ -22,7 +22,6 @@ include $(PLATFORM_PATH)/docker-pde.dep include $(PLATFORM_PATH)/sonic-pde-tests.dep endif include $(PLATFORM_PATH)/one-image.dep -include $(PLATFORM_PATH)/one-pde-image.dep include $(PLATFORM_PATH)/raw-image.dep include $(PLATFORM_PATH)/one-aboot.dep include $(PLATFORM_PATH)/libsaithrift-dev.dep From c79d04da326b5a2ee92b7fa97f1f5ced97e2c15d Mon Sep 17 00:00:00 2001 From: Geans Pin Date: Fri, 23 Jul 2021 03:08:32 -0700 Subject: [PATCH 27/28] Removed unused --- Makefile.work | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/Makefile.work b/Makefile.work index d80086fb6ec2..36cfa080fb7d 100644 --- a/Makefile.work +++ b/Makefile.work @@ -278,17 +278,6 @@ SONIC_BUILD_INSTRUCTION := make \ SLAVE_DIR=$(SLAVE_DIR) \ $(SONIC_OVERRIDE_BUILD_VARS) -PDESUBMODULES = src/sonic-linux-kernel \ - src/sonic-utilities \ - src/sonic-platform-common \ - src/sonic-swss-common \ - src/sonic-swss \ - src/sonic-py-swsssdk \ - src/redis-dump-load \ - src/sonic-sairedis \ - src/sonic-ztp \ - src/sonic-platform-daemons \ - src/sonic-platform-pde .PHONY: sonic-slave-build sonic-slave-bash init reset .DEFAULT_GOAL := all From 7895160b22eb07844a41539b10b21f4c7e0ba0b0 Mon Sep 17 00:00:00 2001 From: Geans Pin Date: Fri, 23 Jul 2021 07:52:37 -0700 Subject: [PATCH 28/28] Fix comment 2nd --- Makefile.work | 2 +- slave.mk | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/Makefile.work b/Makefile.work index 36cfa080fb7d..e1f98c68e897 100644 --- a/Makefile.work +++ b/Makefile.work @@ -247,7 +247,7 @@ SONIC_BUILD_INSTRUCTION := make \ SONIC_IMAGE_VERSION=$(SONIC_IMAGE_VERSION) \ ENABLE_DHCP_GRAPH_SERVICE=$(ENABLE_DHCP_GRAPH_SERVICE) \ ENABLE_ZTP=$(ENABLE_ZTP) \ - ENABLE_PDE=$(ENABLE_PDE) \ + INCLUDE_PDE=$(INCLUDE_PDE) \ SHUTDOWN_BGP_ON_START=$(SHUTDOWN_BGP_ON_START) \ INCLUDE_KUBERNETES=$(INCLUDE_KUBERNETES) \ KUBERNETES_VERSION=$(KUBERNETES_VERSION) \ diff --git a/slave.mk b/slave.mk index 03f03a6a6c2f..700775f7a8d8 100644 --- a/slave.mk +++ b/slave.mk @@ -1044,7 +1044,6 @@ $(addprefix $(TARGET_PATH)/, $(SONIC_INSTALLERS)) : $(TARGET_PATH)/% : \ DEBUG_IMG="$(INSTALL_DEBUG_TOOLS)" \ DEBUG_SRC_ARCHIVE_FILE="$(DBG_SRC_ARCHIVE_FILE)" \ - BUILD_TARGET="$@" \ USERNAME="$(USERNAME)" \ PASSWORD="$(PASSWORD)" \ TARGET_MACHINE=$(dep_machine) \ @@ -1068,7 +1067,6 @@ $(addprefix $(TARGET_PATH)/, $(SONIC_INSTALLERS)) : $(TARGET_PATH)/% : \ ./build_image.sh $(LOG) ) - $(foreach docker, $($*_DOCKERS), \ rm -f *$($(docker:-dbg.gz=.gz)_CONTAINER_NAME).sh rm -f $($(docker:-dbg.gz=.gz)_CONTAINER_NAME).service