1 /* SPDX-License-Identifier: BSD-3-Clause 2 * Copyright 2016 6WIND S.A. 3 * Copyright 2016 Mellanox Technologies, Ltd 4 */ 5 6 #ifndef RTE_FLOW_H_ 7 #define RTE_FLOW_H_ 8 9 /** 10 * @file 11 * RTE generic flow API 12 * 13 * This interface provides the ability to program packet matching and 14 * associated actions in hardware through flow rules. 15 */ 16 17 #include <stddef.h> 18 #include <stdint.h> 19 20 #include <rte_common.h> 21 #include <rte_ether.h> 22 #include <rte_icmp.h> 23 #include <rte_ip.h> 24 #include <rte_sctp.h> 25 #include <rte_tcp.h> 26 #include <rte_udp.h> 27 #include <rte_vxlan.h> 28 #include <rte_esp.h> 29 #include <rte_higig.h> 30 #include <rte_ecpri.h> 31 #include <rte_bitops.h> 32 #include <rte_mbuf_dyn.h> 33 #include <rte_meter.h> 34 #include <rte_gtp.h> 35 #include <rte_l2tpv2.h> 36 #include <rte_ppp.h> 37 #include <rte_gre.h> 38 #include <rte_macsec.h> 39 40 #ifdef __cplusplus 41 extern "C" { 42 #endif 43 44 #define RTE_FLOW_LOG(level, ...) \ 45 rte_log(RTE_LOG_ ## level, rte_eth_dev_logtype, "" __VA_ARGS__) 46 47 /** 48 * Flow rule attributes. 49 * 50 * Priorities are set on a per rule based within groups. 51 * 52 * Lower values denote higher priority, the highest priority for a flow rule 53 * is 0, so that a flow that matches for than one rule, the rule with the 54 * lowest priority value will always be matched. 55 * 56 * Although optional, applications are encouraged to group similar rules as 57 * much as possible to fully take advantage of hardware capabilities 58 * (e.g. optimized matching) and work around limitations (e.g. a single 59 * pattern type possibly allowed in a given group). Applications should be 60 * aware that groups are not linked by default, and that they must be 61 * explicitly linked by the application using the JUMP action. 62 * 63 * Priority levels are arbitrary and up to the application, they 64 * do not need to be contiguous nor start from 0, however the maximum number 65 * varies between devices and may be affected by existing flow rules. 66 * 67 * If a packet is matched by several rules of a given group for a given 68 * priority level, the outcome is undefined. It can take any path, may be 69 * duplicated or even cause unrecoverable errors. 70 * 71 * Note that support for more than a single group and priority level is not 72 * guaranteed. 73 * 74 * At vNIC / ethdev level, flow rules can apply to inbound and / or outbound 75 * traffic (ingress / egress), with respect to the vNIC / ethdev in question. 76 * At embedded switch level, flow rules apply to all traffic seen by it 77 * unless fitting meta items are used to set concrete traffic source(s). 78 * 79 * Several pattern items and actions are valid and can be used in both 80 * directions. Those valid for only one direction are described as such. 81 * 82 * At least one direction must be specified. 83 * 84 * Specifying both directions at once for a given rule is not recommended 85 * but may be valid in a few cases. 86 */ 87 struct rte_flow_attr { 88 uint32_t group; /**< Priority group. */ 89 uint32_t priority; /**< Rule priority level within group. */ 90 /** 91 * The rule in question applies to ingress traffic (non-"transfer"). 92 * 93 * @deprecated 94 * It has been possible to combine this attribute with "transfer". 95 * Doing so has been assumed to restrict the scope of matching 96 * to traffic going from within the embedded switch toward the 97 * ethdev the flow rule being created through. This behaviour 98 * is deprecated. During the transition period, one may still 99 * rely on it, but PMDs and applications are encouraged to 100 * gradually move away from this approach. 101 */ 102 uint32_t ingress:1; 103 /** 104 * The rule in question applies to egress traffic (non-"transfer"). 105 * 106 * @deprecated 107 * It has been possible to combine this attribute with "transfer". 108 * Doing so has been assumed to restrict the scope of matching 109 * to traffic sent by the application by virtue of the ethdev 110 * the flow rule being created through. This behaviour is now 111 * deprecated. During the transition period, one may still 112 * rely on it, but PMDs and applications are encouraged to 113 * gradually move away from this approach. 114 */ 115 uint32_t egress:1; 116 /** 117 * Instead of simply matching the properties of traffic as it would 118 * appear on a given DPDK port ID, enabling this attribute transfers 119 * a flow rule to the lowest possible level of any device endpoints 120 * found in the pattern. 121 * 122 * When supported, this effectively enables an application to 123 * re-route traffic not necessarily intended for it (e.g. coming 124 * from or addressed to different physical ports, VFs or 125 * applications) at the device level. 126 * 127 * The application should match traffic originating from precise 128 * locations. See items PORT_REPRESENTOR and REPRESENTED_PORT. 129 * 130 * Managing "transfer" flows requires that the user communicate them 131 * through a suitable port. @see rte_flow_pick_transfer_proxy(). 132 */ 133 uint32_t transfer:1; 134 uint32_t reserved:29; /**< Reserved, must be zero. */ 135 }; 136 137 /** 138 * Matching pattern item types. 139 * 140 * Pattern items fall in two categories: 141 * 142 * - Matching protocol headers and packet data, usually associated with a 143 * specification structure. These must be stacked in the same order as the 144 * protocol layers to match inside packets, starting from the lowest. 145 * 146 * - Matching meta-data or affecting pattern processing, often without a 147 * specification structure. Since they do not match packet contents, their 148 * position in the list is usually not relevant. 149 * 150 * See the description of individual types for more information. Those 151 * marked with [META] fall into the second category. 152 */ 153 enum rte_flow_item_type { 154 /** 155 * [META] 156 * 157 * End marker for item lists. Prevents further processing of items, 158 * thereby ending the pattern. 159 * 160 * No associated specification structure. 161 */ 162 RTE_FLOW_ITEM_TYPE_END, 163 164 /** 165 * [META] 166 * 167 * Used as a placeholder for convenience. It is ignored and simply 168 * discarded by PMDs. 169 * 170 * No associated specification structure. 171 */ 172 RTE_FLOW_ITEM_TYPE_VOID, 173 174 /** 175 * [META] 176 * 177 * Inverted matching, i.e. process packets that do not match the 178 * pattern. 179 * 180 * No associated specification structure. 181 */ 182 RTE_FLOW_ITEM_TYPE_INVERT, 183 184 /** 185 * Matches any protocol in place of the current layer, a single ANY 186 * may also stand for several protocol layers. 187 * 188 * See struct rte_flow_item_any. 189 */ 190 RTE_FLOW_ITEM_TYPE_ANY, 191 192 /** 193 * @deprecated 194 * @see RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR 195 * @see RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT 196 * 197 * [META] 198 * 199 * Matches traffic originating from (ingress) or going to (egress) a 200 * given DPDK port ID. 201 * 202 * See struct rte_flow_item_port_id. 203 */ 204 RTE_FLOW_ITEM_TYPE_PORT_ID, 205 206 /** 207 * Matches a byte string of a given length at a given offset. 208 * 209 * See struct rte_flow_item_raw. 210 */ 211 RTE_FLOW_ITEM_TYPE_RAW, 212 213 /** 214 * Matches an Ethernet header. 215 * 216 * See struct rte_flow_item_eth. 217 */ 218 RTE_FLOW_ITEM_TYPE_ETH, 219 220 /** 221 * Matches an 802.1Q/ad VLAN tag. 222 * 223 * See struct rte_flow_item_vlan. 224 */ 225 RTE_FLOW_ITEM_TYPE_VLAN, 226 227 /** 228 * Matches an IPv4 header. 229 * 230 * See struct rte_flow_item_ipv4. 231 */ 232 RTE_FLOW_ITEM_TYPE_IPV4, 233 234 /** 235 * Matches an IPv6 header. 236 * 237 * See struct rte_flow_item_ipv6. 238 */ 239 RTE_FLOW_ITEM_TYPE_IPV6, 240 241 /** 242 * Matches an ICMP header. 243 * 244 * See struct rte_flow_item_icmp. 245 */ 246 RTE_FLOW_ITEM_TYPE_ICMP, 247 248 /** 249 * Matches a UDP header. 250 * 251 * See struct rte_flow_item_udp. 252 */ 253 RTE_FLOW_ITEM_TYPE_UDP, 254 255 /** 256 * Matches a TCP header. 257 * 258 * See struct rte_flow_item_tcp. 259 */ 260 RTE_FLOW_ITEM_TYPE_TCP, 261 262 /** 263 * Matches a SCTP header. 264 * 265 * See struct rte_flow_item_sctp. 266 */ 267 RTE_FLOW_ITEM_TYPE_SCTP, 268 269 /** 270 * Matches a VXLAN header. 271 * 272 * See struct rte_flow_item_vxlan. 273 */ 274 RTE_FLOW_ITEM_TYPE_VXLAN, 275 276 /** 277 * Matches a E_TAG header. 278 * 279 * See struct rte_flow_item_e_tag. 280 */ 281 RTE_FLOW_ITEM_TYPE_E_TAG, 282 283 /** 284 * Matches a NVGRE header. 285 * 286 * See struct rte_flow_item_nvgre. 287 */ 288 RTE_FLOW_ITEM_TYPE_NVGRE, 289 290 /** 291 * Matches a MPLS header. 292 * 293 * See struct rte_flow_item_mpls. 294 */ 295 RTE_FLOW_ITEM_TYPE_MPLS, 296 297 /** 298 * Matches a GRE header. 299 * 300 * See struct rte_flow_item_gre. 301 */ 302 RTE_FLOW_ITEM_TYPE_GRE, 303 304 /** 305 * [META] 306 * 307 * Fuzzy pattern match, expect faster than default. 308 * 309 * This is for device that support fuzzy matching option. 310 * Usually a fuzzy matching is fast but the cost is accuracy. 311 * 312 * See struct rte_flow_item_fuzzy. 313 */ 314 RTE_FLOW_ITEM_TYPE_FUZZY, 315 316 /** 317 * Matches a GTP header. 318 * 319 * Configure flow for GTP packets. 320 * 321 * See struct rte_flow_item_gtp. 322 */ 323 RTE_FLOW_ITEM_TYPE_GTP, 324 325 /** 326 * Matches a GTP header. 327 * 328 * Configure flow for GTP-C packets. 329 * 330 * See struct rte_flow_item_gtp. 331 */ 332 RTE_FLOW_ITEM_TYPE_GTPC, 333 334 /** 335 * Matches a GTP header. 336 * 337 * Configure flow for GTP-U packets. 338 * 339 * See struct rte_flow_item_gtp. 340 */ 341 RTE_FLOW_ITEM_TYPE_GTPU, 342 343 /** 344 * Matches a ESP header. 345 * 346 * See struct rte_flow_item_esp. 347 */ 348 RTE_FLOW_ITEM_TYPE_ESP, 349 350 /** 351 * Matches a GENEVE header. 352 * 353 * See struct rte_flow_item_geneve. 354 */ 355 RTE_FLOW_ITEM_TYPE_GENEVE, 356 357 /** 358 * Matches a VXLAN-GPE header. 359 * 360 * See struct rte_flow_item_vxlan_gpe. 361 */ 362 RTE_FLOW_ITEM_TYPE_VXLAN_GPE, 363 364 /** 365 * Matches an ARP header for Ethernet/IPv4. 366 * 367 * See struct rte_flow_item_arp_eth_ipv4. 368 */ 369 RTE_FLOW_ITEM_TYPE_ARP_ETH_IPV4, 370 371 /** 372 * Matches the presence of any IPv6 extension header. 373 * 374 * See struct rte_flow_item_ipv6_ext. 375 */ 376 RTE_FLOW_ITEM_TYPE_IPV6_EXT, 377 378 /** 379 * Matches any ICMPv6 header. 380 * 381 * See struct rte_flow_item_icmp6. 382 */ 383 RTE_FLOW_ITEM_TYPE_ICMP6, 384 385 /** 386 * Matches an ICMPv6 neighbor discovery solicitation. 387 * 388 * See struct rte_flow_item_icmp6_nd_ns. 389 */ 390 RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS, 391 392 /** 393 * Matches an ICMPv6 neighbor discovery advertisement. 394 * 395 * See struct rte_flow_item_icmp6_nd_na. 396 */ 397 RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA, 398 399 /** 400 * Matches the presence of any ICMPv6 neighbor discovery option. 401 * 402 * See struct rte_flow_item_icmp6_nd_opt. 403 */ 404 RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT, 405 406 /** 407 * Matches an ICMPv6 neighbor discovery source Ethernet link-layer 408 * address option. 409 * 410 * See struct rte_flow_item_icmp6_nd_opt_sla_eth. 411 */ 412 RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_SLA_ETH, 413 414 /** 415 * Matches an ICMPv6 neighbor discovery target Ethernet link-layer 416 * address option. 417 * 418 * See struct rte_flow_item_icmp6_nd_opt_tla_eth. 419 */ 420 RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_TLA_ETH, 421 422 /** 423 * Matches specified mark field. 424 * 425 * See struct rte_flow_item_mark. 426 */ 427 RTE_FLOW_ITEM_TYPE_MARK, 428 429 /** 430 * [META] 431 * 432 * Matches a metadata value. 433 * 434 * See struct rte_flow_item_meta. 435 */ 436 RTE_FLOW_ITEM_TYPE_META, 437 438 /** 439 * Matches a GRE optional key field. 440 * 441 * The value should a big-endian 32bit integer. 442 * 443 * When this item present the K bit is implicitly matched as "1" 444 * in the default mask. 445 * 446 * @p spec/mask type: 447 * @code rte_be32_t * @endcode 448 */ 449 RTE_FLOW_ITEM_TYPE_GRE_KEY, 450 451 /** 452 * Matches a GTP extension header: PDU session container. 453 * 454 * Configure flow for GTP packets with extension header type 0x85. 455 * 456 * See struct rte_flow_item_gtp_psc. 457 */ 458 RTE_FLOW_ITEM_TYPE_GTP_PSC, 459 460 /** 461 * Matches a PPPoE header. 462 * 463 * Configure flow for PPPoE session packets. 464 * 465 * See struct rte_flow_item_pppoe. 466 */ 467 RTE_FLOW_ITEM_TYPE_PPPOES, 468 469 /** 470 * Matches a PPPoE header. 471 * 472 * Configure flow for PPPoE discovery packets. 473 * 474 * See struct rte_flow_item_pppoe. 475 */ 476 RTE_FLOW_ITEM_TYPE_PPPOED, 477 478 /** 479 * Matches a PPPoE optional proto_id field. 480 * 481 * It only applies to PPPoE session packets. 482 * 483 * See struct rte_flow_item_pppoe_proto_id. 484 */ 485 RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID, 486 487 /** 488 * Matches Network service header (NSH). 489 * See struct rte_flow_item_nsh. 490 * 491 */ 492 RTE_FLOW_ITEM_TYPE_NSH, 493 494 /** 495 * Matches Internet Group Management Protocol (IGMP). 496 * See struct rte_flow_item_igmp. 497 * 498 */ 499 RTE_FLOW_ITEM_TYPE_IGMP, 500 501 /** 502 * Matches IP Authentication Header (AH). 503 * See struct rte_flow_item_ah. 504 * 505 */ 506 RTE_FLOW_ITEM_TYPE_AH, 507 508 /** 509 * Matches a HIGIG header. 510 * see struct rte_flow_item_higig2_hdr. 511 */ 512 RTE_FLOW_ITEM_TYPE_HIGIG2, 513 514 /** 515 * [META] 516 * 517 * Matches a tag value. 518 * 519 * See struct rte_flow_item_tag. 520 */ 521 RTE_FLOW_ITEM_TYPE_TAG, 522 523 /** 524 * Matches a L2TPv3 over IP header. 525 * 526 * Configure flow for L2TPv3 over IP packets. 527 * 528 * See struct rte_flow_item_l2tpv3oip. 529 */ 530 RTE_FLOW_ITEM_TYPE_L2TPV3OIP, 531 532 /** 533 * Matches PFCP Header. 534 * See struct rte_flow_item_pfcp. 535 * 536 */ 537 RTE_FLOW_ITEM_TYPE_PFCP, 538 539 /** 540 * Matches eCPRI Header. 541 * 542 * Configure flow for eCPRI over ETH or UDP packets. 543 * 544 * See struct rte_flow_item_ecpri. 545 */ 546 RTE_FLOW_ITEM_TYPE_ECPRI, 547 548 /** 549 * Matches the presence of IPv6 fragment extension header. 550 * 551 * See struct rte_flow_item_ipv6_frag_ext. 552 */ 553 RTE_FLOW_ITEM_TYPE_IPV6_FRAG_EXT, 554 555 /** 556 * Matches Geneve Variable Length Option 557 * 558 * See struct rte_flow_item_geneve_opt 559 */ 560 RTE_FLOW_ITEM_TYPE_GENEVE_OPT, 561 562 /** 563 * [META] 564 * 565 * Matches on packet integrity. 566 * For some devices application needs to enable integration checks in HW 567 * before using this item. 568 * 569 * @see struct rte_flow_item_integrity. 570 */ 571 RTE_FLOW_ITEM_TYPE_INTEGRITY, 572 573 /** 574 * [META] 575 * 576 * Matches conntrack state. 577 * 578 * @see struct rte_flow_item_conntrack. 579 */ 580 RTE_FLOW_ITEM_TYPE_CONNTRACK, 581 582 /** 583 * [META] 584 * 585 * Matches traffic entering the embedded switch from the given ethdev. 586 * 587 * @see struct rte_flow_item_ethdev 588 */ 589 RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR, 590 591 /** 592 * [META] 593 * 594 * Matches traffic entering the embedded switch from 595 * the entity represented by the given ethdev. 596 * 597 * @see struct rte_flow_item_ethdev 598 */ 599 RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT, 600 601 /** 602 * Matches a configured set of fields at runtime calculated offsets 603 * over the generic network header with variable length and 604 * flexible pattern 605 * 606 * @see struct rte_flow_item_flex. 607 */ 608 RTE_FLOW_ITEM_TYPE_FLEX, 609 610 /** 611 * Matches L2TPv2 Header. 612 * 613 * See struct rte_flow_item_l2tpv2. 614 */ 615 RTE_FLOW_ITEM_TYPE_L2TPV2, 616 617 /** 618 * Matches PPP Header. 619 * 620 * See struct rte_flow_item_ppp. 621 */ 622 RTE_FLOW_ITEM_TYPE_PPP, 623 624 /** 625 * Matches GRE optional fields. 626 * 627 * See struct rte_flow_item_gre_opt. 628 */ 629 RTE_FLOW_ITEM_TYPE_GRE_OPTION, 630 631 /** 632 * Matches MACsec Ethernet Header. 633 * 634 * See struct rte_flow_item_macsec. 635 */ 636 RTE_FLOW_ITEM_TYPE_MACSEC, 637 }; 638 639 /** 640 * 641 * RTE_FLOW_ITEM_TYPE_HIGIG2 642 * Matches higig2 header 643 */ 644 RTE_STD_C11 645 struct rte_flow_item_higig2_hdr { 646 struct rte_higig2_hdr hdr; 647 }; 648 649 /** Default mask for RTE_FLOW_ITEM_TYPE_HIGIG2. */ 650 #ifndef __cplusplus 651 static const struct rte_flow_item_higig2_hdr rte_flow_item_higig2_hdr_mask = { 652 .hdr = { 653 .ppt1 = { 654 .classification = 0xffff, 655 .vid = 0xfff, 656 }, 657 }, 658 }; 659 #endif 660 661 /** 662 * RTE_FLOW_ITEM_TYPE_ANY 663 * 664 * Matches any protocol in place of the current layer, a single ANY may also 665 * stand for several protocol layers. 666 * 667 * This is usually specified as the first pattern item when looking for a 668 * protocol anywhere in a packet. 669 * 670 * A zeroed mask stands for any number of layers. 671 */ 672 struct rte_flow_item_any { 673 uint32_t num; /**< Number of layers covered. */ 674 }; 675 676 /** Default mask for RTE_FLOW_ITEM_TYPE_ANY. */ 677 #ifndef __cplusplus 678 static const struct rte_flow_item_any rte_flow_item_any_mask = { 679 .num = 0x00000000, 680 }; 681 #endif 682 683 /** 684 * @deprecated 685 * @see RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR 686 * @see RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT 687 * 688 * RTE_FLOW_ITEM_TYPE_PORT_ID 689 * 690 * Matches traffic originating from (ingress) or going to (egress) a given 691 * DPDK port ID. 692 * 693 * Normally only supported if the port ID in question is known by the 694 * underlying PMD and related to the device the flow rule is created 695 * against. 696 */ 697 struct rte_flow_item_port_id { 698 uint32_t id; /**< DPDK port ID. */ 699 }; 700 701 /** Default mask for RTE_FLOW_ITEM_TYPE_PORT_ID. */ 702 #ifndef __cplusplus 703 static const struct rte_flow_item_port_id rte_flow_item_port_id_mask = { 704 .id = 0xffffffff, 705 }; 706 #endif 707 708 /** 709 * RTE_FLOW_ITEM_TYPE_RAW 710 * 711 * Matches a byte string of a given length at a given offset. 712 * 713 * Offset is either absolute (using the start of the packet) or relative to 714 * the end of the previous matched item in the stack, in which case negative 715 * values are allowed. 716 * 717 * If search is enabled, offset is used as the starting point. The search 718 * area can be delimited by setting limit to a nonzero value, which is the 719 * maximum number of bytes after offset where the pattern may start. 720 * 721 * Matching a zero-length pattern is allowed, doing so resets the relative 722 * offset for subsequent items. 723 * 724 * This type does not support ranges (struct rte_flow_item.last). 725 */ 726 struct rte_flow_item_raw { 727 uint32_t relative:1; /**< Look for pattern after the previous item. */ 728 uint32_t search:1; /**< Search pattern from offset (see also limit). */ 729 uint32_t reserved:30; /**< Reserved, must be set to zero. */ 730 int32_t offset; /**< Absolute or relative offset for pattern. */ 731 uint16_t limit; /**< Search area limit for start of pattern. */ 732 uint16_t length; /**< Pattern length. */ 733 const uint8_t *pattern; /**< Byte string to look for. */ 734 }; 735 736 /** Default mask for RTE_FLOW_ITEM_TYPE_RAW. */ 737 #ifndef __cplusplus 738 static const struct rte_flow_item_raw rte_flow_item_raw_mask = { 739 .relative = 1, 740 .search = 1, 741 .reserved = 0x3fffffff, 742 .offset = 0xffffffff, 743 .limit = 0xffff, 744 .length = 0xffff, 745 .pattern = NULL, 746 }; 747 #endif 748 749 /** 750 * RTE_FLOW_ITEM_TYPE_ETH 751 * 752 * Matches an Ethernet header. 753 * 754 * Inside @p hdr field, the sub-field @p ether_type stands either for EtherType 755 * or TPID, depending on whether the item is followed by a VLAN item or not. If 756 * two VLAN items follow, the sub-field refers to the outer one, which, in turn, 757 * contains the inner TPID in the similar header field. The innermost VLAN item 758 * contains a layer-3 EtherType. All of that follows the order seen on the wire. 759 * 760 * If the field in question contains a TPID value, only tagged packets with the 761 * specified TPID will match the pattern. Alternatively, it's possible to match 762 * any type of tagged packets by means of the field @p has_vlan rather than use 763 * the EtherType/TPID field. Also, it's possible to leave the two fields unused. 764 * If this is the case, both tagged and untagged packets will match the pattern. 765 */ 766 RTE_STD_C11 767 struct rte_flow_item_eth { 768 union { 769 struct { 770 /* 771 * These fields are retained for compatibility. 772 * Please switch to the new header field below. 773 */ 774 struct rte_ether_addr dst; /**< Destination MAC. */ 775 struct rte_ether_addr src; /**< Source MAC. */ 776 rte_be16_t type; /**< EtherType or TPID. */ 777 }; 778 struct rte_ether_hdr hdr; 779 }; 780 uint32_t has_vlan:1; /**< Packet header contains at least one VLAN. */ 781 uint32_t reserved:31; /**< Reserved, must be zero. */ 782 }; 783 784 /** Default mask for RTE_FLOW_ITEM_TYPE_ETH. */ 785 #ifndef __cplusplus 786 static const struct rte_flow_item_eth rte_flow_item_eth_mask = { 787 .hdr.dst_addr.addr_bytes = "\xff\xff\xff\xff\xff\xff", 788 .hdr.src_addr.addr_bytes = "\xff\xff\xff\xff\xff\xff", 789 .hdr.ether_type = RTE_BE16(0x0000), 790 }; 791 #endif 792 793 /** 794 * RTE_FLOW_ITEM_TYPE_VLAN 795 * 796 * Matches an 802.1Q/ad VLAN tag. 797 * 798 * The corresponding standard outer EtherType (TPID) values are 799 * RTE_ETHER_TYPE_VLAN or RTE_ETHER_TYPE_QINQ. It can be overridden by 800 * the preceding pattern item. 801 * If a @p VLAN item is present in the pattern, then only tagged packets will 802 * match the pattern. 803 * The field @p has_more_vlan can be used to match any type of tagged packets, 804 * instead of using the @p eth_proto field of @p hdr. 805 * If the @p eth_proto of @p hdr and @p has_more_vlan fields are not specified, 806 * then any tagged packets will match the pattern. 807 */ 808 RTE_STD_C11 809 struct rte_flow_item_vlan { 810 union { 811 struct { 812 /* 813 * These fields are retained for compatibility. 814 * Please switch to the new header field below. 815 */ 816 rte_be16_t tci; /**< Tag control information. */ 817 rte_be16_t inner_type; /**< Inner EtherType or TPID. */ 818 }; 819 struct rte_vlan_hdr hdr; 820 }; 821 /** Packet header contains at least one more VLAN, after this VLAN. */ 822 uint32_t has_more_vlan:1; 823 uint32_t reserved:31; /**< Reserved, must be zero. */ 824 }; 825 826 /** Default mask for RTE_FLOW_ITEM_TYPE_VLAN. */ 827 #ifndef __cplusplus 828 static const struct rte_flow_item_vlan rte_flow_item_vlan_mask = { 829 .hdr.vlan_tci = RTE_BE16(0x0fff), 830 .hdr.eth_proto = RTE_BE16(0x0000), 831 }; 832 #endif 833 834 /** 835 * RTE_FLOW_ITEM_TYPE_IPV4 836 * 837 * Matches an IPv4 header. 838 * 839 * Note: IPv4 options are handled by dedicated pattern items. 840 */ 841 struct rte_flow_item_ipv4 { 842 struct rte_ipv4_hdr hdr; /**< IPv4 header definition. */ 843 }; 844 845 /** Default mask for RTE_FLOW_ITEM_TYPE_IPV4. */ 846 #ifndef __cplusplus 847 static const struct rte_flow_item_ipv4 rte_flow_item_ipv4_mask = { 848 .hdr = { 849 .src_addr = RTE_BE32(0xffffffff), 850 .dst_addr = RTE_BE32(0xffffffff), 851 }, 852 }; 853 #endif 854 855 /** 856 * RTE_FLOW_ITEM_TYPE_IPV6. 857 * 858 * Matches an IPv6 header. 859 * 860 * Dedicated flags indicate if header contains specific extension headers. 861 */ 862 struct rte_flow_item_ipv6 { 863 struct rte_ipv6_hdr hdr; /**< IPv6 header definition. */ 864 /** Header contains Hop-by-Hop Options extension header. */ 865 uint32_t has_hop_ext:1; 866 /** Header contains Routing extension header. */ 867 uint32_t has_route_ext:1; 868 /** Header contains Fragment extension header. */ 869 uint32_t has_frag_ext:1; 870 /** Header contains Authentication extension header. */ 871 uint32_t has_auth_ext:1; 872 /** Header contains Encapsulation Security Payload extension header. */ 873 uint32_t has_esp_ext:1; 874 /** Header contains Destination Options extension header. */ 875 uint32_t has_dest_ext:1; 876 /** Header contains Mobility extension header. */ 877 uint32_t has_mobil_ext:1; 878 /** Header contains Host Identity Protocol extension header. */ 879 uint32_t has_hip_ext:1; 880 /** Header contains Shim6 Protocol extension header. */ 881 uint32_t has_shim6_ext:1; 882 /** Reserved for future extension headers, must be zero. */ 883 uint32_t reserved:23; 884 }; 885 886 /** Default mask for RTE_FLOW_ITEM_TYPE_IPV6. */ 887 #ifndef __cplusplus 888 static const struct rte_flow_item_ipv6 rte_flow_item_ipv6_mask = { 889 .hdr = { 890 .src_addr = 891 "\xff\xff\xff\xff\xff\xff\xff\xff" 892 "\xff\xff\xff\xff\xff\xff\xff\xff", 893 .dst_addr = 894 "\xff\xff\xff\xff\xff\xff\xff\xff" 895 "\xff\xff\xff\xff\xff\xff\xff\xff", 896 }, 897 }; 898 #endif 899 900 /** 901 * RTE_FLOW_ITEM_TYPE_ICMP. 902 * 903 * Matches an ICMP header. 904 */ 905 struct rte_flow_item_icmp { 906 struct rte_icmp_hdr hdr; /**< ICMP header definition. */ 907 }; 908 909 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP. */ 910 #ifndef __cplusplus 911 static const struct rte_flow_item_icmp rte_flow_item_icmp_mask = { 912 .hdr = { 913 .icmp_type = 0xff, 914 .icmp_code = 0xff, 915 }, 916 }; 917 #endif 918 919 /** 920 * RTE_FLOW_ITEM_TYPE_UDP. 921 * 922 * Matches a UDP header. 923 */ 924 struct rte_flow_item_udp { 925 struct rte_udp_hdr hdr; /**< UDP header definition. */ 926 }; 927 928 /** Default mask for RTE_FLOW_ITEM_TYPE_UDP. */ 929 #ifndef __cplusplus 930 static const struct rte_flow_item_udp rte_flow_item_udp_mask = { 931 .hdr = { 932 .src_port = RTE_BE16(0xffff), 933 .dst_port = RTE_BE16(0xffff), 934 }, 935 }; 936 #endif 937 938 /** 939 * RTE_FLOW_ITEM_TYPE_TCP. 940 * 941 * Matches a TCP header. 942 */ 943 struct rte_flow_item_tcp { 944 struct rte_tcp_hdr hdr; /**< TCP header definition. */ 945 }; 946 947 /** Default mask for RTE_FLOW_ITEM_TYPE_TCP. */ 948 #ifndef __cplusplus 949 static const struct rte_flow_item_tcp rte_flow_item_tcp_mask = { 950 .hdr = { 951 .src_port = RTE_BE16(0xffff), 952 .dst_port = RTE_BE16(0xffff), 953 }, 954 }; 955 #endif 956 957 /** 958 * RTE_FLOW_ITEM_TYPE_SCTP. 959 * 960 * Matches a SCTP header. 961 */ 962 struct rte_flow_item_sctp { 963 struct rte_sctp_hdr hdr; /**< SCTP header definition. */ 964 }; 965 966 /** Default mask for RTE_FLOW_ITEM_TYPE_SCTP. */ 967 #ifndef __cplusplus 968 static const struct rte_flow_item_sctp rte_flow_item_sctp_mask = { 969 .hdr = { 970 .src_port = RTE_BE16(0xffff), 971 .dst_port = RTE_BE16(0xffff), 972 }, 973 }; 974 #endif 975 976 /** 977 * RTE_FLOW_ITEM_TYPE_VXLAN. 978 * 979 * Matches a VXLAN header (RFC 7348). 980 */ 981 RTE_STD_C11 982 struct rte_flow_item_vxlan { 983 union { 984 struct { 985 /* 986 * These fields are retained for compatibility. 987 * Please switch to the new header field below. 988 */ 989 uint8_t flags; /**< Normally 0x08 (I flag). */ 990 uint8_t rsvd0[3]; /**< Reserved, normally 0x000000. */ 991 uint8_t vni[3]; /**< VXLAN identifier. */ 992 uint8_t rsvd1; /**< Reserved, normally 0x00. */ 993 }; 994 struct rte_vxlan_hdr hdr; 995 }; 996 }; 997 998 /** Default mask for RTE_FLOW_ITEM_TYPE_VXLAN. */ 999 #ifndef __cplusplus 1000 static const struct rte_flow_item_vxlan rte_flow_item_vxlan_mask = { 1001 .hdr.vx_vni = RTE_BE32(0xffffff00), /* (0xffffff << 8) */ 1002 }; 1003 #endif 1004 1005 /** 1006 * RTE_FLOW_ITEM_TYPE_E_TAG. 1007 * 1008 * Matches a E-tag header. 1009 * 1010 * The corresponding standard outer EtherType (TPID) value is 1011 * RTE_ETHER_TYPE_ETAG. It can be overridden by the preceding pattern item. 1012 */ 1013 struct rte_flow_item_e_tag { 1014 /** 1015 * E-Tag control information (E-TCI). 1016 * E-PCP (3b), E-DEI (1b), ingress E-CID base (12b). 1017 */ 1018 rte_be16_t epcp_edei_in_ecid_b; 1019 /** Reserved (2b), GRP (2b), E-CID base (12b). */ 1020 rte_be16_t rsvd_grp_ecid_b; 1021 uint8_t in_ecid_e; /**< Ingress E-CID ext. */ 1022 uint8_t ecid_e; /**< E-CID ext. */ 1023 rte_be16_t inner_type; /**< Inner EtherType or TPID. */ 1024 }; 1025 1026 /** Default mask for RTE_FLOW_ITEM_TYPE_E_TAG. */ 1027 #ifndef __cplusplus 1028 static const struct rte_flow_item_e_tag rte_flow_item_e_tag_mask = { 1029 .rsvd_grp_ecid_b = RTE_BE16(0x3fff), 1030 }; 1031 #endif 1032 1033 /** 1034 * RTE_FLOW_ITEM_TYPE_NVGRE. 1035 * 1036 * Matches a NVGRE header. 1037 */ 1038 struct rte_flow_item_nvgre { 1039 /** 1040 * Checksum (1b), undefined (1b), key bit (1b), sequence number (1b), 1041 * reserved 0 (9b), version (3b). 1042 * 1043 * c_k_s_rsvd0_ver must have value 0x2000 according to RFC 7637. 1044 */ 1045 rte_be16_t c_k_s_rsvd0_ver; 1046 rte_be16_t protocol; /**< Protocol type (0x6558). */ 1047 uint8_t tni[3]; /**< Virtual subnet ID. */ 1048 uint8_t flow_id; /**< Flow ID. */ 1049 }; 1050 1051 /** Default mask for RTE_FLOW_ITEM_TYPE_NVGRE. */ 1052 #ifndef __cplusplus 1053 static const struct rte_flow_item_nvgre rte_flow_item_nvgre_mask = { 1054 .tni = "\xff\xff\xff", 1055 }; 1056 #endif 1057 1058 /** 1059 * RTE_FLOW_ITEM_TYPE_MPLS. 1060 * 1061 * Matches a MPLS header. 1062 */ 1063 struct rte_flow_item_mpls { 1064 /** 1065 * Label (20b), TC (3b), Bottom of Stack (1b). 1066 */ 1067 uint8_t label_tc_s[3]; 1068 uint8_t ttl; /** Time-to-Live. */ 1069 }; 1070 1071 /** Default mask for RTE_FLOW_ITEM_TYPE_MPLS. */ 1072 #ifndef __cplusplus 1073 static const struct rte_flow_item_mpls rte_flow_item_mpls_mask = { 1074 .label_tc_s = "\xff\xff\xf0", 1075 }; 1076 #endif 1077 1078 /** 1079 * RTE_FLOW_ITEM_TYPE_GRE. 1080 * 1081 * Matches a GRE header. 1082 */ 1083 struct rte_flow_item_gre { 1084 /** 1085 * Checksum (1b), reserved 0 (12b), version (3b). 1086 * Refer to RFC 2784. 1087 */ 1088 rte_be16_t c_rsvd0_ver; 1089 rte_be16_t protocol; /**< Protocol type. */ 1090 }; 1091 1092 /** Default mask for RTE_FLOW_ITEM_TYPE_GRE. */ 1093 #ifndef __cplusplus 1094 static const struct rte_flow_item_gre rte_flow_item_gre_mask = { 1095 .protocol = RTE_BE16(0xffff), 1096 }; 1097 #endif 1098 1099 /** 1100 * RTE_FLOW_ITEM_TYPE_GRE_OPTION. 1101 * 1102 * Matches GRE optional fields in header. 1103 */ 1104 struct rte_flow_item_gre_opt { 1105 struct rte_gre_hdr_opt_checksum_rsvd checksum_rsvd; 1106 struct rte_gre_hdr_opt_key key; 1107 struct rte_gre_hdr_opt_sequence sequence; 1108 }; 1109 1110 /** 1111 * RTE_FLOW_ITEM_TYPE_MACSEC. 1112 * 1113 * Matches MACsec header. 1114 */ 1115 struct rte_flow_item_macsec { 1116 struct rte_macsec_hdr macsec_hdr; 1117 }; 1118 1119 /** 1120 * RTE_FLOW_ITEM_TYPE_FUZZY 1121 * 1122 * Fuzzy pattern match, expect faster than default. 1123 * 1124 * This is for device that support fuzzy match option. 1125 * Usually a fuzzy match is fast but the cost is accuracy. 1126 * i.e. Signature Match only match pattern's hash value, but it is 1127 * possible two different patterns have the same hash value. 1128 * 1129 * Matching accuracy level can be configure by threshold. 1130 * Driver can divide the range of threshold and map to different 1131 * accuracy levels that device support. 1132 * 1133 * Threshold 0 means perfect match (no fuzziness), while threshold 1134 * 0xffffffff means fuzziest match. 1135 */ 1136 struct rte_flow_item_fuzzy { 1137 uint32_t thresh; /**< Accuracy threshold. */ 1138 }; 1139 1140 /** Default mask for RTE_FLOW_ITEM_TYPE_FUZZY. */ 1141 #ifndef __cplusplus 1142 static const struct rte_flow_item_fuzzy rte_flow_item_fuzzy_mask = { 1143 .thresh = 0xffffffff, 1144 }; 1145 #endif 1146 1147 /** 1148 * RTE_FLOW_ITEM_TYPE_GTP. 1149 * 1150 * Matches a GTPv1 header. 1151 */ 1152 struct rte_flow_item_gtp { 1153 /** 1154 * Version (3b), protocol type (1b), reserved (1b), 1155 * Extension header flag (1b), 1156 * Sequence number flag (1b), 1157 * N-PDU number flag (1b). 1158 */ 1159 uint8_t v_pt_rsv_flags; 1160 uint8_t msg_type; /**< Message type. */ 1161 rte_be16_t msg_len; /**< Message length. */ 1162 rte_be32_t teid; /**< Tunnel endpoint identifier. */ 1163 }; 1164 1165 /** Default mask for RTE_FLOW_ITEM_TYPE_GTP. */ 1166 #ifndef __cplusplus 1167 static const struct rte_flow_item_gtp rte_flow_item_gtp_mask = { 1168 .teid = RTE_BE32(0xffffffff), 1169 }; 1170 #endif 1171 1172 /** 1173 * RTE_FLOW_ITEM_TYPE_ESP 1174 * 1175 * Matches an ESP header. 1176 */ 1177 struct rte_flow_item_esp { 1178 struct rte_esp_hdr hdr; /**< ESP header definition. */ 1179 }; 1180 1181 /** Default mask for RTE_FLOW_ITEM_TYPE_ESP. */ 1182 #ifndef __cplusplus 1183 static const struct rte_flow_item_esp rte_flow_item_esp_mask = { 1184 .hdr = { 1185 .spi = RTE_BE32(0xffffffff), 1186 }, 1187 }; 1188 #endif 1189 1190 /** 1191 * RTE_FLOW_ITEM_TYPE_GENEVE. 1192 * 1193 * Matches a GENEVE header. 1194 */ 1195 struct rte_flow_item_geneve { 1196 /** 1197 * Version (2b), length of the options fields (6b), OAM packet (1b), 1198 * critical options present (1b), reserved 0 (6b). 1199 */ 1200 rte_be16_t ver_opt_len_o_c_rsvd0; 1201 rte_be16_t protocol; /**< Protocol type. */ 1202 uint8_t vni[3]; /**< Virtual Network Identifier. */ 1203 uint8_t rsvd1; /**< Reserved, normally 0x00. */ 1204 }; 1205 1206 /** Default mask for RTE_FLOW_ITEM_TYPE_GENEVE. */ 1207 #ifndef __cplusplus 1208 static const struct rte_flow_item_geneve rte_flow_item_geneve_mask = { 1209 .vni = "\xff\xff\xff", 1210 }; 1211 #endif 1212 1213 /** 1214 * RTE_FLOW_ITEM_TYPE_VXLAN_GPE (draft-ietf-nvo3-vxlan-gpe-05). 1215 * 1216 * Matches a VXLAN-GPE header. 1217 */ 1218 struct rte_flow_item_vxlan_gpe { 1219 uint8_t flags; /**< Normally 0x0c (I and P flags). */ 1220 uint8_t rsvd0[2]; /**< Reserved, normally 0x0000. */ 1221 uint8_t protocol; /**< Protocol type. */ 1222 uint8_t vni[3]; /**< VXLAN identifier. */ 1223 uint8_t rsvd1; /**< Reserved, normally 0x00. */ 1224 }; 1225 1226 /** Default mask for RTE_FLOW_ITEM_TYPE_VXLAN_GPE. */ 1227 #ifndef __cplusplus 1228 static const struct rte_flow_item_vxlan_gpe rte_flow_item_vxlan_gpe_mask = { 1229 .vni = "\xff\xff\xff", 1230 }; 1231 #endif 1232 1233 /** 1234 * RTE_FLOW_ITEM_TYPE_ARP_ETH_IPV4 1235 * 1236 * Matches an ARP header for Ethernet/IPv4. 1237 */ 1238 struct rte_flow_item_arp_eth_ipv4 { 1239 rte_be16_t hrd; /**< Hardware type, normally 1. */ 1240 rte_be16_t pro; /**< Protocol type, normally 0x0800. */ 1241 uint8_t hln; /**< Hardware address length, normally 6. */ 1242 uint8_t pln; /**< Protocol address length, normally 4. */ 1243 rte_be16_t op; /**< Opcode (1 for request, 2 for reply). */ 1244 struct rte_ether_addr sha; /**< Sender hardware address. */ 1245 rte_be32_t spa; /**< Sender IPv4 address. */ 1246 struct rte_ether_addr tha; /**< Target hardware address. */ 1247 rte_be32_t tpa; /**< Target IPv4 address. */ 1248 }; 1249 1250 /** Default mask for RTE_FLOW_ITEM_TYPE_ARP_ETH_IPV4. */ 1251 #ifndef __cplusplus 1252 static const struct rte_flow_item_arp_eth_ipv4 1253 rte_flow_item_arp_eth_ipv4_mask = { 1254 .sha.addr_bytes = "\xff\xff\xff\xff\xff\xff", 1255 .spa = RTE_BE32(0xffffffff), 1256 .tha.addr_bytes = "\xff\xff\xff\xff\xff\xff", 1257 .tpa = RTE_BE32(0xffffffff), 1258 }; 1259 #endif 1260 1261 /** 1262 * RTE_FLOW_ITEM_TYPE_IPV6_EXT 1263 * 1264 * Matches the presence of any IPv6 extension header. 1265 * 1266 * Normally preceded by any of: 1267 * 1268 * - RTE_FLOW_ITEM_TYPE_IPV6 1269 * - RTE_FLOW_ITEM_TYPE_IPV6_EXT 1270 */ 1271 struct rte_flow_item_ipv6_ext { 1272 uint8_t next_hdr; /**< Next header. */ 1273 }; 1274 1275 /** Default mask for RTE_FLOW_ITEM_TYPE_IPV6_EXT. */ 1276 #ifndef __cplusplus 1277 static const 1278 struct rte_flow_item_ipv6_ext rte_flow_item_ipv6_ext_mask = { 1279 .next_hdr = 0xff, 1280 }; 1281 #endif 1282 1283 /** 1284 * RTE_FLOW_ITEM_TYPE_IPV6_FRAG_EXT 1285 * 1286 * Matches the presence of IPv6 fragment extension header. 1287 * 1288 * Preceded by any of: 1289 * 1290 * - RTE_FLOW_ITEM_TYPE_IPV6 1291 * - RTE_FLOW_ITEM_TYPE_IPV6_EXT 1292 */ 1293 struct rte_flow_item_ipv6_frag_ext { 1294 struct rte_ipv6_fragment_ext hdr; 1295 }; 1296 1297 /** 1298 * RTE_FLOW_ITEM_TYPE_ICMP6 1299 * 1300 * Matches any ICMPv6 header. 1301 */ 1302 struct rte_flow_item_icmp6 { 1303 uint8_t type; /**< ICMPv6 type. */ 1304 uint8_t code; /**< ICMPv6 code. */ 1305 uint16_t checksum; /**< ICMPv6 checksum. */ 1306 }; 1307 1308 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6. */ 1309 #ifndef __cplusplus 1310 static const struct rte_flow_item_icmp6 rte_flow_item_icmp6_mask = { 1311 .type = 0xff, 1312 .code = 0xff, 1313 }; 1314 #endif 1315 1316 /** 1317 * RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS 1318 * 1319 * Matches an ICMPv6 neighbor discovery solicitation. 1320 */ 1321 struct rte_flow_item_icmp6_nd_ns { 1322 uint8_t type; /**< ICMPv6 type, normally 135. */ 1323 uint8_t code; /**< ICMPv6 code, normally 0. */ 1324 rte_be16_t checksum; /**< ICMPv6 checksum. */ 1325 rte_be32_t reserved; /**< Reserved, normally 0. */ 1326 uint8_t target_addr[16]; /**< Target address. */ 1327 }; 1328 1329 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS. */ 1330 #ifndef __cplusplus 1331 static const 1332 struct rte_flow_item_icmp6_nd_ns rte_flow_item_icmp6_nd_ns_mask = { 1333 .target_addr = 1334 "\xff\xff\xff\xff\xff\xff\xff\xff" 1335 "\xff\xff\xff\xff\xff\xff\xff\xff", 1336 }; 1337 #endif 1338 1339 /** 1340 * RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA 1341 * 1342 * Matches an ICMPv6 neighbor discovery advertisement. 1343 */ 1344 struct rte_flow_item_icmp6_nd_na { 1345 uint8_t type; /**< ICMPv6 type, normally 136. */ 1346 uint8_t code; /**< ICMPv6 code, normally 0. */ 1347 rte_be16_t checksum; /**< ICMPv6 checksum. */ 1348 /** 1349 * Route flag (1b), solicited flag (1b), override flag (1b), 1350 * reserved (29b). 1351 */ 1352 rte_be32_t rso_reserved; 1353 uint8_t target_addr[16]; /**< Target address. */ 1354 }; 1355 1356 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA. */ 1357 #ifndef __cplusplus 1358 static const 1359 struct rte_flow_item_icmp6_nd_na rte_flow_item_icmp6_nd_na_mask = { 1360 .target_addr = 1361 "\xff\xff\xff\xff\xff\xff\xff\xff" 1362 "\xff\xff\xff\xff\xff\xff\xff\xff", 1363 }; 1364 #endif 1365 1366 /** 1367 * RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT 1368 * 1369 * Matches the presence of any ICMPv6 neighbor discovery option. 1370 * 1371 * Normally preceded by any of: 1372 * 1373 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA 1374 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS 1375 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT 1376 */ 1377 struct rte_flow_item_icmp6_nd_opt { 1378 uint8_t type; /**< ND option type. */ 1379 uint8_t length; /**< ND option length. */ 1380 }; 1381 1382 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT. */ 1383 #ifndef __cplusplus 1384 static const struct rte_flow_item_icmp6_nd_opt 1385 rte_flow_item_icmp6_nd_opt_mask = { 1386 .type = 0xff, 1387 }; 1388 #endif 1389 1390 /** 1391 * RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_SLA_ETH 1392 * 1393 * Matches an ICMPv6 neighbor discovery source Ethernet link-layer address 1394 * option. 1395 * 1396 * Normally preceded by any of: 1397 * 1398 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA 1399 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT 1400 */ 1401 struct rte_flow_item_icmp6_nd_opt_sla_eth { 1402 uint8_t type; /**< ND option type, normally 1. */ 1403 uint8_t length; /**< ND option length, normally 1. */ 1404 struct rte_ether_addr sla; /**< Source Ethernet LLA. */ 1405 }; 1406 1407 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_SLA_ETH. */ 1408 #ifndef __cplusplus 1409 static const struct rte_flow_item_icmp6_nd_opt_sla_eth 1410 rte_flow_item_icmp6_nd_opt_sla_eth_mask = { 1411 .sla.addr_bytes = "\xff\xff\xff\xff\xff\xff", 1412 }; 1413 #endif 1414 1415 /** 1416 * RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_TLA_ETH 1417 * 1418 * Matches an ICMPv6 neighbor discovery target Ethernet link-layer address 1419 * option. 1420 * 1421 * Normally preceded by any of: 1422 * 1423 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS 1424 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT 1425 */ 1426 struct rte_flow_item_icmp6_nd_opt_tla_eth { 1427 uint8_t type; /**< ND option type, normally 2. */ 1428 uint8_t length; /**< ND option length, normally 1. */ 1429 struct rte_ether_addr tla; /**< Target Ethernet LLA. */ 1430 }; 1431 1432 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_TLA_ETH. */ 1433 #ifndef __cplusplus 1434 static const struct rte_flow_item_icmp6_nd_opt_tla_eth 1435 rte_flow_item_icmp6_nd_opt_tla_eth_mask = { 1436 .tla.addr_bytes = "\xff\xff\xff\xff\xff\xff", 1437 }; 1438 #endif 1439 1440 /** 1441 * RTE_FLOW_ITEM_TYPE_META 1442 * 1443 * Matches a specified metadata value. On egress, metadata can be set 1444 * either by mbuf dynamic metadata field with RTE_MBUF_DYNFLAG_TX_METADATA flag 1445 * or RTE_FLOW_ACTION_TYPE_SET_META. On ingress, RTE_FLOW_ACTION_TYPE_SET_META 1446 * sets metadata for a packet and the metadata will be reported via mbuf 1447 * metadata dynamic field with RTE_MBUF_DYNFLAG_RX_METADATA flag. The dynamic 1448 * mbuf field must be registered in advance by 1449 * rte_flow_dynf_metadata_register(). 1450 */ 1451 struct rte_flow_item_meta { 1452 uint32_t data; 1453 }; 1454 1455 /** Default mask for RTE_FLOW_ITEM_TYPE_META. */ 1456 #ifndef __cplusplus 1457 static const struct rte_flow_item_meta rte_flow_item_meta_mask = { 1458 .data = UINT32_MAX, 1459 }; 1460 #endif 1461 1462 /** 1463 * RTE_FLOW_ITEM_TYPE_GTP_PSC. 1464 * 1465 * Matches a GTP PDU extension header with type 0x85. 1466 */ 1467 struct rte_flow_item_gtp_psc { 1468 struct rte_gtp_psc_generic_hdr hdr; /**< gtp psc generic hdr. */ 1469 }; 1470 1471 /** Default mask for RTE_FLOW_ITEM_TYPE_GTP_PSC. */ 1472 #ifndef __cplusplus 1473 static const struct rte_flow_item_gtp_psc 1474 rte_flow_item_gtp_psc_mask = { 1475 .hdr.qfi = 0x3f, 1476 }; 1477 #endif 1478 1479 /** 1480 * RTE_FLOW_ITEM_TYPE_PPPOE. 1481 * 1482 * Matches a PPPoE header. 1483 */ 1484 struct rte_flow_item_pppoe { 1485 /** 1486 * Version (4b), type (4b). 1487 */ 1488 uint8_t version_type; 1489 uint8_t code; /**< Message type. */ 1490 rte_be16_t session_id; /**< Session identifier. */ 1491 rte_be16_t length; /**< Payload length. */ 1492 }; 1493 1494 /** 1495 * RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID. 1496 * 1497 * Matches a PPPoE optional proto_id field. 1498 * 1499 * It only applies to PPPoE session packets. 1500 * 1501 * Normally preceded by any of: 1502 * 1503 * - RTE_FLOW_ITEM_TYPE_PPPOE 1504 * - RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID 1505 */ 1506 struct rte_flow_item_pppoe_proto_id { 1507 rte_be16_t proto_id; /**< PPP protocol identifier. */ 1508 }; 1509 1510 /** Default mask for RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID. */ 1511 #ifndef __cplusplus 1512 static const struct rte_flow_item_pppoe_proto_id 1513 rte_flow_item_pppoe_proto_id_mask = { 1514 .proto_id = RTE_BE16(0xffff), 1515 }; 1516 #endif 1517 1518 /** 1519 * @warning 1520 * @b EXPERIMENTAL: this structure may change without prior notice 1521 * 1522 * RTE_FLOW_ITEM_TYPE_TAG 1523 * 1524 * Matches a specified tag value at the specified index. 1525 */ 1526 struct rte_flow_item_tag { 1527 uint32_t data; 1528 uint8_t index; 1529 }; 1530 1531 /** Default mask for RTE_FLOW_ITEM_TYPE_TAG. */ 1532 #ifndef __cplusplus 1533 static const struct rte_flow_item_tag rte_flow_item_tag_mask = { 1534 .data = 0xffffffff, 1535 .index = 0xff, 1536 }; 1537 #endif 1538 1539 /** 1540 * RTE_FLOW_ITEM_TYPE_L2TPV3OIP. 1541 * 1542 * Matches a L2TPv3 over IP header. 1543 */ 1544 struct rte_flow_item_l2tpv3oip { 1545 rte_be32_t session_id; /**< Session ID. */ 1546 }; 1547 1548 /** Default mask for RTE_FLOW_ITEM_TYPE_L2TPV3OIP. */ 1549 #ifndef __cplusplus 1550 static const struct rte_flow_item_l2tpv3oip rte_flow_item_l2tpv3oip_mask = { 1551 .session_id = RTE_BE32(UINT32_MAX), 1552 }; 1553 #endif 1554 1555 1556 /** 1557 * @warning 1558 * @b EXPERIMENTAL: this structure may change without prior notice 1559 * 1560 * RTE_FLOW_ITEM_TYPE_MARK 1561 * 1562 * Matches an arbitrary integer value which was set using the ``MARK`` action 1563 * in a previously matched rule. 1564 * 1565 * This item can only be specified once as a match criteria as the ``MARK`` 1566 * action can only be specified once in a flow action. 1567 * 1568 * This value is arbitrary and application-defined. Maximum allowed value 1569 * depends on the underlying implementation. 1570 * 1571 * Depending on the underlying implementation the MARK item may be supported on 1572 * the physical device, with virtual groups in the PMD or not at all. 1573 */ 1574 struct rte_flow_item_mark { 1575 uint32_t id; /**< Integer value to match against. */ 1576 }; 1577 1578 /** Default mask for RTE_FLOW_ITEM_TYPE_MARK. */ 1579 #ifndef __cplusplus 1580 static const struct rte_flow_item_mark rte_flow_item_mark_mask = { 1581 .id = 0xffffffff, 1582 }; 1583 #endif 1584 1585 /** 1586 * @warning 1587 * @b EXPERIMENTAL: this structure may change without prior notice 1588 * 1589 * RTE_FLOW_ITEM_TYPE_NSH 1590 * 1591 * Match network service header (NSH), RFC 8300 1592 * 1593 */ 1594 struct rte_flow_item_nsh { 1595 uint32_t version:2; 1596 uint32_t oam_pkt:1; 1597 uint32_t reserved:1; 1598 uint32_t ttl:6; 1599 uint32_t length:6; 1600 uint32_t reserved1:4; 1601 uint32_t mdtype:4; 1602 uint32_t next_proto:8; 1603 uint32_t spi:24; 1604 uint32_t sindex:8; 1605 }; 1606 1607 /** Default mask for RTE_FLOW_ITEM_TYPE_NSH. */ 1608 #ifndef __cplusplus 1609 static const struct rte_flow_item_nsh rte_flow_item_nsh_mask = { 1610 .mdtype = 0xf, 1611 .next_proto = 0xff, 1612 .spi = 0xffffff, 1613 .sindex = 0xff, 1614 }; 1615 #endif 1616 1617 /** 1618 * @warning 1619 * @b EXPERIMENTAL: this structure may change without prior notice 1620 * 1621 * RTE_FLOW_ITEM_TYPE_IGMP 1622 * 1623 * Match Internet Group Management Protocol (IGMP), RFC 2236 1624 * 1625 */ 1626 struct rte_flow_item_igmp { 1627 uint32_t type:8; 1628 uint32_t max_resp_time:8; 1629 uint32_t checksum:16; 1630 uint32_t group_addr; 1631 }; 1632 1633 /** Default mask for RTE_FLOW_ITEM_TYPE_IGMP. */ 1634 #ifndef __cplusplus 1635 static const struct rte_flow_item_igmp rte_flow_item_igmp_mask = { 1636 .group_addr = 0xffffffff, 1637 }; 1638 #endif 1639 1640 /** 1641 * @warning 1642 * @b EXPERIMENTAL: this structure may change without prior notice 1643 * 1644 * RTE_FLOW_ITEM_TYPE_AH 1645 * 1646 * Match IP Authentication Header (AH), RFC 4302 1647 * 1648 */ 1649 struct rte_flow_item_ah { 1650 uint32_t next_hdr:8; 1651 uint32_t payload_len:8; 1652 uint32_t reserved:16; 1653 uint32_t spi; 1654 uint32_t seq_num; 1655 }; 1656 1657 /** Default mask for RTE_FLOW_ITEM_TYPE_AH. */ 1658 #ifndef __cplusplus 1659 static const struct rte_flow_item_ah rte_flow_item_ah_mask = { 1660 .spi = 0xffffffff, 1661 }; 1662 #endif 1663 1664 /** 1665 * @warning 1666 * @b EXPERIMENTAL: this structure may change without prior notice 1667 * 1668 * RTE_FLOW_ITEM_TYPE_PFCP 1669 * 1670 * Match PFCP Header 1671 */ 1672 struct rte_flow_item_pfcp { 1673 uint8_t s_field; 1674 uint8_t msg_type; 1675 rte_be16_t msg_len; 1676 rte_be64_t seid; 1677 }; 1678 1679 /** Default mask for RTE_FLOW_ITEM_TYPE_PFCP. */ 1680 #ifndef __cplusplus 1681 static const struct rte_flow_item_pfcp rte_flow_item_pfcp_mask = { 1682 .s_field = 0x01, 1683 .seid = RTE_BE64(UINT64_C(0xffffffffffffffff)), 1684 }; 1685 #endif 1686 1687 /** 1688 * @warning 1689 * @b EXPERIMENTAL: this structure may change without prior notice 1690 * 1691 * RTE_FLOW_ITEM_TYPE_ECPRI 1692 * 1693 * Match eCPRI Header 1694 */ 1695 struct rte_flow_item_ecpri { 1696 struct rte_ecpri_combined_msg_hdr hdr; 1697 }; 1698 1699 /** Default mask for RTE_FLOW_ITEM_TYPE_ECPRI. */ 1700 #ifndef __cplusplus 1701 static const struct rte_flow_item_ecpri rte_flow_item_ecpri_mask = { 1702 .hdr = { 1703 .common = { 1704 .u32 = 0x0, 1705 }, 1706 }, 1707 }; 1708 #endif 1709 1710 /** 1711 * RTE_FLOW_ITEM_TYPE_GENEVE_OPT 1712 * 1713 * Matches a GENEVE Variable Length Option 1714 */ 1715 struct rte_flow_item_geneve_opt { 1716 rte_be16_t option_class; 1717 uint8_t option_type; 1718 uint8_t option_len; 1719 uint32_t *data; 1720 }; 1721 1722 /** Default mask for RTE_FLOW_ITEM_TYPE_GENEVE_OPT. */ 1723 #ifndef __cplusplus 1724 static const struct rte_flow_item_geneve_opt 1725 rte_flow_item_geneve_opt_mask = { 1726 .option_type = 0xff, 1727 }; 1728 #endif 1729 1730 /** 1731 * @warning 1732 * @b EXPERIMENTAL: this structure may change without prior notice 1733 * 1734 * RTE_FLOW_ITEM_TYPE_INTEGRITY 1735 * 1736 * Match on packet integrity check result. 1737 */ 1738 struct rte_flow_item_integrity { 1739 /** Tunnel encapsulation level the item should apply to. 1740 * @see rte_flow_action_rss 1741 */ 1742 uint32_t level; 1743 RTE_STD_C11 1744 union { 1745 __extension__ 1746 struct { 1747 /** The packet is valid after passing all HW checks. */ 1748 uint64_t packet_ok:1; 1749 /** L2 layer is valid after passing all HW checks. */ 1750 uint64_t l2_ok:1; 1751 /** L3 layer is valid after passing all HW checks. */ 1752 uint64_t l3_ok:1; 1753 /** L4 layer is valid after passing all HW checks. */ 1754 uint64_t l4_ok:1; 1755 /** L2 layer CRC is valid. */ 1756 uint64_t l2_crc_ok:1; 1757 /** IPv4 layer checksum is valid. */ 1758 uint64_t ipv4_csum_ok:1; 1759 /** L4 layer checksum is valid. */ 1760 uint64_t l4_csum_ok:1; 1761 /** L3 length is smaller than frame length. */ 1762 uint64_t l3_len_ok:1; 1763 uint64_t reserved:56; 1764 }; 1765 uint64_t value; 1766 }; 1767 }; 1768 1769 #ifndef __cplusplus 1770 static const struct rte_flow_item_integrity 1771 rte_flow_item_integrity_mask = { 1772 .level = 0, 1773 .value = 0, 1774 }; 1775 #endif 1776 1777 /** 1778 * The packet is valid after conntrack checking. 1779 */ 1780 #define RTE_FLOW_CONNTRACK_PKT_STATE_VALID RTE_BIT32(0) 1781 /** 1782 * The state of the connection is changed. 1783 */ 1784 #define RTE_FLOW_CONNTRACK_PKT_STATE_CHANGED RTE_BIT32(1) 1785 /** 1786 * Error is detected on this packet for this connection and 1787 * an invalid state is set. 1788 */ 1789 #define RTE_FLOW_CONNTRACK_PKT_STATE_INVALID RTE_BIT32(2) 1790 /** 1791 * The HW connection tracking module is disabled. 1792 * It can be due to application command or an invalid state. 1793 */ 1794 #define RTE_FLOW_CONNTRACK_PKT_STATE_DISABLED RTE_BIT32(3) 1795 /** 1796 * The packet contains some bad field(s) and cannot continue 1797 * with the conntrack module checking. 1798 */ 1799 #define RTE_FLOW_CONNTRACK_PKT_STATE_BAD RTE_BIT32(4) 1800 1801 /** 1802 * @warning 1803 * @b EXPERIMENTAL: this structure may change without prior notice 1804 * 1805 * RTE_FLOW_ITEM_TYPE_CONNTRACK 1806 * 1807 * Matches the state of a packet after it passed the connection tracking 1808 * examination. The state is a bitmap of one RTE_FLOW_CONNTRACK_PKT_STATE* 1809 * or a reasonable combination of these bits. 1810 */ 1811 struct rte_flow_item_conntrack { 1812 uint32_t flags; 1813 }; 1814 1815 /** Default mask for RTE_FLOW_ITEM_TYPE_CONNTRACK. */ 1816 #ifndef __cplusplus 1817 static const struct rte_flow_item_conntrack rte_flow_item_conntrack_mask = { 1818 .flags = 0xffffffff, 1819 }; 1820 #endif 1821 1822 /** 1823 * Provides an ethdev port ID for use with the following items: 1824 * RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR, 1825 * RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT. 1826 */ 1827 struct rte_flow_item_ethdev { 1828 uint16_t port_id; /**< ethdev port ID */ 1829 }; 1830 1831 /** Default mask for items based on struct rte_flow_item_ethdev */ 1832 #ifndef __cplusplus 1833 static const struct rte_flow_item_ethdev rte_flow_item_ethdev_mask = { 1834 .port_id = 0xffff, 1835 }; 1836 #endif 1837 1838 /** 1839 * @warning 1840 * @b EXPERIMENTAL: this structure may change without prior notice 1841 * 1842 * RTE_FLOW_ITEM_TYPE_L2TPV2 1843 * 1844 * Matches L2TPv2 Header 1845 */ 1846 struct rte_flow_item_l2tpv2 { 1847 struct rte_l2tpv2_combined_msg_hdr hdr; 1848 }; 1849 1850 /** Default mask for RTE_FLOW_ITEM_TYPE_L2TPV2. */ 1851 #ifndef __cplusplus 1852 static const struct rte_flow_item_l2tpv2 rte_flow_item_l2tpv2_mask = { 1853 /* 1854 * flags and version bit mask 1855 * 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 1856 * T L x x S x O P x x x x V V V V 1857 */ 1858 .hdr = { 1859 .common = { 1860 .flags_version = RTE_BE16(0xcb0f), 1861 }, 1862 }, 1863 }; 1864 #endif 1865 1866 /** 1867 * @warning 1868 * @b EXPERIMENTAL: this structure may change without prior notice 1869 * 1870 * RTE_FLOW_ITEM_TYPE_PPP 1871 * 1872 * Matches PPP Header 1873 */ 1874 struct rte_flow_item_ppp { 1875 struct rte_ppp_hdr hdr; 1876 }; 1877 1878 /** Default mask for RTE_FLOW_ITEM_TYPE_PPP. */ 1879 #ifndef __cplusplus 1880 static const struct rte_flow_item_ppp rte_flow_item_ppp_mask = { 1881 .hdr = { 1882 .addr = 0xff, 1883 .ctrl = 0xff, 1884 .proto_id = RTE_BE16(0xffff), 1885 } 1886 }; 1887 #endif 1888 1889 /** 1890 * Matching pattern item definition. 1891 * 1892 * A pattern is formed by stacking items starting from the lowest protocol 1893 * layer to match. This stacking restriction does not apply to meta items 1894 * which can be placed anywhere in the stack without affecting the meaning 1895 * of the resulting pattern. 1896 * 1897 * Patterns are terminated by END items. 1898 * 1899 * The spec field should be a valid pointer to a structure of the related 1900 * item type. It may remain unspecified (NULL) in many cases to request 1901 * broad (nonspecific) matching. In such cases, last and mask must also be 1902 * set to NULL. 1903 * 1904 * Optionally, last can point to a structure of the same type to define an 1905 * inclusive range. This is mostly supported by integer and address fields, 1906 * may cause errors otherwise. Fields that do not support ranges must be set 1907 * to 0 or to the same value as the corresponding fields in spec. 1908 * 1909 * Only the fields defined to nonzero values in the default masks (see 1910 * rte_flow_item_{name}_mask constants) are considered relevant by 1911 * default. This can be overridden by providing a mask structure of the 1912 * same type with applicable bits set to one. It can also be used to 1913 * partially filter out specific fields (e.g. as an alternate mean to match 1914 * ranges of IP addresses). 1915 * 1916 * Mask is a simple bit-mask applied before interpreting the contents of 1917 * spec and last, which may yield unexpected results if not used 1918 * carefully. For example, if for an IPv4 address field, spec provides 1919 * 10.1.2.3, last provides 10.3.4.5 and mask provides 255.255.0.0, the 1920 * effective range becomes 10.1.0.0 to 10.3.255.255. 1921 */ 1922 struct rte_flow_item { 1923 enum rte_flow_item_type type; /**< Item type. */ 1924 const void *spec; /**< Pointer to item specification structure. */ 1925 const void *last; /**< Defines an inclusive range (spec to last). */ 1926 const void *mask; /**< Bit-mask applied to spec and last. */ 1927 }; 1928 1929 /** 1930 * @warning 1931 * @b EXPERIMENTAL: this structure may change without prior notice 1932 * 1933 * RTE_FLOW_ITEM_TYPE_FLEX 1934 * 1935 * Matches a specified set of fields within the network protocol 1936 * header. Each field is presented as set of bits with specified width, and 1937 * bit offset from the header beginning. 1938 * 1939 * The pattern is concatenation of bit fields configured at item creation 1940 * by rte_flow_flex_item_create(). At configuration the fields are presented 1941 * by sample_data array. 1942 * 1943 * This type does not support ranges (struct rte_flow_item.last). 1944 */ 1945 struct rte_flow_item_flex { 1946 struct rte_flow_item_flex_handle *handle; /**< Opaque item handle. */ 1947 uint32_t length; /**< Pattern length in bytes. */ 1948 const uint8_t *pattern; /**< Combined bitfields pattern to match. */ 1949 }; 1950 /** 1951 * Field bit offset calculation mode. 1952 */ 1953 enum rte_flow_item_flex_field_mode { 1954 /** 1955 * Dummy field, used for byte boundary alignment in pattern. 1956 * Pattern mask and data are ignored in the match. All configuration 1957 * parameters besides field size are ignored. 1958 */ 1959 FIELD_MODE_DUMMY = 0, 1960 /** 1961 * Fixed offset field. The bit offset from header beginning 1962 * is permanent and defined by field_base parameter. 1963 */ 1964 FIELD_MODE_FIXED, 1965 /** 1966 * The field bit offset is extracted from other header field (indirect 1967 * offset field). The resulting field offset to match is calculated as: 1968 * 1969 * field_base + (*offset_base & offset_mask) << offset_shift 1970 */ 1971 FIELD_MODE_OFFSET, 1972 /** 1973 * The field bit offset is extracted from other header field (indirect 1974 * offset field), the latter is considered as bitmask containing some 1975 * number of one bits, the resulting field offset to match is 1976 * calculated as: 1977 * 1978 * field_base + bitcount(*offset_base & offset_mask) << offset_shift 1979 */ 1980 FIELD_MODE_BITMASK, 1981 }; 1982 1983 /** 1984 * Flex item field tunnel mode 1985 */ 1986 enum rte_flow_item_flex_tunnel_mode { 1987 /** 1988 * The protocol header can be present in the packet only once. 1989 * No multiple flex item flow inclusions (for inner/outer) are allowed. 1990 * No any relations with tunnel protocols are imposed. The drivers 1991 * can optimize hardware resource usage to handle match on single flex 1992 * item of specific type. 1993 */ 1994 FLEX_TUNNEL_MODE_SINGLE = 0, 1995 /** 1996 * Flex item presents outer header only. 1997 */ 1998 FLEX_TUNNEL_MODE_OUTER, 1999 /** 2000 * Flex item presents inner header only. 2001 */ 2002 FLEX_TUNNEL_MODE_INNER, 2003 /** 2004 * Flex item presents either inner or outer header. The driver 2005 * handles as many multiple inners as hardware supports. 2006 */ 2007 FLEX_TUNNEL_MODE_MULTI, 2008 /** 2009 * Flex item presents tunnel protocol header. 2010 */ 2011 FLEX_TUNNEL_MODE_TUNNEL, 2012 }; 2013 2014 /** 2015 * 2016 * @warning 2017 * @b EXPERIMENTAL: this structure may change without prior notice 2018 */ 2019 __extension__ 2020 struct rte_flow_item_flex_field { 2021 /** Defines how match field offset is calculated over the packet. */ 2022 enum rte_flow_item_flex_field_mode field_mode; 2023 uint32_t field_size; /**< Field size in bits. */ 2024 int32_t field_base; /**< Field offset in bits. */ 2025 uint32_t offset_base; /**< Indirect offset field offset in bits. */ 2026 uint32_t offset_mask; /**< Indirect offset field bit mask. */ 2027 int32_t offset_shift; /**< Indirect offset multiply factor. */ 2028 uint32_t field_id:16; /**< Device hint, for multiple items in flow. */ 2029 uint32_t reserved:16; /**< Reserved field. */ 2030 }; 2031 2032 /** 2033 * @warning 2034 * @b EXPERIMENTAL: this structure may change without prior notice 2035 */ 2036 struct rte_flow_item_flex_link { 2037 /** 2038 * Preceding/following header. The item type must be always provided. 2039 * For preceding one item must specify the header value/mask to match 2040 * for the link be taken and start the flex item header parsing. 2041 */ 2042 struct rte_flow_item item; 2043 /** 2044 * Next field value to match to continue with one of the configured 2045 * next protocols. 2046 */ 2047 uint32_t next; 2048 }; 2049 2050 /** 2051 * @warning 2052 * @b EXPERIMENTAL: this structure may change without prior notice 2053 */ 2054 struct rte_flow_item_flex_conf { 2055 /** 2056 * Specifies the flex item and tunnel relations and tells the PMD 2057 * whether flex item can be used for inner, outer or both headers, 2058 * or whether flex item presents the tunnel protocol itself. 2059 */ 2060 enum rte_flow_item_flex_tunnel_mode tunnel; 2061 /** 2062 * The next header offset, it presents the network header size covered 2063 * by the flex item and can be obtained with all supported offset 2064 * calculating methods (fixed, dedicated field, bitmask, etc). 2065 */ 2066 struct rte_flow_item_flex_field next_header; 2067 /** 2068 * Specifies the next protocol field to match with link next protocol 2069 * values and continue packet parsing with matching link. 2070 */ 2071 struct rte_flow_item_flex_field next_protocol; 2072 /** 2073 * The fields will be sampled and presented for explicit match 2074 * with pattern in the rte_flow_flex_item. There can be multiple 2075 * fields descriptors, the number should be specified by nb_samples. 2076 */ 2077 struct rte_flow_item_flex_field *sample_data; 2078 /** Number of field descriptors in the sample_data array. */ 2079 uint32_t nb_samples; 2080 /** 2081 * Input link defines the flex item relation with preceding 2082 * header. It specified the preceding item type and provides pattern 2083 * to match. The flex item will continue parsing and will provide the 2084 * data to flow match in case if there is the match with one of input 2085 * links. 2086 */ 2087 struct rte_flow_item_flex_link *input_link; 2088 /** Number of link descriptors in the input link array. */ 2089 uint32_t nb_inputs; 2090 /** 2091 * Output link defines the next protocol field value to match and 2092 * the following protocol header to continue packet parsing. Also 2093 * defines the tunnel-related behaviour. 2094 */ 2095 struct rte_flow_item_flex_link *output_link; 2096 /** Number of link descriptors in the output link array. */ 2097 uint32_t nb_outputs; 2098 }; 2099 2100 /** 2101 * Action types. 2102 * 2103 * Each possible action is represented by a type. 2104 * An action can have an associated configuration object. 2105 * Several actions combined in a list can be assigned 2106 * to a flow rule and are performed in order. 2107 * 2108 * They fall in three categories: 2109 * 2110 * - Actions that modify the fate of matching traffic, for instance by 2111 * dropping or assigning it a specific destination. 2112 * 2113 * - Actions that modify matching traffic contents or its properties. This 2114 * includes adding/removing encapsulation, encryption, compression and 2115 * marks. 2116 * 2117 * - Actions related to the flow rule itself, such as updating counters or 2118 * making it non-terminating. 2119 * 2120 * Flow rules being terminating by default, not specifying any action of the 2121 * fate kind results in undefined behavior. This applies to both ingress and 2122 * egress. 2123 * 2124 * PASSTHRU, when supported, makes a flow rule non-terminating. 2125 */ 2126 enum rte_flow_action_type { 2127 /** 2128 * End marker for action lists. Prevents further processing of 2129 * actions, thereby ending the list. 2130 * 2131 * No associated configuration structure. 2132 */ 2133 RTE_FLOW_ACTION_TYPE_END, 2134 2135 /** 2136 * Used as a placeholder for convenience. It is ignored and simply 2137 * discarded by PMDs. 2138 * 2139 * No associated configuration structure. 2140 */ 2141 RTE_FLOW_ACTION_TYPE_VOID, 2142 2143 /** 2144 * Leaves traffic up for additional processing by subsequent flow 2145 * rules; makes a flow rule non-terminating. 2146 * 2147 * No associated configuration structure. 2148 */ 2149 RTE_FLOW_ACTION_TYPE_PASSTHRU, 2150 2151 /** 2152 * RTE_FLOW_ACTION_TYPE_JUMP 2153 * 2154 * Redirects packets to a group on the current device. 2155 * 2156 * See struct rte_flow_action_jump. 2157 */ 2158 RTE_FLOW_ACTION_TYPE_JUMP, 2159 2160 /** 2161 * Attaches an integer value to packets and sets RTE_MBUF_F_RX_FDIR and 2162 * RTE_MBUF_F_RX_FDIR_ID mbuf flags. 2163 * 2164 * See struct rte_flow_action_mark. 2165 * 2166 * One should negotiate mark delivery from the NIC to the PMD. 2167 * @see rte_eth_rx_metadata_negotiate() 2168 * @see RTE_ETH_RX_METADATA_USER_MARK 2169 */ 2170 RTE_FLOW_ACTION_TYPE_MARK, 2171 2172 /** 2173 * Flags packets. Similar to MARK without a specific value; only 2174 * sets the RTE_MBUF_F_RX_FDIR mbuf flag. 2175 * 2176 * No associated configuration structure. 2177 * 2178 * One should negotiate flag delivery from the NIC to the PMD. 2179 * @see rte_eth_rx_metadata_negotiate() 2180 * @see RTE_ETH_RX_METADATA_USER_FLAG 2181 */ 2182 RTE_FLOW_ACTION_TYPE_FLAG, 2183 2184 /** 2185 * Assigns packets to a given queue index. 2186 * 2187 * See struct rte_flow_action_queue. 2188 */ 2189 RTE_FLOW_ACTION_TYPE_QUEUE, 2190 2191 /** 2192 * Drops packets. 2193 * 2194 * PASSTHRU overrides this action if both are specified. 2195 * 2196 * No associated configuration structure. 2197 */ 2198 RTE_FLOW_ACTION_TYPE_DROP, 2199 2200 /** 2201 * Enables counters for this flow rule. 2202 * 2203 * These counters can be retrieved and reset through rte_flow_query() or 2204 * rte_flow_action_handle_query() if the action provided via handle, 2205 * see struct rte_flow_query_count. 2206 * 2207 * See struct rte_flow_action_count. 2208 */ 2209 RTE_FLOW_ACTION_TYPE_COUNT, 2210 2211 /** 2212 * Similar to QUEUE, except RSS is additionally performed on packets 2213 * to spread them among several queues according to the provided 2214 * parameters. 2215 * 2216 * See struct rte_flow_action_rss. 2217 */ 2218 RTE_FLOW_ACTION_TYPE_RSS, 2219 2220 /** 2221 * @deprecated 2222 * @see RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR 2223 * @see RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT 2224 * 2225 * Directs matching traffic to the physical function (PF) of the 2226 * current device. 2227 * 2228 * No associated configuration structure. 2229 */ 2230 RTE_FLOW_ACTION_TYPE_PF, 2231 2232 /** 2233 * @deprecated 2234 * @see RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR 2235 * @see RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT 2236 * 2237 * Directs matching traffic to a given virtual function of the 2238 * current device. 2239 * 2240 * See struct rte_flow_action_vf. 2241 */ 2242 RTE_FLOW_ACTION_TYPE_VF, 2243 2244 /** 2245 * @deprecated 2246 * @see RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR 2247 * @see RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT 2248 * 2249 * Directs matching traffic to a given DPDK port ID. 2250 * 2251 * See struct rte_flow_action_port_id. 2252 */ 2253 RTE_FLOW_ACTION_TYPE_PORT_ID, 2254 2255 /** 2256 * Traffic metering and policing (MTR). 2257 * 2258 * See struct rte_flow_action_meter. 2259 * See file rte_mtr.h for MTR object configuration. 2260 */ 2261 RTE_FLOW_ACTION_TYPE_METER, 2262 2263 /** 2264 * Redirects packets to security engine of current device for security 2265 * processing as specified by security session. 2266 * 2267 * See struct rte_flow_action_security. 2268 */ 2269 RTE_FLOW_ACTION_TYPE_SECURITY, 2270 2271 /** 2272 * @deprecated 2273 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD 2274 * 2275 * Implements OFPAT_SET_MPLS_TTL ("MPLS TTL") as defined by the 2276 * OpenFlow Switch Specification. 2277 * 2278 * See struct rte_flow_action_of_set_mpls_ttl. 2279 */ 2280 RTE_FLOW_ACTION_TYPE_OF_SET_MPLS_TTL, 2281 2282 /** 2283 * @deprecated 2284 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD 2285 * 2286 * Implements OFPAT_DEC_MPLS_TTL ("decrement MPLS TTL") as defined 2287 * by the OpenFlow Switch Specification. 2288 * 2289 * No associated configuration structure. 2290 */ 2291 RTE_FLOW_ACTION_TYPE_OF_DEC_MPLS_TTL, 2292 2293 /** 2294 * @deprecated 2295 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD 2296 * 2297 * Implements OFPAT_SET_NW_TTL ("IP TTL") as defined by the OpenFlow 2298 * Switch Specification. 2299 * 2300 * See struct rte_flow_action_of_set_nw_ttl. 2301 */ 2302 RTE_FLOW_ACTION_TYPE_OF_SET_NW_TTL, 2303 2304 /** 2305 * @warning This is a legacy action. 2306 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD 2307 * 2308 * Implements OFPAT_DEC_NW_TTL ("decrement IP TTL") as defined by 2309 * the OpenFlow Switch Specification. 2310 * 2311 * No associated configuration structure. 2312 */ 2313 RTE_FLOW_ACTION_TYPE_OF_DEC_NW_TTL, 2314 2315 /** 2316 * @deprecated 2317 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD 2318 * 2319 * Implements OFPAT_COPY_TTL_OUT ("copy TTL "outwards" -- from 2320 * next-to-outermost to outermost") as defined by the OpenFlow 2321 * Switch Specification. 2322 * 2323 * No associated configuration structure. 2324 */ 2325 RTE_FLOW_ACTION_TYPE_OF_COPY_TTL_OUT, 2326 2327 /** 2328 * @deprecated 2329 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD 2330 * 2331 * Implements OFPAT_COPY_TTL_IN ("copy TTL "inwards" -- from 2332 * outermost to next-to-outermost") as defined by the OpenFlow 2333 * Switch Specification. 2334 * 2335 * No associated configuration structure. 2336 */ 2337 RTE_FLOW_ACTION_TYPE_OF_COPY_TTL_IN, 2338 2339 /** 2340 * Implements OFPAT_POP_VLAN ("pop the outer VLAN tag") as defined 2341 * by the OpenFlow Switch Specification. 2342 * 2343 * No associated configuration structure. 2344 */ 2345 RTE_FLOW_ACTION_TYPE_OF_POP_VLAN, 2346 2347 /** 2348 * Implements OFPAT_PUSH_VLAN ("push a new VLAN tag") as defined by 2349 * the OpenFlow Switch Specification. 2350 * 2351 * See struct rte_flow_action_of_push_vlan. 2352 */ 2353 RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN, 2354 2355 /** 2356 * Implements OFPAT_SET_VLAN_VID ("set the 802.1q VLAN ID") as 2357 * defined by the OpenFlow Switch Specification. 2358 * 2359 * See struct rte_flow_action_of_set_vlan_vid. 2360 */ 2361 RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID, 2362 2363 /** 2364 * Implements OFPAT_SET_LAN_PCP ("set the 802.1q priority") as 2365 * defined by the OpenFlow Switch Specification. 2366 * 2367 * See struct rte_flow_action_of_set_vlan_pcp. 2368 */ 2369 RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP, 2370 2371 /** 2372 * Implements OFPAT_POP_MPLS ("pop the outer MPLS tag") as defined 2373 * by the OpenFlow Switch Specification. 2374 * 2375 * See struct rte_flow_action_of_pop_mpls. 2376 */ 2377 RTE_FLOW_ACTION_TYPE_OF_POP_MPLS, 2378 2379 /** 2380 * Implements OFPAT_PUSH_MPLS ("push a new MPLS tag") as defined by 2381 * the OpenFlow Switch Specification. 2382 * 2383 * See struct rte_flow_action_of_push_mpls. 2384 */ 2385 RTE_FLOW_ACTION_TYPE_OF_PUSH_MPLS, 2386 2387 /** 2388 * Encapsulate flow in VXLAN tunnel as defined in 2389 * rte_flow_action_vxlan_encap action structure. 2390 * 2391 * See struct rte_flow_action_vxlan_encap. 2392 */ 2393 RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP, 2394 2395 /** 2396 * Decapsulate outer most VXLAN tunnel from matched flow. 2397 * 2398 * If flow pattern does not define a valid VXLAN tunnel (as specified by 2399 * RFC7348) then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION 2400 * error. 2401 */ 2402 RTE_FLOW_ACTION_TYPE_VXLAN_DECAP, 2403 2404 /** 2405 * Encapsulate flow in NVGRE tunnel defined in the 2406 * rte_flow_action_nvgre_encap action structure. 2407 * 2408 * See struct rte_flow_action_nvgre_encap. 2409 */ 2410 RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP, 2411 2412 /** 2413 * Decapsulate outer most NVGRE tunnel from matched flow. 2414 * 2415 * If flow pattern does not define a valid NVGRE tunnel (as specified by 2416 * RFC7637) then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION 2417 * error. 2418 */ 2419 RTE_FLOW_ACTION_TYPE_NVGRE_DECAP, 2420 2421 /** 2422 * Add outer header whose template is provided in its data buffer 2423 * 2424 * See struct rte_flow_action_raw_encap. 2425 */ 2426 RTE_FLOW_ACTION_TYPE_RAW_ENCAP, 2427 2428 /** 2429 * Remove outer header whose template is provided in its data buffer. 2430 * 2431 * See struct rte_flow_action_raw_decap 2432 */ 2433 RTE_FLOW_ACTION_TYPE_RAW_DECAP, 2434 2435 /** 2436 * @warning This is a legacy action. 2437 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD 2438 * 2439 * Modify IPv4 source address in the outermost IPv4 header. 2440 * 2441 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV4, 2442 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error. 2443 * 2444 * See struct rte_flow_action_set_ipv4. 2445 */ 2446 RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC, 2447 2448 /** 2449 * @warning This is a legacy action. 2450 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD 2451 * 2452 * Modify IPv4 destination address in the outermost IPv4 header. 2453 * 2454 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV4, 2455 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error. 2456 * 2457 * See struct rte_flow_action_set_ipv4. 2458 */ 2459 RTE_FLOW_ACTION_TYPE_SET_IPV4_DST, 2460 2461 /** 2462 * @warning This is a legacy action. 2463 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD 2464 * 2465 * Modify IPv6 source address in the outermost IPv6 header. 2466 * 2467 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV6, 2468 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error. 2469 * 2470 * See struct rte_flow_action_set_ipv6. 2471 */ 2472 RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC, 2473 2474 /** 2475 * @warning This is a legacy action. 2476 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD 2477 * 2478 * Modify IPv6 destination address in the outermost IPv6 header. 2479 * 2480 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV6, 2481 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error. 2482 * 2483 * See struct rte_flow_action_set_ipv6. 2484 */ 2485 RTE_FLOW_ACTION_TYPE_SET_IPV6_DST, 2486 2487 /** 2488 * @warning This is a legacy action. 2489 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD 2490 * 2491 * Modify source port number in the outermost TCP/UDP header. 2492 * 2493 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_TCP 2494 * or RTE_FLOW_ITEM_TYPE_UDP, then the PMD should return a 2495 * RTE_FLOW_ERROR_TYPE_ACTION error. 2496 * 2497 * See struct rte_flow_action_set_tp. 2498 */ 2499 RTE_FLOW_ACTION_TYPE_SET_TP_SRC, 2500 2501 /** 2502 * @warning This is a legacy action. 2503 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD 2504 * 2505 * Modify destination port number in the outermost TCP/UDP header. 2506 * 2507 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_TCP 2508 * or RTE_FLOW_ITEM_TYPE_UDP, then the PMD should return a 2509 * RTE_FLOW_ERROR_TYPE_ACTION error. 2510 * 2511 * See struct rte_flow_action_set_tp. 2512 */ 2513 RTE_FLOW_ACTION_TYPE_SET_TP_DST, 2514 2515 /** 2516 * Swap the source and destination MAC addresses in the outermost 2517 * Ethernet header. 2518 * 2519 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_ETH, 2520 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error. 2521 * 2522 * No associated configuration structure. 2523 */ 2524 RTE_FLOW_ACTION_TYPE_MAC_SWAP, 2525 2526 /** 2527 * @warning This is a legacy action. 2528 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD 2529 * 2530 * Decrease TTL value directly 2531 * 2532 * No associated configuration structure. 2533 */ 2534 RTE_FLOW_ACTION_TYPE_DEC_TTL, 2535 2536 /** 2537 * @warning This is a legacy action. 2538 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD 2539 * 2540 * Set TTL value 2541 * 2542 * See struct rte_flow_action_set_ttl 2543 */ 2544 RTE_FLOW_ACTION_TYPE_SET_TTL, 2545 2546 /** 2547 * @warning This is a legacy action. 2548 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD 2549 * 2550 * Set source MAC address from matched flow. 2551 * 2552 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_ETH, 2553 * the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error. 2554 * 2555 * See struct rte_flow_action_set_mac. 2556 */ 2557 RTE_FLOW_ACTION_TYPE_SET_MAC_SRC, 2558 2559 /** 2560 * @warning This is a legacy action. 2561 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD 2562 * 2563 * Set destination MAC address from matched flow. 2564 * 2565 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_ETH, 2566 * the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error. 2567 * 2568 * See struct rte_flow_action_set_mac. 2569 */ 2570 RTE_FLOW_ACTION_TYPE_SET_MAC_DST, 2571 2572 /** 2573 * @warning This is a legacy action. 2574 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD 2575 * 2576 * Increase sequence number in the outermost TCP header. 2577 * 2578 * Action configuration specifies the value to increase 2579 * TCP sequence number as a big-endian 32 bit integer. 2580 * 2581 * @p conf type: 2582 * @code rte_be32_t * @endcode 2583 * 2584 * Using this action on non-matching traffic will result in 2585 * undefined behavior. 2586 */ 2587 RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ, 2588 2589 /** 2590 * @warning This is a legacy action. 2591 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD 2592 * 2593 * Decrease sequence number in the outermost TCP header. 2594 * 2595 * Action configuration specifies the value to decrease 2596 * TCP sequence number as a big-endian 32 bit integer. 2597 * 2598 * @p conf type: 2599 * @code rte_be32_t * @endcode 2600 * 2601 * Using this action on non-matching traffic will result in 2602 * undefined behavior. 2603 */ 2604 RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ, 2605 2606 /** 2607 * @warning This is a legacy action. 2608 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD 2609 * 2610 * Increase acknowledgment number in the outermost TCP header. 2611 * 2612 * Action configuration specifies the value to increase 2613 * TCP acknowledgment number as a big-endian 32 bit integer. 2614 * 2615 * @p conf type: 2616 * @code rte_be32_t * @endcode 2617 2618 * Using this action on non-matching traffic will result in 2619 * undefined behavior. 2620 */ 2621 RTE_FLOW_ACTION_TYPE_INC_TCP_ACK, 2622 2623 /** 2624 * @warning This is a legacy action. 2625 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD 2626 * 2627 * Decrease acknowledgment number in the outermost TCP header. 2628 * 2629 * Action configuration specifies the value to decrease 2630 * TCP acknowledgment number as a big-endian 32 bit integer. 2631 * 2632 * @p conf type: 2633 * @code rte_be32_t * @endcode 2634 * 2635 * Using this action on non-matching traffic will result in 2636 * undefined behavior. 2637 */ 2638 RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK, 2639 2640 /** 2641 * @warning This is a legacy action. 2642 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD 2643 * 2644 * Set Tag. 2645 * 2646 * Tag is for internal flow usage only and 2647 * is not delivered to the application. 2648 * 2649 * See struct rte_flow_action_set_tag. 2650 */ 2651 RTE_FLOW_ACTION_TYPE_SET_TAG, 2652 2653 /** 2654 * @warning This is a legacy action. 2655 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD 2656 * 2657 * Set metadata on ingress or egress path. 2658 * 2659 * See struct rte_flow_action_set_meta. 2660 */ 2661 RTE_FLOW_ACTION_TYPE_SET_META, 2662 2663 /** 2664 * @warning This is a legacy action. 2665 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD 2666 * 2667 * Modify IPv4 DSCP in the outermost IP header. 2668 * 2669 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV4, 2670 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error. 2671 * 2672 * See struct rte_flow_action_set_dscp. 2673 */ 2674 RTE_FLOW_ACTION_TYPE_SET_IPV4_DSCP, 2675 2676 /** 2677 * @warning This is a legacy action. 2678 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD 2679 * 2680 * Modify IPv6 DSCP in the outermost IP header. 2681 * 2682 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV6, 2683 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error. 2684 * 2685 * See struct rte_flow_action_set_dscp. 2686 */ 2687 RTE_FLOW_ACTION_TYPE_SET_IPV6_DSCP, 2688 2689 /** 2690 * Report as aged flow if timeout passed without any matching on the 2691 * flow. 2692 * 2693 * See struct rte_flow_action_age. 2694 * See function rte_flow_get_aged_flows 2695 * see enum RTE_ETH_EVENT_FLOW_AGED 2696 * See struct rte_flow_query_age 2697 */ 2698 RTE_FLOW_ACTION_TYPE_AGE, 2699 2700 /** 2701 * The matching packets will be duplicated with specified ratio and 2702 * applied with own set of actions with a fate action. 2703 * 2704 * See struct rte_flow_action_sample. 2705 */ 2706 RTE_FLOW_ACTION_TYPE_SAMPLE, 2707 2708 /** 2709 * @deprecated 2710 * @see RTE_FLOW_ACTION_TYPE_INDIRECT 2711 * 2712 * Describe action shared across multiple flow rules. 2713 * 2714 * Allow multiple rules reference the same action by handle (see 2715 * struct rte_flow_shared_action). 2716 */ 2717 RTE_FLOW_ACTION_TYPE_SHARED, 2718 2719 /** 2720 * Modify a packet header field, tag, mark or metadata. 2721 * 2722 * Allow the modification of an arbitrary header field via 2723 * set, add and sub operations or copying its content into 2724 * tag, meta or mark for future processing. 2725 * 2726 * See struct rte_flow_action_modify_field. 2727 */ 2728 RTE_FLOW_ACTION_TYPE_MODIFY_FIELD, 2729 2730 /** 2731 * An action handle is referenced in a rule through an indirect action. 2732 * 2733 * The same action handle may be used in multiple rules for the same 2734 * or different ethdev ports. 2735 */ 2736 RTE_FLOW_ACTION_TYPE_INDIRECT, 2737 2738 /** 2739 * [META] 2740 * 2741 * Enable tracking a TCP connection state. 2742 * 2743 * @see struct rte_flow_action_conntrack. 2744 */ 2745 RTE_FLOW_ACTION_TYPE_CONNTRACK, 2746 2747 /** 2748 * Color the packet to reflect the meter color result. 2749 * Set the meter color in the mbuf to the selected color. 2750 * 2751 * See struct rte_flow_action_meter_color. 2752 */ 2753 RTE_FLOW_ACTION_TYPE_METER_COLOR, 2754 2755 /** 2756 * At embedded switch level, sends matching traffic to the given ethdev. 2757 * 2758 * @see struct rte_flow_action_ethdev 2759 */ 2760 RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR, 2761 2762 /** 2763 * At embedded switch level, send matching traffic to 2764 * the entity represented by the given ethdev. 2765 * 2766 * @see struct rte_flow_action_ethdev 2767 */ 2768 RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT, 2769 }; 2770 2771 /** 2772 * RTE_FLOW_ACTION_TYPE_MARK 2773 * 2774 * Attaches an integer value to packets and sets RTE_MBUF_F_RX_FDIR and 2775 * RTE_MBUF_F_RX_FDIR_ID mbuf flags. 2776 * 2777 * This value is arbitrary and application-defined. Maximum allowed value 2778 * depends on the underlying implementation. It is returned in the 2779 * hash.fdir.hi mbuf field. 2780 */ 2781 struct rte_flow_action_mark { 2782 uint32_t id; /**< Integer value to return with packets. */ 2783 }; 2784 2785 /** 2786 * @warning 2787 * @b EXPERIMENTAL: this structure may change without prior notice 2788 * 2789 * RTE_FLOW_ACTION_TYPE_JUMP 2790 * 2791 * Redirects packets to a group on the current device. 2792 * 2793 * In a hierarchy of groups, which can be used to represent physical or logical 2794 * flow tables on the device, this action allows the action to be a redirect to 2795 * a group on that device. 2796 */ 2797 struct rte_flow_action_jump { 2798 uint32_t group; 2799 }; 2800 2801 /** 2802 * RTE_FLOW_ACTION_TYPE_QUEUE 2803 * 2804 * Assign packets to a given queue index. 2805 */ 2806 struct rte_flow_action_queue { 2807 uint16_t index; /**< Queue index to use. */ 2808 }; 2809 2810 /** 2811 * @warning 2812 * @b EXPERIMENTAL: this structure may change without prior notice 2813 * 2814 * RTE_FLOW_ACTION_TYPE_AGE 2815 * 2816 * Report flow as aged-out if timeout passed without any matching 2817 * on the flow. RTE_ETH_EVENT_FLOW_AGED event is triggered when a 2818 * port detects new aged-out flows. 2819 * 2820 * The flow context and the flow handle will be reported by the 2821 * rte_flow_get_aged_flows API. 2822 */ 2823 struct rte_flow_action_age { 2824 uint32_t timeout:24; /**< Time in seconds. */ 2825 uint32_t reserved:8; /**< Reserved, must be zero. */ 2826 /** The user flow context, NULL means the rte_flow pointer. */ 2827 void *context; 2828 }; 2829 2830 /** 2831 * RTE_FLOW_ACTION_TYPE_AGE (query) 2832 * 2833 * Query structure to retrieve the aging status information of a 2834 * shared AGE action, or a flow rule using the AGE action. 2835 */ 2836 struct rte_flow_query_age { 2837 uint32_t reserved:6; /**< Reserved, must be zero. */ 2838 uint32_t aged:1; /**< 1 if aging timeout expired, 0 otherwise. */ 2839 /** sec_since_last_hit value is valid. */ 2840 uint32_t sec_since_last_hit_valid:1; 2841 uint32_t sec_since_last_hit:24; /**< Seconds since last traffic hit. */ 2842 }; 2843 2844 /** 2845 * @warning 2846 * @b EXPERIMENTAL: this structure may change without prior notice 2847 * 2848 * RTE_FLOW_ACTION_TYPE_COUNT 2849 * 2850 * Adds a counter action to a matched flow. 2851 * 2852 * If more than one count action is specified in a single flow rule, then each 2853 * action must specify a unique ID. 2854 * 2855 * Counters can be retrieved and reset through ``rte_flow_query()``, see 2856 * ``struct rte_flow_query_count``. 2857 * 2858 * For ports within the same switch domain then the counter ID namespace extends 2859 * to all ports within that switch domain. 2860 */ 2861 struct rte_flow_action_count { 2862 uint32_t id; /**< Counter ID. */ 2863 }; 2864 2865 /** 2866 * RTE_FLOW_ACTION_TYPE_COUNT (query) 2867 * 2868 * Query structure to retrieve and reset flow rule counters. 2869 */ 2870 struct rte_flow_query_count { 2871 uint32_t reset:1; /**< Reset counters after query [in]. */ 2872 uint32_t hits_set:1; /**< hits field is set [out]. */ 2873 uint32_t bytes_set:1; /**< bytes field is set [out]. */ 2874 uint32_t reserved:29; /**< Reserved, must be zero [in, out]. */ 2875 uint64_t hits; /**< Number of hits for this rule [out]. */ 2876 uint64_t bytes; /**< Number of bytes through this rule [out]. */ 2877 }; 2878 2879 /** 2880 * Hash function types. 2881 */ 2882 enum rte_eth_hash_function { 2883 RTE_ETH_HASH_FUNCTION_DEFAULT = 0, 2884 RTE_ETH_HASH_FUNCTION_TOEPLITZ, /**< Toeplitz */ 2885 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR, /**< Simple XOR */ 2886 /** 2887 * Symmetric Toeplitz: src, dst will be replaced by 2888 * xor(src, dst). For the case with src/dst only, 2889 * src or dst address will xor with zero pair. 2890 */ 2891 RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ, 2892 RTE_ETH_HASH_FUNCTION_MAX, 2893 }; 2894 2895 /** 2896 * RTE_FLOW_ACTION_TYPE_RSS 2897 * 2898 * Similar to QUEUE, except RSS is additionally performed on packets to 2899 * spread them among several queues according to the provided parameters. 2900 * 2901 * Unlike global RSS settings used by other DPDK APIs, unsetting the 2902 * @p types field does not disable RSS in a flow rule. Doing so instead 2903 * requests safe unspecified "best-effort" settings from the underlying PMD, 2904 * which depending on the flow rule, may result in anything ranging from 2905 * empty (single queue) to all-inclusive RSS. 2906 * 2907 * Note: RSS hash result is stored in the hash.rss mbuf field which overlaps 2908 * hash.fdir.lo. Since the MARK action sets the hash.fdir.hi field only, 2909 * both can be requested simultaneously. 2910 */ 2911 struct rte_flow_action_rss { 2912 enum rte_eth_hash_function func; /**< RSS hash function to apply. */ 2913 /** 2914 * Packet encapsulation level RSS hash @p types apply to. 2915 * 2916 * - @p 0 requests the default behavior. Depending on the packet 2917 * type, it can mean outermost, innermost, anything in between or 2918 * even no RSS. 2919 * 2920 * It basically stands for the innermost encapsulation level RSS 2921 * can be performed on according to PMD and device capabilities. 2922 * 2923 * - @p 1 requests RSS to be performed on the outermost packet 2924 * encapsulation level. 2925 * 2926 * - @p 2 and subsequent values request RSS to be performed on the 2927 * specified inner packet encapsulation level, from outermost to 2928 * innermost (lower to higher values). 2929 * 2930 * Values other than @p 0 are not necessarily supported. 2931 * 2932 * Requesting a specific RSS level on unrecognized traffic results 2933 * in undefined behavior. For predictable results, it is recommended 2934 * to make the flow rule pattern match packet headers up to the 2935 * requested encapsulation level so that only matching traffic goes 2936 * through. 2937 */ 2938 uint32_t level; 2939 uint64_t types; /**< Specific RSS hash types (see RTE_ETH_RSS_*). */ 2940 uint32_t key_len; /**< Hash key length in bytes. */ 2941 uint32_t queue_num; /**< Number of entries in @p queue. */ 2942 const uint8_t *key; /**< Hash key. */ 2943 const uint16_t *queue; /**< Queue indices to use. */ 2944 }; 2945 2946 /** 2947 * @deprecated 2948 * @see RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR 2949 * @see RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT 2950 * 2951 * RTE_FLOW_ACTION_TYPE_VF 2952 * 2953 * Directs matching traffic to a given virtual function of the current 2954 * device. 2955 * 2956 * Packets matched by a VF pattern item can be redirected to their original 2957 * VF ID instead of the specified one. This parameter may not be available 2958 * and is not guaranteed to work properly if the VF part is matched by a 2959 * prior flow rule or if packets are not addressed to a VF in the first 2960 * place. 2961 */ 2962 struct rte_flow_action_vf { 2963 uint32_t original:1; /**< Use original VF ID if possible. */ 2964 uint32_t reserved:31; /**< Reserved, must be zero. */ 2965 uint32_t id; /**< VF ID. */ 2966 }; 2967 2968 /** 2969 * @deprecated 2970 * @see RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR 2971 * @see RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT 2972 * 2973 * RTE_FLOW_ACTION_TYPE_PORT_ID 2974 * 2975 * Directs matching traffic to a given DPDK port ID. 2976 * 2977 * @see RTE_FLOW_ITEM_TYPE_PORT_ID 2978 */ 2979 struct rte_flow_action_port_id { 2980 uint32_t original:1; /**< Use original DPDK port ID if possible. */ 2981 uint32_t reserved:31; /**< Reserved, must be zero. */ 2982 uint32_t id; /**< DPDK port ID. */ 2983 }; 2984 2985 /** 2986 * RTE_FLOW_ACTION_TYPE_METER 2987 * 2988 * Traffic metering and policing (MTR). 2989 * 2990 * Packets matched by items of this type can be either dropped or passed to the 2991 * next item with their color set by the MTR object. 2992 */ 2993 struct rte_flow_action_meter { 2994 uint32_t mtr_id; /**< MTR object ID created with rte_mtr_create(). */ 2995 }; 2996 2997 /** 2998 * RTE_FLOW_ACTION_TYPE_SECURITY 2999 * 3000 * Perform the security action on flows matched by the pattern items 3001 * according to the configuration of the security session. 3002 * 3003 * This action modifies the payload of matched flows. For INLINE_CRYPTO, the 3004 * security protocol headers and IV are fully provided by the application as 3005 * specified in the flow pattern. The payload of matching packets is 3006 * encrypted on egress, and decrypted and authenticated on ingress. 3007 * For INLINE_PROTOCOL, the security protocol is fully offloaded to HW, 3008 * providing full encapsulation and decapsulation of packets in security 3009 * protocols. The flow pattern specifies both the outer security header fields 3010 * and the inner packet fields. The security session specified in the action 3011 * must match the pattern parameters. 3012 * 3013 * The security session specified in the action must be created on the same 3014 * port as the flow action that is being specified. 3015 * 3016 * The ingress/egress flow attribute should match that specified in the 3017 * security session if the security session supports the definition of the 3018 * direction. 3019 * 3020 * Multiple flows can be configured to use the same security session. 3021 * 3022 * The NULL value is allowed for security session. If security session is NULL, 3023 * then SPI field in ESP flow item and IP addresses in flow items 'IPv4' and 3024 * 'IPv6' will be allowed to be a range. The rule thus created can enable 3025 * security processing on multiple flows. 3026 */ 3027 struct rte_flow_action_security { 3028 void *security_session; /**< Pointer to security session structure. */ 3029 }; 3030 3031 /** 3032 * @deprecated 3033 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD 3034 * 3035 * RTE_FLOW_ACTION_TYPE_OF_SET_MPLS_TTL 3036 * 3037 * Implements OFPAT_SET_MPLS_TTL ("MPLS TTL") as defined by the OpenFlow 3038 * Switch Specification. 3039 */ 3040 struct rte_flow_action_of_set_mpls_ttl { 3041 uint8_t mpls_ttl; /**< MPLS TTL. */ 3042 }; 3043 3044 /** 3045 * @deprecated 3046 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD 3047 * 3048 * RTE_FLOW_ACTION_TYPE_OF_SET_NW_TTL 3049 * 3050 * Implements OFPAT_SET_NW_TTL ("IP TTL") as defined by the OpenFlow Switch 3051 * Specification. 3052 */ 3053 struct rte_flow_action_of_set_nw_ttl { 3054 uint8_t nw_ttl; /**< IP TTL. */ 3055 }; 3056 3057 /** 3058 * RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN 3059 * 3060 * Implements OFPAT_PUSH_VLAN ("push a new VLAN tag") as defined by the 3061 * OpenFlow Switch Specification. 3062 */ 3063 struct rte_flow_action_of_push_vlan { 3064 rte_be16_t ethertype; /**< EtherType. */ 3065 }; 3066 3067 /** 3068 * RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID 3069 * 3070 * Implements OFPAT_SET_VLAN_VID ("set the 802.1q VLAN ID") as defined by 3071 * the OpenFlow Switch Specification. 3072 */ 3073 struct rte_flow_action_of_set_vlan_vid { 3074 rte_be16_t vlan_vid; /**< VLAN ID. */ 3075 }; 3076 3077 /** 3078 * RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP 3079 * 3080 * Implements OFPAT_SET_LAN_PCP ("set the 802.1q priority") as defined by 3081 * the OpenFlow Switch Specification. 3082 */ 3083 struct rte_flow_action_of_set_vlan_pcp { 3084 uint8_t vlan_pcp; /**< VLAN priority. */ 3085 }; 3086 3087 /** 3088 * RTE_FLOW_ACTION_TYPE_OF_POP_MPLS 3089 * 3090 * Implements OFPAT_POP_MPLS ("pop the outer MPLS tag") as defined by the 3091 * OpenFlow Switch Specification. 3092 */ 3093 struct rte_flow_action_of_pop_mpls { 3094 rte_be16_t ethertype; /**< EtherType. */ 3095 }; 3096 3097 /** 3098 * RTE_FLOW_ACTION_TYPE_OF_PUSH_MPLS 3099 * 3100 * Implements OFPAT_PUSH_MPLS ("push a new MPLS tag") as defined by the 3101 * OpenFlow Switch Specification. 3102 */ 3103 struct rte_flow_action_of_push_mpls { 3104 rte_be16_t ethertype; /**< EtherType. */ 3105 }; 3106 3107 /** 3108 * @warning 3109 * @b EXPERIMENTAL: this structure may change without prior notice 3110 * 3111 * RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP 3112 * 3113 * VXLAN tunnel end-point encapsulation data definition 3114 * 3115 * The tunnel definition is provided through the flow item pattern, the 3116 * provided pattern must conform to RFC7348 for the tunnel specified. The flow 3117 * definition must be provided in order from the RTE_FLOW_ITEM_TYPE_ETH 3118 * definition up the end item which is specified by RTE_FLOW_ITEM_TYPE_END. 3119 * 3120 * The mask field allows user to specify which fields in the flow item 3121 * definitions can be ignored and which have valid data and can be used 3122 * verbatim. 3123 * 3124 * Note: the last field is not used in the definition of a tunnel and can be 3125 * ignored. 3126 * 3127 * Valid flow definition for RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP include: 3128 * 3129 * - ETH / IPV4 / UDP / VXLAN / END 3130 * - ETH / IPV6 / UDP / VXLAN / END 3131 * - ETH / VLAN / IPV4 / UDP / VXLAN / END 3132 * 3133 */ 3134 struct rte_flow_action_vxlan_encap { 3135 /** 3136 * Encapsulating vxlan tunnel definition 3137 * (terminated by the END pattern item). 3138 */ 3139 struct rte_flow_item *definition; 3140 }; 3141 3142 /** 3143 * @warning 3144 * @b EXPERIMENTAL: this structure may change without prior notice 3145 * 3146 * RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP 3147 * 3148 * NVGRE tunnel end-point encapsulation data definition 3149 * 3150 * The tunnel definition is provided through the flow item pattern the 3151 * provided pattern must conform with RFC7637. The flow definition must be 3152 * provided in order from the RTE_FLOW_ITEM_TYPE_ETH definition up the end item 3153 * which is specified by RTE_FLOW_ITEM_TYPE_END. 3154 * 3155 * The mask field allows user to specify which fields in the flow item 3156 * definitions can be ignored and which have valid data and can be used 3157 * verbatim. 3158 * 3159 * Note: the last field is not used in the definition of a tunnel and can be 3160 * ignored. 3161 * 3162 * Valid flow definition for RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP include: 3163 * 3164 * - ETH / IPV4 / NVGRE / END 3165 * - ETH / VLAN / IPV6 / NVGRE / END 3166 * 3167 */ 3168 struct rte_flow_action_nvgre_encap { 3169 /** 3170 * Encapsulating vxlan tunnel definition 3171 * (terminated by the END pattern item). 3172 */ 3173 struct rte_flow_item *definition; 3174 }; 3175 3176 /** 3177 * @warning 3178 * @b EXPERIMENTAL: this structure may change without prior notice 3179 * 3180 * RTE_FLOW_ACTION_TYPE_RAW_ENCAP 3181 * 3182 * Raw tunnel end-point encapsulation data definition. 3183 * 3184 * The data holds the headers definitions to be applied on the packet. 3185 * The data must start with ETH header up to the tunnel item header itself. 3186 * When used right after RAW_DECAP (for decapsulating L3 tunnel type for 3187 * example MPLSoGRE) the data will just hold layer 2 header. 3188 * 3189 * The preserve parameter holds which bits in the packet the PMD is not allowed 3190 * to change, this parameter can also be NULL and then the PMD is allowed 3191 * to update any field. 3192 * 3193 * size holds the number of bytes in @p data and @p preserve. 3194 */ 3195 struct rte_flow_action_raw_encap { 3196 uint8_t *data; /**< Encapsulation data. */ 3197 uint8_t *preserve; /**< Bit-mask of @p data to preserve on output. */ 3198 size_t size; /**< Size of @p data and @p preserve. */ 3199 }; 3200 3201 /** 3202 * @warning 3203 * @b EXPERIMENTAL: this structure may change without prior notice 3204 * 3205 * RTE_FLOW_ACTION_TYPE_RAW_DECAP 3206 * 3207 * Raw tunnel end-point decapsulation data definition. 3208 * 3209 * The data holds the headers definitions to be removed from the packet. 3210 * The data must start with ETH header up to the tunnel item header itself. 3211 * When used right before RAW_DECAP (for encapsulating L3 tunnel type for 3212 * example MPLSoGRE) the data will just hold layer 2 header. 3213 * 3214 * size holds the number of bytes in @p data. 3215 */ 3216 struct rte_flow_action_raw_decap { 3217 uint8_t *data; /**< Encapsulation data. */ 3218 size_t size; /**< Size of @p data and @p preserve. */ 3219 }; 3220 3221 /** 3222 * @warning 3223 * @b EXPERIMENTAL: this structure may change without prior notice 3224 * 3225 * RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC 3226 * RTE_FLOW_ACTION_TYPE_SET_IPV4_DST 3227 * 3228 * Allows modification of IPv4 source (RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC) 3229 * and destination address (RTE_FLOW_ACTION_TYPE_SET_IPV4_DST) in the 3230 * specified outermost IPv4 header. 3231 */ 3232 struct rte_flow_action_set_ipv4 { 3233 rte_be32_t ipv4_addr; 3234 }; 3235 3236 /** 3237 * @warning 3238 * @b EXPERIMENTAL: this structure may change without prior notice 3239 * 3240 * RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC 3241 * RTE_FLOW_ACTION_TYPE_SET_IPV6_DST 3242 * 3243 * Allows modification of IPv6 source (RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC) 3244 * and destination address (RTE_FLOW_ACTION_TYPE_SET_IPV6_DST) in the 3245 * specified outermost IPv6 header. 3246 */ 3247 struct rte_flow_action_set_ipv6 { 3248 uint8_t ipv6_addr[16]; 3249 }; 3250 3251 /** 3252 * @warning 3253 * @b EXPERIMENTAL: this structure may change without prior notice 3254 * 3255 * RTE_FLOW_ACTION_TYPE_SET_TP_SRC 3256 * RTE_FLOW_ACTION_TYPE_SET_TP_DST 3257 * 3258 * Allows modification of source (RTE_FLOW_ACTION_TYPE_SET_TP_SRC) 3259 * and destination (RTE_FLOW_ACTION_TYPE_SET_TP_DST) port numbers 3260 * in the specified outermost TCP/UDP header. 3261 */ 3262 struct rte_flow_action_set_tp { 3263 rte_be16_t port; 3264 }; 3265 3266 /** 3267 * RTE_FLOW_ACTION_TYPE_SET_TTL 3268 * 3269 * Set the TTL value directly for IPv4 or IPv6 3270 */ 3271 struct rte_flow_action_set_ttl { 3272 uint8_t ttl_value; 3273 }; 3274 3275 /** 3276 * RTE_FLOW_ACTION_TYPE_SET_MAC 3277 * 3278 * Set MAC address from the matched flow 3279 */ 3280 struct rte_flow_action_set_mac { 3281 uint8_t mac_addr[RTE_ETHER_ADDR_LEN]; 3282 }; 3283 3284 /** 3285 * @warning 3286 * @b EXPERIMENTAL: this structure may change without prior notice 3287 * 3288 * RTE_FLOW_ACTION_TYPE_SET_TAG 3289 * 3290 * Set a tag which is a transient data used during flow matching. This is not 3291 * delivered to application. Multiple tags are supported by specifying index. 3292 */ 3293 struct rte_flow_action_set_tag { 3294 uint32_t data; 3295 uint32_t mask; 3296 uint8_t index; 3297 }; 3298 3299 /** 3300 * @warning 3301 * @b EXPERIMENTAL: this structure may change without prior notice 3302 * 3303 * RTE_FLOW_ACTION_TYPE_SET_META 3304 * 3305 * Set metadata. Metadata set by mbuf metadata dynamic field with 3306 * RTE_MBUF_DYNFLAG_TX_METADATA flag on egress will be overridden by this 3307 * action. On ingress, the metadata will be carried by mbuf metadata dynamic 3308 * field with RTE_MBUF_DYNFLAG_RX_METADATA flag if set. The dynamic mbuf field 3309 * must be registered in advance by rte_flow_dynf_metadata_register(). 3310 * 3311 * Altering partial bits is supported with mask. For bits which have never 3312 * been set, unpredictable value will be seen depending on driver 3313 * implementation. For loopback/hairpin packet, metadata set on Rx/Tx may 3314 * or may not be propagated to the other path depending on HW capability. 3315 * 3316 * RTE_FLOW_ITEM_TYPE_META matches metadata. 3317 */ 3318 struct rte_flow_action_set_meta { 3319 uint32_t data; 3320 uint32_t mask; 3321 }; 3322 3323 /** 3324 * RTE_FLOW_ACTION_TYPE_SET_IPV4_DSCP 3325 * RTE_FLOW_ACTION_TYPE_SET_IPV6_DSCP 3326 * 3327 * Set the DSCP value for IPv4/IPv6 header. 3328 * DSCP in low 6 bits, rest ignored. 3329 */ 3330 struct rte_flow_action_set_dscp { 3331 uint8_t dscp; 3332 }; 3333 3334 /** 3335 * @warning 3336 * @b EXPERIMENTAL: this structure may change without prior notice 3337 * 3338 * RTE_FLOW_ACTION_TYPE_INDIRECT 3339 * 3340 * Opaque type returned after successfully creating an indirect action object. 3341 * The definition of the object handle is different per driver or 3342 * per direct action type. 3343 * 3344 * This handle can be used to manage and query the related direct action: 3345 * - referenced in single flow rule or across multiple flow rules 3346 * over multiple ports 3347 * - update action object configuration 3348 * - query action object data 3349 * - destroy action object 3350 */ 3351 struct rte_flow_action_handle; 3352 3353 /** 3354 * The state of a TCP connection. 3355 */ 3356 enum rte_flow_conntrack_state { 3357 /** SYN-ACK packet was seen. */ 3358 RTE_FLOW_CONNTRACK_STATE_SYN_RECV, 3359 /** 3-way handshake was done. */ 3360 RTE_FLOW_CONNTRACK_STATE_ESTABLISHED, 3361 /** First FIN packet was received to close the connection. */ 3362 RTE_FLOW_CONNTRACK_STATE_FIN_WAIT, 3363 /** First FIN was ACKed. */ 3364 RTE_FLOW_CONNTRACK_STATE_CLOSE_WAIT, 3365 /** Second FIN was received, waiting for the last ACK. */ 3366 RTE_FLOW_CONNTRACK_STATE_LAST_ACK, 3367 /** Second FIN was ACKed, connection was closed. */ 3368 RTE_FLOW_CONNTRACK_STATE_TIME_WAIT, 3369 }; 3370 3371 /** 3372 * The last passed TCP packet flags of a connection. 3373 */ 3374 enum rte_flow_conntrack_tcp_last_index { 3375 RTE_FLOW_CONNTRACK_FLAG_NONE = 0, /**< No Flag. */ 3376 RTE_FLOW_CONNTRACK_FLAG_SYN = RTE_BIT32(0), /**< With SYN flag. */ 3377 RTE_FLOW_CONNTRACK_FLAG_SYNACK = RTE_BIT32(1), /**< With SYNACK flag. */ 3378 RTE_FLOW_CONNTRACK_FLAG_FIN = RTE_BIT32(2), /**< With FIN flag. */ 3379 RTE_FLOW_CONNTRACK_FLAG_ACK = RTE_BIT32(3), /**< With ACK flag. */ 3380 RTE_FLOW_CONNTRACK_FLAG_RST = RTE_BIT32(4), /**< With RST flag. */ 3381 }; 3382 3383 /** 3384 * @warning 3385 * @b EXPERIMENTAL: this structure may change without prior notice 3386 * 3387 * Configuration parameters for each direction of a TCP connection. 3388 * All fields should be in host byte order. 3389 * If needed, driver should convert all fields to network byte order 3390 * if HW needs them in that way. 3391 */ 3392 struct rte_flow_tcp_dir_param { 3393 /** TCP window scaling factor, 0xF to disable. */ 3394 uint32_t scale:4; 3395 /** The FIN was sent by this direction. */ 3396 uint32_t close_initiated:1; 3397 /** An ACK packet has been received by this side. */ 3398 uint32_t last_ack_seen:1; 3399 /** 3400 * If set, it indicates that there is unacknowledged data for the 3401 * packets sent from this direction. 3402 */ 3403 uint32_t data_unacked:1; 3404 /** 3405 * Maximal value of sequence + payload length in sent 3406 * packets (next ACK from the opposite direction). 3407 */ 3408 uint32_t sent_end; 3409 /** 3410 * Maximal value of (ACK + window size) in received packet + length 3411 * over sent packet (maximal sequence could be sent). 3412 */ 3413 uint32_t reply_end; 3414 /** Maximal value of actual window size in sent packets. */ 3415 uint32_t max_win; 3416 /** Maximal value of ACK in sent packets. */ 3417 uint32_t max_ack; 3418 }; 3419 3420 /** 3421 * @warning 3422 * @b EXPERIMENTAL: this structure may change without prior notice 3423 * 3424 * RTE_FLOW_ACTION_TYPE_CONNTRACK 3425 * 3426 * Configuration and initial state for the connection tracking module. 3427 * This structure could be used for both setting and query. 3428 * All fields should be in host byte order. 3429 */ 3430 struct rte_flow_action_conntrack { 3431 /** The peer port number, can be the same port. */ 3432 uint16_t peer_port; 3433 /** 3434 * Direction of this connection when creating a flow rule, the 3435 * value only affects the creation of subsequent flow rules. 3436 */ 3437 uint32_t is_original_dir:1; 3438 /** 3439 * Enable / disable the conntrack HW module. When disabled, the 3440 * result will always be RTE_FLOW_CONNTRACK_FLAG_DISABLED. 3441 * In this state the HW will act as passthrough. 3442 * It only affects this conntrack object in the HW without any effect 3443 * to the other objects. 3444 */ 3445 uint32_t enable:1; 3446 /** At least one ack was seen after the connection was established. */ 3447 uint32_t live_connection:1; 3448 /** Enable selective ACK on this connection. */ 3449 uint32_t selective_ack:1; 3450 /** A challenge ack has passed. */ 3451 uint32_t challenge_ack_passed:1; 3452 /** 3453 * 1: The last packet is seen from the original direction. 3454 * 0: The last packet is seen from the reply direction. 3455 */ 3456 uint32_t last_direction:1; 3457 /** No TCP check will be done except the state change. */ 3458 uint32_t liberal_mode:1; 3459 /** The current state of this connection. */ 3460 enum rte_flow_conntrack_state state; 3461 /** Scaling factor for maximal allowed ACK window. */ 3462 uint8_t max_ack_window; 3463 /** Maximal allowed number of retransmission times. */ 3464 uint8_t retransmission_limit; 3465 /** TCP parameters of the original direction. */ 3466 struct rte_flow_tcp_dir_param original_dir; 3467 /** TCP parameters of the reply direction. */ 3468 struct rte_flow_tcp_dir_param reply_dir; 3469 /** The window value of the last packet passed this conntrack. */ 3470 uint16_t last_window; 3471 enum rte_flow_conntrack_tcp_last_index last_index; 3472 /** The sequence of the last packet passed this conntrack. */ 3473 uint32_t last_seq; 3474 /** The acknowledgment of the last packet passed this conntrack. */ 3475 uint32_t last_ack; 3476 /** 3477 * The total value ACK + payload length of the last packet 3478 * passed this conntrack. 3479 */ 3480 uint32_t last_end; 3481 }; 3482 3483 /** 3484 * RTE_FLOW_ACTION_TYPE_CONNTRACK 3485 * 3486 * Wrapper structure for the context update interface. 3487 * Ports cannot support updating, and the only valid solution is to 3488 * destroy the old context and create a new one instead. 3489 */ 3490 struct rte_flow_modify_conntrack { 3491 /** New connection tracking parameters to be updated. */ 3492 struct rte_flow_action_conntrack new_ct; 3493 /** The direction field will be updated. */ 3494 uint32_t direction:1; 3495 /** All the other fields except direction will be updated. */ 3496 uint32_t state:1; 3497 /** Reserved bits for the future usage. */ 3498 uint32_t reserved:30; 3499 }; 3500 3501 /** 3502 * @warning 3503 * @b EXPERIMENTAL: this structure may change without prior notice 3504 * 3505 * RTE_FLOW_ACTION_TYPE_METER_COLOR 3506 * 3507 * The meter color should be set in the packet meta-data 3508 * (i.e. struct rte_mbuf::sched::color). 3509 */ 3510 struct rte_flow_action_meter_color { 3511 enum rte_color color; /**< Packet color. */ 3512 }; 3513 3514 /** 3515 * Provides an ethdev port ID for use with the following actions: 3516 * RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR, 3517 * RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT. 3518 */ 3519 struct rte_flow_action_ethdev { 3520 uint16_t port_id; /**< ethdev port ID */ 3521 }; 3522 3523 /** 3524 * Field IDs for MODIFY_FIELD action. 3525 */ 3526 enum rte_flow_field_id { 3527 RTE_FLOW_FIELD_START = 0, /**< Start of a packet. */ 3528 RTE_FLOW_FIELD_MAC_DST, /**< Destination MAC Address. */ 3529 RTE_FLOW_FIELD_MAC_SRC, /**< Source MAC Address. */ 3530 RTE_FLOW_FIELD_VLAN_TYPE, /**< 802.1Q Tag Identifier. */ 3531 RTE_FLOW_FIELD_VLAN_ID, /**< 802.1Q VLAN Identifier. */ 3532 RTE_FLOW_FIELD_MAC_TYPE, /**< EtherType. */ 3533 RTE_FLOW_FIELD_IPV4_DSCP, /**< IPv4 DSCP. */ 3534 RTE_FLOW_FIELD_IPV4_TTL, /**< IPv4 Time To Live. */ 3535 RTE_FLOW_FIELD_IPV4_SRC, /**< IPv4 Source Address. */ 3536 RTE_FLOW_FIELD_IPV4_DST, /**< IPv4 Destination Address. */ 3537 RTE_FLOW_FIELD_IPV6_DSCP, /**< IPv6 DSCP. */ 3538 RTE_FLOW_FIELD_IPV6_HOPLIMIT, /**< IPv6 Hop Limit. */ 3539 RTE_FLOW_FIELD_IPV6_SRC, /**< IPv6 Source Address. */ 3540 RTE_FLOW_FIELD_IPV6_DST, /**< IPv6 Destination Address. */ 3541 RTE_FLOW_FIELD_TCP_PORT_SRC, /**< TCP Source Port Number. */ 3542 RTE_FLOW_FIELD_TCP_PORT_DST, /**< TCP Destination Port Number. */ 3543 RTE_FLOW_FIELD_TCP_SEQ_NUM, /**< TCP Sequence Number. */ 3544 RTE_FLOW_FIELD_TCP_ACK_NUM, /**< TCP Acknowledgment Number. */ 3545 RTE_FLOW_FIELD_TCP_FLAGS, /**< TCP Flags. */ 3546 RTE_FLOW_FIELD_UDP_PORT_SRC, /**< UDP Source Port Number. */ 3547 RTE_FLOW_FIELD_UDP_PORT_DST, /**< UDP Destination Port Number. */ 3548 RTE_FLOW_FIELD_VXLAN_VNI, /**< VXLAN Network Identifier. */ 3549 RTE_FLOW_FIELD_GENEVE_VNI, /**< GENEVE Network Identifier. */ 3550 RTE_FLOW_FIELD_GTP_TEID, /**< GTP Tunnel Endpoint Identifier. */ 3551 RTE_FLOW_FIELD_TAG, /**< Tag value. */ 3552 RTE_FLOW_FIELD_MARK, /**< Mark value. */ 3553 RTE_FLOW_FIELD_META, /**< Metadata value. */ 3554 RTE_FLOW_FIELD_POINTER, /**< Memory pointer. */ 3555 RTE_FLOW_FIELD_VALUE, /**< Immediate value. */ 3556 RTE_FLOW_FIELD_IPV4_ECN, /**< IPv4 ECN. */ 3557 RTE_FLOW_FIELD_IPV6_ECN, /**< IPv6 ECN. */ 3558 RTE_FLOW_FIELD_GTP_PSC_QFI, /**< GTP QFI. */ 3559 }; 3560 3561 /** 3562 * @warning 3563 * @b EXPERIMENTAL: this structure may change without prior notice 3564 * 3565 * Field description for MODIFY_FIELD action. 3566 */ 3567 struct rte_flow_action_modify_data { 3568 enum rte_flow_field_id field; /**< Field or memory type ID. */ 3569 RTE_STD_C11 3570 union { 3571 struct { 3572 /** Encapsulation level or tag index. */ 3573 uint32_t level; 3574 /** Number of bits to skip from a field. */ 3575 uint32_t offset; 3576 }; 3577 /** 3578 * Immediate value for RTE_FLOW_FIELD_VALUE, presented in the 3579 * same byte order and length as in relevant rte_flow_item_xxx. 3580 * The immediate source bitfield offset is inherited from 3581 * the destination's one. 3582 */ 3583 uint8_t value[16]; 3584 /** 3585 * Memory address for RTE_FLOW_FIELD_POINTER, memory layout 3586 * should be the same as for relevant field in the 3587 * rte_flow_item_xxx structure. 3588 */ 3589 void *pvalue; 3590 }; 3591 }; 3592 3593 /** 3594 * Operation types for MODIFY_FIELD action. 3595 */ 3596 enum rte_flow_modify_op { 3597 RTE_FLOW_MODIFY_SET = 0, /**< Set a new value. */ 3598 RTE_FLOW_MODIFY_ADD, /**< Add a value to a field. */ 3599 RTE_FLOW_MODIFY_SUB, /**< Subtract a value from a field. */ 3600 }; 3601 3602 /** 3603 * @warning 3604 * @b EXPERIMENTAL: this structure may change without prior notice 3605 * 3606 * RTE_FLOW_ACTION_TYPE_MODIFY_FIELD 3607 * 3608 * Modify a destination header field according to the specified 3609 * operation. Another field of the packet can be used as a source as well 3610 * as tag, mark, metadata, immediate value or a pointer to it. 3611 */ 3612 struct rte_flow_action_modify_field { 3613 enum rte_flow_modify_op operation; /**< Operation to perform. */ 3614 struct rte_flow_action_modify_data dst; /**< Destination field. */ 3615 struct rte_flow_action_modify_data src; /**< Source field. */ 3616 uint32_t width; /**< Number of bits to use from a source field. */ 3617 }; 3618 3619 /* Mbuf dynamic field offset for metadata. */ 3620 extern int32_t rte_flow_dynf_metadata_offs; 3621 3622 /* Mbuf dynamic field flag mask for metadata. */ 3623 extern uint64_t rte_flow_dynf_metadata_mask; 3624 3625 /* Mbuf dynamic field pointer for metadata. */ 3626 #define RTE_FLOW_DYNF_METADATA(m) \ 3627 RTE_MBUF_DYNFIELD((m), rte_flow_dynf_metadata_offs, uint32_t *) 3628 3629 /* Mbuf dynamic flags for metadata. */ 3630 #define RTE_MBUF_DYNFLAG_RX_METADATA (rte_flow_dynf_metadata_mask) 3631 #define RTE_MBUF_DYNFLAG_TX_METADATA (rte_flow_dynf_metadata_mask) 3632 3633 __rte_experimental 3634 static inline uint32_t 3635 rte_flow_dynf_metadata_get(struct rte_mbuf *m) 3636 { 3637 return *RTE_FLOW_DYNF_METADATA(m); 3638 } 3639 3640 __rte_experimental 3641 static inline void 3642 rte_flow_dynf_metadata_set(struct rte_mbuf *m, uint32_t v) 3643 { 3644 *RTE_FLOW_DYNF_METADATA(m) = v; 3645 } 3646 3647 /** 3648 * Definition of a single action. 3649 * 3650 * A list of actions is terminated by a END action. 3651 * 3652 * For simple actions without a configuration object, conf remains NULL. 3653 */ 3654 struct rte_flow_action { 3655 enum rte_flow_action_type type; /**< Action type. */ 3656 const void *conf; /**< Pointer to action configuration object. */ 3657 }; 3658 3659 /** 3660 * Opaque type returned after successfully creating a flow. 3661 * 3662 * This handle can be used to manage and query the related flow (e.g. to 3663 * destroy it or retrieve counters). 3664 */ 3665 struct rte_flow; 3666 3667 /** 3668 * @warning 3669 * @b EXPERIMENTAL: this structure may change without prior notice 3670 * 3671 * RTE_FLOW_ACTION_TYPE_SAMPLE 3672 * 3673 * Adds a sample action to a matched flow. 3674 * 3675 * The matching packets will be duplicated with specified ratio and applied 3676 * with own set of actions with a fate action, the sampled packet could be 3677 * redirected to queue or port. All the packets continue processing on the 3678 * default flow path. 3679 * 3680 * When the sample ratio is set to 1 then the packets will be 100% mirrored. 3681 * Additional action list be supported to add for sampled or mirrored packets. 3682 */ 3683 struct rte_flow_action_sample { 3684 uint32_t ratio; /**< packets sampled equals to '1/ratio'. */ 3685 /** sub-action list specific for the sampling hit cases. */ 3686 const struct rte_flow_action *actions; 3687 }; 3688 3689 /** 3690 * Verbose error types. 3691 * 3692 * Most of them provide the type of the object referenced by struct 3693 * rte_flow_error.cause. 3694 */ 3695 enum rte_flow_error_type { 3696 RTE_FLOW_ERROR_TYPE_NONE, /**< No error. */ 3697 RTE_FLOW_ERROR_TYPE_UNSPECIFIED, /**< Cause unspecified. */ 3698 RTE_FLOW_ERROR_TYPE_HANDLE, /**< Flow rule (handle). */ 3699 RTE_FLOW_ERROR_TYPE_ATTR_GROUP, /**< Group field. */ 3700 RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY, /**< Priority field. */ 3701 RTE_FLOW_ERROR_TYPE_ATTR_INGRESS, /**< Ingress field. */ 3702 RTE_FLOW_ERROR_TYPE_ATTR_EGRESS, /**< Egress field. */ 3703 RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, /**< Transfer field. */ 3704 RTE_FLOW_ERROR_TYPE_ATTR, /**< Attributes structure. */ 3705 RTE_FLOW_ERROR_TYPE_ITEM_NUM, /**< Pattern length. */ 3706 RTE_FLOW_ERROR_TYPE_ITEM_SPEC, /**< Item specification. */ 3707 RTE_FLOW_ERROR_TYPE_ITEM_LAST, /**< Item specification range. */ 3708 RTE_FLOW_ERROR_TYPE_ITEM_MASK, /**< Item specification mask. */ 3709 RTE_FLOW_ERROR_TYPE_ITEM, /**< Specific pattern item. */ 3710 RTE_FLOW_ERROR_TYPE_ACTION_NUM, /**< Number of actions. */ 3711 RTE_FLOW_ERROR_TYPE_ACTION_CONF, /**< Action configuration. */ 3712 RTE_FLOW_ERROR_TYPE_ACTION, /**< Specific action. */ 3713 RTE_FLOW_ERROR_TYPE_STATE, /**< Current device state. */ 3714 }; 3715 3716 /** 3717 * Verbose error structure definition. 3718 * 3719 * This object is normally allocated by applications and set by PMDs, the 3720 * message points to a constant string which does not need to be freed by 3721 * the application, however its pointer can be considered valid only as long 3722 * as its associated DPDK port remains configured. Closing the underlying 3723 * device or unloading the PMD invalidates it. 3724 * 3725 * Both cause and message may be NULL regardless of the error type. 3726 */ 3727 struct rte_flow_error { 3728 enum rte_flow_error_type type; /**< Cause field and error types. */ 3729 const void *cause; /**< Object responsible for the error. */ 3730 const char *message; /**< Human-readable error message. */ 3731 }; 3732 3733 /** 3734 * Complete flow rule description. 3735 * 3736 * This object type is used when converting a flow rule description. 3737 * 3738 * @see RTE_FLOW_CONV_OP_RULE 3739 * @see rte_flow_conv() 3740 */ 3741 RTE_STD_C11 3742 struct rte_flow_conv_rule { 3743 union { 3744 const struct rte_flow_attr *attr_ro; /**< RO attributes. */ 3745 struct rte_flow_attr *attr; /**< Attributes. */ 3746 }; 3747 union { 3748 const struct rte_flow_item *pattern_ro; /**< RO pattern. */ 3749 struct rte_flow_item *pattern; /**< Pattern items. */ 3750 }; 3751 union { 3752 const struct rte_flow_action *actions_ro; /**< RO actions. */ 3753 struct rte_flow_action *actions; /**< List of actions. */ 3754 }; 3755 }; 3756 3757 /** 3758 * Conversion operations for flow API objects. 3759 * 3760 * @see rte_flow_conv() 3761 */ 3762 enum rte_flow_conv_op { 3763 /** 3764 * No operation to perform. 3765 * 3766 * rte_flow_conv() simply returns 0. 3767 */ 3768 RTE_FLOW_CONV_OP_NONE, 3769 3770 /** 3771 * Convert attributes structure. 3772 * 3773 * This is a basic copy of an attributes structure. 3774 * 3775 * - @p src type: 3776 * @code const struct rte_flow_attr * @endcode 3777 * - @p dst type: 3778 * @code struct rte_flow_attr * @endcode 3779 */ 3780 RTE_FLOW_CONV_OP_ATTR, 3781 3782 /** 3783 * Convert a single item. 3784 * 3785 * Duplicates @p spec, @p last and @p mask but not outside objects. 3786 * 3787 * - @p src type: 3788 * @code const struct rte_flow_item * @endcode 3789 * - @p dst type: 3790 * @code struct rte_flow_item * @endcode 3791 */ 3792 RTE_FLOW_CONV_OP_ITEM, 3793 3794 /** 3795 * Convert a single action. 3796 * 3797 * Duplicates @p conf but not outside objects. 3798 * 3799 * - @p src type: 3800 * @code const struct rte_flow_action * @endcode 3801 * - @p dst type: 3802 * @code struct rte_flow_action * @endcode 3803 */ 3804 RTE_FLOW_CONV_OP_ACTION, 3805 3806 /** 3807 * Convert an entire pattern. 3808 * 3809 * Duplicates all pattern items at once with the same constraints as 3810 * RTE_FLOW_CONV_OP_ITEM. 3811 * 3812 * - @p src type: 3813 * @code const struct rte_flow_item * @endcode 3814 * - @p dst type: 3815 * @code struct rte_flow_item * @endcode 3816 */ 3817 RTE_FLOW_CONV_OP_PATTERN, 3818 3819 /** 3820 * Convert a list of actions. 3821 * 3822 * Duplicates the entire list of actions at once with the same 3823 * constraints as RTE_FLOW_CONV_OP_ACTION. 3824 * 3825 * - @p src type: 3826 * @code const struct rte_flow_action * @endcode 3827 * - @p dst type: 3828 * @code struct rte_flow_action * @endcode 3829 */ 3830 RTE_FLOW_CONV_OP_ACTIONS, 3831 3832 /** 3833 * Convert a complete flow rule description. 3834 * 3835 * Comprises attributes, pattern and actions together at once with 3836 * the usual constraints. 3837 * 3838 * - @p src type: 3839 * @code const struct rte_flow_conv_rule * @endcode 3840 * - @p dst type: 3841 * @code struct rte_flow_conv_rule * @endcode 3842 */ 3843 RTE_FLOW_CONV_OP_RULE, 3844 3845 /** 3846 * Convert item type to its name string. 3847 * 3848 * Writes a NUL-terminated string to @p dst. Like snprintf(), the 3849 * returned value excludes the terminator which is always written 3850 * nonetheless. 3851 * 3852 * - @p src type: 3853 * @code (const void *)enum rte_flow_item_type @endcode 3854 * - @p dst type: 3855 * @code char * @endcode 3856 **/ 3857 RTE_FLOW_CONV_OP_ITEM_NAME, 3858 3859 /** 3860 * Convert action type to its name string. 3861 * 3862 * Writes a NUL-terminated string to @p dst. Like snprintf(), the 3863 * returned value excludes the terminator which is always written 3864 * nonetheless. 3865 * 3866 * - @p src type: 3867 * @code (const void *)enum rte_flow_action_type @endcode 3868 * - @p dst type: 3869 * @code char * @endcode 3870 **/ 3871 RTE_FLOW_CONV_OP_ACTION_NAME, 3872 3873 /** 3874 * Convert item type to pointer to item name. 3875 * 3876 * Retrieves item name pointer from its type. The string itself is 3877 * not copied; instead, a unique pointer to an internal static 3878 * constant storage is written to @p dst. 3879 * 3880 * - @p src type: 3881 * @code (const void *)enum rte_flow_item_type @endcode 3882 * - @p dst type: 3883 * @code const char ** @endcode 3884 */ 3885 RTE_FLOW_CONV_OP_ITEM_NAME_PTR, 3886 3887 /** 3888 * Convert action type to pointer to action name. 3889 * 3890 * Retrieves action name pointer from its type. The string itself is 3891 * not copied; instead, a unique pointer to an internal static 3892 * constant storage is written to @p dst. 3893 * 3894 * - @p src type: 3895 * @code (const void *)enum rte_flow_action_type @endcode 3896 * - @p dst type: 3897 * @code const char ** @endcode 3898 */ 3899 RTE_FLOW_CONV_OP_ACTION_NAME_PTR, 3900 }; 3901 3902 /** 3903 * @warning 3904 * @b EXPERIMENTAL: this API may change without prior notice. 3905 * 3906 * Dump hardware internal representation information of 3907 * rte flow to file. 3908 * 3909 * @param[in] port_id 3910 * The port identifier of the Ethernet device. 3911 * @param[in] flow 3912 * The pointer of flow rule to dump. Dump all rules if NULL. 3913 * @param[in] file 3914 * A pointer to a file for output. 3915 * @param[out] error 3916 * Perform verbose error reporting if not NULL. PMDs initialize this 3917 * structure in case of error only. 3918 * @return 3919 * 0 on success, a negative value otherwise. 3920 */ 3921 __rte_experimental 3922 int 3923 rte_flow_dev_dump(uint16_t port_id, struct rte_flow *flow, 3924 FILE *file, struct rte_flow_error *error); 3925 3926 /** 3927 * Check if mbuf dynamic field for metadata is registered. 3928 * 3929 * @return 3930 * True if registered, false otherwise. 3931 */ 3932 __rte_experimental 3933 static inline int 3934 rte_flow_dynf_metadata_avail(void) 3935 { 3936 return !!rte_flow_dynf_metadata_mask; 3937 } 3938 3939 /** 3940 * Register mbuf dynamic field and flag for metadata. 3941 * 3942 * This function must be called prior to use SET_META action in order to 3943 * register the dynamic mbuf field. Otherwise, the data cannot be delivered to 3944 * application. 3945 * 3946 * @return 3947 * 0 on success, a negative errno value otherwise and rte_errno is set. 3948 */ 3949 __rte_experimental 3950 int 3951 rte_flow_dynf_metadata_register(void); 3952 3953 /** 3954 * Check whether a flow rule can be created on a given port. 3955 * 3956 * The flow rule is validated for correctness and whether it could be accepted 3957 * by the device given sufficient resources. The rule is checked against the 3958 * current device mode and queue configuration. The flow rule may also 3959 * optionally be validated against existing flow rules and device resources. 3960 * This function has no effect on the target device. 3961 * 3962 * The returned value is guaranteed to remain valid only as long as no 3963 * successful calls to rte_flow_create() or rte_flow_destroy() are made in 3964 * the meantime and no device parameter affecting flow rules in any way are 3965 * modified, due to possible collisions or resource limitations (although in 3966 * such cases EINVAL should not be returned). 3967 * 3968 * @param port_id 3969 * Port identifier of Ethernet device. 3970 * @param[in] attr 3971 * Flow rule attributes. 3972 * @param[in] pattern 3973 * Pattern specification (list terminated by the END pattern item). 3974 * @param[in] actions 3975 * Associated actions (list terminated by the END action). 3976 * @param[out] error 3977 * Perform verbose error reporting if not NULL. PMDs initialize this 3978 * structure in case of error only. 3979 * 3980 * @return 3981 * 0 if flow rule is valid and can be created. A negative errno value 3982 * otherwise (rte_errno is also set), the following errors are defined: 3983 * 3984 * -ENOSYS: underlying device does not support this functionality. 3985 * 3986 * -EIO: underlying device is removed. 3987 * 3988 * -EINVAL: unknown or invalid rule specification. 3989 * 3990 * -ENOTSUP: valid but unsupported rule specification (e.g. partial 3991 * bit-masks are unsupported). 3992 * 3993 * -EEXIST: collision with an existing rule. Only returned if device 3994 * supports flow rule collision checking and there was a flow rule 3995 * collision. Not receiving this return code is no guarantee that creating 3996 * the rule will not fail due to a collision. 3997 * 3998 * -ENOMEM: not enough memory to execute the function, or if the device 3999 * supports resource validation, resource limitation on the device. 4000 * 4001 * -EBUSY: action cannot be performed due to busy device resources, may 4002 * succeed if the affected queues or even the entire port are in a stopped 4003 * state (see rte_eth_dev_rx_queue_stop() and rte_eth_dev_stop()). 4004 */ 4005 int 4006 rte_flow_validate(uint16_t port_id, 4007 const struct rte_flow_attr *attr, 4008 const struct rte_flow_item pattern[], 4009 const struct rte_flow_action actions[], 4010 struct rte_flow_error *error); 4011 4012 /** 4013 * Create a flow rule on a given port. 4014 * 4015 * @param port_id 4016 * Port identifier of Ethernet device. 4017 * @param[in] attr 4018 * Flow rule attributes. 4019 * @param[in] pattern 4020 * Pattern specification (list terminated by the END pattern item). 4021 * @param[in] actions 4022 * Associated actions (list terminated by the END action). 4023 * @param[out] error 4024 * Perform verbose error reporting if not NULL. PMDs initialize this 4025 * structure in case of error only. 4026 * 4027 * @return 4028 * A valid handle in case of success, NULL otherwise and rte_errno is set 4029 * to the positive version of one of the error codes defined for 4030 * rte_flow_validate(). 4031 */ 4032 struct rte_flow * 4033 rte_flow_create(uint16_t port_id, 4034 const struct rte_flow_attr *attr, 4035 const struct rte_flow_item pattern[], 4036 const struct rte_flow_action actions[], 4037 struct rte_flow_error *error); 4038 4039 /** 4040 * Destroy a flow rule on a given port. 4041 * 4042 * Failure to destroy a flow rule handle may occur when other flow rules 4043 * depend on it, and destroying it would result in an inconsistent state. 4044 * 4045 * This function is only guaranteed to succeed if handles are destroyed in 4046 * reverse order of their creation. 4047 * 4048 * @param port_id 4049 * Port identifier of Ethernet device. 4050 * @param flow 4051 * Flow rule handle to destroy. 4052 * @param[out] error 4053 * Perform verbose error reporting if not NULL. PMDs initialize this 4054 * structure in case of error only. 4055 * 4056 * @return 4057 * 0 on success, a negative errno value otherwise and rte_errno is set. 4058 */ 4059 int 4060 rte_flow_destroy(uint16_t port_id, 4061 struct rte_flow *flow, 4062 struct rte_flow_error *error); 4063 4064 /** 4065 * Destroy all flow rules associated with a port. 4066 * 4067 * In the unlikely event of failure, handles are still considered destroyed 4068 * and no longer valid but the port must be assumed to be in an inconsistent 4069 * state. 4070 * 4071 * @param port_id 4072 * Port identifier of Ethernet device. 4073 * @param[out] error 4074 * Perform verbose error reporting if not NULL. PMDs initialize this 4075 * structure in case of error only. 4076 * 4077 * @return 4078 * 0 on success, a negative errno value otherwise and rte_errno is set. 4079 */ 4080 int 4081 rte_flow_flush(uint16_t port_id, 4082 struct rte_flow_error *error); 4083 4084 /** 4085 * Query an existing flow rule. 4086 * 4087 * This function allows retrieving flow-specific data such as counters. 4088 * Data is gathered by special actions which must be present in the flow 4089 * rule definition. 4090 * 4091 * \see RTE_FLOW_ACTION_TYPE_COUNT 4092 * 4093 * @param port_id 4094 * Port identifier of Ethernet device. 4095 * @param flow 4096 * Flow rule handle to query. 4097 * @param action 4098 * Action definition as defined in original flow rule. 4099 * @param[in, out] data 4100 * Pointer to storage for the associated query data type. 4101 * @param[out] error 4102 * Perform verbose error reporting if not NULL. PMDs initialize this 4103 * structure in case of error only. 4104 * 4105 * @return 4106 * 0 on success, a negative errno value otherwise and rte_errno is set. 4107 */ 4108 int 4109 rte_flow_query(uint16_t port_id, 4110 struct rte_flow *flow, 4111 const struct rte_flow_action *action, 4112 void *data, 4113 struct rte_flow_error *error); 4114 4115 /** 4116 * Restrict ingress traffic to the defined flow rules. 4117 * 4118 * Isolated mode guarantees that all ingress traffic comes from defined flow 4119 * rules only (current and future). 4120 * 4121 * Besides making ingress more deterministic, it allows PMDs to safely reuse 4122 * resources otherwise assigned to handle the remaining traffic, such as 4123 * global RSS configuration settings, VLAN filters, MAC address entries, 4124 * legacy filter API rules and so on in order to expand the set of possible 4125 * flow rule types. 4126 * 4127 * Calling this function as soon as possible after device initialization, 4128 * ideally before the first call to rte_eth_dev_configure(), is recommended 4129 * to avoid possible failures due to conflicting settings. 4130 * 4131 * Once effective, leaving isolated mode may not be possible depending on 4132 * PMD implementation. 4133 * 4134 * Additionally, the following functionality has no effect on the underlying 4135 * port and may return errors such as ENOTSUP ("not supported"): 4136 * 4137 * - Toggling promiscuous mode. 4138 * - Toggling allmulticast mode. 4139 * - Configuring MAC addresses. 4140 * - Configuring multicast addresses. 4141 * - Configuring VLAN filters. 4142 * - Configuring Rx filters through the legacy API (e.g. FDIR). 4143 * - Configuring global RSS settings. 4144 * 4145 * @param port_id 4146 * Port identifier of Ethernet device. 4147 * @param set 4148 * Nonzero to enter isolated mode, attempt to leave it otherwise. 4149 * @param[out] error 4150 * Perform verbose error reporting if not NULL. PMDs initialize this 4151 * structure in case of error only. 4152 * 4153 * @return 4154 * 0 on success, a negative errno value otherwise and rte_errno is set. 4155 */ 4156 int 4157 rte_flow_isolate(uint16_t port_id, int set, struct rte_flow_error *error); 4158 4159 /** 4160 * Initialize flow error structure. 4161 * 4162 * @param[out] error 4163 * Pointer to flow error structure (may be NULL). 4164 * @param code 4165 * Related error code (rte_errno). 4166 * @param type 4167 * Cause field and error types. 4168 * @param cause 4169 * Object responsible for the error. 4170 * @param message 4171 * Human-readable error message. 4172 * 4173 * @return 4174 * Negative error code (errno value) and rte_errno is set. 4175 */ 4176 int 4177 rte_flow_error_set(struct rte_flow_error *error, 4178 int code, 4179 enum rte_flow_error_type type, 4180 const void *cause, 4181 const char *message); 4182 4183 /** 4184 * @deprecated 4185 * @see rte_flow_copy() 4186 */ 4187 struct rte_flow_desc { 4188 size_t size; /**< Allocated space including data[]. */ 4189 struct rte_flow_attr attr; /**< Attributes. */ 4190 struct rte_flow_item *items; /**< Items. */ 4191 struct rte_flow_action *actions; /**< Actions. */ 4192 uint8_t data[]; /**< Storage for items/actions. */ 4193 }; 4194 4195 /** 4196 * @deprecated 4197 * Copy an rte_flow rule description. 4198 * 4199 * This interface is kept for compatibility with older applications but is 4200 * implemented as a wrapper to rte_flow_conv(). It is deprecated due to its 4201 * lack of flexibility and reliance on a type unusable with C++ programs 4202 * (struct rte_flow_desc). 4203 * 4204 * @param[in] fd 4205 * Flow rule description. 4206 * @param[in] len 4207 * Total size of allocated data for the flow description. 4208 * @param[in] attr 4209 * Flow rule attributes. 4210 * @param[in] items 4211 * Pattern specification (list terminated by the END pattern item). 4212 * @param[in] actions 4213 * Associated actions (list terminated by the END action). 4214 * 4215 * @return 4216 * If len is greater or equal to the size of the flow, the total size of the 4217 * flow description and its data. 4218 * If len is lower than the size of the flow, the number of bytes that would 4219 * have been written to desc had it been sufficient. Nothing is written. 4220 */ 4221 __rte_deprecated 4222 size_t 4223 rte_flow_copy(struct rte_flow_desc *fd, size_t len, 4224 const struct rte_flow_attr *attr, 4225 const struct rte_flow_item *items, 4226 const struct rte_flow_action *actions); 4227 4228 /** 4229 * Flow object conversion helper. 4230 * 4231 * This function performs conversion of various flow API objects to a 4232 * pre-allocated destination buffer. See enum rte_flow_conv_op for possible 4233 * operations and details about each of them. 4234 * 4235 * Since destination buffer must be large enough, it works in a manner 4236 * reminiscent of snprintf(): 4237 * 4238 * - If @p size is 0, @p dst may be a NULL pointer, otherwise @p dst must be 4239 * non-NULL. 4240 * - If positive, the returned value represents the number of bytes needed 4241 * to store the conversion of @p src to @p dst according to @p op 4242 * regardless of the @p size parameter. 4243 * - Since no more than @p size bytes can be written to @p dst, output is 4244 * truncated and may be inconsistent when the returned value is larger 4245 * than that. 4246 * - In case of conversion error, a negative error code is returned and 4247 * @p dst contents are unspecified. 4248 * 4249 * @param op 4250 * Operation to perform, related to the object type of @p dst. 4251 * @param[out] dst 4252 * Destination buffer address. Must be suitably aligned by the caller. 4253 * @param size 4254 * Destination buffer size in bytes. 4255 * @param[in] src 4256 * Source object to copy. Depending on @p op, its type may differ from 4257 * that of @p dst. 4258 * @param[out] error 4259 * Perform verbose error reporting if not NULL. Initialized in case of 4260 * error only. 4261 * 4262 * @return 4263 * The number of bytes required to convert @p src to @p dst on success, a 4264 * negative errno value otherwise and rte_errno is set. 4265 * 4266 * @see rte_flow_conv_op 4267 */ 4268 __rte_experimental 4269 int 4270 rte_flow_conv(enum rte_flow_conv_op op, 4271 void *dst, 4272 size_t size, 4273 const void *src, 4274 struct rte_flow_error *error); 4275 4276 /** 4277 * Get aged-out flows of a given port. 4278 * 4279 * RTE_ETH_EVENT_FLOW_AGED event will be triggered when at least one new aged 4280 * out flow was detected after the last call to rte_flow_get_aged_flows. 4281 * This function can be called to get the aged flows asynchronously from the 4282 * event callback or synchronously regardless the event. 4283 * This is not safe to call rte_flow_get_aged_flows function with other flow 4284 * functions from multiple threads simultaneously. 4285 * 4286 * @param port_id 4287 * Port identifier of Ethernet device. 4288 * @param[in, out] contexts 4289 * The address of an array of pointers to the aged-out flows contexts. 4290 * @param[in] nb_contexts 4291 * The length of context array pointers. 4292 * @param[out] error 4293 * Perform verbose error reporting if not NULL. Initialized in case of 4294 * error only. 4295 * 4296 * @return 4297 * if nb_contexts is 0, return the amount of all aged contexts. 4298 * if nb_contexts is not 0 , return the amount of aged flows reported 4299 * in the context array, otherwise negative errno value. 4300 * 4301 * @see rte_flow_action_age 4302 * @see RTE_ETH_EVENT_FLOW_AGED 4303 */ 4304 __rte_experimental 4305 int 4306 rte_flow_get_aged_flows(uint16_t port_id, void **contexts, 4307 uint32_t nb_contexts, struct rte_flow_error *error); 4308 4309 /** 4310 * Specify indirect action object configuration 4311 */ 4312 struct rte_flow_indir_action_conf { 4313 /** 4314 * Flow direction for the indirect action configuration. 4315 * 4316 * Action should be valid at least for one flow direction, 4317 * otherwise it is invalid for both ingress and egress rules. 4318 */ 4319 /** Action valid for rules applied to ingress traffic. */ 4320 uint32_t ingress:1; 4321 /** Action valid for rules applied to egress traffic. */ 4322 uint32_t egress:1; 4323 /** 4324 * When set to 1, indicates that the action is valid for 4325 * transfer traffic; otherwise, for non-transfer traffic. 4326 */ 4327 uint32_t transfer:1; 4328 }; 4329 4330 /** 4331 * @warning 4332 * @b EXPERIMENTAL: this API may change without prior notice. 4333 * 4334 * Create an indirect action object that can be used in flow rules 4335 * via its handle. 4336 * The created object handle has single state and configuration 4337 * across all the flow rules using it. 4338 * 4339 * @param[in] port_id 4340 * The port identifier of the Ethernet device. 4341 * @param[in] conf 4342 * Action configuration for the indirect action object creation. 4343 * @param[in] action 4344 * Specific configuration of the indirect action object. 4345 * @param[out] error 4346 * Perform verbose error reporting if not NULL. PMDs initialize this 4347 * structure in case of error only. 4348 * @return 4349 * A valid handle in case of success, NULL otherwise and rte_errno is set 4350 * to one of the error codes defined: 4351 * - (ENODEV) if *port_id* invalid. 4352 * - (ENOSYS) if underlying device does not support this functionality. 4353 * - (EIO) if underlying device is removed. 4354 * - (EINVAL) if *action* invalid. 4355 * - (ENOTSUP) if *action* valid but unsupported. 4356 */ 4357 __rte_experimental 4358 struct rte_flow_action_handle * 4359 rte_flow_action_handle_create(uint16_t port_id, 4360 const struct rte_flow_indir_action_conf *conf, 4361 const struct rte_flow_action *action, 4362 struct rte_flow_error *error); 4363 4364 /** 4365 * @warning 4366 * @b EXPERIMENTAL: this API may change without prior notice. 4367 * 4368 * Destroy indirect action by handle. 4369 * 4370 * @param[in] port_id 4371 * The port identifier of the Ethernet device. 4372 * @param[in] handle 4373 * Handle for the indirect action object to be destroyed. 4374 * @param[out] error 4375 * Perform verbose error reporting if not NULL. PMDs initialize this 4376 * structure in case of error only. 4377 * @return 4378 * - (0) if success. 4379 * - (-ENODEV) if *port_id* invalid. 4380 * - (-ENOSYS) if underlying device does not support this functionality. 4381 * - (-EIO) if underlying device is removed. 4382 * - (-ENOENT) if action pointed by *action* handle was not found. 4383 * - (-EBUSY) if action pointed by *action* handle still used by some rules 4384 * rte_errno is also set. 4385 */ 4386 __rte_experimental 4387 int 4388 rte_flow_action_handle_destroy(uint16_t port_id, 4389 struct rte_flow_action_handle *handle, 4390 struct rte_flow_error *error); 4391 4392 /** 4393 * @warning 4394 * @b EXPERIMENTAL: this API may change without prior notice. 4395 * 4396 * Update in-place the action configuration and / or state pointed 4397 * by action *handle* with the configuration provided as *update* argument. 4398 * The update of the action configuration effects all flow rules reusing 4399 * the action via *handle*. 4400 * The update general pointer provides the ability of partial updating. 4401 * 4402 * @param[in] port_id 4403 * The port identifier of the Ethernet device. 4404 * @param[in] handle 4405 * Handle for the indirect action object to be updated. 4406 * @param[in] update 4407 * Update profile specification used to modify the action pointed by handle. 4408 * *update* could be with the same type of the immediate action corresponding 4409 * to the *handle* argument when creating, or a wrapper structure includes 4410 * action configuration to be updated and bit fields to indicate the member 4411 * of fields inside the action to update. 4412 * @param[out] error 4413 * Perform verbose error reporting if not NULL. PMDs initialize this 4414 * structure in case of error only. 4415 * @return 4416 * - (0) if success. 4417 * - (-ENODEV) if *port_id* invalid. 4418 * - (-ENOSYS) if underlying device does not support this functionality. 4419 * - (-EIO) if underlying device is removed. 4420 * - (-EINVAL) if *update* invalid. 4421 * - (-ENOTSUP) if *update* valid but unsupported. 4422 * - (-ENOENT) if indirect action object pointed by *handle* was not found. 4423 * rte_errno is also set. 4424 */ 4425 __rte_experimental 4426 int 4427 rte_flow_action_handle_update(uint16_t port_id, 4428 struct rte_flow_action_handle *handle, 4429 const void *update, 4430 struct rte_flow_error *error); 4431 4432 /** 4433 * @warning 4434 * @b EXPERIMENTAL: this API may change without prior notice. 4435 * 4436 * Query the direct action by corresponding indirect action object handle. 4437 * 4438 * Retrieve action-specific data such as counters. 4439 * Data is gathered by special action which may be present/referenced in 4440 * more than one flow rule definition. 4441 * 4442 * @see RTE_FLOW_ACTION_TYPE_COUNT 4443 * 4444 * @param port_id 4445 * Port identifier of Ethernet device. 4446 * @param[in] handle 4447 * Handle for the action object to query. 4448 * @param[in, out] data 4449 * Pointer to storage for the associated query data type. 4450 * @param[out] error 4451 * Perform verbose error reporting if not NULL. PMDs initialize this 4452 * structure in case of error only. 4453 * 4454 * @return 4455 * 0 on success, a negative errno value otherwise and rte_errno is set. 4456 */ 4457 __rte_experimental 4458 int 4459 rte_flow_action_handle_query(uint16_t port_id, 4460 const struct rte_flow_action_handle *handle, 4461 void *data, struct rte_flow_error *error); 4462 4463 /* Tunnel has a type and the key information. */ 4464 struct rte_flow_tunnel { 4465 /** 4466 * Tunnel type, for example RTE_FLOW_ITEM_TYPE_VXLAN, 4467 * RTE_FLOW_ITEM_TYPE_NVGRE etc. 4468 */ 4469 enum rte_flow_item_type type; 4470 uint64_t tun_id; /**< Tunnel identification. */ 4471 4472 RTE_STD_C11 4473 union { 4474 struct { 4475 rte_be32_t src_addr; /**< IPv4 source address. */ 4476 rte_be32_t dst_addr; /**< IPv4 destination address. */ 4477 } ipv4; 4478 struct { 4479 uint8_t src_addr[16]; /**< IPv6 source address. */ 4480 uint8_t dst_addr[16]; /**< IPv6 destination address. */ 4481 } ipv6; 4482 }; 4483 rte_be16_t tp_src; /**< Tunnel port source. */ 4484 rte_be16_t tp_dst; /**< Tunnel port destination. */ 4485 uint16_t tun_flags; /**< Tunnel flags. */ 4486 4487 bool is_ipv6; /**< True for valid IPv6 fields. Otherwise IPv4. */ 4488 4489 /** 4490 * the following members are required to restore packet 4491 * after miss 4492 */ 4493 uint8_t tos; /**< TOS for IPv4, TC for IPv6. */ 4494 uint8_t ttl; /**< TTL for IPv4, HL for IPv6. */ 4495 uint32_t label; /**< Flow Label for IPv6. */ 4496 }; 4497 4498 /** 4499 * Indicate that the packet has a tunnel. 4500 */ 4501 #define RTE_FLOW_RESTORE_INFO_TUNNEL RTE_BIT64(0) 4502 4503 /** 4504 * Indicate that the packet has a non decapsulated tunnel header. 4505 */ 4506 #define RTE_FLOW_RESTORE_INFO_ENCAPSULATED RTE_BIT64(1) 4507 4508 /** 4509 * Indicate that the packet has a group_id. 4510 */ 4511 #define RTE_FLOW_RESTORE_INFO_GROUP_ID RTE_BIT64(2) 4512 4513 /** 4514 * Restore information structure to communicate the current packet processing 4515 * state when some of the processing pipeline is done in hardware and should 4516 * continue in software. 4517 */ 4518 struct rte_flow_restore_info { 4519 /** 4520 * Bitwise flags (RTE_FLOW_RESTORE_INFO_*) to indicate validation of 4521 * other fields in struct rte_flow_restore_info. 4522 */ 4523 uint64_t flags; 4524 uint32_t group_id; /**< Group ID where packed missed */ 4525 struct rte_flow_tunnel tunnel; /**< Tunnel information. */ 4526 }; 4527 4528 /** 4529 * Allocate an array of actions to be used in rte_flow_create, to implement 4530 * tunnel-decap-set for the given tunnel. 4531 * Sample usage: 4532 * actions vxlan_decap / tunnel-decap-set(tunnel properties) / 4533 * jump group 0 / end 4534 * 4535 * @param port_id 4536 * Port identifier of Ethernet device. 4537 * @param[in] tunnel 4538 * Tunnel properties. 4539 * @param[out] actions 4540 * Array of actions to be allocated by the PMD. This array should be 4541 * concatenated with the actions array provided to rte_flow_create. 4542 * @param[out] num_of_actions 4543 * Number of actions allocated. 4544 * @param[out] error 4545 * Perform verbose error reporting if not NULL. PMDs initialize this 4546 * structure in case of error only. 4547 * 4548 * @return 4549 * 0 on success, a negative errno value otherwise and rte_errno is set. 4550 */ 4551 __rte_experimental 4552 int 4553 rte_flow_tunnel_decap_set(uint16_t port_id, 4554 struct rte_flow_tunnel *tunnel, 4555 struct rte_flow_action **actions, 4556 uint32_t *num_of_actions, 4557 struct rte_flow_error *error); 4558 4559 /** 4560 * Allocate an array of items to be used in rte_flow_create, to implement 4561 * tunnel-match for the given tunnel. 4562 * Sample usage: 4563 * pattern tunnel-match(tunnel properties) / outer-header-matches / 4564 * inner-header-matches / end 4565 * 4566 * @param port_id 4567 * Port identifier of Ethernet device. 4568 * @param[in] tunnel 4569 * Tunnel properties. 4570 * @param[out] items 4571 * Array of items to be allocated by the PMD. This array should be 4572 * concatenated with the items array provided to rte_flow_create. 4573 * @param[out] num_of_items 4574 * Number of items allocated. 4575 * @param[out] error 4576 * Perform verbose error reporting if not NULL. PMDs initialize this 4577 * structure in case of error only. 4578 * 4579 * @return 4580 * 0 on success, a negative errno value otherwise and rte_errno is set. 4581 */ 4582 __rte_experimental 4583 int 4584 rte_flow_tunnel_match(uint16_t port_id, 4585 struct rte_flow_tunnel *tunnel, 4586 struct rte_flow_item **items, 4587 uint32_t *num_of_items, 4588 struct rte_flow_error *error); 4589 4590 /** 4591 * Populate the current packet processing state, if exists, for the given mbuf. 4592 * 4593 * One should negotiate tunnel metadata delivery from the NIC to the HW. 4594 * @see rte_eth_rx_metadata_negotiate() 4595 * @see RTE_ETH_RX_METADATA_TUNNEL_ID 4596 * 4597 * @param port_id 4598 * Port identifier of Ethernet device. 4599 * @param[in] m 4600 * Mbuf struct. 4601 * @param[out] info 4602 * Restore information. Upon success contains the HW state. 4603 * @param[out] error 4604 * Perform verbose error reporting if not NULL. PMDs initialize this 4605 * structure in case of error only. 4606 * 4607 * @return 4608 * 0 on success, a negative errno value otherwise and rte_errno is set. 4609 */ 4610 __rte_experimental 4611 int 4612 rte_flow_get_restore_info(uint16_t port_id, 4613 struct rte_mbuf *m, 4614 struct rte_flow_restore_info *info, 4615 struct rte_flow_error *error); 4616 4617 /** 4618 * Release the action array as allocated by rte_flow_tunnel_decap_set. 4619 * 4620 * @param port_id 4621 * Port identifier of Ethernet device. 4622 * @param[in] actions 4623 * Array of actions to be released. 4624 * @param[in] num_of_actions 4625 * Number of elements in actions array. 4626 * @param[out] error 4627 * Perform verbose error reporting if not NULL. PMDs initialize this 4628 * structure in case of error only. 4629 * 4630 * @return 4631 * 0 on success, a negative errno value otherwise and rte_errno is set. 4632 */ 4633 __rte_experimental 4634 int 4635 rte_flow_tunnel_action_decap_release(uint16_t port_id, 4636 struct rte_flow_action *actions, 4637 uint32_t num_of_actions, 4638 struct rte_flow_error *error); 4639 4640 /** 4641 * Release the item array as allocated by rte_flow_tunnel_match. 4642 * 4643 * @param port_id 4644 * Port identifier of Ethernet device. 4645 * @param[in] items 4646 * Array of items to be released. 4647 * @param[in] num_of_items 4648 * Number of elements in item array. 4649 * @param[out] error 4650 * Perform verbose error reporting if not NULL. PMDs initialize this 4651 * structure in case of error only. 4652 * 4653 * @return 4654 * 0 on success, a negative errno value otherwise and rte_errno is set. 4655 */ 4656 __rte_experimental 4657 int 4658 rte_flow_tunnel_item_release(uint16_t port_id, 4659 struct rte_flow_item *items, 4660 uint32_t num_of_items, 4661 struct rte_flow_error *error); 4662 4663 /** 4664 * Get a proxy port to manage "transfer" flows. 4665 * 4666 * Managing "transfer" flows requires that the user communicate them 4667 * via a port which has the privilege to control the embedded switch. 4668 * For some vendors, all ports in a given switching domain have 4669 * this privilege. For other vendors, it's only one port. 4670 * 4671 * This API indicates such a privileged port (a "proxy") 4672 * for a given port in the same switching domain. 4673 * 4674 * @note 4675 * If the PMD serving @p port_id doesn't have the corresponding method 4676 * implemented, the API will return @p port_id via @p proxy_port_id. 4677 * 4678 * @param port_id 4679 * Indicates the port to get a "proxy" for 4680 * @param[out] proxy_port_id 4681 * Indicates the "proxy" port 4682 * @param[out] error 4683 * If not NULL, allows the PMD to provide verbose report in case of error 4684 * 4685 * @return 4686 * 0 on success, a negative error code otherwise 4687 */ 4688 int 4689 rte_flow_pick_transfer_proxy(uint16_t port_id, uint16_t *proxy_port_id, 4690 struct rte_flow_error *error); 4691 4692 /** 4693 * @warning 4694 * @b EXPERIMENTAL: this API may change without prior notice. 4695 * 4696 * Create the flex item with specified configuration over 4697 * the Ethernet device. 4698 * 4699 * @param port_id 4700 * Port identifier of Ethernet device. 4701 * @param[in] conf 4702 * Item configuration. 4703 * @param[out] error 4704 * Perform verbose error reporting if not NULL. PMDs initialize this 4705 * structure in case of error only. 4706 * 4707 * @return 4708 * Non-NULL opaque pointer on success, NULL otherwise and rte_errno is set. 4709 */ 4710 __rte_experimental 4711 struct rte_flow_item_flex_handle * 4712 rte_flow_flex_item_create(uint16_t port_id, 4713 const struct rte_flow_item_flex_conf *conf, 4714 struct rte_flow_error *error); 4715 4716 /** 4717 * Release the flex item on the specified Ethernet device. 4718 * 4719 * @param port_id 4720 * Port identifier of Ethernet device. 4721 * @param[in] handle 4722 * Handle of the item existing on the specified device. 4723 * @param[out] error 4724 * Perform verbose error reporting if not NULL. PMDs initialize this 4725 * structure in case of error only. 4726 * 4727 * @return 4728 * 0 on success, a negative errno value otherwise and rte_errno is set. 4729 */ 4730 __rte_experimental 4731 int 4732 rte_flow_flex_item_release(uint16_t port_id, 4733 const struct rte_flow_item_flex_handle *handle, 4734 struct rte_flow_error *error); 4735 4736 /** 4737 * @warning 4738 * @b EXPERIMENTAL: this API may change without prior notice. 4739 * 4740 * Information about flow engine resources. 4741 * The zero value means a resource is not supported. 4742 * 4743 */ 4744 struct rte_flow_port_info { 4745 /** 4746 * Maximum number of queues for asynchronous operations. 4747 */ 4748 uint32_t max_nb_queues; 4749 /** 4750 * Maximum number of counters. 4751 * @see RTE_FLOW_ACTION_TYPE_COUNT 4752 */ 4753 uint32_t max_nb_counters; 4754 /** 4755 * Maximum number of aging objects. 4756 * @see RTE_FLOW_ACTION_TYPE_AGE 4757 */ 4758 uint32_t max_nb_aging_objects; 4759 /** 4760 * Maximum number traffic meters. 4761 * @see RTE_FLOW_ACTION_TYPE_METER 4762 */ 4763 uint32_t max_nb_meters; 4764 /** 4765 * Maximum number connection trackings. 4766 * @see RTE_FLOW_ACTION_TYPE_CONNTRACK 4767 */ 4768 uint32_t max_nb_conn_tracks; 4769 }; 4770 4771 /** 4772 * @warning 4773 * @b EXPERIMENTAL: this API may change without prior notice. 4774 * 4775 * Information about flow engine asynchronous queues. 4776 * The value only valid if @p port_attr.max_nb_queues is not zero. 4777 * 4778 */ 4779 struct rte_flow_queue_info { 4780 /** 4781 * Maximum number of operations a queue can hold. 4782 */ 4783 uint32_t max_size; 4784 }; 4785 4786 /** 4787 * @warning 4788 * @b EXPERIMENTAL: this API may change without prior notice. 4789 * 4790 * Get information about flow engine resources. 4791 * 4792 * @param port_id 4793 * Port identifier of Ethernet device. 4794 * @param[out] port_info 4795 * A pointer to a structure of type *rte_flow_port_info* 4796 * to be filled with the resources information of the port. 4797 * @param[out] queue_info 4798 * A pointer to a structure of type *rte_flow_queue_info* 4799 * to be filled with the asynchronous queues information. 4800 * @param[out] error 4801 * Perform verbose error reporting if not NULL. 4802 * PMDs initialize this structure in case of error only. 4803 * 4804 * @return 4805 * 0 on success, a negative errno value otherwise and rte_errno is set. 4806 */ 4807 __rte_experimental 4808 int 4809 rte_flow_info_get(uint16_t port_id, 4810 struct rte_flow_port_info *port_info, 4811 struct rte_flow_queue_info *queue_info, 4812 struct rte_flow_error *error); 4813 4814 /** 4815 * @warning 4816 * @b EXPERIMENTAL: this API may change without prior notice. 4817 * 4818 * Flow engine resources settings. 4819 * The zero value means on demand resource allocations only. 4820 * 4821 */ 4822 struct rte_flow_port_attr { 4823 /** 4824 * Number of counters to configure. 4825 * @see RTE_FLOW_ACTION_TYPE_COUNT 4826 */ 4827 uint32_t nb_counters; 4828 /** 4829 * Number of aging objects to configure. 4830 * @see RTE_FLOW_ACTION_TYPE_AGE 4831 */ 4832 uint32_t nb_aging_objects; 4833 /** 4834 * Number of traffic meters to configure. 4835 * @see RTE_FLOW_ACTION_TYPE_METER 4836 */ 4837 uint32_t nb_meters; 4838 /** 4839 * Number of connection trackings to configure. 4840 * @see RTE_FLOW_ACTION_TYPE_CONNTRACK 4841 */ 4842 uint32_t nb_conn_tracks; 4843 }; 4844 4845 /** 4846 * @warning 4847 * @b EXPERIMENTAL: this API may change without prior notice. 4848 * 4849 * Flow engine asynchronous queues settings. 4850 * The value means default value picked by PMD. 4851 * 4852 */ 4853 struct rte_flow_queue_attr { 4854 /** 4855 * Number of flow rule operations a queue can hold. 4856 */ 4857 uint32_t size; 4858 }; 4859 4860 /** 4861 * @warning 4862 * @b EXPERIMENTAL: this API may change without prior notice. 4863 * 4864 * Configure the port's flow API engine. 4865 * 4866 * This API can only be invoked before the application 4867 * starts using the rest of the flow library functions. 4868 * 4869 * The API can be invoked multiple times to change the settings. 4870 * The port, however, may reject changes and keep the old config. 4871 * 4872 * Parameters in configuration attributes must not exceed 4873 * numbers of resources returned by the rte_flow_info_get API. 4874 * 4875 * @param port_id 4876 * Port identifier of Ethernet device. 4877 * @param[in] port_attr 4878 * Port configuration attributes. 4879 * @param[in] nb_queue 4880 * Number of flow queues to be configured. 4881 * @param[in] queue_attr 4882 * Array that holds attributes for each flow queue. 4883 * Number of elements is set in @p port_attr.nb_queues. 4884 * @param[out] error 4885 * Perform verbose error reporting if not NULL. 4886 * PMDs initialize this structure in case of error only. 4887 * 4888 * @return 4889 * 0 on success, a negative errno value otherwise and rte_errno is set. 4890 */ 4891 __rte_experimental 4892 int 4893 rte_flow_configure(uint16_t port_id, 4894 const struct rte_flow_port_attr *port_attr, 4895 uint16_t nb_queue, 4896 const struct rte_flow_queue_attr *queue_attr[], 4897 struct rte_flow_error *error); 4898 4899 /** 4900 * Opaque type returned after successful creation of pattern template. 4901 * This handle can be used to manage the created pattern template. 4902 */ 4903 struct rte_flow_pattern_template; 4904 4905 /** 4906 * @warning 4907 * @b EXPERIMENTAL: this API may change without prior notice. 4908 * 4909 * Flow pattern template attributes. 4910 */ 4911 __extension__ 4912 struct rte_flow_pattern_template_attr { 4913 /** 4914 * Relaxed matching policy. 4915 * - If 1, matching is performed only on items with the mask member set 4916 * and matching on protocol layers specified without any masks is skipped. 4917 * - If 0, matching on protocol layers specified without any masks is done 4918 * as well. This is the standard behaviour of Flow API now. 4919 */ 4920 uint32_t relaxed_matching:1; 4921 /** 4922 * Flow direction for the pattern template. 4923 * At least one direction must be specified. 4924 */ 4925 /** Pattern valid for rules applied to ingress traffic. */ 4926 uint32_t ingress:1; 4927 /** Pattern valid for rules applied to egress traffic. */ 4928 uint32_t egress:1; 4929 /** Pattern valid for rules applied to transfer traffic. */ 4930 uint32_t transfer:1; 4931 }; 4932 4933 /** 4934 * @warning 4935 * @b EXPERIMENTAL: this API may change without prior notice. 4936 * 4937 * Create flow pattern template. 4938 * 4939 * The pattern template defines common matching fields without values. 4940 * For example, matching on 5 tuple TCP flow, the template will be 4941 * eth(null) + IPv4(source + dest) + TCP(s_port + d_port), 4942 * while values for each rule will be set during the flow rule creation. 4943 * The number and order of items in the template must be the same 4944 * at the rule creation. 4945 * 4946 * @param port_id 4947 * Port identifier of Ethernet device. 4948 * @param[in] template_attr 4949 * Pattern template attributes. 4950 * @param[in] pattern 4951 * Pattern specification (list terminated by the END pattern item). 4952 * The spec member of an item is not used unless the end member is used. 4953 * @param[out] error 4954 * Perform verbose error reporting if not NULL. 4955 * PMDs initialize this structure in case of error only. 4956 * 4957 * @return 4958 * Handle on success, NULL otherwise and rte_errno is set. 4959 */ 4960 __rte_experimental 4961 struct rte_flow_pattern_template * 4962 rte_flow_pattern_template_create(uint16_t port_id, 4963 const struct rte_flow_pattern_template_attr *template_attr, 4964 const struct rte_flow_item pattern[], 4965 struct rte_flow_error *error); 4966 4967 /** 4968 * @warning 4969 * @b EXPERIMENTAL: this API may change without prior notice. 4970 * 4971 * Destroy flow pattern template. 4972 * 4973 * This function may be called only when 4974 * there are no more tables referencing this template. 4975 * 4976 * @param port_id 4977 * Port identifier of Ethernet device. 4978 * @param[in] pattern_template 4979 * Handle of the template to be destroyed. 4980 * @param[out] error 4981 * Perform verbose error reporting if not NULL. 4982 * PMDs initialize this structure in case of error only. 4983 * 4984 * @return 4985 * 0 on success, a negative errno value otherwise and rte_errno is set. 4986 */ 4987 __rte_experimental 4988 int 4989 rte_flow_pattern_template_destroy(uint16_t port_id, 4990 struct rte_flow_pattern_template *pattern_template, 4991 struct rte_flow_error *error); 4992 4993 /** 4994 * Opaque type returned after successful creation of actions template. 4995 * This handle can be used to manage the created actions template. 4996 */ 4997 struct rte_flow_actions_template; 4998 4999 /** 5000 * @warning 5001 * @b EXPERIMENTAL: this API may change without prior notice. 5002 * 5003 * Flow actions template attributes. 5004 */ 5005 __extension__ 5006 struct rte_flow_actions_template_attr { 5007 /** 5008 * Flow direction for the actions template. 5009 * At least one direction must be specified. 5010 */ 5011 /** Action valid for rules applied to ingress traffic. */ 5012 uint32_t ingress:1; 5013 /** Action valid for rules applied to egress traffic. */ 5014 uint32_t egress:1; 5015 /** Action valid for rules applied to transfer traffic. */ 5016 uint32_t transfer:1; 5017 }; 5018 5019 /** 5020 * @warning 5021 * @b EXPERIMENTAL: this API may change without prior notice. 5022 * 5023 * Create flow actions template. 5024 * 5025 * The actions template holds a list of action types without values. 5026 * For example, the template to change TCP ports is TCP(s_port + d_port), 5027 * while values for each rule will be set during the flow rule creation. 5028 * The number and order of actions in the template must be the same 5029 * at the rule creation. 5030 * 5031 * @param port_id 5032 * Port identifier of Ethernet device. 5033 * @param[in] template_attr 5034 * Template attributes. 5035 * @param[in] actions 5036 * Associated actions (list terminated by the END action). 5037 * The spec member is only used if @p masks spec is non-zero. 5038 * @param[in] masks 5039 * List of actions that marks which of the action's member is constant. 5040 * A mask has the same format as the corresponding action. 5041 * If the action field in @p masks is not 0, 5042 * the corresponding value in an action from @p actions will be the part 5043 * of the template and used in all flow rules. 5044 * The order of actions in @p masks is the same as in @p actions. 5045 * In case of indirect actions present in @p actions, 5046 * the actual action type should be present in @p mask. 5047 * @param[out] error 5048 * Perform verbose error reporting if not NULL. 5049 * PMDs initialize this structure in case of error only. 5050 * 5051 * @return 5052 * Handle on success, NULL otherwise and rte_errno is set. 5053 */ 5054 __rte_experimental 5055 struct rte_flow_actions_template * 5056 rte_flow_actions_template_create(uint16_t port_id, 5057 const struct rte_flow_actions_template_attr *template_attr, 5058 const struct rte_flow_action actions[], 5059 const struct rte_flow_action masks[], 5060 struct rte_flow_error *error); 5061 5062 /** 5063 * @warning 5064 * @b EXPERIMENTAL: this API may change without prior notice. 5065 * 5066 * Destroy flow actions template. 5067 * 5068 * This function may be called only when 5069 * there are no more tables referencing this template. 5070 * 5071 * @param port_id 5072 * Port identifier of Ethernet device. 5073 * @param[in] actions_template 5074 * Handle to the template to be destroyed. 5075 * @param[out] error 5076 * Perform verbose error reporting if not NULL. 5077 * PMDs initialize this structure in case of error only. 5078 * 5079 * @return 5080 * 0 on success, a negative errno value otherwise and rte_errno is set. 5081 */ 5082 __rte_experimental 5083 int 5084 rte_flow_actions_template_destroy(uint16_t port_id, 5085 struct rte_flow_actions_template *actions_template, 5086 struct rte_flow_error *error); 5087 5088 /** 5089 * Opaque type returned after successful creation of a template table. 5090 * This handle can be used to manage the created template table. 5091 */ 5092 struct rte_flow_template_table; 5093 5094 /** 5095 * @warning 5096 * @b EXPERIMENTAL: this API may change without prior notice. 5097 * 5098 * Table attributes. 5099 */ 5100 struct rte_flow_template_table_attr { 5101 /** 5102 * Flow attributes to be used in each rule generated from this table. 5103 */ 5104 struct rte_flow_attr flow_attr; 5105 /** 5106 * Maximum number of flow rules that this table holds. 5107 */ 5108 uint32_t nb_flows; 5109 }; 5110 5111 /** 5112 * @warning 5113 * @b EXPERIMENTAL: this API may change without prior notice. 5114 * 5115 * Create flow template table. 5116 * 5117 * A template table consists of multiple pattern templates and actions 5118 * templates associated with a single set of rule attributes (group ID, 5119 * priority and traffic direction). 5120 * 5121 * Each rule is free to use any combination of pattern and actions templates 5122 * and specify particular values for items and actions it would like to change. 5123 * 5124 * @param port_id 5125 * Port identifier of Ethernet device. 5126 * @param[in] table_attr 5127 * Template table attributes. 5128 * @param[in] pattern_templates 5129 * Array of pattern templates to be used in this table. 5130 * @param[in] nb_pattern_templates 5131 * The number of pattern templates in the pattern_templates array. 5132 * @param[in] actions_templates 5133 * Array of actions templates to be used in this table. 5134 * @param[in] nb_actions_templates 5135 * The number of actions templates in the actions_templates array. 5136 * @param[out] error 5137 * Perform verbose error reporting if not NULL. 5138 * PMDs initialize this structure in case of error only. 5139 * 5140 * @return 5141 * Handle on success, NULL otherwise and rte_errno is set. 5142 */ 5143 __rte_experimental 5144 struct rte_flow_template_table * 5145 rte_flow_template_table_create(uint16_t port_id, 5146 const struct rte_flow_template_table_attr *table_attr, 5147 struct rte_flow_pattern_template *pattern_templates[], 5148 uint8_t nb_pattern_templates, 5149 struct rte_flow_actions_template *actions_templates[], 5150 uint8_t nb_actions_templates, 5151 struct rte_flow_error *error); 5152 5153 /** 5154 * @warning 5155 * @b EXPERIMENTAL: this API may change without prior notice. 5156 * 5157 * Destroy flow template table. 5158 * 5159 * This function may be called only when 5160 * there are no more flow rules referencing this table. 5161 * 5162 * @param port_id 5163 * Port identifier of Ethernet device. 5164 * @param[in] template_table 5165 * Handle to the table to be destroyed. 5166 * @param[out] error 5167 * Perform verbose error reporting if not NULL. 5168 * PMDs initialize this structure in case of error only. 5169 * 5170 * @return 5171 * 0 on success, a negative errno value otherwise and rte_errno is set. 5172 */ 5173 __rte_experimental 5174 int 5175 rte_flow_template_table_destroy(uint16_t port_id, 5176 struct rte_flow_template_table *template_table, 5177 struct rte_flow_error *error); 5178 5179 /** 5180 * @warning 5181 * @b EXPERIMENTAL: this API may change without prior notice. 5182 * 5183 * Asynchronous operation attributes. 5184 */ 5185 __extension__ 5186 struct rte_flow_op_attr { 5187 /** 5188 * When set, the requested action will not be sent to the HW immediately. 5189 * The application must call the rte_flow_queue_push to actually send it. 5190 */ 5191 uint32_t postpone:1; 5192 }; 5193 5194 /** 5195 * @warning 5196 * @b EXPERIMENTAL: this API may change without prior notice. 5197 * 5198 * Enqueue rule creation operation. 5199 * 5200 * @param port_id 5201 * Port identifier of Ethernet device. 5202 * @param queue_id 5203 * Flow queue used to insert the rule. 5204 * @param[in] op_attr 5205 * Rule creation operation attributes. 5206 * @param[in] template_table 5207 * Template table to select templates from. 5208 * @param[in] pattern 5209 * List of pattern items to be used. 5210 * The list order should match the order in the pattern template. 5211 * The spec is the only relevant member of the item that is being used. 5212 * @param[in] pattern_template_index 5213 * Pattern template index in the table. 5214 * @param[in] actions 5215 * List of actions to be used. 5216 * The list order should match the order in the actions template. 5217 * @param[in] actions_template_index 5218 * Actions template index in the table. 5219 * @param[in] user_data 5220 * The user data that will be returned on the completion events. 5221 * @param[out] error 5222 * Perform verbose error reporting if not NULL. 5223 * PMDs initialize this structure in case of error only. 5224 * 5225 * @return 5226 * Handle on success, NULL otherwise and rte_errno is set. 5227 * The rule handle doesn't mean that the rule has been populated. 5228 * Only completion result indicates that if there was success or failure. 5229 */ 5230 __rte_experimental 5231 struct rte_flow * 5232 rte_flow_async_create(uint16_t port_id, 5233 uint32_t queue_id, 5234 const struct rte_flow_op_attr *op_attr, 5235 struct rte_flow_template_table *template_table, 5236 const struct rte_flow_item pattern[], 5237 uint8_t pattern_template_index, 5238 const struct rte_flow_action actions[], 5239 uint8_t actions_template_index, 5240 void *user_data, 5241 struct rte_flow_error *error); 5242 5243 /** 5244 * @warning 5245 * @b EXPERIMENTAL: this API may change without prior notice. 5246 * 5247 * Enqueue rule destruction operation. 5248 * 5249 * This function enqueues a destruction operation on the queue. 5250 * Application should assume that after calling this function 5251 * the rule handle is not valid anymore. 5252 * Completion indicates the full removal of the rule from the HW. 5253 * 5254 * @param port_id 5255 * Port identifier of Ethernet device. 5256 * @param queue_id 5257 * Flow queue which is used to destroy the rule. 5258 * This must match the queue on which the rule was created. 5259 * @param[in] op_attr 5260 * Rule destruction operation attributes. 5261 * @param[in] flow 5262 * Flow handle to be destroyed. 5263 * @param[in] user_data 5264 * The user data that will be returned on the completion events. 5265 * @param[out] error 5266 * Perform verbose error reporting if not NULL. 5267 * PMDs initialize this structure in case of error only. 5268 * 5269 * @return 5270 * 0 on success, a negative errno value otherwise and rte_errno is set. 5271 */ 5272 __rte_experimental 5273 int 5274 rte_flow_async_destroy(uint16_t port_id, 5275 uint32_t queue_id, 5276 const struct rte_flow_op_attr *op_attr, 5277 struct rte_flow *flow, 5278 void *user_data, 5279 struct rte_flow_error *error); 5280 5281 /** 5282 * @warning 5283 * @b EXPERIMENTAL: this API may change without prior notice. 5284 * 5285 * Push all internally stored rules to the HW. 5286 * Postponed rules are rules that were inserted with the postpone flag set. 5287 * Can be used to notify the HW about batch of rules prepared by the SW to 5288 * reduce the number of communications between the HW and SW. 5289 * 5290 * @param port_id 5291 * Port identifier of Ethernet device. 5292 * @param queue_id 5293 * Flow queue to be pushed. 5294 * @param[out] error 5295 * Perform verbose error reporting if not NULL. 5296 * PMDs initialize this structure in case of error only. 5297 * 5298 * @return 5299 * 0 on success, a negative errno value otherwise and rte_errno is set. 5300 */ 5301 __rte_experimental 5302 int 5303 rte_flow_push(uint16_t port_id, 5304 uint32_t queue_id, 5305 struct rte_flow_error *error); 5306 5307 /** 5308 * @warning 5309 * @b EXPERIMENTAL: this API may change without prior notice. 5310 * 5311 * Asynchronous operation status. 5312 */ 5313 enum rte_flow_op_status { 5314 /** 5315 * The operation was completed successfully. 5316 */ 5317 RTE_FLOW_OP_SUCCESS, 5318 /** 5319 * The operation was not completed successfully. 5320 */ 5321 RTE_FLOW_OP_ERROR, 5322 }; 5323 5324 /** 5325 * @warning 5326 * @b EXPERIMENTAL: this API may change without prior notice. 5327 * 5328 * Asynchronous operation result. 5329 */ 5330 __extension__ 5331 struct rte_flow_op_result { 5332 /** 5333 * Returns the status of the operation that this completion signals. 5334 */ 5335 enum rte_flow_op_status status; 5336 /** 5337 * The user data that will be returned on the completion events. 5338 */ 5339 void *user_data; 5340 }; 5341 5342 /** 5343 * @warning 5344 * @b EXPERIMENTAL: this API may change without prior notice. 5345 * 5346 * Pull a rte flow operation. 5347 * The application must invoke this function in order to complete 5348 * the flow rule offloading and to retrieve the flow rule operation status. 5349 * 5350 * @param port_id 5351 * Port identifier of Ethernet device. 5352 * @param queue_id 5353 * Flow queue which is used to pull the operation. 5354 * @param[out] res 5355 * Array of results that will be set. 5356 * @param[in] n_res 5357 * Maximum number of results that can be returned. 5358 * This value is equal to the size of the res array. 5359 * @param[out] error 5360 * Perform verbose error reporting if not NULL. 5361 * PMDs initialize this structure in case of error only. 5362 * 5363 * @return 5364 * Number of results that were pulled, 5365 * a negative errno value otherwise and rte_errno is set. 5366 */ 5367 __rte_experimental 5368 int 5369 rte_flow_pull(uint16_t port_id, 5370 uint32_t queue_id, 5371 struct rte_flow_op_result res[], 5372 uint16_t n_res, 5373 struct rte_flow_error *error); 5374 5375 /** 5376 * @warning 5377 * @b EXPERIMENTAL: this API may change without prior notice. 5378 * 5379 * Enqueue indirect action creation operation. 5380 * @see rte_flow_action_handle_create 5381 * 5382 * @param[in] port_id 5383 * Port identifier of Ethernet device. 5384 * @param[in] queue_id 5385 * Flow queue which is used to create the rule. 5386 * @param[in] op_attr 5387 * Indirect action creation operation attributes. 5388 * @param[in] indir_action_conf 5389 * Action configuration for the indirect action object creation. 5390 * @param[in] action 5391 * Specific configuration of the indirect action object. 5392 * @param[in] user_data 5393 * The user data that will be returned on the completion events. 5394 * @param[out] error 5395 * Perform verbose error reporting if not NULL. 5396 * PMDs initialize this structure in case of error only. 5397 * 5398 * @return 5399 * A valid handle in case of success, NULL otherwise and rte_errno is set. 5400 */ 5401 __rte_experimental 5402 struct rte_flow_action_handle * 5403 rte_flow_async_action_handle_create(uint16_t port_id, 5404 uint32_t queue_id, 5405 const struct rte_flow_op_attr *op_attr, 5406 const struct rte_flow_indir_action_conf *indir_action_conf, 5407 const struct rte_flow_action *action, 5408 void *user_data, 5409 struct rte_flow_error *error); 5410 5411 /** 5412 * @warning 5413 * @b EXPERIMENTAL: this API may change without prior notice. 5414 * 5415 * Enqueue indirect action destruction operation. 5416 * The destroy queue must be the same 5417 * as the queue on which the action was created. 5418 * 5419 * @param[in] port_id 5420 * Port identifier of Ethernet device. 5421 * @param[in] queue_id 5422 * Flow queue which is used to destroy the rule. 5423 * @param[in] op_attr 5424 * Indirect action destruction operation attributes. 5425 * @param[in] action_handle 5426 * Handle for the indirect action object to be destroyed. 5427 * @param[in] user_data 5428 * The user data that will be returned on the completion events. 5429 * @param[out] error 5430 * Perform verbose error reporting if not NULL. 5431 * PMDs initialize this structure in case of error only. 5432 * 5433 * @return 5434 * 0 on success, a negative errno value otherwise and rte_errno is set. 5435 */ 5436 __rte_experimental 5437 int 5438 rte_flow_async_action_handle_destroy(uint16_t port_id, 5439 uint32_t queue_id, 5440 const struct rte_flow_op_attr *op_attr, 5441 struct rte_flow_action_handle *action_handle, 5442 void *user_data, 5443 struct rte_flow_error *error); 5444 5445 /** 5446 * @warning 5447 * @b EXPERIMENTAL: this API may change without prior notice. 5448 * 5449 * Enqueue indirect action update operation. 5450 * @see rte_flow_action_handle_create 5451 * 5452 * @param[in] port_id 5453 * Port identifier of Ethernet device. 5454 * @param[in] queue_id 5455 * Flow queue which is used to update the rule. 5456 * @param[in] op_attr 5457 * Indirect action update operation attributes. 5458 * @param[in] action_handle 5459 * Handle for the indirect action object to be updated. 5460 * @param[in] update 5461 * Update profile specification used to modify the action pointed by handle. 5462 * *update* could be with the same type of the immediate action corresponding 5463 * to the *handle* argument when creating, or a wrapper structure includes 5464 * action configuration to be updated and bit fields to indicate the member 5465 * of fields inside the action to update. 5466 * @param[in] user_data 5467 * The user data that will be returned on the completion events. 5468 * @param[out] error 5469 * Perform verbose error reporting if not NULL. 5470 * PMDs initialize this structure in case of error only. 5471 * 5472 * @return 5473 * 0 on success, a negative errno value otherwise and rte_errno is set. 5474 */ 5475 __rte_experimental 5476 int 5477 rte_flow_async_action_handle_update(uint16_t port_id, 5478 uint32_t queue_id, 5479 const struct rte_flow_op_attr *op_attr, 5480 struct rte_flow_action_handle *action_handle, 5481 const void *update, 5482 void *user_data, 5483 struct rte_flow_error *error); 5484 5485 /** 5486 * @warning 5487 * @b EXPERIMENTAL: this API may change without prior notice. 5488 * 5489 * Enqueue indirect action query operation. 5490 * 5491 * Retrieve action-specific data such as counters. 5492 * Data is gathered by special action which may be present/referenced in 5493 * more than one flow rule definition. 5494 * Data will be available only when completion event returns. 5495 * 5496 * @see rte_flow_async_action_handle_query 5497 * 5498 * @param port_id 5499 * Port identifier of Ethernet device. 5500 * @param[in] queue_id 5501 * Flow queue which is used to query the action. 5502 * @param[in] op_attr 5503 * Indirect action update operation attributes. 5504 * @param[in] action_handle 5505 * Handle for the action object to query. 5506 * @param[in, out] data 5507 * Pointer to storage for the associated query data type. 5508 * The out data will be available only when completion event returns 5509 * from rte_flow_pull. 5510 * @param[in] user_data 5511 * The user data that will be returned on the completion events. 5512 * @param[out] error 5513 * Perform verbose error reporting if not NULL. PMDs initialize this 5514 * structure in case of error only. 5515 * 5516 * @return 5517 * 0 on success, a negative errno value otherwise and rte_errno is set. 5518 */ 5519 __rte_experimental 5520 int 5521 rte_flow_async_action_handle_query(uint16_t port_id, 5522 uint32_t queue_id, 5523 const struct rte_flow_op_attr *op_attr, 5524 const struct rte_flow_action_handle *action_handle, 5525 void *data, 5526 void *user_data, 5527 struct rte_flow_error *error); 5528 5529 #ifdef __cplusplus 5530 } 5531 #endif 5532 5533 #endif /* RTE_FLOW_H_ */ 5534