p4 spec v1.1 (1185620), страница 15
Текст из файла (страница 15)
Drop inparser is now parser_drop. Added add primitive action. Added errata section.Added action profiles and action selectors. Addedattribute support_timeout to tables.Added push and pop primitive actions.Added preliminary designs for strong typing, expressions, typed action parameters, sequential actionexecution semantics, and extern types.See 17.2.1 for details.Table 16: Revision History17.2.1 Summary of changes introduced in 1.1.0• New typing syntax (Sections 2.3 & 2.4)– Action parameters take types and directionality annotations. This helps thecompiler disambiguate parameter types.8417.2 Revision History17 APPENDICES– New data types. This helps the compiler disambiguates data types.
It alsolays foundation for strong typing.– New width specification syntax for constant (’ –> w).• Support for expression (Sections 2.8, 5.4, and 10.1)– set_metadata() takes expressions. This enables TLV-style header parsingand improves code readability.– modify_field() takes expressions. This enables supports for various arithmetic operations while avoiding the proliferation of additional primitive actions.• Support for extern (Section 16)– Support for extern_type and extern instances. This allows P4 to embracefunctional heterogeneity in a unified and well-defined fashion.• Strong typing (Sections 2.4 – 2.6)– Specification of type conversion rules, along with legitimate operators foreach supported type.
This improves the safety of the language.• Sequential action-execution semantics (Section 10.2.1)– This improves code readability and understandability without hamperingcapabilities for performance optimization (e.g., parallelization).• Miscallenous– execute_meter() replaces meter(), avoiding ambiguity in parsing (Section10.1).– A new counter type bytes_and_packets (Section 8.1).8517.3 Terminology (Incomplete)17 APPENDICES17.3 Terminology (Incomplete)TermControl FlowEgress QueuingEgress SpecificationOrder DependencyParsed RepresentationParserPipelineRun timeTargetDefinitionThe logic that selects which tables are applied to a packetwhen it is processed by a pipeline. Used to resolve order dependencies.An abstract P4 functional block logically separating ingressand egress processing.
Implementations may expose queuing and buffer resource management interfaces for thisblock, but this not specified by P4.Metadata set by the ingress pipeline which determines the setof destination ports (and number of instances on each port)to which the packet should be sentA sequence of match and action operations whose result depends on the order of execution. For example, one table mayset a field which another table uses for a match. The controlflow is used to determine which of the possible effects is intended.A representation of a packet’s header as a set of header instances, each of which is composed of fields.A functional block which maps a packet to a Parsed RepresentationA sequence of match+action tables.When a switch is processing packets.
This is distinguishedfrom configuration time, though these operations may occurat the same time in some implementations.A packet-processing machine that can be programmed in P4.Table 17: Terminology17.4 Summary of P4 BNFp4_program ::= p4_declaration +p4_declaration ::=header_type_declaration |header_instance_declaration |field_list_declaration |field_list_calculation_declaration |calculated_field_declaration |value_set_declaration |8617.4 Summary of P4 BNF17 APPENDICESparser_function_declaration |parser_exception_declaration |counter_declaration |meter_declaration |register_declaration |primitive_action_declaration |action_function_declaration |action_profile_declaration |action_selector_declaration |table_declaration |extern_type_declaration |extern_instance_declaration |control_function_declaration |const_value ::=bool_value |[ "+" | - ] [ width_spec ] unsigned_valueunsigned_value ::=binary_value |decimal_value |hexadecimal_valuebool_value ::= true | falsebinary_value ::=binary_base binary_digit+decimal_value ::= decimal_digit+hexadecimal_value ::= hexadecimal_base hexadecimal_digit+binary_base ::= 0b | 0Bhexadecimal_base ::= 0x | 0Xbinary_digit ::= _ | 0 | 1decimal_digit ::= binary_digit | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9hexadecimal_digit ::=decimal_digit | a | A | b | B | c | C | d | D | e | E | f | Fwidth_spec ::=decimal_digit+ w |decimal_digit+ sfield_value ::= const_valuetype_spec ::=8717.4 Summary of P4 BNF17 APPENDICESheader [ header_type_name ] |metadata [ header_type_name ] |field_list |field_list_calculation |parser |parser_exception |parser_value_set |counter |meter |register |action |action_profile |table |control |extern [ extern_type_name ] |data_typedata_type ::=bit |bit < decimal_digit+ > |varbit < decimal_digit+ > |int < decimal_digit+ >object_ref ::=instance_name |header_ref |field_refgeneral_expr ::=bool_expr | arith_expr | const_expr | object_refbool_expr ::=valid ( object_ref ) | bool_expr bool_op bool_expr |not bool_expr | ( bool_expr ) | arith_expr rel_op arith_expr |bool_valuearith_expr ::=object_ref | const_value |max ( arith_expr , arith_expr ) | min ( arith_expr , arith_expr ) |( arith_expr ) | arith_expr bin_op arith_expr | un_op arith_expr |( data_type ) arith_exprconst_expr ::= const_value |8817.4 Summary of P4 BNF17 APPENDICESmax ( const_expr , const_expr ) | min ( const_expr, const_expr ) |( const_expr ) | const_expr bin_op const_expr | un_op const_exprbin_op ::= "+" | "*" | - | << | >> | & | "|" | ^un_op ::= ~ | bool_op ::= or | andrel_op ::= > | >= | == | <= | < | !=p4_pragma ::= @pragma pragma_name pragma_textheader_type_declaration ::=header_type header_type_name { header_dec_body }header_dec_body ::=fields { field_dec * }[ length : length_exp ; ]field_dec ::= data_type field_name ;length_bin_op ::= "+" | - | "*" | << | >>length_exp ::=const_expr |field_name |length_exp length_bin_op length_exp |( length_exp )header_instance_declaration ::= header_instance | metadata_instanceheader_instance ::= scalar_instance | array_instancescalar_instance ::= header header_type_name instance_name ;array_instance ::=header header_type_nameinstance_name "[" const_expr "]" ;metadata_instance ::=metadata header_type_nameinstance_name [ metadata_initializer ] | ;metadata_initializer ::= { [ field_name : field_value ; ] + }header_ref ::=header_instance_name | header_instance_name "[" header_ref_index "]"header_ref_index ::= const_expr | last | next8917.4 Summary of P4 BNF17 APPENDICESfield_ref ::= header_ref .
field_namefield_list_declaration ::=field_list field_list_name {[ field_list_entry ; ] *}field_list_entry ::=object_ref | field_valuefield_list_calculation_declaration ::=field_list_calculation field_list_calculation_name {input {[ field_list_name ; ] +}algorithm : stream_function_algorithm_name ;output_width : const_expr ;}calculated_field_declaration ::=calculated_field field_ref { update_verify_spec + }update_verify_spec ::=update_or_verify field_list_calculation_name [ if_cond ] ;update_or_verify ::= update | verifyif_cond ::= if ( calc_bool_cond )calc_bool_cond ::=valid ( header_ref | field_ref ) |field_ref == field_valuevalue_set_declaration ::= parser_value_set value_set_name;parser_function_declaration ::=parser parser_state_name { parser_function_body }parser_function_body ::=parser_body_call*return_statementparser_body_call ::=extract_statement |set_statement |extern_method_call ;extract_statement ::= extract ( header_extract_ref );9017.4 Summary of P4 BNF17 APPENDICESheader_extract_ref ::=header_instance_name |header_instance_name "[" header_extract_index "]"header_extract_index ::= const_expr | nextset_statement ::= set_metadata ( field_ref, general_expr ) ;return_statement ::=return_value_type |return select ( select_exp ) { case_entry + }return_value_type ::=return parser_state_name ; |return control_function_name ; |parse_error parser_exception_name ;case_entry ::= value_list : case_return_value_type ;value_list ::= value_or_masked [ , value_or_masked ]* | defaultcase_return_value_type ::=parser_state_name |control_function_name |parse_error parser_exception_namevalue_or_masked ::=field_value | field_value mask field_value | value_set_name |( value_or_masked [, value_or_masked] * )select_exp ::= field_or_data_ref [, field_or_data_ref] *field_or_data_ref ::=field_ref |latest.field_name |current( const_expr , const_expr )parser_exception_declaration ::=parser_exception parser_exception_name {set_statement *return_or_drop ;}return_or_drop ::= return_to_control | parser_dropreturn_to_control ::= return control_function_name9117.4 Summary of P4 BNF17 APPENDICEScounter_declaration ::=counter counter_name {type : counter_type ;[ direct_or_static ; ][ instance_count : const_expr ; ][ min_width : const_expr ; ][ saturating ; ]}counter_type ::= bytes | packets | bytes_and_packetsdirect_or_static ::= direct_attribute | static_attributedirect_attribute ::= direct : table_namestatic_attribute ::= static : table_namemeter_declaration ::=meter meter_name {type : meter_type ;[ result : field_ref ; ][ direct_or_static ; ][ instance_count : const_expr ; ]}meter_type ::= bytes | packetsregister_declaration ::=register register_name {width_or_layout ;[ direct_or_static ; ][ instance_count : const_expr ; ][ attribute_list ; ]}width_or_layout ::= width_declaration | layout_declarationwidth_declaration ::= width : const_exprlayout_declaration ::= layout : header_type_nameattribute_list ::= attributes : attr_entryattr_entry ::= signed | attr_entry , attr_entryregister_ref ::=register_name "[" const_expr "]" [.field_name]compound_action_function_declaration ::=action action_name ( [ action_param_list ] ) { action_statement * } |action action_name ( [ action_param_list ] ) ;9217.4 Summary of P4 BNF17 APPENDICESaction_param_list ::= action_param [, action_param]*action_param ::= param_qualifier* data_type param_nameparam_qualifier ::= in | inoutaction_statement ::=action_name ( [ arg_list ] ) ; |extern_method_call ;arg_list ::= general_expr [, general_expr]*action_profile_declaration ::=action_profile action_profile_name {action_specification[ size : const_expr ; ][ dynamic_action_selection : selector_name ; ]}action_specification ::=actions { [ action_name ; ] + }action_selector_declaration ::=action_selector selector_name {selection_key : field_list_calculation_name ;}table_declaration ::=table table_name {[ reads { field_match + } ]table_actions[ min_size : const_expr ; ][ max_size : const_expr ; ][ size : const_expr ; ][ support_timeout : bool_value ; ]}field_match ::= field_or_masked_ref : field_match_type ;field_or_masked_ref ::=header_ref | field_ref | field_ref mask const_exprfield_match_type ::= exact | ternary | lpm | index | range | validtable_actions ::=action_specification | action_profile_specification9317.4 Summary of P4 BNF17 APPENDICESaction_profile_specification ::=action_profile : action_profile_name ;control_function_declaration ::=control control_fn_name control_blockcontrol_block ::= { control_statement * }control_statement ::=apply_call |apply_and_select_block |extern_method_call ; |if_else_statement |control_fn_name ( ) ; |return ;apply_call ::= apply ( table_name ) ;apply_and_select_block ::= apply ( table_name ) { [ case_list ] }case_list ::= action_case + | hit_miss_case +action_case ::= action_or_default control_blockaction_or_default ::= action_name | defaulthit_miss_case ::= hit_or_miss control_blockhit_or_miss ::= hit | missif_else_statement ::=if ( bool_expr ) control_block[ else_block ]else_block ::= else control_block | else if_else_statementextern_type_declaration ::=extern_type type_name {member_declaration*}member_declaration ::= attribute_declaration | method_declarationmethod_declaration ::=method method_name ( [ method_param_list ] );method_param_list ::= method_param [, method_param ]*method_param ::= param_qualifier* type_spec param_nameattribute_declaration ::=attribute attribute_name {9417.5 P4 Reserved Words17 APPENDICEStype : attribute_type ;[ optional ; ]}identifier_list ::= variable_name ;attribute_type ::=type_specextern_instance_declaration ::=extern type_name instance_name ; |extern type_name instance_name {extern_attribute_binding +}extern_attribute_binding ::=attribute_name : object_ref | general_expr;extern_method_call ::=object_ref .