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