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,
517 * RTE_FLOW_ITEM_TYPE_HIGIG2
518 * Matches higig2 header
521 struct rte_flow_item_higig2_hdr {
522 struct rte_higig2_hdr hdr;
525 /** Default mask for RTE_FLOW_ITEM_TYPE_HIGIG2. */
527 static const struct rte_flow_item_higig2_hdr rte_flow_item_higig2_hdr_mask = {
530 .classification = 0xffff,
538 * RTE_FLOW_ITEM_TYPE_ANY
540 * Matches any protocol in place of the current layer, a single ANY may also
541 * stand for several protocol layers.
543 * This is usually specified as the first pattern item when looking for a
544 * protocol anywhere in a packet.
546 * A zeroed mask stands for any number of layers.
548 struct rte_flow_item_any {
549 uint32_t num; /**< Number of layers covered. */
552 /** Default mask for RTE_FLOW_ITEM_TYPE_ANY. */
554 static const struct rte_flow_item_any rte_flow_item_any_mask = {
560 * RTE_FLOW_ITEM_TYPE_VF
562 * Matches traffic originating from (ingress) or going to (egress) a given
563 * virtual function of the current device.
565 * If supported, should work even if the virtual function is not managed by
566 * the application and thus not associated with a DPDK port ID.
568 * Note this pattern item does not match VF representors traffic which, as
569 * separate entities, should be addressed through their own DPDK port IDs.
571 * - Can be specified multiple times to match traffic addressed to several
573 * - Can be combined with a PF item to match both PF and VF traffic.
575 * A zeroed mask can be used to match any VF ID.
577 struct rte_flow_item_vf {
578 uint32_t id; /**< VF ID. */
581 /** Default mask for RTE_FLOW_ITEM_TYPE_VF. */
583 static const struct rte_flow_item_vf rte_flow_item_vf_mask = {
589 * RTE_FLOW_ITEM_TYPE_PHY_PORT
591 * Matches traffic originating from (ingress) or going to (egress) a
592 * physical port of the underlying device.
594 * The first PHY_PORT item overrides the physical port normally associated
595 * with the specified DPDK input port (port_id). This item can be provided
596 * several times to match additional physical ports.
598 * Note that physical ports are not necessarily tied to DPDK input ports
599 * (port_id) when those are not under DPDK control. Possible values are
600 * specific to each device, they are not necessarily indexed from zero and
601 * may not be contiguous.
603 * As a device property, the list of allowed values as well as the value
604 * associated with a port_id should be retrieved by other means.
606 * A zeroed mask can be used to match any port index.
608 struct rte_flow_item_phy_port {
609 uint32_t index; /**< Physical port index. */
612 /** Default mask for RTE_FLOW_ITEM_TYPE_PHY_PORT. */
614 static const struct rte_flow_item_phy_port rte_flow_item_phy_port_mask = {
620 * RTE_FLOW_ITEM_TYPE_PORT_ID
622 * Matches traffic originating from (ingress) or going to (egress) a given
625 * Normally only supported if the port ID in question is known by the
626 * underlying PMD and related to the device the flow rule is created
629 * This must not be confused with @p PHY_PORT which refers to the physical
630 * port of a device, whereas @p PORT_ID refers to a struct rte_eth_dev
631 * object on the application side (also known as "port representor"
632 * depending on the kind of underlying device).
634 struct rte_flow_item_port_id {
635 uint32_t id; /**< DPDK port ID. */
638 /** Default mask for RTE_FLOW_ITEM_TYPE_PORT_ID. */
640 static const struct rte_flow_item_port_id rte_flow_item_port_id_mask = {
646 * RTE_FLOW_ITEM_TYPE_RAW
648 * Matches a byte string of a given length at a given offset.
650 * Offset is either absolute (using the start of the packet) or relative to
651 * the end of the previous matched item in the stack, in which case negative
652 * values are allowed.
654 * If search is enabled, offset is used as the starting point. The search
655 * area can be delimited by setting limit to a nonzero value, which is the
656 * maximum number of bytes after offset where the pattern may start.
658 * Matching a zero-length pattern is allowed, doing so resets the relative
659 * offset for subsequent items.
661 * This type does not support ranges (struct rte_flow_item.last).
663 struct rte_flow_item_raw {
664 uint32_t relative:1; /**< Look for pattern after the previous item. */
665 uint32_t search:1; /**< Search pattern from offset (see also limit). */
666 uint32_t reserved:30; /**< Reserved, must be set to zero. */
667 int32_t offset; /**< Absolute or relative offset for pattern. */
668 uint16_t limit; /**< Search area limit for start of pattern. */
669 uint16_t length; /**< Pattern length. */
670 const uint8_t *pattern; /**< Byte string to look for. */
673 /** Default mask for RTE_FLOW_ITEM_TYPE_RAW. */
675 static const struct rte_flow_item_raw rte_flow_item_raw_mask = {
678 .reserved = 0x3fffffff,
679 .offset = 0xffffffff,
687 * RTE_FLOW_ITEM_TYPE_ETH
689 * Matches an Ethernet header.
691 * The @p type field either stands for "EtherType" or "TPID" when followed
692 * by so-called layer 2.5 pattern items such as RTE_FLOW_ITEM_TYPE_VLAN. In
693 * the latter case, @p type refers to that of the outer header, with the
694 * inner EtherType/TPID provided by the subsequent pattern item. This is the
695 * same order as on the wire.
697 struct rte_flow_item_eth {
698 struct rte_ether_addr dst; /**< Destination MAC. */
699 struct rte_ether_addr src; /**< Source MAC. */
700 rte_be16_t type; /**< EtherType or TPID. */
703 /** Default mask for RTE_FLOW_ITEM_TYPE_ETH. */
705 static const struct rte_flow_item_eth rte_flow_item_eth_mask = {
706 .dst.addr_bytes = "\xff\xff\xff\xff\xff\xff",
707 .src.addr_bytes = "\xff\xff\xff\xff\xff\xff",
708 .type = RTE_BE16(0x0000),
713 * RTE_FLOW_ITEM_TYPE_VLAN
715 * Matches an 802.1Q/ad VLAN tag.
717 * The corresponding standard outer EtherType (TPID) values are
718 * RTE_ETHER_TYPE_VLAN or RTE_ETHER_TYPE_QINQ. It can be overridden by
719 * the preceding pattern item.
721 struct rte_flow_item_vlan {
722 rte_be16_t tci; /**< Tag control information. */
723 rte_be16_t inner_type; /**< Inner EtherType or TPID. */
726 /** Default mask for RTE_FLOW_ITEM_TYPE_VLAN. */
728 static const struct rte_flow_item_vlan rte_flow_item_vlan_mask = {
729 .tci = RTE_BE16(0x0fff),
730 .inner_type = RTE_BE16(0x0000),
735 * RTE_FLOW_ITEM_TYPE_IPV4
737 * Matches an IPv4 header.
739 * Note: IPv4 options are handled by dedicated pattern items.
741 struct rte_flow_item_ipv4 {
742 struct rte_ipv4_hdr hdr; /**< IPv4 header definition. */
745 /** Default mask for RTE_FLOW_ITEM_TYPE_IPV4. */
747 static const struct rte_flow_item_ipv4 rte_flow_item_ipv4_mask = {
749 .src_addr = RTE_BE32(0xffffffff),
750 .dst_addr = RTE_BE32(0xffffffff),
756 * RTE_FLOW_ITEM_TYPE_IPV6.
758 * Matches an IPv6 header.
760 * Note: IPv6 options are handled by dedicated pattern items, see
761 * RTE_FLOW_ITEM_TYPE_IPV6_EXT.
763 struct rte_flow_item_ipv6 {
764 struct rte_ipv6_hdr hdr; /**< IPv6 header definition. */
767 /** Default mask for RTE_FLOW_ITEM_TYPE_IPV6. */
769 static const struct rte_flow_item_ipv6 rte_flow_item_ipv6_mask = {
772 "\xff\xff\xff\xff\xff\xff\xff\xff"
773 "\xff\xff\xff\xff\xff\xff\xff\xff",
775 "\xff\xff\xff\xff\xff\xff\xff\xff"
776 "\xff\xff\xff\xff\xff\xff\xff\xff",
782 * RTE_FLOW_ITEM_TYPE_ICMP.
784 * Matches an ICMP header.
786 struct rte_flow_item_icmp {
787 struct rte_icmp_hdr hdr; /**< ICMP header definition. */
790 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP. */
792 static const struct rte_flow_item_icmp rte_flow_item_icmp_mask = {
801 * RTE_FLOW_ITEM_TYPE_UDP.
803 * Matches a UDP header.
805 struct rte_flow_item_udp {
806 struct rte_udp_hdr hdr; /**< UDP header definition. */
809 /** Default mask for RTE_FLOW_ITEM_TYPE_UDP. */
811 static const struct rte_flow_item_udp rte_flow_item_udp_mask = {
813 .src_port = RTE_BE16(0xffff),
814 .dst_port = RTE_BE16(0xffff),
820 * RTE_FLOW_ITEM_TYPE_TCP.
822 * Matches a TCP header.
824 struct rte_flow_item_tcp {
825 struct rte_tcp_hdr hdr; /**< TCP header definition. */
828 /** Default mask for RTE_FLOW_ITEM_TYPE_TCP. */
830 static const struct rte_flow_item_tcp rte_flow_item_tcp_mask = {
832 .src_port = RTE_BE16(0xffff),
833 .dst_port = RTE_BE16(0xffff),
839 * RTE_FLOW_ITEM_TYPE_SCTP.
841 * Matches a SCTP header.
843 struct rte_flow_item_sctp {
844 struct rte_sctp_hdr hdr; /**< SCTP header definition. */
847 /** Default mask for RTE_FLOW_ITEM_TYPE_SCTP. */
849 static const struct rte_flow_item_sctp rte_flow_item_sctp_mask = {
851 .src_port = RTE_BE16(0xffff),
852 .dst_port = RTE_BE16(0xffff),
858 * RTE_FLOW_ITEM_TYPE_VXLAN.
860 * Matches a VXLAN header (RFC 7348).
862 struct rte_flow_item_vxlan {
863 uint8_t flags; /**< Normally 0x08 (I flag). */
864 uint8_t rsvd0[3]; /**< Reserved, normally 0x000000. */
865 uint8_t vni[3]; /**< VXLAN identifier. */
866 uint8_t rsvd1; /**< Reserved, normally 0x00. */
869 /** Default mask for RTE_FLOW_ITEM_TYPE_VXLAN. */
871 static const struct rte_flow_item_vxlan rte_flow_item_vxlan_mask = {
872 .vni = "\xff\xff\xff",
877 * RTE_FLOW_ITEM_TYPE_E_TAG.
879 * Matches a E-tag header.
881 * The corresponding standard outer EtherType (TPID) value is
882 * RTE_ETHER_TYPE_ETAG. It can be overridden by the preceding pattern item.
884 struct rte_flow_item_e_tag {
886 * E-Tag control information (E-TCI).
887 * E-PCP (3b), E-DEI (1b), ingress E-CID base (12b).
889 rte_be16_t epcp_edei_in_ecid_b;
890 /** Reserved (2b), GRP (2b), E-CID base (12b). */
891 rte_be16_t rsvd_grp_ecid_b;
892 uint8_t in_ecid_e; /**< Ingress E-CID ext. */
893 uint8_t ecid_e; /**< E-CID ext. */
894 rte_be16_t inner_type; /**< Inner EtherType or TPID. */
897 /** Default mask for RTE_FLOW_ITEM_TYPE_E_TAG. */
899 static const struct rte_flow_item_e_tag rte_flow_item_e_tag_mask = {
900 .rsvd_grp_ecid_b = RTE_BE16(0x3fff),
905 * RTE_FLOW_ITEM_TYPE_NVGRE.
907 * Matches a NVGRE header.
909 struct rte_flow_item_nvgre {
911 * Checksum (1b), undefined (1b), key bit (1b), sequence number (1b),
912 * reserved 0 (9b), version (3b).
914 * c_k_s_rsvd0_ver must have value 0x2000 according to RFC 7637.
916 rte_be16_t c_k_s_rsvd0_ver;
917 rte_be16_t protocol; /**< Protocol type (0x6558). */
918 uint8_t tni[3]; /**< Virtual subnet ID. */
919 uint8_t flow_id; /**< Flow ID. */
922 /** Default mask for RTE_FLOW_ITEM_TYPE_NVGRE. */
924 static const struct rte_flow_item_nvgre rte_flow_item_nvgre_mask = {
925 .tni = "\xff\xff\xff",
930 * RTE_FLOW_ITEM_TYPE_MPLS.
932 * Matches a MPLS header.
934 struct rte_flow_item_mpls {
936 * Label (20b), TC (3b), Bottom of Stack (1b).
938 uint8_t label_tc_s[3];
939 uint8_t ttl; /** Time-to-Live. */
942 /** Default mask for RTE_FLOW_ITEM_TYPE_MPLS. */
944 static const struct rte_flow_item_mpls rte_flow_item_mpls_mask = {
945 .label_tc_s = "\xff\xff\xf0",
950 * RTE_FLOW_ITEM_TYPE_GRE.
952 * Matches a GRE header.
954 struct rte_flow_item_gre {
956 * Checksum (1b), reserved 0 (12b), version (3b).
959 rte_be16_t c_rsvd0_ver;
960 rte_be16_t protocol; /**< Protocol type. */
963 /** Default mask for RTE_FLOW_ITEM_TYPE_GRE. */
965 static const struct rte_flow_item_gre rte_flow_item_gre_mask = {
966 .protocol = RTE_BE16(0xffff),
971 * RTE_FLOW_ITEM_TYPE_FUZZY
973 * Fuzzy pattern match, expect faster than default.
975 * This is for device that support fuzzy match option.
976 * Usually a fuzzy match is fast but the cost is accuracy.
977 * i.e. Signature Match only match pattern's hash value, but it is
978 * possible two different patterns have the same hash value.
980 * Matching accuracy level can be configure by threshold.
981 * Driver can divide the range of threshold and map to different
982 * accuracy levels that device support.
984 * Threshold 0 means perfect match (no fuzziness), while threshold
985 * 0xffffffff means fuzziest match.
987 struct rte_flow_item_fuzzy {
988 uint32_t thresh; /**< Accuracy threshold. */
991 /** Default mask for RTE_FLOW_ITEM_TYPE_FUZZY. */
993 static const struct rte_flow_item_fuzzy rte_flow_item_fuzzy_mask = {
994 .thresh = 0xffffffff,
999 * RTE_FLOW_ITEM_TYPE_GTP.
1001 * Matches a GTPv1 header.
1003 struct rte_flow_item_gtp {
1005 * Version (3b), protocol type (1b), reserved (1b),
1006 * Extension header flag (1b),
1007 * Sequence number flag (1b),
1008 * N-PDU number flag (1b).
1010 uint8_t v_pt_rsv_flags;
1011 uint8_t msg_type; /**< Message type. */
1012 rte_be16_t msg_len; /**< Message length. */
1013 rte_be32_t teid; /**< Tunnel endpoint identifier. */
1016 /** Default mask for RTE_FLOW_ITEM_TYPE_GTP. */
1018 static const struct rte_flow_item_gtp rte_flow_item_gtp_mask = {
1019 .teid = RTE_BE32(0xffffffff),
1024 * RTE_FLOW_ITEM_TYPE_ESP
1026 * Matches an ESP header.
1028 struct rte_flow_item_esp {
1029 struct rte_esp_hdr hdr; /**< ESP header definition. */
1032 /** Default mask for RTE_FLOW_ITEM_TYPE_ESP. */
1034 static const struct rte_flow_item_esp rte_flow_item_esp_mask = {
1036 .spi = RTE_BE32(0xffffffff),
1042 * RTE_FLOW_ITEM_TYPE_GENEVE.
1044 * Matches a GENEVE header.
1046 struct rte_flow_item_geneve {
1048 * Version (2b), length of the options fields (6b), OAM packet (1b),
1049 * critical options present (1b), reserved 0 (6b).
1051 rte_be16_t ver_opt_len_o_c_rsvd0;
1052 rte_be16_t protocol; /**< Protocol type. */
1053 uint8_t vni[3]; /**< Virtual Network Identifier. */
1054 uint8_t rsvd1; /**< Reserved, normally 0x00. */
1057 /** Default mask for RTE_FLOW_ITEM_TYPE_GENEVE. */
1059 static const struct rte_flow_item_geneve rte_flow_item_geneve_mask = {
1060 .vni = "\xff\xff\xff",
1065 * RTE_FLOW_ITEM_TYPE_VXLAN_GPE (draft-ietf-nvo3-vxlan-gpe-05).
1067 * Matches a VXLAN-GPE header.
1069 struct rte_flow_item_vxlan_gpe {
1070 uint8_t flags; /**< Normally 0x0c (I and P flags). */
1071 uint8_t rsvd0[2]; /**< Reserved, normally 0x0000. */
1072 uint8_t protocol; /**< Protocol type. */
1073 uint8_t vni[3]; /**< VXLAN identifier. */
1074 uint8_t rsvd1; /**< Reserved, normally 0x00. */
1077 /** Default mask for RTE_FLOW_ITEM_TYPE_VXLAN_GPE. */
1079 static const struct rte_flow_item_vxlan_gpe rte_flow_item_vxlan_gpe_mask = {
1080 .vni = "\xff\xff\xff",
1085 * RTE_FLOW_ITEM_TYPE_ARP_ETH_IPV4
1087 * Matches an ARP header for Ethernet/IPv4.
1089 struct rte_flow_item_arp_eth_ipv4 {
1090 rte_be16_t hrd; /**< Hardware type, normally 1. */
1091 rte_be16_t pro; /**< Protocol type, normally 0x0800. */
1092 uint8_t hln; /**< Hardware address length, normally 6. */
1093 uint8_t pln; /**< Protocol address length, normally 4. */
1094 rte_be16_t op; /**< Opcode (1 for request, 2 for reply). */
1095 struct rte_ether_addr sha; /**< Sender hardware address. */
1096 rte_be32_t spa; /**< Sender IPv4 address. */
1097 struct rte_ether_addr tha; /**< Target hardware address. */
1098 rte_be32_t tpa; /**< Target IPv4 address. */
1101 /** Default mask for RTE_FLOW_ITEM_TYPE_ARP_ETH_IPV4. */
1103 static const struct rte_flow_item_arp_eth_ipv4
1104 rte_flow_item_arp_eth_ipv4_mask = {
1105 .sha.addr_bytes = "\xff\xff\xff\xff\xff\xff",
1106 .spa = RTE_BE32(0xffffffff),
1107 .tha.addr_bytes = "\xff\xff\xff\xff\xff\xff",
1108 .tpa = RTE_BE32(0xffffffff),
1113 * RTE_FLOW_ITEM_TYPE_IPV6_EXT
1115 * Matches the presence of any IPv6 extension header.
1117 * Normally preceded by any of:
1119 * - RTE_FLOW_ITEM_TYPE_IPV6
1120 * - RTE_FLOW_ITEM_TYPE_IPV6_EXT
1122 struct rte_flow_item_ipv6_ext {
1123 uint8_t next_hdr; /**< Next header. */
1126 /** Default mask for RTE_FLOW_ITEM_TYPE_IPV6_EXT. */
1129 struct rte_flow_item_ipv6_ext rte_flow_item_ipv6_ext_mask = {
1135 * RTE_FLOW_ITEM_TYPE_ICMP6
1137 * Matches any ICMPv6 header.
1139 struct rte_flow_item_icmp6 {
1140 uint8_t type; /**< ICMPv6 type. */
1141 uint8_t code; /**< ICMPv6 code. */
1142 uint16_t checksum; /**< ICMPv6 checksum. */
1145 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6. */
1147 static const struct rte_flow_item_icmp6 rte_flow_item_icmp6_mask = {
1154 * RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS
1156 * Matches an ICMPv6 neighbor discovery solicitation.
1158 struct rte_flow_item_icmp6_nd_ns {
1159 uint8_t type; /**< ICMPv6 type, normally 135. */
1160 uint8_t code; /**< ICMPv6 code, normally 0. */
1161 rte_be16_t checksum; /**< ICMPv6 checksum. */
1162 rte_be32_t reserved; /**< Reserved, normally 0. */
1163 uint8_t target_addr[16]; /**< Target address. */
1166 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS. */
1169 struct rte_flow_item_icmp6_nd_ns rte_flow_item_icmp6_nd_ns_mask = {
1171 "\xff\xff\xff\xff\xff\xff\xff\xff"
1172 "\xff\xff\xff\xff\xff\xff\xff\xff",
1177 * RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA
1179 * Matches an ICMPv6 neighbor discovery advertisement.
1181 struct rte_flow_item_icmp6_nd_na {
1182 uint8_t type; /**< ICMPv6 type, normally 136. */
1183 uint8_t code; /**< ICMPv6 code, normally 0. */
1184 rte_be16_t checksum; /**< ICMPv6 checksum. */
1186 * Route flag (1b), solicited flag (1b), override flag (1b),
1189 rte_be32_t rso_reserved;
1190 uint8_t target_addr[16]; /**< Target address. */
1193 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA. */
1196 struct rte_flow_item_icmp6_nd_na rte_flow_item_icmp6_nd_na_mask = {
1198 "\xff\xff\xff\xff\xff\xff\xff\xff"
1199 "\xff\xff\xff\xff\xff\xff\xff\xff",
1204 * RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT
1206 * Matches the presence of any ICMPv6 neighbor discovery option.
1208 * Normally preceded by any of:
1210 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA
1211 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS
1212 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT
1214 struct rte_flow_item_icmp6_nd_opt {
1215 uint8_t type; /**< ND option type. */
1216 uint8_t length; /**< ND option length. */
1219 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT. */
1221 static const struct rte_flow_item_icmp6_nd_opt
1222 rte_flow_item_icmp6_nd_opt_mask = {
1228 * RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_SLA_ETH
1230 * Matches an ICMPv6 neighbor discovery source Ethernet link-layer address
1233 * Normally preceded by any of:
1235 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA
1236 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT
1238 struct rte_flow_item_icmp6_nd_opt_sla_eth {
1239 uint8_t type; /**< ND option type, normally 1. */
1240 uint8_t length; /**< ND option length, normally 1. */
1241 struct rte_ether_addr sla; /**< Source Ethernet LLA. */
1244 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_SLA_ETH. */
1246 static const struct rte_flow_item_icmp6_nd_opt_sla_eth
1247 rte_flow_item_icmp6_nd_opt_sla_eth_mask = {
1248 .sla.addr_bytes = "\xff\xff\xff\xff\xff\xff",
1253 * RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_TLA_ETH
1255 * Matches an ICMPv6 neighbor discovery target Ethernet link-layer address
1258 * Normally preceded by any of:
1260 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS
1261 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT
1263 struct rte_flow_item_icmp6_nd_opt_tla_eth {
1264 uint8_t type; /**< ND option type, normally 2. */
1265 uint8_t length; /**< ND option length, normally 1. */
1266 struct rte_ether_addr tla; /**< Target Ethernet LLA. */
1269 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_TLA_ETH. */
1271 static const struct rte_flow_item_icmp6_nd_opt_tla_eth
1272 rte_flow_item_icmp6_nd_opt_tla_eth_mask = {
1273 .tla.addr_bytes = "\xff\xff\xff\xff\xff\xff",
1278 * RTE_FLOW_ITEM_TYPE_META
1280 * Matches a specified metadata value. On egress, metadata can be set
1281 * either by mbuf dynamic metadata field with PKT_TX_DYNF_METADATA flag or
1282 * RTE_FLOW_ACTION_TYPE_SET_META. On ingress, RTE_FLOW_ACTION_TYPE_SET_META
1283 * sets metadata for a packet and the metadata will be reported via mbuf
1284 * metadata dynamic field with PKT_RX_DYNF_METADATA flag. The dynamic mbuf
1285 * field must be registered in advance by rte_flow_dynf_metadata_register().
1287 struct rte_flow_item_meta {
1291 /** Default mask for RTE_FLOW_ITEM_TYPE_META. */
1293 static const struct rte_flow_item_meta rte_flow_item_meta_mask = {
1299 * RTE_FLOW_ITEM_TYPE_GTP_PSC.
1301 * Matches a GTP PDU extension header with type 0x85.
1303 struct rte_flow_item_gtp_psc {
1304 uint8_t pdu_type; /**< PDU type. */
1305 uint8_t qfi; /**< QoS flow identifier. */
1308 /** Default mask for RTE_FLOW_ITEM_TYPE_GTP_PSC. */
1310 static const struct rte_flow_item_gtp_psc
1311 rte_flow_item_gtp_psc_mask = {
1317 * RTE_FLOW_ITEM_TYPE_PPPOE.
1319 * Matches a PPPoE header.
1321 struct rte_flow_item_pppoe {
1323 * Version (4b), type (4b).
1325 uint8_t version_type;
1326 uint8_t code; /**< Message type. */
1327 rte_be16_t session_id; /**< Session identifier. */
1328 rte_be16_t length; /**< Payload length. */
1332 * RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID.
1334 * Matches a PPPoE optional proto_id field.
1336 * It only applies to PPPoE session packets.
1338 * Normally preceded by any of:
1340 * - RTE_FLOW_ITEM_TYPE_PPPOE
1341 * - RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID
1343 struct rte_flow_item_pppoe_proto_id {
1344 rte_be16_t proto_id; /**< PPP protocol identifier. */
1347 /** Default mask for RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID. */
1349 static const struct rte_flow_item_pppoe_proto_id
1350 rte_flow_item_pppoe_proto_id_mask = {
1351 .proto_id = RTE_BE16(0xffff),
1357 * @b EXPERIMENTAL: this structure may change without prior notice
1359 * RTE_FLOW_ITEM_TYPE_TAG
1361 * Matches a specified tag value at the specified index.
1363 struct rte_flow_item_tag {
1368 /** Default mask for RTE_FLOW_ITEM_TYPE_TAG. */
1370 static const struct rte_flow_item_tag rte_flow_item_tag_mask = {
1378 * @b EXPERIMENTAL: this structure may change without prior notice
1380 * RTE_FLOW_ITEM_TYPE_MARK
1382 * Matches an arbitrary integer value which was set using the ``MARK`` action
1383 * in a previously matched rule.
1385 * This item can only be specified once as a match criteria as the ``MARK``
1386 * action can only be specified once in a flow action.
1388 * This value is arbitrary and application-defined. Maximum allowed value
1389 * depends on the underlying implementation.
1391 * Depending on the underlying implementation the MARK item may be supported on
1392 * the physical device, with virtual groups in the PMD or not at all.
1394 struct rte_flow_item_mark {
1395 uint32_t id; /**< Integer value to match against. */
1398 /** Default mask for RTE_FLOW_ITEM_TYPE_MARK. */
1400 static const struct rte_flow_item_mark rte_flow_item_mark_mask = {
1407 * @b EXPERIMENTAL: this structure may change without prior notice
1409 * RTE_FLOW_ITEM_TYPE_NSH
1411 * Match network service header (NSH), RFC 8300
1414 struct rte_flow_item_nsh {
1417 uint32_t reserved:1;
1420 uint32_t reserved1:4;
1422 uint32_t next_proto:8;
1427 /** Default mask for RTE_FLOW_ITEM_TYPE_NSH. */
1429 static const struct rte_flow_item_nsh rte_flow_item_nsh_mask = {
1439 * @b EXPERIMENTAL: this structure may change without prior notice
1441 * RTE_FLOW_ITEM_TYPE_IGMP
1443 * Match Internet Group Management Protocol (IGMP), RFC 2236
1446 struct rte_flow_item_igmp {
1448 uint32_t max_resp_time:8;
1449 uint32_t checksum:16;
1450 uint32_t group_addr;
1453 /** Default mask for RTE_FLOW_ITEM_TYPE_IGMP. */
1455 static const struct rte_flow_item_igmp rte_flow_item_igmp_mask = {
1456 .group_addr = 0xffffffff,
1462 * @b EXPERIMENTAL: this structure may change without prior notice
1464 * RTE_FLOW_ITEM_TYPE_AH
1466 * Match IP Authentication Header (AH), RFC 4302
1469 struct rte_flow_item_ah {
1470 uint32_t next_hdr:8;
1471 uint32_t payload_len:8;
1472 uint32_t reserved:16;
1477 /** Default mask for RTE_FLOW_ITEM_TYPE_AH. */
1479 static const struct rte_flow_item_ah rte_flow_item_ah_mask = {
1485 * Matching pattern item definition.
1487 * A pattern is formed by stacking items starting from the lowest protocol
1488 * layer to match. This stacking restriction does not apply to meta items
1489 * which can be placed anywhere in the stack without affecting the meaning
1490 * of the resulting pattern.
1492 * Patterns are terminated by END items.
1494 * The spec field should be a valid pointer to a structure of the related
1495 * item type. It may remain unspecified (NULL) in many cases to request
1496 * broad (nonspecific) matching. In such cases, last and mask must also be
1499 * Optionally, last can point to a structure of the same type to define an
1500 * inclusive range. This is mostly supported by integer and address fields,
1501 * may cause errors otherwise. Fields that do not support ranges must be set
1502 * to 0 or to the same value as the corresponding fields in spec.
1504 * Only the fields defined to nonzero values in the default masks (see
1505 * rte_flow_item_{name}_mask constants) are considered relevant by
1506 * default. This can be overridden by providing a mask structure of the
1507 * same type with applicable bits set to one. It can also be used to
1508 * partially filter out specific fields (e.g. as an alternate mean to match
1509 * ranges of IP addresses).
1511 * Mask is a simple bit-mask applied before interpreting the contents of
1512 * spec and last, which may yield unexpected results if not used
1513 * carefully. For example, if for an IPv4 address field, spec provides
1514 * 10.1.2.3, last provides 10.3.4.5 and mask provides 255.255.0.0, the
1515 * effective range becomes 10.1.0.0 to 10.3.255.255.
1517 struct rte_flow_item {
1518 enum rte_flow_item_type type; /**< Item type. */
1519 const void *spec; /**< Pointer to item specification structure. */
1520 const void *last; /**< Defines an inclusive range (spec to last). */
1521 const void *mask; /**< Bit-mask applied to spec and last. */
1527 * Each possible action is represented by a type.
1528 * An action can have an associated configuration object.
1529 * Several actions combined in a list can be assigned
1530 * to a flow rule and are performed in order.
1532 * They fall in three categories:
1534 * - Actions that modify the fate of matching traffic, for instance by
1535 * dropping or assigning it a specific destination.
1537 * - Actions that modify matching traffic contents or its properties. This
1538 * includes adding/removing encapsulation, encryption, compression and
1541 * - Actions related to the flow rule itself, such as updating counters or
1542 * making it non-terminating.
1544 * Flow rules being terminating by default, not specifying any action of the
1545 * fate kind results in undefined behavior. This applies to both ingress and
1548 * PASSTHRU, when supported, makes a flow rule non-terminating.
1550 enum rte_flow_action_type {
1552 * End marker for action lists. Prevents further processing of
1553 * actions, thereby ending the list.
1555 * No associated configuration structure.
1557 RTE_FLOW_ACTION_TYPE_END,
1560 * Used as a placeholder for convenience. It is ignored and simply
1561 * discarded by PMDs.
1563 * No associated configuration structure.
1565 RTE_FLOW_ACTION_TYPE_VOID,
1568 * Leaves traffic up for additional processing by subsequent flow
1569 * rules; makes a flow rule non-terminating.
1571 * No associated configuration structure.
1573 RTE_FLOW_ACTION_TYPE_PASSTHRU,
1576 * RTE_FLOW_ACTION_TYPE_JUMP
1578 * Redirects packets to a group on the current device.
1580 * See struct rte_flow_action_jump.
1582 RTE_FLOW_ACTION_TYPE_JUMP,
1585 * Attaches an integer value to packets and sets PKT_RX_FDIR and
1586 * PKT_RX_FDIR_ID mbuf flags.
1588 * See struct rte_flow_action_mark.
1590 RTE_FLOW_ACTION_TYPE_MARK,
1593 * Flags packets. Similar to MARK without a specific value; only
1594 * sets the PKT_RX_FDIR mbuf flag.
1596 * No associated configuration structure.
1598 RTE_FLOW_ACTION_TYPE_FLAG,
1601 * Assigns packets to a given queue index.
1603 * See struct rte_flow_action_queue.
1605 RTE_FLOW_ACTION_TYPE_QUEUE,
1610 * PASSTHRU overrides this action if both are specified.
1612 * No associated configuration structure.
1614 RTE_FLOW_ACTION_TYPE_DROP,
1617 * Enables counters for this flow rule.
1619 * These counters can be retrieved and reset through rte_flow_query(),
1620 * see struct rte_flow_query_count.
1622 * See struct rte_flow_action_count.
1624 RTE_FLOW_ACTION_TYPE_COUNT,
1627 * Similar to QUEUE, except RSS is additionally performed on packets
1628 * to spread them among several queues according to the provided
1631 * See struct rte_flow_action_rss.
1633 RTE_FLOW_ACTION_TYPE_RSS,
1636 * Directs matching traffic to the physical function (PF) of the
1639 * No associated configuration structure.
1641 RTE_FLOW_ACTION_TYPE_PF,
1644 * Directs matching traffic to a given virtual function of the
1647 * See struct rte_flow_action_vf.
1649 RTE_FLOW_ACTION_TYPE_VF,
1652 * Directs packets to a given physical port index of the underlying
1655 * See struct rte_flow_action_phy_port.
1657 RTE_FLOW_ACTION_TYPE_PHY_PORT,
1660 * Directs matching traffic to a given DPDK port ID.
1662 * See struct rte_flow_action_port_id.
1664 RTE_FLOW_ACTION_TYPE_PORT_ID,
1667 * Traffic metering and policing (MTR).
1669 * See struct rte_flow_action_meter.
1670 * See file rte_mtr.h for MTR object configuration.
1672 RTE_FLOW_ACTION_TYPE_METER,
1675 * Redirects packets to security engine of current device for security
1676 * processing as specified by security session.
1678 * See struct rte_flow_action_security.
1680 RTE_FLOW_ACTION_TYPE_SECURITY,
1683 * Implements OFPAT_SET_MPLS_TTL ("MPLS TTL") as defined by the
1684 * OpenFlow Switch Specification.
1686 * See struct rte_flow_action_of_set_mpls_ttl.
1688 RTE_FLOW_ACTION_TYPE_OF_SET_MPLS_TTL,
1691 * Implements OFPAT_DEC_MPLS_TTL ("decrement MPLS TTL") as defined
1692 * by the OpenFlow Switch Specification.
1694 * No associated configuration structure.
1696 RTE_FLOW_ACTION_TYPE_OF_DEC_MPLS_TTL,
1699 * Implements OFPAT_SET_NW_TTL ("IP TTL") as defined by the OpenFlow
1700 * Switch Specification.
1702 * See struct rte_flow_action_of_set_nw_ttl.
1704 RTE_FLOW_ACTION_TYPE_OF_SET_NW_TTL,
1707 * Implements OFPAT_DEC_NW_TTL ("decrement IP TTL") as defined by
1708 * the OpenFlow Switch Specification.
1710 * No associated configuration structure.
1712 RTE_FLOW_ACTION_TYPE_OF_DEC_NW_TTL,
1715 * Implements OFPAT_COPY_TTL_OUT ("copy TTL "outwards" -- from
1716 * next-to-outermost to outermost") as defined by the OpenFlow
1717 * Switch Specification.
1719 * No associated configuration structure.
1721 RTE_FLOW_ACTION_TYPE_OF_COPY_TTL_OUT,
1724 * Implements OFPAT_COPY_TTL_IN ("copy TTL "inwards" -- from
1725 * outermost to next-to-outermost") as defined by the OpenFlow
1726 * Switch Specification.
1728 * No associated configuration structure.
1730 RTE_FLOW_ACTION_TYPE_OF_COPY_TTL_IN,
1733 * Implements OFPAT_POP_VLAN ("pop the outer VLAN tag") as defined
1734 * by the OpenFlow Switch Specification.
1736 * No associated configuration structure.
1738 RTE_FLOW_ACTION_TYPE_OF_POP_VLAN,
1741 * Implements OFPAT_PUSH_VLAN ("push a new VLAN tag") as defined by
1742 * the OpenFlow Switch Specification.
1744 * See struct rte_flow_action_of_push_vlan.
1746 RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN,
1749 * Implements OFPAT_SET_VLAN_VID ("set the 802.1q VLAN id") as
1750 * defined by the OpenFlow Switch Specification.
1752 * See struct rte_flow_action_of_set_vlan_vid.
1754 RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID,
1757 * Implements OFPAT_SET_LAN_PCP ("set the 802.1q priority") as
1758 * defined by the OpenFlow Switch Specification.
1760 * See struct rte_flow_action_of_set_vlan_pcp.
1762 RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP,
1765 * Implements OFPAT_POP_MPLS ("pop the outer MPLS tag") as defined
1766 * by the OpenFlow Switch Specification.
1768 * See struct rte_flow_action_of_pop_mpls.
1770 RTE_FLOW_ACTION_TYPE_OF_POP_MPLS,
1773 * Implements OFPAT_PUSH_MPLS ("push a new MPLS tag") as defined by
1774 * the OpenFlow Switch Specification.
1776 * See struct rte_flow_action_of_push_mpls.
1778 RTE_FLOW_ACTION_TYPE_OF_PUSH_MPLS,
1781 * Encapsulate flow in VXLAN tunnel as defined in
1782 * rte_flow_action_vxlan_encap action structure.
1784 * See struct rte_flow_action_vxlan_encap.
1786 RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP,
1789 * Decapsulate outer most VXLAN tunnel from matched flow.
1791 * If flow pattern does not define a valid VXLAN tunnel (as specified by
1792 * RFC7348) then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION
1795 RTE_FLOW_ACTION_TYPE_VXLAN_DECAP,
1798 * Encapsulate flow in NVGRE tunnel defined in the
1799 * rte_flow_action_nvgre_encap action structure.
1801 * See struct rte_flow_action_nvgre_encap.
1803 RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP,
1806 * Decapsulate outer most NVGRE tunnel from matched flow.
1808 * If flow pattern does not define a valid NVGRE tunnel (as specified by
1809 * RFC7637) then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION
1812 RTE_FLOW_ACTION_TYPE_NVGRE_DECAP,
1815 * Add outer header whose template is provided in its data buffer
1817 * See struct rte_flow_action_raw_encap.
1819 RTE_FLOW_ACTION_TYPE_RAW_ENCAP,
1822 * Remove outer header whose template is provided in its data buffer.
1824 * See struct rte_flow_action_raw_decap
1826 RTE_FLOW_ACTION_TYPE_RAW_DECAP,
1829 * Modify IPv4 source address in the outermost IPv4 header.
1831 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV4,
1832 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
1834 * See struct rte_flow_action_set_ipv4.
1836 RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC,
1839 * Modify IPv4 destination address in the outermost IPv4 header.
1841 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV4,
1842 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
1844 * See struct rte_flow_action_set_ipv4.
1846 RTE_FLOW_ACTION_TYPE_SET_IPV4_DST,
1849 * Modify IPv6 source address in the outermost IPv6 header.
1851 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV6,
1852 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
1854 * See struct rte_flow_action_set_ipv6.
1856 RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC,
1859 * Modify IPv6 destination address in the outermost IPv6 header.
1861 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV6,
1862 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
1864 * See struct rte_flow_action_set_ipv6.
1866 RTE_FLOW_ACTION_TYPE_SET_IPV6_DST,
1869 * Modify source port number in the outermost TCP/UDP header.
1871 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_TCP
1872 * or RTE_FLOW_ITEM_TYPE_UDP, then the PMD should return a
1873 * RTE_FLOW_ERROR_TYPE_ACTION error.
1875 * See struct rte_flow_action_set_tp.
1877 RTE_FLOW_ACTION_TYPE_SET_TP_SRC,
1880 * Modify destination port number in the outermost TCP/UDP header.
1882 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_TCP
1883 * or RTE_FLOW_ITEM_TYPE_UDP, then the PMD should return a
1884 * RTE_FLOW_ERROR_TYPE_ACTION error.
1886 * See struct rte_flow_action_set_tp.
1888 RTE_FLOW_ACTION_TYPE_SET_TP_DST,
1891 * Swap the source and destination MAC addresses in the outermost
1894 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_ETH,
1895 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
1897 * No associated configuration structure.
1899 RTE_FLOW_ACTION_TYPE_MAC_SWAP,
1902 * Decrease TTL value directly
1904 * No associated configuration structure.
1906 RTE_FLOW_ACTION_TYPE_DEC_TTL,
1911 * See struct rte_flow_action_set_ttl
1913 RTE_FLOW_ACTION_TYPE_SET_TTL,
1916 * Set source MAC address from matched flow.
1918 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_ETH,
1919 * the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
1921 * See struct rte_flow_action_set_mac.
1923 RTE_FLOW_ACTION_TYPE_SET_MAC_SRC,
1926 * Set destination MAC address from matched flow.
1928 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_ETH,
1929 * the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
1931 * See struct rte_flow_action_set_mac.
1933 RTE_FLOW_ACTION_TYPE_SET_MAC_DST,
1936 * Increase sequence number in the outermost TCP header.
1938 * Action configuration specifies the value to increase
1939 * TCP sequence number as a big-endian 32 bit integer.
1942 * @code rte_be32_t * @endcode
1944 * Using this action on non-matching traffic will result in
1945 * undefined behavior.
1947 RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ,
1950 * Decrease sequence number in the outermost TCP header.
1952 * Action configuration specifies the value to decrease
1953 * TCP sequence number as a big-endian 32 bit integer.
1956 * @code rte_be32_t * @endcode
1958 * Using this action on non-matching traffic will result in
1959 * undefined behavior.
1961 RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ,
1964 * Increase acknowledgment number in the outermost TCP header.
1966 * Action configuration specifies the value to increase
1967 * TCP acknowledgment number as a big-endian 32 bit integer.
1970 * @code rte_be32_t * @endcode
1972 * Using this action on non-matching traffic will result in
1973 * undefined behavior.
1975 RTE_FLOW_ACTION_TYPE_INC_TCP_ACK,
1978 * Decrease acknowledgment number in the outermost TCP header.
1980 * Action configuration specifies the value to decrease
1981 * TCP acknowledgment number as a big-endian 32 bit integer.
1984 * @code rte_be32_t * @endcode
1986 * Using this action on non-matching traffic will result in
1987 * undefined behavior.
1989 RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK,
1994 * Tag is for internal flow usage only and
1995 * is not delivered to the application.
1997 * See struct rte_flow_action_set_tag.
1999 RTE_FLOW_ACTION_TYPE_SET_TAG,
2002 * Set metadata on ingress or egress path.
2004 * See struct rte_flow_action_set_meta.
2006 RTE_FLOW_ACTION_TYPE_SET_META,
2009 * Modify IPv4 DSCP in the outermost IP header.
2011 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV4,
2012 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2014 * See struct rte_flow_action_set_dscp.
2016 RTE_FLOW_ACTION_TYPE_SET_IPV4_DSCP,
2019 * Modify IPv6 DSCP in the outermost IP header.
2021 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV6,
2022 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2024 * See struct rte_flow_action_set_dscp.
2026 RTE_FLOW_ACTION_TYPE_SET_IPV6_DSCP,
2030 * RTE_FLOW_ACTION_TYPE_MARK
2032 * Attaches an integer value to packets and sets PKT_RX_FDIR and
2033 * PKT_RX_FDIR_ID mbuf flags.
2035 * This value is arbitrary and application-defined. Maximum allowed value
2036 * depends on the underlying implementation. It is returned in the
2037 * hash.fdir.hi mbuf field.
2039 struct rte_flow_action_mark {
2040 uint32_t id; /**< Integer value to return with packets. */
2045 * @b EXPERIMENTAL: this structure may change without prior notice
2047 * RTE_FLOW_ACTION_TYPE_JUMP
2049 * Redirects packets to a group on the current device.
2051 * In a hierarchy of groups, which can be used to represent physical or logical
2052 * flow tables on the device, this action allows the action to be a redirect to
2053 * a group on that device.
2055 struct rte_flow_action_jump {
2060 * RTE_FLOW_ACTION_TYPE_QUEUE
2062 * Assign packets to a given queue index.
2064 struct rte_flow_action_queue {
2065 uint16_t index; /**< Queue index to use. */
2071 * @b EXPERIMENTAL: this structure may change without prior notice
2073 * RTE_FLOW_ACTION_TYPE_COUNT
2075 * Adds a counter action to a matched flow.
2077 * If more than one count action is specified in a single flow rule, then each
2078 * action must specify a unique id.
2080 * Counters can be retrieved and reset through ``rte_flow_query()``, see
2081 * ``struct rte_flow_query_count``.
2083 * The shared flag indicates whether the counter is unique to the flow rule the
2084 * action is specified with, or whether it is a shared counter.
2086 * For a count action with the shared flag set, then then a global device
2087 * namespace is assumed for the counter id, so that any matched flow rules using
2088 * a count action with the same counter id on the same port will contribute to
2091 * For ports within the same switch domain then the counter id namespace extends
2092 * to all ports within that switch domain.
2094 struct rte_flow_action_count {
2095 uint32_t shared:1; /**< Share counter ID with other flow rules. */
2096 uint32_t reserved:31; /**< Reserved, must be zero. */
2097 uint32_t id; /**< Counter ID. */
2101 * RTE_FLOW_ACTION_TYPE_COUNT (query)
2103 * Query structure to retrieve and reset flow rule counters.
2105 struct rte_flow_query_count {
2106 uint32_t reset:1; /**< Reset counters after query [in]. */
2107 uint32_t hits_set:1; /**< hits field is set [out]. */
2108 uint32_t bytes_set:1; /**< bytes field is set [out]. */
2109 uint32_t reserved:29; /**< Reserved, must be zero [in, out]. */
2110 uint64_t hits; /**< Number of hits for this rule [out]. */
2111 uint64_t bytes; /**< Number of bytes through this rule [out]. */
2115 * Hash function types.
2117 enum rte_eth_hash_function {
2118 RTE_ETH_HASH_FUNCTION_DEFAULT = 0,
2119 RTE_ETH_HASH_FUNCTION_TOEPLITZ, /**< Toeplitz */
2120 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR, /**< Simple XOR */
2122 * Symmetric Toeplitz: src, dst will be replaced by
2123 * xor(src, dst). For the case with src/dst only,
2124 * src or dst address will xor with zero pair.
2126 RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ,
2127 RTE_ETH_HASH_FUNCTION_MAX,
2131 * RTE_FLOW_ACTION_TYPE_RSS
2133 * Similar to QUEUE, except RSS is additionally performed on packets to
2134 * spread them among several queues according to the provided parameters.
2136 * Unlike global RSS settings used by other DPDK APIs, unsetting the
2137 * @p types field does not disable RSS in a flow rule. Doing so instead
2138 * requests safe unspecified "best-effort" settings from the underlying PMD,
2139 * which depending on the flow rule, may result in anything ranging from
2140 * empty (single queue) to all-inclusive RSS.
2142 * Note: RSS hash result is stored in the hash.rss mbuf field which overlaps
2143 * hash.fdir.lo. Since the MARK action sets the hash.fdir.hi field only,
2144 * both can be requested simultaneously.
2146 struct rte_flow_action_rss {
2147 enum rte_eth_hash_function func; /**< RSS hash function to apply. */
2149 * Packet encapsulation level RSS hash @p types apply to.
2151 * - @p 0 requests the default behavior. Depending on the packet
2152 * type, it can mean outermost, innermost, anything in between or
2155 * It basically stands for the innermost encapsulation level RSS
2156 * can be performed on according to PMD and device capabilities.
2158 * - @p 1 requests RSS to be performed on the outermost packet
2159 * encapsulation level.
2161 * - @p 2 and subsequent values request RSS to be performed on the
2162 * specified inner packet encapsulation level, from outermost to
2163 * innermost (lower to higher values).
2165 * Values other than @p 0 are not necessarily supported.
2167 * Requesting a specific RSS level on unrecognized traffic results
2168 * in undefined behavior. For predictable results, it is recommended
2169 * to make the flow rule pattern match packet headers up to the
2170 * requested encapsulation level so that only matching traffic goes
2174 uint64_t types; /**< Specific RSS hash types (see ETH_RSS_*). */
2175 uint32_t key_len; /**< Hash key length in bytes. */
2176 uint32_t queue_num; /**< Number of entries in @p queue. */
2177 const uint8_t *key; /**< Hash key. */
2178 const uint16_t *queue; /**< Queue indices to use. */
2182 * RTE_FLOW_ACTION_TYPE_VF
2184 * Directs matching traffic to a given virtual function of the current
2187 * Packets matched by a VF pattern item can be redirected to their original
2188 * VF ID instead of the specified one. This parameter may not be available
2189 * and is not guaranteed to work properly if the VF part is matched by a
2190 * prior flow rule or if packets are not addressed to a VF in the first
2193 struct rte_flow_action_vf {
2194 uint32_t original:1; /**< Use original VF ID if possible. */
2195 uint32_t reserved:31; /**< Reserved, must be zero. */
2196 uint32_t id; /**< VF ID. */
2200 * RTE_FLOW_ACTION_TYPE_PHY_PORT
2202 * Directs packets to a given physical port index of the underlying
2205 * @see RTE_FLOW_ITEM_TYPE_PHY_PORT
2207 struct rte_flow_action_phy_port {
2208 uint32_t original:1; /**< Use original port index if possible. */
2209 uint32_t reserved:31; /**< Reserved, must be zero. */
2210 uint32_t index; /**< Physical port index. */
2214 * RTE_FLOW_ACTION_TYPE_PORT_ID
2216 * Directs matching traffic to a given DPDK port ID.
2218 * @see RTE_FLOW_ITEM_TYPE_PORT_ID
2220 struct rte_flow_action_port_id {
2221 uint32_t original:1; /**< Use original DPDK port ID if possible. */
2222 uint32_t reserved:31; /**< Reserved, must be zero. */
2223 uint32_t id; /**< DPDK port ID. */
2227 * RTE_FLOW_ACTION_TYPE_METER
2229 * Traffic metering and policing (MTR).
2231 * Packets matched by items of this type can be either dropped or passed to the
2232 * next item with their color set by the MTR object.
2234 struct rte_flow_action_meter {
2235 uint32_t mtr_id; /**< MTR object ID created with rte_mtr_create(). */
2239 * RTE_FLOW_ACTION_TYPE_SECURITY
2241 * Perform the security action on flows matched by the pattern items
2242 * according to the configuration of the security session.
2244 * This action modifies the payload of matched flows. For INLINE_CRYPTO, the
2245 * security protocol headers and IV are fully provided by the application as
2246 * specified in the flow pattern. The payload of matching packets is
2247 * encrypted on egress, and decrypted and authenticated on ingress.
2248 * For INLINE_PROTOCOL, the security protocol is fully offloaded to HW,
2249 * providing full encapsulation and decapsulation of packets in security
2250 * protocols. The flow pattern specifies both the outer security header fields
2251 * and the inner packet fields. The security session specified in the action
2252 * must match the pattern parameters.
2254 * The security session specified in the action must be created on the same
2255 * port as the flow action that is being specified.
2257 * The ingress/egress flow attribute should match that specified in the
2258 * security session if the security session supports the definition of the
2261 * Multiple flows can be configured to use the same security session.
2263 struct rte_flow_action_security {
2264 void *security_session; /**< Pointer to security session structure. */
2268 * RTE_FLOW_ACTION_TYPE_OF_SET_MPLS_TTL
2270 * Implements OFPAT_SET_MPLS_TTL ("MPLS TTL") as defined by the OpenFlow
2271 * Switch Specification.
2273 struct rte_flow_action_of_set_mpls_ttl {
2274 uint8_t mpls_ttl; /**< MPLS TTL. */
2278 * RTE_FLOW_ACTION_TYPE_OF_SET_NW_TTL
2280 * Implements OFPAT_SET_NW_TTL ("IP TTL") as defined by the OpenFlow Switch
2283 struct rte_flow_action_of_set_nw_ttl {
2284 uint8_t nw_ttl; /**< IP TTL. */
2288 * RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN
2290 * Implements OFPAT_PUSH_VLAN ("push a new VLAN tag") as defined by the
2291 * OpenFlow Switch Specification.
2293 struct rte_flow_action_of_push_vlan {
2294 rte_be16_t ethertype; /**< EtherType. */
2298 * RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID
2300 * Implements OFPAT_SET_VLAN_VID ("set the 802.1q VLAN id") as defined by
2301 * the OpenFlow Switch Specification.
2303 struct rte_flow_action_of_set_vlan_vid {
2304 rte_be16_t vlan_vid; /**< VLAN id. */
2308 * RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP
2310 * Implements OFPAT_SET_LAN_PCP ("set the 802.1q priority") as defined by
2311 * the OpenFlow Switch Specification.
2313 struct rte_flow_action_of_set_vlan_pcp {
2314 uint8_t vlan_pcp; /**< VLAN priority. */
2318 * RTE_FLOW_ACTION_TYPE_OF_POP_MPLS
2320 * Implements OFPAT_POP_MPLS ("pop the outer MPLS tag") as defined by the
2321 * OpenFlow Switch Specification.
2323 struct rte_flow_action_of_pop_mpls {
2324 rte_be16_t ethertype; /**< EtherType. */
2328 * RTE_FLOW_ACTION_TYPE_OF_PUSH_MPLS
2330 * Implements OFPAT_PUSH_MPLS ("push a new MPLS tag") as defined by the
2331 * OpenFlow Switch Specification.
2333 struct rte_flow_action_of_push_mpls {
2334 rte_be16_t ethertype; /**< EtherType. */
2339 * @b EXPERIMENTAL: this structure may change without prior notice
2341 * RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP
2343 * VXLAN tunnel end-point encapsulation data definition
2345 * The tunnel definition is provided through the flow item pattern, the
2346 * provided pattern must conform to RFC7348 for the tunnel specified. The flow
2347 * definition must be provided in order from the RTE_FLOW_ITEM_TYPE_ETH
2348 * definition up the end item which is specified by RTE_FLOW_ITEM_TYPE_END.
2350 * The mask field allows user to specify which fields in the flow item
2351 * definitions can be ignored and which have valid data and can be used
2354 * Note: the last field is not used in the definition of a tunnel and can be
2357 * Valid flow definition for RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP include:
2359 * - ETH / IPV4 / UDP / VXLAN / END
2360 * - ETH / IPV6 / UDP / VXLAN / END
2361 * - ETH / VLAN / IPV4 / UDP / VXLAN / END
2364 struct rte_flow_action_vxlan_encap {
2366 * Encapsulating vxlan tunnel definition
2367 * (terminated by the END pattern item).
2369 struct rte_flow_item *definition;
2374 * @b EXPERIMENTAL: this structure may change without prior notice
2376 * RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP
2378 * NVGRE tunnel end-point encapsulation data definition
2380 * The tunnel definition is provided through the flow item pattern the
2381 * provided pattern must conform with RFC7637. The flow definition must be
2382 * provided in order from the RTE_FLOW_ITEM_TYPE_ETH definition up the end item
2383 * which is specified by RTE_FLOW_ITEM_TYPE_END.
2385 * The mask field allows user to specify which fields in the flow item
2386 * definitions can be ignored and which have valid data and can be used
2389 * Note: the last field is not used in the definition of a tunnel and can be
2392 * Valid flow definition for RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP include:
2394 * - ETH / IPV4 / NVGRE / END
2395 * - ETH / VLAN / IPV6 / NVGRE / END
2398 struct rte_flow_action_nvgre_encap {
2400 * Encapsulating vxlan tunnel definition
2401 * (terminated by the END pattern item).
2403 struct rte_flow_item *definition;
2408 * @b EXPERIMENTAL: this structure may change without prior notice
2410 * RTE_FLOW_ACTION_TYPE_RAW_ENCAP
2412 * Raw tunnel end-point encapsulation data definition.
2414 * The data holds the headers definitions to be applied on the packet.
2415 * The data must start with ETH header up to the tunnel item header itself.
2416 * When used right after RAW_DECAP (for decapsulating L3 tunnel type for
2417 * example MPLSoGRE) the data will just hold layer 2 header.
2419 * The preserve parameter holds which bits in the packet the PMD is not allowed
2420 * to change, this parameter can also be NULL and then the PMD is allowed
2421 * to update any field.
2423 * size holds the number of bytes in @p data and @p preserve.
2425 struct rte_flow_action_raw_encap {
2426 uint8_t *data; /**< Encapsulation data. */
2427 uint8_t *preserve; /**< Bit-mask of @p data to preserve on output. */
2428 size_t size; /**< Size of @p data and @p preserve. */
2433 * @b EXPERIMENTAL: this structure may change without prior notice
2435 * RTE_FLOW_ACTION_TYPE_RAW_DECAP
2437 * Raw tunnel end-point decapsulation data definition.
2439 * The data holds the headers definitions to be removed from the packet.
2440 * The data must start with ETH header up to the tunnel item header itself.
2441 * When used right before RAW_DECAP (for encapsulating L3 tunnel type for
2442 * example MPLSoGRE) the data will just hold layer 2 header.
2444 * size holds the number of bytes in @p data.
2446 struct rte_flow_action_raw_decap {
2447 uint8_t *data; /**< Encapsulation data. */
2448 size_t size; /**< Size of @p data and @p preserve. */
2453 * @b EXPERIMENTAL: this structure may change without prior notice
2455 * RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC
2456 * RTE_FLOW_ACTION_TYPE_SET_IPV4_DST
2458 * Allows modification of IPv4 source (RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC)
2459 * and destination address (RTE_FLOW_ACTION_TYPE_SET_IPV4_DST) in the
2460 * specified outermost IPv4 header.
2462 struct rte_flow_action_set_ipv4 {
2463 rte_be32_t ipv4_addr;
2468 * @b EXPERIMENTAL: this structure may change without prior notice
2470 * RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC
2471 * RTE_FLOW_ACTION_TYPE_SET_IPV6_DST
2473 * Allows modification of IPv6 source (RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC)
2474 * and destination address (RTE_FLOW_ACTION_TYPE_SET_IPV6_DST) in the
2475 * specified outermost IPv6 header.
2477 struct rte_flow_action_set_ipv6 {
2478 uint8_t ipv6_addr[16];
2483 * @b EXPERIMENTAL: this structure may change without prior notice
2485 * RTE_FLOW_ACTION_TYPE_SET_TP_SRC
2486 * RTE_FLOW_ACTION_TYPE_SET_TP_DST
2488 * Allows modification of source (RTE_FLOW_ACTION_TYPE_SET_TP_SRC)
2489 * and destination (RTE_FLOW_ACTION_TYPE_SET_TP_DST) port numbers
2490 * in the specified outermost TCP/UDP header.
2492 struct rte_flow_action_set_tp {
2497 * RTE_FLOW_ACTION_TYPE_SET_TTL
2499 * Set the TTL value directly for IPv4 or IPv6
2501 struct rte_flow_action_set_ttl {
2506 * RTE_FLOW_ACTION_TYPE_SET_MAC
2508 * Set MAC address from the matched flow
2510 struct rte_flow_action_set_mac {
2511 uint8_t mac_addr[RTE_ETHER_ADDR_LEN];
2516 * @b EXPERIMENTAL: this structure may change without prior notice
2518 * RTE_FLOW_ACTION_TYPE_SET_TAG
2520 * Set a tag which is a transient data used during flow matching. This is not
2521 * delivered to application. Multiple tags are supported by specifying index.
2523 struct rte_flow_action_set_tag {
2531 * @b EXPERIMENTAL: this structure may change without prior notice
2533 * RTE_FLOW_ACTION_TYPE_SET_META
2535 * Set metadata. Metadata set by mbuf metadata dynamic field with
2536 * PKT_TX_DYNF_DATA flag on egress will be overridden by this action. On
2537 * ingress, the metadata will be carried by mbuf metadata dynamic field
2538 * with PKT_RX_DYNF_METADATA flag if set. The dynamic mbuf field must be
2539 * registered in advance by rte_flow_dynf_metadata_register().
2541 * Altering partial bits is supported with mask. For bits which have never
2542 * been set, unpredictable value will be seen depending on driver
2543 * implementation. For loopback/hairpin packet, metadata set on Rx/Tx may
2544 * or may not be propagated to the other path depending on HW capability.
2546 * RTE_FLOW_ITEM_TYPE_META matches metadata.
2548 struct rte_flow_action_set_meta {
2554 * RTE_FLOW_ACTION_TYPE_SET_IPV4_DSCP
2555 * RTE_FLOW_ACTION_TYPE_SET_IPV6_DSCP
2557 * Set the DSCP value for IPv4/IPv6 header.
2558 * DSCP in low 6 bits, rest ignored.
2560 struct rte_flow_action_set_dscp {
2564 /* Mbuf dynamic field offset for metadata. */
2565 extern int rte_flow_dynf_metadata_offs;
2567 /* Mbuf dynamic field flag mask for metadata. */
2568 extern uint64_t rte_flow_dynf_metadata_mask;
2570 /* Mbuf dynamic field pointer for metadata. */
2571 #define RTE_FLOW_DYNF_METADATA(m) \
2572 RTE_MBUF_DYNFIELD((m), rte_flow_dynf_metadata_offs, uint32_t *)
2574 /* Mbuf dynamic flags for metadata. */
2575 #define PKT_RX_DYNF_METADATA (rte_flow_dynf_metadata_mask)
2576 #define PKT_TX_DYNF_METADATA (rte_flow_dynf_metadata_mask)
2579 static inline uint32_t
2580 rte_flow_dynf_metadata_get(struct rte_mbuf *m)
2582 return *RTE_FLOW_DYNF_METADATA(m);
2587 rte_flow_dynf_metadata_set(struct rte_mbuf *m, uint32_t v)
2589 *RTE_FLOW_DYNF_METADATA(m) = v;
2593 * Definition of a single action.
2595 * A list of actions is terminated by a END action.
2597 * For simple actions without a configuration object, conf remains NULL.
2599 struct rte_flow_action {
2600 enum rte_flow_action_type type; /**< Action type. */
2601 const void *conf; /**< Pointer to action configuration object. */
2605 * Opaque type returned after successfully creating a flow.
2607 * This handle can be used to manage and query the related flow (e.g. to
2608 * destroy it or retrieve counters).
2613 * Verbose error types.
2615 * Most of them provide the type of the object referenced by struct
2616 * rte_flow_error.cause.
2618 enum rte_flow_error_type {
2619 RTE_FLOW_ERROR_TYPE_NONE, /**< No error. */
2620 RTE_FLOW_ERROR_TYPE_UNSPECIFIED, /**< Cause unspecified. */
2621 RTE_FLOW_ERROR_TYPE_HANDLE, /**< Flow rule (handle). */
2622 RTE_FLOW_ERROR_TYPE_ATTR_GROUP, /**< Group field. */
2623 RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY, /**< Priority field. */
2624 RTE_FLOW_ERROR_TYPE_ATTR_INGRESS, /**< Ingress field. */
2625 RTE_FLOW_ERROR_TYPE_ATTR_EGRESS, /**< Egress field. */
2626 RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, /**< Transfer field. */
2627 RTE_FLOW_ERROR_TYPE_ATTR, /**< Attributes structure. */
2628 RTE_FLOW_ERROR_TYPE_ITEM_NUM, /**< Pattern length. */
2629 RTE_FLOW_ERROR_TYPE_ITEM_SPEC, /**< Item specification. */
2630 RTE_FLOW_ERROR_TYPE_ITEM_LAST, /**< Item specification range. */
2631 RTE_FLOW_ERROR_TYPE_ITEM_MASK, /**< Item specification mask. */
2632 RTE_FLOW_ERROR_TYPE_ITEM, /**< Specific pattern item. */
2633 RTE_FLOW_ERROR_TYPE_ACTION_NUM, /**< Number of actions. */
2634 RTE_FLOW_ERROR_TYPE_ACTION_CONF, /**< Action configuration. */
2635 RTE_FLOW_ERROR_TYPE_ACTION, /**< Specific action. */
2639 * Verbose error structure definition.
2641 * This object is normally allocated by applications and set by PMDs, the
2642 * message points to a constant string which does not need to be freed by
2643 * the application, however its pointer can be considered valid only as long
2644 * as its associated DPDK port remains configured. Closing the underlying
2645 * device or unloading the PMD invalidates it.
2647 * Both cause and message may be NULL regardless of the error type.
2649 struct rte_flow_error {
2650 enum rte_flow_error_type type; /**< Cause field and error types. */
2651 const void *cause; /**< Object responsible for the error. */
2652 const char *message; /**< Human-readable error message. */
2656 * Complete flow rule description.
2658 * This object type is used when converting a flow rule description.
2660 * @see RTE_FLOW_CONV_OP_RULE
2661 * @see rte_flow_conv()
2664 struct rte_flow_conv_rule {
2666 const struct rte_flow_attr *attr_ro; /**< RO attributes. */
2667 struct rte_flow_attr *attr; /**< Attributes. */
2670 const struct rte_flow_item *pattern_ro; /**< RO pattern. */
2671 struct rte_flow_item *pattern; /**< Pattern items. */
2674 const struct rte_flow_action *actions_ro; /**< RO actions. */
2675 struct rte_flow_action *actions; /**< List of actions. */
2680 * Conversion operations for flow API objects.
2682 * @see rte_flow_conv()
2684 enum rte_flow_conv_op {
2686 * No operation to perform.
2688 * rte_flow_conv() simply returns 0.
2690 RTE_FLOW_CONV_OP_NONE,
2693 * Convert attributes structure.
2695 * This is a basic copy of an attributes structure.
2698 * @code const struct rte_flow_attr * @endcode
2700 * @code struct rte_flow_attr * @endcode
2702 RTE_FLOW_CONV_OP_ATTR,
2705 * Convert a single item.
2707 * Duplicates @p spec, @p last and @p mask but not outside objects.
2710 * @code const struct rte_flow_item * @endcode
2712 * @code struct rte_flow_item * @endcode
2714 RTE_FLOW_CONV_OP_ITEM,
2717 * Convert a single action.
2719 * Duplicates @p conf but not outside objects.
2722 * @code const struct rte_flow_action * @endcode
2724 * @code struct rte_flow_action * @endcode
2726 RTE_FLOW_CONV_OP_ACTION,
2729 * Convert an entire pattern.
2731 * Duplicates all pattern items at once with the same constraints as
2732 * RTE_FLOW_CONV_OP_ITEM.
2735 * @code const struct rte_flow_item * @endcode
2737 * @code struct rte_flow_item * @endcode
2739 RTE_FLOW_CONV_OP_PATTERN,
2742 * Convert a list of actions.
2744 * Duplicates the entire list of actions at once with the same
2745 * constraints as RTE_FLOW_CONV_OP_ACTION.
2748 * @code const struct rte_flow_action * @endcode
2750 * @code struct rte_flow_action * @endcode
2752 RTE_FLOW_CONV_OP_ACTIONS,
2755 * Convert a complete flow rule description.
2757 * Comprises attributes, pattern and actions together at once with
2758 * the usual constraints.
2761 * @code const struct rte_flow_conv_rule * @endcode
2763 * @code struct rte_flow_conv_rule * @endcode
2765 RTE_FLOW_CONV_OP_RULE,
2768 * Convert item type to its name string.
2770 * Writes a NUL-terminated string to @p dst. Like snprintf(), the
2771 * returned value excludes the terminator which is always written
2775 * @code (const void *)enum rte_flow_item_type @endcode
2777 * @code char * @endcode
2779 RTE_FLOW_CONV_OP_ITEM_NAME,
2782 * Convert action type to its name string.
2784 * Writes a NUL-terminated string to @p dst. Like snprintf(), the
2785 * returned value excludes the terminator which is always written
2789 * @code (const void *)enum rte_flow_action_type @endcode
2791 * @code char * @endcode
2793 RTE_FLOW_CONV_OP_ACTION_NAME,
2796 * Convert item type to pointer to item name.
2798 * Retrieves item name pointer from its type. The string itself is
2799 * not copied; instead, a unique pointer to an internal static
2800 * constant storage is written to @p dst.
2803 * @code (const void *)enum rte_flow_item_type @endcode
2805 * @code const char ** @endcode
2807 RTE_FLOW_CONV_OP_ITEM_NAME_PTR,
2810 * Convert action type to pointer to action name.
2812 * Retrieves action name pointer from its type. The string itself is
2813 * not copied; instead, a unique pointer to an internal static
2814 * constant storage is written to @p dst.
2817 * @code (const void *)enum rte_flow_action_type @endcode
2819 * @code const char ** @endcode
2821 RTE_FLOW_CONV_OP_ACTION_NAME_PTR,
2825 * Check if mbuf dynamic field for metadata is registered.
2828 * True if registered, false otherwise.
2832 rte_flow_dynf_metadata_avail(void)
2834 return !!rte_flow_dynf_metadata_mask;
2838 * Register mbuf dynamic field and flag for metadata.
2840 * This function must be called prior to use SET_META action in order to
2841 * register the dynamic mbuf field. Otherwise, the data cannot be delivered to
2845 * 0 on success, a negative errno value otherwise and rte_errno is set.
2849 rte_flow_dynf_metadata_register(void);
2852 * Check whether a flow rule can be created on a given port.
2854 * The flow rule is validated for correctness and whether it could be accepted
2855 * by the device given sufficient resources. The rule is checked against the
2856 * current device mode and queue configuration. The flow rule may also
2857 * optionally be validated against existing flow rules and device resources.
2858 * This function has no effect on the target device.
2860 * The returned value is guaranteed to remain valid only as long as no
2861 * successful calls to rte_flow_create() or rte_flow_destroy() are made in
2862 * the meantime and no device parameter affecting flow rules in any way are
2863 * modified, due to possible collisions or resource limitations (although in
2864 * such cases EINVAL should not be returned).
2867 * Port identifier of Ethernet device.
2869 * Flow rule attributes.
2870 * @param[in] pattern
2871 * Pattern specification (list terminated by the END pattern item).
2872 * @param[in] actions
2873 * Associated actions (list terminated by the END action).
2875 * Perform verbose error reporting if not NULL. PMDs initialize this
2876 * structure in case of error only.
2879 * 0 if flow rule is valid and can be created. A negative errno value
2880 * otherwise (rte_errno is also set), the following errors are defined:
2882 * -ENOSYS: underlying device does not support this functionality.
2884 * -EIO: underlying device is removed.
2886 * -EINVAL: unknown or invalid rule specification.
2888 * -ENOTSUP: valid but unsupported rule specification (e.g. partial
2889 * bit-masks are unsupported).
2891 * -EEXIST: collision with an existing rule. Only returned if device
2892 * supports flow rule collision checking and there was a flow rule
2893 * collision. Not receiving this return code is no guarantee that creating
2894 * the rule will not fail due to a collision.
2896 * -ENOMEM: not enough memory to execute the function, or if the device
2897 * supports resource validation, resource limitation on the device.
2899 * -EBUSY: action cannot be performed due to busy device resources, may
2900 * succeed if the affected queues or even the entire port are in a stopped
2901 * state (see rte_eth_dev_rx_queue_stop() and rte_eth_dev_stop()).
2904 rte_flow_validate(uint16_t port_id,
2905 const struct rte_flow_attr *attr,
2906 const struct rte_flow_item pattern[],
2907 const struct rte_flow_action actions[],
2908 struct rte_flow_error *error);
2911 * Create a flow rule on a given port.
2914 * Port identifier of Ethernet device.
2916 * Flow rule attributes.
2917 * @param[in] pattern
2918 * Pattern specification (list terminated by the END pattern item).
2919 * @param[in] actions
2920 * Associated actions (list terminated by the END action).
2922 * Perform verbose error reporting if not NULL. PMDs initialize this
2923 * structure in case of error only.
2926 * A valid handle in case of success, NULL otherwise and rte_errno is set
2927 * to the positive version of one of the error codes defined for
2928 * rte_flow_validate().
2931 rte_flow_create(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 * Destroy a flow rule on a given port.
2940 * Failure to destroy a flow rule handle may occur when other flow rules
2941 * depend on it, and destroying it would result in an inconsistent state.
2943 * This function is only guaranteed to succeed if handles are destroyed in
2944 * reverse order of their creation.
2947 * Port identifier of Ethernet device.
2949 * Flow rule handle to destroy.
2951 * Perform verbose error reporting if not NULL. PMDs initialize this
2952 * structure in case of error only.
2955 * 0 on success, a negative errno value otherwise and rte_errno is set.
2958 rte_flow_destroy(uint16_t port_id,
2959 struct rte_flow *flow,
2960 struct rte_flow_error *error);
2963 * Destroy all flow rules associated with a port.
2965 * In the unlikely event of failure, handles are still considered destroyed
2966 * and no longer valid but the port must be assumed to be in an inconsistent
2970 * Port identifier of Ethernet device.
2972 * Perform verbose error reporting if not NULL. PMDs initialize this
2973 * structure in case of error only.
2976 * 0 on success, a negative errno value otherwise and rte_errno is set.
2979 rte_flow_flush(uint16_t port_id,
2980 struct rte_flow_error *error);
2983 * Query an existing flow rule.
2985 * This function allows retrieving flow-specific data such as counters.
2986 * Data is gathered by special actions which must be present in the flow
2989 * \see RTE_FLOW_ACTION_TYPE_COUNT
2992 * Port identifier of Ethernet device.
2994 * Flow rule handle to query.
2996 * Action definition as defined in original flow rule.
2997 * @param[in, out] data
2998 * Pointer to storage for the associated query data type.
3000 * Perform verbose error reporting if not NULL. PMDs initialize this
3001 * structure in case of error only.
3004 * 0 on success, a negative errno value otherwise and rte_errno is set.
3007 rte_flow_query(uint16_t port_id,
3008 struct rte_flow *flow,
3009 const struct rte_flow_action *action,
3011 struct rte_flow_error *error);
3014 * Restrict ingress traffic to the defined flow rules.
3016 * Isolated mode guarantees that all ingress traffic comes from defined flow
3017 * rules only (current and future).
3019 * Besides making ingress more deterministic, it allows PMDs to safely reuse
3020 * resources otherwise assigned to handle the remaining traffic, such as
3021 * global RSS configuration settings, VLAN filters, MAC address entries,
3022 * legacy filter API rules and so on in order to expand the set of possible
3025 * Calling this function as soon as possible after device initialization,
3026 * ideally before the first call to rte_eth_dev_configure(), is recommended
3027 * to avoid possible failures due to conflicting settings.
3029 * Once effective, leaving isolated mode may not be possible depending on
3030 * PMD implementation.
3032 * Additionally, the following functionality has no effect on the underlying
3033 * port and may return errors such as ENOTSUP ("not supported"):
3035 * - Toggling promiscuous mode.
3036 * - Toggling allmulticast mode.
3037 * - Configuring MAC addresses.
3038 * - Configuring multicast addresses.
3039 * - Configuring VLAN filters.
3040 * - Configuring Rx filters through the legacy API (e.g. FDIR).
3041 * - Configuring global RSS settings.
3044 * Port identifier of Ethernet device.
3046 * Nonzero to enter isolated mode, attempt to leave it otherwise.
3048 * Perform verbose error reporting if not NULL. PMDs initialize this
3049 * structure in case of error only.
3052 * 0 on success, a negative errno value otherwise and rte_errno is set.
3055 rte_flow_isolate(uint16_t port_id, int set, struct rte_flow_error *error);
3058 * Initialize flow error structure.
3061 * Pointer to flow error structure (may be NULL).
3063 * Related error code (rte_errno).
3065 * Cause field and error types.
3067 * Object responsible for the error.
3069 * Human-readable error message.
3072 * Negative error code (errno value) and rte_errno is set.
3075 rte_flow_error_set(struct rte_flow_error *error,
3077 enum rte_flow_error_type type,
3079 const char *message);
3083 * @see rte_flow_copy()
3085 struct rte_flow_desc {
3086 size_t size; /**< Allocated space including data[]. */
3087 struct rte_flow_attr attr; /**< Attributes. */
3088 struct rte_flow_item *items; /**< Items. */
3089 struct rte_flow_action *actions; /**< Actions. */
3090 uint8_t data[]; /**< Storage for items/actions. */
3095 * Copy an rte_flow rule description.
3097 * This interface is kept for compatibility with older applications but is
3098 * implemented as a wrapper to rte_flow_conv(). It is deprecated due to its
3099 * lack of flexibility and reliance on a type unusable with C++ programs
3100 * (struct rte_flow_desc).
3103 * Flow rule description.
3105 * Total size of allocated data for the flow description.
3107 * Flow rule attributes.
3109 * Pattern specification (list terminated by the END pattern item).
3110 * @param[in] actions
3111 * Associated actions (list terminated by the END action).
3114 * If len is greater or equal to the size of the flow, the total size of the
3115 * flow description and its data.
3116 * If len is lower than the size of the flow, the number of bytes that would
3117 * have been written to desc had it been sufficient. Nothing is written.
3121 rte_flow_copy(struct rte_flow_desc *fd, size_t len,
3122 const struct rte_flow_attr *attr,
3123 const struct rte_flow_item *items,
3124 const struct rte_flow_action *actions);
3127 * Flow object conversion helper.
3129 * This function performs conversion of various flow API objects to a
3130 * pre-allocated destination buffer. See enum rte_flow_conv_op for possible
3131 * operations and details about each of them.
3133 * Since destination buffer must be large enough, it works in a manner
3134 * reminiscent of snprintf():
3136 * - If @p size is 0, @p dst may be a NULL pointer, otherwise @p dst must be
3138 * - If positive, the returned value represents the number of bytes needed
3139 * to store the conversion of @p src to @p dst according to @p op
3140 * regardless of the @p size parameter.
3141 * - Since no more than @p size bytes can be written to @p dst, output is
3142 * truncated and may be inconsistent when the returned value is larger
3144 * - In case of conversion error, a negative error code is returned and
3145 * @p dst contents are unspecified.
3148 * Operation to perform, related to the object type of @p dst.
3150 * Destination buffer address. Must be suitably aligned by the caller.
3152 * Destination buffer size in bytes.
3154 * Source object to copy. Depending on @p op, its type may differ from
3157 * Perform verbose error reporting if not NULL. Initialized in case of
3161 * The number of bytes required to convert @p src to @p dst on success, a
3162 * negative errno value otherwise and rte_errno is set.
3164 * @see rte_flow_conv_op
3168 rte_flow_conv(enum rte_flow_conv_op op,
3172 struct rte_flow_error *error);
3178 #endif /* RTE_FLOW_H_ */