ethdev: fix default VLAN TCI mask in flow API
[dpdk.git] / doc / guides / prog_guide / rte_flow.rst
1 ..  BSD LICENSE
2     Copyright 2016 6WIND S.A.
3     Copyright 2016 Mellanox.
4
5     Redistribution and use in source and binary forms, with or without
6     modification, are permitted provided that the following conditions
7     are met:
8
9     * Redistributions of source code must retain the above copyright
10     notice, this list of conditions and the following disclaimer.
11     * Redistributions in binary form must reproduce the above copyright
12     notice, this list of conditions and the following disclaimer in
13     the documentation and/or other materials provided with the
14     distribution.
15     * Neither the name of 6WIND S.A. nor the names of its
16     contributors may be used to endorse or promote products derived
17     from this software without specific prior written permission.
18
19     THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20     "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21     LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22     A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23     OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24     SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25     LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26     DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27     THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28     (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29     OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
31 .. _Generic_flow_API:
32
33 Generic flow API (rte_flow)
34 ===========================
35
36 Overview
37 --------
38
39 This API provides a generic means to configure hardware to match specific
40 ingress or egress traffic, alter its fate and query related counters
41 according to any number of user-defined rules.
42
43 It is named *rte_flow* after the prefix used for all its symbols, and is
44 defined in ``rte_flow.h``.
45
46 - Matching can be performed on packet data (protocol headers, payload) and
47   properties (e.g. associated physical port, virtual device function ID).
48
49 - Possible operations include dropping traffic, diverting it to specific
50   queues, to virtual/physical device functions or ports, performing tunnel
51   offloads, adding marks and so on.
52
53 It is slightly higher-level than the legacy filtering framework which it
54 encompasses and supersedes (including all functions and filter types) in
55 order to expose a single interface with an unambiguous behavior that is
56 common to all poll-mode drivers (PMDs).
57
58 Flow rule
59 ---------
60
61 Description
62 ~~~~~~~~~~~
63
64 A flow rule is the combination of attributes with a matching pattern and a
65 list of actions. Flow rules form the basis of this API.
66
67 Flow rules can have several distinct actions (such as counting,
68 encapsulating, decapsulating before redirecting packets to a particular
69 queue, etc.), instead of relying on several rules to achieve this and having
70 applications deal with hardware implementation details regarding their
71 order.
72
73 Support for different priority levels on a rule basis is provided, for
74 example in order to force a more specific rule to come before a more generic
75 one for packets matched by both. However hardware support for more than a
76 single priority level cannot be guaranteed. When supported, the number of
77 available priority levels is usually low, which is why they can also be
78 implemented in software by PMDs (e.g. missing priority levels may be
79 emulated by reordering rules).
80
81 In order to remain as hardware-agnostic as possible, by default all rules
82 are considered to have the same priority, which means that the order between
83 overlapping rules (when a packet is matched by several filters) is
84 undefined.
85
86 PMDs may refuse to create overlapping rules at a given priority level when
87 they can be detected (e.g. if a pattern matches an existing filter).
88
89 Thus predictable results for a given priority level can only be achieved
90 with non-overlapping rules, using perfect matching on all protocol layers.
91
92 Flow rules can also be grouped, the flow rule priority is specific to the
93 group they belong to. All flow rules in a given group are thus processed
94 either before or after another group.
95
96 Support for multiple actions per rule may be implemented internally on top
97 of non-default hardware priorities, as a result both features may not be
98 simultaneously available to applications.
99
100 Considering that allowed pattern/actions combinations cannot be known in
101 advance and would result in an impractically large number of capabilities to
102 expose, a method is provided to validate a given rule from the current
103 device configuration state.
104
105 This enables applications to check if the rule types they need is supported
106 at initialization time, before starting their data path. This method can be
107 used anytime, its only requirement being that the resources needed by a rule
108 should exist (e.g. a target RX queue should be configured first).
109
110 Each defined rule is associated with an opaque handle managed by the PMD,
111 applications are responsible for keeping it. These can be used for queries
112 and rules management, such as retrieving counters or other data and
113 destroying them.
114
115 To avoid resource leaks on the PMD side, handles must be explicitly
116 destroyed by the application before releasing associated resources such as
117 queues and ports.
118
119 The following sections cover:
120
121 - **Attributes** (represented by ``struct rte_flow_attr``): properties of a
122   flow rule such as its direction (ingress or egress) and priority.
123
124 - **Pattern item** (represented by ``struct rte_flow_item``): part of a
125   matching pattern that either matches specific packet data or traffic
126   properties. It can also describe properties of the pattern itself, such as
127   inverted matching.
128
129 - **Matching pattern**: traffic properties to look for, a combination of any
130   number of items.
131
132 - **Actions** (represented by ``struct rte_flow_action``): operations to
133   perform whenever a packet is matched by a pattern.
134
135 Attributes
136 ~~~~~~~~~~
137
138 Attribute: Group
139 ^^^^^^^^^^^^^^^^
140
141 Flow rules can be grouped by assigning them a common group number. Lower
142 values have higher priority. Group 0 has the highest priority.
143
144 Although optional, applications are encouraged to group similar rules as
145 much as possible to fully take advantage of hardware capabilities
146 (e.g. optimized matching) and work around limitations (e.g. a single pattern
147 type possibly allowed in a given group).
148
149 Note that support for more than a single group is not guaranteed.
150
151 Attribute: Priority
152 ^^^^^^^^^^^^^^^^^^^
153
154 A priority level can be assigned to a flow rule. Like groups, lower values
155 denote higher priority, with 0 as the maximum.
156
157 A rule with priority 0 in group 8 is always matched after a rule with
158 priority 8 in group 0.
159
160 Group and priority levels are arbitrary and up to the application, they do
161 not need to be contiguous nor start from 0, however the maximum number
162 varies between devices and may be affected by existing flow rules.
163
164 If a packet is matched by several rules of a given group for a given
165 priority level, the outcome is undefined. It can take any path, may be
166 duplicated or even cause unrecoverable errors.
167
168 Note that support for more than a single priority level is not guaranteed.
169
170 Attribute: Traffic direction
171 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
172
173 Flow rules can apply to inbound and/or outbound traffic (ingress/egress).
174
175 Several pattern items and actions are valid and can be used in both
176 directions. At least one direction must be specified.
177
178 Specifying both directions at once for a given rule is not recommended but
179 may be valid in a few cases (e.g. shared counters).
180
181 Pattern item
182 ~~~~~~~~~~~~
183
184 Pattern items fall in two categories:
185
186 - Matching protocol headers and packet data, usually associated with a
187   specification structure. These must be stacked in the same order as the
188   protocol layers to match inside packets, starting from the lowest.
189
190 - Matching meta-data or affecting pattern processing, often without a
191   specification structure. Since they do not match packet contents, their
192   position in the list is usually not relevant.
193
194 Item specification structures are used to match specific values among
195 protocol fields (or item properties). Documentation describes for each item
196 whether they are associated with one and their type name if so.
197
198 Up to three structures of the same type can be set for a given item:
199
200 - ``spec``: values to match (e.g. a given IPv4 address).
201
202 - ``last``: upper bound for an inclusive range with corresponding fields in
203   ``spec``.
204
205 - ``mask``: bit-mask applied to both ``spec`` and ``last`` whose purpose is
206   to distinguish the values to take into account and/or partially mask them
207   out (e.g. in order to match an IPv4 address prefix).
208
209 Usage restrictions and expected behavior:
210
211 - Setting either ``mask`` or ``last`` without ``spec`` is an error.
212
213 - Field values in ``last`` which are either 0 or equal to the corresponding
214   values in ``spec`` are ignored; they do not generate a range. Nonzero
215   values lower than those in ``spec`` are not supported.
216
217 - Setting ``spec`` and optionally ``last`` without ``mask`` causes the PMD
218   to use the default mask defined for that item (defined as
219   ``rte_flow_item_{name}_mask`` constants).
220
221 - Not setting any of them (assuming item type allows it) is equivalent to
222   providing an empty (zeroed) ``mask`` for broad (nonspecific) matching.
223
224 - ``mask`` is a simple bit-mask applied before interpreting the contents of
225   ``spec`` and ``last``, which may yield unexpected results if not used
226   carefully. For example, if for an IPv4 address field, ``spec`` provides
227   *10.1.2.3*, ``last`` provides *10.3.4.5* and ``mask`` provides
228   *255.255.0.0*, the effective range becomes *10.1.0.0* to *10.3.255.255*.
229
230 Example of an item specification matching an Ethernet header:
231
232 .. _table_rte_flow_pattern_item_example:
233
234 .. table:: Ethernet item
235
236    +----------+----------+--------------------+
237    | Field    | Subfield | Value              |
238    +==========+==========+====================+
239    | ``spec`` | ``src``  | ``00:01:02:03:04`` |
240    |          +----------+--------------------+
241    |          | ``dst``  | ``00:2a:66:00:01`` |
242    |          +----------+--------------------+
243    |          | ``type`` | ``0x22aa``         |
244    +----------+----------+--------------------+
245    | ``last`` | unspecified                   |
246    +----------+----------+--------------------+
247    | ``mask`` | ``src``  | ``00:ff:ff:ff:00`` |
248    |          +----------+--------------------+
249    |          | ``dst``  | ``00:00:00:00:ff`` |
250    |          +----------+--------------------+
251    |          | ``type`` | ``0x0000``         |
252    +----------+----------+--------------------+
253
254 Non-masked bits stand for any value (shown as ``?`` below), Ethernet headers
255 with the following properties are thus matched:
256
257 - ``src``: ``??:01:02:03:??``
258 - ``dst``: ``??:??:??:??:01``
259 - ``type``: ``0x????``
260
261 Matching pattern
262 ~~~~~~~~~~~~~~~~
263
264 A pattern is formed by stacking items starting from the lowest protocol
265 layer to match. This stacking restriction does not apply to meta items which
266 can be placed anywhere in the stack without affecting the meaning of the
267 resulting pattern.
268
269 Patterns are terminated by END items.
270
271 Examples:
272
273 .. _table_rte_flow_tcpv4_as_l4:
274
275 .. table:: TCPv4 as L4
276
277    +-------+----------+
278    | Index | Item     |
279    +=======+==========+
280    | 0     | Ethernet |
281    +-------+----------+
282    | 1     | IPv4     |
283    +-------+----------+
284    | 2     | TCP      |
285    +-------+----------+
286    | 3     | END      |
287    +-------+----------+
288
289 |
290
291 .. _table_rte_flow_tcpv6_in_vxlan:
292
293 .. table:: TCPv6 in VXLAN
294
295    +-------+------------+
296    | Index | Item       |
297    +=======+============+
298    | 0     | Ethernet   |
299    +-------+------------+
300    | 1     | IPv4       |
301    +-------+------------+
302    | 2     | UDP        |
303    +-------+------------+
304    | 3     | VXLAN      |
305    +-------+------------+
306    | 4     | Ethernet   |
307    +-------+------------+
308    | 5     | IPv6       |
309    +-------+------------+
310    | 6     | TCP        |
311    +-------+------------+
312    | 7     | END        |
313    +-------+------------+
314
315 |
316
317 .. _table_rte_flow_tcpv4_as_l4_meta:
318
319 .. table:: TCPv4 as L4 with meta items
320
321    +-------+----------+
322    | Index | Item     |
323    +=======+==========+
324    | 0     | VOID     |
325    +-------+----------+
326    | 1     | Ethernet |
327    +-------+----------+
328    | 2     | VOID     |
329    +-------+----------+
330    | 3     | IPv4     |
331    +-------+----------+
332    | 4     | TCP      |
333    +-------+----------+
334    | 5     | VOID     |
335    +-------+----------+
336    | 6     | VOID     |
337    +-------+----------+
338    | 7     | END      |
339    +-------+----------+
340
341 The above example shows how meta items do not affect packet data matching
342 items, as long as those remain stacked properly. The resulting matching
343 pattern is identical to "TCPv4 as L4".
344
345 .. _table_rte_flow_udpv6_anywhere:
346
347 .. table:: UDPv6 anywhere
348
349    +-------+------+
350    | Index | Item |
351    +=======+======+
352    | 0     | IPv6 |
353    +-------+------+
354    | 1     | UDP  |
355    +-------+------+
356    | 2     | END  |
357    +-------+------+
358
359 If supported by the PMD, omitting one or several protocol layers at the
360 bottom of the stack as in the above example (missing an Ethernet
361 specification) enables looking up anywhere in packets.
362
363 It is unspecified whether the payload of supported encapsulations
364 (e.g. VXLAN payload) is matched by such a pattern, which may apply to inner,
365 outer or both packets.
366
367 .. _table_rte_flow_invalid_l3:
368
369 .. table:: Invalid, missing L3
370
371    +-------+----------+
372    | Index | Item     |
373    +=======+==========+
374    | 0     | Ethernet |
375    +-------+----------+
376    | 1     | UDP      |
377    +-------+----------+
378    | 2     | END      |
379    +-------+----------+
380
381 The above pattern is invalid due to a missing L3 specification between L2
382 (Ethernet) and L4 (UDP). Doing so is only allowed at the bottom and at the
383 top of the stack.
384
385 Meta item types
386 ~~~~~~~~~~~~~~~
387
388 They match meta-data or affect pattern processing instead of matching packet
389 data directly, most of them do not need a specification structure. This
390 particularity allows them to be specified anywhere in the stack without
391 causing any side effect.
392
393 Item: ``END``
394 ^^^^^^^^^^^^^
395
396 End marker for item lists. Prevents further processing of items, thereby
397 ending the pattern.
398
399 - Its numeric value is 0 for convenience.
400 - PMD support is mandatory.
401 - ``spec``, ``last`` and ``mask`` are ignored.
402
403 .. _table_rte_flow_item_end:
404
405 .. table:: END
406
407    +----------+---------+
408    | Field    | Value   |
409    +==========+=========+
410    | ``spec`` | ignored |
411    +----------+---------+
412    | ``last`` | ignored |
413    +----------+---------+
414    | ``mask`` | ignored |
415    +----------+---------+
416
417 Item: ``VOID``
418 ^^^^^^^^^^^^^^
419
420 Used as a placeholder for convenience. It is ignored and simply discarded by
421 PMDs.
422
423 - PMD support is mandatory.
424 - ``spec``, ``last`` and ``mask`` are ignored.
425
426 .. _table_rte_flow_item_void:
427
428 .. table:: VOID
429
430    +----------+---------+
431    | Field    | Value   |
432    +==========+=========+
433    | ``spec`` | ignored |
434    +----------+---------+
435    | ``last`` | ignored |
436    +----------+---------+
437    | ``mask`` | ignored |
438    +----------+---------+
439
440 One usage example for this type is generating rules that share a common
441 prefix quickly without reallocating memory, only by updating item types:
442
443 .. _table_rte_flow_item_void_example:
444
445 .. table:: TCP, UDP or ICMP as L4
446
447    +-------+--------------------+
448    | Index | Item               |
449    +=======+====================+
450    | 0     | Ethernet           |
451    +-------+--------------------+
452    | 1     | IPv4               |
453    +-------+------+------+------+
454    | 2     | UDP  | VOID | VOID |
455    +-------+------+------+------+
456    | 3     | VOID | TCP  | VOID |
457    +-------+------+------+------+
458    | 4     | VOID | VOID | ICMP |
459    +-------+------+------+------+
460    | 5     | END                |
461    +-------+--------------------+
462
463 Item: ``INVERT``
464 ^^^^^^^^^^^^^^^^
465
466 Inverted matching, i.e. process packets that do not match the pattern.
467
468 - ``spec``, ``last`` and ``mask`` are ignored.
469
470 .. _table_rte_flow_item_invert:
471
472 .. table:: INVERT
473
474    +----------+---------+
475    | Field    | Value   |
476    +==========+=========+
477    | ``spec`` | ignored |
478    +----------+---------+
479    | ``last`` | ignored |
480    +----------+---------+
481    | ``mask`` | ignored |
482    +----------+---------+
483
484 Usage example, matching non-TCPv4 packets only:
485
486 .. _table_rte_flow_item_invert_example:
487
488 .. table:: Anything but TCPv4
489
490    +-------+----------+
491    | Index | Item     |
492    +=======+==========+
493    | 0     | INVERT   |
494    +-------+----------+
495    | 1     | Ethernet |
496    +-------+----------+
497    | 2     | IPv4     |
498    +-------+----------+
499    | 3     | TCP      |
500    +-------+----------+
501    | 4     | END      |
502    +-------+----------+
503
504 Item: ``PF``
505 ^^^^^^^^^^^^
506
507 Matches packets addressed to the physical function of the device.
508
509 If the underlying device function differs from the one that would normally
510 receive the matched traffic, specifying this item prevents it from reaching
511 that device unless the flow rule contains a `Action: PF`_. Packets are not
512 duplicated between device instances by default.
513
514 - Likely to return an error or never match any traffic if applied to a VF
515   device.
516 - Can be combined with any number of `Item: VF`_ to match both PF and VF
517   traffic.
518 - ``spec``, ``last`` and ``mask`` must not be set.
519
520 .. _table_rte_flow_item_pf:
521
522 .. table:: PF
523
524    +----------+-------+
525    | Field    | Value |
526    +==========+=======+
527    | ``spec`` | unset |
528    +----------+-------+
529    | ``last`` | unset |
530    +----------+-------+
531    | ``mask`` | unset |
532    +----------+-------+
533
534 Item: ``VF``
535 ^^^^^^^^^^^^
536
537 Matches packets addressed to a virtual function ID of the device.
538
539 If the underlying device function differs from the one that would normally
540 receive the matched traffic, specifying this item prevents it from reaching
541 that device unless the flow rule contains a `Action: VF`_. Packets are not
542 duplicated between device instances by default.
543
544 - Likely to return an error or never match any traffic if this causes a VF
545   device to match traffic addressed to a different VF.
546 - Can be specified multiple times to match traffic addressed to several VF
547   IDs.
548 - Can be combined with a PF item to match both PF and VF traffic.
549 - Default ``mask`` matches any VF ID.
550
551 .. _table_rte_flow_item_vf:
552
553 .. table:: VF
554
555    +----------+----------+---------------------------+
556    | Field    | Subfield | Value                     |
557    +==========+==========+===========================+
558    | ``spec`` | ``id``   | destination VF ID         |
559    +----------+----------+---------------------------+
560    | ``last`` | ``id``   | upper range value         |
561    +----------+----------+---------------------------+
562    | ``mask`` | ``id``   | zeroed to match any VF ID |
563    +----------+----------+---------------------------+
564
565 Item: ``PORT``
566 ^^^^^^^^^^^^^^
567
568 Matches packets coming from the specified physical port of the underlying
569 device.
570
571 The first PORT item overrides the physical port normally associated with the
572 specified DPDK input port (port_id). This item can be provided several times
573 to match additional physical ports.
574
575 Note that physical ports are not necessarily tied to DPDK input ports
576 (port_id) when those are not under DPDK control. Possible values are
577 specific to each device, they are not necessarily indexed from zero and may
578 not be contiguous.
579
580 As a device property, the list of allowed values as well as the value
581 associated with a port_id should be retrieved by other means.
582
583 - Default ``mask`` matches any port index.
584
585 .. _table_rte_flow_item_port:
586
587 .. table:: PORT
588
589    +----------+-----------+--------------------------------+
590    | Field    | Subfield  | Value                          |
591    +==========+===========+================================+
592    | ``spec`` | ``index`` | physical port index            |
593    +----------+-----------+--------------------------------+
594    | ``last`` | ``index`` | upper range value              |
595    +----------+-----------+--------------------------------+
596    | ``mask`` | ``index`` | zeroed to match any port index |
597    +----------+-----------+--------------------------------+
598
599 Data matching item types
600 ~~~~~~~~~~~~~~~~~~~~~~~~
601
602 Most of these are basically protocol header definitions with associated
603 bit-masks. They must be specified (stacked) from lowest to highest protocol
604 layer to form a matching pattern.
605
606 The following list is not exhaustive, new protocols will be added in the
607 future.
608
609 Item: ``ANY``
610 ^^^^^^^^^^^^^
611
612 Matches any protocol in place of the current layer, a single ANY may also
613 stand for several protocol layers.
614
615 This is usually specified as the first pattern item when looking for a
616 protocol anywhere in a packet.
617
618 - Default ``mask`` stands for any number of layers.
619
620 .. _table_rte_flow_item_any:
621
622 .. table:: ANY
623
624    +----------+----------+--------------------------------------+
625    | Field    | Subfield | Value                                |
626    +==========+==========+======================================+
627    | ``spec`` | ``num``  | number of layers covered             |
628    +----------+----------+--------------------------------------+
629    | ``last`` | ``num``  | upper range value                    |
630    +----------+----------+--------------------------------------+
631    | ``mask`` | ``num``  | zeroed to cover any number of layers |
632    +----------+----------+--------------------------------------+
633
634 Example for VXLAN TCP payload matching regardless of outer L3 (IPv4 or IPv6)
635 and L4 (UDP) both matched by the first ANY specification, and inner L3 (IPv4
636 or IPv6) matched by the second ANY specification:
637
638 .. _table_rte_flow_item_any_example:
639
640 .. table:: TCP in VXLAN with wildcards
641
642    +-------+------+----------+----------+-------+
643    | Index | Item | Field    | Subfield | Value |
644    +=======+======+==========+==========+=======+
645    | 0     | Ethernet                           |
646    +-------+------+----------+----------+-------+
647    | 1     | ANY  | ``spec`` | ``num``  | 2     |
648    +-------+------+----------+----------+-------+
649    | 2     | VXLAN                              |
650    +-------+------------------------------------+
651    | 3     | Ethernet                           |
652    +-------+------+----------+----------+-------+
653    | 4     | ANY  | ``spec`` | ``num``  | 1     |
654    +-------+------+----------+----------+-------+
655    | 5     | TCP                                |
656    +-------+------------------------------------+
657    | 6     | END                                |
658    +-------+------------------------------------+
659
660 Item: ``RAW``
661 ^^^^^^^^^^^^^
662
663 Matches a byte string of a given length at a given offset.
664
665 Offset is either absolute (using the start of the packet) or relative to the
666 end of the previous matched item in the stack, in which case negative values
667 are allowed.
668
669 If search is enabled, offset is used as the starting point. The search area
670 can be delimited by setting limit to a nonzero value, which is the maximum
671 number of bytes after offset where the pattern may start.
672
673 Matching a zero-length pattern is allowed, doing so resets the relative
674 offset for subsequent items.
675
676 - This type does not support ranges (``last`` field).
677 - Default ``mask`` matches all fields exactly.
678
679 .. _table_rte_flow_item_raw:
680
681 .. table:: RAW
682
683    +----------+--------------+-------------------------------------------------+
684    | Field    | Subfield     | Value                                           |
685    +==========+==============+=================================================+
686    | ``spec`` | ``relative`` | look for pattern after the previous item        |
687    |          +--------------+-------------------------------------------------+
688    |          | ``search``   | search pattern from offset (see also ``limit``) |
689    |          +--------------+-------------------------------------------------+
690    |          | ``reserved`` | reserved, must be set to zero                   |
691    |          +--------------+-------------------------------------------------+
692    |          | ``offset``   | absolute or relative offset for ``pattern``     |
693    |          +--------------+-------------------------------------------------+
694    |          | ``limit``    | search area limit for start of ``pattern``      |
695    |          +--------------+-------------------------------------------------+
696    |          | ``length``   | ``pattern`` length                              |
697    |          +--------------+-------------------------------------------------+
698    |          | ``pattern``  | byte string to look for                         |
699    +----------+--------------+-------------------------------------------------+
700    | ``last`` | if specified, either all 0 or with the same values as ``spec`` |
701    +----------+----------------------------------------------------------------+
702    | ``mask`` | bit-mask applied to ``spec`` values with usual behavior        |
703    +----------+----------------------------------------------------------------+
704
705 Example pattern looking for several strings at various offsets of a UDP
706 payload, using combined RAW items:
707
708 .. _table_rte_flow_item_raw_example:
709
710 .. table:: UDP payload matching
711
712    +-------+------+----------+--------------+-------+
713    | Index | Item | Field    | Subfield     | Value |
714    +=======+======+==========+==============+=======+
715    | 0     | Ethernet                               |
716    +-------+----------------------------------------+
717    | 1     | IPv4                                   |
718    +-------+----------------------------------------+
719    | 2     | UDP                                    |
720    +-------+------+----------+--------------+-------+
721    | 3     | RAW  | ``spec`` | ``relative`` | 1     |
722    |       |      |          +--------------+-------+
723    |       |      |          | ``search``   | 1     |
724    |       |      |          +--------------+-------+
725    |       |      |          | ``offset``   | 10    |
726    |       |      |          +--------------+-------+
727    |       |      |          | ``limit``    | 0     |
728    |       |      |          +--------------+-------+
729    |       |      |          | ``length``   | 3     |
730    |       |      |          +--------------+-------+
731    |       |      |          | ``pattern``  | "foo" |
732    +-------+------+----------+--------------+-------+
733    | 4     | RAW  | ``spec`` | ``relative`` | 1     |
734    |       |      |          +--------------+-------+
735    |       |      |          | ``search``   | 0     |
736    |       |      |          +--------------+-------+
737    |       |      |          | ``offset``   | 20    |
738    |       |      |          +--------------+-------+
739    |       |      |          | ``limit``    | 0     |
740    |       |      |          +--------------+-------+
741    |       |      |          | ``length``   | 3     |
742    |       |      |          +--------------+-------+
743    |       |      |          | ``pattern``  | "bar" |
744    +-------+------+----------+--------------+-------+
745    | 5     | RAW  | ``spec`` | ``relative`` | 1     |
746    |       |      |          +--------------+-------+
747    |       |      |          | ``search``   | 0     |
748    |       |      |          +--------------+-------+
749    |       |      |          | ``offset``   | -29   |
750    |       |      |          +--------------+-------+
751    |       |      |          | ``limit``    | 0     |
752    |       |      |          +--------------+-------+
753    |       |      |          | ``length``   | 3     |
754    |       |      |          +--------------+-------+
755    |       |      |          | ``pattern``  | "baz" |
756    +-------+------+----------+--------------+-------+
757    | 6     | END                                    |
758    +-------+----------------------------------------+
759
760 This translates to:
761
762 - Locate "foo" at least 10 bytes deep inside UDP payload.
763 - Locate "bar" after "foo" plus 20 bytes.
764 - Locate "baz" after "bar" minus 29 bytes.
765
766 Such a packet may be represented as follows (not to scale)::
767
768  0                     >= 10 B           == 20 B
769  |                  |<--------->|     |<--------->|
770  |                  |           |     |           |
771  |-----|------|-----|-----|-----|-----|-----------|-----|------|
772  | ETH | IPv4 | UDP | ... | baz | foo | ......... | bar | .... |
773  |-----|------|-----|-----|-----|-----|-----------|-----|------|
774                           |                             |
775                           |<--------------------------->|
776                                       == 29 B
777
778 Note that matching subsequent pattern items would resume after "baz", not
779 "bar" since matching is always performed after the previous item of the
780 stack.
781
782 Item: ``ETH``
783 ^^^^^^^^^^^^^
784
785 Matches an Ethernet header.
786
787 The ``type`` field either stands for "EtherType" or "TPID" when followed by
788 so-called layer 2.5 pattern items such as ``RTE_FLOW_ITEM_TYPE_VLAN``. In
789 the latter case, ``type`` refers to that of the outer header, with the inner
790 EtherType/TPID provided by the subsequent pattern item. This is the same
791 order as on the wire.
792
793 - ``dst``: destination MAC.
794 - ``src``: source MAC.
795 - ``type``: EtherType or TPID.
796 - Default ``mask`` matches destination and source addresses only.
797
798 Item: ``VLAN``
799 ^^^^^^^^^^^^^^
800
801 Matches an 802.1Q/ad VLAN tag.
802
803 The corresponding standard outer EtherType (TPID) values are
804 ``ETHER_TYPE_VLAN`` or ``ETHER_TYPE_QINQ``. It can be overridden by the
805 preceding pattern item.
806
807 - ``tci``: tag control information.
808 - ``inner_type``: inner EtherType or TPID.
809 - Default ``mask`` matches the VID part of TCI only (lower 12 bits).
810
811 Item: ``IPV4``
812 ^^^^^^^^^^^^^^
813
814 Matches an IPv4 header.
815
816 Note: IPv4 options are handled by dedicated pattern items.
817
818 - ``hdr``: IPv4 header definition (``rte_ip.h``).
819 - Default ``mask`` matches source and destination addresses only.
820
821 Item: ``IPV6``
822 ^^^^^^^^^^^^^^
823
824 Matches an IPv6 header.
825
826 Note: IPv6 options are handled by dedicated pattern items.
827
828 - ``hdr``: IPv6 header definition (``rte_ip.h``).
829 - Default ``mask`` matches source and destination addresses only.
830
831 Item: ``ICMP``
832 ^^^^^^^^^^^^^^
833
834 Matches an ICMP header.
835
836 - ``hdr``: ICMP header definition (``rte_icmp.h``).
837 - Default ``mask`` matches ICMP type and code only.
838
839 Item: ``UDP``
840 ^^^^^^^^^^^^^
841
842 Matches a UDP header.
843
844 - ``hdr``: UDP header definition (``rte_udp.h``).
845 - Default ``mask`` matches source and destination ports only.
846
847 Item: ``TCP``
848 ^^^^^^^^^^^^^
849
850 Matches a TCP header.
851
852 - ``hdr``: TCP header definition (``rte_tcp.h``).
853 - Default ``mask`` matches source and destination ports only.
854
855 Item: ``SCTP``
856 ^^^^^^^^^^^^^^
857
858 Matches a SCTP header.
859
860 - ``hdr``: SCTP header definition (``rte_sctp.h``).
861 - Default ``mask`` matches source and destination ports only.
862
863 Item: ``VXLAN``
864 ^^^^^^^^^^^^^^^
865
866 Matches a VXLAN header (RFC 7348).
867
868 - ``flags``: normally 0x08 (I flag).
869 - ``rsvd0``: reserved, normally 0x000000.
870 - ``vni``: VXLAN network identifier.
871 - ``rsvd1``: reserved, normally 0x00.
872 - Default ``mask`` matches VNI only.
873
874 Item: ``E_TAG``
875 ^^^^^^^^^^^^^^^
876
877 Matches an IEEE 802.1BR E-Tag header.
878
879 The corresponding standard outer EtherType (TPID) value is
880 ``ETHER_TYPE_ETAG``. It can be overridden by the preceding pattern item.
881
882 - ``epcp_edei_in_ecid_b``: E-Tag control information (E-TCI), E-PCP (3b),
883   E-DEI (1b), ingress E-CID base (12b).
884 - ``rsvd_grp_ecid_b``: reserved (2b), GRP (2b), E-CID base (12b).
885 - ``in_ecid_e``: ingress E-CID ext.
886 - ``ecid_e``: E-CID ext.
887 - ``inner_type``: inner EtherType or TPID.
888 - Default ``mask`` simultaneously matches GRP and E-CID base.
889
890 Item: ``NVGRE``
891 ^^^^^^^^^^^^^^^
892
893 Matches a NVGRE header (RFC 7637).
894
895 - ``c_k_s_rsvd0_ver``: checksum (1b), undefined (1b), key bit (1b),
896   sequence number (1b), reserved 0 (9b), version (3b). This field must have
897   value 0x2000 according to RFC 7637.
898 - ``protocol``: protocol type (0x6558).
899 - ``tni``: virtual subnet ID.
900 - ``flow_id``: flow ID.
901 - Default ``mask`` matches TNI only.
902
903 Item: ``MPLS``
904 ^^^^^^^^^^^^^^
905
906 Matches a MPLS header.
907
908 - ``label_tc_s_ttl``: label, TC, Bottom of Stack and TTL.
909 - Default ``mask`` matches label only.
910
911 Item: ``GRE``
912 ^^^^^^^^^^^^^
913
914 Matches a GRE header.
915
916 - ``c_rsvd0_ver``: checksum, reserved 0 and version.
917 - ``protocol``: protocol type.
918 - Default ``mask`` matches protocol only.
919
920 Item: ``FUZZY``
921 ^^^^^^^^^^^^^^^
922
923 Fuzzy pattern match, expect faster than default.
924
925 This is for device that support fuzzy match option. Usually a fuzzy match is
926 fast but the cost is accuracy. i.e. Signature Match only match pattern's hash
927 value, but it is possible two different patterns have the same hash value.
928
929 Matching accuracy level can be configured by threshold. Driver can divide the
930 range of threshold and map to different accuracy levels that device support.
931
932 Threshold 0 means perfect match (no fuzziness), while threshold 0xffffffff
933 means fuzziest match.
934
935 .. _table_rte_flow_item_fuzzy:
936
937 .. table:: FUZZY
938
939    +----------+---------------+--------------------------------------------------+
940    | Field    |   Subfield    | Value                                            |
941    +==========+===============+==================================================+
942    | ``spec`` | ``threshold`` | 0 as perfect match, 0xffffffff as fuzziest match |
943    +----------+---------------+--------------------------------------------------+
944    | ``last`` | ``threshold`` | upper range value                                |
945    +----------+---------------+--------------------------------------------------+
946    | ``mask`` | ``threshold`` | bit-mask apply to "spec" and "last"              |
947    +----------+---------------+--------------------------------------------------+
948
949 Usage example, fuzzy match a TCPv4 packets:
950
951 .. _table_rte_flow_item_fuzzy_example:
952
953 .. table:: Fuzzy matching
954
955    +-------+----------+
956    | Index | Item     |
957    +=======+==========+
958    | 0     | FUZZY    |
959    +-------+----------+
960    | 1     | Ethernet |
961    +-------+----------+
962    | 2     | IPv4     |
963    +-------+----------+
964    | 3     | TCP      |
965    +-------+----------+
966    | 4     | END      |
967    +-------+----------+
968
969 Item: ``GTP``, ``GTPC``, ``GTPU``
970 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
971
972 Matches a GTPv1 header.
973
974 Note: GTP, GTPC and GTPU use the same structure. GTPC and GTPU item
975 are defined for a user-friendly API when creating GTP-C and GTP-U
976 flow rules.
977
978 - ``v_pt_rsv_flags``: version (3b), protocol type (1b), reserved (1b),
979   extension header flag (1b), sequence number flag (1b), N-PDU number
980   flag (1b).
981 - ``msg_type``: message type.
982 - ``msg_len``: message length.
983 - ``teid``: tunnel endpoint identifier.
984 - Default ``mask`` matches teid only.
985
986 Item: ``ESP``
987 ^^^^^^^^^^^^^
988
989 Matches an ESP header.
990
991 - ``hdr``: ESP header definition (``rte_esp.h``).
992 - Default ``mask`` matches SPI only.
993
994 Item: ``GENEVE``
995 ^^^^^^^^^^^^^^^^
996
997 Matches a GENEVE header.
998
999 - ``ver_opt_len_o_c_rsvd0``: version (2b), length of the options fields (6b),
1000   OAM packet (1b), critical options present (1b), reserved 0 (6b).
1001 - ``protocol``: protocol type.
1002 - ``vni``: virtual network identifier.
1003 - ``rsvd1``: reserved, normally 0x00.
1004 - Default ``mask`` matches VNI only.
1005
1006 Actions
1007 ~~~~~~~
1008
1009 Each possible action is represented by a type. Some have associated
1010 configuration structures. Several actions combined in a list can be assigned
1011 to a flow rule and are performed in order.
1012
1013 They fall in three categories:
1014
1015 - Actions that modify the fate of matching traffic, for instance by dropping
1016   or assigning it a specific destination.
1017
1018 - Actions that modify matching traffic contents or its properties. This
1019   includes adding/removing encapsulation, encryption, compression and marks.
1020
1021 - Actions related to the flow rule itself, such as updating counters or
1022   making it non-terminating.
1023
1024 Flow rules being terminating by default, not specifying any action of the
1025 fate kind results in undefined behavior. This applies to both ingress and
1026 egress.
1027
1028 PASSTHRU, when supported, makes a flow rule non-terminating.
1029
1030 Like matching patterns, action lists are terminated by END items.
1031
1032 Example of action that redirects packets to queue index 10:
1033
1034 .. _table_rte_flow_action_example:
1035
1036 .. table:: Queue action
1037
1038    +-----------+-------+
1039    | Field     | Value |
1040    +===========+=======+
1041    | ``index`` | 10    |
1042    +-----------+-------+
1043
1044 Actions are performed in list order:
1045
1046 .. _table_rte_flow_count_then_drop:
1047
1048 .. table:: Count then drop
1049
1050    +-------+--------+
1051    | Index | Action |
1052    +=======+========+
1053    | 0     | COUNT  |
1054    +-------+--------+
1055    | 1     | DROP   |
1056    +-------+--------+
1057    | 2     | END    |
1058    +-------+--------+
1059
1060 |
1061
1062 .. _table_rte_flow_mark_count_redirect:
1063
1064 .. table:: Mark, count then redirect
1065
1066    +-------+--------+-----------+-------+
1067    | Index | Action | Field     | Value |
1068    +=======+========+===========+=======+
1069    | 0     | MARK   | ``mark``  | 0x2a  |
1070    +-------+--------+-----------+-------+
1071    | 1     | COUNT                      |
1072    +-------+--------+-----------+-------+
1073    | 2     | QUEUE  | ``queue`` | 10    |
1074    +-------+--------+-----------+-------+
1075    | 3     | END                        |
1076    +-------+----------------------------+
1077
1078 |
1079
1080 .. _table_rte_flow_redirect_queue_5:
1081
1082 .. table:: Redirect to queue 5
1083
1084    +-------+--------+-----------+-------+
1085    | Index | Action | Field     | Value |
1086    +=======+========+===========+=======+
1087    | 0     | DROP                       |
1088    +-------+--------+-----------+-------+
1089    | 1     | QUEUE  | ``queue`` | 5     |
1090    +-------+--------+-----------+-------+
1091    | 2     | END                        |
1092    +-------+----------------------------+
1093
1094 In the above example, while DROP and QUEUE must be performed in order, both
1095 have to happen before reaching END. Only QUEUE has a visible effect.
1096
1097 Note that such a list may be thought as ambiguous and rejected on that
1098 basis.
1099
1100 .. _table_rte_flow_redirect_queue_5_3:
1101
1102 .. table:: Redirect to queues 5 and 3
1103
1104    +-------+--------+-----------+-------+
1105    | Index | Action | Field     | Value |
1106    +=======+========+===========+=======+
1107    | 0     | QUEUE  | ``queue`` | 5     |
1108    +-------+--------+-----------+-------+
1109    | 1     | VOID                       |
1110    +-------+--------+-----------+-------+
1111    | 2     | QUEUE  | ``queue`` | 3     |
1112    +-------+--------+-----------+-------+
1113    | 3     | END                        |
1114    +-------+----------------------------+
1115
1116 As previously described, all actions must be taken into account. This
1117 effectively duplicates traffic to both queues. The above example also shows
1118 that VOID is ignored.
1119
1120 Action types
1121 ~~~~~~~~~~~~
1122
1123 Common action types are described in this section. Like pattern item types,
1124 this list is not exhaustive as new actions will be added in the future.
1125
1126 Action: ``END``
1127 ^^^^^^^^^^^^^^^
1128
1129 End marker for action lists. Prevents further processing of actions, thereby
1130 ending the list.
1131
1132 - Its numeric value is 0 for convenience.
1133 - PMD support is mandatory.
1134 - No configurable properties.
1135
1136 .. _table_rte_flow_action_end:
1137
1138 .. table:: END
1139
1140    +---------------+
1141    | Field         |
1142    +===============+
1143    | no properties |
1144    +---------------+
1145
1146 Action: ``VOID``
1147 ^^^^^^^^^^^^^^^^
1148
1149 Used as a placeholder for convenience. It is ignored and simply discarded by
1150 PMDs.
1151
1152 - PMD support is mandatory.
1153 - No configurable properties.
1154
1155 .. _table_rte_flow_action_void:
1156
1157 .. table:: VOID
1158
1159    +---------------+
1160    | Field         |
1161    +===============+
1162    | no properties |
1163    +---------------+
1164
1165 Action: ``PASSTHRU``
1166 ^^^^^^^^^^^^^^^^^^^^
1167
1168 Leaves traffic up for additional processing by subsequent flow rules; makes
1169 a flow rule non-terminating.
1170
1171 - No configurable properties.
1172
1173 .. _table_rte_flow_action_passthru:
1174
1175 .. table:: PASSTHRU
1176
1177    +---------------+
1178    | Field         |
1179    +===============+
1180    | no properties |
1181    +---------------+
1182
1183 Example to copy a packet to a queue and continue processing by subsequent
1184 flow rules:
1185
1186 .. _table_rte_flow_action_passthru_example:
1187
1188 .. table:: Copy to queue 8
1189
1190    +-------+--------+-----------+-------+
1191    | Index | Action | Field     | Value |
1192    +=======+========+===========+=======+
1193    | 0     | PASSTHRU                   |
1194    +-------+--------+-----------+-------+
1195    | 1     | QUEUE  | ``queue`` | 8     |
1196    +-------+--------+-----------+-------+
1197    | 2     | END                        |
1198    +-------+----------------------------+
1199
1200 Action: ``MARK``
1201 ^^^^^^^^^^^^^^^^
1202
1203 Attaches an integer value to packets and sets ``PKT_RX_FDIR`` and
1204 ``PKT_RX_FDIR_ID`` mbuf flags.
1205
1206 This value is arbitrary and application-defined. Maximum allowed value
1207 depends on the underlying implementation. It is returned in the
1208 ``hash.fdir.hi`` mbuf field.
1209
1210 .. _table_rte_flow_action_mark:
1211
1212 .. table:: MARK
1213
1214    +--------+--------------------------------------+
1215    | Field  | Value                                |
1216    +========+======================================+
1217    | ``id`` | integer value to return with packets |
1218    +--------+--------------------------------------+
1219
1220 Action: ``FLAG``
1221 ^^^^^^^^^^^^^^^^
1222
1223 Flags packets. Similar to `Action: MARK`_ without a specific value; only
1224 sets the ``PKT_RX_FDIR`` mbuf flag.
1225
1226 - No configurable properties.
1227
1228 .. _table_rte_flow_action_flag:
1229
1230 .. table:: FLAG
1231
1232    +---------------+
1233    | Field         |
1234    +===============+
1235    | no properties |
1236    +---------------+
1237
1238 Action: ``QUEUE``
1239 ^^^^^^^^^^^^^^^^^
1240
1241 Assigns packets to a given queue index.
1242
1243 .. _table_rte_flow_action_queue:
1244
1245 .. table:: QUEUE
1246
1247    +-----------+--------------------+
1248    | Field     | Value              |
1249    +===========+====================+
1250    | ``index`` | queue index to use |
1251    +-----------+--------------------+
1252
1253 Action: ``DROP``
1254 ^^^^^^^^^^^^^^^^
1255
1256 Drop packets.
1257
1258 - No configurable properties.
1259
1260 .. _table_rte_flow_action_drop:
1261
1262 .. table:: DROP
1263
1264    +---------------+
1265    | Field         |
1266    +===============+
1267    | no properties |
1268    +---------------+
1269
1270 Action: ``COUNT``
1271 ^^^^^^^^^^^^^^^^^
1272
1273 Enables counters for this rule.
1274
1275 These counters can be retrieved and reset through ``rte_flow_query()``, see
1276 ``struct rte_flow_query_count``.
1277
1278 - Counters can be retrieved with ``rte_flow_query()``.
1279 - No configurable properties.
1280
1281 .. _table_rte_flow_action_count:
1282
1283 .. table:: COUNT
1284
1285    +---------------+
1286    | Field         |
1287    +===============+
1288    | no properties |
1289    +---------------+
1290
1291 Query structure to retrieve and reset flow rule counters:
1292
1293 .. _table_rte_flow_query_count:
1294
1295 .. table:: COUNT query
1296
1297    +---------------+-----+-----------------------------------+
1298    | Field         | I/O | Value                             |
1299    +===============+=====+===================================+
1300    | ``reset``     | in  | reset counter after query         |
1301    +---------------+-----+-----------------------------------+
1302    | ``hits_set``  | out | ``hits`` field is set             |
1303    +---------------+-----+-----------------------------------+
1304    | ``bytes_set`` | out | ``bytes`` field is set            |
1305    +---------------+-----+-----------------------------------+
1306    | ``hits``      | out | number of hits for this rule      |
1307    +---------------+-----+-----------------------------------+
1308    | ``bytes``     | out | number of bytes through this rule |
1309    +---------------+-----+-----------------------------------+
1310
1311 Action: ``RSS``
1312 ^^^^^^^^^^^^^^^
1313
1314 Similar to QUEUE, except RSS is additionally performed on packets to spread
1315 them among several queues according to the provided parameters.
1316
1317 Unlike global RSS settings used by other DPDK APIs, unsetting the ``types``
1318 field does not disable RSS in a flow rule. Doing so instead requests safe
1319 unspecified "best-effort" settings from the underlying PMD, which depending
1320 on the flow rule, may result in anything ranging from empty (single queue)
1321 to all-inclusive RSS.
1322
1323 Note: RSS hash result is stored in the ``hash.rss`` mbuf field which
1324 overlaps ``hash.fdir.lo``. Since `Action: MARK`_ sets the ``hash.fdir.hi``
1325 field only, both can be requested simultaneously.
1326
1327 Also, regarding packet encapsulation ``level``:
1328
1329 - ``0`` requests the default behavior. Depending on the packet type, it can
1330   mean outermost, innermost, anything in between or even no RSS.
1331
1332   It basically stands for the innermost encapsulation level RSS can be
1333   performed on according to PMD and device capabilities.
1334
1335 - ``1`` requests RSS to be performed on the outermost packet encapsulation
1336   level.
1337
1338 - ``2`` and subsequent values request RSS to be performed on the specified
1339    inner packet encapsulation level, from outermost to innermost (lower to
1340    higher values).
1341
1342 Values other than ``0`` are not necessarily supported.
1343
1344 Requesting a specific RSS level on unrecognized traffic results in undefined
1345 behavior. For predictable results, it is recommended to make the flow rule
1346 pattern match packet headers up to the requested encapsulation level so that
1347 only matching traffic goes through.
1348
1349 .. _table_rte_flow_action_rss:
1350
1351 .. table:: RSS
1352
1353    +---------------+---------------------------------------------+
1354    | Field         | Value                                       |
1355    +===============+=============================================+
1356    | ``func``      | RSS hash function to apply                  |
1357    +---------------+---------------------------------------------+
1358    | ``level``     | encapsulation level for ``types``           |
1359    +---------------+---------------------------------------------+
1360    | ``types``     | specific RSS hash types (see ``ETH_RSS_*``) |
1361    +---------------+---------------------------------------------+
1362    | ``key_len``   | hash key length in bytes                    |
1363    +---------------+---------------------------------------------+
1364    | ``queue_num`` | number of entries in ``queue``              |
1365    +---------------+---------------------------------------------+
1366    | ``key``       | hash key                                    |
1367    +---------------+---------------------------------------------+
1368    | ``queue``     | queue indices to use                        |
1369    +---------------+---------------------------------------------+
1370
1371 Action: ``PF``
1372 ^^^^^^^^^^^^^^
1373
1374 Redirects packets to the physical function (PF) of the current device.
1375
1376 - No configurable properties.
1377
1378 .. _table_rte_flow_action_pf:
1379
1380 .. table:: PF
1381
1382    +---------------+
1383    | Field         |
1384    +===============+
1385    | no properties |
1386    +---------------+
1387
1388 Action: ``VF``
1389 ^^^^^^^^^^^^^^
1390
1391 Redirects packets to a virtual function (VF) of the current device.
1392
1393 Packets matched by a VF pattern item can be redirected to their original VF
1394 ID instead of the specified one. This parameter may not be available and is
1395 not guaranteed to work properly if the VF part is matched by a prior flow
1396 rule or if packets are not addressed to a VF in the first place.
1397
1398 .. _table_rte_flow_action_vf:
1399
1400 .. table:: VF
1401
1402    +--------------+--------------------------------+
1403    | Field        | Value                          |
1404    +==============+================================+
1405    | ``original`` | use original VF ID if possible |
1406    +--------------+--------------------------------+
1407    | ``vf``       | VF ID to redirect packets to   |
1408    +--------------+--------------------------------+
1409
1410 Action: ``METER``
1411 ^^^^^^^^^^^^^^^^^
1412
1413 Applies a stage of metering and policing.
1414
1415 The metering and policing (MTR) object has to be first created using the
1416 rte_mtr_create() API function. The ID of the MTR object is specified as
1417 action parameter. More than one flow can use the same MTR object through
1418 the meter action. The MTR object can be further updated or queried using
1419 the rte_mtr* API.
1420
1421 .. _table_rte_flow_action_meter:
1422
1423 .. table:: METER
1424
1425    +--------------+---------------+
1426    | Field        | Value         |
1427    +==============+===============+
1428    | ``mtr_id``   | MTR object ID |
1429    +--------------+---------------+
1430
1431 Action: ``SECURITY``
1432 ^^^^^^^^^^^^^^^^^^^^
1433
1434 Perform the security action on flows matched by the pattern items
1435 according to the configuration of the security session.
1436
1437 This action modifies the payload of matched flows. For INLINE_CRYPTO, the
1438 security protocol headers and IV are fully provided by the application as
1439 specified in the flow pattern. The payload of matching packets is
1440 encrypted on egress, and decrypted and authenticated on ingress.
1441 For INLINE_PROTOCOL, the security protocol is fully offloaded to HW,
1442 providing full encapsulation and decapsulation of packets in security
1443 protocols. The flow pattern specifies both the outer security header fields
1444 and the inner packet fields. The security session specified in the action
1445 must match the pattern parameters.
1446
1447 The security session specified in the action must be created on the same
1448 port as the flow action that is being specified.
1449
1450 The ingress/egress flow attribute should match that specified in the
1451 security session if the security session supports the definition of the
1452 direction.
1453
1454 Multiple flows can be configured to use the same security session.
1455
1456 .. _table_rte_flow_action_security:
1457
1458 .. table:: SECURITY
1459
1460    +----------------------+--------------------------------------+
1461    | Field                | Value                                |
1462    +======================+======================================+
1463    | ``security_session`` | security session to apply            |
1464    +----------------------+--------------------------------------+
1465
1466 The following is an example of configuring IPsec inline using the
1467 INLINE_CRYPTO security session:
1468
1469 The encryption algorithm, keys and salt are part of the opaque
1470 ``rte_security_session``. The SA is identified according to the IP and ESP
1471 fields in the pattern items.
1472
1473 .. _table_rte_flow_item_esp_inline_example:
1474
1475 .. table:: IPsec inline crypto flow pattern items.
1476
1477    +-------+----------+
1478    | Index | Item     |
1479    +=======+==========+
1480    | 0     | Ethernet |
1481    +-------+----------+
1482    | 1     | IPv4     |
1483    +-------+----------+
1484    | 2     | ESP      |
1485    +-------+----------+
1486    | 3     | END      |
1487    +-------+----------+
1488
1489 .. _table_rte_flow_action_esp_inline_example:
1490
1491 .. table:: IPsec inline flow actions.
1492
1493    +-------+----------+
1494    | Index | Action   |
1495    +=======+==========+
1496    | 0     | SECURITY |
1497    +-------+----------+
1498    | 1     | END      |
1499    +-------+----------+
1500
1501 Negative types
1502 ~~~~~~~~~~~~~~
1503
1504 All specified pattern items (``enum rte_flow_item_type``) and actions
1505 (``enum rte_flow_action_type``) use positive identifiers.
1506
1507 The negative space is reserved for dynamic types generated by PMDs during
1508 run-time. PMDs may encounter them as a result but must not accept negative
1509 identifiers they are not aware of.
1510
1511 A method to generate them remains to be defined.
1512
1513 Planned types
1514 ~~~~~~~~~~~~~
1515
1516 Pattern item types will be added as new protocols are implemented.
1517
1518 Variable headers support through dedicated pattern items, for example in
1519 order to match specific IPv4 options and IPv6 extension headers would be
1520 stacked after IPv4/IPv6 items.
1521
1522 Other action types are planned but are not defined yet. These include the
1523 ability to alter packet data in several ways, such as performing
1524 encapsulation/decapsulation of tunnel headers.
1525
1526 Rules management
1527 ----------------
1528
1529 A rather simple API with few functions is provided to fully manage flow
1530 rules.
1531
1532 Each created flow rule is associated with an opaque, PMD-specific handle
1533 pointer. The application is responsible for keeping it until the rule is
1534 destroyed.
1535
1536 Flows rules are represented by ``struct rte_flow`` objects.
1537
1538 Validation
1539 ~~~~~~~~~~
1540
1541 Given that expressing a definite set of device capabilities is not
1542 practical, a dedicated function is provided to check if a flow rule is
1543 supported and can be created.
1544
1545 .. code-block:: c
1546
1547    int
1548    rte_flow_validate(uint16_t port_id,
1549                      const struct rte_flow_attr *attr,
1550                      const struct rte_flow_item pattern[],
1551                      const struct rte_flow_action actions[],
1552                      struct rte_flow_error *error);
1553
1554 The flow rule is validated for correctness and whether it could be accepted
1555 by the device given sufficient resources. The rule is checked against the
1556 current device mode and queue configuration. The flow rule may also
1557 optionally be validated against existing flow rules and device resources.
1558 This function has no effect on the target device.
1559
1560 The returned value is guaranteed to remain valid only as long as no
1561 successful calls to ``rte_flow_create()`` or ``rte_flow_destroy()`` are made
1562 in the meantime and no device parameter affecting flow rules in any way are
1563 modified, due to possible collisions or resource limitations (although in
1564 such cases ``EINVAL`` should not be returned).
1565
1566 Arguments:
1567
1568 - ``port_id``: port identifier of Ethernet device.
1569 - ``attr``: flow rule attributes.
1570 - ``pattern``: pattern specification (list terminated by the END pattern
1571   item).
1572 - ``actions``: associated actions (list terminated by the END action).
1573 - ``error``: perform verbose error reporting if not NULL. PMDs initialize
1574   this structure in case of error only.
1575
1576 Return values:
1577
1578 - 0 if flow rule is valid and can be created. A negative errno value
1579   otherwise (``rte_errno`` is also set), the following errors are defined.
1580 - ``-ENOSYS``: underlying device does not support this functionality.
1581 - ``-EINVAL``: unknown or invalid rule specification.
1582 - ``-ENOTSUP``: valid but unsupported rule specification (e.g. partial
1583   bit-masks are unsupported).
1584 - ``EEXIST``: collision with an existing rule. Only returned if device
1585   supports flow rule collision checking and there was a flow rule
1586   collision. Not receiving this return code is no guarantee that creating
1587   the rule will not fail due to a collision.
1588 - ``ENOMEM``: not enough memory to execute the function, or if the device
1589   supports resource validation, resource limitation on the device.
1590 - ``-EBUSY``: action cannot be performed due to busy device resources, may
1591   succeed if the affected queues or even the entire port are in a stopped
1592   state (see ``rte_eth_dev_rx_queue_stop()`` and ``rte_eth_dev_stop()``).
1593
1594 Creation
1595 ~~~~~~~~
1596
1597 Creating a flow rule is similar to validating one, except the rule is
1598 actually created and a handle returned.
1599
1600 .. code-block:: c
1601
1602    struct rte_flow *
1603    rte_flow_create(uint16_t port_id,
1604                    const struct rte_flow_attr *attr,
1605                    const struct rte_flow_item pattern[],
1606                    const struct rte_flow_action *actions[],
1607                    struct rte_flow_error *error);
1608
1609 Arguments:
1610
1611 - ``port_id``: port identifier of Ethernet device.
1612 - ``attr``: flow rule attributes.
1613 - ``pattern``: pattern specification (list terminated by the END pattern
1614   item).
1615 - ``actions``: associated actions (list terminated by the END action).
1616 - ``error``: perform verbose error reporting if not NULL. PMDs initialize
1617   this structure in case of error only.
1618
1619 Return values:
1620
1621 A valid handle in case of success, NULL otherwise and ``rte_errno`` is set
1622 to the positive version of one of the error codes defined for
1623 ``rte_flow_validate()``.
1624
1625 Destruction
1626 ~~~~~~~~~~~
1627
1628 Flow rules destruction is not automatic, and a queue or a port should not be
1629 released if any are still attached to them. Applications must take care of
1630 performing this step before releasing resources.
1631
1632 .. code-block:: c
1633
1634    int
1635    rte_flow_destroy(uint16_t port_id,
1636                     struct rte_flow *flow,
1637                     struct rte_flow_error *error);
1638
1639
1640 Failure to destroy a flow rule handle may occur when other flow rules depend
1641 on it, and destroying it would result in an inconsistent state.
1642
1643 This function is only guaranteed to succeed if handles are destroyed in
1644 reverse order of their creation.
1645
1646 Arguments:
1647
1648 - ``port_id``: port identifier of Ethernet device.
1649 - ``flow``: flow rule handle to destroy.
1650 - ``error``: perform verbose error reporting if not NULL. PMDs initialize
1651   this structure in case of error only.
1652
1653 Return values:
1654
1655 - 0 on success, a negative errno value otherwise and ``rte_errno`` is set.
1656
1657 Flush
1658 ~~~~~
1659
1660 Convenience function to destroy all flow rule handles associated with a
1661 port. They are released as with successive calls to ``rte_flow_destroy()``.
1662
1663 .. code-block:: c
1664
1665    int
1666    rte_flow_flush(uint16_t port_id,
1667                   struct rte_flow_error *error);
1668
1669 In the unlikely event of failure, handles are still considered destroyed and
1670 no longer valid but the port must be assumed to be in an inconsistent state.
1671
1672 Arguments:
1673
1674 - ``port_id``: port identifier of Ethernet device.
1675 - ``error``: perform verbose error reporting if not NULL. PMDs initialize
1676   this structure in case of error only.
1677
1678 Return values:
1679
1680 - 0 on success, a negative errno value otherwise and ``rte_errno`` is set.
1681
1682 Query
1683 ~~~~~
1684
1685 Query an existing flow rule.
1686
1687 This function allows retrieving flow-specific data such as counters. Data
1688 is gathered by special actions which must be present in the flow rule
1689 definition.
1690
1691 .. code-block:: c
1692
1693    int
1694    rte_flow_query(uint16_t port_id,
1695                   struct rte_flow *flow,
1696                   enum rte_flow_action_type action,
1697                   void *data,
1698                   struct rte_flow_error *error);
1699
1700 Arguments:
1701
1702 - ``port_id``: port identifier of Ethernet device.
1703 - ``flow``: flow rule handle to query.
1704 - ``action``: action type to query.
1705 - ``data``: pointer to storage for the associated query data type.
1706 - ``error``: perform verbose error reporting if not NULL. PMDs initialize
1707   this structure in case of error only.
1708
1709 Return values:
1710
1711 - 0 on success, a negative errno value otherwise and ``rte_errno`` is set.
1712
1713 Isolated mode
1714 -------------
1715
1716 The general expectation for ingress traffic is that flow rules process it
1717 first; the remaining unmatched or pass-through traffic usually ends up in a
1718 queue (with or without RSS, locally or in some sub-device instance)
1719 depending on the global configuration settings of a port.
1720
1721 While fine from a compatibility standpoint, this approach makes drivers more
1722 complex as they have to check for possible side effects outside of this API
1723 when creating or destroying flow rules. It results in a more limited set of
1724 available rule types due to the way device resources are assigned (e.g. no
1725 support for the RSS action even on capable hardware).
1726
1727 Given that nonspecific traffic can be handled by flow rules as well,
1728 isolated mode is a means for applications to tell a driver that ingress on
1729 the underlying port must be injected from the defined flow rules only; that
1730 no default traffic is expected outside those rules.
1731
1732 This has the following benefits:
1733
1734 - Applications get finer-grained control over the kind of traffic they want
1735   to receive (no traffic by default).
1736
1737 - More importantly they control at what point nonspecific traffic is handled
1738   relative to other flow rules, by adjusting priority levels.
1739
1740 - Drivers can assign more hardware resources to flow rules and expand the
1741   set of supported rule types.
1742
1743 Because toggling isolated mode may cause profound changes to the ingress
1744 processing path of a driver, it may not be possible to leave it once
1745 entered. Likewise, existing flow rules or global configuration settings may
1746 prevent a driver from entering isolated mode.
1747
1748 Applications relying on this mode are therefore encouraged to toggle it as
1749 soon as possible after device initialization, ideally before the first call
1750 to ``rte_eth_dev_configure()`` to avoid possible failures due to conflicting
1751 settings.
1752
1753 Once effective, the following functionality has no effect on the underlying
1754 port and may return errors such as ``ENOTSUP`` ("not supported"):
1755
1756 - Toggling promiscuous mode.
1757 - Toggling allmulticast mode.
1758 - Configuring MAC addresses.
1759 - Configuring multicast addresses.
1760 - Configuring VLAN filters.
1761 - Configuring Rx filters through the legacy API (e.g. FDIR).
1762 - Configuring global RSS settings.
1763
1764 .. code-block:: c
1765
1766    int
1767    rte_flow_isolate(uint16_t port_id, int set, struct rte_flow_error *error);
1768
1769 Arguments:
1770
1771 - ``port_id``: port identifier of Ethernet device.
1772 - ``set``: nonzero to enter isolated mode, attempt to leave it otherwise.
1773 - ``error``: perform verbose error reporting if not NULL. PMDs initialize
1774   this structure in case of error only.
1775
1776 Return values:
1777
1778 - 0 on success, a negative errno value otherwise and ``rte_errno`` is set.
1779
1780 Verbose error reporting
1781 -----------------------
1782
1783 The defined *errno* values may not be accurate enough for users or
1784 application developers who want to investigate issues related to flow rules
1785 management. A dedicated error object is defined for this purpose:
1786
1787 .. code-block:: c
1788
1789    enum rte_flow_error_type {
1790        RTE_FLOW_ERROR_TYPE_NONE, /**< No error. */
1791        RTE_FLOW_ERROR_TYPE_UNSPECIFIED, /**< Cause unspecified. */
1792        RTE_FLOW_ERROR_TYPE_HANDLE, /**< Flow rule (handle). */
1793        RTE_FLOW_ERROR_TYPE_ATTR_GROUP, /**< Group field. */
1794        RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY, /**< Priority field. */
1795        RTE_FLOW_ERROR_TYPE_ATTR_INGRESS, /**< Ingress field. */
1796        RTE_FLOW_ERROR_TYPE_ATTR_EGRESS, /**< Egress field. */
1797        RTE_FLOW_ERROR_TYPE_ATTR, /**< Attributes structure. */
1798        RTE_FLOW_ERROR_TYPE_ITEM_NUM, /**< Pattern length. */
1799        RTE_FLOW_ERROR_TYPE_ITEM, /**< Specific pattern item. */
1800        RTE_FLOW_ERROR_TYPE_ACTION_NUM, /**< Number of actions. */
1801        RTE_FLOW_ERROR_TYPE_ACTION, /**< Specific action. */
1802    };
1803
1804    struct rte_flow_error {
1805        enum rte_flow_error_type type; /**< Cause field and error types. */
1806        const void *cause; /**< Object responsible for the error. */
1807        const char *message; /**< Human-readable error message. */
1808    };
1809
1810 Error type ``RTE_FLOW_ERROR_TYPE_NONE`` stands for no error, in which case
1811 remaining fields can be ignored. Other error types describe the type of the
1812 object pointed by ``cause``.
1813
1814 If non-NULL, ``cause`` points to the object responsible for the error. For a
1815 flow rule, this may be a pattern item or an individual action.
1816
1817 If non-NULL, ``message`` provides a human-readable error message.
1818
1819 This object is normally allocated by applications and set by PMDs in case of
1820 error, the message points to a constant string which does not need to be
1821 freed by the application, however its pointer can be considered valid only
1822 as long as its associated DPDK port remains configured. Closing the
1823 underlying device or unloading the PMD invalidates it.
1824
1825 Helpers
1826 -------
1827
1828 Error initializer
1829 ~~~~~~~~~~~~~~~~~
1830
1831 .. code-block:: c
1832
1833    static inline int
1834    rte_flow_error_set(struct rte_flow_error *error,
1835                       int code,
1836                       enum rte_flow_error_type type,
1837                       const void *cause,
1838                       const char *message);
1839
1840 This function initializes ``error`` (if non-NULL) with the provided
1841 parameters and sets ``rte_errno`` to ``code``. A negative error ``code`` is
1842 then returned.
1843
1844 Caveats
1845 -------
1846
1847 - DPDK does not keep track of flow rules definitions or flow rule objects
1848   automatically. Applications may keep track of the former and must keep
1849   track of the latter. PMDs may also do it for internal needs, however this
1850   must not be relied on by applications.
1851
1852 - Flow rules are not maintained between successive port initializations. An
1853   application exiting without releasing them and restarting must re-create
1854   them from scratch.
1855
1856 - API operations are synchronous and blocking (``EAGAIN`` cannot be
1857   returned).
1858
1859 - There is no provision for reentrancy/multi-thread safety, although nothing
1860   should prevent different devices from being configured at the same
1861   time. PMDs may protect their control path functions accordingly.
1862
1863 - Stopping the data path (TX/RX) should not be necessary when managing flow
1864   rules. If this cannot be achieved naturally or with workarounds (such as
1865   temporarily replacing the burst function pointers), an appropriate error
1866   code must be returned (``EBUSY``).
1867
1868 - PMDs, not applications, are responsible for maintaining flow rules
1869   configuration when stopping and restarting a port or performing other
1870   actions which may affect them. They can only be destroyed explicitly by
1871   applications.
1872
1873 For devices exposing multiple ports sharing global settings affected by flow
1874 rules:
1875
1876 - All ports under DPDK control must behave consistently, PMDs are
1877   responsible for making sure that existing flow rules on a port are not
1878   affected by other ports.
1879
1880 - Ports not under DPDK control (unaffected or handled by other applications)
1881   are user's responsibility. They may affect existing flow rules and cause
1882   undefined behavior. PMDs aware of this may prevent flow rules creation
1883   altogether in such cases.
1884
1885 PMD interface
1886 -------------
1887
1888 The PMD interface is defined in ``rte_flow_driver.h``. It is not subject to
1889 API/ABI versioning constraints as it is not exposed to applications and may
1890 evolve independently.
1891
1892 It is currently implemented on top of the legacy filtering framework through
1893 filter type *RTE_ETH_FILTER_GENERIC* that accepts the single operation
1894 *RTE_ETH_FILTER_GET* to return PMD-specific *rte_flow* callbacks wrapped
1895 inside ``struct rte_flow_ops``.
1896
1897 This overhead is temporarily necessary in order to keep compatibility with
1898 the legacy filtering framework, which should eventually disappear.
1899
1900 - PMD callbacks implement exactly the interface described in `Rules
1901   management`_, except for the port ID argument which has already been
1902   converted to a pointer to the underlying ``struct rte_eth_dev``.
1903
1904 - Public API functions do not process flow rules definitions at all before
1905   calling PMD functions (no basic error checking, no validation
1906   whatsoever). They only make sure these callbacks are non-NULL or return
1907   the ``ENOSYS`` (function not supported) error.
1908
1909 This interface additionally defines the following helper function:
1910
1911 - ``rte_flow_ops_get()``: get generic flow operations structure from a
1912   port.
1913
1914 More will be added over time.
1915
1916 Device compatibility
1917 --------------------
1918
1919 No known implementation supports all the described features.
1920
1921 Unsupported features or combinations are not expected to be fully emulated
1922 in software by PMDs for performance reasons. Partially supported features
1923 may be completed in software as long as hardware performs most of the work
1924 (such as queue redirection and packet recognition).
1925
1926 However PMDs are expected to do their best to satisfy application requests
1927 by working around hardware limitations as long as doing so does not affect
1928 the behavior of existing flow rules.
1929
1930 The following sections provide a few examples of such cases and describe how
1931 PMDs should handle them, they are based on limitations built into the
1932 previous APIs.
1933
1934 Global bit-masks
1935 ~~~~~~~~~~~~~~~~
1936
1937 Each flow rule comes with its own, per-layer bit-masks, while hardware may
1938 support only a single, device-wide bit-mask for a given layer type, so that
1939 two IPv4 rules cannot use different bit-masks.
1940
1941 The expected behavior in this case is that PMDs automatically configure
1942 global bit-masks according to the needs of the first flow rule created.
1943
1944 Subsequent rules are allowed only if their bit-masks match those, the
1945 ``EEXIST`` error code should be returned otherwise.
1946
1947 Unsupported layer types
1948 ~~~~~~~~~~~~~~~~~~~~~~~
1949
1950 Many protocols can be simulated by crafting patterns with the `Item: RAW`_
1951 type.
1952
1953 PMDs can rely on this capability to simulate support for protocols with
1954 headers not directly recognized by hardware.
1955
1956 ``ANY`` pattern item
1957 ~~~~~~~~~~~~~~~~~~~~
1958
1959 This pattern item stands for anything, which can be difficult to translate
1960 to something hardware would understand, particularly if followed by more
1961 specific types.
1962
1963 Consider the following pattern:
1964
1965 .. _table_rte_flow_unsupported_any:
1966
1967 .. table:: Pattern with ANY as L3
1968
1969    +-------+-----------------------+
1970    | Index | Item                  |
1971    +=======+=======================+
1972    | 0     | ETHER                 |
1973    +-------+-----+---------+-------+
1974    | 1     | ANY | ``num`` | ``1`` |
1975    +-------+-----+---------+-------+
1976    | 2     | TCP                   |
1977    +-------+-----------------------+
1978    | 3     | END                   |
1979    +-------+-----------------------+
1980
1981 Knowing that TCP does not make sense with something other than IPv4 and IPv6
1982 as L3, such a pattern may be translated to two flow rules instead:
1983
1984 .. _table_rte_flow_unsupported_any_ipv4:
1985
1986 .. table:: ANY replaced with IPV4
1987
1988    +-------+--------------------+
1989    | Index | Item               |
1990    +=======+====================+
1991    | 0     | ETHER              |
1992    +-------+--------------------+
1993    | 1     | IPV4 (zeroed mask) |
1994    +-------+--------------------+
1995    | 2     | TCP                |
1996    +-------+--------------------+
1997    | 3     | END                |
1998    +-------+--------------------+
1999
2000 |
2001
2002 .. _table_rte_flow_unsupported_any_ipv6:
2003
2004 .. table:: ANY replaced with IPV6
2005
2006    +-------+--------------------+
2007    | Index | Item               |
2008    +=======+====================+
2009    | 0     | ETHER              |
2010    +-------+--------------------+
2011    | 1     | IPV6 (zeroed mask) |
2012    +-------+--------------------+
2013    | 2     | TCP                |
2014    +-------+--------------------+
2015    | 3     | END                |
2016    +-------+--------------------+
2017
2018 Note that as soon as a ANY rule covers several layers, this approach may
2019 yield a large number of hidden flow rules. It is thus suggested to only
2020 support the most common scenarios (anything as L2 and/or L3).
2021
2022 Unsupported actions
2023 ~~~~~~~~~~~~~~~~~~~
2024
2025 - When combined with `Action: QUEUE`_, packet counting (`Action: COUNT`_)
2026   and tagging (`Action: MARK`_ or `Action: FLAG`_) may be implemented in
2027   software as long as the target queue is used by a single rule.
2028
2029 - When a single target queue is provided, `Action: RSS`_ can also be
2030   implemented through `Action: QUEUE`_.
2031
2032 Flow rules priority
2033 ~~~~~~~~~~~~~~~~~~~
2034
2035 While it would naturally make sense, flow rules cannot be assumed to be
2036 processed by hardware in the same order as their creation for several
2037 reasons:
2038
2039 - They may be managed internally as a tree or a hash table instead of a
2040   list.
2041 - Removing a flow rule before adding another one can either put the new rule
2042   at the end of the list or reuse a freed entry.
2043 - Duplication may occur when packets are matched by several rules.
2044
2045 For overlapping rules (particularly in order to use `Action: PASSTHRU`_)
2046 predictable behavior is only guaranteed by using different priority levels.
2047
2048 Priority levels are not necessarily implemented in hardware, or may be
2049 severely limited (e.g. a single priority bit).
2050
2051 For these reasons, priority levels may be implemented purely in software by
2052 PMDs.
2053
2054 - For devices expecting flow rules to be added in the correct order, PMDs
2055   may destroy and re-create existing rules after adding a new one with
2056   a higher priority.
2057
2058 - A configurable number of dummy or empty rules can be created at
2059   initialization time to save high priority slots for later.
2060
2061 - In order to save priority levels, PMDs may evaluate whether rules are
2062   likely to collide and adjust their priority accordingly.
2063
2064 Future evolutions
2065 -----------------
2066
2067 - A device profile selection function which could be used to force a
2068   permanent profile instead of relying on its automatic configuration based
2069   on existing flow rules.
2070
2071 - A method to optimize *rte_flow* rules with specific pattern items and
2072   action types generated on the fly by PMDs. DPDK should assign negative
2073   numbers to these in order to not collide with the existing types. See
2074   `Negative types`_.
2075
2076 - Adding specific egress pattern items and actions as described in
2077   `Attribute: Traffic direction`_.
2078
2079 - Optional software fallback when PMDs are unable to handle requested flow
2080   rules so applications do not have to implement their own.