@@ -245,6 +245,9 @@ PortsOrch::PortsOrch(DBConnector *db, vector<table_name_with_pri_t> &tableNames)
245
245
m_portStatusNotificationConsumer = new swss::NotificationConsumer (notificationsDb, " NOTIFICATIONS" );
246
246
auto portStatusNotificatier = new Notifier (m_portStatusNotificationConsumer, this );
247
247
Orch::addExecutor (" PORT_STATUS_NOTIFICATIONS" , portStatusNotificatier);
248
+
249
+ // Try warm start
250
+ bake ();
248
251
}
249
252
250
253
void PortsOrch::removeDefaultVlanMembers ()
@@ -626,7 +629,7 @@ bool PortsOrch::bindAclTable(sai_object_id_t id, sai_object_id_t table_oid, sai_
626
629
{
627
630
// Bind this ACL group to LAG
628
631
sai_attribute_t lag_attr;
629
- lag_attr.id = ingress ? SAI_LAG_ATTR_INGRESS_ACL : SAI_LAG_ATTR_EGRESS_ACL;
632
+ lag_attr.id = ingress ? SAI_LAG_ATTR_INGRESS_ACL : SAI_LAG_ATTR_EGRESS_ACL;
630
633
lag_attr.value .oid = groupOid;
631
634
632
635
status = sai_lag_api->set_lag_attribute (port.m_lag_id , &lag_attr);
@@ -1083,8 +1086,8 @@ bool PortsOrch::removePort(sai_object_id_t port_id)
1083
1086
Port p;
1084
1087
if (getPort (port_id, p))
1085
1088
{
1086
- PortUpdate update = {p, false };
1087
- notify (SUBJECT_TYPE_PORT_CHANGE, static_cast <void *>(&update));
1089
+ PortUpdate update = {p, false };
1090
+ notify (SUBJECT_TYPE_PORT_CHANGE, static_cast <void *>(&update));
1088
1091
}
1089
1092
1090
1093
sai_status_t status = sai_port_api->remove_port (port_id);
@@ -1156,8 +1159,8 @@ bool PortsOrch::initPort(const string &alias, const set<int> &lane_set)
1156
1159
1157
1160
m_flexCounterTable->set (key, fields);
1158
1161
1159
- PortUpdate update = {p, true };
1160
- notify (SUBJECT_TYPE_PORT_CHANGE, static_cast <void *>(&update));
1162
+ PortUpdate update = {p, true };
1163
+ notify (SUBJECT_TYPE_PORT_CHANGE, static_cast <void *>(&update));
1161
1164
1162
1165
SWSS_LOG_NOTICE (" Initialized port %s" , alias.c_str ());
1163
1166
}
@@ -1177,6 +1180,55 @@ bool PortsOrch::initPort(const string &alias, const set<int> &lane_set)
1177
1180
return true ;
1178
1181
}
1179
1182
1183
+ bool PortsOrch::bake ()
1184
+ {
1185
+ SWSS_LOG_ENTER ();
1186
+
1187
+ // Check the APP_DB port table for warm reboot
1188
+ vector<FieldValueTuple> tuples;
1189
+ bool foundPortConfigDone = m_portTable->get (" PortConfigDone" , tuples);
1190
+ SWSS_LOG_NOTICE (" foundPortConfigDone = %d" , foundPortConfigDone);
1191
+
1192
+ bool foundPortInitDone = m_portTable->get (" PortInitDone" , tuples);
1193
+ SWSS_LOG_NOTICE (" foundPortInitDone = %d" , foundPortInitDone);
1194
+
1195
+ vector<string> keys;
1196
+ m_portTable->getKeys (keys);
1197
+ SWSS_LOG_NOTICE (" m_portTable->getKeys %zd" , keys.size ());
1198
+
1199
+ if (!foundPortConfigDone || !foundPortInitDone)
1200
+ {
1201
+ SWSS_LOG_NOTICE (" No port table, fallback to cold start" );
1202
+ cleanPortTable (keys);
1203
+ return false ;
1204
+ }
1205
+
1206
+ if (m_portCount != keys.size () - 2 )
1207
+ {
1208
+ // Invalid port table
1209
+ SWSS_LOG_ERROR (" Invalid port table: m_portCount" );
1210
+ cleanPortTable (keys);
1211
+ return false ;
1212
+ }
1213
+
1214
+ addExistingData (m_portTable.get ());
1215
+ addExistingData (APP_LAG_TABLE_NAME);
1216
+ addExistingData (APP_LAG_MEMBER_TABLE_NAME);
1217
+ addExistingData (APP_VLAN_TABLE_NAME);
1218
+ addExistingData (APP_VLAN_MEMBER_TABLE_NAME);
1219
+
1220
+ return true ;
1221
+ }
1222
+
1223
+ // Clean up port table
1224
+ void PortsOrch::cleanPortTable (const vector<string>& keys)
1225
+ {
1226
+ for (auto & key : keys)
1227
+ {
1228
+ m_portTable->del (key);
1229
+ }
1230
+ }
1231
+
1180
1232
void PortsOrch::doPortTask (Consumer &consumer)
1181
1233
{
1182
1234
SWSS_LOG_ENTER ();
@@ -1279,6 +1331,12 @@ void PortsOrch::doPortTask(Consumer &consumer)
1279
1331
m_lanesAliasSpeedMap[lane_set] = make_tuple (alias, speed, an, fec_mode);
1280
1332
}
1281
1333
1334
+ // TODO:
1335
+ // Fix the issue below
1336
+ // After PortConfigDone, while waiting for "PortInitDone" and the first gBufferOrch->isPortReady(alias),
1337
+ // the complete m_lanesAliasSpeedMap may be populated again, so initPort() will be called more than once
1338
+ // for the same port.
1339
+
1282
1340
/* Once all ports received, go through the each port and perform appropriate actions:
1283
1341
* 1. Remove ports which don't exist anymore
1284
1342
* 2. Create new ports
0 commit comments