Skip to content

Commit

Permalink
[Mellanox|FFB]: Add support for Mellanox fast-fast boot in syncd (son…
Browse files Browse the repository at this point in the history
…ic-net#389)

* [mlnx|ffb] Add fast-fast boot option in syncd

Signed-off-by: Stepan Blyschak <[email protected]>

* [mlnx|ffb]: Add support of "config end" event for mlnx fast-fast boot

Signed-off-by: Volodymyr Samotiy <[email protected]>

* [mlnx|ffb]: Fix misspelled words for aspell check

Signed-off-by: Volodymyr Samotiy <[email protected]>

* [Mellanox|FFB]: Fix review comments

* Change naming convention from "fast-fast" to "fastfast"

Signed-off-by: Volodymyr Samotiy <[email protected]>

* [Mellanox|FFB]: Add misspelled word 'fastfast' to aspellcheck dictionary
  • Loading branch information
Volodymyr Samotiy authored and lguohan committed Dec 3, 2018
1 parent 8eca19c commit edeeda0
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 5 deletions.
15 changes: 13 additions & 2 deletions syncd/scripts/syncd_init_common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
}

Expand Down Expand Up @@ -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()
Expand Down
54 changes: 51 additions & 3 deletions syncd/syncd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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<swss::FieldValueTuple> 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();
Expand Down Expand Up @@ -3475,6 +3508,7 @@ int syncd_main(int argc, char **argv)
std::shared_ptr<swss::NotificationConsumer> restartQuery = std::make_shared<swss::NotificationConsumer>(dbAsic.get(), "RESTARTQUERY");
std::shared_ptr<swss::ConsumerTable> flexCounter = std::make_shared<swss::ConsumerTable>(dbFlexCounter.get(), FLEX_COUNTER_TABLE);
std::shared_ptr<swss::ConsumerTable> flexCounterGroup = std::make_shared<swss::ConsumerTable>(dbFlexCounter.get(), FLEX_COUNTER_GROUP_TABLE);
std::shared_ptr<swss::NotificationConsumer> ffb = std::make_shared<swss::NotificationConsumer>(dbAsic.get(), "MLNX_FFB");

/*
* At the end we cant use producer consumer concept since if one process
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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");

Expand Down Expand Up @@ -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);
Expand Down
5 changes: 5 additions & 0 deletions syncd/syncd.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions tests/aspell.en.pws
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ endl
enum
eth
ethernet
fastfast
fdb
FDB
fdbs
Expand Down Expand Up @@ -99,6 +100,7 @@ LOOPBACK
lua
MCAST
md
Mellanox
metadata
mlnx
mpls
Expand Down

0 comments on commit edeeda0

Please sign in to comment.