Skip to content

Commit

Permalink
[Counters] Query Counters Stats Capabilities (#952)
Browse files Browse the repository at this point in the history
  • Loading branch information
shlomibitton authored Oct 26, 2021
1 parent 433c8df commit a718226
Show file tree
Hide file tree
Showing 26 changed files with 631 additions and 14 deletions.
10 changes: 10 additions & 0 deletions lib/ClientSai.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -886,6 +886,16 @@ sai_status_t ClientSai::getStats(
return waitForGetStatsResponse(number_of_counters, counters);
}

sai_status_t ClientSai::queryStatsCapability(
_In_ sai_object_id_t switchId,
_In_ sai_object_type_t objectType,
_Inout_ sai_stat_capability_list_t *stats_capability)
{
SWSS_LOG_ENTER();

return SAI_STATUS_NOT_IMPLEMENTED;
}

sai_status_t ClientSai::waitForGetStatsResponse(
_In_ uint32_t number_of_counters,
_Out_ uint64_t *counters)
Expand Down
5 changes: 5 additions & 0 deletions lib/ClientSai.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@ namespace sairedis
_In_ const sai_stat_id_t *counter_ids,
_Out_ uint64_t *counters) override;

virtual sai_status_t queryStatsCapability(
_In_ sai_object_id_t switch_id,
_In_ sai_object_type_t object_type,
_Inout_ sai_stat_capability_list_t *stats_capability) override;

virtual sai_status_t getStatsExt(
_In_ sai_object_type_t object_type,
_In_ sai_object_id_t object_id,
Expand Down
12 changes: 12 additions & 0 deletions lib/ClientServerSai.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,18 @@ sai_status_t ClientServerSai::getStats(
counters);
}

sai_status_t ClientServerSai::queryStatsCapability(
_In_ sai_object_id_t switchId,
_In_ sai_object_type_t objectType,
_Inout_ sai_stat_capability_list_t *stats_capability)
{
MUTEX();
SWSS_LOG_ENTER();
REDIS_CHECK_API_INITIALIZED();

return SAI_STATUS_NOT_IMPLEMENTED;
}

sai_status_t ClientServerSai::getStatsExt(
_In_ sai_object_type_t object_type,
_In_ sai_object_id_t object_id,
Expand Down
5 changes: 5 additions & 0 deletions lib/ClientServerSai.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ namespace sairedis
_In_ const sai_stat_id_t *counter_ids,
_Out_ uint64_t *counters) override;

virtual sai_status_t queryStatsCapability(
_In_ sai_object_id_t switch_id,
_In_ sai_object_type_t object_type,
_Inout_ sai_stat_capability_list_t *stats_capability) override;

virtual sai_status_t getStatsExt(
_In_ sai_object_type_t object_type,
_In_ sai_object_id_t object_id,
Expand Down
10 changes: 10 additions & 0 deletions lib/RedisRemoteSaiInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1125,6 +1125,16 @@ sai_status_t RedisRemoteSaiInterface::getStats(
return waitForGetStatsResponse(number_of_counters, counters);
}

sai_status_t RedisRemoteSaiInterface::queryStatsCapability(
_In_ sai_object_id_t switchId,
_In_ sai_object_type_t objectType,
_Inout_ sai_stat_capability_list_t *stats_capability)
{
SWSS_LOG_ENTER();

return SAI_STATUS_NOT_IMPLEMENTED;
}

sai_status_t RedisRemoteSaiInterface::waitForGetStatsResponse(
_In_ uint32_t number_of_counters,
_Out_ uint64_t *counters)
Expand Down
5 changes: 5 additions & 0 deletions lib/RedisRemoteSaiInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,11 @@ namespace sairedis
_In_ const sai_stat_id_t *counter_ids,
_Out_ uint64_t *counters) override;

virtual sai_status_t queryStatsCapability(
_In_ sai_object_id_t switch_id,
_In_ sai_object_type_t object_type,
_Inout_ sai_stat_capability_list_t *stats_capability) override;

virtual sai_status_t getStatsExt(
_In_ sai_object_type_t object_type,
_In_ sai_object_id_t object_id,
Expand Down
10 changes: 10 additions & 0 deletions lib/Sai.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,16 @@ sai_status_t Sai::getStats(
counters);
}

sai_status_t Sai::queryStatsCapability(
_In_ sai_object_id_t switchId,
_In_ sai_object_type_t objectType,
_Inout_ sai_stat_capability_list_t *stats_capability)
{
SWSS_LOG_ENTER();

return SAI_STATUS_NOT_IMPLEMENTED;
}

sai_status_t Sai::getStatsExt(
_In_ sai_object_type_t object_type,
_In_ sai_object_id_t object_id,
Expand Down
5 changes: 5 additions & 0 deletions lib/Sai.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,11 @@ namespace sairedis
_In_ const sai_stat_id_t *counter_ids,
_Out_ uint64_t *counters) override;

virtual sai_status_t queryStatsCapability(
_In_ sai_object_id_t switch_id,
_In_ sai_object_type_t object_type,
_Inout_ sai_stat_capability_list_t *stats_capability) override;

virtual sai_status_t getStatsExt(
_In_ sai_object_type_t object_type,
_In_ sai_object_id_t object_id,
Expand Down
10 changes: 10 additions & 0 deletions lib/ServerSai.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,16 @@ sai_status_t ServerSai::getStats(
counters);
}

sai_status_t ServerSai::queryStatsCapability(
_In_ sai_object_id_t switchId,
_In_ sai_object_type_t objectType,
_Inout_ sai_stat_capability_list_t *stats_capability)
{
SWSS_LOG_ENTER();

return SAI_STATUS_NOT_IMPLEMENTED;
}

sai_status_t ServerSai::getStatsExt(
_In_ sai_object_type_t object_type,
_In_ sai_object_id_t object_id,
Expand Down
5 changes: 5 additions & 0 deletions lib/ServerSai.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@ namespace sairedis
_In_ const sai_stat_id_t *counter_ids,
_Out_ uint64_t *counters) override;

virtual sai_status_t queryStatsCapability(
_In_ sai_object_id_t switch_id,
_In_ sai_object_type_t object_type,
_Inout_ sai_stat_capability_list_t *stats_capability) override;

virtual sai_status_t getStatsExt(
_In_ sai_object_type_t object_type,
_In_ sai_object_id_t object_id,
Expand Down
10 changes: 10 additions & 0 deletions meta/DummySaiInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,16 @@ sai_status_t DummySaiInterface::getStats(
return m_status;
}

sai_status_t DummySaiInterface::queryStatsCapability(
_In_ sai_object_id_t switchId,
_In_ sai_object_type_t objectType,
_Inout_ sai_stat_capability_list_t *stats_capability)
{
SWSS_LOG_ENTER();

return SAI_STATUS_NOT_IMPLEMENTED;
}

sai_status_t DummySaiInterface::getStatsExt(
_In_ sai_object_type_t object_type,
_In_ sai_object_id_t object_id,
Expand Down
5 changes: 5 additions & 0 deletions meta/DummySaiInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,11 @@ namespace saimeta
_In_ const sai_stat_id_t *counter_ids,
_Out_ uint64_t *counters) override;

virtual sai_status_t queryStatsCapability(
_In_ sai_object_id_t switch_id,
_In_ sai_object_type_t object_type,
_Inout_ sai_stat_capability_list_t *stats_capability) override;

virtual sai_status_t getStatsExt(
_In_ sai_object_type_t object_type,
_In_ sai_object_id_t object_id,
Expand Down
49 changes: 49 additions & 0 deletions meta/Meta.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1740,6 +1740,37 @@ sai_status_t Meta::meta_validate_stats(
return SAI_STATUS_SUCCESS;
}

sai_status_t Meta::meta_validate_query_stats_capability(
_In_ sai_object_type_t object_type,
_In_ sai_object_id_t object_id)
{
SWSS_LOG_ENTER();

PARAMETER_CHECK_OBJECT_TYPE_VALID(object_type);
PARAMETER_CHECK_OID_OBJECT_TYPE(object_id, object_type);
PARAMETER_CHECK_OID_EXISTS(object_id, object_type);

sai_object_id_t switch_id = switchIdQuery(object_id);

// checks also if object type is OID
sai_status_t status = meta_sai_validate_oid(object_type, &object_id, switch_id, false);

CHECK_STATUS_SUCCESS(status);

auto info = sai_metadata_get_object_type_info(object_type);

PARAMETER_CHECK_IF_NOT_NULL(info);

if (info->statenum == nullptr)
{
SWSS_LOG_ERROR("%s does not support stats", info->objecttypename);

return SAI_STATUS_INVALID_PARAMETER;
}

return SAI_STATUS_SUCCESS;
}

sai_status_t Meta::getStats(
_In_ sai_object_type_t object_type,
_In_ sai_object_id_t object_id,
Expand All @@ -1760,6 +1791,24 @@ sai_status_t Meta::getStats(
return status;
}

sai_status_t Meta::queryStatsCapability(
_In_ sai_object_id_t switchId,
_In_ sai_object_type_t objectType,
_Inout_ sai_stat_capability_list_t *stats_capability)
{
SWSS_LOG_ENTER();

auto status = meta_validate_query_stats_capability(objectType, switchId);

CHECK_STATUS_SUCCESS(status);

status = m_implementation->queryStatsCapability(switchId, objectType, stats_capability);

// no post validation required

return status;
}

sai_status_t Meta::getStatsExt(
_In_ sai_object_type_t object_type,
_In_ sai_object_id_t object_id,
Expand Down
9 changes: 9 additions & 0 deletions meta/Meta.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@ namespace saimeta
_In_ const sai_stat_id_t *counter_ids,
_Out_ uint64_t *counters) override;

virtual sai_status_t queryStatsCapability(
_In_ sai_object_id_t switch_id,
_In_ sai_object_type_t object_type,
_Inout_ sai_stat_capability_list_t *stats_capability) override;

virtual sai_status_t getStatsExt(
_In_ sai_object_type_t object_type,
_In_ sai_object_id_t object_id,
Expand Down Expand Up @@ -394,6 +399,10 @@ namespace saimeta
_Out_ uint64_t *counters,
_In_ sai_stats_mode_t mode);

sai_status_t meta_validate_query_stats_capability(
_In_ sai_object_type_t object_type,
_In_ sai_object_id_t object_id);

private: // validate OID

sai_status_t meta_sai_validate_oid(
Expand Down
5 changes: 5 additions & 0 deletions meta/SaiInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,11 @@ namespace sairedis
_In_ const sai_stat_id_t *counter_ids,
_Out_ uint64_t *counters) = 0;

virtual sai_status_t queryStatsCapability(
_In_ sai_object_id_t switch_id,
_In_ sai_object_type_t object_type,
_Inout_ sai_stat_capability_list_t *stats_capability) = 0;

virtual sai_status_t getStatsExt(
_In_ sai_object_type_t object_type,
_In_ sai_object_id_t object_id,
Expand Down
Loading

0 comments on commit a718226

Please sign in to comment.