1 .. SPDX-License-Identifier: BSD-3-Clause
2 Copyright 2016 6WIND S.A.
3 Copyright 2016 Mellanox Technologies, Ltd
5 Generic flow API (rte_flow)
6 ===========================
11 This API provides a generic means to configure hardware to match specific
12 traffic, alter its fate and query related counters according to any
13 number of user-defined rules.
15 It is named *rte_flow* after the prefix used for all its symbols, and is
16 defined in ``rte_flow.h``.
18 - Matching can be performed on packet data (protocol headers, payload) and
19 properties (e.g. associated physical port, virtual device function ID).
21 - Possible operations include dropping traffic, diverting it to specific
22 queues, to virtual/physical device functions or ports, performing tunnel
23 offloads, adding marks and so on.
31 A flow rule is the combination of attributes with a matching pattern and a
32 list of actions. Flow rules form the basis of this API.
34 Flow rules can have several distinct actions (such as counting,
35 encapsulating, decapsulating before redirecting packets to a particular
36 queue, etc.), instead of relying on several rules to achieve this and having
37 applications deal with hardware implementation details regarding their
40 Support for different priority levels on a rule basis is provided, for
41 example in order to force a more specific rule to come before a more generic
42 one for packets matched by both. However hardware support for more than a
43 single priority level cannot be guaranteed. When supported, the number of
44 available priority levels is usually low, which is why they can also be
45 implemented in software by PMDs (e.g. missing priority levels may be
46 emulated by reordering rules).
48 In order to remain as hardware-agnostic as possible, by default all rules
49 are considered to have the same priority, which means that the order between
50 overlapping rules (when a packet is matched by several filters) is
53 PMDs may refuse to create overlapping rules at a given priority level when
54 they can be detected (e.g. if a pattern matches an existing filter).
56 Thus predictable results for a given priority level can only be achieved
57 with non-overlapping rules, using perfect matching on all protocol layers.
59 Flow rules can also be grouped, the flow rule priority is specific to the
60 group they belong to. All flow rules in a given group are thus processed within
61 the context of that group. Groups are not linked by default, so the logical
62 hierarchy of groups must be explicitly defined by flow rules themselves in each
63 group using the JUMP action to define the next group to redirect too. Only flow
64 rules defined in the default group 0 are guarantee to be matched against, this
65 makes group 0 the origin of any group hierarchy defined by an application.
67 Support for multiple actions per rule may be implemented internally on top
68 of non-default hardware priorities, as a result both features may not be
69 simultaneously available to applications.
71 Considering that allowed pattern/actions combinations cannot be known in
72 advance and would result in an impractically large number of capabilities to
73 expose, a method is provided to validate a given rule from the current
74 device configuration state.
76 This enables applications to check if the rule types they need is supported
77 at initialization time, before starting their data path. This method can be
78 used anytime, its only requirement being that the resources needed by a rule
79 should exist (e.g. a target RX queue should be configured first).
81 Each defined rule is associated with an opaque handle managed by the PMD,
82 applications are responsible for keeping it. These can be used for queries
83 and rules management, such as retrieving counters or other data and
86 To avoid resource leaks on the PMD side, handles must be explicitly
87 destroyed by the application before releasing associated resources such as
90 The following sections cover:
92 - **Attributes** (represented by ``struct rte_flow_attr``): properties of a
93 flow rule such as its direction (ingress or egress) and priority.
95 - **Pattern item** (represented by ``struct rte_flow_item``): part of a
96 matching pattern that either matches specific packet data or traffic
97 properties. It can also describe properties of the pattern itself, such as
100 - **Matching pattern**: traffic properties to look for, a combination of any
103 - **Actions** (represented by ``struct rte_flow_action``): operations to
104 perform whenever a packet is matched by a pattern.
112 Flow rules can be grouped by assigning them a common group number. Groups
113 allow a logical hierarchy of flow rule groups (tables) to be defined. These
114 groups can be supported virtually in the PMD or in the physical device.
115 Group 0 is the default group and this is the only group which flows are
116 guarantee to matched against, all subsequent groups can only be reached by
117 way of the JUMP action from a matched flow rule.
119 Although optional, applications are encouraged to group similar rules as
120 much as possible to fully take advantage of hardware capabilities
121 (e.g. optimized matching) and work around limitations (e.g. a single pattern
122 type possibly allowed in a given group), while being aware that the groups
123 hierarchies must be programmed explicitly.
125 Note that support for more than a single group is not guaranteed.
130 A priority level can be assigned to a flow rule, lower values
131 denote higher priority, with 0 as the maximum.
133 Priority levels are arbitrary and up to the application, they do
134 not need to be contiguous nor start from 0, however the maximum number
135 varies between devices and may be affected by existing flow rules.
137 A flow which matches multiple rules in the same group will always matched by
138 the rule with the highest priority in that group.
140 If a packet is matched by several rules of a given group for a given
141 priority level, the outcome is undefined. It can take any path, may be
142 duplicated or even cause unrecoverable errors.
144 Note that support for more than a single priority level is not guaranteed.
146 Attribute: Traffic direction
147 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
149 Unless `Attribute: Transfer`_ is specified, flow rule patterns apply
150 to inbound and / or outbound traffic. With this respect, ``ingress``
151 and ``egress`` respectively stand for **inbound** and **outbound**
152 based on the standpoint of the application creating a flow rule.
154 Several pattern items and actions are valid and can be used in both
155 directions. At least one direction must be specified.
157 Specifying both directions at once for a given rule is not recommended but
158 may be valid in a few cases.
163 Instead of simply matching the properties of traffic as it would appear on a
164 given DPDK port ID, enabling this attribute transfers a flow rule to the
165 lowest possible level of any device endpoints found in the pattern.
167 When supported, this effectively enables an application to reroute traffic
168 not necessarily intended for it (e.g. coming from or addressed to different
169 physical ports, VFs or applications) at the device level.
171 In "transfer" flows, the use of `Attribute: Traffic direction`_ in the sense of
172 implicitly matching packets going to or going from the ethdev used to create
173 flow rules is **deprecated**. `Attribute: Transfer`_ shifts the viewpoint to
174 the embedded switch. In it, `Attribute: Traffic direction`_ is ambiguous as
175 the switch serves many different endpoints. The application should match
176 traffic originating from precise locations. To do so, it should
177 use `Item: PORT_REPRESENTOR`_ and `Item: REPRESENTED_PORT`_.
182 Pattern items fall in two categories:
184 - Matching protocol headers and packet data, usually associated with a
185 specification structure. These must be stacked in the same order as the
186 protocol layers to match inside packets, starting from the lowest.
188 - Matching meta-data or affecting pattern processing, often without a
189 specification structure. Since they do not match packet contents, their
190 position in the list is usually not relevant.
192 Item specification structures are used to match specific values among
193 protocol fields (or item properties). Documentation describes for each item
194 whether they are associated with one and their type name if so.
196 Up to three structures of the same type can be set for a given item:
198 - ``spec``: values to match (e.g. a given IPv4 address).
200 - ``last``: upper bound for an inclusive range with corresponding fields in
203 - ``mask``: bit-mask applied to both ``spec`` and ``last`` whose purpose is
204 to distinguish the values to take into account and/or partially mask them
205 out (e.g. in order to match an IPv4 address prefix).
207 Usage restrictions and expected behavior:
209 - Setting either ``mask`` or ``last`` without ``spec`` is an error.
211 - Field values in ``last`` which are either 0 or equal to the corresponding
212 values in ``spec`` are ignored; they do not generate a range. Nonzero
213 values lower than those in ``spec`` are not supported.
215 - Setting ``spec`` and optionally ``last`` without ``mask`` causes the PMD
216 to use the default mask defined for that item (defined as
217 ``rte_flow_item_{name}_mask`` constants).
219 - Not setting any of them (assuming item type allows it) is equivalent to
220 providing an empty (zeroed) ``mask`` for broad (nonspecific) matching.
222 - ``mask`` is a simple bit-mask applied before interpreting the contents of
223 ``spec`` and ``last``, which may yield unexpected results if not used
224 carefully. For example, if for an IPv4 address field, ``spec`` provides
225 *10.1.2.3*, ``last`` provides *10.3.4.5* and ``mask`` provides
226 *255.255.0.0*, the effective range becomes *10.1.0.0* to *10.3.255.255*.
228 Example of an item specification matching an Ethernet header:
230 .. _table_rte_flow_pattern_item_example:
232 .. table:: Ethernet item
234 +----------+----------+-----------------------+
235 | Field | Subfield | Value |
236 +==========+==========+=======================+
237 | ``spec`` | ``src`` | ``00:00:01:02:03:04`` |
238 | +----------+-----------------------+
239 | | ``dst`` | ``00:00:2a:66:00:01`` |
240 | +----------+-----------------------+
241 | | ``type`` | ``0x22aa`` |
242 +----------+----------+-----------------------+
243 | ``last`` | unspecified |
244 +----------+----------+-----------------------+
245 | ``mask`` | ``src`` | ``00:00:ff:ff:ff:00`` |
246 | +----------+-----------------------+
247 | | ``dst`` | ``00:00:00:00:00:ff`` |
248 | +----------+-----------------------+
249 | | ``type`` | ``0x0000`` |
250 +----------+----------+-----------------------+
252 Non-masked bits stand for any value (shown as ``?`` below), Ethernet headers
253 with the following properties are thus matched:
255 - ``src``: ``??:??:01:02:03:??``
256 - ``dst``: ``??:??:??:??:??:01``
257 - ``type``: ``0x????``
262 A pattern is formed by stacking items starting from the lowest protocol
263 layer to match. This stacking restriction does not apply to meta items which
264 can be placed anywhere in the stack without affecting the meaning of the
267 Patterns are terminated by END items.
271 .. _table_rte_flow_tcpv4_as_l4:
273 .. table:: TCPv4 as L4
289 .. _table_rte_flow_tcpv6_in_vxlan:
291 .. table:: TCPv6 in VXLAN
293 +-------+------------+
295 +=======+============+
297 +-------+------------+
299 +-------+------------+
301 +-------+------------+
303 +-------+------------+
305 +-------+------------+
307 +-------+------------+
309 +-------+------------+
311 +-------+------------+
315 .. _table_rte_flow_tcpv4_as_l4_meta:
317 .. table:: TCPv4 as L4 with meta items
339 The above example shows how meta items do not affect packet data matching
340 items, as long as those remain stacked properly. The resulting matching
341 pattern is identical to "TCPv4 as L4".
343 .. _table_rte_flow_udpv6_anywhere:
345 .. table:: UDPv6 anywhere
357 If supported by the PMD, omitting one or several protocol layers at the
358 bottom of the stack as in the above example (missing an Ethernet
359 specification) enables looking up anywhere in packets.
361 It is unspecified whether the payload of supported encapsulations
362 (e.g. VXLAN payload) is matched by such a pattern, which may apply to inner,
363 outer or both packets.
365 .. _table_rte_flow_invalid_l3:
367 .. table:: Invalid, missing L3
379 The above pattern is invalid due to a missing L3 specification between L2
380 (Ethernet) and L4 (UDP). Doing so is only allowed at the bottom and at the
386 They match meta-data or affect pattern processing instead of matching packet
387 data directly, most of them do not need a specification structure. This
388 particularity allows them to be specified anywhere in the stack without
389 causing any side effect.
394 End marker for item lists. Prevents further processing of items, thereby
397 - Its numeric value is 0 for convenience.
398 - PMD support is mandatory.
399 - ``spec``, ``last`` and ``mask`` are ignored.
401 .. _table_rte_flow_item_end:
405 +----------+---------+
407 +==========+=========+
408 | ``spec`` | ignored |
409 +----------+---------+
410 | ``last`` | ignored |
411 +----------+---------+
412 | ``mask`` | ignored |
413 +----------+---------+
418 Used as a placeholder for convenience. It is ignored and simply discarded by
421 - PMD support is mandatory.
422 - ``spec``, ``last`` and ``mask`` are ignored.
424 .. _table_rte_flow_item_void:
428 +----------+---------+
430 +==========+=========+
431 | ``spec`` | ignored |
432 +----------+---------+
433 | ``last`` | ignored |
434 +----------+---------+
435 | ``mask`` | ignored |
436 +----------+---------+
438 One usage example for this type is generating rules that share a common
439 prefix quickly without reallocating memory, only by updating item types:
441 .. _table_rte_flow_item_void_example:
443 .. table:: TCP, UDP or ICMP as L4
445 +-------+--------------------+
447 +=======+====================+
449 +-------+--------------------+
451 +-------+------+------+------+
452 | 2 | UDP | VOID | VOID |
453 +-------+------+------+------+
454 | 3 | VOID | TCP | VOID |
455 +-------+------+------+------+
456 | 4 | VOID | VOID | ICMP |
457 +-------+------+------+------+
459 +-------+--------------------+
464 Inverted matching, i.e. process packets that do not match the pattern.
466 - ``spec``, ``last`` and ``mask`` are ignored.
468 .. _table_rte_flow_item_invert:
472 +----------+---------+
474 +==========+=========+
475 | ``spec`` | ignored |
476 +----------+---------+
477 | ``last`` | ignored |
478 +----------+---------+
479 | ``mask`` | ignored |
480 +----------+---------+
482 Usage example, matching non-TCPv4 packets only:
484 .. _table_rte_flow_item_invert_example:
486 .. table:: Anything but TCPv4
505 This item is deprecated. Consider:
506 - `Item: PORT_REPRESENTOR`_
507 - `Item: REPRESENTED_PORT`_
509 Matches traffic originating from (ingress) or going to (egress) the physical
510 function of the current device.
512 If supported, should work even if the physical function is not managed by
513 the application and thus not associated with a DPDK port ID.
515 - Can be combined with any number of `Item: VF`_ to match both PF and VF
517 - ``spec``, ``last`` and ``mask`` must not be set.
519 .. _table_rte_flow_item_pf:
536 This item is deprecated. Consider:
537 - `Item: PORT_REPRESENTOR`_
538 - `Item: REPRESENTED_PORT`_
540 Matches traffic originating from (ingress) or going to (egress) a given
541 virtual function of the current device.
543 If supported, should work even if the virtual function is not managed by the
544 application and thus not associated with a DPDK port ID.
546 Note this pattern item does not match VF representors traffic which, as
547 separate entities, should be addressed through their own DPDK port IDs.
549 - Can be specified multiple times to match traffic addressed to several VF
551 - Can be combined with a PF item to match both PF and VF traffic.
552 - Default ``mask`` matches any VF ID.
554 .. _table_rte_flow_item_vf:
558 +----------+----------+---------------------------+
559 | Field | Subfield | Value |
560 +==========+==========+===========================+
561 | ``spec`` | ``id`` | destination VF ID |
562 +----------+----------+---------------------------+
563 | ``last`` | ``id`` | upper range value |
564 +----------+----------+---------------------------+
565 | ``mask`` | ``id`` | zeroed to match any VF ID |
566 +----------+----------+---------------------------+
571 This item is deprecated. Consider:
572 - `Item: PORT_REPRESENTOR`_
573 - `Item: REPRESENTED_PORT`_
575 Matches traffic originating from (ingress) or going to (egress) a physical
576 port of the underlying device.
578 The first PHY_PORT item overrides the physical port normally associated with
579 the specified DPDK input port (port_id). This item can be provided several
580 times to match additional physical ports.
582 Note that physical ports are not necessarily tied to DPDK input ports
583 (port_id) when those are not under DPDK control. Possible values are
584 specific to each device, they are not necessarily indexed from zero and may
587 As a device property, the list of allowed values as well as the value
588 associated with a port_id should be retrieved by other means.
590 - Default ``mask`` matches any port index.
592 .. _table_rte_flow_item_phy_port:
596 +----------+-----------+--------------------------------+
597 | Field | Subfield | Value |
598 +==========+===========+================================+
599 | ``spec`` | ``index`` | physical port index |
600 +----------+-----------+--------------------------------+
601 | ``last`` | ``index`` | upper range value |
602 +----------+-----------+--------------------------------+
603 | ``mask`` | ``index`` | zeroed to match any port index |
604 +----------+-----------+--------------------------------+
609 This item is deprecated. Consider:
610 - `Item: PORT_REPRESENTOR`_
611 - `Item: REPRESENTED_PORT`_
613 Matches traffic originating from (ingress) or going to (egress) a given DPDK
616 Normally only supported if the port ID in question is known by the
617 underlying PMD and related to the device the flow rule is created against.
619 This must not be confused with `Item: PHY_PORT`_ which refers to the
620 physical port of a device, whereas `Item: PORT_ID`_ refers to a ``struct
621 rte_eth_dev`` object on the application side (also known as "port
622 representor" depending on the kind of underlying device).
624 - Default ``mask`` matches the specified DPDK port ID.
626 .. _table_rte_flow_item_port_id:
630 +----------+----------+-----------------------------+
631 | Field | Subfield | Value |
632 +==========+==========+=============================+
633 | ``spec`` | ``id`` | DPDK port ID |
634 +----------+----------+-----------------------------+
635 | ``last`` | ``id`` | upper range value |
636 +----------+----------+-----------------------------+
637 | ``mask`` | ``id`` | zeroed to match any port ID |
638 +----------+----------+-----------------------------+
643 Matches an arbitrary integer value which was set using the ``MARK`` action in
644 a previously matched rule.
646 This item can only specified once as a match criteria as the ``MARK`` action can
647 only be specified once in a flow action.
649 Note the value of MARK field is arbitrary and application defined.
651 Depending on the underlying implementation the MARK item may be supported on
652 the physical device, with virtual groups in the PMD or not at all.
654 - Default ``mask`` matches any integer value.
656 .. _table_rte_flow_item_mark:
660 +----------+----------+---------------------------+
661 | Field | Subfield | Value |
662 +==========+==========+===========================+
663 | ``spec`` | ``id`` | integer value |
664 +----------+--------------------------------------+
665 | ``last`` | ``id`` | upper range value |
666 +----------+----------+---------------------------+
667 | ``mask`` | ``id`` | zeroed to match any value |
668 +----------+----------+---------------------------+
673 Matches tag item set by other flows. Multiple tags are supported by specifying
676 - Default ``mask`` matches the specified tag value and index.
678 .. _table_rte_flow_item_tag:
682 +----------+----------+----------------------------------------+
683 | Field | Subfield | Value |
684 +==========+===========+=======================================+
685 | ``spec`` | ``data`` | 32 bit flow tag value |
686 | +-----------+---------------------------------------+
687 | | ``index`` | index of flow tag |
688 +----------+-----------+---------------------------------------+
689 | ``last`` | ``data`` | upper range value |
690 | +-----------+---------------------------------------+
691 | | ``index`` | field is ignored |
692 +----------+-----------+---------------------------------------+
693 | ``mask`` | ``data`` | bit-mask applies to "spec" and "last" |
694 | +-----------+---------------------------------------+
695 | | ``index`` | field is ignored |
696 +----------+-----------+---------------------------------------+
701 Matches 32 bit metadata item set.
703 On egress, metadata can be set either by mbuf metadata field with
704 PKT_TX_DYNF_METADATA flag or ``SET_META`` action. On ingress, ``SET_META``
705 action sets metadata for a packet and the metadata will be reported via
706 ``metadata`` dynamic field of ``rte_mbuf`` with PKT_RX_DYNF_METADATA flag.
708 - Default ``mask`` matches the specified Rx metadata value.
710 .. _table_rte_flow_item_meta:
714 +----------+----------+---------------------------------------+
715 | Field | Subfield | Value |
716 +==========+==========+=======================================+
717 | ``spec`` | ``data`` | 32 bit metadata value |
718 +----------+----------+---------------------------------------+
719 | ``last`` | ``data`` | upper range value |
720 +----------+----------+---------------------------------------+
721 | ``mask`` | ``data`` | bit-mask applies to "spec" and "last" |
722 +----------+----------+---------------------------------------+
724 Data matching item types
725 ~~~~~~~~~~~~~~~~~~~~~~~~
727 Most of these are basically protocol header definitions with associated
728 bit-masks. They must be specified (stacked) from lowest to highest protocol
729 layer to form a matching pattern.
734 Matches any protocol in place of the current layer, a single ANY may also
735 stand for several protocol layers.
737 This is usually specified as the first pattern item when looking for a
738 protocol anywhere in a packet.
740 - Default ``mask`` stands for any number of layers.
742 .. _table_rte_flow_item_any:
746 +----------+----------+--------------------------------------+
747 | Field | Subfield | Value |
748 +==========+==========+======================================+
749 | ``spec`` | ``num`` | number of layers covered |
750 +----------+----------+--------------------------------------+
751 | ``last`` | ``num`` | upper range value |
752 +----------+----------+--------------------------------------+
753 | ``mask`` | ``num`` | zeroed to cover any number of layers |
754 +----------+----------+--------------------------------------+
756 Example for VXLAN TCP payload matching regardless of outer L3 (IPv4 or IPv6)
757 and L4 (UDP) both matched by the first ANY specification, and inner L3 (IPv4
758 or IPv6) matched by the second ANY specification:
760 .. _table_rte_flow_item_any_example:
762 .. table:: TCP in VXLAN with wildcards
764 +-------+------+----------+----------+-------+
765 | Index | Item | Field | Subfield | Value |
766 +=======+======+==========+==========+=======+
768 +-------+------+----------+----------+-------+
769 | 1 | ANY | ``spec`` | ``num`` | 2 |
770 +-------+------+----------+----------+-------+
772 +-------+------------------------------------+
774 +-------+------+----------+----------+-------+
775 | 4 | ANY | ``spec`` | ``num`` | 1 |
776 +-------+------+----------+----------+-------+
778 +-------+------------------------------------+
780 +-------+------------------------------------+
785 Matches a byte string of a given length at a given offset.
787 Offset is either absolute (using the start of the packet) or relative to the
788 end of the previous matched item in the stack, in which case negative values
791 If search is enabled, offset is used as the starting point. The search area
792 can be delimited by setting limit to a nonzero value, which is the maximum
793 number of bytes after offset where the pattern may start.
795 Matching a zero-length pattern is allowed, doing so resets the relative
796 offset for subsequent items.
798 - This type does not support ranges (``last`` field).
799 - Default ``mask`` matches all fields exactly.
801 .. _table_rte_flow_item_raw:
805 +----------+--------------+-------------------------------------------------+
806 | Field | Subfield | Value |
807 +==========+==============+=================================================+
808 | ``spec`` | ``relative`` | look for pattern after the previous item |
809 | +--------------+-------------------------------------------------+
810 | | ``search`` | search pattern from offset (see also ``limit``) |
811 | +--------------+-------------------------------------------------+
812 | | ``reserved`` | reserved, must be set to zero |
813 | +--------------+-------------------------------------------------+
814 | | ``offset`` | absolute or relative offset for ``pattern`` |
815 | +--------------+-------------------------------------------------+
816 | | ``limit`` | search area limit for start of ``pattern`` |
817 | +--------------+-------------------------------------------------+
818 | | ``length`` | ``pattern`` length |
819 | +--------------+-------------------------------------------------+
820 | | ``pattern`` | byte string to look for |
821 +----------+--------------+-------------------------------------------------+
822 | ``last`` | if specified, either all 0 or with the same values as ``spec`` |
823 +----------+----------------------------------------------------------------+
824 | ``mask`` | bit-mask applied to ``spec`` values with usual behavior |
825 +----------+----------------------------------------------------------------+
827 Example pattern looking for several strings at various offsets of a UDP
828 payload, using combined RAW items:
830 .. _table_rte_flow_item_raw_example:
832 .. table:: UDP payload matching
834 +-------+------+----------+--------------+-------+
835 | Index | Item | Field | Subfield | Value |
836 +=======+======+==========+==============+=======+
838 +-------+----------------------------------------+
840 +-------+----------------------------------------+
842 +-------+------+----------+--------------+-------+
843 | 3 | RAW | ``spec`` | ``relative`` | 1 |
844 | | | +--------------+-------+
845 | | | | ``search`` | 1 |
846 | | | +--------------+-------+
847 | | | | ``offset`` | 10 |
848 | | | +--------------+-------+
849 | | | | ``limit`` | 0 |
850 | | | +--------------+-------+
851 | | | | ``length`` | 3 |
852 | | | +--------------+-------+
853 | | | | ``pattern`` | "foo" |
854 +-------+------+----------+--------------+-------+
855 | 4 | RAW | ``spec`` | ``relative`` | 1 |
856 | | | +--------------+-------+
857 | | | | ``search`` | 0 |
858 | | | +--------------+-------+
859 | | | | ``offset`` | 20 |
860 | | | +--------------+-------+
861 | | | | ``limit`` | 0 |
862 | | | +--------------+-------+
863 | | | | ``length`` | 3 |
864 | | | +--------------+-------+
865 | | | | ``pattern`` | "bar" |
866 +-------+------+----------+--------------+-------+
867 | 5 | RAW | ``spec`` | ``relative`` | 1 |
868 | | | +--------------+-------+
869 | | | | ``search`` | 0 |
870 | | | +--------------+-------+
871 | | | | ``offset`` | -29 |
872 | | | +--------------+-------+
873 | | | | ``limit`` | 0 |
874 | | | +--------------+-------+
875 | | | | ``length`` | 3 |
876 | | | +--------------+-------+
877 | | | | ``pattern`` | "baz" |
878 +-------+------+----------+--------------+-------+
880 +-------+----------------------------------------+
884 - Locate "foo" at least 10 bytes deep inside UDP payload.
885 - Locate "bar" after "foo" plus 20 bytes.
886 - Locate "baz" after "bar" minus 29 bytes.
888 Such a packet may be represented as follows (not to scale)::
891 | |<--------->| |<--------->|
893 |-----|------|-----|-----|-----|-----|-----------|-----|------|
894 | ETH | IPv4 | UDP | ... | baz | foo | ......... | bar | .... |
895 |-----|------|-----|-----|-----|-----|-----------|-----|------|
897 |<--------------------------->|
900 Note that matching subsequent pattern items would resume after "baz", not
901 "bar" since matching is always performed after the previous item of the
907 Matches an Ethernet header.
909 The ``type`` field either stands for "EtherType" or "TPID" when followed by
910 so-called layer 2.5 pattern items such as ``RTE_FLOW_ITEM_TYPE_VLAN``. In
911 the latter case, ``type`` refers to that of the outer header, with the inner
912 EtherType/TPID provided by the subsequent pattern item. This is the same
913 order as on the wire.
914 If the ``type`` field contains a TPID value, then only tagged packets with the
915 specified TPID will match the pattern.
916 The field ``has_vlan`` can be used to match any type of tagged packets,
917 instead of using the ``type`` field.
918 If the ``type`` and ``has_vlan`` fields are not specified, then both tagged
919 and untagged packets will match the pattern.
921 - ``dst``: destination MAC.
922 - ``src``: source MAC.
923 - ``type``: EtherType or TPID.
924 - ``has_vlan``: packet header contains at least one VLAN.
925 - Default ``mask`` matches destination and source addresses only.
930 Matches an 802.1Q/ad VLAN tag.
932 The corresponding standard outer EtherType (TPID) values are
933 ``RTE_ETHER_TYPE_VLAN`` or ``RTE_ETHER_TYPE_QINQ``. It can be overridden by the
934 preceding pattern item.
935 If a ``VLAN`` item is present in the pattern, then only tagged packets will
937 The field ``has_more_vlan`` can be used to match any type of tagged packets,
938 instead of using the ``inner_type field``.
939 If the ``inner_type`` and ``has_more_vlan`` fields are not specified,
940 then any tagged packets will match the pattern.
942 - ``tci``: tag control information.
943 - ``inner_type``: inner EtherType or TPID.
944 - ``has_more_vlan``: packet header contains at least one more VLAN, after this VLAN.
945 - Default ``mask`` matches the VID part of TCI only (lower 12 bits).
950 Matches an IPv4 header.
952 Note: IPv4 options are handled by dedicated pattern items.
954 - ``hdr``: IPv4 header definition (``rte_ip.h``).
955 - Default ``mask`` matches source and destination addresses only.
960 Matches an IPv6 header.
962 Dedicated flags indicate if header contains specific extension headers.
963 To match on packets containing a specific extension header, an application
964 should match on the dedicated flag set to 1.
965 To match on packets not containing a specific extension header, an application
966 should match on the dedicated flag clear to 0.
967 In case application doesn't care about the existence of a specific extension
968 header, it should not specify the dedicated flag for matching.
970 - ``hdr``: IPv6 header definition (``rte_ip.h``).
971 - ``has_hop_ext``: header contains Hop-by-Hop Options extension header.
972 - ``has_route_ext``: header contains Routing extension header.
973 - ``has_frag_ext``: header contains Fragment extension header.
974 - ``has_auth_ext``: header contains Authentication extension header.
975 - ``has_esp_ext``: header contains Encapsulation Security Payload extension header.
976 - ``has_dest_ext``: header contains Destination Options extension header.
977 - ``has_mobil_ext``: header contains Mobility extension header.
978 - ``has_hip_ext``: header contains Host Identity Protocol extension header.
979 - ``has_shim6_ext``: header contains Shim6 Protocol extension header.
980 - Default ``mask`` matches ``hdr`` source and destination addresses only.
985 Matches an ICMP header.
987 - ``hdr``: ICMP header definition (``rte_icmp.h``).
988 - Default ``mask`` matches ICMP type and code only.
993 Matches a UDP header.
995 - ``hdr``: UDP header definition (``rte_udp.h``).
996 - Default ``mask`` matches source and destination ports only.
1001 Matches a TCP header.
1003 - ``hdr``: TCP header definition (``rte_tcp.h``).
1004 - Default ``mask`` matches source and destination ports only.
1009 Matches a SCTP header.
1011 - ``hdr``: SCTP header definition (``rte_sctp.h``).
1012 - Default ``mask`` matches source and destination ports only.
1017 Matches a VXLAN header (RFC 7348).
1019 - ``flags``: normally 0x08 (I flag).
1020 - ``rsvd0``: reserved, normally 0x000000.
1021 - ``vni``: VXLAN network identifier.
1022 - ``rsvd1``: reserved, normally 0x00.
1023 - Default ``mask`` matches VNI only.
1028 Matches an IEEE 802.1BR E-Tag header.
1030 The corresponding standard outer EtherType (TPID) value is
1031 ``RTE_ETHER_TYPE_ETAG``. It can be overridden by the preceding pattern item.
1033 - ``epcp_edei_in_ecid_b``: E-Tag control information (E-TCI), E-PCP (3b),
1034 E-DEI (1b), ingress E-CID base (12b).
1035 - ``rsvd_grp_ecid_b``: reserved (2b), GRP (2b), E-CID base (12b).
1036 - ``in_ecid_e``: ingress E-CID ext.
1037 - ``ecid_e``: E-CID ext.
1038 - ``inner_type``: inner EtherType or TPID.
1039 - Default ``mask`` simultaneously matches GRP and E-CID base.
1044 Matches a NVGRE header (RFC 7637).
1046 - ``c_k_s_rsvd0_ver``: checksum (1b), undefined (1b), key bit (1b),
1047 sequence number (1b), reserved 0 (9b), version (3b). This field must have
1048 value 0x2000 according to RFC 7637.
1049 - ``protocol``: protocol type (0x6558).
1050 - ``tni``: virtual subnet ID.
1051 - ``flow_id``: flow ID.
1052 - Default ``mask`` matches TNI only.
1057 Matches a MPLS header.
1059 - ``label_tc_s_ttl``: label, TC, Bottom of Stack and TTL.
1060 - Default ``mask`` matches label only.
1065 Matches a GRE header.
1067 - ``c_rsvd0_ver``: checksum, reserved 0 and version.
1068 - ``protocol``: protocol type.
1069 - Default ``mask`` matches protocol only.
1074 Matches a GRE key field.
1075 This should be preceded by item ``GRE``.
1077 - Value to be matched is a big-endian 32 bit integer.
1078 - When this item present it implicitly match K bit in default mask as "1"
1083 Fuzzy pattern match, expect faster than default.
1085 This is for device that support fuzzy match option. Usually a fuzzy match is
1086 fast but the cost is accuracy. i.e. Signature Match only match pattern's hash
1087 value, but it is possible two different patterns have the same hash value.
1089 Matching accuracy level can be configured by threshold. Driver can divide the
1090 range of threshold and map to different accuracy levels that device support.
1092 Threshold 0 means perfect match (no fuzziness), while threshold 0xffffffff
1093 means fuzziest match.
1095 .. _table_rte_flow_item_fuzzy:
1099 +----------+---------------+--------------------------------------------------+
1100 | Field | Subfield | Value |
1101 +==========+===============+==================================================+
1102 | ``spec`` | ``threshold`` | 0 as perfect match, 0xffffffff as fuzziest match |
1103 +----------+---------------+--------------------------------------------------+
1104 | ``last`` | ``threshold`` | upper range value |
1105 +----------+---------------+--------------------------------------------------+
1106 | ``mask`` | ``threshold`` | bit-mask apply to "spec" and "last" |
1107 +----------+---------------+--------------------------------------------------+
1109 Usage example, fuzzy match a TCPv4 packets:
1111 .. _table_rte_flow_item_fuzzy_example:
1113 .. table:: Fuzzy matching
1115 +-------+----------+
1117 +=======+==========+
1119 +-------+----------+
1121 +-------+----------+
1123 +-------+----------+
1125 +-------+----------+
1127 +-------+----------+
1129 Item: ``GTP``, ``GTPC``, ``GTPU``
1130 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1132 Matches a GTPv1 header.
1134 Note: GTP, GTPC and GTPU use the same structure. GTPC and GTPU item
1135 are defined for a user-friendly API when creating GTP-C and GTP-U
1138 - ``v_pt_rsv_flags``: version (3b), protocol type (1b), reserved (1b),
1139 extension header flag (1b), sequence number flag (1b), N-PDU number
1141 - ``msg_type``: message type.
1142 - ``msg_len``: message length.
1143 - ``teid``: tunnel endpoint identifier.
1144 - Default ``mask`` matches teid only.
1149 Matches an ESP header.
1151 - ``hdr``: ESP header definition (``rte_esp.h``).
1152 - Default ``mask`` matches SPI only.
1157 Matches a GENEVE header.
1159 - ``ver_opt_len_o_c_rsvd0``: version (2b), length of the options fields (6b),
1160 OAM packet (1b), critical options present (1b), reserved 0 (6b).
1161 - ``protocol``: protocol type.
1162 - ``vni``: virtual network identifier.
1163 - ``rsvd1``: reserved, normally 0x00.
1164 - Default ``mask`` matches VNI only.
1169 Matches a VXLAN-GPE header (draft-ietf-nvo3-vxlan-gpe-05).
1171 - ``flags``: normally 0x0C (I and P flags).
1172 - ``rsvd0``: reserved, normally 0x0000.
1173 - ``protocol``: protocol type.
1174 - ``vni``: VXLAN network identifier.
1175 - ``rsvd1``: reserved, normally 0x00.
1176 - Default ``mask`` matches VNI only.
1178 Item: ``ARP_ETH_IPV4``
1179 ^^^^^^^^^^^^^^^^^^^^^^
1181 Matches an ARP header for Ethernet/IPv4.
1183 - ``hdr``: hardware type, normally 1.
1184 - ``pro``: protocol type, normally 0x0800.
1185 - ``hln``: hardware address length, normally 6.
1186 - ``pln``: protocol address length, normally 4.
1187 - ``op``: opcode (1 for request, 2 for reply).
1188 - ``sha``: sender hardware address.
1189 - ``spa``: sender IPv4 address.
1190 - ``tha``: target hardware address.
1191 - ``tpa``: target IPv4 address.
1192 - Default ``mask`` matches SHA, SPA, THA and TPA.
1197 Matches the presence of any IPv6 extension header.
1199 - ``next_hdr``: next header.
1200 - Default ``mask`` matches ``next_hdr``.
1202 Normally preceded by any of:
1207 Item: ``IPV6_FRAG_EXT``
1208 ^^^^^^^^^^^^^^^^^^^^^^^
1210 Matches the presence of IPv6 fragment extension header.
1212 - ``hdr``: IPv6 fragment extension header definition (``rte_ip.h``).
1214 Normally preceded by any of:
1222 Matches any ICMPv6 header.
1224 - ``type``: ICMPv6 type.
1225 - ``code``: ICMPv6 code.
1226 - ``checksum``: ICMPv6 checksum.
1227 - Default ``mask`` matches ``type`` and ``code``.
1229 Item: ``ICMP6_ND_NS``
1230 ^^^^^^^^^^^^^^^^^^^^^
1232 Matches an ICMPv6 neighbor discovery solicitation.
1234 - ``type``: ICMPv6 type, normally 135.
1235 - ``code``: ICMPv6 code, normally 0.
1236 - ``checksum``: ICMPv6 checksum.
1237 - ``reserved``: reserved, normally 0.
1238 - ``target_addr``: target address.
1239 - Default ``mask`` matches target address only.
1241 Item: ``ICMP6_ND_NA``
1242 ^^^^^^^^^^^^^^^^^^^^^
1244 Matches an ICMPv6 neighbor discovery advertisement.
1246 - ``type``: ICMPv6 type, normally 136.
1247 - ``code``: ICMPv6 code, normally 0.
1248 - ``checksum``: ICMPv6 checksum.
1249 - ``rso_reserved``: route flag (1b), solicited flag (1b), override flag
1250 (1b), reserved (29b).
1251 - ``target_addr``: target address.
1252 - Default ``mask`` matches target address only.
1254 Item: ``ICMP6_ND_OPT``
1255 ^^^^^^^^^^^^^^^^^^^^^^
1257 Matches the presence of any ICMPv6 neighbor discovery option.
1259 - ``type``: ND option type.
1260 - ``length``: ND option length.
1261 - Default ``mask`` matches type only.
1263 Normally preceded by any of:
1265 - `Item: ICMP6_ND_NA`_
1266 - `Item: ICMP6_ND_NS`_
1267 - `Item: ICMP6_ND_OPT`_
1269 Item: ``ICMP6_ND_OPT_SLA_ETH``
1270 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1272 Matches an ICMPv6 neighbor discovery source Ethernet link-layer address
1275 - ``type``: ND option type, normally 1.
1276 - ``length``: ND option length, normally 1.
1277 - ``sla``: source Ethernet LLA.
1278 - Default ``mask`` matches source link-layer address only.
1280 Normally preceded by any of:
1282 - `Item: ICMP6_ND_NA`_
1283 - `Item: ICMP6_ND_OPT`_
1285 Item: ``ICMP6_ND_OPT_TLA_ETH``
1286 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1288 Matches an ICMPv6 neighbor discovery target Ethernet link-layer address
1291 - ``type``: ND option type, normally 2.
1292 - ``length``: ND option length, normally 1.
1293 - ``tla``: target Ethernet LLA.
1294 - Default ``mask`` matches target link-layer address only.
1296 Normally preceded by any of:
1298 - `Item: ICMP6_ND_NS`_
1299 - `Item: ICMP6_ND_OPT`_
1304 Matches an application specific 32 bit metadata item.
1306 - Default ``mask`` matches the specified metadata value.
1311 Matches a GTP PDU extension header with type 0x85.
1313 - ``pdu_type``: PDU type.
1314 - ``qfi``: QoS flow identifier.
1315 - Default ``mask`` matches QFI only.
1317 Item: ``PPPOES``, ``PPPOED``
1318 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1320 Matches a PPPoE header.
1322 - ``version_type``: version (4b), type (4b).
1323 - ``code``: message type.
1324 - ``session_id``: session identifier.
1325 - ``length``: payload length.
1327 Item: ``PPPOE_PROTO_ID``
1328 ^^^^^^^^^^^^^^^^^^^^^^^^
1330 Matches a PPPoE session protocol identifier.
1332 - ``proto_id``: PPP protocol identifier.
1333 - Default ``mask`` matches proto_id only.
1338 Matches a network service header (RFC 8300).
1340 - ``version``: normally 0x0 (2 bits).
1341 - ``oam_pkt``: indicate oam packet (1 bit).
1342 - ``reserved``: reserved bit (1 bit).
1343 - ``ttl``: maximum SFF hopes (6 bits).
1344 - ``length``: total length in 4 bytes words (6 bits).
1345 - ``reserved1``: reserved1 bits (4 bits).
1346 - ``mdtype``: ndicates format of NSH header (4 bits).
1347 - ``next_proto``: indicates protocol type of encap data (8 bits).
1348 - ``spi``: service path identifier (3 bytes).
1349 - ``sindex``: service index (1 byte).
1350 - Default ``mask`` matches mdtype, next_proto, spi, sindex.
1356 Matches a Internet Group Management Protocol (RFC 2236).
1358 - ``type``: IGMP message type (Query/Report).
1359 - ``max_resp_time``: max time allowed before sending report.
1360 - ``checksum``: checksum, 1s complement of whole IGMP message.
1361 - ``group_addr``: group address, for Query value will be 0.
1362 - Default ``mask`` matches group_addr.
1368 Matches a IP Authentication Header (RFC 4302).
1370 - ``next_hdr``: next payload after AH.
1371 - ``payload_len``: total length of AH in 4B words.
1372 - ``reserved``: reserved bits.
1373 - ``spi``: security parameters index.
1374 - ``seq_num``: counter value increased by 1 on each packet sent.
1375 - Default ``mask`` matches spi.
1380 Matches a HIGIG2 header field. It is layer 2.5 protocol and used in
1383 - Default ``mask`` matches classification and vlan.
1388 Matches a L2TPv3 over IP header.
1390 - ``session_id``: L2TPv3 over IP session identifier.
1391 - Default ``mask`` matches session_id only.
1396 Matches a PFCP Header.
1398 - ``s_field``: S field.
1399 - ``msg_type``: message type.
1400 - ``msg_len``: message length.
1401 - ``seid``: session endpoint identifier.
1402 - Default ``mask`` matches s_field and seid.
1407 Matches a eCPRI header.
1409 - ``hdr``: eCPRI header definition (``rte_ecpri.h``).
1410 - Default ``mask`` matches nothing, for all eCPRI messages.
1412 Item: ``PACKET_INTEGRITY_CHECKS``
1413 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1415 Matches packet integrity.
1416 For some devices application needs to enable integration checks in HW
1417 before using this item.
1419 - ``level``: the encapsulation level that should be checked:
1420 - ``level == 0`` means the default PMD mode (can be inner most / outermost).
1421 - ``level == 1`` means outermost header.
1422 - ``level > 1`` means inner header. See also RSS level.
1423 - ``packet_ok``: All HW packet integrity checks have passed based on the
1424 topmost network layer. For example, for ICMP packet the topmost network
1425 layer is L3 and for TCP or UDP packet the topmost network layer is L4.
1426 - ``l2_ok``: all layer 2 HW integrity checks passed.
1427 - ``l3_ok``: all layer 3 HW integrity checks passed.
1428 - ``l4_ok``: all layer 4 HW integrity checks passed.
1429 - ``l2_crc_ok``: layer 2 CRC check passed.
1430 - ``ipv4_csum_ok``: IPv4 checksum check passed.
1431 - ``l4_csum_ok``: layer 4 checksum check passed.
1432 - ``l3_len_ok``: the layer 3 length is smaller than the frame length.
1437 Matches a conntrack state after conntrack action.
1439 - ``flags``: conntrack packet state flags.
1440 - Default ``mask`` matches all state bits.
1442 Item: ``PORT_REPRESENTOR``
1443 ^^^^^^^^^^^^^^^^^^^^^^^^^^
1445 Matches traffic entering the embedded switch from the given ethdev.
1447 Term **ethdev** and the concept of **port representor** are synonymous.
1448 The **represented port** is an *entity* plugged to the embedded switch
1449 at the opposite end of the "wire" leading to the ethdev.
1453 .--------------------.
1454 | PORT_REPRESENTOR | Ethdev (Application Port Referred to by its ID)
1455 '--------------------'
1477 .--------------------.
1478 | REPRESENTED_PORT | Net / Guest / Another Ethdev (Same Application)
1479 '--------------------'
1482 - Incompatible with `Attribute: Traffic direction`_.
1483 - Requires `Attribute: Transfer`_.
1485 .. _table_rte_flow_item_ethdev:
1487 .. table:: ``struct rte_flow_item_ethdev``
1489 +----------+-------------+---------------------------+
1490 | Field | Subfield | Value |
1491 +==========+=============+===========================+
1492 | ``spec`` | ``port_id`` | ethdev port ID |
1493 +----------+-------------+---------------------------+
1494 | ``last`` | ``port_id`` | upper range value |
1495 +----------+-------------+---------------------------+
1496 | ``mask`` | ``port_id`` | zeroed for wildcard match |
1497 +----------+-------------+---------------------------+
1499 - Default ``mask`` provides exact match behaviour.
1501 See also `Action: PORT_REPRESENTOR`_.
1503 Item: ``REPRESENTED_PORT``
1504 ^^^^^^^^^^^^^^^^^^^^^^^^^^
1506 Matches traffic entering the embedded switch from
1507 the entity represented by the given ethdev.
1509 Term **ethdev** and the concept of **port representor** are synonymous.
1510 The **represented port** is an *entity* plugged to the embedded switch
1511 at the opposite end of the "wire" leading to the ethdev.
1515 .--------------------.
1516 | PORT_REPRESENTOR | Ethdev (Application Port Referred to by its ID)
1517 '--------------------'
1539 .--------------------.
1540 | REPRESENTED_PORT | Net / Guest / Another Ethdev (Same Application)
1541 '--------------------'
1544 - Incompatible with `Attribute: Traffic direction`_.
1545 - Requires `Attribute: Transfer`_.
1547 This item is meant to use the same structure as `Item: PORT_REPRESENTOR`_.
1549 See also `Action: REPRESENTED_PORT`_.
1554 Matches with the custom network protocol header that was created
1555 using rte_flow_flex_item_create() API. The application describes
1556 the desired header structure, defines the header fields attributes
1557 and header relations with preceding and following protocols and
1558 configures the ethernet devices accordingly via
1559 rte_flow_flex_item_create() routine.
1561 - ``handle``: the flex item handle returned by the PMD on successful
1562 rte_flow_flex_item_create() call, mask for this field is ignored.
1563 - ``length``: match pattern length in bytes. If the length does not cover
1564 all fields defined in item configuration, the pattern spec and mask are
1565 considered by the driver as padded with trailing zeroes till the full
1566 configured item pattern length.
1567 - ``pattern``: pattern to match. The pattern is concatenation of bit fields
1568 configured at item creation. At configuration the fields are presented
1569 by sample_data array. The order of the bitfields is defined by the order
1570 of sample_data elements. The width of each bitfield is defined by the width
1571 specified in the corresponding sample_data element as well. If pattern
1572 length is smaller than configured fields overall length it is considered
1573 as padded with trailing zeroes up to full configured length, both for
1579 Each possible action is represented by a type.
1580 An action can have an associated configuration object.
1581 Several actions combined in a list can be assigned
1582 to a flow rule and are performed in order.
1584 They fall in three categories:
1586 - Actions that modify the fate of matching traffic, for instance by dropping
1587 or assigning it a specific destination.
1589 - Actions that modify matching traffic contents or its properties. This
1590 includes adding/removing encapsulation, encryption, compression and marks.
1592 - Actions related to the flow rule itself, such as updating counters or
1593 making it non-terminating.
1595 Flow rules being terminating by default, not specifying any action of the
1596 fate kind results in undefined behavior. This applies to both ingress and
1599 PASSTHRU, when supported, makes a flow rule non-terminating.
1601 Like matching patterns, action lists are terminated by END items.
1603 Example of action that redirects packets to queue index 10:
1605 .. _table_rte_flow_action_example:
1607 .. table:: Queue action
1609 +-----------+-------+
1611 +===========+=======+
1613 +-----------+-------+
1615 Actions are performed in list order:
1617 .. _table_rte_flow_count_then_drop:
1619 .. table:: Count then drop
1633 .. _table_rte_flow_mark_count_redirect:
1635 .. table:: Mark, count then redirect
1637 +-------+--------+------------+-------+
1638 | Index | Action | Field | Value |
1639 +=======+========+============+=======+
1640 | 0 | MARK | ``mark`` | 0x2a |
1641 +-------+--------+------------+-------+
1642 | 1 | COUNT | ``id`` | 0 |
1643 +-------+--------+------------+-------+
1644 | 2 | QUEUE | ``queue`` | 10 |
1645 +-------+--------+------------+-------+
1647 +-------+-----------------------------+
1651 .. _table_rte_flow_redirect_queue_5:
1653 .. table:: Redirect to queue 5
1655 +-------+--------+-----------+-------+
1656 | Index | Action | Field | Value |
1657 +=======+========+===========+=======+
1659 +-------+--------+-----------+-------+
1660 | 1 | QUEUE | ``queue`` | 5 |
1661 +-------+--------+-----------+-------+
1663 +-------+----------------------------+
1665 In the above example, while DROP and QUEUE must be performed in order, both
1666 have to happen before reaching END. Only QUEUE has a visible effect.
1668 Note that such a list may be thought as ambiguous and rejected on that
1671 .. _table_rte_flow_redirect_queue_5_3:
1673 .. table:: Redirect to queues 5 and 3
1675 +-------+--------+-----------+-------+
1676 | Index | Action | Field | Value |
1677 +=======+========+===========+=======+
1678 | 0 | QUEUE | ``queue`` | 5 |
1679 +-------+--------+-----------+-------+
1681 +-------+--------+-----------+-------+
1682 | 2 | QUEUE | ``queue`` | 3 |
1683 +-------+--------+-----------+-------+
1685 +-------+----------------------------+
1687 As previously described, all actions must be taken into account. This
1688 effectively duplicates traffic to both queues. The above example also shows
1689 that VOID is ignored.
1694 Common action types are described in this section.
1699 End marker for action lists. Prevents further processing of actions, thereby
1702 - Its numeric value is 0 for convenience.
1703 - PMD support is mandatory.
1704 - No configurable properties.
1706 .. _table_rte_flow_action_end:
1719 Used as a placeholder for convenience. It is ignored and simply discarded by
1722 - PMD support is mandatory.
1723 - No configurable properties.
1725 .. _table_rte_flow_action_void:
1735 Action: ``PASSTHRU``
1736 ^^^^^^^^^^^^^^^^^^^^
1738 Leaves traffic up for additional processing by subsequent flow rules; makes
1739 a flow rule non-terminating.
1741 - No configurable properties.
1743 .. _table_rte_flow_action_passthru:
1753 Example to copy a packet to a queue and continue processing by subsequent
1756 .. _table_rte_flow_action_passthru_example:
1758 .. table:: Copy to queue 8
1760 +-------+--------+-----------+-------+
1761 | Index | Action | Field | Value |
1762 +=======+========+===========+=======+
1764 +-------+--------+-----------+-------+
1765 | 1 | QUEUE | ``queue`` | 8 |
1766 +-------+--------+-----------+-------+
1768 +-------+----------------------------+
1773 Redirects packets to a group on the current device.
1775 In a hierarchy of groups, which can be used to represent physical or logical
1776 flow group/tables on the device, this action redirects the matched flow to
1777 the specified group on that device.
1779 If a matched flow is redirected to a table which doesn't contain a matching
1780 rule for that flow then the behavior is undefined and the resulting behavior
1781 is up to the specific device. Best practice when using groups would be define
1782 a default flow rule for each group which a defines the default actions in that
1783 group so a consistent behavior is defined.
1785 Defining an action for matched flow in a group to jump to a group which is
1786 higher in the group hierarchy may not be supported by physical devices,
1787 depending on how groups are mapped to the physical devices. In the
1788 definitions of jump actions, applications should be aware that it may be
1789 possible to define flow rules which trigger an undefined behavior causing
1790 flows to loop between groups.
1792 .. _table_rte_flow_action_jump:
1796 +-----------+------------------------------+
1798 +===========+==============================+
1799 | ``group`` | Group to redirect packets to |
1800 +-----------+------------------------------+
1805 Attaches an integer value to packets and sets ``PKT_RX_FDIR`` and
1806 ``PKT_RX_FDIR_ID`` mbuf flags.
1808 This value is arbitrary and application-defined. Maximum allowed value
1809 depends on the underlying implementation. It is returned in the
1810 ``hash.fdir.hi`` mbuf field.
1812 .. _table_rte_flow_action_mark:
1816 +--------+--------------------------------------+
1818 +========+======================================+
1819 | ``id`` | integer value to return with packets |
1820 +--------+--------------------------------------+
1825 Flags packets. Similar to `Action: MARK`_ without a specific value; only
1826 sets the ``PKT_RX_FDIR`` mbuf flag.
1828 - No configurable properties.
1830 .. _table_rte_flow_action_flag:
1843 Assigns packets to a given queue index.
1845 .. _table_rte_flow_action_queue:
1849 +-----------+--------------------+
1851 +===========+====================+
1852 | ``index`` | queue index to use |
1853 +-----------+--------------------+
1860 - No configurable properties.
1862 .. _table_rte_flow_action_drop:
1875 Adds a counter action to a matched flow.
1877 If more than one count action is specified in a single flow rule, then each
1878 action must specify a unique id.
1880 Counters can be retrieved and reset through ``rte_flow_query()``, see
1881 ``struct rte_flow_query_count``.
1883 For ports within the same switch domain then the counter id namespace extends
1884 to all ports within that switch domain.
1886 .. _table_rte_flow_action_count:
1890 +------------+---------------------------------+
1892 +============+=================================+
1893 | ``id`` | counter id |
1894 +------------+---------------------------------+
1896 Query structure to retrieve and reset flow rule counters:
1898 .. _table_rte_flow_query_count:
1900 .. table:: COUNT query
1902 +---------------+-----+-----------------------------------+
1903 | Field | I/O | Value |
1904 +===============+=====+===================================+
1905 | ``reset`` | in | reset counter after query |
1906 +---------------+-----+-----------------------------------+
1907 | ``hits_set`` | out | ``hits`` field is set |
1908 +---------------+-----+-----------------------------------+
1909 | ``bytes_set`` | out | ``bytes`` field is set |
1910 +---------------+-----+-----------------------------------+
1911 | ``hits`` | out | number of hits for this rule |
1912 +---------------+-----+-----------------------------------+
1913 | ``bytes`` | out | number of bytes through this rule |
1914 +---------------+-----+-----------------------------------+
1919 Similar to QUEUE, except RSS is additionally performed on packets to spread
1920 them among several queues according to the provided parameters.
1922 Unlike global RSS settings used by other DPDK APIs, unsetting the ``types``
1923 field does not disable RSS in a flow rule. Doing so instead requests safe
1924 unspecified "best-effort" settings from the underlying PMD, which depending
1925 on the flow rule, may result in anything ranging from empty (single queue)
1926 to all-inclusive RSS.
1928 If non-applicable for matching packets RSS types are requested,
1929 these RSS types are simply ignored. For example, it happens if:
1931 - Hashing of both TCP and UDP ports is requested
1932 (only one can be present in a packet).
1934 - Requested RSS types contradict to flow rule pattern
1935 (e.g. pattern has UDP item, but RSS types contain TCP).
1937 If requested RSS hash types are not supported by the Ethernet device at all
1938 (not reported in ``dev_info.flow_type_rss_offloads``),
1939 the flow creation will fail.
1941 Note: RSS hash result is stored in the ``hash.rss`` mbuf field which
1942 overlaps ``hash.fdir.lo``. Since `Action: MARK`_ sets the ``hash.fdir.hi``
1943 field only, both can be requested simultaneously.
1945 Also, regarding packet encapsulation ``level``:
1947 - ``0`` requests the default behavior. Depending on the packet type, it can
1948 mean outermost, innermost, anything in between or even no RSS.
1950 It basically stands for the innermost encapsulation level RSS can be
1951 performed on according to PMD and device capabilities.
1953 - ``1`` requests RSS to be performed on the outermost packet encapsulation
1956 - ``2`` and subsequent values request RSS to be performed on the specified
1957 inner packet encapsulation level, from outermost to innermost (lower to
1960 Values other than ``0`` are not necessarily supported.
1962 Requesting a specific RSS level on unrecognized traffic results in undefined
1963 behavior. For predictable results, it is recommended to make the flow rule
1964 pattern match packet headers up to the requested encapsulation level so that
1965 only matching traffic goes through.
1967 .. _table_rte_flow_action_rss:
1971 +---------------+---------------------------------------------+
1973 +===============+=============================================+
1974 | ``func`` | RSS hash function to apply |
1975 +---------------+---------------------------------------------+
1976 | ``level`` | encapsulation level for ``types`` |
1977 +---------------+---------------------------------------------+
1978 | ``types`` | specific RSS hash types (see ``ETH_RSS_*``) |
1979 +---------------+---------------------------------------------+
1980 | ``key_len`` | hash key length in bytes |
1981 +---------------+---------------------------------------------+
1982 | ``queue_num`` | number of entries in ``queue`` |
1983 +---------------+---------------------------------------------+
1984 | ``key`` | hash key |
1985 +---------------+---------------------------------------------+
1986 | ``queue`` | queue indices to use |
1987 +---------------+---------------------------------------------+
1992 This action is deprecated. Consider:
1993 - `Action: PORT_REPRESENTOR`_
1994 - `Action: REPRESENTED_PORT`_
1996 Directs matching traffic to the physical function (PF) of the current
2001 - No configurable properties.
2003 .. _table_rte_flow_action_pf:
2016 This action is deprecated. Consider:
2017 - `Action: PORT_REPRESENTOR`_
2018 - `Action: REPRESENTED_PORT`_
2020 Directs matching traffic to a given virtual function of the current device.
2022 Packets matched by a VF pattern item can be redirected to their original VF
2023 ID instead of the specified one. This parameter may not be available and is
2024 not guaranteed to work properly if the VF part is matched by a prior flow
2025 rule or if packets are not addressed to a VF in the first place.
2029 .. _table_rte_flow_action_vf:
2033 +--------------+--------------------------------+
2035 +==============+================================+
2036 | ``original`` | use original VF ID if possible |
2037 +--------------+--------------------------------+
2039 +--------------+--------------------------------+
2041 Action: ``PHY_PORT``
2042 ^^^^^^^^^^^^^^^^^^^^
2044 This action is deprecated. Consider:
2045 - `Action: PORT_REPRESENTOR`_
2046 - `Action: REPRESENTED_PORT`_
2048 Directs matching traffic to a given physical port index of the underlying
2051 See `Item: PHY_PORT`_.
2053 .. _table_rte_flow_action_phy_port:
2057 +--------------+-------------------------------------+
2059 +==============+=====================================+
2060 | ``original`` | use original port index if possible |
2061 +--------------+-------------------------------------+
2062 | ``index`` | physical port index |
2063 +--------------+-------------------------------------+
2067 This action is deprecated. Consider:
2068 - `Action: PORT_REPRESENTOR`_
2069 - `Action: REPRESENTED_PORT`_
2071 Directs matching traffic to a given DPDK port ID.
2073 See `Item: PORT_ID`_.
2075 .. _table_rte_flow_action_port_id:
2079 +--------------+---------------------------------------+
2081 +==============+=======================================+
2082 | ``original`` | use original DPDK port ID if possible |
2083 +--------------+---------------------------------------+
2084 | ``id`` | DPDK port ID |
2085 +--------------+---------------------------------------+
2090 Applies a stage of metering and policing.
2092 The metering and policing (MTR) object has to be first created using the
2093 rte_mtr_create() API function. The ID of the MTR object is specified as
2094 action parameter. More than one flow can use the same MTR object through
2095 the meter action. The MTR object can be further updated or queried using
2098 .. _table_rte_flow_action_meter:
2102 +--------------+---------------+
2104 +==============+===============+
2105 | ``mtr_id`` | MTR object ID |
2106 +--------------+---------------+
2108 Action: ``SECURITY``
2109 ^^^^^^^^^^^^^^^^^^^^
2111 Perform the security action on flows matched by the pattern items
2112 according to the configuration of the security session.
2114 This action modifies the payload of matched flows. For INLINE_CRYPTO, the
2115 security protocol headers and IV are fully provided by the application as
2116 specified in the flow pattern. The payload of matching packets is
2117 encrypted on egress, and decrypted and authenticated on ingress.
2118 For INLINE_PROTOCOL, the security protocol is fully offloaded to HW,
2119 providing full encapsulation and decapsulation of packets in security
2120 protocols. The flow pattern specifies both the outer security header fields
2121 and the inner packet fields. The security session specified in the action
2122 must match the pattern parameters.
2124 The security session specified in the action must be created on the same
2125 port as the flow action that is being specified.
2127 The ingress/egress flow attribute should match that specified in the
2128 security session if the security session supports the definition of the
2131 Multiple flows can be configured to use the same security session.
2133 .. _table_rte_flow_action_security:
2137 +----------------------+--------------------------------------+
2139 +======================+======================================+
2140 | ``security_session`` | security session to apply |
2141 +----------------------+--------------------------------------+
2143 The following is an example of configuring IPsec inline using the
2144 INLINE_CRYPTO security session:
2146 The encryption algorithm, keys and salt are part of the opaque
2147 ``rte_security_session``. The SA is identified according to the IP and ESP
2148 fields in the pattern items.
2150 .. _table_rte_flow_item_esp_inline_example:
2152 .. table:: IPsec inline crypto flow pattern items.
2154 +-------+----------+
2156 +=======+==========+
2158 +-------+----------+
2160 +-------+----------+
2162 +-------+----------+
2164 +-------+----------+
2166 .. _table_rte_flow_action_esp_inline_example:
2168 .. table:: IPsec inline flow actions.
2170 +-------+----------+
2172 +=======+==========+
2174 +-------+----------+
2176 +-------+----------+
2178 Action: ``OF_SET_MPLS_TTL``
2179 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
2181 Implements ``OFPAT_SET_MPLS_TTL`` ("MPLS TTL") as defined by the `OpenFlow
2182 Switch Specification`_.
2184 .. _table_rte_flow_action_of_set_mpls_ttl:
2186 .. table:: OF_SET_MPLS_TTL
2188 +--------------+----------+
2190 +==============+==========+
2191 | ``mpls_ttl`` | MPLS TTL |
2192 +--------------+----------+
2194 Action: ``OF_DEC_MPLS_TTL``
2195 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
2197 Implements ``OFPAT_DEC_MPLS_TTL`` ("decrement MPLS TTL") as defined by the
2198 `OpenFlow Switch Specification`_.
2200 .. _table_rte_flow_action_of_dec_mpls_ttl:
2202 .. table:: OF_DEC_MPLS_TTL
2210 Action: ``OF_SET_NW_TTL``
2211 ^^^^^^^^^^^^^^^^^^^^^^^^^
2213 Implements ``OFPAT_SET_NW_TTL`` ("IP TTL") as defined by the `OpenFlow
2214 Switch Specification`_.
2216 .. _table_rte_flow_action_of_set_nw_ttl:
2218 .. table:: OF_SET_NW_TTL
2220 +------------+--------+
2222 +============+========+
2223 | ``nw_ttl`` | IP TTL |
2224 +------------+--------+
2226 Action: ``OF_DEC_NW_TTL``
2227 ^^^^^^^^^^^^^^^^^^^^^^^^^
2229 Implements ``OFPAT_DEC_NW_TTL`` ("decrement IP TTL") as defined by the
2230 `OpenFlow Switch Specification`_.
2232 .. _table_rte_flow_action_of_dec_nw_ttl:
2234 .. table:: OF_DEC_NW_TTL
2242 Action: ``OF_COPY_TTL_OUT``
2243 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
2245 Implements ``OFPAT_COPY_TTL_OUT`` ("copy TTL "outwards" -- from
2246 next-to-outermost to outermost") as defined by the `OpenFlow Switch
2249 .. _table_rte_flow_action_of_copy_ttl_out:
2251 .. table:: OF_COPY_TTL_OUT
2259 Action: ``OF_COPY_TTL_IN``
2260 ^^^^^^^^^^^^^^^^^^^^^^^^^^
2262 Implements ``OFPAT_COPY_TTL_IN`` ("copy TTL "inwards" -- from outermost to
2263 next-to-outermost") as defined by the `OpenFlow Switch Specification`_.
2265 .. _table_rte_flow_action_of_copy_ttl_in:
2267 .. table:: OF_COPY_TTL_IN
2275 Action: ``OF_POP_VLAN``
2276 ^^^^^^^^^^^^^^^^^^^^^^^
2278 Implements ``OFPAT_POP_VLAN`` ("pop the outer VLAN tag") as defined
2279 by the `OpenFlow Switch Specification`_.
2281 .. _table_rte_flow_action_of_pop_vlan:
2283 .. table:: OF_POP_VLAN
2291 Action: ``OF_PUSH_VLAN``
2292 ^^^^^^^^^^^^^^^^^^^^^^^^
2294 Implements ``OFPAT_PUSH_VLAN`` ("push a new VLAN tag") as defined by the
2295 `OpenFlow Switch Specification`_.
2297 .. _table_rte_flow_action_of_push_vlan:
2299 .. table:: OF_PUSH_VLAN
2301 +---------------+-----------+
2303 +===============+===========+
2304 | ``ethertype`` | EtherType |
2305 +---------------+-----------+
2307 Action: ``OF_SET_VLAN_VID``
2308 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
2310 Implements ``OFPAT_SET_VLAN_VID`` ("set the 802.1q VLAN id") as defined by
2311 the `OpenFlow Switch Specification`_.
2313 .. _table_rte_flow_action_of_set_vlan_vid:
2315 .. table:: OF_SET_VLAN_VID
2317 +--------------+---------+
2319 +==============+=========+
2320 | ``vlan_vid`` | VLAN id |
2321 +--------------+---------+
2323 Action: ``OF_SET_VLAN_PCP``
2324 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
2326 Implements ``OFPAT_SET_LAN_PCP`` ("set the 802.1q priority") as defined by
2327 the `OpenFlow Switch Specification`_.
2329 .. _table_rte_flow_action_of_set_vlan_pcp:
2331 .. table:: OF_SET_VLAN_PCP
2333 +--------------+---------------+
2335 +==============+===============+
2336 | ``vlan_pcp`` | VLAN priority |
2337 +--------------+---------------+
2339 Action: ``OF_POP_MPLS``
2340 ^^^^^^^^^^^^^^^^^^^^^^^
2342 Implements ``OFPAT_POP_MPLS`` ("pop the outer MPLS tag") as defined by the
2343 `OpenFlow Switch Specification`_.
2345 .. _table_rte_flow_action_of_pop_mpls:
2347 .. table:: OF_POP_MPLS
2349 +---------------+-----------+
2351 +===============+===========+
2352 | ``ethertype`` | EtherType |
2353 +---------------+-----------+
2355 Action: ``OF_PUSH_MPLS``
2356 ^^^^^^^^^^^^^^^^^^^^^^^^
2358 Implements ``OFPAT_PUSH_MPLS`` ("push a new MPLS tag") as defined by the
2359 `OpenFlow Switch Specification`_.
2361 .. _table_rte_flow_action_of_push_mpls:
2363 .. table:: OF_PUSH_MPLS
2365 +---------------+-----------+
2367 +===============+===========+
2368 | ``ethertype`` | EtherType |
2369 +---------------+-----------+
2371 Action: ``VXLAN_ENCAP``
2372 ^^^^^^^^^^^^^^^^^^^^^^^
2374 Performs a VXLAN encapsulation action by encapsulating the matched flow in the
2375 VXLAN tunnel as defined in the``rte_flow_action_vxlan_encap`` flow items
2378 This action modifies the payload of matched flows. The flow definition specified
2379 in the ``rte_flow_action_tunnel_encap`` action structure must define a valid
2380 VLXAN network overlay which conforms with RFC 7348 (Virtual eXtensible Local
2381 Area Network (VXLAN): A Framework for Overlaying Virtualized Layer 2 Networks
2382 over Layer 3 Networks). The pattern must be terminated with the
2383 RTE_FLOW_ITEM_TYPE_END item type.
2385 .. _table_rte_flow_action_vxlan_encap:
2387 .. table:: VXLAN_ENCAP
2389 +----------------+-------------------------------------+
2391 +================+=====================================+
2392 | ``definition`` | Tunnel end-point overlay definition |
2393 +----------------+-------------------------------------+
2395 .. _table_rte_flow_action_vxlan_encap_example:
2397 .. table:: IPv4 VxLAN flow pattern example.
2399 +-------+----------+
2401 +=======+==========+
2403 +-------+----------+
2405 +-------+----------+
2407 +-------+----------+
2409 +-------+----------+
2411 +-------+----------+
2413 Action: ``VXLAN_DECAP``
2414 ^^^^^^^^^^^^^^^^^^^^^^^
2416 Performs a decapsulation action by stripping all headers of the VXLAN tunnel
2417 network overlay from the matched flow.
2419 The flow items pattern defined for the flow rule with which a ``VXLAN_DECAP``
2420 action is specified, must define a valid VXLAN tunnel as per RFC7348. If the
2421 flow pattern does not specify a valid VXLAN tunnel then a
2422 RTE_FLOW_ERROR_TYPE_ACTION error should be returned.
2424 This action modifies the payload of matched flows.
2426 Action: ``NVGRE_ENCAP``
2427 ^^^^^^^^^^^^^^^^^^^^^^^
2429 Performs a NVGRE encapsulation action by encapsulating the matched flow in the
2430 NVGRE tunnel as defined in the``rte_flow_action_tunnel_encap`` flow item
2433 This action modifies the payload of matched flows. The flow definition specified
2434 in the ``rte_flow_action_tunnel_encap`` action structure must defined a valid
2435 NVGRE network overlay which conforms with RFC 7637 (NVGRE: Network
2436 Virtualization Using Generic Routing Encapsulation). The pattern must be
2437 terminated with the RTE_FLOW_ITEM_TYPE_END item type.
2439 .. _table_rte_flow_action_nvgre_encap:
2441 .. table:: NVGRE_ENCAP
2443 +----------------+-------------------------------------+
2445 +================+=====================================+
2446 | ``definition`` | NVGRE end-point overlay definition |
2447 +----------------+-------------------------------------+
2449 .. _table_rte_flow_action_nvgre_encap_example:
2451 .. table:: IPv4 NVGRE flow pattern example.
2453 +-------+----------+
2455 +=======+==========+
2457 +-------+----------+
2459 +-------+----------+
2461 +-------+----------+
2463 +-------+----------+
2465 Action: ``NVGRE_DECAP``
2466 ^^^^^^^^^^^^^^^^^^^^^^^
2468 Performs a decapsulation action by stripping all headers of the NVGRE tunnel
2469 network overlay from the matched flow.
2471 The flow items pattern defined for the flow rule with which a ``NVGRE_DECAP``
2472 action is specified, must define a valid NVGRE tunnel as per RFC7637. If the
2473 flow pattern does not specify a valid NVGRE tunnel then a
2474 RTE_FLOW_ERROR_TYPE_ACTION error should be returned.
2476 This action modifies the payload of matched flows.
2478 Action: ``RAW_ENCAP``
2479 ^^^^^^^^^^^^^^^^^^^^^
2481 Adds outer header whose template is provided in its data buffer,
2482 as defined in the ``rte_flow_action_raw_encap`` definition.
2484 This action modifies the payload of matched flows. The data supplied must
2485 be a valid header, either holding layer 2 data in case of adding layer 2 after
2486 decap layer 3 tunnel (for example MPLSoGRE) or complete tunnel definition
2487 starting from layer 2 and moving to the tunnel item itself. When applied to
2488 the original packet the resulting packet must be a valid packet.
2490 .. _table_rte_flow_action_raw_encap:
2492 .. table:: RAW_ENCAP
2494 +----------------+----------------------------------------+
2496 +================+========================================+
2497 | ``data`` | Encapsulation data |
2498 +----------------+----------------------------------------+
2499 | ``preserve`` | Bit-mask of data to preserve on output |
2500 +----------------+----------------------------------------+
2501 | ``size`` | Size of data and preserve |
2502 +----------------+----------------------------------------+
2504 Action: ``RAW_DECAP``
2505 ^^^^^^^^^^^^^^^^^^^^^^^
2507 Remove outer header whose template is provided in its data buffer,
2508 as defined in the ``rte_flow_action_raw_decap``
2510 This action modifies the payload of matched flows. The data supplied must
2511 be a valid header, either holding layer 2 data in case of removing layer 2
2512 before encapsulation of layer 3 tunnel (for example MPLSoGRE) or complete
2513 tunnel definition starting from layer 2 and moving to the tunnel item itself.
2514 When applied to the original packet the resulting packet must be a
2517 .. _table_rte_flow_action_raw_decap:
2519 .. table:: RAW_DECAP
2521 +----------------+----------------------------------------+
2523 +================+========================================+
2524 | ``data`` | Decapsulation data |
2525 +----------------+----------------------------------------+
2526 | ``size`` | Size of data |
2527 +----------------+----------------------------------------+
2529 Action: ``SET_IPV4_SRC``
2530 ^^^^^^^^^^^^^^^^^^^^^^^^
2532 Set a new IPv4 source address in the outermost IPv4 header.
2534 It must be used with a valid RTE_FLOW_ITEM_TYPE_IPV4 flow pattern item.
2535 Otherwise, RTE_FLOW_ERROR_TYPE_ACTION error will be returned.
2537 .. _table_rte_flow_action_set_ipv4_src:
2539 .. table:: SET_IPV4_SRC
2541 +-----------------------------------------+
2543 +===============+=========================+
2544 | ``ipv4_addr`` | new IPv4 source address |
2545 +---------------+-------------------------+
2547 Action: ``SET_IPV4_DST``
2548 ^^^^^^^^^^^^^^^^^^^^^^^^
2550 Set a new IPv4 destination address in the outermost IPv4 header.
2552 It must be used with a valid RTE_FLOW_ITEM_TYPE_IPV4 flow pattern item.
2553 Otherwise, RTE_FLOW_ERROR_TYPE_ACTION error will be returned.
2555 .. _table_rte_flow_action_set_ipv4_dst:
2557 .. table:: SET_IPV4_DST
2559 +---------------+------------------------------+
2561 +===============+==============================+
2562 | ``ipv4_addr`` | new IPv4 destination address |
2563 +---------------+------------------------------+
2565 Action: ``SET_IPV6_SRC``
2566 ^^^^^^^^^^^^^^^^^^^^^^^^
2568 Set a new IPv6 source address in the outermost IPv6 header.
2570 It must be used with a valid RTE_FLOW_ITEM_TYPE_IPV6 flow pattern item.
2571 Otherwise, RTE_FLOW_ERROR_TYPE_ACTION error will be returned.
2573 .. _table_rte_flow_action_set_ipv6_src:
2575 .. table:: SET_IPV6_SRC
2577 +---------------+-------------------------+
2579 +===============+=========================+
2580 | ``ipv6_addr`` | new IPv6 source address |
2581 +---------------+-------------------------+
2583 Action: ``SET_IPV6_DST``
2584 ^^^^^^^^^^^^^^^^^^^^^^^^
2586 Set a new IPv6 destination address in the outermost IPv6 header.
2588 It must be used with a valid RTE_FLOW_ITEM_TYPE_IPV6 flow pattern item.
2589 Otherwise, RTE_FLOW_ERROR_TYPE_ACTION error will be returned.
2591 .. _table_rte_flow_action_set_ipv6_dst:
2593 .. table:: SET_IPV6_DST
2595 +---------------+------------------------------+
2597 +===============+==============================+
2598 | ``ipv6_addr`` | new IPv6 destination address |
2599 +---------------+------------------------------+
2601 Action: ``SET_TP_SRC``
2602 ^^^^^^^^^^^^^^^^^^^^^^^^^
2604 Set a new source port number in the outermost TCP/UDP header.
2606 It must be used with a valid RTE_FLOW_ITEM_TYPE_TCP or RTE_FLOW_ITEM_TYPE_UDP
2607 flow pattern item. Otherwise, RTE_FLOW_ERROR_TYPE_ACTION error will be returned.
2609 .. _table_rte_flow_action_set_tp_src:
2611 .. table:: SET_TP_SRC
2613 +----------+-------------------------+
2615 +==========+=========================+
2616 | ``port`` | new TCP/UDP source port |
2617 +---------------+--------------------+
2619 Action: ``SET_TP_DST``
2620 ^^^^^^^^^^^^^^^^^^^^^^^^^
2622 Set a new destination port number in the outermost TCP/UDP header.
2624 It must be used with a valid RTE_FLOW_ITEM_TYPE_TCP or RTE_FLOW_ITEM_TYPE_UDP
2625 flow pattern item. Otherwise, RTE_FLOW_ERROR_TYPE_ACTION error will be returned.
2627 .. _table_rte_flow_action_set_tp_dst:
2629 .. table:: SET_TP_DST
2631 +----------+------------------------------+
2633 +==========+==============================+
2634 | ``port`` | new TCP/UDP destination port |
2635 +---------------+-------------------------+
2637 Action: ``MAC_SWAP``
2638 ^^^^^^^^^^^^^^^^^^^^^^^^^
2640 Swap the source and destination MAC addresses in the outermost Ethernet
2643 It must be used with a valid RTE_FLOW_ITEM_TYPE_ETH flow pattern item.
2644 Otherwise, RTE_FLOW_ERROR_TYPE_ACTION error will be returned.
2646 .. _table_rte_flow_action_mac_swap:
2661 If there is no valid RTE_FLOW_ITEM_TYPE_IPV4 or RTE_FLOW_ITEM_TYPE_IPV6
2662 in pattern, Some PMDs will reject rule because behavior will be undefined.
2664 .. _table_rte_flow_action_dec_ttl:
2677 Assigns a new TTL value.
2679 If there is no valid RTE_FLOW_ITEM_TYPE_IPV4 or RTE_FLOW_ITEM_TYPE_IPV6
2680 in pattern, Some PMDs will reject rule because behavior will be undefined.
2682 .. _table_rte_flow_action_set_ttl:
2686 +---------------+--------------------+
2688 +===============+====================+
2689 | ``ttl_value`` | new TTL value |
2690 +---------------+--------------------+
2692 Action: ``SET_MAC_SRC``
2693 ^^^^^^^^^^^^^^^^^^^^^^^
2695 Set source MAC address.
2697 It must be used with a valid RTE_FLOW_ITEM_TYPE_ETH flow pattern item.
2698 Otherwise, RTE_FLOW_ERROR_TYPE_ACTION error will be returned.
2700 .. _table_rte_flow_action_set_mac_src:
2702 .. table:: SET_MAC_SRC
2704 +--------------+---------------+
2706 +==============+===============+
2707 | ``mac_addr`` | MAC address |
2708 +--------------+---------------+
2710 Action: ``SET_MAC_DST``
2711 ^^^^^^^^^^^^^^^^^^^^^^^
2713 Set destination MAC address.
2715 It must be used with a valid RTE_FLOW_ITEM_TYPE_ETH flow pattern item.
2716 Otherwise, RTE_FLOW_ERROR_TYPE_ACTION error will be returned.
2718 .. _table_rte_flow_action_set_mac_dst:
2720 .. table:: SET_MAC_DST
2722 +--------------+---------------+
2724 +==============+===============+
2725 | ``mac_addr`` | MAC address |
2726 +--------------+---------------+
2728 Action: ``INC_TCP_SEQ``
2729 ^^^^^^^^^^^^^^^^^^^^^^^
2731 Increase sequence number in the outermost TCP header.
2732 Value to increase TCP sequence number by is a big-endian 32 bit integer.
2734 Using this action on non-matching traffic will result in undefined behavior.
2736 Action: ``DEC_TCP_SEQ``
2737 ^^^^^^^^^^^^^^^^^^^^^^^
2739 Decrease sequence number in the outermost TCP header.
2740 Value to decrease TCP sequence number by is a big-endian 32 bit integer.
2742 Using this action on non-matching traffic will result in undefined behavior.
2744 Action: ``INC_TCP_ACK``
2745 ^^^^^^^^^^^^^^^^^^^^^^^
2747 Increase acknowledgment number in the outermost TCP header.
2748 Value to increase TCP acknowledgment number by is a big-endian 32 bit integer.
2750 Using this action on non-matching traffic will result in undefined behavior.
2752 Action: ``DEC_TCP_ACK``
2753 ^^^^^^^^^^^^^^^^^^^^^^^
2755 Decrease acknowledgment number in the outermost TCP header.
2756 Value to decrease TCP acknowledgment number by is a big-endian 32 bit integer.
2758 Using this action on non-matching traffic will result in undefined behavior.
2765 Tag is a transient data used during flow matching. This is not delivered to
2766 application. Multiple tags are supported by specifying index.
2768 .. _table_rte_flow_action_set_tag:
2772 +-----------+----------------------------+
2774 +===========+============================+
2775 | ``data`` | 32 bit tag value |
2776 +-----------+----------------------------+
2777 | ``mask`` | bit-mask applies to "data" |
2778 +-----------+----------------------------+
2779 | ``index`` | index of tag to set |
2780 +-----------+----------------------------+
2782 Action: ``SET_META``
2783 ^^^^^^^^^^^^^^^^^^^^^^^
2785 Set metadata. Item ``META`` matches metadata.
2787 Metadata set by mbuf metadata field with PKT_TX_DYNF_METADATA flag on egress
2788 will be overridden by this action. On ingress, the metadata will be carried by
2789 ``metadata`` dynamic field of ``rte_mbuf`` which can be accessed by
2790 ``RTE_FLOW_DYNF_METADATA()``. PKT_RX_DYNF_METADATA flag will be set along
2793 The mbuf dynamic field must be registered by calling
2794 ``rte_flow_dynf_metadata_register()`` prior to use ``SET_META`` action.
2796 Altering partial bits is supported with ``mask``. For bits which have never been
2797 set, unpredictable value will be seen depending on driver implementation. For
2798 loopback/hairpin packet, metadata set on Rx/Tx may or may not be propagated to
2799 the other path depending on HW capability.
2801 In hairpin case with Tx explicit flow mode, metadata could (not mandatory) be
2802 used to connect the Rx and Tx flows if it can be propagated from Rx to Tx path.
2804 .. _table_rte_flow_action_set_meta:
2808 +----------+----------------------------+
2810 +==========+============================+
2811 | ``data`` | 32 bit metadata value |
2812 +----------+----------------------------+
2813 | ``mask`` | bit-mask applies to "data" |
2814 +----------+----------------------------+
2816 Action: ``SET_IPV4_DSCP``
2817 ^^^^^^^^^^^^^^^^^^^^^^^^^
2821 Modify DSCP in IPv4 header.
2823 It must be used with RTE_FLOW_ITEM_TYPE_IPV4 in pattern.
2824 Otherwise, RTE_FLOW_ERROR_TYPE_ACTION error will be returned.
2826 .. _table_rte_flow_action_set_ipv4_dscp:
2828 .. table:: SET_IPV4_DSCP
2830 +-----------+---------------------------------+
2832 +===========+=================================+
2833 | ``dscp`` | DSCP in low 6 bits, rest ignore |
2834 +-----------+---------------------------------+
2836 Action: ``SET_IPV6_DSCP``
2837 ^^^^^^^^^^^^^^^^^^^^^^^^^
2841 Modify DSCP in IPv6 header.
2843 It must be used with RTE_FLOW_ITEM_TYPE_IPV6 in pattern.
2844 Otherwise, RTE_FLOW_ERROR_TYPE_ACTION error will be returned.
2846 .. _table_rte_flow_action_set_ipv6_dscp:
2848 .. table:: SET_IPV6_DSCP
2850 +-----------+---------------------------------+
2852 +===========+=================================+
2853 | ``dscp`` | DSCP in low 6 bits, rest ignore |
2854 +-----------+---------------------------------+
2859 Set ageing timeout configuration to a flow.
2861 Event RTE_ETH_EVENT_FLOW_AGED will be reported if
2862 timeout passed without any matching on the flow.
2864 .. _table_rte_flow_action_age:
2868 +--------------+---------------------------------+
2870 +==============+=================================+
2871 | ``timeout`` | 24 bits timeout value |
2872 +--------------+---------------------------------+
2873 | ``reserved`` | 8 bits reserved, must be zero |
2874 +--------------+---------------------------------+
2875 | ``context`` | user input flow context |
2876 +--------------+---------------------------------+
2878 Query structure to retrieve ageing status information of a
2879 shared AGE action, or a flow rule using the AGE action:
2881 .. _table_rte_flow_query_age:
2883 .. table:: AGE query
2885 +------------------------------+-----+----------------------------------------+
2886 | Field | I/O | Value |
2887 +==============================+=====+========================================+
2888 | ``aged`` | out | Aging timeout expired |
2889 +------------------------------+-----+----------------------------------------+
2890 | ``sec_since_last_hit_valid`` | out | ``sec_since_last_hit`` value is valid |
2891 +------------------------------+-----+----------------------------------------+
2892 | ``sec_since_last_hit`` | out | Seconds since last traffic hit |
2893 +------------------------------+-----+----------------------------------------+
2898 Adds a sample action to a matched flow.
2900 The matching packets will be duplicated with the specified ``ratio`` and
2901 applied with own set of actions with a fate action, the packets sampled
2902 equals is '1/ratio'. All the packets continue to the target destination.
2904 When the ``ratio`` is set to 1 then the packets will be 100% mirrored.
2905 ``actions`` represent the different set of actions for the sampled or mirrored
2906 packets, and must have a fate action.
2908 .. _table_rte_flow_action_sample:
2912 +--------------+---------------------------------+
2914 +==============+=================================+
2915 | ``ratio`` | 32 bits sample ratio value |
2916 +--------------+---------------------------------+
2917 | ``actions`` | sub-action list for sampling |
2918 +--------------+---------------------------------+
2920 Action: ``INDIRECT``
2921 ^^^^^^^^^^^^^^^^^^^^
2923 Flow utilize indirect action by handle as returned from
2924 ``rte_flow_action_handle_create()``.
2926 The behaviour of the indirect action defined by ``action`` argument of type
2927 ``struct rte_flow_action`` passed to ``rte_flow_action_handle_create()``.
2929 The indirect action can be used by a single flow or shared among multiple flows.
2930 The indirect action can be in-place updated by ``rte_flow_action_handle_update()``
2931 without destroying flow and creating flow again. The fields that could be
2932 updated depend on the type of the ``action`` and different for every type.
2934 The indirect action specified data (e.g. counter) can be queried by
2935 ``rte_flow_action_handle_query()``.
2937 .. _table_rte_flow_action_handle:
2947 Action: ``MODIFY_FIELD``
2948 ^^^^^^^^^^^^^^^^^^^^^^^^
2950 Modify ``dst`` field according to ``op`` selected (set, addition,
2951 subtraction) with ``width`` bits of data from ``src`` field.
2953 Any arbitrary header field (as well as mark, metadata or tag values)
2954 can be used as both source and destination fields as set by ``field``.
2955 The immediate value ``RTE_FLOW_FIELD_VALUE`` (or a pointer to it
2956 ``RTE_FLOW_FIELD_POINTER``) is allowed as a source only.
2957 ``RTE_FLOW_FIELD_START`` is used to point to the beginning of a packet.
2958 See ``enum rte_flow_field_id`` for the list of supported fields.
2960 ``op`` selects the operation to perform on a destination field.
2961 - ``set`` copies the data from ``src`` field to ``dst`` field.
2962 - ``add`` adds together ``dst`` and ``src`` and stores the result into ``dst``.
2963 - ``sub`` subtracts ``src`` from ``dst`` and stores the result into ``dst``
2965 ``width`` defines a number of bits to use from ``src`` field.
2967 ``level`` is used to access any packet field on any encapsulation level
2968 as well as any tag element in the tag array.
2969 - ``0`` means the default behaviour. Depending on the packet type, it can
2970 mean outermost, innermost or anything in between.
2971 - ``1`` requests access to the outermost packet encapsulation level.
2972 - ``2`` and subsequent values requests access to the specified packet
2973 encapsulation level, from outermost to innermost (lower to higher values).
2974 For the tag array (in case of multiple tags are supported and present)
2975 ``level`` translates directly into the array index.
2977 ``offset`` specifies the number of bits to skip from a field's start.
2978 That allows performing a partial copy of the needed part or to divide a big
2979 packet field into multiple smaller fields. Alternatively, ``offset`` allows
2980 going past the specified packet field boundary to copy a field to an
2981 arbitrary place in a packet, essentially providing a way to copy any part of
2982 a packet to any other part of it.
2984 ``value`` sets an immediate value to be used as a source or points to a
2985 location of the value in memory. It is used instead of ``level`` and ``offset``
2986 for ``RTE_FLOW_FIELD_VALUE`` and ``RTE_FLOW_FIELD_POINTER`` respectively.
2987 The data in memory should be presented exactly in the same byte order and
2988 length as in the relevant flow item, i.e. data for field with type
2989 ``RTE_FLOW_FIELD_MAC_DST`` should follow the conventions of ``dst`` field
2990 in ``rte_flow_item_eth`` structure, with type ``RTE_FLOW_FIELD_IPV6_SRC`` -
2991 ``rte_flow_item_ipv6`` conventions, and so on. If the field size is larger than
2992 16 bytes the pattern can be provided as pointer only.
2994 The bitfield extracted from the memory being applied as second operation
2995 parameter is defined by action width and by the destination field offset.
2996 Application should provide the data in immediate value memory (either as
2997 buffer or by pointer) exactly as item field without any applied explicit offset,
2998 and destination packet field (with specified width and bit offset) will be
2999 replaced by immediate source bits from the same bit offset. For example,
3000 to replace the third byte of MAC address with value 0x85, application should
3001 specify destination width as 8, destination offset as 16, and provide immediate
3002 value as sequence of bytes {xxx, xxx, 0x85, xxx, xxx, xxx}.
3004 .. _table_rte_flow_action_modify_field:
3006 .. table:: MODIFY_FIELD
3008 +---------------+-------------------------+
3010 +===============+=========================+
3011 | ``op`` | operation to perform |
3012 +---------------+-------------------------+
3013 | ``dst`` | destination field |
3014 +---------------+-------------------------+
3015 | ``src`` | source field |
3016 +---------------+-------------------------+
3017 | ``width`` | number of bits to use |
3018 +---------------+-------------------------+
3020 .. _table_rte_flow_action_modify_data:
3022 .. table:: destination/source field definition
3024 +---------------+----------------------------------------------------------+
3026 +===============+==========================================================+
3027 | ``field`` | ID: packet field, mark, meta, tag, immediate, pointer |
3028 +---------------+----------------------------------------------------------+
3029 | ``level`` | encapsulation level of a packet field or tag array index |
3030 +---------------+----------------------------------------------------------+
3031 | ``offset`` | number of bits to skip at the beginning |
3032 +---------------+----------------------------------------------------------+
3033 | ``value`` | immediate value buffer (source field only, not |
3034 | | applicable to destination) for RTE_FLOW_FIELD_VALUE |
3036 +---------------+----------------------------------------------------------+
3037 | ``pvalue`` | pointer to immediate value data (source field only, not |
3038 | | applicable to destination) for RTE_FLOW_FIELD_POINTER |
3040 +---------------+----------------------------------------------------------+
3042 Action: ``CONNTRACK``
3043 ^^^^^^^^^^^^^^^^^^^^^
3045 Create a conntrack (connection tracking) context with the provided information.
3047 In stateful session like TCP, the conntrack action provides the ability to
3048 examine every packet of this connection and associate the state to every
3049 packet. It will help to realize the stateful offload of connections with little
3050 software participation. For example, the packets with invalid state may be
3051 handled by the software. The control packets could be handled in the hardware.
3052 The software just need to query the state of a connection when needed, and then
3053 decide how to handle the flow rules and conntrack context.
3055 A conntrack context should be created via ``rte_flow_action_handle_create()``
3056 before using. Then the handle with ``INDIRECT`` type is used for a flow rule
3057 creation. If a flow rule with an opposite direction needs to be created, the
3058 ``rte_flow_action_handle_update()`` should be used to modify the direction.
3060 Not all the fields of the ``struct rte_flow_action_conntrack`` will be used
3061 for a conntrack context creating, depending on the HW, and they should be
3062 in host byte order. PMD should convert them into network byte order when
3065 The ``struct rte_flow_modify_conntrack`` should be used for an updating.
3067 The current conntrack context information could be queried via the
3068 ``rte_flow_action_handle_query()`` interface.
3070 .. _table_rte_flow_action_conntrack:
3072 .. table:: CONNTRACK
3074 +--------------------------+-------------------------------------------------------------+
3076 +==========================+=============================================================+
3077 | ``peer_port`` | peer port number |
3078 +--------------------------+-------------------------------------------------------------+
3079 | ``is_original_dir`` | direction of this connection for creating flow rule |
3080 +--------------------------+-------------------------------------------------------------+
3081 | ``enable`` | enable the conntrack context |
3082 +--------------------------+-------------------------------------------------------------+
3083 | ``live_connection`` | one ack was seen for this connection |
3084 +--------------------------+-------------------------------------------------------------+
3085 | ``selective_ack`` | SACK enabled |
3086 +--------------------------+-------------------------------------------------------------+
3087 | ``challenge_ack_passed`` | a challenge ack has passed |
3088 +--------------------------+-------------------------------------------------------------+
3089 | ``last_direction`` | direction of the last passed packet |
3090 +--------------------------+-------------------------------------------------------------+
3091 | ``liberal_mode`` | only report state change |
3092 +--------------------------+-------------------------------------------------------------+
3093 | ``state`` | current state |
3094 +--------------------------+-------------------------------------------------------------+
3095 | ``max_ack_window`` | maximal window scaling factor |
3096 +--------------------------+-------------------------------------------------------------+
3097 | ``retransmission_limit`` | maximal retransmission times |
3098 +--------------------------+-------------------------------------------------------------+
3099 | ``original_dir`` | TCP parameters of the original direction |
3100 +--------------------------+-------------------------------------------------------------+
3101 | ``reply_dir`` | TCP parameters of the reply direction |
3102 +--------------------------+-------------------------------------------------------------+
3103 | ``last_window`` | window size of the last passed packet |
3104 +--------------------------+-------------------------------------------------------------+
3105 | ``last_seq`` | sequence number of the last passed packet |
3106 +--------------------------+-------------------------------------------------------------+
3107 | ``last_ack`` | acknowledgment number the last passed packet |
3108 +--------------------------+-------------------------------------------------------------+
3109 | ``last_end`` | sum of ack number and length of the last passed packet |
3110 +--------------------------+-------------------------------------------------------------+
3112 .. _table_rte_flow_tcp_dir_param:
3114 .. table:: configuration parameters for each direction
3116 +---------------------+---------------------------------------------------------+
3118 +=====================+=========================================================+
3119 | ``scale`` | TCP window scaling factor |
3120 +---------------------+---------------------------------------------------------+
3121 | ``close_initiated`` | FIN sent from this direction |
3122 +---------------------+---------------------------------------------------------+
3123 | ``last_ack_seen`` | an ACK packet received |
3124 +---------------------+---------------------------------------------------------+
3125 | ``data_unacked`` | unacknowledged data for packets from this direction |
3126 +---------------------+---------------------------------------------------------+
3127 | ``sent_end`` | max{seq + len} seen in sent packets |
3128 +---------------------+---------------------------------------------------------+
3129 | ``reply_end`` | max{sack + max{win, 1}} seen in reply packets |
3130 +---------------------+---------------------------------------------------------+
3131 | ``max_win`` | max{max{win, 1}} + {sack - ack} seen in sent packets |
3132 +---------------------+---------------------------------------------------------+
3133 | ``max_ack`` | max{ack} + seen in sent packets |
3134 +---------------------+---------------------------------------------------------+
3136 .. _table_rte_flow_modify_conntrack:
3138 .. table:: update a conntrack context
3140 +----------------+-------------------------------------------------+
3142 +================+=================================================+
3143 | ``new_ct`` | new conntrack information |
3144 +----------------+-------------------------------------------------+
3145 | ``direction`` | direction will be updated |
3146 +----------------+-------------------------------------------------+
3147 | ``state`` | other fields except direction will be updated |
3148 +----------------+-------------------------------------------------+
3149 | ``reserved`` | reserved bits |
3150 +----------------+-------------------------------------------------+
3152 Action: ``METER_COLOR``
3153 ^^^^^^^^^^^^^^^^^^^^^^^
3155 Color the packet to reflect the meter color result.
3157 The meter action must be configured before meter color action.
3158 Meter color action is set to a color to reflect the meter color result.
3159 Set the meter color in the mbuf to the selected color.
3160 The meter color action output color is the output color of the packet,
3161 which is set in the packet meta-data (i.e. struct ``rte_mbuf::sched::color``)
3163 .. _table_rte_flow_action_meter_color:
3165 .. table:: METER_COLOR
3167 +-----------------+--------------+
3169 +=================+==============+
3170 | ``meter_color`` | Packet color |
3171 +-----------------+--------------+
3173 Action: ``PORT_REPRESENTOR``
3174 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3176 At embedded switch level, send matching traffic to the given ethdev.
3178 Term **ethdev** and the concept of **port representor** are synonymous.
3179 The **represented port** is an *entity* plugged to the embedded switch
3180 at the opposite end of the "wire" leading to the ethdev.
3184 .--------------------.
3185 | PORT_REPRESENTOR | Ethdev (Application Port Referred to by its ID)
3186 '--------------------'
3196 .----------. .--------------------.
3197 | Switch | <== | Matching Traffic |
3198 '----------' '--------------------'
3208 .--------------------.
3209 | REPRESENTED_PORT | Net / Guest / Another Ethdev (Same Application)
3210 '--------------------'
3213 - Requires `Attribute: Transfer`_.
3215 .. _table_rte_flow_action_ethdev:
3217 .. table:: ``struct rte_flow_action_ethdev``
3219 +-------------+----------------+
3221 +=============+================+
3222 | ``port_id`` | ethdev port ID |
3223 +-------------+----------------+
3225 See also `Item: PORT_REPRESENTOR`_.
3227 Action: ``REPRESENTED_PORT``
3228 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3230 At embedded switch level, send matching traffic to
3231 the entity represented by the given ethdev.
3233 Term **ethdev** and the concept of **port representor** are synonymous.
3234 The **represented port** is an *entity* plugged to the embedded switch
3235 at the opposite end of the "wire" leading to the ethdev.
3239 .--------------------.
3240 | PORT_REPRESENTOR | Ethdev (Application Port Referred to by its ID)
3241 '--------------------'
3251 .----------. .--------------------.
3252 | Switch | <== | Matching Traffic |
3253 '----------' '--------------------'
3263 .--------------------.
3264 | REPRESENTED_PORT | Net / Guest / Another Ethdev (Same Application)
3265 '--------------------'
3268 - Requires `Attribute: Transfer`_.
3270 This action is meant to use the same structure as `Action: PORT_REPRESENTOR`_.
3272 See also `Item: REPRESENTED_PORT`_.
3277 All specified pattern items (``enum rte_flow_item_type``) and actions
3278 (``enum rte_flow_action_type``) use positive identifiers.
3280 The negative space is reserved for dynamic types generated by PMDs during
3281 run-time. PMDs may encounter them as a result but must not accept negative
3282 identifiers they are not aware of.
3284 A method to generate them remains to be defined.
3286 Application may use PMD dynamic items or actions in flow rules. In that case
3287 size of configuration object in dynamic element must be a pointer size.
3292 A rather simple API with few functions is provided to fully manage flow
3295 Each created flow rule is associated with an opaque, PMD-specific handle
3296 pointer. The application is responsible for keeping it until the rule is
3299 Flows rules are represented by ``struct rte_flow`` objects.
3304 Given that expressing a definite set of device capabilities is not
3305 practical, a dedicated function is provided to check if a flow rule is
3306 supported and can be created.
3311 rte_flow_validate(uint16_t port_id,
3312 const struct rte_flow_attr *attr,
3313 const struct rte_flow_item pattern[],
3314 const struct rte_flow_action actions[],
3315 struct rte_flow_error *error);
3317 The flow rule is validated for correctness and whether it could be accepted
3318 by the device given sufficient resources. The rule is checked against the
3319 current device mode and queue configuration. The flow rule may also
3320 optionally be validated against existing flow rules and device resources.
3321 This function has no effect on the target device.
3323 The returned value is guaranteed to remain valid only as long as no
3324 successful calls to ``rte_flow_create()`` or ``rte_flow_destroy()`` are made
3325 in the meantime and no device parameter affecting flow rules in any way are
3326 modified, due to possible collisions or resource limitations (although in
3327 such cases ``EINVAL`` should not be returned).
3331 - ``port_id``: port identifier of Ethernet device.
3332 - ``attr``: flow rule attributes.
3333 - ``pattern``: pattern specification (list terminated by the END pattern
3335 - ``actions``: associated actions (list terminated by the END action).
3336 - ``error``: perform verbose error reporting if not NULL. PMDs initialize
3337 this structure in case of error only.
3341 - 0 if flow rule is valid and can be created. A negative errno value
3342 otherwise (``rte_errno`` is also set), the following errors are defined.
3343 - ``-ENOSYS``: underlying device does not support this functionality.
3344 - ``-EINVAL``: unknown or invalid rule specification.
3345 - ``-ENOTSUP``: valid but unsupported rule specification (e.g. partial
3346 bit-masks are unsupported).
3347 - ``EEXIST``: collision with an existing rule. Only returned if device
3348 supports flow rule collision checking and there was a flow rule
3349 collision. Not receiving this return code is no guarantee that creating
3350 the rule will not fail due to a collision.
3351 - ``ENOMEM``: not enough memory to execute the function, or if the device
3352 supports resource validation, resource limitation on the device.
3353 - ``-EBUSY``: action cannot be performed due to busy device resources, may
3354 succeed if the affected queues or even the entire port are in a stopped
3355 state (see ``rte_eth_dev_rx_queue_stop()`` and ``rte_eth_dev_stop()``).
3360 Creating a flow rule is similar to validating one, except the rule is
3361 actually created and a handle returned.
3366 rte_flow_create(uint16_t port_id,
3367 const struct rte_flow_attr *attr,
3368 const struct rte_flow_item pattern[],
3369 const struct rte_flow_action *actions[],
3370 struct rte_flow_error *error);
3374 - ``port_id``: port identifier of Ethernet device.
3375 - ``attr``: flow rule attributes.
3376 - ``pattern``: pattern specification (list terminated by the END pattern
3378 - ``actions``: associated actions (list terminated by the END action).
3379 - ``error``: perform verbose error reporting if not NULL. PMDs initialize
3380 this structure in case of error only.
3384 A valid handle in case of success, NULL otherwise and ``rte_errno`` is set
3385 to the positive version of one of the error codes defined for
3386 ``rte_flow_validate()``.
3391 Flow rules destruction is not automatic, and a queue or a port should not be
3392 released if any are still attached to them. Applications must take care of
3393 performing this step before releasing resources.
3398 rte_flow_destroy(uint16_t port_id,
3399 struct rte_flow *flow,
3400 struct rte_flow_error *error);
3403 Failure to destroy a flow rule handle may occur when other flow rules depend
3404 on it, and destroying it would result in an inconsistent state.
3406 This function is only guaranteed to succeed if handles are destroyed in
3407 reverse order of their creation.
3411 - ``port_id``: port identifier of Ethernet device.
3412 - ``flow``: flow rule handle to destroy.
3413 - ``error``: perform verbose error reporting if not NULL. PMDs initialize
3414 this structure in case of error only.
3418 - 0 on success, a negative errno value otherwise and ``rte_errno`` is set.
3423 Convenience function to destroy all flow rule handles associated with a
3424 port. They are released as with successive calls to ``rte_flow_destroy()``.
3429 rte_flow_flush(uint16_t port_id,
3430 struct rte_flow_error *error);
3432 In the unlikely event of failure, handles are still considered destroyed and
3433 no longer valid but the port must be assumed to be in an inconsistent state.
3437 - ``port_id``: port identifier of Ethernet device.
3438 - ``error``: perform verbose error reporting if not NULL. PMDs initialize
3439 this structure in case of error only.
3443 - 0 on success, a negative errno value otherwise and ``rte_errno`` is set.
3448 Query an existing flow rule.
3450 This function allows retrieving flow-specific data such as counters. Data
3451 is gathered by special actions which must be present in the flow rule
3457 rte_flow_query(uint16_t port_id,
3458 struct rte_flow *flow,
3459 const struct rte_flow_action *action,
3461 struct rte_flow_error *error);
3465 - ``port_id``: port identifier of Ethernet device.
3466 - ``flow``: flow rule handle to query.
3467 - ``action``: action to query, this must match prototype from flow rule.
3468 - ``data``: pointer to storage for the associated query data type.
3469 - ``error``: perform verbose error reporting if not NULL. PMDs initialize
3470 this structure in case of error only.
3474 - 0 on success, a negative errno value otherwise and ``rte_errno`` is set.
3476 .. _flow_isolated_mode:
3481 The general expectation for ingress traffic is that flow rules process it
3482 first; the remaining unmatched or pass-through traffic usually ends up in a
3483 queue (with or without RSS, locally or in some sub-device instance)
3484 depending on the global configuration settings of a port.
3486 While fine from a compatibility standpoint, this approach makes drivers more
3487 complex as they have to check for possible side effects outside of this API
3488 when creating or destroying flow rules. It results in a more limited set of
3489 available rule types due to the way device resources are assigned (e.g. no
3490 support for the RSS action even on capable hardware).
3492 Given that nonspecific traffic can be handled by flow rules as well,
3493 isolated mode is a means for applications to tell a driver that ingress on
3494 the underlying port must be injected from the defined flow rules only; that
3495 no default traffic is expected outside those rules.
3497 This has the following benefits:
3499 - Applications get finer-grained control over the kind of traffic they want
3500 to receive (no traffic by default).
3502 - More importantly they control at what point nonspecific traffic is handled
3503 relative to other flow rules, by adjusting priority levels.
3505 - Drivers can assign more hardware resources to flow rules and expand the
3506 set of supported rule types.
3508 Because toggling isolated mode may cause profound changes to the ingress
3509 processing path of a driver, it may not be possible to leave it once
3510 entered. Likewise, existing flow rules or global configuration settings may
3511 prevent a driver from entering isolated mode.
3513 Applications relying on this mode are therefore encouraged to toggle it as
3514 soon as possible after device initialization, ideally before the first call
3515 to ``rte_eth_dev_configure()`` to avoid possible failures due to conflicting
3518 Once effective, the following functionality has no effect on the underlying
3519 port and may return errors such as ``ENOTSUP`` ("not supported"):
3521 - Toggling promiscuous mode.
3522 - Toggling allmulticast mode.
3523 - Configuring MAC addresses.
3524 - Configuring multicast addresses.
3525 - Configuring VLAN filters.
3526 - Configuring global RSS settings.
3531 rte_flow_isolate(uint16_t port_id, int set, struct rte_flow_error *error);
3535 - ``port_id``: port identifier of Ethernet device.
3536 - ``set``: nonzero to enter isolated mode, attempt to leave it otherwise.
3537 - ``error``: perform verbose error reporting if not NULL. PMDs initialize
3538 this structure in case of error only.
3542 - 0 on success, a negative errno value otherwise and ``rte_errno`` is set.
3544 Verbose error reporting
3545 -----------------------
3547 The defined *errno* values may not be accurate enough for users or
3548 application developers who want to investigate issues related to flow rules
3549 management. A dedicated error object is defined for this purpose:
3553 enum rte_flow_error_type {
3554 RTE_FLOW_ERROR_TYPE_NONE, /**< No error. */
3555 RTE_FLOW_ERROR_TYPE_UNSPECIFIED, /**< Cause unspecified. */
3556 RTE_FLOW_ERROR_TYPE_HANDLE, /**< Flow rule (handle). */
3557 RTE_FLOW_ERROR_TYPE_ATTR_GROUP, /**< Group field. */
3558 RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY, /**< Priority field. */
3559 RTE_FLOW_ERROR_TYPE_ATTR_INGRESS, /**< Ingress field. */
3560 RTE_FLOW_ERROR_TYPE_ATTR_EGRESS, /**< Egress field. */
3561 RTE_FLOW_ERROR_TYPE_ATTR, /**< Attributes structure. */
3562 RTE_FLOW_ERROR_TYPE_ITEM_NUM, /**< Pattern length. */
3563 RTE_FLOW_ERROR_TYPE_ITEM, /**< Specific pattern item. */
3564 RTE_FLOW_ERROR_TYPE_ACTION_NUM, /**< Number of actions. */
3565 RTE_FLOW_ERROR_TYPE_ACTION, /**< Specific action. */
3568 struct rte_flow_error {
3569 enum rte_flow_error_type type; /**< Cause field and error types. */
3570 const void *cause; /**< Object responsible for the error. */
3571 const char *message; /**< Human-readable error message. */
3574 Error type ``RTE_FLOW_ERROR_TYPE_NONE`` stands for no error, in which case
3575 remaining fields can be ignored. Other error types describe the type of the
3576 object pointed by ``cause``.
3578 If non-NULL, ``cause`` points to the object responsible for the error. For a
3579 flow rule, this may be a pattern item or an individual action.
3581 If non-NULL, ``message`` provides a human-readable error message.
3583 This object is normally allocated by applications and set by PMDs in case of
3584 error, the message points to a constant string which does not need to be
3585 freed by the application, however its pointer can be considered valid only
3586 as long as its associated DPDK port remains configured. Closing the
3587 underlying device or unloading the PMD invalidates it.
3598 rte_flow_error_set(struct rte_flow_error *error,
3600 enum rte_flow_error_type type,
3602 const char *message);
3604 This function initializes ``error`` (if non-NULL) with the provided
3605 parameters and sets ``rte_errno`` to ``code``. A negative error ``code`` is
3614 rte_flow_conv(enum rte_flow_conv_op op,
3618 struct rte_flow_error *error);
3620 Convert ``src`` to ``dst`` according to operation ``op``. Possible
3623 - Attributes, pattern item or action duplication.
3624 - Duplication of an entire pattern or list of actions.
3625 - Duplication of a complete flow rule description.
3626 - Pattern item or action name retrieval.
3628 Tunneled traffic offload
3629 ~~~~~~~~~~~~~~~~~~~~~~~~
3631 rte_flow API provides the building blocks for vendor-agnostic flow
3632 classification offloads. The rte_flow "patterns" and "actions"
3633 primitives are fine-grained, thus enabling DPDK applications the
3634 flexibility to offload network stacks and complex pipelines.
3635 Applications wishing to offload tunneled traffic are required to use
3636 the rte_flow primitives, such as group, meta, mark, tag, and others to
3637 model their high-level objects. The hardware model design for
3638 high-level software objects is not trivial. Furthermore, an optimal
3639 design is often vendor-specific.
3641 When hardware offloads tunneled traffic in multi-group logic,
3642 partially offloaded packets may arrive to the application after they
3643 were modified in hardware. In this case, the application may need to
3644 restore the original packet headers. Consider the following sequence:
3645 The application decaps a packet in one group and jumps to a second
3646 group where it tries to match on a 5-tuple, that will miss and send
3647 the packet to the application. In this case, the application does not
3648 receive the original packet but a modified one. Also, in this case,
3649 the application cannot match on the outer header fields, such as VXLAN
3652 There are several possible ways to use rte_flow "patterns" and
3653 "actions" to resolve the issues above. For example:
3655 1 Mapping headers to a hardware registers using the
3656 rte_flow_action_mark/rte_flow_action_tag/rte_flow_set_meta objects.
3658 2 Apply the decap only at the last offload stage after all the
3659 "patterns" were matched and the packet will be fully offloaded.
3661 Every approach has its pros and cons and is highly dependent on the
3662 hardware vendor. For example, some hardware may have a limited number
3663 of registers while other hardware could not support inner actions and
3664 must decap before accessing inner headers.
3666 The tunnel offload model resolves these issues. The model goals are:
3668 1 Provide a unified application API to offload tunneled traffic that
3669 is capable to match on outer headers after decap.
3671 2 Allow the application to restore the outer header of partially
3674 The tunnel offload model does not introduce new elements to the
3675 existing RTE flow model and is implemented as a set of helper
3678 For the application to work with the tunnel offload API it
3679 has to adjust flow rules in multi-table tunnel offload in the
3682 1 Remove explicit call to decap action and replace it with PMD actions
3683 obtained from rte_flow_tunnel_decap_and_set() helper.
3685 2 Add PMD items obtained from rte_flow_tunnel_match() helper to all
3686 other rules in the tunnel offload sequence.
3688 The model requirements:
3690 Software application must initialize
3691 rte_tunnel object with tunnel parameters before calling
3692 rte_flow_tunnel_decap_set() & rte_flow_tunnel_match().
3694 PMD actions array obtained in rte_flow_tunnel_decap_set() must be
3695 released by application with rte_flow_action_release() call.
3697 PMD items array obtained with rte_flow_tunnel_match() must be released
3698 by application with rte_flow_item_release() call. Application can
3699 release PMD items and actions after rule was created. However, if the
3700 application needs to create additional rule for the same tunnel it
3701 will need to obtain PMD items again.
3703 Application cannot destroy rte_tunnel object before it releases all
3704 PMD actions & PMD items referencing that tunnel.
3709 - DPDK does not keep track of flow rules definitions or flow rule objects
3710 automatically. Applications may keep track of the former and must keep
3711 track of the latter. PMDs may also do it for internal needs, however this
3712 must not be relied on by applications.
3714 - Flow rules are not maintained between successive port initializations. An
3715 application exiting without releasing them and restarting must re-create
3718 - API operations are synchronous and blocking (``EAGAIN`` cannot be
3721 - Stopping the data path (TX/RX) should not be necessary when managing flow
3722 rules. If this cannot be achieved naturally or with workarounds (such as
3723 temporarily replacing the burst function pointers), an appropriate error
3724 code must be returned (``EBUSY``).
3726 - Applications, not PMDs, are responsible for maintaining flow rules
3727 configuration when closing, stopping or restarting a port or performing other
3728 actions which may affect them.
3729 Applications must assume that after port close, stop or restart all flows
3730 related to that port are not valid, hardware rules are destroyed and relevant
3731 PMD resources are released.
3733 For devices exposing multiple ports sharing global settings affected by flow
3736 - All ports under DPDK control must behave consistently, PMDs are
3737 responsible for making sure that existing flow rules on a port are not
3738 affected by other ports.
3740 - Ports not under DPDK control (unaffected or handled by other applications)
3741 are user's responsibility. They may affect existing flow rules and cause
3742 undefined behavior. PMDs aware of this may prevent flow rules creation
3743 altogether in such cases.
3748 The PMD interface is defined in ``rte_flow_driver.h``. It is not subject to
3749 API/ABI versioning constraints as it is not exposed to applications and may
3750 evolve independently.
3752 The PMD interface is based on callbacks pointed by the ``struct rte_flow_ops``.
3754 - PMD callbacks implement exactly the interface described in `Rules
3755 management`_, except for the port ID argument which has already been
3756 converted to a pointer to the underlying ``struct rte_eth_dev``.
3758 - Public API functions do not process flow rules definitions at all before
3759 calling PMD functions (no basic error checking, no validation
3760 whatsoever). They only make sure these callbacks are non-NULL or return
3761 the ``ENOSYS`` (function not supported) error.
3763 This interface additionally defines the following helper function:
3765 - ``rte_flow_ops_get()``: get generic flow operations structure from a
3768 If PMD interfaces don't support re-entrancy/multi-thread safety,
3769 the rte_flow API functions will protect threads by mutex per port.
3770 The application can check whether ``RTE_ETH_DEV_FLOW_OPS_THREAD_SAFE``
3771 is set in ``dev_flags``, meaning the PMD is thread-safe regarding rte_flow,
3772 so the API level protection is disabled.
3773 Please note that this API-level mutex protects only rte_flow functions,
3774 other control path functions are not in scope.
3776 Device compatibility
3777 --------------------
3779 No known implementation supports all the described features.
3781 Unsupported features or combinations are not expected to be fully emulated
3782 in software by PMDs for performance reasons. Partially supported features
3783 may be completed in software as long as hardware performs most of the work
3784 (such as queue redirection and packet recognition).
3786 However PMDs are expected to do their best to satisfy application requests
3787 by working around hardware limitations as long as doing so does not affect
3788 the behavior of existing flow rules.
3790 The following sections provide a few examples of such cases and describe how
3791 PMDs should handle them, they are based on limitations built into the
3797 Each flow rule comes with its own, per-layer bit-masks, while hardware may
3798 support only a single, device-wide bit-mask for a given layer type, so that
3799 two IPv4 rules cannot use different bit-masks.
3801 The expected behavior in this case is that PMDs automatically configure
3802 global bit-masks according to the needs of the first flow rule created.
3804 Subsequent rules are allowed only if their bit-masks match those, the
3805 ``EEXIST`` error code should be returned otherwise.
3807 Unsupported layer types
3808 ~~~~~~~~~~~~~~~~~~~~~~~
3810 Many protocols can be simulated by crafting patterns with the `Item: RAW`_
3813 PMDs can rely on this capability to simulate support for protocols with
3814 headers not directly recognized by hardware.
3816 ``ANY`` pattern item
3817 ~~~~~~~~~~~~~~~~~~~~
3819 This pattern item stands for anything, which can be difficult to translate
3820 to something hardware would understand, particularly if followed by more
3823 Consider the following pattern:
3825 .. _table_rte_flow_unsupported_any:
3827 .. table:: Pattern with ANY as L3
3829 +-------+-----------------------+
3831 +=======+=======================+
3833 +-------+-----+---------+-------+
3834 | 1 | ANY | ``num`` | ``1`` |
3835 +-------+-----+---------+-------+
3837 +-------+-----------------------+
3839 +-------+-----------------------+
3841 Knowing that TCP does not make sense with something other than IPv4 and IPv6
3842 as L3, such a pattern may be translated to two flow rules instead:
3844 .. _table_rte_flow_unsupported_any_ipv4:
3846 .. table:: ANY replaced with IPV4
3848 +-------+--------------------+
3850 +=======+====================+
3852 +-------+--------------------+
3853 | 1 | IPV4 (zeroed mask) |
3854 +-------+--------------------+
3856 +-------+--------------------+
3858 +-------+--------------------+
3862 .. _table_rte_flow_unsupported_any_ipv6:
3864 .. table:: ANY replaced with IPV6
3866 +-------+--------------------+
3868 +=======+====================+
3870 +-------+--------------------+
3871 | 1 | IPV6 (zeroed mask) |
3872 +-------+--------------------+
3874 +-------+--------------------+
3876 +-------+--------------------+
3878 Note that as soon as a ANY rule covers several layers, this approach may
3879 yield a large number of hidden flow rules. It is thus suggested to only
3880 support the most common scenarios (anything as L2 and/or L3).
3885 - When combined with `Action: QUEUE`_, packet counting (`Action: COUNT`_)
3886 and tagging (`Action: MARK`_ or `Action: FLAG`_) may be implemented in
3887 software as long as the target queue is used by a single rule.
3889 - When a single target queue is provided, `Action: RSS`_ can also be
3890 implemented through `Action: QUEUE`_.
3895 While it would naturally make sense, flow rules cannot be assumed to be
3896 processed by hardware in the same order as their creation for several
3899 - They may be managed internally as a tree or a hash table instead of a
3901 - Removing a flow rule before adding another one can either put the new rule
3902 at the end of the list or reuse a freed entry.
3903 - Duplication may occur when packets are matched by several rules.
3905 For overlapping rules (particularly in order to use `Action: PASSTHRU`_)
3906 predictable behavior is only guaranteed by using different priority levels.
3908 Priority levels are not necessarily implemented in hardware, or may be
3909 severely limited (e.g. a single priority bit).
3911 For these reasons, priority levels may be implemented purely in software by
3914 - For devices expecting flow rules to be added in the correct order, PMDs
3915 may destroy and re-create existing rules after adding a new one with
3918 - A configurable number of dummy or empty rules can be created at
3919 initialization time to save high priority slots for later.
3921 - In order to save priority levels, PMDs may evaluate whether rules are
3922 likely to collide and adjust their priority accordingly.
3925 .. _OpenFlow Switch Specification: https://www.opennetworking.org/software-defined-standards/specifications/