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 ingress or egress traffic, alter its fate and query related counters
13 according to any 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.
25 It is slightly higher-level than the legacy filtering framework which it
26 encompasses and supersedes (including all functions and filter types) in
27 order to expose a single interface with an unambiguous behavior that is
28 common to all poll-mode drivers (PMDs).
36 A flow rule is the combination of attributes with a matching pattern and a
37 list of actions. Flow rules form the basis of this API.
39 Flow rules can have several distinct actions (such as counting,
40 encapsulating, decapsulating before redirecting packets to a particular
41 queue, etc.), instead of relying on several rules to achieve this and having
42 applications deal with hardware implementation details regarding their
45 Support for different priority levels on a rule basis is provided, for
46 example in order to force a more specific rule to come before a more generic
47 one for packets matched by both. However hardware support for more than a
48 single priority level cannot be guaranteed. When supported, the number of
49 available priority levels is usually low, which is why they can also be
50 implemented in software by PMDs (e.g. missing priority levels may be
51 emulated by reordering rules).
53 In order to remain as hardware-agnostic as possible, by default all rules
54 are considered to have the same priority, which means that the order between
55 overlapping rules (when a packet is matched by several filters) is
58 PMDs may refuse to create overlapping rules at a given priority level when
59 they can be detected (e.g. if a pattern matches an existing filter).
61 Thus predictable results for a given priority level can only be achieved
62 with non-overlapping rules, using perfect matching on all protocol layers.
64 Flow rules can also be grouped, the flow rule priority is specific to the
65 group they belong to. All flow rules in a given group are thus processed within
66 the context of that group. Groups are not linked by default, so the logical
67 hierarchy of groups must be explicitly defined by flow rules themselves in each
68 group using the JUMP action to define the next group to redirect too. Only flow
69 rules defined in the default group 0 are guarantee to be matched against, this
70 makes group 0 the origin of any group hierarchy defined by an application.
72 Support for multiple actions per rule may be implemented internally on top
73 of non-default hardware priorities, as a result both features may not be
74 simultaneously available to applications.
76 Considering that allowed pattern/actions combinations cannot be known in
77 advance and would result in an impractically large number of capabilities to
78 expose, a method is provided to validate a given rule from the current
79 device configuration state.
81 This enables applications to check if the rule types they need is supported
82 at initialization time, before starting their data path. This method can be
83 used anytime, its only requirement being that the resources needed by a rule
84 should exist (e.g. a target RX queue should be configured first).
86 Each defined rule is associated with an opaque handle managed by the PMD,
87 applications are responsible for keeping it. These can be used for queries
88 and rules management, such as retrieving counters or other data and
91 To avoid resource leaks on the PMD side, handles must be explicitly
92 destroyed by the application before releasing associated resources such as
95 The following sections cover:
97 - **Attributes** (represented by ``struct rte_flow_attr``): properties of a
98 flow rule such as its direction (ingress or egress) and priority.
100 - **Pattern item** (represented by ``struct rte_flow_item``): part of a
101 matching pattern that either matches specific packet data or traffic
102 properties. It can also describe properties of the pattern itself, such as
105 - **Matching pattern**: traffic properties to look for, a combination of any
108 - **Actions** (represented by ``struct rte_flow_action``): operations to
109 perform whenever a packet is matched by a pattern.
117 Flow rules can be grouped by assigning them a common group number. Groups
118 allow a logical hierarchy of flow rule groups (tables) to be defined. These
119 groups can be supported virtually in the PMD or in the physical device.
120 Group 0 is the default group and this is the only group which flows are
121 guarantee to matched against, all subsequent groups can only be reached by
122 way of the JUMP action from a matched flow rule.
124 Although optional, applications are encouraged to group similar rules as
125 much as possible to fully take advantage of hardware capabilities
126 (e.g. optimized matching) and work around limitations (e.g. a single pattern
127 type possibly allowed in a given group), while being aware that the groups
128 hierarchies must be programmed explicitly.
130 Note that support for more than a single group is not guaranteed.
135 A priority level can be assigned to a flow rule, lower values
136 denote higher priority, with 0 as the maximum.
138 Priority levels are arbitrary and up to the application, they do
139 not need to be contiguous nor start from 0, however the maximum number
140 varies between devices and may be affected by existing flow rules.
142 A flow which matches multiple rules in the same group will always matched by
143 the rule with the highest priority in that group.
145 If a packet is matched by several rules of a given group for a given
146 priority level, the outcome is undefined. It can take any path, may be
147 duplicated or even cause unrecoverable errors.
149 Note that support for more than a single priority level is not guaranteed.
151 Attribute: Traffic direction
152 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
154 Flow rule patterns apply to inbound and/or outbound traffic.
156 In the context of this API, **ingress** and **egress** respectively stand
157 for **inbound** and **outbound** based on the standpoint of the application
158 creating a flow rule.
160 There are no exceptions to this definition.
162 Several pattern items and actions are valid and can be used in both
163 directions. At least one direction must be specified.
165 Specifying both directions at once for a given rule is not recommended but
166 may be valid in a few cases (e.g. shared counters).
171 Instead of simply matching the properties of traffic as it would appear on a
172 given DPDK port ID, enabling this attribute transfers a flow rule to the
173 lowest possible level of any device endpoints found in the pattern.
175 When supported, this effectively enables an application to reroute traffic
176 not necessarily intended for it (e.g. coming from or addressed to different
177 physical ports, VFs or applications) at the device level.
179 It complements the behavior of some pattern items such as `Item: PHY_PORT`_
180 and is meaningless without them.
182 When transferring flow rules, **ingress** and **egress** attributes
183 (`Attribute: Traffic direction`_) keep their original meaning, as if
184 processing traffic emitted or received by the application.
189 Pattern items fall in two categories:
191 - Matching protocol headers and packet data, usually associated with a
192 specification structure. These must be stacked in the same order as the
193 protocol layers to match inside packets, starting from the lowest.
195 - Matching meta-data or affecting pattern processing, often without a
196 specification structure. Since they do not match packet contents, their
197 position in the list is usually not relevant.
199 Item specification structures are used to match specific values among
200 protocol fields (or item properties). Documentation describes for each item
201 whether they are associated with one and their type name if so.
203 Up to three structures of the same type can be set for a given item:
205 - ``spec``: values to match (e.g. a given IPv4 address).
207 - ``last``: upper bound for an inclusive range with corresponding fields in
210 - ``mask``: bit-mask applied to both ``spec`` and ``last`` whose purpose is
211 to distinguish the values to take into account and/or partially mask them
212 out (e.g. in order to match an IPv4 address prefix).
214 Usage restrictions and expected behavior:
216 - Setting either ``mask`` or ``last`` without ``spec`` is an error.
218 - Field values in ``last`` which are either 0 or equal to the corresponding
219 values in ``spec`` are ignored; they do not generate a range. Nonzero
220 values lower than those in ``spec`` are not supported.
222 - Setting ``spec`` and optionally ``last`` without ``mask`` causes the PMD
223 to use the default mask defined for that item (defined as
224 ``rte_flow_item_{name}_mask`` constants).
226 - Not setting any of them (assuming item type allows it) is equivalent to
227 providing an empty (zeroed) ``mask`` for broad (nonspecific) matching.
229 - ``mask`` is a simple bit-mask applied before interpreting the contents of
230 ``spec`` and ``last``, which may yield unexpected results if not used
231 carefully. For example, if for an IPv4 address field, ``spec`` provides
232 *10.1.2.3*, ``last`` provides *10.3.4.5* and ``mask`` provides
233 *255.255.0.0*, the effective range becomes *10.1.0.0* to *10.3.255.255*.
235 Example of an item specification matching an Ethernet header:
237 .. _table_rte_flow_pattern_item_example:
239 .. table:: Ethernet item
241 +----------+----------+-----------------------+
242 | Field | Subfield | Value |
243 +==========+==========+=======================+
244 | ``spec`` | ``src`` | ``00:00:01:02:03:04`` |
245 | +----------+-----------------------+
246 | | ``dst`` | ``00:00:2a:66:00:01`` |
247 | +----------+-----------------------+
248 | | ``type`` | ``0x22aa`` |
249 +----------+----------+-----------------------+
250 | ``last`` | unspecified |
251 +----------+----------+-----------------------+
252 | ``mask`` | ``src`` | ``00:00:ff:ff:ff:00`` |
253 | +----------+-----------------------+
254 | | ``dst`` | ``00:00:00:00:00:ff`` |
255 | +----------+-----------------------+
256 | | ``type`` | ``0x0000`` |
257 +----------+----------+-----------------------+
259 Non-masked bits stand for any value (shown as ``?`` below), Ethernet headers
260 with the following properties are thus matched:
262 - ``src``: ``??:??:01:02:03:??``
263 - ``dst``: ``??:??:??:??:??:01``
264 - ``type``: ``0x????``
269 A pattern is formed by stacking items starting from the lowest protocol
270 layer to match. This stacking restriction does not apply to meta items which
271 can be placed anywhere in the stack without affecting the meaning of the
274 Patterns are terminated by END items.
278 .. _table_rte_flow_tcpv4_as_l4:
280 .. table:: TCPv4 as L4
296 .. _table_rte_flow_tcpv6_in_vxlan:
298 .. table:: TCPv6 in VXLAN
300 +-------+------------+
302 +=======+============+
304 +-------+------------+
306 +-------+------------+
308 +-------+------------+
310 +-------+------------+
312 +-------+------------+
314 +-------+------------+
316 +-------+------------+
318 +-------+------------+
322 .. _table_rte_flow_tcpv4_as_l4_meta:
324 .. table:: TCPv4 as L4 with meta items
346 The above example shows how meta items do not affect packet data matching
347 items, as long as those remain stacked properly. The resulting matching
348 pattern is identical to "TCPv4 as L4".
350 .. _table_rte_flow_udpv6_anywhere:
352 .. table:: UDPv6 anywhere
364 If supported by the PMD, omitting one or several protocol layers at the
365 bottom of the stack as in the above example (missing an Ethernet
366 specification) enables looking up anywhere in packets.
368 It is unspecified whether the payload of supported encapsulations
369 (e.g. VXLAN payload) is matched by such a pattern, which may apply to inner,
370 outer or both packets.
372 .. _table_rte_flow_invalid_l3:
374 .. table:: Invalid, missing L3
386 The above pattern is invalid due to a missing L3 specification between L2
387 (Ethernet) and L4 (UDP). Doing so is only allowed at the bottom and at the
393 They match meta-data or affect pattern processing instead of matching packet
394 data directly, most of them do not need a specification structure. This
395 particularity allows them to be specified anywhere in the stack without
396 causing any side effect.
401 End marker for item lists. Prevents further processing of items, thereby
404 - Its numeric value is 0 for convenience.
405 - PMD support is mandatory.
406 - ``spec``, ``last`` and ``mask`` are ignored.
408 .. _table_rte_flow_item_end:
412 +----------+---------+
414 +==========+=========+
415 | ``spec`` | ignored |
416 +----------+---------+
417 | ``last`` | ignored |
418 +----------+---------+
419 | ``mask`` | ignored |
420 +----------+---------+
425 Used as a placeholder for convenience. It is ignored and simply discarded by
428 - PMD support is mandatory.
429 - ``spec``, ``last`` and ``mask`` are ignored.
431 .. _table_rte_flow_item_void:
435 +----------+---------+
437 +==========+=========+
438 | ``spec`` | ignored |
439 +----------+---------+
440 | ``last`` | ignored |
441 +----------+---------+
442 | ``mask`` | ignored |
443 +----------+---------+
445 One usage example for this type is generating rules that share a common
446 prefix quickly without reallocating memory, only by updating item types:
448 .. _table_rte_flow_item_void_example:
450 .. table:: TCP, UDP or ICMP as L4
452 +-------+--------------------+
454 +=======+====================+
456 +-------+--------------------+
458 +-------+------+------+------+
459 | 2 | UDP | VOID | VOID |
460 +-------+------+------+------+
461 | 3 | VOID | TCP | VOID |
462 +-------+------+------+------+
463 | 4 | VOID | VOID | ICMP |
464 +-------+------+------+------+
466 +-------+--------------------+
471 Inverted matching, i.e. process packets that do not match the pattern.
473 - ``spec``, ``last`` and ``mask`` are ignored.
475 .. _table_rte_flow_item_invert:
479 +----------+---------+
481 +==========+=========+
482 | ``spec`` | ignored |
483 +----------+---------+
484 | ``last`` | ignored |
485 +----------+---------+
486 | ``mask`` | ignored |
487 +----------+---------+
489 Usage example, matching non-TCPv4 packets only:
491 .. _table_rte_flow_item_invert_example:
493 .. table:: Anything but TCPv4
512 Matches traffic originating from (ingress) or going to (egress) the physical
513 function of the current device.
515 If supported, should work even if the physical function is not managed by
516 the application and thus not associated with a DPDK port ID.
518 - Can be combined with any number of `Item: VF`_ to match both PF and VF
520 - ``spec``, ``last`` and ``mask`` must not be set.
522 .. _table_rte_flow_item_pf:
539 Matches traffic originating from (ingress) or going to (egress) a given
540 virtual function of the current device.
542 If supported, should work even if the virtual function is not managed by the
543 application and thus not associated with a DPDK port ID.
545 Note this pattern item does not match VF representors traffic which, as
546 separate entities, should be addressed through their own DPDK port IDs.
548 - Can be specified multiple times to match traffic addressed to several VF
550 - Can be combined with a PF item to match both PF and VF traffic.
551 - Default ``mask`` matches any VF ID.
553 .. _table_rte_flow_item_vf:
557 +----------+----------+---------------------------+
558 | Field | Subfield | Value |
559 +==========+==========+===========================+
560 | ``spec`` | ``id`` | destination VF ID |
561 +----------+----------+---------------------------+
562 | ``last`` | ``id`` | upper range value |
563 +----------+----------+---------------------------+
564 | ``mask`` | ``id`` | zeroed to match any VF ID |
565 +----------+----------+---------------------------+
570 Matches traffic originating from (ingress) or going to (egress) a physical
571 port of the underlying device.
573 The first PHY_PORT item overrides the physical port normally associated with
574 the specified DPDK input port (port_id). This item can be provided several
575 times to match additional physical ports.
577 Note that physical ports are not necessarily tied to DPDK input ports
578 (port_id) when those are not under DPDK control. Possible values are
579 specific to each device, they are not necessarily indexed from zero and may
582 As a device property, the list of allowed values as well as the value
583 associated with a port_id should be retrieved by other means.
585 - Default ``mask`` matches any port index.
587 .. _table_rte_flow_item_phy_port:
591 +----------+-----------+--------------------------------+
592 | Field | Subfield | Value |
593 +==========+===========+================================+
594 | ``spec`` | ``index`` | physical port index |
595 +----------+-----------+--------------------------------+
596 | ``last`` | ``index`` | upper range value |
597 +----------+-----------+--------------------------------+
598 | ``mask`` | ``index`` | zeroed to match any port index |
599 +----------+-----------+--------------------------------+
604 Matches traffic originating from (ingress) or going to (egress) a given DPDK
607 Normally only supported if the port ID in question is known by the
608 underlying PMD and related to the device the flow rule is created against.
610 This must not be confused with `Item: PHY_PORT`_ which refers to the
611 physical port of a device, whereas `Item: PORT_ID`_ refers to a ``struct
612 rte_eth_dev`` object on the application side (also known as "port
613 representor" depending on the kind of underlying device).
615 - Default ``mask`` matches the specified DPDK port ID.
617 .. _table_rte_flow_item_port_id:
621 +----------+----------+-----------------------------+
622 | Field | Subfield | Value |
623 +==========+==========+=============================+
624 | ``spec`` | ``id`` | DPDK port ID |
625 +----------+----------+-----------------------------+
626 | ``last`` | ``id`` | upper range value |
627 +----------+----------+-----------------------------+
628 | ``mask`` | ``id`` | zeroed to match any port ID |
629 +----------+----------+-----------------------------+
634 Matches an arbitrary integer value which was set using the ``MARK`` action in
635 a previously matched rule.
637 This item can only specified once as a match criteria as the ``MARK`` action can
638 only be specified once in a flow action.
640 Note the value of MARK field is arbitrary and application defined.
642 Depending on the underlying implementation the MARK item may be supported on
643 the physical device, with virtual groups in the PMD or not at all.
645 - Default ``mask`` matches any integer value.
647 .. _table_rte_flow_item_mark:
651 +----------+----------+---------------------------+
652 | Field | Subfield | Value |
653 +==========+==========+===========================+
654 | ``spec`` | ``id`` | integer value |
655 +----------+--------------------------------------+
656 | ``last`` | ``id`` | upper range value |
657 +----------+----------+---------------------------+
658 | ``mask`` | ``id`` | zeroed to match any value |
659 +----------+----------+---------------------------+
664 Matches tag item set by other flows. Multiple tags are supported by specifying
667 - Default ``mask`` matches the specified tag value and index.
669 .. _table_rte_flow_item_tag:
673 +----------+----------+----------------------------------------+
674 | Field | Subfield | Value |
675 +==========+===========+=======================================+
676 | ``spec`` | ``data`` | 32 bit flow tag value |
677 | +-----------+---------------------------------------+
678 | | ``index`` | index of flow tag |
679 +----------+-----------+---------------------------------------+
680 | ``last`` | ``data`` | upper range value |
681 | +-----------+---------------------------------------+
682 | | ``index`` | field is ignored |
683 +----------+-----------+---------------------------------------+
684 | ``mask`` | ``data`` | bit-mask applies to "spec" and "last" |
685 | +-----------+---------------------------------------+
686 | | ``index`` | field is ignored |
687 +----------+-----------+---------------------------------------+
692 Matches 32 bit metadata item set.
694 On egress, metadata can be set either by mbuf metadata field with
695 PKT_TX_DYNF_METADATA flag or ``SET_META`` action. On ingress, ``SET_META``
696 action sets metadata for a packet and the metadata will be reported via
697 ``metadata`` dynamic field of ``rte_mbuf`` with PKT_RX_DYNF_METADATA flag.
699 - Default ``mask`` matches the specified Rx metadata value.
701 .. _table_rte_flow_item_meta:
705 +----------+----------+---------------------------------------+
706 | Field | Subfield | Value |
707 +==========+==========+=======================================+
708 | ``spec`` | ``data`` | 32 bit metadata value |
709 +----------+----------+---------------------------------------+
710 | ``last`` | ``data`` | upper range value |
711 +----------+----------+---------------------------------------+
712 | ``mask`` | ``data`` | bit-mask applies to "spec" and "last" |
713 +----------+----------+---------------------------------------+
715 Data matching item types
716 ~~~~~~~~~~~~~~~~~~~~~~~~
718 Most of these are basically protocol header definitions with associated
719 bit-masks. They must be specified (stacked) from lowest to highest protocol
720 layer to form a matching pattern.
722 The following list is not exhaustive, new protocols will be added in the
728 Matches any protocol in place of the current layer, a single ANY may also
729 stand for several protocol layers.
731 This is usually specified as the first pattern item when looking for a
732 protocol anywhere in a packet.
734 - Default ``mask`` stands for any number of layers.
736 .. _table_rte_flow_item_any:
740 +----------+----------+--------------------------------------+
741 | Field | Subfield | Value |
742 +==========+==========+======================================+
743 | ``spec`` | ``num`` | number of layers covered |
744 +----------+----------+--------------------------------------+
745 | ``last`` | ``num`` | upper range value |
746 +----------+----------+--------------------------------------+
747 | ``mask`` | ``num`` | zeroed to cover any number of layers |
748 +----------+----------+--------------------------------------+
750 Example for VXLAN TCP payload matching regardless of outer L3 (IPv4 or IPv6)
751 and L4 (UDP) both matched by the first ANY specification, and inner L3 (IPv4
752 or IPv6) matched by the second ANY specification:
754 .. _table_rte_flow_item_any_example:
756 .. table:: TCP in VXLAN with wildcards
758 +-------+------+----------+----------+-------+
759 | Index | Item | Field | Subfield | Value |
760 +=======+======+==========+==========+=======+
762 +-------+------+----------+----------+-------+
763 | 1 | ANY | ``spec`` | ``num`` | 2 |
764 +-------+------+----------+----------+-------+
766 +-------+------------------------------------+
768 +-------+------+----------+----------+-------+
769 | 4 | ANY | ``spec`` | ``num`` | 1 |
770 +-------+------+----------+----------+-------+
772 +-------+------------------------------------+
774 +-------+------------------------------------+
779 Matches a byte string of a given length at a given offset.
781 Offset is either absolute (using the start of the packet) or relative to the
782 end of the previous matched item in the stack, in which case negative values
785 If search is enabled, offset is used as the starting point. The search area
786 can be delimited by setting limit to a nonzero value, which is the maximum
787 number of bytes after offset where the pattern may start.
789 Matching a zero-length pattern is allowed, doing so resets the relative
790 offset for subsequent items.
792 - This type does not support ranges (``last`` field).
793 - Default ``mask`` matches all fields exactly.
795 .. _table_rte_flow_item_raw:
799 +----------+--------------+-------------------------------------------------+
800 | Field | Subfield | Value |
801 +==========+==============+=================================================+
802 | ``spec`` | ``relative`` | look for pattern after the previous item |
803 | +--------------+-------------------------------------------------+
804 | | ``search`` | search pattern from offset (see also ``limit``) |
805 | +--------------+-------------------------------------------------+
806 | | ``reserved`` | reserved, must be set to zero |
807 | +--------------+-------------------------------------------------+
808 | | ``offset`` | absolute or relative offset for ``pattern`` |
809 | +--------------+-------------------------------------------------+
810 | | ``limit`` | search area limit for start of ``pattern`` |
811 | +--------------+-------------------------------------------------+
812 | | ``length`` | ``pattern`` length |
813 | +--------------+-------------------------------------------------+
814 | | ``pattern`` | byte string to look for |
815 +----------+--------------+-------------------------------------------------+
816 | ``last`` | if specified, either all 0 or with the same values as ``spec`` |
817 +----------+----------------------------------------------------------------+
818 | ``mask`` | bit-mask applied to ``spec`` values with usual behavior |
819 +----------+----------------------------------------------------------------+
821 Example pattern looking for several strings at various offsets of a UDP
822 payload, using combined RAW items:
824 .. _table_rte_flow_item_raw_example:
826 .. table:: UDP payload matching
828 +-------+------+----------+--------------+-------+
829 | Index | Item | Field | Subfield | Value |
830 +=======+======+==========+==============+=======+
832 +-------+----------------------------------------+
834 +-------+----------------------------------------+
836 +-------+------+----------+--------------+-------+
837 | 3 | RAW | ``spec`` | ``relative`` | 1 |
838 | | | +--------------+-------+
839 | | | | ``search`` | 1 |
840 | | | +--------------+-------+
841 | | | | ``offset`` | 10 |
842 | | | +--------------+-------+
843 | | | | ``limit`` | 0 |
844 | | | +--------------+-------+
845 | | | | ``length`` | 3 |
846 | | | +--------------+-------+
847 | | | | ``pattern`` | "foo" |
848 +-------+------+----------+--------------+-------+
849 | 4 | RAW | ``spec`` | ``relative`` | 1 |
850 | | | +--------------+-------+
851 | | | | ``search`` | 0 |
852 | | | +--------------+-------+
853 | | | | ``offset`` | 20 |
854 | | | +--------------+-------+
855 | | | | ``limit`` | 0 |
856 | | | +--------------+-------+
857 | | | | ``length`` | 3 |
858 | | | +--------------+-------+
859 | | | | ``pattern`` | "bar" |
860 +-------+------+----------+--------------+-------+
861 | 5 | RAW | ``spec`` | ``relative`` | 1 |
862 | | | +--------------+-------+
863 | | | | ``search`` | 0 |
864 | | | +--------------+-------+
865 | | | | ``offset`` | -29 |
866 | | | +--------------+-------+
867 | | | | ``limit`` | 0 |
868 | | | +--------------+-------+
869 | | | | ``length`` | 3 |
870 | | | +--------------+-------+
871 | | | | ``pattern`` | "baz" |
872 +-------+------+----------+--------------+-------+
874 +-------+----------------------------------------+
878 - Locate "foo" at least 10 bytes deep inside UDP payload.
879 - Locate "bar" after "foo" plus 20 bytes.
880 - Locate "baz" after "bar" minus 29 bytes.
882 Such a packet may be represented as follows (not to scale)::
885 | |<--------->| |<--------->|
887 |-----|------|-----|-----|-----|-----|-----------|-----|------|
888 | ETH | IPv4 | UDP | ... | baz | foo | ......... | bar | .... |
889 |-----|------|-----|-----|-----|-----|-----------|-----|------|
891 |<--------------------------->|
894 Note that matching subsequent pattern items would resume after "baz", not
895 "bar" since matching is always performed after the previous item of the
901 Matches an Ethernet header.
903 The ``type`` field either stands for "EtherType" or "TPID" when followed by
904 so-called layer 2.5 pattern items such as ``RTE_FLOW_ITEM_TYPE_VLAN``. In
905 the latter case, ``type`` refers to that of the outer header, with the inner
906 EtherType/TPID provided by the subsequent pattern item. This is the same
907 order as on the wire.
908 If the ``type`` field contains a TPID value, then only tagged packets with the
909 specified TPID will match the pattern.
910 The field ``has_vlan`` can be used to match any type of tagged packets,
911 instead of using the ``type`` field.
912 If the ``type`` and ``has_vlan`` fields are not specified, then both tagged
913 and untagged packets will match the pattern.
915 - ``dst``: destination MAC.
916 - ``src``: source MAC.
917 - ``type``: EtherType or TPID.
918 - ``has_vlan``: packet header contains at least one VLAN.
919 - Default ``mask`` matches destination and source addresses only.
924 Matches an 802.1Q/ad VLAN tag.
926 The corresponding standard outer EtherType (TPID) values are
927 ``RTE_ETHER_TYPE_VLAN`` or ``RTE_ETHER_TYPE_QINQ``. It can be overridden by the
928 preceding pattern item.
929 If a ``VLAN`` item is present in the pattern, then only tagged packets will
931 The field ``has_more_vlan`` can be used to match any type of tagged packets,
932 instead of using the ``inner_type field``.
933 If the ``inner_type`` and ``has_more_vlan`` fields are not specified,
934 then any tagged packets will match the pattern.
936 - ``tci``: tag control information.
937 - ``inner_type``: inner EtherType or TPID.
938 - ``has_more_vlan``: packet header contains at least one more VLAN, after this VLAN.
939 - Default ``mask`` matches the VID part of TCI only (lower 12 bits).
944 Matches an IPv4 header.
946 Note: IPv4 options are handled by dedicated pattern items.
948 - ``hdr``: IPv4 header definition (``rte_ip.h``).
949 - Default ``mask`` matches source and destination addresses only.
954 Matches an IPv6 header.
956 Dedicated flags indicate if header contains specific extension headers.
957 To match on packets containing a specific extension header, an application
958 should match on the dedicated flag set to 1.
959 To match on packets not containing a specific extension header, an application
960 should match on the dedicated flag clear to 0.
961 In case application doesn't care about the existence of a specific extension
962 header, it should not specify the dedicated flag for matching.
964 - ``hdr``: IPv6 header definition (``rte_ip.h``).
965 - ``has_hop_ext``: header contains Hop-by-Hop Options extension header.
966 - ``has_route_ext``: header contains Routing extension header.
967 - ``has_frag_ext``: header contains Fragment extension header.
968 - ``has_auth_ext``: header contains Authentication extension header.
969 - ``has_esp_ext``: header contains Encapsulation Security Payload extension header.
970 - ``has_dest_ext``: header contains Destination Options extension header.
971 - ``has_mobil_ext``: header contains Mobility extension header.
972 - ``has_hip_ext``: header contains Host Identity Protocol extension header.
973 - ``has_shim6_ext``: header contains Shim6 Protocol extension header.
974 - Default ``mask`` matches ``hdr`` source and destination addresses only.
979 Matches an ICMP header.
981 - ``hdr``: ICMP header definition (``rte_icmp.h``).
982 - Default ``mask`` matches ICMP type and code only.
987 Matches a UDP header.
989 - ``hdr``: UDP header definition (``rte_udp.h``).
990 - Default ``mask`` matches source and destination ports only.
995 Matches a TCP header.
997 - ``hdr``: TCP header definition (``rte_tcp.h``).
998 - Default ``mask`` matches source and destination ports only.
1003 Matches a SCTP header.
1005 - ``hdr``: SCTP header definition (``rte_sctp.h``).
1006 - Default ``mask`` matches source and destination ports only.
1011 Matches a VXLAN header (RFC 7348).
1013 - ``flags``: normally 0x08 (I flag).
1014 - ``rsvd0``: reserved, normally 0x000000.
1015 - ``vni``: VXLAN network identifier.
1016 - ``rsvd1``: reserved, normally 0x00.
1017 - Default ``mask`` matches VNI only.
1022 Matches an IEEE 802.1BR E-Tag header.
1024 The corresponding standard outer EtherType (TPID) value is
1025 ``RTE_ETHER_TYPE_ETAG``. It can be overridden by the preceding pattern item.
1027 - ``epcp_edei_in_ecid_b``: E-Tag control information (E-TCI), E-PCP (3b),
1028 E-DEI (1b), ingress E-CID base (12b).
1029 - ``rsvd_grp_ecid_b``: reserved (2b), GRP (2b), E-CID base (12b).
1030 - ``in_ecid_e``: ingress E-CID ext.
1031 - ``ecid_e``: E-CID ext.
1032 - ``inner_type``: inner EtherType or TPID.
1033 - Default ``mask`` simultaneously matches GRP and E-CID base.
1038 Matches a NVGRE header (RFC 7637).
1040 - ``c_k_s_rsvd0_ver``: checksum (1b), undefined (1b), key bit (1b),
1041 sequence number (1b), reserved 0 (9b), version (3b). This field must have
1042 value 0x2000 according to RFC 7637.
1043 - ``protocol``: protocol type (0x6558).
1044 - ``tni``: virtual subnet ID.
1045 - ``flow_id``: flow ID.
1046 - Default ``mask`` matches TNI only.
1051 Matches a MPLS header.
1053 - ``label_tc_s_ttl``: label, TC, Bottom of Stack and TTL.
1054 - Default ``mask`` matches label only.
1059 Matches a GRE header.
1061 - ``c_rsvd0_ver``: checksum, reserved 0 and version.
1062 - ``protocol``: protocol type.
1063 - Default ``mask`` matches protocol only.
1068 Matches a GRE key field.
1069 This should be preceded by item ``GRE``.
1071 - Value to be matched is a big-endian 32 bit integer.
1072 - When this item present it implicitly match K bit in default mask as "1"
1077 Fuzzy pattern match, expect faster than default.
1079 This is for device that support fuzzy match option. Usually a fuzzy match is
1080 fast but the cost is accuracy. i.e. Signature Match only match pattern's hash
1081 value, but it is possible two different patterns have the same hash value.
1083 Matching accuracy level can be configured by threshold. Driver can divide the
1084 range of threshold and map to different accuracy levels that device support.
1086 Threshold 0 means perfect match (no fuzziness), while threshold 0xffffffff
1087 means fuzziest match.
1089 .. _table_rte_flow_item_fuzzy:
1093 +----------+---------------+--------------------------------------------------+
1094 | Field | Subfield | Value |
1095 +==========+===============+==================================================+
1096 | ``spec`` | ``threshold`` | 0 as perfect match, 0xffffffff as fuzziest match |
1097 +----------+---------------+--------------------------------------------------+
1098 | ``last`` | ``threshold`` | upper range value |
1099 +----------+---------------+--------------------------------------------------+
1100 | ``mask`` | ``threshold`` | bit-mask apply to "spec" and "last" |
1101 +----------+---------------+--------------------------------------------------+
1103 Usage example, fuzzy match a TCPv4 packets:
1105 .. _table_rte_flow_item_fuzzy_example:
1107 .. table:: Fuzzy matching
1109 +-------+----------+
1111 +=======+==========+
1113 +-------+----------+
1115 +-------+----------+
1117 +-------+----------+
1119 +-------+----------+
1121 +-------+----------+
1123 Item: ``GTP``, ``GTPC``, ``GTPU``
1124 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1126 Matches a GTPv1 header.
1128 Note: GTP, GTPC and GTPU use the same structure. GTPC and GTPU item
1129 are defined for a user-friendly API when creating GTP-C and GTP-U
1132 - ``v_pt_rsv_flags``: version (3b), protocol type (1b), reserved (1b),
1133 extension header flag (1b), sequence number flag (1b), N-PDU number
1135 - ``msg_type``: message type.
1136 - ``msg_len``: message length.
1137 - ``teid``: tunnel endpoint identifier.
1138 - Default ``mask`` matches teid only.
1143 Matches an ESP header.
1145 - ``hdr``: ESP header definition (``rte_esp.h``).
1146 - Default ``mask`` matches SPI only.
1151 Matches a GENEVE header.
1153 - ``ver_opt_len_o_c_rsvd0``: version (2b), length of the options fields (6b),
1154 OAM packet (1b), critical options present (1b), reserved 0 (6b).
1155 - ``protocol``: protocol type.
1156 - ``vni``: virtual network identifier.
1157 - ``rsvd1``: reserved, normally 0x00.
1158 - Default ``mask`` matches VNI only.
1163 Matches a VXLAN-GPE header (draft-ietf-nvo3-vxlan-gpe-05).
1165 - ``flags``: normally 0x0C (I and P flags).
1166 - ``rsvd0``: reserved, normally 0x0000.
1167 - ``protocol``: protocol type.
1168 - ``vni``: VXLAN network identifier.
1169 - ``rsvd1``: reserved, normally 0x00.
1170 - Default ``mask`` matches VNI only.
1172 Item: ``ARP_ETH_IPV4``
1173 ^^^^^^^^^^^^^^^^^^^^^^
1175 Matches an ARP header for Ethernet/IPv4.
1177 - ``hdr``: hardware type, normally 1.
1178 - ``pro``: protocol type, normally 0x0800.
1179 - ``hln``: hardware address length, normally 6.
1180 - ``pln``: protocol address length, normally 4.
1181 - ``op``: opcode (1 for request, 2 for reply).
1182 - ``sha``: sender hardware address.
1183 - ``spa``: sender IPv4 address.
1184 - ``tha``: target hardware address.
1185 - ``tpa``: target IPv4 address.
1186 - Default ``mask`` matches SHA, SPA, THA and TPA.
1191 Matches the presence of any IPv6 extension header.
1193 - ``next_hdr``: next header.
1194 - Default ``mask`` matches ``next_hdr``.
1196 Normally preceded by any of:
1201 Item: ``IPV6_FRAG_EXT``
1202 ^^^^^^^^^^^^^^^^^^^^^^^
1204 Matches the presence of IPv6 fragment extension header.
1206 - ``hdr``: IPv6 fragment extension header definition (``rte_ip.h``).
1208 Normally preceded by any of:
1216 Matches any ICMPv6 header.
1218 - ``type``: ICMPv6 type.
1219 - ``code``: ICMPv6 code.
1220 - ``checksum``: ICMPv6 checksum.
1221 - Default ``mask`` matches ``type`` and ``code``.
1223 Item: ``ICMP6_ND_NS``
1224 ^^^^^^^^^^^^^^^^^^^^^
1226 Matches an ICMPv6 neighbor discovery solicitation.
1228 - ``type``: ICMPv6 type, normally 135.
1229 - ``code``: ICMPv6 code, normally 0.
1230 - ``checksum``: ICMPv6 checksum.
1231 - ``reserved``: reserved, normally 0.
1232 - ``target_addr``: target address.
1233 - Default ``mask`` matches target address only.
1235 Item: ``ICMP6_ND_NA``
1236 ^^^^^^^^^^^^^^^^^^^^^
1238 Matches an ICMPv6 neighbor discovery advertisement.
1240 - ``type``: ICMPv6 type, normally 136.
1241 - ``code``: ICMPv6 code, normally 0.
1242 - ``checksum``: ICMPv6 checksum.
1243 - ``rso_reserved``: route flag (1b), solicited flag (1b), override flag
1244 (1b), reserved (29b).
1245 - ``target_addr``: target address.
1246 - Default ``mask`` matches target address only.
1248 Item: ``ICMP6_ND_OPT``
1249 ^^^^^^^^^^^^^^^^^^^^^^
1251 Matches the presence of any ICMPv6 neighbor discovery option.
1253 - ``type``: ND option type.
1254 - ``length``: ND option length.
1255 - Default ``mask`` matches type only.
1257 Normally preceded by any of:
1259 - `Item: ICMP6_ND_NA`_
1260 - `Item: ICMP6_ND_NS`_
1261 - `Item: ICMP6_ND_OPT`_
1263 Item: ``ICMP6_ND_OPT_SLA_ETH``
1264 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1266 Matches an ICMPv6 neighbor discovery source Ethernet link-layer address
1269 - ``type``: ND option type, normally 1.
1270 - ``length``: ND option length, normally 1.
1271 - ``sla``: source Ethernet LLA.
1272 - Default ``mask`` matches source link-layer address only.
1274 Normally preceded by any of:
1276 - `Item: ICMP6_ND_NA`_
1277 - `Item: ICMP6_ND_OPT`_
1279 Item: ``ICMP6_ND_OPT_TLA_ETH``
1280 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1282 Matches an ICMPv6 neighbor discovery target Ethernet link-layer address
1285 - ``type``: ND option type, normally 2.
1286 - ``length``: ND option length, normally 1.
1287 - ``tla``: target Ethernet LLA.
1288 - Default ``mask`` matches target link-layer address only.
1290 Normally preceded by any of:
1292 - `Item: ICMP6_ND_NS`_
1293 - `Item: ICMP6_ND_OPT`_
1298 Matches an application specific 32 bit metadata item.
1300 - Default ``mask`` matches the specified metadata value.
1305 Matches a GTP PDU extension header with type 0x85.
1307 - ``pdu_type``: PDU type.
1308 - ``qfi``: QoS flow identifier.
1309 - Default ``mask`` matches QFI only.
1311 Item: ``PPPOES``, ``PPPOED``
1312 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1314 Matches a PPPoE header.
1316 - ``version_type``: version (4b), type (4b).
1317 - ``code``: message type.
1318 - ``session_id``: session identifier.
1319 - ``length``: payload length.
1321 Item: ``PPPOE_PROTO_ID``
1322 ^^^^^^^^^^^^^^^^^^^^^^^^
1324 Matches a PPPoE session protocol identifier.
1326 - ``proto_id``: PPP protocol identifier.
1327 - Default ``mask`` matches proto_id only.
1332 Matches a network service header (RFC 8300).
1334 - ``version``: normally 0x0 (2 bits).
1335 - ``oam_pkt``: indicate oam packet (1 bit).
1336 - ``reserved``: reserved bit (1 bit).
1337 - ``ttl``: maximum SFF hopes (6 bits).
1338 - ``length``: total length in 4 bytes words (6 bits).
1339 - ``reserved1``: reserved1 bits (4 bits).
1340 - ``mdtype``: ndicates format of NSH header (4 bits).
1341 - ``next_proto``: indicates protocol type of encap data (8 bits).
1342 - ``spi``: service path identifier (3 bytes).
1343 - ``sindex``: service index (1 byte).
1344 - Default ``mask`` matches mdtype, next_proto, spi, sindex.
1350 Matches a Internet Group Management Protocol (RFC 2236).
1352 - ``type``: IGMP message type (Query/Report).
1353 - ``max_resp_time``: max time allowed before sending report.
1354 - ``checksum``: checksum, 1s complement of whole IGMP message.
1355 - ``group_addr``: group address, for Query value will be 0.
1356 - Default ``mask`` matches group_addr.
1362 Matches a IP Authentication Header (RFC 4302).
1364 - ``next_hdr``: next payload after AH.
1365 - ``payload_len``: total length of AH in 4B words.
1366 - ``reserved``: reserved bits.
1367 - ``spi``: security parameters index.
1368 - ``seq_num``: counter value increased by 1 on each packet sent.
1369 - Default ``mask`` matches spi.
1374 Matches a HIGIG2 header field. It is layer 2.5 protocol and used in
1377 - Default ``mask`` matches classification and vlan.
1382 Matches a L2TPv3 over IP header.
1384 - ``session_id``: L2TPv3 over IP session identifier.
1385 - Default ``mask`` matches session_id only.
1390 Matches a PFCP Header.
1392 - ``s_field``: S field.
1393 - ``msg_type``: message type.
1394 - ``msg_len``: message length.
1395 - ``seid``: session endpoint identifier.
1396 - Default ``mask`` matches s_field and seid.
1401 Matches a eCPRI header.
1403 - ``hdr``: eCPRI header definition (``rte_ecpri.h``).
1404 - Default ``mask`` matches nothing, for all eCPRI messages.
1409 Each possible action is represented by a type.
1410 An action can have an associated configuration object.
1411 Several actions combined in a list can be assigned
1412 to a flow rule and are performed in order.
1414 They fall in three categories:
1416 - Actions that modify the fate of matching traffic, for instance by dropping
1417 or assigning it a specific destination.
1419 - Actions that modify matching traffic contents or its properties. This
1420 includes adding/removing encapsulation, encryption, compression and marks.
1422 - Actions related to the flow rule itself, such as updating counters or
1423 making it non-terminating.
1425 Flow rules being terminating by default, not specifying any action of the
1426 fate kind results in undefined behavior. This applies to both ingress and
1429 PASSTHRU, when supported, makes a flow rule non-terminating.
1431 Like matching patterns, action lists are terminated by END items.
1433 Example of action that redirects packets to queue index 10:
1435 .. _table_rte_flow_action_example:
1437 .. table:: Queue action
1439 +-----------+-------+
1441 +===========+=======+
1443 +-----------+-------+
1445 Actions are performed in list order:
1447 .. _table_rte_flow_count_then_drop:
1449 .. table:: Count then drop
1463 .. _table_rte_flow_mark_count_redirect:
1465 .. table:: Mark, count then redirect
1467 +-------+--------+------------+-------+
1468 | Index | Action | Field | Value |
1469 +=======+========+============+=======+
1470 | 0 | MARK | ``mark`` | 0x2a |
1471 +-------+--------+------------+-------+
1472 | 1 | COUNT | ``shared`` | 0 |
1473 | | +------------+-------+
1475 +-------+--------+------------+-------+
1476 | 2 | QUEUE | ``queue`` | 10 |
1477 +-------+--------+------------+-------+
1479 +-------+-----------------------------+
1483 .. _table_rte_flow_redirect_queue_5:
1485 .. table:: Redirect to queue 5
1487 +-------+--------+-----------+-------+
1488 | Index | Action | Field | Value |
1489 +=======+========+===========+=======+
1491 +-------+--------+-----------+-------+
1492 | 1 | QUEUE | ``queue`` | 5 |
1493 +-------+--------+-----------+-------+
1495 +-------+----------------------------+
1497 In the above example, while DROP and QUEUE must be performed in order, both
1498 have to happen before reaching END. Only QUEUE has a visible effect.
1500 Note that such a list may be thought as ambiguous and rejected on that
1503 .. _table_rte_flow_redirect_queue_5_3:
1505 .. table:: Redirect to queues 5 and 3
1507 +-------+--------+-----------+-------+
1508 | Index | Action | Field | Value |
1509 +=======+========+===========+=======+
1510 | 0 | QUEUE | ``queue`` | 5 |
1511 +-------+--------+-----------+-------+
1513 +-------+--------+-----------+-------+
1514 | 2 | QUEUE | ``queue`` | 3 |
1515 +-------+--------+-----------+-------+
1517 +-------+----------------------------+
1519 As previously described, all actions must be taken into account. This
1520 effectively duplicates traffic to both queues. The above example also shows
1521 that VOID is ignored.
1526 Common action types are described in this section. Like pattern item types,
1527 this list is not exhaustive as new actions will be added in the future.
1532 End marker for action lists. Prevents further processing of actions, thereby
1535 - Its numeric value is 0 for convenience.
1536 - PMD support is mandatory.
1537 - No configurable properties.
1539 .. _table_rte_flow_action_end:
1552 Used as a placeholder for convenience. It is ignored and simply discarded by
1555 - PMD support is mandatory.
1556 - No configurable properties.
1558 .. _table_rte_flow_action_void:
1568 Action: ``PASSTHRU``
1569 ^^^^^^^^^^^^^^^^^^^^
1571 Leaves traffic up for additional processing by subsequent flow rules; makes
1572 a flow rule non-terminating.
1574 - No configurable properties.
1576 .. _table_rte_flow_action_passthru:
1586 Example to copy a packet to a queue and continue processing by subsequent
1589 .. _table_rte_flow_action_passthru_example:
1591 .. table:: Copy to queue 8
1593 +-------+--------+-----------+-------+
1594 | Index | Action | Field | Value |
1595 +=======+========+===========+=======+
1597 +-------+--------+-----------+-------+
1598 | 1 | QUEUE | ``queue`` | 8 |
1599 +-------+--------+-----------+-------+
1601 +-------+----------------------------+
1606 Redirects packets to a group on the current device.
1608 In a hierarchy of groups, which can be used to represent physical or logical
1609 flow group/tables on the device, this action redirects the matched flow to
1610 the specified group on that device.
1612 If a matched flow is redirected to a table which doesn't contain a matching
1613 rule for that flow then the behavior is undefined and the resulting behavior
1614 is up to the specific device. Best practice when using groups would be define
1615 a default flow rule for each group which a defines the default actions in that
1616 group so a consistent behavior is defined.
1618 Defining an action for matched flow in a group to jump to a group which is
1619 higher in the group hierarchy may not be supported by physical devices,
1620 depending on how groups are mapped to the physical devices. In the
1621 definitions of jump actions, applications should be aware that it may be
1622 possible to define flow rules which trigger an undefined behavior causing
1623 flows to loop between groups.
1625 .. _table_rte_flow_action_jump:
1629 +-----------+------------------------------+
1631 +===========+==============================+
1632 | ``group`` | Group to redirect packets to |
1633 +-----------+------------------------------+
1638 Attaches an integer value to packets and sets ``PKT_RX_FDIR`` and
1639 ``PKT_RX_FDIR_ID`` mbuf flags.
1641 This value is arbitrary and application-defined. Maximum allowed value
1642 depends on the underlying implementation. It is returned in the
1643 ``hash.fdir.hi`` mbuf field.
1645 .. _table_rte_flow_action_mark:
1649 +--------+--------------------------------------+
1651 +========+======================================+
1652 | ``id`` | integer value to return with packets |
1653 +--------+--------------------------------------+
1658 Flags packets. Similar to `Action: MARK`_ without a specific value; only
1659 sets the ``PKT_RX_FDIR`` mbuf flag.
1661 - No configurable properties.
1663 .. _table_rte_flow_action_flag:
1676 Assigns packets to a given queue index.
1678 .. _table_rte_flow_action_queue:
1682 +-----------+--------------------+
1684 +===========+====================+
1685 | ``index`` | queue index to use |
1686 +-----------+--------------------+
1693 - No configurable properties.
1695 .. _table_rte_flow_action_drop:
1708 Adds a counter action to a matched flow.
1710 If more than one count action is specified in a single flow rule, then each
1711 action must specify a unique id.
1713 Counters can be retrieved and reset through ``rte_flow_query()``, see
1714 ``struct rte_flow_query_count``.
1716 The shared flag indicates whether the counter is unique to the flow rule the
1717 action is specified with, or whether it is a shared counter.
1719 For a count action with the shared flag set, then a global device
1720 namespace is assumed for the counter id, so that any matched flow rules using
1721 a count action with the same counter id on the same port will contribute to
1724 For ports within the same switch domain then the counter id namespace extends
1725 to all ports within that switch domain.
1727 .. _table_rte_flow_action_count:
1731 +------------+---------------------+
1733 +============+=====================+
1734 | ``shared`` | shared counter flag |
1735 +------------+---------------------+
1736 | ``id`` | counter id |
1737 +------------+---------------------+
1739 Query structure to retrieve and reset flow rule counters:
1741 .. _table_rte_flow_query_count:
1743 .. table:: COUNT query
1745 +---------------+-----+-----------------------------------+
1746 | Field | I/O | Value |
1747 +===============+=====+===================================+
1748 | ``reset`` | in | reset counter after query |
1749 +---------------+-----+-----------------------------------+
1750 | ``hits_set`` | out | ``hits`` field is set |
1751 +---------------+-----+-----------------------------------+
1752 | ``bytes_set`` | out | ``bytes`` field is set |
1753 +---------------+-----+-----------------------------------+
1754 | ``hits`` | out | number of hits for this rule |
1755 +---------------+-----+-----------------------------------+
1756 | ``bytes`` | out | number of bytes through this rule |
1757 +---------------+-----+-----------------------------------+
1762 Similar to QUEUE, except RSS is additionally performed on packets to spread
1763 them among several queues according to the provided parameters.
1765 Unlike global RSS settings used by other DPDK APIs, unsetting the ``types``
1766 field does not disable RSS in a flow rule. Doing so instead requests safe
1767 unspecified "best-effort" settings from the underlying PMD, which depending
1768 on the flow rule, may result in anything ranging from empty (single queue)
1769 to all-inclusive RSS.
1771 If non-applicable for matching packets RSS types are requested,
1772 these RSS types are simply ignored. For example, it happens if:
1774 - Hashing of both TCP and UDP ports is requested
1775 (only one can be present in a packet).
1777 - Requested RSS types contradict to flow rule pattern
1778 (e.g. pattern has UDP item, but RSS types contain TCP).
1780 If requested RSS hash types are not supported by the Ethernet device at all
1781 (not reported in ``dev_info.flow_type_rss_offloads``),
1782 the flow creation will fail.
1784 Note: RSS hash result is stored in the ``hash.rss`` mbuf field which
1785 overlaps ``hash.fdir.lo``. Since `Action: MARK`_ sets the ``hash.fdir.hi``
1786 field only, both can be requested simultaneously.
1788 Also, regarding packet encapsulation ``level``:
1790 - ``0`` requests the default behavior. Depending on the packet type, it can
1791 mean outermost, innermost, anything in between or even no RSS.
1793 It basically stands for the innermost encapsulation level RSS can be
1794 performed on according to PMD and device capabilities.
1796 - ``1`` requests RSS to be performed on the outermost packet encapsulation
1799 - ``2`` and subsequent values request RSS to be performed on the specified
1800 inner packet encapsulation level, from outermost to innermost (lower to
1803 Values other than ``0`` are not necessarily supported.
1805 Requesting a specific RSS level on unrecognized traffic results in undefined
1806 behavior. For predictable results, it is recommended to make the flow rule
1807 pattern match packet headers up to the requested encapsulation level so that
1808 only matching traffic goes through.
1810 .. _table_rte_flow_action_rss:
1814 +---------------+---------------------------------------------+
1816 +===============+=============================================+
1817 | ``func`` | RSS hash function to apply |
1818 +---------------+---------------------------------------------+
1819 | ``level`` | encapsulation level for ``types`` |
1820 +---------------+---------------------------------------------+
1821 | ``types`` | specific RSS hash types (see ``ETH_RSS_*``) |
1822 +---------------+---------------------------------------------+
1823 | ``key_len`` | hash key length in bytes |
1824 +---------------+---------------------------------------------+
1825 | ``queue_num`` | number of entries in ``queue`` |
1826 +---------------+---------------------------------------------+
1827 | ``key`` | hash key |
1828 +---------------+---------------------------------------------+
1829 | ``queue`` | queue indices to use |
1830 +---------------+---------------------------------------------+
1835 Directs matching traffic to the physical function (PF) of the current
1840 - No configurable properties.
1842 .. _table_rte_flow_action_pf:
1855 Directs matching traffic to a given virtual function of the current device.
1857 Packets matched by a VF pattern item can be redirected to their original VF
1858 ID instead of the specified one. This parameter may not be available and is
1859 not guaranteed to work properly if the VF part is matched by a prior flow
1860 rule or if packets are not addressed to a VF in the first place.
1864 .. _table_rte_flow_action_vf:
1868 +--------------+--------------------------------+
1870 +==============+================================+
1871 | ``original`` | use original VF ID if possible |
1872 +--------------+--------------------------------+
1874 +--------------+--------------------------------+
1876 Action: ``PHY_PORT``
1877 ^^^^^^^^^^^^^^^^^^^^
1879 Directs matching traffic to a given physical port index of the underlying
1882 See `Item: PHY_PORT`_.
1884 .. _table_rte_flow_action_phy_port:
1888 +--------------+-------------------------------------+
1890 +==============+=====================================+
1891 | ``original`` | use original port index if possible |
1892 +--------------+-------------------------------------+
1893 | ``index`` | physical port index |
1894 +--------------+-------------------------------------+
1898 Directs matching traffic to a given DPDK port ID.
1900 See `Item: PORT_ID`_.
1902 .. _table_rte_flow_action_port_id:
1906 +--------------+---------------------------------------+
1908 +==============+=======================================+
1909 | ``original`` | use original DPDK port ID if possible |
1910 +--------------+---------------------------------------+
1911 | ``id`` | DPDK port ID |
1912 +--------------+---------------------------------------+
1917 Applies a stage of metering and policing.
1919 The metering and policing (MTR) object has to be first created using the
1920 rte_mtr_create() API function. The ID of the MTR object is specified as
1921 action parameter. More than one flow can use the same MTR object through
1922 the meter action. The MTR object can be further updated or queried using
1925 .. _table_rte_flow_action_meter:
1929 +--------------+---------------+
1931 +==============+===============+
1932 | ``mtr_id`` | MTR object ID |
1933 +--------------+---------------+
1935 Action: ``SECURITY``
1936 ^^^^^^^^^^^^^^^^^^^^
1938 Perform the security action on flows matched by the pattern items
1939 according to the configuration of the security session.
1941 This action modifies the payload of matched flows. For INLINE_CRYPTO, the
1942 security protocol headers and IV are fully provided by the application as
1943 specified in the flow pattern. The payload of matching packets is
1944 encrypted on egress, and decrypted and authenticated on ingress.
1945 For INLINE_PROTOCOL, the security protocol is fully offloaded to HW,
1946 providing full encapsulation and decapsulation of packets in security
1947 protocols. The flow pattern specifies both the outer security header fields
1948 and the inner packet fields. The security session specified in the action
1949 must match the pattern parameters.
1951 The security session specified in the action must be created on the same
1952 port as the flow action that is being specified.
1954 The ingress/egress flow attribute should match that specified in the
1955 security session if the security session supports the definition of the
1958 Multiple flows can be configured to use the same security session.
1960 .. _table_rte_flow_action_security:
1964 +----------------------+--------------------------------------+
1966 +======================+======================================+
1967 | ``security_session`` | security session to apply |
1968 +----------------------+--------------------------------------+
1970 The following is an example of configuring IPsec inline using the
1971 INLINE_CRYPTO security session:
1973 The encryption algorithm, keys and salt are part of the opaque
1974 ``rte_security_session``. The SA is identified according to the IP and ESP
1975 fields in the pattern items.
1977 .. _table_rte_flow_item_esp_inline_example:
1979 .. table:: IPsec inline crypto flow pattern items.
1981 +-------+----------+
1983 +=======+==========+
1985 +-------+----------+
1987 +-------+----------+
1989 +-------+----------+
1991 +-------+----------+
1993 .. _table_rte_flow_action_esp_inline_example:
1995 .. table:: IPsec inline flow actions.
1997 +-------+----------+
1999 +=======+==========+
2001 +-------+----------+
2003 +-------+----------+
2005 Action: ``OF_SET_MPLS_TTL``
2006 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
2008 Implements ``OFPAT_SET_MPLS_TTL`` ("MPLS TTL") as defined by the `OpenFlow
2009 Switch Specification`_.
2011 .. _table_rte_flow_action_of_set_mpls_ttl:
2013 .. table:: OF_SET_MPLS_TTL
2015 +--------------+----------+
2017 +==============+==========+
2018 | ``mpls_ttl`` | MPLS TTL |
2019 +--------------+----------+
2021 Action: ``OF_DEC_MPLS_TTL``
2022 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024 Implements ``OFPAT_DEC_MPLS_TTL`` ("decrement MPLS TTL") as defined by the
2025 `OpenFlow Switch Specification`_.
2027 .. _table_rte_flow_action_of_dec_mpls_ttl:
2029 .. table:: OF_DEC_MPLS_TTL
2037 Action: ``OF_SET_NW_TTL``
2038 ^^^^^^^^^^^^^^^^^^^^^^^^^
2040 Implements ``OFPAT_SET_NW_TTL`` ("IP TTL") as defined by the `OpenFlow
2041 Switch Specification`_.
2043 .. _table_rte_flow_action_of_set_nw_ttl:
2045 .. table:: OF_SET_NW_TTL
2047 +------------+--------+
2049 +============+========+
2050 | ``nw_ttl`` | IP TTL |
2051 +------------+--------+
2053 Action: ``OF_DEC_NW_TTL``
2054 ^^^^^^^^^^^^^^^^^^^^^^^^^
2056 Implements ``OFPAT_DEC_NW_TTL`` ("decrement IP TTL") as defined by the
2057 `OpenFlow Switch Specification`_.
2059 .. _table_rte_flow_action_of_dec_nw_ttl:
2061 .. table:: OF_DEC_NW_TTL
2069 Action: ``OF_COPY_TTL_OUT``
2070 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
2072 Implements ``OFPAT_COPY_TTL_OUT`` ("copy TTL "outwards" -- from
2073 next-to-outermost to outermost") as defined by the `OpenFlow Switch
2076 .. _table_rte_flow_action_of_copy_ttl_out:
2078 .. table:: OF_COPY_TTL_OUT
2086 Action: ``OF_COPY_TTL_IN``
2087 ^^^^^^^^^^^^^^^^^^^^^^^^^^
2089 Implements ``OFPAT_COPY_TTL_IN`` ("copy TTL "inwards" -- from outermost to
2090 next-to-outermost") as defined by the `OpenFlow Switch Specification`_.
2092 .. _table_rte_flow_action_of_copy_ttl_in:
2094 .. table:: OF_COPY_TTL_IN
2102 Action: ``OF_POP_VLAN``
2103 ^^^^^^^^^^^^^^^^^^^^^^^
2105 Implements ``OFPAT_POP_VLAN`` ("pop the outer VLAN tag") as defined
2106 by the `OpenFlow Switch Specification`_.
2108 .. _table_rte_flow_action_of_pop_vlan:
2110 .. table:: OF_POP_VLAN
2118 Action: ``OF_PUSH_VLAN``
2119 ^^^^^^^^^^^^^^^^^^^^^^^^
2121 Implements ``OFPAT_PUSH_VLAN`` ("push a new VLAN tag") as defined by the
2122 `OpenFlow Switch Specification`_.
2124 .. _table_rte_flow_action_of_push_vlan:
2126 .. table:: OF_PUSH_VLAN
2128 +---------------+-----------+
2130 +===============+===========+
2131 | ``ethertype`` | EtherType |
2132 +---------------+-----------+
2134 Action: ``OF_SET_VLAN_VID``
2135 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
2137 Implements ``OFPAT_SET_VLAN_VID`` ("set the 802.1q VLAN id") as defined by
2138 the `OpenFlow Switch Specification`_.
2140 .. _table_rte_flow_action_of_set_vlan_vid:
2142 .. table:: OF_SET_VLAN_VID
2144 +--------------+---------+
2146 +==============+=========+
2147 | ``vlan_vid`` | VLAN id |
2148 +--------------+---------+
2150 Action: ``OF_SET_VLAN_PCP``
2151 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
2153 Implements ``OFPAT_SET_LAN_PCP`` ("set the 802.1q priority") as defined by
2154 the `OpenFlow Switch Specification`_.
2156 .. _table_rte_flow_action_of_set_vlan_pcp:
2158 .. table:: OF_SET_VLAN_PCP
2160 +--------------+---------------+
2162 +==============+===============+
2163 | ``vlan_pcp`` | VLAN priority |
2164 +--------------+---------------+
2166 Action: ``OF_POP_MPLS``
2167 ^^^^^^^^^^^^^^^^^^^^^^^
2169 Implements ``OFPAT_POP_MPLS`` ("pop the outer MPLS tag") as defined by the
2170 `OpenFlow Switch Specification`_.
2172 .. _table_rte_flow_action_of_pop_mpls:
2174 .. table:: OF_POP_MPLS
2176 +---------------+-----------+
2178 +===============+===========+
2179 | ``ethertype`` | EtherType |
2180 +---------------+-----------+
2182 Action: ``OF_PUSH_MPLS``
2183 ^^^^^^^^^^^^^^^^^^^^^^^^
2185 Implements ``OFPAT_PUSH_MPLS`` ("push a new MPLS tag") as defined by the
2186 `OpenFlow Switch Specification`_.
2188 .. _table_rte_flow_action_of_push_mpls:
2190 .. table:: OF_PUSH_MPLS
2192 +---------------+-----------+
2194 +===============+===========+
2195 | ``ethertype`` | EtherType |
2196 +---------------+-----------+
2198 Action: ``VXLAN_ENCAP``
2199 ^^^^^^^^^^^^^^^^^^^^^^^
2201 Performs a VXLAN encapsulation action by encapsulating the matched flow in the
2202 VXLAN tunnel as defined in the``rte_flow_action_vxlan_encap`` flow items
2205 This action modifies the payload of matched flows. The flow definition specified
2206 in the ``rte_flow_action_tunnel_encap`` action structure must define a valid
2207 VLXAN network overlay which conforms with RFC 7348 (Virtual eXtensible Local
2208 Area Network (VXLAN): A Framework for Overlaying Virtualized Layer 2 Networks
2209 over Layer 3 Networks). The pattern must be terminated with the
2210 RTE_FLOW_ITEM_TYPE_END item type.
2212 .. _table_rte_flow_action_vxlan_encap:
2214 .. table:: VXLAN_ENCAP
2216 +----------------+-------------------------------------+
2218 +================+=====================================+
2219 | ``definition`` | Tunnel end-point overlay definition |
2220 +----------------+-------------------------------------+
2222 .. _table_rte_flow_action_vxlan_encap_example:
2224 .. table:: IPv4 VxLAN flow pattern example.
2226 +-------+----------+
2228 +=======+==========+
2230 +-------+----------+
2232 +-------+----------+
2234 +-------+----------+
2236 +-------+----------+
2238 +-------+----------+
2240 Action: ``VXLAN_DECAP``
2241 ^^^^^^^^^^^^^^^^^^^^^^^
2243 Performs a decapsulation action by stripping all headers of the VXLAN tunnel
2244 network overlay from the matched flow.
2246 The flow items pattern defined for the flow rule with which a ``VXLAN_DECAP``
2247 action is specified, must define a valid VXLAN tunnel as per RFC7348. If the
2248 flow pattern does not specify a valid VXLAN tunnel then a
2249 RTE_FLOW_ERROR_TYPE_ACTION error should be returned.
2251 This action modifies the payload of matched flows.
2253 Action: ``NVGRE_ENCAP``
2254 ^^^^^^^^^^^^^^^^^^^^^^^
2256 Performs a NVGRE encapsulation action by encapsulating the matched flow in the
2257 NVGRE tunnel as defined in the``rte_flow_action_tunnel_encap`` flow item
2260 This action modifies the payload of matched flows. The flow definition specified
2261 in the ``rte_flow_action_tunnel_encap`` action structure must defined a valid
2262 NVGRE network overlay which conforms with RFC 7637 (NVGRE: Network
2263 Virtualization Using Generic Routing Encapsulation). The pattern must be
2264 terminated with the RTE_FLOW_ITEM_TYPE_END item type.
2266 .. _table_rte_flow_action_nvgre_encap:
2268 .. table:: NVGRE_ENCAP
2270 +----------------+-------------------------------------+
2272 +================+=====================================+
2273 | ``definition`` | NVGRE end-point overlay definition |
2274 +----------------+-------------------------------------+
2276 .. _table_rte_flow_action_nvgre_encap_example:
2278 .. table:: IPv4 NVGRE flow pattern example.
2280 +-------+----------+
2282 +=======+==========+
2284 +-------+----------+
2286 +-------+----------+
2288 +-------+----------+
2290 +-------+----------+
2292 Action: ``NVGRE_DECAP``
2293 ^^^^^^^^^^^^^^^^^^^^^^^
2295 Performs a decapsulation action by stripping all headers of the NVGRE tunnel
2296 network overlay from the matched flow.
2298 The flow items pattern defined for the flow rule with which a ``NVGRE_DECAP``
2299 action is specified, must define a valid NVGRE tunnel as per RFC7637. If the
2300 flow pattern does not specify a valid NVGRE tunnel then a
2301 RTE_FLOW_ERROR_TYPE_ACTION error should be returned.
2303 This action modifies the payload of matched flows.
2305 Action: ``RAW_ENCAP``
2306 ^^^^^^^^^^^^^^^^^^^^^
2308 Adds outer header whose template is provided in its data buffer,
2309 as defined in the ``rte_flow_action_raw_encap`` definition.
2311 This action modifies the payload of matched flows. The data supplied must
2312 be a valid header, either holding layer 2 data in case of adding layer 2 after
2313 decap layer 3 tunnel (for example MPLSoGRE) or complete tunnel definition
2314 starting from layer 2 and moving to the tunnel item itself. When applied to
2315 the original packet the resulting packet must be a valid packet.
2317 .. _table_rte_flow_action_raw_encap:
2319 .. table:: RAW_ENCAP
2321 +----------------+----------------------------------------+
2323 +================+========================================+
2324 | ``data`` | Encapsulation data |
2325 +----------------+----------------------------------------+
2326 | ``preserve`` | Bit-mask of data to preserve on output |
2327 +----------------+----------------------------------------+
2328 | ``size`` | Size of data and preserve |
2329 +----------------+----------------------------------------+
2331 Action: ``RAW_DECAP``
2332 ^^^^^^^^^^^^^^^^^^^^^^^
2334 Remove outer header whose template is provided in its data buffer,
2335 as defined in the ``rte_flow_action_raw_decap``
2337 This action modifies the payload of matched flows. The data supplied must
2338 be a valid header, either holding layer 2 data in case of removing layer 2
2339 before encapsulation of layer 3 tunnel (for example MPLSoGRE) or complete
2340 tunnel definition starting from layer 2 and moving to the tunnel item itself.
2341 When applied to the original packet the resulting packet must be a
2344 .. _table_rte_flow_action_raw_decap:
2346 .. table:: RAW_DECAP
2348 +----------------+----------------------------------------+
2350 +================+========================================+
2351 | ``data`` | Decapsulation data |
2352 +----------------+----------------------------------------+
2353 | ``size`` | Size of data |
2354 +----------------+----------------------------------------+
2356 Action: ``SET_IPV4_SRC``
2357 ^^^^^^^^^^^^^^^^^^^^^^^^
2359 Set a new IPv4 source address in the outermost IPv4 header.
2361 It must be used with a valid RTE_FLOW_ITEM_TYPE_IPV4 flow pattern item.
2362 Otherwise, RTE_FLOW_ERROR_TYPE_ACTION error will be returned.
2364 .. _table_rte_flow_action_set_ipv4_src:
2366 .. table:: SET_IPV4_SRC
2368 +-----------------------------------------+
2370 +===============+=========================+
2371 | ``ipv4_addr`` | new IPv4 source address |
2372 +---------------+-------------------------+
2374 Action: ``SET_IPV4_DST``
2375 ^^^^^^^^^^^^^^^^^^^^^^^^
2377 Set a new IPv4 destination address in the outermost IPv4 header.
2379 It must be used with a valid RTE_FLOW_ITEM_TYPE_IPV4 flow pattern item.
2380 Otherwise, RTE_FLOW_ERROR_TYPE_ACTION error will be returned.
2382 .. _table_rte_flow_action_set_ipv4_dst:
2384 .. table:: SET_IPV4_DST
2386 +---------------+------------------------------+
2388 +===============+==============================+
2389 | ``ipv4_addr`` | new IPv4 destination address |
2390 +---------------+------------------------------+
2392 Action: ``SET_IPV6_SRC``
2393 ^^^^^^^^^^^^^^^^^^^^^^^^
2395 Set a new IPv6 source address in the outermost IPv6 header.
2397 It must be used with a valid RTE_FLOW_ITEM_TYPE_IPV6 flow pattern item.
2398 Otherwise, RTE_FLOW_ERROR_TYPE_ACTION error will be returned.
2400 .. _table_rte_flow_action_set_ipv6_src:
2402 .. table:: SET_IPV6_SRC
2404 +---------------+-------------------------+
2406 +===============+=========================+
2407 | ``ipv6_addr`` | new IPv6 source address |
2408 +---------------+-------------------------+
2410 Action: ``SET_IPV6_DST``
2411 ^^^^^^^^^^^^^^^^^^^^^^^^
2413 Set a new IPv6 destination address in the outermost IPv6 header.
2415 It must be used with a valid RTE_FLOW_ITEM_TYPE_IPV6 flow pattern item.
2416 Otherwise, RTE_FLOW_ERROR_TYPE_ACTION error will be returned.
2418 .. _table_rte_flow_action_set_ipv6_dst:
2420 .. table:: SET_IPV6_DST
2422 +---------------+------------------------------+
2424 +===============+==============================+
2425 | ``ipv6_addr`` | new IPv6 destination address |
2426 +---------------+------------------------------+
2428 Action: ``SET_TP_SRC``
2429 ^^^^^^^^^^^^^^^^^^^^^^^^^
2431 Set a new source port number in the outermost TCP/UDP header.
2433 It must be used with a valid RTE_FLOW_ITEM_TYPE_TCP or RTE_FLOW_ITEM_TYPE_UDP
2434 flow pattern item. Otherwise, RTE_FLOW_ERROR_TYPE_ACTION error will be returned.
2436 .. _table_rte_flow_action_set_tp_src:
2438 .. table:: SET_TP_SRC
2440 +----------+-------------------------+
2442 +==========+=========================+
2443 | ``port`` | new TCP/UDP source port |
2444 +---------------+--------------------+
2446 Action: ``SET_TP_DST``
2447 ^^^^^^^^^^^^^^^^^^^^^^^^^
2449 Set a new destination port number in the outermost TCP/UDP header.
2451 It must be used with a valid RTE_FLOW_ITEM_TYPE_TCP or RTE_FLOW_ITEM_TYPE_UDP
2452 flow pattern item. Otherwise, RTE_FLOW_ERROR_TYPE_ACTION error will be returned.
2454 .. _table_rte_flow_action_set_tp_dst:
2456 .. table:: SET_TP_DST
2458 +----------+------------------------------+
2460 +==========+==============================+
2461 | ``port`` | new TCP/UDP destination port |
2462 +---------------+-------------------------+
2464 Action: ``MAC_SWAP``
2465 ^^^^^^^^^^^^^^^^^^^^^^^^^
2467 Swap the source and destination MAC addresses in the outermost Ethernet
2470 It must be used with a valid RTE_FLOW_ITEM_TYPE_ETH flow pattern item.
2471 Otherwise, RTE_FLOW_ERROR_TYPE_ACTION error will be returned.
2473 .. _table_rte_flow_action_mac_swap:
2488 If there is no valid RTE_FLOW_ITEM_TYPE_IPV4 or RTE_FLOW_ITEM_TYPE_IPV6
2489 in pattern, Some PMDs will reject rule because behavior will be undefined.
2491 .. _table_rte_flow_action_dec_ttl:
2504 Assigns a new TTL value.
2506 If there is no valid RTE_FLOW_ITEM_TYPE_IPV4 or RTE_FLOW_ITEM_TYPE_IPV6
2507 in pattern, Some PMDs will reject rule because behavior will be undefined.
2509 .. _table_rte_flow_action_set_ttl:
2513 +---------------+--------------------+
2515 +===============+====================+
2516 | ``ttl_value`` | new TTL value |
2517 +---------------+--------------------+
2519 Action: ``SET_MAC_SRC``
2520 ^^^^^^^^^^^^^^^^^^^^^^^
2522 Set source MAC address.
2524 It must be used with a valid RTE_FLOW_ITEM_TYPE_ETH flow pattern item.
2525 Otherwise, RTE_FLOW_ERROR_TYPE_ACTION error will be returned.
2527 .. _table_rte_flow_action_set_mac_src:
2529 .. table:: SET_MAC_SRC
2531 +--------------+---------------+
2533 +==============+===============+
2534 | ``mac_addr`` | MAC address |
2535 +--------------+---------------+
2537 Action: ``SET_MAC_DST``
2538 ^^^^^^^^^^^^^^^^^^^^^^^
2540 Set destination MAC address.
2542 It must be used with a valid RTE_FLOW_ITEM_TYPE_ETH flow pattern item.
2543 Otherwise, RTE_FLOW_ERROR_TYPE_ACTION error will be returned.
2545 .. _table_rte_flow_action_set_mac_dst:
2547 .. table:: SET_MAC_DST
2549 +--------------+---------------+
2551 +==============+===============+
2552 | ``mac_addr`` | MAC address |
2553 +--------------+---------------+
2555 Action: ``INC_TCP_SEQ``
2556 ^^^^^^^^^^^^^^^^^^^^^^^
2558 Increase sequence number in the outermost TCP header.
2559 Value to increase TCP sequence number by is a big-endian 32 bit integer.
2561 Using this action on non-matching traffic will result in undefined behavior.
2563 Action: ``DEC_TCP_SEQ``
2564 ^^^^^^^^^^^^^^^^^^^^^^^
2566 Decrease sequence number in the outermost TCP header.
2567 Value to decrease TCP sequence number by is a big-endian 32 bit integer.
2569 Using this action on non-matching traffic will result in undefined behavior.
2571 Action: ``INC_TCP_ACK``
2572 ^^^^^^^^^^^^^^^^^^^^^^^
2574 Increase acknowledgment number in the outermost TCP header.
2575 Value to increase TCP acknowledgment number by is a big-endian 32 bit integer.
2577 Using this action on non-matching traffic will result in undefined behavior.
2579 Action: ``DEC_TCP_ACK``
2580 ^^^^^^^^^^^^^^^^^^^^^^^
2582 Decrease acknowledgment number in the outermost TCP header.
2583 Value to decrease TCP acknowledgment number by is a big-endian 32 bit integer.
2585 Using this action on non-matching traffic will result in undefined behavior.
2592 Tag is a transient data used during flow matching. This is not delivered to
2593 application. Multiple tags are supported by specifying index.
2595 .. _table_rte_flow_action_set_tag:
2599 +-----------+----------------------------+
2601 +===========+============================+
2602 | ``data`` | 32 bit tag value |
2603 +-----------+----------------------------+
2604 | ``mask`` | bit-mask applies to "data" |
2605 +-----------+----------------------------+
2606 | ``index`` | index of tag to set |
2607 +-----------+----------------------------+
2609 Action: ``SET_META``
2610 ^^^^^^^^^^^^^^^^^^^^^^^
2612 Set metadata. Item ``META`` matches metadata.
2614 Metadata set by mbuf metadata field with PKT_TX_DYNF_METADATA flag on egress
2615 will be overridden by this action. On ingress, the metadata will be carried by
2616 ``metadata`` dynamic field of ``rte_mbuf`` which can be accessed by
2617 ``RTE_FLOW_DYNF_METADATA()``. PKT_RX_DYNF_METADATA flag will be set along
2620 The mbuf dynamic field must be registered by calling
2621 ``rte_flow_dynf_metadata_register()`` prior to use ``SET_META`` action.
2623 Altering partial bits is supported with ``mask``. For bits which have never been
2624 set, unpredictable value will be seen depending on driver implementation. For
2625 loopback/hairpin packet, metadata set on Rx/Tx may or may not be propagated to
2626 the other path depending on HW capability.
2628 In hairpin case with Tx explicit flow mode, metadata could (not mandatory) be
2629 used to connect the Rx and Tx flows if it can be propagated from Rx to Tx path.
2631 .. _table_rte_flow_action_set_meta:
2635 +----------+----------------------------+
2637 +==========+============================+
2638 | ``data`` | 32 bit metadata value |
2639 +----------+----------------------------+
2640 | ``mask`` | bit-mask applies to "data" |
2641 +----------+----------------------------+
2643 Action: ``SET_IPV4_DSCP``
2644 ^^^^^^^^^^^^^^^^^^^^^^^^^
2648 Modify DSCP in IPv4 header.
2650 It must be used with RTE_FLOW_ITEM_TYPE_IPV4 in pattern.
2651 Otherwise, RTE_FLOW_ERROR_TYPE_ACTION error will be returned.
2653 .. _table_rte_flow_action_set_ipv4_dscp:
2655 .. table:: SET_IPV4_DSCP
2657 +-----------+---------------------------------+
2659 +===========+=================================+
2660 | ``dscp`` | DSCP in low 6 bits, rest ignore |
2661 +-----------+---------------------------------+
2663 Action: ``SET_IPV6_DSCP``
2664 ^^^^^^^^^^^^^^^^^^^^^^^^^
2668 Modify DSCP in IPv6 header.
2670 It must be used with RTE_FLOW_ITEM_TYPE_IPV6 in pattern.
2671 Otherwise, RTE_FLOW_ERROR_TYPE_ACTION error will be returned.
2673 .. _table_rte_flow_action_set_ipv6_dscp:
2675 .. table:: SET_IPV6_DSCP
2677 +-----------+---------------------------------+
2679 +===========+=================================+
2680 | ``dscp`` | DSCP in low 6 bits, rest ignore |
2681 +-----------+---------------------------------+
2686 Set ageing timeout configuration to a flow.
2688 Event RTE_ETH_EVENT_FLOW_AGED will be reported if
2689 timeout passed without any matching on the flow.
2691 .. _table_rte_flow_action_age:
2695 +--------------+---------------------------------+
2697 +==============+=================================+
2698 | ``timeout`` | 24 bits timeout value |
2699 +--------------+---------------------------------+
2700 | ``reserved`` | 8 bits reserved, must be zero |
2701 +--------------+---------------------------------+
2702 | ``context`` | user input flow context |
2703 +--------------+---------------------------------+
2705 Query structure to retrieve ageing status information of a
2706 shared AGE action, or a flow rule using the AGE action:
2708 .. _table_rte_flow_query_age:
2710 .. table:: AGE query
2712 +------------------------------+-----+----------------------------------------+
2713 | Field | I/O | Value |
2714 +==============================+=====+========================================+
2715 | ``aged`` | out | Aging timeout expired |
2716 +------------------------------+-----+----------------------------------------+
2717 | ``sec_since_last_hit_valid`` | out | ``sec_since_last_hit`` value is valid |
2718 +------------------------------+-----+----------------------------------------+
2719 | ``sec_since_last_hit`` | out | Seconds since last traffic hit |
2720 +------------------------------+-----+----------------------------------------+
2725 Adds a sample action to a matched flow.
2727 The matching packets will be duplicated with the specified ``ratio`` and
2728 applied with own set of actions with a fate action, the packets sampled
2729 equals is '1/ratio'. All the packets continue to the target destination.
2731 When the ``ratio`` is set to 1 then the packets will be 100% mirrored.
2732 ``actions`` represent the different set of actions for the sampled or mirrored
2733 packets, and must have a fate action.
2735 .. _table_rte_flow_action_sample:
2739 +--------------+---------------------------------+
2741 +==============+=================================+
2742 | ``ratio`` | 32 bits sample ratio value |
2743 +--------------+---------------------------------+
2744 | ``actions`` | sub-action list for sampling |
2745 +--------------+---------------------------------+
2750 Flow utilize shared action by handle as returned from
2751 ``rte_flow_shared_action_create()``.
2753 The behaviour of the shared action defined by ``action`` argument of type
2754 ``struct rte_flow_action`` passed to ``rte_flow_shared_action_create()``.
2756 .. _table_rte_flow_shared_action:
2769 All specified pattern items (``enum rte_flow_item_type``) and actions
2770 (``enum rte_flow_action_type``) use positive identifiers.
2772 The negative space is reserved for dynamic types generated by PMDs during
2773 run-time. PMDs may encounter them as a result but must not accept negative
2774 identifiers they are not aware of.
2776 A method to generate them remains to be defined.
2778 Application may use PMD dynamic items or actions in flow rules. In that case
2779 size of configuration object in dynamic element must be a pointer size.
2784 Pattern item types will be added as new protocols are implemented.
2786 Variable headers support through dedicated pattern items, for example in
2787 order to match specific IPv4 options and IPv6 extension headers would be
2788 stacked after IPv4/IPv6 items.
2790 Other action types are planned but are not defined yet. These include the
2791 ability to alter packet data in several ways, such as performing
2792 encapsulation/decapsulation of tunnel headers.
2797 A rather simple API with few functions is provided to fully manage flow
2800 Each created flow rule is associated with an opaque, PMD-specific handle
2801 pointer. The application is responsible for keeping it until the rule is
2804 Flows rules are represented by ``struct rte_flow`` objects.
2809 Given that expressing a definite set of device capabilities is not
2810 practical, a dedicated function is provided to check if a flow rule is
2811 supported and can be created.
2816 rte_flow_validate(uint16_t port_id,
2817 const struct rte_flow_attr *attr,
2818 const struct rte_flow_item pattern[],
2819 const struct rte_flow_action actions[],
2820 struct rte_flow_error *error);
2822 The flow rule is validated for correctness and whether it could be accepted
2823 by the device given sufficient resources. The rule is checked against the
2824 current device mode and queue configuration. The flow rule may also
2825 optionally be validated against existing flow rules and device resources.
2826 This function has no effect on the target device.
2828 The returned value is guaranteed to remain valid only as long as no
2829 successful calls to ``rte_flow_create()`` or ``rte_flow_destroy()`` are made
2830 in the meantime and no device parameter affecting flow rules in any way are
2831 modified, due to possible collisions or resource limitations (although in
2832 such cases ``EINVAL`` should not be returned).
2836 - ``port_id``: port identifier of Ethernet device.
2837 - ``attr``: flow rule attributes.
2838 - ``pattern``: pattern specification (list terminated by the END pattern
2840 - ``actions``: associated actions (list terminated by the END action).
2841 - ``error``: perform verbose error reporting if not NULL. PMDs initialize
2842 this structure in case of error only.
2846 - 0 if flow rule is valid and can be created. A negative errno value
2847 otherwise (``rte_errno`` is also set), the following errors are defined.
2848 - ``-ENOSYS``: underlying device does not support this functionality.
2849 - ``-EINVAL``: unknown or invalid rule specification.
2850 - ``-ENOTSUP``: valid but unsupported rule specification (e.g. partial
2851 bit-masks are unsupported).
2852 - ``EEXIST``: collision with an existing rule. Only returned if device
2853 supports flow rule collision checking and there was a flow rule
2854 collision. Not receiving this return code is no guarantee that creating
2855 the rule will not fail due to a collision.
2856 - ``ENOMEM``: not enough memory to execute the function, or if the device
2857 supports resource validation, resource limitation on the device.
2858 - ``-EBUSY``: action cannot be performed due to busy device resources, may
2859 succeed if the affected queues or even the entire port are in a stopped
2860 state (see ``rte_eth_dev_rx_queue_stop()`` and ``rte_eth_dev_stop()``).
2865 Creating a flow rule is similar to validating one, except the rule is
2866 actually created and a handle returned.
2871 rte_flow_create(uint16_t port_id,
2872 const struct rte_flow_attr *attr,
2873 const struct rte_flow_item pattern[],
2874 const struct rte_flow_action *actions[],
2875 struct rte_flow_error *error);
2879 - ``port_id``: port identifier of Ethernet device.
2880 - ``attr``: flow rule attributes.
2881 - ``pattern``: pattern specification (list terminated by the END pattern
2883 - ``actions``: associated actions (list terminated by the END action).
2884 - ``error``: perform verbose error reporting if not NULL. PMDs initialize
2885 this structure in case of error only.
2889 A valid handle in case of success, NULL otherwise and ``rte_errno`` is set
2890 to the positive version of one of the error codes defined for
2891 ``rte_flow_validate()``.
2896 Flow rules destruction is not automatic, and a queue or a port should not be
2897 released if any are still attached to them. Applications must take care of
2898 performing this step before releasing resources.
2903 rte_flow_destroy(uint16_t port_id,
2904 struct rte_flow *flow,
2905 struct rte_flow_error *error);
2908 Failure to destroy a flow rule handle may occur when other flow rules depend
2909 on it, and destroying it would result in an inconsistent state.
2911 This function is only guaranteed to succeed if handles are destroyed in
2912 reverse order of their creation.
2916 - ``port_id``: port identifier of Ethernet device.
2917 - ``flow``: flow rule handle to destroy.
2918 - ``error``: perform verbose error reporting if not NULL. PMDs initialize
2919 this structure in case of error only.
2923 - 0 on success, a negative errno value otherwise and ``rte_errno`` is set.
2928 Convenience function to destroy all flow rule handles associated with a
2929 port. They are released as with successive calls to ``rte_flow_destroy()``.
2934 rte_flow_flush(uint16_t port_id,
2935 struct rte_flow_error *error);
2937 In the unlikely event of failure, handles are still considered destroyed and
2938 no longer valid but the port must be assumed to be in an inconsistent state.
2942 - ``port_id``: port identifier of Ethernet device.
2943 - ``error``: perform verbose error reporting if not NULL. PMDs initialize
2944 this structure in case of error only.
2948 - 0 on success, a negative errno value otherwise and ``rte_errno`` is set.
2953 Query an existing flow rule.
2955 This function allows retrieving flow-specific data such as counters. Data
2956 is gathered by special actions which must be present in the flow rule
2962 rte_flow_query(uint16_t port_id,
2963 struct rte_flow *flow,
2964 const struct rte_flow_action *action,
2966 struct rte_flow_error *error);
2970 - ``port_id``: port identifier of Ethernet device.
2971 - ``flow``: flow rule handle to query.
2972 - ``action``: action to query, this must match prototype from flow rule.
2973 - ``data``: pointer to storage for the associated query data type.
2974 - ``error``: perform verbose error reporting if not NULL. PMDs initialize
2975 this structure in case of error only.
2979 - 0 on success, a negative errno value otherwise and ``rte_errno`` is set.
2981 .. _flow_isolated_mode:
2986 The general expectation for ingress traffic is that flow rules process it
2987 first; the remaining unmatched or pass-through traffic usually ends up in a
2988 queue (with or without RSS, locally or in some sub-device instance)
2989 depending on the global configuration settings of a port.
2991 While fine from a compatibility standpoint, this approach makes drivers more
2992 complex as they have to check for possible side effects outside of this API
2993 when creating or destroying flow rules. It results in a more limited set of
2994 available rule types due to the way device resources are assigned (e.g. no
2995 support for the RSS action even on capable hardware).
2997 Given that nonspecific traffic can be handled by flow rules as well,
2998 isolated mode is a means for applications to tell a driver that ingress on
2999 the underlying port must be injected from the defined flow rules only; that
3000 no default traffic is expected outside those rules.
3002 This has the following benefits:
3004 - Applications get finer-grained control over the kind of traffic they want
3005 to receive (no traffic by default).
3007 - More importantly they control at what point nonspecific traffic is handled
3008 relative to other flow rules, by adjusting priority levels.
3010 - Drivers can assign more hardware resources to flow rules and expand the
3011 set of supported rule types.
3013 Because toggling isolated mode may cause profound changes to the ingress
3014 processing path of a driver, it may not be possible to leave it once
3015 entered. Likewise, existing flow rules or global configuration settings may
3016 prevent a driver from entering isolated mode.
3018 Applications relying on this mode are therefore encouraged to toggle it as
3019 soon as possible after device initialization, ideally before the first call
3020 to ``rte_eth_dev_configure()`` to avoid possible failures due to conflicting
3023 Once effective, the following functionality has no effect on the underlying
3024 port and may return errors such as ``ENOTSUP`` ("not supported"):
3026 - Toggling promiscuous mode.
3027 - Toggling allmulticast mode.
3028 - Configuring MAC addresses.
3029 - Configuring multicast addresses.
3030 - Configuring VLAN filters.
3031 - Configuring Rx filters through the legacy API (e.g. FDIR).
3032 - Configuring global RSS settings.
3037 rte_flow_isolate(uint16_t port_id, int set, struct rte_flow_error *error);
3041 - ``port_id``: port identifier of Ethernet device.
3042 - ``set``: nonzero to enter isolated mode, attempt to leave it otherwise.
3043 - ``error``: perform verbose error reporting if not NULL. PMDs initialize
3044 this structure in case of error only.
3048 - 0 on success, a negative errno value otherwise and ``rte_errno`` is set.
3050 Verbose error reporting
3051 -----------------------
3053 The defined *errno* values may not be accurate enough for users or
3054 application developers who want to investigate issues related to flow rules
3055 management. A dedicated error object is defined for this purpose:
3059 enum rte_flow_error_type {
3060 RTE_FLOW_ERROR_TYPE_NONE, /**< No error. */
3061 RTE_FLOW_ERROR_TYPE_UNSPECIFIED, /**< Cause unspecified. */
3062 RTE_FLOW_ERROR_TYPE_HANDLE, /**< Flow rule (handle). */
3063 RTE_FLOW_ERROR_TYPE_ATTR_GROUP, /**< Group field. */
3064 RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY, /**< Priority field. */
3065 RTE_FLOW_ERROR_TYPE_ATTR_INGRESS, /**< Ingress field. */
3066 RTE_FLOW_ERROR_TYPE_ATTR_EGRESS, /**< Egress field. */
3067 RTE_FLOW_ERROR_TYPE_ATTR, /**< Attributes structure. */
3068 RTE_FLOW_ERROR_TYPE_ITEM_NUM, /**< Pattern length. */
3069 RTE_FLOW_ERROR_TYPE_ITEM, /**< Specific pattern item. */
3070 RTE_FLOW_ERROR_TYPE_ACTION_NUM, /**< Number of actions. */
3071 RTE_FLOW_ERROR_TYPE_ACTION, /**< Specific action. */
3074 struct rte_flow_error {
3075 enum rte_flow_error_type type; /**< Cause field and error types. */
3076 const void *cause; /**< Object responsible for the error. */
3077 const char *message; /**< Human-readable error message. */
3080 Error type ``RTE_FLOW_ERROR_TYPE_NONE`` stands for no error, in which case
3081 remaining fields can be ignored. Other error types describe the type of the
3082 object pointed by ``cause``.
3084 If non-NULL, ``cause`` points to the object responsible for the error. For a
3085 flow rule, this may be a pattern item or an individual action.
3087 If non-NULL, ``message`` provides a human-readable error message.
3089 This object is normally allocated by applications and set by PMDs in case of
3090 error, the message points to a constant string which does not need to be
3091 freed by the application, however its pointer can be considered valid only
3092 as long as its associated DPDK port remains configured. Closing the
3093 underlying device or unloading the PMD invalidates it.
3104 rte_flow_error_set(struct rte_flow_error *error,
3106 enum rte_flow_error_type type,
3108 const char *message);
3110 This function initializes ``error`` (if non-NULL) with the provided
3111 parameters and sets ``rte_errno`` to ``code``. A negative error ``code`` is
3120 rte_flow_conv(enum rte_flow_conv_op op,
3124 struct rte_flow_error *error);
3126 Convert ``src`` to ``dst`` according to operation ``op``. Possible
3129 - Attributes, pattern item or action duplication.
3130 - Duplication of an entire pattern or list of actions.
3131 - Duplication of a complete flow rule description.
3132 - Pattern item or action name retrieval.
3134 Tunneled traffic offload
3135 ~~~~~~~~~~~~~~~~~~~~~~~~
3137 rte_flow API provides the building blocks for vendor-agnostic flow
3138 classification offloads. The rte_flow "patterns" and "actions"
3139 primitives are fine-grained, thus enabling DPDK applications the
3140 flexibility to offload network stacks and complex pipelines.
3141 Applications wishing to offload tunneled traffic are required to use
3142 the rte_flow primitives, such as group, meta, mark, tag, and others to
3143 model their high-level objects. The hardware model design for
3144 high-level software objects is not trivial. Furthermore, an optimal
3145 design is often vendor-specific.
3147 When hardware offloads tunneled traffic in multi-group logic,
3148 partially offloaded packets may arrive to the application after they
3149 were modified in hardware. In this case, the application may need to
3150 restore the original packet headers. Consider the following sequence:
3151 The application decaps a packet in one group and jumps to a second
3152 group where it tries to match on a 5-tuple, that will miss and send
3153 the packet to the application. In this case, the application does not
3154 receive the original packet but a modified one. Also, in this case,
3155 the application cannot match on the outer header fields, such as VXLAN
3158 There are several possible ways to use rte_flow "patterns" and
3159 "actions" to resolve the issues above. For example:
3161 1 Mapping headers to a hardware registers using the
3162 rte_flow_action_mark/rte_flow_action_tag/rte_flow_set_meta objects.
3164 2 Apply the decap only at the last offload stage after all the
3165 "patterns" were matched and the packet will be fully offloaded.
3167 Every approach has its pros and cons and is highly dependent on the
3168 hardware vendor. For example, some hardware may have a limited number
3169 of registers while other hardware could not support inner actions and
3170 must decap before accessing inner headers.
3172 The tunnel offload model resolves these issues. The model goals are:
3174 1 Provide a unified application API to offload tunneled traffic that
3175 is capable to match on outer headers after decap.
3177 2 Allow the application to restore the outer header of partially
3180 The tunnel offload model does not introduce new elements to the
3181 existing RTE flow model and is implemented as a set of helper
3184 For the application to work with the tunnel offload API it
3185 has to adjust flow rules in multi-table tunnel offload in the
3188 1 Remove explicit call to decap action and replace it with PMD actions
3189 obtained from rte_flow_tunnel_decap_and_set() helper.
3191 2 Add PMD items obtained from rte_flow_tunnel_match() helper to all
3192 other rules in the tunnel offload sequence.
3194 The model requirements:
3196 Software application must initialize
3197 rte_tunnel object with tunnel parameters before calling
3198 rte_flow_tunnel_decap_set() & rte_flow_tunnel_match().
3200 PMD actions array obtained in rte_flow_tunnel_decap_set() must be
3201 released by application with rte_flow_action_release() call.
3203 PMD items array obtained with rte_flow_tunnel_match() must be released
3204 by application with rte_flow_item_release() call. Application can
3205 release PMD items and actions after rule was created. However, if the
3206 application needs to create additional rule for the same tunnel it
3207 will need to obtain PMD items again.
3209 Application cannot destroy rte_tunnel object before it releases all
3210 PMD actions & PMD items referencing that tunnel.
3215 - DPDK does not keep track of flow rules definitions or flow rule objects
3216 automatically. Applications may keep track of the former and must keep
3217 track of the latter. PMDs may also do it for internal needs, however this
3218 must not be relied on by applications.
3220 - Flow rules are not maintained between successive port initializations. An
3221 application exiting without releasing them and restarting must re-create
3224 - API operations are synchronous and blocking (``EAGAIN`` cannot be
3227 - Stopping the data path (TX/RX) should not be necessary when managing flow
3228 rules. If this cannot be achieved naturally or with workarounds (such as
3229 temporarily replacing the burst function pointers), an appropriate error
3230 code must be returned (``EBUSY``).
3232 - Applications, not PMDs, are responsible for maintaining flow rules
3233 configuration when closing, stopping or restarting a port or performing other
3234 actions which may affect them.
3235 Applications must assume that after port close, stop or restart all flows
3236 related to that port are not valid, hardware rules are destroyed and relevant
3237 PMD resources are released.
3239 For devices exposing multiple ports sharing global settings affected by flow
3242 - All ports under DPDK control must behave consistently, PMDs are
3243 responsible for making sure that existing flow rules on a port are not
3244 affected by other ports.
3246 - Ports not under DPDK control (unaffected or handled by other applications)
3247 are user's responsibility. They may affect existing flow rules and cause
3248 undefined behavior. PMDs aware of this may prevent flow rules creation
3249 altogether in such cases.
3254 The PMD interface is defined in ``rte_flow_driver.h``. It is not subject to
3255 API/ABI versioning constraints as it is not exposed to applications and may
3256 evolve independently.
3258 It is currently implemented on top of the legacy filtering framework through
3259 filter type *RTE_ETH_FILTER_GENERIC* that accepts the single operation
3260 *RTE_ETH_FILTER_GET* to return PMD-specific *rte_flow* callbacks wrapped
3261 inside ``struct rte_flow_ops``.
3263 This overhead is temporarily necessary in order to keep compatibility with
3264 the legacy filtering framework, which should eventually disappear.
3266 - PMD callbacks implement exactly the interface described in `Rules
3267 management`_, except for the port ID argument which has already been
3268 converted to a pointer to the underlying ``struct rte_eth_dev``.
3270 - Public API functions do not process flow rules definitions at all before
3271 calling PMD functions (no basic error checking, no validation
3272 whatsoever). They only make sure these callbacks are non-NULL or return
3273 the ``ENOSYS`` (function not supported) error.
3275 This interface additionally defines the following helper function:
3277 - ``rte_flow_ops_get()``: get generic flow operations structure from a
3280 If PMD interfaces don't support re-entrancy/multi-thread safety,
3281 the rte_flow API functions will protect threads by mutex per port.
3282 The application can check whether ``RTE_ETH_DEV_FLOW_OPS_THREAD_SAFE``
3283 is set in ``dev_flags``, meaning the PMD is thread-safe regarding rte_flow,
3284 so the API level protection is disabled.
3285 Please note that this API-level mutex protects only rte_flow functions,
3286 other control path functions are not in scope.
3288 More will be added over time.
3290 Device compatibility
3291 --------------------
3293 No known implementation supports all the described features.
3295 Unsupported features or combinations are not expected to be fully emulated
3296 in software by PMDs for performance reasons. Partially supported features
3297 may be completed in software as long as hardware performs most of the work
3298 (such as queue redirection and packet recognition).
3300 However PMDs are expected to do their best to satisfy application requests
3301 by working around hardware limitations as long as doing so does not affect
3302 the behavior of existing flow rules.
3304 The following sections provide a few examples of such cases and describe how
3305 PMDs should handle them, they are based on limitations built into the
3311 Each flow rule comes with its own, per-layer bit-masks, while hardware may
3312 support only a single, device-wide bit-mask for a given layer type, so that
3313 two IPv4 rules cannot use different bit-masks.
3315 The expected behavior in this case is that PMDs automatically configure
3316 global bit-masks according to the needs of the first flow rule created.
3318 Subsequent rules are allowed only if their bit-masks match those, the
3319 ``EEXIST`` error code should be returned otherwise.
3321 Unsupported layer types
3322 ~~~~~~~~~~~~~~~~~~~~~~~
3324 Many protocols can be simulated by crafting patterns with the `Item: RAW`_
3327 PMDs can rely on this capability to simulate support for protocols with
3328 headers not directly recognized by hardware.
3330 ``ANY`` pattern item
3331 ~~~~~~~~~~~~~~~~~~~~
3333 This pattern item stands for anything, which can be difficult to translate
3334 to something hardware would understand, particularly if followed by more
3337 Consider the following pattern:
3339 .. _table_rte_flow_unsupported_any:
3341 .. table:: Pattern with ANY as L3
3343 +-------+-----------------------+
3345 +=======+=======================+
3347 +-------+-----+---------+-------+
3348 | 1 | ANY | ``num`` | ``1`` |
3349 +-------+-----+---------+-------+
3351 +-------+-----------------------+
3353 +-------+-----------------------+
3355 Knowing that TCP does not make sense with something other than IPv4 and IPv6
3356 as L3, such a pattern may be translated to two flow rules instead:
3358 .. _table_rte_flow_unsupported_any_ipv4:
3360 .. table:: ANY replaced with IPV4
3362 +-------+--------------------+
3364 +=======+====================+
3366 +-------+--------------------+
3367 | 1 | IPV4 (zeroed mask) |
3368 +-------+--------------------+
3370 +-------+--------------------+
3372 +-------+--------------------+
3376 .. _table_rte_flow_unsupported_any_ipv6:
3378 .. table:: ANY replaced with IPV6
3380 +-------+--------------------+
3382 +=======+====================+
3384 +-------+--------------------+
3385 | 1 | IPV6 (zeroed mask) |
3386 +-------+--------------------+
3388 +-------+--------------------+
3390 +-------+--------------------+
3392 Note that as soon as a ANY rule covers several layers, this approach may
3393 yield a large number of hidden flow rules. It is thus suggested to only
3394 support the most common scenarios (anything as L2 and/or L3).
3399 - When combined with `Action: QUEUE`_, packet counting (`Action: COUNT`_)
3400 and tagging (`Action: MARK`_ or `Action: FLAG`_) may be implemented in
3401 software as long as the target queue is used by a single rule.
3403 - When a single target queue is provided, `Action: RSS`_ can also be
3404 implemented through `Action: QUEUE`_.
3409 While it would naturally make sense, flow rules cannot be assumed to be
3410 processed by hardware in the same order as their creation for several
3413 - They may be managed internally as a tree or a hash table instead of a
3415 - Removing a flow rule before adding another one can either put the new rule
3416 at the end of the list or reuse a freed entry.
3417 - Duplication may occur when packets are matched by several rules.
3419 For overlapping rules (particularly in order to use `Action: PASSTHRU`_)
3420 predictable behavior is only guaranteed by using different priority levels.
3422 Priority levels are not necessarily implemented in hardware, or may be
3423 severely limited (e.g. a single priority bit).
3425 For these reasons, priority levels may be implemented purely in software by
3428 - For devices expecting flow rules to be added in the correct order, PMDs
3429 may destroy and re-create existing rules after adding a new one with
3432 - A configurable number of dummy or empty rules can be created at
3433 initialization time to save high priority slots for later.
3435 - In order to save priority levels, PMDs may evaluate whether rules are
3436 likely to collide and adjust their priority accordingly.
3441 - A device profile selection function which could be used to force a
3442 permanent profile instead of relying on its automatic configuration based
3443 on existing flow rules.
3445 - A method to optimize *rte_flow* rules with specific pattern items and
3446 action types generated on the fly by PMDs. DPDK should assign negative
3447 numbers to these in order to not collide with the existing types. See
3450 - Adding specific egress pattern items and actions as described in
3451 `Attribute: Traffic direction`_.
3453 - Optional software fallback when PMDs are unable to handle requested flow
3454 rules so applications do not have to implement their own.
3456 .. _OpenFlow Switch Specification: https://www.opennetworking.org/software-defined-standards/specifications/