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