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