From bef2f3e6f632a6a1567740c985e552dd80a120e8 Mon Sep 17 00:00:00 2001 From: Junhua Zhai Date: Wed, 9 Nov 2022 09:58:25 +0800 Subject: [PATCH] [gbsyncd] Enable debug shell for BRCM broncos PHY (#12622) * Build docker-gbsyncd-broncos image * Correct typo in LIBSAI_BRONCOS_URL_PREFIX * Update docker-gbsyncd-broncos/Dockerfile.j2 * Enable debug shell support on docker-gbsyncd-broncos * Include bcmsh in docker-gbsyncd-broncos Why I did it In docker-gbsyncd-broncos image, enable debug shell support for BRCM broncos PHY. How I did it How to verify it Note: need enable attr SAI_SWITCH_ATTR_SWITCH_SHELL_ENABLE support in BCM PAI library # bcmsh Press Enter to show prompt. Press Ctrl+C to exit. NOTICE: Only one bcmsh or bcmcmd can connect to the shell at same time. BRCM:> help help List of available commands - h or help => Print command menu - l => Print list of active ports on the PHY - ps => Print port status => 1 -> Link status => 2 -> Link training failure status => 3 -> Link training RX status => 4 -> PRBS lock status => 5 -> PRBS lock loss status - rd => Read register contents - wr => Write register data - rrd => Raw read register contents using lanemap and if_side (line = 0, system = 1) - rwr => Raw write register data using lanemap and if_side (line = 0, system = 1) - fw or firmware => Print firmware version of the PHY - pd or port_dump => Dump port status - eyescan => Display eye scan - fec_status => Get fec status of the port - polarity => Set TX and RX polarity => 0xF, 0xFF, or 0xFFFF based on number of lanes => Line = 0, System = 1 =>_TX/RX Polarity bitmap of all lanes Each bit represents a lane number. E.g. Lane 0's polarity value (0 or 1) is populated in Bit 0. - polarity => Print TX and RX polarity - lb => Enable loopback on the port lb_value = 0 -> Disable, 1 -> PHY, 2 -> MAC - lb => Print loopback configuration of the port - prbs => Set/Get PRBS configuration => 1 -> Get PRBS state and polynomial 2 -> Set PRBS Polynomial, - PRBS Polynomial Please refer to phy/chip documentation for valid values 3 -> Enable PRBS => 0 Disable PRBS 1 Enable both PRBS Transmitter and Receiver 2 Enable PRBS Receiver 3 Enable PRBS Transmitter exit or q => Exit the diagnostic shell --- .../docker-gbsyncd-broncos/Dockerfile.j2 | 3 ++ .../components/docker-gbsyncd-broncos/bcmsh | 40 +++++++++++++++++++ .../critical_processes.j2 | 1 + .../supervisord.conf.j2 | 2 +- 4 files changed, 45 insertions(+), 1 deletion(-) create mode 100755 platform/components/docker-gbsyncd-broncos/bcmsh diff --git a/platform/components/docker-gbsyncd-broncos/Dockerfile.j2 b/platform/components/docker-gbsyncd-broncos/Dockerfile.j2 index 154c7735ce..ca7670acb6 100644 --- a/platform/components/docker-gbsyncd-broncos/Dockerfile.j2 +++ b/platform/components/docker-gbsyncd-broncos/Dockerfile.j2 @@ -27,11 +27,14 @@ debs/{{ deb }}{{' '}} COPY ["docker-init.sh", "/usr/bin/"] COPY ["start.sh", "/usr/bin/"] +COPY ["bcmsh", "/usr/bin/"] COPY ["critical_processes.j2", "/usr/share/sonic/templates"] COPY ["supervisord.conf.j2", "/usr/share/sonic/templates"] COPY ["files/supervisor-proc-exit-listener", "/usr/bin"] +COPY ["files/dsserve", "/usr/bin/"] +RUN chmod +x /usr/bin/dsserve ## Clean up RUN apt-get clean -y; apt-get autoclean -y; apt-get autoremove -y diff --git a/platform/components/docker-gbsyncd-broncos/bcmsh b/platform/components/docker-gbsyncd-broncos/bcmsh new file mode 100755 index 0000000000..bad7a10519 --- /dev/null +++ b/platform/components/docker-gbsyncd-broncos/bcmsh @@ -0,0 +1,40 @@ +#!/bin/bash +usage="$(basename "$0") [-h] [-q] [-t timeout] -- interactive shell for bcm service + +where: + -h show this help text + -t inactivity timeout in seconds (default 300 seconds, 0 for no timeout) + -q quite, no banner (default: verbose)" + +banner="Press Enter to show prompt. +Press Ctrl+C to exit. +NOTICE: Only one bcmsh or bcmcmd can connect to the shell at same time. +" + +# Default verbose +quiet=false +timeout=300 + +while getopts 'hqt:' option; do + case "$option" in + h) echo "$usage" + exit + ;; + q) quiet=true + ;; + t) timeout=$OPTARG + ;; + \?) printf "illegal option: -%s\n" "$OPTARG" >&2 + echo "$usage" >&2 + exit 1 + ;; + esac +done +shift $((OPTIND - 1)) + +if [ "$quiet" = false ]; then + echo "$banner" +fi + +/usr/bin/socat -T$timeout readline UNIX-CONNECT:/var/run/sswsyncd/sswgbsyncd.socket + diff --git a/platform/components/docker-gbsyncd-broncos/critical_processes.j2 b/platform/components/docker-gbsyncd-broncos/critical_processes.j2 index bdd6903c56..d1163a9c30 100644 --- a/platform/components/docker-gbsyncd-broncos/critical_processes.j2 +++ b/platform/components/docker-gbsyncd-broncos/critical_processes.j2 @@ -1 +1,2 @@ +program:dsserve program:syncd diff --git a/platform/components/docker-gbsyncd-broncos/supervisord.conf.j2 b/platform/components/docker-gbsyncd-broncos/supervisord.conf.j2 index c274315ef6..2ac52c22c2 100644 --- a/platform/components/docker-gbsyncd-broncos/supervisord.conf.j2 +++ b/platform/components/docker-gbsyncd-broncos/supervisord.conf.j2 @@ -33,7 +33,7 @@ dependent_startup_wait_for=rsyslogd:running [program:syncd] environment=BRONCOS_DEVICE_PATH=/usr/lib -command=/usr/bin/syncd -s -p /etc/sai.d/psai.profile -x /usr/share/sonic/hwsku/context_config.json -g 1 +command=/usr/bin/dsserve -f /var/run/sswsyncd/sswgbsyncd.socket /usr/bin/syncd --diag -s -p /etc/sai.d/psai.profile -x /usr/share/sonic/hwsku/context_config.json -g 1 priority=3 autostart=false autorestart=false