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