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