Skip to content

Commit

Permalink
[mellanox|ffb] use system level warm reboot for Mellanox fastfast boot (
Browse files Browse the repository at this point in the history
#400)

* [mellanox|ffb] use system level warm reboot for Mellanox fastfast boot

Signed-off-by: Stepan Blyschak <stepanb@mellanox.com>

* [mellanox|ffb] remove platform check code

Signed-off-by: Stepan Blyschak <stepanb@mellanox.com>

* [mellanox|ffb] rename function to onApplyViewInFastFastBoot, check for error status

Signed-off-by: Stepan Blyschak <stepanb@mellanox.com>

* [mellanox|ffb] Set UNINIT_DATA_PLANE_ON_REMOVAL in warm shutdown case as well

Signed-off-by: Stepan Blyschak <stepanb@mellanox.com>

* [mellanox|ffb] build mellanox with -DSAI_SWITCH_ATTR_UNINIT_DATA_PLANE_ON_REMOVAL

Signed-off-by: Stepan Blyschak <stepanb@mellanox.com>

* [mellanox|ffb] rename 'SAI_SWITCH_ATTR_UNINIT_DATA_PLANE_ON_REMOVAL' -> 'SAI_SUPPORT_UNINIT_DATA_PLANE_ON_REMOVAL' to avoid overlapping with SAI attribute

Signed-off-by: Stepan Blyschak <stepanb@mellanox.com>
  • Loading branch information
stepanblyschak authored and lguohan committed Jan 7, 2019
1 parent e90bb63 commit 60f97c3
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 44 deletions.
1 change: 1 addition & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ AC_PROG_LIBTOOL
AC_HEADER_STDC

AM_CONDITIONAL(sonic_asic_platform_barefoot, test x$CONFIGURED_PLATFORM = xbarefoot)
AM_CONDITIONAL(sonic_asic_platform_mellanox, test x$CONFIGURED_PLATFORM = xmellanox)

AC_ARG_ENABLE(debug,
[ --enable-debug turn on debugging],
Expand Down
4 changes: 4 additions & 0 deletions syncd/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ syncd_CPPFLAGS += -DSAITHRIFT=yes
syncd_LDADD += -lrpcserver -lthrift
endif

if sonic_asic_platform_mellanox
syncd_CPPFLAGS += -DSAI_SUPPORT_UNINIT_DATA_PLANE_ON_REMOVAL
endif

syncd_request_shutdown_SOURCES = syncd_request_shutdown.cpp
syncd_request_shutdown_CPPFLAGS = $(DBGFLAGS) $(AM_CPPFLAGS) $(CFLAGS_COMMON)
syncd_request_shutdown_LDADD = -lhiredis -lswsscommon -lpthread
Expand Down
2 changes: 1 addition & 1 deletion syncd/scripts/syncd_init_common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ case "$BOOT_TYPE" in
FAST_REBOOT='yes'
;;
fastfast)
if [ -e /var/warmboot/issu_started ]; then
if [ -e /var/warmboot/warm-starting ]; then
FASTFAST_REBOOT='yes'
fi
;;
Expand Down
1 change: 0 additions & 1 deletion syncd/scripts/syncd_start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
# Source the file that holds common code for systemd and supervisord
. /usr/bin/syncd_init_common.sh


config_syncd

exec ${CMD} ${CMD_ARGS}
Expand Down
80 changes: 38 additions & 42 deletions syncd/syncd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1626,6 +1626,28 @@ void InspectAsic()
}
}

sai_status_t onApplyViewInFastFastBoot()
{
SWSS_LOG_ENTER();

sai_switch_api_t* sai_switch_api = nullptr;
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());
}

return status;
}

sai_status_t notifySyncd(
_In_ const std::string& op)
{
Expand Down Expand Up @@ -1657,6 +1679,8 @@ sai_status_t notifySyncd(
{
SWSS_LOG_NOTICE("very first run is TRUE, op = %s", op.c_str());

sai_status_t status = SAI_STATUS_SUCCESS;

/*
* On the very first start of syncd, "compile" view is directly applied
* on device, since it will make it easier to switch to new asic state
Expand Down Expand Up @@ -1686,16 +1710,22 @@ sai_status_t notifySyncd(

g_asicInitViewMode = false;

if (options.startType == SAI_FASTFAST_BOOT)
{
/* fastfast boot configuration end */
status = onApplyViewInFastFastBoot();
}

SWSS_LOG_NOTICE("setting very first run to FALSE, op = %s", op.c_str());
}
else
{
SWSS_LOG_THROW("unknown operation: %s", op.c_str());
}

sendNotifyResponse(SAI_STATUS_SUCCESS);
sendNotifyResponse(status);

return SAI_STATUS_SUCCESS;
return status;
}

if (op == SYNCD_INIT_VIEW)
Expand Down Expand Up @@ -3246,35 +3276,6 @@ 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 @@ -3530,7 +3531,6 @@ 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 All @@ -3543,7 +3543,8 @@ int syncd_main(int argc, char **argv)

g_veryFirstRun = isVeryFirstRun();

if (swss::WarmStart::isWarmStart())
/* ignore warm logic here if syncd starts in Mellanox fastfast boot mode */
if (swss::WarmStart::isWarmStart() && (options.startType != SAI_FASTFAST_BOOT))
{
options.startType = SAI_WARM_BOOT;
}
Expand Down Expand Up @@ -3580,7 +3581,7 @@ int syncd_main(int argc, char **argv)
{
/*
* Mellanox SAI requires to pass SAI_WARM_BOOT as SAI_BOOT_KEY
* to start 'fast-fast'
* to start 'fastfast'
*/
gProfileMap[SAI_KEY_BOOT_TYPE] = std::to_string(SAI_WARM_BOOT);
} else {
Expand Down Expand Up @@ -3639,7 +3640,6 @@ 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 @@ -3728,10 +3728,6 @@ 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 Expand Up @@ -3789,11 +3785,11 @@ int syncd_main(int argc, char **argv)

SWSS_LOG_NOTICE("Removing the switch gSwitchId=0x%lx", gSwitchId);

#ifdef SAI_SWITCH_ATTR_UNINIT_DATA_PLANE_ON_REMOVAL
#ifdef SAI_SUPPORT_UNINIT_DATA_PLANE_ON_REMOVAL

if (shutdownType == SYNCD_RESTART_TYPE_FAST)
if (shutdownType == SYNCD_RESTART_TYPE_FAST || shutdownType == SYNCD_RESTART_TYPE_WARM)
{
SWSS_LOG_NOTICE("Fast Reboot requested, keeping data plane running");
SWSS_LOG_NOTICE("Fast/warm reboot requested, keeping data plane running");

sai_attribute_t attr;

Expand Down

0 comments on commit 60f97c3

Please sign in to comment.