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 RTE_FLOW_FIELD_FLEX_ITEM, /**< Flex item. */ 3617 RTE_FLOW_FIELD_HASH_RESULT, /**< Hash result. */ 3618 }; 3619 3620 /** 3621 * @warning 3622 * @b EXPERIMENTAL: this structure may change without prior notice 3623 * 3624 * Field description for MODIFY_FIELD action. 3625 */ 3626 struct rte_flow_action_modify_data { 3627 enum rte_flow_field_id field; /**< Field or memory type ID. */ 3628 RTE_STD_C11 3629 union { 3630 struct { 3631 /** Encapsulation level or tag index or flex item handle. */ 3632 union { 3633 uint32_t level; 3634 struct rte_flow_item_flex_handle *flex_handle; 3635 }; 3636 /** Number of bits to skip from a field. */ 3637 uint32_t offset; 3638 }; 3639 /** 3640 * Immediate value for RTE_FLOW_FIELD_VALUE, presented in the 3641 * same byte order and length as in relevant rte_flow_item_xxx. 3642 * The immediate source bitfield offset is inherited from 3643 * the destination's one. 3644 */ 3645 uint8_t value[16]; 3646 /** 3647 * Memory address for RTE_FLOW_FIELD_POINTER, memory layout 3648 * should be the same as for relevant field in the 3649 * rte_flow_item_xxx structure. 3650 */ 3651 void *pvalue; 3652 }; 3653 }; 3654 3655 /** 3656 * Operation types for MODIFY_FIELD action. 3657 */ 3658 enum rte_flow_modify_op { 3659 RTE_FLOW_MODIFY_SET = 0, /**< Set a new value. */ 3660 RTE_FLOW_MODIFY_ADD, /**< Add a value to a field. */ 3661 RTE_FLOW_MODIFY_SUB, /**< Subtract a value from a field. */ 3662 }; 3663 3664 /** 3665 * @warning 3666 * @b EXPERIMENTAL: this structure may change without prior notice 3667 * 3668 * RTE_FLOW_ACTION_TYPE_MODIFY_FIELD 3669 * 3670 * Modify a destination header field according to the specified 3671 * operation. Another field of the packet can be used as a source as well 3672 * as tag, mark, metadata, immediate value or a pointer to it. 3673 */ 3674 struct rte_flow_action_modify_field { 3675 enum rte_flow_modify_op operation; /**< Operation to perform. */ 3676 struct rte_flow_action_modify_data dst; /**< Destination field. */ 3677 struct rte_flow_action_modify_data src; /**< Source field. */ 3678 uint32_t width; /**< Number of bits to use from a source field. */ 3679 }; 3680 3681 /** 3682 * RTE_FLOW_ACTION_TYPE_METER_MARK 3683 * 3684 * Traffic metering and marking (MTR). 3685 * 3686 * Meters a packet stream and marks its packets either 3687 * green, yellow, or red according to the specified profile. 3688 * The policy is optional and may be specified for defining 3689 * subsequent actions based on a color assigned by MTR. 3690 * Alternatively, the METER_COLOR item may be used for this. 3691 */ 3692 struct rte_flow_action_meter_mark { 3693 3694 /**< Profile config retrieved with rte_mtr_profile_get(). */ 3695 struct rte_flow_meter_profile *profile; 3696 /**< Policy config retrieved with rte_mtr_policy_get(). */ 3697 struct rte_flow_meter_policy *policy; 3698 /** Metering mode: 0 - Color-Blind, 1 - Color-Aware. */ 3699 int color_mode; 3700 /** Initial Color applied to packets in Color-Aware mode. */ 3701 enum rte_color init_color; 3702 /** Metering state: 0 - Disabled, 1 - Enabled. */ 3703 int state; 3704 }; 3705 3706 /** 3707 * RTE_FLOW_ACTION_TYPE_METER_MARK 3708 * 3709 * Wrapper structure for the context update interface. 3710 * 3711 */ 3712 struct rte_flow_update_meter_mark { 3713 /** New meter_mark parameters to be updated. */ 3714 struct rte_flow_action_meter_mark meter_mark; 3715 /** The profile will be updated. */ 3716 uint32_t profile_valid:1; 3717 /** The policy will be updated. */ 3718 uint32_t policy_valid:1; 3719 /** The color mode will be updated. */ 3720 uint32_t color_mode_valid:1; 3721 /** The initial color will be updated. */ 3722 uint32_t init_color_valid:1; 3723 /** The meter state will be updated. */ 3724 uint32_t state_valid:1; 3725 /** Reserved bits for the future usage. */ 3726 uint32_t reserved:27; 3727 }; 3728 3729 /* Mbuf dynamic field offset for metadata. */ 3730 extern int32_t rte_flow_dynf_metadata_offs; 3731 3732 /* Mbuf dynamic field flag mask for metadata. */ 3733 extern uint64_t rte_flow_dynf_metadata_mask; 3734 3735 /* Mbuf dynamic field pointer for metadata. */ 3736 #define RTE_FLOW_DYNF_METADATA(m) \ 3737 RTE_MBUF_DYNFIELD((m), rte_flow_dynf_metadata_offs, uint32_t *) 3738 3739 /* Mbuf dynamic flags for metadata. */ 3740 #define RTE_MBUF_DYNFLAG_RX_METADATA (rte_flow_dynf_metadata_mask) 3741 #define RTE_MBUF_DYNFLAG_TX_METADATA (rte_flow_dynf_metadata_mask) 3742 3743 __rte_experimental 3744 static inline uint32_t 3745 rte_flow_dynf_metadata_get(struct rte_mbuf *m) 3746 { 3747 return *RTE_FLOW_DYNF_METADATA(m); 3748 } 3749 3750 __rte_experimental 3751 static inline void 3752 rte_flow_dynf_metadata_set(struct rte_mbuf *m, uint32_t v) 3753 { 3754 *RTE_FLOW_DYNF_METADATA(m) = v; 3755 } 3756 3757 /** 3758 * Definition of a single action. 3759 * 3760 * A list of actions is terminated by a END action. 3761 * 3762 * For simple actions without a configuration object, conf remains NULL. 3763 */ 3764 struct rte_flow_action { 3765 enum rte_flow_action_type type; /**< Action type. */ 3766 const void *conf; /**< Pointer to action configuration object. */ 3767 }; 3768 3769 /** 3770 * Opaque type returned after successfully creating a flow. 3771 * 3772 * This handle can be used to manage and query the related flow (e.g. to 3773 * destroy it or retrieve counters). 3774 */ 3775 struct rte_flow; 3776 3777 /** 3778 * Opaque type for Meter profile object returned by MTR API. 3779 * 3780 * This handle can be used to create Meter actions instead of profile ID. 3781 */ 3782 struct rte_flow_meter_profile; 3783 3784 /** 3785 * Opaque type for Meter policy object returned by MTR API. 3786 * 3787 * This handle can be used to create Meter actions instead of policy ID. 3788 */ 3789 struct rte_flow_meter_policy; 3790 3791 /** 3792 * @warning 3793 * @b EXPERIMENTAL: this structure may change without prior notice 3794 * 3795 * RTE_FLOW_ACTION_TYPE_SAMPLE 3796 * 3797 * Adds a sample action to a matched flow. 3798 * 3799 * The matching packets will be duplicated with specified ratio and applied 3800 * with own set of actions with a fate action, the sampled packet could be 3801 * redirected to queue or port. All the packets continue processing on the 3802 * default flow path. 3803 * 3804 * When the sample ratio is set to 1 then the packets will be 100% mirrored. 3805 * Additional action list be supported to add for sampled or mirrored packets. 3806 */ 3807 struct rte_flow_action_sample { 3808 uint32_t ratio; /**< packets sampled equals to '1/ratio'. */ 3809 /** sub-action list specific for the sampling hit cases. */ 3810 const struct rte_flow_action *actions; 3811 }; 3812 3813 /** 3814 * Verbose error types. 3815 * 3816 * Most of them provide the type of the object referenced by struct 3817 * rte_flow_error.cause. 3818 */ 3819 enum rte_flow_error_type { 3820 RTE_FLOW_ERROR_TYPE_NONE, /**< No error. */ 3821 RTE_FLOW_ERROR_TYPE_UNSPECIFIED, /**< Cause unspecified. */ 3822 RTE_FLOW_ERROR_TYPE_HANDLE, /**< Flow rule (handle). */ 3823 RTE_FLOW_ERROR_TYPE_ATTR_GROUP, /**< Group field. */ 3824 RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY, /**< Priority field. */ 3825 RTE_FLOW_ERROR_TYPE_ATTR_INGRESS, /**< Ingress field. */ 3826 RTE_FLOW_ERROR_TYPE_ATTR_EGRESS, /**< Egress field. */ 3827 RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, /**< Transfer field. */ 3828 RTE_FLOW_ERROR_TYPE_ATTR, /**< Attributes structure. */ 3829 RTE_FLOW_ERROR_TYPE_ITEM_NUM, /**< Pattern length. */ 3830 RTE_FLOW_ERROR_TYPE_ITEM_SPEC, /**< Item specification. */ 3831 RTE_FLOW_ERROR_TYPE_ITEM_LAST, /**< Item specification range. */ 3832 RTE_FLOW_ERROR_TYPE_ITEM_MASK, /**< Item specification mask. */ 3833 RTE_FLOW_ERROR_TYPE_ITEM, /**< Specific pattern item. */ 3834 RTE_FLOW_ERROR_TYPE_ACTION_NUM, /**< Number of actions. */ 3835 RTE_FLOW_ERROR_TYPE_ACTION_CONF, /**< Action configuration. */ 3836 RTE_FLOW_ERROR_TYPE_ACTION, /**< Specific action. */ 3837 RTE_FLOW_ERROR_TYPE_STATE, /**< Current device state. */ 3838 }; 3839 3840 /** 3841 * Verbose error structure definition. 3842 * 3843 * This object is normally allocated by applications and set by PMDs, the 3844 * message points to a constant string which does not need to be freed by 3845 * the application, however its pointer can be considered valid only as long 3846 * as its associated DPDK port remains configured. Closing the underlying 3847 * device or unloading the PMD invalidates it. 3848 * 3849 * Both cause and message may be NULL regardless of the error type. 3850 */ 3851 struct rte_flow_error { 3852 enum rte_flow_error_type type; /**< Cause field and error types. */ 3853 const void *cause; /**< Object responsible for the error. */ 3854 const char *message; /**< Human-readable error message. */ 3855 }; 3856 3857 /** 3858 * Complete flow rule description. 3859 * 3860 * This object type is used when converting a flow rule description. 3861 * 3862 * @see RTE_FLOW_CONV_OP_RULE 3863 * @see rte_flow_conv() 3864 */ 3865 RTE_STD_C11 3866 struct rte_flow_conv_rule { 3867 union { 3868 const struct rte_flow_attr *attr_ro; /**< RO attributes. */ 3869 struct rte_flow_attr *attr; /**< Attributes. */ 3870 }; 3871 union { 3872 const struct rte_flow_item *pattern_ro; /**< RO pattern. */ 3873 struct rte_flow_item *pattern; /**< Pattern items. */ 3874 }; 3875 union { 3876 const struct rte_flow_action *actions_ro; /**< RO actions. */ 3877 struct rte_flow_action *actions; /**< List of actions. */ 3878 }; 3879 }; 3880 3881 /** 3882 * Conversion operations for flow API objects. 3883 * 3884 * @see rte_flow_conv() 3885 */ 3886 enum rte_flow_conv_op { 3887 /** 3888 * No operation to perform. 3889 * 3890 * rte_flow_conv() simply returns 0. 3891 */ 3892 RTE_FLOW_CONV_OP_NONE, 3893 3894 /** 3895 * Convert attributes structure. 3896 * 3897 * This is a basic copy of an attributes structure. 3898 * 3899 * - @p src type: 3900 * @code const struct rte_flow_attr * @endcode 3901 * - @p dst type: 3902 * @code struct rte_flow_attr * @endcode 3903 */ 3904 RTE_FLOW_CONV_OP_ATTR, 3905 3906 /** 3907 * Convert a single item. 3908 * 3909 * Duplicates @p spec, @p last and @p mask but not outside objects. 3910 * 3911 * - @p src type: 3912 * @code const struct rte_flow_item * @endcode 3913 * - @p dst type: 3914 * @code struct rte_flow_item * @endcode 3915 */ 3916 RTE_FLOW_CONV_OP_ITEM, 3917 3918 /** 3919 * Convert a single action. 3920 * 3921 * Duplicates @p conf but not outside objects. 3922 * 3923 * - @p src type: 3924 * @code const struct rte_flow_action * @endcode 3925 * - @p dst type: 3926 * @code struct rte_flow_action * @endcode 3927 */ 3928 RTE_FLOW_CONV_OP_ACTION, 3929 3930 /** 3931 * Convert an entire pattern. 3932 * 3933 * Duplicates all pattern items at once with the same constraints as 3934 * RTE_FLOW_CONV_OP_ITEM. 3935 * 3936 * - @p src type: 3937 * @code const struct rte_flow_item * @endcode 3938 * - @p dst type: 3939 * @code struct rte_flow_item * @endcode 3940 */ 3941 RTE_FLOW_CONV_OP_PATTERN, 3942 3943 /** 3944 * Convert a list of actions. 3945 * 3946 * Duplicates the entire list of actions at once with the same 3947 * constraints as RTE_FLOW_CONV_OP_ACTION. 3948 * 3949 * - @p src type: 3950 * @code const struct rte_flow_action * @endcode 3951 * - @p dst type: 3952 * @code struct rte_flow_action * @endcode 3953 */ 3954 RTE_FLOW_CONV_OP_ACTIONS, 3955 3956 /** 3957 * Convert a complete flow rule description. 3958 * 3959 * Comprises attributes, pattern and actions together at once with 3960 * the usual constraints. 3961 * 3962 * - @p src type: 3963 * @code const struct rte_flow_conv_rule * @endcode 3964 * - @p dst type: 3965 * @code struct rte_flow_conv_rule * @endcode 3966 */ 3967 RTE_FLOW_CONV_OP_RULE, 3968 3969 /** 3970 * Convert item type to its name string. 3971 * 3972 * Writes a NUL-terminated string to @p dst. Like snprintf(), the 3973 * returned value excludes the terminator which is always written 3974 * nonetheless. 3975 * 3976 * - @p src type: 3977 * @code (const void *)enum rte_flow_item_type @endcode 3978 * - @p dst type: 3979 * @code char * @endcode 3980 **/ 3981 RTE_FLOW_CONV_OP_ITEM_NAME, 3982 3983 /** 3984 * Convert action type to its name string. 3985 * 3986 * Writes a NUL-terminated string to @p dst. Like snprintf(), the 3987 * returned value excludes the terminator which is always written 3988 * nonetheless. 3989 * 3990 * - @p src type: 3991 * @code (const void *)enum rte_flow_action_type @endcode 3992 * - @p dst type: 3993 * @code char * @endcode 3994 **/ 3995 RTE_FLOW_CONV_OP_ACTION_NAME, 3996 3997 /** 3998 * Convert item type to pointer to item name. 3999 * 4000 * Retrieves item name pointer from its type. The string itself is 4001 * not copied; instead, a unique pointer to an internal static 4002 * constant storage is written to @p dst. 4003 * 4004 * - @p src type: 4005 * @code (const void *)enum rte_flow_item_type @endcode 4006 * - @p dst type: 4007 * @code const char ** @endcode 4008 */ 4009 RTE_FLOW_CONV_OP_ITEM_NAME_PTR, 4010 4011 /** 4012 * Convert action type to pointer to action name. 4013 * 4014 * Retrieves action name pointer from its type. The string itself is 4015 * not copied; instead, a unique pointer to an internal static 4016 * constant storage is written to @p dst. 4017 * 4018 * - @p src type: 4019 * @code (const void *)enum rte_flow_action_type @endcode 4020 * - @p dst type: 4021 * @code const char ** @endcode 4022 */ 4023 RTE_FLOW_CONV_OP_ACTION_NAME_PTR, 4024 }; 4025 4026 /** 4027 * @warning 4028 * @b EXPERIMENTAL: this API may change without prior notice. 4029 * 4030 * Dump hardware internal representation information of 4031 * rte flow to file. 4032 * 4033 * @param[in] port_id 4034 * The port identifier of the Ethernet device. 4035 * @param[in] flow 4036 * The pointer of flow rule to dump. Dump all rules if NULL. 4037 * @param[in] file 4038 * A pointer to a file for output. 4039 * @param[out] error 4040 * Perform verbose error reporting if not NULL. PMDs initialize this 4041 * structure in case of error only. 4042 * @return 4043 * 0 on success, a negative value otherwise. 4044 */ 4045 __rte_experimental 4046 int 4047 rte_flow_dev_dump(uint16_t port_id, struct rte_flow *flow, 4048 FILE *file, struct rte_flow_error *error); 4049 4050 /** 4051 * Check if mbuf dynamic field for metadata is registered. 4052 * 4053 * @return 4054 * True if registered, false otherwise. 4055 */ 4056 __rte_experimental 4057 static inline int 4058 rte_flow_dynf_metadata_avail(void) 4059 { 4060 return !!rte_flow_dynf_metadata_mask; 4061 } 4062 4063 /** 4064 * Register mbuf dynamic field and flag for metadata. 4065 * 4066 * This function must be called prior to use SET_META action in order to 4067 * register the dynamic mbuf field. Otherwise, the data cannot be delivered to 4068 * application. 4069 * 4070 * @return 4071 * 0 on success, a negative errno value otherwise and rte_errno is set. 4072 */ 4073 __rte_experimental 4074 int 4075 rte_flow_dynf_metadata_register(void); 4076 4077 /** 4078 * Check whether a flow rule can be created on a given port. 4079 * 4080 * The flow rule is validated for correctness and whether it could be accepted 4081 * by the device given sufficient resources. The rule is checked against the 4082 * current device mode and queue configuration. The flow rule may also 4083 * optionally be validated against existing flow rules and device resources. 4084 * This function has no effect on the target device. 4085 * 4086 * The returned value is guaranteed to remain valid only as long as no 4087 * successful calls to rte_flow_create() or rte_flow_destroy() are made in 4088 * the meantime and no device parameter affecting flow rules in any way are 4089 * modified, due to possible collisions or resource limitations (although in 4090 * such cases EINVAL should not be returned). 4091 * 4092 * @param port_id 4093 * Port identifier of Ethernet device. 4094 * @param[in] attr 4095 * Flow rule attributes. 4096 * @param[in] pattern 4097 * Pattern specification (list terminated by the END pattern item). 4098 * @param[in] actions 4099 * Associated actions (list terminated by the END action). 4100 * @param[out] error 4101 * Perform verbose error reporting if not NULL. PMDs initialize this 4102 * structure in case of error only. 4103 * 4104 * @return 4105 * 0 if flow rule is valid and can be created. A negative errno value 4106 * otherwise (rte_errno is also set), the following errors are defined: 4107 * 4108 * -ENOSYS: underlying device does not support this functionality. 4109 * 4110 * -EIO: underlying device is removed. 4111 * 4112 * -EINVAL: unknown or invalid rule specification. 4113 * 4114 * -ENOTSUP: valid but unsupported rule specification (e.g. partial 4115 * bit-masks are unsupported). 4116 * 4117 * -EEXIST: collision with an existing rule. Only returned if device 4118 * supports flow rule collision checking and there was a flow rule 4119 * collision. Not receiving this return code is no guarantee that creating 4120 * the rule will not fail due to a collision. 4121 * 4122 * -ENOMEM: not enough memory to execute the function, or if the device 4123 * supports resource validation, resource limitation on the device. 4124 * 4125 * -EBUSY: action cannot be performed due to busy device resources, may 4126 * succeed if the affected queues or even the entire port are in a stopped 4127 * state (see rte_eth_dev_rx_queue_stop() and rte_eth_dev_stop()). 4128 */ 4129 int 4130 rte_flow_validate(uint16_t port_id, 4131 const struct rte_flow_attr *attr, 4132 const struct rte_flow_item pattern[], 4133 const struct rte_flow_action actions[], 4134 struct rte_flow_error *error); 4135 4136 /** 4137 * Create a flow rule on a given port. 4138 * 4139 * @param port_id 4140 * Port identifier of Ethernet device. 4141 * @param[in] attr 4142 * Flow rule attributes. 4143 * @param[in] pattern 4144 * Pattern specification (list terminated by the END pattern item). 4145 * @param[in] actions 4146 * Associated actions (list terminated by the END action). 4147 * @param[out] error 4148 * Perform verbose error reporting if not NULL. PMDs initialize this 4149 * structure in case of error only. 4150 * 4151 * @return 4152 * A valid handle in case of success, NULL otherwise and rte_errno is set 4153 * to the positive version of one of the error codes defined for 4154 * rte_flow_validate(). 4155 */ 4156 struct rte_flow * 4157 rte_flow_create(uint16_t port_id, 4158 const struct rte_flow_attr *attr, 4159 const struct rte_flow_item pattern[], 4160 const struct rte_flow_action actions[], 4161 struct rte_flow_error *error); 4162 4163 /** 4164 * Destroy a flow rule on a given port. 4165 * 4166 * Failure to destroy a flow rule handle may occur when other flow rules 4167 * depend on it, and destroying it would result in an inconsistent state. 4168 * 4169 * This function is only guaranteed to succeed if handles are destroyed in 4170 * reverse order of their creation. 4171 * 4172 * @param port_id 4173 * Port identifier of Ethernet device. 4174 * @param flow 4175 * Flow rule handle to destroy. 4176 * @param[out] error 4177 * Perform verbose error reporting if not NULL. PMDs initialize this 4178 * structure in case of error only. 4179 * 4180 * @return 4181 * 0 on success, a negative errno value otherwise and rte_errno is set. 4182 */ 4183 int 4184 rte_flow_destroy(uint16_t port_id, 4185 struct rte_flow *flow, 4186 struct rte_flow_error *error); 4187 4188 /** 4189 * Destroy all flow rules associated with a port. 4190 * 4191 * In the unlikely event of failure, handles are still considered destroyed 4192 * and no longer valid but the port must be assumed to be in an inconsistent 4193 * state. 4194 * 4195 * @param port_id 4196 * Port identifier of Ethernet device. 4197 * @param[out] error 4198 * Perform verbose error reporting if not NULL. PMDs initialize this 4199 * structure in case of error only. 4200 * 4201 * @return 4202 * 0 on success, a negative errno value otherwise and rte_errno is set. 4203 */ 4204 int 4205 rte_flow_flush(uint16_t port_id, 4206 struct rte_flow_error *error); 4207 4208 /** 4209 * Query an existing flow rule. 4210 * 4211 * This function allows retrieving flow-specific data such as counters. 4212 * Data is gathered by special actions which must be present in the flow 4213 * rule definition. 4214 * 4215 * \see RTE_FLOW_ACTION_TYPE_COUNT 4216 * 4217 * @param port_id 4218 * Port identifier of Ethernet device. 4219 * @param flow 4220 * Flow rule handle to query. 4221 * @param action 4222 * Action definition as defined in original flow rule. 4223 * @param[in, out] data 4224 * Pointer to storage for the associated query data type. 4225 * @param[out] error 4226 * Perform verbose error reporting if not NULL. PMDs initialize this 4227 * structure in case of error only. 4228 * 4229 * @return 4230 * 0 on success, a negative errno value otherwise and rte_errno is set. 4231 */ 4232 int 4233 rte_flow_query(uint16_t port_id, 4234 struct rte_flow *flow, 4235 const struct rte_flow_action *action, 4236 void *data, 4237 struct rte_flow_error *error); 4238 4239 /** 4240 * Restrict ingress traffic to the defined flow rules. 4241 * 4242 * Isolated mode guarantees that all ingress traffic comes from defined flow 4243 * rules only (current and future). 4244 * When enabled with a bifurcated driver, 4245 * non-matched packets are routed to the kernel driver interface. 4246 * When disabled (the default), 4247 * there may be some default rules routing traffic to the DPDK port. 4248 * 4249 * Besides making ingress more deterministic, it allows PMDs to safely reuse 4250 * resources otherwise assigned to handle the remaining traffic, such as 4251 * global RSS configuration settings, VLAN filters, MAC address entries, 4252 * legacy filter API rules and so on in order to expand the set of possible 4253 * flow rule types. 4254 * 4255 * Calling this function as soon as possible after device initialization, 4256 * ideally before the first call to rte_eth_dev_configure(), is recommended 4257 * to avoid possible failures due to conflicting settings. 4258 * 4259 * Once effective, leaving isolated mode may not be possible depending on 4260 * PMD implementation. 4261 * 4262 * Additionally, the following functionality has no effect on the underlying 4263 * port and may return errors such as ENOTSUP ("not supported"): 4264 * 4265 * - Toggling promiscuous mode. 4266 * - Toggling allmulticast mode. 4267 * - Configuring MAC addresses. 4268 * - Configuring multicast addresses. 4269 * - Configuring VLAN filters. 4270 * - Configuring Rx filters through the legacy API (e.g. FDIR). 4271 * - Configuring global RSS settings. 4272 * 4273 * @param port_id 4274 * Port identifier of Ethernet device. 4275 * @param set 4276 * Nonzero to enter isolated mode, attempt to leave it otherwise. 4277 * @param[out] error 4278 * Perform verbose error reporting if not NULL. PMDs initialize this 4279 * structure in case of error only. 4280 * 4281 * @return 4282 * 0 on success, a negative errno value otherwise and rte_errno is set. 4283 */ 4284 int 4285 rte_flow_isolate(uint16_t port_id, int set, struct rte_flow_error *error); 4286 4287 /** 4288 * Initialize flow error structure. 4289 * 4290 * @param[out] error 4291 * Pointer to flow error structure (may be NULL). 4292 * @param code 4293 * Related error code (rte_errno). 4294 * @param type 4295 * Cause field and error types. 4296 * @param cause 4297 * Object responsible for the error. 4298 * @param message 4299 * Human-readable error message. 4300 * 4301 * @return 4302 * Negative error code (errno value) and rte_errno is set. 4303 */ 4304 int 4305 rte_flow_error_set(struct rte_flow_error *error, 4306 int code, 4307 enum rte_flow_error_type type, 4308 const void *cause, 4309 const char *message); 4310 4311 /** 4312 * @deprecated 4313 * @see rte_flow_copy() 4314 */ 4315 struct rte_flow_desc { 4316 size_t size; /**< Allocated space including data[]. */ 4317 struct rte_flow_attr attr; /**< Attributes. */ 4318 struct rte_flow_item *items; /**< Items. */ 4319 struct rte_flow_action *actions; /**< Actions. */ 4320 uint8_t data[]; /**< Storage for items/actions. */ 4321 }; 4322 4323 /** 4324 * @deprecated 4325 * Copy an rte_flow rule description. 4326 * 4327 * This interface is kept for compatibility with older applications but is 4328 * implemented as a wrapper to rte_flow_conv(). It is deprecated due to its 4329 * lack of flexibility and reliance on a type unusable with C++ programs 4330 * (struct rte_flow_desc). 4331 * 4332 * @param[in] fd 4333 * Flow rule description. 4334 * @param[in] len 4335 * Total size of allocated data for the flow description. 4336 * @param[in] attr 4337 * Flow rule attributes. 4338 * @param[in] items 4339 * Pattern specification (list terminated by the END pattern item). 4340 * @param[in] actions 4341 * Associated actions (list terminated by the END action). 4342 * 4343 * @return 4344 * If len is greater or equal to the size of the flow, the total size of the 4345 * flow description and its data. 4346 * If len is lower than the size of the flow, the number of bytes that would 4347 * have been written to desc had it been sufficient. Nothing is written. 4348 */ 4349 __rte_deprecated 4350 size_t 4351 rte_flow_copy(struct rte_flow_desc *fd, size_t len, 4352 const struct rte_flow_attr *attr, 4353 const struct rte_flow_item *items, 4354 const struct rte_flow_action *actions); 4355 4356 /** 4357 * Flow object conversion helper. 4358 * 4359 * This function performs conversion of various flow API objects to a 4360 * pre-allocated destination buffer. See enum rte_flow_conv_op for possible 4361 * operations and details about each of them. 4362 * 4363 * Since destination buffer must be large enough, it works in a manner 4364 * reminiscent of snprintf(): 4365 * 4366 * - If @p size is 0, @p dst may be a NULL pointer, otherwise @p dst must be 4367 * non-NULL. 4368 * - If positive, the returned value represents the number of bytes needed 4369 * to store the conversion of @p src to @p dst according to @p op 4370 * regardless of the @p size parameter. 4371 * - Since no more than @p size bytes can be written to @p dst, output is 4372 * truncated and may be inconsistent when the returned value is larger 4373 * than that. 4374 * - In case of conversion error, a negative error code is returned and 4375 * @p dst contents are unspecified. 4376 * 4377 * @param op 4378 * Operation to perform, related to the object type of @p dst. 4379 * @param[out] dst 4380 * Destination buffer address. Must be suitably aligned by the caller. 4381 * @param size 4382 * Destination buffer size in bytes. 4383 * @param[in] src 4384 * Source object to copy. Depending on @p op, its type may differ from 4385 * that of @p dst. 4386 * @param[out] error 4387 * Perform verbose error reporting if not NULL. Initialized in case of 4388 * error only. 4389 * 4390 * @return 4391 * The number of bytes required to convert @p src to @p dst on success, a 4392 * negative errno value otherwise and rte_errno is set. 4393 * 4394 * @see rte_flow_conv_op 4395 */ 4396 __rte_experimental 4397 int 4398 rte_flow_conv(enum rte_flow_conv_op op, 4399 void *dst, 4400 size_t size, 4401 const void *src, 4402 struct rte_flow_error *error); 4403 4404 /** 4405 * Get aged-out flows of a given port. 4406 * 4407 * RTE_ETH_EVENT_FLOW_AGED event will be triggered when at least one new aged 4408 * out flow was detected after the last call to rte_flow_get_aged_flows. 4409 * This function can be called to get the aged flows asynchronously from the 4410 * event callback or synchronously regardless the event. 4411 * This is not safe to call rte_flow_get_aged_flows function with other flow 4412 * functions from multiple threads simultaneously. 4413 * 4414 * @param port_id 4415 * Port identifier of Ethernet device. 4416 * @param[in, out] contexts 4417 * The address of an array of pointers to the aged-out flows contexts. 4418 * @param[in] nb_contexts 4419 * The length of context array pointers. 4420 * @param[out] error 4421 * Perform verbose error reporting if not NULL. Initialized in case of 4422 * error only. 4423 * 4424 * @return 4425 * if nb_contexts is 0, return the amount of all aged contexts. 4426 * if nb_contexts is not 0 , return the amount of aged flows reported 4427 * in the context array, otherwise negative errno value. 4428 * 4429 * @see rte_flow_action_age 4430 * @see RTE_ETH_EVENT_FLOW_AGED 4431 */ 4432 __rte_experimental 4433 int 4434 rte_flow_get_aged_flows(uint16_t port_id, void **contexts, 4435 uint32_t nb_contexts, struct rte_flow_error *error); 4436 4437 /** 4438 * @warning 4439 * @b EXPERIMENTAL: this API may change without prior notice. 4440 * 4441 * Get aged-out flows of a given port on the given flow queue. 4442 * 4443 * If application configure port attribute with RTE_FLOW_PORT_FLAG_STRICT_QUEUE, 4444 * there is no RTE_ETH_EVENT_FLOW_AGED event and this function must be called to 4445 * get the aged flows synchronously. 4446 * 4447 * If application configure port attribute without 4448 * RTE_FLOW_PORT_FLAG_STRICT_QUEUE, RTE_ETH_EVENT_FLOW_AGED event will be 4449 * triggered at least one new aged out flow was detected on any flow queue after 4450 * the last call to rte_flow_get_q_aged_flows. 4451 * In addition, the @p queue_id will be ignored. 4452 * This function can be called to get the aged flows asynchronously from the 4453 * event callback or synchronously regardless the event. 4454 * 4455 * @param[in] port_id 4456 * Port identifier of Ethernet device. 4457 * @param[in] queue_id 4458 * Flow queue to query. Ignored when RTE_FLOW_PORT_FLAG_STRICT_QUEUE not set. 4459 * @param[in, out] contexts 4460 * The address of an array of pointers to the aged-out flows contexts. 4461 * @param[in] nb_contexts 4462 * The length of context array pointers. 4463 * @param[out] error 4464 * Perform verbose error reporting if not NULL. Initialized in case of 4465 * error only. 4466 * 4467 * @return 4468 * if nb_contexts is 0, return the amount of all aged contexts. 4469 * if nb_contexts is not 0 , return the amount of aged flows reported 4470 * in the context array, otherwise negative errno value. 4471 * 4472 * @see rte_flow_action_age 4473 * @see RTE_ETH_EVENT_FLOW_AGED 4474 * @see rte_flow_port_flag 4475 */ 4476 __rte_experimental 4477 int 4478 rte_flow_get_q_aged_flows(uint16_t port_id, uint32_t queue_id, void **contexts, 4479 uint32_t nb_contexts, struct rte_flow_error *error); 4480 4481 /** 4482 * Specify indirect action object configuration 4483 */ 4484 struct rte_flow_indir_action_conf { 4485 /** 4486 * Flow direction for the indirect action configuration. 4487 * 4488 * Action should be valid at least for one flow direction, 4489 * otherwise it is invalid for both ingress and egress rules. 4490 */ 4491 /** Action valid for rules applied to ingress traffic. */ 4492 uint32_t ingress:1; 4493 /** Action valid for rules applied to egress traffic. */ 4494 uint32_t egress:1; 4495 /** 4496 * When set to 1, indicates that the action is valid for 4497 * transfer traffic; otherwise, for non-transfer traffic. 4498 */ 4499 uint32_t transfer:1; 4500 }; 4501 4502 /** 4503 * @warning 4504 * @b EXPERIMENTAL: this API may change without prior notice. 4505 * 4506 * Create an indirect action object that can be used in flow rules 4507 * via its handle. 4508 * The created object handle has single state and configuration 4509 * across all the flow rules using it. 4510 * 4511 * @param[in] port_id 4512 * The port identifier of the Ethernet device. 4513 * @param[in] conf 4514 * Action configuration for the indirect action object creation. 4515 * @param[in] action 4516 * Specific configuration of the indirect action object. 4517 * @param[out] error 4518 * Perform verbose error reporting if not NULL. PMDs initialize this 4519 * structure in case of error only. 4520 * @return 4521 * A valid handle in case of success, NULL otherwise and rte_errno is set 4522 * to one of the error codes defined: 4523 * - (ENODEV) if *port_id* invalid. 4524 * - (ENOSYS) if underlying device does not support this functionality. 4525 * - (EIO) if underlying device is removed. 4526 * - (EINVAL) if *action* invalid. 4527 * - (ENOTSUP) if *action* valid but unsupported. 4528 */ 4529 __rte_experimental 4530 struct rte_flow_action_handle * 4531 rte_flow_action_handle_create(uint16_t port_id, 4532 const struct rte_flow_indir_action_conf *conf, 4533 const struct rte_flow_action *action, 4534 struct rte_flow_error *error); 4535 4536 /** 4537 * @warning 4538 * @b EXPERIMENTAL: this API may change without prior notice. 4539 * 4540 * Destroy indirect action by handle. 4541 * 4542 * @param[in] port_id 4543 * The port identifier of the Ethernet device. 4544 * @param[in] handle 4545 * Handle for the indirect action object to be destroyed. 4546 * @param[out] error 4547 * Perform verbose error reporting if not NULL. PMDs initialize this 4548 * structure in case of error only. 4549 * @return 4550 * - (0) if success. 4551 * - (-ENODEV) if *port_id* invalid. 4552 * - (-ENOSYS) if underlying device does not support this functionality. 4553 * - (-EIO) if underlying device is removed. 4554 * - (-ENOENT) if action pointed by *action* handle was not found. 4555 * - (-EBUSY) if action pointed by *action* handle still used by some rules 4556 * rte_errno is also set. 4557 */ 4558 __rte_experimental 4559 int 4560 rte_flow_action_handle_destroy(uint16_t port_id, 4561 struct rte_flow_action_handle *handle, 4562 struct rte_flow_error *error); 4563 4564 /** 4565 * @warning 4566 * @b EXPERIMENTAL: this API may change without prior notice. 4567 * 4568 * Update in-place the action configuration and / or state pointed 4569 * by action *handle* with the configuration provided as *update* argument. 4570 * The update of the action configuration effects all flow rules reusing 4571 * the action via *handle*. 4572 * The update general pointer provides the ability of partial updating. 4573 * 4574 * @param[in] port_id 4575 * The port identifier of the Ethernet device. 4576 * @param[in] handle 4577 * Handle for the indirect action object to be updated. 4578 * @param[in] update 4579 * Update profile specification used to modify the action pointed by handle. 4580 * *update* could be with the same type of the immediate action corresponding 4581 * to the *handle* argument when creating, or a wrapper structure includes 4582 * action configuration to be updated and bit fields to indicate the member 4583 * of fields inside the action to update. 4584 * @param[out] error 4585 * Perform verbose error reporting if not NULL. PMDs initialize this 4586 * structure in case of error only. 4587 * @return 4588 * - (0) if success. 4589 * - (-ENODEV) if *port_id* invalid. 4590 * - (-ENOSYS) if underlying device does not support this functionality. 4591 * - (-EIO) if underlying device is removed. 4592 * - (-EINVAL) if *update* invalid. 4593 * - (-ENOTSUP) if *update* valid but unsupported. 4594 * - (-ENOENT) if indirect action object pointed by *handle* was not found. 4595 * rte_errno is also set. 4596 */ 4597 __rte_experimental 4598 int 4599 rte_flow_action_handle_update(uint16_t port_id, 4600 struct rte_flow_action_handle *handle, 4601 const void *update, 4602 struct rte_flow_error *error); 4603 4604 /** 4605 * @warning 4606 * @b EXPERIMENTAL: this API may change without prior notice. 4607 * 4608 * Query the direct action by corresponding indirect action object handle. 4609 * 4610 * Retrieve action-specific data such as counters. 4611 * Data is gathered by special action which may be present/referenced in 4612 * more than one flow rule definition. 4613 * 4614 * @see RTE_FLOW_ACTION_TYPE_COUNT 4615 * 4616 * @param port_id 4617 * Port identifier of Ethernet device. 4618 * @param[in] handle 4619 * Handle for the action object to query. 4620 * @param[in, out] data 4621 * Pointer to storage for the associated query data type. 4622 * @param[out] error 4623 * Perform verbose error reporting if not NULL. PMDs initialize this 4624 * structure in case of error only. 4625 * 4626 * @return 4627 * 0 on success, a negative errno value otherwise and rte_errno is set. 4628 */ 4629 __rte_experimental 4630 int 4631 rte_flow_action_handle_query(uint16_t port_id, 4632 const struct rte_flow_action_handle *handle, 4633 void *data, struct rte_flow_error *error); 4634 4635 /* Tunnel has a type and the key information. */ 4636 struct rte_flow_tunnel { 4637 /** 4638 * Tunnel type, for example RTE_FLOW_ITEM_TYPE_VXLAN, 4639 * RTE_FLOW_ITEM_TYPE_NVGRE etc. 4640 */ 4641 enum rte_flow_item_type type; 4642 uint64_t tun_id; /**< Tunnel identification. */ 4643 4644 RTE_STD_C11 4645 union { 4646 struct { 4647 rte_be32_t src_addr; /**< IPv4 source address. */ 4648 rte_be32_t dst_addr; /**< IPv4 destination address. */ 4649 } ipv4; 4650 struct { 4651 uint8_t src_addr[16]; /**< IPv6 source address. */ 4652 uint8_t dst_addr[16]; /**< IPv6 destination address. */ 4653 } ipv6; 4654 }; 4655 rte_be16_t tp_src; /**< Tunnel port source. */ 4656 rte_be16_t tp_dst; /**< Tunnel port destination. */ 4657 uint16_t tun_flags; /**< Tunnel flags. */ 4658 4659 bool is_ipv6; /**< True for valid IPv6 fields. Otherwise IPv4. */ 4660 4661 /** 4662 * the following members are required to restore packet 4663 * after miss 4664 */ 4665 uint8_t tos; /**< TOS for IPv4, TC for IPv6. */ 4666 uint8_t ttl; /**< TTL for IPv4, HL for IPv6. */ 4667 uint32_t label; /**< Flow Label for IPv6. */ 4668 }; 4669 4670 /** 4671 * Indicate that the packet has a tunnel. 4672 */ 4673 #define RTE_FLOW_RESTORE_INFO_TUNNEL RTE_BIT64(0) 4674 4675 /** 4676 * Indicate that the packet has a non decapsulated tunnel header. 4677 */ 4678 #define RTE_FLOW_RESTORE_INFO_ENCAPSULATED RTE_BIT64(1) 4679 4680 /** 4681 * Indicate that the packet has a group_id. 4682 */ 4683 #define RTE_FLOW_RESTORE_INFO_GROUP_ID RTE_BIT64(2) 4684 4685 /** 4686 * Restore information structure to communicate the current packet processing 4687 * state when some of the processing pipeline is done in hardware and should 4688 * continue in software. 4689 */ 4690 struct rte_flow_restore_info { 4691 /** 4692 * Bitwise flags (RTE_FLOW_RESTORE_INFO_*) to indicate validation of 4693 * other fields in struct rte_flow_restore_info. 4694 */ 4695 uint64_t flags; 4696 uint32_t group_id; /**< Group ID where packed missed */ 4697 struct rte_flow_tunnel tunnel; /**< Tunnel information. */ 4698 }; 4699 4700 /** 4701 * Allocate an array of actions to be used in rte_flow_create, to implement 4702 * tunnel-decap-set for the given tunnel. 4703 * Sample usage: 4704 * actions vxlan_decap / tunnel-decap-set(tunnel properties) / 4705 * jump group 0 / end 4706 * 4707 * @param port_id 4708 * Port identifier of Ethernet device. 4709 * @param[in] tunnel 4710 * Tunnel properties. 4711 * @param[out] actions 4712 * Array of actions to be allocated by the PMD. This array should be 4713 * concatenated with the actions array provided to rte_flow_create. 4714 * @param[out] num_of_actions 4715 * Number of actions allocated. 4716 * @param[out] error 4717 * Perform verbose error reporting if not NULL. PMDs initialize this 4718 * structure in case of error only. 4719 * 4720 * @return 4721 * 0 on success, a negative errno value otherwise and rte_errno is set. 4722 */ 4723 __rte_experimental 4724 int 4725 rte_flow_tunnel_decap_set(uint16_t port_id, 4726 struct rte_flow_tunnel *tunnel, 4727 struct rte_flow_action **actions, 4728 uint32_t *num_of_actions, 4729 struct rte_flow_error *error); 4730 4731 /** 4732 * Allocate an array of items to be used in rte_flow_create, to implement 4733 * tunnel-match for the given tunnel. 4734 * Sample usage: 4735 * pattern tunnel-match(tunnel properties) / outer-header-matches / 4736 * inner-header-matches / end 4737 * 4738 * @param port_id 4739 * Port identifier of Ethernet device. 4740 * @param[in] tunnel 4741 * Tunnel properties. 4742 * @param[out] items 4743 * Array of items to be allocated by the PMD. This array should be 4744 * concatenated with the items array provided to rte_flow_create. 4745 * @param[out] num_of_items 4746 * Number of items allocated. 4747 * @param[out] error 4748 * Perform verbose error reporting if not NULL. PMDs initialize this 4749 * structure in case of error only. 4750 * 4751 * @return 4752 * 0 on success, a negative errno value otherwise and rte_errno is set. 4753 */ 4754 __rte_experimental 4755 int 4756 rte_flow_tunnel_match(uint16_t port_id, 4757 struct rte_flow_tunnel *tunnel, 4758 struct rte_flow_item **items, 4759 uint32_t *num_of_items, 4760 struct rte_flow_error *error); 4761 4762 /** 4763 * Populate the current packet processing state, if exists, for the given mbuf. 4764 * 4765 * One should negotiate tunnel metadata delivery from the NIC to the HW. 4766 * @see rte_eth_rx_metadata_negotiate() 4767 * @see RTE_ETH_RX_METADATA_TUNNEL_ID 4768 * 4769 * @param port_id 4770 * Port identifier of Ethernet device. 4771 * @param[in] m 4772 * Mbuf struct. 4773 * @param[out] info 4774 * Restore information. Upon success contains the HW state. 4775 * @param[out] error 4776 * Perform verbose error reporting if not NULL. PMDs initialize this 4777 * structure in case of error only. 4778 * 4779 * @return 4780 * 0 on success, a negative errno value otherwise and rte_errno is set. 4781 */ 4782 __rte_experimental 4783 int 4784 rte_flow_get_restore_info(uint16_t port_id, 4785 struct rte_mbuf *m, 4786 struct rte_flow_restore_info *info, 4787 struct rte_flow_error *error); 4788 4789 /** 4790 * Release the action array as allocated by rte_flow_tunnel_decap_set. 4791 * 4792 * @param port_id 4793 * Port identifier of Ethernet device. 4794 * @param[in] actions 4795 * Array of actions to be released. 4796 * @param[in] num_of_actions 4797 * Number of elements in actions array. 4798 * @param[out] error 4799 * Perform verbose error reporting if not NULL. PMDs initialize this 4800 * structure in case of error only. 4801 * 4802 * @return 4803 * 0 on success, a negative errno value otherwise and rte_errno is set. 4804 */ 4805 __rte_experimental 4806 int 4807 rte_flow_tunnel_action_decap_release(uint16_t port_id, 4808 struct rte_flow_action *actions, 4809 uint32_t num_of_actions, 4810 struct rte_flow_error *error); 4811 4812 /** 4813 * Release the item array as allocated by rte_flow_tunnel_match. 4814 * 4815 * @param port_id 4816 * Port identifier of Ethernet device. 4817 * @param[in] items 4818 * Array of items to be released. 4819 * @param[in] num_of_items 4820 * Number of elements in item array. 4821 * @param[out] error 4822 * Perform verbose error reporting if not NULL. PMDs initialize this 4823 * structure in case of error only. 4824 * 4825 * @return 4826 * 0 on success, a negative errno value otherwise and rte_errno is set. 4827 */ 4828 __rte_experimental 4829 int 4830 rte_flow_tunnel_item_release(uint16_t port_id, 4831 struct rte_flow_item *items, 4832 uint32_t num_of_items, 4833 struct rte_flow_error *error); 4834 4835 /** 4836 * Get a proxy port to manage "transfer" flows. 4837 * 4838 * Managing "transfer" flows requires that the user communicate them 4839 * via a port which has the privilege to control the embedded switch. 4840 * For some vendors, all ports in a given switching domain have 4841 * this privilege. For other vendors, it's only one port. 4842 * 4843 * This API indicates such a privileged port (a "proxy") 4844 * for a given port in the same switching domain. 4845 * 4846 * @note 4847 * If the PMD serving @p port_id doesn't have the corresponding method 4848 * implemented, the API will return @p port_id via @p proxy_port_id. 4849 * 4850 * @param port_id 4851 * Indicates the port to get a "proxy" for 4852 * @param[out] proxy_port_id 4853 * Indicates the "proxy" port 4854 * @param[out] error 4855 * If not NULL, allows the PMD to provide verbose report in case of error 4856 * 4857 * @return 4858 * 0 on success, a negative error code otherwise 4859 */ 4860 int 4861 rte_flow_pick_transfer_proxy(uint16_t port_id, uint16_t *proxy_port_id, 4862 struct rte_flow_error *error); 4863 4864 /** 4865 * @warning 4866 * @b EXPERIMENTAL: this API may change without prior notice. 4867 * 4868 * Create the flex item with specified configuration over 4869 * the Ethernet device. 4870 * 4871 * @param port_id 4872 * Port identifier of Ethernet device. 4873 * @param[in] conf 4874 * Item configuration. 4875 * @param[out] error 4876 * Perform verbose error reporting if not NULL. PMDs initialize this 4877 * structure in case of error only. 4878 * 4879 * @return 4880 * Non-NULL opaque pointer on success, NULL otherwise and rte_errno is set. 4881 */ 4882 __rte_experimental 4883 struct rte_flow_item_flex_handle * 4884 rte_flow_flex_item_create(uint16_t port_id, 4885 const struct rte_flow_item_flex_conf *conf, 4886 struct rte_flow_error *error); 4887 4888 /** 4889 * Release the flex item on the specified Ethernet device. 4890 * 4891 * @param port_id 4892 * Port identifier of Ethernet device. 4893 * @param[in] handle 4894 * Handle of the item existing on the specified device. 4895 * @param[out] error 4896 * Perform verbose error reporting if not NULL. PMDs initialize this 4897 * structure in case of error only. 4898 * 4899 * @return 4900 * 0 on success, a negative errno value otherwise and rte_errno is set. 4901 */ 4902 __rte_experimental 4903 int 4904 rte_flow_flex_item_release(uint16_t port_id, 4905 const struct rte_flow_item_flex_handle *handle, 4906 struct rte_flow_error *error); 4907 4908 /** 4909 * Indicate all operations for a given flow rule will _strictly_ 4910 * happen on the same queue (create/destroy/query/update). 4911 */ 4912 #define RTE_FLOW_PORT_FLAG_STRICT_QUEUE RTE_BIT32(0) 4913 4914 /** 4915 * @warning 4916 * @b EXPERIMENTAL: this API may change without prior notice. 4917 * 4918 * Information about flow engine resources. 4919 * The zero value means a resource is not supported. 4920 * 4921 */ 4922 struct rte_flow_port_info { 4923 /** 4924 * Maximum number of queues for asynchronous operations. 4925 */ 4926 uint32_t max_nb_queues; 4927 /** 4928 * Maximum number of counters. 4929 * @see RTE_FLOW_ACTION_TYPE_COUNT 4930 */ 4931 uint32_t max_nb_counters; 4932 /** 4933 * Maximum number of aging objects. 4934 * @see RTE_FLOW_ACTION_TYPE_AGE 4935 */ 4936 uint32_t max_nb_aging_objects; 4937 /** 4938 * Maximum number traffic meters. 4939 * @see RTE_FLOW_ACTION_TYPE_METER 4940 */ 4941 uint32_t max_nb_meters; 4942 /** 4943 * Maximum number connection trackings. 4944 * @see RTE_FLOW_ACTION_TYPE_CONNTRACK 4945 */ 4946 uint32_t max_nb_conn_tracks; 4947 /** 4948 * Port supported flags (RTE_FLOW_PORT_FLAG_*). 4949 */ 4950 uint32_t supported_flags; 4951 }; 4952 4953 /** 4954 * @warning 4955 * @b EXPERIMENTAL: this API may change without prior notice. 4956 * 4957 * Information about flow engine asynchronous queues. 4958 * The value only valid if @p port_attr.max_nb_queues is not zero. 4959 * 4960 */ 4961 struct rte_flow_queue_info { 4962 /** 4963 * Maximum number of operations a queue can hold. 4964 */ 4965 uint32_t max_size; 4966 }; 4967 4968 /** 4969 * @warning 4970 * @b EXPERIMENTAL: this API may change without prior notice. 4971 * 4972 * Get information about flow engine resources. 4973 * 4974 * @param port_id 4975 * Port identifier of Ethernet device. 4976 * @param[out] port_info 4977 * A pointer to a structure of type *rte_flow_port_info* 4978 * to be filled with the resources information of the port. 4979 * @param[out] queue_info 4980 * A pointer to a structure of type *rte_flow_queue_info* 4981 * to be filled with the asynchronous queues information. 4982 * @param[out] error 4983 * Perform verbose error reporting if not NULL. 4984 * PMDs initialize this structure in case of error only. 4985 * 4986 * @return 4987 * 0 on success, a negative errno value otherwise and rte_errno is set. 4988 */ 4989 __rte_experimental 4990 int 4991 rte_flow_info_get(uint16_t port_id, 4992 struct rte_flow_port_info *port_info, 4993 struct rte_flow_queue_info *queue_info, 4994 struct rte_flow_error *error); 4995 4996 /** 4997 * Indicate all steering objects should be created on contexts 4998 * of the host port, providing indirect object sharing between 4999 * ports. 5000 */ 5001 #define RTE_FLOW_PORT_FLAG_SHARE_INDIRECT RTE_BIT32(0) 5002 5003 /** 5004 * @warning 5005 * @b EXPERIMENTAL: this API may change without prior notice. 5006 * 5007 * Flow engine resources settings. 5008 * The zero value means on demand resource allocations only. 5009 * 5010 */ 5011 struct rte_flow_port_attr { 5012 /** 5013 * Number of counters to configure. 5014 * @see RTE_FLOW_ACTION_TYPE_COUNT 5015 */ 5016 uint32_t nb_counters; 5017 /** 5018 * Number of aging objects to configure. 5019 * @see RTE_FLOW_ACTION_TYPE_AGE 5020 */ 5021 uint32_t nb_aging_objects; 5022 /** 5023 * Number of traffic meters to configure. 5024 * @see RTE_FLOW_ACTION_TYPE_METER 5025 */ 5026 uint32_t nb_meters; 5027 /** 5028 * Number of connection trackings to configure. 5029 * @see RTE_FLOW_ACTION_TYPE_CONNTRACK 5030 */ 5031 uint32_t nb_conn_tracks; 5032 /** 5033 * Port to base shared objects on. 5034 */ 5035 uint16_t host_port_id; 5036 /** 5037 * Port flags (RTE_FLOW_PORT_FLAG_*). 5038 */ 5039 uint32_t flags; 5040 }; 5041 5042 /** 5043 * @warning 5044 * @b EXPERIMENTAL: this API may change without prior notice. 5045 * 5046 * Flow engine asynchronous queues settings. 5047 * The value means default value picked by PMD. 5048 * 5049 */ 5050 struct rte_flow_queue_attr { 5051 /** 5052 * Number of flow rule operations a queue can hold. 5053 */ 5054 uint32_t size; 5055 }; 5056 5057 /** 5058 * @warning 5059 * @b EXPERIMENTAL: this API may change without prior notice. 5060 * 5061 * Configure the port's flow API engine. 5062 * 5063 * This API can only be invoked before the application 5064 * starts using the rest of the flow library functions. 5065 * 5066 * The API can be invoked multiple times to change the settings. 5067 * The port, however, may reject changes and keep the old config. 5068 * 5069 * Parameters in configuration attributes must not exceed 5070 * numbers of resources returned by the rte_flow_info_get API. 5071 * 5072 * @param port_id 5073 * Port identifier of Ethernet device. 5074 * @param[in] port_attr 5075 * Port configuration attributes. 5076 * @param[in] nb_queue 5077 * Number of flow queues to be configured. 5078 * @param[in] queue_attr 5079 * Array that holds attributes for each flow queue. 5080 * Number of elements is set in @p port_attr.nb_queues. 5081 * @param[out] error 5082 * Perform verbose error reporting if not NULL. 5083 * PMDs initialize this structure in case of error only. 5084 * 5085 * @return 5086 * 0 on success, a negative errno value otherwise and rte_errno is set. 5087 */ 5088 __rte_experimental 5089 int 5090 rte_flow_configure(uint16_t port_id, 5091 const struct rte_flow_port_attr *port_attr, 5092 uint16_t nb_queue, 5093 const struct rte_flow_queue_attr *queue_attr[], 5094 struct rte_flow_error *error); 5095 5096 /** 5097 * Opaque type returned after successful creation of pattern template. 5098 * This handle can be used to manage the created pattern template. 5099 */ 5100 struct rte_flow_pattern_template; 5101 5102 /** 5103 * @warning 5104 * @b EXPERIMENTAL: this API may change without prior notice. 5105 * 5106 * Flow pattern template attributes. 5107 */ 5108 __extension__ 5109 struct rte_flow_pattern_template_attr { 5110 /** 5111 * Relaxed matching policy. 5112 * - If 1, matching is performed only on items with the mask member set 5113 * and matching on protocol layers specified without any masks is skipped. 5114 * - If 0, matching on protocol layers specified without any masks is done 5115 * as well. This is the standard behaviour of Flow API now. 5116 */ 5117 uint32_t relaxed_matching:1; 5118 /** 5119 * Flow direction for the pattern template. 5120 * At least one direction must be specified. 5121 */ 5122 /** Pattern valid for rules applied to ingress traffic. */ 5123 uint32_t ingress:1; 5124 /** Pattern valid for rules applied to egress traffic. */ 5125 uint32_t egress:1; 5126 /** Pattern valid for rules applied to transfer traffic. */ 5127 uint32_t transfer:1; 5128 }; 5129 5130 /** 5131 * @warning 5132 * @b EXPERIMENTAL: this API may change without prior notice. 5133 * 5134 * Create flow pattern template. 5135 * 5136 * The pattern template defines common matching fields without values. 5137 * For example, matching on 5 tuple TCP flow, the template will be 5138 * eth(null) + IPv4(source + dest) + TCP(s_port + d_port), 5139 * while values for each rule will be set during the flow rule creation. 5140 * The number and order of items in the template must be the same 5141 * at the rule creation. 5142 * 5143 * @param port_id 5144 * Port identifier of Ethernet device. 5145 * @param[in] template_attr 5146 * Pattern template attributes. 5147 * @param[in] pattern 5148 * Pattern specification (list terminated by the END pattern item). 5149 * The spec member of an item is not used unless the end member is used. 5150 * @param[out] error 5151 * Perform verbose error reporting if not NULL. 5152 * PMDs initialize this structure in case of error only. 5153 * 5154 * @return 5155 * Handle on success, NULL otherwise and rte_errno is set. 5156 */ 5157 __rte_experimental 5158 struct rte_flow_pattern_template * 5159 rte_flow_pattern_template_create(uint16_t port_id, 5160 const struct rte_flow_pattern_template_attr *template_attr, 5161 const struct rte_flow_item pattern[], 5162 struct rte_flow_error *error); 5163 5164 /** 5165 * @warning 5166 * @b EXPERIMENTAL: this API may change without prior notice. 5167 * 5168 * Destroy flow pattern template. 5169 * 5170 * This function may be called only when 5171 * there are no more tables referencing this template. 5172 * 5173 * @param port_id 5174 * Port identifier of Ethernet device. 5175 * @param[in] pattern_template 5176 * Handle of the template to be destroyed. 5177 * @param[out] error 5178 * Perform verbose error reporting if not NULL. 5179 * PMDs initialize this structure in case of error only. 5180 * 5181 * @return 5182 * 0 on success, a negative errno value otherwise and rte_errno is set. 5183 */ 5184 __rte_experimental 5185 int 5186 rte_flow_pattern_template_destroy(uint16_t port_id, 5187 struct rte_flow_pattern_template *pattern_template, 5188 struct rte_flow_error *error); 5189 5190 /** 5191 * Opaque type returned after successful creation of actions template. 5192 * This handle can be used to manage the created actions template. 5193 */ 5194 struct rte_flow_actions_template; 5195 5196 /** 5197 * @warning 5198 * @b EXPERIMENTAL: this API may change without prior notice. 5199 * 5200 * Flow actions template attributes. 5201 */ 5202 __extension__ 5203 struct rte_flow_actions_template_attr { 5204 /** 5205 * Flow direction for the actions template. 5206 * At least one direction must be specified. 5207 */ 5208 /** Action valid for rules applied to ingress traffic. */ 5209 uint32_t ingress:1; 5210 /** Action valid for rules applied to egress traffic. */ 5211 uint32_t egress:1; 5212 /** Action valid for rules applied to transfer traffic. */ 5213 uint32_t transfer:1; 5214 }; 5215 5216 /** 5217 * @warning 5218 * @b EXPERIMENTAL: this API may change without prior notice. 5219 * 5220 * Create flow actions template. 5221 * 5222 * The actions template holds a list of action types without values. 5223 * For example, the template to change TCP ports is TCP(s_port + d_port), 5224 * while values for each rule will be set during the flow rule creation. 5225 * The number and order of actions in the template must be the same 5226 * at the rule creation. 5227 * 5228 * @param port_id 5229 * Port identifier of Ethernet device. 5230 * @param[in] template_attr 5231 * Template attributes. 5232 * @param[in] actions 5233 * Associated actions (list terminated by the END action). 5234 * The spec member is only used if @p masks spec is non-zero. 5235 * @param[in] masks 5236 * List of actions that marks which of the action's member is constant. 5237 * A mask has the same format as the corresponding action. 5238 * If the action field in @p masks is not 0, 5239 * the corresponding value in an action from @p actions will be the part 5240 * of the template and used in all flow rules. 5241 * The order of actions in @p masks is the same as in @p actions. 5242 * In case of indirect actions present in @p actions, 5243 * the actual action type should be present in @p mask. 5244 * @param[out] error 5245 * Perform verbose error reporting if not NULL. 5246 * PMDs initialize this structure in case of error only. 5247 * 5248 * @return 5249 * Handle on success, NULL otherwise and rte_errno is set. 5250 */ 5251 __rte_experimental 5252 struct rte_flow_actions_template * 5253 rte_flow_actions_template_create(uint16_t port_id, 5254 const struct rte_flow_actions_template_attr *template_attr, 5255 const struct rte_flow_action actions[], 5256 const struct rte_flow_action masks[], 5257 struct rte_flow_error *error); 5258 5259 /** 5260 * @warning 5261 * @b EXPERIMENTAL: this API may change without prior notice. 5262 * 5263 * Destroy flow actions template. 5264 * 5265 * This function may be called only when 5266 * there are no more tables referencing this template. 5267 * 5268 * @param port_id 5269 * Port identifier of Ethernet device. 5270 * @param[in] actions_template 5271 * Handle to the template to be destroyed. 5272 * @param[out] error 5273 * Perform verbose error reporting if not NULL. 5274 * PMDs initialize this structure in case of error only. 5275 * 5276 * @return 5277 * 0 on success, a negative errno value otherwise and rte_errno is set. 5278 */ 5279 __rte_experimental 5280 int 5281 rte_flow_actions_template_destroy(uint16_t port_id, 5282 struct rte_flow_actions_template *actions_template, 5283 struct rte_flow_error *error); 5284 5285 /** 5286 * Opaque type returned after successful creation of a template table. 5287 * This handle can be used to manage the created template table. 5288 */ 5289 struct rte_flow_template_table; 5290 5291 /**@{@name Flags for template table attribute. 5292 * Each bit is an optional hint for table specialization, 5293 * offering a potential optimization at driver layer. 5294 * The driver can ignore the hints silently. 5295 * The hints do not replace any matching criteria. 5296 */ 5297 /** 5298 * Specialize table for transfer flows which come only from wire. 5299 * It allows PMD not to allocate resources for non-wire originated traffic. 5300 * This bit is not a matching criteria, just an optimization hint. 5301 * Flow rules which match non-wire originated traffic will be missed 5302 * if the hint is supported. 5303 */ 5304 #define RTE_FLOW_TABLE_SPECIALIZE_TRANSFER_WIRE_ORIG RTE_BIT32(0) 5305 /** 5306 * Specialize table for transfer flows which come only from vport (e.g. VF, SF). 5307 * It allows PMD not to allocate resources for non-vport originated traffic. 5308 * This bit is not a matching criteria, just an optimization hint. 5309 * Flow rules which match non-vport originated traffic will be missed 5310 * if the hint is supported. 5311 */ 5312 #define RTE_FLOW_TABLE_SPECIALIZE_TRANSFER_VPORT_ORIG RTE_BIT32(1) 5313 /**@}*/ 5314 5315 /** 5316 * @warning 5317 * @b EXPERIMENTAL: this API may change without prior notice. 5318 * 5319 * Template table flow rules insertion type. 5320 */ 5321 enum rte_flow_table_insertion_type { 5322 /** 5323 * Pattern-based insertion. 5324 */ 5325 RTE_FLOW_TABLE_INSERTION_TYPE_PATTERN, 5326 /** 5327 * Index-based insertion. 5328 */ 5329 RTE_FLOW_TABLE_INSERTION_TYPE_INDEX, 5330 }; 5331 5332 /** 5333 * @warning 5334 * @b EXPERIMENTAL: this API may change without prior notice. 5335 * 5336 * Template table hash index calculation function. 5337 */ 5338 enum rte_flow_table_hash_func { 5339 /** 5340 * Default hash calculation. 5341 */ 5342 RTE_FLOW_TABLE_HASH_FUNC_DEFAULT, 5343 /** 5344 * Linear hash calculation. 5345 */ 5346 RTE_FLOW_TABLE_HASH_FUNC_LINEAR, 5347 /** 5348 * 32-bit checksum hash calculation. 5349 */ 5350 RTE_FLOW_TABLE_HASH_FUNC_CRC32, 5351 /** 5352 * 16-bit checksum hash calculation. 5353 */ 5354 RTE_FLOW_TABLE_HASH_FUNC_CRC16, 5355 }; 5356 5357 /** 5358 * @warning 5359 * @b EXPERIMENTAL: this API may change without prior notice. 5360 * 5361 * Table attributes. 5362 */ 5363 struct rte_flow_template_table_attr { 5364 /** 5365 * Flow attributes to be used in each rule generated from this table. 5366 */ 5367 struct rte_flow_attr flow_attr; 5368 /** 5369 * Maximum number of flow rules that this table holds. 5370 */ 5371 uint32_t nb_flows; 5372 /** 5373 * Optional hint flags for driver optimization. 5374 * The effect may vary in the different drivers. 5375 * The functionality must not rely on the hints. 5376 * Value is composed with RTE_FLOW_TABLE_SPECIALIZE_* based on application 5377 * design choices. 5378 * Misused hints may mislead the driver, it may result in an undefined behavior. 5379 */ 5380 uint32_t specialize; 5381 /** 5382 * Insertion type for flow rules. 5383 */ 5384 enum rte_flow_table_insertion_type insertion_type; 5385 /** 5386 * Hash calculation function for the packet matching. 5387 */ 5388 enum rte_flow_table_hash_func hash_func; 5389 }; 5390 5391 /** 5392 * @warning 5393 * @b EXPERIMENTAL: this API may change without prior notice. 5394 * 5395 * Create flow template table. 5396 * 5397 * A template table consists of multiple pattern templates and actions 5398 * templates associated with a single set of rule attributes (group ID, 5399 * priority and traffic direction). 5400 * 5401 * Each rule is free to use any combination of pattern and actions templates 5402 * and specify particular values for items and actions it would like to change. 5403 * 5404 * @param port_id 5405 * Port identifier of Ethernet device. 5406 * @param[in] table_attr 5407 * Template table attributes. 5408 * @param[in] pattern_templates 5409 * Array of pattern templates to be used in this table. 5410 * @param[in] nb_pattern_templates 5411 * The number of pattern templates in the pattern_templates array. 5412 * @param[in] actions_templates 5413 * Array of actions templates to be used in this table. 5414 * @param[in] nb_actions_templates 5415 * The number of actions templates in the actions_templates array. 5416 * @param[out] error 5417 * Perform verbose error reporting if not NULL. 5418 * PMDs initialize this structure in case of error only. 5419 * 5420 * @return 5421 * Handle on success, NULL otherwise and rte_errno is set. 5422 */ 5423 __rte_experimental 5424 struct rte_flow_template_table * 5425 rte_flow_template_table_create(uint16_t port_id, 5426 const struct rte_flow_template_table_attr *table_attr, 5427 struct rte_flow_pattern_template *pattern_templates[], 5428 uint8_t nb_pattern_templates, 5429 struct rte_flow_actions_template *actions_templates[], 5430 uint8_t nb_actions_templates, 5431 struct rte_flow_error *error); 5432 5433 /** 5434 * @warning 5435 * @b EXPERIMENTAL: this API may change without prior notice. 5436 * 5437 * Destroy flow template table. 5438 * 5439 * This function may be called only when 5440 * there are no more flow rules referencing this table. 5441 * 5442 * @param port_id 5443 * Port identifier of Ethernet device. 5444 * @param[in] template_table 5445 * Handle to the table to be destroyed. 5446 * @param[out] error 5447 * Perform verbose error reporting if not NULL. 5448 * PMDs initialize this structure in case of error only. 5449 * 5450 * @return 5451 * 0 on success, a negative errno value otherwise and rte_errno is set. 5452 */ 5453 __rte_experimental 5454 int 5455 rte_flow_template_table_destroy(uint16_t port_id, 5456 struct rte_flow_template_table *template_table, 5457 struct rte_flow_error *error); 5458 5459 /** 5460 * @warning 5461 * @b EXPERIMENTAL: this API may change without prior notice. 5462 * 5463 * Asynchronous operation attributes. 5464 */ 5465 __extension__ 5466 struct rte_flow_op_attr { 5467 /** 5468 * When set, the requested action will not be sent to the HW immediately. 5469 * The application must call the rte_flow_queue_push to actually send it. 5470 */ 5471 uint32_t postpone:1; 5472 }; 5473 5474 /** 5475 * @warning 5476 * @b EXPERIMENTAL: this API may change without prior notice. 5477 * 5478 * Enqueue rule creation operation. 5479 * 5480 * @param port_id 5481 * Port identifier of Ethernet device. 5482 * @param queue_id 5483 * Flow queue used to insert the rule. 5484 * @param[in] op_attr 5485 * Rule creation operation attributes. 5486 * @param[in] template_table 5487 * Template table to select templates from. 5488 * @param[in] pattern 5489 * List of pattern items to be used. 5490 * The list order should match the order in the pattern template. 5491 * The spec is the only relevant member of the item that is being used. 5492 * @param[in] pattern_template_index 5493 * Pattern template index in the table. 5494 * @param[in] actions 5495 * List of actions to be used. 5496 * The list order should match the order in the actions template. 5497 * @param[in] actions_template_index 5498 * Actions template index in the table. 5499 * @param[in] user_data 5500 * The user data that will be returned on the completion events. 5501 * @param[out] error 5502 * Perform verbose error reporting if not NULL. 5503 * PMDs initialize this structure in case of error only. 5504 * 5505 * @return 5506 * Handle on success, NULL otherwise and rte_errno is set. 5507 * The rule handle doesn't mean that the rule has been populated. 5508 * Only completion result indicates that if there was success or failure. 5509 */ 5510 __rte_experimental 5511 struct rte_flow * 5512 rte_flow_async_create(uint16_t port_id, 5513 uint32_t queue_id, 5514 const struct rte_flow_op_attr *op_attr, 5515 struct rte_flow_template_table *template_table, 5516 const struct rte_flow_item pattern[], 5517 uint8_t pattern_template_index, 5518 const struct rte_flow_action actions[], 5519 uint8_t actions_template_index, 5520 void *user_data, 5521 struct rte_flow_error *error); 5522 5523 /** 5524 * @warning 5525 * @b EXPERIMENTAL: this API may change without prior notice. 5526 * 5527 * Enqueue rule creation operation. 5528 * 5529 * @param port_id 5530 * Port identifier of Ethernet device. 5531 * @param queue_id 5532 * Flow queue used to insert the rule. 5533 * @param[in] op_attr 5534 * Rule creation operation attributes. 5535 * @param[in] template_table 5536 * Template table to select templates from. 5537 * @param[in] rule_index 5538 * Rule index in the table. 5539 * @param[in] actions 5540 * List of actions to be used. 5541 * The list order should match the order in the actions template. 5542 * @param[in] actions_template_index 5543 * Actions template index in the table. 5544 * @param[in] user_data 5545 * The user data that will be returned on the completion events. 5546 * @param[out] error 5547 * Perform verbose error reporting if not NULL. 5548 * PMDs initialize this structure in case of error only. 5549 * 5550 * @return 5551 * Handle on success, NULL otherwise and rte_errno is set. 5552 * The rule handle doesn't mean that the rule has been populated. 5553 * Only completion result indicates that if there was success or failure. 5554 */ 5555 __rte_experimental 5556 struct rte_flow * 5557 rte_flow_async_create_by_index(uint16_t port_id, 5558 uint32_t queue_id, 5559 const struct rte_flow_op_attr *op_attr, 5560 struct rte_flow_template_table *template_table, 5561 uint32_t rule_index, 5562 const struct rte_flow_action actions[], 5563 uint8_t actions_template_index, 5564 void *user_data, 5565 struct rte_flow_error *error); 5566 5567 /** 5568 * @warning 5569 * @b EXPERIMENTAL: this API may change without prior notice. 5570 * 5571 * Enqueue rule destruction operation. 5572 * 5573 * This function enqueues a destruction operation on the queue. 5574 * Application should assume that after calling this function 5575 * the rule handle is not valid anymore. 5576 * Completion indicates the full removal of the rule from the HW. 5577 * 5578 * @param port_id 5579 * Port identifier of Ethernet device. 5580 * @param queue_id 5581 * Flow queue which is used to destroy the rule. 5582 * This must match the queue on which the rule was created. 5583 * @param[in] op_attr 5584 * Rule destruction operation attributes. 5585 * @param[in] flow 5586 * Flow handle to be destroyed. 5587 * @param[in] user_data 5588 * The user data that will be returned on the completion events. 5589 * @param[out] error 5590 * Perform verbose error reporting if not NULL. 5591 * PMDs initialize this structure in case of error only. 5592 * 5593 * @return 5594 * 0 on success, a negative errno value otherwise and rte_errno is set. 5595 */ 5596 __rte_experimental 5597 int 5598 rte_flow_async_destroy(uint16_t port_id, 5599 uint32_t queue_id, 5600 const struct rte_flow_op_attr *op_attr, 5601 struct rte_flow *flow, 5602 void *user_data, 5603 struct rte_flow_error *error); 5604 5605 /** 5606 * @warning 5607 * @b EXPERIMENTAL: this API may change without prior notice. 5608 * 5609 * Push all internally stored rules to the HW. 5610 * Postponed rules are rules that were inserted with the postpone flag set. 5611 * Can be used to notify the HW about batch of rules prepared by the SW to 5612 * reduce the number of communications between the HW and SW. 5613 * 5614 * @param port_id 5615 * Port identifier of Ethernet device. 5616 * @param queue_id 5617 * Flow queue to be pushed. 5618 * @param[out] error 5619 * Perform verbose error reporting if not NULL. 5620 * PMDs initialize this structure in case of error only. 5621 * 5622 * @return 5623 * 0 on success, a negative errno value otherwise and rte_errno is set. 5624 */ 5625 __rte_experimental 5626 int 5627 rte_flow_push(uint16_t port_id, 5628 uint32_t queue_id, 5629 struct rte_flow_error *error); 5630 5631 /** 5632 * @warning 5633 * @b EXPERIMENTAL: this API may change without prior notice. 5634 * 5635 * Asynchronous operation status. 5636 */ 5637 enum rte_flow_op_status { 5638 /** 5639 * The operation was completed successfully. 5640 */ 5641 RTE_FLOW_OP_SUCCESS, 5642 /** 5643 * The operation was not completed successfully. 5644 */ 5645 RTE_FLOW_OP_ERROR, 5646 }; 5647 5648 /** 5649 * @warning 5650 * @b EXPERIMENTAL: this API may change without prior notice. 5651 * 5652 * Asynchronous operation result. 5653 */ 5654 __extension__ 5655 struct rte_flow_op_result { 5656 /** 5657 * Returns the status of the operation that this completion signals. 5658 */ 5659 enum rte_flow_op_status status; 5660 /** 5661 * The user data that will be returned on the completion events. 5662 */ 5663 void *user_data; 5664 }; 5665 5666 /** 5667 * @warning 5668 * @b EXPERIMENTAL: this API may change without prior notice. 5669 * 5670 * Pull a rte flow operation. 5671 * The application must invoke this function in order to complete 5672 * the flow rule offloading and to retrieve the flow rule operation status. 5673 * 5674 * @param port_id 5675 * Port identifier of Ethernet device. 5676 * @param queue_id 5677 * Flow queue which is used to pull the operation. 5678 * @param[out] res 5679 * Array of results that will be set. 5680 * @param[in] n_res 5681 * Maximum number of results that can be returned. 5682 * This value is equal to the size of the res array. 5683 * @param[out] error 5684 * Perform verbose error reporting if not NULL. 5685 * PMDs initialize this structure in case of error only. 5686 * 5687 * @return 5688 * Number of results that were pulled, 5689 * a negative errno value otherwise and rte_errno is set. 5690 */ 5691 __rte_experimental 5692 int 5693 rte_flow_pull(uint16_t port_id, 5694 uint32_t queue_id, 5695 struct rte_flow_op_result res[], 5696 uint16_t n_res, 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 creation operation. 5704 * @see rte_flow_action_handle_create 5705 * 5706 * @param[in] port_id 5707 * Port identifier of Ethernet device. 5708 * @param[in] queue_id 5709 * Flow queue which is used to create the rule. 5710 * @param[in] op_attr 5711 * Indirect action creation operation attributes. 5712 * @param[in] indir_action_conf 5713 * Action configuration for the indirect action object creation. 5714 * @param[in] action 5715 * Specific configuration of the indirect action object. 5716 * @param[in] user_data 5717 * The user data that will be returned on the completion events. 5718 * @param[out] error 5719 * Perform verbose error reporting if not NULL. 5720 * PMDs initialize this structure in case of error only. 5721 * 5722 * @return 5723 * A valid handle in case of success, NULL otherwise and rte_errno is set. 5724 */ 5725 __rte_experimental 5726 struct rte_flow_action_handle * 5727 rte_flow_async_action_handle_create(uint16_t port_id, 5728 uint32_t queue_id, 5729 const struct rte_flow_op_attr *op_attr, 5730 const struct rte_flow_indir_action_conf *indir_action_conf, 5731 const struct rte_flow_action *action, 5732 void *user_data, 5733 struct rte_flow_error *error); 5734 5735 /** 5736 * @warning 5737 * @b EXPERIMENTAL: this API may change without prior notice. 5738 * 5739 * Enqueue indirect action destruction operation. 5740 * The destroy queue must be the same 5741 * as the queue on which the action was created. 5742 * 5743 * @param[in] port_id 5744 * Port identifier of Ethernet device. 5745 * @param[in] queue_id 5746 * Flow queue which is used to destroy the rule. 5747 * @param[in] op_attr 5748 * Indirect action destruction operation attributes. 5749 * @param[in] action_handle 5750 * Handle for the indirect action object to be destroyed. 5751 * @param[in] user_data 5752 * The user data that will be returned on the completion events. 5753 * @param[out] error 5754 * Perform verbose error reporting if not NULL. 5755 * PMDs initialize this structure in case of error only. 5756 * 5757 * @return 5758 * 0 on success, a negative errno value otherwise and rte_errno is set. 5759 */ 5760 __rte_experimental 5761 int 5762 rte_flow_async_action_handle_destroy(uint16_t port_id, 5763 uint32_t queue_id, 5764 const struct rte_flow_op_attr *op_attr, 5765 struct rte_flow_action_handle *action_handle, 5766 void *user_data, 5767 struct rte_flow_error *error); 5768 5769 /** 5770 * @warning 5771 * @b EXPERIMENTAL: this API may change without prior notice. 5772 * 5773 * Enqueue indirect action update operation. 5774 * @see rte_flow_action_handle_create 5775 * 5776 * @param[in] port_id 5777 * Port identifier of Ethernet device. 5778 * @param[in] queue_id 5779 * Flow queue which is used to update the rule. 5780 * @param[in] op_attr 5781 * Indirect action update operation attributes. 5782 * @param[in] action_handle 5783 * Handle for the indirect action object to be updated. 5784 * @param[in] update 5785 * Update profile specification used to modify the action pointed by handle. 5786 * *update* could be with the same type of the immediate action corresponding 5787 * to the *handle* argument when creating, or a wrapper structure includes 5788 * action configuration to be updated and bit fields to indicate the member 5789 * of fields inside the action to update. 5790 * @param[in] user_data 5791 * The user data that will be returned on the completion events. 5792 * @param[out] error 5793 * Perform verbose error reporting if not NULL. 5794 * PMDs initialize this structure in case of error only. 5795 * 5796 * @return 5797 * 0 on success, a negative errno value otherwise and rte_errno is set. 5798 */ 5799 __rte_experimental 5800 int 5801 rte_flow_async_action_handle_update(uint16_t port_id, 5802 uint32_t queue_id, 5803 const struct rte_flow_op_attr *op_attr, 5804 struct rte_flow_action_handle *action_handle, 5805 const void *update, 5806 void *user_data, 5807 struct rte_flow_error *error); 5808 5809 /** 5810 * @warning 5811 * @b EXPERIMENTAL: this API may change without prior notice. 5812 * 5813 * Enqueue indirect action query operation. 5814 * 5815 * Retrieve action-specific data such as counters. 5816 * Data is gathered by special action which may be present/referenced in 5817 * more than one flow rule definition. 5818 * Data will be available only when completion event returns. 5819 * 5820 * @see rte_flow_async_action_handle_query 5821 * 5822 * @param port_id 5823 * Port identifier of Ethernet device. 5824 * @param[in] queue_id 5825 * Flow queue which is used to query the action. 5826 * @param[in] op_attr 5827 * Indirect action update operation attributes. 5828 * @param[in] action_handle 5829 * Handle for the action object to query. 5830 * @param[in, out] data 5831 * Pointer to storage for the associated query data type. 5832 * The out data will be available only when completion event returns 5833 * from rte_flow_pull. 5834 * @param[in] user_data 5835 * The user data that will be returned on the completion events. 5836 * @param[out] error 5837 * Perform verbose error reporting if not NULL. PMDs initialize this 5838 * structure in case of error only. 5839 * 5840 * @return 5841 * 0 on success, a negative errno value otherwise and rte_errno is set. 5842 */ 5843 __rte_experimental 5844 int 5845 rte_flow_async_action_handle_query(uint16_t port_id, 5846 uint32_t queue_id, 5847 const struct rte_flow_op_attr *op_attr, 5848 const struct rte_flow_action_handle *action_handle, 5849 void *data, 5850 void *user_data, 5851 struct rte_flow_error *error); 5852 5853 #ifdef __cplusplus 5854 } 5855 #endif 5856 5857 #endif /* RTE_FLOW_H_ */ 5858