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_byteorder.h>
30 #include <rte_higig.h>
32 #include <rte_mbuf_dyn.h>
39 * Flow rule attributes.
41 * Priorities are set on a per rule based within groups.
43 * Lower values denote higher priority, the highest priority for a flow rule
44 * is 0, so that a flow that matches for than one rule, the rule with the
45 * lowest priority value will always be matched.
47 * Although optional, applications are encouraged to group similar rules as
48 * much as possible to fully take advantage of hardware capabilities
49 * (e.g. optimized matching) and work around limitations (e.g. a single
50 * pattern type possibly allowed in a given group). Applications should be
51 * aware that groups are not linked by default, and that they must be
52 * explicitly linked by the application using the JUMP action.
54 * Priority levels are arbitrary and up to the application, they
55 * do not need to be contiguous nor start from 0, however the maximum number
56 * varies between devices and may be affected by existing flow rules.
58 * If a packet is matched by several rules of a given group for a given
59 * priority level, the outcome is undefined. It can take any path, may be
60 * duplicated or even cause unrecoverable errors.
62 * Note that support for more than a single group and priority level is not
65 * Flow rules can apply to inbound and/or outbound traffic (ingress/egress).
67 * Several pattern items and actions are valid and can be used in both
68 * directions. Those valid for only one direction are described as such.
70 * At least one direction must be specified.
72 * Specifying both directions at once for a given rule is not recommended
73 * but may be valid in a few cases (e.g. shared counter).
75 struct rte_flow_attr {
76 uint32_t group; /**< Priority group. */
77 uint32_t priority; /**< Rule priority level within group. */
78 uint32_t ingress:1; /**< Rule applies to ingress traffic. */
79 uint32_t egress:1; /**< Rule applies to egress traffic. */
81 * Instead of simply matching the properties of traffic as it would
82 * appear on a given DPDK port ID, enabling this attribute transfers
83 * a flow rule to the lowest possible level of any device endpoints
84 * found in the pattern.
86 * When supported, this effectively enables an application to
87 * re-route traffic not necessarily intended for it (e.g. coming
88 * from or addressed to different physical ports, VFs or
89 * applications) at the device level.
91 * It complements the behavior of some pattern items such as
92 * RTE_FLOW_ITEM_TYPE_PHY_PORT and is meaningless without them.
94 * When transferring flow rules, ingress and egress attributes keep
95 * their original meaning, as if processing traffic emitted or
96 * received by the application.
99 uint32_t reserved:29; /**< Reserved, must be zero. */
103 * Matching pattern item types.
105 * Pattern items fall in two categories:
107 * - Matching protocol headers and packet data, usually associated with a
108 * specification structure. These must be stacked in the same order as the
109 * protocol layers to match inside packets, starting from the lowest.
111 * - Matching meta-data or affecting pattern processing, often without a
112 * specification structure. Since they do not match packet contents, their
113 * position in the list is usually not relevant.
115 * See the description of individual types for more information. Those
116 * marked with [META] fall into the second category.
118 enum rte_flow_item_type {
122 * End marker for item lists. Prevents further processing of items,
123 * thereby ending the pattern.
125 * No associated specification structure.
127 RTE_FLOW_ITEM_TYPE_END,
132 * Used as a placeholder for convenience. It is ignored and simply
135 * No associated specification structure.
137 RTE_FLOW_ITEM_TYPE_VOID,
142 * Inverted matching, i.e. process packets that do not match the
145 * No associated specification structure.
147 RTE_FLOW_ITEM_TYPE_INVERT,
150 * Matches any protocol in place of the current layer, a single ANY
151 * may also stand for several protocol layers.
153 * See struct rte_flow_item_any.
155 RTE_FLOW_ITEM_TYPE_ANY,
160 * Matches traffic originating from (ingress) or going to (egress)
161 * the physical function of the current device.
163 * No associated specification structure.
165 RTE_FLOW_ITEM_TYPE_PF,
170 * Matches traffic originating from (ingress) or going to (egress) a
171 * given virtual function of the current device.
173 * See struct rte_flow_item_vf.
175 RTE_FLOW_ITEM_TYPE_VF,
180 * Matches traffic originating from (ingress) or going to (egress) a
181 * physical port of the underlying device.
183 * See struct rte_flow_item_phy_port.
185 RTE_FLOW_ITEM_TYPE_PHY_PORT,
190 * Matches traffic originating from (ingress) or going to (egress) a
191 * given DPDK port ID.
193 * See struct rte_flow_item_port_id.
195 RTE_FLOW_ITEM_TYPE_PORT_ID,
198 * Matches a byte string of a given length at a given offset.
200 * See struct rte_flow_item_raw.
202 RTE_FLOW_ITEM_TYPE_RAW,
205 * Matches an Ethernet header.
207 * See struct rte_flow_item_eth.
209 RTE_FLOW_ITEM_TYPE_ETH,
212 * Matches an 802.1Q/ad VLAN tag.
214 * See struct rte_flow_item_vlan.
216 RTE_FLOW_ITEM_TYPE_VLAN,
219 * Matches an IPv4 header.
221 * See struct rte_flow_item_ipv4.
223 RTE_FLOW_ITEM_TYPE_IPV4,
226 * Matches an IPv6 header.
228 * See struct rte_flow_item_ipv6.
230 RTE_FLOW_ITEM_TYPE_IPV6,
233 * Matches an ICMP header.
235 * See struct rte_flow_item_icmp.
237 RTE_FLOW_ITEM_TYPE_ICMP,
240 * Matches a UDP header.
242 * See struct rte_flow_item_udp.
244 RTE_FLOW_ITEM_TYPE_UDP,
247 * Matches a TCP header.
249 * See struct rte_flow_item_tcp.
251 RTE_FLOW_ITEM_TYPE_TCP,
254 * Matches a SCTP header.
256 * See struct rte_flow_item_sctp.
258 RTE_FLOW_ITEM_TYPE_SCTP,
261 * Matches a VXLAN header.
263 * See struct rte_flow_item_vxlan.
265 RTE_FLOW_ITEM_TYPE_VXLAN,
268 * Matches a E_TAG header.
270 * See struct rte_flow_item_e_tag.
272 RTE_FLOW_ITEM_TYPE_E_TAG,
275 * Matches a NVGRE header.
277 * See struct rte_flow_item_nvgre.
279 RTE_FLOW_ITEM_TYPE_NVGRE,
282 * Matches a MPLS header.
284 * See struct rte_flow_item_mpls.
286 RTE_FLOW_ITEM_TYPE_MPLS,
289 * Matches a GRE header.
291 * See struct rte_flow_item_gre.
293 RTE_FLOW_ITEM_TYPE_GRE,
298 * Fuzzy pattern match, expect faster than default.
300 * This is for device that support fuzzy matching option.
301 * Usually a fuzzy matching is fast but the cost is accuracy.
303 * See struct rte_flow_item_fuzzy.
305 RTE_FLOW_ITEM_TYPE_FUZZY,
308 * Matches a GTP header.
310 * Configure flow for GTP packets.
312 * See struct rte_flow_item_gtp.
314 RTE_FLOW_ITEM_TYPE_GTP,
317 * Matches a GTP header.
319 * Configure flow for GTP-C packets.
321 * See struct rte_flow_item_gtp.
323 RTE_FLOW_ITEM_TYPE_GTPC,
326 * Matches a GTP header.
328 * Configure flow for GTP-U packets.
330 * See struct rte_flow_item_gtp.
332 RTE_FLOW_ITEM_TYPE_GTPU,
335 * Matches a ESP header.
337 * See struct rte_flow_item_esp.
339 RTE_FLOW_ITEM_TYPE_ESP,
342 * Matches a GENEVE header.
344 * See struct rte_flow_item_geneve.
346 RTE_FLOW_ITEM_TYPE_GENEVE,
349 * Matches a VXLAN-GPE header.
351 * See struct rte_flow_item_vxlan_gpe.
353 RTE_FLOW_ITEM_TYPE_VXLAN_GPE,
356 * Matches an ARP header for Ethernet/IPv4.
358 * See struct rte_flow_item_arp_eth_ipv4.
360 RTE_FLOW_ITEM_TYPE_ARP_ETH_IPV4,
363 * Matches the presence of any IPv6 extension header.
365 * See struct rte_flow_item_ipv6_ext.
367 RTE_FLOW_ITEM_TYPE_IPV6_EXT,
370 * Matches any ICMPv6 header.
372 * See struct rte_flow_item_icmp6.
374 RTE_FLOW_ITEM_TYPE_ICMP6,
377 * Matches an ICMPv6 neighbor discovery solicitation.
379 * See struct rte_flow_item_icmp6_nd_ns.
381 RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS,
384 * Matches an ICMPv6 neighbor discovery advertisement.
386 * See struct rte_flow_item_icmp6_nd_na.
388 RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA,
391 * Matches the presence of any ICMPv6 neighbor discovery option.
393 * See struct rte_flow_item_icmp6_nd_opt.
395 RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT,
398 * Matches an ICMPv6 neighbor discovery source Ethernet link-layer
401 * See struct rte_flow_item_icmp6_nd_opt_sla_eth.
403 RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_SLA_ETH,
406 * Matches an ICMPv6 neighbor discovery target Ethernet link-layer
409 * See struct rte_flow_item_icmp6_nd_opt_tla_eth.
411 RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_TLA_ETH,
414 * Matches specified mark field.
416 * See struct rte_flow_item_mark.
418 RTE_FLOW_ITEM_TYPE_MARK,
423 * Matches a metadata value.
425 * See struct rte_flow_item_meta.
427 RTE_FLOW_ITEM_TYPE_META,
430 * Matches a GRE optional key field.
432 * The value should a big-endian 32bit integer.
434 * When this item present the K bit is implicitly matched as "1"
435 * in the default mask.
438 * @code rte_be32_t * @endcode
440 RTE_FLOW_ITEM_TYPE_GRE_KEY,
443 * Matches a GTP extension header: PDU session container.
445 * Configure flow for GTP packets with extension header type 0x85.
447 * See struct rte_flow_item_gtp_psc.
449 RTE_FLOW_ITEM_TYPE_GTP_PSC,
452 * Matches a PPPoE header.
454 * Configure flow for PPPoE session packets.
456 * See struct rte_flow_item_pppoe.
458 RTE_FLOW_ITEM_TYPE_PPPOES,
461 * Matches a PPPoE header.
463 * Configure flow for PPPoE discovery packets.
465 * See struct rte_flow_item_pppoe.
467 RTE_FLOW_ITEM_TYPE_PPPOED,
470 * Matches a PPPoE optional proto_id field.
472 * It only applies to PPPoE session packets.
474 * See struct rte_flow_item_pppoe_proto_id.
476 RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID,
479 * Matches Network service header (NSH).
480 * See struct rte_flow_item_nsh.
483 RTE_FLOW_ITEM_TYPE_NSH,
486 * Matches Internet Group Management Protocol (IGMP).
487 * See struct rte_flow_item_igmp.
490 RTE_FLOW_ITEM_TYPE_IGMP,
493 * Matches IP Authentication Header (AH).
494 * See struct rte_flow_item_ah.
497 RTE_FLOW_ITEM_TYPE_AH,
500 * Matches a HIGIG header.
501 * see struct rte_flow_item_higig2_hdr.
503 RTE_FLOW_ITEM_TYPE_HIGIG2,
508 * Matches a tag value.
510 * See struct rte_flow_item_tag.
512 RTE_FLOW_ITEM_TYPE_TAG,
515 * Matches a L2TPv3 over IP header.
517 * Configure flow for L2TPv3 over IP packets.
519 * See struct rte_flow_item_l2tpv3oip.
521 RTE_FLOW_ITEM_TYPE_L2TPV3OIP,
527 * RTE_FLOW_ITEM_TYPE_HIGIG2
528 * Matches higig2 header
531 struct rte_flow_item_higig2_hdr {
532 struct rte_higig2_hdr hdr;
535 /** Default mask for RTE_FLOW_ITEM_TYPE_HIGIG2. */
537 static const struct rte_flow_item_higig2_hdr rte_flow_item_higig2_hdr_mask = {
540 .classification = 0xffff,
548 * RTE_FLOW_ITEM_TYPE_ANY
550 * Matches any protocol in place of the current layer, a single ANY may also
551 * stand for several protocol layers.
553 * This is usually specified as the first pattern item when looking for a
554 * protocol anywhere in a packet.
556 * A zeroed mask stands for any number of layers.
558 struct rte_flow_item_any {
559 uint32_t num; /**< Number of layers covered. */
562 /** Default mask for RTE_FLOW_ITEM_TYPE_ANY. */
564 static const struct rte_flow_item_any rte_flow_item_any_mask = {
570 * RTE_FLOW_ITEM_TYPE_VF
572 * Matches traffic originating from (ingress) or going to (egress) a given
573 * virtual function of the current device.
575 * If supported, should work even if the virtual function is not managed by
576 * the application and thus not associated with a DPDK port ID.
578 * Note this pattern item does not match VF representors traffic which, as
579 * separate entities, should be addressed through their own DPDK port IDs.
581 * - Can be specified multiple times to match traffic addressed to several
583 * - Can be combined with a PF item to match both PF and VF traffic.
585 * A zeroed mask can be used to match any VF ID.
587 struct rte_flow_item_vf {
588 uint32_t id; /**< VF ID. */
591 /** Default mask for RTE_FLOW_ITEM_TYPE_VF. */
593 static const struct rte_flow_item_vf rte_flow_item_vf_mask = {
599 * RTE_FLOW_ITEM_TYPE_PHY_PORT
601 * Matches traffic originating from (ingress) or going to (egress) a
602 * physical port of the underlying device.
604 * The first PHY_PORT item overrides the physical port normally associated
605 * with the specified DPDK input port (port_id). This item can be provided
606 * several times to match additional physical ports.
608 * Note that physical ports are not necessarily tied to DPDK input ports
609 * (port_id) when those are not under DPDK control. Possible values are
610 * specific to each device, they are not necessarily indexed from zero and
611 * may not be contiguous.
613 * As a device property, the list of allowed values as well as the value
614 * associated with a port_id should be retrieved by other means.
616 * A zeroed mask can be used to match any port index.
618 struct rte_flow_item_phy_port {
619 uint32_t index; /**< Physical port index. */
622 /** Default mask for RTE_FLOW_ITEM_TYPE_PHY_PORT. */
624 static const struct rte_flow_item_phy_port rte_flow_item_phy_port_mask = {
630 * RTE_FLOW_ITEM_TYPE_PORT_ID
632 * Matches traffic originating from (ingress) or going to (egress) a given
635 * Normally only supported if the port ID in question is known by the
636 * underlying PMD and related to the device the flow rule is created
639 * This must not be confused with @p PHY_PORT which refers to the physical
640 * port of a device, whereas @p PORT_ID refers to a struct rte_eth_dev
641 * object on the application side (also known as "port representor"
642 * depending on the kind of underlying device).
644 struct rte_flow_item_port_id {
645 uint32_t id; /**< DPDK port ID. */
648 /** Default mask for RTE_FLOW_ITEM_TYPE_PORT_ID. */
650 static const struct rte_flow_item_port_id rte_flow_item_port_id_mask = {
656 * RTE_FLOW_ITEM_TYPE_RAW
658 * Matches a byte string of a given length at a given offset.
660 * Offset is either absolute (using the start of the packet) or relative to
661 * the end of the previous matched item in the stack, in which case negative
662 * values are allowed.
664 * If search is enabled, offset is used as the starting point. The search
665 * area can be delimited by setting limit to a nonzero value, which is the
666 * maximum number of bytes after offset where the pattern may start.
668 * Matching a zero-length pattern is allowed, doing so resets the relative
669 * offset for subsequent items.
671 * This type does not support ranges (struct rte_flow_item.last).
673 struct rte_flow_item_raw {
674 uint32_t relative:1; /**< Look for pattern after the previous item. */
675 uint32_t search:1; /**< Search pattern from offset (see also limit). */
676 uint32_t reserved:30; /**< Reserved, must be set to zero. */
677 int32_t offset; /**< Absolute or relative offset for pattern. */
678 uint16_t limit; /**< Search area limit for start of pattern. */
679 uint16_t length; /**< Pattern length. */
680 const uint8_t *pattern; /**< Byte string to look for. */
683 /** Default mask for RTE_FLOW_ITEM_TYPE_RAW. */
685 static const struct rte_flow_item_raw rte_flow_item_raw_mask = {
688 .reserved = 0x3fffffff,
689 .offset = 0xffffffff,
697 * RTE_FLOW_ITEM_TYPE_ETH
699 * Matches an Ethernet header.
701 * The @p type field either stands for "EtherType" or "TPID" when followed
702 * by so-called layer 2.5 pattern items such as RTE_FLOW_ITEM_TYPE_VLAN. In
703 * the latter case, @p type refers to that of the outer header, with the
704 * inner EtherType/TPID provided by the subsequent pattern item. This is the
705 * same order as on the wire.
707 struct rte_flow_item_eth {
708 struct rte_ether_addr dst; /**< Destination MAC. */
709 struct rte_ether_addr src; /**< Source MAC. */
710 rte_be16_t type; /**< EtherType or TPID. */
713 /** Default mask for RTE_FLOW_ITEM_TYPE_ETH. */
715 static const struct rte_flow_item_eth rte_flow_item_eth_mask = {
716 .dst.addr_bytes = "\xff\xff\xff\xff\xff\xff",
717 .src.addr_bytes = "\xff\xff\xff\xff\xff\xff",
718 .type = RTE_BE16(0x0000),
723 * RTE_FLOW_ITEM_TYPE_VLAN
725 * Matches an 802.1Q/ad VLAN tag.
727 * The corresponding standard outer EtherType (TPID) values are
728 * RTE_ETHER_TYPE_VLAN or RTE_ETHER_TYPE_QINQ. It can be overridden by
729 * the preceding pattern item.
731 struct rte_flow_item_vlan {
732 rte_be16_t tci; /**< Tag control information. */
733 rte_be16_t inner_type; /**< Inner EtherType or TPID. */
736 /** Default mask for RTE_FLOW_ITEM_TYPE_VLAN. */
738 static const struct rte_flow_item_vlan rte_flow_item_vlan_mask = {
739 .tci = RTE_BE16(0x0fff),
740 .inner_type = RTE_BE16(0x0000),
745 * RTE_FLOW_ITEM_TYPE_IPV4
747 * Matches an IPv4 header.
749 * Note: IPv4 options are handled by dedicated pattern items.
751 struct rte_flow_item_ipv4 {
752 struct rte_ipv4_hdr hdr; /**< IPv4 header definition. */
755 /** Default mask for RTE_FLOW_ITEM_TYPE_IPV4. */
757 static const struct rte_flow_item_ipv4 rte_flow_item_ipv4_mask = {
759 .src_addr = RTE_BE32(0xffffffff),
760 .dst_addr = RTE_BE32(0xffffffff),
766 * RTE_FLOW_ITEM_TYPE_IPV6.
768 * Matches an IPv6 header.
770 * Note: IPv6 options are handled by dedicated pattern items, see
771 * RTE_FLOW_ITEM_TYPE_IPV6_EXT.
773 struct rte_flow_item_ipv6 {
774 struct rte_ipv6_hdr hdr; /**< IPv6 header definition. */
777 /** Default mask for RTE_FLOW_ITEM_TYPE_IPV6. */
779 static const struct rte_flow_item_ipv6 rte_flow_item_ipv6_mask = {
782 "\xff\xff\xff\xff\xff\xff\xff\xff"
783 "\xff\xff\xff\xff\xff\xff\xff\xff",
785 "\xff\xff\xff\xff\xff\xff\xff\xff"
786 "\xff\xff\xff\xff\xff\xff\xff\xff",
792 * RTE_FLOW_ITEM_TYPE_ICMP.
794 * Matches an ICMP header.
796 struct rte_flow_item_icmp {
797 struct rte_icmp_hdr hdr; /**< ICMP header definition. */
800 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP. */
802 static const struct rte_flow_item_icmp rte_flow_item_icmp_mask = {
811 * RTE_FLOW_ITEM_TYPE_UDP.
813 * Matches a UDP header.
815 struct rte_flow_item_udp {
816 struct rte_udp_hdr hdr; /**< UDP header definition. */
819 /** Default mask for RTE_FLOW_ITEM_TYPE_UDP. */
821 static const struct rte_flow_item_udp rte_flow_item_udp_mask = {
823 .src_port = RTE_BE16(0xffff),
824 .dst_port = RTE_BE16(0xffff),
830 * RTE_FLOW_ITEM_TYPE_TCP.
832 * Matches a TCP header.
834 struct rte_flow_item_tcp {
835 struct rte_tcp_hdr hdr; /**< TCP header definition. */
838 /** Default mask for RTE_FLOW_ITEM_TYPE_TCP. */
840 static const struct rte_flow_item_tcp rte_flow_item_tcp_mask = {
842 .src_port = RTE_BE16(0xffff),
843 .dst_port = RTE_BE16(0xffff),
849 * RTE_FLOW_ITEM_TYPE_SCTP.
851 * Matches a SCTP header.
853 struct rte_flow_item_sctp {
854 struct rte_sctp_hdr hdr; /**< SCTP header definition. */
857 /** Default mask for RTE_FLOW_ITEM_TYPE_SCTP. */
859 static const struct rte_flow_item_sctp rte_flow_item_sctp_mask = {
861 .src_port = RTE_BE16(0xffff),
862 .dst_port = RTE_BE16(0xffff),
868 * RTE_FLOW_ITEM_TYPE_VXLAN.
870 * Matches a VXLAN header (RFC 7348).
872 struct rte_flow_item_vxlan {
873 uint8_t flags; /**< Normally 0x08 (I flag). */
874 uint8_t rsvd0[3]; /**< Reserved, normally 0x000000. */
875 uint8_t vni[3]; /**< VXLAN identifier. */
876 uint8_t rsvd1; /**< Reserved, normally 0x00. */
879 /** Default mask for RTE_FLOW_ITEM_TYPE_VXLAN. */
881 static const struct rte_flow_item_vxlan rte_flow_item_vxlan_mask = {
882 .vni = "\xff\xff\xff",
887 * RTE_FLOW_ITEM_TYPE_E_TAG.
889 * Matches a E-tag header.
891 * The corresponding standard outer EtherType (TPID) value is
892 * RTE_ETHER_TYPE_ETAG. It can be overridden by the preceding pattern item.
894 struct rte_flow_item_e_tag {
896 * E-Tag control information (E-TCI).
897 * E-PCP (3b), E-DEI (1b), ingress E-CID base (12b).
899 rte_be16_t epcp_edei_in_ecid_b;
900 /** Reserved (2b), GRP (2b), E-CID base (12b). */
901 rte_be16_t rsvd_grp_ecid_b;
902 uint8_t in_ecid_e; /**< Ingress E-CID ext. */
903 uint8_t ecid_e; /**< E-CID ext. */
904 rte_be16_t inner_type; /**< Inner EtherType or TPID. */
907 /** Default mask for RTE_FLOW_ITEM_TYPE_E_TAG. */
909 static const struct rte_flow_item_e_tag rte_flow_item_e_tag_mask = {
910 .rsvd_grp_ecid_b = RTE_BE16(0x3fff),
915 * RTE_FLOW_ITEM_TYPE_NVGRE.
917 * Matches a NVGRE header.
919 struct rte_flow_item_nvgre {
921 * Checksum (1b), undefined (1b), key bit (1b), sequence number (1b),
922 * reserved 0 (9b), version (3b).
924 * c_k_s_rsvd0_ver must have value 0x2000 according to RFC 7637.
926 rte_be16_t c_k_s_rsvd0_ver;
927 rte_be16_t protocol; /**< Protocol type (0x6558). */
928 uint8_t tni[3]; /**< Virtual subnet ID. */
929 uint8_t flow_id; /**< Flow ID. */
932 /** Default mask for RTE_FLOW_ITEM_TYPE_NVGRE. */
934 static const struct rte_flow_item_nvgre rte_flow_item_nvgre_mask = {
935 .tni = "\xff\xff\xff",
940 * RTE_FLOW_ITEM_TYPE_MPLS.
942 * Matches a MPLS header.
944 struct rte_flow_item_mpls {
946 * Label (20b), TC (3b), Bottom of Stack (1b).
948 uint8_t label_tc_s[3];
949 uint8_t ttl; /** Time-to-Live. */
952 /** Default mask for RTE_FLOW_ITEM_TYPE_MPLS. */
954 static const struct rte_flow_item_mpls rte_flow_item_mpls_mask = {
955 .label_tc_s = "\xff\xff\xf0",
960 * RTE_FLOW_ITEM_TYPE_GRE.
962 * Matches a GRE header.
964 struct rte_flow_item_gre {
966 * Checksum (1b), reserved 0 (12b), version (3b).
969 rte_be16_t c_rsvd0_ver;
970 rte_be16_t protocol; /**< Protocol type. */
973 /** Default mask for RTE_FLOW_ITEM_TYPE_GRE. */
975 static const struct rte_flow_item_gre rte_flow_item_gre_mask = {
976 .protocol = RTE_BE16(0xffff),
981 * RTE_FLOW_ITEM_TYPE_FUZZY
983 * Fuzzy pattern match, expect faster than default.
985 * This is for device that support fuzzy match option.
986 * Usually a fuzzy match is fast but the cost is accuracy.
987 * i.e. Signature Match only match pattern's hash value, but it is
988 * possible two different patterns have the same hash value.
990 * Matching accuracy level can be configure by threshold.
991 * Driver can divide the range of threshold and map to different
992 * accuracy levels that device support.
994 * Threshold 0 means perfect match (no fuzziness), while threshold
995 * 0xffffffff means fuzziest match.
997 struct rte_flow_item_fuzzy {
998 uint32_t thresh; /**< Accuracy threshold. */
1001 /** Default mask for RTE_FLOW_ITEM_TYPE_FUZZY. */
1003 static const struct rte_flow_item_fuzzy rte_flow_item_fuzzy_mask = {
1004 .thresh = 0xffffffff,
1009 * RTE_FLOW_ITEM_TYPE_GTP.
1011 * Matches a GTPv1 header.
1013 struct rte_flow_item_gtp {
1015 * Version (3b), protocol type (1b), reserved (1b),
1016 * Extension header flag (1b),
1017 * Sequence number flag (1b),
1018 * N-PDU number flag (1b).
1020 uint8_t v_pt_rsv_flags;
1021 uint8_t msg_type; /**< Message type. */
1022 rte_be16_t msg_len; /**< Message length. */
1023 rte_be32_t teid; /**< Tunnel endpoint identifier. */
1026 /** Default mask for RTE_FLOW_ITEM_TYPE_GTP. */
1028 static const struct rte_flow_item_gtp rte_flow_item_gtp_mask = {
1029 .teid = RTE_BE32(0xffffffff),
1034 * RTE_FLOW_ITEM_TYPE_ESP
1036 * Matches an ESP header.
1038 struct rte_flow_item_esp {
1039 struct rte_esp_hdr hdr; /**< ESP header definition. */
1042 /** Default mask for RTE_FLOW_ITEM_TYPE_ESP. */
1044 static const struct rte_flow_item_esp rte_flow_item_esp_mask = {
1046 .spi = RTE_BE32(0xffffffff),
1052 * RTE_FLOW_ITEM_TYPE_GENEVE.
1054 * Matches a GENEVE header.
1056 struct rte_flow_item_geneve {
1058 * Version (2b), length of the options fields (6b), OAM packet (1b),
1059 * critical options present (1b), reserved 0 (6b).
1061 rte_be16_t ver_opt_len_o_c_rsvd0;
1062 rte_be16_t protocol; /**< Protocol type. */
1063 uint8_t vni[3]; /**< Virtual Network Identifier. */
1064 uint8_t rsvd1; /**< Reserved, normally 0x00. */
1067 /** Default mask for RTE_FLOW_ITEM_TYPE_GENEVE. */
1069 static const struct rte_flow_item_geneve rte_flow_item_geneve_mask = {
1070 .vni = "\xff\xff\xff",
1075 * RTE_FLOW_ITEM_TYPE_VXLAN_GPE (draft-ietf-nvo3-vxlan-gpe-05).
1077 * Matches a VXLAN-GPE header.
1079 struct rte_flow_item_vxlan_gpe {
1080 uint8_t flags; /**< Normally 0x0c (I and P flags). */
1081 uint8_t rsvd0[2]; /**< Reserved, normally 0x0000. */
1082 uint8_t protocol; /**< Protocol type. */
1083 uint8_t vni[3]; /**< VXLAN identifier. */
1084 uint8_t rsvd1; /**< Reserved, normally 0x00. */
1087 /** Default mask for RTE_FLOW_ITEM_TYPE_VXLAN_GPE. */
1089 static const struct rte_flow_item_vxlan_gpe rte_flow_item_vxlan_gpe_mask = {
1090 .vni = "\xff\xff\xff",
1095 * RTE_FLOW_ITEM_TYPE_ARP_ETH_IPV4
1097 * Matches an ARP header for Ethernet/IPv4.
1099 struct rte_flow_item_arp_eth_ipv4 {
1100 rte_be16_t hrd; /**< Hardware type, normally 1. */
1101 rte_be16_t pro; /**< Protocol type, normally 0x0800. */
1102 uint8_t hln; /**< Hardware address length, normally 6. */
1103 uint8_t pln; /**< Protocol address length, normally 4. */
1104 rte_be16_t op; /**< Opcode (1 for request, 2 for reply). */
1105 struct rte_ether_addr sha; /**< Sender hardware address. */
1106 rte_be32_t spa; /**< Sender IPv4 address. */
1107 struct rte_ether_addr tha; /**< Target hardware address. */
1108 rte_be32_t tpa; /**< Target IPv4 address. */
1111 /** Default mask for RTE_FLOW_ITEM_TYPE_ARP_ETH_IPV4. */
1113 static const struct rte_flow_item_arp_eth_ipv4
1114 rte_flow_item_arp_eth_ipv4_mask = {
1115 .sha.addr_bytes = "\xff\xff\xff\xff\xff\xff",
1116 .spa = RTE_BE32(0xffffffff),
1117 .tha.addr_bytes = "\xff\xff\xff\xff\xff\xff",
1118 .tpa = RTE_BE32(0xffffffff),
1123 * RTE_FLOW_ITEM_TYPE_IPV6_EXT
1125 * Matches the presence of any IPv6 extension header.
1127 * Normally preceded by any of:
1129 * - RTE_FLOW_ITEM_TYPE_IPV6
1130 * - RTE_FLOW_ITEM_TYPE_IPV6_EXT
1132 struct rte_flow_item_ipv6_ext {
1133 uint8_t next_hdr; /**< Next header. */
1136 /** Default mask for RTE_FLOW_ITEM_TYPE_IPV6_EXT. */
1139 struct rte_flow_item_ipv6_ext rte_flow_item_ipv6_ext_mask = {
1145 * RTE_FLOW_ITEM_TYPE_ICMP6
1147 * Matches any ICMPv6 header.
1149 struct rte_flow_item_icmp6 {
1150 uint8_t type; /**< ICMPv6 type. */
1151 uint8_t code; /**< ICMPv6 code. */
1152 uint16_t checksum; /**< ICMPv6 checksum. */
1155 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6. */
1157 static const struct rte_flow_item_icmp6 rte_flow_item_icmp6_mask = {
1164 * RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS
1166 * Matches an ICMPv6 neighbor discovery solicitation.
1168 struct rte_flow_item_icmp6_nd_ns {
1169 uint8_t type; /**< ICMPv6 type, normally 135. */
1170 uint8_t code; /**< ICMPv6 code, normally 0. */
1171 rte_be16_t checksum; /**< ICMPv6 checksum. */
1172 rte_be32_t reserved; /**< Reserved, normally 0. */
1173 uint8_t target_addr[16]; /**< Target address. */
1176 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS. */
1179 struct rte_flow_item_icmp6_nd_ns rte_flow_item_icmp6_nd_ns_mask = {
1181 "\xff\xff\xff\xff\xff\xff\xff\xff"
1182 "\xff\xff\xff\xff\xff\xff\xff\xff",
1187 * RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA
1189 * Matches an ICMPv6 neighbor discovery advertisement.
1191 struct rte_flow_item_icmp6_nd_na {
1192 uint8_t type; /**< ICMPv6 type, normally 136. */
1193 uint8_t code; /**< ICMPv6 code, normally 0. */
1194 rte_be16_t checksum; /**< ICMPv6 checksum. */
1196 * Route flag (1b), solicited flag (1b), override flag (1b),
1199 rte_be32_t rso_reserved;
1200 uint8_t target_addr[16]; /**< Target address. */
1203 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA. */
1206 struct rte_flow_item_icmp6_nd_na rte_flow_item_icmp6_nd_na_mask = {
1208 "\xff\xff\xff\xff\xff\xff\xff\xff"
1209 "\xff\xff\xff\xff\xff\xff\xff\xff",
1214 * RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT
1216 * Matches the presence of any ICMPv6 neighbor discovery option.
1218 * Normally preceded by any of:
1220 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA
1221 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS
1222 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT
1224 struct rte_flow_item_icmp6_nd_opt {
1225 uint8_t type; /**< ND option type. */
1226 uint8_t length; /**< ND option length. */
1229 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT. */
1231 static const struct rte_flow_item_icmp6_nd_opt
1232 rte_flow_item_icmp6_nd_opt_mask = {
1238 * RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_SLA_ETH
1240 * Matches an ICMPv6 neighbor discovery source Ethernet link-layer address
1243 * Normally preceded by any of:
1245 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA
1246 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT
1248 struct rte_flow_item_icmp6_nd_opt_sla_eth {
1249 uint8_t type; /**< ND option type, normally 1. */
1250 uint8_t length; /**< ND option length, normally 1. */
1251 struct rte_ether_addr sla; /**< Source Ethernet LLA. */
1254 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_SLA_ETH. */
1256 static const struct rte_flow_item_icmp6_nd_opt_sla_eth
1257 rte_flow_item_icmp6_nd_opt_sla_eth_mask = {
1258 .sla.addr_bytes = "\xff\xff\xff\xff\xff\xff",
1263 * RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_TLA_ETH
1265 * Matches an ICMPv6 neighbor discovery target Ethernet link-layer address
1268 * Normally preceded by any of:
1270 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS
1271 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT
1273 struct rte_flow_item_icmp6_nd_opt_tla_eth {
1274 uint8_t type; /**< ND option type, normally 2. */
1275 uint8_t length; /**< ND option length, normally 1. */
1276 struct rte_ether_addr tla; /**< Target Ethernet LLA. */
1279 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_TLA_ETH. */
1281 static const struct rte_flow_item_icmp6_nd_opt_tla_eth
1282 rte_flow_item_icmp6_nd_opt_tla_eth_mask = {
1283 .tla.addr_bytes = "\xff\xff\xff\xff\xff\xff",
1288 * RTE_FLOW_ITEM_TYPE_META
1290 * Matches a specified metadata value. On egress, metadata can be set
1291 * either by mbuf dynamic metadata field with PKT_TX_DYNF_METADATA flag or
1292 * RTE_FLOW_ACTION_TYPE_SET_META. On ingress, RTE_FLOW_ACTION_TYPE_SET_META
1293 * sets metadata for a packet and the metadata will be reported via mbuf
1294 * metadata dynamic field with PKT_RX_DYNF_METADATA flag. The dynamic mbuf
1295 * field must be registered in advance by rte_flow_dynf_metadata_register().
1297 struct rte_flow_item_meta {
1301 /** Default mask for RTE_FLOW_ITEM_TYPE_META. */
1303 static const struct rte_flow_item_meta rte_flow_item_meta_mask = {
1309 * RTE_FLOW_ITEM_TYPE_GTP_PSC.
1311 * Matches a GTP PDU extension header with type 0x85.
1313 struct rte_flow_item_gtp_psc {
1314 uint8_t pdu_type; /**< PDU type. */
1315 uint8_t qfi; /**< QoS flow identifier. */
1318 /** Default mask for RTE_FLOW_ITEM_TYPE_GTP_PSC. */
1320 static const struct rte_flow_item_gtp_psc
1321 rte_flow_item_gtp_psc_mask = {
1327 * RTE_FLOW_ITEM_TYPE_PPPOE.
1329 * Matches a PPPoE header.
1331 struct rte_flow_item_pppoe {
1333 * Version (4b), type (4b).
1335 uint8_t version_type;
1336 uint8_t code; /**< Message type. */
1337 rte_be16_t session_id; /**< Session identifier. */
1338 rte_be16_t length; /**< Payload length. */
1342 * RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID.
1344 * Matches a PPPoE optional proto_id field.
1346 * It only applies to PPPoE session packets.
1348 * Normally preceded by any of:
1350 * - RTE_FLOW_ITEM_TYPE_PPPOE
1351 * - RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID
1353 struct rte_flow_item_pppoe_proto_id {
1354 rte_be16_t proto_id; /**< PPP protocol identifier. */
1357 /** Default mask for RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID. */
1359 static const struct rte_flow_item_pppoe_proto_id
1360 rte_flow_item_pppoe_proto_id_mask = {
1361 .proto_id = RTE_BE16(0xffff),
1367 * @b EXPERIMENTAL: this structure may change without prior notice
1369 * RTE_FLOW_ITEM_TYPE_TAG
1371 * Matches a specified tag value at the specified index.
1373 struct rte_flow_item_tag {
1378 /** Default mask for RTE_FLOW_ITEM_TYPE_TAG. */
1380 static const struct rte_flow_item_tag rte_flow_item_tag_mask = {
1387 * RTE_FLOW_ITEM_TYPE_L2TPV3OIP.
1389 * Matches a L2TPv3 over IP header.
1391 struct rte_flow_item_l2tpv3oip {
1392 rte_be32_t session_id; /**< Session ID. */
1395 /** Default mask for RTE_FLOW_ITEM_TYPE_L2TPV3OIP. */
1397 static const struct rte_flow_item_l2tpv3oip rte_flow_item_l2tpv3oip_mask = {
1398 .session_id = RTE_BE32(UINT32_MAX),
1405 * @b EXPERIMENTAL: this structure may change without prior notice
1407 * RTE_FLOW_ITEM_TYPE_MARK
1409 * Matches an arbitrary integer value which was set using the ``MARK`` action
1410 * in a previously matched rule.
1412 * This item can only be specified once as a match criteria as the ``MARK``
1413 * action can only be specified once in a flow action.
1415 * This value is arbitrary and application-defined. Maximum allowed value
1416 * depends on the underlying implementation.
1418 * Depending on the underlying implementation the MARK item may be supported on
1419 * the physical device, with virtual groups in the PMD or not at all.
1421 struct rte_flow_item_mark {
1422 uint32_t id; /**< Integer value to match against. */
1425 /** Default mask for RTE_FLOW_ITEM_TYPE_MARK. */
1427 static const struct rte_flow_item_mark rte_flow_item_mark_mask = {
1434 * @b EXPERIMENTAL: this structure may change without prior notice
1436 * RTE_FLOW_ITEM_TYPE_NSH
1438 * Match network service header (NSH), RFC 8300
1441 struct rte_flow_item_nsh {
1444 uint32_t reserved:1;
1447 uint32_t reserved1:4;
1449 uint32_t next_proto:8;
1454 /** Default mask for RTE_FLOW_ITEM_TYPE_NSH. */
1456 static const struct rte_flow_item_nsh rte_flow_item_nsh_mask = {
1466 * @b EXPERIMENTAL: this structure may change without prior notice
1468 * RTE_FLOW_ITEM_TYPE_IGMP
1470 * Match Internet Group Management Protocol (IGMP), RFC 2236
1473 struct rte_flow_item_igmp {
1475 uint32_t max_resp_time:8;
1476 uint32_t checksum:16;
1477 uint32_t group_addr;
1480 /** Default mask for RTE_FLOW_ITEM_TYPE_IGMP. */
1482 static const struct rte_flow_item_igmp rte_flow_item_igmp_mask = {
1483 .group_addr = 0xffffffff,
1489 * @b EXPERIMENTAL: this structure may change without prior notice
1491 * RTE_FLOW_ITEM_TYPE_AH
1493 * Match IP Authentication Header (AH), RFC 4302
1496 struct rte_flow_item_ah {
1497 uint32_t next_hdr:8;
1498 uint32_t payload_len:8;
1499 uint32_t reserved:16;
1504 /** Default mask for RTE_FLOW_ITEM_TYPE_AH. */
1506 static const struct rte_flow_item_ah rte_flow_item_ah_mask = {
1512 * Matching pattern item definition.
1514 * A pattern is formed by stacking items starting from the lowest protocol
1515 * layer to match. This stacking restriction does not apply to meta items
1516 * which can be placed anywhere in the stack without affecting the meaning
1517 * of the resulting pattern.
1519 * Patterns are terminated by END items.
1521 * The spec field should be a valid pointer to a structure of the related
1522 * item type. It may remain unspecified (NULL) in many cases to request
1523 * broad (nonspecific) matching. In such cases, last and mask must also be
1526 * Optionally, last can point to a structure of the same type to define an
1527 * inclusive range. This is mostly supported by integer and address fields,
1528 * may cause errors otherwise. Fields that do not support ranges must be set
1529 * to 0 or to the same value as the corresponding fields in spec.
1531 * Only the fields defined to nonzero values in the default masks (see
1532 * rte_flow_item_{name}_mask constants) are considered relevant by
1533 * default. This can be overridden by providing a mask structure of the
1534 * same type with applicable bits set to one. It can also be used to
1535 * partially filter out specific fields (e.g. as an alternate mean to match
1536 * ranges of IP addresses).
1538 * Mask is a simple bit-mask applied before interpreting the contents of
1539 * spec and last, which may yield unexpected results if not used
1540 * carefully. For example, if for an IPv4 address field, spec provides
1541 * 10.1.2.3, last provides 10.3.4.5 and mask provides 255.255.0.0, the
1542 * effective range becomes 10.1.0.0 to 10.3.255.255.
1544 struct rte_flow_item {
1545 enum rte_flow_item_type type; /**< Item type. */
1546 const void *spec; /**< Pointer to item specification structure. */
1547 const void *last; /**< Defines an inclusive range (spec to last). */
1548 const void *mask; /**< Bit-mask applied to spec and last. */
1554 * Each possible action is represented by a type.
1555 * An action can have an associated configuration object.
1556 * Several actions combined in a list can be assigned
1557 * to a flow rule and are performed in order.
1559 * They fall in three categories:
1561 * - Actions that modify the fate of matching traffic, for instance by
1562 * dropping or assigning it a specific destination.
1564 * - Actions that modify matching traffic contents or its properties. This
1565 * includes adding/removing encapsulation, encryption, compression and
1568 * - Actions related to the flow rule itself, such as updating counters or
1569 * making it non-terminating.
1571 * Flow rules being terminating by default, not specifying any action of the
1572 * fate kind results in undefined behavior. This applies to both ingress and
1575 * PASSTHRU, when supported, makes a flow rule non-terminating.
1577 enum rte_flow_action_type {
1579 * End marker for action lists. Prevents further processing of
1580 * actions, thereby ending the list.
1582 * No associated configuration structure.
1584 RTE_FLOW_ACTION_TYPE_END,
1587 * Used as a placeholder for convenience. It is ignored and simply
1588 * discarded by PMDs.
1590 * No associated configuration structure.
1592 RTE_FLOW_ACTION_TYPE_VOID,
1595 * Leaves traffic up for additional processing by subsequent flow
1596 * rules; makes a flow rule non-terminating.
1598 * No associated configuration structure.
1600 RTE_FLOW_ACTION_TYPE_PASSTHRU,
1603 * RTE_FLOW_ACTION_TYPE_JUMP
1605 * Redirects packets to a group on the current device.
1607 * See struct rte_flow_action_jump.
1609 RTE_FLOW_ACTION_TYPE_JUMP,
1612 * Attaches an integer value to packets and sets PKT_RX_FDIR and
1613 * PKT_RX_FDIR_ID mbuf flags.
1615 * See struct rte_flow_action_mark.
1617 RTE_FLOW_ACTION_TYPE_MARK,
1620 * Flags packets. Similar to MARK without a specific value; only
1621 * sets the PKT_RX_FDIR mbuf flag.
1623 * No associated configuration structure.
1625 RTE_FLOW_ACTION_TYPE_FLAG,
1628 * Assigns packets to a given queue index.
1630 * See struct rte_flow_action_queue.
1632 RTE_FLOW_ACTION_TYPE_QUEUE,
1637 * PASSTHRU overrides this action if both are specified.
1639 * No associated configuration structure.
1641 RTE_FLOW_ACTION_TYPE_DROP,
1644 * Enables counters for this flow rule.
1646 * These counters can be retrieved and reset through rte_flow_query(),
1647 * see struct rte_flow_query_count.
1649 * See struct rte_flow_action_count.
1651 RTE_FLOW_ACTION_TYPE_COUNT,
1654 * Similar to QUEUE, except RSS is additionally performed on packets
1655 * to spread them among several queues according to the provided
1658 * See struct rte_flow_action_rss.
1660 RTE_FLOW_ACTION_TYPE_RSS,
1663 * Directs matching traffic to the physical function (PF) of the
1666 * No associated configuration structure.
1668 RTE_FLOW_ACTION_TYPE_PF,
1671 * Directs matching traffic to a given virtual function of the
1674 * See struct rte_flow_action_vf.
1676 RTE_FLOW_ACTION_TYPE_VF,
1679 * Directs packets to a given physical port index of the underlying
1682 * See struct rte_flow_action_phy_port.
1684 RTE_FLOW_ACTION_TYPE_PHY_PORT,
1687 * Directs matching traffic to a given DPDK port ID.
1689 * See struct rte_flow_action_port_id.
1691 RTE_FLOW_ACTION_TYPE_PORT_ID,
1694 * Traffic metering and policing (MTR).
1696 * See struct rte_flow_action_meter.
1697 * See file rte_mtr.h for MTR object configuration.
1699 RTE_FLOW_ACTION_TYPE_METER,
1702 * Redirects packets to security engine of current device for security
1703 * processing as specified by security session.
1705 * See struct rte_flow_action_security.
1707 RTE_FLOW_ACTION_TYPE_SECURITY,
1710 * Implements OFPAT_SET_MPLS_TTL ("MPLS TTL") as defined by the
1711 * OpenFlow Switch Specification.
1713 * See struct rte_flow_action_of_set_mpls_ttl.
1715 RTE_FLOW_ACTION_TYPE_OF_SET_MPLS_TTL,
1718 * Implements OFPAT_DEC_MPLS_TTL ("decrement MPLS TTL") as defined
1719 * by the OpenFlow Switch Specification.
1721 * No associated configuration structure.
1723 RTE_FLOW_ACTION_TYPE_OF_DEC_MPLS_TTL,
1726 * Implements OFPAT_SET_NW_TTL ("IP TTL") as defined by the OpenFlow
1727 * Switch Specification.
1729 * See struct rte_flow_action_of_set_nw_ttl.
1731 RTE_FLOW_ACTION_TYPE_OF_SET_NW_TTL,
1734 * Implements OFPAT_DEC_NW_TTL ("decrement IP TTL") as defined by
1735 * the OpenFlow Switch Specification.
1737 * No associated configuration structure.
1739 RTE_FLOW_ACTION_TYPE_OF_DEC_NW_TTL,
1742 * Implements OFPAT_COPY_TTL_OUT ("copy TTL "outwards" -- from
1743 * next-to-outermost to outermost") as defined by the OpenFlow
1744 * Switch Specification.
1746 * No associated configuration structure.
1748 RTE_FLOW_ACTION_TYPE_OF_COPY_TTL_OUT,
1751 * Implements OFPAT_COPY_TTL_IN ("copy TTL "inwards" -- from
1752 * outermost to next-to-outermost") as defined by the OpenFlow
1753 * Switch Specification.
1755 * No associated configuration structure.
1757 RTE_FLOW_ACTION_TYPE_OF_COPY_TTL_IN,
1760 * Implements OFPAT_POP_VLAN ("pop the outer VLAN tag") as defined
1761 * by the OpenFlow Switch Specification.
1763 * No associated configuration structure.
1765 RTE_FLOW_ACTION_TYPE_OF_POP_VLAN,
1768 * Implements OFPAT_PUSH_VLAN ("push a new VLAN tag") as defined by
1769 * the OpenFlow Switch Specification.
1771 * See struct rte_flow_action_of_push_vlan.
1773 RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN,
1776 * Implements OFPAT_SET_VLAN_VID ("set the 802.1q VLAN id") as
1777 * defined by the OpenFlow Switch Specification.
1779 * See struct rte_flow_action_of_set_vlan_vid.
1781 RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID,
1784 * Implements OFPAT_SET_LAN_PCP ("set the 802.1q priority") as
1785 * defined by the OpenFlow Switch Specification.
1787 * See struct rte_flow_action_of_set_vlan_pcp.
1789 RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP,
1792 * Implements OFPAT_POP_MPLS ("pop the outer MPLS tag") as defined
1793 * by the OpenFlow Switch Specification.
1795 * See struct rte_flow_action_of_pop_mpls.
1797 RTE_FLOW_ACTION_TYPE_OF_POP_MPLS,
1800 * Implements OFPAT_PUSH_MPLS ("push a new MPLS tag") as defined by
1801 * the OpenFlow Switch Specification.
1803 * See struct rte_flow_action_of_push_mpls.
1805 RTE_FLOW_ACTION_TYPE_OF_PUSH_MPLS,
1808 * Encapsulate flow in VXLAN tunnel as defined in
1809 * rte_flow_action_vxlan_encap action structure.
1811 * See struct rte_flow_action_vxlan_encap.
1813 RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP,
1816 * Decapsulate outer most VXLAN tunnel from matched flow.
1818 * If flow pattern does not define a valid VXLAN tunnel (as specified by
1819 * RFC7348) then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION
1822 RTE_FLOW_ACTION_TYPE_VXLAN_DECAP,
1825 * Encapsulate flow in NVGRE tunnel defined in the
1826 * rte_flow_action_nvgre_encap action structure.
1828 * See struct rte_flow_action_nvgre_encap.
1830 RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP,
1833 * Decapsulate outer most NVGRE tunnel from matched flow.
1835 * If flow pattern does not define a valid NVGRE tunnel (as specified by
1836 * RFC7637) then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION
1839 RTE_FLOW_ACTION_TYPE_NVGRE_DECAP,
1842 * Add outer header whose template is provided in its data buffer
1844 * See struct rte_flow_action_raw_encap.
1846 RTE_FLOW_ACTION_TYPE_RAW_ENCAP,
1849 * Remove outer header whose template is provided in its data buffer.
1851 * See struct rte_flow_action_raw_decap
1853 RTE_FLOW_ACTION_TYPE_RAW_DECAP,
1856 * Modify IPv4 source address in the outermost IPv4 header.
1858 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV4,
1859 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
1861 * See struct rte_flow_action_set_ipv4.
1863 RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC,
1866 * Modify IPv4 destination address in the outermost IPv4 header.
1868 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV4,
1869 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
1871 * See struct rte_flow_action_set_ipv4.
1873 RTE_FLOW_ACTION_TYPE_SET_IPV4_DST,
1876 * Modify IPv6 source address in the outermost IPv6 header.
1878 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV6,
1879 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
1881 * See struct rte_flow_action_set_ipv6.
1883 RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC,
1886 * Modify IPv6 destination address in the outermost IPv6 header.
1888 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV6,
1889 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
1891 * See struct rte_flow_action_set_ipv6.
1893 RTE_FLOW_ACTION_TYPE_SET_IPV6_DST,
1896 * Modify source port number in the outermost TCP/UDP header.
1898 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_TCP
1899 * or RTE_FLOW_ITEM_TYPE_UDP, then the PMD should return a
1900 * RTE_FLOW_ERROR_TYPE_ACTION error.
1902 * See struct rte_flow_action_set_tp.
1904 RTE_FLOW_ACTION_TYPE_SET_TP_SRC,
1907 * Modify destination port number in the outermost TCP/UDP header.
1909 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_TCP
1910 * or RTE_FLOW_ITEM_TYPE_UDP, then the PMD should return a
1911 * RTE_FLOW_ERROR_TYPE_ACTION error.
1913 * See struct rte_flow_action_set_tp.
1915 RTE_FLOW_ACTION_TYPE_SET_TP_DST,
1918 * Swap the source and destination MAC addresses in the outermost
1921 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_ETH,
1922 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
1924 * No associated configuration structure.
1926 RTE_FLOW_ACTION_TYPE_MAC_SWAP,
1929 * Decrease TTL value directly
1931 * No associated configuration structure.
1933 RTE_FLOW_ACTION_TYPE_DEC_TTL,
1938 * See struct rte_flow_action_set_ttl
1940 RTE_FLOW_ACTION_TYPE_SET_TTL,
1943 * Set source MAC address from matched flow.
1945 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_ETH,
1946 * the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
1948 * See struct rte_flow_action_set_mac.
1950 RTE_FLOW_ACTION_TYPE_SET_MAC_SRC,
1953 * Set destination MAC address from matched flow.
1955 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_ETH,
1956 * the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
1958 * See struct rte_flow_action_set_mac.
1960 RTE_FLOW_ACTION_TYPE_SET_MAC_DST,
1963 * Increase sequence number in the outermost TCP header.
1965 * Action configuration specifies the value to increase
1966 * TCP sequence number as a big-endian 32 bit integer.
1969 * @code rte_be32_t * @endcode
1971 * Using this action on non-matching traffic will result in
1972 * undefined behavior.
1974 RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ,
1977 * Decrease sequence number in the outermost TCP header.
1979 * Action configuration specifies the value to decrease
1980 * TCP sequence number as a big-endian 32 bit integer.
1983 * @code rte_be32_t * @endcode
1985 * Using this action on non-matching traffic will result in
1986 * undefined behavior.
1988 RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ,
1991 * Increase acknowledgment number in the outermost TCP header.
1993 * Action configuration specifies the value to increase
1994 * TCP acknowledgment number as a big-endian 32 bit integer.
1997 * @code rte_be32_t * @endcode
1999 * Using this action on non-matching traffic will result in
2000 * undefined behavior.
2002 RTE_FLOW_ACTION_TYPE_INC_TCP_ACK,
2005 * Decrease acknowledgment number in the outermost TCP header.
2007 * Action configuration specifies the value to decrease
2008 * TCP acknowledgment number as a big-endian 32 bit integer.
2011 * @code rte_be32_t * @endcode
2013 * Using this action on non-matching traffic will result in
2014 * undefined behavior.
2016 RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK,
2021 * Tag is for internal flow usage only and
2022 * is not delivered to the application.
2024 * See struct rte_flow_action_set_tag.
2026 RTE_FLOW_ACTION_TYPE_SET_TAG,
2029 * Set metadata on ingress or egress path.
2031 * See struct rte_flow_action_set_meta.
2033 RTE_FLOW_ACTION_TYPE_SET_META,
2036 * Modify IPv4 DSCP in the outermost IP header.
2038 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV4,
2039 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2041 * See struct rte_flow_action_set_dscp.
2043 RTE_FLOW_ACTION_TYPE_SET_IPV4_DSCP,
2046 * Modify IPv6 DSCP in the outermost IP header.
2048 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV6,
2049 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2051 * See struct rte_flow_action_set_dscp.
2053 RTE_FLOW_ACTION_TYPE_SET_IPV6_DSCP,
2057 * RTE_FLOW_ACTION_TYPE_MARK
2059 * Attaches an integer value to packets and sets PKT_RX_FDIR and
2060 * PKT_RX_FDIR_ID mbuf flags.
2062 * This value is arbitrary and application-defined. Maximum allowed value
2063 * depends on the underlying implementation. It is returned in the
2064 * hash.fdir.hi mbuf field.
2066 struct rte_flow_action_mark {
2067 uint32_t id; /**< Integer value to return with packets. */
2072 * @b EXPERIMENTAL: this structure may change without prior notice
2074 * RTE_FLOW_ACTION_TYPE_JUMP
2076 * Redirects packets to a group on the current device.
2078 * In a hierarchy of groups, which can be used to represent physical or logical
2079 * flow tables on the device, this action allows the action to be a redirect to
2080 * a group on that device.
2082 struct rte_flow_action_jump {
2087 * RTE_FLOW_ACTION_TYPE_QUEUE
2089 * Assign packets to a given queue index.
2091 struct rte_flow_action_queue {
2092 uint16_t index; /**< Queue index to use. */
2098 * @b EXPERIMENTAL: this structure may change without prior notice
2100 * RTE_FLOW_ACTION_TYPE_COUNT
2102 * Adds a counter action to a matched flow.
2104 * If more than one count action is specified in a single flow rule, then each
2105 * action must specify a unique id.
2107 * Counters can be retrieved and reset through ``rte_flow_query()``, see
2108 * ``struct rte_flow_query_count``.
2110 * The shared flag indicates whether the counter is unique to the flow rule the
2111 * action is specified with, or whether it is a shared counter.
2113 * For a count action with the shared flag set, then then a global device
2114 * namespace is assumed for the counter id, so that any matched flow rules using
2115 * a count action with the same counter id on the same port will contribute to
2118 * For ports within the same switch domain then the counter id namespace extends
2119 * to all ports within that switch domain.
2121 struct rte_flow_action_count {
2122 uint32_t shared:1; /**< Share counter ID with other flow rules. */
2123 uint32_t reserved:31; /**< Reserved, must be zero. */
2124 uint32_t id; /**< Counter ID. */
2128 * RTE_FLOW_ACTION_TYPE_COUNT (query)
2130 * Query structure to retrieve and reset flow rule counters.
2132 struct rte_flow_query_count {
2133 uint32_t reset:1; /**< Reset counters after query [in]. */
2134 uint32_t hits_set:1; /**< hits field is set [out]. */
2135 uint32_t bytes_set:1; /**< bytes field is set [out]. */
2136 uint32_t reserved:29; /**< Reserved, must be zero [in, out]. */
2137 uint64_t hits; /**< Number of hits for this rule [out]. */
2138 uint64_t bytes; /**< Number of bytes through this rule [out]. */
2142 * Hash function types.
2144 enum rte_eth_hash_function {
2145 RTE_ETH_HASH_FUNCTION_DEFAULT = 0,
2146 RTE_ETH_HASH_FUNCTION_TOEPLITZ, /**< Toeplitz */
2147 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR, /**< Simple XOR */
2149 * Symmetric Toeplitz: src, dst will be replaced by
2150 * xor(src, dst). For the case with src/dst only,
2151 * src or dst address will xor with zero pair.
2153 RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ,
2154 RTE_ETH_HASH_FUNCTION_MAX,
2158 * RTE_FLOW_ACTION_TYPE_RSS
2160 * Similar to QUEUE, except RSS is additionally performed on packets to
2161 * spread them among several queues according to the provided parameters.
2163 * Unlike global RSS settings used by other DPDK APIs, unsetting the
2164 * @p types field does not disable RSS in a flow rule. Doing so instead
2165 * requests safe unspecified "best-effort" settings from the underlying PMD,
2166 * which depending on the flow rule, may result in anything ranging from
2167 * empty (single queue) to all-inclusive RSS.
2169 * Note: RSS hash result is stored in the hash.rss mbuf field which overlaps
2170 * hash.fdir.lo. Since the MARK action sets the hash.fdir.hi field only,
2171 * both can be requested simultaneously.
2173 struct rte_flow_action_rss {
2174 enum rte_eth_hash_function func; /**< RSS hash function to apply. */
2176 * Packet encapsulation level RSS hash @p types apply to.
2178 * - @p 0 requests the default behavior. Depending on the packet
2179 * type, it can mean outermost, innermost, anything in between or
2182 * It basically stands for the innermost encapsulation level RSS
2183 * can be performed on according to PMD and device capabilities.
2185 * - @p 1 requests RSS to be performed on the outermost packet
2186 * encapsulation level.
2188 * - @p 2 and subsequent values request RSS to be performed on the
2189 * specified inner packet encapsulation level, from outermost to
2190 * innermost (lower to higher values).
2192 * Values other than @p 0 are not necessarily supported.
2194 * Requesting a specific RSS level on unrecognized traffic results
2195 * in undefined behavior. For predictable results, it is recommended
2196 * to make the flow rule pattern match packet headers up to the
2197 * requested encapsulation level so that only matching traffic goes
2201 uint64_t types; /**< Specific RSS hash types (see ETH_RSS_*). */
2202 uint32_t key_len; /**< Hash key length in bytes. */
2203 uint32_t queue_num; /**< Number of entries in @p queue. */
2204 const uint8_t *key; /**< Hash key. */
2205 const uint16_t *queue; /**< Queue indices to use. */
2209 * RTE_FLOW_ACTION_TYPE_VF
2211 * Directs matching traffic to a given virtual function of the current
2214 * Packets matched by a VF pattern item can be redirected to their original
2215 * VF ID instead of the specified one. This parameter may not be available
2216 * and is not guaranteed to work properly if the VF part is matched by a
2217 * prior flow rule or if packets are not addressed to a VF in the first
2220 struct rte_flow_action_vf {
2221 uint32_t original:1; /**< Use original VF ID if possible. */
2222 uint32_t reserved:31; /**< Reserved, must be zero. */
2223 uint32_t id; /**< VF ID. */
2227 * RTE_FLOW_ACTION_TYPE_PHY_PORT
2229 * Directs packets to a given physical port index of the underlying
2232 * @see RTE_FLOW_ITEM_TYPE_PHY_PORT
2234 struct rte_flow_action_phy_port {
2235 uint32_t original:1; /**< Use original port index if possible. */
2236 uint32_t reserved:31; /**< Reserved, must be zero. */
2237 uint32_t index; /**< Physical port index. */
2241 * RTE_FLOW_ACTION_TYPE_PORT_ID
2243 * Directs matching traffic to a given DPDK port ID.
2245 * @see RTE_FLOW_ITEM_TYPE_PORT_ID
2247 struct rte_flow_action_port_id {
2248 uint32_t original:1; /**< Use original DPDK port ID if possible. */
2249 uint32_t reserved:31; /**< Reserved, must be zero. */
2250 uint32_t id; /**< DPDK port ID. */
2254 * RTE_FLOW_ACTION_TYPE_METER
2256 * Traffic metering and policing (MTR).
2258 * Packets matched by items of this type can be either dropped or passed to the
2259 * next item with their color set by the MTR object.
2261 struct rte_flow_action_meter {
2262 uint32_t mtr_id; /**< MTR object ID created with rte_mtr_create(). */
2266 * RTE_FLOW_ACTION_TYPE_SECURITY
2268 * Perform the security action on flows matched by the pattern items
2269 * according to the configuration of the security session.
2271 * This action modifies the payload of matched flows. For INLINE_CRYPTO, the
2272 * security protocol headers and IV are fully provided by the application as
2273 * specified in the flow pattern. The payload of matching packets is
2274 * encrypted on egress, and decrypted and authenticated on ingress.
2275 * For INLINE_PROTOCOL, the security protocol is fully offloaded to HW,
2276 * providing full encapsulation and decapsulation of packets in security
2277 * protocols. The flow pattern specifies both the outer security header fields
2278 * and the inner packet fields. The security session specified in the action
2279 * must match the pattern parameters.
2281 * The security session specified in the action must be created on the same
2282 * port as the flow action that is being specified.
2284 * The ingress/egress flow attribute should match that specified in the
2285 * security session if the security session supports the definition of the
2288 * Multiple flows can be configured to use the same security session.
2290 struct rte_flow_action_security {
2291 void *security_session; /**< Pointer to security session structure. */
2295 * RTE_FLOW_ACTION_TYPE_OF_SET_MPLS_TTL
2297 * Implements OFPAT_SET_MPLS_TTL ("MPLS TTL") as defined by the OpenFlow
2298 * Switch Specification.
2300 struct rte_flow_action_of_set_mpls_ttl {
2301 uint8_t mpls_ttl; /**< MPLS TTL. */
2305 * RTE_FLOW_ACTION_TYPE_OF_SET_NW_TTL
2307 * Implements OFPAT_SET_NW_TTL ("IP TTL") as defined by the OpenFlow Switch
2310 struct rte_flow_action_of_set_nw_ttl {
2311 uint8_t nw_ttl; /**< IP TTL. */
2315 * RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN
2317 * Implements OFPAT_PUSH_VLAN ("push a new VLAN tag") as defined by the
2318 * OpenFlow Switch Specification.
2320 struct rte_flow_action_of_push_vlan {
2321 rte_be16_t ethertype; /**< EtherType. */
2325 * RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID
2327 * Implements OFPAT_SET_VLAN_VID ("set the 802.1q VLAN id") as defined by
2328 * the OpenFlow Switch Specification.
2330 struct rte_flow_action_of_set_vlan_vid {
2331 rte_be16_t vlan_vid; /**< VLAN id. */
2335 * RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP
2337 * Implements OFPAT_SET_LAN_PCP ("set the 802.1q priority") as defined by
2338 * the OpenFlow Switch Specification.
2340 struct rte_flow_action_of_set_vlan_pcp {
2341 uint8_t vlan_pcp; /**< VLAN priority. */
2345 * RTE_FLOW_ACTION_TYPE_OF_POP_MPLS
2347 * Implements OFPAT_POP_MPLS ("pop the outer MPLS tag") as defined by the
2348 * OpenFlow Switch Specification.
2350 struct rte_flow_action_of_pop_mpls {
2351 rte_be16_t ethertype; /**< EtherType. */
2355 * RTE_FLOW_ACTION_TYPE_OF_PUSH_MPLS
2357 * Implements OFPAT_PUSH_MPLS ("push a new MPLS tag") as defined by the
2358 * OpenFlow Switch Specification.
2360 struct rte_flow_action_of_push_mpls {
2361 rte_be16_t ethertype; /**< EtherType. */
2366 * @b EXPERIMENTAL: this structure may change without prior notice
2368 * RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP
2370 * VXLAN tunnel end-point encapsulation data definition
2372 * The tunnel definition is provided through the flow item pattern, the
2373 * provided pattern must conform to RFC7348 for the tunnel specified. The flow
2374 * definition must be provided in order from the RTE_FLOW_ITEM_TYPE_ETH
2375 * definition up the end item which is specified by RTE_FLOW_ITEM_TYPE_END.
2377 * The mask field allows user to specify which fields in the flow item
2378 * definitions can be ignored and which have valid data and can be used
2381 * Note: the last field is not used in the definition of a tunnel and can be
2384 * Valid flow definition for RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP include:
2386 * - ETH / IPV4 / UDP / VXLAN / END
2387 * - ETH / IPV6 / UDP / VXLAN / END
2388 * - ETH / VLAN / IPV4 / UDP / VXLAN / END
2391 struct rte_flow_action_vxlan_encap {
2393 * Encapsulating vxlan tunnel definition
2394 * (terminated by the END pattern item).
2396 struct rte_flow_item *definition;
2401 * @b EXPERIMENTAL: this structure may change without prior notice
2403 * RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP
2405 * NVGRE tunnel end-point encapsulation data definition
2407 * The tunnel definition is provided through the flow item pattern the
2408 * provided pattern must conform with RFC7637. The flow definition must be
2409 * provided in order from the RTE_FLOW_ITEM_TYPE_ETH definition up the end item
2410 * which is specified by RTE_FLOW_ITEM_TYPE_END.
2412 * The mask field allows user to specify which fields in the flow item
2413 * definitions can be ignored and which have valid data and can be used
2416 * Note: the last field is not used in the definition of a tunnel and can be
2419 * Valid flow definition for RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP include:
2421 * - ETH / IPV4 / NVGRE / END
2422 * - ETH / VLAN / IPV6 / NVGRE / END
2425 struct rte_flow_action_nvgre_encap {
2427 * Encapsulating vxlan tunnel definition
2428 * (terminated by the END pattern item).
2430 struct rte_flow_item *definition;
2435 * @b EXPERIMENTAL: this structure may change without prior notice
2437 * RTE_FLOW_ACTION_TYPE_RAW_ENCAP
2439 * Raw tunnel end-point encapsulation data definition.
2441 * The data holds the headers definitions to be applied on the packet.
2442 * The data must start with ETH header up to the tunnel item header itself.
2443 * When used right after RAW_DECAP (for decapsulating L3 tunnel type for
2444 * example MPLSoGRE) the data will just hold layer 2 header.
2446 * The preserve parameter holds which bits in the packet the PMD is not allowed
2447 * to change, this parameter can also be NULL and then the PMD is allowed
2448 * to update any field.
2450 * size holds the number of bytes in @p data and @p preserve.
2452 struct rte_flow_action_raw_encap {
2453 uint8_t *data; /**< Encapsulation data. */
2454 uint8_t *preserve; /**< Bit-mask of @p data to preserve on output. */
2455 size_t size; /**< Size of @p data and @p preserve. */
2460 * @b EXPERIMENTAL: this structure may change without prior notice
2462 * RTE_FLOW_ACTION_TYPE_RAW_DECAP
2464 * Raw tunnel end-point decapsulation data definition.
2466 * The data holds the headers definitions to be removed from the packet.
2467 * The data must start with ETH header up to the tunnel item header itself.
2468 * When used right before RAW_DECAP (for encapsulating L3 tunnel type for
2469 * example MPLSoGRE) the data will just hold layer 2 header.
2471 * size holds the number of bytes in @p data.
2473 struct rte_flow_action_raw_decap {
2474 uint8_t *data; /**< Encapsulation data. */
2475 size_t size; /**< Size of @p data and @p preserve. */
2480 * @b EXPERIMENTAL: this structure may change without prior notice
2482 * RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC
2483 * RTE_FLOW_ACTION_TYPE_SET_IPV4_DST
2485 * Allows modification of IPv4 source (RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC)
2486 * and destination address (RTE_FLOW_ACTION_TYPE_SET_IPV4_DST) in the
2487 * specified outermost IPv4 header.
2489 struct rte_flow_action_set_ipv4 {
2490 rte_be32_t ipv4_addr;
2495 * @b EXPERIMENTAL: this structure may change without prior notice
2497 * RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC
2498 * RTE_FLOW_ACTION_TYPE_SET_IPV6_DST
2500 * Allows modification of IPv6 source (RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC)
2501 * and destination address (RTE_FLOW_ACTION_TYPE_SET_IPV6_DST) in the
2502 * specified outermost IPv6 header.
2504 struct rte_flow_action_set_ipv6 {
2505 uint8_t ipv6_addr[16];
2510 * @b EXPERIMENTAL: this structure may change without prior notice
2512 * RTE_FLOW_ACTION_TYPE_SET_TP_SRC
2513 * RTE_FLOW_ACTION_TYPE_SET_TP_DST
2515 * Allows modification of source (RTE_FLOW_ACTION_TYPE_SET_TP_SRC)
2516 * and destination (RTE_FLOW_ACTION_TYPE_SET_TP_DST) port numbers
2517 * in the specified outermost TCP/UDP header.
2519 struct rte_flow_action_set_tp {
2524 * RTE_FLOW_ACTION_TYPE_SET_TTL
2526 * Set the TTL value directly for IPv4 or IPv6
2528 struct rte_flow_action_set_ttl {
2533 * RTE_FLOW_ACTION_TYPE_SET_MAC
2535 * Set MAC address from the matched flow
2537 struct rte_flow_action_set_mac {
2538 uint8_t mac_addr[RTE_ETHER_ADDR_LEN];
2543 * @b EXPERIMENTAL: this structure may change without prior notice
2545 * RTE_FLOW_ACTION_TYPE_SET_TAG
2547 * Set a tag which is a transient data used during flow matching. This is not
2548 * delivered to application. Multiple tags are supported by specifying index.
2550 struct rte_flow_action_set_tag {
2558 * @b EXPERIMENTAL: this structure may change without prior notice
2560 * RTE_FLOW_ACTION_TYPE_SET_META
2562 * Set metadata. Metadata set by mbuf metadata dynamic field with
2563 * PKT_TX_DYNF_DATA flag on egress will be overridden by this action. On
2564 * ingress, the metadata will be carried by mbuf metadata dynamic field
2565 * with PKT_RX_DYNF_METADATA flag if set. The dynamic mbuf field must be
2566 * registered in advance by rte_flow_dynf_metadata_register().
2568 * Altering partial bits is supported with mask. For bits which have never
2569 * been set, unpredictable value will be seen depending on driver
2570 * implementation. For loopback/hairpin packet, metadata set on Rx/Tx may
2571 * or may not be propagated to the other path depending on HW capability.
2573 * RTE_FLOW_ITEM_TYPE_META matches metadata.
2575 struct rte_flow_action_set_meta {
2581 * RTE_FLOW_ACTION_TYPE_SET_IPV4_DSCP
2582 * RTE_FLOW_ACTION_TYPE_SET_IPV6_DSCP
2584 * Set the DSCP value for IPv4/IPv6 header.
2585 * DSCP in low 6 bits, rest ignored.
2587 struct rte_flow_action_set_dscp {
2591 /* Mbuf dynamic field offset for metadata. */
2592 extern int rte_flow_dynf_metadata_offs;
2594 /* Mbuf dynamic field flag mask for metadata. */
2595 extern uint64_t rte_flow_dynf_metadata_mask;
2597 /* Mbuf dynamic field pointer for metadata. */
2598 #define RTE_FLOW_DYNF_METADATA(m) \
2599 RTE_MBUF_DYNFIELD((m), rte_flow_dynf_metadata_offs, uint32_t *)
2601 /* Mbuf dynamic flags for metadata. */
2602 #define PKT_RX_DYNF_METADATA (rte_flow_dynf_metadata_mask)
2603 #define PKT_TX_DYNF_METADATA (rte_flow_dynf_metadata_mask)
2606 static inline uint32_t
2607 rte_flow_dynf_metadata_get(struct rte_mbuf *m)
2609 return *RTE_FLOW_DYNF_METADATA(m);
2614 rte_flow_dynf_metadata_set(struct rte_mbuf *m, uint32_t v)
2616 *RTE_FLOW_DYNF_METADATA(m) = v;
2620 * Definition of a single action.
2622 * A list of actions is terminated by a END action.
2624 * For simple actions without a configuration object, conf remains NULL.
2626 struct rte_flow_action {
2627 enum rte_flow_action_type type; /**< Action type. */
2628 const void *conf; /**< Pointer to action configuration object. */
2632 * Opaque type returned after successfully creating a flow.
2634 * This handle can be used to manage and query the related flow (e.g. to
2635 * destroy it or retrieve counters).
2640 * Verbose error types.
2642 * Most of them provide the type of the object referenced by struct
2643 * rte_flow_error.cause.
2645 enum rte_flow_error_type {
2646 RTE_FLOW_ERROR_TYPE_NONE, /**< No error. */
2647 RTE_FLOW_ERROR_TYPE_UNSPECIFIED, /**< Cause unspecified. */
2648 RTE_FLOW_ERROR_TYPE_HANDLE, /**< Flow rule (handle). */
2649 RTE_FLOW_ERROR_TYPE_ATTR_GROUP, /**< Group field. */
2650 RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY, /**< Priority field. */
2651 RTE_FLOW_ERROR_TYPE_ATTR_INGRESS, /**< Ingress field. */
2652 RTE_FLOW_ERROR_TYPE_ATTR_EGRESS, /**< Egress field. */
2653 RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, /**< Transfer field. */
2654 RTE_FLOW_ERROR_TYPE_ATTR, /**< Attributes structure. */
2655 RTE_FLOW_ERROR_TYPE_ITEM_NUM, /**< Pattern length. */
2656 RTE_FLOW_ERROR_TYPE_ITEM_SPEC, /**< Item specification. */
2657 RTE_FLOW_ERROR_TYPE_ITEM_LAST, /**< Item specification range. */
2658 RTE_FLOW_ERROR_TYPE_ITEM_MASK, /**< Item specification mask. */
2659 RTE_FLOW_ERROR_TYPE_ITEM, /**< Specific pattern item. */
2660 RTE_FLOW_ERROR_TYPE_ACTION_NUM, /**< Number of actions. */
2661 RTE_FLOW_ERROR_TYPE_ACTION_CONF, /**< Action configuration. */
2662 RTE_FLOW_ERROR_TYPE_ACTION, /**< Specific action. */
2666 * Verbose error structure definition.
2668 * This object is normally allocated by applications and set by PMDs, the
2669 * message points to a constant string which does not need to be freed by
2670 * the application, however its pointer can be considered valid only as long
2671 * as its associated DPDK port remains configured. Closing the underlying
2672 * device or unloading the PMD invalidates it.
2674 * Both cause and message may be NULL regardless of the error type.
2676 struct rte_flow_error {
2677 enum rte_flow_error_type type; /**< Cause field and error types. */
2678 const void *cause; /**< Object responsible for the error. */
2679 const char *message; /**< Human-readable error message. */
2683 * Complete flow rule description.
2685 * This object type is used when converting a flow rule description.
2687 * @see RTE_FLOW_CONV_OP_RULE
2688 * @see rte_flow_conv()
2691 struct rte_flow_conv_rule {
2693 const struct rte_flow_attr *attr_ro; /**< RO attributes. */
2694 struct rte_flow_attr *attr; /**< Attributes. */
2697 const struct rte_flow_item *pattern_ro; /**< RO pattern. */
2698 struct rte_flow_item *pattern; /**< Pattern items. */
2701 const struct rte_flow_action *actions_ro; /**< RO actions. */
2702 struct rte_flow_action *actions; /**< List of actions. */
2707 * Conversion operations for flow API objects.
2709 * @see rte_flow_conv()
2711 enum rte_flow_conv_op {
2713 * No operation to perform.
2715 * rte_flow_conv() simply returns 0.
2717 RTE_FLOW_CONV_OP_NONE,
2720 * Convert attributes structure.
2722 * This is a basic copy of an attributes structure.
2725 * @code const struct rte_flow_attr * @endcode
2727 * @code struct rte_flow_attr * @endcode
2729 RTE_FLOW_CONV_OP_ATTR,
2732 * Convert a single item.
2734 * Duplicates @p spec, @p last and @p mask but not outside objects.
2737 * @code const struct rte_flow_item * @endcode
2739 * @code struct rte_flow_item * @endcode
2741 RTE_FLOW_CONV_OP_ITEM,
2744 * Convert a single action.
2746 * Duplicates @p conf but not outside objects.
2749 * @code const struct rte_flow_action * @endcode
2751 * @code struct rte_flow_action * @endcode
2753 RTE_FLOW_CONV_OP_ACTION,
2756 * Convert an entire pattern.
2758 * Duplicates all pattern items at once with the same constraints as
2759 * RTE_FLOW_CONV_OP_ITEM.
2762 * @code const struct rte_flow_item * @endcode
2764 * @code struct rte_flow_item * @endcode
2766 RTE_FLOW_CONV_OP_PATTERN,
2769 * Convert a list of actions.
2771 * Duplicates the entire list of actions at once with the same
2772 * constraints as RTE_FLOW_CONV_OP_ACTION.
2775 * @code const struct rte_flow_action * @endcode
2777 * @code struct rte_flow_action * @endcode
2779 RTE_FLOW_CONV_OP_ACTIONS,
2782 * Convert a complete flow rule description.
2784 * Comprises attributes, pattern and actions together at once with
2785 * the usual constraints.
2788 * @code const struct rte_flow_conv_rule * @endcode
2790 * @code struct rte_flow_conv_rule * @endcode
2792 RTE_FLOW_CONV_OP_RULE,
2795 * Convert item type to its name string.
2797 * Writes a NUL-terminated string to @p dst. Like snprintf(), the
2798 * returned value excludes the terminator which is always written
2802 * @code (const void *)enum rte_flow_item_type @endcode
2804 * @code char * @endcode
2806 RTE_FLOW_CONV_OP_ITEM_NAME,
2809 * Convert action type to its name string.
2811 * Writes a NUL-terminated string to @p dst. Like snprintf(), the
2812 * returned value excludes the terminator which is always written
2816 * @code (const void *)enum rte_flow_action_type @endcode
2818 * @code char * @endcode
2820 RTE_FLOW_CONV_OP_ACTION_NAME,
2823 * Convert item type to pointer to item name.
2825 * Retrieves item name pointer from its type. The string itself is
2826 * not copied; instead, a unique pointer to an internal static
2827 * constant storage is written to @p dst.
2830 * @code (const void *)enum rte_flow_item_type @endcode
2832 * @code const char ** @endcode
2834 RTE_FLOW_CONV_OP_ITEM_NAME_PTR,
2837 * Convert action type to pointer to action name.
2839 * Retrieves action name pointer from its type. The string itself is
2840 * not copied; instead, a unique pointer to an internal static
2841 * constant storage is written to @p dst.
2844 * @code (const void *)enum rte_flow_action_type @endcode
2846 * @code const char ** @endcode
2848 RTE_FLOW_CONV_OP_ACTION_NAME_PTR,
2852 * Check if mbuf dynamic field for metadata is registered.
2855 * True if registered, false otherwise.
2859 rte_flow_dynf_metadata_avail(void)
2861 return !!rte_flow_dynf_metadata_mask;
2865 * Register mbuf dynamic field and flag for metadata.
2867 * This function must be called prior to use SET_META action in order to
2868 * register the dynamic mbuf field. Otherwise, the data cannot be delivered to
2872 * 0 on success, a negative errno value otherwise and rte_errno is set.
2876 rte_flow_dynf_metadata_register(void);
2879 * Check whether a flow rule can be created on a given port.
2881 * The flow rule is validated for correctness and whether it could be accepted
2882 * by the device given sufficient resources. The rule is checked against the
2883 * current device mode and queue configuration. The flow rule may also
2884 * optionally be validated against existing flow rules and device resources.
2885 * This function has no effect on the target device.
2887 * The returned value is guaranteed to remain valid only as long as no
2888 * successful calls to rte_flow_create() or rte_flow_destroy() are made in
2889 * the meantime and no device parameter affecting flow rules in any way are
2890 * modified, due to possible collisions or resource limitations (although in
2891 * such cases EINVAL should not be returned).
2894 * Port identifier of Ethernet device.
2896 * Flow rule attributes.
2897 * @param[in] pattern
2898 * Pattern specification (list terminated by the END pattern item).
2899 * @param[in] actions
2900 * Associated actions (list terminated by the END action).
2902 * Perform verbose error reporting if not NULL. PMDs initialize this
2903 * structure in case of error only.
2906 * 0 if flow rule is valid and can be created. A negative errno value
2907 * otherwise (rte_errno is also set), the following errors are defined:
2909 * -ENOSYS: underlying device does not support this functionality.
2911 * -EIO: underlying device is removed.
2913 * -EINVAL: unknown or invalid rule specification.
2915 * -ENOTSUP: valid but unsupported rule specification (e.g. partial
2916 * bit-masks are unsupported).
2918 * -EEXIST: collision with an existing rule. Only returned if device
2919 * supports flow rule collision checking and there was a flow rule
2920 * collision. Not receiving this return code is no guarantee that creating
2921 * the rule will not fail due to a collision.
2923 * -ENOMEM: not enough memory to execute the function, or if the device
2924 * supports resource validation, resource limitation on the device.
2926 * -EBUSY: action cannot be performed due to busy device resources, may
2927 * succeed if the affected queues or even the entire port are in a stopped
2928 * state (see rte_eth_dev_rx_queue_stop() and rte_eth_dev_stop()).
2931 rte_flow_validate(uint16_t port_id,
2932 const struct rte_flow_attr *attr,
2933 const struct rte_flow_item pattern[],
2934 const struct rte_flow_action actions[],
2935 struct rte_flow_error *error);
2938 * Create a flow rule on a given port.
2941 * Port identifier of Ethernet device.
2943 * Flow rule attributes.
2944 * @param[in] pattern
2945 * Pattern specification (list terminated by the END pattern item).
2946 * @param[in] actions
2947 * Associated actions (list terminated by the END action).
2949 * Perform verbose error reporting if not NULL. PMDs initialize this
2950 * structure in case of error only.
2953 * A valid handle in case of success, NULL otherwise and rte_errno is set
2954 * to the positive version of one of the error codes defined for
2955 * rte_flow_validate().
2958 rte_flow_create(uint16_t port_id,
2959 const struct rte_flow_attr *attr,
2960 const struct rte_flow_item pattern[],
2961 const struct rte_flow_action actions[],
2962 struct rte_flow_error *error);
2965 * Destroy a flow rule on a given port.
2967 * Failure to destroy a flow rule handle may occur when other flow rules
2968 * depend on it, and destroying it would result in an inconsistent state.
2970 * This function is only guaranteed to succeed if handles are destroyed in
2971 * reverse order of their creation.
2974 * Port identifier of Ethernet device.
2976 * Flow rule handle to destroy.
2978 * Perform verbose error reporting if not NULL. PMDs initialize this
2979 * structure in case of error only.
2982 * 0 on success, a negative errno value otherwise and rte_errno is set.
2985 rte_flow_destroy(uint16_t port_id,
2986 struct rte_flow *flow,
2987 struct rte_flow_error *error);
2990 * Destroy all flow rules associated with a port.
2992 * In the unlikely event of failure, handles are still considered destroyed
2993 * and no longer valid but the port must be assumed to be in an inconsistent
2997 * Port identifier of Ethernet device.
2999 * Perform verbose error reporting if not NULL. PMDs initialize this
3000 * structure in case of error only.
3003 * 0 on success, a negative errno value otherwise and rte_errno is set.
3006 rte_flow_flush(uint16_t port_id,
3007 struct rte_flow_error *error);
3010 * Query an existing flow rule.
3012 * This function allows retrieving flow-specific data such as counters.
3013 * Data is gathered by special actions which must be present in the flow
3016 * \see RTE_FLOW_ACTION_TYPE_COUNT
3019 * Port identifier of Ethernet device.
3021 * Flow rule handle to query.
3023 * Action definition as defined in original flow rule.
3024 * @param[in, out] data
3025 * Pointer to storage for the associated query data type.
3027 * Perform verbose error reporting if not NULL. PMDs initialize this
3028 * structure in case of error only.
3031 * 0 on success, a negative errno value otherwise and rte_errno is set.
3034 rte_flow_query(uint16_t port_id,
3035 struct rte_flow *flow,
3036 const struct rte_flow_action *action,
3038 struct rte_flow_error *error);
3041 * Restrict ingress traffic to the defined flow rules.
3043 * Isolated mode guarantees that all ingress traffic comes from defined flow
3044 * rules only (current and future).
3046 * Besides making ingress more deterministic, it allows PMDs to safely reuse
3047 * resources otherwise assigned to handle the remaining traffic, such as
3048 * global RSS configuration settings, VLAN filters, MAC address entries,
3049 * legacy filter API rules and so on in order to expand the set of possible
3052 * Calling this function as soon as possible after device initialization,
3053 * ideally before the first call to rte_eth_dev_configure(), is recommended
3054 * to avoid possible failures due to conflicting settings.
3056 * Once effective, leaving isolated mode may not be possible depending on
3057 * PMD implementation.
3059 * Additionally, the following functionality has no effect on the underlying
3060 * port and may return errors such as ENOTSUP ("not supported"):
3062 * - Toggling promiscuous mode.
3063 * - Toggling allmulticast mode.
3064 * - Configuring MAC addresses.
3065 * - Configuring multicast addresses.
3066 * - Configuring VLAN filters.
3067 * - Configuring Rx filters through the legacy API (e.g. FDIR).
3068 * - Configuring global RSS settings.
3071 * Port identifier of Ethernet device.
3073 * Nonzero to enter isolated mode, attempt to leave it otherwise.
3075 * Perform verbose error reporting if not NULL. PMDs initialize this
3076 * structure in case of error only.
3079 * 0 on success, a negative errno value otherwise and rte_errno is set.
3082 rte_flow_isolate(uint16_t port_id, int set, struct rte_flow_error *error);
3085 * Initialize flow error structure.
3088 * Pointer to flow error structure (may be NULL).
3090 * Related error code (rte_errno).
3092 * Cause field and error types.
3094 * Object responsible for the error.
3096 * Human-readable error message.
3099 * Negative error code (errno value) and rte_errno is set.
3102 rte_flow_error_set(struct rte_flow_error *error,
3104 enum rte_flow_error_type type,
3106 const char *message);
3110 * @see rte_flow_copy()
3112 struct rte_flow_desc {
3113 size_t size; /**< Allocated space including data[]. */
3114 struct rte_flow_attr attr; /**< Attributes. */
3115 struct rte_flow_item *items; /**< Items. */
3116 struct rte_flow_action *actions; /**< Actions. */
3117 uint8_t data[]; /**< Storage for items/actions. */
3122 * Copy an rte_flow rule description.
3124 * This interface is kept for compatibility with older applications but is
3125 * implemented as a wrapper to rte_flow_conv(). It is deprecated due to its
3126 * lack of flexibility and reliance on a type unusable with C++ programs
3127 * (struct rte_flow_desc).
3130 * Flow rule description.
3132 * Total size of allocated data for the flow description.
3134 * Flow rule attributes.
3136 * Pattern specification (list terminated by the END pattern item).
3137 * @param[in] actions
3138 * Associated actions (list terminated by the END action).
3141 * If len is greater or equal to the size of the flow, the total size of the
3142 * flow description and its data.
3143 * If len is lower than the size of the flow, the number of bytes that would
3144 * have been written to desc had it been sufficient. Nothing is written.
3148 rte_flow_copy(struct rte_flow_desc *fd, size_t len,
3149 const struct rte_flow_attr *attr,
3150 const struct rte_flow_item *items,
3151 const struct rte_flow_action *actions);
3154 * Flow object conversion helper.
3156 * This function performs conversion of various flow API objects to a
3157 * pre-allocated destination buffer. See enum rte_flow_conv_op for possible
3158 * operations and details about each of them.
3160 * Since destination buffer must be large enough, it works in a manner
3161 * reminiscent of snprintf():
3163 * - If @p size is 0, @p dst may be a NULL pointer, otherwise @p dst must be
3165 * - If positive, the returned value represents the number of bytes needed
3166 * to store the conversion of @p src to @p dst according to @p op
3167 * regardless of the @p size parameter.
3168 * - Since no more than @p size bytes can be written to @p dst, output is
3169 * truncated and may be inconsistent when the returned value is larger
3171 * - In case of conversion error, a negative error code is returned and
3172 * @p dst contents are unspecified.
3175 * Operation to perform, related to the object type of @p dst.
3177 * Destination buffer address. Must be suitably aligned by the caller.
3179 * Destination buffer size in bytes.
3181 * Source object to copy. Depending on @p op, its type may differ from
3184 * Perform verbose error reporting if not NULL. Initialized in case of
3188 * The number of bytes required to convert @p src to @p dst on success, a
3189 * negative errno value otherwise and rte_errno is set.
3191 * @see rte_flow_conv_op
3195 rte_flow_conv(enum rte_flow_conv_op op,
3199 struct rte_flow_error *error);
3205 #endif /* RTE_FLOW_H_ */