Skip to content

Commit

Permalink
[flexcounter]: query for port supported counters once for all instanc…
Browse files Browse the repository at this point in the history
…es (sonic-net#302)

Signed-off-by: Sihui Han <[email protected]>
  • Loading branch information
sihuihan88 authored Mar 13, 2018
1 parent 191628c commit a4c0c0e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
16 changes: 9 additions & 7 deletions syncd/syncd_flex_counter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

/* Global map with FlexCounter instances for different polling interval */
static std::map<std::string, std::shared_ptr<FlexCounter>> g_flex_counters_map;

// List with supported counters
static std::set<sai_port_stat_t> supportedPortCounters;
static std::set<sai_queue_stat_t> supportedQueueCounters;

FlexCounter::PortCounterIds::PortCounterIds(
_In_ sai_object_id_t port,
Expand Down Expand Up @@ -56,7 +58,7 @@ void FlexCounter::setPortCounterList(
FlexCounter &fc = getInstance(instanceId);

// Initialize the supported counters list before setting
if (fc.m_supportedPortCounters.size() == 0)
if (supportedPortCounters.size() == 0)
{
fc.saiUpdateSupportedPortCounters(portId);
}
Expand Down Expand Up @@ -352,14 +354,14 @@ bool FlexCounter::isPortCounterSupported(sai_port_stat_t counter) const
{
SWSS_LOG_ENTER();

return m_supportedPortCounters.count(counter) != 0;
return supportedPortCounters.count(counter) != 0;
}

bool FlexCounter::isQueueCounterSupported(sai_queue_stat_t counter) const
{
SWSS_LOG_ENTER();

return m_supportedQueueCounters.count(counter) != 0;
return supportedQueueCounters.count(counter) != 0;
}

FlexCounter::FlexCounter(std::string instanceId) : m_instanceId(instanceId)
Expand Down Expand Up @@ -654,7 +656,7 @@ void FlexCounter::saiUpdateSupportedPortCounters(sai_object_id_t portId)
continue;
}

m_supportedPortCounters.insert(counter);
supportedPortCounters.insert(counter);
}
}

Expand All @@ -665,7 +667,7 @@ void FlexCounter::saiUpdateSupportedQueueCounters(
SWSS_LOG_ENTER();

uint64_t value;
m_supportedQueueCounters.clear();
supportedQueueCounters.clear();

for (auto &counter : counterIds)
{
Expand All @@ -682,7 +684,7 @@ void FlexCounter::saiUpdateSupportedQueueCounters(
}
else
{
m_supportedQueueCounters.insert(counter);
supportedQueueCounters.insert(counter);
}
}
}
4 changes: 0 additions & 4 deletions syncd/syncd_flex_counter.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,6 @@ class FlexCounter
std::map<sai_object_id_t, std::shared_ptr<QueueCounterIds>> m_queueCounterIdsMap;
std::map<sai_object_id_t, std::shared_ptr<QueueAttrIds>> m_queueAttrIdsMap;

// List with supported counters
std::set<sai_port_stat_t> m_supportedPortCounters;
std::set<sai_queue_stat_t> m_supportedQueueCounters;

// Plugins
std::set<std::string> m_queuePlugins;
std::set<std::string> m_portPlugins;
Expand Down

0 comments on commit a4c0c0e

Please sign in to comment.