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