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