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