Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Mellanox|FFB]: Add support for Mellanox fast-fast boot in syncd #389

Merged
merged 5 commits into from
Dec 3, 2018
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can cause compatibility issue. image you are on old image and want to fastfast boot into new image. We need to be aware of this issue.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SONIC_BOOT_TYPE= [](start = 42, length = 16)

We should handle both cases for backward-compatible with 201803:

fast-reboot
SONIC_BOOT_TYPE=fast-reboot
Otherwise we cannot fast-reboot from 201803 into 201811.


case "$BOOT_TYPE" in
fast-reboot)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since you are breaking backward compatibility, I suggest to you to change to fast and remove -reboot.

FAST_REBOOT='yes'
;;
fastfast)
if [ -e /var/warmboot/issu_started ]; then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is this flag? why kernel cmdline is not enough?

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-> FAST_BOOT

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 @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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<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 @@ -3459,6 +3492,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 @@ -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);

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

Expand All @@ -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);
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
1 change: 1 addition & 0 deletions tests/aspell.en.pws
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ LOOPBACK
lua
MCAST
md
Mellanox
metadata
mlnx
mpls
Expand Down