Skip to content

Commit dcab09f

Browse files
wendanilguohan
authored andcommitted
Add buffer pool stat to flex counter architecture (#451)
1 parent f93e27a commit dcab09f

File tree

5 files changed

+308
-13
lines changed

5 files changed

+308
-13
lines changed

meta/sai_serialize.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,10 @@ void sai_deserialize_ingress_priority_group_attr(
277277
_In_ const std::string& s,
278278
_Out_ sai_ingress_priority_group_attr_t& attr);
279279

280+
void sai_deserialize_buffer_pool_stat(
281+
_In_ const std::string& s,
282+
_Out_ sai_buffer_pool_stat_t& stat);
283+
280284
void sai_deserialize_queue_attr(
281285
_In_ const std::string& s,
282286
_Out_ sai_queue_attr_t& attr);

meta/saiserialize.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2968,6 +2968,15 @@ void sai_deserialize_ingress_priority_group_attr(
29682968
sai_deserialize_enum(s, &sai_metadata_enum_sai_ingress_priority_group_attr_t, (int32_t&)attr);
29692969
}
29702970

2971+
void sai_deserialize_buffer_pool_stat(
2972+
_In_ const std::string& s,
2973+
_Out_ sai_buffer_pool_stat_t& stat)
2974+
{
2975+
SWSS_LOG_ENTER();
2976+
2977+
sai_deserialize_enum(s, &sai_metadata_enum_sai_buffer_pool_stat_t, (int32_t&)stat);
2978+
}
2979+
29712980
void sai_deserialize_queue_attr(
29722981
_In_ const std::string& s,
29732982
_Out_ sai_queue_attr_t& attr)

syncd/syncd.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2831,6 +2831,14 @@ void processFlexCounterGroupEvent(
28312831
FlexCounter::addPortCounterPlugin(sha, groupName);
28322832
}
28332833
}
2834+
else if (field == BUFFER_POOL_PLUGIN_FIELD)
2835+
{
2836+
auto shaStrings = swss::tokenize(value, ',');
2837+
for (const auto &sha : shaStrings)
2838+
{
2839+
FlexCounter::addBufferPoolCounterPlugin(sha, groupName);
2840+
}
2841+
}
28342842
else if (field == FLEX_COUNTER_STATUS_FIELD)
28352843
{
28362844
FlexCounter::updateFlexCounterStatus(value, groupName);
@@ -2894,6 +2902,10 @@ void processFlexCounterEvent(
28942902
{
28952903
FlexCounter::removeRif(vid, groupName);
28962904
}
2905+
else if (objectType == SAI_OBJECT_TYPE_BUFFER_POOL)
2906+
{
2907+
FlexCounter::removeBufferPool(vid, groupName);
2908+
}
28972909
else
28982910
{
28992911
SWSS_LOG_ERROR("Object type for removal not supported, %s", objectTypeStr.c_str());
@@ -2919,6 +2931,7 @@ void processFlexCounterEvent(
29192931
sai_deserialize_port_stat(str.c_str(), &stat);
29202932
portCounterIds.push_back(stat);
29212933
}
2934+
29222935
FlexCounter::setPortCounterList(vid, rid, groupName, portCounterIds);
29232936
}
29242937
else if (objectType == SAI_OBJECT_TYPE_QUEUE && field == QUEUE_COUNTER_ID_LIST)
@@ -2930,6 +2943,7 @@ void processFlexCounterEvent(
29302943
sai_deserialize_queue_stat(str.c_str(), &stat);
29312944
queueCounterIds.push_back(stat);
29322945
}
2946+
29332947
FlexCounter::setQueueCounterList(vid, rid, groupName, queueCounterIds);
29342948
}
29352949
else if (objectType == SAI_OBJECT_TYPE_QUEUE && field == QUEUE_ATTR_ID_LIST)
@@ -2953,6 +2967,7 @@ void processFlexCounterEvent(
29532967
sai_deserialize_ingress_priority_group_stat(str.c_str(), &stat);
29542968
pgCounterIds.push_back(stat);
29552969
}
2970+
29562971
FlexCounter::setPriorityGroupCounterList(vid, rid, groupName, pgCounterIds);
29572972
}
29582973
else if (objectType == SAI_OBJECT_TYPE_INGRESS_PRIORITY_GROUP && field == PG_ATTR_ID_LIST)
@@ -2976,8 +2991,21 @@ void processFlexCounterEvent(
29762991
sai_deserialize_router_interface_stat(str.c_str(), &stat);
29772992
rifCounterIds.push_back(stat);
29782993
}
2994+
29792995
FlexCounter::setRifCounterList(vid, rid, groupName, rifCounterIds);
29802996
}
2997+
else if (objectType == SAI_OBJECT_TYPE_BUFFER_POOL && field == BUFFER_POOL_COUNTER_ID_LIST)
2998+
{
2999+
std::vector<sai_buffer_pool_stat_t> bufferPoolCounterIds;
3000+
for (const auto &str : idStrings)
3001+
{
3002+
sai_buffer_pool_stat_t stat;
3003+
sai_deserialize_buffer_pool_stat(str, stat);
3004+
bufferPoolCounterIds.push_back(stat);
3005+
}
3006+
3007+
FlexCounter::setBufferPoolCounterList(vid, rid, groupName, bufferPoolCounterIds);
3008+
}
29813009
else
29823010
{
29833011
SWSS_LOG_ERROR("Object type and field combination is not supported, object type %s, field %s", objectTypeStr.c_str(), field.c_str());

0 commit comments

Comments
 (0)