From 9ed845158a0f104ccf020635c67e7b42ecac4023 Mon Sep 17 00:00:00 2001 From: Stepan Blyschak Date: Fri, 23 Nov 2018 14:30:27 +0000 Subject: [PATCH 1/5] [mlnx|ffb] Add fast-fast boot option in syncd Signed-off-by: Stepan Blyschak --- syncd/scripts/syncd_init_common.sh | 15 +++++++++++++-- syncd/syncd.cpp | 19 ++++++++++++++++--- syncd/syncd.h | 5 +++++ 3 files changed, 34 insertions(+), 5 deletions(-) diff --git a/syncd/scripts/syncd_init_common.sh b/syncd/scripts/syncd_init_common.sh index 5c0b8beae..d573dbf86 100755 --- a/syncd/scripts/syncd_init_common.sh +++ b/syncd/scripts/syncd_init_common.sh @@ -24,12 +24,21 @@ 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' ;; + fast-fast) + if [ -e /var/warmboot/issu_started ]; then + FAST_FAST_REBOOT='yes' + rm -f /var/warmboot/issu_started + fi + ;; *) FAST_REBOOT='no' + FAST_FAST_REBOOT='no' ;; esac @@ -55,6 +64,8 @@ function set_start_type() CMD_ARGS+=" -t warm" elif [ $FAST_REBOOT == "yes" ]; then CMD_ARGS+=" -t fast" + elif [ $FAST_FAST_REBOOT == "yes" ]; then + CMD_ARGS+=" -t fast-fast" fi } diff --git a/syncd/syncd.cpp b/syncd/syncd.cpp index 0c0ced126..091aeea41 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|fast-fast]] [-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|fast-fast 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) == "fast-fast") + { + options.startType = SAI_FAST_FAST_BOOT; + } else { SWSS_LOG_ERROR("unknown start type %s", optarg); @@ -3504,7 +3508,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_FAST_FAST_BOOT) + { + /* + * Mellanox SAI requieres 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); diff --git a/syncd/syncd.h b/syncd/syncd.h index 214239a7b..2bbf7c07e 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 'fast-fast' boot mode + */ +#define SAI_FAST_FAST_BOOT 3 #ifdef SAITHRIFT #define SWITCH_SAI_THRIFT_RPC_SERVER_PORT 9092 From 7d8114a3ac9aea47d166811c4bce05854d10f930 Mon Sep 17 00:00:00 2001 From: Volodymyr Samotiy Date: Fri, 23 Nov 2018 16:57:06 +0200 Subject: [PATCH 2/5] [mlnx|ffb]: Add support of "config end" event for mlnx fast-fast boot Signed-off-by: Volodymyr Samotiy --- syncd/scripts/syncd_init_common.sh | 1 - syncd/syncd.cpp | 35 ++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/syncd/scripts/syncd_init_common.sh b/syncd/scripts/syncd_init_common.sh index d573dbf86..471a4e616 100755 --- a/syncd/scripts/syncd_init_common.sh +++ b/syncd/scripts/syncd_init_common.sh @@ -33,7 +33,6 @@ case "$BOOT_TYPE" in fast-fast) if [ -e /var/warmboot/issu_started ]; then FAST_FAST_REBOOT='yes' - rm -f /var/warmboot/issu_started fi ;; *) diff --git a/syncd/syncd.cpp b/syncd/syncd.cpp index 091aeea41..dba978951 100644 --- a/syncd/syncd.cpp +++ b/syncd/syncd.cpp @@ -3210,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(); @@ -3463,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 @@ -3568,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"); @@ -3590,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); From a2bb7518885f275cefd0d4072cd1f82c800a0e31 Mon Sep 17 00:00:00 2001 From: Volodymyr Samotiy Date: Mon, 26 Nov 2018 12:42:01 +0000 Subject: [PATCH 3/5] [mlnx|ffb]: Fix misspelled words for aspell check Signed-off-by: Volodymyr Samotiy --- syncd/syncd.cpp | 2 +- tests/aspell.en.pws | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/syncd/syncd.cpp b/syncd/syncd.cpp index dba978951..49b6d480f 100644 --- a/syncd/syncd.cpp +++ b/syncd/syncd.cpp @@ -3541,7 +3541,7 @@ int syncd_main(int argc, char **argv) if (options.startType == SAI_FAST_FAST_BOOT) { /* - * Mellanox SAI requieres to pass SAI_WARM_BOOT as SAI_BOOT_KEY + * 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); diff --git a/tests/aspell.en.pws b/tests/aspell.en.pws index 3fa07dd3f..6fffabd12 100644 --- a/tests/aspell.en.pws +++ b/tests/aspell.en.pws @@ -99,6 +99,7 @@ LOOPBACK lua MCAST md +Mellanox metadata mlnx mpls From 3f1433f042fa4fa6065e8a33fe56279c76029f4c Mon Sep 17 00:00:00 2001 From: Volodymyr Samotiy Date: Fri, 30 Nov 2018 13:51:22 +0000 Subject: [PATCH 4/5] [Mellanox|FFB]: Fix review comments * Change naming convention from "fast-fast" to "fastfast" Signed-off-by: Volodymyr Samotiy --- syncd/scripts/syncd_init_common.sh | 11 ++++++----- syncd/syncd.cpp | 10 +++++----- syncd/syncd.h | 4 ++-- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/syncd/scripts/syncd_init_common.sh b/syncd/scripts/syncd_init_common.sh index 471a4e616..2d8ee6662 100755 --- a/syncd/scripts/syncd_init_common.sh +++ b/syncd/scripts/syncd_init_common.sh @@ -30,14 +30,14 @@ case "$BOOT_TYPE" in fast-reboot) FAST_REBOOT='yes' ;; - fast-fast) + fastfast) if [ -e /var/warmboot/issu_started ]; then - FAST_FAST_REBOOT='yes' + FASTFAST_REBOOT='yes' fi ;; *) FAST_REBOOT='no' - FAST_FAST_REBOOT='no' + FASTFAST_REBOOT='no' ;; esac @@ -63,8 +63,8 @@ function set_start_type() CMD_ARGS+=" -t warm" elif [ $FAST_REBOOT == "yes" ]; then CMD_ARGS+=" -t fast" - elif [ $FAST_FAST_REBOOT == "yes" ]; then - CMD_ARGS+=" -t fast-fast" + elif [ $FASTFAST_REBOOT == "yes" ]; then + CMD_ARGS+=" -t fastfast" fi } @@ -97,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 49b6d480f..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|fast-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|fast-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,9 +3028,9 @@ void handleCmdLine(int argc, char **argv) { options.startType = SAI_FAST_BOOT; } - else if (std::string(optarg) == "fast-fast") + else if (std::string(optarg) == "fastfast") { - options.startType = SAI_FAST_FAST_BOOT; + options.startType = SAI_FASTFAST_BOOT; } else { @@ -3538,7 +3538,7 @@ int syncd_main(int argc, char **argv) options.startType = SAI_COLD_BOOT; } - if (options.startType == SAI_FAST_FAST_BOOT) + if (options.startType == SAI_FASTFAST_BOOT) { /* * Mellanox SAI requires to pass SAI_WARM_BOOT as SAI_BOOT_KEY diff --git a/syncd/syncd.h b/syncd/syncd.h index 2bbf7c07e..8f74c07b8 100644 --- a/syncd/syncd.h +++ b/syncd/syncd.h @@ -57,9 +57,9 @@ extern "C" { #define SAI_FAST_BOOT 2 /** * A special type of boot used by Mellanox platforms - * to start in 'fast-fast' boot mode + * to start in 'fastfast' boot mode */ -#define SAI_FAST_FAST_BOOT 3 +#define SAI_FASTFAST_BOOT 3 #ifdef SAITHRIFT #define SWITCH_SAI_THRIFT_RPC_SERVER_PORT 9092 From 99d8c38c68be951904b179afbdf7bb2e859c48ee Mon Sep 17 00:00:00 2001 From: Volodymyr Samotiy Date: Sat, 1 Dec 2018 14:05:36 +0000 Subject: [PATCH 5/5] [Mellanox|FFB]: Add misspelled word 'fastfast' to aspellcheck dictionary --- tests/aspell.en.pws | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/aspell.en.pws b/tests/aspell.en.pws index 6fffabd12..e529f033d 100644 --- a/tests/aspell.en.pws +++ b/tests/aspell.en.pws @@ -59,6 +59,7 @@ endl enum eth ethernet +fastfast fdb FDB fdbs