@@ -484,6 +484,8 @@ def _parse_sai_table_attribute_annotation(self, p4rt_anno_list: Dict[str, Any])
484484 self .skipattr = str (kv ['value' ]['stringValue' ])
485485 elif kv ['key' ] == 'match_type' :
486486 self .match_type = str (kv ['value' ]['stringValue' ])
487+ elif kv ['key' ] == 'validonly' :
488+ self .validonly = str (kv ['value' ]['stringValue' ])
487489 else :
488490 raise ValueError ("Unknown attr annotation " + kv ['key' ])
489491
@@ -516,6 +518,7 @@ def __init__(self):
516518 self .isreadonly : str = "true"
517519 self .counter_type : str = "bytes"
518520 self .attr_type : str = "stats"
521+ self .no_suffix : bool = ""
519522 self .param_actions : List [str ] = []
520523
521524 def parse_p4rt (self , p4rt_counter : Dict [str , Any ], var_ref_graph : P4VarRefGraph ) -> None :
@@ -597,6 +600,8 @@ def __parse_sai_counter_annotation(self, p4rt_counter: Dict[str, Any]) -> None:
597600 self .attr_type = str (kv ['value' ]['stringValue' ])
598601 if self .attr_type not in ["counter_attr" , "counter_id" , "stats" ]:
599602 raise ValueError (f'Unknown counter attribute type: attr_type={ self .attr_type } ' )
603+ elif kv ['key' ] == 'no_suffix' :
604+ self .no_suffix = str (kv ['value' ]['stringValue' ]) == "true"
600605 else :
601606 raise ValueError ("Unknown attr annotation " + kv ['key' ])
602607
@@ -613,10 +618,11 @@ def generate_counter_sai_attributes(self) -> 'Iterator[SAICounter]':
613618 counter = copy .deepcopy (self )
614619
615620 counter .counter_type = counter_type
621+
616622 if counter .attr_type == "counter_attr" :
617- counter .name = f"{ counter .name } _{ counter .counter_type } _counter"
623+ counter .name = f"{ counter .name } _{ counter .counter_type } _counter" if not self . no_suffix else f" { counter . name } _counter"
618624 else :
619- counter .name = f"{ counter .name } _{ counter .counter_type } "
625+ counter .name = f"{ counter .name } _{ counter .counter_type } " if not self . no_suffix else counter . name
620626
621627 yield counter
622628
@@ -695,8 +701,8 @@ def parse_p4rt(self, p4rt_table_action: Dict[str, Any], sai_enums: List[SAIEnum]
695701 },
696702 "params": [
697703 { "id": 1, "name": "dst_vnet_id", "bitwidth": 16 },
698- { "id": 2, "name": "meter_policy_en ", "bitwidth": 1 },
699- { "id": 3, "name": "meter_class ", "bitwidth": 16 }
704+ { "id": 2, "name": "meter_class_or ", "bitwidth": 32 },
705+ { "id": 3, "name": "meter_class_and ", "bitwidth": 32 }
700706 ]
701707 }
702708 '''
0 commit comments