Skip to content

Commit

Permalink
portsorch ports init done flag should means buffer, autoneg, speed, m… (
Browse files Browse the repository at this point in the history
#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>
  • Loading branch information
jipanyang authored and lguohan committed Jan 30, 2019
1 parent 4280036 commit 316ae6c
Show file tree
Hide file tree
Showing 15 changed files with 41 additions and 35 deletions.
2 changes: 1 addition & 1 deletion orchagent/aclorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1876,7 +1876,7 @@ void AclOrch::doTask(Consumer &consumer)
{
SWSS_LOG_ENTER();

if (!gPortsOrch->isInitDone())
if (!gPortsOrch->isPortReady())
{
return;
}
Expand Down
2 changes: 1 addition & 1 deletion orchagent/copporch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ void CoppOrch::doTask(Consumer &consumer)
{
SWSS_LOG_ENTER();

if (!gPortsOrch->isInitDone())
if (!gPortsOrch->isPortReady())
{
return;
}
Expand Down
4 changes: 2 additions & 2 deletions orchagent/fdborch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ void FdbOrch::doTask(Consumer& consumer)
{
SWSS_LOG_ENTER();

if (!gPortsOrch->isInitDone())
if (!gPortsOrch->isPortReady())
{
return;
}
Expand Down Expand Up @@ -336,7 +336,7 @@ void FdbOrch::doTask(NotificationConsumer& consumer)
{
SWSS_LOG_ENTER();

if (!gPortsOrch->isInitDone())
if (!gPortsOrch->isPortReady())
{
return;
}
Expand Down
2 changes: 1 addition & 1 deletion orchagent/flexcounterorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ void FlexCounterOrch::doTask(Consumer &consumer)
{
SWSS_LOG_ENTER();

if (!gPortsOrch->isInitDone())
if (!gPortsOrch->isPortReady())
{
return;
}
Expand Down
9 changes: 1 addition & 8 deletions orchagent/intfsorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ void IntfsOrch::doTask(Consumer &consumer)
{
SWSS_LOG_ENTER();

if (!gPortsOrch->isInitDone())
if (!gPortsOrch->isPortReady())
{
return;
}
Expand Down Expand Up @@ -275,13 +275,6 @@ void IntfsOrch::doTask(Consumer &consumer)
continue;
}

// buffer configuration hasn't been applied yet, hold from intf config.
if (!gBufferOrch->isPortReady(alias))
{
it++;
continue;
}

if (!vnet_name.empty())
{
VNetOrch* vnet_orch = gDirectory.get<VNetOrch*>();
Expand Down
2 changes: 1 addition & 1 deletion orchagent/mirrororch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -934,7 +934,7 @@ void MirrorOrch::doTask(Consumer& consumer)
{
SWSS_LOG_ENTER();

if (!gPortsOrch->isInitDone())
if (!gPortsOrch->isPortReady())
{
return;
}
Expand Down
2 changes: 1 addition & 1 deletion orchagent/neighorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ void NeighOrch::doTask(Consumer &consumer)
{
SWSS_LOG_ENTER();

if (!gPortsOrch->isInitDone())
if (!gPortsOrch->isPortReady())
{
return;
}
Expand Down
20 changes: 9 additions & 11 deletions orchagent/orchdaemon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ bool OrchDaemon::init()

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

/*
* Three iterations are needed.
* Four iterations are needed.
*
* First iteration: Orch(s) which do not have dependency on port table,
* gBufferOrch, gPortsOrch(Port table and VLAN table),
* and orch(s) which have dependency on Port but processed after it.
* First iteration: switchorch, Port init/hostif create part of portorch.
*
* Second iteration: gBufferOrch (has inter-dependency with gPortsOrch),
* remaining attributes on port table for gPortsOrch,
* gIntfsOrch which has dependency on both gBufferOrch and port table of gPortsOrch.
* LAG_TABLE in gPortsOrch.
* Second iteratoin: gBufferOrch which requires port created,
* then port speed/mtu/fec_mode/pfc_asym/admin_status config.
*
* Third iteration: Drain remaining data that are out of order like LAG_MEMBER_TABLE and
* Third iteration: other orch(s) which wait for port init done.
*
* Fourth iteration: Drain remaining data that are out of order like LAG_MEMBER_TABLE and
* VLAN_MEMBER_TABLE since they were checked before LAG_TABLE and VLAN_TABLE within gPortsOrch.
*/
for (auto it = 0; it < 3; it++)
for (auto it = 0; it < 4; it++)
{
for (Orch *o : m_orchList)
{
Expand Down
2 changes: 1 addition & 1 deletion orchagent/pfcwdorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ void PfcWdOrch<DropHandler, ForwardHandler>::doTask(Consumer& consumer)
{
SWSS_LOG_ENTER();

if (!gPortsOrch->isInitDone())
if (!gPortsOrch->isPortReady())
{
return;
}
Expand Down
16 changes: 14 additions & 2 deletions orchagent/portsorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -385,11 +385,18 @@ void PortsOrch::removeDefaultBridgePorts()
SWSS_LOG_NOTICE("Remove bridge ports from default 1Q bridge");
}

bool PortsOrch::isPortReady()
{
return m_initDone && m_pendingPortSet.empty();
}

/* Upon receiving PortInitDone, all the configured ports have been created*/
bool PortsOrch::isInitDone()
{
return m_initDone;
}


map<string, Port>& PortsOrch::getAllPorts()
{
return m_portList;
Expand Down Expand Up @@ -1626,9 +1633,14 @@ void PortsOrch::doPortTask(Consumer &consumer)
if (!gBufferOrch->isPortReady(alias))
{
// buffer configuration hasn't been applied yet. save it for future retry
m_pendingPortSet.emplace(alias);
it++;
continue;
}
else
{
m_pendingPortSet.erase(alias);
}

Port p;
if (!getPort(alias, p))
Expand Down Expand Up @@ -2233,7 +2245,7 @@ void PortsOrch::doTask(Consumer &consumer)
else
{
/* Wait for all ports to be initialized */
if (!isInitDone())
if (!isPortReady())
{
return;
}
Expand Down Expand Up @@ -3051,7 +3063,7 @@ void PortsOrch::doTask(NotificationConsumer &consumer)
SWSS_LOG_ENTER();

/* Wait for all ports to be initialized */
if (!isInitDone())
if (!isPortReady())
{
return;
}
Expand Down
5 changes: 4 additions & 1 deletion orchagent/portsorch.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class PortsOrch : public Orch, public Subject
public:
PortsOrch(DBConnector *db, vector<table_name_with_pri_t> &tableNames);

bool isPortReady();
bool isInitDone();

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

unordered_set<string> m_pendingPortSet;

NotificationConsumer* m_portStatusNotificationConsumer;

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

bool setPortAdvSpeed(sai_object_id_t port_id, sai_uint32_t speed);

bool getQueueTypeAndIndex(sai_object_id_t queue_id, string &type, uint8_t &index);

bool m_isQueueMapGenerated = false;
Expand Down
2 changes: 1 addition & 1 deletion orchagent/qosorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1365,7 +1365,7 @@ void QosOrch::doTask(Consumer &consumer)
{
SWSS_LOG_ENTER();

if (!gPortsOrch->isInitDone())
if (!gPortsOrch->isPortReady())
{
return;
}
Expand Down
2 changes: 1 addition & 1 deletion orchagent/routeorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ void RouteOrch::doTask(Consumer& consumer)
{
SWSS_LOG_ENTER();

if (!gPortsOrch->isInitDone())
if (!gPortsOrch->isPortReady())
{
return;
}
Expand Down
2 changes: 1 addition & 1 deletion orchagent/tunneldecaporch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ void TunnelDecapOrch::doTask(Consumer& consumer)
{
SWSS_LOG_ENTER();

if (!gPortsOrch->isInitDone())
if (!gPortsOrch->isPortReady())
{
return;
}
Expand Down
4 changes: 2 additions & 2 deletions orchagent/watermarkorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ void WatermarkOrch::doTask(Consumer &consumer)
{
SWSS_LOG_ENTER();

if (!gPortsOrch->isInitDone())
if (!gPortsOrch->isPortReady())
{
return;
}
Expand Down Expand Up @@ -96,7 +96,7 @@ void WatermarkOrch::doTask(Consumer &consumer)

void WatermarkOrch::doTask(NotificationConsumer &consumer)
{
if (!gPortsOrch->isInitDone())
if (!gPortsOrch->isPortReady())
{
return;
}
Expand Down

0 comments on commit 316ae6c

Please sign in to comment.