mem: add dirty malloc element support
[dpdk.git] / doc / guides / prog_guide / rte_flow.rst
1 ..  SPDX-License-Identifier: BSD-3-Clause
2     Copyright 2016 6WIND S.A.
3     Copyright 2016 Mellanox Technologies, Ltd
4
5 Generic flow API (rte_flow)
6 ===========================
7
8 Overview
9 --------
10
11 This API provides a generic means to configure hardware to match specific
12 traffic, alter its fate and query related counters according to any
13 number of user-defined rules.
14
15 It is named *rte_flow* after the prefix used for all its symbols, and is
16 defined in ``rte_flow.h``.
17
18 - Matching can be performed on packet data (protocol headers, payload) and
19   properties (e.g. associated physical port, virtual device function ID).
20
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.
24
25 Flow rule
26 ---------
27
28 Description
29 ~~~~~~~~~~~
30
31 A flow rule is the combination of attributes with a matching pattern and a
32 list of actions. Flow rules form the basis of this API.
33
34 Flow rules can have several distinct actions (such as counting,
35 encapsulating, decapsulating before redirecting packets to a particular
36 queue, etc.), instead of relying on several rules to achieve this and having
37 applications deal with hardware implementation details regarding their
38 order.
39
40 Support for different priority levels on a rule basis is provided, for
41 example in order to force a more specific rule to come before a more generic
42 one for packets matched by both. However hardware support for more than a
43 single priority level cannot be guaranteed. When supported, the number of
44 available priority levels is usually low, which is why they can also be
45 implemented in software by PMDs (e.g. missing priority levels may be
46 emulated by reordering rules).
47
48 In order to remain as hardware-agnostic as possible, by default all rules
49 are considered to have the same priority, which means that the order between
50 overlapping rules (when a packet is matched by several filters) is
51 undefined.
52
53 PMDs may refuse to create overlapping rules at a given priority level when
54 they can be detected (e.g. if a pattern matches an existing filter).
55
56 Thus predictable results for a given priority level can only be achieved
57 with non-overlapping rules, using perfect matching on all protocol layers.
58
59 Flow rules can also be grouped, the flow rule priority is specific to the
60 group they belong to. All flow rules in a given group are thus processed within
61 the context of that group. Groups are not linked by default, so the logical
62 hierarchy of groups must be explicitly defined by flow rules themselves in each
63 group using the JUMP action to define the next group to redirect too. Only flow
64 rules defined in the default group 0 are guarantee to be matched against, this
65 makes group 0 the origin of any group hierarchy defined by an application.
66
67 Support for multiple actions per rule may be implemented internally on top
68 of non-default hardware priorities, as a result both features may not be
69 simultaneously available to applications.
70
71 Considering that allowed pattern/actions combinations cannot be known in
72 advance and would result in an impractically large number of capabilities to
73 expose, a method is provided to validate a given rule from the current
74 device configuration state.
75
76 This enables applications to check if the rule types they need is supported
77 at initialization time, before starting their data path. This method can be
78 used anytime, its only requirement being that the resources needed by a rule
79 should exist (e.g. a target RX queue should be configured first).
80
81 Each defined rule is associated with an opaque handle managed by the PMD,
82 applications are responsible for keeping it. These can be used for queries
83 and rules management, such as retrieving counters or other data and
84 destroying them.
85
86 To avoid resource leaks on the PMD side, handles must be explicitly
87 destroyed by the application before releasing associated resources such as
88 queues and ports.
89
90 .. warning::
91
92    The following description of rule persistence is an experimental behavior
93    that may change without a prior notice.
94
95 When the device is stopped, its rules do not process the traffic.
96 In particular, transfer rules created using some device
97 stop affecting the traffic even if they refer to different ports.
98
99 If ``RTE_ETH_DEV_CAPA_FLOW_RULE_KEEP`` is not advertised,
100 rules cannot be created until the device is started for the first time
101 and cannot be kept when the device is stopped.
102 However, PMD also does not flush them automatically on stop,
103 so the application must call ``rte_flow_flush()`` or ``rte_flow_destroy()``
104 before stopping the device to ensure no rules remain.
105
106 If ``RTE_ETH_DEV_CAPA_FLOW_RULE_KEEP`` is advertised, this means
107 the PMD can keep at least some rules across the device stop and start.
108 However, ``rte_eth_dev_configure()`` may fail if any rules remain,
109 so the application must flush them before attempting a reconfiguration.
110 Keeping may be unsupported for some types of rule items and actions,
111 as well as depending on the value of flow attributes transfer bit.
112 A combination of a single an item or action type
113 and a value of the transfer bit is called a rule feature.
114 For example: a COUNT action with the transfer bit set.
115 To test if rules with a particular feature are kept, the application must try
116 to create a valid rule using this feature when the device is not started
117 (either before the first start or after a stop).
118 If it fails with an error of type ``RTE_FLOW_ERROR_TYPE_STATE``,
119 all rules using this feature must be flushed by the application
120 before stopping the device.
121 If it succeeds, such rules will be kept when the device is stopped,
122 provided they do not use other features that are not supported.
123 Rules that are created when the device is stopped, including the rules
124 created for the test, will be kept after the device is started.
125
126 The following sections cover:
127
128 - **Attributes** (represented by ``struct rte_flow_attr``): properties of a
129   flow rule such as its direction (ingress or egress) and priority.
130
131 - **Pattern item** (represented by ``struct rte_flow_item``): part of a
132   matching pattern that either matches specific packet data or traffic
133   properties. It can also describe properties of the pattern itself, such as
134   inverted matching.
135
136 - **Matching pattern**: traffic properties to look for, a combination of any
137   number of items.
138
139 - **Actions** (represented by ``struct rte_flow_action``): operations to
140   perform whenever a packet is matched by a pattern.
141
142 Attributes
143 ~~~~~~~~~~
144
145 Attribute: Group
146 ^^^^^^^^^^^^^^^^
147
148 Flow rules can be grouped by assigning them a common group number. Groups
149 allow a logical hierarchy of flow rule groups (tables) to be defined. These
150 groups can be supported virtually in the PMD or in the physical device.
151 Group 0 is the default group and this is the only group which flows are
152 guarantee to matched against, all subsequent groups can only be reached by
153 way of the JUMP action from a matched flow rule.
154
155 Although optional, applications are encouraged to group similar rules as
156 much as possible to fully take advantage of hardware capabilities
157 (e.g. optimized matching) and work around limitations (e.g. a single pattern
158 type possibly allowed in a given group), while being aware that the groups
159 hierarchies must be programmed explicitly.
160
161 Note that support for more than a single group is not guaranteed.
162
163 Attribute: Priority
164 ^^^^^^^^^^^^^^^^^^^
165
166 A priority level can be assigned to a flow rule, lower values
167 denote higher priority, with 0 as the maximum.
168
169 Priority levels are arbitrary and up to the application, they do
170 not need to be contiguous nor start from 0, however the maximum number
171 varies between devices and may be affected by existing flow rules.
172
173 A flow which matches multiple rules in the same group will always matched by
174 the rule with the highest priority in that group.
175
176 If a packet is matched by several rules of a given group for a given
177 priority level, the outcome is undefined. It can take any path, may be
178 duplicated or even cause unrecoverable errors.
179
180 Note that support for more than a single priority level is not guaranteed.
181
182 Attribute: Traffic direction
183 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
184
185 Unless `Attribute: Transfer`_ is specified, flow rule patterns apply
186 to inbound and / or outbound traffic. With this respect, ``ingress``
187 and ``egress`` respectively stand for **inbound** and **outbound**
188 based on the standpoint of the application creating a flow rule.
189
190 Several pattern items and actions are valid and can be used in both
191 directions. At least one direction must be specified.
192
193 Specifying both directions at once for a given rule is not recommended but
194 may be valid in a few cases.
195
196 Attribute: Transfer
197 ^^^^^^^^^^^^^^^^^^^
198
199 Instead of simply matching the properties of traffic as it would appear on a
200 given DPDK port ID, enabling this attribute transfers a flow rule to the
201 lowest possible level of any device endpoints found in the pattern.
202
203 When supported, this effectively enables an application to reroute traffic
204 not necessarily intended for it (e.g. coming from or addressed to different
205 physical ports, VFs or applications) at the device level.
206
207 In "transfer" flows, the use of `Attribute: Traffic direction`_ in the sense of
208 implicitly matching packets going to or going from the ethdev used to create
209 flow rules is **deprecated**. `Attribute: Transfer`_ shifts the viewpoint to
210 the embedded switch. In it, `Attribute: Traffic direction`_ is ambiguous as
211 the switch serves many different endpoints. The application should match
212 traffic originating from precise locations. To do so, it should
213 use `Item: PORT_REPRESENTOR`_ and `Item: REPRESENTED_PORT`_.
214
215 Pattern item
216 ~~~~~~~~~~~~
217
218 Pattern items fall in two categories:
219
220 - Matching protocol headers and packet data, usually associated with a
221   specification structure. These must be stacked in the same order as the
222   protocol layers to match inside packets, starting from the lowest.
223
224 - Matching meta-data or affecting pattern processing, often without a
225   specification structure. Since they do not match packet contents, their
226   position in the list is usually not relevant.
227
228 Item specification structures are used to match specific values among
229 protocol fields (or item properties). Documentation describes for each item
230 whether they are associated with one and their type name if so.
231
232 Up to three structures of the same type can be set for a given item:
233
234 - ``spec``: values to match (e.g. a given IPv4 address).
235
236 - ``last``: upper bound for an inclusive range with corresponding fields in
237   ``spec``.
238
239 - ``mask``: bit-mask applied to both ``spec`` and ``last`` whose purpose is
240   to distinguish the values to take into account and/or partially mask them
241   out (e.g. in order to match an IPv4 address prefix).
242
243 Usage restrictions and expected behavior:
244
245 - Setting either ``mask`` or ``last`` without ``spec`` is an error.
246
247 - Field values in ``last`` which are either 0 or equal to the corresponding
248   values in ``spec`` are ignored; they do not generate a range. Nonzero
249   values lower than those in ``spec`` are not supported.
250
251 - Setting ``spec`` and optionally ``last`` without ``mask`` causes the PMD
252   to use the default mask defined for that item (defined as
253   ``rte_flow_item_{name}_mask`` constants).
254
255 - Not setting any of them (assuming item type allows it) is equivalent to
256   providing an empty (zeroed) ``mask`` for broad (nonspecific) matching.
257
258 - ``mask`` is a simple bit-mask applied before interpreting the contents of
259   ``spec`` and ``last``, which may yield unexpected results if not used
260   carefully. For example, if for an IPv4 address field, ``spec`` provides
261   *10.1.2.3*, ``last`` provides *10.3.4.5* and ``mask`` provides
262   *255.255.0.0*, the effective range becomes *10.1.0.0* to *10.3.255.255*.
263
264 Example of an item specification matching an Ethernet header:
265
266 .. _table_rte_flow_pattern_item_example:
267
268 .. table:: Ethernet item
269
270    +----------+----------+-----------------------+
271    | Field    | Subfield | Value                 |
272    +==========+==========+=======================+
273    | ``spec`` | ``src``  | ``00:00:01:02:03:04`` |
274    |          +----------+-----------------------+
275    |          | ``dst``  | ``00:00:2a:66:00:01`` |
276    |          +----------+-----------------------+
277    |          | ``type`` | ``0x22aa``            |
278    +----------+----------+-----------------------+
279    | ``last`` | unspecified                      |
280    +----------+----------+-----------------------+
281    | ``mask`` | ``src``  | ``00:00:ff:ff:ff:00`` |
282    |          +----------+-----------------------+
283    |          | ``dst``  | ``00:00:00:00:00:ff`` |
284    |          +----------+-----------------------+
285    |          | ``type`` | ``0x0000``            |
286    +----------+----------+-----------------------+
287
288 Non-masked bits stand for any value (shown as ``?`` below), Ethernet headers
289 with the following properties are thus matched:
290
291 - ``src``: ``??:??:01:02:03:??``
292 - ``dst``: ``??:??:??:??:??:01``
293 - ``type``: ``0x????``
294
295 Matching pattern
296 ~~~~~~~~~~~~~~~~
297
298 A pattern is formed by stacking items starting from the lowest protocol
299 layer to match. This stacking restriction does not apply to meta items which
300 can be placed anywhere in the stack without affecting the meaning of the
301 resulting pattern.
302
303 Patterns are terminated by END items.
304
305 Examples:
306
307 .. _table_rte_flow_tcpv4_as_l4:
308
309 .. table:: TCPv4 as L4
310
311    +-------+----------+
312    | Index | Item     |
313    +=======+==========+
314    | 0     | Ethernet |
315    +-------+----------+
316    | 1     | IPv4     |
317    +-------+----------+
318    | 2     | TCP      |
319    +-------+----------+
320    | 3     | END      |
321    +-------+----------+
322
323 |
324
325 .. _table_rte_flow_tcpv6_in_vxlan:
326
327 .. table:: TCPv6 in VXLAN
328
329    +-------+------------+
330    | Index | Item       |
331    +=======+============+
332    | 0     | Ethernet   |
333    +-------+------------+
334    | 1     | IPv4       |
335    +-------+------------+
336    | 2     | UDP        |
337    +-------+------------+
338    | 3     | VXLAN      |
339    +-------+------------+
340    | 4     | Ethernet   |
341    +-------+------------+
342    | 5     | IPv6       |
343    +-------+------------+
344    | 6     | TCP        |
345    +-------+------------+
346    | 7     | END        |
347    +-------+------------+
348
349 |
350
351 .. _table_rte_flow_tcpv4_as_l4_meta:
352
353 .. table:: TCPv4 as L4 with meta items
354
355    +-------+----------+
356    | Index | Item     |
357    +=======+==========+
358    | 0     | VOID     |
359    +-------+----------+
360    | 1     | Ethernet |
361    +-------+----------+
362    | 2     | VOID     |
363    +-------+----------+
364    | 3     | IPv4     |
365    +-------+----------+
366    | 4     | TCP      |
367    +-------+----------+
368    | 5     | VOID     |
369    +-------+----------+
370    | 6     | VOID     |
371    +-------+----------+
372    | 7     | END      |
373    +-------+----------+
374
375 The above example shows how meta items do not affect packet data matching
376 items, as long as those remain stacked properly. The resulting matching
377 pattern is identical to "TCPv4 as L4".
378
379 .. _table_rte_flow_udpv6_anywhere:
380
381 .. table:: UDPv6 anywhere
382
383    +-------+------+
384    | Index | Item |
385    +=======+======+
386    | 0     | IPv6 |
387    +-------+------+
388    | 1     | UDP  |
389    +-------+------+
390    | 2     | END  |
391    +-------+------+
392
393 If supported by the PMD, omitting one or several protocol layers at the
394 bottom of the stack as in the above example (missing an Ethernet
395 specification) enables looking up anywhere in packets.
396
397 It is unspecified whether the payload of supported encapsulations
398 (e.g. VXLAN payload) is matched by such a pattern, which may apply to inner,
399 outer or both packets.
400
401 .. _table_rte_flow_invalid_l3:
402
403 .. table:: Invalid, missing L3
404
405    +-------+----------+
406    | Index | Item     |
407    +=======+==========+
408    | 0     | Ethernet |
409    +-------+----------+
410    | 1     | UDP      |
411    +-------+----------+
412    | 2     | END      |
413    +-------+----------+
414
415 The above pattern is invalid due to a missing L3 specification between L2
416 (Ethernet) and L4 (UDP). Doing so is only allowed at the bottom and at the
417 top of the stack.
418
419 Meta item types
420 ~~~~~~~~~~~~~~~
421
422 They match meta-data or affect pattern processing instead of matching packet
423 data directly, most of them do not need a specification structure. This
424 particularity allows them to be specified anywhere in the stack without
425 causing any side effect.
426
427 Item: ``END``
428 ^^^^^^^^^^^^^
429
430 End marker for item lists. Prevents further processing of items, thereby
431 ending the pattern.
432
433 - Its numeric value is 0 for convenience.
434 - PMD support is mandatory.
435 - ``spec``, ``last`` and ``mask`` are ignored.
436
437 .. _table_rte_flow_item_end:
438
439 .. table:: END
440
441    +----------+---------+
442    | Field    | Value   |
443    +==========+=========+
444    | ``spec`` | ignored |
445    +----------+---------+
446    | ``last`` | ignored |
447    +----------+---------+
448    | ``mask`` | ignored |
449    +----------+---------+
450
451 Item: ``VOID``
452 ^^^^^^^^^^^^^^
453
454 Used as a placeholder for convenience. It is ignored and simply discarded by
455 PMDs.
456
457 - PMD support is mandatory.
458 - ``spec``, ``last`` and ``mask`` are ignored.
459
460 .. _table_rte_flow_item_void:
461
462 .. table:: VOID
463
464    +----------+---------+
465    | Field    | Value   |
466    +==========+=========+
467    | ``spec`` | ignored |
468    +----------+---------+
469    | ``last`` | ignored |
470    +----------+---------+
471    | ``mask`` | ignored |
472    +----------+---------+
473
474 One usage example for this type is generating rules that share a common
475 prefix quickly without reallocating memory, only by updating item types:
476
477 .. _table_rte_flow_item_void_example:
478
479 .. table:: TCP, UDP or ICMP as L4
480
481    +-------+--------------------+
482    | Index | Item               |
483    +=======+====================+
484    | 0     | Ethernet           |
485    +-------+--------------------+
486    | 1     | IPv4               |
487    +-------+------+------+------+
488    | 2     | UDP  | VOID | VOID |
489    +-------+------+------+------+
490    | 3     | VOID | TCP  | VOID |
491    +-------+------+------+------+
492    | 4     | VOID | VOID | ICMP |
493    +-------+------+------+------+
494    | 5     | END                |
495    +-------+--------------------+
496
497 Item: ``INVERT``
498 ^^^^^^^^^^^^^^^^
499
500 Inverted matching, i.e. process packets that do not match the pattern.
501
502 - ``spec``, ``last`` and ``mask`` are ignored.
503
504 .. _table_rte_flow_item_invert:
505
506 .. table:: INVERT
507
508    +----------+---------+
509    | Field    | Value   |
510    +==========+=========+
511    | ``spec`` | ignored |
512    +----------+---------+
513    | ``last`` | ignored |
514    +----------+---------+
515    | ``mask`` | ignored |
516    +----------+---------+
517
518 Usage example, matching non-TCPv4 packets only:
519
520 .. _table_rte_flow_item_invert_example:
521
522 .. table:: Anything but TCPv4
523
524    +-------+----------+
525    | Index | Item     |
526    +=======+==========+
527    | 0     | INVERT   |
528    +-------+----------+
529    | 1     | Ethernet |
530    +-------+----------+
531    | 2     | IPv4     |
532    +-------+----------+
533    | 3     | TCP      |
534    +-------+----------+
535    | 4     | END      |
536    +-------+----------+
537
538 Item: ``PF``
539 ^^^^^^^^^^^^
540
541 This item is deprecated. Consider:
542  - `Item: PORT_REPRESENTOR`_
543  - `Item: REPRESENTED_PORT`_
544
545 Matches traffic originating from (ingress) or going to (egress) the physical
546 function of the current device.
547
548 If supported, should work even if the physical function is not managed by
549 the application and thus not associated with a DPDK port ID.
550
551 - Can be combined with any number of `Item: VF`_ to match both PF and VF
552   traffic.
553 - ``spec``, ``last`` and ``mask`` must not be set.
554
555 .. _table_rte_flow_item_pf:
556
557 .. table:: PF
558
559    +----------+-------+
560    | Field    | Value |
561    +==========+=======+
562    | ``spec`` | unset |
563    +----------+-------+
564    | ``last`` | unset |
565    +----------+-------+
566    | ``mask`` | unset |
567    +----------+-------+
568
569 Item: ``VF``
570 ^^^^^^^^^^^^
571
572 This item is deprecated. Consider:
573  - `Item: PORT_REPRESENTOR`_
574  - `Item: REPRESENTED_PORT`_
575
576 Matches traffic originating from (ingress) or going to (egress) a given
577 virtual function of the current device.
578
579 If supported, should work even if the virtual function is not managed by the
580 application and thus not associated with a DPDK port ID.
581
582 Note this pattern item does not match VF representors traffic which, as
583 separate entities, should be addressed through their own DPDK port IDs.
584
585 - Can be specified multiple times to match traffic addressed to several VF
586   IDs.
587 - Can be combined with a PF item to match both PF and VF traffic.
588 - Default ``mask`` matches any VF ID.
589
590 .. _table_rte_flow_item_vf:
591
592 .. table:: VF
593
594    +----------+----------+---------------------------+
595    | Field    | Subfield | Value                     |
596    +==========+==========+===========================+
597    | ``spec`` | ``id``   | destination VF ID         |
598    +----------+----------+---------------------------+
599    | ``last`` | ``id``   | upper range value         |
600    +----------+----------+---------------------------+
601    | ``mask`` | ``id``   | zeroed to match any VF ID |
602    +----------+----------+---------------------------+
603
604 Item: ``PHY_PORT``
605 ^^^^^^^^^^^^^^^^^^
606
607 This item is deprecated. Consider:
608  - `Item: PORT_REPRESENTOR`_
609  - `Item: REPRESENTED_PORT`_
610
611 Matches traffic originating from (ingress) or going to (egress) a physical
612 port of the underlying device.
613
614 The first PHY_PORT item overrides the physical port normally associated with
615 the specified DPDK input port (port_id). This item can be provided several
616 times to match additional physical ports.
617
618 Note that physical ports are not necessarily tied to DPDK input ports
619 (port_id) when those are not under DPDK control. Possible values are
620 specific to each device, they are not necessarily indexed from zero and may
621 not be contiguous.
622
623 As a device property, the list of allowed values as well as the value
624 associated with a port_id should be retrieved by other means.
625
626 - Default ``mask`` matches any port index.
627
628 .. _table_rte_flow_item_phy_port:
629
630 .. table:: PHY_PORT
631
632    +----------+-----------+--------------------------------+
633    | Field    | Subfield  | Value                          |
634    +==========+===========+================================+
635    | ``spec`` | ``index`` | physical port index            |
636    +----------+-----------+--------------------------------+
637    | ``last`` | ``index`` | upper range value              |
638    +----------+-----------+--------------------------------+
639    | ``mask`` | ``index`` | zeroed to match any port index |
640    +----------+-----------+--------------------------------+
641
642 Item: ``PORT_ID``
643 ^^^^^^^^^^^^^^^^^
644
645 This item is deprecated. Consider:
646  - `Item: PORT_REPRESENTOR`_
647  - `Item: REPRESENTED_PORT`_
648
649 Matches traffic originating from (ingress) or going to (egress) a given DPDK
650 port ID.
651
652 Normally only supported if the port ID in question is known by the
653 underlying PMD and related to the device the flow rule is created against.
654
655 This must not be confused with `Item: PHY_PORT`_ which refers to the
656 physical port of a device, whereas `Item: PORT_ID`_ refers to a ``struct
657 rte_eth_dev`` object on the application side (also known as "port
658 representor" depending on the kind of underlying device).
659
660 - Default ``mask`` matches the specified DPDK port ID.
661
662 .. _table_rte_flow_item_port_id:
663
664 .. table:: PORT_ID
665
666    +----------+----------+-----------------------------+
667    | Field    | Subfield | Value                       |
668    +==========+==========+=============================+
669    | ``spec`` | ``id``   | DPDK port ID                |
670    +----------+----------+-----------------------------+
671    | ``last`` | ``id``   | upper range value           |
672    +----------+----------+-----------------------------+
673    | ``mask`` | ``id``   | zeroed to match any port ID |
674    +----------+----------+-----------------------------+
675
676 Item: ``MARK``
677 ^^^^^^^^^^^^^^
678
679 Matches an arbitrary integer value which was set using the ``MARK`` action in
680 a previously matched rule.
681
682 This item can only specified once as a match criteria as the ``MARK`` action can
683 only be specified once in a flow action.
684
685 Note the value of MARK field is arbitrary and application defined.
686
687 Depending on the underlying implementation the MARK item may be supported on
688 the physical device, with virtual groups in the PMD or not at all.
689
690 - Default ``mask`` matches any integer value.
691
692 .. _table_rte_flow_item_mark:
693
694 .. table:: MARK
695
696    +----------+----------+---------------------------+
697    | Field    | Subfield | Value                     |
698    +==========+==========+===========================+
699    | ``spec`` | ``id``   | integer value             |
700    +----------+--------------------------------------+
701    | ``last`` | ``id``   | upper range value         |
702    +----------+----------+---------------------------+
703    | ``mask`` | ``id``   | zeroed to match any value |
704    +----------+----------+---------------------------+
705
706 Item: ``TAG``
707 ^^^^^^^^^^^^^
708
709 Matches tag item set by other flows. Multiple tags are supported by specifying
710 ``index``.
711
712 - Default ``mask`` matches the specified tag value and index.
713
714 .. _table_rte_flow_item_tag:
715
716 .. table:: TAG
717
718    +----------+----------+----------------------------------------+
719    | Field    | Subfield  | Value                                 |
720    +==========+===========+=======================================+
721    | ``spec`` | ``data``  | 32 bit flow tag value                 |
722    |          +-----------+---------------------------------------+
723    |          | ``index`` | index of flow tag                     |
724    +----------+-----------+---------------------------------------+
725    | ``last`` | ``data``  | upper range value                     |
726    |          +-----------+---------------------------------------+
727    |          | ``index`` | field is ignored                      |
728    +----------+-----------+---------------------------------------+
729    | ``mask`` | ``data``  | bit-mask applies to "spec" and "last" |
730    |          +-----------+---------------------------------------+
731    |          | ``index`` | field is ignored                      |
732    +----------+-----------+---------------------------------------+
733
734 Item: ``META``
735 ^^^^^^^^^^^^^^^^^
736
737 Matches 32 bit metadata item set.
738
739 On egress, metadata can be set either by mbuf metadata field with
740 RTE_MBUF_DYNFLAG_TX_METADATA flag or ``SET_META`` action. On ingress, ``SET_META``
741 action sets metadata for a packet and the metadata will be reported via
742 ``metadata`` dynamic field of ``rte_mbuf`` with RTE_MBUF_DYNFLAG_RX_METADATA flag.
743
744 - Default ``mask`` matches the specified Rx metadata value.
745
746 .. _table_rte_flow_item_meta:
747
748 .. table:: META
749
750    +----------+----------+---------------------------------------+
751    | Field    | Subfield | Value                                 |
752    +==========+==========+=======================================+
753    | ``spec`` | ``data`` | 32 bit metadata value                 |
754    +----------+----------+---------------------------------------+
755    | ``last`` | ``data`` | upper range value                     |
756    +----------+----------+---------------------------------------+
757    | ``mask`` | ``data`` | bit-mask applies to "spec" and "last" |
758    +----------+----------+---------------------------------------+
759
760 Data matching item types
761 ~~~~~~~~~~~~~~~~~~~~~~~~
762
763 Most of these are basically protocol header definitions with associated
764 bit-masks. They must be specified (stacked) from lowest to highest protocol
765 layer to form a matching pattern.
766
767 Item: ``ANY``
768 ^^^^^^^^^^^^^
769
770 Matches any protocol in place of the current layer, a single ANY may also
771 stand for several protocol layers.
772
773 This is usually specified as the first pattern item when looking for a
774 protocol anywhere in a packet.
775
776 - Default ``mask`` stands for any number of layers.
777
778 .. _table_rte_flow_item_any:
779
780 .. table:: ANY
781
782    +----------+----------+--------------------------------------+
783    | Field    | Subfield | Value                                |
784    +==========+==========+======================================+
785    | ``spec`` | ``num``  | number of layers covered             |
786    +----------+----------+--------------------------------------+
787    | ``last`` | ``num``  | upper range value                    |
788    +----------+----------+--------------------------------------+
789    | ``mask`` | ``num``  | zeroed to cover any number of layers |
790    +----------+----------+--------------------------------------+
791
792 Example for VXLAN TCP payload matching regardless of outer L3 (IPv4 or IPv6)
793 and L4 (UDP) both matched by the first ANY specification, and inner L3 (IPv4
794 or IPv6) matched by the second ANY specification:
795
796 .. _table_rte_flow_item_any_example:
797
798 .. table:: TCP in VXLAN with wildcards
799
800    +-------+------+----------+----------+-------+
801    | Index | Item | Field    | Subfield | Value |
802    +=======+======+==========+==========+=======+
803    | 0     | Ethernet                           |
804    +-------+------+----------+----------+-------+
805    | 1     | ANY  | ``spec`` | ``num``  | 2     |
806    +-------+------+----------+----------+-------+
807    | 2     | VXLAN                              |
808    +-------+------------------------------------+
809    | 3     | Ethernet                           |
810    +-------+------+----------+----------+-------+
811    | 4     | ANY  | ``spec`` | ``num``  | 1     |
812    +-------+------+----------+----------+-------+
813    | 5     | TCP                                |
814    +-------+------------------------------------+
815    | 6     | END                                |
816    +-------+------------------------------------+
817
818 Item: ``RAW``
819 ^^^^^^^^^^^^^
820
821 Matches a byte string of a given length at a given offset.
822
823 Offset is either absolute (using the start of the packet) or relative to the
824 end of the previous matched item in the stack, in which case negative values
825 are allowed.
826
827 If search is enabled, offset is used as the starting point. The search area
828 can be delimited by setting limit to a nonzero value, which is the maximum
829 number of bytes after offset where the pattern may start.
830
831 Matching a zero-length pattern is allowed, doing so resets the relative
832 offset for subsequent items.
833
834 - This type does not support ranges (``last`` field).
835 - Default ``mask`` matches all fields exactly.
836
837 .. _table_rte_flow_item_raw:
838
839 .. table:: RAW
840
841    +----------+--------------+-------------------------------------------------+
842    | Field    | Subfield     | Value                                           |
843    +==========+==============+=================================================+
844    | ``spec`` | ``relative`` | look for pattern after the previous item        |
845    |          +--------------+-------------------------------------------------+
846    |          | ``search``   | search pattern from offset (see also ``limit``) |
847    |          +--------------+-------------------------------------------------+
848    |          | ``reserved`` | reserved, must be set to zero                   |
849    |          +--------------+-------------------------------------------------+
850    |          | ``offset``   | absolute or relative offset for ``pattern``     |
851    |          +--------------+-------------------------------------------------+
852    |          | ``limit``    | search area limit for start of ``pattern``      |
853    |          +--------------+-------------------------------------------------+
854    |          | ``length``   | ``pattern`` length                              |
855    |          +--------------+-------------------------------------------------+
856    |          | ``pattern``  | byte string to look for                         |
857    +----------+--------------+-------------------------------------------------+
858    | ``last`` | if specified, either all 0 or with the same values as ``spec`` |
859    +----------+----------------------------------------------------------------+
860    | ``mask`` | bit-mask applied to ``spec`` values with usual behavior        |
861    +----------+----------------------------------------------------------------+
862
863 Example pattern looking for several strings at various offsets of a UDP
864 payload, using combined RAW items:
865
866 .. _table_rte_flow_item_raw_example:
867
868 .. table:: UDP payload matching
869
870    +-------+------+----------+--------------+-------+
871    | Index | Item | Field    | Subfield     | Value |
872    +=======+======+==========+==============+=======+
873    | 0     | Ethernet                               |
874    +-------+----------------------------------------+
875    | 1     | IPv4                                   |
876    +-------+----------------------------------------+
877    | 2     | UDP                                    |
878    +-------+------+----------+--------------+-------+
879    | 3     | RAW  | ``spec`` | ``relative`` | 1     |
880    |       |      |          +--------------+-------+
881    |       |      |          | ``search``   | 1     |
882    |       |      |          +--------------+-------+
883    |       |      |          | ``offset``   | 10    |
884    |       |      |          +--------------+-------+
885    |       |      |          | ``limit``    | 0     |
886    |       |      |          +--------------+-------+
887    |       |      |          | ``length``   | 3     |
888    |       |      |          +--------------+-------+
889    |       |      |          | ``pattern``  | "foo" |
890    +-------+------+----------+--------------+-------+
891    | 4     | RAW  | ``spec`` | ``relative`` | 1     |
892    |       |      |          +--------------+-------+
893    |       |      |          | ``search``   | 0     |
894    |       |      |          +--------------+-------+
895    |       |      |          | ``offset``   | 20    |
896    |       |      |          +--------------+-------+
897    |       |      |          | ``limit``    | 0     |
898    |       |      |          +--------------+-------+
899    |       |      |          | ``length``   | 3     |
900    |       |      |          +--------------+-------+
901    |       |      |          | ``pattern``  | "bar" |
902    +-------+------+----------+--------------+-------+
903    | 5     | RAW  | ``spec`` | ``relative`` | 1     |
904    |       |      |          +--------------+-------+
905    |       |      |          | ``search``   | 0     |
906    |       |      |          +--------------+-------+
907    |       |      |          | ``offset``   | -29   |
908    |       |      |          +--------------+-------+
909    |       |      |          | ``limit``    | 0     |
910    |       |      |          +--------------+-------+
911    |       |      |          | ``length``   | 3     |
912    |       |      |          +--------------+-------+
913    |       |      |          | ``pattern``  | "baz" |
914    +-------+------+----------+--------------+-------+
915    | 6     | END                                    |
916    +-------+----------------------------------------+
917
918 This translates to:
919
920 - Locate "foo" at least 10 bytes deep inside UDP payload.
921 - Locate "bar" after "foo" plus 20 bytes.
922 - Locate "baz" after "bar" minus 29 bytes.
923
924 Such a packet may be represented as follows (not to scale)::
925
926  0                     >= 10 B           == 20 B
927  |                  |<--------->|     |<--------->|
928  |                  |           |     |           |
929  |-----|------|-----|-----|-----|-----|-----------|-----|------|
930  | ETH | IPv4 | UDP | ... | baz | foo | ......... | bar | .... |
931  |-----|------|-----|-----|-----|-----|-----------|-----|------|
932                           |                             |
933                           |<--------------------------->|
934                                       == 29 B
935
936 Note that matching subsequent pattern items would resume after "baz", not
937 "bar" since matching is always performed after the previous item of the
938 stack.
939
940 Item: ``ETH``
941 ^^^^^^^^^^^^^
942
943 Matches an Ethernet header.
944
945 The ``type`` field either stands for "EtherType" or "TPID" when followed by
946 so-called layer 2.5 pattern items such as ``RTE_FLOW_ITEM_TYPE_VLAN``. In
947 the latter case, ``type`` refers to that of the outer header, with the inner
948 EtherType/TPID provided by the subsequent pattern item. This is the same
949 order as on the wire.
950 If the ``type`` field contains a TPID value, then only tagged packets with the
951 specified TPID will match the pattern.
952 The field ``has_vlan`` can be used to match any type of tagged packets,
953 instead of using the ``type`` field.
954 If the ``type`` and ``has_vlan`` fields are not specified, then both tagged
955 and untagged packets will match the pattern.
956
957 - ``dst``: destination MAC.
958 - ``src``: source MAC.
959 - ``type``: EtherType or TPID.
960 - ``has_vlan``: packet header contains at least one VLAN.
961 - Default ``mask`` matches destination and source addresses only.
962
963 Item: ``VLAN``
964 ^^^^^^^^^^^^^^
965
966 Matches an 802.1Q/ad VLAN tag.
967
968 The corresponding standard outer EtherType (TPID) values are
969 ``RTE_ETHER_TYPE_VLAN`` or ``RTE_ETHER_TYPE_QINQ``. It can be overridden by the
970 preceding pattern item.
971 If a ``VLAN`` item is present in the pattern, then only tagged packets will
972 match the pattern.
973 The field ``has_more_vlan`` can be used to match any type of tagged packets,
974 instead of using the ``inner_type field``.
975 If the ``inner_type`` and ``has_more_vlan`` fields are not specified,
976 then any tagged packets will match the pattern.
977
978 - ``tci``: tag control information.
979 - ``inner_type``: inner EtherType or TPID.
980 - ``has_more_vlan``: packet header contains at least one more VLAN, after this VLAN.
981 - Default ``mask`` matches the VID part of TCI only (lower 12 bits).
982
983 Item: ``IPV4``
984 ^^^^^^^^^^^^^^
985
986 Matches an IPv4 header.
987
988 Note: IPv4 options are handled by dedicated pattern items.
989
990 - ``hdr``: IPv4 header definition (``rte_ip.h``).
991 - Default ``mask`` matches source and destination addresses only.
992
993 Item: ``IPV6``
994 ^^^^^^^^^^^^^^
995
996 Matches an IPv6 header.
997
998 Dedicated flags indicate if header contains specific extension headers.
999 To match on packets containing a specific extension header, an application
1000 should match on the dedicated flag set to 1.
1001 To match on packets not containing a specific extension header, an application
1002 should match on the dedicated flag clear to 0.
1003 In case application doesn't care about the existence of a specific extension
1004 header, it should not specify the dedicated flag for matching.
1005
1006 - ``hdr``: IPv6 header definition (``rte_ip.h``).
1007 - ``has_hop_ext``: header contains Hop-by-Hop Options extension header.
1008 - ``has_route_ext``: header contains Routing extension header.
1009 - ``has_frag_ext``: header contains Fragment extension header.
1010 - ``has_auth_ext``: header contains Authentication extension header.
1011 - ``has_esp_ext``: header contains Encapsulation Security Payload extension header.
1012 - ``has_dest_ext``: header contains Destination Options extension header.
1013 - ``has_mobil_ext``: header contains Mobility extension header.
1014 - ``has_hip_ext``: header contains Host Identity Protocol extension header.
1015 - ``has_shim6_ext``: header contains Shim6 Protocol extension header.
1016 - Default ``mask`` matches ``hdr`` source and destination addresses only.
1017
1018 Item: ``ICMP``
1019 ^^^^^^^^^^^^^^
1020
1021 Matches an ICMP header.
1022
1023 - ``hdr``: ICMP header definition (``rte_icmp.h``).
1024 - Default ``mask`` matches ICMP type and code only.
1025
1026 Item: ``UDP``
1027 ^^^^^^^^^^^^^
1028
1029 Matches a UDP header.
1030
1031 - ``hdr``: UDP header definition (``rte_udp.h``).
1032 - Default ``mask`` matches source and destination ports only.
1033
1034 Item: ``TCP``
1035 ^^^^^^^^^^^^^
1036
1037 Matches a TCP header.
1038
1039 - ``hdr``: TCP header definition (``rte_tcp.h``).
1040 - Default ``mask`` matches source and destination ports only.
1041
1042 Item: ``SCTP``
1043 ^^^^^^^^^^^^^^
1044
1045 Matches a SCTP header.
1046
1047 - ``hdr``: SCTP header definition (``rte_sctp.h``).
1048 - Default ``mask`` matches source and destination ports only.
1049
1050 Item: ``VXLAN``
1051 ^^^^^^^^^^^^^^^
1052
1053 Matches a VXLAN header (RFC 7348).
1054
1055 - ``flags``: normally 0x08 (I flag).
1056 - ``rsvd0``: reserved, normally 0x000000.
1057 - ``vni``: VXLAN network identifier.
1058 - ``rsvd1``: reserved, normally 0x00.
1059 - Default ``mask`` matches VNI only.
1060
1061 Item: ``E_TAG``
1062 ^^^^^^^^^^^^^^^
1063
1064 Matches an IEEE 802.1BR E-Tag header.
1065
1066 The corresponding standard outer EtherType (TPID) value is
1067 ``RTE_ETHER_TYPE_ETAG``. It can be overridden by the preceding pattern item.
1068
1069 - ``epcp_edei_in_ecid_b``: E-Tag control information (E-TCI), E-PCP (3b),
1070   E-DEI (1b), ingress E-CID base (12b).
1071 - ``rsvd_grp_ecid_b``: reserved (2b), GRP (2b), E-CID base (12b).
1072 - ``in_ecid_e``: ingress E-CID ext.
1073 - ``ecid_e``: E-CID ext.
1074 - ``inner_type``: inner EtherType or TPID.
1075 - Default ``mask`` simultaneously matches GRP and E-CID base.
1076
1077 Item: ``NVGRE``
1078 ^^^^^^^^^^^^^^^
1079
1080 Matches a NVGRE header (RFC 7637).
1081
1082 - ``c_k_s_rsvd0_ver``: checksum (1b), undefined (1b), key bit (1b),
1083   sequence number (1b), reserved 0 (9b), version (3b). This field must have
1084   value 0x2000 according to RFC 7637.
1085 - ``protocol``: protocol type (0x6558).
1086 - ``tni``: virtual subnet ID.
1087 - ``flow_id``: flow ID.
1088 - Default ``mask`` matches TNI only.
1089
1090 Item: ``MPLS``
1091 ^^^^^^^^^^^^^^
1092
1093 Matches a MPLS header.
1094
1095 - ``label_tc_s_ttl``: label, TC, Bottom of Stack and TTL.
1096 - Default ``mask`` matches label only.
1097
1098 Item: ``GRE``
1099 ^^^^^^^^^^^^^
1100
1101 Matches a GRE header.
1102
1103 - ``c_rsvd0_ver``: checksum, reserved 0 and version.
1104 - ``protocol``: protocol type.
1105 - Default ``mask`` matches protocol only.
1106
1107 Item: ``GRE_KEY``
1108 ^^^^^^^^^^^^^^^^^
1109
1110 Matches a GRE key field.
1111 This should be preceded by item ``GRE``.
1112
1113 - Value to be matched is a big-endian 32 bit integer.
1114 - When this item present it implicitly match K bit in default mask as "1"
1115
1116 Item: ``FUZZY``
1117 ^^^^^^^^^^^^^^^
1118
1119 Fuzzy pattern match, expect faster than default.
1120
1121 This is for device that support fuzzy match option. Usually a fuzzy match is
1122 fast but the cost is accuracy. i.e. Signature Match only match pattern's hash
1123 value, but it is possible two different patterns have the same hash value.
1124
1125 Matching accuracy level can be configured by threshold. Driver can divide the
1126 range of threshold and map to different accuracy levels that device support.
1127
1128 Threshold 0 means perfect match (no fuzziness), while threshold 0xffffffff
1129 means fuzziest match.
1130
1131 .. _table_rte_flow_item_fuzzy:
1132
1133 .. table:: FUZZY
1134
1135    +----------+---------------+--------------------------------------------------+
1136    | Field    |   Subfield    | Value                                            |
1137    +==========+===============+==================================================+
1138    | ``spec`` | ``threshold`` | 0 as perfect match, 0xffffffff as fuzziest match |
1139    +----------+---------------+--------------------------------------------------+
1140    | ``last`` | ``threshold`` | upper range value                                |
1141    +----------+---------------+--------------------------------------------------+
1142    | ``mask`` | ``threshold`` | bit-mask apply to "spec" and "last"              |
1143    +----------+---------------+--------------------------------------------------+
1144
1145 Usage example, fuzzy match a TCPv4 packets:
1146
1147 .. _table_rte_flow_item_fuzzy_example:
1148
1149 .. table:: Fuzzy matching
1150
1151    +-------+----------+
1152    | Index | Item     |
1153    +=======+==========+
1154    | 0     | FUZZY    |
1155    +-------+----------+
1156    | 1     | Ethernet |
1157    +-------+----------+
1158    | 2     | IPv4     |
1159    +-------+----------+
1160    | 3     | TCP      |
1161    +-------+----------+
1162    | 4     | END      |
1163    +-------+----------+
1164
1165 Item: ``GTP``, ``GTPC``, ``GTPU``
1166 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1167
1168 Matches a GTPv1 header.
1169
1170 Note: GTP, GTPC and GTPU use the same structure. GTPC and GTPU item
1171 are defined for a user-friendly API when creating GTP-C and GTP-U
1172 flow rules.
1173
1174 - ``v_pt_rsv_flags``: version (3b), protocol type (1b), reserved (1b),
1175   extension header flag (1b), sequence number flag (1b), N-PDU number
1176   flag (1b).
1177 - ``msg_type``: message type.
1178 - ``msg_len``: message length.
1179 - ``teid``: tunnel endpoint identifier.
1180 - Default ``mask`` matches teid only.
1181
1182 Item: ``ESP``
1183 ^^^^^^^^^^^^^
1184
1185 Matches an ESP header.
1186
1187 - ``hdr``: ESP header definition (``rte_esp.h``).
1188 - Default ``mask`` matches SPI only.
1189
1190 Item: ``GENEVE``
1191 ^^^^^^^^^^^^^^^^
1192
1193 Matches a GENEVE header.
1194
1195 - ``ver_opt_len_o_c_rsvd0``: version (2b), length of the options fields (6b),
1196   OAM packet (1b), critical options present (1b), reserved 0 (6b).
1197 - ``protocol``: protocol type.
1198 - ``vni``: virtual network identifier.
1199 - ``rsvd1``: reserved, normally 0x00.
1200 - Default ``mask`` matches VNI only.
1201
1202 Item: ``VXLAN-GPE``
1203 ^^^^^^^^^^^^^^^^^^^
1204
1205 Matches a VXLAN-GPE header (draft-ietf-nvo3-vxlan-gpe-05).
1206
1207 - ``flags``: normally 0x0C (I and P flags).
1208 - ``rsvd0``: reserved, normally 0x0000.
1209 - ``protocol``: protocol type.
1210 - ``vni``: VXLAN network identifier.
1211 - ``rsvd1``: reserved, normally 0x00.
1212 - Default ``mask`` matches VNI only.
1213
1214 Item: ``ARP_ETH_IPV4``
1215 ^^^^^^^^^^^^^^^^^^^^^^
1216
1217 Matches an ARP header for Ethernet/IPv4.
1218
1219 - ``hdr``: hardware type, normally 1.
1220 - ``pro``: protocol type, normally 0x0800.
1221 - ``hln``: hardware address length, normally 6.
1222 - ``pln``: protocol address length, normally 4.
1223 - ``op``: opcode (1 for request, 2 for reply).
1224 - ``sha``: sender hardware address.
1225 - ``spa``: sender IPv4 address.
1226 - ``tha``: target hardware address.
1227 - ``tpa``: target IPv4 address.
1228 - Default ``mask`` matches SHA, SPA, THA and TPA.
1229
1230 Item: ``IPV6_EXT``
1231 ^^^^^^^^^^^^^^^^^^
1232
1233 Matches the presence of any IPv6 extension header.
1234
1235 - ``next_hdr``: next header.
1236 - Default ``mask`` matches ``next_hdr``.
1237
1238 Normally preceded by any of:
1239
1240 - `Item: IPV6`_
1241 - `Item: IPV6_EXT`_
1242
1243 Item: ``IPV6_FRAG_EXT``
1244 ^^^^^^^^^^^^^^^^^^^^^^^
1245
1246 Matches the presence of IPv6 fragment extension header.
1247
1248 - ``hdr``: IPv6 fragment extension header definition (``rte_ip.h``).
1249
1250 Normally preceded by any of:
1251
1252 - `Item: IPV6`_
1253 - `Item: IPV6_EXT`_
1254
1255 Item: ``ICMP6``
1256 ^^^^^^^^^^^^^^^
1257
1258 Matches any ICMPv6 header.
1259
1260 - ``type``: ICMPv6 type.
1261 - ``code``: ICMPv6 code.
1262 - ``checksum``: ICMPv6 checksum.
1263 - Default ``mask`` matches ``type`` and ``code``.
1264
1265 Item: ``ICMP6_ND_NS``
1266 ^^^^^^^^^^^^^^^^^^^^^
1267
1268 Matches an ICMPv6 neighbor discovery solicitation.
1269
1270 - ``type``: ICMPv6 type, normally 135.
1271 - ``code``: ICMPv6 code, normally 0.
1272 - ``checksum``: ICMPv6 checksum.
1273 - ``reserved``: reserved, normally 0.
1274 - ``target_addr``: target address.
1275 - Default ``mask`` matches target address only.
1276
1277 Item: ``ICMP6_ND_NA``
1278 ^^^^^^^^^^^^^^^^^^^^^
1279
1280 Matches an ICMPv6 neighbor discovery advertisement.
1281
1282 - ``type``: ICMPv6 type, normally 136.
1283 - ``code``: ICMPv6 code, normally 0.
1284 - ``checksum``: ICMPv6 checksum.
1285 - ``rso_reserved``: route flag (1b), solicited flag (1b), override flag
1286   (1b), reserved (29b).
1287 - ``target_addr``: target address.
1288 - Default ``mask`` matches target address only.
1289
1290 Item: ``ICMP6_ND_OPT``
1291 ^^^^^^^^^^^^^^^^^^^^^^
1292
1293 Matches the presence of any ICMPv6 neighbor discovery option.
1294
1295 - ``type``: ND option type.
1296 - ``length``: ND option length.
1297 - Default ``mask`` matches type only.
1298
1299 Normally preceded by any of:
1300
1301 - `Item: ICMP6_ND_NA`_
1302 - `Item: ICMP6_ND_NS`_
1303 - `Item: ICMP6_ND_OPT`_
1304
1305 Item: ``ICMP6_ND_OPT_SLA_ETH``
1306 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1307
1308 Matches an ICMPv6 neighbor discovery source Ethernet link-layer address
1309 option.
1310
1311 - ``type``: ND option type, normally 1.
1312 - ``length``: ND option length, normally 1.
1313 - ``sla``: source Ethernet LLA.
1314 - Default ``mask`` matches source link-layer address only.
1315
1316 Normally preceded by any of:
1317
1318 - `Item: ICMP6_ND_NA`_
1319 - `Item: ICMP6_ND_OPT`_
1320
1321 Item: ``ICMP6_ND_OPT_TLA_ETH``
1322 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1323
1324 Matches an ICMPv6 neighbor discovery target Ethernet link-layer address
1325 option.
1326
1327 - ``type``: ND option type, normally 2.
1328 - ``length``: ND option length, normally 1.
1329 - ``tla``: target Ethernet LLA.
1330 - Default ``mask`` matches target link-layer address only.
1331
1332 Normally preceded by any of:
1333
1334 - `Item: ICMP6_ND_NS`_
1335 - `Item: ICMP6_ND_OPT`_
1336
1337 Item: ``META``
1338 ^^^^^^^^^^^^^^
1339
1340 Matches an application specific 32 bit metadata item.
1341
1342 - Default ``mask`` matches the specified metadata value.
1343
1344 Item: ``GTP_PSC``
1345 ^^^^^^^^^^^^^^^^^
1346
1347 Matches a GTP PDU extension header with type 0x85.
1348
1349 - ``pdu_type``: PDU type.
1350 - ``qfi``: QoS flow identifier.
1351 - Default ``mask`` matches QFI only.
1352
1353 Item: ``PPPOES``, ``PPPOED``
1354 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1355
1356 Matches a PPPoE header.
1357
1358 - ``version_type``: version (4b), type (4b).
1359 - ``code``: message type.
1360 - ``session_id``: session identifier.
1361 - ``length``: payload length.
1362
1363 Item: ``PPPOE_PROTO_ID``
1364 ^^^^^^^^^^^^^^^^^^^^^^^^
1365
1366 Matches a PPPoE session protocol identifier.
1367
1368 - ``proto_id``: PPP protocol identifier.
1369 - Default ``mask`` matches proto_id only.
1370
1371 Item: ``NSH``
1372 ^^^^^^^^^^^^^
1373
1374 Matches a network service header (RFC 8300).
1375
1376 - ``version``: normally 0x0 (2 bits).
1377 - ``oam_pkt``: indicate oam packet (1 bit).
1378 - ``reserved``: reserved bit (1 bit).
1379 - ``ttl``: maximum SFF hopes (6 bits).
1380 - ``length``: total length in 4 bytes words (6 bits).
1381 - ``reserved1``: reserved1 bits (4 bits).
1382 - ``mdtype``: indicates format of NSH header (4 bits).
1383 - ``next_proto``: indicates protocol type of encap data (8 bits).
1384 - ``spi``: service path identifier (3 bytes).
1385 - ``sindex``: service index (1 byte).
1386 - Default ``mask`` matches mdtype, next_proto, spi, sindex.
1387
1388
1389 Item: ``IGMP``
1390 ^^^^^^^^^^^^^^
1391
1392 Matches a Internet Group Management Protocol (RFC 2236).
1393
1394 - ``type``: IGMP message type (Query/Report).
1395 - ``max_resp_time``: max time allowed before sending report.
1396 - ``checksum``: checksum, 1s complement of whole IGMP message.
1397 - ``group_addr``: group address, for Query value will be 0.
1398 - Default ``mask`` matches group_addr.
1399
1400
1401 Item: ``AH``
1402 ^^^^^^^^^^^^
1403
1404 Matches a IP Authentication Header (RFC 4302).
1405
1406 - ``next_hdr``: next payload after AH.
1407 - ``payload_len``: total length of AH in 4B words.
1408 - ``reserved``: reserved bits.
1409 - ``spi``: security parameters index.
1410 - ``seq_num``: counter value increased by 1 on each packet sent.
1411 - Default ``mask`` matches spi.
1412
1413 Item: ``HIGIG2``
1414 ^^^^^^^^^^^^^^^^^
1415
1416 Matches a HIGIG2 header field. It is layer 2.5 protocol and used in
1417 Broadcom switches.
1418
1419 - Default ``mask`` matches classification and vlan.
1420
1421 Item: ``L2TPV3OIP``
1422 ^^^^^^^^^^^^^^^^^^^
1423
1424 Matches a L2TPv3 over IP header.
1425
1426 - ``session_id``: L2TPv3 over IP session identifier.
1427 - Default ``mask`` matches session_id only.
1428
1429 Item: ``PFCP``
1430 ^^^^^^^^^^^^^^
1431
1432 Matches a PFCP Header.
1433
1434 - ``s_field``: S field.
1435 - ``msg_type``: message type.
1436 - ``msg_len``: message length.
1437 - ``seid``: session endpoint identifier.
1438 - Default ``mask`` matches s_field and seid.
1439
1440 Item: ``ECPRI``
1441 ^^^^^^^^^^^^^^^
1442
1443 Matches a eCPRI header.
1444
1445 - ``hdr``: eCPRI header definition (``rte_ecpri.h``).
1446 - Default ``mask`` matches nothing, for all eCPRI messages.
1447
1448 Item: ``PACKET_INTEGRITY_CHECKS``
1449 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1450
1451 Matches packet integrity.
1452 For some devices application needs to enable integration checks in HW
1453 before using this item.
1454
1455 - ``level``: the encapsulation level that should be checked:
1456    - ``level == 0`` means the default PMD mode (can be inner most / outermost).
1457    - ``level == 1`` means outermost header.
1458    - ``level > 1``  means inner header. See also RSS level.
1459 - ``packet_ok``: All HW packet integrity checks have passed based on the
1460   topmost network layer. For example, for ICMP packet the topmost network
1461   layer is L3 and for TCP or UDP packet the topmost network layer is L4.
1462 - ``l2_ok``: all layer 2 HW integrity checks passed.
1463 - ``l3_ok``: all layer 3 HW integrity checks passed.
1464 - ``l4_ok``: all layer 4 HW integrity checks passed.
1465 - ``l2_crc_ok``: layer 2 CRC check passed.
1466 - ``ipv4_csum_ok``: IPv4 checksum check passed.
1467 - ``l4_csum_ok``: layer 4 checksum check passed.
1468 - ``l3_len_ok``: the layer 3 length is smaller than the frame length.
1469
1470 Item: ``CONNTRACK``
1471 ^^^^^^^^^^^^^^^^^^^
1472
1473 Matches a conntrack state after conntrack action.
1474
1475 - ``flags``: conntrack packet state flags.
1476 - Default ``mask`` matches all state bits.
1477
1478 Item: ``PORT_REPRESENTOR``
1479 ^^^^^^^^^^^^^^^^^^^^^^^^^^
1480
1481 Matches traffic entering the embedded switch from the given ethdev.
1482
1483 Term **ethdev** and the concept of **port representor** are synonymous.
1484 The **represented port** is an *entity* plugged to the embedded switch
1485 at the opposite end of the "wire" leading to the ethdev.
1486
1487 ::
1488
1489     .--------------------.
1490     |  PORT_REPRESENTOR  |  Ethdev (Application Port Referred to by its ID)
1491     '--------------------'
1492               ||
1493               \/
1494       .----------------.
1495       |  Logical Port  |
1496       '----------------'
1497               ||
1498               ||
1499               ||
1500               \/
1501          .----------.
1502          |  Switch  |
1503          '----------'
1504               :
1505                :
1506               :
1507                :
1508       .----------------.
1509       |  Logical Port  |
1510       '----------------'
1511               :
1512                :
1513     .--------------------.
1514     |  REPRESENTED_PORT  |  Net / Guest / Another Ethdev (Same Application)
1515     '--------------------'
1516
1517
1518 - Incompatible with `Attribute: Traffic direction`_.
1519 - Requires `Attribute: Transfer`_.
1520
1521 .. _table_rte_flow_item_ethdev:
1522
1523 .. table:: ``struct rte_flow_item_ethdev``
1524
1525    +----------+-------------+---------------------------+
1526    | Field    | Subfield    | Value                     |
1527    +==========+=============+===========================+
1528    | ``spec`` | ``port_id`` | ethdev port ID            |
1529    +----------+-------------+---------------------------+
1530    | ``last`` | ``port_id`` | upper range value         |
1531    +----------+-------------+---------------------------+
1532    | ``mask`` | ``port_id`` | zeroed for wildcard match |
1533    +----------+-------------+---------------------------+
1534
1535 - Default ``mask`` provides exact match behaviour.
1536
1537 See also `Action: PORT_REPRESENTOR`_.
1538
1539 Item: ``REPRESENTED_PORT``
1540 ^^^^^^^^^^^^^^^^^^^^^^^^^^
1541
1542 Matches traffic entering the embedded switch from
1543 the entity represented by the given ethdev.
1544
1545 Term **ethdev** and the concept of **port representor** are synonymous.
1546 The **represented port** is an *entity* plugged to the embedded switch
1547 at the opposite end of the "wire" leading to the ethdev.
1548
1549 ::
1550
1551     .--------------------.
1552     |  PORT_REPRESENTOR  |  Ethdev (Application Port Referred to by its ID)
1553     '--------------------'
1554               :
1555                :
1556       .----------------.
1557       |  Logical Port  |
1558       '----------------'
1559               :
1560                :
1561               :
1562                :
1563          .----------.
1564          |  Switch  |
1565          '----------'
1566               /\
1567               ||
1568               ||
1569               ||
1570       .----------------.
1571       |  Logical Port  |
1572       '----------------'
1573               /\
1574               ||
1575     .--------------------.
1576     |  REPRESENTED_PORT  |  Net / Guest / Another Ethdev (Same Application)
1577     '--------------------'
1578
1579
1580 - Incompatible with `Attribute: Traffic direction`_.
1581 - Requires `Attribute: Transfer`_.
1582
1583 This item is meant to use the same structure as `Item: PORT_REPRESENTOR`_.
1584
1585 See also `Action: REPRESENTED_PORT`_.
1586
1587 Item: ``FLEX``
1588 ^^^^^^^^^^^^^^
1589
1590 Matches with the custom network protocol header that was created
1591 using rte_flow_flex_item_create() API. The application describes
1592 the desired header structure, defines the header fields attributes
1593 and header relations with preceding and following protocols and
1594 configures the ethernet devices accordingly via
1595 rte_flow_flex_item_create() routine.
1596
1597 - ``handle``: the flex item handle returned by the PMD on successful
1598   rte_flow_flex_item_create() call, mask for this field is ignored.
1599 - ``length``: match pattern length in bytes. If the length does not cover
1600   all fields defined in item configuration, the pattern spec and mask are
1601   considered by the driver as padded with trailing zeroes till the full
1602   configured item pattern length.
1603 - ``pattern``: pattern to match. The pattern is concatenation of bit fields
1604   configured at item creation. At configuration the fields are presented
1605   by sample_data array. The order of the bitfields is defined by the order
1606   of sample_data elements. The width of each bitfield is defined by the width
1607   specified in the corresponding sample_data element as well. If pattern
1608   length is smaller than configured fields overall length it is considered
1609   as padded with trailing zeroes up to full configured length, both for
1610   value and mask.
1611
1612 Item: ``L2TPV2``
1613 ^^^^^^^^^^^^^^^^^^^
1614
1615 Matches a L2TPv2 header.
1616
1617 - ``flags_version``: flags(12b), version(4b).
1618 - ``length``: total length of the message.
1619 - ``tunnel_id``: identifier for the control connection.
1620 - ``session_id``: identifier for a session within a tunnel.
1621 - ``ns``: sequence number for this date or control message.
1622 - ``nr``: sequence number expected in the next control message to be received.
1623 - ``offset_size``: offset of payload data.
1624 - ``offset_padding``: offset padding, variable length.
1625 - Default ``mask`` matches flags_version only.
1626
1627 Item: ``PPP``
1628 ^^^^^^^^^^^^^^^^^^^
1629
1630 Matches a PPP header.
1631
1632 - ``addr``: PPP address.
1633 - ``ctrl``: PPP control.
1634 - ``proto_id``: PPP protocol identifier.
1635 - Default ``mask`` matches addr, ctrl, proto_id.
1636
1637 Actions
1638 ~~~~~~~
1639
1640 Each possible action is represented by a type.
1641 An action can have an associated configuration object.
1642 Several actions combined in a list can be assigned
1643 to a flow rule and are performed in order.
1644
1645 They fall in three categories:
1646
1647 - Actions that modify the fate of matching traffic, for instance by dropping
1648   or assigning it a specific destination.
1649
1650 - Actions that modify matching traffic contents or its properties. This
1651   includes adding/removing encapsulation, encryption, compression and marks.
1652
1653 - Actions related to the flow rule itself, such as updating counters or
1654   making it non-terminating.
1655
1656 Flow rules being terminating by default, not specifying any action of the
1657 fate kind results in undefined behavior. This applies to both ingress and
1658 egress.
1659
1660 PASSTHRU, when supported, makes a flow rule non-terminating.
1661
1662 Like matching patterns, action lists are terminated by END items.
1663
1664 Example of action that redirects packets to queue index 10:
1665
1666 .. _table_rte_flow_action_example:
1667
1668 .. table:: Queue action
1669
1670    +-----------+-------+
1671    | Field     | Value |
1672    +===========+=======+
1673    | ``index`` | 10    |
1674    +-----------+-------+
1675
1676 Actions are performed in list order:
1677
1678 .. _table_rte_flow_count_then_drop:
1679
1680 .. table:: Count then drop
1681
1682    +-------+--------+
1683    | Index | Action |
1684    +=======+========+
1685    | 0     | COUNT  |
1686    +-------+--------+
1687    | 1     | DROP   |
1688    +-------+--------+
1689    | 2     | END    |
1690    +-------+--------+
1691
1692 |
1693
1694 .. _table_rte_flow_mark_count_redirect:
1695
1696 .. table:: Mark, count then redirect
1697
1698    +-------+--------+------------+-------+
1699    | Index | Action | Field      | Value |
1700    +=======+========+============+=======+
1701    | 0     | MARK   | ``mark``   | 0x2a  |
1702    +-------+--------+------------+-------+
1703    | 1     | COUNT  | ``id``     | 0     |
1704    +-------+--------+------------+-------+
1705    | 2     | QUEUE  | ``queue``  | 10    |
1706    +-------+--------+------------+-------+
1707    | 3     | END                         |
1708    +-------+-----------------------------+
1709
1710 |
1711
1712 .. _table_rte_flow_redirect_queue_5:
1713
1714 .. table:: Redirect to queue 5
1715
1716    +-------+--------+-----------+-------+
1717    | Index | Action | Field     | Value |
1718    +=======+========+===========+=======+
1719    | 0     | DROP                       |
1720    +-------+--------+-----------+-------+
1721    | 1     | QUEUE  | ``queue`` | 5     |
1722    +-------+--------+-----------+-------+
1723    | 2     | END                        |
1724    +-------+----------------------------+
1725
1726 In the above example, while DROP and QUEUE must be performed in order, both
1727 have to happen before reaching END. Only QUEUE has a visible effect.
1728
1729 Note that such a list may be thought as ambiguous and rejected on that
1730 basis.
1731
1732 .. _table_rte_flow_redirect_queue_5_3:
1733
1734 .. table:: Redirect to queues 5 and 3
1735
1736    +-------+--------+-----------+-------+
1737    | Index | Action | Field     | Value |
1738    +=======+========+===========+=======+
1739    | 0     | QUEUE  | ``queue`` | 5     |
1740    +-------+--------+-----------+-------+
1741    | 1     | VOID                       |
1742    +-------+--------+-----------+-------+
1743    | 2     | QUEUE  | ``queue`` | 3     |
1744    +-------+--------+-----------+-------+
1745    | 3     | END                        |
1746    +-------+----------------------------+
1747
1748 As previously described, all actions must be taken into account. This
1749 effectively duplicates traffic to both queues. The above example also shows
1750 that VOID is ignored.
1751
1752 Action types
1753 ~~~~~~~~~~~~
1754
1755 Common action types are described in this section.
1756
1757 Action: ``END``
1758 ^^^^^^^^^^^^^^^
1759
1760 End marker for action lists. Prevents further processing of actions, thereby
1761 ending the list.
1762
1763 - Its numeric value is 0 for convenience.
1764 - PMD support is mandatory.
1765 - No configurable properties.
1766
1767 .. _table_rte_flow_action_end:
1768
1769 .. table:: END
1770
1771    +---------------+
1772    | Field         |
1773    +===============+
1774    | no properties |
1775    +---------------+
1776
1777 Action: ``VOID``
1778 ^^^^^^^^^^^^^^^^
1779
1780 Used as a placeholder for convenience. It is ignored and simply discarded by
1781 PMDs.
1782
1783 - PMD support is mandatory.
1784 - No configurable properties.
1785
1786 .. _table_rte_flow_action_void:
1787
1788 .. table:: VOID
1789
1790    +---------------+
1791    | Field         |
1792    +===============+
1793    | no properties |
1794    +---------------+
1795
1796 Action: ``PASSTHRU``
1797 ^^^^^^^^^^^^^^^^^^^^
1798
1799 Leaves traffic up for additional processing by subsequent flow rules; makes
1800 a flow rule non-terminating.
1801
1802 - No configurable properties.
1803
1804 .. _table_rte_flow_action_passthru:
1805
1806 .. table:: PASSTHRU
1807
1808    +---------------+
1809    | Field         |
1810    +===============+
1811    | no properties |
1812    +---------------+
1813
1814 Example to copy a packet to a queue and continue processing by subsequent
1815 flow rules:
1816
1817 .. _table_rte_flow_action_passthru_example:
1818
1819 .. table:: Copy to queue 8
1820
1821    +-------+--------+-----------+-------+
1822    | Index | Action | Field     | Value |
1823    +=======+========+===========+=======+
1824    | 0     | PASSTHRU                   |
1825    +-------+--------+-----------+-------+
1826    | 1     | QUEUE  | ``queue`` | 8     |
1827    +-------+--------+-----------+-------+
1828    | 2     | END                        |
1829    +-------+----------------------------+
1830
1831 Action: ``JUMP``
1832 ^^^^^^^^^^^^^^^^
1833
1834 Redirects packets to a group on the current device.
1835
1836 In a hierarchy of groups, which can be used to represent physical or logical
1837 flow group/tables on the device, this action redirects the matched flow to
1838 the specified group on that device.
1839
1840 If a matched flow is redirected to a table which doesn't contain a matching
1841 rule for that flow then the behavior is undefined and the resulting behavior
1842 is up to the specific device. Best practice when using groups would be define
1843 a default flow rule for each group which a defines the default actions in that
1844 group so a consistent behavior is defined.
1845
1846 Defining an action for matched flow in a group to jump to a group which is
1847 higher in the group hierarchy may not be supported by physical devices,
1848 depending on how groups are mapped to the physical devices. In the
1849 definitions of jump actions, applications should be aware that it may be
1850 possible to define flow rules which trigger an undefined behavior causing
1851 flows to loop between groups.
1852
1853 .. _table_rte_flow_action_jump:
1854
1855 .. table:: JUMP
1856
1857    +-----------+------------------------------+
1858    | Field     | Value                        |
1859    +===========+==============================+
1860    | ``group`` | Group to redirect packets to |
1861    +-----------+------------------------------+
1862
1863 Action: ``MARK``
1864 ^^^^^^^^^^^^^^^^
1865
1866 Attaches an integer value to packets and sets ``RTE_MBUF_F_RX_FDIR`` and
1867 ``RTE_MBUF_F_RX_FDIR_ID`` mbuf flags.
1868
1869 This value is arbitrary and application-defined. Maximum allowed value
1870 depends on the underlying implementation. It is returned in the
1871 ``hash.fdir.hi`` mbuf field.
1872
1873 .. _table_rte_flow_action_mark:
1874
1875 .. table:: MARK
1876
1877    +--------+--------------------------------------+
1878    | Field  | Value                                |
1879    +========+======================================+
1880    | ``id`` | integer value to return with packets |
1881    +--------+--------------------------------------+
1882
1883 Action: ``FLAG``
1884 ^^^^^^^^^^^^^^^^
1885
1886 Flags packets. Similar to `Action: MARK`_ without a specific value; only
1887 sets the ``RTE_MBUF_F_RX_FDIR`` mbuf flag.
1888
1889 - No configurable properties.
1890
1891 .. _table_rte_flow_action_flag:
1892
1893 .. table:: FLAG
1894
1895    +---------------+
1896    | Field         |
1897    +===============+
1898    | no properties |
1899    +---------------+
1900
1901 Action: ``QUEUE``
1902 ^^^^^^^^^^^^^^^^^
1903
1904 Assigns packets to a given queue index.
1905
1906 .. _table_rte_flow_action_queue:
1907
1908 .. table:: QUEUE
1909
1910    +-----------+--------------------+
1911    | Field     | Value              |
1912    +===========+====================+
1913    | ``index`` | queue index to use |
1914    +-----------+--------------------+
1915
1916 Action: ``DROP``
1917 ^^^^^^^^^^^^^^^^
1918
1919 Drop packets.
1920
1921 - No configurable properties.
1922
1923 .. _table_rte_flow_action_drop:
1924
1925 .. table:: DROP
1926
1927    +---------------+
1928    | Field         |
1929    +===============+
1930    | no properties |
1931    +---------------+
1932
1933 Action: ``COUNT``
1934 ^^^^^^^^^^^^^^^^^
1935
1936 Adds a counter action to a matched flow.
1937
1938 If more than one count action is specified in a single flow rule, then each
1939 action must specify a unique id.
1940
1941 Counters can be retrieved and reset through ``rte_flow_query()``, see
1942 ``struct rte_flow_query_count``.
1943
1944 For ports within the same switch domain then the counter id namespace extends
1945 to all ports within that switch domain.
1946
1947 .. _table_rte_flow_action_count:
1948
1949 .. table:: COUNT
1950
1951    +------------+---------------------------------+
1952    | Field      | Value                           |
1953    +============+=================================+
1954    | ``id``     | counter id                      |
1955    +------------+---------------------------------+
1956
1957 Query structure to retrieve and reset flow rule counters:
1958
1959 .. _table_rte_flow_query_count:
1960
1961 .. table:: COUNT query
1962
1963    +---------------+-----+-----------------------------------+
1964    | Field         | I/O | Value                             |
1965    +===============+=====+===================================+
1966    | ``reset``     | in  | reset counter after query         |
1967    +---------------+-----+-----------------------------------+
1968    | ``hits_set``  | out | ``hits`` field is set             |
1969    +---------------+-----+-----------------------------------+
1970    | ``bytes_set`` | out | ``bytes`` field is set            |
1971    +---------------+-----+-----------------------------------+
1972    | ``hits``      | out | number of hits for this rule      |
1973    +---------------+-----+-----------------------------------+
1974    | ``bytes``     | out | number of bytes through this rule |
1975    +---------------+-----+-----------------------------------+
1976
1977 Action: ``RSS``
1978 ^^^^^^^^^^^^^^^
1979
1980 Similar to QUEUE, except RSS is additionally performed on packets to spread
1981 them among several queues according to the provided parameters.
1982
1983 Unlike global RSS settings used by other DPDK APIs, unsetting the ``types``
1984 field does not disable RSS in a flow rule. Doing so instead requests safe
1985 unspecified "best-effort" settings from the underlying PMD, which depending
1986 on the flow rule, may result in anything ranging from empty (single queue)
1987 to all-inclusive RSS.
1988
1989 If non-applicable for matching packets RSS types are requested,
1990 these RSS types are simply ignored. For example, it happens if:
1991
1992 - Hashing of both TCP and UDP ports is requested
1993   (only one can be present in a packet).
1994
1995 - Requested RSS types contradict to flow rule pattern
1996   (e.g. pattern has UDP item, but RSS types contain TCP).
1997
1998 If requested RSS hash types are not supported by the Ethernet device at all
1999 (not reported in ``dev_info.flow_type_rss_offloads``),
2000 the flow creation will fail.
2001
2002 Note: RSS hash result is stored in the ``hash.rss`` mbuf field which
2003 overlaps ``hash.fdir.lo``. Since `Action: MARK`_ sets the ``hash.fdir.hi``
2004 field only, both can be requested simultaneously.
2005
2006 Also, regarding packet encapsulation ``level``:
2007
2008 - ``0`` requests the default behavior. Depending on the packet type, it can
2009   mean outermost, innermost, anything in between or even no RSS.
2010
2011   It basically stands for the innermost encapsulation level RSS can be
2012   performed on according to PMD and device capabilities.
2013
2014 - ``1`` requests RSS to be performed on the outermost packet encapsulation
2015   level.
2016
2017 - ``2`` and subsequent values request RSS to be performed on the specified
2018    inner packet encapsulation level, from outermost to innermost (lower to
2019    higher values).
2020
2021 Values other than ``0`` are not necessarily supported.
2022
2023 Requesting a specific RSS level on unrecognized traffic results in undefined
2024 behavior. For predictable results, it is recommended to make the flow rule
2025 pattern match packet headers up to the requested encapsulation level so that
2026 only matching traffic goes through.
2027
2028 .. _table_rte_flow_action_rss:
2029
2030 .. table:: RSS
2031
2032    +---------------+-------------------------------------------------+
2033    | Field         | Value                                           |
2034    +===============+=================================================+
2035    | ``func``      | RSS hash function to apply                      |
2036    +---------------+-------------------------------------------------+
2037    | ``level``     | encapsulation level for ``types``               |
2038    +---------------+-------------------------------------------------+
2039    | ``types``     | specific RSS hash types (see ``RTE_ETH_RSS_*``) |
2040    +---------------+-------------------------------------------------+
2041    | ``key_len``   | hash key length in bytes                        |
2042    +---------------+-------------------------------------------------+
2043    | ``queue_num`` | number of entries in ``queue``                  |
2044    +---------------+-------------------------------------------------+
2045    | ``key``       | hash key                                        |
2046    +---------------+-------------------------------------------------+
2047    | ``queue``     | queue indices to use                            |
2048    +---------------+-------------------------------------------------+
2049
2050 Action: ``PF``
2051 ^^^^^^^^^^^^^^
2052
2053 This action is deprecated. Consider:
2054  - `Action: PORT_REPRESENTOR`_
2055  - `Action: REPRESENTED_PORT`_
2056
2057 Directs matching traffic to the physical function (PF) of the current
2058 device.
2059
2060 See `Item: PF`_.
2061
2062 - No configurable properties.
2063
2064 .. _table_rte_flow_action_pf:
2065
2066 .. table:: PF
2067
2068    +---------------+
2069    | Field         |
2070    +===============+
2071    | no properties |
2072    +---------------+
2073
2074 Action: ``VF``
2075 ^^^^^^^^^^^^^^
2076
2077 This action is deprecated. Consider:
2078  - `Action: PORT_REPRESENTOR`_
2079  - `Action: REPRESENTED_PORT`_
2080
2081 Directs matching traffic to a given virtual function of the current device.
2082
2083 Packets matched by a VF pattern item can be redirected to their original VF
2084 ID instead of the specified one. This parameter may not be available and is
2085 not guaranteed to work properly if the VF part is matched by a prior flow
2086 rule or if packets are not addressed to a VF in the first place.
2087
2088 See `Item: VF`_.
2089
2090 .. _table_rte_flow_action_vf:
2091
2092 .. table:: VF
2093
2094    +--------------+--------------------------------+
2095    | Field        | Value                          |
2096    +==============+================================+
2097    | ``original`` | use original VF ID if possible |
2098    +--------------+--------------------------------+
2099    | ``id``       | VF ID                          |
2100    +--------------+--------------------------------+
2101
2102 Action: ``PHY_PORT``
2103 ^^^^^^^^^^^^^^^^^^^^
2104
2105 This action is deprecated. Consider:
2106  - `Action: PORT_REPRESENTOR`_
2107  - `Action: REPRESENTED_PORT`_
2108
2109 Directs matching traffic to a given physical port index of the underlying
2110 device.
2111
2112 See `Item: PHY_PORT`_.
2113
2114 .. _table_rte_flow_action_phy_port:
2115
2116 .. table:: PHY_PORT
2117
2118    +--------------+-------------------------------------+
2119    | Field        | Value                               |
2120    +==============+=====================================+
2121    | ``original`` | use original port index if possible |
2122    +--------------+-------------------------------------+
2123    | ``index``    | physical port index                 |
2124    +--------------+-------------------------------------+
2125
2126 Action: ``PORT_ID``
2127 ^^^^^^^^^^^^^^^^^^^
2128 This action is deprecated. Consider:
2129  - `Action: PORT_REPRESENTOR`_
2130  - `Action: REPRESENTED_PORT`_
2131
2132 Directs matching traffic to a given DPDK port ID.
2133
2134 See `Item: PORT_ID`_.
2135
2136 .. _table_rte_flow_action_port_id:
2137
2138 .. table:: PORT_ID
2139
2140    +--------------+---------------------------------------+
2141    | Field        | Value                                 |
2142    +==============+=======================================+
2143    | ``original`` | use original DPDK port ID if possible |
2144    +--------------+---------------------------------------+
2145    | ``id``       | DPDK port ID                          |
2146    +--------------+---------------------------------------+
2147
2148 Action: ``METER``
2149 ^^^^^^^^^^^^^^^^^
2150
2151 Applies a stage of metering and policing.
2152
2153 The metering and policing (MTR) object has to be first created using the
2154 rte_mtr_create() API function. The ID of the MTR object is specified as
2155 action parameter. More than one flow can use the same MTR object through
2156 the meter action. The MTR object can be further updated or queried using
2157 the rte_mtr* API.
2158
2159 .. _table_rte_flow_action_meter:
2160
2161 .. table:: METER
2162
2163    +--------------+---------------+
2164    | Field        | Value         |
2165    +==============+===============+
2166    | ``mtr_id``   | MTR object ID |
2167    +--------------+---------------+
2168
2169 Action: ``SECURITY``
2170 ^^^^^^^^^^^^^^^^^^^^
2171
2172 Perform the security action on flows matched by the pattern items
2173 according to the configuration of the security session.
2174
2175 This action modifies the payload of matched flows. For INLINE_CRYPTO, the
2176 security protocol headers and IV are fully provided by the application as
2177 specified in the flow pattern. The payload of matching packets is
2178 encrypted on egress, and decrypted and authenticated on ingress.
2179 For INLINE_PROTOCOL, the security protocol is fully offloaded to HW,
2180 providing full encapsulation and decapsulation of packets in security
2181 protocols. The flow pattern specifies both the outer security header fields
2182 and the inner packet fields. The security session specified in the action
2183 must match the pattern parameters.
2184
2185 The security session specified in the action must be created on the same
2186 port as the flow action that is being specified.
2187
2188 The ingress/egress flow attribute should match that specified in the
2189 security session if the security session supports the definition of the
2190 direction.
2191
2192 Multiple flows can be configured to use the same security session.
2193
2194 .. _table_rte_flow_action_security:
2195
2196 .. table:: SECURITY
2197
2198    +----------------------+--------------------------------------+
2199    | Field                | Value                                |
2200    +======================+======================================+
2201    | ``security_session`` | security session to apply            |
2202    +----------------------+--------------------------------------+
2203
2204 The following is an example of configuring IPsec inline using the
2205 INLINE_CRYPTO security session:
2206
2207 The encryption algorithm, keys and salt are part of the opaque
2208 ``rte_security_session``. The SA is identified according to the IP and ESP
2209 fields in the pattern items.
2210
2211 .. _table_rte_flow_item_esp_inline_example:
2212
2213 .. table:: IPsec inline crypto flow pattern items.
2214
2215    +-------+----------+
2216    | Index | Item     |
2217    +=======+==========+
2218    | 0     | Ethernet |
2219    +-------+----------+
2220    | 1     | IPv4     |
2221    +-------+----------+
2222    | 2     | ESP      |
2223    +-------+----------+
2224    | 3     | END      |
2225    +-------+----------+
2226
2227 .. _table_rte_flow_action_esp_inline_example:
2228
2229 .. table:: IPsec inline flow actions.
2230
2231    +-------+----------+
2232    | Index | Action   |
2233    +=======+==========+
2234    | 0     | SECURITY |
2235    +-------+----------+
2236    | 1     | END      |
2237    +-------+----------+
2238
2239 Action: ``OF_SET_MPLS_TTL``
2240 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
2241 This action is deprecated. Consider `Action: MODIFY_FIELD`_.
2242
2243 Implements ``OFPAT_SET_MPLS_TTL`` ("MPLS TTL") as defined by the `OpenFlow
2244 Switch Specification`_.
2245
2246 .. _table_rte_flow_action_of_set_mpls_ttl:
2247
2248 .. table:: OF_SET_MPLS_TTL
2249
2250    +--------------+----------+
2251    | Field        | Value    |
2252    +==============+==========+
2253    | ``mpls_ttl`` | MPLS TTL |
2254    +--------------+----------+
2255
2256 Action: ``OF_DEC_MPLS_TTL``
2257 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
2258 This action is deprecated. Consider `Action: MODIFY_FIELD`_.
2259
2260 Implements ``OFPAT_DEC_MPLS_TTL`` ("decrement MPLS TTL") as defined by the
2261 `OpenFlow Switch Specification`_.
2262
2263 .. _table_rte_flow_action_of_dec_mpls_ttl:
2264
2265 .. table:: OF_DEC_MPLS_TTL
2266
2267    +---------------+
2268    | Field         |
2269    +===============+
2270    | no properties |
2271    +---------------+
2272
2273 Action: ``OF_SET_NW_TTL``
2274 ^^^^^^^^^^^^^^^^^^^^^^^^^
2275 This action is deprecated. Consider `Action: MODIFY_FIELD`_.
2276
2277 Implements ``OFPAT_SET_NW_TTL`` ("IP TTL") as defined by the `OpenFlow
2278 Switch Specification`_.
2279
2280 .. _table_rte_flow_action_of_set_nw_ttl:
2281
2282 .. table:: OF_SET_NW_TTL
2283
2284    +------------+--------+
2285    | Field      | Value  |
2286    +============+========+
2287    | ``nw_ttl`` | IP TTL |
2288    +------------+--------+
2289
2290 Action: ``OF_DEC_NW_TTL``
2291 ^^^^^^^^^^^^^^^^^^^^^^^^^
2292 This is a legacy action. Consider `Action: MODIFY_FIELD`_ as alternative.
2293
2294 Implements ``OFPAT_DEC_NW_TTL`` ("decrement IP TTL") as defined by the
2295 `OpenFlow Switch Specification`_.
2296
2297 .. _table_rte_flow_action_of_dec_nw_ttl:
2298
2299 .. table:: OF_DEC_NW_TTL
2300
2301    +---------------+
2302    | Field         |
2303    +===============+
2304    | no properties |
2305    +---------------+
2306
2307 Action: ``OF_COPY_TTL_OUT``
2308 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
2309 This action is deprecated. Consider `Action: MODIFY_FIELD`_.
2310
2311 Implements ``OFPAT_COPY_TTL_OUT`` ("copy TTL "outwards" -- from
2312 next-to-outermost to outermost") as defined by the `OpenFlow Switch
2313 Specification`_.
2314
2315 .. _table_rte_flow_action_of_copy_ttl_out:
2316
2317 .. table:: OF_COPY_TTL_OUT
2318
2319    +---------------+
2320    | Field         |
2321    +===============+
2322    | no properties |
2323    +---------------+
2324
2325 Action: ``OF_COPY_TTL_IN``
2326 ^^^^^^^^^^^^^^^^^^^^^^^^^^
2327 This action is deprecated. Consider `Action: MODIFY_FIELD`_.
2328
2329 Implements ``OFPAT_COPY_TTL_IN`` ("copy TTL "inwards" -- from outermost to
2330 next-to-outermost") as defined by the `OpenFlow Switch Specification`_.
2331
2332 .. _table_rte_flow_action_of_copy_ttl_in:
2333
2334 .. table:: OF_COPY_TTL_IN
2335
2336    +---------------+
2337    | Field         |
2338    +===============+
2339    | no properties |
2340    +---------------+
2341
2342 Action: ``OF_POP_VLAN``
2343 ^^^^^^^^^^^^^^^^^^^^^^^
2344
2345 Implements ``OFPAT_POP_VLAN`` ("pop the outer VLAN tag") as defined
2346 by the `OpenFlow Switch Specification`_.
2347
2348 .. _table_rte_flow_action_of_pop_vlan:
2349
2350 .. table:: OF_POP_VLAN
2351
2352    +---------------+
2353    | Field         |
2354    +===============+
2355    | no properties |
2356    +---------------+
2357
2358 Action: ``OF_PUSH_VLAN``
2359 ^^^^^^^^^^^^^^^^^^^^^^^^
2360
2361 Implements ``OFPAT_PUSH_VLAN`` ("push a new VLAN tag") as defined by the
2362 `OpenFlow Switch Specification`_.
2363
2364 .. _table_rte_flow_action_of_push_vlan:
2365
2366 .. table:: OF_PUSH_VLAN
2367
2368    +---------------+-----------+
2369    | Field         | Value     |
2370    +===============+===========+
2371    | ``ethertype`` | EtherType |
2372    +---------------+-----------+
2373
2374 Action: ``OF_SET_VLAN_VID``
2375 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
2376
2377 Implements ``OFPAT_SET_VLAN_VID`` ("set the 802.1q VLAN id") as defined by
2378 the `OpenFlow Switch Specification`_.
2379
2380 .. _table_rte_flow_action_of_set_vlan_vid:
2381
2382 .. table:: OF_SET_VLAN_VID
2383
2384    +--------------+---------+
2385    | Field        | Value   |
2386    +==============+=========+
2387    | ``vlan_vid`` | VLAN id |
2388    +--------------+---------+
2389
2390 Action: ``OF_SET_VLAN_PCP``
2391 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
2392
2393 Implements ``OFPAT_SET_LAN_PCP`` ("set the 802.1q priority") as defined by
2394 the `OpenFlow Switch Specification`_.
2395
2396 .. _table_rte_flow_action_of_set_vlan_pcp:
2397
2398 .. table:: OF_SET_VLAN_PCP
2399
2400    +--------------+---------------+
2401    | Field        | Value         |
2402    +==============+===============+
2403    | ``vlan_pcp`` | VLAN priority |
2404    +--------------+---------------+
2405
2406 Action: ``OF_POP_MPLS``
2407 ^^^^^^^^^^^^^^^^^^^^^^^
2408
2409 Implements ``OFPAT_POP_MPLS`` ("pop the outer MPLS tag") as defined by the
2410 `OpenFlow Switch Specification`_.
2411
2412 .. _table_rte_flow_action_of_pop_mpls:
2413
2414 .. table:: OF_POP_MPLS
2415
2416    +---------------+-----------+
2417    | Field         | Value     |
2418    +===============+===========+
2419    | ``ethertype`` | EtherType |
2420    +---------------+-----------+
2421
2422 Action: ``OF_PUSH_MPLS``
2423 ^^^^^^^^^^^^^^^^^^^^^^^^
2424
2425 Implements ``OFPAT_PUSH_MPLS`` ("push a new MPLS tag") as defined by the
2426 `OpenFlow Switch Specification`_.
2427
2428 .. _table_rte_flow_action_of_push_mpls:
2429
2430 .. table:: OF_PUSH_MPLS
2431
2432    +---------------+-----------+
2433    | Field         | Value     |
2434    +===============+===========+
2435    | ``ethertype`` | EtherType |
2436    +---------------+-----------+
2437
2438 Action: ``VXLAN_ENCAP``
2439 ^^^^^^^^^^^^^^^^^^^^^^^
2440
2441 Performs a VXLAN encapsulation action by encapsulating the matched flow in the
2442 VXLAN tunnel as defined in the``rte_flow_action_vxlan_encap`` flow items
2443 definition.
2444
2445 This action modifies the payload of matched flows. The flow definition specified
2446 in the ``rte_flow_action_tunnel_encap`` action structure must define a valid
2447 VLXAN network overlay which conforms with RFC 7348 (Virtual eXtensible Local
2448 Area Network (VXLAN): A Framework for Overlaying Virtualized Layer 2 Networks
2449 over Layer 3 Networks). The pattern must be terminated with the
2450 RTE_FLOW_ITEM_TYPE_END item type.
2451
2452 .. _table_rte_flow_action_vxlan_encap:
2453
2454 .. table:: VXLAN_ENCAP
2455
2456    +----------------+-------------------------------------+
2457    | Field          | Value                               |
2458    +================+=====================================+
2459    | ``definition`` | Tunnel end-point overlay definition |
2460    +----------------+-------------------------------------+
2461
2462 .. _table_rte_flow_action_vxlan_encap_example:
2463
2464 .. table:: IPv4 VxLAN flow pattern example.
2465
2466    +-------+----------+
2467    | Index | Item     |
2468    +=======+==========+
2469    | 0     | Ethernet |
2470    +-------+----------+
2471    | 1     | IPv4     |
2472    +-------+----------+
2473    | 2     | UDP      |
2474    +-------+----------+
2475    | 3     | VXLAN    |
2476    +-------+----------+
2477    | 4     | END      |
2478    +-------+----------+
2479
2480 Action: ``VXLAN_DECAP``
2481 ^^^^^^^^^^^^^^^^^^^^^^^
2482
2483 Performs a decapsulation action by stripping all headers of the VXLAN tunnel
2484 network overlay from the matched flow.
2485
2486 The flow items pattern defined for the flow rule with which a ``VXLAN_DECAP``
2487 action is specified, must define a valid VXLAN tunnel as per RFC7348. If the
2488 flow pattern does not specify a valid VXLAN tunnel then a
2489 RTE_FLOW_ERROR_TYPE_ACTION error should be returned.
2490
2491 This action modifies the payload of matched flows.
2492
2493 Action: ``NVGRE_ENCAP``
2494 ^^^^^^^^^^^^^^^^^^^^^^^
2495
2496 Performs a NVGRE encapsulation action by encapsulating the matched flow in the
2497 NVGRE tunnel as defined in the``rte_flow_action_tunnel_encap`` flow item
2498 definition.
2499
2500 This action modifies the payload of matched flows. The flow definition specified
2501 in the ``rte_flow_action_tunnel_encap`` action structure must defined a valid
2502 NVGRE network overlay which conforms with RFC 7637 (NVGRE: Network
2503 Virtualization Using Generic Routing Encapsulation). The pattern must be
2504 terminated with the RTE_FLOW_ITEM_TYPE_END item type.
2505
2506 .. _table_rte_flow_action_nvgre_encap:
2507
2508 .. table:: NVGRE_ENCAP
2509
2510    +----------------+-------------------------------------+
2511    | Field          | Value                               |
2512    +================+=====================================+
2513    | ``definition`` | NVGRE end-point overlay definition  |
2514    +----------------+-------------------------------------+
2515
2516 .. _table_rte_flow_action_nvgre_encap_example:
2517
2518 .. table:: IPv4 NVGRE flow pattern example.
2519
2520    +-------+----------+
2521    | Index | Item     |
2522    +=======+==========+
2523    | 0     | Ethernet |
2524    +-------+----------+
2525    | 1     | IPv4     |
2526    +-------+----------+
2527    | 2     | NVGRE    |
2528    +-------+----------+
2529    | 3     | END      |
2530    +-------+----------+
2531
2532 Action: ``NVGRE_DECAP``
2533 ^^^^^^^^^^^^^^^^^^^^^^^
2534
2535 Performs a decapsulation action by stripping all headers of the NVGRE tunnel
2536 network overlay from the matched flow.
2537
2538 The flow items pattern defined for the flow rule with which a ``NVGRE_DECAP``
2539 action is specified, must define a valid NVGRE tunnel as per RFC7637. If the
2540 flow pattern does not specify a valid NVGRE tunnel then a
2541 RTE_FLOW_ERROR_TYPE_ACTION error should be returned.
2542
2543 This action modifies the payload of matched flows.
2544
2545 Action: ``RAW_ENCAP``
2546 ^^^^^^^^^^^^^^^^^^^^^
2547
2548 Adds outer header whose template is provided in its data buffer,
2549 as defined in the ``rte_flow_action_raw_encap`` definition.
2550
2551 This action modifies the payload of matched flows. The data supplied must
2552 be a valid header, either holding layer 2 data in case of adding layer 2 after
2553 decap layer 3 tunnel (for example MPLSoGRE) or complete tunnel definition
2554 starting from layer 2 and moving to the tunnel item itself. When applied to
2555 the original packet the resulting packet must be a valid packet.
2556
2557 .. _table_rte_flow_action_raw_encap:
2558
2559 .. table:: RAW_ENCAP
2560
2561    +----------------+----------------------------------------+
2562    | Field          | Value                                  |
2563    +================+========================================+
2564    | ``data``       | Encapsulation data                     |
2565    +----------------+----------------------------------------+
2566    | ``preserve``   | Bit-mask of data to preserve on output |
2567    +----------------+----------------------------------------+
2568    | ``size``       | Size of data and preserve              |
2569    +----------------+----------------------------------------+
2570
2571 Action: ``RAW_DECAP``
2572 ^^^^^^^^^^^^^^^^^^^^^^^
2573
2574 Remove outer header whose template is provided in its data buffer,
2575 as defined in the ``rte_flow_action_raw_decap``
2576
2577 This action modifies the payload of matched flows. The data supplied must
2578 be a valid header, either holding layer 2 data in case of removing layer 2
2579 before encapsulation of layer 3 tunnel (for example MPLSoGRE) or complete
2580 tunnel definition starting from layer 2 and moving to the tunnel item itself.
2581 When applied to the original packet the resulting packet must be a
2582 valid packet.
2583
2584 .. _table_rte_flow_action_raw_decap:
2585
2586 .. table:: RAW_DECAP
2587
2588    +----------------+----------------------------------------+
2589    | Field          | Value                                  |
2590    +================+========================================+
2591    | ``data``       | Decapsulation data                     |
2592    +----------------+----------------------------------------+
2593    | ``size``       | Size of data                           |
2594    +----------------+----------------------------------------+
2595
2596 Action: ``SET_IPV4_SRC``
2597 ^^^^^^^^^^^^^^^^^^^^^^^^
2598 This is a legacy action. Consider `Action: MODIFY_FIELD`_ as alternative.
2599
2600 Set a new IPv4 source address in the outermost IPv4 header.
2601
2602 It must be used with a valid RTE_FLOW_ITEM_TYPE_IPV4 flow pattern item.
2603 Otherwise, RTE_FLOW_ERROR_TYPE_ACTION error will be returned.
2604
2605 .. _table_rte_flow_action_set_ipv4_src:
2606
2607 .. table:: SET_IPV4_SRC
2608
2609    +-----------------------------------------+
2610    | Field         | Value                   |
2611    +===============+=========================+
2612    | ``ipv4_addr`` | new IPv4 source address |
2613    +---------------+-------------------------+
2614
2615 Action: ``SET_IPV4_DST``
2616 ^^^^^^^^^^^^^^^^^^^^^^^^
2617 This is a legacy action. Consider `Action: MODIFY_FIELD`_ as alternative.
2618
2619 Set a new IPv4 destination address in the outermost IPv4 header.
2620
2621 It must be used with a valid RTE_FLOW_ITEM_TYPE_IPV4 flow pattern item.
2622 Otherwise, RTE_FLOW_ERROR_TYPE_ACTION error will be returned.
2623
2624 .. _table_rte_flow_action_set_ipv4_dst:
2625
2626 .. table:: SET_IPV4_DST
2627
2628    +---------------+------------------------------+
2629    | Field         | Value                        |
2630    +===============+==============================+
2631    | ``ipv4_addr`` | new IPv4 destination address |
2632    +---------------+------------------------------+
2633
2634 Action: ``SET_IPV6_SRC``
2635 ^^^^^^^^^^^^^^^^^^^^^^^^
2636 This is a legacy action. Consider `Action: MODIFY_FIELD`_ as alternative.
2637
2638 Set a new IPv6 source address in the outermost IPv6 header.
2639
2640 It must be used with a valid RTE_FLOW_ITEM_TYPE_IPV6 flow pattern item.
2641 Otherwise, RTE_FLOW_ERROR_TYPE_ACTION error will be returned.
2642
2643 .. _table_rte_flow_action_set_ipv6_src:
2644
2645 .. table:: SET_IPV6_SRC
2646
2647    +---------------+-------------------------+
2648    | Field         | Value                   |
2649    +===============+=========================+
2650    | ``ipv6_addr`` | new IPv6 source address |
2651    +---------------+-------------------------+
2652
2653 Action: ``SET_IPV6_DST``
2654 ^^^^^^^^^^^^^^^^^^^^^^^^
2655 This is a legacy action. Consider `Action: MODIFY_FIELD`_ as alternative.
2656
2657 Set a new IPv6 destination address in the outermost IPv6 header.
2658
2659 It must be used with a valid RTE_FLOW_ITEM_TYPE_IPV6 flow pattern item.
2660 Otherwise, RTE_FLOW_ERROR_TYPE_ACTION error will be returned.
2661
2662 .. _table_rte_flow_action_set_ipv6_dst:
2663
2664 .. table:: SET_IPV6_DST
2665
2666    +---------------+------------------------------+
2667    | Field         | Value                        |
2668    +===============+==============================+
2669    | ``ipv6_addr`` | new IPv6 destination address |
2670    +---------------+------------------------------+
2671
2672 Action: ``SET_TP_SRC``
2673 ^^^^^^^^^^^^^^^^^^^^^^^^^
2674 This is a legacy action. Consider `Action: MODIFY_FIELD`_ as alternative.
2675
2676 Set a new source port number in the outermost TCP/UDP header.
2677
2678 It must be used with a valid RTE_FLOW_ITEM_TYPE_TCP or RTE_FLOW_ITEM_TYPE_UDP
2679 flow pattern item. Otherwise, RTE_FLOW_ERROR_TYPE_ACTION error will be returned.
2680
2681 .. _table_rte_flow_action_set_tp_src:
2682
2683 .. table:: SET_TP_SRC
2684
2685    +----------+-------------------------+
2686    | Field    | Value                   |
2687    +==========+=========================+
2688    | ``port`` | new TCP/UDP source port |
2689    +---------------+--------------------+
2690
2691 Action: ``SET_TP_DST``
2692 ^^^^^^^^^^^^^^^^^^^^^^^^^
2693 This is a legacy action. Consider `Action: MODIFY_FIELD`_ as alternative.
2694
2695 Set a new destination port number in the outermost TCP/UDP header.
2696
2697 It must be used with a valid RTE_FLOW_ITEM_TYPE_TCP or RTE_FLOW_ITEM_TYPE_UDP
2698 flow pattern item. Otherwise, RTE_FLOW_ERROR_TYPE_ACTION error will be returned.
2699
2700 .. _table_rte_flow_action_set_tp_dst:
2701
2702 .. table:: SET_TP_DST
2703
2704    +----------+------------------------------+
2705    | Field    | Value                        |
2706    +==========+==============================+
2707    | ``port`` | new TCP/UDP destination port |
2708    +---------------+-------------------------+
2709
2710 Action: ``MAC_SWAP``
2711 ^^^^^^^^^^^^^^^^^^^^^^^^^
2712
2713 Swap the source and destination MAC addresses in the outermost Ethernet
2714 header.
2715
2716 It must be used with a valid RTE_FLOW_ITEM_TYPE_ETH flow pattern item.
2717 Otherwise, RTE_FLOW_ERROR_TYPE_ACTION error will be returned.
2718
2719 .. _table_rte_flow_action_mac_swap:
2720
2721 .. table:: MAC_SWAP
2722
2723    +---------------+
2724    | Field         |
2725    +===============+
2726    | no properties |
2727    +---------------+
2728
2729 Action: ``DEC_TTL``
2730 ^^^^^^^^^^^^^^^^^^^
2731 This is a legacy action. Consider `Action: MODIFY_FIELD`_ as alternative.
2732
2733 Decrease TTL value.
2734
2735 If there is no valid RTE_FLOW_ITEM_TYPE_IPV4 or RTE_FLOW_ITEM_TYPE_IPV6
2736 in pattern, Some PMDs will reject rule because behavior will be undefined.
2737
2738 .. _table_rte_flow_action_dec_ttl:
2739
2740 .. table:: DEC_TTL
2741
2742    +---------------+
2743    | Field         |
2744    +===============+
2745    | no properties |
2746    +---------------+
2747
2748 Action: ``SET_TTL``
2749 ^^^^^^^^^^^^^^^^^^^
2750 This is a legacy action. Consider `Action: MODIFY_FIELD`_ as alternative.
2751
2752 Assigns a new TTL value.
2753
2754 If there is no valid RTE_FLOW_ITEM_TYPE_IPV4 or RTE_FLOW_ITEM_TYPE_IPV6
2755 in pattern, Some PMDs will reject rule because behavior will be undefined.
2756
2757 .. _table_rte_flow_action_set_ttl:
2758
2759 .. table:: SET_TTL
2760
2761    +---------------+--------------------+
2762    | Field         | Value              |
2763    +===============+====================+
2764    | ``ttl_value`` | new TTL value      |
2765    +---------------+--------------------+
2766
2767 Action: ``SET_MAC_SRC``
2768 ^^^^^^^^^^^^^^^^^^^^^^^
2769 This is a legacy action. Consider `Action: MODIFY_FIELD`_ as alternative.
2770
2771 Set source MAC address.
2772
2773 It must be used with a valid RTE_FLOW_ITEM_TYPE_ETH flow pattern item.
2774 Otherwise, RTE_FLOW_ERROR_TYPE_ACTION error will be returned.
2775
2776 .. _table_rte_flow_action_set_mac_src:
2777
2778 .. table:: SET_MAC_SRC
2779
2780    +--------------+---------------+
2781    | Field        | Value         |
2782    +==============+===============+
2783    | ``mac_addr`` | MAC address   |
2784    +--------------+---------------+
2785
2786 Action: ``SET_MAC_DST``
2787 ^^^^^^^^^^^^^^^^^^^^^^^
2788 This is a legacy action. Consider `Action: MODIFY_FIELD`_ as alternative.
2789
2790 Set destination MAC address.
2791
2792 It must be used with a valid RTE_FLOW_ITEM_TYPE_ETH flow pattern item.
2793 Otherwise, RTE_FLOW_ERROR_TYPE_ACTION error will be returned.
2794
2795 .. _table_rte_flow_action_set_mac_dst:
2796
2797 .. table:: SET_MAC_DST
2798
2799    +--------------+---------------+
2800    | Field        | Value         |
2801    +==============+===============+
2802    | ``mac_addr`` | MAC address   |
2803    +--------------+---------------+
2804
2805 Action: ``INC_TCP_SEQ``
2806 ^^^^^^^^^^^^^^^^^^^^^^^
2807 This is a legacy action. Consider `Action: MODIFY_FIELD`_ as alternative.
2808
2809 Increase sequence number in the outermost TCP header.
2810 Value to increase TCP sequence number by is a big-endian 32 bit integer.
2811
2812 Using this action on non-matching traffic will result in undefined behavior.
2813
2814 Action: ``DEC_TCP_SEQ``
2815 ^^^^^^^^^^^^^^^^^^^^^^^
2816 This is a legacy action. Consider `Action: MODIFY_FIELD`_ as alternative.
2817
2818 Decrease sequence number in the outermost TCP header.
2819 Value to decrease TCP sequence number by is a big-endian 32 bit integer.
2820
2821 Using this action on non-matching traffic will result in undefined behavior.
2822
2823 Action: ``INC_TCP_ACK``
2824 ^^^^^^^^^^^^^^^^^^^^^^^
2825 This is a legacy action. Consider `Action: MODIFY_FIELD`_ as alternative.
2826
2827 Increase acknowledgment number in the outermost TCP header.
2828 Value to increase TCP acknowledgment number by is a big-endian 32 bit integer.
2829
2830 Using this action on non-matching traffic will result in undefined behavior.
2831
2832 Action: ``DEC_TCP_ACK``
2833 ^^^^^^^^^^^^^^^^^^^^^^^
2834 This is a legacy action. Consider `Action: MODIFY_FIELD`_ as alternative.
2835
2836 Decrease acknowledgment number in the outermost TCP header.
2837 Value to decrease TCP acknowledgment number by is a big-endian 32 bit integer.
2838
2839 Using this action on non-matching traffic will result in undefined behavior.
2840
2841 Action: ``SET_TAG``
2842 ^^^^^^^^^^^^^^^^^^^
2843 This is a legacy action. Consider `Action: MODIFY_FIELD`_ as alternative.
2844
2845 Set Tag.
2846
2847 Tag is a transient data used during flow matching. This is not delivered to
2848 application. Multiple tags are supported by specifying index.
2849
2850 .. _table_rte_flow_action_set_tag:
2851
2852 .. table:: SET_TAG
2853
2854    +-----------+----------------------------+
2855    | Field     | Value                      |
2856    +===========+============================+
2857    | ``data``  | 32 bit tag value           |
2858    +-----------+----------------------------+
2859    | ``mask``  | bit-mask applies to "data" |
2860    +-----------+----------------------------+
2861    | ``index`` | index of tag to set        |
2862    +-----------+----------------------------+
2863
2864 Action: ``SET_META``
2865 ^^^^^^^^^^^^^^^^^^^^^^^
2866 This is a legacy action. Consider `Action: MODIFY_FIELD`_ as alternative.
2867
2868 Set metadata. Item ``META`` matches metadata.
2869
2870 Metadata set by mbuf metadata field with RTE_MBUF_DYNFLAG_TX_METADATA flag on egress
2871 will be overridden by this action. On ingress, the metadata will be carried by
2872 ``metadata`` dynamic field of ``rte_mbuf`` which can be accessed by
2873 ``RTE_FLOW_DYNF_METADATA()``. RTE_MBUF_DYNFLAG_RX_METADATA flag will be set along
2874 with the data.
2875
2876 The mbuf dynamic field must be registered by calling
2877 ``rte_flow_dynf_metadata_register()`` prior to use ``SET_META`` action.
2878
2879 Altering partial bits is supported with ``mask``. For bits which have never been
2880 set, unpredictable value will be seen depending on driver implementation. For
2881 loopback/hairpin packet, metadata set on Rx/Tx may or may not be propagated to
2882 the other path depending on HW capability.
2883
2884 In hairpin case with Tx explicit flow mode, metadata could (not mandatory) be
2885 used to connect the Rx and Tx flows if it can be propagated from Rx to Tx path.
2886
2887 .. _table_rte_flow_action_set_meta:
2888
2889 .. table:: SET_META
2890
2891    +----------+----------------------------+
2892    | Field    | Value                      |
2893    +==========+============================+
2894    | ``data`` | 32 bit metadata value      |
2895    +----------+----------------------------+
2896    | ``mask`` | bit-mask applies to "data" |
2897    +----------+----------------------------+
2898
2899 Action: ``SET_IPV4_DSCP``
2900 ^^^^^^^^^^^^^^^^^^^^^^^^^
2901 This is a legacy action. Consider `Action: MODIFY_FIELD`_ as alternative.
2902
2903 Set IPv4 DSCP.
2904
2905 Modify DSCP in IPv4 header.
2906
2907 It must be used with RTE_FLOW_ITEM_TYPE_IPV4 in pattern.
2908 Otherwise, RTE_FLOW_ERROR_TYPE_ACTION error will be returned.
2909
2910 .. _table_rte_flow_action_set_ipv4_dscp:
2911
2912 .. table:: SET_IPV4_DSCP
2913
2914    +-----------+---------------------------------+
2915    | Field     | Value                           |
2916    +===========+=================================+
2917    | ``dscp``  | DSCP in low 6 bits, rest ignore |
2918    +-----------+---------------------------------+
2919
2920 Action: ``SET_IPV6_DSCP``
2921 ^^^^^^^^^^^^^^^^^^^^^^^^^
2922 This is a legacy action. Consider `Action: MODIFY_FIELD`_ as alternative.
2923
2924 Set IPv6 DSCP.
2925
2926 Modify DSCP in IPv6 header.
2927
2928 It must be used with RTE_FLOW_ITEM_TYPE_IPV6 in pattern.
2929 Otherwise, RTE_FLOW_ERROR_TYPE_ACTION error will be returned.
2930
2931 .. _table_rte_flow_action_set_ipv6_dscp:
2932
2933 .. table:: SET_IPV6_DSCP
2934
2935    +-----------+---------------------------------+
2936    | Field     | Value                           |
2937    +===========+=================================+
2938    | ``dscp``  | DSCP in low 6 bits, rest ignore |
2939    +-----------+---------------------------------+
2940
2941 Action: ``AGE``
2942 ^^^^^^^^^^^^^^^
2943
2944 Set ageing timeout configuration to a flow.
2945
2946 Event RTE_ETH_EVENT_FLOW_AGED will be reported if
2947 timeout passed without any matching on the flow.
2948
2949 .. _table_rte_flow_action_age:
2950
2951 .. table:: AGE
2952
2953    +--------------+---------------------------------+
2954    | Field        | Value                           |
2955    +==============+=================================+
2956    | ``timeout``  | 24 bits timeout value           |
2957    +--------------+---------------------------------+
2958    | ``reserved`` | 8 bits reserved, must be zero   |
2959    +--------------+---------------------------------+
2960    | ``context``  | user input flow context         |
2961    +--------------+---------------------------------+
2962
2963 Query structure to retrieve ageing status information of a
2964 shared AGE action, or a flow rule using the AGE action:
2965
2966 .. _table_rte_flow_query_age:
2967
2968 .. table:: AGE query
2969
2970    +------------------------------+-----+----------------------------------------+
2971    | Field                        | I/O | Value                                  |
2972    +==============================+=====+========================================+
2973    | ``aged``                     | out | Aging timeout expired                  |
2974    +------------------------------+-----+----------------------------------------+
2975    | ``sec_since_last_hit_valid`` | out | ``sec_since_last_hit`` value is valid  |
2976    +------------------------------+-----+----------------------------------------+
2977    | ``sec_since_last_hit``       | out | Seconds since last traffic hit         |
2978    +------------------------------+-----+----------------------------------------+
2979
2980 Action: ``SAMPLE``
2981 ^^^^^^^^^^^^^^^^^^
2982
2983 Adds a sample action to a matched flow.
2984
2985 The matching packets will be duplicated with the specified ``ratio`` and
2986 applied with own set of actions with a fate action, the packets sampled
2987 equals is '1/ratio'. All the packets continue to the target destination.
2988
2989 When the ``ratio`` is set to 1 then the packets will be 100% mirrored.
2990 ``actions`` represent the different set of actions for the sampled or mirrored
2991 packets, and must have a fate action.
2992
2993 .. _table_rte_flow_action_sample:
2994
2995 .. table:: SAMPLE
2996
2997    +--------------+---------------------------------+
2998    | Field        | Value                           |
2999    +==============+=================================+
3000    | ``ratio``    | 32 bits sample ratio value      |
3001    +--------------+---------------------------------+
3002    | ``actions``  | sub-action list for sampling    |
3003    +--------------+---------------------------------+
3004
3005 Action: ``INDIRECT``
3006 ^^^^^^^^^^^^^^^^^^^^
3007
3008 Flow utilize indirect action by handle as returned from
3009 ``rte_flow_action_handle_create()``.
3010
3011 The behaviour of the indirect action defined by ``action`` argument of type
3012 ``struct rte_flow_action`` passed to ``rte_flow_action_handle_create()``.
3013
3014 The indirect action can be used by a single flow or shared among multiple flows.
3015 The indirect action can be in-place updated by ``rte_flow_action_handle_update()``
3016 without destroying flow and creating flow again. The fields that could be
3017 updated depend on the type of the ``action`` and different for every type.
3018
3019 The indirect action specified data (e.g. counter) can be queried by
3020 ``rte_flow_action_handle_query()``.
3021
3022 .. warning::
3023
3024    The following description of indirect action persistence
3025    is an experimental behavior that may change without a prior notice.
3026
3027 If ``RTE_ETH_DEV_CAPA_FLOW_SHARED_OBJECT_KEEP`` is not advertised,
3028 indirect actions cannot be created until the device is started for the first time
3029 and cannot be kept when the device is stopped.
3030 However, PMD also does not flush them automatically on stop,
3031 so the application must call ``rte_flow_action_handle_destroy()``
3032 before stopping the device to ensure no indirect actions remain.
3033
3034 If ``RTE_ETH_DEV_CAPA_FLOW_SHARED_OBJECT_KEEP`` is advertised,
3035 this means that the PMD can keep at least some indirect actions
3036 across device stop and start.
3037 However, ``rte_eth_dev_configure()`` may fail if any indirect actions remain,
3038 so the application must destroy them before attempting a reconfiguration.
3039 Keeping may be only supported for certain kinds of indirect actions.
3040 A kind is a combination of an action type and a value of its transfer bit.
3041 For example: an indirect counter with the transfer bit reset.
3042 To test if a particular kind of indirect actions is kept,
3043 the application must try to create a valid indirect action of that kind
3044 when the device is not started (either before the first start of after a stop).
3045 If it fails with an error of type ``RTE_FLOW_ERROR_TYPE_STATE``,
3046 application must destroy all indirect actions of this kind
3047 before stopping the device.
3048 If it succeeds, all indirect actions of the same kind are kept
3049 when the device is stopped.
3050 Indirect actions of a kept kind that are created when the device is stopped,
3051 including the ones created for the test, will be kept after the device start.
3052
3053 .. _table_rte_flow_action_handle:
3054
3055 .. table:: INDIRECT
3056
3057    +---------------+
3058    | Field         |
3059    +===============+
3060    | no properties |
3061    +---------------+
3062
3063 Action: ``MODIFY_FIELD``
3064 ^^^^^^^^^^^^^^^^^^^^^^^^
3065
3066 Modify ``dst`` field according to ``op`` selected (set, addition,
3067 subtraction) with ``width`` bits of data from ``src`` field.
3068
3069 Any arbitrary header field (as well as mark, metadata or tag values)
3070 can be used as both source and destination fields as set by ``field``.
3071 The immediate value ``RTE_FLOW_FIELD_VALUE`` (or a pointer to it
3072 ``RTE_FLOW_FIELD_POINTER``) is allowed as a source only.
3073 ``RTE_FLOW_FIELD_START`` is used to point to the beginning of a packet.
3074 See ``enum rte_flow_field_id`` for the list of supported fields.
3075
3076 ``op`` selects the operation to perform on a destination field.
3077 - ``set`` copies the data from ``src`` field to ``dst`` field.
3078 - ``add`` adds together ``dst`` and ``src`` and stores the result into ``dst``.
3079 - ``sub`` subtracts ``src`` from ``dst`` and stores the result into ``dst``
3080
3081 ``width`` defines a number of bits to use from ``src`` field.
3082
3083 ``level`` is used to access any packet field on any encapsulation level
3084 as well as any tag element in the tag array.
3085 - ``0`` means the default behaviour. Depending on the packet type, it can
3086 mean outermost, innermost or anything in between.
3087 - ``1`` requests access to the outermost packet encapsulation level.
3088 - ``2`` and subsequent values requests access to the specified packet
3089 encapsulation level, from outermost to innermost (lower to higher values).
3090 For the tag array (in case of multiple tags are supported and present)
3091 ``level`` translates directly into the array index.
3092
3093 ``offset`` specifies the number of bits to skip from a field's start.
3094 That allows performing a partial copy of the needed part or to divide a big
3095 packet field into multiple smaller fields. Alternatively, ``offset`` allows
3096 going past the specified packet field boundary to copy a field to an
3097 arbitrary place in a packet, essentially providing a way to copy any part of
3098 a packet to any other part of it.
3099
3100 ``value`` sets an immediate value to be used as a source or points to a
3101 location of the value in memory. It is used instead of ``level`` and ``offset``
3102 for ``RTE_FLOW_FIELD_VALUE`` and ``RTE_FLOW_FIELD_POINTER`` respectively.
3103 The data in memory should be presented exactly in the same byte order and
3104 length as in the relevant flow item, i.e. data for field with type
3105 ``RTE_FLOW_FIELD_MAC_DST`` should follow the conventions of ``dst`` field
3106 in ``rte_flow_item_eth`` structure, with type ``RTE_FLOW_FIELD_IPV6_SRC`` -
3107 ``rte_flow_item_ipv6`` conventions, and so on. If the field size is larger than
3108 16 bytes the pattern can be provided as pointer only.
3109
3110 The bitfield extracted from the memory being applied as second operation
3111 parameter is defined by action width and by the destination field offset.
3112 Application should provide the data in immediate value memory (either as
3113 buffer or by pointer) exactly as item field without any applied explicit offset,
3114 and destination packet field (with specified width and bit offset) will be
3115 replaced by immediate source bits from the same bit offset. For example,
3116 to replace the third byte of MAC address with value 0x85, application should
3117 specify destination width as 8, destination offset as 16, and provide immediate
3118 value as sequence of bytes {xxx, xxx, 0x85, xxx, xxx, xxx}.
3119
3120 .. _table_rte_flow_action_modify_field:
3121
3122 .. table:: MODIFY_FIELD
3123
3124    +---------------+-------------------------+
3125    | Field         | Value                   |
3126    +===============+=========================+
3127    | ``op``        | operation to perform    |
3128    +---------------+-------------------------+
3129    | ``dst``       | destination field       |
3130    +---------------+-------------------------+
3131    | ``src``       | source field            |
3132    +---------------+-------------------------+
3133    | ``width``     | number of bits to use   |
3134    +---------------+-------------------------+
3135
3136 .. _table_rte_flow_action_modify_data:
3137
3138 .. table:: destination/source field definition
3139
3140    +---------------+----------------------------------------------------------+
3141    | Field         | Value                                                    |
3142    +===============+==========================================================+
3143    | ``field``     | ID: packet field, mark, meta, tag, immediate, pointer    |
3144    +---------------+----------------------------------------------------------+
3145    | ``level``     | encapsulation level of a packet field or tag array index |
3146    +---------------+----------------------------------------------------------+
3147    | ``offset``    | number of bits to skip at the beginning                  |
3148    +---------------+----------------------------------------------------------+
3149    | ``value``     | immediate value buffer (source field only, not           |
3150    |               | applicable to destination) for RTE_FLOW_FIELD_VALUE      |
3151    |               | field type                                               |
3152    +---------------+----------------------------------------------------------+
3153    | ``pvalue``    | pointer to immediate value data (source field only, not  |
3154    |               | applicable to destination) for RTE_FLOW_FIELD_POINTER    |
3155    |               | field type                                               |
3156    +---------------+----------------------------------------------------------+
3157
3158 Action: ``CONNTRACK``
3159 ^^^^^^^^^^^^^^^^^^^^^
3160
3161 Create a conntrack (connection tracking) context with the provided information.
3162
3163 In stateful session like TCP, the conntrack action provides the ability to
3164 examine every packet of this connection and associate the state to every
3165 packet. It will help to realize the stateful offload of connections with little
3166 software participation. For example, the packets with invalid state may be
3167 handled by the software. The control packets could be handled in the hardware.
3168 The software just need to query the state of a connection when needed, and then
3169 decide how to handle the flow rules and conntrack context.
3170
3171 A conntrack context should be created via ``rte_flow_action_handle_create()``
3172 before using. Then the handle with ``INDIRECT`` type is used for a flow rule
3173 creation. If a flow rule with an opposite direction needs to be created, the
3174 ``rte_flow_action_handle_update()`` should be used to modify the direction.
3175
3176 Not all the fields of the ``struct rte_flow_action_conntrack`` will be used
3177 for a conntrack context creating, depending on the HW, and they should be
3178 in host byte order. PMD should convert them into network byte order when
3179 needed by the HW.
3180
3181 The ``struct rte_flow_modify_conntrack`` should be used for an updating.
3182
3183 The current conntrack context information could be queried via the
3184 ``rte_flow_action_handle_query()`` interface.
3185
3186 .. _table_rte_flow_action_conntrack:
3187
3188 .. table:: CONNTRACK
3189
3190    +--------------------------+-------------------------------------------------------------+
3191    | Field                    | Value                                                       |
3192    +==========================+=============================================================+
3193    | ``peer_port``            | peer port number                                            |
3194    +--------------------------+-------------------------------------------------------------+
3195    | ``is_original_dir``      | direction of this connection for creating flow rule         |
3196    +--------------------------+-------------------------------------------------------------+
3197    | ``enable``               | enable the conntrack context                                |
3198    +--------------------------+-------------------------------------------------------------+
3199    | ``live_connection``      | one ack was seen for this connection                        |
3200    +--------------------------+-------------------------------------------------------------+
3201    | ``selective_ack``        | SACK enabled                                                |
3202    +--------------------------+-------------------------------------------------------------+
3203    | ``challenge_ack_passed`` | a challenge ack has passed                                  |
3204    +--------------------------+-------------------------------------------------------------+
3205    | ``last_direction``       | direction of the last passed packet                         |
3206    +--------------------------+-------------------------------------------------------------+
3207    | ``liberal_mode``         | only report state change                                    |
3208    +--------------------------+-------------------------------------------------------------+
3209    | ``state``                | current state                                               |
3210    +--------------------------+-------------------------------------------------------------+
3211    | ``max_ack_window``       | maximal window scaling factor                               |
3212    +--------------------------+-------------------------------------------------------------+
3213    | ``retransmission_limit`` | maximal retransmission times                                |
3214    +--------------------------+-------------------------------------------------------------+
3215    | ``original_dir``         | TCP parameters of the original direction                    |
3216    +--------------------------+-------------------------------------------------------------+
3217    | ``reply_dir``            | TCP parameters of the reply direction                       |
3218    +--------------------------+-------------------------------------------------------------+
3219    | ``last_window``          | window size of the last passed packet                       |
3220    +--------------------------+-------------------------------------------------------------+
3221    | ``last_seq``             | sequence number of the last passed packet                   |
3222    +--------------------------+-------------------------------------------------------------+
3223    | ``last_ack``             | acknowledgment number the last passed packet                |
3224    +--------------------------+-------------------------------------------------------------+
3225    | ``last_end``             | sum of ack number and length of the last passed packet      |
3226    +--------------------------+-------------------------------------------------------------+
3227
3228 .. _table_rte_flow_tcp_dir_param:
3229
3230 .. table:: configuration parameters for each direction
3231
3232    +---------------------+---------------------------------------------------------+
3233    | Field               | Value                                                   |
3234    +=====================+=========================================================+
3235    | ``scale``           | TCP window scaling factor                               |
3236    +---------------------+---------------------------------------------------------+
3237    | ``close_initiated`` | FIN sent from this direction                            |
3238    +---------------------+---------------------------------------------------------+
3239    | ``last_ack_seen``   | an ACK packet received                                  |
3240    +---------------------+---------------------------------------------------------+
3241    | ``data_unacked``    | unacknowledged data for packets from this direction     |
3242    +---------------------+---------------------------------------------------------+
3243    | ``sent_end``        | max{seq + len} seen in sent packets                     |
3244    +---------------------+---------------------------------------------------------+
3245    | ``reply_end``       | max{sack + max{win, 1}} seen in reply packets           |
3246    +---------------------+---------------------------------------------------------+
3247    | ``max_win``         | max{max{win, 1}} + {sack - ack} seen in sent packets    |
3248    +---------------------+---------------------------------------------------------+
3249    | ``max_ack``         | max{ack} + seen in sent packets                         |
3250    +---------------------+---------------------------------------------------------+
3251
3252 .. _table_rte_flow_modify_conntrack:
3253
3254 .. table:: update a conntrack context
3255
3256    +----------------+-------------------------------------------------+
3257    | Field          | Value                                           |
3258    +================+=================================================+
3259    | ``new_ct``     | new conntrack information                       |
3260    +----------------+-------------------------------------------------+
3261    | ``direction``  | direction will be updated                       |
3262    +----------------+-------------------------------------------------+
3263    | ``state``      | other fields except direction will be updated   |
3264    +----------------+-------------------------------------------------+
3265    | ``reserved``   | reserved bits                                   |
3266    +----------------+-------------------------------------------------+
3267
3268 Action: ``METER_COLOR``
3269 ^^^^^^^^^^^^^^^^^^^^^^^
3270
3271 Color the packet to reflect the meter color result.
3272
3273 The meter action must be configured before meter color action.
3274 Meter color action is set to a color to reflect the meter color result.
3275 Set the meter color in the mbuf to the selected color.
3276 The meter color action output color is the output color of the packet,
3277 which is set in the packet meta-data (i.e. struct ``rte_mbuf::sched::color``)
3278
3279 .. _table_rte_flow_action_meter_color:
3280
3281 .. table:: METER_COLOR
3282
3283    +-----------------+--------------+
3284    | Field           | Value        |
3285    +=================+==============+
3286    | ``meter_color`` | Packet color |
3287    +-----------------+--------------+
3288
3289 Action: ``PORT_REPRESENTOR``
3290 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3291
3292 At embedded switch level, send matching traffic to the given ethdev.
3293
3294 Term **ethdev** and the concept of **port representor** are synonymous.
3295 The **represented port** is an *entity* plugged to the embedded switch
3296 at the opposite end of the "wire" leading to the ethdev.
3297
3298 ::
3299
3300     .--------------------.
3301     |  PORT_REPRESENTOR  |  Ethdev (Application Port Referred to by its ID)
3302     '--------------------'
3303               /\
3304               ||
3305       .----------------.
3306       |  Logical Port  |
3307       '----------------'
3308               /\
3309               ||
3310               ||
3311               ||
3312          .----------.       .--------------------.
3313          |  Switch  |  <==  |  Matching Traffic  |
3314          '----------'       '--------------------'
3315               :
3316                :
3317               :
3318                :
3319       .----------------.
3320       |  Logical Port  |
3321       '----------------'
3322               :
3323                :
3324     .--------------------.
3325     |  REPRESENTED_PORT  |  Net / Guest / Another Ethdev (Same Application)
3326     '--------------------'
3327
3328
3329 - Requires `Attribute: Transfer`_.
3330
3331 .. _table_rte_flow_action_ethdev:
3332
3333 .. table:: ``struct rte_flow_action_ethdev``
3334
3335    +-------------+----------------+
3336    | Field       | Value          |
3337    +=============+================+
3338    | ``port_id`` | ethdev port ID |
3339    +-------------+----------------+
3340
3341 See also `Item: PORT_REPRESENTOR`_.
3342
3343 Action: ``REPRESENTED_PORT``
3344 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3345
3346 At embedded switch level, send matching traffic to
3347 the entity represented by the given ethdev.
3348
3349 Term **ethdev** and the concept of **port representor** are synonymous.
3350 The **represented port** is an *entity* plugged to the embedded switch
3351 at the opposite end of the "wire" leading to the ethdev.
3352
3353 ::
3354
3355     .--------------------.
3356     |  PORT_REPRESENTOR  |  Ethdev (Application Port Referred to by its ID)
3357     '--------------------'
3358               :
3359                :
3360       .----------------.
3361       |  Logical Port  |
3362       '----------------'
3363               :
3364                :
3365               :
3366                :
3367          .----------.       .--------------------.
3368          |  Switch  |  <==  |  Matching Traffic  |
3369          '----------'       '--------------------'
3370               ||
3371               ||
3372               ||
3373               \/
3374       .----------------.
3375       |  Logical Port  |
3376       '----------------'
3377               ||
3378               \/
3379     .--------------------.
3380     |  REPRESENTED_PORT  |  Net / Guest / Another Ethdev (Same Application)
3381     '--------------------'
3382
3383
3384 - Requires `Attribute: Transfer`_.
3385
3386 This action is meant to use the same structure as `Action: PORT_REPRESENTOR`_.
3387
3388 See also `Item: REPRESENTED_PORT`_.
3389
3390 Negative types
3391 ~~~~~~~~~~~~~~
3392
3393 All specified pattern items (``enum rte_flow_item_type``) and actions
3394 (``enum rte_flow_action_type``) use positive identifiers.
3395
3396 The negative space is reserved for dynamic types generated by PMDs during
3397 run-time. PMDs may encounter them as a result but must not accept negative
3398 identifiers they are not aware of.
3399
3400 A method to generate them remains to be defined.
3401
3402 Application may use PMD dynamic items or actions in flow rules. In that case
3403 size of configuration object in dynamic element must be a pointer size.
3404
3405 Rules management
3406 ----------------
3407
3408 A rather simple API with few functions is provided to fully manage flow
3409 rules.
3410
3411 Each created flow rule is associated with an opaque, PMD-specific handle
3412 pointer. The application is responsible for keeping it until the rule is
3413 destroyed.
3414
3415 Flows rules are represented by ``struct rte_flow`` objects.
3416
3417 Validation
3418 ~~~~~~~~~~
3419
3420 Given that expressing a definite set of device capabilities is not
3421 practical, a dedicated function is provided to check if a flow rule is
3422 supported and can be created.
3423
3424 .. code-block:: c
3425
3426    int
3427    rte_flow_validate(uint16_t port_id,
3428                      const struct rte_flow_attr *attr,
3429                      const struct rte_flow_item pattern[],
3430                      const struct rte_flow_action actions[],
3431                      struct rte_flow_error *error);
3432
3433 The flow rule is validated for correctness and whether it could be accepted
3434 by the device given sufficient resources. The rule is checked against the
3435 current device mode and queue configuration. The flow rule may also
3436 optionally be validated against existing flow rules and device resources.
3437 This function has no effect on the target device.
3438
3439 The returned value is guaranteed to remain valid only as long as no
3440 successful calls to ``rte_flow_create()`` or ``rte_flow_destroy()`` are made
3441 in the meantime and no device parameter affecting flow rules in any way are
3442 modified, due to possible collisions or resource limitations (although in
3443 such cases ``EINVAL`` should not be returned).
3444
3445 Arguments:
3446
3447 - ``port_id``: port identifier of Ethernet device.
3448 - ``attr``: flow rule attributes.
3449 - ``pattern``: pattern specification (list terminated by the END pattern
3450   item).
3451 - ``actions``: associated actions (list terminated by the END action).
3452 - ``error``: perform verbose error reporting if not NULL. PMDs initialize
3453   this structure in case of error only.
3454
3455 Return values:
3456
3457 - 0 if flow rule is valid and can be created. A negative errno value
3458   otherwise (``rte_errno`` is also set), the following errors are defined.
3459 - ``-ENOSYS``: underlying device does not support this functionality.
3460 - ``-EINVAL``: unknown or invalid rule specification.
3461 - ``-ENOTSUP``: valid but unsupported rule specification (e.g. partial
3462   bit-masks are unsupported).
3463 - ``EEXIST``: collision with an existing rule. Only returned if device
3464   supports flow rule collision checking and there was a flow rule
3465   collision. Not receiving this return code is no guarantee that creating
3466   the rule will not fail due to a collision.
3467 - ``ENOMEM``: not enough memory to execute the function, or if the device
3468   supports resource validation, resource limitation on the device.
3469 - ``-EBUSY``: action cannot be performed due to busy device resources, may
3470   succeed if the affected queues or even the entire port are in a stopped
3471   state (see ``rte_eth_dev_rx_queue_stop()`` and ``rte_eth_dev_stop()``).
3472
3473 Creation
3474 ~~~~~~~~
3475
3476 Creating a flow rule is similar to validating one, except the rule is
3477 actually created and a handle returned.
3478
3479 .. code-block:: c
3480
3481    struct rte_flow *
3482    rte_flow_create(uint16_t port_id,
3483                    const struct rte_flow_attr *attr,
3484                    const struct rte_flow_item pattern[],
3485                    const struct rte_flow_action *actions[],
3486                    struct rte_flow_error *error);
3487
3488 Arguments:
3489
3490 - ``port_id``: port identifier of Ethernet device.
3491 - ``attr``: flow rule attributes.
3492 - ``pattern``: pattern specification (list terminated by the END pattern
3493   item).
3494 - ``actions``: associated actions (list terminated by the END action).
3495 - ``error``: perform verbose error reporting if not NULL. PMDs initialize
3496   this structure in case of error only.
3497
3498 Return values:
3499
3500 A valid handle in case of success, NULL otherwise and ``rte_errno`` is set
3501 to the positive version of one of the error codes defined for
3502 ``rte_flow_validate()``.
3503
3504 Destruction
3505 ~~~~~~~~~~~
3506
3507 Flow rules destruction is not automatic, and a queue or a port should not be
3508 released if any are still attached to them. Applications must take care of
3509 performing this step before releasing resources.
3510
3511 .. code-block:: c
3512
3513    int
3514    rte_flow_destroy(uint16_t port_id,
3515                     struct rte_flow *flow,
3516                     struct rte_flow_error *error);
3517
3518
3519 Failure to destroy a flow rule handle may occur when other flow rules depend
3520 on it, and destroying it would result in an inconsistent state.
3521
3522 This function is only guaranteed to succeed if handles are destroyed in
3523 reverse order of their creation.
3524
3525 Arguments:
3526
3527 - ``port_id``: port identifier of Ethernet device.
3528 - ``flow``: flow rule handle to destroy.
3529 - ``error``: perform verbose error reporting if not NULL. PMDs initialize
3530   this structure in case of error only.
3531
3532 Return values:
3533
3534 - 0 on success, a negative errno value otherwise and ``rte_errno`` is set.
3535
3536 Flush
3537 ~~~~~
3538
3539 Convenience function to destroy all flow rule handles associated with a
3540 port. They are released as with successive calls to ``rte_flow_destroy()``.
3541
3542 .. code-block:: c
3543
3544    int
3545    rte_flow_flush(uint16_t port_id,
3546                   struct rte_flow_error *error);
3547
3548 In the unlikely event of failure, handles are still considered destroyed and
3549 no longer valid but the port must be assumed to be in an inconsistent state.
3550
3551 Arguments:
3552
3553 - ``port_id``: port identifier of Ethernet device.
3554 - ``error``: perform verbose error reporting if not NULL. PMDs initialize
3555   this structure in case of error only.
3556
3557 Return values:
3558
3559 - 0 on success, a negative errno value otherwise and ``rte_errno`` is set.
3560
3561 Query
3562 ~~~~~
3563
3564 Query an existing flow rule.
3565
3566 This function allows retrieving flow-specific data such as counters. Data
3567 is gathered by special actions which must be present in the flow rule
3568 definition.
3569
3570 .. code-block:: c
3571
3572    int
3573    rte_flow_query(uint16_t port_id,
3574                   struct rte_flow *flow,
3575                   const struct rte_flow_action *action,
3576                   void *data,
3577                   struct rte_flow_error *error);
3578
3579 Arguments:
3580
3581 - ``port_id``: port identifier of Ethernet device.
3582 - ``flow``: flow rule handle to query.
3583 - ``action``: action to query, this must match prototype from flow rule.
3584 - ``data``: pointer to storage for the associated query data type.
3585 - ``error``: perform verbose error reporting if not NULL. PMDs initialize
3586   this structure in case of error only.
3587
3588 Return values:
3589
3590 - 0 on success, a negative errno value otherwise and ``rte_errno`` is set.
3591
3592 .. _flow_isolated_mode:
3593
3594 Flow isolated mode
3595 ------------------
3596
3597 The general expectation for ingress traffic is that flow rules process it
3598 first; the remaining unmatched or pass-through traffic usually ends up in a
3599 queue (with or without RSS, locally or in some sub-device instance)
3600 depending on the global configuration settings of a port.
3601
3602 While fine from a compatibility standpoint, this approach makes drivers more
3603 complex as they have to check for possible side effects outside of this API
3604 when creating or destroying flow rules. It results in a more limited set of
3605 available rule types due to the way device resources are assigned (e.g. no
3606 support for the RSS action even on capable hardware).
3607
3608 Given that nonspecific traffic can be handled by flow rules as well,
3609 isolated mode is a means for applications to tell a driver that ingress on
3610 the underlying port must be injected from the defined flow rules only; that
3611 no default traffic is expected outside those rules.
3612
3613 This has the following benefits:
3614
3615 - Applications get finer-grained control over the kind of traffic they want
3616   to receive (no traffic by default).
3617
3618 - More importantly they control at what point nonspecific traffic is handled
3619   relative to other flow rules, by adjusting priority levels.
3620
3621 - Drivers can assign more hardware resources to flow rules and expand the
3622   set of supported rule types.
3623
3624 Because toggling isolated mode may cause profound changes to the ingress
3625 processing path of a driver, it may not be possible to leave it once
3626 entered. Likewise, existing flow rules or global configuration settings may
3627 prevent a driver from entering isolated mode.
3628
3629 Applications relying on this mode are therefore encouraged to toggle it as
3630 soon as possible after device initialization, ideally before the first call
3631 to ``rte_eth_dev_configure()`` to avoid possible failures due to conflicting
3632 settings.
3633
3634 Once effective, the following functionality has no effect on the underlying
3635 port and may return errors such as ``ENOTSUP`` ("not supported"):
3636
3637 - Toggling promiscuous mode.
3638 - Toggling allmulticast mode.
3639 - Configuring MAC addresses.
3640 - Configuring multicast addresses.
3641 - Configuring VLAN filters.
3642 - Configuring global RSS settings.
3643
3644 .. code-block:: c
3645
3646    int
3647    rte_flow_isolate(uint16_t port_id, int set, struct rte_flow_error *error);
3648
3649 Arguments:
3650
3651 - ``port_id``: port identifier of Ethernet device.
3652 - ``set``: nonzero to enter isolated mode, attempt to leave it otherwise.
3653 - ``error``: perform verbose error reporting if not NULL. PMDs initialize
3654   this structure in case of error only.
3655
3656 Return values:
3657
3658 - 0 on success, a negative errno value otherwise and ``rte_errno`` is set.
3659
3660 Verbose error reporting
3661 -----------------------
3662
3663 The defined *errno* values may not be accurate enough for users or
3664 application developers who want to investigate issues related to flow rules
3665 management. A dedicated error object is defined for this purpose:
3666
3667 .. code-block:: c
3668
3669    enum rte_flow_error_type {
3670        RTE_FLOW_ERROR_TYPE_NONE, /**< No error. */
3671        RTE_FLOW_ERROR_TYPE_UNSPECIFIED, /**< Cause unspecified. */
3672        RTE_FLOW_ERROR_TYPE_HANDLE, /**< Flow rule (handle). */
3673        RTE_FLOW_ERROR_TYPE_ATTR_GROUP, /**< Group field. */
3674        RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY, /**< Priority field. */
3675        RTE_FLOW_ERROR_TYPE_ATTR_INGRESS, /**< Ingress field. */
3676        RTE_FLOW_ERROR_TYPE_ATTR_EGRESS, /**< Egress field. */
3677        RTE_FLOW_ERROR_TYPE_ATTR, /**< Attributes structure. */
3678        RTE_FLOW_ERROR_TYPE_ITEM_NUM, /**< Pattern length. */
3679        RTE_FLOW_ERROR_TYPE_ITEM, /**< Specific pattern item. */
3680        RTE_FLOW_ERROR_TYPE_ACTION_NUM, /**< Number of actions. */
3681        RTE_FLOW_ERROR_TYPE_ACTION, /**< Specific action. */
3682    };
3683
3684    struct rte_flow_error {
3685        enum rte_flow_error_type type; /**< Cause field and error types. */
3686        const void *cause; /**< Object responsible for the error. */
3687        const char *message; /**< Human-readable error message. */
3688    };
3689
3690 Error type ``RTE_FLOW_ERROR_TYPE_NONE`` stands for no error, in which case
3691 remaining fields can be ignored. Other error types describe the type of the
3692 object pointed by ``cause``.
3693
3694 If non-NULL, ``cause`` points to the object responsible for the error. For a
3695 flow rule, this may be a pattern item or an individual action.
3696
3697 If non-NULL, ``message`` provides a human-readable error message.
3698
3699 This object is normally allocated by applications and set by PMDs in case of
3700 error, the message points to a constant string which does not need to be
3701 freed by the application, however its pointer can be considered valid only
3702 as long as its associated DPDK port remains configured. Closing the
3703 underlying device or unloading the PMD invalidates it.
3704
3705 Helpers
3706 -------
3707
3708 Error initializer
3709 ~~~~~~~~~~~~~~~~~
3710
3711 .. code-block:: c
3712
3713    static inline int
3714    rte_flow_error_set(struct rte_flow_error *error,
3715                       int code,
3716                       enum rte_flow_error_type type,
3717                       const void *cause,
3718                       const char *message);
3719
3720 This function initializes ``error`` (if non-NULL) with the provided
3721 parameters and sets ``rte_errno`` to ``code``. A negative error ``code`` is
3722 then returned.
3723
3724 Object conversion
3725 ~~~~~~~~~~~~~~~~~
3726
3727 .. code-block:: c
3728
3729    int
3730    rte_flow_conv(enum rte_flow_conv_op op,
3731                  void *dst,
3732                  size_t size,
3733                  const void *src,
3734                  struct rte_flow_error *error);
3735
3736 Convert ``src`` to ``dst`` according to operation ``op``. Possible
3737 operations include:
3738
3739 - Attributes, pattern item or action duplication.
3740 - Duplication of an entire pattern or list of actions.
3741 - Duplication of a complete flow rule description.
3742 - Pattern item or action name retrieval.
3743
3744 Tunneled traffic offload
3745 ~~~~~~~~~~~~~~~~~~~~~~~~
3746
3747 rte_flow API provides the building blocks for vendor-agnostic flow
3748 classification offloads. The rte_flow "patterns" and "actions"
3749 primitives are fine-grained, thus enabling DPDK applications the
3750 flexibility to offload network stacks and complex pipelines.
3751 Applications wishing to offload tunneled traffic are required to use
3752 the rte_flow primitives, such as group, meta, mark, tag, and others to
3753 model their high-level objects.  The hardware model design for
3754 high-level software objects is not trivial.  Furthermore, an optimal
3755 design is often vendor-specific.
3756
3757 When hardware offloads tunneled traffic in multi-group logic,
3758 partially offloaded packets may arrive to the application after they
3759 were modified in hardware. In this case, the application may need to
3760 restore the original packet headers. Consider the following sequence:
3761 The application decaps a packet in one group and jumps to a second
3762 group where it tries to match on a 5-tuple, that will miss and send
3763 the packet to the application. In this case, the application does not
3764 receive the original packet but a modified one. Also, in this case,
3765 the application cannot match on the outer header fields, such as VXLAN
3766 vni and 5-tuple.
3767
3768 There are several possible ways to use rte_flow "patterns" and
3769 "actions" to resolve the issues above. For example:
3770
3771 1 Mapping headers to a hardware registers using the
3772 rte_flow_action_mark/rte_flow_action_tag/rte_flow_set_meta objects.
3773
3774 2 Apply the decap only at the last offload stage after all the
3775 "patterns" were matched and the packet will be fully offloaded.
3776
3777 Every approach has its pros and cons and is highly dependent on the
3778 hardware vendor.  For example, some hardware may have a limited number
3779 of registers while other hardware could not support inner actions and
3780 must decap before accessing inner headers.
3781
3782 The tunnel offload model resolves these issues. The model goals are:
3783
3784 1 Provide a unified application API to offload tunneled traffic that
3785 is capable to match on outer headers after decap.
3786
3787 2 Allow the application to restore the outer header of partially
3788 offloaded packets.
3789
3790 The tunnel offload model does not introduce new elements to the
3791 existing RTE flow model and is implemented as a set of helper
3792 functions.
3793
3794 For the application to work with the tunnel offload API it
3795 has to adjust flow rules in multi-table tunnel offload in the
3796 following way:
3797
3798 1 Remove explicit call to decap action and replace it with PMD actions
3799 obtained from rte_flow_tunnel_decap_and_set() helper.
3800
3801 2 Add PMD items obtained from rte_flow_tunnel_match() helper to all
3802 other rules in the tunnel offload sequence.
3803
3804 The model requirements:
3805
3806 Software application must initialize
3807 rte_tunnel object with tunnel parameters before calling
3808 rte_flow_tunnel_decap_set() & rte_flow_tunnel_match().
3809
3810 PMD actions array obtained in rte_flow_tunnel_decap_set() must be
3811 released by application with rte_flow_action_release() call.
3812
3813 PMD items array obtained with rte_flow_tunnel_match() must be released
3814 by application with rte_flow_item_release() call.  Application can
3815 release PMD items and actions after rule was created. However, if the
3816 application needs to create additional rule for the same tunnel it
3817 will need to obtain PMD items again.
3818
3819 Application cannot destroy rte_tunnel object before it releases all
3820 PMD actions & PMD items referencing that tunnel.
3821
3822 Caveats
3823 -------
3824
3825 - DPDK does not keep track of flow rules definitions or flow rule objects
3826   automatically. Applications may keep track of the former and must keep
3827   track of the latter. PMDs may also do it for internal needs, however this
3828   must not be relied on by applications.
3829
3830 - Flow rules are not maintained between successive port initializations. An
3831   application exiting without releasing them and restarting must re-create
3832   them from scratch.
3833
3834 - API operations are synchronous and blocking (``EAGAIN`` cannot be
3835   returned).
3836
3837 - Stopping the data path (TX/RX) should not be necessary when managing flow
3838   rules. If this cannot be achieved naturally or with workarounds (such as
3839   temporarily replacing the burst function pointers), an appropriate error
3840   code must be returned (``EBUSY``).
3841
3842 - Applications, not PMDs, are responsible for maintaining flow rules
3843   configuration when closing, stopping or restarting a port or performing other
3844   actions which may affect them.
3845   Applications must assume that after port close, stop or restart all flows
3846   related to that port are not valid, hardware rules are destroyed and relevant
3847   PMD resources are released.
3848
3849 For devices exposing multiple ports sharing global settings affected by flow
3850 rules:
3851
3852 - All ports under DPDK control must behave consistently, PMDs are
3853   responsible for making sure that existing flow rules on a port are not
3854   affected by other ports.
3855
3856 - Ports not under DPDK control (unaffected or handled by other applications)
3857   are user's responsibility. They may affect existing flow rules and cause
3858   undefined behavior. PMDs aware of this may prevent flow rules creation
3859   altogether in such cases.
3860
3861 PMD interface
3862 -------------
3863
3864 The PMD interface is defined in ``rte_flow_driver.h``. It is not subject to
3865 API/ABI versioning constraints as it is not exposed to applications and may
3866 evolve independently.
3867
3868 The PMD interface is based on callbacks pointed by the ``struct rte_flow_ops``.
3869
3870 - PMD callbacks implement exactly the interface described in `Rules
3871   management`_, except for the port ID argument which has already been
3872   converted to a pointer to the underlying ``struct rte_eth_dev``.
3873
3874 - Public API functions do not process flow rules definitions at all before
3875   calling PMD functions (no basic error checking, no validation
3876   whatsoever). They only make sure these callbacks are non-NULL or return
3877   the ``ENOSYS`` (function not supported) error.
3878
3879 This interface additionally defines the following helper function:
3880
3881 - ``rte_flow_ops_get()``: get generic flow operations structure from a
3882   port.
3883
3884 If PMD interfaces don't support re-entrancy/multi-thread safety,
3885 the rte_flow API functions will protect threads by mutex per port.
3886 The application can check whether ``RTE_ETH_DEV_FLOW_OPS_THREAD_SAFE``
3887 is set in ``dev_flags``, meaning the PMD is thread-safe regarding rte_flow,
3888 so the API level protection is disabled.
3889 Please note that this API-level mutex protects only rte_flow functions,
3890 other control path functions are not in scope.
3891
3892 Device compatibility
3893 --------------------
3894
3895 No known implementation supports all the described features.
3896
3897 Unsupported features or combinations are not expected to be fully emulated
3898 in software by PMDs for performance reasons. Partially supported features
3899 may be completed in software as long as hardware performs most of the work
3900 (such as queue redirection and packet recognition).
3901
3902 However PMDs are expected to do their best to satisfy application requests
3903 by working around hardware limitations as long as doing so does not affect
3904 the behavior of existing flow rules.
3905
3906 The following sections provide a few examples of such cases and describe how
3907 PMDs should handle them, they are based on limitations built into the
3908 previous APIs.
3909
3910 Global bit-masks
3911 ~~~~~~~~~~~~~~~~
3912
3913 Each flow rule comes with its own, per-layer bit-masks, while hardware may
3914 support only a single, device-wide bit-mask for a given layer type, so that
3915 two IPv4 rules cannot use different bit-masks.
3916
3917 The expected behavior in this case is that PMDs automatically configure
3918 global bit-masks according to the needs of the first flow rule created.
3919
3920 Subsequent rules are allowed only if their bit-masks match those, the
3921 ``EEXIST`` error code should be returned otherwise.
3922
3923 Unsupported layer types
3924 ~~~~~~~~~~~~~~~~~~~~~~~
3925
3926 Many protocols can be simulated by crafting patterns with the `Item: RAW`_
3927 type.
3928
3929 PMDs can rely on this capability to simulate support for protocols with
3930 headers not directly recognized by hardware.
3931
3932 ``ANY`` pattern item
3933 ~~~~~~~~~~~~~~~~~~~~
3934
3935 This pattern item stands for anything, which can be difficult to translate
3936 to something hardware would understand, particularly if followed by more
3937 specific types.
3938
3939 Consider the following pattern:
3940
3941 .. _table_rte_flow_unsupported_any:
3942
3943 .. table:: Pattern with ANY as L3
3944
3945    +-------+-----------------------+
3946    | Index | Item                  |
3947    +=======+=======================+
3948    | 0     | ETHER                 |
3949    +-------+-----+---------+-------+
3950    | 1     | ANY | ``num`` | ``1`` |
3951    +-------+-----+---------+-------+
3952    | 2     | TCP                   |
3953    +-------+-----------------------+
3954    | 3     | END                   |
3955    +-------+-----------------------+
3956
3957 Knowing that TCP does not make sense with something other than IPv4 and IPv6
3958 as L3, such a pattern may be translated to two flow rules instead:
3959
3960 .. _table_rte_flow_unsupported_any_ipv4:
3961
3962 .. table:: ANY replaced with IPV4
3963
3964    +-------+--------------------+
3965    | Index | Item               |
3966    +=======+====================+
3967    | 0     | ETHER              |
3968    +-------+--------------------+
3969    | 1     | IPV4 (zeroed mask) |
3970    +-------+--------------------+
3971    | 2     | TCP                |
3972    +-------+--------------------+
3973    | 3     | END                |
3974    +-------+--------------------+
3975
3976 |
3977
3978 .. _table_rte_flow_unsupported_any_ipv6:
3979
3980 .. table:: ANY replaced with IPV6
3981
3982    +-------+--------------------+
3983    | Index | Item               |
3984    +=======+====================+
3985    | 0     | ETHER              |
3986    +-------+--------------------+
3987    | 1     | IPV6 (zeroed mask) |
3988    +-------+--------------------+
3989    | 2     | TCP                |
3990    +-------+--------------------+
3991    | 3     | END                |
3992    +-------+--------------------+
3993
3994 Note that as soon as a ANY rule covers several layers, this approach may
3995 yield a large number of hidden flow rules. It is thus suggested to only
3996 support the most common scenarios (anything as L2 and/or L3).
3997
3998 Unsupported actions
3999 ~~~~~~~~~~~~~~~~~~~
4000
4001 - When combined with `Action: QUEUE`_, packet counting (`Action: COUNT`_)
4002   and tagging (`Action: MARK`_ or `Action: FLAG`_) may be implemented in
4003   software as long as the target queue is used by a single rule.
4004
4005 - When a single target queue is provided, `Action: RSS`_ can also be
4006   implemented through `Action: QUEUE`_.
4007
4008 Flow rules priority
4009 ~~~~~~~~~~~~~~~~~~~
4010
4011 While it would naturally make sense, flow rules cannot be assumed to be
4012 processed by hardware in the same order as their creation for several
4013 reasons:
4014
4015 - They may be managed internally as a tree or a hash table instead of a
4016   list.
4017 - Removing a flow rule before adding another one can either put the new rule
4018   at the end of the list or reuse a freed entry.
4019 - Duplication may occur when packets are matched by several rules.
4020
4021 For overlapping rules (particularly in order to use `Action: PASSTHRU`_)
4022 predictable behavior is only guaranteed by using different priority levels.
4023
4024 Priority levels are not necessarily implemented in hardware, or may be
4025 severely limited (e.g. a single priority bit).
4026
4027 For these reasons, priority levels may be implemented purely in software by
4028 PMDs.
4029
4030 - For devices expecting flow rules to be added in the correct order, PMDs
4031   may destroy and re-create existing rules after adding a new one with
4032   a higher priority.
4033
4034 - A configurable number of dummy or empty rules can be created at
4035   initialization time to save high priority slots for later.
4036
4037 - In order to save priority levels, PMDs may evaluate whether rules are
4038   likely to collide and adjust their priority accordingly.
4039
4040
4041 .. _OpenFlow Switch Specification: https://www.opennetworking.org/software-defined-standards/specifications/