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