Skip to content

Commit

Permalink
Add support for VLAN Stacking/Translation API
Browse files Browse the repository at this point in the history
- Define SAI layer VLAN translation and VLAN Stacking function API in saivlan.h
  • Loading branch information
kuanyu99 committed Jan 20, 2022
1 parent 4b20033 commit f635bd9
Show file tree
Hide file tree
Showing 3 changed files with 188 additions and 2 deletions.
1 change: 1 addition & 0 deletions inc/saitypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ typedef enum _sai_object_type_t
SAI_OBJECT_TYPE_IPSEC = 99,
SAI_OBJECT_TYPE_IPSEC_PORT = 100,
SAI_OBJECT_TYPE_IPSEC_SA = 101,
SAI_OBJECT_TYPE_VLAN_STACK = 102,
SAI_OBJECT_TYPE_MAX, /* Must remain in last position */
} sai_object_type_t;

Expand Down
186 changes: 185 additions & 1 deletion inc/saivlan.h
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,187 @@ typedef enum _sai_vlan_stat_t

} sai_vlan_stat_t;

/**
* @brief VLAN Stack stage
*/
typedef enum _sai_vlan_stack_stage_t
{
SAI_VLAN_STACK_STAGE_INGRESS,

SAI_VLAN_STACK_STAGE_EGRESS,

} sai_vlan_stack_stage_t;

/**
* @brief VLAN Stack action
*
* If the action is SAI_VLAN_STACK_ACTION_SWAP, the original vlan id of the frame will be replaced
* with new vlan id and the new vlan id will be placed in the original tag position.
* If the action is SAI_VLAN_STACK_ACTION_PUSH, the original vlan id of the frame will be kept if
* exists and the new vlan id will be added as the outer vlan tag.
* If the action is SAI_VLAN_STACK_ACTION_POP, the original vlan id of the frame will be removed
* if exists.
*/
typedef enum _sai_vlan_stack_action_t
{
SAI_VLAN_STACK_ACTION_SWAP,

SAI_VLAN_STACK_ACTION_PUSH,

SAI_VLAN_STACK_ACTION_POP,

} sai_vlan_stack_action_t;

/**
* @brief VLAN Stack match type
*/
typedef enum _sai_vlan_stack_match_type_t
{
SAI_VLAN_STACK_MATCH_TYPE_INNER,

SAI_VLAN_STACK_MATCH_TYPE_OUTER,

} sai_vlan_stack_match_type_t;

/**
* @brief Attributes for VLAN Stack
*/
typedef enum _sai_vlan_stack_attr_t
{
/**
* @brief Start of attributes
*/
SAI_VLAN_STACK_ATTR_START,

/**
* @brief Stage type
*
* @type sai_vlan_stack_stage_t
* @flags MANDATORY_ON_CREATE | CREATE_ONLY
*/
SAI_VLAN_STACK_ATTR_STAGE = SAI_VLAN_STACK_ATTR_START,

/**
* @brief Action type
*
* @type sai_vlan_stack_action_t
* @flags MANDATORY_ON_CREATE | CREATE_ONLY
*/
SAI_VLAN_STACK_ATTR_ACTION,

/**
* @brief Match type
* Conduct the action toward the inner tag or outer tag
*
* @type sai_vlan_stack_match_type_t
* @flags MANDATORY_ON_CREATE | CREATE_ONLY
*/
SAI_VLAN_STACK_ATTR_MATCH_TYPE,

/**
* @brief Original Vlan ID
*
* @type sai_uint16_t
* @flags MANDATORY_ON_CREATE | CREATE_ONLY
* @isvlan true
*/
SAI_VLAN_STACK_ATTR_ORIGINAL_VLAN_ID,

/**
* @brief VLAN Stack port object
*
* @type sai_object_id_t
* @flags MANDATORY_ON_CREATE | CREATE_ONLY
* @objects SAI_OBJECT_TYPE_PORT, SAI_OBJECT_TYPE_LAG
*/
SAI_VLAN_STACK_ATTR_PORT,

/**
* @brief Applied Vlan ID
*
* @type sai_uint16_t
* @flags CREATE_AND_SET
* @isvlan true
* @default 0
* @validonly SAI_VLAN_STACK_ATTR_ACTION == SAI_VLAN_STACK_ACTION_PUSH or SAI_VLAN_STACK_ATTR_ACTION == SAI_VLAN_STACK_ACTION_SWAP
*/
SAI_VLAN_STACK_ATTR_APPLIED_VLAN_ID,

/**
* @brief The packet priority (3 bits) in the vlan tag
* Range from 0 to 7. Default 0xFF will inherit the original vlan tag priority
*
* @type sai_uint8_t
* @flags CREATE_AND_SET
* @default 0xFF
*/
SAI_VLAN_STACK_ATTR_VLAN_APPLIED_PRI,

/**
* @brief End of attributes
*/
SAI_VLAN_STACK_ATTR_END,

/** Custom range base value */
SAI_VLAN_STACK_ATTR_CUSTOM_RANGE_START = 0x10000000,

/** End of custom range base */
SAI_VLAN_STACK_ATTR_CUSTOM_RANGE_END

} sai_vlan_stack_attr_t;

/**
* @brief Create and apply a single VLAN Stack rule
*
* @param[out] vlan_stack_id VLAN Stack ID
* @param[in] switch_id Switch id
* @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_vlan_stack_fn)(
_Out_ sai_object_id_t *vlan_stack_id,
_In_ sai_object_id_t switch_id,
_In_ uint32_t attr_count,
_In_ const sai_attribute_t *attr_list);

/**
* @brief Remove a VLAN Stack rule
*
* @param[in] vlan_stack_id VLAN Stack ID
*
* @return #SAI_STATUS_SUCCESS on success, failure status code on error
*/
typedef sai_status_t (*sai_remove_vlan_stack_fn)(
_In_ sai_object_id_t vlan_stack_id);

/**
* @brief Modify VLAN Stack rule attribute
*
* @param[in] vlan_stack_id VLAN Stack ID
* @param[in] attr Attribute
*
* @return #SAI_STATUS_SUCCESS on success, failure status code on error
*/
typedef sai_status_t (*sai_set_vlan_stack_attribute_fn)(
_In_ sai_object_id_t vlan_stack_id,
_In_ const sai_attribute_t *attr);

/**
* @brief Get VLAN Stack rule attribute
*
* @param[in] vlan_stack_id VLAN Stack ID
* @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_vlan_stack_attribute_fn)(
_In_ sai_object_id_t vlan_stack_id,
_In_ uint32_t attr_count,
_Inout_ sai_attribute_t *attr_list);

/**
* @brief Create a VLAN
*
Expand Down Expand Up @@ -654,7 +835,10 @@ typedef struct _sai_vlan_api_t
sai_get_vlan_stats_fn get_vlan_stats;
sai_get_vlan_stats_ext_fn get_vlan_stats_ext;
sai_clear_vlan_stats_fn clear_vlan_stats;

sai_create_vlan_stack_fn create_vlan_stack;
sai_remove_vlan_stack_fn remove_vlan_stack;
sai_set_vlan_stack_attribute_fn set_vlan_stack_attribute;
sai_get_vlan_stack_attribute_fn get_vlan_stack_attribute;
} sai_vlan_api_t;

/**
Expand Down
3 changes: 2 additions & 1 deletion meta/saisanitycheck.c
Original file line number Diff line number Diff line change
Expand Up @@ -4685,7 +4685,8 @@ void check_object_ro_list(
oi->objecttype == SAI_OBJECT_TYPE_HOSTIF_TABLE_ENTRY ||
oi->objecttype == SAI_OBJECT_TYPE_DTEL ||
oi->objecttype == SAI_OBJECT_TYPE_DTEL_QUEUE_REPORT ||
oi->objecttype == SAI_OBJECT_TYPE_DTEL_EVENT)
oi->objecttype == SAI_OBJECT_TYPE_DTEL_EVENT ||
oi->objecttype == SAI_OBJECT_TYPE_VLAN_STACK)
{
/*
* We skip hostif table entry since there is no 1 object which can
Expand Down

0 comments on commit f635bd9

Please sign in to comment.