@@ -7,6 +7,8 @@ swss::NotificationProducer *notifySyncdResponse = NULL;
7
7
8
8
std::map<std::string, std::string> gProfileMap ;
9
9
10
+ bool g_veryFirstRun = false ;
11
+
10
12
void sai_diag_shell ()
11
13
{
12
14
SWSS_LOG_ENTER ();
@@ -872,6 +874,25 @@ void notifySyncd(swss::NotificationConsumer &consumer)
872
874
873
875
consumer.pop (op, data, values);
874
876
877
+ if (g_veryFirstRun)
878
+ {
879
+ SWSS_LOG_NOTICE (" very first run is TRUE, op = %s" , op.c_str ());
880
+
881
+ // on the very first start of syncd, "compile" view is directly
882
+ // applied on device, since it will make it easier to switch
883
+ // to new asic state later on when we restart orch agent
884
+
885
+ if (op == NOTIFY_SAI_SWITCH_VIEW)
886
+ {
887
+ g_veryFirstRun = false ;
888
+
889
+ SWSS_LOG_NOTICE (" setting very first run to FALSE, op = %s" , op.c_str ());
890
+ }
891
+
892
+ sendResponse (SAI_STATUS_SUCCESS);
893
+ return ;
894
+ }
895
+
875
896
sai_status_t status = SAI_STATUS_FAILURE;
876
897
877
898
if (op == NOTIFY_SAI_INIT_VIEW)
@@ -1058,6 +1079,25 @@ bool handleRestartQuery(swss::NotificationConsumer &restartQuery)
1058
1079
return false ;
1059
1080
}
1060
1081
1082
+ bool isVeryFirstRun ()
1083
+ {
1084
+ std::lock_guard<std::mutex> lock (g_mutex);
1085
+
1086
+ SWSS_LOG_ENTER ();
1087
+
1088
+ // if lane map is not defined in redis db then
1089
+ // we assume this is very first start of syncd
1090
+ // later on we can add additional checks here
1091
+
1092
+ auto redisLaneMap = redisGetLaneMap ();
1093
+
1094
+ bool firstRun = redisLaneMap.size () == 0 ;
1095
+
1096
+ SWSS_LOG_NOTICE (" First Run: %s" , firstRun ? " True" : " False" );
1097
+
1098
+ return firstRun;
1099
+ }
1100
+
1061
1101
int main (int argc, char **argv)
1062
1102
{
1063
1103
swss::Logger::getInstance ().setMinPrio (swss::Logger::SWSS_DEBUG);
@@ -1092,6 +1132,8 @@ int main(int argc, char **argv)
1092
1132
gProfileMap [SAI_KEY_INIT_CONFIG_FILE] = mlnx_config_file;
1093
1133
#endif /* MLNX_SAI */
1094
1134
1135
+ g_veryFirstRun = isVeryFirstRun ();
1136
+
1095
1137
if (options.warmStart )
1096
1138
{
1097
1139
const char *warmBootReadFile = profile_get_value (0 , SAI_KEY_WARM_BOOT_READ_FILE);
@@ -1106,6 +1148,16 @@ int main(int argc, char **argv)
1106
1148
}
1107
1149
}
1108
1150
1151
+ if (options.warmStart && g_veryFirstRun)
1152
+ {
1153
+ SWSS_LOG_WARN (" warm start requested, but this is very first syncd start, forcing cold start" );
1154
+
1155
+ // we force cold start since if it's first run then redis db is not complete
1156
+ // so redis asic view will not reflect warm boot asic state, if this happen
1157
+ // then orch agent needs to be restarted as well to repopulate asic view
1158
+ options.warmStart = false ;
1159
+ }
1160
+
1109
1161
gProfileMap [SAI_KEY_WARM_BOOT] = options.warmStart ? " 1" : " 0" ;
1110
1162
1111
1163
sai_api_initialize (0 , (service_method_table_t *)&test_services);
0 commit comments