1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright 2016 6WIND S.A.
3 * Copyright 2016 Mellanox Technologies, Ltd
11 * RTE generic flow API
13 * This interface provides the ability to program packet matching and
14 * associated actions in hardware through flow rules.
21 #include <rte_common.h>
22 #include <rte_ether.h>
28 #include <rte_vxlan.h>
29 #include <rte_byteorder.h>
31 #include <rte_higig.h>
32 #include <rte_ecpri.h>
33 #include <rte_bitops.h>
35 #include <rte_mbuf_dyn.h>
36 #include <rte_meter.h>
38 #include <rte_l2tpv2.h>
46 * Flow rule attributes.
48 * Priorities are set on a per rule based within groups.
50 * Lower values denote higher priority, the highest priority for a flow rule
51 * is 0, so that a flow that matches for than one rule, the rule with the
52 * lowest priority value will always be matched.
54 * Although optional, applications are encouraged to group similar rules as
55 * much as possible to fully take advantage of hardware capabilities
56 * (e.g. optimized matching) and work around limitations (e.g. a single
57 * pattern type possibly allowed in a given group). Applications should be
58 * aware that groups are not linked by default, and that they must be
59 * explicitly linked by the application using the JUMP action.
61 * Priority levels are arbitrary and up to the application, they
62 * do not need to be contiguous nor start from 0, however the maximum number
63 * varies between devices and may be affected by existing flow rules.
65 * If a packet is matched by several rules of a given group for a given
66 * priority level, the outcome is undefined. It can take any path, may be
67 * duplicated or even cause unrecoverable errors.
69 * Note that support for more than a single group and priority level is not
72 * At vNIC / ethdev level, flow rules can apply to inbound and / or outbound
73 * traffic (ingress / egress), with respect to the vNIC / ethdev in question.
74 * At embedded switch level, flow rules apply to all traffic seen by it
75 * unless fitting meta items are used to set concrete traffic source(s).
77 * Several pattern items and actions are valid and can be used in both
78 * directions. Those valid for only one direction are described as such.
80 * At least one direction must be specified.
82 * Specifying both directions at once for a given rule is not recommended
83 * but may be valid in a few cases.
85 struct rte_flow_attr {
86 uint32_t group; /**< Priority group. */
87 uint32_t priority; /**< Rule priority level within group. */
89 * The rule in question applies to ingress traffic (non-"transfer").
92 * It has been possible to combine this attribute with "transfer".
93 * Doing so has been assumed to restrict the scope of matching
94 * to traffic going from within the embedded switch toward the
95 * ethdev the flow rule being created through. This behaviour
96 * is deprecated. During the transition period, one may still
97 * rely on it, but PMDs and applications are encouraged to
98 * gradually move away from this approach.
102 * The rule in question applies to egress traffic (non-"transfer").
105 * It has been possible to combine this attribute with "transfer".
106 * Doing so has been assumed to restrict the scope of matching
107 * to traffic sent by the application by virtue of the ethdev
108 * the flow rule being created through. This behaviour is now
109 * deprecated. During the transition period, one may still
110 * rely on it, but PMDs and applications are encouraged to
111 * gradually move away from this approach.
115 * Instead of simply matching the properties of traffic as it would
116 * appear on a given DPDK port ID, enabling this attribute transfers
117 * a flow rule to the lowest possible level of any device endpoints
118 * found in the pattern.
120 * When supported, this effectively enables an application to
121 * re-route traffic not necessarily intended for it (e.g. coming
122 * from or addressed to different physical ports, VFs or
123 * applications) at the device level.
125 * The application should match traffic originating from precise
126 * locations. See items PORT_REPRESENTOR and REPRESENTED_PORT.
128 * Managing "transfer" flows requires that the user communicate them
129 * through a suitable port. @see rte_flow_pick_transfer_proxy().
132 uint32_t reserved:29; /**< Reserved, must be zero. */
136 * Matching pattern item types.
138 * Pattern items fall in two categories:
140 * - Matching protocol headers and packet data, usually associated with a
141 * specification structure. These must be stacked in the same order as the
142 * protocol layers to match inside packets, starting from the lowest.
144 * - Matching meta-data or affecting pattern processing, often without a
145 * specification structure. Since they do not match packet contents, their
146 * position in the list is usually not relevant.
148 * See the description of individual types for more information. Those
149 * marked with [META] fall into the second category.
151 enum rte_flow_item_type {
155 * End marker for item lists. Prevents further processing of items,
156 * thereby ending the pattern.
158 * No associated specification structure.
160 RTE_FLOW_ITEM_TYPE_END,
165 * Used as a placeholder for convenience. It is ignored and simply
168 * No associated specification structure.
170 RTE_FLOW_ITEM_TYPE_VOID,
175 * Inverted matching, i.e. process packets that do not match the
178 * No associated specification structure.
180 RTE_FLOW_ITEM_TYPE_INVERT,
183 * Matches any protocol in place of the current layer, a single ANY
184 * may also stand for several protocol layers.
186 * See struct rte_flow_item_any.
188 RTE_FLOW_ITEM_TYPE_ANY,
192 * @see RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR
193 * @see RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT
197 * Matches traffic originating from (ingress) or going to (egress)
198 * the physical function of the current device.
200 * No associated specification structure.
202 RTE_FLOW_ITEM_TYPE_PF,
206 * @see RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR
207 * @see RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT
211 * Matches traffic originating from (ingress) or going to (egress) a
212 * given virtual function of the current device.
214 * See struct rte_flow_item_vf.
216 RTE_FLOW_ITEM_TYPE_VF,
220 * @see RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR
221 * @see RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT
225 * Matches traffic originating from (ingress) or going to (egress) a
226 * physical port of the underlying device.
228 * See struct rte_flow_item_phy_port.
230 RTE_FLOW_ITEM_TYPE_PHY_PORT,
234 * @see RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR
235 * @see RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT
239 * Matches traffic originating from (ingress) or going to (egress) a
240 * given DPDK port ID.
242 * See struct rte_flow_item_port_id.
244 RTE_FLOW_ITEM_TYPE_PORT_ID,
247 * Matches a byte string of a given length at a given offset.
249 * See struct rte_flow_item_raw.
251 RTE_FLOW_ITEM_TYPE_RAW,
254 * Matches an Ethernet header.
256 * See struct rte_flow_item_eth.
258 RTE_FLOW_ITEM_TYPE_ETH,
261 * Matches an 802.1Q/ad VLAN tag.
263 * See struct rte_flow_item_vlan.
265 RTE_FLOW_ITEM_TYPE_VLAN,
268 * Matches an IPv4 header.
270 * See struct rte_flow_item_ipv4.
272 RTE_FLOW_ITEM_TYPE_IPV4,
275 * Matches an IPv6 header.
277 * See struct rte_flow_item_ipv6.
279 RTE_FLOW_ITEM_TYPE_IPV6,
282 * Matches an ICMP header.
284 * See struct rte_flow_item_icmp.
286 RTE_FLOW_ITEM_TYPE_ICMP,
289 * Matches a UDP header.
291 * See struct rte_flow_item_udp.
293 RTE_FLOW_ITEM_TYPE_UDP,
296 * Matches a TCP header.
298 * See struct rte_flow_item_tcp.
300 RTE_FLOW_ITEM_TYPE_TCP,
303 * Matches a SCTP header.
305 * See struct rte_flow_item_sctp.
307 RTE_FLOW_ITEM_TYPE_SCTP,
310 * Matches a VXLAN header.
312 * See struct rte_flow_item_vxlan.
314 RTE_FLOW_ITEM_TYPE_VXLAN,
317 * Matches a E_TAG header.
319 * See struct rte_flow_item_e_tag.
321 RTE_FLOW_ITEM_TYPE_E_TAG,
324 * Matches a NVGRE header.
326 * See struct rte_flow_item_nvgre.
328 RTE_FLOW_ITEM_TYPE_NVGRE,
331 * Matches a MPLS header.
333 * See struct rte_flow_item_mpls.
335 RTE_FLOW_ITEM_TYPE_MPLS,
338 * Matches a GRE header.
340 * See struct rte_flow_item_gre.
342 RTE_FLOW_ITEM_TYPE_GRE,
347 * Fuzzy pattern match, expect faster than default.
349 * This is for device that support fuzzy matching option.
350 * Usually a fuzzy matching is fast but the cost is accuracy.
352 * See struct rte_flow_item_fuzzy.
354 RTE_FLOW_ITEM_TYPE_FUZZY,
357 * Matches a GTP header.
359 * Configure flow for GTP packets.
361 * See struct rte_flow_item_gtp.
363 RTE_FLOW_ITEM_TYPE_GTP,
366 * Matches a GTP header.
368 * Configure flow for GTP-C packets.
370 * See struct rte_flow_item_gtp.
372 RTE_FLOW_ITEM_TYPE_GTPC,
375 * Matches a GTP header.
377 * Configure flow for GTP-U packets.
379 * See struct rte_flow_item_gtp.
381 RTE_FLOW_ITEM_TYPE_GTPU,
384 * Matches a ESP header.
386 * See struct rte_flow_item_esp.
388 RTE_FLOW_ITEM_TYPE_ESP,
391 * Matches a GENEVE header.
393 * See struct rte_flow_item_geneve.
395 RTE_FLOW_ITEM_TYPE_GENEVE,
398 * Matches a VXLAN-GPE header.
400 * See struct rte_flow_item_vxlan_gpe.
402 RTE_FLOW_ITEM_TYPE_VXLAN_GPE,
405 * Matches an ARP header for Ethernet/IPv4.
407 * See struct rte_flow_item_arp_eth_ipv4.
409 RTE_FLOW_ITEM_TYPE_ARP_ETH_IPV4,
412 * Matches the presence of any IPv6 extension header.
414 * See struct rte_flow_item_ipv6_ext.
416 RTE_FLOW_ITEM_TYPE_IPV6_EXT,
419 * Matches any ICMPv6 header.
421 * See struct rte_flow_item_icmp6.
423 RTE_FLOW_ITEM_TYPE_ICMP6,
426 * Matches an ICMPv6 neighbor discovery solicitation.
428 * See struct rte_flow_item_icmp6_nd_ns.
430 RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS,
433 * Matches an ICMPv6 neighbor discovery advertisement.
435 * See struct rte_flow_item_icmp6_nd_na.
437 RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA,
440 * Matches the presence of any ICMPv6 neighbor discovery option.
442 * See struct rte_flow_item_icmp6_nd_opt.
444 RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT,
447 * Matches an ICMPv6 neighbor discovery source Ethernet link-layer
450 * See struct rte_flow_item_icmp6_nd_opt_sla_eth.
452 RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_SLA_ETH,
455 * Matches an ICMPv6 neighbor discovery target Ethernet link-layer
458 * See struct rte_flow_item_icmp6_nd_opt_tla_eth.
460 RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_TLA_ETH,
463 * Matches specified mark field.
465 * See struct rte_flow_item_mark.
467 RTE_FLOW_ITEM_TYPE_MARK,
472 * Matches a metadata value.
474 * See struct rte_flow_item_meta.
476 RTE_FLOW_ITEM_TYPE_META,
479 * Matches a GRE optional key field.
481 * The value should a big-endian 32bit integer.
483 * When this item present the K bit is implicitly matched as "1"
484 * in the default mask.
487 * @code rte_be32_t * @endcode
489 RTE_FLOW_ITEM_TYPE_GRE_KEY,
492 * Matches a GTP extension header: PDU session container.
494 * Configure flow for GTP packets with extension header type 0x85.
496 * See struct rte_flow_item_gtp_psc.
498 RTE_FLOW_ITEM_TYPE_GTP_PSC,
501 * Matches a PPPoE header.
503 * Configure flow for PPPoE session packets.
505 * See struct rte_flow_item_pppoe.
507 RTE_FLOW_ITEM_TYPE_PPPOES,
510 * Matches a PPPoE header.
512 * Configure flow for PPPoE discovery packets.
514 * See struct rte_flow_item_pppoe.
516 RTE_FLOW_ITEM_TYPE_PPPOED,
519 * Matches a PPPoE optional proto_id field.
521 * It only applies to PPPoE session packets.
523 * See struct rte_flow_item_pppoe_proto_id.
525 RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID,
528 * Matches Network service header (NSH).
529 * See struct rte_flow_item_nsh.
532 RTE_FLOW_ITEM_TYPE_NSH,
535 * Matches Internet Group Management Protocol (IGMP).
536 * See struct rte_flow_item_igmp.
539 RTE_FLOW_ITEM_TYPE_IGMP,
542 * Matches IP Authentication Header (AH).
543 * See struct rte_flow_item_ah.
546 RTE_FLOW_ITEM_TYPE_AH,
549 * Matches a HIGIG header.
550 * see struct rte_flow_item_higig2_hdr.
552 RTE_FLOW_ITEM_TYPE_HIGIG2,
557 * Matches a tag value.
559 * See struct rte_flow_item_tag.
561 RTE_FLOW_ITEM_TYPE_TAG,
564 * Matches a L2TPv3 over IP header.
566 * Configure flow for L2TPv3 over IP packets.
568 * See struct rte_flow_item_l2tpv3oip.
570 RTE_FLOW_ITEM_TYPE_L2TPV3OIP,
573 * Matches PFCP Header.
574 * See struct rte_flow_item_pfcp.
577 RTE_FLOW_ITEM_TYPE_PFCP,
580 * Matches eCPRI Header.
582 * Configure flow for eCPRI over ETH or UDP packets.
584 * See struct rte_flow_item_ecpri.
586 RTE_FLOW_ITEM_TYPE_ECPRI,
589 * Matches the presence of IPv6 fragment extension header.
591 * See struct rte_flow_item_ipv6_frag_ext.
593 RTE_FLOW_ITEM_TYPE_IPV6_FRAG_EXT,
596 * Matches Geneve Variable Length Option
598 * See struct rte_flow_item_geneve_opt
600 RTE_FLOW_ITEM_TYPE_GENEVE_OPT,
605 * Matches on packet integrity.
606 * For some devices application needs to enable integration checks in HW
607 * before using this item.
609 * @see struct rte_flow_item_integrity.
611 RTE_FLOW_ITEM_TYPE_INTEGRITY,
616 * Matches conntrack state.
618 * @see struct rte_flow_item_conntrack.
620 RTE_FLOW_ITEM_TYPE_CONNTRACK,
625 * Matches traffic entering the embedded switch from the given ethdev.
627 * @see struct rte_flow_item_ethdev
629 RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR,
634 * Matches traffic entering the embedded switch from
635 * the entity represented by the given ethdev.
637 * @see struct rte_flow_item_ethdev
639 RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT,
642 * Matches a configured set of fields at runtime calculated offsets
643 * over the generic network header with variable length and
646 * @see struct rte_flow_item_flex.
648 RTE_FLOW_ITEM_TYPE_FLEX,
651 * Matches L2TPv2 Header.
653 * See struct rte_flow_item_l2tpv2.
655 RTE_FLOW_ITEM_TYPE_L2TPV2,
658 * Matches PPP Header.
660 * See struct rte_flow_item_ppp.
662 RTE_FLOW_ITEM_TYPE_PPP,
667 * RTE_FLOW_ITEM_TYPE_HIGIG2
668 * Matches higig2 header
671 struct rte_flow_item_higig2_hdr {
672 struct rte_higig2_hdr hdr;
675 /** Default mask for RTE_FLOW_ITEM_TYPE_HIGIG2. */
677 static const struct rte_flow_item_higig2_hdr rte_flow_item_higig2_hdr_mask = {
680 .classification = 0xffff,
688 * RTE_FLOW_ITEM_TYPE_ANY
690 * Matches any protocol in place of the current layer, a single ANY may also
691 * stand for several protocol layers.
693 * This is usually specified as the first pattern item when looking for a
694 * protocol anywhere in a packet.
696 * A zeroed mask stands for any number of layers.
698 struct rte_flow_item_any {
699 uint32_t num; /**< Number of layers covered. */
702 /** Default mask for RTE_FLOW_ITEM_TYPE_ANY. */
704 static const struct rte_flow_item_any rte_flow_item_any_mask = {
711 * @see RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR
712 * @see RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT
714 * RTE_FLOW_ITEM_TYPE_VF
716 * Matches traffic originating from (ingress) or going to (egress) a given
717 * virtual function of the current device.
719 * If supported, should work even if the virtual function is not managed by
720 * the application and thus not associated with a DPDK port ID.
722 * Note this pattern item does not match VF representors traffic which, as
723 * separate entities, should be addressed through their own DPDK port IDs.
725 * - Can be specified multiple times to match traffic addressed to several
727 * - Can be combined with a PF item to match both PF and VF traffic.
729 * A zeroed mask can be used to match any VF ID.
731 struct rte_flow_item_vf {
732 uint32_t id; /**< VF ID. */
735 /** Default mask for RTE_FLOW_ITEM_TYPE_VF. */
737 static const struct rte_flow_item_vf rte_flow_item_vf_mask = {
744 * @see RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR
745 * @see RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT
747 * RTE_FLOW_ITEM_TYPE_PHY_PORT
749 * Matches traffic originating from (ingress) or going to (egress) a
750 * physical port of the underlying device.
752 * The first PHY_PORT item overrides the physical port normally associated
753 * with the specified DPDK input port (port_id). This item can be provided
754 * several times to match additional physical ports.
756 * Note that physical ports are not necessarily tied to DPDK input ports
757 * (port_id) when those are not under DPDK control. Possible values are
758 * specific to each device, they are not necessarily indexed from zero and
759 * may not be contiguous.
761 * As a device property, the list of allowed values as well as the value
762 * associated with a port_id should be retrieved by other means.
764 * A zeroed mask can be used to match any port index.
766 struct rte_flow_item_phy_port {
767 uint32_t index; /**< Physical port index. */
770 /** Default mask for RTE_FLOW_ITEM_TYPE_PHY_PORT. */
772 static const struct rte_flow_item_phy_port rte_flow_item_phy_port_mask = {
779 * @see RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR
780 * @see RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT
782 * RTE_FLOW_ITEM_TYPE_PORT_ID
784 * Matches traffic originating from (ingress) or going to (egress) a given
787 * Normally only supported if the port ID in question is known by the
788 * underlying PMD and related to the device the flow rule is created
791 * This must not be confused with @p PHY_PORT which refers to the physical
792 * port of a device, whereas @p PORT_ID refers to a struct rte_eth_dev
793 * object on the application side (also known as "port representor"
794 * depending on the kind of underlying device).
796 struct rte_flow_item_port_id {
797 uint32_t id; /**< DPDK port ID. */
800 /** Default mask for RTE_FLOW_ITEM_TYPE_PORT_ID. */
802 static const struct rte_flow_item_port_id rte_flow_item_port_id_mask = {
808 * RTE_FLOW_ITEM_TYPE_RAW
810 * Matches a byte string of a given length at a given offset.
812 * Offset is either absolute (using the start of the packet) or relative to
813 * the end of the previous matched item in the stack, in which case negative
814 * values are allowed.
816 * If search is enabled, offset is used as the starting point. The search
817 * area can be delimited by setting limit to a nonzero value, which is the
818 * maximum number of bytes after offset where the pattern may start.
820 * Matching a zero-length pattern is allowed, doing so resets the relative
821 * offset for subsequent items.
823 * This type does not support ranges (struct rte_flow_item.last).
825 struct rte_flow_item_raw {
826 uint32_t relative:1; /**< Look for pattern after the previous item. */
827 uint32_t search:1; /**< Search pattern from offset (see also limit). */
828 uint32_t reserved:30; /**< Reserved, must be set to zero. */
829 int32_t offset; /**< Absolute or relative offset for pattern. */
830 uint16_t limit; /**< Search area limit for start of pattern. */
831 uint16_t length; /**< Pattern length. */
832 const uint8_t *pattern; /**< Byte string to look for. */
835 /** Default mask for RTE_FLOW_ITEM_TYPE_RAW. */
837 static const struct rte_flow_item_raw rte_flow_item_raw_mask = {
840 .reserved = 0x3fffffff,
841 .offset = 0xffffffff,
849 * RTE_FLOW_ITEM_TYPE_ETH
851 * Matches an Ethernet header.
853 * Inside @p hdr field, the sub-field @p ether_type stands either for EtherType
854 * or TPID, depending on whether the item is followed by a VLAN item or not. If
855 * two VLAN items follow, the sub-field refers to the outer one, which, in turn,
856 * contains the inner TPID in the similar header field. The innermost VLAN item
857 * contains a layer-3 EtherType. All of that follows the order seen on the wire.
859 * If the field in question contains a TPID value, only tagged packets with the
860 * specified TPID will match the pattern. Alternatively, it's possible to match
861 * any type of tagged packets by means of the field @p has_vlan rather than use
862 * the EtherType/TPID field. Also, it's possible to leave the two fields unused.
863 * If this is the case, both tagged and untagged packets will match the pattern.
866 struct rte_flow_item_eth {
870 * These fields are retained for compatibility.
871 * Please switch to the new header field below.
873 struct rte_ether_addr dst; /**< Destination MAC. */
874 struct rte_ether_addr src; /**< Source MAC. */
875 rte_be16_t type; /**< EtherType or TPID. */
877 struct rte_ether_hdr hdr;
879 uint32_t has_vlan:1; /**< Packet header contains at least one VLAN. */
880 uint32_t reserved:31; /**< Reserved, must be zero. */
883 /** Default mask for RTE_FLOW_ITEM_TYPE_ETH. */
885 static const struct rte_flow_item_eth rte_flow_item_eth_mask = {
886 .hdr.dst_addr.addr_bytes = "\xff\xff\xff\xff\xff\xff",
887 .hdr.src_addr.addr_bytes = "\xff\xff\xff\xff\xff\xff",
888 .hdr.ether_type = RTE_BE16(0x0000),
893 * RTE_FLOW_ITEM_TYPE_VLAN
895 * Matches an 802.1Q/ad VLAN tag.
897 * The corresponding standard outer EtherType (TPID) values are
898 * RTE_ETHER_TYPE_VLAN or RTE_ETHER_TYPE_QINQ. It can be overridden by
899 * the preceding pattern item.
900 * If a @p VLAN item is present in the pattern, then only tagged packets will
902 * The field @p has_more_vlan can be used to match any type of tagged packets,
903 * instead of using the @p eth_proto field of @p hdr.
904 * If the @p eth_proto of @p hdr and @p has_more_vlan fields are not specified,
905 * then any tagged packets will match the pattern.
908 struct rte_flow_item_vlan {
912 * These fields are retained for compatibility.
913 * Please switch to the new header field below.
915 rte_be16_t tci; /**< Tag control information. */
916 rte_be16_t inner_type; /**< Inner EtherType or TPID. */
918 struct rte_vlan_hdr hdr;
920 /** Packet header contains at least one more VLAN, after this VLAN. */
921 uint32_t has_more_vlan:1;
922 uint32_t reserved:31; /**< Reserved, must be zero. */
925 /** Default mask for RTE_FLOW_ITEM_TYPE_VLAN. */
927 static const struct rte_flow_item_vlan rte_flow_item_vlan_mask = {
928 .hdr.vlan_tci = RTE_BE16(0x0fff),
929 .hdr.eth_proto = RTE_BE16(0x0000),
934 * RTE_FLOW_ITEM_TYPE_IPV4
936 * Matches an IPv4 header.
938 * Note: IPv4 options are handled by dedicated pattern items.
940 struct rte_flow_item_ipv4 {
941 struct rte_ipv4_hdr hdr; /**< IPv4 header definition. */
944 /** Default mask for RTE_FLOW_ITEM_TYPE_IPV4. */
946 static const struct rte_flow_item_ipv4 rte_flow_item_ipv4_mask = {
948 .src_addr = RTE_BE32(0xffffffff),
949 .dst_addr = RTE_BE32(0xffffffff),
955 * RTE_FLOW_ITEM_TYPE_IPV6.
957 * Matches an IPv6 header.
959 * Dedicated flags indicate if header contains specific extension headers.
961 struct rte_flow_item_ipv6 {
962 struct rte_ipv6_hdr hdr; /**< IPv6 header definition. */
963 /** Header contains Hop-by-Hop Options extension header. */
964 uint32_t has_hop_ext:1;
965 /** Header contains Routing extension header. */
966 uint32_t has_route_ext:1;
967 /** Header contains Fragment extension header. */
968 uint32_t has_frag_ext:1;
969 /** Header contains Authentication extension header. */
970 uint32_t has_auth_ext:1;
971 /** Header contains Encapsulation Security Payload extension header. */
972 uint32_t has_esp_ext:1;
973 /** Header contains Destination Options extension header. */
974 uint32_t has_dest_ext:1;
975 /** Header contains Mobility extension header. */
976 uint32_t has_mobil_ext:1;
977 /** Header contains Host Identity Protocol extension header. */
978 uint32_t has_hip_ext:1;
979 /** Header contains Shim6 Protocol extension header. */
980 uint32_t has_shim6_ext:1;
981 /** Reserved for future extension headers, must be zero. */
982 uint32_t reserved:23;
985 /** Default mask for RTE_FLOW_ITEM_TYPE_IPV6. */
987 static const struct rte_flow_item_ipv6 rte_flow_item_ipv6_mask = {
990 "\xff\xff\xff\xff\xff\xff\xff\xff"
991 "\xff\xff\xff\xff\xff\xff\xff\xff",
993 "\xff\xff\xff\xff\xff\xff\xff\xff"
994 "\xff\xff\xff\xff\xff\xff\xff\xff",
1000 * RTE_FLOW_ITEM_TYPE_ICMP.
1002 * Matches an ICMP header.
1004 struct rte_flow_item_icmp {
1005 struct rte_icmp_hdr hdr; /**< ICMP header definition. */
1008 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP. */
1010 static const struct rte_flow_item_icmp rte_flow_item_icmp_mask = {
1019 * RTE_FLOW_ITEM_TYPE_UDP.
1021 * Matches a UDP header.
1023 struct rte_flow_item_udp {
1024 struct rte_udp_hdr hdr; /**< UDP header definition. */
1027 /** Default mask for RTE_FLOW_ITEM_TYPE_UDP. */
1029 static const struct rte_flow_item_udp rte_flow_item_udp_mask = {
1031 .src_port = RTE_BE16(0xffff),
1032 .dst_port = RTE_BE16(0xffff),
1038 * RTE_FLOW_ITEM_TYPE_TCP.
1040 * Matches a TCP header.
1042 struct rte_flow_item_tcp {
1043 struct rte_tcp_hdr hdr; /**< TCP header definition. */
1046 /** Default mask for RTE_FLOW_ITEM_TYPE_TCP. */
1048 static const struct rte_flow_item_tcp rte_flow_item_tcp_mask = {
1050 .src_port = RTE_BE16(0xffff),
1051 .dst_port = RTE_BE16(0xffff),
1057 * RTE_FLOW_ITEM_TYPE_SCTP.
1059 * Matches a SCTP header.
1061 struct rte_flow_item_sctp {
1062 struct rte_sctp_hdr hdr; /**< SCTP header definition. */
1065 /** Default mask for RTE_FLOW_ITEM_TYPE_SCTP. */
1067 static const struct rte_flow_item_sctp rte_flow_item_sctp_mask = {
1069 .src_port = RTE_BE16(0xffff),
1070 .dst_port = RTE_BE16(0xffff),
1076 * RTE_FLOW_ITEM_TYPE_VXLAN.
1078 * Matches a VXLAN header (RFC 7348).
1081 struct rte_flow_item_vxlan {
1085 * These fields are retained for compatibility.
1086 * Please switch to the new header field below.
1088 uint8_t flags; /**< Normally 0x08 (I flag). */
1089 uint8_t rsvd0[3]; /**< Reserved, normally 0x000000. */
1090 uint8_t vni[3]; /**< VXLAN identifier. */
1091 uint8_t rsvd1; /**< Reserved, normally 0x00. */
1093 struct rte_vxlan_hdr hdr;
1097 /** Default mask for RTE_FLOW_ITEM_TYPE_VXLAN. */
1099 static const struct rte_flow_item_vxlan rte_flow_item_vxlan_mask = {
1100 .hdr.vx_vni = RTE_BE32(0xffffff00), /* (0xffffff << 8) */
1105 * RTE_FLOW_ITEM_TYPE_E_TAG.
1107 * Matches a E-tag header.
1109 * The corresponding standard outer EtherType (TPID) value is
1110 * RTE_ETHER_TYPE_ETAG. It can be overridden by the preceding pattern item.
1112 struct rte_flow_item_e_tag {
1114 * E-Tag control information (E-TCI).
1115 * E-PCP (3b), E-DEI (1b), ingress E-CID base (12b).
1117 rte_be16_t epcp_edei_in_ecid_b;
1118 /** Reserved (2b), GRP (2b), E-CID base (12b). */
1119 rte_be16_t rsvd_grp_ecid_b;
1120 uint8_t in_ecid_e; /**< Ingress E-CID ext. */
1121 uint8_t ecid_e; /**< E-CID ext. */
1122 rte_be16_t inner_type; /**< Inner EtherType or TPID. */
1125 /** Default mask for RTE_FLOW_ITEM_TYPE_E_TAG. */
1127 static const struct rte_flow_item_e_tag rte_flow_item_e_tag_mask = {
1128 .rsvd_grp_ecid_b = RTE_BE16(0x3fff),
1133 * RTE_FLOW_ITEM_TYPE_NVGRE.
1135 * Matches a NVGRE header.
1137 struct rte_flow_item_nvgre {
1139 * Checksum (1b), undefined (1b), key bit (1b), sequence number (1b),
1140 * reserved 0 (9b), version (3b).
1142 * c_k_s_rsvd0_ver must have value 0x2000 according to RFC 7637.
1144 rte_be16_t c_k_s_rsvd0_ver;
1145 rte_be16_t protocol; /**< Protocol type (0x6558). */
1146 uint8_t tni[3]; /**< Virtual subnet ID. */
1147 uint8_t flow_id; /**< Flow ID. */
1150 /** Default mask for RTE_FLOW_ITEM_TYPE_NVGRE. */
1152 static const struct rte_flow_item_nvgre rte_flow_item_nvgre_mask = {
1153 .tni = "\xff\xff\xff",
1158 * RTE_FLOW_ITEM_TYPE_MPLS.
1160 * Matches a MPLS header.
1162 struct rte_flow_item_mpls {
1164 * Label (20b), TC (3b), Bottom of Stack (1b).
1166 uint8_t label_tc_s[3];
1167 uint8_t ttl; /** Time-to-Live. */
1170 /** Default mask for RTE_FLOW_ITEM_TYPE_MPLS. */
1172 static const struct rte_flow_item_mpls rte_flow_item_mpls_mask = {
1173 .label_tc_s = "\xff\xff\xf0",
1178 * RTE_FLOW_ITEM_TYPE_GRE.
1180 * Matches a GRE header.
1182 struct rte_flow_item_gre {
1184 * Checksum (1b), reserved 0 (12b), version (3b).
1185 * Refer to RFC 2784.
1187 rte_be16_t c_rsvd0_ver;
1188 rte_be16_t protocol; /**< Protocol type. */
1191 /** Default mask for RTE_FLOW_ITEM_TYPE_GRE. */
1193 static const struct rte_flow_item_gre rte_flow_item_gre_mask = {
1194 .protocol = RTE_BE16(0xffff),
1199 * RTE_FLOW_ITEM_TYPE_FUZZY
1201 * Fuzzy pattern match, expect faster than default.
1203 * This is for device that support fuzzy match option.
1204 * Usually a fuzzy match is fast but the cost is accuracy.
1205 * i.e. Signature Match only match pattern's hash value, but it is
1206 * possible two different patterns have the same hash value.
1208 * Matching accuracy level can be configure by threshold.
1209 * Driver can divide the range of threshold and map to different
1210 * accuracy levels that device support.
1212 * Threshold 0 means perfect match (no fuzziness), while threshold
1213 * 0xffffffff means fuzziest match.
1215 struct rte_flow_item_fuzzy {
1216 uint32_t thresh; /**< Accuracy threshold. */
1219 /** Default mask for RTE_FLOW_ITEM_TYPE_FUZZY. */
1221 static const struct rte_flow_item_fuzzy rte_flow_item_fuzzy_mask = {
1222 .thresh = 0xffffffff,
1227 * RTE_FLOW_ITEM_TYPE_GTP.
1229 * Matches a GTPv1 header.
1231 struct rte_flow_item_gtp {
1233 * Version (3b), protocol type (1b), reserved (1b),
1234 * Extension header flag (1b),
1235 * Sequence number flag (1b),
1236 * N-PDU number flag (1b).
1238 uint8_t v_pt_rsv_flags;
1239 uint8_t msg_type; /**< Message type. */
1240 rte_be16_t msg_len; /**< Message length. */
1241 rte_be32_t teid; /**< Tunnel endpoint identifier. */
1244 /** Default mask for RTE_FLOW_ITEM_TYPE_GTP. */
1246 static const struct rte_flow_item_gtp rte_flow_item_gtp_mask = {
1247 .teid = RTE_BE32(0xffffffff),
1252 * RTE_FLOW_ITEM_TYPE_ESP
1254 * Matches an ESP header.
1256 struct rte_flow_item_esp {
1257 struct rte_esp_hdr hdr; /**< ESP header definition. */
1260 /** Default mask for RTE_FLOW_ITEM_TYPE_ESP. */
1262 static const struct rte_flow_item_esp rte_flow_item_esp_mask = {
1264 .spi = RTE_BE32(0xffffffff),
1270 * RTE_FLOW_ITEM_TYPE_GENEVE.
1272 * Matches a GENEVE header.
1274 struct rte_flow_item_geneve {
1276 * Version (2b), length of the options fields (6b), OAM packet (1b),
1277 * critical options present (1b), reserved 0 (6b).
1279 rte_be16_t ver_opt_len_o_c_rsvd0;
1280 rte_be16_t protocol; /**< Protocol type. */
1281 uint8_t vni[3]; /**< Virtual Network Identifier. */
1282 uint8_t rsvd1; /**< Reserved, normally 0x00. */
1285 /** Default mask for RTE_FLOW_ITEM_TYPE_GENEVE. */
1287 static const struct rte_flow_item_geneve rte_flow_item_geneve_mask = {
1288 .vni = "\xff\xff\xff",
1293 * RTE_FLOW_ITEM_TYPE_VXLAN_GPE (draft-ietf-nvo3-vxlan-gpe-05).
1295 * Matches a VXLAN-GPE header.
1297 struct rte_flow_item_vxlan_gpe {
1298 uint8_t flags; /**< Normally 0x0c (I and P flags). */
1299 uint8_t rsvd0[2]; /**< Reserved, normally 0x0000. */
1300 uint8_t protocol; /**< Protocol type. */
1301 uint8_t vni[3]; /**< VXLAN identifier. */
1302 uint8_t rsvd1; /**< Reserved, normally 0x00. */
1305 /** Default mask for RTE_FLOW_ITEM_TYPE_VXLAN_GPE. */
1307 static const struct rte_flow_item_vxlan_gpe rte_flow_item_vxlan_gpe_mask = {
1308 .vni = "\xff\xff\xff",
1313 * RTE_FLOW_ITEM_TYPE_ARP_ETH_IPV4
1315 * Matches an ARP header for Ethernet/IPv4.
1317 struct rte_flow_item_arp_eth_ipv4 {
1318 rte_be16_t hrd; /**< Hardware type, normally 1. */
1319 rte_be16_t pro; /**< Protocol type, normally 0x0800. */
1320 uint8_t hln; /**< Hardware address length, normally 6. */
1321 uint8_t pln; /**< Protocol address length, normally 4. */
1322 rte_be16_t op; /**< Opcode (1 for request, 2 for reply). */
1323 struct rte_ether_addr sha; /**< Sender hardware address. */
1324 rte_be32_t spa; /**< Sender IPv4 address. */
1325 struct rte_ether_addr tha; /**< Target hardware address. */
1326 rte_be32_t tpa; /**< Target IPv4 address. */
1329 /** Default mask for RTE_FLOW_ITEM_TYPE_ARP_ETH_IPV4. */
1331 static const struct rte_flow_item_arp_eth_ipv4
1332 rte_flow_item_arp_eth_ipv4_mask = {
1333 .sha.addr_bytes = "\xff\xff\xff\xff\xff\xff",
1334 .spa = RTE_BE32(0xffffffff),
1335 .tha.addr_bytes = "\xff\xff\xff\xff\xff\xff",
1336 .tpa = RTE_BE32(0xffffffff),
1341 * RTE_FLOW_ITEM_TYPE_IPV6_EXT
1343 * Matches the presence of any IPv6 extension header.
1345 * Normally preceded by any of:
1347 * - RTE_FLOW_ITEM_TYPE_IPV6
1348 * - RTE_FLOW_ITEM_TYPE_IPV6_EXT
1350 struct rte_flow_item_ipv6_ext {
1351 uint8_t next_hdr; /**< Next header. */
1354 /** Default mask for RTE_FLOW_ITEM_TYPE_IPV6_EXT. */
1357 struct rte_flow_item_ipv6_ext rte_flow_item_ipv6_ext_mask = {
1363 * RTE_FLOW_ITEM_TYPE_IPV6_FRAG_EXT
1365 * Matches the presence of IPv6 fragment extension header.
1367 * Preceded by any of:
1369 * - RTE_FLOW_ITEM_TYPE_IPV6
1370 * - RTE_FLOW_ITEM_TYPE_IPV6_EXT
1372 struct rte_flow_item_ipv6_frag_ext {
1373 struct rte_ipv6_fragment_ext hdr;
1377 * RTE_FLOW_ITEM_TYPE_ICMP6
1379 * Matches any ICMPv6 header.
1381 struct rte_flow_item_icmp6 {
1382 uint8_t type; /**< ICMPv6 type. */
1383 uint8_t code; /**< ICMPv6 code. */
1384 uint16_t checksum; /**< ICMPv6 checksum. */
1387 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6. */
1389 static const struct rte_flow_item_icmp6 rte_flow_item_icmp6_mask = {
1396 * RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS
1398 * Matches an ICMPv6 neighbor discovery solicitation.
1400 struct rte_flow_item_icmp6_nd_ns {
1401 uint8_t type; /**< ICMPv6 type, normally 135. */
1402 uint8_t code; /**< ICMPv6 code, normally 0. */
1403 rte_be16_t checksum; /**< ICMPv6 checksum. */
1404 rte_be32_t reserved; /**< Reserved, normally 0. */
1405 uint8_t target_addr[16]; /**< Target address. */
1408 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS. */
1411 struct rte_flow_item_icmp6_nd_ns rte_flow_item_icmp6_nd_ns_mask = {
1413 "\xff\xff\xff\xff\xff\xff\xff\xff"
1414 "\xff\xff\xff\xff\xff\xff\xff\xff",
1419 * RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA
1421 * Matches an ICMPv6 neighbor discovery advertisement.
1423 struct rte_flow_item_icmp6_nd_na {
1424 uint8_t type; /**< ICMPv6 type, normally 136. */
1425 uint8_t code; /**< ICMPv6 code, normally 0. */
1426 rte_be16_t checksum; /**< ICMPv6 checksum. */
1428 * Route flag (1b), solicited flag (1b), override flag (1b),
1431 rte_be32_t rso_reserved;
1432 uint8_t target_addr[16]; /**< Target address. */
1435 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA. */
1438 struct rte_flow_item_icmp6_nd_na rte_flow_item_icmp6_nd_na_mask = {
1440 "\xff\xff\xff\xff\xff\xff\xff\xff"
1441 "\xff\xff\xff\xff\xff\xff\xff\xff",
1446 * RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT
1448 * Matches the presence of any ICMPv6 neighbor discovery option.
1450 * Normally preceded by any of:
1452 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA
1453 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS
1454 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT
1456 struct rte_flow_item_icmp6_nd_opt {
1457 uint8_t type; /**< ND option type. */
1458 uint8_t length; /**< ND option length. */
1461 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT. */
1463 static const struct rte_flow_item_icmp6_nd_opt
1464 rte_flow_item_icmp6_nd_opt_mask = {
1470 * RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_SLA_ETH
1472 * Matches an ICMPv6 neighbor discovery source Ethernet link-layer address
1475 * Normally preceded by any of:
1477 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA
1478 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT
1480 struct rte_flow_item_icmp6_nd_opt_sla_eth {
1481 uint8_t type; /**< ND option type, normally 1. */
1482 uint8_t length; /**< ND option length, normally 1. */
1483 struct rte_ether_addr sla; /**< Source Ethernet LLA. */
1486 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_SLA_ETH. */
1488 static const struct rte_flow_item_icmp6_nd_opt_sla_eth
1489 rte_flow_item_icmp6_nd_opt_sla_eth_mask = {
1490 .sla.addr_bytes = "\xff\xff\xff\xff\xff\xff",
1495 * RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_TLA_ETH
1497 * Matches an ICMPv6 neighbor discovery target Ethernet link-layer address
1500 * Normally preceded by any of:
1502 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS
1503 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT
1505 struct rte_flow_item_icmp6_nd_opt_tla_eth {
1506 uint8_t type; /**< ND option type, normally 2. */
1507 uint8_t length; /**< ND option length, normally 1. */
1508 struct rte_ether_addr tla; /**< Target Ethernet LLA. */
1511 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_TLA_ETH. */
1513 static const struct rte_flow_item_icmp6_nd_opt_tla_eth
1514 rte_flow_item_icmp6_nd_opt_tla_eth_mask = {
1515 .tla.addr_bytes = "\xff\xff\xff\xff\xff\xff",
1520 * RTE_FLOW_ITEM_TYPE_META
1522 * Matches a specified metadata value. On egress, metadata can be set
1523 * either by mbuf dynamic metadata field with RTE_MBUF_DYNFLAG_TX_METADATA flag
1524 * or RTE_FLOW_ACTION_TYPE_SET_META. On ingress, RTE_FLOW_ACTION_TYPE_SET_META
1525 * sets metadata for a packet and the metadata will be reported via mbuf
1526 * metadata dynamic field with RTE_MBUF_DYNFLAG_RX_METADATA flag. The dynamic
1527 * mbuf field must be registered in advance by
1528 * rte_flow_dynf_metadata_register().
1530 struct rte_flow_item_meta {
1534 /** Default mask for RTE_FLOW_ITEM_TYPE_META. */
1536 static const struct rte_flow_item_meta rte_flow_item_meta_mask = {
1542 * RTE_FLOW_ITEM_TYPE_GTP_PSC.
1544 * Matches a GTP PDU extension header with type 0x85.
1546 struct rte_flow_item_gtp_psc {
1547 struct rte_gtp_psc_generic_hdr hdr; /**< gtp psc generic hdr. */
1550 /** Default mask for RTE_FLOW_ITEM_TYPE_GTP_PSC. */
1552 static const struct rte_flow_item_gtp_psc
1553 rte_flow_item_gtp_psc_mask = {
1559 * RTE_FLOW_ITEM_TYPE_PPPOE.
1561 * Matches a PPPoE header.
1563 struct rte_flow_item_pppoe {
1565 * Version (4b), type (4b).
1567 uint8_t version_type;
1568 uint8_t code; /**< Message type. */
1569 rte_be16_t session_id; /**< Session identifier. */
1570 rte_be16_t length; /**< Payload length. */
1574 * RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID.
1576 * Matches a PPPoE optional proto_id field.
1578 * It only applies to PPPoE session packets.
1580 * Normally preceded by any of:
1582 * - RTE_FLOW_ITEM_TYPE_PPPOE
1583 * - RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID
1585 struct rte_flow_item_pppoe_proto_id {
1586 rte_be16_t proto_id; /**< PPP protocol identifier. */
1589 /** Default mask for RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID. */
1591 static const struct rte_flow_item_pppoe_proto_id
1592 rte_flow_item_pppoe_proto_id_mask = {
1593 .proto_id = RTE_BE16(0xffff),
1599 * @b EXPERIMENTAL: this structure may change without prior notice
1601 * RTE_FLOW_ITEM_TYPE_TAG
1603 * Matches a specified tag value at the specified index.
1605 struct rte_flow_item_tag {
1610 /** Default mask for RTE_FLOW_ITEM_TYPE_TAG. */
1612 static const struct rte_flow_item_tag rte_flow_item_tag_mask = {
1619 * RTE_FLOW_ITEM_TYPE_L2TPV3OIP.
1621 * Matches a L2TPv3 over IP header.
1623 struct rte_flow_item_l2tpv3oip {
1624 rte_be32_t session_id; /**< Session ID. */
1627 /** Default mask for RTE_FLOW_ITEM_TYPE_L2TPV3OIP. */
1629 static const struct rte_flow_item_l2tpv3oip rte_flow_item_l2tpv3oip_mask = {
1630 .session_id = RTE_BE32(UINT32_MAX),
1637 * @b EXPERIMENTAL: this structure may change without prior notice
1639 * RTE_FLOW_ITEM_TYPE_MARK
1641 * Matches an arbitrary integer value which was set using the ``MARK`` action
1642 * in a previously matched rule.
1644 * This item can only be specified once as a match criteria as the ``MARK``
1645 * action can only be specified once in a flow action.
1647 * This value is arbitrary and application-defined. Maximum allowed value
1648 * depends on the underlying implementation.
1650 * Depending on the underlying implementation the MARK item may be supported on
1651 * the physical device, with virtual groups in the PMD or not at all.
1653 struct rte_flow_item_mark {
1654 uint32_t id; /**< Integer value to match against. */
1657 /** Default mask for RTE_FLOW_ITEM_TYPE_MARK. */
1659 static const struct rte_flow_item_mark rte_flow_item_mark_mask = {
1666 * @b EXPERIMENTAL: this structure may change without prior notice
1668 * RTE_FLOW_ITEM_TYPE_NSH
1670 * Match network service header (NSH), RFC 8300
1673 struct rte_flow_item_nsh {
1676 uint32_t reserved:1;
1679 uint32_t reserved1:4;
1681 uint32_t next_proto:8;
1686 /** Default mask for RTE_FLOW_ITEM_TYPE_NSH. */
1688 static const struct rte_flow_item_nsh rte_flow_item_nsh_mask = {
1698 * @b EXPERIMENTAL: this structure may change without prior notice
1700 * RTE_FLOW_ITEM_TYPE_IGMP
1702 * Match Internet Group Management Protocol (IGMP), RFC 2236
1705 struct rte_flow_item_igmp {
1707 uint32_t max_resp_time:8;
1708 uint32_t checksum:16;
1709 uint32_t group_addr;
1712 /** Default mask for RTE_FLOW_ITEM_TYPE_IGMP. */
1714 static const struct rte_flow_item_igmp rte_flow_item_igmp_mask = {
1715 .group_addr = 0xffffffff,
1721 * @b EXPERIMENTAL: this structure may change without prior notice
1723 * RTE_FLOW_ITEM_TYPE_AH
1725 * Match IP Authentication Header (AH), RFC 4302
1728 struct rte_flow_item_ah {
1729 uint32_t next_hdr:8;
1730 uint32_t payload_len:8;
1731 uint32_t reserved:16;
1736 /** Default mask for RTE_FLOW_ITEM_TYPE_AH. */
1738 static const struct rte_flow_item_ah rte_flow_item_ah_mask = {
1745 * @b EXPERIMENTAL: this structure may change without prior notice
1747 * RTE_FLOW_ITEM_TYPE_PFCP
1751 struct rte_flow_item_pfcp {
1758 /** Default mask for RTE_FLOW_ITEM_TYPE_PFCP. */
1760 static const struct rte_flow_item_pfcp rte_flow_item_pfcp_mask = {
1762 .seid = RTE_BE64(UINT64_C(0xffffffffffffffff)),
1768 * @b EXPERIMENTAL: this structure may change without prior notice
1770 * RTE_FLOW_ITEM_TYPE_ECPRI
1772 * Match eCPRI Header
1774 struct rte_flow_item_ecpri {
1775 struct rte_ecpri_combined_msg_hdr hdr;
1778 /** Default mask for RTE_FLOW_ITEM_TYPE_ECPRI. */
1780 static const struct rte_flow_item_ecpri rte_flow_item_ecpri_mask = {
1790 * RTE_FLOW_ITEM_TYPE_GENEVE_OPT
1792 * Matches a GENEVE Variable Length Option
1794 struct rte_flow_item_geneve_opt {
1795 rte_be16_t option_class;
1796 uint8_t option_type;
1801 /** Default mask for RTE_FLOW_ITEM_TYPE_GENEVE_OPT. */
1803 static const struct rte_flow_item_geneve_opt
1804 rte_flow_item_geneve_opt_mask = {
1805 .option_type = 0xff,
1811 * @b EXPERIMENTAL: this structure may change without prior notice
1813 * RTE_FLOW_ITEM_TYPE_INTEGRITY
1815 * Match on packet integrity check result.
1817 struct rte_flow_item_integrity {
1818 /** Tunnel encapsulation level the item should apply to.
1819 * @see rte_flow_action_rss
1826 /** The packet is valid after passing all HW checks. */
1827 uint64_t packet_ok:1;
1828 /** L2 layer is valid after passing all HW checks. */
1830 /** L3 layer is valid after passing all HW checks. */
1832 /** L4 layer is valid after passing all HW checks. */
1834 /** L2 layer CRC is valid. */
1835 uint64_t l2_crc_ok:1;
1836 /** IPv4 layer checksum is valid. */
1837 uint64_t ipv4_csum_ok:1;
1838 /** L4 layer checksum is valid. */
1839 uint64_t l4_csum_ok:1;
1840 /** L3 length is smaller than frame length. */
1841 uint64_t l3_len_ok:1;
1842 uint64_t reserved:56;
1849 static const struct rte_flow_item_integrity
1850 rte_flow_item_integrity_mask = {
1857 * The packet is valid after conntrack checking.
1859 #define RTE_FLOW_CONNTRACK_PKT_STATE_VALID RTE_BIT32(0)
1861 * The state of the connection is changed.
1863 #define RTE_FLOW_CONNTRACK_PKT_STATE_CHANGED RTE_BIT32(1)
1865 * Error is detected on this packet for this connection and
1866 * an invalid state is set.
1868 #define RTE_FLOW_CONNTRACK_PKT_STATE_INVALID RTE_BIT32(2)
1870 * The HW connection tracking module is disabled.
1871 * It can be due to application command or an invalid state.
1873 #define RTE_FLOW_CONNTRACK_PKT_STATE_DISABLED RTE_BIT32(3)
1875 * The packet contains some bad field(s) and cannot continue
1876 * with the conntrack module checking.
1878 #define RTE_FLOW_CONNTRACK_PKT_STATE_BAD RTE_BIT32(4)
1882 * @b EXPERIMENTAL: this structure may change without prior notice
1884 * RTE_FLOW_ITEM_TYPE_CONNTRACK
1886 * Matches the state of a packet after it passed the connection tracking
1887 * examination. The state is a bitmap of one RTE_FLOW_CONNTRACK_PKT_STATE*
1888 * or a reasonable combination of these bits.
1890 struct rte_flow_item_conntrack {
1894 /** Default mask for RTE_FLOW_ITEM_TYPE_CONNTRACK. */
1896 static const struct rte_flow_item_conntrack rte_flow_item_conntrack_mask = {
1897 .flags = 0xffffffff,
1903 * @b EXPERIMENTAL: this structure may change without prior notice
1905 * Provides an ethdev port ID for use with the following items:
1906 * RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR,
1907 * RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT.
1909 struct rte_flow_item_ethdev {
1910 uint16_t port_id; /**< ethdev port ID */
1913 /** Default mask for items based on struct rte_flow_item_ethdev */
1915 static const struct rte_flow_item_ethdev rte_flow_item_ethdev_mask = {
1922 * @b EXPERIMENTAL: this structure may change without prior notice
1924 * RTE_FLOW_ITEM_TYPE_L2TPV2
1926 * Matches L2TPv2 Header
1928 struct rte_flow_item_l2tpv2 {
1929 struct rte_l2tpv2_combined_msg_hdr hdr;
1932 /** Default mask for RTE_FLOW_ITEM_TYPE_L2TPV2. */
1934 static const struct rte_flow_item_l2tpv2 rte_flow_item_l2tpv2_mask = {
1936 * flags and version bit mask
1937 * 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0
1938 * T L x x S x O P x x x x V V V V
1942 .flags_version = RTE_BE16(0xcb0f),
1950 * @b EXPERIMENTAL: this structure may change without prior notice
1952 * RTE_FLOW_ITEM_TYPE_PPP
1954 * Matches PPP Header
1956 struct rte_flow_item_ppp {
1957 struct rte_ppp_hdr hdr;
1960 /** Default mask for RTE_FLOW_ITEM_TYPE_PPP. */
1962 static const struct rte_flow_item_ppp rte_flow_item_ppp_mask = {
1966 .proto_id = RTE_BE16(0xffff),
1972 * Matching pattern item definition.
1974 * A pattern is formed by stacking items starting from the lowest protocol
1975 * layer to match. This stacking restriction does not apply to meta items
1976 * which can be placed anywhere in the stack without affecting the meaning
1977 * of the resulting pattern.
1979 * Patterns are terminated by END items.
1981 * The spec field should be a valid pointer to a structure of the related
1982 * item type. It may remain unspecified (NULL) in many cases to request
1983 * broad (nonspecific) matching. In such cases, last and mask must also be
1986 * Optionally, last can point to a structure of the same type to define an
1987 * inclusive range. This is mostly supported by integer and address fields,
1988 * may cause errors otherwise. Fields that do not support ranges must be set
1989 * to 0 or to the same value as the corresponding fields in spec.
1991 * Only the fields defined to nonzero values in the default masks (see
1992 * rte_flow_item_{name}_mask constants) are considered relevant by
1993 * default. This can be overridden by providing a mask structure of the
1994 * same type with applicable bits set to one. It can also be used to
1995 * partially filter out specific fields (e.g. as an alternate mean to match
1996 * ranges of IP addresses).
1998 * Mask is a simple bit-mask applied before interpreting the contents of
1999 * spec and last, which may yield unexpected results if not used
2000 * carefully. For example, if for an IPv4 address field, spec provides
2001 * 10.1.2.3, last provides 10.3.4.5 and mask provides 255.255.0.0, the
2002 * effective range becomes 10.1.0.0 to 10.3.255.255.
2004 struct rte_flow_item {
2005 enum rte_flow_item_type type; /**< Item type. */
2006 const void *spec; /**< Pointer to item specification structure. */
2007 const void *last; /**< Defines an inclusive range (spec to last). */
2008 const void *mask; /**< Bit-mask applied to spec and last. */
2013 * @b EXPERIMENTAL: this structure may change without prior notice
2015 * RTE_FLOW_ITEM_TYPE_FLEX
2017 * Matches a specified set of fields within the network protocol
2018 * header. Each field is presented as set of bits with specified width, and
2019 * bit offset from the header beginning.
2021 * The pattern is concatenation of bit fields configured at item creation
2022 * by rte_flow_flex_item_create(). At configuration the fields are presented
2023 * by sample_data array.
2025 * This type does not support ranges (struct rte_flow_item.last).
2027 struct rte_flow_item_flex {
2028 struct rte_flow_item_flex_handle *handle; /**< Opaque item handle. */
2029 uint32_t length; /**< Pattern length in bytes. */
2030 const uint8_t *pattern; /**< Combined bitfields pattern to match. */
2033 * Field bit offset calculation mode.
2035 enum rte_flow_item_flex_field_mode {
2037 * Dummy field, used for byte boundary alignment in pattern.
2038 * Pattern mask and data are ignored in the match. All configuration
2039 * parameters besides field size are ignored.
2041 FIELD_MODE_DUMMY = 0,
2043 * Fixed offset field. The bit offset from header beginning
2044 * is permanent and defined by field_base parameter.
2048 * The field bit offset is extracted from other header field (indirect
2049 * offset field). The resulting field offset to match is calculated as:
2051 * field_base + (*offset_base & offset_mask) << offset_shift
2055 * The field bit offset is extracted from other header field (indirect
2056 * offset field), the latter is considered as bitmask containing some
2057 * number of one bits, the resulting field offset to match is
2060 * field_base + bitcount(*offset_base & offset_mask) << offset_shift
2066 * Flex item field tunnel mode
2068 enum rte_flow_item_flex_tunnel_mode {
2070 * The protocol header can be present in the packet only once.
2071 * No multiple flex item flow inclusions (for inner/outer) are allowed.
2072 * No any relations with tunnel protocols are imposed. The drivers
2073 * can optimize hardware resource usage to handle match on single flex
2074 * item of specific type.
2076 FLEX_TUNNEL_MODE_SINGLE = 0,
2078 * Flex item presents outer header only.
2080 FLEX_TUNNEL_MODE_OUTER,
2082 * Flex item presents inner header only.
2084 FLEX_TUNNEL_MODE_INNER,
2086 * Flex item presents either inner or outer header. The driver
2087 * handles as many multiple inners as hardware supports.
2089 FLEX_TUNNEL_MODE_MULTI,
2091 * Flex item presents tunnel protocol header.
2093 FLEX_TUNNEL_MODE_TUNNEL,
2099 * @b EXPERIMENTAL: this structure may change without prior notice
2102 struct rte_flow_item_flex_field {
2103 /** Defines how match field offset is calculated over the packet. */
2104 enum rte_flow_item_flex_field_mode field_mode;
2105 uint32_t field_size; /**< Field size in bits. */
2106 int32_t field_base; /**< Field offset in bits. */
2107 uint32_t offset_base; /**< Indirect offset field offset in bits. */
2108 uint32_t offset_mask; /**< Indirect offset field bit mask. */
2109 int32_t offset_shift; /**< Indirect offset multiply factor. */
2110 uint32_t field_id:16; /**< Device hint, for multiple items in flow. */
2111 uint32_t reserved:16; /**< Reserved field. */
2116 * @b EXPERIMENTAL: this structure may change without prior notice
2118 struct rte_flow_item_flex_link {
2120 * Preceding/following header. The item type must be always provided.
2121 * For preceding one item must specify the header value/mask to match
2122 * for the link be taken and start the flex item header parsing.
2124 struct rte_flow_item item;
2126 * Next field value to match to continue with one of the configured
2134 * @b EXPERIMENTAL: this structure may change without prior notice
2136 struct rte_flow_item_flex_conf {
2138 * Specifies the flex item and tunnel relations and tells the PMD
2139 * whether flex item can be used for inner, outer or both headers,
2140 * or whether flex item presents the tunnel protocol itself.
2142 enum rte_flow_item_flex_tunnel_mode tunnel;
2144 * The next header offset, it presents the network header size covered
2145 * by the flex item and can be obtained with all supported offset
2146 * calculating methods (fixed, dedicated field, bitmask, etc).
2148 struct rte_flow_item_flex_field next_header;
2150 * Specifies the next protocol field to match with link next protocol
2151 * values and continue packet parsing with matching link.
2153 struct rte_flow_item_flex_field next_protocol;
2155 * The fields will be sampled and presented for explicit match
2156 * with pattern in the rte_flow_flex_item. There can be multiple
2157 * fields descriptors, the number should be specified by nb_samples.
2159 struct rte_flow_item_flex_field *sample_data;
2160 /** Number of field descriptors in the sample_data array. */
2161 uint32_t nb_samples;
2163 * Input link defines the flex item relation with preceding
2164 * header. It specified the preceding item type and provides pattern
2165 * to match. The flex item will continue parsing and will provide the
2166 * data to flow match in case if there is the match with one of input
2169 struct rte_flow_item_flex_link *input_link;
2170 /** Number of link descriptors in the input link array. */
2173 * Output link defines the next protocol field value to match and
2174 * the following protocol header to continue packet parsing. Also
2175 * defines the tunnel-related behaviour.
2177 struct rte_flow_item_flex_link *output_link;
2178 /** Number of link descriptors in the output link array. */
2179 uint32_t nb_outputs;
2185 * Each possible action is represented by a type.
2186 * An action can have an associated configuration object.
2187 * Several actions combined in a list can be assigned
2188 * to a flow rule and are performed in order.
2190 * They fall in three categories:
2192 * - Actions that modify the fate of matching traffic, for instance by
2193 * dropping or assigning it a specific destination.
2195 * - Actions that modify matching traffic contents or its properties. This
2196 * includes adding/removing encapsulation, encryption, compression and
2199 * - Actions related to the flow rule itself, such as updating counters or
2200 * making it non-terminating.
2202 * Flow rules being terminating by default, not specifying any action of the
2203 * fate kind results in undefined behavior. This applies to both ingress and
2206 * PASSTHRU, when supported, makes a flow rule non-terminating.
2208 enum rte_flow_action_type {
2210 * End marker for action lists. Prevents further processing of
2211 * actions, thereby ending the list.
2213 * No associated configuration structure.
2215 RTE_FLOW_ACTION_TYPE_END,
2218 * Used as a placeholder for convenience. It is ignored and simply
2219 * discarded by PMDs.
2221 * No associated configuration structure.
2223 RTE_FLOW_ACTION_TYPE_VOID,
2226 * Leaves traffic up for additional processing by subsequent flow
2227 * rules; makes a flow rule non-terminating.
2229 * No associated configuration structure.
2231 RTE_FLOW_ACTION_TYPE_PASSTHRU,
2234 * RTE_FLOW_ACTION_TYPE_JUMP
2236 * Redirects packets to a group on the current device.
2238 * See struct rte_flow_action_jump.
2240 RTE_FLOW_ACTION_TYPE_JUMP,
2243 * Attaches an integer value to packets and sets RTE_MBUF_F_RX_FDIR and
2244 * RTE_MBUF_F_RX_FDIR_ID mbuf flags.
2246 * See struct rte_flow_action_mark.
2248 * One should negotiate mark delivery from the NIC to the PMD.
2249 * @see rte_eth_rx_metadata_negotiate()
2250 * @see RTE_ETH_RX_METADATA_USER_MARK
2252 RTE_FLOW_ACTION_TYPE_MARK,
2255 * Flags packets. Similar to MARK without a specific value; only
2256 * sets the RTE_MBUF_F_RX_FDIR mbuf flag.
2258 * No associated configuration structure.
2260 * One should negotiate flag delivery from the NIC to the PMD.
2261 * @see rte_eth_rx_metadata_negotiate()
2262 * @see RTE_ETH_RX_METADATA_USER_FLAG
2264 RTE_FLOW_ACTION_TYPE_FLAG,
2267 * Assigns packets to a given queue index.
2269 * See struct rte_flow_action_queue.
2271 RTE_FLOW_ACTION_TYPE_QUEUE,
2276 * PASSTHRU overrides this action if both are specified.
2278 * No associated configuration structure.
2280 RTE_FLOW_ACTION_TYPE_DROP,
2283 * Enables counters for this flow rule.
2285 * These counters can be retrieved and reset through rte_flow_query() or
2286 * rte_flow_action_handle_query() if the action provided via handle,
2287 * see struct rte_flow_query_count.
2289 * See struct rte_flow_action_count.
2291 RTE_FLOW_ACTION_TYPE_COUNT,
2294 * Similar to QUEUE, except RSS is additionally performed on packets
2295 * to spread them among several queues according to the provided
2298 * See struct rte_flow_action_rss.
2300 RTE_FLOW_ACTION_TYPE_RSS,
2304 * @see RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR
2305 * @see RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT
2307 * Directs matching traffic to the physical function (PF) of the
2310 * No associated configuration structure.
2312 RTE_FLOW_ACTION_TYPE_PF,
2316 * @see RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR
2317 * @see RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT
2319 * Directs matching traffic to a given virtual function of the
2322 * See struct rte_flow_action_vf.
2324 RTE_FLOW_ACTION_TYPE_VF,
2328 * @see RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR
2329 * @see RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT
2331 * Directs packets to a given physical port index of the underlying
2334 * See struct rte_flow_action_phy_port.
2336 RTE_FLOW_ACTION_TYPE_PHY_PORT,
2340 * @see RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR
2341 * @see RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT
2343 * Directs matching traffic to a given DPDK port ID.
2345 * See struct rte_flow_action_port_id.
2347 RTE_FLOW_ACTION_TYPE_PORT_ID,
2350 * Traffic metering and policing (MTR).
2352 * See struct rte_flow_action_meter.
2353 * See file rte_mtr.h for MTR object configuration.
2355 RTE_FLOW_ACTION_TYPE_METER,
2358 * Redirects packets to security engine of current device for security
2359 * processing as specified by security session.
2361 * See struct rte_flow_action_security.
2363 RTE_FLOW_ACTION_TYPE_SECURITY,
2366 * Implements OFPAT_SET_MPLS_TTL ("MPLS TTL") as defined by the
2367 * OpenFlow Switch Specification.
2369 * See struct rte_flow_action_of_set_mpls_ttl.
2371 RTE_FLOW_ACTION_TYPE_OF_SET_MPLS_TTL,
2374 * Implements OFPAT_DEC_MPLS_TTL ("decrement MPLS TTL") as defined
2375 * by the OpenFlow Switch Specification.
2377 * No associated configuration structure.
2379 RTE_FLOW_ACTION_TYPE_OF_DEC_MPLS_TTL,
2382 * Implements OFPAT_SET_NW_TTL ("IP TTL") as defined by the OpenFlow
2383 * Switch Specification.
2385 * See struct rte_flow_action_of_set_nw_ttl.
2387 RTE_FLOW_ACTION_TYPE_OF_SET_NW_TTL,
2390 * Implements OFPAT_DEC_NW_TTL ("decrement IP TTL") as defined by
2391 * the OpenFlow Switch Specification.
2393 * No associated configuration structure.
2395 RTE_FLOW_ACTION_TYPE_OF_DEC_NW_TTL,
2398 * Implements OFPAT_COPY_TTL_OUT ("copy TTL "outwards" -- from
2399 * next-to-outermost to outermost") as defined by the OpenFlow
2400 * Switch Specification.
2402 * No associated configuration structure.
2404 RTE_FLOW_ACTION_TYPE_OF_COPY_TTL_OUT,
2407 * Implements OFPAT_COPY_TTL_IN ("copy TTL "inwards" -- from
2408 * outermost to next-to-outermost") as defined by the OpenFlow
2409 * Switch Specification.
2411 * No associated configuration structure.
2413 RTE_FLOW_ACTION_TYPE_OF_COPY_TTL_IN,
2416 * Implements OFPAT_POP_VLAN ("pop the outer VLAN tag") as defined
2417 * by the OpenFlow Switch Specification.
2419 * No associated configuration structure.
2421 RTE_FLOW_ACTION_TYPE_OF_POP_VLAN,
2424 * Implements OFPAT_PUSH_VLAN ("push a new VLAN tag") as defined by
2425 * the OpenFlow Switch Specification.
2427 * See struct rte_flow_action_of_push_vlan.
2429 RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN,
2432 * Implements OFPAT_SET_VLAN_VID ("set the 802.1q VLAN ID") as
2433 * defined by the OpenFlow Switch Specification.
2435 * See struct rte_flow_action_of_set_vlan_vid.
2437 RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID,
2440 * Implements OFPAT_SET_LAN_PCP ("set the 802.1q priority") as
2441 * defined by the OpenFlow Switch Specification.
2443 * See struct rte_flow_action_of_set_vlan_pcp.
2445 RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP,
2448 * Implements OFPAT_POP_MPLS ("pop the outer MPLS tag") as defined
2449 * by the OpenFlow Switch Specification.
2451 * See struct rte_flow_action_of_pop_mpls.
2453 RTE_FLOW_ACTION_TYPE_OF_POP_MPLS,
2456 * Implements OFPAT_PUSH_MPLS ("push a new MPLS tag") as defined by
2457 * the OpenFlow Switch Specification.
2459 * See struct rte_flow_action_of_push_mpls.
2461 RTE_FLOW_ACTION_TYPE_OF_PUSH_MPLS,
2464 * Encapsulate flow in VXLAN tunnel as defined in
2465 * rte_flow_action_vxlan_encap action structure.
2467 * See struct rte_flow_action_vxlan_encap.
2469 RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP,
2472 * Decapsulate outer most VXLAN tunnel from matched flow.
2474 * If flow pattern does not define a valid VXLAN tunnel (as specified by
2475 * RFC7348) then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION
2478 RTE_FLOW_ACTION_TYPE_VXLAN_DECAP,
2481 * Encapsulate flow in NVGRE tunnel defined in the
2482 * rte_flow_action_nvgre_encap action structure.
2484 * See struct rte_flow_action_nvgre_encap.
2486 RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP,
2489 * Decapsulate outer most NVGRE tunnel from matched flow.
2491 * If flow pattern does not define a valid NVGRE tunnel (as specified by
2492 * RFC7637) then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION
2495 RTE_FLOW_ACTION_TYPE_NVGRE_DECAP,
2498 * Add outer header whose template is provided in its data buffer
2500 * See struct rte_flow_action_raw_encap.
2502 RTE_FLOW_ACTION_TYPE_RAW_ENCAP,
2505 * Remove outer header whose template is provided in its data buffer.
2507 * See struct rte_flow_action_raw_decap
2509 RTE_FLOW_ACTION_TYPE_RAW_DECAP,
2512 * Modify IPv4 source address in the outermost IPv4 header.
2514 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV4,
2515 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2517 * See struct rte_flow_action_set_ipv4.
2519 RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC,
2522 * Modify IPv4 destination address in the outermost IPv4 header.
2524 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV4,
2525 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2527 * See struct rte_flow_action_set_ipv4.
2529 RTE_FLOW_ACTION_TYPE_SET_IPV4_DST,
2532 * Modify IPv6 source address in the outermost IPv6 header.
2534 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV6,
2535 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2537 * See struct rte_flow_action_set_ipv6.
2539 RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC,
2542 * Modify IPv6 destination address in the outermost IPv6 header.
2544 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV6,
2545 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2547 * See struct rte_flow_action_set_ipv6.
2549 RTE_FLOW_ACTION_TYPE_SET_IPV6_DST,
2552 * Modify source port number in the outermost TCP/UDP header.
2554 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_TCP
2555 * or RTE_FLOW_ITEM_TYPE_UDP, then the PMD should return a
2556 * RTE_FLOW_ERROR_TYPE_ACTION error.
2558 * See struct rte_flow_action_set_tp.
2560 RTE_FLOW_ACTION_TYPE_SET_TP_SRC,
2563 * Modify destination port number in the outermost TCP/UDP header.
2565 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_TCP
2566 * or RTE_FLOW_ITEM_TYPE_UDP, then the PMD should return a
2567 * RTE_FLOW_ERROR_TYPE_ACTION error.
2569 * See struct rte_flow_action_set_tp.
2571 RTE_FLOW_ACTION_TYPE_SET_TP_DST,
2574 * Swap the source and destination MAC addresses in the outermost
2577 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_ETH,
2578 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2580 * No associated configuration structure.
2582 RTE_FLOW_ACTION_TYPE_MAC_SWAP,
2585 * Decrease TTL value directly
2587 * No associated configuration structure.
2589 RTE_FLOW_ACTION_TYPE_DEC_TTL,
2594 * See struct rte_flow_action_set_ttl
2596 RTE_FLOW_ACTION_TYPE_SET_TTL,
2599 * Set source MAC address from matched flow.
2601 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_ETH,
2602 * the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2604 * See struct rte_flow_action_set_mac.
2606 RTE_FLOW_ACTION_TYPE_SET_MAC_SRC,
2609 * Set destination MAC address from matched flow.
2611 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_ETH,
2612 * the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2614 * See struct rte_flow_action_set_mac.
2616 RTE_FLOW_ACTION_TYPE_SET_MAC_DST,
2619 * Increase sequence number in the outermost TCP header.
2621 * Action configuration specifies the value to increase
2622 * TCP sequence number as a big-endian 32 bit integer.
2625 * @code rte_be32_t * @endcode
2627 * Using this action on non-matching traffic will result in
2628 * undefined behavior.
2630 RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ,
2633 * Decrease sequence number in the outermost TCP header.
2635 * Action configuration specifies the value to decrease
2636 * TCP sequence number as a big-endian 32 bit integer.
2639 * @code rte_be32_t * @endcode
2641 * Using this action on non-matching traffic will result in
2642 * undefined behavior.
2644 RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ,
2647 * Increase acknowledgment number in the outermost TCP header.
2649 * Action configuration specifies the value to increase
2650 * TCP acknowledgment number as a big-endian 32 bit integer.
2653 * @code rte_be32_t * @endcode
2655 * Using this action on non-matching traffic will result in
2656 * undefined behavior.
2658 RTE_FLOW_ACTION_TYPE_INC_TCP_ACK,
2661 * Decrease acknowledgment number in the outermost TCP header.
2663 * Action configuration specifies the value to decrease
2664 * TCP acknowledgment number as a big-endian 32 bit integer.
2667 * @code rte_be32_t * @endcode
2669 * Using this action on non-matching traffic will result in
2670 * undefined behavior.
2672 RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK,
2677 * Tag is for internal flow usage only and
2678 * is not delivered to the application.
2680 * See struct rte_flow_action_set_tag.
2682 RTE_FLOW_ACTION_TYPE_SET_TAG,
2685 * Set metadata on ingress or egress path.
2687 * See struct rte_flow_action_set_meta.
2689 RTE_FLOW_ACTION_TYPE_SET_META,
2692 * Modify IPv4 DSCP in the outermost IP header.
2694 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV4,
2695 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2697 * See struct rte_flow_action_set_dscp.
2699 RTE_FLOW_ACTION_TYPE_SET_IPV4_DSCP,
2702 * Modify IPv6 DSCP in the outermost IP header.
2704 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV6,
2705 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2707 * See struct rte_flow_action_set_dscp.
2709 RTE_FLOW_ACTION_TYPE_SET_IPV6_DSCP,
2712 * Report as aged flow if timeout passed without any matching on the
2715 * See struct rte_flow_action_age.
2716 * See function rte_flow_get_aged_flows
2717 * see enum RTE_ETH_EVENT_FLOW_AGED
2718 * See struct rte_flow_query_age
2720 RTE_FLOW_ACTION_TYPE_AGE,
2723 * The matching packets will be duplicated with specified ratio and
2724 * applied with own set of actions with a fate action.
2726 * See struct rte_flow_action_sample.
2728 RTE_FLOW_ACTION_TYPE_SAMPLE,
2732 * @see RTE_FLOW_ACTION_TYPE_INDIRECT
2734 * Describe action shared across multiple flow rules.
2736 * Allow multiple rules reference the same action by handle (see
2737 * struct rte_flow_shared_action).
2739 RTE_FLOW_ACTION_TYPE_SHARED,
2742 * Modify a packet header field, tag, mark or metadata.
2744 * Allow the modification of an arbitrary header field via
2745 * set, add and sub operations or copying its content into
2746 * tag, meta or mark for future processing.
2748 * See struct rte_flow_action_modify_field.
2750 RTE_FLOW_ACTION_TYPE_MODIFY_FIELD,
2753 * An action handle is referenced in a rule through an indirect action.
2755 * The same action handle may be used in multiple rules for the same
2756 * or different ethdev ports.
2758 RTE_FLOW_ACTION_TYPE_INDIRECT,
2763 * Enable tracking a TCP connection state.
2765 * @see struct rte_flow_action_conntrack.
2767 RTE_FLOW_ACTION_TYPE_CONNTRACK,
2770 * Color the packet to reflect the meter color result.
2771 * Set the meter color in the mbuf to the selected color.
2773 * See struct rte_flow_action_meter_color.
2775 RTE_FLOW_ACTION_TYPE_METER_COLOR,
2778 * At embedded switch level, sends matching traffic to the given ethdev.
2780 * @see struct rte_flow_action_ethdev
2782 RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR,
2785 * At embedded switch level, send matching traffic to
2786 * the entity represented by the given ethdev.
2788 * @see struct rte_flow_action_ethdev
2790 RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT,
2794 * RTE_FLOW_ACTION_TYPE_MARK
2796 * Attaches an integer value to packets and sets RTE_MBUF_F_RX_FDIR and
2797 * RTE_MBUF_F_RX_FDIR_ID mbuf flags.
2799 * This value is arbitrary and application-defined. Maximum allowed value
2800 * depends on the underlying implementation. It is returned in the
2801 * hash.fdir.hi mbuf field.
2803 struct rte_flow_action_mark {
2804 uint32_t id; /**< Integer value to return with packets. */
2809 * @b EXPERIMENTAL: this structure may change without prior notice
2811 * RTE_FLOW_ACTION_TYPE_JUMP
2813 * Redirects packets to a group on the current device.
2815 * In a hierarchy of groups, which can be used to represent physical or logical
2816 * flow tables on the device, this action allows the action to be a redirect to
2817 * a group on that device.
2819 struct rte_flow_action_jump {
2824 * RTE_FLOW_ACTION_TYPE_QUEUE
2826 * Assign packets to a given queue index.
2828 struct rte_flow_action_queue {
2829 uint16_t index; /**< Queue index to use. */
2834 * @b EXPERIMENTAL: this structure may change without prior notice
2836 * RTE_FLOW_ACTION_TYPE_AGE
2838 * Report flow as aged-out if timeout passed without any matching
2839 * on the flow. RTE_ETH_EVENT_FLOW_AGED event is triggered when a
2840 * port detects new aged-out flows.
2842 * The flow context and the flow handle will be reported by the
2843 * rte_flow_get_aged_flows API.
2845 struct rte_flow_action_age {
2846 uint32_t timeout:24; /**< Time in seconds. */
2847 uint32_t reserved:8; /**< Reserved, must be zero. */
2848 /** The user flow context, NULL means the rte_flow pointer. */
2853 * RTE_FLOW_ACTION_TYPE_AGE (query)
2855 * Query structure to retrieve the aging status information of a
2856 * shared AGE action, or a flow rule using the AGE action.
2858 struct rte_flow_query_age {
2859 uint32_t reserved:6; /**< Reserved, must be zero. */
2860 uint32_t aged:1; /**< 1 if aging timeout expired, 0 otherwise. */
2861 /** sec_since_last_hit value is valid. */
2862 uint32_t sec_since_last_hit_valid:1;
2863 uint32_t sec_since_last_hit:24; /**< Seconds since last traffic hit. */
2868 * @b EXPERIMENTAL: this structure may change without prior notice
2870 * RTE_FLOW_ACTION_TYPE_COUNT
2872 * Adds a counter action to a matched flow.
2874 * If more than one count action is specified in a single flow rule, then each
2875 * action must specify a unique ID.
2877 * Counters can be retrieved and reset through ``rte_flow_query()``, see
2878 * ``struct rte_flow_query_count``.
2880 * For ports within the same switch domain then the counter ID namespace extends
2881 * to all ports within that switch domain.
2883 struct rte_flow_action_count {
2884 uint32_t id; /**< Counter ID. */
2888 * RTE_FLOW_ACTION_TYPE_COUNT (query)
2890 * Query structure to retrieve and reset flow rule counters.
2892 struct rte_flow_query_count {
2893 uint32_t reset:1; /**< Reset counters after query [in]. */
2894 uint32_t hits_set:1; /**< hits field is set [out]. */
2895 uint32_t bytes_set:1; /**< bytes field is set [out]. */
2896 uint32_t reserved:29; /**< Reserved, must be zero [in, out]. */
2897 uint64_t hits; /**< Number of hits for this rule [out]. */
2898 uint64_t bytes; /**< Number of bytes through this rule [out]. */
2902 * Hash function types.
2904 enum rte_eth_hash_function {
2905 RTE_ETH_HASH_FUNCTION_DEFAULT = 0,
2906 RTE_ETH_HASH_FUNCTION_TOEPLITZ, /**< Toeplitz */
2907 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR, /**< Simple XOR */
2909 * Symmetric Toeplitz: src, dst will be replaced by
2910 * xor(src, dst). For the case with src/dst only,
2911 * src or dst address will xor with zero pair.
2913 RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ,
2914 RTE_ETH_HASH_FUNCTION_MAX,
2918 * RTE_FLOW_ACTION_TYPE_RSS
2920 * Similar to QUEUE, except RSS is additionally performed on packets to
2921 * spread them among several queues according to the provided parameters.
2923 * Unlike global RSS settings used by other DPDK APIs, unsetting the
2924 * @p types field does not disable RSS in a flow rule. Doing so instead
2925 * requests safe unspecified "best-effort" settings from the underlying PMD,
2926 * which depending on the flow rule, may result in anything ranging from
2927 * empty (single queue) to all-inclusive RSS.
2929 * Note: RSS hash result is stored in the hash.rss mbuf field which overlaps
2930 * hash.fdir.lo. Since the MARK action sets the hash.fdir.hi field only,
2931 * both can be requested simultaneously.
2933 struct rte_flow_action_rss {
2934 enum rte_eth_hash_function func; /**< RSS hash function to apply. */
2936 * Packet encapsulation level RSS hash @p types apply to.
2938 * - @p 0 requests the default behavior. Depending on the packet
2939 * type, it can mean outermost, innermost, anything in between or
2942 * It basically stands for the innermost encapsulation level RSS
2943 * can be performed on according to PMD and device capabilities.
2945 * - @p 1 requests RSS to be performed on the outermost packet
2946 * encapsulation level.
2948 * - @p 2 and subsequent values request RSS to be performed on the
2949 * specified inner packet encapsulation level, from outermost to
2950 * innermost (lower to higher values).
2952 * Values other than @p 0 are not necessarily supported.
2954 * Requesting a specific RSS level on unrecognized traffic results
2955 * in undefined behavior. For predictable results, it is recommended
2956 * to make the flow rule pattern match packet headers up to the
2957 * requested encapsulation level so that only matching traffic goes
2961 uint64_t types; /**< Specific RSS hash types (see RTE_ETH_RSS_*). */
2962 uint32_t key_len; /**< Hash key length in bytes. */
2963 uint32_t queue_num; /**< Number of entries in @p queue. */
2964 const uint8_t *key; /**< Hash key. */
2965 const uint16_t *queue; /**< Queue indices to use. */
2970 * @see RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR
2971 * @see RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT
2973 * RTE_FLOW_ACTION_TYPE_VF
2975 * Directs matching traffic to a given virtual function of the current
2978 * Packets matched by a VF pattern item can be redirected to their original
2979 * VF ID instead of the specified one. This parameter may not be available
2980 * and is not guaranteed to work properly if the VF part is matched by a
2981 * prior flow rule or if packets are not addressed to a VF in the first
2984 struct rte_flow_action_vf {
2985 uint32_t original:1; /**< Use original VF ID if possible. */
2986 uint32_t reserved:31; /**< Reserved, must be zero. */
2987 uint32_t id; /**< VF ID. */
2992 * @see RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR
2993 * @see RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT
2995 * RTE_FLOW_ACTION_TYPE_PHY_PORT
2997 * Directs packets to a given physical port index of the underlying
3000 * @see RTE_FLOW_ITEM_TYPE_PHY_PORT
3002 struct rte_flow_action_phy_port {
3003 uint32_t original:1; /**< Use original port index if possible. */
3004 uint32_t reserved:31; /**< Reserved, must be zero. */
3005 uint32_t index; /**< Physical port index. */
3010 * @see RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR
3011 * @see RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT
3013 * RTE_FLOW_ACTION_TYPE_PORT_ID
3015 * Directs matching traffic to a given DPDK port ID.
3017 * @see RTE_FLOW_ITEM_TYPE_PORT_ID
3019 struct rte_flow_action_port_id {
3020 uint32_t original:1; /**< Use original DPDK port ID if possible. */
3021 uint32_t reserved:31; /**< Reserved, must be zero. */
3022 uint32_t id; /**< DPDK port ID. */
3026 * RTE_FLOW_ACTION_TYPE_METER
3028 * Traffic metering and policing (MTR).
3030 * Packets matched by items of this type can be either dropped or passed to the
3031 * next item with their color set by the MTR object.
3033 struct rte_flow_action_meter {
3034 uint32_t mtr_id; /**< MTR object ID created with rte_mtr_create(). */
3038 * RTE_FLOW_ACTION_TYPE_SECURITY
3040 * Perform the security action on flows matched by the pattern items
3041 * according to the configuration of the security session.
3043 * This action modifies the payload of matched flows. For INLINE_CRYPTO, the
3044 * security protocol headers and IV are fully provided by the application as
3045 * specified in the flow pattern. The payload of matching packets is
3046 * encrypted on egress, and decrypted and authenticated on ingress.
3047 * For INLINE_PROTOCOL, the security protocol is fully offloaded to HW,
3048 * providing full encapsulation and decapsulation of packets in security
3049 * protocols. The flow pattern specifies both the outer security header fields
3050 * and the inner packet fields. The security session specified in the action
3051 * must match the pattern parameters.
3053 * The security session specified in the action must be created on the same
3054 * port as the flow action that is being specified.
3056 * The ingress/egress flow attribute should match that specified in the
3057 * security session if the security session supports the definition of the
3060 * Multiple flows can be configured to use the same security session.
3062 * The NULL value is allowed for security session. If security session is NULL,
3063 * then SPI field in ESP flow item and IP addresses in flow items 'IPv4' and
3064 * 'IPv6' will be allowed to be a range. The rule thus created can enable
3065 * security processing on multiple flows.
3067 struct rte_flow_action_security {
3068 void *security_session; /**< Pointer to security session structure. */
3072 * RTE_FLOW_ACTION_TYPE_OF_SET_MPLS_TTL
3074 * Implements OFPAT_SET_MPLS_TTL ("MPLS TTL") as defined by the OpenFlow
3075 * Switch Specification.
3077 struct rte_flow_action_of_set_mpls_ttl {
3078 uint8_t mpls_ttl; /**< MPLS TTL. */
3082 * RTE_FLOW_ACTION_TYPE_OF_SET_NW_TTL
3084 * Implements OFPAT_SET_NW_TTL ("IP TTL") as defined by the OpenFlow Switch
3087 struct rte_flow_action_of_set_nw_ttl {
3088 uint8_t nw_ttl; /**< IP TTL. */
3092 * RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN
3094 * Implements OFPAT_PUSH_VLAN ("push a new VLAN tag") as defined by the
3095 * OpenFlow Switch Specification.
3097 struct rte_flow_action_of_push_vlan {
3098 rte_be16_t ethertype; /**< EtherType. */
3102 * RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID
3104 * Implements OFPAT_SET_VLAN_VID ("set the 802.1q VLAN ID") as defined by
3105 * the OpenFlow Switch Specification.
3107 struct rte_flow_action_of_set_vlan_vid {
3108 rte_be16_t vlan_vid; /**< VLAN ID. */
3112 * RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP
3114 * Implements OFPAT_SET_LAN_PCP ("set the 802.1q priority") as defined by
3115 * the OpenFlow Switch Specification.
3117 struct rte_flow_action_of_set_vlan_pcp {
3118 uint8_t vlan_pcp; /**< VLAN priority. */
3122 * RTE_FLOW_ACTION_TYPE_OF_POP_MPLS
3124 * Implements OFPAT_POP_MPLS ("pop the outer MPLS tag") as defined by the
3125 * OpenFlow Switch Specification.
3127 struct rte_flow_action_of_pop_mpls {
3128 rte_be16_t ethertype; /**< EtherType. */
3132 * RTE_FLOW_ACTION_TYPE_OF_PUSH_MPLS
3134 * Implements OFPAT_PUSH_MPLS ("push a new MPLS tag") as defined by the
3135 * OpenFlow Switch Specification.
3137 struct rte_flow_action_of_push_mpls {
3138 rte_be16_t ethertype; /**< EtherType. */
3143 * @b EXPERIMENTAL: this structure may change without prior notice
3145 * RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP
3147 * VXLAN tunnel end-point encapsulation data definition
3149 * The tunnel definition is provided through the flow item pattern, the
3150 * provided pattern must conform to RFC7348 for the tunnel specified. The flow
3151 * definition must be provided in order from the RTE_FLOW_ITEM_TYPE_ETH
3152 * definition up the end item which is specified by RTE_FLOW_ITEM_TYPE_END.
3154 * The mask field allows user to specify which fields in the flow item
3155 * definitions can be ignored and which have valid data and can be used
3158 * Note: the last field is not used in the definition of a tunnel and can be
3161 * Valid flow definition for RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP include:
3163 * - ETH / IPV4 / UDP / VXLAN / END
3164 * - ETH / IPV6 / UDP / VXLAN / END
3165 * - ETH / VLAN / IPV4 / UDP / VXLAN / END
3168 struct rte_flow_action_vxlan_encap {
3170 * Encapsulating vxlan tunnel definition
3171 * (terminated by the END pattern item).
3173 struct rte_flow_item *definition;
3178 * @b EXPERIMENTAL: this structure may change without prior notice
3180 * RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP
3182 * NVGRE tunnel end-point encapsulation data definition
3184 * The tunnel definition is provided through the flow item pattern the
3185 * provided pattern must conform with RFC7637. The flow definition must be
3186 * provided in order from the RTE_FLOW_ITEM_TYPE_ETH definition up the end item
3187 * which is specified by RTE_FLOW_ITEM_TYPE_END.
3189 * The mask field allows user to specify which fields in the flow item
3190 * definitions can be ignored and which have valid data and can be used
3193 * Note: the last field is not used in the definition of a tunnel and can be
3196 * Valid flow definition for RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP include:
3198 * - ETH / IPV4 / NVGRE / END
3199 * - ETH / VLAN / IPV6 / NVGRE / END
3202 struct rte_flow_action_nvgre_encap {
3204 * Encapsulating vxlan tunnel definition
3205 * (terminated by the END pattern item).
3207 struct rte_flow_item *definition;
3212 * @b EXPERIMENTAL: this structure may change without prior notice
3214 * RTE_FLOW_ACTION_TYPE_RAW_ENCAP
3216 * Raw tunnel end-point encapsulation data definition.
3218 * The data holds the headers definitions to be applied on the packet.
3219 * The data must start with ETH header up to the tunnel item header itself.
3220 * When used right after RAW_DECAP (for decapsulating L3 tunnel type for
3221 * example MPLSoGRE) the data will just hold layer 2 header.
3223 * The preserve parameter holds which bits in the packet the PMD is not allowed
3224 * to change, this parameter can also be NULL and then the PMD is allowed
3225 * to update any field.
3227 * size holds the number of bytes in @p data and @p preserve.
3229 struct rte_flow_action_raw_encap {
3230 uint8_t *data; /**< Encapsulation data. */
3231 uint8_t *preserve; /**< Bit-mask of @p data to preserve on output. */
3232 size_t size; /**< Size of @p data and @p preserve. */
3237 * @b EXPERIMENTAL: this structure may change without prior notice
3239 * RTE_FLOW_ACTION_TYPE_RAW_DECAP
3241 * Raw tunnel end-point decapsulation data definition.
3243 * The data holds the headers definitions to be removed from the packet.
3244 * The data must start with ETH header up to the tunnel item header itself.
3245 * When used right before RAW_DECAP (for encapsulating L3 tunnel type for
3246 * example MPLSoGRE) the data will just hold layer 2 header.
3248 * size holds the number of bytes in @p data.
3250 struct rte_flow_action_raw_decap {
3251 uint8_t *data; /**< Encapsulation data. */
3252 size_t size; /**< Size of @p data and @p preserve. */
3257 * @b EXPERIMENTAL: this structure may change without prior notice
3259 * RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC
3260 * RTE_FLOW_ACTION_TYPE_SET_IPV4_DST
3262 * Allows modification of IPv4 source (RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC)
3263 * and destination address (RTE_FLOW_ACTION_TYPE_SET_IPV4_DST) in the
3264 * specified outermost IPv4 header.
3266 struct rte_flow_action_set_ipv4 {
3267 rte_be32_t ipv4_addr;
3272 * @b EXPERIMENTAL: this structure may change without prior notice
3274 * RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC
3275 * RTE_FLOW_ACTION_TYPE_SET_IPV6_DST
3277 * Allows modification of IPv6 source (RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC)
3278 * and destination address (RTE_FLOW_ACTION_TYPE_SET_IPV6_DST) in the
3279 * specified outermost IPv6 header.
3281 struct rte_flow_action_set_ipv6 {
3282 uint8_t ipv6_addr[16];
3287 * @b EXPERIMENTAL: this structure may change without prior notice
3289 * RTE_FLOW_ACTION_TYPE_SET_TP_SRC
3290 * RTE_FLOW_ACTION_TYPE_SET_TP_DST
3292 * Allows modification of source (RTE_FLOW_ACTION_TYPE_SET_TP_SRC)
3293 * and destination (RTE_FLOW_ACTION_TYPE_SET_TP_DST) port numbers
3294 * in the specified outermost TCP/UDP header.
3296 struct rte_flow_action_set_tp {
3301 * RTE_FLOW_ACTION_TYPE_SET_TTL
3303 * Set the TTL value directly for IPv4 or IPv6
3305 struct rte_flow_action_set_ttl {
3310 * RTE_FLOW_ACTION_TYPE_SET_MAC
3312 * Set MAC address from the matched flow
3314 struct rte_flow_action_set_mac {
3315 uint8_t mac_addr[RTE_ETHER_ADDR_LEN];
3320 * @b EXPERIMENTAL: this structure may change without prior notice
3322 * RTE_FLOW_ACTION_TYPE_SET_TAG
3324 * Set a tag which is a transient data used during flow matching. This is not
3325 * delivered to application. Multiple tags are supported by specifying index.
3327 struct rte_flow_action_set_tag {
3335 * @b EXPERIMENTAL: this structure may change without prior notice
3337 * RTE_FLOW_ACTION_TYPE_SET_META
3339 * Set metadata. Metadata set by mbuf metadata dynamic field with
3340 * RTE_MBUF_DYNFLAG_TX_METADATA flag on egress will be overridden by this
3341 * action. On ingress, the metadata will be carried by mbuf metadata dynamic
3342 * field with RTE_MBUF_DYNFLAG_RX_METADATA flag if set. The dynamic mbuf field
3343 * must be registered in advance by rte_flow_dynf_metadata_register().
3345 * Altering partial bits is supported with mask. For bits which have never
3346 * been set, unpredictable value will be seen depending on driver
3347 * implementation. For loopback/hairpin packet, metadata set on Rx/Tx may
3348 * or may not be propagated to the other path depending on HW capability.
3350 * RTE_FLOW_ITEM_TYPE_META matches metadata.
3352 struct rte_flow_action_set_meta {
3358 * RTE_FLOW_ACTION_TYPE_SET_IPV4_DSCP
3359 * RTE_FLOW_ACTION_TYPE_SET_IPV6_DSCP
3361 * Set the DSCP value for IPv4/IPv6 header.
3362 * DSCP in low 6 bits, rest ignored.
3364 struct rte_flow_action_set_dscp {
3370 * @b EXPERIMENTAL: this structure may change without prior notice
3372 * RTE_FLOW_ACTION_TYPE_INDIRECT
3374 * Opaque type returned after successfully creating an indirect action object.
3375 * The definition of the object handle is different per driver or
3376 * per direct action type.
3378 * This handle can be used to manage and query the related direct action:
3379 * - referenced in single flow rule or across multiple flow rules
3380 * over multiple ports
3381 * - update action object configuration
3382 * - query action object data
3383 * - destroy action object
3385 struct rte_flow_action_handle;
3388 * The state of a TCP connection.
3390 enum rte_flow_conntrack_state {
3391 /** SYN-ACK packet was seen. */
3392 RTE_FLOW_CONNTRACK_STATE_SYN_RECV,
3393 /** 3-way handshake was done. */
3394 RTE_FLOW_CONNTRACK_STATE_ESTABLISHED,
3395 /** First FIN packet was received to close the connection. */
3396 RTE_FLOW_CONNTRACK_STATE_FIN_WAIT,
3397 /** First FIN was ACKed. */
3398 RTE_FLOW_CONNTRACK_STATE_CLOSE_WAIT,
3399 /** Second FIN was received, waiting for the last ACK. */
3400 RTE_FLOW_CONNTRACK_STATE_LAST_ACK,
3401 /** Second FIN was ACKed, connection was closed. */
3402 RTE_FLOW_CONNTRACK_STATE_TIME_WAIT,
3406 * The last passed TCP packet flags of a connection.
3408 enum rte_flow_conntrack_tcp_last_index {
3409 RTE_FLOW_CONNTRACK_FLAG_NONE = 0, /**< No Flag. */
3410 RTE_FLOW_CONNTRACK_FLAG_SYN = RTE_BIT32(0), /**< With SYN flag. */
3411 RTE_FLOW_CONNTRACK_FLAG_SYNACK = RTE_BIT32(1), /**< With SYNACK flag. */
3412 RTE_FLOW_CONNTRACK_FLAG_FIN = RTE_BIT32(2), /**< With FIN flag. */
3413 RTE_FLOW_CONNTRACK_FLAG_ACK = RTE_BIT32(3), /**< With ACK flag. */
3414 RTE_FLOW_CONNTRACK_FLAG_RST = RTE_BIT32(4), /**< With RST flag. */
3419 * @b EXPERIMENTAL: this structure may change without prior notice
3421 * Configuration parameters for each direction of a TCP connection.
3422 * All fields should be in host byte order.
3423 * If needed, driver should convert all fields to network byte order
3424 * if HW needs them in that way.
3426 struct rte_flow_tcp_dir_param {
3427 /** TCP window scaling factor, 0xF to disable. */
3429 /** The FIN was sent by this direction. */
3430 uint32_t close_initiated:1;
3431 /** An ACK packet has been received by this side. */
3432 uint32_t last_ack_seen:1;
3434 * If set, it indicates that there is unacknowledged data for the
3435 * packets sent from this direction.
3437 uint32_t data_unacked:1;
3439 * Maximal value of sequence + payload length in sent
3440 * packets (next ACK from the opposite direction).
3444 * Maximal value of (ACK + window size) in received packet + length
3445 * over sent packet (maximal sequence could be sent).
3448 /** Maximal value of actual window size in sent packets. */
3450 /** Maximal value of ACK in sent packets. */
3456 * @b EXPERIMENTAL: this structure may change without prior notice
3458 * RTE_FLOW_ACTION_TYPE_CONNTRACK
3460 * Configuration and initial state for the connection tracking module.
3461 * This structure could be used for both setting and query.
3462 * All fields should be in host byte order.
3464 struct rte_flow_action_conntrack {
3465 /** The peer port number, can be the same port. */
3468 * Direction of this connection when creating a flow rule, the
3469 * value only affects the creation of subsequent flow rules.
3471 uint32_t is_original_dir:1;
3473 * Enable / disable the conntrack HW module. When disabled, the
3474 * result will always be RTE_FLOW_CONNTRACK_FLAG_DISABLED.
3475 * In this state the HW will act as passthrough.
3476 * It only affects this conntrack object in the HW without any effect
3477 * to the other objects.
3480 /** At least one ack was seen after the connection was established. */
3481 uint32_t live_connection:1;
3482 /** Enable selective ACK on this connection. */
3483 uint32_t selective_ack:1;
3484 /** A challenge ack has passed. */
3485 uint32_t challenge_ack_passed:1;
3487 * 1: The last packet is seen from the original direction.
3488 * 0: The last packet is seen from the reply direction.
3490 uint32_t last_direction:1;
3491 /** No TCP check will be done except the state change. */
3492 uint32_t liberal_mode:1;
3493 /** The current state of this connection. */
3494 enum rte_flow_conntrack_state state;
3495 /** Scaling factor for maximal allowed ACK window. */
3496 uint8_t max_ack_window;
3497 /** Maximal allowed number of retransmission times. */
3498 uint8_t retransmission_limit;
3499 /** TCP parameters of the original direction. */
3500 struct rte_flow_tcp_dir_param original_dir;
3501 /** TCP parameters of the reply direction. */
3502 struct rte_flow_tcp_dir_param reply_dir;
3503 /** The window value of the last packet passed this conntrack. */
3504 uint16_t last_window;
3505 enum rte_flow_conntrack_tcp_last_index last_index;
3506 /** The sequence of the last packet passed this conntrack. */
3508 /** The acknowledgment of the last packet passed this conntrack. */
3511 * The total value ACK + payload length of the last packet
3512 * passed this conntrack.
3518 * RTE_FLOW_ACTION_TYPE_CONNTRACK
3520 * Wrapper structure for the context update interface.
3521 * Ports cannot support updating, and the only valid solution is to
3522 * destroy the old context and create a new one instead.
3524 struct rte_flow_modify_conntrack {
3525 /** New connection tracking parameters to be updated. */
3526 struct rte_flow_action_conntrack new_ct;
3527 /** The direction field will be updated. */
3528 uint32_t direction:1;
3529 /** All the other fields except direction will be updated. */
3531 /** Reserved bits for the future usage. */
3532 uint32_t reserved:30;
3537 * @b EXPERIMENTAL: this structure may change without prior notice
3539 * RTE_FLOW_ACTION_TYPE_METER_COLOR
3541 * The meter color should be set in the packet meta-data
3542 * (i.e. struct rte_mbuf::sched::color).
3544 struct rte_flow_action_meter_color {
3545 enum rte_color color; /**< Packet color. */
3550 * @b EXPERIMENTAL: this structure may change without prior notice
3552 * Provides an ethdev port ID for use with the following actions:
3553 * RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR,
3554 * RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT.
3556 struct rte_flow_action_ethdev {
3557 uint16_t port_id; /**< ethdev port ID */
3561 * Field IDs for MODIFY_FIELD action.
3563 enum rte_flow_field_id {
3564 RTE_FLOW_FIELD_START = 0, /**< Start of a packet. */
3565 RTE_FLOW_FIELD_MAC_DST, /**< Destination MAC Address. */
3566 RTE_FLOW_FIELD_MAC_SRC, /**< Source MAC Address. */
3567 RTE_FLOW_FIELD_VLAN_TYPE, /**< 802.1Q Tag Identifier. */
3568 RTE_FLOW_FIELD_VLAN_ID, /**< 802.1Q VLAN Identifier. */
3569 RTE_FLOW_FIELD_MAC_TYPE, /**< EtherType. */
3570 RTE_FLOW_FIELD_IPV4_DSCP, /**< IPv4 DSCP. */
3571 RTE_FLOW_FIELD_IPV4_TTL, /**< IPv4 Time To Live. */
3572 RTE_FLOW_FIELD_IPV4_SRC, /**< IPv4 Source Address. */
3573 RTE_FLOW_FIELD_IPV4_DST, /**< IPv4 Destination Address. */
3574 RTE_FLOW_FIELD_IPV6_DSCP, /**< IPv6 DSCP. */
3575 RTE_FLOW_FIELD_IPV6_HOPLIMIT, /**< IPv6 Hop Limit. */
3576 RTE_FLOW_FIELD_IPV6_SRC, /**< IPv6 Source Address. */
3577 RTE_FLOW_FIELD_IPV6_DST, /**< IPv6 Destination Address. */
3578 RTE_FLOW_FIELD_TCP_PORT_SRC, /**< TCP Source Port Number. */
3579 RTE_FLOW_FIELD_TCP_PORT_DST, /**< TCP Destination Port Number. */
3580 RTE_FLOW_FIELD_TCP_SEQ_NUM, /**< TCP Sequence Number. */
3581 RTE_FLOW_FIELD_TCP_ACK_NUM, /**< TCP Acknowledgment Number. */
3582 RTE_FLOW_FIELD_TCP_FLAGS, /**< TCP Flags. */
3583 RTE_FLOW_FIELD_UDP_PORT_SRC, /**< UDP Source Port Number. */
3584 RTE_FLOW_FIELD_UDP_PORT_DST, /**< UDP Destination Port Number. */
3585 RTE_FLOW_FIELD_VXLAN_VNI, /**< VXLAN Network Identifier. */
3586 RTE_FLOW_FIELD_GENEVE_VNI, /**< GENEVE Network Identifier. */
3587 RTE_FLOW_FIELD_GTP_TEID, /**< GTP Tunnel Endpoint Identifier. */
3588 RTE_FLOW_FIELD_TAG, /**< Tag value. */
3589 RTE_FLOW_FIELD_MARK, /**< Mark value. */
3590 RTE_FLOW_FIELD_META, /**< Metadata value. */
3591 RTE_FLOW_FIELD_POINTER, /**< Memory pointer. */
3592 RTE_FLOW_FIELD_VALUE, /**< Immediate value. */
3597 * @b EXPERIMENTAL: this structure may change without prior notice
3599 * Field description for MODIFY_FIELD action.
3601 struct rte_flow_action_modify_data {
3602 enum rte_flow_field_id field; /**< Field or memory type ID. */
3606 /** Encapsulation level or tag index. */
3608 /** Number of bits to skip from a field. */
3612 * Immediate value for RTE_FLOW_FIELD_VALUE, presented in the
3613 * same byte order and length as in relevant rte_flow_item_xxx.
3614 * The immediate source bitfield offset is inherited from
3615 * the destination's one.
3619 * Memory address for RTE_FLOW_FIELD_POINTER, memory layout
3620 * should be the same as for relevant field in the
3621 * rte_flow_item_xxx structure.
3628 * Operation types for MODIFY_FIELD action.
3630 enum rte_flow_modify_op {
3631 RTE_FLOW_MODIFY_SET = 0, /**< Set a new value. */
3632 RTE_FLOW_MODIFY_ADD, /**< Add a value to a field. */
3633 RTE_FLOW_MODIFY_SUB, /**< Subtract a value from a field. */
3638 * @b EXPERIMENTAL: this structure may change without prior notice
3640 * RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
3642 * Modify a destination header field according to the specified
3643 * operation. Another field of the packet can be used as a source as well
3644 * as tag, mark, metadata, immediate value or a pointer to it.
3646 struct rte_flow_action_modify_field {
3647 enum rte_flow_modify_op operation; /**< Operation to perform. */
3648 struct rte_flow_action_modify_data dst; /**< Destination field. */
3649 struct rte_flow_action_modify_data src; /**< Source field. */
3650 uint32_t width; /**< Number of bits to use from a source field. */
3653 /* Mbuf dynamic field offset for metadata. */
3654 extern int32_t rte_flow_dynf_metadata_offs;
3656 /* Mbuf dynamic field flag mask for metadata. */
3657 extern uint64_t rte_flow_dynf_metadata_mask;
3659 /* Mbuf dynamic field pointer for metadata. */
3660 #define RTE_FLOW_DYNF_METADATA(m) \
3661 RTE_MBUF_DYNFIELD((m), rte_flow_dynf_metadata_offs, uint32_t *)
3663 /* Mbuf dynamic flags for metadata. */
3664 #define RTE_MBUF_DYNFLAG_RX_METADATA (rte_flow_dynf_metadata_mask)
3665 #define PKT_RX_DYNF_METADATA RTE_DEPRECATED(PKT_RX_DYNF_METADATA) \
3666 RTE_MBUF_DYNFLAG_RX_METADATA
3667 #define RTE_MBUF_DYNFLAG_TX_METADATA (rte_flow_dynf_metadata_mask)
3668 #define PKT_TX_DYNF_METADATA RTE_DEPRECATED(PKT_TX_DYNF_METADATA) \
3669 RTE_MBUF_DYNFLAG_TX_METADATA
3672 static inline uint32_t
3673 rte_flow_dynf_metadata_get(struct rte_mbuf *m)
3675 return *RTE_FLOW_DYNF_METADATA(m);
3680 rte_flow_dynf_metadata_set(struct rte_mbuf *m, uint32_t v)
3682 *RTE_FLOW_DYNF_METADATA(m) = v;
3686 * Definition of a single action.
3688 * A list of actions is terminated by a END action.
3690 * For simple actions without a configuration object, conf remains NULL.
3692 struct rte_flow_action {
3693 enum rte_flow_action_type type; /**< Action type. */
3694 const void *conf; /**< Pointer to action configuration object. */
3698 * Opaque type returned after successfully creating a flow.
3700 * This handle can be used to manage and query the related flow (e.g. to
3701 * destroy it or retrieve counters).
3707 * @b EXPERIMENTAL: this structure may change without prior notice
3709 * RTE_FLOW_ACTION_TYPE_SAMPLE
3711 * Adds a sample action to a matched flow.
3713 * The matching packets will be duplicated with specified ratio and applied
3714 * with own set of actions with a fate action, the sampled packet could be
3715 * redirected to queue or port. All the packets continue processing on the
3716 * default flow path.
3718 * When the sample ratio is set to 1 then the packets will be 100% mirrored.
3719 * Additional action list be supported to add for sampled or mirrored packets.
3721 struct rte_flow_action_sample {
3722 uint32_t ratio; /**< packets sampled equals to '1/ratio'. */
3723 /** sub-action list specific for the sampling hit cases. */
3724 const struct rte_flow_action *actions;
3728 * Verbose error types.
3730 * Most of them provide the type of the object referenced by struct
3731 * rte_flow_error.cause.
3733 enum rte_flow_error_type {
3734 RTE_FLOW_ERROR_TYPE_NONE, /**< No error. */
3735 RTE_FLOW_ERROR_TYPE_UNSPECIFIED, /**< Cause unspecified. */
3736 RTE_FLOW_ERROR_TYPE_HANDLE, /**< Flow rule (handle). */
3737 RTE_FLOW_ERROR_TYPE_ATTR_GROUP, /**< Group field. */
3738 RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY, /**< Priority field. */
3739 RTE_FLOW_ERROR_TYPE_ATTR_INGRESS, /**< Ingress field. */
3740 RTE_FLOW_ERROR_TYPE_ATTR_EGRESS, /**< Egress field. */
3741 RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, /**< Transfer field. */
3742 RTE_FLOW_ERROR_TYPE_ATTR, /**< Attributes structure. */
3743 RTE_FLOW_ERROR_TYPE_ITEM_NUM, /**< Pattern length. */
3744 RTE_FLOW_ERROR_TYPE_ITEM_SPEC, /**< Item specification. */
3745 RTE_FLOW_ERROR_TYPE_ITEM_LAST, /**< Item specification range. */
3746 RTE_FLOW_ERROR_TYPE_ITEM_MASK, /**< Item specification mask. */
3747 RTE_FLOW_ERROR_TYPE_ITEM, /**< Specific pattern item. */
3748 RTE_FLOW_ERROR_TYPE_ACTION_NUM, /**< Number of actions. */
3749 RTE_FLOW_ERROR_TYPE_ACTION_CONF, /**< Action configuration. */
3750 RTE_FLOW_ERROR_TYPE_ACTION, /**< Specific action. */
3754 * Verbose error structure definition.
3756 * This object is normally allocated by applications and set by PMDs, the
3757 * message points to a constant string which does not need to be freed by
3758 * the application, however its pointer can be considered valid only as long
3759 * as its associated DPDK port remains configured. Closing the underlying
3760 * device or unloading the PMD invalidates it.
3762 * Both cause and message may be NULL regardless of the error type.
3764 struct rte_flow_error {
3765 enum rte_flow_error_type type; /**< Cause field and error types. */
3766 const void *cause; /**< Object responsible for the error. */
3767 const char *message; /**< Human-readable error message. */
3771 * Complete flow rule description.
3773 * This object type is used when converting a flow rule description.
3775 * @see RTE_FLOW_CONV_OP_RULE
3776 * @see rte_flow_conv()
3779 struct rte_flow_conv_rule {
3781 const struct rte_flow_attr *attr_ro; /**< RO attributes. */
3782 struct rte_flow_attr *attr; /**< Attributes. */
3785 const struct rte_flow_item *pattern_ro; /**< RO pattern. */
3786 struct rte_flow_item *pattern; /**< Pattern items. */
3789 const struct rte_flow_action *actions_ro; /**< RO actions. */
3790 struct rte_flow_action *actions; /**< List of actions. */
3795 * Conversion operations for flow API objects.
3797 * @see rte_flow_conv()
3799 enum rte_flow_conv_op {
3801 * No operation to perform.
3803 * rte_flow_conv() simply returns 0.
3805 RTE_FLOW_CONV_OP_NONE,
3808 * Convert attributes structure.
3810 * This is a basic copy of an attributes structure.
3813 * @code const struct rte_flow_attr * @endcode
3815 * @code struct rte_flow_attr * @endcode
3817 RTE_FLOW_CONV_OP_ATTR,
3820 * Convert a single item.
3822 * Duplicates @p spec, @p last and @p mask but not outside objects.
3825 * @code const struct rte_flow_item * @endcode
3827 * @code struct rte_flow_item * @endcode
3829 RTE_FLOW_CONV_OP_ITEM,
3832 * Convert a single action.
3834 * Duplicates @p conf but not outside objects.
3837 * @code const struct rte_flow_action * @endcode
3839 * @code struct rte_flow_action * @endcode
3841 RTE_FLOW_CONV_OP_ACTION,
3844 * Convert an entire pattern.
3846 * Duplicates all pattern items at once with the same constraints as
3847 * RTE_FLOW_CONV_OP_ITEM.
3850 * @code const struct rte_flow_item * @endcode
3852 * @code struct rte_flow_item * @endcode
3854 RTE_FLOW_CONV_OP_PATTERN,
3857 * Convert a list of actions.
3859 * Duplicates the entire list of actions at once with the same
3860 * constraints as RTE_FLOW_CONV_OP_ACTION.
3863 * @code const struct rte_flow_action * @endcode
3865 * @code struct rte_flow_action * @endcode
3867 RTE_FLOW_CONV_OP_ACTIONS,
3870 * Convert a complete flow rule description.
3872 * Comprises attributes, pattern and actions together at once with
3873 * the usual constraints.
3876 * @code const struct rte_flow_conv_rule * @endcode
3878 * @code struct rte_flow_conv_rule * @endcode
3880 RTE_FLOW_CONV_OP_RULE,
3883 * Convert item type to its name string.
3885 * Writes a NUL-terminated string to @p dst. Like snprintf(), the
3886 * returned value excludes the terminator which is always written
3890 * @code (const void *)enum rte_flow_item_type @endcode
3892 * @code char * @endcode
3894 RTE_FLOW_CONV_OP_ITEM_NAME,
3897 * Convert action type to its name string.
3899 * Writes a NUL-terminated string to @p dst. Like snprintf(), the
3900 * returned value excludes the terminator which is always written
3904 * @code (const void *)enum rte_flow_action_type @endcode
3906 * @code char * @endcode
3908 RTE_FLOW_CONV_OP_ACTION_NAME,
3911 * Convert item type to pointer to item name.
3913 * Retrieves item name pointer from its type. The string itself is
3914 * not copied; instead, a unique pointer to an internal static
3915 * constant storage is written to @p dst.
3918 * @code (const void *)enum rte_flow_item_type @endcode
3920 * @code const char ** @endcode
3922 RTE_FLOW_CONV_OP_ITEM_NAME_PTR,
3925 * Convert action type to pointer to action name.
3927 * Retrieves action name pointer from its type. The string itself is
3928 * not copied; instead, a unique pointer to an internal static
3929 * constant storage is written to @p dst.
3932 * @code (const void *)enum rte_flow_action_type @endcode
3934 * @code const char ** @endcode
3936 RTE_FLOW_CONV_OP_ACTION_NAME_PTR,
3941 * @b EXPERIMENTAL: this API may change without prior notice.
3943 * Dump hardware internal representation information of
3946 * @param[in] port_id
3947 * The port identifier of the Ethernet device.
3949 * The pointer of flow rule to dump. Dump all rules if NULL.
3951 * A pointer to a file for output.
3953 * Perform verbose error reporting if not NULL. PMDs initialize this
3954 * structure in case of error only.
3956 * 0 on success, a nagative value otherwise.
3960 rte_flow_dev_dump(uint16_t port_id, struct rte_flow *flow,
3961 FILE *file, struct rte_flow_error *error);
3964 * Check if mbuf dynamic field for metadata is registered.
3967 * True if registered, false otherwise.
3971 rte_flow_dynf_metadata_avail(void)
3973 return !!rte_flow_dynf_metadata_mask;
3977 * Register mbuf dynamic field and flag for metadata.
3979 * This function must be called prior to use SET_META action in order to
3980 * register the dynamic mbuf field. Otherwise, the data cannot be delivered to
3984 * 0 on success, a negative errno value otherwise and rte_errno is set.
3988 rte_flow_dynf_metadata_register(void);
3991 * Check whether a flow rule can be created on a given port.
3993 * The flow rule is validated for correctness and whether it could be accepted
3994 * by the device given sufficient resources. The rule is checked against the
3995 * current device mode and queue configuration. The flow rule may also
3996 * optionally be validated against existing flow rules and device resources.
3997 * This function has no effect on the target device.
3999 * The returned value is guaranteed to remain valid only as long as no
4000 * successful calls to rte_flow_create() or rte_flow_destroy() are made in
4001 * the meantime and no device parameter affecting flow rules in any way are
4002 * modified, due to possible collisions or resource limitations (although in
4003 * such cases EINVAL should not be returned).
4006 * Port identifier of Ethernet device.
4008 * Flow rule attributes.
4009 * @param[in] pattern
4010 * Pattern specification (list terminated by the END pattern item).
4011 * @param[in] actions
4012 * Associated actions (list terminated by the END action).
4014 * Perform verbose error reporting if not NULL. PMDs initialize this
4015 * structure in case of error only.
4018 * 0 if flow rule is valid and can be created. A negative errno value
4019 * otherwise (rte_errno is also set), the following errors are defined:
4021 * -ENOSYS: underlying device does not support this functionality.
4023 * -EIO: underlying device is removed.
4025 * -EINVAL: unknown or invalid rule specification.
4027 * -ENOTSUP: valid but unsupported rule specification (e.g. partial
4028 * bit-masks are unsupported).
4030 * -EEXIST: collision with an existing rule. Only returned if device
4031 * supports flow rule collision checking and there was a flow rule
4032 * collision. Not receiving this return code is no guarantee that creating
4033 * the rule will not fail due to a collision.
4035 * -ENOMEM: not enough memory to execute the function, or if the device
4036 * supports resource validation, resource limitation on the device.
4038 * -EBUSY: action cannot be performed due to busy device resources, may
4039 * succeed if the affected queues or even the entire port are in a stopped
4040 * state (see rte_eth_dev_rx_queue_stop() and rte_eth_dev_stop()).
4043 rte_flow_validate(uint16_t port_id,
4044 const struct rte_flow_attr *attr,
4045 const struct rte_flow_item pattern[],
4046 const struct rte_flow_action actions[],
4047 struct rte_flow_error *error);
4050 * Create a flow rule on a given port.
4053 * Port identifier of Ethernet device.
4055 * Flow rule attributes.
4056 * @param[in] pattern
4057 * Pattern specification (list terminated by the END pattern item).
4058 * @param[in] actions
4059 * Associated actions (list terminated by the END action).
4061 * Perform verbose error reporting if not NULL. PMDs initialize this
4062 * structure in case of error only.
4065 * A valid handle in case of success, NULL otherwise and rte_errno is set
4066 * to the positive version of one of the error codes defined for
4067 * rte_flow_validate().
4070 rte_flow_create(uint16_t port_id,
4071 const struct rte_flow_attr *attr,
4072 const struct rte_flow_item pattern[],
4073 const struct rte_flow_action actions[],
4074 struct rte_flow_error *error);
4077 * Destroy a flow rule on a given port.
4079 * Failure to destroy a flow rule handle may occur when other flow rules
4080 * depend on it, and destroying it would result in an inconsistent state.
4082 * This function is only guaranteed to succeed if handles are destroyed in
4083 * reverse order of their creation.
4086 * Port identifier of Ethernet device.
4088 * Flow rule handle to destroy.
4090 * Perform verbose error reporting if not NULL. PMDs initialize this
4091 * structure in case of error only.
4094 * 0 on success, a negative errno value otherwise and rte_errno is set.
4097 rte_flow_destroy(uint16_t port_id,
4098 struct rte_flow *flow,
4099 struct rte_flow_error *error);
4102 * Destroy all flow rules associated with a port.
4104 * In the unlikely event of failure, handles are still considered destroyed
4105 * and no longer valid but the port must be assumed to be in an inconsistent
4109 * Port identifier of Ethernet device.
4111 * Perform verbose error reporting if not NULL. PMDs initialize this
4112 * structure in case of error only.
4115 * 0 on success, a negative errno value otherwise and rte_errno is set.
4118 rte_flow_flush(uint16_t port_id,
4119 struct rte_flow_error *error);
4122 * Query an existing flow rule.
4124 * This function allows retrieving flow-specific data such as counters.
4125 * Data is gathered by special actions which must be present in the flow
4128 * \see RTE_FLOW_ACTION_TYPE_COUNT
4131 * Port identifier of Ethernet device.
4133 * Flow rule handle to query.
4135 * Action definition as defined in original flow rule.
4136 * @param[in, out] data
4137 * Pointer to storage for the associated query data type.
4139 * Perform verbose error reporting if not NULL. PMDs initialize this
4140 * structure in case of error only.
4143 * 0 on success, a negative errno value otherwise and rte_errno is set.
4146 rte_flow_query(uint16_t port_id,
4147 struct rte_flow *flow,
4148 const struct rte_flow_action *action,
4150 struct rte_flow_error *error);
4153 * Restrict ingress traffic to the defined flow rules.
4155 * Isolated mode guarantees that all ingress traffic comes from defined flow
4156 * rules only (current and future).
4158 * Besides making ingress more deterministic, it allows PMDs to safely reuse
4159 * resources otherwise assigned to handle the remaining traffic, such as
4160 * global RSS configuration settings, VLAN filters, MAC address entries,
4161 * legacy filter API rules and so on in order to expand the set of possible
4164 * Calling this function as soon as possible after device initialization,
4165 * ideally before the first call to rte_eth_dev_configure(), is recommended
4166 * to avoid possible failures due to conflicting settings.
4168 * Once effective, leaving isolated mode may not be possible depending on
4169 * PMD implementation.
4171 * Additionally, the following functionality has no effect on the underlying
4172 * port and may return errors such as ENOTSUP ("not supported"):
4174 * - Toggling promiscuous mode.
4175 * - Toggling allmulticast mode.
4176 * - Configuring MAC addresses.
4177 * - Configuring multicast addresses.
4178 * - Configuring VLAN filters.
4179 * - Configuring Rx filters through the legacy API (e.g. FDIR).
4180 * - Configuring global RSS settings.
4183 * Port identifier of Ethernet device.
4185 * Nonzero to enter isolated mode, attempt to leave it otherwise.
4187 * Perform verbose error reporting if not NULL. PMDs initialize this
4188 * structure in case of error only.
4191 * 0 on success, a negative errno value otherwise and rte_errno is set.
4194 rte_flow_isolate(uint16_t port_id, int set, struct rte_flow_error *error);
4197 * Initialize flow error structure.
4200 * Pointer to flow error structure (may be NULL).
4202 * Related error code (rte_errno).
4204 * Cause field and error types.
4206 * Object responsible for the error.
4208 * Human-readable error message.
4211 * Negative error code (errno value) and rte_errno is set.
4214 rte_flow_error_set(struct rte_flow_error *error,
4216 enum rte_flow_error_type type,
4218 const char *message);
4222 * @see rte_flow_copy()
4224 struct rte_flow_desc {
4225 size_t size; /**< Allocated space including data[]. */
4226 struct rte_flow_attr attr; /**< Attributes. */
4227 struct rte_flow_item *items; /**< Items. */
4228 struct rte_flow_action *actions; /**< Actions. */
4229 uint8_t data[]; /**< Storage for items/actions. */
4234 * Copy an rte_flow rule description.
4236 * This interface is kept for compatibility with older applications but is
4237 * implemented as a wrapper to rte_flow_conv(). It is deprecated due to its
4238 * lack of flexibility and reliance on a type unusable with C++ programs
4239 * (struct rte_flow_desc).
4242 * Flow rule description.
4244 * Total size of allocated data for the flow description.
4246 * Flow rule attributes.
4248 * Pattern specification (list terminated by the END pattern item).
4249 * @param[in] actions
4250 * Associated actions (list terminated by the END action).
4253 * If len is greater or equal to the size of the flow, the total size of the
4254 * flow description and its data.
4255 * If len is lower than the size of the flow, the number of bytes that would
4256 * have been written to desc had it been sufficient. Nothing is written.
4260 rte_flow_copy(struct rte_flow_desc *fd, size_t len,
4261 const struct rte_flow_attr *attr,
4262 const struct rte_flow_item *items,
4263 const struct rte_flow_action *actions);
4266 * Flow object conversion helper.
4268 * This function performs conversion of various flow API objects to a
4269 * pre-allocated destination buffer. See enum rte_flow_conv_op for possible
4270 * operations and details about each of them.
4272 * Since destination buffer must be large enough, it works in a manner
4273 * reminiscent of snprintf():
4275 * - If @p size is 0, @p dst may be a NULL pointer, otherwise @p dst must be
4277 * - If positive, the returned value represents the number of bytes needed
4278 * to store the conversion of @p src to @p dst according to @p op
4279 * regardless of the @p size parameter.
4280 * - Since no more than @p size bytes can be written to @p dst, output is
4281 * truncated and may be inconsistent when the returned value is larger
4283 * - In case of conversion error, a negative error code is returned and
4284 * @p dst contents are unspecified.
4287 * Operation to perform, related to the object type of @p dst.
4289 * Destination buffer address. Must be suitably aligned by the caller.
4291 * Destination buffer size in bytes.
4293 * Source object to copy. Depending on @p op, its type may differ from
4296 * Perform verbose error reporting if not NULL. Initialized in case of
4300 * The number of bytes required to convert @p src to @p dst on success, a
4301 * negative errno value otherwise and rte_errno is set.
4303 * @see rte_flow_conv_op
4307 rte_flow_conv(enum rte_flow_conv_op op,
4311 struct rte_flow_error *error);
4314 * Get aged-out flows of a given port.
4316 * RTE_ETH_EVENT_FLOW_AGED event will be triggered when at least one new aged
4317 * out flow was detected after the last call to rte_flow_get_aged_flows.
4318 * This function can be called to get the aged flows usynchronously from the
4319 * event callback or synchronously regardless the event.
4320 * This is not safe to call rte_flow_get_aged_flows function with other flow
4321 * functions from multiple threads simultaneously.
4324 * Port identifier of Ethernet device.
4325 * @param[in, out] contexts
4326 * The address of an array of pointers to the aged-out flows contexts.
4327 * @param[in] nb_contexts
4328 * The length of context array pointers.
4330 * Perform verbose error reporting if not NULL. Initialized in case of
4334 * if nb_contexts is 0, return the amount of all aged contexts.
4335 * if nb_contexts is not 0 , return the amount of aged flows reported
4336 * in the context array, otherwise negative errno value.
4338 * @see rte_flow_action_age
4339 * @see RTE_ETH_EVENT_FLOW_AGED
4343 rte_flow_get_aged_flows(uint16_t port_id, void **contexts,
4344 uint32_t nb_contexts, struct rte_flow_error *error);
4347 * Specify indirect action object configuration
4349 struct rte_flow_indir_action_conf {
4351 * Flow direction for the indirect action configuration.
4353 * Action should be valid at least for one flow direction,
4354 * otherwise it is invalid for both ingress and egress rules.
4356 /** Action valid for rules applied to ingress traffic. */
4358 /** Action valid for rules applied to egress traffic. */
4361 * When set to 1, indicates that the action is valid for
4362 * transfer traffic; otherwise, for non-transfer traffic.
4364 uint32_t transfer:1;
4369 * @b EXPERIMENTAL: this API may change without prior notice.
4371 * Create an indirect action object that can be used in flow rules
4373 * The created object handle has single state and configuration
4374 * across all the flow rules using it.
4376 * @param[in] port_id
4377 * The port identifier of the Ethernet device.
4379 * Action configuration for the indirect action object creation.
4381 * Specific configuration of the indirect action object.
4383 * Perform verbose error reporting if not NULL. PMDs initialize this
4384 * structure in case of error only.
4386 * A valid handle in case of success, NULL otherwise and rte_errno is set
4387 * to one of the error codes defined:
4388 * - (ENODEV) if *port_id* invalid.
4389 * - (ENOSYS) if underlying device does not support this functionality.
4390 * - (EIO) if underlying device is removed.
4391 * - (EINVAL) if *action* invalid.
4392 * - (ENOTSUP) if *action* valid but unsupported.
4395 struct rte_flow_action_handle *
4396 rte_flow_action_handle_create(uint16_t port_id,
4397 const struct rte_flow_indir_action_conf *conf,
4398 const struct rte_flow_action *action,
4399 struct rte_flow_error *error);
4403 * @b EXPERIMENTAL: this API may change without prior notice.
4405 * Destroy indirect action by handle.
4407 * @param[in] port_id
4408 * The port identifier of the Ethernet device.
4410 * Handle for the indirect action object to be destroyed.
4412 * Perform verbose error reporting if not NULL. PMDs initialize this
4413 * structure in case of error only.
4416 * - (-ENODEV) if *port_id* invalid.
4417 * - (-ENOSYS) if underlying device does not support this functionality.
4418 * - (-EIO) if underlying device is removed.
4419 * - (-ENOENT) if action pointed by *action* handle was not found.
4420 * - (-EBUSY) if action pointed by *action* handle still used by some rules
4421 * rte_errno is also set.
4425 rte_flow_action_handle_destroy(uint16_t port_id,
4426 struct rte_flow_action_handle *handle,
4427 struct rte_flow_error *error);
4431 * @b EXPERIMENTAL: this API may change without prior notice.
4433 * Update in-place the action configuration and / or state pointed
4434 * by action *handle* with the configuration provided as *update* argument.
4435 * The update of the action configuration effects all flow rules reusing
4436 * the action via *handle*.
4437 * The update general pointer provides the ability of partial updating.
4439 * @param[in] port_id
4440 * The port identifier of the Ethernet device.
4442 * Handle for the indirect action object to be updated.
4444 * Update profile specification used to modify the action pointed by handle.
4445 * *update* could be with the same type of the immediate action corresponding
4446 * to the *handle* argument when creating, or a wrapper structure includes
4447 * action configuration to be updated and bit fields to indicate the member
4448 * of fields inside the action to update.
4450 * Perform verbose error reporting if not NULL. PMDs initialize this
4451 * structure in case of error only.
4454 * - (-ENODEV) if *port_id* invalid.
4455 * - (-ENOSYS) if underlying device does not support this functionality.
4456 * - (-EIO) if underlying device is removed.
4457 * - (-EINVAL) if *update* invalid.
4458 * - (-ENOTSUP) if *update* valid but unsupported.
4459 * - (-ENOENT) if indirect action object pointed by *handle* was not found.
4460 * rte_errno is also set.
4464 rte_flow_action_handle_update(uint16_t port_id,
4465 struct rte_flow_action_handle *handle,
4467 struct rte_flow_error *error);
4471 * @b EXPERIMENTAL: this API may change without prior notice.
4473 * Query the direct action by corresponding indirect action object handle.
4475 * Retrieve action-specific data such as counters.
4476 * Data is gathered by special action which may be present/referenced in
4477 * more than one flow rule definition.
4479 * @see RTE_FLOW_ACTION_TYPE_COUNT
4482 * Port identifier of Ethernet device.
4484 * Handle for the action object to query.
4485 * @param[in, out] data
4486 * Pointer to storage for the associated query data type.
4488 * Perform verbose error reporting if not NULL. PMDs initialize this
4489 * structure in case of error only.
4492 * 0 on success, a negative errno value otherwise and rte_errno is set.
4496 rte_flow_action_handle_query(uint16_t port_id,
4497 const struct rte_flow_action_handle *handle,
4498 void *data, struct rte_flow_error *error);
4500 /* Tunnel has a type and the key information. */
4501 struct rte_flow_tunnel {
4503 * Tunnel type, for example RTE_FLOW_ITEM_TYPE_VXLAN,
4504 * RTE_FLOW_ITEM_TYPE_NVGRE etc.
4506 enum rte_flow_item_type type;
4507 uint64_t tun_id; /**< Tunnel identification. */
4512 rte_be32_t src_addr; /**< IPv4 source address. */
4513 rte_be32_t dst_addr; /**< IPv4 destination address. */
4516 uint8_t src_addr[16]; /**< IPv6 source address. */
4517 uint8_t dst_addr[16]; /**< IPv6 destination address. */
4520 rte_be16_t tp_src; /**< Tunnel port source. */
4521 rte_be16_t tp_dst; /**< Tunnel port destination. */
4522 uint16_t tun_flags; /**< Tunnel flags. */
4524 bool is_ipv6; /**< True for valid IPv6 fields. Otherwise IPv4. */
4527 * the following members are required to restore packet
4530 uint8_t tos; /**< TOS for IPv4, TC for IPv6. */
4531 uint8_t ttl; /**< TTL for IPv4, HL for IPv6. */
4532 uint32_t label; /**< Flow Label for IPv6. */
4536 * Indicate that the packet has a tunnel.
4538 #define RTE_FLOW_RESTORE_INFO_TUNNEL RTE_BIT64(0)
4541 * Indicate that the packet has a non decapsulated tunnel header.
4543 #define RTE_FLOW_RESTORE_INFO_ENCAPSULATED RTE_BIT64(1)
4546 * Indicate that the packet has a group_id.
4548 #define RTE_FLOW_RESTORE_INFO_GROUP_ID RTE_BIT64(2)
4551 * Restore information structure to communicate the current packet processing
4552 * state when some of the processing pipeline is done in hardware and should
4553 * continue in software.
4555 struct rte_flow_restore_info {
4557 * Bitwise flags (RTE_FLOW_RESTORE_INFO_*) to indicate validation of
4558 * other fields in struct rte_flow_restore_info.
4561 uint32_t group_id; /**< Group ID where packed missed */
4562 struct rte_flow_tunnel tunnel; /**< Tunnel information. */
4566 * Allocate an array of actions to be used in rte_flow_create, to implement
4567 * tunnel-decap-set for the given tunnel.
4569 * actions vxlan_decap / tunnel-decap-set(tunnel properties) /
4570 * jump group 0 / end
4573 * Port identifier of Ethernet device.
4575 * Tunnel properties.
4576 * @param[out] actions
4577 * Array of actions to be allocated by the PMD. This array should be
4578 * concatenated with the actions array provided to rte_flow_create.
4579 * @param[out] num_of_actions
4580 * Number of actions allocated.
4582 * Perform verbose error reporting if not NULL. PMDs initialize this
4583 * structure in case of error only.
4586 * 0 on success, a negative errno value otherwise and rte_errno is set.
4590 rte_flow_tunnel_decap_set(uint16_t port_id,
4591 struct rte_flow_tunnel *tunnel,
4592 struct rte_flow_action **actions,
4593 uint32_t *num_of_actions,
4594 struct rte_flow_error *error);
4597 * Allocate an array of items to be used in rte_flow_create, to implement
4598 * tunnel-match for the given tunnel.
4600 * pattern tunnel-match(tunnel properties) / outer-header-matches /
4601 * inner-header-matches / end
4604 * Port identifier of Ethernet device.
4606 * Tunnel properties.
4608 * Array of items to be allocated by the PMD. This array should be
4609 * concatenated with the items array provided to rte_flow_create.
4610 * @param[out] num_of_items
4611 * Number of items allocated.
4613 * Perform verbose error reporting if not NULL. PMDs initialize this
4614 * structure in case of error only.
4617 * 0 on success, a negative errno value otherwise and rte_errno is set.
4621 rte_flow_tunnel_match(uint16_t port_id,
4622 struct rte_flow_tunnel *tunnel,
4623 struct rte_flow_item **items,
4624 uint32_t *num_of_items,
4625 struct rte_flow_error *error);
4628 * Populate the current packet processing state, if exists, for the given mbuf.
4630 * One should negotiate tunnel metadata delivery from the NIC to the HW.
4631 * @see rte_eth_rx_metadata_negotiate()
4632 * @see RTE_ETH_RX_METADATA_TUNNEL_ID
4635 * Port identifier of Ethernet device.
4639 * Restore information. Upon success contains the HW state.
4641 * Perform verbose error reporting if not NULL. PMDs initialize this
4642 * structure in case of error only.
4645 * 0 on success, a negative errno value otherwise and rte_errno is set.
4649 rte_flow_get_restore_info(uint16_t port_id,
4651 struct rte_flow_restore_info *info,
4652 struct rte_flow_error *error);
4655 * Release the action array as allocated by rte_flow_tunnel_decap_set.
4658 * Port identifier of Ethernet device.
4659 * @param[in] actions
4660 * Array of actions to be released.
4661 * @param[in] num_of_actions
4662 * Number of elements in actions array.
4664 * Perform verbose error reporting if not NULL. PMDs initialize this
4665 * structure in case of error only.
4668 * 0 on success, a negative errno value otherwise and rte_errno is set.
4672 rte_flow_tunnel_action_decap_release(uint16_t port_id,
4673 struct rte_flow_action *actions,
4674 uint32_t num_of_actions,
4675 struct rte_flow_error *error);
4678 * Release the item array as allocated by rte_flow_tunnel_match.
4681 * Port identifier of Ethernet device.
4683 * Array of items to be released.
4684 * @param[in] num_of_items
4685 * Number of elements in item array.
4687 * Perform verbose error reporting if not NULL. PMDs initialize this
4688 * structure in case of error only.
4691 * 0 on success, a negative errno value otherwise and rte_errno is set.
4695 rte_flow_tunnel_item_release(uint16_t port_id,
4696 struct rte_flow_item *items,
4697 uint32_t num_of_items,
4698 struct rte_flow_error *error);
4702 * @b EXPERIMENTAL: this API may change without prior notice.
4704 * Get a proxy port to manage "transfer" flows.
4706 * Managing "transfer" flows requires that the user communicate them
4707 * via a port which has the privilege to control the embedded switch.
4708 * For some vendors, all ports in a given switching domain have
4709 * this privilege. For other vendors, it's only one port.
4711 * This API indicates such a privileged port (a "proxy")
4712 * for a given port in the same switching domain.
4715 * If the PMD serving @p port_id doesn't have the corresponding method
4716 * implemented, the API will return @p port_id via @p proxy_port_id.
4719 * Indicates the port to get a "proxy" for
4720 * @param[out] proxy_port_id
4721 * Indicates the "proxy" port
4723 * If not NULL, allows the PMD to provide verbose report in case of error
4726 * 0 on success, a negative error code otherwise
4730 rte_flow_pick_transfer_proxy(uint16_t port_id, uint16_t *proxy_port_id,
4731 struct rte_flow_error *error);
4735 * @b EXPERIMENTAL: this API may change without prior notice.
4737 * Create the flex item with specified configuration over
4738 * the Ethernet device.
4741 * Port identifier of Ethernet device.
4743 * Item configuration.
4745 * Perform verbose error reporting if not NULL. PMDs initialize this
4746 * structure in case of error only.
4749 * Non-NULL opaque pointer on success, NULL otherwise and rte_errno is set.
4752 struct rte_flow_item_flex_handle *
4753 rte_flow_flex_item_create(uint16_t port_id,
4754 const struct rte_flow_item_flex_conf *conf,
4755 struct rte_flow_error *error);
4758 * Release the flex item on the specified Ethernet device.
4761 * Port identifier of Ethernet device.
4763 * Handle of the item existing on the specified device.
4765 * Perform verbose error reporting if not NULL. PMDs initialize this
4766 * structure in case of error only.
4769 * 0 on success, a negative errno value otherwise and rte_errno is set.
4773 rte_flow_flex_item_release(uint16_t port_id,
4774 const struct rte_flow_item_flex_handle *handle,
4775 struct rte_flow_error *error);
4781 #endif /* RTE_FLOW_H_ */