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