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