Skip to content

Commit 316ae6c

Browse files
jipanyanglguohan
authored andcommitted
portsorch ports init done flag should means buffer, autoneg, speed, m… (sonic-net#747)
* portsorch ports init done flag should means buffer, autoneg, speed, mtu, fec and other port level initial config done too. Signed-off-by: Jipan Yang <jipan.yang@alibaba-inc.com> * Change to four iterations for warm data restore with ordered port init Signed-off-by: Jipan Yang <jipan.yang@alibaba-inc.com> * Rename port readiness check functions to avoid confusion. Signed-off-by: Jipan Yang <jipan.yang@alibaba-inc.com>
1 parent 4280036 commit 316ae6c

15 files changed

+41
-35
lines changed

orchagent/aclorch.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1876,7 +1876,7 @@ void AclOrch::doTask(Consumer &consumer)
18761876
{
18771877
SWSS_LOG_ENTER();
18781878

1879-
if (!gPortsOrch->isInitDone())
1879+
if (!gPortsOrch->isPortReady())
18801880
{
18811881
return;
18821882
}

orchagent/copporch.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,7 @@ void CoppOrch::doTask(Consumer &consumer)
589589
{
590590
SWSS_LOG_ENTER();
591591

592-
if (!gPortsOrch->isInitDone())
592+
if (!gPortsOrch->isPortReady())
593593
{
594594
return;
595595
}

orchagent/fdborch.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ void FdbOrch::doTask(Consumer& consumer)
256256
{
257257
SWSS_LOG_ENTER();
258258

259-
if (!gPortsOrch->isInitDone())
259+
if (!gPortsOrch->isPortReady())
260260
{
261261
return;
262262
}
@@ -336,7 +336,7 @@ void FdbOrch::doTask(NotificationConsumer& consumer)
336336
{
337337
SWSS_LOG_ENTER();
338338

339-
if (!gPortsOrch->isInitDone())
339+
if (!gPortsOrch->isPortReady())
340340
{
341341
return;
342342
}

orchagent/flexcounterorch.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ void FlexCounterOrch::doTask(Consumer &consumer)
3838
{
3939
SWSS_LOG_ENTER();
4040

41-
if (!gPortsOrch->isInitDone())
41+
if (!gPortsOrch->isPortReady())
4242
{
4343
return;
4444
}

orchagent/intfsorch.cpp

+1-8
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ void IntfsOrch::doTask(Consumer &consumer)
171171
{
172172
SWSS_LOG_ENTER();
173173

174-
if (!gPortsOrch->isInitDone())
174+
if (!gPortsOrch->isPortReady())
175175
{
176176
return;
177177
}
@@ -275,13 +275,6 @@ void IntfsOrch::doTask(Consumer &consumer)
275275
continue;
276276
}
277277

278-
// buffer configuration hasn't been applied yet, hold from intf config.
279-
if (!gBufferOrch->isPortReady(alias))
280-
{
281-
it++;
282-
continue;
283-
}
284-
285278
if (!vnet_name.empty())
286279
{
287280
VNetOrch* vnet_orch = gDirectory.get<VNetOrch*>();

orchagent/mirrororch.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -934,7 +934,7 @@ void MirrorOrch::doTask(Consumer& consumer)
934934
{
935935
SWSS_LOG_ENTER();
936936

937-
if (!gPortsOrch->isInitDone())
937+
if (!gPortsOrch->isPortReady())
938938
{
939939
return;
940940
}

orchagent/neighorch.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ void NeighOrch::doTask(Consumer &consumer)
275275
{
276276
SWSS_LOG_ENTER();
277277

278-
if (!gPortsOrch->isInitDone())
278+
if (!gPortsOrch->isPortReady())
279279
{
280280
return;
281281
}

orchagent/orchdaemon.cpp

+9-11
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ bool OrchDaemon::init()
144144

145145
/*
146146
* The order of the orch list is important for state restore of warm start and
147-
* the queued processing in m_toSync map after gPortsOrch->isInitDone() is set.
147+
* the queued processing in m_toSync map after gPortsOrch->isPortReady() is set.
148148
*
149149
* For the multiple consumers in ports_tables, tasks for LAG_TABLE is processed before VLAN_TABLE
150150
* when iterating ConsumerMap.
@@ -413,21 +413,19 @@ bool OrchDaemon::warmRestoreAndSyncUp()
413413
}
414414

415415
/*
416-
* Three iterations are needed.
416+
* Four iterations are needed.
417417
*
418-
* First iteration: Orch(s) which do not have dependency on port table,
419-
* gBufferOrch, gPortsOrch(Port table and VLAN table),
420-
* and orch(s) which have dependency on Port but processed after it.
418+
* First iteration: switchorch, Port init/hostif create part of portorch.
421419
*
422-
* Second iteration: gBufferOrch (has inter-dependency with gPortsOrch),
423-
* remaining attributes on port table for gPortsOrch,
424-
* gIntfsOrch which has dependency on both gBufferOrch and port table of gPortsOrch.
425-
* LAG_TABLE in gPortsOrch.
420+
* Second iteratoin: gBufferOrch which requires port created,
421+
* then port speed/mtu/fec_mode/pfc_asym/admin_status config.
426422
*
427-
* Third iteration: Drain remaining data that are out of order like LAG_MEMBER_TABLE and
423+
* Third iteration: other orch(s) which wait for port init done.
424+
*
425+
* Fourth iteration: Drain remaining data that are out of order like LAG_MEMBER_TABLE and
428426
* VLAN_MEMBER_TABLE since they were checked before LAG_TABLE and VLAN_TABLE within gPortsOrch.
429427
*/
430-
for (auto it = 0; it < 3; it++)
428+
for (auto it = 0; it < 4; it++)
431429
{
432430
for (Orch *o : m_orchList)
433431
{

orchagent/pfcwdorch.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ void PfcWdOrch<DropHandler, ForwardHandler>::doTask(Consumer& consumer)
5050
{
5151
SWSS_LOG_ENTER();
5252

53-
if (!gPortsOrch->isInitDone())
53+
if (!gPortsOrch->isPortReady())
5454
{
5555
return;
5656
}

orchagent/portsorch.cpp

+14-2
Original file line numberDiff line numberDiff line change
@@ -385,11 +385,18 @@ void PortsOrch::removeDefaultBridgePorts()
385385
SWSS_LOG_NOTICE("Remove bridge ports from default 1Q bridge");
386386
}
387387

388+
bool PortsOrch::isPortReady()
389+
{
390+
return m_initDone && m_pendingPortSet.empty();
391+
}
392+
393+
/* Upon receiving PortInitDone, all the configured ports have been created*/
388394
bool PortsOrch::isInitDone()
389395
{
390396
return m_initDone;
391397
}
392398

399+
393400
map<string, Port>& PortsOrch::getAllPorts()
394401
{
395402
return m_portList;
@@ -1626,9 +1633,14 @@ void PortsOrch::doPortTask(Consumer &consumer)
16261633
if (!gBufferOrch->isPortReady(alias))
16271634
{
16281635
// buffer configuration hasn't been applied yet. save it for future retry
1636+
m_pendingPortSet.emplace(alias);
16291637
it++;
16301638
continue;
16311639
}
1640+
else
1641+
{
1642+
m_pendingPortSet.erase(alias);
1643+
}
16321644

16331645
Port p;
16341646
if (!getPort(alias, p))
@@ -2233,7 +2245,7 @@ void PortsOrch::doTask(Consumer &consumer)
22332245
else
22342246
{
22352247
/* Wait for all ports to be initialized */
2236-
if (!isInitDone())
2248+
if (!isPortReady())
22372249
{
22382250
return;
22392251
}
@@ -3051,7 +3063,7 @@ void PortsOrch::doTask(NotificationConsumer &consumer)
30513063
SWSS_LOG_ENTER();
30523064

30533065
/* Wait for all ports to be initialized */
3054-
if (!isInitDone())
3066+
if (!isPortReady())
30553067
{
30563068
return;
30573069
}

orchagent/portsorch.h

+4-1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ class PortsOrch : public Orch, public Subject
5555
public:
5656
PortsOrch(DBConnector *db, vector<table_name_with_pri_t> &tableNames);
5757

58+
bool isPortReady();
5859
bool isInitDone();
5960

6061
map<string, Port>& getAllPorts();
@@ -117,6 +118,8 @@ class PortsOrch : public Orch, public Subject
117118
map<set<int>, tuple<string, uint32_t, int, string>> m_lanesAliasSpeedMap;
118119
map<string, Port> m_portList;
119120

121+
unordered_set<string> m_pendingPortSet;
122+
120123
NotificationConsumer* m_portStatusNotificationConsumer;
121124

122125
void doTask(Consumer &consumer);
@@ -170,7 +173,7 @@ class PortsOrch : public Orch, public Subject
170173
bool getPortSpeed(sai_object_id_t port_id, sai_uint32_t &speed);
171174

172175
bool setPortAdvSpeed(sai_object_id_t port_id, sai_uint32_t speed);
173-
176+
174177
bool getQueueTypeAndIndex(sai_object_id_t queue_id, string &type, uint8_t &index);
175178

176179
bool m_isQueueMapGenerated = false;

orchagent/qosorch.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1365,7 +1365,7 @@ void QosOrch::doTask(Consumer &consumer)
13651365
{
13661366
SWSS_LOG_ENTER();
13671367

1368-
if (!gPortsOrch->isInitDone())
1368+
if (!gPortsOrch->isPortReady())
13691369
{
13701370
return;
13711371
}

orchagent/routeorch.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ void RouteOrch::doTask(Consumer& consumer)
269269
{
270270
SWSS_LOG_ENTER();
271271

272-
if (!gPortsOrch->isInitDone())
272+
if (!gPortsOrch->isPortReady())
273273
{
274274
return;
275275
}

orchagent/tunneldecaporch.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ void TunnelDecapOrch::doTask(Consumer& consumer)
2121
{
2222
SWSS_LOG_ENTER();
2323

24-
if (!gPortsOrch->isInitDone())
24+
if (!gPortsOrch->isPortReady())
2525
{
2626
return;
2727
}

orchagent/watermarkorch.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ void WatermarkOrch::doTask(Consumer &consumer)
5050
{
5151
SWSS_LOG_ENTER();
5252

53-
if (!gPortsOrch->isInitDone())
53+
if (!gPortsOrch->isPortReady())
5454
{
5555
return;
5656
}
@@ -96,7 +96,7 @@ void WatermarkOrch::doTask(Consumer &consumer)
9696

9797
void WatermarkOrch::doTask(NotificationConsumer &consumer)
9898
{
99-
if (!gPortsOrch->isInitDone())
99+
if (!gPortsOrch->isPortReady())
100100
{
101101
return;
102102
}

0 commit comments

Comments
 (0)