From a4ee3ada9180ec30356353c27076143638a451d2 Mon Sep 17 00:00:00 2001 From: Kamil Cudnik Date: Fri, 26 Oct 2018 19:21:11 +0200 Subject: [PATCH] Add VS support for counters (#363) --- vslib/inc/sai_vs.h | 24 ++- vslib/inc/sai_vs_internal.h | 81 ++++++-- vslib/src/Makefile.am | 2 +- vslib/src/sai_vs_bridge.cpp | 95 +-------- vslib/src/sai_vs_buffer.cpp | 81 +------- vslib/src/sai_vs_generic_get_stats.cpp | 91 --------- vslib/src/sai_vs_generic_stats.cpp | 258 +++++++++++++++++++++++++ vslib/src/sai_vs_hostintf.cpp | 2 +- vslib/src/sai_vs_policer.cpp | 45 +---- vslib/src/sai_vs_port.cpp | 66 +------ vslib/src/sai_vs_queue.cpp | 34 +--- vslib/src/sai_vs_router_interface.cpp | 45 +---- vslib/src/sai_vs_stp.cpp | 1 - vslib/src/sai_vs_tunnel.cpp | 49 +---- vslib/src/sai_vs_vlan.cpp | 45 +---- 15 files changed, 370 insertions(+), 549 deletions(-) delete mode 100644 vslib/src/sai_vs_generic_get_stats.cpp create mode 100644 vslib/src/sai_vs_generic_stats.cpp diff --git a/vslib/inc/sai_vs.h b/vslib/inc/sai_vs.h index 0a1e30991762..a67b8ec3eb2c 100644 --- a/vslib/inc/sai_vs.h +++ b/vslib/inc/sai_vs.h @@ -176,12 +176,28 @@ sai_status_t vs_generic_get_route_entry( // STATS -template sai_status_t vs_generic_get_stats( _In_ sai_object_type_t object_type, _In_ sai_object_id_t object_id, - _In_ uint32_t count, - _In_ const T* counter_id_list, - _Out_ uint64_t *counter_list); + _In_ const sai_enum_metadata_t *enum_metadata, + _In_ uint32_t number_of_counters, + _In_ const int32_t *counter_ids, + _Out_ uint64_t *counters); + +sai_status_t vs_generic_get_stats_ext( + _In_ sai_object_type_t object_type, + _In_ sai_object_id_t object_id, + _In_ const sai_enum_metadata_t *enum_metadata, + _In_ uint32_t number_of_counters, + _In_ const int32_t *counter_ids, + _In_ sai_stats_mode_t mode, + _Out_ uint64_t *counters); + +sai_status_t vs_generic_clear_stats( + _In_ sai_object_type_t object_type, + _In_ sai_object_id_t object_id, + _In_ const sai_enum_metadata_t *enum_metadata, + _In_ uint32_t number_of_counters, + _In_ const int32_t *counter_ids); #endif // __SAI_VS__ diff --git a/vslib/inc/sai_vs_internal.h b/vslib/inc/sai_vs_internal.h index 05d2eca0525b..973f0a05474d 100644 --- a/vslib/inc/sai_vs_internal.h +++ b/vslib/inc/sai_vs_internal.h @@ -142,21 +142,68 @@ // stats -#define VS_GENERIC_GET_STATS(OBJECT_TYPE,object_type) \ - sai_status_t vs_get_ ## object_type ## _stats( \ - _In_ sai_object_id_t object_type ##_id, \ - _In_ uint32_t count, \ - _In_ const sai_ ## object_type ## _stat_t *counter_id_list, \ - _Out_ uint64_t *counter_list) \ - { \ - MUTEX(); \ - SWSS_LOG_ENTER(); \ - \ - return meta_sai_get_stats_oid( \ - SAI_OBJECT_TYPE_ ## OBJECT_TYPE, \ - object_type ## _id, \ - count, \ - counter_id_list, \ - counter_list, \ - &vs_generic_get_stats); \ +#define VS_GET_STATS(OBJECT_TYPE,object_type) \ + sai_status_t vs_get_ ## object_type ## _stats( \ + _In_ sai_object_id_t object_type ## _id, \ + _In_ uint32_t number_of_counters, \ + _In_ const sai_ ## object_type ## _stat_t *counter_ids, \ + _Out_ uint64_t *counters) \ + { \ + MUTEX(); \ + SWSS_LOG_ENTER(); \ + return vs_generic_get_stats( \ + SAI_OBJECT_TYPE_ ## OBJECT_TYPE, \ + object_type ## _id, \ + &sai_metadata_enum_sai_ ## object_type ## _stat_t, \ + number_of_counters, \ + (const int32_t*)counter_ids, \ + counters); \ } + +#define VS_GET_STATS_EXT(OBJECT_TYPE,object_type) \ + sai_status_t vs_get_ ## object_type ## _stats_ext( \ + _In_ sai_object_id_t object_type ## _id, \ + _In_ uint32_t number_of_counters, \ + _In_ const sai_ ## object_type ## _stat_t *counter_ids, \ + _In_ sai_stats_mode_t mode, \ + _Out_ uint64_t *counters) \ + { \ + MUTEX(); \ + SWSS_LOG_ENTER(); \ + return vs_generic_get_stats_ext( \ + SAI_OBJECT_TYPE_ ## OBJECT_TYPE, \ + object_type ## _id, \ + &sai_metadata_enum_sai_ ## object_type ## _stat_t, \ + number_of_counters, \ + (const int32_t*)counter_ids, \ + mode, \ + counters); \ + } + +#define VS_CLEAR_STATS(OBJECT_TYPE,object_type) \ + sai_status_t vs_clear_ ## object_type ## _stats( \ + _In_ sai_object_id_t object_type ## _id, \ + _In_ uint32_t number_of_counters, \ + _In_ const sai_ ## object_type ## _stat_t *counter_ids) \ + { \ + MUTEX(); \ + SWSS_LOG_ENTER(); \ + return vs_generic_clear_stats( \ + SAI_OBJECT_TYPE_ ## OBJECT_TYPE, \ + object_type ## _id, \ + &sai_metadata_enum_sai_ ## object_type ## _stat_t, \ + number_of_counters, \ + (const int32_t*)counter_ids); \ + } + +#define VS_GENERIC_STATS(OT, ot) \ + VS_GET_STATS(OT,ot); \ + VS_GET_STATS_EXT(OT,ot); \ + VS_CLEAR_STATS(OT,ot); + +// common stats api + +#define VS_GENERIC_STATS_API(ot) \ + vs_get_ ## ot ## _stats, \ + vs_get_ ## ot ## _stats_ext, \ + vs_clear_ ## ot ## _stats, diff --git a/vslib/src/Makefile.am b/vslib/src/Makefile.am index 6acc41c94fb0..0991d0f105be 100644 --- a/vslib/src/Makefile.am +++ b/vslib/src/Makefile.am @@ -42,7 +42,7 @@ libsaivs_la_SOURCES = \ sai_vs_generic_get.cpp \ sai_vs_generic_remove.cpp \ sai_vs_generic_set.cpp \ - sai_vs_generic_get_stats.cpp \ + sai_vs_generic_stats.cpp \ sai_vs.cpp \ sai_vs_switch_BCM56850.cpp \ sai_vs_switch_MLNX2700.cpp diff --git a/vslib/src/sai_vs_bridge.cpp b/vslib/src/sai_vs_bridge.cpp index a9d92368c559..b5374ba5920d 100644 --- a/vslib/src/sai_vs_bridge.cpp +++ b/vslib/src/sai_vs_bridge.cpp @@ -1,98 +1,15 @@ #include "sai_vs.h" #include "sai_vs_internal.h" -sai_status_t vs_get_bridge_stats( - _In_ sai_object_id_t bridge_id, - _In_ uint32_t number_of_counters, - _In_ const sai_bridge_stat_t *counter_ids, - _Out_ uint64_t *counters) -{ - MUTEX(); - - SWSS_LOG_ENTER(); - - return SAI_STATUS_NOT_IMPLEMENTED; -} - -sai_status_t vs_get_bridge_stats_ext( - _In_ sai_object_id_t bridge_id, - _In_ uint32_t number_of_counters, - _In_ const sai_bridge_stat_t *counter_ids, - _In_ sai_stats_mode_t mode, - _Out_ uint64_t *counters) -{ - MUTEX(); - - SWSS_LOG_ENTER(); - - return SAI_STATUS_NOT_IMPLEMENTED; -} - -sai_status_t vs_clear_bridge_stats( - _In_ sai_object_id_t bridge_id, - _In_ uint32_t number_of_counters, - _In_ const sai_bridge_stat_t *counter_ids) -{ - MUTEX(); - - SWSS_LOG_ENTER(); - - return SAI_STATUS_NOT_IMPLEMENTED; -} - -sai_status_t vs_get_bridge_port_stats( - _In_ sai_object_id_t bridge_port_id, - _In_ uint32_t number_of_counters, - _In_ const sai_bridge_port_stat_t *counter_ids, - _Out_ uint64_t *counters) -{ - MUTEX(); - - SWSS_LOG_ENTER(); - - return SAI_STATUS_NOT_IMPLEMENTED; -} - -sai_status_t vs_get_bridge_port_stats_ext( - _In_ sai_object_id_t bridge_port_id, - _In_ uint32_t number_of_counters, - _In_ const sai_bridge_port_stat_t *counter_ids, - _In_ sai_stats_mode_t mode, - _Out_ uint64_t *counters) -{ - MUTEX(); - - SWSS_LOG_ENTER(); - - return SAI_STATUS_NOT_IMPLEMENTED; -} - -sai_status_t vs_clear_bridge_port_stats( - _In_ sai_object_id_t bridge_port_id, - _In_ uint32_t number_of_counters, - _In_ const sai_bridge_port_stat_t *counter_ids) -{ - MUTEX(); - - SWSS_LOG_ENTER(); - - return SAI_STATUS_NOT_IMPLEMENTED; -} - VS_GENERIC_QUAD(BRIDGE,bridge); VS_GENERIC_QUAD(BRIDGE_PORT,bridge_port); +VS_GENERIC_STATS(BRIDGE,bridge); +VS_GENERIC_STATS(BRIDGE_PORT,bridge_port); -const sai_bridge_api_t vs_bridge_api = -{ - VS_GENERIC_QUAD_API(bridge) - - vs_get_bridge_stats, - vs_get_bridge_stats_ext, - vs_clear_bridge_stats, +const sai_bridge_api_t vs_bridge_api = { + VS_GENERIC_QUAD_API(bridge) + VS_GENERIC_STATS_API(bridge) VS_GENERIC_QUAD_API(bridge_port) - - vs_get_bridge_port_stats, - vs_get_bridge_port_stats_ext, - vs_clear_bridge_port_stats, + VS_GENERIC_STATS_API(bridge_port) }; diff --git a/vslib/src/sai_vs_buffer.cpp b/vslib/src/sai_vs_buffer.cpp index b3866d9d5305..1b484eba1b73 100644 --- a/vslib/src/sai_vs_buffer.cpp +++ b/vslib/src/sai_vs_buffer.cpp @@ -1,90 +1,17 @@ #include "sai_vs.h" #include "sai_vs_internal.h" -sai_status_t vs_clear_ingress_priority_group_stats( - _In_ sai_object_id_t ingress_pg_id, - _In_ uint32_t number_of_counters, - _In_ const sai_ingress_priority_group_stat_t *counter_ids) -{ - MUTEX(); - - SWSS_LOG_ENTER(); - - return SAI_STATUS_NOT_IMPLEMENTED; -} - -sai_status_t vs_get_ingress_priority_group_stats_ext( - _In_ sai_object_id_t ingress_priority_group_id, - _In_ uint32_t number_of_counters, - _In_ const sai_ingress_priority_group_stat_t *counter_ids, - _In_ sai_stats_mode_t mode, - _Out_ uint64_t *counters) -{ - MUTEX(); - - SWSS_LOG_ENTER(); - - return SAI_STATUS_NOT_IMPLEMENTED; -} - -sai_status_t vs_get_buffer_pool_stats( - _In_ sai_object_id_t pool_id, - _In_ uint32_t number_of_counters, - _In_ const sai_buffer_pool_stat_t *counter_ids, - _Out_ uint64_t *counters) -{ - MUTEX(); - - SWSS_LOG_ENTER(); - - return SAI_STATUS_NOT_IMPLEMENTED; -} - -sai_status_t vs_get_buffer_pool_stats_ext( - _In_ sai_object_id_t buffer_pool_id, - _In_ uint32_t number_of_counters, - _In_ const sai_buffer_pool_stat_t *counter_ids, - _In_ sai_stats_mode_t mode, - _Out_ uint64_t *counters) -{ - MUTEX(); - - SWSS_LOG_ENTER(); - - return SAI_STATUS_NOT_IMPLEMENTED; -} - -sai_status_t vs_clear_buffer_pool_stats( - _In_ sai_object_id_t pool_id, - _In_ uint32_t number_of_counters, - _In_ const sai_buffer_pool_stat_t *counter_ids) -{ - MUTEX(); - - SWSS_LOG_ENTER(); - - return SAI_STATUS_NOT_IMPLEMENTED; -} - -VS_GENERIC_GET_STATS(INGRESS_PRIORITY_GROUP,ingress_priority_group); - VS_GENERIC_QUAD(BUFFER_POOL,buffer_pool); VS_GENERIC_QUAD(INGRESS_PRIORITY_GROUP,ingress_priority_group); VS_GENERIC_QUAD(BUFFER_PROFILE,buffer_profile); +VS_GENERIC_STATS(BUFFER_POOL,buffer_pool); +VS_GENERIC_STATS(INGRESS_PRIORITY_GROUP,ingress_priority_group); const sai_buffer_api_t vs_buffer_api = { VS_GENERIC_QUAD_API(buffer_pool) - - vs_get_buffer_pool_stats, - vs_get_buffer_pool_stats_ext, - vs_clear_buffer_pool_stats, - + VS_GENERIC_STATS_API(buffer_pool) VS_GENERIC_QUAD_API(ingress_priority_group) - - vs_get_ingress_priority_group_stats, - vs_get_ingress_priority_group_stats_ext, - vs_clear_ingress_priority_group_stats, - + VS_GENERIC_STATS_API(ingress_priority_group) VS_GENERIC_QUAD_API(buffer_profile) }; diff --git a/vslib/src/sai_vs_generic_get_stats.cpp b/vslib/src/sai_vs_generic_get_stats.cpp deleted file mode 100644 index 622b7cb8d462..000000000000 --- a/vslib/src/sai_vs_generic_get_stats.cpp +++ /dev/null @@ -1,91 +0,0 @@ -#include "sai_vs.h" -#include "sai_vs_state.h" -#include "meta/sai_serialize.h" - -template -sai_status_t internal_vs_generic_get_stats( - _In_ sai_object_type_t object_type, - _In_ const std::string &serialized_object_id, - _In_ sai_object_id_t switch_id, - _In_ uint32_t count, - _In_ const T *counter_id_list, - _Out_ uint64_t *counter_list) -{ - SWSS_LOG_ENTER(); - - bool perform_set = false; - - if (meta_unittests_enabled() && (count & 0x80000000)) - { - count = count & ~0x80000000; - - SWSS_LOG_NOTICE("unittests are enabled and counters count MSB is set to 1, performing SET on counters"); - - perform_set = true; - } - - auto &countersMap = g_switch_state_map.at(switch_id)->countersMap; - - auto it = countersMap.find(serialized_object_id); - - if (it == countersMap.end()) - countersMap[serialized_object_id] = std::map(); - - std::map& counters = countersMap[serialized_object_id]; - - for (uint32_t i = 0; i < count; ++i) - { - if (perform_set) - { - counters[ counter_id_list[i] ] = counter_list[i]; - } - else - { - auto itt = counters.find(counter_id_list[i]); - - if (itt == counters.end()) - counter_list[i] = 0; - else - counter_list[i] = itt->second; - } - } - - return SAI_STATUS_SUCCESS; -} - -template -sai_status_t vs_generic_get_stats( - _In_ sai_object_type_t object_type, - _In_ sai_object_id_t object_id, - _In_ uint32_t count, - _In_ const T* counter_id_list, - _Out_ uint64_t *counter_list) -{ - SWSS_LOG_ENTER(); - - std::string str_object_id = sai_serialize_object_id(object_id); - - sai_object_id_t switch_id = sai_switch_id_query(object_id); - - return internal_vs_generic_get_stats( - object_type, - str_object_id, - switch_id, - count, - counter_id_list, - counter_list); -} - -#define DECLARE_VS_GENERIC_GET_STATS(type) \ - template \ - sai_status_t vs_generic_get_stats( \ - _In_ sai_object_type_t object_type, \ - _In_ sai_object_id_t object_id, \ - _In_ uint32_t count, \ - _In_ const sai_ ## type ## _stat_t *counter_id_list, \ - _Out_ uint64_t *counter_list); \ - -DECLARE_VS_GENERIC_GET_STATS(port); -DECLARE_VS_GENERIC_GET_STATS(port_pool); -DECLARE_VS_GENERIC_GET_STATS(queue); -DECLARE_VS_GENERIC_GET_STATS(ingress_priority_group); diff --git a/vslib/src/sai_vs_generic_stats.cpp b/vslib/src/sai_vs_generic_stats.cpp new file mode 100644 index 000000000000..4f5d4bb6056f --- /dev/null +++ b/vslib/src/sai_vs_generic_stats.cpp @@ -0,0 +1,258 @@ +#include "sai_vs.h" +#include "sai_vs_state.h" +#include "meta/sai_serialize.h" + +/* + * Max number of counters used in 1 api call + */ +#define VS_MAX_COUNTERS 128 + +#define VS_COUNTERS_COUNT_MSB (0x80000000) + +sai_status_t internal_vs_generic_stats_function( + _In_ sai_object_type_t obejct_type, + _In_ sai_object_id_t object_id, + _In_ sai_object_id_t switch_id, + _In_ const sai_enum_metadata_t *enum_metadata, + _In_ uint32_t number_of_counters, + _In_ const int32_t *counter_ids, + _In_ sai_stats_mode_t mode, + _Out_ uint64_t *counters) +{ + SWSS_LOG_ENTER(); + + bool perform_set = false; + + if (meta_unittests_enabled() && (number_of_counters & VS_COUNTERS_COUNT_MSB )) + { + number_of_counters &= ~VS_COUNTERS_COUNT_MSB; + + SWSS_LOG_NOTICE("unittests are enabled and counters count MSB is set to 1, performing SET on %s counters (%s)", + sai_serialize_object_id(object_id).c_str(), + enum_metadata->name); + + perform_set = true; + } + + auto &countersMap = g_switch_state_map.at(switch_id)->countersMap; + + auto str_object_id = sai_serialize_object_id(object_id); + + auto mapit = countersMap.find(str_object_id); + + if (mapit == countersMap.end()) + countersMap[str_object_id] = std::map(); + + std::map& localcounters = countersMap[str_object_id]; + + for (uint32_t i = 0; i < number_of_counters; ++i) + { + int32_t id = counter_ids[i]; + + if (perform_set) + { + localcounters[ id ] = counters[i]; + } + else + { + auto it = localcounters.find(id); + + if (it == localcounters.end()) + { + // if counter is not found on list, just return 0 + counters[i] = 0; + } + else + counters[i] = it->second; + + if (mode == SAI_STATS_MODE_READ_AND_CLEAR) + { + localcounters[ id ] = 0; + } + } + } + + return SAI_STATUS_SUCCESS; +} + +sai_status_t vs_generic_stats_function( + _In_ sai_object_type_t object_type, + _In_ sai_object_id_t object_id, + _In_ const sai_enum_metadata_t *enum_metadata, + _In_ uint32_t number_of_counters, + _In_ const int32_t *counter_ids, + _In_ sai_stats_mode_t mode, + _Out_ uint64_t *counters) +{ + SWSS_LOG_ENTER(); + + /* + * Do all parameter validation. + */ + + if (object_id == SAI_NULL_OBJECT_ID) + { + SWSS_LOG_ERROR("object id is NULL"); + + return SAI_STATUS_INVALID_PARAMETER; + } + + sai_object_type_t ot = sai_object_type_query(object_id); + + if (ot != object_type) + { + SWSS_LOG_ERROR("object %s is %s but expected %s", + sai_serialize_object_id(object_id).c_str(), + sai_serialize_object_type(ot).c_str(), + sai_serialize_object_type(object_type).c_str()); + + return SAI_STATUS_INVALID_PARAMETER; + } + + sai_object_id_t switch_id = sai_switch_id_query(object_id); + + if (switch_id == SAI_NULL_OBJECT_ID) + { + SWSS_LOG_ERROR("object %s does not correspond to any switch object", + sai_serialize_object_id(object_id).c_str()); + + return SAI_STATUS_INVALID_PARAMETER; + } + + uint32_t count = number_of_counters & ~VS_COUNTERS_COUNT_MSB; + + if (count > VS_MAX_COUNTERS) + { + SWSS_LOG_ERROR("max supported counters to get/clear is %u, but %u given", + VS_MAX_COUNTERS, + count); + + return SAI_STATUS_INVALID_PARAMETER; + } + + if (counter_ids == NULL) + { + SWSS_LOG_ERROR("counter ids pointer is NULL"); + + return SAI_STATUS_INVALID_PARAMETER; + } + + if (counters == NULL) + { + SWSS_LOG_ERROR("counters output pointer is NULL"); + + return SAI_STATUS_INVALID_PARAMETER; + } + + if (enum_metadata == NULL) + { + SWSS_LOG_ERROR("enum metadata pointer is NULL, bug?"); + + return SAI_STATUS_FAILURE; + } + + for (uint32_t i = 0; i < count; i++) + { + if (sai_metadata_get_enum_value_name(enum_metadata, counter_ids[i]) == NULL) + { + SWSS_LOG_ERROR("counter id %u is not allowed on %s", counter_ids[i], enum_metadata->name); + + return SAI_STATUS_INVALID_PARAMETER; + } + } + + switch (mode) + { + case SAI_STATS_MODE_READ: + case SAI_STATS_MODE_READ_AND_CLEAR: + break; + + default: + + SWSS_LOG_ERROR("counters mode is invalid %d", mode); + + return SAI_STATUS_INVALID_PARAMETER; + } + + return internal_vs_generic_stats_function( + object_type, + object_id, + switch_id, + enum_metadata, + number_of_counters, + counter_ids, + mode, + counters); +} + +sai_status_t vs_generic_get_stats( + _In_ sai_object_type_t object_type, + _In_ sai_object_id_t object_id, + _In_ const sai_enum_metadata_t *enum_metadata, + _In_ uint32_t number_of_counters, + _In_ const int32_t *counter_ids, + _Out_ uint64_t *counters) +{ + SWSS_LOG_ENTER(); + + /* + * Get stats is the same as get stats ext with mode == SAI_STATS_MODE_READ. + */ + + return vs_generic_stats_function( + object_type, + object_id, + enum_metadata, + number_of_counters, + counter_ids, + SAI_STATS_MODE_READ, + counters); +} + +sai_status_t vs_generic_get_stats_ext( + _In_ sai_object_type_t object_type, + _In_ sai_object_id_t object_id, + _In_ const sai_enum_metadata_t *enum_metadata, + _In_ uint32_t number_of_counters, + _In_ const int32_t *counter_ids, + _In_ sai_stats_mode_t mode, + _Out_ uint64_t *counters) +{ + SWSS_LOG_ENTER(); + + return vs_generic_stats_function( + object_type, + object_id, + enum_metadata, + number_of_counters, + counter_ids, + mode, + counters); +} + +sai_status_t vs_generic_clear_stats( + _In_ sai_object_type_t object_type, + _In_ sai_object_id_t object_id, + _In_ const sai_enum_metadata_t *enum_metadata, + _In_ uint32_t number_of_counters, + _In_ const int32_t *counter_ids) +{ + SWSS_LOG_ENTER(); + + /* + * Clear stats is the same as get stats ext with mode == + * SAI_STATS_MODE_READ_AND_CLEAR and we just read counters locally and + * discard them, in that way. + */ + + uint64_t counters[VS_MAX_COUNTERS]; + + return vs_generic_stats_function( + object_type, + object_id, + enum_metadata, + number_of_counters, + counter_ids, + SAI_STATS_MODE_READ_AND_CLEAR, + counters); +} diff --git a/vslib/src/sai_vs_hostintf.cpp b/vslib/src/sai_vs_hostintf.cpp index 87e9b0f797f7..6b758226d729 100644 --- a/vslib/src/sai_vs_hostintf.cpp +++ b/vslib/src/sai_vs_hostintf.cpp @@ -192,7 +192,7 @@ void findBridgeVlanForPortVlan( attrs[0].id = SAI_BRIDGE_PORT_ATTR_PORT_ID; attrs[1].id = SAI_BRIDGE_PORT_ATTR_TYPE; - sai_status_t status = vs_generic_get(SAI_OBJECT_TYPE_BRIDGE_PORT, bpid, sizeof(attrs)/sizeof(attrs[0]), attrs); + sai_status_t status = vs_generic_get(SAI_OBJECT_TYPE_BRIDGE_PORT, bpid, (uint32_t)(sizeof(attrs)/sizeof(attrs[0])), attrs); if (status != SAI_STATUS_SUCCESS) { diff --git a/vslib/src/sai_vs_policer.cpp b/vslib/src/sai_vs_policer.cpp index e81521fc53cb..b49132a4469e 100644 --- a/vslib/src/sai_vs_policer.cpp +++ b/vslib/src/sai_vs_policer.cpp @@ -1,52 +1,11 @@ #include "sai_vs.h" #include "sai_vs_internal.h" -sai_status_t vs_get_policer_stats( - _In_ sai_object_id_t policer_id, - _In_ uint32_t number_of_counters, - _In_ const sai_policer_stat_t *counter_ids, - _Out_ uint64_t *counters) -{ - MUTEX(); - - SWSS_LOG_ENTER(); - - return SAI_STATUS_NOT_IMPLEMENTED; -} - -sai_status_t vs_clear_policer_stats( - _In_ sai_object_id_t policer_id, - _In_ uint32_t number_of_counters, - _In_ const sai_policer_stat_t *counter_ids) -{ - MUTEX(); - - SWSS_LOG_ENTER(); - - return SAI_STATUS_NOT_IMPLEMENTED; -} - -sai_status_t vs_get_policer_stats_ext( - _In_ sai_object_id_t policer_id, - _In_ uint32_t number_of_counters, - _In_ const sai_policer_stat_t *counter_ids, - _In_ sai_stats_mode_t mode, - _Out_ uint64_t *counters) -{ - MUTEX(); - - SWSS_LOG_ENTER(); - - return SAI_STATUS_NOT_IMPLEMENTED; -} - VS_GENERIC_QUAD(POLICER,policer); +VS_GENERIC_STATS(POLICER,policer); const sai_policer_api_t vs_policer_api = { VS_GENERIC_QUAD_API(policer) - - vs_get_policer_stats, - vs_get_policer_stats_ext, - vs_clear_policer_stats, + VS_GENERIC_STATS_API(policer) }; diff --git a/vslib/src/sai_vs_port.cpp b/vslib/src/sai_vs_port.cpp index 32fa2cb52ece..d511cb93f1e9 100644 --- a/vslib/src/sai_vs_port.cpp +++ b/vslib/src/sai_vs_port.cpp @@ -1,32 +1,6 @@ #include "sai_vs.h" #include "sai_vs_internal.h" -sai_status_t vs_clear_port_stats( - _In_ sai_object_id_t port_id, - _In_ uint32_t number_of_counters, - _In_ const sai_port_stat_t *counter_ids) -{ - MUTEX(); - - SWSS_LOG_ENTER(); - - return SAI_STATUS_NOT_IMPLEMENTED; -} - -sai_status_t vs_get_port_stats_ext( - _In_ sai_object_id_t port_id, - _In_ uint32_t number_of_counters, - _In_ const sai_port_stat_t *counter_ids, - _In_ sai_stats_mode_t mode, - _Out_ uint64_t *counters) -{ - MUTEX(); - - SWSS_LOG_ENTER(); - - return SAI_STATUS_NOT_IMPLEMENTED; -} - sai_status_t vs_clear_port_all_stats( _In_ sai_object_id_t port_id) { @@ -37,50 +11,18 @@ sai_status_t vs_clear_port_all_stats( return SAI_STATUS_NOT_IMPLEMENTED; } -sai_status_t vs_get_port_pool_stats_ext( - _In_ sai_object_id_t port_pool_id, - _In_ uint32_t number_of_counters, - _In_ const sai_port_pool_stat_t *counter_ids, - _In_ sai_stats_mode_t mode, - _Out_ uint64_t *counters) -{ - MUTEX(); - - SWSS_LOG_ENTER(); - - return SAI_STATUS_NOT_IMPLEMENTED; -} - -sai_status_t vs_clear_port_pool_stats( - _In_ sai_object_id_t port_pool_id, - _In_ uint32_t number_of_counters, - _In_ const sai_port_pool_stat_t *counter_ids) -{ - MUTEX(); - - SWSS_LOG_ENTER(); - - return SAI_STATUS_NOT_IMPLEMENTED; -} - -VS_GENERIC_GET_STATS(PORT,port); -VS_GENERIC_GET_STATS(PORT_POOL,port_pool); - VS_GENERIC_QUAD(PORT,port); VS_GENERIC_QUAD(PORT_POOL,port_pool); +VS_GENERIC_STATS(PORT,port); +VS_GENERIC_STATS(PORT_POOL,port_pool); const sai_port_api_t vs_port_api = { VS_GENERIC_QUAD_API(port) + VS_GENERIC_STATS_API(port) - vs_get_port_stats, - vs_get_port_stats_ext, - vs_clear_port_stats, vs_clear_port_all_stats, VS_GENERIC_QUAD_API(port_pool) - - vs_get_port_pool_stats, - vs_get_port_pool_stats_ext, - vs_clear_port_pool_stats + VS_GENERIC_STATS_API(port_pool) }; diff --git a/vslib/src/sai_vs_queue.cpp b/vslib/src/sai_vs_queue.cpp index 25a0d83badca..1ae66a871e34 100644 --- a/vslib/src/sai_vs_queue.cpp +++ b/vslib/src/sai_vs_queue.cpp @@ -1,41 +1,11 @@ #include "sai_vs.h" #include "sai_vs_internal.h" -sai_status_t vs_clear_queue_stats( - _In_ sai_object_id_t queue_id, - _In_ uint32_t number_of_counters, - _In_ const sai_queue_stat_t *counter_ids) -{ - MUTEX(); - - SWSS_LOG_ENTER(); - - return SAI_STATUS_NOT_IMPLEMENTED; -} - -sai_status_t vs_get_queue_stats_ext( - _In_ sai_object_id_t queue_id, - _In_ uint32_t number_of_counters, - _In_ const sai_queue_stat_t *counter_ids, - _In_ sai_stats_mode_t mode, - _Out_ uint64_t *counters) -{ - MUTEX(); - - SWSS_LOG_ENTER(); - - return SAI_STATUS_NOT_IMPLEMENTED; -} - -VS_GENERIC_GET_STATS(QUEUE,queue); - VS_GENERIC_QUAD(QUEUE,queue); +VS_GENERIC_STATS(QUEUE,queue); const sai_queue_api_t vs_queue_api = { VS_GENERIC_QUAD_API(queue) - - vs_get_queue_stats, - vs_get_queue_stats_ext, - vs_clear_queue_stats, + VS_GENERIC_STATS_API(queue) }; diff --git a/vslib/src/sai_vs_router_interface.cpp b/vslib/src/sai_vs_router_interface.cpp index b4f3e48e0194..6cd628239633 100644 --- a/vslib/src/sai_vs_router_interface.cpp +++ b/vslib/src/sai_vs_router_interface.cpp @@ -2,51 +2,10 @@ #include "sai_vs_internal.h" VS_GENERIC_QUAD(ROUTER_INTERFACE,router_interface); - -sai_status_t vs_get_router_interface_stats( - _In_ sai_object_id_t router_interface_id, - _In_ uint32_t number_of_counters, - _In_ const sai_router_interface_stat_t *counter_ids, - _Out_ uint64_t *counters) -{ - MUTEX(); - - SWSS_LOG_ENTER(); - - return SAI_STATUS_NOT_IMPLEMENTED; -} - -sai_status_t vs_get_router_interface_stats_ext( - _In_ sai_object_id_t router_interface_id, - _In_ uint32_t number_of_counters, - _In_ const sai_router_interface_stat_t *counter_ids, - _In_ sai_stats_mode_t mode, - _Out_ uint64_t *counters) -{ - MUTEX(); - - SWSS_LOG_ENTER(); - - return SAI_STATUS_NOT_IMPLEMENTED; -} - -sai_status_t vs_clear_router_interface_stats( - _In_ sai_object_id_t router_interface_id, - _In_ uint32_t number_of_counters, - _In_ const sai_router_interface_stat_t *counter_ids) -{ - MUTEX(); - - SWSS_LOG_ENTER(); - - return SAI_STATUS_NOT_IMPLEMENTED; -} +VS_GENERIC_STATS(ROUTER_INTERFACE,router_interface); const sai_router_interface_api_t vs_router_interface_api = { VS_GENERIC_QUAD_API(router_interface) - - vs_get_router_interface_stats, - vs_get_router_interface_stats_ext, - vs_clear_router_interface_stats, + VS_GENERIC_STATS_API(router_interface) }; diff --git a/vslib/src/sai_vs_stp.cpp b/vslib/src/sai_vs_stp.cpp index e6198d2952ce..9242aa634a05 100644 --- a/vslib/src/sai_vs_stp.cpp +++ b/vslib/src/sai_vs_stp.cpp @@ -33,7 +33,6 @@ sai_status_t vs_remove_stp_ports( VS_GENERIC_QUAD(STP,stp); VS_GENERIC_QUAD(STP_PORT,stp_port); - const sai_stp_api_t vs_stp_api = { VS_GENERIC_QUAD_API(stp) diff --git a/vslib/src/sai_vs_tunnel.cpp b/vslib/src/sai_vs_tunnel.cpp index af3246796aa1..0141d9ef586d 100644 --- a/vslib/src/sai_vs_tunnel.cpp +++ b/vslib/src/sai_vs_tunnel.cpp @@ -1,60 +1,17 @@ #include "sai_vs.h" #include "sai_vs_internal.h" -sai_status_t vs_get_tunnel_stats( - _In_ sai_object_id_t tunnel_id, - _In_ uint32_t number_of_counters, - _In_ const sai_tunnel_stat_t *counter_ids, - _Out_ uint64_t *counters) -{ - MUTEX(); - - SWSS_LOG_ENTER(); - - return SAI_STATUS_NOT_IMPLEMENTED; -} - -sai_status_t vs_get_tunnel_stats_ext( - _In_ sai_object_id_t tunnel_id, - _In_ uint32_t number_of_counters, - _In_ const sai_tunnel_stat_t *counter_ids, - _In_ sai_stats_mode_t mode, - _Out_ uint64_t *counters) -{ - MUTEX(); - - SWSS_LOG_ENTER(); - - return SAI_STATUS_NOT_IMPLEMENTED; -} - -sai_status_t vs_clear_tunnel_stats( - _In_ sai_object_id_t tunnel_id, - _In_ uint32_t number_of_counters, - _In_ const sai_tunnel_stat_t *counter_ids) -{ - MUTEX(); - - SWSS_LOG_ENTER(); - - return SAI_STATUS_NOT_IMPLEMENTED; -} - - VS_GENERIC_QUAD(TUNNEL_MAP,tunnel_map); VS_GENERIC_QUAD(TUNNEL,tunnel); VS_GENERIC_QUAD(TUNNEL_TERM_TABLE_ENTRY,tunnel_term_table_entry); VS_GENERIC_QUAD(TUNNEL_MAP_ENTRY,tunnel_map_entry); - +VS_GENERIC_STATS(TUNNEL,tunnel); const sai_tunnel_api_t vs_tunnel_api = { + VS_GENERIC_QUAD_API(tunnel_map) VS_GENERIC_QUAD_API(tunnel) - - vs_get_tunnel_stats, - vs_get_tunnel_stats_ext, - vs_clear_tunnel_stats, - + VS_GENERIC_STATS_API(tunnel) VS_GENERIC_QUAD_API(tunnel_term_table_entry) VS_GENERIC_QUAD_API(tunnel_map_entry) }; diff --git a/vslib/src/sai_vs_vlan.cpp b/vslib/src/sai_vs_vlan.cpp index 27ed5732d5c1..c4863bdf6b0f 100644 --- a/vslib/src/sai_vs_vlan.cpp +++ b/vslib/src/sai_vs_vlan.cpp @@ -30,47 +30,9 @@ sai_status_t vs_remove_vlan_members( return SAI_STATUS_NOT_IMPLEMENTED; } -sai_status_t vs_get_vlan_stats( - _In_ sai_object_id_t vlan_id, - _In_ uint32_t number_of_counters, - _In_ const sai_vlan_stat_t *counter_ids, - _Out_ uint64_t *counters) -{ - MUTEX(); - - SWSS_LOG_ENTER(); - - return SAI_STATUS_NOT_IMPLEMENTED; -} - -sai_status_t vs_get_vlan_stats_ext( - _In_ sai_object_id_t vlan_id, - _In_ uint32_t number_of_counters, - _In_ const sai_vlan_stat_t *counter_ids, - _In_ sai_stats_mode_t mode, - _Out_ uint64_t *counters) -{ - MUTEX(); - - SWSS_LOG_ENTER(); - - return SAI_STATUS_NOT_IMPLEMENTED; -} - -sai_status_t vs_clear_vlan_stats( - _In_ sai_object_id_t vlan_id, - _In_ uint32_t number_of_counters, - _In_ const sai_vlan_stat_t *counter_ids) -{ - MUTEX(); - - SWSS_LOG_ENTER(); - - return SAI_STATUS_NOT_IMPLEMENTED; -} - VS_GENERIC_QUAD(VLAN,vlan); VS_GENERIC_QUAD(VLAN_MEMBER,vlan_member); +VS_GENERIC_STATS(VLAN,vlan); const sai_vlan_api_t vs_vlan_api = { @@ -79,7 +41,6 @@ const sai_vlan_api_t vs_vlan_api = { vs_create_vlan_members, vs_remove_vlan_members, - vs_get_vlan_stats, - vs_get_vlan_stats_ext, - vs_clear_vlan_stats, + + VS_GENERIC_STATS_API(vlan) };