Skip to content

Commit

Permalink
[flex counter] add rif plugins (sonic-net#562)
Browse files Browse the repository at this point in the history
According to [HLD](https://github.com/Azure/SONiC/blob/master/doc/rates-and-utilization/Rates_and_utilization_HLD.md)

Signed-off-by: Mykola Faryma <mykolaf@mellanox.com>
  • Loading branch information
mykolaf authored Jun 10, 2020
1 parent 322dd01 commit db0b35a
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 3 deletions.
39 changes: 36 additions & 3 deletions syncd/FlexCounter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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)
{
Expand Down Expand Up @@ -803,6 +816,7 @@ void FlexCounter::removeCounterPlugins()

m_queuePlugins.clear();
m_portPlugins.clear();
m_rifPlugins.clear();
m_priorityGroupPlugins.clear();
m_bufferPoolPlugins.clear();
}
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -1473,6 +1495,17 @@ void FlexCounter::runPlugins(
runRedisScript(counters_db, sha, portList, argv);
}

std::vector<std::string> 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(counters_db, sha, rifList, argv);
}

std::vector<std::string> queueList;

queueList.reserve(m_queueCounterIdsMap.size());
Expand Down
4 changes: 4 additions & 0 deletions syncd/FlexCounter.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -350,6 +353,7 @@ namespace syncd

std::set<std::string> m_queuePlugins;
std::set<std::string> m_portPlugins;
std::set<std::string> m_rifPlugins;
std::set<std::string> m_priorityGroupPlugins;
std::set<std::string> m_bufferPoolPlugins;

Expand Down

0 comments on commit db0b35a

Please sign in to comment.