1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright 2016 6WIND S.A.
3 * Copyright 2016 Mellanox Technologies, Ltd
11 * RTE generic flow API
13 * This interface provides the ability to program packet matching and
14 * associated actions in hardware through flow rules.
21 #include <rte_common.h>
22 #include <rte_ether.h>
28 #include <rte_vxlan.h>
29 #include <rte_byteorder.h>
31 #include <rte_higig.h>
32 #include <rte_ecpri.h>
33 #include <rte_bitops.h>
35 #include <rte_mbuf_dyn.h>
36 #include <rte_meter.h>
44 * Flow rule attributes.
46 * Priorities are set on a per rule based within groups.
48 * Lower values denote higher priority, the highest priority for a flow rule
49 * is 0, so that a flow that matches for than one rule, the rule with the
50 * lowest priority value will always be matched.
52 * Although optional, applications are encouraged to group similar rules as
53 * much as possible to fully take advantage of hardware capabilities
54 * (e.g. optimized matching) and work around limitations (e.g. a single
55 * pattern type possibly allowed in a given group). Applications should be
56 * aware that groups are not linked by default, and that they must be
57 * explicitly linked by the application using the JUMP action.
59 * Priority levels are arbitrary and up to the application, they
60 * do not need to be contiguous nor start from 0, however the maximum number
61 * varies between devices and may be affected by existing flow rules.
63 * If a packet is matched by several rules of a given group for a given
64 * priority level, the outcome is undefined. It can take any path, may be
65 * duplicated or even cause unrecoverable errors.
67 * Note that support for more than a single group and priority level is not
70 * Flow rules can apply to inbound and/or outbound traffic (ingress/egress).
72 * Several pattern items and actions are valid and can be used in both
73 * directions. Those valid for only one direction are described as such.
75 * At least one direction must be specified.
77 * Specifying both directions at once for a given rule is not recommended
78 * but may be valid in a few cases.
80 struct rte_flow_attr {
81 uint32_t group; /**< Priority group. */
82 uint32_t priority; /**< Rule priority level within group. */
83 uint32_t ingress:1; /**< Rule applies to ingress traffic. */
84 uint32_t egress:1; /**< Rule applies to egress traffic. */
86 * Instead of simply matching the properties of traffic as it would
87 * appear on a given DPDK port ID, enabling this attribute transfers
88 * a flow rule to the lowest possible level of any device endpoints
89 * found in the pattern.
91 * When supported, this effectively enables an application to
92 * re-route traffic not necessarily intended for it (e.g. coming
93 * from or addressed to different physical ports, VFs or
94 * applications) at the device level.
96 * It complements the behavior of some pattern items such as
97 * RTE_FLOW_ITEM_TYPE_PHY_PORT and is meaningless without them.
99 * When transferring flow rules, ingress and egress attributes keep
100 * their original meaning, as if processing traffic emitted or
101 * received by the application.
104 uint32_t reserved:29; /**< Reserved, must be zero. */
108 * Matching pattern item types.
110 * Pattern items fall in two categories:
112 * - Matching protocol headers and packet data, usually associated with a
113 * specification structure. These must be stacked in the same order as the
114 * protocol layers to match inside packets, starting from the lowest.
116 * - Matching meta-data or affecting pattern processing, often without a
117 * specification structure. Since they do not match packet contents, their
118 * position in the list is usually not relevant.
120 * See the description of individual types for more information. Those
121 * marked with [META] fall into the second category.
123 enum rte_flow_item_type {
127 * End marker for item lists. Prevents further processing of items,
128 * thereby ending the pattern.
130 * No associated specification structure.
132 RTE_FLOW_ITEM_TYPE_END,
137 * Used as a placeholder for convenience. It is ignored and simply
140 * No associated specification structure.
142 RTE_FLOW_ITEM_TYPE_VOID,
147 * Inverted matching, i.e. process packets that do not match the
150 * No associated specification structure.
152 RTE_FLOW_ITEM_TYPE_INVERT,
155 * Matches any protocol in place of the current layer, a single ANY
156 * may also stand for several protocol layers.
158 * See struct rte_flow_item_any.
160 RTE_FLOW_ITEM_TYPE_ANY,
165 * Matches traffic originating from (ingress) or going to (egress)
166 * the physical function of the current device.
168 * No associated specification structure.
170 RTE_FLOW_ITEM_TYPE_PF,
175 * Matches traffic originating from (ingress) or going to (egress) a
176 * given virtual function of the current device.
178 * See struct rte_flow_item_vf.
180 RTE_FLOW_ITEM_TYPE_VF,
185 * Matches traffic originating from (ingress) or going to (egress) a
186 * physical port of the underlying device.
188 * See struct rte_flow_item_phy_port.
190 RTE_FLOW_ITEM_TYPE_PHY_PORT,
195 * Matches traffic originating from (ingress) or going to (egress) a
196 * given DPDK port ID.
198 * See struct rte_flow_item_port_id.
200 RTE_FLOW_ITEM_TYPE_PORT_ID,
203 * Matches a byte string of a given length at a given offset.
205 * See struct rte_flow_item_raw.
207 RTE_FLOW_ITEM_TYPE_RAW,
210 * Matches an Ethernet header.
212 * See struct rte_flow_item_eth.
214 RTE_FLOW_ITEM_TYPE_ETH,
217 * Matches an 802.1Q/ad VLAN tag.
219 * See struct rte_flow_item_vlan.
221 RTE_FLOW_ITEM_TYPE_VLAN,
224 * Matches an IPv4 header.
226 * See struct rte_flow_item_ipv4.
228 RTE_FLOW_ITEM_TYPE_IPV4,
231 * Matches an IPv6 header.
233 * See struct rte_flow_item_ipv6.
235 RTE_FLOW_ITEM_TYPE_IPV6,
238 * Matches an ICMP header.
240 * See struct rte_flow_item_icmp.
242 RTE_FLOW_ITEM_TYPE_ICMP,
245 * Matches a UDP header.
247 * See struct rte_flow_item_udp.
249 RTE_FLOW_ITEM_TYPE_UDP,
252 * Matches a TCP header.
254 * See struct rte_flow_item_tcp.
256 RTE_FLOW_ITEM_TYPE_TCP,
259 * Matches a SCTP header.
261 * See struct rte_flow_item_sctp.
263 RTE_FLOW_ITEM_TYPE_SCTP,
266 * Matches a VXLAN header.
268 * See struct rte_flow_item_vxlan.
270 RTE_FLOW_ITEM_TYPE_VXLAN,
273 * Matches a E_TAG header.
275 * See struct rte_flow_item_e_tag.
277 RTE_FLOW_ITEM_TYPE_E_TAG,
280 * Matches a NVGRE header.
282 * See struct rte_flow_item_nvgre.
284 RTE_FLOW_ITEM_TYPE_NVGRE,
287 * Matches a MPLS header.
289 * See struct rte_flow_item_mpls.
291 RTE_FLOW_ITEM_TYPE_MPLS,
294 * Matches a GRE header.
296 * See struct rte_flow_item_gre.
298 RTE_FLOW_ITEM_TYPE_GRE,
303 * Fuzzy pattern match, expect faster than default.
305 * This is for device that support fuzzy matching option.
306 * Usually a fuzzy matching is fast but the cost is accuracy.
308 * See struct rte_flow_item_fuzzy.
310 RTE_FLOW_ITEM_TYPE_FUZZY,
313 * Matches a GTP header.
315 * Configure flow for GTP packets.
317 * See struct rte_flow_item_gtp.
319 RTE_FLOW_ITEM_TYPE_GTP,
322 * Matches a GTP header.
324 * Configure flow for GTP-C packets.
326 * See struct rte_flow_item_gtp.
328 RTE_FLOW_ITEM_TYPE_GTPC,
331 * Matches a GTP header.
333 * Configure flow for GTP-U packets.
335 * See struct rte_flow_item_gtp.
337 RTE_FLOW_ITEM_TYPE_GTPU,
340 * Matches a ESP header.
342 * See struct rte_flow_item_esp.
344 RTE_FLOW_ITEM_TYPE_ESP,
347 * Matches a GENEVE header.
349 * See struct rte_flow_item_geneve.
351 RTE_FLOW_ITEM_TYPE_GENEVE,
354 * Matches a VXLAN-GPE header.
356 * See struct rte_flow_item_vxlan_gpe.
358 RTE_FLOW_ITEM_TYPE_VXLAN_GPE,
361 * Matches an ARP header for Ethernet/IPv4.
363 * See struct rte_flow_item_arp_eth_ipv4.
365 RTE_FLOW_ITEM_TYPE_ARP_ETH_IPV4,
368 * Matches the presence of any IPv6 extension header.
370 * See struct rte_flow_item_ipv6_ext.
372 RTE_FLOW_ITEM_TYPE_IPV6_EXT,
375 * Matches any ICMPv6 header.
377 * See struct rte_flow_item_icmp6.
379 RTE_FLOW_ITEM_TYPE_ICMP6,
382 * Matches an ICMPv6 neighbor discovery solicitation.
384 * See struct rte_flow_item_icmp6_nd_ns.
386 RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS,
389 * Matches an ICMPv6 neighbor discovery advertisement.
391 * See struct rte_flow_item_icmp6_nd_na.
393 RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA,
396 * Matches the presence of any ICMPv6 neighbor discovery option.
398 * See struct rte_flow_item_icmp6_nd_opt.
400 RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT,
403 * Matches an ICMPv6 neighbor discovery source Ethernet link-layer
406 * See struct rte_flow_item_icmp6_nd_opt_sla_eth.
408 RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_SLA_ETH,
411 * Matches an ICMPv6 neighbor discovery target Ethernet link-layer
414 * See struct rte_flow_item_icmp6_nd_opt_tla_eth.
416 RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_TLA_ETH,
419 * Matches specified mark field.
421 * See struct rte_flow_item_mark.
423 RTE_FLOW_ITEM_TYPE_MARK,
428 * Matches a metadata value.
430 * See struct rte_flow_item_meta.
432 RTE_FLOW_ITEM_TYPE_META,
435 * Matches a GRE optional key field.
437 * The value should a big-endian 32bit integer.
439 * When this item present the K bit is implicitly matched as "1"
440 * in the default mask.
443 * @code rte_be32_t * @endcode
445 RTE_FLOW_ITEM_TYPE_GRE_KEY,
448 * Matches a GTP extension header: PDU session container.
450 * Configure flow for GTP packets with extension header type 0x85.
452 * See struct rte_flow_item_gtp_psc.
454 RTE_FLOW_ITEM_TYPE_GTP_PSC,
457 * Matches a PPPoE header.
459 * Configure flow for PPPoE session packets.
461 * See struct rte_flow_item_pppoe.
463 RTE_FLOW_ITEM_TYPE_PPPOES,
466 * Matches a PPPoE header.
468 * Configure flow for PPPoE discovery packets.
470 * See struct rte_flow_item_pppoe.
472 RTE_FLOW_ITEM_TYPE_PPPOED,
475 * Matches a PPPoE optional proto_id field.
477 * It only applies to PPPoE session packets.
479 * See struct rte_flow_item_pppoe_proto_id.
481 RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID,
484 * Matches Network service header (NSH).
485 * See struct rte_flow_item_nsh.
488 RTE_FLOW_ITEM_TYPE_NSH,
491 * Matches Internet Group Management Protocol (IGMP).
492 * See struct rte_flow_item_igmp.
495 RTE_FLOW_ITEM_TYPE_IGMP,
498 * Matches IP Authentication Header (AH).
499 * See struct rte_flow_item_ah.
502 RTE_FLOW_ITEM_TYPE_AH,
505 * Matches a HIGIG header.
506 * see struct rte_flow_item_higig2_hdr.
508 RTE_FLOW_ITEM_TYPE_HIGIG2,
513 * Matches a tag value.
515 * See struct rte_flow_item_tag.
517 RTE_FLOW_ITEM_TYPE_TAG,
520 * Matches a L2TPv3 over IP header.
522 * Configure flow for L2TPv3 over IP packets.
524 * See struct rte_flow_item_l2tpv3oip.
526 RTE_FLOW_ITEM_TYPE_L2TPV3OIP,
529 * Matches PFCP Header.
530 * See struct rte_flow_item_pfcp.
533 RTE_FLOW_ITEM_TYPE_PFCP,
536 * Matches eCPRI Header.
538 * Configure flow for eCPRI over ETH or UDP packets.
540 * See struct rte_flow_item_ecpri.
542 RTE_FLOW_ITEM_TYPE_ECPRI,
545 * Matches the presence of IPv6 fragment extension header.
547 * See struct rte_flow_item_ipv6_frag_ext.
549 RTE_FLOW_ITEM_TYPE_IPV6_FRAG_EXT,
552 * Matches Geneve Variable Length Option
554 * See struct rte_flow_item_geneve_opt
556 RTE_FLOW_ITEM_TYPE_GENEVE_OPT,
561 * Matches on packet integrity.
562 * For some devices application needs to enable integration checks in HW
563 * before using this item.
565 * @see struct rte_flow_item_integrity.
567 RTE_FLOW_ITEM_TYPE_INTEGRITY,
572 * Matches conntrack state.
574 * @see struct rte_flow_item_conntrack.
576 RTE_FLOW_ITEM_TYPE_CONNTRACK,
581 * RTE_FLOW_ITEM_TYPE_HIGIG2
582 * Matches higig2 header
585 struct rte_flow_item_higig2_hdr {
586 struct rte_higig2_hdr hdr;
589 /** Default mask for RTE_FLOW_ITEM_TYPE_HIGIG2. */
591 static const struct rte_flow_item_higig2_hdr rte_flow_item_higig2_hdr_mask = {
594 .classification = 0xffff,
602 * RTE_FLOW_ITEM_TYPE_ANY
604 * Matches any protocol in place of the current layer, a single ANY may also
605 * stand for several protocol layers.
607 * This is usually specified as the first pattern item when looking for a
608 * protocol anywhere in a packet.
610 * A zeroed mask stands for any number of layers.
612 struct rte_flow_item_any {
613 uint32_t num; /**< Number of layers covered. */
616 /** Default mask for RTE_FLOW_ITEM_TYPE_ANY. */
618 static const struct rte_flow_item_any rte_flow_item_any_mask = {
624 * RTE_FLOW_ITEM_TYPE_VF
626 * Matches traffic originating from (ingress) or going to (egress) a given
627 * virtual function of the current device.
629 * If supported, should work even if the virtual function is not managed by
630 * the application and thus not associated with a DPDK port ID.
632 * Note this pattern item does not match VF representors traffic which, as
633 * separate entities, should be addressed through their own DPDK port IDs.
635 * - Can be specified multiple times to match traffic addressed to several
637 * - Can be combined with a PF item to match both PF and VF traffic.
639 * A zeroed mask can be used to match any VF ID.
641 struct rte_flow_item_vf {
642 uint32_t id; /**< VF ID. */
645 /** Default mask for RTE_FLOW_ITEM_TYPE_VF. */
647 static const struct rte_flow_item_vf rte_flow_item_vf_mask = {
653 * RTE_FLOW_ITEM_TYPE_PHY_PORT
655 * Matches traffic originating from (ingress) or going to (egress) a
656 * physical port of the underlying device.
658 * The first PHY_PORT item overrides the physical port normally associated
659 * with the specified DPDK input port (port_id). This item can be provided
660 * several times to match additional physical ports.
662 * Note that physical ports are not necessarily tied to DPDK input ports
663 * (port_id) when those are not under DPDK control. Possible values are
664 * specific to each device, they are not necessarily indexed from zero and
665 * may not be contiguous.
667 * As a device property, the list of allowed values as well as the value
668 * associated with a port_id should be retrieved by other means.
670 * A zeroed mask can be used to match any port index.
672 struct rte_flow_item_phy_port {
673 uint32_t index; /**< Physical port index. */
676 /** Default mask for RTE_FLOW_ITEM_TYPE_PHY_PORT. */
678 static const struct rte_flow_item_phy_port rte_flow_item_phy_port_mask = {
684 * RTE_FLOW_ITEM_TYPE_PORT_ID
686 * Matches traffic originating from (ingress) or going to (egress) a given
689 * Normally only supported if the port ID in question is known by the
690 * underlying PMD and related to the device the flow rule is created
693 * This must not be confused with @p PHY_PORT which refers to the physical
694 * port of a device, whereas @p PORT_ID refers to a struct rte_eth_dev
695 * object on the application side (also known as "port representor"
696 * depending on the kind of underlying device).
698 struct rte_flow_item_port_id {
699 uint32_t id; /**< DPDK port ID. */
702 /** Default mask for RTE_FLOW_ITEM_TYPE_PORT_ID. */
704 static const struct rte_flow_item_port_id rte_flow_item_port_id_mask = {
710 * RTE_FLOW_ITEM_TYPE_RAW
712 * Matches a byte string of a given length at a given offset.
714 * Offset is either absolute (using the start of the packet) or relative to
715 * the end of the previous matched item in the stack, in which case negative
716 * values are allowed.
718 * If search is enabled, offset is used as the starting point. The search
719 * area can be delimited by setting limit to a nonzero value, which is the
720 * maximum number of bytes after offset where the pattern may start.
722 * Matching a zero-length pattern is allowed, doing so resets the relative
723 * offset for subsequent items.
725 * This type does not support ranges (struct rte_flow_item.last).
727 struct rte_flow_item_raw {
728 uint32_t relative:1; /**< Look for pattern after the previous item. */
729 uint32_t search:1; /**< Search pattern from offset (see also limit). */
730 uint32_t reserved:30; /**< Reserved, must be set to zero. */
731 int32_t offset; /**< Absolute or relative offset for pattern. */
732 uint16_t limit; /**< Search area limit for start of pattern. */
733 uint16_t length; /**< Pattern length. */
734 const uint8_t *pattern; /**< Byte string to look for. */
737 /** Default mask for RTE_FLOW_ITEM_TYPE_RAW. */
739 static const struct rte_flow_item_raw rte_flow_item_raw_mask = {
742 .reserved = 0x3fffffff,
743 .offset = 0xffffffff,
751 * RTE_FLOW_ITEM_TYPE_ETH
753 * Matches an Ethernet header.
755 * Inside @p hdr field, the sub-field @p ether_type stands either for EtherType
756 * or TPID, depending on whether the item is followed by a VLAN item or not. If
757 * two VLAN items follow, the sub-field refers to the outer one, which, in turn,
758 * contains the inner TPID in the similar header field. The innermost VLAN item
759 * contains a layer-3 EtherType. All of that follows the order seen on the wire.
761 * If the field in question contains a TPID value, only tagged packets with the
762 * specified TPID will match the pattern. Alternatively, it's possible to match
763 * any type of tagged packets by means of the field @p has_vlan rather than use
764 * the EtherType/TPID field. Also, it's possible to leave the two fields unused.
765 * If this is the case, both tagged and untagged packets will match the pattern.
768 struct rte_flow_item_eth {
772 * These fields are retained for compatibility.
773 * Please switch to the new header field below.
775 struct rte_ether_addr dst; /**< Destination MAC. */
776 struct rte_ether_addr src; /**< Source MAC. */
777 rte_be16_t type; /**< EtherType or TPID. */
779 struct rte_ether_hdr hdr;
781 uint32_t has_vlan:1; /**< Packet header contains at least one VLAN. */
782 uint32_t reserved:31; /**< Reserved, must be zero. */
785 /** Default mask for RTE_FLOW_ITEM_TYPE_ETH. */
787 static const struct rte_flow_item_eth rte_flow_item_eth_mask = {
788 .hdr.dst_addr.addr_bytes = "\xff\xff\xff\xff\xff\xff",
789 .hdr.src_addr.addr_bytes = "\xff\xff\xff\xff\xff\xff",
790 .hdr.ether_type = RTE_BE16(0x0000),
795 * RTE_FLOW_ITEM_TYPE_VLAN
797 * Matches an 802.1Q/ad VLAN tag.
799 * The corresponding standard outer EtherType (TPID) values are
800 * RTE_ETHER_TYPE_VLAN or RTE_ETHER_TYPE_QINQ. It can be overridden by
801 * the preceding pattern item.
802 * If a @p VLAN item is present in the pattern, then only tagged packets will
804 * The field @p has_more_vlan can be used to match any type of tagged packets,
805 * instead of using the @p eth_proto field of @p hdr.
806 * If the @p eth_proto of @p hdr and @p has_more_vlan fields are not specified,
807 * then any tagged packets will match the pattern.
810 struct rte_flow_item_vlan {
814 * These fields are retained for compatibility.
815 * Please switch to the new header field below.
817 rte_be16_t tci; /**< Tag control information. */
818 rte_be16_t inner_type; /**< Inner EtherType or TPID. */
820 struct rte_vlan_hdr hdr;
822 uint32_t has_more_vlan:1;
823 /**< Packet header contains at least one more VLAN, after this VLAN. */
824 uint32_t reserved:31; /**< Reserved, must be zero. */
827 /** Default mask for RTE_FLOW_ITEM_TYPE_VLAN. */
829 static const struct rte_flow_item_vlan rte_flow_item_vlan_mask = {
830 .hdr.vlan_tci = RTE_BE16(0x0fff),
831 .hdr.eth_proto = RTE_BE16(0x0000),
836 * RTE_FLOW_ITEM_TYPE_IPV4
838 * Matches an IPv4 header.
840 * Note: IPv4 options are handled by dedicated pattern items.
842 struct rte_flow_item_ipv4 {
843 struct rte_ipv4_hdr hdr; /**< IPv4 header definition. */
846 /** Default mask for RTE_FLOW_ITEM_TYPE_IPV4. */
848 static const struct rte_flow_item_ipv4 rte_flow_item_ipv4_mask = {
850 .src_addr = RTE_BE32(0xffffffff),
851 .dst_addr = RTE_BE32(0xffffffff),
857 * RTE_FLOW_ITEM_TYPE_IPV6.
859 * Matches an IPv6 header.
861 * Dedicated flags indicate if header contains specific extension headers.
863 struct rte_flow_item_ipv6 {
864 struct rte_ipv6_hdr hdr; /**< IPv6 header definition. */
865 uint32_t has_hop_ext:1;
866 /**< Header contains Hop-by-Hop Options extension header. */
867 uint32_t has_route_ext:1;
868 /**< Header contains Routing extension header. */
869 uint32_t has_frag_ext:1;
870 /**< Header contains Fragment extension header. */
871 uint32_t has_auth_ext:1;
872 /**< Header contains Authentication extension header. */
873 uint32_t has_esp_ext:1;
874 /**< Header contains Encapsulation Security Payload extension header. */
875 uint32_t has_dest_ext:1;
876 /**< Header contains Destination Options extension header. */
877 uint32_t has_mobil_ext:1;
878 /**< Header contains Mobility extension header. */
879 uint32_t has_hip_ext:1;
880 /**< Header contains Host Identity Protocol extension header. */
881 uint32_t has_shim6_ext:1;
882 /**< Header contains Shim6 Protocol extension header. */
883 uint32_t reserved:23;
884 /**< Reserved for future extension headers, must be zero. */
887 /** Default mask for RTE_FLOW_ITEM_TYPE_IPV6. */
889 static const struct rte_flow_item_ipv6 rte_flow_item_ipv6_mask = {
892 "\xff\xff\xff\xff\xff\xff\xff\xff"
893 "\xff\xff\xff\xff\xff\xff\xff\xff",
895 "\xff\xff\xff\xff\xff\xff\xff\xff"
896 "\xff\xff\xff\xff\xff\xff\xff\xff",
902 * RTE_FLOW_ITEM_TYPE_ICMP.
904 * Matches an ICMP header.
906 struct rte_flow_item_icmp {
907 struct rte_icmp_hdr hdr; /**< ICMP header definition. */
910 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP. */
912 static const struct rte_flow_item_icmp rte_flow_item_icmp_mask = {
921 * RTE_FLOW_ITEM_TYPE_UDP.
923 * Matches a UDP header.
925 struct rte_flow_item_udp {
926 struct rte_udp_hdr hdr; /**< UDP header definition. */
929 /** Default mask for RTE_FLOW_ITEM_TYPE_UDP. */
931 static const struct rte_flow_item_udp rte_flow_item_udp_mask = {
933 .src_port = RTE_BE16(0xffff),
934 .dst_port = RTE_BE16(0xffff),
940 * RTE_FLOW_ITEM_TYPE_TCP.
942 * Matches a TCP header.
944 struct rte_flow_item_tcp {
945 struct rte_tcp_hdr hdr; /**< TCP header definition. */
948 /** Default mask for RTE_FLOW_ITEM_TYPE_TCP. */
950 static const struct rte_flow_item_tcp rte_flow_item_tcp_mask = {
952 .src_port = RTE_BE16(0xffff),
953 .dst_port = RTE_BE16(0xffff),
959 * RTE_FLOW_ITEM_TYPE_SCTP.
961 * Matches a SCTP header.
963 struct rte_flow_item_sctp {
964 struct rte_sctp_hdr hdr; /**< SCTP header definition. */
967 /** Default mask for RTE_FLOW_ITEM_TYPE_SCTP. */
969 static const struct rte_flow_item_sctp rte_flow_item_sctp_mask = {
971 .src_port = RTE_BE16(0xffff),
972 .dst_port = RTE_BE16(0xffff),
978 * RTE_FLOW_ITEM_TYPE_VXLAN.
980 * Matches a VXLAN header (RFC 7348).
983 struct rte_flow_item_vxlan {
987 * These fields are retained for compatibility.
988 * Please switch to the new header field below.
990 uint8_t flags; /**< Normally 0x08 (I flag). */
991 uint8_t rsvd0[3]; /**< Reserved, normally 0x000000. */
992 uint8_t vni[3]; /**< VXLAN identifier. */
993 uint8_t rsvd1; /**< Reserved, normally 0x00. */
995 struct rte_vxlan_hdr hdr;
999 /** Default mask for RTE_FLOW_ITEM_TYPE_VXLAN. */
1001 static const struct rte_flow_item_vxlan rte_flow_item_vxlan_mask = {
1002 .hdr.vx_vni = RTE_BE32(0xffffff00), /* (0xffffff << 8) */
1007 * RTE_FLOW_ITEM_TYPE_E_TAG.
1009 * Matches a E-tag header.
1011 * The corresponding standard outer EtherType (TPID) value is
1012 * RTE_ETHER_TYPE_ETAG. It can be overridden by the preceding pattern item.
1014 struct rte_flow_item_e_tag {
1016 * E-Tag control information (E-TCI).
1017 * E-PCP (3b), E-DEI (1b), ingress E-CID base (12b).
1019 rte_be16_t epcp_edei_in_ecid_b;
1020 /** Reserved (2b), GRP (2b), E-CID base (12b). */
1021 rte_be16_t rsvd_grp_ecid_b;
1022 uint8_t in_ecid_e; /**< Ingress E-CID ext. */
1023 uint8_t ecid_e; /**< E-CID ext. */
1024 rte_be16_t inner_type; /**< Inner EtherType or TPID. */
1027 /** Default mask for RTE_FLOW_ITEM_TYPE_E_TAG. */
1029 static const struct rte_flow_item_e_tag rte_flow_item_e_tag_mask = {
1030 .rsvd_grp_ecid_b = RTE_BE16(0x3fff),
1035 * RTE_FLOW_ITEM_TYPE_NVGRE.
1037 * Matches a NVGRE header.
1039 struct rte_flow_item_nvgre {
1041 * Checksum (1b), undefined (1b), key bit (1b), sequence number (1b),
1042 * reserved 0 (9b), version (3b).
1044 * c_k_s_rsvd0_ver must have value 0x2000 according to RFC 7637.
1046 rte_be16_t c_k_s_rsvd0_ver;
1047 rte_be16_t protocol; /**< Protocol type (0x6558). */
1048 uint8_t tni[3]; /**< Virtual subnet ID. */
1049 uint8_t flow_id; /**< Flow ID. */
1052 /** Default mask for RTE_FLOW_ITEM_TYPE_NVGRE. */
1054 static const struct rte_flow_item_nvgre rte_flow_item_nvgre_mask = {
1055 .tni = "\xff\xff\xff",
1060 * RTE_FLOW_ITEM_TYPE_MPLS.
1062 * Matches a MPLS header.
1064 struct rte_flow_item_mpls {
1066 * Label (20b), TC (3b), Bottom of Stack (1b).
1068 uint8_t label_tc_s[3];
1069 uint8_t ttl; /** Time-to-Live. */
1072 /** Default mask for RTE_FLOW_ITEM_TYPE_MPLS. */
1074 static const struct rte_flow_item_mpls rte_flow_item_mpls_mask = {
1075 .label_tc_s = "\xff\xff\xf0",
1080 * RTE_FLOW_ITEM_TYPE_GRE.
1082 * Matches a GRE header.
1084 struct rte_flow_item_gre {
1086 * Checksum (1b), reserved 0 (12b), version (3b).
1087 * Refer to RFC 2784.
1089 rte_be16_t c_rsvd0_ver;
1090 rte_be16_t protocol; /**< Protocol type. */
1093 /** Default mask for RTE_FLOW_ITEM_TYPE_GRE. */
1095 static const struct rte_flow_item_gre rte_flow_item_gre_mask = {
1096 .protocol = RTE_BE16(0xffff),
1101 * RTE_FLOW_ITEM_TYPE_FUZZY
1103 * Fuzzy pattern match, expect faster than default.
1105 * This is for device that support fuzzy match option.
1106 * Usually a fuzzy match is fast but the cost is accuracy.
1107 * i.e. Signature Match only match pattern's hash value, but it is
1108 * possible two different patterns have the same hash value.
1110 * Matching accuracy level can be configure by threshold.
1111 * Driver can divide the range of threshold and map to different
1112 * accuracy levels that device support.
1114 * Threshold 0 means perfect match (no fuzziness), while threshold
1115 * 0xffffffff means fuzziest match.
1117 struct rte_flow_item_fuzzy {
1118 uint32_t thresh; /**< Accuracy threshold. */
1121 /** Default mask for RTE_FLOW_ITEM_TYPE_FUZZY. */
1123 static const struct rte_flow_item_fuzzy rte_flow_item_fuzzy_mask = {
1124 .thresh = 0xffffffff,
1129 * RTE_FLOW_ITEM_TYPE_GTP.
1131 * Matches a GTPv1 header.
1133 struct rte_flow_item_gtp {
1135 * Version (3b), protocol type (1b), reserved (1b),
1136 * Extension header flag (1b),
1137 * Sequence number flag (1b),
1138 * N-PDU number flag (1b).
1140 uint8_t v_pt_rsv_flags;
1141 uint8_t msg_type; /**< Message type. */
1142 rte_be16_t msg_len; /**< Message length. */
1143 rte_be32_t teid; /**< Tunnel endpoint identifier. */
1146 /** Default mask for RTE_FLOW_ITEM_TYPE_GTP. */
1148 static const struct rte_flow_item_gtp rte_flow_item_gtp_mask = {
1149 .teid = RTE_BE32(0xffffffff),
1154 * RTE_FLOW_ITEM_TYPE_ESP
1156 * Matches an ESP header.
1158 struct rte_flow_item_esp {
1159 struct rte_esp_hdr hdr; /**< ESP header definition. */
1162 /** Default mask for RTE_FLOW_ITEM_TYPE_ESP. */
1164 static const struct rte_flow_item_esp rte_flow_item_esp_mask = {
1166 .spi = RTE_BE32(0xffffffff),
1172 * RTE_FLOW_ITEM_TYPE_GENEVE.
1174 * Matches a GENEVE header.
1176 struct rte_flow_item_geneve {
1178 * Version (2b), length of the options fields (6b), OAM packet (1b),
1179 * critical options present (1b), reserved 0 (6b).
1181 rte_be16_t ver_opt_len_o_c_rsvd0;
1182 rte_be16_t protocol; /**< Protocol type. */
1183 uint8_t vni[3]; /**< Virtual Network Identifier. */
1184 uint8_t rsvd1; /**< Reserved, normally 0x00. */
1187 /** Default mask for RTE_FLOW_ITEM_TYPE_GENEVE. */
1189 static const struct rte_flow_item_geneve rte_flow_item_geneve_mask = {
1190 .vni = "\xff\xff\xff",
1195 * RTE_FLOW_ITEM_TYPE_VXLAN_GPE (draft-ietf-nvo3-vxlan-gpe-05).
1197 * Matches a VXLAN-GPE header.
1199 struct rte_flow_item_vxlan_gpe {
1200 uint8_t flags; /**< Normally 0x0c (I and P flags). */
1201 uint8_t rsvd0[2]; /**< Reserved, normally 0x0000. */
1202 uint8_t protocol; /**< Protocol type. */
1203 uint8_t vni[3]; /**< VXLAN identifier. */
1204 uint8_t rsvd1; /**< Reserved, normally 0x00. */
1207 /** Default mask for RTE_FLOW_ITEM_TYPE_VXLAN_GPE. */
1209 static const struct rte_flow_item_vxlan_gpe rte_flow_item_vxlan_gpe_mask = {
1210 .vni = "\xff\xff\xff",
1215 * RTE_FLOW_ITEM_TYPE_ARP_ETH_IPV4
1217 * Matches an ARP header for Ethernet/IPv4.
1219 struct rte_flow_item_arp_eth_ipv4 {
1220 rte_be16_t hrd; /**< Hardware type, normally 1. */
1221 rte_be16_t pro; /**< Protocol type, normally 0x0800. */
1222 uint8_t hln; /**< Hardware address length, normally 6. */
1223 uint8_t pln; /**< Protocol address length, normally 4. */
1224 rte_be16_t op; /**< Opcode (1 for request, 2 for reply). */
1225 struct rte_ether_addr sha; /**< Sender hardware address. */
1226 rte_be32_t spa; /**< Sender IPv4 address. */
1227 struct rte_ether_addr tha; /**< Target hardware address. */
1228 rte_be32_t tpa; /**< Target IPv4 address. */
1231 /** Default mask for RTE_FLOW_ITEM_TYPE_ARP_ETH_IPV4. */
1233 static const struct rte_flow_item_arp_eth_ipv4
1234 rte_flow_item_arp_eth_ipv4_mask = {
1235 .sha.addr_bytes = "\xff\xff\xff\xff\xff\xff",
1236 .spa = RTE_BE32(0xffffffff),
1237 .tha.addr_bytes = "\xff\xff\xff\xff\xff\xff",
1238 .tpa = RTE_BE32(0xffffffff),
1243 * RTE_FLOW_ITEM_TYPE_IPV6_EXT
1245 * Matches the presence of any IPv6 extension header.
1247 * Normally preceded by any of:
1249 * - RTE_FLOW_ITEM_TYPE_IPV6
1250 * - RTE_FLOW_ITEM_TYPE_IPV6_EXT
1252 struct rte_flow_item_ipv6_ext {
1253 uint8_t next_hdr; /**< Next header. */
1256 /** Default mask for RTE_FLOW_ITEM_TYPE_IPV6_EXT. */
1259 struct rte_flow_item_ipv6_ext rte_flow_item_ipv6_ext_mask = {
1265 * RTE_FLOW_ITEM_TYPE_IPV6_FRAG_EXT
1267 * Matches the presence of IPv6 fragment extension header.
1269 * Preceded by any of:
1271 * - RTE_FLOW_ITEM_TYPE_IPV6
1272 * - RTE_FLOW_ITEM_TYPE_IPV6_EXT
1274 struct rte_flow_item_ipv6_frag_ext {
1275 struct rte_ipv6_fragment_ext hdr;
1279 * RTE_FLOW_ITEM_TYPE_ICMP6
1281 * Matches any ICMPv6 header.
1283 struct rte_flow_item_icmp6 {
1284 uint8_t type; /**< ICMPv6 type. */
1285 uint8_t code; /**< ICMPv6 code. */
1286 uint16_t checksum; /**< ICMPv6 checksum. */
1289 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6. */
1291 static const struct rte_flow_item_icmp6 rte_flow_item_icmp6_mask = {
1298 * RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS
1300 * Matches an ICMPv6 neighbor discovery solicitation.
1302 struct rte_flow_item_icmp6_nd_ns {
1303 uint8_t type; /**< ICMPv6 type, normally 135. */
1304 uint8_t code; /**< ICMPv6 code, normally 0. */
1305 rte_be16_t checksum; /**< ICMPv6 checksum. */
1306 rte_be32_t reserved; /**< Reserved, normally 0. */
1307 uint8_t target_addr[16]; /**< Target address. */
1310 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS. */
1313 struct rte_flow_item_icmp6_nd_ns rte_flow_item_icmp6_nd_ns_mask = {
1315 "\xff\xff\xff\xff\xff\xff\xff\xff"
1316 "\xff\xff\xff\xff\xff\xff\xff\xff",
1321 * RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA
1323 * Matches an ICMPv6 neighbor discovery advertisement.
1325 struct rte_flow_item_icmp6_nd_na {
1326 uint8_t type; /**< ICMPv6 type, normally 136. */
1327 uint8_t code; /**< ICMPv6 code, normally 0. */
1328 rte_be16_t checksum; /**< ICMPv6 checksum. */
1330 * Route flag (1b), solicited flag (1b), override flag (1b),
1333 rte_be32_t rso_reserved;
1334 uint8_t target_addr[16]; /**< Target address. */
1337 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA. */
1340 struct rte_flow_item_icmp6_nd_na rte_flow_item_icmp6_nd_na_mask = {
1342 "\xff\xff\xff\xff\xff\xff\xff\xff"
1343 "\xff\xff\xff\xff\xff\xff\xff\xff",
1348 * RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT
1350 * Matches the presence of any ICMPv6 neighbor discovery option.
1352 * Normally preceded by any of:
1354 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA
1355 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS
1356 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT
1358 struct rte_flow_item_icmp6_nd_opt {
1359 uint8_t type; /**< ND option type. */
1360 uint8_t length; /**< ND option length. */
1363 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT. */
1365 static const struct rte_flow_item_icmp6_nd_opt
1366 rte_flow_item_icmp6_nd_opt_mask = {
1372 * RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_SLA_ETH
1374 * Matches an ICMPv6 neighbor discovery source Ethernet link-layer address
1377 * Normally preceded by any of:
1379 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA
1380 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT
1382 struct rte_flow_item_icmp6_nd_opt_sla_eth {
1383 uint8_t type; /**< ND option type, normally 1. */
1384 uint8_t length; /**< ND option length, normally 1. */
1385 struct rte_ether_addr sla; /**< Source Ethernet LLA. */
1388 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_SLA_ETH. */
1390 static const struct rte_flow_item_icmp6_nd_opt_sla_eth
1391 rte_flow_item_icmp6_nd_opt_sla_eth_mask = {
1392 .sla.addr_bytes = "\xff\xff\xff\xff\xff\xff",
1397 * RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_TLA_ETH
1399 * Matches an ICMPv6 neighbor discovery target Ethernet link-layer address
1402 * Normally preceded by any of:
1404 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS
1405 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT
1407 struct rte_flow_item_icmp6_nd_opt_tla_eth {
1408 uint8_t type; /**< ND option type, normally 2. */
1409 uint8_t length; /**< ND option length, normally 1. */
1410 struct rte_ether_addr tla; /**< Target Ethernet LLA. */
1413 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_TLA_ETH. */
1415 static const struct rte_flow_item_icmp6_nd_opt_tla_eth
1416 rte_flow_item_icmp6_nd_opt_tla_eth_mask = {
1417 .tla.addr_bytes = "\xff\xff\xff\xff\xff\xff",
1422 * RTE_FLOW_ITEM_TYPE_META
1424 * Matches a specified metadata value. On egress, metadata can be set
1425 * either by mbuf dynamic metadata field with PKT_TX_DYNF_METADATA flag or
1426 * RTE_FLOW_ACTION_TYPE_SET_META. On ingress, RTE_FLOW_ACTION_TYPE_SET_META
1427 * sets metadata for a packet and the metadata will be reported via mbuf
1428 * metadata dynamic field with PKT_RX_DYNF_METADATA flag. The dynamic mbuf
1429 * field must be registered in advance by rte_flow_dynf_metadata_register().
1431 struct rte_flow_item_meta {
1435 /** Default mask for RTE_FLOW_ITEM_TYPE_META. */
1437 static const struct rte_flow_item_meta rte_flow_item_meta_mask = {
1443 * RTE_FLOW_ITEM_TYPE_GTP_PSC.
1445 * Matches a GTP PDU extension header with type 0x85.
1447 struct rte_flow_item_gtp_psc {
1448 struct rte_gtp_psc_generic_hdr hdr; /**< gtp psc generic hdr. */
1451 /** Default mask for RTE_FLOW_ITEM_TYPE_GTP_PSC. */
1453 static const struct rte_flow_item_gtp_psc
1454 rte_flow_item_gtp_psc_mask = {
1460 * RTE_FLOW_ITEM_TYPE_PPPOE.
1462 * Matches a PPPoE header.
1464 struct rte_flow_item_pppoe {
1466 * Version (4b), type (4b).
1468 uint8_t version_type;
1469 uint8_t code; /**< Message type. */
1470 rte_be16_t session_id; /**< Session identifier. */
1471 rte_be16_t length; /**< Payload length. */
1475 * RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID.
1477 * Matches a PPPoE optional proto_id field.
1479 * It only applies to PPPoE session packets.
1481 * Normally preceded by any of:
1483 * - RTE_FLOW_ITEM_TYPE_PPPOE
1484 * - RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID
1486 struct rte_flow_item_pppoe_proto_id {
1487 rte_be16_t proto_id; /**< PPP protocol identifier. */
1490 /** Default mask for RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID. */
1492 static const struct rte_flow_item_pppoe_proto_id
1493 rte_flow_item_pppoe_proto_id_mask = {
1494 .proto_id = RTE_BE16(0xffff),
1500 * @b EXPERIMENTAL: this structure may change without prior notice
1502 * RTE_FLOW_ITEM_TYPE_TAG
1504 * Matches a specified tag value at the specified index.
1506 struct rte_flow_item_tag {
1511 /** Default mask for RTE_FLOW_ITEM_TYPE_TAG. */
1513 static const struct rte_flow_item_tag rte_flow_item_tag_mask = {
1520 * RTE_FLOW_ITEM_TYPE_L2TPV3OIP.
1522 * Matches a L2TPv3 over IP header.
1524 struct rte_flow_item_l2tpv3oip {
1525 rte_be32_t session_id; /**< Session ID. */
1528 /** Default mask for RTE_FLOW_ITEM_TYPE_L2TPV3OIP. */
1530 static const struct rte_flow_item_l2tpv3oip rte_flow_item_l2tpv3oip_mask = {
1531 .session_id = RTE_BE32(UINT32_MAX),
1538 * @b EXPERIMENTAL: this structure may change without prior notice
1540 * RTE_FLOW_ITEM_TYPE_MARK
1542 * Matches an arbitrary integer value which was set using the ``MARK`` action
1543 * in a previously matched rule.
1545 * This item can only be specified once as a match criteria as the ``MARK``
1546 * action can only be specified once in a flow action.
1548 * This value is arbitrary and application-defined. Maximum allowed value
1549 * depends on the underlying implementation.
1551 * Depending on the underlying implementation the MARK item may be supported on
1552 * the physical device, with virtual groups in the PMD or not at all.
1554 struct rte_flow_item_mark {
1555 uint32_t id; /**< Integer value to match against. */
1558 /** Default mask for RTE_FLOW_ITEM_TYPE_MARK. */
1560 static const struct rte_flow_item_mark rte_flow_item_mark_mask = {
1567 * @b EXPERIMENTAL: this structure may change without prior notice
1569 * RTE_FLOW_ITEM_TYPE_NSH
1571 * Match network service header (NSH), RFC 8300
1574 struct rte_flow_item_nsh {
1577 uint32_t reserved:1;
1580 uint32_t reserved1:4;
1582 uint32_t next_proto:8;
1587 /** Default mask for RTE_FLOW_ITEM_TYPE_NSH. */
1589 static const struct rte_flow_item_nsh rte_flow_item_nsh_mask = {
1599 * @b EXPERIMENTAL: this structure may change without prior notice
1601 * RTE_FLOW_ITEM_TYPE_IGMP
1603 * Match Internet Group Management Protocol (IGMP), RFC 2236
1606 struct rte_flow_item_igmp {
1608 uint32_t max_resp_time:8;
1609 uint32_t checksum:16;
1610 uint32_t group_addr;
1613 /** Default mask for RTE_FLOW_ITEM_TYPE_IGMP. */
1615 static const struct rte_flow_item_igmp rte_flow_item_igmp_mask = {
1616 .group_addr = 0xffffffff,
1622 * @b EXPERIMENTAL: this structure may change without prior notice
1624 * RTE_FLOW_ITEM_TYPE_AH
1626 * Match IP Authentication Header (AH), RFC 4302
1629 struct rte_flow_item_ah {
1630 uint32_t next_hdr:8;
1631 uint32_t payload_len:8;
1632 uint32_t reserved:16;
1637 /** Default mask for RTE_FLOW_ITEM_TYPE_AH. */
1639 static const struct rte_flow_item_ah rte_flow_item_ah_mask = {
1646 * @b EXPERIMENTAL: this structure may change without prior notice
1648 * RTE_FLOW_ITEM_TYPE_PFCP
1652 struct rte_flow_item_pfcp {
1659 /** Default mask for RTE_FLOW_ITEM_TYPE_PFCP. */
1661 static const struct rte_flow_item_pfcp rte_flow_item_pfcp_mask = {
1663 .seid = RTE_BE64(UINT64_C(0xffffffffffffffff)),
1669 * @b EXPERIMENTAL: this structure may change without prior notice
1671 * RTE_FLOW_ITEM_TYPE_ECPRI
1673 * Match eCPRI Header
1675 struct rte_flow_item_ecpri {
1676 struct rte_ecpri_combined_msg_hdr hdr;
1679 /** Default mask for RTE_FLOW_ITEM_TYPE_ECPRI. */
1681 static const struct rte_flow_item_ecpri rte_flow_item_ecpri_mask = {
1691 * RTE_FLOW_ITEM_TYPE_GENEVE_OPT
1693 * Matches a GENEVE Variable Length Option
1695 struct rte_flow_item_geneve_opt {
1696 rte_be16_t option_class;
1697 uint8_t option_type;
1702 /** Default mask for RTE_FLOW_ITEM_TYPE_GENEVE_OPT. */
1704 static const struct rte_flow_item_geneve_opt
1705 rte_flow_item_geneve_opt_mask = {
1706 .option_type = 0xff,
1712 * @b EXPERIMENTAL: this structure may change without prior notice
1714 * RTE_FLOW_ITEM_TYPE_INTEGRITY
1716 * Match on packet integrity check result.
1718 struct rte_flow_item_integrity {
1719 /** Tunnel encapsulation level the item should apply to.
1720 * @see rte_flow_action_rss
1727 /** The packet is valid after passing all HW checks. */
1728 uint64_t packet_ok:1;
1729 /** L2 layer is valid after passing all HW checks. */
1731 /** L3 layer is valid after passing all HW checks. */
1733 /** L4 layer is valid after passing all HW checks. */
1735 /** L2 layer CRC is valid. */
1736 uint64_t l2_crc_ok:1;
1737 /** IPv4 layer checksum is valid. */
1738 uint64_t ipv4_csum_ok:1;
1739 /** L4 layer checksum is valid. */
1740 uint64_t l4_csum_ok:1;
1741 /** L3 length is smaller than frame length. */
1742 uint64_t l3_len_ok:1;
1743 uint64_t reserved:56;
1750 static const struct rte_flow_item_integrity
1751 rte_flow_item_integrity_mask = {
1758 * The packet is valid after conntrack checking.
1760 #define RTE_FLOW_CONNTRACK_PKT_STATE_VALID RTE_BIT32(0)
1762 * The state of the connection is changed.
1764 #define RTE_FLOW_CONNTRACK_PKT_STATE_CHANGED RTE_BIT32(1)
1766 * Error is detected on this packet for this connection and
1767 * an invalid state is set.
1769 #define RTE_FLOW_CONNTRACK_PKT_STATE_INVALID RTE_BIT32(2)
1771 * The HW connection tracking module is disabled.
1772 * It can be due to application command or an invalid state.
1774 #define RTE_FLOW_CONNTRACK_PKT_STATE_DISABLED RTE_BIT32(3)
1776 * The packet contains some bad field(s) and cannot continue
1777 * with the conntrack module checking.
1779 #define RTE_FLOW_CONNTRACK_PKT_STATE_BAD RTE_BIT32(4)
1783 * @b EXPERIMENTAL: this structure may change without prior notice
1785 * RTE_FLOW_ITEM_TYPE_CONNTRACK
1787 * Matches the state of a packet after it passed the connection tracking
1788 * examination. The state is a bitmap of one RTE_FLOW_CONNTRACK_PKT_STATE*
1789 * or a reasonable combination of these bits.
1791 struct rte_flow_item_conntrack {
1795 /** Default mask for RTE_FLOW_ITEM_TYPE_CONNTRACK. */
1797 static const struct rte_flow_item_conntrack rte_flow_item_conntrack_mask = {
1798 .flags = 0xffffffff,
1803 * Matching pattern item definition.
1805 * A pattern is formed by stacking items starting from the lowest protocol
1806 * layer to match. This stacking restriction does not apply to meta items
1807 * which can be placed anywhere in the stack without affecting the meaning
1808 * of the resulting pattern.
1810 * Patterns are terminated by END items.
1812 * The spec field should be a valid pointer to a structure of the related
1813 * item type. It may remain unspecified (NULL) in many cases to request
1814 * broad (nonspecific) matching. In such cases, last and mask must also be
1817 * Optionally, last can point to a structure of the same type to define an
1818 * inclusive range. This is mostly supported by integer and address fields,
1819 * may cause errors otherwise. Fields that do not support ranges must be set
1820 * to 0 or to the same value as the corresponding fields in spec.
1822 * Only the fields defined to nonzero values in the default masks (see
1823 * rte_flow_item_{name}_mask constants) are considered relevant by
1824 * default. This can be overridden by providing a mask structure of the
1825 * same type with applicable bits set to one. It can also be used to
1826 * partially filter out specific fields (e.g. as an alternate mean to match
1827 * ranges of IP addresses).
1829 * Mask is a simple bit-mask applied before interpreting the contents of
1830 * spec and last, which may yield unexpected results if not used
1831 * carefully. For example, if for an IPv4 address field, spec provides
1832 * 10.1.2.3, last provides 10.3.4.5 and mask provides 255.255.0.0, the
1833 * effective range becomes 10.1.0.0 to 10.3.255.255.
1835 struct rte_flow_item {
1836 enum rte_flow_item_type type; /**< Item type. */
1837 const void *spec; /**< Pointer to item specification structure. */
1838 const void *last; /**< Defines an inclusive range (spec to last). */
1839 const void *mask; /**< Bit-mask applied to spec and last. */
1845 * Each possible action is represented by a type.
1846 * An action can have an associated configuration object.
1847 * Several actions combined in a list can be assigned
1848 * to a flow rule and are performed in order.
1850 * They fall in three categories:
1852 * - Actions that modify the fate of matching traffic, for instance by
1853 * dropping or assigning it a specific destination.
1855 * - Actions that modify matching traffic contents or its properties. This
1856 * includes adding/removing encapsulation, encryption, compression and
1859 * - Actions related to the flow rule itself, such as updating counters or
1860 * making it non-terminating.
1862 * Flow rules being terminating by default, not specifying any action of the
1863 * fate kind results in undefined behavior. This applies to both ingress and
1866 * PASSTHRU, when supported, makes a flow rule non-terminating.
1868 enum rte_flow_action_type {
1870 * End marker for action lists. Prevents further processing of
1871 * actions, thereby ending the list.
1873 * No associated configuration structure.
1875 RTE_FLOW_ACTION_TYPE_END,
1878 * Used as a placeholder for convenience. It is ignored and simply
1879 * discarded by PMDs.
1881 * No associated configuration structure.
1883 RTE_FLOW_ACTION_TYPE_VOID,
1886 * Leaves traffic up for additional processing by subsequent flow
1887 * rules; makes a flow rule non-terminating.
1889 * No associated configuration structure.
1891 RTE_FLOW_ACTION_TYPE_PASSTHRU,
1894 * RTE_FLOW_ACTION_TYPE_JUMP
1896 * Redirects packets to a group on the current device.
1898 * See struct rte_flow_action_jump.
1900 RTE_FLOW_ACTION_TYPE_JUMP,
1903 * Attaches an integer value to packets and sets PKT_RX_FDIR and
1904 * PKT_RX_FDIR_ID mbuf flags.
1906 * See struct rte_flow_action_mark.
1908 * One should negotiate mark delivery from the NIC to the PMD.
1909 * @see rte_eth_rx_metadata_negotiate()
1910 * @see RTE_ETH_RX_METADATA_USER_MARK
1912 RTE_FLOW_ACTION_TYPE_MARK,
1915 * Flags packets. Similar to MARK without a specific value; only
1916 * sets the PKT_RX_FDIR mbuf flag.
1918 * No associated configuration structure.
1920 * One should negotiate flag delivery from the NIC to the PMD.
1921 * @see rte_eth_rx_metadata_negotiate()
1922 * @see RTE_ETH_RX_METADATA_USER_FLAG
1924 RTE_FLOW_ACTION_TYPE_FLAG,
1927 * Assigns packets to a given queue index.
1929 * See struct rte_flow_action_queue.
1931 RTE_FLOW_ACTION_TYPE_QUEUE,
1936 * PASSTHRU overrides this action if both are specified.
1938 * No associated configuration structure.
1940 RTE_FLOW_ACTION_TYPE_DROP,
1943 * Enables counters for this flow rule.
1945 * These counters can be retrieved and reset through rte_flow_query() or
1946 * rte_flow_action_handle_query() if the action provided via handle,
1947 * see struct rte_flow_query_count.
1949 * See struct rte_flow_action_count.
1951 RTE_FLOW_ACTION_TYPE_COUNT,
1954 * Similar to QUEUE, except RSS is additionally performed on packets
1955 * to spread them among several queues according to the provided
1958 * See struct rte_flow_action_rss.
1960 RTE_FLOW_ACTION_TYPE_RSS,
1963 * Directs matching traffic to the physical function (PF) of the
1966 * No associated configuration structure.
1968 RTE_FLOW_ACTION_TYPE_PF,
1971 * Directs matching traffic to a given virtual function of the
1974 * See struct rte_flow_action_vf.
1976 RTE_FLOW_ACTION_TYPE_VF,
1979 * Directs packets to a given physical port index of the underlying
1982 * See struct rte_flow_action_phy_port.
1984 RTE_FLOW_ACTION_TYPE_PHY_PORT,
1987 * Directs matching traffic to a given DPDK port ID.
1989 * See struct rte_flow_action_port_id.
1991 RTE_FLOW_ACTION_TYPE_PORT_ID,
1994 * Traffic metering and policing (MTR).
1996 * See struct rte_flow_action_meter.
1997 * See file rte_mtr.h for MTR object configuration.
1999 RTE_FLOW_ACTION_TYPE_METER,
2002 * Redirects packets to security engine of current device for security
2003 * processing as specified by security session.
2005 * See struct rte_flow_action_security.
2007 RTE_FLOW_ACTION_TYPE_SECURITY,
2010 * Implements OFPAT_SET_MPLS_TTL ("MPLS TTL") as defined by the
2011 * OpenFlow Switch Specification.
2013 * See struct rte_flow_action_of_set_mpls_ttl.
2015 RTE_FLOW_ACTION_TYPE_OF_SET_MPLS_TTL,
2018 * Implements OFPAT_DEC_MPLS_TTL ("decrement MPLS TTL") as defined
2019 * by the OpenFlow Switch Specification.
2021 * No associated configuration structure.
2023 RTE_FLOW_ACTION_TYPE_OF_DEC_MPLS_TTL,
2026 * Implements OFPAT_SET_NW_TTL ("IP TTL") as defined by the OpenFlow
2027 * Switch Specification.
2029 * See struct rte_flow_action_of_set_nw_ttl.
2031 RTE_FLOW_ACTION_TYPE_OF_SET_NW_TTL,
2034 * Implements OFPAT_DEC_NW_TTL ("decrement IP TTL") as defined by
2035 * the OpenFlow Switch Specification.
2037 * No associated configuration structure.
2039 RTE_FLOW_ACTION_TYPE_OF_DEC_NW_TTL,
2042 * Implements OFPAT_COPY_TTL_OUT ("copy TTL "outwards" -- from
2043 * next-to-outermost to outermost") as defined by the OpenFlow
2044 * Switch Specification.
2046 * No associated configuration structure.
2048 RTE_FLOW_ACTION_TYPE_OF_COPY_TTL_OUT,
2051 * Implements OFPAT_COPY_TTL_IN ("copy TTL "inwards" -- from
2052 * outermost to next-to-outermost") as defined by the OpenFlow
2053 * Switch Specification.
2055 * No associated configuration structure.
2057 RTE_FLOW_ACTION_TYPE_OF_COPY_TTL_IN,
2060 * Implements OFPAT_POP_VLAN ("pop the outer VLAN tag") as defined
2061 * by the OpenFlow Switch Specification.
2063 * No associated configuration structure.
2065 RTE_FLOW_ACTION_TYPE_OF_POP_VLAN,
2068 * Implements OFPAT_PUSH_VLAN ("push a new VLAN tag") as defined by
2069 * the OpenFlow Switch Specification.
2071 * See struct rte_flow_action_of_push_vlan.
2073 RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN,
2076 * Implements OFPAT_SET_VLAN_VID ("set the 802.1q VLAN id") as
2077 * defined by the OpenFlow Switch Specification.
2079 * See struct rte_flow_action_of_set_vlan_vid.
2081 RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID,
2084 * Implements OFPAT_SET_LAN_PCP ("set the 802.1q priority") as
2085 * defined by the OpenFlow Switch Specification.
2087 * See struct rte_flow_action_of_set_vlan_pcp.
2089 RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP,
2092 * Implements OFPAT_POP_MPLS ("pop the outer MPLS tag") as defined
2093 * by the OpenFlow Switch Specification.
2095 * See struct rte_flow_action_of_pop_mpls.
2097 RTE_FLOW_ACTION_TYPE_OF_POP_MPLS,
2100 * Implements OFPAT_PUSH_MPLS ("push a new MPLS tag") as defined by
2101 * the OpenFlow Switch Specification.
2103 * See struct rte_flow_action_of_push_mpls.
2105 RTE_FLOW_ACTION_TYPE_OF_PUSH_MPLS,
2108 * Encapsulate flow in VXLAN tunnel as defined in
2109 * rte_flow_action_vxlan_encap action structure.
2111 * See struct rte_flow_action_vxlan_encap.
2113 RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP,
2116 * Decapsulate outer most VXLAN tunnel from matched flow.
2118 * If flow pattern does not define a valid VXLAN tunnel (as specified by
2119 * RFC7348) then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION
2122 RTE_FLOW_ACTION_TYPE_VXLAN_DECAP,
2125 * Encapsulate flow in NVGRE tunnel defined in the
2126 * rte_flow_action_nvgre_encap action structure.
2128 * See struct rte_flow_action_nvgre_encap.
2130 RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP,
2133 * Decapsulate outer most NVGRE tunnel from matched flow.
2135 * If flow pattern does not define a valid NVGRE tunnel (as specified by
2136 * RFC7637) then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION
2139 RTE_FLOW_ACTION_TYPE_NVGRE_DECAP,
2142 * Add outer header whose template is provided in its data buffer
2144 * See struct rte_flow_action_raw_encap.
2146 RTE_FLOW_ACTION_TYPE_RAW_ENCAP,
2149 * Remove outer header whose template is provided in its data buffer.
2151 * See struct rte_flow_action_raw_decap
2153 RTE_FLOW_ACTION_TYPE_RAW_DECAP,
2156 * Modify IPv4 source address in the outermost IPv4 header.
2158 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV4,
2159 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2161 * See struct rte_flow_action_set_ipv4.
2163 RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC,
2166 * Modify IPv4 destination address in the outermost IPv4 header.
2168 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV4,
2169 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2171 * See struct rte_flow_action_set_ipv4.
2173 RTE_FLOW_ACTION_TYPE_SET_IPV4_DST,
2176 * Modify IPv6 source address in the outermost IPv6 header.
2178 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV6,
2179 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2181 * See struct rte_flow_action_set_ipv6.
2183 RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC,
2186 * Modify IPv6 destination address in the outermost IPv6 header.
2188 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV6,
2189 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2191 * See struct rte_flow_action_set_ipv6.
2193 RTE_FLOW_ACTION_TYPE_SET_IPV6_DST,
2196 * Modify source port number in the outermost TCP/UDP header.
2198 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_TCP
2199 * or RTE_FLOW_ITEM_TYPE_UDP, then the PMD should return a
2200 * RTE_FLOW_ERROR_TYPE_ACTION error.
2202 * See struct rte_flow_action_set_tp.
2204 RTE_FLOW_ACTION_TYPE_SET_TP_SRC,
2207 * Modify destination port number in the outermost TCP/UDP header.
2209 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_TCP
2210 * or RTE_FLOW_ITEM_TYPE_UDP, then the PMD should return a
2211 * RTE_FLOW_ERROR_TYPE_ACTION error.
2213 * See struct rte_flow_action_set_tp.
2215 RTE_FLOW_ACTION_TYPE_SET_TP_DST,
2218 * Swap the source and destination MAC addresses in the outermost
2221 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_ETH,
2222 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2224 * No associated configuration structure.
2226 RTE_FLOW_ACTION_TYPE_MAC_SWAP,
2229 * Decrease TTL value directly
2231 * No associated configuration structure.
2233 RTE_FLOW_ACTION_TYPE_DEC_TTL,
2238 * See struct rte_flow_action_set_ttl
2240 RTE_FLOW_ACTION_TYPE_SET_TTL,
2243 * Set source MAC address from matched flow.
2245 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_ETH,
2246 * the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2248 * See struct rte_flow_action_set_mac.
2250 RTE_FLOW_ACTION_TYPE_SET_MAC_SRC,
2253 * Set destination MAC address from matched flow.
2255 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_ETH,
2256 * the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2258 * See struct rte_flow_action_set_mac.
2260 RTE_FLOW_ACTION_TYPE_SET_MAC_DST,
2263 * Increase sequence number in the outermost TCP header.
2265 * Action configuration specifies the value to increase
2266 * TCP sequence number as a big-endian 32 bit integer.
2269 * @code rte_be32_t * @endcode
2271 * Using this action on non-matching traffic will result in
2272 * undefined behavior.
2274 RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ,
2277 * Decrease sequence number in the outermost TCP header.
2279 * Action configuration specifies the value to decrease
2280 * TCP sequence number as a big-endian 32 bit integer.
2283 * @code rte_be32_t * @endcode
2285 * Using this action on non-matching traffic will result in
2286 * undefined behavior.
2288 RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ,
2291 * Increase acknowledgment number in the outermost TCP header.
2293 * Action configuration specifies the value to increase
2294 * TCP acknowledgment number as a big-endian 32 bit integer.
2297 * @code rte_be32_t * @endcode
2299 * Using this action on non-matching traffic will result in
2300 * undefined behavior.
2302 RTE_FLOW_ACTION_TYPE_INC_TCP_ACK,
2305 * Decrease acknowledgment number in the outermost TCP header.
2307 * Action configuration specifies the value to decrease
2308 * TCP acknowledgment number as a big-endian 32 bit integer.
2311 * @code rte_be32_t * @endcode
2313 * Using this action on non-matching traffic will result in
2314 * undefined behavior.
2316 RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK,
2321 * Tag is for internal flow usage only and
2322 * is not delivered to the application.
2324 * See struct rte_flow_action_set_tag.
2326 RTE_FLOW_ACTION_TYPE_SET_TAG,
2329 * Set metadata on ingress or egress path.
2331 * See struct rte_flow_action_set_meta.
2333 RTE_FLOW_ACTION_TYPE_SET_META,
2336 * Modify IPv4 DSCP in the outermost IP header.
2338 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV4,
2339 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2341 * See struct rte_flow_action_set_dscp.
2343 RTE_FLOW_ACTION_TYPE_SET_IPV4_DSCP,
2346 * Modify IPv6 DSCP in the outermost IP header.
2348 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV6,
2349 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2351 * See struct rte_flow_action_set_dscp.
2353 RTE_FLOW_ACTION_TYPE_SET_IPV6_DSCP,
2356 * Report as aged flow if timeout passed without any matching on the
2359 * See struct rte_flow_action_age.
2360 * See function rte_flow_get_aged_flows
2361 * see enum RTE_ETH_EVENT_FLOW_AGED
2362 * See struct rte_flow_query_age
2364 RTE_FLOW_ACTION_TYPE_AGE,
2367 * The matching packets will be duplicated with specified ratio and
2368 * applied with own set of actions with a fate action.
2370 * See struct rte_flow_action_sample.
2372 RTE_FLOW_ACTION_TYPE_SAMPLE,
2376 * @see RTE_FLOW_ACTION_TYPE_INDIRECT
2378 * Describe action shared across multiple flow rules.
2380 * Allow multiple rules reference the same action by handle (see
2381 * struct rte_flow_shared_action).
2383 RTE_FLOW_ACTION_TYPE_SHARED,
2386 * Modify a packet header field, tag, mark or metadata.
2388 * Allow the modification of an arbitrary header field via
2389 * set, add and sub operations or copying its content into
2390 * tag, meta or mark for future processing.
2392 * See struct rte_flow_action_modify_field.
2394 RTE_FLOW_ACTION_TYPE_MODIFY_FIELD,
2397 * An action handle is referenced in a rule through an indirect action.
2399 * The same action handle may be used in multiple rules for the same
2400 * or different ethdev ports.
2402 RTE_FLOW_ACTION_TYPE_INDIRECT,
2407 * Enable tracking a TCP connection state.
2409 * @see struct rte_flow_action_conntrack.
2411 RTE_FLOW_ACTION_TYPE_CONNTRACK,
2414 * Color the packet to reflect the meter color result.
2415 * Set the meter color in the mbuf to the selected color.
2417 * See struct rte_flow_action_meter_color.
2419 RTE_FLOW_ACTION_TYPE_METER_COLOR,
2423 * RTE_FLOW_ACTION_TYPE_MARK
2425 * Attaches an integer value to packets and sets PKT_RX_FDIR and
2426 * PKT_RX_FDIR_ID mbuf flags.
2428 * This value is arbitrary and application-defined. Maximum allowed value
2429 * depends on the underlying implementation. It is returned in the
2430 * hash.fdir.hi mbuf field.
2432 struct rte_flow_action_mark {
2433 uint32_t id; /**< Integer value to return with packets. */
2438 * @b EXPERIMENTAL: this structure may change without prior notice
2440 * RTE_FLOW_ACTION_TYPE_JUMP
2442 * Redirects packets to a group on the current device.
2444 * In a hierarchy of groups, which can be used to represent physical or logical
2445 * flow tables on the device, this action allows the action to be a redirect to
2446 * a group on that device.
2448 struct rte_flow_action_jump {
2453 * RTE_FLOW_ACTION_TYPE_QUEUE
2455 * Assign packets to a given queue index.
2457 struct rte_flow_action_queue {
2458 uint16_t index; /**< Queue index to use. */
2463 * @b EXPERIMENTAL: this structure may change without prior notice
2465 * RTE_FLOW_ACTION_TYPE_AGE
2467 * Report flow as aged-out if timeout passed without any matching
2468 * on the flow. RTE_ETH_EVENT_FLOW_AGED event is triggered when a
2469 * port detects new aged-out flows.
2471 * The flow context and the flow handle will be reported by the
2472 * rte_flow_get_aged_flows API.
2474 struct rte_flow_action_age {
2475 uint32_t timeout:24; /**< Time in seconds. */
2476 uint32_t reserved:8; /**< Reserved, must be zero. */
2478 /**< The user flow context, NULL means the rte_flow pointer. */
2482 * RTE_FLOW_ACTION_TYPE_AGE (query)
2484 * Query structure to retrieve the aging status information of a
2485 * shared AGE action, or a flow rule using the AGE action.
2487 struct rte_flow_query_age {
2488 uint32_t reserved:6; /**< Reserved, must be zero. */
2489 uint32_t aged:1; /**< 1 if aging timeout expired, 0 otherwise. */
2490 uint32_t sec_since_last_hit_valid:1;
2491 /**< sec_since_last_hit value is valid. */
2492 uint32_t sec_since_last_hit:24; /**< Seconds since last traffic hit. */
2497 * @b EXPERIMENTAL: this structure may change without prior notice
2499 * RTE_FLOW_ACTION_TYPE_COUNT
2501 * Adds a counter action to a matched flow.
2503 * If more than one count action is specified in a single flow rule, then each
2504 * action must specify a unique id.
2506 * Counters can be retrieved and reset through ``rte_flow_query()``, see
2507 * ``struct rte_flow_query_count``.
2509 * For ports within the same switch domain then the counter id namespace extends
2510 * to all ports within that switch domain.
2512 struct rte_flow_action_count {
2513 uint32_t id; /**< Counter ID. */
2517 * RTE_FLOW_ACTION_TYPE_COUNT (query)
2519 * Query structure to retrieve and reset flow rule counters.
2521 struct rte_flow_query_count {
2522 uint32_t reset:1; /**< Reset counters after query [in]. */
2523 uint32_t hits_set:1; /**< hits field is set [out]. */
2524 uint32_t bytes_set:1; /**< bytes field is set [out]. */
2525 uint32_t reserved:29; /**< Reserved, must be zero [in, out]. */
2526 uint64_t hits; /**< Number of hits for this rule [out]. */
2527 uint64_t bytes; /**< Number of bytes through this rule [out]. */
2531 * Hash function types.
2533 enum rte_eth_hash_function {
2534 RTE_ETH_HASH_FUNCTION_DEFAULT = 0,
2535 RTE_ETH_HASH_FUNCTION_TOEPLITZ, /**< Toeplitz */
2536 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR, /**< Simple XOR */
2538 * Symmetric Toeplitz: src, dst will be replaced by
2539 * xor(src, dst). For the case with src/dst only,
2540 * src or dst address will xor with zero pair.
2542 RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ,
2543 RTE_ETH_HASH_FUNCTION_MAX,
2547 * RTE_FLOW_ACTION_TYPE_RSS
2549 * Similar to QUEUE, except RSS is additionally performed on packets to
2550 * spread them among several queues according to the provided parameters.
2552 * Unlike global RSS settings used by other DPDK APIs, unsetting the
2553 * @p types field does not disable RSS in a flow rule. Doing so instead
2554 * requests safe unspecified "best-effort" settings from the underlying PMD,
2555 * which depending on the flow rule, may result in anything ranging from
2556 * empty (single queue) to all-inclusive RSS.
2558 * Note: RSS hash result is stored in the hash.rss mbuf field which overlaps
2559 * hash.fdir.lo. Since the MARK action sets the hash.fdir.hi field only,
2560 * both can be requested simultaneously.
2562 struct rte_flow_action_rss {
2563 enum rte_eth_hash_function func; /**< RSS hash function to apply. */
2565 * Packet encapsulation level RSS hash @p types apply to.
2567 * - @p 0 requests the default behavior. Depending on the packet
2568 * type, it can mean outermost, innermost, anything in between or
2571 * It basically stands for the innermost encapsulation level RSS
2572 * can be performed on according to PMD and device capabilities.
2574 * - @p 1 requests RSS to be performed on the outermost packet
2575 * encapsulation level.
2577 * - @p 2 and subsequent values request RSS to be performed on the
2578 * specified inner packet encapsulation level, from outermost to
2579 * innermost (lower to higher values).
2581 * Values other than @p 0 are not necessarily supported.
2583 * Requesting a specific RSS level on unrecognized traffic results
2584 * in undefined behavior. For predictable results, it is recommended
2585 * to make the flow rule pattern match packet headers up to the
2586 * requested encapsulation level so that only matching traffic goes
2590 uint64_t types; /**< Specific RSS hash types (see ETH_RSS_*). */
2591 uint32_t key_len; /**< Hash key length in bytes. */
2592 uint32_t queue_num; /**< Number of entries in @p queue. */
2593 const uint8_t *key; /**< Hash key. */
2594 const uint16_t *queue; /**< Queue indices to use. */
2598 * RTE_FLOW_ACTION_TYPE_VF
2600 * Directs matching traffic to a given virtual function of the current
2603 * Packets matched by a VF pattern item can be redirected to their original
2604 * VF ID instead of the specified one. This parameter may not be available
2605 * and is not guaranteed to work properly if the VF part is matched by a
2606 * prior flow rule or if packets are not addressed to a VF in the first
2609 struct rte_flow_action_vf {
2610 uint32_t original:1; /**< Use original VF ID if possible. */
2611 uint32_t reserved:31; /**< Reserved, must be zero. */
2612 uint32_t id; /**< VF ID. */
2616 * RTE_FLOW_ACTION_TYPE_PHY_PORT
2618 * Directs packets to a given physical port index of the underlying
2621 * @see RTE_FLOW_ITEM_TYPE_PHY_PORT
2623 struct rte_flow_action_phy_port {
2624 uint32_t original:1; /**< Use original port index if possible. */
2625 uint32_t reserved:31; /**< Reserved, must be zero. */
2626 uint32_t index; /**< Physical port index. */
2630 * RTE_FLOW_ACTION_TYPE_PORT_ID
2632 * Directs matching traffic to a given DPDK port ID.
2634 * @see RTE_FLOW_ITEM_TYPE_PORT_ID
2636 struct rte_flow_action_port_id {
2637 uint32_t original:1; /**< Use original DPDK port ID if possible. */
2638 uint32_t reserved:31; /**< Reserved, must be zero. */
2639 uint32_t id; /**< DPDK port ID. */
2643 * RTE_FLOW_ACTION_TYPE_METER
2645 * Traffic metering and policing (MTR).
2647 * Packets matched by items of this type can be either dropped or passed to the
2648 * next item with their color set by the MTR object.
2650 struct rte_flow_action_meter {
2651 uint32_t mtr_id; /**< MTR object ID created with rte_mtr_create(). */
2655 * RTE_FLOW_ACTION_TYPE_SECURITY
2657 * Perform the security action on flows matched by the pattern items
2658 * according to the configuration of the security session.
2660 * This action modifies the payload of matched flows. For INLINE_CRYPTO, the
2661 * security protocol headers and IV are fully provided by the application as
2662 * specified in the flow pattern. The payload of matching packets is
2663 * encrypted on egress, and decrypted and authenticated on ingress.
2664 * For INLINE_PROTOCOL, the security protocol is fully offloaded to HW,
2665 * providing full encapsulation and decapsulation of packets in security
2666 * protocols. The flow pattern specifies both the outer security header fields
2667 * and the inner packet fields. The security session specified in the action
2668 * must match the pattern parameters.
2670 * The security session specified in the action must be created on the same
2671 * port as the flow action that is being specified.
2673 * The ingress/egress flow attribute should match that specified in the
2674 * security session if the security session supports the definition of the
2677 * Multiple flows can be configured to use the same security session.
2679 * The NULL value is allowed for security session. If security session is NULL,
2680 * then SPI field in ESP flow item and IP addresses in flow items 'IPv4' and
2681 * 'IPv6' will be allowed to be a range. The rule thus created can enable
2682 * security processing on multiple flows.
2684 struct rte_flow_action_security {
2685 void *security_session; /**< Pointer to security session structure. */
2689 * RTE_FLOW_ACTION_TYPE_OF_SET_MPLS_TTL
2691 * Implements OFPAT_SET_MPLS_TTL ("MPLS TTL") as defined by the OpenFlow
2692 * Switch Specification.
2694 struct rte_flow_action_of_set_mpls_ttl {
2695 uint8_t mpls_ttl; /**< MPLS TTL. */
2699 * RTE_FLOW_ACTION_TYPE_OF_SET_NW_TTL
2701 * Implements OFPAT_SET_NW_TTL ("IP TTL") as defined by the OpenFlow Switch
2704 struct rte_flow_action_of_set_nw_ttl {
2705 uint8_t nw_ttl; /**< IP TTL. */
2709 * RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN
2711 * Implements OFPAT_PUSH_VLAN ("push a new VLAN tag") as defined by the
2712 * OpenFlow Switch Specification.
2714 struct rte_flow_action_of_push_vlan {
2715 rte_be16_t ethertype; /**< EtherType. */
2719 * RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID
2721 * Implements OFPAT_SET_VLAN_VID ("set the 802.1q VLAN id") as defined by
2722 * the OpenFlow Switch Specification.
2724 struct rte_flow_action_of_set_vlan_vid {
2725 rte_be16_t vlan_vid; /**< VLAN id. */
2729 * RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP
2731 * Implements OFPAT_SET_LAN_PCP ("set the 802.1q priority") as defined by
2732 * the OpenFlow Switch Specification.
2734 struct rte_flow_action_of_set_vlan_pcp {
2735 uint8_t vlan_pcp; /**< VLAN priority. */
2739 * RTE_FLOW_ACTION_TYPE_OF_POP_MPLS
2741 * Implements OFPAT_POP_MPLS ("pop the outer MPLS tag") as defined by the
2742 * OpenFlow Switch Specification.
2744 struct rte_flow_action_of_pop_mpls {
2745 rte_be16_t ethertype; /**< EtherType. */
2749 * RTE_FLOW_ACTION_TYPE_OF_PUSH_MPLS
2751 * Implements OFPAT_PUSH_MPLS ("push a new MPLS tag") as defined by the
2752 * OpenFlow Switch Specification.
2754 struct rte_flow_action_of_push_mpls {
2755 rte_be16_t ethertype; /**< EtherType. */
2760 * @b EXPERIMENTAL: this structure may change without prior notice
2762 * RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP
2764 * VXLAN tunnel end-point encapsulation data definition
2766 * The tunnel definition is provided through the flow item pattern, the
2767 * provided pattern must conform to RFC7348 for the tunnel specified. The flow
2768 * definition must be provided in order from the RTE_FLOW_ITEM_TYPE_ETH
2769 * definition up the end item which is specified by RTE_FLOW_ITEM_TYPE_END.
2771 * The mask field allows user to specify which fields in the flow item
2772 * definitions can be ignored and which have valid data and can be used
2775 * Note: the last field is not used in the definition of a tunnel and can be
2778 * Valid flow definition for RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP include:
2780 * - ETH / IPV4 / UDP / VXLAN / END
2781 * - ETH / IPV6 / UDP / VXLAN / END
2782 * - ETH / VLAN / IPV4 / UDP / VXLAN / END
2785 struct rte_flow_action_vxlan_encap {
2787 * Encapsulating vxlan tunnel definition
2788 * (terminated by the END pattern item).
2790 struct rte_flow_item *definition;
2795 * @b EXPERIMENTAL: this structure may change without prior notice
2797 * RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP
2799 * NVGRE tunnel end-point encapsulation data definition
2801 * The tunnel definition is provided through the flow item pattern the
2802 * provided pattern must conform with RFC7637. The flow definition must be
2803 * provided in order from the RTE_FLOW_ITEM_TYPE_ETH definition up the end item
2804 * which is specified by RTE_FLOW_ITEM_TYPE_END.
2806 * The mask field allows user to specify which fields in the flow item
2807 * definitions can be ignored and which have valid data and can be used
2810 * Note: the last field is not used in the definition of a tunnel and can be
2813 * Valid flow definition for RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP include:
2815 * - ETH / IPV4 / NVGRE / END
2816 * - ETH / VLAN / IPV6 / NVGRE / END
2819 struct rte_flow_action_nvgre_encap {
2821 * Encapsulating vxlan tunnel definition
2822 * (terminated by the END pattern item).
2824 struct rte_flow_item *definition;
2829 * @b EXPERIMENTAL: this structure may change without prior notice
2831 * RTE_FLOW_ACTION_TYPE_RAW_ENCAP
2833 * Raw tunnel end-point encapsulation data definition.
2835 * The data holds the headers definitions to be applied on the packet.
2836 * The data must start with ETH header up to the tunnel item header itself.
2837 * When used right after RAW_DECAP (for decapsulating L3 tunnel type for
2838 * example MPLSoGRE) the data will just hold layer 2 header.
2840 * The preserve parameter holds which bits in the packet the PMD is not allowed
2841 * to change, this parameter can also be NULL and then the PMD is allowed
2842 * to update any field.
2844 * size holds the number of bytes in @p data and @p preserve.
2846 struct rte_flow_action_raw_encap {
2847 uint8_t *data; /**< Encapsulation data. */
2848 uint8_t *preserve; /**< Bit-mask of @p data to preserve on output. */
2849 size_t size; /**< Size of @p data and @p preserve. */
2854 * @b EXPERIMENTAL: this structure may change without prior notice
2856 * RTE_FLOW_ACTION_TYPE_RAW_DECAP
2858 * Raw tunnel end-point decapsulation data definition.
2860 * The data holds the headers definitions to be removed from the packet.
2861 * The data must start with ETH header up to the tunnel item header itself.
2862 * When used right before RAW_DECAP (for encapsulating L3 tunnel type for
2863 * example MPLSoGRE) the data will just hold layer 2 header.
2865 * size holds the number of bytes in @p data.
2867 struct rte_flow_action_raw_decap {
2868 uint8_t *data; /**< Encapsulation data. */
2869 size_t size; /**< Size of @p data and @p preserve. */
2874 * @b EXPERIMENTAL: this structure may change without prior notice
2876 * RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC
2877 * RTE_FLOW_ACTION_TYPE_SET_IPV4_DST
2879 * Allows modification of IPv4 source (RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC)
2880 * and destination address (RTE_FLOW_ACTION_TYPE_SET_IPV4_DST) in the
2881 * specified outermost IPv4 header.
2883 struct rte_flow_action_set_ipv4 {
2884 rte_be32_t ipv4_addr;
2889 * @b EXPERIMENTAL: this structure may change without prior notice
2891 * RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC
2892 * RTE_FLOW_ACTION_TYPE_SET_IPV6_DST
2894 * Allows modification of IPv6 source (RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC)
2895 * and destination address (RTE_FLOW_ACTION_TYPE_SET_IPV6_DST) in the
2896 * specified outermost IPv6 header.
2898 struct rte_flow_action_set_ipv6 {
2899 uint8_t ipv6_addr[16];
2904 * @b EXPERIMENTAL: this structure may change without prior notice
2906 * RTE_FLOW_ACTION_TYPE_SET_TP_SRC
2907 * RTE_FLOW_ACTION_TYPE_SET_TP_DST
2909 * Allows modification of source (RTE_FLOW_ACTION_TYPE_SET_TP_SRC)
2910 * and destination (RTE_FLOW_ACTION_TYPE_SET_TP_DST) port numbers
2911 * in the specified outermost TCP/UDP header.
2913 struct rte_flow_action_set_tp {
2918 * RTE_FLOW_ACTION_TYPE_SET_TTL
2920 * Set the TTL value directly for IPv4 or IPv6
2922 struct rte_flow_action_set_ttl {
2927 * RTE_FLOW_ACTION_TYPE_SET_MAC
2929 * Set MAC address from the matched flow
2931 struct rte_flow_action_set_mac {
2932 uint8_t mac_addr[RTE_ETHER_ADDR_LEN];
2937 * @b EXPERIMENTAL: this structure may change without prior notice
2939 * RTE_FLOW_ACTION_TYPE_SET_TAG
2941 * Set a tag which is a transient data used during flow matching. This is not
2942 * delivered to application. Multiple tags are supported by specifying index.
2944 struct rte_flow_action_set_tag {
2952 * @b EXPERIMENTAL: this structure may change without prior notice
2954 * RTE_FLOW_ACTION_TYPE_SET_META
2956 * Set metadata. Metadata set by mbuf metadata dynamic field with
2957 * PKT_TX_DYNF_DATA flag on egress will be overridden by this action. On
2958 * ingress, the metadata will be carried by mbuf metadata dynamic field
2959 * with PKT_RX_DYNF_METADATA flag if set. The dynamic mbuf field must be
2960 * registered in advance by rte_flow_dynf_metadata_register().
2962 * Altering partial bits is supported with mask. For bits which have never
2963 * been set, unpredictable value will be seen depending on driver
2964 * implementation. For loopback/hairpin packet, metadata set on Rx/Tx may
2965 * or may not be propagated to the other path depending on HW capability.
2967 * RTE_FLOW_ITEM_TYPE_META matches metadata.
2969 struct rte_flow_action_set_meta {
2975 * RTE_FLOW_ACTION_TYPE_SET_IPV4_DSCP
2976 * RTE_FLOW_ACTION_TYPE_SET_IPV6_DSCP
2978 * Set the DSCP value for IPv4/IPv6 header.
2979 * DSCP in low 6 bits, rest ignored.
2981 struct rte_flow_action_set_dscp {
2987 * @b EXPERIMENTAL: this structure may change without prior notice
2989 * RTE_FLOW_ACTION_TYPE_INDIRECT
2991 * Opaque type returned after successfully creating an indirect action object.
2992 * The definition of the object handle is different per driver or
2993 * per direct action type.
2995 * This handle can be used to manage and query the related direct action:
2996 * - referenced in single flow rule or across multiple flow rules
2997 * over multiple ports
2998 * - update action object configuration
2999 * - query action object data
3000 * - destroy action object
3002 struct rte_flow_action_handle;
3005 * The state of a TCP connection.
3007 enum rte_flow_conntrack_state {
3008 /** SYN-ACK packet was seen. */
3009 RTE_FLOW_CONNTRACK_STATE_SYN_RECV,
3010 /** 3-way handshake was done. */
3011 RTE_FLOW_CONNTRACK_STATE_ESTABLISHED,
3012 /** First FIN packet was received to close the connection. */
3013 RTE_FLOW_CONNTRACK_STATE_FIN_WAIT,
3014 /** First FIN was ACKed. */
3015 RTE_FLOW_CONNTRACK_STATE_CLOSE_WAIT,
3016 /** Second FIN was received, waiting for the last ACK. */
3017 RTE_FLOW_CONNTRACK_STATE_LAST_ACK,
3018 /** Second FIN was ACKed, connection was closed. */
3019 RTE_FLOW_CONNTRACK_STATE_TIME_WAIT,
3023 * The last passed TCP packet flags of a connection.
3025 enum rte_flow_conntrack_tcp_last_index {
3026 RTE_FLOW_CONNTRACK_FLAG_NONE = 0, /**< No Flag. */
3027 RTE_FLOW_CONNTRACK_FLAG_SYN = RTE_BIT32(0), /**< With SYN flag. */
3028 RTE_FLOW_CONNTRACK_FLAG_SYNACK = RTE_BIT32(1), /**< With SYNACK flag. */
3029 RTE_FLOW_CONNTRACK_FLAG_FIN = RTE_BIT32(2), /**< With FIN flag. */
3030 RTE_FLOW_CONNTRACK_FLAG_ACK = RTE_BIT32(3), /**< With ACK flag. */
3031 RTE_FLOW_CONNTRACK_FLAG_RST = RTE_BIT32(4), /**< With RST flag. */
3036 * @b EXPERIMENTAL: this structure may change without prior notice
3038 * Configuration parameters for each direction of a TCP connection.
3039 * All fields should be in host byte order.
3040 * If needed, driver should convert all fields to network byte order
3041 * if HW needs them in that way.
3043 struct rte_flow_tcp_dir_param {
3044 /** TCP window scaling factor, 0xF to disable. */
3046 /** The FIN was sent by this direction. */
3047 uint32_t close_initiated:1;
3048 /** An ACK packet has been received by this side. */
3049 uint32_t last_ack_seen:1;
3051 * If set, it indicates that there is unacknowledged data for the
3052 * packets sent from this direction.
3054 uint32_t data_unacked:1;
3056 * Maximal value of sequence + payload length in sent
3057 * packets (next ACK from the opposite direction).
3061 * Maximal value of (ACK + window size) in received packet + length
3062 * over sent packet (maximal sequence could be sent).
3065 /** Maximal value of actual window size in sent packets. */
3067 /** Maximal value of ACK in sent packets. */
3073 * @b EXPERIMENTAL: this structure may change without prior notice
3075 * RTE_FLOW_ACTION_TYPE_CONNTRACK
3077 * Configuration and initial state for the connection tracking module.
3078 * This structure could be used for both setting and query.
3079 * All fields should be in host byte order.
3081 struct rte_flow_action_conntrack {
3082 /** The peer port number, can be the same port. */
3085 * Direction of this connection when creating a flow rule, the
3086 * value only affects the creation of subsequent flow rules.
3088 uint32_t is_original_dir:1;
3090 * Enable / disable the conntrack HW module. When disabled, the
3091 * result will always be RTE_FLOW_CONNTRACK_FLAG_DISABLED.
3092 * In this state the HW will act as passthrough.
3093 * It only affects this conntrack object in the HW without any effect
3094 * to the other objects.
3097 /** At least one ack was seen after the connection was established. */
3098 uint32_t live_connection:1;
3099 /** Enable selective ACK on this connection. */
3100 uint32_t selective_ack:1;
3101 /** A challenge ack has passed. */
3102 uint32_t challenge_ack_passed:1;
3104 * 1: The last packet is seen from the original direction.
3105 * 0: The last packet is seen from the reply direction.
3107 uint32_t last_direction:1;
3108 /** No TCP check will be done except the state change. */
3109 uint32_t liberal_mode:1;
3110 /**<The current state of this connection. */
3111 enum rte_flow_conntrack_state state;
3112 /** Scaling factor for maximal allowed ACK window. */
3113 uint8_t max_ack_window;
3114 /** Maximal allowed number of retransmission times. */
3115 uint8_t retransmission_limit;
3116 /** TCP parameters of the original direction. */
3117 struct rte_flow_tcp_dir_param original_dir;
3118 /** TCP parameters of the reply direction. */
3119 struct rte_flow_tcp_dir_param reply_dir;
3120 /** The window value of the last packet passed this conntrack. */
3121 uint16_t last_window;
3122 enum rte_flow_conntrack_tcp_last_index last_index;
3123 /** The sequence of the last packet passed this conntrack. */
3125 /** The acknowledgment of the last packet passed this conntrack. */
3128 * The total value ACK + payload length of the last packet
3129 * passed this conntrack.
3135 * RTE_FLOW_ACTION_TYPE_CONNTRACK
3137 * Wrapper structure for the context update interface.
3138 * Ports cannot support updating, and the only valid solution is to
3139 * destroy the old context and create a new one instead.
3141 struct rte_flow_modify_conntrack {
3142 /** New connection tracking parameters to be updated. */
3143 struct rte_flow_action_conntrack new_ct;
3144 /** The direction field will be updated. */
3145 uint32_t direction:1;
3146 /** All the other fields except direction will be updated. */
3148 /** Reserved bits for the future usage. */
3149 uint32_t reserved:30;
3154 * @b EXPERIMENTAL: this structure may change without prior notice
3156 * RTE_FLOW_ACTION_TYPE_METER_COLOR
3158 * The meter color should be set in the packet meta-data
3159 * (i.e. struct rte_mbuf::sched::color).
3161 struct rte_flow_action_meter_color {
3162 enum rte_color color; /**< Packet color. */
3166 * Field IDs for MODIFY_FIELD action.
3168 enum rte_flow_field_id {
3169 RTE_FLOW_FIELD_START = 0, /**< Start of a packet. */
3170 RTE_FLOW_FIELD_MAC_DST, /**< Destination MAC Address. */
3171 RTE_FLOW_FIELD_MAC_SRC, /**< Source MAC Address. */
3172 RTE_FLOW_FIELD_VLAN_TYPE, /**< 802.1Q Tag Identifier. */
3173 RTE_FLOW_FIELD_VLAN_ID, /**< 802.1Q VLAN Identifier. */
3174 RTE_FLOW_FIELD_MAC_TYPE, /**< EtherType. */
3175 RTE_FLOW_FIELD_IPV4_DSCP, /**< IPv4 DSCP. */
3176 RTE_FLOW_FIELD_IPV4_TTL, /**< IPv4 Time To Live. */
3177 RTE_FLOW_FIELD_IPV4_SRC, /**< IPv4 Source Address. */
3178 RTE_FLOW_FIELD_IPV4_DST, /**< IPv4 Destination Address. */
3179 RTE_FLOW_FIELD_IPV6_DSCP, /**< IPv6 DSCP. */
3180 RTE_FLOW_FIELD_IPV6_HOPLIMIT, /**< IPv6 Hop Limit. */
3181 RTE_FLOW_FIELD_IPV6_SRC, /**< IPv6 Source Address. */
3182 RTE_FLOW_FIELD_IPV6_DST, /**< IPv6 Destination Address. */
3183 RTE_FLOW_FIELD_TCP_PORT_SRC, /**< TCP Source Port Number. */
3184 RTE_FLOW_FIELD_TCP_PORT_DST, /**< TCP Destination Port Number. */
3185 RTE_FLOW_FIELD_TCP_SEQ_NUM, /**< TCP Sequence Number. */
3186 RTE_FLOW_FIELD_TCP_ACK_NUM, /**< TCP Acknowledgment Number. */
3187 RTE_FLOW_FIELD_TCP_FLAGS, /**< TCP Flags. */
3188 RTE_FLOW_FIELD_UDP_PORT_SRC, /**< UDP Source Port Number. */
3189 RTE_FLOW_FIELD_UDP_PORT_DST, /**< UDP Destination Port Number. */
3190 RTE_FLOW_FIELD_VXLAN_VNI, /**< VXLAN Network Identifier. */
3191 RTE_FLOW_FIELD_GENEVE_VNI, /**< GENEVE Network Identifier. */
3192 RTE_FLOW_FIELD_GTP_TEID, /**< GTP Tunnel Endpoint Identifier. */
3193 RTE_FLOW_FIELD_TAG, /**< Tag value. */
3194 RTE_FLOW_FIELD_MARK, /**< Mark value. */
3195 RTE_FLOW_FIELD_META, /**< Metadata value. */
3196 RTE_FLOW_FIELD_POINTER, /**< Memory pointer. */
3197 RTE_FLOW_FIELD_VALUE, /**< Immediate value. */
3201 * Field description for MODIFY_FIELD action.
3203 struct rte_flow_action_modify_data {
3204 enum rte_flow_field_id field; /**< Field or memory type ID. */
3208 /**< Encapsulation level or tag index. */
3210 /**< Number of bits to skip from a field. */
3214 * Immediate value for RTE_FLOW_FIELD_VALUE or
3215 * memory address for RTE_FLOW_FIELD_POINTER.
3222 * Operation types for MODIFY_FIELD action.
3224 enum rte_flow_modify_op {
3225 RTE_FLOW_MODIFY_SET = 0, /**< Set a new value. */
3226 RTE_FLOW_MODIFY_ADD, /**< Add a value to a field. */
3227 RTE_FLOW_MODIFY_SUB, /**< Subtract a value from a field. */
3232 * @b EXPERIMENTAL: this structure may change without prior notice
3234 * RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
3236 * Modify a destination header field according to the specified
3237 * operation. Another packet field can be used as a source as well
3238 * as tag, mark, metadata, immediate value or a pointer to it.
3240 struct rte_flow_action_modify_field {
3241 enum rte_flow_modify_op operation; /**< Operation to perform. */
3242 struct rte_flow_action_modify_data dst; /**< Destination field. */
3243 struct rte_flow_action_modify_data src; /**< Source field. */
3244 uint32_t width; /**< Number of bits to use from a source field. */
3247 /* Mbuf dynamic field offset for metadata. */
3248 extern int32_t rte_flow_dynf_metadata_offs;
3250 /* Mbuf dynamic field flag mask for metadata. */
3251 extern uint64_t rte_flow_dynf_metadata_mask;
3253 /* Mbuf dynamic field pointer for metadata. */
3254 #define RTE_FLOW_DYNF_METADATA(m) \
3255 RTE_MBUF_DYNFIELD((m), rte_flow_dynf_metadata_offs, uint32_t *)
3257 /* Mbuf dynamic flags for metadata. */
3258 #define PKT_RX_DYNF_METADATA (rte_flow_dynf_metadata_mask)
3259 #define PKT_TX_DYNF_METADATA (rte_flow_dynf_metadata_mask)
3262 static inline uint32_t
3263 rte_flow_dynf_metadata_get(struct rte_mbuf *m)
3265 return *RTE_FLOW_DYNF_METADATA(m);
3270 rte_flow_dynf_metadata_set(struct rte_mbuf *m, uint32_t v)
3272 *RTE_FLOW_DYNF_METADATA(m) = v;
3276 * Definition of a single action.
3278 * A list of actions is terminated by a END action.
3280 * For simple actions without a configuration object, conf remains NULL.
3282 struct rte_flow_action {
3283 enum rte_flow_action_type type; /**< Action type. */
3284 const void *conf; /**< Pointer to action configuration object. */
3288 * Opaque type returned after successfully creating a flow.
3290 * This handle can be used to manage and query the related flow (e.g. to
3291 * destroy it or retrieve counters).
3297 * @b EXPERIMENTAL: this structure may change without prior notice
3299 * RTE_FLOW_ACTION_TYPE_SAMPLE
3301 * Adds a sample action to a matched flow.
3303 * The matching packets will be duplicated with specified ratio and applied
3304 * with own set of actions with a fate action, the sampled packet could be
3305 * redirected to queue or port. All the packets continue processing on the
3306 * default flow path.
3308 * When the sample ratio is set to 1 then the packets will be 100% mirrored.
3309 * Additional action list be supported to add for sampled or mirrored packets.
3311 struct rte_flow_action_sample {
3312 uint32_t ratio; /**< packets sampled equals to '1/ratio'. */
3313 const struct rte_flow_action *actions;
3314 /**< sub-action list specific for the sampling hit cases. */
3318 * Verbose error types.
3320 * Most of them provide the type of the object referenced by struct
3321 * rte_flow_error.cause.
3323 enum rte_flow_error_type {
3324 RTE_FLOW_ERROR_TYPE_NONE, /**< No error. */
3325 RTE_FLOW_ERROR_TYPE_UNSPECIFIED, /**< Cause unspecified. */
3326 RTE_FLOW_ERROR_TYPE_HANDLE, /**< Flow rule (handle). */
3327 RTE_FLOW_ERROR_TYPE_ATTR_GROUP, /**< Group field. */
3328 RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY, /**< Priority field. */
3329 RTE_FLOW_ERROR_TYPE_ATTR_INGRESS, /**< Ingress field. */
3330 RTE_FLOW_ERROR_TYPE_ATTR_EGRESS, /**< Egress field. */
3331 RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, /**< Transfer field. */
3332 RTE_FLOW_ERROR_TYPE_ATTR, /**< Attributes structure. */
3333 RTE_FLOW_ERROR_TYPE_ITEM_NUM, /**< Pattern length. */
3334 RTE_FLOW_ERROR_TYPE_ITEM_SPEC, /**< Item specification. */
3335 RTE_FLOW_ERROR_TYPE_ITEM_LAST, /**< Item specification range. */
3336 RTE_FLOW_ERROR_TYPE_ITEM_MASK, /**< Item specification mask. */
3337 RTE_FLOW_ERROR_TYPE_ITEM, /**< Specific pattern item. */
3338 RTE_FLOW_ERROR_TYPE_ACTION_NUM, /**< Number of actions. */
3339 RTE_FLOW_ERROR_TYPE_ACTION_CONF, /**< Action configuration. */
3340 RTE_FLOW_ERROR_TYPE_ACTION, /**< Specific action. */
3344 * Verbose error structure definition.
3346 * This object is normally allocated by applications and set by PMDs, the
3347 * message points to a constant string which does not need to be freed by
3348 * the application, however its pointer can be considered valid only as long
3349 * as its associated DPDK port remains configured. Closing the underlying
3350 * device or unloading the PMD invalidates it.
3352 * Both cause and message may be NULL regardless of the error type.
3354 struct rte_flow_error {
3355 enum rte_flow_error_type type; /**< Cause field and error types. */
3356 const void *cause; /**< Object responsible for the error. */
3357 const char *message; /**< Human-readable error message. */
3361 * Complete flow rule description.
3363 * This object type is used when converting a flow rule description.
3365 * @see RTE_FLOW_CONV_OP_RULE
3366 * @see rte_flow_conv()
3369 struct rte_flow_conv_rule {
3371 const struct rte_flow_attr *attr_ro; /**< RO attributes. */
3372 struct rte_flow_attr *attr; /**< Attributes. */
3375 const struct rte_flow_item *pattern_ro; /**< RO pattern. */
3376 struct rte_flow_item *pattern; /**< Pattern items. */
3379 const struct rte_flow_action *actions_ro; /**< RO actions. */
3380 struct rte_flow_action *actions; /**< List of actions. */
3385 * Conversion operations for flow API objects.
3387 * @see rte_flow_conv()
3389 enum rte_flow_conv_op {
3391 * No operation to perform.
3393 * rte_flow_conv() simply returns 0.
3395 RTE_FLOW_CONV_OP_NONE,
3398 * Convert attributes structure.
3400 * This is a basic copy of an attributes structure.
3403 * @code const struct rte_flow_attr * @endcode
3405 * @code struct rte_flow_attr * @endcode
3407 RTE_FLOW_CONV_OP_ATTR,
3410 * Convert a single item.
3412 * Duplicates @p spec, @p last and @p mask but not outside objects.
3415 * @code const struct rte_flow_item * @endcode
3417 * @code struct rte_flow_item * @endcode
3419 RTE_FLOW_CONV_OP_ITEM,
3422 * Convert a single action.
3424 * Duplicates @p conf but not outside objects.
3427 * @code const struct rte_flow_action * @endcode
3429 * @code struct rte_flow_action * @endcode
3431 RTE_FLOW_CONV_OP_ACTION,
3434 * Convert an entire pattern.
3436 * Duplicates all pattern items at once with the same constraints as
3437 * RTE_FLOW_CONV_OP_ITEM.
3440 * @code const struct rte_flow_item * @endcode
3442 * @code struct rte_flow_item * @endcode
3444 RTE_FLOW_CONV_OP_PATTERN,
3447 * Convert a list of actions.
3449 * Duplicates the entire list of actions at once with the same
3450 * constraints as RTE_FLOW_CONV_OP_ACTION.
3453 * @code const struct rte_flow_action * @endcode
3455 * @code struct rte_flow_action * @endcode
3457 RTE_FLOW_CONV_OP_ACTIONS,
3460 * Convert a complete flow rule description.
3462 * Comprises attributes, pattern and actions together at once with
3463 * the usual constraints.
3466 * @code const struct rte_flow_conv_rule * @endcode
3468 * @code struct rte_flow_conv_rule * @endcode
3470 RTE_FLOW_CONV_OP_RULE,
3473 * Convert item type to its name string.
3475 * Writes a NUL-terminated string to @p dst. Like snprintf(), the
3476 * returned value excludes the terminator which is always written
3480 * @code (const void *)enum rte_flow_item_type @endcode
3482 * @code char * @endcode
3484 RTE_FLOW_CONV_OP_ITEM_NAME,
3487 * Convert action type to its name string.
3489 * Writes a NUL-terminated string to @p dst. Like snprintf(), the
3490 * returned value excludes the terminator which is always written
3494 * @code (const void *)enum rte_flow_action_type @endcode
3496 * @code char * @endcode
3498 RTE_FLOW_CONV_OP_ACTION_NAME,
3501 * Convert item type to pointer to item name.
3503 * Retrieves item name pointer from its type. The string itself is
3504 * not copied; instead, a unique pointer to an internal static
3505 * constant storage is written to @p dst.
3508 * @code (const void *)enum rte_flow_item_type @endcode
3510 * @code const char ** @endcode
3512 RTE_FLOW_CONV_OP_ITEM_NAME_PTR,
3515 * Convert action type to pointer to action name.
3517 * Retrieves action name pointer from its type. The string itself is
3518 * not copied; instead, a unique pointer to an internal static
3519 * constant storage is written to @p dst.
3522 * @code (const void *)enum rte_flow_action_type @endcode
3524 * @code const char ** @endcode
3526 RTE_FLOW_CONV_OP_ACTION_NAME_PTR,
3531 * @b EXPERIMENTAL: this API may change without prior notice.
3533 * Dump hardware internal representation information of
3536 * @param[in] port_id
3537 * The port identifier of the Ethernet device.
3539 * The pointer of flow rule to dump. Dump all rules if NULL.
3541 * A pointer to a file for output.
3543 * Perform verbose error reporting if not NULL. PMDs initialize this
3544 * structure in case of error only.
3546 * 0 on success, a nagative value otherwise.
3550 rte_flow_dev_dump(uint16_t port_id, struct rte_flow *flow,
3551 FILE *file, struct rte_flow_error *error);
3554 * Check if mbuf dynamic field for metadata is registered.
3557 * True if registered, false otherwise.
3561 rte_flow_dynf_metadata_avail(void)
3563 return !!rte_flow_dynf_metadata_mask;
3567 * Register mbuf dynamic field and flag for metadata.
3569 * This function must be called prior to use SET_META action in order to
3570 * register the dynamic mbuf field. Otherwise, the data cannot be delivered to
3574 * 0 on success, a negative errno value otherwise and rte_errno is set.
3578 rte_flow_dynf_metadata_register(void);
3581 * Check whether a flow rule can be created on a given port.
3583 * The flow rule is validated for correctness and whether it could be accepted
3584 * by the device given sufficient resources. The rule is checked against the
3585 * current device mode and queue configuration. The flow rule may also
3586 * optionally be validated against existing flow rules and device resources.
3587 * This function has no effect on the target device.
3589 * The returned value is guaranteed to remain valid only as long as no
3590 * successful calls to rte_flow_create() or rte_flow_destroy() are made in
3591 * the meantime and no device parameter affecting flow rules in any way are
3592 * modified, due to possible collisions or resource limitations (although in
3593 * such cases EINVAL should not be returned).
3596 * Port identifier of Ethernet device.
3598 * Flow rule attributes.
3599 * @param[in] pattern
3600 * Pattern specification (list terminated by the END pattern item).
3601 * @param[in] actions
3602 * Associated actions (list terminated by the END action).
3604 * Perform verbose error reporting if not NULL. PMDs initialize this
3605 * structure in case of error only.
3608 * 0 if flow rule is valid and can be created. A negative errno value
3609 * otherwise (rte_errno is also set), the following errors are defined:
3611 * -ENOSYS: underlying device does not support this functionality.
3613 * -EIO: underlying device is removed.
3615 * -EINVAL: unknown or invalid rule specification.
3617 * -ENOTSUP: valid but unsupported rule specification (e.g. partial
3618 * bit-masks are unsupported).
3620 * -EEXIST: collision with an existing rule. Only returned if device
3621 * supports flow rule collision checking and there was a flow rule
3622 * collision. Not receiving this return code is no guarantee that creating
3623 * the rule will not fail due to a collision.
3625 * -ENOMEM: not enough memory to execute the function, or if the device
3626 * supports resource validation, resource limitation on the device.
3628 * -EBUSY: action cannot be performed due to busy device resources, may
3629 * succeed if the affected queues or even the entire port are in a stopped
3630 * state (see rte_eth_dev_rx_queue_stop() and rte_eth_dev_stop()).
3633 rte_flow_validate(uint16_t port_id,
3634 const struct rte_flow_attr *attr,
3635 const struct rte_flow_item pattern[],
3636 const struct rte_flow_action actions[],
3637 struct rte_flow_error *error);
3640 * Create a flow rule on a given port.
3643 * Port identifier of Ethernet device.
3645 * Flow rule attributes.
3646 * @param[in] pattern
3647 * Pattern specification (list terminated by the END pattern item).
3648 * @param[in] actions
3649 * Associated actions (list terminated by the END action).
3651 * Perform verbose error reporting if not NULL. PMDs initialize this
3652 * structure in case of error only.
3655 * A valid handle in case of success, NULL otherwise and rte_errno is set
3656 * to the positive version of one of the error codes defined for
3657 * rte_flow_validate().
3660 rte_flow_create(uint16_t port_id,
3661 const struct rte_flow_attr *attr,
3662 const struct rte_flow_item pattern[],
3663 const struct rte_flow_action actions[],
3664 struct rte_flow_error *error);
3667 * Destroy a flow rule on a given port.
3669 * Failure to destroy a flow rule handle may occur when other flow rules
3670 * depend on it, and destroying it would result in an inconsistent state.
3672 * This function is only guaranteed to succeed if handles are destroyed in
3673 * reverse order of their creation.
3676 * Port identifier of Ethernet device.
3678 * Flow rule handle to destroy.
3680 * Perform verbose error reporting if not NULL. PMDs initialize this
3681 * structure in case of error only.
3684 * 0 on success, a negative errno value otherwise and rte_errno is set.
3687 rte_flow_destroy(uint16_t port_id,
3688 struct rte_flow *flow,
3689 struct rte_flow_error *error);
3692 * Destroy all flow rules associated with a port.
3694 * In the unlikely event of failure, handles are still considered destroyed
3695 * and no longer valid but the port must be assumed to be in an inconsistent
3699 * Port identifier of Ethernet device.
3701 * Perform verbose error reporting if not NULL. PMDs initialize this
3702 * structure in case of error only.
3705 * 0 on success, a negative errno value otherwise and rte_errno is set.
3708 rte_flow_flush(uint16_t port_id,
3709 struct rte_flow_error *error);
3712 * Query an existing flow rule.
3714 * This function allows retrieving flow-specific data such as counters.
3715 * Data is gathered by special actions which must be present in the flow
3718 * \see RTE_FLOW_ACTION_TYPE_COUNT
3721 * Port identifier of Ethernet device.
3723 * Flow rule handle to query.
3725 * Action definition as defined in original flow rule.
3726 * @param[in, out] data
3727 * Pointer to storage for the associated query data type.
3729 * Perform verbose error reporting if not NULL. PMDs initialize this
3730 * structure in case of error only.
3733 * 0 on success, a negative errno value otherwise and rte_errno is set.
3736 rte_flow_query(uint16_t port_id,
3737 struct rte_flow *flow,
3738 const struct rte_flow_action *action,
3740 struct rte_flow_error *error);
3743 * Restrict ingress traffic to the defined flow rules.
3745 * Isolated mode guarantees that all ingress traffic comes from defined flow
3746 * rules only (current and future).
3748 * Besides making ingress more deterministic, it allows PMDs to safely reuse
3749 * resources otherwise assigned to handle the remaining traffic, such as
3750 * global RSS configuration settings, VLAN filters, MAC address entries,
3751 * legacy filter API rules and so on in order to expand the set of possible
3754 * Calling this function as soon as possible after device initialization,
3755 * ideally before the first call to rte_eth_dev_configure(), is recommended
3756 * to avoid possible failures due to conflicting settings.
3758 * Once effective, leaving isolated mode may not be possible depending on
3759 * PMD implementation.
3761 * Additionally, the following functionality has no effect on the underlying
3762 * port and may return errors such as ENOTSUP ("not supported"):
3764 * - Toggling promiscuous mode.
3765 * - Toggling allmulticast mode.
3766 * - Configuring MAC addresses.
3767 * - Configuring multicast addresses.
3768 * - Configuring VLAN filters.
3769 * - Configuring Rx filters through the legacy API (e.g. FDIR).
3770 * - Configuring global RSS settings.
3773 * Port identifier of Ethernet device.
3775 * Nonzero to enter isolated mode, attempt to leave it otherwise.
3777 * Perform verbose error reporting if not NULL. PMDs initialize this
3778 * structure in case of error only.
3781 * 0 on success, a negative errno value otherwise and rte_errno is set.
3784 rte_flow_isolate(uint16_t port_id, int set, struct rte_flow_error *error);
3787 * Initialize flow error structure.
3790 * Pointer to flow error structure (may be NULL).
3792 * Related error code (rte_errno).
3794 * Cause field and error types.
3796 * Object responsible for the error.
3798 * Human-readable error message.
3801 * Negative error code (errno value) and rte_errno is set.
3804 rte_flow_error_set(struct rte_flow_error *error,
3806 enum rte_flow_error_type type,
3808 const char *message);
3812 * @see rte_flow_copy()
3814 struct rte_flow_desc {
3815 size_t size; /**< Allocated space including data[]. */
3816 struct rte_flow_attr attr; /**< Attributes. */
3817 struct rte_flow_item *items; /**< Items. */
3818 struct rte_flow_action *actions; /**< Actions. */
3819 uint8_t data[]; /**< Storage for items/actions. */
3824 * Copy an rte_flow rule description.
3826 * This interface is kept for compatibility with older applications but is
3827 * implemented as a wrapper to rte_flow_conv(). It is deprecated due to its
3828 * lack of flexibility and reliance on a type unusable with C++ programs
3829 * (struct rte_flow_desc).
3832 * Flow rule description.
3834 * Total size of allocated data for the flow description.
3836 * Flow rule attributes.
3838 * Pattern specification (list terminated by the END pattern item).
3839 * @param[in] actions
3840 * Associated actions (list terminated by the END action).
3843 * If len is greater or equal to the size of the flow, the total size of the
3844 * flow description and its data.
3845 * If len is lower than the size of the flow, the number of bytes that would
3846 * have been written to desc had it been sufficient. Nothing is written.
3850 rte_flow_copy(struct rte_flow_desc *fd, size_t len,
3851 const struct rte_flow_attr *attr,
3852 const struct rte_flow_item *items,
3853 const struct rte_flow_action *actions);
3856 * Flow object conversion helper.
3858 * This function performs conversion of various flow API objects to a
3859 * pre-allocated destination buffer. See enum rte_flow_conv_op for possible
3860 * operations and details about each of them.
3862 * Since destination buffer must be large enough, it works in a manner
3863 * reminiscent of snprintf():
3865 * - If @p size is 0, @p dst may be a NULL pointer, otherwise @p dst must be
3867 * - If positive, the returned value represents the number of bytes needed
3868 * to store the conversion of @p src to @p dst according to @p op
3869 * regardless of the @p size parameter.
3870 * - Since no more than @p size bytes can be written to @p dst, output is
3871 * truncated and may be inconsistent when the returned value is larger
3873 * - In case of conversion error, a negative error code is returned and
3874 * @p dst contents are unspecified.
3877 * Operation to perform, related to the object type of @p dst.
3879 * Destination buffer address. Must be suitably aligned by the caller.
3881 * Destination buffer size in bytes.
3883 * Source object to copy. Depending on @p op, its type may differ from
3886 * Perform verbose error reporting if not NULL. Initialized in case of
3890 * The number of bytes required to convert @p src to @p dst on success, a
3891 * negative errno value otherwise and rte_errno is set.
3893 * @see rte_flow_conv_op
3897 rte_flow_conv(enum rte_flow_conv_op op,
3901 struct rte_flow_error *error);
3904 * Get aged-out flows of a given port.
3906 * RTE_ETH_EVENT_FLOW_AGED event will be triggered when at least one new aged
3907 * out flow was detected after the last call to rte_flow_get_aged_flows.
3908 * This function can be called to get the aged flows usynchronously from the
3909 * event callback or synchronously regardless the event.
3910 * This is not safe to call rte_flow_get_aged_flows function with other flow
3911 * functions from multiple threads simultaneously.
3914 * Port identifier of Ethernet device.
3915 * @param[in, out] contexts
3916 * The address of an array of pointers to the aged-out flows contexts.
3917 * @param[in] nb_contexts
3918 * The length of context array pointers.
3920 * Perform verbose error reporting if not NULL. Initialized in case of
3924 * if nb_contexts is 0, return the amount of all aged contexts.
3925 * if nb_contexts is not 0 , return the amount of aged flows reported
3926 * in the context array, otherwise negative errno value.
3928 * @see rte_flow_action_age
3929 * @see RTE_ETH_EVENT_FLOW_AGED
3933 rte_flow_get_aged_flows(uint16_t port_id, void **contexts,
3934 uint32_t nb_contexts, struct rte_flow_error *error);
3937 * Specify indirect action object configuration
3939 struct rte_flow_indir_action_conf {
3941 * Flow direction for the indirect action configuration.
3943 * Action should be valid at least for one flow direction,
3944 * otherwise it is invalid for both ingress and egress rules.
3947 /**< Action valid for rules applied to ingress traffic. */
3949 /**< Action valid for rules applied to egress traffic. */
3951 * When set to 1, indicates that the action is valid for
3952 * transfer traffic; otherwise, for non-transfer traffic.
3954 uint32_t transfer:1;
3959 * @b EXPERIMENTAL: this API may change without prior notice.
3961 * Create an indirect action object that can be used in flow rules
3963 * The created object handle has single state and configuration
3964 * across all the flow rules using it.
3966 * @param[in] port_id
3967 * The port identifier of the Ethernet device.
3969 * Action configuration for the indirect action object creation.
3971 * Specific configuration of the indirect action object.
3973 * Perform verbose error reporting if not NULL. PMDs initialize this
3974 * structure in case of error only.
3976 * A valid handle in case of success, NULL otherwise and rte_errno is set
3977 * to one of the error codes defined:
3978 * - (ENODEV) if *port_id* invalid.
3979 * - (ENOSYS) if underlying device does not support this functionality.
3980 * - (EIO) if underlying device is removed.
3981 * - (EINVAL) if *action* invalid.
3982 * - (ENOTSUP) if *action* valid but unsupported.
3985 struct rte_flow_action_handle *
3986 rte_flow_action_handle_create(uint16_t port_id,
3987 const struct rte_flow_indir_action_conf *conf,
3988 const struct rte_flow_action *action,
3989 struct rte_flow_error *error);
3993 * @b EXPERIMENTAL: this API may change without prior notice.
3995 * Destroy indirect action by handle.
3997 * @param[in] port_id
3998 * The port identifier of the Ethernet device.
4000 * Handle for the indirect action object to be destroyed.
4002 * Perform verbose error reporting if not NULL. PMDs initialize this
4003 * structure in case of error only.
4006 * - (-ENODEV) if *port_id* invalid.
4007 * - (-ENOSYS) if underlying device does not support this functionality.
4008 * - (-EIO) if underlying device is removed.
4009 * - (-ENOENT) if action pointed by *action* handle was not found.
4010 * - (-EBUSY) if action pointed by *action* handle still used by some rules
4011 * rte_errno is also set.
4015 rte_flow_action_handle_destroy(uint16_t port_id,
4016 struct rte_flow_action_handle *handle,
4017 struct rte_flow_error *error);
4021 * @b EXPERIMENTAL: this API may change without prior notice.
4023 * Update in-place the action configuration and / or state pointed
4024 * by action *handle* with the configuration provided as *update* argument.
4025 * The update of the action configuration effects all flow rules reusing
4026 * the action via *handle*.
4027 * The update general pointer provides the ability of partial updating.
4029 * @param[in] port_id
4030 * The port identifier of the Ethernet device.
4032 * Handle for the indirect action object to be updated.
4034 * Update profile specification used to modify the action pointed by handle.
4035 * *update* could be with the same type of the immediate action corresponding
4036 * to the *handle* argument when creating, or a wrapper structure includes
4037 * action configuration to be updated and bit fields to indicate the member
4038 * of fields inside the action to update.
4040 * Perform verbose error reporting if not NULL. PMDs initialize this
4041 * structure in case of error only.
4044 * - (-ENODEV) if *port_id* invalid.
4045 * - (-ENOSYS) if underlying device does not support this functionality.
4046 * - (-EIO) if underlying device is removed.
4047 * - (-EINVAL) if *update* invalid.
4048 * - (-ENOTSUP) if *update* valid but unsupported.
4049 * - (-ENOENT) if indirect action object pointed by *handle* was not found.
4050 * rte_errno is also set.
4054 rte_flow_action_handle_update(uint16_t port_id,
4055 struct rte_flow_action_handle *handle,
4057 struct rte_flow_error *error);
4061 * @b EXPERIMENTAL: this API may change without prior notice.
4063 * Query the direct action by corresponding indirect action object handle.
4065 * Retrieve action-specific data such as counters.
4066 * Data is gathered by special action which may be present/referenced in
4067 * more than one flow rule definition.
4069 * @see RTE_FLOW_ACTION_TYPE_COUNT
4072 * Port identifier of Ethernet device.
4074 * Handle for the action object to query.
4075 * @param[in, out] data
4076 * Pointer to storage for the associated query data type.
4078 * Perform verbose error reporting if not NULL. PMDs initialize this
4079 * structure in case of error only.
4082 * 0 on success, a negative errno value otherwise and rte_errno is set.
4086 rte_flow_action_handle_query(uint16_t port_id,
4087 const struct rte_flow_action_handle *handle,
4088 void *data, struct rte_flow_error *error);
4090 /* Tunnel has a type and the key information. */
4091 struct rte_flow_tunnel {
4093 * Tunnel type, for example RTE_FLOW_ITEM_TYPE_VXLAN,
4094 * RTE_FLOW_ITEM_TYPE_NVGRE etc.
4096 enum rte_flow_item_type type;
4097 uint64_t tun_id; /**< Tunnel identification. */
4102 rte_be32_t src_addr; /**< IPv4 source address. */
4103 rte_be32_t dst_addr; /**< IPv4 destination address. */
4106 uint8_t src_addr[16]; /**< IPv6 source address. */
4107 uint8_t dst_addr[16]; /**< IPv6 destination address. */
4110 rte_be16_t tp_src; /**< Tunnel port source. */
4111 rte_be16_t tp_dst; /**< Tunnel port destination. */
4112 uint16_t tun_flags; /**< Tunnel flags. */
4114 bool is_ipv6; /**< True for valid IPv6 fields. Otherwise IPv4. */
4117 * the following members are required to restore packet
4120 uint8_t tos; /**< TOS for IPv4, TC for IPv6. */
4121 uint8_t ttl; /**< TTL for IPv4, HL for IPv6. */
4122 uint32_t label; /**< Flow Label for IPv6. */
4126 * Indicate that the packet has a tunnel.
4128 #define RTE_FLOW_RESTORE_INFO_TUNNEL (1ULL << 0)
4131 * Indicate that the packet has a non decapsulated tunnel header.
4133 #define RTE_FLOW_RESTORE_INFO_ENCAPSULATED (1ULL << 1)
4136 * Indicate that the packet has a group_id.
4138 #define RTE_FLOW_RESTORE_INFO_GROUP_ID (1ULL << 2)
4141 * Restore information structure to communicate the current packet processing
4142 * state when some of the processing pipeline is done in hardware and should
4143 * continue in software.
4145 struct rte_flow_restore_info {
4147 * Bitwise flags (RTE_FLOW_RESTORE_INFO_*) to indicate validation of
4148 * other fields in struct rte_flow_restore_info.
4151 uint32_t group_id; /**< Group ID where packed missed */
4152 struct rte_flow_tunnel tunnel; /**< Tunnel information. */
4156 * Allocate an array of actions to be used in rte_flow_create, to implement
4157 * tunnel-decap-set for the given tunnel.
4159 * actions vxlan_decap / tunnel-decap-set(tunnel properties) /
4160 * jump group 0 / end
4163 * Port identifier of Ethernet device.
4165 * Tunnel properties.
4166 * @param[out] actions
4167 * Array of actions to be allocated by the PMD. This array should be
4168 * concatenated with the actions array provided to rte_flow_create.
4169 * @param[out] num_of_actions
4170 * Number of actions allocated.
4172 * Perform verbose error reporting if not NULL. PMDs initialize this
4173 * structure in case of error only.
4176 * 0 on success, a negative errno value otherwise and rte_errno is set.
4180 rte_flow_tunnel_decap_set(uint16_t port_id,
4181 struct rte_flow_tunnel *tunnel,
4182 struct rte_flow_action **actions,
4183 uint32_t *num_of_actions,
4184 struct rte_flow_error *error);
4187 * Allocate an array of items to be used in rte_flow_create, to implement
4188 * tunnel-match for the given tunnel.
4190 * pattern tunnel-match(tunnel properties) / outer-header-matches /
4191 * inner-header-matches / end
4194 * Port identifier of Ethernet device.
4196 * Tunnel properties.
4198 * Array of items to be allocated by the PMD. This array should be
4199 * concatenated with the items array provided to rte_flow_create.
4200 * @param[out] num_of_items
4201 * Number of items allocated.
4203 * Perform verbose error reporting if not NULL. PMDs initialize this
4204 * structure in case of error only.
4207 * 0 on success, a negative errno value otherwise and rte_errno is set.
4211 rte_flow_tunnel_match(uint16_t port_id,
4212 struct rte_flow_tunnel *tunnel,
4213 struct rte_flow_item **items,
4214 uint32_t *num_of_items,
4215 struct rte_flow_error *error);
4218 * Populate the current packet processing state, if exists, for the given mbuf.
4220 * One should negotiate tunnel metadata delivery from the NIC to the HW.
4221 * @see rte_eth_rx_metadata_negotiate()
4222 * @see RTE_ETH_RX_METADATA_TUNNEL_ID
4225 * Port identifier of Ethernet device.
4229 * Restore information. Upon success contains the HW state.
4231 * Perform verbose error reporting if not NULL. PMDs initialize this
4232 * structure in case of error only.
4235 * 0 on success, a negative errno value otherwise and rte_errno is set.
4239 rte_flow_get_restore_info(uint16_t port_id,
4241 struct rte_flow_restore_info *info,
4242 struct rte_flow_error *error);
4245 * Release the action array as allocated by rte_flow_tunnel_decap_set.
4248 * Port identifier of Ethernet device.
4249 * @param[in] actions
4250 * Array of actions to be released.
4251 * @param[in] num_of_actions
4252 * Number of elements in actions array.
4254 * Perform verbose error reporting if not NULL. PMDs initialize this
4255 * structure in case of error only.
4258 * 0 on success, a negative errno value otherwise and rte_errno is set.
4262 rte_flow_tunnel_action_decap_release(uint16_t port_id,
4263 struct rte_flow_action *actions,
4264 uint32_t num_of_actions,
4265 struct rte_flow_error *error);
4268 * Release the item array as allocated by rte_flow_tunnel_match.
4271 * Port identifier of Ethernet device.
4273 * Array of items to be released.
4274 * @param[in] num_of_items
4275 * Number of elements in item array.
4277 * Perform verbose error reporting if not NULL. PMDs initialize this
4278 * structure in case of error only.
4281 * 0 on success, a negative errno value otherwise and rte_errno is set.
4285 rte_flow_tunnel_item_release(uint16_t port_id,
4286 struct rte_flow_item *items,
4287 uint32_t num_of_items,
4288 struct rte_flow_error *error);
4293 #endif /* RTE_FLOW_H_ */