Skip to content

Commit 60f97c3

Browse files
stepanblyschaklguohan
authored andcommitted
[mellanox|ffb] use system level warm reboot for Mellanox fastfast boot (#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>
1 parent e90bb63 commit 60f97c3

File tree

5 files changed

+44
-44
lines changed

5 files changed

+44
-44
lines changed

configure.ac

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ AC_PROG_LIBTOOL
1212
AC_HEADER_STDC
1313

1414
AM_CONDITIONAL(sonic_asic_platform_barefoot, test x$CONFIGURED_PLATFORM = xbarefoot)
15+
AM_CONDITIONAL(sonic_asic_platform_mellanox, test x$CONFIGURED_PLATFORM = xmellanox)
1516

1617
AC_ARG_ENABLE(debug,
1718
[ --enable-debug turn on debugging],

syncd/Makefile.am

+4
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ syncd_CPPFLAGS += -DSAITHRIFT=yes
3737
syncd_LDADD += -lrpcserver -lthrift
3838
endif
3939

40+
if sonic_asic_platform_mellanox
41+
syncd_CPPFLAGS += -DSAI_SUPPORT_UNINIT_DATA_PLANE_ON_REMOVAL
42+
endif
43+
4044
syncd_request_shutdown_SOURCES = syncd_request_shutdown.cpp
4145
syncd_request_shutdown_CPPFLAGS = $(DBGFLAGS) $(AM_CPPFLAGS) $(CFLAGS_COMMON)
4246
syncd_request_shutdown_LDADD = -lhiredis -lswsscommon -lpthread

syncd/scripts/syncd_init_common.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ case "$BOOT_TYPE" in
3131
FAST_REBOOT='yes'
3232
;;
3333
fastfast)
34-
if [ -e /var/warmboot/issu_started ]; then
34+
if [ -e /var/warmboot/warm-starting ]; then
3535
FASTFAST_REBOOT='yes'
3636
fi
3737
;;

syncd/scripts/syncd_start.sh

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
# Source the file that holds common code for systemd and supervisord
77
. /usr/bin/syncd_init_common.sh
88

9-
109
config_syncd
1110

1211
exec ${CMD} ${CMD_ARGS}

syncd/syncd.cpp

+38-42
Original file line numberDiff line numberDiff line change
@@ -1626,6 +1626,28 @@ void InspectAsic()
16261626
}
16271627
}
16281628

1629+
sai_status_t onApplyViewInFastFastBoot()
1630+
{
1631+
SWSS_LOG_ENTER();
1632+
1633+
sai_switch_api_t* sai_switch_api = nullptr;
1634+
sai_api_query(SAI_API_SWITCH, (void**)&sai_switch_api);
1635+
1636+
sai_attribute_t attr;
1637+
1638+
attr.id = SAI_SWITCH_ATTR_FAST_API_ENABLE;
1639+
attr.value.booldata = false;
1640+
1641+
sai_status_t status = sai_switch_api->set_switch_attribute(gSwitchId, &attr);
1642+
1643+
if (status != SAI_STATUS_SUCCESS)
1644+
{
1645+
SWSS_LOG_ERROR("Failed to set SAI_SWITCH_ATTR_FAST_API_ENABLE=false: %s", sai_serialize_status(status).c_str());
1646+
}
1647+
1648+
return status;
1649+
}
1650+
16291651
sai_status_t notifySyncd(
16301652
_In_ const std::string& op)
16311653
{
@@ -1657,6 +1679,8 @@ sai_status_t notifySyncd(
16571679
{
16581680
SWSS_LOG_NOTICE("very first run is TRUE, op = %s", op.c_str());
16591681

1682+
sai_status_t status = SAI_STATUS_SUCCESS;
1683+
16601684
/*
16611685
* On the very first start of syncd, "compile" view is directly applied
16621686
* on device, since it will make it easier to switch to new asic state
@@ -1686,16 +1710,22 @@ sai_status_t notifySyncd(
16861710

16871711
g_asicInitViewMode = false;
16881712

1713+
if (options.startType == SAI_FASTFAST_BOOT)
1714+
{
1715+
/* fastfast boot configuration end */
1716+
status = onApplyViewInFastFastBoot();
1717+
}
1718+
16891719
SWSS_LOG_NOTICE("setting very first run to FALSE, op = %s", op.c_str());
16901720
}
16911721
else
16921722
{
16931723
SWSS_LOG_THROW("unknown operation: %s", op.c_str());
16941724
}
16951725

1696-
sendNotifyResponse(SAI_STATUS_SUCCESS);
1726+
sendNotifyResponse(status);
16971727

1698-
return SAI_STATUS_SUCCESS;
1728+
return status;
16991729
}
17001730

17011731
if (op == SYNCD_INIT_VIEW)
@@ -3246,35 +3276,6 @@ syncd_restart_type_t handleRestartQuery(swss::NotificationConsumer &restartQuery
32463276
return SYNCD_RESTART_TYPE_COLD;
32473277
}
32483278

3249-
void handleFfbEvent(swss::NotificationConsumer &ffb)
3250-
{
3251-
SWSS_LOG_ENTER();
3252-
3253-
std::string op;
3254-
std::string data;
3255-
std::vector<swss::FieldValueTuple> values;
3256-
3257-
ffb.pop(op, data, values);
3258-
3259-
if ((op == "SET") && (data == "ISSU_END"))
3260-
{
3261-
sai_switch_api_t *sai_switch_api = NULL;
3262-
sai_api_query(SAI_API_SWITCH, (void**)&sai_switch_api);
3263-
3264-
sai_attribute_t attr;
3265-
3266-
attr.id = SAI_SWITCH_ATTR_FAST_API_ENABLE;
3267-
attr.value.booldata = false;
3268-
3269-
sai_status_t status = sai_switch_api->set_switch_attribute(gSwitchId, &attr);
3270-
3271-
if (status != SAI_STATUS_SUCCESS)
3272-
{
3273-
SWSS_LOG_ERROR("Failed to set SAI_SWITCH_ATTR_FAST_API_ENABLE=false: %s", sai_serialize_status(status).c_str());
3274-
}
3275-
}
3276-
}
3277-
32783279
bool isVeryFirstRun()
32793280
{
32803281
SWSS_LOG_ENTER();
@@ -3530,7 +3531,6 @@ int syncd_main(int argc, char **argv)
35303531
std::shared_ptr<swss::NotificationConsumer> restartQuery = std::make_shared<swss::NotificationConsumer>(dbAsic.get(), "RESTARTQUERY");
35313532
std::shared_ptr<swss::ConsumerTable> flexCounter = std::make_shared<swss::ConsumerTable>(dbFlexCounter.get(), FLEX_COUNTER_TABLE);
35323533
std::shared_ptr<swss::ConsumerTable> flexCounterGroup = std::make_shared<swss::ConsumerTable>(dbFlexCounter.get(), FLEX_COUNTER_GROUP_TABLE);
3533-
std::shared_ptr<swss::NotificationConsumer> ffb = std::make_shared<swss::NotificationConsumer>(dbAsic.get(), "MLNX_FFB");
35343534

35353535
/*
35363536
* At the end we cant use producer consumer concept since if one process
@@ -3543,7 +3543,8 @@ int syncd_main(int argc, char **argv)
35433543

35443544
g_veryFirstRun = isVeryFirstRun();
35453545

3546-
if (swss::WarmStart::isWarmStart())
3546+
/* ignore warm logic here if syncd starts in Mellanox fastfast boot mode */
3547+
if (swss::WarmStart::isWarmStart() && (options.startType != SAI_FASTFAST_BOOT))
35473548
{
35483549
options.startType = SAI_WARM_BOOT;
35493550
}
@@ -3580,7 +3581,7 @@ int syncd_main(int argc, char **argv)
35803581
{
35813582
/*
35823583
* Mellanox SAI requires to pass SAI_WARM_BOOT as SAI_BOOT_KEY
3583-
* to start 'fast-fast'
3584+
* to start 'fastfast'
35843585
*/
35853586
gProfileMap[SAI_KEY_BOOT_TYPE] = std::to_string(SAI_WARM_BOOT);
35863587
} else {
@@ -3639,7 +3640,6 @@ int syncd_main(int argc, char **argv)
36393640
s->addSelectable(restartQuery.get());
36403641
s->addSelectable(flexCounter.get());
36413642
s->addSelectable(flexCounterGroup.get());
3642-
s->addSelectable(ffb.get());
36433643

36443644
SWSS_LOG_NOTICE("starting main loop");
36453645

@@ -3728,10 +3728,6 @@ int syncd_main(int argc, char **argv)
37283728
status = sai_switch_api->set_switch_attribute(gSwitchId, &attr);
37293729
}
37303730
}
3731-
else if (sel == ffb.get())
3732-
{
3733-
handleFfbEvent(*ffb);
3734-
}
37353731
else if (sel == flexCounter.get())
37363732
{
37373733
processFlexCounterEvent(*(swss::ConsumerTable*)sel);
@@ -3789,11 +3785,11 @@ int syncd_main(int argc, char **argv)
37893785

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

3792-
#ifdef SAI_SWITCH_ATTR_UNINIT_DATA_PLANE_ON_REMOVAL
3788+
#ifdef SAI_SUPPORT_UNINIT_DATA_PLANE_ON_REMOVAL
37933789

3794-
if (shutdownType == SYNCD_RESTART_TYPE_FAST)
3790+
if (shutdownType == SYNCD_RESTART_TYPE_FAST || shutdownType == SYNCD_RESTART_TYPE_WARM)
37953791
{
3796-
SWSS_LOG_NOTICE("Fast Reboot requested, keeping data plane running");
3792+
SWSS_LOG_NOTICE("Fast/warm reboot requested, keeping data plane running");
37973793

37983794
sai_attribute_t attr;
37993795

0 commit comments

Comments
 (0)