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