From fd7d1b2e11c15c30ec57facf0f3b0065b448682b Mon Sep 17 00:00:00 2001 From: Mykola Faryma Date: Wed, 8 Apr 2020 17:51:40 +0300 Subject: [PATCH 1/4] [flex counter] add rif plugins Signed-off-by: Mykola Faryma --- syncd/FlexCounter.cpp | 39 ++++++++++++++++++++++++++++++++++++--- syncd/FlexCounter.h | 4 ++++ 2 files changed, 40 insertions(+), 3 deletions(-) diff --git a/syncd/FlexCounter.cpp b/syncd/FlexCounter.cpp index ad4815347..8c1d0464d 100644 --- a/syncd/FlexCounter.cpp +++ b/syncd/FlexCounter.cpp @@ -738,6 +738,7 @@ void FlexCounter::checkPluginRegistered( if ( m_portPlugins.find(sha) != m_portPlugins.end() || + m_rifPlugins.find(sha) != m_rifPlugins.end() || m_queuePlugins.find(sha) != m_queuePlugins.end() || m_priorityGroupPlugins.find(sha) != m_priorityGroupPlugins.end() || m_bufferPoolPlugins.find(sha) != m_bufferPoolPlugins.end() @@ -759,6 +760,18 @@ void FlexCounter::addPortCounterPlugin( SWSS_LOG_NOTICE("Port counters plugin %s registered", sha.c_str()); } +void FlexCounter::addRifCounterPlugin( + _In_ const std::string& sha) +{ + SWSS_LOG_ENTER(); + + checkPluginRegistered(sha); + + m_rifPlugins.insert(sha); + + SWSS_LOG_NOTICE("Rif counters plugin %s registered", sha.c_str()); +} + void FlexCounter::addQueueCounterPlugin( _In_ const std::string& sha) { @@ -803,6 +816,7 @@ void FlexCounter::removeCounterPlugins() m_queuePlugins.clear(); m_portPlugins.clear(); + m_rifPlugins.clear(); m_priorityGroupPlugins.clear(); m_bufferPoolPlugins.clear(); } @@ -854,6 +868,13 @@ void FlexCounter::addCounterPlugin( addPortCounterPlugin(sha); } } + else if (field == RIF_PLUGIN_FIELD) + { + for (auto& sha: shaStrings) + { + addRifCounterPlugin(sha); + } + } else if (field == BUFFER_POOL_PLUGIN_FIELD) { for (auto& sha: shaStrings) @@ -900,9 +921,10 @@ bool FlexCounter::allPluginsEmpty() const SWSS_LOG_ENTER(); return m_priorityGroupPlugins.empty() && - m_queuePlugins.empty() && - m_portPlugins.empty() && - m_bufferPoolPlugins.empty(); + m_queuePlugins.empty() && + m_portPlugins.empty() && + m_rifPlugins.empty() && + m_bufferPoolPlugins.empty(); } bool FlexCounter::isPortCounterSupported(sai_port_stat_t counter) const @@ -1473,6 +1495,17 @@ void FlexCounter::runPlugins( runRedisScript(db, sha, portList, argv); } + std::vector rifList; + rifList.reserve(m_rifCounterIdsMap.size()); + for (const auto& kv : m_rifCounterIdsMap) + { + rifList.push_back(sai_serialize_object_id(kv.first)); + } + for (const auto& sha : m_rifPlugins) + { + runRedisScript(db, sha, rifList, argv); + } + std::vector queueList; queueList.reserve(m_queueCounterIdsMap.size()); diff --git a/syncd/FlexCounter.h b/syncd/FlexCounter.h index 3b1d2b897..d5d256c9a 100644 --- a/syncd/FlexCounter.h +++ b/syncd/FlexCounter.h @@ -64,6 +64,9 @@ namespace syncd void addPortCounterPlugin( _In_ const std::string& sha); + void addRifCounterPlugin( + _In_ const std::string& sha); + void addBufferPoolCounterPlugin( _In_ const std::string& sha); @@ -350,6 +353,7 @@ namespace syncd std::set m_queuePlugins; std::set m_portPlugins; + std::set m_rifPlugins; std::set m_priorityGroupPlugins; std::set m_bufferPoolPlugins; From 390ce7fc4656c98361c66eb9b01f3b3edacf6b08 Mon Sep 17 00:00:00 2001 From: Mykola Faryma Date: Tue, 21 Apr 2020 17:19:32 +0300 Subject: [PATCH 2/4] [FC] pass ASIC & CONFIG DB IDs to redis scripts Signed-off-by: Mykola Faryma --- syncd/FlexCounter.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/syncd/FlexCounter.cpp b/syncd/FlexCounter.cpp index 8c1d0464d..c321b8be8 100644 --- a/syncd/FlexCounter.cpp +++ b/syncd/FlexCounter.cpp @@ -1478,7 +1478,9 @@ void FlexCounter::runPlugins( { std::to_string(COUNTERS_DB), // TODO COUNTERS_TABLE, - std::to_string(m_pollInterval * 1000) + std::to_string(m_pollInterval * 1000), + std::to_string(ASIC_DB), + std::to_string(CONFIG_DB) }; std::vector portList; From 8f063aac56c53765872555c3cbe69b2615b26b44 Mon Sep 17 00:00:00 2001 From: Mykola Faryma Date: Fri, 5 Jun 2020 15:05:17 +0300 Subject: [PATCH 3/4] remove unneccessary hardcoded b ids Signed-off-by: Mykola Faryma --- syncd/FlexCounter.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/syncd/FlexCounter.cpp b/syncd/FlexCounter.cpp index c321b8be8..e142413fc 100644 --- a/syncd/FlexCounter.cpp +++ b/syncd/FlexCounter.cpp @@ -1476,11 +1476,9 @@ void FlexCounter::runPlugins( const std::vector argv = { - std::to_string(COUNTERS_DB), // TODO + std::to_string(m_dbCounters), // TODO COUNTERS_TABLE, - std::to_string(m_pollInterval * 1000), - std::to_string(ASIC_DB), - std::to_string(CONFIG_DB) + std::to_string(m_pollInterval * 1000) }; std::vector portList; From 4253fe4a9a7398c5aa1149f30bf716ed5dec18a0 Mon Sep 17 00:00:00 2001 From: Mykola Faryma Date: Tue, 9 Jun 2020 17:55:13 +0300 Subject: [PATCH 4/4] fix compilation error Signed-off-by: Mykola Faryma --- syncd/FlexCounter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/syncd/FlexCounter.cpp b/syncd/FlexCounter.cpp index 1edb422a5..4dd82f29e 100644 --- a/syncd/FlexCounter.cpp +++ b/syncd/FlexCounter.cpp @@ -1503,7 +1503,7 @@ void FlexCounter::runPlugins( } for (const auto& sha : m_rifPlugins) { - runRedisScript(db, sha, rifList, argv); + runRedisScript(counters_db, sha, rifList, argv); } std::vector queueList;