Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[flex counter] add rif plugins #562

Merged
merged 5 commits into from
Jun 10, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 39 additions & 4 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 @@ -1456,7 +1478,9 @@ void FlexCounter::runPlugins(
{
std::to_string(COUNTERS_DB), // TODO
lguohan marked this conversation as resolved.
Show resolved Hide resolved
COUNTERS_TABLE,
std::to_string(m_pollInterval * 1000)
std::to_string(m_pollInterval * 1000),
std::to_string(ASIC_DB),
lguohan marked this conversation as resolved.
Show resolved Hide resolved
std::to_string(CONFIG_DB)
};

std::vector<std::string> portList;
Expand All @@ -1473,6 +1497,17 @@ void FlexCounter::runPlugins(
runRedisScript(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(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