@@ -5,6 +5,8 @@ declare -r EXIT_ERROR=1
55declare -r WATCHDOG_UTIL=" /usr/local/bin/watchdogutil"
66declare -r PRE_REBOOT_HOOK=" pre_reboot_hook"
77
8+ source reboot_smartswitch_helper
9+
810DEVPATH=" /usr/share/sonic/device"
911PLAT_REBOOT=" platform_reboot"
1012PLATFORM_UPDATE_REBOOT_CAUSE=" platform_update_reboot_cause"
@@ -37,10 +39,16 @@ EXIT_NEXT_IMAGE_NOT_EXISTS=4
3739EXIT_SONIC_INSTALLER_VERIFY_REBOOT=21
3840EXIT_PLATFORM_FW_AU_FAILURE=22
3941PLATFORM_FWUTIL_AU_REBOOT_HANDLE=" platform_fw_au_reboot_handle"
42+ PLATFORM_JSON_FILE=" platform.json"
43+ PLATFORM_JSON_PATH=" ${DEVPATH} /${PLATFORM} /${PLATFORM_JSON_FILE} "
4044REBOOT_SCRIPT_NAME=$( basename $0 )
4145REBOOT_TYPE=" ${REBOOT_SCRIPT_NAME} "
4246TAG_LATEST=no
4347REBOOT_FLAGS=" "
48+ SMART_SWITCH=" no"
49+ DPU_MODULE_NAME=" "
50+ REBOOT_DPU=" no"
51+ PRE_SHUTDOWN=" no"
4452
4553function debug()
4654{
@@ -64,6 +72,9 @@ function stop_pmon_service()
6472{
6573 CONTAINER_STOP_RC=0
6674 debug " Stopping pmon docker"
75+ if [[ " ${PRE_SHUTDOWN} " == " yes" ]]; then
76+ systemctl disable pmon
77+ fi
6778 systemctl stop pmon || debug " Ignore stopping pmon error $? "
6879 docker kill pmon & > /dev/null || CONTAINER_STOP_RC=$?
6980 if [[ CONTAINER_STOP_RC -ne 0 ]]; then
@@ -128,6 +139,8 @@ function show_help_and_exit()
128139 echo " "
129140 echo " Available options:"
130141 echo " -h, -? : getting this help"
142+ echo " -d : DPU module name on a smart switch, option is invalid when on DPU"
143+ echo " -p : Pre-shutdown steps on DPU, invalid on NPU"
131144
132145 exit ${EXIT_SUCCESS}
133146}
@@ -154,7 +167,7 @@ function reboot_pre_check()
154167 ${DEVPATH} /${PLATFORM} /${PLATFORM_REBOOT_PRE_CHECK}
155168 [[ $? -ne 0 ]] && exit $?
156169 fi
157-
170+
158171 # Verify the next image by sonic-installer
159172 local message=$( sonic-installer verify-next-image 2>&1 )
160173 if [ $? -ne 0 ]; then
@@ -178,7 +191,7 @@ function check_conflict_boot_in_fw_update()
178191
179192function parse_options()
180193{
181- while getopts " h?vf " opt; do
194+ while getopts " h?vfpd: " opt; do
182195 case ${opt} in
183196 h|\? )
184197 show_help_and_exit
@@ -192,6 +205,13 @@ function parse_options()
192205 f )
193206 REBOOT_FLAGS+=" -f"
194207 ;;
208+ d )
209+ REBOOT_DPU=" yes"
210+ DPU_MODULE_NAME=" $OPTARG "
211+ ;;
212+ p )
213+ PRE_SHUTDOWN=" yes"
214+ ;;
195215 esac
196216 done
197217}
225245
226246debug " User requested rebooting device ..."
227247
248+ handle_smart_switch " $REBOOT_DPU " " $PRE_SHUTDOWN " " $DPU_MODULE_NAME "
249+ smart_switch_result=$?
250+ if [[ $smart_switch_result -ne 0 ]]; then
251+ exit $smart_switch_result
252+ fi
253+
254+ # On a smartswitch, complete the DPU reboot and exit
255+ smartswitch=$( is_smartswitch)
256+ if [ " $smartswitch " == " True" ] && [ " $REBOOT_DPU " == " yes" ]; then
257+ exit $smart_switch_result
258+ fi
259+
228260check_conflict_boot_in_fw_update
229261
230262setup_reboot_variables
@@ -287,6 +319,11 @@ if [ -x ${WATCHDOG_UTIL} ]; then
287319 ${WATCHDOG_UTIL} arm
288320fi
289321
322+ if [[ " ${PRE_SHUTDOWN} " == " yes" ]]; then
323+ echo " ${DPU_MODULE_NAME} pre-shutdown steps are completed"
324+ exit ${EXIT_SUCCESS}
325+ fi
326+
290327if [ -x ${DEVPATH} /${PLATFORM} /${PLAT_REBOOT} ]; then
291328 VERBOSE=yes debug " Rebooting with platform ${PLATFORM} specific tool ..."
292329 ${DEVPATH} /${PLATFORM} /${PLAT_REBOOT} $@
0 commit comments