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 * Flow rules can apply to inbound and/or outbound traffic (ingress/egress).
72 * Several pattern items and actions are valid and can be used in both
73 * directions. Those valid for only one direction are described as such.
75 * At least one direction must be specified.
77 * Specifying both directions at once for a given rule is not recommended
78 * but may be valid in a few cases.
80 struct rte_flow_attr {
81 uint32_t group; /**< Priority group. */
82 uint32_t priority; /**< Rule priority level within group. */
83 uint32_t ingress:1; /**< Rule applies to ingress traffic. */
84 uint32_t egress:1; /**< Rule applies to egress traffic. */
86 * Instead of simply matching the properties of traffic as it would
87 * appear on a given DPDK port ID, enabling this attribute transfers
88 * a flow rule to the lowest possible level of any device endpoints
89 * found in the pattern.
91 * When supported, this effectively enables an application to
92 * re-route traffic not necessarily intended for it (e.g. coming
93 * from or addressed to different physical ports, VFs or
94 * applications) at the device level.
96 * It complements the behavior of some pattern items such as
97 * RTE_FLOW_ITEM_TYPE_PHY_PORT and is meaningless without them.
99 * When transferring flow rules, ingress and egress attributes keep
100 * their original meaning, as if processing traffic emitted or
101 * received by the application.
104 uint32_t reserved:29; /**< Reserved, must be zero. */
108 * Matching pattern item types.
110 * Pattern items fall in two categories:
112 * - Matching protocol headers and packet data, usually associated with a
113 * specification structure. These must be stacked in the same order as the
114 * protocol layers to match inside packets, starting from the lowest.
116 * - Matching meta-data or affecting pattern processing, often without a
117 * specification structure. Since they do not match packet contents, their
118 * position in the list is usually not relevant.
120 * See the description of individual types for more information. Those
121 * marked with [META] fall into the second category.
123 enum rte_flow_item_type {
127 * End marker for item lists. Prevents further processing of items,
128 * thereby ending the pattern.
130 * No associated specification structure.
132 RTE_FLOW_ITEM_TYPE_END,
137 * Used as a placeholder for convenience. It is ignored and simply
140 * No associated specification structure.
142 RTE_FLOW_ITEM_TYPE_VOID,
147 * Inverted matching, i.e. process packets that do not match the
150 * No associated specification structure.
152 RTE_FLOW_ITEM_TYPE_INVERT,
155 * Matches any protocol in place of the current layer, a single ANY
156 * may also stand for several protocol layers.
158 * See struct rte_flow_item_any.
160 RTE_FLOW_ITEM_TYPE_ANY,
165 * Matches traffic originating from (ingress) or going to (egress)
166 * the physical function of the current device.
168 * No associated specification structure.
170 RTE_FLOW_ITEM_TYPE_PF,
175 * Matches traffic originating from (ingress) or going to (egress) a
176 * given virtual function of the current device.
178 * See struct rte_flow_item_vf.
180 RTE_FLOW_ITEM_TYPE_VF,
185 * Matches traffic originating from (ingress) or going to (egress) a
186 * physical port of the underlying device.
188 * See struct rte_flow_item_phy_port.
190 RTE_FLOW_ITEM_TYPE_PHY_PORT,
195 * Matches traffic originating from (ingress) or going to (egress) a
196 * given DPDK port ID.
198 * See struct rte_flow_item_port_id.
200 RTE_FLOW_ITEM_TYPE_PORT_ID,
203 * Matches a byte string of a given length at a given offset.
205 * See struct rte_flow_item_raw.
207 RTE_FLOW_ITEM_TYPE_RAW,
210 * Matches an Ethernet header.
212 * See struct rte_flow_item_eth.
214 RTE_FLOW_ITEM_TYPE_ETH,
217 * Matches an 802.1Q/ad VLAN tag.
219 * See struct rte_flow_item_vlan.
221 RTE_FLOW_ITEM_TYPE_VLAN,
224 * Matches an IPv4 header.
226 * See struct rte_flow_item_ipv4.
228 RTE_FLOW_ITEM_TYPE_IPV4,
231 * Matches an IPv6 header.
233 * See struct rte_flow_item_ipv6.
235 RTE_FLOW_ITEM_TYPE_IPV6,
238 * Matches an ICMP header.
240 * See struct rte_flow_item_icmp.
242 RTE_FLOW_ITEM_TYPE_ICMP,
245 * Matches a UDP header.
247 * See struct rte_flow_item_udp.
249 RTE_FLOW_ITEM_TYPE_UDP,
252 * Matches a TCP header.
254 * See struct rte_flow_item_tcp.
256 RTE_FLOW_ITEM_TYPE_TCP,
259 * Matches a SCTP header.
261 * See struct rte_flow_item_sctp.
263 RTE_FLOW_ITEM_TYPE_SCTP,
266 * Matches a VXLAN header.
268 * See struct rte_flow_item_vxlan.
270 RTE_FLOW_ITEM_TYPE_VXLAN,
273 * Matches a E_TAG header.
275 * See struct rte_flow_item_e_tag.
277 RTE_FLOW_ITEM_TYPE_E_TAG,
280 * Matches a NVGRE header.
282 * See struct rte_flow_item_nvgre.
284 RTE_FLOW_ITEM_TYPE_NVGRE,
287 * Matches a MPLS header.
289 * See struct rte_flow_item_mpls.
291 RTE_FLOW_ITEM_TYPE_MPLS,
294 * Matches a GRE header.
296 * See struct rte_flow_item_gre.
298 RTE_FLOW_ITEM_TYPE_GRE,
303 * Fuzzy pattern match, expect faster than default.
305 * This is for device that support fuzzy matching option.
306 * Usually a fuzzy matching is fast but the cost is accuracy.
308 * See struct rte_flow_item_fuzzy.
310 RTE_FLOW_ITEM_TYPE_FUZZY,
313 * Matches a GTP header.
315 * Configure flow for GTP packets.
317 * See struct rte_flow_item_gtp.
319 RTE_FLOW_ITEM_TYPE_GTP,
322 * Matches a GTP header.
324 * Configure flow for GTP-C packets.
326 * See struct rte_flow_item_gtp.
328 RTE_FLOW_ITEM_TYPE_GTPC,
331 * Matches a GTP header.
333 * Configure flow for GTP-U packets.
335 * See struct rte_flow_item_gtp.
337 RTE_FLOW_ITEM_TYPE_GTPU,
340 * Matches a ESP header.
342 * See struct rte_flow_item_esp.
344 RTE_FLOW_ITEM_TYPE_ESP,
347 * Matches a GENEVE header.
349 * See struct rte_flow_item_geneve.
351 RTE_FLOW_ITEM_TYPE_GENEVE,
354 * Matches a VXLAN-GPE header.
356 * See struct rte_flow_item_vxlan_gpe.
358 RTE_FLOW_ITEM_TYPE_VXLAN_GPE,
361 * Matches an ARP header for Ethernet/IPv4.
363 * See struct rte_flow_item_arp_eth_ipv4.
365 RTE_FLOW_ITEM_TYPE_ARP_ETH_IPV4,
368 * Matches the presence of any IPv6 extension header.
370 * See struct rte_flow_item_ipv6_ext.
372 RTE_FLOW_ITEM_TYPE_IPV6_EXT,
375 * Matches any ICMPv6 header.
377 * See struct rte_flow_item_icmp6.
379 RTE_FLOW_ITEM_TYPE_ICMP6,
382 * Matches an ICMPv6 neighbor discovery solicitation.
384 * See struct rte_flow_item_icmp6_nd_ns.
386 RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS,
389 * Matches an ICMPv6 neighbor discovery advertisement.
391 * See struct rte_flow_item_icmp6_nd_na.
393 RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA,
396 * Matches the presence of any ICMPv6 neighbor discovery option.
398 * See struct rte_flow_item_icmp6_nd_opt.
400 RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT,
403 * Matches an ICMPv6 neighbor discovery source Ethernet link-layer
406 * See struct rte_flow_item_icmp6_nd_opt_sla_eth.
408 RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_SLA_ETH,
411 * Matches an ICMPv6 neighbor discovery target Ethernet link-layer
414 * See struct rte_flow_item_icmp6_nd_opt_tla_eth.
416 RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_TLA_ETH,
419 * Matches specified mark field.
421 * See struct rte_flow_item_mark.
423 RTE_FLOW_ITEM_TYPE_MARK,
428 * Matches a metadata value.
430 * See struct rte_flow_item_meta.
432 RTE_FLOW_ITEM_TYPE_META,
435 * Matches a GRE optional key field.
437 * The value should a big-endian 32bit integer.
439 * When this item present the K bit is implicitly matched as "1"
440 * in the default mask.
443 * @code rte_be32_t * @endcode
445 RTE_FLOW_ITEM_TYPE_GRE_KEY,
448 * Matches a GTP extension header: PDU session container.
450 * Configure flow for GTP packets with extension header type 0x85.
452 * See struct rte_flow_item_gtp_psc.
454 RTE_FLOW_ITEM_TYPE_GTP_PSC,
457 * Matches a PPPoE header.
459 * Configure flow for PPPoE session packets.
461 * See struct rte_flow_item_pppoe.
463 RTE_FLOW_ITEM_TYPE_PPPOES,
466 * Matches a PPPoE header.
468 * Configure flow for PPPoE discovery packets.
470 * See struct rte_flow_item_pppoe.
472 RTE_FLOW_ITEM_TYPE_PPPOED,
475 * Matches a PPPoE optional proto_id field.
477 * It only applies to PPPoE session packets.
479 * See struct rte_flow_item_pppoe_proto_id.
481 RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID,
484 * Matches Network service header (NSH).
485 * See struct rte_flow_item_nsh.
488 RTE_FLOW_ITEM_TYPE_NSH,
491 * Matches Internet Group Management Protocol (IGMP).
492 * See struct rte_flow_item_igmp.
495 RTE_FLOW_ITEM_TYPE_IGMP,
498 * Matches IP Authentication Header (AH).
499 * See struct rte_flow_item_ah.
502 RTE_FLOW_ITEM_TYPE_AH,
505 * Matches a HIGIG header.
506 * see struct rte_flow_item_higig2_hdr.
508 RTE_FLOW_ITEM_TYPE_HIGIG2,
513 * Matches a tag value.
515 * See struct rte_flow_item_tag.
517 RTE_FLOW_ITEM_TYPE_TAG,
520 * Matches a L2TPv3 over IP header.
522 * Configure flow for L2TPv3 over IP packets.
524 * See struct rte_flow_item_l2tpv3oip.
526 RTE_FLOW_ITEM_TYPE_L2TPV3OIP,
529 * Matches PFCP Header.
530 * See struct rte_flow_item_pfcp.
533 RTE_FLOW_ITEM_TYPE_PFCP,
536 * Matches eCPRI Header.
538 * Configure flow for eCPRI over ETH or UDP packets.
540 * See struct rte_flow_item_ecpri.
542 RTE_FLOW_ITEM_TYPE_ECPRI,
545 * Matches the presence of IPv6 fragment extension header.
547 * See struct rte_flow_item_ipv6_frag_ext.
549 RTE_FLOW_ITEM_TYPE_IPV6_FRAG_EXT,
552 * Matches Geneve Variable Length Option
554 * See struct rte_flow_item_geneve_opt
556 RTE_FLOW_ITEM_TYPE_GENEVE_OPT,
561 * Matches on packet integrity.
562 * For some devices application needs to enable integration checks in HW
563 * before using this item.
565 * @see struct rte_flow_item_integrity.
567 RTE_FLOW_ITEM_TYPE_INTEGRITY,
572 * Matches conntrack state.
574 * @see struct rte_flow_item_conntrack.
576 RTE_FLOW_ITEM_TYPE_CONNTRACK,
581 * Matches traffic entering the embedded switch from the given ethdev.
583 * @see struct rte_flow_item_ethdev
585 RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR,
590 * Matches traffic entering the embedded switch from
591 * the entity represented by the given ethdev.
593 * @see struct rte_flow_item_ethdev
595 RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT,
600 * RTE_FLOW_ITEM_TYPE_HIGIG2
601 * Matches higig2 header
604 struct rte_flow_item_higig2_hdr {
605 struct rte_higig2_hdr hdr;
608 /** Default mask for RTE_FLOW_ITEM_TYPE_HIGIG2. */
610 static const struct rte_flow_item_higig2_hdr rte_flow_item_higig2_hdr_mask = {
613 .classification = 0xffff,
621 * RTE_FLOW_ITEM_TYPE_ANY
623 * Matches any protocol in place of the current layer, a single ANY may also
624 * stand for several protocol layers.
626 * This is usually specified as the first pattern item when looking for a
627 * protocol anywhere in a packet.
629 * A zeroed mask stands for any number of layers.
631 struct rte_flow_item_any {
632 uint32_t num; /**< Number of layers covered. */
635 /** Default mask for RTE_FLOW_ITEM_TYPE_ANY. */
637 static const struct rte_flow_item_any rte_flow_item_any_mask = {
643 * RTE_FLOW_ITEM_TYPE_VF
645 * Matches traffic originating from (ingress) or going to (egress) a given
646 * virtual function of the current device.
648 * If supported, should work even if the virtual function is not managed by
649 * the application and thus not associated with a DPDK port ID.
651 * Note this pattern item does not match VF representors traffic which, as
652 * separate entities, should be addressed through their own DPDK port IDs.
654 * - Can be specified multiple times to match traffic addressed to several
656 * - Can be combined with a PF item to match both PF and VF traffic.
658 * A zeroed mask can be used to match any VF ID.
660 struct rte_flow_item_vf {
661 uint32_t id; /**< VF ID. */
664 /** Default mask for RTE_FLOW_ITEM_TYPE_VF. */
666 static const struct rte_flow_item_vf rte_flow_item_vf_mask = {
672 * RTE_FLOW_ITEM_TYPE_PHY_PORT
674 * Matches traffic originating from (ingress) or going to (egress) a
675 * physical port of the underlying device.
677 * The first PHY_PORT item overrides the physical port normally associated
678 * with the specified DPDK input port (port_id). This item can be provided
679 * several times to match additional physical ports.
681 * Note that physical ports are not necessarily tied to DPDK input ports
682 * (port_id) when those are not under DPDK control. Possible values are
683 * specific to each device, they are not necessarily indexed from zero and
684 * may not be contiguous.
686 * As a device property, the list of allowed values as well as the value
687 * associated with a port_id should be retrieved by other means.
689 * A zeroed mask can be used to match any port index.
691 struct rte_flow_item_phy_port {
692 uint32_t index; /**< Physical port index. */
695 /** Default mask for RTE_FLOW_ITEM_TYPE_PHY_PORT. */
697 static const struct rte_flow_item_phy_port rte_flow_item_phy_port_mask = {
703 * RTE_FLOW_ITEM_TYPE_PORT_ID
705 * Matches traffic originating from (ingress) or going to (egress) a given
708 * Normally only supported if the port ID in question is known by the
709 * underlying PMD and related to the device the flow rule is created
712 * This must not be confused with @p PHY_PORT which refers to the physical
713 * port of a device, whereas @p PORT_ID refers to a struct rte_eth_dev
714 * object on the application side (also known as "port representor"
715 * depending on the kind of underlying device).
717 struct rte_flow_item_port_id {
718 uint32_t id; /**< DPDK port ID. */
721 /** Default mask for RTE_FLOW_ITEM_TYPE_PORT_ID. */
723 static const struct rte_flow_item_port_id rte_flow_item_port_id_mask = {
729 * RTE_FLOW_ITEM_TYPE_RAW
731 * Matches a byte string of a given length at a given offset.
733 * Offset is either absolute (using the start of the packet) or relative to
734 * the end of the previous matched item in the stack, in which case negative
735 * values are allowed.
737 * If search is enabled, offset is used as the starting point. The search
738 * area can be delimited by setting limit to a nonzero value, which is the
739 * maximum number of bytes after offset where the pattern may start.
741 * Matching a zero-length pattern is allowed, doing so resets the relative
742 * offset for subsequent items.
744 * This type does not support ranges (struct rte_flow_item.last).
746 struct rte_flow_item_raw {
747 uint32_t relative:1; /**< Look for pattern after the previous item. */
748 uint32_t search:1; /**< Search pattern from offset (see also limit). */
749 uint32_t reserved:30; /**< Reserved, must be set to zero. */
750 int32_t offset; /**< Absolute or relative offset for pattern. */
751 uint16_t limit; /**< Search area limit for start of pattern. */
752 uint16_t length; /**< Pattern length. */
753 const uint8_t *pattern; /**< Byte string to look for. */
756 /** Default mask for RTE_FLOW_ITEM_TYPE_RAW. */
758 static const struct rte_flow_item_raw rte_flow_item_raw_mask = {
761 .reserved = 0x3fffffff,
762 .offset = 0xffffffff,
770 * RTE_FLOW_ITEM_TYPE_ETH
772 * Matches an Ethernet header.
774 * Inside @p hdr field, the sub-field @p ether_type stands either for EtherType
775 * or TPID, depending on whether the item is followed by a VLAN item or not. If
776 * two VLAN items follow, the sub-field refers to the outer one, which, in turn,
777 * contains the inner TPID in the similar header field. The innermost VLAN item
778 * contains a layer-3 EtherType. All of that follows the order seen on the wire.
780 * If the field in question contains a TPID value, only tagged packets with the
781 * specified TPID will match the pattern. Alternatively, it's possible to match
782 * any type of tagged packets by means of the field @p has_vlan rather than use
783 * the EtherType/TPID field. Also, it's possible to leave the two fields unused.
784 * If this is the case, both tagged and untagged packets will match the pattern.
787 struct rte_flow_item_eth {
791 * These fields are retained for compatibility.
792 * Please switch to the new header field below.
794 struct rte_ether_addr dst; /**< Destination MAC. */
795 struct rte_ether_addr src; /**< Source MAC. */
796 rte_be16_t type; /**< EtherType or TPID. */
798 struct rte_ether_hdr hdr;
800 uint32_t has_vlan:1; /**< Packet header contains at least one VLAN. */
801 uint32_t reserved:31; /**< Reserved, must be zero. */
804 /** Default mask for RTE_FLOW_ITEM_TYPE_ETH. */
806 static const struct rte_flow_item_eth rte_flow_item_eth_mask = {
807 .hdr.dst_addr.addr_bytes = "\xff\xff\xff\xff\xff\xff",
808 .hdr.src_addr.addr_bytes = "\xff\xff\xff\xff\xff\xff",
809 .hdr.ether_type = RTE_BE16(0x0000),
814 * RTE_FLOW_ITEM_TYPE_VLAN
816 * Matches an 802.1Q/ad VLAN tag.
818 * The corresponding standard outer EtherType (TPID) values are
819 * RTE_ETHER_TYPE_VLAN or RTE_ETHER_TYPE_QINQ. It can be overridden by
820 * the preceding pattern item.
821 * If a @p VLAN item is present in the pattern, then only tagged packets will
823 * The field @p has_more_vlan can be used to match any type of tagged packets,
824 * instead of using the @p eth_proto field of @p hdr.
825 * If the @p eth_proto of @p hdr and @p has_more_vlan fields are not specified,
826 * then any tagged packets will match the pattern.
829 struct rte_flow_item_vlan {
833 * These fields are retained for compatibility.
834 * Please switch to the new header field below.
836 rte_be16_t tci; /**< Tag control information. */
837 rte_be16_t inner_type; /**< Inner EtherType or TPID. */
839 struct rte_vlan_hdr hdr;
841 uint32_t has_more_vlan:1;
842 /**< Packet header contains at least one more VLAN, after this VLAN. */
843 uint32_t reserved:31; /**< Reserved, must be zero. */
846 /** Default mask for RTE_FLOW_ITEM_TYPE_VLAN. */
848 static const struct rte_flow_item_vlan rte_flow_item_vlan_mask = {
849 .hdr.vlan_tci = RTE_BE16(0x0fff),
850 .hdr.eth_proto = RTE_BE16(0x0000),
855 * RTE_FLOW_ITEM_TYPE_IPV4
857 * Matches an IPv4 header.
859 * Note: IPv4 options are handled by dedicated pattern items.
861 struct rte_flow_item_ipv4 {
862 struct rte_ipv4_hdr hdr; /**< IPv4 header definition. */
865 /** Default mask for RTE_FLOW_ITEM_TYPE_IPV4. */
867 static const struct rte_flow_item_ipv4 rte_flow_item_ipv4_mask = {
869 .src_addr = RTE_BE32(0xffffffff),
870 .dst_addr = RTE_BE32(0xffffffff),
876 * RTE_FLOW_ITEM_TYPE_IPV6.
878 * Matches an IPv6 header.
880 * Dedicated flags indicate if header contains specific extension headers.
882 struct rte_flow_item_ipv6 {
883 struct rte_ipv6_hdr hdr; /**< IPv6 header definition. */
884 uint32_t has_hop_ext:1;
885 /**< Header contains Hop-by-Hop Options extension header. */
886 uint32_t has_route_ext:1;
887 /**< Header contains Routing extension header. */
888 uint32_t has_frag_ext:1;
889 /**< Header contains Fragment extension header. */
890 uint32_t has_auth_ext:1;
891 /**< Header contains Authentication extension header. */
892 uint32_t has_esp_ext:1;
893 /**< Header contains Encapsulation Security Payload extension header. */
894 uint32_t has_dest_ext:1;
895 /**< Header contains Destination Options extension header. */
896 uint32_t has_mobil_ext:1;
897 /**< Header contains Mobility extension header. */
898 uint32_t has_hip_ext:1;
899 /**< Header contains Host Identity Protocol extension header. */
900 uint32_t has_shim6_ext:1;
901 /**< Header contains Shim6 Protocol extension header. */
902 uint32_t reserved:23;
903 /**< Reserved for future extension headers, must be zero. */
906 /** Default mask for RTE_FLOW_ITEM_TYPE_IPV6. */
908 static const struct rte_flow_item_ipv6 rte_flow_item_ipv6_mask = {
911 "\xff\xff\xff\xff\xff\xff\xff\xff"
912 "\xff\xff\xff\xff\xff\xff\xff\xff",
914 "\xff\xff\xff\xff\xff\xff\xff\xff"
915 "\xff\xff\xff\xff\xff\xff\xff\xff",
921 * RTE_FLOW_ITEM_TYPE_ICMP.
923 * Matches an ICMP header.
925 struct rte_flow_item_icmp {
926 struct rte_icmp_hdr hdr; /**< ICMP header definition. */
929 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP. */
931 static const struct rte_flow_item_icmp rte_flow_item_icmp_mask = {
940 * RTE_FLOW_ITEM_TYPE_UDP.
942 * Matches a UDP header.
944 struct rte_flow_item_udp {
945 struct rte_udp_hdr hdr; /**< UDP header definition. */
948 /** Default mask for RTE_FLOW_ITEM_TYPE_UDP. */
950 static const struct rte_flow_item_udp rte_flow_item_udp_mask = {
952 .src_port = RTE_BE16(0xffff),
953 .dst_port = RTE_BE16(0xffff),
959 * RTE_FLOW_ITEM_TYPE_TCP.
961 * Matches a TCP header.
963 struct rte_flow_item_tcp {
964 struct rte_tcp_hdr hdr; /**< TCP header definition. */
967 /** Default mask for RTE_FLOW_ITEM_TYPE_TCP. */
969 static const struct rte_flow_item_tcp rte_flow_item_tcp_mask = {
971 .src_port = RTE_BE16(0xffff),
972 .dst_port = RTE_BE16(0xffff),
978 * RTE_FLOW_ITEM_TYPE_SCTP.
980 * Matches a SCTP header.
982 struct rte_flow_item_sctp {
983 struct rte_sctp_hdr hdr; /**< SCTP header definition. */
986 /** Default mask for RTE_FLOW_ITEM_TYPE_SCTP. */
988 static const struct rte_flow_item_sctp rte_flow_item_sctp_mask = {
990 .src_port = RTE_BE16(0xffff),
991 .dst_port = RTE_BE16(0xffff),
997 * RTE_FLOW_ITEM_TYPE_VXLAN.
999 * Matches a VXLAN header (RFC 7348).
1002 struct rte_flow_item_vxlan {
1006 * These fields are retained for compatibility.
1007 * Please switch to the new header field below.
1009 uint8_t flags; /**< Normally 0x08 (I flag). */
1010 uint8_t rsvd0[3]; /**< Reserved, normally 0x000000. */
1011 uint8_t vni[3]; /**< VXLAN identifier. */
1012 uint8_t rsvd1; /**< Reserved, normally 0x00. */
1014 struct rte_vxlan_hdr hdr;
1018 /** Default mask for RTE_FLOW_ITEM_TYPE_VXLAN. */
1020 static const struct rte_flow_item_vxlan rte_flow_item_vxlan_mask = {
1021 .hdr.vx_vni = RTE_BE32(0xffffff00), /* (0xffffff << 8) */
1026 * RTE_FLOW_ITEM_TYPE_E_TAG.
1028 * Matches a E-tag header.
1030 * The corresponding standard outer EtherType (TPID) value is
1031 * RTE_ETHER_TYPE_ETAG. It can be overridden by the preceding pattern item.
1033 struct rte_flow_item_e_tag {
1035 * E-Tag control information (E-TCI).
1036 * E-PCP (3b), E-DEI (1b), ingress E-CID base (12b).
1038 rte_be16_t epcp_edei_in_ecid_b;
1039 /** Reserved (2b), GRP (2b), E-CID base (12b). */
1040 rte_be16_t rsvd_grp_ecid_b;
1041 uint8_t in_ecid_e; /**< Ingress E-CID ext. */
1042 uint8_t ecid_e; /**< E-CID ext. */
1043 rte_be16_t inner_type; /**< Inner EtherType or TPID. */
1046 /** Default mask for RTE_FLOW_ITEM_TYPE_E_TAG. */
1048 static const struct rte_flow_item_e_tag rte_flow_item_e_tag_mask = {
1049 .rsvd_grp_ecid_b = RTE_BE16(0x3fff),
1054 * RTE_FLOW_ITEM_TYPE_NVGRE.
1056 * Matches a NVGRE header.
1058 struct rte_flow_item_nvgre {
1060 * Checksum (1b), undefined (1b), key bit (1b), sequence number (1b),
1061 * reserved 0 (9b), version (3b).
1063 * c_k_s_rsvd0_ver must have value 0x2000 according to RFC 7637.
1065 rte_be16_t c_k_s_rsvd0_ver;
1066 rte_be16_t protocol; /**< Protocol type (0x6558). */
1067 uint8_t tni[3]; /**< Virtual subnet ID. */
1068 uint8_t flow_id; /**< Flow ID. */
1071 /** Default mask for RTE_FLOW_ITEM_TYPE_NVGRE. */
1073 static const struct rte_flow_item_nvgre rte_flow_item_nvgre_mask = {
1074 .tni = "\xff\xff\xff",
1079 * RTE_FLOW_ITEM_TYPE_MPLS.
1081 * Matches a MPLS header.
1083 struct rte_flow_item_mpls {
1085 * Label (20b), TC (3b), Bottom of Stack (1b).
1087 uint8_t label_tc_s[3];
1088 uint8_t ttl; /** Time-to-Live. */
1091 /** Default mask for RTE_FLOW_ITEM_TYPE_MPLS. */
1093 static const struct rte_flow_item_mpls rte_flow_item_mpls_mask = {
1094 .label_tc_s = "\xff\xff\xf0",
1099 * RTE_FLOW_ITEM_TYPE_GRE.
1101 * Matches a GRE header.
1103 struct rte_flow_item_gre {
1105 * Checksum (1b), reserved 0 (12b), version (3b).
1106 * Refer to RFC 2784.
1108 rte_be16_t c_rsvd0_ver;
1109 rte_be16_t protocol; /**< Protocol type. */
1112 /** Default mask for RTE_FLOW_ITEM_TYPE_GRE. */
1114 static const struct rte_flow_item_gre rte_flow_item_gre_mask = {
1115 .protocol = RTE_BE16(0xffff),
1120 * RTE_FLOW_ITEM_TYPE_FUZZY
1122 * Fuzzy pattern match, expect faster than default.
1124 * This is for device that support fuzzy match option.
1125 * Usually a fuzzy match is fast but the cost is accuracy.
1126 * i.e. Signature Match only match pattern's hash value, but it is
1127 * possible two different patterns have the same hash value.
1129 * Matching accuracy level can be configure by threshold.
1130 * Driver can divide the range of threshold and map to different
1131 * accuracy levels that device support.
1133 * Threshold 0 means perfect match (no fuzziness), while threshold
1134 * 0xffffffff means fuzziest match.
1136 struct rte_flow_item_fuzzy {
1137 uint32_t thresh; /**< Accuracy threshold. */
1140 /** Default mask for RTE_FLOW_ITEM_TYPE_FUZZY. */
1142 static const struct rte_flow_item_fuzzy rte_flow_item_fuzzy_mask = {
1143 .thresh = 0xffffffff,
1148 * RTE_FLOW_ITEM_TYPE_GTP.
1150 * Matches a GTPv1 header.
1152 struct rte_flow_item_gtp {
1154 * Version (3b), protocol type (1b), reserved (1b),
1155 * Extension header flag (1b),
1156 * Sequence number flag (1b),
1157 * N-PDU number flag (1b).
1159 uint8_t v_pt_rsv_flags;
1160 uint8_t msg_type; /**< Message type. */
1161 rte_be16_t msg_len; /**< Message length. */
1162 rte_be32_t teid; /**< Tunnel endpoint identifier. */
1165 /** Default mask for RTE_FLOW_ITEM_TYPE_GTP. */
1167 static const struct rte_flow_item_gtp rte_flow_item_gtp_mask = {
1168 .teid = RTE_BE32(0xffffffff),
1173 * RTE_FLOW_ITEM_TYPE_ESP
1175 * Matches an ESP header.
1177 struct rte_flow_item_esp {
1178 struct rte_esp_hdr hdr; /**< ESP header definition. */
1181 /** Default mask for RTE_FLOW_ITEM_TYPE_ESP. */
1183 static const struct rte_flow_item_esp rte_flow_item_esp_mask = {
1185 .spi = RTE_BE32(0xffffffff),
1191 * RTE_FLOW_ITEM_TYPE_GENEVE.
1193 * Matches a GENEVE header.
1195 struct rte_flow_item_geneve {
1197 * Version (2b), length of the options fields (6b), OAM packet (1b),
1198 * critical options present (1b), reserved 0 (6b).
1200 rte_be16_t ver_opt_len_o_c_rsvd0;
1201 rte_be16_t protocol; /**< Protocol type. */
1202 uint8_t vni[3]; /**< Virtual Network Identifier. */
1203 uint8_t rsvd1; /**< Reserved, normally 0x00. */
1206 /** Default mask for RTE_FLOW_ITEM_TYPE_GENEVE. */
1208 static const struct rte_flow_item_geneve rte_flow_item_geneve_mask = {
1209 .vni = "\xff\xff\xff",
1214 * RTE_FLOW_ITEM_TYPE_VXLAN_GPE (draft-ietf-nvo3-vxlan-gpe-05).
1216 * Matches a VXLAN-GPE header.
1218 struct rte_flow_item_vxlan_gpe {
1219 uint8_t flags; /**< Normally 0x0c (I and P flags). */
1220 uint8_t rsvd0[2]; /**< Reserved, normally 0x0000. */
1221 uint8_t protocol; /**< Protocol type. */
1222 uint8_t vni[3]; /**< VXLAN identifier. */
1223 uint8_t rsvd1; /**< Reserved, normally 0x00. */
1226 /** Default mask for RTE_FLOW_ITEM_TYPE_VXLAN_GPE. */
1228 static const struct rte_flow_item_vxlan_gpe rte_flow_item_vxlan_gpe_mask = {
1229 .vni = "\xff\xff\xff",
1234 * RTE_FLOW_ITEM_TYPE_ARP_ETH_IPV4
1236 * Matches an ARP header for Ethernet/IPv4.
1238 struct rte_flow_item_arp_eth_ipv4 {
1239 rte_be16_t hrd; /**< Hardware type, normally 1. */
1240 rte_be16_t pro; /**< Protocol type, normally 0x0800. */
1241 uint8_t hln; /**< Hardware address length, normally 6. */
1242 uint8_t pln; /**< Protocol address length, normally 4. */
1243 rte_be16_t op; /**< Opcode (1 for request, 2 for reply). */
1244 struct rte_ether_addr sha; /**< Sender hardware address. */
1245 rte_be32_t spa; /**< Sender IPv4 address. */
1246 struct rte_ether_addr tha; /**< Target hardware address. */
1247 rte_be32_t tpa; /**< Target IPv4 address. */
1250 /** Default mask for RTE_FLOW_ITEM_TYPE_ARP_ETH_IPV4. */
1252 static const struct rte_flow_item_arp_eth_ipv4
1253 rte_flow_item_arp_eth_ipv4_mask = {
1254 .sha.addr_bytes = "\xff\xff\xff\xff\xff\xff",
1255 .spa = RTE_BE32(0xffffffff),
1256 .tha.addr_bytes = "\xff\xff\xff\xff\xff\xff",
1257 .tpa = RTE_BE32(0xffffffff),
1262 * RTE_FLOW_ITEM_TYPE_IPV6_EXT
1264 * Matches the presence of any IPv6 extension header.
1266 * Normally preceded by any of:
1268 * - RTE_FLOW_ITEM_TYPE_IPV6
1269 * - RTE_FLOW_ITEM_TYPE_IPV6_EXT
1271 struct rte_flow_item_ipv6_ext {
1272 uint8_t next_hdr; /**< Next header. */
1275 /** Default mask for RTE_FLOW_ITEM_TYPE_IPV6_EXT. */
1278 struct rte_flow_item_ipv6_ext rte_flow_item_ipv6_ext_mask = {
1284 * RTE_FLOW_ITEM_TYPE_IPV6_FRAG_EXT
1286 * Matches the presence of IPv6 fragment extension header.
1288 * Preceded by any of:
1290 * - RTE_FLOW_ITEM_TYPE_IPV6
1291 * - RTE_FLOW_ITEM_TYPE_IPV6_EXT
1293 struct rte_flow_item_ipv6_frag_ext {
1294 struct rte_ipv6_fragment_ext hdr;
1298 * RTE_FLOW_ITEM_TYPE_ICMP6
1300 * Matches any ICMPv6 header.
1302 struct rte_flow_item_icmp6 {
1303 uint8_t type; /**< ICMPv6 type. */
1304 uint8_t code; /**< ICMPv6 code. */
1305 uint16_t checksum; /**< ICMPv6 checksum. */
1308 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6. */
1310 static const struct rte_flow_item_icmp6 rte_flow_item_icmp6_mask = {
1317 * RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS
1319 * Matches an ICMPv6 neighbor discovery solicitation.
1321 struct rte_flow_item_icmp6_nd_ns {
1322 uint8_t type; /**< ICMPv6 type, normally 135. */
1323 uint8_t code; /**< ICMPv6 code, normally 0. */
1324 rte_be16_t checksum; /**< ICMPv6 checksum. */
1325 rte_be32_t reserved; /**< Reserved, normally 0. */
1326 uint8_t target_addr[16]; /**< Target address. */
1329 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS. */
1332 struct rte_flow_item_icmp6_nd_ns rte_flow_item_icmp6_nd_ns_mask = {
1334 "\xff\xff\xff\xff\xff\xff\xff\xff"
1335 "\xff\xff\xff\xff\xff\xff\xff\xff",
1340 * RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA
1342 * Matches an ICMPv6 neighbor discovery advertisement.
1344 struct rte_flow_item_icmp6_nd_na {
1345 uint8_t type; /**< ICMPv6 type, normally 136. */
1346 uint8_t code; /**< ICMPv6 code, normally 0. */
1347 rte_be16_t checksum; /**< ICMPv6 checksum. */
1349 * Route flag (1b), solicited flag (1b), override flag (1b),
1352 rte_be32_t rso_reserved;
1353 uint8_t target_addr[16]; /**< Target address. */
1356 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA. */
1359 struct rte_flow_item_icmp6_nd_na rte_flow_item_icmp6_nd_na_mask = {
1361 "\xff\xff\xff\xff\xff\xff\xff\xff"
1362 "\xff\xff\xff\xff\xff\xff\xff\xff",
1367 * RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT
1369 * Matches the presence of any ICMPv6 neighbor discovery option.
1371 * Normally preceded by any of:
1373 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA
1374 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS
1375 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT
1377 struct rte_flow_item_icmp6_nd_opt {
1378 uint8_t type; /**< ND option type. */
1379 uint8_t length; /**< ND option length. */
1382 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT. */
1384 static const struct rte_flow_item_icmp6_nd_opt
1385 rte_flow_item_icmp6_nd_opt_mask = {
1391 * RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_SLA_ETH
1393 * Matches an ICMPv6 neighbor discovery source Ethernet link-layer address
1396 * Normally preceded by any of:
1398 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA
1399 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT
1401 struct rte_flow_item_icmp6_nd_opt_sla_eth {
1402 uint8_t type; /**< ND option type, normally 1. */
1403 uint8_t length; /**< ND option length, normally 1. */
1404 struct rte_ether_addr sla; /**< Source Ethernet LLA. */
1407 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_SLA_ETH. */
1409 static const struct rte_flow_item_icmp6_nd_opt_sla_eth
1410 rte_flow_item_icmp6_nd_opt_sla_eth_mask = {
1411 .sla.addr_bytes = "\xff\xff\xff\xff\xff\xff",
1416 * RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_TLA_ETH
1418 * Matches an ICMPv6 neighbor discovery target Ethernet link-layer address
1421 * Normally preceded by any of:
1423 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS
1424 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT
1426 struct rte_flow_item_icmp6_nd_opt_tla_eth {
1427 uint8_t type; /**< ND option type, normally 2. */
1428 uint8_t length; /**< ND option length, normally 1. */
1429 struct rte_ether_addr tla; /**< Target Ethernet LLA. */
1432 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_TLA_ETH. */
1434 static const struct rte_flow_item_icmp6_nd_opt_tla_eth
1435 rte_flow_item_icmp6_nd_opt_tla_eth_mask = {
1436 .tla.addr_bytes = "\xff\xff\xff\xff\xff\xff",
1441 * RTE_FLOW_ITEM_TYPE_META
1443 * Matches a specified metadata value. On egress, metadata can be set
1444 * either by mbuf dynamic metadata field with PKT_TX_DYNF_METADATA flag or
1445 * RTE_FLOW_ACTION_TYPE_SET_META. On ingress, RTE_FLOW_ACTION_TYPE_SET_META
1446 * sets metadata for a packet and the metadata will be reported via mbuf
1447 * metadata dynamic field with PKT_RX_DYNF_METADATA flag. The dynamic mbuf
1448 * field must be registered in advance by rte_flow_dynf_metadata_register().
1450 struct rte_flow_item_meta {
1454 /** Default mask for RTE_FLOW_ITEM_TYPE_META. */
1456 static const struct rte_flow_item_meta rte_flow_item_meta_mask = {
1462 * RTE_FLOW_ITEM_TYPE_GTP_PSC.
1464 * Matches a GTP PDU extension header with type 0x85.
1466 struct rte_flow_item_gtp_psc {
1467 struct rte_gtp_psc_generic_hdr hdr; /**< gtp psc generic hdr. */
1470 /** Default mask for RTE_FLOW_ITEM_TYPE_GTP_PSC. */
1472 static const struct rte_flow_item_gtp_psc
1473 rte_flow_item_gtp_psc_mask = {
1479 * RTE_FLOW_ITEM_TYPE_PPPOE.
1481 * Matches a PPPoE header.
1483 struct rte_flow_item_pppoe {
1485 * Version (4b), type (4b).
1487 uint8_t version_type;
1488 uint8_t code; /**< Message type. */
1489 rte_be16_t session_id; /**< Session identifier. */
1490 rte_be16_t length; /**< Payload length. */
1494 * RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID.
1496 * Matches a PPPoE optional proto_id field.
1498 * It only applies to PPPoE session packets.
1500 * Normally preceded by any of:
1502 * - RTE_FLOW_ITEM_TYPE_PPPOE
1503 * - RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID
1505 struct rte_flow_item_pppoe_proto_id {
1506 rte_be16_t proto_id; /**< PPP protocol identifier. */
1509 /** Default mask for RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID. */
1511 static const struct rte_flow_item_pppoe_proto_id
1512 rte_flow_item_pppoe_proto_id_mask = {
1513 .proto_id = RTE_BE16(0xffff),
1519 * @b EXPERIMENTAL: this structure may change without prior notice
1521 * RTE_FLOW_ITEM_TYPE_TAG
1523 * Matches a specified tag value at the specified index.
1525 struct rte_flow_item_tag {
1530 /** Default mask for RTE_FLOW_ITEM_TYPE_TAG. */
1532 static const struct rte_flow_item_tag rte_flow_item_tag_mask = {
1539 * RTE_FLOW_ITEM_TYPE_L2TPV3OIP.
1541 * Matches a L2TPv3 over IP header.
1543 struct rte_flow_item_l2tpv3oip {
1544 rte_be32_t session_id; /**< Session ID. */
1547 /** Default mask for RTE_FLOW_ITEM_TYPE_L2TPV3OIP. */
1549 static const struct rte_flow_item_l2tpv3oip rte_flow_item_l2tpv3oip_mask = {
1550 .session_id = RTE_BE32(UINT32_MAX),
1557 * @b EXPERIMENTAL: this structure may change without prior notice
1559 * RTE_FLOW_ITEM_TYPE_MARK
1561 * Matches an arbitrary integer value which was set using the ``MARK`` action
1562 * in a previously matched rule.
1564 * This item can only be specified once as a match criteria as the ``MARK``
1565 * action can only be specified once in a flow action.
1567 * This value is arbitrary and application-defined. Maximum allowed value
1568 * depends on the underlying implementation.
1570 * Depending on the underlying implementation the MARK item may be supported on
1571 * the physical device, with virtual groups in the PMD or not at all.
1573 struct rte_flow_item_mark {
1574 uint32_t id; /**< Integer value to match against. */
1577 /** Default mask for RTE_FLOW_ITEM_TYPE_MARK. */
1579 static const struct rte_flow_item_mark rte_flow_item_mark_mask = {
1586 * @b EXPERIMENTAL: this structure may change without prior notice
1588 * RTE_FLOW_ITEM_TYPE_NSH
1590 * Match network service header (NSH), RFC 8300
1593 struct rte_flow_item_nsh {
1596 uint32_t reserved:1;
1599 uint32_t reserved1:4;
1601 uint32_t next_proto:8;
1606 /** Default mask for RTE_FLOW_ITEM_TYPE_NSH. */
1608 static const struct rte_flow_item_nsh rte_flow_item_nsh_mask = {
1618 * @b EXPERIMENTAL: this structure may change without prior notice
1620 * RTE_FLOW_ITEM_TYPE_IGMP
1622 * Match Internet Group Management Protocol (IGMP), RFC 2236
1625 struct rte_flow_item_igmp {
1627 uint32_t max_resp_time:8;
1628 uint32_t checksum:16;
1629 uint32_t group_addr;
1632 /** Default mask for RTE_FLOW_ITEM_TYPE_IGMP. */
1634 static const struct rte_flow_item_igmp rte_flow_item_igmp_mask = {
1635 .group_addr = 0xffffffff,
1641 * @b EXPERIMENTAL: this structure may change without prior notice
1643 * RTE_FLOW_ITEM_TYPE_AH
1645 * Match IP Authentication Header (AH), RFC 4302
1648 struct rte_flow_item_ah {
1649 uint32_t next_hdr:8;
1650 uint32_t payload_len:8;
1651 uint32_t reserved:16;
1656 /** Default mask for RTE_FLOW_ITEM_TYPE_AH. */
1658 static const struct rte_flow_item_ah rte_flow_item_ah_mask = {
1665 * @b EXPERIMENTAL: this structure may change without prior notice
1667 * RTE_FLOW_ITEM_TYPE_PFCP
1671 struct rte_flow_item_pfcp {
1678 /** Default mask for RTE_FLOW_ITEM_TYPE_PFCP. */
1680 static const struct rte_flow_item_pfcp rte_flow_item_pfcp_mask = {
1682 .seid = RTE_BE64(UINT64_C(0xffffffffffffffff)),
1688 * @b EXPERIMENTAL: this structure may change without prior notice
1690 * RTE_FLOW_ITEM_TYPE_ECPRI
1692 * Match eCPRI Header
1694 struct rte_flow_item_ecpri {
1695 struct rte_ecpri_combined_msg_hdr hdr;
1698 /** Default mask for RTE_FLOW_ITEM_TYPE_ECPRI. */
1700 static const struct rte_flow_item_ecpri rte_flow_item_ecpri_mask = {
1710 * RTE_FLOW_ITEM_TYPE_GENEVE_OPT
1712 * Matches a GENEVE Variable Length Option
1714 struct rte_flow_item_geneve_opt {
1715 rte_be16_t option_class;
1716 uint8_t option_type;
1721 /** Default mask for RTE_FLOW_ITEM_TYPE_GENEVE_OPT. */
1723 static const struct rte_flow_item_geneve_opt
1724 rte_flow_item_geneve_opt_mask = {
1725 .option_type = 0xff,
1731 * @b EXPERIMENTAL: this structure may change without prior notice
1733 * RTE_FLOW_ITEM_TYPE_INTEGRITY
1735 * Match on packet integrity check result.
1737 struct rte_flow_item_integrity {
1738 /** Tunnel encapsulation level the item should apply to.
1739 * @see rte_flow_action_rss
1746 /** The packet is valid after passing all HW checks. */
1747 uint64_t packet_ok:1;
1748 /** L2 layer is valid after passing all HW checks. */
1750 /** L3 layer is valid after passing all HW checks. */
1752 /** L4 layer is valid after passing all HW checks. */
1754 /** L2 layer CRC is valid. */
1755 uint64_t l2_crc_ok:1;
1756 /** IPv4 layer checksum is valid. */
1757 uint64_t ipv4_csum_ok:1;
1758 /** L4 layer checksum is valid. */
1759 uint64_t l4_csum_ok:1;
1760 /** L3 length is smaller than frame length. */
1761 uint64_t l3_len_ok:1;
1762 uint64_t reserved:56;
1769 static const struct rte_flow_item_integrity
1770 rte_flow_item_integrity_mask = {
1777 * The packet is valid after conntrack checking.
1779 #define RTE_FLOW_CONNTRACK_PKT_STATE_VALID RTE_BIT32(0)
1781 * The state of the connection is changed.
1783 #define RTE_FLOW_CONNTRACK_PKT_STATE_CHANGED RTE_BIT32(1)
1785 * Error is detected on this packet for this connection and
1786 * an invalid state is set.
1788 #define RTE_FLOW_CONNTRACK_PKT_STATE_INVALID RTE_BIT32(2)
1790 * The HW connection tracking module is disabled.
1791 * It can be due to application command or an invalid state.
1793 #define RTE_FLOW_CONNTRACK_PKT_STATE_DISABLED RTE_BIT32(3)
1795 * The packet contains some bad field(s) and cannot continue
1796 * with the conntrack module checking.
1798 #define RTE_FLOW_CONNTRACK_PKT_STATE_BAD RTE_BIT32(4)
1802 * @b EXPERIMENTAL: this structure may change without prior notice
1804 * RTE_FLOW_ITEM_TYPE_CONNTRACK
1806 * Matches the state of a packet after it passed the connection tracking
1807 * examination. The state is a bitmap of one RTE_FLOW_CONNTRACK_PKT_STATE*
1808 * or a reasonable combination of these bits.
1810 struct rte_flow_item_conntrack {
1814 /** Default mask for RTE_FLOW_ITEM_TYPE_CONNTRACK. */
1816 static const struct rte_flow_item_conntrack rte_flow_item_conntrack_mask = {
1817 .flags = 0xffffffff,
1823 * @b EXPERIMENTAL: this structure may change without prior notice
1825 * Provides an ethdev port ID for use with the following items:
1826 * RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR,
1827 * RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT.
1829 struct rte_flow_item_ethdev {
1830 uint16_t port_id; /**< ethdev port ID */
1833 /** Default mask for items based on struct rte_flow_item_ethdev */
1835 static const struct rte_flow_item_ethdev rte_flow_item_ethdev_mask = {
1841 * Matching pattern item definition.
1843 * A pattern is formed by stacking items starting from the lowest protocol
1844 * layer to match. This stacking restriction does not apply to meta items
1845 * which can be placed anywhere in the stack without affecting the meaning
1846 * of the resulting pattern.
1848 * Patterns are terminated by END items.
1850 * The spec field should be a valid pointer to a structure of the related
1851 * item type. It may remain unspecified (NULL) in many cases to request
1852 * broad (nonspecific) matching. In such cases, last and mask must also be
1855 * Optionally, last can point to a structure of the same type to define an
1856 * inclusive range. This is mostly supported by integer and address fields,
1857 * may cause errors otherwise. Fields that do not support ranges must be set
1858 * to 0 or to the same value as the corresponding fields in spec.
1860 * Only the fields defined to nonzero values in the default masks (see
1861 * rte_flow_item_{name}_mask constants) are considered relevant by
1862 * default. This can be overridden by providing a mask structure of the
1863 * same type with applicable bits set to one. It can also be used to
1864 * partially filter out specific fields (e.g. as an alternate mean to match
1865 * ranges of IP addresses).
1867 * Mask is a simple bit-mask applied before interpreting the contents of
1868 * spec and last, which may yield unexpected results if not used
1869 * carefully. For example, if for an IPv4 address field, spec provides
1870 * 10.1.2.3, last provides 10.3.4.5 and mask provides 255.255.0.0, the
1871 * effective range becomes 10.1.0.0 to 10.3.255.255.
1873 struct rte_flow_item {
1874 enum rte_flow_item_type type; /**< Item type. */
1875 const void *spec; /**< Pointer to item specification structure. */
1876 const void *last; /**< Defines an inclusive range (spec to last). */
1877 const void *mask; /**< Bit-mask applied to spec and last. */
1883 * Each possible action is represented by a type.
1884 * An action can have an associated configuration object.
1885 * Several actions combined in a list can be assigned
1886 * to a flow rule and are performed in order.
1888 * They fall in three categories:
1890 * - Actions that modify the fate of matching traffic, for instance by
1891 * dropping or assigning it a specific destination.
1893 * - Actions that modify matching traffic contents or its properties. This
1894 * includes adding/removing encapsulation, encryption, compression and
1897 * - Actions related to the flow rule itself, such as updating counters or
1898 * making it non-terminating.
1900 * Flow rules being terminating by default, not specifying any action of the
1901 * fate kind results in undefined behavior. This applies to both ingress and
1904 * PASSTHRU, when supported, makes a flow rule non-terminating.
1906 enum rte_flow_action_type {
1908 * End marker for action lists. Prevents further processing of
1909 * actions, thereby ending the list.
1911 * No associated configuration structure.
1913 RTE_FLOW_ACTION_TYPE_END,
1916 * Used as a placeholder for convenience. It is ignored and simply
1917 * discarded by PMDs.
1919 * No associated configuration structure.
1921 RTE_FLOW_ACTION_TYPE_VOID,
1924 * Leaves traffic up for additional processing by subsequent flow
1925 * rules; makes a flow rule non-terminating.
1927 * No associated configuration structure.
1929 RTE_FLOW_ACTION_TYPE_PASSTHRU,
1932 * RTE_FLOW_ACTION_TYPE_JUMP
1934 * Redirects packets to a group on the current device.
1936 * See struct rte_flow_action_jump.
1938 RTE_FLOW_ACTION_TYPE_JUMP,
1941 * Attaches an integer value to packets and sets PKT_RX_FDIR and
1942 * PKT_RX_FDIR_ID mbuf flags.
1944 * See struct rte_flow_action_mark.
1946 * One should negotiate mark delivery from the NIC to the PMD.
1947 * @see rte_eth_rx_metadata_negotiate()
1948 * @see RTE_ETH_RX_METADATA_USER_MARK
1950 RTE_FLOW_ACTION_TYPE_MARK,
1953 * Flags packets. Similar to MARK without a specific value; only
1954 * sets the PKT_RX_FDIR mbuf flag.
1956 * No associated configuration structure.
1958 * One should negotiate flag delivery from the NIC to the PMD.
1959 * @see rte_eth_rx_metadata_negotiate()
1960 * @see RTE_ETH_RX_METADATA_USER_FLAG
1962 RTE_FLOW_ACTION_TYPE_FLAG,
1965 * Assigns packets to a given queue index.
1967 * See struct rte_flow_action_queue.
1969 RTE_FLOW_ACTION_TYPE_QUEUE,
1974 * PASSTHRU overrides this action if both are specified.
1976 * No associated configuration structure.
1978 RTE_FLOW_ACTION_TYPE_DROP,
1981 * Enables counters for this flow rule.
1983 * These counters can be retrieved and reset through rte_flow_query() or
1984 * rte_flow_action_handle_query() if the action provided via handle,
1985 * see struct rte_flow_query_count.
1987 * See struct rte_flow_action_count.
1989 RTE_FLOW_ACTION_TYPE_COUNT,
1992 * Similar to QUEUE, except RSS is additionally performed on packets
1993 * to spread them among several queues according to the provided
1996 * See struct rte_flow_action_rss.
1998 RTE_FLOW_ACTION_TYPE_RSS,
2001 * Directs matching traffic to the physical function (PF) of the
2004 * No associated configuration structure.
2006 RTE_FLOW_ACTION_TYPE_PF,
2009 * Directs matching traffic to a given virtual function of the
2012 * See struct rte_flow_action_vf.
2014 RTE_FLOW_ACTION_TYPE_VF,
2017 * Directs packets to a given physical port index of the underlying
2020 * See struct rte_flow_action_phy_port.
2022 RTE_FLOW_ACTION_TYPE_PHY_PORT,
2025 * Directs matching traffic to a given DPDK port ID.
2027 * See struct rte_flow_action_port_id.
2029 RTE_FLOW_ACTION_TYPE_PORT_ID,
2032 * Traffic metering and policing (MTR).
2034 * See struct rte_flow_action_meter.
2035 * See file rte_mtr.h for MTR object configuration.
2037 RTE_FLOW_ACTION_TYPE_METER,
2040 * Redirects packets to security engine of current device for security
2041 * processing as specified by security session.
2043 * See struct rte_flow_action_security.
2045 RTE_FLOW_ACTION_TYPE_SECURITY,
2048 * Implements OFPAT_SET_MPLS_TTL ("MPLS TTL") as defined by the
2049 * OpenFlow Switch Specification.
2051 * See struct rte_flow_action_of_set_mpls_ttl.
2053 RTE_FLOW_ACTION_TYPE_OF_SET_MPLS_TTL,
2056 * Implements OFPAT_DEC_MPLS_TTL ("decrement MPLS TTL") as defined
2057 * by the OpenFlow Switch Specification.
2059 * No associated configuration structure.
2061 RTE_FLOW_ACTION_TYPE_OF_DEC_MPLS_TTL,
2064 * Implements OFPAT_SET_NW_TTL ("IP TTL") as defined by the OpenFlow
2065 * Switch Specification.
2067 * See struct rte_flow_action_of_set_nw_ttl.
2069 RTE_FLOW_ACTION_TYPE_OF_SET_NW_TTL,
2072 * Implements OFPAT_DEC_NW_TTL ("decrement IP TTL") as defined by
2073 * the OpenFlow Switch Specification.
2075 * No associated configuration structure.
2077 RTE_FLOW_ACTION_TYPE_OF_DEC_NW_TTL,
2080 * Implements OFPAT_COPY_TTL_OUT ("copy TTL "outwards" -- from
2081 * next-to-outermost to outermost") as defined by the OpenFlow
2082 * Switch Specification.
2084 * No associated configuration structure.
2086 RTE_FLOW_ACTION_TYPE_OF_COPY_TTL_OUT,
2089 * Implements OFPAT_COPY_TTL_IN ("copy TTL "inwards" -- from
2090 * outermost to next-to-outermost") as defined by the OpenFlow
2091 * Switch Specification.
2093 * No associated configuration structure.
2095 RTE_FLOW_ACTION_TYPE_OF_COPY_TTL_IN,
2098 * Implements OFPAT_POP_VLAN ("pop the outer VLAN tag") as defined
2099 * by the OpenFlow Switch Specification.
2101 * No associated configuration structure.
2103 RTE_FLOW_ACTION_TYPE_OF_POP_VLAN,
2106 * Implements OFPAT_PUSH_VLAN ("push a new VLAN tag") as defined by
2107 * the OpenFlow Switch Specification.
2109 * See struct rte_flow_action_of_push_vlan.
2111 RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN,
2114 * Implements OFPAT_SET_VLAN_VID ("set the 802.1q VLAN id") as
2115 * defined by the OpenFlow Switch Specification.
2117 * See struct rte_flow_action_of_set_vlan_vid.
2119 RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID,
2122 * Implements OFPAT_SET_LAN_PCP ("set the 802.1q priority") as
2123 * defined by the OpenFlow Switch Specification.
2125 * See struct rte_flow_action_of_set_vlan_pcp.
2127 RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP,
2130 * Implements OFPAT_POP_MPLS ("pop the outer MPLS tag") as defined
2131 * by the OpenFlow Switch Specification.
2133 * See struct rte_flow_action_of_pop_mpls.
2135 RTE_FLOW_ACTION_TYPE_OF_POP_MPLS,
2138 * Implements OFPAT_PUSH_MPLS ("push a new MPLS tag") as defined by
2139 * the OpenFlow Switch Specification.
2141 * See struct rte_flow_action_of_push_mpls.
2143 RTE_FLOW_ACTION_TYPE_OF_PUSH_MPLS,
2146 * Encapsulate flow in VXLAN tunnel as defined in
2147 * rte_flow_action_vxlan_encap action structure.
2149 * See struct rte_flow_action_vxlan_encap.
2151 RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP,
2154 * Decapsulate outer most VXLAN tunnel from matched flow.
2156 * If flow pattern does not define a valid VXLAN tunnel (as specified by
2157 * RFC7348) then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION
2160 RTE_FLOW_ACTION_TYPE_VXLAN_DECAP,
2163 * Encapsulate flow in NVGRE tunnel defined in the
2164 * rte_flow_action_nvgre_encap action structure.
2166 * See struct rte_flow_action_nvgre_encap.
2168 RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP,
2171 * Decapsulate outer most NVGRE tunnel from matched flow.
2173 * If flow pattern does not define a valid NVGRE tunnel (as specified by
2174 * RFC7637) then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION
2177 RTE_FLOW_ACTION_TYPE_NVGRE_DECAP,
2180 * Add outer header whose template is provided in its data buffer
2182 * See struct rte_flow_action_raw_encap.
2184 RTE_FLOW_ACTION_TYPE_RAW_ENCAP,
2187 * Remove outer header whose template is provided in its data buffer.
2189 * See struct rte_flow_action_raw_decap
2191 RTE_FLOW_ACTION_TYPE_RAW_DECAP,
2194 * Modify IPv4 source address in the outermost IPv4 header.
2196 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV4,
2197 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2199 * See struct rte_flow_action_set_ipv4.
2201 RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC,
2204 * Modify IPv4 destination address in the outermost IPv4 header.
2206 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV4,
2207 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2209 * See struct rte_flow_action_set_ipv4.
2211 RTE_FLOW_ACTION_TYPE_SET_IPV4_DST,
2214 * Modify IPv6 source address in the outermost IPv6 header.
2216 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV6,
2217 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2219 * See struct rte_flow_action_set_ipv6.
2221 RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC,
2224 * Modify IPv6 destination address in the outermost IPv6 header.
2226 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV6,
2227 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2229 * See struct rte_flow_action_set_ipv6.
2231 RTE_FLOW_ACTION_TYPE_SET_IPV6_DST,
2234 * Modify source port number in the outermost TCP/UDP header.
2236 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_TCP
2237 * or RTE_FLOW_ITEM_TYPE_UDP, then the PMD should return a
2238 * RTE_FLOW_ERROR_TYPE_ACTION error.
2240 * See struct rte_flow_action_set_tp.
2242 RTE_FLOW_ACTION_TYPE_SET_TP_SRC,
2245 * Modify destination port number in the outermost TCP/UDP header.
2247 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_TCP
2248 * or RTE_FLOW_ITEM_TYPE_UDP, then the PMD should return a
2249 * RTE_FLOW_ERROR_TYPE_ACTION error.
2251 * See struct rte_flow_action_set_tp.
2253 RTE_FLOW_ACTION_TYPE_SET_TP_DST,
2256 * Swap the source and destination MAC addresses in the outermost
2259 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_ETH,
2260 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2262 * No associated configuration structure.
2264 RTE_FLOW_ACTION_TYPE_MAC_SWAP,
2267 * Decrease TTL value directly
2269 * No associated configuration structure.
2271 RTE_FLOW_ACTION_TYPE_DEC_TTL,
2276 * See struct rte_flow_action_set_ttl
2278 RTE_FLOW_ACTION_TYPE_SET_TTL,
2281 * Set source MAC address from matched flow.
2283 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_ETH,
2284 * the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2286 * See struct rte_flow_action_set_mac.
2288 RTE_FLOW_ACTION_TYPE_SET_MAC_SRC,
2291 * Set destination MAC address from matched flow.
2293 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_ETH,
2294 * the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2296 * See struct rte_flow_action_set_mac.
2298 RTE_FLOW_ACTION_TYPE_SET_MAC_DST,
2301 * Increase sequence number in the outermost TCP header.
2303 * Action configuration specifies the value to increase
2304 * TCP sequence number as a big-endian 32 bit integer.
2307 * @code rte_be32_t * @endcode
2309 * Using this action on non-matching traffic will result in
2310 * undefined behavior.
2312 RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ,
2315 * Decrease sequence number in the outermost TCP header.
2317 * Action configuration specifies the value to decrease
2318 * TCP sequence number as a big-endian 32 bit integer.
2321 * @code rte_be32_t * @endcode
2323 * Using this action on non-matching traffic will result in
2324 * undefined behavior.
2326 RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ,
2329 * Increase acknowledgment number in the outermost TCP header.
2331 * Action configuration specifies the value to increase
2332 * TCP acknowledgment number as a big-endian 32 bit integer.
2335 * @code rte_be32_t * @endcode
2337 * Using this action on non-matching traffic will result in
2338 * undefined behavior.
2340 RTE_FLOW_ACTION_TYPE_INC_TCP_ACK,
2343 * Decrease acknowledgment number in the outermost TCP header.
2345 * Action configuration specifies the value to decrease
2346 * TCP acknowledgment number as a big-endian 32 bit integer.
2349 * @code rte_be32_t * @endcode
2351 * Using this action on non-matching traffic will result in
2352 * undefined behavior.
2354 RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK,
2359 * Tag is for internal flow usage only and
2360 * is not delivered to the application.
2362 * See struct rte_flow_action_set_tag.
2364 RTE_FLOW_ACTION_TYPE_SET_TAG,
2367 * Set metadata on ingress or egress path.
2369 * See struct rte_flow_action_set_meta.
2371 RTE_FLOW_ACTION_TYPE_SET_META,
2374 * Modify IPv4 DSCP in the outermost IP header.
2376 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV4,
2377 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2379 * See struct rte_flow_action_set_dscp.
2381 RTE_FLOW_ACTION_TYPE_SET_IPV4_DSCP,
2384 * Modify IPv6 DSCP in the outermost IP header.
2386 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV6,
2387 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2389 * See struct rte_flow_action_set_dscp.
2391 RTE_FLOW_ACTION_TYPE_SET_IPV6_DSCP,
2394 * Report as aged flow if timeout passed without any matching on the
2397 * See struct rte_flow_action_age.
2398 * See function rte_flow_get_aged_flows
2399 * see enum RTE_ETH_EVENT_FLOW_AGED
2400 * See struct rte_flow_query_age
2402 RTE_FLOW_ACTION_TYPE_AGE,
2405 * The matching packets will be duplicated with specified ratio and
2406 * applied with own set of actions with a fate action.
2408 * See struct rte_flow_action_sample.
2410 RTE_FLOW_ACTION_TYPE_SAMPLE,
2414 * @see RTE_FLOW_ACTION_TYPE_INDIRECT
2416 * Describe action shared across multiple flow rules.
2418 * Allow multiple rules reference the same action by handle (see
2419 * struct rte_flow_shared_action).
2421 RTE_FLOW_ACTION_TYPE_SHARED,
2424 * Modify a packet header field, tag, mark or metadata.
2426 * Allow the modification of an arbitrary header field via
2427 * set, add and sub operations or copying its content into
2428 * tag, meta or mark for future processing.
2430 * See struct rte_flow_action_modify_field.
2432 RTE_FLOW_ACTION_TYPE_MODIFY_FIELD,
2435 * An action handle is referenced in a rule through an indirect action.
2437 * The same action handle may be used in multiple rules for the same
2438 * or different ethdev ports.
2440 RTE_FLOW_ACTION_TYPE_INDIRECT,
2445 * Enable tracking a TCP connection state.
2447 * @see struct rte_flow_action_conntrack.
2449 RTE_FLOW_ACTION_TYPE_CONNTRACK,
2452 * Color the packet to reflect the meter color result.
2453 * Set the meter color in the mbuf to the selected color.
2455 * See struct rte_flow_action_meter_color.
2457 RTE_FLOW_ACTION_TYPE_METER_COLOR,
2460 * At embedded switch level, sends matching traffic to the given ethdev.
2462 * @see struct rte_flow_action_ethdev
2464 RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR,
2467 * At embedded switch level, send matching traffic to
2468 * the entity represented by the given ethdev.
2470 * @see struct rte_flow_action_ethdev
2472 RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT,
2476 * RTE_FLOW_ACTION_TYPE_MARK
2478 * Attaches an integer value to packets and sets PKT_RX_FDIR and
2479 * PKT_RX_FDIR_ID mbuf flags.
2481 * This value is arbitrary and application-defined. Maximum allowed value
2482 * depends on the underlying implementation. It is returned in the
2483 * hash.fdir.hi mbuf field.
2485 struct rte_flow_action_mark {
2486 uint32_t id; /**< Integer value to return with packets. */
2491 * @b EXPERIMENTAL: this structure may change without prior notice
2493 * RTE_FLOW_ACTION_TYPE_JUMP
2495 * Redirects packets to a group on the current device.
2497 * In a hierarchy of groups, which can be used to represent physical or logical
2498 * flow tables on the device, this action allows the action to be a redirect to
2499 * a group on that device.
2501 struct rte_flow_action_jump {
2506 * RTE_FLOW_ACTION_TYPE_QUEUE
2508 * Assign packets to a given queue index.
2510 struct rte_flow_action_queue {
2511 uint16_t index; /**< Queue index to use. */
2516 * @b EXPERIMENTAL: this structure may change without prior notice
2518 * RTE_FLOW_ACTION_TYPE_AGE
2520 * Report flow as aged-out if timeout passed without any matching
2521 * on the flow. RTE_ETH_EVENT_FLOW_AGED event is triggered when a
2522 * port detects new aged-out flows.
2524 * The flow context and the flow handle will be reported by the
2525 * rte_flow_get_aged_flows API.
2527 struct rte_flow_action_age {
2528 uint32_t timeout:24; /**< Time in seconds. */
2529 uint32_t reserved:8; /**< Reserved, must be zero. */
2531 /**< The user flow context, NULL means the rte_flow pointer. */
2535 * RTE_FLOW_ACTION_TYPE_AGE (query)
2537 * Query structure to retrieve the aging status information of a
2538 * shared AGE action, or a flow rule using the AGE action.
2540 struct rte_flow_query_age {
2541 uint32_t reserved:6; /**< Reserved, must be zero. */
2542 uint32_t aged:1; /**< 1 if aging timeout expired, 0 otherwise. */
2543 uint32_t sec_since_last_hit_valid:1;
2544 /**< sec_since_last_hit value is valid. */
2545 uint32_t sec_since_last_hit:24; /**< Seconds since last traffic hit. */
2550 * @b EXPERIMENTAL: this structure may change without prior notice
2552 * RTE_FLOW_ACTION_TYPE_COUNT
2554 * Adds a counter action to a matched flow.
2556 * If more than one count action is specified in a single flow rule, then each
2557 * action must specify a unique id.
2559 * Counters can be retrieved and reset through ``rte_flow_query()``, see
2560 * ``struct rte_flow_query_count``.
2562 * For ports within the same switch domain then the counter id namespace extends
2563 * to all ports within that switch domain.
2565 struct rte_flow_action_count {
2566 uint32_t id; /**< Counter ID. */
2570 * RTE_FLOW_ACTION_TYPE_COUNT (query)
2572 * Query structure to retrieve and reset flow rule counters.
2574 struct rte_flow_query_count {
2575 uint32_t reset:1; /**< Reset counters after query [in]. */
2576 uint32_t hits_set:1; /**< hits field is set [out]. */
2577 uint32_t bytes_set:1; /**< bytes field is set [out]. */
2578 uint32_t reserved:29; /**< Reserved, must be zero [in, out]. */
2579 uint64_t hits; /**< Number of hits for this rule [out]. */
2580 uint64_t bytes; /**< Number of bytes through this rule [out]. */
2584 * Hash function types.
2586 enum rte_eth_hash_function {
2587 RTE_ETH_HASH_FUNCTION_DEFAULT = 0,
2588 RTE_ETH_HASH_FUNCTION_TOEPLITZ, /**< Toeplitz */
2589 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR, /**< Simple XOR */
2591 * Symmetric Toeplitz: src, dst will be replaced by
2592 * xor(src, dst). For the case with src/dst only,
2593 * src or dst address will xor with zero pair.
2595 RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ,
2596 RTE_ETH_HASH_FUNCTION_MAX,
2600 * RTE_FLOW_ACTION_TYPE_RSS
2602 * Similar to QUEUE, except RSS is additionally performed on packets to
2603 * spread them among several queues according to the provided parameters.
2605 * Unlike global RSS settings used by other DPDK APIs, unsetting the
2606 * @p types field does not disable RSS in a flow rule. Doing so instead
2607 * requests safe unspecified "best-effort" settings from the underlying PMD,
2608 * which depending on the flow rule, may result in anything ranging from
2609 * empty (single queue) to all-inclusive RSS.
2611 * Note: RSS hash result is stored in the hash.rss mbuf field which overlaps
2612 * hash.fdir.lo. Since the MARK action sets the hash.fdir.hi field only,
2613 * both can be requested simultaneously.
2615 struct rte_flow_action_rss {
2616 enum rte_eth_hash_function func; /**< RSS hash function to apply. */
2618 * Packet encapsulation level RSS hash @p types apply to.
2620 * - @p 0 requests the default behavior. Depending on the packet
2621 * type, it can mean outermost, innermost, anything in between or
2624 * It basically stands for the innermost encapsulation level RSS
2625 * can be performed on according to PMD and device capabilities.
2627 * - @p 1 requests RSS to be performed on the outermost packet
2628 * encapsulation level.
2630 * - @p 2 and subsequent values request RSS to be performed on the
2631 * specified inner packet encapsulation level, from outermost to
2632 * innermost (lower to higher values).
2634 * Values other than @p 0 are not necessarily supported.
2636 * Requesting a specific RSS level on unrecognized traffic results
2637 * in undefined behavior. For predictable results, it is recommended
2638 * to make the flow rule pattern match packet headers up to the
2639 * requested encapsulation level so that only matching traffic goes
2643 uint64_t types; /**< Specific RSS hash types (see ETH_RSS_*). */
2644 uint32_t key_len; /**< Hash key length in bytes. */
2645 uint32_t queue_num; /**< Number of entries in @p queue. */
2646 const uint8_t *key; /**< Hash key. */
2647 const uint16_t *queue; /**< Queue indices to use. */
2651 * RTE_FLOW_ACTION_TYPE_VF
2653 * Directs matching traffic to a given virtual function of the current
2656 * Packets matched by a VF pattern item can be redirected to their original
2657 * VF ID instead of the specified one. This parameter may not be available
2658 * and is not guaranteed to work properly if the VF part is matched by a
2659 * prior flow rule or if packets are not addressed to a VF in the first
2662 struct rte_flow_action_vf {
2663 uint32_t original:1; /**< Use original VF ID if possible. */
2664 uint32_t reserved:31; /**< Reserved, must be zero. */
2665 uint32_t id; /**< VF ID. */
2669 * RTE_FLOW_ACTION_TYPE_PHY_PORT
2671 * Directs packets to a given physical port index of the underlying
2674 * @see RTE_FLOW_ITEM_TYPE_PHY_PORT
2676 struct rte_flow_action_phy_port {
2677 uint32_t original:1; /**< Use original port index if possible. */
2678 uint32_t reserved:31; /**< Reserved, must be zero. */
2679 uint32_t index; /**< Physical port index. */
2683 * RTE_FLOW_ACTION_TYPE_PORT_ID
2685 * Directs matching traffic to a given DPDK port ID.
2687 * @see RTE_FLOW_ITEM_TYPE_PORT_ID
2689 struct rte_flow_action_port_id {
2690 uint32_t original:1; /**< Use original DPDK port ID if possible. */
2691 uint32_t reserved:31; /**< Reserved, must be zero. */
2692 uint32_t id; /**< DPDK port ID. */
2696 * RTE_FLOW_ACTION_TYPE_METER
2698 * Traffic metering and policing (MTR).
2700 * Packets matched by items of this type can be either dropped or passed to the
2701 * next item with their color set by the MTR object.
2703 struct rte_flow_action_meter {
2704 uint32_t mtr_id; /**< MTR object ID created with rte_mtr_create(). */
2708 * RTE_FLOW_ACTION_TYPE_SECURITY
2710 * Perform the security action on flows matched by the pattern items
2711 * according to the configuration of the security session.
2713 * This action modifies the payload of matched flows. For INLINE_CRYPTO, the
2714 * security protocol headers and IV are fully provided by the application as
2715 * specified in the flow pattern. The payload of matching packets is
2716 * encrypted on egress, and decrypted and authenticated on ingress.
2717 * For INLINE_PROTOCOL, the security protocol is fully offloaded to HW,
2718 * providing full encapsulation and decapsulation of packets in security
2719 * protocols. The flow pattern specifies both the outer security header fields
2720 * and the inner packet fields. The security session specified in the action
2721 * must match the pattern parameters.
2723 * The security session specified in the action must be created on the same
2724 * port as the flow action that is being specified.
2726 * The ingress/egress flow attribute should match that specified in the
2727 * security session if the security session supports the definition of the
2730 * Multiple flows can be configured to use the same security session.
2732 * The NULL value is allowed for security session. If security session is NULL,
2733 * then SPI field in ESP flow item and IP addresses in flow items 'IPv4' and
2734 * 'IPv6' will be allowed to be a range. The rule thus created can enable
2735 * security processing on multiple flows.
2737 struct rte_flow_action_security {
2738 void *security_session; /**< Pointer to security session structure. */
2742 * RTE_FLOW_ACTION_TYPE_OF_SET_MPLS_TTL
2744 * Implements OFPAT_SET_MPLS_TTL ("MPLS TTL") as defined by the OpenFlow
2745 * Switch Specification.
2747 struct rte_flow_action_of_set_mpls_ttl {
2748 uint8_t mpls_ttl; /**< MPLS TTL. */
2752 * RTE_FLOW_ACTION_TYPE_OF_SET_NW_TTL
2754 * Implements OFPAT_SET_NW_TTL ("IP TTL") as defined by the OpenFlow Switch
2757 struct rte_flow_action_of_set_nw_ttl {
2758 uint8_t nw_ttl; /**< IP TTL. */
2762 * RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN
2764 * Implements OFPAT_PUSH_VLAN ("push a new VLAN tag") as defined by the
2765 * OpenFlow Switch Specification.
2767 struct rte_flow_action_of_push_vlan {
2768 rte_be16_t ethertype; /**< EtherType. */
2772 * RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID
2774 * Implements OFPAT_SET_VLAN_VID ("set the 802.1q VLAN id") as defined by
2775 * the OpenFlow Switch Specification.
2777 struct rte_flow_action_of_set_vlan_vid {
2778 rte_be16_t vlan_vid; /**< VLAN id. */
2782 * RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP
2784 * Implements OFPAT_SET_LAN_PCP ("set the 802.1q priority") as defined by
2785 * the OpenFlow Switch Specification.
2787 struct rte_flow_action_of_set_vlan_pcp {
2788 uint8_t vlan_pcp; /**< VLAN priority. */
2792 * RTE_FLOW_ACTION_TYPE_OF_POP_MPLS
2794 * Implements OFPAT_POP_MPLS ("pop the outer MPLS tag") as defined by the
2795 * OpenFlow Switch Specification.
2797 struct rte_flow_action_of_pop_mpls {
2798 rte_be16_t ethertype; /**< EtherType. */
2802 * RTE_FLOW_ACTION_TYPE_OF_PUSH_MPLS
2804 * Implements OFPAT_PUSH_MPLS ("push a new MPLS tag") as defined by the
2805 * OpenFlow Switch Specification.
2807 struct rte_flow_action_of_push_mpls {
2808 rte_be16_t ethertype; /**< EtherType. */
2813 * @b EXPERIMENTAL: this structure may change without prior notice
2815 * RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP
2817 * VXLAN tunnel end-point encapsulation data definition
2819 * The tunnel definition is provided through the flow item pattern, the
2820 * provided pattern must conform to RFC7348 for the tunnel specified. The flow
2821 * definition must be provided in order from the RTE_FLOW_ITEM_TYPE_ETH
2822 * definition up the end item which is specified by RTE_FLOW_ITEM_TYPE_END.
2824 * The mask field allows user to specify which fields in the flow item
2825 * definitions can be ignored and which have valid data and can be used
2828 * Note: the last field is not used in the definition of a tunnel and can be
2831 * Valid flow definition for RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP include:
2833 * - ETH / IPV4 / UDP / VXLAN / END
2834 * - ETH / IPV6 / UDP / VXLAN / END
2835 * - ETH / VLAN / IPV4 / UDP / VXLAN / END
2838 struct rte_flow_action_vxlan_encap {
2840 * Encapsulating vxlan tunnel definition
2841 * (terminated by the END pattern item).
2843 struct rte_flow_item *definition;
2848 * @b EXPERIMENTAL: this structure may change without prior notice
2850 * RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP
2852 * NVGRE tunnel end-point encapsulation data definition
2854 * The tunnel definition is provided through the flow item pattern the
2855 * provided pattern must conform with RFC7637. The flow definition must be
2856 * provided in order from the RTE_FLOW_ITEM_TYPE_ETH definition up the end item
2857 * which is specified by RTE_FLOW_ITEM_TYPE_END.
2859 * The mask field allows user to specify which fields in the flow item
2860 * definitions can be ignored and which have valid data and can be used
2863 * Note: the last field is not used in the definition of a tunnel and can be
2866 * Valid flow definition for RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP include:
2868 * - ETH / IPV4 / NVGRE / END
2869 * - ETH / VLAN / IPV6 / NVGRE / END
2872 struct rte_flow_action_nvgre_encap {
2874 * Encapsulating vxlan tunnel definition
2875 * (terminated by the END pattern item).
2877 struct rte_flow_item *definition;
2882 * @b EXPERIMENTAL: this structure may change without prior notice
2884 * RTE_FLOW_ACTION_TYPE_RAW_ENCAP
2886 * Raw tunnel end-point encapsulation data definition.
2888 * The data holds the headers definitions to be applied on the packet.
2889 * The data must start with ETH header up to the tunnel item header itself.
2890 * When used right after RAW_DECAP (for decapsulating L3 tunnel type for
2891 * example MPLSoGRE) the data will just hold layer 2 header.
2893 * The preserve parameter holds which bits in the packet the PMD is not allowed
2894 * to change, this parameter can also be NULL and then the PMD is allowed
2895 * to update any field.
2897 * size holds the number of bytes in @p data and @p preserve.
2899 struct rte_flow_action_raw_encap {
2900 uint8_t *data; /**< Encapsulation data. */
2901 uint8_t *preserve; /**< Bit-mask of @p data to preserve on output. */
2902 size_t size; /**< Size of @p data and @p preserve. */
2907 * @b EXPERIMENTAL: this structure may change without prior notice
2909 * RTE_FLOW_ACTION_TYPE_RAW_DECAP
2911 * Raw tunnel end-point decapsulation data definition.
2913 * The data holds the headers definitions to be removed from the packet.
2914 * The data must start with ETH header up to the tunnel item header itself.
2915 * When used right before RAW_DECAP (for encapsulating L3 tunnel type for
2916 * example MPLSoGRE) the data will just hold layer 2 header.
2918 * size holds the number of bytes in @p data.
2920 struct rte_flow_action_raw_decap {
2921 uint8_t *data; /**< Encapsulation data. */
2922 size_t size; /**< Size of @p data and @p preserve. */
2927 * @b EXPERIMENTAL: this structure may change without prior notice
2929 * RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC
2930 * RTE_FLOW_ACTION_TYPE_SET_IPV4_DST
2932 * Allows modification of IPv4 source (RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC)
2933 * and destination address (RTE_FLOW_ACTION_TYPE_SET_IPV4_DST) in the
2934 * specified outermost IPv4 header.
2936 struct rte_flow_action_set_ipv4 {
2937 rte_be32_t ipv4_addr;
2942 * @b EXPERIMENTAL: this structure may change without prior notice
2944 * RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC
2945 * RTE_FLOW_ACTION_TYPE_SET_IPV6_DST
2947 * Allows modification of IPv6 source (RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC)
2948 * and destination address (RTE_FLOW_ACTION_TYPE_SET_IPV6_DST) in the
2949 * specified outermost IPv6 header.
2951 struct rte_flow_action_set_ipv6 {
2952 uint8_t ipv6_addr[16];
2957 * @b EXPERIMENTAL: this structure may change without prior notice
2959 * RTE_FLOW_ACTION_TYPE_SET_TP_SRC
2960 * RTE_FLOW_ACTION_TYPE_SET_TP_DST
2962 * Allows modification of source (RTE_FLOW_ACTION_TYPE_SET_TP_SRC)
2963 * and destination (RTE_FLOW_ACTION_TYPE_SET_TP_DST) port numbers
2964 * in the specified outermost TCP/UDP header.
2966 struct rte_flow_action_set_tp {
2971 * RTE_FLOW_ACTION_TYPE_SET_TTL
2973 * Set the TTL value directly for IPv4 or IPv6
2975 struct rte_flow_action_set_ttl {
2980 * RTE_FLOW_ACTION_TYPE_SET_MAC
2982 * Set MAC address from the matched flow
2984 struct rte_flow_action_set_mac {
2985 uint8_t mac_addr[RTE_ETHER_ADDR_LEN];
2990 * @b EXPERIMENTAL: this structure may change without prior notice
2992 * RTE_FLOW_ACTION_TYPE_SET_TAG
2994 * Set a tag which is a transient data used during flow matching. This is not
2995 * delivered to application. Multiple tags are supported by specifying index.
2997 struct rte_flow_action_set_tag {
3005 * @b EXPERIMENTAL: this structure may change without prior notice
3007 * RTE_FLOW_ACTION_TYPE_SET_META
3009 * Set metadata. Metadata set by mbuf metadata dynamic field with
3010 * PKT_TX_DYNF_DATA flag on egress will be overridden by this action. On
3011 * ingress, the metadata will be carried by mbuf metadata dynamic field
3012 * with PKT_RX_DYNF_METADATA flag if set. The dynamic mbuf field must be
3013 * registered in advance by rte_flow_dynf_metadata_register().
3015 * Altering partial bits is supported with mask. For bits which have never
3016 * been set, unpredictable value will be seen depending on driver
3017 * implementation. For loopback/hairpin packet, metadata set on Rx/Tx may
3018 * or may not be propagated to the other path depending on HW capability.
3020 * RTE_FLOW_ITEM_TYPE_META matches metadata.
3022 struct rte_flow_action_set_meta {
3028 * RTE_FLOW_ACTION_TYPE_SET_IPV4_DSCP
3029 * RTE_FLOW_ACTION_TYPE_SET_IPV6_DSCP
3031 * Set the DSCP value for IPv4/IPv6 header.
3032 * DSCP in low 6 bits, rest ignored.
3034 struct rte_flow_action_set_dscp {
3040 * @b EXPERIMENTAL: this structure may change without prior notice
3042 * RTE_FLOW_ACTION_TYPE_INDIRECT
3044 * Opaque type returned after successfully creating an indirect action object.
3045 * The definition of the object handle is different per driver or
3046 * per direct action type.
3048 * This handle can be used to manage and query the related direct action:
3049 * - referenced in single flow rule or across multiple flow rules
3050 * over multiple ports
3051 * - update action object configuration
3052 * - query action object data
3053 * - destroy action object
3055 struct rte_flow_action_handle;
3058 * The state of a TCP connection.
3060 enum rte_flow_conntrack_state {
3061 /** SYN-ACK packet was seen. */
3062 RTE_FLOW_CONNTRACK_STATE_SYN_RECV,
3063 /** 3-way handshake was done. */
3064 RTE_FLOW_CONNTRACK_STATE_ESTABLISHED,
3065 /** First FIN packet was received to close the connection. */
3066 RTE_FLOW_CONNTRACK_STATE_FIN_WAIT,
3067 /** First FIN was ACKed. */
3068 RTE_FLOW_CONNTRACK_STATE_CLOSE_WAIT,
3069 /** Second FIN was received, waiting for the last ACK. */
3070 RTE_FLOW_CONNTRACK_STATE_LAST_ACK,
3071 /** Second FIN was ACKed, connection was closed. */
3072 RTE_FLOW_CONNTRACK_STATE_TIME_WAIT,
3076 * The last passed TCP packet flags of a connection.
3078 enum rte_flow_conntrack_tcp_last_index {
3079 RTE_FLOW_CONNTRACK_FLAG_NONE = 0, /**< No Flag. */
3080 RTE_FLOW_CONNTRACK_FLAG_SYN = RTE_BIT32(0), /**< With SYN flag. */
3081 RTE_FLOW_CONNTRACK_FLAG_SYNACK = RTE_BIT32(1), /**< With SYNACK flag. */
3082 RTE_FLOW_CONNTRACK_FLAG_FIN = RTE_BIT32(2), /**< With FIN flag. */
3083 RTE_FLOW_CONNTRACK_FLAG_ACK = RTE_BIT32(3), /**< With ACK flag. */
3084 RTE_FLOW_CONNTRACK_FLAG_RST = RTE_BIT32(4), /**< With RST flag. */
3089 * @b EXPERIMENTAL: this structure may change without prior notice
3091 * Configuration parameters for each direction of a TCP connection.
3092 * All fields should be in host byte order.
3093 * If needed, driver should convert all fields to network byte order
3094 * if HW needs them in that way.
3096 struct rte_flow_tcp_dir_param {
3097 /** TCP window scaling factor, 0xF to disable. */
3099 /** The FIN was sent by this direction. */
3100 uint32_t close_initiated:1;
3101 /** An ACK packet has been received by this side. */
3102 uint32_t last_ack_seen:1;
3104 * If set, it indicates that there is unacknowledged data for the
3105 * packets sent from this direction.
3107 uint32_t data_unacked:1;
3109 * Maximal value of sequence + payload length in sent
3110 * packets (next ACK from the opposite direction).
3114 * Maximal value of (ACK + window size) in received packet + length
3115 * over sent packet (maximal sequence could be sent).
3118 /** Maximal value of actual window size in sent packets. */
3120 /** Maximal value of ACK in sent packets. */
3126 * @b EXPERIMENTAL: this structure may change without prior notice
3128 * RTE_FLOW_ACTION_TYPE_CONNTRACK
3130 * Configuration and initial state for the connection tracking module.
3131 * This structure could be used for both setting and query.
3132 * All fields should be in host byte order.
3134 struct rte_flow_action_conntrack {
3135 /** The peer port number, can be the same port. */
3138 * Direction of this connection when creating a flow rule, the
3139 * value only affects the creation of subsequent flow rules.
3141 uint32_t is_original_dir:1;
3143 * Enable / disable the conntrack HW module. When disabled, the
3144 * result will always be RTE_FLOW_CONNTRACK_FLAG_DISABLED.
3145 * In this state the HW will act as passthrough.
3146 * It only affects this conntrack object in the HW without any effect
3147 * to the other objects.
3150 /** At least one ack was seen after the connection was established. */
3151 uint32_t live_connection:1;
3152 /** Enable selective ACK on this connection. */
3153 uint32_t selective_ack:1;
3154 /** A challenge ack has passed. */
3155 uint32_t challenge_ack_passed:1;
3157 * 1: The last packet is seen from the original direction.
3158 * 0: The last packet is seen from the reply direction.
3160 uint32_t last_direction:1;
3161 /** No TCP check will be done except the state change. */
3162 uint32_t liberal_mode:1;
3163 /**<The current state of this connection. */
3164 enum rte_flow_conntrack_state state;
3165 /** Scaling factor for maximal allowed ACK window. */
3166 uint8_t max_ack_window;
3167 /** Maximal allowed number of retransmission times. */
3168 uint8_t retransmission_limit;
3169 /** TCP parameters of the original direction. */
3170 struct rte_flow_tcp_dir_param original_dir;
3171 /** TCP parameters of the reply direction. */
3172 struct rte_flow_tcp_dir_param reply_dir;
3173 /** The window value of the last packet passed this conntrack. */
3174 uint16_t last_window;
3175 enum rte_flow_conntrack_tcp_last_index last_index;
3176 /** The sequence of the last packet passed this conntrack. */
3178 /** The acknowledgment of the last packet passed this conntrack. */
3181 * The total value ACK + payload length of the last packet
3182 * passed this conntrack.
3188 * RTE_FLOW_ACTION_TYPE_CONNTRACK
3190 * Wrapper structure for the context update interface.
3191 * Ports cannot support updating, and the only valid solution is to
3192 * destroy the old context and create a new one instead.
3194 struct rte_flow_modify_conntrack {
3195 /** New connection tracking parameters to be updated. */
3196 struct rte_flow_action_conntrack new_ct;
3197 /** The direction field will be updated. */
3198 uint32_t direction:1;
3199 /** All the other fields except direction will be updated. */
3201 /** Reserved bits for the future usage. */
3202 uint32_t reserved:30;
3207 * @b EXPERIMENTAL: this structure may change without prior notice
3209 * RTE_FLOW_ACTION_TYPE_METER_COLOR
3211 * The meter color should be set in the packet meta-data
3212 * (i.e. struct rte_mbuf::sched::color).
3214 struct rte_flow_action_meter_color {
3215 enum rte_color color; /**< Packet color. */
3220 * @b EXPERIMENTAL: this structure may change without prior notice
3222 * Provides an ethdev port ID for use with the following actions:
3223 * RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR,
3224 * RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT.
3226 struct rte_flow_action_ethdev {
3227 uint16_t port_id; /**< ethdev port ID */
3231 * Field IDs for MODIFY_FIELD action.
3233 enum rte_flow_field_id {
3234 RTE_FLOW_FIELD_START = 0, /**< Start of a packet. */
3235 RTE_FLOW_FIELD_MAC_DST, /**< Destination MAC Address. */
3236 RTE_FLOW_FIELD_MAC_SRC, /**< Source MAC Address. */
3237 RTE_FLOW_FIELD_VLAN_TYPE, /**< 802.1Q Tag Identifier. */
3238 RTE_FLOW_FIELD_VLAN_ID, /**< 802.1Q VLAN Identifier. */
3239 RTE_FLOW_FIELD_MAC_TYPE, /**< EtherType. */
3240 RTE_FLOW_FIELD_IPV4_DSCP, /**< IPv4 DSCP. */
3241 RTE_FLOW_FIELD_IPV4_TTL, /**< IPv4 Time To Live. */
3242 RTE_FLOW_FIELD_IPV4_SRC, /**< IPv4 Source Address. */
3243 RTE_FLOW_FIELD_IPV4_DST, /**< IPv4 Destination Address. */
3244 RTE_FLOW_FIELD_IPV6_DSCP, /**< IPv6 DSCP. */
3245 RTE_FLOW_FIELD_IPV6_HOPLIMIT, /**< IPv6 Hop Limit. */
3246 RTE_FLOW_FIELD_IPV6_SRC, /**< IPv6 Source Address. */
3247 RTE_FLOW_FIELD_IPV6_DST, /**< IPv6 Destination Address. */
3248 RTE_FLOW_FIELD_TCP_PORT_SRC, /**< TCP Source Port Number. */
3249 RTE_FLOW_FIELD_TCP_PORT_DST, /**< TCP Destination Port Number. */
3250 RTE_FLOW_FIELD_TCP_SEQ_NUM, /**< TCP Sequence Number. */
3251 RTE_FLOW_FIELD_TCP_ACK_NUM, /**< TCP Acknowledgment Number. */
3252 RTE_FLOW_FIELD_TCP_FLAGS, /**< TCP Flags. */
3253 RTE_FLOW_FIELD_UDP_PORT_SRC, /**< UDP Source Port Number. */
3254 RTE_FLOW_FIELD_UDP_PORT_DST, /**< UDP Destination Port Number. */
3255 RTE_FLOW_FIELD_VXLAN_VNI, /**< VXLAN Network Identifier. */
3256 RTE_FLOW_FIELD_GENEVE_VNI, /**< GENEVE Network Identifier. */
3257 RTE_FLOW_FIELD_GTP_TEID, /**< GTP Tunnel Endpoint Identifier. */
3258 RTE_FLOW_FIELD_TAG, /**< Tag value. */
3259 RTE_FLOW_FIELD_MARK, /**< Mark value. */
3260 RTE_FLOW_FIELD_META, /**< Metadata value. */
3261 RTE_FLOW_FIELD_POINTER, /**< Memory pointer. */
3262 RTE_FLOW_FIELD_VALUE, /**< Immediate value. */
3266 * Field description for MODIFY_FIELD action.
3268 struct rte_flow_action_modify_data {
3269 enum rte_flow_field_id field; /**< Field or memory type ID. */
3273 /**< Encapsulation level or tag index. */
3275 /**< Number of bits to skip from a field. */
3279 * Immediate value for RTE_FLOW_FIELD_VALUE or
3280 * memory address for RTE_FLOW_FIELD_POINTER.
3287 * Operation types for MODIFY_FIELD action.
3289 enum rte_flow_modify_op {
3290 RTE_FLOW_MODIFY_SET = 0, /**< Set a new value. */
3291 RTE_FLOW_MODIFY_ADD, /**< Add a value to a field. */
3292 RTE_FLOW_MODIFY_SUB, /**< Subtract a value from a field. */
3297 * @b EXPERIMENTAL: this structure may change without prior notice
3299 * RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
3301 * Modify a destination header field according to the specified
3302 * operation. Another packet field can be used as a source as well
3303 * as tag, mark, metadata, immediate value or a pointer to it.
3305 struct rte_flow_action_modify_field {
3306 enum rte_flow_modify_op operation; /**< Operation to perform. */
3307 struct rte_flow_action_modify_data dst; /**< Destination field. */
3308 struct rte_flow_action_modify_data src; /**< Source field. */
3309 uint32_t width; /**< Number of bits to use from a source field. */
3312 /* Mbuf dynamic field offset for metadata. */
3313 extern int32_t rte_flow_dynf_metadata_offs;
3315 /* Mbuf dynamic field flag mask for metadata. */
3316 extern uint64_t rte_flow_dynf_metadata_mask;
3318 /* Mbuf dynamic field pointer for metadata. */
3319 #define RTE_FLOW_DYNF_METADATA(m) \
3320 RTE_MBUF_DYNFIELD((m), rte_flow_dynf_metadata_offs, uint32_t *)
3322 /* Mbuf dynamic flags for metadata. */
3323 #define PKT_RX_DYNF_METADATA (rte_flow_dynf_metadata_mask)
3324 #define PKT_TX_DYNF_METADATA (rte_flow_dynf_metadata_mask)
3327 static inline uint32_t
3328 rte_flow_dynf_metadata_get(struct rte_mbuf *m)
3330 return *RTE_FLOW_DYNF_METADATA(m);
3335 rte_flow_dynf_metadata_set(struct rte_mbuf *m, uint32_t v)
3337 *RTE_FLOW_DYNF_METADATA(m) = v;
3341 * Definition of a single action.
3343 * A list of actions is terminated by a END action.
3345 * For simple actions without a configuration object, conf remains NULL.
3347 struct rte_flow_action {
3348 enum rte_flow_action_type type; /**< Action type. */
3349 const void *conf; /**< Pointer to action configuration object. */
3353 * Opaque type returned after successfully creating a flow.
3355 * This handle can be used to manage and query the related flow (e.g. to
3356 * destroy it or retrieve counters).
3362 * @b EXPERIMENTAL: this structure may change without prior notice
3364 * RTE_FLOW_ACTION_TYPE_SAMPLE
3366 * Adds a sample action to a matched flow.
3368 * The matching packets will be duplicated with specified ratio and applied
3369 * with own set of actions with a fate action, the sampled packet could be
3370 * redirected to queue or port. All the packets continue processing on the
3371 * default flow path.
3373 * When the sample ratio is set to 1 then the packets will be 100% mirrored.
3374 * Additional action list be supported to add for sampled or mirrored packets.
3376 struct rte_flow_action_sample {
3377 uint32_t ratio; /**< packets sampled equals to '1/ratio'. */
3378 const struct rte_flow_action *actions;
3379 /**< sub-action list specific for the sampling hit cases. */
3383 * Verbose error types.
3385 * Most of them provide the type of the object referenced by struct
3386 * rte_flow_error.cause.
3388 enum rte_flow_error_type {
3389 RTE_FLOW_ERROR_TYPE_NONE, /**< No error. */
3390 RTE_FLOW_ERROR_TYPE_UNSPECIFIED, /**< Cause unspecified. */
3391 RTE_FLOW_ERROR_TYPE_HANDLE, /**< Flow rule (handle). */
3392 RTE_FLOW_ERROR_TYPE_ATTR_GROUP, /**< Group field. */
3393 RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY, /**< Priority field. */
3394 RTE_FLOW_ERROR_TYPE_ATTR_INGRESS, /**< Ingress field. */
3395 RTE_FLOW_ERROR_TYPE_ATTR_EGRESS, /**< Egress field. */
3396 RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, /**< Transfer field. */
3397 RTE_FLOW_ERROR_TYPE_ATTR, /**< Attributes structure. */
3398 RTE_FLOW_ERROR_TYPE_ITEM_NUM, /**< Pattern length. */
3399 RTE_FLOW_ERROR_TYPE_ITEM_SPEC, /**< Item specification. */
3400 RTE_FLOW_ERROR_TYPE_ITEM_LAST, /**< Item specification range. */
3401 RTE_FLOW_ERROR_TYPE_ITEM_MASK, /**< Item specification mask. */
3402 RTE_FLOW_ERROR_TYPE_ITEM, /**< Specific pattern item. */
3403 RTE_FLOW_ERROR_TYPE_ACTION_NUM, /**< Number of actions. */
3404 RTE_FLOW_ERROR_TYPE_ACTION_CONF, /**< Action configuration. */
3405 RTE_FLOW_ERROR_TYPE_ACTION, /**< Specific action. */
3409 * Verbose error structure definition.
3411 * This object is normally allocated by applications and set by PMDs, the
3412 * message points to a constant string which does not need to be freed by
3413 * the application, however its pointer can be considered valid only as long
3414 * as its associated DPDK port remains configured. Closing the underlying
3415 * device or unloading the PMD invalidates it.
3417 * Both cause and message may be NULL regardless of the error type.
3419 struct rte_flow_error {
3420 enum rte_flow_error_type type; /**< Cause field and error types. */
3421 const void *cause; /**< Object responsible for the error. */
3422 const char *message; /**< Human-readable error message. */
3426 * Complete flow rule description.
3428 * This object type is used when converting a flow rule description.
3430 * @see RTE_FLOW_CONV_OP_RULE
3431 * @see rte_flow_conv()
3434 struct rte_flow_conv_rule {
3436 const struct rte_flow_attr *attr_ro; /**< RO attributes. */
3437 struct rte_flow_attr *attr; /**< Attributes. */
3440 const struct rte_flow_item *pattern_ro; /**< RO pattern. */
3441 struct rte_flow_item *pattern; /**< Pattern items. */
3444 const struct rte_flow_action *actions_ro; /**< RO actions. */
3445 struct rte_flow_action *actions; /**< List of actions. */
3450 * Conversion operations for flow API objects.
3452 * @see rte_flow_conv()
3454 enum rte_flow_conv_op {
3456 * No operation to perform.
3458 * rte_flow_conv() simply returns 0.
3460 RTE_FLOW_CONV_OP_NONE,
3463 * Convert attributes structure.
3465 * This is a basic copy of an attributes structure.
3468 * @code const struct rte_flow_attr * @endcode
3470 * @code struct rte_flow_attr * @endcode
3472 RTE_FLOW_CONV_OP_ATTR,
3475 * Convert a single item.
3477 * Duplicates @p spec, @p last and @p mask but not outside objects.
3480 * @code const struct rte_flow_item * @endcode
3482 * @code struct rte_flow_item * @endcode
3484 RTE_FLOW_CONV_OP_ITEM,
3487 * Convert a single action.
3489 * Duplicates @p conf but not outside objects.
3492 * @code const struct rte_flow_action * @endcode
3494 * @code struct rte_flow_action * @endcode
3496 RTE_FLOW_CONV_OP_ACTION,
3499 * Convert an entire pattern.
3501 * Duplicates all pattern items at once with the same constraints as
3502 * RTE_FLOW_CONV_OP_ITEM.
3505 * @code const struct rte_flow_item * @endcode
3507 * @code struct rte_flow_item * @endcode
3509 RTE_FLOW_CONV_OP_PATTERN,
3512 * Convert a list of actions.
3514 * Duplicates the entire list of actions at once with the same
3515 * constraints as RTE_FLOW_CONV_OP_ACTION.
3518 * @code const struct rte_flow_action * @endcode
3520 * @code struct rte_flow_action * @endcode
3522 RTE_FLOW_CONV_OP_ACTIONS,
3525 * Convert a complete flow rule description.
3527 * Comprises attributes, pattern and actions together at once with
3528 * the usual constraints.
3531 * @code const struct rte_flow_conv_rule * @endcode
3533 * @code struct rte_flow_conv_rule * @endcode
3535 RTE_FLOW_CONV_OP_RULE,
3538 * Convert item type to its name string.
3540 * Writes a NUL-terminated string to @p dst. Like snprintf(), the
3541 * returned value excludes the terminator which is always written
3545 * @code (const void *)enum rte_flow_item_type @endcode
3547 * @code char * @endcode
3549 RTE_FLOW_CONV_OP_ITEM_NAME,
3552 * Convert action type to its name string.
3554 * Writes a NUL-terminated string to @p dst. Like snprintf(), the
3555 * returned value excludes the terminator which is always written
3559 * @code (const void *)enum rte_flow_action_type @endcode
3561 * @code char * @endcode
3563 RTE_FLOW_CONV_OP_ACTION_NAME,
3566 * Convert item type to pointer to item name.
3568 * Retrieves item name pointer from its type. The string itself is
3569 * not copied; instead, a unique pointer to an internal static
3570 * constant storage is written to @p dst.
3573 * @code (const void *)enum rte_flow_item_type @endcode
3575 * @code const char ** @endcode
3577 RTE_FLOW_CONV_OP_ITEM_NAME_PTR,
3580 * Convert action type to pointer to action name.
3582 * Retrieves action name pointer from its type. The string itself is
3583 * not copied; instead, a unique pointer to an internal static
3584 * constant storage is written to @p dst.
3587 * @code (const void *)enum rte_flow_action_type @endcode
3589 * @code const char ** @endcode
3591 RTE_FLOW_CONV_OP_ACTION_NAME_PTR,
3596 * @b EXPERIMENTAL: this API may change without prior notice.
3598 * Dump hardware internal representation information of
3601 * @param[in] port_id
3602 * The port identifier of the Ethernet device.
3604 * The pointer of flow rule to dump. Dump all rules if NULL.
3606 * A pointer to a file for output.
3608 * Perform verbose error reporting if not NULL. PMDs initialize this
3609 * structure in case of error only.
3611 * 0 on success, a nagative value otherwise.
3615 rte_flow_dev_dump(uint16_t port_id, struct rte_flow *flow,
3616 FILE *file, struct rte_flow_error *error);
3619 * Check if mbuf dynamic field for metadata is registered.
3622 * True if registered, false otherwise.
3626 rte_flow_dynf_metadata_avail(void)
3628 return !!rte_flow_dynf_metadata_mask;
3632 * Register mbuf dynamic field and flag for metadata.
3634 * This function must be called prior to use SET_META action in order to
3635 * register the dynamic mbuf field. Otherwise, the data cannot be delivered to
3639 * 0 on success, a negative errno value otherwise and rte_errno is set.
3643 rte_flow_dynf_metadata_register(void);
3646 * Check whether a flow rule can be created on a given port.
3648 * The flow rule is validated for correctness and whether it could be accepted
3649 * by the device given sufficient resources. The rule is checked against the
3650 * current device mode and queue configuration. The flow rule may also
3651 * optionally be validated against existing flow rules and device resources.
3652 * This function has no effect on the target device.
3654 * The returned value is guaranteed to remain valid only as long as no
3655 * successful calls to rte_flow_create() or rte_flow_destroy() are made in
3656 * the meantime and no device parameter affecting flow rules in any way are
3657 * modified, due to possible collisions or resource limitations (although in
3658 * such cases EINVAL should not be returned).
3661 * Port identifier of Ethernet device.
3663 * Flow rule attributes.
3664 * @param[in] pattern
3665 * Pattern specification (list terminated by the END pattern item).
3666 * @param[in] actions
3667 * Associated actions (list terminated by the END action).
3669 * Perform verbose error reporting if not NULL. PMDs initialize this
3670 * structure in case of error only.
3673 * 0 if flow rule is valid and can be created. A negative errno value
3674 * otherwise (rte_errno is also set), the following errors are defined:
3676 * -ENOSYS: underlying device does not support this functionality.
3678 * -EIO: underlying device is removed.
3680 * -EINVAL: unknown or invalid rule specification.
3682 * -ENOTSUP: valid but unsupported rule specification (e.g. partial
3683 * bit-masks are unsupported).
3685 * -EEXIST: collision with an existing rule. Only returned if device
3686 * supports flow rule collision checking and there was a flow rule
3687 * collision. Not receiving this return code is no guarantee that creating
3688 * the rule will not fail due to a collision.
3690 * -ENOMEM: not enough memory to execute the function, or if the device
3691 * supports resource validation, resource limitation on the device.
3693 * -EBUSY: action cannot be performed due to busy device resources, may
3694 * succeed if the affected queues or even the entire port are in a stopped
3695 * state (see rte_eth_dev_rx_queue_stop() and rte_eth_dev_stop()).
3698 rte_flow_validate(uint16_t port_id,
3699 const struct rte_flow_attr *attr,
3700 const struct rte_flow_item pattern[],
3701 const struct rte_flow_action actions[],
3702 struct rte_flow_error *error);
3705 * Create a flow rule on a given port.
3708 * Port identifier of Ethernet device.
3710 * Flow rule attributes.
3711 * @param[in] pattern
3712 * Pattern specification (list terminated by the END pattern item).
3713 * @param[in] actions
3714 * Associated actions (list terminated by the END action).
3716 * Perform verbose error reporting if not NULL. PMDs initialize this
3717 * structure in case of error only.
3720 * A valid handle in case of success, NULL otherwise and rte_errno is set
3721 * to the positive version of one of the error codes defined for
3722 * rte_flow_validate().
3725 rte_flow_create(uint16_t port_id,
3726 const struct rte_flow_attr *attr,
3727 const struct rte_flow_item pattern[],
3728 const struct rte_flow_action actions[],
3729 struct rte_flow_error *error);
3732 * Destroy a flow rule on a given port.
3734 * Failure to destroy a flow rule handle may occur when other flow rules
3735 * depend on it, and destroying it would result in an inconsistent state.
3737 * This function is only guaranteed to succeed if handles are destroyed in
3738 * reverse order of their creation.
3741 * Port identifier of Ethernet device.
3743 * Flow rule handle to destroy.
3745 * Perform verbose error reporting if not NULL. PMDs initialize this
3746 * structure in case of error only.
3749 * 0 on success, a negative errno value otherwise and rte_errno is set.
3752 rte_flow_destroy(uint16_t port_id,
3753 struct rte_flow *flow,
3754 struct rte_flow_error *error);
3757 * Destroy all flow rules associated with a port.
3759 * In the unlikely event of failure, handles are still considered destroyed
3760 * and no longer valid but the port must be assumed to be in an inconsistent
3764 * Port identifier of Ethernet device.
3766 * Perform verbose error reporting if not NULL. PMDs initialize this
3767 * structure in case of error only.
3770 * 0 on success, a negative errno value otherwise and rte_errno is set.
3773 rte_flow_flush(uint16_t port_id,
3774 struct rte_flow_error *error);
3777 * Query an existing flow rule.
3779 * This function allows retrieving flow-specific data such as counters.
3780 * Data is gathered by special actions which must be present in the flow
3783 * \see RTE_FLOW_ACTION_TYPE_COUNT
3786 * Port identifier of Ethernet device.
3788 * Flow rule handle to query.
3790 * Action definition as defined in original flow rule.
3791 * @param[in, out] data
3792 * Pointer to storage for the associated query data type.
3794 * Perform verbose error reporting if not NULL. PMDs initialize this
3795 * structure in case of error only.
3798 * 0 on success, a negative errno value otherwise and rte_errno is set.
3801 rte_flow_query(uint16_t port_id,
3802 struct rte_flow *flow,
3803 const struct rte_flow_action *action,
3805 struct rte_flow_error *error);
3808 * Restrict ingress traffic to the defined flow rules.
3810 * Isolated mode guarantees that all ingress traffic comes from defined flow
3811 * rules only (current and future).
3813 * Besides making ingress more deterministic, it allows PMDs to safely reuse
3814 * resources otherwise assigned to handle the remaining traffic, such as
3815 * global RSS configuration settings, VLAN filters, MAC address entries,
3816 * legacy filter API rules and so on in order to expand the set of possible
3819 * Calling this function as soon as possible after device initialization,
3820 * ideally before the first call to rte_eth_dev_configure(), is recommended
3821 * to avoid possible failures due to conflicting settings.
3823 * Once effective, leaving isolated mode may not be possible depending on
3824 * PMD implementation.
3826 * Additionally, the following functionality has no effect on the underlying
3827 * port and may return errors such as ENOTSUP ("not supported"):
3829 * - Toggling promiscuous mode.
3830 * - Toggling allmulticast mode.
3831 * - Configuring MAC addresses.
3832 * - Configuring multicast addresses.
3833 * - Configuring VLAN filters.
3834 * - Configuring Rx filters through the legacy API (e.g. FDIR).
3835 * - Configuring global RSS settings.
3838 * Port identifier of Ethernet device.
3840 * Nonzero to enter isolated mode, attempt to leave it otherwise.
3842 * Perform verbose error reporting if not NULL. PMDs initialize this
3843 * structure in case of error only.
3846 * 0 on success, a negative errno value otherwise and rte_errno is set.
3849 rte_flow_isolate(uint16_t port_id, int set, struct rte_flow_error *error);
3852 * Initialize flow error structure.
3855 * Pointer to flow error structure (may be NULL).
3857 * Related error code (rte_errno).
3859 * Cause field and error types.
3861 * Object responsible for the error.
3863 * Human-readable error message.
3866 * Negative error code (errno value) and rte_errno is set.
3869 rte_flow_error_set(struct rte_flow_error *error,
3871 enum rte_flow_error_type type,
3873 const char *message);
3877 * @see rte_flow_copy()
3879 struct rte_flow_desc {
3880 size_t size; /**< Allocated space including data[]. */
3881 struct rte_flow_attr attr; /**< Attributes. */
3882 struct rte_flow_item *items; /**< Items. */
3883 struct rte_flow_action *actions; /**< Actions. */
3884 uint8_t data[]; /**< Storage for items/actions. */
3889 * Copy an rte_flow rule description.
3891 * This interface is kept for compatibility with older applications but is
3892 * implemented as a wrapper to rte_flow_conv(). It is deprecated due to its
3893 * lack of flexibility and reliance on a type unusable with C++ programs
3894 * (struct rte_flow_desc).
3897 * Flow rule description.
3899 * Total size of allocated data for the flow description.
3901 * Flow rule attributes.
3903 * Pattern specification (list terminated by the END pattern item).
3904 * @param[in] actions
3905 * Associated actions (list terminated by the END action).
3908 * If len is greater or equal to the size of the flow, the total size of the
3909 * flow description and its data.
3910 * If len is lower than the size of the flow, the number of bytes that would
3911 * have been written to desc had it been sufficient. Nothing is written.
3915 rte_flow_copy(struct rte_flow_desc *fd, size_t len,
3916 const struct rte_flow_attr *attr,
3917 const struct rte_flow_item *items,
3918 const struct rte_flow_action *actions);
3921 * Flow object conversion helper.
3923 * This function performs conversion of various flow API objects to a
3924 * pre-allocated destination buffer. See enum rte_flow_conv_op for possible
3925 * operations and details about each of them.
3927 * Since destination buffer must be large enough, it works in a manner
3928 * reminiscent of snprintf():
3930 * - If @p size is 0, @p dst may be a NULL pointer, otherwise @p dst must be
3932 * - If positive, the returned value represents the number of bytes needed
3933 * to store the conversion of @p src to @p dst according to @p op
3934 * regardless of the @p size parameter.
3935 * - Since no more than @p size bytes can be written to @p dst, output is
3936 * truncated and may be inconsistent when the returned value is larger
3938 * - In case of conversion error, a negative error code is returned and
3939 * @p dst contents are unspecified.
3942 * Operation to perform, related to the object type of @p dst.
3944 * Destination buffer address. Must be suitably aligned by the caller.
3946 * Destination buffer size in bytes.
3948 * Source object to copy. Depending on @p op, its type may differ from
3951 * Perform verbose error reporting if not NULL. Initialized in case of
3955 * The number of bytes required to convert @p src to @p dst on success, a
3956 * negative errno value otherwise and rte_errno is set.
3958 * @see rte_flow_conv_op
3962 rte_flow_conv(enum rte_flow_conv_op op,
3966 struct rte_flow_error *error);
3969 * Get aged-out flows of a given port.
3971 * RTE_ETH_EVENT_FLOW_AGED event will be triggered when at least one new aged
3972 * out flow was detected after the last call to rte_flow_get_aged_flows.
3973 * This function can be called to get the aged flows usynchronously from the
3974 * event callback or synchronously regardless the event.
3975 * This is not safe to call rte_flow_get_aged_flows function with other flow
3976 * functions from multiple threads simultaneously.
3979 * Port identifier of Ethernet device.
3980 * @param[in, out] contexts
3981 * The address of an array of pointers to the aged-out flows contexts.
3982 * @param[in] nb_contexts
3983 * The length of context array pointers.
3985 * Perform verbose error reporting if not NULL. Initialized in case of
3989 * if nb_contexts is 0, return the amount of all aged contexts.
3990 * if nb_contexts is not 0 , return the amount of aged flows reported
3991 * in the context array, otherwise negative errno value.
3993 * @see rte_flow_action_age
3994 * @see RTE_ETH_EVENT_FLOW_AGED
3998 rte_flow_get_aged_flows(uint16_t port_id, void **contexts,
3999 uint32_t nb_contexts, struct rte_flow_error *error);
4002 * Specify indirect action object configuration
4004 struct rte_flow_indir_action_conf {
4006 * Flow direction for the indirect action configuration.
4008 * Action should be valid at least for one flow direction,
4009 * otherwise it is invalid for both ingress and egress rules.
4012 /**< Action valid for rules applied to ingress traffic. */
4014 /**< Action valid for rules applied to egress traffic. */
4016 * When set to 1, indicates that the action is valid for
4017 * transfer traffic; otherwise, for non-transfer traffic.
4019 uint32_t transfer:1;
4024 * @b EXPERIMENTAL: this API may change without prior notice.
4026 * Create an indirect action object that can be used in flow rules
4028 * The created object handle has single state and configuration
4029 * across all the flow rules using it.
4031 * @param[in] port_id
4032 * The port identifier of the Ethernet device.
4034 * Action configuration for the indirect action object creation.
4036 * Specific configuration of the indirect action object.
4038 * Perform verbose error reporting if not NULL. PMDs initialize this
4039 * structure in case of error only.
4041 * A valid handle in case of success, NULL otherwise and rte_errno is set
4042 * to one of the error codes defined:
4043 * - (ENODEV) if *port_id* invalid.
4044 * - (ENOSYS) if underlying device does not support this functionality.
4045 * - (EIO) if underlying device is removed.
4046 * - (EINVAL) if *action* invalid.
4047 * - (ENOTSUP) if *action* valid but unsupported.
4050 struct rte_flow_action_handle *
4051 rte_flow_action_handle_create(uint16_t port_id,
4052 const struct rte_flow_indir_action_conf *conf,
4053 const struct rte_flow_action *action,
4054 struct rte_flow_error *error);
4058 * @b EXPERIMENTAL: this API may change without prior notice.
4060 * Destroy indirect action by handle.
4062 * @param[in] port_id
4063 * The port identifier of the Ethernet device.
4065 * Handle for the indirect action object to be destroyed.
4067 * Perform verbose error reporting if not NULL. PMDs initialize this
4068 * structure in case of error only.
4071 * - (-ENODEV) if *port_id* invalid.
4072 * - (-ENOSYS) if underlying device does not support this functionality.
4073 * - (-EIO) if underlying device is removed.
4074 * - (-ENOENT) if action pointed by *action* handle was not found.
4075 * - (-EBUSY) if action pointed by *action* handle still used by some rules
4076 * rte_errno is also set.
4080 rte_flow_action_handle_destroy(uint16_t port_id,
4081 struct rte_flow_action_handle *handle,
4082 struct rte_flow_error *error);
4086 * @b EXPERIMENTAL: this API may change without prior notice.
4088 * Update in-place the action configuration and / or state pointed
4089 * by action *handle* with the configuration provided as *update* argument.
4090 * The update of the action configuration effects all flow rules reusing
4091 * the action via *handle*.
4092 * The update general pointer provides the ability of partial updating.
4094 * @param[in] port_id
4095 * The port identifier of the Ethernet device.
4097 * Handle for the indirect action object to be updated.
4099 * Update profile specification used to modify the action pointed by handle.
4100 * *update* could be with the same type of the immediate action corresponding
4101 * to the *handle* argument when creating, or a wrapper structure includes
4102 * action configuration to be updated and bit fields to indicate the member
4103 * of fields inside the action to update.
4105 * Perform verbose error reporting if not NULL. PMDs initialize this
4106 * structure in case of error only.
4109 * - (-ENODEV) if *port_id* invalid.
4110 * - (-ENOSYS) if underlying device does not support this functionality.
4111 * - (-EIO) if underlying device is removed.
4112 * - (-EINVAL) if *update* invalid.
4113 * - (-ENOTSUP) if *update* valid but unsupported.
4114 * - (-ENOENT) if indirect action object pointed by *handle* was not found.
4115 * rte_errno is also set.
4119 rte_flow_action_handle_update(uint16_t port_id,
4120 struct rte_flow_action_handle *handle,
4122 struct rte_flow_error *error);
4126 * @b EXPERIMENTAL: this API may change without prior notice.
4128 * Query the direct action by corresponding indirect action object handle.
4130 * Retrieve action-specific data such as counters.
4131 * Data is gathered by special action which may be present/referenced in
4132 * more than one flow rule definition.
4134 * @see RTE_FLOW_ACTION_TYPE_COUNT
4137 * Port identifier of Ethernet device.
4139 * Handle for the action object to query.
4140 * @param[in, out] data
4141 * Pointer to storage for the associated query data type.
4143 * Perform verbose error reporting if not NULL. PMDs initialize this
4144 * structure in case of error only.
4147 * 0 on success, a negative errno value otherwise and rte_errno is set.
4151 rte_flow_action_handle_query(uint16_t port_id,
4152 const struct rte_flow_action_handle *handle,
4153 void *data, struct rte_flow_error *error);
4155 /* Tunnel has a type and the key information. */
4156 struct rte_flow_tunnel {
4158 * Tunnel type, for example RTE_FLOW_ITEM_TYPE_VXLAN,
4159 * RTE_FLOW_ITEM_TYPE_NVGRE etc.
4161 enum rte_flow_item_type type;
4162 uint64_t tun_id; /**< Tunnel identification. */
4167 rte_be32_t src_addr; /**< IPv4 source address. */
4168 rte_be32_t dst_addr; /**< IPv4 destination address. */
4171 uint8_t src_addr[16]; /**< IPv6 source address. */
4172 uint8_t dst_addr[16]; /**< IPv6 destination address. */
4175 rte_be16_t tp_src; /**< Tunnel port source. */
4176 rte_be16_t tp_dst; /**< Tunnel port destination. */
4177 uint16_t tun_flags; /**< Tunnel flags. */
4179 bool is_ipv6; /**< True for valid IPv6 fields. Otherwise IPv4. */
4182 * the following members are required to restore packet
4185 uint8_t tos; /**< TOS for IPv4, TC for IPv6. */
4186 uint8_t ttl; /**< TTL for IPv4, HL for IPv6. */
4187 uint32_t label; /**< Flow Label for IPv6. */
4191 * Indicate that the packet has a tunnel.
4193 #define RTE_FLOW_RESTORE_INFO_TUNNEL (1ULL << 0)
4196 * Indicate that the packet has a non decapsulated tunnel header.
4198 #define RTE_FLOW_RESTORE_INFO_ENCAPSULATED (1ULL << 1)
4201 * Indicate that the packet has a group_id.
4203 #define RTE_FLOW_RESTORE_INFO_GROUP_ID (1ULL << 2)
4206 * Restore information structure to communicate the current packet processing
4207 * state when some of the processing pipeline is done in hardware and should
4208 * continue in software.
4210 struct rte_flow_restore_info {
4212 * Bitwise flags (RTE_FLOW_RESTORE_INFO_*) to indicate validation of
4213 * other fields in struct rte_flow_restore_info.
4216 uint32_t group_id; /**< Group ID where packed missed */
4217 struct rte_flow_tunnel tunnel; /**< Tunnel information. */
4221 * Allocate an array of actions to be used in rte_flow_create, to implement
4222 * tunnel-decap-set for the given tunnel.
4224 * actions vxlan_decap / tunnel-decap-set(tunnel properties) /
4225 * jump group 0 / end
4228 * Port identifier of Ethernet device.
4230 * Tunnel properties.
4231 * @param[out] actions
4232 * Array of actions to be allocated by the PMD. This array should be
4233 * concatenated with the actions array provided to rte_flow_create.
4234 * @param[out] num_of_actions
4235 * Number of actions allocated.
4237 * Perform verbose error reporting if not NULL. PMDs initialize this
4238 * structure in case of error only.
4241 * 0 on success, a negative errno value otherwise and rte_errno is set.
4245 rte_flow_tunnel_decap_set(uint16_t port_id,
4246 struct rte_flow_tunnel *tunnel,
4247 struct rte_flow_action **actions,
4248 uint32_t *num_of_actions,
4249 struct rte_flow_error *error);
4252 * Allocate an array of items to be used in rte_flow_create, to implement
4253 * tunnel-match for the given tunnel.
4255 * pattern tunnel-match(tunnel properties) / outer-header-matches /
4256 * inner-header-matches / end
4259 * Port identifier of Ethernet device.
4261 * Tunnel properties.
4263 * Array of items to be allocated by the PMD. This array should be
4264 * concatenated with the items array provided to rte_flow_create.
4265 * @param[out] num_of_items
4266 * Number of items allocated.
4268 * Perform verbose error reporting if not NULL. PMDs initialize this
4269 * structure in case of error only.
4272 * 0 on success, a negative errno value otherwise and rte_errno is set.
4276 rte_flow_tunnel_match(uint16_t port_id,
4277 struct rte_flow_tunnel *tunnel,
4278 struct rte_flow_item **items,
4279 uint32_t *num_of_items,
4280 struct rte_flow_error *error);
4283 * Populate the current packet processing state, if exists, for the given mbuf.
4285 * One should negotiate tunnel metadata delivery from the NIC to the HW.
4286 * @see rte_eth_rx_metadata_negotiate()
4287 * @see RTE_ETH_RX_METADATA_TUNNEL_ID
4290 * Port identifier of Ethernet device.
4294 * Restore information. Upon success contains the HW state.
4296 * Perform verbose error reporting if not NULL. PMDs initialize this
4297 * structure in case of error only.
4300 * 0 on success, a negative errno value otherwise and rte_errno is set.
4304 rte_flow_get_restore_info(uint16_t port_id,
4306 struct rte_flow_restore_info *info,
4307 struct rte_flow_error *error);
4310 * Release the action array as allocated by rte_flow_tunnel_decap_set.
4313 * Port identifier of Ethernet device.
4314 * @param[in] actions
4315 * Array of actions to be released.
4316 * @param[in] num_of_actions
4317 * Number of elements in actions array.
4319 * Perform verbose error reporting if not NULL. PMDs initialize this
4320 * structure in case of error only.
4323 * 0 on success, a negative errno value otherwise and rte_errno is set.
4327 rte_flow_tunnel_action_decap_release(uint16_t port_id,
4328 struct rte_flow_action *actions,
4329 uint32_t num_of_actions,
4330 struct rte_flow_error *error);
4333 * Release the item array as allocated by rte_flow_tunnel_match.
4336 * Port identifier of Ethernet device.
4338 * Array of items to be released.
4339 * @param[in] num_of_items
4340 * Number of elements in item array.
4342 * Perform verbose error reporting if not NULL. PMDs initialize this
4343 * structure in case of error only.
4346 * 0 on success, a negative errno value otherwise and rte_errno is set.
4350 rte_flow_tunnel_item_release(uint16_t port_id,
4351 struct rte_flow_item *items,
4352 uint32_t num_of_items,
4353 struct rte_flow_error *error);
4358 #endif /* RTE_FLOW_H_ */