Skip to content

Commit

Permalink
Add buffer pool stat to flex counter architecture (sonic-net#451)
Browse files Browse the repository at this point in the history
  • Loading branch information
wendani authored and lguohan committed May 26, 2019
1 parent f93e27a commit dcab09f
Show file tree
Hide file tree
Showing 5 changed files with 308 additions and 13 deletions.
4 changes: 4 additions & 0 deletions meta/sai_serialize.h
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,10 @@ void sai_deserialize_ingress_priority_group_attr(
_In_ const std::string& s,
_Out_ sai_ingress_priority_group_attr_t& attr);

void sai_deserialize_buffer_pool_stat(
_In_ const std::string& s,
_Out_ sai_buffer_pool_stat_t& stat);

void sai_deserialize_queue_attr(
_In_ const std::string& s,
_Out_ sai_queue_attr_t& attr);
Expand Down
9 changes: 9 additions & 0 deletions meta/saiserialize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2968,6 +2968,15 @@ void sai_deserialize_ingress_priority_group_attr(
sai_deserialize_enum(s, &sai_metadata_enum_sai_ingress_priority_group_attr_t, (int32_t&)attr);
}

void sai_deserialize_buffer_pool_stat(
_In_ const std::string& s,
_Out_ sai_buffer_pool_stat_t& stat)
{
SWSS_LOG_ENTER();

sai_deserialize_enum(s, &sai_metadata_enum_sai_buffer_pool_stat_t, (int32_t&)stat);
}

void sai_deserialize_queue_attr(
_In_ const std::string& s,
_Out_ sai_queue_attr_t& attr)
Expand Down
28 changes: 28 additions & 0 deletions syncd/syncd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2831,6 +2831,14 @@ void processFlexCounterGroupEvent(
FlexCounter::addPortCounterPlugin(sha, groupName);
}
}
else if (field == BUFFER_POOL_PLUGIN_FIELD)
{
auto shaStrings = swss::tokenize(value, ',');
for (const auto &sha : shaStrings)
{
FlexCounter::addBufferPoolCounterPlugin(sha, groupName);
}
}
else if (field == FLEX_COUNTER_STATUS_FIELD)
{
FlexCounter::updateFlexCounterStatus(value, groupName);
Expand Down Expand Up @@ -2894,6 +2902,10 @@ void processFlexCounterEvent(
{
FlexCounter::removeRif(vid, groupName);
}
else if (objectType == SAI_OBJECT_TYPE_BUFFER_POOL)
{
FlexCounter::removeBufferPool(vid, groupName);
}
else
{
SWSS_LOG_ERROR("Object type for removal not supported, %s", objectTypeStr.c_str());
Expand All @@ -2919,6 +2931,7 @@ void processFlexCounterEvent(
sai_deserialize_port_stat(str.c_str(), &stat);
portCounterIds.push_back(stat);
}

FlexCounter::setPortCounterList(vid, rid, groupName, portCounterIds);
}
else if (objectType == SAI_OBJECT_TYPE_QUEUE && field == QUEUE_COUNTER_ID_LIST)
Expand All @@ -2930,6 +2943,7 @@ void processFlexCounterEvent(
sai_deserialize_queue_stat(str.c_str(), &stat);
queueCounterIds.push_back(stat);
}

FlexCounter::setQueueCounterList(vid, rid, groupName, queueCounterIds);
}
else if (objectType == SAI_OBJECT_TYPE_QUEUE && field == QUEUE_ATTR_ID_LIST)
Expand All @@ -2953,6 +2967,7 @@ void processFlexCounterEvent(
sai_deserialize_ingress_priority_group_stat(str.c_str(), &stat);
pgCounterIds.push_back(stat);
}

FlexCounter::setPriorityGroupCounterList(vid, rid, groupName, pgCounterIds);
}
else if (objectType == SAI_OBJECT_TYPE_INGRESS_PRIORITY_GROUP && field == PG_ATTR_ID_LIST)
Expand All @@ -2976,8 +2991,21 @@ void processFlexCounterEvent(
sai_deserialize_router_interface_stat(str.c_str(), &stat);
rifCounterIds.push_back(stat);
}

FlexCounter::setRifCounterList(vid, rid, groupName, rifCounterIds);
}
else if (objectType == SAI_OBJECT_TYPE_BUFFER_POOL && field == BUFFER_POOL_COUNTER_ID_LIST)
{
std::vector<sai_buffer_pool_stat_t> bufferPoolCounterIds;
for (const auto &str : idStrings)
{
sai_buffer_pool_stat_t stat;
sai_deserialize_buffer_pool_stat(str, stat);
bufferPoolCounterIds.push_back(stat);
}

FlexCounter::setBufferPoolCounterList(vid, rid, groupName, bufferPoolCounterIds);
}
else
{
SWSS_LOG_ERROR("Object type and field combination is not supported, object type %s, field %s", objectTypeStr.c_str(), field.c_str());
Expand Down
Loading

0 comments on commit dcab09f

Please sign in to comment.