@@ -28,6 +28,7 @@ static const std::string COUNTER_TYPE_TUNNEL = "Tunnel Counter";
28
28
static const std::string COUNTER_TYPE_BUFFER_POOL = " Buffer Pool Counter" ;
29
29
static const std::string COUNTER_TYPE_ENI = " DASH ENI Counter" ;
30
30
static const std::string COUNTER_TYPE_METER_BUCKET = " DASH Meter Bucket Counter" ;
31
+ static const std::string COUNTER_TYPE_POLICER = " Policer Counter" ;
31
32
static const std::string ATTR_TYPE_QUEUE = " Queue Attribute" ;
32
33
static const std::string ATTR_TYPE_PG = " Priority Group Attribute" ;
33
34
static const std::string ATTR_TYPE_MACSEC_SA = " MACSEC SA Attribute" ;
@@ -164,6 +165,14 @@ std::string serializeStat(
164
165
return sai_serialize_port_stat (stat);
165
166
}
166
167
168
+ template <>
169
+ std::string serializeStat (
170
+ _In_ const sai_policer_stat_t stat)
171
+ {
172
+ SWSS_LOG_ENTER ();
173
+ return sai_serialize_policer_stat (stat);
174
+ }
175
+
167
176
template <>
168
177
std::string serializeStat (
169
178
_In_ const sai_queue_stat_t stat)
@@ -270,6 +279,15 @@ void deserializeStat(
270
279
sai_deserialize_port_stat (name, stat);
271
280
}
272
281
282
+ template <>
283
+ void deserializeStat (
284
+ _In_ const char * name,
285
+ _Out_ sai_policer_stat_t *stat)
286
+ {
287
+ SWSS_LOG_ENTER ();
288
+ sai_deserialize_policer_stat (name, stat);
289
+ }
290
+
273
291
template <>
274
292
void deserializeStat (
275
293
_In_ const char * name,
@@ -1714,6 +1732,10 @@ std::shared_ptr<BaseCounterContext> FlexCounter::createCounterContext(
1714
1732
{
1715
1733
return std::make_shared<AttrContext<sai_acl_counter_attr_t >>(context_name, SAI_OBJECT_TYPE_ACL_COUNTER, m_vendorSai.get (), m_statsMode);
1716
1734
}
1735
+ else if (context_name == COUNTER_TYPE_POLICER)
1736
+ {
1737
+ return std::make_shared<CounterContext<sai_policer_stat_t >>(context_name, SAI_OBJECT_TYPE_POLICER, m_vendorSai.get (), m_statsMode);
1738
+ }
1717
1739
1718
1740
SWSS_LOG_THROW (" Invalid counter type %s" , context_name.c_str ());
1719
1741
// GCC 8.3 requires a return value here
@@ -1992,6 +2014,13 @@ void FlexCounter::removeCounter(
1992
2014
removeDataFromCountersDB (vid, " :TRAP" );
1993
2015
}
1994
2016
}
2017
+ else if (objectType == SAI_OBJECT_TYPE_POLICER)
2018
+ {
2019
+ if (hasCounterContext (COUNTER_TYPE_POLICER))
2020
+ {
2021
+ getCounterContext (COUNTER_TYPE_POLICER)->removeObject (vid);
2022
+ }
2023
+ }
1995
2024
else
1996
2025
{
1997
2026
SWSS_LOG_ERROR (" Object type for removal not supported, %s" ,
@@ -2126,6 +2155,14 @@ void FlexCounter::addCounter(
2126
2155
idStrings,
2127
2156
" " );
2128
2157
}
2158
+ else if (objectType == SAI_OBJECT_TYPE_POLICER && field == POLICER_COUNTER_ID_LIST)
2159
+ {
2160
+ getCounterContext (COUNTER_TYPE_POLICER)->addObject (
2161
+ vid,
2162
+ rid,
2163
+ idStrings,
2164
+ " " );
2165
+ }
2129
2166
else if (objectType == SAI_OBJECT_TYPE_BUFFER_POOL && field == BUFFER_POOL_COUNTER_ID_LIST)
2130
2167
{
2131
2168
counterIds = idStrings;
0 commit comments