From 316ae6c0d2a47c95b3becb89497c42e46404b252 Mon Sep 17 00:00:00 2001 From: Jipan Yang Date: Wed, 30 Jan 2019 15:39:38 -0800 Subject: [PATCH] =?UTF-8?q?portsorch=20ports=20init=20done=20flag=20should?= =?UTF-8?q?=20means=20buffer,=20autoneg,=20speed,=20m=E2=80=A6=20(#747)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 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 * Change to four iterations for warm data restore with ordered port init Signed-off-by: Jipan Yang * Rename port readiness check functions to avoid confusion. Signed-off-by: Jipan Yang --- orchagent/aclorch.cpp | 2 +- orchagent/copporch.cpp | 2 +- orchagent/fdborch.cpp | 4 ++-- orchagent/flexcounterorch.cpp | 2 +- orchagent/intfsorch.cpp | 9 +-------- orchagent/mirrororch.cpp | 2 +- orchagent/neighorch.cpp | 2 +- orchagent/orchdaemon.cpp | 20 +++++++++----------- orchagent/pfcwdorch.cpp | 2 +- orchagent/portsorch.cpp | 16 ++++++++++++++-- orchagent/portsorch.h | 5 ++++- orchagent/qosorch.cpp | 2 +- orchagent/routeorch.cpp | 2 +- orchagent/tunneldecaporch.cpp | 2 +- orchagent/watermarkorch.cpp | 4 ++-- 15 files changed, 41 insertions(+), 35 deletions(-) diff --git a/orchagent/aclorch.cpp b/orchagent/aclorch.cpp index 888cf45a9bc..431cefd43b6 100644 --- a/orchagent/aclorch.cpp +++ b/orchagent/aclorch.cpp @@ -1876,7 +1876,7 @@ void AclOrch::doTask(Consumer &consumer) { SWSS_LOG_ENTER(); - if (!gPortsOrch->isInitDone()) + if (!gPortsOrch->isPortReady()) { return; } diff --git a/orchagent/copporch.cpp b/orchagent/copporch.cpp index 29bbc8eb2f8..ea68dd0cbaf 100644 --- a/orchagent/copporch.cpp +++ b/orchagent/copporch.cpp @@ -589,7 +589,7 @@ void CoppOrch::doTask(Consumer &consumer) { SWSS_LOG_ENTER(); - if (!gPortsOrch->isInitDone()) + if (!gPortsOrch->isPortReady()) { return; } diff --git a/orchagent/fdborch.cpp b/orchagent/fdborch.cpp index 68fec2f655c..b79e589af4f 100644 --- a/orchagent/fdborch.cpp +++ b/orchagent/fdborch.cpp @@ -256,7 +256,7 @@ void FdbOrch::doTask(Consumer& consumer) { SWSS_LOG_ENTER(); - if (!gPortsOrch->isInitDone()) + if (!gPortsOrch->isPortReady()) { return; } @@ -336,7 +336,7 @@ void FdbOrch::doTask(NotificationConsumer& consumer) { SWSS_LOG_ENTER(); - if (!gPortsOrch->isInitDone()) + if (!gPortsOrch->isPortReady()) { return; } diff --git a/orchagent/flexcounterorch.cpp b/orchagent/flexcounterorch.cpp index b844fce6df7..6126447bc13 100644 --- a/orchagent/flexcounterorch.cpp +++ b/orchagent/flexcounterorch.cpp @@ -38,7 +38,7 @@ void FlexCounterOrch::doTask(Consumer &consumer) { SWSS_LOG_ENTER(); - if (!gPortsOrch->isInitDone()) + if (!gPortsOrch->isPortReady()) { return; } diff --git a/orchagent/intfsorch.cpp b/orchagent/intfsorch.cpp index 34d857b51a9..1b42c978d5e 100644 --- a/orchagent/intfsorch.cpp +++ b/orchagent/intfsorch.cpp @@ -171,7 +171,7 @@ void IntfsOrch::doTask(Consumer &consumer) { SWSS_LOG_ENTER(); - if (!gPortsOrch->isInitDone()) + if (!gPortsOrch->isPortReady()) { return; } @@ -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(); diff --git a/orchagent/mirrororch.cpp b/orchagent/mirrororch.cpp index 488b8d4efd7..120eb7b17a2 100644 --- a/orchagent/mirrororch.cpp +++ b/orchagent/mirrororch.cpp @@ -934,7 +934,7 @@ void MirrorOrch::doTask(Consumer& consumer) { SWSS_LOG_ENTER(); - if (!gPortsOrch->isInitDone()) + if (!gPortsOrch->isPortReady()) { return; } diff --git a/orchagent/neighorch.cpp b/orchagent/neighorch.cpp index b8d2aee13fd..1594dfd969e 100644 --- a/orchagent/neighorch.cpp +++ b/orchagent/neighorch.cpp @@ -275,7 +275,7 @@ void NeighOrch::doTask(Consumer &consumer) { SWSS_LOG_ENTER(); - if (!gPortsOrch->isInitDone()) + if (!gPortsOrch->isPortReady()) { return; } diff --git a/orchagent/orchdaemon.cpp b/orchagent/orchdaemon.cpp index 50c51104a97..063b0bb8d77 100644 --- a/orchagent/orchdaemon.cpp +++ b/orchagent/orchdaemon.cpp @@ -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. @@ -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) { diff --git a/orchagent/pfcwdorch.cpp b/orchagent/pfcwdorch.cpp index ae2c50a2d85..032b821b606 100644 --- a/orchagent/pfcwdorch.cpp +++ b/orchagent/pfcwdorch.cpp @@ -50,7 +50,7 @@ void PfcWdOrch::doTask(Consumer& consumer) { SWSS_LOG_ENTER(); - if (!gPortsOrch->isInitDone()) + if (!gPortsOrch->isPortReady()) { return; } diff --git a/orchagent/portsorch.cpp b/orchagent/portsorch.cpp index 4feb597b705..ceba79a3987 100644 --- a/orchagent/portsorch.cpp +++ b/orchagent/portsorch.cpp @@ -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& PortsOrch::getAllPorts() { return m_portList; @@ -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)) @@ -2233,7 +2245,7 @@ void PortsOrch::doTask(Consumer &consumer) else { /* Wait for all ports to be initialized */ - if (!isInitDone()) + if (!isPortReady()) { return; } @@ -3051,7 +3063,7 @@ void PortsOrch::doTask(NotificationConsumer &consumer) SWSS_LOG_ENTER(); /* Wait for all ports to be initialized */ - if (!isInitDone()) + if (!isPortReady()) { return; } diff --git a/orchagent/portsorch.h b/orchagent/portsorch.h index 87e88a89265..fd2d7636363 100644 --- a/orchagent/portsorch.h +++ b/orchagent/portsorch.h @@ -55,6 +55,7 @@ class PortsOrch : public Orch, public Subject public: PortsOrch(DBConnector *db, vector &tableNames); + bool isPortReady(); bool isInitDone(); map& getAllPorts(); @@ -117,6 +118,8 @@ class PortsOrch : public Orch, public Subject map, tuple> m_lanesAliasSpeedMap; map m_portList; + unordered_set m_pendingPortSet; + NotificationConsumer* m_portStatusNotificationConsumer; void doTask(Consumer &consumer); @@ -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; diff --git a/orchagent/qosorch.cpp b/orchagent/qosorch.cpp index 66fb70d13eb..514cb5ec4da 100644 --- a/orchagent/qosorch.cpp +++ b/orchagent/qosorch.cpp @@ -1365,7 +1365,7 @@ void QosOrch::doTask(Consumer &consumer) { SWSS_LOG_ENTER(); - if (!gPortsOrch->isInitDone()) + if (!gPortsOrch->isPortReady()) { return; } diff --git a/orchagent/routeorch.cpp b/orchagent/routeorch.cpp index 5ad716303c4..087c7432888 100644 --- a/orchagent/routeorch.cpp +++ b/orchagent/routeorch.cpp @@ -269,7 +269,7 @@ void RouteOrch::doTask(Consumer& consumer) { SWSS_LOG_ENTER(); - if (!gPortsOrch->isInitDone()) + if (!gPortsOrch->isPortReady()) { return; } diff --git a/orchagent/tunneldecaporch.cpp b/orchagent/tunneldecaporch.cpp index 78470775aac..f056d5753f1 100644 --- a/orchagent/tunneldecaporch.cpp +++ b/orchagent/tunneldecaporch.cpp @@ -21,7 +21,7 @@ void TunnelDecapOrch::doTask(Consumer& consumer) { SWSS_LOG_ENTER(); - if (!gPortsOrch->isInitDone()) + if (!gPortsOrch->isPortReady()) { return; } diff --git a/orchagent/watermarkorch.cpp b/orchagent/watermarkorch.cpp index 79d3823db49..5069aaec723 100644 --- a/orchagent/watermarkorch.cpp +++ b/orchagent/watermarkorch.cpp @@ -50,7 +50,7 @@ void WatermarkOrch::doTask(Consumer &consumer) { SWSS_LOG_ENTER(); - if (!gPortsOrch->isInitDone()) + if (!gPortsOrch->isPortReady()) { return; } @@ -96,7 +96,7 @@ void WatermarkOrch::doTask(Consumer &consumer) void WatermarkOrch::doTask(NotificationConsumer &consumer) { - if (!gPortsOrch->isInitDone()) + if (!gPortsOrch->isPortReady()) { return; }