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>
43 * Flow rule attributes.
45 * Priorities are set on a per rule based within groups.
47 * Lower values denote higher priority, the highest priority for a flow rule
48 * is 0, so that a flow that matches for than one rule, the rule with the
49 * lowest priority value will always be matched.
51 * Although optional, applications are encouraged to group similar rules as
52 * much as possible to fully take advantage of hardware capabilities
53 * (e.g. optimized matching) and work around limitations (e.g. a single
54 * pattern type possibly allowed in a given group). Applications should be
55 * aware that groups are not linked by default, and that they must be
56 * explicitly linked by the application using the JUMP action.
58 * Priority levels are arbitrary and up to the application, they
59 * do not need to be contiguous nor start from 0, however the maximum number
60 * varies between devices and may be affected by existing flow rules.
62 * If a packet is matched by several rules of a given group for a given
63 * priority level, the outcome is undefined. It can take any path, may be
64 * duplicated or even cause unrecoverable errors.
66 * Note that support for more than a single group and priority level is not
69 * Flow rules can apply to inbound and/or outbound traffic (ingress/egress).
71 * Several pattern items and actions are valid and can be used in both
72 * directions. Those valid for only one direction are described as such.
74 * At least one direction must be specified.
76 * Specifying both directions at once for a given rule is not recommended
77 * but may be valid in a few cases (e.g. shared counter).
79 struct rte_flow_attr {
80 uint32_t group; /**< Priority group. */
81 uint32_t priority; /**< Rule priority level within group. */
82 uint32_t ingress:1; /**< Rule applies to ingress traffic. */
83 uint32_t egress:1; /**< Rule applies to egress traffic. */
85 * Instead of simply matching the properties of traffic as it would
86 * appear on a given DPDK port ID, enabling this attribute transfers
87 * a flow rule to the lowest possible level of any device endpoints
88 * found in the pattern.
90 * When supported, this effectively enables an application to
91 * re-route traffic not necessarily intended for it (e.g. coming
92 * from or addressed to different physical ports, VFs or
93 * applications) at the device level.
95 * It complements the behavior of some pattern items such as
96 * RTE_FLOW_ITEM_TYPE_PHY_PORT and is meaningless without them.
98 * When transferring flow rules, ingress and egress attributes keep
99 * their original meaning, as if processing traffic emitted or
100 * received by the application.
103 uint32_t reserved:29; /**< Reserved, must be zero. */
107 * Matching pattern item types.
109 * Pattern items fall in two categories:
111 * - Matching protocol headers and packet data, usually associated with a
112 * specification structure. These must be stacked in the same order as the
113 * protocol layers to match inside packets, starting from the lowest.
115 * - Matching meta-data or affecting pattern processing, often without a
116 * specification structure. Since they do not match packet contents, their
117 * position in the list is usually not relevant.
119 * See the description of individual types for more information. Those
120 * marked with [META] fall into the second category.
122 enum rte_flow_item_type {
126 * End marker for item lists. Prevents further processing of items,
127 * thereby ending the pattern.
129 * No associated specification structure.
131 RTE_FLOW_ITEM_TYPE_END,
136 * Used as a placeholder for convenience. It is ignored and simply
139 * No associated specification structure.
141 RTE_FLOW_ITEM_TYPE_VOID,
146 * Inverted matching, i.e. process packets that do not match the
149 * No associated specification structure.
151 RTE_FLOW_ITEM_TYPE_INVERT,
154 * Matches any protocol in place of the current layer, a single ANY
155 * may also stand for several protocol layers.
157 * See struct rte_flow_item_any.
159 RTE_FLOW_ITEM_TYPE_ANY,
164 * Matches traffic originating from (ingress) or going to (egress)
165 * the physical function of the current device.
167 * No associated specification structure.
169 RTE_FLOW_ITEM_TYPE_PF,
174 * Matches traffic originating from (ingress) or going to (egress) a
175 * given virtual function of the current device.
177 * See struct rte_flow_item_vf.
179 RTE_FLOW_ITEM_TYPE_VF,
184 * Matches traffic originating from (ingress) or going to (egress) a
185 * physical port of the underlying device.
187 * See struct rte_flow_item_phy_port.
189 RTE_FLOW_ITEM_TYPE_PHY_PORT,
194 * Matches traffic originating from (ingress) or going to (egress) a
195 * given DPDK port ID.
197 * See struct rte_flow_item_port_id.
199 RTE_FLOW_ITEM_TYPE_PORT_ID,
202 * Matches a byte string of a given length at a given offset.
204 * See struct rte_flow_item_raw.
206 RTE_FLOW_ITEM_TYPE_RAW,
209 * Matches an Ethernet header.
211 * See struct rte_flow_item_eth.
213 RTE_FLOW_ITEM_TYPE_ETH,
216 * Matches an 802.1Q/ad VLAN tag.
218 * See struct rte_flow_item_vlan.
220 RTE_FLOW_ITEM_TYPE_VLAN,
223 * Matches an IPv4 header.
225 * See struct rte_flow_item_ipv4.
227 RTE_FLOW_ITEM_TYPE_IPV4,
230 * Matches an IPv6 header.
232 * See struct rte_flow_item_ipv6.
234 RTE_FLOW_ITEM_TYPE_IPV6,
237 * Matches an ICMP header.
239 * See struct rte_flow_item_icmp.
241 RTE_FLOW_ITEM_TYPE_ICMP,
244 * Matches a UDP header.
246 * See struct rte_flow_item_udp.
248 RTE_FLOW_ITEM_TYPE_UDP,
251 * Matches a TCP header.
253 * See struct rte_flow_item_tcp.
255 RTE_FLOW_ITEM_TYPE_TCP,
258 * Matches a SCTP header.
260 * See struct rte_flow_item_sctp.
262 RTE_FLOW_ITEM_TYPE_SCTP,
265 * Matches a VXLAN header.
267 * See struct rte_flow_item_vxlan.
269 RTE_FLOW_ITEM_TYPE_VXLAN,
272 * Matches a E_TAG header.
274 * See struct rte_flow_item_e_tag.
276 RTE_FLOW_ITEM_TYPE_E_TAG,
279 * Matches a NVGRE header.
281 * See struct rte_flow_item_nvgre.
283 RTE_FLOW_ITEM_TYPE_NVGRE,
286 * Matches a MPLS header.
288 * See struct rte_flow_item_mpls.
290 RTE_FLOW_ITEM_TYPE_MPLS,
293 * Matches a GRE header.
295 * See struct rte_flow_item_gre.
297 RTE_FLOW_ITEM_TYPE_GRE,
302 * Fuzzy pattern match, expect faster than default.
304 * This is for device that support fuzzy matching option.
305 * Usually a fuzzy matching is fast but the cost is accuracy.
307 * See struct rte_flow_item_fuzzy.
309 RTE_FLOW_ITEM_TYPE_FUZZY,
312 * Matches a GTP header.
314 * Configure flow for GTP packets.
316 * See struct rte_flow_item_gtp.
318 RTE_FLOW_ITEM_TYPE_GTP,
321 * Matches a GTP header.
323 * Configure flow for GTP-C packets.
325 * See struct rte_flow_item_gtp.
327 RTE_FLOW_ITEM_TYPE_GTPC,
330 * Matches a GTP header.
332 * Configure flow for GTP-U packets.
334 * See struct rte_flow_item_gtp.
336 RTE_FLOW_ITEM_TYPE_GTPU,
339 * Matches a ESP header.
341 * See struct rte_flow_item_esp.
343 RTE_FLOW_ITEM_TYPE_ESP,
346 * Matches a GENEVE header.
348 * See struct rte_flow_item_geneve.
350 RTE_FLOW_ITEM_TYPE_GENEVE,
353 * Matches a VXLAN-GPE header.
355 * See struct rte_flow_item_vxlan_gpe.
357 RTE_FLOW_ITEM_TYPE_VXLAN_GPE,
360 * Matches an ARP header for Ethernet/IPv4.
362 * See struct rte_flow_item_arp_eth_ipv4.
364 RTE_FLOW_ITEM_TYPE_ARP_ETH_IPV4,
367 * Matches the presence of any IPv6 extension header.
369 * See struct rte_flow_item_ipv6_ext.
371 RTE_FLOW_ITEM_TYPE_IPV6_EXT,
374 * Matches any ICMPv6 header.
376 * See struct rte_flow_item_icmp6.
378 RTE_FLOW_ITEM_TYPE_ICMP6,
381 * Matches an ICMPv6 neighbor discovery solicitation.
383 * See struct rte_flow_item_icmp6_nd_ns.
385 RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS,
388 * Matches an ICMPv6 neighbor discovery advertisement.
390 * See struct rte_flow_item_icmp6_nd_na.
392 RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA,
395 * Matches the presence of any ICMPv6 neighbor discovery option.
397 * See struct rte_flow_item_icmp6_nd_opt.
399 RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT,
402 * Matches an ICMPv6 neighbor discovery source Ethernet link-layer
405 * See struct rte_flow_item_icmp6_nd_opt_sla_eth.
407 RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_SLA_ETH,
410 * Matches an ICMPv6 neighbor discovery target Ethernet link-layer
413 * See struct rte_flow_item_icmp6_nd_opt_tla_eth.
415 RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_TLA_ETH,
418 * Matches specified mark field.
420 * See struct rte_flow_item_mark.
422 RTE_FLOW_ITEM_TYPE_MARK,
427 * Matches a metadata value.
429 * See struct rte_flow_item_meta.
431 RTE_FLOW_ITEM_TYPE_META,
434 * Matches a GRE optional key field.
436 * The value should a big-endian 32bit integer.
438 * When this item present the K bit is implicitly matched as "1"
439 * in the default mask.
442 * @code rte_be32_t * @endcode
444 RTE_FLOW_ITEM_TYPE_GRE_KEY,
447 * Matches a GTP extension header: PDU session container.
449 * Configure flow for GTP packets with extension header type 0x85.
451 * See struct rte_flow_item_gtp_psc.
453 RTE_FLOW_ITEM_TYPE_GTP_PSC,
456 * Matches a PPPoE header.
458 * Configure flow for PPPoE session packets.
460 * See struct rte_flow_item_pppoe.
462 RTE_FLOW_ITEM_TYPE_PPPOES,
465 * Matches a PPPoE header.
467 * Configure flow for PPPoE discovery packets.
469 * See struct rte_flow_item_pppoe.
471 RTE_FLOW_ITEM_TYPE_PPPOED,
474 * Matches a PPPoE optional proto_id field.
476 * It only applies to PPPoE session packets.
478 * See struct rte_flow_item_pppoe_proto_id.
480 RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID,
483 * Matches Network service header (NSH).
484 * See struct rte_flow_item_nsh.
487 RTE_FLOW_ITEM_TYPE_NSH,
490 * Matches Internet Group Management Protocol (IGMP).
491 * See struct rte_flow_item_igmp.
494 RTE_FLOW_ITEM_TYPE_IGMP,
497 * Matches IP Authentication Header (AH).
498 * See struct rte_flow_item_ah.
501 RTE_FLOW_ITEM_TYPE_AH,
504 * Matches a HIGIG header.
505 * see struct rte_flow_item_higig2_hdr.
507 RTE_FLOW_ITEM_TYPE_HIGIG2,
512 * Matches a tag value.
514 * See struct rte_flow_item_tag.
516 RTE_FLOW_ITEM_TYPE_TAG,
519 * Matches a L2TPv3 over IP header.
521 * Configure flow for L2TPv3 over IP packets.
523 * See struct rte_flow_item_l2tpv3oip.
525 RTE_FLOW_ITEM_TYPE_L2TPV3OIP,
528 * Matches PFCP Header.
529 * See struct rte_flow_item_pfcp.
532 RTE_FLOW_ITEM_TYPE_PFCP,
535 * Matches eCPRI Header.
537 * Configure flow for eCPRI over ETH or UDP packets.
539 * See struct rte_flow_item_ecpri.
541 RTE_FLOW_ITEM_TYPE_ECPRI,
544 * Matches the presence of IPv6 fragment extension header.
546 * See struct rte_flow_item_ipv6_frag_ext.
548 RTE_FLOW_ITEM_TYPE_IPV6_FRAG_EXT,
551 * Matches Geneve Variable Length Option
553 * See struct rte_flow_item_geneve_opt
555 RTE_FLOW_ITEM_TYPE_GENEVE_OPT,
560 * Matches on packet integrity.
561 * For some devices application needs to enable integration checks in HW
562 * before using this item.
564 * @see struct rte_flow_item_integrity.
566 RTE_FLOW_ITEM_TYPE_INTEGRITY,
571 * Matches conntrack state.
573 * @see struct rte_flow_item_conntrack.
575 RTE_FLOW_ITEM_TYPE_CONNTRACK,
580 * RTE_FLOW_ITEM_TYPE_HIGIG2
581 * Matches higig2 header
584 struct rte_flow_item_higig2_hdr {
585 struct rte_higig2_hdr hdr;
588 /** Default mask for RTE_FLOW_ITEM_TYPE_HIGIG2. */
590 static const struct rte_flow_item_higig2_hdr rte_flow_item_higig2_hdr_mask = {
593 .classification = 0xffff,
601 * RTE_FLOW_ITEM_TYPE_ANY
603 * Matches any protocol in place of the current layer, a single ANY may also
604 * stand for several protocol layers.
606 * This is usually specified as the first pattern item when looking for a
607 * protocol anywhere in a packet.
609 * A zeroed mask stands for any number of layers.
611 struct rte_flow_item_any {
612 uint32_t num; /**< Number of layers covered. */
615 /** Default mask for RTE_FLOW_ITEM_TYPE_ANY. */
617 static const struct rte_flow_item_any rte_flow_item_any_mask = {
623 * RTE_FLOW_ITEM_TYPE_VF
625 * Matches traffic originating from (ingress) or going to (egress) a given
626 * virtual function of the current device.
628 * If supported, should work even if the virtual function is not managed by
629 * the application and thus not associated with a DPDK port ID.
631 * Note this pattern item does not match VF representors traffic which, as
632 * separate entities, should be addressed through their own DPDK port IDs.
634 * - Can be specified multiple times to match traffic addressed to several
636 * - Can be combined with a PF item to match both PF and VF traffic.
638 * A zeroed mask can be used to match any VF ID.
640 struct rte_flow_item_vf {
641 uint32_t id; /**< VF ID. */
644 /** Default mask for RTE_FLOW_ITEM_TYPE_VF. */
646 static const struct rte_flow_item_vf rte_flow_item_vf_mask = {
652 * RTE_FLOW_ITEM_TYPE_PHY_PORT
654 * Matches traffic originating from (ingress) or going to (egress) a
655 * physical port of the underlying device.
657 * The first PHY_PORT item overrides the physical port normally associated
658 * with the specified DPDK input port (port_id). This item can be provided
659 * several times to match additional physical ports.
661 * Note that physical ports are not necessarily tied to DPDK input ports
662 * (port_id) when those are not under DPDK control. Possible values are
663 * specific to each device, they are not necessarily indexed from zero and
664 * may not be contiguous.
666 * As a device property, the list of allowed values as well as the value
667 * associated with a port_id should be retrieved by other means.
669 * A zeroed mask can be used to match any port index.
671 struct rte_flow_item_phy_port {
672 uint32_t index; /**< Physical port index. */
675 /** Default mask for RTE_FLOW_ITEM_TYPE_PHY_PORT. */
677 static const struct rte_flow_item_phy_port rte_flow_item_phy_port_mask = {
683 * RTE_FLOW_ITEM_TYPE_PORT_ID
685 * Matches traffic originating from (ingress) or going to (egress) a given
688 * Normally only supported if the port ID in question is known by the
689 * underlying PMD and related to the device the flow rule is created
692 * This must not be confused with @p PHY_PORT which refers to the physical
693 * port of a device, whereas @p PORT_ID refers to a struct rte_eth_dev
694 * object on the application side (also known as "port representor"
695 * depending on the kind of underlying device).
697 struct rte_flow_item_port_id {
698 uint32_t id; /**< DPDK port ID. */
701 /** Default mask for RTE_FLOW_ITEM_TYPE_PORT_ID. */
703 static const struct rte_flow_item_port_id rte_flow_item_port_id_mask = {
709 * RTE_FLOW_ITEM_TYPE_RAW
711 * Matches a byte string of a given length at a given offset.
713 * Offset is either absolute (using the start of the packet) or relative to
714 * the end of the previous matched item in the stack, in which case negative
715 * values are allowed.
717 * If search is enabled, offset is used as the starting point. The search
718 * area can be delimited by setting limit to a nonzero value, which is the
719 * maximum number of bytes after offset where the pattern may start.
721 * Matching a zero-length pattern is allowed, doing so resets the relative
722 * offset for subsequent items.
724 * This type does not support ranges (struct rte_flow_item.last).
726 struct rte_flow_item_raw {
727 uint32_t relative:1; /**< Look for pattern after the previous item. */
728 uint32_t search:1; /**< Search pattern from offset (see also limit). */
729 uint32_t reserved:30; /**< Reserved, must be set to zero. */
730 int32_t offset; /**< Absolute or relative offset for pattern. */
731 uint16_t limit; /**< Search area limit for start of pattern. */
732 uint16_t length; /**< Pattern length. */
733 const uint8_t *pattern; /**< Byte string to look for. */
736 /** Default mask for RTE_FLOW_ITEM_TYPE_RAW. */
738 static const struct rte_flow_item_raw rte_flow_item_raw_mask = {
741 .reserved = 0x3fffffff,
742 .offset = 0xffffffff,
750 * RTE_FLOW_ITEM_TYPE_ETH
752 * Matches an Ethernet header.
754 * Inside @p hdr field, the sub-field @p ether_type stands either for EtherType
755 * or TPID, depending on whether the item is followed by a VLAN item or not. If
756 * two VLAN items follow, the sub-field refers to the outer one, which, in turn,
757 * contains the inner TPID in the similar header field. The innermost VLAN item
758 * contains a layer-3 EtherType. All of that follows the order seen on the wire.
760 * If the field in question contains a TPID value, only tagged packets with the
761 * specified TPID will match the pattern. Alternatively, it's possible to match
762 * any type of tagged packets by means of the field @p has_vlan rather than use
763 * the EtherType/TPID field. Also, it's possible to leave the two fields unused.
764 * If this is the case, both tagged and untagged packets will match the pattern.
767 struct rte_flow_item_eth {
771 * These fields are retained for compatibility.
772 * Please switch to the new header field below.
774 struct rte_ether_addr dst; /**< Destination MAC. */
775 struct rte_ether_addr src; /**< Source MAC. */
776 rte_be16_t type; /**< EtherType or TPID. */
778 struct rte_ether_hdr hdr;
780 uint32_t has_vlan:1; /**< Packet header contains at least one VLAN. */
781 uint32_t reserved:31; /**< Reserved, must be zero. */
784 /** Default mask for RTE_FLOW_ITEM_TYPE_ETH. */
786 static const struct rte_flow_item_eth rte_flow_item_eth_mask = {
787 .hdr.d_addr.addr_bytes = "\xff\xff\xff\xff\xff\xff",
788 .hdr.s_addr.addr_bytes = "\xff\xff\xff\xff\xff\xff",
789 .hdr.ether_type = RTE_BE16(0x0000),
794 * RTE_FLOW_ITEM_TYPE_VLAN
796 * Matches an 802.1Q/ad VLAN tag.
798 * The corresponding standard outer EtherType (TPID) values are
799 * RTE_ETHER_TYPE_VLAN or RTE_ETHER_TYPE_QINQ. It can be overridden by
800 * the preceding pattern item.
801 * If a @p VLAN item is present in the pattern, then only tagged packets will
803 * The field @p has_more_vlan can be used to match any type of tagged packets,
804 * instead of using the @p eth_proto field of @p hdr.
805 * If the @p eth_proto of @p hdr and @p has_more_vlan fields are not specified,
806 * then any tagged packets will match the pattern.
809 struct rte_flow_item_vlan {
813 * These fields are retained for compatibility.
814 * Please switch to the new header field below.
816 rte_be16_t tci; /**< Tag control information. */
817 rte_be16_t inner_type; /**< Inner EtherType or TPID. */
819 struct rte_vlan_hdr hdr;
821 uint32_t has_more_vlan:1;
822 /**< Packet header contains at least one more VLAN, after this VLAN. */
823 uint32_t reserved:31; /**< Reserved, must be zero. */
826 /** Default mask for RTE_FLOW_ITEM_TYPE_VLAN. */
828 static const struct rte_flow_item_vlan rte_flow_item_vlan_mask = {
829 .hdr.vlan_tci = RTE_BE16(0x0fff),
830 .hdr.eth_proto = RTE_BE16(0x0000),
835 * RTE_FLOW_ITEM_TYPE_IPV4
837 * Matches an IPv4 header.
839 * Note: IPv4 options are handled by dedicated pattern items.
841 struct rte_flow_item_ipv4 {
842 struct rte_ipv4_hdr hdr; /**< IPv4 header definition. */
845 /** Default mask for RTE_FLOW_ITEM_TYPE_IPV4. */
847 static const struct rte_flow_item_ipv4 rte_flow_item_ipv4_mask = {
849 .src_addr = RTE_BE32(0xffffffff),
850 .dst_addr = RTE_BE32(0xffffffff),
856 * RTE_FLOW_ITEM_TYPE_IPV6.
858 * Matches an IPv6 header.
860 * Dedicated flags indicate if header contains specific extension headers.
862 struct rte_flow_item_ipv6 {
863 struct rte_ipv6_hdr hdr; /**< IPv6 header definition. */
864 uint32_t has_hop_ext:1;
865 /**< Header contains Hop-by-Hop Options extension header. */
866 uint32_t has_route_ext:1;
867 /**< Header contains Routing extension header. */
868 uint32_t has_frag_ext:1;
869 /**< Header contains Fragment extension header. */
870 uint32_t has_auth_ext:1;
871 /**< Header contains Authentication extension header. */
872 uint32_t has_esp_ext:1;
873 /**< Header contains Encapsulation Security Payload extension header. */
874 uint32_t has_dest_ext:1;
875 /**< Header contains Destination Options extension header. */
876 uint32_t has_mobil_ext:1;
877 /**< Header contains Mobility extension header. */
878 uint32_t has_hip_ext:1;
879 /**< Header contains Host Identity Protocol extension header. */
880 uint32_t has_shim6_ext:1;
881 /**< Header contains Shim6 Protocol extension header. */
882 uint32_t reserved:23;
883 /**< Reserved for future extension headers, must be zero. */
886 /** Default mask for RTE_FLOW_ITEM_TYPE_IPV6. */
888 static const struct rte_flow_item_ipv6 rte_flow_item_ipv6_mask = {
891 "\xff\xff\xff\xff\xff\xff\xff\xff"
892 "\xff\xff\xff\xff\xff\xff\xff\xff",
894 "\xff\xff\xff\xff\xff\xff\xff\xff"
895 "\xff\xff\xff\xff\xff\xff\xff\xff",
901 * RTE_FLOW_ITEM_TYPE_ICMP.
903 * Matches an ICMP header.
905 struct rte_flow_item_icmp {
906 struct rte_icmp_hdr hdr; /**< ICMP header definition. */
909 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP. */
911 static const struct rte_flow_item_icmp rte_flow_item_icmp_mask = {
920 * RTE_FLOW_ITEM_TYPE_UDP.
922 * Matches a UDP header.
924 struct rte_flow_item_udp {
925 struct rte_udp_hdr hdr; /**< UDP header definition. */
928 /** Default mask for RTE_FLOW_ITEM_TYPE_UDP. */
930 static const struct rte_flow_item_udp rte_flow_item_udp_mask = {
932 .src_port = RTE_BE16(0xffff),
933 .dst_port = RTE_BE16(0xffff),
939 * RTE_FLOW_ITEM_TYPE_TCP.
941 * Matches a TCP header.
943 struct rte_flow_item_tcp {
944 struct rte_tcp_hdr hdr; /**< TCP header definition. */
947 /** Default mask for RTE_FLOW_ITEM_TYPE_TCP. */
949 static const struct rte_flow_item_tcp rte_flow_item_tcp_mask = {
951 .src_port = RTE_BE16(0xffff),
952 .dst_port = RTE_BE16(0xffff),
958 * RTE_FLOW_ITEM_TYPE_SCTP.
960 * Matches a SCTP header.
962 struct rte_flow_item_sctp {
963 struct rte_sctp_hdr hdr; /**< SCTP header definition. */
966 /** Default mask for RTE_FLOW_ITEM_TYPE_SCTP. */
968 static const struct rte_flow_item_sctp rte_flow_item_sctp_mask = {
970 .src_port = RTE_BE16(0xffff),
971 .dst_port = RTE_BE16(0xffff),
977 * RTE_FLOW_ITEM_TYPE_VXLAN.
979 * Matches a VXLAN header (RFC 7348).
982 struct rte_flow_item_vxlan {
986 * These fields are retained for compatibility.
987 * Please switch to the new header field below.
989 uint8_t flags; /**< Normally 0x08 (I flag). */
990 uint8_t rsvd0[3]; /**< Reserved, normally 0x000000. */
991 uint8_t vni[3]; /**< VXLAN identifier. */
992 uint8_t rsvd1; /**< Reserved, normally 0x00. */
994 struct rte_vxlan_hdr hdr;
998 /** Default mask for RTE_FLOW_ITEM_TYPE_VXLAN. */
1000 static const struct rte_flow_item_vxlan rte_flow_item_vxlan_mask = {
1001 .hdr.vx_vni = RTE_BE32(0xffffff00), /* (0xffffff << 8) */
1006 * RTE_FLOW_ITEM_TYPE_E_TAG.
1008 * Matches a E-tag header.
1010 * The corresponding standard outer EtherType (TPID) value is
1011 * RTE_ETHER_TYPE_ETAG. It can be overridden by the preceding pattern item.
1013 struct rte_flow_item_e_tag {
1015 * E-Tag control information (E-TCI).
1016 * E-PCP (3b), E-DEI (1b), ingress E-CID base (12b).
1018 rte_be16_t epcp_edei_in_ecid_b;
1019 /** Reserved (2b), GRP (2b), E-CID base (12b). */
1020 rte_be16_t rsvd_grp_ecid_b;
1021 uint8_t in_ecid_e; /**< Ingress E-CID ext. */
1022 uint8_t ecid_e; /**< E-CID ext. */
1023 rte_be16_t inner_type; /**< Inner EtherType or TPID. */
1026 /** Default mask for RTE_FLOW_ITEM_TYPE_E_TAG. */
1028 static const struct rte_flow_item_e_tag rte_flow_item_e_tag_mask = {
1029 .rsvd_grp_ecid_b = RTE_BE16(0x3fff),
1034 * RTE_FLOW_ITEM_TYPE_NVGRE.
1036 * Matches a NVGRE header.
1038 struct rte_flow_item_nvgre {
1040 * Checksum (1b), undefined (1b), key bit (1b), sequence number (1b),
1041 * reserved 0 (9b), version (3b).
1043 * c_k_s_rsvd0_ver must have value 0x2000 according to RFC 7637.
1045 rte_be16_t c_k_s_rsvd0_ver;
1046 rte_be16_t protocol; /**< Protocol type (0x6558). */
1047 uint8_t tni[3]; /**< Virtual subnet ID. */
1048 uint8_t flow_id; /**< Flow ID. */
1051 /** Default mask for RTE_FLOW_ITEM_TYPE_NVGRE. */
1053 static const struct rte_flow_item_nvgre rte_flow_item_nvgre_mask = {
1054 .tni = "\xff\xff\xff",
1059 * RTE_FLOW_ITEM_TYPE_MPLS.
1061 * Matches a MPLS header.
1063 struct rte_flow_item_mpls {
1065 * Label (20b), TC (3b), Bottom of Stack (1b).
1067 uint8_t label_tc_s[3];
1068 uint8_t ttl; /** Time-to-Live. */
1071 /** Default mask for RTE_FLOW_ITEM_TYPE_MPLS. */
1073 static const struct rte_flow_item_mpls rte_flow_item_mpls_mask = {
1074 .label_tc_s = "\xff\xff\xf0",
1079 * RTE_FLOW_ITEM_TYPE_GRE.
1081 * Matches a GRE header.
1083 struct rte_flow_item_gre {
1085 * Checksum (1b), reserved 0 (12b), version (3b).
1086 * Refer to RFC 2784.
1088 rte_be16_t c_rsvd0_ver;
1089 rte_be16_t protocol; /**< Protocol type. */
1092 /** Default mask for RTE_FLOW_ITEM_TYPE_GRE. */
1094 static const struct rte_flow_item_gre rte_flow_item_gre_mask = {
1095 .protocol = RTE_BE16(0xffff),
1100 * RTE_FLOW_ITEM_TYPE_FUZZY
1102 * Fuzzy pattern match, expect faster than default.
1104 * This is for device that support fuzzy match option.
1105 * Usually a fuzzy match is fast but the cost is accuracy.
1106 * i.e. Signature Match only match pattern's hash value, but it is
1107 * possible two different patterns have the same hash value.
1109 * Matching accuracy level can be configure by threshold.
1110 * Driver can divide the range of threshold and map to different
1111 * accuracy levels that device support.
1113 * Threshold 0 means perfect match (no fuzziness), while threshold
1114 * 0xffffffff means fuzziest match.
1116 struct rte_flow_item_fuzzy {
1117 uint32_t thresh; /**< Accuracy threshold. */
1120 /** Default mask for RTE_FLOW_ITEM_TYPE_FUZZY. */
1122 static const struct rte_flow_item_fuzzy rte_flow_item_fuzzy_mask = {
1123 .thresh = 0xffffffff,
1128 * RTE_FLOW_ITEM_TYPE_GTP.
1130 * Matches a GTPv1 header.
1132 struct rte_flow_item_gtp {
1134 * Version (3b), protocol type (1b), reserved (1b),
1135 * Extension header flag (1b),
1136 * Sequence number flag (1b),
1137 * N-PDU number flag (1b).
1139 uint8_t v_pt_rsv_flags;
1140 uint8_t msg_type; /**< Message type. */
1141 rte_be16_t msg_len; /**< Message length. */
1142 rte_be32_t teid; /**< Tunnel endpoint identifier. */
1145 /** Default mask for RTE_FLOW_ITEM_TYPE_GTP. */
1147 static const struct rte_flow_item_gtp rte_flow_item_gtp_mask = {
1148 .teid = RTE_BE32(0xffffffff),
1153 * RTE_FLOW_ITEM_TYPE_ESP
1155 * Matches an ESP header.
1157 struct rte_flow_item_esp {
1158 struct rte_esp_hdr hdr; /**< ESP header definition. */
1161 /** Default mask for RTE_FLOW_ITEM_TYPE_ESP. */
1163 static const struct rte_flow_item_esp rte_flow_item_esp_mask = {
1165 .spi = RTE_BE32(0xffffffff),
1171 * RTE_FLOW_ITEM_TYPE_GENEVE.
1173 * Matches a GENEVE header.
1175 struct rte_flow_item_geneve {
1177 * Version (2b), length of the options fields (6b), OAM packet (1b),
1178 * critical options present (1b), reserved 0 (6b).
1180 rte_be16_t ver_opt_len_o_c_rsvd0;
1181 rte_be16_t protocol; /**< Protocol type. */
1182 uint8_t vni[3]; /**< Virtual Network Identifier. */
1183 uint8_t rsvd1; /**< Reserved, normally 0x00. */
1186 /** Default mask for RTE_FLOW_ITEM_TYPE_GENEVE. */
1188 static const struct rte_flow_item_geneve rte_flow_item_geneve_mask = {
1189 .vni = "\xff\xff\xff",
1194 * RTE_FLOW_ITEM_TYPE_VXLAN_GPE (draft-ietf-nvo3-vxlan-gpe-05).
1196 * Matches a VXLAN-GPE header.
1198 struct rte_flow_item_vxlan_gpe {
1199 uint8_t flags; /**< Normally 0x0c (I and P flags). */
1200 uint8_t rsvd0[2]; /**< Reserved, normally 0x0000. */
1201 uint8_t protocol; /**< Protocol type. */
1202 uint8_t vni[3]; /**< VXLAN identifier. */
1203 uint8_t rsvd1; /**< Reserved, normally 0x00. */
1206 /** Default mask for RTE_FLOW_ITEM_TYPE_VXLAN_GPE. */
1208 static const struct rte_flow_item_vxlan_gpe rte_flow_item_vxlan_gpe_mask = {
1209 .vni = "\xff\xff\xff",
1214 * RTE_FLOW_ITEM_TYPE_ARP_ETH_IPV4
1216 * Matches an ARP header for Ethernet/IPv4.
1218 struct rte_flow_item_arp_eth_ipv4 {
1219 rte_be16_t hrd; /**< Hardware type, normally 1. */
1220 rte_be16_t pro; /**< Protocol type, normally 0x0800. */
1221 uint8_t hln; /**< Hardware address length, normally 6. */
1222 uint8_t pln; /**< Protocol address length, normally 4. */
1223 rte_be16_t op; /**< Opcode (1 for request, 2 for reply). */
1224 struct rte_ether_addr sha; /**< Sender hardware address. */
1225 rte_be32_t spa; /**< Sender IPv4 address. */
1226 struct rte_ether_addr tha; /**< Target hardware address. */
1227 rte_be32_t tpa; /**< Target IPv4 address. */
1230 /** Default mask for RTE_FLOW_ITEM_TYPE_ARP_ETH_IPV4. */
1232 static const struct rte_flow_item_arp_eth_ipv4
1233 rte_flow_item_arp_eth_ipv4_mask = {
1234 .sha.addr_bytes = "\xff\xff\xff\xff\xff\xff",
1235 .spa = RTE_BE32(0xffffffff),
1236 .tha.addr_bytes = "\xff\xff\xff\xff\xff\xff",
1237 .tpa = RTE_BE32(0xffffffff),
1242 * RTE_FLOW_ITEM_TYPE_IPV6_EXT
1244 * Matches the presence of any IPv6 extension header.
1246 * Normally preceded by any of:
1248 * - RTE_FLOW_ITEM_TYPE_IPV6
1249 * - RTE_FLOW_ITEM_TYPE_IPV6_EXT
1251 struct rte_flow_item_ipv6_ext {
1252 uint8_t next_hdr; /**< Next header. */
1255 /** Default mask for RTE_FLOW_ITEM_TYPE_IPV6_EXT. */
1258 struct rte_flow_item_ipv6_ext rte_flow_item_ipv6_ext_mask = {
1264 * RTE_FLOW_ITEM_TYPE_IPV6_FRAG_EXT
1266 * Matches the presence of IPv6 fragment extension header.
1268 * Preceded by any of:
1270 * - RTE_FLOW_ITEM_TYPE_IPV6
1271 * - RTE_FLOW_ITEM_TYPE_IPV6_EXT
1273 struct rte_flow_item_ipv6_frag_ext {
1274 struct rte_ipv6_fragment_ext hdr;
1278 * RTE_FLOW_ITEM_TYPE_ICMP6
1280 * Matches any ICMPv6 header.
1282 struct rte_flow_item_icmp6 {
1283 uint8_t type; /**< ICMPv6 type. */
1284 uint8_t code; /**< ICMPv6 code. */
1285 uint16_t checksum; /**< ICMPv6 checksum. */
1288 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6. */
1290 static const struct rte_flow_item_icmp6 rte_flow_item_icmp6_mask = {
1297 * RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS
1299 * Matches an ICMPv6 neighbor discovery solicitation.
1301 struct rte_flow_item_icmp6_nd_ns {
1302 uint8_t type; /**< ICMPv6 type, normally 135. */
1303 uint8_t code; /**< ICMPv6 code, normally 0. */
1304 rte_be16_t checksum; /**< ICMPv6 checksum. */
1305 rte_be32_t reserved; /**< Reserved, normally 0. */
1306 uint8_t target_addr[16]; /**< Target address. */
1309 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS. */
1312 struct rte_flow_item_icmp6_nd_ns rte_flow_item_icmp6_nd_ns_mask = {
1314 "\xff\xff\xff\xff\xff\xff\xff\xff"
1315 "\xff\xff\xff\xff\xff\xff\xff\xff",
1320 * RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA
1322 * Matches an ICMPv6 neighbor discovery advertisement.
1324 struct rte_flow_item_icmp6_nd_na {
1325 uint8_t type; /**< ICMPv6 type, normally 136. */
1326 uint8_t code; /**< ICMPv6 code, normally 0. */
1327 rte_be16_t checksum; /**< ICMPv6 checksum. */
1329 * Route flag (1b), solicited flag (1b), override flag (1b),
1332 rte_be32_t rso_reserved;
1333 uint8_t target_addr[16]; /**< Target address. */
1336 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA. */
1339 struct rte_flow_item_icmp6_nd_na rte_flow_item_icmp6_nd_na_mask = {
1341 "\xff\xff\xff\xff\xff\xff\xff\xff"
1342 "\xff\xff\xff\xff\xff\xff\xff\xff",
1347 * RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT
1349 * Matches the presence of any ICMPv6 neighbor discovery option.
1351 * Normally preceded by any of:
1353 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA
1354 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS
1355 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT
1357 struct rte_flow_item_icmp6_nd_opt {
1358 uint8_t type; /**< ND option type. */
1359 uint8_t length; /**< ND option length. */
1362 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT. */
1364 static const struct rte_flow_item_icmp6_nd_opt
1365 rte_flow_item_icmp6_nd_opt_mask = {
1371 * RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_SLA_ETH
1373 * Matches an ICMPv6 neighbor discovery source Ethernet link-layer address
1376 * Normally preceded by any of:
1378 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA
1379 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT
1381 struct rte_flow_item_icmp6_nd_opt_sla_eth {
1382 uint8_t type; /**< ND option type, normally 1. */
1383 uint8_t length; /**< ND option length, normally 1. */
1384 struct rte_ether_addr sla; /**< Source Ethernet LLA. */
1387 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_SLA_ETH. */
1389 static const struct rte_flow_item_icmp6_nd_opt_sla_eth
1390 rte_flow_item_icmp6_nd_opt_sla_eth_mask = {
1391 .sla.addr_bytes = "\xff\xff\xff\xff\xff\xff",
1396 * RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_TLA_ETH
1398 * Matches an ICMPv6 neighbor discovery target Ethernet link-layer address
1401 * Normally preceded by any of:
1403 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS
1404 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT
1406 struct rte_flow_item_icmp6_nd_opt_tla_eth {
1407 uint8_t type; /**< ND option type, normally 2. */
1408 uint8_t length; /**< ND option length, normally 1. */
1409 struct rte_ether_addr tla; /**< Target Ethernet LLA. */
1412 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_TLA_ETH. */
1414 static const struct rte_flow_item_icmp6_nd_opt_tla_eth
1415 rte_flow_item_icmp6_nd_opt_tla_eth_mask = {
1416 .tla.addr_bytes = "\xff\xff\xff\xff\xff\xff",
1421 * RTE_FLOW_ITEM_TYPE_META
1423 * Matches a specified metadata value. On egress, metadata can be set
1424 * either by mbuf dynamic metadata field with PKT_TX_DYNF_METADATA flag or
1425 * RTE_FLOW_ACTION_TYPE_SET_META. On ingress, RTE_FLOW_ACTION_TYPE_SET_META
1426 * sets metadata for a packet and the metadata will be reported via mbuf
1427 * metadata dynamic field with PKT_RX_DYNF_METADATA flag. The dynamic mbuf
1428 * field must be registered in advance by rte_flow_dynf_metadata_register().
1430 struct rte_flow_item_meta {
1434 /** Default mask for RTE_FLOW_ITEM_TYPE_META. */
1436 static const struct rte_flow_item_meta rte_flow_item_meta_mask = {
1442 * RTE_FLOW_ITEM_TYPE_GTP_PSC.
1444 * Matches a GTP PDU extension header with type 0x85.
1446 struct rte_flow_item_gtp_psc {
1447 uint8_t pdu_type; /**< PDU type. */
1448 uint8_t qfi; /**< PPP, RQI, QoS flow identifier. */
1451 /** Default mask for RTE_FLOW_ITEM_TYPE_GTP_PSC. */
1453 static const struct rte_flow_item_gtp_psc
1454 rte_flow_item_gtp_psc_mask = {
1460 * RTE_FLOW_ITEM_TYPE_PPPOE.
1462 * Matches a PPPoE header.
1464 struct rte_flow_item_pppoe {
1466 * Version (4b), type (4b).
1468 uint8_t version_type;
1469 uint8_t code; /**< Message type. */
1470 rte_be16_t session_id; /**< Session identifier. */
1471 rte_be16_t length; /**< Payload length. */
1475 * RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID.
1477 * Matches a PPPoE optional proto_id field.
1479 * It only applies to PPPoE session packets.
1481 * Normally preceded by any of:
1483 * - RTE_FLOW_ITEM_TYPE_PPPOE
1484 * - RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID
1486 struct rte_flow_item_pppoe_proto_id {
1487 rte_be16_t proto_id; /**< PPP protocol identifier. */
1490 /** Default mask for RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID. */
1492 static const struct rte_flow_item_pppoe_proto_id
1493 rte_flow_item_pppoe_proto_id_mask = {
1494 .proto_id = RTE_BE16(0xffff),
1500 * @b EXPERIMENTAL: this structure may change without prior notice
1502 * RTE_FLOW_ITEM_TYPE_TAG
1504 * Matches a specified tag value at the specified index.
1506 struct rte_flow_item_tag {
1511 /** Default mask for RTE_FLOW_ITEM_TYPE_TAG. */
1513 static const struct rte_flow_item_tag rte_flow_item_tag_mask = {
1520 * RTE_FLOW_ITEM_TYPE_L2TPV3OIP.
1522 * Matches a L2TPv3 over IP header.
1524 struct rte_flow_item_l2tpv3oip {
1525 rte_be32_t session_id; /**< Session ID. */
1528 /** Default mask for RTE_FLOW_ITEM_TYPE_L2TPV3OIP. */
1530 static const struct rte_flow_item_l2tpv3oip rte_flow_item_l2tpv3oip_mask = {
1531 .session_id = RTE_BE32(UINT32_MAX),
1538 * @b EXPERIMENTAL: this structure may change without prior notice
1540 * RTE_FLOW_ITEM_TYPE_MARK
1542 * Matches an arbitrary integer value which was set using the ``MARK`` action
1543 * in a previously matched rule.
1545 * This item can only be specified once as a match criteria as the ``MARK``
1546 * action can only be specified once in a flow action.
1548 * This value is arbitrary and application-defined. Maximum allowed value
1549 * depends on the underlying implementation.
1551 * Depending on the underlying implementation the MARK item may be supported on
1552 * the physical device, with virtual groups in the PMD or not at all.
1554 struct rte_flow_item_mark {
1555 uint32_t id; /**< Integer value to match against. */
1558 /** Default mask for RTE_FLOW_ITEM_TYPE_MARK. */
1560 static const struct rte_flow_item_mark rte_flow_item_mark_mask = {
1567 * @b EXPERIMENTAL: this structure may change without prior notice
1569 * RTE_FLOW_ITEM_TYPE_NSH
1571 * Match network service header (NSH), RFC 8300
1574 struct rte_flow_item_nsh {
1577 uint32_t reserved:1;
1580 uint32_t reserved1:4;
1582 uint32_t next_proto:8;
1587 /** Default mask for RTE_FLOW_ITEM_TYPE_NSH. */
1589 static const struct rte_flow_item_nsh rte_flow_item_nsh_mask = {
1599 * @b EXPERIMENTAL: this structure may change without prior notice
1601 * RTE_FLOW_ITEM_TYPE_IGMP
1603 * Match Internet Group Management Protocol (IGMP), RFC 2236
1606 struct rte_flow_item_igmp {
1608 uint32_t max_resp_time:8;
1609 uint32_t checksum:16;
1610 uint32_t group_addr;
1613 /** Default mask for RTE_FLOW_ITEM_TYPE_IGMP. */
1615 static const struct rte_flow_item_igmp rte_flow_item_igmp_mask = {
1616 .group_addr = 0xffffffff,
1622 * @b EXPERIMENTAL: this structure may change without prior notice
1624 * RTE_FLOW_ITEM_TYPE_AH
1626 * Match IP Authentication Header (AH), RFC 4302
1629 struct rte_flow_item_ah {
1630 uint32_t next_hdr:8;
1631 uint32_t payload_len:8;
1632 uint32_t reserved:16;
1637 /** Default mask for RTE_FLOW_ITEM_TYPE_AH. */
1639 static const struct rte_flow_item_ah rte_flow_item_ah_mask = {
1646 * @b EXPERIMENTAL: this structure may change without prior notice
1648 * RTE_FLOW_ITEM_TYPE_PFCP
1652 struct rte_flow_item_pfcp {
1659 /** Default mask for RTE_FLOW_ITEM_TYPE_PFCP. */
1661 static const struct rte_flow_item_pfcp rte_flow_item_pfcp_mask = {
1663 .seid = RTE_BE64(UINT64_C(0xffffffffffffffff)),
1669 * @b EXPERIMENTAL: this structure may change without prior notice
1671 * RTE_FLOW_ITEM_TYPE_ECPRI
1673 * Match eCPRI Header
1675 struct rte_flow_item_ecpri {
1676 struct rte_ecpri_combined_msg_hdr hdr;
1679 /** Default mask for RTE_FLOW_ITEM_TYPE_ECPRI. */
1681 static const struct rte_flow_item_ecpri rte_flow_item_ecpri_mask = {
1691 * RTE_FLOW_ITEM_TYPE_GENEVE_OPT
1693 * Matches a GENEVE Variable Length Option
1695 struct rte_flow_item_geneve_opt {
1696 rte_be16_t option_class;
1697 uint8_t option_type;
1702 /** Default mask for RTE_FLOW_ITEM_TYPE_GENEVE_OPT. */
1704 static const struct rte_flow_item_geneve_opt
1705 rte_flow_item_geneve_opt_mask = {
1706 .option_type = 0xff,
1712 * @b EXPERIMENTAL: this structure may change without prior notice
1714 * RTE_FLOW_ITEM_TYPE_INTEGRITY
1716 * Match on packet integrity check result.
1718 struct rte_flow_item_integrity {
1719 /** Tunnel encapsulation level the item should apply to.
1720 * @see rte_flow_action_rss
1727 /** The packet is valid after passing all HW checks. */
1728 uint64_t packet_ok:1;
1729 /** L2 layer is valid after passing all HW checks. */
1731 /** L3 layer is valid after passing all HW checks. */
1733 /** L4 layer is valid after passing all HW checks. */
1735 /** L2 layer CRC is valid. */
1736 uint64_t l2_crc_ok:1;
1737 /** IPv4 layer checksum is valid. */
1738 uint64_t ipv4_csum_ok:1;
1739 /** L4 layer checksum is valid. */
1740 uint64_t l4_csum_ok:1;
1741 /** L3 length is smaller than frame length. */
1742 uint64_t l3_len_ok:1;
1743 uint64_t reserved:56;
1750 static const struct rte_flow_item_integrity
1751 rte_flow_item_integrity_mask = {
1758 * The packet is valid after conntrack checking.
1760 #define RTE_FLOW_CONNTRACK_PKT_STATE_VALID RTE_BIT32(0)
1762 * The state of the connection is changed.
1764 #define RTE_FLOW_CONNTRACK_PKT_STATE_CHANGED RTE_BIT32(1)
1766 * Error is detected on this packet for this connection and
1767 * an invalid state is set.
1769 #define RTE_FLOW_CONNTRACK_PKT_STATE_INVALID RTE_BIT32(2)
1771 * The HW connection tracking module is disabled.
1772 * It can be due to application command or an invalid state.
1774 #define RTE_FLOW_CONNTRACK_PKT_STATE_DISABLED RTE_BIT32(3)
1776 * The packet contains some bad field(s) and cannot continue
1777 * with the conntrack module checking.
1779 #define RTE_FLOW_CONNTRACK_PKT_STATE_BAD RTE_BIT32(4)
1783 * @b EXPERIMENTAL: this structure may change without prior notice
1785 * RTE_FLOW_ITEM_TYPE_CONNTRACK
1787 * Matches the state of a packet after it passed the connection tracking
1788 * examination. The state is a bitmap of one RTE_FLOW_CONNTRACK_PKT_STATE*
1789 * or a reasonable combination of these bits.
1791 struct rte_flow_item_conntrack {
1795 /** Default mask for RTE_FLOW_ITEM_TYPE_CONNTRACK. */
1797 static const struct rte_flow_item_conntrack rte_flow_item_conntrack_mask = {
1798 .flags = 0xffffffff,
1803 * Matching pattern item definition.
1805 * A pattern is formed by stacking items starting from the lowest protocol
1806 * layer to match. This stacking restriction does not apply to meta items
1807 * which can be placed anywhere in the stack without affecting the meaning
1808 * of the resulting pattern.
1810 * Patterns are terminated by END items.
1812 * The spec field should be a valid pointer to a structure of the related
1813 * item type. It may remain unspecified (NULL) in many cases to request
1814 * broad (nonspecific) matching. In such cases, last and mask must also be
1817 * Optionally, last can point to a structure of the same type to define an
1818 * inclusive range. This is mostly supported by integer and address fields,
1819 * may cause errors otherwise. Fields that do not support ranges must be set
1820 * to 0 or to the same value as the corresponding fields in spec.
1822 * Only the fields defined to nonzero values in the default masks (see
1823 * rte_flow_item_{name}_mask constants) are considered relevant by
1824 * default. This can be overridden by providing a mask structure of the
1825 * same type with applicable bits set to one. It can also be used to
1826 * partially filter out specific fields (e.g. as an alternate mean to match
1827 * ranges of IP addresses).
1829 * Mask is a simple bit-mask applied before interpreting the contents of
1830 * spec and last, which may yield unexpected results if not used
1831 * carefully. For example, if for an IPv4 address field, spec provides
1832 * 10.1.2.3, last provides 10.3.4.5 and mask provides 255.255.0.0, the
1833 * effective range becomes 10.1.0.0 to 10.3.255.255.
1835 struct rte_flow_item {
1836 enum rte_flow_item_type type; /**< Item type. */
1837 const void *spec; /**< Pointer to item specification structure. */
1838 const void *last; /**< Defines an inclusive range (spec to last). */
1839 const void *mask; /**< Bit-mask applied to spec and last. */
1845 * Each possible action is represented by a type.
1846 * An action can have an associated configuration object.
1847 * Several actions combined in a list can be assigned
1848 * to a flow rule and are performed in order.
1850 * They fall in three categories:
1852 * - Actions that modify the fate of matching traffic, for instance by
1853 * dropping or assigning it a specific destination.
1855 * - Actions that modify matching traffic contents or its properties. This
1856 * includes adding/removing encapsulation, encryption, compression and
1859 * - Actions related to the flow rule itself, such as updating counters or
1860 * making it non-terminating.
1862 * Flow rules being terminating by default, not specifying any action of the
1863 * fate kind results in undefined behavior. This applies to both ingress and
1866 * PASSTHRU, when supported, makes a flow rule non-terminating.
1868 enum rte_flow_action_type {
1870 * End marker for action lists. Prevents further processing of
1871 * actions, thereby ending the list.
1873 * No associated configuration structure.
1875 RTE_FLOW_ACTION_TYPE_END,
1878 * Used as a placeholder for convenience. It is ignored and simply
1879 * discarded by PMDs.
1881 * No associated configuration structure.
1883 RTE_FLOW_ACTION_TYPE_VOID,
1886 * Leaves traffic up for additional processing by subsequent flow
1887 * rules; makes a flow rule non-terminating.
1889 * No associated configuration structure.
1891 RTE_FLOW_ACTION_TYPE_PASSTHRU,
1894 * RTE_FLOW_ACTION_TYPE_JUMP
1896 * Redirects packets to a group on the current device.
1898 * See struct rte_flow_action_jump.
1900 RTE_FLOW_ACTION_TYPE_JUMP,
1903 * Attaches an integer value to packets and sets PKT_RX_FDIR and
1904 * PKT_RX_FDIR_ID mbuf flags.
1906 * See struct rte_flow_action_mark.
1908 RTE_FLOW_ACTION_TYPE_MARK,
1911 * Flags packets. Similar to MARK without a specific value; only
1912 * sets the PKT_RX_FDIR mbuf flag.
1914 * No associated configuration structure.
1916 RTE_FLOW_ACTION_TYPE_FLAG,
1919 * Assigns packets to a given queue index.
1921 * See struct rte_flow_action_queue.
1923 RTE_FLOW_ACTION_TYPE_QUEUE,
1928 * PASSTHRU overrides this action if both are specified.
1930 * No associated configuration structure.
1932 RTE_FLOW_ACTION_TYPE_DROP,
1935 * Enables counters for this flow rule.
1937 * These counters can be retrieved and reset through rte_flow_query() or
1938 * rte_flow_action_handle_query() if the action provided via handle,
1939 * see struct rte_flow_query_count.
1941 * See struct rte_flow_action_count.
1943 RTE_FLOW_ACTION_TYPE_COUNT,
1946 * Similar to QUEUE, except RSS is additionally performed on packets
1947 * to spread them among several queues according to the provided
1950 * See struct rte_flow_action_rss.
1952 RTE_FLOW_ACTION_TYPE_RSS,
1955 * Directs matching traffic to the physical function (PF) of the
1958 * No associated configuration structure.
1960 RTE_FLOW_ACTION_TYPE_PF,
1963 * Directs matching traffic to a given virtual function of the
1966 * See struct rte_flow_action_vf.
1968 RTE_FLOW_ACTION_TYPE_VF,
1971 * Directs packets to a given physical port index of the underlying
1974 * See struct rte_flow_action_phy_port.
1976 RTE_FLOW_ACTION_TYPE_PHY_PORT,
1979 * Directs matching traffic to a given DPDK port ID.
1981 * See struct rte_flow_action_port_id.
1983 RTE_FLOW_ACTION_TYPE_PORT_ID,
1986 * Traffic metering and policing (MTR).
1988 * See struct rte_flow_action_meter.
1989 * See file rte_mtr.h for MTR object configuration.
1991 RTE_FLOW_ACTION_TYPE_METER,
1994 * Redirects packets to security engine of current device for security
1995 * processing as specified by security session.
1997 * See struct rte_flow_action_security.
1999 RTE_FLOW_ACTION_TYPE_SECURITY,
2002 * Implements OFPAT_SET_MPLS_TTL ("MPLS TTL") as defined by the
2003 * OpenFlow Switch Specification.
2005 * See struct rte_flow_action_of_set_mpls_ttl.
2007 RTE_FLOW_ACTION_TYPE_OF_SET_MPLS_TTL,
2010 * Implements OFPAT_DEC_MPLS_TTL ("decrement MPLS TTL") as defined
2011 * by the OpenFlow Switch Specification.
2013 * No associated configuration structure.
2015 RTE_FLOW_ACTION_TYPE_OF_DEC_MPLS_TTL,
2018 * Implements OFPAT_SET_NW_TTL ("IP TTL") as defined by the OpenFlow
2019 * Switch Specification.
2021 * See struct rte_flow_action_of_set_nw_ttl.
2023 RTE_FLOW_ACTION_TYPE_OF_SET_NW_TTL,
2026 * Implements OFPAT_DEC_NW_TTL ("decrement IP TTL") as defined by
2027 * the OpenFlow Switch Specification.
2029 * No associated configuration structure.
2031 RTE_FLOW_ACTION_TYPE_OF_DEC_NW_TTL,
2034 * Implements OFPAT_COPY_TTL_OUT ("copy TTL "outwards" -- from
2035 * next-to-outermost to outermost") as defined by the OpenFlow
2036 * Switch Specification.
2038 * No associated configuration structure.
2040 RTE_FLOW_ACTION_TYPE_OF_COPY_TTL_OUT,
2043 * Implements OFPAT_COPY_TTL_IN ("copy TTL "inwards" -- from
2044 * outermost to next-to-outermost") as defined by the OpenFlow
2045 * Switch Specification.
2047 * No associated configuration structure.
2049 RTE_FLOW_ACTION_TYPE_OF_COPY_TTL_IN,
2052 * Implements OFPAT_POP_VLAN ("pop the outer VLAN tag") as defined
2053 * by the OpenFlow Switch Specification.
2055 * No associated configuration structure.
2057 RTE_FLOW_ACTION_TYPE_OF_POP_VLAN,
2060 * Implements OFPAT_PUSH_VLAN ("push a new VLAN tag") as defined by
2061 * the OpenFlow Switch Specification.
2063 * See struct rte_flow_action_of_push_vlan.
2065 RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN,
2068 * Implements OFPAT_SET_VLAN_VID ("set the 802.1q VLAN id") as
2069 * defined by the OpenFlow Switch Specification.
2071 * See struct rte_flow_action_of_set_vlan_vid.
2073 RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID,
2076 * Implements OFPAT_SET_LAN_PCP ("set the 802.1q priority") as
2077 * defined by the OpenFlow Switch Specification.
2079 * See struct rte_flow_action_of_set_vlan_pcp.
2081 RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP,
2084 * Implements OFPAT_POP_MPLS ("pop the outer MPLS tag") as defined
2085 * by the OpenFlow Switch Specification.
2087 * See struct rte_flow_action_of_pop_mpls.
2089 RTE_FLOW_ACTION_TYPE_OF_POP_MPLS,
2092 * Implements OFPAT_PUSH_MPLS ("push a new MPLS tag") as defined by
2093 * the OpenFlow Switch Specification.
2095 * See struct rte_flow_action_of_push_mpls.
2097 RTE_FLOW_ACTION_TYPE_OF_PUSH_MPLS,
2100 * Encapsulate flow in VXLAN tunnel as defined in
2101 * rte_flow_action_vxlan_encap action structure.
2103 * See struct rte_flow_action_vxlan_encap.
2105 RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP,
2108 * Decapsulate outer most VXLAN tunnel from matched flow.
2110 * If flow pattern does not define a valid VXLAN tunnel (as specified by
2111 * RFC7348) then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION
2114 RTE_FLOW_ACTION_TYPE_VXLAN_DECAP,
2117 * Encapsulate flow in NVGRE tunnel defined in the
2118 * rte_flow_action_nvgre_encap action structure.
2120 * See struct rte_flow_action_nvgre_encap.
2122 RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP,
2125 * Decapsulate outer most NVGRE tunnel from matched flow.
2127 * If flow pattern does not define a valid NVGRE tunnel (as specified by
2128 * RFC7637) then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION
2131 RTE_FLOW_ACTION_TYPE_NVGRE_DECAP,
2134 * Add outer header whose template is provided in its data buffer
2136 * See struct rte_flow_action_raw_encap.
2138 RTE_FLOW_ACTION_TYPE_RAW_ENCAP,
2141 * Remove outer header whose template is provided in its data buffer.
2143 * See struct rte_flow_action_raw_decap
2145 RTE_FLOW_ACTION_TYPE_RAW_DECAP,
2148 * Modify IPv4 source address in the outermost IPv4 header.
2150 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV4,
2151 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2153 * See struct rte_flow_action_set_ipv4.
2155 RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC,
2158 * Modify IPv4 destination address in the outermost IPv4 header.
2160 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV4,
2161 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2163 * See struct rte_flow_action_set_ipv4.
2165 RTE_FLOW_ACTION_TYPE_SET_IPV4_DST,
2168 * Modify IPv6 source address in the outermost IPv6 header.
2170 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV6,
2171 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2173 * See struct rte_flow_action_set_ipv6.
2175 RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC,
2178 * Modify IPv6 destination address in the outermost IPv6 header.
2180 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV6,
2181 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2183 * See struct rte_flow_action_set_ipv6.
2185 RTE_FLOW_ACTION_TYPE_SET_IPV6_DST,
2188 * Modify source port number in the outermost TCP/UDP header.
2190 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_TCP
2191 * or RTE_FLOW_ITEM_TYPE_UDP, then the PMD should return a
2192 * RTE_FLOW_ERROR_TYPE_ACTION error.
2194 * See struct rte_flow_action_set_tp.
2196 RTE_FLOW_ACTION_TYPE_SET_TP_SRC,
2199 * Modify destination port number in the outermost TCP/UDP header.
2201 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_TCP
2202 * or RTE_FLOW_ITEM_TYPE_UDP, then the PMD should return a
2203 * RTE_FLOW_ERROR_TYPE_ACTION error.
2205 * See struct rte_flow_action_set_tp.
2207 RTE_FLOW_ACTION_TYPE_SET_TP_DST,
2210 * Swap the source and destination MAC addresses in the outermost
2213 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_ETH,
2214 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2216 * No associated configuration structure.
2218 RTE_FLOW_ACTION_TYPE_MAC_SWAP,
2221 * Decrease TTL value directly
2223 * No associated configuration structure.
2225 RTE_FLOW_ACTION_TYPE_DEC_TTL,
2230 * See struct rte_flow_action_set_ttl
2232 RTE_FLOW_ACTION_TYPE_SET_TTL,
2235 * Set source MAC address from matched flow.
2237 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_ETH,
2238 * the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2240 * See struct rte_flow_action_set_mac.
2242 RTE_FLOW_ACTION_TYPE_SET_MAC_SRC,
2245 * Set destination MAC address from matched flow.
2247 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_ETH,
2248 * the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2250 * See struct rte_flow_action_set_mac.
2252 RTE_FLOW_ACTION_TYPE_SET_MAC_DST,
2255 * Increase sequence number in the outermost TCP header.
2257 * Action configuration specifies the value to increase
2258 * TCP sequence number as a big-endian 32 bit integer.
2261 * @code rte_be32_t * @endcode
2263 * Using this action on non-matching traffic will result in
2264 * undefined behavior.
2266 RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ,
2269 * Decrease sequence number in the outermost TCP header.
2271 * Action configuration specifies the value to decrease
2272 * TCP sequence number as a big-endian 32 bit integer.
2275 * @code rte_be32_t * @endcode
2277 * Using this action on non-matching traffic will result in
2278 * undefined behavior.
2280 RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ,
2283 * Increase acknowledgment number in the outermost TCP header.
2285 * Action configuration specifies the value to increase
2286 * TCP acknowledgment number as a big-endian 32 bit integer.
2289 * @code rte_be32_t * @endcode
2291 * Using this action on non-matching traffic will result in
2292 * undefined behavior.
2294 RTE_FLOW_ACTION_TYPE_INC_TCP_ACK,
2297 * Decrease acknowledgment number in the outermost TCP header.
2299 * Action configuration specifies the value to decrease
2300 * TCP acknowledgment number as a big-endian 32 bit integer.
2303 * @code rte_be32_t * @endcode
2305 * Using this action on non-matching traffic will result in
2306 * undefined behavior.
2308 RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK,
2313 * Tag is for internal flow usage only and
2314 * is not delivered to the application.
2316 * See struct rte_flow_action_set_tag.
2318 RTE_FLOW_ACTION_TYPE_SET_TAG,
2321 * Set metadata on ingress or egress path.
2323 * See struct rte_flow_action_set_meta.
2325 RTE_FLOW_ACTION_TYPE_SET_META,
2328 * Modify IPv4 DSCP in the outermost IP header.
2330 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV4,
2331 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2333 * See struct rte_flow_action_set_dscp.
2335 RTE_FLOW_ACTION_TYPE_SET_IPV4_DSCP,
2338 * Modify IPv6 DSCP in the outermost IP header.
2340 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV6,
2341 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2343 * See struct rte_flow_action_set_dscp.
2345 RTE_FLOW_ACTION_TYPE_SET_IPV6_DSCP,
2348 * Report as aged flow if timeout passed without any matching on the
2351 * See struct rte_flow_action_age.
2352 * See function rte_flow_get_aged_flows
2353 * see enum RTE_ETH_EVENT_FLOW_AGED
2354 * See struct rte_flow_query_age
2356 RTE_FLOW_ACTION_TYPE_AGE,
2359 * The matching packets will be duplicated with specified ratio and
2360 * applied with own set of actions with a fate action.
2362 * See struct rte_flow_action_sample.
2364 RTE_FLOW_ACTION_TYPE_SAMPLE,
2368 * @see RTE_FLOW_ACTION_TYPE_INDIRECT
2370 * Describe action shared across multiple flow rules.
2372 * Allow multiple rules reference the same action by handle (see
2373 * struct rte_flow_shared_action).
2375 RTE_FLOW_ACTION_TYPE_SHARED,
2378 * Modify a packet header field, tag, mark or metadata.
2380 * Allow the modification of an arbitrary header field via
2381 * set, add and sub operations or copying its content into
2382 * tag, meta or mark for future processing.
2384 * See struct rte_flow_action_modify_field.
2386 RTE_FLOW_ACTION_TYPE_MODIFY_FIELD,
2389 * An action handle is referenced in a rule through an indirect action.
2391 * The same action handle may be used in multiple rules for the same
2392 * or different ethdev ports.
2394 RTE_FLOW_ACTION_TYPE_INDIRECT,
2399 * Enable tracking a TCP connection state.
2401 * @see struct rte_flow_action_conntrack.
2403 RTE_FLOW_ACTION_TYPE_CONNTRACK,
2406 * Color the packet to reflect the meter color result.
2407 * Set the meter color in the mbuf to the selected color.
2409 * See struct rte_flow_action_meter_color.
2411 RTE_FLOW_ACTION_TYPE_METER_COLOR,
2415 * RTE_FLOW_ACTION_TYPE_MARK
2417 * Attaches an integer value to packets and sets PKT_RX_FDIR and
2418 * PKT_RX_FDIR_ID mbuf flags.
2420 * This value is arbitrary and application-defined. Maximum allowed value
2421 * depends on the underlying implementation. It is returned in the
2422 * hash.fdir.hi mbuf field.
2424 struct rte_flow_action_mark {
2425 uint32_t id; /**< Integer value to return with packets. */
2430 * @b EXPERIMENTAL: this structure may change without prior notice
2432 * RTE_FLOW_ACTION_TYPE_JUMP
2434 * Redirects packets to a group on the current device.
2436 * In a hierarchy of groups, which can be used to represent physical or logical
2437 * flow tables on the device, this action allows the action to be a redirect to
2438 * a group on that device.
2440 struct rte_flow_action_jump {
2445 * RTE_FLOW_ACTION_TYPE_QUEUE
2447 * Assign packets to a given queue index.
2449 struct rte_flow_action_queue {
2450 uint16_t index; /**< Queue index to use. */
2455 * @b EXPERIMENTAL: this structure may change without prior notice
2457 * RTE_FLOW_ACTION_TYPE_AGE
2459 * Report flow as aged-out if timeout passed without any matching
2460 * on the flow. RTE_ETH_EVENT_FLOW_AGED event is triggered when a
2461 * port detects new aged-out flows.
2463 * The flow context and the flow handle will be reported by the
2464 * rte_flow_get_aged_flows API.
2466 struct rte_flow_action_age {
2467 uint32_t timeout:24; /**< Time in seconds. */
2468 uint32_t reserved:8; /**< Reserved, must be zero. */
2470 /**< The user flow context, NULL means the rte_flow pointer. */
2474 * RTE_FLOW_ACTION_TYPE_AGE (query)
2476 * Query structure to retrieve the aging status information of a
2477 * shared AGE action, or a flow rule using the AGE action.
2479 struct rte_flow_query_age {
2480 uint32_t reserved:6; /**< Reserved, must be zero. */
2481 uint32_t aged:1; /**< 1 if aging timeout expired, 0 otherwise. */
2482 uint32_t sec_since_last_hit_valid:1;
2483 /**< sec_since_last_hit value is valid. */
2484 uint32_t sec_since_last_hit:24; /**< Seconds since last traffic hit. */
2489 * @b EXPERIMENTAL: this structure may change without prior notice
2491 * RTE_FLOW_ACTION_TYPE_COUNT
2493 * Adds a counter action to a matched flow.
2495 * If more than one count action is specified in a single flow rule, then each
2496 * action must specify a unique id.
2498 * Counters can be retrieved and reset through ``rte_flow_query()``, see
2499 * ``struct rte_flow_query_count``.
2501 * @deprecated Shared attribute is deprecated, use generic
2502 * RTE_FLOW_ACTION_TYPE_INDIRECT action.
2504 * The shared flag indicates whether the counter is unique to the flow rule the
2505 * action is specified with, or whether it is a shared counter.
2507 * For a count action with the shared flag set, then then a global device
2508 * namespace is assumed for the counter id, so that any matched flow rules using
2509 * a count action with the same counter id on the same port will contribute to
2512 * For ports within the same switch domain then the counter id namespace extends
2513 * to all ports within that switch domain.
2515 struct rte_flow_action_count {
2516 /** @deprecated Share counter ID with other flow rules. */
2518 uint32_t reserved:31; /**< Reserved, must be zero. */
2519 uint32_t id; /**< Counter ID. */
2523 * RTE_FLOW_ACTION_TYPE_COUNT (query)
2525 * Query structure to retrieve and reset flow rule counters.
2527 struct rte_flow_query_count {
2528 uint32_t reset:1; /**< Reset counters after query [in]. */
2529 uint32_t hits_set:1; /**< hits field is set [out]. */
2530 uint32_t bytes_set:1; /**< bytes field is set [out]. */
2531 uint32_t reserved:29; /**< Reserved, must be zero [in, out]. */
2532 uint64_t hits; /**< Number of hits for this rule [out]. */
2533 uint64_t bytes; /**< Number of bytes through this rule [out]. */
2537 * Hash function types.
2539 enum rte_eth_hash_function {
2540 RTE_ETH_HASH_FUNCTION_DEFAULT = 0,
2541 RTE_ETH_HASH_FUNCTION_TOEPLITZ, /**< Toeplitz */
2542 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR, /**< Simple XOR */
2544 * Symmetric Toeplitz: src, dst will be replaced by
2545 * xor(src, dst). For the case with src/dst only,
2546 * src or dst address will xor with zero pair.
2548 RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ,
2549 RTE_ETH_HASH_FUNCTION_MAX,
2553 * RTE_FLOW_ACTION_TYPE_RSS
2555 * Similar to QUEUE, except RSS is additionally performed on packets to
2556 * spread them among several queues according to the provided parameters.
2558 * Unlike global RSS settings used by other DPDK APIs, unsetting the
2559 * @p types field does not disable RSS in a flow rule. Doing so instead
2560 * requests safe unspecified "best-effort" settings from the underlying PMD,
2561 * which depending on the flow rule, may result in anything ranging from
2562 * empty (single queue) to all-inclusive RSS.
2564 * Note: RSS hash result is stored in the hash.rss mbuf field which overlaps
2565 * hash.fdir.lo. Since the MARK action sets the hash.fdir.hi field only,
2566 * both can be requested simultaneously.
2568 struct rte_flow_action_rss {
2569 enum rte_eth_hash_function func; /**< RSS hash function to apply. */
2571 * Packet encapsulation level RSS hash @p types apply to.
2573 * - @p 0 requests the default behavior. Depending on the packet
2574 * type, it can mean outermost, innermost, anything in between or
2577 * It basically stands for the innermost encapsulation level RSS
2578 * can be performed on according to PMD and device capabilities.
2580 * - @p 1 requests RSS to be performed on the outermost packet
2581 * encapsulation level.
2583 * - @p 2 and subsequent values request RSS to be performed on the
2584 * specified inner packet encapsulation level, from outermost to
2585 * innermost (lower to higher values).
2587 * Values other than @p 0 are not necessarily supported.
2589 * Requesting a specific RSS level on unrecognized traffic results
2590 * in undefined behavior. For predictable results, it is recommended
2591 * to make the flow rule pattern match packet headers up to the
2592 * requested encapsulation level so that only matching traffic goes
2596 uint64_t types; /**< Specific RSS hash types (see ETH_RSS_*). */
2597 uint32_t key_len; /**< Hash key length in bytes. */
2598 uint32_t queue_num; /**< Number of entries in @p queue. */
2599 const uint8_t *key; /**< Hash key. */
2600 const uint16_t *queue; /**< Queue indices to use. */
2604 * RTE_FLOW_ACTION_TYPE_VF
2606 * Directs matching traffic to a given virtual function of the current
2609 * Packets matched by a VF pattern item can be redirected to their original
2610 * VF ID instead of the specified one. This parameter may not be available
2611 * and is not guaranteed to work properly if the VF part is matched by a
2612 * prior flow rule or if packets are not addressed to a VF in the first
2615 struct rte_flow_action_vf {
2616 uint32_t original:1; /**< Use original VF ID if possible. */
2617 uint32_t reserved:31; /**< Reserved, must be zero. */
2618 uint32_t id; /**< VF ID. */
2622 * RTE_FLOW_ACTION_TYPE_PHY_PORT
2624 * Directs packets to a given physical port index of the underlying
2627 * @see RTE_FLOW_ITEM_TYPE_PHY_PORT
2629 struct rte_flow_action_phy_port {
2630 uint32_t original:1; /**< Use original port index if possible. */
2631 uint32_t reserved:31; /**< Reserved, must be zero. */
2632 uint32_t index; /**< Physical port index. */
2636 * RTE_FLOW_ACTION_TYPE_PORT_ID
2638 * Directs matching traffic to a given DPDK port ID.
2640 * @see RTE_FLOW_ITEM_TYPE_PORT_ID
2642 struct rte_flow_action_port_id {
2643 uint32_t original:1; /**< Use original DPDK port ID if possible. */
2644 uint32_t reserved:31; /**< Reserved, must be zero. */
2645 uint32_t id; /**< DPDK port ID. */
2649 * RTE_FLOW_ACTION_TYPE_METER
2651 * Traffic metering and policing (MTR).
2653 * Packets matched by items of this type can be either dropped or passed to the
2654 * next item with their color set by the MTR object.
2656 struct rte_flow_action_meter {
2657 uint32_t mtr_id; /**< MTR object ID created with rte_mtr_create(). */
2661 * RTE_FLOW_ACTION_TYPE_SECURITY
2663 * Perform the security action on flows matched by the pattern items
2664 * according to the configuration of the security session.
2666 * This action modifies the payload of matched flows. For INLINE_CRYPTO, the
2667 * security protocol headers and IV are fully provided by the application as
2668 * specified in the flow pattern. The payload of matching packets is
2669 * encrypted on egress, and decrypted and authenticated on ingress.
2670 * For INLINE_PROTOCOL, the security protocol is fully offloaded to HW,
2671 * providing full encapsulation and decapsulation of packets in security
2672 * protocols. The flow pattern specifies both the outer security header fields
2673 * and the inner packet fields. The security session specified in the action
2674 * must match the pattern parameters.
2676 * The security session specified in the action must be created on the same
2677 * port as the flow action that is being specified.
2679 * The ingress/egress flow attribute should match that specified in the
2680 * security session if the security session supports the definition of the
2683 * Multiple flows can be configured to use the same security session.
2685 * The NULL value is allowed for security session. If security session is NULL,
2686 * then SPI field in ESP flow item and IP addresses in flow items 'IPv4' and
2687 * 'IPv6' will be allowed to be a range. The rule thus created can enable
2688 * security processing on multiple flows.
2690 struct rte_flow_action_security {
2691 void *security_session; /**< Pointer to security session structure. */
2695 * RTE_FLOW_ACTION_TYPE_OF_SET_MPLS_TTL
2697 * Implements OFPAT_SET_MPLS_TTL ("MPLS TTL") as defined by the OpenFlow
2698 * Switch Specification.
2700 struct rte_flow_action_of_set_mpls_ttl {
2701 uint8_t mpls_ttl; /**< MPLS TTL. */
2705 * RTE_FLOW_ACTION_TYPE_OF_SET_NW_TTL
2707 * Implements OFPAT_SET_NW_TTL ("IP TTL") as defined by the OpenFlow Switch
2710 struct rte_flow_action_of_set_nw_ttl {
2711 uint8_t nw_ttl; /**< IP TTL. */
2715 * RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN
2717 * Implements OFPAT_PUSH_VLAN ("push a new VLAN tag") as defined by the
2718 * OpenFlow Switch Specification.
2720 struct rte_flow_action_of_push_vlan {
2721 rte_be16_t ethertype; /**< EtherType. */
2725 * RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID
2727 * Implements OFPAT_SET_VLAN_VID ("set the 802.1q VLAN id") as defined by
2728 * the OpenFlow Switch Specification.
2730 struct rte_flow_action_of_set_vlan_vid {
2731 rte_be16_t vlan_vid; /**< VLAN id. */
2735 * RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP
2737 * Implements OFPAT_SET_LAN_PCP ("set the 802.1q priority") as defined by
2738 * the OpenFlow Switch Specification.
2740 struct rte_flow_action_of_set_vlan_pcp {
2741 uint8_t vlan_pcp; /**< VLAN priority. */
2745 * RTE_FLOW_ACTION_TYPE_OF_POP_MPLS
2747 * Implements OFPAT_POP_MPLS ("pop the outer MPLS tag") as defined by the
2748 * OpenFlow Switch Specification.
2750 struct rte_flow_action_of_pop_mpls {
2751 rte_be16_t ethertype; /**< EtherType. */
2755 * RTE_FLOW_ACTION_TYPE_OF_PUSH_MPLS
2757 * Implements OFPAT_PUSH_MPLS ("push a new MPLS tag") as defined by the
2758 * OpenFlow Switch Specification.
2760 struct rte_flow_action_of_push_mpls {
2761 rte_be16_t ethertype; /**< EtherType. */
2766 * @b EXPERIMENTAL: this structure may change without prior notice
2768 * RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP
2770 * VXLAN tunnel end-point encapsulation data definition
2772 * The tunnel definition is provided through the flow item pattern, the
2773 * provided pattern must conform to RFC7348 for the tunnel specified. The flow
2774 * definition must be provided in order from the RTE_FLOW_ITEM_TYPE_ETH
2775 * definition up the end item which is specified by RTE_FLOW_ITEM_TYPE_END.
2777 * The mask field allows user to specify which fields in the flow item
2778 * definitions can be ignored and which have valid data and can be used
2781 * Note: the last field is not used in the definition of a tunnel and can be
2784 * Valid flow definition for RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP include:
2786 * - ETH / IPV4 / UDP / VXLAN / END
2787 * - ETH / IPV6 / UDP / VXLAN / END
2788 * - ETH / VLAN / IPV4 / UDP / VXLAN / END
2791 struct rte_flow_action_vxlan_encap {
2793 * Encapsulating vxlan tunnel definition
2794 * (terminated by the END pattern item).
2796 struct rte_flow_item *definition;
2801 * @b EXPERIMENTAL: this structure may change without prior notice
2803 * RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP
2805 * NVGRE tunnel end-point encapsulation data definition
2807 * The tunnel definition is provided through the flow item pattern the
2808 * provided pattern must conform with RFC7637. The flow definition must be
2809 * provided in order from the RTE_FLOW_ITEM_TYPE_ETH definition up the end item
2810 * which is specified by RTE_FLOW_ITEM_TYPE_END.
2812 * The mask field allows user to specify which fields in the flow item
2813 * definitions can be ignored and which have valid data and can be used
2816 * Note: the last field is not used in the definition of a tunnel and can be
2819 * Valid flow definition for RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP include:
2821 * - ETH / IPV4 / NVGRE / END
2822 * - ETH / VLAN / IPV6 / NVGRE / END
2825 struct rte_flow_action_nvgre_encap {
2827 * Encapsulating vxlan tunnel definition
2828 * (terminated by the END pattern item).
2830 struct rte_flow_item *definition;
2835 * @b EXPERIMENTAL: this structure may change without prior notice
2837 * RTE_FLOW_ACTION_TYPE_RAW_ENCAP
2839 * Raw tunnel end-point encapsulation data definition.
2841 * The data holds the headers definitions to be applied on the packet.
2842 * The data must start with ETH header up to the tunnel item header itself.
2843 * When used right after RAW_DECAP (for decapsulating L3 tunnel type for
2844 * example MPLSoGRE) the data will just hold layer 2 header.
2846 * The preserve parameter holds which bits in the packet the PMD is not allowed
2847 * to change, this parameter can also be NULL and then the PMD is allowed
2848 * to update any field.
2850 * size holds the number of bytes in @p data and @p preserve.
2852 struct rte_flow_action_raw_encap {
2853 uint8_t *data; /**< Encapsulation data. */
2854 uint8_t *preserve; /**< Bit-mask of @p data to preserve on output. */
2855 size_t size; /**< Size of @p data and @p preserve. */
2860 * @b EXPERIMENTAL: this structure may change without prior notice
2862 * RTE_FLOW_ACTION_TYPE_RAW_DECAP
2864 * Raw tunnel end-point decapsulation data definition.
2866 * The data holds the headers definitions to be removed from the packet.
2867 * The data must start with ETH header up to the tunnel item header itself.
2868 * When used right before RAW_DECAP (for encapsulating L3 tunnel type for
2869 * example MPLSoGRE) the data will just hold layer 2 header.
2871 * size holds the number of bytes in @p data.
2873 struct rte_flow_action_raw_decap {
2874 uint8_t *data; /**< Encapsulation data. */
2875 size_t size; /**< Size of @p data and @p preserve. */
2880 * @b EXPERIMENTAL: this structure may change without prior notice
2882 * RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC
2883 * RTE_FLOW_ACTION_TYPE_SET_IPV4_DST
2885 * Allows modification of IPv4 source (RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC)
2886 * and destination address (RTE_FLOW_ACTION_TYPE_SET_IPV4_DST) in the
2887 * specified outermost IPv4 header.
2889 struct rte_flow_action_set_ipv4 {
2890 rte_be32_t ipv4_addr;
2895 * @b EXPERIMENTAL: this structure may change without prior notice
2897 * RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC
2898 * RTE_FLOW_ACTION_TYPE_SET_IPV6_DST
2900 * Allows modification of IPv6 source (RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC)
2901 * and destination address (RTE_FLOW_ACTION_TYPE_SET_IPV6_DST) in the
2902 * specified outermost IPv6 header.
2904 struct rte_flow_action_set_ipv6 {
2905 uint8_t ipv6_addr[16];
2910 * @b EXPERIMENTAL: this structure may change without prior notice
2912 * RTE_FLOW_ACTION_TYPE_SET_TP_SRC
2913 * RTE_FLOW_ACTION_TYPE_SET_TP_DST
2915 * Allows modification of source (RTE_FLOW_ACTION_TYPE_SET_TP_SRC)
2916 * and destination (RTE_FLOW_ACTION_TYPE_SET_TP_DST) port numbers
2917 * in the specified outermost TCP/UDP header.
2919 struct rte_flow_action_set_tp {
2924 * RTE_FLOW_ACTION_TYPE_SET_TTL
2926 * Set the TTL value directly for IPv4 or IPv6
2928 struct rte_flow_action_set_ttl {
2933 * RTE_FLOW_ACTION_TYPE_SET_MAC
2935 * Set MAC address from the matched flow
2937 struct rte_flow_action_set_mac {
2938 uint8_t mac_addr[RTE_ETHER_ADDR_LEN];
2943 * @b EXPERIMENTAL: this structure may change without prior notice
2945 * RTE_FLOW_ACTION_TYPE_SET_TAG
2947 * Set a tag which is a transient data used during flow matching. This is not
2948 * delivered to application. Multiple tags are supported by specifying index.
2950 struct rte_flow_action_set_tag {
2958 * @b EXPERIMENTAL: this structure may change without prior notice
2960 * RTE_FLOW_ACTION_TYPE_SET_META
2962 * Set metadata. Metadata set by mbuf metadata dynamic field with
2963 * PKT_TX_DYNF_DATA flag on egress will be overridden by this action. On
2964 * ingress, the metadata will be carried by mbuf metadata dynamic field
2965 * with PKT_RX_DYNF_METADATA flag if set. The dynamic mbuf field must be
2966 * registered in advance by rte_flow_dynf_metadata_register().
2968 * Altering partial bits is supported with mask. For bits which have never
2969 * been set, unpredictable value will be seen depending on driver
2970 * implementation. For loopback/hairpin packet, metadata set on Rx/Tx may
2971 * or may not be propagated to the other path depending on HW capability.
2973 * RTE_FLOW_ITEM_TYPE_META matches metadata.
2975 struct rte_flow_action_set_meta {
2981 * RTE_FLOW_ACTION_TYPE_SET_IPV4_DSCP
2982 * RTE_FLOW_ACTION_TYPE_SET_IPV6_DSCP
2984 * Set the DSCP value for IPv4/IPv6 header.
2985 * DSCP in low 6 bits, rest ignored.
2987 struct rte_flow_action_set_dscp {
2993 * @b EXPERIMENTAL: this structure may change without prior notice
2995 * RTE_FLOW_ACTION_TYPE_INDIRECT
2997 * Opaque type returned after successfully creating an indirect action object.
2998 * The definition of the object handle is different per driver or
2999 * per direct action type.
3001 * This handle can be used to manage and query the related direct action:
3002 * - referenced in single flow rule or across multiple flow rules
3003 * over multiple ports
3004 * - update action object configuration
3005 * - query action object data
3006 * - destroy action object
3008 struct rte_flow_action_handle;
3011 * The state of a TCP connection.
3013 enum rte_flow_conntrack_state {
3014 /** SYN-ACK packet was seen. */
3015 RTE_FLOW_CONNTRACK_STATE_SYN_RECV,
3016 /** 3-way handshake was done. */
3017 RTE_FLOW_CONNTRACK_STATE_ESTABLISHED,
3018 /** First FIN packet was received to close the connection. */
3019 RTE_FLOW_CONNTRACK_STATE_FIN_WAIT,
3020 /** First FIN was ACKed. */
3021 RTE_FLOW_CONNTRACK_STATE_CLOSE_WAIT,
3022 /** Second FIN was received, waiting for the last ACK. */
3023 RTE_FLOW_CONNTRACK_STATE_LAST_ACK,
3024 /** Second FIN was ACKed, connection was closed. */
3025 RTE_FLOW_CONNTRACK_STATE_TIME_WAIT,
3029 * The last passed TCP packet flags of a connection.
3031 enum rte_flow_conntrack_tcp_last_index {
3032 RTE_FLOW_CONNTRACK_FLAG_NONE = 0, /**< No Flag. */
3033 RTE_FLOW_CONNTRACK_FLAG_SYN = RTE_BIT32(0), /**< With SYN flag. */
3034 RTE_FLOW_CONNTRACK_FLAG_SYNACK = RTE_BIT32(1), /**< With SYNACK flag. */
3035 RTE_FLOW_CONNTRACK_FLAG_FIN = RTE_BIT32(2), /**< With FIN flag. */
3036 RTE_FLOW_CONNTRACK_FLAG_ACK = RTE_BIT32(3), /**< With ACK flag. */
3037 RTE_FLOW_CONNTRACK_FLAG_RST = RTE_BIT32(4), /**< With RST flag. */
3042 * @b EXPERIMENTAL: this structure may change without prior notice
3044 * Configuration parameters for each direction of a TCP connection.
3045 * All fields should be in host byte order.
3046 * If needed, driver should convert all fields to network byte order
3047 * if HW needs them in that way.
3049 struct rte_flow_tcp_dir_param {
3050 /** TCP window scaling factor, 0xF to disable. */
3052 /** The FIN was sent by this direction. */
3053 uint32_t close_initiated:1;
3054 /** An ACK packet has been received by this side. */
3055 uint32_t last_ack_seen:1;
3057 * If set, it indicates that there is unacknowledged data for the
3058 * packets sent from this direction.
3060 uint32_t data_unacked:1;
3062 * Maximal value of sequence + payload length in sent
3063 * packets (next ACK from the opposite direction).
3067 * Maximal value of (ACK + window size) in received packet + length
3068 * over sent packet (maximal sequence could be sent).
3071 /** Maximal value of actual window size in sent packets. */
3073 /** Maximal value of ACK in sent packets. */
3079 * @b EXPERIMENTAL: this structure may change without prior notice
3081 * RTE_FLOW_ACTION_TYPE_CONNTRACK
3083 * Configuration and initial state for the connection tracking module.
3084 * This structure could be used for both setting and query.
3085 * All fields should be in host byte order.
3087 struct rte_flow_action_conntrack {
3088 /** The peer port number, can be the same port. */
3091 * Direction of this connection when creating a flow rule, the
3092 * value only affects the creation of subsequent flow rules.
3094 uint32_t is_original_dir:1;
3096 * Enable / disable the conntrack HW module. When disabled, the
3097 * result will always be RTE_FLOW_CONNTRACK_FLAG_DISABLED.
3098 * In this state the HW will act as passthrough.
3099 * It only affects this conntrack object in the HW without any effect
3100 * to the other objects.
3103 /** At least one ack was seen after the connection was established. */
3104 uint32_t live_connection:1;
3105 /** Enable selective ACK on this connection. */
3106 uint32_t selective_ack:1;
3107 /** A challenge ack has passed. */
3108 uint32_t challenge_ack_passed:1;
3110 * 1: The last packet is seen from the original direction.
3111 * 0: The last packet is seen from the reply direction.
3113 uint32_t last_direction:1;
3114 /** No TCP check will be done except the state change. */
3115 uint32_t liberal_mode:1;
3116 /**<The current state of this connection. */
3117 enum rte_flow_conntrack_state state;
3118 /** Scaling factor for maximal allowed ACK window. */
3119 uint8_t max_ack_window;
3120 /** Maximal allowed number of retransmission times. */
3121 uint8_t retransmission_limit;
3122 /** TCP parameters of the original direction. */
3123 struct rte_flow_tcp_dir_param original_dir;
3124 /** TCP parameters of the reply direction. */
3125 struct rte_flow_tcp_dir_param reply_dir;
3126 /** The window value of the last packet passed this conntrack. */
3127 uint16_t last_window;
3128 enum rte_flow_conntrack_tcp_last_index last_index;
3129 /** The sequence of the last packet passed this conntrack. */
3131 /** The acknowledgment of the last packet passed this conntrack. */
3134 * The total value ACK + payload length of the last packet
3135 * passed this conntrack.
3141 * RTE_FLOW_ACTION_TYPE_CONNTRACK
3143 * Wrapper structure for the context update interface.
3144 * Ports cannot support updating, and the only valid solution is to
3145 * destroy the old context and create a new one instead.
3147 struct rte_flow_modify_conntrack {
3148 /** New connection tracking parameters to be updated. */
3149 struct rte_flow_action_conntrack new_ct;
3150 /** The direction field will be updated. */
3151 uint32_t direction:1;
3152 /** All the other fields except direction will be updated. */
3154 /** Reserved bits for the future usage. */
3155 uint32_t reserved:30;
3160 * @b EXPERIMENTAL: this structure may change without prior notice
3162 * RTE_FLOW_ACTION_TYPE_METER_COLOR
3164 * The meter color should be set in the packet meta-data
3165 * (i.e. struct rte_mbuf::sched::color).
3167 struct rte_flow_action_meter_color {
3168 enum rte_color color; /**< Packet color. */
3172 * Field IDs for MODIFY_FIELD action.
3174 enum rte_flow_field_id {
3175 RTE_FLOW_FIELD_START = 0, /**< Start of a packet. */
3176 RTE_FLOW_FIELD_MAC_DST, /**< Destination MAC Address. */
3177 RTE_FLOW_FIELD_MAC_SRC, /**< Source MAC Address. */
3178 RTE_FLOW_FIELD_VLAN_TYPE, /**< 802.1Q Tag Identifier. */
3179 RTE_FLOW_FIELD_VLAN_ID, /**< 802.1Q VLAN Identifier. */
3180 RTE_FLOW_FIELD_MAC_TYPE, /**< EtherType. */
3181 RTE_FLOW_FIELD_IPV4_DSCP, /**< IPv4 DSCP. */
3182 RTE_FLOW_FIELD_IPV4_TTL, /**< IPv4 Time To Live. */
3183 RTE_FLOW_FIELD_IPV4_SRC, /**< IPv4 Source Address. */
3184 RTE_FLOW_FIELD_IPV4_DST, /**< IPv4 Destination Address. */
3185 RTE_FLOW_FIELD_IPV6_DSCP, /**< IPv6 DSCP. */
3186 RTE_FLOW_FIELD_IPV6_HOPLIMIT, /**< IPv6 Hop Limit. */
3187 RTE_FLOW_FIELD_IPV6_SRC, /**< IPv6 Source Address. */
3188 RTE_FLOW_FIELD_IPV6_DST, /**< IPv6 Destination Address. */
3189 RTE_FLOW_FIELD_TCP_PORT_SRC, /**< TCP Source Port Number. */
3190 RTE_FLOW_FIELD_TCP_PORT_DST, /**< TCP Destination Port Number. */
3191 RTE_FLOW_FIELD_TCP_SEQ_NUM, /**< TCP Sequence Number. */
3192 RTE_FLOW_FIELD_TCP_ACK_NUM, /**< TCP Acknowledgment Number. */
3193 RTE_FLOW_FIELD_TCP_FLAGS, /**< TCP Flags. */
3194 RTE_FLOW_FIELD_UDP_PORT_SRC, /**< UDP Source Port Number. */
3195 RTE_FLOW_FIELD_UDP_PORT_DST, /**< UDP Destination Port Number. */
3196 RTE_FLOW_FIELD_VXLAN_VNI, /**< VXLAN Network Identifier. */
3197 RTE_FLOW_FIELD_GENEVE_VNI, /**< GENEVE Network Identifier. */
3198 RTE_FLOW_FIELD_GTP_TEID, /**< GTP Tunnel Endpoint Identifier. */
3199 RTE_FLOW_FIELD_TAG, /**< Tag value. */
3200 RTE_FLOW_FIELD_MARK, /**< Mark value. */
3201 RTE_FLOW_FIELD_META, /**< Metadata value. */
3202 RTE_FLOW_FIELD_POINTER, /**< Memory pointer. */
3203 RTE_FLOW_FIELD_VALUE, /**< Immediate value. */
3207 * Field description for MODIFY_FIELD action.
3209 struct rte_flow_action_modify_data {
3210 enum rte_flow_field_id field; /**< Field or memory type ID. */
3214 /**< Encapsulation level or tag index. */
3216 /**< Number of bits to skip from a field. */
3220 * Immediate value for RTE_FLOW_FIELD_VALUE or
3221 * memory address for RTE_FLOW_FIELD_POINTER.
3228 * Operation types for MODIFY_FIELD action.
3230 enum rte_flow_modify_op {
3231 RTE_FLOW_MODIFY_SET = 0, /**< Set a new value. */
3232 RTE_FLOW_MODIFY_ADD, /**< Add a value to a field. */
3233 RTE_FLOW_MODIFY_SUB, /**< Subtract a value from a field. */
3238 * @b EXPERIMENTAL: this structure may change without prior notice
3240 * RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
3242 * Modify a destination header field according to the specified
3243 * operation. Another packet field can be used as a source as well
3244 * as tag, mark, metadata, immediate value or a pointer to it.
3246 struct rte_flow_action_modify_field {
3247 enum rte_flow_modify_op operation; /**< Operation to perform. */
3248 struct rte_flow_action_modify_data dst; /**< Destination field. */
3249 struct rte_flow_action_modify_data src; /**< Source field. */
3250 uint32_t width; /**< Number of bits to use from a source field. */
3253 /* Mbuf dynamic field offset for metadata. */
3254 extern int32_t rte_flow_dynf_metadata_offs;
3256 /* Mbuf dynamic field flag mask for metadata. */
3257 extern uint64_t rte_flow_dynf_metadata_mask;
3259 /* Mbuf dynamic field pointer for metadata. */
3260 #define RTE_FLOW_DYNF_METADATA(m) \
3261 RTE_MBUF_DYNFIELD((m), rte_flow_dynf_metadata_offs, uint32_t *)
3263 /* Mbuf dynamic flags for metadata. */
3264 #define PKT_RX_DYNF_METADATA (rte_flow_dynf_metadata_mask)
3265 #define PKT_TX_DYNF_METADATA (rte_flow_dynf_metadata_mask)
3268 static inline uint32_t
3269 rte_flow_dynf_metadata_get(struct rte_mbuf *m)
3271 return *RTE_FLOW_DYNF_METADATA(m);
3276 rte_flow_dynf_metadata_set(struct rte_mbuf *m, uint32_t v)
3278 *RTE_FLOW_DYNF_METADATA(m) = v;
3282 * Definition of a single action.
3284 * A list of actions is terminated by a END action.
3286 * For simple actions without a configuration object, conf remains NULL.
3288 struct rte_flow_action {
3289 enum rte_flow_action_type type; /**< Action type. */
3290 const void *conf; /**< Pointer to action configuration object. */
3294 * Opaque type returned after successfully creating a flow.
3296 * This handle can be used to manage and query the related flow (e.g. to
3297 * destroy it or retrieve counters).
3303 * @b EXPERIMENTAL: this structure may change without prior notice
3305 * RTE_FLOW_ACTION_TYPE_SAMPLE
3307 * Adds a sample action to a matched flow.
3309 * The matching packets will be duplicated with specified ratio and applied
3310 * with own set of actions with a fate action, the sampled packet could be
3311 * redirected to queue or port. All the packets continue processing on the
3312 * default flow path.
3314 * When the sample ratio is set to 1 then the packets will be 100% mirrored.
3315 * Additional action list be supported to add for sampled or mirrored packets.
3317 struct rte_flow_action_sample {
3318 uint32_t ratio; /**< packets sampled equals to '1/ratio'. */
3319 const struct rte_flow_action *actions;
3320 /**< sub-action list specific for the sampling hit cases. */
3324 * Verbose error types.
3326 * Most of them provide the type of the object referenced by struct
3327 * rte_flow_error.cause.
3329 enum rte_flow_error_type {
3330 RTE_FLOW_ERROR_TYPE_NONE, /**< No error. */
3331 RTE_FLOW_ERROR_TYPE_UNSPECIFIED, /**< Cause unspecified. */
3332 RTE_FLOW_ERROR_TYPE_HANDLE, /**< Flow rule (handle). */
3333 RTE_FLOW_ERROR_TYPE_ATTR_GROUP, /**< Group field. */
3334 RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY, /**< Priority field. */
3335 RTE_FLOW_ERROR_TYPE_ATTR_INGRESS, /**< Ingress field. */
3336 RTE_FLOW_ERROR_TYPE_ATTR_EGRESS, /**< Egress field. */
3337 RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, /**< Transfer field. */
3338 RTE_FLOW_ERROR_TYPE_ATTR, /**< Attributes structure. */
3339 RTE_FLOW_ERROR_TYPE_ITEM_NUM, /**< Pattern length. */
3340 RTE_FLOW_ERROR_TYPE_ITEM_SPEC, /**< Item specification. */
3341 RTE_FLOW_ERROR_TYPE_ITEM_LAST, /**< Item specification range. */
3342 RTE_FLOW_ERROR_TYPE_ITEM_MASK, /**< Item specification mask. */
3343 RTE_FLOW_ERROR_TYPE_ITEM, /**< Specific pattern item. */
3344 RTE_FLOW_ERROR_TYPE_ACTION_NUM, /**< Number of actions. */
3345 RTE_FLOW_ERROR_TYPE_ACTION_CONF, /**< Action configuration. */
3346 RTE_FLOW_ERROR_TYPE_ACTION, /**< Specific action. */
3350 * Verbose error structure definition.
3352 * This object is normally allocated by applications and set by PMDs, the
3353 * message points to a constant string which does not need to be freed by
3354 * the application, however its pointer can be considered valid only as long
3355 * as its associated DPDK port remains configured. Closing the underlying
3356 * device or unloading the PMD invalidates it.
3358 * Both cause and message may be NULL regardless of the error type.
3360 struct rte_flow_error {
3361 enum rte_flow_error_type type; /**< Cause field and error types. */
3362 const void *cause; /**< Object responsible for the error. */
3363 const char *message; /**< Human-readable error message. */
3367 * Complete flow rule description.
3369 * This object type is used when converting a flow rule description.
3371 * @see RTE_FLOW_CONV_OP_RULE
3372 * @see rte_flow_conv()
3375 struct rte_flow_conv_rule {
3377 const struct rte_flow_attr *attr_ro; /**< RO attributes. */
3378 struct rte_flow_attr *attr; /**< Attributes. */
3381 const struct rte_flow_item *pattern_ro; /**< RO pattern. */
3382 struct rte_flow_item *pattern; /**< Pattern items. */
3385 const struct rte_flow_action *actions_ro; /**< RO actions. */
3386 struct rte_flow_action *actions; /**< List of actions. */
3391 * Conversion operations for flow API objects.
3393 * @see rte_flow_conv()
3395 enum rte_flow_conv_op {
3397 * No operation to perform.
3399 * rte_flow_conv() simply returns 0.
3401 RTE_FLOW_CONV_OP_NONE,
3404 * Convert attributes structure.
3406 * This is a basic copy of an attributes structure.
3409 * @code const struct rte_flow_attr * @endcode
3411 * @code struct rte_flow_attr * @endcode
3413 RTE_FLOW_CONV_OP_ATTR,
3416 * Convert a single item.
3418 * Duplicates @p spec, @p last and @p mask but not outside objects.
3421 * @code const struct rte_flow_item * @endcode
3423 * @code struct rte_flow_item * @endcode
3425 RTE_FLOW_CONV_OP_ITEM,
3428 * Convert a single action.
3430 * Duplicates @p conf but not outside objects.
3433 * @code const struct rte_flow_action * @endcode
3435 * @code struct rte_flow_action * @endcode
3437 RTE_FLOW_CONV_OP_ACTION,
3440 * Convert an entire pattern.
3442 * Duplicates all pattern items at once with the same constraints as
3443 * RTE_FLOW_CONV_OP_ITEM.
3446 * @code const struct rte_flow_item * @endcode
3448 * @code struct rte_flow_item * @endcode
3450 RTE_FLOW_CONV_OP_PATTERN,
3453 * Convert a list of actions.
3455 * Duplicates the entire list of actions at once with the same
3456 * constraints as RTE_FLOW_CONV_OP_ACTION.
3459 * @code const struct rte_flow_action * @endcode
3461 * @code struct rte_flow_action * @endcode
3463 RTE_FLOW_CONV_OP_ACTIONS,
3466 * Convert a complete flow rule description.
3468 * Comprises attributes, pattern and actions together at once with
3469 * the usual constraints.
3472 * @code const struct rte_flow_conv_rule * @endcode
3474 * @code struct rte_flow_conv_rule * @endcode
3476 RTE_FLOW_CONV_OP_RULE,
3479 * Convert item type to its name string.
3481 * Writes a NUL-terminated string to @p dst. Like snprintf(), the
3482 * returned value excludes the terminator which is always written
3486 * @code (const void *)enum rte_flow_item_type @endcode
3488 * @code char * @endcode
3490 RTE_FLOW_CONV_OP_ITEM_NAME,
3493 * Convert action type to its name string.
3495 * Writes a NUL-terminated string to @p dst. Like snprintf(), the
3496 * returned value excludes the terminator which is always written
3500 * @code (const void *)enum rte_flow_action_type @endcode
3502 * @code char * @endcode
3504 RTE_FLOW_CONV_OP_ACTION_NAME,
3507 * Convert item type to pointer to item name.
3509 * Retrieves item name pointer from its type. The string itself is
3510 * not copied; instead, a unique pointer to an internal static
3511 * constant storage is written to @p dst.
3514 * @code (const void *)enum rte_flow_item_type @endcode
3516 * @code const char ** @endcode
3518 RTE_FLOW_CONV_OP_ITEM_NAME_PTR,
3521 * Convert action type to pointer to action name.
3523 * Retrieves action name pointer from its type. The string itself is
3524 * not copied; instead, a unique pointer to an internal static
3525 * constant storage is written to @p dst.
3528 * @code (const void *)enum rte_flow_action_type @endcode
3530 * @code const char ** @endcode
3532 RTE_FLOW_CONV_OP_ACTION_NAME_PTR,
3537 * @b EXPERIMENTAL: this API may change without prior notice.
3539 * Dump hardware internal representation information of
3542 * @param[in] port_id
3543 * The port identifier of the Ethernet device.
3545 * The pointer of flow rule to dump. Dump all rules if NULL.
3547 * A pointer to a file for output.
3549 * Perform verbose error reporting if not NULL. PMDs initialize this
3550 * structure in case of error only.
3552 * 0 on success, a nagative value otherwise.
3556 rte_flow_dev_dump(uint16_t port_id, struct rte_flow *flow,
3557 FILE *file, struct rte_flow_error *error);
3560 * Check if mbuf dynamic field for metadata is registered.
3563 * True if registered, false otherwise.
3567 rte_flow_dynf_metadata_avail(void)
3569 return !!rte_flow_dynf_metadata_mask;
3573 * Register mbuf dynamic field and flag for metadata.
3575 * This function must be called prior to use SET_META action in order to
3576 * register the dynamic mbuf field. Otherwise, the data cannot be delivered to
3580 * 0 on success, a negative errno value otherwise and rte_errno is set.
3584 rte_flow_dynf_metadata_register(void);
3587 * Check whether a flow rule can be created on a given port.
3589 * The flow rule is validated for correctness and whether it could be accepted
3590 * by the device given sufficient resources. The rule is checked against the
3591 * current device mode and queue configuration. The flow rule may also
3592 * optionally be validated against existing flow rules and device resources.
3593 * This function has no effect on the target device.
3595 * The returned value is guaranteed to remain valid only as long as no
3596 * successful calls to rte_flow_create() or rte_flow_destroy() are made in
3597 * the meantime and no device parameter affecting flow rules in any way are
3598 * modified, due to possible collisions or resource limitations (although in
3599 * such cases EINVAL should not be returned).
3602 * Port identifier of Ethernet device.
3604 * Flow rule attributes.
3605 * @param[in] pattern
3606 * Pattern specification (list terminated by the END pattern item).
3607 * @param[in] actions
3608 * Associated actions (list terminated by the END action).
3610 * Perform verbose error reporting if not NULL. PMDs initialize this
3611 * structure in case of error only.
3614 * 0 if flow rule is valid and can be created. A negative errno value
3615 * otherwise (rte_errno is also set), the following errors are defined:
3617 * -ENOSYS: underlying device does not support this functionality.
3619 * -EIO: underlying device is removed.
3621 * -EINVAL: unknown or invalid rule specification.
3623 * -ENOTSUP: valid but unsupported rule specification (e.g. partial
3624 * bit-masks are unsupported).
3626 * -EEXIST: collision with an existing rule. Only returned if device
3627 * supports flow rule collision checking and there was a flow rule
3628 * collision. Not receiving this return code is no guarantee that creating
3629 * the rule will not fail due to a collision.
3631 * -ENOMEM: not enough memory to execute the function, or if the device
3632 * supports resource validation, resource limitation on the device.
3634 * -EBUSY: action cannot be performed due to busy device resources, may
3635 * succeed if the affected queues or even the entire port are in a stopped
3636 * state (see rte_eth_dev_rx_queue_stop() and rte_eth_dev_stop()).
3639 rte_flow_validate(uint16_t port_id,
3640 const struct rte_flow_attr *attr,
3641 const struct rte_flow_item pattern[],
3642 const struct rte_flow_action actions[],
3643 struct rte_flow_error *error);
3646 * Create a flow rule on a given port.
3649 * Port identifier of Ethernet device.
3651 * Flow rule attributes.
3652 * @param[in] pattern
3653 * Pattern specification (list terminated by the END pattern item).
3654 * @param[in] actions
3655 * Associated actions (list terminated by the END action).
3657 * Perform verbose error reporting if not NULL. PMDs initialize this
3658 * structure in case of error only.
3661 * A valid handle in case of success, NULL otherwise and rte_errno is set
3662 * to the positive version of one of the error codes defined for
3663 * rte_flow_validate().
3666 rte_flow_create(uint16_t port_id,
3667 const struct rte_flow_attr *attr,
3668 const struct rte_flow_item pattern[],
3669 const struct rte_flow_action actions[],
3670 struct rte_flow_error *error);
3673 * Destroy a flow rule on a given port.
3675 * Failure to destroy a flow rule handle may occur when other flow rules
3676 * depend on it, and destroying it would result in an inconsistent state.
3678 * This function is only guaranteed to succeed if handles are destroyed in
3679 * reverse order of their creation.
3682 * Port identifier of Ethernet device.
3684 * Flow rule handle to destroy.
3686 * Perform verbose error reporting if not NULL. PMDs initialize this
3687 * structure in case of error only.
3690 * 0 on success, a negative errno value otherwise and rte_errno is set.
3693 rte_flow_destroy(uint16_t port_id,
3694 struct rte_flow *flow,
3695 struct rte_flow_error *error);
3698 * Destroy all flow rules associated with a port.
3700 * In the unlikely event of failure, handles are still considered destroyed
3701 * and no longer valid but the port must be assumed to be in an inconsistent
3705 * Port identifier of Ethernet device.
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_flush(uint16_t port_id,
3715 struct rte_flow_error *error);
3718 * Query an existing flow rule.
3720 * This function allows retrieving flow-specific data such as counters.
3721 * Data is gathered by special actions which must be present in the flow
3724 * \see RTE_FLOW_ACTION_TYPE_COUNT
3727 * Port identifier of Ethernet device.
3729 * Flow rule handle to query.
3731 * Action definition as defined in original flow rule.
3732 * @param[in, out] data
3733 * Pointer to storage for the associated query data type.
3735 * Perform verbose error reporting if not NULL. PMDs initialize this
3736 * structure in case of error only.
3739 * 0 on success, a negative errno value otherwise and rte_errno is set.
3742 rte_flow_query(uint16_t port_id,
3743 struct rte_flow *flow,
3744 const struct rte_flow_action *action,
3746 struct rte_flow_error *error);
3749 * Restrict ingress traffic to the defined flow rules.
3751 * Isolated mode guarantees that all ingress traffic comes from defined flow
3752 * rules only (current and future).
3754 * Besides making ingress more deterministic, it allows PMDs to safely reuse
3755 * resources otherwise assigned to handle the remaining traffic, such as
3756 * global RSS configuration settings, VLAN filters, MAC address entries,
3757 * legacy filter API rules and so on in order to expand the set of possible
3760 * Calling this function as soon as possible after device initialization,
3761 * ideally before the first call to rte_eth_dev_configure(), is recommended
3762 * to avoid possible failures due to conflicting settings.
3764 * Once effective, leaving isolated mode may not be possible depending on
3765 * PMD implementation.
3767 * Additionally, the following functionality has no effect on the underlying
3768 * port and may return errors such as ENOTSUP ("not supported"):
3770 * - Toggling promiscuous mode.
3771 * - Toggling allmulticast mode.
3772 * - Configuring MAC addresses.
3773 * - Configuring multicast addresses.
3774 * - Configuring VLAN filters.
3775 * - Configuring Rx filters through the legacy API (e.g. FDIR).
3776 * - Configuring global RSS settings.
3779 * Port identifier of Ethernet device.
3781 * Nonzero to enter isolated mode, attempt to leave it otherwise.
3783 * Perform verbose error reporting if not NULL. PMDs initialize this
3784 * structure in case of error only.
3787 * 0 on success, a negative errno value otherwise and rte_errno is set.
3790 rte_flow_isolate(uint16_t port_id, int set, struct rte_flow_error *error);
3793 * Initialize flow error structure.
3796 * Pointer to flow error structure (may be NULL).
3798 * Related error code (rte_errno).
3800 * Cause field and error types.
3802 * Object responsible for the error.
3804 * Human-readable error message.
3807 * Negative error code (errno value) and rte_errno is set.
3810 rte_flow_error_set(struct rte_flow_error *error,
3812 enum rte_flow_error_type type,
3814 const char *message);
3818 * @see rte_flow_copy()
3820 struct rte_flow_desc {
3821 size_t size; /**< Allocated space including data[]. */
3822 struct rte_flow_attr attr; /**< Attributes. */
3823 struct rte_flow_item *items; /**< Items. */
3824 struct rte_flow_action *actions; /**< Actions. */
3825 uint8_t data[]; /**< Storage for items/actions. */
3830 * Copy an rte_flow rule description.
3832 * This interface is kept for compatibility with older applications but is
3833 * implemented as a wrapper to rte_flow_conv(). It is deprecated due to its
3834 * lack of flexibility and reliance on a type unusable with C++ programs
3835 * (struct rte_flow_desc).
3838 * Flow rule description.
3840 * Total size of allocated data for the flow description.
3842 * Flow rule attributes.
3844 * Pattern specification (list terminated by the END pattern item).
3845 * @param[in] actions
3846 * Associated actions (list terminated by the END action).
3849 * If len is greater or equal to the size of the flow, the total size of the
3850 * flow description and its data.
3851 * If len is lower than the size of the flow, the number of bytes that would
3852 * have been written to desc had it been sufficient. Nothing is written.
3856 rte_flow_copy(struct rte_flow_desc *fd, size_t len,
3857 const struct rte_flow_attr *attr,
3858 const struct rte_flow_item *items,
3859 const struct rte_flow_action *actions);
3862 * Flow object conversion helper.
3864 * This function performs conversion of various flow API objects to a
3865 * pre-allocated destination buffer. See enum rte_flow_conv_op for possible
3866 * operations and details about each of them.
3868 * Since destination buffer must be large enough, it works in a manner
3869 * reminiscent of snprintf():
3871 * - If @p size is 0, @p dst may be a NULL pointer, otherwise @p dst must be
3873 * - If positive, the returned value represents the number of bytes needed
3874 * to store the conversion of @p src to @p dst according to @p op
3875 * regardless of the @p size parameter.
3876 * - Since no more than @p size bytes can be written to @p dst, output is
3877 * truncated and may be inconsistent when the returned value is larger
3879 * - In case of conversion error, a negative error code is returned and
3880 * @p dst contents are unspecified.
3883 * Operation to perform, related to the object type of @p dst.
3885 * Destination buffer address. Must be suitably aligned by the caller.
3887 * Destination buffer size in bytes.
3889 * Source object to copy. Depending on @p op, its type may differ from
3892 * Perform verbose error reporting if not NULL. Initialized in case of
3896 * The number of bytes required to convert @p src to @p dst on success, a
3897 * negative errno value otherwise and rte_errno is set.
3899 * @see rte_flow_conv_op
3903 rte_flow_conv(enum rte_flow_conv_op op,
3907 struct rte_flow_error *error);
3910 * Get aged-out flows of a given port.
3912 * RTE_ETH_EVENT_FLOW_AGED event will be triggered when at least one new aged
3913 * out flow was detected after the last call to rte_flow_get_aged_flows.
3914 * This function can be called to get the aged flows usynchronously from the
3915 * event callback or synchronously regardless the event.
3916 * This is not safe to call rte_flow_get_aged_flows function with other flow
3917 * functions from multiple threads simultaneously.
3920 * Port identifier of Ethernet device.
3921 * @param[in, out] contexts
3922 * The address of an array of pointers to the aged-out flows contexts.
3923 * @param[in] nb_contexts
3924 * The length of context array pointers.
3926 * Perform verbose error reporting if not NULL. Initialized in case of
3930 * if nb_contexts is 0, return the amount of all aged contexts.
3931 * if nb_contexts is not 0 , return the amount of aged flows reported
3932 * in the context array, otherwise negative errno value.
3934 * @see rte_flow_action_age
3935 * @see RTE_ETH_EVENT_FLOW_AGED
3939 rte_flow_get_aged_flows(uint16_t port_id, void **contexts,
3940 uint32_t nb_contexts, struct rte_flow_error *error);
3943 * Specify indirect action object configuration
3945 struct rte_flow_indir_action_conf {
3947 * Flow direction for the indirect action configuration.
3949 * Action should be valid at least for one flow direction,
3950 * otherwise it is invalid for both ingress and egress rules.
3953 /**< Action valid for rules applied to ingress traffic. */
3955 /**< Action valid for rules applied to egress traffic. */
3957 * When set to 1, indicates that the action is valid for
3958 * transfer traffic; otherwise, for non-transfer traffic.
3960 uint32_t transfer:1;
3965 * @b EXPERIMENTAL: this API may change without prior notice.
3967 * Create an indirect action object that can be used in flow rules
3969 * The created object handle has single state and configuration
3970 * across all the flow rules using it.
3972 * @param[in] port_id
3973 * The port identifier of the Ethernet device.
3975 * Action configuration for the indirect action object creation.
3977 * Specific configuration of the indirect action object.
3979 * Perform verbose error reporting if not NULL. PMDs initialize this
3980 * structure in case of error only.
3982 * A valid handle in case of success, NULL otherwise and rte_errno is set
3983 * to one of the error codes defined:
3984 * - (ENODEV) if *port_id* invalid.
3985 * - (ENOSYS) if underlying device does not support this functionality.
3986 * - (EIO) if underlying device is removed.
3987 * - (EINVAL) if *action* invalid.
3988 * - (ENOTSUP) if *action* valid but unsupported.
3991 struct rte_flow_action_handle *
3992 rte_flow_action_handle_create(uint16_t port_id,
3993 const struct rte_flow_indir_action_conf *conf,
3994 const struct rte_flow_action *action,
3995 struct rte_flow_error *error);
3999 * @b EXPERIMENTAL: this API may change without prior notice.
4001 * Destroy indirect action by handle.
4003 * @param[in] port_id
4004 * The port identifier of the Ethernet device.
4006 * Handle for the indirect action object to be destroyed.
4008 * Perform verbose error reporting if not NULL. PMDs initialize this
4009 * structure in case of error only.
4012 * - (-ENODEV) if *port_id* invalid.
4013 * - (-ENOSYS) if underlying device does not support this functionality.
4014 * - (-EIO) if underlying device is removed.
4015 * - (-ENOENT) if action pointed by *action* handle was not found.
4016 * - (-EBUSY) if action pointed by *action* handle still used by some rules
4017 * rte_errno is also set.
4021 rte_flow_action_handle_destroy(uint16_t port_id,
4022 struct rte_flow_action_handle *handle,
4023 struct rte_flow_error *error);
4027 * @b EXPERIMENTAL: this API may change without prior notice.
4029 * Update in-place the action configuration and / or state pointed
4030 * by action *handle* with the configuration provided as *update* argument.
4031 * The update of the action configuration effects all flow rules reusing
4032 * the action via *handle*.
4033 * The update general pointer provides the ability of partial updating.
4035 * @param[in] port_id
4036 * The port identifier of the Ethernet device.
4038 * Handle for the indirect action object to be updated.
4040 * Update profile specification used to modify the action pointed by handle.
4041 * *update* could be with the same type of the immediate action corresponding
4042 * to the *handle* argument when creating, or a wrapper structure includes
4043 * action configuration to be updated and bit fields to indicate the member
4044 * of fields inside the action to update.
4046 * Perform verbose error reporting if not NULL. PMDs initialize this
4047 * structure in case of error only.
4050 * - (-ENODEV) if *port_id* invalid.
4051 * - (-ENOSYS) if underlying device does not support this functionality.
4052 * - (-EIO) if underlying device is removed.
4053 * - (-EINVAL) if *update* invalid.
4054 * - (-ENOTSUP) if *update* valid but unsupported.
4055 * - (-ENOENT) if indirect action object pointed by *handle* was not found.
4056 * rte_errno is also set.
4060 rte_flow_action_handle_update(uint16_t port_id,
4061 struct rte_flow_action_handle *handle,
4063 struct rte_flow_error *error);
4067 * @b EXPERIMENTAL: this API may change without prior notice.
4069 * Query the direct action by corresponding indirect action object handle.
4071 * Retrieve action-specific data such as counters.
4072 * Data is gathered by special action which may be present/referenced in
4073 * more than one flow rule definition.
4075 * @see RTE_FLOW_ACTION_TYPE_COUNT
4078 * Port identifier of Ethernet device.
4080 * Handle for the action object to query.
4081 * @param[in, out] data
4082 * Pointer to storage for the associated query data type.
4084 * Perform verbose error reporting if not NULL. PMDs initialize this
4085 * structure in case of error only.
4088 * 0 on success, a negative errno value otherwise and rte_errno is set.
4092 rte_flow_action_handle_query(uint16_t port_id,
4093 const struct rte_flow_action_handle *handle,
4094 void *data, struct rte_flow_error *error);
4096 /* Tunnel has a type and the key information. */
4097 struct rte_flow_tunnel {
4099 * Tunnel type, for example RTE_FLOW_ITEM_TYPE_VXLAN,
4100 * RTE_FLOW_ITEM_TYPE_NVGRE etc.
4102 enum rte_flow_item_type type;
4103 uint64_t tun_id; /**< Tunnel identification. */
4108 rte_be32_t src_addr; /**< IPv4 source address. */
4109 rte_be32_t dst_addr; /**< IPv4 destination address. */
4112 uint8_t src_addr[16]; /**< IPv6 source address. */
4113 uint8_t dst_addr[16]; /**< IPv6 destination address. */
4116 rte_be16_t tp_src; /**< Tunnel port source. */
4117 rte_be16_t tp_dst; /**< Tunnel port destination. */
4118 uint16_t tun_flags; /**< Tunnel flags. */
4120 bool is_ipv6; /**< True for valid IPv6 fields. Otherwise IPv4. */
4123 * the following members are required to restore packet
4126 uint8_t tos; /**< TOS for IPv4, TC for IPv6. */
4127 uint8_t ttl; /**< TTL for IPv4, HL for IPv6. */
4128 uint32_t label; /**< Flow Label for IPv6. */
4132 * Indicate that the packet has a tunnel.
4134 #define RTE_FLOW_RESTORE_INFO_TUNNEL (1ULL << 0)
4137 * Indicate that the packet has a non decapsulated tunnel header.
4139 #define RTE_FLOW_RESTORE_INFO_ENCAPSULATED (1ULL << 1)
4142 * Indicate that the packet has a group_id.
4144 #define RTE_FLOW_RESTORE_INFO_GROUP_ID (1ULL << 2)
4147 * Restore information structure to communicate the current packet processing
4148 * state when some of the processing pipeline is done in hardware and should
4149 * continue in software.
4151 struct rte_flow_restore_info {
4153 * Bitwise flags (RTE_FLOW_RESTORE_INFO_*) to indicate validation of
4154 * other fields in struct rte_flow_restore_info.
4157 uint32_t group_id; /**< Group ID where packed missed */
4158 struct rte_flow_tunnel tunnel; /**< Tunnel information. */
4162 * Allocate an array of actions to be used in rte_flow_create, to implement
4163 * tunnel-decap-set for the given tunnel.
4165 * actions vxlan_decap / tunnel-decap-set(tunnel properties) /
4166 * jump group 0 / end
4169 * Port identifier of Ethernet device.
4171 * Tunnel properties.
4172 * @param[out] actions
4173 * Array of actions to be allocated by the PMD. This array should be
4174 * concatenated with the actions array provided to rte_flow_create.
4175 * @param[out] num_of_actions
4176 * Number of actions allocated.
4178 * Perform verbose error reporting if not NULL. PMDs initialize this
4179 * structure in case of error only.
4182 * 0 on success, a negative errno value otherwise and rte_errno is set.
4186 rte_flow_tunnel_decap_set(uint16_t port_id,
4187 struct rte_flow_tunnel *tunnel,
4188 struct rte_flow_action **actions,
4189 uint32_t *num_of_actions,
4190 struct rte_flow_error *error);
4193 * Allocate an array of items to be used in rte_flow_create, to implement
4194 * tunnel-match for the given tunnel.
4196 * pattern tunnel-match(tunnel properties) / outer-header-matches /
4197 * inner-header-matches / end
4200 * Port identifier of Ethernet device.
4202 * Tunnel properties.
4204 * Array of items to be allocated by the PMD. This array should be
4205 * concatenated with the items array provided to rte_flow_create.
4206 * @param[out] num_of_items
4207 * Number of items allocated.
4209 * Perform verbose error reporting if not NULL. PMDs initialize this
4210 * structure in case of error only.
4213 * 0 on success, a negative errno value otherwise and rte_errno is set.
4217 rte_flow_tunnel_match(uint16_t port_id,
4218 struct rte_flow_tunnel *tunnel,
4219 struct rte_flow_item **items,
4220 uint32_t *num_of_items,
4221 struct rte_flow_error *error);
4224 * Populate the current packet processing state, if exists, for the given mbuf.
4227 * Port identifier of Ethernet device.
4231 * Restore information. Upon success contains the HW state.
4233 * Perform verbose error reporting if not NULL. PMDs initialize this
4234 * structure in case of error only.
4237 * 0 on success, a negative errno value otherwise and rte_errno is set.
4241 rte_flow_get_restore_info(uint16_t port_id,
4243 struct rte_flow_restore_info *info,
4244 struct rte_flow_error *error);
4247 * Release the action array as allocated by rte_flow_tunnel_decap_set.
4250 * Port identifier of Ethernet device.
4251 * @param[in] actions
4252 * Array of actions to be released.
4253 * @param[in] num_of_actions
4254 * Number of elements in actions array.
4256 * Perform verbose error reporting if not NULL. PMDs initialize this
4257 * structure in case of error only.
4260 * 0 on success, a negative errno value otherwise and rte_errno is set.
4264 rte_flow_tunnel_action_decap_release(uint16_t port_id,
4265 struct rte_flow_action *actions,
4266 uint32_t num_of_actions,
4267 struct rte_flow_error *error);
4270 * Release the item array as allocated by rte_flow_tunnel_match.
4273 * Port identifier of Ethernet device.
4275 * Array of items to be released.
4276 * @param[in] num_of_items
4277 * Number of elements in item array.
4279 * Perform verbose error reporting if not NULL. PMDs initialize this
4280 * structure in case of error only.
4283 * 0 on success, a negative errno value otherwise and rte_errno is set.
4287 rte_flow_tunnel_item_release(uint16_t port_id,
4288 struct rte_flow_item *items,
4289 uint32_t num_of_items,
4290 struct rte_flow_error *error);
4295 #endif /* RTE_FLOW_H_ */