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