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>
42 * Flow rule attributes.
44 * Priorities are set on a per rule based within groups.
46 * Lower values denote higher priority, the highest priority for a flow rule
47 * is 0, so that a flow that matches for than one rule, the rule with the
48 * lowest priority value will always be matched.
50 * Although optional, applications are encouraged to group similar rules as
51 * much as possible to fully take advantage of hardware capabilities
52 * (e.g. optimized matching) and work around limitations (e.g. a single
53 * pattern type possibly allowed in a given group). Applications should be
54 * aware that groups are not linked by default, and that they must be
55 * explicitly linked by the application using the JUMP action.
57 * Priority levels are arbitrary and up to the application, they
58 * do not need to be contiguous nor start from 0, however the maximum number
59 * varies between devices and may be affected by existing flow rules.
61 * If a packet is matched by several rules of a given group for a given
62 * priority level, the outcome is undefined. It can take any path, may be
63 * duplicated or even cause unrecoverable errors.
65 * Note that support for more than a single group and priority level is not
68 * Flow rules can apply to inbound and/or outbound traffic (ingress/egress).
70 * Several pattern items and actions are valid and can be used in both
71 * directions. Those valid for only one direction are described as such.
73 * At least one direction must be specified.
75 * Specifying both directions at once for a given rule is not recommended
76 * but may be valid in a few cases (e.g. shared counter).
78 struct rte_flow_attr {
79 uint32_t group; /**< Priority group. */
80 uint32_t priority; /**< Rule priority level within group. */
81 uint32_t ingress:1; /**< Rule applies to ingress traffic. */
82 uint32_t egress:1; /**< Rule applies to egress traffic. */
84 * Instead of simply matching the properties of traffic as it would
85 * appear on a given DPDK port ID, enabling this attribute transfers
86 * a flow rule to the lowest possible level of any device endpoints
87 * found in the pattern.
89 * When supported, this effectively enables an application to
90 * re-route traffic not necessarily intended for it (e.g. coming
91 * from or addressed to different physical ports, VFs or
92 * applications) at the device level.
94 * It complements the behavior of some pattern items such as
95 * RTE_FLOW_ITEM_TYPE_PHY_PORT and is meaningless without them.
97 * When transferring flow rules, ingress and egress attributes keep
98 * their original meaning, as if processing traffic emitted or
99 * received by the application.
102 uint32_t reserved:29; /**< Reserved, must be zero. */
106 * Matching pattern item types.
108 * Pattern items fall in two categories:
110 * - Matching protocol headers and packet data, usually associated with a
111 * specification structure. These must be stacked in the same order as the
112 * protocol layers to match inside packets, starting from the lowest.
114 * - Matching meta-data or affecting pattern processing, often without a
115 * specification structure. Since they do not match packet contents, their
116 * position in the list is usually not relevant.
118 * See the description of individual types for more information. Those
119 * marked with [META] fall into the second category.
121 enum rte_flow_item_type {
125 * End marker for item lists. Prevents further processing of items,
126 * thereby ending the pattern.
128 * No associated specification structure.
130 RTE_FLOW_ITEM_TYPE_END,
135 * Used as a placeholder for convenience. It is ignored and simply
138 * No associated specification structure.
140 RTE_FLOW_ITEM_TYPE_VOID,
145 * Inverted matching, i.e. process packets that do not match the
148 * No associated specification structure.
150 RTE_FLOW_ITEM_TYPE_INVERT,
153 * Matches any protocol in place of the current layer, a single ANY
154 * may also stand for several protocol layers.
156 * See struct rte_flow_item_any.
158 RTE_FLOW_ITEM_TYPE_ANY,
163 * Matches traffic originating from (ingress) or going to (egress)
164 * the physical function of the current device.
166 * No associated specification structure.
168 RTE_FLOW_ITEM_TYPE_PF,
173 * Matches traffic originating from (ingress) or going to (egress) a
174 * given virtual function of the current device.
176 * See struct rte_flow_item_vf.
178 RTE_FLOW_ITEM_TYPE_VF,
183 * Matches traffic originating from (ingress) or going to (egress) a
184 * physical port of the underlying device.
186 * See struct rte_flow_item_phy_port.
188 RTE_FLOW_ITEM_TYPE_PHY_PORT,
193 * Matches traffic originating from (ingress) or going to (egress) a
194 * given DPDK port ID.
196 * See struct rte_flow_item_port_id.
198 RTE_FLOW_ITEM_TYPE_PORT_ID,
201 * Matches a byte string of a given length at a given offset.
203 * See struct rte_flow_item_raw.
205 RTE_FLOW_ITEM_TYPE_RAW,
208 * Matches an Ethernet header.
210 * See struct rte_flow_item_eth.
212 RTE_FLOW_ITEM_TYPE_ETH,
215 * Matches an 802.1Q/ad VLAN tag.
217 * See struct rte_flow_item_vlan.
219 RTE_FLOW_ITEM_TYPE_VLAN,
222 * Matches an IPv4 header.
224 * See struct rte_flow_item_ipv4.
226 RTE_FLOW_ITEM_TYPE_IPV4,
229 * Matches an IPv6 header.
231 * See struct rte_flow_item_ipv6.
233 RTE_FLOW_ITEM_TYPE_IPV6,
236 * Matches an ICMP header.
238 * See struct rte_flow_item_icmp.
240 RTE_FLOW_ITEM_TYPE_ICMP,
243 * Matches a UDP header.
245 * See struct rte_flow_item_udp.
247 RTE_FLOW_ITEM_TYPE_UDP,
250 * Matches a TCP header.
252 * See struct rte_flow_item_tcp.
254 RTE_FLOW_ITEM_TYPE_TCP,
257 * Matches a SCTP header.
259 * See struct rte_flow_item_sctp.
261 RTE_FLOW_ITEM_TYPE_SCTP,
264 * Matches a VXLAN header.
266 * See struct rte_flow_item_vxlan.
268 RTE_FLOW_ITEM_TYPE_VXLAN,
271 * Matches a E_TAG header.
273 * See struct rte_flow_item_e_tag.
275 RTE_FLOW_ITEM_TYPE_E_TAG,
278 * Matches a NVGRE header.
280 * See struct rte_flow_item_nvgre.
282 RTE_FLOW_ITEM_TYPE_NVGRE,
285 * Matches a MPLS header.
287 * See struct rte_flow_item_mpls.
289 RTE_FLOW_ITEM_TYPE_MPLS,
292 * Matches a GRE header.
294 * See struct rte_flow_item_gre.
296 RTE_FLOW_ITEM_TYPE_GRE,
301 * Fuzzy pattern match, expect faster than default.
303 * This is for device that support fuzzy matching option.
304 * Usually a fuzzy matching is fast but the cost is accuracy.
306 * See struct rte_flow_item_fuzzy.
308 RTE_FLOW_ITEM_TYPE_FUZZY,
311 * Matches a GTP header.
313 * Configure flow for GTP packets.
315 * See struct rte_flow_item_gtp.
317 RTE_FLOW_ITEM_TYPE_GTP,
320 * Matches a GTP header.
322 * Configure flow for GTP-C packets.
324 * See struct rte_flow_item_gtp.
326 RTE_FLOW_ITEM_TYPE_GTPC,
329 * Matches a GTP header.
331 * Configure flow for GTP-U packets.
333 * See struct rte_flow_item_gtp.
335 RTE_FLOW_ITEM_TYPE_GTPU,
338 * Matches a ESP header.
340 * See struct rte_flow_item_esp.
342 RTE_FLOW_ITEM_TYPE_ESP,
345 * Matches a GENEVE header.
347 * See struct rte_flow_item_geneve.
349 RTE_FLOW_ITEM_TYPE_GENEVE,
352 * Matches a VXLAN-GPE header.
354 * See struct rte_flow_item_vxlan_gpe.
356 RTE_FLOW_ITEM_TYPE_VXLAN_GPE,
359 * Matches an ARP header for Ethernet/IPv4.
361 * See struct rte_flow_item_arp_eth_ipv4.
363 RTE_FLOW_ITEM_TYPE_ARP_ETH_IPV4,
366 * Matches the presence of any IPv6 extension header.
368 * See struct rte_flow_item_ipv6_ext.
370 RTE_FLOW_ITEM_TYPE_IPV6_EXT,
373 * Matches any ICMPv6 header.
375 * See struct rte_flow_item_icmp6.
377 RTE_FLOW_ITEM_TYPE_ICMP6,
380 * Matches an ICMPv6 neighbor discovery solicitation.
382 * See struct rte_flow_item_icmp6_nd_ns.
384 RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS,
387 * Matches an ICMPv6 neighbor discovery advertisement.
389 * See struct rte_flow_item_icmp6_nd_na.
391 RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA,
394 * Matches the presence of any ICMPv6 neighbor discovery option.
396 * See struct rte_flow_item_icmp6_nd_opt.
398 RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT,
401 * Matches an ICMPv6 neighbor discovery source Ethernet link-layer
404 * See struct rte_flow_item_icmp6_nd_opt_sla_eth.
406 RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_SLA_ETH,
409 * Matches an ICMPv6 neighbor discovery target Ethernet link-layer
412 * See struct rte_flow_item_icmp6_nd_opt_tla_eth.
414 RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_TLA_ETH,
417 * Matches specified mark field.
419 * See struct rte_flow_item_mark.
421 RTE_FLOW_ITEM_TYPE_MARK,
426 * Matches a metadata value.
428 * See struct rte_flow_item_meta.
430 RTE_FLOW_ITEM_TYPE_META,
433 * Matches a GRE optional key field.
435 * The value should a big-endian 32bit integer.
437 * When this item present the K bit is implicitly matched as "1"
438 * in the default mask.
441 * @code rte_be32_t * @endcode
443 RTE_FLOW_ITEM_TYPE_GRE_KEY,
446 * Matches a GTP extension header: PDU session container.
448 * Configure flow for GTP packets with extension header type 0x85.
450 * See struct rte_flow_item_gtp_psc.
452 RTE_FLOW_ITEM_TYPE_GTP_PSC,
455 * Matches a PPPoE header.
457 * Configure flow for PPPoE session packets.
459 * See struct rte_flow_item_pppoe.
461 RTE_FLOW_ITEM_TYPE_PPPOES,
464 * Matches a PPPoE header.
466 * Configure flow for PPPoE discovery packets.
468 * See struct rte_flow_item_pppoe.
470 RTE_FLOW_ITEM_TYPE_PPPOED,
473 * Matches a PPPoE optional proto_id field.
475 * It only applies to PPPoE session packets.
477 * See struct rte_flow_item_pppoe_proto_id.
479 RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID,
482 * Matches Network service header (NSH).
483 * See struct rte_flow_item_nsh.
486 RTE_FLOW_ITEM_TYPE_NSH,
489 * Matches Internet Group Management Protocol (IGMP).
490 * See struct rte_flow_item_igmp.
493 RTE_FLOW_ITEM_TYPE_IGMP,
496 * Matches IP Authentication Header (AH).
497 * See struct rte_flow_item_ah.
500 RTE_FLOW_ITEM_TYPE_AH,
503 * Matches a HIGIG header.
504 * see struct rte_flow_item_higig2_hdr.
506 RTE_FLOW_ITEM_TYPE_HIGIG2,
511 * Matches a tag value.
513 * See struct rte_flow_item_tag.
515 RTE_FLOW_ITEM_TYPE_TAG,
518 * Matches a L2TPv3 over IP header.
520 * Configure flow for L2TPv3 over IP packets.
522 * See struct rte_flow_item_l2tpv3oip.
524 RTE_FLOW_ITEM_TYPE_L2TPV3OIP,
527 * Matches PFCP Header.
528 * See struct rte_flow_item_pfcp.
531 RTE_FLOW_ITEM_TYPE_PFCP,
534 * Matches eCPRI Header.
536 * Configure flow for eCPRI over ETH or UDP packets.
538 * See struct rte_flow_item_ecpri.
540 RTE_FLOW_ITEM_TYPE_ECPRI,
543 * Matches the presence of IPv6 fragment extension header.
545 * See struct rte_flow_item_ipv6_frag_ext.
547 RTE_FLOW_ITEM_TYPE_IPV6_FRAG_EXT,
550 * Matches Geneve Variable Length Option
552 * See struct rte_flow_item_geneve_opt
554 RTE_FLOW_ITEM_TYPE_GENEVE_OPT,
559 * Matches on packet integrity.
560 * For some devices application needs to enable integration checks in HW
561 * before using this item.
563 * @see struct rte_flow_item_integrity.
565 RTE_FLOW_ITEM_TYPE_INTEGRITY,
570 * Matches conntrack state.
572 * @see struct rte_flow_item_conntrack.
574 RTE_FLOW_ITEM_TYPE_CONNTRACK,
579 * RTE_FLOW_ITEM_TYPE_HIGIG2
580 * Matches higig2 header
583 struct rte_flow_item_higig2_hdr {
584 struct rte_higig2_hdr hdr;
587 /** Default mask for RTE_FLOW_ITEM_TYPE_HIGIG2. */
589 static const struct rte_flow_item_higig2_hdr rte_flow_item_higig2_hdr_mask = {
592 .classification = 0xffff,
600 * RTE_FLOW_ITEM_TYPE_ANY
602 * Matches any protocol in place of the current layer, a single ANY may also
603 * stand for several protocol layers.
605 * This is usually specified as the first pattern item when looking for a
606 * protocol anywhere in a packet.
608 * A zeroed mask stands for any number of layers.
610 struct rte_flow_item_any {
611 uint32_t num; /**< Number of layers covered. */
614 /** Default mask for RTE_FLOW_ITEM_TYPE_ANY. */
616 static const struct rte_flow_item_any rte_flow_item_any_mask = {
622 * RTE_FLOW_ITEM_TYPE_VF
624 * Matches traffic originating from (ingress) or going to (egress) a given
625 * virtual function of the current device.
627 * If supported, should work even if the virtual function is not managed by
628 * the application and thus not associated with a DPDK port ID.
630 * Note this pattern item does not match VF representors traffic which, as
631 * separate entities, should be addressed through their own DPDK port IDs.
633 * - Can be specified multiple times to match traffic addressed to several
635 * - Can be combined with a PF item to match both PF and VF traffic.
637 * A zeroed mask can be used to match any VF ID.
639 struct rte_flow_item_vf {
640 uint32_t id; /**< VF ID. */
643 /** Default mask for RTE_FLOW_ITEM_TYPE_VF. */
645 static const struct rte_flow_item_vf rte_flow_item_vf_mask = {
651 * RTE_FLOW_ITEM_TYPE_PHY_PORT
653 * Matches traffic originating from (ingress) or going to (egress) a
654 * physical port of the underlying device.
656 * The first PHY_PORT item overrides the physical port normally associated
657 * with the specified DPDK input port (port_id). This item can be provided
658 * several times to match additional physical ports.
660 * Note that physical ports are not necessarily tied to DPDK input ports
661 * (port_id) when those are not under DPDK control. Possible values are
662 * specific to each device, they are not necessarily indexed from zero and
663 * may not be contiguous.
665 * As a device property, the list of allowed values as well as the value
666 * associated with a port_id should be retrieved by other means.
668 * A zeroed mask can be used to match any port index.
670 struct rte_flow_item_phy_port {
671 uint32_t index; /**< Physical port index. */
674 /** Default mask for RTE_FLOW_ITEM_TYPE_PHY_PORT. */
676 static const struct rte_flow_item_phy_port rte_flow_item_phy_port_mask = {
682 * RTE_FLOW_ITEM_TYPE_PORT_ID
684 * Matches traffic originating from (ingress) or going to (egress) a given
687 * Normally only supported if the port ID in question is known by the
688 * underlying PMD and related to the device the flow rule is created
691 * This must not be confused with @p PHY_PORT which refers to the physical
692 * port of a device, whereas @p PORT_ID refers to a struct rte_eth_dev
693 * object on the application side (also known as "port representor"
694 * depending on the kind of underlying device).
696 struct rte_flow_item_port_id {
697 uint32_t id; /**< DPDK port ID. */
700 /** Default mask for RTE_FLOW_ITEM_TYPE_PORT_ID. */
702 static const struct rte_flow_item_port_id rte_flow_item_port_id_mask = {
708 * RTE_FLOW_ITEM_TYPE_RAW
710 * Matches a byte string of a given length at a given offset.
712 * Offset is either absolute (using the start of the packet) or relative to
713 * the end of the previous matched item in the stack, in which case negative
714 * values are allowed.
716 * If search is enabled, offset is used as the starting point. The search
717 * area can be delimited by setting limit to a nonzero value, which is the
718 * maximum number of bytes after offset where the pattern may start.
720 * Matching a zero-length pattern is allowed, doing so resets the relative
721 * offset for subsequent items.
723 * This type does not support ranges (struct rte_flow_item.last).
725 struct rte_flow_item_raw {
726 uint32_t relative:1; /**< Look for pattern after the previous item. */
727 uint32_t search:1; /**< Search pattern from offset (see also limit). */
728 uint32_t reserved:30; /**< Reserved, must be set to zero. */
729 int32_t offset; /**< Absolute or relative offset for pattern. */
730 uint16_t limit; /**< Search area limit for start of pattern. */
731 uint16_t length; /**< Pattern length. */
732 const uint8_t *pattern; /**< Byte string to look for. */
735 /** Default mask for RTE_FLOW_ITEM_TYPE_RAW. */
737 static const struct rte_flow_item_raw rte_flow_item_raw_mask = {
740 .reserved = 0x3fffffff,
741 .offset = 0xffffffff,
749 * RTE_FLOW_ITEM_TYPE_ETH
751 * Matches an Ethernet header.
753 * Inside @p hdr field, the sub-field @p ether_type stands either for EtherType
754 * or TPID, depending on whether the item is followed by a VLAN item or not. If
755 * two VLAN items follow, the sub-field refers to the outer one, which, in turn,
756 * contains the inner TPID in the similar header field. The innermost VLAN item
757 * contains a layer-3 EtherType. All of that follows the order seen on the wire.
759 * If the field in question contains a TPID value, only tagged packets with the
760 * specified TPID will match the pattern. Alternatively, it's possible to match
761 * any type of tagged packets by means of the field @p has_vlan rather than use
762 * the EtherType/TPID field. Also, it's possible to leave the two fields unused.
763 * If this is the case, both tagged and untagged packets will match the pattern.
766 struct rte_flow_item_eth {
770 * These fields are retained for compatibility.
771 * Please switch to the new header field below.
773 struct rte_ether_addr dst; /**< Destination MAC. */
774 struct rte_ether_addr src; /**< Source MAC. */
775 rte_be16_t type; /**< EtherType or TPID. */
777 struct rte_ether_hdr hdr;
779 uint32_t has_vlan:1; /**< Packet header contains at least one VLAN. */
780 uint32_t reserved:31; /**< Reserved, must be zero. */
783 /** Default mask for RTE_FLOW_ITEM_TYPE_ETH. */
785 static const struct rte_flow_item_eth rte_flow_item_eth_mask = {
786 .hdr.d_addr.addr_bytes = "\xff\xff\xff\xff\xff\xff",
787 .hdr.s_addr.addr_bytes = "\xff\xff\xff\xff\xff\xff",
788 .hdr.ether_type = RTE_BE16(0x0000),
793 * RTE_FLOW_ITEM_TYPE_VLAN
795 * Matches an 802.1Q/ad VLAN tag.
797 * The corresponding standard outer EtherType (TPID) values are
798 * RTE_ETHER_TYPE_VLAN or RTE_ETHER_TYPE_QINQ. It can be overridden by
799 * the preceding pattern item.
800 * If a @p VLAN item is present in the pattern, then only tagged packets will
802 * The field @p has_more_vlan can be used to match any type of tagged packets,
803 * instead of using the @p eth_proto field of @p hdr.
804 * If the @p eth_proto of @p hdr and @p has_more_vlan fields are not specified,
805 * then any tagged packets will match the pattern.
808 struct rte_flow_item_vlan {
812 * These fields are retained for compatibility.
813 * Please switch to the new header field below.
815 rte_be16_t tci; /**< Tag control information. */
816 rte_be16_t inner_type; /**< Inner EtherType or TPID. */
818 struct rte_vlan_hdr hdr;
820 uint32_t has_more_vlan:1;
821 /**< Packet header contains at least one more VLAN, after this VLAN. */
822 uint32_t reserved:31; /**< Reserved, must be zero. */
825 /** Default mask for RTE_FLOW_ITEM_TYPE_VLAN. */
827 static const struct rte_flow_item_vlan rte_flow_item_vlan_mask = {
828 .hdr.vlan_tci = RTE_BE16(0x0fff),
829 .hdr.eth_proto = RTE_BE16(0x0000),
834 * RTE_FLOW_ITEM_TYPE_IPV4
836 * Matches an IPv4 header.
838 * Note: IPv4 options are handled by dedicated pattern items.
840 struct rte_flow_item_ipv4 {
841 struct rte_ipv4_hdr hdr; /**< IPv4 header definition. */
844 /** Default mask for RTE_FLOW_ITEM_TYPE_IPV4. */
846 static const struct rte_flow_item_ipv4 rte_flow_item_ipv4_mask = {
848 .src_addr = RTE_BE32(0xffffffff),
849 .dst_addr = RTE_BE32(0xffffffff),
855 * RTE_FLOW_ITEM_TYPE_IPV6.
857 * Matches an IPv6 header.
859 * Dedicated flags indicate if header contains specific extension headers.
861 struct rte_flow_item_ipv6 {
862 struct rte_ipv6_hdr hdr; /**< IPv6 header definition. */
863 uint32_t has_hop_ext:1;
864 /**< Header contains Hop-by-Hop Options extension header. */
865 uint32_t has_route_ext:1;
866 /**< Header contains Routing extension header. */
867 uint32_t has_frag_ext:1;
868 /**< Header contains Fragment extension header. */
869 uint32_t has_auth_ext:1;
870 /**< Header contains Authentication extension header. */
871 uint32_t has_esp_ext:1;
872 /**< Header contains Encapsulation Security Payload extension header. */
873 uint32_t has_dest_ext:1;
874 /**< Header contains Destination Options extension header. */
875 uint32_t has_mobil_ext:1;
876 /**< Header contains Mobility extension header. */
877 uint32_t has_hip_ext:1;
878 /**< Header contains Host Identity Protocol extension header. */
879 uint32_t has_shim6_ext:1;
880 /**< Header contains Shim6 Protocol extension header. */
881 uint32_t reserved:23;
882 /**< Reserved for future extension headers, must be zero. */
885 /** Default mask for RTE_FLOW_ITEM_TYPE_IPV6. */
887 static const struct rte_flow_item_ipv6 rte_flow_item_ipv6_mask = {
890 "\xff\xff\xff\xff\xff\xff\xff\xff"
891 "\xff\xff\xff\xff\xff\xff\xff\xff",
893 "\xff\xff\xff\xff\xff\xff\xff\xff"
894 "\xff\xff\xff\xff\xff\xff\xff\xff",
900 * RTE_FLOW_ITEM_TYPE_ICMP.
902 * Matches an ICMP header.
904 struct rte_flow_item_icmp {
905 struct rte_icmp_hdr hdr; /**< ICMP header definition. */
908 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP. */
910 static const struct rte_flow_item_icmp rte_flow_item_icmp_mask = {
919 * RTE_FLOW_ITEM_TYPE_UDP.
921 * Matches a UDP header.
923 struct rte_flow_item_udp {
924 struct rte_udp_hdr hdr; /**< UDP header definition. */
927 /** Default mask for RTE_FLOW_ITEM_TYPE_UDP. */
929 static const struct rte_flow_item_udp rte_flow_item_udp_mask = {
931 .src_port = RTE_BE16(0xffff),
932 .dst_port = RTE_BE16(0xffff),
938 * RTE_FLOW_ITEM_TYPE_TCP.
940 * Matches a TCP header.
942 struct rte_flow_item_tcp {
943 struct rte_tcp_hdr hdr; /**< TCP header definition. */
946 /** Default mask for RTE_FLOW_ITEM_TYPE_TCP. */
948 static const struct rte_flow_item_tcp rte_flow_item_tcp_mask = {
950 .src_port = RTE_BE16(0xffff),
951 .dst_port = RTE_BE16(0xffff),
957 * RTE_FLOW_ITEM_TYPE_SCTP.
959 * Matches a SCTP header.
961 struct rte_flow_item_sctp {
962 struct rte_sctp_hdr hdr; /**< SCTP header definition. */
965 /** Default mask for RTE_FLOW_ITEM_TYPE_SCTP. */
967 static const struct rte_flow_item_sctp rte_flow_item_sctp_mask = {
969 .src_port = RTE_BE16(0xffff),
970 .dst_port = RTE_BE16(0xffff),
976 * RTE_FLOW_ITEM_TYPE_VXLAN.
978 * Matches a VXLAN header (RFC 7348).
981 struct rte_flow_item_vxlan {
985 * These fields are retained for compatibility.
986 * Please switch to the new header field below.
988 uint8_t flags; /**< Normally 0x08 (I flag). */
989 uint8_t rsvd0[3]; /**< Reserved, normally 0x000000. */
990 uint8_t vni[3]; /**< VXLAN identifier. */
991 uint8_t rsvd1; /**< Reserved, normally 0x00. */
993 struct rte_vxlan_hdr hdr;
997 /** Default mask for RTE_FLOW_ITEM_TYPE_VXLAN. */
999 static const struct rte_flow_item_vxlan rte_flow_item_vxlan_mask = {
1000 .hdr.vx_vni = RTE_BE32(0xffffff00), /* (0xffffff << 8) */
1005 * RTE_FLOW_ITEM_TYPE_E_TAG.
1007 * Matches a E-tag header.
1009 * The corresponding standard outer EtherType (TPID) value is
1010 * RTE_ETHER_TYPE_ETAG. It can be overridden by the preceding pattern item.
1012 struct rte_flow_item_e_tag {
1014 * E-Tag control information (E-TCI).
1015 * E-PCP (3b), E-DEI (1b), ingress E-CID base (12b).
1017 rte_be16_t epcp_edei_in_ecid_b;
1018 /** Reserved (2b), GRP (2b), E-CID base (12b). */
1019 rte_be16_t rsvd_grp_ecid_b;
1020 uint8_t in_ecid_e; /**< Ingress E-CID ext. */
1021 uint8_t ecid_e; /**< E-CID ext. */
1022 rte_be16_t inner_type; /**< Inner EtherType or TPID. */
1025 /** Default mask for RTE_FLOW_ITEM_TYPE_E_TAG. */
1027 static const struct rte_flow_item_e_tag rte_flow_item_e_tag_mask = {
1028 .rsvd_grp_ecid_b = RTE_BE16(0x3fff),
1033 * RTE_FLOW_ITEM_TYPE_NVGRE.
1035 * Matches a NVGRE header.
1037 struct rte_flow_item_nvgre {
1039 * Checksum (1b), undefined (1b), key bit (1b), sequence number (1b),
1040 * reserved 0 (9b), version (3b).
1042 * c_k_s_rsvd0_ver must have value 0x2000 according to RFC 7637.
1044 rte_be16_t c_k_s_rsvd0_ver;
1045 rte_be16_t protocol; /**< Protocol type (0x6558). */
1046 uint8_t tni[3]; /**< Virtual subnet ID. */
1047 uint8_t flow_id; /**< Flow ID. */
1050 /** Default mask for RTE_FLOW_ITEM_TYPE_NVGRE. */
1052 static const struct rte_flow_item_nvgre rte_flow_item_nvgre_mask = {
1053 .tni = "\xff\xff\xff",
1058 * RTE_FLOW_ITEM_TYPE_MPLS.
1060 * Matches a MPLS header.
1062 struct rte_flow_item_mpls {
1064 * Label (20b), TC (3b), Bottom of Stack (1b).
1066 uint8_t label_tc_s[3];
1067 uint8_t ttl; /** Time-to-Live. */
1070 /** Default mask for RTE_FLOW_ITEM_TYPE_MPLS. */
1072 static const struct rte_flow_item_mpls rte_flow_item_mpls_mask = {
1073 .label_tc_s = "\xff\xff\xf0",
1078 * RTE_FLOW_ITEM_TYPE_GRE.
1080 * Matches a GRE header.
1082 struct rte_flow_item_gre {
1084 * Checksum (1b), reserved 0 (12b), version (3b).
1085 * Refer to RFC 2784.
1087 rte_be16_t c_rsvd0_ver;
1088 rte_be16_t protocol; /**< Protocol type. */
1091 /** Default mask for RTE_FLOW_ITEM_TYPE_GRE. */
1093 static const struct rte_flow_item_gre rte_flow_item_gre_mask = {
1094 .protocol = RTE_BE16(0xffff),
1099 * RTE_FLOW_ITEM_TYPE_FUZZY
1101 * Fuzzy pattern match, expect faster than default.
1103 * This is for device that support fuzzy match option.
1104 * Usually a fuzzy match is fast but the cost is accuracy.
1105 * i.e. Signature Match only match pattern's hash value, but it is
1106 * possible two different patterns have the same hash value.
1108 * Matching accuracy level can be configure by threshold.
1109 * Driver can divide the range of threshold and map to different
1110 * accuracy levels that device support.
1112 * Threshold 0 means perfect match (no fuzziness), while threshold
1113 * 0xffffffff means fuzziest match.
1115 struct rte_flow_item_fuzzy {
1116 uint32_t thresh; /**< Accuracy threshold. */
1119 /** Default mask for RTE_FLOW_ITEM_TYPE_FUZZY. */
1121 static const struct rte_flow_item_fuzzy rte_flow_item_fuzzy_mask = {
1122 .thresh = 0xffffffff,
1127 * RTE_FLOW_ITEM_TYPE_GTP.
1129 * Matches a GTPv1 header.
1131 struct rte_flow_item_gtp {
1133 * Version (3b), protocol type (1b), reserved (1b),
1134 * Extension header flag (1b),
1135 * Sequence number flag (1b),
1136 * N-PDU number flag (1b).
1138 uint8_t v_pt_rsv_flags;
1139 uint8_t msg_type; /**< Message type. */
1140 rte_be16_t msg_len; /**< Message length. */
1141 rte_be32_t teid; /**< Tunnel endpoint identifier. */
1144 /** Default mask for RTE_FLOW_ITEM_TYPE_GTP. */
1146 static const struct rte_flow_item_gtp rte_flow_item_gtp_mask = {
1147 .teid = RTE_BE32(0xffffffff),
1152 * RTE_FLOW_ITEM_TYPE_ESP
1154 * Matches an ESP header.
1156 struct rte_flow_item_esp {
1157 struct rte_esp_hdr hdr; /**< ESP header definition. */
1160 /** Default mask for RTE_FLOW_ITEM_TYPE_ESP. */
1162 static const struct rte_flow_item_esp rte_flow_item_esp_mask = {
1164 .spi = RTE_BE32(0xffffffff),
1170 * RTE_FLOW_ITEM_TYPE_GENEVE.
1172 * Matches a GENEVE header.
1174 struct rte_flow_item_geneve {
1176 * Version (2b), length of the options fields (6b), OAM packet (1b),
1177 * critical options present (1b), reserved 0 (6b).
1179 rte_be16_t ver_opt_len_o_c_rsvd0;
1180 rte_be16_t protocol; /**< Protocol type. */
1181 uint8_t vni[3]; /**< Virtual Network Identifier. */
1182 uint8_t rsvd1; /**< Reserved, normally 0x00. */
1185 /** Default mask for RTE_FLOW_ITEM_TYPE_GENEVE. */
1187 static const struct rte_flow_item_geneve rte_flow_item_geneve_mask = {
1188 .vni = "\xff\xff\xff",
1193 * RTE_FLOW_ITEM_TYPE_VXLAN_GPE (draft-ietf-nvo3-vxlan-gpe-05).
1195 * Matches a VXLAN-GPE header.
1197 struct rte_flow_item_vxlan_gpe {
1198 uint8_t flags; /**< Normally 0x0c (I and P flags). */
1199 uint8_t rsvd0[2]; /**< Reserved, normally 0x0000. */
1200 uint8_t protocol; /**< Protocol type. */
1201 uint8_t vni[3]; /**< VXLAN identifier. */
1202 uint8_t rsvd1; /**< Reserved, normally 0x00. */
1205 /** Default mask for RTE_FLOW_ITEM_TYPE_VXLAN_GPE. */
1207 static const struct rte_flow_item_vxlan_gpe rte_flow_item_vxlan_gpe_mask = {
1208 .vni = "\xff\xff\xff",
1213 * RTE_FLOW_ITEM_TYPE_ARP_ETH_IPV4
1215 * Matches an ARP header for Ethernet/IPv4.
1217 struct rte_flow_item_arp_eth_ipv4 {
1218 rte_be16_t hrd; /**< Hardware type, normally 1. */
1219 rte_be16_t pro; /**< Protocol type, normally 0x0800. */
1220 uint8_t hln; /**< Hardware address length, normally 6. */
1221 uint8_t pln; /**< Protocol address length, normally 4. */
1222 rte_be16_t op; /**< Opcode (1 for request, 2 for reply). */
1223 struct rte_ether_addr sha; /**< Sender hardware address. */
1224 rte_be32_t spa; /**< Sender IPv4 address. */
1225 struct rte_ether_addr tha; /**< Target hardware address. */
1226 rte_be32_t tpa; /**< Target IPv4 address. */
1229 /** Default mask for RTE_FLOW_ITEM_TYPE_ARP_ETH_IPV4. */
1231 static const struct rte_flow_item_arp_eth_ipv4
1232 rte_flow_item_arp_eth_ipv4_mask = {
1233 .sha.addr_bytes = "\xff\xff\xff\xff\xff\xff",
1234 .spa = RTE_BE32(0xffffffff),
1235 .tha.addr_bytes = "\xff\xff\xff\xff\xff\xff",
1236 .tpa = RTE_BE32(0xffffffff),
1241 * RTE_FLOW_ITEM_TYPE_IPV6_EXT
1243 * Matches the presence of any IPv6 extension header.
1245 * Normally preceded by any of:
1247 * - RTE_FLOW_ITEM_TYPE_IPV6
1248 * - RTE_FLOW_ITEM_TYPE_IPV6_EXT
1250 struct rte_flow_item_ipv6_ext {
1251 uint8_t next_hdr; /**< Next header. */
1254 /** Default mask for RTE_FLOW_ITEM_TYPE_IPV6_EXT. */
1257 struct rte_flow_item_ipv6_ext rte_flow_item_ipv6_ext_mask = {
1263 * RTE_FLOW_ITEM_TYPE_IPV6_FRAG_EXT
1265 * Matches the presence of IPv6 fragment extension header.
1267 * Preceded by any of:
1269 * - RTE_FLOW_ITEM_TYPE_IPV6
1270 * - RTE_FLOW_ITEM_TYPE_IPV6_EXT
1272 struct rte_flow_item_ipv6_frag_ext {
1273 struct rte_ipv6_fragment_ext hdr;
1277 * RTE_FLOW_ITEM_TYPE_ICMP6
1279 * Matches any ICMPv6 header.
1281 struct rte_flow_item_icmp6 {
1282 uint8_t type; /**< ICMPv6 type. */
1283 uint8_t code; /**< ICMPv6 code. */
1284 uint16_t checksum; /**< ICMPv6 checksum. */
1287 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6. */
1289 static const struct rte_flow_item_icmp6 rte_flow_item_icmp6_mask = {
1296 * RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS
1298 * Matches an ICMPv6 neighbor discovery solicitation.
1300 struct rte_flow_item_icmp6_nd_ns {
1301 uint8_t type; /**< ICMPv6 type, normally 135. */
1302 uint8_t code; /**< ICMPv6 code, normally 0. */
1303 rte_be16_t checksum; /**< ICMPv6 checksum. */
1304 rte_be32_t reserved; /**< Reserved, normally 0. */
1305 uint8_t target_addr[16]; /**< Target address. */
1308 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS. */
1311 struct rte_flow_item_icmp6_nd_ns rte_flow_item_icmp6_nd_ns_mask = {
1313 "\xff\xff\xff\xff\xff\xff\xff\xff"
1314 "\xff\xff\xff\xff\xff\xff\xff\xff",
1319 * RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA
1321 * Matches an ICMPv6 neighbor discovery advertisement.
1323 struct rte_flow_item_icmp6_nd_na {
1324 uint8_t type; /**< ICMPv6 type, normally 136. */
1325 uint8_t code; /**< ICMPv6 code, normally 0. */
1326 rte_be16_t checksum; /**< ICMPv6 checksum. */
1328 * Route flag (1b), solicited flag (1b), override flag (1b),
1331 rte_be32_t rso_reserved;
1332 uint8_t target_addr[16]; /**< Target address. */
1335 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA. */
1338 struct rte_flow_item_icmp6_nd_na rte_flow_item_icmp6_nd_na_mask = {
1340 "\xff\xff\xff\xff\xff\xff\xff\xff"
1341 "\xff\xff\xff\xff\xff\xff\xff\xff",
1346 * RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT
1348 * Matches the presence of any ICMPv6 neighbor discovery option.
1350 * Normally preceded by any of:
1352 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA
1353 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS
1354 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT
1356 struct rte_flow_item_icmp6_nd_opt {
1357 uint8_t type; /**< ND option type. */
1358 uint8_t length; /**< ND option length. */
1361 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT. */
1363 static const struct rte_flow_item_icmp6_nd_opt
1364 rte_flow_item_icmp6_nd_opt_mask = {
1370 * RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_SLA_ETH
1372 * Matches an ICMPv6 neighbor discovery source Ethernet link-layer address
1375 * Normally preceded by any of:
1377 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA
1378 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT
1380 struct rte_flow_item_icmp6_nd_opt_sla_eth {
1381 uint8_t type; /**< ND option type, normally 1. */
1382 uint8_t length; /**< ND option length, normally 1. */
1383 struct rte_ether_addr sla; /**< Source Ethernet LLA. */
1386 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_SLA_ETH. */
1388 static const struct rte_flow_item_icmp6_nd_opt_sla_eth
1389 rte_flow_item_icmp6_nd_opt_sla_eth_mask = {
1390 .sla.addr_bytes = "\xff\xff\xff\xff\xff\xff",
1395 * RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_TLA_ETH
1397 * Matches an ICMPv6 neighbor discovery target Ethernet link-layer address
1400 * Normally preceded by any of:
1402 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS
1403 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT
1405 struct rte_flow_item_icmp6_nd_opt_tla_eth {
1406 uint8_t type; /**< ND option type, normally 2. */
1407 uint8_t length; /**< ND option length, normally 1. */
1408 struct rte_ether_addr tla; /**< Target Ethernet LLA. */
1411 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_TLA_ETH. */
1413 static const struct rte_flow_item_icmp6_nd_opt_tla_eth
1414 rte_flow_item_icmp6_nd_opt_tla_eth_mask = {
1415 .tla.addr_bytes = "\xff\xff\xff\xff\xff\xff",
1420 * RTE_FLOW_ITEM_TYPE_META
1422 * Matches a specified metadata value. On egress, metadata can be set
1423 * either by mbuf dynamic metadata field with PKT_TX_DYNF_METADATA flag or
1424 * RTE_FLOW_ACTION_TYPE_SET_META. On ingress, RTE_FLOW_ACTION_TYPE_SET_META
1425 * sets metadata for a packet and the metadata will be reported via mbuf
1426 * metadata dynamic field with PKT_RX_DYNF_METADATA flag. The dynamic mbuf
1427 * field must be registered in advance by rte_flow_dynf_metadata_register().
1429 struct rte_flow_item_meta {
1433 /** Default mask for RTE_FLOW_ITEM_TYPE_META. */
1435 static const struct rte_flow_item_meta rte_flow_item_meta_mask = {
1441 * RTE_FLOW_ITEM_TYPE_GTP_PSC.
1443 * Matches a GTP PDU extension header with type 0x85.
1445 struct rte_flow_item_gtp_psc {
1446 uint8_t pdu_type; /**< PDU type. */
1447 uint8_t qfi; /**< PPP, RQI, QoS flow identifier. */
1450 /** Default mask for RTE_FLOW_ITEM_TYPE_GTP_PSC. */
1452 static const struct rte_flow_item_gtp_psc
1453 rte_flow_item_gtp_psc_mask = {
1459 * RTE_FLOW_ITEM_TYPE_PPPOE.
1461 * Matches a PPPoE header.
1463 struct rte_flow_item_pppoe {
1465 * Version (4b), type (4b).
1467 uint8_t version_type;
1468 uint8_t code; /**< Message type. */
1469 rte_be16_t session_id; /**< Session identifier. */
1470 rte_be16_t length; /**< Payload length. */
1474 * RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID.
1476 * Matches a PPPoE optional proto_id field.
1478 * It only applies to PPPoE session packets.
1480 * Normally preceded by any of:
1482 * - RTE_FLOW_ITEM_TYPE_PPPOE
1483 * - RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID
1485 struct rte_flow_item_pppoe_proto_id {
1486 rte_be16_t proto_id; /**< PPP protocol identifier. */
1489 /** Default mask for RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID. */
1491 static const struct rte_flow_item_pppoe_proto_id
1492 rte_flow_item_pppoe_proto_id_mask = {
1493 .proto_id = RTE_BE16(0xffff),
1499 * @b EXPERIMENTAL: this structure may change without prior notice
1501 * RTE_FLOW_ITEM_TYPE_TAG
1503 * Matches a specified tag value at the specified index.
1505 struct rte_flow_item_tag {
1510 /** Default mask for RTE_FLOW_ITEM_TYPE_TAG. */
1512 static const struct rte_flow_item_tag rte_flow_item_tag_mask = {
1519 * RTE_FLOW_ITEM_TYPE_L2TPV3OIP.
1521 * Matches a L2TPv3 over IP header.
1523 struct rte_flow_item_l2tpv3oip {
1524 rte_be32_t session_id; /**< Session ID. */
1527 /** Default mask for RTE_FLOW_ITEM_TYPE_L2TPV3OIP. */
1529 static const struct rte_flow_item_l2tpv3oip rte_flow_item_l2tpv3oip_mask = {
1530 .session_id = RTE_BE32(UINT32_MAX),
1537 * @b EXPERIMENTAL: this structure may change without prior notice
1539 * RTE_FLOW_ITEM_TYPE_MARK
1541 * Matches an arbitrary integer value which was set using the ``MARK`` action
1542 * in a previously matched rule.
1544 * This item can only be specified once as a match criteria as the ``MARK``
1545 * action can only be specified once in a flow action.
1547 * This value is arbitrary and application-defined. Maximum allowed value
1548 * depends on the underlying implementation.
1550 * Depending on the underlying implementation the MARK item may be supported on
1551 * the physical device, with virtual groups in the PMD or not at all.
1553 struct rte_flow_item_mark {
1554 uint32_t id; /**< Integer value to match against. */
1557 /** Default mask for RTE_FLOW_ITEM_TYPE_MARK. */
1559 static const struct rte_flow_item_mark rte_flow_item_mark_mask = {
1566 * @b EXPERIMENTAL: this structure may change without prior notice
1568 * RTE_FLOW_ITEM_TYPE_NSH
1570 * Match network service header (NSH), RFC 8300
1573 struct rte_flow_item_nsh {
1576 uint32_t reserved:1;
1579 uint32_t reserved1:4;
1581 uint32_t next_proto:8;
1586 /** Default mask for RTE_FLOW_ITEM_TYPE_NSH. */
1588 static const struct rte_flow_item_nsh rte_flow_item_nsh_mask = {
1598 * @b EXPERIMENTAL: this structure may change without prior notice
1600 * RTE_FLOW_ITEM_TYPE_IGMP
1602 * Match Internet Group Management Protocol (IGMP), RFC 2236
1605 struct rte_flow_item_igmp {
1607 uint32_t max_resp_time:8;
1608 uint32_t checksum:16;
1609 uint32_t group_addr;
1612 /** Default mask for RTE_FLOW_ITEM_TYPE_IGMP. */
1614 static const struct rte_flow_item_igmp rte_flow_item_igmp_mask = {
1615 .group_addr = 0xffffffff,
1621 * @b EXPERIMENTAL: this structure may change without prior notice
1623 * RTE_FLOW_ITEM_TYPE_AH
1625 * Match IP Authentication Header (AH), RFC 4302
1628 struct rte_flow_item_ah {
1629 uint32_t next_hdr:8;
1630 uint32_t payload_len:8;
1631 uint32_t reserved:16;
1636 /** Default mask for RTE_FLOW_ITEM_TYPE_AH. */
1638 static const struct rte_flow_item_ah rte_flow_item_ah_mask = {
1645 * @b EXPERIMENTAL: this structure may change without prior notice
1647 * RTE_FLOW_ITEM_TYPE_PFCP
1651 struct rte_flow_item_pfcp {
1658 /** Default mask for RTE_FLOW_ITEM_TYPE_PFCP. */
1660 static const struct rte_flow_item_pfcp rte_flow_item_pfcp_mask = {
1662 .seid = RTE_BE64(UINT64_C(0xffffffffffffffff)),
1668 * @b EXPERIMENTAL: this structure may change without prior notice
1670 * RTE_FLOW_ITEM_TYPE_ECPRI
1672 * Match eCPRI Header
1674 struct rte_flow_item_ecpri {
1675 struct rte_ecpri_combined_msg_hdr hdr;
1678 /** Default mask for RTE_FLOW_ITEM_TYPE_ECPRI. */
1680 static const struct rte_flow_item_ecpri rte_flow_item_ecpri_mask = {
1690 * RTE_FLOW_ITEM_TYPE_GENEVE_OPT
1692 * Matches a GENEVE Variable Length Option
1694 struct rte_flow_item_geneve_opt {
1695 rte_be16_t option_class;
1696 uint8_t option_type;
1701 /** Default mask for RTE_FLOW_ITEM_TYPE_GENEVE_OPT. */
1703 static const struct rte_flow_item_geneve_opt
1704 rte_flow_item_geneve_opt_mask = {
1705 .option_type = 0xff,
1709 struct rte_flow_item_integrity {
1710 /**< Tunnel encapsulation level the item should apply to.
1711 * @see rte_flow_action_rss
1718 /**< The packet is valid after passing all HW checks. */
1719 uint64_t packet_ok:1;
1720 /**< L2 layer is valid after passing all HW checks. */
1722 /**< L3 layer is valid after passing all HW checks. */
1724 /**< L4 layer is valid after passing all HW checks. */
1726 /**< L2 layer CRC is valid. */
1727 uint64_t l2_crc_ok:1;
1728 /**< IPv4 layer checksum is valid. */
1729 uint64_t ipv4_csum_ok:1;
1730 /**< L4 layer checksum is valid. */
1731 uint64_t l4_csum_ok:1;
1732 /**< The l3 length is smaller than the frame length. */
1733 uint64_t l3_len_ok:1;
1734 uint64_t reserved:56;
1741 static const struct rte_flow_item_integrity
1742 rte_flow_item_integrity_mask = {
1749 * The packet is valid after conntrack checking.
1751 #define RTE_FLOW_CONNTRACK_PKT_STATE_VALID RTE_BIT32(0)
1753 * The state of the connection is changed.
1755 #define RTE_FLOW_CONNTRACK_PKT_STATE_CHANGED RTE_BIT32(1)
1757 * Error is detected on this packet for this connection and
1758 * an invalid state is set.
1760 #define RTE_FLOW_CONNTRACK_PKT_STATE_INVALID RTE_BIT32(2)
1762 * The HW connection tracking module is disabled.
1763 * It can be due to application command or an invalid state.
1765 #define RTE_FLOW_CONNTRACK_PKT_STATE_DISABLED RTE_BIT32(3)
1767 * The packet contains some bad field(s) and cannot continue
1768 * with the conntrack module checking.
1770 #define RTE_FLOW_CONNTRACK_PKT_STATE_BAD RTE_BIT32(4)
1774 * @b EXPERIMENTAL: this structure may change without prior notice
1776 * RTE_FLOW_ITEM_TYPE_CONNTRACK
1778 * Matches the state of a packet after it passed the connection tracking
1779 * examination. The state is a bitmap of one RTE_FLOW_CONNTRACK_PKT_STATE*
1780 * or a reasonable combination of these bits.
1782 struct rte_flow_item_conntrack {
1786 /** Default mask for RTE_FLOW_ITEM_TYPE_CONNTRACK. */
1788 static const struct rte_flow_item_conntrack rte_flow_item_conntrack_mask = {
1789 .flags = 0xffffffff,
1794 * Matching pattern item definition.
1796 * A pattern is formed by stacking items starting from the lowest protocol
1797 * layer to match. This stacking restriction does not apply to meta items
1798 * which can be placed anywhere in the stack without affecting the meaning
1799 * of the resulting pattern.
1801 * Patterns are terminated by END items.
1803 * The spec field should be a valid pointer to a structure of the related
1804 * item type. It may remain unspecified (NULL) in many cases to request
1805 * broad (nonspecific) matching. In such cases, last and mask must also be
1808 * Optionally, last can point to a structure of the same type to define an
1809 * inclusive range. This is mostly supported by integer and address fields,
1810 * may cause errors otherwise. Fields that do not support ranges must be set
1811 * to 0 or to the same value as the corresponding fields in spec.
1813 * Only the fields defined to nonzero values in the default masks (see
1814 * rte_flow_item_{name}_mask constants) are considered relevant by
1815 * default. This can be overridden by providing a mask structure of the
1816 * same type with applicable bits set to one. It can also be used to
1817 * partially filter out specific fields (e.g. as an alternate mean to match
1818 * ranges of IP addresses).
1820 * Mask is a simple bit-mask applied before interpreting the contents of
1821 * spec and last, which may yield unexpected results if not used
1822 * carefully. For example, if for an IPv4 address field, spec provides
1823 * 10.1.2.3, last provides 10.3.4.5 and mask provides 255.255.0.0, the
1824 * effective range becomes 10.1.0.0 to 10.3.255.255.
1826 struct rte_flow_item {
1827 enum rte_flow_item_type type; /**< Item type. */
1828 const void *spec; /**< Pointer to item specification structure. */
1829 const void *last; /**< Defines an inclusive range (spec to last). */
1830 const void *mask; /**< Bit-mask applied to spec and last. */
1836 * Each possible action is represented by a type.
1837 * An action can have an associated configuration object.
1838 * Several actions combined in a list can be assigned
1839 * to a flow rule and are performed in order.
1841 * They fall in three categories:
1843 * - Actions that modify the fate of matching traffic, for instance by
1844 * dropping or assigning it a specific destination.
1846 * - Actions that modify matching traffic contents or its properties. This
1847 * includes adding/removing encapsulation, encryption, compression and
1850 * - Actions related to the flow rule itself, such as updating counters or
1851 * making it non-terminating.
1853 * Flow rules being terminating by default, not specifying any action of the
1854 * fate kind results in undefined behavior. This applies to both ingress and
1857 * PASSTHRU, when supported, makes a flow rule non-terminating.
1859 enum rte_flow_action_type {
1861 * End marker for action lists. Prevents further processing of
1862 * actions, thereby ending the list.
1864 * No associated configuration structure.
1866 RTE_FLOW_ACTION_TYPE_END,
1869 * Used as a placeholder for convenience. It is ignored and simply
1870 * discarded by PMDs.
1872 * No associated configuration structure.
1874 RTE_FLOW_ACTION_TYPE_VOID,
1877 * Leaves traffic up for additional processing by subsequent flow
1878 * rules; makes a flow rule non-terminating.
1880 * No associated configuration structure.
1882 RTE_FLOW_ACTION_TYPE_PASSTHRU,
1885 * RTE_FLOW_ACTION_TYPE_JUMP
1887 * Redirects packets to a group on the current device.
1889 * See struct rte_flow_action_jump.
1891 RTE_FLOW_ACTION_TYPE_JUMP,
1894 * Attaches an integer value to packets and sets PKT_RX_FDIR and
1895 * PKT_RX_FDIR_ID mbuf flags.
1897 * See struct rte_flow_action_mark.
1899 RTE_FLOW_ACTION_TYPE_MARK,
1902 * Flags packets. Similar to MARK without a specific value; only
1903 * sets the PKT_RX_FDIR mbuf flag.
1905 * No associated configuration structure.
1907 RTE_FLOW_ACTION_TYPE_FLAG,
1910 * Assigns packets to a given queue index.
1912 * See struct rte_flow_action_queue.
1914 RTE_FLOW_ACTION_TYPE_QUEUE,
1919 * PASSTHRU overrides this action if both are specified.
1921 * No associated configuration structure.
1923 RTE_FLOW_ACTION_TYPE_DROP,
1926 * Enables counters for this flow rule.
1928 * These counters can be retrieved and reset through rte_flow_query() or
1929 * rte_flow_action_handle_query() if the action provided via handle,
1930 * see struct rte_flow_query_count.
1932 * See struct rte_flow_action_count.
1934 RTE_FLOW_ACTION_TYPE_COUNT,
1937 * Similar to QUEUE, except RSS is additionally performed on packets
1938 * to spread them among several queues according to the provided
1941 * See struct rte_flow_action_rss.
1943 RTE_FLOW_ACTION_TYPE_RSS,
1946 * Directs matching traffic to the physical function (PF) of the
1949 * No associated configuration structure.
1951 RTE_FLOW_ACTION_TYPE_PF,
1954 * Directs matching traffic to a given virtual function of the
1957 * See struct rte_flow_action_vf.
1959 RTE_FLOW_ACTION_TYPE_VF,
1962 * Directs packets to a given physical port index of the underlying
1965 * See struct rte_flow_action_phy_port.
1967 RTE_FLOW_ACTION_TYPE_PHY_PORT,
1970 * Directs matching traffic to a given DPDK port ID.
1972 * See struct rte_flow_action_port_id.
1974 RTE_FLOW_ACTION_TYPE_PORT_ID,
1977 * Traffic metering and policing (MTR).
1979 * See struct rte_flow_action_meter.
1980 * See file rte_mtr.h for MTR object configuration.
1982 RTE_FLOW_ACTION_TYPE_METER,
1985 * Redirects packets to security engine of current device for security
1986 * processing as specified by security session.
1988 * See struct rte_flow_action_security.
1990 RTE_FLOW_ACTION_TYPE_SECURITY,
1993 * Implements OFPAT_SET_MPLS_TTL ("MPLS TTL") as defined by the
1994 * OpenFlow Switch Specification.
1996 * See struct rte_flow_action_of_set_mpls_ttl.
1998 RTE_FLOW_ACTION_TYPE_OF_SET_MPLS_TTL,
2001 * Implements OFPAT_DEC_MPLS_TTL ("decrement MPLS TTL") as defined
2002 * by the OpenFlow Switch Specification.
2004 * No associated configuration structure.
2006 RTE_FLOW_ACTION_TYPE_OF_DEC_MPLS_TTL,
2009 * Implements OFPAT_SET_NW_TTL ("IP TTL") as defined by the OpenFlow
2010 * Switch Specification.
2012 * See struct rte_flow_action_of_set_nw_ttl.
2014 RTE_FLOW_ACTION_TYPE_OF_SET_NW_TTL,
2017 * Implements OFPAT_DEC_NW_TTL ("decrement IP TTL") as defined by
2018 * the OpenFlow Switch Specification.
2020 * No associated configuration structure.
2022 RTE_FLOW_ACTION_TYPE_OF_DEC_NW_TTL,
2025 * Implements OFPAT_COPY_TTL_OUT ("copy TTL "outwards" -- from
2026 * next-to-outermost to outermost") as defined by the OpenFlow
2027 * Switch Specification.
2029 * No associated configuration structure.
2031 RTE_FLOW_ACTION_TYPE_OF_COPY_TTL_OUT,
2034 * Implements OFPAT_COPY_TTL_IN ("copy TTL "inwards" -- from
2035 * outermost to next-to-outermost") as defined by the OpenFlow
2036 * Switch Specification.
2038 * No associated configuration structure.
2040 RTE_FLOW_ACTION_TYPE_OF_COPY_TTL_IN,
2043 * Implements OFPAT_POP_VLAN ("pop the outer VLAN tag") as defined
2044 * by the OpenFlow Switch Specification.
2046 * No associated configuration structure.
2048 RTE_FLOW_ACTION_TYPE_OF_POP_VLAN,
2051 * Implements OFPAT_PUSH_VLAN ("push a new VLAN tag") as defined by
2052 * the OpenFlow Switch Specification.
2054 * See struct rte_flow_action_of_push_vlan.
2056 RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN,
2059 * Implements OFPAT_SET_VLAN_VID ("set the 802.1q VLAN id") as
2060 * defined by the OpenFlow Switch Specification.
2062 * See struct rte_flow_action_of_set_vlan_vid.
2064 RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID,
2067 * Implements OFPAT_SET_LAN_PCP ("set the 802.1q priority") as
2068 * defined by the OpenFlow Switch Specification.
2070 * See struct rte_flow_action_of_set_vlan_pcp.
2072 RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP,
2075 * Implements OFPAT_POP_MPLS ("pop the outer MPLS tag") as defined
2076 * by the OpenFlow Switch Specification.
2078 * See struct rte_flow_action_of_pop_mpls.
2080 RTE_FLOW_ACTION_TYPE_OF_POP_MPLS,
2083 * Implements OFPAT_PUSH_MPLS ("push a new MPLS tag") as defined by
2084 * the OpenFlow Switch Specification.
2086 * See struct rte_flow_action_of_push_mpls.
2088 RTE_FLOW_ACTION_TYPE_OF_PUSH_MPLS,
2091 * Encapsulate flow in VXLAN tunnel as defined in
2092 * rte_flow_action_vxlan_encap action structure.
2094 * See struct rte_flow_action_vxlan_encap.
2096 RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP,
2099 * Decapsulate outer most VXLAN tunnel from matched flow.
2101 * If flow pattern does not define a valid VXLAN tunnel (as specified by
2102 * RFC7348) then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION
2105 RTE_FLOW_ACTION_TYPE_VXLAN_DECAP,
2108 * Encapsulate flow in NVGRE tunnel defined in the
2109 * rte_flow_action_nvgre_encap action structure.
2111 * See struct rte_flow_action_nvgre_encap.
2113 RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP,
2116 * Decapsulate outer most NVGRE tunnel from matched flow.
2118 * If flow pattern does not define a valid NVGRE tunnel (as specified by
2119 * RFC7637) then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION
2122 RTE_FLOW_ACTION_TYPE_NVGRE_DECAP,
2125 * Add outer header whose template is provided in its data buffer
2127 * See struct rte_flow_action_raw_encap.
2129 RTE_FLOW_ACTION_TYPE_RAW_ENCAP,
2132 * Remove outer header whose template is provided in its data buffer.
2134 * See struct rte_flow_action_raw_decap
2136 RTE_FLOW_ACTION_TYPE_RAW_DECAP,
2139 * Modify IPv4 source address in the outermost IPv4 header.
2141 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV4,
2142 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2144 * See struct rte_flow_action_set_ipv4.
2146 RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC,
2149 * Modify IPv4 destination address in the outermost IPv4 header.
2151 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV4,
2152 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2154 * See struct rte_flow_action_set_ipv4.
2156 RTE_FLOW_ACTION_TYPE_SET_IPV4_DST,
2159 * Modify IPv6 source address in the outermost IPv6 header.
2161 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV6,
2162 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2164 * See struct rte_flow_action_set_ipv6.
2166 RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC,
2169 * Modify IPv6 destination address in the outermost IPv6 header.
2171 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV6,
2172 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2174 * See struct rte_flow_action_set_ipv6.
2176 RTE_FLOW_ACTION_TYPE_SET_IPV6_DST,
2179 * Modify source port number in the outermost TCP/UDP header.
2181 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_TCP
2182 * or RTE_FLOW_ITEM_TYPE_UDP, then the PMD should return a
2183 * RTE_FLOW_ERROR_TYPE_ACTION error.
2185 * See struct rte_flow_action_set_tp.
2187 RTE_FLOW_ACTION_TYPE_SET_TP_SRC,
2190 * Modify destination port number in the outermost TCP/UDP header.
2192 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_TCP
2193 * or RTE_FLOW_ITEM_TYPE_UDP, then the PMD should return a
2194 * RTE_FLOW_ERROR_TYPE_ACTION error.
2196 * See struct rte_flow_action_set_tp.
2198 RTE_FLOW_ACTION_TYPE_SET_TP_DST,
2201 * Swap the source and destination MAC addresses in the outermost
2204 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_ETH,
2205 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2207 * No associated configuration structure.
2209 RTE_FLOW_ACTION_TYPE_MAC_SWAP,
2212 * Decrease TTL value directly
2214 * No associated configuration structure.
2216 RTE_FLOW_ACTION_TYPE_DEC_TTL,
2221 * See struct rte_flow_action_set_ttl
2223 RTE_FLOW_ACTION_TYPE_SET_TTL,
2226 * Set source MAC address from matched flow.
2228 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_ETH,
2229 * the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2231 * See struct rte_flow_action_set_mac.
2233 RTE_FLOW_ACTION_TYPE_SET_MAC_SRC,
2236 * Set destination MAC address from matched flow.
2238 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_ETH,
2239 * the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2241 * See struct rte_flow_action_set_mac.
2243 RTE_FLOW_ACTION_TYPE_SET_MAC_DST,
2246 * Increase sequence number in the outermost TCP header.
2248 * Action configuration specifies the value to increase
2249 * TCP sequence number as a big-endian 32 bit integer.
2252 * @code rte_be32_t * @endcode
2254 * Using this action on non-matching traffic will result in
2255 * undefined behavior.
2257 RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ,
2260 * Decrease sequence number in the outermost TCP header.
2262 * Action configuration specifies the value to decrease
2263 * TCP sequence number as a big-endian 32 bit integer.
2266 * @code rte_be32_t * @endcode
2268 * Using this action on non-matching traffic will result in
2269 * undefined behavior.
2271 RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ,
2274 * Increase acknowledgment number in the outermost TCP header.
2276 * Action configuration specifies the value to increase
2277 * TCP acknowledgment number as a big-endian 32 bit integer.
2280 * @code rte_be32_t * @endcode
2282 * Using this action on non-matching traffic will result in
2283 * undefined behavior.
2285 RTE_FLOW_ACTION_TYPE_INC_TCP_ACK,
2288 * Decrease acknowledgment number in the outermost TCP header.
2290 * Action configuration specifies the value to decrease
2291 * TCP acknowledgment number as a big-endian 32 bit integer.
2294 * @code rte_be32_t * @endcode
2296 * Using this action on non-matching traffic will result in
2297 * undefined behavior.
2299 RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK,
2304 * Tag is for internal flow usage only and
2305 * is not delivered to the application.
2307 * See struct rte_flow_action_set_tag.
2309 RTE_FLOW_ACTION_TYPE_SET_TAG,
2312 * Set metadata on ingress or egress path.
2314 * See struct rte_flow_action_set_meta.
2316 RTE_FLOW_ACTION_TYPE_SET_META,
2319 * Modify IPv4 DSCP in the outermost IP header.
2321 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV4,
2322 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2324 * See struct rte_flow_action_set_dscp.
2326 RTE_FLOW_ACTION_TYPE_SET_IPV4_DSCP,
2329 * Modify IPv6 DSCP in the outermost IP header.
2331 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV6,
2332 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2334 * See struct rte_flow_action_set_dscp.
2336 RTE_FLOW_ACTION_TYPE_SET_IPV6_DSCP,
2339 * Report as aged flow if timeout passed without any matching on the
2342 * See struct rte_flow_action_age.
2343 * See function rte_flow_get_aged_flows
2344 * see enum RTE_ETH_EVENT_FLOW_AGED
2345 * See struct rte_flow_query_age
2347 RTE_FLOW_ACTION_TYPE_AGE,
2350 * The matching packets will be duplicated with specified ratio and
2351 * applied with own set of actions with a fate action.
2353 * See struct rte_flow_action_sample.
2355 RTE_FLOW_ACTION_TYPE_SAMPLE,
2359 * @see RTE_FLOW_ACTION_TYPE_INDIRECT
2361 * Describe action shared across multiple flow rules.
2363 * Allow multiple rules reference the same action by handle (see
2364 * struct rte_flow_shared_action).
2366 RTE_FLOW_ACTION_TYPE_SHARED,
2369 * Modify a packet header field, tag, mark or metadata.
2371 * Allow the modification of an arbitrary header field via
2372 * set, add and sub operations or copying its content into
2373 * tag, meta or mark for future processing.
2375 * See struct rte_flow_action_modify_field.
2377 RTE_FLOW_ACTION_TYPE_MODIFY_FIELD,
2380 * An action handle is referenced in a rule through an indirect action.
2382 * The same action handle may be used in multiple rules for the same
2383 * or different ethdev ports.
2385 RTE_FLOW_ACTION_TYPE_INDIRECT,
2390 * Enable tracking a TCP connection state.
2392 * @see struct rte_flow_action_conntrack.
2394 RTE_FLOW_ACTION_TYPE_CONNTRACK,
2398 * RTE_FLOW_ACTION_TYPE_MARK
2400 * Attaches an integer value to packets and sets PKT_RX_FDIR and
2401 * PKT_RX_FDIR_ID mbuf flags.
2403 * This value is arbitrary and application-defined. Maximum allowed value
2404 * depends on the underlying implementation. It is returned in the
2405 * hash.fdir.hi mbuf field.
2407 struct rte_flow_action_mark {
2408 uint32_t id; /**< Integer value to return with packets. */
2413 * @b EXPERIMENTAL: this structure may change without prior notice
2415 * RTE_FLOW_ACTION_TYPE_JUMP
2417 * Redirects packets to a group on the current device.
2419 * In a hierarchy of groups, which can be used to represent physical or logical
2420 * flow tables on the device, this action allows the action to be a redirect to
2421 * a group on that device.
2423 struct rte_flow_action_jump {
2428 * RTE_FLOW_ACTION_TYPE_QUEUE
2430 * Assign packets to a given queue index.
2432 struct rte_flow_action_queue {
2433 uint16_t index; /**< Queue index to use. */
2438 * @b EXPERIMENTAL: this structure may change without prior notice
2440 * RTE_FLOW_ACTION_TYPE_AGE
2442 * Report flow as aged-out if timeout passed without any matching
2443 * on the flow. RTE_ETH_EVENT_FLOW_AGED event is triggered when a
2444 * port detects new aged-out flows.
2446 * The flow context and the flow handle will be reported by the
2447 * rte_flow_get_aged_flows API.
2449 struct rte_flow_action_age {
2450 uint32_t timeout:24; /**< Time in seconds. */
2451 uint32_t reserved:8; /**< Reserved, must be zero. */
2453 /**< The user flow context, NULL means the rte_flow pointer. */
2457 * RTE_FLOW_ACTION_TYPE_AGE (query)
2459 * Query structure to retrieve the aging status information of a
2460 * shared AGE action, or a flow rule using the AGE action.
2462 struct rte_flow_query_age {
2463 uint32_t reserved:6; /**< Reserved, must be zero. */
2464 uint32_t aged:1; /**< 1 if aging timeout expired, 0 otherwise. */
2465 uint32_t sec_since_last_hit_valid:1;
2466 /**< sec_since_last_hit value is valid. */
2467 uint32_t sec_since_last_hit:24; /**< Seconds since last traffic hit. */
2472 * @b EXPERIMENTAL: this structure may change without prior notice
2474 * RTE_FLOW_ACTION_TYPE_COUNT
2476 * Adds a counter action to a matched flow.
2478 * If more than one count action is specified in a single flow rule, then each
2479 * action must specify a unique id.
2481 * Counters can be retrieved and reset through ``rte_flow_query()``, see
2482 * ``struct rte_flow_query_count``.
2484 * @deprecated Shared attribute is deprecated, use generic
2485 * RTE_FLOW_ACTION_TYPE_INDIRECT action.
2487 * The shared flag indicates whether the counter is unique to the flow rule the
2488 * action is specified with, or whether it is a shared counter.
2490 * For a count action with the shared flag set, then then a global device
2491 * namespace is assumed for the counter id, so that any matched flow rules using
2492 * a count action with the same counter id on the same port will contribute to
2495 * For ports within the same switch domain then the counter id namespace extends
2496 * to all ports within that switch domain.
2498 struct rte_flow_action_count {
2499 /** @deprecated Share counter ID with other flow rules. */
2501 uint32_t reserved:31; /**< Reserved, must be zero. */
2502 uint32_t id; /**< Counter ID. */
2506 * RTE_FLOW_ACTION_TYPE_COUNT (query)
2508 * Query structure to retrieve and reset flow rule counters.
2510 struct rte_flow_query_count {
2511 uint32_t reset:1; /**< Reset counters after query [in]. */
2512 uint32_t hits_set:1; /**< hits field is set [out]. */
2513 uint32_t bytes_set:1; /**< bytes field is set [out]. */
2514 uint32_t reserved:29; /**< Reserved, must be zero [in, out]. */
2515 uint64_t hits; /**< Number of hits for this rule [out]. */
2516 uint64_t bytes; /**< Number of bytes through this rule [out]. */
2520 * Hash function types.
2522 enum rte_eth_hash_function {
2523 RTE_ETH_HASH_FUNCTION_DEFAULT = 0,
2524 RTE_ETH_HASH_FUNCTION_TOEPLITZ, /**< Toeplitz */
2525 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR, /**< Simple XOR */
2527 * Symmetric Toeplitz: src, dst will be replaced by
2528 * xor(src, dst). For the case with src/dst only,
2529 * src or dst address will xor with zero pair.
2531 RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ,
2532 RTE_ETH_HASH_FUNCTION_MAX,
2536 * RTE_FLOW_ACTION_TYPE_RSS
2538 * Similar to QUEUE, except RSS is additionally performed on packets to
2539 * spread them among several queues according to the provided parameters.
2541 * Unlike global RSS settings used by other DPDK APIs, unsetting the
2542 * @p types field does not disable RSS in a flow rule. Doing so instead
2543 * requests safe unspecified "best-effort" settings from the underlying PMD,
2544 * which depending on the flow rule, may result in anything ranging from
2545 * empty (single queue) to all-inclusive RSS.
2547 * Note: RSS hash result is stored in the hash.rss mbuf field which overlaps
2548 * hash.fdir.lo. Since the MARK action sets the hash.fdir.hi field only,
2549 * both can be requested simultaneously.
2551 struct rte_flow_action_rss {
2552 enum rte_eth_hash_function func; /**< RSS hash function to apply. */
2554 * Packet encapsulation level RSS hash @p types apply to.
2556 * - @p 0 requests the default behavior. Depending on the packet
2557 * type, it can mean outermost, innermost, anything in between or
2560 * It basically stands for the innermost encapsulation level RSS
2561 * can be performed on according to PMD and device capabilities.
2563 * - @p 1 requests RSS to be performed on the outermost packet
2564 * encapsulation level.
2566 * - @p 2 and subsequent values request RSS to be performed on the
2567 * specified inner packet encapsulation level, from outermost to
2568 * innermost (lower to higher values).
2570 * Values other than @p 0 are not necessarily supported.
2572 * Requesting a specific RSS level on unrecognized traffic results
2573 * in undefined behavior. For predictable results, it is recommended
2574 * to make the flow rule pattern match packet headers up to the
2575 * requested encapsulation level so that only matching traffic goes
2579 uint64_t types; /**< Specific RSS hash types (see ETH_RSS_*). */
2580 uint32_t key_len; /**< Hash key length in bytes. */
2581 uint32_t queue_num; /**< Number of entries in @p queue. */
2582 const uint8_t *key; /**< Hash key. */
2583 const uint16_t *queue; /**< Queue indices to use. */
2587 * RTE_FLOW_ACTION_TYPE_VF
2589 * Directs matching traffic to a given virtual function of the current
2592 * Packets matched by a VF pattern item can be redirected to their original
2593 * VF ID instead of the specified one. This parameter may not be available
2594 * and is not guaranteed to work properly if the VF part is matched by a
2595 * prior flow rule or if packets are not addressed to a VF in the first
2598 struct rte_flow_action_vf {
2599 uint32_t original:1; /**< Use original VF ID if possible. */
2600 uint32_t reserved:31; /**< Reserved, must be zero. */
2601 uint32_t id; /**< VF ID. */
2605 * RTE_FLOW_ACTION_TYPE_PHY_PORT
2607 * Directs packets to a given physical port index of the underlying
2610 * @see RTE_FLOW_ITEM_TYPE_PHY_PORT
2612 struct rte_flow_action_phy_port {
2613 uint32_t original:1; /**< Use original port index if possible. */
2614 uint32_t reserved:31; /**< Reserved, must be zero. */
2615 uint32_t index; /**< Physical port index. */
2619 * RTE_FLOW_ACTION_TYPE_PORT_ID
2621 * Directs matching traffic to a given DPDK port ID.
2623 * @see RTE_FLOW_ITEM_TYPE_PORT_ID
2625 struct rte_flow_action_port_id {
2626 uint32_t original:1; /**< Use original DPDK port ID if possible. */
2627 uint32_t reserved:31; /**< Reserved, must be zero. */
2628 uint32_t id; /**< DPDK port ID. */
2632 * RTE_FLOW_ACTION_TYPE_METER
2634 * Traffic metering and policing (MTR).
2636 * Packets matched by items of this type can be either dropped or passed to the
2637 * next item with their color set by the MTR object.
2639 struct rte_flow_action_meter {
2640 uint32_t mtr_id; /**< MTR object ID created with rte_mtr_create(). */
2644 * RTE_FLOW_ACTION_TYPE_SECURITY
2646 * Perform the security action on flows matched by the pattern items
2647 * according to the configuration of the security session.
2649 * This action modifies the payload of matched flows. For INLINE_CRYPTO, the
2650 * security protocol headers and IV are fully provided by the application as
2651 * specified in the flow pattern. The payload of matching packets is
2652 * encrypted on egress, and decrypted and authenticated on ingress.
2653 * For INLINE_PROTOCOL, the security protocol is fully offloaded to HW,
2654 * providing full encapsulation and decapsulation of packets in security
2655 * protocols. The flow pattern specifies both the outer security header fields
2656 * and the inner packet fields. The security session specified in the action
2657 * must match the pattern parameters.
2659 * The security session specified in the action must be created on the same
2660 * port as the flow action that is being specified.
2662 * The ingress/egress flow attribute should match that specified in the
2663 * security session if the security session supports the definition of the
2666 * Multiple flows can be configured to use the same security session.
2668 * The NULL value is allowed for security session. If security session is NULL,
2669 * then SPI field in ESP flow item and IP addresses in flow items 'IPv4' and
2670 * 'IPv6' will be allowed to be a range. The rule thus created can enable
2671 * security processing on multiple flows.
2673 struct rte_flow_action_security {
2674 void *security_session; /**< Pointer to security session structure. */
2678 * RTE_FLOW_ACTION_TYPE_OF_SET_MPLS_TTL
2680 * Implements OFPAT_SET_MPLS_TTL ("MPLS TTL") as defined by the OpenFlow
2681 * Switch Specification.
2683 struct rte_flow_action_of_set_mpls_ttl {
2684 uint8_t mpls_ttl; /**< MPLS TTL. */
2688 * RTE_FLOW_ACTION_TYPE_OF_SET_NW_TTL
2690 * Implements OFPAT_SET_NW_TTL ("IP TTL") as defined by the OpenFlow Switch
2693 struct rte_flow_action_of_set_nw_ttl {
2694 uint8_t nw_ttl; /**< IP TTL. */
2698 * RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN
2700 * Implements OFPAT_PUSH_VLAN ("push a new VLAN tag") as defined by the
2701 * OpenFlow Switch Specification.
2703 struct rte_flow_action_of_push_vlan {
2704 rte_be16_t ethertype; /**< EtherType. */
2708 * RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID
2710 * Implements OFPAT_SET_VLAN_VID ("set the 802.1q VLAN id") as defined by
2711 * the OpenFlow Switch Specification.
2713 struct rte_flow_action_of_set_vlan_vid {
2714 rte_be16_t vlan_vid; /**< VLAN id. */
2718 * RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP
2720 * Implements OFPAT_SET_LAN_PCP ("set the 802.1q priority") as defined by
2721 * the OpenFlow Switch Specification.
2723 struct rte_flow_action_of_set_vlan_pcp {
2724 uint8_t vlan_pcp; /**< VLAN priority. */
2728 * RTE_FLOW_ACTION_TYPE_OF_POP_MPLS
2730 * Implements OFPAT_POP_MPLS ("pop the outer MPLS tag") as defined by the
2731 * OpenFlow Switch Specification.
2733 struct rte_flow_action_of_pop_mpls {
2734 rte_be16_t ethertype; /**< EtherType. */
2738 * RTE_FLOW_ACTION_TYPE_OF_PUSH_MPLS
2740 * Implements OFPAT_PUSH_MPLS ("push a new MPLS tag") as defined by the
2741 * OpenFlow Switch Specification.
2743 struct rte_flow_action_of_push_mpls {
2744 rte_be16_t ethertype; /**< EtherType. */
2749 * @b EXPERIMENTAL: this structure may change without prior notice
2751 * RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP
2753 * VXLAN tunnel end-point encapsulation data definition
2755 * The tunnel definition is provided through the flow item pattern, the
2756 * provided pattern must conform to RFC7348 for the tunnel specified. The flow
2757 * definition must be provided in order from the RTE_FLOW_ITEM_TYPE_ETH
2758 * definition up the end item which is specified by RTE_FLOW_ITEM_TYPE_END.
2760 * The mask field allows user to specify which fields in the flow item
2761 * definitions can be ignored and which have valid data and can be used
2764 * Note: the last field is not used in the definition of a tunnel and can be
2767 * Valid flow definition for RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP include:
2769 * - ETH / IPV4 / UDP / VXLAN / END
2770 * - ETH / IPV6 / UDP / VXLAN / END
2771 * - ETH / VLAN / IPV4 / UDP / VXLAN / END
2774 struct rte_flow_action_vxlan_encap {
2776 * Encapsulating vxlan tunnel definition
2777 * (terminated by the END pattern item).
2779 struct rte_flow_item *definition;
2784 * @b EXPERIMENTAL: this structure may change without prior notice
2786 * RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP
2788 * NVGRE tunnel end-point encapsulation data definition
2790 * The tunnel definition is provided through the flow item pattern the
2791 * provided pattern must conform with RFC7637. The flow definition must be
2792 * provided in order from the RTE_FLOW_ITEM_TYPE_ETH definition up the end item
2793 * which is specified by RTE_FLOW_ITEM_TYPE_END.
2795 * The mask field allows user to specify which fields in the flow item
2796 * definitions can be ignored and which have valid data and can be used
2799 * Note: the last field is not used in the definition of a tunnel and can be
2802 * Valid flow definition for RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP include:
2804 * - ETH / IPV4 / NVGRE / END
2805 * - ETH / VLAN / IPV6 / NVGRE / END
2808 struct rte_flow_action_nvgre_encap {
2810 * Encapsulating vxlan tunnel definition
2811 * (terminated by the END pattern item).
2813 struct rte_flow_item *definition;
2818 * @b EXPERIMENTAL: this structure may change without prior notice
2820 * RTE_FLOW_ACTION_TYPE_RAW_ENCAP
2822 * Raw tunnel end-point encapsulation data definition.
2824 * The data holds the headers definitions to be applied on the packet.
2825 * The data must start with ETH header up to the tunnel item header itself.
2826 * When used right after RAW_DECAP (for decapsulating L3 tunnel type for
2827 * example MPLSoGRE) the data will just hold layer 2 header.
2829 * The preserve parameter holds which bits in the packet the PMD is not allowed
2830 * to change, this parameter can also be NULL and then the PMD is allowed
2831 * to update any field.
2833 * size holds the number of bytes in @p data and @p preserve.
2835 struct rte_flow_action_raw_encap {
2836 uint8_t *data; /**< Encapsulation data. */
2837 uint8_t *preserve; /**< Bit-mask of @p data to preserve on output. */
2838 size_t size; /**< Size of @p data and @p preserve. */
2843 * @b EXPERIMENTAL: this structure may change without prior notice
2845 * RTE_FLOW_ACTION_TYPE_RAW_DECAP
2847 * Raw tunnel end-point decapsulation data definition.
2849 * The data holds the headers definitions to be removed from the packet.
2850 * The data must start with ETH header up to the tunnel item header itself.
2851 * When used right before RAW_DECAP (for encapsulating L3 tunnel type for
2852 * example MPLSoGRE) the data will just hold layer 2 header.
2854 * size holds the number of bytes in @p data.
2856 struct rte_flow_action_raw_decap {
2857 uint8_t *data; /**< Encapsulation data. */
2858 size_t size; /**< Size of @p data and @p preserve. */
2863 * @b EXPERIMENTAL: this structure may change without prior notice
2865 * RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC
2866 * RTE_FLOW_ACTION_TYPE_SET_IPV4_DST
2868 * Allows modification of IPv4 source (RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC)
2869 * and destination address (RTE_FLOW_ACTION_TYPE_SET_IPV4_DST) in the
2870 * specified outermost IPv4 header.
2872 struct rte_flow_action_set_ipv4 {
2873 rte_be32_t ipv4_addr;
2878 * @b EXPERIMENTAL: this structure may change without prior notice
2880 * RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC
2881 * RTE_FLOW_ACTION_TYPE_SET_IPV6_DST
2883 * Allows modification of IPv6 source (RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC)
2884 * and destination address (RTE_FLOW_ACTION_TYPE_SET_IPV6_DST) in the
2885 * specified outermost IPv6 header.
2887 struct rte_flow_action_set_ipv6 {
2888 uint8_t ipv6_addr[16];
2893 * @b EXPERIMENTAL: this structure may change without prior notice
2895 * RTE_FLOW_ACTION_TYPE_SET_TP_SRC
2896 * RTE_FLOW_ACTION_TYPE_SET_TP_DST
2898 * Allows modification of source (RTE_FLOW_ACTION_TYPE_SET_TP_SRC)
2899 * and destination (RTE_FLOW_ACTION_TYPE_SET_TP_DST) port numbers
2900 * in the specified outermost TCP/UDP header.
2902 struct rte_flow_action_set_tp {
2907 * RTE_FLOW_ACTION_TYPE_SET_TTL
2909 * Set the TTL value directly for IPv4 or IPv6
2911 struct rte_flow_action_set_ttl {
2916 * RTE_FLOW_ACTION_TYPE_SET_MAC
2918 * Set MAC address from the matched flow
2920 struct rte_flow_action_set_mac {
2921 uint8_t mac_addr[RTE_ETHER_ADDR_LEN];
2926 * @b EXPERIMENTAL: this structure may change without prior notice
2928 * RTE_FLOW_ACTION_TYPE_SET_TAG
2930 * Set a tag which is a transient data used during flow matching. This is not
2931 * delivered to application. Multiple tags are supported by specifying index.
2933 struct rte_flow_action_set_tag {
2941 * @b EXPERIMENTAL: this structure may change without prior notice
2943 * RTE_FLOW_ACTION_TYPE_SET_META
2945 * Set metadata. Metadata set by mbuf metadata dynamic field with
2946 * PKT_TX_DYNF_DATA flag on egress will be overridden by this action. On
2947 * ingress, the metadata will be carried by mbuf metadata dynamic field
2948 * with PKT_RX_DYNF_METADATA flag if set. The dynamic mbuf field must be
2949 * registered in advance by rte_flow_dynf_metadata_register().
2951 * Altering partial bits is supported with mask. For bits which have never
2952 * been set, unpredictable value will be seen depending on driver
2953 * implementation. For loopback/hairpin packet, metadata set on Rx/Tx may
2954 * or may not be propagated to the other path depending on HW capability.
2956 * RTE_FLOW_ITEM_TYPE_META matches metadata.
2958 struct rte_flow_action_set_meta {
2964 * RTE_FLOW_ACTION_TYPE_SET_IPV4_DSCP
2965 * RTE_FLOW_ACTION_TYPE_SET_IPV6_DSCP
2967 * Set the DSCP value for IPv4/IPv6 header.
2968 * DSCP in low 6 bits, rest ignored.
2970 struct rte_flow_action_set_dscp {
2976 * @b EXPERIMENTAL: this structure may change without prior notice
2978 * RTE_FLOW_ACTION_TYPE_INDIRECT
2980 * Opaque type returned after successfully creating an indirect action object.
2981 * The definition of the object handle is different per driver or
2982 * per direct action type.
2984 * This handle can be used to manage and query the related direct action:
2985 * - referenced in single flow rule or across multiple flow rules
2986 * over multiple ports
2987 * - update action object configuration
2988 * - query action object data
2989 * - destroy action object
2991 struct rte_flow_action_handle;
2994 * The state of a TCP connection.
2996 enum rte_flow_conntrack_state {
2997 /** SYN-ACK packet was seen. */
2998 RTE_FLOW_CONNTRACK_STATE_SYN_RECV,
2999 /** 3-way handshake was done. */
3000 RTE_FLOW_CONNTRACK_STATE_ESTABLISHED,
3001 /** First FIN packet was received to close the connection. */
3002 RTE_FLOW_CONNTRACK_STATE_FIN_WAIT,
3003 /** First FIN was ACKed. */
3004 RTE_FLOW_CONNTRACK_STATE_CLOSE_WAIT,
3005 /** Second FIN was received, waiting for the last ACK. */
3006 RTE_FLOW_CONNTRACK_STATE_LAST_ACK,
3007 /** Second FIN was ACKed, connection was closed. */
3008 RTE_FLOW_CONNTRACK_STATE_TIME_WAIT,
3012 * The last passed TCP packet flags of a connection.
3014 enum rte_flow_conntrack_tcp_last_index {
3015 RTE_FLOW_CONNTRACK_FLAG_NONE = 0, /**< No Flag. */
3016 RTE_FLOW_CONNTRACK_FLAG_SYN = RTE_BIT32(0), /**< With SYN flag. */
3017 RTE_FLOW_CONNTRACK_FLAG_SYNACK = RTE_BIT32(1), /**< With SYNACK flag. */
3018 RTE_FLOW_CONNTRACK_FLAG_FIN = RTE_BIT32(2), /**< With FIN flag. */
3019 RTE_FLOW_CONNTRACK_FLAG_ACK = RTE_BIT32(3), /**< With ACK flag. */
3020 RTE_FLOW_CONNTRACK_FLAG_RST = RTE_BIT32(4), /**< With RST flag. */
3025 * @b EXPERIMENTAL: this structure may change without prior notice
3027 * Configuration parameters for each direction of a TCP connection.
3028 * All fields should be in host byte order.
3029 * If needed, driver should convert all fields to network byte order
3030 * if HW needs them in that way.
3032 struct rte_flow_tcp_dir_param {
3033 /** TCP window scaling factor, 0xF to disable. */
3035 /** The FIN was sent by this direction. */
3036 uint32_t close_initiated:1;
3037 /** An ACK packet has been received by this side. */
3038 uint32_t last_ack_seen:1;
3040 * If set, it indicates that there is unacknowledged data for the
3041 * packets sent from this direction.
3043 uint32_t data_unacked:1;
3045 * Maximal value of sequence + payload length in sent
3046 * packets (next ACK from the opposite direction).
3050 * Maximal value of (ACK + window size) in received packet + length
3051 * over sent packet (maximal sequence could be sent).
3054 /** Maximal value of actual window size in sent packets. */
3056 /** Maximal value of ACK in sent packets. */
3062 * @b EXPERIMENTAL: this structure may change without prior notice
3064 * RTE_FLOW_ACTION_TYPE_CONNTRACK
3066 * Configuration and initial state for the connection tracking module.
3067 * This structure could be used for both setting and query.
3068 * All fields should be in host byte order.
3070 struct rte_flow_action_conntrack {
3071 /** The peer port number, can be the same port. */
3074 * Direction of this connection when creating a flow rule, the
3075 * value only affects the creation of subsequent flow rules.
3077 uint32_t is_original_dir:1;
3079 * Enable / disable the conntrack HW module. When disabled, the
3080 * result will always be RTE_FLOW_CONNTRACK_FLAG_DISABLED.
3081 * In this state the HW will act as passthrough.
3082 * It only affects this conntrack object in the HW without any effect
3083 * to the other objects.
3086 /** At least one ack was seen after the connection was established. */
3087 uint32_t live_connection:1;
3088 /** Enable selective ACK on this connection. */
3089 uint32_t selective_ack:1;
3090 /** A challenge ack has passed. */
3091 uint32_t challenge_ack_passed:1;
3093 * 1: The last packet is seen from the original direction.
3094 * 0: The last packet is seen from the reply direction.
3096 uint32_t last_direction:1;
3097 /** No TCP check will be done except the state change. */
3098 uint32_t liberal_mode:1;
3099 /**<The current state of this connection. */
3100 enum rte_flow_conntrack_state state;
3101 /** Scaling factor for maximal allowed ACK window. */
3102 uint8_t max_ack_window;
3103 /** Maximal allowed number of retransmission times. */
3104 uint8_t retransmission_limit;
3105 /** TCP parameters of the original direction. */
3106 struct rte_flow_tcp_dir_param original_dir;
3107 /** TCP parameters of the reply direction. */
3108 struct rte_flow_tcp_dir_param reply_dir;
3109 /** The window value of the last packet passed this conntrack. */
3110 uint16_t last_window;
3111 enum rte_flow_conntrack_tcp_last_index last_index;
3112 /** The sequence of the last packet passed this conntrack. */
3114 /** The acknowledgment of the last packet passed this conntrack. */
3117 * The total value ACK + payload length of the last packet
3118 * passed this conntrack.
3124 * RTE_FLOW_ACTION_TYPE_CONNTRACK
3126 * Wrapper structure for the context update interface.
3127 * Ports cannot support updating, and the only valid solution is to
3128 * destroy the old context and create a new one instead.
3130 struct rte_flow_modify_conntrack {
3131 /** New connection tracking parameters to be updated. */
3132 struct rte_flow_action_conntrack new_ct;
3133 /** The direction field will be updated. */
3134 uint32_t direction:1;
3135 /** All the other fields except direction will be updated. */
3137 /** Reserved bits for the future usage. */
3138 uint32_t reserved:30;
3142 * Field IDs for MODIFY_FIELD action.
3144 enum rte_flow_field_id {
3145 RTE_FLOW_FIELD_START = 0, /**< Start of a packet. */
3146 RTE_FLOW_FIELD_MAC_DST, /**< Destination MAC Address. */
3147 RTE_FLOW_FIELD_MAC_SRC, /**< Source MAC Address. */
3148 RTE_FLOW_FIELD_VLAN_TYPE, /**< 802.1Q Tag Identifier. */
3149 RTE_FLOW_FIELD_VLAN_ID, /**< 802.1Q VLAN Identifier. */
3150 RTE_FLOW_FIELD_MAC_TYPE, /**< EtherType. */
3151 RTE_FLOW_FIELD_IPV4_DSCP, /**< IPv4 DSCP. */
3152 RTE_FLOW_FIELD_IPV4_TTL, /**< IPv4 Time To Live. */
3153 RTE_FLOW_FIELD_IPV4_SRC, /**< IPv4 Source Address. */
3154 RTE_FLOW_FIELD_IPV4_DST, /**< IPv4 Destination Address. */
3155 RTE_FLOW_FIELD_IPV6_DSCP, /**< IPv6 DSCP. */
3156 RTE_FLOW_FIELD_IPV6_HOPLIMIT, /**< IPv6 Hop Limit. */
3157 RTE_FLOW_FIELD_IPV6_SRC, /**< IPv6 Source Address. */
3158 RTE_FLOW_FIELD_IPV6_DST, /**< IPv6 Destination Address. */
3159 RTE_FLOW_FIELD_TCP_PORT_SRC, /**< TCP Source Port Number. */
3160 RTE_FLOW_FIELD_TCP_PORT_DST, /**< TCP Destination Port Number. */
3161 RTE_FLOW_FIELD_TCP_SEQ_NUM, /**< TCP Sequence Number. */
3162 RTE_FLOW_FIELD_TCP_ACK_NUM, /**< TCP Acknowledgment Number. */
3163 RTE_FLOW_FIELD_TCP_FLAGS, /**< TCP Flags. */
3164 RTE_FLOW_FIELD_UDP_PORT_SRC, /**< UDP Source Port Number. */
3165 RTE_FLOW_FIELD_UDP_PORT_DST, /**< UDP Destination Port Number. */
3166 RTE_FLOW_FIELD_VXLAN_VNI, /**< VXLAN Network Identifier. */
3167 RTE_FLOW_FIELD_GENEVE_VNI, /**< GENEVE Network Identifier. */
3168 RTE_FLOW_FIELD_GTP_TEID, /**< GTP Tunnel Endpoint Identifier. */
3169 RTE_FLOW_FIELD_TAG, /**< Tag value. */
3170 RTE_FLOW_FIELD_MARK, /**< Mark value. */
3171 RTE_FLOW_FIELD_META, /**< Metadata value. */
3172 RTE_FLOW_FIELD_POINTER, /**< Memory pointer. */
3173 RTE_FLOW_FIELD_VALUE, /**< Immediate value. */
3177 * Field description for MODIFY_FIELD action.
3179 struct rte_flow_action_modify_data {
3180 enum rte_flow_field_id field; /**< Field or memory type ID. */
3184 /**< Encapsulation level or tag index. */
3186 /**< Number of bits to skip from a field. */
3190 * Immediate value for RTE_FLOW_FIELD_VALUE or
3191 * memory address for RTE_FLOW_FIELD_POINTER.
3198 * Operation types for MODIFY_FIELD action.
3200 enum rte_flow_modify_op {
3201 RTE_FLOW_MODIFY_SET = 0, /**< Set a new value. */
3202 RTE_FLOW_MODIFY_ADD, /**< Add a value to a field. */
3203 RTE_FLOW_MODIFY_SUB, /**< Subtract a value from a field. */
3208 * @b EXPERIMENTAL: this structure may change without prior notice
3210 * RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
3212 * Modify a destination header field according to the specified
3213 * operation. Another packet field can be used as a source as well
3214 * as tag, mark, metadata, immediate value or a pointer to it.
3216 struct rte_flow_action_modify_field {
3217 enum rte_flow_modify_op operation; /**< Operation to perform. */
3218 struct rte_flow_action_modify_data dst; /**< Destination field. */
3219 struct rte_flow_action_modify_data src; /**< Source field. */
3220 uint32_t width; /**< Number of bits to use from a source field. */
3223 /* Mbuf dynamic field offset for metadata. */
3224 extern int32_t rte_flow_dynf_metadata_offs;
3226 /* Mbuf dynamic field flag mask for metadata. */
3227 extern uint64_t rte_flow_dynf_metadata_mask;
3229 /* Mbuf dynamic field pointer for metadata. */
3230 #define RTE_FLOW_DYNF_METADATA(m) \
3231 RTE_MBUF_DYNFIELD((m), rte_flow_dynf_metadata_offs, uint32_t *)
3233 /* Mbuf dynamic flags for metadata. */
3234 #define PKT_RX_DYNF_METADATA (rte_flow_dynf_metadata_mask)
3235 #define PKT_TX_DYNF_METADATA (rte_flow_dynf_metadata_mask)
3238 static inline uint32_t
3239 rte_flow_dynf_metadata_get(struct rte_mbuf *m)
3241 return *RTE_FLOW_DYNF_METADATA(m);
3246 rte_flow_dynf_metadata_set(struct rte_mbuf *m, uint32_t v)
3248 *RTE_FLOW_DYNF_METADATA(m) = v;
3252 * Definition of a single action.
3254 * A list of actions is terminated by a END action.
3256 * For simple actions without a configuration object, conf remains NULL.
3258 struct rte_flow_action {
3259 enum rte_flow_action_type type; /**< Action type. */
3260 const void *conf; /**< Pointer to action configuration object. */
3264 * Opaque type returned after successfully creating a flow.
3266 * This handle can be used to manage and query the related flow (e.g. to
3267 * destroy it or retrieve counters).
3273 * @b EXPERIMENTAL: this structure may change without prior notice
3275 * RTE_FLOW_ACTION_TYPE_SAMPLE
3277 * Adds a sample action to a matched flow.
3279 * The matching packets will be duplicated with specified ratio and applied
3280 * with own set of actions with a fate action, the sampled packet could be
3281 * redirected to queue or port. All the packets continue processing on the
3282 * default flow path.
3284 * When the sample ratio is set to 1 then the packets will be 100% mirrored.
3285 * Additional action list be supported to add for sampled or mirrored packets.
3287 struct rte_flow_action_sample {
3288 uint32_t ratio; /**< packets sampled equals to '1/ratio'. */
3289 const struct rte_flow_action *actions;
3290 /**< sub-action list specific for the sampling hit cases. */
3294 * Verbose error types.
3296 * Most of them provide the type of the object referenced by struct
3297 * rte_flow_error.cause.
3299 enum rte_flow_error_type {
3300 RTE_FLOW_ERROR_TYPE_NONE, /**< No error. */
3301 RTE_FLOW_ERROR_TYPE_UNSPECIFIED, /**< Cause unspecified. */
3302 RTE_FLOW_ERROR_TYPE_HANDLE, /**< Flow rule (handle). */
3303 RTE_FLOW_ERROR_TYPE_ATTR_GROUP, /**< Group field. */
3304 RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY, /**< Priority field. */
3305 RTE_FLOW_ERROR_TYPE_ATTR_INGRESS, /**< Ingress field. */
3306 RTE_FLOW_ERROR_TYPE_ATTR_EGRESS, /**< Egress field. */
3307 RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, /**< Transfer field. */
3308 RTE_FLOW_ERROR_TYPE_ATTR, /**< Attributes structure. */
3309 RTE_FLOW_ERROR_TYPE_ITEM_NUM, /**< Pattern length. */
3310 RTE_FLOW_ERROR_TYPE_ITEM_SPEC, /**< Item specification. */
3311 RTE_FLOW_ERROR_TYPE_ITEM_LAST, /**< Item specification range. */
3312 RTE_FLOW_ERROR_TYPE_ITEM_MASK, /**< Item specification mask. */
3313 RTE_FLOW_ERROR_TYPE_ITEM, /**< Specific pattern item. */
3314 RTE_FLOW_ERROR_TYPE_ACTION_NUM, /**< Number of actions. */
3315 RTE_FLOW_ERROR_TYPE_ACTION_CONF, /**< Action configuration. */
3316 RTE_FLOW_ERROR_TYPE_ACTION, /**< Specific action. */
3320 * Verbose error structure definition.
3322 * This object is normally allocated by applications and set by PMDs, the
3323 * message points to a constant string which does not need to be freed by
3324 * the application, however its pointer can be considered valid only as long
3325 * as its associated DPDK port remains configured. Closing the underlying
3326 * device or unloading the PMD invalidates it.
3328 * Both cause and message may be NULL regardless of the error type.
3330 struct rte_flow_error {
3331 enum rte_flow_error_type type; /**< Cause field and error types. */
3332 const void *cause; /**< Object responsible for the error. */
3333 const char *message; /**< Human-readable error message. */
3337 * Complete flow rule description.
3339 * This object type is used when converting a flow rule description.
3341 * @see RTE_FLOW_CONV_OP_RULE
3342 * @see rte_flow_conv()
3345 struct rte_flow_conv_rule {
3347 const struct rte_flow_attr *attr_ro; /**< RO attributes. */
3348 struct rte_flow_attr *attr; /**< Attributes. */
3351 const struct rte_flow_item *pattern_ro; /**< RO pattern. */
3352 struct rte_flow_item *pattern; /**< Pattern items. */
3355 const struct rte_flow_action *actions_ro; /**< RO actions. */
3356 struct rte_flow_action *actions; /**< List of actions. */
3361 * Conversion operations for flow API objects.
3363 * @see rte_flow_conv()
3365 enum rte_flow_conv_op {
3367 * No operation to perform.
3369 * rte_flow_conv() simply returns 0.
3371 RTE_FLOW_CONV_OP_NONE,
3374 * Convert attributes structure.
3376 * This is a basic copy of an attributes structure.
3379 * @code const struct rte_flow_attr * @endcode
3381 * @code struct rte_flow_attr * @endcode
3383 RTE_FLOW_CONV_OP_ATTR,
3386 * Convert a single item.
3388 * Duplicates @p spec, @p last and @p mask but not outside objects.
3391 * @code const struct rte_flow_item * @endcode
3393 * @code struct rte_flow_item * @endcode
3395 RTE_FLOW_CONV_OP_ITEM,
3398 * Convert a single action.
3400 * Duplicates @p conf but not outside objects.
3403 * @code const struct rte_flow_action * @endcode
3405 * @code struct rte_flow_action * @endcode
3407 RTE_FLOW_CONV_OP_ACTION,
3410 * Convert an entire pattern.
3412 * Duplicates all pattern items at once with the same constraints as
3413 * RTE_FLOW_CONV_OP_ITEM.
3416 * @code const struct rte_flow_item * @endcode
3418 * @code struct rte_flow_item * @endcode
3420 RTE_FLOW_CONV_OP_PATTERN,
3423 * Convert a list of actions.
3425 * Duplicates the entire list of actions at once with the same
3426 * constraints as RTE_FLOW_CONV_OP_ACTION.
3429 * @code const struct rte_flow_action * @endcode
3431 * @code struct rte_flow_action * @endcode
3433 RTE_FLOW_CONV_OP_ACTIONS,
3436 * Convert a complete flow rule description.
3438 * Comprises attributes, pattern and actions together at once with
3439 * the usual constraints.
3442 * @code const struct rte_flow_conv_rule * @endcode
3444 * @code struct rte_flow_conv_rule * @endcode
3446 RTE_FLOW_CONV_OP_RULE,
3449 * Convert item type to its name string.
3451 * Writes a NUL-terminated string to @p dst. Like snprintf(), the
3452 * returned value excludes the terminator which is always written
3456 * @code (const void *)enum rte_flow_item_type @endcode
3458 * @code char * @endcode
3460 RTE_FLOW_CONV_OP_ITEM_NAME,
3463 * Convert action type to its name string.
3465 * Writes a NUL-terminated string to @p dst. Like snprintf(), the
3466 * returned value excludes the terminator which is always written
3470 * @code (const void *)enum rte_flow_action_type @endcode
3472 * @code char * @endcode
3474 RTE_FLOW_CONV_OP_ACTION_NAME,
3477 * Convert item type to pointer to item name.
3479 * Retrieves item name pointer from its type. The string itself is
3480 * not copied; instead, a unique pointer to an internal static
3481 * constant storage is written to @p dst.
3484 * @code (const void *)enum rte_flow_item_type @endcode
3486 * @code const char ** @endcode
3488 RTE_FLOW_CONV_OP_ITEM_NAME_PTR,
3491 * Convert action type to pointer to action name.
3493 * Retrieves action name pointer from its type. The string itself is
3494 * not copied; instead, a unique pointer to an internal static
3495 * constant storage is written to @p dst.
3498 * @code (const void *)enum rte_flow_action_type @endcode
3500 * @code const char ** @endcode
3502 RTE_FLOW_CONV_OP_ACTION_NAME_PTR,
3507 * @b EXPERIMENTAL: this API may change without prior notice.
3509 * Dump hardware internal representation information of
3512 * @param[in] port_id
3513 * The port identifier of the Ethernet device.
3515 * The pointer of flow rule to dump. Dump all rules if NULL.
3517 * A pointer to a file for output.
3519 * Perform verbose error reporting if not NULL. PMDs initialize this
3520 * structure in case of error only.
3522 * 0 on success, a nagative value otherwise.
3526 rte_flow_dev_dump(uint16_t port_id, struct rte_flow *flow,
3527 FILE *file, struct rte_flow_error *error);
3530 * Check if mbuf dynamic field for metadata is registered.
3533 * True if registered, false otherwise.
3537 rte_flow_dynf_metadata_avail(void)
3539 return !!rte_flow_dynf_metadata_mask;
3543 * Register mbuf dynamic field and flag for metadata.
3545 * This function must be called prior to use SET_META action in order to
3546 * register the dynamic mbuf field. Otherwise, the data cannot be delivered to
3550 * 0 on success, a negative errno value otherwise and rte_errno is set.
3554 rte_flow_dynf_metadata_register(void);
3557 * Check whether a flow rule can be created on a given port.
3559 * The flow rule is validated for correctness and whether it could be accepted
3560 * by the device given sufficient resources. The rule is checked against the
3561 * current device mode and queue configuration. The flow rule may also
3562 * optionally be validated against existing flow rules and device resources.
3563 * This function has no effect on the target device.
3565 * The returned value is guaranteed to remain valid only as long as no
3566 * successful calls to rte_flow_create() or rte_flow_destroy() are made in
3567 * the meantime and no device parameter affecting flow rules in any way are
3568 * modified, due to possible collisions or resource limitations (although in
3569 * such cases EINVAL should not be returned).
3572 * Port identifier of Ethernet device.
3574 * Flow rule attributes.
3575 * @param[in] pattern
3576 * Pattern specification (list terminated by the END pattern item).
3577 * @param[in] actions
3578 * Associated actions (list terminated by the END action).
3580 * Perform verbose error reporting if not NULL. PMDs initialize this
3581 * structure in case of error only.
3584 * 0 if flow rule is valid and can be created. A negative errno value
3585 * otherwise (rte_errno is also set), the following errors are defined:
3587 * -ENOSYS: underlying device does not support this functionality.
3589 * -EIO: underlying device is removed.
3591 * -EINVAL: unknown or invalid rule specification.
3593 * -ENOTSUP: valid but unsupported rule specification (e.g. partial
3594 * bit-masks are unsupported).
3596 * -EEXIST: collision with an existing rule. Only returned if device
3597 * supports flow rule collision checking and there was a flow rule
3598 * collision. Not receiving this return code is no guarantee that creating
3599 * the rule will not fail due to a collision.
3601 * -ENOMEM: not enough memory to execute the function, or if the device
3602 * supports resource validation, resource limitation on the device.
3604 * -EBUSY: action cannot be performed due to busy device resources, may
3605 * succeed if the affected queues or even the entire port are in a stopped
3606 * state (see rte_eth_dev_rx_queue_stop() and rte_eth_dev_stop()).
3609 rte_flow_validate(uint16_t port_id,
3610 const struct rte_flow_attr *attr,
3611 const struct rte_flow_item pattern[],
3612 const struct rte_flow_action actions[],
3613 struct rte_flow_error *error);
3616 * Create a flow rule on a given port.
3619 * Port identifier of Ethernet device.
3621 * Flow rule attributes.
3622 * @param[in] pattern
3623 * Pattern specification (list terminated by the END pattern item).
3624 * @param[in] actions
3625 * Associated actions (list terminated by the END action).
3627 * Perform verbose error reporting if not NULL. PMDs initialize this
3628 * structure in case of error only.
3631 * A valid handle in case of success, NULL otherwise and rte_errno is set
3632 * to the positive version of one of the error codes defined for
3633 * rte_flow_validate().
3636 rte_flow_create(uint16_t port_id,
3637 const struct rte_flow_attr *attr,
3638 const struct rte_flow_item pattern[],
3639 const struct rte_flow_action actions[],
3640 struct rte_flow_error *error);
3643 * Destroy a flow rule on a given port.
3645 * Failure to destroy a flow rule handle may occur when other flow rules
3646 * depend on it, and destroying it would result in an inconsistent state.
3648 * This function is only guaranteed to succeed if handles are destroyed in
3649 * reverse order of their creation.
3652 * Port identifier of Ethernet device.
3654 * Flow rule handle to destroy.
3656 * Perform verbose error reporting if not NULL. PMDs initialize this
3657 * structure in case of error only.
3660 * 0 on success, a negative errno value otherwise and rte_errno is set.
3663 rte_flow_destroy(uint16_t port_id,
3664 struct rte_flow *flow,
3665 struct rte_flow_error *error);
3668 * Destroy all flow rules associated with a port.
3670 * In the unlikely event of failure, handles are still considered destroyed
3671 * and no longer valid but the port must be assumed to be in an inconsistent
3675 * Port identifier of Ethernet device.
3677 * Perform verbose error reporting if not NULL. PMDs initialize this
3678 * structure in case of error only.
3681 * 0 on success, a negative errno value otherwise and rte_errno is set.
3684 rte_flow_flush(uint16_t port_id,
3685 struct rte_flow_error *error);
3688 * Query an existing flow rule.
3690 * This function allows retrieving flow-specific data such as counters.
3691 * Data is gathered by special actions which must be present in the flow
3694 * \see RTE_FLOW_ACTION_TYPE_COUNT
3697 * Port identifier of Ethernet device.
3699 * Flow rule handle to query.
3701 * Action definition as defined in original flow rule.
3702 * @param[in, out] data
3703 * Pointer to storage for the associated query data type.
3705 * Perform verbose error reporting if not NULL. PMDs initialize this
3706 * structure in case of error only.
3709 * 0 on success, a negative errno value otherwise and rte_errno is set.
3712 rte_flow_query(uint16_t port_id,
3713 struct rte_flow *flow,
3714 const struct rte_flow_action *action,
3716 struct rte_flow_error *error);
3719 * Restrict ingress traffic to the defined flow rules.
3721 * Isolated mode guarantees that all ingress traffic comes from defined flow
3722 * rules only (current and future).
3724 * Besides making ingress more deterministic, it allows PMDs to safely reuse
3725 * resources otherwise assigned to handle the remaining traffic, such as
3726 * global RSS configuration settings, VLAN filters, MAC address entries,
3727 * legacy filter API rules and so on in order to expand the set of possible
3730 * Calling this function as soon as possible after device initialization,
3731 * ideally before the first call to rte_eth_dev_configure(), is recommended
3732 * to avoid possible failures due to conflicting settings.
3734 * Once effective, leaving isolated mode may not be possible depending on
3735 * PMD implementation.
3737 * Additionally, the following functionality has no effect on the underlying
3738 * port and may return errors such as ENOTSUP ("not supported"):
3740 * - Toggling promiscuous mode.
3741 * - Toggling allmulticast mode.
3742 * - Configuring MAC addresses.
3743 * - Configuring multicast addresses.
3744 * - Configuring VLAN filters.
3745 * - Configuring Rx filters through the legacy API (e.g. FDIR).
3746 * - Configuring global RSS settings.
3749 * Port identifier of Ethernet device.
3751 * Nonzero to enter isolated mode, attempt to leave it otherwise.
3753 * Perform verbose error reporting if not NULL. PMDs initialize this
3754 * structure in case of error only.
3757 * 0 on success, a negative errno value otherwise and rte_errno is set.
3760 rte_flow_isolate(uint16_t port_id, int set, struct rte_flow_error *error);
3763 * Initialize flow error structure.
3766 * Pointer to flow error structure (may be NULL).
3768 * Related error code (rte_errno).
3770 * Cause field and error types.
3772 * Object responsible for the error.
3774 * Human-readable error message.
3777 * Negative error code (errno value) and rte_errno is set.
3780 rte_flow_error_set(struct rte_flow_error *error,
3782 enum rte_flow_error_type type,
3784 const char *message);
3788 * @see rte_flow_copy()
3790 struct rte_flow_desc {
3791 size_t size; /**< Allocated space including data[]. */
3792 struct rte_flow_attr attr; /**< Attributes. */
3793 struct rte_flow_item *items; /**< Items. */
3794 struct rte_flow_action *actions; /**< Actions. */
3795 uint8_t data[]; /**< Storage for items/actions. */
3800 * Copy an rte_flow rule description.
3802 * This interface is kept for compatibility with older applications but is
3803 * implemented as a wrapper to rte_flow_conv(). It is deprecated due to its
3804 * lack of flexibility and reliance on a type unusable with C++ programs
3805 * (struct rte_flow_desc).
3808 * Flow rule description.
3810 * Total size of allocated data for the flow description.
3812 * Flow rule attributes.
3814 * Pattern specification (list terminated by the END pattern item).
3815 * @param[in] actions
3816 * Associated actions (list terminated by the END action).
3819 * If len is greater or equal to the size of the flow, the total size of the
3820 * flow description and its data.
3821 * If len is lower than the size of the flow, the number of bytes that would
3822 * have been written to desc had it been sufficient. Nothing is written.
3826 rte_flow_copy(struct rte_flow_desc *fd, size_t len,
3827 const struct rte_flow_attr *attr,
3828 const struct rte_flow_item *items,
3829 const struct rte_flow_action *actions);
3832 * Flow object conversion helper.
3834 * This function performs conversion of various flow API objects to a
3835 * pre-allocated destination buffer. See enum rte_flow_conv_op for possible
3836 * operations and details about each of them.
3838 * Since destination buffer must be large enough, it works in a manner
3839 * reminiscent of snprintf():
3841 * - If @p size is 0, @p dst may be a NULL pointer, otherwise @p dst must be
3843 * - If positive, the returned value represents the number of bytes needed
3844 * to store the conversion of @p src to @p dst according to @p op
3845 * regardless of the @p size parameter.
3846 * - Since no more than @p size bytes can be written to @p dst, output is
3847 * truncated and may be inconsistent when the returned value is larger
3849 * - In case of conversion error, a negative error code is returned and
3850 * @p dst contents are unspecified.
3853 * Operation to perform, related to the object type of @p dst.
3855 * Destination buffer address. Must be suitably aligned by the caller.
3857 * Destination buffer size in bytes.
3859 * Source object to copy. Depending on @p op, its type may differ from
3862 * Perform verbose error reporting if not NULL. Initialized in case of
3866 * The number of bytes required to convert @p src to @p dst on success, a
3867 * negative errno value otherwise and rte_errno is set.
3869 * @see rte_flow_conv_op
3873 rte_flow_conv(enum rte_flow_conv_op op,
3877 struct rte_flow_error *error);
3880 * Get aged-out flows of a given port.
3882 * RTE_ETH_EVENT_FLOW_AGED event will be triggered when at least one new aged
3883 * out flow was detected after the last call to rte_flow_get_aged_flows.
3884 * This function can be called to get the aged flows usynchronously from the
3885 * event callback or synchronously regardless the event.
3886 * This is not safe to call rte_flow_get_aged_flows function with other flow
3887 * functions from multiple threads simultaneously.
3890 * Port identifier of Ethernet device.
3891 * @param[in, out] contexts
3892 * The address of an array of pointers to the aged-out flows contexts.
3893 * @param[in] nb_contexts
3894 * The length of context array pointers.
3896 * Perform verbose error reporting if not NULL. Initialized in case of
3900 * if nb_contexts is 0, return the amount of all aged contexts.
3901 * if nb_contexts is not 0 , return the amount of aged flows reported
3902 * in the context array, otherwise negative errno value.
3904 * @see rte_flow_action_age
3905 * @see RTE_ETH_EVENT_FLOW_AGED
3909 rte_flow_get_aged_flows(uint16_t port_id, void **contexts,
3910 uint32_t nb_contexts, struct rte_flow_error *error);
3913 * Specify indirect action object configuration
3915 struct rte_flow_indir_action_conf {
3917 * Flow direction for the indirect action configuration.
3919 * Action should be valid at least for one flow direction,
3920 * otherwise it is invalid for both ingress and egress rules.
3923 /**< Action valid for rules applied to ingress traffic. */
3925 /**< Action valid for rules applied to egress traffic. */
3927 * When set to 1, indicates that the action is valid for
3928 * transfer traffic; otherwise, for non-transfer traffic.
3930 uint32_t transfer:1;
3935 * @b EXPERIMENTAL: this API may change without prior notice.
3937 * Create an indirect action object that can be used in flow rules
3939 * The created object handle has single state and configuration
3940 * across all the flow rules using it.
3942 * @param[in] port_id
3943 * The port identifier of the Ethernet device.
3945 * Action configuration for the indirect action object creation.
3947 * Specific configuration of the indirect action object.
3949 * Perform verbose error reporting if not NULL. PMDs initialize this
3950 * structure in case of error only.
3952 * A valid handle in case of success, NULL otherwise and rte_errno is set
3953 * to one of the error codes defined:
3954 * - (ENODEV) if *port_id* invalid.
3955 * - (ENOSYS) if underlying device does not support this functionality.
3956 * - (EIO) if underlying device is removed.
3957 * - (EINVAL) if *action* invalid.
3958 * - (ENOTSUP) if *action* valid but unsupported.
3961 struct rte_flow_action_handle *
3962 rte_flow_action_handle_create(uint16_t port_id,
3963 const struct rte_flow_indir_action_conf *conf,
3964 const struct rte_flow_action *action,
3965 struct rte_flow_error *error);
3969 * @b EXPERIMENTAL: this API may change without prior notice.
3971 * Destroy indirect action by handle.
3973 * @param[in] port_id
3974 * The port identifier of the Ethernet device.
3976 * Handle for the indirect action object to be destroyed.
3978 * Perform verbose error reporting if not NULL. PMDs initialize this
3979 * structure in case of error only.
3982 * - (-ENODEV) if *port_id* invalid.
3983 * - (-ENOSYS) if underlying device does not support this functionality.
3984 * - (-EIO) if underlying device is removed.
3985 * - (-ENOENT) if action pointed by *action* handle was not found.
3986 * - (-EBUSY) if action pointed by *action* handle still used by some rules
3987 * rte_errno is also set.
3991 rte_flow_action_handle_destroy(uint16_t port_id,
3992 struct rte_flow_action_handle *handle,
3993 struct rte_flow_error *error);
3997 * @b EXPERIMENTAL: this API may change without prior notice.
3999 * Update in-place the action configuration and / or state pointed
4000 * by action *handle* with the configuration provided as *update* argument.
4001 * The update of the action configuration effects all flow rules reusing
4002 * the action via *handle*.
4003 * The update general pointer provides the ability of partial updating.
4005 * @param[in] port_id
4006 * The port identifier of the Ethernet device.
4008 * Handle for the indirect action object to be updated.
4010 * Update profile specification used to modify the action pointed by handle.
4011 * *update* could be with the same type of the immediate action corresponding
4012 * to the *handle* argument when creating, or a wrapper structure includes
4013 * action configuration to be updated and bit fields to indicate the member
4014 * of fields inside the action to update.
4016 * Perform verbose error reporting if not NULL. PMDs initialize this
4017 * structure in case of error only.
4020 * - (-ENODEV) if *port_id* invalid.
4021 * - (-ENOSYS) if underlying device does not support this functionality.
4022 * - (-EIO) if underlying device is removed.
4023 * - (-EINVAL) if *update* invalid.
4024 * - (-ENOTSUP) if *update* valid but unsupported.
4025 * - (-ENOENT) if indirect action object pointed by *handle* was not found.
4026 * rte_errno is also set.
4030 rte_flow_action_handle_update(uint16_t port_id,
4031 struct rte_flow_action_handle *handle,
4033 struct rte_flow_error *error);
4037 * @b EXPERIMENTAL: this API may change without prior notice.
4039 * Query the direct action by corresponding indirect action object handle.
4041 * Retrieve action-specific data such as counters.
4042 * Data is gathered by special action which may be present/referenced in
4043 * more than one flow rule definition.
4045 * @see RTE_FLOW_ACTION_TYPE_COUNT
4048 * Port identifier of Ethernet device.
4050 * Handle for the action object to query.
4051 * @param[in, out] data
4052 * Pointer to storage for the associated query data type.
4054 * Perform verbose error reporting if not NULL. PMDs initialize this
4055 * structure in case of error only.
4058 * 0 on success, a negative errno value otherwise and rte_errno is set.
4062 rte_flow_action_handle_query(uint16_t port_id,
4063 const struct rte_flow_action_handle *handle,
4064 void *data, struct rte_flow_error *error);
4066 /* Tunnel has a type and the key information. */
4067 struct rte_flow_tunnel {
4069 * Tunnel type, for example RTE_FLOW_ITEM_TYPE_VXLAN,
4070 * RTE_FLOW_ITEM_TYPE_NVGRE etc.
4072 enum rte_flow_item_type type;
4073 uint64_t tun_id; /**< Tunnel identification. */
4078 rte_be32_t src_addr; /**< IPv4 source address. */
4079 rte_be32_t dst_addr; /**< IPv4 destination address. */
4082 uint8_t src_addr[16]; /**< IPv6 source address. */
4083 uint8_t dst_addr[16]; /**< IPv6 destination address. */
4086 rte_be16_t tp_src; /**< Tunnel port source. */
4087 rte_be16_t tp_dst; /**< Tunnel port destination. */
4088 uint16_t tun_flags; /**< Tunnel flags. */
4090 bool is_ipv6; /**< True for valid IPv6 fields. Otherwise IPv4. */
4093 * the following members are required to restore packet
4096 uint8_t tos; /**< TOS for IPv4, TC for IPv6. */
4097 uint8_t ttl; /**< TTL for IPv4, HL for IPv6. */
4098 uint32_t label; /**< Flow Label for IPv6. */
4102 * Indicate that the packet has a tunnel.
4104 #define RTE_FLOW_RESTORE_INFO_TUNNEL (1ULL << 0)
4107 * Indicate that the packet has a non decapsulated tunnel header.
4109 #define RTE_FLOW_RESTORE_INFO_ENCAPSULATED (1ULL << 1)
4112 * Indicate that the packet has a group_id.
4114 #define RTE_FLOW_RESTORE_INFO_GROUP_ID (1ULL << 2)
4117 * Restore information structure to communicate the current packet processing
4118 * state when some of the processing pipeline is done in hardware and should
4119 * continue in software.
4121 struct rte_flow_restore_info {
4123 * Bitwise flags (RTE_FLOW_RESTORE_INFO_*) to indicate validation of
4124 * other fields in struct rte_flow_restore_info.
4127 uint32_t group_id; /**< Group ID where packed missed */
4128 struct rte_flow_tunnel tunnel; /**< Tunnel information. */
4132 * Allocate an array of actions to be used in rte_flow_create, to implement
4133 * tunnel-decap-set for the given tunnel.
4135 * actions vxlan_decap / tunnel-decap-set(tunnel properties) /
4136 * jump group 0 / end
4139 * Port identifier of Ethernet device.
4141 * Tunnel properties.
4142 * @param[out] actions
4143 * Array of actions to be allocated by the PMD. This array should be
4144 * concatenated with the actions array provided to rte_flow_create.
4145 * @param[out] num_of_actions
4146 * Number of actions allocated.
4148 * Perform verbose error reporting if not NULL. PMDs initialize this
4149 * structure in case of error only.
4152 * 0 on success, a negative errno value otherwise and rte_errno is set.
4156 rte_flow_tunnel_decap_set(uint16_t port_id,
4157 struct rte_flow_tunnel *tunnel,
4158 struct rte_flow_action **actions,
4159 uint32_t *num_of_actions,
4160 struct rte_flow_error *error);
4163 * Allocate an array of items to be used in rte_flow_create, to implement
4164 * tunnel-match for the given tunnel.
4166 * pattern tunnel-match(tunnel properties) / outer-header-matches /
4167 * inner-header-matches / end
4170 * Port identifier of Ethernet device.
4172 * Tunnel properties.
4174 * Array of items to be allocated by the PMD. This array should be
4175 * concatenated with the items array provided to rte_flow_create.
4176 * @param[out] num_of_items
4177 * Number of items allocated.
4179 * Perform verbose error reporting if not NULL. PMDs initialize this
4180 * structure in case of error only.
4183 * 0 on success, a negative errno value otherwise and rte_errno is set.
4187 rte_flow_tunnel_match(uint16_t port_id,
4188 struct rte_flow_tunnel *tunnel,
4189 struct rte_flow_item **items,
4190 uint32_t *num_of_items,
4191 struct rte_flow_error *error);
4194 * Populate the current packet processing state, if exists, for the given mbuf.
4197 * Port identifier of Ethernet device.
4201 * Restore information. Upon success contains the HW state.
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_get_restore_info(uint16_t port_id,
4213 struct rte_flow_restore_info *info,
4214 struct rte_flow_error *error);
4217 * Release the action array as allocated by rte_flow_tunnel_decap_set.
4220 * Port identifier of Ethernet device.
4221 * @param[in] actions
4222 * Array of actions to be released.
4223 * @param[in] num_of_actions
4224 * Number of elements in actions array.
4226 * Perform verbose error reporting if not NULL. PMDs initialize this
4227 * structure in case of error only.
4230 * 0 on success, a negative errno value otherwise and rte_errno is set.
4234 rte_flow_tunnel_action_decap_release(uint16_t port_id,
4235 struct rte_flow_action *actions,
4236 uint32_t num_of_actions,
4237 struct rte_flow_error *error);
4240 * Release the item array as allocated by rte_flow_tunnel_match.
4243 * Port identifier of Ethernet device.
4245 * Array of items to be released.
4246 * @param[in] num_of_items
4247 * Number of elements in item array.
4249 * Perform verbose error reporting if not NULL. PMDs initialize this
4250 * structure in case of error only.
4253 * 0 on success, a negative errno value otherwise and rte_errno is set.
4257 rte_flow_tunnel_item_release(uint16_t port_id,
4258 struct rte_flow_item *items,
4259 uint32_t num_of_items,
4260 struct rte_flow_error *error);
4265 #endif /* RTE_FLOW_H_ */