Skip to content

Commit

Permalink
Add support for DASH ENI Counters (sonic-net#1418)
Browse files Browse the repository at this point in the history
* Add support for DASH ENI Counters

* Fix whitespace error
  • Loading branch information
vivekrnv authored Sep 16, 2024
1 parent dbcba69 commit 9b9d330
Show file tree
Hide file tree
Showing 4 changed files with 138 additions and 30 deletions.
8 changes: 8 additions & 0 deletions meta/SaiSerialize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1041,6 +1041,14 @@ std::string sai_serialize_buffer_pool_stat(
return sai_serialize_enum(counter, &sai_metadata_enum_sai_buffer_pool_stat_t);
}

std::string sai_serialize_eni_stat(
_In_ const sai_eni_stat_t counter)
{
SWSS_LOG_ENTER();

return sai_serialize_enum(counter, &sai_metadata_enum_sai_eni_stat_t);
}

std::string sai_serialize_tunnel_stat(
_In_ const sai_tunnel_stat_t counter)
{
Expand Down
3 changes: 3 additions & 0 deletions meta/sai_serialize.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ std::string sai_serialize_ingress_priority_group_attr(
std::string sai_serialize_buffer_pool_stat(
_In_ const sai_buffer_pool_stat_t counter);

std::string sai_serialize_eni_stat(
_In_ const sai_eni_stat_t counter);

std::string sai_serialize_tunnel_stat(
_In_ const sai_tunnel_stat_t counter);

Expand Down
39 changes: 39 additions & 0 deletions syncd/FlexCounter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ static const std::string COUNTER_TYPE_MACSEC_SA = "MACSEC SA Counter";
static const std::string COUNTER_TYPE_FLOW = "Flow Counter";
static const std::string COUNTER_TYPE_TUNNEL = "Tunnel Counter";
static const std::string COUNTER_TYPE_BUFFER_POOL = "Buffer Pool Counter";
static const std::string COUNTER_TYPE_ENI = "DASH ENI Counter";
static const std::string ATTR_TYPE_QUEUE = "Queue Attribute";
static const std::string ATTR_TYPE_PG = "Priority Group Attribute";
static const std::string ATTR_TYPE_MACSEC_SA = "MACSEC SA Attribute";
Expand Down Expand Up @@ -219,6 +220,14 @@ std::string serializeStat(
return sai_serialize_buffer_pool_stat(stat);
}

template <>
std::string serializeStat(
_In_ const sai_eni_stat_t stat)
{
SWSS_LOG_ENTER();
return sai_serialize_eni_stat(stat);
}

template <typename StatType>
void deserializeStat(
_In_ const char* name,
Expand Down Expand Up @@ -318,6 +327,15 @@ void deserializeStat(
sai_deserialize_buffer_pool_stat(name, stat);
}

template <>
void deserializeStat(
_In_ const char* name,
_Out_ sai_eni_stat_t *stat)
{
SWSS_LOG_ENTER();
sai_deserialize_eni_stat(name, stat);
}

template <typename AttrType>
void deserializeAttr(
_In_ const std::string& name,
Expand Down Expand Up @@ -1297,6 +1315,12 @@ std::shared_ptr<BaseCounterContext> FlexCounter::createCounterContext(
context->always_check_supported_counters = true;
return context;
}
else if (context_name == COUNTER_TYPE_ENI)
{
auto context = std::make_shared<CounterContext<sai_eni_stat_t>>(context_name, (sai_object_type_t)SAI_OBJECT_TYPE_ENI, m_vendorSai.get(), m_statsMode);
context->always_check_supported_counters = true;
return context;
}
else if (context_name == ATTR_TYPE_QUEUE)
{
return std::make_shared<AttrContext<sai_queue_attr_t>>(context_name, SAI_OBJECT_TYPE_QUEUE, m_vendorSai.get(), m_statsMode);
Expand Down Expand Up @@ -1572,6 +1596,13 @@ void FlexCounter::removeCounter(
getCounterContext(COUNTER_TYPE_TUNNEL)->removeObject(vid);
}
}
else if (objectType == (sai_object_type_t)SAI_OBJECT_TYPE_ENI)
{
if (hasCounterContext(COUNTER_TYPE_ENI))
{
getCounterContext(COUNTER_TYPE_ENI)->removeObject(vid);
}
}
else if (objectType == SAI_OBJECT_TYPE_COUNTER)
{
if (hasCounterContext(COUNTER_TYPE_FLOW))
Expand Down Expand Up @@ -1730,6 +1761,14 @@ void FlexCounter::addCounter(
idStrings,
"");
}
else if (objectType == (sai_object_type_t)SAI_OBJECT_TYPE_ENI && field == ENI_COUNTER_ID_LIST)
{
getCounterContext(COUNTER_TYPE_ENI)->addObject(
vid,
rid,
idStrings,
"");
}
else
{
SWSS_LOG_ERROR("Object type and field combination is not supported, object type %s, field %s",
Expand Down
Loading

0 comments on commit 9b9d330

Please sign in to comment.