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