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,
640 * Matches a configured set of fields at runtime calculated offsets
641 * over the generic network header with variable length and
644 * @see struct rte_flow_item_flex.
646 RTE_FLOW_ITEM_TYPE_FLEX,
651 * RTE_FLOW_ITEM_TYPE_HIGIG2
652 * Matches higig2 header
655 struct rte_flow_item_higig2_hdr {
656 struct rte_higig2_hdr hdr;
659 /** Default mask for RTE_FLOW_ITEM_TYPE_HIGIG2. */
661 static const struct rte_flow_item_higig2_hdr rte_flow_item_higig2_hdr_mask = {
664 .classification = 0xffff,
672 * RTE_FLOW_ITEM_TYPE_ANY
674 * Matches any protocol in place of the current layer, a single ANY may also
675 * stand for several protocol layers.
677 * This is usually specified as the first pattern item when looking for a
678 * protocol anywhere in a packet.
680 * A zeroed mask stands for any number of layers.
682 struct rte_flow_item_any {
683 uint32_t num; /**< Number of layers covered. */
686 /** Default mask for RTE_FLOW_ITEM_TYPE_ANY. */
688 static const struct rte_flow_item_any rte_flow_item_any_mask = {
695 * @see RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR
696 * @see RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT
698 * RTE_FLOW_ITEM_TYPE_VF
700 * Matches traffic originating from (ingress) or going to (egress) a given
701 * virtual function of the current device.
703 * If supported, should work even if the virtual function is not managed by
704 * the application and thus not associated with a DPDK port ID.
706 * Note this pattern item does not match VF representors traffic which, as
707 * separate entities, should be addressed through their own DPDK port IDs.
709 * - Can be specified multiple times to match traffic addressed to several
711 * - Can be combined with a PF item to match both PF and VF traffic.
713 * A zeroed mask can be used to match any VF ID.
715 struct rte_flow_item_vf {
716 uint32_t id; /**< VF ID. */
719 /** Default mask for RTE_FLOW_ITEM_TYPE_VF. */
721 static const struct rte_flow_item_vf rte_flow_item_vf_mask = {
728 * @see RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR
729 * @see RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT
731 * RTE_FLOW_ITEM_TYPE_PHY_PORT
733 * Matches traffic originating from (ingress) or going to (egress) a
734 * physical port of the underlying device.
736 * The first PHY_PORT item overrides the physical port normally associated
737 * with the specified DPDK input port (port_id). This item can be provided
738 * several times to match additional physical ports.
740 * Note that physical ports are not necessarily tied to DPDK input ports
741 * (port_id) when those are not under DPDK control. Possible values are
742 * specific to each device, they are not necessarily indexed from zero and
743 * may not be contiguous.
745 * As a device property, the list of allowed values as well as the value
746 * associated with a port_id should be retrieved by other means.
748 * A zeroed mask can be used to match any port index.
750 struct rte_flow_item_phy_port {
751 uint32_t index; /**< Physical port index. */
754 /** Default mask for RTE_FLOW_ITEM_TYPE_PHY_PORT. */
756 static const struct rte_flow_item_phy_port rte_flow_item_phy_port_mask = {
763 * @see RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR
764 * @see RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT
766 * RTE_FLOW_ITEM_TYPE_PORT_ID
768 * Matches traffic originating from (ingress) or going to (egress) a given
771 * Normally only supported if the port ID in question is known by the
772 * underlying PMD and related to the device the flow rule is created
775 * This must not be confused with @p PHY_PORT which refers to the physical
776 * port of a device, whereas @p PORT_ID refers to a struct rte_eth_dev
777 * object on the application side (also known as "port representor"
778 * depending on the kind of underlying device).
780 struct rte_flow_item_port_id {
781 uint32_t id; /**< DPDK port ID. */
784 /** Default mask for RTE_FLOW_ITEM_TYPE_PORT_ID. */
786 static const struct rte_flow_item_port_id rte_flow_item_port_id_mask = {
792 * RTE_FLOW_ITEM_TYPE_RAW
794 * Matches a byte string of a given length at a given offset.
796 * Offset is either absolute (using the start of the packet) or relative to
797 * the end of the previous matched item in the stack, in which case negative
798 * values are allowed.
800 * If search is enabled, offset is used as the starting point. The search
801 * area can be delimited by setting limit to a nonzero value, which is the
802 * maximum number of bytes after offset where the pattern may start.
804 * Matching a zero-length pattern is allowed, doing so resets the relative
805 * offset for subsequent items.
807 * This type does not support ranges (struct rte_flow_item.last).
809 struct rte_flow_item_raw {
810 uint32_t relative:1; /**< Look for pattern after the previous item. */
811 uint32_t search:1; /**< Search pattern from offset (see also limit). */
812 uint32_t reserved:30; /**< Reserved, must be set to zero. */
813 int32_t offset; /**< Absolute or relative offset for pattern. */
814 uint16_t limit; /**< Search area limit for start of pattern. */
815 uint16_t length; /**< Pattern length. */
816 const uint8_t *pattern; /**< Byte string to look for. */
819 /** Default mask for RTE_FLOW_ITEM_TYPE_RAW. */
821 static const struct rte_flow_item_raw rte_flow_item_raw_mask = {
824 .reserved = 0x3fffffff,
825 .offset = 0xffffffff,
833 * RTE_FLOW_ITEM_TYPE_ETH
835 * Matches an Ethernet header.
837 * Inside @p hdr field, the sub-field @p ether_type stands either for EtherType
838 * or TPID, depending on whether the item is followed by a VLAN item or not. If
839 * two VLAN items follow, the sub-field refers to the outer one, which, in turn,
840 * contains the inner TPID in the similar header field. The innermost VLAN item
841 * contains a layer-3 EtherType. All of that follows the order seen on the wire.
843 * If the field in question contains a TPID value, only tagged packets with the
844 * specified TPID will match the pattern. Alternatively, it's possible to match
845 * any type of tagged packets by means of the field @p has_vlan rather than use
846 * the EtherType/TPID field. Also, it's possible to leave the two fields unused.
847 * If this is the case, both tagged and untagged packets will match the pattern.
850 struct rte_flow_item_eth {
854 * These fields are retained for compatibility.
855 * Please switch to the new header field below.
857 struct rte_ether_addr dst; /**< Destination MAC. */
858 struct rte_ether_addr src; /**< Source MAC. */
859 rte_be16_t type; /**< EtherType or TPID. */
861 struct rte_ether_hdr hdr;
863 uint32_t has_vlan:1; /**< Packet header contains at least one VLAN. */
864 uint32_t reserved:31; /**< Reserved, must be zero. */
867 /** Default mask for RTE_FLOW_ITEM_TYPE_ETH. */
869 static const struct rte_flow_item_eth rte_flow_item_eth_mask = {
870 .hdr.dst_addr.addr_bytes = "\xff\xff\xff\xff\xff\xff",
871 .hdr.src_addr.addr_bytes = "\xff\xff\xff\xff\xff\xff",
872 .hdr.ether_type = RTE_BE16(0x0000),
877 * RTE_FLOW_ITEM_TYPE_VLAN
879 * Matches an 802.1Q/ad VLAN tag.
881 * The corresponding standard outer EtherType (TPID) values are
882 * RTE_ETHER_TYPE_VLAN or RTE_ETHER_TYPE_QINQ. It can be overridden by
883 * the preceding pattern item.
884 * If a @p VLAN item is present in the pattern, then only tagged packets will
886 * The field @p has_more_vlan can be used to match any type of tagged packets,
887 * instead of using the @p eth_proto field of @p hdr.
888 * If the @p eth_proto of @p hdr and @p has_more_vlan fields are not specified,
889 * then any tagged packets will match the pattern.
892 struct rte_flow_item_vlan {
896 * These fields are retained for compatibility.
897 * Please switch to the new header field below.
899 rte_be16_t tci; /**< Tag control information. */
900 rte_be16_t inner_type; /**< Inner EtherType or TPID. */
902 struct rte_vlan_hdr hdr;
904 /** Packet header contains at least one more VLAN, after this VLAN. */
905 uint32_t has_more_vlan:1;
906 uint32_t reserved:31; /**< Reserved, must be zero. */
909 /** Default mask for RTE_FLOW_ITEM_TYPE_VLAN. */
911 static const struct rte_flow_item_vlan rte_flow_item_vlan_mask = {
912 .hdr.vlan_tci = RTE_BE16(0x0fff),
913 .hdr.eth_proto = RTE_BE16(0x0000),
918 * RTE_FLOW_ITEM_TYPE_IPV4
920 * Matches an IPv4 header.
922 * Note: IPv4 options are handled by dedicated pattern items.
924 struct rte_flow_item_ipv4 {
925 struct rte_ipv4_hdr hdr; /**< IPv4 header definition. */
928 /** Default mask for RTE_FLOW_ITEM_TYPE_IPV4. */
930 static const struct rte_flow_item_ipv4 rte_flow_item_ipv4_mask = {
932 .src_addr = RTE_BE32(0xffffffff),
933 .dst_addr = RTE_BE32(0xffffffff),
939 * RTE_FLOW_ITEM_TYPE_IPV6.
941 * Matches an IPv6 header.
943 * Dedicated flags indicate if header contains specific extension headers.
945 struct rte_flow_item_ipv6 {
946 struct rte_ipv6_hdr hdr; /**< IPv6 header definition. */
947 /** Header contains Hop-by-Hop Options extension header. */
948 uint32_t has_hop_ext:1;
949 /** Header contains Routing extension header. */
950 uint32_t has_route_ext:1;
951 /** Header contains Fragment extension header. */
952 uint32_t has_frag_ext:1;
953 /** Header contains Authentication extension header. */
954 uint32_t has_auth_ext:1;
955 /** Header contains Encapsulation Security Payload extension header. */
956 uint32_t has_esp_ext:1;
957 /** Header contains Destination Options extension header. */
958 uint32_t has_dest_ext:1;
959 /** Header contains Mobility extension header. */
960 uint32_t has_mobil_ext:1;
961 /** Header contains Host Identity Protocol extension header. */
962 uint32_t has_hip_ext:1;
963 /** Header contains Shim6 Protocol extension header. */
964 uint32_t has_shim6_ext:1;
965 /** Reserved for future extension headers, must be zero. */
966 uint32_t reserved:23;
969 /** Default mask for RTE_FLOW_ITEM_TYPE_IPV6. */
971 static const struct rte_flow_item_ipv6 rte_flow_item_ipv6_mask = {
974 "\xff\xff\xff\xff\xff\xff\xff\xff"
975 "\xff\xff\xff\xff\xff\xff\xff\xff",
977 "\xff\xff\xff\xff\xff\xff\xff\xff"
978 "\xff\xff\xff\xff\xff\xff\xff\xff",
984 * RTE_FLOW_ITEM_TYPE_ICMP.
986 * Matches an ICMP header.
988 struct rte_flow_item_icmp {
989 struct rte_icmp_hdr hdr; /**< ICMP header definition. */
992 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP. */
994 static const struct rte_flow_item_icmp rte_flow_item_icmp_mask = {
1003 * RTE_FLOW_ITEM_TYPE_UDP.
1005 * Matches a UDP header.
1007 struct rte_flow_item_udp {
1008 struct rte_udp_hdr hdr; /**< UDP header definition. */
1011 /** Default mask for RTE_FLOW_ITEM_TYPE_UDP. */
1013 static const struct rte_flow_item_udp rte_flow_item_udp_mask = {
1015 .src_port = RTE_BE16(0xffff),
1016 .dst_port = RTE_BE16(0xffff),
1022 * RTE_FLOW_ITEM_TYPE_TCP.
1024 * Matches a TCP header.
1026 struct rte_flow_item_tcp {
1027 struct rte_tcp_hdr hdr; /**< TCP header definition. */
1030 /** Default mask for RTE_FLOW_ITEM_TYPE_TCP. */
1032 static const struct rte_flow_item_tcp rte_flow_item_tcp_mask = {
1034 .src_port = RTE_BE16(0xffff),
1035 .dst_port = RTE_BE16(0xffff),
1041 * RTE_FLOW_ITEM_TYPE_SCTP.
1043 * Matches a SCTP header.
1045 struct rte_flow_item_sctp {
1046 struct rte_sctp_hdr hdr; /**< SCTP header definition. */
1049 /** Default mask for RTE_FLOW_ITEM_TYPE_SCTP. */
1051 static const struct rte_flow_item_sctp rte_flow_item_sctp_mask = {
1053 .src_port = RTE_BE16(0xffff),
1054 .dst_port = RTE_BE16(0xffff),
1060 * RTE_FLOW_ITEM_TYPE_VXLAN.
1062 * Matches a VXLAN header (RFC 7348).
1065 struct rte_flow_item_vxlan {
1069 * These fields are retained for compatibility.
1070 * Please switch to the new header field below.
1072 uint8_t flags; /**< Normally 0x08 (I flag). */
1073 uint8_t rsvd0[3]; /**< Reserved, normally 0x000000. */
1074 uint8_t vni[3]; /**< VXLAN identifier. */
1075 uint8_t rsvd1; /**< Reserved, normally 0x00. */
1077 struct rte_vxlan_hdr hdr;
1081 /** Default mask for RTE_FLOW_ITEM_TYPE_VXLAN. */
1083 static const struct rte_flow_item_vxlan rte_flow_item_vxlan_mask = {
1084 .hdr.vx_vni = RTE_BE32(0xffffff00), /* (0xffffff << 8) */
1089 * RTE_FLOW_ITEM_TYPE_E_TAG.
1091 * Matches a E-tag header.
1093 * The corresponding standard outer EtherType (TPID) value is
1094 * RTE_ETHER_TYPE_ETAG. It can be overridden by the preceding pattern item.
1096 struct rte_flow_item_e_tag {
1098 * E-Tag control information (E-TCI).
1099 * E-PCP (3b), E-DEI (1b), ingress E-CID base (12b).
1101 rte_be16_t epcp_edei_in_ecid_b;
1102 /** Reserved (2b), GRP (2b), E-CID base (12b). */
1103 rte_be16_t rsvd_grp_ecid_b;
1104 uint8_t in_ecid_e; /**< Ingress E-CID ext. */
1105 uint8_t ecid_e; /**< E-CID ext. */
1106 rte_be16_t inner_type; /**< Inner EtherType or TPID. */
1109 /** Default mask for RTE_FLOW_ITEM_TYPE_E_TAG. */
1111 static const struct rte_flow_item_e_tag rte_flow_item_e_tag_mask = {
1112 .rsvd_grp_ecid_b = RTE_BE16(0x3fff),
1117 * RTE_FLOW_ITEM_TYPE_NVGRE.
1119 * Matches a NVGRE header.
1121 struct rte_flow_item_nvgre {
1123 * Checksum (1b), undefined (1b), key bit (1b), sequence number (1b),
1124 * reserved 0 (9b), version (3b).
1126 * c_k_s_rsvd0_ver must have value 0x2000 according to RFC 7637.
1128 rte_be16_t c_k_s_rsvd0_ver;
1129 rte_be16_t protocol; /**< Protocol type (0x6558). */
1130 uint8_t tni[3]; /**< Virtual subnet ID. */
1131 uint8_t flow_id; /**< Flow ID. */
1134 /** Default mask for RTE_FLOW_ITEM_TYPE_NVGRE. */
1136 static const struct rte_flow_item_nvgre rte_flow_item_nvgre_mask = {
1137 .tni = "\xff\xff\xff",
1142 * RTE_FLOW_ITEM_TYPE_MPLS.
1144 * Matches a MPLS header.
1146 struct rte_flow_item_mpls {
1148 * Label (20b), TC (3b), Bottom of Stack (1b).
1150 uint8_t label_tc_s[3];
1151 uint8_t ttl; /** Time-to-Live. */
1154 /** Default mask for RTE_FLOW_ITEM_TYPE_MPLS. */
1156 static const struct rte_flow_item_mpls rte_flow_item_mpls_mask = {
1157 .label_tc_s = "\xff\xff\xf0",
1162 * RTE_FLOW_ITEM_TYPE_GRE.
1164 * Matches a GRE header.
1166 struct rte_flow_item_gre {
1168 * Checksum (1b), reserved 0 (12b), version (3b).
1169 * Refer to RFC 2784.
1171 rte_be16_t c_rsvd0_ver;
1172 rte_be16_t protocol; /**< Protocol type. */
1175 /** Default mask for RTE_FLOW_ITEM_TYPE_GRE. */
1177 static const struct rte_flow_item_gre rte_flow_item_gre_mask = {
1178 .protocol = RTE_BE16(0xffff),
1183 * RTE_FLOW_ITEM_TYPE_FUZZY
1185 * Fuzzy pattern match, expect faster than default.
1187 * This is for device that support fuzzy match option.
1188 * Usually a fuzzy match is fast but the cost is accuracy.
1189 * i.e. Signature Match only match pattern's hash value, but it is
1190 * possible two different patterns have the same hash value.
1192 * Matching accuracy level can be configure by threshold.
1193 * Driver can divide the range of threshold and map to different
1194 * accuracy levels that device support.
1196 * Threshold 0 means perfect match (no fuzziness), while threshold
1197 * 0xffffffff means fuzziest match.
1199 struct rte_flow_item_fuzzy {
1200 uint32_t thresh; /**< Accuracy threshold. */
1203 /** Default mask for RTE_FLOW_ITEM_TYPE_FUZZY. */
1205 static const struct rte_flow_item_fuzzy rte_flow_item_fuzzy_mask = {
1206 .thresh = 0xffffffff,
1211 * RTE_FLOW_ITEM_TYPE_GTP.
1213 * Matches a GTPv1 header.
1215 struct rte_flow_item_gtp {
1217 * Version (3b), protocol type (1b), reserved (1b),
1218 * Extension header flag (1b),
1219 * Sequence number flag (1b),
1220 * N-PDU number flag (1b).
1222 uint8_t v_pt_rsv_flags;
1223 uint8_t msg_type; /**< Message type. */
1224 rte_be16_t msg_len; /**< Message length. */
1225 rte_be32_t teid; /**< Tunnel endpoint identifier. */
1228 /** Default mask for RTE_FLOW_ITEM_TYPE_GTP. */
1230 static const struct rte_flow_item_gtp rte_flow_item_gtp_mask = {
1231 .teid = RTE_BE32(0xffffffff),
1236 * RTE_FLOW_ITEM_TYPE_ESP
1238 * Matches an ESP header.
1240 struct rte_flow_item_esp {
1241 struct rte_esp_hdr hdr; /**< ESP header definition. */
1244 /** Default mask for RTE_FLOW_ITEM_TYPE_ESP. */
1246 static const struct rte_flow_item_esp rte_flow_item_esp_mask = {
1248 .spi = RTE_BE32(0xffffffff),
1254 * RTE_FLOW_ITEM_TYPE_GENEVE.
1256 * Matches a GENEVE header.
1258 struct rte_flow_item_geneve {
1260 * Version (2b), length of the options fields (6b), OAM packet (1b),
1261 * critical options present (1b), reserved 0 (6b).
1263 rte_be16_t ver_opt_len_o_c_rsvd0;
1264 rte_be16_t protocol; /**< Protocol type. */
1265 uint8_t vni[3]; /**< Virtual Network Identifier. */
1266 uint8_t rsvd1; /**< Reserved, normally 0x00. */
1269 /** Default mask for RTE_FLOW_ITEM_TYPE_GENEVE. */
1271 static const struct rte_flow_item_geneve rte_flow_item_geneve_mask = {
1272 .vni = "\xff\xff\xff",
1277 * RTE_FLOW_ITEM_TYPE_VXLAN_GPE (draft-ietf-nvo3-vxlan-gpe-05).
1279 * Matches a VXLAN-GPE header.
1281 struct rte_flow_item_vxlan_gpe {
1282 uint8_t flags; /**< Normally 0x0c (I and P flags). */
1283 uint8_t rsvd0[2]; /**< Reserved, normally 0x0000. */
1284 uint8_t protocol; /**< Protocol type. */
1285 uint8_t vni[3]; /**< VXLAN identifier. */
1286 uint8_t rsvd1; /**< Reserved, normally 0x00. */
1289 /** Default mask for RTE_FLOW_ITEM_TYPE_VXLAN_GPE. */
1291 static const struct rte_flow_item_vxlan_gpe rte_flow_item_vxlan_gpe_mask = {
1292 .vni = "\xff\xff\xff",
1297 * RTE_FLOW_ITEM_TYPE_ARP_ETH_IPV4
1299 * Matches an ARP header for Ethernet/IPv4.
1301 struct rte_flow_item_arp_eth_ipv4 {
1302 rte_be16_t hrd; /**< Hardware type, normally 1. */
1303 rte_be16_t pro; /**< Protocol type, normally 0x0800. */
1304 uint8_t hln; /**< Hardware address length, normally 6. */
1305 uint8_t pln; /**< Protocol address length, normally 4. */
1306 rte_be16_t op; /**< Opcode (1 for request, 2 for reply). */
1307 struct rte_ether_addr sha; /**< Sender hardware address. */
1308 rte_be32_t spa; /**< Sender IPv4 address. */
1309 struct rte_ether_addr tha; /**< Target hardware address. */
1310 rte_be32_t tpa; /**< Target IPv4 address. */
1313 /** Default mask for RTE_FLOW_ITEM_TYPE_ARP_ETH_IPV4. */
1315 static const struct rte_flow_item_arp_eth_ipv4
1316 rte_flow_item_arp_eth_ipv4_mask = {
1317 .sha.addr_bytes = "\xff\xff\xff\xff\xff\xff",
1318 .spa = RTE_BE32(0xffffffff),
1319 .tha.addr_bytes = "\xff\xff\xff\xff\xff\xff",
1320 .tpa = RTE_BE32(0xffffffff),
1325 * RTE_FLOW_ITEM_TYPE_IPV6_EXT
1327 * Matches the presence of any IPv6 extension header.
1329 * Normally preceded by any of:
1331 * - RTE_FLOW_ITEM_TYPE_IPV6
1332 * - RTE_FLOW_ITEM_TYPE_IPV6_EXT
1334 struct rte_flow_item_ipv6_ext {
1335 uint8_t next_hdr; /**< Next header. */
1338 /** Default mask for RTE_FLOW_ITEM_TYPE_IPV6_EXT. */
1341 struct rte_flow_item_ipv6_ext rte_flow_item_ipv6_ext_mask = {
1347 * RTE_FLOW_ITEM_TYPE_IPV6_FRAG_EXT
1349 * Matches the presence of IPv6 fragment extension header.
1351 * Preceded by any of:
1353 * - RTE_FLOW_ITEM_TYPE_IPV6
1354 * - RTE_FLOW_ITEM_TYPE_IPV6_EXT
1356 struct rte_flow_item_ipv6_frag_ext {
1357 struct rte_ipv6_fragment_ext hdr;
1361 * RTE_FLOW_ITEM_TYPE_ICMP6
1363 * Matches any ICMPv6 header.
1365 struct rte_flow_item_icmp6 {
1366 uint8_t type; /**< ICMPv6 type. */
1367 uint8_t code; /**< ICMPv6 code. */
1368 uint16_t checksum; /**< ICMPv6 checksum. */
1371 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6. */
1373 static const struct rte_flow_item_icmp6 rte_flow_item_icmp6_mask = {
1380 * RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS
1382 * Matches an ICMPv6 neighbor discovery solicitation.
1384 struct rte_flow_item_icmp6_nd_ns {
1385 uint8_t type; /**< ICMPv6 type, normally 135. */
1386 uint8_t code; /**< ICMPv6 code, normally 0. */
1387 rte_be16_t checksum; /**< ICMPv6 checksum. */
1388 rte_be32_t reserved; /**< Reserved, normally 0. */
1389 uint8_t target_addr[16]; /**< Target address. */
1392 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS. */
1395 struct rte_flow_item_icmp6_nd_ns rte_flow_item_icmp6_nd_ns_mask = {
1397 "\xff\xff\xff\xff\xff\xff\xff\xff"
1398 "\xff\xff\xff\xff\xff\xff\xff\xff",
1403 * RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA
1405 * Matches an ICMPv6 neighbor discovery advertisement.
1407 struct rte_flow_item_icmp6_nd_na {
1408 uint8_t type; /**< ICMPv6 type, normally 136. */
1409 uint8_t code; /**< ICMPv6 code, normally 0. */
1410 rte_be16_t checksum; /**< ICMPv6 checksum. */
1412 * Route flag (1b), solicited flag (1b), override flag (1b),
1415 rte_be32_t rso_reserved;
1416 uint8_t target_addr[16]; /**< Target address. */
1419 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA. */
1422 struct rte_flow_item_icmp6_nd_na rte_flow_item_icmp6_nd_na_mask = {
1424 "\xff\xff\xff\xff\xff\xff\xff\xff"
1425 "\xff\xff\xff\xff\xff\xff\xff\xff",
1430 * RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT
1432 * Matches the presence of any ICMPv6 neighbor discovery option.
1434 * Normally preceded by any of:
1436 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA
1437 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS
1438 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT
1440 struct rte_flow_item_icmp6_nd_opt {
1441 uint8_t type; /**< ND option type. */
1442 uint8_t length; /**< ND option length. */
1445 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT. */
1447 static const struct rte_flow_item_icmp6_nd_opt
1448 rte_flow_item_icmp6_nd_opt_mask = {
1454 * RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_SLA_ETH
1456 * Matches an ICMPv6 neighbor discovery source Ethernet link-layer address
1459 * Normally preceded by any of:
1461 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA
1462 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT
1464 struct rte_flow_item_icmp6_nd_opt_sla_eth {
1465 uint8_t type; /**< ND option type, normally 1. */
1466 uint8_t length; /**< ND option length, normally 1. */
1467 struct rte_ether_addr sla; /**< Source Ethernet LLA. */
1470 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_SLA_ETH. */
1472 static const struct rte_flow_item_icmp6_nd_opt_sla_eth
1473 rte_flow_item_icmp6_nd_opt_sla_eth_mask = {
1474 .sla.addr_bytes = "\xff\xff\xff\xff\xff\xff",
1479 * RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_TLA_ETH
1481 * Matches an ICMPv6 neighbor discovery target Ethernet link-layer address
1484 * Normally preceded by any of:
1486 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS
1487 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT
1489 struct rte_flow_item_icmp6_nd_opt_tla_eth {
1490 uint8_t type; /**< ND option type, normally 2. */
1491 uint8_t length; /**< ND option length, normally 1. */
1492 struct rte_ether_addr tla; /**< Target Ethernet LLA. */
1495 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_TLA_ETH. */
1497 static const struct rte_flow_item_icmp6_nd_opt_tla_eth
1498 rte_flow_item_icmp6_nd_opt_tla_eth_mask = {
1499 .tla.addr_bytes = "\xff\xff\xff\xff\xff\xff",
1504 * RTE_FLOW_ITEM_TYPE_META
1506 * Matches a specified metadata value. On egress, metadata can be set
1507 * either by mbuf dynamic metadata field with PKT_TX_DYNF_METADATA flag or
1508 * RTE_FLOW_ACTION_TYPE_SET_META. On ingress, RTE_FLOW_ACTION_TYPE_SET_META
1509 * sets metadata for a packet and the metadata will be reported via mbuf
1510 * metadata dynamic field with PKT_RX_DYNF_METADATA flag. The dynamic mbuf
1511 * field must be registered in advance by rte_flow_dynf_metadata_register().
1513 struct rte_flow_item_meta {
1517 /** Default mask for RTE_FLOW_ITEM_TYPE_META. */
1519 static const struct rte_flow_item_meta rte_flow_item_meta_mask = {
1525 * RTE_FLOW_ITEM_TYPE_GTP_PSC.
1527 * Matches a GTP PDU extension header with type 0x85.
1529 struct rte_flow_item_gtp_psc {
1530 struct rte_gtp_psc_generic_hdr hdr; /**< gtp psc generic hdr. */
1533 /** Default mask for RTE_FLOW_ITEM_TYPE_GTP_PSC. */
1535 static const struct rte_flow_item_gtp_psc
1536 rte_flow_item_gtp_psc_mask = {
1542 * RTE_FLOW_ITEM_TYPE_PPPOE.
1544 * Matches a PPPoE header.
1546 struct rte_flow_item_pppoe {
1548 * Version (4b), type (4b).
1550 uint8_t version_type;
1551 uint8_t code; /**< Message type. */
1552 rte_be16_t session_id; /**< Session identifier. */
1553 rte_be16_t length; /**< Payload length. */
1557 * RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID.
1559 * Matches a PPPoE optional proto_id field.
1561 * It only applies to PPPoE session packets.
1563 * Normally preceded by any of:
1565 * - RTE_FLOW_ITEM_TYPE_PPPOE
1566 * - RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID
1568 struct rte_flow_item_pppoe_proto_id {
1569 rte_be16_t proto_id; /**< PPP protocol identifier. */
1572 /** Default mask for RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID. */
1574 static const struct rte_flow_item_pppoe_proto_id
1575 rte_flow_item_pppoe_proto_id_mask = {
1576 .proto_id = RTE_BE16(0xffff),
1582 * @b EXPERIMENTAL: this structure may change without prior notice
1584 * RTE_FLOW_ITEM_TYPE_TAG
1586 * Matches a specified tag value at the specified index.
1588 struct rte_flow_item_tag {
1593 /** Default mask for RTE_FLOW_ITEM_TYPE_TAG. */
1595 static const struct rte_flow_item_tag rte_flow_item_tag_mask = {
1602 * RTE_FLOW_ITEM_TYPE_L2TPV3OIP.
1604 * Matches a L2TPv3 over IP header.
1606 struct rte_flow_item_l2tpv3oip {
1607 rte_be32_t session_id; /**< Session ID. */
1610 /** Default mask for RTE_FLOW_ITEM_TYPE_L2TPV3OIP. */
1612 static const struct rte_flow_item_l2tpv3oip rte_flow_item_l2tpv3oip_mask = {
1613 .session_id = RTE_BE32(UINT32_MAX),
1620 * @b EXPERIMENTAL: this structure may change without prior notice
1622 * RTE_FLOW_ITEM_TYPE_MARK
1624 * Matches an arbitrary integer value which was set using the ``MARK`` action
1625 * in a previously matched rule.
1627 * This item can only be specified once as a match criteria as the ``MARK``
1628 * action can only be specified once in a flow action.
1630 * This value is arbitrary and application-defined. Maximum allowed value
1631 * depends on the underlying implementation.
1633 * Depending on the underlying implementation the MARK item may be supported on
1634 * the physical device, with virtual groups in the PMD or not at all.
1636 struct rte_flow_item_mark {
1637 uint32_t id; /**< Integer value to match against. */
1640 /** Default mask for RTE_FLOW_ITEM_TYPE_MARK. */
1642 static const struct rte_flow_item_mark rte_flow_item_mark_mask = {
1649 * @b EXPERIMENTAL: this structure may change without prior notice
1651 * RTE_FLOW_ITEM_TYPE_NSH
1653 * Match network service header (NSH), RFC 8300
1656 struct rte_flow_item_nsh {
1659 uint32_t reserved:1;
1662 uint32_t reserved1:4;
1664 uint32_t next_proto:8;
1669 /** Default mask for RTE_FLOW_ITEM_TYPE_NSH. */
1671 static const struct rte_flow_item_nsh rte_flow_item_nsh_mask = {
1681 * @b EXPERIMENTAL: this structure may change without prior notice
1683 * RTE_FLOW_ITEM_TYPE_IGMP
1685 * Match Internet Group Management Protocol (IGMP), RFC 2236
1688 struct rte_flow_item_igmp {
1690 uint32_t max_resp_time:8;
1691 uint32_t checksum:16;
1692 uint32_t group_addr;
1695 /** Default mask for RTE_FLOW_ITEM_TYPE_IGMP. */
1697 static const struct rte_flow_item_igmp rte_flow_item_igmp_mask = {
1698 .group_addr = 0xffffffff,
1704 * @b EXPERIMENTAL: this structure may change without prior notice
1706 * RTE_FLOW_ITEM_TYPE_AH
1708 * Match IP Authentication Header (AH), RFC 4302
1711 struct rte_flow_item_ah {
1712 uint32_t next_hdr:8;
1713 uint32_t payload_len:8;
1714 uint32_t reserved:16;
1719 /** Default mask for RTE_FLOW_ITEM_TYPE_AH. */
1721 static const struct rte_flow_item_ah rte_flow_item_ah_mask = {
1728 * @b EXPERIMENTAL: this structure may change without prior notice
1730 * RTE_FLOW_ITEM_TYPE_PFCP
1734 struct rte_flow_item_pfcp {
1741 /** Default mask for RTE_FLOW_ITEM_TYPE_PFCP. */
1743 static const struct rte_flow_item_pfcp rte_flow_item_pfcp_mask = {
1745 .seid = RTE_BE64(UINT64_C(0xffffffffffffffff)),
1751 * @b EXPERIMENTAL: this structure may change without prior notice
1753 * RTE_FLOW_ITEM_TYPE_ECPRI
1755 * Match eCPRI Header
1757 struct rte_flow_item_ecpri {
1758 struct rte_ecpri_combined_msg_hdr hdr;
1761 /** Default mask for RTE_FLOW_ITEM_TYPE_ECPRI. */
1763 static const struct rte_flow_item_ecpri rte_flow_item_ecpri_mask = {
1773 * RTE_FLOW_ITEM_TYPE_GENEVE_OPT
1775 * Matches a GENEVE Variable Length Option
1777 struct rte_flow_item_geneve_opt {
1778 rte_be16_t option_class;
1779 uint8_t option_type;
1784 /** Default mask for RTE_FLOW_ITEM_TYPE_GENEVE_OPT. */
1786 static const struct rte_flow_item_geneve_opt
1787 rte_flow_item_geneve_opt_mask = {
1788 .option_type = 0xff,
1794 * @b EXPERIMENTAL: this structure may change without prior notice
1796 * RTE_FLOW_ITEM_TYPE_INTEGRITY
1798 * Match on packet integrity check result.
1800 struct rte_flow_item_integrity {
1801 /** Tunnel encapsulation level the item should apply to.
1802 * @see rte_flow_action_rss
1809 /** The packet is valid after passing all HW checks. */
1810 uint64_t packet_ok:1;
1811 /** L2 layer is valid after passing all HW checks. */
1813 /** L3 layer is valid after passing all HW checks. */
1815 /** L4 layer is valid after passing all HW checks. */
1817 /** L2 layer CRC is valid. */
1818 uint64_t l2_crc_ok:1;
1819 /** IPv4 layer checksum is valid. */
1820 uint64_t ipv4_csum_ok:1;
1821 /** L4 layer checksum is valid. */
1822 uint64_t l4_csum_ok:1;
1823 /** L3 length is smaller than frame length. */
1824 uint64_t l3_len_ok:1;
1825 uint64_t reserved:56;
1832 static const struct rte_flow_item_integrity
1833 rte_flow_item_integrity_mask = {
1840 * The packet is valid after conntrack checking.
1842 #define RTE_FLOW_CONNTRACK_PKT_STATE_VALID RTE_BIT32(0)
1844 * The state of the connection is changed.
1846 #define RTE_FLOW_CONNTRACK_PKT_STATE_CHANGED RTE_BIT32(1)
1848 * Error is detected on this packet for this connection and
1849 * an invalid state is set.
1851 #define RTE_FLOW_CONNTRACK_PKT_STATE_INVALID RTE_BIT32(2)
1853 * The HW connection tracking module is disabled.
1854 * It can be due to application command or an invalid state.
1856 #define RTE_FLOW_CONNTRACK_PKT_STATE_DISABLED RTE_BIT32(3)
1858 * The packet contains some bad field(s) and cannot continue
1859 * with the conntrack module checking.
1861 #define RTE_FLOW_CONNTRACK_PKT_STATE_BAD RTE_BIT32(4)
1865 * @b EXPERIMENTAL: this structure may change without prior notice
1867 * RTE_FLOW_ITEM_TYPE_CONNTRACK
1869 * Matches the state of a packet after it passed the connection tracking
1870 * examination. The state is a bitmap of one RTE_FLOW_CONNTRACK_PKT_STATE*
1871 * or a reasonable combination of these bits.
1873 struct rte_flow_item_conntrack {
1877 /** Default mask for RTE_FLOW_ITEM_TYPE_CONNTRACK. */
1879 static const struct rte_flow_item_conntrack rte_flow_item_conntrack_mask = {
1880 .flags = 0xffffffff,
1886 * @b EXPERIMENTAL: this structure may change without prior notice
1888 * Provides an ethdev port ID for use with the following items:
1889 * RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR,
1890 * RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT.
1892 struct rte_flow_item_ethdev {
1893 uint16_t port_id; /**< ethdev port ID */
1896 /** Default mask for items based on struct rte_flow_item_ethdev */
1898 static const struct rte_flow_item_ethdev rte_flow_item_ethdev_mask = {
1904 * Matching pattern item definition.
1906 * A pattern is formed by stacking items starting from the lowest protocol
1907 * layer to match. This stacking restriction does not apply to meta items
1908 * which can be placed anywhere in the stack without affecting the meaning
1909 * of the resulting pattern.
1911 * Patterns are terminated by END items.
1913 * The spec field should be a valid pointer to a structure of the related
1914 * item type. It may remain unspecified (NULL) in many cases to request
1915 * broad (nonspecific) matching. In such cases, last and mask must also be
1918 * Optionally, last can point to a structure of the same type to define an
1919 * inclusive range. This is mostly supported by integer and address fields,
1920 * may cause errors otherwise. Fields that do not support ranges must be set
1921 * to 0 or to the same value as the corresponding fields in spec.
1923 * Only the fields defined to nonzero values in the default masks (see
1924 * rte_flow_item_{name}_mask constants) are considered relevant by
1925 * default. This can be overridden by providing a mask structure of the
1926 * same type with applicable bits set to one. It can also be used to
1927 * partially filter out specific fields (e.g. as an alternate mean to match
1928 * ranges of IP addresses).
1930 * Mask is a simple bit-mask applied before interpreting the contents of
1931 * spec and last, which may yield unexpected results if not used
1932 * carefully. For example, if for an IPv4 address field, spec provides
1933 * 10.1.2.3, last provides 10.3.4.5 and mask provides 255.255.0.0, the
1934 * effective range becomes 10.1.0.0 to 10.3.255.255.
1936 struct rte_flow_item {
1937 enum rte_flow_item_type type; /**< Item type. */
1938 const void *spec; /**< Pointer to item specification structure. */
1939 const void *last; /**< Defines an inclusive range (spec to last). */
1940 const void *mask; /**< Bit-mask applied to spec and last. */
1945 * @b EXPERIMENTAL: this structure may change without prior notice
1947 * RTE_FLOW_ITEM_TYPE_FLEX
1949 * Matches a specified set of fields within the network protocol
1950 * header. Each field is presented as set of bits with specified width, and
1951 * bit offset from the header beginning.
1953 * The pattern is concatenation of bit fields configured at item creation
1954 * by rte_flow_flex_item_create(). At configuration the fields are presented
1955 * by sample_data array.
1957 * This type does not support ranges (struct rte_flow_item.last).
1959 struct rte_flow_item_flex {
1960 struct rte_flow_item_flex_handle *handle; /**< Opaque item handle. */
1961 uint32_t length; /**< Pattern length in bytes. */
1962 const uint8_t *pattern; /**< Combined bitfields pattern to match. */
1965 * Field bit offset calculation mode.
1967 enum rte_flow_item_flex_field_mode {
1969 * Dummy field, used for byte boundary alignment in pattern.
1970 * Pattern mask and data are ignored in the match. All configuration
1971 * parameters besides field size are ignored.
1973 FIELD_MODE_DUMMY = 0,
1975 * Fixed offset field. The bit offset from header beginning
1976 * is permanent and defined by field_base parameter.
1980 * The field bit offset is extracted from other header field (indirect
1981 * offset field). The resulting field offset to match is calculated as:
1983 * field_base + (*offset_base & offset_mask) << offset_shift
1987 * The field bit offset is extracted from other header field (indirect
1988 * offset field), the latter is considered as bitmask containing some
1989 * number of one bits, the resulting field offset to match is
1992 * field_base + bitcount(*offset_base & offset_mask) << offset_shift
1998 * Flex item field tunnel mode
2000 enum rte_flow_item_flex_tunnel_mode {
2002 * The protocol header can be present in the packet only once.
2003 * No multiple flex item flow inclusions (for inner/outer) are allowed.
2004 * No any relations with tunnel protocols are imposed. The drivers
2005 * can optimize hardware resource usage to handle match on single flex
2006 * item of specific type.
2008 FLEX_TUNNEL_MODE_SINGLE = 0,
2010 * Flex item presents outer header only.
2012 FLEX_TUNNEL_MODE_OUTER,
2014 * Flex item presents inner header only.
2016 FLEX_TUNNEL_MODE_INNER,
2018 * Flex item presents either inner or outer header. The driver
2019 * handles as many multiple inners as hardware supports.
2021 FLEX_TUNNEL_MODE_MULTI,
2023 * Flex item presents tunnel protocol header.
2025 FLEX_TUNNEL_MODE_TUNNEL,
2031 * @b EXPERIMENTAL: this structure may change without prior notice
2034 struct rte_flow_item_flex_field {
2035 /** Defines how match field offset is calculated over the packet. */
2036 enum rte_flow_item_flex_field_mode field_mode;
2037 uint32_t field_size; /**< Field size in bits. */
2038 int32_t field_base; /**< Field offset in bits. */
2039 uint32_t offset_base; /**< Indirect offset field offset in bits. */
2040 uint32_t offset_mask; /**< Indirect offset field bit mask. */
2041 int32_t offset_shift; /**< Indirect offset multiply factor. */
2042 uint32_t field_id:16; /**< Device hint, for multiple items in flow. */
2043 uint32_t reserved:16; /**< Reserved field. */
2048 * @b EXPERIMENTAL: this structure may change without prior notice
2050 struct rte_flow_item_flex_link {
2052 * Preceding/following header. The item type must be always provided.
2053 * For preceding one item must specify the header value/mask to match
2054 * for the link be taken and start the flex item header parsing.
2056 struct rte_flow_item item;
2058 * Next field value to match to continue with one of the configured
2066 * @b EXPERIMENTAL: this structure may change without prior notice
2068 struct rte_flow_item_flex_conf {
2070 * Specifies the flex item and tunnel relations and tells the PMD
2071 * whether flex item can be used for inner, outer or both headers,
2072 * or whether flex item presents the tunnel protocol itself.
2074 enum rte_flow_item_flex_tunnel_mode tunnel;
2076 * The next header offset, it presents the network header size covered
2077 * by the flex item and can be obtained with all supported offset
2078 * calculating methods (fixed, dedicated field, bitmask, etc).
2080 struct rte_flow_item_flex_field next_header;
2082 * Specifies the next protocol field to match with link next protocol
2083 * values and continue packet parsing with matching link.
2085 struct rte_flow_item_flex_field next_protocol;
2087 * The fields will be sampled and presented for explicit match
2088 * with pattern in the rte_flow_flex_item. There can be multiple
2089 * fields descriptors, the number should be specified by nb_samples.
2091 struct rte_flow_item_flex_field *sample_data;
2092 /** Number of field descriptors in the sample_data array. */
2093 uint32_t nb_samples;
2095 * Input link defines the flex item relation with preceding
2096 * header. It specified the preceding item type and provides pattern
2097 * to match. The flex item will continue parsing and will provide the
2098 * data to flow match in case if there is the match with one of input
2101 struct rte_flow_item_flex_link *input_link;
2102 /** Number of link descriptors in the input link array. */
2105 * Output link defines the next protocol field value to match and
2106 * the following protocol header to continue packet parsing. Also
2107 * defines the tunnel-related behaviour.
2109 struct rte_flow_item_flex_link *output_link;
2110 /** Number of link descriptors in the output link array. */
2111 uint32_t nb_outputs;
2117 * Each possible action is represented by a type.
2118 * An action can have an associated configuration object.
2119 * Several actions combined in a list can be assigned
2120 * to a flow rule and are performed in order.
2122 * They fall in three categories:
2124 * - Actions that modify the fate of matching traffic, for instance by
2125 * dropping or assigning it a specific destination.
2127 * - Actions that modify matching traffic contents or its properties. This
2128 * includes adding/removing encapsulation, encryption, compression and
2131 * - Actions related to the flow rule itself, such as updating counters or
2132 * making it non-terminating.
2134 * Flow rules being terminating by default, not specifying any action of the
2135 * fate kind results in undefined behavior. This applies to both ingress and
2138 * PASSTHRU, when supported, makes a flow rule non-terminating.
2140 enum rte_flow_action_type {
2142 * End marker for action lists. Prevents further processing of
2143 * actions, thereby ending the list.
2145 * No associated configuration structure.
2147 RTE_FLOW_ACTION_TYPE_END,
2150 * Used as a placeholder for convenience. It is ignored and simply
2151 * discarded by PMDs.
2153 * No associated configuration structure.
2155 RTE_FLOW_ACTION_TYPE_VOID,
2158 * Leaves traffic up for additional processing by subsequent flow
2159 * rules; makes a flow rule non-terminating.
2161 * No associated configuration structure.
2163 RTE_FLOW_ACTION_TYPE_PASSTHRU,
2166 * RTE_FLOW_ACTION_TYPE_JUMP
2168 * Redirects packets to a group on the current device.
2170 * See struct rte_flow_action_jump.
2172 RTE_FLOW_ACTION_TYPE_JUMP,
2175 * Attaches an integer value to packets and sets PKT_RX_FDIR and
2176 * PKT_RX_FDIR_ID mbuf flags.
2178 * See struct rte_flow_action_mark.
2180 * One should negotiate mark delivery from the NIC to the PMD.
2181 * @see rte_eth_rx_metadata_negotiate()
2182 * @see RTE_ETH_RX_METADATA_USER_MARK
2184 RTE_FLOW_ACTION_TYPE_MARK,
2187 * Flags packets. Similar to MARK without a specific value; only
2188 * sets the PKT_RX_FDIR mbuf flag.
2190 * No associated configuration structure.
2192 * One should negotiate flag delivery from the NIC to the PMD.
2193 * @see rte_eth_rx_metadata_negotiate()
2194 * @see RTE_ETH_RX_METADATA_USER_FLAG
2196 RTE_FLOW_ACTION_TYPE_FLAG,
2199 * Assigns packets to a given queue index.
2201 * See struct rte_flow_action_queue.
2203 RTE_FLOW_ACTION_TYPE_QUEUE,
2208 * PASSTHRU overrides this action if both are specified.
2210 * No associated configuration structure.
2212 RTE_FLOW_ACTION_TYPE_DROP,
2215 * Enables counters for this flow rule.
2217 * These counters can be retrieved and reset through rte_flow_query() or
2218 * rte_flow_action_handle_query() if the action provided via handle,
2219 * see struct rte_flow_query_count.
2221 * See struct rte_flow_action_count.
2223 RTE_FLOW_ACTION_TYPE_COUNT,
2226 * Similar to QUEUE, except RSS is additionally performed on packets
2227 * to spread them among several queues according to the provided
2230 * See struct rte_flow_action_rss.
2232 RTE_FLOW_ACTION_TYPE_RSS,
2236 * @see RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR
2237 * @see RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT
2239 * Directs matching traffic to the physical function (PF) of the
2242 * No associated configuration structure.
2244 RTE_FLOW_ACTION_TYPE_PF,
2248 * @see RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR
2249 * @see RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT
2251 * Directs matching traffic to a given virtual function of the
2254 * See struct rte_flow_action_vf.
2256 RTE_FLOW_ACTION_TYPE_VF,
2260 * @see RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR
2261 * @see RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT
2263 * Directs packets to a given physical port index of the underlying
2266 * See struct rte_flow_action_phy_port.
2268 RTE_FLOW_ACTION_TYPE_PHY_PORT,
2272 * @see RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR
2273 * @see RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT
2275 * Directs matching traffic to a given DPDK port ID.
2277 * See struct rte_flow_action_port_id.
2279 RTE_FLOW_ACTION_TYPE_PORT_ID,
2282 * Traffic metering and policing (MTR).
2284 * See struct rte_flow_action_meter.
2285 * See file rte_mtr.h for MTR object configuration.
2287 RTE_FLOW_ACTION_TYPE_METER,
2290 * Redirects packets to security engine of current device for security
2291 * processing as specified by security session.
2293 * See struct rte_flow_action_security.
2295 RTE_FLOW_ACTION_TYPE_SECURITY,
2298 * Implements OFPAT_SET_MPLS_TTL ("MPLS TTL") as defined by the
2299 * OpenFlow Switch Specification.
2301 * See struct rte_flow_action_of_set_mpls_ttl.
2303 RTE_FLOW_ACTION_TYPE_OF_SET_MPLS_TTL,
2306 * Implements OFPAT_DEC_MPLS_TTL ("decrement MPLS TTL") as defined
2307 * by the OpenFlow Switch Specification.
2309 * No associated configuration structure.
2311 RTE_FLOW_ACTION_TYPE_OF_DEC_MPLS_TTL,
2314 * Implements OFPAT_SET_NW_TTL ("IP TTL") as defined by the OpenFlow
2315 * Switch Specification.
2317 * See struct rte_flow_action_of_set_nw_ttl.
2319 RTE_FLOW_ACTION_TYPE_OF_SET_NW_TTL,
2322 * Implements OFPAT_DEC_NW_TTL ("decrement IP TTL") as defined by
2323 * the OpenFlow Switch Specification.
2325 * No associated configuration structure.
2327 RTE_FLOW_ACTION_TYPE_OF_DEC_NW_TTL,
2330 * Implements OFPAT_COPY_TTL_OUT ("copy TTL "outwards" -- from
2331 * next-to-outermost to outermost") as defined by the OpenFlow
2332 * Switch Specification.
2334 * No associated configuration structure.
2336 RTE_FLOW_ACTION_TYPE_OF_COPY_TTL_OUT,
2339 * Implements OFPAT_COPY_TTL_IN ("copy TTL "inwards" -- from
2340 * outermost to next-to-outermost") as defined by the OpenFlow
2341 * Switch Specification.
2343 * No associated configuration structure.
2345 RTE_FLOW_ACTION_TYPE_OF_COPY_TTL_IN,
2348 * Implements OFPAT_POP_VLAN ("pop the outer VLAN tag") as defined
2349 * by the OpenFlow Switch Specification.
2351 * No associated configuration structure.
2353 RTE_FLOW_ACTION_TYPE_OF_POP_VLAN,
2356 * Implements OFPAT_PUSH_VLAN ("push a new VLAN tag") as defined by
2357 * the OpenFlow Switch Specification.
2359 * See struct rte_flow_action_of_push_vlan.
2361 RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN,
2364 * Implements OFPAT_SET_VLAN_VID ("set the 802.1q VLAN id") as
2365 * defined by the OpenFlow Switch Specification.
2367 * See struct rte_flow_action_of_set_vlan_vid.
2369 RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID,
2372 * Implements OFPAT_SET_LAN_PCP ("set the 802.1q priority") as
2373 * defined by the OpenFlow Switch Specification.
2375 * See struct rte_flow_action_of_set_vlan_pcp.
2377 RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP,
2380 * Implements OFPAT_POP_MPLS ("pop the outer MPLS tag") as defined
2381 * by the OpenFlow Switch Specification.
2383 * See struct rte_flow_action_of_pop_mpls.
2385 RTE_FLOW_ACTION_TYPE_OF_POP_MPLS,
2388 * Implements OFPAT_PUSH_MPLS ("push a new MPLS tag") as defined by
2389 * the OpenFlow Switch Specification.
2391 * See struct rte_flow_action_of_push_mpls.
2393 RTE_FLOW_ACTION_TYPE_OF_PUSH_MPLS,
2396 * Encapsulate flow in VXLAN tunnel as defined in
2397 * rte_flow_action_vxlan_encap action structure.
2399 * See struct rte_flow_action_vxlan_encap.
2401 RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP,
2404 * Decapsulate outer most VXLAN tunnel from matched flow.
2406 * If flow pattern does not define a valid VXLAN tunnel (as specified by
2407 * RFC7348) then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION
2410 RTE_FLOW_ACTION_TYPE_VXLAN_DECAP,
2413 * Encapsulate flow in NVGRE tunnel defined in the
2414 * rte_flow_action_nvgre_encap action structure.
2416 * See struct rte_flow_action_nvgre_encap.
2418 RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP,
2421 * Decapsulate outer most NVGRE tunnel from matched flow.
2423 * If flow pattern does not define a valid NVGRE tunnel (as specified by
2424 * RFC7637) then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION
2427 RTE_FLOW_ACTION_TYPE_NVGRE_DECAP,
2430 * Add outer header whose template is provided in its data buffer
2432 * See struct rte_flow_action_raw_encap.
2434 RTE_FLOW_ACTION_TYPE_RAW_ENCAP,
2437 * Remove outer header whose template is provided in its data buffer.
2439 * See struct rte_flow_action_raw_decap
2441 RTE_FLOW_ACTION_TYPE_RAW_DECAP,
2444 * Modify IPv4 source address in the outermost IPv4 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_ipv4.
2451 RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC,
2454 * Modify IPv4 destination address in the outermost IPv4 header.
2456 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV4,
2457 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2459 * See struct rte_flow_action_set_ipv4.
2461 RTE_FLOW_ACTION_TYPE_SET_IPV4_DST,
2464 * Modify IPv6 source address in the outermost IPv6 header.
2466 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV6,
2467 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2469 * See struct rte_flow_action_set_ipv6.
2471 RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC,
2474 * Modify IPv6 destination address in the outermost IPv6 header.
2476 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV6,
2477 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2479 * See struct rte_flow_action_set_ipv6.
2481 RTE_FLOW_ACTION_TYPE_SET_IPV6_DST,
2484 * Modify source port number in the outermost TCP/UDP header.
2486 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_TCP
2487 * or RTE_FLOW_ITEM_TYPE_UDP, then the PMD should return a
2488 * RTE_FLOW_ERROR_TYPE_ACTION error.
2490 * See struct rte_flow_action_set_tp.
2492 RTE_FLOW_ACTION_TYPE_SET_TP_SRC,
2495 * Modify destination port number in the outermost TCP/UDP header.
2497 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_TCP
2498 * or RTE_FLOW_ITEM_TYPE_UDP, then the PMD should return a
2499 * RTE_FLOW_ERROR_TYPE_ACTION error.
2501 * See struct rte_flow_action_set_tp.
2503 RTE_FLOW_ACTION_TYPE_SET_TP_DST,
2506 * Swap the source and destination MAC addresses in the outermost
2509 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_ETH,
2510 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2512 * No associated configuration structure.
2514 RTE_FLOW_ACTION_TYPE_MAC_SWAP,
2517 * Decrease TTL value directly
2519 * No associated configuration structure.
2521 RTE_FLOW_ACTION_TYPE_DEC_TTL,
2526 * See struct rte_flow_action_set_ttl
2528 RTE_FLOW_ACTION_TYPE_SET_TTL,
2531 * Set source MAC address from matched flow.
2533 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_ETH,
2534 * the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2536 * See struct rte_flow_action_set_mac.
2538 RTE_FLOW_ACTION_TYPE_SET_MAC_SRC,
2541 * Set destination MAC address from matched flow.
2543 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_ETH,
2544 * the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2546 * See struct rte_flow_action_set_mac.
2548 RTE_FLOW_ACTION_TYPE_SET_MAC_DST,
2551 * Increase sequence number in the outermost TCP header.
2553 * Action configuration specifies the value to increase
2554 * TCP sequence number as a big-endian 32 bit integer.
2557 * @code rte_be32_t * @endcode
2559 * Using this action on non-matching traffic will result in
2560 * undefined behavior.
2562 RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ,
2565 * Decrease sequence number in the outermost TCP header.
2567 * Action configuration specifies the value to decrease
2568 * TCP sequence number as a big-endian 32 bit integer.
2571 * @code rte_be32_t * @endcode
2573 * Using this action on non-matching traffic will result in
2574 * undefined behavior.
2576 RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ,
2579 * Increase acknowledgment number in the outermost TCP header.
2581 * Action configuration specifies the value to increase
2582 * TCP acknowledgment number as a big-endian 32 bit integer.
2585 * @code rte_be32_t * @endcode
2587 * Using this action on non-matching traffic will result in
2588 * undefined behavior.
2590 RTE_FLOW_ACTION_TYPE_INC_TCP_ACK,
2593 * Decrease acknowledgment number in the outermost TCP header.
2595 * Action configuration specifies the value to decrease
2596 * TCP acknowledgment number as a big-endian 32 bit integer.
2599 * @code rte_be32_t * @endcode
2601 * Using this action on non-matching traffic will result in
2602 * undefined behavior.
2604 RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK,
2609 * Tag is for internal flow usage only and
2610 * is not delivered to the application.
2612 * See struct rte_flow_action_set_tag.
2614 RTE_FLOW_ACTION_TYPE_SET_TAG,
2617 * Set metadata on ingress or egress path.
2619 * See struct rte_flow_action_set_meta.
2621 RTE_FLOW_ACTION_TYPE_SET_META,
2624 * Modify IPv4 DSCP in the outermost IP header.
2626 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV4,
2627 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2629 * See struct rte_flow_action_set_dscp.
2631 RTE_FLOW_ACTION_TYPE_SET_IPV4_DSCP,
2634 * Modify IPv6 DSCP in the outermost IP header.
2636 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV6,
2637 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2639 * See struct rte_flow_action_set_dscp.
2641 RTE_FLOW_ACTION_TYPE_SET_IPV6_DSCP,
2644 * Report as aged flow if timeout passed without any matching on the
2647 * See struct rte_flow_action_age.
2648 * See function rte_flow_get_aged_flows
2649 * see enum RTE_ETH_EVENT_FLOW_AGED
2650 * See struct rte_flow_query_age
2652 RTE_FLOW_ACTION_TYPE_AGE,
2655 * The matching packets will be duplicated with specified ratio and
2656 * applied with own set of actions with a fate action.
2658 * See struct rte_flow_action_sample.
2660 RTE_FLOW_ACTION_TYPE_SAMPLE,
2664 * @see RTE_FLOW_ACTION_TYPE_INDIRECT
2666 * Describe action shared across multiple flow rules.
2668 * Allow multiple rules reference the same action by handle (see
2669 * struct rte_flow_shared_action).
2671 RTE_FLOW_ACTION_TYPE_SHARED,
2674 * Modify a packet header field, tag, mark or metadata.
2676 * Allow the modification of an arbitrary header field via
2677 * set, add and sub operations or copying its content into
2678 * tag, meta or mark for future processing.
2680 * See struct rte_flow_action_modify_field.
2682 RTE_FLOW_ACTION_TYPE_MODIFY_FIELD,
2685 * An action handle is referenced in a rule through an indirect action.
2687 * The same action handle may be used in multiple rules for the same
2688 * or different ethdev ports.
2690 RTE_FLOW_ACTION_TYPE_INDIRECT,
2695 * Enable tracking a TCP connection state.
2697 * @see struct rte_flow_action_conntrack.
2699 RTE_FLOW_ACTION_TYPE_CONNTRACK,
2702 * Color the packet to reflect the meter color result.
2703 * Set the meter color in the mbuf to the selected color.
2705 * See struct rte_flow_action_meter_color.
2707 RTE_FLOW_ACTION_TYPE_METER_COLOR,
2710 * At embedded switch level, sends matching traffic to the given ethdev.
2712 * @see struct rte_flow_action_ethdev
2714 RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR,
2717 * At embedded switch level, send matching traffic to
2718 * the entity represented by the given ethdev.
2720 * @see struct rte_flow_action_ethdev
2722 RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT,
2726 * RTE_FLOW_ACTION_TYPE_MARK
2728 * Attaches an integer value to packets and sets PKT_RX_FDIR and
2729 * PKT_RX_FDIR_ID mbuf flags.
2731 * This value is arbitrary and application-defined. Maximum allowed value
2732 * depends on the underlying implementation. It is returned in the
2733 * hash.fdir.hi mbuf field.
2735 struct rte_flow_action_mark {
2736 uint32_t id; /**< Integer value to return with packets. */
2741 * @b EXPERIMENTAL: this structure may change without prior notice
2743 * RTE_FLOW_ACTION_TYPE_JUMP
2745 * Redirects packets to a group on the current device.
2747 * In a hierarchy of groups, which can be used to represent physical or logical
2748 * flow tables on the device, this action allows the action to be a redirect to
2749 * a group on that device.
2751 struct rte_flow_action_jump {
2756 * RTE_FLOW_ACTION_TYPE_QUEUE
2758 * Assign packets to a given queue index.
2760 struct rte_flow_action_queue {
2761 uint16_t index; /**< Queue index to use. */
2766 * @b EXPERIMENTAL: this structure may change without prior notice
2768 * RTE_FLOW_ACTION_TYPE_AGE
2770 * Report flow as aged-out if timeout passed without any matching
2771 * on the flow. RTE_ETH_EVENT_FLOW_AGED event is triggered when a
2772 * port detects new aged-out flows.
2774 * The flow context and the flow handle will be reported by the
2775 * rte_flow_get_aged_flows API.
2777 struct rte_flow_action_age {
2778 uint32_t timeout:24; /**< Time in seconds. */
2779 uint32_t reserved:8; /**< Reserved, must be zero. */
2780 /** The user flow context, NULL means the rte_flow pointer. */
2785 * RTE_FLOW_ACTION_TYPE_AGE (query)
2787 * Query structure to retrieve the aging status information of a
2788 * shared AGE action, or a flow rule using the AGE action.
2790 struct rte_flow_query_age {
2791 uint32_t reserved:6; /**< Reserved, must be zero. */
2792 uint32_t aged:1; /**< 1 if aging timeout expired, 0 otherwise. */
2793 /** sec_since_last_hit value is valid. */
2794 uint32_t sec_since_last_hit_valid:1;
2795 uint32_t sec_since_last_hit:24; /**< Seconds since last traffic hit. */
2800 * @b EXPERIMENTAL: this structure may change without prior notice
2802 * RTE_FLOW_ACTION_TYPE_COUNT
2804 * Adds a counter action to a matched flow.
2806 * If more than one count action is specified in a single flow rule, then each
2807 * action must specify a unique id.
2809 * Counters can be retrieved and reset through ``rte_flow_query()``, see
2810 * ``struct rte_flow_query_count``.
2812 * For ports within the same switch domain then the counter id namespace extends
2813 * to all ports within that switch domain.
2815 struct rte_flow_action_count {
2816 uint32_t id; /**< Counter ID. */
2820 * RTE_FLOW_ACTION_TYPE_COUNT (query)
2822 * Query structure to retrieve and reset flow rule counters.
2824 struct rte_flow_query_count {
2825 uint32_t reset:1; /**< Reset counters after query [in]. */
2826 uint32_t hits_set:1; /**< hits field is set [out]. */
2827 uint32_t bytes_set:1; /**< bytes field is set [out]. */
2828 uint32_t reserved:29; /**< Reserved, must be zero [in, out]. */
2829 uint64_t hits; /**< Number of hits for this rule [out]. */
2830 uint64_t bytes; /**< Number of bytes through this rule [out]. */
2834 * Hash function types.
2836 enum rte_eth_hash_function {
2837 RTE_ETH_HASH_FUNCTION_DEFAULT = 0,
2838 RTE_ETH_HASH_FUNCTION_TOEPLITZ, /**< Toeplitz */
2839 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR, /**< Simple XOR */
2841 * Symmetric Toeplitz: src, dst will be replaced by
2842 * xor(src, dst). For the case with src/dst only,
2843 * src or dst address will xor with zero pair.
2845 RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ,
2846 RTE_ETH_HASH_FUNCTION_MAX,
2850 * RTE_FLOW_ACTION_TYPE_RSS
2852 * Similar to QUEUE, except RSS is additionally performed on packets to
2853 * spread them among several queues according to the provided parameters.
2855 * Unlike global RSS settings used by other DPDK APIs, unsetting the
2856 * @p types field does not disable RSS in a flow rule. Doing so instead
2857 * requests safe unspecified "best-effort" settings from the underlying PMD,
2858 * which depending on the flow rule, may result in anything ranging from
2859 * empty (single queue) to all-inclusive RSS.
2861 * Note: RSS hash result is stored in the hash.rss mbuf field which overlaps
2862 * hash.fdir.lo. Since the MARK action sets the hash.fdir.hi field only,
2863 * both can be requested simultaneously.
2865 struct rte_flow_action_rss {
2866 enum rte_eth_hash_function func; /**< RSS hash function to apply. */
2868 * Packet encapsulation level RSS hash @p types apply to.
2870 * - @p 0 requests the default behavior. Depending on the packet
2871 * type, it can mean outermost, innermost, anything in between or
2874 * It basically stands for the innermost encapsulation level RSS
2875 * can be performed on according to PMD and device capabilities.
2877 * - @p 1 requests RSS to be performed on the outermost packet
2878 * encapsulation level.
2880 * - @p 2 and subsequent values request RSS to be performed on the
2881 * specified inner packet encapsulation level, from outermost to
2882 * innermost (lower to higher values).
2884 * Values other than @p 0 are not necessarily supported.
2886 * Requesting a specific RSS level on unrecognized traffic results
2887 * in undefined behavior. For predictable results, it is recommended
2888 * to make the flow rule pattern match packet headers up to the
2889 * requested encapsulation level so that only matching traffic goes
2893 uint64_t types; /**< Specific RSS hash types (see ETH_RSS_*). */
2894 uint32_t key_len; /**< Hash key length in bytes. */
2895 uint32_t queue_num; /**< Number of entries in @p queue. */
2896 const uint8_t *key; /**< Hash key. */
2897 const uint16_t *queue; /**< Queue indices to use. */
2902 * @see RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR
2903 * @see RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT
2905 * RTE_FLOW_ACTION_TYPE_VF
2907 * Directs matching traffic to a given virtual function of the current
2910 * Packets matched by a VF pattern item can be redirected to their original
2911 * VF ID instead of the specified one. This parameter may not be available
2912 * and is not guaranteed to work properly if the VF part is matched by a
2913 * prior flow rule or if packets are not addressed to a VF in the first
2916 struct rte_flow_action_vf {
2917 uint32_t original:1; /**< Use original VF ID if possible. */
2918 uint32_t reserved:31; /**< Reserved, must be zero. */
2919 uint32_t id; /**< VF ID. */
2924 * @see RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR
2925 * @see RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT
2927 * RTE_FLOW_ACTION_TYPE_PHY_PORT
2929 * Directs packets to a given physical port index of the underlying
2932 * @see RTE_FLOW_ITEM_TYPE_PHY_PORT
2934 struct rte_flow_action_phy_port {
2935 uint32_t original:1; /**< Use original port index if possible. */
2936 uint32_t reserved:31; /**< Reserved, must be zero. */
2937 uint32_t index; /**< Physical port index. */
2942 * @see RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR
2943 * @see RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT
2945 * RTE_FLOW_ACTION_TYPE_PORT_ID
2947 * Directs matching traffic to a given DPDK port ID.
2949 * @see RTE_FLOW_ITEM_TYPE_PORT_ID
2951 struct rte_flow_action_port_id {
2952 uint32_t original:1; /**< Use original DPDK port ID if possible. */
2953 uint32_t reserved:31; /**< Reserved, must be zero. */
2954 uint32_t id; /**< DPDK port ID. */
2958 * RTE_FLOW_ACTION_TYPE_METER
2960 * Traffic metering and policing (MTR).
2962 * Packets matched by items of this type can be either dropped or passed to the
2963 * next item with their color set by the MTR object.
2965 struct rte_flow_action_meter {
2966 uint32_t mtr_id; /**< MTR object ID created with rte_mtr_create(). */
2970 * RTE_FLOW_ACTION_TYPE_SECURITY
2972 * Perform the security action on flows matched by the pattern items
2973 * according to the configuration of the security session.
2975 * This action modifies the payload of matched flows. For INLINE_CRYPTO, the
2976 * security protocol headers and IV are fully provided by the application as
2977 * specified in the flow pattern. The payload of matching packets is
2978 * encrypted on egress, and decrypted and authenticated on ingress.
2979 * For INLINE_PROTOCOL, the security protocol is fully offloaded to HW,
2980 * providing full encapsulation and decapsulation of packets in security
2981 * protocols. The flow pattern specifies both the outer security header fields
2982 * and the inner packet fields. The security session specified in the action
2983 * must match the pattern parameters.
2985 * The security session specified in the action must be created on the same
2986 * port as the flow action that is being specified.
2988 * The ingress/egress flow attribute should match that specified in the
2989 * security session if the security session supports the definition of the
2992 * Multiple flows can be configured to use the same security session.
2994 * The NULL value is allowed for security session. If security session is NULL,
2995 * then SPI field in ESP flow item and IP addresses in flow items 'IPv4' and
2996 * 'IPv6' will be allowed to be a range. The rule thus created can enable
2997 * security processing on multiple flows.
2999 struct rte_flow_action_security {
3000 void *security_session; /**< Pointer to security session structure. */
3004 * RTE_FLOW_ACTION_TYPE_OF_SET_MPLS_TTL
3006 * Implements OFPAT_SET_MPLS_TTL ("MPLS TTL") as defined by the OpenFlow
3007 * Switch Specification.
3009 struct rte_flow_action_of_set_mpls_ttl {
3010 uint8_t mpls_ttl; /**< MPLS TTL. */
3014 * RTE_FLOW_ACTION_TYPE_OF_SET_NW_TTL
3016 * Implements OFPAT_SET_NW_TTL ("IP TTL") as defined by the OpenFlow Switch
3019 struct rte_flow_action_of_set_nw_ttl {
3020 uint8_t nw_ttl; /**< IP TTL. */
3024 * RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN
3026 * Implements OFPAT_PUSH_VLAN ("push a new VLAN tag") as defined by the
3027 * OpenFlow Switch Specification.
3029 struct rte_flow_action_of_push_vlan {
3030 rte_be16_t ethertype; /**< EtherType. */
3034 * RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID
3036 * Implements OFPAT_SET_VLAN_VID ("set the 802.1q VLAN id") as defined by
3037 * the OpenFlow Switch Specification.
3039 struct rte_flow_action_of_set_vlan_vid {
3040 rte_be16_t vlan_vid; /**< VLAN id. */
3044 * RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP
3046 * Implements OFPAT_SET_LAN_PCP ("set the 802.1q priority") as defined by
3047 * the OpenFlow Switch Specification.
3049 struct rte_flow_action_of_set_vlan_pcp {
3050 uint8_t vlan_pcp; /**< VLAN priority. */
3054 * RTE_FLOW_ACTION_TYPE_OF_POP_MPLS
3056 * Implements OFPAT_POP_MPLS ("pop the outer MPLS tag") as defined by the
3057 * OpenFlow Switch Specification.
3059 struct rte_flow_action_of_pop_mpls {
3060 rte_be16_t ethertype; /**< EtherType. */
3064 * RTE_FLOW_ACTION_TYPE_OF_PUSH_MPLS
3066 * Implements OFPAT_PUSH_MPLS ("push a new MPLS tag") as defined by the
3067 * OpenFlow Switch Specification.
3069 struct rte_flow_action_of_push_mpls {
3070 rte_be16_t ethertype; /**< EtherType. */
3075 * @b EXPERIMENTAL: this structure may change without prior notice
3077 * RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP
3079 * VXLAN tunnel end-point encapsulation data definition
3081 * The tunnel definition is provided through the flow item pattern, the
3082 * provided pattern must conform to RFC7348 for the tunnel specified. The flow
3083 * definition must be provided in order from the RTE_FLOW_ITEM_TYPE_ETH
3084 * definition up the end item which is specified by RTE_FLOW_ITEM_TYPE_END.
3086 * The mask field allows user to specify which fields in the flow item
3087 * definitions can be ignored and which have valid data and can be used
3090 * Note: the last field is not used in the definition of a tunnel and can be
3093 * Valid flow definition for RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP include:
3095 * - ETH / IPV4 / UDP / VXLAN / END
3096 * - ETH / IPV6 / UDP / VXLAN / END
3097 * - ETH / VLAN / IPV4 / UDP / VXLAN / END
3100 struct rte_flow_action_vxlan_encap {
3102 * Encapsulating vxlan tunnel definition
3103 * (terminated by the END pattern item).
3105 struct rte_flow_item *definition;
3110 * @b EXPERIMENTAL: this structure may change without prior notice
3112 * RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP
3114 * NVGRE tunnel end-point encapsulation data definition
3116 * The tunnel definition is provided through the flow item pattern the
3117 * provided pattern must conform with RFC7637. The flow definition must be
3118 * provided in order from the RTE_FLOW_ITEM_TYPE_ETH definition up the end item
3119 * which is specified by RTE_FLOW_ITEM_TYPE_END.
3121 * The mask field allows user to specify which fields in the flow item
3122 * definitions can be ignored and which have valid data and can be used
3125 * Note: the last field is not used in the definition of a tunnel and can be
3128 * Valid flow definition for RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP include:
3130 * - ETH / IPV4 / NVGRE / END
3131 * - ETH / VLAN / IPV6 / NVGRE / END
3134 struct rte_flow_action_nvgre_encap {
3136 * Encapsulating vxlan tunnel definition
3137 * (terminated by the END pattern item).
3139 struct rte_flow_item *definition;
3144 * @b EXPERIMENTAL: this structure may change without prior notice
3146 * RTE_FLOW_ACTION_TYPE_RAW_ENCAP
3148 * Raw tunnel end-point encapsulation data definition.
3150 * The data holds the headers definitions to be applied on the packet.
3151 * The data must start with ETH header up to the tunnel item header itself.
3152 * When used right after RAW_DECAP (for decapsulating L3 tunnel type for
3153 * example MPLSoGRE) the data will just hold layer 2 header.
3155 * The preserve parameter holds which bits in the packet the PMD is not allowed
3156 * to change, this parameter can also be NULL and then the PMD is allowed
3157 * to update any field.
3159 * size holds the number of bytes in @p data and @p preserve.
3161 struct rte_flow_action_raw_encap {
3162 uint8_t *data; /**< Encapsulation data. */
3163 uint8_t *preserve; /**< Bit-mask of @p data to preserve on output. */
3164 size_t size; /**< Size of @p data and @p preserve. */
3169 * @b EXPERIMENTAL: this structure may change without prior notice
3171 * RTE_FLOW_ACTION_TYPE_RAW_DECAP
3173 * Raw tunnel end-point decapsulation data definition.
3175 * The data holds the headers definitions to be removed from the packet.
3176 * The data must start with ETH header up to the tunnel item header itself.
3177 * When used right before RAW_DECAP (for encapsulating L3 tunnel type for
3178 * example MPLSoGRE) the data will just hold layer 2 header.
3180 * size holds the number of bytes in @p data.
3182 struct rte_flow_action_raw_decap {
3183 uint8_t *data; /**< Encapsulation data. */
3184 size_t size; /**< Size of @p data and @p preserve. */
3189 * @b EXPERIMENTAL: this structure may change without prior notice
3191 * RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC
3192 * RTE_FLOW_ACTION_TYPE_SET_IPV4_DST
3194 * Allows modification of IPv4 source (RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC)
3195 * and destination address (RTE_FLOW_ACTION_TYPE_SET_IPV4_DST) in the
3196 * specified outermost IPv4 header.
3198 struct rte_flow_action_set_ipv4 {
3199 rte_be32_t ipv4_addr;
3204 * @b EXPERIMENTAL: this structure may change without prior notice
3206 * RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC
3207 * RTE_FLOW_ACTION_TYPE_SET_IPV6_DST
3209 * Allows modification of IPv6 source (RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC)
3210 * and destination address (RTE_FLOW_ACTION_TYPE_SET_IPV6_DST) in the
3211 * specified outermost IPv6 header.
3213 struct rte_flow_action_set_ipv6 {
3214 uint8_t ipv6_addr[16];
3219 * @b EXPERIMENTAL: this structure may change without prior notice
3221 * RTE_FLOW_ACTION_TYPE_SET_TP_SRC
3222 * RTE_FLOW_ACTION_TYPE_SET_TP_DST
3224 * Allows modification of source (RTE_FLOW_ACTION_TYPE_SET_TP_SRC)
3225 * and destination (RTE_FLOW_ACTION_TYPE_SET_TP_DST) port numbers
3226 * in the specified outermost TCP/UDP header.
3228 struct rte_flow_action_set_tp {
3233 * RTE_FLOW_ACTION_TYPE_SET_TTL
3235 * Set the TTL value directly for IPv4 or IPv6
3237 struct rte_flow_action_set_ttl {
3242 * RTE_FLOW_ACTION_TYPE_SET_MAC
3244 * Set MAC address from the matched flow
3246 struct rte_flow_action_set_mac {
3247 uint8_t mac_addr[RTE_ETHER_ADDR_LEN];
3252 * @b EXPERIMENTAL: this structure may change without prior notice
3254 * RTE_FLOW_ACTION_TYPE_SET_TAG
3256 * Set a tag which is a transient data used during flow matching. This is not
3257 * delivered to application. Multiple tags are supported by specifying index.
3259 struct rte_flow_action_set_tag {
3267 * @b EXPERIMENTAL: this structure may change without prior notice
3269 * RTE_FLOW_ACTION_TYPE_SET_META
3271 * Set metadata. Metadata set by mbuf metadata dynamic field with
3272 * PKT_TX_DYNF_DATA flag on egress will be overridden by this action. On
3273 * ingress, the metadata will be carried by mbuf metadata dynamic field
3274 * with PKT_RX_DYNF_METADATA flag if set. The dynamic mbuf field must be
3275 * registered in advance by rte_flow_dynf_metadata_register().
3277 * Altering partial bits is supported with mask. For bits which have never
3278 * been set, unpredictable value will be seen depending on driver
3279 * implementation. For loopback/hairpin packet, metadata set on Rx/Tx may
3280 * or may not be propagated to the other path depending on HW capability.
3282 * RTE_FLOW_ITEM_TYPE_META matches metadata.
3284 struct rte_flow_action_set_meta {
3290 * RTE_FLOW_ACTION_TYPE_SET_IPV4_DSCP
3291 * RTE_FLOW_ACTION_TYPE_SET_IPV6_DSCP
3293 * Set the DSCP value for IPv4/IPv6 header.
3294 * DSCP in low 6 bits, rest ignored.
3296 struct rte_flow_action_set_dscp {
3302 * @b EXPERIMENTAL: this structure may change without prior notice
3304 * RTE_FLOW_ACTION_TYPE_INDIRECT
3306 * Opaque type returned after successfully creating an indirect action object.
3307 * The definition of the object handle is different per driver or
3308 * per direct action type.
3310 * This handle can be used to manage and query the related direct action:
3311 * - referenced in single flow rule or across multiple flow rules
3312 * over multiple ports
3313 * - update action object configuration
3314 * - query action object data
3315 * - destroy action object
3317 struct rte_flow_action_handle;
3320 * The state of a TCP connection.
3322 enum rte_flow_conntrack_state {
3323 /** SYN-ACK packet was seen. */
3324 RTE_FLOW_CONNTRACK_STATE_SYN_RECV,
3325 /** 3-way handshake was done. */
3326 RTE_FLOW_CONNTRACK_STATE_ESTABLISHED,
3327 /** First FIN packet was received to close the connection. */
3328 RTE_FLOW_CONNTRACK_STATE_FIN_WAIT,
3329 /** First FIN was ACKed. */
3330 RTE_FLOW_CONNTRACK_STATE_CLOSE_WAIT,
3331 /** Second FIN was received, waiting for the last ACK. */
3332 RTE_FLOW_CONNTRACK_STATE_LAST_ACK,
3333 /** Second FIN was ACKed, connection was closed. */
3334 RTE_FLOW_CONNTRACK_STATE_TIME_WAIT,
3338 * The last passed TCP packet flags of a connection.
3340 enum rte_flow_conntrack_tcp_last_index {
3341 RTE_FLOW_CONNTRACK_FLAG_NONE = 0, /**< No Flag. */
3342 RTE_FLOW_CONNTRACK_FLAG_SYN = RTE_BIT32(0), /**< With SYN flag. */
3343 RTE_FLOW_CONNTRACK_FLAG_SYNACK = RTE_BIT32(1), /**< With SYNACK flag. */
3344 RTE_FLOW_CONNTRACK_FLAG_FIN = RTE_BIT32(2), /**< With FIN flag. */
3345 RTE_FLOW_CONNTRACK_FLAG_ACK = RTE_BIT32(3), /**< With ACK flag. */
3346 RTE_FLOW_CONNTRACK_FLAG_RST = RTE_BIT32(4), /**< With RST flag. */
3351 * @b EXPERIMENTAL: this structure may change without prior notice
3353 * Configuration parameters for each direction of a TCP connection.
3354 * All fields should be in host byte order.
3355 * If needed, driver should convert all fields to network byte order
3356 * if HW needs them in that way.
3358 struct rte_flow_tcp_dir_param {
3359 /** TCP window scaling factor, 0xF to disable. */
3361 /** The FIN was sent by this direction. */
3362 uint32_t close_initiated:1;
3363 /** An ACK packet has been received by this side. */
3364 uint32_t last_ack_seen:1;
3366 * If set, it indicates that there is unacknowledged data for the
3367 * packets sent from this direction.
3369 uint32_t data_unacked:1;
3371 * Maximal value of sequence + payload length in sent
3372 * packets (next ACK from the opposite direction).
3376 * Maximal value of (ACK + window size) in received packet + length
3377 * over sent packet (maximal sequence could be sent).
3380 /** Maximal value of actual window size in sent packets. */
3382 /** Maximal value of ACK in sent packets. */
3388 * @b EXPERIMENTAL: this structure may change without prior notice
3390 * RTE_FLOW_ACTION_TYPE_CONNTRACK
3392 * Configuration and initial state for the connection tracking module.
3393 * This structure could be used for both setting and query.
3394 * All fields should be in host byte order.
3396 struct rte_flow_action_conntrack {
3397 /** The peer port number, can be the same port. */
3400 * Direction of this connection when creating a flow rule, the
3401 * value only affects the creation of subsequent flow rules.
3403 uint32_t is_original_dir:1;
3405 * Enable / disable the conntrack HW module. When disabled, the
3406 * result will always be RTE_FLOW_CONNTRACK_FLAG_DISABLED.
3407 * In this state the HW will act as passthrough.
3408 * It only affects this conntrack object in the HW without any effect
3409 * to the other objects.
3412 /** At least one ack was seen after the connection was established. */
3413 uint32_t live_connection:1;
3414 /** Enable selective ACK on this connection. */
3415 uint32_t selective_ack:1;
3416 /** A challenge ack has passed. */
3417 uint32_t challenge_ack_passed:1;
3419 * 1: The last packet is seen from the original direction.
3420 * 0: The last packet is seen from the reply direction.
3422 uint32_t last_direction:1;
3423 /** No TCP check will be done except the state change. */
3424 uint32_t liberal_mode:1;
3425 /** The current state of this connection. */
3426 enum rte_flow_conntrack_state state;
3427 /** Scaling factor for maximal allowed ACK window. */
3428 uint8_t max_ack_window;
3429 /** Maximal allowed number of retransmission times. */
3430 uint8_t retransmission_limit;
3431 /** TCP parameters of the original direction. */
3432 struct rte_flow_tcp_dir_param original_dir;
3433 /** TCP parameters of the reply direction. */
3434 struct rte_flow_tcp_dir_param reply_dir;
3435 /** The window value of the last packet passed this conntrack. */
3436 uint16_t last_window;
3437 enum rte_flow_conntrack_tcp_last_index last_index;
3438 /** The sequence of the last packet passed this conntrack. */
3440 /** The acknowledgment of the last packet passed this conntrack. */
3443 * The total value ACK + payload length of the last packet
3444 * passed this conntrack.
3450 * RTE_FLOW_ACTION_TYPE_CONNTRACK
3452 * Wrapper structure for the context update interface.
3453 * Ports cannot support updating, and the only valid solution is to
3454 * destroy the old context and create a new one instead.
3456 struct rte_flow_modify_conntrack {
3457 /** New connection tracking parameters to be updated. */
3458 struct rte_flow_action_conntrack new_ct;
3459 /** The direction field will be updated. */
3460 uint32_t direction:1;
3461 /** All the other fields except direction will be updated. */
3463 /** Reserved bits for the future usage. */
3464 uint32_t reserved:30;
3469 * @b EXPERIMENTAL: this structure may change without prior notice
3471 * RTE_FLOW_ACTION_TYPE_METER_COLOR
3473 * The meter color should be set in the packet meta-data
3474 * (i.e. struct rte_mbuf::sched::color).
3476 struct rte_flow_action_meter_color {
3477 enum rte_color color; /**< Packet color. */
3482 * @b EXPERIMENTAL: this structure may change without prior notice
3484 * Provides an ethdev port ID for use with the following actions:
3485 * RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR,
3486 * RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT.
3488 struct rte_flow_action_ethdev {
3489 uint16_t port_id; /**< ethdev port ID */
3493 * Field IDs for MODIFY_FIELD action.
3495 enum rte_flow_field_id {
3496 RTE_FLOW_FIELD_START = 0, /**< Start of a packet. */
3497 RTE_FLOW_FIELD_MAC_DST, /**< Destination MAC Address. */
3498 RTE_FLOW_FIELD_MAC_SRC, /**< Source MAC Address. */
3499 RTE_FLOW_FIELD_VLAN_TYPE, /**< 802.1Q Tag Identifier. */
3500 RTE_FLOW_FIELD_VLAN_ID, /**< 802.1Q VLAN Identifier. */
3501 RTE_FLOW_FIELD_MAC_TYPE, /**< EtherType. */
3502 RTE_FLOW_FIELD_IPV4_DSCP, /**< IPv4 DSCP. */
3503 RTE_FLOW_FIELD_IPV4_TTL, /**< IPv4 Time To Live. */
3504 RTE_FLOW_FIELD_IPV4_SRC, /**< IPv4 Source Address. */
3505 RTE_FLOW_FIELD_IPV4_DST, /**< IPv4 Destination Address. */
3506 RTE_FLOW_FIELD_IPV6_DSCP, /**< IPv6 DSCP. */
3507 RTE_FLOW_FIELD_IPV6_HOPLIMIT, /**< IPv6 Hop Limit. */
3508 RTE_FLOW_FIELD_IPV6_SRC, /**< IPv6 Source Address. */
3509 RTE_FLOW_FIELD_IPV6_DST, /**< IPv6 Destination Address. */
3510 RTE_FLOW_FIELD_TCP_PORT_SRC, /**< TCP Source Port Number. */
3511 RTE_FLOW_FIELD_TCP_PORT_DST, /**< TCP Destination Port Number. */
3512 RTE_FLOW_FIELD_TCP_SEQ_NUM, /**< TCP Sequence Number. */
3513 RTE_FLOW_FIELD_TCP_ACK_NUM, /**< TCP Acknowledgment Number. */
3514 RTE_FLOW_FIELD_TCP_FLAGS, /**< TCP Flags. */
3515 RTE_FLOW_FIELD_UDP_PORT_SRC, /**< UDP Source Port Number. */
3516 RTE_FLOW_FIELD_UDP_PORT_DST, /**< UDP Destination Port Number. */
3517 RTE_FLOW_FIELD_VXLAN_VNI, /**< VXLAN Network Identifier. */
3518 RTE_FLOW_FIELD_GENEVE_VNI, /**< GENEVE Network Identifier. */
3519 RTE_FLOW_FIELD_GTP_TEID, /**< GTP Tunnel Endpoint Identifier. */
3520 RTE_FLOW_FIELD_TAG, /**< Tag value. */
3521 RTE_FLOW_FIELD_MARK, /**< Mark value. */
3522 RTE_FLOW_FIELD_META, /**< Metadata value. */
3523 RTE_FLOW_FIELD_POINTER, /**< Memory pointer. */
3524 RTE_FLOW_FIELD_VALUE, /**< Immediate value. */
3529 * @b EXPERIMENTAL: this structure may change without prior notice
3531 * Field description for MODIFY_FIELD action.
3533 struct rte_flow_action_modify_data {
3534 enum rte_flow_field_id field; /**< Field or memory type ID. */
3538 /** Encapsulation level or tag index. */
3540 /** Number of bits to skip from a field. */
3544 * Immediate value for RTE_FLOW_FIELD_VALUE, presented in the
3545 * same byte order and length as in relevant rte_flow_item_xxx.
3546 * The immediate source bitfield offset is inherited from
3547 * the destination's one.
3551 * Memory address for RTE_FLOW_FIELD_POINTER, memory layout
3552 * should be the same as for relevant field in the
3553 * rte_flow_item_xxx structure.
3560 * Operation types for MODIFY_FIELD action.
3562 enum rte_flow_modify_op {
3563 RTE_FLOW_MODIFY_SET = 0, /**< Set a new value. */
3564 RTE_FLOW_MODIFY_ADD, /**< Add a value to a field. */
3565 RTE_FLOW_MODIFY_SUB, /**< Subtract a value from a field. */
3570 * @b EXPERIMENTAL: this structure may change without prior notice
3572 * RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
3574 * Modify a destination header field according to the specified
3575 * operation. Another field of the packet can be used as a source as well
3576 * as tag, mark, metadata, immediate value or a pointer to it.
3578 struct rte_flow_action_modify_field {
3579 enum rte_flow_modify_op operation; /**< Operation to perform. */
3580 struct rte_flow_action_modify_data dst; /**< Destination field. */
3581 struct rte_flow_action_modify_data src; /**< Source field. */
3582 uint32_t width; /**< Number of bits to use from a source field. */
3585 /* Mbuf dynamic field offset for metadata. */
3586 extern int32_t rte_flow_dynf_metadata_offs;
3588 /* Mbuf dynamic field flag mask for metadata. */
3589 extern uint64_t rte_flow_dynf_metadata_mask;
3591 /* Mbuf dynamic field pointer for metadata. */
3592 #define RTE_FLOW_DYNF_METADATA(m) \
3593 RTE_MBUF_DYNFIELD((m), rte_flow_dynf_metadata_offs, uint32_t *)
3595 /* Mbuf dynamic flags for metadata. */
3596 #define PKT_RX_DYNF_METADATA (rte_flow_dynf_metadata_mask)
3597 #define PKT_TX_DYNF_METADATA (rte_flow_dynf_metadata_mask)
3600 static inline uint32_t
3601 rte_flow_dynf_metadata_get(struct rte_mbuf *m)
3603 return *RTE_FLOW_DYNF_METADATA(m);
3608 rte_flow_dynf_metadata_set(struct rte_mbuf *m, uint32_t v)
3610 *RTE_FLOW_DYNF_METADATA(m) = v;
3614 * Definition of a single action.
3616 * A list of actions is terminated by a END action.
3618 * For simple actions without a configuration object, conf remains NULL.
3620 struct rte_flow_action {
3621 enum rte_flow_action_type type; /**< Action type. */
3622 const void *conf; /**< Pointer to action configuration object. */
3626 * Opaque type returned after successfully creating a flow.
3628 * This handle can be used to manage and query the related flow (e.g. to
3629 * destroy it or retrieve counters).
3635 * @b EXPERIMENTAL: this structure may change without prior notice
3637 * RTE_FLOW_ACTION_TYPE_SAMPLE
3639 * Adds a sample action to a matched flow.
3641 * The matching packets will be duplicated with specified ratio and applied
3642 * with own set of actions with a fate action, the sampled packet could be
3643 * redirected to queue or port. All the packets continue processing on the
3644 * default flow path.
3646 * When the sample ratio is set to 1 then the packets will be 100% mirrored.
3647 * Additional action list be supported to add for sampled or mirrored packets.
3649 struct rte_flow_action_sample {
3650 uint32_t ratio; /**< packets sampled equals to '1/ratio'. */
3651 /** sub-action list specific for the sampling hit cases. */
3652 const struct rte_flow_action *actions;
3656 * Verbose error types.
3658 * Most of them provide the type of the object referenced by struct
3659 * rte_flow_error.cause.
3661 enum rte_flow_error_type {
3662 RTE_FLOW_ERROR_TYPE_NONE, /**< No error. */
3663 RTE_FLOW_ERROR_TYPE_UNSPECIFIED, /**< Cause unspecified. */
3664 RTE_FLOW_ERROR_TYPE_HANDLE, /**< Flow rule (handle). */
3665 RTE_FLOW_ERROR_TYPE_ATTR_GROUP, /**< Group field. */
3666 RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY, /**< Priority field. */
3667 RTE_FLOW_ERROR_TYPE_ATTR_INGRESS, /**< Ingress field. */
3668 RTE_FLOW_ERROR_TYPE_ATTR_EGRESS, /**< Egress field. */
3669 RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, /**< Transfer field. */
3670 RTE_FLOW_ERROR_TYPE_ATTR, /**< Attributes structure. */
3671 RTE_FLOW_ERROR_TYPE_ITEM_NUM, /**< Pattern length. */
3672 RTE_FLOW_ERROR_TYPE_ITEM_SPEC, /**< Item specification. */
3673 RTE_FLOW_ERROR_TYPE_ITEM_LAST, /**< Item specification range. */
3674 RTE_FLOW_ERROR_TYPE_ITEM_MASK, /**< Item specification mask. */
3675 RTE_FLOW_ERROR_TYPE_ITEM, /**< Specific pattern item. */
3676 RTE_FLOW_ERROR_TYPE_ACTION_NUM, /**< Number of actions. */
3677 RTE_FLOW_ERROR_TYPE_ACTION_CONF, /**< Action configuration. */
3678 RTE_FLOW_ERROR_TYPE_ACTION, /**< Specific action. */
3682 * Verbose error structure definition.
3684 * This object is normally allocated by applications and set by PMDs, the
3685 * message points to a constant string which does not need to be freed by
3686 * the application, however its pointer can be considered valid only as long
3687 * as its associated DPDK port remains configured. Closing the underlying
3688 * device or unloading the PMD invalidates it.
3690 * Both cause and message may be NULL regardless of the error type.
3692 struct rte_flow_error {
3693 enum rte_flow_error_type type; /**< Cause field and error types. */
3694 const void *cause; /**< Object responsible for the error. */
3695 const char *message; /**< Human-readable error message. */
3699 * Complete flow rule description.
3701 * This object type is used when converting a flow rule description.
3703 * @see RTE_FLOW_CONV_OP_RULE
3704 * @see rte_flow_conv()
3707 struct rte_flow_conv_rule {
3709 const struct rte_flow_attr *attr_ro; /**< RO attributes. */
3710 struct rte_flow_attr *attr; /**< Attributes. */
3713 const struct rte_flow_item *pattern_ro; /**< RO pattern. */
3714 struct rte_flow_item *pattern; /**< Pattern items. */
3717 const struct rte_flow_action *actions_ro; /**< RO actions. */
3718 struct rte_flow_action *actions; /**< List of actions. */
3723 * Conversion operations for flow API objects.
3725 * @see rte_flow_conv()
3727 enum rte_flow_conv_op {
3729 * No operation to perform.
3731 * rte_flow_conv() simply returns 0.
3733 RTE_FLOW_CONV_OP_NONE,
3736 * Convert attributes structure.
3738 * This is a basic copy of an attributes structure.
3741 * @code const struct rte_flow_attr * @endcode
3743 * @code struct rte_flow_attr * @endcode
3745 RTE_FLOW_CONV_OP_ATTR,
3748 * Convert a single item.
3750 * Duplicates @p spec, @p last and @p mask but not outside objects.
3753 * @code const struct rte_flow_item * @endcode
3755 * @code struct rte_flow_item * @endcode
3757 RTE_FLOW_CONV_OP_ITEM,
3760 * Convert a single action.
3762 * Duplicates @p conf but not outside objects.
3765 * @code const struct rte_flow_action * @endcode
3767 * @code struct rte_flow_action * @endcode
3769 RTE_FLOW_CONV_OP_ACTION,
3772 * Convert an entire pattern.
3774 * Duplicates all pattern items at once with the same constraints as
3775 * RTE_FLOW_CONV_OP_ITEM.
3778 * @code const struct rte_flow_item * @endcode
3780 * @code struct rte_flow_item * @endcode
3782 RTE_FLOW_CONV_OP_PATTERN,
3785 * Convert a list of actions.
3787 * Duplicates the entire list of actions at once with the same
3788 * constraints as RTE_FLOW_CONV_OP_ACTION.
3791 * @code const struct rte_flow_action * @endcode
3793 * @code struct rte_flow_action * @endcode
3795 RTE_FLOW_CONV_OP_ACTIONS,
3798 * Convert a complete flow rule description.
3800 * Comprises attributes, pattern and actions together at once with
3801 * the usual constraints.
3804 * @code const struct rte_flow_conv_rule * @endcode
3806 * @code struct rte_flow_conv_rule * @endcode
3808 RTE_FLOW_CONV_OP_RULE,
3811 * Convert item type to its name string.
3813 * Writes a NUL-terminated string to @p dst. Like snprintf(), the
3814 * returned value excludes the terminator which is always written
3818 * @code (const void *)enum rte_flow_item_type @endcode
3820 * @code char * @endcode
3822 RTE_FLOW_CONV_OP_ITEM_NAME,
3825 * Convert action type to its name string.
3827 * Writes a NUL-terminated string to @p dst. Like snprintf(), the
3828 * returned value excludes the terminator which is always written
3832 * @code (const void *)enum rte_flow_action_type @endcode
3834 * @code char * @endcode
3836 RTE_FLOW_CONV_OP_ACTION_NAME,
3839 * Convert item type to pointer to item name.
3841 * Retrieves item name pointer from its type. The string itself is
3842 * not copied; instead, a unique pointer to an internal static
3843 * constant storage is written to @p dst.
3846 * @code (const void *)enum rte_flow_item_type @endcode
3848 * @code const char ** @endcode
3850 RTE_FLOW_CONV_OP_ITEM_NAME_PTR,
3853 * Convert action type to pointer to action name.
3855 * Retrieves action name pointer from its type. The string itself is
3856 * not copied; instead, a unique pointer to an internal static
3857 * constant storage is written to @p dst.
3860 * @code (const void *)enum rte_flow_action_type @endcode
3862 * @code const char ** @endcode
3864 RTE_FLOW_CONV_OP_ACTION_NAME_PTR,
3869 * @b EXPERIMENTAL: this API may change without prior notice.
3871 * Dump hardware internal representation information of
3874 * @param[in] port_id
3875 * The port identifier of the Ethernet device.
3877 * The pointer of flow rule to dump. Dump all rules if NULL.
3879 * A pointer to a file for output.
3881 * Perform verbose error reporting if not NULL. PMDs initialize this
3882 * structure in case of error only.
3884 * 0 on success, a nagative value otherwise.
3888 rte_flow_dev_dump(uint16_t port_id, struct rte_flow *flow,
3889 FILE *file, struct rte_flow_error *error);
3892 * Check if mbuf dynamic field for metadata is registered.
3895 * True if registered, false otherwise.
3899 rte_flow_dynf_metadata_avail(void)
3901 return !!rte_flow_dynf_metadata_mask;
3905 * Register mbuf dynamic field and flag for metadata.
3907 * This function must be called prior to use SET_META action in order to
3908 * register the dynamic mbuf field. Otherwise, the data cannot be delivered to
3912 * 0 on success, a negative errno value otherwise and rte_errno is set.
3916 rte_flow_dynf_metadata_register(void);
3919 * Check whether a flow rule can be created on a given port.
3921 * The flow rule is validated for correctness and whether it could be accepted
3922 * by the device given sufficient resources. The rule is checked against the
3923 * current device mode and queue configuration. The flow rule may also
3924 * optionally be validated against existing flow rules and device resources.
3925 * This function has no effect on the target device.
3927 * The returned value is guaranteed to remain valid only as long as no
3928 * successful calls to rte_flow_create() or rte_flow_destroy() are made in
3929 * the meantime and no device parameter affecting flow rules in any way are
3930 * modified, due to possible collisions or resource limitations (although in
3931 * such cases EINVAL should not be returned).
3934 * Port identifier of Ethernet device.
3936 * Flow rule attributes.
3937 * @param[in] pattern
3938 * Pattern specification (list terminated by the END pattern item).
3939 * @param[in] actions
3940 * Associated actions (list terminated by the END action).
3942 * Perform verbose error reporting if not NULL. PMDs initialize this
3943 * structure in case of error only.
3946 * 0 if flow rule is valid and can be created. A negative errno value
3947 * otherwise (rte_errno is also set), the following errors are defined:
3949 * -ENOSYS: underlying device does not support this functionality.
3951 * -EIO: underlying device is removed.
3953 * -EINVAL: unknown or invalid rule specification.
3955 * -ENOTSUP: valid but unsupported rule specification (e.g. partial
3956 * bit-masks are unsupported).
3958 * -EEXIST: collision with an existing rule. Only returned if device
3959 * supports flow rule collision checking and there was a flow rule
3960 * collision. Not receiving this return code is no guarantee that creating
3961 * the rule will not fail due to a collision.
3963 * -ENOMEM: not enough memory to execute the function, or if the device
3964 * supports resource validation, resource limitation on the device.
3966 * -EBUSY: action cannot be performed due to busy device resources, may
3967 * succeed if the affected queues or even the entire port are in a stopped
3968 * state (see rte_eth_dev_rx_queue_stop() and rte_eth_dev_stop()).
3971 rte_flow_validate(uint16_t port_id,
3972 const struct rte_flow_attr *attr,
3973 const struct rte_flow_item pattern[],
3974 const struct rte_flow_action actions[],
3975 struct rte_flow_error *error);
3978 * Create a flow rule on a given port.
3981 * Port identifier of Ethernet device.
3983 * Flow rule attributes.
3984 * @param[in] pattern
3985 * Pattern specification (list terminated by the END pattern item).
3986 * @param[in] actions
3987 * Associated actions (list terminated by the END action).
3989 * Perform verbose error reporting if not NULL. PMDs initialize this
3990 * structure in case of error only.
3993 * A valid handle in case of success, NULL otherwise and rte_errno is set
3994 * to the positive version of one of the error codes defined for
3995 * rte_flow_validate().
3998 rte_flow_create(uint16_t port_id,
3999 const struct rte_flow_attr *attr,
4000 const struct rte_flow_item pattern[],
4001 const struct rte_flow_action actions[],
4002 struct rte_flow_error *error);
4005 * Destroy a flow rule on a given port.
4007 * Failure to destroy a flow rule handle may occur when other flow rules
4008 * depend on it, and destroying it would result in an inconsistent state.
4010 * This function is only guaranteed to succeed if handles are destroyed in
4011 * reverse order of their creation.
4014 * Port identifier of Ethernet device.
4016 * Flow rule handle to destroy.
4018 * Perform verbose error reporting if not NULL. PMDs initialize this
4019 * structure in case of error only.
4022 * 0 on success, a negative errno value otherwise and rte_errno is set.
4025 rte_flow_destroy(uint16_t port_id,
4026 struct rte_flow *flow,
4027 struct rte_flow_error *error);
4030 * Destroy all flow rules associated with a port.
4032 * In the unlikely event of failure, handles are still considered destroyed
4033 * and no longer valid but the port must be assumed to be in an inconsistent
4037 * Port identifier of Ethernet device.
4039 * Perform verbose error reporting if not NULL. PMDs initialize this
4040 * structure in case of error only.
4043 * 0 on success, a negative errno value otherwise and rte_errno is set.
4046 rte_flow_flush(uint16_t port_id,
4047 struct rte_flow_error *error);
4050 * Query an existing flow rule.
4052 * This function allows retrieving flow-specific data such as counters.
4053 * Data is gathered by special actions which must be present in the flow
4056 * \see RTE_FLOW_ACTION_TYPE_COUNT
4059 * Port identifier of Ethernet device.
4061 * Flow rule handle to query.
4063 * Action definition as defined in original flow rule.
4064 * @param[in, out] data
4065 * Pointer to storage for the associated query data type.
4067 * Perform verbose error reporting if not NULL. PMDs initialize this
4068 * structure in case of error only.
4071 * 0 on success, a negative errno value otherwise and rte_errno is set.
4074 rte_flow_query(uint16_t port_id,
4075 struct rte_flow *flow,
4076 const struct rte_flow_action *action,
4078 struct rte_flow_error *error);
4081 * Restrict ingress traffic to the defined flow rules.
4083 * Isolated mode guarantees that all ingress traffic comes from defined flow
4084 * rules only (current and future).
4086 * Besides making ingress more deterministic, it allows PMDs to safely reuse
4087 * resources otherwise assigned to handle the remaining traffic, such as
4088 * global RSS configuration settings, VLAN filters, MAC address entries,
4089 * legacy filter API rules and so on in order to expand the set of possible
4092 * Calling this function as soon as possible after device initialization,
4093 * ideally before the first call to rte_eth_dev_configure(), is recommended
4094 * to avoid possible failures due to conflicting settings.
4096 * Once effective, leaving isolated mode may not be possible depending on
4097 * PMD implementation.
4099 * Additionally, the following functionality has no effect on the underlying
4100 * port and may return errors such as ENOTSUP ("not supported"):
4102 * - Toggling promiscuous mode.
4103 * - Toggling allmulticast mode.
4104 * - Configuring MAC addresses.
4105 * - Configuring multicast addresses.
4106 * - Configuring VLAN filters.
4107 * - Configuring Rx filters through the legacy API (e.g. FDIR).
4108 * - Configuring global RSS settings.
4111 * Port identifier of Ethernet device.
4113 * Nonzero to enter isolated mode, attempt to leave it otherwise.
4115 * Perform verbose error reporting if not NULL. PMDs initialize this
4116 * structure in case of error only.
4119 * 0 on success, a negative errno value otherwise and rte_errno is set.
4122 rte_flow_isolate(uint16_t port_id, int set, struct rte_flow_error *error);
4125 * Initialize flow error structure.
4128 * Pointer to flow error structure (may be NULL).
4130 * Related error code (rte_errno).
4132 * Cause field and error types.
4134 * Object responsible for the error.
4136 * Human-readable error message.
4139 * Negative error code (errno value) and rte_errno is set.
4142 rte_flow_error_set(struct rte_flow_error *error,
4144 enum rte_flow_error_type type,
4146 const char *message);
4150 * @see rte_flow_copy()
4152 struct rte_flow_desc {
4153 size_t size; /**< Allocated space including data[]. */
4154 struct rte_flow_attr attr; /**< Attributes. */
4155 struct rte_flow_item *items; /**< Items. */
4156 struct rte_flow_action *actions; /**< Actions. */
4157 uint8_t data[]; /**< Storage for items/actions. */
4162 * Copy an rte_flow rule description.
4164 * This interface is kept for compatibility with older applications but is
4165 * implemented as a wrapper to rte_flow_conv(). It is deprecated due to its
4166 * lack of flexibility and reliance on a type unusable with C++ programs
4167 * (struct rte_flow_desc).
4170 * Flow rule description.
4172 * Total size of allocated data for the flow description.
4174 * Flow rule attributes.
4176 * Pattern specification (list terminated by the END pattern item).
4177 * @param[in] actions
4178 * Associated actions (list terminated by the END action).
4181 * If len is greater or equal to the size of the flow, the total size of the
4182 * flow description and its data.
4183 * If len is lower than the size of the flow, the number of bytes that would
4184 * have been written to desc had it been sufficient. Nothing is written.
4188 rte_flow_copy(struct rte_flow_desc *fd, size_t len,
4189 const struct rte_flow_attr *attr,
4190 const struct rte_flow_item *items,
4191 const struct rte_flow_action *actions);
4194 * Flow object conversion helper.
4196 * This function performs conversion of various flow API objects to a
4197 * pre-allocated destination buffer. See enum rte_flow_conv_op for possible
4198 * operations and details about each of them.
4200 * Since destination buffer must be large enough, it works in a manner
4201 * reminiscent of snprintf():
4203 * - If @p size is 0, @p dst may be a NULL pointer, otherwise @p dst must be
4205 * - If positive, the returned value represents the number of bytes needed
4206 * to store the conversion of @p src to @p dst according to @p op
4207 * regardless of the @p size parameter.
4208 * - Since no more than @p size bytes can be written to @p dst, output is
4209 * truncated and may be inconsistent when the returned value is larger
4211 * - In case of conversion error, a negative error code is returned and
4212 * @p dst contents are unspecified.
4215 * Operation to perform, related to the object type of @p dst.
4217 * Destination buffer address. Must be suitably aligned by the caller.
4219 * Destination buffer size in bytes.
4221 * Source object to copy. Depending on @p op, its type may differ from
4224 * Perform verbose error reporting if not NULL. Initialized in case of
4228 * The number of bytes required to convert @p src to @p dst on success, a
4229 * negative errno value otherwise and rte_errno is set.
4231 * @see rte_flow_conv_op
4235 rte_flow_conv(enum rte_flow_conv_op op,
4239 struct rte_flow_error *error);
4242 * Get aged-out flows of a given port.
4244 * RTE_ETH_EVENT_FLOW_AGED event will be triggered when at least one new aged
4245 * out flow was detected after the last call to rte_flow_get_aged_flows.
4246 * This function can be called to get the aged flows usynchronously from the
4247 * event callback or synchronously regardless the event.
4248 * This is not safe to call rte_flow_get_aged_flows function with other flow
4249 * functions from multiple threads simultaneously.
4252 * Port identifier of Ethernet device.
4253 * @param[in, out] contexts
4254 * The address of an array of pointers to the aged-out flows contexts.
4255 * @param[in] nb_contexts
4256 * The length of context array pointers.
4258 * Perform verbose error reporting if not NULL. Initialized in case of
4262 * if nb_contexts is 0, return the amount of all aged contexts.
4263 * if nb_contexts is not 0 , return the amount of aged flows reported
4264 * in the context array, otherwise negative errno value.
4266 * @see rte_flow_action_age
4267 * @see RTE_ETH_EVENT_FLOW_AGED
4271 rte_flow_get_aged_flows(uint16_t port_id, void **contexts,
4272 uint32_t nb_contexts, struct rte_flow_error *error);
4275 * Specify indirect action object configuration
4277 struct rte_flow_indir_action_conf {
4279 * Flow direction for the indirect action configuration.
4281 * Action should be valid at least for one flow direction,
4282 * otherwise it is invalid for both ingress and egress rules.
4284 /** Action valid for rules applied to ingress traffic. */
4286 /** Action valid for rules applied to egress traffic. */
4289 * When set to 1, indicates that the action is valid for
4290 * transfer traffic; otherwise, for non-transfer traffic.
4292 uint32_t transfer:1;
4297 * @b EXPERIMENTAL: this API may change without prior notice.
4299 * Create an indirect action object that can be used in flow rules
4301 * The created object handle has single state and configuration
4302 * across all the flow rules using it.
4304 * @param[in] port_id
4305 * The port identifier of the Ethernet device.
4307 * Action configuration for the indirect action object creation.
4309 * Specific configuration of the indirect action object.
4311 * Perform verbose error reporting if not NULL. PMDs initialize this
4312 * structure in case of error only.
4314 * A valid handle in case of success, NULL otherwise and rte_errno is set
4315 * to one of the error codes defined:
4316 * - (ENODEV) if *port_id* invalid.
4317 * - (ENOSYS) if underlying device does not support this functionality.
4318 * - (EIO) if underlying device is removed.
4319 * - (EINVAL) if *action* invalid.
4320 * - (ENOTSUP) if *action* valid but unsupported.
4323 struct rte_flow_action_handle *
4324 rte_flow_action_handle_create(uint16_t port_id,
4325 const struct rte_flow_indir_action_conf *conf,
4326 const struct rte_flow_action *action,
4327 struct rte_flow_error *error);
4331 * @b EXPERIMENTAL: this API may change without prior notice.
4333 * Destroy indirect action by handle.
4335 * @param[in] port_id
4336 * The port identifier of the Ethernet device.
4338 * Handle for the indirect action object to be destroyed.
4340 * Perform verbose error reporting if not NULL. PMDs initialize this
4341 * structure in case of error only.
4344 * - (-ENODEV) if *port_id* invalid.
4345 * - (-ENOSYS) if underlying device does not support this functionality.
4346 * - (-EIO) if underlying device is removed.
4347 * - (-ENOENT) if action pointed by *action* handle was not found.
4348 * - (-EBUSY) if action pointed by *action* handle still used by some rules
4349 * rte_errno is also set.
4353 rte_flow_action_handle_destroy(uint16_t port_id,
4354 struct rte_flow_action_handle *handle,
4355 struct rte_flow_error *error);
4359 * @b EXPERIMENTAL: this API may change without prior notice.
4361 * Update in-place the action configuration and / or state pointed
4362 * by action *handle* with the configuration provided as *update* argument.
4363 * The update of the action configuration effects all flow rules reusing
4364 * the action via *handle*.
4365 * The update general pointer provides the ability of partial updating.
4367 * @param[in] port_id
4368 * The port identifier of the Ethernet device.
4370 * Handle for the indirect action object to be updated.
4372 * Update profile specification used to modify the action pointed by handle.
4373 * *update* could be with the same type of the immediate action corresponding
4374 * to the *handle* argument when creating, or a wrapper structure includes
4375 * action configuration to be updated and bit fields to indicate the member
4376 * of fields inside the action to update.
4378 * Perform verbose error reporting if not NULL. PMDs initialize this
4379 * structure in case of error only.
4382 * - (-ENODEV) if *port_id* invalid.
4383 * - (-ENOSYS) if underlying device does not support this functionality.
4384 * - (-EIO) if underlying device is removed.
4385 * - (-EINVAL) if *update* invalid.
4386 * - (-ENOTSUP) if *update* valid but unsupported.
4387 * - (-ENOENT) if indirect action object pointed by *handle* was not found.
4388 * rte_errno is also set.
4392 rte_flow_action_handle_update(uint16_t port_id,
4393 struct rte_flow_action_handle *handle,
4395 struct rte_flow_error *error);
4399 * @b EXPERIMENTAL: this API may change without prior notice.
4401 * Query the direct action by corresponding indirect action object handle.
4403 * Retrieve action-specific data such as counters.
4404 * Data is gathered by special action which may be present/referenced in
4405 * more than one flow rule definition.
4407 * @see RTE_FLOW_ACTION_TYPE_COUNT
4410 * Port identifier of Ethernet device.
4412 * Handle for the action object to query.
4413 * @param[in, out] data
4414 * Pointer to storage for the associated query data type.
4416 * Perform verbose error reporting if not NULL. PMDs initialize this
4417 * structure in case of error only.
4420 * 0 on success, a negative errno value otherwise and rte_errno is set.
4424 rte_flow_action_handle_query(uint16_t port_id,
4425 const struct rte_flow_action_handle *handle,
4426 void *data, struct rte_flow_error *error);
4428 /* Tunnel has a type and the key information. */
4429 struct rte_flow_tunnel {
4431 * Tunnel type, for example RTE_FLOW_ITEM_TYPE_VXLAN,
4432 * RTE_FLOW_ITEM_TYPE_NVGRE etc.
4434 enum rte_flow_item_type type;
4435 uint64_t tun_id; /**< Tunnel identification. */
4440 rte_be32_t src_addr; /**< IPv4 source address. */
4441 rte_be32_t dst_addr; /**< IPv4 destination address. */
4444 uint8_t src_addr[16]; /**< IPv6 source address. */
4445 uint8_t dst_addr[16]; /**< IPv6 destination address. */
4448 rte_be16_t tp_src; /**< Tunnel port source. */
4449 rte_be16_t tp_dst; /**< Tunnel port destination. */
4450 uint16_t tun_flags; /**< Tunnel flags. */
4452 bool is_ipv6; /**< True for valid IPv6 fields. Otherwise IPv4. */
4455 * the following members are required to restore packet
4458 uint8_t tos; /**< TOS for IPv4, TC for IPv6. */
4459 uint8_t ttl; /**< TTL for IPv4, HL for IPv6. */
4460 uint32_t label; /**< Flow Label for IPv6. */
4464 * Indicate that the packet has a tunnel.
4466 #define RTE_FLOW_RESTORE_INFO_TUNNEL RTE_BIT64(0)
4469 * Indicate that the packet has a non decapsulated tunnel header.
4471 #define RTE_FLOW_RESTORE_INFO_ENCAPSULATED RTE_BIT64(1)
4474 * Indicate that the packet has a group_id.
4476 #define RTE_FLOW_RESTORE_INFO_GROUP_ID RTE_BIT64(2)
4479 * Restore information structure to communicate the current packet processing
4480 * state when some of the processing pipeline is done in hardware and should
4481 * continue in software.
4483 struct rte_flow_restore_info {
4485 * Bitwise flags (RTE_FLOW_RESTORE_INFO_*) to indicate validation of
4486 * other fields in struct rte_flow_restore_info.
4489 uint32_t group_id; /**< Group ID where packed missed */
4490 struct rte_flow_tunnel tunnel; /**< Tunnel information. */
4494 * Allocate an array of actions to be used in rte_flow_create, to implement
4495 * tunnel-decap-set for the given tunnel.
4497 * actions vxlan_decap / tunnel-decap-set(tunnel properties) /
4498 * jump group 0 / end
4501 * Port identifier of Ethernet device.
4503 * Tunnel properties.
4504 * @param[out] actions
4505 * Array of actions to be allocated by the PMD. This array should be
4506 * concatenated with the actions array provided to rte_flow_create.
4507 * @param[out] num_of_actions
4508 * Number of actions allocated.
4510 * Perform verbose error reporting if not NULL. PMDs initialize this
4511 * structure in case of error only.
4514 * 0 on success, a negative errno value otherwise and rte_errno is set.
4518 rte_flow_tunnel_decap_set(uint16_t port_id,
4519 struct rte_flow_tunnel *tunnel,
4520 struct rte_flow_action **actions,
4521 uint32_t *num_of_actions,
4522 struct rte_flow_error *error);
4525 * Allocate an array of items to be used in rte_flow_create, to implement
4526 * tunnel-match for the given tunnel.
4528 * pattern tunnel-match(tunnel properties) / outer-header-matches /
4529 * inner-header-matches / end
4532 * Port identifier of Ethernet device.
4534 * Tunnel properties.
4536 * Array of items to be allocated by the PMD. This array should be
4537 * concatenated with the items array provided to rte_flow_create.
4538 * @param[out] num_of_items
4539 * Number of items allocated.
4541 * Perform verbose error reporting if not NULL. PMDs initialize this
4542 * structure in case of error only.
4545 * 0 on success, a negative errno value otherwise and rte_errno is set.
4549 rte_flow_tunnel_match(uint16_t port_id,
4550 struct rte_flow_tunnel *tunnel,
4551 struct rte_flow_item **items,
4552 uint32_t *num_of_items,
4553 struct rte_flow_error *error);
4556 * Populate the current packet processing state, if exists, for the given mbuf.
4558 * One should negotiate tunnel metadata delivery from the NIC to the HW.
4559 * @see rte_eth_rx_metadata_negotiate()
4560 * @see RTE_ETH_RX_METADATA_TUNNEL_ID
4563 * Port identifier of Ethernet device.
4567 * Restore information. Upon success contains the HW state.
4569 * Perform verbose error reporting if not NULL. PMDs initialize this
4570 * structure in case of error only.
4573 * 0 on success, a negative errno value otherwise and rte_errno is set.
4577 rte_flow_get_restore_info(uint16_t port_id,
4579 struct rte_flow_restore_info *info,
4580 struct rte_flow_error *error);
4583 * Release the action array as allocated by rte_flow_tunnel_decap_set.
4586 * Port identifier of Ethernet device.
4587 * @param[in] actions
4588 * Array of actions to be released.
4589 * @param[in] num_of_actions
4590 * Number of elements in actions array.
4592 * Perform verbose error reporting if not NULL. PMDs initialize this
4593 * structure in case of error only.
4596 * 0 on success, a negative errno value otherwise and rte_errno is set.
4600 rte_flow_tunnel_action_decap_release(uint16_t port_id,
4601 struct rte_flow_action *actions,
4602 uint32_t num_of_actions,
4603 struct rte_flow_error *error);
4606 * Release the item array as allocated by rte_flow_tunnel_match.
4609 * Port identifier of Ethernet device.
4611 * Array of items to be released.
4612 * @param[in] num_of_items
4613 * Number of elements in item array.
4615 * Perform verbose error reporting if not NULL. PMDs initialize this
4616 * structure in case of error only.
4619 * 0 on success, a negative errno value otherwise and rte_errno is set.
4623 rte_flow_tunnel_item_release(uint16_t port_id,
4624 struct rte_flow_item *items,
4625 uint32_t num_of_items,
4626 struct rte_flow_error *error);
4630 * @b EXPERIMENTAL: this API may change without prior notice.
4632 * Get a proxy port to manage "transfer" flows.
4634 * Managing "transfer" flows requires that the user communicate them
4635 * via a port which has the privilege to control the embedded switch.
4636 * For some vendors, all ports in a given switching domain have
4637 * this privilege. For other vendors, it's only one port.
4639 * This API indicates such a privileged port (a "proxy")
4640 * for a given port in the same switching domain.
4643 * If the PMD serving @p port_id doesn't have the corresponding method
4644 * implemented, the API will return @p port_id via @p proxy_port_id.
4647 * Indicates the port to get a "proxy" for
4648 * @param[out] proxy_port_id
4649 * Indicates the "proxy" port
4651 * If not NULL, allows the PMD to provide verbose report in case of error
4654 * 0 on success, a negative error code otherwise
4658 rte_flow_pick_transfer_proxy(uint16_t port_id, uint16_t *proxy_port_id,
4659 struct rte_flow_error *error);
4663 * @b EXPERIMENTAL: this API may change without prior notice.
4665 * Create the flex item with specified configuration over
4666 * the Ethernet device.
4669 * Port identifier of Ethernet device.
4671 * Item configuration.
4673 * Perform verbose error reporting if not NULL. PMDs initialize this
4674 * structure in case of error only.
4677 * Non-NULL opaque pointer on success, NULL otherwise and rte_errno is set.
4680 struct rte_flow_item_flex_handle *
4681 rte_flow_flex_item_create(uint16_t port_id,
4682 const struct rte_flow_item_flex_conf *conf,
4683 struct rte_flow_error *error);
4686 * Release the flex item on the specified Ethernet device.
4689 * Port identifier of Ethernet device.
4691 * Handle of the item existing on the specified device.
4693 * Perform verbose error reporting if not NULL. PMDs initialize this
4694 * structure in case of error only.
4697 * 0 on success, a negative errno value otherwise and rte_errno is set.
4701 rte_flow_flex_item_release(uint16_t port_id,
4702 const struct rte_flow_item_flex_handle *handle,
4703 struct rte_flow_error *error);
4709 #endif /* RTE_FLOW_H_ */