Skip to content

Commit a4c0c0e

Browse files
authored
[flexcounter]: query for port supported counters once for all instances (sonic-net#302)
Signed-off-by: Sihui Han <[email protected]>
1 parent 191628c commit a4c0c0e

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

syncd/syncd_flex_counter.cpp

+9-7
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44

55
/* Global map with FlexCounter instances for different polling interval */
66
static std::map<std::string, std::shared_ptr<FlexCounter>> g_flex_counters_map;
7-
7+
// List with supported counters
8+
static std::set<sai_port_stat_t> supportedPortCounters;
9+
static std::set<sai_queue_stat_t> supportedQueueCounters;
810

911
FlexCounter::PortCounterIds::PortCounterIds(
1012
_In_ sai_object_id_t port,
@@ -56,7 +58,7 @@ void FlexCounter::setPortCounterList(
5658
FlexCounter &fc = getInstance(instanceId);
5759

5860
// Initialize the supported counters list before setting
59-
if (fc.m_supportedPortCounters.size() == 0)
61+
if (supportedPortCounters.size() == 0)
6062
{
6163
fc.saiUpdateSupportedPortCounters(portId);
6264
}
@@ -352,14 +354,14 @@ bool FlexCounter::isPortCounterSupported(sai_port_stat_t counter) const
352354
{
353355
SWSS_LOG_ENTER();
354356

355-
return m_supportedPortCounters.count(counter) != 0;
357+
return supportedPortCounters.count(counter) != 0;
356358
}
357359

358360
bool FlexCounter::isQueueCounterSupported(sai_queue_stat_t counter) const
359361
{
360362
SWSS_LOG_ENTER();
361363

362-
return m_supportedQueueCounters.count(counter) != 0;
364+
return supportedQueueCounters.count(counter) != 0;
363365
}
364366

365367
FlexCounter::FlexCounter(std::string instanceId) : m_instanceId(instanceId)
@@ -654,7 +656,7 @@ void FlexCounter::saiUpdateSupportedPortCounters(sai_object_id_t portId)
654656
continue;
655657
}
656658

657-
m_supportedPortCounters.insert(counter);
659+
supportedPortCounters.insert(counter);
658660
}
659661
}
660662

@@ -665,7 +667,7 @@ void FlexCounter::saiUpdateSupportedQueueCounters(
665667
SWSS_LOG_ENTER();
666668

667669
uint64_t value;
668-
m_supportedQueueCounters.clear();
670+
supportedQueueCounters.clear();
669671

670672
for (auto &counter : counterIds)
671673
{
@@ -682,7 +684,7 @@ void FlexCounter::saiUpdateSupportedQueueCounters(
682684
}
683685
else
684686
{
685-
m_supportedQueueCounters.insert(counter);
687+
supportedQueueCounters.insert(counter);
686688
}
687689
}
688690
}

syncd/syncd_flex_counter.h

-4
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,6 @@ class FlexCounter
108108
std::map<sai_object_id_t, std::shared_ptr<QueueCounterIds>> m_queueCounterIdsMap;
109109
std::map<sai_object_id_t, std::shared_ptr<QueueAttrIds>> m_queueAttrIdsMap;
110110

111-
// List with supported counters
112-
std::set<sai_port_stat_t> m_supportedPortCounters;
113-
std::set<sai_queue_stat_t> m_supportedQueueCounters;
114-
115111
// Plugins
116112
std::set<std::string> m_queuePlugins;
117113
std::set<std::string> m_portPlugins;

0 commit comments

Comments
 (0)