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