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_vxlan.h>
29 #include <rte_byteorder.h>
31 #include <rte_higig.h>
32 #include <rte_ecpri.h>
33 #include <rte_bitops.h>
35 #include <rte_mbuf_dyn.h>
36 #include <rte_meter.h>
38 #include <rte_l2tpv2.h>
46 #define RTE_FLOW_LOG(level, ...) \
47 rte_log(RTE_LOG_ ## level, rte_eth_dev_logtype, "" __VA_ARGS__)
50 * Flow rule attributes.
52 * Priorities are set on a per rule based within groups.
54 * Lower values denote higher priority, the highest priority for a flow rule
55 * is 0, so that a flow that matches for than one rule, the rule with the
56 * lowest priority value will always be matched.
58 * Although optional, applications are encouraged to group similar rules as
59 * much as possible to fully take advantage of hardware capabilities
60 * (e.g. optimized matching) and work around limitations (e.g. a single
61 * pattern type possibly allowed in a given group). Applications should be
62 * aware that groups are not linked by default, and that they must be
63 * explicitly linked by the application using the JUMP action.
65 * Priority levels are arbitrary and up to the application, they
66 * do not need to be contiguous nor start from 0, however the maximum number
67 * varies between devices and may be affected by existing flow rules.
69 * If a packet is matched by several rules of a given group for a given
70 * priority level, the outcome is undefined. It can take any path, may be
71 * duplicated or even cause unrecoverable errors.
73 * Note that support for more than a single group and priority level is not
76 * At vNIC / ethdev level, flow rules can apply to inbound and / or outbound
77 * traffic (ingress / egress), with respect to the vNIC / ethdev in question.
78 * At embedded switch level, flow rules apply to all traffic seen by it
79 * unless fitting meta items are used to set concrete traffic source(s).
81 * Several pattern items and actions are valid and can be used in both
82 * directions. Those valid for only one direction are described as such.
84 * At least one direction must be specified.
86 * Specifying both directions at once for a given rule is not recommended
87 * but may be valid in a few cases.
89 struct rte_flow_attr {
90 uint32_t group; /**< Priority group. */
91 uint32_t priority; /**< Rule priority level within group. */
93 * The rule in question applies to ingress traffic (non-"transfer").
96 * It has been possible to combine this attribute with "transfer".
97 * Doing so has been assumed to restrict the scope of matching
98 * to traffic going from within the embedded switch toward the
99 * ethdev the flow rule being created through. This behaviour
100 * is deprecated. During the transition period, one may still
101 * rely on it, but PMDs and applications are encouraged to
102 * gradually move away from this approach.
106 * The rule in question applies to egress traffic (non-"transfer").
109 * It has been possible to combine this attribute with "transfer".
110 * Doing so has been assumed to restrict the scope of matching
111 * to traffic sent by the application by virtue of the ethdev
112 * the flow rule being created through. This behaviour is now
113 * deprecated. During the transition period, one may still
114 * rely on it, but PMDs and applications are encouraged to
115 * gradually move away from this approach.
119 * Instead of simply matching the properties of traffic as it would
120 * appear on a given DPDK port ID, enabling this attribute transfers
121 * a flow rule to the lowest possible level of any device endpoints
122 * found in the pattern.
124 * When supported, this effectively enables an application to
125 * re-route traffic not necessarily intended for it (e.g. coming
126 * from or addressed to different physical ports, VFs or
127 * applications) at the device level.
129 * The application should match traffic originating from precise
130 * locations. See items PORT_REPRESENTOR and REPRESENTED_PORT.
132 * Managing "transfer" flows requires that the user communicate them
133 * through a suitable port. @see rte_flow_pick_transfer_proxy().
136 uint32_t reserved:29; /**< Reserved, must be zero. */
140 * Matching pattern item types.
142 * Pattern items fall in two categories:
144 * - Matching protocol headers and packet data, usually associated with a
145 * specification structure. These must be stacked in the same order as the
146 * protocol layers to match inside packets, starting from the lowest.
148 * - Matching meta-data or affecting pattern processing, often without a
149 * specification structure. Since they do not match packet contents, their
150 * position in the list is usually not relevant.
152 * See the description of individual types for more information. Those
153 * marked with [META] fall into the second category.
155 enum rte_flow_item_type {
159 * End marker for item lists. Prevents further processing of items,
160 * thereby ending the pattern.
162 * No associated specification structure.
164 RTE_FLOW_ITEM_TYPE_END,
169 * Used as a placeholder for convenience. It is ignored and simply
172 * No associated specification structure.
174 RTE_FLOW_ITEM_TYPE_VOID,
179 * Inverted matching, i.e. process packets that do not match the
182 * No associated specification structure.
184 RTE_FLOW_ITEM_TYPE_INVERT,
187 * Matches any protocol in place of the current layer, a single ANY
188 * may also stand for several protocol layers.
190 * See struct rte_flow_item_any.
192 RTE_FLOW_ITEM_TYPE_ANY,
196 * @see RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR
197 * @see RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT
201 * Matches traffic originating from (ingress) or going to (egress)
202 * the physical function of the current device.
204 * No associated specification structure.
206 RTE_FLOW_ITEM_TYPE_PF,
210 * @see RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR
211 * @see RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT
215 * Matches traffic originating from (ingress) or going to (egress) a
216 * given virtual function of the current device.
218 * See struct rte_flow_item_vf.
220 RTE_FLOW_ITEM_TYPE_VF,
224 * @see RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR
225 * @see RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT
229 * Matches traffic originating from (ingress) or going to (egress) a
230 * physical port of the underlying device.
232 * See struct rte_flow_item_phy_port.
234 RTE_FLOW_ITEM_TYPE_PHY_PORT,
238 * @see RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR
239 * @see RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT
243 * Matches traffic originating from (ingress) or going to (egress) a
244 * given DPDK port ID.
246 * See struct rte_flow_item_port_id.
248 RTE_FLOW_ITEM_TYPE_PORT_ID,
251 * Matches a byte string of a given length at a given offset.
253 * See struct rte_flow_item_raw.
255 RTE_FLOW_ITEM_TYPE_RAW,
258 * Matches an Ethernet header.
260 * See struct rte_flow_item_eth.
262 RTE_FLOW_ITEM_TYPE_ETH,
265 * Matches an 802.1Q/ad VLAN tag.
267 * See struct rte_flow_item_vlan.
269 RTE_FLOW_ITEM_TYPE_VLAN,
272 * Matches an IPv4 header.
274 * See struct rte_flow_item_ipv4.
276 RTE_FLOW_ITEM_TYPE_IPV4,
279 * Matches an IPv6 header.
281 * See struct rte_flow_item_ipv6.
283 RTE_FLOW_ITEM_TYPE_IPV6,
286 * Matches an ICMP header.
288 * See struct rte_flow_item_icmp.
290 RTE_FLOW_ITEM_TYPE_ICMP,
293 * Matches a UDP header.
295 * See struct rte_flow_item_udp.
297 RTE_FLOW_ITEM_TYPE_UDP,
300 * Matches a TCP header.
302 * See struct rte_flow_item_tcp.
304 RTE_FLOW_ITEM_TYPE_TCP,
307 * Matches a SCTP header.
309 * See struct rte_flow_item_sctp.
311 RTE_FLOW_ITEM_TYPE_SCTP,
314 * Matches a VXLAN header.
316 * See struct rte_flow_item_vxlan.
318 RTE_FLOW_ITEM_TYPE_VXLAN,
321 * Matches a E_TAG header.
323 * See struct rte_flow_item_e_tag.
325 RTE_FLOW_ITEM_TYPE_E_TAG,
328 * Matches a NVGRE header.
330 * See struct rte_flow_item_nvgre.
332 RTE_FLOW_ITEM_TYPE_NVGRE,
335 * Matches a MPLS header.
337 * See struct rte_flow_item_mpls.
339 RTE_FLOW_ITEM_TYPE_MPLS,
342 * Matches a GRE header.
344 * See struct rte_flow_item_gre.
346 RTE_FLOW_ITEM_TYPE_GRE,
351 * Fuzzy pattern match, expect faster than default.
353 * This is for device that support fuzzy matching option.
354 * Usually a fuzzy matching is fast but the cost is accuracy.
356 * See struct rte_flow_item_fuzzy.
358 RTE_FLOW_ITEM_TYPE_FUZZY,
361 * Matches a GTP header.
363 * Configure flow for GTP packets.
365 * See struct rte_flow_item_gtp.
367 RTE_FLOW_ITEM_TYPE_GTP,
370 * Matches a GTP header.
372 * Configure flow for GTP-C packets.
374 * See struct rte_flow_item_gtp.
376 RTE_FLOW_ITEM_TYPE_GTPC,
379 * Matches a GTP header.
381 * Configure flow for GTP-U packets.
383 * See struct rte_flow_item_gtp.
385 RTE_FLOW_ITEM_TYPE_GTPU,
388 * Matches a ESP header.
390 * See struct rte_flow_item_esp.
392 RTE_FLOW_ITEM_TYPE_ESP,
395 * Matches a GENEVE header.
397 * See struct rte_flow_item_geneve.
399 RTE_FLOW_ITEM_TYPE_GENEVE,
402 * Matches a VXLAN-GPE header.
404 * See struct rte_flow_item_vxlan_gpe.
406 RTE_FLOW_ITEM_TYPE_VXLAN_GPE,
409 * Matches an ARP header for Ethernet/IPv4.
411 * See struct rte_flow_item_arp_eth_ipv4.
413 RTE_FLOW_ITEM_TYPE_ARP_ETH_IPV4,
416 * Matches the presence of any IPv6 extension header.
418 * See struct rte_flow_item_ipv6_ext.
420 RTE_FLOW_ITEM_TYPE_IPV6_EXT,
423 * Matches any ICMPv6 header.
425 * See struct rte_flow_item_icmp6.
427 RTE_FLOW_ITEM_TYPE_ICMP6,
430 * Matches an ICMPv6 neighbor discovery solicitation.
432 * See struct rte_flow_item_icmp6_nd_ns.
434 RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS,
437 * Matches an ICMPv6 neighbor discovery advertisement.
439 * See struct rte_flow_item_icmp6_nd_na.
441 RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA,
444 * Matches the presence of any ICMPv6 neighbor discovery option.
446 * See struct rte_flow_item_icmp6_nd_opt.
448 RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT,
451 * Matches an ICMPv6 neighbor discovery source Ethernet link-layer
454 * See struct rte_flow_item_icmp6_nd_opt_sla_eth.
456 RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_SLA_ETH,
459 * Matches an ICMPv6 neighbor discovery target Ethernet link-layer
462 * See struct rte_flow_item_icmp6_nd_opt_tla_eth.
464 RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_TLA_ETH,
467 * Matches specified mark field.
469 * See struct rte_flow_item_mark.
471 RTE_FLOW_ITEM_TYPE_MARK,
476 * Matches a metadata value.
478 * See struct rte_flow_item_meta.
480 RTE_FLOW_ITEM_TYPE_META,
483 * Matches a GRE optional key field.
485 * The value should a big-endian 32bit integer.
487 * When this item present the K bit is implicitly matched as "1"
488 * in the default mask.
491 * @code rte_be32_t * @endcode
493 RTE_FLOW_ITEM_TYPE_GRE_KEY,
496 * Matches a GTP extension header: PDU session container.
498 * Configure flow for GTP packets with extension header type 0x85.
500 * See struct rte_flow_item_gtp_psc.
502 RTE_FLOW_ITEM_TYPE_GTP_PSC,
505 * Matches a PPPoE header.
507 * Configure flow for PPPoE session packets.
509 * See struct rte_flow_item_pppoe.
511 RTE_FLOW_ITEM_TYPE_PPPOES,
514 * Matches a PPPoE header.
516 * Configure flow for PPPoE discovery packets.
518 * See struct rte_flow_item_pppoe.
520 RTE_FLOW_ITEM_TYPE_PPPOED,
523 * Matches a PPPoE optional proto_id field.
525 * It only applies to PPPoE session packets.
527 * See struct rte_flow_item_pppoe_proto_id.
529 RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID,
532 * Matches Network service header (NSH).
533 * See struct rte_flow_item_nsh.
536 RTE_FLOW_ITEM_TYPE_NSH,
539 * Matches Internet Group Management Protocol (IGMP).
540 * See struct rte_flow_item_igmp.
543 RTE_FLOW_ITEM_TYPE_IGMP,
546 * Matches IP Authentication Header (AH).
547 * See struct rte_flow_item_ah.
550 RTE_FLOW_ITEM_TYPE_AH,
553 * Matches a HIGIG header.
554 * see struct rte_flow_item_higig2_hdr.
556 RTE_FLOW_ITEM_TYPE_HIGIG2,
561 * Matches a tag value.
563 * See struct rte_flow_item_tag.
565 RTE_FLOW_ITEM_TYPE_TAG,
568 * Matches a L2TPv3 over IP header.
570 * Configure flow for L2TPv3 over IP packets.
572 * See struct rte_flow_item_l2tpv3oip.
574 RTE_FLOW_ITEM_TYPE_L2TPV3OIP,
577 * Matches PFCP Header.
578 * See struct rte_flow_item_pfcp.
581 RTE_FLOW_ITEM_TYPE_PFCP,
584 * Matches eCPRI Header.
586 * Configure flow for eCPRI over ETH or UDP packets.
588 * See struct rte_flow_item_ecpri.
590 RTE_FLOW_ITEM_TYPE_ECPRI,
593 * Matches the presence of IPv6 fragment extension header.
595 * See struct rte_flow_item_ipv6_frag_ext.
597 RTE_FLOW_ITEM_TYPE_IPV6_FRAG_EXT,
600 * Matches Geneve Variable Length Option
602 * See struct rte_flow_item_geneve_opt
604 RTE_FLOW_ITEM_TYPE_GENEVE_OPT,
609 * Matches on packet integrity.
610 * For some devices application needs to enable integration checks in HW
611 * before using this item.
613 * @see struct rte_flow_item_integrity.
615 RTE_FLOW_ITEM_TYPE_INTEGRITY,
620 * Matches conntrack state.
622 * @see struct rte_flow_item_conntrack.
624 RTE_FLOW_ITEM_TYPE_CONNTRACK,
629 * Matches traffic entering the embedded switch from the given ethdev.
631 * @see struct rte_flow_item_ethdev
633 RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR,
638 * Matches traffic entering the embedded switch from
639 * the entity represented by the given ethdev.
641 * @see struct rte_flow_item_ethdev
643 RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT,
646 * Matches a configured set of fields at runtime calculated offsets
647 * over the generic network header with variable length and
650 * @see struct rte_flow_item_flex.
652 RTE_FLOW_ITEM_TYPE_FLEX,
655 * Matches L2TPv2 Header.
657 * See struct rte_flow_item_l2tpv2.
659 RTE_FLOW_ITEM_TYPE_L2TPV2,
662 * Matches PPP Header.
664 * See struct rte_flow_item_ppp.
666 RTE_FLOW_ITEM_TYPE_PPP,
669 * Matches GRE optional fields.
671 * See struct rte_flow_item_gre_opt.
673 RTE_FLOW_ITEM_TYPE_GRE_OPTION,
678 * RTE_FLOW_ITEM_TYPE_HIGIG2
679 * Matches higig2 header
682 struct rte_flow_item_higig2_hdr {
683 struct rte_higig2_hdr hdr;
686 /** Default mask for RTE_FLOW_ITEM_TYPE_HIGIG2. */
688 static const struct rte_flow_item_higig2_hdr rte_flow_item_higig2_hdr_mask = {
691 .classification = 0xffff,
699 * RTE_FLOW_ITEM_TYPE_ANY
701 * Matches any protocol in place of the current layer, a single ANY may also
702 * stand for several protocol layers.
704 * This is usually specified as the first pattern item when looking for a
705 * protocol anywhere in a packet.
707 * A zeroed mask stands for any number of layers.
709 struct rte_flow_item_any {
710 uint32_t num; /**< Number of layers covered. */
713 /** Default mask for RTE_FLOW_ITEM_TYPE_ANY. */
715 static const struct rte_flow_item_any rte_flow_item_any_mask = {
722 * @see RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR
723 * @see RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT
725 * RTE_FLOW_ITEM_TYPE_VF
727 * Matches traffic originating from (ingress) or going to (egress) a given
728 * virtual function of the current device.
730 * If supported, should work even if the virtual function is not managed by
731 * the application and thus not associated with a DPDK port ID.
733 * Note this pattern item does not match VF representors traffic which, as
734 * separate entities, should be addressed through their own DPDK port IDs.
736 * - Can be specified multiple times to match traffic addressed to several
738 * - Can be combined with a PF item to match both PF and VF traffic.
740 * A zeroed mask can be used to match any VF ID.
742 struct rte_flow_item_vf {
743 uint32_t id; /**< VF ID. */
746 /** Default mask for RTE_FLOW_ITEM_TYPE_VF. */
748 static const struct rte_flow_item_vf rte_flow_item_vf_mask = {
755 * @see RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR
756 * @see RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT
758 * RTE_FLOW_ITEM_TYPE_PHY_PORT
760 * Matches traffic originating from (ingress) or going to (egress) a
761 * physical port of the underlying device.
763 * The first PHY_PORT item overrides the physical port normally associated
764 * with the specified DPDK input port (port_id). This item can be provided
765 * several times to match additional physical ports.
767 * Note that physical ports are not necessarily tied to DPDK input ports
768 * (port_id) when those are not under DPDK control. Possible values are
769 * specific to each device, they are not necessarily indexed from zero and
770 * may not be contiguous.
772 * As a device property, the list of allowed values as well as the value
773 * associated with a port_id should be retrieved by other means.
775 * A zeroed mask can be used to match any port index.
777 struct rte_flow_item_phy_port {
778 uint32_t index; /**< Physical port index. */
781 /** Default mask for RTE_FLOW_ITEM_TYPE_PHY_PORT. */
783 static const struct rte_flow_item_phy_port rte_flow_item_phy_port_mask = {
790 * @see RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR
791 * @see RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT
793 * RTE_FLOW_ITEM_TYPE_PORT_ID
795 * Matches traffic originating from (ingress) or going to (egress) a given
798 * Normally only supported if the port ID in question is known by the
799 * underlying PMD and related to the device the flow rule is created
802 * This must not be confused with @p PHY_PORT which refers to the physical
803 * port of a device, whereas @p PORT_ID refers to a struct rte_eth_dev
804 * object on the application side (also known as "port representor"
805 * depending on the kind of underlying device).
807 struct rte_flow_item_port_id {
808 uint32_t id; /**< DPDK port ID. */
811 /** Default mask for RTE_FLOW_ITEM_TYPE_PORT_ID. */
813 static const struct rte_flow_item_port_id rte_flow_item_port_id_mask = {
819 * RTE_FLOW_ITEM_TYPE_RAW
821 * Matches a byte string of a given length at a given offset.
823 * Offset is either absolute (using the start of the packet) or relative to
824 * the end of the previous matched item in the stack, in which case negative
825 * values are allowed.
827 * If search is enabled, offset is used as the starting point. The search
828 * area can be delimited by setting limit to a nonzero value, which is the
829 * maximum number of bytes after offset where the pattern may start.
831 * Matching a zero-length pattern is allowed, doing so resets the relative
832 * offset for subsequent items.
834 * This type does not support ranges (struct rte_flow_item.last).
836 struct rte_flow_item_raw {
837 uint32_t relative:1; /**< Look for pattern after the previous item. */
838 uint32_t search:1; /**< Search pattern from offset (see also limit). */
839 uint32_t reserved:30; /**< Reserved, must be set to zero. */
840 int32_t offset; /**< Absolute or relative offset for pattern. */
841 uint16_t limit; /**< Search area limit for start of pattern. */
842 uint16_t length; /**< Pattern length. */
843 const uint8_t *pattern; /**< Byte string to look for. */
846 /** Default mask for RTE_FLOW_ITEM_TYPE_RAW. */
848 static const struct rte_flow_item_raw rte_flow_item_raw_mask = {
851 .reserved = 0x3fffffff,
852 .offset = 0xffffffff,
860 * RTE_FLOW_ITEM_TYPE_ETH
862 * Matches an Ethernet header.
864 * Inside @p hdr field, the sub-field @p ether_type stands either for EtherType
865 * or TPID, depending on whether the item is followed by a VLAN item or not. If
866 * two VLAN items follow, the sub-field refers to the outer one, which, in turn,
867 * contains the inner TPID in the similar header field. The innermost VLAN item
868 * contains a layer-3 EtherType. All of that follows the order seen on the wire.
870 * If the field in question contains a TPID value, only tagged packets with the
871 * specified TPID will match the pattern. Alternatively, it's possible to match
872 * any type of tagged packets by means of the field @p has_vlan rather than use
873 * the EtherType/TPID field. Also, it's possible to leave the two fields unused.
874 * If this is the case, both tagged and untagged packets will match the pattern.
877 struct rte_flow_item_eth {
881 * These fields are retained for compatibility.
882 * Please switch to the new header field below.
884 struct rte_ether_addr dst; /**< Destination MAC. */
885 struct rte_ether_addr src; /**< Source MAC. */
886 rte_be16_t type; /**< EtherType or TPID. */
888 struct rte_ether_hdr hdr;
890 uint32_t has_vlan:1; /**< Packet header contains at least one VLAN. */
891 uint32_t reserved:31; /**< Reserved, must be zero. */
894 /** Default mask for RTE_FLOW_ITEM_TYPE_ETH. */
896 static const struct rte_flow_item_eth rte_flow_item_eth_mask = {
897 .hdr.dst_addr.addr_bytes = "\xff\xff\xff\xff\xff\xff",
898 .hdr.src_addr.addr_bytes = "\xff\xff\xff\xff\xff\xff",
899 .hdr.ether_type = RTE_BE16(0x0000),
904 * RTE_FLOW_ITEM_TYPE_VLAN
906 * Matches an 802.1Q/ad VLAN tag.
908 * The corresponding standard outer EtherType (TPID) values are
909 * RTE_ETHER_TYPE_VLAN or RTE_ETHER_TYPE_QINQ. It can be overridden by
910 * the preceding pattern item.
911 * If a @p VLAN item is present in the pattern, then only tagged packets will
913 * The field @p has_more_vlan can be used to match any type of tagged packets,
914 * instead of using the @p eth_proto field of @p hdr.
915 * If the @p eth_proto of @p hdr and @p has_more_vlan fields are not specified,
916 * then any tagged packets will match the pattern.
919 struct rte_flow_item_vlan {
923 * These fields are retained for compatibility.
924 * Please switch to the new header field below.
926 rte_be16_t tci; /**< Tag control information. */
927 rte_be16_t inner_type; /**< Inner EtherType or TPID. */
929 struct rte_vlan_hdr hdr;
931 /** Packet header contains at least one more VLAN, after this VLAN. */
932 uint32_t has_more_vlan:1;
933 uint32_t reserved:31; /**< Reserved, must be zero. */
936 /** Default mask for RTE_FLOW_ITEM_TYPE_VLAN. */
938 static const struct rte_flow_item_vlan rte_flow_item_vlan_mask = {
939 .hdr.vlan_tci = RTE_BE16(0x0fff),
940 .hdr.eth_proto = RTE_BE16(0x0000),
945 * RTE_FLOW_ITEM_TYPE_IPV4
947 * Matches an IPv4 header.
949 * Note: IPv4 options are handled by dedicated pattern items.
951 struct rte_flow_item_ipv4 {
952 struct rte_ipv4_hdr hdr; /**< IPv4 header definition. */
955 /** Default mask for RTE_FLOW_ITEM_TYPE_IPV4. */
957 static const struct rte_flow_item_ipv4 rte_flow_item_ipv4_mask = {
959 .src_addr = RTE_BE32(0xffffffff),
960 .dst_addr = RTE_BE32(0xffffffff),
966 * RTE_FLOW_ITEM_TYPE_IPV6.
968 * Matches an IPv6 header.
970 * Dedicated flags indicate if header contains specific extension headers.
972 struct rte_flow_item_ipv6 {
973 struct rte_ipv6_hdr hdr; /**< IPv6 header definition. */
974 /** Header contains Hop-by-Hop Options extension header. */
975 uint32_t has_hop_ext:1;
976 /** Header contains Routing extension header. */
977 uint32_t has_route_ext:1;
978 /** Header contains Fragment extension header. */
979 uint32_t has_frag_ext:1;
980 /** Header contains Authentication extension header. */
981 uint32_t has_auth_ext:1;
982 /** Header contains Encapsulation Security Payload extension header. */
983 uint32_t has_esp_ext:1;
984 /** Header contains Destination Options extension header. */
985 uint32_t has_dest_ext:1;
986 /** Header contains Mobility extension header. */
987 uint32_t has_mobil_ext:1;
988 /** Header contains Host Identity Protocol extension header. */
989 uint32_t has_hip_ext:1;
990 /** Header contains Shim6 Protocol extension header. */
991 uint32_t has_shim6_ext:1;
992 /** Reserved for future extension headers, must be zero. */
993 uint32_t reserved:23;
996 /** Default mask for RTE_FLOW_ITEM_TYPE_IPV6. */
998 static const struct rte_flow_item_ipv6 rte_flow_item_ipv6_mask = {
1001 "\xff\xff\xff\xff\xff\xff\xff\xff"
1002 "\xff\xff\xff\xff\xff\xff\xff\xff",
1004 "\xff\xff\xff\xff\xff\xff\xff\xff"
1005 "\xff\xff\xff\xff\xff\xff\xff\xff",
1011 * RTE_FLOW_ITEM_TYPE_ICMP.
1013 * Matches an ICMP header.
1015 struct rte_flow_item_icmp {
1016 struct rte_icmp_hdr hdr; /**< ICMP header definition. */
1019 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP. */
1021 static const struct rte_flow_item_icmp rte_flow_item_icmp_mask = {
1030 * RTE_FLOW_ITEM_TYPE_UDP.
1032 * Matches a UDP header.
1034 struct rte_flow_item_udp {
1035 struct rte_udp_hdr hdr; /**< UDP header definition. */
1038 /** Default mask for RTE_FLOW_ITEM_TYPE_UDP. */
1040 static const struct rte_flow_item_udp rte_flow_item_udp_mask = {
1042 .src_port = RTE_BE16(0xffff),
1043 .dst_port = RTE_BE16(0xffff),
1049 * RTE_FLOW_ITEM_TYPE_TCP.
1051 * Matches a TCP header.
1053 struct rte_flow_item_tcp {
1054 struct rte_tcp_hdr hdr; /**< TCP header definition. */
1057 /** Default mask for RTE_FLOW_ITEM_TYPE_TCP. */
1059 static const struct rte_flow_item_tcp rte_flow_item_tcp_mask = {
1061 .src_port = RTE_BE16(0xffff),
1062 .dst_port = RTE_BE16(0xffff),
1068 * RTE_FLOW_ITEM_TYPE_SCTP.
1070 * Matches a SCTP header.
1072 struct rte_flow_item_sctp {
1073 struct rte_sctp_hdr hdr; /**< SCTP header definition. */
1076 /** Default mask for RTE_FLOW_ITEM_TYPE_SCTP. */
1078 static const struct rte_flow_item_sctp rte_flow_item_sctp_mask = {
1080 .src_port = RTE_BE16(0xffff),
1081 .dst_port = RTE_BE16(0xffff),
1087 * RTE_FLOW_ITEM_TYPE_VXLAN.
1089 * Matches a VXLAN header (RFC 7348).
1092 struct rte_flow_item_vxlan {
1096 * These fields are retained for compatibility.
1097 * Please switch to the new header field below.
1099 uint8_t flags; /**< Normally 0x08 (I flag). */
1100 uint8_t rsvd0[3]; /**< Reserved, normally 0x000000. */
1101 uint8_t vni[3]; /**< VXLAN identifier. */
1102 uint8_t rsvd1; /**< Reserved, normally 0x00. */
1104 struct rte_vxlan_hdr hdr;
1108 /** Default mask for RTE_FLOW_ITEM_TYPE_VXLAN. */
1110 static const struct rte_flow_item_vxlan rte_flow_item_vxlan_mask = {
1111 .hdr.vx_vni = RTE_BE32(0xffffff00), /* (0xffffff << 8) */
1116 * RTE_FLOW_ITEM_TYPE_E_TAG.
1118 * Matches a E-tag header.
1120 * The corresponding standard outer EtherType (TPID) value is
1121 * RTE_ETHER_TYPE_ETAG. It can be overridden by the preceding pattern item.
1123 struct rte_flow_item_e_tag {
1125 * E-Tag control information (E-TCI).
1126 * E-PCP (3b), E-DEI (1b), ingress E-CID base (12b).
1128 rte_be16_t epcp_edei_in_ecid_b;
1129 /** Reserved (2b), GRP (2b), E-CID base (12b). */
1130 rte_be16_t rsvd_grp_ecid_b;
1131 uint8_t in_ecid_e; /**< Ingress E-CID ext. */
1132 uint8_t ecid_e; /**< E-CID ext. */
1133 rte_be16_t inner_type; /**< Inner EtherType or TPID. */
1136 /** Default mask for RTE_FLOW_ITEM_TYPE_E_TAG. */
1138 static const struct rte_flow_item_e_tag rte_flow_item_e_tag_mask = {
1139 .rsvd_grp_ecid_b = RTE_BE16(0x3fff),
1144 * RTE_FLOW_ITEM_TYPE_NVGRE.
1146 * Matches a NVGRE header.
1148 struct rte_flow_item_nvgre {
1150 * Checksum (1b), undefined (1b), key bit (1b), sequence number (1b),
1151 * reserved 0 (9b), version (3b).
1153 * c_k_s_rsvd0_ver must have value 0x2000 according to RFC 7637.
1155 rte_be16_t c_k_s_rsvd0_ver;
1156 rte_be16_t protocol; /**< Protocol type (0x6558). */
1157 uint8_t tni[3]; /**< Virtual subnet ID. */
1158 uint8_t flow_id; /**< Flow ID. */
1161 /** Default mask for RTE_FLOW_ITEM_TYPE_NVGRE. */
1163 static const struct rte_flow_item_nvgre rte_flow_item_nvgre_mask = {
1164 .tni = "\xff\xff\xff",
1169 * RTE_FLOW_ITEM_TYPE_MPLS.
1171 * Matches a MPLS header.
1173 struct rte_flow_item_mpls {
1175 * Label (20b), TC (3b), Bottom of Stack (1b).
1177 uint8_t label_tc_s[3];
1178 uint8_t ttl; /** Time-to-Live. */
1181 /** Default mask for RTE_FLOW_ITEM_TYPE_MPLS. */
1183 static const struct rte_flow_item_mpls rte_flow_item_mpls_mask = {
1184 .label_tc_s = "\xff\xff\xf0",
1189 * RTE_FLOW_ITEM_TYPE_GRE.
1191 * Matches a GRE header.
1193 struct rte_flow_item_gre {
1195 * Checksum (1b), reserved 0 (12b), version (3b).
1196 * Refer to RFC 2784.
1198 rte_be16_t c_rsvd0_ver;
1199 rte_be16_t protocol; /**< Protocol type. */
1202 /** Default mask for RTE_FLOW_ITEM_TYPE_GRE. */
1204 static const struct rte_flow_item_gre rte_flow_item_gre_mask = {
1205 .protocol = RTE_BE16(0xffff),
1210 * RTE_FLOW_ITEM_TYPE_GRE_OPTION.
1212 * Matches GRE optional fields in header.
1214 struct rte_flow_item_gre_opt {
1215 struct rte_gre_hdr_opt_checksum_rsvd checksum_rsvd;
1216 struct rte_gre_hdr_opt_key key;
1217 struct rte_gre_hdr_opt_sequence sequence;
1221 * RTE_FLOW_ITEM_TYPE_FUZZY
1223 * Fuzzy pattern match, expect faster than default.
1225 * This is for device that support fuzzy match option.
1226 * Usually a fuzzy match is fast but the cost is accuracy.
1227 * i.e. Signature Match only match pattern's hash value, but it is
1228 * possible two different patterns have the same hash value.
1230 * Matching accuracy level can be configure by threshold.
1231 * Driver can divide the range of threshold and map to different
1232 * accuracy levels that device support.
1234 * Threshold 0 means perfect match (no fuzziness), while threshold
1235 * 0xffffffff means fuzziest match.
1237 struct rte_flow_item_fuzzy {
1238 uint32_t thresh; /**< Accuracy threshold. */
1241 /** Default mask for RTE_FLOW_ITEM_TYPE_FUZZY. */
1243 static const struct rte_flow_item_fuzzy rte_flow_item_fuzzy_mask = {
1244 .thresh = 0xffffffff,
1249 * RTE_FLOW_ITEM_TYPE_GTP.
1251 * Matches a GTPv1 header.
1253 struct rte_flow_item_gtp {
1255 * Version (3b), protocol type (1b), reserved (1b),
1256 * Extension header flag (1b),
1257 * Sequence number flag (1b),
1258 * N-PDU number flag (1b).
1260 uint8_t v_pt_rsv_flags;
1261 uint8_t msg_type; /**< Message type. */
1262 rte_be16_t msg_len; /**< Message length. */
1263 rte_be32_t teid; /**< Tunnel endpoint identifier. */
1266 /** Default mask for RTE_FLOW_ITEM_TYPE_GTP. */
1268 static const struct rte_flow_item_gtp rte_flow_item_gtp_mask = {
1269 .teid = RTE_BE32(0xffffffff),
1274 * RTE_FLOW_ITEM_TYPE_ESP
1276 * Matches an ESP header.
1278 struct rte_flow_item_esp {
1279 struct rte_esp_hdr hdr; /**< ESP header definition. */
1282 /** Default mask for RTE_FLOW_ITEM_TYPE_ESP. */
1284 static const struct rte_flow_item_esp rte_flow_item_esp_mask = {
1286 .spi = RTE_BE32(0xffffffff),
1292 * RTE_FLOW_ITEM_TYPE_GENEVE.
1294 * Matches a GENEVE header.
1296 struct rte_flow_item_geneve {
1298 * Version (2b), length of the options fields (6b), OAM packet (1b),
1299 * critical options present (1b), reserved 0 (6b).
1301 rte_be16_t ver_opt_len_o_c_rsvd0;
1302 rte_be16_t protocol; /**< Protocol type. */
1303 uint8_t vni[3]; /**< Virtual Network Identifier. */
1304 uint8_t rsvd1; /**< Reserved, normally 0x00. */
1307 /** Default mask for RTE_FLOW_ITEM_TYPE_GENEVE. */
1309 static const struct rte_flow_item_geneve rte_flow_item_geneve_mask = {
1310 .vni = "\xff\xff\xff",
1315 * RTE_FLOW_ITEM_TYPE_VXLAN_GPE (draft-ietf-nvo3-vxlan-gpe-05).
1317 * Matches a VXLAN-GPE header.
1319 struct rte_flow_item_vxlan_gpe {
1320 uint8_t flags; /**< Normally 0x0c (I and P flags). */
1321 uint8_t rsvd0[2]; /**< Reserved, normally 0x0000. */
1322 uint8_t protocol; /**< Protocol type. */
1323 uint8_t vni[3]; /**< VXLAN identifier. */
1324 uint8_t rsvd1; /**< Reserved, normally 0x00. */
1327 /** Default mask for RTE_FLOW_ITEM_TYPE_VXLAN_GPE. */
1329 static const struct rte_flow_item_vxlan_gpe rte_flow_item_vxlan_gpe_mask = {
1330 .vni = "\xff\xff\xff",
1335 * RTE_FLOW_ITEM_TYPE_ARP_ETH_IPV4
1337 * Matches an ARP header for Ethernet/IPv4.
1339 struct rte_flow_item_arp_eth_ipv4 {
1340 rte_be16_t hrd; /**< Hardware type, normally 1. */
1341 rte_be16_t pro; /**< Protocol type, normally 0x0800. */
1342 uint8_t hln; /**< Hardware address length, normally 6. */
1343 uint8_t pln; /**< Protocol address length, normally 4. */
1344 rte_be16_t op; /**< Opcode (1 for request, 2 for reply). */
1345 struct rte_ether_addr sha; /**< Sender hardware address. */
1346 rte_be32_t spa; /**< Sender IPv4 address. */
1347 struct rte_ether_addr tha; /**< Target hardware address. */
1348 rte_be32_t tpa; /**< Target IPv4 address. */
1351 /** Default mask for RTE_FLOW_ITEM_TYPE_ARP_ETH_IPV4. */
1353 static const struct rte_flow_item_arp_eth_ipv4
1354 rte_flow_item_arp_eth_ipv4_mask = {
1355 .sha.addr_bytes = "\xff\xff\xff\xff\xff\xff",
1356 .spa = RTE_BE32(0xffffffff),
1357 .tha.addr_bytes = "\xff\xff\xff\xff\xff\xff",
1358 .tpa = RTE_BE32(0xffffffff),
1363 * RTE_FLOW_ITEM_TYPE_IPV6_EXT
1365 * Matches the presence of any IPv6 extension header.
1367 * Normally preceded by any of:
1369 * - RTE_FLOW_ITEM_TYPE_IPV6
1370 * - RTE_FLOW_ITEM_TYPE_IPV6_EXT
1372 struct rte_flow_item_ipv6_ext {
1373 uint8_t next_hdr; /**< Next header. */
1376 /** Default mask for RTE_FLOW_ITEM_TYPE_IPV6_EXT. */
1379 struct rte_flow_item_ipv6_ext rte_flow_item_ipv6_ext_mask = {
1385 * RTE_FLOW_ITEM_TYPE_IPV6_FRAG_EXT
1387 * Matches the presence of IPv6 fragment extension header.
1389 * Preceded by any of:
1391 * - RTE_FLOW_ITEM_TYPE_IPV6
1392 * - RTE_FLOW_ITEM_TYPE_IPV6_EXT
1394 struct rte_flow_item_ipv6_frag_ext {
1395 struct rte_ipv6_fragment_ext hdr;
1399 * RTE_FLOW_ITEM_TYPE_ICMP6
1401 * Matches any ICMPv6 header.
1403 struct rte_flow_item_icmp6 {
1404 uint8_t type; /**< ICMPv6 type. */
1405 uint8_t code; /**< ICMPv6 code. */
1406 uint16_t checksum; /**< ICMPv6 checksum. */
1409 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6. */
1411 static const struct rte_flow_item_icmp6 rte_flow_item_icmp6_mask = {
1418 * RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS
1420 * Matches an ICMPv6 neighbor discovery solicitation.
1422 struct rte_flow_item_icmp6_nd_ns {
1423 uint8_t type; /**< ICMPv6 type, normally 135. */
1424 uint8_t code; /**< ICMPv6 code, normally 0. */
1425 rte_be16_t checksum; /**< ICMPv6 checksum. */
1426 rte_be32_t reserved; /**< Reserved, normally 0. */
1427 uint8_t target_addr[16]; /**< Target address. */
1430 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS. */
1433 struct rte_flow_item_icmp6_nd_ns rte_flow_item_icmp6_nd_ns_mask = {
1435 "\xff\xff\xff\xff\xff\xff\xff\xff"
1436 "\xff\xff\xff\xff\xff\xff\xff\xff",
1441 * RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA
1443 * Matches an ICMPv6 neighbor discovery advertisement.
1445 struct rte_flow_item_icmp6_nd_na {
1446 uint8_t type; /**< ICMPv6 type, normally 136. */
1447 uint8_t code; /**< ICMPv6 code, normally 0. */
1448 rte_be16_t checksum; /**< ICMPv6 checksum. */
1450 * Route flag (1b), solicited flag (1b), override flag (1b),
1453 rte_be32_t rso_reserved;
1454 uint8_t target_addr[16]; /**< Target address. */
1457 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA. */
1460 struct rte_flow_item_icmp6_nd_na rte_flow_item_icmp6_nd_na_mask = {
1462 "\xff\xff\xff\xff\xff\xff\xff\xff"
1463 "\xff\xff\xff\xff\xff\xff\xff\xff",
1468 * RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT
1470 * Matches the presence of any ICMPv6 neighbor discovery option.
1472 * Normally preceded by any of:
1474 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA
1475 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS
1476 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT
1478 struct rte_flow_item_icmp6_nd_opt {
1479 uint8_t type; /**< ND option type. */
1480 uint8_t length; /**< ND option length. */
1483 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT. */
1485 static const struct rte_flow_item_icmp6_nd_opt
1486 rte_flow_item_icmp6_nd_opt_mask = {
1492 * RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_SLA_ETH
1494 * Matches an ICMPv6 neighbor discovery source Ethernet link-layer address
1497 * Normally preceded by any of:
1499 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA
1500 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT
1502 struct rte_flow_item_icmp6_nd_opt_sla_eth {
1503 uint8_t type; /**< ND option type, normally 1. */
1504 uint8_t length; /**< ND option length, normally 1. */
1505 struct rte_ether_addr sla; /**< Source Ethernet LLA. */
1508 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_SLA_ETH. */
1510 static const struct rte_flow_item_icmp6_nd_opt_sla_eth
1511 rte_flow_item_icmp6_nd_opt_sla_eth_mask = {
1512 .sla.addr_bytes = "\xff\xff\xff\xff\xff\xff",
1517 * RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_TLA_ETH
1519 * Matches an ICMPv6 neighbor discovery target Ethernet link-layer address
1522 * Normally preceded by any of:
1524 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS
1525 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT
1527 struct rte_flow_item_icmp6_nd_opt_tla_eth {
1528 uint8_t type; /**< ND option type, normally 2. */
1529 uint8_t length; /**< ND option length, normally 1. */
1530 struct rte_ether_addr tla; /**< Target Ethernet LLA. */
1533 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_TLA_ETH. */
1535 static const struct rte_flow_item_icmp6_nd_opt_tla_eth
1536 rte_flow_item_icmp6_nd_opt_tla_eth_mask = {
1537 .tla.addr_bytes = "\xff\xff\xff\xff\xff\xff",
1542 * RTE_FLOW_ITEM_TYPE_META
1544 * Matches a specified metadata value. On egress, metadata can be set
1545 * either by mbuf dynamic metadata field with RTE_MBUF_DYNFLAG_TX_METADATA flag
1546 * or RTE_FLOW_ACTION_TYPE_SET_META. On ingress, RTE_FLOW_ACTION_TYPE_SET_META
1547 * sets metadata for a packet and the metadata will be reported via mbuf
1548 * metadata dynamic field with RTE_MBUF_DYNFLAG_RX_METADATA flag. The dynamic
1549 * mbuf field must be registered in advance by
1550 * rte_flow_dynf_metadata_register().
1552 struct rte_flow_item_meta {
1556 /** Default mask for RTE_FLOW_ITEM_TYPE_META. */
1558 static const struct rte_flow_item_meta rte_flow_item_meta_mask = {
1564 * RTE_FLOW_ITEM_TYPE_GTP_PSC.
1566 * Matches a GTP PDU extension header with type 0x85.
1568 struct rte_flow_item_gtp_psc {
1569 struct rte_gtp_psc_generic_hdr hdr; /**< gtp psc generic hdr. */
1572 /** Default mask for RTE_FLOW_ITEM_TYPE_GTP_PSC. */
1574 static const struct rte_flow_item_gtp_psc
1575 rte_flow_item_gtp_psc_mask = {
1581 * RTE_FLOW_ITEM_TYPE_PPPOE.
1583 * Matches a PPPoE header.
1585 struct rte_flow_item_pppoe {
1587 * Version (4b), type (4b).
1589 uint8_t version_type;
1590 uint8_t code; /**< Message type. */
1591 rte_be16_t session_id; /**< Session identifier. */
1592 rte_be16_t length; /**< Payload length. */
1596 * RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID.
1598 * Matches a PPPoE optional proto_id field.
1600 * It only applies to PPPoE session packets.
1602 * Normally preceded by any of:
1604 * - RTE_FLOW_ITEM_TYPE_PPPOE
1605 * - RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID
1607 struct rte_flow_item_pppoe_proto_id {
1608 rte_be16_t proto_id; /**< PPP protocol identifier. */
1611 /** Default mask for RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID. */
1613 static const struct rte_flow_item_pppoe_proto_id
1614 rte_flow_item_pppoe_proto_id_mask = {
1615 .proto_id = RTE_BE16(0xffff),
1621 * @b EXPERIMENTAL: this structure may change without prior notice
1623 * RTE_FLOW_ITEM_TYPE_TAG
1625 * Matches a specified tag value at the specified index.
1627 struct rte_flow_item_tag {
1632 /** Default mask for RTE_FLOW_ITEM_TYPE_TAG. */
1634 static const struct rte_flow_item_tag rte_flow_item_tag_mask = {
1641 * RTE_FLOW_ITEM_TYPE_L2TPV3OIP.
1643 * Matches a L2TPv3 over IP header.
1645 struct rte_flow_item_l2tpv3oip {
1646 rte_be32_t session_id; /**< Session ID. */
1649 /** Default mask for RTE_FLOW_ITEM_TYPE_L2TPV3OIP. */
1651 static const struct rte_flow_item_l2tpv3oip rte_flow_item_l2tpv3oip_mask = {
1652 .session_id = RTE_BE32(UINT32_MAX),
1659 * @b EXPERIMENTAL: this structure may change without prior notice
1661 * RTE_FLOW_ITEM_TYPE_MARK
1663 * Matches an arbitrary integer value which was set using the ``MARK`` action
1664 * in a previously matched rule.
1666 * This item can only be specified once as a match criteria as the ``MARK``
1667 * action can only be specified once in a flow action.
1669 * This value is arbitrary and application-defined. Maximum allowed value
1670 * depends on the underlying implementation.
1672 * Depending on the underlying implementation the MARK item may be supported on
1673 * the physical device, with virtual groups in the PMD or not at all.
1675 struct rte_flow_item_mark {
1676 uint32_t id; /**< Integer value to match against. */
1679 /** Default mask for RTE_FLOW_ITEM_TYPE_MARK. */
1681 static const struct rte_flow_item_mark rte_flow_item_mark_mask = {
1688 * @b EXPERIMENTAL: this structure may change without prior notice
1690 * RTE_FLOW_ITEM_TYPE_NSH
1692 * Match network service header (NSH), RFC 8300
1695 struct rte_flow_item_nsh {
1698 uint32_t reserved:1;
1701 uint32_t reserved1:4;
1703 uint32_t next_proto:8;
1708 /** Default mask for RTE_FLOW_ITEM_TYPE_NSH. */
1710 static const struct rte_flow_item_nsh rte_flow_item_nsh_mask = {
1720 * @b EXPERIMENTAL: this structure may change without prior notice
1722 * RTE_FLOW_ITEM_TYPE_IGMP
1724 * Match Internet Group Management Protocol (IGMP), RFC 2236
1727 struct rte_flow_item_igmp {
1729 uint32_t max_resp_time:8;
1730 uint32_t checksum:16;
1731 uint32_t group_addr;
1734 /** Default mask for RTE_FLOW_ITEM_TYPE_IGMP. */
1736 static const struct rte_flow_item_igmp rte_flow_item_igmp_mask = {
1737 .group_addr = 0xffffffff,
1743 * @b EXPERIMENTAL: this structure may change without prior notice
1745 * RTE_FLOW_ITEM_TYPE_AH
1747 * Match IP Authentication Header (AH), RFC 4302
1750 struct rte_flow_item_ah {
1751 uint32_t next_hdr:8;
1752 uint32_t payload_len:8;
1753 uint32_t reserved:16;
1758 /** Default mask for RTE_FLOW_ITEM_TYPE_AH. */
1760 static const struct rte_flow_item_ah rte_flow_item_ah_mask = {
1767 * @b EXPERIMENTAL: this structure may change without prior notice
1769 * RTE_FLOW_ITEM_TYPE_PFCP
1773 struct rte_flow_item_pfcp {
1780 /** Default mask for RTE_FLOW_ITEM_TYPE_PFCP. */
1782 static const struct rte_flow_item_pfcp rte_flow_item_pfcp_mask = {
1784 .seid = RTE_BE64(UINT64_C(0xffffffffffffffff)),
1790 * @b EXPERIMENTAL: this structure may change without prior notice
1792 * RTE_FLOW_ITEM_TYPE_ECPRI
1794 * Match eCPRI Header
1796 struct rte_flow_item_ecpri {
1797 struct rte_ecpri_combined_msg_hdr hdr;
1800 /** Default mask for RTE_FLOW_ITEM_TYPE_ECPRI. */
1802 static const struct rte_flow_item_ecpri rte_flow_item_ecpri_mask = {
1812 * RTE_FLOW_ITEM_TYPE_GENEVE_OPT
1814 * Matches a GENEVE Variable Length Option
1816 struct rte_flow_item_geneve_opt {
1817 rte_be16_t option_class;
1818 uint8_t option_type;
1823 /** Default mask for RTE_FLOW_ITEM_TYPE_GENEVE_OPT. */
1825 static const struct rte_flow_item_geneve_opt
1826 rte_flow_item_geneve_opt_mask = {
1827 .option_type = 0xff,
1833 * @b EXPERIMENTAL: this structure may change without prior notice
1835 * RTE_FLOW_ITEM_TYPE_INTEGRITY
1837 * Match on packet integrity check result.
1839 struct rte_flow_item_integrity {
1840 /** Tunnel encapsulation level the item should apply to.
1841 * @see rte_flow_action_rss
1848 /** The packet is valid after passing all HW checks. */
1849 uint64_t packet_ok:1;
1850 /** L2 layer is valid after passing all HW checks. */
1852 /** L3 layer is valid after passing all HW checks. */
1854 /** L4 layer is valid after passing all HW checks. */
1856 /** L2 layer CRC is valid. */
1857 uint64_t l2_crc_ok:1;
1858 /** IPv4 layer checksum is valid. */
1859 uint64_t ipv4_csum_ok:1;
1860 /** L4 layer checksum is valid. */
1861 uint64_t l4_csum_ok:1;
1862 /** L3 length is smaller than frame length. */
1863 uint64_t l3_len_ok:1;
1864 uint64_t reserved:56;
1871 static const struct rte_flow_item_integrity
1872 rte_flow_item_integrity_mask = {
1879 * The packet is valid after conntrack checking.
1881 #define RTE_FLOW_CONNTRACK_PKT_STATE_VALID RTE_BIT32(0)
1883 * The state of the connection is changed.
1885 #define RTE_FLOW_CONNTRACK_PKT_STATE_CHANGED RTE_BIT32(1)
1887 * Error is detected on this packet for this connection and
1888 * an invalid state is set.
1890 #define RTE_FLOW_CONNTRACK_PKT_STATE_INVALID RTE_BIT32(2)
1892 * The HW connection tracking module is disabled.
1893 * It can be due to application command or an invalid state.
1895 #define RTE_FLOW_CONNTRACK_PKT_STATE_DISABLED RTE_BIT32(3)
1897 * The packet contains some bad field(s) and cannot continue
1898 * with the conntrack module checking.
1900 #define RTE_FLOW_CONNTRACK_PKT_STATE_BAD RTE_BIT32(4)
1904 * @b EXPERIMENTAL: this structure may change without prior notice
1906 * RTE_FLOW_ITEM_TYPE_CONNTRACK
1908 * Matches the state of a packet after it passed the connection tracking
1909 * examination. The state is a bitmap of one RTE_FLOW_CONNTRACK_PKT_STATE*
1910 * or a reasonable combination of these bits.
1912 struct rte_flow_item_conntrack {
1916 /** Default mask for RTE_FLOW_ITEM_TYPE_CONNTRACK. */
1918 static const struct rte_flow_item_conntrack rte_flow_item_conntrack_mask = {
1919 .flags = 0xffffffff,
1925 * @b EXPERIMENTAL: this structure may change without prior notice
1927 * Provides an ethdev port ID for use with the following items:
1928 * RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR,
1929 * RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT.
1931 struct rte_flow_item_ethdev {
1932 uint16_t port_id; /**< ethdev port ID */
1935 /** Default mask for items based on struct rte_flow_item_ethdev */
1937 static const struct rte_flow_item_ethdev rte_flow_item_ethdev_mask = {
1944 * @b EXPERIMENTAL: this structure may change without prior notice
1946 * RTE_FLOW_ITEM_TYPE_L2TPV2
1948 * Matches L2TPv2 Header
1950 struct rte_flow_item_l2tpv2 {
1951 struct rte_l2tpv2_combined_msg_hdr hdr;
1954 /** Default mask for RTE_FLOW_ITEM_TYPE_L2TPV2. */
1956 static const struct rte_flow_item_l2tpv2 rte_flow_item_l2tpv2_mask = {
1958 * flags and version bit mask
1959 * 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0
1960 * T L x x S x O P x x x x V V V V
1964 .flags_version = RTE_BE16(0xcb0f),
1972 * @b EXPERIMENTAL: this structure may change without prior notice
1974 * RTE_FLOW_ITEM_TYPE_PPP
1976 * Matches PPP Header
1978 struct rte_flow_item_ppp {
1979 struct rte_ppp_hdr hdr;
1982 /** Default mask for RTE_FLOW_ITEM_TYPE_PPP. */
1984 static const struct rte_flow_item_ppp rte_flow_item_ppp_mask = {
1988 .proto_id = RTE_BE16(0xffff),
1994 * Matching pattern item definition.
1996 * A pattern is formed by stacking items starting from the lowest protocol
1997 * layer to match. This stacking restriction does not apply to meta items
1998 * which can be placed anywhere in the stack without affecting the meaning
1999 * of the resulting pattern.
2001 * Patterns are terminated by END items.
2003 * The spec field should be a valid pointer to a structure of the related
2004 * item type. It may remain unspecified (NULL) in many cases to request
2005 * broad (nonspecific) matching. In such cases, last and mask must also be
2008 * Optionally, last can point to a structure of the same type to define an
2009 * inclusive range. This is mostly supported by integer and address fields,
2010 * may cause errors otherwise. Fields that do not support ranges must be set
2011 * to 0 or to the same value as the corresponding fields in spec.
2013 * Only the fields defined to nonzero values in the default masks (see
2014 * rte_flow_item_{name}_mask constants) are considered relevant by
2015 * default. This can be overridden by providing a mask structure of the
2016 * same type with applicable bits set to one. It can also be used to
2017 * partially filter out specific fields (e.g. as an alternate mean to match
2018 * ranges of IP addresses).
2020 * Mask is a simple bit-mask applied before interpreting the contents of
2021 * spec and last, which may yield unexpected results if not used
2022 * carefully. For example, if for an IPv4 address field, spec provides
2023 * 10.1.2.3, last provides 10.3.4.5 and mask provides 255.255.0.0, the
2024 * effective range becomes 10.1.0.0 to 10.3.255.255.
2026 struct rte_flow_item {
2027 enum rte_flow_item_type type; /**< Item type. */
2028 const void *spec; /**< Pointer to item specification structure. */
2029 const void *last; /**< Defines an inclusive range (spec to last). */
2030 const void *mask; /**< Bit-mask applied to spec and last. */
2035 * @b EXPERIMENTAL: this structure may change without prior notice
2037 * RTE_FLOW_ITEM_TYPE_FLEX
2039 * Matches a specified set of fields within the network protocol
2040 * header. Each field is presented as set of bits with specified width, and
2041 * bit offset from the header beginning.
2043 * The pattern is concatenation of bit fields configured at item creation
2044 * by rte_flow_flex_item_create(). At configuration the fields are presented
2045 * by sample_data array.
2047 * This type does not support ranges (struct rte_flow_item.last).
2049 struct rte_flow_item_flex {
2050 struct rte_flow_item_flex_handle *handle; /**< Opaque item handle. */
2051 uint32_t length; /**< Pattern length in bytes. */
2052 const uint8_t *pattern; /**< Combined bitfields pattern to match. */
2055 * Field bit offset calculation mode.
2057 enum rte_flow_item_flex_field_mode {
2059 * Dummy field, used for byte boundary alignment in pattern.
2060 * Pattern mask and data are ignored in the match. All configuration
2061 * parameters besides field size are ignored.
2063 FIELD_MODE_DUMMY = 0,
2065 * Fixed offset field. The bit offset from header beginning
2066 * is permanent and defined by field_base parameter.
2070 * The field bit offset is extracted from other header field (indirect
2071 * offset field). The resulting field offset to match is calculated as:
2073 * field_base + (*offset_base & offset_mask) << offset_shift
2077 * The field bit offset is extracted from other header field (indirect
2078 * offset field), the latter is considered as bitmask containing some
2079 * number of one bits, the resulting field offset to match is
2082 * field_base + bitcount(*offset_base & offset_mask) << offset_shift
2088 * Flex item field tunnel mode
2090 enum rte_flow_item_flex_tunnel_mode {
2092 * The protocol header can be present in the packet only once.
2093 * No multiple flex item flow inclusions (for inner/outer) are allowed.
2094 * No any relations with tunnel protocols are imposed. The drivers
2095 * can optimize hardware resource usage to handle match on single flex
2096 * item of specific type.
2098 FLEX_TUNNEL_MODE_SINGLE = 0,
2100 * Flex item presents outer header only.
2102 FLEX_TUNNEL_MODE_OUTER,
2104 * Flex item presents inner header only.
2106 FLEX_TUNNEL_MODE_INNER,
2108 * Flex item presents either inner or outer header. The driver
2109 * handles as many multiple inners as hardware supports.
2111 FLEX_TUNNEL_MODE_MULTI,
2113 * Flex item presents tunnel protocol header.
2115 FLEX_TUNNEL_MODE_TUNNEL,
2121 * @b EXPERIMENTAL: this structure may change without prior notice
2124 struct rte_flow_item_flex_field {
2125 /** Defines how match field offset is calculated over the packet. */
2126 enum rte_flow_item_flex_field_mode field_mode;
2127 uint32_t field_size; /**< Field size in bits. */
2128 int32_t field_base; /**< Field offset in bits. */
2129 uint32_t offset_base; /**< Indirect offset field offset in bits. */
2130 uint32_t offset_mask; /**< Indirect offset field bit mask. */
2131 int32_t offset_shift; /**< Indirect offset multiply factor. */
2132 uint32_t field_id:16; /**< Device hint, for multiple items in flow. */
2133 uint32_t reserved:16; /**< Reserved field. */
2138 * @b EXPERIMENTAL: this structure may change without prior notice
2140 struct rte_flow_item_flex_link {
2142 * Preceding/following header. The item type must be always provided.
2143 * For preceding one item must specify the header value/mask to match
2144 * for the link be taken and start the flex item header parsing.
2146 struct rte_flow_item item;
2148 * Next field value to match to continue with one of the configured
2156 * @b EXPERIMENTAL: this structure may change without prior notice
2158 struct rte_flow_item_flex_conf {
2160 * Specifies the flex item and tunnel relations and tells the PMD
2161 * whether flex item can be used for inner, outer or both headers,
2162 * or whether flex item presents the tunnel protocol itself.
2164 enum rte_flow_item_flex_tunnel_mode tunnel;
2166 * The next header offset, it presents the network header size covered
2167 * by the flex item and can be obtained with all supported offset
2168 * calculating methods (fixed, dedicated field, bitmask, etc).
2170 struct rte_flow_item_flex_field next_header;
2172 * Specifies the next protocol field to match with link next protocol
2173 * values and continue packet parsing with matching link.
2175 struct rte_flow_item_flex_field next_protocol;
2177 * The fields will be sampled and presented for explicit match
2178 * with pattern in the rte_flow_flex_item. There can be multiple
2179 * fields descriptors, the number should be specified by nb_samples.
2181 struct rte_flow_item_flex_field *sample_data;
2182 /** Number of field descriptors in the sample_data array. */
2183 uint32_t nb_samples;
2185 * Input link defines the flex item relation with preceding
2186 * header. It specified the preceding item type and provides pattern
2187 * to match. The flex item will continue parsing and will provide the
2188 * data to flow match in case if there is the match with one of input
2191 struct rte_flow_item_flex_link *input_link;
2192 /** Number of link descriptors in the input link array. */
2195 * Output link defines the next protocol field value to match and
2196 * the following protocol header to continue packet parsing. Also
2197 * defines the tunnel-related behaviour.
2199 struct rte_flow_item_flex_link *output_link;
2200 /** Number of link descriptors in the output link array. */
2201 uint32_t nb_outputs;
2207 * Each possible action is represented by a type.
2208 * An action can have an associated configuration object.
2209 * Several actions combined in a list can be assigned
2210 * to a flow rule and are performed in order.
2212 * They fall in three categories:
2214 * - Actions that modify the fate of matching traffic, for instance by
2215 * dropping or assigning it a specific destination.
2217 * - Actions that modify matching traffic contents or its properties. This
2218 * includes adding/removing encapsulation, encryption, compression and
2221 * - Actions related to the flow rule itself, such as updating counters or
2222 * making it non-terminating.
2224 * Flow rules being terminating by default, not specifying any action of the
2225 * fate kind results in undefined behavior. This applies to both ingress and
2228 * PASSTHRU, when supported, makes a flow rule non-terminating.
2230 enum rte_flow_action_type {
2232 * End marker for action lists. Prevents further processing of
2233 * actions, thereby ending the list.
2235 * No associated configuration structure.
2237 RTE_FLOW_ACTION_TYPE_END,
2240 * Used as a placeholder for convenience. It is ignored and simply
2241 * discarded by PMDs.
2243 * No associated configuration structure.
2245 RTE_FLOW_ACTION_TYPE_VOID,
2248 * Leaves traffic up for additional processing by subsequent flow
2249 * rules; makes a flow rule non-terminating.
2251 * No associated configuration structure.
2253 RTE_FLOW_ACTION_TYPE_PASSTHRU,
2256 * RTE_FLOW_ACTION_TYPE_JUMP
2258 * Redirects packets to a group on the current device.
2260 * See struct rte_flow_action_jump.
2262 RTE_FLOW_ACTION_TYPE_JUMP,
2265 * Attaches an integer value to packets and sets RTE_MBUF_F_RX_FDIR and
2266 * RTE_MBUF_F_RX_FDIR_ID mbuf flags.
2268 * See struct rte_flow_action_mark.
2270 * One should negotiate mark delivery from the NIC to the PMD.
2271 * @see rte_eth_rx_metadata_negotiate()
2272 * @see RTE_ETH_RX_METADATA_USER_MARK
2274 RTE_FLOW_ACTION_TYPE_MARK,
2277 * Flags packets. Similar to MARK without a specific value; only
2278 * sets the RTE_MBUF_F_RX_FDIR mbuf flag.
2280 * No associated configuration structure.
2282 * One should negotiate flag delivery from the NIC to the PMD.
2283 * @see rte_eth_rx_metadata_negotiate()
2284 * @see RTE_ETH_RX_METADATA_USER_FLAG
2286 RTE_FLOW_ACTION_TYPE_FLAG,
2289 * Assigns packets to a given queue index.
2291 * See struct rte_flow_action_queue.
2293 RTE_FLOW_ACTION_TYPE_QUEUE,
2298 * PASSTHRU overrides this action if both are specified.
2300 * No associated configuration structure.
2302 RTE_FLOW_ACTION_TYPE_DROP,
2305 * Enables counters for this flow rule.
2307 * These counters can be retrieved and reset through rte_flow_query() or
2308 * rte_flow_action_handle_query() if the action provided via handle,
2309 * see struct rte_flow_query_count.
2311 * See struct rte_flow_action_count.
2313 RTE_FLOW_ACTION_TYPE_COUNT,
2316 * Similar to QUEUE, except RSS is additionally performed on packets
2317 * to spread them among several queues according to the provided
2320 * See struct rte_flow_action_rss.
2322 RTE_FLOW_ACTION_TYPE_RSS,
2326 * @see RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR
2327 * @see RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT
2329 * Directs matching traffic to the physical function (PF) of the
2332 * No associated configuration structure.
2334 RTE_FLOW_ACTION_TYPE_PF,
2338 * @see RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR
2339 * @see RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT
2341 * Directs matching traffic to a given virtual function of the
2344 * See struct rte_flow_action_vf.
2346 RTE_FLOW_ACTION_TYPE_VF,
2350 * @see RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR
2351 * @see RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT
2353 * Directs packets to a given physical port index of the underlying
2356 * See struct rte_flow_action_phy_port.
2358 RTE_FLOW_ACTION_TYPE_PHY_PORT,
2362 * @see RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR
2363 * @see RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT
2365 * Directs matching traffic to a given DPDK port ID.
2367 * See struct rte_flow_action_port_id.
2369 RTE_FLOW_ACTION_TYPE_PORT_ID,
2372 * Traffic metering and policing (MTR).
2374 * See struct rte_flow_action_meter.
2375 * See file rte_mtr.h for MTR object configuration.
2377 RTE_FLOW_ACTION_TYPE_METER,
2380 * Redirects packets to security engine of current device for security
2381 * processing as specified by security session.
2383 * See struct rte_flow_action_security.
2385 RTE_FLOW_ACTION_TYPE_SECURITY,
2389 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
2391 * Implements OFPAT_SET_MPLS_TTL ("MPLS TTL") as defined by the
2392 * OpenFlow Switch Specification.
2394 * See struct rte_flow_action_of_set_mpls_ttl.
2396 RTE_FLOW_ACTION_TYPE_OF_SET_MPLS_TTL,
2400 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
2402 * Implements OFPAT_DEC_MPLS_TTL ("decrement MPLS TTL") as defined
2403 * by the OpenFlow Switch Specification.
2405 * No associated configuration structure.
2407 RTE_FLOW_ACTION_TYPE_OF_DEC_MPLS_TTL,
2411 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
2413 * Implements OFPAT_SET_NW_TTL ("IP TTL") as defined by the OpenFlow
2414 * Switch Specification.
2416 * See struct rte_flow_action_of_set_nw_ttl.
2418 RTE_FLOW_ACTION_TYPE_OF_SET_NW_TTL,
2421 * @warning This is a legacy action.
2422 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
2424 * Implements OFPAT_DEC_NW_TTL ("decrement IP TTL") as defined by
2425 * the OpenFlow Switch Specification.
2427 * No associated configuration structure.
2429 RTE_FLOW_ACTION_TYPE_OF_DEC_NW_TTL,
2433 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
2435 * Implements OFPAT_COPY_TTL_OUT ("copy TTL "outwards" -- from
2436 * next-to-outermost to outermost") as defined by the OpenFlow
2437 * Switch Specification.
2439 * No associated configuration structure.
2441 RTE_FLOW_ACTION_TYPE_OF_COPY_TTL_OUT,
2445 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
2447 * Implements OFPAT_COPY_TTL_IN ("copy TTL "inwards" -- from
2448 * outermost to next-to-outermost") as defined by the OpenFlow
2449 * Switch Specification.
2451 * No associated configuration structure.
2453 RTE_FLOW_ACTION_TYPE_OF_COPY_TTL_IN,
2456 * Implements OFPAT_POP_VLAN ("pop the outer VLAN tag") as defined
2457 * by the OpenFlow Switch Specification.
2459 * No associated configuration structure.
2461 RTE_FLOW_ACTION_TYPE_OF_POP_VLAN,
2464 * Implements OFPAT_PUSH_VLAN ("push a new VLAN tag") as defined by
2465 * the OpenFlow Switch Specification.
2467 * See struct rte_flow_action_of_push_vlan.
2469 RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN,
2472 * Implements OFPAT_SET_VLAN_VID ("set the 802.1q VLAN ID") as
2473 * defined by the OpenFlow Switch Specification.
2475 * See struct rte_flow_action_of_set_vlan_vid.
2477 RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID,
2480 * Implements OFPAT_SET_LAN_PCP ("set the 802.1q priority") as
2481 * defined by the OpenFlow Switch Specification.
2483 * See struct rte_flow_action_of_set_vlan_pcp.
2485 RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP,
2488 * Implements OFPAT_POP_MPLS ("pop the outer MPLS tag") as defined
2489 * by the OpenFlow Switch Specification.
2491 * See struct rte_flow_action_of_pop_mpls.
2493 RTE_FLOW_ACTION_TYPE_OF_POP_MPLS,
2496 * Implements OFPAT_PUSH_MPLS ("push a new MPLS tag") as defined by
2497 * the OpenFlow Switch Specification.
2499 * See struct rte_flow_action_of_push_mpls.
2501 RTE_FLOW_ACTION_TYPE_OF_PUSH_MPLS,
2504 * Encapsulate flow in VXLAN tunnel as defined in
2505 * rte_flow_action_vxlan_encap action structure.
2507 * See struct rte_flow_action_vxlan_encap.
2509 RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP,
2512 * Decapsulate outer most VXLAN tunnel from matched flow.
2514 * If flow pattern does not define a valid VXLAN tunnel (as specified by
2515 * RFC7348) then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION
2518 RTE_FLOW_ACTION_TYPE_VXLAN_DECAP,
2521 * Encapsulate flow in NVGRE tunnel defined in the
2522 * rte_flow_action_nvgre_encap action structure.
2524 * See struct rte_flow_action_nvgre_encap.
2526 RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP,
2529 * Decapsulate outer most NVGRE tunnel from matched flow.
2531 * If flow pattern does not define a valid NVGRE tunnel (as specified by
2532 * RFC7637) then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION
2535 RTE_FLOW_ACTION_TYPE_NVGRE_DECAP,
2538 * Add outer header whose template is provided in its data buffer
2540 * See struct rte_flow_action_raw_encap.
2542 RTE_FLOW_ACTION_TYPE_RAW_ENCAP,
2545 * Remove outer header whose template is provided in its data buffer.
2547 * See struct rte_flow_action_raw_decap
2549 RTE_FLOW_ACTION_TYPE_RAW_DECAP,
2552 * @warning This is a legacy action.
2553 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
2555 * Modify IPv4 source address in the outermost IPv4 header.
2557 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV4,
2558 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2560 * See struct rte_flow_action_set_ipv4.
2562 RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC,
2565 * @warning This is a legacy action.
2566 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
2568 * Modify IPv4 destination address in the outermost IPv4 header.
2570 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV4,
2571 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2573 * See struct rte_flow_action_set_ipv4.
2575 RTE_FLOW_ACTION_TYPE_SET_IPV4_DST,
2578 * @warning This is a legacy action.
2579 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
2581 * Modify IPv6 source address in the outermost IPv6 header.
2583 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV6,
2584 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2586 * See struct rte_flow_action_set_ipv6.
2588 RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC,
2591 * @warning This is a legacy action.
2592 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
2594 * Modify IPv6 destination address in the outermost IPv6 header.
2596 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV6,
2597 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2599 * See struct rte_flow_action_set_ipv6.
2601 RTE_FLOW_ACTION_TYPE_SET_IPV6_DST,
2604 * @warning This is a legacy action.
2605 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
2607 * Modify source port number in the outermost TCP/UDP header.
2609 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_TCP
2610 * or RTE_FLOW_ITEM_TYPE_UDP, then the PMD should return a
2611 * RTE_FLOW_ERROR_TYPE_ACTION error.
2613 * See struct rte_flow_action_set_tp.
2615 RTE_FLOW_ACTION_TYPE_SET_TP_SRC,
2618 * @warning This is a legacy action.
2619 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
2621 * Modify destination port number in the outermost TCP/UDP header.
2623 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_TCP
2624 * or RTE_FLOW_ITEM_TYPE_UDP, then the PMD should return a
2625 * RTE_FLOW_ERROR_TYPE_ACTION error.
2627 * See struct rte_flow_action_set_tp.
2629 RTE_FLOW_ACTION_TYPE_SET_TP_DST,
2632 * Swap the source and destination MAC addresses in the outermost
2635 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_ETH,
2636 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2638 * No associated configuration structure.
2640 RTE_FLOW_ACTION_TYPE_MAC_SWAP,
2643 * @warning This is a legacy action.
2644 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
2646 * Decrease TTL value directly
2648 * No associated configuration structure.
2650 RTE_FLOW_ACTION_TYPE_DEC_TTL,
2653 * @warning This is a legacy action.
2654 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
2658 * See struct rte_flow_action_set_ttl
2660 RTE_FLOW_ACTION_TYPE_SET_TTL,
2663 * @warning This is a legacy action.
2664 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
2666 * Set source MAC address from matched flow.
2668 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_ETH,
2669 * the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2671 * See struct rte_flow_action_set_mac.
2673 RTE_FLOW_ACTION_TYPE_SET_MAC_SRC,
2676 * @warning This is a legacy action.
2677 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
2679 * Set destination MAC address from matched flow.
2681 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_ETH,
2682 * the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2684 * See struct rte_flow_action_set_mac.
2686 RTE_FLOW_ACTION_TYPE_SET_MAC_DST,
2689 * @warning This is a legacy action.
2690 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
2692 * Increase sequence number in the outermost TCP header.
2694 * Action configuration specifies the value to increase
2695 * TCP sequence number as a big-endian 32 bit integer.
2698 * @code rte_be32_t * @endcode
2700 * Using this action on non-matching traffic will result in
2701 * undefined behavior.
2703 RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ,
2706 * @warning This is a legacy action.
2707 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
2709 * Decrease sequence number in the outermost TCP header.
2711 * Action configuration specifies the value to decrease
2712 * TCP sequence number as a big-endian 32 bit integer.
2715 * @code rte_be32_t * @endcode
2717 * Using this action on non-matching traffic will result in
2718 * undefined behavior.
2720 RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ,
2723 * @warning This is a legacy action.
2724 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
2726 * Increase acknowledgment number in the outermost TCP header.
2728 * Action configuration specifies the value to increase
2729 * TCP acknowledgment number as a big-endian 32 bit integer.
2732 * @code rte_be32_t * @endcode
2734 * Using this action on non-matching traffic will result in
2735 * undefined behavior.
2737 RTE_FLOW_ACTION_TYPE_INC_TCP_ACK,
2740 * @warning This is a legacy action.
2741 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
2743 * Decrease acknowledgment number in the outermost TCP header.
2745 * Action configuration specifies the value to decrease
2746 * TCP acknowledgment number as a big-endian 32 bit integer.
2749 * @code rte_be32_t * @endcode
2751 * Using this action on non-matching traffic will result in
2752 * undefined behavior.
2754 RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK,
2757 * @warning This is a legacy action.
2758 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
2762 * Tag is for internal flow usage only and
2763 * is not delivered to the application.
2765 * See struct rte_flow_action_set_tag.
2767 RTE_FLOW_ACTION_TYPE_SET_TAG,
2770 * @warning This is a legacy action.
2771 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
2773 * Set metadata on ingress or egress path.
2775 * See struct rte_flow_action_set_meta.
2777 RTE_FLOW_ACTION_TYPE_SET_META,
2780 * @warning This is a legacy action.
2781 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
2783 * Modify IPv4 DSCP in the outermost IP header.
2785 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV4,
2786 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2788 * See struct rte_flow_action_set_dscp.
2790 RTE_FLOW_ACTION_TYPE_SET_IPV4_DSCP,
2793 * @warning This is a legacy action.
2794 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
2796 * Modify IPv6 DSCP in the outermost IP header.
2798 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV6,
2799 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2801 * See struct rte_flow_action_set_dscp.
2803 RTE_FLOW_ACTION_TYPE_SET_IPV6_DSCP,
2806 * Report as aged flow if timeout passed without any matching on the
2809 * See struct rte_flow_action_age.
2810 * See function rte_flow_get_aged_flows
2811 * see enum RTE_ETH_EVENT_FLOW_AGED
2812 * See struct rte_flow_query_age
2814 RTE_FLOW_ACTION_TYPE_AGE,
2817 * The matching packets will be duplicated with specified ratio and
2818 * applied with own set of actions with a fate action.
2820 * See struct rte_flow_action_sample.
2822 RTE_FLOW_ACTION_TYPE_SAMPLE,
2826 * @see RTE_FLOW_ACTION_TYPE_INDIRECT
2828 * Describe action shared across multiple flow rules.
2830 * Allow multiple rules reference the same action by handle (see
2831 * struct rte_flow_shared_action).
2833 RTE_FLOW_ACTION_TYPE_SHARED,
2836 * Modify a packet header field, tag, mark or metadata.
2838 * Allow the modification of an arbitrary header field via
2839 * set, add and sub operations or copying its content into
2840 * tag, meta or mark for future processing.
2842 * See struct rte_flow_action_modify_field.
2844 RTE_FLOW_ACTION_TYPE_MODIFY_FIELD,
2847 * An action handle is referenced in a rule through an indirect action.
2849 * The same action handle may be used in multiple rules for the same
2850 * or different ethdev ports.
2852 RTE_FLOW_ACTION_TYPE_INDIRECT,
2857 * Enable tracking a TCP connection state.
2859 * @see struct rte_flow_action_conntrack.
2861 RTE_FLOW_ACTION_TYPE_CONNTRACK,
2864 * Color the packet to reflect the meter color result.
2865 * Set the meter color in the mbuf to the selected color.
2867 * See struct rte_flow_action_meter_color.
2869 RTE_FLOW_ACTION_TYPE_METER_COLOR,
2872 * At embedded switch level, sends matching traffic to the given ethdev.
2874 * @see struct rte_flow_action_ethdev
2876 RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR,
2879 * At embedded switch level, send matching traffic to
2880 * the entity represented by the given ethdev.
2882 * @see struct rte_flow_action_ethdev
2884 RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT,
2888 * RTE_FLOW_ACTION_TYPE_MARK
2890 * Attaches an integer value to packets and sets RTE_MBUF_F_RX_FDIR and
2891 * RTE_MBUF_F_RX_FDIR_ID mbuf flags.
2893 * This value is arbitrary and application-defined. Maximum allowed value
2894 * depends on the underlying implementation. It is returned in the
2895 * hash.fdir.hi mbuf field.
2897 struct rte_flow_action_mark {
2898 uint32_t id; /**< Integer value to return with packets. */
2903 * @b EXPERIMENTAL: this structure may change without prior notice
2905 * RTE_FLOW_ACTION_TYPE_JUMP
2907 * Redirects packets to a group on the current device.
2909 * In a hierarchy of groups, which can be used to represent physical or logical
2910 * flow tables on the device, this action allows the action to be a redirect to
2911 * a group on that device.
2913 struct rte_flow_action_jump {
2918 * RTE_FLOW_ACTION_TYPE_QUEUE
2920 * Assign packets to a given queue index.
2922 struct rte_flow_action_queue {
2923 uint16_t index; /**< Queue index to use. */
2928 * @b EXPERIMENTAL: this structure may change without prior notice
2930 * RTE_FLOW_ACTION_TYPE_AGE
2932 * Report flow as aged-out if timeout passed without any matching
2933 * on the flow. RTE_ETH_EVENT_FLOW_AGED event is triggered when a
2934 * port detects new aged-out flows.
2936 * The flow context and the flow handle will be reported by the
2937 * rte_flow_get_aged_flows API.
2939 struct rte_flow_action_age {
2940 uint32_t timeout:24; /**< Time in seconds. */
2941 uint32_t reserved:8; /**< Reserved, must be zero. */
2942 /** The user flow context, NULL means the rte_flow pointer. */
2947 * RTE_FLOW_ACTION_TYPE_AGE (query)
2949 * Query structure to retrieve the aging status information of a
2950 * shared AGE action, or a flow rule using the AGE action.
2952 struct rte_flow_query_age {
2953 uint32_t reserved:6; /**< Reserved, must be zero. */
2954 uint32_t aged:1; /**< 1 if aging timeout expired, 0 otherwise. */
2955 /** sec_since_last_hit value is valid. */
2956 uint32_t sec_since_last_hit_valid:1;
2957 uint32_t sec_since_last_hit:24; /**< Seconds since last traffic hit. */
2962 * @b EXPERIMENTAL: this structure may change without prior notice
2964 * RTE_FLOW_ACTION_TYPE_COUNT
2966 * Adds a counter action to a matched flow.
2968 * If more than one count action is specified in a single flow rule, then each
2969 * action must specify a unique ID.
2971 * Counters can be retrieved and reset through ``rte_flow_query()``, see
2972 * ``struct rte_flow_query_count``.
2974 * For ports within the same switch domain then the counter ID namespace extends
2975 * to all ports within that switch domain.
2977 struct rte_flow_action_count {
2978 uint32_t id; /**< Counter ID. */
2982 * RTE_FLOW_ACTION_TYPE_COUNT (query)
2984 * Query structure to retrieve and reset flow rule counters.
2986 struct rte_flow_query_count {
2987 uint32_t reset:1; /**< Reset counters after query [in]. */
2988 uint32_t hits_set:1; /**< hits field is set [out]. */
2989 uint32_t bytes_set:1; /**< bytes field is set [out]. */
2990 uint32_t reserved:29; /**< Reserved, must be zero [in, out]. */
2991 uint64_t hits; /**< Number of hits for this rule [out]. */
2992 uint64_t bytes; /**< Number of bytes through this rule [out]. */
2996 * Hash function types.
2998 enum rte_eth_hash_function {
2999 RTE_ETH_HASH_FUNCTION_DEFAULT = 0,
3000 RTE_ETH_HASH_FUNCTION_TOEPLITZ, /**< Toeplitz */
3001 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR, /**< Simple XOR */
3003 * Symmetric Toeplitz: src, dst will be replaced by
3004 * xor(src, dst). For the case with src/dst only,
3005 * src or dst address will xor with zero pair.
3007 RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ,
3008 RTE_ETH_HASH_FUNCTION_MAX,
3012 * RTE_FLOW_ACTION_TYPE_RSS
3014 * Similar to QUEUE, except RSS is additionally performed on packets to
3015 * spread them among several queues according to the provided parameters.
3017 * Unlike global RSS settings used by other DPDK APIs, unsetting the
3018 * @p types field does not disable RSS in a flow rule. Doing so instead
3019 * requests safe unspecified "best-effort" settings from the underlying PMD,
3020 * which depending on the flow rule, may result in anything ranging from
3021 * empty (single queue) to all-inclusive RSS.
3023 * Note: RSS hash result is stored in the hash.rss mbuf field which overlaps
3024 * hash.fdir.lo. Since the MARK action sets the hash.fdir.hi field only,
3025 * both can be requested simultaneously.
3027 struct rte_flow_action_rss {
3028 enum rte_eth_hash_function func; /**< RSS hash function to apply. */
3030 * Packet encapsulation level RSS hash @p types apply to.
3032 * - @p 0 requests the default behavior. Depending on the packet
3033 * type, it can mean outermost, innermost, anything in between or
3036 * It basically stands for the innermost encapsulation level RSS
3037 * can be performed on according to PMD and device capabilities.
3039 * - @p 1 requests RSS to be performed on the outermost packet
3040 * encapsulation level.
3042 * - @p 2 and subsequent values request RSS to be performed on the
3043 * specified inner packet encapsulation level, from outermost to
3044 * innermost (lower to higher values).
3046 * Values other than @p 0 are not necessarily supported.
3048 * Requesting a specific RSS level on unrecognized traffic results
3049 * in undefined behavior. For predictable results, it is recommended
3050 * to make the flow rule pattern match packet headers up to the
3051 * requested encapsulation level so that only matching traffic goes
3055 uint64_t types; /**< Specific RSS hash types (see RTE_ETH_RSS_*). */
3056 uint32_t key_len; /**< Hash key length in bytes. */
3057 uint32_t queue_num; /**< Number of entries in @p queue. */
3058 const uint8_t *key; /**< Hash key. */
3059 const uint16_t *queue; /**< Queue indices to use. */
3064 * @see RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR
3065 * @see RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT
3067 * RTE_FLOW_ACTION_TYPE_VF
3069 * Directs matching traffic to a given virtual function of the current
3072 * Packets matched by a VF pattern item can be redirected to their original
3073 * VF ID instead of the specified one. This parameter may not be available
3074 * and is not guaranteed to work properly if the VF part is matched by a
3075 * prior flow rule or if packets are not addressed to a VF in the first
3078 struct rte_flow_action_vf {
3079 uint32_t original:1; /**< Use original VF ID if possible. */
3080 uint32_t reserved:31; /**< Reserved, must be zero. */
3081 uint32_t id; /**< VF ID. */
3086 * @see RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR
3087 * @see RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT
3089 * RTE_FLOW_ACTION_TYPE_PHY_PORT
3091 * Directs packets to a given physical port index of the underlying
3094 * @see RTE_FLOW_ITEM_TYPE_PHY_PORT
3096 struct rte_flow_action_phy_port {
3097 uint32_t original:1; /**< Use original port index if possible. */
3098 uint32_t reserved:31; /**< Reserved, must be zero. */
3099 uint32_t index; /**< Physical port index. */
3104 * @see RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR
3105 * @see RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT
3107 * RTE_FLOW_ACTION_TYPE_PORT_ID
3109 * Directs matching traffic to a given DPDK port ID.
3111 * @see RTE_FLOW_ITEM_TYPE_PORT_ID
3113 struct rte_flow_action_port_id {
3114 uint32_t original:1; /**< Use original DPDK port ID if possible. */
3115 uint32_t reserved:31; /**< Reserved, must be zero. */
3116 uint32_t id; /**< DPDK port ID. */
3120 * RTE_FLOW_ACTION_TYPE_METER
3122 * Traffic metering and policing (MTR).
3124 * Packets matched by items of this type can be either dropped or passed to the
3125 * next item with their color set by the MTR object.
3127 struct rte_flow_action_meter {
3128 uint32_t mtr_id; /**< MTR object ID created with rte_mtr_create(). */
3132 * RTE_FLOW_ACTION_TYPE_SECURITY
3134 * Perform the security action on flows matched by the pattern items
3135 * according to the configuration of the security session.
3137 * This action modifies the payload of matched flows. For INLINE_CRYPTO, the
3138 * security protocol headers and IV are fully provided by the application as
3139 * specified in the flow pattern. The payload of matching packets is
3140 * encrypted on egress, and decrypted and authenticated on ingress.
3141 * For INLINE_PROTOCOL, the security protocol is fully offloaded to HW,
3142 * providing full encapsulation and decapsulation of packets in security
3143 * protocols. The flow pattern specifies both the outer security header fields
3144 * and the inner packet fields. The security session specified in the action
3145 * must match the pattern parameters.
3147 * The security session specified in the action must be created on the same
3148 * port as the flow action that is being specified.
3150 * The ingress/egress flow attribute should match that specified in the
3151 * security session if the security session supports the definition of the
3154 * Multiple flows can be configured to use the same security session.
3156 * The NULL value is allowed for security session. If security session is NULL,
3157 * then SPI field in ESP flow item and IP addresses in flow items 'IPv4' and
3158 * 'IPv6' will be allowed to be a range. The rule thus created can enable
3159 * security processing on multiple flows.
3161 struct rte_flow_action_security {
3162 void *security_session; /**< Pointer to security session structure. */
3167 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
3169 * RTE_FLOW_ACTION_TYPE_OF_SET_MPLS_TTL
3171 * Implements OFPAT_SET_MPLS_TTL ("MPLS TTL") as defined by the OpenFlow
3172 * Switch Specification.
3174 struct rte_flow_action_of_set_mpls_ttl {
3175 uint8_t mpls_ttl; /**< MPLS TTL. */
3180 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
3182 * RTE_FLOW_ACTION_TYPE_OF_SET_NW_TTL
3184 * Implements OFPAT_SET_NW_TTL ("IP TTL") as defined by the OpenFlow Switch
3187 struct rte_flow_action_of_set_nw_ttl {
3188 uint8_t nw_ttl; /**< IP TTL. */
3192 * RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN
3194 * Implements OFPAT_PUSH_VLAN ("push a new VLAN tag") as defined by the
3195 * OpenFlow Switch Specification.
3197 struct rte_flow_action_of_push_vlan {
3198 rte_be16_t ethertype; /**< EtherType. */
3202 * RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID
3204 * Implements OFPAT_SET_VLAN_VID ("set the 802.1q VLAN ID") as defined by
3205 * the OpenFlow Switch Specification.
3207 struct rte_flow_action_of_set_vlan_vid {
3208 rte_be16_t vlan_vid; /**< VLAN ID. */
3212 * RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP
3214 * Implements OFPAT_SET_LAN_PCP ("set the 802.1q priority") as defined by
3215 * the OpenFlow Switch Specification.
3217 struct rte_flow_action_of_set_vlan_pcp {
3218 uint8_t vlan_pcp; /**< VLAN priority. */
3222 * RTE_FLOW_ACTION_TYPE_OF_POP_MPLS
3224 * Implements OFPAT_POP_MPLS ("pop the outer MPLS tag") as defined by the
3225 * OpenFlow Switch Specification.
3227 struct rte_flow_action_of_pop_mpls {
3228 rte_be16_t ethertype; /**< EtherType. */
3232 * RTE_FLOW_ACTION_TYPE_OF_PUSH_MPLS
3234 * Implements OFPAT_PUSH_MPLS ("push a new MPLS tag") as defined by the
3235 * OpenFlow Switch Specification.
3237 struct rte_flow_action_of_push_mpls {
3238 rte_be16_t ethertype; /**< EtherType. */
3243 * @b EXPERIMENTAL: this structure may change without prior notice
3245 * RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP
3247 * VXLAN tunnel end-point encapsulation data definition
3249 * The tunnel definition is provided through the flow item pattern, the
3250 * provided pattern must conform to RFC7348 for the tunnel specified. The flow
3251 * definition must be provided in order from the RTE_FLOW_ITEM_TYPE_ETH
3252 * definition up the end item which is specified by RTE_FLOW_ITEM_TYPE_END.
3254 * The mask field allows user to specify which fields in the flow item
3255 * definitions can be ignored and which have valid data and can be used
3258 * Note: the last field is not used in the definition of a tunnel and can be
3261 * Valid flow definition for RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP include:
3263 * - ETH / IPV4 / UDP / VXLAN / END
3264 * - ETH / IPV6 / UDP / VXLAN / END
3265 * - ETH / VLAN / IPV4 / UDP / VXLAN / END
3268 struct rte_flow_action_vxlan_encap {
3270 * Encapsulating vxlan tunnel definition
3271 * (terminated by the END pattern item).
3273 struct rte_flow_item *definition;
3278 * @b EXPERIMENTAL: this structure may change without prior notice
3280 * RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP
3282 * NVGRE tunnel end-point encapsulation data definition
3284 * The tunnel definition is provided through the flow item pattern the
3285 * provided pattern must conform with RFC7637. The flow definition must be
3286 * provided in order from the RTE_FLOW_ITEM_TYPE_ETH definition up the end item
3287 * which is specified by RTE_FLOW_ITEM_TYPE_END.
3289 * The mask field allows user to specify which fields in the flow item
3290 * definitions can be ignored and which have valid data and can be used
3293 * Note: the last field is not used in the definition of a tunnel and can be
3296 * Valid flow definition for RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP include:
3298 * - ETH / IPV4 / NVGRE / END
3299 * - ETH / VLAN / IPV6 / NVGRE / END
3302 struct rte_flow_action_nvgre_encap {
3304 * Encapsulating vxlan tunnel definition
3305 * (terminated by the END pattern item).
3307 struct rte_flow_item *definition;
3312 * @b EXPERIMENTAL: this structure may change without prior notice
3314 * RTE_FLOW_ACTION_TYPE_RAW_ENCAP
3316 * Raw tunnel end-point encapsulation data definition.
3318 * The data holds the headers definitions to be applied on the packet.
3319 * The data must start with ETH header up to the tunnel item header itself.
3320 * When used right after RAW_DECAP (for decapsulating L3 tunnel type for
3321 * example MPLSoGRE) the data will just hold layer 2 header.
3323 * The preserve parameter holds which bits in the packet the PMD is not allowed
3324 * to change, this parameter can also be NULL and then the PMD is allowed
3325 * to update any field.
3327 * size holds the number of bytes in @p data and @p preserve.
3329 struct rte_flow_action_raw_encap {
3330 uint8_t *data; /**< Encapsulation data. */
3331 uint8_t *preserve; /**< Bit-mask of @p data to preserve on output. */
3332 size_t size; /**< Size of @p data and @p preserve. */
3337 * @b EXPERIMENTAL: this structure may change without prior notice
3339 * RTE_FLOW_ACTION_TYPE_RAW_DECAP
3341 * Raw tunnel end-point decapsulation data definition.
3343 * The data holds the headers definitions to be removed from the packet.
3344 * The data must start with ETH header up to the tunnel item header itself.
3345 * When used right before RAW_DECAP (for encapsulating L3 tunnel type for
3346 * example MPLSoGRE) the data will just hold layer 2 header.
3348 * size holds the number of bytes in @p data.
3350 struct rte_flow_action_raw_decap {
3351 uint8_t *data; /**< Encapsulation data. */
3352 size_t size; /**< Size of @p data and @p preserve. */
3357 * @b EXPERIMENTAL: this structure may change without prior notice
3359 * RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC
3360 * RTE_FLOW_ACTION_TYPE_SET_IPV4_DST
3362 * Allows modification of IPv4 source (RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC)
3363 * and destination address (RTE_FLOW_ACTION_TYPE_SET_IPV4_DST) in the
3364 * specified outermost IPv4 header.
3366 struct rte_flow_action_set_ipv4 {
3367 rte_be32_t ipv4_addr;
3372 * @b EXPERIMENTAL: this structure may change without prior notice
3374 * RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC
3375 * RTE_FLOW_ACTION_TYPE_SET_IPV6_DST
3377 * Allows modification of IPv6 source (RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC)
3378 * and destination address (RTE_FLOW_ACTION_TYPE_SET_IPV6_DST) in the
3379 * specified outermost IPv6 header.
3381 struct rte_flow_action_set_ipv6 {
3382 uint8_t ipv6_addr[16];
3387 * @b EXPERIMENTAL: this structure may change without prior notice
3389 * RTE_FLOW_ACTION_TYPE_SET_TP_SRC
3390 * RTE_FLOW_ACTION_TYPE_SET_TP_DST
3392 * Allows modification of source (RTE_FLOW_ACTION_TYPE_SET_TP_SRC)
3393 * and destination (RTE_FLOW_ACTION_TYPE_SET_TP_DST) port numbers
3394 * in the specified outermost TCP/UDP header.
3396 struct rte_flow_action_set_tp {
3401 * RTE_FLOW_ACTION_TYPE_SET_TTL
3403 * Set the TTL value directly for IPv4 or IPv6
3405 struct rte_flow_action_set_ttl {
3410 * RTE_FLOW_ACTION_TYPE_SET_MAC
3412 * Set MAC address from the matched flow
3414 struct rte_flow_action_set_mac {
3415 uint8_t mac_addr[RTE_ETHER_ADDR_LEN];
3420 * @b EXPERIMENTAL: this structure may change without prior notice
3422 * RTE_FLOW_ACTION_TYPE_SET_TAG
3424 * Set a tag which is a transient data used during flow matching. This is not
3425 * delivered to application. Multiple tags are supported by specifying index.
3427 struct rte_flow_action_set_tag {
3435 * @b EXPERIMENTAL: this structure may change without prior notice
3437 * RTE_FLOW_ACTION_TYPE_SET_META
3439 * Set metadata. Metadata set by mbuf metadata dynamic field with
3440 * RTE_MBUF_DYNFLAG_TX_METADATA flag on egress will be overridden by this
3441 * action. On ingress, the metadata will be carried by mbuf metadata dynamic
3442 * field with RTE_MBUF_DYNFLAG_RX_METADATA flag if set. The dynamic mbuf field
3443 * must be registered in advance by rte_flow_dynf_metadata_register().
3445 * Altering partial bits is supported with mask. For bits which have never
3446 * been set, unpredictable value will be seen depending on driver
3447 * implementation. For loopback/hairpin packet, metadata set on Rx/Tx may
3448 * or may not be propagated to the other path depending on HW capability.
3450 * RTE_FLOW_ITEM_TYPE_META matches metadata.
3452 struct rte_flow_action_set_meta {
3458 * RTE_FLOW_ACTION_TYPE_SET_IPV4_DSCP
3459 * RTE_FLOW_ACTION_TYPE_SET_IPV6_DSCP
3461 * Set the DSCP value for IPv4/IPv6 header.
3462 * DSCP in low 6 bits, rest ignored.
3464 struct rte_flow_action_set_dscp {
3470 * @b EXPERIMENTAL: this structure may change without prior notice
3472 * RTE_FLOW_ACTION_TYPE_INDIRECT
3474 * Opaque type returned after successfully creating an indirect action object.
3475 * The definition of the object handle is different per driver or
3476 * per direct action type.
3478 * This handle can be used to manage and query the related direct action:
3479 * - referenced in single flow rule or across multiple flow rules
3480 * over multiple ports
3481 * - update action object configuration
3482 * - query action object data
3483 * - destroy action object
3485 struct rte_flow_action_handle;
3488 * The state of a TCP connection.
3490 enum rte_flow_conntrack_state {
3491 /** SYN-ACK packet was seen. */
3492 RTE_FLOW_CONNTRACK_STATE_SYN_RECV,
3493 /** 3-way handshake was done. */
3494 RTE_FLOW_CONNTRACK_STATE_ESTABLISHED,
3495 /** First FIN packet was received to close the connection. */
3496 RTE_FLOW_CONNTRACK_STATE_FIN_WAIT,
3497 /** First FIN was ACKed. */
3498 RTE_FLOW_CONNTRACK_STATE_CLOSE_WAIT,
3499 /** Second FIN was received, waiting for the last ACK. */
3500 RTE_FLOW_CONNTRACK_STATE_LAST_ACK,
3501 /** Second FIN was ACKed, connection was closed. */
3502 RTE_FLOW_CONNTRACK_STATE_TIME_WAIT,
3506 * The last passed TCP packet flags of a connection.
3508 enum rte_flow_conntrack_tcp_last_index {
3509 RTE_FLOW_CONNTRACK_FLAG_NONE = 0, /**< No Flag. */
3510 RTE_FLOW_CONNTRACK_FLAG_SYN = RTE_BIT32(0), /**< With SYN flag. */
3511 RTE_FLOW_CONNTRACK_FLAG_SYNACK = RTE_BIT32(1), /**< With SYNACK flag. */
3512 RTE_FLOW_CONNTRACK_FLAG_FIN = RTE_BIT32(2), /**< With FIN flag. */
3513 RTE_FLOW_CONNTRACK_FLAG_ACK = RTE_BIT32(3), /**< With ACK flag. */
3514 RTE_FLOW_CONNTRACK_FLAG_RST = RTE_BIT32(4), /**< With RST flag. */
3519 * @b EXPERIMENTAL: this structure may change without prior notice
3521 * Configuration parameters for each direction of a TCP connection.
3522 * All fields should be in host byte order.
3523 * If needed, driver should convert all fields to network byte order
3524 * if HW needs them in that way.
3526 struct rte_flow_tcp_dir_param {
3527 /** TCP window scaling factor, 0xF to disable. */
3529 /** The FIN was sent by this direction. */
3530 uint32_t close_initiated:1;
3531 /** An ACK packet has been received by this side. */
3532 uint32_t last_ack_seen:1;
3534 * If set, it indicates that there is unacknowledged data for the
3535 * packets sent from this direction.
3537 uint32_t data_unacked:1;
3539 * Maximal value of sequence + payload length in sent
3540 * packets (next ACK from the opposite direction).
3544 * Maximal value of (ACK + window size) in received packet + length
3545 * over sent packet (maximal sequence could be sent).
3548 /** Maximal value of actual window size in sent packets. */
3550 /** Maximal value of ACK in sent packets. */
3556 * @b EXPERIMENTAL: this structure may change without prior notice
3558 * RTE_FLOW_ACTION_TYPE_CONNTRACK
3560 * Configuration and initial state for the connection tracking module.
3561 * This structure could be used for both setting and query.
3562 * All fields should be in host byte order.
3564 struct rte_flow_action_conntrack {
3565 /** The peer port number, can be the same port. */
3568 * Direction of this connection when creating a flow rule, the
3569 * value only affects the creation of subsequent flow rules.
3571 uint32_t is_original_dir:1;
3573 * Enable / disable the conntrack HW module. When disabled, the
3574 * result will always be RTE_FLOW_CONNTRACK_FLAG_DISABLED.
3575 * In this state the HW will act as passthrough.
3576 * It only affects this conntrack object in the HW without any effect
3577 * to the other objects.
3580 /** At least one ack was seen after the connection was established. */
3581 uint32_t live_connection:1;
3582 /** Enable selective ACK on this connection. */
3583 uint32_t selective_ack:1;
3584 /** A challenge ack has passed. */
3585 uint32_t challenge_ack_passed:1;
3587 * 1: The last packet is seen from the original direction.
3588 * 0: The last packet is seen from the reply direction.
3590 uint32_t last_direction:1;
3591 /** No TCP check will be done except the state change. */
3592 uint32_t liberal_mode:1;
3593 /** The current state of this connection. */
3594 enum rte_flow_conntrack_state state;
3595 /** Scaling factor for maximal allowed ACK window. */
3596 uint8_t max_ack_window;
3597 /** Maximal allowed number of retransmission times. */
3598 uint8_t retransmission_limit;
3599 /** TCP parameters of the original direction. */
3600 struct rte_flow_tcp_dir_param original_dir;
3601 /** TCP parameters of the reply direction. */
3602 struct rte_flow_tcp_dir_param reply_dir;
3603 /** The window value of the last packet passed this conntrack. */
3604 uint16_t last_window;
3605 enum rte_flow_conntrack_tcp_last_index last_index;
3606 /** The sequence of the last packet passed this conntrack. */
3608 /** The acknowledgment of the last packet passed this conntrack. */
3611 * The total value ACK + payload length of the last packet
3612 * passed this conntrack.
3618 * RTE_FLOW_ACTION_TYPE_CONNTRACK
3620 * Wrapper structure for the context update interface.
3621 * Ports cannot support updating, and the only valid solution is to
3622 * destroy the old context and create a new one instead.
3624 struct rte_flow_modify_conntrack {
3625 /** New connection tracking parameters to be updated. */
3626 struct rte_flow_action_conntrack new_ct;
3627 /** The direction field will be updated. */
3628 uint32_t direction:1;
3629 /** All the other fields except direction will be updated. */
3631 /** Reserved bits for the future usage. */
3632 uint32_t reserved:30;
3637 * @b EXPERIMENTAL: this structure may change without prior notice
3639 * RTE_FLOW_ACTION_TYPE_METER_COLOR
3641 * The meter color should be set in the packet meta-data
3642 * (i.e. struct rte_mbuf::sched::color).
3644 struct rte_flow_action_meter_color {
3645 enum rte_color color; /**< Packet color. */
3650 * @b EXPERIMENTAL: this structure may change without prior notice
3652 * Provides an ethdev port ID for use with the following actions:
3653 * RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR,
3654 * RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT.
3656 struct rte_flow_action_ethdev {
3657 uint16_t port_id; /**< ethdev port ID */
3661 * Field IDs for MODIFY_FIELD action.
3663 enum rte_flow_field_id {
3664 RTE_FLOW_FIELD_START = 0, /**< Start of a packet. */
3665 RTE_FLOW_FIELD_MAC_DST, /**< Destination MAC Address. */
3666 RTE_FLOW_FIELD_MAC_SRC, /**< Source MAC Address. */
3667 RTE_FLOW_FIELD_VLAN_TYPE, /**< 802.1Q Tag Identifier. */
3668 RTE_FLOW_FIELD_VLAN_ID, /**< 802.1Q VLAN Identifier. */
3669 RTE_FLOW_FIELD_MAC_TYPE, /**< EtherType. */
3670 RTE_FLOW_FIELD_IPV4_DSCP, /**< IPv4 DSCP. */
3671 RTE_FLOW_FIELD_IPV4_TTL, /**< IPv4 Time To Live. */
3672 RTE_FLOW_FIELD_IPV4_SRC, /**< IPv4 Source Address. */
3673 RTE_FLOW_FIELD_IPV4_DST, /**< IPv4 Destination Address. */
3674 RTE_FLOW_FIELD_IPV6_DSCP, /**< IPv6 DSCP. */
3675 RTE_FLOW_FIELD_IPV6_HOPLIMIT, /**< IPv6 Hop Limit. */
3676 RTE_FLOW_FIELD_IPV6_SRC, /**< IPv6 Source Address. */
3677 RTE_FLOW_FIELD_IPV6_DST, /**< IPv6 Destination Address. */
3678 RTE_FLOW_FIELD_TCP_PORT_SRC, /**< TCP Source Port Number. */
3679 RTE_FLOW_FIELD_TCP_PORT_DST, /**< TCP Destination Port Number. */
3680 RTE_FLOW_FIELD_TCP_SEQ_NUM, /**< TCP Sequence Number. */
3681 RTE_FLOW_FIELD_TCP_ACK_NUM, /**< TCP Acknowledgment Number. */
3682 RTE_FLOW_FIELD_TCP_FLAGS, /**< TCP Flags. */
3683 RTE_FLOW_FIELD_UDP_PORT_SRC, /**< UDP Source Port Number. */
3684 RTE_FLOW_FIELD_UDP_PORT_DST, /**< UDP Destination Port Number. */
3685 RTE_FLOW_FIELD_VXLAN_VNI, /**< VXLAN Network Identifier. */
3686 RTE_FLOW_FIELD_GENEVE_VNI, /**< GENEVE Network Identifier. */
3687 RTE_FLOW_FIELD_GTP_TEID, /**< GTP Tunnel Endpoint Identifier. */
3688 RTE_FLOW_FIELD_TAG, /**< Tag value. */
3689 RTE_FLOW_FIELD_MARK, /**< Mark value. */
3690 RTE_FLOW_FIELD_META, /**< Metadata value. */
3691 RTE_FLOW_FIELD_POINTER, /**< Memory pointer. */
3692 RTE_FLOW_FIELD_VALUE, /**< Immediate value. */
3697 * @b EXPERIMENTAL: this structure may change without prior notice
3699 * Field description for MODIFY_FIELD action.
3701 struct rte_flow_action_modify_data {
3702 enum rte_flow_field_id field; /**< Field or memory type ID. */
3706 /** Encapsulation level or tag index. */
3708 /** Number of bits to skip from a field. */
3712 * Immediate value for RTE_FLOW_FIELD_VALUE, presented in the
3713 * same byte order and length as in relevant rte_flow_item_xxx.
3714 * The immediate source bitfield offset is inherited from
3715 * the destination's one.
3719 * Memory address for RTE_FLOW_FIELD_POINTER, memory layout
3720 * should be the same as for relevant field in the
3721 * rte_flow_item_xxx structure.
3728 * Operation types for MODIFY_FIELD action.
3730 enum rte_flow_modify_op {
3731 RTE_FLOW_MODIFY_SET = 0, /**< Set a new value. */
3732 RTE_FLOW_MODIFY_ADD, /**< Add a value to a field. */
3733 RTE_FLOW_MODIFY_SUB, /**< Subtract a value from a field. */
3738 * @b EXPERIMENTAL: this structure may change without prior notice
3740 * RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
3742 * Modify a destination header field according to the specified
3743 * operation. Another field of the packet can be used as a source as well
3744 * as tag, mark, metadata, immediate value or a pointer to it.
3746 struct rte_flow_action_modify_field {
3747 enum rte_flow_modify_op operation; /**< Operation to perform. */
3748 struct rte_flow_action_modify_data dst; /**< Destination field. */
3749 struct rte_flow_action_modify_data src; /**< Source field. */
3750 uint32_t width; /**< Number of bits to use from a source field. */
3753 /* Mbuf dynamic field offset for metadata. */
3754 extern int32_t rte_flow_dynf_metadata_offs;
3756 /* Mbuf dynamic field flag mask for metadata. */
3757 extern uint64_t rte_flow_dynf_metadata_mask;
3759 /* Mbuf dynamic field pointer for metadata. */
3760 #define RTE_FLOW_DYNF_METADATA(m) \
3761 RTE_MBUF_DYNFIELD((m), rte_flow_dynf_metadata_offs, uint32_t *)
3763 /* Mbuf dynamic flags for metadata. */
3764 #define RTE_MBUF_DYNFLAG_RX_METADATA (rte_flow_dynf_metadata_mask)
3765 #define PKT_RX_DYNF_METADATA RTE_DEPRECATED(PKT_RX_DYNF_METADATA) \
3766 RTE_MBUF_DYNFLAG_RX_METADATA
3767 #define RTE_MBUF_DYNFLAG_TX_METADATA (rte_flow_dynf_metadata_mask)
3768 #define PKT_TX_DYNF_METADATA RTE_DEPRECATED(PKT_TX_DYNF_METADATA) \
3769 RTE_MBUF_DYNFLAG_TX_METADATA
3772 static inline uint32_t
3773 rte_flow_dynf_metadata_get(struct rte_mbuf *m)
3775 return *RTE_FLOW_DYNF_METADATA(m);
3780 rte_flow_dynf_metadata_set(struct rte_mbuf *m, uint32_t v)
3782 *RTE_FLOW_DYNF_METADATA(m) = v;
3786 * Definition of a single action.
3788 * A list of actions is terminated by a END action.
3790 * For simple actions without a configuration object, conf remains NULL.
3792 struct rte_flow_action {
3793 enum rte_flow_action_type type; /**< Action type. */
3794 const void *conf; /**< Pointer to action configuration object. */
3798 * Opaque type returned after successfully creating a flow.
3800 * This handle can be used to manage and query the related flow (e.g. to
3801 * destroy it or retrieve counters).
3807 * @b EXPERIMENTAL: this structure may change without prior notice
3809 * RTE_FLOW_ACTION_TYPE_SAMPLE
3811 * Adds a sample action to a matched flow.
3813 * The matching packets will be duplicated with specified ratio and applied
3814 * with own set of actions with a fate action, the sampled packet could be
3815 * redirected to queue or port. All the packets continue processing on the
3816 * default flow path.
3818 * When the sample ratio is set to 1 then the packets will be 100% mirrored.
3819 * Additional action list be supported to add for sampled or mirrored packets.
3821 struct rte_flow_action_sample {
3822 uint32_t ratio; /**< packets sampled equals to '1/ratio'. */
3823 /** sub-action list specific for the sampling hit cases. */
3824 const struct rte_flow_action *actions;
3828 * Verbose error types.
3830 * Most of them provide the type of the object referenced by struct
3831 * rte_flow_error.cause.
3833 enum rte_flow_error_type {
3834 RTE_FLOW_ERROR_TYPE_NONE, /**< No error. */
3835 RTE_FLOW_ERROR_TYPE_UNSPECIFIED, /**< Cause unspecified. */
3836 RTE_FLOW_ERROR_TYPE_HANDLE, /**< Flow rule (handle). */
3837 RTE_FLOW_ERROR_TYPE_ATTR_GROUP, /**< Group field. */
3838 RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY, /**< Priority field. */
3839 RTE_FLOW_ERROR_TYPE_ATTR_INGRESS, /**< Ingress field. */
3840 RTE_FLOW_ERROR_TYPE_ATTR_EGRESS, /**< Egress field. */
3841 RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, /**< Transfer field. */
3842 RTE_FLOW_ERROR_TYPE_ATTR, /**< Attributes structure. */
3843 RTE_FLOW_ERROR_TYPE_ITEM_NUM, /**< Pattern length. */
3844 RTE_FLOW_ERROR_TYPE_ITEM_SPEC, /**< Item specification. */
3845 RTE_FLOW_ERROR_TYPE_ITEM_LAST, /**< Item specification range. */
3846 RTE_FLOW_ERROR_TYPE_ITEM_MASK, /**< Item specification mask. */
3847 RTE_FLOW_ERROR_TYPE_ITEM, /**< Specific pattern item. */
3848 RTE_FLOW_ERROR_TYPE_ACTION_NUM, /**< Number of actions. */
3849 RTE_FLOW_ERROR_TYPE_ACTION_CONF, /**< Action configuration. */
3850 RTE_FLOW_ERROR_TYPE_ACTION, /**< Specific action. */
3851 RTE_FLOW_ERROR_TYPE_STATE, /**< Current device state. */
3855 * Verbose error structure definition.
3857 * This object is normally allocated by applications and set by PMDs, the
3858 * message points to a constant string which does not need to be freed by
3859 * the application, however its pointer can be considered valid only as long
3860 * as its associated DPDK port remains configured. Closing the underlying
3861 * device or unloading the PMD invalidates it.
3863 * Both cause and message may be NULL regardless of the error type.
3865 struct rte_flow_error {
3866 enum rte_flow_error_type type; /**< Cause field and error types. */
3867 const void *cause; /**< Object responsible for the error. */
3868 const char *message; /**< Human-readable error message. */
3872 * Complete flow rule description.
3874 * This object type is used when converting a flow rule description.
3876 * @see RTE_FLOW_CONV_OP_RULE
3877 * @see rte_flow_conv()
3880 struct rte_flow_conv_rule {
3882 const struct rte_flow_attr *attr_ro; /**< RO attributes. */
3883 struct rte_flow_attr *attr; /**< Attributes. */
3886 const struct rte_flow_item *pattern_ro; /**< RO pattern. */
3887 struct rte_flow_item *pattern; /**< Pattern items. */
3890 const struct rte_flow_action *actions_ro; /**< RO actions. */
3891 struct rte_flow_action *actions; /**< List of actions. */
3896 * Conversion operations for flow API objects.
3898 * @see rte_flow_conv()
3900 enum rte_flow_conv_op {
3902 * No operation to perform.
3904 * rte_flow_conv() simply returns 0.
3906 RTE_FLOW_CONV_OP_NONE,
3909 * Convert attributes structure.
3911 * This is a basic copy of an attributes structure.
3914 * @code const struct rte_flow_attr * @endcode
3916 * @code struct rte_flow_attr * @endcode
3918 RTE_FLOW_CONV_OP_ATTR,
3921 * Convert a single item.
3923 * Duplicates @p spec, @p last and @p mask but not outside objects.
3926 * @code const struct rte_flow_item * @endcode
3928 * @code struct rte_flow_item * @endcode
3930 RTE_FLOW_CONV_OP_ITEM,
3933 * Convert a single action.
3935 * Duplicates @p conf but not outside objects.
3938 * @code const struct rte_flow_action * @endcode
3940 * @code struct rte_flow_action * @endcode
3942 RTE_FLOW_CONV_OP_ACTION,
3945 * Convert an entire pattern.
3947 * Duplicates all pattern items at once with the same constraints as
3948 * RTE_FLOW_CONV_OP_ITEM.
3951 * @code const struct rte_flow_item * @endcode
3953 * @code struct rte_flow_item * @endcode
3955 RTE_FLOW_CONV_OP_PATTERN,
3958 * Convert a list of actions.
3960 * Duplicates the entire list of actions at once with the same
3961 * constraints as RTE_FLOW_CONV_OP_ACTION.
3964 * @code const struct rte_flow_action * @endcode
3966 * @code struct rte_flow_action * @endcode
3968 RTE_FLOW_CONV_OP_ACTIONS,
3971 * Convert a complete flow rule description.
3973 * Comprises attributes, pattern and actions together at once with
3974 * the usual constraints.
3977 * @code const struct rte_flow_conv_rule * @endcode
3979 * @code struct rte_flow_conv_rule * @endcode
3981 RTE_FLOW_CONV_OP_RULE,
3984 * Convert item type to its name string.
3986 * Writes a NUL-terminated string to @p dst. Like snprintf(), the
3987 * returned value excludes the terminator which is always written
3991 * @code (const void *)enum rte_flow_item_type @endcode
3993 * @code char * @endcode
3995 RTE_FLOW_CONV_OP_ITEM_NAME,
3998 * Convert action type to its name string.
4000 * Writes a NUL-terminated string to @p dst. Like snprintf(), the
4001 * returned value excludes the terminator which is always written
4005 * @code (const void *)enum rte_flow_action_type @endcode
4007 * @code char * @endcode
4009 RTE_FLOW_CONV_OP_ACTION_NAME,
4012 * Convert item type to pointer to item name.
4014 * Retrieves item name pointer from its type. The string itself is
4015 * not copied; instead, a unique pointer to an internal static
4016 * constant storage is written to @p dst.
4019 * @code (const void *)enum rte_flow_item_type @endcode
4021 * @code const char ** @endcode
4023 RTE_FLOW_CONV_OP_ITEM_NAME_PTR,
4026 * Convert action type to pointer to action name.
4028 * Retrieves action name pointer from its type. The string itself is
4029 * not copied; instead, a unique pointer to an internal static
4030 * constant storage is written to @p dst.
4033 * @code (const void *)enum rte_flow_action_type @endcode
4035 * @code const char ** @endcode
4037 RTE_FLOW_CONV_OP_ACTION_NAME_PTR,
4042 * @b EXPERIMENTAL: this API may change without prior notice.
4044 * Dump hardware internal representation information of
4047 * @param[in] port_id
4048 * The port identifier of the Ethernet device.
4050 * The pointer of flow rule to dump. Dump all rules if NULL.
4052 * A pointer to a file for output.
4054 * Perform verbose error reporting if not NULL. PMDs initialize this
4055 * structure in case of error only.
4057 * 0 on success, a negative value otherwise.
4061 rte_flow_dev_dump(uint16_t port_id, struct rte_flow *flow,
4062 FILE *file, struct rte_flow_error *error);
4065 * Check if mbuf dynamic field for metadata is registered.
4068 * True if registered, false otherwise.
4072 rte_flow_dynf_metadata_avail(void)
4074 return !!rte_flow_dynf_metadata_mask;
4078 * Register mbuf dynamic field and flag for metadata.
4080 * This function must be called prior to use SET_META action in order to
4081 * register the dynamic mbuf field. Otherwise, the data cannot be delivered to
4085 * 0 on success, a negative errno value otherwise and rte_errno is set.
4089 rte_flow_dynf_metadata_register(void);
4092 * Check whether a flow rule can be created on a given port.
4094 * The flow rule is validated for correctness and whether it could be accepted
4095 * by the device given sufficient resources. The rule is checked against the
4096 * current device mode and queue configuration. The flow rule may also
4097 * optionally be validated against existing flow rules and device resources.
4098 * This function has no effect on the target device.
4100 * The returned value is guaranteed to remain valid only as long as no
4101 * successful calls to rte_flow_create() or rte_flow_destroy() are made in
4102 * the meantime and no device parameter affecting flow rules in any way are
4103 * modified, due to possible collisions or resource limitations (although in
4104 * such cases EINVAL should not be returned).
4107 * Port identifier of Ethernet device.
4109 * Flow rule attributes.
4110 * @param[in] pattern
4111 * Pattern specification (list terminated by the END pattern item).
4112 * @param[in] actions
4113 * Associated actions (list terminated by the END action).
4115 * Perform verbose error reporting if not NULL. PMDs initialize this
4116 * structure in case of error only.
4119 * 0 if flow rule is valid and can be created. A negative errno value
4120 * otherwise (rte_errno is also set), the following errors are defined:
4122 * -ENOSYS: underlying device does not support this functionality.
4124 * -EIO: underlying device is removed.
4126 * -EINVAL: unknown or invalid rule specification.
4128 * -ENOTSUP: valid but unsupported rule specification (e.g. partial
4129 * bit-masks are unsupported).
4131 * -EEXIST: collision with an existing rule. Only returned if device
4132 * supports flow rule collision checking and there was a flow rule
4133 * collision. Not receiving this return code is no guarantee that creating
4134 * the rule will not fail due to a collision.
4136 * -ENOMEM: not enough memory to execute the function, or if the device
4137 * supports resource validation, resource limitation on the device.
4139 * -EBUSY: action cannot be performed due to busy device resources, may
4140 * succeed if the affected queues or even the entire port are in a stopped
4141 * state (see rte_eth_dev_rx_queue_stop() and rte_eth_dev_stop()).
4144 rte_flow_validate(uint16_t port_id,
4145 const struct rte_flow_attr *attr,
4146 const struct rte_flow_item pattern[],
4147 const struct rte_flow_action actions[],
4148 struct rte_flow_error *error);
4151 * Create a flow rule on a given port.
4154 * Port identifier of Ethernet device.
4156 * Flow rule attributes.
4157 * @param[in] pattern
4158 * Pattern specification (list terminated by the END pattern item).
4159 * @param[in] actions
4160 * Associated actions (list terminated by the END action).
4162 * Perform verbose error reporting if not NULL. PMDs initialize this
4163 * structure in case of error only.
4166 * A valid handle in case of success, NULL otherwise and rte_errno is set
4167 * to the positive version of one of the error codes defined for
4168 * rte_flow_validate().
4171 rte_flow_create(uint16_t port_id,
4172 const struct rte_flow_attr *attr,
4173 const struct rte_flow_item pattern[],
4174 const struct rte_flow_action actions[],
4175 struct rte_flow_error *error);
4178 * Destroy a flow rule on a given port.
4180 * Failure to destroy a flow rule handle may occur when other flow rules
4181 * depend on it, and destroying it would result in an inconsistent state.
4183 * This function is only guaranteed to succeed if handles are destroyed in
4184 * reverse order of their creation.
4187 * Port identifier of Ethernet device.
4189 * Flow rule handle to destroy.
4191 * Perform verbose error reporting if not NULL. PMDs initialize this
4192 * structure in case of error only.
4195 * 0 on success, a negative errno value otherwise and rte_errno is set.
4198 rte_flow_destroy(uint16_t port_id,
4199 struct rte_flow *flow,
4200 struct rte_flow_error *error);
4203 * Destroy all flow rules associated with a port.
4205 * In the unlikely event of failure, handles are still considered destroyed
4206 * and no longer valid but the port must be assumed to be in an inconsistent
4210 * Port identifier of Ethernet device.
4212 * Perform verbose error reporting if not NULL. PMDs initialize this
4213 * structure in case of error only.
4216 * 0 on success, a negative errno value otherwise and rte_errno is set.
4219 rte_flow_flush(uint16_t port_id,
4220 struct rte_flow_error *error);
4223 * Query an existing flow rule.
4225 * This function allows retrieving flow-specific data such as counters.
4226 * Data is gathered by special actions which must be present in the flow
4229 * \see RTE_FLOW_ACTION_TYPE_COUNT
4232 * Port identifier of Ethernet device.
4234 * Flow rule handle to query.
4236 * Action definition as defined in original flow rule.
4237 * @param[in, out] data
4238 * Pointer to storage for the associated query data type.
4240 * Perform verbose error reporting if not NULL. PMDs initialize this
4241 * structure in case of error only.
4244 * 0 on success, a negative errno value otherwise and rte_errno is set.
4247 rte_flow_query(uint16_t port_id,
4248 struct rte_flow *flow,
4249 const struct rte_flow_action *action,
4251 struct rte_flow_error *error);
4254 * Restrict ingress traffic to the defined flow rules.
4256 * Isolated mode guarantees that all ingress traffic comes from defined flow
4257 * rules only (current and future).
4259 * Besides making ingress more deterministic, it allows PMDs to safely reuse
4260 * resources otherwise assigned to handle the remaining traffic, such as
4261 * global RSS configuration settings, VLAN filters, MAC address entries,
4262 * legacy filter API rules and so on in order to expand the set of possible
4265 * Calling this function as soon as possible after device initialization,
4266 * ideally before the first call to rte_eth_dev_configure(), is recommended
4267 * to avoid possible failures due to conflicting settings.
4269 * Once effective, leaving isolated mode may not be possible depending on
4270 * PMD implementation.
4272 * Additionally, the following functionality has no effect on the underlying
4273 * port and may return errors such as ENOTSUP ("not supported"):
4275 * - Toggling promiscuous mode.
4276 * - Toggling allmulticast mode.
4277 * - Configuring MAC addresses.
4278 * - Configuring multicast addresses.
4279 * - Configuring VLAN filters.
4280 * - Configuring Rx filters through the legacy API (e.g. FDIR).
4281 * - Configuring global RSS settings.
4284 * Port identifier of Ethernet device.
4286 * Nonzero to enter isolated mode, attempt to leave it otherwise.
4288 * Perform verbose error reporting if not NULL. PMDs initialize this
4289 * structure in case of error only.
4292 * 0 on success, a negative errno value otherwise and rte_errno is set.
4295 rte_flow_isolate(uint16_t port_id, int set, struct rte_flow_error *error);
4298 * Initialize flow error structure.
4301 * Pointer to flow error structure (may be NULL).
4303 * Related error code (rte_errno).
4305 * Cause field and error types.
4307 * Object responsible for the error.
4309 * Human-readable error message.
4312 * Negative error code (errno value) and rte_errno is set.
4315 rte_flow_error_set(struct rte_flow_error *error,
4317 enum rte_flow_error_type type,
4319 const char *message);
4323 * @see rte_flow_copy()
4325 struct rte_flow_desc {
4326 size_t size; /**< Allocated space including data[]. */
4327 struct rte_flow_attr attr; /**< Attributes. */
4328 struct rte_flow_item *items; /**< Items. */
4329 struct rte_flow_action *actions; /**< Actions. */
4330 uint8_t data[]; /**< Storage for items/actions. */
4335 * Copy an rte_flow rule description.
4337 * This interface is kept for compatibility with older applications but is
4338 * implemented as a wrapper to rte_flow_conv(). It is deprecated due to its
4339 * lack of flexibility and reliance on a type unusable with C++ programs
4340 * (struct rte_flow_desc).
4343 * Flow rule description.
4345 * Total size of allocated data for the flow description.
4347 * Flow rule attributes.
4349 * Pattern specification (list terminated by the END pattern item).
4350 * @param[in] actions
4351 * Associated actions (list terminated by the END action).
4354 * If len is greater or equal to the size of the flow, the total size of the
4355 * flow description and its data.
4356 * If len is lower than the size of the flow, the number of bytes that would
4357 * have been written to desc had it been sufficient. Nothing is written.
4361 rte_flow_copy(struct rte_flow_desc *fd, size_t len,
4362 const struct rte_flow_attr *attr,
4363 const struct rte_flow_item *items,
4364 const struct rte_flow_action *actions);
4367 * Flow object conversion helper.
4369 * This function performs conversion of various flow API objects to a
4370 * pre-allocated destination buffer. See enum rte_flow_conv_op for possible
4371 * operations and details about each of them.
4373 * Since destination buffer must be large enough, it works in a manner
4374 * reminiscent of snprintf():
4376 * - If @p size is 0, @p dst may be a NULL pointer, otherwise @p dst must be
4378 * - If positive, the returned value represents the number of bytes needed
4379 * to store the conversion of @p src to @p dst according to @p op
4380 * regardless of the @p size parameter.
4381 * - Since no more than @p size bytes can be written to @p dst, output is
4382 * truncated and may be inconsistent when the returned value is larger
4384 * - In case of conversion error, a negative error code is returned and
4385 * @p dst contents are unspecified.
4388 * Operation to perform, related to the object type of @p dst.
4390 * Destination buffer address. Must be suitably aligned by the caller.
4392 * Destination buffer size in bytes.
4394 * Source object to copy. Depending on @p op, its type may differ from
4397 * Perform verbose error reporting if not NULL. Initialized in case of
4401 * The number of bytes required to convert @p src to @p dst on success, a
4402 * negative errno value otherwise and rte_errno is set.
4404 * @see rte_flow_conv_op
4408 rte_flow_conv(enum rte_flow_conv_op op,
4412 struct rte_flow_error *error);
4415 * Get aged-out flows of a given port.
4417 * RTE_ETH_EVENT_FLOW_AGED event will be triggered when at least one new aged
4418 * out flow was detected after the last call to rte_flow_get_aged_flows.
4419 * This function can be called to get the aged flows asynchronously from the
4420 * event callback or synchronously regardless the event.
4421 * This is not safe to call rte_flow_get_aged_flows function with other flow
4422 * functions from multiple threads simultaneously.
4425 * Port identifier of Ethernet device.
4426 * @param[in, out] contexts
4427 * The address of an array of pointers to the aged-out flows contexts.
4428 * @param[in] nb_contexts
4429 * The length of context array pointers.
4431 * Perform verbose error reporting if not NULL. Initialized in case of
4435 * if nb_contexts is 0, return the amount of all aged contexts.
4436 * if nb_contexts is not 0 , return the amount of aged flows reported
4437 * in the context array, otherwise negative errno value.
4439 * @see rte_flow_action_age
4440 * @see RTE_ETH_EVENT_FLOW_AGED
4444 rte_flow_get_aged_flows(uint16_t port_id, void **contexts,
4445 uint32_t nb_contexts, struct rte_flow_error *error);
4448 * Specify indirect action object configuration
4450 struct rte_flow_indir_action_conf {
4452 * Flow direction for the indirect action configuration.
4454 * Action should be valid at least for one flow direction,
4455 * otherwise it is invalid for both ingress and egress rules.
4457 /** Action valid for rules applied to ingress traffic. */
4459 /** Action valid for rules applied to egress traffic. */
4462 * When set to 1, indicates that the action is valid for
4463 * transfer traffic; otherwise, for non-transfer traffic.
4465 uint32_t transfer:1;
4470 * @b EXPERIMENTAL: this API may change without prior notice.
4472 * Create an indirect action object that can be used in flow rules
4474 * The created object handle has single state and configuration
4475 * across all the flow rules using it.
4477 * @param[in] port_id
4478 * The port identifier of the Ethernet device.
4480 * Action configuration for the indirect action object creation.
4482 * Specific configuration of the indirect action object.
4484 * Perform verbose error reporting if not NULL. PMDs initialize this
4485 * structure in case of error only.
4487 * A valid handle in case of success, NULL otherwise and rte_errno is set
4488 * to one of the error codes defined:
4489 * - (ENODEV) if *port_id* invalid.
4490 * - (ENOSYS) if underlying device does not support this functionality.
4491 * - (EIO) if underlying device is removed.
4492 * - (EINVAL) if *action* invalid.
4493 * - (ENOTSUP) if *action* valid but unsupported.
4496 struct rte_flow_action_handle *
4497 rte_flow_action_handle_create(uint16_t port_id,
4498 const struct rte_flow_indir_action_conf *conf,
4499 const struct rte_flow_action *action,
4500 struct rte_flow_error *error);
4504 * @b EXPERIMENTAL: this API may change without prior notice.
4506 * Destroy indirect action by handle.
4508 * @param[in] port_id
4509 * The port identifier of the Ethernet device.
4511 * Handle for the indirect action object to be destroyed.
4513 * Perform verbose error reporting if not NULL. PMDs initialize this
4514 * structure in case of error only.
4517 * - (-ENODEV) if *port_id* invalid.
4518 * - (-ENOSYS) if underlying device does not support this functionality.
4519 * - (-EIO) if underlying device is removed.
4520 * - (-ENOENT) if action pointed by *action* handle was not found.
4521 * - (-EBUSY) if action pointed by *action* handle still used by some rules
4522 * rte_errno is also set.
4526 rte_flow_action_handle_destroy(uint16_t port_id,
4527 struct rte_flow_action_handle *handle,
4528 struct rte_flow_error *error);
4532 * @b EXPERIMENTAL: this API may change without prior notice.
4534 * Update in-place the action configuration and / or state pointed
4535 * by action *handle* with the configuration provided as *update* argument.
4536 * The update of the action configuration effects all flow rules reusing
4537 * the action via *handle*.
4538 * The update general pointer provides the ability of partial updating.
4540 * @param[in] port_id
4541 * The port identifier of the Ethernet device.
4543 * Handle for the indirect action object to be updated.
4545 * Update profile specification used to modify the action pointed by handle.
4546 * *update* could be with the same type of the immediate action corresponding
4547 * to the *handle* argument when creating, or a wrapper structure includes
4548 * action configuration to be updated and bit fields to indicate the member
4549 * of fields inside the action to update.
4551 * Perform verbose error reporting if not NULL. PMDs initialize this
4552 * structure in case of error only.
4555 * - (-ENODEV) if *port_id* invalid.
4556 * - (-ENOSYS) if underlying device does not support this functionality.
4557 * - (-EIO) if underlying device is removed.
4558 * - (-EINVAL) if *update* invalid.
4559 * - (-ENOTSUP) if *update* valid but unsupported.
4560 * - (-ENOENT) if indirect action object pointed by *handle* was not found.
4561 * rte_errno is also set.
4565 rte_flow_action_handle_update(uint16_t port_id,
4566 struct rte_flow_action_handle *handle,
4568 struct rte_flow_error *error);
4572 * @b EXPERIMENTAL: this API may change without prior notice.
4574 * Query the direct action by corresponding indirect action object handle.
4576 * Retrieve action-specific data such as counters.
4577 * Data is gathered by special action which may be present/referenced in
4578 * more than one flow rule definition.
4580 * @see RTE_FLOW_ACTION_TYPE_COUNT
4583 * Port identifier of Ethernet device.
4585 * Handle for the action object to query.
4586 * @param[in, out] data
4587 * Pointer to storage for the associated query data type.
4589 * Perform verbose error reporting if not NULL. PMDs initialize this
4590 * structure in case of error only.
4593 * 0 on success, a negative errno value otherwise and rte_errno is set.
4597 rte_flow_action_handle_query(uint16_t port_id,
4598 const struct rte_flow_action_handle *handle,
4599 void *data, struct rte_flow_error *error);
4601 /* Tunnel has a type and the key information. */
4602 struct rte_flow_tunnel {
4604 * Tunnel type, for example RTE_FLOW_ITEM_TYPE_VXLAN,
4605 * RTE_FLOW_ITEM_TYPE_NVGRE etc.
4607 enum rte_flow_item_type type;
4608 uint64_t tun_id; /**< Tunnel identification. */
4613 rte_be32_t src_addr; /**< IPv4 source address. */
4614 rte_be32_t dst_addr; /**< IPv4 destination address. */
4617 uint8_t src_addr[16]; /**< IPv6 source address. */
4618 uint8_t dst_addr[16]; /**< IPv6 destination address. */
4621 rte_be16_t tp_src; /**< Tunnel port source. */
4622 rte_be16_t tp_dst; /**< Tunnel port destination. */
4623 uint16_t tun_flags; /**< Tunnel flags. */
4625 bool is_ipv6; /**< True for valid IPv6 fields. Otherwise IPv4. */
4628 * the following members are required to restore packet
4631 uint8_t tos; /**< TOS for IPv4, TC for IPv6. */
4632 uint8_t ttl; /**< TTL for IPv4, HL for IPv6. */
4633 uint32_t label; /**< Flow Label for IPv6. */
4637 * Indicate that the packet has a tunnel.
4639 #define RTE_FLOW_RESTORE_INFO_TUNNEL RTE_BIT64(0)
4642 * Indicate that the packet has a non decapsulated tunnel header.
4644 #define RTE_FLOW_RESTORE_INFO_ENCAPSULATED RTE_BIT64(1)
4647 * Indicate that the packet has a group_id.
4649 #define RTE_FLOW_RESTORE_INFO_GROUP_ID RTE_BIT64(2)
4652 * Restore information structure to communicate the current packet processing
4653 * state when some of the processing pipeline is done in hardware and should
4654 * continue in software.
4656 struct rte_flow_restore_info {
4658 * Bitwise flags (RTE_FLOW_RESTORE_INFO_*) to indicate validation of
4659 * other fields in struct rte_flow_restore_info.
4662 uint32_t group_id; /**< Group ID where packed missed */
4663 struct rte_flow_tunnel tunnel; /**< Tunnel information. */
4667 * Allocate an array of actions to be used in rte_flow_create, to implement
4668 * tunnel-decap-set for the given tunnel.
4670 * actions vxlan_decap / tunnel-decap-set(tunnel properties) /
4671 * jump group 0 / end
4674 * Port identifier of Ethernet device.
4676 * Tunnel properties.
4677 * @param[out] actions
4678 * Array of actions to be allocated by the PMD. This array should be
4679 * concatenated with the actions array provided to rte_flow_create.
4680 * @param[out] num_of_actions
4681 * Number of actions allocated.
4683 * Perform verbose error reporting if not NULL. PMDs initialize this
4684 * structure in case of error only.
4687 * 0 on success, a negative errno value otherwise and rte_errno is set.
4691 rte_flow_tunnel_decap_set(uint16_t port_id,
4692 struct rte_flow_tunnel *tunnel,
4693 struct rte_flow_action **actions,
4694 uint32_t *num_of_actions,
4695 struct rte_flow_error *error);
4698 * Allocate an array of items to be used in rte_flow_create, to implement
4699 * tunnel-match for the given tunnel.
4701 * pattern tunnel-match(tunnel properties) / outer-header-matches /
4702 * inner-header-matches / end
4705 * Port identifier of Ethernet device.
4707 * Tunnel properties.
4709 * Array of items to be allocated by the PMD. This array should be
4710 * concatenated with the items array provided to rte_flow_create.
4711 * @param[out] num_of_items
4712 * Number of items allocated.
4714 * Perform verbose error reporting if not NULL. PMDs initialize this
4715 * structure in case of error only.
4718 * 0 on success, a negative errno value otherwise and rte_errno is set.
4722 rte_flow_tunnel_match(uint16_t port_id,
4723 struct rte_flow_tunnel *tunnel,
4724 struct rte_flow_item **items,
4725 uint32_t *num_of_items,
4726 struct rte_flow_error *error);
4729 * Populate the current packet processing state, if exists, for the given mbuf.
4731 * One should negotiate tunnel metadata delivery from the NIC to the HW.
4732 * @see rte_eth_rx_metadata_negotiate()
4733 * @see RTE_ETH_RX_METADATA_TUNNEL_ID
4736 * Port identifier of Ethernet device.
4740 * Restore information. Upon success contains the HW state.
4742 * Perform verbose error reporting if not NULL. PMDs initialize this
4743 * structure in case of error only.
4746 * 0 on success, a negative errno value otherwise and rte_errno is set.
4750 rte_flow_get_restore_info(uint16_t port_id,
4752 struct rte_flow_restore_info *info,
4753 struct rte_flow_error *error);
4756 * Release the action array as allocated by rte_flow_tunnel_decap_set.
4759 * Port identifier of Ethernet device.
4760 * @param[in] actions
4761 * Array of actions to be released.
4762 * @param[in] num_of_actions
4763 * Number of elements in actions array.
4765 * Perform verbose error reporting if not NULL. PMDs initialize this
4766 * structure in case of error only.
4769 * 0 on success, a negative errno value otherwise and rte_errno is set.
4773 rte_flow_tunnel_action_decap_release(uint16_t port_id,
4774 struct rte_flow_action *actions,
4775 uint32_t num_of_actions,
4776 struct rte_flow_error *error);
4779 * Release the item array as allocated by rte_flow_tunnel_match.
4782 * Port identifier of Ethernet device.
4784 * Array of items to be released.
4785 * @param[in] num_of_items
4786 * Number of elements in item array.
4788 * Perform verbose error reporting if not NULL. PMDs initialize this
4789 * structure in case of error only.
4792 * 0 on success, a negative errno value otherwise and rte_errno is set.
4796 rte_flow_tunnel_item_release(uint16_t port_id,
4797 struct rte_flow_item *items,
4798 uint32_t num_of_items,
4799 struct rte_flow_error *error);
4803 * @b EXPERIMENTAL: this API may change without prior notice.
4805 * Get a proxy port to manage "transfer" flows.
4807 * Managing "transfer" flows requires that the user communicate them
4808 * via a port which has the privilege to control the embedded switch.
4809 * For some vendors, all ports in a given switching domain have
4810 * this privilege. For other vendors, it's only one port.
4812 * This API indicates such a privileged port (a "proxy")
4813 * for a given port in the same switching domain.
4816 * If the PMD serving @p port_id doesn't have the corresponding method
4817 * implemented, the API will return @p port_id via @p proxy_port_id.
4820 * Indicates the port to get a "proxy" for
4821 * @param[out] proxy_port_id
4822 * Indicates the "proxy" port
4824 * If not NULL, allows the PMD to provide verbose report in case of error
4827 * 0 on success, a negative error code otherwise
4831 rte_flow_pick_transfer_proxy(uint16_t port_id, uint16_t *proxy_port_id,
4832 struct rte_flow_error *error);
4836 * @b EXPERIMENTAL: this API may change without prior notice.
4838 * Create the flex item with specified configuration over
4839 * the Ethernet device.
4842 * Port identifier of Ethernet device.
4844 * Item configuration.
4846 * Perform verbose error reporting if not NULL. PMDs initialize this
4847 * structure in case of error only.
4850 * Non-NULL opaque pointer on success, NULL otherwise and rte_errno is set.
4853 struct rte_flow_item_flex_handle *
4854 rte_flow_flex_item_create(uint16_t port_id,
4855 const struct rte_flow_item_flex_conf *conf,
4856 struct rte_flow_error *error);
4859 * Release the flex item on the specified Ethernet device.
4862 * Port identifier of Ethernet device.
4864 * Handle of the item existing on the specified device.
4866 * Perform verbose error reporting if not NULL. PMDs initialize this
4867 * structure in case of error only.
4870 * 0 on success, a negative errno value otherwise and rte_errno is set.
4874 rte_flow_flex_item_release(uint16_t port_id,
4875 const struct rte_flow_item_flex_handle *handle,
4876 struct rte_flow_error *error);
4880 * @b EXPERIMENTAL: this API may change without prior notice.
4882 * Information about flow engine resources.
4883 * The zero value means a resource is not supported.
4886 struct rte_flow_port_info {
4888 * Maximum number of queues for asynchronous operations.
4890 uint32_t max_nb_queues;
4892 * Maximum number of counters.
4893 * @see RTE_FLOW_ACTION_TYPE_COUNT
4895 uint32_t max_nb_counters;
4897 * Maximum number of aging objects.
4898 * @see RTE_FLOW_ACTION_TYPE_AGE
4900 uint32_t max_nb_aging_objects;
4902 * Maximum number traffic meters.
4903 * @see RTE_FLOW_ACTION_TYPE_METER
4905 uint32_t max_nb_meters;
4910 * @b EXPERIMENTAL: this API may change without prior notice.
4912 * Information about flow engine asynchronous queues.
4913 * The value only valid if @p port_attr.max_nb_queues is not zero.
4916 struct rte_flow_queue_info {
4918 * Maximum number of operations a queue can hold.
4925 * @b EXPERIMENTAL: this API may change without prior notice.
4927 * Get information about flow engine resources.
4930 * Port identifier of Ethernet device.
4931 * @param[out] port_info
4932 * A pointer to a structure of type *rte_flow_port_info*
4933 * to be filled with the resources information of the port.
4934 * @param[out] queue_info
4935 * A pointer to a structure of type *rte_flow_queue_info*
4936 * to be filled with the asynchronous queues information.
4938 * Perform verbose error reporting if not NULL.
4939 * PMDs initialize this structure in case of error only.
4942 * 0 on success, a negative errno value otherwise and rte_errno is set.
4946 rte_flow_info_get(uint16_t port_id,
4947 struct rte_flow_port_info *port_info,
4948 struct rte_flow_queue_info *queue_info,
4949 struct rte_flow_error *error);
4953 * @b EXPERIMENTAL: this API may change without prior notice.
4955 * Flow engine resources settings.
4956 * The zero value means on demand resource allocations only.
4959 struct rte_flow_port_attr {
4961 * Number of counters to configure.
4962 * @see RTE_FLOW_ACTION_TYPE_COUNT
4964 uint32_t nb_counters;
4966 * Number of aging objects to configure.
4967 * @see RTE_FLOW_ACTION_TYPE_AGE
4969 uint32_t nb_aging_objects;
4971 * Number of traffic meters to configure.
4972 * @see RTE_FLOW_ACTION_TYPE_METER
4979 * @b EXPERIMENTAL: this API may change without prior notice.
4981 * Flow engine asynchronous queues settings.
4982 * The value means default value picked by PMD.
4985 struct rte_flow_queue_attr {
4987 * Number of flow rule operations a queue can hold.
4994 * @b EXPERIMENTAL: this API may change without prior notice.
4996 * Configure the port's flow API engine.
4998 * This API can only be invoked before the application
4999 * starts using the rest of the flow library functions.
5001 * The API can be invoked multiple times to change the settings.
5002 * The port, however, may reject changes and keep the old config.
5004 * Parameters in configuration attributes must not exceed
5005 * numbers of resources returned by the rte_flow_info_get API.
5008 * Port identifier of Ethernet device.
5009 * @param[in] port_attr
5010 * Port configuration attributes.
5011 * @param[in] nb_queue
5012 * Number of flow queues to be configured.
5013 * @param[in] queue_attr
5014 * Array that holds attributes for each flow queue.
5015 * Number of elements is set in @p port_attr.nb_queues.
5017 * Perform verbose error reporting if not NULL.
5018 * PMDs initialize this structure in case of error only.
5021 * 0 on success, a negative errno value otherwise and rte_errno is set.
5025 rte_flow_configure(uint16_t port_id,
5026 const struct rte_flow_port_attr *port_attr,
5028 const struct rte_flow_queue_attr *queue_attr[],
5029 struct rte_flow_error *error);
5032 * Opaque type returned after successful creation of pattern template.
5033 * This handle can be used to manage the created pattern template.
5035 struct rte_flow_pattern_template;
5039 * @b EXPERIMENTAL: this API may change without prior notice.
5041 * Flow pattern template attributes.
5044 struct rte_flow_pattern_template_attr {
5046 * Relaxed matching policy.
5047 * - If 1, matching is performed only on items with the mask member set
5048 * and matching on protocol layers specified without any masks is skipped.
5049 * - If 0, matching on protocol layers specified without any masks is done
5050 * as well. This is the standard behaviour of Flow API now.
5052 uint32_t relaxed_matching:1;
5054 * Flow direction for the pattern template.
5055 * At least one direction must be specified.
5057 /** Pattern valid for rules applied to ingress traffic. */
5059 /** Pattern valid for rules applied to egress traffic. */
5061 /** Pattern valid for rules applied to transfer traffic. */
5062 uint32_t transfer:1;
5067 * @b EXPERIMENTAL: this API may change without prior notice.
5069 * Create flow pattern template.
5071 * The pattern template defines common matching fields without values.
5072 * For example, matching on 5 tuple TCP flow, the template will be
5073 * eth(null) + IPv4(source + dest) + TCP(s_port + d_port),
5074 * while values for each rule will be set during the flow rule creation.
5075 * The number and order of items in the template must be the same
5076 * at the rule creation.
5079 * Port identifier of Ethernet device.
5080 * @param[in] template_attr
5081 * Pattern template attributes.
5082 * @param[in] pattern
5083 * Pattern specification (list terminated by the END pattern item).
5084 * The spec member of an item is not used unless the end member is used.
5086 * Perform verbose error reporting if not NULL.
5087 * PMDs initialize this structure in case of error only.
5090 * Handle on success, NULL otherwise and rte_errno is set.
5093 struct rte_flow_pattern_template *
5094 rte_flow_pattern_template_create(uint16_t port_id,
5095 const struct rte_flow_pattern_template_attr *template_attr,
5096 const struct rte_flow_item pattern[],
5097 struct rte_flow_error *error);
5101 * @b EXPERIMENTAL: this API may change without prior notice.
5103 * Destroy flow pattern template.
5105 * This function may be called only when
5106 * there are no more tables referencing this template.
5109 * Port identifier of Ethernet device.
5110 * @param[in] pattern_template
5111 * Handle of the template to be destroyed.
5113 * Perform verbose error reporting if not NULL.
5114 * PMDs initialize this structure in case of error only.
5117 * 0 on success, a negative errno value otherwise and rte_errno is set.
5121 rte_flow_pattern_template_destroy(uint16_t port_id,
5122 struct rte_flow_pattern_template *pattern_template,
5123 struct rte_flow_error *error);
5126 * Opaque type returned after successful creation of actions template.
5127 * This handle can be used to manage the created actions template.
5129 struct rte_flow_actions_template;
5133 * @b EXPERIMENTAL: this API may change without prior notice.
5135 * Flow actions template attributes.
5138 struct rte_flow_actions_template_attr {
5140 * Flow direction for the actions template.
5141 * At least one direction must be specified.
5143 /** Action valid for rules applied to ingress traffic. */
5145 /** Action valid for rules applied to egress traffic. */
5147 /** Action valid for rules applied to transfer traffic. */
5148 uint32_t transfer:1;
5153 * @b EXPERIMENTAL: this API may change without prior notice.
5155 * Create flow actions template.
5157 * The actions template holds a list of action types without values.
5158 * For example, the template to change TCP ports is TCP(s_port + d_port),
5159 * while values for each rule will be set during the flow rule creation.
5160 * The number and order of actions in the template must be the same
5161 * at the rule creation.
5164 * Port identifier of Ethernet device.
5165 * @param[in] template_attr
5166 * Template attributes.
5167 * @param[in] actions
5168 * Associated actions (list terminated by the END action).
5169 * The spec member is only used if @p masks spec is non-zero.
5171 * List of actions that marks which of the action's member is constant.
5172 * A mask has the same format as the corresponding action.
5173 * If the action field in @p masks is not 0,
5174 * the corresponding value in an action from @p actions will be the part
5175 * of the template and used in all flow rules.
5176 * The order of actions in @p masks is the same as in @p actions.
5177 * In case of indirect actions present in @p actions,
5178 * the actual action type should be present in @p mask.
5180 * Perform verbose error reporting if not NULL.
5181 * PMDs initialize this structure in case of error only.
5184 * Handle on success, NULL otherwise and rte_errno is set.
5187 struct rte_flow_actions_template *
5188 rte_flow_actions_template_create(uint16_t port_id,
5189 const struct rte_flow_actions_template_attr *template_attr,
5190 const struct rte_flow_action actions[],
5191 const struct rte_flow_action masks[],
5192 struct rte_flow_error *error);
5196 * @b EXPERIMENTAL: this API may change without prior notice.
5198 * Destroy flow actions template.
5200 * This function may be called only when
5201 * there are no more tables referencing this template.
5204 * Port identifier of Ethernet device.
5205 * @param[in] actions_template
5206 * Handle to the template to be destroyed.
5208 * Perform verbose error reporting if not NULL.
5209 * PMDs initialize this structure in case of error only.
5212 * 0 on success, a negative errno value otherwise and rte_errno is set.
5216 rte_flow_actions_template_destroy(uint16_t port_id,
5217 struct rte_flow_actions_template *actions_template,
5218 struct rte_flow_error *error);
5221 * Opaque type returned after successful creation of a template table.
5222 * This handle can be used to manage the created template table.
5224 struct rte_flow_template_table;
5228 * @b EXPERIMENTAL: this API may change without prior notice.
5232 struct rte_flow_template_table_attr {
5234 * Flow attributes to be used in each rule generated from this table.
5236 struct rte_flow_attr flow_attr;
5238 * Maximum number of flow rules that this table holds.
5245 * @b EXPERIMENTAL: this API may change without prior notice.
5247 * Create flow template table.
5249 * A template table consists of multiple pattern templates and actions
5250 * templates associated with a single set of rule attributes (group ID,
5251 * priority and traffic direction).
5253 * Each rule is free to use any combination of pattern and actions templates
5254 * and specify particular values for items and actions it would like to change.
5257 * Port identifier of Ethernet device.
5258 * @param[in] table_attr
5259 * Template table attributes.
5260 * @param[in] pattern_templates
5261 * Array of pattern templates to be used in this table.
5262 * @param[in] nb_pattern_templates
5263 * The number of pattern templates in the pattern_templates array.
5264 * @param[in] actions_templates
5265 * Array of actions templates to be used in this table.
5266 * @param[in] nb_actions_templates
5267 * The number of actions templates in the actions_templates array.
5269 * Perform verbose error reporting if not NULL.
5270 * PMDs initialize this structure in case of error only.
5273 * Handle on success, NULL otherwise and rte_errno is set.
5276 struct rte_flow_template_table *
5277 rte_flow_template_table_create(uint16_t port_id,
5278 const struct rte_flow_template_table_attr *table_attr,
5279 struct rte_flow_pattern_template *pattern_templates[],
5280 uint8_t nb_pattern_templates,
5281 struct rte_flow_actions_template *actions_templates[],
5282 uint8_t nb_actions_templates,
5283 struct rte_flow_error *error);
5287 * @b EXPERIMENTAL: this API may change without prior notice.
5289 * Destroy flow template table.
5291 * This function may be called only when
5292 * there are no more flow rules referencing this table.
5295 * Port identifier of Ethernet device.
5296 * @param[in] template_table
5297 * Handle to the table to be destroyed.
5299 * Perform verbose error reporting if not NULL.
5300 * PMDs initialize this structure in case of error only.
5303 * 0 on success, a negative errno value otherwise and rte_errno is set.
5307 rte_flow_template_table_destroy(uint16_t port_id,
5308 struct rte_flow_template_table *template_table,
5309 struct rte_flow_error *error);
5313 * @b EXPERIMENTAL: this API may change without prior notice.
5315 * Asynchronous operation attributes.
5318 struct rte_flow_op_attr {
5320 * When set, the requested action will not be sent to the HW immediately.
5321 * The application must call the rte_flow_queue_push to actually send it.
5323 uint32_t postpone:1;
5328 * @b EXPERIMENTAL: this API may change without prior notice.
5330 * Enqueue rule creation operation.
5333 * Port identifier of Ethernet device.
5335 * Flow queue used to insert the rule.
5336 * @param[in] op_attr
5337 * Rule creation operation attributes.
5338 * @param[in] template_table
5339 * Template table to select templates from.
5340 * @param[in] pattern
5341 * List of pattern items to be used.
5342 * The list order should match the order in the pattern template.
5343 * The spec is the only relevant member of the item that is being used.
5344 * @param[in] pattern_template_index
5345 * Pattern template index in the table.
5346 * @param[in] actions
5347 * List of actions to be used.
5348 * The list order should match the order in the actions template.
5349 * @param[in] actions_template_index
5350 * Actions template index in the table.
5351 * @param[in] user_data
5352 * The user data that will be returned on the completion events.
5354 * Perform verbose error reporting if not NULL.
5355 * PMDs initialize this structure in case of error only.
5358 * Handle on success, NULL otherwise and rte_errno is set.
5359 * The rule handle doesn't mean that the rule has been populated.
5360 * Only completion result indicates that if there was success or failure.
5364 rte_flow_async_create(uint16_t port_id,
5366 const struct rte_flow_op_attr *op_attr,
5367 struct rte_flow_template_table *template_table,
5368 const struct rte_flow_item pattern[],
5369 uint8_t pattern_template_index,
5370 const struct rte_flow_action actions[],
5371 uint8_t actions_template_index,
5373 struct rte_flow_error *error);
5377 * @b EXPERIMENTAL: this API may change without prior notice.
5379 * Enqueue rule destruction operation.
5381 * This function enqueues a destruction operation on the queue.
5382 * Application should assume that after calling this function
5383 * the rule handle is not valid anymore.
5384 * Completion indicates the full removal of the rule from the HW.
5387 * Port identifier of Ethernet device.
5389 * Flow queue which is used to destroy the rule.
5390 * This must match the queue on which the rule was created.
5391 * @param[in] op_attr
5392 * Rule destruction operation attributes.
5394 * Flow handle to be destroyed.
5395 * @param[in] user_data
5396 * The user data that will be returned on the completion events.
5398 * Perform verbose error reporting if not NULL.
5399 * PMDs initialize this structure in case of error only.
5402 * 0 on success, a negative errno value otherwise and rte_errno is set.
5406 rte_flow_async_destroy(uint16_t port_id,
5408 const struct rte_flow_op_attr *op_attr,
5409 struct rte_flow *flow,
5411 struct rte_flow_error *error);
5415 * @b EXPERIMENTAL: this API may change without prior notice.
5417 * Push all internally stored rules to the HW.
5418 * Postponed rules are rules that were inserted with the postpone flag set.
5419 * Can be used to notify the HW about batch of rules prepared by the SW to
5420 * reduce the number of communications between the HW and SW.
5423 * Port identifier of Ethernet device.
5425 * Flow queue to be pushed.
5427 * Perform verbose error reporting if not NULL.
5428 * PMDs initialize this structure in case of error only.
5431 * 0 on success, a negative errno value otherwise and rte_errno is set.
5435 rte_flow_push(uint16_t port_id,
5437 struct rte_flow_error *error);
5441 * @b EXPERIMENTAL: this API may change without prior notice.
5443 * Asynchronous operation status.
5445 enum rte_flow_op_status {
5447 * The operation was completed successfully.
5449 RTE_FLOW_OP_SUCCESS,
5451 * The operation was not completed successfully.
5458 * @b EXPERIMENTAL: this API may change without prior notice.
5460 * Asynchronous operation result.
5463 struct rte_flow_op_result {
5465 * Returns the status of the operation that this completion signals.
5467 enum rte_flow_op_status status;
5469 * The user data that will be returned on the completion events.
5476 * @b EXPERIMENTAL: this API may change without prior notice.
5478 * Pull a rte flow operation.
5479 * The application must invoke this function in order to complete
5480 * the flow rule offloading and to retrieve the flow rule operation status.
5483 * Port identifier of Ethernet device.
5485 * Flow queue which is used to pull the operation.
5487 * Array of results that will be set.
5489 * Maximum number of results that can be returned.
5490 * This value is equal to the size of the res array.
5492 * Perform verbose error reporting if not NULL.
5493 * PMDs initialize this structure in case of error only.
5496 * Number of results that were pulled,
5497 * a negative errno value otherwise and rte_errno is set.
5501 rte_flow_pull(uint16_t port_id,
5503 struct rte_flow_op_result res[],
5505 struct rte_flow_error *error);
5509 * @b EXPERIMENTAL: this API may change without prior notice.
5511 * Enqueue indirect action creation operation.
5512 * @see rte_flow_action_handle_create
5514 * @param[in] port_id
5515 * Port identifier of Ethernet device.
5516 * @param[in] queue_id
5517 * Flow queue which is used to create the rule.
5518 * @param[in] op_attr
5519 * Indirect action creation operation attributes.
5520 * @param[in] indir_action_conf
5521 * Action configuration for the indirect action object creation.
5523 * Specific configuration of the indirect action object.
5524 * @param[in] user_data
5525 * The user data that will be returned on the completion events.
5527 * Perform verbose error reporting if not NULL.
5528 * PMDs initialize this structure in case of error only.
5531 * A valid handle in case of success, NULL otherwise and rte_errno is set.
5534 struct rte_flow_action_handle *
5535 rte_flow_async_action_handle_create(uint16_t port_id,
5537 const struct rte_flow_op_attr *op_attr,
5538 const struct rte_flow_indir_action_conf *indir_action_conf,
5539 const struct rte_flow_action *action,
5541 struct rte_flow_error *error);
5545 * @b EXPERIMENTAL: this API may change without prior notice.
5547 * Enqueue indirect action destruction operation.
5548 * The destroy queue must be the same
5549 * as the queue on which the action was created.
5551 * @param[in] port_id
5552 * Port identifier of Ethernet device.
5553 * @param[in] queue_id
5554 * Flow queue which is used to destroy the rule.
5555 * @param[in] op_attr
5556 * Indirect action destruction operation attributes.
5557 * @param[in] action_handle
5558 * Handle for the indirect action object to be destroyed.
5559 * @param[in] user_data
5560 * The user data that will be returned on the completion events.
5562 * Perform verbose error reporting if not NULL.
5563 * PMDs initialize this structure in case of error only.
5566 * 0 on success, a negative errno value otherwise and rte_errno is set.
5570 rte_flow_async_action_handle_destroy(uint16_t port_id,
5572 const struct rte_flow_op_attr *op_attr,
5573 struct rte_flow_action_handle *action_handle,
5575 struct rte_flow_error *error);
5579 * @b EXPERIMENTAL: this API may change without prior notice.
5581 * Enqueue indirect action update operation.
5582 * @see rte_flow_action_handle_create
5584 * @param[in] port_id
5585 * Port identifier of Ethernet device.
5586 * @param[in] queue_id
5587 * Flow queue which is used to update the rule.
5588 * @param[in] op_attr
5589 * Indirect action update operation attributes.
5590 * @param[in] action_handle
5591 * Handle for the indirect action object to be updated.
5593 * Update profile specification used to modify the action pointed by handle.
5594 * *update* could be with the same type of the immediate action corresponding
5595 * to the *handle* argument when creating, or a wrapper structure includes
5596 * action configuration to be updated and bit fields to indicate the member
5597 * of fields inside the action to update.
5598 * @param[in] user_data
5599 * The user data that will be returned on the completion events.
5601 * Perform verbose error reporting if not NULL.
5602 * PMDs initialize this structure in case of error only.
5605 * 0 on success, a negative errno value otherwise and rte_errno is set.
5609 rte_flow_async_action_handle_update(uint16_t port_id,
5611 const struct rte_flow_op_attr *op_attr,
5612 struct rte_flow_action_handle *action_handle,
5615 struct rte_flow_error *error);
5620 #endif /* RTE_FLOW_H_ */