Skip to content

Commit ff9e136

Browse files
authored
[smartswitch] Enable watchdog utility for DPUs (#22315)
* Do not disable watchdog on DPU * Address review comments
1 parent 64e91a9 commit ff9e136

File tree

1 file changed

+35
-1
lines changed

1 file changed

+35
-1
lines changed

files/image_config/watchdog-control/watchdog-control.sh

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
VERBOSE=no
44
WATCHDOG_UTIL="/usr/local/bin/watchdogutil"
55

6+
# read SONiC immutable variables
7+
[ -f /etc/sonic/sonic-environment ] && . /etc/sonic/sonic-environment
8+
PLATFORM=${PLATFORM:-$(sonic-db-cli CONFIG_DB HGET 'DEVICE_METADATA|localhost' platform)}
9+
PLATFORM_JSON="/usr/share/sonic/device/$PLATFORM/platform.json"
10+
611
function debug()
712
{
813
/usr/bin/logger "$0 : $1"
@@ -34,6 +39,19 @@ function getBootType()
3439
echo "${TYPE}"
3540
}
3641

42+
function is_smart_switch_dpu()
43+
{
44+
if [[ ! -f "$PLATFORM_JSON" ]]; then
45+
return 1
46+
fi
47+
48+
if jq -e 'has("DPU")' "$PLATFORM_JSON" > /dev/null; then
49+
return 0
50+
else
51+
return 1
52+
fi
53+
}
54+
3755
function disable_watchdog()
3856
{
3957
# Obtain boot type from kernel arguments
@@ -44,4 +62,20 @@ function disable_watchdog()
4462
fi
4563
}
4664

47-
disable_watchdog
65+
function enable_watchdog()
66+
{
67+
if [[ -x ${WATCHDOG_UTIL} ]]; then
68+
debug "Enabling Watchdog"
69+
${WATCHDOG_UTIL} arm
70+
fi
71+
}
72+
73+
if is_smart_switch_dpu; then
74+
# Keep watchdog enabled for smart switch DPUs
75+
# Smart switch DPUs uses ARM SBSA Generic Watchdog,
76+
# which is capable of monitoring the system in runtime.
77+
enable_watchdog
78+
else
79+
# Disable watchdog for all other platforms
80+
disable_watchdog
81+
fi

0 commit comments

Comments
 (0)