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

[counter]: support enable/disable counter query #322

Merged
merged 2 commits into from
Jun 19, 2018
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 4 additions & 0 deletions syncd/syncd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2580,6 +2580,10 @@ void processFlexCounterGroupEvent(
FlexCounter::addPortCounterPlugin(sha, groupName);
}
}
else if (field == FLEX_COUNTER_STATUS_FIELD)
{
FlexCounter::updateFlexCounterStatus(value, groupName);
}
else
{
SWSS_LOG_ERROR("Field is not supported %s", field.c_str());
Expand Down
29 changes: 27 additions & 2 deletions syncd/syncd_flex_counter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,28 @@ void FlexCounter::setPollInterval(
fc.m_pollInterval = pollInterval;
}

void FlexCounter::updateFlexCounterStatus(
_In_ std::string status,
_In_ std::string instanceId)
{
SWSS_LOG_ENTER();

FlexCounter &fc = getInstance(instanceId);
if (status == "enable")
{
fc.m_enable = true;
}
else if (status == "disable")
{
fc.m_enable = false;
}
else
{
SWSS_LOG_NOTICE("Input value %s is not supported for Flex counter status, enter enable or disable", status.c_str());
}

}

/* The current implementation of 'setPortCounterList' and 'setQueueCounterList' are
* not the same. Need to refactor these two functions to have the similar logic.
* Either the full SAI attributes are queried once, or each of the needed counters
Expand Down Expand Up @@ -586,8 +608,11 @@ void FlexCounter::flexCounterThread(void)
{
auto start = std::chrono::steady_clock::now();

collectCounters(countersTable);
runPlugins(db);
if (m_enable)
{
collectCounters(countersTable);
runPlugins(db);
}

auto finish = std::chrono::steady_clock::now();
uint32_t delay = static_cast<uint32_t>(
Expand Down
5 changes: 5 additions & 0 deletions syncd/syncd_flex_counter.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ class FlexCounter
_In_ sai_object_id_t queueId,
_In_ std::string instanceId,
_In_ const std::vector<sai_queue_attr_t> &attrIds);
static void updateFlexCounterStatus(
_In_ std::string status,
_In_ std::string instanceId);


static void removePort(
_In_ sai_object_id_t portVid,
Expand Down Expand Up @@ -119,6 +123,7 @@ class FlexCounter

uint32_t m_pollInterval = 0;
std::string m_instanceId;
bool m_enable = false;
};

#endif