-
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] Create SAI spec for SAI API generation. (#573)
## Problem Currently, the SAI API generation is facing 2 issues: ABI compatibility and code review with SAI API change. To maintain the ABI compatibility, it is required to maintain the order of API, attributes, stats in the order of its creation. The newer ones must comes later. Before the "order" annotation is introduced, this problem was never solved. With "order" annotation, although it kinda helps some cases, but it is still not good - it is hacky, and it is not generically applicable. E.g., currently, the keys and action parameters are not sorted together, counters can be introduced in multiple files making "order" not intuitive. Furthermore, with P4 updates, it is hard to review the SAI API changes, because these changes are not captured in the PR. ## What we are doing in this change The SAI spec YAML file is introduced for helping these cases. First all, all changes to the SAI API will be reflected in the SAI spec YAML file, allow us to review the PR without building the SAI branch. Once the CI passes, we will know how the SAI APIs are being changed, and it works. Secondly, it helps maintaining the ABI compatibility in future. Instead of using "order" to explicitly order the attributes, we can merge the new API spec with the old API spec by insert any new things in the end of the spec. This ensures any new changes will be put in the end, and no hacky solution needs to be introduced again. This change will not change any generated SAI headers and libs. ![image](https://github.com/sonic-net/DASH/assets/1533278/279af16d-e0d7-4ea0-bc68-4595545e1dfc)
- Loading branch information
Showing
38 changed files
with
3,650 additions
and
6 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
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
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,100 @@ | ||
!!python/object:utils.sai_spec.sai_api_group.SaiApiGroup | ||
name: dash_acl | ||
description: '' | ||
sai_apis: | ||
- !!python/object:utils.sai_spec.sai_api.SaiApi | ||
name: dash_acl_group | ||
description: '' | ||
is_object: true | ||
enums: [] | ||
structs: [] | ||
attributes: | ||
- !!python/object:utils.sai_spec.sai_attribute.SaiAttribute | ||
name: SAI_DASH_ACL_GROUP_IP_ADDR_FAMILY | ||
description: Action parameter IP_ADDR_FAMILY | ||
type: sai_ip_addr_family_t | ||
attr_value_field: u32 | ||
default: SAI_IP_ADDR_FAMILY_IPV4 | ||
isresourcetype: true | ||
flags: CREATE_AND_SET | ||
object_name: null | ||
allow_null: false | ||
valid_only: null | ||
deprecated: null | ||
stats: [] | ||
- !!python/object:utils.sai_spec.sai_api.SaiApi | ||
name: dash_acl_rule | ||
description: '' | ||
is_object: true | ||
enums: | ||
- !!python/object:utils.sai_spec.sai_enum.SaiEnum | ||
name: sai_dash_acl_rule_action_t | ||
description: Attribute data for SAI_DASH_ACL_RULE_ATTR_ACTION | ||
members: | ||
- !!python/object:utils.sai_spec.sai_enum_member.SaiEnumMember | ||
name: SAI_DASH_ACL_RULE_ACTION_PERMIT | ||
description: '' | ||
value: '0' | ||
- !!python/object:utils.sai_spec.sai_enum_member.SaiEnumMember | ||
name: SAI_DASH_ACL_RULE_ACTION_PERMIT_AND_CONTINUE | ||
description: '' | ||
value: '0' | ||
- !!python/object:utils.sai_spec.sai_enum_member.SaiEnumMember | ||
name: SAI_DASH_ACL_RULE_ACTION_DENY | ||
description: '' | ||
value: '0' | ||
- !!python/object:utils.sai_spec.sai_enum_member.SaiEnumMember | ||
name: SAI_DASH_ACL_RULE_ACTION_DENY_AND_CONTINUE | ||
description: '' | ||
value: '0' | ||
structs: [] | ||
attributes: | ||
- !!python/object:utils.sai_spec.sai_attribute.SaiAttribute | ||
name: SAI_DASH_ACL_RULE_ATTR_ACTION | ||
description: Action | ||
type: sai_dash_acl_rule_action_t | ||
attr_value_field: null | ||
default: SAI_DASH_ACL_RULE_ACTION_PERMIT | ||
isresourcetype: false | ||
flags: MANDATORY_ON_CREATE | CREATE_ONLY | ||
object_name: null | ||
allow_null: false | ||
valid_only: null | ||
deprecated: null | ||
- !!python/object:utils.sai_spec.sai_attribute.SaiAttribute | ||
name: SAI_DASH_ACL_RULE_ATTR_COUNTER_ID | ||
description: Attach a counter. When it is empty, then packet hits won't be counted. | ||
type: sai_object_id_t | ||
attr_value_field: null | ||
default: SAI_NULL_OBJECT_ID | ||
isresourcetype: false | ||
flags: CREATE_AND_SET | ||
object_name: SAI_OBJECT_TYPE_COUNTER | ||
allow_null: true | ||
valid_only: null | ||
deprecated: null | ||
- !!python/object:utils.sai_spec.sai_attribute.SaiAttribute | ||
name: SAI_DASH_ACL_RULE_ATTR_PRIORITY | ||
description: Rule priority in table | ||
type: sai_uint32_t | ||
attr_value_field: null | ||
default: null | ||
isresourcetype: false | ||
flags: MANDATORY_ON_CREATE | CREATE_ONLY | ||
object_name: null | ||
allow_null: false | ||
valid_only: null | ||
deprecated: null | ||
- !!python/object:utils.sai_spec.sai_attribute.SaiAttribute | ||
name: SAI_DASH_ACL_RULE_ATTR_IP_ADDR_FAMILY | ||
description: IP address family for resource accounting | ||
type: sai_ip_addr_family_t | ||
attr_value_field: null | ||
default: null | ||
isresourcetype: true | ||
flags: READ_ONLY | ||
object_name: null | ||
allow_null: false | ||
valid_only: null | ||
deprecated: null | ||
stats: [] |
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,42 @@ | ||
!!python/object:utils.sai_spec.sai_api_group.SaiApiGroup | ||
name: dash_direction_lookup | ||
description: '' | ||
sai_apis: | ||
- !!python/object:utils.sai_spec.sai_api.SaiApi | ||
name: direction_lookup_entry | ||
description: '' | ||
is_object: false | ||
enums: | ||
- !!python/object:utils.sai_spec.sai_enum.SaiEnum | ||
name: sai_direction_lookup_entry_action_t | ||
description: Attribute data for SAI_DIRECTION_LOOKUP_ENTRY_ATTR_ACTION | ||
members: | ||
- !!python/object:utils.sai_spec.sai_enum_member.SaiEnumMember | ||
name: SAI_DIRECTION_LOOKUP_ENTRY_ACTION_SET_OUTBOUND_DIRECTION | ||
description: '' | ||
value: '0' | ||
structs: | ||
- !!python/object:utils.sai_spec.sai_struct.SaiStruct | ||
name: sai_direction_lookup_entry_entry_t | ||
description: Entry for direction_lookup_entry | ||
members: | ||
- !!python/object:utils.sai_spec.sai_struct_entry.SaiStructEntry | ||
name: VNI | ||
description: Exact matched key VNI | ||
type: sai_uint32_t | ||
objects: null | ||
valid_only: null | ||
attributes: | ||
- !!python/object:utils.sai_spec.sai_attribute.SaiAttribute | ||
name: SAI_DIRECTION_LOOKUP_ENTRY_ATTR_ACTION | ||
description: Action | ||
type: sai_direction_lookup_entry_action_t | ||
attr_value_field: null | ||
default: SAI_DIRECTION_LOOKUP_ENTRY_ACTION_SET_OUTBOUND_DIRECTION | ||
isresourcetype: false | ||
flags: MANDATORY_ON_CREATE | CREATE_ONLY | ||
object_name: null | ||
allow_null: false | ||
valid_only: null | ||
deprecated: null | ||
stats: [] |
Oops, something went wrong.