Skip to content

Commit edeeda0

Browse files
Volodymyr Samotiylguohan
Volodymyr Samotiy
authored andcommitted
[Mellanox|FFB]: Add support for Mellanox fast-fast boot in syncd (sonic-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
1 parent 8eca19c commit edeeda0

File tree

4 files changed

+71
-5
lines changed

4 files changed

+71
-5
lines changed

syncd/scripts/syncd_init_common.sh

+13-2
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,20 @@ fi
2424
# Use temporary view between init and apply
2525
CMD_ARGS+=" -u"
2626

27-
case "$(cat /proc/cmdline)" in
28-
*fast-reboot*)
27+
BOOT_TYPE="$(cat /proc/cmdline | grep -o 'SONIC_BOOT_TYPE=\S*' | cut -d'=' -f2)"
28+
29+
case "$BOOT_TYPE" in
30+
fast-reboot)
2931
FAST_REBOOT='yes'
3032
;;
33+
fastfast)
34+
if [ -e /var/warmboot/issu_started ]; then
35+
FASTFAST_REBOOT='yes'
36+
fi
37+
;;
3138
*)
3239
FAST_REBOOT='no'
40+
FASTFAST_REBOOT='no'
3341
;;
3442
esac
3543

@@ -55,6 +63,8 @@ function set_start_type()
5563
CMD_ARGS+=" -t warm"
5664
elif [ $FAST_REBOOT == "yes" ]; then
5765
CMD_ARGS+=" -t fast"
66+
elif [ $FASTFAST_REBOOT == "yes" ]; then
67+
CMD_ARGS+=" -t fastfast"
5868
fi
5969
}
6070

@@ -87,6 +97,7 @@ config_syncd_mlnx()
8797
# Write MAC address into /tmp/profile file.
8898
cat $HWSKU_DIR/sai.profile > /tmp/sai.profile
8999
echo "DEVICE_MAC_ADDRESS=$ALIGNED_MAC_ADDRESS" >> /tmp/sai.profile
100+
echo "SAI_WARM_BOOT_WRITE_FILE=/var/warmboot/" >> /tmp/sai.profile
90101
}
91102

92103
config_syncd_centec()

syncd/syncd.cpp

+51-3
Original file line numberDiff line numberDiff line change
@@ -2925,7 +2925,7 @@ void printUsage()
29252925
{
29262926
SWSS_LOG_ENTER();
29272927

2928-
std::cout << "Usage: syncd [-N] [-U] [-d] [-p profile] [-i interval] [-t [cold|warm|fast]] [-h] [-u] [-S]" << std::endl;
2928+
std::cout << "Usage: syncd [-N] [-U] [-d] [-p profile] [-i interval] [-t [cold|warm|fast|fastfast]] [-h] [-u] [-S]" << std::endl;
29292929
std::cout << " -N --nocounters" << std::endl;
29302930
std::cout << " Disable counter thread" << std::endl;
29312931
std::cout << " -d --diag" << std::endl;
@@ -2935,7 +2935,7 @@ void printUsage()
29352935
std::cout << " -i --countersInterval interval" << std::endl;
29362936
std::cout << " Provide counter thread interval" << std::endl;
29372937
std::cout << " -t --startType type" << std::endl;
2938-
std::cout << " Specify cold|warm|fast start type" << std::endl;
2938+
std::cout << " Specify cold|warm|fast|fastfast start type" << std::endl;
29392939
std::cout << " -u --useTempView:" << std::endl;
29402940
std::cout << " Use temporary view between init and apply" << std::endl;
29412941
std::cout << " -S --disableExitSleep" << std::endl;
@@ -3034,6 +3034,10 @@ void handleCmdLine(int argc, char **argv)
30343034
{
30353035
options.startType = SAI_FAST_BOOT;
30363036
}
3037+
else if (std::string(optarg) == "fastfast")
3038+
{
3039+
options.startType = SAI_FASTFAST_BOOT;
3040+
}
30373041
else
30383042
{
30393043
SWSS_LOG_ERROR("unknown start type %s", optarg);
@@ -3220,6 +3224,35 @@ syncd_restart_type_t handleRestartQuery(swss::NotificationConsumer &restartQuery
32203224
return SYNCD_RESTART_TYPE_COLD;
32213225
}
32223226

3227+
void handleFfbEvent(swss::NotificationConsumer &ffb)
3228+
{
3229+
SWSS_LOG_ENTER();
3230+
3231+
std::string op;
3232+
std::string data;
3233+
std::vector<swss::FieldValueTuple> values;
3234+
3235+
ffb.pop(op, data, values);
3236+
3237+
if ((op == "SET") && (data == "ISSU_END"))
3238+
{
3239+
sai_switch_api_t *sai_switch_api = NULL;
3240+
sai_api_query(SAI_API_SWITCH, (void**)&sai_switch_api);
3241+
3242+
sai_attribute_t attr;
3243+
3244+
attr.id = SAI_SWITCH_ATTR_FAST_API_ENABLE;
3245+
attr.value.booldata = false;
3246+
3247+
sai_status_t status = sai_switch_api->set_switch_attribute(gSwitchId, &attr);
3248+
3249+
if (status != SAI_STATUS_SUCCESS)
3250+
{
3251+
SWSS_LOG_ERROR("Failed to set SAI_SWITCH_ATTR_FAST_API_ENABLE=false: %s", sai_serialize_status(status).c_str());
3252+
}
3253+
}
3254+
}
3255+
32233256
bool isVeryFirstRun()
32243257
{
32253258
SWSS_LOG_ENTER();
@@ -3475,6 +3508,7 @@ int syncd_main(int argc, char **argv)
34753508
std::shared_ptr<swss::NotificationConsumer> restartQuery = std::make_shared<swss::NotificationConsumer>(dbAsic.get(), "RESTARTQUERY");
34763509
std::shared_ptr<swss::ConsumerTable> flexCounter = std::make_shared<swss::ConsumerTable>(dbFlexCounter.get(), FLEX_COUNTER_TABLE);
34773510
std::shared_ptr<swss::ConsumerTable> flexCounterGroup = std::make_shared<swss::ConsumerTable>(dbFlexCounter.get(), FLEX_COUNTER_GROUP_TABLE);
3511+
std::shared_ptr<swss::NotificationConsumer> ffb = std::make_shared<swss::NotificationConsumer>(dbAsic.get(), "MLNX_FFB");
34783512

34793513
/*
34803514
* At the end we cant use producer consumer concept since if one process
@@ -3520,7 +3554,16 @@ int syncd_main(int argc, char **argv)
35203554
options.startType = SAI_COLD_BOOT;
35213555
}
35223556

3523-
gProfileMap[SAI_KEY_BOOT_TYPE] = std::to_string(options.startType);
3557+
if (options.startType == SAI_FASTFAST_BOOT)
3558+
{
3559+
/*
3560+
* Mellanox SAI requires to pass SAI_WARM_BOOT as SAI_BOOT_KEY
3561+
* to start 'fast-fast'
3562+
*/
3563+
gProfileMap[SAI_KEY_BOOT_TYPE] = std::to_string(SAI_WARM_BOOT);
3564+
} else {
3565+
gProfileMap[SAI_KEY_BOOT_TYPE] = std::to_string(options.startType);
3566+
}
35243567

35253568
sai_status_t status = sai_api_initialize(0, (sai_service_method_table_t*)&test_services);
35263569

@@ -3574,6 +3617,7 @@ int syncd_main(int argc, char **argv)
35743617
s.addSelectable(restartQuery.get());
35753618
s.addSelectable(flexCounter.get());
35763619
s.addSelectable(flexCounterGroup.get());
3620+
s.addSelectable(ffb.get());
35773621

35783622
SWSS_LOG_NOTICE("starting main loop");
35793623

@@ -3653,6 +3697,10 @@ int syncd_main(int argc, char **argv)
36533697
status = sai_switch_api->set_switch_attribute(gSwitchId, &attr);
36543698
}
36553699
}
3700+
else if (sel == ffb.get())
3701+
{
3702+
handleFfbEvent(*ffb);
3703+
}
36563704
else if (sel == flexCounter.get())
36573705
{
36583706
processFlexCounterEvent(*(swss::ConsumerTable*)sel);

syncd/syncd.h

+5
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ extern "C" {
5555
#define SAI_COLD_BOOT 0
5656
#define SAI_WARM_BOOT 1
5757
#define SAI_FAST_BOOT 2
58+
/**
59+
* A special type of boot used by Mellanox platforms
60+
* to start in 'fastfast' boot mode
61+
*/
62+
#define SAI_FASTFAST_BOOT 3
5863

5964
#ifdef SAITHRIFT
6065
#define SWITCH_SAI_THRIFT_RPC_SERVER_PORT 9092

tests/aspell.en.pws

+2
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ endl
5959
enum
6060
eth
6161
ethernet
62+
fastfast
6263
fdb
6364
FDB
6465
fdbs
@@ -99,6 +100,7 @@ LOOPBACK
99100
lua
100101
MCAST
101102
md
103+
Mellanox
102104
metadata
103105
mlnx
104106
mpls

0 commit comments

Comments
 (0)