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.
20 #include <rte_common.h>
21 #include <rte_ether.h>
27 #include <rte_vxlan.h>
29 #include <rte_higig.h>
30 #include <rte_ecpri.h>
31 #include <rte_bitops.h>
32 #include <rte_mbuf_dyn.h>
33 #include <rte_meter.h>
35 #include <rte_l2tpv2.h>
43 #define RTE_FLOW_LOG(level, ...) \
44 rte_log(RTE_LOG_ ## level, rte_eth_dev_logtype, "" __VA_ARGS__)
47 * Flow rule attributes.
49 * Priorities are set on a per rule based within groups.
51 * Lower values denote higher priority, the highest priority for a flow rule
52 * is 0, so that a flow that matches for than one rule, the rule with the
53 * lowest priority value will always be matched.
55 * Although optional, applications are encouraged to group similar rules as
56 * much as possible to fully take advantage of hardware capabilities
57 * (e.g. optimized matching) and work around limitations (e.g. a single
58 * pattern type possibly allowed in a given group). Applications should be
59 * aware that groups are not linked by default, and that they must be
60 * explicitly linked by the application using the JUMP action.
62 * Priority levels are arbitrary and up to the application, they
63 * do not need to be contiguous nor start from 0, however the maximum number
64 * varies between devices and may be affected by existing flow rules.
66 * If a packet is matched by several rules of a given group for a given
67 * priority level, the outcome is undefined. It can take any path, may be
68 * duplicated or even cause unrecoverable errors.
70 * Note that support for more than a single group and priority level is not
73 * At vNIC / ethdev level, flow rules can apply to inbound and / or outbound
74 * traffic (ingress / egress), with respect to the vNIC / ethdev in question.
75 * At embedded switch level, flow rules apply to all traffic seen by it
76 * unless fitting meta items are used to set concrete traffic source(s).
78 * Several pattern items and actions are valid and can be used in both
79 * directions. Those valid for only one direction are described as such.
81 * At least one direction must be specified.
83 * Specifying both directions at once for a given rule is not recommended
84 * but may be valid in a few cases.
86 struct rte_flow_attr {
87 uint32_t group; /**< Priority group. */
88 uint32_t priority; /**< Rule priority level within group. */
90 * The rule in question applies to ingress traffic (non-"transfer").
93 * It has been possible to combine this attribute with "transfer".
94 * Doing so has been assumed to restrict the scope of matching
95 * to traffic going from within the embedded switch toward the
96 * ethdev the flow rule being created through. This behaviour
97 * is deprecated. During the transition period, one may still
98 * rely on it, but PMDs and applications are encouraged to
99 * gradually move away from this approach.
103 * The rule in question applies to egress traffic (non-"transfer").
106 * It has been possible to combine this attribute with "transfer".
107 * Doing so has been assumed to restrict the scope of matching
108 * to traffic sent by the application by virtue of the ethdev
109 * the flow rule being created through. This behaviour is now
110 * deprecated. During the transition period, one may still
111 * rely on it, but PMDs and applications are encouraged to
112 * gradually move away from this approach.
116 * Instead of simply matching the properties of traffic as it would
117 * appear on a given DPDK port ID, enabling this attribute transfers
118 * a flow rule to the lowest possible level of any device endpoints
119 * found in the pattern.
121 * When supported, this effectively enables an application to
122 * re-route traffic not necessarily intended for it (e.g. coming
123 * from or addressed to different physical ports, VFs or
124 * applications) at the device level.
126 * The application should match traffic originating from precise
127 * locations. See items PORT_REPRESENTOR and REPRESENTED_PORT.
129 * Managing "transfer" flows requires that the user communicate them
130 * through a suitable port. @see rte_flow_pick_transfer_proxy().
133 uint32_t reserved:29; /**< Reserved, must be zero. */
137 * Matching pattern item types.
139 * Pattern items fall in two categories:
141 * - Matching protocol headers and packet data, usually associated with a
142 * specification structure. These must be stacked in the same order as the
143 * protocol layers to match inside packets, starting from the lowest.
145 * - Matching meta-data or affecting pattern processing, often without a
146 * specification structure. Since they do not match packet contents, their
147 * position in the list is usually not relevant.
149 * See the description of individual types for more information. Those
150 * marked with [META] fall into the second category.
152 enum rte_flow_item_type {
156 * End marker for item lists. Prevents further processing of items,
157 * thereby ending the pattern.
159 * No associated specification structure.
161 RTE_FLOW_ITEM_TYPE_END,
166 * Used as a placeholder for convenience. It is ignored and simply
169 * No associated specification structure.
171 RTE_FLOW_ITEM_TYPE_VOID,
176 * Inverted matching, i.e. process packets that do not match the
179 * No associated specification structure.
181 RTE_FLOW_ITEM_TYPE_INVERT,
184 * Matches any protocol in place of the current layer, a single ANY
185 * may also stand for several protocol layers.
187 * See struct rte_flow_item_any.
189 RTE_FLOW_ITEM_TYPE_ANY,
193 * @see RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR
194 * @see RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT
198 * Matches traffic originating from (ingress) or going to (egress)
199 * the physical function of the current device.
201 * No associated specification structure.
203 RTE_FLOW_ITEM_TYPE_PF,
207 * @see RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR
208 * @see RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT
212 * Matches traffic originating from (ingress) or going to (egress) a
213 * given virtual function of the current device.
215 * See struct rte_flow_item_vf.
217 RTE_FLOW_ITEM_TYPE_VF,
221 * @see RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR
222 * @see RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT
226 * Matches traffic originating from (ingress) or going to (egress) a
227 * physical port of the underlying device.
229 * See struct rte_flow_item_phy_port.
231 RTE_FLOW_ITEM_TYPE_PHY_PORT,
235 * @see RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR
236 * @see RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT
240 * Matches traffic originating from (ingress) or going to (egress) a
241 * given DPDK port ID.
243 * See struct rte_flow_item_port_id.
245 RTE_FLOW_ITEM_TYPE_PORT_ID,
248 * Matches a byte string of a given length at a given offset.
250 * See struct rte_flow_item_raw.
252 RTE_FLOW_ITEM_TYPE_RAW,
255 * Matches an Ethernet header.
257 * See struct rte_flow_item_eth.
259 RTE_FLOW_ITEM_TYPE_ETH,
262 * Matches an 802.1Q/ad VLAN tag.
264 * See struct rte_flow_item_vlan.
266 RTE_FLOW_ITEM_TYPE_VLAN,
269 * Matches an IPv4 header.
271 * See struct rte_flow_item_ipv4.
273 RTE_FLOW_ITEM_TYPE_IPV4,
276 * Matches an IPv6 header.
278 * See struct rte_flow_item_ipv6.
280 RTE_FLOW_ITEM_TYPE_IPV6,
283 * Matches an ICMP header.
285 * See struct rte_flow_item_icmp.
287 RTE_FLOW_ITEM_TYPE_ICMP,
290 * Matches a UDP header.
292 * See struct rte_flow_item_udp.
294 RTE_FLOW_ITEM_TYPE_UDP,
297 * Matches a TCP header.
299 * See struct rte_flow_item_tcp.
301 RTE_FLOW_ITEM_TYPE_TCP,
304 * Matches a SCTP header.
306 * See struct rte_flow_item_sctp.
308 RTE_FLOW_ITEM_TYPE_SCTP,
311 * Matches a VXLAN header.
313 * See struct rte_flow_item_vxlan.
315 RTE_FLOW_ITEM_TYPE_VXLAN,
318 * Matches a E_TAG header.
320 * See struct rte_flow_item_e_tag.
322 RTE_FLOW_ITEM_TYPE_E_TAG,
325 * Matches a NVGRE header.
327 * See struct rte_flow_item_nvgre.
329 RTE_FLOW_ITEM_TYPE_NVGRE,
332 * Matches a MPLS header.
334 * See struct rte_flow_item_mpls.
336 RTE_FLOW_ITEM_TYPE_MPLS,
339 * Matches a GRE header.
341 * See struct rte_flow_item_gre.
343 RTE_FLOW_ITEM_TYPE_GRE,
348 * Fuzzy pattern match, expect faster than default.
350 * This is for device that support fuzzy matching option.
351 * Usually a fuzzy matching is fast but the cost is accuracy.
353 * See struct rte_flow_item_fuzzy.
355 RTE_FLOW_ITEM_TYPE_FUZZY,
358 * Matches a GTP header.
360 * Configure flow for GTP packets.
362 * See struct rte_flow_item_gtp.
364 RTE_FLOW_ITEM_TYPE_GTP,
367 * Matches a GTP header.
369 * Configure flow for GTP-C packets.
371 * See struct rte_flow_item_gtp.
373 RTE_FLOW_ITEM_TYPE_GTPC,
376 * Matches a GTP header.
378 * Configure flow for GTP-U packets.
380 * See struct rte_flow_item_gtp.
382 RTE_FLOW_ITEM_TYPE_GTPU,
385 * Matches a ESP header.
387 * See struct rte_flow_item_esp.
389 RTE_FLOW_ITEM_TYPE_ESP,
392 * Matches a GENEVE header.
394 * See struct rte_flow_item_geneve.
396 RTE_FLOW_ITEM_TYPE_GENEVE,
399 * Matches a VXLAN-GPE header.
401 * See struct rte_flow_item_vxlan_gpe.
403 RTE_FLOW_ITEM_TYPE_VXLAN_GPE,
406 * Matches an ARP header for Ethernet/IPv4.
408 * See struct rte_flow_item_arp_eth_ipv4.
410 RTE_FLOW_ITEM_TYPE_ARP_ETH_IPV4,
413 * Matches the presence of any IPv6 extension header.
415 * See struct rte_flow_item_ipv6_ext.
417 RTE_FLOW_ITEM_TYPE_IPV6_EXT,
420 * Matches any ICMPv6 header.
422 * See struct rte_flow_item_icmp6.
424 RTE_FLOW_ITEM_TYPE_ICMP6,
427 * Matches an ICMPv6 neighbor discovery solicitation.
429 * See struct rte_flow_item_icmp6_nd_ns.
431 RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS,
434 * Matches an ICMPv6 neighbor discovery advertisement.
436 * See struct rte_flow_item_icmp6_nd_na.
438 RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA,
441 * Matches the presence of any ICMPv6 neighbor discovery option.
443 * See struct rte_flow_item_icmp6_nd_opt.
445 RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT,
448 * Matches an ICMPv6 neighbor discovery source Ethernet link-layer
451 * See struct rte_flow_item_icmp6_nd_opt_sla_eth.
453 RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_SLA_ETH,
456 * Matches an ICMPv6 neighbor discovery target Ethernet link-layer
459 * See struct rte_flow_item_icmp6_nd_opt_tla_eth.
461 RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_TLA_ETH,
464 * Matches specified mark field.
466 * See struct rte_flow_item_mark.
468 RTE_FLOW_ITEM_TYPE_MARK,
473 * Matches a metadata value.
475 * See struct rte_flow_item_meta.
477 RTE_FLOW_ITEM_TYPE_META,
480 * Matches a GRE optional key field.
482 * The value should a big-endian 32bit integer.
484 * When this item present the K bit is implicitly matched as "1"
485 * in the default mask.
488 * @code rte_be32_t * @endcode
490 RTE_FLOW_ITEM_TYPE_GRE_KEY,
493 * Matches a GTP extension header: PDU session container.
495 * Configure flow for GTP packets with extension header type 0x85.
497 * See struct rte_flow_item_gtp_psc.
499 RTE_FLOW_ITEM_TYPE_GTP_PSC,
502 * Matches a PPPoE header.
504 * Configure flow for PPPoE session packets.
506 * See struct rte_flow_item_pppoe.
508 RTE_FLOW_ITEM_TYPE_PPPOES,
511 * Matches a PPPoE header.
513 * Configure flow for PPPoE discovery packets.
515 * See struct rte_flow_item_pppoe.
517 RTE_FLOW_ITEM_TYPE_PPPOED,
520 * Matches a PPPoE optional proto_id field.
522 * It only applies to PPPoE session packets.
524 * See struct rte_flow_item_pppoe_proto_id.
526 RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID,
529 * Matches Network service header (NSH).
530 * See struct rte_flow_item_nsh.
533 RTE_FLOW_ITEM_TYPE_NSH,
536 * Matches Internet Group Management Protocol (IGMP).
537 * See struct rte_flow_item_igmp.
540 RTE_FLOW_ITEM_TYPE_IGMP,
543 * Matches IP Authentication Header (AH).
544 * See struct rte_flow_item_ah.
547 RTE_FLOW_ITEM_TYPE_AH,
550 * Matches a HIGIG header.
551 * see struct rte_flow_item_higig2_hdr.
553 RTE_FLOW_ITEM_TYPE_HIGIG2,
558 * Matches a tag value.
560 * See struct rte_flow_item_tag.
562 RTE_FLOW_ITEM_TYPE_TAG,
565 * Matches a L2TPv3 over IP header.
567 * Configure flow for L2TPv3 over IP packets.
569 * See struct rte_flow_item_l2tpv3oip.
571 RTE_FLOW_ITEM_TYPE_L2TPV3OIP,
574 * Matches PFCP Header.
575 * See struct rte_flow_item_pfcp.
578 RTE_FLOW_ITEM_TYPE_PFCP,
581 * Matches eCPRI Header.
583 * Configure flow for eCPRI over ETH or UDP packets.
585 * See struct rte_flow_item_ecpri.
587 RTE_FLOW_ITEM_TYPE_ECPRI,
590 * Matches the presence of IPv6 fragment extension header.
592 * See struct rte_flow_item_ipv6_frag_ext.
594 RTE_FLOW_ITEM_TYPE_IPV6_FRAG_EXT,
597 * Matches Geneve Variable Length Option
599 * See struct rte_flow_item_geneve_opt
601 RTE_FLOW_ITEM_TYPE_GENEVE_OPT,
606 * Matches on packet integrity.
607 * For some devices application needs to enable integration checks in HW
608 * before using this item.
610 * @see struct rte_flow_item_integrity.
612 RTE_FLOW_ITEM_TYPE_INTEGRITY,
617 * Matches conntrack state.
619 * @see struct rte_flow_item_conntrack.
621 RTE_FLOW_ITEM_TYPE_CONNTRACK,
626 * Matches traffic entering the embedded switch from the given ethdev.
628 * @see struct rte_flow_item_ethdev
630 RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR,
635 * Matches traffic entering the embedded switch from
636 * the entity represented by the given ethdev.
638 * @see struct rte_flow_item_ethdev
640 RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT,
643 * Matches a configured set of fields at runtime calculated offsets
644 * over the generic network header with variable length and
647 * @see struct rte_flow_item_flex.
649 RTE_FLOW_ITEM_TYPE_FLEX,
652 * Matches L2TPv2 Header.
654 * See struct rte_flow_item_l2tpv2.
656 RTE_FLOW_ITEM_TYPE_L2TPV2,
659 * Matches PPP Header.
661 * See struct rte_flow_item_ppp.
663 RTE_FLOW_ITEM_TYPE_PPP,
666 * Matches GRE optional fields.
668 * See struct rte_flow_item_gre_opt.
670 RTE_FLOW_ITEM_TYPE_GRE_OPTION,
675 * RTE_FLOW_ITEM_TYPE_HIGIG2
676 * Matches higig2 header
679 struct rte_flow_item_higig2_hdr {
680 struct rte_higig2_hdr hdr;
683 /** Default mask for RTE_FLOW_ITEM_TYPE_HIGIG2. */
685 static const struct rte_flow_item_higig2_hdr rte_flow_item_higig2_hdr_mask = {
688 .classification = 0xffff,
696 * RTE_FLOW_ITEM_TYPE_ANY
698 * Matches any protocol in place of the current layer, a single ANY may also
699 * stand for several protocol layers.
701 * This is usually specified as the first pattern item when looking for a
702 * protocol anywhere in a packet.
704 * A zeroed mask stands for any number of layers.
706 struct rte_flow_item_any {
707 uint32_t num; /**< Number of layers covered. */
710 /** Default mask for RTE_FLOW_ITEM_TYPE_ANY. */
712 static const struct rte_flow_item_any rte_flow_item_any_mask = {
719 * @see RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR
720 * @see RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT
722 * RTE_FLOW_ITEM_TYPE_VF
724 * Matches traffic originating from (ingress) or going to (egress) a given
725 * virtual function of the current device.
727 * If supported, should work even if the virtual function is not managed by
728 * the application and thus not associated with a DPDK port ID.
730 * Note this pattern item does not match VF representors traffic which, as
731 * separate entities, should be addressed through their own DPDK port IDs.
733 * - Can be specified multiple times to match traffic addressed to several
735 * - Can be combined with a PF item to match both PF and VF traffic.
737 * A zeroed mask can be used to match any VF ID.
739 struct rte_flow_item_vf {
740 uint32_t id; /**< VF ID. */
743 /** Default mask for RTE_FLOW_ITEM_TYPE_VF. */
745 static const struct rte_flow_item_vf rte_flow_item_vf_mask = {
752 * @see RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR
753 * @see RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT
755 * RTE_FLOW_ITEM_TYPE_PHY_PORT
757 * Matches traffic originating from (ingress) or going to (egress) a
758 * physical port of the underlying device.
760 * The first PHY_PORT item overrides the physical port normally associated
761 * with the specified DPDK input port (port_id). This item can be provided
762 * several times to match additional physical ports.
764 * Note that physical ports are not necessarily tied to DPDK input ports
765 * (port_id) when those are not under DPDK control. Possible values are
766 * specific to each device, they are not necessarily indexed from zero and
767 * may not be contiguous.
769 * As a device property, the list of allowed values as well as the value
770 * associated with a port_id should be retrieved by other means.
772 * A zeroed mask can be used to match any port index.
774 struct rte_flow_item_phy_port {
775 uint32_t index; /**< Physical port index. */
778 /** Default mask for RTE_FLOW_ITEM_TYPE_PHY_PORT. */
780 static const struct rte_flow_item_phy_port rte_flow_item_phy_port_mask = {
787 * @see RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR
788 * @see RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT
790 * RTE_FLOW_ITEM_TYPE_PORT_ID
792 * Matches traffic originating from (ingress) or going to (egress) a given
795 * Normally only supported if the port ID in question is known by the
796 * underlying PMD and related to the device the flow rule is created
799 * This must not be confused with @p PHY_PORT which refers to the physical
800 * port of a device, whereas @p PORT_ID refers to a struct rte_eth_dev
801 * object on the application side (also known as "port representor"
802 * depending on the kind of underlying device).
804 struct rte_flow_item_port_id {
805 uint32_t id; /**< DPDK port ID. */
808 /** Default mask for RTE_FLOW_ITEM_TYPE_PORT_ID. */
810 static const struct rte_flow_item_port_id rte_flow_item_port_id_mask = {
816 * RTE_FLOW_ITEM_TYPE_RAW
818 * Matches a byte string of a given length at a given offset.
820 * Offset is either absolute (using the start of the packet) or relative to
821 * the end of the previous matched item in the stack, in which case negative
822 * values are allowed.
824 * If search is enabled, offset is used as the starting point. The search
825 * area can be delimited by setting limit to a nonzero value, which is the
826 * maximum number of bytes after offset where the pattern may start.
828 * Matching a zero-length pattern is allowed, doing so resets the relative
829 * offset for subsequent items.
831 * This type does not support ranges (struct rte_flow_item.last).
833 struct rte_flow_item_raw {
834 uint32_t relative:1; /**< Look for pattern after the previous item. */
835 uint32_t search:1; /**< Search pattern from offset (see also limit). */
836 uint32_t reserved:30; /**< Reserved, must be set to zero. */
837 int32_t offset; /**< Absolute or relative offset for pattern. */
838 uint16_t limit; /**< Search area limit for start of pattern. */
839 uint16_t length; /**< Pattern length. */
840 const uint8_t *pattern; /**< Byte string to look for. */
843 /** Default mask for RTE_FLOW_ITEM_TYPE_RAW. */
845 static const struct rte_flow_item_raw rte_flow_item_raw_mask = {
848 .reserved = 0x3fffffff,
849 .offset = 0xffffffff,
857 * RTE_FLOW_ITEM_TYPE_ETH
859 * Matches an Ethernet header.
861 * Inside @p hdr field, the sub-field @p ether_type stands either for EtherType
862 * or TPID, depending on whether the item is followed by a VLAN item or not. If
863 * two VLAN items follow, the sub-field refers to the outer one, which, in turn,
864 * contains the inner TPID in the similar header field. The innermost VLAN item
865 * contains a layer-3 EtherType. All of that follows the order seen on the wire.
867 * If the field in question contains a TPID value, only tagged packets with the
868 * specified TPID will match the pattern. Alternatively, it's possible to match
869 * any type of tagged packets by means of the field @p has_vlan rather than use
870 * the EtherType/TPID field. Also, it's possible to leave the two fields unused.
871 * If this is the case, both tagged and untagged packets will match the pattern.
874 struct rte_flow_item_eth {
878 * These fields are retained for compatibility.
879 * Please switch to the new header field below.
881 struct rte_ether_addr dst; /**< Destination MAC. */
882 struct rte_ether_addr src; /**< Source MAC. */
883 rte_be16_t type; /**< EtherType or TPID. */
885 struct rte_ether_hdr hdr;
887 uint32_t has_vlan:1; /**< Packet header contains at least one VLAN. */
888 uint32_t reserved:31; /**< Reserved, must be zero. */
891 /** Default mask for RTE_FLOW_ITEM_TYPE_ETH. */
893 static const struct rte_flow_item_eth rte_flow_item_eth_mask = {
894 .hdr.dst_addr.addr_bytes = "\xff\xff\xff\xff\xff\xff",
895 .hdr.src_addr.addr_bytes = "\xff\xff\xff\xff\xff\xff",
896 .hdr.ether_type = RTE_BE16(0x0000),
901 * RTE_FLOW_ITEM_TYPE_VLAN
903 * Matches an 802.1Q/ad VLAN tag.
905 * The corresponding standard outer EtherType (TPID) values are
906 * RTE_ETHER_TYPE_VLAN or RTE_ETHER_TYPE_QINQ. It can be overridden by
907 * the preceding pattern item.
908 * If a @p VLAN item is present in the pattern, then only tagged packets will
910 * The field @p has_more_vlan can be used to match any type of tagged packets,
911 * instead of using the @p eth_proto field of @p hdr.
912 * If the @p eth_proto of @p hdr and @p has_more_vlan fields are not specified,
913 * then any tagged packets will match the pattern.
916 struct rte_flow_item_vlan {
920 * These fields are retained for compatibility.
921 * Please switch to the new header field below.
923 rte_be16_t tci; /**< Tag control information. */
924 rte_be16_t inner_type; /**< Inner EtherType or TPID. */
926 struct rte_vlan_hdr hdr;
928 /** Packet header contains at least one more VLAN, after this VLAN. */
929 uint32_t has_more_vlan:1;
930 uint32_t reserved:31; /**< Reserved, must be zero. */
933 /** Default mask for RTE_FLOW_ITEM_TYPE_VLAN. */
935 static const struct rte_flow_item_vlan rte_flow_item_vlan_mask = {
936 .hdr.vlan_tci = RTE_BE16(0x0fff),
937 .hdr.eth_proto = RTE_BE16(0x0000),
942 * RTE_FLOW_ITEM_TYPE_IPV4
944 * Matches an IPv4 header.
946 * Note: IPv4 options are handled by dedicated pattern items.
948 struct rte_flow_item_ipv4 {
949 struct rte_ipv4_hdr hdr; /**< IPv4 header definition. */
952 /** Default mask for RTE_FLOW_ITEM_TYPE_IPV4. */
954 static const struct rte_flow_item_ipv4 rte_flow_item_ipv4_mask = {
956 .src_addr = RTE_BE32(0xffffffff),
957 .dst_addr = RTE_BE32(0xffffffff),
963 * RTE_FLOW_ITEM_TYPE_IPV6.
965 * Matches an IPv6 header.
967 * Dedicated flags indicate if header contains specific extension headers.
969 struct rte_flow_item_ipv6 {
970 struct rte_ipv6_hdr hdr; /**< IPv6 header definition. */
971 /** Header contains Hop-by-Hop Options extension header. */
972 uint32_t has_hop_ext:1;
973 /** Header contains Routing extension header. */
974 uint32_t has_route_ext:1;
975 /** Header contains Fragment extension header. */
976 uint32_t has_frag_ext:1;
977 /** Header contains Authentication extension header. */
978 uint32_t has_auth_ext:1;
979 /** Header contains Encapsulation Security Payload extension header. */
980 uint32_t has_esp_ext:1;
981 /** Header contains Destination Options extension header. */
982 uint32_t has_dest_ext:1;
983 /** Header contains Mobility extension header. */
984 uint32_t has_mobil_ext:1;
985 /** Header contains Host Identity Protocol extension header. */
986 uint32_t has_hip_ext:1;
987 /** Header contains Shim6 Protocol extension header. */
988 uint32_t has_shim6_ext:1;
989 /** Reserved for future extension headers, must be zero. */
990 uint32_t reserved:23;
993 /** Default mask for RTE_FLOW_ITEM_TYPE_IPV6. */
995 static const struct rte_flow_item_ipv6 rte_flow_item_ipv6_mask = {
998 "\xff\xff\xff\xff\xff\xff\xff\xff"
999 "\xff\xff\xff\xff\xff\xff\xff\xff",
1001 "\xff\xff\xff\xff\xff\xff\xff\xff"
1002 "\xff\xff\xff\xff\xff\xff\xff\xff",
1008 * RTE_FLOW_ITEM_TYPE_ICMP.
1010 * Matches an ICMP header.
1012 struct rte_flow_item_icmp {
1013 struct rte_icmp_hdr hdr; /**< ICMP header definition. */
1016 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP. */
1018 static const struct rte_flow_item_icmp rte_flow_item_icmp_mask = {
1027 * RTE_FLOW_ITEM_TYPE_UDP.
1029 * Matches a UDP header.
1031 struct rte_flow_item_udp {
1032 struct rte_udp_hdr hdr; /**< UDP header definition. */
1035 /** Default mask for RTE_FLOW_ITEM_TYPE_UDP. */
1037 static const struct rte_flow_item_udp rte_flow_item_udp_mask = {
1039 .src_port = RTE_BE16(0xffff),
1040 .dst_port = RTE_BE16(0xffff),
1046 * RTE_FLOW_ITEM_TYPE_TCP.
1048 * Matches a TCP header.
1050 struct rte_flow_item_tcp {
1051 struct rte_tcp_hdr hdr; /**< TCP header definition. */
1054 /** Default mask for RTE_FLOW_ITEM_TYPE_TCP. */
1056 static const struct rte_flow_item_tcp rte_flow_item_tcp_mask = {
1058 .src_port = RTE_BE16(0xffff),
1059 .dst_port = RTE_BE16(0xffff),
1065 * RTE_FLOW_ITEM_TYPE_SCTP.
1067 * Matches a SCTP header.
1069 struct rte_flow_item_sctp {
1070 struct rte_sctp_hdr hdr; /**< SCTP header definition. */
1073 /** Default mask for RTE_FLOW_ITEM_TYPE_SCTP. */
1075 static const struct rte_flow_item_sctp rte_flow_item_sctp_mask = {
1077 .src_port = RTE_BE16(0xffff),
1078 .dst_port = RTE_BE16(0xffff),
1084 * RTE_FLOW_ITEM_TYPE_VXLAN.
1086 * Matches a VXLAN header (RFC 7348).
1089 struct rte_flow_item_vxlan {
1093 * These fields are retained for compatibility.
1094 * Please switch to the new header field below.
1096 uint8_t flags; /**< Normally 0x08 (I flag). */
1097 uint8_t rsvd0[3]; /**< Reserved, normally 0x000000. */
1098 uint8_t vni[3]; /**< VXLAN identifier. */
1099 uint8_t rsvd1; /**< Reserved, normally 0x00. */
1101 struct rte_vxlan_hdr hdr;
1105 /** Default mask for RTE_FLOW_ITEM_TYPE_VXLAN. */
1107 static const struct rte_flow_item_vxlan rte_flow_item_vxlan_mask = {
1108 .hdr.vx_vni = RTE_BE32(0xffffff00), /* (0xffffff << 8) */
1113 * RTE_FLOW_ITEM_TYPE_E_TAG.
1115 * Matches a E-tag header.
1117 * The corresponding standard outer EtherType (TPID) value is
1118 * RTE_ETHER_TYPE_ETAG. It can be overridden by the preceding pattern item.
1120 struct rte_flow_item_e_tag {
1122 * E-Tag control information (E-TCI).
1123 * E-PCP (3b), E-DEI (1b), ingress E-CID base (12b).
1125 rte_be16_t epcp_edei_in_ecid_b;
1126 /** Reserved (2b), GRP (2b), E-CID base (12b). */
1127 rte_be16_t rsvd_grp_ecid_b;
1128 uint8_t in_ecid_e; /**< Ingress E-CID ext. */
1129 uint8_t ecid_e; /**< E-CID ext. */
1130 rte_be16_t inner_type; /**< Inner EtherType or TPID. */
1133 /** Default mask for RTE_FLOW_ITEM_TYPE_E_TAG. */
1135 static const struct rte_flow_item_e_tag rte_flow_item_e_tag_mask = {
1136 .rsvd_grp_ecid_b = RTE_BE16(0x3fff),
1141 * RTE_FLOW_ITEM_TYPE_NVGRE.
1143 * Matches a NVGRE header.
1145 struct rte_flow_item_nvgre {
1147 * Checksum (1b), undefined (1b), key bit (1b), sequence number (1b),
1148 * reserved 0 (9b), version (3b).
1150 * c_k_s_rsvd0_ver must have value 0x2000 according to RFC 7637.
1152 rte_be16_t c_k_s_rsvd0_ver;
1153 rte_be16_t protocol; /**< Protocol type (0x6558). */
1154 uint8_t tni[3]; /**< Virtual subnet ID. */
1155 uint8_t flow_id; /**< Flow ID. */
1158 /** Default mask for RTE_FLOW_ITEM_TYPE_NVGRE. */
1160 static const struct rte_flow_item_nvgre rte_flow_item_nvgre_mask = {
1161 .tni = "\xff\xff\xff",
1166 * RTE_FLOW_ITEM_TYPE_MPLS.
1168 * Matches a MPLS header.
1170 struct rte_flow_item_mpls {
1172 * Label (20b), TC (3b), Bottom of Stack (1b).
1174 uint8_t label_tc_s[3];
1175 uint8_t ttl; /** Time-to-Live. */
1178 /** Default mask for RTE_FLOW_ITEM_TYPE_MPLS. */
1180 static const struct rte_flow_item_mpls rte_flow_item_mpls_mask = {
1181 .label_tc_s = "\xff\xff\xf0",
1186 * RTE_FLOW_ITEM_TYPE_GRE.
1188 * Matches a GRE header.
1190 struct rte_flow_item_gre {
1192 * Checksum (1b), reserved 0 (12b), version (3b).
1193 * Refer to RFC 2784.
1195 rte_be16_t c_rsvd0_ver;
1196 rte_be16_t protocol; /**< Protocol type. */
1199 /** Default mask for RTE_FLOW_ITEM_TYPE_GRE. */
1201 static const struct rte_flow_item_gre rte_flow_item_gre_mask = {
1202 .protocol = RTE_BE16(0xffff),
1207 * RTE_FLOW_ITEM_TYPE_GRE_OPTION.
1209 * Matches GRE optional fields in header.
1211 struct rte_flow_item_gre_opt {
1212 struct rte_gre_hdr_opt_checksum_rsvd checksum_rsvd;
1213 struct rte_gre_hdr_opt_key key;
1214 struct rte_gre_hdr_opt_sequence sequence;
1218 * RTE_FLOW_ITEM_TYPE_FUZZY
1220 * Fuzzy pattern match, expect faster than default.
1222 * This is for device that support fuzzy match option.
1223 * Usually a fuzzy match is fast but the cost is accuracy.
1224 * i.e. Signature Match only match pattern's hash value, but it is
1225 * possible two different patterns have the same hash value.
1227 * Matching accuracy level can be configure by threshold.
1228 * Driver can divide the range of threshold and map to different
1229 * accuracy levels that device support.
1231 * Threshold 0 means perfect match (no fuzziness), while threshold
1232 * 0xffffffff means fuzziest match.
1234 struct rte_flow_item_fuzzy {
1235 uint32_t thresh; /**< Accuracy threshold. */
1238 /** Default mask for RTE_FLOW_ITEM_TYPE_FUZZY. */
1240 static const struct rte_flow_item_fuzzy rte_flow_item_fuzzy_mask = {
1241 .thresh = 0xffffffff,
1246 * RTE_FLOW_ITEM_TYPE_GTP.
1248 * Matches a GTPv1 header.
1250 struct rte_flow_item_gtp {
1252 * Version (3b), protocol type (1b), reserved (1b),
1253 * Extension header flag (1b),
1254 * Sequence number flag (1b),
1255 * N-PDU number flag (1b).
1257 uint8_t v_pt_rsv_flags;
1258 uint8_t msg_type; /**< Message type. */
1259 rte_be16_t msg_len; /**< Message length. */
1260 rte_be32_t teid; /**< Tunnel endpoint identifier. */
1263 /** Default mask for RTE_FLOW_ITEM_TYPE_GTP. */
1265 static const struct rte_flow_item_gtp rte_flow_item_gtp_mask = {
1266 .teid = RTE_BE32(0xffffffff),
1271 * RTE_FLOW_ITEM_TYPE_ESP
1273 * Matches an ESP header.
1275 struct rte_flow_item_esp {
1276 struct rte_esp_hdr hdr; /**< ESP header definition. */
1279 /** Default mask for RTE_FLOW_ITEM_TYPE_ESP. */
1281 static const struct rte_flow_item_esp rte_flow_item_esp_mask = {
1283 .spi = RTE_BE32(0xffffffff),
1289 * RTE_FLOW_ITEM_TYPE_GENEVE.
1291 * Matches a GENEVE header.
1293 struct rte_flow_item_geneve {
1295 * Version (2b), length of the options fields (6b), OAM packet (1b),
1296 * critical options present (1b), reserved 0 (6b).
1298 rte_be16_t ver_opt_len_o_c_rsvd0;
1299 rte_be16_t protocol; /**< Protocol type. */
1300 uint8_t vni[3]; /**< Virtual Network Identifier. */
1301 uint8_t rsvd1; /**< Reserved, normally 0x00. */
1304 /** Default mask for RTE_FLOW_ITEM_TYPE_GENEVE. */
1306 static const struct rte_flow_item_geneve rte_flow_item_geneve_mask = {
1307 .vni = "\xff\xff\xff",
1312 * RTE_FLOW_ITEM_TYPE_VXLAN_GPE (draft-ietf-nvo3-vxlan-gpe-05).
1314 * Matches a VXLAN-GPE header.
1316 struct rte_flow_item_vxlan_gpe {
1317 uint8_t flags; /**< Normally 0x0c (I and P flags). */
1318 uint8_t rsvd0[2]; /**< Reserved, normally 0x0000. */
1319 uint8_t protocol; /**< Protocol type. */
1320 uint8_t vni[3]; /**< VXLAN identifier. */
1321 uint8_t rsvd1; /**< Reserved, normally 0x00. */
1324 /** Default mask for RTE_FLOW_ITEM_TYPE_VXLAN_GPE. */
1326 static const struct rte_flow_item_vxlan_gpe rte_flow_item_vxlan_gpe_mask = {
1327 .vni = "\xff\xff\xff",
1332 * RTE_FLOW_ITEM_TYPE_ARP_ETH_IPV4
1334 * Matches an ARP header for Ethernet/IPv4.
1336 struct rte_flow_item_arp_eth_ipv4 {
1337 rte_be16_t hrd; /**< Hardware type, normally 1. */
1338 rte_be16_t pro; /**< Protocol type, normally 0x0800. */
1339 uint8_t hln; /**< Hardware address length, normally 6. */
1340 uint8_t pln; /**< Protocol address length, normally 4. */
1341 rte_be16_t op; /**< Opcode (1 for request, 2 for reply). */
1342 struct rte_ether_addr sha; /**< Sender hardware address. */
1343 rte_be32_t spa; /**< Sender IPv4 address. */
1344 struct rte_ether_addr tha; /**< Target hardware address. */
1345 rte_be32_t tpa; /**< Target IPv4 address. */
1348 /** Default mask for RTE_FLOW_ITEM_TYPE_ARP_ETH_IPV4. */
1350 static const struct rte_flow_item_arp_eth_ipv4
1351 rte_flow_item_arp_eth_ipv4_mask = {
1352 .sha.addr_bytes = "\xff\xff\xff\xff\xff\xff",
1353 .spa = RTE_BE32(0xffffffff),
1354 .tha.addr_bytes = "\xff\xff\xff\xff\xff\xff",
1355 .tpa = RTE_BE32(0xffffffff),
1360 * RTE_FLOW_ITEM_TYPE_IPV6_EXT
1362 * Matches the presence of any IPv6 extension header.
1364 * Normally preceded by any of:
1366 * - RTE_FLOW_ITEM_TYPE_IPV6
1367 * - RTE_FLOW_ITEM_TYPE_IPV6_EXT
1369 struct rte_flow_item_ipv6_ext {
1370 uint8_t next_hdr; /**< Next header. */
1373 /** Default mask for RTE_FLOW_ITEM_TYPE_IPV6_EXT. */
1376 struct rte_flow_item_ipv6_ext rte_flow_item_ipv6_ext_mask = {
1382 * RTE_FLOW_ITEM_TYPE_IPV6_FRAG_EXT
1384 * Matches the presence of IPv6 fragment extension header.
1386 * Preceded by any of:
1388 * - RTE_FLOW_ITEM_TYPE_IPV6
1389 * - RTE_FLOW_ITEM_TYPE_IPV6_EXT
1391 struct rte_flow_item_ipv6_frag_ext {
1392 struct rte_ipv6_fragment_ext hdr;
1396 * RTE_FLOW_ITEM_TYPE_ICMP6
1398 * Matches any ICMPv6 header.
1400 struct rte_flow_item_icmp6 {
1401 uint8_t type; /**< ICMPv6 type. */
1402 uint8_t code; /**< ICMPv6 code. */
1403 uint16_t checksum; /**< ICMPv6 checksum. */
1406 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6. */
1408 static const struct rte_flow_item_icmp6 rte_flow_item_icmp6_mask = {
1415 * RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS
1417 * Matches an ICMPv6 neighbor discovery solicitation.
1419 struct rte_flow_item_icmp6_nd_ns {
1420 uint8_t type; /**< ICMPv6 type, normally 135. */
1421 uint8_t code; /**< ICMPv6 code, normally 0. */
1422 rte_be16_t checksum; /**< ICMPv6 checksum. */
1423 rte_be32_t reserved; /**< Reserved, normally 0. */
1424 uint8_t target_addr[16]; /**< Target address. */
1427 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS. */
1430 struct rte_flow_item_icmp6_nd_ns rte_flow_item_icmp6_nd_ns_mask = {
1432 "\xff\xff\xff\xff\xff\xff\xff\xff"
1433 "\xff\xff\xff\xff\xff\xff\xff\xff",
1438 * RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA
1440 * Matches an ICMPv6 neighbor discovery advertisement.
1442 struct rte_flow_item_icmp6_nd_na {
1443 uint8_t type; /**< ICMPv6 type, normally 136. */
1444 uint8_t code; /**< ICMPv6 code, normally 0. */
1445 rte_be16_t checksum; /**< ICMPv6 checksum. */
1447 * Route flag (1b), solicited flag (1b), override flag (1b),
1450 rte_be32_t rso_reserved;
1451 uint8_t target_addr[16]; /**< Target address. */
1454 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA. */
1457 struct rte_flow_item_icmp6_nd_na rte_flow_item_icmp6_nd_na_mask = {
1459 "\xff\xff\xff\xff\xff\xff\xff\xff"
1460 "\xff\xff\xff\xff\xff\xff\xff\xff",
1465 * RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT
1467 * Matches the presence of any ICMPv6 neighbor discovery option.
1469 * Normally preceded by any of:
1471 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA
1472 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS
1473 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT
1475 struct rte_flow_item_icmp6_nd_opt {
1476 uint8_t type; /**< ND option type. */
1477 uint8_t length; /**< ND option length. */
1480 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT. */
1482 static const struct rte_flow_item_icmp6_nd_opt
1483 rte_flow_item_icmp6_nd_opt_mask = {
1489 * RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_SLA_ETH
1491 * Matches an ICMPv6 neighbor discovery source Ethernet link-layer address
1494 * Normally preceded by any of:
1496 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA
1497 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT
1499 struct rte_flow_item_icmp6_nd_opt_sla_eth {
1500 uint8_t type; /**< ND option type, normally 1. */
1501 uint8_t length; /**< ND option length, normally 1. */
1502 struct rte_ether_addr sla; /**< Source Ethernet LLA. */
1505 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_SLA_ETH. */
1507 static const struct rte_flow_item_icmp6_nd_opt_sla_eth
1508 rte_flow_item_icmp6_nd_opt_sla_eth_mask = {
1509 .sla.addr_bytes = "\xff\xff\xff\xff\xff\xff",
1514 * RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_TLA_ETH
1516 * Matches an ICMPv6 neighbor discovery target Ethernet link-layer address
1519 * Normally preceded by any of:
1521 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS
1522 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT
1524 struct rte_flow_item_icmp6_nd_opt_tla_eth {
1525 uint8_t type; /**< ND option type, normally 2. */
1526 uint8_t length; /**< ND option length, normally 1. */
1527 struct rte_ether_addr tla; /**< Target Ethernet LLA. */
1530 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_TLA_ETH. */
1532 static const struct rte_flow_item_icmp6_nd_opt_tla_eth
1533 rte_flow_item_icmp6_nd_opt_tla_eth_mask = {
1534 .tla.addr_bytes = "\xff\xff\xff\xff\xff\xff",
1539 * RTE_FLOW_ITEM_TYPE_META
1541 * Matches a specified metadata value. On egress, metadata can be set
1542 * either by mbuf dynamic metadata field with RTE_MBUF_DYNFLAG_TX_METADATA flag
1543 * or RTE_FLOW_ACTION_TYPE_SET_META. On ingress, RTE_FLOW_ACTION_TYPE_SET_META
1544 * sets metadata for a packet and the metadata will be reported via mbuf
1545 * metadata dynamic field with RTE_MBUF_DYNFLAG_RX_METADATA flag. The dynamic
1546 * mbuf field must be registered in advance by
1547 * rte_flow_dynf_metadata_register().
1549 struct rte_flow_item_meta {
1553 /** Default mask for RTE_FLOW_ITEM_TYPE_META. */
1555 static const struct rte_flow_item_meta rte_flow_item_meta_mask = {
1561 * RTE_FLOW_ITEM_TYPE_GTP_PSC.
1563 * Matches a GTP PDU extension header with type 0x85.
1565 struct rte_flow_item_gtp_psc {
1566 struct rte_gtp_psc_generic_hdr hdr; /**< gtp psc generic hdr. */
1569 /** Default mask for RTE_FLOW_ITEM_TYPE_GTP_PSC. */
1571 static const struct rte_flow_item_gtp_psc
1572 rte_flow_item_gtp_psc_mask = {
1578 * RTE_FLOW_ITEM_TYPE_PPPOE.
1580 * Matches a PPPoE header.
1582 struct rte_flow_item_pppoe {
1584 * Version (4b), type (4b).
1586 uint8_t version_type;
1587 uint8_t code; /**< Message type. */
1588 rte_be16_t session_id; /**< Session identifier. */
1589 rte_be16_t length; /**< Payload length. */
1593 * RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID.
1595 * Matches a PPPoE optional proto_id field.
1597 * It only applies to PPPoE session packets.
1599 * Normally preceded by any of:
1601 * - RTE_FLOW_ITEM_TYPE_PPPOE
1602 * - RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID
1604 struct rte_flow_item_pppoe_proto_id {
1605 rte_be16_t proto_id; /**< PPP protocol identifier. */
1608 /** Default mask for RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID. */
1610 static const struct rte_flow_item_pppoe_proto_id
1611 rte_flow_item_pppoe_proto_id_mask = {
1612 .proto_id = RTE_BE16(0xffff),
1618 * @b EXPERIMENTAL: this structure may change without prior notice
1620 * RTE_FLOW_ITEM_TYPE_TAG
1622 * Matches a specified tag value at the specified index.
1624 struct rte_flow_item_tag {
1629 /** Default mask for RTE_FLOW_ITEM_TYPE_TAG. */
1631 static const struct rte_flow_item_tag rte_flow_item_tag_mask = {
1638 * RTE_FLOW_ITEM_TYPE_L2TPV3OIP.
1640 * Matches a L2TPv3 over IP header.
1642 struct rte_flow_item_l2tpv3oip {
1643 rte_be32_t session_id; /**< Session ID. */
1646 /** Default mask for RTE_FLOW_ITEM_TYPE_L2TPV3OIP. */
1648 static const struct rte_flow_item_l2tpv3oip rte_flow_item_l2tpv3oip_mask = {
1649 .session_id = RTE_BE32(UINT32_MAX),
1656 * @b EXPERIMENTAL: this structure may change without prior notice
1658 * RTE_FLOW_ITEM_TYPE_MARK
1660 * Matches an arbitrary integer value which was set using the ``MARK`` action
1661 * in a previously matched rule.
1663 * This item can only be specified once as a match criteria as the ``MARK``
1664 * action can only be specified once in a flow action.
1666 * This value is arbitrary and application-defined. Maximum allowed value
1667 * depends on the underlying implementation.
1669 * Depending on the underlying implementation the MARK item may be supported on
1670 * the physical device, with virtual groups in the PMD or not at all.
1672 struct rte_flow_item_mark {
1673 uint32_t id; /**< Integer value to match against. */
1676 /** Default mask for RTE_FLOW_ITEM_TYPE_MARK. */
1678 static const struct rte_flow_item_mark rte_flow_item_mark_mask = {
1685 * @b EXPERIMENTAL: this structure may change without prior notice
1687 * RTE_FLOW_ITEM_TYPE_NSH
1689 * Match network service header (NSH), RFC 8300
1692 struct rte_flow_item_nsh {
1695 uint32_t reserved:1;
1698 uint32_t reserved1:4;
1700 uint32_t next_proto:8;
1705 /** Default mask for RTE_FLOW_ITEM_TYPE_NSH. */
1707 static const struct rte_flow_item_nsh rte_flow_item_nsh_mask = {
1717 * @b EXPERIMENTAL: this structure may change without prior notice
1719 * RTE_FLOW_ITEM_TYPE_IGMP
1721 * Match Internet Group Management Protocol (IGMP), RFC 2236
1724 struct rte_flow_item_igmp {
1726 uint32_t max_resp_time:8;
1727 uint32_t checksum:16;
1728 uint32_t group_addr;
1731 /** Default mask for RTE_FLOW_ITEM_TYPE_IGMP. */
1733 static const struct rte_flow_item_igmp rte_flow_item_igmp_mask = {
1734 .group_addr = 0xffffffff,
1740 * @b EXPERIMENTAL: this structure may change without prior notice
1742 * RTE_FLOW_ITEM_TYPE_AH
1744 * Match IP Authentication Header (AH), RFC 4302
1747 struct rte_flow_item_ah {
1748 uint32_t next_hdr:8;
1749 uint32_t payload_len:8;
1750 uint32_t reserved:16;
1755 /** Default mask for RTE_FLOW_ITEM_TYPE_AH. */
1757 static const struct rte_flow_item_ah rte_flow_item_ah_mask = {
1764 * @b EXPERIMENTAL: this structure may change without prior notice
1766 * RTE_FLOW_ITEM_TYPE_PFCP
1770 struct rte_flow_item_pfcp {
1777 /** Default mask for RTE_FLOW_ITEM_TYPE_PFCP. */
1779 static const struct rte_flow_item_pfcp rte_flow_item_pfcp_mask = {
1781 .seid = RTE_BE64(UINT64_C(0xffffffffffffffff)),
1787 * @b EXPERIMENTAL: this structure may change without prior notice
1789 * RTE_FLOW_ITEM_TYPE_ECPRI
1791 * Match eCPRI Header
1793 struct rte_flow_item_ecpri {
1794 struct rte_ecpri_combined_msg_hdr hdr;
1797 /** Default mask for RTE_FLOW_ITEM_TYPE_ECPRI. */
1799 static const struct rte_flow_item_ecpri rte_flow_item_ecpri_mask = {
1809 * RTE_FLOW_ITEM_TYPE_GENEVE_OPT
1811 * Matches a GENEVE Variable Length Option
1813 struct rte_flow_item_geneve_opt {
1814 rte_be16_t option_class;
1815 uint8_t option_type;
1820 /** Default mask for RTE_FLOW_ITEM_TYPE_GENEVE_OPT. */
1822 static const struct rte_flow_item_geneve_opt
1823 rte_flow_item_geneve_opt_mask = {
1824 .option_type = 0xff,
1830 * @b EXPERIMENTAL: this structure may change without prior notice
1832 * RTE_FLOW_ITEM_TYPE_INTEGRITY
1834 * Match on packet integrity check result.
1836 struct rte_flow_item_integrity {
1837 /** Tunnel encapsulation level the item should apply to.
1838 * @see rte_flow_action_rss
1845 /** The packet is valid after passing all HW checks. */
1846 uint64_t packet_ok:1;
1847 /** L2 layer is valid after passing all HW checks. */
1849 /** L3 layer is valid after passing all HW checks. */
1851 /** L4 layer is valid after passing all HW checks. */
1853 /** L2 layer CRC is valid. */
1854 uint64_t l2_crc_ok:1;
1855 /** IPv4 layer checksum is valid. */
1856 uint64_t ipv4_csum_ok:1;
1857 /** L4 layer checksum is valid. */
1858 uint64_t l4_csum_ok:1;
1859 /** L3 length is smaller than frame length. */
1860 uint64_t l3_len_ok:1;
1861 uint64_t reserved:56;
1868 static const struct rte_flow_item_integrity
1869 rte_flow_item_integrity_mask = {
1876 * The packet is valid after conntrack checking.
1878 #define RTE_FLOW_CONNTRACK_PKT_STATE_VALID RTE_BIT32(0)
1880 * The state of the connection is changed.
1882 #define RTE_FLOW_CONNTRACK_PKT_STATE_CHANGED RTE_BIT32(1)
1884 * Error is detected on this packet for this connection and
1885 * an invalid state is set.
1887 #define RTE_FLOW_CONNTRACK_PKT_STATE_INVALID RTE_BIT32(2)
1889 * The HW connection tracking module is disabled.
1890 * It can be due to application command or an invalid state.
1892 #define RTE_FLOW_CONNTRACK_PKT_STATE_DISABLED RTE_BIT32(3)
1894 * The packet contains some bad field(s) and cannot continue
1895 * with the conntrack module checking.
1897 #define RTE_FLOW_CONNTRACK_PKT_STATE_BAD RTE_BIT32(4)
1901 * @b EXPERIMENTAL: this structure may change without prior notice
1903 * RTE_FLOW_ITEM_TYPE_CONNTRACK
1905 * Matches the state of a packet after it passed the connection tracking
1906 * examination. The state is a bitmap of one RTE_FLOW_CONNTRACK_PKT_STATE*
1907 * or a reasonable combination of these bits.
1909 struct rte_flow_item_conntrack {
1913 /** Default mask for RTE_FLOW_ITEM_TYPE_CONNTRACK. */
1915 static const struct rte_flow_item_conntrack rte_flow_item_conntrack_mask = {
1916 .flags = 0xffffffff,
1922 * @b EXPERIMENTAL: this structure may change without prior notice
1924 * Provides an ethdev port ID for use with the following items:
1925 * RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR,
1926 * RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT.
1928 struct rte_flow_item_ethdev {
1929 uint16_t port_id; /**< ethdev port ID */
1932 /** Default mask for items based on struct rte_flow_item_ethdev */
1934 static const struct rte_flow_item_ethdev rte_flow_item_ethdev_mask = {
1941 * @b EXPERIMENTAL: this structure may change without prior notice
1943 * RTE_FLOW_ITEM_TYPE_L2TPV2
1945 * Matches L2TPv2 Header
1947 struct rte_flow_item_l2tpv2 {
1948 struct rte_l2tpv2_combined_msg_hdr hdr;
1951 /** Default mask for RTE_FLOW_ITEM_TYPE_L2TPV2. */
1953 static const struct rte_flow_item_l2tpv2 rte_flow_item_l2tpv2_mask = {
1955 * flags and version bit mask
1956 * 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0
1957 * T L x x S x O P x x x x V V V V
1961 .flags_version = RTE_BE16(0xcb0f),
1969 * @b EXPERIMENTAL: this structure may change without prior notice
1971 * RTE_FLOW_ITEM_TYPE_PPP
1973 * Matches PPP Header
1975 struct rte_flow_item_ppp {
1976 struct rte_ppp_hdr hdr;
1979 /** Default mask for RTE_FLOW_ITEM_TYPE_PPP. */
1981 static const struct rte_flow_item_ppp rte_flow_item_ppp_mask = {
1985 .proto_id = RTE_BE16(0xffff),
1991 * Matching pattern item definition.
1993 * A pattern is formed by stacking items starting from the lowest protocol
1994 * layer to match. This stacking restriction does not apply to meta items
1995 * which can be placed anywhere in the stack without affecting the meaning
1996 * of the resulting pattern.
1998 * Patterns are terminated by END items.
2000 * The spec field should be a valid pointer to a structure of the related
2001 * item type. It may remain unspecified (NULL) in many cases to request
2002 * broad (nonspecific) matching. In such cases, last and mask must also be
2005 * Optionally, last can point to a structure of the same type to define an
2006 * inclusive range. This is mostly supported by integer and address fields,
2007 * may cause errors otherwise. Fields that do not support ranges must be set
2008 * to 0 or to the same value as the corresponding fields in spec.
2010 * Only the fields defined to nonzero values in the default masks (see
2011 * rte_flow_item_{name}_mask constants) are considered relevant by
2012 * default. This can be overridden by providing a mask structure of the
2013 * same type with applicable bits set to one. It can also be used to
2014 * partially filter out specific fields (e.g. as an alternate mean to match
2015 * ranges of IP addresses).
2017 * Mask is a simple bit-mask applied before interpreting the contents of
2018 * spec and last, which may yield unexpected results if not used
2019 * carefully. For example, if for an IPv4 address field, spec provides
2020 * 10.1.2.3, last provides 10.3.4.5 and mask provides 255.255.0.0, the
2021 * effective range becomes 10.1.0.0 to 10.3.255.255.
2023 struct rte_flow_item {
2024 enum rte_flow_item_type type; /**< Item type. */
2025 const void *spec; /**< Pointer to item specification structure. */
2026 const void *last; /**< Defines an inclusive range (spec to last). */
2027 const void *mask; /**< Bit-mask applied to spec and last. */
2032 * @b EXPERIMENTAL: this structure may change without prior notice
2034 * RTE_FLOW_ITEM_TYPE_FLEX
2036 * Matches a specified set of fields within the network protocol
2037 * header. Each field is presented as set of bits with specified width, and
2038 * bit offset from the header beginning.
2040 * The pattern is concatenation of bit fields configured at item creation
2041 * by rte_flow_flex_item_create(). At configuration the fields are presented
2042 * by sample_data array.
2044 * This type does not support ranges (struct rte_flow_item.last).
2046 struct rte_flow_item_flex {
2047 struct rte_flow_item_flex_handle *handle; /**< Opaque item handle. */
2048 uint32_t length; /**< Pattern length in bytes. */
2049 const uint8_t *pattern; /**< Combined bitfields pattern to match. */
2052 * Field bit offset calculation mode.
2054 enum rte_flow_item_flex_field_mode {
2056 * Dummy field, used for byte boundary alignment in pattern.
2057 * Pattern mask and data are ignored in the match. All configuration
2058 * parameters besides field size are ignored.
2060 FIELD_MODE_DUMMY = 0,
2062 * Fixed offset field. The bit offset from header beginning
2063 * is permanent and defined by field_base parameter.
2067 * The field bit offset is extracted from other header field (indirect
2068 * offset field). The resulting field offset to match is calculated as:
2070 * field_base + (*offset_base & offset_mask) << offset_shift
2074 * The field bit offset is extracted from other header field (indirect
2075 * offset field), the latter is considered as bitmask containing some
2076 * number of one bits, the resulting field offset to match is
2079 * field_base + bitcount(*offset_base & offset_mask) << offset_shift
2085 * Flex item field tunnel mode
2087 enum rte_flow_item_flex_tunnel_mode {
2089 * The protocol header can be present in the packet only once.
2090 * No multiple flex item flow inclusions (for inner/outer) are allowed.
2091 * No any relations with tunnel protocols are imposed. The drivers
2092 * can optimize hardware resource usage to handle match on single flex
2093 * item of specific type.
2095 FLEX_TUNNEL_MODE_SINGLE = 0,
2097 * Flex item presents outer header only.
2099 FLEX_TUNNEL_MODE_OUTER,
2101 * Flex item presents inner header only.
2103 FLEX_TUNNEL_MODE_INNER,
2105 * Flex item presents either inner or outer header. The driver
2106 * handles as many multiple inners as hardware supports.
2108 FLEX_TUNNEL_MODE_MULTI,
2110 * Flex item presents tunnel protocol header.
2112 FLEX_TUNNEL_MODE_TUNNEL,
2118 * @b EXPERIMENTAL: this structure may change without prior notice
2121 struct rte_flow_item_flex_field {
2122 /** Defines how match field offset is calculated over the packet. */
2123 enum rte_flow_item_flex_field_mode field_mode;
2124 uint32_t field_size; /**< Field size in bits. */
2125 int32_t field_base; /**< Field offset in bits. */
2126 uint32_t offset_base; /**< Indirect offset field offset in bits. */
2127 uint32_t offset_mask; /**< Indirect offset field bit mask. */
2128 int32_t offset_shift; /**< Indirect offset multiply factor. */
2129 uint32_t field_id:16; /**< Device hint, for multiple items in flow. */
2130 uint32_t reserved:16; /**< Reserved field. */
2135 * @b EXPERIMENTAL: this structure may change without prior notice
2137 struct rte_flow_item_flex_link {
2139 * Preceding/following header. The item type must be always provided.
2140 * For preceding one item must specify the header value/mask to match
2141 * for the link be taken and start the flex item header parsing.
2143 struct rte_flow_item item;
2145 * Next field value to match to continue with one of the configured
2153 * @b EXPERIMENTAL: this structure may change without prior notice
2155 struct rte_flow_item_flex_conf {
2157 * Specifies the flex item and tunnel relations and tells the PMD
2158 * whether flex item can be used for inner, outer or both headers,
2159 * or whether flex item presents the tunnel protocol itself.
2161 enum rte_flow_item_flex_tunnel_mode tunnel;
2163 * The next header offset, it presents the network header size covered
2164 * by the flex item and can be obtained with all supported offset
2165 * calculating methods (fixed, dedicated field, bitmask, etc).
2167 struct rte_flow_item_flex_field next_header;
2169 * Specifies the next protocol field to match with link next protocol
2170 * values and continue packet parsing with matching link.
2172 struct rte_flow_item_flex_field next_protocol;
2174 * The fields will be sampled and presented for explicit match
2175 * with pattern in the rte_flow_flex_item. There can be multiple
2176 * fields descriptors, the number should be specified by nb_samples.
2178 struct rte_flow_item_flex_field *sample_data;
2179 /** Number of field descriptors in the sample_data array. */
2180 uint32_t nb_samples;
2182 * Input link defines the flex item relation with preceding
2183 * header. It specified the preceding item type and provides pattern
2184 * to match. The flex item will continue parsing and will provide the
2185 * data to flow match in case if there is the match with one of input
2188 struct rte_flow_item_flex_link *input_link;
2189 /** Number of link descriptors in the input link array. */
2192 * Output link defines the next protocol field value to match and
2193 * the following protocol header to continue packet parsing. Also
2194 * defines the tunnel-related behaviour.
2196 struct rte_flow_item_flex_link *output_link;
2197 /** Number of link descriptors in the output link array. */
2198 uint32_t nb_outputs;
2204 * Each possible action is represented by a type.
2205 * An action can have an associated configuration object.
2206 * Several actions combined in a list can be assigned
2207 * to a flow rule and are performed in order.
2209 * They fall in three categories:
2211 * - Actions that modify the fate of matching traffic, for instance by
2212 * dropping or assigning it a specific destination.
2214 * - Actions that modify matching traffic contents or its properties. This
2215 * includes adding/removing encapsulation, encryption, compression and
2218 * - Actions related to the flow rule itself, such as updating counters or
2219 * making it non-terminating.
2221 * Flow rules being terminating by default, not specifying any action of the
2222 * fate kind results in undefined behavior. This applies to both ingress and
2225 * PASSTHRU, when supported, makes a flow rule non-terminating.
2227 enum rte_flow_action_type {
2229 * End marker for action lists. Prevents further processing of
2230 * actions, thereby ending the list.
2232 * No associated configuration structure.
2234 RTE_FLOW_ACTION_TYPE_END,
2237 * Used as a placeholder for convenience. It is ignored and simply
2238 * discarded by PMDs.
2240 * No associated configuration structure.
2242 RTE_FLOW_ACTION_TYPE_VOID,
2245 * Leaves traffic up for additional processing by subsequent flow
2246 * rules; makes a flow rule non-terminating.
2248 * No associated configuration structure.
2250 RTE_FLOW_ACTION_TYPE_PASSTHRU,
2253 * RTE_FLOW_ACTION_TYPE_JUMP
2255 * Redirects packets to a group on the current device.
2257 * See struct rte_flow_action_jump.
2259 RTE_FLOW_ACTION_TYPE_JUMP,
2262 * Attaches an integer value to packets and sets RTE_MBUF_F_RX_FDIR and
2263 * RTE_MBUF_F_RX_FDIR_ID mbuf flags.
2265 * See struct rte_flow_action_mark.
2267 * One should negotiate mark delivery from the NIC to the PMD.
2268 * @see rte_eth_rx_metadata_negotiate()
2269 * @see RTE_ETH_RX_METADATA_USER_MARK
2271 RTE_FLOW_ACTION_TYPE_MARK,
2274 * Flags packets. Similar to MARK without a specific value; only
2275 * sets the RTE_MBUF_F_RX_FDIR mbuf flag.
2277 * No associated configuration structure.
2279 * One should negotiate flag delivery from the NIC to the PMD.
2280 * @see rte_eth_rx_metadata_negotiate()
2281 * @see RTE_ETH_RX_METADATA_USER_FLAG
2283 RTE_FLOW_ACTION_TYPE_FLAG,
2286 * Assigns packets to a given queue index.
2288 * See struct rte_flow_action_queue.
2290 RTE_FLOW_ACTION_TYPE_QUEUE,
2295 * PASSTHRU overrides this action if both are specified.
2297 * No associated configuration structure.
2299 RTE_FLOW_ACTION_TYPE_DROP,
2302 * Enables counters for this flow rule.
2304 * These counters can be retrieved and reset through rte_flow_query() or
2305 * rte_flow_action_handle_query() if the action provided via handle,
2306 * see struct rte_flow_query_count.
2308 * See struct rte_flow_action_count.
2310 RTE_FLOW_ACTION_TYPE_COUNT,
2313 * Similar to QUEUE, except RSS is additionally performed on packets
2314 * to spread them among several queues according to the provided
2317 * See struct rte_flow_action_rss.
2319 RTE_FLOW_ACTION_TYPE_RSS,
2323 * @see RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR
2324 * @see RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT
2326 * Directs matching traffic to the physical function (PF) of the
2329 * No associated configuration structure.
2331 RTE_FLOW_ACTION_TYPE_PF,
2335 * @see RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR
2336 * @see RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT
2338 * Directs matching traffic to a given virtual function of the
2341 * See struct rte_flow_action_vf.
2343 RTE_FLOW_ACTION_TYPE_VF,
2347 * @see RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR
2348 * @see RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT
2350 * Directs packets to a given physical port index of the underlying
2353 * See struct rte_flow_action_phy_port.
2355 RTE_FLOW_ACTION_TYPE_PHY_PORT,
2359 * @see RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR
2360 * @see RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT
2362 * Directs matching traffic to a given DPDK port ID.
2364 * See struct rte_flow_action_port_id.
2366 RTE_FLOW_ACTION_TYPE_PORT_ID,
2369 * Traffic metering and policing (MTR).
2371 * See struct rte_flow_action_meter.
2372 * See file rte_mtr.h for MTR object configuration.
2374 RTE_FLOW_ACTION_TYPE_METER,
2377 * Redirects packets to security engine of current device for security
2378 * processing as specified by security session.
2380 * See struct rte_flow_action_security.
2382 RTE_FLOW_ACTION_TYPE_SECURITY,
2386 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
2388 * Implements OFPAT_SET_MPLS_TTL ("MPLS TTL") as defined by the
2389 * OpenFlow Switch Specification.
2391 * See struct rte_flow_action_of_set_mpls_ttl.
2393 RTE_FLOW_ACTION_TYPE_OF_SET_MPLS_TTL,
2397 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
2399 * Implements OFPAT_DEC_MPLS_TTL ("decrement MPLS TTL") as defined
2400 * by the OpenFlow Switch Specification.
2402 * No associated configuration structure.
2404 RTE_FLOW_ACTION_TYPE_OF_DEC_MPLS_TTL,
2408 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
2410 * Implements OFPAT_SET_NW_TTL ("IP TTL") as defined by the OpenFlow
2411 * Switch Specification.
2413 * See struct rte_flow_action_of_set_nw_ttl.
2415 RTE_FLOW_ACTION_TYPE_OF_SET_NW_TTL,
2418 * @warning This is a legacy action.
2419 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
2421 * Implements OFPAT_DEC_NW_TTL ("decrement IP TTL") as defined by
2422 * the OpenFlow Switch Specification.
2424 * No associated configuration structure.
2426 RTE_FLOW_ACTION_TYPE_OF_DEC_NW_TTL,
2430 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
2432 * Implements OFPAT_COPY_TTL_OUT ("copy TTL "outwards" -- from
2433 * next-to-outermost to outermost") as defined by the OpenFlow
2434 * Switch Specification.
2436 * No associated configuration structure.
2438 RTE_FLOW_ACTION_TYPE_OF_COPY_TTL_OUT,
2442 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
2444 * Implements OFPAT_COPY_TTL_IN ("copy TTL "inwards" -- from
2445 * outermost to next-to-outermost") as defined by the OpenFlow
2446 * Switch Specification.
2448 * No associated configuration structure.
2450 RTE_FLOW_ACTION_TYPE_OF_COPY_TTL_IN,
2453 * Implements OFPAT_POP_VLAN ("pop the outer VLAN tag") as defined
2454 * by the OpenFlow Switch Specification.
2456 * No associated configuration structure.
2458 RTE_FLOW_ACTION_TYPE_OF_POP_VLAN,
2461 * Implements OFPAT_PUSH_VLAN ("push a new VLAN tag") as defined by
2462 * the OpenFlow Switch Specification.
2464 * See struct rte_flow_action_of_push_vlan.
2466 RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN,
2469 * Implements OFPAT_SET_VLAN_VID ("set the 802.1q VLAN ID") as
2470 * defined by the OpenFlow Switch Specification.
2472 * See struct rte_flow_action_of_set_vlan_vid.
2474 RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID,
2477 * Implements OFPAT_SET_LAN_PCP ("set the 802.1q priority") as
2478 * defined by the OpenFlow Switch Specification.
2480 * See struct rte_flow_action_of_set_vlan_pcp.
2482 RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP,
2485 * Implements OFPAT_POP_MPLS ("pop the outer MPLS tag") as defined
2486 * by the OpenFlow Switch Specification.
2488 * See struct rte_flow_action_of_pop_mpls.
2490 RTE_FLOW_ACTION_TYPE_OF_POP_MPLS,
2493 * Implements OFPAT_PUSH_MPLS ("push a new MPLS tag") as defined by
2494 * the OpenFlow Switch Specification.
2496 * See struct rte_flow_action_of_push_mpls.
2498 RTE_FLOW_ACTION_TYPE_OF_PUSH_MPLS,
2501 * Encapsulate flow in VXLAN tunnel as defined in
2502 * rte_flow_action_vxlan_encap action structure.
2504 * See struct rte_flow_action_vxlan_encap.
2506 RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP,
2509 * Decapsulate outer most VXLAN tunnel from matched flow.
2511 * If flow pattern does not define a valid VXLAN tunnel (as specified by
2512 * RFC7348) then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION
2515 RTE_FLOW_ACTION_TYPE_VXLAN_DECAP,
2518 * Encapsulate flow in NVGRE tunnel defined in the
2519 * rte_flow_action_nvgre_encap action structure.
2521 * See struct rte_flow_action_nvgre_encap.
2523 RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP,
2526 * Decapsulate outer most NVGRE tunnel from matched flow.
2528 * If flow pattern does not define a valid NVGRE tunnel (as specified by
2529 * RFC7637) then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION
2532 RTE_FLOW_ACTION_TYPE_NVGRE_DECAP,
2535 * Add outer header whose template is provided in its data buffer
2537 * See struct rte_flow_action_raw_encap.
2539 RTE_FLOW_ACTION_TYPE_RAW_ENCAP,
2542 * Remove outer header whose template is provided in its data buffer.
2544 * See struct rte_flow_action_raw_decap
2546 RTE_FLOW_ACTION_TYPE_RAW_DECAP,
2549 * @warning This is a legacy action.
2550 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
2552 * Modify IPv4 source address in the outermost IPv4 header.
2554 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV4,
2555 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2557 * See struct rte_flow_action_set_ipv4.
2559 RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC,
2562 * @warning This is a legacy action.
2563 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
2565 * Modify IPv4 destination address in the outermost IPv4 header.
2567 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV4,
2568 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2570 * See struct rte_flow_action_set_ipv4.
2572 RTE_FLOW_ACTION_TYPE_SET_IPV4_DST,
2575 * @warning This is a legacy action.
2576 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
2578 * Modify IPv6 source address in the outermost IPv6 header.
2580 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV6,
2581 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2583 * See struct rte_flow_action_set_ipv6.
2585 RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC,
2588 * @warning This is a legacy action.
2589 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
2591 * Modify IPv6 destination address in the outermost IPv6 header.
2593 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV6,
2594 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2596 * See struct rte_flow_action_set_ipv6.
2598 RTE_FLOW_ACTION_TYPE_SET_IPV6_DST,
2601 * @warning This is a legacy action.
2602 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
2604 * Modify source port number in the outermost TCP/UDP header.
2606 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_TCP
2607 * or RTE_FLOW_ITEM_TYPE_UDP, then the PMD should return a
2608 * RTE_FLOW_ERROR_TYPE_ACTION error.
2610 * See struct rte_flow_action_set_tp.
2612 RTE_FLOW_ACTION_TYPE_SET_TP_SRC,
2615 * @warning This is a legacy action.
2616 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
2618 * Modify destination port number in the outermost TCP/UDP header.
2620 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_TCP
2621 * or RTE_FLOW_ITEM_TYPE_UDP, then the PMD should return a
2622 * RTE_FLOW_ERROR_TYPE_ACTION error.
2624 * See struct rte_flow_action_set_tp.
2626 RTE_FLOW_ACTION_TYPE_SET_TP_DST,
2629 * Swap the source and destination MAC addresses in the outermost
2632 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_ETH,
2633 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2635 * No associated configuration structure.
2637 RTE_FLOW_ACTION_TYPE_MAC_SWAP,
2640 * @warning This is a legacy action.
2641 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
2643 * Decrease TTL value directly
2645 * No associated configuration structure.
2647 RTE_FLOW_ACTION_TYPE_DEC_TTL,
2650 * @warning This is a legacy action.
2651 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
2655 * See struct rte_flow_action_set_ttl
2657 RTE_FLOW_ACTION_TYPE_SET_TTL,
2660 * @warning This is a legacy action.
2661 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
2663 * Set source MAC address from matched flow.
2665 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_ETH,
2666 * the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2668 * See struct rte_flow_action_set_mac.
2670 RTE_FLOW_ACTION_TYPE_SET_MAC_SRC,
2673 * @warning This is a legacy action.
2674 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
2676 * Set destination MAC address from matched flow.
2678 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_ETH,
2679 * the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2681 * See struct rte_flow_action_set_mac.
2683 RTE_FLOW_ACTION_TYPE_SET_MAC_DST,
2686 * @warning This is a legacy action.
2687 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
2689 * Increase sequence number in the outermost TCP header.
2691 * Action configuration specifies the value to increase
2692 * TCP sequence number as a big-endian 32 bit integer.
2695 * @code rte_be32_t * @endcode
2697 * Using this action on non-matching traffic will result in
2698 * undefined behavior.
2700 RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ,
2703 * @warning This is a legacy action.
2704 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
2706 * Decrease sequence number in the outermost TCP header.
2708 * Action configuration specifies the value to decrease
2709 * TCP sequence number as a big-endian 32 bit integer.
2712 * @code rte_be32_t * @endcode
2714 * Using this action on non-matching traffic will result in
2715 * undefined behavior.
2717 RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ,
2720 * @warning This is a legacy action.
2721 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
2723 * Increase acknowledgment number in the outermost TCP header.
2725 * Action configuration specifies the value to increase
2726 * TCP acknowledgment number as a big-endian 32 bit integer.
2729 * @code rte_be32_t * @endcode
2731 * Using this action on non-matching traffic will result in
2732 * undefined behavior.
2734 RTE_FLOW_ACTION_TYPE_INC_TCP_ACK,
2737 * @warning This is a legacy action.
2738 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
2740 * Decrease acknowledgment number in the outermost TCP header.
2742 * Action configuration specifies the value to decrease
2743 * TCP acknowledgment number as a big-endian 32 bit integer.
2746 * @code rte_be32_t * @endcode
2748 * Using this action on non-matching traffic will result in
2749 * undefined behavior.
2751 RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK,
2754 * @warning This is a legacy action.
2755 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
2759 * Tag is for internal flow usage only and
2760 * is not delivered to the application.
2762 * See struct rte_flow_action_set_tag.
2764 RTE_FLOW_ACTION_TYPE_SET_TAG,
2767 * @warning This is a legacy action.
2768 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
2770 * Set metadata on ingress or egress path.
2772 * See struct rte_flow_action_set_meta.
2774 RTE_FLOW_ACTION_TYPE_SET_META,
2777 * @warning This is a legacy action.
2778 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
2780 * Modify IPv4 DSCP in the outermost IP header.
2782 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV4,
2783 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2785 * See struct rte_flow_action_set_dscp.
2787 RTE_FLOW_ACTION_TYPE_SET_IPV4_DSCP,
2790 * @warning This is a legacy action.
2791 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
2793 * Modify IPv6 DSCP in the outermost IP header.
2795 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV6,
2796 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2798 * See struct rte_flow_action_set_dscp.
2800 RTE_FLOW_ACTION_TYPE_SET_IPV6_DSCP,
2803 * Report as aged flow if timeout passed without any matching on the
2806 * See struct rte_flow_action_age.
2807 * See function rte_flow_get_aged_flows
2808 * see enum RTE_ETH_EVENT_FLOW_AGED
2809 * See struct rte_flow_query_age
2811 RTE_FLOW_ACTION_TYPE_AGE,
2814 * The matching packets will be duplicated with specified ratio and
2815 * applied with own set of actions with a fate action.
2817 * See struct rte_flow_action_sample.
2819 RTE_FLOW_ACTION_TYPE_SAMPLE,
2823 * @see RTE_FLOW_ACTION_TYPE_INDIRECT
2825 * Describe action shared across multiple flow rules.
2827 * Allow multiple rules reference the same action by handle (see
2828 * struct rte_flow_shared_action).
2830 RTE_FLOW_ACTION_TYPE_SHARED,
2833 * Modify a packet header field, tag, mark or metadata.
2835 * Allow the modification of an arbitrary header field via
2836 * set, add and sub operations or copying its content into
2837 * tag, meta or mark for future processing.
2839 * See struct rte_flow_action_modify_field.
2841 RTE_FLOW_ACTION_TYPE_MODIFY_FIELD,
2844 * An action handle is referenced in a rule through an indirect action.
2846 * The same action handle may be used in multiple rules for the same
2847 * or different ethdev ports.
2849 RTE_FLOW_ACTION_TYPE_INDIRECT,
2854 * Enable tracking a TCP connection state.
2856 * @see struct rte_flow_action_conntrack.
2858 RTE_FLOW_ACTION_TYPE_CONNTRACK,
2861 * Color the packet to reflect the meter color result.
2862 * Set the meter color in the mbuf to the selected color.
2864 * See struct rte_flow_action_meter_color.
2866 RTE_FLOW_ACTION_TYPE_METER_COLOR,
2869 * At embedded switch level, sends matching traffic to the given ethdev.
2871 * @see struct rte_flow_action_ethdev
2873 RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR,
2876 * At embedded switch level, send matching traffic to
2877 * the entity represented by the given ethdev.
2879 * @see struct rte_flow_action_ethdev
2881 RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT,
2885 * RTE_FLOW_ACTION_TYPE_MARK
2887 * Attaches an integer value to packets and sets RTE_MBUF_F_RX_FDIR and
2888 * RTE_MBUF_F_RX_FDIR_ID mbuf flags.
2890 * This value is arbitrary and application-defined. Maximum allowed value
2891 * depends on the underlying implementation. It is returned in the
2892 * hash.fdir.hi mbuf field.
2894 struct rte_flow_action_mark {
2895 uint32_t id; /**< Integer value to return with packets. */
2900 * @b EXPERIMENTAL: this structure may change without prior notice
2902 * RTE_FLOW_ACTION_TYPE_JUMP
2904 * Redirects packets to a group on the current device.
2906 * In a hierarchy of groups, which can be used to represent physical or logical
2907 * flow tables on the device, this action allows the action to be a redirect to
2908 * a group on that device.
2910 struct rte_flow_action_jump {
2915 * RTE_FLOW_ACTION_TYPE_QUEUE
2917 * Assign packets to a given queue index.
2919 struct rte_flow_action_queue {
2920 uint16_t index; /**< Queue index to use. */
2925 * @b EXPERIMENTAL: this structure may change without prior notice
2927 * RTE_FLOW_ACTION_TYPE_AGE
2929 * Report flow as aged-out if timeout passed without any matching
2930 * on the flow. RTE_ETH_EVENT_FLOW_AGED event is triggered when a
2931 * port detects new aged-out flows.
2933 * The flow context and the flow handle will be reported by the
2934 * rte_flow_get_aged_flows API.
2936 struct rte_flow_action_age {
2937 uint32_t timeout:24; /**< Time in seconds. */
2938 uint32_t reserved:8; /**< Reserved, must be zero. */
2939 /** The user flow context, NULL means the rte_flow pointer. */
2944 * RTE_FLOW_ACTION_TYPE_AGE (query)
2946 * Query structure to retrieve the aging status information of a
2947 * shared AGE action, or a flow rule using the AGE action.
2949 struct rte_flow_query_age {
2950 uint32_t reserved:6; /**< Reserved, must be zero. */
2951 uint32_t aged:1; /**< 1 if aging timeout expired, 0 otherwise. */
2952 /** sec_since_last_hit value is valid. */
2953 uint32_t sec_since_last_hit_valid:1;
2954 uint32_t sec_since_last_hit:24; /**< Seconds since last traffic hit. */
2959 * @b EXPERIMENTAL: this structure may change without prior notice
2961 * RTE_FLOW_ACTION_TYPE_COUNT
2963 * Adds a counter action to a matched flow.
2965 * If more than one count action is specified in a single flow rule, then each
2966 * action must specify a unique ID.
2968 * Counters can be retrieved and reset through ``rte_flow_query()``, see
2969 * ``struct rte_flow_query_count``.
2971 * For ports within the same switch domain then the counter ID namespace extends
2972 * to all ports within that switch domain.
2974 struct rte_flow_action_count {
2975 uint32_t id; /**< Counter ID. */
2979 * RTE_FLOW_ACTION_TYPE_COUNT (query)
2981 * Query structure to retrieve and reset flow rule counters.
2983 struct rte_flow_query_count {
2984 uint32_t reset:1; /**< Reset counters after query [in]. */
2985 uint32_t hits_set:1; /**< hits field is set [out]. */
2986 uint32_t bytes_set:1; /**< bytes field is set [out]. */
2987 uint32_t reserved:29; /**< Reserved, must be zero [in, out]. */
2988 uint64_t hits; /**< Number of hits for this rule [out]. */
2989 uint64_t bytes; /**< Number of bytes through this rule [out]. */
2993 * Hash function types.
2995 enum rte_eth_hash_function {
2996 RTE_ETH_HASH_FUNCTION_DEFAULT = 0,
2997 RTE_ETH_HASH_FUNCTION_TOEPLITZ, /**< Toeplitz */
2998 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR, /**< Simple XOR */
3000 * Symmetric Toeplitz: src, dst will be replaced by
3001 * xor(src, dst). For the case with src/dst only,
3002 * src or dst address will xor with zero pair.
3004 RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ,
3005 RTE_ETH_HASH_FUNCTION_MAX,
3009 * RTE_FLOW_ACTION_TYPE_RSS
3011 * Similar to QUEUE, except RSS is additionally performed on packets to
3012 * spread them among several queues according to the provided parameters.
3014 * Unlike global RSS settings used by other DPDK APIs, unsetting the
3015 * @p types field does not disable RSS in a flow rule. Doing so instead
3016 * requests safe unspecified "best-effort" settings from the underlying PMD,
3017 * which depending on the flow rule, may result in anything ranging from
3018 * empty (single queue) to all-inclusive RSS.
3020 * Note: RSS hash result is stored in the hash.rss mbuf field which overlaps
3021 * hash.fdir.lo. Since the MARK action sets the hash.fdir.hi field only,
3022 * both can be requested simultaneously.
3024 struct rte_flow_action_rss {
3025 enum rte_eth_hash_function func; /**< RSS hash function to apply. */
3027 * Packet encapsulation level RSS hash @p types apply to.
3029 * - @p 0 requests the default behavior. Depending on the packet
3030 * type, it can mean outermost, innermost, anything in between or
3033 * It basically stands for the innermost encapsulation level RSS
3034 * can be performed on according to PMD and device capabilities.
3036 * - @p 1 requests RSS to be performed on the outermost packet
3037 * encapsulation level.
3039 * - @p 2 and subsequent values request RSS to be performed on the
3040 * specified inner packet encapsulation level, from outermost to
3041 * innermost (lower to higher values).
3043 * Values other than @p 0 are not necessarily supported.
3045 * Requesting a specific RSS level on unrecognized traffic results
3046 * in undefined behavior. For predictable results, it is recommended
3047 * to make the flow rule pattern match packet headers up to the
3048 * requested encapsulation level so that only matching traffic goes
3052 uint64_t types; /**< Specific RSS hash types (see RTE_ETH_RSS_*). */
3053 uint32_t key_len; /**< Hash key length in bytes. */
3054 uint32_t queue_num; /**< Number of entries in @p queue. */
3055 const uint8_t *key; /**< Hash key. */
3056 const uint16_t *queue; /**< Queue indices to use. */
3061 * @see RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR
3062 * @see RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT
3064 * RTE_FLOW_ACTION_TYPE_VF
3066 * Directs matching traffic to a given virtual function of the current
3069 * Packets matched by a VF pattern item can be redirected to their original
3070 * VF ID instead of the specified one. This parameter may not be available
3071 * and is not guaranteed to work properly if the VF part is matched by a
3072 * prior flow rule or if packets are not addressed to a VF in the first
3075 struct rte_flow_action_vf {
3076 uint32_t original:1; /**< Use original VF ID if possible. */
3077 uint32_t reserved:31; /**< Reserved, must be zero. */
3078 uint32_t id; /**< VF ID. */
3083 * @see RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR
3084 * @see RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT
3086 * RTE_FLOW_ACTION_TYPE_PHY_PORT
3088 * Directs packets to a given physical port index of the underlying
3091 * @see RTE_FLOW_ITEM_TYPE_PHY_PORT
3093 struct rte_flow_action_phy_port {
3094 uint32_t original:1; /**< Use original port index if possible. */
3095 uint32_t reserved:31; /**< Reserved, must be zero. */
3096 uint32_t index; /**< Physical port index. */
3101 * @see RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR
3102 * @see RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT
3104 * RTE_FLOW_ACTION_TYPE_PORT_ID
3106 * Directs matching traffic to a given DPDK port ID.
3108 * @see RTE_FLOW_ITEM_TYPE_PORT_ID
3110 struct rte_flow_action_port_id {
3111 uint32_t original:1; /**< Use original DPDK port ID if possible. */
3112 uint32_t reserved:31; /**< Reserved, must be zero. */
3113 uint32_t id; /**< DPDK port ID. */
3117 * RTE_FLOW_ACTION_TYPE_METER
3119 * Traffic metering and policing (MTR).
3121 * Packets matched by items of this type can be either dropped or passed to the
3122 * next item with their color set by the MTR object.
3124 struct rte_flow_action_meter {
3125 uint32_t mtr_id; /**< MTR object ID created with rte_mtr_create(). */
3129 * RTE_FLOW_ACTION_TYPE_SECURITY
3131 * Perform the security action on flows matched by the pattern items
3132 * according to the configuration of the security session.
3134 * This action modifies the payload of matched flows. For INLINE_CRYPTO, the
3135 * security protocol headers and IV are fully provided by the application as
3136 * specified in the flow pattern. The payload of matching packets is
3137 * encrypted on egress, and decrypted and authenticated on ingress.
3138 * For INLINE_PROTOCOL, the security protocol is fully offloaded to HW,
3139 * providing full encapsulation and decapsulation of packets in security
3140 * protocols. The flow pattern specifies both the outer security header fields
3141 * and the inner packet fields. The security session specified in the action
3142 * must match the pattern parameters.
3144 * The security session specified in the action must be created on the same
3145 * port as the flow action that is being specified.
3147 * The ingress/egress flow attribute should match that specified in the
3148 * security session if the security session supports the definition of the
3151 * Multiple flows can be configured to use the same security session.
3153 * The NULL value is allowed for security session. If security session is NULL,
3154 * then SPI field in ESP flow item and IP addresses in flow items 'IPv4' and
3155 * 'IPv6' will be allowed to be a range. The rule thus created can enable
3156 * security processing on multiple flows.
3158 struct rte_flow_action_security {
3159 void *security_session; /**< Pointer to security session structure. */
3164 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
3166 * RTE_FLOW_ACTION_TYPE_OF_SET_MPLS_TTL
3168 * Implements OFPAT_SET_MPLS_TTL ("MPLS TTL") as defined by the OpenFlow
3169 * Switch Specification.
3171 struct rte_flow_action_of_set_mpls_ttl {
3172 uint8_t mpls_ttl; /**< MPLS TTL. */
3177 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
3179 * RTE_FLOW_ACTION_TYPE_OF_SET_NW_TTL
3181 * Implements OFPAT_SET_NW_TTL ("IP TTL") as defined by the OpenFlow Switch
3184 struct rte_flow_action_of_set_nw_ttl {
3185 uint8_t nw_ttl; /**< IP TTL. */
3189 * RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN
3191 * Implements OFPAT_PUSH_VLAN ("push a new VLAN tag") as defined by the
3192 * OpenFlow Switch Specification.
3194 struct rte_flow_action_of_push_vlan {
3195 rte_be16_t ethertype; /**< EtherType. */
3199 * RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID
3201 * Implements OFPAT_SET_VLAN_VID ("set the 802.1q VLAN ID") as defined by
3202 * the OpenFlow Switch Specification.
3204 struct rte_flow_action_of_set_vlan_vid {
3205 rte_be16_t vlan_vid; /**< VLAN ID. */
3209 * RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP
3211 * Implements OFPAT_SET_LAN_PCP ("set the 802.1q priority") as defined by
3212 * the OpenFlow Switch Specification.
3214 struct rte_flow_action_of_set_vlan_pcp {
3215 uint8_t vlan_pcp; /**< VLAN priority. */
3219 * RTE_FLOW_ACTION_TYPE_OF_POP_MPLS
3221 * Implements OFPAT_POP_MPLS ("pop the outer MPLS tag") as defined by the
3222 * OpenFlow Switch Specification.
3224 struct rte_flow_action_of_pop_mpls {
3225 rte_be16_t ethertype; /**< EtherType. */
3229 * RTE_FLOW_ACTION_TYPE_OF_PUSH_MPLS
3231 * Implements OFPAT_PUSH_MPLS ("push a new MPLS tag") as defined by the
3232 * OpenFlow Switch Specification.
3234 struct rte_flow_action_of_push_mpls {
3235 rte_be16_t ethertype; /**< EtherType. */
3240 * @b EXPERIMENTAL: this structure may change without prior notice
3242 * RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP
3244 * VXLAN tunnel end-point encapsulation data definition
3246 * The tunnel definition is provided through the flow item pattern, the
3247 * provided pattern must conform to RFC7348 for the tunnel specified. The flow
3248 * definition must be provided in order from the RTE_FLOW_ITEM_TYPE_ETH
3249 * definition up the end item which is specified by RTE_FLOW_ITEM_TYPE_END.
3251 * The mask field allows user to specify which fields in the flow item
3252 * definitions can be ignored and which have valid data and can be used
3255 * Note: the last field is not used in the definition of a tunnel and can be
3258 * Valid flow definition for RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP include:
3260 * - ETH / IPV4 / UDP / VXLAN / END
3261 * - ETH / IPV6 / UDP / VXLAN / END
3262 * - ETH / VLAN / IPV4 / UDP / VXLAN / END
3265 struct rte_flow_action_vxlan_encap {
3267 * Encapsulating vxlan tunnel definition
3268 * (terminated by the END pattern item).
3270 struct rte_flow_item *definition;
3275 * @b EXPERIMENTAL: this structure may change without prior notice
3277 * RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP
3279 * NVGRE tunnel end-point encapsulation data definition
3281 * The tunnel definition is provided through the flow item pattern the
3282 * provided pattern must conform with RFC7637. The flow definition must be
3283 * provided in order from the RTE_FLOW_ITEM_TYPE_ETH definition up the end item
3284 * which is specified by RTE_FLOW_ITEM_TYPE_END.
3286 * The mask field allows user to specify which fields in the flow item
3287 * definitions can be ignored and which have valid data and can be used
3290 * Note: the last field is not used in the definition of a tunnel and can be
3293 * Valid flow definition for RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP include:
3295 * - ETH / IPV4 / NVGRE / END
3296 * - ETH / VLAN / IPV6 / NVGRE / END
3299 struct rte_flow_action_nvgre_encap {
3301 * Encapsulating vxlan tunnel definition
3302 * (terminated by the END pattern item).
3304 struct rte_flow_item *definition;
3309 * @b EXPERIMENTAL: this structure may change without prior notice
3311 * RTE_FLOW_ACTION_TYPE_RAW_ENCAP
3313 * Raw tunnel end-point encapsulation data definition.
3315 * The data holds the headers definitions to be applied on the packet.
3316 * The data must start with ETH header up to the tunnel item header itself.
3317 * When used right after RAW_DECAP (for decapsulating L3 tunnel type for
3318 * example MPLSoGRE) the data will just hold layer 2 header.
3320 * The preserve parameter holds which bits in the packet the PMD is not allowed
3321 * to change, this parameter can also be NULL and then the PMD is allowed
3322 * to update any field.
3324 * size holds the number of bytes in @p data and @p preserve.
3326 struct rte_flow_action_raw_encap {
3327 uint8_t *data; /**< Encapsulation data. */
3328 uint8_t *preserve; /**< Bit-mask of @p data to preserve on output. */
3329 size_t size; /**< Size of @p data and @p preserve. */
3334 * @b EXPERIMENTAL: this structure may change without prior notice
3336 * RTE_FLOW_ACTION_TYPE_RAW_DECAP
3338 * Raw tunnel end-point decapsulation data definition.
3340 * The data holds the headers definitions to be removed from the packet.
3341 * The data must start with ETH header up to the tunnel item header itself.
3342 * When used right before RAW_DECAP (for encapsulating L3 tunnel type for
3343 * example MPLSoGRE) the data will just hold layer 2 header.
3345 * size holds the number of bytes in @p data.
3347 struct rte_flow_action_raw_decap {
3348 uint8_t *data; /**< Encapsulation data. */
3349 size_t size; /**< Size of @p data and @p preserve. */
3354 * @b EXPERIMENTAL: this structure may change without prior notice
3356 * RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC
3357 * RTE_FLOW_ACTION_TYPE_SET_IPV4_DST
3359 * Allows modification of IPv4 source (RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC)
3360 * and destination address (RTE_FLOW_ACTION_TYPE_SET_IPV4_DST) in the
3361 * specified outermost IPv4 header.
3363 struct rte_flow_action_set_ipv4 {
3364 rte_be32_t ipv4_addr;
3369 * @b EXPERIMENTAL: this structure may change without prior notice
3371 * RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC
3372 * RTE_FLOW_ACTION_TYPE_SET_IPV6_DST
3374 * Allows modification of IPv6 source (RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC)
3375 * and destination address (RTE_FLOW_ACTION_TYPE_SET_IPV6_DST) in the
3376 * specified outermost IPv6 header.
3378 struct rte_flow_action_set_ipv6 {
3379 uint8_t ipv6_addr[16];
3384 * @b EXPERIMENTAL: this structure may change without prior notice
3386 * RTE_FLOW_ACTION_TYPE_SET_TP_SRC
3387 * RTE_FLOW_ACTION_TYPE_SET_TP_DST
3389 * Allows modification of source (RTE_FLOW_ACTION_TYPE_SET_TP_SRC)
3390 * and destination (RTE_FLOW_ACTION_TYPE_SET_TP_DST) port numbers
3391 * in the specified outermost TCP/UDP header.
3393 struct rte_flow_action_set_tp {
3398 * RTE_FLOW_ACTION_TYPE_SET_TTL
3400 * Set the TTL value directly for IPv4 or IPv6
3402 struct rte_flow_action_set_ttl {
3407 * RTE_FLOW_ACTION_TYPE_SET_MAC
3409 * Set MAC address from the matched flow
3411 struct rte_flow_action_set_mac {
3412 uint8_t mac_addr[RTE_ETHER_ADDR_LEN];
3417 * @b EXPERIMENTAL: this structure may change without prior notice
3419 * RTE_FLOW_ACTION_TYPE_SET_TAG
3421 * Set a tag which is a transient data used during flow matching. This is not
3422 * delivered to application. Multiple tags are supported by specifying index.
3424 struct rte_flow_action_set_tag {
3432 * @b EXPERIMENTAL: this structure may change without prior notice
3434 * RTE_FLOW_ACTION_TYPE_SET_META
3436 * Set metadata. Metadata set by mbuf metadata dynamic field with
3437 * RTE_MBUF_DYNFLAG_TX_METADATA flag on egress will be overridden by this
3438 * action. On ingress, the metadata will be carried by mbuf metadata dynamic
3439 * field with RTE_MBUF_DYNFLAG_RX_METADATA flag if set. The dynamic mbuf field
3440 * must be registered in advance by rte_flow_dynf_metadata_register().
3442 * Altering partial bits is supported with mask. For bits which have never
3443 * been set, unpredictable value will be seen depending on driver
3444 * implementation. For loopback/hairpin packet, metadata set on Rx/Tx may
3445 * or may not be propagated to the other path depending on HW capability.
3447 * RTE_FLOW_ITEM_TYPE_META matches metadata.
3449 struct rte_flow_action_set_meta {
3455 * RTE_FLOW_ACTION_TYPE_SET_IPV4_DSCP
3456 * RTE_FLOW_ACTION_TYPE_SET_IPV6_DSCP
3458 * Set the DSCP value for IPv4/IPv6 header.
3459 * DSCP in low 6 bits, rest ignored.
3461 struct rte_flow_action_set_dscp {
3467 * @b EXPERIMENTAL: this structure may change without prior notice
3469 * RTE_FLOW_ACTION_TYPE_INDIRECT
3471 * Opaque type returned after successfully creating an indirect action object.
3472 * The definition of the object handle is different per driver or
3473 * per direct action type.
3475 * This handle can be used to manage and query the related direct action:
3476 * - referenced in single flow rule or across multiple flow rules
3477 * over multiple ports
3478 * - update action object configuration
3479 * - query action object data
3480 * - destroy action object
3482 struct rte_flow_action_handle;
3485 * The state of a TCP connection.
3487 enum rte_flow_conntrack_state {
3488 /** SYN-ACK packet was seen. */
3489 RTE_FLOW_CONNTRACK_STATE_SYN_RECV,
3490 /** 3-way handshake was done. */
3491 RTE_FLOW_CONNTRACK_STATE_ESTABLISHED,
3492 /** First FIN packet was received to close the connection. */
3493 RTE_FLOW_CONNTRACK_STATE_FIN_WAIT,
3494 /** First FIN was ACKed. */
3495 RTE_FLOW_CONNTRACK_STATE_CLOSE_WAIT,
3496 /** Second FIN was received, waiting for the last ACK. */
3497 RTE_FLOW_CONNTRACK_STATE_LAST_ACK,
3498 /** Second FIN was ACKed, connection was closed. */
3499 RTE_FLOW_CONNTRACK_STATE_TIME_WAIT,
3503 * The last passed TCP packet flags of a connection.
3505 enum rte_flow_conntrack_tcp_last_index {
3506 RTE_FLOW_CONNTRACK_FLAG_NONE = 0, /**< No Flag. */
3507 RTE_FLOW_CONNTRACK_FLAG_SYN = RTE_BIT32(0), /**< With SYN flag. */
3508 RTE_FLOW_CONNTRACK_FLAG_SYNACK = RTE_BIT32(1), /**< With SYNACK flag. */
3509 RTE_FLOW_CONNTRACK_FLAG_FIN = RTE_BIT32(2), /**< With FIN flag. */
3510 RTE_FLOW_CONNTRACK_FLAG_ACK = RTE_BIT32(3), /**< With ACK flag. */
3511 RTE_FLOW_CONNTRACK_FLAG_RST = RTE_BIT32(4), /**< With RST flag. */
3516 * @b EXPERIMENTAL: this structure may change without prior notice
3518 * Configuration parameters for each direction of a TCP connection.
3519 * All fields should be in host byte order.
3520 * If needed, driver should convert all fields to network byte order
3521 * if HW needs them in that way.
3523 struct rte_flow_tcp_dir_param {
3524 /** TCP window scaling factor, 0xF to disable. */
3526 /** The FIN was sent by this direction. */
3527 uint32_t close_initiated:1;
3528 /** An ACK packet has been received by this side. */
3529 uint32_t last_ack_seen:1;
3531 * If set, it indicates that there is unacknowledged data for the
3532 * packets sent from this direction.
3534 uint32_t data_unacked:1;
3536 * Maximal value of sequence + payload length in sent
3537 * packets (next ACK from the opposite direction).
3541 * Maximal value of (ACK + window size) in received packet + length
3542 * over sent packet (maximal sequence could be sent).
3545 /** Maximal value of actual window size in sent packets. */
3547 /** Maximal value of ACK in sent packets. */
3553 * @b EXPERIMENTAL: this structure may change without prior notice
3555 * RTE_FLOW_ACTION_TYPE_CONNTRACK
3557 * Configuration and initial state for the connection tracking module.
3558 * This structure could be used for both setting and query.
3559 * All fields should be in host byte order.
3561 struct rte_flow_action_conntrack {
3562 /** The peer port number, can be the same port. */
3565 * Direction of this connection when creating a flow rule, the
3566 * value only affects the creation of subsequent flow rules.
3568 uint32_t is_original_dir:1;
3570 * Enable / disable the conntrack HW module. When disabled, the
3571 * result will always be RTE_FLOW_CONNTRACK_FLAG_DISABLED.
3572 * In this state the HW will act as passthrough.
3573 * It only affects this conntrack object in the HW without any effect
3574 * to the other objects.
3577 /** At least one ack was seen after the connection was established. */
3578 uint32_t live_connection:1;
3579 /** Enable selective ACK on this connection. */
3580 uint32_t selective_ack:1;
3581 /** A challenge ack has passed. */
3582 uint32_t challenge_ack_passed:1;
3584 * 1: The last packet is seen from the original direction.
3585 * 0: The last packet is seen from the reply direction.
3587 uint32_t last_direction:1;
3588 /** No TCP check will be done except the state change. */
3589 uint32_t liberal_mode:1;
3590 /** The current state of this connection. */
3591 enum rte_flow_conntrack_state state;
3592 /** Scaling factor for maximal allowed ACK window. */
3593 uint8_t max_ack_window;
3594 /** Maximal allowed number of retransmission times. */
3595 uint8_t retransmission_limit;
3596 /** TCP parameters of the original direction. */
3597 struct rte_flow_tcp_dir_param original_dir;
3598 /** TCP parameters of the reply direction. */
3599 struct rte_flow_tcp_dir_param reply_dir;
3600 /** The window value of the last packet passed this conntrack. */
3601 uint16_t last_window;
3602 enum rte_flow_conntrack_tcp_last_index last_index;
3603 /** The sequence of the last packet passed this conntrack. */
3605 /** The acknowledgment of the last packet passed this conntrack. */
3608 * The total value ACK + payload length of the last packet
3609 * passed this conntrack.
3615 * RTE_FLOW_ACTION_TYPE_CONNTRACK
3617 * Wrapper structure for the context update interface.
3618 * Ports cannot support updating, and the only valid solution is to
3619 * destroy the old context and create a new one instead.
3621 struct rte_flow_modify_conntrack {
3622 /** New connection tracking parameters to be updated. */
3623 struct rte_flow_action_conntrack new_ct;
3624 /** The direction field will be updated. */
3625 uint32_t direction:1;
3626 /** All the other fields except direction will be updated. */
3628 /** Reserved bits for the future usage. */
3629 uint32_t reserved:30;
3634 * @b EXPERIMENTAL: this structure may change without prior notice
3636 * RTE_FLOW_ACTION_TYPE_METER_COLOR
3638 * The meter color should be set in the packet meta-data
3639 * (i.e. struct rte_mbuf::sched::color).
3641 struct rte_flow_action_meter_color {
3642 enum rte_color color; /**< Packet color. */
3647 * @b EXPERIMENTAL: this structure may change without prior notice
3649 * Provides an ethdev port ID for use with the following actions:
3650 * RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR,
3651 * RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT.
3653 struct rte_flow_action_ethdev {
3654 uint16_t port_id; /**< ethdev port ID */
3658 * Field IDs for MODIFY_FIELD action.
3660 enum rte_flow_field_id {
3661 RTE_FLOW_FIELD_START = 0, /**< Start of a packet. */
3662 RTE_FLOW_FIELD_MAC_DST, /**< Destination MAC Address. */
3663 RTE_FLOW_FIELD_MAC_SRC, /**< Source MAC Address. */
3664 RTE_FLOW_FIELD_VLAN_TYPE, /**< 802.1Q Tag Identifier. */
3665 RTE_FLOW_FIELD_VLAN_ID, /**< 802.1Q VLAN Identifier. */
3666 RTE_FLOW_FIELD_MAC_TYPE, /**< EtherType. */
3667 RTE_FLOW_FIELD_IPV4_DSCP, /**< IPv4 DSCP. */
3668 RTE_FLOW_FIELD_IPV4_TTL, /**< IPv4 Time To Live. */
3669 RTE_FLOW_FIELD_IPV4_SRC, /**< IPv4 Source Address. */
3670 RTE_FLOW_FIELD_IPV4_DST, /**< IPv4 Destination Address. */
3671 RTE_FLOW_FIELD_IPV6_DSCP, /**< IPv6 DSCP. */
3672 RTE_FLOW_FIELD_IPV6_HOPLIMIT, /**< IPv6 Hop Limit. */
3673 RTE_FLOW_FIELD_IPV6_SRC, /**< IPv6 Source Address. */
3674 RTE_FLOW_FIELD_IPV6_DST, /**< IPv6 Destination Address. */
3675 RTE_FLOW_FIELD_TCP_PORT_SRC, /**< TCP Source Port Number. */
3676 RTE_FLOW_FIELD_TCP_PORT_DST, /**< TCP Destination Port Number. */
3677 RTE_FLOW_FIELD_TCP_SEQ_NUM, /**< TCP Sequence Number. */
3678 RTE_FLOW_FIELD_TCP_ACK_NUM, /**< TCP Acknowledgment Number. */
3679 RTE_FLOW_FIELD_TCP_FLAGS, /**< TCP Flags. */
3680 RTE_FLOW_FIELD_UDP_PORT_SRC, /**< UDP Source Port Number. */
3681 RTE_FLOW_FIELD_UDP_PORT_DST, /**< UDP Destination Port Number. */
3682 RTE_FLOW_FIELD_VXLAN_VNI, /**< VXLAN Network Identifier. */
3683 RTE_FLOW_FIELD_GENEVE_VNI, /**< GENEVE Network Identifier. */
3684 RTE_FLOW_FIELD_GTP_TEID, /**< GTP Tunnel Endpoint Identifier. */
3685 RTE_FLOW_FIELD_TAG, /**< Tag value. */
3686 RTE_FLOW_FIELD_MARK, /**< Mark value. */
3687 RTE_FLOW_FIELD_META, /**< Metadata value. */
3688 RTE_FLOW_FIELD_POINTER, /**< Memory pointer. */
3689 RTE_FLOW_FIELD_VALUE, /**< Immediate value. */
3690 RTE_FLOW_FIELD_IPV4_ECN, /**< IPv4 ECN. */
3691 RTE_FLOW_FIELD_IPV6_ECN, /**< IPv6 ECN. */
3696 * @b EXPERIMENTAL: this structure may change without prior notice
3698 * Field description for MODIFY_FIELD action.
3700 struct rte_flow_action_modify_data {
3701 enum rte_flow_field_id field; /**< Field or memory type ID. */
3705 /** Encapsulation level or tag index. */
3707 /** Number of bits to skip from a field. */
3711 * Immediate value for RTE_FLOW_FIELD_VALUE, presented in the
3712 * same byte order and length as in relevant rte_flow_item_xxx.
3713 * The immediate source bitfield offset is inherited from
3714 * the destination's one.
3718 * Memory address for RTE_FLOW_FIELD_POINTER, memory layout
3719 * should be the same as for relevant field in the
3720 * rte_flow_item_xxx structure.
3727 * Operation types for MODIFY_FIELD action.
3729 enum rte_flow_modify_op {
3730 RTE_FLOW_MODIFY_SET = 0, /**< Set a new value. */
3731 RTE_FLOW_MODIFY_ADD, /**< Add a value to a field. */
3732 RTE_FLOW_MODIFY_SUB, /**< Subtract a value from a field. */
3737 * @b EXPERIMENTAL: this structure may change without prior notice
3739 * RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
3741 * Modify a destination header field according to the specified
3742 * operation. Another field of the packet can be used as a source as well
3743 * as tag, mark, metadata, immediate value or a pointer to it.
3745 struct rte_flow_action_modify_field {
3746 enum rte_flow_modify_op operation; /**< Operation to perform. */
3747 struct rte_flow_action_modify_data dst; /**< Destination field. */
3748 struct rte_flow_action_modify_data src; /**< Source field. */
3749 uint32_t width; /**< Number of bits to use from a source field. */
3752 /* Mbuf dynamic field offset for metadata. */
3753 extern int32_t rte_flow_dynf_metadata_offs;
3755 /* Mbuf dynamic field flag mask for metadata. */
3756 extern uint64_t rte_flow_dynf_metadata_mask;
3758 /* Mbuf dynamic field pointer for metadata. */
3759 #define RTE_FLOW_DYNF_METADATA(m) \
3760 RTE_MBUF_DYNFIELD((m), rte_flow_dynf_metadata_offs, uint32_t *)
3762 /* Mbuf dynamic flags for metadata. */
3763 #define RTE_MBUF_DYNFLAG_RX_METADATA (rte_flow_dynf_metadata_mask)
3764 #define PKT_RX_DYNF_METADATA RTE_DEPRECATED(PKT_RX_DYNF_METADATA) \
3765 RTE_MBUF_DYNFLAG_RX_METADATA
3766 #define RTE_MBUF_DYNFLAG_TX_METADATA (rte_flow_dynf_metadata_mask)
3767 #define PKT_TX_DYNF_METADATA RTE_DEPRECATED(PKT_TX_DYNF_METADATA) \
3768 RTE_MBUF_DYNFLAG_TX_METADATA
3771 static inline uint32_t
3772 rte_flow_dynf_metadata_get(struct rte_mbuf *m)
3774 return *RTE_FLOW_DYNF_METADATA(m);
3779 rte_flow_dynf_metadata_set(struct rte_mbuf *m, uint32_t v)
3781 *RTE_FLOW_DYNF_METADATA(m) = v;
3785 * Definition of a single action.
3787 * A list of actions is terminated by a END action.
3789 * For simple actions without a configuration object, conf remains NULL.
3791 struct rte_flow_action {
3792 enum rte_flow_action_type type; /**< Action type. */
3793 const void *conf; /**< Pointer to action configuration object. */
3797 * Opaque type returned after successfully creating a flow.
3799 * This handle can be used to manage and query the related flow (e.g. to
3800 * destroy it or retrieve counters).
3806 * @b EXPERIMENTAL: this structure may change without prior notice
3808 * RTE_FLOW_ACTION_TYPE_SAMPLE
3810 * Adds a sample action to a matched flow.
3812 * The matching packets will be duplicated with specified ratio and applied
3813 * with own set of actions with a fate action, the sampled packet could be
3814 * redirected to queue or port. All the packets continue processing on the
3815 * default flow path.
3817 * When the sample ratio is set to 1 then the packets will be 100% mirrored.
3818 * Additional action list be supported to add for sampled or mirrored packets.
3820 struct rte_flow_action_sample {
3821 uint32_t ratio; /**< packets sampled equals to '1/ratio'. */
3822 /** sub-action list specific for the sampling hit cases. */
3823 const struct rte_flow_action *actions;
3827 * Verbose error types.
3829 * Most of them provide the type of the object referenced by struct
3830 * rte_flow_error.cause.
3832 enum rte_flow_error_type {
3833 RTE_FLOW_ERROR_TYPE_NONE, /**< No error. */
3834 RTE_FLOW_ERROR_TYPE_UNSPECIFIED, /**< Cause unspecified. */
3835 RTE_FLOW_ERROR_TYPE_HANDLE, /**< Flow rule (handle). */
3836 RTE_FLOW_ERROR_TYPE_ATTR_GROUP, /**< Group field. */
3837 RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY, /**< Priority field. */
3838 RTE_FLOW_ERROR_TYPE_ATTR_INGRESS, /**< Ingress field. */
3839 RTE_FLOW_ERROR_TYPE_ATTR_EGRESS, /**< Egress field. */
3840 RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, /**< Transfer field. */
3841 RTE_FLOW_ERROR_TYPE_ATTR, /**< Attributes structure. */
3842 RTE_FLOW_ERROR_TYPE_ITEM_NUM, /**< Pattern length. */
3843 RTE_FLOW_ERROR_TYPE_ITEM_SPEC, /**< Item specification. */
3844 RTE_FLOW_ERROR_TYPE_ITEM_LAST, /**< Item specification range. */
3845 RTE_FLOW_ERROR_TYPE_ITEM_MASK, /**< Item specification mask. */
3846 RTE_FLOW_ERROR_TYPE_ITEM, /**< Specific pattern item. */
3847 RTE_FLOW_ERROR_TYPE_ACTION_NUM, /**< Number of actions. */
3848 RTE_FLOW_ERROR_TYPE_ACTION_CONF, /**< Action configuration. */
3849 RTE_FLOW_ERROR_TYPE_ACTION, /**< Specific action. */
3850 RTE_FLOW_ERROR_TYPE_STATE, /**< Current device state. */
3854 * Verbose error structure definition.
3856 * This object is normally allocated by applications and set by PMDs, the
3857 * message points to a constant string which does not need to be freed by
3858 * the application, however its pointer can be considered valid only as long
3859 * as its associated DPDK port remains configured. Closing the underlying
3860 * device or unloading the PMD invalidates it.
3862 * Both cause and message may be NULL regardless of the error type.
3864 struct rte_flow_error {
3865 enum rte_flow_error_type type; /**< Cause field and error types. */
3866 const void *cause; /**< Object responsible for the error. */
3867 const char *message; /**< Human-readable error message. */
3871 * Complete flow rule description.
3873 * This object type is used when converting a flow rule description.
3875 * @see RTE_FLOW_CONV_OP_RULE
3876 * @see rte_flow_conv()
3879 struct rte_flow_conv_rule {
3881 const struct rte_flow_attr *attr_ro; /**< RO attributes. */
3882 struct rte_flow_attr *attr; /**< Attributes. */
3885 const struct rte_flow_item *pattern_ro; /**< RO pattern. */
3886 struct rte_flow_item *pattern; /**< Pattern items. */
3889 const struct rte_flow_action *actions_ro; /**< RO actions. */
3890 struct rte_flow_action *actions; /**< List of actions. */
3895 * Conversion operations for flow API objects.
3897 * @see rte_flow_conv()
3899 enum rte_flow_conv_op {
3901 * No operation to perform.
3903 * rte_flow_conv() simply returns 0.
3905 RTE_FLOW_CONV_OP_NONE,
3908 * Convert attributes structure.
3910 * This is a basic copy of an attributes structure.
3913 * @code const struct rte_flow_attr * @endcode
3915 * @code struct rte_flow_attr * @endcode
3917 RTE_FLOW_CONV_OP_ATTR,
3920 * Convert a single item.
3922 * Duplicates @p spec, @p last and @p mask but not outside objects.
3925 * @code const struct rte_flow_item * @endcode
3927 * @code struct rte_flow_item * @endcode
3929 RTE_FLOW_CONV_OP_ITEM,
3932 * Convert a single action.
3934 * Duplicates @p conf but not outside objects.
3937 * @code const struct rte_flow_action * @endcode
3939 * @code struct rte_flow_action * @endcode
3941 RTE_FLOW_CONV_OP_ACTION,
3944 * Convert an entire pattern.
3946 * Duplicates all pattern items at once with the same constraints as
3947 * RTE_FLOW_CONV_OP_ITEM.
3950 * @code const struct rte_flow_item * @endcode
3952 * @code struct rte_flow_item * @endcode
3954 RTE_FLOW_CONV_OP_PATTERN,
3957 * Convert a list of actions.
3959 * Duplicates the entire list of actions at once with the same
3960 * constraints as RTE_FLOW_CONV_OP_ACTION.
3963 * @code const struct rte_flow_action * @endcode
3965 * @code struct rte_flow_action * @endcode
3967 RTE_FLOW_CONV_OP_ACTIONS,
3970 * Convert a complete flow rule description.
3972 * Comprises attributes, pattern and actions together at once with
3973 * the usual constraints.
3976 * @code const struct rte_flow_conv_rule * @endcode
3978 * @code struct rte_flow_conv_rule * @endcode
3980 RTE_FLOW_CONV_OP_RULE,
3983 * Convert item type to its name string.
3985 * Writes a NUL-terminated string to @p dst. Like snprintf(), the
3986 * returned value excludes the terminator which is always written
3990 * @code (const void *)enum rte_flow_item_type @endcode
3992 * @code char * @endcode
3994 RTE_FLOW_CONV_OP_ITEM_NAME,
3997 * Convert action type to its name string.
3999 * Writes a NUL-terminated string to @p dst. Like snprintf(), the
4000 * returned value excludes the terminator which is always written
4004 * @code (const void *)enum rte_flow_action_type @endcode
4006 * @code char * @endcode
4008 RTE_FLOW_CONV_OP_ACTION_NAME,
4011 * Convert item type to pointer to item name.
4013 * Retrieves item name pointer from its type. The string itself is
4014 * not copied; instead, a unique pointer to an internal static
4015 * constant storage is written to @p dst.
4018 * @code (const void *)enum rte_flow_item_type @endcode
4020 * @code const char ** @endcode
4022 RTE_FLOW_CONV_OP_ITEM_NAME_PTR,
4025 * Convert action type to pointer to action name.
4027 * Retrieves action name pointer from its type. The string itself is
4028 * not copied; instead, a unique pointer to an internal static
4029 * constant storage is written to @p dst.
4032 * @code (const void *)enum rte_flow_action_type @endcode
4034 * @code const char ** @endcode
4036 RTE_FLOW_CONV_OP_ACTION_NAME_PTR,
4041 * @b EXPERIMENTAL: this API may change without prior notice.
4043 * Dump hardware internal representation information of
4046 * @param[in] port_id
4047 * The port identifier of the Ethernet device.
4049 * The pointer of flow rule to dump. Dump all rules if NULL.
4051 * A pointer to a file for output.
4053 * Perform verbose error reporting if not NULL. PMDs initialize this
4054 * structure in case of error only.
4056 * 0 on success, a negative value otherwise.
4060 rte_flow_dev_dump(uint16_t port_id, struct rte_flow *flow,
4061 FILE *file, struct rte_flow_error *error);
4064 * Check if mbuf dynamic field for metadata is registered.
4067 * True if registered, false otherwise.
4071 rte_flow_dynf_metadata_avail(void)
4073 return !!rte_flow_dynf_metadata_mask;
4077 * Register mbuf dynamic field and flag for metadata.
4079 * This function must be called prior to use SET_META action in order to
4080 * register the dynamic mbuf field. Otherwise, the data cannot be delivered to
4084 * 0 on success, a negative errno value otherwise and rte_errno is set.
4088 rte_flow_dynf_metadata_register(void);
4091 * Check whether a flow rule can be created on a given port.
4093 * The flow rule is validated for correctness and whether it could be accepted
4094 * by the device given sufficient resources. The rule is checked against the
4095 * current device mode and queue configuration. The flow rule may also
4096 * optionally be validated against existing flow rules and device resources.
4097 * This function has no effect on the target device.
4099 * The returned value is guaranteed to remain valid only as long as no
4100 * successful calls to rte_flow_create() or rte_flow_destroy() are made in
4101 * the meantime and no device parameter affecting flow rules in any way are
4102 * modified, due to possible collisions or resource limitations (although in
4103 * such cases EINVAL should not be returned).
4106 * Port identifier of Ethernet device.
4108 * Flow rule attributes.
4109 * @param[in] pattern
4110 * Pattern specification (list terminated by the END pattern item).
4111 * @param[in] actions
4112 * Associated actions (list terminated by the END action).
4114 * Perform verbose error reporting if not NULL. PMDs initialize this
4115 * structure in case of error only.
4118 * 0 if flow rule is valid and can be created. A negative errno value
4119 * otherwise (rte_errno is also set), the following errors are defined:
4121 * -ENOSYS: underlying device does not support this functionality.
4123 * -EIO: underlying device is removed.
4125 * -EINVAL: unknown or invalid rule specification.
4127 * -ENOTSUP: valid but unsupported rule specification (e.g. partial
4128 * bit-masks are unsupported).
4130 * -EEXIST: collision with an existing rule. Only returned if device
4131 * supports flow rule collision checking and there was a flow rule
4132 * collision. Not receiving this return code is no guarantee that creating
4133 * the rule will not fail due to a collision.
4135 * -ENOMEM: not enough memory to execute the function, or if the device
4136 * supports resource validation, resource limitation on the device.
4138 * -EBUSY: action cannot be performed due to busy device resources, may
4139 * succeed if the affected queues or even the entire port are in a stopped
4140 * state (see rte_eth_dev_rx_queue_stop() and rte_eth_dev_stop()).
4143 rte_flow_validate(uint16_t port_id,
4144 const struct rte_flow_attr *attr,
4145 const struct rte_flow_item pattern[],
4146 const struct rte_flow_action actions[],
4147 struct rte_flow_error *error);
4150 * Create a flow rule on a given port.
4153 * Port identifier of Ethernet device.
4155 * Flow rule attributes.
4156 * @param[in] pattern
4157 * Pattern specification (list terminated by the END pattern item).
4158 * @param[in] actions
4159 * Associated actions (list terminated by the END action).
4161 * Perform verbose error reporting if not NULL. PMDs initialize this
4162 * structure in case of error only.
4165 * A valid handle in case of success, NULL otherwise and rte_errno is set
4166 * to the positive version of one of the error codes defined for
4167 * rte_flow_validate().
4170 rte_flow_create(uint16_t port_id,
4171 const struct rte_flow_attr *attr,
4172 const struct rte_flow_item pattern[],
4173 const struct rte_flow_action actions[],
4174 struct rte_flow_error *error);
4177 * Destroy a flow rule on a given port.
4179 * Failure to destroy a flow rule handle may occur when other flow rules
4180 * depend on it, and destroying it would result in an inconsistent state.
4182 * This function is only guaranteed to succeed if handles are destroyed in
4183 * reverse order of their creation.
4186 * Port identifier of Ethernet device.
4188 * Flow rule handle to destroy.
4190 * Perform verbose error reporting if not NULL. PMDs initialize this
4191 * structure in case of error only.
4194 * 0 on success, a negative errno value otherwise and rte_errno is set.
4197 rte_flow_destroy(uint16_t port_id,
4198 struct rte_flow *flow,
4199 struct rte_flow_error *error);
4202 * Destroy all flow rules associated with a port.
4204 * In the unlikely event of failure, handles are still considered destroyed
4205 * and no longer valid but the port must be assumed to be in an inconsistent
4209 * Port identifier of Ethernet device.
4211 * Perform verbose error reporting if not NULL. PMDs initialize this
4212 * structure in case of error only.
4215 * 0 on success, a negative errno value otherwise and rte_errno is set.
4218 rte_flow_flush(uint16_t port_id,
4219 struct rte_flow_error *error);
4222 * Query an existing flow rule.
4224 * This function allows retrieving flow-specific data such as counters.
4225 * Data is gathered by special actions which must be present in the flow
4228 * \see RTE_FLOW_ACTION_TYPE_COUNT
4231 * Port identifier of Ethernet device.
4233 * Flow rule handle to query.
4235 * Action definition as defined in original flow rule.
4236 * @param[in, out] data
4237 * Pointer to storage for the associated query data type.
4239 * Perform verbose error reporting if not NULL. PMDs initialize this
4240 * structure in case of error only.
4243 * 0 on success, a negative errno value otherwise and rte_errno is set.
4246 rte_flow_query(uint16_t port_id,
4247 struct rte_flow *flow,
4248 const struct rte_flow_action *action,
4250 struct rte_flow_error *error);
4253 * Restrict ingress traffic to the defined flow rules.
4255 * Isolated mode guarantees that all ingress traffic comes from defined flow
4256 * rules only (current and future).
4258 * Besides making ingress more deterministic, it allows PMDs to safely reuse
4259 * resources otherwise assigned to handle the remaining traffic, such as
4260 * global RSS configuration settings, VLAN filters, MAC address entries,
4261 * legacy filter API rules and so on in order to expand the set of possible
4264 * Calling this function as soon as possible after device initialization,
4265 * ideally before the first call to rte_eth_dev_configure(), is recommended
4266 * to avoid possible failures due to conflicting settings.
4268 * Once effective, leaving isolated mode may not be possible depending on
4269 * PMD implementation.
4271 * Additionally, the following functionality has no effect on the underlying
4272 * port and may return errors such as ENOTSUP ("not supported"):
4274 * - Toggling promiscuous mode.
4275 * - Toggling allmulticast mode.
4276 * - Configuring MAC addresses.
4277 * - Configuring multicast addresses.
4278 * - Configuring VLAN filters.
4279 * - Configuring Rx filters through the legacy API (e.g. FDIR).
4280 * - Configuring global RSS settings.
4283 * Port identifier of Ethernet device.
4285 * Nonzero to enter isolated mode, attempt to leave it otherwise.
4287 * Perform verbose error reporting if not NULL. PMDs initialize this
4288 * structure in case of error only.
4291 * 0 on success, a negative errno value otherwise and rte_errno is set.
4294 rte_flow_isolate(uint16_t port_id, int set, struct rte_flow_error *error);
4297 * Initialize flow error structure.
4300 * Pointer to flow error structure (may be NULL).
4302 * Related error code (rte_errno).
4304 * Cause field and error types.
4306 * Object responsible for the error.
4308 * Human-readable error message.
4311 * Negative error code (errno value) and rte_errno is set.
4314 rte_flow_error_set(struct rte_flow_error *error,
4316 enum rte_flow_error_type type,
4318 const char *message);
4322 * @see rte_flow_copy()
4324 struct rte_flow_desc {
4325 size_t size; /**< Allocated space including data[]. */
4326 struct rte_flow_attr attr; /**< Attributes. */
4327 struct rte_flow_item *items; /**< Items. */
4328 struct rte_flow_action *actions; /**< Actions. */
4329 uint8_t data[]; /**< Storage for items/actions. */
4334 * Copy an rte_flow rule description.
4336 * This interface is kept for compatibility with older applications but is
4337 * implemented as a wrapper to rte_flow_conv(). It is deprecated due to its
4338 * lack of flexibility and reliance on a type unusable with C++ programs
4339 * (struct rte_flow_desc).
4342 * Flow rule description.
4344 * Total size of allocated data for the flow description.
4346 * Flow rule attributes.
4348 * Pattern specification (list terminated by the END pattern item).
4349 * @param[in] actions
4350 * Associated actions (list terminated by the END action).
4353 * If len is greater or equal to the size of the flow, the total size of the
4354 * flow description and its data.
4355 * If len is lower than the size of the flow, the number of bytes that would
4356 * have been written to desc had it been sufficient. Nothing is written.
4360 rte_flow_copy(struct rte_flow_desc *fd, size_t len,
4361 const struct rte_flow_attr *attr,
4362 const struct rte_flow_item *items,
4363 const struct rte_flow_action *actions);
4366 * Flow object conversion helper.
4368 * This function performs conversion of various flow API objects to a
4369 * pre-allocated destination buffer. See enum rte_flow_conv_op for possible
4370 * operations and details about each of them.
4372 * Since destination buffer must be large enough, it works in a manner
4373 * reminiscent of snprintf():
4375 * - If @p size is 0, @p dst may be a NULL pointer, otherwise @p dst must be
4377 * - If positive, the returned value represents the number of bytes needed
4378 * to store the conversion of @p src to @p dst according to @p op
4379 * regardless of the @p size parameter.
4380 * - Since no more than @p size bytes can be written to @p dst, output is
4381 * truncated and may be inconsistent when the returned value is larger
4383 * - In case of conversion error, a negative error code is returned and
4384 * @p dst contents are unspecified.
4387 * Operation to perform, related to the object type of @p dst.
4389 * Destination buffer address. Must be suitably aligned by the caller.
4391 * Destination buffer size in bytes.
4393 * Source object to copy. Depending on @p op, its type may differ from
4396 * Perform verbose error reporting if not NULL. Initialized in case of
4400 * The number of bytes required to convert @p src to @p dst on success, a
4401 * negative errno value otherwise and rte_errno is set.
4403 * @see rte_flow_conv_op
4407 rte_flow_conv(enum rte_flow_conv_op op,
4411 struct rte_flow_error *error);
4414 * Get aged-out flows of a given port.
4416 * RTE_ETH_EVENT_FLOW_AGED event will be triggered when at least one new aged
4417 * out flow was detected after the last call to rte_flow_get_aged_flows.
4418 * This function can be called to get the aged flows asynchronously from the
4419 * event callback or synchronously regardless the event.
4420 * This is not safe to call rte_flow_get_aged_flows function with other flow
4421 * functions from multiple threads simultaneously.
4424 * Port identifier of Ethernet device.
4425 * @param[in, out] contexts
4426 * The address of an array of pointers to the aged-out flows contexts.
4427 * @param[in] nb_contexts
4428 * The length of context array pointers.
4430 * Perform verbose error reporting if not NULL. Initialized in case of
4434 * if nb_contexts is 0, return the amount of all aged contexts.
4435 * if nb_contexts is not 0 , return the amount of aged flows reported
4436 * in the context array, otherwise negative errno value.
4438 * @see rte_flow_action_age
4439 * @see RTE_ETH_EVENT_FLOW_AGED
4443 rte_flow_get_aged_flows(uint16_t port_id, void **contexts,
4444 uint32_t nb_contexts, struct rte_flow_error *error);
4447 * Specify indirect action object configuration
4449 struct rte_flow_indir_action_conf {
4451 * Flow direction for the indirect action configuration.
4453 * Action should be valid at least for one flow direction,
4454 * otherwise it is invalid for both ingress and egress rules.
4456 /** Action valid for rules applied to ingress traffic. */
4458 /** Action valid for rules applied to egress traffic. */
4461 * When set to 1, indicates that the action is valid for
4462 * transfer traffic; otherwise, for non-transfer traffic.
4464 uint32_t transfer:1;
4469 * @b EXPERIMENTAL: this API may change without prior notice.
4471 * Create an indirect action object that can be used in flow rules
4473 * The created object handle has single state and configuration
4474 * across all the flow rules using it.
4476 * @param[in] port_id
4477 * The port identifier of the Ethernet device.
4479 * Action configuration for the indirect action object creation.
4481 * Specific configuration of the indirect action object.
4483 * Perform verbose error reporting if not NULL. PMDs initialize this
4484 * structure in case of error only.
4486 * A valid handle in case of success, NULL otherwise and rte_errno is set
4487 * to one of the error codes defined:
4488 * - (ENODEV) if *port_id* invalid.
4489 * - (ENOSYS) if underlying device does not support this functionality.
4490 * - (EIO) if underlying device is removed.
4491 * - (EINVAL) if *action* invalid.
4492 * - (ENOTSUP) if *action* valid but unsupported.
4495 struct rte_flow_action_handle *
4496 rte_flow_action_handle_create(uint16_t port_id,
4497 const struct rte_flow_indir_action_conf *conf,
4498 const struct rte_flow_action *action,
4499 struct rte_flow_error *error);
4503 * @b EXPERIMENTAL: this API may change without prior notice.
4505 * Destroy indirect action by handle.
4507 * @param[in] port_id
4508 * The port identifier of the Ethernet device.
4510 * Handle for the indirect action object to be destroyed.
4512 * Perform verbose error reporting if not NULL. PMDs initialize this
4513 * structure in case of error only.
4516 * - (-ENODEV) if *port_id* invalid.
4517 * - (-ENOSYS) if underlying device does not support this functionality.
4518 * - (-EIO) if underlying device is removed.
4519 * - (-ENOENT) if action pointed by *action* handle was not found.
4520 * - (-EBUSY) if action pointed by *action* handle still used by some rules
4521 * rte_errno is also set.
4525 rte_flow_action_handle_destroy(uint16_t port_id,
4526 struct rte_flow_action_handle *handle,
4527 struct rte_flow_error *error);
4531 * @b EXPERIMENTAL: this API may change without prior notice.
4533 * Update in-place the action configuration and / or state pointed
4534 * by action *handle* with the configuration provided as *update* argument.
4535 * The update of the action configuration effects all flow rules reusing
4536 * the action via *handle*.
4537 * The update general pointer provides the ability of partial updating.
4539 * @param[in] port_id
4540 * The port identifier of the Ethernet device.
4542 * Handle for the indirect action object to be updated.
4544 * Update profile specification used to modify the action pointed by handle.
4545 * *update* could be with the same type of the immediate action corresponding
4546 * to the *handle* argument when creating, or a wrapper structure includes
4547 * action configuration to be updated and bit fields to indicate the member
4548 * of fields inside the action to update.
4550 * Perform verbose error reporting if not NULL. PMDs initialize this
4551 * structure in case of error only.
4554 * - (-ENODEV) if *port_id* invalid.
4555 * - (-ENOSYS) if underlying device does not support this functionality.
4556 * - (-EIO) if underlying device is removed.
4557 * - (-EINVAL) if *update* invalid.
4558 * - (-ENOTSUP) if *update* valid but unsupported.
4559 * - (-ENOENT) if indirect action object pointed by *handle* was not found.
4560 * rte_errno is also set.
4564 rte_flow_action_handle_update(uint16_t port_id,
4565 struct rte_flow_action_handle *handle,
4567 struct rte_flow_error *error);
4571 * @b EXPERIMENTAL: this API may change without prior notice.
4573 * Query the direct action by corresponding indirect action object handle.
4575 * Retrieve action-specific data such as counters.
4576 * Data is gathered by special action which may be present/referenced in
4577 * more than one flow rule definition.
4579 * @see RTE_FLOW_ACTION_TYPE_COUNT
4582 * Port identifier of Ethernet device.
4584 * Handle for the action object to query.
4585 * @param[in, out] data
4586 * Pointer to storage for the associated query data type.
4588 * Perform verbose error reporting if not NULL. PMDs initialize this
4589 * structure in case of error only.
4592 * 0 on success, a negative errno value otherwise and rte_errno is set.
4596 rte_flow_action_handle_query(uint16_t port_id,
4597 const struct rte_flow_action_handle *handle,
4598 void *data, struct rte_flow_error *error);
4600 /* Tunnel has a type and the key information. */
4601 struct rte_flow_tunnel {
4603 * Tunnel type, for example RTE_FLOW_ITEM_TYPE_VXLAN,
4604 * RTE_FLOW_ITEM_TYPE_NVGRE etc.
4606 enum rte_flow_item_type type;
4607 uint64_t tun_id; /**< Tunnel identification. */
4612 rte_be32_t src_addr; /**< IPv4 source address. */
4613 rte_be32_t dst_addr; /**< IPv4 destination address. */
4616 uint8_t src_addr[16]; /**< IPv6 source address. */
4617 uint8_t dst_addr[16]; /**< IPv6 destination address. */
4620 rte_be16_t tp_src; /**< Tunnel port source. */
4621 rte_be16_t tp_dst; /**< Tunnel port destination. */
4622 uint16_t tun_flags; /**< Tunnel flags. */
4624 bool is_ipv6; /**< True for valid IPv6 fields. Otherwise IPv4. */
4627 * the following members are required to restore packet
4630 uint8_t tos; /**< TOS for IPv4, TC for IPv6. */
4631 uint8_t ttl; /**< TTL for IPv4, HL for IPv6. */
4632 uint32_t label; /**< Flow Label for IPv6. */
4636 * Indicate that the packet has a tunnel.
4638 #define RTE_FLOW_RESTORE_INFO_TUNNEL RTE_BIT64(0)
4641 * Indicate that the packet has a non decapsulated tunnel header.
4643 #define RTE_FLOW_RESTORE_INFO_ENCAPSULATED RTE_BIT64(1)
4646 * Indicate that the packet has a group_id.
4648 #define RTE_FLOW_RESTORE_INFO_GROUP_ID RTE_BIT64(2)
4651 * Restore information structure to communicate the current packet processing
4652 * state when some of the processing pipeline is done in hardware and should
4653 * continue in software.
4655 struct rte_flow_restore_info {
4657 * Bitwise flags (RTE_FLOW_RESTORE_INFO_*) to indicate validation of
4658 * other fields in struct rte_flow_restore_info.
4661 uint32_t group_id; /**< Group ID where packed missed */
4662 struct rte_flow_tunnel tunnel; /**< Tunnel information. */
4666 * Allocate an array of actions to be used in rte_flow_create, to implement
4667 * tunnel-decap-set for the given tunnel.
4669 * actions vxlan_decap / tunnel-decap-set(tunnel properties) /
4670 * jump group 0 / end
4673 * Port identifier of Ethernet device.
4675 * Tunnel properties.
4676 * @param[out] actions
4677 * Array of actions to be allocated by the PMD. This array should be
4678 * concatenated with the actions array provided to rte_flow_create.
4679 * @param[out] num_of_actions
4680 * Number of actions allocated.
4682 * Perform verbose error reporting if not NULL. PMDs initialize this
4683 * structure in case of error only.
4686 * 0 on success, a negative errno value otherwise and rte_errno is set.
4690 rte_flow_tunnel_decap_set(uint16_t port_id,
4691 struct rte_flow_tunnel *tunnel,
4692 struct rte_flow_action **actions,
4693 uint32_t *num_of_actions,
4694 struct rte_flow_error *error);
4697 * Allocate an array of items to be used in rte_flow_create, to implement
4698 * tunnel-match for the given tunnel.
4700 * pattern tunnel-match(tunnel properties) / outer-header-matches /
4701 * inner-header-matches / end
4704 * Port identifier of Ethernet device.
4706 * Tunnel properties.
4708 * Array of items to be allocated by the PMD. This array should be
4709 * concatenated with the items array provided to rte_flow_create.
4710 * @param[out] num_of_items
4711 * Number of items allocated.
4713 * Perform verbose error reporting if not NULL. PMDs initialize this
4714 * structure in case of error only.
4717 * 0 on success, a negative errno value otherwise and rte_errno is set.
4721 rte_flow_tunnel_match(uint16_t port_id,
4722 struct rte_flow_tunnel *tunnel,
4723 struct rte_flow_item **items,
4724 uint32_t *num_of_items,
4725 struct rte_flow_error *error);
4728 * Populate the current packet processing state, if exists, for the given mbuf.
4730 * One should negotiate tunnel metadata delivery from the NIC to the HW.
4731 * @see rte_eth_rx_metadata_negotiate()
4732 * @see RTE_ETH_RX_METADATA_TUNNEL_ID
4735 * Port identifier of Ethernet device.
4739 * Restore information. Upon success contains the HW state.
4741 * Perform verbose error reporting if not NULL. PMDs initialize this
4742 * structure in case of error only.
4745 * 0 on success, a negative errno value otherwise and rte_errno is set.
4749 rte_flow_get_restore_info(uint16_t port_id,
4751 struct rte_flow_restore_info *info,
4752 struct rte_flow_error *error);
4755 * Release the action array as allocated by rte_flow_tunnel_decap_set.
4758 * Port identifier of Ethernet device.
4759 * @param[in] actions
4760 * Array of actions to be released.
4761 * @param[in] num_of_actions
4762 * Number of elements in actions array.
4764 * Perform verbose error reporting if not NULL. PMDs initialize this
4765 * structure in case of error only.
4768 * 0 on success, a negative errno value otherwise and rte_errno is set.
4772 rte_flow_tunnel_action_decap_release(uint16_t port_id,
4773 struct rte_flow_action *actions,
4774 uint32_t num_of_actions,
4775 struct rte_flow_error *error);
4778 * Release the item array as allocated by rte_flow_tunnel_match.
4781 * Port identifier of Ethernet device.
4783 * Array of items to be released.
4784 * @param[in] num_of_items
4785 * Number of elements in item array.
4787 * Perform verbose error reporting if not NULL. PMDs initialize this
4788 * structure in case of error only.
4791 * 0 on success, a negative errno value otherwise and rte_errno is set.
4795 rte_flow_tunnel_item_release(uint16_t port_id,
4796 struct rte_flow_item *items,
4797 uint32_t num_of_items,
4798 struct rte_flow_error *error);
4802 * @b EXPERIMENTAL: this API may change without prior notice.
4804 * Get a proxy port to manage "transfer" flows.
4806 * Managing "transfer" flows requires that the user communicate them
4807 * via a port which has the privilege to control the embedded switch.
4808 * For some vendors, all ports in a given switching domain have
4809 * this privilege. For other vendors, it's only one port.
4811 * This API indicates such a privileged port (a "proxy")
4812 * for a given port in the same switching domain.
4815 * If the PMD serving @p port_id doesn't have the corresponding method
4816 * implemented, the API will return @p port_id via @p proxy_port_id.
4819 * Indicates the port to get a "proxy" for
4820 * @param[out] proxy_port_id
4821 * Indicates the "proxy" port
4823 * If not NULL, allows the PMD to provide verbose report in case of error
4826 * 0 on success, a negative error code otherwise
4830 rte_flow_pick_transfer_proxy(uint16_t port_id, uint16_t *proxy_port_id,
4831 struct rte_flow_error *error);
4835 * @b EXPERIMENTAL: this API may change without prior notice.
4837 * Create the flex item with specified configuration over
4838 * the Ethernet device.
4841 * Port identifier of Ethernet device.
4843 * Item configuration.
4845 * Perform verbose error reporting if not NULL. PMDs initialize this
4846 * structure in case of error only.
4849 * Non-NULL opaque pointer on success, NULL otherwise and rte_errno is set.
4852 struct rte_flow_item_flex_handle *
4853 rte_flow_flex_item_create(uint16_t port_id,
4854 const struct rte_flow_item_flex_conf *conf,
4855 struct rte_flow_error *error);
4858 * Release the flex item on the specified Ethernet device.
4861 * Port identifier of Ethernet device.
4863 * Handle of the item existing on the specified device.
4865 * Perform verbose error reporting if not NULL. PMDs initialize this
4866 * structure in case of error only.
4869 * 0 on success, a negative errno value otherwise and rte_errno is set.
4873 rte_flow_flex_item_release(uint16_t port_id,
4874 const struct rte_flow_item_flex_handle *handle,
4875 struct rte_flow_error *error);
4879 * @b EXPERIMENTAL: this API may change without prior notice.
4881 * Information about flow engine resources.
4882 * The zero value means a resource is not supported.
4885 struct rte_flow_port_info {
4887 * Maximum number of queues for asynchronous operations.
4889 uint32_t max_nb_queues;
4891 * Maximum number of counters.
4892 * @see RTE_FLOW_ACTION_TYPE_COUNT
4894 uint32_t max_nb_counters;
4896 * Maximum number of aging objects.
4897 * @see RTE_FLOW_ACTION_TYPE_AGE
4899 uint32_t max_nb_aging_objects;
4901 * Maximum number traffic meters.
4902 * @see RTE_FLOW_ACTION_TYPE_METER
4904 uint32_t max_nb_meters;
4909 * @b EXPERIMENTAL: this API may change without prior notice.
4911 * Information about flow engine asynchronous queues.
4912 * The value only valid if @p port_attr.max_nb_queues is not zero.
4915 struct rte_flow_queue_info {
4917 * Maximum number of operations a queue can hold.
4924 * @b EXPERIMENTAL: this API may change without prior notice.
4926 * Get information about flow engine resources.
4929 * Port identifier of Ethernet device.
4930 * @param[out] port_info
4931 * A pointer to a structure of type *rte_flow_port_info*
4932 * to be filled with the resources information of the port.
4933 * @param[out] queue_info
4934 * A pointer to a structure of type *rte_flow_queue_info*
4935 * to be filled with the asynchronous queues information.
4937 * Perform verbose error reporting if not NULL.
4938 * PMDs initialize this structure in case of error only.
4941 * 0 on success, a negative errno value otherwise and rte_errno is set.
4945 rte_flow_info_get(uint16_t port_id,
4946 struct rte_flow_port_info *port_info,
4947 struct rte_flow_queue_info *queue_info,
4948 struct rte_flow_error *error);
4952 * @b EXPERIMENTAL: this API may change without prior notice.
4954 * Flow engine resources settings.
4955 * The zero value means on demand resource allocations only.
4958 struct rte_flow_port_attr {
4960 * Number of counters to configure.
4961 * @see RTE_FLOW_ACTION_TYPE_COUNT
4963 uint32_t nb_counters;
4965 * Number of aging objects to configure.
4966 * @see RTE_FLOW_ACTION_TYPE_AGE
4968 uint32_t nb_aging_objects;
4970 * Number of traffic meters to configure.
4971 * @see RTE_FLOW_ACTION_TYPE_METER
4978 * @b EXPERIMENTAL: this API may change without prior notice.
4980 * Flow engine asynchronous queues settings.
4981 * The value means default value picked by PMD.
4984 struct rte_flow_queue_attr {
4986 * Number of flow rule operations a queue can hold.
4993 * @b EXPERIMENTAL: this API may change without prior notice.
4995 * Configure the port's flow API engine.
4997 * This API can only be invoked before the application
4998 * starts using the rest of the flow library functions.
5000 * The API can be invoked multiple times to change the settings.
5001 * The port, however, may reject changes and keep the old config.
5003 * Parameters in configuration attributes must not exceed
5004 * numbers of resources returned by the rte_flow_info_get API.
5007 * Port identifier of Ethernet device.
5008 * @param[in] port_attr
5009 * Port configuration attributes.
5010 * @param[in] nb_queue
5011 * Number of flow queues to be configured.
5012 * @param[in] queue_attr
5013 * Array that holds attributes for each flow queue.
5014 * Number of elements is set in @p port_attr.nb_queues.
5016 * Perform verbose error reporting if not NULL.
5017 * PMDs initialize this structure in case of error only.
5020 * 0 on success, a negative errno value otherwise and rte_errno is set.
5024 rte_flow_configure(uint16_t port_id,
5025 const struct rte_flow_port_attr *port_attr,
5027 const struct rte_flow_queue_attr *queue_attr[],
5028 struct rte_flow_error *error);
5031 * Opaque type returned after successful creation of pattern template.
5032 * This handle can be used to manage the created pattern template.
5034 struct rte_flow_pattern_template;
5038 * @b EXPERIMENTAL: this API may change without prior notice.
5040 * Flow pattern template attributes.
5043 struct rte_flow_pattern_template_attr {
5045 * Relaxed matching policy.
5046 * - If 1, matching is performed only on items with the mask member set
5047 * and matching on protocol layers specified without any masks is skipped.
5048 * - If 0, matching on protocol layers specified without any masks is done
5049 * as well. This is the standard behaviour of Flow API now.
5051 uint32_t relaxed_matching:1;
5053 * Flow direction for the pattern template.
5054 * At least one direction must be specified.
5056 /** Pattern valid for rules applied to ingress traffic. */
5058 /** Pattern valid for rules applied to egress traffic. */
5060 /** Pattern valid for rules applied to transfer traffic. */
5061 uint32_t transfer:1;
5066 * @b EXPERIMENTAL: this API may change without prior notice.
5068 * Create flow pattern template.
5070 * The pattern template defines common matching fields without values.
5071 * For example, matching on 5 tuple TCP flow, the template will be
5072 * eth(null) + IPv4(source + dest) + TCP(s_port + d_port),
5073 * while values for each rule will be set during the flow rule creation.
5074 * The number and order of items in the template must be the same
5075 * at the rule creation.
5078 * Port identifier of Ethernet device.
5079 * @param[in] template_attr
5080 * Pattern template attributes.
5081 * @param[in] pattern
5082 * Pattern specification (list terminated by the END pattern item).
5083 * The spec member of an item is not used unless the end member is used.
5085 * Perform verbose error reporting if not NULL.
5086 * PMDs initialize this structure in case of error only.
5089 * Handle on success, NULL otherwise and rte_errno is set.
5092 struct rte_flow_pattern_template *
5093 rte_flow_pattern_template_create(uint16_t port_id,
5094 const struct rte_flow_pattern_template_attr *template_attr,
5095 const struct rte_flow_item pattern[],
5096 struct rte_flow_error *error);
5100 * @b EXPERIMENTAL: this API may change without prior notice.
5102 * Destroy flow pattern template.
5104 * This function may be called only when
5105 * there are no more tables referencing this template.
5108 * Port identifier of Ethernet device.
5109 * @param[in] pattern_template
5110 * Handle of the template to be destroyed.
5112 * Perform verbose error reporting if not NULL.
5113 * PMDs initialize this structure in case of error only.
5116 * 0 on success, a negative errno value otherwise and rte_errno is set.
5120 rte_flow_pattern_template_destroy(uint16_t port_id,
5121 struct rte_flow_pattern_template *pattern_template,
5122 struct rte_flow_error *error);
5125 * Opaque type returned after successful creation of actions template.
5126 * This handle can be used to manage the created actions template.
5128 struct rte_flow_actions_template;
5132 * @b EXPERIMENTAL: this API may change without prior notice.
5134 * Flow actions template attributes.
5137 struct rte_flow_actions_template_attr {
5139 * Flow direction for the actions template.
5140 * At least one direction must be specified.
5142 /** Action valid for rules applied to ingress traffic. */
5144 /** Action valid for rules applied to egress traffic. */
5146 /** Action valid for rules applied to transfer traffic. */
5147 uint32_t transfer:1;
5152 * @b EXPERIMENTAL: this API may change without prior notice.
5154 * Create flow actions template.
5156 * The actions template holds a list of action types without values.
5157 * For example, the template to change TCP ports is TCP(s_port + d_port),
5158 * while values for each rule will be set during the flow rule creation.
5159 * The number and order of actions in the template must be the same
5160 * at the rule creation.
5163 * Port identifier of Ethernet device.
5164 * @param[in] template_attr
5165 * Template attributes.
5166 * @param[in] actions
5167 * Associated actions (list terminated by the END action).
5168 * The spec member is only used if @p masks spec is non-zero.
5170 * List of actions that marks which of the action's member is constant.
5171 * A mask has the same format as the corresponding action.
5172 * If the action field in @p masks is not 0,
5173 * the corresponding value in an action from @p actions will be the part
5174 * of the template and used in all flow rules.
5175 * The order of actions in @p masks is the same as in @p actions.
5176 * In case of indirect actions present in @p actions,
5177 * the actual action type should be present in @p mask.
5179 * Perform verbose error reporting if not NULL.
5180 * PMDs initialize this structure in case of error only.
5183 * Handle on success, NULL otherwise and rte_errno is set.
5186 struct rte_flow_actions_template *
5187 rte_flow_actions_template_create(uint16_t port_id,
5188 const struct rte_flow_actions_template_attr *template_attr,
5189 const struct rte_flow_action actions[],
5190 const struct rte_flow_action masks[],
5191 struct rte_flow_error *error);
5195 * @b EXPERIMENTAL: this API may change without prior notice.
5197 * Destroy flow actions template.
5199 * This function may be called only when
5200 * there are no more tables referencing this template.
5203 * Port identifier of Ethernet device.
5204 * @param[in] actions_template
5205 * Handle to the template to be destroyed.
5207 * Perform verbose error reporting if not NULL.
5208 * PMDs initialize this structure in case of error only.
5211 * 0 on success, a negative errno value otherwise and rte_errno is set.
5215 rte_flow_actions_template_destroy(uint16_t port_id,
5216 struct rte_flow_actions_template *actions_template,
5217 struct rte_flow_error *error);
5220 * Opaque type returned after successful creation of a template table.
5221 * This handle can be used to manage the created template table.
5223 struct rte_flow_template_table;
5227 * @b EXPERIMENTAL: this API may change without prior notice.
5231 struct rte_flow_template_table_attr {
5233 * Flow attributes to be used in each rule generated from this table.
5235 struct rte_flow_attr flow_attr;
5237 * Maximum number of flow rules that this table holds.
5244 * @b EXPERIMENTAL: this API may change without prior notice.
5246 * Create flow template table.
5248 * A template table consists of multiple pattern templates and actions
5249 * templates associated with a single set of rule attributes (group ID,
5250 * priority and traffic direction).
5252 * Each rule is free to use any combination of pattern and actions templates
5253 * and specify particular values for items and actions it would like to change.
5256 * Port identifier of Ethernet device.
5257 * @param[in] table_attr
5258 * Template table attributes.
5259 * @param[in] pattern_templates
5260 * Array of pattern templates to be used in this table.
5261 * @param[in] nb_pattern_templates
5262 * The number of pattern templates in the pattern_templates array.
5263 * @param[in] actions_templates
5264 * Array of actions templates to be used in this table.
5265 * @param[in] nb_actions_templates
5266 * The number of actions templates in the actions_templates array.
5268 * Perform verbose error reporting if not NULL.
5269 * PMDs initialize this structure in case of error only.
5272 * Handle on success, NULL otherwise and rte_errno is set.
5275 struct rte_flow_template_table *
5276 rte_flow_template_table_create(uint16_t port_id,
5277 const struct rte_flow_template_table_attr *table_attr,
5278 struct rte_flow_pattern_template *pattern_templates[],
5279 uint8_t nb_pattern_templates,
5280 struct rte_flow_actions_template *actions_templates[],
5281 uint8_t nb_actions_templates,
5282 struct rte_flow_error *error);
5286 * @b EXPERIMENTAL: this API may change without prior notice.
5288 * Destroy flow template table.
5290 * This function may be called only when
5291 * there are no more flow rules referencing this table.
5294 * Port identifier of Ethernet device.
5295 * @param[in] template_table
5296 * Handle to the table to be destroyed.
5298 * Perform verbose error reporting if not NULL.
5299 * PMDs initialize this structure in case of error only.
5302 * 0 on success, a negative errno value otherwise and rte_errno is set.
5306 rte_flow_template_table_destroy(uint16_t port_id,
5307 struct rte_flow_template_table *template_table,
5308 struct rte_flow_error *error);
5312 * @b EXPERIMENTAL: this API may change without prior notice.
5314 * Asynchronous operation attributes.
5317 struct rte_flow_op_attr {
5319 * When set, the requested action will not be sent to the HW immediately.
5320 * The application must call the rte_flow_queue_push to actually send it.
5322 uint32_t postpone:1;
5327 * @b EXPERIMENTAL: this API may change without prior notice.
5329 * Enqueue rule creation operation.
5332 * Port identifier of Ethernet device.
5334 * Flow queue used to insert the rule.
5335 * @param[in] op_attr
5336 * Rule creation operation attributes.
5337 * @param[in] template_table
5338 * Template table to select templates from.
5339 * @param[in] pattern
5340 * List of pattern items to be used.
5341 * The list order should match the order in the pattern template.
5342 * The spec is the only relevant member of the item that is being used.
5343 * @param[in] pattern_template_index
5344 * Pattern template index in the table.
5345 * @param[in] actions
5346 * List of actions to be used.
5347 * The list order should match the order in the actions template.
5348 * @param[in] actions_template_index
5349 * Actions template index in the table.
5350 * @param[in] user_data
5351 * The user data that will be returned on the completion events.
5353 * Perform verbose error reporting if not NULL.
5354 * PMDs initialize this structure in case of error only.
5357 * Handle on success, NULL otherwise and rte_errno is set.
5358 * The rule handle doesn't mean that the rule has been populated.
5359 * Only completion result indicates that if there was success or failure.
5363 rte_flow_async_create(uint16_t port_id,
5365 const struct rte_flow_op_attr *op_attr,
5366 struct rte_flow_template_table *template_table,
5367 const struct rte_flow_item pattern[],
5368 uint8_t pattern_template_index,
5369 const struct rte_flow_action actions[],
5370 uint8_t actions_template_index,
5372 struct rte_flow_error *error);
5376 * @b EXPERIMENTAL: this API may change without prior notice.
5378 * Enqueue rule destruction operation.
5380 * This function enqueues a destruction operation on the queue.
5381 * Application should assume that after calling this function
5382 * the rule handle is not valid anymore.
5383 * Completion indicates the full removal of the rule from the HW.
5386 * Port identifier of Ethernet device.
5388 * Flow queue which is used to destroy the rule.
5389 * This must match the queue on which the rule was created.
5390 * @param[in] op_attr
5391 * Rule destruction operation attributes.
5393 * Flow handle to be destroyed.
5394 * @param[in] user_data
5395 * The user data that will be returned on the completion events.
5397 * Perform verbose error reporting if not NULL.
5398 * PMDs initialize this structure in case of error only.
5401 * 0 on success, a negative errno value otherwise and rte_errno is set.
5405 rte_flow_async_destroy(uint16_t port_id,
5407 const struct rte_flow_op_attr *op_attr,
5408 struct rte_flow *flow,
5410 struct rte_flow_error *error);
5414 * @b EXPERIMENTAL: this API may change without prior notice.
5416 * Push all internally stored rules to the HW.
5417 * Postponed rules are rules that were inserted with the postpone flag set.
5418 * Can be used to notify the HW about batch of rules prepared by the SW to
5419 * reduce the number of communications between the HW and SW.
5422 * Port identifier of Ethernet device.
5424 * Flow queue to be pushed.
5426 * Perform verbose error reporting if not NULL.
5427 * PMDs initialize this structure in case of error only.
5430 * 0 on success, a negative errno value otherwise and rte_errno is set.
5434 rte_flow_push(uint16_t port_id,
5436 struct rte_flow_error *error);
5440 * @b EXPERIMENTAL: this API may change without prior notice.
5442 * Asynchronous operation status.
5444 enum rte_flow_op_status {
5446 * The operation was completed successfully.
5448 RTE_FLOW_OP_SUCCESS,
5450 * The operation was not completed successfully.
5457 * @b EXPERIMENTAL: this API may change without prior notice.
5459 * Asynchronous operation result.
5462 struct rte_flow_op_result {
5464 * Returns the status of the operation that this completion signals.
5466 enum rte_flow_op_status status;
5468 * The user data that will be returned on the completion events.
5475 * @b EXPERIMENTAL: this API may change without prior notice.
5477 * Pull a rte flow operation.
5478 * The application must invoke this function in order to complete
5479 * the flow rule offloading and to retrieve the flow rule operation status.
5482 * Port identifier of Ethernet device.
5484 * Flow queue which is used to pull the operation.
5486 * Array of results that will be set.
5488 * Maximum number of results that can be returned.
5489 * This value is equal to the size of the res array.
5491 * Perform verbose error reporting if not NULL.
5492 * PMDs initialize this structure in case of error only.
5495 * Number of results that were pulled,
5496 * a negative errno value otherwise and rte_errno is set.
5500 rte_flow_pull(uint16_t port_id,
5502 struct rte_flow_op_result res[],
5504 struct rte_flow_error *error);
5508 * @b EXPERIMENTAL: this API may change without prior notice.
5510 * Enqueue indirect action creation operation.
5511 * @see rte_flow_action_handle_create
5513 * @param[in] port_id
5514 * Port identifier of Ethernet device.
5515 * @param[in] queue_id
5516 * Flow queue which is used to create the rule.
5517 * @param[in] op_attr
5518 * Indirect action creation operation attributes.
5519 * @param[in] indir_action_conf
5520 * Action configuration for the indirect action object creation.
5522 * Specific configuration of the indirect action object.
5523 * @param[in] user_data
5524 * The user data that will be returned on the completion events.
5526 * Perform verbose error reporting if not NULL.
5527 * PMDs initialize this structure in case of error only.
5530 * A valid handle in case of success, NULL otherwise and rte_errno is set.
5533 struct rte_flow_action_handle *
5534 rte_flow_async_action_handle_create(uint16_t port_id,
5536 const struct rte_flow_op_attr *op_attr,
5537 const struct rte_flow_indir_action_conf *indir_action_conf,
5538 const struct rte_flow_action *action,
5540 struct rte_flow_error *error);
5544 * @b EXPERIMENTAL: this API may change without prior notice.
5546 * Enqueue indirect action destruction operation.
5547 * The destroy queue must be the same
5548 * as the queue on which the action was created.
5550 * @param[in] port_id
5551 * Port identifier of Ethernet device.
5552 * @param[in] queue_id
5553 * Flow queue which is used to destroy the rule.
5554 * @param[in] op_attr
5555 * Indirect action destruction operation attributes.
5556 * @param[in] action_handle
5557 * Handle for the indirect action object to be destroyed.
5558 * @param[in] user_data
5559 * The user data that will be returned on the completion events.
5561 * Perform verbose error reporting if not NULL.
5562 * PMDs initialize this structure in case of error only.
5565 * 0 on success, a negative errno value otherwise and rte_errno is set.
5569 rte_flow_async_action_handle_destroy(uint16_t port_id,
5571 const struct rte_flow_op_attr *op_attr,
5572 struct rte_flow_action_handle *action_handle,
5574 struct rte_flow_error *error);
5578 * @b EXPERIMENTAL: this API may change without prior notice.
5580 * Enqueue indirect action update operation.
5581 * @see rte_flow_action_handle_create
5583 * @param[in] port_id
5584 * Port identifier of Ethernet device.
5585 * @param[in] queue_id
5586 * Flow queue which is used to update the rule.
5587 * @param[in] op_attr
5588 * Indirect action update operation attributes.
5589 * @param[in] action_handle
5590 * Handle for the indirect action object to be updated.
5592 * Update profile specification used to modify the action pointed by handle.
5593 * *update* could be with the same type of the immediate action corresponding
5594 * to the *handle* argument when creating, or a wrapper structure includes
5595 * action configuration to be updated and bit fields to indicate the member
5596 * of fields inside the action to update.
5597 * @param[in] user_data
5598 * The user data that will be returned on the completion events.
5600 * Perform verbose error reporting if not NULL.
5601 * PMDs initialize this structure in case of error only.
5604 * 0 on success, a negative errno value otherwise and rte_errno is set.
5608 rte_flow_async_action_handle_update(uint16_t port_id,
5610 const struct rte_flow_op_attr *op_attr,
5611 struct rte_flow_action_handle *action_handle,
5614 struct rte_flow_error *error);
5619 #endif /* RTE_FLOW_H_ */