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