Skip to content

Commit

Permalink
[flex_counter] Add sairedis support for drop counters (sonic-net#520)
Browse files Browse the repository at this point in the history
* Adds functions to syncd_flex_counter for configuring and polling port-level debug counters

Signed-off-by: Danny Allen daall@microsoft.com

* Remove uneccesary includes

* Add stubs for querying sai capabilities

* Add support for serializing debug counter attributes

* Add support for switch level debug counters

* Improve vslib support for debug counters

* Remove interface query stubs

* Add missing swss log

* Clean-up virtual switch implementation

* Simplify vs debug counters

* Remove unnecessary includes

* Fix formatting

* Respond to review comments
  • Loading branch information
daall authored Nov 12, 2019
1 parent afe2a0d commit 1aa5ebf
Show file tree
Hide file tree
Showing 8 changed files with 450 additions and 3 deletions.
9 changes: 9 additions & 0 deletions meta/sai_serialize.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ std::string sai_serialize_common_api(
std::string sai_serialize_port_stat(
_In_ const sai_port_stat_t counter);

std::string sai_serialize_switch_stat(
_In_ const sai_switch_stat_t counter);

std::string sai_serialize_port_pool_stat(
_In_ const sai_port_pool_stat_t counter);

Expand Down Expand Up @@ -135,6 +138,12 @@ std::string sai_serialize_mac(
std::string sai_serialize_port_oper_status(
_In_ sai_port_oper_status_t status);

std::string sai_serialize_ingress_drop_reason(
_In_ const sai_in_drop_reason_t reason);

std::string sai_serialize_egress_drop_reason(
_In_ const sai_out_drop_reason_t reason);

std::string sai_serialize_l2mc_entry_type(
_In_ const sai_l2mc_entry_type_t type);

Expand Down
24 changes: 24 additions & 0 deletions meta/saiserialize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -820,6 +820,14 @@ std::string sai_serialize_port_stat(
return sai_serialize_enum(counter, &sai_metadata_enum_sai_port_stat_t);
}

std::string sai_serialize_switch_stat(
_In_ const sai_switch_stat_t counter)
{
SWSS_LOG_ENTER();

return sai_serialize_enum(counter, &sai_metadata_enum_sai_switch_stat_t);
}

std::string sai_serialize_port_pool_stat(
_In_ const sai_port_pool_stat_t counter)
{
Expand Down Expand Up @@ -898,6 +906,22 @@ std::string sai_serialize_switch_oper_status(
return j.dump();
}

std::string sai_serialize_ingress_drop_reason(
_In_ const sai_in_drop_reason_t reason)
{
SWSS_LOG_ENTER();

return sai_serialize_enum(reason, &sai_metadata_enum_sai_in_drop_reason_t);
}

std::string sai_serialize_egress_drop_reason(
_In_ const sai_out_drop_reason_t reason)
{
SWSS_LOG_ENTER();

return sai_serialize_enum(reason, &sai_metadata_enum_sai_out_drop_reason_t);
}

std::string sai_serialize_switch_shutdown_request(
_In_ sai_object_id_t switch_id)
{
Expand Down
29 changes: 29 additions & 0 deletions syncd/syncd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3376,6 +3376,7 @@ void processFlexCounterEvent(
if (objectType == SAI_OBJECT_TYPE_PORT)
{
FlexCounter::removePort(vid, groupName);
FlexCounter::removePortDebugCounters(vid, groupName);
}
else if (objectType == SAI_OBJECT_TYPE_QUEUE)
{
Expand All @@ -3393,6 +3394,10 @@ void processFlexCounterEvent(
{
FlexCounter::removeBufferPool(vid, groupName);
}
else if (objectType == SAI_OBJECT_TYPE_SWITCH)
{
FlexCounter::removeSwitchDebugCounters(vid, groupName);
}
else
{
SWSS_LOG_ERROR("Object type for removal not supported, %s", objectTypeStr.c_str());
Expand Down Expand Up @@ -3423,6 +3428,18 @@ void processFlexCounterEvent(

FlexCounter::setPortCounterList(vid, rid, groupName, portCounterIds);
}
else if (objectType == SAI_OBJECT_TYPE_PORT && field == PORT_DEBUG_COUNTER_ID_LIST)
{
std::vector<sai_port_stat_t> portDebugCounterIds;
for (const auto &str : idStrings)
{
sai_port_stat_t stat;
sai_deserialize_port_stat(str.c_str(), &stat);
portDebugCounterIds.push_back(stat);
}

FlexCounter::setPortDebugCounterList(vid, rid, groupName, portDebugCounterIds);
}
else if (objectType == SAI_OBJECT_TYPE_QUEUE && field == QUEUE_COUNTER_ID_LIST)
{
std::vector<sai_queue_stat_t> queueCounterIds;
Expand Down Expand Up @@ -3483,6 +3500,18 @@ void processFlexCounterEvent(

FlexCounter::setRifCounterList(vid, rid, groupName, rifCounterIds);
}
else if (objectType == SAI_OBJECT_TYPE_SWITCH && field == SWITCH_DEBUG_COUNTER_ID_LIST)
{
std::vector<sai_switch_stat_t> switchCounterIds;
for (const auto &str : idStrings)
{
sai_switch_stat_t stat;
sai_deserialize_switch_stat(str.c_str(), &stat);
switchCounterIds.push_back(stat);
}

FlexCounter::setSwitchDebugCounterList(vid, rid, groupName, switchCounterIds);
}
else if (objectType == SAI_OBJECT_TYPE_BUFFER_POOL && field == BUFFER_POOL_COUNTER_ID_LIST)
{
counterIds = idStrings;
Expand Down
Loading

0 comments on commit 1aa5ebf

Please sign in to comment.