Skip to content

Commit 1fd1dbf

Browse files
Add support for route flow counter (#2094)
* Add support for route flow counter
1 parent d8fadc6 commit 1fd1dbf

24 files changed

+1733
-29
lines changed

orchagent/Makefile.am

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ orchagent_SOURCES = \
9696
response_publisher.cpp \
9797
nvgreorch.cpp
9898

99-
orchagent_SOURCES += flex_counter/flex_counter_manager.cpp flex_counter/flex_counter_stat_manager.cpp flex_counter/flow_counter_handler.cpp
99+
orchagent_SOURCES += flex_counter/flex_counter_manager.cpp flex_counter/flex_counter_stat_manager.cpp flex_counter/flow_counter_handler.cpp flex_counter/flowcounterrouteorch.cpp
100100
orchagent_SOURCES += debug_counter/debug_counter.cpp debug_counter/drop_counter.cpp
101101
orchagent_SOURCES += p4orch/p4orch.cpp \
102102
p4orch/p4orch_util.cpp \

orchagent/flex_counter/flex_counter_manager.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ const unordered_map<CounterType, string> FlexCounterManager::counter_id_field_lo
4444
{ CounterType::ACL_COUNTER, ACL_COUNTER_ATTR_ID_LIST },
4545
{ CounterType::TUNNEL, TUNNEL_COUNTER_ID_LIST },
4646
{ CounterType::HOSTIF_TRAP, FLOW_COUNTER_ID_LIST },
47+
{ CounterType::ROUTE, FLOW_COUNTER_ID_LIST },
4748
};
4849

4950
FlexManagerDirectory g_FlexManagerDirectory;

orchagent/flex_counter/flex_counter_manager.h

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ enum class CounterType
3131
ACL_COUNTER,
3232
TUNNEL,
3333
HOSTIF_TRAP,
34+
ROUTE,
3435
};
3536

3637
// FlexCounterManager allows users to manage a group of flex counters.

orchagent/flex_counter/flow_counter_handler.cpp

+13
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,16 @@ void FlowCounterHandler::getGenericCounterStatIdList(std::unordered_set<std::str
4747
counter_stats.emplace(sai_serialize_counter_stat(it));
4848
}
4949
}
50+
51+
bool FlowCounterHandler::queryRouteFlowCounterCapability()
52+
{
53+
sai_attr_capability_t capability;
54+
sai_status_t status = sai_query_attribute_capability(gSwitchId, SAI_OBJECT_TYPE_ROUTE_ENTRY, SAI_ROUTE_ENTRY_ATTR_COUNTER_ID, &capability);
55+
if (status != SAI_STATUS_SUCCESS)
56+
{
57+
SWSS_LOG_WARN("Could not query route entry attribute SAI_ROUTE_ENTRY_ATTR_COUNTER_ID %d", status);
58+
return false;
59+
}
60+
61+
return capability.set_implemented;
62+
}

orchagent/flex_counter/flow_counter_handler.h

+1
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@ class FlowCounterHandler
1313
static bool createGenericCounter(sai_object_id_t &counter_id);
1414
static bool removeGenericCounter(sai_object_id_t counter_id);
1515
static void getGenericCounterStatIdList(std::unordered_set<std::string>& counter_stats);
16+
static bool queryRouteFlowCounterCapability();
1617
};

0 commit comments

Comments
 (0)