1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright 2016 6WIND S.A.
3 * Copyright 2016 Mellanox Technologies, Ltd
11 * RTE generic flow API
13 * This interface provides the ability to program packet matching and
14 * associated actions in hardware through flow rules.
21 #include <rte_common.h>
22 #include <rte_ether.h>
28 #include <rte_byteorder.h>
30 #include <rte_higig.h>
31 #include <rte_ecpri.h>
33 #include <rte_mbuf_dyn.h>
40 * Flow rule attributes.
42 * Priorities are set on a per rule based within groups.
44 * Lower values denote higher priority, the highest priority for a flow rule
45 * is 0, so that a flow that matches for than one rule, the rule with the
46 * lowest priority value will always be matched.
48 * Although optional, applications are encouraged to group similar rules as
49 * much as possible to fully take advantage of hardware capabilities
50 * (e.g. optimized matching) and work around limitations (e.g. a single
51 * pattern type possibly allowed in a given group). Applications should be
52 * aware that groups are not linked by default, and that they must be
53 * explicitly linked by the application using the JUMP action.
55 * Priority levels are arbitrary and up to the application, they
56 * do not need to be contiguous nor start from 0, however the maximum number
57 * varies between devices and may be affected by existing flow rules.
59 * If a packet is matched by several rules of a given group for a given
60 * priority level, the outcome is undefined. It can take any path, may be
61 * duplicated or even cause unrecoverable errors.
63 * Note that support for more than a single group and priority level is not
66 * Flow rules can apply to inbound and/or outbound traffic (ingress/egress).
68 * Several pattern items and actions are valid and can be used in both
69 * directions. Those valid for only one direction are described as such.
71 * At least one direction must be specified.
73 * Specifying both directions at once for a given rule is not recommended
74 * but may be valid in a few cases (e.g. shared counter).
76 struct rte_flow_attr {
77 uint32_t group; /**< Priority group. */
78 uint32_t priority; /**< Rule priority level within group. */
79 uint32_t ingress:1; /**< Rule applies to ingress traffic. */
80 uint32_t egress:1; /**< Rule applies to egress traffic. */
82 * Instead of simply matching the properties of traffic as it would
83 * appear on a given DPDK port ID, enabling this attribute transfers
84 * a flow rule to the lowest possible level of any device endpoints
85 * found in the pattern.
87 * When supported, this effectively enables an application to
88 * re-route traffic not necessarily intended for it (e.g. coming
89 * from or addressed to different physical ports, VFs or
90 * applications) at the device level.
92 * It complements the behavior of some pattern items such as
93 * RTE_FLOW_ITEM_TYPE_PHY_PORT and is meaningless without them.
95 * When transferring flow rules, ingress and egress attributes keep
96 * their original meaning, as if processing traffic emitted or
97 * received by the application.
100 uint32_t reserved:29; /**< Reserved, must be zero. */
104 * Matching pattern item types.
106 * Pattern items fall in two categories:
108 * - Matching protocol headers and packet data, usually associated with a
109 * specification structure. These must be stacked in the same order as the
110 * protocol layers to match inside packets, starting from the lowest.
112 * - Matching meta-data or affecting pattern processing, often without a
113 * specification structure. Since they do not match packet contents, their
114 * position in the list is usually not relevant.
116 * See the description of individual types for more information. Those
117 * marked with [META] fall into the second category.
119 enum rte_flow_item_type {
123 * End marker for item lists. Prevents further processing of items,
124 * thereby ending the pattern.
126 * No associated specification structure.
128 RTE_FLOW_ITEM_TYPE_END,
133 * Used as a placeholder for convenience. It is ignored and simply
136 * No associated specification structure.
138 RTE_FLOW_ITEM_TYPE_VOID,
143 * Inverted matching, i.e. process packets that do not match the
146 * No associated specification structure.
148 RTE_FLOW_ITEM_TYPE_INVERT,
151 * Matches any protocol in place of the current layer, a single ANY
152 * may also stand for several protocol layers.
154 * See struct rte_flow_item_any.
156 RTE_FLOW_ITEM_TYPE_ANY,
161 * Matches traffic originating from (ingress) or going to (egress)
162 * the physical function of the current device.
164 * No associated specification structure.
166 RTE_FLOW_ITEM_TYPE_PF,
171 * Matches traffic originating from (ingress) or going to (egress) a
172 * given virtual function of the current device.
174 * See struct rte_flow_item_vf.
176 RTE_FLOW_ITEM_TYPE_VF,
181 * Matches traffic originating from (ingress) or going to (egress) a
182 * physical port of the underlying device.
184 * See struct rte_flow_item_phy_port.
186 RTE_FLOW_ITEM_TYPE_PHY_PORT,
191 * Matches traffic originating from (ingress) or going to (egress) a
192 * given DPDK port ID.
194 * See struct rte_flow_item_port_id.
196 RTE_FLOW_ITEM_TYPE_PORT_ID,
199 * Matches a byte string of a given length at a given offset.
201 * See struct rte_flow_item_raw.
203 RTE_FLOW_ITEM_TYPE_RAW,
206 * Matches an Ethernet header.
208 * See struct rte_flow_item_eth.
210 RTE_FLOW_ITEM_TYPE_ETH,
213 * Matches an 802.1Q/ad VLAN tag.
215 * See struct rte_flow_item_vlan.
217 RTE_FLOW_ITEM_TYPE_VLAN,
220 * Matches an IPv4 header.
222 * See struct rte_flow_item_ipv4.
224 RTE_FLOW_ITEM_TYPE_IPV4,
227 * Matches an IPv6 header.
229 * See struct rte_flow_item_ipv6.
231 RTE_FLOW_ITEM_TYPE_IPV6,
234 * Matches an ICMP header.
236 * See struct rte_flow_item_icmp.
238 RTE_FLOW_ITEM_TYPE_ICMP,
241 * Matches a UDP header.
243 * See struct rte_flow_item_udp.
245 RTE_FLOW_ITEM_TYPE_UDP,
248 * Matches a TCP header.
250 * See struct rte_flow_item_tcp.
252 RTE_FLOW_ITEM_TYPE_TCP,
255 * Matches a SCTP header.
257 * See struct rte_flow_item_sctp.
259 RTE_FLOW_ITEM_TYPE_SCTP,
262 * Matches a VXLAN header.
264 * See struct rte_flow_item_vxlan.
266 RTE_FLOW_ITEM_TYPE_VXLAN,
269 * Matches a E_TAG header.
271 * See struct rte_flow_item_e_tag.
273 RTE_FLOW_ITEM_TYPE_E_TAG,
276 * Matches a NVGRE header.
278 * See struct rte_flow_item_nvgre.
280 RTE_FLOW_ITEM_TYPE_NVGRE,
283 * Matches a MPLS header.
285 * See struct rte_flow_item_mpls.
287 RTE_FLOW_ITEM_TYPE_MPLS,
290 * Matches a GRE header.
292 * See struct rte_flow_item_gre.
294 RTE_FLOW_ITEM_TYPE_GRE,
299 * Fuzzy pattern match, expect faster than default.
301 * This is for device that support fuzzy matching option.
302 * Usually a fuzzy matching is fast but the cost is accuracy.
304 * See struct rte_flow_item_fuzzy.
306 RTE_FLOW_ITEM_TYPE_FUZZY,
309 * Matches a GTP header.
311 * Configure flow for GTP packets.
313 * See struct rte_flow_item_gtp.
315 RTE_FLOW_ITEM_TYPE_GTP,
318 * Matches a GTP header.
320 * Configure flow for GTP-C packets.
322 * See struct rte_flow_item_gtp.
324 RTE_FLOW_ITEM_TYPE_GTPC,
327 * Matches a GTP header.
329 * Configure flow for GTP-U packets.
331 * See struct rte_flow_item_gtp.
333 RTE_FLOW_ITEM_TYPE_GTPU,
336 * Matches a ESP header.
338 * See struct rte_flow_item_esp.
340 RTE_FLOW_ITEM_TYPE_ESP,
343 * Matches a GENEVE header.
345 * See struct rte_flow_item_geneve.
347 RTE_FLOW_ITEM_TYPE_GENEVE,
350 * Matches a VXLAN-GPE header.
352 * See struct rte_flow_item_vxlan_gpe.
354 RTE_FLOW_ITEM_TYPE_VXLAN_GPE,
357 * Matches an ARP header for Ethernet/IPv4.
359 * See struct rte_flow_item_arp_eth_ipv4.
361 RTE_FLOW_ITEM_TYPE_ARP_ETH_IPV4,
364 * Matches the presence of any IPv6 extension header.
366 * See struct rte_flow_item_ipv6_ext.
368 RTE_FLOW_ITEM_TYPE_IPV6_EXT,
371 * Matches any ICMPv6 header.
373 * See struct rte_flow_item_icmp6.
375 RTE_FLOW_ITEM_TYPE_ICMP6,
378 * Matches an ICMPv6 neighbor discovery solicitation.
380 * See struct rte_flow_item_icmp6_nd_ns.
382 RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS,
385 * Matches an ICMPv6 neighbor discovery advertisement.
387 * See struct rte_flow_item_icmp6_nd_na.
389 RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA,
392 * Matches the presence of any ICMPv6 neighbor discovery option.
394 * See struct rte_flow_item_icmp6_nd_opt.
396 RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT,
399 * Matches an ICMPv6 neighbor discovery source Ethernet link-layer
402 * See struct rte_flow_item_icmp6_nd_opt_sla_eth.
404 RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_SLA_ETH,
407 * Matches an ICMPv6 neighbor discovery target Ethernet link-layer
410 * See struct rte_flow_item_icmp6_nd_opt_tla_eth.
412 RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_TLA_ETH,
415 * Matches specified mark field.
417 * See struct rte_flow_item_mark.
419 RTE_FLOW_ITEM_TYPE_MARK,
424 * Matches a metadata value.
426 * See struct rte_flow_item_meta.
428 RTE_FLOW_ITEM_TYPE_META,
431 * Matches a GRE optional key field.
433 * The value should a big-endian 32bit integer.
435 * When this item present the K bit is implicitly matched as "1"
436 * in the default mask.
439 * @code rte_be32_t * @endcode
441 RTE_FLOW_ITEM_TYPE_GRE_KEY,
444 * Matches a GTP extension header: PDU session container.
446 * Configure flow for GTP packets with extension header type 0x85.
448 * See struct rte_flow_item_gtp_psc.
450 RTE_FLOW_ITEM_TYPE_GTP_PSC,
453 * Matches a PPPoE header.
455 * Configure flow for PPPoE session packets.
457 * See struct rte_flow_item_pppoe.
459 RTE_FLOW_ITEM_TYPE_PPPOES,
462 * Matches a PPPoE header.
464 * Configure flow for PPPoE discovery packets.
466 * See struct rte_flow_item_pppoe.
468 RTE_FLOW_ITEM_TYPE_PPPOED,
471 * Matches a PPPoE optional proto_id field.
473 * It only applies to PPPoE session packets.
475 * See struct rte_flow_item_pppoe_proto_id.
477 RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID,
480 * Matches Network service header (NSH).
481 * See struct rte_flow_item_nsh.
484 RTE_FLOW_ITEM_TYPE_NSH,
487 * Matches Internet Group Management Protocol (IGMP).
488 * See struct rte_flow_item_igmp.
491 RTE_FLOW_ITEM_TYPE_IGMP,
494 * Matches IP Authentication Header (AH).
495 * See struct rte_flow_item_ah.
498 RTE_FLOW_ITEM_TYPE_AH,
501 * Matches a HIGIG header.
502 * see struct rte_flow_item_higig2_hdr.
504 RTE_FLOW_ITEM_TYPE_HIGIG2,
509 * Matches a tag value.
511 * See struct rte_flow_item_tag.
513 RTE_FLOW_ITEM_TYPE_TAG,
516 * Matches a L2TPv3 over IP header.
518 * Configure flow for L2TPv3 over IP packets.
520 * See struct rte_flow_item_l2tpv3oip.
522 RTE_FLOW_ITEM_TYPE_L2TPV3OIP,
525 * Matches PFCP Header.
526 * See struct rte_flow_item_pfcp.
529 RTE_FLOW_ITEM_TYPE_PFCP,
532 * Matches eCPRI Header.
534 * Configure flow for eCPRI over ETH or UDP packets.
536 * See struct rte_flow_item_ecpri.
538 RTE_FLOW_ITEM_TYPE_ECPRI,
541 * Matches the presence of IPv6 fragment extension header.
543 * See struct rte_flow_item_ipv6_frag_ext.
545 RTE_FLOW_ITEM_TYPE_IPV6_FRAG_EXT,
550 * RTE_FLOW_ITEM_TYPE_HIGIG2
551 * Matches higig2 header
554 struct rte_flow_item_higig2_hdr {
555 struct rte_higig2_hdr hdr;
558 /** Default mask for RTE_FLOW_ITEM_TYPE_HIGIG2. */
560 static const struct rte_flow_item_higig2_hdr rte_flow_item_higig2_hdr_mask = {
563 .classification = 0xffff,
571 * RTE_FLOW_ITEM_TYPE_ANY
573 * Matches any protocol in place of the current layer, a single ANY may also
574 * stand for several protocol layers.
576 * This is usually specified as the first pattern item when looking for a
577 * protocol anywhere in a packet.
579 * A zeroed mask stands for any number of layers.
581 struct rte_flow_item_any {
582 uint32_t num; /**< Number of layers covered. */
585 /** Default mask for RTE_FLOW_ITEM_TYPE_ANY. */
587 static const struct rte_flow_item_any rte_flow_item_any_mask = {
593 * RTE_FLOW_ITEM_TYPE_VF
595 * Matches traffic originating from (ingress) or going to (egress) a given
596 * virtual function of the current device.
598 * If supported, should work even if the virtual function is not managed by
599 * the application and thus not associated with a DPDK port ID.
601 * Note this pattern item does not match VF representors traffic which, as
602 * separate entities, should be addressed through their own DPDK port IDs.
604 * - Can be specified multiple times to match traffic addressed to several
606 * - Can be combined with a PF item to match both PF and VF traffic.
608 * A zeroed mask can be used to match any VF ID.
610 struct rte_flow_item_vf {
611 uint32_t id; /**< VF ID. */
614 /** Default mask for RTE_FLOW_ITEM_TYPE_VF. */
616 static const struct rte_flow_item_vf rte_flow_item_vf_mask = {
622 * RTE_FLOW_ITEM_TYPE_PHY_PORT
624 * Matches traffic originating from (ingress) or going to (egress) a
625 * physical port of the underlying device.
627 * The first PHY_PORT item overrides the physical port normally associated
628 * with the specified DPDK input port (port_id). This item can be provided
629 * several times to match additional physical ports.
631 * Note that physical ports are not necessarily tied to DPDK input ports
632 * (port_id) when those are not under DPDK control. Possible values are
633 * specific to each device, they are not necessarily indexed from zero and
634 * may not be contiguous.
636 * As a device property, the list of allowed values as well as the value
637 * associated with a port_id should be retrieved by other means.
639 * A zeroed mask can be used to match any port index.
641 struct rte_flow_item_phy_port {
642 uint32_t index; /**< Physical port index. */
645 /** Default mask for RTE_FLOW_ITEM_TYPE_PHY_PORT. */
647 static const struct rte_flow_item_phy_port rte_flow_item_phy_port_mask = {
653 * RTE_FLOW_ITEM_TYPE_PORT_ID
655 * Matches traffic originating from (ingress) or going to (egress) a given
658 * Normally only supported if the port ID in question is known by the
659 * underlying PMD and related to the device the flow rule is created
662 * This must not be confused with @p PHY_PORT which refers to the physical
663 * port of a device, whereas @p PORT_ID refers to a struct rte_eth_dev
664 * object on the application side (also known as "port representor"
665 * depending on the kind of underlying device).
667 struct rte_flow_item_port_id {
668 uint32_t id; /**< DPDK port ID. */
671 /** Default mask for RTE_FLOW_ITEM_TYPE_PORT_ID. */
673 static const struct rte_flow_item_port_id rte_flow_item_port_id_mask = {
679 * RTE_FLOW_ITEM_TYPE_RAW
681 * Matches a byte string of a given length at a given offset.
683 * Offset is either absolute (using the start of the packet) or relative to
684 * the end of the previous matched item in the stack, in which case negative
685 * values are allowed.
687 * If search is enabled, offset is used as the starting point. The search
688 * area can be delimited by setting limit to a nonzero value, which is the
689 * maximum number of bytes after offset where the pattern may start.
691 * Matching a zero-length pattern is allowed, doing so resets the relative
692 * offset for subsequent items.
694 * This type does not support ranges (struct rte_flow_item.last).
696 struct rte_flow_item_raw {
697 uint32_t relative:1; /**< Look for pattern after the previous item. */
698 uint32_t search:1; /**< Search pattern from offset (see also limit). */
699 uint32_t reserved:30; /**< Reserved, must be set to zero. */
700 int32_t offset; /**< Absolute or relative offset for pattern. */
701 uint16_t limit; /**< Search area limit for start of pattern. */
702 uint16_t length; /**< Pattern length. */
703 const uint8_t *pattern; /**< Byte string to look for. */
706 /** Default mask for RTE_FLOW_ITEM_TYPE_RAW. */
708 static const struct rte_flow_item_raw rte_flow_item_raw_mask = {
711 .reserved = 0x3fffffff,
712 .offset = 0xffffffff,
720 * RTE_FLOW_ITEM_TYPE_ETH
722 * Matches an Ethernet header.
724 * The @p type field either stands for "EtherType" or "TPID" when followed
725 * by so-called layer 2.5 pattern items such as RTE_FLOW_ITEM_TYPE_VLAN. In
726 * the latter case, @p type refers to that of the outer header, with the
727 * inner EtherType/TPID provided by the subsequent pattern item. This is the
728 * same order as on the wire.
729 * If the @p type field contains a TPID value, then only tagged packets with the
730 * specified TPID will match the pattern.
731 * The field @p has_vlan can be used to match any type of tagged packets,
732 * instead of using the @p type field.
733 * If the @p type and @p has_vlan fields are not specified, then both tagged
734 * and untagged packets will match the pattern.
736 struct rte_flow_item_eth {
737 struct rte_ether_addr dst; /**< Destination MAC. */
738 struct rte_ether_addr src; /**< Source MAC. */
739 rte_be16_t type; /**< EtherType or TPID. */
740 uint32_t has_vlan:1; /**< Packet header contains at least one VLAN. */
741 uint32_t reserved:31; /**< Reserved, must be zero. */
744 /** Default mask for RTE_FLOW_ITEM_TYPE_ETH. */
746 static const struct rte_flow_item_eth rte_flow_item_eth_mask = {
747 .dst.addr_bytes = "\xff\xff\xff\xff\xff\xff",
748 .src.addr_bytes = "\xff\xff\xff\xff\xff\xff",
749 .type = RTE_BE16(0x0000),
754 * RTE_FLOW_ITEM_TYPE_VLAN
756 * Matches an 802.1Q/ad VLAN tag.
758 * The corresponding standard outer EtherType (TPID) values are
759 * RTE_ETHER_TYPE_VLAN or RTE_ETHER_TYPE_QINQ. It can be overridden by
760 * the preceding pattern item.
761 * If a @p VLAN item is present in the pattern, then only tagged packets will
763 * The field @p has_more_vlan can be used to match any type of tagged packets,
764 * instead of using the @p inner_type field.
765 * If the @p inner_type and @p has_more_vlan fields are not specified,
766 * then any tagged packets will match the pattern.
768 struct rte_flow_item_vlan {
769 rte_be16_t tci; /**< Tag control information. */
770 rte_be16_t inner_type; /**< Inner EtherType or TPID. */
771 uint32_t has_more_vlan:1;
772 /**< Packet header contains at least one more VLAN, after this VLAN. */
773 uint32_t reserved:31; /**< Reserved, must be zero. */
776 /** Default mask for RTE_FLOW_ITEM_TYPE_VLAN. */
778 static const struct rte_flow_item_vlan rte_flow_item_vlan_mask = {
779 .tci = RTE_BE16(0x0fff),
780 .inner_type = RTE_BE16(0x0000),
785 * RTE_FLOW_ITEM_TYPE_IPV4
787 * Matches an IPv4 header.
789 * Note: IPv4 options are handled by dedicated pattern items.
791 struct rte_flow_item_ipv4 {
792 struct rte_ipv4_hdr hdr; /**< IPv4 header definition. */
795 /** Default mask for RTE_FLOW_ITEM_TYPE_IPV4. */
797 static const struct rte_flow_item_ipv4 rte_flow_item_ipv4_mask = {
799 .src_addr = RTE_BE32(0xffffffff),
800 .dst_addr = RTE_BE32(0xffffffff),
806 * RTE_FLOW_ITEM_TYPE_IPV6.
808 * Matches an IPv6 header.
810 * Dedicated flags indicate if header contains specific extension headers.
812 struct rte_flow_item_ipv6 {
813 struct rte_ipv6_hdr hdr; /**< IPv6 header definition. */
814 uint32_t has_hop_ext:1;
815 /**< Header contains Hop-by-Hop Options extension header. */
816 uint32_t has_route_ext:1;
817 /**< Header contains Routing extension header. */
818 uint32_t has_frag_ext:1;
819 /**< Header contains Fragment extension header. */
820 uint32_t has_auth_ext:1;
821 /**< Header contains Authentication extension header. */
822 uint32_t has_esp_ext:1;
823 /**< Header contains Encapsulation Security Payload extension header. */
824 uint32_t has_dest_ext:1;
825 /**< Header contains Destination Options extension header. */
826 uint32_t has_mobil_ext:1;
827 /**< Header contains Mobility extension header. */
828 uint32_t has_hip_ext:1;
829 /**< Header contains Host Identity Protocol extension header. */
830 uint32_t has_shim6_ext:1;
831 /**< Header contains Shim6 Protocol extension header. */
832 uint32_t reserved:23;
833 /**< Reserved for future extension headers, must be zero. */
836 /** Default mask for RTE_FLOW_ITEM_TYPE_IPV6. */
838 static const struct rte_flow_item_ipv6 rte_flow_item_ipv6_mask = {
841 "\xff\xff\xff\xff\xff\xff\xff\xff"
842 "\xff\xff\xff\xff\xff\xff\xff\xff",
844 "\xff\xff\xff\xff\xff\xff\xff\xff"
845 "\xff\xff\xff\xff\xff\xff\xff\xff",
851 * RTE_FLOW_ITEM_TYPE_ICMP.
853 * Matches an ICMP header.
855 struct rte_flow_item_icmp {
856 struct rte_icmp_hdr hdr; /**< ICMP header definition. */
859 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP. */
861 static const struct rte_flow_item_icmp rte_flow_item_icmp_mask = {
870 * RTE_FLOW_ITEM_TYPE_UDP.
872 * Matches a UDP header.
874 struct rte_flow_item_udp {
875 struct rte_udp_hdr hdr; /**< UDP header definition. */
878 /** Default mask for RTE_FLOW_ITEM_TYPE_UDP. */
880 static const struct rte_flow_item_udp rte_flow_item_udp_mask = {
882 .src_port = RTE_BE16(0xffff),
883 .dst_port = RTE_BE16(0xffff),
889 * RTE_FLOW_ITEM_TYPE_TCP.
891 * Matches a TCP header.
893 struct rte_flow_item_tcp {
894 struct rte_tcp_hdr hdr; /**< TCP header definition. */
897 /** Default mask for RTE_FLOW_ITEM_TYPE_TCP. */
899 static const struct rte_flow_item_tcp rte_flow_item_tcp_mask = {
901 .src_port = RTE_BE16(0xffff),
902 .dst_port = RTE_BE16(0xffff),
908 * RTE_FLOW_ITEM_TYPE_SCTP.
910 * Matches a SCTP header.
912 struct rte_flow_item_sctp {
913 struct rte_sctp_hdr hdr; /**< SCTP header definition. */
916 /** Default mask for RTE_FLOW_ITEM_TYPE_SCTP. */
918 static const struct rte_flow_item_sctp rte_flow_item_sctp_mask = {
920 .src_port = RTE_BE16(0xffff),
921 .dst_port = RTE_BE16(0xffff),
927 * RTE_FLOW_ITEM_TYPE_VXLAN.
929 * Matches a VXLAN header (RFC 7348).
931 struct rte_flow_item_vxlan {
932 uint8_t flags; /**< Normally 0x08 (I flag). */
933 uint8_t rsvd0[3]; /**< Reserved, normally 0x000000. */
934 uint8_t vni[3]; /**< VXLAN identifier. */
935 uint8_t rsvd1; /**< Reserved, normally 0x00. */
938 /** Default mask for RTE_FLOW_ITEM_TYPE_VXLAN. */
940 static const struct rte_flow_item_vxlan rte_flow_item_vxlan_mask = {
941 .vni = "\xff\xff\xff",
946 * RTE_FLOW_ITEM_TYPE_E_TAG.
948 * Matches a E-tag header.
950 * The corresponding standard outer EtherType (TPID) value is
951 * RTE_ETHER_TYPE_ETAG. It can be overridden by the preceding pattern item.
953 struct rte_flow_item_e_tag {
955 * E-Tag control information (E-TCI).
956 * E-PCP (3b), E-DEI (1b), ingress E-CID base (12b).
958 rte_be16_t epcp_edei_in_ecid_b;
959 /** Reserved (2b), GRP (2b), E-CID base (12b). */
960 rte_be16_t rsvd_grp_ecid_b;
961 uint8_t in_ecid_e; /**< Ingress E-CID ext. */
962 uint8_t ecid_e; /**< E-CID ext. */
963 rte_be16_t inner_type; /**< Inner EtherType or TPID. */
966 /** Default mask for RTE_FLOW_ITEM_TYPE_E_TAG. */
968 static const struct rte_flow_item_e_tag rte_flow_item_e_tag_mask = {
969 .rsvd_grp_ecid_b = RTE_BE16(0x3fff),
974 * RTE_FLOW_ITEM_TYPE_NVGRE.
976 * Matches a NVGRE header.
978 struct rte_flow_item_nvgre {
980 * Checksum (1b), undefined (1b), key bit (1b), sequence number (1b),
981 * reserved 0 (9b), version (3b).
983 * c_k_s_rsvd0_ver must have value 0x2000 according to RFC 7637.
985 rte_be16_t c_k_s_rsvd0_ver;
986 rte_be16_t protocol; /**< Protocol type (0x6558). */
987 uint8_t tni[3]; /**< Virtual subnet ID. */
988 uint8_t flow_id; /**< Flow ID. */
991 /** Default mask for RTE_FLOW_ITEM_TYPE_NVGRE. */
993 static const struct rte_flow_item_nvgre rte_flow_item_nvgre_mask = {
994 .tni = "\xff\xff\xff",
999 * RTE_FLOW_ITEM_TYPE_MPLS.
1001 * Matches a MPLS header.
1003 struct rte_flow_item_mpls {
1005 * Label (20b), TC (3b), Bottom of Stack (1b).
1007 uint8_t label_tc_s[3];
1008 uint8_t ttl; /** Time-to-Live. */
1011 /** Default mask for RTE_FLOW_ITEM_TYPE_MPLS. */
1013 static const struct rte_flow_item_mpls rte_flow_item_mpls_mask = {
1014 .label_tc_s = "\xff\xff\xf0",
1019 * RTE_FLOW_ITEM_TYPE_GRE.
1021 * Matches a GRE header.
1023 struct rte_flow_item_gre {
1025 * Checksum (1b), reserved 0 (12b), version (3b).
1026 * Refer to RFC 2784.
1028 rte_be16_t c_rsvd0_ver;
1029 rte_be16_t protocol; /**< Protocol type. */
1032 /** Default mask for RTE_FLOW_ITEM_TYPE_GRE. */
1034 static const struct rte_flow_item_gre rte_flow_item_gre_mask = {
1035 .protocol = RTE_BE16(0xffff),
1040 * RTE_FLOW_ITEM_TYPE_FUZZY
1042 * Fuzzy pattern match, expect faster than default.
1044 * This is for device that support fuzzy match option.
1045 * Usually a fuzzy match is fast but the cost is accuracy.
1046 * i.e. Signature Match only match pattern's hash value, but it is
1047 * possible two different patterns have the same hash value.
1049 * Matching accuracy level can be configure by threshold.
1050 * Driver can divide the range of threshold and map to different
1051 * accuracy levels that device support.
1053 * Threshold 0 means perfect match (no fuzziness), while threshold
1054 * 0xffffffff means fuzziest match.
1056 struct rte_flow_item_fuzzy {
1057 uint32_t thresh; /**< Accuracy threshold. */
1060 /** Default mask for RTE_FLOW_ITEM_TYPE_FUZZY. */
1062 static const struct rte_flow_item_fuzzy rte_flow_item_fuzzy_mask = {
1063 .thresh = 0xffffffff,
1068 * RTE_FLOW_ITEM_TYPE_GTP.
1070 * Matches a GTPv1 header.
1072 struct rte_flow_item_gtp {
1074 * Version (3b), protocol type (1b), reserved (1b),
1075 * Extension header flag (1b),
1076 * Sequence number flag (1b),
1077 * N-PDU number flag (1b).
1079 uint8_t v_pt_rsv_flags;
1080 uint8_t msg_type; /**< Message type. */
1081 rte_be16_t msg_len; /**< Message length. */
1082 rte_be32_t teid; /**< Tunnel endpoint identifier. */
1085 /** Default mask for RTE_FLOW_ITEM_TYPE_GTP. */
1087 static const struct rte_flow_item_gtp rte_flow_item_gtp_mask = {
1088 .teid = RTE_BE32(0xffffffff),
1093 * RTE_FLOW_ITEM_TYPE_ESP
1095 * Matches an ESP header.
1097 struct rte_flow_item_esp {
1098 struct rte_esp_hdr hdr; /**< ESP header definition. */
1101 /** Default mask for RTE_FLOW_ITEM_TYPE_ESP. */
1103 static const struct rte_flow_item_esp rte_flow_item_esp_mask = {
1105 .spi = RTE_BE32(0xffffffff),
1111 * RTE_FLOW_ITEM_TYPE_GENEVE.
1113 * Matches a GENEVE header.
1115 struct rte_flow_item_geneve {
1117 * Version (2b), length of the options fields (6b), OAM packet (1b),
1118 * critical options present (1b), reserved 0 (6b).
1120 rte_be16_t ver_opt_len_o_c_rsvd0;
1121 rte_be16_t protocol; /**< Protocol type. */
1122 uint8_t vni[3]; /**< Virtual Network Identifier. */
1123 uint8_t rsvd1; /**< Reserved, normally 0x00. */
1126 /** Default mask for RTE_FLOW_ITEM_TYPE_GENEVE. */
1128 static const struct rte_flow_item_geneve rte_flow_item_geneve_mask = {
1129 .vni = "\xff\xff\xff",
1134 * RTE_FLOW_ITEM_TYPE_VXLAN_GPE (draft-ietf-nvo3-vxlan-gpe-05).
1136 * Matches a VXLAN-GPE header.
1138 struct rte_flow_item_vxlan_gpe {
1139 uint8_t flags; /**< Normally 0x0c (I and P flags). */
1140 uint8_t rsvd0[2]; /**< Reserved, normally 0x0000. */
1141 uint8_t protocol; /**< Protocol type. */
1142 uint8_t vni[3]; /**< VXLAN identifier. */
1143 uint8_t rsvd1; /**< Reserved, normally 0x00. */
1146 /** Default mask for RTE_FLOW_ITEM_TYPE_VXLAN_GPE. */
1148 static const struct rte_flow_item_vxlan_gpe rte_flow_item_vxlan_gpe_mask = {
1149 .vni = "\xff\xff\xff",
1154 * RTE_FLOW_ITEM_TYPE_ARP_ETH_IPV4
1156 * Matches an ARP header for Ethernet/IPv4.
1158 struct rte_flow_item_arp_eth_ipv4 {
1159 rte_be16_t hrd; /**< Hardware type, normally 1. */
1160 rte_be16_t pro; /**< Protocol type, normally 0x0800. */
1161 uint8_t hln; /**< Hardware address length, normally 6. */
1162 uint8_t pln; /**< Protocol address length, normally 4. */
1163 rte_be16_t op; /**< Opcode (1 for request, 2 for reply). */
1164 struct rte_ether_addr sha; /**< Sender hardware address. */
1165 rte_be32_t spa; /**< Sender IPv4 address. */
1166 struct rte_ether_addr tha; /**< Target hardware address. */
1167 rte_be32_t tpa; /**< Target IPv4 address. */
1170 /** Default mask for RTE_FLOW_ITEM_TYPE_ARP_ETH_IPV4. */
1172 static const struct rte_flow_item_arp_eth_ipv4
1173 rte_flow_item_arp_eth_ipv4_mask = {
1174 .sha.addr_bytes = "\xff\xff\xff\xff\xff\xff",
1175 .spa = RTE_BE32(0xffffffff),
1176 .tha.addr_bytes = "\xff\xff\xff\xff\xff\xff",
1177 .tpa = RTE_BE32(0xffffffff),
1182 * RTE_FLOW_ITEM_TYPE_IPV6_EXT
1184 * Matches the presence of any IPv6 extension header.
1186 * Normally preceded by any of:
1188 * - RTE_FLOW_ITEM_TYPE_IPV6
1189 * - RTE_FLOW_ITEM_TYPE_IPV6_EXT
1191 struct rte_flow_item_ipv6_ext {
1192 uint8_t next_hdr; /**< Next header. */
1195 /** Default mask for RTE_FLOW_ITEM_TYPE_IPV6_EXT. */
1198 struct rte_flow_item_ipv6_ext rte_flow_item_ipv6_ext_mask = {
1204 * RTE_FLOW_ITEM_TYPE_IPV6_FRAG_EXT
1206 * Matches the presence of IPv6 fragment extension header.
1208 * Preceded by any of:
1210 * - RTE_FLOW_ITEM_TYPE_IPV6
1211 * - RTE_FLOW_ITEM_TYPE_IPV6_EXT
1213 struct rte_flow_item_ipv6_frag_ext {
1214 struct rte_ipv6_fragment_ext hdr;
1218 * RTE_FLOW_ITEM_TYPE_ICMP6
1220 * Matches any ICMPv6 header.
1222 struct rte_flow_item_icmp6 {
1223 uint8_t type; /**< ICMPv6 type. */
1224 uint8_t code; /**< ICMPv6 code. */
1225 uint16_t checksum; /**< ICMPv6 checksum. */
1228 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6. */
1230 static const struct rte_flow_item_icmp6 rte_flow_item_icmp6_mask = {
1237 * RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS
1239 * Matches an ICMPv6 neighbor discovery solicitation.
1241 struct rte_flow_item_icmp6_nd_ns {
1242 uint8_t type; /**< ICMPv6 type, normally 135. */
1243 uint8_t code; /**< ICMPv6 code, normally 0. */
1244 rte_be16_t checksum; /**< ICMPv6 checksum. */
1245 rte_be32_t reserved; /**< Reserved, normally 0. */
1246 uint8_t target_addr[16]; /**< Target address. */
1249 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS. */
1252 struct rte_flow_item_icmp6_nd_ns rte_flow_item_icmp6_nd_ns_mask = {
1254 "\xff\xff\xff\xff\xff\xff\xff\xff"
1255 "\xff\xff\xff\xff\xff\xff\xff\xff",
1260 * RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA
1262 * Matches an ICMPv6 neighbor discovery advertisement.
1264 struct rte_flow_item_icmp6_nd_na {
1265 uint8_t type; /**< ICMPv6 type, normally 136. */
1266 uint8_t code; /**< ICMPv6 code, normally 0. */
1267 rte_be16_t checksum; /**< ICMPv6 checksum. */
1269 * Route flag (1b), solicited flag (1b), override flag (1b),
1272 rte_be32_t rso_reserved;
1273 uint8_t target_addr[16]; /**< Target address. */
1276 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA. */
1279 struct rte_flow_item_icmp6_nd_na rte_flow_item_icmp6_nd_na_mask = {
1281 "\xff\xff\xff\xff\xff\xff\xff\xff"
1282 "\xff\xff\xff\xff\xff\xff\xff\xff",
1287 * RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT
1289 * Matches the presence of any ICMPv6 neighbor discovery option.
1291 * Normally preceded by any of:
1293 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA
1294 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS
1295 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT
1297 struct rte_flow_item_icmp6_nd_opt {
1298 uint8_t type; /**< ND option type. */
1299 uint8_t length; /**< ND option length. */
1302 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT. */
1304 static const struct rte_flow_item_icmp6_nd_opt
1305 rte_flow_item_icmp6_nd_opt_mask = {
1311 * RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_SLA_ETH
1313 * Matches an ICMPv6 neighbor discovery source Ethernet link-layer address
1316 * Normally preceded by any of:
1318 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA
1319 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT
1321 struct rte_flow_item_icmp6_nd_opt_sla_eth {
1322 uint8_t type; /**< ND option type, normally 1. */
1323 uint8_t length; /**< ND option length, normally 1. */
1324 struct rte_ether_addr sla; /**< Source Ethernet LLA. */
1327 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_SLA_ETH. */
1329 static const struct rte_flow_item_icmp6_nd_opt_sla_eth
1330 rte_flow_item_icmp6_nd_opt_sla_eth_mask = {
1331 .sla.addr_bytes = "\xff\xff\xff\xff\xff\xff",
1336 * RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_TLA_ETH
1338 * Matches an ICMPv6 neighbor discovery target Ethernet link-layer address
1341 * Normally preceded by any of:
1343 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS
1344 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT
1346 struct rte_flow_item_icmp6_nd_opt_tla_eth {
1347 uint8_t type; /**< ND option type, normally 2. */
1348 uint8_t length; /**< ND option length, normally 1. */
1349 struct rte_ether_addr tla; /**< Target Ethernet LLA. */
1352 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_TLA_ETH. */
1354 static const struct rte_flow_item_icmp6_nd_opt_tla_eth
1355 rte_flow_item_icmp6_nd_opt_tla_eth_mask = {
1356 .tla.addr_bytes = "\xff\xff\xff\xff\xff\xff",
1361 * RTE_FLOW_ITEM_TYPE_META
1363 * Matches a specified metadata value. On egress, metadata can be set
1364 * either by mbuf dynamic metadata field with PKT_TX_DYNF_METADATA flag or
1365 * RTE_FLOW_ACTION_TYPE_SET_META. On ingress, RTE_FLOW_ACTION_TYPE_SET_META
1366 * sets metadata for a packet and the metadata will be reported via mbuf
1367 * metadata dynamic field with PKT_RX_DYNF_METADATA flag. The dynamic mbuf
1368 * field must be registered in advance by rte_flow_dynf_metadata_register().
1370 struct rte_flow_item_meta {
1374 /** Default mask for RTE_FLOW_ITEM_TYPE_META. */
1376 static const struct rte_flow_item_meta rte_flow_item_meta_mask = {
1382 * RTE_FLOW_ITEM_TYPE_GTP_PSC.
1384 * Matches a GTP PDU extension header with type 0x85.
1386 struct rte_flow_item_gtp_psc {
1387 uint8_t pdu_type; /**< PDU type. */
1388 uint8_t qfi; /**< QoS flow identifier. */
1391 /** Default mask for RTE_FLOW_ITEM_TYPE_GTP_PSC. */
1393 static const struct rte_flow_item_gtp_psc
1394 rte_flow_item_gtp_psc_mask = {
1400 * RTE_FLOW_ITEM_TYPE_PPPOE.
1402 * Matches a PPPoE header.
1404 struct rte_flow_item_pppoe {
1406 * Version (4b), type (4b).
1408 uint8_t version_type;
1409 uint8_t code; /**< Message type. */
1410 rte_be16_t session_id; /**< Session identifier. */
1411 rte_be16_t length; /**< Payload length. */
1415 * RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID.
1417 * Matches a PPPoE optional proto_id field.
1419 * It only applies to PPPoE session packets.
1421 * Normally preceded by any of:
1423 * - RTE_FLOW_ITEM_TYPE_PPPOE
1424 * - RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID
1426 struct rte_flow_item_pppoe_proto_id {
1427 rte_be16_t proto_id; /**< PPP protocol identifier. */
1430 /** Default mask for RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID. */
1432 static const struct rte_flow_item_pppoe_proto_id
1433 rte_flow_item_pppoe_proto_id_mask = {
1434 .proto_id = RTE_BE16(0xffff),
1440 * @b EXPERIMENTAL: this structure may change without prior notice
1442 * RTE_FLOW_ITEM_TYPE_TAG
1444 * Matches a specified tag value at the specified index.
1446 struct rte_flow_item_tag {
1451 /** Default mask for RTE_FLOW_ITEM_TYPE_TAG. */
1453 static const struct rte_flow_item_tag rte_flow_item_tag_mask = {
1460 * RTE_FLOW_ITEM_TYPE_L2TPV3OIP.
1462 * Matches a L2TPv3 over IP header.
1464 struct rte_flow_item_l2tpv3oip {
1465 rte_be32_t session_id; /**< Session ID. */
1468 /** Default mask for RTE_FLOW_ITEM_TYPE_L2TPV3OIP. */
1470 static const struct rte_flow_item_l2tpv3oip rte_flow_item_l2tpv3oip_mask = {
1471 .session_id = RTE_BE32(UINT32_MAX),
1478 * @b EXPERIMENTAL: this structure may change without prior notice
1480 * RTE_FLOW_ITEM_TYPE_MARK
1482 * Matches an arbitrary integer value which was set using the ``MARK`` action
1483 * in a previously matched rule.
1485 * This item can only be specified once as a match criteria as the ``MARK``
1486 * action can only be specified once in a flow action.
1488 * This value is arbitrary and application-defined. Maximum allowed value
1489 * depends on the underlying implementation.
1491 * Depending on the underlying implementation the MARK item may be supported on
1492 * the physical device, with virtual groups in the PMD or not at all.
1494 struct rte_flow_item_mark {
1495 uint32_t id; /**< Integer value to match against. */
1498 /** Default mask for RTE_FLOW_ITEM_TYPE_MARK. */
1500 static const struct rte_flow_item_mark rte_flow_item_mark_mask = {
1507 * @b EXPERIMENTAL: this structure may change without prior notice
1509 * RTE_FLOW_ITEM_TYPE_NSH
1511 * Match network service header (NSH), RFC 8300
1514 struct rte_flow_item_nsh {
1517 uint32_t reserved:1;
1520 uint32_t reserved1:4;
1522 uint32_t next_proto:8;
1527 /** Default mask for RTE_FLOW_ITEM_TYPE_NSH. */
1529 static const struct rte_flow_item_nsh rte_flow_item_nsh_mask = {
1539 * @b EXPERIMENTAL: this structure may change without prior notice
1541 * RTE_FLOW_ITEM_TYPE_IGMP
1543 * Match Internet Group Management Protocol (IGMP), RFC 2236
1546 struct rte_flow_item_igmp {
1548 uint32_t max_resp_time:8;
1549 uint32_t checksum:16;
1550 uint32_t group_addr;
1553 /** Default mask for RTE_FLOW_ITEM_TYPE_IGMP. */
1555 static const struct rte_flow_item_igmp rte_flow_item_igmp_mask = {
1556 .group_addr = 0xffffffff,
1562 * @b EXPERIMENTAL: this structure may change without prior notice
1564 * RTE_FLOW_ITEM_TYPE_AH
1566 * Match IP Authentication Header (AH), RFC 4302
1569 struct rte_flow_item_ah {
1570 uint32_t next_hdr:8;
1571 uint32_t payload_len:8;
1572 uint32_t reserved:16;
1577 /** Default mask for RTE_FLOW_ITEM_TYPE_AH. */
1579 static const struct rte_flow_item_ah rte_flow_item_ah_mask = {
1586 * @b EXPERIMENTAL: this structure may change without prior notice
1588 * RTE_FLOW_ITEM_TYPE_PFCP
1592 struct rte_flow_item_pfcp {
1599 /** Default mask for RTE_FLOW_ITEM_TYPE_PFCP. */
1601 static const struct rte_flow_item_pfcp rte_flow_item_pfcp_mask = {
1603 .seid = RTE_BE64(UINT64_C(0xffffffffffffffff)),
1609 * @b EXPERIMENTAL: this structure may change without prior notice
1611 * RTE_FLOW_ITEM_TYPE_ECPRI
1613 * Match eCPRI Header
1615 struct rte_flow_item_ecpri {
1616 struct rte_ecpri_combined_msg_hdr hdr;
1619 /** Default mask for RTE_FLOW_ITEM_TYPE_ECPRI. */
1621 static const struct rte_flow_item_ecpri rte_flow_item_ecpri_mask = {
1631 * Matching pattern item definition.
1633 * A pattern is formed by stacking items starting from the lowest protocol
1634 * layer to match. This stacking restriction does not apply to meta items
1635 * which can be placed anywhere in the stack without affecting the meaning
1636 * of the resulting pattern.
1638 * Patterns are terminated by END items.
1640 * The spec field should be a valid pointer to a structure of the related
1641 * item type. It may remain unspecified (NULL) in many cases to request
1642 * broad (nonspecific) matching. In such cases, last and mask must also be
1645 * Optionally, last can point to a structure of the same type to define an
1646 * inclusive range. This is mostly supported by integer and address fields,
1647 * may cause errors otherwise. Fields that do not support ranges must be set
1648 * to 0 or to the same value as the corresponding fields in spec.
1650 * Only the fields defined to nonzero values in the default masks (see
1651 * rte_flow_item_{name}_mask constants) are considered relevant by
1652 * default. This can be overridden by providing a mask structure of the
1653 * same type with applicable bits set to one. It can also be used to
1654 * partially filter out specific fields (e.g. as an alternate mean to match
1655 * ranges of IP addresses).
1657 * Mask is a simple bit-mask applied before interpreting the contents of
1658 * spec and last, which may yield unexpected results if not used
1659 * carefully. For example, if for an IPv4 address field, spec provides
1660 * 10.1.2.3, last provides 10.3.4.5 and mask provides 255.255.0.0, the
1661 * effective range becomes 10.1.0.0 to 10.3.255.255.
1663 struct rte_flow_item {
1664 enum rte_flow_item_type type; /**< Item type. */
1665 const void *spec; /**< Pointer to item specification structure. */
1666 const void *last; /**< Defines an inclusive range (spec to last). */
1667 const void *mask; /**< Bit-mask applied to spec and last. */
1673 * Each possible action is represented by a type.
1674 * An action can have an associated configuration object.
1675 * Several actions combined in a list can be assigned
1676 * to a flow rule and are performed in order.
1678 * They fall in three categories:
1680 * - Actions that modify the fate of matching traffic, for instance by
1681 * dropping or assigning it a specific destination.
1683 * - Actions that modify matching traffic contents or its properties. This
1684 * includes adding/removing encapsulation, encryption, compression and
1687 * - Actions related to the flow rule itself, such as updating counters or
1688 * making it non-terminating.
1690 * Flow rules being terminating by default, not specifying any action of the
1691 * fate kind results in undefined behavior. This applies to both ingress and
1694 * PASSTHRU, when supported, makes a flow rule non-terminating.
1696 enum rte_flow_action_type {
1698 * End marker for action lists. Prevents further processing of
1699 * actions, thereby ending the list.
1701 * No associated configuration structure.
1703 RTE_FLOW_ACTION_TYPE_END,
1706 * Used as a placeholder for convenience. It is ignored and simply
1707 * discarded by PMDs.
1709 * No associated configuration structure.
1711 RTE_FLOW_ACTION_TYPE_VOID,
1714 * Leaves traffic up for additional processing by subsequent flow
1715 * rules; makes a flow rule non-terminating.
1717 * No associated configuration structure.
1719 RTE_FLOW_ACTION_TYPE_PASSTHRU,
1722 * RTE_FLOW_ACTION_TYPE_JUMP
1724 * Redirects packets to a group on the current device.
1726 * See struct rte_flow_action_jump.
1728 RTE_FLOW_ACTION_TYPE_JUMP,
1731 * Attaches an integer value to packets and sets PKT_RX_FDIR and
1732 * PKT_RX_FDIR_ID mbuf flags.
1734 * See struct rte_flow_action_mark.
1736 RTE_FLOW_ACTION_TYPE_MARK,
1739 * Flags packets. Similar to MARK without a specific value; only
1740 * sets the PKT_RX_FDIR mbuf flag.
1742 * No associated configuration structure.
1744 RTE_FLOW_ACTION_TYPE_FLAG,
1747 * Assigns packets to a given queue index.
1749 * See struct rte_flow_action_queue.
1751 RTE_FLOW_ACTION_TYPE_QUEUE,
1756 * PASSTHRU overrides this action if both are specified.
1758 * No associated configuration structure.
1760 RTE_FLOW_ACTION_TYPE_DROP,
1763 * Enables counters for this flow rule.
1765 * These counters can be retrieved and reset through rte_flow_query() or
1766 * rte_flow_shared_action_query() if the action provided via handle,
1767 * see struct rte_flow_query_count.
1769 * See struct rte_flow_action_count.
1771 RTE_FLOW_ACTION_TYPE_COUNT,
1774 * Similar to QUEUE, except RSS is additionally performed on packets
1775 * to spread them among several queues according to the provided
1778 * See struct rte_flow_action_rss.
1780 RTE_FLOW_ACTION_TYPE_RSS,
1783 * Directs matching traffic to the physical function (PF) of the
1786 * No associated configuration structure.
1788 RTE_FLOW_ACTION_TYPE_PF,
1791 * Directs matching traffic to a given virtual function of the
1794 * See struct rte_flow_action_vf.
1796 RTE_FLOW_ACTION_TYPE_VF,
1799 * Directs packets to a given physical port index of the underlying
1802 * See struct rte_flow_action_phy_port.
1804 RTE_FLOW_ACTION_TYPE_PHY_PORT,
1807 * Directs matching traffic to a given DPDK port ID.
1809 * See struct rte_flow_action_port_id.
1811 RTE_FLOW_ACTION_TYPE_PORT_ID,
1814 * Traffic metering and policing (MTR).
1816 * See struct rte_flow_action_meter.
1817 * See file rte_mtr.h for MTR object configuration.
1819 RTE_FLOW_ACTION_TYPE_METER,
1822 * Redirects packets to security engine of current device for security
1823 * processing as specified by security session.
1825 * See struct rte_flow_action_security.
1827 RTE_FLOW_ACTION_TYPE_SECURITY,
1830 * Implements OFPAT_SET_MPLS_TTL ("MPLS TTL") as defined by the
1831 * OpenFlow Switch Specification.
1833 * See struct rte_flow_action_of_set_mpls_ttl.
1835 RTE_FLOW_ACTION_TYPE_OF_SET_MPLS_TTL,
1838 * Implements OFPAT_DEC_MPLS_TTL ("decrement MPLS TTL") as defined
1839 * by the OpenFlow Switch Specification.
1841 * No associated configuration structure.
1843 RTE_FLOW_ACTION_TYPE_OF_DEC_MPLS_TTL,
1846 * Implements OFPAT_SET_NW_TTL ("IP TTL") as defined by the OpenFlow
1847 * Switch Specification.
1849 * See struct rte_flow_action_of_set_nw_ttl.
1851 RTE_FLOW_ACTION_TYPE_OF_SET_NW_TTL,
1854 * Implements OFPAT_DEC_NW_TTL ("decrement IP TTL") as defined by
1855 * the OpenFlow Switch Specification.
1857 * No associated configuration structure.
1859 RTE_FLOW_ACTION_TYPE_OF_DEC_NW_TTL,
1862 * Implements OFPAT_COPY_TTL_OUT ("copy TTL "outwards" -- from
1863 * next-to-outermost to outermost") as defined by the OpenFlow
1864 * Switch Specification.
1866 * No associated configuration structure.
1868 RTE_FLOW_ACTION_TYPE_OF_COPY_TTL_OUT,
1871 * Implements OFPAT_COPY_TTL_IN ("copy TTL "inwards" -- from
1872 * outermost to next-to-outermost") as defined by the OpenFlow
1873 * Switch Specification.
1875 * No associated configuration structure.
1877 RTE_FLOW_ACTION_TYPE_OF_COPY_TTL_IN,
1880 * Implements OFPAT_POP_VLAN ("pop the outer VLAN tag") as defined
1881 * by the OpenFlow Switch Specification.
1883 * No associated configuration structure.
1885 RTE_FLOW_ACTION_TYPE_OF_POP_VLAN,
1888 * Implements OFPAT_PUSH_VLAN ("push a new VLAN tag") as defined by
1889 * the OpenFlow Switch Specification.
1891 * See struct rte_flow_action_of_push_vlan.
1893 RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN,
1896 * Implements OFPAT_SET_VLAN_VID ("set the 802.1q VLAN id") as
1897 * defined by the OpenFlow Switch Specification.
1899 * See struct rte_flow_action_of_set_vlan_vid.
1901 RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID,
1904 * Implements OFPAT_SET_LAN_PCP ("set the 802.1q priority") as
1905 * defined by the OpenFlow Switch Specification.
1907 * See struct rte_flow_action_of_set_vlan_pcp.
1909 RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP,
1912 * Implements OFPAT_POP_MPLS ("pop the outer MPLS tag") as defined
1913 * by the OpenFlow Switch Specification.
1915 * See struct rte_flow_action_of_pop_mpls.
1917 RTE_FLOW_ACTION_TYPE_OF_POP_MPLS,
1920 * Implements OFPAT_PUSH_MPLS ("push a new MPLS tag") as defined by
1921 * the OpenFlow Switch Specification.
1923 * See struct rte_flow_action_of_push_mpls.
1925 RTE_FLOW_ACTION_TYPE_OF_PUSH_MPLS,
1928 * Encapsulate flow in VXLAN tunnel as defined in
1929 * rte_flow_action_vxlan_encap action structure.
1931 * See struct rte_flow_action_vxlan_encap.
1933 RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP,
1936 * Decapsulate outer most VXLAN tunnel from matched flow.
1938 * If flow pattern does not define a valid VXLAN tunnel (as specified by
1939 * RFC7348) then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION
1942 RTE_FLOW_ACTION_TYPE_VXLAN_DECAP,
1945 * Encapsulate flow in NVGRE tunnel defined in the
1946 * rte_flow_action_nvgre_encap action structure.
1948 * See struct rte_flow_action_nvgre_encap.
1950 RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP,
1953 * Decapsulate outer most NVGRE tunnel from matched flow.
1955 * If flow pattern does not define a valid NVGRE tunnel (as specified by
1956 * RFC7637) then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION
1959 RTE_FLOW_ACTION_TYPE_NVGRE_DECAP,
1962 * Add outer header whose template is provided in its data buffer
1964 * See struct rte_flow_action_raw_encap.
1966 RTE_FLOW_ACTION_TYPE_RAW_ENCAP,
1969 * Remove outer header whose template is provided in its data buffer.
1971 * See struct rte_flow_action_raw_decap
1973 RTE_FLOW_ACTION_TYPE_RAW_DECAP,
1976 * Modify IPv4 source address in the outermost IPv4 header.
1978 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV4,
1979 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
1981 * See struct rte_flow_action_set_ipv4.
1983 RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC,
1986 * Modify IPv4 destination address in the outermost IPv4 header.
1988 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV4,
1989 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
1991 * See struct rte_flow_action_set_ipv4.
1993 RTE_FLOW_ACTION_TYPE_SET_IPV4_DST,
1996 * Modify IPv6 source address in the outermost IPv6 header.
1998 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV6,
1999 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2001 * See struct rte_flow_action_set_ipv6.
2003 RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC,
2006 * Modify IPv6 destination address in the outermost IPv6 header.
2008 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV6,
2009 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2011 * See struct rte_flow_action_set_ipv6.
2013 RTE_FLOW_ACTION_TYPE_SET_IPV6_DST,
2016 * Modify source port number in the outermost TCP/UDP header.
2018 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_TCP
2019 * or RTE_FLOW_ITEM_TYPE_UDP, then the PMD should return a
2020 * RTE_FLOW_ERROR_TYPE_ACTION error.
2022 * See struct rte_flow_action_set_tp.
2024 RTE_FLOW_ACTION_TYPE_SET_TP_SRC,
2027 * Modify destination port number in the outermost TCP/UDP header.
2029 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_TCP
2030 * or RTE_FLOW_ITEM_TYPE_UDP, then the PMD should return a
2031 * RTE_FLOW_ERROR_TYPE_ACTION error.
2033 * See struct rte_flow_action_set_tp.
2035 RTE_FLOW_ACTION_TYPE_SET_TP_DST,
2038 * Swap the source and destination MAC addresses in the outermost
2041 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_ETH,
2042 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2044 * No associated configuration structure.
2046 RTE_FLOW_ACTION_TYPE_MAC_SWAP,
2049 * Decrease TTL value directly
2051 * No associated configuration structure.
2053 RTE_FLOW_ACTION_TYPE_DEC_TTL,
2058 * See struct rte_flow_action_set_ttl
2060 RTE_FLOW_ACTION_TYPE_SET_TTL,
2063 * Set source MAC address from matched flow.
2065 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_ETH,
2066 * the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2068 * See struct rte_flow_action_set_mac.
2070 RTE_FLOW_ACTION_TYPE_SET_MAC_SRC,
2073 * Set destination MAC address from matched flow.
2075 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_ETH,
2076 * the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2078 * See struct rte_flow_action_set_mac.
2080 RTE_FLOW_ACTION_TYPE_SET_MAC_DST,
2083 * Increase sequence number in the outermost TCP header.
2085 * Action configuration specifies the value to increase
2086 * TCP sequence number as a big-endian 32 bit integer.
2089 * @code rte_be32_t * @endcode
2091 * Using this action on non-matching traffic will result in
2092 * undefined behavior.
2094 RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ,
2097 * Decrease sequence number in the outermost TCP header.
2099 * Action configuration specifies the value to decrease
2100 * TCP sequence number as a big-endian 32 bit integer.
2103 * @code rte_be32_t * @endcode
2105 * Using this action on non-matching traffic will result in
2106 * undefined behavior.
2108 RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ,
2111 * Increase acknowledgment number in the outermost TCP header.
2113 * Action configuration specifies the value to increase
2114 * TCP acknowledgment number as a big-endian 32 bit integer.
2117 * @code rte_be32_t * @endcode
2119 * Using this action on non-matching traffic will result in
2120 * undefined behavior.
2122 RTE_FLOW_ACTION_TYPE_INC_TCP_ACK,
2125 * Decrease acknowledgment number in the outermost TCP header.
2127 * Action configuration specifies the value to decrease
2128 * TCP acknowledgment number as a big-endian 32 bit integer.
2131 * @code rte_be32_t * @endcode
2133 * Using this action on non-matching traffic will result in
2134 * undefined behavior.
2136 RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK,
2141 * Tag is for internal flow usage only and
2142 * is not delivered to the application.
2144 * See struct rte_flow_action_set_tag.
2146 RTE_FLOW_ACTION_TYPE_SET_TAG,
2149 * Set metadata on ingress or egress path.
2151 * See struct rte_flow_action_set_meta.
2153 RTE_FLOW_ACTION_TYPE_SET_META,
2156 * Modify IPv4 DSCP in the outermost IP header.
2158 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV4,
2159 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2161 * See struct rte_flow_action_set_dscp.
2163 RTE_FLOW_ACTION_TYPE_SET_IPV4_DSCP,
2166 * Modify IPv6 DSCP in the outermost IP header.
2168 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV6,
2169 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2171 * See struct rte_flow_action_set_dscp.
2173 RTE_FLOW_ACTION_TYPE_SET_IPV6_DSCP,
2176 * Report as aged flow if timeout passed without any matching on the
2179 * See struct rte_flow_action_age.
2180 * See function rte_flow_get_aged_flows
2181 * see enum RTE_ETH_EVENT_FLOW_AGED
2182 * See struct rte_flow_query_age
2184 RTE_FLOW_ACTION_TYPE_AGE,
2187 * The matching packets will be duplicated with specified ratio and
2188 * applied with own set of actions with a fate action.
2190 * See struct rte_flow_action_sample.
2192 RTE_FLOW_ACTION_TYPE_SAMPLE,
2195 * Describe action shared across multiple flow rules.
2197 * Allow multiple rules reference the same action by handle (see
2198 * struct rte_flow_shared_action).
2200 RTE_FLOW_ACTION_TYPE_SHARED,
2204 * RTE_FLOW_ACTION_TYPE_MARK
2206 * Attaches an integer value to packets and sets PKT_RX_FDIR and
2207 * PKT_RX_FDIR_ID mbuf flags.
2209 * This value is arbitrary and application-defined. Maximum allowed value
2210 * depends on the underlying implementation. It is returned in the
2211 * hash.fdir.hi mbuf field.
2213 struct rte_flow_action_mark {
2214 uint32_t id; /**< Integer value to return with packets. */
2219 * @b EXPERIMENTAL: this structure may change without prior notice
2221 * RTE_FLOW_ACTION_TYPE_JUMP
2223 * Redirects packets to a group on the current device.
2225 * In a hierarchy of groups, which can be used to represent physical or logical
2226 * flow tables on the device, this action allows the action to be a redirect to
2227 * a group on that device.
2229 struct rte_flow_action_jump {
2234 * RTE_FLOW_ACTION_TYPE_QUEUE
2236 * Assign packets to a given queue index.
2238 struct rte_flow_action_queue {
2239 uint16_t index; /**< Queue index to use. */
2244 * @b EXPERIMENTAL: this structure may change without prior notice
2246 * RTE_FLOW_ACTION_TYPE_AGE
2248 * Report flow as aged-out if timeout passed without any matching
2249 * on the flow. RTE_ETH_EVENT_FLOW_AGED event is triggered when a
2250 * port detects new aged-out flows.
2252 * The flow context and the flow handle will be reported by the
2253 * rte_flow_get_aged_flows API.
2255 struct rte_flow_action_age {
2256 uint32_t timeout:24; /**< Time in seconds. */
2257 uint32_t reserved:8; /**< Reserved, must be zero. */
2259 /**< The user flow context, NULL means the rte_flow pointer. */
2263 * RTE_FLOW_ACTION_TYPE_AGE (query)
2265 * Query structure to retrieve the aging status information of a
2266 * shared AGE action, or a flow rule using the AGE action.
2268 struct rte_flow_query_age {
2269 uint32_t reserved:6; /**< Reserved, must be zero. */
2270 uint32_t aged:1; /**< 1 if aging timeout expired, 0 otherwise. */
2271 uint32_t sec_since_last_hit_valid:1;
2272 /**< sec_since_last_hit value is valid. */
2273 uint32_t sec_since_last_hit:24; /**< Seconds since last traffic hit. */
2278 * @b EXPERIMENTAL: this structure may change without prior notice
2280 * RTE_FLOW_ACTION_TYPE_COUNT
2282 * Adds a counter action to a matched flow.
2284 * If more than one count action is specified in a single flow rule, then each
2285 * action must specify a unique id.
2287 * Counters can be retrieved and reset through ``rte_flow_query()``, see
2288 * ``struct rte_flow_query_count``.
2290 * @deprecated Shared attribute is deprecated, use generic
2291 * RTE_FLOW_ACTION_TYPE_SHARED action.
2293 * The shared flag indicates whether the counter is unique to the flow rule the
2294 * action is specified with, or whether it is a shared counter.
2296 * For a count action with the shared flag set, then then a global device
2297 * namespace is assumed for the counter id, so that any matched flow rules using
2298 * a count action with the same counter id on the same port will contribute to
2301 * For ports within the same switch domain then the counter id namespace extends
2302 * to all ports within that switch domain.
2304 struct rte_flow_action_count {
2305 /** @deprecated Share counter ID with other flow rules. */
2307 uint32_t reserved:31; /**< Reserved, must be zero. */
2308 uint32_t id; /**< Counter ID. */
2312 * RTE_FLOW_ACTION_TYPE_COUNT (query)
2314 * Query structure to retrieve and reset flow rule counters.
2316 struct rte_flow_query_count {
2317 uint32_t reset:1; /**< Reset counters after query [in]. */
2318 uint32_t hits_set:1; /**< hits field is set [out]. */
2319 uint32_t bytes_set:1; /**< bytes field is set [out]. */
2320 uint32_t reserved:29; /**< Reserved, must be zero [in, out]. */
2321 uint64_t hits; /**< Number of hits for this rule [out]. */
2322 uint64_t bytes; /**< Number of bytes through this rule [out]. */
2326 * Hash function types.
2328 enum rte_eth_hash_function {
2329 RTE_ETH_HASH_FUNCTION_DEFAULT = 0,
2330 RTE_ETH_HASH_FUNCTION_TOEPLITZ, /**< Toeplitz */
2331 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR, /**< Simple XOR */
2333 * Symmetric Toeplitz: src, dst will be replaced by
2334 * xor(src, dst). For the case with src/dst only,
2335 * src or dst address will xor with zero pair.
2337 RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ,
2338 RTE_ETH_HASH_FUNCTION_MAX,
2342 * RTE_FLOW_ACTION_TYPE_RSS
2344 * Similar to QUEUE, except RSS is additionally performed on packets to
2345 * spread them among several queues according to the provided parameters.
2347 * Unlike global RSS settings used by other DPDK APIs, unsetting the
2348 * @p types field does not disable RSS in a flow rule. Doing so instead
2349 * requests safe unspecified "best-effort" settings from the underlying PMD,
2350 * which depending on the flow rule, may result in anything ranging from
2351 * empty (single queue) to all-inclusive RSS.
2353 * Note: RSS hash result is stored in the hash.rss mbuf field which overlaps
2354 * hash.fdir.lo. Since the MARK action sets the hash.fdir.hi field only,
2355 * both can be requested simultaneously.
2357 struct rte_flow_action_rss {
2358 enum rte_eth_hash_function func; /**< RSS hash function to apply. */
2360 * Packet encapsulation level RSS hash @p types apply to.
2362 * - @p 0 requests the default behavior. Depending on the packet
2363 * type, it can mean outermost, innermost, anything in between or
2366 * It basically stands for the innermost encapsulation level RSS
2367 * can be performed on according to PMD and device capabilities.
2369 * - @p 1 requests RSS to be performed on the outermost packet
2370 * encapsulation level.
2372 * - @p 2 and subsequent values request RSS to be performed on the
2373 * specified inner packet encapsulation level, from outermost to
2374 * innermost (lower to higher values).
2376 * Values other than @p 0 are not necessarily supported.
2378 * Requesting a specific RSS level on unrecognized traffic results
2379 * in undefined behavior. For predictable results, it is recommended
2380 * to make the flow rule pattern match packet headers up to the
2381 * requested encapsulation level so that only matching traffic goes
2385 uint64_t types; /**< Specific RSS hash types (see ETH_RSS_*). */
2386 uint32_t key_len; /**< Hash key length in bytes. */
2387 uint32_t queue_num; /**< Number of entries in @p queue. */
2388 const uint8_t *key; /**< Hash key. */
2389 const uint16_t *queue; /**< Queue indices to use. */
2393 * RTE_FLOW_ACTION_TYPE_VF
2395 * Directs matching traffic to a given virtual function of the current
2398 * Packets matched by a VF pattern item can be redirected to their original
2399 * VF ID instead of the specified one. This parameter may not be available
2400 * and is not guaranteed to work properly if the VF part is matched by a
2401 * prior flow rule or if packets are not addressed to a VF in the first
2404 struct rte_flow_action_vf {
2405 uint32_t original:1; /**< Use original VF ID if possible. */
2406 uint32_t reserved:31; /**< Reserved, must be zero. */
2407 uint32_t id; /**< VF ID. */
2411 * RTE_FLOW_ACTION_TYPE_PHY_PORT
2413 * Directs packets to a given physical port index of the underlying
2416 * @see RTE_FLOW_ITEM_TYPE_PHY_PORT
2418 struct rte_flow_action_phy_port {
2419 uint32_t original:1; /**< Use original port index if possible. */
2420 uint32_t reserved:31; /**< Reserved, must be zero. */
2421 uint32_t index; /**< Physical port index. */
2425 * RTE_FLOW_ACTION_TYPE_PORT_ID
2427 * Directs matching traffic to a given DPDK port ID.
2429 * @see RTE_FLOW_ITEM_TYPE_PORT_ID
2431 struct rte_flow_action_port_id {
2432 uint32_t original:1; /**< Use original DPDK port ID if possible. */
2433 uint32_t reserved:31; /**< Reserved, must be zero. */
2434 uint32_t id; /**< DPDK port ID. */
2438 * RTE_FLOW_ACTION_TYPE_METER
2440 * Traffic metering and policing (MTR).
2442 * Packets matched by items of this type can be either dropped or passed to the
2443 * next item with their color set by the MTR object.
2445 struct rte_flow_action_meter {
2446 uint32_t mtr_id; /**< MTR object ID created with rte_mtr_create(). */
2450 * RTE_FLOW_ACTION_TYPE_SECURITY
2452 * Perform the security action on flows matched by the pattern items
2453 * according to the configuration of the security session.
2455 * This action modifies the payload of matched flows. For INLINE_CRYPTO, the
2456 * security protocol headers and IV are fully provided by the application as
2457 * specified in the flow pattern. The payload of matching packets is
2458 * encrypted on egress, and decrypted and authenticated on ingress.
2459 * For INLINE_PROTOCOL, the security protocol is fully offloaded to HW,
2460 * providing full encapsulation and decapsulation of packets in security
2461 * protocols. The flow pattern specifies both the outer security header fields
2462 * and the inner packet fields. The security session specified in the action
2463 * must match the pattern parameters.
2465 * The security session specified in the action must be created on the same
2466 * port as the flow action that is being specified.
2468 * The ingress/egress flow attribute should match that specified in the
2469 * security session if the security session supports the definition of the
2472 * Multiple flows can be configured to use the same security session.
2474 * The NULL value is allowed for security session. If security session is NULL,
2475 * then SPI field in ESP flow item and IP addresses in flow items 'IPv4' and
2476 * 'IPv6' will be allowed to be a range. The rule thus created can enable
2477 * security processing on multiple flows.
2479 struct rte_flow_action_security {
2480 void *security_session; /**< Pointer to security session structure. */
2484 * RTE_FLOW_ACTION_TYPE_OF_SET_MPLS_TTL
2486 * Implements OFPAT_SET_MPLS_TTL ("MPLS TTL") as defined by the OpenFlow
2487 * Switch Specification.
2489 struct rte_flow_action_of_set_mpls_ttl {
2490 uint8_t mpls_ttl; /**< MPLS TTL. */
2494 * RTE_FLOW_ACTION_TYPE_OF_SET_NW_TTL
2496 * Implements OFPAT_SET_NW_TTL ("IP TTL") as defined by the OpenFlow Switch
2499 struct rte_flow_action_of_set_nw_ttl {
2500 uint8_t nw_ttl; /**< IP TTL. */
2504 * RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN
2506 * Implements OFPAT_PUSH_VLAN ("push a new VLAN tag") as defined by the
2507 * OpenFlow Switch Specification.
2509 struct rte_flow_action_of_push_vlan {
2510 rte_be16_t ethertype; /**< EtherType. */
2514 * RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID
2516 * Implements OFPAT_SET_VLAN_VID ("set the 802.1q VLAN id") as defined by
2517 * the OpenFlow Switch Specification.
2519 struct rte_flow_action_of_set_vlan_vid {
2520 rte_be16_t vlan_vid; /**< VLAN id. */
2524 * RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP
2526 * Implements OFPAT_SET_LAN_PCP ("set the 802.1q priority") as defined by
2527 * the OpenFlow Switch Specification.
2529 struct rte_flow_action_of_set_vlan_pcp {
2530 uint8_t vlan_pcp; /**< VLAN priority. */
2534 * RTE_FLOW_ACTION_TYPE_OF_POP_MPLS
2536 * Implements OFPAT_POP_MPLS ("pop the outer MPLS tag") as defined by the
2537 * OpenFlow Switch Specification.
2539 struct rte_flow_action_of_pop_mpls {
2540 rte_be16_t ethertype; /**< EtherType. */
2544 * RTE_FLOW_ACTION_TYPE_OF_PUSH_MPLS
2546 * Implements OFPAT_PUSH_MPLS ("push a new MPLS tag") as defined by the
2547 * OpenFlow Switch Specification.
2549 struct rte_flow_action_of_push_mpls {
2550 rte_be16_t ethertype; /**< EtherType. */
2555 * @b EXPERIMENTAL: this structure may change without prior notice
2557 * RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP
2559 * VXLAN tunnel end-point encapsulation data definition
2561 * The tunnel definition is provided through the flow item pattern, the
2562 * provided pattern must conform to RFC7348 for the tunnel specified. The flow
2563 * definition must be provided in order from the RTE_FLOW_ITEM_TYPE_ETH
2564 * definition up the end item which is specified by RTE_FLOW_ITEM_TYPE_END.
2566 * The mask field allows user to specify which fields in the flow item
2567 * definitions can be ignored and which have valid data and can be used
2570 * Note: the last field is not used in the definition of a tunnel and can be
2573 * Valid flow definition for RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP include:
2575 * - ETH / IPV4 / UDP / VXLAN / END
2576 * - ETH / IPV6 / UDP / VXLAN / END
2577 * - ETH / VLAN / IPV4 / UDP / VXLAN / END
2580 struct rte_flow_action_vxlan_encap {
2582 * Encapsulating vxlan tunnel definition
2583 * (terminated by the END pattern item).
2585 struct rte_flow_item *definition;
2590 * @b EXPERIMENTAL: this structure may change without prior notice
2592 * RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP
2594 * NVGRE tunnel end-point encapsulation data definition
2596 * The tunnel definition is provided through the flow item pattern the
2597 * provided pattern must conform with RFC7637. The flow definition must be
2598 * provided in order from the RTE_FLOW_ITEM_TYPE_ETH definition up the end item
2599 * which is specified by RTE_FLOW_ITEM_TYPE_END.
2601 * The mask field allows user to specify which fields in the flow item
2602 * definitions can be ignored and which have valid data and can be used
2605 * Note: the last field is not used in the definition of a tunnel and can be
2608 * Valid flow definition for RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP include:
2610 * - ETH / IPV4 / NVGRE / END
2611 * - ETH / VLAN / IPV6 / NVGRE / END
2614 struct rte_flow_action_nvgre_encap {
2616 * Encapsulating vxlan tunnel definition
2617 * (terminated by the END pattern item).
2619 struct rte_flow_item *definition;
2624 * @b EXPERIMENTAL: this structure may change without prior notice
2626 * RTE_FLOW_ACTION_TYPE_RAW_ENCAP
2628 * Raw tunnel end-point encapsulation data definition.
2630 * The data holds the headers definitions to be applied on the packet.
2631 * The data must start with ETH header up to the tunnel item header itself.
2632 * When used right after RAW_DECAP (for decapsulating L3 tunnel type for
2633 * example MPLSoGRE) the data will just hold layer 2 header.
2635 * The preserve parameter holds which bits in the packet the PMD is not allowed
2636 * to change, this parameter can also be NULL and then the PMD is allowed
2637 * to update any field.
2639 * size holds the number of bytes in @p data and @p preserve.
2641 struct rte_flow_action_raw_encap {
2642 uint8_t *data; /**< Encapsulation data. */
2643 uint8_t *preserve; /**< Bit-mask of @p data to preserve on output. */
2644 size_t size; /**< Size of @p data and @p preserve. */
2649 * @b EXPERIMENTAL: this structure may change without prior notice
2651 * RTE_FLOW_ACTION_TYPE_RAW_DECAP
2653 * Raw tunnel end-point decapsulation data definition.
2655 * The data holds the headers definitions to be removed from the packet.
2656 * The data must start with ETH header up to the tunnel item header itself.
2657 * When used right before RAW_DECAP (for encapsulating L3 tunnel type for
2658 * example MPLSoGRE) the data will just hold layer 2 header.
2660 * size holds the number of bytes in @p data.
2662 struct rte_flow_action_raw_decap {
2663 uint8_t *data; /**< Encapsulation data. */
2664 size_t size; /**< Size of @p data and @p preserve. */
2669 * @b EXPERIMENTAL: this structure may change without prior notice
2671 * RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC
2672 * RTE_FLOW_ACTION_TYPE_SET_IPV4_DST
2674 * Allows modification of IPv4 source (RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC)
2675 * and destination address (RTE_FLOW_ACTION_TYPE_SET_IPV4_DST) in the
2676 * specified outermost IPv4 header.
2678 struct rte_flow_action_set_ipv4 {
2679 rte_be32_t ipv4_addr;
2684 * @b EXPERIMENTAL: this structure may change without prior notice
2686 * RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC
2687 * RTE_FLOW_ACTION_TYPE_SET_IPV6_DST
2689 * Allows modification of IPv6 source (RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC)
2690 * and destination address (RTE_FLOW_ACTION_TYPE_SET_IPV6_DST) in the
2691 * specified outermost IPv6 header.
2693 struct rte_flow_action_set_ipv6 {
2694 uint8_t ipv6_addr[16];
2699 * @b EXPERIMENTAL: this structure may change without prior notice
2701 * RTE_FLOW_ACTION_TYPE_SET_TP_SRC
2702 * RTE_FLOW_ACTION_TYPE_SET_TP_DST
2704 * Allows modification of source (RTE_FLOW_ACTION_TYPE_SET_TP_SRC)
2705 * and destination (RTE_FLOW_ACTION_TYPE_SET_TP_DST) port numbers
2706 * in the specified outermost TCP/UDP header.
2708 struct rte_flow_action_set_tp {
2713 * RTE_FLOW_ACTION_TYPE_SET_TTL
2715 * Set the TTL value directly for IPv4 or IPv6
2717 struct rte_flow_action_set_ttl {
2722 * RTE_FLOW_ACTION_TYPE_SET_MAC
2724 * Set MAC address from the matched flow
2726 struct rte_flow_action_set_mac {
2727 uint8_t mac_addr[RTE_ETHER_ADDR_LEN];
2732 * @b EXPERIMENTAL: this structure may change without prior notice
2734 * RTE_FLOW_ACTION_TYPE_SET_TAG
2736 * Set a tag which is a transient data used during flow matching. This is not
2737 * delivered to application. Multiple tags are supported by specifying index.
2739 struct rte_flow_action_set_tag {
2747 * @b EXPERIMENTAL: this structure may change without prior notice
2749 * RTE_FLOW_ACTION_TYPE_SET_META
2751 * Set metadata. Metadata set by mbuf metadata dynamic field with
2752 * PKT_TX_DYNF_DATA flag on egress will be overridden by this action. On
2753 * ingress, the metadata will be carried by mbuf metadata dynamic field
2754 * with PKT_RX_DYNF_METADATA flag if set. The dynamic mbuf field must be
2755 * registered in advance by rte_flow_dynf_metadata_register().
2757 * Altering partial bits is supported with mask. For bits which have never
2758 * been set, unpredictable value will be seen depending on driver
2759 * implementation. For loopback/hairpin packet, metadata set on Rx/Tx may
2760 * or may not be propagated to the other path depending on HW capability.
2762 * RTE_FLOW_ITEM_TYPE_META matches metadata.
2764 struct rte_flow_action_set_meta {
2770 * RTE_FLOW_ACTION_TYPE_SET_IPV4_DSCP
2771 * RTE_FLOW_ACTION_TYPE_SET_IPV6_DSCP
2773 * Set the DSCP value for IPv4/IPv6 header.
2774 * DSCP in low 6 bits, rest ignored.
2776 struct rte_flow_action_set_dscp {
2782 * RTE_FLOW_ACTION_TYPE_SHARED
2784 * Opaque type returned after successfully creating a shared action.
2786 * This handle can be used to manage and query the related action:
2787 * - share it across multiple flow rules
2788 * - update action configuration
2789 * - query action data
2792 struct rte_flow_shared_action;
2794 /* Mbuf dynamic field offset for metadata. */
2795 extern int32_t rte_flow_dynf_metadata_offs;
2797 /* Mbuf dynamic field flag mask for metadata. */
2798 extern uint64_t rte_flow_dynf_metadata_mask;
2800 /* Mbuf dynamic field pointer for metadata. */
2801 #define RTE_FLOW_DYNF_METADATA(m) \
2802 RTE_MBUF_DYNFIELD((m), rte_flow_dynf_metadata_offs, uint32_t *)
2804 /* Mbuf dynamic flags for metadata. */
2805 #define PKT_RX_DYNF_METADATA (rte_flow_dynf_metadata_mask)
2806 #define PKT_TX_DYNF_METADATA (rte_flow_dynf_metadata_mask)
2809 static inline uint32_t
2810 rte_flow_dynf_metadata_get(struct rte_mbuf *m)
2812 return *RTE_FLOW_DYNF_METADATA(m);
2817 rte_flow_dynf_metadata_set(struct rte_mbuf *m, uint32_t v)
2819 *RTE_FLOW_DYNF_METADATA(m) = v;
2823 * Definition of a single action.
2825 * A list of actions is terminated by a END action.
2827 * For simple actions without a configuration object, conf remains NULL.
2829 struct rte_flow_action {
2830 enum rte_flow_action_type type; /**< Action type. */
2831 const void *conf; /**< Pointer to action configuration object. */
2835 * Opaque type returned after successfully creating a flow.
2837 * This handle can be used to manage and query the related flow (e.g. to
2838 * destroy it or retrieve counters).
2844 * @b EXPERIMENTAL: this structure may change without prior notice
2846 * RTE_FLOW_ACTION_TYPE_SAMPLE
2848 * Adds a sample action to a matched flow.
2850 * The matching packets will be duplicated with specified ratio and applied
2851 * with own set of actions with a fate action, the sampled packet could be
2852 * redirected to queue or port. All the packets continue processing on the
2853 * default flow path.
2855 * When the sample ratio is set to 1 then the packets will be 100% mirrored.
2856 * Additional action list be supported to add for sampled or mirrored packets.
2858 struct rte_flow_action_sample {
2859 uint32_t ratio; /**< packets sampled equals to '1/ratio'. */
2860 const struct rte_flow_action *actions;
2861 /**< sub-action list specific for the sampling hit cases. */
2865 * Verbose error types.
2867 * Most of them provide the type of the object referenced by struct
2868 * rte_flow_error.cause.
2870 enum rte_flow_error_type {
2871 RTE_FLOW_ERROR_TYPE_NONE, /**< No error. */
2872 RTE_FLOW_ERROR_TYPE_UNSPECIFIED, /**< Cause unspecified. */
2873 RTE_FLOW_ERROR_TYPE_HANDLE, /**< Flow rule (handle). */
2874 RTE_FLOW_ERROR_TYPE_ATTR_GROUP, /**< Group field. */
2875 RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY, /**< Priority field. */
2876 RTE_FLOW_ERROR_TYPE_ATTR_INGRESS, /**< Ingress field. */
2877 RTE_FLOW_ERROR_TYPE_ATTR_EGRESS, /**< Egress field. */
2878 RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, /**< Transfer field. */
2879 RTE_FLOW_ERROR_TYPE_ATTR, /**< Attributes structure. */
2880 RTE_FLOW_ERROR_TYPE_ITEM_NUM, /**< Pattern length. */
2881 RTE_FLOW_ERROR_TYPE_ITEM_SPEC, /**< Item specification. */
2882 RTE_FLOW_ERROR_TYPE_ITEM_LAST, /**< Item specification range. */
2883 RTE_FLOW_ERROR_TYPE_ITEM_MASK, /**< Item specification mask. */
2884 RTE_FLOW_ERROR_TYPE_ITEM, /**< Specific pattern item. */
2885 RTE_FLOW_ERROR_TYPE_ACTION_NUM, /**< Number of actions. */
2886 RTE_FLOW_ERROR_TYPE_ACTION_CONF, /**< Action configuration. */
2887 RTE_FLOW_ERROR_TYPE_ACTION, /**< Specific action. */
2891 * Verbose error structure definition.
2893 * This object is normally allocated by applications and set by PMDs, the
2894 * message points to a constant string which does not need to be freed by
2895 * the application, however its pointer can be considered valid only as long
2896 * as its associated DPDK port remains configured. Closing the underlying
2897 * device or unloading the PMD invalidates it.
2899 * Both cause and message may be NULL regardless of the error type.
2901 struct rte_flow_error {
2902 enum rte_flow_error_type type; /**< Cause field and error types. */
2903 const void *cause; /**< Object responsible for the error. */
2904 const char *message; /**< Human-readable error message. */
2908 * Complete flow rule description.
2910 * This object type is used when converting a flow rule description.
2912 * @see RTE_FLOW_CONV_OP_RULE
2913 * @see rte_flow_conv()
2916 struct rte_flow_conv_rule {
2918 const struct rte_flow_attr *attr_ro; /**< RO attributes. */
2919 struct rte_flow_attr *attr; /**< Attributes. */
2922 const struct rte_flow_item *pattern_ro; /**< RO pattern. */
2923 struct rte_flow_item *pattern; /**< Pattern items. */
2926 const struct rte_flow_action *actions_ro; /**< RO actions. */
2927 struct rte_flow_action *actions; /**< List of actions. */
2932 * Conversion operations for flow API objects.
2934 * @see rte_flow_conv()
2936 enum rte_flow_conv_op {
2938 * No operation to perform.
2940 * rte_flow_conv() simply returns 0.
2942 RTE_FLOW_CONV_OP_NONE,
2945 * Convert attributes structure.
2947 * This is a basic copy of an attributes structure.
2950 * @code const struct rte_flow_attr * @endcode
2952 * @code struct rte_flow_attr * @endcode
2954 RTE_FLOW_CONV_OP_ATTR,
2957 * Convert a single item.
2959 * Duplicates @p spec, @p last and @p mask but not outside objects.
2962 * @code const struct rte_flow_item * @endcode
2964 * @code struct rte_flow_item * @endcode
2966 RTE_FLOW_CONV_OP_ITEM,
2969 * Convert a single action.
2971 * Duplicates @p conf but not outside objects.
2974 * @code const struct rte_flow_action * @endcode
2976 * @code struct rte_flow_action * @endcode
2978 RTE_FLOW_CONV_OP_ACTION,
2981 * Convert an entire pattern.
2983 * Duplicates all pattern items at once with the same constraints as
2984 * RTE_FLOW_CONV_OP_ITEM.
2987 * @code const struct rte_flow_item * @endcode
2989 * @code struct rte_flow_item * @endcode
2991 RTE_FLOW_CONV_OP_PATTERN,
2994 * Convert a list of actions.
2996 * Duplicates the entire list of actions at once with the same
2997 * constraints as RTE_FLOW_CONV_OP_ACTION.
3000 * @code const struct rte_flow_action * @endcode
3002 * @code struct rte_flow_action * @endcode
3004 RTE_FLOW_CONV_OP_ACTIONS,
3007 * Convert a complete flow rule description.
3009 * Comprises attributes, pattern and actions together at once with
3010 * the usual constraints.
3013 * @code const struct rte_flow_conv_rule * @endcode
3015 * @code struct rte_flow_conv_rule * @endcode
3017 RTE_FLOW_CONV_OP_RULE,
3020 * Convert item type to its name string.
3022 * Writes a NUL-terminated string to @p dst. Like snprintf(), the
3023 * returned value excludes the terminator which is always written
3027 * @code (const void *)enum rte_flow_item_type @endcode
3029 * @code char * @endcode
3031 RTE_FLOW_CONV_OP_ITEM_NAME,
3034 * Convert action type to its name string.
3036 * Writes a NUL-terminated string to @p dst. Like snprintf(), the
3037 * returned value excludes the terminator which is always written
3041 * @code (const void *)enum rte_flow_action_type @endcode
3043 * @code char * @endcode
3045 RTE_FLOW_CONV_OP_ACTION_NAME,
3048 * Convert item type to pointer to item name.
3050 * Retrieves item name pointer from its type. The string itself is
3051 * not copied; instead, a unique pointer to an internal static
3052 * constant storage is written to @p dst.
3055 * @code (const void *)enum rte_flow_item_type @endcode
3057 * @code const char ** @endcode
3059 RTE_FLOW_CONV_OP_ITEM_NAME_PTR,
3062 * Convert action type to pointer to action name.
3064 * Retrieves action name pointer from its type. The string itself is
3065 * not copied; instead, a unique pointer to an internal static
3066 * constant storage is written to @p dst.
3069 * @code (const void *)enum rte_flow_action_type @endcode
3071 * @code const char ** @endcode
3073 RTE_FLOW_CONV_OP_ACTION_NAME_PTR,
3078 * @b EXPERIMENTAL: this API may change without prior notice.
3080 * Dump hardware internal representation information of
3083 * @param[in] port_id
3084 * The port identifier of the Ethernet device.
3086 * A pointer to a file for output.
3088 * Perform verbose error reporting if not NULL. PMDs initialize this
3089 * structure in case of error only.
3091 * 0 on success, a nagative value otherwise.
3095 rte_flow_dev_dump(uint16_t port_id, FILE *file, struct rte_flow_error *error);
3098 * Check if mbuf dynamic field for metadata is registered.
3101 * True if registered, false otherwise.
3105 rte_flow_dynf_metadata_avail(void)
3107 return !!rte_flow_dynf_metadata_mask;
3111 * Register mbuf dynamic field and flag for metadata.
3113 * This function must be called prior to use SET_META action in order to
3114 * register the dynamic mbuf field. Otherwise, the data cannot be delivered to
3118 * 0 on success, a negative errno value otherwise and rte_errno is set.
3122 rte_flow_dynf_metadata_register(void);
3125 * Check whether a flow rule can be created on a given port.
3127 * The flow rule is validated for correctness and whether it could be accepted
3128 * by the device given sufficient resources. The rule is checked against the
3129 * current device mode and queue configuration. The flow rule may also
3130 * optionally be validated against existing flow rules and device resources.
3131 * This function has no effect on the target device.
3133 * The returned value is guaranteed to remain valid only as long as no
3134 * successful calls to rte_flow_create() or rte_flow_destroy() are made in
3135 * the meantime and no device parameter affecting flow rules in any way are
3136 * modified, due to possible collisions or resource limitations (although in
3137 * such cases EINVAL should not be returned).
3140 * Port identifier of Ethernet device.
3142 * Flow rule attributes.
3143 * @param[in] pattern
3144 * Pattern specification (list terminated by the END pattern item).
3145 * @param[in] actions
3146 * Associated actions (list terminated by the END action).
3148 * Perform verbose error reporting if not NULL. PMDs initialize this
3149 * structure in case of error only.
3152 * 0 if flow rule is valid and can be created. A negative errno value
3153 * otherwise (rte_errno is also set), the following errors are defined:
3155 * -ENOSYS: underlying device does not support this functionality.
3157 * -EIO: underlying device is removed.
3159 * -EINVAL: unknown or invalid rule specification.
3161 * -ENOTSUP: valid but unsupported rule specification (e.g. partial
3162 * bit-masks are unsupported).
3164 * -EEXIST: collision with an existing rule. Only returned if device
3165 * supports flow rule collision checking and there was a flow rule
3166 * collision. Not receiving this return code is no guarantee that creating
3167 * the rule will not fail due to a collision.
3169 * -ENOMEM: not enough memory to execute the function, or if the device
3170 * supports resource validation, resource limitation on the device.
3172 * -EBUSY: action cannot be performed due to busy device resources, may
3173 * succeed if the affected queues or even the entire port are in a stopped
3174 * state (see rte_eth_dev_rx_queue_stop() and rte_eth_dev_stop()).
3177 rte_flow_validate(uint16_t port_id,
3178 const struct rte_flow_attr *attr,
3179 const struct rte_flow_item pattern[],
3180 const struct rte_flow_action actions[],
3181 struct rte_flow_error *error);
3184 * Create a flow rule on a given port.
3187 * Port identifier of Ethernet device.
3189 * Flow rule attributes.
3190 * @param[in] pattern
3191 * Pattern specification (list terminated by the END pattern item).
3192 * @param[in] actions
3193 * Associated actions (list terminated by the END action).
3195 * Perform verbose error reporting if not NULL. PMDs initialize this
3196 * structure in case of error only.
3199 * A valid handle in case of success, NULL otherwise and rte_errno is set
3200 * to the positive version of one of the error codes defined for
3201 * rte_flow_validate().
3204 rte_flow_create(uint16_t port_id,
3205 const struct rte_flow_attr *attr,
3206 const struct rte_flow_item pattern[],
3207 const struct rte_flow_action actions[],
3208 struct rte_flow_error *error);
3211 * Destroy a flow rule on a given port.
3213 * Failure to destroy a flow rule handle may occur when other flow rules
3214 * depend on it, and destroying it would result in an inconsistent state.
3216 * This function is only guaranteed to succeed if handles are destroyed in
3217 * reverse order of their creation.
3220 * Port identifier of Ethernet device.
3222 * Flow rule handle to destroy.
3224 * Perform verbose error reporting if not NULL. PMDs initialize this
3225 * structure in case of error only.
3228 * 0 on success, a negative errno value otherwise and rte_errno is set.
3231 rte_flow_destroy(uint16_t port_id,
3232 struct rte_flow *flow,
3233 struct rte_flow_error *error);
3236 * Destroy all flow rules associated with a port.
3238 * In the unlikely event of failure, handles are still considered destroyed
3239 * and no longer valid but the port must be assumed to be in an inconsistent
3243 * Port identifier of Ethernet device.
3245 * Perform verbose error reporting if not NULL. PMDs initialize this
3246 * structure in case of error only.
3249 * 0 on success, a negative errno value otherwise and rte_errno is set.
3252 rte_flow_flush(uint16_t port_id,
3253 struct rte_flow_error *error);
3256 * Query an existing flow rule.
3258 * This function allows retrieving flow-specific data such as counters.
3259 * Data is gathered by special actions which must be present in the flow
3262 * \see RTE_FLOW_ACTION_TYPE_COUNT
3265 * Port identifier of Ethernet device.
3267 * Flow rule handle to query.
3269 * Action definition as defined in original flow rule.
3270 * @param[in, out] data
3271 * Pointer to storage for the associated query data type.
3273 * Perform verbose error reporting if not NULL. PMDs initialize this
3274 * structure in case of error only.
3277 * 0 on success, a negative errno value otherwise and rte_errno is set.
3280 rte_flow_query(uint16_t port_id,
3281 struct rte_flow *flow,
3282 const struct rte_flow_action *action,
3284 struct rte_flow_error *error);
3287 * Restrict ingress traffic to the defined flow rules.
3289 * Isolated mode guarantees that all ingress traffic comes from defined flow
3290 * rules only (current and future).
3292 * Besides making ingress more deterministic, it allows PMDs to safely reuse
3293 * resources otherwise assigned to handle the remaining traffic, such as
3294 * global RSS configuration settings, VLAN filters, MAC address entries,
3295 * legacy filter API rules and so on in order to expand the set of possible
3298 * Calling this function as soon as possible after device initialization,
3299 * ideally before the first call to rte_eth_dev_configure(), is recommended
3300 * to avoid possible failures due to conflicting settings.
3302 * Once effective, leaving isolated mode may not be possible depending on
3303 * PMD implementation.
3305 * Additionally, the following functionality has no effect on the underlying
3306 * port and may return errors such as ENOTSUP ("not supported"):
3308 * - Toggling promiscuous mode.
3309 * - Toggling allmulticast mode.
3310 * - Configuring MAC addresses.
3311 * - Configuring multicast addresses.
3312 * - Configuring VLAN filters.
3313 * - Configuring Rx filters through the legacy API (e.g. FDIR).
3314 * - Configuring global RSS settings.
3317 * Port identifier of Ethernet device.
3319 * Nonzero to enter isolated mode, attempt to leave it otherwise.
3321 * Perform verbose error reporting if not NULL. PMDs initialize this
3322 * structure in case of error only.
3325 * 0 on success, a negative errno value otherwise and rte_errno is set.
3328 rte_flow_isolate(uint16_t port_id, int set, struct rte_flow_error *error);
3331 * Initialize flow error structure.
3334 * Pointer to flow error structure (may be NULL).
3336 * Related error code (rte_errno).
3338 * Cause field and error types.
3340 * Object responsible for the error.
3342 * Human-readable error message.
3345 * Negative error code (errno value) and rte_errno is set.
3348 rte_flow_error_set(struct rte_flow_error *error,
3350 enum rte_flow_error_type type,
3352 const char *message);
3356 * @see rte_flow_copy()
3358 struct rte_flow_desc {
3359 size_t size; /**< Allocated space including data[]. */
3360 struct rte_flow_attr attr; /**< Attributes. */
3361 struct rte_flow_item *items; /**< Items. */
3362 struct rte_flow_action *actions; /**< Actions. */
3363 uint8_t data[]; /**< Storage for items/actions. */
3368 * Copy an rte_flow rule description.
3370 * This interface is kept for compatibility with older applications but is
3371 * implemented as a wrapper to rte_flow_conv(). It is deprecated due to its
3372 * lack of flexibility and reliance on a type unusable with C++ programs
3373 * (struct rte_flow_desc).
3376 * Flow rule description.
3378 * Total size of allocated data for the flow description.
3380 * Flow rule attributes.
3382 * Pattern specification (list terminated by the END pattern item).
3383 * @param[in] actions
3384 * Associated actions (list terminated by the END action).
3387 * If len is greater or equal to the size of the flow, the total size of the
3388 * flow description and its data.
3389 * If len is lower than the size of the flow, the number of bytes that would
3390 * have been written to desc had it been sufficient. Nothing is written.
3394 rte_flow_copy(struct rte_flow_desc *fd, size_t len,
3395 const struct rte_flow_attr *attr,
3396 const struct rte_flow_item *items,
3397 const struct rte_flow_action *actions);
3400 * Flow object conversion helper.
3402 * This function performs conversion of various flow API objects to a
3403 * pre-allocated destination buffer. See enum rte_flow_conv_op for possible
3404 * operations and details about each of them.
3406 * Since destination buffer must be large enough, it works in a manner
3407 * reminiscent of snprintf():
3409 * - If @p size is 0, @p dst may be a NULL pointer, otherwise @p dst must be
3411 * - If positive, the returned value represents the number of bytes needed
3412 * to store the conversion of @p src to @p dst according to @p op
3413 * regardless of the @p size parameter.
3414 * - Since no more than @p size bytes can be written to @p dst, output is
3415 * truncated and may be inconsistent when the returned value is larger
3417 * - In case of conversion error, a negative error code is returned and
3418 * @p dst contents are unspecified.
3421 * Operation to perform, related to the object type of @p dst.
3423 * Destination buffer address. Must be suitably aligned by the caller.
3425 * Destination buffer size in bytes.
3427 * Source object to copy. Depending on @p op, its type may differ from
3430 * Perform verbose error reporting if not NULL. Initialized in case of
3434 * The number of bytes required to convert @p src to @p dst on success, a
3435 * negative errno value otherwise and rte_errno is set.
3437 * @see rte_flow_conv_op
3441 rte_flow_conv(enum rte_flow_conv_op op,
3445 struct rte_flow_error *error);
3448 * Get aged-out flows of a given port.
3450 * RTE_ETH_EVENT_FLOW_AGED event will be triggered when at least one new aged
3451 * out flow was detected after the last call to rte_flow_get_aged_flows.
3452 * This function can be called to get the aged flows usynchronously from the
3453 * event callback or synchronously regardless the event.
3454 * This is not safe to call rte_flow_get_aged_flows function with other flow
3455 * functions from multiple threads simultaneously.
3458 * Port identifier of Ethernet device.
3459 * @param[in, out] contexts
3460 * The address of an array of pointers to the aged-out flows contexts.
3461 * @param[in] nb_contexts
3462 * The length of context array pointers.
3464 * Perform verbose error reporting if not NULL. Initialized in case of
3468 * if nb_contexts is 0, return the amount of all aged contexts.
3469 * if nb_contexts is not 0 , return the amount of aged flows reported
3470 * in the context array, otherwise negative errno value.
3472 * @see rte_flow_action_age
3473 * @see RTE_ETH_EVENT_FLOW_AGED
3477 rte_flow_get_aged_flows(uint16_t port_id, void **contexts,
3478 uint32_t nb_contexts, struct rte_flow_error *error);
3481 * Specify shared action configuration
3483 struct rte_flow_shared_action_conf {
3485 * Flow direction for shared action configuration.
3487 * Shared action should be valid at least for one flow direction,
3488 * otherwise it is invalid for both ingress and egress rules.
3491 /**< Action valid for rules applied to ingress traffic. */
3493 /**< Action valid for rules applied to egress traffic. */
3496 * When set to 1, indicates that the action is valid for
3497 * transfer traffic; otherwise, for non-transfer traffic.
3499 * See struct rte_flow_attr.
3501 uint32_t transfer:1;
3506 * @b EXPERIMENTAL: this API may change without prior notice.
3508 * Create shared action for reuse in multiple flow rules.
3509 * The created shared action has single state and configuration
3510 * across all flow rules using it.
3512 * @param[in] port_id
3513 * The port identifier of the Ethernet device.
3515 * Shared action configuration.
3517 * Action configuration for shared action creation.
3519 * Perform verbose error reporting if not NULL. PMDs initialize this
3520 * structure in case of error only.
3522 * A valid handle in case of success, NULL otherwise and rte_errno is set
3523 * to one of the error codes defined:
3524 * - (ENODEV) if *port_id* invalid.
3525 * - (ENOSYS) if underlying device does not support this functionality.
3526 * - (EIO) if underlying device is removed.
3527 * - (EINVAL) if *action* invalid.
3528 * - (ENOTSUP) if *action* valid but unsupported.
3531 struct rte_flow_shared_action *
3532 rte_flow_shared_action_create(uint16_t port_id,
3533 const struct rte_flow_shared_action_conf *conf,
3534 const struct rte_flow_action *action,
3535 struct rte_flow_error *error);
3539 * @b EXPERIMENTAL: this API may change without prior notice.
3541 * Destroy the shared action by handle.
3543 * @param[in] port_id
3544 * The port identifier of the Ethernet device.
3546 * Handle for the shared action to be destroyed.
3548 * Perform verbose error reporting if not NULL. PMDs initialize this
3549 * structure in case of error only.
3552 * - (-ENODEV) if *port_id* invalid.
3553 * - (-ENOSYS) if underlying device does not support this functionality.
3554 * - (-EIO) if underlying device is removed.
3555 * - (-ENOENT) if action pointed by *action* handle was not found.
3556 * - (-EBUSY) if action pointed by *action* handle still used by some rules
3557 * rte_errno is also set.
3561 rte_flow_shared_action_destroy(uint16_t port_id,
3562 struct rte_flow_shared_action *action,
3563 struct rte_flow_error *error);
3567 * @b EXPERIMENTAL: this API may change without prior notice.
3569 * Update in-place the shared action configuration pointed by *action* handle
3570 * with the configuration provided as *update* argument.
3571 * The update of the shared action configuration effects all flow rules reusing
3572 * the action via handle.
3574 * @param[in] port_id
3575 * The port identifier of the Ethernet device.
3577 * Handle for the shared action to be updated.
3579 * Action specification used to modify the action pointed by handle.
3580 * *update* should be of same type with the action pointed by the *action*
3581 * handle argument, otherwise considered as invalid.
3583 * Perform verbose error reporting if not NULL. PMDs initialize this
3584 * structure in case of error only.
3587 * - (-ENODEV) if *port_id* invalid.
3588 * - (-ENOSYS) if underlying device does not support this functionality.
3589 * - (-EIO) if underlying device is removed.
3590 * - (-EINVAL) if *update* invalid.
3591 * - (-ENOTSUP) if *update* valid but unsupported.
3592 * - (-ENOENT) if action pointed by *ctx* was not found.
3593 * rte_errno is also set.
3597 rte_flow_shared_action_update(uint16_t port_id,
3598 struct rte_flow_shared_action *action,
3599 const struct rte_flow_action *update,
3600 struct rte_flow_error *error);
3604 * @b EXPERIMENTAL: this API may change without prior notice.
3606 * Query the shared action by handle.
3608 * Retrieve action-specific data such as counters.
3609 * Data is gathered by special action which may be present/referenced in
3610 * more than one flow rule definition.
3612 * \see RTE_FLOW_ACTION_TYPE_COUNT
3615 * Port identifier of Ethernet device.
3617 * Handle for the shared action to query.
3618 * @param[in, out] data
3619 * Pointer to storage for the associated query data type.
3621 * Perform verbose error reporting if not NULL. PMDs initialize this
3622 * structure in case of error only.
3625 * 0 on success, a negative errno value otherwise and rte_errno is set.
3629 rte_flow_shared_action_query(uint16_t port_id,
3630 const struct rte_flow_shared_action *action,
3632 struct rte_flow_error *error);
3634 /* Tunnel has a type and the key information. */
3635 struct rte_flow_tunnel {
3637 * Tunnel type, for example RTE_FLOW_ITEM_TYPE_VXLAN,
3638 * RTE_FLOW_ITEM_TYPE_NVGRE etc.
3640 enum rte_flow_item_type type;
3641 uint64_t tun_id; /**< Tunnel identification. */
3646 rte_be32_t src_addr; /**< IPv4 source address. */
3647 rte_be32_t dst_addr; /**< IPv4 destination address. */
3650 uint8_t src_addr[16]; /**< IPv6 source address. */
3651 uint8_t dst_addr[16]; /**< IPv6 destination address. */
3654 rte_be16_t tp_src; /**< Tunnel port source. */
3655 rte_be16_t tp_dst; /**< Tunnel port destination. */
3656 uint16_t tun_flags; /**< Tunnel flags. */
3658 bool is_ipv6; /**< True for valid IPv6 fields. Otherwise IPv4. */
3661 * the following members are required to restore packet
3664 uint8_t tos; /**< TOS for IPv4, TC for IPv6. */
3665 uint8_t ttl; /**< TTL for IPv4, HL for IPv6. */
3666 uint32_t label; /**< Flow Label for IPv6. */
3670 * Indicate that the packet has a tunnel.
3672 #define RTE_FLOW_RESTORE_INFO_TUNNEL (1ULL << 0)
3675 * Indicate that the packet has a non decapsulated tunnel header.
3677 #define RTE_FLOW_RESTORE_INFO_ENCAPSULATED (1ULL << 1)
3680 * Indicate that the packet has a group_id.
3682 #define RTE_FLOW_RESTORE_INFO_GROUP_ID (1ULL << 2)
3685 * Restore information structure to communicate the current packet processing
3686 * state when some of the processing pipeline is done in hardware and should
3687 * continue in software.
3689 struct rte_flow_restore_info {
3691 * Bitwise flags (RTE_FLOW_RESTORE_INFO_*) to indicate validation of
3692 * other fields in struct rte_flow_restore_info.
3695 uint32_t group_id; /**< Group ID where packed missed */
3696 struct rte_flow_tunnel tunnel; /**< Tunnel information. */
3700 * Allocate an array of actions to be used in rte_flow_create, to implement
3701 * tunnel-decap-set for the given tunnel.
3703 * actions vxlan_decap / tunnel-decap-set(tunnel properties) /
3704 * jump group 0 / end
3707 * Port identifier of Ethernet device.
3709 * Tunnel properties.
3710 * @param[out] actions
3711 * Array of actions to be allocated by the PMD. This array should be
3712 * concatenated with the actions array provided to rte_flow_create.
3713 * @param[out] num_of_actions
3714 * Number of actions allocated.
3716 * Perform verbose error reporting if not NULL. PMDs initialize this
3717 * structure in case of error only.
3720 * 0 on success, a negative errno value otherwise and rte_errno is set.
3724 rte_flow_tunnel_decap_set(uint16_t port_id,
3725 struct rte_flow_tunnel *tunnel,
3726 struct rte_flow_action **actions,
3727 uint32_t *num_of_actions,
3728 struct rte_flow_error *error);
3731 * Allocate an array of items to be used in rte_flow_create, to implement
3732 * tunnel-match for the given tunnel.
3734 * pattern tunnel-match(tunnel properties) / outer-header-matches /
3735 * inner-header-matches / end
3738 * Port identifier of Ethernet device.
3740 * Tunnel properties.
3742 * Array of items to be allocated by the PMD. This array should be
3743 * concatenated with the items array provided to rte_flow_create.
3744 * @param[out] num_of_items
3745 * Number of items allocated.
3747 * Perform verbose error reporting if not NULL. PMDs initialize this
3748 * structure in case of error only.
3751 * 0 on success, a negative errno value otherwise and rte_errno is set.
3755 rte_flow_tunnel_match(uint16_t port_id,
3756 struct rte_flow_tunnel *tunnel,
3757 struct rte_flow_item **items,
3758 uint32_t *num_of_items,
3759 struct rte_flow_error *error);
3762 * Populate the current packet processing state, if exists, for the given mbuf.
3765 * Port identifier of Ethernet device.
3769 * Restore information. Upon success contains the HW state.
3771 * Perform verbose error reporting if not NULL. PMDs initialize this
3772 * structure in case of error only.
3775 * 0 on success, a negative errno value otherwise and rte_errno is set.
3779 rte_flow_get_restore_info(uint16_t port_id,
3781 struct rte_flow_restore_info *info,
3782 struct rte_flow_error *error);
3785 * Release the action array as allocated by rte_flow_tunnel_decap_set.
3788 * Port identifier of Ethernet device.
3789 * @param[in] actions
3790 * Array of actions to be released.
3791 * @param[in] num_of_actions
3792 * Number of elements in actions array.
3794 * Perform verbose error reporting if not NULL. PMDs initialize this
3795 * structure in case of error only.
3798 * 0 on success, a negative errno value otherwise and rte_errno is set.
3802 rte_flow_tunnel_action_decap_release(uint16_t port_id,
3803 struct rte_flow_action *actions,
3804 uint32_t num_of_actions,
3805 struct rte_flow_error *error);
3808 * Release the item array as allocated by rte_flow_tunnel_match.
3811 * Port identifier of Ethernet device.
3813 * Array of items to be released.
3814 * @param[in] num_of_items
3815 * Number of elements in item array.
3817 * Perform verbose error reporting if not NULL. PMDs initialize this
3818 * structure in case of error only.
3821 * 0 on success, a negative errno value otherwise and rte_errno is set.
3825 rte_flow_tunnel_item_release(uint16_t port_id,
3826 struct rte_flow_item *items,
3827 uint32_t num_of_items,
3828 struct rte_flow_error *error);
3833 #endif /* RTE_FLOW_H_ */