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