summaryrefslogtreecommitdiff
path: root/meta-facebook
diff options
context:
space:
mode:
authorPotin Lai <potin.lai@quantatw.com>2023-04-07 11:15:47 +0300
committerPatrick Williams <patrick@stwcx.xyz>2023-04-11 21:52:28 +0300
commit7bb0c21b18e6716b8f0937c620b1c43cd85f0175 (patch)
tree6cfb4e04f2738ec9e3ba9c41ae37f7e9cfeda468 /meta-facebook
parent7cbff67c14e1d33d2d77dd4b7adcf42426d64a1e (diff)
downloadopenbmc-7bb0c21b18e6716b8f0937c620b1c43cd85f0175.tar.xz
meta-bletchley: add bletchley-net-util
Add bletchley-net-util for link status checking and port registers dumping. Test results: - show link status ``` root@bmc:~# bletchley-net-util --link-st ======================================== Link Status ======================================== Switch: Port 10 (BMC): up Port 3 (SLED1): down Port 2 (SLED2): down Port 1 (SLED3): down Port 7 (SLED4): up Port 6 (SLED5): down Port 5 (SLED6): down Retimer: Inner Port (XFI): up Outer Port (SFI): up ======================================== ``` - show port registers dumping ``` root@bmc:~# bletchley-net-util --port-reg-dump ======================================== Port 10 (BMC) **************************************** [00]: 0F4D [01]: 0003 ... [1E]: 0000 [1F]: 005D ======================================== ======================================== Port 3 (SLED1) **************************************** [00]: 100F [01]: 0003 ... [1E]: 0000 [1F]: 0000 ======================================== ======================================== Port 2 (SLED2) **************************************** [00]: 100F [01]: 0003 ... [1E]: 0000 [1F]: 0000 ======================================== ======================================== Port 1 (SLED3) **************************************** [00]: 100F [01]: 0003 ... [1E]: 0000 [1F]: 0000 ======================================== ======================================== Port 7 (SLED4) **************************************** [00]: DE4F [01]: 0003 ... [1E]: 0000 [1F]: 0166 ======================================== ======================================== Port 6 (SLED5) **************************************** [00]: 100F [01]: 0003 ... [1E]: 0000 [1F]: 0000 ======================================== ======================================== Port 5 (SLED6) **************************************** [00]: 100F [01]: 0003 ... [1E]: 0000 [1F]: 0000 ======================================== ``` Signed-off-by: Potin Lai <potin.lai@quantatw.com> Change-Id: Ic4464c0b466b4d6c02246d013fc4d99ca857cbdc
Diffstat (limited to 'meta-facebook')
-rw-r--r--meta-facebook/meta-bletchley/recipes-bletchley/plat-tools/bletchley-common-tool_0.1.bb2
-rw-r--r--meta-facebook/meta-bletchley/recipes-bletchley/plat-tools/files/bletchley-net-util102
2 files changed, 104 insertions, 0 deletions
diff --git a/meta-facebook/meta-bletchley/recipes-bletchley/plat-tools/bletchley-common-tool_0.1.bb b/meta-facebook/meta-bletchley/recipes-bletchley/plat-tools/bletchley-common-tool_0.1.bb
index 3b7ba82cdb..afe3791351 100644
--- a/meta-facebook/meta-bletchley/recipes-bletchley/plat-tools/bletchley-common-tool_0.1.bb
+++ b/meta-facebook/meta-bletchley/recipes-bletchley/plat-tools/bletchley-common-tool_0.1.bb
@@ -10,6 +10,7 @@ SRC_URI += " \
file://bletchley-system-state-init \
file://bletchley-system-state-init@.service \
file://bletchley-usbmux-util \
+ file://bletchley-net-util \
"
do_install() {
@@ -18,6 +19,7 @@ do_install() {
install -d ${D}${bindir}
install -m 0755 ${WORKDIR}/bletchley-usbmux-util ${D}${bindir}
+ install -m 0755 ${WORKDIR}/bletchley-net-util ${D}${bindir}
}
diff --git a/meta-facebook/meta-bletchley/recipes-bletchley/plat-tools/files/bletchley-net-util b/meta-facebook/meta-bletchley/recipes-bletchley/plat-tools/files/bletchley-net-util
new file mode 100644
index 0000000000..4127b19133
--- /dev/null
+++ b/meta-facebook/meta-bletchley/recipes-bletchley/plat-tools/files/bletchley-net-util
@@ -0,0 +1,102 @@
+#!/bin/bash
+
+declare -a PORT_NUM_MAP=(10 3 2 1 7 6 5)
+declare -a PORT_NAME_MAP=(BMC SLED1 SLED2 SLED3 SLED4 SLED5 SLED6)
+SWITCH_MDIO_BUS="1e650000.mdio-1"
+
+INNER_PORT_DEV_ID="4"
+OUTER_PORT_DEV_ID="3"
+RETIMER_MDIO_BUS="1e650018.mdio-1"
+
+get_switch_port_link_st()
+{
+ local port_phy_id=$1
+
+ if PORT_ST_VAL="$(mdio "$SWITCH_MDIO_BUS" phy "$port_phy_id" 0x00)"; then
+ PORT_ST_VAL="${PORT_ST_VAL:2}"
+ if [ "$((16#$PORT_ST_VAL & 16#0800))" -eq "0" ]; then
+ PORT_ST="down"
+ else
+ PORT_ST="up"
+ fi
+ else
+ PORT_ST="mdio failed"
+ fi
+ echo "${PORT_ST}"
+}
+
+get_retimer_port_link_st()
+{
+ local port_dev_id=$1
+
+ if PORT_ST_VAL="$(mdio "$RETIMER_MDIO_BUS" mmd 0:"$port_dev_id" 0x9002)"; then
+ PORT_ST_VAL="${PORT_ST_VAL:2}"
+ if [ "$((16#$PORT_ST_VAL & 16#0004))" -eq "0" ]; then
+ PORT_ST="down"
+ else
+ PORT_ST="up"
+ fi
+ else
+ PORT_ST="mdio failed"
+ fi
+ echo "${PORT_ST}"
+}
+
+get_port_link_st()
+{
+ printf "========================================\n"
+ printf "Link Status\n"
+ printf "========================================\n"
+ printf "Switch:\n"
+ for port_phy in {0..6}
+ do
+ printf " Port %d (%s): %s\n" "${PORT_NUM_MAP[port_phy]}" "${PORT_NAME_MAP[port_phy]}" "$(get_switch_port_link_st "${PORT_NUM_MAP[port_phy]}")"
+ done
+ printf "\n"
+ printf "Retimer:\n"
+ printf " Inner Port (XFI): %s\n" "$(get_retimer_port_link_st "${INNER_PORT_DEV_ID}")"
+ printf " Outer Port (SFI): %s\n" "$(get_retimer_port_link_st "${OUTER_PORT_DEV_ID}")"
+ printf "========================================\n\n"
+}
+
+get_switch_port_reg_dump()
+{
+ for port_phy in {0..6}
+ do
+ printf "========================================\n"
+ printf "Port %d (%s)\n" "${PORT_NUM_MAP[port_phy]}" "${PORT_NAME_MAP[port_phy]}"
+ printf "****************************************\n"
+ for reg_offset in {0..31}
+ do
+ printf "[%02X]: %04X\n" "$reg_offset" "$(mdio "$SWITCH_MDIO_BUS" phy "${PORT_NUM_MAP[port_phy]}" "$reg_offset")"
+ done
+ printf "========================================\n\n"
+ done
+}
+
+print_help()
+{
+ echo "Usage:"
+ echo " $0 <COMMAND>"
+ echo ""
+ echo "COMMAND:"
+ echo " --link-st"
+ echo " show link status"
+ echo ""
+ echo " --port-reg-dump"
+ echo " port registers dump"
+ echo ""
+}
+
+ACTION_CMD="$1"
+
+if [[ ${ACTION_CMD} =~ -h|--help ]]; then
+ print_help
+elif [ "${ACTION_CMD}" = "--link-st" ]; then
+ get_port_link_st
+elif [ "${ACTION_CMD}" = "--port-reg-dump" ]; then
+ get_switch_port_reg_dump
+else
+ echo "Unknow command: $ACTION_CMD"
+ print_help
+fi