1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright 2016 6WIND S.A.
3 * Copyright 2016 Mellanox Technologies, Ltd
11 * RTE generic flow API
13 * This interface provides the ability to program packet matching and
14 * associated actions in hardware through flow rules.
21 #include <rte_common.h>
22 #include <rte_ether.h>
28 #include <rte_vxlan.h>
29 #include <rte_byteorder.h>
31 #include <rte_higig.h>
32 #include <rte_ecpri.h>
33 #include <rte_bitops.h>
35 #include <rte_mbuf_dyn.h>
36 #include <rte_meter.h>
44 * Flow rule attributes.
46 * Priorities are set on a per rule based within groups.
48 * Lower values denote higher priority, the highest priority for a flow rule
49 * is 0, so that a flow that matches for than one rule, the rule with the
50 * lowest priority value will always be matched.
52 * Although optional, applications are encouraged to group similar rules as
53 * much as possible to fully take advantage of hardware capabilities
54 * (e.g. optimized matching) and work around limitations (e.g. a single
55 * pattern type possibly allowed in a given group). Applications should be
56 * aware that groups are not linked by default, and that they must be
57 * explicitly linked by the application using the JUMP action.
59 * Priority levels are arbitrary and up to the application, they
60 * do not need to be contiguous nor start from 0, however the maximum number
61 * varies between devices and may be affected by existing flow rules.
63 * If a packet is matched by several rules of a given group for a given
64 * priority level, the outcome is undefined. It can take any path, may be
65 * duplicated or even cause unrecoverable errors.
67 * Note that support for more than a single group and priority level is not
70 * At vNIC / ethdev level, flow rules can apply to inbound and / or outbound
71 * traffic (ingress / egress), with respect to the vNIC / ethdev in question.
72 * At embedded switch level, flow rules apply to all traffic seen by it
73 * unless fitting meta items are used to set concrete traffic source(s).
75 * Several pattern items and actions are valid and can be used in both
76 * directions. Those valid for only one direction are described as such.
78 * At least one direction must be specified.
80 * Specifying both directions at once for a given rule is not recommended
81 * but may be valid in a few cases.
83 struct rte_flow_attr {
84 uint32_t group; /**< Priority group. */
85 uint32_t priority; /**< Rule priority level within group. */
87 * The rule in question applies to ingress traffic (non-"transfer").
90 * It has been possible to combine this attribute with "transfer".
91 * Doing so has been assumed to restrict the scope of matching
92 * to traffic going from within the embedded switch toward the
93 * ethdev the flow rule being created through. This behaviour
94 * is deprecated. During the transition period, one may still
95 * rely on it, but PMDs and applications are encouraged to
96 * gradually move away from this approach.
100 * The rule in question applies to egress traffic (non-"transfer").
103 * It has been possible to combine this attribute with "transfer".
104 * Doing so has been assumed to restrict the scope of matching
105 * to traffic sent by the application by virtue of the ethdev
106 * the flow rule being created through. This behaviour is now
107 * deprecated. During the transition period, one may still
108 * rely on it, but PMDs and applications are encouraged to
109 * gradually move away from this approach.
113 * Instead of simply matching the properties of traffic as it would
114 * appear on a given DPDK port ID, enabling this attribute transfers
115 * a flow rule to the lowest possible level of any device endpoints
116 * found in the pattern.
118 * When supported, this effectively enables an application to
119 * re-route traffic not necessarily intended for it (e.g. coming
120 * from or addressed to different physical ports, VFs or
121 * applications) at the device level.
123 * The application should match traffic originating from precise
124 * locations. See items PORT_REPRESENTOR and REPRESENTED_PORT.
126 * Managing "transfer" flows requires that the user communicate them
127 * through a suitable port. @see rte_flow_pick_transfer_proxy().
130 uint32_t reserved:29; /**< Reserved, must be zero. */
134 * Matching pattern item types.
136 * Pattern items fall in two categories:
138 * - Matching protocol headers and packet data, usually associated with a
139 * specification structure. These must be stacked in the same order as the
140 * protocol layers to match inside packets, starting from the lowest.
142 * - Matching meta-data or affecting pattern processing, often without a
143 * specification structure. Since they do not match packet contents, their
144 * position in the list is usually not relevant.
146 * See the description of individual types for more information. Those
147 * marked with [META] fall into the second category.
149 enum rte_flow_item_type {
153 * End marker for item lists. Prevents further processing of items,
154 * thereby ending the pattern.
156 * No associated specification structure.
158 RTE_FLOW_ITEM_TYPE_END,
163 * Used as a placeholder for convenience. It is ignored and simply
166 * No associated specification structure.
168 RTE_FLOW_ITEM_TYPE_VOID,
173 * Inverted matching, i.e. process packets that do not match the
176 * No associated specification structure.
178 RTE_FLOW_ITEM_TYPE_INVERT,
181 * Matches any protocol in place of the current layer, a single ANY
182 * may also stand for several protocol layers.
184 * See struct rte_flow_item_any.
186 RTE_FLOW_ITEM_TYPE_ANY,
190 * @see RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR
191 * @see RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT
195 * Matches traffic originating from (ingress) or going to (egress)
196 * the physical function of the current device.
198 * No associated specification structure.
200 RTE_FLOW_ITEM_TYPE_PF,
204 * @see RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR
205 * @see RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT
209 * Matches traffic originating from (ingress) or going to (egress) a
210 * given virtual function of the current device.
212 * See struct rte_flow_item_vf.
214 RTE_FLOW_ITEM_TYPE_VF,
218 * @see RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR
219 * @see RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT
223 * Matches traffic originating from (ingress) or going to (egress) a
224 * physical port of the underlying device.
226 * See struct rte_flow_item_phy_port.
228 RTE_FLOW_ITEM_TYPE_PHY_PORT,
232 * @see RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR
233 * @see RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT
237 * Matches traffic originating from (ingress) or going to (egress) a
238 * given DPDK port ID.
240 * See struct rte_flow_item_port_id.
242 RTE_FLOW_ITEM_TYPE_PORT_ID,
245 * Matches a byte string of a given length at a given offset.
247 * See struct rte_flow_item_raw.
249 RTE_FLOW_ITEM_TYPE_RAW,
252 * Matches an Ethernet header.
254 * See struct rte_flow_item_eth.
256 RTE_FLOW_ITEM_TYPE_ETH,
259 * Matches an 802.1Q/ad VLAN tag.
261 * See struct rte_flow_item_vlan.
263 RTE_FLOW_ITEM_TYPE_VLAN,
266 * Matches an IPv4 header.
268 * See struct rte_flow_item_ipv4.
270 RTE_FLOW_ITEM_TYPE_IPV4,
273 * Matches an IPv6 header.
275 * See struct rte_flow_item_ipv6.
277 RTE_FLOW_ITEM_TYPE_IPV6,
280 * Matches an ICMP header.
282 * See struct rte_flow_item_icmp.
284 RTE_FLOW_ITEM_TYPE_ICMP,
287 * Matches a UDP header.
289 * See struct rte_flow_item_udp.
291 RTE_FLOW_ITEM_TYPE_UDP,
294 * Matches a TCP header.
296 * See struct rte_flow_item_tcp.
298 RTE_FLOW_ITEM_TYPE_TCP,
301 * Matches a SCTP header.
303 * See struct rte_flow_item_sctp.
305 RTE_FLOW_ITEM_TYPE_SCTP,
308 * Matches a VXLAN header.
310 * See struct rte_flow_item_vxlan.
312 RTE_FLOW_ITEM_TYPE_VXLAN,
315 * Matches a E_TAG header.
317 * See struct rte_flow_item_e_tag.
319 RTE_FLOW_ITEM_TYPE_E_TAG,
322 * Matches a NVGRE header.
324 * See struct rte_flow_item_nvgre.
326 RTE_FLOW_ITEM_TYPE_NVGRE,
329 * Matches a MPLS header.
331 * See struct rte_flow_item_mpls.
333 RTE_FLOW_ITEM_TYPE_MPLS,
336 * Matches a GRE header.
338 * See struct rte_flow_item_gre.
340 RTE_FLOW_ITEM_TYPE_GRE,
345 * Fuzzy pattern match, expect faster than default.
347 * This is for device that support fuzzy matching option.
348 * Usually a fuzzy matching is fast but the cost is accuracy.
350 * See struct rte_flow_item_fuzzy.
352 RTE_FLOW_ITEM_TYPE_FUZZY,
355 * Matches a GTP header.
357 * Configure flow for GTP packets.
359 * See struct rte_flow_item_gtp.
361 RTE_FLOW_ITEM_TYPE_GTP,
364 * Matches a GTP header.
366 * Configure flow for GTP-C packets.
368 * See struct rte_flow_item_gtp.
370 RTE_FLOW_ITEM_TYPE_GTPC,
373 * Matches a GTP header.
375 * Configure flow for GTP-U packets.
377 * See struct rte_flow_item_gtp.
379 RTE_FLOW_ITEM_TYPE_GTPU,
382 * Matches a ESP header.
384 * See struct rte_flow_item_esp.
386 RTE_FLOW_ITEM_TYPE_ESP,
389 * Matches a GENEVE header.
391 * See struct rte_flow_item_geneve.
393 RTE_FLOW_ITEM_TYPE_GENEVE,
396 * Matches a VXLAN-GPE header.
398 * See struct rte_flow_item_vxlan_gpe.
400 RTE_FLOW_ITEM_TYPE_VXLAN_GPE,
403 * Matches an ARP header for Ethernet/IPv4.
405 * See struct rte_flow_item_arp_eth_ipv4.
407 RTE_FLOW_ITEM_TYPE_ARP_ETH_IPV4,
410 * Matches the presence of any IPv6 extension header.
412 * See struct rte_flow_item_ipv6_ext.
414 RTE_FLOW_ITEM_TYPE_IPV6_EXT,
417 * Matches any ICMPv6 header.
419 * See struct rte_flow_item_icmp6.
421 RTE_FLOW_ITEM_TYPE_ICMP6,
424 * Matches an ICMPv6 neighbor discovery solicitation.
426 * See struct rte_flow_item_icmp6_nd_ns.
428 RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS,
431 * Matches an ICMPv6 neighbor discovery advertisement.
433 * See struct rte_flow_item_icmp6_nd_na.
435 RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA,
438 * Matches the presence of any ICMPv6 neighbor discovery option.
440 * See struct rte_flow_item_icmp6_nd_opt.
442 RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT,
445 * Matches an ICMPv6 neighbor discovery source Ethernet link-layer
448 * See struct rte_flow_item_icmp6_nd_opt_sla_eth.
450 RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_SLA_ETH,
453 * Matches an ICMPv6 neighbor discovery target Ethernet link-layer
456 * See struct rte_flow_item_icmp6_nd_opt_tla_eth.
458 RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_TLA_ETH,
461 * Matches specified mark field.
463 * See struct rte_flow_item_mark.
465 RTE_FLOW_ITEM_TYPE_MARK,
470 * Matches a metadata value.
472 * See struct rte_flow_item_meta.
474 RTE_FLOW_ITEM_TYPE_META,
477 * Matches a GRE optional key field.
479 * The value should a big-endian 32bit integer.
481 * When this item present the K bit is implicitly matched as "1"
482 * in the default mask.
485 * @code rte_be32_t * @endcode
487 RTE_FLOW_ITEM_TYPE_GRE_KEY,
490 * Matches a GTP extension header: PDU session container.
492 * Configure flow for GTP packets with extension header type 0x85.
494 * See struct rte_flow_item_gtp_psc.
496 RTE_FLOW_ITEM_TYPE_GTP_PSC,
499 * Matches a PPPoE header.
501 * Configure flow for PPPoE session packets.
503 * See struct rte_flow_item_pppoe.
505 RTE_FLOW_ITEM_TYPE_PPPOES,
508 * Matches a PPPoE header.
510 * Configure flow for PPPoE discovery packets.
512 * See struct rte_flow_item_pppoe.
514 RTE_FLOW_ITEM_TYPE_PPPOED,
517 * Matches a PPPoE optional proto_id field.
519 * It only applies to PPPoE session packets.
521 * See struct rte_flow_item_pppoe_proto_id.
523 RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID,
526 * Matches Network service header (NSH).
527 * See struct rte_flow_item_nsh.
530 RTE_FLOW_ITEM_TYPE_NSH,
533 * Matches Internet Group Management Protocol (IGMP).
534 * See struct rte_flow_item_igmp.
537 RTE_FLOW_ITEM_TYPE_IGMP,
540 * Matches IP Authentication Header (AH).
541 * See struct rte_flow_item_ah.
544 RTE_FLOW_ITEM_TYPE_AH,
547 * Matches a HIGIG header.
548 * see struct rte_flow_item_higig2_hdr.
550 RTE_FLOW_ITEM_TYPE_HIGIG2,
555 * Matches a tag value.
557 * See struct rte_flow_item_tag.
559 RTE_FLOW_ITEM_TYPE_TAG,
562 * Matches a L2TPv3 over IP header.
564 * Configure flow for L2TPv3 over IP packets.
566 * See struct rte_flow_item_l2tpv3oip.
568 RTE_FLOW_ITEM_TYPE_L2TPV3OIP,
571 * Matches PFCP Header.
572 * See struct rte_flow_item_pfcp.
575 RTE_FLOW_ITEM_TYPE_PFCP,
578 * Matches eCPRI Header.
580 * Configure flow for eCPRI over ETH or UDP packets.
582 * See struct rte_flow_item_ecpri.
584 RTE_FLOW_ITEM_TYPE_ECPRI,
587 * Matches the presence of IPv6 fragment extension header.
589 * See struct rte_flow_item_ipv6_frag_ext.
591 RTE_FLOW_ITEM_TYPE_IPV6_FRAG_EXT,
594 * Matches Geneve Variable Length Option
596 * See struct rte_flow_item_geneve_opt
598 RTE_FLOW_ITEM_TYPE_GENEVE_OPT,
603 * Matches on packet integrity.
604 * For some devices application needs to enable integration checks in HW
605 * before using this item.
607 * @see struct rte_flow_item_integrity.
609 RTE_FLOW_ITEM_TYPE_INTEGRITY,
614 * Matches conntrack state.
616 * @see struct rte_flow_item_conntrack.
618 RTE_FLOW_ITEM_TYPE_CONNTRACK,
623 * Matches traffic entering the embedded switch from the given ethdev.
625 * @see struct rte_flow_item_ethdev
627 RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR,
632 * Matches traffic entering the embedded switch from
633 * the entity represented by the given ethdev.
635 * @see struct rte_flow_item_ethdev
637 RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT,
642 * RTE_FLOW_ITEM_TYPE_HIGIG2
643 * Matches higig2 header
646 struct rte_flow_item_higig2_hdr {
647 struct rte_higig2_hdr hdr;
650 /** Default mask for RTE_FLOW_ITEM_TYPE_HIGIG2. */
652 static const struct rte_flow_item_higig2_hdr rte_flow_item_higig2_hdr_mask = {
655 .classification = 0xffff,
663 * RTE_FLOW_ITEM_TYPE_ANY
665 * Matches any protocol in place of the current layer, a single ANY may also
666 * stand for several protocol layers.
668 * This is usually specified as the first pattern item when looking for a
669 * protocol anywhere in a packet.
671 * A zeroed mask stands for any number of layers.
673 struct rte_flow_item_any {
674 uint32_t num; /**< Number of layers covered. */
677 /** Default mask for RTE_FLOW_ITEM_TYPE_ANY. */
679 static const struct rte_flow_item_any rte_flow_item_any_mask = {
686 * @see RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR
687 * @see RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT
689 * RTE_FLOW_ITEM_TYPE_VF
691 * Matches traffic originating from (ingress) or going to (egress) a given
692 * virtual function of the current device.
694 * If supported, should work even if the virtual function is not managed by
695 * the application and thus not associated with a DPDK port ID.
697 * Note this pattern item does not match VF representors traffic which, as
698 * separate entities, should be addressed through their own DPDK port IDs.
700 * - Can be specified multiple times to match traffic addressed to several
702 * - Can be combined with a PF item to match both PF and VF traffic.
704 * A zeroed mask can be used to match any VF ID.
706 struct rte_flow_item_vf {
707 uint32_t id; /**< VF ID. */
710 /** Default mask for RTE_FLOW_ITEM_TYPE_VF. */
712 static const struct rte_flow_item_vf rte_flow_item_vf_mask = {
719 * @see RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR
720 * @see RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT
722 * RTE_FLOW_ITEM_TYPE_PHY_PORT
724 * Matches traffic originating from (ingress) or going to (egress) a
725 * physical port of the underlying device.
727 * The first PHY_PORT item overrides the physical port normally associated
728 * with the specified DPDK input port (port_id). This item can be provided
729 * several times to match additional physical ports.
731 * Note that physical ports are not necessarily tied to DPDK input ports
732 * (port_id) when those are not under DPDK control. Possible values are
733 * specific to each device, they are not necessarily indexed from zero and
734 * may not be contiguous.
736 * As a device property, the list of allowed values as well as the value
737 * associated with a port_id should be retrieved by other means.
739 * A zeroed mask can be used to match any port index.
741 struct rte_flow_item_phy_port {
742 uint32_t index; /**< Physical port index. */
745 /** Default mask for RTE_FLOW_ITEM_TYPE_PHY_PORT. */
747 static const struct rte_flow_item_phy_port rte_flow_item_phy_port_mask = {
754 * @see RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR
755 * @see RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT
757 * RTE_FLOW_ITEM_TYPE_PORT_ID
759 * Matches traffic originating from (ingress) or going to (egress) a given
762 * Normally only supported if the port ID in question is known by the
763 * underlying PMD and related to the device the flow rule is created
766 * This must not be confused with @p PHY_PORT which refers to the physical
767 * port of a device, whereas @p PORT_ID refers to a struct rte_eth_dev
768 * object on the application side (also known as "port representor"
769 * depending on the kind of underlying device).
771 struct rte_flow_item_port_id {
772 uint32_t id; /**< DPDK port ID. */
775 /** Default mask for RTE_FLOW_ITEM_TYPE_PORT_ID. */
777 static const struct rte_flow_item_port_id rte_flow_item_port_id_mask = {
783 * RTE_FLOW_ITEM_TYPE_RAW
785 * Matches a byte string of a given length at a given offset.
787 * Offset is either absolute (using the start of the packet) or relative to
788 * the end of the previous matched item in the stack, in which case negative
789 * values are allowed.
791 * If search is enabled, offset is used as the starting point. The search
792 * area can be delimited by setting limit to a nonzero value, which is the
793 * maximum number of bytes after offset where the pattern may start.
795 * Matching a zero-length pattern is allowed, doing so resets the relative
796 * offset for subsequent items.
798 * This type does not support ranges (struct rte_flow_item.last).
800 struct rte_flow_item_raw {
801 uint32_t relative:1; /**< Look for pattern after the previous item. */
802 uint32_t search:1; /**< Search pattern from offset (see also limit). */
803 uint32_t reserved:30; /**< Reserved, must be set to zero. */
804 int32_t offset; /**< Absolute or relative offset for pattern. */
805 uint16_t limit; /**< Search area limit for start of pattern. */
806 uint16_t length; /**< Pattern length. */
807 const uint8_t *pattern; /**< Byte string to look for. */
810 /** Default mask for RTE_FLOW_ITEM_TYPE_RAW. */
812 static const struct rte_flow_item_raw rte_flow_item_raw_mask = {
815 .reserved = 0x3fffffff,
816 .offset = 0xffffffff,
824 * RTE_FLOW_ITEM_TYPE_ETH
826 * Matches an Ethernet header.
828 * Inside @p hdr field, the sub-field @p ether_type stands either for EtherType
829 * or TPID, depending on whether the item is followed by a VLAN item or not. If
830 * two VLAN items follow, the sub-field refers to the outer one, which, in turn,
831 * contains the inner TPID in the similar header field. The innermost VLAN item
832 * contains a layer-3 EtherType. All of that follows the order seen on the wire.
834 * If the field in question contains a TPID value, only tagged packets with the
835 * specified TPID will match the pattern. Alternatively, it's possible to match
836 * any type of tagged packets by means of the field @p has_vlan rather than use
837 * the EtherType/TPID field. Also, it's possible to leave the two fields unused.
838 * If this is the case, both tagged and untagged packets will match the pattern.
841 struct rte_flow_item_eth {
845 * These fields are retained for compatibility.
846 * Please switch to the new header field below.
848 struct rte_ether_addr dst; /**< Destination MAC. */
849 struct rte_ether_addr src; /**< Source MAC. */
850 rte_be16_t type; /**< EtherType or TPID. */
852 struct rte_ether_hdr hdr;
854 uint32_t has_vlan:1; /**< Packet header contains at least one VLAN. */
855 uint32_t reserved:31; /**< Reserved, must be zero. */
858 /** Default mask for RTE_FLOW_ITEM_TYPE_ETH. */
860 static const struct rte_flow_item_eth rte_flow_item_eth_mask = {
861 .hdr.dst_addr.addr_bytes = "\xff\xff\xff\xff\xff\xff",
862 .hdr.src_addr.addr_bytes = "\xff\xff\xff\xff\xff\xff",
863 .hdr.ether_type = RTE_BE16(0x0000),
868 * RTE_FLOW_ITEM_TYPE_VLAN
870 * Matches an 802.1Q/ad VLAN tag.
872 * The corresponding standard outer EtherType (TPID) values are
873 * RTE_ETHER_TYPE_VLAN or RTE_ETHER_TYPE_QINQ. It can be overridden by
874 * the preceding pattern item.
875 * If a @p VLAN item is present in the pattern, then only tagged packets will
877 * The field @p has_more_vlan can be used to match any type of tagged packets,
878 * instead of using the @p eth_proto field of @p hdr.
879 * If the @p eth_proto of @p hdr and @p has_more_vlan fields are not specified,
880 * then any tagged packets will match the pattern.
883 struct rte_flow_item_vlan {
887 * These fields are retained for compatibility.
888 * Please switch to the new header field below.
890 rte_be16_t tci; /**< Tag control information. */
891 rte_be16_t inner_type; /**< Inner EtherType or TPID. */
893 struct rte_vlan_hdr hdr;
895 uint32_t has_more_vlan:1;
896 /**< Packet header contains at least one more VLAN, after this VLAN. */
897 uint32_t reserved:31; /**< Reserved, must be zero. */
900 /** Default mask for RTE_FLOW_ITEM_TYPE_VLAN. */
902 static const struct rte_flow_item_vlan rte_flow_item_vlan_mask = {
903 .hdr.vlan_tci = RTE_BE16(0x0fff),
904 .hdr.eth_proto = RTE_BE16(0x0000),
909 * RTE_FLOW_ITEM_TYPE_IPV4
911 * Matches an IPv4 header.
913 * Note: IPv4 options are handled by dedicated pattern items.
915 struct rte_flow_item_ipv4 {
916 struct rte_ipv4_hdr hdr; /**< IPv4 header definition. */
919 /** Default mask for RTE_FLOW_ITEM_TYPE_IPV4. */
921 static const struct rte_flow_item_ipv4 rte_flow_item_ipv4_mask = {
923 .src_addr = RTE_BE32(0xffffffff),
924 .dst_addr = RTE_BE32(0xffffffff),
930 * RTE_FLOW_ITEM_TYPE_IPV6.
932 * Matches an IPv6 header.
934 * Dedicated flags indicate if header contains specific extension headers.
936 struct rte_flow_item_ipv6 {
937 struct rte_ipv6_hdr hdr; /**< IPv6 header definition. */
938 uint32_t has_hop_ext:1;
939 /**< Header contains Hop-by-Hop Options extension header. */
940 uint32_t has_route_ext:1;
941 /**< Header contains Routing extension header. */
942 uint32_t has_frag_ext:1;
943 /**< Header contains Fragment extension header. */
944 uint32_t has_auth_ext:1;
945 /**< Header contains Authentication extension header. */
946 uint32_t has_esp_ext:1;
947 /**< Header contains Encapsulation Security Payload extension header. */
948 uint32_t has_dest_ext:1;
949 /**< Header contains Destination Options extension header. */
950 uint32_t has_mobil_ext:1;
951 /**< Header contains Mobility extension header. */
952 uint32_t has_hip_ext:1;
953 /**< Header contains Host Identity Protocol extension header. */
954 uint32_t has_shim6_ext:1;
955 /**< Header contains Shim6 Protocol extension header. */
956 uint32_t reserved:23;
957 /**< Reserved for future extension headers, must be zero. */
960 /** Default mask for RTE_FLOW_ITEM_TYPE_IPV6. */
962 static const struct rte_flow_item_ipv6 rte_flow_item_ipv6_mask = {
965 "\xff\xff\xff\xff\xff\xff\xff\xff"
966 "\xff\xff\xff\xff\xff\xff\xff\xff",
968 "\xff\xff\xff\xff\xff\xff\xff\xff"
969 "\xff\xff\xff\xff\xff\xff\xff\xff",
975 * RTE_FLOW_ITEM_TYPE_ICMP.
977 * Matches an ICMP header.
979 struct rte_flow_item_icmp {
980 struct rte_icmp_hdr hdr; /**< ICMP header definition. */
983 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP. */
985 static const struct rte_flow_item_icmp rte_flow_item_icmp_mask = {
994 * RTE_FLOW_ITEM_TYPE_UDP.
996 * Matches a UDP header.
998 struct rte_flow_item_udp {
999 struct rte_udp_hdr hdr; /**< UDP header definition. */
1002 /** Default mask for RTE_FLOW_ITEM_TYPE_UDP. */
1004 static const struct rte_flow_item_udp rte_flow_item_udp_mask = {
1006 .src_port = RTE_BE16(0xffff),
1007 .dst_port = RTE_BE16(0xffff),
1013 * RTE_FLOW_ITEM_TYPE_TCP.
1015 * Matches a TCP header.
1017 struct rte_flow_item_tcp {
1018 struct rte_tcp_hdr hdr; /**< TCP header definition. */
1021 /** Default mask for RTE_FLOW_ITEM_TYPE_TCP. */
1023 static const struct rte_flow_item_tcp rte_flow_item_tcp_mask = {
1025 .src_port = RTE_BE16(0xffff),
1026 .dst_port = RTE_BE16(0xffff),
1032 * RTE_FLOW_ITEM_TYPE_SCTP.
1034 * Matches a SCTP header.
1036 struct rte_flow_item_sctp {
1037 struct rte_sctp_hdr hdr; /**< SCTP header definition. */
1040 /** Default mask for RTE_FLOW_ITEM_TYPE_SCTP. */
1042 static const struct rte_flow_item_sctp rte_flow_item_sctp_mask = {
1044 .src_port = RTE_BE16(0xffff),
1045 .dst_port = RTE_BE16(0xffff),
1051 * RTE_FLOW_ITEM_TYPE_VXLAN.
1053 * Matches a VXLAN header (RFC 7348).
1056 struct rte_flow_item_vxlan {
1060 * These fields are retained for compatibility.
1061 * Please switch to the new header field below.
1063 uint8_t flags; /**< Normally 0x08 (I flag). */
1064 uint8_t rsvd0[3]; /**< Reserved, normally 0x000000. */
1065 uint8_t vni[3]; /**< VXLAN identifier. */
1066 uint8_t rsvd1; /**< Reserved, normally 0x00. */
1068 struct rte_vxlan_hdr hdr;
1072 /** Default mask for RTE_FLOW_ITEM_TYPE_VXLAN. */
1074 static const struct rte_flow_item_vxlan rte_flow_item_vxlan_mask = {
1075 .hdr.vx_vni = RTE_BE32(0xffffff00), /* (0xffffff << 8) */
1080 * RTE_FLOW_ITEM_TYPE_E_TAG.
1082 * Matches a E-tag header.
1084 * The corresponding standard outer EtherType (TPID) value is
1085 * RTE_ETHER_TYPE_ETAG. It can be overridden by the preceding pattern item.
1087 struct rte_flow_item_e_tag {
1089 * E-Tag control information (E-TCI).
1090 * E-PCP (3b), E-DEI (1b), ingress E-CID base (12b).
1092 rte_be16_t epcp_edei_in_ecid_b;
1093 /** Reserved (2b), GRP (2b), E-CID base (12b). */
1094 rte_be16_t rsvd_grp_ecid_b;
1095 uint8_t in_ecid_e; /**< Ingress E-CID ext. */
1096 uint8_t ecid_e; /**< E-CID ext. */
1097 rte_be16_t inner_type; /**< Inner EtherType or TPID. */
1100 /** Default mask for RTE_FLOW_ITEM_TYPE_E_TAG. */
1102 static const struct rte_flow_item_e_tag rte_flow_item_e_tag_mask = {
1103 .rsvd_grp_ecid_b = RTE_BE16(0x3fff),
1108 * RTE_FLOW_ITEM_TYPE_NVGRE.
1110 * Matches a NVGRE header.
1112 struct rte_flow_item_nvgre {
1114 * Checksum (1b), undefined (1b), key bit (1b), sequence number (1b),
1115 * reserved 0 (9b), version (3b).
1117 * c_k_s_rsvd0_ver must have value 0x2000 according to RFC 7637.
1119 rte_be16_t c_k_s_rsvd0_ver;
1120 rte_be16_t protocol; /**< Protocol type (0x6558). */
1121 uint8_t tni[3]; /**< Virtual subnet ID. */
1122 uint8_t flow_id; /**< Flow ID. */
1125 /** Default mask for RTE_FLOW_ITEM_TYPE_NVGRE. */
1127 static const struct rte_flow_item_nvgre rte_flow_item_nvgre_mask = {
1128 .tni = "\xff\xff\xff",
1133 * RTE_FLOW_ITEM_TYPE_MPLS.
1135 * Matches a MPLS header.
1137 struct rte_flow_item_mpls {
1139 * Label (20b), TC (3b), Bottom of Stack (1b).
1141 uint8_t label_tc_s[3];
1142 uint8_t ttl; /** Time-to-Live. */
1145 /** Default mask for RTE_FLOW_ITEM_TYPE_MPLS. */
1147 static const struct rte_flow_item_mpls rte_flow_item_mpls_mask = {
1148 .label_tc_s = "\xff\xff\xf0",
1153 * RTE_FLOW_ITEM_TYPE_GRE.
1155 * Matches a GRE header.
1157 struct rte_flow_item_gre {
1159 * Checksum (1b), reserved 0 (12b), version (3b).
1160 * Refer to RFC 2784.
1162 rte_be16_t c_rsvd0_ver;
1163 rte_be16_t protocol; /**< Protocol type. */
1166 /** Default mask for RTE_FLOW_ITEM_TYPE_GRE. */
1168 static const struct rte_flow_item_gre rte_flow_item_gre_mask = {
1169 .protocol = RTE_BE16(0xffff),
1174 * RTE_FLOW_ITEM_TYPE_FUZZY
1176 * Fuzzy pattern match, expect faster than default.
1178 * This is for device that support fuzzy match option.
1179 * Usually a fuzzy match is fast but the cost is accuracy.
1180 * i.e. Signature Match only match pattern's hash value, but it is
1181 * possible two different patterns have the same hash value.
1183 * Matching accuracy level can be configure by threshold.
1184 * Driver can divide the range of threshold and map to different
1185 * accuracy levels that device support.
1187 * Threshold 0 means perfect match (no fuzziness), while threshold
1188 * 0xffffffff means fuzziest match.
1190 struct rte_flow_item_fuzzy {
1191 uint32_t thresh; /**< Accuracy threshold. */
1194 /** Default mask for RTE_FLOW_ITEM_TYPE_FUZZY. */
1196 static const struct rte_flow_item_fuzzy rte_flow_item_fuzzy_mask = {
1197 .thresh = 0xffffffff,
1202 * RTE_FLOW_ITEM_TYPE_GTP.
1204 * Matches a GTPv1 header.
1206 struct rte_flow_item_gtp {
1208 * Version (3b), protocol type (1b), reserved (1b),
1209 * Extension header flag (1b),
1210 * Sequence number flag (1b),
1211 * N-PDU number flag (1b).
1213 uint8_t v_pt_rsv_flags;
1214 uint8_t msg_type; /**< Message type. */
1215 rte_be16_t msg_len; /**< Message length. */
1216 rte_be32_t teid; /**< Tunnel endpoint identifier. */
1219 /** Default mask for RTE_FLOW_ITEM_TYPE_GTP. */
1221 static const struct rte_flow_item_gtp rte_flow_item_gtp_mask = {
1222 .teid = RTE_BE32(0xffffffff),
1227 * RTE_FLOW_ITEM_TYPE_ESP
1229 * Matches an ESP header.
1231 struct rte_flow_item_esp {
1232 struct rte_esp_hdr hdr; /**< ESP header definition. */
1235 /** Default mask for RTE_FLOW_ITEM_TYPE_ESP. */
1237 static const struct rte_flow_item_esp rte_flow_item_esp_mask = {
1239 .spi = RTE_BE32(0xffffffff),
1245 * RTE_FLOW_ITEM_TYPE_GENEVE.
1247 * Matches a GENEVE header.
1249 struct rte_flow_item_geneve {
1251 * Version (2b), length of the options fields (6b), OAM packet (1b),
1252 * critical options present (1b), reserved 0 (6b).
1254 rte_be16_t ver_opt_len_o_c_rsvd0;
1255 rte_be16_t protocol; /**< Protocol type. */
1256 uint8_t vni[3]; /**< Virtual Network Identifier. */
1257 uint8_t rsvd1; /**< Reserved, normally 0x00. */
1260 /** Default mask for RTE_FLOW_ITEM_TYPE_GENEVE. */
1262 static const struct rte_flow_item_geneve rte_flow_item_geneve_mask = {
1263 .vni = "\xff\xff\xff",
1268 * RTE_FLOW_ITEM_TYPE_VXLAN_GPE (draft-ietf-nvo3-vxlan-gpe-05).
1270 * Matches a VXLAN-GPE header.
1272 struct rte_flow_item_vxlan_gpe {
1273 uint8_t flags; /**< Normally 0x0c (I and P flags). */
1274 uint8_t rsvd0[2]; /**< Reserved, normally 0x0000. */
1275 uint8_t protocol; /**< Protocol type. */
1276 uint8_t vni[3]; /**< VXLAN identifier. */
1277 uint8_t rsvd1; /**< Reserved, normally 0x00. */
1280 /** Default mask for RTE_FLOW_ITEM_TYPE_VXLAN_GPE. */
1282 static const struct rte_flow_item_vxlan_gpe rte_flow_item_vxlan_gpe_mask = {
1283 .vni = "\xff\xff\xff",
1288 * RTE_FLOW_ITEM_TYPE_ARP_ETH_IPV4
1290 * Matches an ARP header for Ethernet/IPv4.
1292 struct rte_flow_item_arp_eth_ipv4 {
1293 rte_be16_t hrd; /**< Hardware type, normally 1. */
1294 rte_be16_t pro; /**< Protocol type, normally 0x0800. */
1295 uint8_t hln; /**< Hardware address length, normally 6. */
1296 uint8_t pln; /**< Protocol address length, normally 4. */
1297 rte_be16_t op; /**< Opcode (1 for request, 2 for reply). */
1298 struct rte_ether_addr sha; /**< Sender hardware address. */
1299 rte_be32_t spa; /**< Sender IPv4 address. */
1300 struct rte_ether_addr tha; /**< Target hardware address. */
1301 rte_be32_t tpa; /**< Target IPv4 address. */
1304 /** Default mask for RTE_FLOW_ITEM_TYPE_ARP_ETH_IPV4. */
1306 static const struct rte_flow_item_arp_eth_ipv4
1307 rte_flow_item_arp_eth_ipv4_mask = {
1308 .sha.addr_bytes = "\xff\xff\xff\xff\xff\xff",
1309 .spa = RTE_BE32(0xffffffff),
1310 .tha.addr_bytes = "\xff\xff\xff\xff\xff\xff",
1311 .tpa = RTE_BE32(0xffffffff),
1316 * RTE_FLOW_ITEM_TYPE_IPV6_EXT
1318 * Matches the presence of any IPv6 extension header.
1320 * Normally preceded by any of:
1322 * - RTE_FLOW_ITEM_TYPE_IPV6
1323 * - RTE_FLOW_ITEM_TYPE_IPV6_EXT
1325 struct rte_flow_item_ipv6_ext {
1326 uint8_t next_hdr; /**< Next header. */
1329 /** Default mask for RTE_FLOW_ITEM_TYPE_IPV6_EXT. */
1332 struct rte_flow_item_ipv6_ext rte_flow_item_ipv6_ext_mask = {
1338 * RTE_FLOW_ITEM_TYPE_IPV6_FRAG_EXT
1340 * Matches the presence of IPv6 fragment extension header.
1342 * Preceded by any of:
1344 * - RTE_FLOW_ITEM_TYPE_IPV6
1345 * - RTE_FLOW_ITEM_TYPE_IPV6_EXT
1347 struct rte_flow_item_ipv6_frag_ext {
1348 struct rte_ipv6_fragment_ext hdr;
1352 * RTE_FLOW_ITEM_TYPE_ICMP6
1354 * Matches any ICMPv6 header.
1356 struct rte_flow_item_icmp6 {
1357 uint8_t type; /**< ICMPv6 type. */
1358 uint8_t code; /**< ICMPv6 code. */
1359 uint16_t checksum; /**< ICMPv6 checksum. */
1362 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6. */
1364 static const struct rte_flow_item_icmp6 rte_flow_item_icmp6_mask = {
1371 * RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS
1373 * Matches an ICMPv6 neighbor discovery solicitation.
1375 struct rte_flow_item_icmp6_nd_ns {
1376 uint8_t type; /**< ICMPv6 type, normally 135. */
1377 uint8_t code; /**< ICMPv6 code, normally 0. */
1378 rte_be16_t checksum; /**< ICMPv6 checksum. */
1379 rte_be32_t reserved; /**< Reserved, normally 0. */
1380 uint8_t target_addr[16]; /**< Target address. */
1383 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS. */
1386 struct rte_flow_item_icmp6_nd_ns rte_flow_item_icmp6_nd_ns_mask = {
1388 "\xff\xff\xff\xff\xff\xff\xff\xff"
1389 "\xff\xff\xff\xff\xff\xff\xff\xff",
1394 * RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA
1396 * Matches an ICMPv6 neighbor discovery advertisement.
1398 struct rte_flow_item_icmp6_nd_na {
1399 uint8_t type; /**< ICMPv6 type, normally 136. */
1400 uint8_t code; /**< ICMPv6 code, normally 0. */
1401 rte_be16_t checksum; /**< ICMPv6 checksum. */
1403 * Route flag (1b), solicited flag (1b), override flag (1b),
1406 rte_be32_t rso_reserved;
1407 uint8_t target_addr[16]; /**< Target address. */
1410 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA. */
1413 struct rte_flow_item_icmp6_nd_na rte_flow_item_icmp6_nd_na_mask = {
1415 "\xff\xff\xff\xff\xff\xff\xff\xff"
1416 "\xff\xff\xff\xff\xff\xff\xff\xff",
1421 * RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT
1423 * Matches the presence of any ICMPv6 neighbor discovery option.
1425 * Normally preceded by any of:
1427 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA
1428 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS
1429 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT
1431 struct rte_flow_item_icmp6_nd_opt {
1432 uint8_t type; /**< ND option type. */
1433 uint8_t length; /**< ND option length. */
1436 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT. */
1438 static const struct rte_flow_item_icmp6_nd_opt
1439 rte_flow_item_icmp6_nd_opt_mask = {
1445 * RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_SLA_ETH
1447 * Matches an ICMPv6 neighbor discovery source Ethernet link-layer address
1450 * Normally preceded by any of:
1452 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA
1453 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT
1455 struct rte_flow_item_icmp6_nd_opt_sla_eth {
1456 uint8_t type; /**< ND option type, normally 1. */
1457 uint8_t length; /**< ND option length, normally 1. */
1458 struct rte_ether_addr sla; /**< Source Ethernet LLA. */
1461 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_SLA_ETH. */
1463 static const struct rte_flow_item_icmp6_nd_opt_sla_eth
1464 rte_flow_item_icmp6_nd_opt_sla_eth_mask = {
1465 .sla.addr_bytes = "\xff\xff\xff\xff\xff\xff",
1470 * RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_TLA_ETH
1472 * Matches an ICMPv6 neighbor discovery target Ethernet link-layer address
1475 * Normally preceded by any of:
1477 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS
1478 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT
1480 struct rte_flow_item_icmp6_nd_opt_tla_eth {
1481 uint8_t type; /**< ND option type, normally 2. */
1482 uint8_t length; /**< ND option length, normally 1. */
1483 struct rte_ether_addr tla; /**< Target Ethernet LLA. */
1486 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_TLA_ETH. */
1488 static const struct rte_flow_item_icmp6_nd_opt_tla_eth
1489 rte_flow_item_icmp6_nd_opt_tla_eth_mask = {
1490 .tla.addr_bytes = "\xff\xff\xff\xff\xff\xff",
1495 * RTE_FLOW_ITEM_TYPE_META
1497 * Matches a specified metadata value. On egress, metadata can be set
1498 * either by mbuf dynamic metadata field with PKT_TX_DYNF_METADATA flag or
1499 * RTE_FLOW_ACTION_TYPE_SET_META. On ingress, RTE_FLOW_ACTION_TYPE_SET_META
1500 * sets metadata for a packet and the metadata will be reported via mbuf
1501 * metadata dynamic field with PKT_RX_DYNF_METADATA flag. The dynamic mbuf
1502 * field must be registered in advance by rte_flow_dynf_metadata_register().
1504 struct rte_flow_item_meta {
1508 /** Default mask for RTE_FLOW_ITEM_TYPE_META. */
1510 static const struct rte_flow_item_meta rte_flow_item_meta_mask = {
1516 * RTE_FLOW_ITEM_TYPE_GTP_PSC.
1518 * Matches a GTP PDU extension header with type 0x85.
1520 struct rte_flow_item_gtp_psc {
1521 struct rte_gtp_psc_generic_hdr hdr; /**< gtp psc generic hdr. */
1524 /** Default mask for RTE_FLOW_ITEM_TYPE_GTP_PSC. */
1526 static const struct rte_flow_item_gtp_psc
1527 rte_flow_item_gtp_psc_mask = {
1533 * RTE_FLOW_ITEM_TYPE_PPPOE.
1535 * Matches a PPPoE header.
1537 struct rte_flow_item_pppoe {
1539 * Version (4b), type (4b).
1541 uint8_t version_type;
1542 uint8_t code; /**< Message type. */
1543 rte_be16_t session_id; /**< Session identifier. */
1544 rte_be16_t length; /**< Payload length. */
1548 * RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID.
1550 * Matches a PPPoE optional proto_id field.
1552 * It only applies to PPPoE session packets.
1554 * Normally preceded by any of:
1556 * - RTE_FLOW_ITEM_TYPE_PPPOE
1557 * - RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID
1559 struct rte_flow_item_pppoe_proto_id {
1560 rte_be16_t proto_id; /**< PPP protocol identifier. */
1563 /** Default mask for RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID. */
1565 static const struct rte_flow_item_pppoe_proto_id
1566 rte_flow_item_pppoe_proto_id_mask = {
1567 .proto_id = RTE_BE16(0xffff),
1573 * @b EXPERIMENTAL: this structure may change without prior notice
1575 * RTE_FLOW_ITEM_TYPE_TAG
1577 * Matches a specified tag value at the specified index.
1579 struct rte_flow_item_tag {
1584 /** Default mask for RTE_FLOW_ITEM_TYPE_TAG. */
1586 static const struct rte_flow_item_tag rte_flow_item_tag_mask = {
1593 * RTE_FLOW_ITEM_TYPE_L2TPV3OIP.
1595 * Matches a L2TPv3 over IP header.
1597 struct rte_flow_item_l2tpv3oip {
1598 rte_be32_t session_id; /**< Session ID. */
1601 /** Default mask for RTE_FLOW_ITEM_TYPE_L2TPV3OIP. */
1603 static const struct rte_flow_item_l2tpv3oip rte_flow_item_l2tpv3oip_mask = {
1604 .session_id = RTE_BE32(UINT32_MAX),
1611 * @b EXPERIMENTAL: this structure may change without prior notice
1613 * RTE_FLOW_ITEM_TYPE_MARK
1615 * Matches an arbitrary integer value which was set using the ``MARK`` action
1616 * in a previously matched rule.
1618 * This item can only be specified once as a match criteria as the ``MARK``
1619 * action can only be specified once in a flow action.
1621 * This value is arbitrary and application-defined. Maximum allowed value
1622 * depends on the underlying implementation.
1624 * Depending on the underlying implementation the MARK item may be supported on
1625 * the physical device, with virtual groups in the PMD or not at all.
1627 struct rte_flow_item_mark {
1628 uint32_t id; /**< Integer value to match against. */
1631 /** Default mask for RTE_FLOW_ITEM_TYPE_MARK. */
1633 static const struct rte_flow_item_mark rte_flow_item_mark_mask = {
1640 * @b EXPERIMENTAL: this structure may change without prior notice
1642 * RTE_FLOW_ITEM_TYPE_NSH
1644 * Match network service header (NSH), RFC 8300
1647 struct rte_flow_item_nsh {
1650 uint32_t reserved:1;
1653 uint32_t reserved1:4;
1655 uint32_t next_proto:8;
1660 /** Default mask for RTE_FLOW_ITEM_TYPE_NSH. */
1662 static const struct rte_flow_item_nsh rte_flow_item_nsh_mask = {
1672 * @b EXPERIMENTAL: this structure may change without prior notice
1674 * RTE_FLOW_ITEM_TYPE_IGMP
1676 * Match Internet Group Management Protocol (IGMP), RFC 2236
1679 struct rte_flow_item_igmp {
1681 uint32_t max_resp_time:8;
1682 uint32_t checksum:16;
1683 uint32_t group_addr;
1686 /** Default mask for RTE_FLOW_ITEM_TYPE_IGMP. */
1688 static const struct rte_flow_item_igmp rte_flow_item_igmp_mask = {
1689 .group_addr = 0xffffffff,
1695 * @b EXPERIMENTAL: this structure may change without prior notice
1697 * RTE_FLOW_ITEM_TYPE_AH
1699 * Match IP Authentication Header (AH), RFC 4302
1702 struct rte_flow_item_ah {
1703 uint32_t next_hdr:8;
1704 uint32_t payload_len:8;
1705 uint32_t reserved:16;
1710 /** Default mask for RTE_FLOW_ITEM_TYPE_AH. */
1712 static const struct rte_flow_item_ah rte_flow_item_ah_mask = {
1719 * @b EXPERIMENTAL: this structure may change without prior notice
1721 * RTE_FLOW_ITEM_TYPE_PFCP
1725 struct rte_flow_item_pfcp {
1732 /** Default mask for RTE_FLOW_ITEM_TYPE_PFCP. */
1734 static const struct rte_flow_item_pfcp rte_flow_item_pfcp_mask = {
1736 .seid = RTE_BE64(UINT64_C(0xffffffffffffffff)),
1742 * @b EXPERIMENTAL: this structure may change without prior notice
1744 * RTE_FLOW_ITEM_TYPE_ECPRI
1746 * Match eCPRI Header
1748 struct rte_flow_item_ecpri {
1749 struct rte_ecpri_combined_msg_hdr hdr;
1752 /** Default mask for RTE_FLOW_ITEM_TYPE_ECPRI. */
1754 static const struct rte_flow_item_ecpri rte_flow_item_ecpri_mask = {
1764 * RTE_FLOW_ITEM_TYPE_GENEVE_OPT
1766 * Matches a GENEVE Variable Length Option
1768 struct rte_flow_item_geneve_opt {
1769 rte_be16_t option_class;
1770 uint8_t option_type;
1775 /** Default mask for RTE_FLOW_ITEM_TYPE_GENEVE_OPT. */
1777 static const struct rte_flow_item_geneve_opt
1778 rte_flow_item_geneve_opt_mask = {
1779 .option_type = 0xff,
1785 * @b EXPERIMENTAL: this structure may change without prior notice
1787 * RTE_FLOW_ITEM_TYPE_INTEGRITY
1789 * Match on packet integrity check result.
1791 struct rte_flow_item_integrity {
1792 /** Tunnel encapsulation level the item should apply to.
1793 * @see rte_flow_action_rss
1800 /** The packet is valid after passing all HW checks. */
1801 uint64_t packet_ok:1;
1802 /** L2 layer is valid after passing all HW checks. */
1804 /** L3 layer is valid after passing all HW checks. */
1806 /** L4 layer is valid after passing all HW checks. */
1808 /** L2 layer CRC is valid. */
1809 uint64_t l2_crc_ok:1;
1810 /** IPv4 layer checksum is valid. */
1811 uint64_t ipv4_csum_ok:1;
1812 /** L4 layer checksum is valid. */
1813 uint64_t l4_csum_ok:1;
1814 /** L3 length is smaller than frame length. */
1815 uint64_t l3_len_ok:1;
1816 uint64_t reserved:56;
1823 static const struct rte_flow_item_integrity
1824 rte_flow_item_integrity_mask = {
1831 * The packet is valid after conntrack checking.
1833 #define RTE_FLOW_CONNTRACK_PKT_STATE_VALID RTE_BIT32(0)
1835 * The state of the connection is changed.
1837 #define RTE_FLOW_CONNTRACK_PKT_STATE_CHANGED RTE_BIT32(1)
1839 * Error is detected on this packet for this connection and
1840 * an invalid state is set.
1842 #define RTE_FLOW_CONNTRACK_PKT_STATE_INVALID RTE_BIT32(2)
1844 * The HW connection tracking module is disabled.
1845 * It can be due to application command or an invalid state.
1847 #define RTE_FLOW_CONNTRACK_PKT_STATE_DISABLED RTE_BIT32(3)
1849 * The packet contains some bad field(s) and cannot continue
1850 * with the conntrack module checking.
1852 #define RTE_FLOW_CONNTRACK_PKT_STATE_BAD RTE_BIT32(4)
1856 * @b EXPERIMENTAL: this structure may change without prior notice
1858 * RTE_FLOW_ITEM_TYPE_CONNTRACK
1860 * Matches the state of a packet after it passed the connection tracking
1861 * examination. The state is a bitmap of one RTE_FLOW_CONNTRACK_PKT_STATE*
1862 * or a reasonable combination of these bits.
1864 struct rte_flow_item_conntrack {
1868 /** Default mask for RTE_FLOW_ITEM_TYPE_CONNTRACK. */
1870 static const struct rte_flow_item_conntrack rte_flow_item_conntrack_mask = {
1871 .flags = 0xffffffff,
1877 * @b EXPERIMENTAL: this structure may change without prior notice
1879 * Provides an ethdev port ID for use with the following items:
1880 * RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR,
1881 * RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT.
1883 struct rte_flow_item_ethdev {
1884 uint16_t port_id; /**< ethdev port ID */
1887 /** Default mask for items based on struct rte_flow_item_ethdev */
1889 static const struct rte_flow_item_ethdev rte_flow_item_ethdev_mask = {
1895 * Matching pattern item definition.
1897 * A pattern is formed by stacking items starting from the lowest protocol
1898 * layer to match. This stacking restriction does not apply to meta items
1899 * which can be placed anywhere in the stack without affecting the meaning
1900 * of the resulting pattern.
1902 * Patterns are terminated by END items.
1904 * The spec field should be a valid pointer to a structure of the related
1905 * item type. It may remain unspecified (NULL) in many cases to request
1906 * broad (nonspecific) matching. In such cases, last and mask must also be
1909 * Optionally, last can point to a structure of the same type to define an
1910 * inclusive range. This is mostly supported by integer and address fields,
1911 * may cause errors otherwise. Fields that do not support ranges must be set
1912 * to 0 or to the same value as the corresponding fields in spec.
1914 * Only the fields defined to nonzero values in the default masks (see
1915 * rte_flow_item_{name}_mask constants) are considered relevant by
1916 * default. This can be overridden by providing a mask structure of the
1917 * same type with applicable bits set to one. It can also be used to
1918 * partially filter out specific fields (e.g. as an alternate mean to match
1919 * ranges of IP addresses).
1921 * Mask is a simple bit-mask applied before interpreting the contents of
1922 * spec and last, which may yield unexpected results if not used
1923 * carefully. For example, if for an IPv4 address field, spec provides
1924 * 10.1.2.3, last provides 10.3.4.5 and mask provides 255.255.0.0, the
1925 * effective range becomes 10.1.0.0 to 10.3.255.255.
1927 struct rte_flow_item {
1928 enum rte_flow_item_type type; /**< Item type. */
1929 const void *spec; /**< Pointer to item specification structure. */
1930 const void *last; /**< Defines an inclusive range (spec to last). */
1931 const void *mask; /**< Bit-mask applied to spec and last. */
1937 * Each possible action is represented by a type.
1938 * An action can have an associated configuration object.
1939 * Several actions combined in a list can be assigned
1940 * to a flow rule and are performed in order.
1942 * They fall in three categories:
1944 * - Actions that modify the fate of matching traffic, for instance by
1945 * dropping or assigning it a specific destination.
1947 * - Actions that modify matching traffic contents or its properties. This
1948 * includes adding/removing encapsulation, encryption, compression and
1951 * - Actions related to the flow rule itself, such as updating counters or
1952 * making it non-terminating.
1954 * Flow rules being terminating by default, not specifying any action of the
1955 * fate kind results in undefined behavior. This applies to both ingress and
1958 * PASSTHRU, when supported, makes a flow rule non-terminating.
1960 enum rte_flow_action_type {
1962 * End marker for action lists. Prevents further processing of
1963 * actions, thereby ending the list.
1965 * No associated configuration structure.
1967 RTE_FLOW_ACTION_TYPE_END,
1970 * Used as a placeholder for convenience. It is ignored and simply
1971 * discarded by PMDs.
1973 * No associated configuration structure.
1975 RTE_FLOW_ACTION_TYPE_VOID,
1978 * Leaves traffic up for additional processing by subsequent flow
1979 * rules; makes a flow rule non-terminating.
1981 * No associated configuration structure.
1983 RTE_FLOW_ACTION_TYPE_PASSTHRU,
1986 * RTE_FLOW_ACTION_TYPE_JUMP
1988 * Redirects packets to a group on the current device.
1990 * See struct rte_flow_action_jump.
1992 RTE_FLOW_ACTION_TYPE_JUMP,
1995 * Attaches an integer value to packets and sets PKT_RX_FDIR and
1996 * PKT_RX_FDIR_ID mbuf flags.
1998 * See struct rte_flow_action_mark.
2000 * One should negotiate mark delivery from the NIC to the PMD.
2001 * @see rte_eth_rx_metadata_negotiate()
2002 * @see RTE_ETH_RX_METADATA_USER_MARK
2004 RTE_FLOW_ACTION_TYPE_MARK,
2007 * Flags packets. Similar to MARK without a specific value; only
2008 * sets the PKT_RX_FDIR mbuf flag.
2010 * No associated configuration structure.
2012 * One should negotiate flag delivery from the NIC to the PMD.
2013 * @see rte_eth_rx_metadata_negotiate()
2014 * @see RTE_ETH_RX_METADATA_USER_FLAG
2016 RTE_FLOW_ACTION_TYPE_FLAG,
2019 * Assigns packets to a given queue index.
2021 * See struct rte_flow_action_queue.
2023 RTE_FLOW_ACTION_TYPE_QUEUE,
2028 * PASSTHRU overrides this action if both are specified.
2030 * No associated configuration structure.
2032 RTE_FLOW_ACTION_TYPE_DROP,
2035 * Enables counters for this flow rule.
2037 * These counters can be retrieved and reset through rte_flow_query() or
2038 * rte_flow_action_handle_query() if the action provided via handle,
2039 * see struct rte_flow_query_count.
2041 * See struct rte_flow_action_count.
2043 RTE_FLOW_ACTION_TYPE_COUNT,
2046 * Similar to QUEUE, except RSS is additionally performed on packets
2047 * to spread them among several queues according to the provided
2050 * See struct rte_flow_action_rss.
2052 RTE_FLOW_ACTION_TYPE_RSS,
2056 * @see RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR
2057 * @see RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT
2059 * Directs matching traffic to the physical function (PF) of the
2062 * No associated configuration structure.
2064 RTE_FLOW_ACTION_TYPE_PF,
2068 * @see RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR
2069 * @see RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT
2071 * Directs matching traffic to a given virtual function of the
2074 * See struct rte_flow_action_vf.
2076 RTE_FLOW_ACTION_TYPE_VF,
2080 * @see RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR
2081 * @see RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT
2083 * Directs packets to a given physical port index of the underlying
2086 * See struct rte_flow_action_phy_port.
2088 RTE_FLOW_ACTION_TYPE_PHY_PORT,
2092 * @see RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR
2093 * @see RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT
2095 * Directs matching traffic to a given DPDK port ID.
2097 * See struct rte_flow_action_port_id.
2099 RTE_FLOW_ACTION_TYPE_PORT_ID,
2102 * Traffic metering and policing (MTR).
2104 * See struct rte_flow_action_meter.
2105 * See file rte_mtr.h for MTR object configuration.
2107 RTE_FLOW_ACTION_TYPE_METER,
2110 * Redirects packets to security engine of current device for security
2111 * processing as specified by security session.
2113 * See struct rte_flow_action_security.
2115 RTE_FLOW_ACTION_TYPE_SECURITY,
2118 * Implements OFPAT_SET_MPLS_TTL ("MPLS TTL") as defined by the
2119 * OpenFlow Switch Specification.
2121 * See struct rte_flow_action_of_set_mpls_ttl.
2123 RTE_FLOW_ACTION_TYPE_OF_SET_MPLS_TTL,
2126 * Implements OFPAT_DEC_MPLS_TTL ("decrement MPLS TTL") as defined
2127 * by the OpenFlow Switch Specification.
2129 * No associated configuration structure.
2131 RTE_FLOW_ACTION_TYPE_OF_DEC_MPLS_TTL,
2134 * Implements OFPAT_SET_NW_TTL ("IP TTL") as defined by the OpenFlow
2135 * Switch Specification.
2137 * See struct rte_flow_action_of_set_nw_ttl.
2139 RTE_FLOW_ACTION_TYPE_OF_SET_NW_TTL,
2142 * Implements OFPAT_DEC_NW_TTL ("decrement IP TTL") as defined by
2143 * the OpenFlow Switch Specification.
2145 * No associated configuration structure.
2147 RTE_FLOW_ACTION_TYPE_OF_DEC_NW_TTL,
2150 * Implements OFPAT_COPY_TTL_OUT ("copy TTL "outwards" -- from
2151 * next-to-outermost to outermost") as defined by the OpenFlow
2152 * Switch Specification.
2154 * No associated configuration structure.
2156 RTE_FLOW_ACTION_TYPE_OF_COPY_TTL_OUT,
2159 * Implements OFPAT_COPY_TTL_IN ("copy TTL "inwards" -- from
2160 * outermost to next-to-outermost") as defined by the OpenFlow
2161 * Switch Specification.
2163 * No associated configuration structure.
2165 RTE_FLOW_ACTION_TYPE_OF_COPY_TTL_IN,
2168 * Implements OFPAT_POP_VLAN ("pop the outer VLAN tag") as defined
2169 * by the OpenFlow Switch Specification.
2171 * No associated configuration structure.
2173 RTE_FLOW_ACTION_TYPE_OF_POP_VLAN,
2176 * Implements OFPAT_PUSH_VLAN ("push a new VLAN tag") as defined by
2177 * the OpenFlow Switch Specification.
2179 * See struct rte_flow_action_of_push_vlan.
2181 RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN,
2184 * Implements OFPAT_SET_VLAN_VID ("set the 802.1q VLAN id") as
2185 * defined by the OpenFlow Switch Specification.
2187 * See struct rte_flow_action_of_set_vlan_vid.
2189 RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID,
2192 * Implements OFPAT_SET_LAN_PCP ("set the 802.1q priority") as
2193 * defined by the OpenFlow Switch Specification.
2195 * See struct rte_flow_action_of_set_vlan_pcp.
2197 RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP,
2200 * Implements OFPAT_POP_MPLS ("pop the outer MPLS tag") as defined
2201 * by the OpenFlow Switch Specification.
2203 * See struct rte_flow_action_of_pop_mpls.
2205 RTE_FLOW_ACTION_TYPE_OF_POP_MPLS,
2208 * Implements OFPAT_PUSH_MPLS ("push a new MPLS tag") as defined by
2209 * the OpenFlow Switch Specification.
2211 * See struct rte_flow_action_of_push_mpls.
2213 RTE_FLOW_ACTION_TYPE_OF_PUSH_MPLS,
2216 * Encapsulate flow in VXLAN tunnel as defined in
2217 * rte_flow_action_vxlan_encap action structure.
2219 * See struct rte_flow_action_vxlan_encap.
2221 RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP,
2224 * Decapsulate outer most VXLAN tunnel from matched flow.
2226 * If flow pattern does not define a valid VXLAN tunnel (as specified by
2227 * RFC7348) then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION
2230 RTE_FLOW_ACTION_TYPE_VXLAN_DECAP,
2233 * Encapsulate flow in NVGRE tunnel defined in the
2234 * rte_flow_action_nvgre_encap action structure.
2236 * See struct rte_flow_action_nvgre_encap.
2238 RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP,
2241 * Decapsulate outer most NVGRE tunnel from matched flow.
2243 * If flow pattern does not define a valid NVGRE tunnel (as specified by
2244 * RFC7637) then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION
2247 RTE_FLOW_ACTION_TYPE_NVGRE_DECAP,
2250 * Add outer header whose template is provided in its data buffer
2252 * See struct rte_flow_action_raw_encap.
2254 RTE_FLOW_ACTION_TYPE_RAW_ENCAP,
2257 * Remove outer header whose template is provided in its data buffer.
2259 * See struct rte_flow_action_raw_decap
2261 RTE_FLOW_ACTION_TYPE_RAW_DECAP,
2264 * Modify IPv4 source address in the outermost IPv4 header.
2266 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV4,
2267 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2269 * See struct rte_flow_action_set_ipv4.
2271 RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC,
2274 * Modify IPv4 destination address in the outermost IPv4 header.
2276 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV4,
2277 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2279 * See struct rte_flow_action_set_ipv4.
2281 RTE_FLOW_ACTION_TYPE_SET_IPV4_DST,
2284 * Modify IPv6 source address in the outermost IPv6 header.
2286 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV6,
2287 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2289 * See struct rte_flow_action_set_ipv6.
2291 RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC,
2294 * Modify IPv6 destination address in the outermost IPv6 header.
2296 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV6,
2297 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2299 * See struct rte_flow_action_set_ipv6.
2301 RTE_FLOW_ACTION_TYPE_SET_IPV6_DST,
2304 * Modify source port number in the outermost TCP/UDP header.
2306 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_TCP
2307 * or RTE_FLOW_ITEM_TYPE_UDP, then the PMD should return a
2308 * RTE_FLOW_ERROR_TYPE_ACTION error.
2310 * See struct rte_flow_action_set_tp.
2312 RTE_FLOW_ACTION_TYPE_SET_TP_SRC,
2315 * Modify destination port number in the outermost TCP/UDP header.
2317 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_TCP
2318 * or RTE_FLOW_ITEM_TYPE_UDP, then the PMD should return a
2319 * RTE_FLOW_ERROR_TYPE_ACTION error.
2321 * See struct rte_flow_action_set_tp.
2323 RTE_FLOW_ACTION_TYPE_SET_TP_DST,
2326 * Swap the source and destination MAC addresses in the outermost
2329 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_ETH,
2330 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2332 * No associated configuration structure.
2334 RTE_FLOW_ACTION_TYPE_MAC_SWAP,
2337 * Decrease TTL value directly
2339 * No associated configuration structure.
2341 RTE_FLOW_ACTION_TYPE_DEC_TTL,
2346 * See struct rte_flow_action_set_ttl
2348 RTE_FLOW_ACTION_TYPE_SET_TTL,
2351 * Set source MAC address from matched flow.
2353 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_ETH,
2354 * the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2356 * See struct rte_flow_action_set_mac.
2358 RTE_FLOW_ACTION_TYPE_SET_MAC_SRC,
2361 * Set destination MAC address from matched flow.
2363 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_ETH,
2364 * the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2366 * See struct rte_flow_action_set_mac.
2368 RTE_FLOW_ACTION_TYPE_SET_MAC_DST,
2371 * Increase sequence number in the outermost TCP header.
2373 * Action configuration specifies the value to increase
2374 * TCP sequence number as a big-endian 32 bit integer.
2377 * @code rte_be32_t * @endcode
2379 * Using this action on non-matching traffic will result in
2380 * undefined behavior.
2382 RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ,
2385 * Decrease sequence number in the outermost TCP header.
2387 * Action configuration specifies the value to decrease
2388 * TCP sequence number as a big-endian 32 bit integer.
2391 * @code rte_be32_t * @endcode
2393 * Using this action on non-matching traffic will result in
2394 * undefined behavior.
2396 RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ,
2399 * Increase acknowledgment number in the outermost TCP header.
2401 * Action configuration specifies the value to increase
2402 * TCP acknowledgment number as a big-endian 32 bit integer.
2405 * @code rte_be32_t * @endcode
2407 * Using this action on non-matching traffic will result in
2408 * undefined behavior.
2410 RTE_FLOW_ACTION_TYPE_INC_TCP_ACK,
2413 * Decrease acknowledgment number in the outermost TCP header.
2415 * Action configuration specifies the value to decrease
2416 * TCP acknowledgment number as a big-endian 32 bit integer.
2419 * @code rte_be32_t * @endcode
2421 * Using this action on non-matching traffic will result in
2422 * undefined behavior.
2424 RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK,
2429 * Tag is for internal flow usage only and
2430 * is not delivered to the application.
2432 * See struct rte_flow_action_set_tag.
2434 RTE_FLOW_ACTION_TYPE_SET_TAG,
2437 * Set metadata on ingress or egress path.
2439 * See struct rte_flow_action_set_meta.
2441 RTE_FLOW_ACTION_TYPE_SET_META,
2444 * Modify IPv4 DSCP in the outermost IP header.
2446 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV4,
2447 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2449 * See struct rte_flow_action_set_dscp.
2451 RTE_FLOW_ACTION_TYPE_SET_IPV4_DSCP,
2454 * Modify IPv6 DSCP in the outermost IP header.
2456 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV6,
2457 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2459 * See struct rte_flow_action_set_dscp.
2461 RTE_FLOW_ACTION_TYPE_SET_IPV6_DSCP,
2464 * Report as aged flow if timeout passed without any matching on the
2467 * See struct rte_flow_action_age.
2468 * See function rte_flow_get_aged_flows
2469 * see enum RTE_ETH_EVENT_FLOW_AGED
2470 * See struct rte_flow_query_age
2472 RTE_FLOW_ACTION_TYPE_AGE,
2475 * The matching packets will be duplicated with specified ratio and
2476 * applied with own set of actions with a fate action.
2478 * See struct rte_flow_action_sample.
2480 RTE_FLOW_ACTION_TYPE_SAMPLE,
2484 * @see RTE_FLOW_ACTION_TYPE_INDIRECT
2486 * Describe action shared across multiple flow rules.
2488 * Allow multiple rules reference the same action by handle (see
2489 * struct rte_flow_shared_action).
2491 RTE_FLOW_ACTION_TYPE_SHARED,
2494 * Modify a packet header field, tag, mark or metadata.
2496 * Allow the modification of an arbitrary header field via
2497 * set, add and sub operations or copying its content into
2498 * tag, meta or mark for future processing.
2500 * See struct rte_flow_action_modify_field.
2502 RTE_FLOW_ACTION_TYPE_MODIFY_FIELD,
2505 * An action handle is referenced in a rule through an indirect action.
2507 * The same action handle may be used in multiple rules for the same
2508 * or different ethdev ports.
2510 RTE_FLOW_ACTION_TYPE_INDIRECT,
2515 * Enable tracking a TCP connection state.
2517 * @see struct rte_flow_action_conntrack.
2519 RTE_FLOW_ACTION_TYPE_CONNTRACK,
2522 * Color the packet to reflect the meter color result.
2523 * Set the meter color in the mbuf to the selected color.
2525 * See struct rte_flow_action_meter_color.
2527 RTE_FLOW_ACTION_TYPE_METER_COLOR,
2530 * At embedded switch level, sends matching traffic to the given ethdev.
2532 * @see struct rte_flow_action_ethdev
2534 RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR,
2537 * At embedded switch level, send matching traffic to
2538 * the entity represented by the given ethdev.
2540 * @see struct rte_flow_action_ethdev
2542 RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT,
2546 * RTE_FLOW_ACTION_TYPE_MARK
2548 * Attaches an integer value to packets and sets PKT_RX_FDIR and
2549 * PKT_RX_FDIR_ID mbuf flags.
2551 * This value is arbitrary and application-defined. Maximum allowed value
2552 * depends on the underlying implementation. It is returned in the
2553 * hash.fdir.hi mbuf field.
2555 struct rte_flow_action_mark {
2556 uint32_t id; /**< Integer value to return with packets. */
2561 * @b EXPERIMENTAL: this structure may change without prior notice
2563 * RTE_FLOW_ACTION_TYPE_JUMP
2565 * Redirects packets to a group on the current device.
2567 * In a hierarchy of groups, which can be used to represent physical or logical
2568 * flow tables on the device, this action allows the action to be a redirect to
2569 * a group on that device.
2571 struct rte_flow_action_jump {
2576 * RTE_FLOW_ACTION_TYPE_QUEUE
2578 * Assign packets to a given queue index.
2580 struct rte_flow_action_queue {
2581 uint16_t index; /**< Queue index to use. */
2586 * @b EXPERIMENTAL: this structure may change without prior notice
2588 * RTE_FLOW_ACTION_TYPE_AGE
2590 * Report flow as aged-out if timeout passed without any matching
2591 * on the flow. RTE_ETH_EVENT_FLOW_AGED event is triggered when a
2592 * port detects new aged-out flows.
2594 * The flow context and the flow handle will be reported by the
2595 * rte_flow_get_aged_flows API.
2597 struct rte_flow_action_age {
2598 uint32_t timeout:24; /**< Time in seconds. */
2599 uint32_t reserved:8; /**< Reserved, must be zero. */
2601 /**< The user flow context, NULL means the rte_flow pointer. */
2605 * RTE_FLOW_ACTION_TYPE_AGE (query)
2607 * Query structure to retrieve the aging status information of a
2608 * shared AGE action, or a flow rule using the AGE action.
2610 struct rte_flow_query_age {
2611 uint32_t reserved:6; /**< Reserved, must be zero. */
2612 uint32_t aged:1; /**< 1 if aging timeout expired, 0 otherwise. */
2613 uint32_t sec_since_last_hit_valid:1;
2614 /**< sec_since_last_hit value is valid. */
2615 uint32_t sec_since_last_hit:24; /**< Seconds since last traffic hit. */
2620 * @b EXPERIMENTAL: this structure may change without prior notice
2622 * RTE_FLOW_ACTION_TYPE_COUNT
2624 * Adds a counter action to a matched flow.
2626 * If more than one count action is specified in a single flow rule, then each
2627 * action must specify a unique id.
2629 * Counters can be retrieved and reset through ``rte_flow_query()``, see
2630 * ``struct rte_flow_query_count``.
2632 * For ports within the same switch domain then the counter id namespace extends
2633 * to all ports within that switch domain.
2635 struct rte_flow_action_count {
2636 uint32_t id; /**< Counter ID. */
2640 * RTE_FLOW_ACTION_TYPE_COUNT (query)
2642 * Query structure to retrieve and reset flow rule counters.
2644 struct rte_flow_query_count {
2645 uint32_t reset:1; /**< Reset counters after query [in]. */
2646 uint32_t hits_set:1; /**< hits field is set [out]. */
2647 uint32_t bytes_set:1; /**< bytes field is set [out]. */
2648 uint32_t reserved:29; /**< Reserved, must be zero [in, out]. */
2649 uint64_t hits; /**< Number of hits for this rule [out]. */
2650 uint64_t bytes; /**< Number of bytes through this rule [out]. */
2654 * Hash function types.
2656 enum rte_eth_hash_function {
2657 RTE_ETH_HASH_FUNCTION_DEFAULT = 0,
2658 RTE_ETH_HASH_FUNCTION_TOEPLITZ, /**< Toeplitz */
2659 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR, /**< Simple XOR */
2661 * Symmetric Toeplitz: src, dst will be replaced by
2662 * xor(src, dst). For the case with src/dst only,
2663 * src or dst address will xor with zero pair.
2665 RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ,
2666 RTE_ETH_HASH_FUNCTION_MAX,
2670 * RTE_FLOW_ACTION_TYPE_RSS
2672 * Similar to QUEUE, except RSS is additionally performed on packets to
2673 * spread them among several queues according to the provided parameters.
2675 * Unlike global RSS settings used by other DPDK APIs, unsetting the
2676 * @p types field does not disable RSS in a flow rule. Doing so instead
2677 * requests safe unspecified "best-effort" settings from the underlying PMD,
2678 * which depending on the flow rule, may result in anything ranging from
2679 * empty (single queue) to all-inclusive RSS.
2681 * Note: RSS hash result is stored in the hash.rss mbuf field which overlaps
2682 * hash.fdir.lo. Since the MARK action sets the hash.fdir.hi field only,
2683 * both can be requested simultaneously.
2685 struct rte_flow_action_rss {
2686 enum rte_eth_hash_function func; /**< RSS hash function to apply. */
2688 * Packet encapsulation level RSS hash @p types apply to.
2690 * - @p 0 requests the default behavior. Depending on the packet
2691 * type, it can mean outermost, innermost, anything in between or
2694 * It basically stands for the innermost encapsulation level RSS
2695 * can be performed on according to PMD and device capabilities.
2697 * - @p 1 requests RSS to be performed on the outermost packet
2698 * encapsulation level.
2700 * - @p 2 and subsequent values request RSS to be performed on the
2701 * specified inner packet encapsulation level, from outermost to
2702 * innermost (lower to higher values).
2704 * Values other than @p 0 are not necessarily supported.
2706 * Requesting a specific RSS level on unrecognized traffic results
2707 * in undefined behavior. For predictable results, it is recommended
2708 * to make the flow rule pattern match packet headers up to the
2709 * requested encapsulation level so that only matching traffic goes
2713 uint64_t types; /**< Specific RSS hash types (see ETH_RSS_*). */
2714 uint32_t key_len; /**< Hash key length in bytes. */
2715 uint32_t queue_num; /**< Number of entries in @p queue. */
2716 const uint8_t *key; /**< Hash key. */
2717 const uint16_t *queue; /**< Queue indices to use. */
2722 * @see RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR
2723 * @see RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT
2725 * RTE_FLOW_ACTION_TYPE_VF
2727 * Directs matching traffic to a given virtual function of the current
2730 * Packets matched by a VF pattern item can be redirected to their original
2731 * VF ID instead of the specified one. This parameter may not be available
2732 * and is not guaranteed to work properly if the VF part is matched by a
2733 * prior flow rule or if packets are not addressed to a VF in the first
2736 struct rte_flow_action_vf {
2737 uint32_t original:1; /**< Use original VF ID if possible. */
2738 uint32_t reserved:31; /**< Reserved, must be zero. */
2739 uint32_t id; /**< VF ID. */
2744 * @see RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR
2745 * @see RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT
2747 * RTE_FLOW_ACTION_TYPE_PHY_PORT
2749 * Directs packets to a given physical port index of the underlying
2752 * @see RTE_FLOW_ITEM_TYPE_PHY_PORT
2754 struct rte_flow_action_phy_port {
2755 uint32_t original:1; /**< Use original port index if possible. */
2756 uint32_t reserved:31; /**< Reserved, must be zero. */
2757 uint32_t index; /**< Physical port index. */
2762 * @see RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR
2763 * @see RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT
2765 * RTE_FLOW_ACTION_TYPE_PORT_ID
2767 * Directs matching traffic to a given DPDK port ID.
2769 * @see RTE_FLOW_ITEM_TYPE_PORT_ID
2771 struct rte_flow_action_port_id {
2772 uint32_t original:1; /**< Use original DPDK port ID if possible. */
2773 uint32_t reserved:31; /**< Reserved, must be zero. */
2774 uint32_t id; /**< DPDK port ID. */
2778 * RTE_FLOW_ACTION_TYPE_METER
2780 * Traffic metering and policing (MTR).
2782 * Packets matched by items of this type can be either dropped or passed to the
2783 * next item with their color set by the MTR object.
2785 struct rte_flow_action_meter {
2786 uint32_t mtr_id; /**< MTR object ID created with rte_mtr_create(). */
2790 * RTE_FLOW_ACTION_TYPE_SECURITY
2792 * Perform the security action on flows matched by the pattern items
2793 * according to the configuration of the security session.
2795 * This action modifies the payload of matched flows. For INLINE_CRYPTO, the
2796 * security protocol headers and IV are fully provided by the application as
2797 * specified in the flow pattern. The payload of matching packets is
2798 * encrypted on egress, and decrypted and authenticated on ingress.
2799 * For INLINE_PROTOCOL, the security protocol is fully offloaded to HW,
2800 * providing full encapsulation and decapsulation of packets in security
2801 * protocols. The flow pattern specifies both the outer security header fields
2802 * and the inner packet fields. The security session specified in the action
2803 * must match the pattern parameters.
2805 * The security session specified in the action must be created on the same
2806 * port as the flow action that is being specified.
2808 * The ingress/egress flow attribute should match that specified in the
2809 * security session if the security session supports the definition of the
2812 * Multiple flows can be configured to use the same security session.
2814 * The NULL value is allowed for security session. If security session is NULL,
2815 * then SPI field in ESP flow item and IP addresses in flow items 'IPv4' and
2816 * 'IPv6' will be allowed to be a range. The rule thus created can enable
2817 * security processing on multiple flows.
2819 struct rte_flow_action_security {
2820 void *security_session; /**< Pointer to security session structure. */
2824 * RTE_FLOW_ACTION_TYPE_OF_SET_MPLS_TTL
2826 * Implements OFPAT_SET_MPLS_TTL ("MPLS TTL") as defined by the OpenFlow
2827 * Switch Specification.
2829 struct rte_flow_action_of_set_mpls_ttl {
2830 uint8_t mpls_ttl; /**< MPLS TTL. */
2834 * RTE_FLOW_ACTION_TYPE_OF_SET_NW_TTL
2836 * Implements OFPAT_SET_NW_TTL ("IP TTL") as defined by the OpenFlow Switch
2839 struct rte_flow_action_of_set_nw_ttl {
2840 uint8_t nw_ttl; /**< IP TTL. */
2844 * RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN
2846 * Implements OFPAT_PUSH_VLAN ("push a new VLAN tag") as defined by the
2847 * OpenFlow Switch Specification.
2849 struct rte_flow_action_of_push_vlan {
2850 rte_be16_t ethertype; /**< EtherType. */
2854 * RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID
2856 * Implements OFPAT_SET_VLAN_VID ("set the 802.1q VLAN id") as defined by
2857 * the OpenFlow Switch Specification.
2859 struct rte_flow_action_of_set_vlan_vid {
2860 rte_be16_t vlan_vid; /**< VLAN id. */
2864 * RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP
2866 * Implements OFPAT_SET_LAN_PCP ("set the 802.1q priority") as defined by
2867 * the OpenFlow Switch Specification.
2869 struct rte_flow_action_of_set_vlan_pcp {
2870 uint8_t vlan_pcp; /**< VLAN priority. */
2874 * RTE_FLOW_ACTION_TYPE_OF_POP_MPLS
2876 * Implements OFPAT_POP_MPLS ("pop the outer MPLS tag") as defined by the
2877 * OpenFlow Switch Specification.
2879 struct rte_flow_action_of_pop_mpls {
2880 rte_be16_t ethertype; /**< EtherType. */
2884 * RTE_FLOW_ACTION_TYPE_OF_PUSH_MPLS
2886 * Implements OFPAT_PUSH_MPLS ("push a new MPLS tag") as defined by the
2887 * OpenFlow Switch Specification.
2889 struct rte_flow_action_of_push_mpls {
2890 rte_be16_t ethertype; /**< EtherType. */
2895 * @b EXPERIMENTAL: this structure may change without prior notice
2897 * RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP
2899 * VXLAN tunnel end-point encapsulation data definition
2901 * The tunnel definition is provided through the flow item pattern, the
2902 * provided pattern must conform to RFC7348 for the tunnel specified. The flow
2903 * definition must be provided in order from the RTE_FLOW_ITEM_TYPE_ETH
2904 * definition up the end item which is specified by RTE_FLOW_ITEM_TYPE_END.
2906 * The mask field allows user to specify which fields in the flow item
2907 * definitions can be ignored and which have valid data and can be used
2910 * Note: the last field is not used in the definition of a tunnel and can be
2913 * Valid flow definition for RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP include:
2915 * - ETH / IPV4 / UDP / VXLAN / END
2916 * - ETH / IPV6 / UDP / VXLAN / END
2917 * - ETH / VLAN / IPV4 / UDP / VXLAN / END
2920 struct rte_flow_action_vxlan_encap {
2922 * Encapsulating vxlan tunnel definition
2923 * (terminated by the END pattern item).
2925 struct rte_flow_item *definition;
2930 * @b EXPERIMENTAL: this structure may change without prior notice
2932 * RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP
2934 * NVGRE tunnel end-point encapsulation data definition
2936 * The tunnel definition is provided through the flow item pattern the
2937 * provided pattern must conform with RFC7637. The flow definition must be
2938 * provided in order from the RTE_FLOW_ITEM_TYPE_ETH definition up the end item
2939 * which is specified by RTE_FLOW_ITEM_TYPE_END.
2941 * The mask field allows user to specify which fields in the flow item
2942 * definitions can be ignored and which have valid data and can be used
2945 * Note: the last field is not used in the definition of a tunnel and can be
2948 * Valid flow definition for RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP include:
2950 * - ETH / IPV4 / NVGRE / END
2951 * - ETH / VLAN / IPV6 / NVGRE / END
2954 struct rte_flow_action_nvgre_encap {
2956 * Encapsulating vxlan tunnel definition
2957 * (terminated by the END pattern item).
2959 struct rte_flow_item *definition;
2964 * @b EXPERIMENTAL: this structure may change without prior notice
2966 * RTE_FLOW_ACTION_TYPE_RAW_ENCAP
2968 * Raw tunnel end-point encapsulation data definition.
2970 * The data holds the headers definitions to be applied on the packet.
2971 * The data must start with ETH header up to the tunnel item header itself.
2972 * When used right after RAW_DECAP (for decapsulating L3 tunnel type for
2973 * example MPLSoGRE) the data will just hold layer 2 header.
2975 * The preserve parameter holds which bits in the packet the PMD is not allowed
2976 * to change, this parameter can also be NULL and then the PMD is allowed
2977 * to update any field.
2979 * size holds the number of bytes in @p data and @p preserve.
2981 struct rte_flow_action_raw_encap {
2982 uint8_t *data; /**< Encapsulation data. */
2983 uint8_t *preserve; /**< Bit-mask of @p data to preserve on output. */
2984 size_t size; /**< Size of @p data and @p preserve. */
2989 * @b EXPERIMENTAL: this structure may change without prior notice
2991 * RTE_FLOW_ACTION_TYPE_RAW_DECAP
2993 * Raw tunnel end-point decapsulation data definition.
2995 * The data holds the headers definitions to be removed from the packet.
2996 * The data must start with ETH header up to the tunnel item header itself.
2997 * When used right before RAW_DECAP (for encapsulating L3 tunnel type for
2998 * example MPLSoGRE) the data will just hold layer 2 header.
3000 * size holds the number of bytes in @p data.
3002 struct rte_flow_action_raw_decap {
3003 uint8_t *data; /**< Encapsulation data. */
3004 size_t size; /**< Size of @p data and @p preserve. */
3009 * @b EXPERIMENTAL: this structure may change without prior notice
3011 * RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC
3012 * RTE_FLOW_ACTION_TYPE_SET_IPV4_DST
3014 * Allows modification of IPv4 source (RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC)
3015 * and destination address (RTE_FLOW_ACTION_TYPE_SET_IPV4_DST) in the
3016 * specified outermost IPv4 header.
3018 struct rte_flow_action_set_ipv4 {
3019 rte_be32_t ipv4_addr;
3024 * @b EXPERIMENTAL: this structure may change without prior notice
3026 * RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC
3027 * RTE_FLOW_ACTION_TYPE_SET_IPV6_DST
3029 * Allows modification of IPv6 source (RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC)
3030 * and destination address (RTE_FLOW_ACTION_TYPE_SET_IPV6_DST) in the
3031 * specified outermost IPv6 header.
3033 struct rte_flow_action_set_ipv6 {
3034 uint8_t ipv6_addr[16];
3039 * @b EXPERIMENTAL: this structure may change without prior notice
3041 * RTE_FLOW_ACTION_TYPE_SET_TP_SRC
3042 * RTE_FLOW_ACTION_TYPE_SET_TP_DST
3044 * Allows modification of source (RTE_FLOW_ACTION_TYPE_SET_TP_SRC)
3045 * and destination (RTE_FLOW_ACTION_TYPE_SET_TP_DST) port numbers
3046 * in the specified outermost TCP/UDP header.
3048 struct rte_flow_action_set_tp {
3053 * RTE_FLOW_ACTION_TYPE_SET_TTL
3055 * Set the TTL value directly for IPv4 or IPv6
3057 struct rte_flow_action_set_ttl {
3062 * RTE_FLOW_ACTION_TYPE_SET_MAC
3064 * Set MAC address from the matched flow
3066 struct rte_flow_action_set_mac {
3067 uint8_t mac_addr[RTE_ETHER_ADDR_LEN];
3072 * @b EXPERIMENTAL: this structure may change without prior notice
3074 * RTE_FLOW_ACTION_TYPE_SET_TAG
3076 * Set a tag which is a transient data used during flow matching. This is not
3077 * delivered to application. Multiple tags are supported by specifying index.
3079 struct rte_flow_action_set_tag {
3087 * @b EXPERIMENTAL: this structure may change without prior notice
3089 * RTE_FLOW_ACTION_TYPE_SET_META
3091 * Set metadata. Metadata set by mbuf metadata dynamic field with
3092 * PKT_TX_DYNF_DATA flag on egress will be overridden by this action. On
3093 * ingress, the metadata will be carried by mbuf metadata dynamic field
3094 * with PKT_RX_DYNF_METADATA flag if set. The dynamic mbuf field must be
3095 * registered in advance by rte_flow_dynf_metadata_register().
3097 * Altering partial bits is supported with mask. For bits which have never
3098 * been set, unpredictable value will be seen depending on driver
3099 * implementation. For loopback/hairpin packet, metadata set on Rx/Tx may
3100 * or may not be propagated to the other path depending on HW capability.
3102 * RTE_FLOW_ITEM_TYPE_META matches metadata.
3104 struct rte_flow_action_set_meta {
3110 * RTE_FLOW_ACTION_TYPE_SET_IPV4_DSCP
3111 * RTE_FLOW_ACTION_TYPE_SET_IPV6_DSCP
3113 * Set the DSCP value for IPv4/IPv6 header.
3114 * DSCP in low 6 bits, rest ignored.
3116 struct rte_flow_action_set_dscp {
3122 * @b EXPERIMENTAL: this structure may change without prior notice
3124 * RTE_FLOW_ACTION_TYPE_INDIRECT
3126 * Opaque type returned after successfully creating an indirect action object.
3127 * The definition of the object handle is different per driver or
3128 * per direct action type.
3130 * This handle can be used to manage and query the related direct action:
3131 * - referenced in single flow rule or across multiple flow rules
3132 * over multiple ports
3133 * - update action object configuration
3134 * - query action object data
3135 * - destroy action object
3137 struct rte_flow_action_handle;
3140 * The state of a TCP connection.
3142 enum rte_flow_conntrack_state {
3143 /** SYN-ACK packet was seen. */
3144 RTE_FLOW_CONNTRACK_STATE_SYN_RECV,
3145 /** 3-way handshake was done. */
3146 RTE_FLOW_CONNTRACK_STATE_ESTABLISHED,
3147 /** First FIN packet was received to close the connection. */
3148 RTE_FLOW_CONNTRACK_STATE_FIN_WAIT,
3149 /** First FIN was ACKed. */
3150 RTE_FLOW_CONNTRACK_STATE_CLOSE_WAIT,
3151 /** Second FIN was received, waiting for the last ACK. */
3152 RTE_FLOW_CONNTRACK_STATE_LAST_ACK,
3153 /** Second FIN was ACKed, connection was closed. */
3154 RTE_FLOW_CONNTRACK_STATE_TIME_WAIT,
3158 * The last passed TCP packet flags of a connection.
3160 enum rte_flow_conntrack_tcp_last_index {
3161 RTE_FLOW_CONNTRACK_FLAG_NONE = 0, /**< No Flag. */
3162 RTE_FLOW_CONNTRACK_FLAG_SYN = RTE_BIT32(0), /**< With SYN flag. */
3163 RTE_FLOW_CONNTRACK_FLAG_SYNACK = RTE_BIT32(1), /**< With SYNACK flag. */
3164 RTE_FLOW_CONNTRACK_FLAG_FIN = RTE_BIT32(2), /**< With FIN flag. */
3165 RTE_FLOW_CONNTRACK_FLAG_ACK = RTE_BIT32(3), /**< With ACK flag. */
3166 RTE_FLOW_CONNTRACK_FLAG_RST = RTE_BIT32(4), /**< With RST flag. */
3171 * @b EXPERIMENTAL: this structure may change without prior notice
3173 * Configuration parameters for each direction of a TCP connection.
3174 * All fields should be in host byte order.
3175 * If needed, driver should convert all fields to network byte order
3176 * if HW needs them in that way.
3178 struct rte_flow_tcp_dir_param {
3179 /** TCP window scaling factor, 0xF to disable. */
3181 /** The FIN was sent by this direction. */
3182 uint32_t close_initiated:1;
3183 /** An ACK packet has been received by this side. */
3184 uint32_t last_ack_seen:1;
3186 * If set, it indicates that there is unacknowledged data for the
3187 * packets sent from this direction.
3189 uint32_t data_unacked:1;
3191 * Maximal value of sequence + payload length in sent
3192 * packets (next ACK from the opposite direction).
3196 * Maximal value of (ACK + window size) in received packet + length
3197 * over sent packet (maximal sequence could be sent).
3200 /** Maximal value of actual window size in sent packets. */
3202 /** Maximal value of ACK in sent packets. */
3208 * @b EXPERIMENTAL: this structure may change without prior notice
3210 * RTE_FLOW_ACTION_TYPE_CONNTRACK
3212 * Configuration and initial state for the connection tracking module.
3213 * This structure could be used for both setting and query.
3214 * All fields should be in host byte order.
3216 struct rte_flow_action_conntrack {
3217 /** The peer port number, can be the same port. */
3220 * Direction of this connection when creating a flow rule, the
3221 * value only affects the creation of subsequent flow rules.
3223 uint32_t is_original_dir:1;
3225 * Enable / disable the conntrack HW module. When disabled, the
3226 * result will always be RTE_FLOW_CONNTRACK_FLAG_DISABLED.
3227 * In this state the HW will act as passthrough.
3228 * It only affects this conntrack object in the HW without any effect
3229 * to the other objects.
3232 /** At least one ack was seen after the connection was established. */
3233 uint32_t live_connection:1;
3234 /** Enable selective ACK on this connection. */
3235 uint32_t selective_ack:1;
3236 /** A challenge ack has passed. */
3237 uint32_t challenge_ack_passed:1;
3239 * 1: The last packet is seen from the original direction.
3240 * 0: The last packet is seen from the reply direction.
3242 uint32_t last_direction:1;
3243 /** No TCP check will be done except the state change. */
3244 uint32_t liberal_mode:1;
3245 /**<The current state of this connection. */
3246 enum rte_flow_conntrack_state state;
3247 /** Scaling factor for maximal allowed ACK window. */
3248 uint8_t max_ack_window;
3249 /** Maximal allowed number of retransmission times. */
3250 uint8_t retransmission_limit;
3251 /** TCP parameters of the original direction. */
3252 struct rte_flow_tcp_dir_param original_dir;
3253 /** TCP parameters of the reply direction. */
3254 struct rte_flow_tcp_dir_param reply_dir;
3255 /** The window value of the last packet passed this conntrack. */
3256 uint16_t last_window;
3257 enum rte_flow_conntrack_tcp_last_index last_index;
3258 /** The sequence of the last packet passed this conntrack. */
3260 /** The acknowledgment of the last packet passed this conntrack. */
3263 * The total value ACK + payload length of the last packet
3264 * passed this conntrack.
3270 * RTE_FLOW_ACTION_TYPE_CONNTRACK
3272 * Wrapper structure for the context update interface.
3273 * Ports cannot support updating, and the only valid solution is to
3274 * destroy the old context and create a new one instead.
3276 struct rte_flow_modify_conntrack {
3277 /** New connection tracking parameters to be updated. */
3278 struct rte_flow_action_conntrack new_ct;
3279 /** The direction field will be updated. */
3280 uint32_t direction:1;
3281 /** All the other fields except direction will be updated. */
3283 /** Reserved bits for the future usage. */
3284 uint32_t reserved:30;
3289 * @b EXPERIMENTAL: this structure may change without prior notice
3291 * RTE_FLOW_ACTION_TYPE_METER_COLOR
3293 * The meter color should be set in the packet meta-data
3294 * (i.e. struct rte_mbuf::sched::color).
3296 struct rte_flow_action_meter_color {
3297 enum rte_color color; /**< Packet color. */
3302 * @b EXPERIMENTAL: this structure may change without prior notice
3304 * Provides an ethdev port ID for use with the following actions:
3305 * RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR,
3306 * RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT.
3308 struct rte_flow_action_ethdev {
3309 uint16_t port_id; /**< ethdev port ID */
3313 * Field IDs for MODIFY_FIELD action.
3315 enum rte_flow_field_id {
3316 RTE_FLOW_FIELD_START = 0, /**< Start of a packet. */
3317 RTE_FLOW_FIELD_MAC_DST, /**< Destination MAC Address. */
3318 RTE_FLOW_FIELD_MAC_SRC, /**< Source MAC Address. */
3319 RTE_FLOW_FIELD_VLAN_TYPE, /**< 802.1Q Tag Identifier. */
3320 RTE_FLOW_FIELD_VLAN_ID, /**< 802.1Q VLAN Identifier. */
3321 RTE_FLOW_FIELD_MAC_TYPE, /**< EtherType. */
3322 RTE_FLOW_FIELD_IPV4_DSCP, /**< IPv4 DSCP. */
3323 RTE_FLOW_FIELD_IPV4_TTL, /**< IPv4 Time To Live. */
3324 RTE_FLOW_FIELD_IPV4_SRC, /**< IPv4 Source Address. */
3325 RTE_FLOW_FIELD_IPV4_DST, /**< IPv4 Destination Address. */
3326 RTE_FLOW_FIELD_IPV6_DSCP, /**< IPv6 DSCP. */
3327 RTE_FLOW_FIELD_IPV6_HOPLIMIT, /**< IPv6 Hop Limit. */
3328 RTE_FLOW_FIELD_IPV6_SRC, /**< IPv6 Source Address. */
3329 RTE_FLOW_FIELD_IPV6_DST, /**< IPv6 Destination Address. */
3330 RTE_FLOW_FIELD_TCP_PORT_SRC, /**< TCP Source Port Number. */
3331 RTE_FLOW_FIELD_TCP_PORT_DST, /**< TCP Destination Port Number. */
3332 RTE_FLOW_FIELD_TCP_SEQ_NUM, /**< TCP Sequence Number. */
3333 RTE_FLOW_FIELD_TCP_ACK_NUM, /**< TCP Acknowledgment Number. */
3334 RTE_FLOW_FIELD_TCP_FLAGS, /**< TCP Flags. */
3335 RTE_FLOW_FIELD_UDP_PORT_SRC, /**< UDP Source Port Number. */
3336 RTE_FLOW_FIELD_UDP_PORT_DST, /**< UDP Destination Port Number. */
3337 RTE_FLOW_FIELD_VXLAN_VNI, /**< VXLAN Network Identifier. */
3338 RTE_FLOW_FIELD_GENEVE_VNI, /**< GENEVE Network Identifier. */
3339 RTE_FLOW_FIELD_GTP_TEID, /**< GTP Tunnel Endpoint Identifier. */
3340 RTE_FLOW_FIELD_TAG, /**< Tag value. */
3341 RTE_FLOW_FIELD_MARK, /**< Mark value. */
3342 RTE_FLOW_FIELD_META, /**< Metadata value. */
3343 RTE_FLOW_FIELD_POINTER, /**< Memory pointer. */
3344 RTE_FLOW_FIELD_VALUE, /**< Immediate value. */
3348 * Field description for MODIFY_FIELD action.
3350 struct rte_flow_action_modify_data {
3351 enum rte_flow_field_id field; /**< Field or memory type ID. */
3355 /**< Encapsulation level or tag index. */
3357 /**< Number of bits to skip from a field. */
3361 * Immediate value for RTE_FLOW_FIELD_VALUE or
3362 * memory address for RTE_FLOW_FIELD_POINTER.
3369 * Operation types for MODIFY_FIELD action.
3371 enum rte_flow_modify_op {
3372 RTE_FLOW_MODIFY_SET = 0, /**< Set a new value. */
3373 RTE_FLOW_MODIFY_ADD, /**< Add a value to a field. */
3374 RTE_FLOW_MODIFY_SUB, /**< Subtract a value from a field. */
3379 * @b EXPERIMENTAL: this structure may change without prior notice
3381 * RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
3383 * Modify a destination header field according to the specified
3384 * operation. Another packet field can be used as a source as well
3385 * as tag, mark, metadata, immediate value or a pointer to it.
3387 struct rte_flow_action_modify_field {
3388 enum rte_flow_modify_op operation; /**< Operation to perform. */
3389 struct rte_flow_action_modify_data dst; /**< Destination field. */
3390 struct rte_flow_action_modify_data src; /**< Source field. */
3391 uint32_t width; /**< Number of bits to use from a source field. */
3394 /* Mbuf dynamic field offset for metadata. */
3395 extern int32_t rte_flow_dynf_metadata_offs;
3397 /* Mbuf dynamic field flag mask for metadata. */
3398 extern uint64_t rte_flow_dynf_metadata_mask;
3400 /* Mbuf dynamic field pointer for metadata. */
3401 #define RTE_FLOW_DYNF_METADATA(m) \
3402 RTE_MBUF_DYNFIELD((m), rte_flow_dynf_metadata_offs, uint32_t *)
3404 /* Mbuf dynamic flags for metadata. */
3405 #define PKT_RX_DYNF_METADATA (rte_flow_dynf_metadata_mask)
3406 #define PKT_TX_DYNF_METADATA (rte_flow_dynf_metadata_mask)
3409 static inline uint32_t
3410 rte_flow_dynf_metadata_get(struct rte_mbuf *m)
3412 return *RTE_FLOW_DYNF_METADATA(m);
3417 rte_flow_dynf_metadata_set(struct rte_mbuf *m, uint32_t v)
3419 *RTE_FLOW_DYNF_METADATA(m) = v;
3423 * Definition of a single action.
3425 * A list of actions is terminated by a END action.
3427 * For simple actions without a configuration object, conf remains NULL.
3429 struct rte_flow_action {
3430 enum rte_flow_action_type type; /**< Action type. */
3431 const void *conf; /**< Pointer to action configuration object. */
3435 * Opaque type returned after successfully creating a flow.
3437 * This handle can be used to manage and query the related flow (e.g. to
3438 * destroy it or retrieve counters).
3444 * @b EXPERIMENTAL: this structure may change without prior notice
3446 * RTE_FLOW_ACTION_TYPE_SAMPLE
3448 * Adds a sample action to a matched flow.
3450 * The matching packets will be duplicated with specified ratio and applied
3451 * with own set of actions with a fate action, the sampled packet could be
3452 * redirected to queue or port. All the packets continue processing on the
3453 * default flow path.
3455 * When the sample ratio is set to 1 then the packets will be 100% mirrored.
3456 * Additional action list be supported to add for sampled or mirrored packets.
3458 struct rte_flow_action_sample {
3459 uint32_t ratio; /**< packets sampled equals to '1/ratio'. */
3460 const struct rte_flow_action *actions;
3461 /**< sub-action list specific for the sampling hit cases. */
3465 * Verbose error types.
3467 * Most of them provide the type of the object referenced by struct
3468 * rte_flow_error.cause.
3470 enum rte_flow_error_type {
3471 RTE_FLOW_ERROR_TYPE_NONE, /**< No error. */
3472 RTE_FLOW_ERROR_TYPE_UNSPECIFIED, /**< Cause unspecified. */
3473 RTE_FLOW_ERROR_TYPE_HANDLE, /**< Flow rule (handle). */
3474 RTE_FLOW_ERROR_TYPE_ATTR_GROUP, /**< Group field. */
3475 RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY, /**< Priority field. */
3476 RTE_FLOW_ERROR_TYPE_ATTR_INGRESS, /**< Ingress field. */
3477 RTE_FLOW_ERROR_TYPE_ATTR_EGRESS, /**< Egress field. */
3478 RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, /**< Transfer field. */
3479 RTE_FLOW_ERROR_TYPE_ATTR, /**< Attributes structure. */
3480 RTE_FLOW_ERROR_TYPE_ITEM_NUM, /**< Pattern length. */
3481 RTE_FLOW_ERROR_TYPE_ITEM_SPEC, /**< Item specification. */
3482 RTE_FLOW_ERROR_TYPE_ITEM_LAST, /**< Item specification range. */
3483 RTE_FLOW_ERROR_TYPE_ITEM_MASK, /**< Item specification mask. */
3484 RTE_FLOW_ERROR_TYPE_ITEM, /**< Specific pattern item. */
3485 RTE_FLOW_ERROR_TYPE_ACTION_NUM, /**< Number of actions. */
3486 RTE_FLOW_ERROR_TYPE_ACTION_CONF, /**< Action configuration. */
3487 RTE_FLOW_ERROR_TYPE_ACTION, /**< Specific action. */
3491 * Verbose error structure definition.
3493 * This object is normally allocated by applications and set by PMDs, the
3494 * message points to a constant string which does not need to be freed by
3495 * the application, however its pointer can be considered valid only as long
3496 * as its associated DPDK port remains configured. Closing the underlying
3497 * device or unloading the PMD invalidates it.
3499 * Both cause and message may be NULL regardless of the error type.
3501 struct rte_flow_error {
3502 enum rte_flow_error_type type; /**< Cause field and error types. */
3503 const void *cause; /**< Object responsible for the error. */
3504 const char *message; /**< Human-readable error message. */
3508 * Complete flow rule description.
3510 * This object type is used when converting a flow rule description.
3512 * @see RTE_FLOW_CONV_OP_RULE
3513 * @see rte_flow_conv()
3516 struct rte_flow_conv_rule {
3518 const struct rte_flow_attr *attr_ro; /**< RO attributes. */
3519 struct rte_flow_attr *attr; /**< Attributes. */
3522 const struct rte_flow_item *pattern_ro; /**< RO pattern. */
3523 struct rte_flow_item *pattern; /**< Pattern items. */
3526 const struct rte_flow_action *actions_ro; /**< RO actions. */
3527 struct rte_flow_action *actions; /**< List of actions. */
3532 * Conversion operations for flow API objects.
3534 * @see rte_flow_conv()
3536 enum rte_flow_conv_op {
3538 * No operation to perform.
3540 * rte_flow_conv() simply returns 0.
3542 RTE_FLOW_CONV_OP_NONE,
3545 * Convert attributes structure.
3547 * This is a basic copy of an attributes structure.
3550 * @code const struct rte_flow_attr * @endcode
3552 * @code struct rte_flow_attr * @endcode
3554 RTE_FLOW_CONV_OP_ATTR,
3557 * Convert a single item.
3559 * Duplicates @p spec, @p last and @p mask but not outside objects.
3562 * @code const struct rte_flow_item * @endcode
3564 * @code struct rte_flow_item * @endcode
3566 RTE_FLOW_CONV_OP_ITEM,
3569 * Convert a single action.
3571 * Duplicates @p conf but not outside objects.
3574 * @code const struct rte_flow_action * @endcode
3576 * @code struct rte_flow_action * @endcode
3578 RTE_FLOW_CONV_OP_ACTION,
3581 * Convert an entire pattern.
3583 * Duplicates all pattern items at once with the same constraints as
3584 * RTE_FLOW_CONV_OP_ITEM.
3587 * @code const struct rte_flow_item * @endcode
3589 * @code struct rte_flow_item * @endcode
3591 RTE_FLOW_CONV_OP_PATTERN,
3594 * Convert a list of actions.
3596 * Duplicates the entire list of actions at once with the same
3597 * constraints as RTE_FLOW_CONV_OP_ACTION.
3600 * @code const struct rte_flow_action * @endcode
3602 * @code struct rte_flow_action * @endcode
3604 RTE_FLOW_CONV_OP_ACTIONS,
3607 * Convert a complete flow rule description.
3609 * Comprises attributes, pattern and actions together at once with
3610 * the usual constraints.
3613 * @code const struct rte_flow_conv_rule * @endcode
3615 * @code struct rte_flow_conv_rule * @endcode
3617 RTE_FLOW_CONV_OP_RULE,
3620 * Convert item type to its name string.
3622 * Writes a NUL-terminated string to @p dst. Like snprintf(), the
3623 * returned value excludes the terminator which is always written
3627 * @code (const void *)enum rte_flow_item_type @endcode
3629 * @code char * @endcode
3631 RTE_FLOW_CONV_OP_ITEM_NAME,
3634 * Convert action type to its name string.
3636 * Writes a NUL-terminated string to @p dst. Like snprintf(), the
3637 * returned value excludes the terminator which is always written
3641 * @code (const void *)enum rte_flow_action_type @endcode
3643 * @code char * @endcode
3645 RTE_FLOW_CONV_OP_ACTION_NAME,
3648 * Convert item type to pointer to item name.
3650 * Retrieves item name pointer from its type. The string itself is
3651 * not copied; instead, a unique pointer to an internal static
3652 * constant storage is written to @p dst.
3655 * @code (const void *)enum rte_flow_item_type @endcode
3657 * @code const char ** @endcode
3659 RTE_FLOW_CONV_OP_ITEM_NAME_PTR,
3662 * Convert action type to pointer to action name.
3664 * Retrieves action name pointer from its type. The string itself is
3665 * not copied; instead, a unique pointer to an internal static
3666 * constant storage is written to @p dst.
3669 * @code (const void *)enum rte_flow_action_type @endcode
3671 * @code const char ** @endcode
3673 RTE_FLOW_CONV_OP_ACTION_NAME_PTR,
3678 * @b EXPERIMENTAL: this API may change without prior notice.
3680 * Dump hardware internal representation information of
3683 * @param[in] port_id
3684 * The port identifier of the Ethernet device.
3686 * The pointer of flow rule to dump. Dump all rules if NULL.
3688 * A pointer to a file for output.
3690 * Perform verbose error reporting if not NULL. PMDs initialize this
3691 * structure in case of error only.
3693 * 0 on success, a nagative value otherwise.
3697 rte_flow_dev_dump(uint16_t port_id, struct rte_flow *flow,
3698 FILE *file, struct rte_flow_error *error);
3701 * Check if mbuf dynamic field for metadata is registered.
3704 * True if registered, false otherwise.
3708 rte_flow_dynf_metadata_avail(void)
3710 return !!rte_flow_dynf_metadata_mask;
3714 * Register mbuf dynamic field and flag for metadata.
3716 * This function must be called prior to use SET_META action in order to
3717 * register the dynamic mbuf field. Otherwise, the data cannot be delivered to
3721 * 0 on success, a negative errno value otherwise and rte_errno is set.
3725 rte_flow_dynf_metadata_register(void);
3728 * Check whether a flow rule can be created on a given port.
3730 * The flow rule is validated for correctness and whether it could be accepted
3731 * by the device given sufficient resources. The rule is checked against the
3732 * current device mode and queue configuration. The flow rule may also
3733 * optionally be validated against existing flow rules and device resources.
3734 * This function has no effect on the target device.
3736 * The returned value is guaranteed to remain valid only as long as no
3737 * successful calls to rte_flow_create() or rte_flow_destroy() are made in
3738 * the meantime and no device parameter affecting flow rules in any way are
3739 * modified, due to possible collisions or resource limitations (although in
3740 * such cases EINVAL should not be returned).
3743 * Port identifier of Ethernet device.
3745 * Flow rule attributes.
3746 * @param[in] pattern
3747 * Pattern specification (list terminated by the END pattern item).
3748 * @param[in] actions
3749 * Associated actions (list terminated by the END action).
3751 * Perform verbose error reporting if not NULL. PMDs initialize this
3752 * structure in case of error only.
3755 * 0 if flow rule is valid and can be created. A negative errno value
3756 * otherwise (rte_errno is also set), the following errors are defined:
3758 * -ENOSYS: underlying device does not support this functionality.
3760 * -EIO: underlying device is removed.
3762 * -EINVAL: unknown or invalid rule specification.
3764 * -ENOTSUP: valid but unsupported rule specification (e.g. partial
3765 * bit-masks are unsupported).
3767 * -EEXIST: collision with an existing rule. Only returned if device
3768 * supports flow rule collision checking and there was a flow rule
3769 * collision. Not receiving this return code is no guarantee that creating
3770 * the rule will not fail due to a collision.
3772 * -ENOMEM: not enough memory to execute the function, or if the device
3773 * supports resource validation, resource limitation on the device.
3775 * -EBUSY: action cannot be performed due to busy device resources, may
3776 * succeed if the affected queues or even the entire port are in a stopped
3777 * state (see rte_eth_dev_rx_queue_stop() and rte_eth_dev_stop()).
3780 rte_flow_validate(uint16_t port_id,
3781 const struct rte_flow_attr *attr,
3782 const struct rte_flow_item pattern[],
3783 const struct rte_flow_action actions[],
3784 struct rte_flow_error *error);
3787 * Create a flow rule on a given port.
3790 * Port identifier of Ethernet device.
3792 * Flow rule attributes.
3793 * @param[in] pattern
3794 * Pattern specification (list terminated by the END pattern item).
3795 * @param[in] actions
3796 * Associated actions (list terminated by the END action).
3798 * Perform verbose error reporting if not NULL. PMDs initialize this
3799 * structure in case of error only.
3802 * A valid handle in case of success, NULL otherwise and rte_errno is set
3803 * to the positive version of one of the error codes defined for
3804 * rte_flow_validate().
3807 rte_flow_create(uint16_t port_id,
3808 const struct rte_flow_attr *attr,
3809 const struct rte_flow_item pattern[],
3810 const struct rte_flow_action actions[],
3811 struct rte_flow_error *error);
3814 * Destroy a flow rule on a given port.
3816 * Failure to destroy a flow rule handle may occur when other flow rules
3817 * depend on it, and destroying it would result in an inconsistent state.
3819 * This function is only guaranteed to succeed if handles are destroyed in
3820 * reverse order of their creation.
3823 * Port identifier of Ethernet device.
3825 * Flow rule handle to destroy.
3827 * Perform verbose error reporting if not NULL. PMDs initialize this
3828 * structure in case of error only.
3831 * 0 on success, a negative errno value otherwise and rte_errno is set.
3834 rte_flow_destroy(uint16_t port_id,
3835 struct rte_flow *flow,
3836 struct rte_flow_error *error);
3839 * Destroy all flow rules associated with a port.
3841 * In the unlikely event of failure, handles are still considered destroyed
3842 * and no longer valid but the port must be assumed to be in an inconsistent
3846 * Port identifier of Ethernet device.
3848 * Perform verbose error reporting if not NULL. PMDs initialize this
3849 * structure in case of error only.
3852 * 0 on success, a negative errno value otherwise and rte_errno is set.
3855 rte_flow_flush(uint16_t port_id,
3856 struct rte_flow_error *error);
3859 * Query an existing flow rule.
3861 * This function allows retrieving flow-specific data such as counters.
3862 * Data is gathered by special actions which must be present in the flow
3865 * \see RTE_FLOW_ACTION_TYPE_COUNT
3868 * Port identifier of Ethernet device.
3870 * Flow rule handle to query.
3872 * Action definition as defined in original flow rule.
3873 * @param[in, out] data
3874 * Pointer to storage for the associated query data type.
3876 * Perform verbose error reporting if not NULL. PMDs initialize this
3877 * structure in case of error only.
3880 * 0 on success, a negative errno value otherwise and rte_errno is set.
3883 rte_flow_query(uint16_t port_id,
3884 struct rte_flow *flow,
3885 const struct rte_flow_action *action,
3887 struct rte_flow_error *error);
3890 * Restrict ingress traffic to the defined flow rules.
3892 * Isolated mode guarantees that all ingress traffic comes from defined flow
3893 * rules only (current and future).
3895 * Besides making ingress more deterministic, it allows PMDs to safely reuse
3896 * resources otherwise assigned to handle the remaining traffic, such as
3897 * global RSS configuration settings, VLAN filters, MAC address entries,
3898 * legacy filter API rules and so on in order to expand the set of possible
3901 * Calling this function as soon as possible after device initialization,
3902 * ideally before the first call to rte_eth_dev_configure(), is recommended
3903 * to avoid possible failures due to conflicting settings.
3905 * Once effective, leaving isolated mode may not be possible depending on
3906 * PMD implementation.
3908 * Additionally, the following functionality has no effect on the underlying
3909 * port and may return errors such as ENOTSUP ("not supported"):
3911 * - Toggling promiscuous mode.
3912 * - Toggling allmulticast mode.
3913 * - Configuring MAC addresses.
3914 * - Configuring multicast addresses.
3915 * - Configuring VLAN filters.
3916 * - Configuring Rx filters through the legacy API (e.g. FDIR).
3917 * - Configuring global RSS settings.
3920 * Port identifier of Ethernet device.
3922 * Nonzero to enter isolated mode, attempt to leave it otherwise.
3924 * Perform verbose error reporting if not NULL. PMDs initialize this
3925 * structure in case of error only.
3928 * 0 on success, a negative errno value otherwise and rte_errno is set.
3931 rte_flow_isolate(uint16_t port_id, int set, struct rte_flow_error *error);
3934 * Initialize flow error structure.
3937 * Pointer to flow error structure (may be NULL).
3939 * Related error code (rte_errno).
3941 * Cause field and error types.
3943 * Object responsible for the error.
3945 * Human-readable error message.
3948 * Negative error code (errno value) and rte_errno is set.
3951 rte_flow_error_set(struct rte_flow_error *error,
3953 enum rte_flow_error_type type,
3955 const char *message);
3959 * @see rte_flow_copy()
3961 struct rte_flow_desc {
3962 size_t size; /**< Allocated space including data[]. */
3963 struct rte_flow_attr attr; /**< Attributes. */
3964 struct rte_flow_item *items; /**< Items. */
3965 struct rte_flow_action *actions; /**< Actions. */
3966 uint8_t data[]; /**< Storage for items/actions. */
3971 * Copy an rte_flow rule description.
3973 * This interface is kept for compatibility with older applications but is
3974 * implemented as a wrapper to rte_flow_conv(). It is deprecated due to its
3975 * lack of flexibility and reliance on a type unusable with C++ programs
3976 * (struct rte_flow_desc).
3979 * Flow rule description.
3981 * Total size of allocated data for the flow description.
3983 * Flow rule attributes.
3985 * Pattern specification (list terminated by the END pattern item).
3986 * @param[in] actions
3987 * Associated actions (list terminated by the END action).
3990 * If len is greater or equal to the size of the flow, the total size of the
3991 * flow description and its data.
3992 * If len is lower than the size of the flow, the number of bytes that would
3993 * have been written to desc had it been sufficient. Nothing is written.
3997 rte_flow_copy(struct rte_flow_desc *fd, size_t len,
3998 const struct rte_flow_attr *attr,
3999 const struct rte_flow_item *items,
4000 const struct rte_flow_action *actions);
4003 * Flow object conversion helper.
4005 * This function performs conversion of various flow API objects to a
4006 * pre-allocated destination buffer. See enum rte_flow_conv_op for possible
4007 * operations and details about each of them.
4009 * Since destination buffer must be large enough, it works in a manner
4010 * reminiscent of snprintf():
4012 * - If @p size is 0, @p dst may be a NULL pointer, otherwise @p dst must be
4014 * - If positive, the returned value represents the number of bytes needed
4015 * to store the conversion of @p src to @p dst according to @p op
4016 * regardless of the @p size parameter.
4017 * - Since no more than @p size bytes can be written to @p dst, output is
4018 * truncated and may be inconsistent when the returned value is larger
4020 * - In case of conversion error, a negative error code is returned and
4021 * @p dst contents are unspecified.
4024 * Operation to perform, related to the object type of @p dst.
4026 * Destination buffer address. Must be suitably aligned by the caller.
4028 * Destination buffer size in bytes.
4030 * Source object to copy. Depending on @p op, its type may differ from
4033 * Perform verbose error reporting if not NULL. Initialized in case of
4037 * The number of bytes required to convert @p src to @p dst on success, a
4038 * negative errno value otherwise and rte_errno is set.
4040 * @see rte_flow_conv_op
4044 rte_flow_conv(enum rte_flow_conv_op op,
4048 struct rte_flow_error *error);
4051 * Get aged-out flows of a given port.
4053 * RTE_ETH_EVENT_FLOW_AGED event will be triggered when at least one new aged
4054 * out flow was detected after the last call to rte_flow_get_aged_flows.
4055 * This function can be called to get the aged flows usynchronously from the
4056 * event callback or synchronously regardless the event.
4057 * This is not safe to call rte_flow_get_aged_flows function with other flow
4058 * functions from multiple threads simultaneously.
4061 * Port identifier of Ethernet device.
4062 * @param[in, out] contexts
4063 * The address of an array of pointers to the aged-out flows contexts.
4064 * @param[in] nb_contexts
4065 * The length of context array pointers.
4067 * Perform verbose error reporting if not NULL. Initialized in case of
4071 * if nb_contexts is 0, return the amount of all aged contexts.
4072 * if nb_contexts is not 0 , return the amount of aged flows reported
4073 * in the context array, otherwise negative errno value.
4075 * @see rte_flow_action_age
4076 * @see RTE_ETH_EVENT_FLOW_AGED
4080 rte_flow_get_aged_flows(uint16_t port_id, void **contexts,
4081 uint32_t nb_contexts, struct rte_flow_error *error);
4084 * Specify indirect action object configuration
4086 struct rte_flow_indir_action_conf {
4088 * Flow direction for the indirect action configuration.
4090 * Action should be valid at least for one flow direction,
4091 * otherwise it is invalid for both ingress and egress rules.
4094 /**< Action valid for rules applied to ingress traffic. */
4096 /**< Action valid for rules applied to egress traffic. */
4098 * When set to 1, indicates that the action is valid for
4099 * transfer traffic; otherwise, for non-transfer traffic.
4101 uint32_t transfer:1;
4106 * @b EXPERIMENTAL: this API may change without prior notice.
4108 * Create an indirect action object that can be used in flow rules
4110 * The created object handle has single state and configuration
4111 * across all the flow rules using it.
4113 * @param[in] port_id
4114 * The port identifier of the Ethernet device.
4116 * Action configuration for the indirect action object creation.
4118 * Specific configuration of the indirect action object.
4120 * Perform verbose error reporting if not NULL. PMDs initialize this
4121 * structure in case of error only.
4123 * A valid handle in case of success, NULL otherwise and rte_errno is set
4124 * to one of the error codes defined:
4125 * - (ENODEV) if *port_id* invalid.
4126 * - (ENOSYS) if underlying device does not support this functionality.
4127 * - (EIO) if underlying device is removed.
4128 * - (EINVAL) if *action* invalid.
4129 * - (ENOTSUP) if *action* valid but unsupported.
4132 struct rte_flow_action_handle *
4133 rte_flow_action_handle_create(uint16_t port_id,
4134 const struct rte_flow_indir_action_conf *conf,
4135 const struct rte_flow_action *action,
4136 struct rte_flow_error *error);
4140 * @b EXPERIMENTAL: this API may change without prior notice.
4142 * Destroy indirect action by handle.
4144 * @param[in] port_id
4145 * The port identifier of the Ethernet device.
4147 * Handle for the indirect action object to be destroyed.
4149 * Perform verbose error reporting if not NULL. PMDs initialize this
4150 * structure in case of error only.
4153 * - (-ENODEV) if *port_id* invalid.
4154 * - (-ENOSYS) if underlying device does not support this functionality.
4155 * - (-EIO) if underlying device is removed.
4156 * - (-ENOENT) if action pointed by *action* handle was not found.
4157 * - (-EBUSY) if action pointed by *action* handle still used by some rules
4158 * rte_errno is also set.
4162 rte_flow_action_handle_destroy(uint16_t port_id,
4163 struct rte_flow_action_handle *handle,
4164 struct rte_flow_error *error);
4168 * @b EXPERIMENTAL: this API may change without prior notice.
4170 * Update in-place the action configuration and / or state pointed
4171 * by action *handle* with the configuration provided as *update* argument.
4172 * The update of the action configuration effects all flow rules reusing
4173 * the action via *handle*.
4174 * The update general pointer provides the ability of partial updating.
4176 * @param[in] port_id
4177 * The port identifier of the Ethernet device.
4179 * Handle for the indirect action object to be updated.
4181 * Update profile specification used to modify the action pointed by handle.
4182 * *update* could be with the same type of the immediate action corresponding
4183 * to the *handle* argument when creating, or a wrapper structure includes
4184 * action configuration to be updated and bit fields to indicate the member
4185 * of fields inside the action to update.
4187 * Perform verbose error reporting if not NULL. PMDs initialize this
4188 * structure in case of error only.
4191 * - (-ENODEV) if *port_id* invalid.
4192 * - (-ENOSYS) if underlying device does not support this functionality.
4193 * - (-EIO) if underlying device is removed.
4194 * - (-EINVAL) if *update* invalid.
4195 * - (-ENOTSUP) if *update* valid but unsupported.
4196 * - (-ENOENT) if indirect action object pointed by *handle* was not found.
4197 * rte_errno is also set.
4201 rte_flow_action_handle_update(uint16_t port_id,
4202 struct rte_flow_action_handle *handle,
4204 struct rte_flow_error *error);
4208 * @b EXPERIMENTAL: this API may change without prior notice.
4210 * Query the direct action by corresponding indirect action object handle.
4212 * Retrieve action-specific data such as counters.
4213 * Data is gathered by special action which may be present/referenced in
4214 * more than one flow rule definition.
4216 * @see RTE_FLOW_ACTION_TYPE_COUNT
4219 * Port identifier of Ethernet device.
4221 * Handle for the action object to query.
4222 * @param[in, out] data
4223 * Pointer to storage for the associated query data type.
4225 * Perform verbose error reporting if not NULL. PMDs initialize this
4226 * structure in case of error only.
4229 * 0 on success, a negative errno value otherwise and rte_errno is set.
4233 rte_flow_action_handle_query(uint16_t port_id,
4234 const struct rte_flow_action_handle *handle,
4235 void *data, struct rte_flow_error *error);
4237 /* Tunnel has a type and the key information. */
4238 struct rte_flow_tunnel {
4240 * Tunnel type, for example RTE_FLOW_ITEM_TYPE_VXLAN,
4241 * RTE_FLOW_ITEM_TYPE_NVGRE etc.
4243 enum rte_flow_item_type type;
4244 uint64_t tun_id; /**< Tunnel identification. */
4249 rte_be32_t src_addr; /**< IPv4 source address. */
4250 rte_be32_t dst_addr; /**< IPv4 destination address. */
4253 uint8_t src_addr[16]; /**< IPv6 source address. */
4254 uint8_t dst_addr[16]; /**< IPv6 destination address. */
4257 rte_be16_t tp_src; /**< Tunnel port source. */
4258 rte_be16_t tp_dst; /**< Tunnel port destination. */
4259 uint16_t tun_flags; /**< Tunnel flags. */
4261 bool is_ipv6; /**< True for valid IPv6 fields. Otherwise IPv4. */
4264 * the following members are required to restore packet
4267 uint8_t tos; /**< TOS for IPv4, TC for IPv6. */
4268 uint8_t ttl; /**< TTL for IPv4, HL for IPv6. */
4269 uint32_t label; /**< Flow Label for IPv6. */
4273 * Indicate that the packet has a tunnel.
4275 #define RTE_FLOW_RESTORE_INFO_TUNNEL (1ULL << 0)
4278 * Indicate that the packet has a non decapsulated tunnel header.
4280 #define RTE_FLOW_RESTORE_INFO_ENCAPSULATED (1ULL << 1)
4283 * Indicate that the packet has a group_id.
4285 #define RTE_FLOW_RESTORE_INFO_GROUP_ID (1ULL << 2)
4288 * Restore information structure to communicate the current packet processing
4289 * state when some of the processing pipeline is done in hardware and should
4290 * continue in software.
4292 struct rte_flow_restore_info {
4294 * Bitwise flags (RTE_FLOW_RESTORE_INFO_*) to indicate validation of
4295 * other fields in struct rte_flow_restore_info.
4298 uint32_t group_id; /**< Group ID where packed missed */
4299 struct rte_flow_tunnel tunnel; /**< Tunnel information. */
4303 * Allocate an array of actions to be used in rte_flow_create, to implement
4304 * tunnel-decap-set for the given tunnel.
4306 * actions vxlan_decap / tunnel-decap-set(tunnel properties) /
4307 * jump group 0 / end
4310 * Port identifier of Ethernet device.
4312 * Tunnel properties.
4313 * @param[out] actions
4314 * Array of actions to be allocated by the PMD. This array should be
4315 * concatenated with the actions array provided to rte_flow_create.
4316 * @param[out] num_of_actions
4317 * Number of actions allocated.
4319 * Perform verbose error reporting if not NULL. PMDs initialize this
4320 * structure in case of error only.
4323 * 0 on success, a negative errno value otherwise and rte_errno is set.
4327 rte_flow_tunnel_decap_set(uint16_t port_id,
4328 struct rte_flow_tunnel *tunnel,
4329 struct rte_flow_action **actions,
4330 uint32_t *num_of_actions,
4331 struct rte_flow_error *error);
4334 * Allocate an array of items to be used in rte_flow_create, to implement
4335 * tunnel-match for the given tunnel.
4337 * pattern tunnel-match(tunnel properties) / outer-header-matches /
4338 * inner-header-matches / end
4341 * Port identifier of Ethernet device.
4343 * Tunnel properties.
4345 * Array of items to be allocated by the PMD. This array should be
4346 * concatenated with the items array provided to rte_flow_create.
4347 * @param[out] num_of_items
4348 * Number of items allocated.
4350 * Perform verbose error reporting if not NULL. PMDs initialize this
4351 * structure in case of error only.
4354 * 0 on success, a negative errno value otherwise and rte_errno is set.
4358 rte_flow_tunnel_match(uint16_t port_id,
4359 struct rte_flow_tunnel *tunnel,
4360 struct rte_flow_item **items,
4361 uint32_t *num_of_items,
4362 struct rte_flow_error *error);
4365 * Populate the current packet processing state, if exists, for the given mbuf.
4367 * One should negotiate tunnel metadata delivery from the NIC to the HW.
4368 * @see rte_eth_rx_metadata_negotiate()
4369 * @see RTE_ETH_RX_METADATA_TUNNEL_ID
4372 * Port identifier of Ethernet device.
4376 * Restore information. Upon success contains the HW state.
4378 * Perform verbose error reporting if not NULL. PMDs initialize this
4379 * structure in case of error only.
4382 * 0 on success, a negative errno value otherwise and rte_errno is set.
4386 rte_flow_get_restore_info(uint16_t port_id,
4388 struct rte_flow_restore_info *info,
4389 struct rte_flow_error *error);
4392 * Release the action array as allocated by rte_flow_tunnel_decap_set.
4395 * Port identifier of Ethernet device.
4396 * @param[in] actions
4397 * Array of actions to be released.
4398 * @param[in] num_of_actions
4399 * Number of elements in actions array.
4401 * Perform verbose error reporting if not NULL. PMDs initialize this
4402 * structure in case of error only.
4405 * 0 on success, a negative errno value otherwise and rte_errno is set.
4409 rte_flow_tunnel_action_decap_release(uint16_t port_id,
4410 struct rte_flow_action *actions,
4411 uint32_t num_of_actions,
4412 struct rte_flow_error *error);
4415 * Release the item array as allocated by rte_flow_tunnel_match.
4418 * Port identifier of Ethernet device.
4420 * Array of items to be released.
4421 * @param[in] num_of_items
4422 * Number of elements in item array.
4424 * Perform verbose error reporting if not NULL. PMDs initialize this
4425 * structure in case of error only.
4428 * 0 on success, a negative errno value otherwise and rte_errno is set.
4432 rte_flow_tunnel_item_release(uint16_t port_id,
4433 struct rte_flow_item *items,
4434 uint32_t num_of_items,
4435 struct rte_flow_error *error);
4439 * @b EXPERIMENTAL: this API may change without prior notice.
4441 * Get a proxy port to manage "transfer" flows.
4443 * Managing "transfer" flows requires that the user communicate them
4444 * via a port which has the privilege to control the embedded switch.
4445 * For some vendors, all ports in a given switching domain have
4446 * this privilege. For other vendors, it's only one port.
4448 * This API indicates such a privileged port (a "proxy")
4449 * for a given port in the same switching domain.
4452 * If the PMD serving @p port_id doesn't have the corresponding method
4453 * implemented, the API will return @p port_id via @p proxy_port_id.
4456 * Indicates the port to get a "proxy" for
4457 * @param[out] proxy_port_id
4458 * Indicates the "proxy" port
4460 * If not NULL, allows the PMD to provide verbose report in case of error
4463 * 0 on success, a negative error code otherwise
4467 rte_flow_pick_transfer_proxy(uint16_t port_id, uint16_t *proxy_port_id,
4468 struct rte_flow_error *error);
4473 #endif /* RTE_FLOW_H_ */