From edeeda06012d580037ddd43a8f7ab9b94112fdf9 Mon Sep 17 00:00:00 2001 From: Volodymyr Samotiy Date: Mon, 3 Dec 2018 09:45:19 +0200 Subject: [PATCH] [Mellanox|FFB]: Add support for Mellanox fast-fast boot in syncd (#389) * [mlnx|ffb] Add fast-fast boot option in syncd Signed-off-by: Stepan Blyschak * [mlnx|ffb]: Add support of "config end" event for mlnx fast-fast boot Signed-off-by: Volodymyr Samotiy * [mlnx|ffb]: Fix misspelled words for aspell check Signed-off-by: Volodymyr Samotiy * [Mellanox|FFB]: Fix review comments * Change naming convention from "fast-fast" to "fastfast" Signed-off-by: Volodymyr Samotiy * [Mellanox|FFB]: Add misspelled word 'fastfast' to aspellcheck dictionary --- syncd/scripts/syncd_init_common.sh | 15 +++++++-- syncd/syncd.cpp | 54 ++++++++++++++++++++++++++++-- syncd/syncd.h | 5 +++ tests/aspell.en.pws | 2 ++ 4 files changed, 71 insertions(+), 5 deletions(-) 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 eeb110984..c803ea981 100644 --- a/syncd/syncd.cpp +++ b/syncd/syncd.cpp @@ -2925,7 +2925,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; @@ -2935,7 +2935,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; @@ -3034,6 +3034,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); @@ -3220,6 +3224,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(); @@ -3475,6 +3508,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 @@ -3520,7 +3554,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); @@ -3574,6 +3617,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"); @@ -3653,6 +3697,10 @@ int syncd_main(int argc, char **argv) status = sai_switch_api->set_switch_attribute(gSwitchId, &attr); } } + 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 019cfde9e..a2338dff2 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