p4 spec v1.1 (1185620), страница 11
Текст из файла (страница 11)
An element at index N will be moved to index N-1, and the element at index 0 will be lost. The bottom-most elements that had nothing shifted into them are invalidated.If a count is specified, elements will be shifted by count instead of 1.Popping from an empty array (or popping more elements than are in thearray) results in an empty array.count(counter_ref, index)SummaryUpdate a counter.Parameterscounter_refindex(C-REF) The name of the counter array.(VAL) The offset in the array to get a counter reference.DescriptionThe given counter is incremented by 1, if it is a packet counter, or by thepacket length, if it is a byte counter.
The counter array is determined atcompile time. The index may be a table entry parameter or determinedat compile time. It is an error to reference a direct-mapped counter array from this action.5910.1 Primitive Actions10 ACTIONSexecute_meter(meter_ref, index, field)SummaryExecute a meter operation.Parametersmeter_ref(M-REF) The name of the meter array.index(VAL) The offset in the array to get a meter reference.Applicable only if the meter type is indirect.field(FLD) A field reference to store the meter state.DescriptionThe given meter, determined by meter_ref and index, is executed. Ifthe meter is direct, then index is ignored as the table entry determineswhich cell to reference.
The length of the packet is passed to the meter. The state of meter is updated and the meter returns information(a "color") which is stored in field. If the parent header of field is notvalid, the meter state is updated, but the color of the packet is discarded.generate_digest(receiver, field_list)SummaryGenerate a digest of a packet and send to a receiver.Parametersreceiver(VAL) An opaque value identifying the receiver.field_list(FLDLIST) A list of field references.DescriptionThe indicated field list is populated with the packet’s data and sent bya target-specific mechanism to an agent capable of processing the object.
The specification of receivers is outside of the scope of P4. Examplereceivers might be the CPU through a channel parallel to that for transferring packets, or a co-processor connected by a bus dedicated to thisoperation.This function might also be used to represent a self-updating operationsuch as address learning.6010.1 Primitive Actions10 ACTIONSresubmit( [ field_list ] )SummaryApplied in the ingress pipeline, mark the packet to be resubmitted to theparser.Parametersfield_list(FLDLIST) An optional list of metadata field references.DescriptionOnly valid on the ingress pipeline.The packet is marked for resubmission. It will complete the ingresspipeline to generate any necessary metadata values. Then, the originalpacket data will be resubmitted to the parser with values of the fieldsin field_list from the ingress processing on the packet.
These valuesreplace the normal initial values of the metadata fields indicated in theinitializer of the instance declaration.If multiple resubmit actions get executed on one packet, the union of allthe fields in the field lists should be resubmitted with the packet.See Section 15 for more details.recirculate( [ field_list ] )SummaryOn egress, mark the packet to be resubmitted to the parser.Parametersfield_list(FLDLIST) An optional list of metadata field references.DescriptionOnly valid on the egress pipeline.The packet is marked for resubmission. It will complete the egresspipeline and be deparsed.
This version of the packet is then resubmittedto the parser with values of the fields in field_list from the processing on the packet. These values replace the normal initial values of themetadata fields indicated in the initializer of the instance declaration.See Section 15 for more details.6110.1 Primitive Actions10 ACTIONSclone_ingress_pkt_to_ingress(clone_spec, [ field_list ] )SummaryGenerate a copy of the original packet and submit it to the ingressparser.Parametersclone_spec(VAL) An opaque identifier indicating additional runtime characteristics of the clone operation.field_list(FLDLIST) An optional list of metadata field references.DescriptionThis action indicates that the switch should generate a copy of the original packet (prior to any modifications from match+action) and submitit to the parser as an independent packet instance. This may occur immediately when the action executes or be deferred until the the originalpacket is buffered.The original packet continues to be processed as though the clone hadnot been produced.The clone_spec is used to allow the configuration of other target specific characteristics of the clone operation.
It may be a simple identifier indicating a session. For instance, the clone operation may supporttruncating the cloned instance. The truncation length would be a property of the session. The concept of session is optional and the parametermay be ignored on some targets.The cloned instance will have instance_type set to indicate that it is aningress clone.The fields indicated in field_list are copied to the Parsed Representation of the clone instance.
These values replace the normal initial valuesof the metadata fields indicated in the initializer of the instance declaration (which occurs before parsing).The function may also be referred to as clone_i2i.See the Section 15 for more details.6210.1 Primitive Actions10 ACTIONSclone_egress_pkt_to_ingress(clone_spec [ , field_list])SummaryGenerate a duplicate of the egress packet and submit it to the parser.Parametersclone_spec(VAL) An opaque identifier indicating additional runtime characteristics of the clone operation.field_list(FLDLIST) An optional list of metadata field references.DescriptionThe packet is marked for cloning at egress.
Once the original packetcompletes the egress pipeline, a copy of the deparsed packet (includingall modifications due to match+action) is passed to the parser as an independent packet instance. The original packet is forwarded as normal.The clone_spec is used to allow the configuration of other target specificcharacteristics of the clone operation as described in clone_ingress_pkt_to_ingress.The fields indicated in field_list are copied to the clone instance.These values replace the normal initial values of the metadata fields indicated in the initializer of the instance declaration.The cloned instance will have instance_type set to indicate that it is aningress clone.The function may also be referred to as clone_e2i.See the Section 15 for more details.6310.1 Primitive Actions10 ACTIONSclone_ingress_pkt_to_egress(clone_spec [ , field_list ] )SummaryGenerate a copy of the original packet and submit it to the BufferingMechanism.Parametersclone_spec(VAL) An opaque identifier indicating additional runtime characteristics of the clone operation.field_list(FLDLIST) An optional list of metadata field references.DescriptionThis action indicates that the switch should generate a copy of the original packet.
The clone’s Parsed Representation will match the original’simmediately after parsing, with the exception that the fields listed infield_list are replaced with the original packet’s values after beingprocessed by the ingress pipeline.The clone of the packet is submitted directly to the Buffering Mechanism as an independent packet instance. It does not go through ingressmatch+action processing.The original packet continues to be processed as though the clone hadnot been produced.The clone_spec is used to allow the configuration of other target specificcharacteristics of the clone operation as described in clone_ingress_pkt_to_ingress. In addition to other session attributes, clone_spec determines the egress specification (standard metadata egress_spec) thatis presented to the Buffering Mechanism.The cloned instance will have instance_type set to indicate that it is anegress clone.The function may also be referred to as clone_i2e.See the Section 15 for more details.6410.1 Primitive Actions10 ACTIONSclone_egress_pkt_to_egress(clone_spec [ , field_list ] )SummaryDuplicate the egress version of the packet and submit it to the BufferingMechanism.Parametersclone_spec(VAL) An opaque identifier indicating additional runtime characteristics of the clone operation.field_list(FLDLIST) An optional list of metadata field references.DescriptionThe packet is marked for cloning at egress.
Once the original packetcompletes the egress pipeline, the packet and its Parsed Representation of packet headers (including all modifications due to match+action)along with the metadata fields specified in field_listare submitted tothe Buffering Mechanism as a new packet instance.The original packet is forwarded as normal.The clone_specis used to allow the configuration of other target specificcharacteristics of the clone operation as described in clone_ingress_pkt_to_ingress. In addition to other session attributes, clone_specdetermines the egress specification (standard metadata egress_spec) that is presented to the Buffering Mechanism.The cloned instance will have instance_typeset to indicate that it is anegress clone.The function may also be referred to as clone_e2e.See the Section 15 for more details.10.1.1 Parameter BindingIn several primitive actions above, a parameter may take one of:• An immediate value; or• A value from a table entry’s action parameter data; or• A reference to a field instance whose current value is used; or• A reference to a counter, meter, or register cell whose current value is used.The P4 language does not specify limits on the specification of which of these may beexercised at a given time.
However, it should be noted that there is a qualitative difference (in the sense that it imposes different functional requirements on the underlyingtarget) between specifying a particular field instance in a P4 program and allowing a runtime API to specify the field instance to reference when the table entry is added.6510.2 Action Definitions10 ACTIONSThis is a binding-time issue; the first binds the field reference at compile time whilethe second allows run time binding.
Targets may impose constraints on the flexibilityallowed for such parameter binding. The difference must also be reflected in the runtime interfaces that are generated.10.2 Action DefinitionsCompound actions are declared as functions.compound_action_function_declaration ::=action action_name ( [ action_param_list ] ) { action_statement * } |action action_name ( [ action_param_list ] ) ;action_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 function declarations must obey the following conventions:• The body of the function contains only:– Calls to other action functions (primitive or compound).– Calls to extern methods.• Recursion is not allowed.• The usage of an action parameter must conform to any qualifiers specified beforethe parameter’s type:– in: This parameter is effectively readonly and must not be modified by thecode enclosed by the parameter list.– inout: This parameter has no read/write usage restrictions.
If a directionality is not otherwise specified, this is assumed by default.• Compound actions must be declared with bodies, even if those bodies are empty.Primitive actions must be declared without bodies.Not all targets will support all forms of action expression. In particular:6610.2 Action Definitions10 ACTIONS• there might be limits on whether specific parameters have to be bound at compiletime or can be chosen by a table at run time.• there might be limits on the complexity of expressions bound to an action’s parameters when calling itTarget architectures should document such limitations accordingly.In the following example, the parameters dst_mac, src_mac and vid would be exposedvia a run time API for adding entries to the table which used this action.