diff --git a/dash-pipeline/SAI/sai_api_gen.py b/dash-pipeline/SAI/sai_api_gen.py index bebd8637c..d63bb524d 100755 --- a/dash-pipeline/SAI/sai_api_gen.py +++ b/dash-pipeline/SAI/sai_api_gen.py @@ -236,6 +236,7 @@ def __init__(self): self.skipattr = None self.field = None self.default = None + self.match_type = "" def parse_basic_info_if_exists(self, p4rt_object): ''' @@ -300,6 +301,8 @@ def _parse_sai_object_annotation(self, p4rt_anno_list): self.object_name = kv['value']['stringValue'] elif kv['key'] == 'skipattr': self.skipattr = kv['value']['stringValue'] + elif kv['key'] == 'match_type': + self.match_type = kv['value']['stringValue'] else: raise ValueError("Unknown attr annotation " + kv['key']) @@ -381,7 +384,6 @@ class SAIAPITableKey(SAIObject): ''' def __init__(self): super().__init__() - self.match_type = "" self.bitwidth = 0 self.ip_is_v6_field_id = 0 diff --git a/dash-pipeline/bmv2/README.md b/dash-pipeline/bmv2/README.md index 6e555eb82..b1c1abe65 100644 --- a/dash-pipeline/bmv2/README.md +++ b/dash-pipeline/bmv2/README.md @@ -50,6 +50,7 @@ Available tags are: - `stage`: Specify which stage this table represents for the matching stage type, e.g. `acl.stage1`. - `isobject`: When set to "true", a top level objects in SAI that attached to switch will be generated. Otherwise, a new type of entry will be generated, if nothing else helps us to determine this table is an object table. - `ignored`: When set to "true", we skip this table in SAI API generation. +- `match_type`: Some match kinds used in DASH might not be supported by BMv2, such as `list` and `range_list`. In BMv2, we use `optional` to make the P4 compiler happy. However, we still want to generate the correct SAI API. This tag is used to specify the match type in SAI API generation. For more details, please check the SAI API generation script: [sai_api_gen.py](../SAI/sai_api_gen.py). diff --git a/dash-pipeline/bmv2/dash_acl.p4 b/dash-pipeline/bmv2/dash_acl.p4 index 63f03676f..8b3f6eafb 100644 --- a/dash-pipeline/bmv2/dash_acl.p4 +++ b/dash-pipeline/bmv2/dash_acl.p4 @@ -38,11 +38,11 @@ match_kind { key = { \ meta.stage ## stage_index ##_dash_acl_group_id : exact \ @SaiVal[name = "dash_acl_group_id", type="sai_object_id_t", isresourcetype="true", objects="SAI_OBJECT_TYPE_DASH_ACL_GROUP"]; \ - meta.dst_ip_addr : LIST_MATCH @SaiVal[name = "dip", type = "sai_ip_prefix_list_t"]; \ - meta.src_ip_addr : LIST_MATCH @SaiVal[name = "sip", type = "sai_ip_prefix_list_t"]; \ - meta.ip_protocol : LIST_MATCH @SaiVal[name = "protocol", type = "sai_u8_list_t"]; \ - meta.src_l4_port : RANGE_LIST_MATCH @SaiVal[name = "src_port", type = "sai_u16_range_list_t"]; \ - meta.dst_l4_port : RANGE_LIST_MATCH @SaiVal[name = "dst_port", type = "sai_u16_range_list_t"]; \ + meta.dst_ip_addr : LIST_MATCH @SaiVal[name = "dip", type = "sai_ip_prefix_list_t", match_type = "list"]; \ + meta.src_ip_addr : LIST_MATCH @SaiVal[name = "sip", type = "sai_ip_prefix_list_t", match_type = "list"]; \ + meta.ip_protocol : LIST_MATCH @SaiVal[name = "protocol", type = "sai_u8_list_t", match_type = "list"]; \ + meta.src_l4_port : RANGE_LIST_MATCH @SaiVal[name = "src_port", type = "sai_u16_range_list_t", match_type = "range_list"]; \ + meta.dst_l4_port : RANGE_LIST_MATCH @SaiVal[name = "dst_port", type = "sai_u16_range_list_t", match_type = "range_list"]; \ } \ actions = { \ permit; \