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