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 * RTE_FLOW_ITEM_TYPE_HIGIG2
591 * Matches higig2 header
594 struct rte_flow_item_higig2_hdr {
595 struct rte_higig2_hdr hdr;
598 /** Default mask for RTE_FLOW_ITEM_TYPE_HIGIG2. */
600 static const struct rte_flow_item_higig2_hdr rte_flow_item_higig2_hdr_mask = {
603 .classification = 0xffff,
611 * RTE_FLOW_ITEM_TYPE_ANY
613 * Matches any protocol in place of the current layer, a single ANY may also
614 * stand for several protocol layers.
616 * This is usually specified as the first pattern item when looking for a
617 * protocol anywhere in a packet.
619 * A zeroed mask stands for any number of layers.
621 struct rte_flow_item_any {
622 uint32_t num; /**< Number of layers covered. */
625 /** Default mask for RTE_FLOW_ITEM_TYPE_ANY. */
627 static const struct rte_flow_item_any rte_flow_item_any_mask = {
633 * RTE_FLOW_ITEM_TYPE_VF
635 * Matches traffic originating from (ingress) or going to (egress) a given
636 * virtual function of the current device.
638 * If supported, should work even if the virtual function is not managed by
639 * the application and thus not associated with a DPDK port ID.
641 * Note this pattern item does not match VF representors traffic which, as
642 * separate entities, should be addressed through their own DPDK port IDs.
644 * - Can be specified multiple times to match traffic addressed to several
646 * - Can be combined with a PF item to match both PF and VF traffic.
648 * A zeroed mask can be used to match any VF ID.
650 struct rte_flow_item_vf {
651 uint32_t id; /**< VF ID. */
654 /** Default mask for RTE_FLOW_ITEM_TYPE_VF. */
656 static const struct rte_flow_item_vf rte_flow_item_vf_mask = {
662 * RTE_FLOW_ITEM_TYPE_PHY_PORT
664 * Matches traffic originating from (ingress) or going to (egress) a
665 * physical port of the underlying device.
667 * The first PHY_PORT item overrides the physical port normally associated
668 * with the specified DPDK input port (port_id). This item can be provided
669 * several times to match additional physical ports.
671 * Note that physical ports are not necessarily tied to DPDK input ports
672 * (port_id) when those are not under DPDK control. Possible values are
673 * specific to each device, they are not necessarily indexed from zero and
674 * may not be contiguous.
676 * As a device property, the list of allowed values as well as the value
677 * associated with a port_id should be retrieved by other means.
679 * A zeroed mask can be used to match any port index.
681 struct rte_flow_item_phy_port {
682 uint32_t index; /**< Physical port index. */
685 /** Default mask for RTE_FLOW_ITEM_TYPE_PHY_PORT. */
687 static const struct rte_flow_item_phy_port rte_flow_item_phy_port_mask = {
693 * RTE_FLOW_ITEM_TYPE_PORT_ID
695 * Matches traffic originating from (ingress) or going to (egress) a given
698 * Normally only supported if the port ID in question is known by the
699 * underlying PMD and related to the device the flow rule is created
702 * This must not be confused with @p PHY_PORT which refers to the physical
703 * port of a device, whereas @p PORT_ID refers to a struct rte_eth_dev
704 * object on the application side (also known as "port representor"
705 * depending on the kind of underlying device).
707 struct rte_flow_item_port_id {
708 uint32_t id; /**< DPDK port ID. */
711 /** Default mask for RTE_FLOW_ITEM_TYPE_PORT_ID. */
713 static const struct rte_flow_item_port_id rte_flow_item_port_id_mask = {
719 * RTE_FLOW_ITEM_TYPE_RAW
721 * Matches a byte string of a given length at a given offset.
723 * Offset is either absolute (using the start of the packet) or relative to
724 * the end of the previous matched item in the stack, in which case negative
725 * values are allowed.
727 * If search is enabled, offset is used as the starting point. The search
728 * area can be delimited by setting limit to a nonzero value, which is the
729 * maximum number of bytes after offset where the pattern may start.
731 * Matching a zero-length pattern is allowed, doing so resets the relative
732 * offset for subsequent items.
734 * This type does not support ranges (struct rte_flow_item.last).
736 struct rte_flow_item_raw {
737 uint32_t relative:1; /**< Look for pattern after the previous item. */
738 uint32_t search:1; /**< Search pattern from offset (see also limit). */
739 uint32_t reserved:30; /**< Reserved, must be set to zero. */
740 int32_t offset; /**< Absolute or relative offset for pattern. */
741 uint16_t limit; /**< Search area limit for start of pattern. */
742 uint16_t length; /**< Pattern length. */
743 const uint8_t *pattern; /**< Byte string to look for. */
746 /** Default mask for RTE_FLOW_ITEM_TYPE_RAW. */
748 static const struct rte_flow_item_raw rte_flow_item_raw_mask = {
751 .reserved = 0x3fffffff,
752 .offset = 0xffffffff,
760 * RTE_FLOW_ITEM_TYPE_ETH
762 * Matches an Ethernet header.
764 * Inside @p hdr field, the sub-field @p ether_type stands either for EtherType
765 * or TPID, depending on whether the item is followed by a VLAN item or not. If
766 * two VLAN items follow, the sub-field refers to the outer one, which, in turn,
767 * contains the inner TPID in the similar header field. The innermost VLAN item
768 * contains a layer-3 EtherType. All of that follows the order seen on the wire.
770 * If the field in question contains a TPID value, only tagged packets with the
771 * specified TPID will match the pattern. Alternatively, it's possible to match
772 * any type of tagged packets by means of the field @p has_vlan rather than use
773 * the EtherType/TPID field. Also, it's possible to leave the two fields unused.
774 * If this is the case, both tagged and untagged packets will match the pattern.
777 struct rte_flow_item_eth {
781 * These fields are retained for compatibility.
782 * Please switch to the new header field below.
784 struct rte_ether_addr dst; /**< Destination MAC. */
785 struct rte_ether_addr src; /**< Source MAC. */
786 rte_be16_t type; /**< EtherType or TPID. */
788 struct rte_ether_hdr hdr;
790 uint32_t has_vlan:1; /**< Packet header contains at least one VLAN. */
791 uint32_t reserved:31; /**< Reserved, must be zero. */
794 /** Default mask for RTE_FLOW_ITEM_TYPE_ETH. */
796 static const struct rte_flow_item_eth rte_flow_item_eth_mask = {
797 .hdr.dst_addr.addr_bytes = "\xff\xff\xff\xff\xff\xff",
798 .hdr.src_addr.addr_bytes = "\xff\xff\xff\xff\xff\xff",
799 .hdr.ether_type = RTE_BE16(0x0000),
804 * RTE_FLOW_ITEM_TYPE_VLAN
806 * Matches an 802.1Q/ad VLAN tag.
808 * The corresponding standard outer EtherType (TPID) values are
809 * RTE_ETHER_TYPE_VLAN or RTE_ETHER_TYPE_QINQ. It can be overridden by
810 * the preceding pattern item.
811 * If a @p VLAN item is present in the pattern, then only tagged packets will
813 * The field @p has_more_vlan can be used to match any type of tagged packets,
814 * instead of using the @p eth_proto field of @p hdr.
815 * If the @p eth_proto of @p hdr and @p has_more_vlan fields are not specified,
816 * then any tagged packets will match the pattern.
819 struct rte_flow_item_vlan {
823 * These fields are retained for compatibility.
824 * Please switch to the new header field below.
826 rte_be16_t tci; /**< Tag control information. */
827 rte_be16_t inner_type; /**< Inner EtherType or TPID. */
829 struct rte_vlan_hdr hdr;
831 uint32_t has_more_vlan:1;
832 /**< Packet header contains at least one more VLAN, after this VLAN. */
833 uint32_t reserved:31; /**< Reserved, must be zero. */
836 /** Default mask for RTE_FLOW_ITEM_TYPE_VLAN. */
838 static const struct rte_flow_item_vlan rte_flow_item_vlan_mask = {
839 .hdr.vlan_tci = RTE_BE16(0x0fff),
840 .hdr.eth_proto = RTE_BE16(0x0000),
845 * RTE_FLOW_ITEM_TYPE_IPV4
847 * Matches an IPv4 header.
849 * Note: IPv4 options are handled by dedicated pattern items.
851 struct rte_flow_item_ipv4 {
852 struct rte_ipv4_hdr hdr; /**< IPv4 header definition. */
855 /** Default mask for RTE_FLOW_ITEM_TYPE_IPV4. */
857 static const struct rte_flow_item_ipv4 rte_flow_item_ipv4_mask = {
859 .src_addr = RTE_BE32(0xffffffff),
860 .dst_addr = RTE_BE32(0xffffffff),
866 * RTE_FLOW_ITEM_TYPE_IPV6.
868 * Matches an IPv6 header.
870 * Dedicated flags indicate if header contains specific extension headers.
872 struct rte_flow_item_ipv6 {
873 struct rte_ipv6_hdr hdr; /**< IPv6 header definition. */
874 uint32_t has_hop_ext:1;
875 /**< Header contains Hop-by-Hop Options extension header. */
876 uint32_t has_route_ext:1;
877 /**< Header contains Routing extension header. */
878 uint32_t has_frag_ext:1;
879 /**< Header contains Fragment extension header. */
880 uint32_t has_auth_ext:1;
881 /**< Header contains Authentication extension header. */
882 uint32_t has_esp_ext:1;
883 /**< Header contains Encapsulation Security Payload extension header. */
884 uint32_t has_dest_ext:1;
885 /**< Header contains Destination Options extension header. */
886 uint32_t has_mobil_ext:1;
887 /**< Header contains Mobility extension header. */
888 uint32_t has_hip_ext:1;
889 /**< Header contains Host Identity Protocol extension header. */
890 uint32_t has_shim6_ext:1;
891 /**< Header contains Shim6 Protocol extension header. */
892 uint32_t reserved:23;
893 /**< Reserved for future extension headers, must be zero. */
896 /** Default mask for RTE_FLOW_ITEM_TYPE_IPV6. */
898 static const struct rte_flow_item_ipv6 rte_flow_item_ipv6_mask = {
901 "\xff\xff\xff\xff\xff\xff\xff\xff"
902 "\xff\xff\xff\xff\xff\xff\xff\xff",
904 "\xff\xff\xff\xff\xff\xff\xff\xff"
905 "\xff\xff\xff\xff\xff\xff\xff\xff",
911 * RTE_FLOW_ITEM_TYPE_ICMP.
913 * Matches an ICMP header.
915 struct rte_flow_item_icmp {
916 struct rte_icmp_hdr hdr; /**< ICMP header definition. */
919 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP. */
921 static const struct rte_flow_item_icmp rte_flow_item_icmp_mask = {
930 * RTE_FLOW_ITEM_TYPE_UDP.
932 * Matches a UDP header.
934 struct rte_flow_item_udp {
935 struct rte_udp_hdr hdr; /**< UDP header definition. */
938 /** Default mask for RTE_FLOW_ITEM_TYPE_UDP. */
940 static const struct rte_flow_item_udp rte_flow_item_udp_mask = {
942 .src_port = RTE_BE16(0xffff),
943 .dst_port = RTE_BE16(0xffff),
949 * RTE_FLOW_ITEM_TYPE_TCP.
951 * Matches a TCP header.
953 struct rte_flow_item_tcp {
954 struct rte_tcp_hdr hdr; /**< TCP header definition. */
957 /** Default mask for RTE_FLOW_ITEM_TYPE_TCP. */
959 static const struct rte_flow_item_tcp rte_flow_item_tcp_mask = {
961 .src_port = RTE_BE16(0xffff),
962 .dst_port = RTE_BE16(0xffff),
968 * RTE_FLOW_ITEM_TYPE_SCTP.
970 * Matches a SCTP header.
972 struct rte_flow_item_sctp {
973 struct rte_sctp_hdr hdr; /**< SCTP header definition. */
976 /** Default mask for RTE_FLOW_ITEM_TYPE_SCTP. */
978 static const struct rte_flow_item_sctp rte_flow_item_sctp_mask = {
980 .src_port = RTE_BE16(0xffff),
981 .dst_port = RTE_BE16(0xffff),
987 * RTE_FLOW_ITEM_TYPE_VXLAN.
989 * Matches a VXLAN header (RFC 7348).
992 struct rte_flow_item_vxlan {
996 * These fields are retained for compatibility.
997 * Please switch to the new header field below.
999 uint8_t flags; /**< Normally 0x08 (I flag). */
1000 uint8_t rsvd0[3]; /**< Reserved, normally 0x000000. */
1001 uint8_t vni[3]; /**< VXLAN identifier. */
1002 uint8_t rsvd1; /**< Reserved, normally 0x00. */
1004 struct rte_vxlan_hdr hdr;
1008 /** Default mask for RTE_FLOW_ITEM_TYPE_VXLAN. */
1010 static const struct rte_flow_item_vxlan rte_flow_item_vxlan_mask = {
1011 .hdr.vx_vni = RTE_BE32(0xffffff00), /* (0xffffff << 8) */
1016 * RTE_FLOW_ITEM_TYPE_E_TAG.
1018 * Matches a E-tag header.
1020 * The corresponding standard outer EtherType (TPID) value is
1021 * RTE_ETHER_TYPE_ETAG. It can be overridden by the preceding pattern item.
1023 struct rte_flow_item_e_tag {
1025 * E-Tag control information (E-TCI).
1026 * E-PCP (3b), E-DEI (1b), ingress E-CID base (12b).
1028 rte_be16_t epcp_edei_in_ecid_b;
1029 /** Reserved (2b), GRP (2b), E-CID base (12b). */
1030 rte_be16_t rsvd_grp_ecid_b;
1031 uint8_t in_ecid_e; /**< Ingress E-CID ext. */
1032 uint8_t ecid_e; /**< E-CID ext. */
1033 rte_be16_t inner_type; /**< Inner EtherType or TPID. */
1036 /** Default mask for RTE_FLOW_ITEM_TYPE_E_TAG. */
1038 static const struct rte_flow_item_e_tag rte_flow_item_e_tag_mask = {
1039 .rsvd_grp_ecid_b = RTE_BE16(0x3fff),
1044 * RTE_FLOW_ITEM_TYPE_NVGRE.
1046 * Matches a NVGRE header.
1048 struct rte_flow_item_nvgre {
1050 * Checksum (1b), undefined (1b), key bit (1b), sequence number (1b),
1051 * reserved 0 (9b), version (3b).
1053 * c_k_s_rsvd0_ver must have value 0x2000 according to RFC 7637.
1055 rte_be16_t c_k_s_rsvd0_ver;
1056 rte_be16_t protocol; /**< Protocol type (0x6558). */
1057 uint8_t tni[3]; /**< Virtual subnet ID. */
1058 uint8_t flow_id; /**< Flow ID. */
1061 /** Default mask for RTE_FLOW_ITEM_TYPE_NVGRE. */
1063 static const struct rte_flow_item_nvgre rte_flow_item_nvgre_mask = {
1064 .tni = "\xff\xff\xff",
1069 * RTE_FLOW_ITEM_TYPE_MPLS.
1071 * Matches a MPLS header.
1073 struct rte_flow_item_mpls {
1075 * Label (20b), TC (3b), Bottom of Stack (1b).
1077 uint8_t label_tc_s[3];
1078 uint8_t ttl; /** Time-to-Live. */
1081 /** Default mask for RTE_FLOW_ITEM_TYPE_MPLS. */
1083 static const struct rte_flow_item_mpls rte_flow_item_mpls_mask = {
1084 .label_tc_s = "\xff\xff\xf0",
1089 * RTE_FLOW_ITEM_TYPE_GRE.
1091 * Matches a GRE header.
1093 struct rte_flow_item_gre {
1095 * Checksum (1b), reserved 0 (12b), version (3b).
1096 * Refer to RFC 2784.
1098 rte_be16_t c_rsvd0_ver;
1099 rte_be16_t protocol; /**< Protocol type. */
1102 /** Default mask for RTE_FLOW_ITEM_TYPE_GRE. */
1104 static const struct rte_flow_item_gre rte_flow_item_gre_mask = {
1105 .protocol = RTE_BE16(0xffff),
1110 * RTE_FLOW_ITEM_TYPE_FUZZY
1112 * Fuzzy pattern match, expect faster than default.
1114 * This is for device that support fuzzy match option.
1115 * Usually a fuzzy match is fast but the cost is accuracy.
1116 * i.e. Signature Match only match pattern's hash value, but it is
1117 * possible two different patterns have the same hash value.
1119 * Matching accuracy level can be configure by threshold.
1120 * Driver can divide the range of threshold and map to different
1121 * accuracy levels that device support.
1123 * Threshold 0 means perfect match (no fuzziness), while threshold
1124 * 0xffffffff means fuzziest match.
1126 struct rte_flow_item_fuzzy {
1127 uint32_t thresh; /**< Accuracy threshold. */
1130 /** Default mask for RTE_FLOW_ITEM_TYPE_FUZZY. */
1132 static const struct rte_flow_item_fuzzy rte_flow_item_fuzzy_mask = {
1133 .thresh = 0xffffffff,
1138 * RTE_FLOW_ITEM_TYPE_GTP.
1140 * Matches a GTPv1 header.
1142 struct rte_flow_item_gtp {
1144 * Version (3b), protocol type (1b), reserved (1b),
1145 * Extension header flag (1b),
1146 * Sequence number flag (1b),
1147 * N-PDU number flag (1b).
1149 uint8_t v_pt_rsv_flags;
1150 uint8_t msg_type; /**< Message type. */
1151 rte_be16_t msg_len; /**< Message length. */
1152 rte_be32_t teid; /**< Tunnel endpoint identifier. */
1155 /** Default mask for RTE_FLOW_ITEM_TYPE_GTP. */
1157 static const struct rte_flow_item_gtp rte_flow_item_gtp_mask = {
1158 .teid = RTE_BE32(0xffffffff),
1163 * RTE_FLOW_ITEM_TYPE_ESP
1165 * Matches an ESP header.
1167 struct rte_flow_item_esp {
1168 struct rte_esp_hdr hdr; /**< ESP header definition. */
1171 /** Default mask for RTE_FLOW_ITEM_TYPE_ESP. */
1173 static const struct rte_flow_item_esp rte_flow_item_esp_mask = {
1175 .spi = RTE_BE32(0xffffffff),
1181 * RTE_FLOW_ITEM_TYPE_GENEVE.
1183 * Matches a GENEVE header.
1185 struct rte_flow_item_geneve {
1187 * Version (2b), length of the options fields (6b), OAM packet (1b),
1188 * critical options present (1b), reserved 0 (6b).
1190 rte_be16_t ver_opt_len_o_c_rsvd0;
1191 rte_be16_t protocol; /**< Protocol type. */
1192 uint8_t vni[3]; /**< Virtual Network Identifier. */
1193 uint8_t rsvd1; /**< Reserved, normally 0x00. */
1196 /** Default mask for RTE_FLOW_ITEM_TYPE_GENEVE. */
1198 static const struct rte_flow_item_geneve rte_flow_item_geneve_mask = {
1199 .vni = "\xff\xff\xff",
1204 * RTE_FLOW_ITEM_TYPE_VXLAN_GPE (draft-ietf-nvo3-vxlan-gpe-05).
1206 * Matches a VXLAN-GPE header.
1208 struct rte_flow_item_vxlan_gpe {
1209 uint8_t flags; /**< Normally 0x0c (I and P flags). */
1210 uint8_t rsvd0[2]; /**< Reserved, normally 0x0000. */
1211 uint8_t protocol; /**< Protocol type. */
1212 uint8_t vni[3]; /**< VXLAN identifier. */
1213 uint8_t rsvd1; /**< Reserved, normally 0x00. */
1216 /** Default mask for RTE_FLOW_ITEM_TYPE_VXLAN_GPE. */
1218 static const struct rte_flow_item_vxlan_gpe rte_flow_item_vxlan_gpe_mask = {
1219 .vni = "\xff\xff\xff",
1224 * RTE_FLOW_ITEM_TYPE_ARP_ETH_IPV4
1226 * Matches an ARP header for Ethernet/IPv4.
1228 struct rte_flow_item_arp_eth_ipv4 {
1229 rte_be16_t hrd; /**< Hardware type, normally 1. */
1230 rte_be16_t pro; /**< Protocol type, normally 0x0800. */
1231 uint8_t hln; /**< Hardware address length, normally 6. */
1232 uint8_t pln; /**< Protocol address length, normally 4. */
1233 rte_be16_t op; /**< Opcode (1 for request, 2 for reply). */
1234 struct rte_ether_addr sha; /**< Sender hardware address. */
1235 rte_be32_t spa; /**< Sender IPv4 address. */
1236 struct rte_ether_addr tha; /**< Target hardware address. */
1237 rte_be32_t tpa; /**< Target IPv4 address. */
1240 /** Default mask for RTE_FLOW_ITEM_TYPE_ARP_ETH_IPV4. */
1242 static const struct rte_flow_item_arp_eth_ipv4
1243 rte_flow_item_arp_eth_ipv4_mask = {
1244 .sha.addr_bytes = "\xff\xff\xff\xff\xff\xff",
1245 .spa = RTE_BE32(0xffffffff),
1246 .tha.addr_bytes = "\xff\xff\xff\xff\xff\xff",
1247 .tpa = RTE_BE32(0xffffffff),
1252 * RTE_FLOW_ITEM_TYPE_IPV6_EXT
1254 * Matches the presence of any IPv6 extension header.
1256 * Normally preceded by any of:
1258 * - RTE_FLOW_ITEM_TYPE_IPV6
1259 * - RTE_FLOW_ITEM_TYPE_IPV6_EXT
1261 struct rte_flow_item_ipv6_ext {
1262 uint8_t next_hdr; /**< Next header. */
1265 /** Default mask for RTE_FLOW_ITEM_TYPE_IPV6_EXT. */
1268 struct rte_flow_item_ipv6_ext rte_flow_item_ipv6_ext_mask = {
1274 * RTE_FLOW_ITEM_TYPE_IPV6_FRAG_EXT
1276 * Matches the presence of IPv6 fragment extension header.
1278 * Preceded by any of:
1280 * - RTE_FLOW_ITEM_TYPE_IPV6
1281 * - RTE_FLOW_ITEM_TYPE_IPV6_EXT
1283 struct rte_flow_item_ipv6_frag_ext {
1284 struct rte_ipv6_fragment_ext hdr;
1288 * RTE_FLOW_ITEM_TYPE_ICMP6
1290 * Matches any ICMPv6 header.
1292 struct rte_flow_item_icmp6 {
1293 uint8_t type; /**< ICMPv6 type. */
1294 uint8_t code; /**< ICMPv6 code. */
1295 uint16_t checksum; /**< ICMPv6 checksum. */
1298 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6. */
1300 static const struct rte_flow_item_icmp6 rte_flow_item_icmp6_mask = {
1307 * RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS
1309 * Matches an ICMPv6 neighbor discovery solicitation.
1311 struct rte_flow_item_icmp6_nd_ns {
1312 uint8_t type; /**< ICMPv6 type, normally 135. */
1313 uint8_t code; /**< ICMPv6 code, normally 0. */
1314 rte_be16_t checksum; /**< ICMPv6 checksum. */
1315 rte_be32_t reserved; /**< Reserved, normally 0. */
1316 uint8_t target_addr[16]; /**< Target address. */
1319 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS. */
1322 struct rte_flow_item_icmp6_nd_ns rte_flow_item_icmp6_nd_ns_mask = {
1324 "\xff\xff\xff\xff\xff\xff\xff\xff"
1325 "\xff\xff\xff\xff\xff\xff\xff\xff",
1330 * RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA
1332 * Matches an ICMPv6 neighbor discovery advertisement.
1334 struct rte_flow_item_icmp6_nd_na {
1335 uint8_t type; /**< ICMPv6 type, normally 136. */
1336 uint8_t code; /**< ICMPv6 code, normally 0. */
1337 rte_be16_t checksum; /**< ICMPv6 checksum. */
1339 * Route flag (1b), solicited flag (1b), override flag (1b),
1342 rte_be32_t rso_reserved;
1343 uint8_t target_addr[16]; /**< Target address. */
1346 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA. */
1349 struct rte_flow_item_icmp6_nd_na rte_flow_item_icmp6_nd_na_mask = {
1351 "\xff\xff\xff\xff\xff\xff\xff\xff"
1352 "\xff\xff\xff\xff\xff\xff\xff\xff",
1357 * RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT
1359 * Matches the presence of any ICMPv6 neighbor discovery option.
1361 * Normally preceded by any of:
1363 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA
1364 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS
1365 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT
1367 struct rte_flow_item_icmp6_nd_opt {
1368 uint8_t type; /**< ND option type. */
1369 uint8_t length; /**< ND option length. */
1372 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT. */
1374 static const struct rte_flow_item_icmp6_nd_opt
1375 rte_flow_item_icmp6_nd_opt_mask = {
1381 * RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_SLA_ETH
1383 * Matches an ICMPv6 neighbor discovery source Ethernet link-layer address
1386 * Normally preceded by any of:
1388 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA
1389 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT
1391 struct rte_flow_item_icmp6_nd_opt_sla_eth {
1392 uint8_t type; /**< ND option type, normally 1. */
1393 uint8_t length; /**< ND option length, normally 1. */
1394 struct rte_ether_addr sla; /**< Source Ethernet LLA. */
1397 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_SLA_ETH. */
1399 static const struct rte_flow_item_icmp6_nd_opt_sla_eth
1400 rte_flow_item_icmp6_nd_opt_sla_eth_mask = {
1401 .sla.addr_bytes = "\xff\xff\xff\xff\xff\xff",
1406 * RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_TLA_ETH
1408 * Matches an ICMPv6 neighbor discovery target Ethernet link-layer address
1411 * Normally preceded by any of:
1413 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS
1414 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT
1416 struct rte_flow_item_icmp6_nd_opt_tla_eth {
1417 uint8_t type; /**< ND option type, normally 2. */
1418 uint8_t length; /**< ND option length, normally 1. */
1419 struct rte_ether_addr tla; /**< Target Ethernet LLA. */
1422 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_TLA_ETH. */
1424 static const struct rte_flow_item_icmp6_nd_opt_tla_eth
1425 rte_flow_item_icmp6_nd_opt_tla_eth_mask = {
1426 .tla.addr_bytes = "\xff\xff\xff\xff\xff\xff",
1431 * RTE_FLOW_ITEM_TYPE_META
1433 * Matches a specified metadata value. On egress, metadata can be set
1434 * either by mbuf dynamic metadata field with PKT_TX_DYNF_METADATA flag or
1435 * RTE_FLOW_ACTION_TYPE_SET_META. On ingress, RTE_FLOW_ACTION_TYPE_SET_META
1436 * sets metadata for a packet and the metadata will be reported via mbuf
1437 * metadata dynamic field with PKT_RX_DYNF_METADATA flag. The dynamic mbuf
1438 * field must be registered in advance by rte_flow_dynf_metadata_register().
1440 struct rte_flow_item_meta {
1444 /** Default mask for RTE_FLOW_ITEM_TYPE_META. */
1446 static const struct rte_flow_item_meta rte_flow_item_meta_mask = {
1452 * RTE_FLOW_ITEM_TYPE_GTP_PSC.
1454 * Matches a GTP PDU extension header with type 0x85.
1456 struct rte_flow_item_gtp_psc {
1457 struct rte_gtp_psc_generic_hdr hdr; /**< gtp psc generic hdr. */
1460 /** Default mask for RTE_FLOW_ITEM_TYPE_GTP_PSC. */
1462 static const struct rte_flow_item_gtp_psc
1463 rte_flow_item_gtp_psc_mask = {
1469 * RTE_FLOW_ITEM_TYPE_PPPOE.
1471 * Matches a PPPoE header.
1473 struct rte_flow_item_pppoe {
1475 * Version (4b), type (4b).
1477 uint8_t version_type;
1478 uint8_t code; /**< Message type. */
1479 rte_be16_t session_id; /**< Session identifier. */
1480 rte_be16_t length; /**< Payload length. */
1484 * RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID.
1486 * Matches a PPPoE optional proto_id field.
1488 * It only applies to PPPoE session packets.
1490 * Normally preceded by any of:
1492 * - RTE_FLOW_ITEM_TYPE_PPPOE
1493 * - RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID
1495 struct rte_flow_item_pppoe_proto_id {
1496 rte_be16_t proto_id; /**< PPP protocol identifier. */
1499 /** Default mask for RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID. */
1501 static const struct rte_flow_item_pppoe_proto_id
1502 rte_flow_item_pppoe_proto_id_mask = {
1503 .proto_id = RTE_BE16(0xffff),
1509 * @b EXPERIMENTAL: this structure may change without prior notice
1511 * RTE_FLOW_ITEM_TYPE_TAG
1513 * Matches a specified tag value at the specified index.
1515 struct rte_flow_item_tag {
1520 /** Default mask for RTE_FLOW_ITEM_TYPE_TAG. */
1522 static const struct rte_flow_item_tag rte_flow_item_tag_mask = {
1529 * RTE_FLOW_ITEM_TYPE_L2TPV3OIP.
1531 * Matches a L2TPv3 over IP header.
1533 struct rte_flow_item_l2tpv3oip {
1534 rte_be32_t session_id; /**< Session ID. */
1537 /** Default mask for RTE_FLOW_ITEM_TYPE_L2TPV3OIP. */
1539 static const struct rte_flow_item_l2tpv3oip rte_flow_item_l2tpv3oip_mask = {
1540 .session_id = RTE_BE32(UINT32_MAX),
1547 * @b EXPERIMENTAL: this structure may change without prior notice
1549 * RTE_FLOW_ITEM_TYPE_MARK
1551 * Matches an arbitrary integer value which was set using the ``MARK`` action
1552 * in a previously matched rule.
1554 * This item can only be specified once as a match criteria as the ``MARK``
1555 * action can only be specified once in a flow action.
1557 * This value is arbitrary and application-defined. Maximum allowed value
1558 * depends on the underlying implementation.
1560 * Depending on the underlying implementation the MARK item may be supported on
1561 * the physical device, with virtual groups in the PMD or not at all.
1563 struct rte_flow_item_mark {
1564 uint32_t id; /**< Integer value to match against. */
1567 /** Default mask for RTE_FLOW_ITEM_TYPE_MARK. */
1569 static const struct rte_flow_item_mark rte_flow_item_mark_mask = {
1576 * @b EXPERIMENTAL: this structure may change without prior notice
1578 * RTE_FLOW_ITEM_TYPE_NSH
1580 * Match network service header (NSH), RFC 8300
1583 struct rte_flow_item_nsh {
1586 uint32_t reserved:1;
1589 uint32_t reserved1:4;
1591 uint32_t next_proto:8;
1596 /** Default mask for RTE_FLOW_ITEM_TYPE_NSH. */
1598 static const struct rte_flow_item_nsh rte_flow_item_nsh_mask = {
1608 * @b EXPERIMENTAL: this structure may change without prior notice
1610 * RTE_FLOW_ITEM_TYPE_IGMP
1612 * Match Internet Group Management Protocol (IGMP), RFC 2236
1615 struct rte_flow_item_igmp {
1617 uint32_t max_resp_time:8;
1618 uint32_t checksum:16;
1619 uint32_t group_addr;
1622 /** Default mask for RTE_FLOW_ITEM_TYPE_IGMP. */
1624 static const struct rte_flow_item_igmp rte_flow_item_igmp_mask = {
1625 .group_addr = 0xffffffff,
1631 * @b EXPERIMENTAL: this structure may change without prior notice
1633 * RTE_FLOW_ITEM_TYPE_AH
1635 * Match IP Authentication Header (AH), RFC 4302
1638 struct rte_flow_item_ah {
1639 uint32_t next_hdr:8;
1640 uint32_t payload_len:8;
1641 uint32_t reserved:16;
1646 /** Default mask for RTE_FLOW_ITEM_TYPE_AH. */
1648 static const struct rte_flow_item_ah rte_flow_item_ah_mask = {
1655 * @b EXPERIMENTAL: this structure may change without prior notice
1657 * RTE_FLOW_ITEM_TYPE_PFCP
1661 struct rte_flow_item_pfcp {
1668 /** Default mask for RTE_FLOW_ITEM_TYPE_PFCP. */
1670 static const struct rte_flow_item_pfcp rte_flow_item_pfcp_mask = {
1672 .seid = RTE_BE64(UINT64_C(0xffffffffffffffff)),
1678 * @b EXPERIMENTAL: this structure may change without prior notice
1680 * RTE_FLOW_ITEM_TYPE_ECPRI
1682 * Match eCPRI Header
1684 struct rte_flow_item_ecpri {
1685 struct rte_ecpri_combined_msg_hdr hdr;
1688 /** Default mask for RTE_FLOW_ITEM_TYPE_ECPRI. */
1690 static const struct rte_flow_item_ecpri rte_flow_item_ecpri_mask = {
1700 * RTE_FLOW_ITEM_TYPE_GENEVE_OPT
1702 * Matches a GENEVE Variable Length Option
1704 struct rte_flow_item_geneve_opt {
1705 rte_be16_t option_class;
1706 uint8_t option_type;
1711 /** Default mask for RTE_FLOW_ITEM_TYPE_GENEVE_OPT. */
1713 static const struct rte_flow_item_geneve_opt
1714 rte_flow_item_geneve_opt_mask = {
1715 .option_type = 0xff,
1721 * @b EXPERIMENTAL: this structure may change without prior notice
1723 * RTE_FLOW_ITEM_TYPE_INTEGRITY
1725 * Match on packet integrity check result.
1727 struct rte_flow_item_integrity {
1728 /** Tunnel encapsulation level the item should apply to.
1729 * @see rte_flow_action_rss
1736 /** The packet is valid after passing all HW checks. */
1737 uint64_t packet_ok:1;
1738 /** L2 layer is valid after passing all HW checks. */
1740 /** L3 layer is valid after passing all HW checks. */
1742 /** L4 layer is valid after passing all HW checks. */
1744 /** L2 layer CRC is valid. */
1745 uint64_t l2_crc_ok:1;
1746 /** IPv4 layer checksum is valid. */
1747 uint64_t ipv4_csum_ok:1;
1748 /** L4 layer checksum is valid. */
1749 uint64_t l4_csum_ok:1;
1750 /** L3 length is smaller than frame length. */
1751 uint64_t l3_len_ok:1;
1752 uint64_t reserved:56;
1759 static const struct rte_flow_item_integrity
1760 rte_flow_item_integrity_mask = {
1767 * The packet is valid after conntrack checking.
1769 #define RTE_FLOW_CONNTRACK_PKT_STATE_VALID RTE_BIT32(0)
1771 * The state of the connection is changed.
1773 #define RTE_FLOW_CONNTRACK_PKT_STATE_CHANGED RTE_BIT32(1)
1775 * Error is detected on this packet for this connection and
1776 * an invalid state is set.
1778 #define RTE_FLOW_CONNTRACK_PKT_STATE_INVALID RTE_BIT32(2)
1780 * The HW connection tracking module is disabled.
1781 * It can be due to application command or an invalid state.
1783 #define RTE_FLOW_CONNTRACK_PKT_STATE_DISABLED RTE_BIT32(3)
1785 * The packet contains some bad field(s) and cannot continue
1786 * with the conntrack module checking.
1788 #define RTE_FLOW_CONNTRACK_PKT_STATE_BAD RTE_BIT32(4)
1792 * @b EXPERIMENTAL: this structure may change without prior notice
1794 * RTE_FLOW_ITEM_TYPE_CONNTRACK
1796 * Matches the state of a packet after it passed the connection tracking
1797 * examination. The state is a bitmap of one RTE_FLOW_CONNTRACK_PKT_STATE*
1798 * or a reasonable combination of these bits.
1800 struct rte_flow_item_conntrack {
1804 /** Default mask for RTE_FLOW_ITEM_TYPE_CONNTRACK. */
1806 static const struct rte_flow_item_conntrack rte_flow_item_conntrack_mask = {
1807 .flags = 0xffffffff,
1813 * @b EXPERIMENTAL: this structure may change without prior notice
1815 * Provides an ethdev port ID for use with the following items:
1816 * RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR.
1818 struct rte_flow_item_ethdev {
1819 uint16_t port_id; /**< ethdev port ID */
1822 /** Default mask for items based on struct rte_flow_item_ethdev */
1824 static const struct rte_flow_item_ethdev rte_flow_item_ethdev_mask = {
1830 * Matching pattern item definition.
1832 * A pattern is formed by stacking items starting from the lowest protocol
1833 * layer to match. This stacking restriction does not apply to meta items
1834 * which can be placed anywhere in the stack without affecting the meaning
1835 * of the resulting pattern.
1837 * Patterns are terminated by END items.
1839 * The spec field should be a valid pointer to a structure of the related
1840 * item type. It may remain unspecified (NULL) in many cases to request
1841 * broad (nonspecific) matching. In such cases, last and mask must also be
1844 * Optionally, last can point to a structure of the same type to define an
1845 * inclusive range. This is mostly supported by integer and address fields,
1846 * may cause errors otherwise. Fields that do not support ranges must be set
1847 * to 0 or to the same value as the corresponding fields in spec.
1849 * Only the fields defined to nonzero values in the default masks (see
1850 * rte_flow_item_{name}_mask constants) are considered relevant by
1851 * default. This can be overridden by providing a mask structure of the
1852 * same type with applicable bits set to one. It can also be used to
1853 * partially filter out specific fields (e.g. as an alternate mean to match
1854 * ranges of IP addresses).
1856 * Mask is a simple bit-mask applied before interpreting the contents of
1857 * spec and last, which may yield unexpected results if not used
1858 * carefully. For example, if for an IPv4 address field, spec provides
1859 * 10.1.2.3, last provides 10.3.4.5 and mask provides 255.255.0.0, the
1860 * effective range becomes 10.1.0.0 to 10.3.255.255.
1862 struct rte_flow_item {
1863 enum rte_flow_item_type type; /**< Item type. */
1864 const void *spec; /**< Pointer to item specification structure. */
1865 const void *last; /**< Defines an inclusive range (spec to last). */
1866 const void *mask; /**< Bit-mask applied to spec and last. */
1872 * Each possible action is represented by a type.
1873 * An action can have an associated configuration object.
1874 * Several actions combined in a list can be assigned
1875 * to a flow rule and are performed in order.
1877 * They fall in three categories:
1879 * - Actions that modify the fate of matching traffic, for instance by
1880 * dropping or assigning it a specific destination.
1882 * - Actions that modify matching traffic contents or its properties. This
1883 * includes adding/removing encapsulation, encryption, compression and
1886 * - Actions related to the flow rule itself, such as updating counters or
1887 * making it non-terminating.
1889 * Flow rules being terminating by default, not specifying any action of the
1890 * fate kind results in undefined behavior. This applies to both ingress and
1893 * PASSTHRU, when supported, makes a flow rule non-terminating.
1895 enum rte_flow_action_type {
1897 * End marker for action lists. Prevents further processing of
1898 * actions, thereby ending the list.
1900 * No associated configuration structure.
1902 RTE_FLOW_ACTION_TYPE_END,
1905 * Used as a placeholder for convenience. It is ignored and simply
1906 * discarded by PMDs.
1908 * No associated configuration structure.
1910 RTE_FLOW_ACTION_TYPE_VOID,
1913 * Leaves traffic up for additional processing by subsequent flow
1914 * rules; makes a flow rule non-terminating.
1916 * No associated configuration structure.
1918 RTE_FLOW_ACTION_TYPE_PASSTHRU,
1921 * RTE_FLOW_ACTION_TYPE_JUMP
1923 * Redirects packets to a group on the current device.
1925 * See struct rte_flow_action_jump.
1927 RTE_FLOW_ACTION_TYPE_JUMP,
1930 * Attaches an integer value to packets and sets PKT_RX_FDIR and
1931 * PKT_RX_FDIR_ID mbuf flags.
1933 * See struct rte_flow_action_mark.
1935 * One should negotiate mark delivery from the NIC to the PMD.
1936 * @see rte_eth_rx_metadata_negotiate()
1937 * @see RTE_ETH_RX_METADATA_USER_MARK
1939 RTE_FLOW_ACTION_TYPE_MARK,
1942 * Flags packets. Similar to MARK without a specific value; only
1943 * sets the PKT_RX_FDIR mbuf flag.
1945 * No associated configuration structure.
1947 * One should negotiate flag delivery from the NIC to the PMD.
1948 * @see rte_eth_rx_metadata_negotiate()
1949 * @see RTE_ETH_RX_METADATA_USER_FLAG
1951 RTE_FLOW_ACTION_TYPE_FLAG,
1954 * Assigns packets to a given queue index.
1956 * See struct rte_flow_action_queue.
1958 RTE_FLOW_ACTION_TYPE_QUEUE,
1963 * PASSTHRU overrides this action if both are specified.
1965 * No associated configuration structure.
1967 RTE_FLOW_ACTION_TYPE_DROP,
1970 * Enables counters for this flow rule.
1972 * These counters can be retrieved and reset through rte_flow_query() or
1973 * rte_flow_action_handle_query() if the action provided via handle,
1974 * see struct rte_flow_query_count.
1976 * See struct rte_flow_action_count.
1978 RTE_FLOW_ACTION_TYPE_COUNT,
1981 * Similar to QUEUE, except RSS is additionally performed on packets
1982 * to spread them among several queues according to the provided
1985 * See struct rte_flow_action_rss.
1987 RTE_FLOW_ACTION_TYPE_RSS,
1990 * Directs matching traffic to the physical function (PF) of the
1993 * No associated configuration structure.
1995 RTE_FLOW_ACTION_TYPE_PF,
1998 * Directs matching traffic to a given virtual function of the
2001 * See struct rte_flow_action_vf.
2003 RTE_FLOW_ACTION_TYPE_VF,
2006 * Directs packets to a given physical port index of the underlying
2009 * See struct rte_flow_action_phy_port.
2011 RTE_FLOW_ACTION_TYPE_PHY_PORT,
2014 * Directs matching traffic to a given DPDK port ID.
2016 * See struct rte_flow_action_port_id.
2018 RTE_FLOW_ACTION_TYPE_PORT_ID,
2021 * Traffic metering and policing (MTR).
2023 * See struct rte_flow_action_meter.
2024 * See file rte_mtr.h for MTR object configuration.
2026 RTE_FLOW_ACTION_TYPE_METER,
2029 * Redirects packets to security engine of current device for security
2030 * processing as specified by security session.
2032 * See struct rte_flow_action_security.
2034 RTE_FLOW_ACTION_TYPE_SECURITY,
2037 * Implements OFPAT_SET_MPLS_TTL ("MPLS TTL") as defined by the
2038 * OpenFlow Switch Specification.
2040 * See struct rte_flow_action_of_set_mpls_ttl.
2042 RTE_FLOW_ACTION_TYPE_OF_SET_MPLS_TTL,
2045 * Implements OFPAT_DEC_MPLS_TTL ("decrement MPLS TTL") as defined
2046 * by the OpenFlow Switch Specification.
2048 * No associated configuration structure.
2050 RTE_FLOW_ACTION_TYPE_OF_DEC_MPLS_TTL,
2053 * Implements OFPAT_SET_NW_TTL ("IP TTL") as defined by the OpenFlow
2054 * Switch Specification.
2056 * See struct rte_flow_action_of_set_nw_ttl.
2058 RTE_FLOW_ACTION_TYPE_OF_SET_NW_TTL,
2061 * Implements OFPAT_DEC_NW_TTL ("decrement IP TTL") as defined by
2062 * the OpenFlow Switch Specification.
2064 * No associated configuration structure.
2066 RTE_FLOW_ACTION_TYPE_OF_DEC_NW_TTL,
2069 * Implements OFPAT_COPY_TTL_OUT ("copy TTL "outwards" -- from
2070 * next-to-outermost to outermost") as defined by the OpenFlow
2071 * Switch Specification.
2073 * No associated configuration structure.
2075 RTE_FLOW_ACTION_TYPE_OF_COPY_TTL_OUT,
2078 * Implements OFPAT_COPY_TTL_IN ("copy TTL "inwards" -- from
2079 * outermost to next-to-outermost") as defined by the OpenFlow
2080 * Switch Specification.
2082 * No associated configuration structure.
2084 RTE_FLOW_ACTION_TYPE_OF_COPY_TTL_IN,
2087 * Implements OFPAT_POP_VLAN ("pop the outer VLAN tag") as defined
2088 * by the OpenFlow Switch Specification.
2090 * No associated configuration structure.
2092 RTE_FLOW_ACTION_TYPE_OF_POP_VLAN,
2095 * Implements OFPAT_PUSH_VLAN ("push a new VLAN tag") as defined by
2096 * the OpenFlow Switch Specification.
2098 * See struct rte_flow_action_of_push_vlan.
2100 RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN,
2103 * Implements OFPAT_SET_VLAN_VID ("set the 802.1q VLAN id") as
2104 * defined by the OpenFlow Switch Specification.
2106 * See struct rte_flow_action_of_set_vlan_vid.
2108 RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID,
2111 * Implements OFPAT_SET_LAN_PCP ("set the 802.1q priority") as
2112 * defined by the OpenFlow Switch Specification.
2114 * See struct rte_flow_action_of_set_vlan_pcp.
2116 RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP,
2119 * Implements OFPAT_POP_MPLS ("pop the outer MPLS tag") as defined
2120 * by the OpenFlow Switch Specification.
2122 * See struct rte_flow_action_of_pop_mpls.
2124 RTE_FLOW_ACTION_TYPE_OF_POP_MPLS,
2127 * Implements OFPAT_PUSH_MPLS ("push a new MPLS tag") as defined by
2128 * the OpenFlow Switch Specification.
2130 * See struct rte_flow_action_of_push_mpls.
2132 RTE_FLOW_ACTION_TYPE_OF_PUSH_MPLS,
2135 * Encapsulate flow in VXLAN tunnel as defined in
2136 * rte_flow_action_vxlan_encap action structure.
2138 * See struct rte_flow_action_vxlan_encap.
2140 RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP,
2143 * Decapsulate outer most VXLAN tunnel from matched flow.
2145 * If flow pattern does not define a valid VXLAN tunnel (as specified by
2146 * RFC7348) then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION
2149 RTE_FLOW_ACTION_TYPE_VXLAN_DECAP,
2152 * Encapsulate flow in NVGRE tunnel defined in the
2153 * rte_flow_action_nvgre_encap action structure.
2155 * See struct rte_flow_action_nvgre_encap.
2157 RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP,
2160 * Decapsulate outer most NVGRE tunnel from matched flow.
2162 * If flow pattern does not define a valid NVGRE tunnel (as specified by
2163 * RFC7637) then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION
2166 RTE_FLOW_ACTION_TYPE_NVGRE_DECAP,
2169 * Add outer header whose template is provided in its data buffer
2171 * See struct rte_flow_action_raw_encap.
2173 RTE_FLOW_ACTION_TYPE_RAW_ENCAP,
2176 * Remove outer header whose template is provided in its data buffer.
2178 * See struct rte_flow_action_raw_decap
2180 RTE_FLOW_ACTION_TYPE_RAW_DECAP,
2183 * Modify IPv4 source address in the outermost IPv4 header.
2185 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV4,
2186 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2188 * See struct rte_flow_action_set_ipv4.
2190 RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC,
2193 * Modify IPv4 destination address in the outermost IPv4 header.
2195 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV4,
2196 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2198 * See struct rte_flow_action_set_ipv4.
2200 RTE_FLOW_ACTION_TYPE_SET_IPV4_DST,
2203 * Modify IPv6 source address in the outermost IPv6 header.
2205 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV6,
2206 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2208 * See struct rte_flow_action_set_ipv6.
2210 RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC,
2213 * Modify IPv6 destination address in the outermost IPv6 header.
2215 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV6,
2216 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2218 * See struct rte_flow_action_set_ipv6.
2220 RTE_FLOW_ACTION_TYPE_SET_IPV6_DST,
2223 * Modify source port number in the outermost TCP/UDP header.
2225 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_TCP
2226 * or RTE_FLOW_ITEM_TYPE_UDP, then the PMD should return a
2227 * RTE_FLOW_ERROR_TYPE_ACTION error.
2229 * See struct rte_flow_action_set_tp.
2231 RTE_FLOW_ACTION_TYPE_SET_TP_SRC,
2234 * Modify destination 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_DST,
2245 * Swap the source and destination MAC addresses in the outermost
2248 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_ETH,
2249 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2251 * No associated configuration structure.
2253 RTE_FLOW_ACTION_TYPE_MAC_SWAP,
2256 * Decrease TTL value directly
2258 * No associated configuration structure.
2260 RTE_FLOW_ACTION_TYPE_DEC_TTL,
2265 * See struct rte_flow_action_set_ttl
2267 RTE_FLOW_ACTION_TYPE_SET_TTL,
2270 * Set source MAC address from matched flow.
2272 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_ETH,
2273 * the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2275 * See struct rte_flow_action_set_mac.
2277 RTE_FLOW_ACTION_TYPE_SET_MAC_SRC,
2280 * Set destination MAC address from matched flow.
2282 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_ETH,
2283 * the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2285 * See struct rte_flow_action_set_mac.
2287 RTE_FLOW_ACTION_TYPE_SET_MAC_DST,
2290 * Increase sequence number in the outermost TCP header.
2292 * Action configuration specifies the value to increase
2293 * TCP sequence number as a big-endian 32 bit integer.
2296 * @code rte_be32_t * @endcode
2298 * Using this action on non-matching traffic will result in
2299 * undefined behavior.
2301 RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ,
2304 * Decrease sequence number in the outermost TCP header.
2306 * Action configuration specifies the value to decrease
2307 * TCP sequence number as a big-endian 32 bit integer.
2310 * @code rte_be32_t * @endcode
2312 * Using this action on non-matching traffic will result in
2313 * undefined behavior.
2315 RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ,
2318 * Increase acknowledgment number in the outermost TCP header.
2320 * Action configuration specifies the value to increase
2321 * TCP acknowledgment number as a big-endian 32 bit integer.
2324 * @code rte_be32_t * @endcode
2326 * Using this action on non-matching traffic will result in
2327 * undefined behavior.
2329 RTE_FLOW_ACTION_TYPE_INC_TCP_ACK,
2332 * Decrease acknowledgment number in the outermost TCP header.
2334 * Action configuration specifies the value to decrease
2335 * TCP acknowledgment number as a big-endian 32 bit integer.
2338 * @code rte_be32_t * @endcode
2340 * Using this action on non-matching traffic will result in
2341 * undefined behavior.
2343 RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK,
2348 * Tag is for internal flow usage only and
2349 * is not delivered to the application.
2351 * See struct rte_flow_action_set_tag.
2353 RTE_FLOW_ACTION_TYPE_SET_TAG,
2356 * Set metadata on ingress or egress path.
2358 * See struct rte_flow_action_set_meta.
2360 RTE_FLOW_ACTION_TYPE_SET_META,
2363 * Modify IPv4 DSCP in the outermost IP header.
2365 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV4,
2366 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2368 * See struct rte_flow_action_set_dscp.
2370 RTE_FLOW_ACTION_TYPE_SET_IPV4_DSCP,
2373 * Modify IPv6 DSCP in the outermost IP header.
2375 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV6,
2376 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2378 * See struct rte_flow_action_set_dscp.
2380 RTE_FLOW_ACTION_TYPE_SET_IPV6_DSCP,
2383 * Report as aged flow if timeout passed without any matching on the
2386 * See struct rte_flow_action_age.
2387 * See function rte_flow_get_aged_flows
2388 * see enum RTE_ETH_EVENT_FLOW_AGED
2389 * See struct rte_flow_query_age
2391 RTE_FLOW_ACTION_TYPE_AGE,
2394 * The matching packets will be duplicated with specified ratio and
2395 * applied with own set of actions with a fate action.
2397 * See struct rte_flow_action_sample.
2399 RTE_FLOW_ACTION_TYPE_SAMPLE,
2403 * @see RTE_FLOW_ACTION_TYPE_INDIRECT
2405 * Describe action shared across multiple flow rules.
2407 * Allow multiple rules reference the same action by handle (see
2408 * struct rte_flow_shared_action).
2410 RTE_FLOW_ACTION_TYPE_SHARED,
2413 * Modify a packet header field, tag, mark or metadata.
2415 * Allow the modification of an arbitrary header field via
2416 * set, add and sub operations or copying its content into
2417 * tag, meta or mark for future processing.
2419 * See struct rte_flow_action_modify_field.
2421 RTE_FLOW_ACTION_TYPE_MODIFY_FIELD,
2424 * An action handle is referenced in a rule through an indirect action.
2426 * The same action handle may be used in multiple rules for the same
2427 * or different ethdev ports.
2429 RTE_FLOW_ACTION_TYPE_INDIRECT,
2434 * Enable tracking a TCP connection state.
2436 * @see struct rte_flow_action_conntrack.
2438 RTE_FLOW_ACTION_TYPE_CONNTRACK,
2441 * Color the packet to reflect the meter color result.
2442 * Set the meter color in the mbuf to the selected color.
2444 * See struct rte_flow_action_meter_color.
2446 RTE_FLOW_ACTION_TYPE_METER_COLOR,
2450 * RTE_FLOW_ACTION_TYPE_MARK
2452 * Attaches an integer value to packets and sets PKT_RX_FDIR and
2453 * PKT_RX_FDIR_ID mbuf flags.
2455 * This value is arbitrary and application-defined. Maximum allowed value
2456 * depends on the underlying implementation. It is returned in the
2457 * hash.fdir.hi mbuf field.
2459 struct rte_flow_action_mark {
2460 uint32_t id; /**< Integer value to return with packets. */
2465 * @b EXPERIMENTAL: this structure may change without prior notice
2467 * RTE_FLOW_ACTION_TYPE_JUMP
2469 * Redirects packets to a group on the current device.
2471 * In a hierarchy of groups, which can be used to represent physical or logical
2472 * flow tables on the device, this action allows the action to be a redirect to
2473 * a group on that device.
2475 struct rte_flow_action_jump {
2480 * RTE_FLOW_ACTION_TYPE_QUEUE
2482 * Assign packets to a given queue index.
2484 struct rte_flow_action_queue {
2485 uint16_t index; /**< Queue index to use. */
2490 * @b EXPERIMENTAL: this structure may change without prior notice
2492 * RTE_FLOW_ACTION_TYPE_AGE
2494 * Report flow as aged-out if timeout passed without any matching
2495 * on the flow. RTE_ETH_EVENT_FLOW_AGED event is triggered when a
2496 * port detects new aged-out flows.
2498 * The flow context and the flow handle will be reported by the
2499 * rte_flow_get_aged_flows API.
2501 struct rte_flow_action_age {
2502 uint32_t timeout:24; /**< Time in seconds. */
2503 uint32_t reserved:8; /**< Reserved, must be zero. */
2505 /**< The user flow context, NULL means the rte_flow pointer. */
2509 * RTE_FLOW_ACTION_TYPE_AGE (query)
2511 * Query structure to retrieve the aging status information of a
2512 * shared AGE action, or a flow rule using the AGE action.
2514 struct rte_flow_query_age {
2515 uint32_t reserved:6; /**< Reserved, must be zero. */
2516 uint32_t aged:1; /**< 1 if aging timeout expired, 0 otherwise. */
2517 uint32_t sec_since_last_hit_valid:1;
2518 /**< sec_since_last_hit value is valid. */
2519 uint32_t sec_since_last_hit:24; /**< Seconds since last traffic hit. */
2524 * @b EXPERIMENTAL: this structure may change without prior notice
2526 * RTE_FLOW_ACTION_TYPE_COUNT
2528 * Adds a counter action to a matched flow.
2530 * If more than one count action is specified in a single flow rule, then each
2531 * action must specify a unique id.
2533 * Counters can be retrieved and reset through ``rte_flow_query()``, see
2534 * ``struct rte_flow_query_count``.
2536 * For ports within the same switch domain then the counter id namespace extends
2537 * to all ports within that switch domain.
2539 struct rte_flow_action_count {
2540 uint32_t id; /**< Counter ID. */
2544 * RTE_FLOW_ACTION_TYPE_COUNT (query)
2546 * Query structure to retrieve and reset flow rule counters.
2548 struct rte_flow_query_count {
2549 uint32_t reset:1; /**< Reset counters after query [in]. */
2550 uint32_t hits_set:1; /**< hits field is set [out]. */
2551 uint32_t bytes_set:1; /**< bytes field is set [out]. */
2552 uint32_t reserved:29; /**< Reserved, must be zero [in, out]. */
2553 uint64_t hits; /**< Number of hits for this rule [out]. */
2554 uint64_t bytes; /**< Number of bytes through this rule [out]. */
2558 * Hash function types.
2560 enum rte_eth_hash_function {
2561 RTE_ETH_HASH_FUNCTION_DEFAULT = 0,
2562 RTE_ETH_HASH_FUNCTION_TOEPLITZ, /**< Toeplitz */
2563 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR, /**< Simple XOR */
2565 * Symmetric Toeplitz: src, dst will be replaced by
2566 * xor(src, dst). For the case with src/dst only,
2567 * src or dst address will xor with zero pair.
2569 RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ,
2570 RTE_ETH_HASH_FUNCTION_MAX,
2574 * RTE_FLOW_ACTION_TYPE_RSS
2576 * Similar to QUEUE, except RSS is additionally performed on packets to
2577 * spread them among several queues according to the provided parameters.
2579 * Unlike global RSS settings used by other DPDK APIs, unsetting the
2580 * @p types field does not disable RSS in a flow rule. Doing so instead
2581 * requests safe unspecified "best-effort" settings from the underlying PMD,
2582 * which depending on the flow rule, may result in anything ranging from
2583 * empty (single queue) to all-inclusive RSS.
2585 * Note: RSS hash result is stored in the hash.rss mbuf field which overlaps
2586 * hash.fdir.lo. Since the MARK action sets the hash.fdir.hi field only,
2587 * both can be requested simultaneously.
2589 struct rte_flow_action_rss {
2590 enum rte_eth_hash_function func; /**< RSS hash function to apply. */
2592 * Packet encapsulation level RSS hash @p types apply to.
2594 * - @p 0 requests the default behavior. Depending on the packet
2595 * type, it can mean outermost, innermost, anything in between or
2598 * It basically stands for the innermost encapsulation level RSS
2599 * can be performed on according to PMD and device capabilities.
2601 * - @p 1 requests RSS to be performed on the outermost packet
2602 * encapsulation level.
2604 * - @p 2 and subsequent values request RSS to be performed on the
2605 * specified inner packet encapsulation level, from outermost to
2606 * innermost (lower to higher values).
2608 * Values other than @p 0 are not necessarily supported.
2610 * Requesting a specific RSS level on unrecognized traffic results
2611 * in undefined behavior. For predictable results, it is recommended
2612 * to make the flow rule pattern match packet headers up to the
2613 * requested encapsulation level so that only matching traffic goes
2617 uint64_t types; /**< Specific RSS hash types (see ETH_RSS_*). */
2618 uint32_t key_len; /**< Hash key length in bytes. */
2619 uint32_t queue_num; /**< Number of entries in @p queue. */
2620 const uint8_t *key; /**< Hash key. */
2621 const uint16_t *queue; /**< Queue indices to use. */
2625 * RTE_FLOW_ACTION_TYPE_VF
2627 * Directs matching traffic to a given virtual function of the current
2630 * Packets matched by a VF pattern item can be redirected to their original
2631 * VF ID instead of the specified one. This parameter may not be available
2632 * and is not guaranteed to work properly if the VF part is matched by a
2633 * prior flow rule or if packets are not addressed to a VF in the first
2636 struct rte_flow_action_vf {
2637 uint32_t original:1; /**< Use original VF ID if possible. */
2638 uint32_t reserved:31; /**< Reserved, must be zero. */
2639 uint32_t id; /**< VF ID. */
2643 * RTE_FLOW_ACTION_TYPE_PHY_PORT
2645 * Directs packets to a given physical port index of the underlying
2648 * @see RTE_FLOW_ITEM_TYPE_PHY_PORT
2650 struct rte_flow_action_phy_port {
2651 uint32_t original:1; /**< Use original port index if possible. */
2652 uint32_t reserved:31; /**< Reserved, must be zero. */
2653 uint32_t index; /**< Physical port index. */
2657 * RTE_FLOW_ACTION_TYPE_PORT_ID
2659 * Directs matching traffic to a given DPDK port ID.
2661 * @see RTE_FLOW_ITEM_TYPE_PORT_ID
2663 struct rte_flow_action_port_id {
2664 uint32_t original:1; /**< Use original DPDK port ID if possible. */
2665 uint32_t reserved:31; /**< Reserved, must be zero. */
2666 uint32_t id; /**< DPDK port ID. */
2670 * RTE_FLOW_ACTION_TYPE_METER
2672 * Traffic metering and policing (MTR).
2674 * Packets matched by items of this type can be either dropped or passed to the
2675 * next item with their color set by the MTR object.
2677 struct rte_flow_action_meter {
2678 uint32_t mtr_id; /**< MTR object ID created with rte_mtr_create(). */
2682 * RTE_FLOW_ACTION_TYPE_SECURITY
2684 * Perform the security action on flows matched by the pattern items
2685 * according to the configuration of the security session.
2687 * This action modifies the payload of matched flows. For INLINE_CRYPTO, the
2688 * security protocol headers and IV are fully provided by the application as
2689 * specified in the flow pattern. The payload of matching packets is
2690 * encrypted on egress, and decrypted and authenticated on ingress.
2691 * For INLINE_PROTOCOL, the security protocol is fully offloaded to HW,
2692 * providing full encapsulation and decapsulation of packets in security
2693 * protocols. The flow pattern specifies both the outer security header fields
2694 * and the inner packet fields. The security session specified in the action
2695 * must match the pattern parameters.
2697 * The security session specified in the action must be created on the same
2698 * port as the flow action that is being specified.
2700 * The ingress/egress flow attribute should match that specified in the
2701 * security session if the security session supports the definition of the
2704 * Multiple flows can be configured to use the same security session.
2706 * The NULL value is allowed for security session. If security session is NULL,
2707 * then SPI field in ESP flow item and IP addresses in flow items 'IPv4' and
2708 * 'IPv6' will be allowed to be a range. The rule thus created can enable
2709 * security processing on multiple flows.
2711 struct rte_flow_action_security {
2712 void *security_session; /**< Pointer to security session structure. */
2716 * RTE_FLOW_ACTION_TYPE_OF_SET_MPLS_TTL
2718 * Implements OFPAT_SET_MPLS_TTL ("MPLS TTL") as defined by the OpenFlow
2719 * Switch Specification.
2721 struct rte_flow_action_of_set_mpls_ttl {
2722 uint8_t mpls_ttl; /**< MPLS TTL. */
2726 * RTE_FLOW_ACTION_TYPE_OF_SET_NW_TTL
2728 * Implements OFPAT_SET_NW_TTL ("IP TTL") as defined by the OpenFlow Switch
2731 struct rte_flow_action_of_set_nw_ttl {
2732 uint8_t nw_ttl; /**< IP TTL. */
2736 * RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN
2738 * Implements OFPAT_PUSH_VLAN ("push a new VLAN tag") as defined by the
2739 * OpenFlow Switch Specification.
2741 struct rte_flow_action_of_push_vlan {
2742 rte_be16_t ethertype; /**< EtherType. */
2746 * RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID
2748 * Implements OFPAT_SET_VLAN_VID ("set the 802.1q VLAN id") as defined by
2749 * the OpenFlow Switch Specification.
2751 struct rte_flow_action_of_set_vlan_vid {
2752 rte_be16_t vlan_vid; /**< VLAN id. */
2756 * RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP
2758 * Implements OFPAT_SET_LAN_PCP ("set the 802.1q priority") as defined by
2759 * the OpenFlow Switch Specification.
2761 struct rte_flow_action_of_set_vlan_pcp {
2762 uint8_t vlan_pcp; /**< VLAN priority. */
2766 * RTE_FLOW_ACTION_TYPE_OF_POP_MPLS
2768 * Implements OFPAT_POP_MPLS ("pop the outer MPLS tag") as defined by the
2769 * OpenFlow Switch Specification.
2771 struct rte_flow_action_of_pop_mpls {
2772 rte_be16_t ethertype; /**< EtherType. */
2776 * RTE_FLOW_ACTION_TYPE_OF_PUSH_MPLS
2778 * Implements OFPAT_PUSH_MPLS ("push a new MPLS tag") as defined by the
2779 * OpenFlow Switch Specification.
2781 struct rte_flow_action_of_push_mpls {
2782 rte_be16_t ethertype; /**< EtherType. */
2787 * @b EXPERIMENTAL: this structure may change without prior notice
2789 * RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP
2791 * VXLAN tunnel end-point encapsulation data definition
2793 * The tunnel definition is provided through the flow item pattern, the
2794 * provided pattern must conform to RFC7348 for the tunnel specified. The flow
2795 * definition must be provided in order from the RTE_FLOW_ITEM_TYPE_ETH
2796 * definition up the end item which is specified by RTE_FLOW_ITEM_TYPE_END.
2798 * The mask field allows user to specify which fields in the flow item
2799 * definitions can be ignored and which have valid data and can be used
2802 * Note: the last field is not used in the definition of a tunnel and can be
2805 * Valid flow definition for RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP include:
2807 * - ETH / IPV4 / UDP / VXLAN / END
2808 * - ETH / IPV6 / UDP / VXLAN / END
2809 * - ETH / VLAN / IPV4 / UDP / VXLAN / END
2812 struct rte_flow_action_vxlan_encap {
2814 * Encapsulating vxlan tunnel definition
2815 * (terminated by the END pattern item).
2817 struct rte_flow_item *definition;
2822 * @b EXPERIMENTAL: this structure may change without prior notice
2824 * RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP
2826 * NVGRE tunnel end-point encapsulation data definition
2828 * The tunnel definition is provided through the flow item pattern the
2829 * provided pattern must conform with RFC7637. The flow definition must be
2830 * provided in order from the RTE_FLOW_ITEM_TYPE_ETH definition up the end item
2831 * which is specified by RTE_FLOW_ITEM_TYPE_END.
2833 * The mask field allows user to specify which fields in the flow item
2834 * definitions can be ignored and which have valid data and can be used
2837 * Note: the last field is not used in the definition of a tunnel and can be
2840 * Valid flow definition for RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP include:
2842 * - ETH / IPV4 / NVGRE / END
2843 * - ETH / VLAN / IPV6 / NVGRE / END
2846 struct rte_flow_action_nvgre_encap {
2848 * Encapsulating vxlan tunnel definition
2849 * (terminated by the END pattern item).
2851 struct rte_flow_item *definition;
2856 * @b EXPERIMENTAL: this structure may change without prior notice
2858 * RTE_FLOW_ACTION_TYPE_RAW_ENCAP
2860 * Raw tunnel end-point encapsulation data definition.
2862 * The data holds the headers definitions to be applied on the packet.
2863 * The data must start with ETH header up to the tunnel item header itself.
2864 * When used right after RAW_DECAP (for decapsulating L3 tunnel type for
2865 * example MPLSoGRE) the data will just hold layer 2 header.
2867 * The preserve parameter holds which bits in the packet the PMD is not allowed
2868 * to change, this parameter can also be NULL and then the PMD is allowed
2869 * to update any field.
2871 * size holds the number of bytes in @p data and @p preserve.
2873 struct rte_flow_action_raw_encap {
2874 uint8_t *data; /**< Encapsulation data. */
2875 uint8_t *preserve; /**< Bit-mask of @p data to preserve on output. */
2876 size_t size; /**< Size of @p data and @p preserve. */
2881 * @b EXPERIMENTAL: this structure may change without prior notice
2883 * RTE_FLOW_ACTION_TYPE_RAW_DECAP
2885 * Raw tunnel end-point decapsulation data definition.
2887 * The data holds the headers definitions to be removed from the packet.
2888 * The data must start with ETH header up to the tunnel item header itself.
2889 * When used right before RAW_DECAP (for encapsulating L3 tunnel type for
2890 * example MPLSoGRE) the data will just hold layer 2 header.
2892 * size holds the number of bytes in @p data.
2894 struct rte_flow_action_raw_decap {
2895 uint8_t *data; /**< Encapsulation data. */
2896 size_t size; /**< Size of @p data and @p preserve. */
2901 * @b EXPERIMENTAL: this structure may change without prior notice
2903 * RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC
2904 * RTE_FLOW_ACTION_TYPE_SET_IPV4_DST
2906 * Allows modification of IPv4 source (RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC)
2907 * and destination address (RTE_FLOW_ACTION_TYPE_SET_IPV4_DST) in the
2908 * specified outermost IPv4 header.
2910 struct rte_flow_action_set_ipv4 {
2911 rte_be32_t ipv4_addr;
2916 * @b EXPERIMENTAL: this structure may change without prior notice
2918 * RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC
2919 * RTE_FLOW_ACTION_TYPE_SET_IPV6_DST
2921 * Allows modification of IPv6 source (RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC)
2922 * and destination address (RTE_FLOW_ACTION_TYPE_SET_IPV6_DST) in the
2923 * specified outermost IPv6 header.
2925 struct rte_flow_action_set_ipv6 {
2926 uint8_t ipv6_addr[16];
2931 * @b EXPERIMENTAL: this structure may change without prior notice
2933 * RTE_FLOW_ACTION_TYPE_SET_TP_SRC
2934 * RTE_FLOW_ACTION_TYPE_SET_TP_DST
2936 * Allows modification of source (RTE_FLOW_ACTION_TYPE_SET_TP_SRC)
2937 * and destination (RTE_FLOW_ACTION_TYPE_SET_TP_DST) port numbers
2938 * in the specified outermost TCP/UDP header.
2940 struct rte_flow_action_set_tp {
2945 * RTE_FLOW_ACTION_TYPE_SET_TTL
2947 * Set the TTL value directly for IPv4 or IPv6
2949 struct rte_flow_action_set_ttl {
2954 * RTE_FLOW_ACTION_TYPE_SET_MAC
2956 * Set MAC address from the matched flow
2958 struct rte_flow_action_set_mac {
2959 uint8_t mac_addr[RTE_ETHER_ADDR_LEN];
2964 * @b EXPERIMENTAL: this structure may change without prior notice
2966 * RTE_FLOW_ACTION_TYPE_SET_TAG
2968 * Set a tag which is a transient data used during flow matching. This is not
2969 * delivered to application. Multiple tags are supported by specifying index.
2971 struct rte_flow_action_set_tag {
2979 * @b EXPERIMENTAL: this structure may change without prior notice
2981 * RTE_FLOW_ACTION_TYPE_SET_META
2983 * Set metadata. Metadata set by mbuf metadata dynamic field with
2984 * PKT_TX_DYNF_DATA flag on egress will be overridden by this action. On
2985 * ingress, the metadata will be carried by mbuf metadata dynamic field
2986 * with PKT_RX_DYNF_METADATA flag if set. The dynamic mbuf field must be
2987 * registered in advance by rte_flow_dynf_metadata_register().
2989 * Altering partial bits is supported with mask. For bits which have never
2990 * been set, unpredictable value will be seen depending on driver
2991 * implementation. For loopback/hairpin packet, metadata set on Rx/Tx may
2992 * or may not be propagated to the other path depending on HW capability.
2994 * RTE_FLOW_ITEM_TYPE_META matches metadata.
2996 struct rte_flow_action_set_meta {
3002 * RTE_FLOW_ACTION_TYPE_SET_IPV4_DSCP
3003 * RTE_FLOW_ACTION_TYPE_SET_IPV6_DSCP
3005 * Set the DSCP value for IPv4/IPv6 header.
3006 * DSCP in low 6 bits, rest ignored.
3008 struct rte_flow_action_set_dscp {
3014 * @b EXPERIMENTAL: this structure may change without prior notice
3016 * RTE_FLOW_ACTION_TYPE_INDIRECT
3018 * Opaque type returned after successfully creating an indirect action object.
3019 * The definition of the object handle is different per driver or
3020 * per direct action type.
3022 * This handle can be used to manage and query the related direct action:
3023 * - referenced in single flow rule or across multiple flow rules
3024 * over multiple ports
3025 * - update action object configuration
3026 * - query action object data
3027 * - destroy action object
3029 struct rte_flow_action_handle;
3032 * The state of a TCP connection.
3034 enum rte_flow_conntrack_state {
3035 /** SYN-ACK packet was seen. */
3036 RTE_FLOW_CONNTRACK_STATE_SYN_RECV,
3037 /** 3-way handshake was done. */
3038 RTE_FLOW_CONNTRACK_STATE_ESTABLISHED,
3039 /** First FIN packet was received to close the connection. */
3040 RTE_FLOW_CONNTRACK_STATE_FIN_WAIT,
3041 /** First FIN was ACKed. */
3042 RTE_FLOW_CONNTRACK_STATE_CLOSE_WAIT,
3043 /** Second FIN was received, waiting for the last ACK. */
3044 RTE_FLOW_CONNTRACK_STATE_LAST_ACK,
3045 /** Second FIN was ACKed, connection was closed. */
3046 RTE_FLOW_CONNTRACK_STATE_TIME_WAIT,
3050 * The last passed TCP packet flags of a connection.
3052 enum rte_flow_conntrack_tcp_last_index {
3053 RTE_FLOW_CONNTRACK_FLAG_NONE = 0, /**< No Flag. */
3054 RTE_FLOW_CONNTRACK_FLAG_SYN = RTE_BIT32(0), /**< With SYN flag. */
3055 RTE_FLOW_CONNTRACK_FLAG_SYNACK = RTE_BIT32(1), /**< With SYNACK flag. */
3056 RTE_FLOW_CONNTRACK_FLAG_FIN = RTE_BIT32(2), /**< With FIN flag. */
3057 RTE_FLOW_CONNTRACK_FLAG_ACK = RTE_BIT32(3), /**< With ACK flag. */
3058 RTE_FLOW_CONNTRACK_FLAG_RST = RTE_BIT32(4), /**< With RST flag. */
3063 * @b EXPERIMENTAL: this structure may change without prior notice
3065 * Configuration parameters for each direction of a TCP connection.
3066 * All fields should be in host byte order.
3067 * If needed, driver should convert all fields to network byte order
3068 * if HW needs them in that way.
3070 struct rte_flow_tcp_dir_param {
3071 /** TCP window scaling factor, 0xF to disable. */
3073 /** The FIN was sent by this direction. */
3074 uint32_t close_initiated:1;
3075 /** An ACK packet has been received by this side. */
3076 uint32_t last_ack_seen:1;
3078 * If set, it indicates that there is unacknowledged data for the
3079 * packets sent from this direction.
3081 uint32_t data_unacked:1;
3083 * Maximal value of sequence + payload length in sent
3084 * packets (next ACK from the opposite direction).
3088 * Maximal value of (ACK + window size) in received packet + length
3089 * over sent packet (maximal sequence could be sent).
3092 /** Maximal value of actual window size in sent packets. */
3094 /** Maximal value of ACK in sent packets. */
3100 * @b EXPERIMENTAL: this structure may change without prior notice
3102 * RTE_FLOW_ACTION_TYPE_CONNTRACK
3104 * Configuration and initial state for the connection tracking module.
3105 * This structure could be used for both setting and query.
3106 * All fields should be in host byte order.
3108 struct rte_flow_action_conntrack {
3109 /** The peer port number, can be the same port. */
3112 * Direction of this connection when creating a flow rule, the
3113 * value only affects the creation of subsequent flow rules.
3115 uint32_t is_original_dir:1;
3117 * Enable / disable the conntrack HW module. When disabled, the
3118 * result will always be RTE_FLOW_CONNTRACK_FLAG_DISABLED.
3119 * In this state the HW will act as passthrough.
3120 * It only affects this conntrack object in the HW without any effect
3121 * to the other objects.
3124 /** At least one ack was seen after the connection was established. */
3125 uint32_t live_connection:1;
3126 /** Enable selective ACK on this connection. */
3127 uint32_t selective_ack:1;
3128 /** A challenge ack has passed. */
3129 uint32_t challenge_ack_passed:1;
3131 * 1: The last packet is seen from the original direction.
3132 * 0: The last packet is seen from the reply direction.
3134 uint32_t last_direction:1;
3135 /** No TCP check will be done except the state change. */
3136 uint32_t liberal_mode:1;
3137 /**<The current state of this connection. */
3138 enum rte_flow_conntrack_state state;
3139 /** Scaling factor for maximal allowed ACK window. */
3140 uint8_t max_ack_window;
3141 /** Maximal allowed number of retransmission times. */
3142 uint8_t retransmission_limit;
3143 /** TCP parameters of the original direction. */
3144 struct rte_flow_tcp_dir_param original_dir;
3145 /** TCP parameters of the reply direction. */
3146 struct rte_flow_tcp_dir_param reply_dir;
3147 /** The window value of the last packet passed this conntrack. */
3148 uint16_t last_window;
3149 enum rte_flow_conntrack_tcp_last_index last_index;
3150 /** The sequence of the last packet passed this conntrack. */
3152 /** The acknowledgment of the last packet passed this conntrack. */
3155 * The total value ACK + payload length of the last packet
3156 * passed this conntrack.
3162 * RTE_FLOW_ACTION_TYPE_CONNTRACK
3164 * Wrapper structure for the context update interface.
3165 * Ports cannot support updating, and the only valid solution is to
3166 * destroy the old context and create a new one instead.
3168 struct rte_flow_modify_conntrack {
3169 /** New connection tracking parameters to be updated. */
3170 struct rte_flow_action_conntrack new_ct;
3171 /** The direction field will be updated. */
3172 uint32_t direction:1;
3173 /** All the other fields except direction will be updated. */
3175 /** Reserved bits for the future usage. */
3176 uint32_t reserved:30;
3181 * @b EXPERIMENTAL: this structure may change without prior notice
3183 * RTE_FLOW_ACTION_TYPE_METER_COLOR
3185 * The meter color should be set in the packet meta-data
3186 * (i.e. struct rte_mbuf::sched::color).
3188 struct rte_flow_action_meter_color {
3189 enum rte_color color; /**< Packet color. */
3193 * Field IDs for MODIFY_FIELD action.
3195 enum rte_flow_field_id {
3196 RTE_FLOW_FIELD_START = 0, /**< Start of a packet. */
3197 RTE_FLOW_FIELD_MAC_DST, /**< Destination MAC Address. */
3198 RTE_FLOW_FIELD_MAC_SRC, /**< Source MAC Address. */
3199 RTE_FLOW_FIELD_VLAN_TYPE, /**< 802.1Q Tag Identifier. */
3200 RTE_FLOW_FIELD_VLAN_ID, /**< 802.1Q VLAN Identifier. */
3201 RTE_FLOW_FIELD_MAC_TYPE, /**< EtherType. */
3202 RTE_FLOW_FIELD_IPV4_DSCP, /**< IPv4 DSCP. */
3203 RTE_FLOW_FIELD_IPV4_TTL, /**< IPv4 Time To Live. */
3204 RTE_FLOW_FIELD_IPV4_SRC, /**< IPv4 Source Address. */
3205 RTE_FLOW_FIELD_IPV4_DST, /**< IPv4 Destination Address. */
3206 RTE_FLOW_FIELD_IPV6_DSCP, /**< IPv6 DSCP. */
3207 RTE_FLOW_FIELD_IPV6_HOPLIMIT, /**< IPv6 Hop Limit. */
3208 RTE_FLOW_FIELD_IPV6_SRC, /**< IPv6 Source Address. */
3209 RTE_FLOW_FIELD_IPV6_DST, /**< IPv6 Destination Address. */
3210 RTE_FLOW_FIELD_TCP_PORT_SRC, /**< TCP Source Port Number. */
3211 RTE_FLOW_FIELD_TCP_PORT_DST, /**< TCP Destination Port Number. */
3212 RTE_FLOW_FIELD_TCP_SEQ_NUM, /**< TCP Sequence Number. */
3213 RTE_FLOW_FIELD_TCP_ACK_NUM, /**< TCP Acknowledgment Number. */
3214 RTE_FLOW_FIELD_TCP_FLAGS, /**< TCP Flags. */
3215 RTE_FLOW_FIELD_UDP_PORT_SRC, /**< UDP Source Port Number. */
3216 RTE_FLOW_FIELD_UDP_PORT_DST, /**< UDP Destination Port Number. */
3217 RTE_FLOW_FIELD_VXLAN_VNI, /**< VXLAN Network Identifier. */
3218 RTE_FLOW_FIELD_GENEVE_VNI, /**< GENEVE Network Identifier. */
3219 RTE_FLOW_FIELD_GTP_TEID, /**< GTP Tunnel Endpoint Identifier. */
3220 RTE_FLOW_FIELD_TAG, /**< Tag value. */
3221 RTE_FLOW_FIELD_MARK, /**< Mark value. */
3222 RTE_FLOW_FIELD_META, /**< Metadata value. */
3223 RTE_FLOW_FIELD_POINTER, /**< Memory pointer. */
3224 RTE_FLOW_FIELD_VALUE, /**< Immediate value. */
3228 * Field description for MODIFY_FIELD action.
3230 struct rte_flow_action_modify_data {
3231 enum rte_flow_field_id field; /**< Field or memory type ID. */
3235 /**< Encapsulation level or tag index. */
3237 /**< Number of bits to skip from a field. */
3241 * Immediate value for RTE_FLOW_FIELD_VALUE or
3242 * memory address for RTE_FLOW_FIELD_POINTER.
3249 * Operation types for MODIFY_FIELD action.
3251 enum rte_flow_modify_op {
3252 RTE_FLOW_MODIFY_SET = 0, /**< Set a new value. */
3253 RTE_FLOW_MODIFY_ADD, /**< Add a value to a field. */
3254 RTE_FLOW_MODIFY_SUB, /**< Subtract a value from a field. */
3259 * @b EXPERIMENTAL: this structure may change without prior notice
3261 * RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
3263 * Modify a destination header field according to the specified
3264 * operation. Another packet field can be used as a source as well
3265 * as tag, mark, metadata, immediate value or a pointer to it.
3267 struct rte_flow_action_modify_field {
3268 enum rte_flow_modify_op operation; /**< Operation to perform. */
3269 struct rte_flow_action_modify_data dst; /**< Destination field. */
3270 struct rte_flow_action_modify_data src; /**< Source field. */
3271 uint32_t width; /**< Number of bits to use from a source field. */
3274 /* Mbuf dynamic field offset for metadata. */
3275 extern int32_t rte_flow_dynf_metadata_offs;
3277 /* Mbuf dynamic field flag mask for metadata. */
3278 extern uint64_t rte_flow_dynf_metadata_mask;
3280 /* Mbuf dynamic field pointer for metadata. */
3281 #define RTE_FLOW_DYNF_METADATA(m) \
3282 RTE_MBUF_DYNFIELD((m), rte_flow_dynf_metadata_offs, uint32_t *)
3284 /* Mbuf dynamic flags for metadata. */
3285 #define PKT_RX_DYNF_METADATA (rte_flow_dynf_metadata_mask)
3286 #define PKT_TX_DYNF_METADATA (rte_flow_dynf_metadata_mask)
3289 static inline uint32_t
3290 rte_flow_dynf_metadata_get(struct rte_mbuf *m)
3292 return *RTE_FLOW_DYNF_METADATA(m);
3297 rte_flow_dynf_metadata_set(struct rte_mbuf *m, uint32_t v)
3299 *RTE_FLOW_DYNF_METADATA(m) = v;
3303 * Definition of a single action.
3305 * A list of actions is terminated by a END action.
3307 * For simple actions without a configuration object, conf remains NULL.
3309 struct rte_flow_action {
3310 enum rte_flow_action_type type; /**< Action type. */
3311 const void *conf; /**< Pointer to action configuration object. */
3315 * Opaque type returned after successfully creating a flow.
3317 * This handle can be used to manage and query the related flow (e.g. to
3318 * destroy it or retrieve counters).
3324 * @b EXPERIMENTAL: this structure may change without prior notice
3326 * RTE_FLOW_ACTION_TYPE_SAMPLE
3328 * Adds a sample action to a matched flow.
3330 * The matching packets will be duplicated with specified ratio and applied
3331 * with own set of actions with a fate action, the sampled packet could be
3332 * redirected to queue or port. All the packets continue processing on the
3333 * default flow path.
3335 * When the sample ratio is set to 1 then the packets will be 100% mirrored.
3336 * Additional action list be supported to add for sampled or mirrored packets.
3338 struct rte_flow_action_sample {
3339 uint32_t ratio; /**< packets sampled equals to '1/ratio'. */
3340 const struct rte_flow_action *actions;
3341 /**< sub-action list specific for the sampling hit cases. */
3345 * Verbose error types.
3347 * Most of them provide the type of the object referenced by struct
3348 * rte_flow_error.cause.
3350 enum rte_flow_error_type {
3351 RTE_FLOW_ERROR_TYPE_NONE, /**< No error. */
3352 RTE_FLOW_ERROR_TYPE_UNSPECIFIED, /**< Cause unspecified. */
3353 RTE_FLOW_ERROR_TYPE_HANDLE, /**< Flow rule (handle). */
3354 RTE_FLOW_ERROR_TYPE_ATTR_GROUP, /**< Group field. */
3355 RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY, /**< Priority field. */
3356 RTE_FLOW_ERROR_TYPE_ATTR_INGRESS, /**< Ingress field. */
3357 RTE_FLOW_ERROR_TYPE_ATTR_EGRESS, /**< Egress field. */
3358 RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, /**< Transfer field. */
3359 RTE_FLOW_ERROR_TYPE_ATTR, /**< Attributes structure. */
3360 RTE_FLOW_ERROR_TYPE_ITEM_NUM, /**< Pattern length. */
3361 RTE_FLOW_ERROR_TYPE_ITEM_SPEC, /**< Item specification. */
3362 RTE_FLOW_ERROR_TYPE_ITEM_LAST, /**< Item specification range. */
3363 RTE_FLOW_ERROR_TYPE_ITEM_MASK, /**< Item specification mask. */
3364 RTE_FLOW_ERROR_TYPE_ITEM, /**< Specific pattern item. */
3365 RTE_FLOW_ERROR_TYPE_ACTION_NUM, /**< Number of actions. */
3366 RTE_FLOW_ERROR_TYPE_ACTION_CONF, /**< Action configuration. */
3367 RTE_FLOW_ERROR_TYPE_ACTION, /**< Specific action. */
3371 * Verbose error structure definition.
3373 * This object is normally allocated by applications and set by PMDs, the
3374 * message points to a constant string which does not need to be freed by
3375 * the application, however its pointer can be considered valid only as long
3376 * as its associated DPDK port remains configured. Closing the underlying
3377 * device or unloading the PMD invalidates it.
3379 * Both cause and message may be NULL regardless of the error type.
3381 struct rte_flow_error {
3382 enum rte_flow_error_type type; /**< Cause field and error types. */
3383 const void *cause; /**< Object responsible for the error. */
3384 const char *message; /**< Human-readable error message. */
3388 * Complete flow rule description.
3390 * This object type is used when converting a flow rule description.
3392 * @see RTE_FLOW_CONV_OP_RULE
3393 * @see rte_flow_conv()
3396 struct rte_flow_conv_rule {
3398 const struct rte_flow_attr *attr_ro; /**< RO attributes. */
3399 struct rte_flow_attr *attr; /**< Attributes. */
3402 const struct rte_flow_item *pattern_ro; /**< RO pattern. */
3403 struct rte_flow_item *pattern; /**< Pattern items. */
3406 const struct rte_flow_action *actions_ro; /**< RO actions. */
3407 struct rte_flow_action *actions; /**< List of actions. */
3412 * Conversion operations for flow API objects.
3414 * @see rte_flow_conv()
3416 enum rte_flow_conv_op {
3418 * No operation to perform.
3420 * rte_flow_conv() simply returns 0.
3422 RTE_FLOW_CONV_OP_NONE,
3425 * Convert attributes structure.
3427 * This is a basic copy of an attributes structure.
3430 * @code const struct rte_flow_attr * @endcode
3432 * @code struct rte_flow_attr * @endcode
3434 RTE_FLOW_CONV_OP_ATTR,
3437 * Convert a single item.
3439 * Duplicates @p spec, @p last and @p mask but not outside objects.
3442 * @code const struct rte_flow_item * @endcode
3444 * @code struct rte_flow_item * @endcode
3446 RTE_FLOW_CONV_OP_ITEM,
3449 * Convert a single action.
3451 * Duplicates @p conf but not outside objects.
3454 * @code const struct rte_flow_action * @endcode
3456 * @code struct rte_flow_action * @endcode
3458 RTE_FLOW_CONV_OP_ACTION,
3461 * Convert an entire pattern.
3463 * Duplicates all pattern items at once with the same constraints as
3464 * RTE_FLOW_CONV_OP_ITEM.
3467 * @code const struct rte_flow_item * @endcode
3469 * @code struct rte_flow_item * @endcode
3471 RTE_FLOW_CONV_OP_PATTERN,
3474 * Convert a list of actions.
3476 * Duplicates the entire list of actions at once with the same
3477 * constraints as RTE_FLOW_CONV_OP_ACTION.
3480 * @code const struct rte_flow_action * @endcode
3482 * @code struct rte_flow_action * @endcode
3484 RTE_FLOW_CONV_OP_ACTIONS,
3487 * Convert a complete flow rule description.
3489 * Comprises attributes, pattern and actions together at once with
3490 * the usual constraints.
3493 * @code const struct rte_flow_conv_rule * @endcode
3495 * @code struct rte_flow_conv_rule * @endcode
3497 RTE_FLOW_CONV_OP_RULE,
3500 * Convert item type to its name string.
3502 * Writes a NUL-terminated string to @p dst. Like snprintf(), the
3503 * returned value excludes the terminator which is always written
3507 * @code (const void *)enum rte_flow_item_type @endcode
3509 * @code char * @endcode
3511 RTE_FLOW_CONV_OP_ITEM_NAME,
3514 * Convert action type to its name string.
3516 * Writes a NUL-terminated string to @p dst. Like snprintf(), the
3517 * returned value excludes the terminator which is always written
3521 * @code (const void *)enum rte_flow_action_type @endcode
3523 * @code char * @endcode
3525 RTE_FLOW_CONV_OP_ACTION_NAME,
3528 * Convert item type to pointer to item name.
3530 * Retrieves item name pointer from its type. The string itself is
3531 * not copied; instead, a unique pointer to an internal static
3532 * constant storage is written to @p dst.
3535 * @code (const void *)enum rte_flow_item_type @endcode
3537 * @code const char ** @endcode
3539 RTE_FLOW_CONV_OP_ITEM_NAME_PTR,
3542 * Convert action type to pointer to action name.
3544 * Retrieves action name pointer from its type. The string itself is
3545 * not copied; instead, a unique pointer to an internal static
3546 * constant storage is written to @p dst.
3549 * @code (const void *)enum rte_flow_action_type @endcode
3551 * @code const char ** @endcode
3553 RTE_FLOW_CONV_OP_ACTION_NAME_PTR,
3558 * @b EXPERIMENTAL: this API may change without prior notice.
3560 * Dump hardware internal representation information of
3563 * @param[in] port_id
3564 * The port identifier of the Ethernet device.
3566 * The pointer of flow rule to dump. Dump all rules if NULL.
3568 * A pointer to a file for output.
3570 * Perform verbose error reporting if not NULL. PMDs initialize this
3571 * structure in case of error only.
3573 * 0 on success, a nagative value otherwise.
3577 rte_flow_dev_dump(uint16_t port_id, struct rte_flow *flow,
3578 FILE *file, struct rte_flow_error *error);
3581 * Check if mbuf dynamic field for metadata is registered.
3584 * True if registered, false otherwise.
3588 rte_flow_dynf_metadata_avail(void)
3590 return !!rte_flow_dynf_metadata_mask;
3594 * Register mbuf dynamic field and flag for metadata.
3596 * This function must be called prior to use SET_META action in order to
3597 * register the dynamic mbuf field. Otherwise, the data cannot be delivered to
3601 * 0 on success, a negative errno value otherwise and rte_errno is set.
3605 rte_flow_dynf_metadata_register(void);
3608 * Check whether a flow rule can be created on a given port.
3610 * The flow rule is validated for correctness and whether it could be accepted
3611 * by the device given sufficient resources. The rule is checked against the
3612 * current device mode and queue configuration. The flow rule may also
3613 * optionally be validated against existing flow rules and device resources.
3614 * This function has no effect on the target device.
3616 * The returned value is guaranteed to remain valid only as long as no
3617 * successful calls to rte_flow_create() or rte_flow_destroy() are made in
3618 * the meantime and no device parameter affecting flow rules in any way are
3619 * modified, due to possible collisions or resource limitations (although in
3620 * such cases EINVAL should not be returned).
3623 * Port identifier of Ethernet device.
3625 * Flow rule attributes.
3626 * @param[in] pattern
3627 * Pattern specification (list terminated by the END pattern item).
3628 * @param[in] actions
3629 * Associated actions (list terminated by the END action).
3631 * Perform verbose error reporting if not NULL. PMDs initialize this
3632 * structure in case of error only.
3635 * 0 if flow rule is valid and can be created. A negative errno value
3636 * otherwise (rte_errno is also set), the following errors are defined:
3638 * -ENOSYS: underlying device does not support this functionality.
3640 * -EIO: underlying device is removed.
3642 * -EINVAL: unknown or invalid rule specification.
3644 * -ENOTSUP: valid but unsupported rule specification (e.g. partial
3645 * bit-masks are unsupported).
3647 * -EEXIST: collision with an existing rule. Only returned if device
3648 * supports flow rule collision checking and there was a flow rule
3649 * collision. Not receiving this return code is no guarantee that creating
3650 * the rule will not fail due to a collision.
3652 * -ENOMEM: not enough memory to execute the function, or if the device
3653 * supports resource validation, resource limitation on the device.
3655 * -EBUSY: action cannot be performed due to busy device resources, may
3656 * succeed if the affected queues or even the entire port are in a stopped
3657 * state (see rte_eth_dev_rx_queue_stop() and rte_eth_dev_stop()).
3660 rte_flow_validate(uint16_t port_id,
3661 const struct rte_flow_attr *attr,
3662 const struct rte_flow_item pattern[],
3663 const struct rte_flow_action actions[],
3664 struct rte_flow_error *error);
3667 * Create a flow rule on a given port.
3670 * Port identifier of Ethernet device.
3672 * Flow rule attributes.
3673 * @param[in] pattern
3674 * Pattern specification (list terminated by the END pattern item).
3675 * @param[in] actions
3676 * Associated actions (list terminated by the END action).
3678 * Perform verbose error reporting if not NULL. PMDs initialize this
3679 * structure in case of error only.
3682 * A valid handle in case of success, NULL otherwise and rte_errno is set
3683 * to the positive version of one of the error codes defined for
3684 * rte_flow_validate().
3687 rte_flow_create(uint16_t port_id,
3688 const struct rte_flow_attr *attr,
3689 const struct rte_flow_item pattern[],
3690 const struct rte_flow_action actions[],
3691 struct rte_flow_error *error);
3694 * Destroy a flow rule on a given port.
3696 * Failure to destroy a flow rule handle may occur when other flow rules
3697 * depend on it, and destroying it would result in an inconsistent state.
3699 * This function is only guaranteed to succeed if handles are destroyed in
3700 * reverse order of their creation.
3703 * Port identifier of Ethernet device.
3705 * Flow rule handle to destroy.
3707 * Perform verbose error reporting if not NULL. PMDs initialize this
3708 * structure in case of error only.
3711 * 0 on success, a negative errno value otherwise and rte_errno is set.
3714 rte_flow_destroy(uint16_t port_id,
3715 struct rte_flow *flow,
3716 struct rte_flow_error *error);
3719 * Destroy all flow rules associated with a port.
3721 * In the unlikely event of failure, handles are still considered destroyed
3722 * and no longer valid but the port must be assumed to be in an inconsistent
3726 * Port identifier of Ethernet device.
3728 * Perform verbose error reporting if not NULL. PMDs initialize this
3729 * structure in case of error only.
3732 * 0 on success, a negative errno value otherwise and rte_errno is set.
3735 rte_flow_flush(uint16_t port_id,
3736 struct rte_flow_error *error);
3739 * Query an existing flow rule.
3741 * This function allows retrieving flow-specific data such as counters.
3742 * Data is gathered by special actions which must be present in the flow
3745 * \see RTE_FLOW_ACTION_TYPE_COUNT
3748 * Port identifier of Ethernet device.
3750 * Flow rule handle to query.
3752 * Action definition as defined in original flow rule.
3753 * @param[in, out] data
3754 * Pointer to storage for the associated query data type.
3756 * Perform verbose error reporting if not NULL. PMDs initialize this
3757 * structure in case of error only.
3760 * 0 on success, a negative errno value otherwise and rte_errno is set.
3763 rte_flow_query(uint16_t port_id,
3764 struct rte_flow *flow,
3765 const struct rte_flow_action *action,
3767 struct rte_flow_error *error);
3770 * Restrict ingress traffic to the defined flow rules.
3772 * Isolated mode guarantees that all ingress traffic comes from defined flow
3773 * rules only (current and future).
3775 * Besides making ingress more deterministic, it allows PMDs to safely reuse
3776 * resources otherwise assigned to handle the remaining traffic, such as
3777 * global RSS configuration settings, VLAN filters, MAC address entries,
3778 * legacy filter API rules and so on in order to expand the set of possible
3781 * Calling this function as soon as possible after device initialization,
3782 * ideally before the first call to rte_eth_dev_configure(), is recommended
3783 * to avoid possible failures due to conflicting settings.
3785 * Once effective, leaving isolated mode may not be possible depending on
3786 * PMD implementation.
3788 * Additionally, the following functionality has no effect on the underlying
3789 * port and may return errors such as ENOTSUP ("not supported"):
3791 * - Toggling promiscuous mode.
3792 * - Toggling allmulticast mode.
3793 * - Configuring MAC addresses.
3794 * - Configuring multicast addresses.
3795 * - Configuring VLAN filters.
3796 * - Configuring Rx filters through the legacy API (e.g. FDIR).
3797 * - Configuring global RSS settings.
3800 * Port identifier of Ethernet device.
3802 * Nonzero to enter isolated mode, attempt to leave it otherwise.
3804 * Perform verbose error reporting if not NULL. PMDs initialize this
3805 * structure in case of error only.
3808 * 0 on success, a negative errno value otherwise and rte_errno is set.
3811 rte_flow_isolate(uint16_t port_id, int set, struct rte_flow_error *error);
3814 * Initialize flow error structure.
3817 * Pointer to flow error structure (may be NULL).
3819 * Related error code (rte_errno).
3821 * Cause field and error types.
3823 * Object responsible for the error.
3825 * Human-readable error message.
3828 * Negative error code (errno value) and rte_errno is set.
3831 rte_flow_error_set(struct rte_flow_error *error,
3833 enum rte_flow_error_type type,
3835 const char *message);
3839 * @see rte_flow_copy()
3841 struct rte_flow_desc {
3842 size_t size; /**< Allocated space including data[]. */
3843 struct rte_flow_attr attr; /**< Attributes. */
3844 struct rte_flow_item *items; /**< Items. */
3845 struct rte_flow_action *actions; /**< Actions. */
3846 uint8_t data[]; /**< Storage for items/actions. */
3851 * Copy an rte_flow rule description.
3853 * This interface is kept for compatibility with older applications but is
3854 * implemented as a wrapper to rte_flow_conv(). It is deprecated due to its
3855 * lack of flexibility and reliance on a type unusable with C++ programs
3856 * (struct rte_flow_desc).
3859 * Flow rule description.
3861 * Total size of allocated data for the flow description.
3863 * Flow rule attributes.
3865 * Pattern specification (list terminated by the END pattern item).
3866 * @param[in] actions
3867 * Associated actions (list terminated by the END action).
3870 * If len is greater or equal to the size of the flow, the total size of the
3871 * flow description and its data.
3872 * If len is lower than the size of the flow, the number of bytes that would
3873 * have been written to desc had it been sufficient. Nothing is written.
3877 rte_flow_copy(struct rte_flow_desc *fd, size_t len,
3878 const struct rte_flow_attr *attr,
3879 const struct rte_flow_item *items,
3880 const struct rte_flow_action *actions);
3883 * Flow object conversion helper.
3885 * This function performs conversion of various flow API objects to a
3886 * pre-allocated destination buffer. See enum rte_flow_conv_op for possible
3887 * operations and details about each of them.
3889 * Since destination buffer must be large enough, it works in a manner
3890 * reminiscent of snprintf():
3892 * - If @p size is 0, @p dst may be a NULL pointer, otherwise @p dst must be
3894 * - If positive, the returned value represents the number of bytes needed
3895 * to store the conversion of @p src to @p dst according to @p op
3896 * regardless of the @p size parameter.
3897 * - Since no more than @p size bytes can be written to @p dst, output is
3898 * truncated and may be inconsistent when the returned value is larger
3900 * - In case of conversion error, a negative error code is returned and
3901 * @p dst contents are unspecified.
3904 * Operation to perform, related to the object type of @p dst.
3906 * Destination buffer address. Must be suitably aligned by the caller.
3908 * Destination buffer size in bytes.
3910 * Source object to copy. Depending on @p op, its type may differ from
3913 * Perform verbose error reporting if not NULL. Initialized in case of
3917 * The number of bytes required to convert @p src to @p dst on success, a
3918 * negative errno value otherwise and rte_errno is set.
3920 * @see rte_flow_conv_op
3924 rte_flow_conv(enum rte_flow_conv_op op,
3928 struct rte_flow_error *error);
3931 * Get aged-out flows of a given port.
3933 * RTE_ETH_EVENT_FLOW_AGED event will be triggered when at least one new aged
3934 * out flow was detected after the last call to rte_flow_get_aged_flows.
3935 * This function can be called to get the aged flows usynchronously from the
3936 * event callback or synchronously regardless the event.
3937 * This is not safe to call rte_flow_get_aged_flows function with other flow
3938 * functions from multiple threads simultaneously.
3941 * Port identifier of Ethernet device.
3942 * @param[in, out] contexts
3943 * The address of an array of pointers to the aged-out flows contexts.
3944 * @param[in] nb_contexts
3945 * The length of context array pointers.
3947 * Perform verbose error reporting if not NULL. Initialized in case of
3951 * if nb_contexts is 0, return the amount of all aged contexts.
3952 * if nb_contexts is not 0 , return the amount of aged flows reported
3953 * in the context array, otherwise negative errno value.
3955 * @see rte_flow_action_age
3956 * @see RTE_ETH_EVENT_FLOW_AGED
3960 rte_flow_get_aged_flows(uint16_t port_id, void **contexts,
3961 uint32_t nb_contexts, struct rte_flow_error *error);
3964 * Specify indirect action object configuration
3966 struct rte_flow_indir_action_conf {
3968 * Flow direction for the indirect action configuration.
3970 * Action should be valid at least for one flow direction,
3971 * otherwise it is invalid for both ingress and egress rules.
3974 /**< Action valid for rules applied to ingress traffic. */
3976 /**< Action valid for rules applied to egress traffic. */
3978 * When set to 1, indicates that the action is valid for
3979 * transfer traffic; otherwise, for non-transfer traffic.
3981 uint32_t transfer:1;
3986 * @b EXPERIMENTAL: this API may change without prior notice.
3988 * Create an indirect action object that can be used in flow rules
3990 * The created object handle has single state and configuration
3991 * across all the flow rules using it.
3993 * @param[in] port_id
3994 * The port identifier of the Ethernet device.
3996 * Action configuration for the indirect action object creation.
3998 * Specific configuration of the indirect action object.
4000 * Perform verbose error reporting if not NULL. PMDs initialize this
4001 * structure in case of error only.
4003 * A valid handle in case of success, NULL otherwise and rte_errno is set
4004 * to one of the error codes defined:
4005 * - (ENODEV) if *port_id* invalid.
4006 * - (ENOSYS) if underlying device does not support this functionality.
4007 * - (EIO) if underlying device is removed.
4008 * - (EINVAL) if *action* invalid.
4009 * - (ENOTSUP) if *action* valid but unsupported.
4012 struct rte_flow_action_handle *
4013 rte_flow_action_handle_create(uint16_t port_id,
4014 const struct rte_flow_indir_action_conf *conf,
4015 const struct rte_flow_action *action,
4016 struct rte_flow_error *error);
4020 * @b EXPERIMENTAL: this API may change without prior notice.
4022 * Destroy indirect action by handle.
4024 * @param[in] port_id
4025 * The port identifier of the Ethernet device.
4027 * Handle for the indirect action object to be destroyed.
4029 * Perform verbose error reporting if not NULL. PMDs initialize this
4030 * structure in case of error only.
4033 * - (-ENODEV) if *port_id* invalid.
4034 * - (-ENOSYS) if underlying device does not support this functionality.
4035 * - (-EIO) if underlying device is removed.
4036 * - (-ENOENT) if action pointed by *action* handle was not found.
4037 * - (-EBUSY) if action pointed by *action* handle still used by some rules
4038 * rte_errno is also set.
4042 rte_flow_action_handle_destroy(uint16_t port_id,
4043 struct rte_flow_action_handle *handle,
4044 struct rte_flow_error *error);
4048 * @b EXPERIMENTAL: this API may change without prior notice.
4050 * Update in-place the action configuration and / or state pointed
4051 * by action *handle* with the configuration provided as *update* argument.
4052 * The update of the action configuration effects all flow rules reusing
4053 * the action via *handle*.
4054 * The update general pointer provides the ability of partial updating.
4056 * @param[in] port_id
4057 * The port identifier of the Ethernet device.
4059 * Handle for the indirect action object to be updated.
4061 * Update profile specification used to modify the action pointed by handle.
4062 * *update* could be with the same type of the immediate action corresponding
4063 * to the *handle* argument when creating, or a wrapper structure includes
4064 * action configuration to be updated and bit fields to indicate the member
4065 * of fields inside the action to update.
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 * - (-EINVAL) if *update* invalid.
4075 * - (-ENOTSUP) if *update* valid but unsupported.
4076 * - (-ENOENT) if indirect action object pointed by *handle* was not found.
4077 * rte_errno is also set.
4081 rte_flow_action_handle_update(uint16_t port_id,
4082 struct rte_flow_action_handle *handle,
4084 struct rte_flow_error *error);
4088 * @b EXPERIMENTAL: this API may change without prior notice.
4090 * Query the direct action by corresponding indirect action object handle.
4092 * Retrieve action-specific data such as counters.
4093 * Data is gathered by special action which may be present/referenced in
4094 * more than one flow rule definition.
4096 * @see RTE_FLOW_ACTION_TYPE_COUNT
4099 * Port identifier of Ethernet device.
4101 * Handle for the action object to query.
4102 * @param[in, out] data
4103 * Pointer to storage for the associated query data type.
4105 * Perform verbose error reporting if not NULL. PMDs initialize this
4106 * structure in case of error only.
4109 * 0 on success, a negative errno value otherwise and rte_errno is set.
4113 rte_flow_action_handle_query(uint16_t port_id,
4114 const struct rte_flow_action_handle *handle,
4115 void *data, struct rte_flow_error *error);
4117 /* Tunnel has a type and the key information. */
4118 struct rte_flow_tunnel {
4120 * Tunnel type, for example RTE_FLOW_ITEM_TYPE_VXLAN,
4121 * RTE_FLOW_ITEM_TYPE_NVGRE etc.
4123 enum rte_flow_item_type type;
4124 uint64_t tun_id; /**< Tunnel identification. */
4129 rte_be32_t src_addr; /**< IPv4 source address. */
4130 rte_be32_t dst_addr; /**< IPv4 destination address. */
4133 uint8_t src_addr[16]; /**< IPv6 source address. */
4134 uint8_t dst_addr[16]; /**< IPv6 destination address. */
4137 rte_be16_t tp_src; /**< Tunnel port source. */
4138 rte_be16_t tp_dst; /**< Tunnel port destination. */
4139 uint16_t tun_flags; /**< Tunnel flags. */
4141 bool is_ipv6; /**< True for valid IPv6 fields. Otherwise IPv4. */
4144 * the following members are required to restore packet
4147 uint8_t tos; /**< TOS for IPv4, TC for IPv6. */
4148 uint8_t ttl; /**< TTL for IPv4, HL for IPv6. */
4149 uint32_t label; /**< Flow Label for IPv6. */
4153 * Indicate that the packet has a tunnel.
4155 #define RTE_FLOW_RESTORE_INFO_TUNNEL (1ULL << 0)
4158 * Indicate that the packet has a non decapsulated tunnel header.
4160 #define RTE_FLOW_RESTORE_INFO_ENCAPSULATED (1ULL << 1)
4163 * Indicate that the packet has a group_id.
4165 #define RTE_FLOW_RESTORE_INFO_GROUP_ID (1ULL << 2)
4168 * Restore information structure to communicate the current packet processing
4169 * state when some of the processing pipeline is done in hardware and should
4170 * continue in software.
4172 struct rte_flow_restore_info {
4174 * Bitwise flags (RTE_FLOW_RESTORE_INFO_*) to indicate validation of
4175 * other fields in struct rte_flow_restore_info.
4178 uint32_t group_id; /**< Group ID where packed missed */
4179 struct rte_flow_tunnel tunnel; /**< Tunnel information. */
4183 * Allocate an array of actions to be used in rte_flow_create, to implement
4184 * tunnel-decap-set for the given tunnel.
4186 * actions vxlan_decap / tunnel-decap-set(tunnel properties) /
4187 * jump group 0 / end
4190 * Port identifier of Ethernet device.
4192 * Tunnel properties.
4193 * @param[out] actions
4194 * Array of actions to be allocated by the PMD. This array should be
4195 * concatenated with the actions array provided to rte_flow_create.
4196 * @param[out] num_of_actions
4197 * Number of actions allocated.
4199 * Perform verbose error reporting if not NULL. PMDs initialize this
4200 * structure in case of error only.
4203 * 0 on success, a negative errno value otherwise and rte_errno is set.
4207 rte_flow_tunnel_decap_set(uint16_t port_id,
4208 struct rte_flow_tunnel *tunnel,
4209 struct rte_flow_action **actions,
4210 uint32_t *num_of_actions,
4211 struct rte_flow_error *error);
4214 * Allocate an array of items to be used in rte_flow_create, to implement
4215 * tunnel-match for the given tunnel.
4217 * pattern tunnel-match(tunnel properties) / outer-header-matches /
4218 * inner-header-matches / end
4221 * Port identifier of Ethernet device.
4223 * Tunnel properties.
4225 * Array of items to be allocated by the PMD. This array should be
4226 * concatenated with the items array provided to rte_flow_create.
4227 * @param[out] num_of_items
4228 * Number of items allocated.
4230 * Perform verbose error reporting if not NULL. PMDs initialize this
4231 * structure in case of error only.
4234 * 0 on success, a negative errno value otherwise and rte_errno is set.
4238 rte_flow_tunnel_match(uint16_t port_id,
4239 struct rte_flow_tunnel *tunnel,
4240 struct rte_flow_item **items,
4241 uint32_t *num_of_items,
4242 struct rte_flow_error *error);
4245 * Populate the current packet processing state, if exists, for the given mbuf.
4247 * One should negotiate tunnel metadata delivery from the NIC to the HW.
4248 * @see rte_eth_rx_metadata_negotiate()
4249 * @see RTE_ETH_RX_METADATA_TUNNEL_ID
4252 * Port identifier of Ethernet device.
4256 * Restore information. Upon success contains the HW state.
4258 * Perform verbose error reporting if not NULL. PMDs initialize this
4259 * structure in case of error only.
4262 * 0 on success, a negative errno value otherwise and rte_errno is set.
4266 rte_flow_get_restore_info(uint16_t port_id,
4268 struct rte_flow_restore_info *info,
4269 struct rte_flow_error *error);
4272 * Release the action array as allocated by rte_flow_tunnel_decap_set.
4275 * Port identifier of Ethernet device.
4276 * @param[in] actions
4277 * Array of actions to be released.
4278 * @param[in] num_of_actions
4279 * Number of elements in actions array.
4281 * Perform verbose error reporting if not NULL. PMDs initialize this
4282 * structure in case of error only.
4285 * 0 on success, a negative errno value otherwise and rte_errno is set.
4289 rte_flow_tunnel_action_decap_release(uint16_t port_id,
4290 struct rte_flow_action *actions,
4291 uint32_t num_of_actions,
4292 struct rte_flow_error *error);
4295 * Release the item array as allocated by rte_flow_tunnel_match.
4298 * Port identifier of Ethernet device.
4300 * Array of items to be released.
4301 * @param[in] num_of_items
4302 * Number of elements in item array.
4304 * Perform verbose error reporting if not NULL. PMDs initialize this
4305 * structure in case of error only.
4308 * 0 on success, a negative errno value otherwise and rte_errno is set.
4312 rte_flow_tunnel_item_release(uint16_t port_id,
4313 struct rte_flow_item *items,
4314 uint32_t num_of_items,
4315 struct rte_flow_error *error);
4320 #endif /* RTE_FLOW_H_ */