diff --git a/syncd/scripts/syncd_init_common.sh b/syncd/scripts/syncd_init_common.sh index 5c0b8beae..2d8ee6662 100755 --- a/syncd/scripts/syncd_init_common.sh +++ b/syncd/scripts/syncd_init_common.sh @@ -24,12 +24,20 @@ fi # Use temporary view between init and apply CMD_ARGS+=" -u" -case "$(cat /proc/cmdline)" in - *fast-reboot*) +BOOT_TYPE="$(cat /proc/cmdline | grep -o 'SONIC_BOOT_TYPE=\S*' | cut -d'=' -f2)" + +case "$BOOT_TYPE" in + fast-reboot) FAST_REBOOT='yes' ;; + fastfast) + if [ -e /var/warmboot/issu_started ]; then + FASTFAST_REBOOT='yes' + fi + ;; *) FAST_REBOOT='no' + FASTFAST_REBOOT='no' ;; esac @@ -55,6 +63,8 @@ function set_start_type() CMD_ARGS+=" -t warm" elif [ $FAST_REBOOT == "yes" ]; then CMD_ARGS+=" -t fast" + elif [ $FASTFAST_REBOOT == "yes" ]; then + CMD_ARGS+=" -t fastfast" fi } @@ -87,6 +97,7 @@ config_syncd_mlnx() # Write MAC address into /tmp/profile file. cat $HWSKU_DIR/sai.profile > /tmp/sai.profile echo "DEVICE_MAC_ADDRESS=$ALIGNED_MAC_ADDRESS" >> /tmp/sai.profile + echo "SAI_WARM_BOOT_WRITE_FILE=/var/warmboot/" >> /tmp/sai.profile } config_syncd_centec() diff --git a/syncd/syncd.cpp b/syncd/syncd.cpp index 0c0ced126..7bec79338 100644 --- a/syncd/syncd.cpp +++ b/syncd/syncd.cpp @@ -2919,7 +2919,7 @@ void printUsage() { SWSS_LOG_ENTER(); - std::cout << "Usage: syncd [-N] [-U] [-d] [-p profile] [-i interval] [-t [cold|warm|fast]] [-h] [-u] [-S]" << std::endl; + std::cout << "Usage: syncd [-N] [-U] [-d] [-p profile] [-i interval] [-t [cold|warm|fast|fastfast]] [-h] [-u] [-S]" << std::endl; std::cout << " -N --nocounters" << std::endl; std::cout << " Disable counter thread" << std::endl; std::cout << " -d --diag" << std::endl; @@ -2929,7 +2929,7 @@ void printUsage() std::cout << " -i --countersInterval interval" << std::endl; std::cout << " Provide counter thread interval" << std::endl; std::cout << " -t --startType type" << std::endl; - std::cout << " Specify cold|warm|fast start type" << std::endl; + std::cout << " Specify cold|warm|fast|fastfast start type" << std::endl; std::cout << " -u --useTempView:" << std::endl; std::cout << " Use temporary view between init and apply" << std::endl; std::cout << " -S --disableExitSleep" << std::endl; @@ -3028,6 +3028,10 @@ void handleCmdLine(int argc, char **argv) { options.startType = SAI_FAST_BOOT; } + else if (std::string(optarg) == "fastfast") + { + options.startType = SAI_FASTFAST_BOOT; + } else { SWSS_LOG_ERROR("unknown start type %s", optarg); @@ -3206,6 +3210,35 @@ syncd_restart_type_t handleRestartQuery(swss::NotificationConsumer &restartQuery return SYNCD_RESTART_TYPE_COLD; } +void handleFfbEvent(swss::NotificationConsumer &ffb) +{ + SWSS_LOG_ENTER(); + + std::string op; + std::string data; + std::vector values; + + ffb.pop(op, data, values); + + if ((op == "SET") && (data == "ISSU_END")) + { + sai_switch_api_t *sai_switch_api = NULL; + sai_api_query(SAI_API_SWITCH, (void**)&sai_switch_api); + + sai_attribute_t attr; + + attr.id = SAI_SWITCH_ATTR_FAST_API_ENABLE; + attr.value.booldata = false; + + sai_status_t status = sai_switch_api->set_switch_attribute(gSwitchId, &attr); + + if (status != SAI_STATUS_SUCCESS) + { + SWSS_LOG_ERROR("Failed to set SAI_SWITCH_ATTR_FAST_API_ENABLE=false: %s", sai_serialize_status(status).c_str()); + } + } +} + bool isVeryFirstRun() { SWSS_LOG_ENTER(); @@ -3459,6 +3492,7 @@ int syncd_main(int argc, char **argv) std::shared_ptr restartQuery = std::make_shared(dbAsic.get(), "RESTARTQUERY"); std::shared_ptr flexCounter = std::make_shared(dbFlexCounter.get(), FLEX_COUNTER_TABLE); std::shared_ptr flexCounterGroup = std::make_shared(dbFlexCounter.get(), FLEX_COUNTER_GROUP_TABLE); + std::shared_ptr ffb = std::make_shared(dbAsic.get(), "MLNX_FFB"); /* * At the end we cant use producer consumer concept since if one process @@ -3504,7 +3538,16 @@ int syncd_main(int argc, char **argv) options.startType = SAI_COLD_BOOT; } - gProfileMap[SAI_KEY_BOOT_TYPE] = std::to_string(options.startType); + if (options.startType == SAI_FASTFAST_BOOT) + { + /* + * Mellanox SAI requires to pass SAI_WARM_BOOT as SAI_BOOT_KEY + * to start 'fast-fast' + */ + gProfileMap[SAI_KEY_BOOT_TYPE] = std::to_string(SAI_WARM_BOOT); + } else { + gProfileMap[SAI_KEY_BOOT_TYPE] = std::to_string(options.startType); + } sai_status_t status = sai_api_initialize(0, (sai_service_method_table_t*)&test_services); @@ -3555,6 +3598,7 @@ int syncd_main(int argc, char **argv) s.addSelectable(restartQuery.get()); s.addSelectable(flexCounter.get()); s.addSelectable(flexCounterGroup.get()); + s.addSelectable(ffb.get()); SWSS_LOG_NOTICE("starting main loop"); @@ -3577,6 +3621,10 @@ int syncd_main(int argc, char **argv) shutdownType = handleRestartQuery(*restartQuery); break; } + else if (sel == ffb.get()) + { + handleFfbEvent(*ffb); + } else if (sel == flexCounter.get()) { processFlexCounterEvent(*(swss::ConsumerTable*)sel); diff --git a/syncd/syncd.h b/syncd/syncd.h index 214239a7b..8f74c07b8 100644 --- a/syncd/syncd.h +++ b/syncd/syncd.h @@ -55,6 +55,11 @@ extern "C" { #define SAI_COLD_BOOT 0 #define SAI_WARM_BOOT 1 #define SAI_FAST_BOOT 2 +/** + * A special type of boot used by Mellanox platforms + * to start in 'fastfast' boot mode + */ +#define SAI_FASTFAST_BOOT 3 #ifdef SAITHRIFT #define SWITCH_SAI_THRIFT_RPC_SERVER_PORT 9092 diff --git a/tests/aspell.en.pws b/tests/aspell.en.pws index 3fa07dd3f..e529f033d 100644 --- a/tests/aspell.en.pws +++ b/tests/aspell.en.pws @@ -59,6 +59,7 @@ endl enum eth ethernet +fastfast fdb FDB fdbs @@ -99,6 +100,7 @@ LOOPBACK lua MCAST md +Mellanox metadata mlnx mpls