-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[sai-gen] Add support for generating SAI stats APIs for counters. (#514)
## Problem DASH has scaling requirement that requires technology providers to support huge number of objects, e.g. 8M of CA-PA mappings. If we need to add counters for these objects by using generic SAI counters, we will generate large number of counter ids, which might not be ideal. Also some counters we are collecting are not data path counters, but more like hit counts, which is not what generic SAI counter is modeling. For these cases, we can support generating the counters as SAI stats and leverage existing SAI stats API design for querying the counters back. ## What we are doing in this change This change updated sai_api_gen.py with 2 changes: 1. Rename `as_attr` to `attr_type` for supporting more types of counter generation. 2. Updated the counter generation logic and its templates for generating SAI stats APIs. This feature will be used in the incoming fast path API generations.
- Loading branch information
Showing
12 changed files
with
233 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
dash-pipeline/SAI/templates/headers/sai_api_comment_object_id.j2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{% if table.is_object == 'true' %} | ||
* @param[in] {{ table.name }}_id Entry id | ||
{% else %} | ||
* @param[in] {{ table.name }} Entry | ||
{% endif %} |
5 changes: 5 additions & 0 deletions
5
dash-pipeline/SAI/templates/headers/sai_api_param_object_id.j2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{% if table.is_object == 'true' %} | ||
_In_ sai_object_id_t {{ table.name }}_id, | ||
{% else %} | ||
_In_ const sai_{{ table.name }}_t *{{ table.name }}, | ||
{% endif %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
{% if table.sai_stats | length > 0 %} | ||
/** | ||
* @brief Get {{ table.name }} statistics counters. Deprecated for backward compatibility. | ||
* | ||
{% include 'templates/headers/sai_api_comment_object_id.j2' %} | ||
* @param[in] number_of_counters Number of counters in the array | ||
* @param[in] counter_ids Specifies the array of counter ids | ||
* @param[out] counters Array of resulting counter values. | ||
* | ||
* @return #SAI_STATUS_SUCCESS on success, failure status code on error | ||
*/ | ||
typedef sai_status_t (*sai_get_{{ table.name }}_stats_fn)( | ||
{% include 'templates/headers/sai_api_param_object_id.j2' %} | ||
_In_ uint32_t number_of_counters, | ||
_In_ const sai_stat_id_t *counter_ids, | ||
_Out_ uint64_t *counters); | ||
|
||
/** | ||
* @brief Get {{ table.name }} statistics counters extended. | ||
* | ||
{% include 'templates/headers/sai_api_comment_object_id.j2' %} | ||
* @param[in] number_of_counters Number of counters in the array | ||
* @param[in] counter_ids Specifies the array of counter ids | ||
* @param[in] mode Statistics mode | ||
* @param[out] counters Array of resulting counter values. | ||
* | ||
* @return #SAI_STATUS_SUCCESS on success, failure status code on error | ||
*/ | ||
typedef sai_status_t (*sai_get_{{ table.name }}_stats_ext_fn)( | ||
{% include 'templates/headers/sai_api_param_object_id.j2' %} | ||
_In_ uint32_t number_of_counters, | ||
_In_ const sai_stat_id_t *counter_ids, | ||
_In_ sai_stats_mode_t mode, | ||
_Out_ uint64_t *counters); | ||
|
||
/** | ||
* @brief Clear {{ table.name }} statistics counters. | ||
* | ||
{% include 'templates/headers/sai_api_comment_object_id.j2' %} | ||
* @param[in] number_of_counters Number of counters in the array | ||
* @param[in] counter_ids Specifies the array of counter ids | ||
* | ||
* @return #SAI_STATUS_SUCCESS on success, failure status code on error | ||
*/ | ||
typedef sai_status_t (*sai_clear_{{ table.name }}_stats_fn)( | ||
{% include 'templates/headers/sai_api_param_object_id.j2' %} | ||
_In_ uint32_t number_of_counters, | ||
_In_ const sai_stat_id_t *counter_ids); | ||
|
||
{% endif %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{% if table.sai_stats | length > 0 %} | ||
sai_get_{{ table.name }}_stats_fn {{ " " * space_offset }}get_{{ table.name }}_stats; | ||
sai_get_{{ table.name }}_stats_ext_fn {{ " " * space_offset }}get_{{ table.name }}_stats_ext; | ||
sai_clear_{{ table.name }}_stats_fn {{ " " * space_offset }}clear_{{ table.name }}_stats; | ||
{% endif %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{% if table.sai_stats | length > 0 %} | ||
/** | ||
* @brief Counter IDs for {{ table.name }} in sai_get_{{ table.name }}_stats() call | ||
*/ | ||
typedef enum _sai_{{ table.name }}_stat_t | ||
{ | ||
{% for stat in table.sai_stats %} | ||
/** DASH {{ table.name | lower }} {{ stat.name | upper }} stat count */ | ||
SAI_{{ table.name | upper }}_STAT_{{ stat.name | upper }}, | ||
|
||
{% endfor %} | ||
} sai_{{ table.name }}_stat_t; | ||
|
||
{% endif %} |
11 changes: 11 additions & 0 deletions
11
dash-pipeline/SAI/templates/headers/sai_stats_extensions.j2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{% set sai_stats_extensions_ns = namespace(is_first_attr = is_first_attr) %} | ||
{% for stat in sai_stats %} | ||
/** DASH {{ table_name | lower }} {{ stat.name | upper }} stat count */ | ||
{% if sai_stats_extensions_ns.is_first_attr == true %} | ||
SAI_{{ table_name | upper }}_STAT_{{ stat.name | upper }} = SAI_{{ table_name | upper }}_STAT_EXTENSIONS_RANGE_START, | ||
{% else %} | ||
SAI_{{ table_name | upper }}_STAT_{{ stat.name | upper }}, | ||
{% endif %} | ||
{% set sai_stats_extensions_ns.is_first_attr = false %} | ||
|
||
{% endfor %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.