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>
34 #include <rte_mbuf_dyn.h>
41 * Flow rule attributes.
43 * Priorities are set on a per rule based within groups.
45 * Lower values denote higher priority, the highest priority for a flow rule
46 * is 0, so that a flow that matches for than one rule, the rule with the
47 * lowest priority value will always be matched.
49 * Although optional, applications are encouraged to group similar rules as
50 * much as possible to fully take advantage of hardware capabilities
51 * (e.g. optimized matching) and work around limitations (e.g. a single
52 * pattern type possibly allowed in a given group). Applications should be
53 * aware that groups are not linked by default, and that they must be
54 * explicitly linked by the application using the JUMP action.
56 * Priority levels are arbitrary and up to the application, they
57 * do not need to be contiguous nor start from 0, however the maximum number
58 * varies between devices and may be affected by existing flow rules.
60 * If a packet is matched by several rules of a given group for a given
61 * priority level, the outcome is undefined. It can take any path, may be
62 * duplicated or even cause unrecoverable errors.
64 * Note that support for more than a single group and priority level is not
67 * Flow rules can apply to inbound and/or outbound traffic (ingress/egress).
69 * Several pattern items and actions are valid and can be used in both
70 * directions. Those valid for only one direction are described as such.
72 * At least one direction must be specified.
74 * Specifying both directions at once for a given rule is not recommended
75 * but may be valid in a few cases (e.g. shared counter).
77 struct rte_flow_attr {
78 uint32_t group; /**< Priority group. */
79 uint32_t priority; /**< Rule priority level within group. */
80 uint32_t ingress:1; /**< Rule applies to ingress traffic. */
81 uint32_t egress:1; /**< Rule applies to egress traffic. */
83 * Instead of simply matching the properties of traffic as it would
84 * appear on a given DPDK port ID, enabling this attribute transfers
85 * a flow rule to the lowest possible level of any device endpoints
86 * found in the pattern.
88 * When supported, this effectively enables an application to
89 * re-route traffic not necessarily intended for it (e.g. coming
90 * from or addressed to different physical ports, VFs or
91 * applications) at the device level.
93 * It complements the behavior of some pattern items such as
94 * RTE_FLOW_ITEM_TYPE_PHY_PORT and is meaningless without them.
96 * When transferring flow rules, ingress and egress attributes keep
97 * their original meaning, as if processing traffic emitted or
98 * received by the application.
101 uint32_t reserved:29; /**< Reserved, must be zero. */
105 * Matching pattern item types.
107 * Pattern items fall in two categories:
109 * - Matching protocol headers and packet data, usually associated with a
110 * specification structure. These must be stacked in the same order as the
111 * protocol layers to match inside packets, starting from the lowest.
113 * - Matching meta-data or affecting pattern processing, often without a
114 * specification structure. Since they do not match packet contents, their
115 * position in the list is usually not relevant.
117 * See the description of individual types for more information. Those
118 * marked with [META] fall into the second category.
120 enum rte_flow_item_type {
124 * End marker for item lists. Prevents further processing of items,
125 * thereby ending the pattern.
127 * No associated specification structure.
129 RTE_FLOW_ITEM_TYPE_END,
134 * Used as a placeholder for convenience. It is ignored and simply
137 * No associated specification structure.
139 RTE_FLOW_ITEM_TYPE_VOID,
144 * Inverted matching, i.e. process packets that do not match the
147 * No associated specification structure.
149 RTE_FLOW_ITEM_TYPE_INVERT,
152 * Matches any protocol in place of the current layer, a single ANY
153 * may also stand for several protocol layers.
155 * See struct rte_flow_item_any.
157 RTE_FLOW_ITEM_TYPE_ANY,
162 * Matches traffic originating from (ingress) or going to (egress)
163 * the physical function of the current device.
165 * No associated specification structure.
167 RTE_FLOW_ITEM_TYPE_PF,
172 * Matches traffic originating from (ingress) or going to (egress) a
173 * given virtual function of the current device.
175 * See struct rte_flow_item_vf.
177 RTE_FLOW_ITEM_TYPE_VF,
182 * Matches traffic originating from (ingress) or going to (egress) a
183 * physical port of the underlying device.
185 * See struct rte_flow_item_phy_port.
187 RTE_FLOW_ITEM_TYPE_PHY_PORT,
192 * Matches traffic originating from (ingress) or going to (egress) a
193 * given DPDK port ID.
195 * See struct rte_flow_item_port_id.
197 RTE_FLOW_ITEM_TYPE_PORT_ID,
200 * Matches a byte string of a given length at a given offset.
202 * See struct rte_flow_item_raw.
204 RTE_FLOW_ITEM_TYPE_RAW,
207 * Matches an Ethernet header.
209 * See struct rte_flow_item_eth.
211 RTE_FLOW_ITEM_TYPE_ETH,
214 * Matches an 802.1Q/ad VLAN tag.
216 * See struct rte_flow_item_vlan.
218 RTE_FLOW_ITEM_TYPE_VLAN,
221 * Matches an IPv4 header.
223 * See struct rte_flow_item_ipv4.
225 RTE_FLOW_ITEM_TYPE_IPV4,
228 * Matches an IPv6 header.
230 * See struct rte_flow_item_ipv6.
232 RTE_FLOW_ITEM_TYPE_IPV6,
235 * Matches an ICMP header.
237 * See struct rte_flow_item_icmp.
239 RTE_FLOW_ITEM_TYPE_ICMP,
242 * Matches a UDP header.
244 * See struct rte_flow_item_udp.
246 RTE_FLOW_ITEM_TYPE_UDP,
249 * Matches a TCP header.
251 * See struct rte_flow_item_tcp.
253 RTE_FLOW_ITEM_TYPE_TCP,
256 * Matches a SCTP header.
258 * See struct rte_flow_item_sctp.
260 RTE_FLOW_ITEM_TYPE_SCTP,
263 * Matches a VXLAN header.
265 * See struct rte_flow_item_vxlan.
267 RTE_FLOW_ITEM_TYPE_VXLAN,
270 * Matches a E_TAG header.
272 * See struct rte_flow_item_e_tag.
274 RTE_FLOW_ITEM_TYPE_E_TAG,
277 * Matches a NVGRE header.
279 * See struct rte_flow_item_nvgre.
281 RTE_FLOW_ITEM_TYPE_NVGRE,
284 * Matches a MPLS header.
286 * See struct rte_flow_item_mpls.
288 RTE_FLOW_ITEM_TYPE_MPLS,
291 * Matches a GRE header.
293 * See struct rte_flow_item_gre.
295 RTE_FLOW_ITEM_TYPE_GRE,
300 * Fuzzy pattern match, expect faster than default.
302 * This is for device that support fuzzy matching option.
303 * Usually a fuzzy matching is fast but the cost is accuracy.
305 * See struct rte_flow_item_fuzzy.
307 RTE_FLOW_ITEM_TYPE_FUZZY,
310 * Matches a GTP header.
312 * Configure flow for GTP packets.
314 * See struct rte_flow_item_gtp.
316 RTE_FLOW_ITEM_TYPE_GTP,
319 * Matches a GTP header.
321 * Configure flow for GTP-C packets.
323 * See struct rte_flow_item_gtp.
325 RTE_FLOW_ITEM_TYPE_GTPC,
328 * Matches a GTP header.
330 * Configure flow for GTP-U packets.
332 * See struct rte_flow_item_gtp.
334 RTE_FLOW_ITEM_TYPE_GTPU,
337 * Matches a ESP header.
339 * See struct rte_flow_item_esp.
341 RTE_FLOW_ITEM_TYPE_ESP,
344 * Matches a GENEVE header.
346 * See struct rte_flow_item_geneve.
348 RTE_FLOW_ITEM_TYPE_GENEVE,
351 * Matches a VXLAN-GPE header.
353 * See struct rte_flow_item_vxlan_gpe.
355 RTE_FLOW_ITEM_TYPE_VXLAN_GPE,
358 * Matches an ARP header for Ethernet/IPv4.
360 * See struct rte_flow_item_arp_eth_ipv4.
362 RTE_FLOW_ITEM_TYPE_ARP_ETH_IPV4,
365 * Matches the presence of any IPv6 extension header.
367 * See struct rte_flow_item_ipv6_ext.
369 RTE_FLOW_ITEM_TYPE_IPV6_EXT,
372 * Matches any ICMPv6 header.
374 * See struct rte_flow_item_icmp6.
376 RTE_FLOW_ITEM_TYPE_ICMP6,
379 * Matches an ICMPv6 neighbor discovery solicitation.
381 * See struct rte_flow_item_icmp6_nd_ns.
383 RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS,
386 * Matches an ICMPv6 neighbor discovery advertisement.
388 * See struct rte_flow_item_icmp6_nd_na.
390 RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA,
393 * Matches the presence of any ICMPv6 neighbor discovery option.
395 * See struct rte_flow_item_icmp6_nd_opt.
397 RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT,
400 * Matches an ICMPv6 neighbor discovery source Ethernet link-layer
403 * See struct rte_flow_item_icmp6_nd_opt_sla_eth.
405 RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_SLA_ETH,
408 * Matches an ICMPv6 neighbor discovery target Ethernet link-layer
411 * See struct rte_flow_item_icmp6_nd_opt_tla_eth.
413 RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_TLA_ETH,
416 * Matches specified mark field.
418 * See struct rte_flow_item_mark.
420 RTE_FLOW_ITEM_TYPE_MARK,
425 * Matches a metadata value.
427 * See struct rte_flow_item_meta.
429 RTE_FLOW_ITEM_TYPE_META,
432 * Matches a GRE optional key field.
434 * The value should a big-endian 32bit integer.
436 * When this item present the K bit is implicitly matched as "1"
437 * in the default mask.
440 * @code rte_be32_t * @endcode
442 RTE_FLOW_ITEM_TYPE_GRE_KEY,
445 * Matches a GTP extension header: PDU session container.
447 * Configure flow for GTP packets with extension header type 0x85.
449 * See struct rte_flow_item_gtp_psc.
451 RTE_FLOW_ITEM_TYPE_GTP_PSC,
454 * Matches a PPPoE header.
456 * Configure flow for PPPoE session packets.
458 * See struct rte_flow_item_pppoe.
460 RTE_FLOW_ITEM_TYPE_PPPOES,
463 * Matches a PPPoE header.
465 * Configure flow for PPPoE discovery packets.
467 * See struct rte_flow_item_pppoe.
469 RTE_FLOW_ITEM_TYPE_PPPOED,
472 * Matches a PPPoE optional proto_id field.
474 * It only applies to PPPoE session packets.
476 * See struct rte_flow_item_pppoe_proto_id.
478 RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID,
481 * Matches Network service header (NSH).
482 * See struct rte_flow_item_nsh.
485 RTE_FLOW_ITEM_TYPE_NSH,
488 * Matches Internet Group Management Protocol (IGMP).
489 * See struct rte_flow_item_igmp.
492 RTE_FLOW_ITEM_TYPE_IGMP,
495 * Matches IP Authentication Header (AH).
496 * See struct rte_flow_item_ah.
499 RTE_FLOW_ITEM_TYPE_AH,
502 * Matches a HIGIG header.
503 * see struct rte_flow_item_higig2_hdr.
505 RTE_FLOW_ITEM_TYPE_HIGIG2,
510 * Matches a tag value.
512 * See struct rte_flow_item_tag.
514 RTE_FLOW_ITEM_TYPE_TAG,
517 * Matches a L2TPv3 over IP header.
519 * Configure flow for L2TPv3 over IP packets.
521 * See struct rte_flow_item_l2tpv3oip.
523 RTE_FLOW_ITEM_TYPE_L2TPV3OIP,
526 * Matches PFCP Header.
527 * See struct rte_flow_item_pfcp.
530 RTE_FLOW_ITEM_TYPE_PFCP,
533 * Matches eCPRI Header.
535 * Configure flow for eCPRI over ETH or UDP packets.
537 * See struct rte_flow_item_ecpri.
539 RTE_FLOW_ITEM_TYPE_ECPRI,
542 * Matches the presence of IPv6 fragment extension header.
544 * See struct rte_flow_item_ipv6_frag_ext.
546 RTE_FLOW_ITEM_TYPE_IPV6_FRAG_EXT,
549 * Matches Geneve Variable Length Option
551 * See struct rte_flow_item_geneve_opt
553 RTE_FLOW_ITEM_TYPE_GENEVE_OPT,
558 * RTE_FLOW_ITEM_TYPE_HIGIG2
559 * Matches higig2 header
562 struct rte_flow_item_higig2_hdr {
563 struct rte_higig2_hdr hdr;
566 /** Default mask for RTE_FLOW_ITEM_TYPE_HIGIG2. */
568 static const struct rte_flow_item_higig2_hdr rte_flow_item_higig2_hdr_mask = {
571 .classification = 0xffff,
579 * RTE_FLOW_ITEM_TYPE_ANY
581 * Matches any protocol in place of the current layer, a single ANY may also
582 * stand for several protocol layers.
584 * This is usually specified as the first pattern item when looking for a
585 * protocol anywhere in a packet.
587 * A zeroed mask stands for any number of layers.
589 struct rte_flow_item_any {
590 uint32_t num; /**< Number of layers covered. */
593 /** Default mask for RTE_FLOW_ITEM_TYPE_ANY. */
595 static const struct rte_flow_item_any rte_flow_item_any_mask = {
601 * RTE_FLOW_ITEM_TYPE_VF
603 * Matches traffic originating from (ingress) or going to (egress) a given
604 * virtual function of the current device.
606 * If supported, should work even if the virtual function is not managed by
607 * the application and thus not associated with a DPDK port ID.
609 * Note this pattern item does not match VF representors traffic which, as
610 * separate entities, should be addressed through their own DPDK port IDs.
612 * - Can be specified multiple times to match traffic addressed to several
614 * - Can be combined with a PF item to match both PF and VF traffic.
616 * A zeroed mask can be used to match any VF ID.
618 struct rte_flow_item_vf {
619 uint32_t id; /**< VF ID. */
622 /** Default mask for RTE_FLOW_ITEM_TYPE_VF. */
624 static const struct rte_flow_item_vf rte_flow_item_vf_mask = {
630 * RTE_FLOW_ITEM_TYPE_PHY_PORT
632 * Matches traffic originating from (ingress) or going to (egress) a
633 * physical port of the underlying device.
635 * The first PHY_PORT item overrides the physical port normally associated
636 * with the specified DPDK input port (port_id). This item can be provided
637 * several times to match additional physical ports.
639 * Note that physical ports are not necessarily tied to DPDK input ports
640 * (port_id) when those are not under DPDK control. Possible values are
641 * specific to each device, they are not necessarily indexed from zero and
642 * may not be contiguous.
644 * As a device property, the list of allowed values as well as the value
645 * associated with a port_id should be retrieved by other means.
647 * A zeroed mask can be used to match any port index.
649 struct rte_flow_item_phy_port {
650 uint32_t index; /**< Physical port index. */
653 /** Default mask for RTE_FLOW_ITEM_TYPE_PHY_PORT. */
655 static const struct rte_flow_item_phy_port rte_flow_item_phy_port_mask = {
661 * RTE_FLOW_ITEM_TYPE_PORT_ID
663 * Matches traffic originating from (ingress) or going to (egress) a given
666 * Normally only supported if the port ID in question is known by the
667 * underlying PMD and related to the device the flow rule is created
670 * This must not be confused with @p PHY_PORT which refers to the physical
671 * port of a device, whereas @p PORT_ID refers to a struct rte_eth_dev
672 * object on the application side (also known as "port representor"
673 * depending on the kind of underlying device).
675 struct rte_flow_item_port_id {
676 uint32_t id; /**< DPDK port ID. */
679 /** Default mask for RTE_FLOW_ITEM_TYPE_PORT_ID. */
681 static const struct rte_flow_item_port_id rte_flow_item_port_id_mask = {
687 * RTE_FLOW_ITEM_TYPE_RAW
689 * Matches a byte string of a given length at a given offset.
691 * Offset is either absolute (using the start of the packet) or relative to
692 * the end of the previous matched item in the stack, in which case negative
693 * values are allowed.
695 * If search is enabled, offset is used as the starting point. The search
696 * area can be delimited by setting limit to a nonzero value, which is the
697 * maximum number of bytes after offset where the pattern may start.
699 * Matching a zero-length pattern is allowed, doing so resets the relative
700 * offset for subsequent items.
702 * This type does not support ranges (struct rte_flow_item.last).
704 struct rte_flow_item_raw {
705 uint32_t relative:1; /**< Look for pattern after the previous item. */
706 uint32_t search:1; /**< Search pattern from offset (see also limit). */
707 uint32_t reserved:30; /**< Reserved, must be set to zero. */
708 int32_t offset; /**< Absolute or relative offset for pattern. */
709 uint16_t limit; /**< Search area limit for start of pattern. */
710 uint16_t length; /**< Pattern length. */
711 const uint8_t *pattern; /**< Byte string to look for. */
714 /** Default mask for RTE_FLOW_ITEM_TYPE_RAW. */
716 static const struct rte_flow_item_raw rte_flow_item_raw_mask = {
719 .reserved = 0x3fffffff,
720 .offset = 0xffffffff,
728 * RTE_FLOW_ITEM_TYPE_ETH
730 * Matches an Ethernet header.
732 * Inside @p hdr field, the sub-field @p ether_type stands either for EtherType
733 * or TPID, depending on whether the item is followed by a VLAN item or not. If
734 * two VLAN items follow, the sub-field refers to the outer one, which, in turn,
735 * contains the inner TPID in the similar header field. The innermost VLAN item
736 * contains a layer-3 EtherType. All of that follows the order seen on the wire.
738 * If the field in question contains a TPID value, only tagged packets with the
739 * specified TPID will match the pattern. Alternatively, it's possible to match
740 * any type of tagged packets by means of the field @p has_vlan rather than use
741 * the EtherType/TPID field. Also, it's possible to leave the two fields unused.
742 * If this is the case, both tagged and untagged packets will match the pattern.
745 struct rte_flow_item_eth {
749 * These fields are retained for compatibility.
750 * Please switch to the new header field below.
752 struct rte_ether_addr dst; /**< Destination MAC. */
753 struct rte_ether_addr src; /**< Source MAC. */
754 rte_be16_t type; /**< EtherType or TPID. */
756 struct rte_ether_hdr hdr;
758 uint32_t has_vlan:1; /**< Packet header contains at least one VLAN. */
759 uint32_t reserved:31; /**< Reserved, must be zero. */
762 /** Default mask for RTE_FLOW_ITEM_TYPE_ETH. */
764 static const struct rte_flow_item_eth rte_flow_item_eth_mask = {
765 .hdr.d_addr.addr_bytes = "\xff\xff\xff\xff\xff\xff",
766 .hdr.s_addr.addr_bytes = "\xff\xff\xff\xff\xff\xff",
767 .hdr.ether_type = RTE_BE16(0x0000),
772 * RTE_FLOW_ITEM_TYPE_VLAN
774 * Matches an 802.1Q/ad VLAN tag.
776 * The corresponding standard outer EtherType (TPID) values are
777 * RTE_ETHER_TYPE_VLAN or RTE_ETHER_TYPE_QINQ. It can be overridden by
778 * the preceding pattern item.
779 * If a @p VLAN item is present in the pattern, then only tagged packets will
781 * The field @p has_more_vlan can be used to match any type of tagged packets,
782 * instead of using the @p eth_proto field of @p hdr.
783 * If the @p eth_proto of @p hdr and @p has_more_vlan fields are not specified,
784 * then any tagged packets will match the pattern.
787 struct rte_flow_item_vlan {
791 * These fields are retained for compatibility.
792 * Please switch to the new header field below.
794 rte_be16_t tci; /**< Tag control information. */
795 rte_be16_t inner_type; /**< Inner EtherType or TPID. */
797 struct rte_vlan_hdr hdr;
799 uint32_t has_more_vlan:1;
800 /**< Packet header contains at least one more VLAN, after this VLAN. */
801 uint32_t reserved:31; /**< Reserved, must be zero. */
804 /** Default mask for RTE_FLOW_ITEM_TYPE_VLAN. */
806 static const struct rte_flow_item_vlan rte_flow_item_vlan_mask = {
807 .hdr.vlan_tci = RTE_BE16(0x0fff),
808 .hdr.eth_proto = RTE_BE16(0x0000),
813 * RTE_FLOW_ITEM_TYPE_IPV4
815 * Matches an IPv4 header.
817 * Note: IPv4 options are handled by dedicated pattern items.
819 struct rte_flow_item_ipv4 {
820 struct rte_ipv4_hdr hdr; /**< IPv4 header definition. */
823 /** Default mask for RTE_FLOW_ITEM_TYPE_IPV4. */
825 static const struct rte_flow_item_ipv4 rte_flow_item_ipv4_mask = {
827 .src_addr = RTE_BE32(0xffffffff),
828 .dst_addr = RTE_BE32(0xffffffff),
834 * RTE_FLOW_ITEM_TYPE_IPV6.
836 * Matches an IPv6 header.
838 * Dedicated flags indicate if header contains specific extension headers.
840 struct rte_flow_item_ipv6 {
841 struct rte_ipv6_hdr hdr; /**< IPv6 header definition. */
842 uint32_t has_hop_ext:1;
843 /**< Header contains Hop-by-Hop Options extension header. */
844 uint32_t has_route_ext:1;
845 /**< Header contains Routing extension header. */
846 uint32_t has_frag_ext:1;
847 /**< Header contains Fragment extension header. */
848 uint32_t has_auth_ext:1;
849 /**< Header contains Authentication extension header. */
850 uint32_t has_esp_ext:1;
851 /**< Header contains Encapsulation Security Payload extension header. */
852 uint32_t has_dest_ext:1;
853 /**< Header contains Destination Options extension header. */
854 uint32_t has_mobil_ext:1;
855 /**< Header contains Mobility extension header. */
856 uint32_t has_hip_ext:1;
857 /**< Header contains Host Identity Protocol extension header. */
858 uint32_t has_shim6_ext:1;
859 /**< Header contains Shim6 Protocol extension header. */
860 uint32_t reserved:23;
861 /**< Reserved for future extension headers, must be zero. */
864 /** Default mask for RTE_FLOW_ITEM_TYPE_IPV6. */
866 static const struct rte_flow_item_ipv6 rte_flow_item_ipv6_mask = {
869 "\xff\xff\xff\xff\xff\xff\xff\xff"
870 "\xff\xff\xff\xff\xff\xff\xff\xff",
872 "\xff\xff\xff\xff\xff\xff\xff\xff"
873 "\xff\xff\xff\xff\xff\xff\xff\xff",
879 * RTE_FLOW_ITEM_TYPE_ICMP.
881 * Matches an ICMP header.
883 struct rte_flow_item_icmp {
884 struct rte_icmp_hdr hdr; /**< ICMP header definition. */
887 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP. */
889 static const struct rte_flow_item_icmp rte_flow_item_icmp_mask = {
898 * RTE_FLOW_ITEM_TYPE_UDP.
900 * Matches a UDP header.
902 struct rte_flow_item_udp {
903 struct rte_udp_hdr hdr; /**< UDP header definition. */
906 /** Default mask for RTE_FLOW_ITEM_TYPE_UDP. */
908 static const struct rte_flow_item_udp rte_flow_item_udp_mask = {
910 .src_port = RTE_BE16(0xffff),
911 .dst_port = RTE_BE16(0xffff),
917 * RTE_FLOW_ITEM_TYPE_TCP.
919 * Matches a TCP header.
921 struct rte_flow_item_tcp {
922 struct rte_tcp_hdr hdr; /**< TCP header definition. */
925 /** Default mask for RTE_FLOW_ITEM_TYPE_TCP. */
927 static const struct rte_flow_item_tcp rte_flow_item_tcp_mask = {
929 .src_port = RTE_BE16(0xffff),
930 .dst_port = RTE_BE16(0xffff),
936 * RTE_FLOW_ITEM_TYPE_SCTP.
938 * Matches a SCTP header.
940 struct rte_flow_item_sctp {
941 struct rte_sctp_hdr hdr; /**< SCTP header definition. */
944 /** Default mask for RTE_FLOW_ITEM_TYPE_SCTP. */
946 static const struct rte_flow_item_sctp rte_flow_item_sctp_mask = {
948 .src_port = RTE_BE16(0xffff),
949 .dst_port = RTE_BE16(0xffff),
955 * RTE_FLOW_ITEM_TYPE_VXLAN.
957 * Matches a VXLAN header (RFC 7348).
960 struct rte_flow_item_vxlan {
964 * These fields are retained for compatibility.
965 * Please switch to the new header field below.
967 uint8_t flags; /**< Normally 0x08 (I flag). */
968 uint8_t rsvd0[3]; /**< Reserved, normally 0x000000. */
969 uint8_t vni[3]; /**< VXLAN identifier. */
970 uint8_t rsvd1; /**< Reserved, normally 0x00. */
972 struct rte_vxlan_hdr hdr;
976 /** Default mask for RTE_FLOW_ITEM_TYPE_VXLAN. */
978 static const struct rte_flow_item_vxlan rte_flow_item_vxlan_mask = {
979 .hdr.vx_vni = RTE_BE32(0xffffff00), /* (0xffffff << 8) */
984 * RTE_FLOW_ITEM_TYPE_E_TAG.
986 * Matches a E-tag header.
988 * The corresponding standard outer EtherType (TPID) value is
989 * RTE_ETHER_TYPE_ETAG. It can be overridden by the preceding pattern item.
991 struct rte_flow_item_e_tag {
993 * E-Tag control information (E-TCI).
994 * E-PCP (3b), E-DEI (1b), ingress E-CID base (12b).
996 rte_be16_t epcp_edei_in_ecid_b;
997 /** Reserved (2b), GRP (2b), E-CID base (12b). */
998 rte_be16_t rsvd_grp_ecid_b;
999 uint8_t in_ecid_e; /**< Ingress E-CID ext. */
1000 uint8_t ecid_e; /**< E-CID ext. */
1001 rte_be16_t inner_type; /**< Inner EtherType or TPID. */
1004 /** Default mask for RTE_FLOW_ITEM_TYPE_E_TAG. */
1006 static const struct rte_flow_item_e_tag rte_flow_item_e_tag_mask = {
1007 .rsvd_grp_ecid_b = RTE_BE16(0x3fff),
1012 * RTE_FLOW_ITEM_TYPE_NVGRE.
1014 * Matches a NVGRE header.
1016 struct rte_flow_item_nvgre {
1018 * Checksum (1b), undefined (1b), key bit (1b), sequence number (1b),
1019 * reserved 0 (9b), version (3b).
1021 * c_k_s_rsvd0_ver must have value 0x2000 according to RFC 7637.
1023 rte_be16_t c_k_s_rsvd0_ver;
1024 rte_be16_t protocol; /**< Protocol type (0x6558). */
1025 uint8_t tni[3]; /**< Virtual subnet ID. */
1026 uint8_t flow_id; /**< Flow ID. */
1029 /** Default mask for RTE_FLOW_ITEM_TYPE_NVGRE. */
1031 static const struct rte_flow_item_nvgre rte_flow_item_nvgre_mask = {
1032 .tni = "\xff\xff\xff",
1037 * RTE_FLOW_ITEM_TYPE_MPLS.
1039 * Matches a MPLS header.
1041 struct rte_flow_item_mpls {
1043 * Label (20b), TC (3b), Bottom of Stack (1b).
1045 uint8_t label_tc_s[3];
1046 uint8_t ttl; /** Time-to-Live. */
1049 /** Default mask for RTE_FLOW_ITEM_TYPE_MPLS. */
1051 static const struct rte_flow_item_mpls rte_flow_item_mpls_mask = {
1052 .label_tc_s = "\xff\xff\xf0",
1057 * RTE_FLOW_ITEM_TYPE_GRE.
1059 * Matches a GRE header.
1061 struct rte_flow_item_gre {
1063 * Checksum (1b), reserved 0 (12b), version (3b).
1064 * Refer to RFC 2784.
1066 rte_be16_t c_rsvd0_ver;
1067 rte_be16_t protocol; /**< Protocol type. */
1070 /** Default mask for RTE_FLOW_ITEM_TYPE_GRE. */
1072 static const struct rte_flow_item_gre rte_flow_item_gre_mask = {
1073 .protocol = RTE_BE16(0xffff),
1078 * RTE_FLOW_ITEM_TYPE_FUZZY
1080 * Fuzzy pattern match, expect faster than default.
1082 * This is for device that support fuzzy match option.
1083 * Usually a fuzzy match is fast but the cost is accuracy.
1084 * i.e. Signature Match only match pattern's hash value, but it is
1085 * possible two different patterns have the same hash value.
1087 * Matching accuracy level can be configure by threshold.
1088 * Driver can divide the range of threshold and map to different
1089 * accuracy levels that device support.
1091 * Threshold 0 means perfect match (no fuzziness), while threshold
1092 * 0xffffffff means fuzziest match.
1094 struct rte_flow_item_fuzzy {
1095 uint32_t thresh; /**< Accuracy threshold. */
1098 /** Default mask for RTE_FLOW_ITEM_TYPE_FUZZY. */
1100 static const struct rte_flow_item_fuzzy rte_flow_item_fuzzy_mask = {
1101 .thresh = 0xffffffff,
1106 * RTE_FLOW_ITEM_TYPE_GTP.
1108 * Matches a GTPv1 header.
1110 struct rte_flow_item_gtp {
1112 * Version (3b), protocol type (1b), reserved (1b),
1113 * Extension header flag (1b),
1114 * Sequence number flag (1b),
1115 * N-PDU number flag (1b).
1117 uint8_t v_pt_rsv_flags;
1118 uint8_t msg_type; /**< Message type. */
1119 rte_be16_t msg_len; /**< Message length. */
1120 rte_be32_t teid; /**< Tunnel endpoint identifier. */
1123 /** Default mask for RTE_FLOW_ITEM_TYPE_GTP. */
1125 static const struct rte_flow_item_gtp rte_flow_item_gtp_mask = {
1126 .teid = RTE_BE32(0xffffffff),
1131 * RTE_FLOW_ITEM_TYPE_ESP
1133 * Matches an ESP header.
1135 struct rte_flow_item_esp {
1136 struct rte_esp_hdr hdr; /**< ESP header definition. */
1139 /** Default mask for RTE_FLOW_ITEM_TYPE_ESP. */
1141 static const struct rte_flow_item_esp rte_flow_item_esp_mask = {
1143 .spi = RTE_BE32(0xffffffff),
1149 * RTE_FLOW_ITEM_TYPE_GENEVE.
1151 * Matches a GENEVE header.
1153 struct rte_flow_item_geneve {
1155 * Version (2b), length of the options fields (6b), OAM packet (1b),
1156 * critical options present (1b), reserved 0 (6b).
1158 rte_be16_t ver_opt_len_o_c_rsvd0;
1159 rte_be16_t protocol; /**< Protocol type. */
1160 uint8_t vni[3]; /**< Virtual Network Identifier. */
1161 uint8_t rsvd1; /**< Reserved, normally 0x00. */
1164 /** Default mask for RTE_FLOW_ITEM_TYPE_GENEVE. */
1166 static const struct rte_flow_item_geneve rte_flow_item_geneve_mask = {
1167 .vni = "\xff\xff\xff",
1172 * RTE_FLOW_ITEM_TYPE_VXLAN_GPE (draft-ietf-nvo3-vxlan-gpe-05).
1174 * Matches a VXLAN-GPE header.
1176 struct rte_flow_item_vxlan_gpe {
1177 uint8_t flags; /**< Normally 0x0c (I and P flags). */
1178 uint8_t rsvd0[2]; /**< Reserved, normally 0x0000. */
1179 uint8_t protocol; /**< Protocol type. */
1180 uint8_t vni[3]; /**< VXLAN identifier. */
1181 uint8_t rsvd1; /**< Reserved, normally 0x00. */
1184 /** Default mask for RTE_FLOW_ITEM_TYPE_VXLAN_GPE. */
1186 static const struct rte_flow_item_vxlan_gpe rte_flow_item_vxlan_gpe_mask = {
1187 .vni = "\xff\xff\xff",
1192 * RTE_FLOW_ITEM_TYPE_ARP_ETH_IPV4
1194 * Matches an ARP header for Ethernet/IPv4.
1196 struct rte_flow_item_arp_eth_ipv4 {
1197 rte_be16_t hrd; /**< Hardware type, normally 1. */
1198 rte_be16_t pro; /**< Protocol type, normally 0x0800. */
1199 uint8_t hln; /**< Hardware address length, normally 6. */
1200 uint8_t pln; /**< Protocol address length, normally 4. */
1201 rte_be16_t op; /**< Opcode (1 for request, 2 for reply). */
1202 struct rte_ether_addr sha; /**< Sender hardware address. */
1203 rte_be32_t spa; /**< Sender IPv4 address. */
1204 struct rte_ether_addr tha; /**< Target hardware address. */
1205 rte_be32_t tpa; /**< Target IPv4 address. */
1208 /** Default mask for RTE_FLOW_ITEM_TYPE_ARP_ETH_IPV4. */
1210 static const struct rte_flow_item_arp_eth_ipv4
1211 rte_flow_item_arp_eth_ipv4_mask = {
1212 .sha.addr_bytes = "\xff\xff\xff\xff\xff\xff",
1213 .spa = RTE_BE32(0xffffffff),
1214 .tha.addr_bytes = "\xff\xff\xff\xff\xff\xff",
1215 .tpa = RTE_BE32(0xffffffff),
1220 * RTE_FLOW_ITEM_TYPE_IPV6_EXT
1222 * Matches the presence of any IPv6 extension header.
1224 * Normally preceded by any of:
1226 * - RTE_FLOW_ITEM_TYPE_IPV6
1227 * - RTE_FLOW_ITEM_TYPE_IPV6_EXT
1229 struct rte_flow_item_ipv6_ext {
1230 uint8_t next_hdr; /**< Next header. */
1233 /** Default mask for RTE_FLOW_ITEM_TYPE_IPV6_EXT. */
1236 struct rte_flow_item_ipv6_ext rte_flow_item_ipv6_ext_mask = {
1242 * RTE_FLOW_ITEM_TYPE_IPV6_FRAG_EXT
1244 * Matches the presence of IPv6 fragment extension header.
1246 * Preceded by any of:
1248 * - RTE_FLOW_ITEM_TYPE_IPV6
1249 * - RTE_FLOW_ITEM_TYPE_IPV6_EXT
1251 struct rte_flow_item_ipv6_frag_ext {
1252 struct rte_ipv6_fragment_ext hdr;
1256 * RTE_FLOW_ITEM_TYPE_ICMP6
1258 * Matches any ICMPv6 header.
1260 struct rte_flow_item_icmp6 {
1261 uint8_t type; /**< ICMPv6 type. */
1262 uint8_t code; /**< ICMPv6 code. */
1263 uint16_t checksum; /**< ICMPv6 checksum. */
1266 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6. */
1268 static const struct rte_flow_item_icmp6 rte_flow_item_icmp6_mask = {
1275 * RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS
1277 * Matches an ICMPv6 neighbor discovery solicitation.
1279 struct rte_flow_item_icmp6_nd_ns {
1280 uint8_t type; /**< ICMPv6 type, normally 135. */
1281 uint8_t code; /**< ICMPv6 code, normally 0. */
1282 rte_be16_t checksum; /**< ICMPv6 checksum. */
1283 rte_be32_t reserved; /**< Reserved, normally 0. */
1284 uint8_t target_addr[16]; /**< Target address. */
1287 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS. */
1290 struct rte_flow_item_icmp6_nd_ns rte_flow_item_icmp6_nd_ns_mask = {
1292 "\xff\xff\xff\xff\xff\xff\xff\xff"
1293 "\xff\xff\xff\xff\xff\xff\xff\xff",
1298 * RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA
1300 * Matches an ICMPv6 neighbor discovery advertisement.
1302 struct rte_flow_item_icmp6_nd_na {
1303 uint8_t type; /**< ICMPv6 type, normally 136. */
1304 uint8_t code; /**< ICMPv6 code, normally 0. */
1305 rte_be16_t checksum; /**< ICMPv6 checksum. */
1307 * Route flag (1b), solicited flag (1b), override flag (1b),
1310 rte_be32_t rso_reserved;
1311 uint8_t target_addr[16]; /**< Target address. */
1314 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA. */
1317 struct rte_flow_item_icmp6_nd_na rte_flow_item_icmp6_nd_na_mask = {
1319 "\xff\xff\xff\xff\xff\xff\xff\xff"
1320 "\xff\xff\xff\xff\xff\xff\xff\xff",
1325 * RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT
1327 * Matches the presence of any ICMPv6 neighbor discovery option.
1329 * Normally preceded by any of:
1331 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA
1332 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS
1333 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT
1335 struct rte_flow_item_icmp6_nd_opt {
1336 uint8_t type; /**< ND option type. */
1337 uint8_t length; /**< ND option length. */
1340 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT. */
1342 static const struct rte_flow_item_icmp6_nd_opt
1343 rte_flow_item_icmp6_nd_opt_mask = {
1349 * RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_SLA_ETH
1351 * Matches an ICMPv6 neighbor discovery source Ethernet link-layer address
1354 * Normally preceded by any of:
1356 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA
1357 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT
1359 struct rte_flow_item_icmp6_nd_opt_sla_eth {
1360 uint8_t type; /**< ND option type, normally 1. */
1361 uint8_t length; /**< ND option length, normally 1. */
1362 struct rte_ether_addr sla; /**< Source Ethernet LLA. */
1365 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_SLA_ETH. */
1367 static const struct rte_flow_item_icmp6_nd_opt_sla_eth
1368 rte_flow_item_icmp6_nd_opt_sla_eth_mask = {
1369 .sla.addr_bytes = "\xff\xff\xff\xff\xff\xff",
1374 * RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_TLA_ETH
1376 * Matches an ICMPv6 neighbor discovery target Ethernet link-layer address
1379 * Normally preceded by any of:
1381 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS
1382 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT
1384 struct rte_flow_item_icmp6_nd_opt_tla_eth {
1385 uint8_t type; /**< ND option type, normally 2. */
1386 uint8_t length; /**< ND option length, normally 1. */
1387 struct rte_ether_addr tla; /**< Target Ethernet LLA. */
1390 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_TLA_ETH. */
1392 static const struct rte_flow_item_icmp6_nd_opt_tla_eth
1393 rte_flow_item_icmp6_nd_opt_tla_eth_mask = {
1394 .tla.addr_bytes = "\xff\xff\xff\xff\xff\xff",
1399 * RTE_FLOW_ITEM_TYPE_META
1401 * Matches a specified metadata value. On egress, metadata can be set
1402 * either by mbuf dynamic metadata field with PKT_TX_DYNF_METADATA flag or
1403 * RTE_FLOW_ACTION_TYPE_SET_META. On ingress, RTE_FLOW_ACTION_TYPE_SET_META
1404 * sets metadata for a packet and the metadata will be reported via mbuf
1405 * metadata dynamic field with PKT_RX_DYNF_METADATA flag. The dynamic mbuf
1406 * field must be registered in advance by rte_flow_dynf_metadata_register().
1408 struct rte_flow_item_meta {
1412 /** Default mask for RTE_FLOW_ITEM_TYPE_META. */
1414 static const struct rte_flow_item_meta rte_flow_item_meta_mask = {
1420 * RTE_FLOW_ITEM_TYPE_GTP_PSC.
1422 * Matches a GTP PDU extension header with type 0x85.
1424 struct rte_flow_item_gtp_psc {
1425 uint8_t pdu_type; /**< PDU type. */
1426 uint8_t qfi; /**< PPP, RQI, QoS flow identifier. */
1429 /** Default mask for RTE_FLOW_ITEM_TYPE_GTP_PSC. */
1431 static const struct rte_flow_item_gtp_psc
1432 rte_flow_item_gtp_psc_mask = {
1438 * RTE_FLOW_ITEM_TYPE_PPPOE.
1440 * Matches a PPPoE header.
1442 struct rte_flow_item_pppoe {
1444 * Version (4b), type (4b).
1446 uint8_t version_type;
1447 uint8_t code; /**< Message type. */
1448 rte_be16_t session_id; /**< Session identifier. */
1449 rte_be16_t length; /**< Payload length. */
1453 * RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID.
1455 * Matches a PPPoE optional proto_id field.
1457 * It only applies to PPPoE session packets.
1459 * Normally preceded by any of:
1461 * - RTE_FLOW_ITEM_TYPE_PPPOE
1462 * - RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID
1464 struct rte_flow_item_pppoe_proto_id {
1465 rte_be16_t proto_id; /**< PPP protocol identifier. */
1468 /** Default mask for RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID. */
1470 static const struct rte_flow_item_pppoe_proto_id
1471 rte_flow_item_pppoe_proto_id_mask = {
1472 .proto_id = RTE_BE16(0xffff),
1478 * @b EXPERIMENTAL: this structure may change without prior notice
1480 * RTE_FLOW_ITEM_TYPE_TAG
1482 * Matches a specified tag value at the specified index.
1484 struct rte_flow_item_tag {
1489 /** Default mask for RTE_FLOW_ITEM_TYPE_TAG. */
1491 static const struct rte_flow_item_tag rte_flow_item_tag_mask = {
1498 * RTE_FLOW_ITEM_TYPE_L2TPV3OIP.
1500 * Matches a L2TPv3 over IP header.
1502 struct rte_flow_item_l2tpv3oip {
1503 rte_be32_t session_id; /**< Session ID. */
1506 /** Default mask for RTE_FLOW_ITEM_TYPE_L2TPV3OIP. */
1508 static const struct rte_flow_item_l2tpv3oip rte_flow_item_l2tpv3oip_mask = {
1509 .session_id = RTE_BE32(UINT32_MAX),
1516 * @b EXPERIMENTAL: this structure may change without prior notice
1518 * RTE_FLOW_ITEM_TYPE_MARK
1520 * Matches an arbitrary integer value which was set using the ``MARK`` action
1521 * in a previously matched rule.
1523 * This item can only be specified once as a match criteria as the ``MARK``
1524 * action can only be specified once in a flow action.
1526 * This value is arbitrary and application-defined. Maximum allowed value
1527 * depends on the underlying implementation.
1529 * Depending on the underlying implementation the MARK item may be supported on
1530 * the physical device, with virtual groups in the PMD or not at all.
1532 struct rte_flow_item_mark {
1533 uint32_t id; /**< Integer value to match against. */
1536 /** Default mask for RTE_FLOW_ITEM_TYPE_MARK. */
1538 static const struct rte_flow_item_mark rte_flow_item_mark_mask = {
1545 * @b EXPERIMENTAL: this structure may change without prior notice
1547 * RTE_FLOW_ITEM_TYPE_NSH
1549 * Match network service header (NSH), RFC 8300
1552 struct rte_flow_item_nsh {
1555 uint32_t reserved:1;
1558 uint32_t reserved1:4;
1560 uint32_t next_proto:8;
1565 /** Default mask for RTE_FLOW_ITEM_TYPE_NSH. */
1567 static const struct rte_flow_item_nsh rte_flow_item_nsh_mask = {
1577 * @b EXPERIMENTAL: this structure may change without prior notice
1579 * RTE_FLOW_ITEM_TYPE_IGMP
1581 * Match Internet Group Management Protocol (IGMP), RFC 2236
1584 struct rte_flow_item_igmp {
1586 uint32_t max_resp_time:8;
1587 uint32_t checksum:16;
1588 uint32_t group_addr;
1591 /** Default mask for RTE_FLOW_ITEM_TYPE_IGMP. */
1593 static const struct rte_flow_item_igmp rte_flow_item_igmp_mask = {
1594 .group_addr = 0xffffffff,
1600 * @b EXPERIMENTAL: this structure may change without prior notice
1602 * RTE_FLOW_ITEM_TYPE_AH
1604 * Match IP Authentication Header (AH), RFC 4302
1607 struct rte_flow_item_ah {
1608 uint32_t next_hdr:8;
1609 uint32_t payload_len:8;
1610 uint32_t reserved:16;
1615 /** Default mask for RTE_FLOW_ITEM_TYPE_AH. */
1617 static const struct rte_flow_item_ah rte_flow_item_ah_mask = {
1624 * @b EXPERIMENTAL: this structure may change without prior notice
1626 * RTE_FLOW_ITEM_TYPE_PFCP
1630 struct rte_flow_item_pfcp {
1637 /** Default mask for RTE_FLOW_ITEM_TYPE_PFCP. */
1639 static const struct rte_flow_item_pfcp rte_flow_item_pfcp_mask = {
1641 .seid = RTE_BE64(UINT64_C(0xffffffffffffffff)),
1647 * @b EXPERIMENTAL: this structure may change without prior notice
1649 * RTE_FLOW_ITEM_TYPE_ECPRI
1651 * Match eCPRI Header
1653 struct rte_flow_item_ecpri {
1654 struct rte_ecpri_combined_msg_hdr hdr;
1657 /** Default mask for RTE_FLOW_ITEM_TYPE_ECPRI. */
1659 static const struct rte_flow_item_ecpri rte_flow_item_ecpri_mask = {
1669 * RTE_FLOW_ITEM_TYPE_GENEVE_OPT
1671 * Matches a GENEVE Variable Length Option
1673 struct rte_flow_item_geneve_opt {
1674 rte_be16_t option_class;
1675 uint8_t option_type;
1680 /** Default mask for RTE_FLOW_ITEM_TYPE_GENEVE_OPT. */
1682 static const struct rte_flow_item_geneve_opt
1683 rte_flow_item_geneve_opt_mask = {
1684 .option_type = 0xff,
1689 * Matching pattern item definition.
1691 * A pattern is formed by stacking items starting from the lowest protocol
1692 * layer to match. This stacking restriction does not apply to meta items
1693 * which can be placed anywhere in the stack without affecting the meaning
1694 * of the resulting pattern.
1696 * Patterns are terminated by END items.
1698 * The spec field should be a valid pointer to a structure of the related
1699 * item type. It may remain unspecified (NULL) in many cases to request
1700 * broad (nonspecific) matching. In such cases, last and mask must also be
1703 * Optionally, last can point to a structure of the same type to define an
1704 * inclusive range. This is mostly supported by integer and address fields,
1705 * may cause errors otherwise. Fields that do not support ranges must be set
1706 * to 0 or to the same value as the corresponding fields in spec.
1708 * Only the fields defined to nonzero values in the default masks (see
1709 * rte_flow_item_{name}_mask constants) are considered relevant by
1710 * default. This can be overridden by providing a mask structure of the
1711 * same type with applicable bits set to one. It can also be used to
1712 * partially filter out specific fields (e.g. as an alternate mean to match
1713 * ranges of IP addresses).
1715 * Mask is a simple bit-mask applied before interpreting the contents of
1716 * spec and last, which may yield unexpected results if not used
1717 * carefully. For example, if for an IPv4 address field, spec provides
1718 * 10.1.2.3, last provides 10.3.4.5 and mask provides 255.255.0.0, the
1719 * effective range becomes 10.1.0.0 to 10.3.255.255.
1721 struct rte_flow_item {
1722 enum rte_flow_item_type type; /**< Item type. */
1723 const void *spec; /**< Pointer to item specification structure. */
1724 const void *last; /**< Defines an inclusive range (spec to last). */
1725 const void *mask; /**< Bit-mask applied to spec and last. */
1731 * Each possible action is represented by a type.
1732 * An action can have an associated configuration object.
1733 * Several actions combined in a list can be assigned
1734 * to a flow rule and are performed in order.
1736 * They fall in three categories:
1738 * - Actions that modify the fate of matching traffic, for instance by
1739 * dropping or assigning it a specific destination.
1741 * - Actions that modify matching traffic contents or its properties. This
1742 * includes adding/removing encapsulation, encryption, compression and
1745 * - Actions related to the flow rule itself, such as updating counters or
1746 * making it non-terminating.
1748 * Flow rules being terminating by default, not specifying any action of the
1749 * fate kind results in undefined behavior. This applies to both ingress and
1752 * PASSTHRU, when supported, makes a flow rule non-terminating.
1754 enum rte_flow_action_type {
1756 * End marker for action lists. Prevents further processing of
1757 * actions, thereby ending the list.
1759 * No associated configuration structure.
1761 RTE_FLOW_ACTION_TYPE_END,
1764 * Used as a placeholder for convenience. It is ignored and simply
1765 * discarded by PMDs.
1767 * No associated configuration structure.
1769 RTE_FLOW_ACTION_TYPE_VOID,
1772 * Leaves traffic up for additional processing by subsequent flow
1773 * rules; makes a flow rule non-terminating.
1775 * No associated configuration structure.
1777 RTE_FLOW_ACTION_TYPE_PASSTHRU,
1780 * RTE_FLOW_ACTION_TYPE_JUMP
1782 * Redirects packets to a group on the current device.
1784 * See struct rte_flow_action_jump.
1786 RTE_FLOW_ACTION_TYPE_JUMP,
1789 * Attaches an integer value to packets and sets PKT_RX_FDIR and
1790 * PKT_RX_FDIR_ID mbuf flags.
1792 * See struct rte_flow_action_mark.
1794 RTE_FLOW_ACTION_TYPE_MARK,
1797 * Flags packets. Similar to MARK without a specific value; only
1798 * sets the PKT_RX_FDIR mbuf flag.
1800 * No associated configuration structure.
1802 RTE_FLOW_ACTION_TYPE_FLAG,
1805 * Assigns packets to a given queue index.
1807 * See struct rte_flow_action_queue.
1809 RTE_FLOW_ACTION_TYPE_QUEUE,
1814 * PASSTHRU overrides this action if both are specified.
1816 * No associated configuration structure.
1818 RTE_FLOW_ACTION_TYPE_DROP,
1821 * Enables counters for this flow rule.
1823 * These counters can be retrieved and reset through rte_flow_query() or
1824 * rte_flow_shared_action_query() if the action provided via handle,
1825 * see struct rte_flow_query_count.
1827 * See struct rte_flow_action_count.
1829 RTE_FLOW_ACTION_TYPE_COUNT,
1832 * Similar to QUEUE, except RSS is additionally performed on packets
1833 * to spread them among several queues according to the provided
1836 * See struct rte_flow_action_rss.
1838 RTE_FLOW_ACTION_TYPE_RSS,
1841 * Directs matching traffic to the physical function (PF) of the
1844 * No associated configuration structure.
1846 RTE_FLOW_ACTION_TYPE_PF,
1849 * Directs matching traffic to a given virtual function of the
1852 * See struct rte_flow_action_vf.
1854 RTE_FLOW_ACTION_TYPE_VF,
1857 * Directs packets to a given physical port index of the underlying
1860 * See struct rte_flow_action_phy_port.
1862 RTE_FLOW_ACTION_TYPE_PHY_PORT,
1865 * Directs matching traffic to a given DPDK port ID.
1867 * See struct rte_flow_action_port_id.
1869 RTE_FLOW_ACTION_TYPE_PORT_ID,
1872 * Traffic metering and policing (MTR).
1874 * See struct rte_flow_action_meter.
1875 * See file rte_mtr.h for MTR object configuration.
1877 RTE_FLOW_ACTION_TYPE_METER,
1880 * Redirects packets to security engine of current device for security
1881 * processing as specified by security session.
1883 * See struct rte_flow_action_security.
1885 RTE_FLOW_ACTION_TYPE_SECURITY,
1888 * Implements OFPAT_SET_MPLS_TTL ("MPLS TTL") as defined by the
1889 * OpenFlow Switch Specification.
1891 * See struct rte_flow_action_of_set_mpls_ttl.
1893 RTE_FLOW_ACTION_TYPE_OF_SET_MPLS_TTL,
1896 * Implements OFPAT_DEC_MPLS_TTL ("decrement MPLS TTL") as defined
1897 * by the OpenFlow Switch Specification.
1899 * No associated configuration structure.
1901 RTE_FLOW_ACTION_TYPE_OF_DEC_MPLS_TTL,
1904 * Implements OFPAT_SET_NW_TTL ("IP TTL") as defined by the OpenFlow
1905 * Switch Specification.
1907 * See struct rte_flow_action_of_set_nw_ttl.
1909 RTE_FLOW_ACTION_TYPE_OF_SET_NW_TTL,
1912 * Implements OFPAT_DEC_NW_TTL ("decrement IP TTL") as defined by
1913 * the OpenFlow Switch Specification.
1915 * No associated configuration structure.
1917 RTE_FLOW_ACTION_TYPE_OF_DEC_NW_TTL,
1920 * Implements OFPAT_COPY_TTL_OUT ("copy TTL "outwards" -- from
1921 * next-to-outermost to outermost") as defined by the OpenFlow
1922 * Switch Specification.
1924 * No associated configuration structure.
1926 RTE_FLOW_ACTION_TYPE_OF_COPY_TTL_OUT,
1929 * Implements OFPAT_COPY_TTL_IN ("copy TTL "inwards" -- from
1930 * outermost to next-to-outermost") as defined by the OpenFlow
1931 * Switch Specification.
1933 * No associated configuration structure.
1935 RTE_FLOW_ACTION_TYPE_OF_COPY_TTL_IN,
1938 * Implements OFPAT_POP_VLAN ("pop the outer VLAN tag") as defined
1939 * by the OpenFlow Switch Specification.
1941 * No associated configuration structure.
1943 RTE_FLOW_ACTION_TYPE_OF_POP_VLAN,
1946 * Implements OFPAT_PUSH_VLAN ("push a new VLAN tag") as defined by
1947 * the OpenFlow Switch Specification.
1949 * See struct rte_flow_action_of_push_vlan.
1951 RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN,
1954 * Implements OFPAT_SET_VLAN_VID ("set the 802.1q VLAN id") as
1955 * defined by the OpenFlow Switch Specification.
1957 * See struct rte_flow_action_of_set_vlan_vid.
1959 RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID,
1962 * Implements OFPAT_SET_LAN_PCP ("set the 802.1q priority") as
1963 * defined by the OpenFlow Switch Specification.
1965 * See struct rte_flow_action_of_set_vlan_pcp.
1967 RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP,
1970 * Implements OFPAT_POP_MPLS ("pop the outer MPLS tag") as defined
1971 * by the OpenFlow Switch Specification.
1973 * See struct rte_flow_action_of_pop_mpls.
1975 RTE_FLOW_ACTION_TYPE_OF_POP_MPLS,
1978 * Implements OFPAT_PUSH_MPLS ("push a new MPLS tag") as defined by
1979 * the OpenFlow Switch Specification.
1981 * See struct rte_flow_action_of_push_mpls.
1983 RTE_FLOW_ACTION_TYPE_OF_PUSH_MPLS,
1986 * Encapsulate flow in VXLAN tunnel as defined in
1987 * rte_flow_action_vxlan_encap action structure.
1989 * See struct rte_flow_action_vxlan_encap.
1991 RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP,
1994 * Decapsulate outer most VXLAN tunnel from matched flow.
1996 * If flow pattern does not define a valid VXLAN tunnel (as specified by
1997 * RFC7348) then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION
2000 RTE_FLOW_ACTION_TYPE_VXLAN_DECAP,
2003 * Encapsulate flow in NVGRE tunnel defined in the
2004 * rte_flow_action_nvgre_encap action structure.
2006 * See struct rte_flow_action_nvgre_encap.
2008 RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP,
2011 * Decapsulate outer most NVGRE tunnel from matched flow.
2013 * If flow pattern does not define a valid NVGRE tunnel (as specified by
2014 * RFC7637) then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION
2017 RTE_FLOW_ACTION_TYPE_NVGRE_DECAP,
2020 * Add outer header whose template is provided in its data buffer
2022 * See struct rte_flow_action_raw_encap.
2024 RTE_FLOW_ACTION_TYPE_RAW_ENCAP,
2027 * Remove outer header whose template is provided in its data buffer.
2029 * See struct rte_flow_action_raw_decap
2031 RTE_FLOW_ACTION_TYPE_RAW_DECAP,
2034 * Modify IPv4 source address in the outermost IPv4 header.
2036 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV4,
2037 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2039 * See struct rte_flow_action_set_ipv4.
2041 RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC,
2044 * Modify IPv4 destination address in the outermost IPv4 header.
2046 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV4,
2047 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2049 * See struct rte_flow_action_set_ipv4.
2051 RTE_FLOW_ACTION_TYPE_SET_IPV4_DST,
2054 * Modify IPv6 source address in the outermost IPv6 header.
2056 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV6,
2057 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2059 * See struct rte_flow_action_set_ipv6.
2061 RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC,
2064 * Modify IPv6 destination address in the outermost IPv6 header.
2066 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV6,
2067 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2069 * See struct rte_flow_action_set_ipv6.
2071 RTE_FLOW_ACTION_TYPE_SET_IPV6_DST,
2074 * Modify source port number in the outermost TCP/UDP header.
2076 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_TCP
2077 * or RTE_FLOW_ITEM_TYPE_UDP, then the PMD should return a
2078 * RTE_FLOW_ERROR_TYPE_ACTION error.
2080 * See struct rte_flow_action_set_tp.
2082 RTE_FLOW_ACTION_TYPE_SET_TP_SRC,
2085 * Modify destination port number in the outermost TCP/UDP header.
2087 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_TCP
2088 * or RTE_FLOW_ITEM_TYPE_UDP, then the PMD should return a
2089 * RTE_FLOW_ERROR_TYPE_ACTION error.
2091 * See struct rte_flow_action_set_tp.
2093 RTE_FLOW_ACTION_TYPE_SET_TP_DST,
2096 * Swap the source and destination MAC addresses in the outermost
2099 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_ETH,
2100 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2102 * No associated configuration structure.
2104 RTE_FLOW_ACTION_TYPE_MAC_SWAP,
2107 * Decrease TTL value directly
2109 * No associated configuration structure.
2111 RTE_FLOW_ACTION_TYPE_DEC_TTL,
2116 * See struct rte_flow_action_set_ttl
2118 RTE_FLOW_ACTION_TYPE_SET_TTL,
2121 * Set source MAC address from matched flow.
2123 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_ETH,
2124 * the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2126 * See struct rte_flow_action_set_mac.
2128 RTE_FLOW_ACTION_TYPE_SET_MAC_SRC,
2131 * Set destination MAC address from matched flow.
2133 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_ETH,
2134 * the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2136 * See struct rte_flow_action_set_mac.
2138 RTE_FLOW_ACTION_TYPE_SET_MAC_DST,
2141 * Increase sequence number in the outermost TCP header.
2143 * Action configuration specifies the value to increase
2144 * TCP sequence number as a big-endian 32 bit integer.
2147 * @code rte_be32_t * @endcode
2149 * Using this action on non-matching traffic will result in
2150 * undefined behavior.
2152 RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ,
2155 * Decrease sequence number in the outermost TCP header.
2157 * Action configuration specifies the value to decrease
2158 * TCP sequence number as a big-endian 32 bit integer.
2161 * @code rte_be32_t * @endcode
2163 * Using this action on non-matching traffic will result in
2164 * undefined behavior.
2166 RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ,
2169 * Increase acknowledgment number in the outermost TCP header.
2171 * Action configuration specifies the value to increase
2172 * TCP acknowledgment number as a big-endian 32 bit integer.
2175 * @code rte_be32_t * @endcode
2177 * Using this action on non-matching traffic will result in
2178 * undefined behavior.
2180 RTE_FLOW_ACTION_TYPE_INC_TCP_ACK,
2183 * Decrease acknowledgment number in the outermost TCP header.
2185 * Action configuration specifies the value to decrease
2186 * TCP acknowledgment number as a big-endian 32 bit integer.
2189 * @code rte_be32_t * @endcode
2191 * Using this action on non-matching traffic will result in
2192 * undefined behavior.
2194 RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK,
2199 * Tag is for internal flow usage only and
2200 * is not delivered to the application.
2202 * See struct rte_flow_action_set_tag.
2204 RTE_FLOW_ACTION_TYPE_SET_TAG,
2207 * Set metadata on ingress or egress path.
2209 * See struct rte_flow_action_set_meta.
2211 RTE_FLOW_ACTION_TYPE_SET_META,
2214 * Modify IPv4 DSCP in the outermost IP header.
2216 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV4,
2217 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2219 * See struct rte_flow_action_set_dscp.
2221 RTE_FLOW_ACTION_TYPE_SET_IPV4_DSCP,
2224 * Modify IPv6 DSCP in the outermost IP header.
2226 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV6,
2227 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2229 * See struct rte_flow_action_set_dscp.
2231 RTE_FLOW_ACTION_TYPE_SET_IPV6_DSCP,
2234 * Report as aged flow if timeout passed without any matching on the
2237 * See struct rte_flow_action_age.
2238 * See function rte_flow_get_aged_flows
2239 * see enum RTE_ETH_EVENT_FLOW_AGED
2240 * See struct rte_flow_query_age
2242 RTE_FLOW_ACTION_TYPE_AGE,
2245 * The matching packets will be duplicated with specified ratio and
2246 * applied with own set of actions with a fate action.
2248 * See struct rte_flow_action_sample.
2250 RTE_FLOW_ACTION_TYPE_SAMPLE,
2253 * Describe action shared across multiple flow rules.
2255 * Allow multiple rules reference the same action by handle (see
2256 * struct rte_flow_shared_action).
2258 RTE_FLOW_ACTION_TYPE_SHARED,
2261 * Modify a packet header field, tag, mark or metadata.
2263 * Allow the modification of an arbitrary header field via
2264 * set, add and sub operations or copying its content into
2265 * tag, meta or mark for future processing.
2267 * See struct rte_flow_action_modify_field.
2269 RTE_FLOW_ACTION_TYPE_MODIFY_FIELD,
2273 * RTE_FLOW_ACTION_TYPE_MARK
2275 * Attaches an integer value to packets and sets PKT_RX_FDIR and
2276 * PKT_RX_FDIR_ID mbuf flags.
2278 * This value is arbitrary and application-defined. Maximum allowed value
2279 * depends on the underlying implementation. It is returned in the
2280 * hash.fdir.hi mbuf field.
2282 struct rte_flow_action_mark {
2283 uint32_t id; /**< Integer value to return with packets. */
2288 * @b EXPERIMENTAL: this structure may change without prior notice
2290 * RTE_FLOW_ACTION_TYPE_JUMP
2292 * Redirects packets to a group on the current device.
2294 * In a hierarchy of groups, which can be used to represent physical or logical
2295 * flow tables on the device, this action allows the action to be a redirect to
2296 * a group on that device.
2298 struct rte_flow_action_jump {
2303 * RTE_FLOW_ACTION_TYPE_QUEUE
2305 * Assign packets to a given queue index.
2307 struct rte_flow_action_queue {
2308 uint16_t index; /**< Queue index to use. */
2313 * @b EXPERIMENTAL: this structure may change without prior notice
2315 * RTE_FLOW_ACTION_TYPE_AGE
2317 * Report flow as aged-out if timeout passed without any matching
2318 * on the flow. RTE_ETH_EVENT_FLOW_AGED event is triggered when a
2319 * port detects new aged-out flows.
2321 * The flow context and the flow handle will be reported by the
2322 * rte_flow_get_aged_flows API.
2324 struct rte_flow_action_age {
2325 uint32_t timeout:24; /**< Time in seconds. */
2326 uint32_t reserved:8; /**< Reserved, must be zero. */
2328 /**< The user flow context, NULL means the rte_flow pointer. */
2332 * RTE_FLOW_ACTION_TYPE_AGE (query)
2334 * Query structure to retrieve the aging status information of a
2335 * shared AGE action, or a flow rule using the AGE action.
2337 struct rte_flow_query_age {
2338 uint32_t reserved:6; /**< Reserved, must be zero. */
2339 uint32_t aged:1; /**< 1 if aging timeout expired, 0 otherwise. */
2340 uint32_t sec_since_last_hit_valid:1;
2341 /**< sec_since_last_hit value is valid. */
2342 uint32_t sec_since_last_hit:24; /**< Seconds since last traffic hit. */
2347 * @b EXPERIMENTAL: this structure may change without prior notice
2349 * RTE_FLOW_ACTION_TYPE_COUNT
2351 * Adds a counter action to a matched flow.
2353 * If more than one count action is specified in a single flow rule, then each
2354 * action must specify a unique id.
2356 * Counters can be retrieved and reset through ``rte_flow_query()``, see
2357 * ``struct rte_flow_query_count``.
2359 * @deprecated Shared attribute is deprecated, use generic
2360 * RTE_FLOW_ACTION_TYPE_SHARED action.
2362 * The shared flag indicates whether the counter is unique to the flow rule the
2363 * action is specified with, or whether it is a shared counter.
2365 * For a count action with the shared flag set, then then a global device
2366 * namespace is assumed for the counter id, so that any matched flow rules using
2367 * a count action with the same counter id on the same port will contribute to
2370 * For ports within the same switch domain then the counter id namespace extends
2371 * to all ports within that switch domain.
2373 struct rte_flow_action_count {
2374 /** @deprecated Share counter ID with other flow rules. */
2376 uint32_t reserved:31; /**< Reserved, must be zero. */
2377 uint32_t id; /**< Counter ID. */
2381 * RTE_FLOW_ACTION_TYPE_COUNT (query)
2383 * Query structure to retrieve and reset flow rule counters.
2385 struct rte_flow_query_count {
2386 uint32_t reset:1; /**< Reset counters after query [in]. */
2387 uint32_t hits_set:1; /**< hits field is set [out]. */
2388 uint32_t bytes_set:1; /**< bytes field is set [out]. */
2389 uint32_t reserved:29; /**< Reserved, must be zero [in, out]. */
2390 uint64_t hits; /**< Number of hits for this rule [out]. */
2391 uint64_t bytes; /**< Number of bytes through this rule [out]. */
2395 * Hash function types.
2397 enum rte_eth_hash_function {
2398 RTE_ETH_HASH_FUNCTION_DEFAULT = 0,
2399 RTE_ETH_HASH_FUNCTION_TOEPLITZ, /**< Toeplitz */
2400 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR, /**< Simple XOR */
2402 * Symmetric Toeplitz: src, dst will be replaced by
2403 * xor(src, dst). For the case with src/dst only,
2404 * src or dst address will xor with zero pair.
2406 RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ,
2407 RTE_ETH_HASH_FUNCTION_MAX,
2411 * RTE_FLOW_ACTION_TYPE_RSS
2413 * Similar to QUEUE, except RSS is additionally performed on packets to
2414 * spread them among several queues according to the provided parameters.
2416 * Unlike global RSS settings used by other DPDK APIs, unsetting the
2417 * @p types field does not disable RSS in a flow rule. Doing so instead
2418 * requests safe unspecified "best-effort" settings from the underlying PMD,
2419 * which depending on the flow rule, may result in anything ranging from
2420 * empty (single queue) to all-inclusive RSS.
2422 * Note: RSS hash result is stored in the hash.rss mbuf field which overlaps
2423 * hash.fdir.lo. Since the MARK action sets the hash.fdir.hi field only,
2424 * both can be requested simultaneously.
2426 struct rte_flow_action_rss {
2427 enum rte_eth_hash_function func; /**< RSS hash function to apply. */
2429 * Packet encapsulation level RSS hash @p types apply to.
2431 * - @p 0 requests the default behavior. Depending on the packet
2432 * type, it can mean outermost, innermost, anything in between or
2435 * It basically stands for the innermost encapsulation level RSS
2436 * can be performed on according to PMD and device capabilities.
2438 * - @p 1 requests RSS to be performed on the outermost packet
2439 * encapsulation level.
2441 * - @p 2 and subsequent values request RSS to be performed on the
2442 * specified inner packet encapsulation level, from outermost to
2443 * innermost (lower to higher values).
2445 * Values other than @p 0 are not necessarily supported.
2447 * Requesting a specific RSS level on unrecognized traffic results
2448 * in undefined behavior. For predictable results, it is recommended
2449 * to make the flow rule pattern match packet headers up to the
2450 * requested encapsulation level so that only matching traffic goes
2454 uint64_t types; /**< Specific RSS hash types (see ETH_RSS_*). */
2455 uint32_t key_len; /**< Hash key length in bytes. */
2456 uint32_t queue_num; /**< Number of entries in @p queue. */
2457 const uint8_t *key; /**< Hash key. */
2458 const uint16_t *queue; /**< Queue indices to use. */
2462 * RTE_FLOW_ACTION_TYPE_VF
2464 * Directs matching traffic to a given virtual function of the current
2467 * Packets matched by a VF pattern item can be redirected to their original
2468 * VF ID instead of the specified one. This parameter may not be available
2469 * and is not guaranteed to work properly if the VF part is matched by a
2470 * prior flow rule or if packets are not addressed to a VF in the first
2473 struct rte_flow_action_vf {
2474 uint32_t original:1; /**< Use original VF ID if possible. */
2475 uint32_t reserved:31; /**< Reserved, must be zero. */
2476 uint32_t id; /**< VF ID. */
2480 * RTE_FLOW_ACTION_TYPE_PHY_PORT
2482 * Directs packets to a given physical port index of the underlying
2485 * @see RTE_FLOW_ITEM_TYPE_PHY_PORT
2487 struct rte_flow_action_phy_port {
2488 uint32_t original:1; /**< Use original port index if possible. */
2489 uint32_t reserved:31; /**< Reserved, must be zero. */
2490 uint32_t index; /**< Physical port index. */
2494 * RTE_FLOW_ACTION_TYPE_PORT_ID
2496 * Directs matching traffic to a given DPDK port ID.
2498 * @see RTE_FLOW_ITEM_TYPE_PORT_ID
2500 struct rte_flow_action_port_id {
2501 uint32_t original:1; /**< Use original DPDK port ID if possible. */
2502 uint32_t reserved:31; /**< Reserved, must be zero. */
2503 uint32_t id; /**< DPDK port ID. */
2507 * RTE_FLOW_ACTION_TYPE_METER
2509 * Traffic metering and policing (MTR).
2511 * Packets matched by items of this type can be either dropped or passed to the
2512 * next item with their color set by the MTR object.
2514 struct rte_flow_action_meter {
2515 uint32_t mtr_id; /**< MTR object ID created with rte_mtr_create(). */
2519 * RTE_FLOW_ACTION_TYPE_SECURITY
2521 * Perform the security action on flows matched by the pattern items
2522 * according to the configuration of the security session.
2524 * This action modifies the payload of matched flows. For INLINE_CRYPTO, the
2525 * security protocol headers and IV are fully provided by the application as
2526 * specified in the flow pattern. The payload of matching packets is
2527 * encrypted on egress, and decrypted and authenticated on ingress.
2528 * For INLINE_PROTOCOL, the security protocol is fully offloaded to HW,
2529 * providing full encapsulation and decapsulation of packets in security
2530 * protocols. The flow pattern specifies both the outer security header fields
2531 * and the inner packet fields. The security session specified in the action
2532 * must match the pattern parameters.
2534 * The security session specified in the action must be created on the same
2535 * port as the flow action that is being specified.
2537 * The ingress/egress flow attribute should match that specified in the
2538 * security session if the security session supports the definition of the
2541 * Multiple flows can be configured to use the same security session.
2543 * The NULL value is allowed for security session. If security session is NULL,
2544 * then SPI field in ESP flow item and IP addresses in flow items 'IPv4' and
2545 * 'IPv6' will be allowed to be a range. The rule thus created can enable
2546 * security processing on multiple flows.
2548 struct rte_flow_action_security {
2549 void *security_session; /**< Pointer to security session structure. */
2553 * RTE_FLOW_ACTION_TYPE_OF_SET_MPLS_TTL
2555 * Implements OFPAT_SET_MPLS_TTL ("MPLS TTL") as defined by the OpenFlow
2556 * Switch Specification.
2558 struct rte_flow_action_of_set_mpls_ttl {
2559 uint8_t mpls_ttl; /**< MPLS TTL. */
2563 * RTE_FLOW_ACTION_TYPE_OF_SET_NW_TTL
2565 * Implements OFPAT_SET_NW_TTL ("IP TTL") as defined by the OpenFlow Switch
2568 struct rte_flow_action_of_set_nw_ttl {
2569 uint8_t nw_ttl; /**< IP TTL. */
2573 * RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN
2575 * Implements OFPAT_PUSH_VLAN ("push a new VLAN tag") as defined by the
2576 * OpenFlow Switch Specification.
2578 struct rte_flow_action_of_push_vlan {
2579 rte_be16_t ethertype; /**< EtherType. */
2583 * RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID
2585 * Implements OFPAT_SET_VLAN_VID ("set the 802.1q VLAN id") as defined by
2586 * the OpenFlow Switch Specification.
2588 struct rte_flow_action_of_set_vlan_vid {
2589 rte_be16_t vlan_vid; /**< VLAN id. */
2593 * RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP
2595 * Implements OFPAT_SET_LAN_PCP ("set the 802.1q priority") as defined by
2596 * the OpenFlow Switch Specification.
2598 struct rte_flow_action_of_set_vlan_pcp {
2599 uint8_t vlan_pcp; /**< VLAN priority. */
2603 * RTE_FLOW_ACTION_TYPE_OF_POP_MPLS
2605 * Implements OFPAT_POP_MPLS ("pop the outer MPLS tag") as defined by the
2606 * OpenFlow Switch Specification.
2608 struct rte_flow_action_of_pop_mpls {
2609 rte_be16_t ethertype; /**< EtherType. */
2613 * RTE_FLOW_ACTION_TYPE_OF_PUSH_MPLS
2615 * Implements OFPAT_PUSH_MPLS ("push a new MPLS tag") as defined by the
2616 * OpenFlow Switch Specification.
2618 struct rte_flow_action_of_push_mpls {
2619 rte_be16_t ethertype; /**< EtherType. */
2624 * @b EXPERIMENTAL: this structure may change without prior notice
2626 * RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP
2628 * VXLAN tunnel end-point encapsulation data definition
2630 * The tunnel definition is provided through the flow item pattern, the
2631 * provided pattern must conform to RFC7348 for the tunnel specified. The flow
2632 * definition must be provided in order from the RTE_FLOW_ITEM_TYPE_ETH
2633 * definition up the end item which is specified by RTE_FLOW_ITEM_TYPE_END.
2635 * The mask field allows user to specify which fields in the flow item
2636 * definitions can be ignored and which have valid data and can be used
2639 * Note: the last field is not used in the definition of a tunnel and can be
2642 * Valid flow definition for RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP include:
2644 * - ETH / IPV4 / UDP / VXLAN / END
2645 * - ETH / IPV6 / UDP / VXLAN / END
2646 * - ETH / VLAN / IPV4 / UDP / VXLAN / END
2649 struct rte_flow_action_vxlan_encap {
2651 * Encapsulating vxlan tunnel definition
2652 * (terminated by the END pattern item).
2654 struct rte_flow_item *definition;
2659 * @b EXPERIMENTAL: this structure may change without prior notice
2661 * RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP
2663 * NVGRE tunnel end-point encapsulation data definition
2665 * The tunnel definition is provided through the flow item pattern the
2666 * provided pattern must conform with RFC7637. The flow definition must be
2667 * provided in order from the RTE_FLOW_ITEM_TYPE_ETH definition up the end item
2668 * which is specified by RTE_FLOW_ITEM_TYPE_END.
2670 * The mask field allows user to specify which fields in the flow item
2671 * definitions can be ignored and which have valid data and can be used
2674 * Note: the last field is not used in the definition of a tunnel and can be
2677 * Valid flow definition for RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP include:
2679 * - ETH / IPV4 / NVGRE / END
2680 * - ETH / VLAN / IPV6 / NVGRE / END
2683 struct rte_flow_action_nvgre_encap {
2685 * Encapsulating vxlan tunnel definition
2686 * (terminated by the END pattern item).
2688 struct rte_flow_item *definition;
2693 * @b EXPERIMENTAL: this structure may change without prior notice
2695 * RTE_FLOW_ACTION_TYPE_RAW_ENCAP
2697 * Raw tunnel end-point encapsulation data definition.
2699 * The data holds the headers definitions to be applied on the packet.
2700 * The data must start with ETH header up to the tunnel item header itself.
2701 * When used right after RAW_DECAP (for decapsulating L3 tunnel type for
2702 * example MPLSoGRE) the data will just hold layer 2 header.
2704 * The preserve parameter holds which bits in the packet the PMD is not allowed
2705 * to change, this parameter can also be NULL and then the PMD is allowed
2706 * to update any field.
2708 * size holds the number of bytes in @p data and @p preserve.
2710 struct rte_flow_action_raw_encap {
2711 uint8_t *data; /**< Encapsulation data. */
2712 uint8_t *preserve; /**< Bit-mask of @p data to preserve on output. */
2713 size_t size; /**< Size of @p data and @p preserve. */
2718 * @b EXPERIMENTAL: this structure may change without prior notice
2720 * RTE_FLOW_ACTION_TYPE_RAW_DECAP
2722 * Raw tunnel end-point decapsulation data definition.
2724 * The data holds the headers definitions to be removed from the packet.
2725 * The data must start with ETH header up to the tunnel item header itself.
2726 * When used right before RAW_DECAP (for encapsulating L3 tunnel type for
2727 * example MPLSoGRE) the data will just hold layer 2 header.
2729 * size holds the number of bytes in @p data.
2731 struct rte_flow_action_raw_decap {
2732 uint8_t *data; /**< Encapsulation data. */
2733 size_t size; /**< Size of @p data and @p preserve. */
2738 * @b EXPERIMENTAL: this structure may change without prior notice
2740 * RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC
2741 * RTE_FLOW_ACTION_TYPE_SET_IPV4_DST
2743 * Allows modification of IPv4 source (RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC)
2744 * and destination address (RTE_FLOW_ACTION_TYPE_SET_IPV4_DST) in the
2745 * specified outermost IPv4 header.
2747 struct rte_flow_action_set_ipv4 {
2748 rte_be32_t ipv4_addr;
2753 * @b EXPERIMENTAL: this structure may change without prior notice
2755 * RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC
2756 * RTE_FLOW_ACTION_TYPE_SET_IPV6_DST
2758 * Allows modification of IPv6 source (RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC)
2759 * and destination address (RTE_FLOW_ACTION_TYPE_SET_IPV6_DST) in the
2760 * specified outermost IPv6 header.
2762 struct rte_flow_action_set_ipv6 {
2763 uint8_t ipv6_addr[16];
2768 * @b EXPERIMENTAL: this structure may change without prior notice
2770 * RTE_FLOW_ACTION_TYPE_SET_TP_SRC
2771 * RTE_FLOW_ACTION_TYPE_SET_TP_DST
2773 * Allows modification of source (RTE_FLOW_ACTION_TYPE_SET_TP_SRC)
2774 * and destination (RTE_FLOW_ACTION_TYPE_SET_TP_DST) port numbers
2775 * in the specified outermost TCP/UDP header.
2777 struct rte_flow_action_set_tp {
2782 * RTE_FLOW_ACTION_TYPE_SET_TTL
2784 * Set the TTL value directly for IPv4 or IPv6
2786 struct rte_flow_action_set_ttl {
2791 * RTE_FLOW_ACTION_TYPE_SET_MAC
2793 * Set MAC address from the matched flow
2795 struct rte_flow_action_set_mac {
2796 uint8_t mac_addr[RTE_ETHER_ADDR_LEN];
2801 * @b EXPERIMENTAL: this structure may change without prior notice
2803 * RTE_FLOW_ACTION_TYPE_SET_TAG
2805 * Set a tag which is a transient data used during flow matching. This is not
2806 * delivered to application. Multiple tags are supported by specifying index.
2808 struct rte_flow_action_set_tag {
2816 * @b EXPERIMENTAL: this structure may change without prior notice
2818 * RTE_FLOW_ACTION_TYPE_SET_META
2820 * Set metadata. Metadata set by mbuf metadata dynamic field with
2821 * PKT_TX_DYNF_DATA flag on egress will be overridden by this action. On
2822 * ingress, the metadata will be carried by mbuf metadata dynamic field
2823 * with PKT_RX_DYNF_METADATA flag if set. The dynamic mbuf field must be
2824 * registered in advance by rte_flow_dynf_metadata_register().
2826 * Altering partial bits is supported with mask. For bits which have never
2827 * been set, unpredictable value will be seen depending on driver
2828 * implementation. For loopback/hairpin packet, metadata set on Rx/Tx may
2829 * or may not be propagated to the other path depending on HW capability.
2831 * RTE_FLOW_ITEM_TYPE_META matches metadata.
2833 struct rte_flow_action_set_meta {
2839 * RTE_FLOW_ACTION_TYPE_SET_IPV4_DSCP
2840 * RTE_FLOW_ACTION_TYPE_SET_IPV6_DSCP
2842 * Set the DSCP value for IPv4/IPv6 header.
2843 * DSCP in low 6 bits, rest ignored.
2845 struct rte_flow_action_set_dscp {
2850 * RTE_FLOW_ACTION_TYPE_SHARED
2852 * Opaque type returned after successfully creating a shared action.
2854 * This handle can be used to manage and query the related action:
2855 * - share it across multiple flow rules
2856 * - update action configuration
2857 * - query action data
2860 struct rte_flow_shared_action;
2863 * Field IDs for MODIFY_FIELD action.
2865 enum rte_flow_field_id {
2866 RTE_FLOW_FIELD_START = 0, /**< Start of a packet. */
2867 RTE_FLOW_FIELD_MAC_DST, /**< Destination MAC Address. */
2868 RTE_FLOW_FIELD_MAC_SRC, /**< Source MAC Address. */
2869 RTE_FLOW_FIELD_VLAN_TYPE, /**< 802.1Q Tag Identifier. */
2870 RTE_FLOW_FIELD_VLAN_ID, /**< 802.1Q VLAN Identifier. */
2871 RTE_FLOW_FIELD_MAC_TYPE, /**< EtherType. */
2872 RTE_FLOW_FIELD_IPV4_DSCP, /**< IPv4 DSCP. */
2873 RTE_FLOW_FIELD_IPV4_TTL, /**< IPv4 Time To Live. */
2874 RTE_FLOW_FIELD_IPV4_SRC, /**< IPv4 Source Address. */
2875 RTE_FLOW_FIELD_IPV4_DST, /**< IPv4 Destination Address. */
2876 RTE_FLOW_FIELD_IPV6_DSCP, /**< IPv6 DSCP. */
2877 RTE_FLOW_FIELD_IPV6_HOPLIMIT, /**< IPv6 Hop Limit. */
2878 RTE_FLOW_FIELD_IPV6_SRC, /**< IPv6 Source Address. */
2879 RTE_FLOW_FIELD_IPV6_DST, /**< IPv6 Destination Address. */
2880 RTE_FLOW_FIELD_TCP_PORT_SRC, /**< TCP Source Port Number. */
2881 RTE_FLOW_FIELD_TCP_PORT_DST, /**< TCP Destination Port Number. */
2882 RTE_FLOW_FIELD_TCP_SEQ_NUM, /**< TCP Sequence Number. */
2883 RTE_FLOW_FIELD_TCP_ACK_NUM, /**< TCP Acknowledgment Number. */
2884 RTE_FLOW_FIELD_TCP_FLAGS, /**< TCP Flags. */
2885 RTE_FLOW_FIELD_UDP_PORT_SRC, /**< UDP Source Port Number. */
2886 RTE_FLOW_FIELD_UDP_PORT_DST, /**< UDP Destination Port Number. */
2887 RTE_FLOW_FIELD_VXLAN_VNI, /**< VXLAN Network Identifier. */
2888 RTE_FLOW_FIELD_GENEVE_VNI, /**< GENEVE Network Identifier. */
2889 RTE_FLOW_FIELD_GTP_TEID, /**< GTP Tunnel Endpoint Identifier. */
2890 RTE_FLOW_FIELD_TAG, /**< Tag value. */
2891 RTE_FLOW_FIELD_MARK, /**< Mark value. */
2892 RTE_FLOW_FIELD_META, /**< Metadata value. */
2893 RTE_FLOW_FIELD_POINTER, /**< Memory pointer. */
2894 RTE_FLOW_FIELD_VALUE, /**< Immediate value. */
2898 * Field description for MODIFY_FIELD action.
2900 struct rte_flow_action_modify_data {
2901 enum rte_flow_field_id field; /**< Field or memory type ID. */
2905 /**< Encapsulation level or tag index. */
2907 /**< Number of bits to skip from a field. */
2911 * Immediate value for RTE_FLOW_FIELD_VALUE or
2912 * memory address for RTE_FLOW_FIELD_POINTER.
2919 * Operation types for MODIFY_FIELD action.
2921 enum rte_flow_modify_op {
2922 RTE_FLOW_MODIFY_SET = 0, /**< Set a new value. */
2923 RTE_FLOW_MODIFY_ADD, /**< Add a value to a field. */
2924 RTE_FLOW_MODIFY_SUB, /**< Subtract a value from a field. */
2929 * @b EXPERIMENTAL: this structure may change without prior notice
2931 * RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
2933 * Modify a destination header field according to the specified
2934 * operation. Another packet field can be used as a source as well
2935 * as tag, mark, metadata, immediate value or a pointer to it.
2937 struct rte_flow_action_modify_field {
2938 enum rte_flow_modify_op operation; /**< Operation to perform. */
2939 struct rte_flow_action_modify_data dst; /**< Destination field. */
2940 struct rte_flow_action_modify_data src; /**< Source field. */
2941 uint32_t width; /**< Number of bits to use from a source field. */
2944 /* Mbuf dynamic field offset for metadata. */
2945 extern int32_t rte_flow_dynf_metadata_offs;
2947 /* Mbuf dynamic field flag mask for metadata. */
2948 extern uint64_t rte_flow_dynf_metadata_mask;
2950 /* Mbuf dynamic field pointer for metadata. */
2951 #define RTE_FLOW_DYNF_METADATA(m) \
2952 RTE_MBUF_DYNFIELD((m), rte_flow_dynf_metadata_offs, uint32_t *)
2954 /* Mbuf dynamic flags for metadata. */
2955 #define PKT_RX_DYNF_METADATA (rte_flow_dynf_metadata_mask)
2956 #define PKT_TX_DYNF_METADATA (rte_flow_dynf_metadata_mask)
2959 static inline uint32_t
2960 rte_flow_dynf_metadata_get(struct rte_mbuf *m)
2962 return *RTE_FLOW_DYNF_METADATA(m);
2967 rte_flow_dynf_metadata_set(struct rte_mbuf *m, uint32_t v)
2969 *RTE_FLOW_DYNF_METADATA(m) = v;
2973 * Definition of a single action.
2975 * A list of actions is terminated by a END action.
2977 * For simple actions without a configuration object, conf remains NULL.
2979 struct rte_flow_action {
2980 enum rte_flow_action_type type; /**< Action type. */
2981 const void *conf; /**< Pointer to action configuration object. */
2985 * Opaque type returned after successfully creating a flow.
2987 * This handle can be used to manage and query the related flow (e.g. to
2988 * destroy it or retrieve counters).
2994 * @b EXPERIMENTAL: this structure may change without prior notice
2996 * RTE_FLOW_ACTION_TYPE_SAMPLE
2998 * Adds a sample action to a matched flow.
3000 * The matching packets will be duplicated with specified ratio and applied
3001 * with own set of actions with a fate action, the sampled packet could be
3002 * redirected to queue or port. All the packets continue processing on the
3003 * default flow path.
3005 * When the sample ratio is set to 1 then the packets will be 100% mirrored.
3006 * Additional action list be supported to add for sampled or mirrored packets.
3008 struct rte_flow_action_sample {
3009 uint32_t ratio; /**< packets sampled equals to '1/ratio'. */
3010 const struct rte_flow_action *actions;
3011 /**< sub-action list specific for the sampling hit cases. */
3015 * Verbose error types.
3017 * Most of them provide the type of the object referenced by struct
3018 * rte_flow_error.cause.
3020 enum rte_flow_error_type {
3021 RTE_FLOW_ERROR_TYPE_NONE, /**< No error. */
3022 RTE_FLOW_ERROR_TYPE_UNSPECIFIED, /**< Cause unspecified. */
3023 RTE_FLOW_ERROR_TYPE_HANDLE, /**< Flow rule (handle). */
3024 RTE_FLOW_ERROR_TYPE_ATTR_GROUP, /**< Group field. */
3025 RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY, /**< Priority field. */
3026 RTE_FLOW_ERROR_TYPE_ATTR_INGRESS, /**< Ingress field. */
3027 RTE_FLOW_ERROR_TYPE_ATTR_EGRESS, /**< Egress field. */
3028 RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, /**< Transfer field. */
3029 RTE_FLOW_ERROR_TYPE_ATTR, /**< Attributes structure. */
3030 RTE_FLOW_ERROR_TYPE_ITEM_NUM, /**< Pattern length. */
3031 RTE_FLOW_ERROR_TYPE_ITEM_SPEC, /**< Item specification. */
3032 RTE_FLOW_ERROR_TYPE_ITEM_LAST, /**< Item specification range. */
3033 RTE_FLOW_ERROR_TYPE_ITEM_MASK, /**< Item specification mask. */
3034 RTE_FLOW_ERROR_TYPE_ITEM, /**< Specific pattern item. */
3035 RTE_FLOW_ERROR_TYPE_ACTION_NUM, /**< Number of actions. */
3036 RTE_FLOW_ERROR_TYPE_ACTION_CONF, /**< Action configuration. */
3037 RTE_FLOW_ERROR_TYPE_ACTION, /**< Specific action. */
3041 * Verbose error structure definition.
3043 * This object is normally allocated by applications and set by PMDs, the
3044 * message points to a constant string which does not need to be freed by
3045 * the application, however its pointer can be considered valid only as long
3046 * as its associated DPDK port remains configured. Closing the underlying
3047 * device or unloading the PMD invalidates it.
3049 * Both cause and message may be NULL regardless of the error type.
3051 struct rte_flow_error {
3052 enum rte_flow_error_type type; /**< Cause field and error types. */
3053 const void *cause; /**< Object responsible for the error. */
3054 const char *message; /**< Human-readable error message. */
3058 * Complete flow rule description.
3060 * This object type is used when converting a flow rule description.
3062 * @see RTE_FLOW_CONV_OP_RULE
3063 * @see rte_flow_conv()
3066 struct rte_flow_conv_rule {
3068 const struct rte_flow_attr *attr_ro; /**< RO attributes. */
3069 struct rte_flow_attr *attr; /**< Attributes. */
3072 const struct rte_flow_item *pattern_ro; /**< RO pattern. */
3073 struct rte_flow_item *pattern; /**< Pattern items. */
3076 const struct rte_flow_action *actions_ro; /**< RO actions. */
3077 struct rte_flow_action *actions; /**< List of actions. */
3082 * Conversion operations for flow API objects.
3084 * @see rte_flow_conv()
3086 enum rte_flow_conv_op {
3088 * No operation to perform.
3090 * rte_flow_conv() simply returns 0.
3092 RTE_FLOW_CONV_OP_NONE,
3095 * Convert attributes structure.
3097 * This is a basic copy of an attributes structure.
3100 * @code const struct rte_flow_attr * @endcode
3102 * @code struct rte_flow_attr * @endcode
3104 RTE_FLOW_CONV_OP_ATTR,
3107 * Convert a single item.
3109 * Duplicates @p spec, @p last and @p mask but not outside objects.
3112 * @code const struct rte_flow_item * @endcode
3114 * @code struct rte_flow_item * @endcode
3116 RTE_FLOW_CONV_OP_ITEM,
3119 * Convert a single action.
3121 * Duplicates @p conf but not outside objects.
3124 * @code const struct rte_flow_action * @endcode
3126 * @code struct rte_flow_action * @endcode
3128 RTE_FLOW_CONV_OP_ACTION,
3131 * Convert an entire pattern.
3133 * Duplicates all pattern items at once with the same constraints as
3134 * RTE_FLOW_CONV_OP_ITEM.
3137 * @code const struct rte_flow_item * @endcode
3139 * @code struct rte_flow_item * @endcode
3141 RTE_FLOW_CONV_OP_PATTERN,
3144 * Convert a list of actions.
3146 * Duplicates the entire list of actions at once with the same
3147 * constraints as RTE_FLOW_CONV_OP_ACTION.
3150 * @code const struct rte_flow_action * @endcode
3152 * @code struct rte_flow_action * @endcode
3154 RTE_FLOW_CONV_OP_ACTIONS,
3157 * Convert a complete flow rule description.
3159 * Comprises attributes, pattern and actions together at once with
3160 * the usual constraints.
3163 * @code const struct rte_flow_conv_rule * @endcode
3165 * @code struct rte_flow_conv_rule * @endcode
3167 RTE_FLOW_CONV_OP_RULE,
3170 * Convert item type to its name string.
3172 * Writes a NUL-terminated string to @p dst. Like snprintf(), the
3173 * returned value excludes the terminator which is always written
3177 * @code (const void *)enum rte_flow_item_type @endcode
3179 * @code char * @endcode
3181 RTE_FLOW_CONV_OP_ITEM_NAME,
3184 * Convert action type to its name string.
3186 * Writes a NUL-terminated string to @p dst. Like snprintf(), the
3187 * returned value excludes the terminator which is always written
3191 * @code (const void *)enum rte_flow_action_type @endcode
3193 * @code char * @endcode
3195 RTE_FLOW_CONV_OP_ACTION_NAME,
3198 * Convert item type to pointer to item name.
3200 * Retrieves item name pointer from its type. The string itself is
3201 * not copied; instead, a unique pointer to an internal static
3202 * constant storage is written to @p dst.
3205 * @code (const void *)enum rte_flow_item_type @endcode
3207 * @code const char ** @endcode
3209 RTE_FLOW_CONV_OP_ITEM_NAME_PTR,
3212 * Convert action type to pointer to action name.
3214 * Retrieves action name pointer from its type. The string itself is
3215 * not copied; instead, a unique pointer to an internal static
3216 * constant storage is written to @p dst.
3219 * @code (const void *)enum rte_flow_action_type @endcode
3221 * @code const char ** @endcode
3223 RTE_FLOW_CONV_OP_ACTION_NAME_PTR,
3228 * @b EXPERIMENTAL: this API may change without prior notice.
3230 * Dump hardware internal representation information of
3233 * @param[in] port_id
3234 * The port identifier of the Ethernet device.
3236 * The pointer of flow rule to dump. Dump all rules if NULL.
3238 * A pointer to a file for output.
3240 * Perform verbose error reporting if not NULL. PMDs initialize this
3241 * structure in case of error only.
3243 * 0 on success, a nagative value otherwise.
3247 rte_flow_dev_dump(uint16_t port_id, struct rte_flow *flow,
3248 FILE *file, struct rte_flow_error *error);
3251 * Check if mbuf dynamic field for metadata is registered.
3254 * True if registered, false otherwise.
3258 rte_flow_dynf_metadata_avail(void)
3260 return !!rte_flow_dynf_metadata_mask;
3264 * Register mbuf dynamic field and flag for metadata.
3266 * This function must be called prior to use SET_META action in order to
3267 * register the dynamic mbuf field. Otherwise, the data cannot be delivered to
3271 * 0 on success, a negative errno value otherwise and rte_errno is set.
3275 rte_flow_dynf_metadata_register(void);
3278 * Check whether a flow rule can be created on a given port.
3280 * The flow rule is validated for correctness and whether it could be accepted
3281 * by the device given sufficient resources. The rule is checked against the
3282 * current device mode and queue configuration. The flow rule may also
3283 * optionally be validated against existing flow rules and device resources.
3284 * This function has no effect on the target device.
3286 * The returned value is guaranteed to remain valid only as long as no
3287 * successful calls to rte_flow_create() or rte_flow_destroy() are made in
3288 * the meantime and no device parameter affecting flow rules in any way are
3289 * modified, due to possible collisions or resource limitations (although in
3290 * such cases EINVAL should not be returned).
3293 * Port identifier of Ethernet device.
3295 * Flow rule attributes.
3296 * @param[in] pattern
3297 * Pattern specification (list terminated by the END pattern item).
3298 * @param[in] actions
3299 * Associated actions (list terminated by the END action).
3301 * Perform verbose error reporting if not NULL. PMDs initialize this
3302 * structure in case of error only.
3305 * 0 if flow rule is valid and can be created. A negative errno value
3306 * otherwise (rte_errno is also set), the following errors are defined:
3308 * -ENOSYS: underlying device does not support this functionality.
3310 * -EIO: underlying device is removed.
3312 * -EINVAL: unknown or invalid rule specification.
3314 * -ENOTSUP: valid but unsupported rule specification (e.g. partial
3315 * bit-masks are unsupported).
3317 * -EEXIST: collision with an existing rule. Only returned if device
3318 * supports flow rule collision checking and there was a flow rule
3319 * collision. Not receiving this return code is no guarantee that creating
3320 * the rule will not fail due to a collision.
3322 * -ENOMEM: not enough memory to execute the function, or if the device
3323 * supports resource validation, resource limitation on the device.
3325 * -EBUSY: action cannot be performed due to busy device resources, may
3326 * succeed if the affected queues or even the entire port are in a stopped
3327 * state (see rte_eth_dev_rx_queue_stop() and rte_eth_dev_stop()).
3330 rte_flow_validate(uint16_t port_id,
3331 const struct rte_flow_attr *attr,
3332 const struct rte_flow_item pattern[],
3333 const struct rte_flow_action actions[],
3334 struct rte_flow_error *error);
3337 * Create a flow rule on a given port.
3340 * Port identifier of Ethernet device.
3342 * Flow rule attributes.
3343 * @param[in] pattern
3344 * Pattern specification (list terminated by the END pattern item).
3345 * @param[in] actions
3346 * Associated actions (list terminated by the END action).
3348 * Perform verbose error reporting if not NULL. PMDs initialize this
3349 * structure in case of error only.
3352 * A valid handle in case of success, NULL otherwise and rte_errno is set
3353 * to the positive version of one of the error codes defined for
3354 * rte_flow_validate().
3357 rte_flow_create(uint16_t port_id,
3358 const struct rte_flow_attr *attr,
3359 const struct rte_flow_item pattern[],
3360 const struct rte_flow_action actions[],
3361 struct rte_flow_error *error);
3364 * Destroy a flow rule on a given port.
3366 * Failure to destroy a flow rule handle may occur when other flow rules
3367 * depend on it, and destroying it would result in an inconsistent state.
3369 * This function is only guaranteed to succeed if handles are destroyed in
3370 * reverse order of their creation.
3373 * Port identifier of Ethernet device.
3375 * Flow rule handle to destroy.
3377 * Perform verbose error reporting if not NULL. PMDs initialize this
3378 * structure in case of error only.
3381 * 0 on success, a negative errno value otherwise and rte_errno is set.
3384 rte_flow_destroy(uint16_t port_id,
3385 struct rte_flow *flow,
3386 struct rte_flow_error *error);
3389 * Destroy all flow rules associated with a port.
3391 * In the unlikely event of failure, handles are still considered destroyed
3392 * and no longer valid but the port must be assumed to be in an inconsistent
3396 * Port identifier of Ethernet device.
3398 * Perform verbose error reporting if not NULL. PMDs initialize this
3399 * structure in case of error only.
3402 * 0 on success, a negative errno value otherwise and rte_errno is set.
3405 rte_flow_flush(uint16_t port_id,
3406 struct rte_flow_error *error);
3409 * Query an existing flow rule.
3411 * This function allows retrieving flow-specific data such as counters.
3412 * Data is gathered by special actions which must be present in the flow
3415 * \see RTE_FLOW_ACTION_TYPE_COUNT
3418 * Port identifier of Ethernet device.
3420 * Flow rule handle to query.
3422 * Action definition as defined in original flow rule.
3423 * @param[in, out] data
3424 * Pointer to storage for the associated query data type.
3426 * Perform verbose error reporting if not NULL. PMDs initialize this
3427 * structure in case of error only.
3430 * 0 on success, a negative errno value otherwise and rte_errno is set.
3433 rte_flow_query(uint16_t port_id,
3434 struct rte_flow *flow,
3435 const struct rte_flow_action *action,
3437 struct rte_flow_error *error);
3440 * Restrict ingress traffic to the defined flow rules.
3442 * Isolated mode guarantees that all ingress traffic comes from defined flow
3443 * rules only (current and future).
3445 * Besides making ingress more deterministic, it allows PMDs to safely reuse
3446 * resources otherwise assigned to handle the remaining traffic, such as
3447 * global RSS configuration settings, VLAN filters, MAC address entries,
3448 * legacy filter API rules and so on in order to expand the set of possible
3451 * Calling this function as soon as possible after device initialization,
3452 * ideally before the first call to rte_eth_dev_configure(), is recommended
3453 * to avoid possible failures due to conflicting settings.
3455 * Once effective, leaving isolated mode may not be possible depending on
3456 * PMD implementation.
3458 * Additionally, the following functionality has no effect on the underlying
3459 * port and may return errors such as ENOTSUP ("not supported"):
3461 * - Toggling promiscuous mode.
3462 * - Toggling allmulticast mode.
3463 * - Configuring MAC addresses.
3464 * - Configuring multicast addresses.
3465 * - Configuring VLAN filters.
3466 * - Configuring Rx filters through the legacy API (e.g. FDIR).
3467 * - Configuring global RSS settings.
3470 * Port identifier of Ethernet device.
3472 * Nonzero to enter isolated mode, attempt to leave it otherwise.
3474 * Perform verbose error reporting if not NULL. PMDs initialize this
3475 * structure in case of error only.
3478 * 0 on success, a negative errno value otherwise and rte_errno is set.
3481 rte_flow_isolate(uint16_t port_id, int set, struct rte_flow_error *error);
3484 * Initialize flow error structure.
3487 * Pointer to flow error structure (may be NULL).
3489 * Related error code (rte_errno).
3491 * Cause field and error types.
3493 * Object responsible for the error.
3495 * Human-readable error message.
3498 * Negative error code (errno value) and rte_errno is set.
3501 rte_flow_error_set(struct rte_flow_error *error,
3503 enum rte_flow_error_type type,
3505 const char *message);
3509 * @see rte_flow_copy()
3511 struct rte_flow_desc {
3512 size_t size; /**< Allocated space including data[]. */
3513 struct rte_flow_attr attr; /**< Attributes. */
3514 struct rte_flow_item *items; /**< Items. */
3515 struct rte_flow_action *actions; /**< Actions. */
3516 uint8_t data[]; /**< Storage for items/actions. */
3521 * Copy an rte_flow rule description.
3523 * This interface is kept for compatibility with older applications but is
3524 * implemented as a wrapper to rte_flow_conv(). It is deprecated due to its
3525 * lack of flexibility and reliance on a type unusable with C++ programs
3526 * (struct rte_flow_desc).
3529 * Flow rule description.
3531 * Total size of allocated data for the flow description.
3533 * Flow rule attributes.
3535 * Pattern specification (list terminated by the END pattern item).
3536 * @param[in] actions
3537 * Associated actions (list terminated by the END action).
3540 * If len is greater or equal to the size of the flow, the total size of the
3541 * flow description and its data.
3542 * If len is lower than the size of the flow, the number of bytes that would
3543 * have been written to desc had it been sufficient. Nothing is written.
3547 rte_flow_copy(struct rte_flow_desc *fd, size_t len,
3548 const struct rte_flow_attr *attr,
3549 const struct rte_flow_item *items,
3550 const struct rte_flow_action *actions);
3553 * Flow object conversion helper.
3555 * This function performs conversion of various flow API objects to a
3556 * pre-allocated destination buffer. See enum rte_flow_conv_op for possible
3557 * operations and details about each of them.
3559 * Since destination buffer must be large enough, it works in a manner
3560 * reminiscent of snprintf():
3562 * - If @p size is 0, @p dst may be a NULL pointer, otherwise @p dst must be
3564 * - If positive, the returned value represents the number of bytes needed
3565 * to store the conversion of @p src to @p dst according to @p op
3566 * regardless of the @p size parameter.
3567 * - Since no more than @p size bytes can be written to @p dst, output is
3568 * truncated and may be inconsistent when the returned value is larger
3570 * - In case of conversion error, a negative error code is returned and
3571 * @p dst contents are unspecified.
3574 * Operation to perform, related to the object type of @p dst.
3576 * Destination buffer address. Must be suitably aligned by the caller.
3578 * Destination buffer size in bytes.
3580 * Source object to copy. Depending on @p op, its type may differ from
3583 * Perform verbose error reporting if not NULL. Initialized in case of
3587 * The number of bytes required to convert @p src to @p dst on success, a
3588 * negative errno value otherwise and rte_errno is set.
3590 * @see rte_flow_conv_op
3594 rte_flow_conv(enum rte_flow_conv_op op,
3598 struct rte_flow_error *error);
3601 * Get aged-out flows of a given port.
3603 * RTE_ETH_EVENT_FLOW_AGED event will be triggered when at least one new aged
3604 * out flow was detected after the last call to rte_flow_get_aged_flows.
3605 * This function can be called to get the aged flows usynchronously from the
3606 * event callback or synchronously regardless the event.
3607 * This is not safe to call rte_flow_get_aged_flows function with other flow
3608 * functions from multiple threads simultaneously.
3611 * Port identifier of Ethernet device.
3612 * @param[in, out] contexts
3613 * The address of an array of pointers to the aged-out flows contexts.
3614 * @param[in] nb_contexts
3615 * The length of context array pointers.
3617 * Perform verbose error reporting if not NULL. Initialized in case of
3621 * if nb_contexts is 0, return the amount of all aged contexts.
3622 * if nb_contexts is not 0 , return the amount of aged flows reported
3623 * in the context array, otherwise negative errno value.
3625 * @see rte_flow_action_age
3626 * @see RTE_ETH_EVENT_FLOW_AGED
3630 rte_flow_get_aged_flows(uint16_t port_id, void **contexts,
3631 uint32_t nb_contexts, struct rte_flow_error *error);
3634 * Specify shared action configuration
3636 struct rte_flow_shared_action_conf {
3638 * Flow direction for shared action configuration.
3640 * Shared action should be valid at least for one flow direction,
3641 * otherwise it is invalid for both ingress and egress rules.
3644 /**< Action valid for rules applied to ingress traffic. */
3646 /**< Action valid for rules applied to egress traffic. */
3649 * When set to 1, indicates that the action is valid for
3650 * transfer traffic; otherwise, for non-transfer traffic.
3652 * See struct rte_flow_attr.
3654 uint32_t transfer:1;
3659 * @b EXPERIMENTAL: this API may change without prior notice.
3661 * Create shared action for reuse in multiple flow rules.
3662 * The created shared action has single state and configuration
3663 * across all flow rules using it.
3665 * @param[in] port_id
3666 * The port identifier of the Ethernet device.
3668 * Shared action configuration.
3670 * Action configuration for shared action creation.
3672 * Perform verbose error reporting if not NULL. PMDs initialize this
3673 * structure in case of error only.
3675 * A valid handle in case of success, NULL otherwise and rte_errno is set
3676 * to one of the error codes defined:
3677 * - (ENODEV) if *port_id* invalid.
3678 * - (ENOSYS) if underlying device does not support this functionality.
3679 * - (EIO) if underlying device is removed.
3680 * - (EINVAL) if *action* invalid.
3681 * - (ENOTSUP) if *action* valid but unsupported.
3684 struct rte_flow_shared_action *
3685 rte_flow_shared_action_create(uint16_t port_id,
3686 const struct rte_flow_shared_action_conf *conf,
3687 const struct rte_flow_action *action,
3688 struct rte_flow_error *error);
3692 * @b EXPERIMENTAL: this API may change without prior notice.
3694 * Destroy the shared action by handle.
3696 * @param[in] port_id
3697 * The port identifier of the Ethernet device.
3699 * Handle for the shared action to be destroyed.
3701 * Perform verbose error reporting if not NULL. PMDs initialize this
3702 * structure in case of error only.
3705 * - (-ENODEV) if *port_id* invalid.
3706 * - (-ENOSYS) if underlying device does not support this functionality.
3707 * - (-EIO) if underlying device is removed.
3708 * - (-ENOENT) if action pointed by *action* handle was not found.
3709 * - (-EBUSY) if action pointed by *action* handle still used by some rules
3710 * rte_errno is also set.
3714 rte_flow_shared_action_destroy(uint16_t port_id,
3715 struct rte_flow_shared_action *action,
3716 struct rte_flow_error *error);
3720 * @b EXPERIMENTAL: this API may change without prior notice.
3722 * Update in-place the shared action configuration pointed by *action* handle
3723 * with the configuration provided as *update* argument.
3724 * The update of the shared action configuration effects all flow rules reusing
3725 * the action via handle.
3727 * @param[in] port_id
3728 * The port identifier of the Ethernet device.
3730 * Handle for the shared action to be updated.
3732 * Action specification used to modify the action pointed by handle.
3733 * *update* should be of same type with the action pointed by the *action*
3734 * handle argument, otherwise considered as invalid.
3736 * Perform verbose error reporting if not NULL. PMDs initialize this
3737 * structure in case of error only.
3740 * - (-ENODEV) if *port_id* invalid.
3741 * - (-ENOSYS) if underlying device does not support this functionality.
3742 * - (-EIO) if underlying device is removed.
3743 * - (-EINVAL) if *update* invalid.
3744 * - (-ENOTSUP) if *update* valid but unsupported.
3745 * - (-ENOENT) if action pointed by *ctx* was not found.
3746 * rte_errno is also set.
3750 rte_flow_shared_action_update(uint16_t port_id,
3751 struct rte_flow_shared_action *action,
3752 const struct rte_flow_action *update,
3753 struct rte_flow_error *error);
3757 * @b EXPERIMENTAL: this API may change without prior notice.
3759 * Query the shared action by handle.
3761 * Retrieve action-specific data such as counters.
3762 * Data is gathered by special action which may be present/referenced in
3763 * more than one flow rule definition.
3765 * \see RTE_FLOW_ACTION_TYPE_COUNT
3768 * Port identifier of Ethernet device.
3770 * Handle for the shared action to query.
3771 * @param[in, out] data
3772 * Pointer to storage for the associated query data type.
3774 * Perform verbose error reporting if not NULL. PMDs initialize this
3775 * structure in case of error only.
3778 * 0 on success, a negative errno value otherwise and rte_errno is set.
3782 rte_flow_shared_action_query(uint16_t port_id,
3783 const struct rte_flow_shared_action *action,
3785 struct rte_flow_error *error);
3787 /* Tunnel has a type and the key information. */
3788 struct rte_flow_tunnel {
3790 * Tunnel type, for example RTE_FLOW_ITEM_TYPE_VXLAN,
3791 * RTE_FLOW_ITEM_TYPE_NVGRE etc.
3793 enum rte_flow_item_type type;
3794 uint64_t tun_id; /**< Tunnel identification. */
3799 rte_be32_t src_addr; /**< IPv4 source address. */
3800 rte_be32_t dst_addr; /**< IPv4 destination address. */
3803 uint8_t src_addr[16]; /**< IPv6 source address. */
3804 uint8_t dst_addr[16]; /**< IPv6 destination address. */
3807 rte_be16_t tp_src; /**< Tunnel port source. */
3808 rte_be16_t tp_dst; /**< Tunnel port destination. */
3809 uint16_t tun_flags; /**< Tunnel flags. */
3811 bool is_ipv6; /**< True for valid IPv6 fields. Otherwise IPv4. */
3814 * the following members are required to restore packet
3817 uint8_t tos; /**< TOS for IPv4, TC for IPv6. */
3818 uint8_t ttl; /**< TTL for IPv4, HL for IPv6. */
3819 uint32_t label; /**< Flow Label for IPv6. */
3823 * Indicate that the packet has a tunnel.
3825 #define RTE_FLOW_RESTORE_INFO_TUNNEL (1ULL << 0)
3828 * Indicate that the packet has a non decapsulated tunnel header.
3830 #define RTE_FLOW_RESTORE_INFO_ENCAPSULATED (1ULL << 1)
3833 * Indicate that the packet has a group_id.
3835 #define RTE_FLOW_RESTORE_INFO_GROUP_ID (1ULL << 2)
3838 * Restore information structure to communicate the current packet processing
3839 * state when some of the processing pipeline is done in hardware and should
3840 * continue in software.
3842 struct rte_flow_restore_info {
3844 * Bitwise flags (RTE_FLOW_RESTORE_INFO_*) to indicate validation of
3845 * other fields in struct rte_flow_restore_info.
3848 uint32_t group_id; /**< Group ID where packed missed */
3849 struct rte_flow_tunnel tunnel; /**< Tunnel information. */
3853 * Allocate an array of actions to be used in rte_flow_create, to implement
3854 * tunnel-decap-set for the given tunnel.
3856 * actions vxlan_decap / tunnel-decap-set(tunnel properties) /
3857 * jump group 0 / end
3860 * Port identifier of Ethernet device.
3862 * Tunnel properties.
3863 * @param[out] actions
3864 * Array of actions to be allocated by the PMD. This array should be
3865 * concatenated with the actions array provided to rte_flow_create.
3866 * @param[out] num_of_actions
3867 * Number of actions allocated.
3869 * Perform verbose error reporting if not NULL. PMDs initialize this
3870 * structure in case of error only.
3873 * 0 on success, a negative errno value otherwise and rte_errno is set.
3877 rte_flow_tunnel_decap_set(uint16_t port_id,
3878 struct rte_flow_tunnel *tunnel,
3879 struct rte_flow_action **actions,
3880 uint32_t *num_of_actions,
3881 struct rte_flow_error *error);
3884 * Allocate an array of items to be used in rte_flow_create, to implement
3885 * tunnel-match for the given tunnel.
3887 * pattern tunnel-match(tunnel properties) / outer-header-matches /
3888 * inner-header-matches / end
3891 * Port identifier of Ethernet device.
3893 * Tunnel properties.
3895 * Array of items to be allocated by the PMD. This array should be
3896 * concatenated with the items array provided to rte_flow_create.
3897 * @param[out] num_of_items
3898 * Number of items allocated.
3900 * Perform verbose error reporting if not NULL. PMDs initialize this
3901 * structure in case of error only.
3904 * 0 on success, a negative errno value otherwise and rte_errno is set.
3908 rte_flow_tunnel_match(uint16_t port_id,
3909 struct rte_flow_tunnel *tunnel,
3910 struct rte_flow_item **items,
3911 uint32_t *num_of_items,
3912 struct rte_flow_error *error);
3915 * Populate the current packet processing state, if exists, for the given mbuf.
3918 * Port identifier of Ethernet device.
3922 * Restore information. Upon success contains the HW state.
3924 * Perform verbose error reporting if not NULL. PMDs initialize this
3925 * structure in case of error only.
3928 * 0 on success, a negative errno value otherwise and rte_errno is set.
3932 rte_flow_get_restore_info(uint16_t port_id,
3934 struct rte_flow_restore_info *info,
3935 struct rte_flow_error *error);
3938 * Release the action array as allocated by rte_flow_tunnel_decap_set.
3941 * Port identifier of Ethernet device.
3942 * @param[in] actions
3943 * Array of actions to be released.
3944 * @param[in] num_of_actions
3945 * Number of elements in actions array.
3947 * Perform verbose error reporting if not NULL. PMDs initialize this
3948 * structure in case of error only.
3951 * 0 on success, a negative errno value otherwise and rte_errno is set.
3955 rte_flow_tunnel_action_decap_release(uint16_t port_id,
3956 struct rte_flow_action *actions,
3957 uint32_t num_of_actions,
3958 struct rte_flow_error *error);
3961 * Release the item array as allocated by rte_flow_tunnel_match.
3964 * Port identifier of Ethernet device.
3966 * Array of items to be released.
3967 * @param[in] num_of_items
3968 * Number of elements in item array.
3970 * Perform verbose error reporting if not NULL. PMDs initialize this
3971 * structure in case of error only.
3974 * 0 on success, a negative errno value otherwise and rte_errno is set.
3978 rte_flow_tunnel_item_release(uint16_t port_id,
3979 struct rte_flow_item *items,
3980 uint32_t num_of_items,
3981 struct rte_flow_error *error);
3986 #endif /* RTE_FLOW_H_ */