Skip to content

Commit

Permalink
Convert DASH meter bucket object to table entry
Browse files Browse the repository at this point in the history
Bring in SAI API changes from this DASH PR
sonic-net/DASH#605

Signed-off-by: mukeshmv <[email protected]>
  • Loading branch information
mukeshmv committed Jul 24, 2024
1 parent dff0e34 commit 68a0f1d
Show file tree
Hide file tree
Showing 4 changed files with 157 additions and 77 deletions.
218 changes: 144 additions & 74 deletions experimental/saiexperimentaldashmeter.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,57 +36,84 @@
*/

/**
* @brief Attribute ID for meter bucket
* @brief Attribute data for #SAI_METER_BUCKET_ENTRY_ATTR_ACTION
*/
typedef enum _sai_meter_bucket_attr_t
typedef enum _sai_meter_bucket_entry_action_t
{
SAI_METER_BUCKET_ENTRY_ACTION_UPDATE_METER_BUCKET,

} sai_meter_bucket_entry_action_t;

/**
* @brief Entry for meter_bucket_entry
*/
typedef struct _sai_meter_bucket_entry_t
{
/**
* @brief Start of attributes
* @brief Switch ID
*
* @objects SAI_OBJECT_TYPE_SWITCH
*/
SAI_METER_BUCKET_ATTR_START,
sai_object_id_t switch_id;

/**
* @brief Exact matched key eni_id
*
* @type sai_object_id_t
* @flags MANDATORY_ON_CREATE | CREATE_ONLY
* @objects SAI_OBJECT_TYPE_ENI
*/
SAI_METER_BUCKET_ATTR_ENI_ID = SAI_METER_BUCKET_ATTR_START,
sai_object_id_t eni_id;

/**
* @brief Exact matched key meter_class
*/
sai_uint32_t meter_class;

} sai_meter_bucket_entry_t;

/**
* @brief Attribute ID for meter bucket entry
*/
typedef enum _sai_meter_bucket_entry_attr_t
{
/**
* @brief Start of attributes
*/
SAI_METER_BUCKET_ENTRY_ATTR_START,

/**
* @brief Action
*
* @type sai_uint32_t
* @flags MANDATORY_ON_CREATE | CREATE_ONLY
* @type sai_meter_bucket_entry_action_t
* @flags CREATE_AND_SET
* @default SAI_METER_BUCKET_ENTRY_ACTION_UPDATE_METER_BUCKET
*/
SAI_METER_BUCKET_ATTR_METER_CLASS,
SAI_METER_BUCKET_ENTRY_ATTR_ACTION = SAI_METER_BUCKET_ENTRY_ATTR_START,

/**
* @brief End of attributes
*/
SAI_METER_BUCKET_ATTR_END,
SAI_METER_BUCKET_ENTRY_ATTR_END,

/** Custom range base value */
SAI_METER_BUCKET_ATTR_CUSTOM_RANGE_START = 0x10000000,
SAI_METER_BUCKET_ENTRY_ATTR_CUSTOM_RANGE_START = 0x10000000,

/** End of custom range base */
SAI_METER_BUCKET_ATTR_CUSTOM_RANGE_END,
SAI_METER_BUCKET_ENTRY_ATTR_CUSTOM_RANGE_END,

} sai_meter_bucket_attr_t;
} sai_meter_bucket_entry_attr_t;

/**
* @brief Counter IDs for METER BUCKET
* @brief Counter IDs for meter bucket entry
*/
typedef enum _sai_meter_bucket_stat_t
typedef enum _sai_meter_bucket_entry_stat_t
{
/** DASH METER_BUCKET OUTBOUND_BYTES stat count */
SAI_METER_BUCKET_STAT_OUTBOUND_BYTES,
/** DASH METER_BUCKET_ENTRY OUTBOUND_BYTES stat count */
SAI_METER_BUCKET_ENTRY_STAT_OUTBOUND_BYTES,

/** DASH METER_BUCKET INBOUND_BYTES stat count */
SAI_METER_BUCKET_STAT_INBOUND_BYTES,
/** DASH METER_BUCKET_ENTRY INBOUND_BYTES stat count */
SAI_METER_BUCKET_ENTRY_STAT_INBOUND_BYTES,

} sai_meter_bucket_stat_t;
} sai_meter_bucket_entry_stat_t;

/**
* @brief Attribute ID for meter policy
Expand Down Expand Up @@ -197,105 +224,148 @@ typedef enum _sai_meter_rule_attr_t
} sai_meter_rule_attr_t;

/**
* @brief Create meter bucket
* @brief Create meter bucket entry
*
* @param[out] meter_bucket_id Entry id
* @param[in] switch_id Switch id
* @param[in] meter_bucket_entry Entry
* @param[in] attr_count Number of attributes
* @param[in] attr_list Array of attributes
*
* @return #SAI_STATUS_SUCCESS on success Failure status code on error
*/
typedef sai_status_t (*sai_create_meter_bucket_fn)(
_Out_ sai_object_id_t *meter_bucket_id,
_In_ sai_object_id_t switch_id,
typedef sai_status_t (*sai_create_meter_bucket_entry_fn)(
_In_ const sai_meter_bucket_entry_t *meter_bucket_entry,
_In_ uint32_t attr_count,
_In_ const sai_attribute_t *attr_list);

/**
* @brief Remove meter bucket
* @brief Remove meter bucket entry
*
* @param[in] meter_bucket_id Entry id
* @param[in] meter_bucket_entry Entry
*
* @return #SAI_STATUS_SUCCESS on success Failure status code on error
*/
typedef sai_status_t (*sai_remove_meter_bucket_fn)(
_In_ sai_object_id_t meter_bucket_id);
typedef sai_status_t (*sai_remove_meter_bucket_entry_fn)(
_In_ const sai_meter_bucket_entry_t *meter_bucket_entry);

/**
* @brief Set attribute for meter bucket
* @brief Set attribute for meter bucket entry
*
* @param[in] meter_bucket_id Entry id
* @param[in] meter_bucket_entry Entry
* @param[in] attr Attribute
*
* @return #SAI_STATUS_SUCCESS on success Failure status code on error
*/
typedef sai_status_t (*sai_set_meter_bucket_attribute_fn)(
_In_ sai_object_id_t meter_bucket_id,
typedef sai_status_t (*sai_set_meter_bucket_entry_attribute_fn)(
_In_ const sai_meter_bucket_entry_t *meter_bucket_entry,
_In_ const sai_attribute_t *attr);

/**
* @brief Get attribute for meter bucket
* @brief Get attribute for meter bucket entry
*
* @param[in] meter_bucket_id Entry id
* @param[in] meter_bucket_entry Entry
* @param[in] attr_count Number of attributes
* @param[inout] attr_list Array of attributes
*
* @return #SAI_STATUS_SUCCESS on success Failure status code on error
*/
typedef sai_status_t (*sai_get_meter_bucket_attribute_fn)(
_In_ sai_object_id_t meter_bucket_id,
typedef sai_status_t (*sai_get_meter_bucket_entry_attribute_fn)(
_In_ const sai_meter_bucket_entry_t *meter_bucket_entry,
_In_ uint32_t attr_count,
_Inout_ sai_attribute_t *attr_list);

/**
* @brief Get METER_BUCKET statistics counters. Deprecated for backward compatibility.
* @brief Get METER_BUCKET_ENTRY statistics counters. Deprecated for backward compatibility.
*
* @param[in] meter_bucket_id Entry id
* @param[in] meter_bucket_entry Entry
* @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_meter_bucket_stats_fn)(
_In_ sai_object_id_t meter_bucket_id,
typedef sai_status_t (*sai_get_meter_bucket_entry_stats_fn)(
_In_ const sai_meter_bucket_entry_t *meter_bucket_entry,
_In_ uint32_t number_of_counters,
_In_ const sai_stat_id_t *counter_ids,
_Out_ uint64_t *counters);

/**
* @brief Get METER_BUCKET statistics counters extended.
* @brief Get METER_BUCKET_ENTRY statistics counters extended.
*
* @param[in] meter_bucket_id Entry id
* @param[in] meter_bucket_entry Entry
* @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_meter_bucket_stats_ext_fn)(
_In_ sai_object_id_t meter_bucket_id,
typedef sai_status_t (*sai_get_meter_bucket_entry_stats_ext_fn)(
_In_ const sai_meter_bucket_entry_t *meter_bucket_entry,
_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 METER_BUCKET statistics counters.
* @brief Clear METER_BUCKET_ENTRY statistics counters.
*
* @param[in] meter_bucket_id Entry id
* @param[in] meter_bucket_entry Entry
* @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_meter_bucket_stats_fn)(
_In_ sai_object_id_t meter_bucket_id,
typedef sai_status_t (*sai_clear_meter_bucket_entry_stats_fn)(
_In_ const sai_meter_bucket_entry_t *meter_bucket_entry,
_In_ uint32_t number_of_counters,
_In_ const sai_stat_id_t *counter_ids);

/**
* @brief Bulk create meter bucket entry
*
* @param[in] object_count Number of objects to create
* @param[in] meter_bucket_entry List of object to create
* @param[in] attr_count List of attr_count. Caller passes the number
* of attribute for each object to create.
* @param[in] attr_list List of attributes for every object.
* @param[in] mode Bulk operation error handling mode.
* @param[out] object_statuses List of status for every object. Caller needs to
* allocate the buffer
*
* @return #SAI_STATUS_SUCCESS on success when all objects are created or
* #SAI_STATUS_FAILURE when any of the objects fails to create. When there is
* failure, Caller is expected to go through the list of returned statuses to
* find out which fails and which succeeds.
*/
typedef sai_status_t (*sai_bulk_create_meter_bucket_entry_fn)(
_In_ uint32_t object_count,
_In_ const sai_meter_bucket_entry_t *meter_bucket_entry,
_In_ const uint32_t *attr_count,
_In_ const sai_attribute_t **attr_list,
_In_ sai_bulk_op_error_mode_t mode,
_Out_ sai_status_t *object_statuses);

/**
* @brief Bulk remove meter bucket entry
*
* @param[in] object_count Number of objects to remove
* @param[in] meter_bucket_entry List of objects to remove
* @param[in] mode Bulk operation error handling mode.
* @param[out] object_statuses List of status for every object. Caller needs to
* allocate the buffer
*
* @return #SAI_STATUS_SUCCESS on success when all objects are removed or
* #SAI_STATUS_FAILURE when any of the objects fails to remove. When there is
* failure, Caller is expected to go through the list of returned statuses to
* find out which fails and which succeeds.
*/
typedef sai_status_t (*sai_bulk_remove_meter_bucket_entry_fn)(
_In_ uint32_t object_count,
_In_ const sai_meter_bucket_entry_t *meter_bucket_entry,
_In_ sai_bulk_op_error_mode_t mode,
_Out_ sai_status_t *object_statuses);

/**
* @brief Create meter policy
*
Expand Down Expand Up @@ -402,29 +472,29 @@ typedef sai_status_t (*sai_get_meter_rule_attribute_fn)(

typedef struct _sai_dash_meter_api_t
{
sai_create_meter_bucket_fn create_meter_bucket;
sai_remove_meter_bucket_fn remove_meter_bucket;
sai_set_meter_bucket_attribute_fn set_meter_bucket_attribute;
sai_get_meter_bucket_attribute_fn get_meter_bucket_attribute;
sai_get_meter_bucket_stats_fn get_meter_bucket_stats;
sai_get_meter_bucket_stats_ext_fn get_meter_bucket_stats_ext;
sai_clear_meter_bucket_stats_fn clear_meter_bucket_stats;
sai_bulk_object_create_fn create_meter_buckets;
sai_bulk_object_remove_fn remove_meter_buckets;

sai_create_meter_policy_fn create_meter_policy;
sai_remove_meter_policy_fn remove_meter_policy;
sai_set_meter_policy_attribute_fn set_meter_policy_attribute;
sai_get_meter_policy_attribute_fn get_meter_policy_attribute;
sai_bulk_object_create_fn create_meter_policys;
sai_bulk_object_remove_fn remove_meter_policys;

sai_create_meter_rule_fn create_meter_rule;
sai_remove_meter_rule_fn remove_meter_rule;
sai_set_meter_rule_attribute_fn set_meter_rule_attribute;
sai_get_meter_rule_attribute_fn get_meter_rule_attribute;
sai_bulk_object_create_fn create_meter_rules;
sai_bulk_object_remove_fn remove_meter_rules;
sai_create_meter_bucket_entry_fn create_meter_bucket_entry;
sai_remove_meter_bucket_entry_fn remove_meter_bucket_entry;
sai_set_meter_bucket_entry_attribute_fn set_meter_bucket_entry_attribute;
sai_get_meter_bucket_entry_attribute_fn get_meter_bucket_entry_attribute;
sai_get_meter_bucket_entry_stats_fn get_meter_bucket_entry_stats;
sai_get_meter_bucket_entry_stats_ext_fn get_meter_bucket_entry_stats_ext;
sai_clear_meter_bucket_entry_stats_fn clear_meter_bucket_entry_stats;
sai_bulk_create_meter_bucket_entry_fn create_meter_bucket_entries;
sai_bulk_remove_meter_bucket_entry_fn remove_meter_bucket_entries;

sai_create_meter_policy_fn create_meter_policy;
sai_remove_meter_policy_fn remove_meter_policy;
sai_set_meter_policy_attribute_fn set_meter_policy_attribute;
sai_get_meter_policy_attribute_fn get_meter_policy_attribute;
sai_bulk_object_create_fn create_meter_policys;
sai_bulk_object_remove_fn remove_meter_policys;

sai_create_meter_rule_fn create_meter_rule;
sai_remove_meter_rule_fn remove_meter_rule;
sai_set_meter_rule_attribute_fn set_meter_rule_attribute;
sai_get_meter_rule_attribute_fn get_meter_rule_attribute;
sai_bulk_object_create_fn create_meter_rules;
sai_bulk_object_remove_fn remove_meter_rules;

} sai_dash_meter_api_t;

Expand Down
2 changes: 1 addition & 1 deletion experimental/saitypesextensions.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ typedef enum _sai_object_type_extensions_t

SAI_OBJECT_TYPE_INBOUND_ROUTING_ENTRY,

SAI_OBJECT_TYPE_METER_BUCKET,
SAI_OBJECT_TYPE_METER_BUCKET_ENTRY,

SAI_OBJECT_TYPE_METER_POLICY,

Expand Down
4 changes: 4 additions & 0 deletions inc/saiobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include <saisrv6.h>

/* new experimental object type includes */
#include <saiexperimentaldashmeter.h>
#include <saiexperimentaldashvip.h>
#include <saiexperimentaldashpavalidation.h>
#include <saiexperimentaldashvnet.h>
Expand Down Expand Up @@ -114,6 +115,9 @@ typedef union _sai_object_key_entry_t
/** @validonly object_type == SAI_OBJECT_TYPE_VIP_ENTRY */
sai_vip_entry_t vip_entry;

/** @validonly object_type == SAI_OBJECT_TYPE_METER_BUCKET_ENTRY */
sai_meter_bucket_entry_t meter_bucket_entry;

/* Add new experimental entries above this line */

} sai_object_key_entry_t;
Expand Down
10 changes: 8 additions & 2 deletions meta/style.pm
Original file line number Diff line number Diff line change
Expand Up @@ -215,15 +215,21 @@ sub CheckStatsFunction

if (not $fnparams =~ /^\w+_id number_of_counters counter_ids( (mode )?counters)?$/)
{
LogWarning "invalid stat function $fname params names: $fnparams";
if (not $fnparams =~ /^\w+_entry number_of_counters counter_ids( (mode )?counters)?$/)
{
LogWarning "invalid stat function $fname params names: $fnparams";
}
}

my @paramtypes = $fn =~ /_(?:In|Out|Inout)_\s*(.+?)\s*(?:\w+?)\s*[,\)]/gis;
my $ptypes = "@paramtypes";

if (not $ptypes =~ /^sai_object_id_t uint32_t const sai_stat_id_t \*( (sai_stats_mode_t )?uint64_t \*)?$/)
{
LogWarning "invalid stat function $fname param types: $ptypes";
if (not $ptypes =~ /^const \w+_entry_t \* uint32_t const sai_stat_id_t \*( (sai_stats_mode_t )?uint64_t \*)?$/)
{
LogWarning "invalid stat function $fname param types: $ptypes";
}
}
}

Expand Down

0 comments on commit 68a0f1d

Please sign in to comment.