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