Skip to content

Commit

Permalink
Add VS support for counters (sonic-net#363)
Browse files Browse the repository at this point in the history
  • Loading branch information
kcudnik authored Oct 26, 2018
1 parent 85a579b commit a4ee3ad
Show file tree
Hide file tree
Showing 15 changed files with 370 additions and 549 deletions.
24 changes: 20 additions & 4 deletions vslib/inc/sai_vs.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,12 +176,28 @@ sai_status_t vs_generic_get_route_entry(

// STATS

template <typename T>
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__
81 changes: 64 additions & 17 deletions vslib/inc/sai_vs_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 ## _stat_t>( \
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,
2 changes: 1 addition & 1 deletion vslib/src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
95 changes: 6 additions & 89 deletions vslib/src/sai_vs_bridge.cpp
Original file line number Diff line number Diff line change
@@ -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)
};
81 changes: 4 additions & 77 deletions vslib/src/sai_vs_buffer.cpp
Original file line number Diff line number Diff line change
@@ -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)
};
Loading

0 comments on commit a4ee3ad

Please sign in to comment.