Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion syncd/FlexCounter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ 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 COUNTER_TYPE_METER_BUCKET = "DASH Meter Bucket Counter";
static const std::string COUNTER_TYPE_POLICER = "Policer Counter";
static const std::string COUNTER_TYPE_SRV6 = "SRv6 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 @@ -64,7 +65,8 @@ const std::map<std::tuple<sai_object_type_t, std::string>, std::string> FlexCoun
{{SAI_OBJECT_TYPE_POLICER, POLICER_COUNTER_ID_LIST}, COUNTER_TYPE_POLICER},
{{SAI_OBJECT_TYPE_TUNNEL, TUNNEL_COUNTER_ID_LIST}, COUNTER_TYPE_TUNNEL},
{{(sai_object_type_t)SAI_OBJECT_TYPE_ENI, ENI_COUNTER_ID_LIST}, COUNTER_TYPE_ENI},
{{(sai_object_type_t)SAI_OBJECT_TYPE_ENI, DASH_METER_COUNTER_ID_LIST}, COUNTER_TYPE_METER_BUCKET}
{{(sai_object_type_t)SAI_OBJECT_TYPE_ENI, DASH_METER_COUNTER_ID_LIST}, COUNTER_TYPE_METER_BUCKET},
{{SAI_OBJECT_TYPE_COUNTER, SRV6_COUNTER_ID_LIST}, COUNTER_TYPE_SRV6},
};

BaseCounterContext::BaseCounterContext(const std::string &name, const std::string &instance):
Expand Down Expand Up @@ -2411,6 +2413,10 @@ std::shared_ptr<BaseCounterContext> FlexCounter::createCounterContext(
{
return std::make_shared<CounterContext<sai_policer_stat_t>>(context_name, instance, SAI_OBJECT_TYPE_POLICER, m_vendorSai.get(), m_statsMode);
}
else if (context_name == COUNTER_TYPE_SRV6)
{
return std::make_shared<CounterContext<sai_counter_stat_t>>(context_name, instance, SAI_OBJECT_TYPE_COUNTER, m_vendorSai.get(), m_statsMode);
}

SWSS_LOG_THROW("Invalid counter type %s", context_name.c_str());
// GCC 8.3 requires a return value here
Expand Down Expand Up @@ -2704,6 +2710,11 @@ void FlexCounter::removeCounter(
getCounterContext(COUNTER_TYPE_FLOW)->removeObject(vid);
removeDataFromCountersDB(vid, ":TRAP");
}

if (hasCounterContext(COUNTER_TYPE_SRV6))
{
getCounterContext(COUNTER_TYPE_SRV6)->removeObject(vid);
}
}
else if (objectType == SAI_OBJECT_TYPE_POLICER)
{
Expand Down
33 changes: 31 additions & 2 deletions unittest/syncd/TestFlexCounter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,26 @@ TEST(FlexCounter, addRemoveCounter)
false,
STATS_MODE_READ,
true);

testAddRemoveCounter(
1,
SAI_OBJECT_TYPE_COUNTER,
SRV6_COUNTER_ID_LIST,
{"SAI_COUNTER_STAT_PACKETS", "SAI_COUNTER_STAT_BYTES"},
{"100", "200"},
counterVerifyFunc,
false);

testAddRemoveCounter(
1,
SAI_OBJECT_TYPE_COUNTER,
SRV6_COUNTER_ID_LIST,
{"SAI_COUNTER_STAT_PACKETS", "SAI_COUNTER_STAT_BYTES"},
{"100", "200"},
counterVerifyFunc,
false,
STATS_MODE_READ,
true);
}

TEST(FlexCounter, UpdateExistingCounterAddBulk)
Expand Down Expand Up @@ -1047,6 +1067,8 @@ TEST(FlexCounter, bulkCounter)
{"10", "20"},
counterVerifyFunc,
false);
// buffer pool stats does not support bulk
EXPECT_EQ(false, clearCalled);

capabilities = (SAI_STATS_MODE_READ|SAI_STATS_MODE_BULK_READ);
testAddRemoveCounter(
Expand All @@ -1060,8 +1082,15 @@ TEST(FlexCounter, bulkCounter)
{"100", "200", "300", "400", "500", "600", "700", "800"},
counterVerifyFunc,
false);
// buffer pool stats does not support bulk
EXPECT_EQ(false, clearCalled);

testAddRemoveCounter(
2,
SAI_OBJECT_TYPE_COUNTER,
SRV6_COUNTER_ID_LIST,
{"SAI_COUNTER_STAT_PACKETS", "SAI_COUNTER_STAT_BYTES"},
{"100", "200"},
counterVerifyFunc,
false);
}

TEST(FlexCounter, bulkChunksize)
Expand Down
Loading