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 * 2966 * No associated configuration structure. 2967 */ 2968 RTE_FLOW_ACTION_TYPE_SEND_TO_KERNEL, 2969 2970 /** 2971 * Apply the quota verdict (PASS or BLOCK) to a flow. 2972 * 2973 * @see struct rte_flow_action_quota 2974 * @see struct rte_flow_query_quota 2975 * @see struct rte_flow_update_quota 2976 */ 2977 RTE_FLOW_ACTION_TYPE_QUOTA, 2978 2979 /** 2980 * Skip congestion management configuration. 2981 * 2982 * Using rte_eth_cman_config_set(), the application 2983 * can configure ethdev Rx queue's congestion mechanism. 2984 * This flow action allows to skip the congestion configuration 2985 * applied to the given ethdev Rx queue. 2986 */ 2987 RTE_FLOW_ACTION_TYPE_SKIP_CMAN, 2988 2989 /** 2990 * RTE_FLOW_ACTION_TYPE_IPV6_EXT_PUSH 2991 * 2992 * Push IPv6 extension into IPv6 packet. 2993 * 2994 * @see struct rte_flow_action_ipv6_ext_push. 2995 */ 2996 RTE_FLOW_ACTION_TYPE_IPV6_EXT_PUSH, 2997 2998 /** 2999 * RTE_FLOW_ACTION_TYPE_IPV6_EXT_REMOVE 3000 * 3001 * Remove IPv6 extension from IPv6 packet whose type 3002 * is provided in its configuration buffer. 3003 * 3004 * @see struct rte_flow_action_ipv6_ext_remove. 3005 */ 3006 RTE_FLOW_ACTION_TYPE_IPV6_EXT_REMOVE, 3007 3008 /** 3009 * Action handle to reference flow actions list. 3010 * 3011 * @see struct rte_flow_action_indirect_list 3012 */ 3013 RTE_FLOW_ACTION_TYPE_INDIRECT_LIST, 3014 3015 /** 3016 * Program action. These actions are defined by the program currently 3017 * loaded on the device. For example, these actions are applicable to 3018 * devices that can be programmed through the P4 language. 3019 * 3020 * @see struct rte_flow_action_prog. 3021 */ 3022 RTE_FLOW_ACTION_TYPE_PROG, 3023 }; 3024 3025 /** 3026 * @warning 3027 * @b EXPERIMENTAL: this API may change without prior notice. 3028 * 3029 * QUOTA operational mode. 3030 * 3031 * @see struct rte_flow_action_quota 3032 */ 3033 enum rte_flow_quota_mode { 3034 RTE_FLOW_QUOTA_MODE_PACKET = 1, /**< Count packets. */ 3035 RTE_FLOW_QUOTA_MODE_L2 = 2, /**< Count packet bytes starting from L2. */ 3036 RTE_FLOW_QUOTA_MODE_L3 = 3, /**< Count packet bytes starting from L3. */ 3037 }; 3038 3039 /** 3040 * @warning 3041 * @b EXPERIMENTAL: this API may change without prior notice. 3042 * 3043 * Create QUOTA action. 3044 * 3045 * @see RTE_FLOW_ACTION_TYPE_QUOTA 3046 */ 3047 struct rte_flow_action_quota { 3048 enum rte_flow_quota_mode mode; /**< Quota operational mode. */ 3049 int64_t quota; /**< Quota value. */ 3050 }; 3051 3052 /** 3053 * @warning 3054 * @b EXPERIMENTAL: this API may change without prior notice. 3055 * 3056 * Query indirect QUOTA action. 3057 * 3058 * @see RTE_FLOW_ACTION_TYPE_QUOTA 3059 */ 3060 struct rte_flow_query_quota { 3061 int64_t quota; /**< Quota value. */ 3062 }; 3063 3064 /** 3065 * @warning 3066 * @b EXPERIMENTAL: this API may change without prior notice. 3067 * 3068 * Indirect QUOTA update operations. 3069 * 3070 * @see struct rte_flow_update_quota 3071 */ 3072 enum rte_flow_update_quota_op { 3073 RTE_FLOW_UPDATE_QUOTA_SET, /**< Set new quota value. */ 3074 RTE_FLOW_UPDATE_QUOTA_ADD, /**< Increase quota value. */ 3075 }; 3076 3077 /** 3078 * @warning 3079 * @b EXPERIMENTAL: this API may change without prior notice. 3080 * 3081 * @see RTE_FLOW_ACTION_TYPE_QUOTA 3082 * 3083 * Update indirect QUOTA action. 3084 */ 3085 struct rte_flow_update_quota { 3086 enum rte_flow_update_quota_op op; /**< Update operation. */ 3087 int64_t quota; /**< Quota value. */ 3088 }; 3089 3090 /** 3091 * RTE_FLOW_ACTION_TYPE_MARK 3092 * 3093 * Attaches an integer value to packets and sets RTE_MBUF_F_RX_FDIR and 3094 * RTE_MBUF_F_RX_FDIR_ID mbuf flags. 3095 * 3096 * This value is arbitrary and application-defined. Maximum allowed value 3097 * depends on the underlying implementation. It is returned in the 3098 * hash.fdir.hi mbuf field. 3099 */ 3100 struct rte_flow_action_mark { 3101 uint32_t id; /**< Integer value to return with packets. */ 3102 }; 3103 3104 /** 3105 * @warning 3106 * @b EXPERIMENTAL: this structure may change without prior notice 3107 * 3108 * RTE_FLOW_ACTION_TYPE_JUMP 3109 * 3110 * Redirects packets to a group on the current device. 3111 * 3112 * In a hierarchy of groups, which can be used to represent physical or logical 3113 * flow tables on the device, this action allows the action to be a redirect to 3114 * a group on that device. 3115 */ 3116 struct rte_flow_action_jump { 3117 uint32_t group; 3118 }; 3119 3120 /** 3121 * RTE_FLOW_ACTION_TYPE_QUEUE 3122 * 3123 * Assign packets to a given queue index. 3124 */ 3125 struct rte_flow_action_queue { 3126 uint16_t index; /**< Queue index to use. */ 3127 }; 3128 3129 /** 3130 * @warning 3131 * @b EXPERIMENTAL: this structure may change without prior notice 3132 * 3133 * RTE_FLOW_ACTION_TYPE_AGE 3134 * 3135 * Report flow as aged-out if timeout passed without any matching 3136 * on the flow. RTE_ETH_EVENT_FLOW_AGED event is triggered when a 3137 * port detects new aged-out flows. 3138 * 3139 * The flow context and the flow handle will be reported by the either 3140 * rte_flow_get_aged_flows or rte_flow_get_q_aged_flows APIs. 3141 */ 3142 struct rte_flow_action_age { 3143 uint32_t timeout:24; /**< Time in seconds. */ 3144 uint32_t reserved:8; /**< Reserved, must be zero. */ 3145 /** The user flow context, NULL means the rte_flow pointer. */ 3146 void *context; 3147 }; 3148 3149 /** 3150 * RTE_FLOW_ACTION_TYPE_AGE (query) 3151 * 3152 * Query structure to retrieve the aging status information of a 3153 * shared AGE action, or a flow rule using the AGE action. 3154 */ 3155 struct rte_flow_query_age { 3156 uint32_t reserved:6; /**< Reserved, must be zero. */ 3157 uint32_t aged:1; /**< 1 if aging timeout expired, 0 otherwise. */ 3158 /** sec_since_last_hit value is valid. */ 3159 uint32_t sec_since_last_hit_valid:1; 3160 uint32_t sec_since_last_hit:24; /**< Seconds since last traffic hit. */ 3161 }; 3162 3163 /** 3164 * @warning 3165 * @b EXPERIMENTAL: this structure may change without prior notice 3166 * 3167 * RTE_FLOW_ACTION_TYPE_AGE 3168 * 3169 * Update indirect AGE action attributes: 3170 * - Timeout can be updated including stop/start action: 3171 * +-------------+-------------+------------------------------+ 3172 * | Old Timeout | New Timeout | Updating | 3173 * +=============+=============+==============================+ 3174 * | 0 | positive | Start aging with new value | 3175 * +-------------+-------------+------------------------------+ 3176 * | positive | 0 | Stop aging | 3177 * +-------------+-------------+------------------------------+ 3178 * | positive | positive | Change timeout to new value | 3179 * +-------------+-------------+------------------------------+ 3180 * - sec_since_last_hit can be reset. 3181 */ 3182 struct rte_flow_update_age { 3183 uint32_t reserved:6; /**< Reserved, must be zero. */ 3184 uint32_t timeout_valid:1; /**< The timeout is valid for update. */ 3185 uint32_t timeout:24; /**< Time in seconds. */ 3186 /** Means that aging should assume packet passed the aging. */ 3187 uint32_t touch:1; 3188 }; 3189 3190 /** 3191 * @warning 3192 * @b EXPERIMENTAL: this structure may change without prior notice 3193 * 3194 * RTE_FLOW_ACTION_TYPE_COUNT 3195 * 3196 * Adds a counter action to a matched flow. 3197 * 3198 * If more than one count action is specified in a single flow rule, then each 3199 * action must specify a unique ID. 3200 * 3201 * Counters can be retrieved and reset through ``rte_flow_query()``, see 3202 * ``struct rte_flow_query_count``. 3203 * 3204 * For ports within the same switch domain then the counter ID namespace extends 3205 * to all ports within that switch domain. 3206 */ 3207 struct rte_flow_action_count { 3208 uint32_t id; /**< Counter ID. */ 3209 }; 3210 3211 /** 3212 * RTE_FLOW_ACTION_TYPE_COUNT (query) 3213 * 3214 * Query structure to retrieve and reset flow rule counters. 3215 */ 3216 struct rte_flow_query_count { 3217 uint32_t reset:1; /**< Reset counters after query [in]. */ 3218 uint32_t hits_set:1; /**< hits field is set [out]. */ 3219 uint32_t bytes_set:1; /**< bytes field is set [out]. */ 3220 uint32_t reserved:29; /**< Reserved, must be zero [in, out]. */ 3221 uint64_t hits; /**< Number of hits for this rule [out]. */ 3222 uint64_t bytes; /**< Number of bytes through this rule [out]. */ 3223 }; 3224 3225 /** 3226 * Hash function types. 3227 */ 3228 enum rte_eth_hash_function { 3229 RTE_ETH_HASH_FUNCTION_DEFAULT = 0, 3230 RTE_ETH_HASH_FUNCTION_TOEPLITZ, /**< Toeplitz */ 3231 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR, /**< Simple XOR */ 3232 /** 3233 * Symmetric Toeplitz: src, dst will be replaced by 3234 * xor(src, dst). For the case with src/dst only, 3235 * src or dst address will xor with zero pair. 3236 */ 3237 RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ, 3238 /** 3239 * Symmetric Toeplitz: L3 and L4 fields are sorted prior to 3240 * the hash function. 3241 * If src_ip > dst_ip, swap src_ip and dst_ip. 3242 * If src_port > dst_port, swap src_port and dst_port. 3243 */ 3244 RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ_SORT, 3245 RTE_ETH_HASH_FUNCTION_MAX, 3246 }; 3247 3248 /** 3249 * RTE_FLOW_ACTION_TYPE_RSS 3250 * 3251 * Similar to QUEUE, except RSS is additionally performed on packets to 3252 * spread them among several queues according to the provided parameters. 3253 * 3254 * Unlike global RSS settings used by other DPDK APIs, unsetting the 3255 * @p types field does not disable RSS in a flow rule. Doing so instead 3256 * requests safe unspecified "best-effort" settings from the underlying PMD, 3257 * which depending on the flow rule, may result in anything ranging from 3258 * empty (single queue) to all-inclusive RSS. 3259 * 3260 * Note: RSS hash result is stored in the hash.rss mbuf field which overlaps 3261 * hash.fdir.lo. Since the MARK action sets the hash.fdir.hi field only, 3262 * both can be requested simultaneously. 3263 */ 3264 struct rte_flow_action_rss { 3265 enum rte_eth_hash_function func; /**< RSS hash function to apply. */ 3266 /** 3267 * Packet encapsulation level RSS hash @p types apply to. 3268 * 3269 * - @p 0 requests the default behavior. Depending on the packet 3270 * type, it can mean outermost, innermost, anything in between or 3271 * even no RSS. 3272 * 3273 * It basically stands for the innermost encapsulation level RSS 3274 * can be performed on according to PMD and device capabilities. 3275 * 3276 * - @p 1 requests RSS to be performed on the outermost packet 3277 * encapsulation level. 3278 * 3279 * - @p 2 and subsequent values request RSS to be performed on the 3280 * specified inner packet encapsulation level, from outermost to 3281 * innermost (lower to higher values). 3282 * 3283 * Values other than @p 0 are not necessarily supported. 3284 * 3285 * Requesting a specific RSS level on unrecognized traffic results 3286 * in undefined behavior. For predictable results, it is recommended 3287 * to make the flow rule pattern match packet headers up to the 3288 * requested encapsulation level so that only matching traffic goes 3289 * through. 3290 */ 3291 uint32_t level; 3292 uint64_t types; /**< Specific RSS hash types (see RTE_ETH_RSS_*). */ 3293 uint32_t key_len; /**< Hash key length in bytes. */ 3294 uint32_t queue_num; /**< Number of entries in @p queue. */ 3295 const uint8_t *key; /**< Hash key. */ 3296 const uint16_t *queue; /**< Queue indices to use. */ 3297 }; 3298 3299 /** 3300 * @deprecated 3301 * @see RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR 3302 * @see RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT 3303 * 3304 * RTE_FLOW_ACTION_TYPE_VF 3305 * 3306 * Directs matching traffic to a given virtual function of the current 3307 * device. 3308 * 3309 * Packets matched by a VF pattern item can be redirected to their original 3310 * VF ID instead of the specified one. This parameter may not be available 3311 * and is not guaranteed to work properly if the VF part is matched by a 3312 * prior flow rule or if packets are not addressed to a VF in the first 3313 * place. 3314 */ 3315 struct rte_flow_action_vf { 3316 uint32_t original:1; /**< Use original VF ID if possible. */ 3317 uint32_t reserved:31; /**< Reserved, must be zero. */ 3318 uint32_t id; /**< VF ID. */ 3319 }; 3320 3321 /** 3322 * @deprecated 3323 * @see RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR 3324 * @see RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT 3325 * 3326 * RTE_FLOW_ACTION_TYPE_PORT_ID 3327 * 3328 * Directs matching traffic to a given DPDK port ID. 3329 * 3330 * @see RTE_FLOW_ITEM_TYPE_PORT_ID 3331 */ 3332 struct rte_flow_action_port_id { 3333 uint32_t original:1; /**< Use original DPDK port ID if possible. */ 3334 uint32_t reserved:31; /**< Reserved, must be zero. */ 3335 uint32_t id; /**< DPDK port ID. */ 3336 }; 3337 3338 /** 3339 * RTE_FLOW_ACTION_TYPE_METER 3340 * 3341 * Traffic metering and policing (MTR). 3342 * 3343 * Packets matched by items of this type can be either dropped or passed to the 3344 * next item with their color set by the MTR object. 3345 */ 3346 struct rte_flow_action_meter { 3347 uint32_t mtr_id; /**< MTR object ID created with rte_mtr_create(). */ 3348 }; 3349 3350 /** 3351 * RTE_FLOW_ACTION_TYPE_SECURITY 3352 * 3353 * Perform the security action on flows matched by the pattern items 3354 * according to the configuration of the security session. 3355 * 3356 * This action modifies the payload of matched flows. For INLINE_CRYPTO, the 3357 * security protocol headers and IV are fully provided by the application as 3358 * specified in the flow pattern. The payload of matching packets is 3359 * encrypted on egress, and decrypted and authenticated on ingress. 3360 * For INLINE_PROTOCOL, the security protocol is fully offloaded to HW, 3361 * providing full encapsulation and decapsulation of packets in security 3362 * protocols. The flow pattern specifies both the outer security header fields 3363 * and the inner packet fields. The security session specified in the action 3364 * must match the pattern parameters. 3365 * 3366 * The security session specified in the action must be created on the same 3367 * port as the flow action that is being specified. 3368 * 3369 * The ingress/egress flow attribute should match that specified in the 3370 * security session if the security session supports the definition of the 3371 * direction. 3372 * 3373 * Multiple flows can be configured to use the same security session. 3374 * 3375 * The NULL value is allowed for security session. If security session is NULL, 3376 * then SPI field in ESP flow item and IP addresses in flow items 'IPv4' and 3377 * 'IPv6' will be allowed to be a range. The rule thus created can enable 3378 * security processing on multiple flows. 3379 */ 3380 struct rte_flow_action_security { 3381 void *security_session; /**< Pointer to security session structure. */ 3382 }; 3383 3384 /** 3385 * RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN 3386 * 3387 * Implements OFPAT_PUSH_VLAN ("push a new VLAN tag") as defined by the 3388 * OpenFlow Switch Specification. 3389 */ 3390 struct rte_flow_action_of_push_vlan { 3391 rte_be16_t ethertype; /**< EtherType. */ 3392 }; 3393 3394 /** 3395 * RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID 3396 * 3397 * Implements OFPAT_SET_VLAN_VID ("set the 802.1q VLAN ID") as defined by 3398 * the OpenFlow Switch Specification. 3399 */ 3400 struct rte_flow_action_of_set_vlan_vid { 3401 rte_be16_t vlan_vid; /**< VLAN ID. */ 3402 }; 3403 3404 /** 3405 * RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP 3406 * 3407 * Implements OFPAT_SET_LAN_PCP ("set the 802.1q priority") as defined by 3408 * the OpenFlow Switch Specification. 3409 */ 3410 struct rte_flow_action_of_set_vlan_pcp { 3411 uint8_t vlan_pcp; /**< VLAN priority. */ 3412 }; 3413 3414 /** 3415 * RTE_FLOW_ACTION_TYPE_OF_POP_MPLS 3416 * 3417 * Implements OFPAT_POP_MPLS ("pop the outer MPLS tag") as defined by the 3418 * OpenFlow Switch Specification. 3419 */ 3420 struct rte_flow_action_of_pop_mpls { 3421 rte_be16_t ethertype; /**< EtherType. */ 3422 }; 3423 3424 /** 3425 * RTE_FLOW_ACTION_TYPE_OF_PUSH_MPLS 3426 * 3427 * Implements OFPAT_PUSH_MPLS ("push a new MPLS tag") as defined by the 3428 * OpenFlow Switch Specification. 3429 */ 3430 struct rte_flow_action_of_push_mpls { 3431 rte_be16_t ethertype; /**< EtherType. */ 3432 }; 3433 3434 /** 3435 * @warning 3436 * @b EXPERIMENTAL: this structure may change without prior notice 3437 * 3438 * RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP 3439 * 3440 * VXLAN tunnel end-point encapsulation data definition 3441 * 3442 * The tunnel definition is provided through the flow item pattern, the 3443 * provided pattern must conform to RFC7348 for the tunnel specified. The flow 3444 * definition must be provided in order from the RTE_FLOW_ITEM_TYPE_ETH 3445 * definition up the end item which is specified by RTE_FLOW_ITEM_TYPE_END. 3446 * 3447 * The mask field allows user to specify which fields in the flow item 3448 * definitions can be ignored and which have valid data and can be used 3449 * verbatim. 3450 * 3451 * Note: the last field is not used in the definition of a tunnel and can be 3452 * ignored. 3453 * 3454 * Valid flow definition for RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP include: 3455 * 3456 * - ETH / IPV4 / UDP / VXLAN / END 3457 * - ETH / IPV6 / UDP / VXLAN / END 3458 * - ETH / VLAN / IPV4 / UDP / VXLAN / END 3459 */ 3460 struct rte_flow_action_vxlan_encap { 3461 /** 3462 * Encapsulating vxlan tunnel definition 3463 * (terminated by the END pattern item). 3464 */ 3465 struct rte_flow_item *definition; 3466 }; 3467 3468 /** 3469 * @warning 3470 * @b EXPERIMENTAL: this structure may change without prior notice 3471 * 3472 * RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP 3473 * 3474 * NVGRE tunnel end-point encapsulation data definition 3475 * 3476 * The tunnel definition is provided through the flow item pattern the 3477 * provided pattern must conform with RFC7637. The flow definition must be 3478 * provided in order from the RTE_FLOW_ITEM_TYPE_ETH definition up the end item 3479 * which is specified by RTE_FLOW_ITEM_TYPE_END. 3480 * 3481 * The mask field allows user to specify which fields in the flow item 3482 * definitions can be ignored and which have valid data and can be used 3483 * verbatim. 3484 * 3485 * Note: the last field is not used in the definition of a tunnel and can be 3486 * ignored. 3487 * 3488 * Valid flow definition for RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP include: 3489 * 3490 * - ETH / IPV4 / NVGRE / END 3491 * - ETH / VLAN / IPV6 / NVGRE / END 3492 */ 3493 struct rte_flow_action_nvgre_encap { 3494 /** 3495 * Encapsulating vxlan tunnel definition 3496 * (terminated by the END pattern item). 3497 */ 3498 struct rte_flow_item *definition; 3499 }; 3500 3501 /** 3502 * @warning 3503 * @b EXPERIMENTAL: this structure may change without prior notice 3504 * 3505 * RTE_FLOW_ACTION_TYPE_RAW_ENCAP 3506 * 3507 * Raw tunnel end-point encapsulation data definition. 3508 * 3509 * The data holds the headers definitions to be applied on the packet. 3510 * The data must start with ETH header up to the tunnel item header itself. 3511 * When used right after RAW_DECAP (for decapsulating L3 tunnel type for 3512 * example MPLSoGRE) the data will just hold layer 2 header. 3513 * 3514 * The preserve parameter holds which bits in the packet the PMD is not allowed 3515 * to change, this parameter can also be NULL and then the PMD is allowed 3516 * to update any field. 3517 * 3518 * size holds the number of bytes in @p data and @p preserve. 3519 */ 3520 struct rte_flow_action_raw_encap { 3521 uint8_t *data; /**< Encapsulation data. */ 3522 uint8_t *preserve; /**< Bit-mask of @p data to preserve on output. */ 3523 size_t size; /**< Size of @p data and @p preserve. */ 3524 }; 3525 3526 /** 3527 * @warning 3528 * @b EXPERIMENTAL: this structure may change without prior notice 3529 * 3530 * RTE_FLOW_ACTION_TYPE_RAW_DECAP 3531 * 3532 * Raw tunnel end-point decapsulation data definition. 3533 * 3534 * The data holds the headers definitions to be removed from the packet. 3535 * The data must start with ETH header up to the tunnel item header itself. 3536 * When used right before RAW_DECAP (for encapsulating L3 tunnel type for 3537 * example MPLSoGRE) the data will just hold layer 2 header. 3538 * 3539 * size holds the number of bytes in @p data. 3540 */ 3541 struct rte_flow_action_raw_decap { 3542 uint8_t *data; /**< Encapsulation data. */ 3543 size_t size; /**< Size of @p data and @p preserve. */ 3544 }; 3545 3546 /** 3547 * @warning 3548 * @b EXPERIMENTAL: this structure may change without prior notice 3549 * 3550 * RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC 3551 * RTE_FLOW_ACTION_TYPE_SET_IPV4_DST 3552 * 3553 * Allows modification of IPv4 source (RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC) 3554 * and destination address (RTE_FLOW_ACTION_TYPE_SET_IPV4_DST) in the 3555 * specified outermost IPv4 header. 3556 */ 3557 struct rte_flow_action_set_ipv4 { 3558 rte_be32_t ipv4_addr; 3559 }; 3560 3561 /** 3562 * @warning 3563 * @b EXPERIMENTAL: this structure may change without prior notice 3564 * 3565 * RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC 3566 * RTE_FLOW_ACTION_TYPE_SET_IPV6_DST 3567 * 3568 * Allows modification of IPv6 source (RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC) 3569 * and destination address (RTE_FLOW_ACTION_TYPE_SET_IPV6_DST) in the 3570 * specified outermost IPv6 header. 3571 */ 3572 struct rte_flow_action_set_ipv6 { 3573 uint8_t ipv6_addr[16]; 3574 }; 3575 3576 /** 3577 * @warning 3578 * @b EXPERIMENTAL: this structure may change without prior notice. 3579 * 3580 * RTE_FLOW_ACTION_TYPE_IPV6_EXT_PUSH 3581 * 3582 * Valid flow definition for RTE_FLOW_ACTION_TYPE_IPV6_EXT_PUSH include: 3583 * 3584 * - IPV6_EXT TYPE / IPV6_EXT_HEADER_IN_TYPE / END 3585 * 3586 * The data must be added as the last IPv6 extension. 3587 */ 3588 struct rte_flow_action_ipv6_ext_push { 3589 uint8_t *data; /**< IPv6 extension header data. */ 3590 size_t size; /**< Size (in bytes) of @p data. */ 3591 uint8_t type; /**< Type of IPv6 extension. */ 3592 }; 3593 3594 /** 3595 * @warning 3596 * @b EXPERIMENTAL: this structure may change without prior notice. 3597 * 3598 * RTE_FLOW_ACTION_TYPE_IPV6_EXT_REMOVE 3599 * 3600 * Valid flow definition for RTE_FLOW_ACTION_TYPE_IPV6_EXT_REMOVE include: 3601 * 3602 * - IPV6_EXT TYPE / END 3603 */ 3604 struct rte_flow_action_ipv6_ext_remove { 3605 uint8_t type; /**< Type of IPv6 extension. */ 3606 }; 3607 3608 /** 3609 * @warning 3610 * @b EXPERIMENTAL: this structure may change without prior notice 3611 * 3612 * RTE_FLOW_ACTION_TYPE_SET_TP_SRC 3613 * RTE_FLOW_ACTION_TYPE_SET_TP_DST 3614 * 3615 * Allows modification of source (RTE_FLOW_ACTION_TYPE_SET_TP_SRC) 3616 * and destination (RTE_FLOW_ACTION_TYPE_SET_TP_DST) port numbers 3617 * in the specified outermost TCP/UDP header. 3618 */ 3619 struct rte_flow_action_set_tp { 3620 rte_be16_t port; 3621 }; 3622 3623 /** 3624 * RTE_FLOW_ACTION_TYPE_SET_TTL 3625 * 3626 * Set the TTL value directly for IPv4 or IPv6 3627 */ 3628 struct rte_flow_action_set_ttl { 3629 uint8_t ttl_value; 3630 }; 3631 3632 /** 3633 * RTE_FLOW_ACTION_TYPE_SET_MAC 3634 * 3635 * Set MAC address from the matched flow 3636 */ 3637 struct rte_flow_action_set_mac { 3638 uint8_t mac_addr[RTE_ETHER_ADDR_LEN]; 3639 }; 3640 3641 /** 3642 * @warning 3643 * @b EXPERIMENTAL: this structure may change without prior notice 3644 * 3645 * RTE_FLOW_ACTION_TYPE_SET_TAG 3646 * 3647 * Set a tag which is a transient data used during flow matching. This is not 3648 * delivered to application. Multiple tags are supported by specifying index. 3649 */ 3650 struct rte_flow_action_set_tag { 3651 uint32_t data; 3652 uint32_t mask; 3653 uint8_t index; 3654 }; 3655 3656 /** 3657 * @warning 3658 * @b EXPERIMENTAL: this structure may change without prior notice 3659 * 3660 * RTE_FLOW_ACTION_TYPE_SET_META 3661 * 3662 * Set metadata. Metadata set by mbuf metadata dynamic field with 3663 * RTE_MBUF_DYNFLAG_TX_METADATA flag on egress will be overridden by this 3664 * action. On ingress, the metadata will be carried by mbuf metadata dynamic 3665 * field with RTE_MBUF_DYNFLAG_RX_METADATA flag if set. The dynamic mbuf field 3666 * must be registered in advance by rte_flow_dynf_metadata_register(). 3667 * 3668 * Altering partial bits is supported with mask. For bits which have never 3669 * been set, unpredictable value will be seen depending on driver 3670 * implementation. For loopback/hairpin packet, metadata set on Rx/Tx may 3671 * or may not be propagated to the other path depending on HW capability. 3672 * 3673 * RTE_FLOW_ITEM_TYPE_META matches metadata. 3674 */ 3675 struct rte_flow_action_set_meta { 3676 uint32_t data; 3677 uint32_t mask; 3678 }; 3679 3680 /** 3681 * RTE_FLOW_ACTION_TYPE_SET_IPV4_DSCP 3682 * RTE_FLOW_ACTION_TYPE_SET_IPV6_DSCP 3683 * 3684 * Set the DSCP value for IPv4/IPv6 header. 3685 * DSCP in low 6 bits, rest ignored. 3686 */ 3687 struct rte_flow_action_set_dscp { 3688 uint8_t dscp; 3689 }; 3690 3691 /** 3692 * @warning 3693 * @b EXPERIMENTAL: this structure may change without prior notice 3694 * 3695 * RTE_FLOW_ACTION_TYPE_INDIRECT 3696 * 3697 * Opaque type returned after successfully creating an indirect action object. 3698 * The definition of the object handle is different per driver or 3699 * per direct action type. 3700 * 3701 * This handle can be used to manage and query the related direct action: 3702 * - referenced in single flow rule or across multiple flow rules 3703 * over multiple ports 3704 * - update action object configuration 3705 * - query action object data 3706 * - destroy action object 3707 */ 3708 struct rte_flow_action_handle; 3709 3710 /** 3711 * The state of a TCP connection. 3712 */ 3713 enum rte_flow_conntrack_state { 3714 /** SYN-ACK packet was seen. */ 3715 RTE_FLOW_CONNTRACK_STATE_SYN_RECV, 3716 /** 3-way handshake was done. */ 3717 RTE_FLOW_CONNTRACK_STATE_ESTABLISHED, 3718 /** First FIN packet was received to close the connection. */ 3719 RTE_FLOW_CONNTRACK_STATE_FIN_WAIT, 3720 /** First FIN was ACKed. */ 3721 RTE_FLOW_CONNTRACK_STATE_CLOSE_WAIT, 3722 /** Second FIN was received, waiting for the last ACK. */ 3723 RTE_FLOW_CONNTRACK_STATE_LAST_ACK, 3724 /** Second FIN was ACKed, connection was closed. */ 3725 RTE_FLOW_CONNTRACK_STATE_TIME_WAIT, 3726 }; 3727 3728 /** 3729 * The last passed TCP packet flags of a connection. 3730 */ 3731 enum rte_flow_conntrack_tcp_last_index { 3732 RTE_FLOW_CONNTRACK_FLAG_NONE = 0, /**< No Flag. */ 3733 RTE_FLOW_CONNTRACK_FLAG_SYN = RTE_BIT32(0), /**< With SYN flag. */ 3734 RTE_FLOW_CONNTRACK_FLAG_SYNACK = RTE_BIT32(1), /**< With SYNACK flag. */ 3735 RTE_FLOW_CONNTRACK_FLAG_FIN = RTE_BIT32(2), /**< With FIN flag. */ 3736 RTE_FLOW_CONNTRACK_FLAG_ACK = RTE_BIT32(3), /**< With ACK flag. */ 3737 RTE_FLOW_CONNTRACK_FLAG_RST = RTE_BIT32(4), /**< With RST flag. */ 3738 }; 3739 3740 /** 3741 * @warning 3742 * @b EXPERIMENTAL: this structure may change without prior notice 3743 * 3744 * Configuration parameters for each direction of a TCP connection. 3745 * All fields should be in host byte order. 3746 * If needed, driver should convert all fields to network byte order 3747 * if HW needs them in that way. 3748 */ 3749 struct rte_flow_tcp_dir_param { 3750 /** TCP window scaling factor, 0xF to disable. */ 3751 uint32_t scale:4; 3752 /** The FIN was sent by this direction. */ 3753 uint32_t close_initiated:1; 3754 /** An ACK packet has been received by this side. */ 3755 uint32_t last_ack_seen:1; 3756 /** 3757 * If set, it indicates that there is unacknowledged data for the 3758 * packets sent from this direction. 3759 */ 3760 uint32_t data_unacked:1; 3761 /** 3762 * Maximal value of sequence + payload length in sent 3763 * packets (next ACK from the opposite direction). 3764 */ 3765 uint32_t sent_end; 3766 /** 3767 * Maximal value of (ACK + window size) in received packet + length 3768 * over sent packet (maximal sequence could be sent). 3769 */ 3770 uint32_t reply_end; 3771 /** Maximal value of actual window size in sent packets. */ 3772 uint32_t max_win; 3773 /** Maximal value of ACK in sent packets. */ 3774 uint32_t max_ack; 3775 }; 3776 3777 /** 3778 * @warning 3779 * @b EXPERIMENTAL: this structure may change without prior notice 3780 * 3781 * RTE_FLOW_ACTION_TYPE_CONNTRACK 3782 * 3783 * Configuration and initial state for the connection tracking module. 3784 * This structure could be used for both setting and query. 3785 * All fields should be in host byte order. 3786 */ 3787 struct rte_flow_action_conntrack { 3788 /** The peer port number, can be the same port. */ 3789 uint16_t peer_port; 3790 /** 3791 * Direction of this connection when creating a flow rule, the 3792 * value only affects the creation of subsequent flow rules. 3793 */ 3794 uint32_t is_original_dir:1; 3795 /** 3796 * Enable / disable the conntrack HW module. When disabled, the 3797 * result will always be RTE_FLOW_CONNTRACK_FLAG_DISABLED. 3798 * In this state the HW will act as passthrough. 3799 * It only affects this conntrack object in the HW without any effect 3800 * to the other objects. 3801 */ 3802 uint32_t enable:1; 3803 /** At least one ack was seen after the connection was established. */ 3804 uint32_t live_connection:1; 3805 /** Enable selective ACK on this connection. */ 3806 uint32_t selective_ack:1; 3807 /** A challenge ack has passed. */ 3808 uint32_t challenge_ack_passed:1; 3809 /** 3810 * 1: The last packet is seen from the original direction. 3811 * 0: The last packet is seen from the reply direction. 3812 */ 3813 uint32_t last_direction:1; 3814 /** No TCP check will be done except the state change. */ 3815 uint32_t liberal_mode:1; 3816 /** The current state of this connection. */ 3817 enum rte_flow_conntrack_state state; 3818 /** Scaling factor for maximal allowed ACK window. */ 3819 uint8_t max_ack_window; 3820 /** Maximal allowed number of retransmission times. */ 3821 uint8_t retransmission_limit; 3822 /** TCP parameters of the original direction. */ 3823 struct rte_flow_tcp_dir_param original_dir; 3824 /** TCP parameters of the reply direction. */ 3825 struct rte_flow_tcp_dir_param reply_dir; 3826 /** The window value of the last packet passed this conntrack. */ 3827 uint16_t last_window; 3828 enum rte_flow_conntrack_tcp_last_index last_index; 3829 /** The sequence of the last packet passed this conntrack. */ 3830 uint32_t last_seq; 3831 /** The acknowledgment of the last packet passed this conntrack. */ 3832 uint32_t last_ack; 3833 /** 3834 * The total value ACK + payload length of the last packet 3835 * passed this conntrack. 3836 */ 3837 uint32_t last_end; 3838 }; 3839 3840 /** 3841 * RTE_FLOW_ACTION_TYPE_CONNTRACK 3842 * 3843 * Wrapper structure for the context update interface. 3844 * Ports cannot support updating, and the only valid solution is to 3845 * destroy the old context and create a new one instead. 3846 */ 3847 struct rte_flow_modify_conntrack { 3848 /** New connection tracking parameters to be updated. */ 3849 struct rte_flow_action_conntrack new_ct; 3850 /** The direction field will be updated. */ 3851 uint32_t direction:1; 3852 /** All the other fields except direction will be updated. */ 3853 uint32_t state:1; 3854 /** Reserved bits for the future usage. */ 3855 uint32_t reserved:30; 3856 }; 3857 3858 /** 3859 * @warning 3860 * @b EXPERIMENTAL: this structure may change without prior notice 3861 * 3862 * RTE_FLOW_ACTION_TYPE_METER_COLOR 3863 * 3864 * The meter color should be set in the packet meta-data 3865 * (i.e. struct rte_mbuf::sched::color). 3866 */ 3867 struct rte_flow_action_meter_color { 3868 enum rte_color color; /**< Packet color. */ 3869 }; 3870 3871 /** 3872 * Provides an ethdev port ID for use with the following actions: 3873 * RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR, 3874 * RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT. 3875 */ 3876 struct rte_flow_action_ethdev { 3877 uint16_t port_id; /**< ethdev port ID */ 3878 }; 3879 3880 /** 3881 * Field IDs for MODIFY_FIELD action. 3882 */ 3883 enum rte_flow_field_id { 3884 RTE_FLOW_FIELD_START = 0, /**< Start of a packet. */ 3885 RTE_FLOW_FIELD_MAC_DST, /**< Destination MAC Address. */ 3886 RTE_FLOW_FIELD_MAC_SRC, /**< Source MAC Address. */ 3887 RTE_FLOW_FIELD_VLAN_TYPE, /**< VLAN Tag Identifier. */ 3888 RTE_FLOW_FIELD_VLAN_ID, /**< VLAN Identifier. */ 3889 RTE_FLOW_FIELD_MAC_TYPE, /**< EtherType. */ 3890 RTE_FLOW_FIELD_IPV4_DSCP, /**< IPv4 DSCP. */ 3891 RTE_FLOW_FIELD_IPV4_TTL, /**< IPv4 Time To Live. */ 3892 RTE_FLOW_FIELD_IPV4_SRC, /**< IPv4 Source Address. */ 3893 RTE_FLOW_FIELD_IPV4_DST, /**< IPv4 Destination Address. */ 3894 RTE_FLOW_FIELD_IPV6_DSCP, /**< IPv6 DSCP. */ 3895 RTE_FLOW_FIELD_IPV6_HOPLIMIT, /**< IPv6 Hop Limit. */ 3896 RTE_FLOW_FIELD_IPV6_SRC, /**< IPv6 Source Address. */ 3897 RTE_FLOW_FIELD_IPV6_DST, /**< IPv6 Destination Address. */ 3898 RTE_FLOW_FIELD_TCP_PORT_SRC, /**< TCP Source Port Number. */ 3899 RTE_FLOW_FIELD_TCP_PORT_DST, /**< TCP Destination Port Number. */ 3900 RTE_FLOW_FIELD_TCP_SEQ_NUM, /**< TCP Sequence Number. */ 3901 RTE_FLOW_FIELD_TCP_ACK_NUM, /**< TCP Acknowledgment Number. */ 3902 RTE_FLOW_FIELD_TCP_FLAGS, /**< TCP Flags. */ 3903 RTE_FLOW_FIELD_UDP_PORT_SRC, /**< UDP Source Port Number. */ 3904 RTE_FLOW_FIELD_UDP_PORT_DST, /**< UDP Destination Port Number. */ 3905 RTE_FLOW_FIELD_VXLAN_VNI, /**< VXLAN Network Identifier. */ 3906 RTE_FLOW_FIELD_GENEVE_VNI, /**< GENEVE Network Identifier. */ 3907 RTE_FLOW_FIELD_GTP_TEID, /**< GTP Tunnel Endpoint Identifier. */ 3908 RTE_FLOW_FIELD_TAG, /**< Tag value. */ 3909 RTE_FLOW_FIELD_MARK, /**< Mark value. */ 3910 RTE_FLOW_FIELD_META, /**< Metadata value. */ 3911 RTE_FLOW_FIELD_POINTER, /**< Memory pointer. */ 3912 RTE_FLOW_FIELD_VALUE, /**< Immediate value. */ 3913 RTE_FLOW_FIELD_IPV4_ECN, /**< IPv4 ECN. */ 3914 RTE_FLOW_FIELD_IPV6_ECN, /**< IPv6 ECN. */ 3915 RTE_FLOW_FIELD_GTP_PSC_QFI, /**< GTP QFI. */ 3916 RTE_FLOW_FIELD_METER_COLOR, /**< Meter color marker. */ 3917 RTE_FLOW_FIELD_IPV6_PROTO, /**< IPv6 next header. */ 3918 RTE_FLOW_FIELD_FLEX_ITEM, /**< Flex item. */ 3919 RTE_FLOW_FIELD_HASH_RESULT, /**< Hash result. */ 3920 RTE_FLOW_FIELD_GENEVE_OPT_TYPE, /**< GENEVE option type. */ 3921 RTE_FLOW_FIELD_GENEVE_OPT_CLASS,/**< GENEVE option class. */ 3922 RTE_FLOW_FIELD_GENEVE_OPT_DATA, /**< GENEVE option data. */ 3923 RTE_FLOW_FIELD_MPLS, /**< MPLS header. */ 3924 RTE_FLOW_FIELD_TCP_DATA_OFFSET, /**< TCP data offset. */ 3925 RTE_FLOW_FIELD_IPV4_IHL, /**< IPv4 IHL. */ 3926 RTE_FLOW_FIELD_IPV4_TOTAL_LEN, /**< IPv4 total length. */ 3927 RTE_FLOW_FIELD_IPV6_PAYLOAD_LEN /**< IPv6 payload length. */ 3928 }; 3929 3930 /** 3931 * @warning 3932 * @b EXPERIMENTAL: this structure may change without prior notice 3933 * 3934 * Field description for MODIFY_FIELD action. 3935 */ 3936 struct rte_flow_action_modify_data { 3937 enum rte_flow_field_id field; /**< Field or memory type ID. */ 3938 union { 3939 struct { 3940 /** Encapsulation level and tag index or flex item handle. */ 3941 union { 3942 struct { 3943 /** 3944 * Packet encapsulation level containing 3945 * the field to modify. 3946 * 3947 * - @p 0 requests the default behavior. 3948 * Depending on the packet type, it 3949 * can mean outermost, innermost or 3950 * anything in between. 3951 * 3952 * It basically stands for the 3953 * innermost encapsulation level. 3954 * Modification can be performed 3955 * according to PMD and device 3956 * capabilities. 3957 * 3958 * - @p 1 requests modification to be 3959 * performed on the outermost packet 3960 * encapsulation level. 3961 * 3962 * - @p 2 and subsequent values request 3963 * modification to be performed on 3964 * the specified inner packet 3965 * encapsulation level, from 3966 * outermost to innermost (lower to 3967 * higher values). 3968 * 3969 * Values other than @p 0 are not 3970 * necessarily supported. 3971 * 3972 * @note that for MPLS field, 3973 * encapsulation level also include 3974 * tunnel since MPLS may appear in 3975 * outer, inner or tunnel. 3976 */ 3977 uint8_t level; 3978 union { 3979 /** 3980 * Tag index array inside 3981 * encapsulation level. 3982 * Used for VLAN, MPLS or TAG types. 3983 */ 3984 uint8_t tag_index; 3985 /** 3986 * Geneve option identifier. 3987 * Relevant only for 3988 * RTE_FLOW_FIELD_GENEVE_OPT_XXXX 3989 * modification type. 3990 */ 3991 struct { 3992 /** 3993 * Geneve option type. 3994 */ 3995 uint8_t type; 3996 /** 3997 * Geneve option class. 3998 */ 3999 rte_be16_t class_id; 4000 }; 4001 }; 4002 }; 4003 struct rte_flow_item_flex_handle *flex_handle; 4004 }; 4005 /** Number of bits to skip from a field. */ 4006 uint32_t offset; 4007 }; 4008 /** 4009 * Immediate value for RTE_FLOW_FIELD_VALUE, presented in the 4010 * same byte order and length as in relevant rte_flow_item_xxx. 4011 * The immediate source bitfield offset is inherited from 4012 * the destination's one. 4013 */ 4014 uint8_t value[16]; 4015 /** 4016 * Memory address for RTE_FLOW_FIELD_POINTER, memory layout 4017 * should be the same as for relevant field in the 4018 * rte_flow_item_xxx structure. 4019 */ 4020 void *pvalue; 4021 }; 4022 }; 4023 4024 /** 4025 * Operation types for MODIFY_FIELD action. 4026 */ 4027 enum rte_flow_modify_op { 4028 RTE_FLOW_MODIFY_SET = 0, /**< Set a new value. */ 4029 RTE_FLOW_MODIFY_ADD, /**< Add a value to a field. */ 4030 RTE_FLOW_MODIFY_SUB, /**< Subtract a value from a field. */ 4031 }; 4032 4033 /** 4034 * @warning 4035 * @b EXPERIMENTAL: this structure may change without prior notice 4036 * 4037 * RTE_FLOW_ACTION_TYPE_MODIFY_FIELD 4038 * 4039 * Modify a destination header field according to the specified 4040 * operation. Another field of the packet can be used as a source as well 4041 * as tag, mark, metadata, immediate value or a pointer to it. 4042 */ 4043 struct rte_flow_action_modify_field { 4044 enum rte_flow_modify_op operation; /**< Operation to perform. */ 4045 struct rte_flow_action_modify_data dst; /**< Destination field. */ 4046 struct rte_flow_action_modify_data src; /**< Source field. */ 4047 uint32_t width; /**< Number of bits to use from a source field. */ 4048 }; 4049 4050 /** 4051 * RTE_FLOW_ACTION_TYPE_METER_MARK 4052 * 4053 * Traffic metering and marking (MTR). 4054 * 4055 * Meters a packet stream and marks its packets either 4056 * green, yellow, or red according to the specified profile. 4057 * The policy is optional and may be specified for defining 4058 * subsequent actions based on a color assigned by MTR. 4059 * Alternatively, the METER_COLOR item may be used for this. 4060 */ 4061 struct rte_flow_action_meter_mark { 4062 4063 /**< Profile config retrieved with rte_mtr_profile_get(). */ 4064 struct rte_flow_meter_profile *profile; 4065 /**< Policy config retrieved with rte_mtr_policy_get(). */ 4066 struct rte_flow_meter_policy *policy; 4067 /** Metering mode: 0 - Color-Blind, 1 - Color-Aware. */ 4068 int color_mode; 4069 /** Metering state: 0 - Disabled, 1 - Enabled. */ 4070 int state; 4071 }; 4072 4073 /** 4074 * RTE_FLOW_ACTION_TYPE_METER_MARK 4075 * 4076 * Wrapper structure for the context update interface. 4077 */ 4078 struct rte_flow_update_meter_mark { 4079 /** New meter_mark parameters to be updated. */ 4080 struct rte_flow_action_meter_mark meter_mark; 4081 /** The profile will be updated. */ 4082 uint32_t profile_valid:1; 4083 /** The policy will be updated. */ 4084 uint32_t policy_valid:1; 4085 /** The color mode will be updated. */ 4086 uint32_t color_mode_valid:1; 4087 /** The meter state will be updated. */ 4088 uint32_t state_valid:1; 4089 /** Reserved bits for the future usage. */ 4090 uint32_t reserved:28; 4091 }; 4092 4093 /** 4094 * @see RTE_FLOW_ACTION_TYPE_METER_MARK 4095 * @see RTE_FLOW_ACTION_TYPE_INDIRECT_LIST 4096 * 4097 * Update flow mutable context. 4098 */ 4099 struct rte_flow_indirect_update_flow_meter_mark { 4100 /** Updated init color applied to packet */ 4101 enum rte_color init_color; 4102 }; 4103 4104 /** 4105 * @warning 4106 * @b EXPERIMENTAL: this structure may change without prior notice. 4107 * 4108 * Program action argument configuration parameters. 4109 * 4110 * For each action argument, its *size* must be non-zero and its *value* must 4111 * point to a valid array of *size* bytes specified in network byte order. 4112 * 4113 * @see struct rte_flow_action_prog 4114 */ 4115 struct rte_flow_action_prog_argument { 4116 /** Argument name. */ 4117 const char *name; 4118 /** Argument size in bytes. */ 4119 uint32_t size; 4120 /** Argument value. */ 4121 const uint8_t *value; 4122 }; 4123 4124 /** 4125 * @warning 4126 * @b EXPERIMENTAL: this structure may change without prior notice. 4127 * 4128 * RTE_FLOW_ACTION_TYPE_PROG 4129 * 4130 * Program action configuration parameters. 4131 * 4132 * Each action can have zero or more arguments. When *args_num* is non-zero, the 4133 * *args* parameter must point to a valid array of *args_num* elements. 4134 * 4135 * @see RTE_FLOW_ACTION_TYPE_PROG 4136 */ 4137 struct rte_flow_action_prog { 4138 /** Action name. */ 4139 const char *name; 4140 /** Number of action arguments. */ 4141 uint32_t args_num; 4142 /** Action arguments array. */ 4143 const struct rte_flow_action_prog_argument *args; 4144 }; 4145 4146 /* Mbuf dynamic field offset for metadata. */ 4147 extern int32_t rte_flow_dynf_metadata_offs; 4148 4149 /* Mbuf dynamic field flag mask for metadata. */ 4150 extern uint64_t rte_flow_dynf_metadata_mask; 4151 4152 /* Mbuf dynamic field pointer for metadata. */ 4153 #define RTE_FLOW_DYNF_METADATA(m) \ 4154 RTE_MBUF_DYNFIELD((m), rte_flow_dynf_metadata_offs, uint32_t *) 4155 4156 /* Mbuf dynamic flags for metadata. */ 4157 #define RTE_MBUF_DYNFLAG_RX_METADATA (rte_flow_dynf_metadata_mask) 4158 #define RTE_MBUF_DYNFLAG_TX_METADATA (rte_flow_dynf_metadata_mask) 4159 4160 __rte_experimental 4161 static inline uint32_t 4162 rte_flow_dynf_metadata_get(struct rte_mbuf *m) 4163 { 4164 return *RTE_FLOW_DYNF_METADATA(m); 4165 } 4166 4167 __rte_experimental 4168 static inline void 4169 rte_flow_dynf_metadata_set(struct rte_mbuf *m, uint32_t v) 4170 { 4171 *RTE_FLOW_DYNF_METADATA(m) = v; 4172 } 4173 4174 /** 4175 * Definition of a single action. 4176 * 4177 * A list of actions is terminated by a END action. 4178 * 4179 * For simple actions without a configuration object, conf remains NULL. 4180 */ 4181 struct rte_flow_action { 4182 enum rte_flow_action_type type; /**< Action type. */ 4183 const void *conf; /**< Pointer to action configuration object. */ 4184 }; 4185 4186 /** 4187 * Opaque type returned after successfully creating a flow. 4188 * 4189 * This handle can be used to manage and query the related flow (e.g. to 4190 * destroy it or retrieve counters). 4191 */ 4192 struct rte_flow; 4193 4194 /** 4195 * Opaque type for Meter profile object returned by MTR API. 4196 * 4197 * This handle can be used to create Meter actions instead of profile ID. 4198 */ 4199 struct rte_flow_meter_profile; 4200 4201 /** 4202 * Opaque type for Meter policy object returned by MTR API. 4203 * 4204 * This handle can be used to create Meter actions instead of policy ID. 4205 */ 4206 struct rte_flow_meter_policy; 4207 4208 /** 4209 * @warning 4210 * @b EXPERIMENTAL: this structure may change without prior notice 4211 * 4212 * RTE_FLOW_ACTION_TYPE_SAMPLE 4213 * 4214 * Adds a sample action to a matched flow. 4215 * 4216 * The matching packets will be duplicated with specified ratio and applied 4217 * with own set of actions with a fate action, the sampled packet could be 4218 * redirected to queue or port. All the packets continue processing on the 4219 * default flow path. 4220 * 4221 * When the sample ratio is set to 1 then the packets will be 100% mirrored. 4222 * Additional action list be supported to add for sampled or mirrored packets. 4223 */ 4224 struct rte_flow_action_sample { 4225 uint32_t ratio; /**< packets sampled equals to '1/ratio'. */ 4226 /** sub-action list specific for the sampling hit cases. */ 4227 const struct rte_flow_action *actions; 4228 }; 4229 4230 /** 4231 * Verbose error types. 4232 * 4233 * Most of them provide the type of the object referenced by struct 4234 * rte_flow_error.cause. 4235 */ 4236 enum rte_flow_error_type { 4237 RTE_FLOW_ERROR_TYPE_NONE, /**< No error. */ 4238 RTE_FLOW_ERROR_TYPE_UNSPECIFIED, /**< Cause unspecified. */ 4239 RTE_FLOW_ERROR_TYPE_HANDLE, /**< Flow rule (handle). */ 4240 RTE_FLOW_ERROR_TYPE_ATTR_GROUP, /**< Group field. */ 4241 RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY, /**< Priority field. */ 4242 RTE_FLOW_ERROR_TYPE_ATTR_INGRESS, /**< Ingress field. */ 4243 RTE_FLOW_ERROR_TYPE_ATTR_EGRESS, /**< Egress field. */ 4244 RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, /**< Transfer field. */ 4245 RTE_FLOW_ERROR_TYPE_ATTR, /**< Attributes structure. */ 4246 RTE_FLOW_ERROR_TYPE_ITEM_NUM, /**< Pattern length. */ 4247 RTE_FLOW_ERROR_TYPE_ITEM_SPEC, /**< Item specification. */ 4248 RTE_FLOW_ERROR_TYPE_ITEM_LAST, /**< Item specification range. */ 4249 RTE_FLOW_ERROR_TYPE_ITEM_MASK, /**< Item specification mask. */ 4250 RTE_FLOW_ERROR_TYPE_ITEM, /**< Specific pattern item. */ 4251 RTE_FLOW_ERROR_TYPE_ACTION_NUM, /**< Number of actions. */ 4252 RTE_FLOW_ERROR_TYPE_ACTION_CONF, /**< Action configuration. */ 4253 RTE_FLOW_ERROR_TYPE_ACTION, /**< Specific action. */ 4254 RTE_FLOW_ERROR_TYPE_STATE, /**< Current device state. */ 4255 }; 4256 4257 /** 4258 * Verbose error structure definition. 4259 * 4260 * This object is normally allocated by applications and set by PMDs, the 4261 * message points to a constant string which does not need to be freed by 4262 * the application, however its pointer can be considered valid only as long 4263 * as its associated DPDK port remains configured. Closing the underlying 4264 * device or unloading the PMD invalidates it. 4265 * 4266 * Both cause and message may be NULL regardless of the error type. 4267 */ 4268 struct rte_flow_error { 4269 enum rte_flow_error_type type; /**< Cause field and error types. */ 4270 const void *cause; /**< Object responsible for the error. */ 4271 const char *message; /**< Human-readable error message. */ 4272 }; 4273 4274 /** 4275 * Complete flow rule description. 4276 * 4277 * This object type is used when converting a flow rule description. 4278 * 4279 * @see RTE_FLOW_CONV_OP_RULE 4280 * @see rte_flow_conv() 4281 */ 4282 struct rte_flow_conv_rule { 4283 union { 4284 const struct rte_flow_attr *attr_ro; /**< RO attributes. */ 4285 struct rte_flow_attr *attr; /**< Attributes. */ 4286 }; 4287 union { 4288 const struct rte_flow_item *pattern_ro; /**< RO pattern. */ 4289 struct rte_flow_item *pattern; /**< Pattern items. */ 4290 }; 4291 union { 4292 const struct rte_flow_action *actions_ro; /**< RO actions. */ 4293 struct rte_flow_action *actions; /**< List of actions. */ 4294 }; 4295 }; 4296 4297 /** 4298 * Conversion operations for flow API objects. 4299 * 4300 * @see rte_flow_conv() 4301 */ 4302 enum rte_flow_conv_op { 4303 /** 4304 * No operation to perform. 4305 * 4306 * rte_flow_conv() simply returns 0. 4307 */ 4308 RTE_FLOW_CONV_OP_NONE, 4309 4310 /** 4311 * Convert attributes structure. 4312 * 4313 * This is a basic copy of an attributes structure. 4314 * 4315 * - @p src type: 4316 * @code const struct rte_flow_attr * @endcode 4317 * - @p dst type: 4318 * @code struct rte_flow_attr * @endcode 4319 */ 4320 RTE_FLOW_CONV_OP_ATTR, 4321 4322 /** 4323 * Convert a single item. 4324 * 4325 * Duplicates @p spec, @p last and @p mask but not outside objects. 4326 * 4327 * - @p src type: 4328 * @code const struct rte_flow_item * @endcode 4329 * - @p dst type: 4330 * @code struct rte_flow_item * @endcode 4331 */ 4332 RTE_FLOW_CONV_OP_ITEM, 4333 4334 /** 4335 * Convert a single action. 4336 * 4337 * Duplicates @p conf but not outside objects. 4338 * 4339 * - @p src type: 4340 * @code const struct rte_flow_action * @endcode 4341 * - @p dst type: 4342 * @code struct rte_flow_action * @endcode 4343 */ 4344 RTE_FLOW_CONV_OP_ACTION, 4345 4346 /** 4347 * Convert an entire pattern. 4348 * 4349 * Duplicates all pattern items at once with the same constraints as 4350 * RTE_FLOW_CONV_OP_ITEM. 4351 * 4352 * - @p src type: 4353 * @code const struct rte_flow_item * @endcode 4354 * - @p dst type: 4355 * @code struct rte_flow_item * @endcode 4356 */ 4357 RTE_FLOW_CONV_OP_PATTERN, 4358 4359 /** 4360 * Convert a list of actions. 4361 * 4362 * Duplicates the entire list of actions at once with the same 4363 * constraints as RTE_FLOW_CONV_OP_ACTION. 4364 * 4365 * - @p src type: 4366 * @code const struct rte_flow_action * @endcode 4367 * - @p dst type: 4368 * @code struct rte_flow_action * @endcode 4369 */ 4370 RTE_FLOW_CONV_OP_ACTIONS, 4371 4372 /** 4373 * Convert a complete flow rule description. 4374 * 4375 * Comprises attributes, pattern and actions together at once with 4376 * the usual constraints. 4377 * 4378 * - @p src type: 4379 * @code const struct rte_flow_conv_rule * @endcode 4380 * - @p dst type: 4381 * @code struct rte_flow_conv_rule * @endcode 4382 */ 4383 RTE_FLOW_CONV_OP_RULE, 4384 4385 /** 4386 * Convert item type to its name string. 4387 * 4388 * Writes a NUL-terminated string to @p dst. Like snprintf(), the 4389 * returned value excludes the terminator which is always written 4390 * nonetheless. 4391 * 4392 * - @p src type: 4393 * @code (const void *)enum rte_flow_item_type @endcode 4394 * - @p dst type: 4395 * @code char * @endcode 4396 */ 4397 RTE_FLOW_CONV_OP_ITEM_NAME, 4398 4399 /** 4400 * Convert action type to its name string. 4401 * 4402 * Writes a NUL-terminated string to @p dst. Like snprintf(), the 4403 * returned value excludes the terminator which is always written 4404 * nonetheless. 4405 * 4406 * - @p src type: 4407 * @code (const void *)enum rte_flow_action_type @endcode 4408 * - @p dst type: 4409 * @code char * @endcode 4410 */ 4411 RTE_FLOW_CONV_OP_ACTION_NAME, 4412 4413 /** 4414 * Convert item type to pointer to item name. 4415 * 4416 * Retrieves item name pointer from its type. The string itself is 4417 * not copied; instead, a unique pointer to an internal static 4418 * constant storage is written to @p dst. 4419 * 4420 * - @p src type: 4421 * @code (const void *)enum rte_flow_item_type @endcode 4422 * - @p dst type: 4423 * @code const char ** @endcode 4424 */ 4425 RTE_FLOW_CONV_OP_ITEM_NAME_PTR, 4426 4427 /** 4428 * Convert action type to pointer to action name. 4429 * 4430 * Retrieves action name pointer from its type. The string itself is 4431 * not copied; instead, a unique pointer to an internal static 4432 * constant storage is written to @p dst. 4433 * 4434 * - @p src type: 4435 * @code (const void *)enum rte_flow_action_type @endcode 4436 * - @p dst type: 4437 * @code const char ** @endcode 4438 */ 4439 RTE_FLOW_CONV_OP_ACTION_NAME_PTR, 4440 }; 4441 4442 /** 4443 * @warning 4444 * @b EXPERIMENTAL: this API may change without prior notice. 4445 * 4446 * Dump hardware internal representation information of 4447 * rte flow to file. 4448 * 4449 * @param[in] port_id 4450 * The port identifier of the Ethernet device. 4451 * @param[in] flow 4452 * The pointer of flow rule to dump. Dump all rules if NULL. 4453 * @param[in] file 4454 * A pointer to a file for output. 4455 * @param[out] error 4456 * Perform verbose error reporting if not NULL. PMDs initialize this 4457 * structure in case of error only. 4458 * @return 4459 * 0 on success, a negative value otherwise. 4460 */ 4461 __rte_experimental 4462 int 4463 rte_flow_dev_dump(uint16_t port_id, struct rte_flow *flow, 4464 FILE *file, struct rte_flow_error *error); 4465 4466 /** 4467 * Check if mbuf dynamic field for metadata is registered. 4468 * 4469 * @return 4470 * True if registered, false otherwise. 4471 */ 4472 __rte_experimental 4473 static inline int 4474 rte_flow_dynf_metadata_avail(void) 4475 { 4476 return !!rte_flow_dynf_metadata_mask; 4477 } 4478 4479 /** 4480 * Register mbuf dynamic field and flag for metadata. 4481 * 4482 * This function must be called prior to use SET_META action in order to 4483 * register the dynamic mbuf field. Otherwise, the data cannot be delivered to 4484 * application. 4485 * 4486 * @return 4487 * 0 on success, a negative errno value otherwise and rte_errno is set. 4488 */ 4489 __rte_experimental 4490 int 4491 rte_flow_dynf_metadata_register(void); 4492 4493 /** 4494 * Check whether a flow rule can be created on a given port. 4495 * 4496 * The flow rule is validated for correctness and whether it could be accepted 4497 * by the device given sufficient resources. The rule is checked against the 4498 * current device mode and queue configuration. The flow rule may also 4499 * optionally be validated against existing flow rules and device resources. 4500 * This function has no effect on the target device. 4501 * 4502 * The returned value is guaranteed to remain valid only as long as no 4503 * successful calls to rte_flow_create() or rte_flow_destroy() are made in 4504 * the meantime and no device parameter affecting flow rules in any way are 4505 * modified, due to possible collisions or resource limitations (although in 4506 * such cases EINVAL should not be returned). 4507 * 4508 * @param port_id 4509 * Port identifier of Ethernet device. 4510 * @param[in] attr 4511 * Flow rule attributes. 4512 * @param[in] pattern 4513 * Pattern specification (list terminated by the END pattern item). 4514 * @param[in] actions 4515 * Associated actions (list terminated by the END action). 4516 * @param[out] error 4517 * Perform verbose error reporting if not NULL. PMDs initialize this 4518 * structure in case of error only. 4519 * 4520 * @return 4521 * 0 if flow rule is valid and can be created. A negative errno value 4522 * otherwise (rte_errno is also set), the following errors are defined: 4523 * 4524 * -ENOSYS: underlying device does not support this functionality. 4525 * 4526 * -EIO: underlying device is removed. 4527 * 4528 * -EINVAL: unknown or invalid rule specification. 4529 * 4530 * -ENOTSUP: valid but unsupported rule specification (e.g. partial 4531 * bit-masks are unsupported). 4532 * 4533 * -EEXIST: collision with an existing rule. Only returned if device 4534 * supports flow rule collision checking and there was a flow rule 4535 * collision. Not receiving this return code is no guarantee that creating 4536 * the rule will not fail due to a collision. 4537 * 4538 * -ENOMEM: not enough memory to execute the function, or if the device 4539 * supports resource validation, resource limitation on the device. 4540 * 4541 * -EBUSY: action cannot be performed due to busy device resources, may 4542 * succeed if the affected queues or even the entire port are in a stopped 4543 * state (see rte_eth_dev_rx_queue_stop() and rte_eth_dev_stop()). 4544 */ 4545 int 4546 rte_flow_validate(uint16_t port_id, 4547 const struct rte_flow_attr *attr, 4548 const struct rte_flow_item pattern[], 4549 const struct rte_flow_action actions[], 4550 struct rte_flow_error *error); 4551 4552 /** 4553 * Create a flow rule on a given port. 4554 * 4555 * @param port_id 4556 * Port identifier of Ethernet device. 4557 * @param[in] attr 4558 * Flow rule attributes. 4559 * @param[in] pattern 4560 * Pattern specification (list terminated by the END pattern item). 4561 * @param[in] actions 4562 * Associated actions (list terminated by the END action). 4563 * @param[out] error 4564 * Perform verbose error reporting if not NULL. PMDs initialize this 4565 * structure in case of error only. 4566 * 4567 * @return 4568 * A valid handle in case of success, NULL otherwise and rte_errno is set 4569 * to the positive version of one of the error codes defined for 4570 * rte_flow_validate(). 4571 */ 4572 struct rte_flow * 4573 rte_flow_create(uint16_t port_id, 4574 const struct rte_flow_attr *attr, 4575 const struct rte_flow_item pattern[], 4576 const struct rte_flow_action actions[], 4577 struct rte_flow_error *error); 4578 4579 /** 4580 * Destroy a flow rule on a given port. 4581 * 4582 * Failure to destroy a flow rule handle may occur when other flow rules 4583 * depend on it, and destroying it would result in an inconsistent state. 4584 * 4585 * This function is only guaranteed to succeed if handles are destroyed in 4586 * reverse order of their creation. 4587 * 4588 * @param port_id 4589 * Port identifier of Ethernet device. 4590 * @param flow 4591 * Flow rule handle to destroy. 4592 * @param[out] error 4593 * Perform verbose error reporting if not NULL. PMDs initialize this 4594 * structure in case of error only. 4595 * 4596 * @return 4597 * 0 on success, a negative errno value otherwise and rte_errno is set. 4598 */ 4599 int 4600 rte_flow_destroy(uint16_t port_id, 4601 struct rte_flow *flow, 4602 struct rte_flow_error *error); 4603 4604 /** 4605 * Update a flow rule with new actions on a given port. 4606 * 4607 * @param port_id 4608 * Port identifier of Ethernet device. 4609 * @param flow 4610 * Flow rule handle to update. 4611 * @param[in] actions 4612 * Associated actions (list terminated by the END action). 4613 * @param[out] error 4614 * Perform verbose error reporting if not NULL. PMDs initialize this 4615 * structure in case of error only. 4616 * 4617 * @return 4618 * 0 on success, a negative errno value otherwise and rte_errno is set. 4619 */ 4620 __rte_experimental 4621 int 4622 rte_flow_actions_update(uint16_t port_id, 4623 struct rte_flow *flow, 4624 const struct rte_flow_action actions[], 4625 struct rte_flow_error *error); 4626 4627 /** 4628 * Destroy all flow rules associated with a port. 4629 * 4630 * In the unlikely event of failure, handles are still considered destroyed 4631 * and no longer valid but the port must be assumed to be in an inconsistent 4632 * state. 4633 * 4634 * @param port_id 4635 * Port identifier of Ethernet device. 4636 * @param[out] error 4637 * Perform verbose error reporting if not NULL. PMDs initialize this 4638 * structure in case of error only. 4639 * 4640 * @return 4641 * 0 on success, a negative errno value otherwise and rte_errno is set. 4642 */ 4643 int 4644 rte_flow_flush(uint16_t port_id, 4645 struct rte_flow_error *error); 4646 4647 /** 4648 * Query an existing flow rule. 4649 * 4650 * This function allows retrieving flow-specific data such as counters. 4651 * Data is gathered by special actions which must be present in the flow 4652 * rule definition. 4653 * 4654 * \see RTE_FLOW_ACTION_TYPE_COUNT 4655 * 4656 * @param port_id 4657 * Port identifier of Ethernet device. 4658 * @param flow 4659 * Flow rule handle to query. 4660 * @param action 4661 * Action definition as defined in original flow rule. 4662 * @param[in, out] data 4663 * Pointer to storage for the associated query data type. 4664 * @param[out] error 4665 * Perform verbose error reporting if not NULL. PMDs initialize this 4666 * structure in case of error only. 4667 * 4668 * @return 4669 * 0 on success, a negative errno value otherwise and rte_errno is set. 4670 */ 4671 int 4672 rte_flow_query(uint16_t port_id, 4673 struct rte_flow *flow, 4674 const struct rte_flow_action *action, 4675 void *data, 4676 struct rte_flow_error *error); 4677 4678 /** 4679 * Restrict ingress traffic to the defined flow rules. 4680 * 4681 * Isolated mode guarantees that all ingress traffic comes from defined flow 4682 * rules only (current and future). 4683 * When enabled with a bifurcated driver, 4684 * non-matched packets are routed to the kernel driver interface. 4685 * When disabled (the default), 4686 * there may be some default rules routing traffic to the DPDK port. 4687 * 4688 * Besides making ingress more deterministic, it allows PMDs to safely reuse 4689 * resources otherwise assigned to handle the remaining traffic, such as 4690 * global RSS configuration settings, VLAN filters, MAC address entries, 4691 * legacy filter API rules and so on in order to expand the set of possible 4692 * flow rule types. 4693 * 4694 * Calling this function as soon as possible after device initialization, 4695 * ideally before the first call to rte_eth_dev_configure(), is recommended 4696 * to avoid possible failures due to conflicting settings. 4697 * 4698 * Once effective, leaving isolated mode may not be possible depending on 4699 * PMD implementation. 4700 * 4701 * Additionally, the following functionality has no effect on the underlying 4702 * port and may return errors such as ENOTSUP ("not supported"): 4703 * 4704 * - Toggling promiscuous mode. 4705 * - Toggling allmulticast mode. 4706 * - Configuring MAC addresses. 4707 * - Configuring multicast addresses. 4708 * - Configuring VLAN filters. 4709 * - Configuring Rx filters through the legacy API (e.g. FDIR). 4710 * - Configuring global RSS settings. 4711 * 4712 * @param port_id 4713 * Port identifier of Ethernet device. 4714 * @param set 4715 * Nonzero to enter isolated mode, attempt to leave it otherwise. 4716 * @param[out] error 4717 * Perform verbose error reporting if not NULL. PMDs initialize this 4718 * structure in case of error only. 4719 * 4720 * @return 4721 * 0 on success, a negative errno value otherwise and rte_errno is set. 4722 */ 4723 int 4724 rte_flow_isolate(uint16_t port_id, int set, struct rte_flow_error *error); 4725 4726 /** 4727 * Initialize flow error structure. 4728 * 4729 * @param[out] error 4730 * Pointer to flow error structure (may be NULL). 4731 * @param code 4732 * Related error code (rte_errno). 4733 * @param type 4734 * Cause field and error types. 4735 * @param cause 4736 * Object responsible for the error. 4737 * @param message 4738 * Human-readable error message. 4739 * 4740 * @return 4741 * Negative error code (errno value) and rte_errno is set. 4742 */ 4743 int 4744 rte_flow_error_set(struct rte_flow_error *error, 4745 int code, 4746 enum rte_flow_error_type type, 4747 const void *cause, 4748 const char *message); 4749 4750 /** 4751 * @deprecated 4752 * @see rte_flow_copy() 4753 */ 4754 struct rte_flow_desc { 4755 size_t size; /**< Allocated space including data[]. */ 4756 struct rte_flow_attr attr; /**< Attributes. */ 4757 struct rte_flow_item *items; /**< Items. */ 4758 struct rte_flow_action *actions; /**< Actions. */ 4759 uint8_t data[]; /**< Storage for items/actions. */ 4760 }; 4761 4762 /** 4763 * @deprecated 4764 * Copy an rte_flow rule description. 4765 * 4766 * This interface is kept for compatibility with older applications but is 4767 * implemented as a wrapper to rte_flow_conv(). It is deprecated due to its 4768 * lack of flexibility and reliance on a type unusable with C++ programs 4769 * (struct rte_flow_desc). 4770 * 4771 * @param[in] fd 4772 * Flow rule description. 4773 * @param[in] len 4774 * Total size of allocated data for the flow description. 4775 * @param[in] attr 4776 * Flow rule attributes. 4777 * @param[in] items 4778 * Pattern specification (list terminated by the END pattern item). 4779 * @param[in] actions 4780 * Associated actions (list terminated by the END action). 4781 * 4782 * @return 4783 * If len is greater or equal to the size of the flow, the total size of the 4784 * flow description and its data. 4785 * If len is lower than the size of the flow, the number of bytes that would 4786 * have been written to desc had it been sufficient. Nothing is written. 4787 */ 4788 __rte_deprecated 4789 size_t 4790 rte_flow_copy(struct rte_flow_desc *fd, size_t len, 4791 const struct rte_flow_attr *attr, 4792 const struct rte_flow_item *items, 4793 const struct rte_flow_action *actions); 4794 4795 /** 4796 * Flow object conversion helper. 4797 * 4798 * This function performs conversion of various flow API objects to a 4799 * pre-allocated destination buffer. See enum rte_flow_conv_op for possible 4800 * operations and details about each of them. 4801 * 4802 * Since destination buffer must be large enough, it works in a manner 4803 * reminiscent of snprintf(): 4804 * 4805 * - If @p size is 0, @p dst may be a NULL pointer, otherwise @p dst must be 4806 * non-NULL. 4807 * - If positive, the returned value represents the number of bytes needed 4808 * to store the conversion of @p src to @p dst according to @p op 4809 * regardless of the @p size parameter. 4810 * - Since no more than @p size bytes can be written to @p dst, output is 4811 * truncated and may be inconsistent when the returned value is larger 4812 * than that. 4813 * - In case of conversion error, a negative error code is returned and 4814 * @p dst contents are unspecified. 4815 * 4816 * @param op 4817 * Operation to perform, related to the object type of @p dst. 4818 * @param[out] dst 4819 * Destination buffer address. Must be suitably aligned by the caller. 4820 * @param size 4821 * Destination buffer size in bytes. 4822 * @param[in] src 4823 * Source object to copy. Depending on @p op, its type may differ from 4824 * that of @p dst. 4825 * @param[out] error 4826 * Perform verbose error reporting if not NULL. Initialized in case of 4827 * error only. 4828 * 4829 * @return 4830 * The number of bytes required to convert @p src to @p dst on success, a 4831 * negative errno value otherwise and rte_errno is set. 4832 * 4833 * @see rte_flow_conv_op 4834 */ 4835 __rte_experimental 4836 int 4837 rte_flow_conv(enum rte_flow_conv_op op, 4838 void *dst, 4839 size_t size, 4840 const void *src, 4841 struct rte_flow_error *error); 4842 4843 /** 4844 * Get aged-out flows of a given port. 4845 * 4846 * RTE_ETH_EVENT_FLOW_AGED event will be triggered when at least one new aged 4847 * out flow was detected after the last call to rte_flow_get_aged_flows. 4848 * This function can be called to get the aged flows asynchronously from the 4849 * event callback or synchronously regardless the event. 4850 * This is not safe to call rte_flow_get_aged_flows function with other flow 4851 * functions from multiple threads simultaneously. 4852 * 4853 * @param port_id 4854 * Port identifier of Ethernet device. 4855 * @param[in, out] contexts 4856 * The address of an array of pointers to the aged-out flows contexts. 4857 * @param[in] nb_contexts 4858 * The length of context array pointers. 4859 * @param[out] error 4860 * Perform verbose error reporting if not NULL. Initialized in case of 4861 * error only. 4862 * 4863 * @return 4864 * if nb_contexts is 0, return the amount of all aged contexts. 4865 * if nb_contexts is not 0 , return the amount of aged flows reported 4866 * in the context array, otherwise negative errno value. 4867 * 4868 * @see rte_flow_action_age 4869 * @see RTE_ETH_EVENT_FLOW_AGED 4870 */ 4871 __rte_experimental 4872 int 4873 rte_flow_get_aged_flows(uint16_t port_id, void **contexts, 4874 uint32_t nb_contexts, struct rte_flow_error *error); 4875 4876 /** 4877 * @warning 4878 * @b EXPERIMENTAL: this API may change without prior notice. 4879 * 4880 * Get aged-out flows of a given port on the given flow queue. 4881 * 4882 * If application configure port attribute with RTE_FLOW_PORT_FLAG_STRICT_QUEUE, 4883 * there is no RTE_ETH_EVENT_FLOW_AGED event and this function must be called to 4884 * get the aged flows synchronously. 4885 * 4886 * If application configure port attribute without 4887 * RTE_FLOW_PORT_FLAG_STRICT_QUEUE, RTE_ETH_EVENT_FLOW_AGED event will be 4888 * triggered at least one new aged out flow was detected on any flow queue after 4889 * the last call to rte_flow_get_q_aged_flows. 4890 * In addition, the @p queue_id will be ignored. 4891 * This function can be called to get the aged flows asynchronously from the 4892 * event callback or synchronously regardless the event. 4893 * 4894 * @param[in] port_id 4895 * Port identifier of Ethernet device. 4896 * @param[in] queue_id 4897 * Flow queue to query. Ignored when RTE_FLOW_PORT_FLAG_STRICT_QUEUE not set. 4898 * @param[in, out] contexts 4899 * The address of an array of pointers to the aged-out flows contexts. 4900 * @param[in] nb_contexts 4901 * The length of context array pointers. 4902 * @param[out] error 4903 * Perform verbose error reporting if not NULL. Initialized in case of 4904 * error only. 4905 * 4906 * @return 4907 * if nb_contexts is 0, return the amount of all aged contexts. 4908 * if nb_contexts is not 0 , return the amount of aged flows reported 4909 * in the context array, otherwise negative errno value. 4910 * 4911 * @see rte_flow_action_age 4912 * @see RTE_ETH_EVENT_FLOW_AGED 4913 * @see rte_flow_port_flag 4914 */ 4915 __rte_experimental 4916 int 4917 rte_flow_get_q_aged_flows(uint16_t port_id, uint32_t queue_id, void **contexts, 4918 uint32_t nb_contexts, struct rte_flow_error *error); 4919 4920 /** 4921 * Specify indirect action object configuration 4922 */ 4923 struct rte_flow_indir_action_conf { 4924 /** 4925 * Flow direction for the indirect action configuration. 4926 * 4927 * Action should be valid at least for one flow direction, 4928 * otherwise it is invalid for both ingress and egress rules. 4929 */ 4930 /** Action valid for rules applied to ingress traffic. */ 4931 uint32_t ingress:1; 4932 /** Action valid for rules applied to egress traffic. */ 4933 uint32_t egress:1; 4934 /** 4935 * When set to 1, indicates that the action is valid for 4936 * transfer traffic; otherwise, for non-transfer traffic. 4937 */ 4938 uint32_t transfer:1; 4939 }; 4940 4941 /** 4942 * @warning 4943 * @b EXPERIMENTAL: this API may change without prior notice. 4944 * 4945 * Create an indirect action object that can be used in flow rules 4946 * via its handle. 4947 * The created object handle has single state and configuration 4948 * across all the flow rules using it. 4949 * 4950 * @param[in] port_id 4951 * The port identifier of the Ethernet device. 4952 * @param[in] conf 4953 * Action configuration for the indirect action object creation. 4954 * @param[in] action 4955 * Specific configuration of the indirect action object. 4956 * @param[out] error 4957 * Perform verbose error reporting if not NULL. PMDs initialize this 4958 * structure in case of error only. 4959 * @return 4960 * A valid handle in case of success, NULL otherwise and rte_errno is set 4961 * to one of the error codes defined: 4962 * - (ENODEV) if *port_id* invalid. 4963 * - (ENOSYS) if underlying device does not support this functionality. 4964 * - (EIO) if underlying device is removed. 4965 * - (EINVAL) if *action* invalid. 4966 * - (ENOTSUP) if *action* valid but unsupported. 4967 */ 4968 __rte_experimental 4969 struct rte_flow_action_handle * 4970 rte_flow_action_handle_create(uint16_t port_id, 4971 const struct rte_flow_indir_action_conf *conf, 4972 const struct rte_flow_action *action, 4973 struct rte_flow_error *error); 4974 4975 /** 4976 * @warning 4977 * @b EXPERIMENTAL: this API may change without prior notice. 4978 * 4979 * Destroy indirect action by handle. 4980 * 4981 * @param[in] port_id 4982 * The port identifier of the Ethernet device. 4983 * @param[in] handle 4984 * Handle for the indirect action object to be destroyed. 4985 * @param[out] error 4986 * Perform verbose error reporting if not NULL. PMDs initialize this 4987 * structure in case of error only. 4988 * @return 4989 * - (0) if success. 4990 * - (-ENODEV) if *port_id* invalid. 4991 * - (-ENOSYS) if underlying device does not support this functionality. 4992 * - (-EIO) if underlying device is removed. 4993 * - (-ENOENT) if action pointed by *action* handle was not found. 4994 * - (-EBUSY) if action pointed by *action* handle still used by some rules 4995 * rte_errno is also set. 4996 */ 4997 __rte_experimental 4998 int 4999 rte_flow_action_handle_destroy(uint16_t port_id, 5000 struct rte_flow_action_handle *handle, 5001 struct rte_flow_error *error); 5002 5003 /** 5004 * @warning 5005 * @b EXPERIMENTAL: this API may change without prior notice. 5006 * 5007 * Update in-place the action configuration and / or state pointed 5008 * by action *handle* with the configuration provided as *update* argument. 5009 * The update of the action configuration effects all flow rules reusing 5010 * the action via *handle*. 5011 * The update general pointer provides the ability of partial updating. 5012 * 5013 * @param[in] port_id 5014 * The port identifier of the Ethernet device. 5015 * @param[in] handle 5016 * Handle for the indirect action object to be updated. 5017 * @param[in] update 5018 * Update profile specification used to modify the action pointed by handle. 5019 * *update* could be with the same type of the immediate action corresponding 5020 * to the *handle* argument when creating, or a wrapper structure includes 5021 * action configuration to be updated and bit fields to indicate the member 5022 * of fields inside the action to update. 5023 * @param[out] error 5024 * Perform verbose error reporting if not NULL. PMDs initialize this 5025 * structure in case of error only. 5026 * @return 5027 * - (0) if success. 5028 * - (-ENODEV) if *port_id* invalid. 5029 * - (-ENOSYS) if underlying device does not support this functionality. 5030 * - (-EIO) if underlying device is removed. 5031 * - (-EINVAL) if *update* invalid. 5032 * - (-ENOTSUP) if *update* valid but unsupported. 5033 * - (-ENOENT) if indirect action object pointed by *handle* was not found. 5034 * rte_errno is also set. 5035 */ 5036 __rte_experimental 5037 int 5038 rte_flow_action_handle_update(uint16_t port_id, 5039 struct rte_flow_action_handle *handle, 5040 const void *update, 5041 struct rte_flow_error *error); 5042 5043 /** 5044 * @warning 5045 * @b EXPERIMENTAL: this API may change without prior notice. 5046 * 5047 * Query the direct action by corresponding indirect action object handle. 5048 * 5049 * Retrieve action-specific data such as counters. 5050 * Data is gathered by special action which may be present/referenced in 5051 * more than one flow rule definition. 5052 * 5053 * @see RTE_FLOW_ACTION_TYPE_COUNT 5054 * 5055 * @param port_id 5056 * Port identifier of Ethernet device. 5057 * @param[in] handle 5058 * Handle for the action object to query. 5059 * @param[in, out] data 5060 * Pointer to storage for the associated query data type. 5061 * @param[out] error 5062 * Perform verbose error reporting if not NULL. PMDs initialize this 5063 * structure in case of error only. 5064 * 5065 * @return 5066 * 0 on success, a negative errno value otherwise and rte_errno is set. 5067 */ 5068 __rte_experimental 5069 int 5070 rte_flow_action_handle_query(uint16_t port_id, 5071 const struct rte_flow_action_handle *handle, 5072 void *data, struct rte_flow_error *error); 5073 5074 /* Tunnel has a type and the key information. */ 5075 struct rte_flow_tunnel { 5076 /** 5077 * Tunnel type, for example RTE_FLOW_ITEM_TYPE_VXLAN, 5078 * RTE_FLOW_ITEM_TYPE_NVGRE etc. 5079 */ 5080 enum rte_flow_item_type type; 5081 uint64_t tun_id; /**< Tunnel identification. */ 5082 5083 union { 5084 struct { 5085 rte_be32_t src_addr; /**< IPv4 source address. */ 5086 rte_be32_t dst_addr; /**< IPv4 destination address. */ 5087 } ipv4; 5088 struct { 5089 uint8_t src_addr[16]; /**< IPv6 source address. */ 5090 uint8_t dst_addr[16]; /**< IPv6 destination address. */ 5091 } ipv6; 5092 }; 5093 rte_be16_t tp_src; /**< Tunnel port source. */ 5094 rte_be16_t tp_dst; /**< Tunnel port destination. */ 5095 uint16_t tun_flags; /**< Tunnel flags. */ 5096 5097 bool is_ipv6; /**< True for valid IPv6 fields. Otherwise IPv4. */ 5098 5099 /** 5100 * the following members are required to restore packet 5101 * after miss 5102 */ 5103 uint8_t tos; /**< TOS for IPv4, TC for IPv6. */ 5104 uint8_t ttl; /**< TTL for IPv4, HL for IPv6. */ 5105 uint32_t label; /**< Flow Label for IPv6. */ 5106 }; 5107 5108 /** 5109 * Indicate that the packet has a tunnel. 5110 */ 5111 #define RTE_FLOW_RESTORE_INFO_TUNNEL RTE_BIT64(0) 5112 5113 /** 5114 * Indicate that the packet has a non decapsulated tunnel header. 5115 */ 5116 #define RTE_FLOW_RESTORE_INFO_ENCAPSULATED RTE_BIT64(1) 5117 5118 /** 5119 * Indicate that the packet has a group_id. 5120 */ 5121 #define RTE_FLOW_RESTORE_INFO_GROUP_ID RTE_BIT64(2) 5122 5123 /** 5124 * Restore information structure to communicate the current packet processing 5125 * state when some of the processing pipeline is done in hardware and should 5126 * continue in software. 5127 */ 5128 struct rte_flow_restore_info { 5129 /** 5130 * Bitwise flags (RTE_FLOW_RESTORE_INFO_*) to indicate validation of 5131 * other fields in struct rte_flow_restore_info. 5132 */ 5133 uint64_t flags; 5134 uint32_t group_id; /**< Group ID where packed missed */ 5135 struct rte_flow_tunnel tunnel; /**< Tunnel information. */ 5136 }; 5137 5138 /** 5139 * Allocate an array of actions to be used in rte_flow_create, to implement 5140 * tunnel-decap-set for the given tunnel. 5141 * Sample usage: 5142 * actions vxlan_decap / tunnel-decap-set(tunnel properties) / 5143 * jump group 0 / end 5144 * 5145 * @param port_id 5146 * Port identifier of Ethernet device. 5147 * @param[in] tunnel 5148 * Tunnel properties. 5149 * @param[out] actions 5150 * Array of actions to be allocated by the PMD. This array should be 5151 * concatenated with the actions array provided to rte_flow_create. 5152 * @param[out] num_of_actions 5153 * Number of actions allocated. 5154 * @param[out] error 5155 * Perform verbose error reporting if not NULL. PMDs initialize this 5156 * structure in case of error only. 5157 * 5158 * @return 5159 * 0 on success, a negative errno value otherwise and rte_errno is set. 5160 */ 5161 __rte_experimental 5162 int 5163 rte_flow_tunnel_decap_set(uint16_t port_id, 5164 struct rte_flow_tunnel *tunnel, 5165 struct rte_flow_action **actions, 5166 uint32_t *num_of_actions, 5167 struct rte_flow_error *error); 5168 5169 /** 5170 * Allocate an array of items to be used in rte_flow_create, to implement 5171 * tunnel-match for the given tunnel. 5172 * Sample usage: 5173 * pattern tunnel-match(tunnel properties) / outer-header-matches / 5174 * inner-header-matches / end 5175 * 5176 * @param port_id 5177 * Port identifier of Ethernet device. 5178 * @param[in] tunnel 5179 * Tunnel properties. 5180 * @param[out] items 5181 * Array of items to be allocated by the PMD. This array should be 5182 * concatenated with the items array provided to rte_flow_create. 5183 * @param[out] num_of_items 5184 * Number of items allocated. 5185 * @param[out] error 5186 * Perform verbose error reporting if not NULL. PMDs initialize this 5187 * structure in case of error only. 5188 * 5189 * @return 5190 * 0 on success, a negative errno value otherwise and rte_errno is set. 5191 */ 5192 __rte_experimental 5193 int 5194 rte_flow_tunnel_match(uint16_t port_id, 5195 struct rte_flow_tunnel *tunnel, 5196 struct rte_flow_item **items, 5197 uint32_t *num_of_items, 5198 struct rte_flow_error *error); 5199 5200 /** 5201 * On reception of a mbuf from HW, a call to rte_flow_get_restore_info() may be 5202 * required to retrieve some metadata. 5203 * This function returns the associated mbuf ol_flags. 5204 * 5205 * Note: the dynamic flag is registered during a call to 5206 * rte_eth_rx_metadata_negotiate() with RTE_ETH_RX_METADATA_TUNNEL_ID. 5207 * 5208 * @return 5209 * The offload flag indicating rte_flow_get_restore_info() must be called. 5210 */ 5211 __rte_experimental 5212 uint64_t 5213 rte_flow_restore_info_dynflag(void); 5214 5215 /** 5216 * If a mbuf contains the rte_flow_restore_info_dynflag() flag in ol_flags, 5217 * populate the current packet processing state. 5218 * 5219 * One should negotiate tunnel metadata delivery from the NIC to the HW. 5220 * @see rte_eth_rx_metadata_negotiate() 5221 * @see RTE_ETH_RX_METADATA_TUNNEL_ID 5222 * 5223 * @param port_id 5224 * Port identifier of Ethernet device. 5225 * @param[in] m 5226 * Mbuf struct. 5227 * @param[out] info 5228 * Restore information. Upon success contains the HW state. 5229 * @param[out] error 5230 * Perform verbose error reporting if not NULL. PMDs initialize this 5231 * structure in case of error only. 5232 * 5233 * @return 5234 * 0 on success, a negative errno value otherwise and rte_errno is set. 5235 */ 5236 __rte_experimental 5237 int 5238 rte_flow_get_restore_info(uint16_t port_id, 5239 struct rte_mbuf *m, 5240 struct rte_flow_restore_info *info, 5241 struct rte_flow_error *error); 5242 5243 /** 5244 * Release the action array as allocated by rte_flow_tunnel_decap_set. 5245 * 5246 * @param port_id 5247 * Port identifier of Ethernet device. 5248 * @param[in] actions 5249 * Array of actions to be released. 5250 * @param[in] num_of_actions 5251 * Number of elements in actions array. 5252 * @param[out] error 5253 * Perform verbose error reporting if not NULL. PMDs initialize this 5254 * structure in case of error only. 5255 * 5256 * @return 5257 * 0 on success, a negative errno value otherwise and rte_errno is set. 5258 */ 5259 __rte_experimental 5260 int 5261 rte_flow_tunnel_action_decap_release(uint16_t port_id, 5262 struct rte_flow_action *actions, 5263 uint32_t num_of_actions, 5264 struct rte_flow_error *error); 5265 5266 /** 5267 * Release the item array as allocated by rte_flow_tunnel_match. 5268 * 5269 * @param port_id 5270 * Port identifier of Ethernet device. 5271 * @param[in] items 5272 * Array of items to be released. 5273 * @param[in] num_of_items 5274 * Number of elements in item array. 5275 * @param[out] error 5276 * Perform verbose error reporting if not NULL. PMDs initialize this 5277 * structure in case of error only. 5278 * 5279 * @return 5280 * 0 on success, a negative errno value otherwise and rte_errno is set. 5281 */ 5282 __rte_experimental 5283 int 5284 rte_flow_tunnel_item_release(uint16_t port_id, 5285 struct rte_flow_item *items, 5286 uint32_t num_of_items, 5287 struct rte_flow_error *error); 5288 5289 /** 5290 * Get a proxy port to manage "transfer" flows. 5291 * 5292 * Managing "transfer" flows requires that the user communicate them 5293 * via a port which has the privilege to control the embedded switch. 5294 * For some vendors, all ports in a given switching domain have 5295 * this privilege. For other vendors, it's only one port. 5296 * 5297 * This API indicates such a privileged port (a "proxy") 5298 * for a given port in the same switching domain. 5299 * 5300 * @note 5301 * If the PMD serving @p port_id doesn't have the corresponding method 5302 * implemented, the API will return @p port_id via @p proxy_port_id. 5303 * 5304 * @param port_id 5305 * Indicates the port to get a "proxy" for 5306 * @param[out] proxy_port_id 5307 * Indicates the "proxy" port 5308 * @param[out] error 5309 * If not NULL, allows the PMD to provide verbose report in case of error 5310 * 5311 * @return 5312 * 0 on success, a negative error code otherwise 5313 */ 5314 int 5315 rte_flow_pick_transfer_proxy(uint16_t port_id, uint16_t *proxy_port_id, 5316 struct rte_flow_error *error); 5317 5318 /** 5319 * @warning 5320 * @b EXPERIMENTAL: this API may change without prior notice. 5321 * 5322 * Create the flex item with specified configuration over 5323 * the Ethernet device. 5324 * 5325 * @param port_id 5326 * Port identifier of Ethernet device. 5327 * @param[in] conf 5328 * Item configuration. 5329 * @param[out] error 5330 * Perform verbose error reporting if not NULL. PMDs initialize this 5331 * structure in case of error only. 5332 * 5333 * @return 5334 * Non-NULL opaque pointer on success, NULL otherwise and rte_errno is set. 5335 */ 5336 __rte_experimental 5337 struct rte_flow_item_flex_handle * 5338 rte_flow_flex_item_create(uint16_t port_id, 5339 const struct rte_flow_item_flex_conf *conf, 5340 struct rte_flow_error *error); 5341 5342 /** 5343 * Release the flex item on the specified Ethernet device. 5344 * 5345 * @param port_id 5346 * Port identifier of Ethernet device. 5347 * @param[in] handle 5348 * Handle of the item existing on the specified device. 5349 * @param[out] error 5350 * Perform verbose error reporting if not NULL. PMDs initialize this 5351 * structure in case of error only. 5352 * 5353 * @return 5354 * 0 on success, a negative errno value otherwise and rte_errno is set. 5355 */ 5356 __rte_experimental 5357 int 5358 rte_flow_flex_item_release(uint16_t port_id, 5359 const struct rte_flow_item_flex_handle *handle, 5360 struct rte_flow_error *error); 5361 5362 /** 5363 * Indicate all operations for a given flow rule will _strictly_ 5364 * happen on the same queue (create/destroy/query/update). 5365 */ 5366 #define RTE_FLOW_PORT_FLAG_STRICT_QUEUE RTE_BIT32(0) 5367 5368 /** 5369 * @warning 5370 * @b EXPERIMENTAL: this API may change without prior notice. 5371 * 5372 * Information about flow engine resources. 5373 * The zero value means a resource is not supported. 5374 */ 5375 struct rte_flow_port_info { 5376 /** 5377 * Maximum number of queues for asynchronous operations. 5378 */ 5379 uint32_t max_nb_queues; 5380 /** 5381 * Maximum number of counters. 5382 * @see RTE_FLOW_ACTION_TYPE_COUNT 5383 */ 5384 uint32_t max_nb_counters; 5385 /** 5386 * Maximum number of aging objects. 5387 * @see RTE_FLOW_ACTION_TYPE_AGE 5388 */ 5389 uint32_t max_nb_aging_objects; 5390 /** 5391 * Maximum number traffic meters. 5392 * @see RTE_FLOW_ACTION_TYPE_METER 5393 */ 5394 uint32_t max_nb_meters; 5395 /** 5396 * Maximum number connection trackings. 5397 * @see RTE_FLOW_ACTION_TYPE_CONNTRACK 5398 */ 5399 uint32_t max_nb_conn_tracks; 5400 /** 5401 * Maximum number of quota actions. 5402 * @see RTE_FLOW_ACTION_TYPE_QUOTA 5403 */ 5404 uint32_t max_nb_quotas; 5405 /** 5406 * Port supported flags (RTE_FLOW_PORT_FLAG_*). 5407 */ 5408 uint32_t supported_flags; 5409 }; 5410 5411 /** 5412 * @warning 5413 * @b EXPERIMENTAL: this API may change without prior notice. 5414 * 5415 * Information about flow engine asynchronous queues. 5416 * The value only valid if @p port_attr.max_nb_queues is not zero. 5417 */ 5418 struct rte_flow_queue_info { 5419 /** 5420 * Maximum number of operations a queue can hold. 5421 */ 5422 uint32_t max_size; 5423 }; 5424 5425 /** 5426 * @warning 5427 * @b EXPERIMENTAL: this API may change without prior notice. 5428 * 5429 * Get information about flow engine resources. 5430 * 5431 * @param port_id 5432 * Port identifier of Ethernet device. 5433 * @param[out] port_info 5434 * A pointer to a structure of type *rte_flow_port_info* 5435 * to be filled with the resources information of the port. 5436 * @param[out] queue_info 5437 * A pointer to a structure of type *rte_flow_queue_info* 5438 * to be filled with the asynchronous queues information. 5439 * @param[out] error 5440 * Perform verbose error reporting if not NULL. 5441 * PMDs initialize this structure in case of error only. 5442 * 5443 * @return 5444 * 0 on success, a negative errno value otherwise and rte_errno is set. 5445 */ 5446 __rte_experimental 5447 int 5448 rte_flow_info_get(uint16_t port_id, 5449 struct rte_flow_port_info *port_info, 5450 struct rte_flow_queue_info *queue_info, 5451 struct rte_flow_error *error); 5452 5453 /** 5454 * Indicate all steering objects should be created on contexts 5455 * of the host port, providing indirect object sharing between 5456 * ports. 5457 */ 5458 #define RTE_FLOW_PORT_FLAG_SHARE_INDIRECT RTE_BIT32(0) 5459 5460 /** 5461 * @warning 5462 * @b EXPERIMENTAL: this API may change without prior notice. 5463 * 5464 * Flow engine resources settings. 5465 * The zero value means on demand resource allocations only. 5466 */ 5467 struct rte_flow_port_attr { 5468 /** 5469 * Number of counters to configure. 5470 * @see RTE_FLOW_ACTION_TYPE_COUNT 5471 */ 5472 uint32_t nb_counters; 5473 /** 5474 * Number of aging objects to configure. 5475 * @see RTE_FLOW_ACTION_TYPE_AGE 5476 */ 5477 uint32_t nb_aging_objects; 5478 /** 5479 * Number of traffic meters to configure. 5480 * @see RTE_FLOW_ACTION_TYPE_METER 5481 */ 5482 uint32_t nb_meters; 5483 /** 5484 * Number of connection trackings to configure. 5485 * @see RTE_FLOW_ACTION_TYPE_CONNTRACK 5486 */ 5487 uint32_t nb_conn_tracks; 5488 /** 5489 * Port to base shared objects on. 5490 */ 5491 uint16_t host_port_id; 5492 /** 5493 * Maximum number of quota actions. 5494 * @see RTE_FLOW_ACTION_TYPE_QUOTA 5495 */ 5496 uint32_t nb_quotas; 5497 /** 5498 * Port flags (RTE_FLOW_PORT_FLAG_*). 5499 */ 5500 uint32_t flags; 5501 }; 5502 5503 /** 5504 * @warning 5505 * @b EXPERIMENTAL: this API may change without prior notice. 5506 * 5507 * Flow engine asynchronous queues settings. 5508 * The value means default value picked by PMD. 5509 */ 5510 struct rte_flow_queue_attr { 5511 /** 5512 * Number of flow rule operations a queue can hold. 5513 */ 5514 uint32_t size; 5515 }; 5516 5517 /** 5518 * @warning 5519 * @b EXPERIMENTAL: this API may change without prior notice. 5520 * 5521 * Configure the port's flow API engine. 5522 * 5523 * This API can only be invoked before the application 5524 * starts using the rest of the flow library functions. 5525 * 5526 * The API can be invoked multiple times to change the settings. 5527 * The port, however, may reject changes and keep the old config. 5528 * 5529 * Parameters in configuration attributes must not exceed 5530 * numbers of resources returned by the rte_flow_info_get API. 5531 * 5532 * @param port_id 5533 * Port identifier of Ethernet device. 5534 * @param[in] port_attr 5535 * Port configuration attributes. 5536 * @param[in] nb_queue 5537 * Number of flow queues to be configured. 5538 * @param[in] queue_attr 5539 * Array that holds attributes for each flow queue. 5540 * Number of elements is set in @p port_attr.nb_queues. 5541 * @param[out] error 5542 * Perform verbose error reporting if not NULL. 5543 * PMDs initialize this structure in case of error only. 5544 * 5545 * @return 5546 * 0 on success, a negative errno value otherwise and rte_errno is set. 5547 */ 5548 __rte_experimental 5549 int 5550 rte_flow_configure(uint16_t port_id, 5551 const struct rte_flow_port_attr *port_attr, 5552 uint16_t nb_queue, 5553 const struct rte_flow_queue_attr *queue_attr[], 5554 struct rte_flow_error *error); 5555 5556 /** 5557 * Opaque type returned after successful creation of pattern template. 5558 * This handle can be used to manage the created pattern template. 5559 */ 5560 struct rte_flow_pattern_template; 5561 5562 /** 5563 * @warning 5564 * @b EXPERIMENTAL: this API may change without prior notice. 5565 * 5566 * Flow pattern template attributes. 5567 */ 5568 __extension__ 5569 struct rte_flow_pattern_template_attr { 5570 /** 5571 * Relaxed matching policy. 5572 * - If 1, matching is performed only on items with the mask member set 5573 * and matching on protocol layers specified without any masks is skipped. 5574 * - If 0, matching on protocol layers specified without any masks is done 5575 * as well. This is the standard behaviour of Flow API now. 5576 */ 5577 uint32_t relaxed_matching:1; 5578 /** 5579 * Flow direction for the pattern template. 5580 * At least one direction must be specified. 5581 */ 5582 /** Pattern valid for rules applied to ingress traffic. */ 5583 uint32_t ingress:1; 5584 /** Pattern valid for rules applied to egress traffic. */ 5585 uint32_t egress:1; 5586 /** Pattern valid for rules applied to transfer traffic. */ 5587 uint32_t transfer:1; 5588 }; 5589 5590 /** 5591 * @warning 5592 * @b EXPERIMENTAL: this API may change without prior notice. 5593 * 5594 * Create flow pattern template. 5595 * 5596 * The pattern template defines common matching fields without values. 5597 * For example, matching on 5 tuple TCP flow, the template will be 5598 * eth(null) + IPv4(source + dest) + TCP(s_port + d_port), 5599 * while values for each rule will be set during the flow rule creation. 5600 * The number and order of items in the template must be the same 5601 * at the rule creation. 5602 * 5603 * @param port_id 5604 * Port identifier of Ethernet device. 5605 * @param[in] template_attr 5606 * Pattern template attributes. 5607 * @param[in] pattern 5608 * Pattern specification (list terminated by the END pattern item). 5609 * The spec member of an item is not used unless the end member is used. 5610 * @param[out] error 5611 * Perform verbose error reporting if not NULL. 5612 * PMDs initialize this structure in case of error only. 5613 * 5614 * @return 5615 * Handle on success, NULL otherwise and rte_errno is set. 5616 */ 5617 __rte_experimental 5618 struct rte_flow_pattern_template * 5619 rte_flow_pattern_template_create(uint16_t port_id, 5620 const struct rte_flow_pattern_template_attr *template_attr, 5621 const struct rte_flow_item pattern[], 5622 struct rte_flow_error *error); 5623 5624 /** 5625 * @warning 5626 * @b EXPERIMENTAL: this API may change without prior notice. 5627 * 5628 * Destroy flow pattern template. 5629 * 5630 * This function may be called only when 5631 * there are no more tables referencing this template. 5632 * 5633 * @param port_id 5634 * Port identifier of Ethernet device. 5635 * @param[in] pattern_template 5636 * Handle of the template to be destroyed. 5637 * @param[out] error 5638 * Perform verbose error reporting if not NULL. 5639 * PMDs initialize this structure in case of error only. 5640 * 5641 * @return 5642 * 0 on success, a negative errno value otherwise and rte_errno is set. 5643 */ 5644 __rte_experimental 5645 int 5646 rte_flow_pattern_template_destroy(uint16_t port_id, 5647 struct rte_flow_pattern_template *pattern_template, 5648 struct rte_flow_error *error); 5649 5650 /** 5651 * Opaque type returned after successful creation of actions template. 5652 * This handle can be used to manage the created actions template. 5653 */ 5654 struct rte_flow_actions_template; 5655 5656 /** 5657 * @warning 5658 * @b EXPERIMENTAL: this API may change without prior notice. 5659 * 5660 * Flow actions template attributes. 5661 */ 5662 __extension__ 5663 struct rte_flow_actions_template_attr { 5664 /** 5665 * Flow direction for the actions template. 5666 * At least one direction must be specified. 5667 */ 5668 /** Action valid for rules applied to ingress traffic. */ 5669 uint32_t ingress:1; 5670 /** Action valid for rules applied to egress traffic. */ 5671 uint32_t egress:1; 5672 /** Action valid for rules applied to transfer traffic. */ 5673 uint32_t transfer:1; 5674 }; 5675 5676 /** 5677 * @warning 5678 * @b EXPERIMENTAL: this API may change without prior notice. 5679 * 5680 * Create flow actions template. 5681 * 5682 * The actions template holds a list of action types without values. 5683 * For example, the template to change TCP ports is TCP(s_port + d_port), 5684 * while values for each rule will be set during the flow rule creation. 5685 * The number and order of actions in the template must be the same 5686 * at the rule creation. 5687 * 5688 * @param port_id 5689 * Port identifier of Ethernet device. 5690 * @param[in] template_attr 5691 * Template attributes. 5692 * @param[in] actions 5693 * Associated actions (list terminated by the END action). 5694 * The spec member is only used if @p masks spec is non-zero. 5695 * @param[in] masks 5696 * List of actions that marks which of the action's member is constant. 5697 * A mask has the same format as the corresponding action. 5698 * If the action field in @p masks is not 0, 5699 * the corresponding value in an action from @p actions will be the part 5700 * of the template and used in all flow rules. 5701 * The order of actions in @p masks is the same as in @p actions. 5702 * In case of indirect actions present in @p actions, 5703 * the actual action type should be present in @p mask. 5704 * @param[out] error 5705 * Perform verbose error reporting if not NULL. 5706 * PMDs initialize this structure in case of error only. 5707 * 5708 * @return 5709 * Handle on success, NULL otherwise and rte_errno is set. 5710 */ 5711 __rte_experimental 5712 struct rte_flow_actions_template * 5713 rte_flow_actions_template_create(uint16_t port_id, 5714 const struct rte_flow_actions_template_attr *template_attr, 5715 const struct rte_flow_action actions[], 5716 const struct rte_flow_action masks[], 5717 struct rte_flow_error *error); 5718 5719 /** 5720 * @warning 5721 * @b EXPERIMENTAL: this API may change without prior notice. 5722 * 5723 * Destroy flow actions template. 5724 * 5725 * This function may be called only when 5726 * there are no more tables referencing this template. 5727 * 5728 * @param port_id 5729 * Port identifier of Ethernet device. 5730 * @param[in] actions_template 5731 * Handle to the template to be destroyed. 5732 * @param[out] error 5733 * Perform verbose error reporting if not NULL. 5734 * PMDs initialize this structure in case of error only. 5735 * 5736 * @return 5737 * 0 on success, a negative errno value otherwise and rte_errno is set. 5738 */ 5739 __rte_experimental 5740 int 5741 rte_flow_actions_template_destroy(uint16_t port_id, 5742 struct rte_flow_actions_template *actions_template, 5743 struct rte_flow_error *error); 5744 5745 /** 5746 * Opaque type returned after successful creation of a template table. 5747 * This handle can be used to manage the created template table. 5748 */ 5749 struct rte_flow_template_table; 5750 5751 /**@{@name Flags for template table attribute. 5752 * Each bit is an optional hint for table specialization, 5753 * offering a potential optimization at driver layer. 5754 * The driver can ignore the hints silently. 5755 * The hints do not replace any matching criteria. 5756 */ 5757 /** 5758 * Specialize table for transfer flows which come only from wire. 5759 * It allows PMD not to allocate resources for non-wire originated traffic. 5760 * This bit is not a matching criteria, just an optimization hint. 5761 * Flow rules which match non-wire originated traffic will be missed 5762 * if the hint is supported. 5763 */ 5764 #define RTE_FLOW_TABLE_SPECIALIZE_TRANSFER_WIRE_ORIG RTE_BIT32(0) 5765 /** 5766 * Specialize table for transfer flows which come only from vport (e.g. VF, SF). 5767 * It allows PMD not to allocate resources for non-vport originated traffic. 5768 * This bit is not a matching criteria, just an optimization hint. 5769 * Flow rules which match non-vport originated traffic will be missed 5770 * if the hint is supported. 5771 */ 5772 #define RTE_FLOW_TABLE_SPECIALIZE_TRANSFER_VPORT_ORIG RTE_BIT32(1) 5773 /**@}*/ 5774 5775 /** 5776 * @warning 5777 * @b EXPERIMENTAL: this API may change without prior notice. 5778 * 5779 * Template table flow rules insertion type. 5780 */ 5781 enum rte_flow_table_insertion_type { 5782 /** 5783 * Pattern-based insertion. 5784 */ 5785 RTE_FLOW_TABLE_INSERTION_TYPE_PATTERN, 5786 /** 5787 * Index-based insertion. 5788 */ 5789 RTE_FLOW_TABLE_INSERTION_TYPE_INDEX, 5790 }; 5791 5792 /** 5793 * @warning 5794 * @b EXPERIMENTAL: this API may change without prior notice. 5795 * 5796 * Template table hash index calculation function. 5797 */ 5798 enum rte_flow_table_hash_func { 5799 /** 5800 * Default hash calculation. 5801 */ 5802 RTE_FLOW_TABLE_HASH_FUNC_DEFAULT, 5803 /** 5804 * Linear hash calculation. 5805 */ 5806 RTE_FLOW_TABLE_HASH_FUNC_LINEAR, 5807 /** 5808 * 32-bit checksum hash calculation. 5809 */ 5810 RTE_FLOW_TABLE_HASH_FUNC_CRC32, 5811 /** 5812 * 16-bit checksum hash calculation. 5813 */ 5814 RTE_FLOW_TABLE_HASH_FUNC_CRC16, 5815 }; 5816 5817 /** 5818 * @warning 5819 * @b EXPERIMENTAL: this API may change without prior notice. 5820 * 5821 * Table attributes. 5822 */ 5823 struct rte_flow_template_table_attr { 5824 /** 5825 * Flow attributes to be used in each rule generated from this table. 5826 */ 5827 struct rte_flow_attr flow_attr; 5828 /** 5829 * Maximum number of flow rules that this table holds. 5830 */ 5831 uint32_t nb_flows; 5832 /** 5833 * Optional hint flags for driver optimization. 5834 * The effect may vary in the different drivers. 5835 * The functionality must not rely on the hints. 5836 * Value is composed with RTE_FLOW_TABLE_SPECIALIZE_* based on application 5837 * design choices. 5838 * Misused hints may mislead the driver, it may result in an undefined behavior. 5839 */ 5840 uint32_t specialize; 5841 /** 5842 * Insertion type for flow rules. 5843 */ 5844 enum rte_flow_table_insertion_type insertion_type; 5845 /** 5846 * Hash calculation function for the packet matching. 5847 */ 5848 enum rte_flow_table_hash_func hash_func; 5849 }; 5850 5851 /** 5852 * @warning 5853 * @b EXPERIMENTAL: this API may change without prior notice. 5854 * 5855 * Create flow template table. 5856 * 5857 * A template table consists of multiple pattern templates and actions 5858 * templates associated with a single set of rule attributes (group ID, 5859 * priority and traffic direction). 5860 * 5861 * Each rule is free to use any combination of pattern and actions templates 5862 * and specify particular values for items and actions it would like to change. 5863 * 5864 * @param port_id 5865 * Port identifier of Ethernet device. 5866 * @param[in] table_attr 5867 * Template table attributes. 5868 * @param[in] pattern_templates 5869 * Array of pattern templates to be used in this table. 5870 * @param[in] nb_pattern_templates 5871 * The number of pattern templates in the pattern_templates array. 5872 * @param[in] actions_templates 5873 * Array of actions templates to be used in this table. 5874 * @param[in] nb_actions_templates 5875 * The number of actions templates in the actions_templates array. 5876 * @param[out] error 5877 * Perform verbose error reporting if not NULL. 5878 * PMDs initialize this structure in case of error only. 5879 * 5880 * @return 5881 * Handle on success, NULL otherwise and rte_errno is set. 5882 */ 5883 __rte_experimental 5884 struct rte_flow_template_table * 5885 rte_flow_template_table_create(uint16_t port_id, 5886 const struct rte_flow_template_table_attr *table_attr, 5887 struct rte_flow_pattern_template *pattern_templates[], 5888 uint8_t nb_pattern_templates, 5889 struct rte_flow_actions_template *actions_templates[], 5890 uint8_t nb_actions_templates, 5891 struct rte_flow_error *error); 5892 5893 /** 5894 * @warning 5895 * @b EXPERIMENTAL: this API may change without prior notice. 5896 * 5897 * Destroy flow template table. 5898 * 5899 * This function may be called only when 5900 * there are no more flow rules referencing this table. 5901 * 5902 * @param port_id 5903 * Port identifier of Ethernet device. 5904 * @param[in] template_table 5905 * Handle to the table to be destroyed. 5906 * @param[out] error 5907 * Perform verbose error reporting if not NULL. 5908 * PMDs initialize this structure in case of error only. 5909 * 5910 * @return 5911 * 0 on success, a negative errno value otherwise and rte_errno is set. 5912 */ 5913 __rte_experimental 5914 int 5915 rte_flow_template_table_destroy(uint16_t port_id, 5916 struct rte_flow_template_table *template_table, 5917 struct rte_flow_error *error); 5918 5919 /** 5920 * @warning 5921 * @b EXPERIMENTAL: this API may change without prior notice. 5922 * 5923 * Set group miss actions. 5924 * 5925 * @param port_id 5926 * Port identifier of Ethernet device. 5927 * @param group_id 5928 * Identifier of a group to set miss actions for. 5929 * @param attr 5930 * Group attributes. 5931 * @param actions 5932 * List of group miss actions. 5933 * @param[out] error 5934 * Perform verbose error reporting if not NULL. 5935 * PMDs initialize this structure in case of error only. 5936 * 5937 * @return 5938 * 0 on success, a negative errno value otherwise and rte_errno is set. 5939 */ 5940 __rte_experimental 5941 int 5942 rte_flow_group_set_miss_actions(uint16_t port_id, 5943 uint32_t group_id, 5944 const struct rte_flow_group_attr *attr, 5945 const struct rte_flow_action actions[], 5946 struct rte_flow_error *error); 5947 5948 /** 5949 * @warning 5950 * @b EXPERIMENTAL: this API may change without prior notice. 5951 * 5952 * Asynchronous operation attributes. 5953 */ 5954 __extension__ 5955 struct rte_flow_op_attr { 5956 /** 5957 * When set, the requested action will not be sent to the HW immediately. 5958 * The application must call the rte_flow_queue_push to actually send it. 5959 */ 5960 uint32_t postpone:1; 5961 }; 5962 5963 /** 5964 * @warning 5965 * @b EXPERIMENTAL: this API may change without prior notice. 5966 * 5967 * Enqueue rule creation operation. 5968 * 5969 * @param port_id 5970 * Port identifier of Ethernet device. 5971 * @param queue_id 5972 * Flow queue used to insert the rule. 5973 * @param[in] op_attr 5974 * Rule creation operation attributes. 5975 * @param[in] template_table 5976 * Template table to select templates from. 5977 * @param[in] pattern 5978 * List of pattern items to be used. 5979 * The list order should match the order in the pattern template. 5980 * The spec is the only relevant member of the item that is being used. 5981 * @param[in] pattern_template_index 5982 * Pattern template index in the table. 5983 * @param[in] actions 5984 * List of actions to be used. 5985 * The list order should match the order in the actions template. 5986 * @param[in] actions_template_index 5987 * Actions template index in the table. 5988 * @param[in] user_data 5989 * The user data that will be returned on the completion events. 5990 * @param[out] error 5991 * Perform verbose error reporting if not NULL. 5992 * PMDs initialize this structure in case of error only. 5993 * 5994 * @return 5995 * Handle on success, NULL otherwise and rte_errno is set. 5996 * The rule handle doesn't mean that the rule has been populated. 5997 * Only completion result indicates that if there was success or failure. 5998 */ 5999 __rte_experimental 6000 struct rte_flow * 6001 rte_flow_async_create(uint16_t port_id, 6002 uint32_t queue_id, 6003 const struct rte_flow_op_attr *op_attr, 6004 struct rte_flow_template_table *template_table, 6005 const struct rte_flow_item pattern[], 6006 uint8_t pattern_template_index, 6007 const struct rte_flow_action actions[], 6008 uint8_t actions_template_index, 6009 void *user_data, 6010 struct rte_flow_error *error); 6011 6012 /** 6013 * @warning 6014 * @b EXPERIMENTAL: this API may change without prior notice. 6015 * 6016 * Enqueue rule creation operation. 6017 * 6018 * @param port_id 6019 * Port identifier of Ethernet device. 6020 * @param queue_id 6021 * Flow queue used to insert the rule. 6022 * @param[in] op_attr 6023 * Rule creation operation attributes. 6024 * @param[in] template_table 6025 * Template table to select templates from. 6026 * @param[in] rule_index 6027 * Rule index in the table. 6028 * @param[in] actions 6029 * List of actions to be used. 6030 * The list order should match the order in the actions template. 6031 * @param[in] actions_template_index 6032 * Actions template index in the table. 6033 * @param[in] user_data 6034 * The user data that will be returned on the completion events. 6035 * @param[out] error 6036 * Perform verbose error reporting if not NULL. 6037 * PMDs initialize this structure in case of error only. 6038 * 6039 * @return 6040 * Handle on success, NULL otherwise and rte_errno is set. 6041 * The rule handle doesn't mean that the rule has been populated. 6042 * Only completion result indicates that if there was success or failure. 6043 */ 6044 __rte_experimental 6045 struct rte_flow * 6046 rte_flow_async_create_by_index(uint16_t port_id, 6047 uint32_t queue_id, 6048 const struct rte_flow_op_attr *op_attr, 6049 struct rte_flow_template_table *template_table, 6050 uint32_t rule_index, 6051 const struct rte_flow_action actions[], 6052 uint8_t actions_template_index, 6053 void *user_data, 6054 struct rte_flow_error *error); 6055 6056 /** 6057 * @warning 6058 * @b EXPERIMENTAL: this API may change without prior notice. 6059 * 6060 * Enqueue rule destruction operation. 6061 * 6062 * This function enqueues a destruction operation on the queue. 6063 * Application should assume that after calling this function 6064 * the rule handle is not valid anymore. 6065 * Completion indicates the full removal of the rule from the HW. 6066 * 6067 * @param port_id 6068 * Port identifier of Ethernet device. 6069 * @param queue_id 6070 * Flow queue which is used to destroy the rule. 6071 * This must match the queue on which the rule was created. 6072 * @param[in] op_attr 6073 * Rule destruction operation attributes. 6074 * @param[in] flow 6075 * Flow handle to be destroyed. 6076 * @param[in] user_data 6077 * The user data that will be returned on the completion events. 6078 * @param[out] error 6079 * Perform verbose error reporting if not NULL. 6080 * PMDs initialize this structure in case of error only. 6081 * 6082 * @return 6083 * 0 on success, a negative errno value otherwise and rte_errno is set. 6084 */ 6085 __rte_experimental 6086 int 6087 rte_flow_async_destroy(uint16_t port_id, 6088 uint32_t queue_id, 6089 const struct rte_flow_op_attr *op_attr, 6090 struct rte_flow *flow, 6091 void *user_data, 6092 struct rte_flow_error *error); 6093 6094 /** 6095 * @warning 6096 * @b EXPERIMENTAL: this API may change without prior notice. 6097 * 6098 * Enqueue rule update operation. 6099 * 6100 * @param port_id 6101 * Port identifier of Ethernet device. 6102 * @param queue_id 6103 * Flow queue used to insert the rule. 6104 * @param[in] op_attr 6105 * Rule creation operation attributes. 6106 * @param[in] flow 6107 * Flow rule to be updated. 6108 * @param[in] actions 6109 * List of actions to be used. 6110 * The list order should match the order in the actions template. 6111 * @param[in] actions_template_index 6112 * Actions template index in the table. 6113 * @param[in] user_data 6114 * The user data that will be returned on the completion events. 6115 * @param[out] error 6116 * Perform verbose error reporting if not NULL. 6117 * PMDs initialize this structure in case of error only. 6118 * 6119 * @return 6120 * 0 on success, a negative errno value otherwise and rte_errno is set. 6121 */ 6122 __rte_experimental 6123 int 6124 rte_flow_async_actions_update(uint16_t port_id, 6125 uint32_t queue_id, 6126 const struct rte_flow_op_attr *op_attr, 6127 struct rte_flow *flow, 6128 const struct rte_flow_action actions[], 6129 uint8_t actions_template_index, 6130 void *user_data, 6131 struct rte_flow_error *error); 6132 6133 /** 6134 * @warning 6135 * @b EXPERIMENTAL: this API may change without prior notice. 6136 * 6137 * Push all internally stored rules to the HW. 6138 * Postponed rules are rules that were inserted with the postpone flag set. 6139 * Can be used to notify the HW about batch of rules prepared by the SW to 6140 * reduce the number of communications between the HW and SW. 6141 * 6142 * @param port_id 6143 * Port identifier of Ethernet device. 6144 * @param queue_id 6145 * Flow queue to be pushed. 6146 * @param[out] error 6147 * Perform verbose error reporting if not NULL. 6148 * PMDs initialize this structure in case of error only. 6149 * 6150 * @return 6151 * 0 on success, a negative errno value otherwise and rte_errno is set. 6152 */ 6153 __rte_experimental 6154 int 6155 rte_flow_push(uint16_t port_id, 6156 uint32_t queue_id, 6157 struct rte_flow_error *error); 6158 6159 /** 6160 * @warning 6161 * @b EXPERIMENTAL: this API may change without prior notice. 6162 * 6163 * Asynchronous operation status. 6164 */ 6165 enum rte_flow_op_status { 6166 /** 6167 * The operation was completed successfully. 6168 */ 6169 RTE_FLOW_OP_SUCCESS, 6170 /** 6171 * The operation was not completed successfully. 6172 */ 6173 RTE_FLOW_OP_ERROR, 6174 }; 6175 6176 /** 6177 * @warning 6178 * @b EXPERIMENTAL: this API may change without prior notice. 6179 * 6180 * Asynchronous operation result. 6181 */ 6182 __extension__ 6183 struct rte_flow_op_result { 6184 /** 6185 * Returns the status of the operation that this completion signals. 6186 */ 6187 enum rte_flow_op_status status; 6188 /** 6189 * The user data that will be returned on the completion events. 6190 */ 6191 void *user_data; 6192 }; 6193 6194 /** 6195 * @warning 6196 * @b EXPERIMENTAL: this API may change without prior notice. 6197 * 6198 * Pull a rte flow operation. 6199 * The application must invoke this function in order to complete 6200 * the flow rule offloading and to retrieve the flow rule operation status. 6201 * 6202 * @param port_id 6203 * Port identifier of Ethernet device. 6204 * @param queue_id 6205 * Flow queue which is used to pull the operation. 6206 * @param[out] res 6207 * Array of results that will be set. 6208 * @param[in] n_res 6209 * Maximum number of results that can be returned. 6210 * This value is equal to the size of the res array. 6211 * @param[out] error 6212 * Perform verbose error reporting if not NULL. 6213 * PMDs initialize this structure in case of error only. 6214 * 6215 * @return 6216 * Number of results that were pulled, 6217 * a negative errno value otherwise and rte_errno is set. 6218 */ 6219 __rte_experimental 6220 int 6221 rte_flow_pull(uint16_t port_id, 6222 uint32_t queue_id, 6223 struct rte_flow_op_result res[], 6224 uint16_t n_res, 6225 struct rte_flow_error *error); 6226 6227 /** 6228 * @warning 6229 * @b EXPERIMENTAL: this API may change without prior notice. 6230 * 6231 * Enqueue indirect action creation operation. 6232 * @see rte_flow_action_handle_create 6233 * 6234 * @param[in] port_id 6235 * Port identifier of Ethernet device. 6236 * @param[in] queue_id 6237 * Flow queue which is used to create the rule. 6238 * @param[in] op_attr 6239 * Indirect action creation operation attributes. 6240 * @param[in] indir_action_conf 6241 * Action configuration for the indirect action object creation. 6242 * @param[in] action 6243 * Specific configuration of the indirect action object. 6244 * @param[in] user_data 6245 * The user data that will be returned on the completion events. 6246 * @param[out] error 6247 * Perform verbose error reporting if not NULL. 6248 * PMDs initialize this structure in case of error only. 6249 * 6250 * @return 6251 * A valid handle in case of success, NULL otherwise and rte_errno is set. 6252 */ 6253 __rte_experimental 6254 struct rte_flow_action_handle * 6255 rte_flow_async_action_handle_create(uint16_t port_id, 6256 uint32_t queue_id, 6257 const struct rte_flow_op_attr *op_attr, 6258 const struct rte_flow_indir_action_conf *indir_action_conf, 6259 const struct rte_flow_action *action, 6260 void *user_data, 6261 struct rte_flow_error *error); 6262 6263 /** 6264 * @warning 6265 * @b EXPERIMENTAL: this API may change without prior notice. 6266 * 6267 * Enqueue indirect action destruction operation. 6268 * The destroy queue must be the same 6269 * as the queue on which the action was created. 6270 * 6271 * @param[in] port_id 6272 * Port identifier of Ethernet device. 6273 * @param[in] queue_id 6274 * Flow queue which is used to destroy the rule. 6275 * @param[in] op_attr 6276 * Indirect action destruction operation attributes. 6277 * @param[in] action_handle 6278 * Handle for the indirect action object to be destroyed. 6279 * @param[in] user_data 6280 * The user data that will be returned on the completion events. 6281 * @param[out] error 6282 * Perform verbose error reporting if not NULL. 6283 * PMDs initialize this structure in case of error only. 6284 * 6285 * @return 6286 * 0 on success, a negative errno value otherwise and rte_errno is set. 6287 */ 6288 __rte_experimental 6289 int 6290 rte_flow_async_action_handle_destroy(uint16_t port_id, 6291 uint32_t queue_id, 6292 const struct rte_flow_op_attr *op_attr, 6293 struct rte_flow_action_handle *action_handle, 6294 void *user_data, 6295 struct rte_flow_error *error); 6296 6297 /** 6298 * @warning 6299 * @b EXPERIMENTAL: this API may change without prior notice. 6300 * 6301 * Enqueue indirect action update operation. 6302 * @see rte_flow_action_handle_create 6303 * 6304 * @param[in] port_id 6305 * Port identifier of Ethernet device. 6306 * @param[in] queue_id 6307 * Flow queue which is used to update the rule. 6308 * @param[in] op_attr 6309 * Indirect action update operation attributes. 6310 * @param[in] action_handle 6311 * Handle for the indirect action object to be updated. 6312 * @param[in] update 6313 * Update profile specification used to modify the action pointed by handle. 6314 * *update* could be with the same type of the immediate action corresponding 6315 * to the *handle* argument when creating, or a wrapper structure includes 6316 * action configuration to be updated and bit fields to indicate the member 6317 * of fields inside the action to update. 6318 * @param[in] user_data 6319 * The user data that will be returned on the completion events. 6320 * @param[out] error 6321 * Perform verbose error reporting if not NULL. 6322 * PMDs initialize this structure in case of error only. 6323 * 6324 * @return 6325 * 0 on success, a negative errno value otherwise and rte_errno is set. 6326 */ 6327 __rte_experimental 6328 int 6329 rte_flow_async_action_handle_update(uint16_t port_id, 6330 uint32_t queue_id, 6331 const struct rte_flow_op_attr *op_attr, 6332 struct rte_flow_action_handle *action_handle, 6333 const void *update, 6334 void *user_data, 6335 struct rte_flow_error *error); 6336 6337 /** 6338 * @warning 6339 * @b EXPERIMENTAL: this API may change without prior notice. 6340 * 6341 * Enqueue indirect action query operation. 6342 * 6343 * Retrieve action-specific data such as counters. 6344 * Data is gathered by special action which may be present/referenced in 6345 * more than one flow rule definition. 6346 * Data will be available only when completion event returns. 6347 * 6348 * @see rte_flow_async_action_handle_query 6349 * 6350 * @param port_id 6351 * Port identifier of Ethernet device. 6352 * @param[in] queue_id 6353 * Flow queue which is used to query the action. 6354 * @param[in] op_attr 6355 * Indirect action update operation attributes. 6356 * @param[in] action_handle 6357 * Handle for the action object to query. 6358 * @param[in, out] data 6359 * Pointer to storage for the associated query data type. 6360 * The out data will be available only when completion event returns 6361 * from rte_flow_pull. 6362 * @param[in] user_data 6363 * The user data that will be returned on the completion events. 6364 * @param[out] error 6365 * Perform verbose error reporting if not NULL. PMDs initialize this 6366 * structure in case of error only. 6367 * 6368 * @return 6369 * 0 on success, a negative errno value otherwise and rte_errno is set. 6370 */ 6371 __rte_experimental 6372 int 6373 rte_flow_async_action_handle_query(uint16_t port_id, 6374 uint32_t queue_id, 6375 const struct rte_flow_op_attr *op_attr, 6376 const struct rte_flow_action_handle *action_handle, 6377 void *data, 6378 void *user_data, 6379 struct rte_flow_error *error); 6380 6381 /** 6382 * @warning 6383 * @b EXPERIMENTAL: this API may change without prior notice. 6384 * 6385 * Query and update operational mode. 6386 * 6387 * @see rte_flow_action_handle_query_update() 6388 * @see rte_flow_async_action_handle_query_update() 6389 */ 6390 enum rte_flow_query_update_mode { 6391 RTE_FLOW_QU_QUERY_FIRST = 1, /**< Query before update. */ 6392 RTE_FLOW_QU_UPDATE_FIRST, /**< Query after update. */ 6393 }; 6394 6395 /** 6396 * @warning 6397 * @b EXPERIMENTAL: this API may change without prior notice. 6398 * 6399 * Query and/or update indirect flow action. 6400 * If both query and update not NULL, the function atomically 6401 * queries and updates indirect action. Query and update are carried in order 6402 * specified in the mode parameter. 6403 * If ether query or update is NULL, the function executes 6404 * complementing operation. 6405 * 6406 * @param port_id 6407 * Port identifier of Ethernet device. 6408 * @param handle 6409 * Handle for the indirect action object to be updated. 6410 * @param update 6411 * If not NULL, update profile specification used to modify the action 6412 * pointed by handle. 6413 * @param query 6414 * If not NULL pointer to storage for the associated query data type. 6415 * @param mode 6416 * Operational mode. 6417 * @param error 6418 * Perform verbose error reporting if not NULL. 6419 * PMDs initialize this structure in case of error only. 6420 * 6421 * @return 6422 * 0 on success, a negative errno value otherwise and rte_errno is set. 6423 * - (-ENODEV) if *port_id* invalid. 6424 * - (-ENOTSUP) if underlying device does not support this functionality. 6425 * - (-EINVAL) if *handle* or *mode* invalid or 6426 * both *query* and *update* are NULL. 6427 */ 6428 __rte_experimental 6429 int 6430 rte_flow_action_handle_query_update(uint16_t port_id, 6431 struct rte_flow_action_handle *handle, 6432 const void *update, void *query, 6433 enum rte_flow_query_update_mode mode, 6434 struct rte_flow_error *error); 6435 6436 /** 6437 * @warning 6438 * @b EXPERIMENTAL: this API may change without prior notice. 6439 * 6440 * Enqueue async indirect flow action query and/or update 6441 * 6442 * @param port_id 6443 * Port identifier of Ethernet device. 6444 * @param queue_id 6445 * Flow queue which is used to update the rule. 6446 * @param attr 6447 * Indirect action update operation attributes. 6448 * @param handle 6449 * Handle for the indirect action object to be updated. 6450 * @param update 6451 * If not NULL, update profile specification used to modify the action 6452 * pointed by handle. 6453 * @param query 6454 * If not NULL, pointer to storage for the associated query data type. 6455 * Query result returned on async completion event. 6456 * @param mode 6457 * Operational mode. 6458 * @param user_data 6459 * The user data that will be returned on async completion event. 6460 * @param error 6461 * Perform verbose error reporting if not NULL. 6462 * PMDs initialize this structure in case of error only. 6463 * 6464 * @return 6465 * 0 on success, a negative errno value otherwise and rte_errno is set. 6466 * - (-ENODEV) if *port_id* invalid. 6467 * - (-ENOTSUP) if underlying device does not support this functionality. 6468 * - (-EINVAL) if *handle* or *mode* invalid or 6469 * both *update* and *query* are NULL. 6470 */ 6471 __rte_experimental 6472 int 6473 rte_flow_async_action_handle_query_update(uint16_t port_id, uint32_t queue_id, 6474 const struct rte_flow_op_attr *attr, 6475 struct rte_flow_action_handle *handle, 6476 const void *update, void *query, 6477 enum rte_flow_query_update_mode mode, 6478 void *user_data, 6479 struct rte_flow_error *error); 6480 6481 struct rte_flow_action_list_handle; 6482 6483 /** 6484 * @warning 6485 * @b EXPERIMENTAL: this API may change without prior notice. 6486 * 6487 * Configure INDIRECT_LIST flow action. 6488 * 6489 * @see RTE_FLOW_ACTION_TYPE_INDIRECT_LIST 6490 */ 6491 struct rte_flow_action_indirect_list { 6492 /** Indirect action list handle */ 6493 struct rte_flow_action_list_handle *handle; 6494 /** 6495 * Flow mutable configuration array. 6496 * NULL if the handle has no flow mutable configuration update. 6497 * Otherwise, if the handle was created with list A1 / A2 .. An / END 6498 * size of conf is n. 6499 * conf[i] points to flow mutable update of Ai in the handle 6500 * actions list or NULL if Ai has no update. 6501 */ 6502 const void **conf; 6503 }; 6504 6505 /** 6506 * @warning 6507 * @b EXPERIMENTAL: this API may change without prior notice. 6508 * 6509 * Create an indirect flow action object from flow actions list. 6510 * The object is identified by a unique handle. 6511 * The handle has single state and configuration 6512 * across all the flow rules using it. 6513 * 6514 * @param[in] port_id 6515 * The port identifier of the Ethernet device. 6516 * @param[in] conf 6517 * Action configuration for the indirect action list creation. 6518 * @param[in] actions 6519 * Specific configuration of the indirect action lists. 6520 * @param[out] error 6521 * Perform verbose error reporting if not NULL. PMDs initialize this 6522 * structure in case of error only. 6523 * @return 6524 * A valid handle in case of success, NULL otherwise and rte_errno is set 6525 * to one of the error codes defined: 6526 * - (-ENODEV) if *port_id* invalid. 6527 * - (-ENOSYS) if underlying device does not support this functionality. 6528 * - (-EIO) if underlying device is removed. 6529 * - (-EINVAL) if *actions* list invalid. 6530 * - (-ENOTSUP) if *action* list element valid but unsupported. 6531 */ 6532 __rte_experimental 6533 struct rte_flow_action_list_handle * 6534 rte_flow_action_list_handle_create(uint16_t port_id, 6535 const 6536 struct rte_flow_indir_action_conf *conf, 6537 const struct rte_flow_action *actions, 6538 struct rte_flow_error *error); 6539 6540 /** 6541 * @warning 6542 * @b EXPERIMENTAL: this API may change without prior notice. 6543 * 6544 * Async function call to create an indirect flow action object 6545 * from flow actions list. 6546 * The object is identified by a unique handle. 6547 * The handle has single state and configuration 6548 * across all the flow rules using it. 6549 * 6550 * @param[in] port_id 6551 * The port identifier of the Ethernet device. 6552 * @param[in] queue_id 6553 * Flow queue which is used to update the rule. 6554 * @param[in] attr 6555 * Indirect action update operation attributes. 6556 * @param[in] conf 6557 * Action configuration for the indirect action list creation. 6558 * @param[in] actions 6559 * Specific configuration of the indirect action list. 6560 * @param[in] user_data 6561 * The user data that will be returned on async completion event. 6562 * @param[out] error 6563 * Perform verbose error reporting if not NULL. PMDs initialize this 6564 * structure in case of error only. 6565 * @return 6566 * A valid handle in case of success, NULL otherwise and rte_errno is set 6567 * to one of the error codes defined: 6568 * - (-ENODEV) if *port_id* invalid. 6569 * - (-ENOSYS) if underlying device does not support this functionality. 6570 * - (-EIO) if underlying device is removed. 6571 * - (-EINVAL) if *actions* list invalid. 6572 * - (-ENOTSUP) if *action* list element valid but unsupported. 6573 */ 6574 __rte_experimental 6575 struct rte_flow_action_list_handle * 6576 rte_flow_async_action_list_handle_create(uint16_t port_id, uint32_t queue_id, 6577 const struct rte_flow_op_attr *attr, 6578 const struct rte_flow_indir_action_conf *conf, 6579 const struct rte_flow_action *actions, 6580 void *user_data, 6581 struct rte_flow_error *error); 6582 6583 /** 6584 * @warning 6585 * @b EXPERIMENTAL: this API may change without prior notice. 6586 * 6587 * Destroy indirect actions list by handle. 6588 * 6589 * @param[in] port_id 6590 * The port identifier of the Ethernet device. 6591 * @param[in] handle 6592 * Handle for the indirect actions list to be destroyed. 6593 * @param[out] error 6594 * Perform verbose error reporting if not NULL. PMDs initialize this 6595 * structure in case of error only. 6596 * @return 6597 * - (0) if success. 6598 * - (-ENODEV) if *port_id* invalid. 6599 * - (-ENOSYS) if underlying device does not support this functionality. 6600 * - (-EIO) if underlying device is removed. 6601 * - (-ENOENT) if actions list pointed by *action* handle was not found. 6602 * - (-EBUSY) if actions list pointed by *action* handle still used 6603 */ 6604 __rte_experimental 6605 int 6606 rte_flow_action_list_handle_destroy(uint16_t port_id, 6607 struct rte_flow_action_list_handle *handle, 6608 struct rte_flow_error *error); 6609 6610 /** 6611 * @warning 6612 * @b EXPERIMENTAL: this API may change without prior notice. 6613 * 6614 * Enqueue indirect action list destruction operation. 6615 * The destroy queue must be the same 6616 * as the queue on which the action was created. 6617 * 6618 * @param[in] port_id 6619 * Port identifier of Ethernet device. 6620 * @param[in] queue_id 6621 * Flow queue which is used to destroy the rule. 6622 * @param[in] op_attr 6623 * Indirect action destruction operation attributes. 6624 * @param[in] handle 6625 * Handle for the indirect action object to be destroyed. 6626 * @param[in] user_data 6627 * The user data that will be returned on the completion events. 6628 * @param[out] error 6629 * Perform verbose error reporting if not NULL. 6630 * PMDs initialize this structure in case of error only. 6631 * 6632 * @return 6633 * - (0) if success. 6634 * - (-ENODEV) if *port_id* invalid. 6635 * - (-ENOSYS) if underlying device does not support this functionality. 6636 * - (-EIO) if underlying device is removed. 6637 * - (-ENOENT) if actions list pointed by *action* handle was not found. 6638 * - (-EBUSY) if actions list pointed by *action* handle still used 6639 */ 6640 __rte_experimental 6641 int 6642 rte_flow_async_action_list_handle_destroy 6643 (uint16_t port_id, uint32_t queue_id, 6644 const struct rte_flow_op_attr *op_attr, 6645 struct rte_flow_action_list_handle *handle, 6646 void *user_data, struct rte_flow_error *error); 6647 6648 /** 6649 * @warning 6650 * @b EXPERIMENTAL: this API may change without prior notice. 6651 * 6652 * Query and/or update indirect flow actions list. 6653 * If both query and update not NULL, the function atomically 6654 * queries and updates indirect action. Query and update are carried in order 6655 * specified in the mode parameter. 6656 * If ether query or update is NULL, the function executes 6657 * complementing operation. 6658 * 6659 * @param port_id 6660 * Port identifier of Ethernet device. 6661 * @param handle 6662 * Handle for the indirect actions list object to be updated. 6663 * @param update 6664 * If the action list handle was created from n actions A1 / A2 ... An / END 6665 * non-NULL update parameter is an array [U1, U2, ... Un] where Ui points to 6666 * Ai update context or NULL if Ai should not be updated. 6667 * @param query 6668 * If the action list handle was created from n actions A1 / A2 ... An / END 6669 * non-NULL query parameter is an array [Q1, Q2, ... Qn] where Qi points to 6670 * Ai query context or NULL if Ai should not be queried. 6671 * @param mode 6672 * Operational mode. 6673 * @param error 6674 * Perform verbose error reporting if not NULL. 6675 * PMDs initialize this structure in case of error only. 6676 * 6677 * @return 6678 * - (0) if success. 6679 * - (-ENODEV) if *port_id* invalid. 6680 * - (-ENOTSUP) if underlying device does not support this functionality. 6681 * - (-EINVAL) if *handle* or *mode* invalid or 6682 * both *query* and *update* are NULL. 6683 */ 6684 __rte_experimental 6685 int 6686 rte_flow_action_list_handle_query_update(uint16_t port_id, 6687 const struct rte_flow_action_list_handle *handle, 6688 const void **update, void **query, 6689 enum rte_flow_query_update_mode mode, 6690 struct rte_flow_error *error); 6691 6692 /** 6693 * @warning 6694 * @b EXPERIMENTAL: this API may change without prior notice. 6695 * 6696 * Enqueue async indirect flow actions list query and/or update 6697 * If both query and update not NULL, the function atomically 6698 * queries and updates indirect action. Query and update are carried in order 6699 * specified in the mode parameter. 6700 * If ether query or update is NULL, the function executes 6701 * complementing operation. 6702 * 6703 * @param port_id 6704 * Port identifier of Ethernet device. 6705 * @param queue_id 6706 * Flow queue which is used to update the rule. 6707 * @param attr 6708 * Indirect action update operation attributes. 6709 * @param handle 6710 * Handle for the indirect actions list object to be updated. 6711 * @param update 6712 * If the action list handle was created from n actions A1 / A2 ... An / END 6713 * non-NULL update parameter is an array [U1, U2, ... Un] where Ui points to 6714 * Ai update context or NULL if Ai should not be updated. 6715 * @param query 6716 * If the action list handle was created from n actions A1 / A2 ... An / END 6717 * non-NULL query parameter is an array [Q1, Q2, ... Qn] where Qi points to 6718 * Ai query context or NULL if Ai should not be queried. 6719 * Query result returned on async completion event. 6720 * @param mode 6721 * Operational mode. 6722 * @param user_data 6723 * The user data that will be returned on async completion event. 6724 * @param error 6725 * Perform verbose error reporting if not NULL. 6726 * PMDs initialize this structure in case of error only. 6727 * 6728 * @return 6729 * - (0) if success. 6730 * - (-ENODEV) if *port_id* invalid. 6731 * - (-ENOTSUP) if underlying device does not support this functionality. 6732 * - (-EINVAL) if *handle* or *mode* invalid or 6733 * both *update* and *query* are NULL. 6734 */ 6735 __rte_experimental 6736 int 6737 rte_flow_async_action_list_handle_query_update(uint16_t port_id, uint32_t queue_id, 6738 const struct rte_flow_op_attr *attr, 6739 const struct rte_flow_action_list_handle *handle, 6740 const void **update, void **query, 6741 enum rte_flow_query_update_mode mode, 6742 void *user_data, 6743 struct rte_flow_error *error); 6744 6745 /** 6746 * @warning 6747 * @b EXPERIMENTAL: this API may change without prior notice. 6748 * 6749 * Calculate the hash for a given pattern in a given table as 6750 * calculated by the HW. 6751 * 6752 * @param port_id 6753 * Port identifier of Ethernet device. 6754 * @param table 6755 * The table the SW wishes to simulate. 6756 * @param pattern 6757 * The values to be used in the hash calculation. 6758 * @param pattern_template_index 6759 * The pattern index in the table to be used for the calculation. 6760 * @param hash 6761 * Used to return the calculated hash. 6762 * @param error 6763 * Perform verbose error reporting if not NULL. 6764 * PMDs initialize this structure in case of error only. 6765 * 6766 * @return 6767 * - (0) if success. 6768 * - (-ENODEV) if *port_id* invalid. 6769 * - (-ENOTSUP) if underlying device does not support this functionality. 6770 */ 6771 __rte_experimental 6772 int 6773 rte_flow_calc_table_hash(uint16_t port_id, const struct rte_flow_template_table *table, 6774 const struct rte_flow_item pattern[], uint8_t pattern_template_index, 6775 uint32_t *hash, struct rte_flow_error *error); 6776 6777 #ifdef __cplusplus 6778 } 6779 #endif 6780 6781 #endif /* RTE_FLOW_H_ */ 6782