Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[sai-gen] Update SAI API header file generation to use SAI spec #578

Merged
merged 16 commits into from
Jun 21, 2024
4 changes: 3 additions & 1 deletion dash-pipeline/SAI/sai_api_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from utils.dash_p4 import DashP4SAIExtensions
from utils.p4ir import P4IRTree, P4VarRefGraph
from utils.sai_spec import SaiSpec
from utils.sai_gen import SAIGenerator
from utils.sai_gen import SAIGenerator, SaiHeaderGenerator
except ImportError as ie:
print("Import failed for " + ie.name)
exit(1)
Expand Down Expand Up @@ -68,8 +68,10 @@
print("Outputting new SAI spec to " + sai_spec_dir)
yaml_inc_ctor.autoload = False
new_sai_spec = dash_sai_exts.to_sai()
new_sai_spec.finalize()
sai_spec.merge(new_sai_spec)
sai_spec.serialize(sai_spec_dir)

# Generate and update all SAI files
SAIGenerator(dash_sai_exts).generate()
SaiHeaderGenerator(sai_spec).generate()
106 changes: 95 additions & 11 deletions dash-pipeline/SAI/specs/dash_acl.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
!!python/object:utils.sai_spec.sai_api_group.SaiApiGroup
name: dash_acl
description: ''
description: DASH ACL
api_type: overlay
sai_apis:
- !!python/object:utils.sai_spec.sai_api.SaiApi
name: dash_acl_group
description: ''
description: DASH ACL group
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
name: SAI_DASH_ACL_GROUP_ATTR_IP_ADDR_FAMILY
description: Action parameter IP address family
type: sai_ip_addr_family_t
attr_value_field: u32
default: SAI_IP_ADDR_FAMILY_IPV4
Expand All @@ -20,7 +21,8 @@ sai_apis:
object_name: null
allow_null: false
valid_only: null
deprecated: null
is_vlan: false
deprecated: false
stats: []
p4_meta: !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4Meta
tables:
Expand All @@ -33,12 +35,12 @@ sai_apis:
attr_param_id: {}
- !!python/object:utils.sai_spec.sai_api.SaiApi
name: dash_acl_rule
description: ''
description: DASH ACL rule
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
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
Expand All @@ -65,11 +67,90 @@ sai_apis:
attr_value_field: null
default: SAI_DASH_ACL_RULE_ACTION_PERMIT
isresourcetype: false
flags: CREATE_AND_SET
object_name: null
allow_null: false
valid_only: null
deprecated: false
is_vlan: false
- !!python/object:utils.sai_spec.sai_attribute.SaiAttribute
name: SAI_DASH_ACL_RULE_ATTR_DASH_ACL_GROUP_ID
description: Exact matched key dash_acl_group_id
type: sai_object_id_t
attr_value_field: u16
default: null
isresourcetype: true
flags: MANDATORY_ON_CREATE | CREATE_ONLY
object_name: SAI_OBJECT_TYPE_DASH_ACL_GROUP
allow_null: false
valid_only: null
is_vlan: false
deprecated: false
- !!python/object:utils.sai_spec.sai_attribute.SaiAttribute
name: SAI_DASH_ACL_RULE_ATTR_DIP
description: List matched key dip
type: sai_ip_prefix_list_t
attr_value_field: ipprefixlist
default: null
isresourcetype: false
flags: MANDATORY_ON_CREATE | CREATE_ONLY
object_name: null
allow_null: false
valid_only: null
is_vlan: false
deprecated: false
- !!python/object:utils.sai_spec.sai_attribute.SaiAttribute
name: SAI_DASH_ACL_RULE_ATTR_SIP
description: List matched key sip
type: sai_ip_prefix_list_t
attr_value_field: ipprefixlist
default: null
isresourcetype: false
flags: MANDATORY_ON_CREATE | CREATE_ONLY
object_name: null
allow_null: false
valid_only: null
is_vlan: false
deprecated: false
- !!python/object:utils.sai_spec.sai_attribute.SaiAttribute
name: SAI_DASH_ACL_RULE_ATTR_PROTOCOL
description: List matched key protocol
type: sai_u8_list_t
attr_value_field: u8list
default: null
isresourcetype: false
flags: MANDATORY_ON_CREATE | CREATE_ONLY
object_name: null
allow_null: false
valid_only: null
is_vlan: false
deprecated: false
- !!python/object:utils.sai_spec.sai_attribute.SaiAttribute
name: SAI_DASH_ACL_RULE_ATTR_SRC_PORT
description: Range_list matched key src_port
type: sai_u16_range_list_t
attr_value_field: u16rangelist
default: null
isresourcetype: false
flags: MANDATORY_ON_CREATE | CREATE_ONLY
object_name: null
allow_null: false
valid_only: null
is_vlan: false
deprecated: false
- !!python/object:utils.sai_spec.sai_attribute.SaiAttribute
name: SAI_DASH_ACL_RULE_ATTR_DST_PORT
description: Range_list matched key dst_port
type: sai_u16_range_list_t
attr_value_field: u16rangelist
default: null
isresourcetype: false
flags: MANDATORY_ON_CREATE | CREATE_ONLY
object_name: null
allow_null: false
valid_only: null
deprecated: null
is_vlan: false
deprecated: false
- !!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.
Expand All @@ -81,7 +162,8 @@ sai_apis:
object_name: SAI_OBJECT_TYPE_COUNTER
allow_null: true
valid_only: null
deprecated: null
deprecated: false
is_vlan: false
- !!python/object:utils.sai_spec.sai_attribute.SaiAttribute
name: SAI_DASH_ACL_RULE_ATTR_PRIORITY
description: Rule priority in table
Expand All @@ -93,7 +175,8 @@ sai_apis:
object_name: null
allow_null: false
valid_only: null
deprecated: null
deprecated: false
is_vlan: false
- !!python/object:utils.sai_spec.sai_attribute.SaiAttribute
name: SAI_DASH_ACL_RULE_ATTR_IP_ADDR_FAMILY
description: IP address family for resource accounting
Expand All @@ -105,7 +188,8 @@ sai_apis:
object_name: null
allow_null: false
valid_only: null
deprecated: null
deprecated: false
is_vlan: false
stats: []
p4_meta: !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4Meta
tables:
Expand Down
22 changes: 15 additions & 7 deletions dash-pipeline/SAI/specs/dash_direction_lookup.yaml
Original file line number Diff line number Diff line change
@@ -1,27 +1,34 @@
!!python/object:utils.sai_spec.sai_api_group.SaiApiGroup
name: dash_direction_lookup
description: ''
description: DASH direction lookup
api_type: overlay
sai_apis:
- !!python/object:utils.sai_spec.sai_api.SaiApi
name: direction_lookup_entry
description: ''
description: direction lookup entry
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
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
name: sai_direction_lookup_entry_t
description: Entry for direction_lookup_entry
members:
- !!python/object:utils.sai_spec.sai_struct_entry.SaiStructEntry
name: VNI
name: switch_id
description: Switch ID
type: sai_object_id_t
objects: SAI_OBJECT_TYPE_SWITCH
valid_only: null
- !!python/object:utils.sai_spec.sai_struct_entry.SaiStructEntry
name: vni
description: Exact matched key VNI
type: sai_uint32_t
objects: null
Expand All @@ -34,11 +41,12 @@ sai_apis:
attr_value_field: null
default: SAI_DIRECTION_LOOKUP_ENTRY_ACTION_SET_OUTBOUND_DIRECTION
isresourcetype: false
flags: MANDATORY_ON_CREATE | CREATE_ONLY
flags: CREATE_AND_SET
object_name: null
allow_null: false
valid_only: null
deprecated: null
deprecated: false
is_vlan: false
stats: []
p4_meta: !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4Meta
tables:
Expand Down
Loading
Loading