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>
37 * Flow rule attributes.
39 * Priorities are set on a per rule based within groups.
41 * Lower values denote higher priority, the highest priority for a flow rule
42 * is 0, so that a flow that matches for than one rule, the rule with the
43 * lowest priority value will always be matched.
45 * Although optional, applications are encouraged to group similar rules as
46 * much as possible to fully take advantage of hardware capabilities
47 * (e.g. optimized matching) and work around limitations (e.g. a single
48 * pattern type possibly allowed in a given group). Applications should be
49 * aware that groups are not linked by default, and that they must be
50 * explicitly linked by the application using the JUMP action.
52 * Priority levels are arbitrary and up to the application, they
53 * do not need to be contiguous nor start from 0, however the maximum number
54 * varies between devices and may be affected by existing flow rules.
56 * If a packet is matched by several rules of a given group for a given
57 * priority level, the outcome is undefined. It can take any path, may be
58 * duplicated or even cause unrecoverable errors.
60 * Note that support for more than a single group and priority level is not
63 * Flow rules can apply to inbound and/or outbound traffic (ingress/egress).
65 * Several pattern items and actions are valid and can be used in both
66 * directions. Those valid for only one direction are described as such.
68 * At least one direction must be specified.
70 * Specifying both directions at once for a given rule is not recommended
71 * but may be valid in a few cases (e.g. shared counter).
73 struct rte_flow_attr {
74 uint32_t group; /**< Priority group. */
75 uint32_t priority; /**< Rule priority level within group. */
76 uint32_t ingress:1; /**< Rule applies to ingress traffic. */
77 uint32_t egress:1; /**< Rule applies to egress traffic. */
79 * Instead of simply matching the properties of traffic as it would
80 * appear on a given DPDK port ID, enabling this attribute transfers
81 * a flow rule to the lowest possible level of any device endpoints
82 * found in the pattern.
84 * When supported, this effectively enables an application to
85 * re-route traffic not necessarily intended for it (e.g. coming
86 * from or addressed to different physical ports, VFs or
87 * applications) at the device level.
89 * It complements the behavior of some pattern items such as
90 * RTE_FLOW_ITEM_TYPE_PHY_PORT and is meaningless without them.
92 * When transferring flow rules, ingress and egress attributes keep
93 * their original meaning, as if processing traffic emitted or
94 * received by the application.
97 uint32_t reserved:29; /**< Reserved, must be zero. */
101 * Matching pattern item types.
103 * Pattern items fall in two categories:
105 * - Matching protocol headers and packet data, usually associated with a
106 * specification structure. These must be stacked in the same order as the
107 * protocol layers to match inside packets, starting from the lowest.
109 * - Matching meta-data or affecting pattern processing, often without a
110 * specification structure. Since they do not match packet contents, their
111 * position in the list is usually not relevant.
113 * See the description of individual types for more information. Those
114 * marked with [META] fall into the second category.
116 enum rte_flow_item_type {
120 * End marker for item lists. Prevents further processing of items,
121 * thereby ending the pattern.
123 * No associated specification structure.
125 RTE_FLOW_ITEM_TYPE_END,
130 * Used as a placeholder for convenience. It is ignored and simply
133 * No associated specification structure.
135 RTE_FLOW_ITEM_TYPE_VOID,
140 * Inverted matching, i.e. process packets that do not match the
143 * No associated specification structure.
145 RTE_FLOW_ITEM_TYPE_INVERT,
148 * Matches any protocol in place of the current layer, a single ANY
149 * may also stand for several protocol layers.
151 * See struct rte_flow_item_any.
153 RTE_FLOW_ITEM_TYPE_ANY,
158 * Matches traffic originating from (ingress) or going to (egress)
159 * the physical function of the current device.
161 * No associated specification structure.
163 RTE_FLOW_ITEM_TYPE_PF,
168 * Matches traffic originating from (ingress) or going to (egress) a
169 * given virtual function of the current device.
171 * See struct rte_flow_item_vf.
173 RTE_FLOW_ITEM_TYPE_VF,
178 * Matches traffic originating from (ingress) or going to (egress) a
179 * physical port of the underlying device.
181 * See struct rte_flow_item_phy_port.
183 RTE_FLOW_ITEM_TYPE_PHY_PORT,
188 * Matches traffic originating from (ingress) or going to (egress) a
189 * given DPDK port ID.
191 * See struct rte_flow_item_port_id.
193 RTE_FLOW_ITEM_TYPE_PORT_ID,
196 * Matches a byte string of a given length at a given offset.
198 * See struct rte_flow_item_raw.
200 RTE_FLOW_ITEM_TYPE_RAW,
203 * Matches an Ethernet header.
205 * See struct rte_flow_item_eth.
207 RTE_FLOW_ITEM_TYPE_ETH,
210 * Matches an 802.1Q/ad VLAN tag.
212 * See struct rte_flow_item_vlan.
214 RTE_FLOW_ITEM_TYPE_VLAN,
217 * Matches an IPv4 header.
219 * See struct rte_flow_item_ipv4.
221 RTE_FLOW_ITEM_TYPE_IPV4,
224 * Matches an IPv6 header.
226 * See struct rte_flow_item_ipv6.
228 RTE_FLOW_ITEM_TYPE_IPV6,
231 * Matches an ICMP header.
233 * See struct rte_flow_item_icmp.
235 RTE_FLOW_ITEM_TYPE_ICMP,
238 * Matches a UDP header.
240 * See struct rte_flow_item_udp.
242 RTE_FLOW_ITEM_TYPE_UDP,
245 * Matches a TCP header.
247 * See struct rte_flow_item_tcp.
249 RTE_FLOW_ITEM_TYPE_TCP,
252 * Matches a SCTP header.
254 * See struct rte_flow_item_sctp.
256 RTE_FLOW_ITEM_TYPE_SCTP,
259 * Matches a VXLAN header.
261 * See struct rte_flow_item_vxlan.
263 RTE_FLOW_ITEM_TYPE_VXLAN,
266 * Matches a E_TAG header.
268 * See struct rte_flow_item_e_tag.
270 RTE_FLOW_ITEM_TYPE_E_TAG,
273 * Matches a NVGRE header.
275 * See struct rte_flow_item_nvgre.
277 RTE_FLOW_ITEM_TYPE_NVGRE,
280 * Matches a MPLS header.
282 * See struct rte_flow_item_mpls.
284 RTE_FLOW_ITEM_TYPE_MPLS,
287 * Matches a GRE header.
289 * See struct rte_flow_item_gre.
291 RTE_FLOW_ITEM_TYPE_GRE,
296 * Fuzzy pattern match, expect faster than default.
298 * This is for device that support fuzzy matching option.
299 * Usually a fuzzy matching is fast but the cost is accuracy.
301 * See struct rte_flow_item_fuzzy.
303 RTE_FLOW_ITEM_TYPE_FUZZY,
306 * Matches a GTP header.
308 * Configure flow for GTP packets.
310 * See struct rte_flow_item_gtp.
312 RTE_FLOW_ITEM_TYPE_GTP,
315 * Matches a GTP header.
317 * Configure flow for GTP-C packets.
319 * See struct rte_flow_item_gtp.
321 RTE_FLOW_ITEM_TYPE_GTPC,
324 * Matches a GTP header.
326 * Configure flow for GTP-U packets.
328 * See struct rte_flow_item_gtp.
330 RTE_FLOW_ITEM_TYPE_GTPU,
333 * Matches a ESP header.
335 * See struct rte_flow_item_esp.
337 RTE_FLOW_ITEM_TYPE_ESP,
340 * Matches a GENEVE header.
342 * See struct rte_flow_item_geneve.
344 RTE_FLOW_ITEM_TYPE_GENEVE,
347 * Matches a VXLAN-GPE header.
349 * See struct rte_flow_item_vxlan_gpe.
351 RTE_FLOW_ITEM_TYPE_VXLAN_GPE,
354 * Matches an ARP header for Ethernet/IPv4.
356 * See struct rte_flow_item_arp_eth_ipv4.
358 RTE_FLOW_ITEM_TYPE_ARP_ETH_IPV4,
361 * Matches the presence of any IPv6 extension header.
363 * See struct rte_flow_item_ipv6_ext.
365 RTE_FLOW_ITEM_TYPE_IPV6_EXT,
368 * Matches any ICMPv6 header.
370 * See struct rte_flow_item_icmp6.
372 RTE_FLOW_ITEM_TYPE_ICMP6,
375 * Matches an ICMPv6 neighbor discovery solicitation.
377 * See struct rte_flow_item_icmp6_nd_ns.
379 RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS,
382 * Matches an ICMPv6 neighbor discovery advertisement.
384 * See struct rte_flow_item_icmp6_nd_na.
386 RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA,
389 * Matches the presence of any ICMPv6 neighbor discovery option.
391 * See struct rte_flow_item_icmp6_nd_opt.
393 RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT,
396 * Matches an ICMPv6 neighbor discovery source Ethernet link-layer
399 * See struct rte_flow_item_icmp6_nd_opt_sla_eth.
401 RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_SLA_ETH,
404 * Matches an ICMPv6 neighbor discovery target Ethernet link-layer
407 * See struct rte_flow_item_icmp6_nd_opt_tla_eth.
409 RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_TLA_ETH,
412 * Matches specified mark field.
414 * See struct rte_flow_item_mark.
416 RTE_FLOW_ITEM_TYPE_MARK,
421 * Matches a metadata value specified in mbuf metadata field.
422 * See struct rte_flow_item_meta.
424 RTE_FLOW_ITEM_TYPE_META,
427 * Matches a GRE optional key field.
429 * The value should a big-endian 32bit integer.
431 * When this item present the K bit is implicitly matched as "1"
432 * in the default mask.
435 * @code rte_be32_t * @endcode
437 RTE_FLOW_ITEM_TYPE_GRE_KEY,
440 * Matches a GTP extension header: PDU session container.
442 * Configure flow for GTP packets with extension header type 0x85.
444 * See struct rte_flow_item_gtp_psc.
446 RTE_FLOW_ITEM_TYPE_GTP_PSC,
449 * Matches a PPPoE header.
451 * Configure flow for PPPoE session packets.
453 * See struct rte_flow_item_pppoe.
455 RTE_FLOW_ITEM_TYPE_PPPOES,
458 * Matches a PPPoE header.
460 * Configure flow for PPPoE discovery packets.
462 * See struct rte_flow_item_pppoe.
464 RTE_FLOW_ITEM_TYPE_PPPOED,
467 * Matches a PPPoE optional proto_id field.
469 * It only applies to PPPoE session packets.
471 * See struct rte_flow_item_pppoe_proto_id.
473 RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID,
476 * Matches Network service header (NSH).
477 * See struct rte_flow_item_nsh.
480 RTE_FLOW_ITEM_TYPE_NSH,
483 * Matches Internet Group Management Protocol (IGMP).
484 * See struct rte_flow_item_igmp.
487 RTE_FLOW_ITEM_TYPE_IGMP,
490 * Matches IP Authentication Header (AH).
491 * See struct rte_flow_item_ah.
494 RTE_FLOW_ITEM_TYPE_AH,
497 * Matches a HIGIG header.
498 * see struct rte_flow_item_higig2_hdr.
500 RTE_FLOW_ITEM_TYPE_HIGIG2,
505 * RTE_FLOW_ITEM_TYPE_HIGIG2
506 * Matches higig2 header
509 struct rte_flow_item_higig2_hdr {
510 struct rte_higig2_hdr hdr;
513 /** Default mask for RTE_FLOW_ITEM_TYPE_HIGIG2. */
515 static const struct rte_flow_item_higig2_hdr rte_flow_item_higig2_hdr_mask = {
518 .classification = 0xffff,
526 * RTE_FLOW_ITEM_TYPE_ANY
528 * Matches any protocol in place of the current layer, a single ANY may also
529 * stand for several protocol layers.
531 * This is usually specified as the first pattern item when looking for a
532 * protocol anywhere in a packet.
534 * A zeroed mask stands for any number of layers.
536 struct rte_flow_item_any {
537 uint32_t num; /**< Number of layers covered. */
540 /** Default mask for RTE_FLOW_ITEM_TYPE_ANY. */
542 static const struct rte_flow_item_any rte_flow_item_any_mask = {
548 * RTE_FLOW_ITEM_TYPE_VF
550 * Matches traffic originating from (ingress) or going to (egress) a given
551 * virtual function of the current device.
553 * If supported, should work even if the virtual function is not managed by
554 * the application and thus not associated with a DPDK port ID.
556 * Note this pattern item does not match VF representors traffic which, as
557 * separate entities, should be addressed through their own DPDK port IDs.
559 * - Can be specified multiple times to match traffic addressed to several
561 * - Can be combined with a PF item to match both PF and VF traffic.
563 * A zeroed mask can be used to match any VF ID.
565 struct rte_flow_item_vf {
566 uint32_t id; /**< VF ID. */
569 /** Default mask for RTE_FLOW_ITEM_TYPE_VF. */
571 static const struct rte_flow_item_vf rte_flow_item_vf_mask = {
577 * RTE_FLOW_ITEM_TYPE_PHY_PORT
579 * Matches traffic originating from (ingress) or going to (egress) a
580 * physical port of the underlying device.
582 * The first PHY_PORT item overrides the physical port normally associated
583 * with the specified DPDK input port (port_id). This item can be provided
584 * several times to match additional physical ports.
586 * Note that physical ports are not necessarily tied to DPDK input ports
587 * (port_id) when those are not under DPDK control. Possible values are
588 * specific to each device, they are not necessarily indexed from zero and
589 * may not be contiguous.
591 * As a device property, the list of allowed values as well as the value
592 * associated with a port_id should be retrieved by other means.
594 * A zeroed mask can be used to match any port index.
596 struct rte_flow_item_phy_port {
597 uint32_t index; /**< Physical port index. */
600 /** Default mask for RTE_FLOW_ITEM_TYPE_PHY_PORT. */
602 static const struct rte_flow_item_phy_port rte_flow_item_phy_port_mask = {
608 * RTE_FLOW_ITEM_TYPE_PORT_ID
610 * Matches traffic originating from (ingress) or going to (egress) a given
613 * Normally only supported if the port ID in question is known by the
614 * underlying PMD and related to the device the flow rule is created
617 * This must not be confused with @p PHY_PORT which refers to the physical
618 * port of a device, whereas @p PORT_ID refers to a struct rte_eth_dev
619 * object on the application side (also known as "port representor"
620 * depending on the kind of underlying device).
622 struct rte_flow_item_port_id {
623 uint32_t id; /**< DPDK port ID. */
626 /** Default mask for RTE_FLOW_ITEM_TYPE_PORT_ID. */
628 static const struct rte_flow_item_port_id rte_flow_item_port_id_mask = {
634 * RTE_FLOW_ITEM_TYPE_RAW
636 * Matches a byte string of a given length at a given offset.
638 * Offset is either absolute (using the start of the packet) or relative to
639 * the end of the previous matched item in the stack, in which case negative
640 * values are allowed.
642 * If search is enabled, offset is used as the starting point. The search
643 * area can be delimited by setting limit to a nonzero value, which is the
644 * maximum number of bytes after offset where the pattern may start.
646 * Matching a zero-length pattern is allowed, doing so resets the relative
647 * offset for subsequent items.
649 * This type does not support ranges (struct rte_flow_item.last).
651 struct rte_flow_item_raw {
652 uint32_t relative:1; /**< Look for pattern after the previous item. */
653 uint32_t search:1; /**< Search pattern from offset (see also limit). */
654 uint32_t reserved:30; /**< Reserved, must be set to zero. */
655 int32_t offset; /**< Absolute or relative offset for pattern. */
656 uint16_t limit; /**< Search area limit for start of pattern. */
657 uint16_t length; /**< Pattern length. */
658 const uint8_t *pattern; /**< Byte string to look for. */
661 /** Default mask for RTE_FLOW_ITEM_TYPE_RAW. */
663 static const struct rte_flow_item_raw rte_flow_item_raw_mask = {
666 .reserved = 0x3fffffff,
667 .offset = 0xffffffff,
675 * RTE_FLOW_ITEM_TYPE_ETH
677 * Matches an Ethernet header.
679 * The @p type field either stands for "EtherType" or "TPID" when followed
680 * by so-called layer 2.5 pattern items such as RTE_FLOW_ITEM_TYPE_VLAN. In
681 * the latter case, @p type refers to that of the outer header, with the
682 * inner EtherType/TPID provided by the subsequent pattern item. This is the
683 * same order as on the wire.
685 struct rte_flow_item_eth {
686 struct rte_ether_addr dst; /**< Destination MAC. */
687 struct rte_ether_addr src; /**< Source MAC. */
688 rte_be16_t type; /**< EtherType or TPID. */
691 /** Default mask for RTE_FLOW_ITEM_TYPE_ETH. */
693 static const struct rte_flow_item_eth rte_flow_item_eth_mask = {
694 .dst.addr_bytes = "\xff\xff\xff\xff\xff\xff",
695 .src.addr_bytes = "\xff\xff\xff\xff\xff\xff",
696 .type = RTE_BE16(0x0000),
701 * RTE_FLOW_ITEM_TYPE_VLAN
703 * Matches an 802.1Q/ad VLAN tag.
705 * The corresponding standard outer EtherType (TPID) values are
706 * RTE_ETHER_TYPE_VLAN or RTE_ETHER_TYPE_QINQ. It can be overridden by
707 * the preceding pattern item.
709 struct rte_flow_item_vlan {
710 rte_be16_t tci; /**< Tag control information. */
711 rte_be16_t inner_type; /**< Inner EtherType or TPID. */
714 /** Default mask for RTE_FLOW_ITEM_TYPE_VLAN. */
716 static const struct rte_flow_item_vlan rte_flow_item_vlan_mask = {
717 .tci = RTE_BE16(0x0fff),
718 .inner_type = RTE_BE16(0x0000),
723 * RTE_FLOW_ITEM_TYPE_IPV4
725 * Matches an IPv4 header.
727 * Note: IPv4 options are handled by dedicated pattern items.
729 struct rte_flow_item_ipv4 {
730 struct rte_ipv4_hdr hdr; /**< IPv4 header definition. */
733 /** Default mask for RTE_FLOW_ITEM_TYPE_IPV4. */
735 static const struct rte_flow_item_ipv4 rte_flow_item_ipv4_mask = {
737 .src_addr = RTE_BE32(0xffffffff),
738 .dst_addr = RTE_BE32(0xffffffff),
744 * RTE_FLOW_ITEM_TYPE_IPV6.
746 * Matches an IPv6 header.
748 * Note: IPv6 options are handled by dedicated pattern items, see
749 * RTE_FLOW_ITEM_TYPE_IPV6_EXT.
751 struct rte_flow_item_ipv6 {
752 struct rte_ipv6_hdr hdr; /**< IPv6 header definition. */
755 /** Default mask for RTE_FLOW_ITEM_TYPE_IPV6. */
757 static const struct rte_flow_item_ipv6 rte_flow_item_ipv6_mask = {
760 "\xff\xff\xff\xff\xff\xff\xff\xff"
761 "\xff\xff\xff\xff\xff\xff\xff\xff",
763 "\xff\xff\xff\xff\xff\xff\xff\xff"
764 "\xff\xff\xff\xff\xff\xff\xff\xff",
770 * RTE_FLOW_ITEM_TYPE_ICMP.
772 * Matches an ICMP header.
774 struct rte_flow_item_icmp {
775 struct rte_icmp_hdr hdr; /**< ICMP header definition. */
778 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP. */
780 static const struct rte_flow_item_icmp rte_flow_item_icmp_mask = {
789 * RTE_FLOW_ITEM_TYPE_UDP.
791 * Matches a UDP header.
793 struct rte_flow_item_udp {
794 struct rte_udp_hdr hdr; /**< UDP header definition. */
797 /** Default mask for RTE_FLOW_ITEM_TYPE_UDP. */
799 static const struct rte_flow_item_udp rte_flow_item_udp_mask = {
801 .src_port = RTE_BE16(0xffff),
802 .dst_port = RTE_BE16(0xffff),
808 * RTE_FLOW_ITEM_TYPE_TCP.
810 * Matches a TCP header.
812 struct rte_flow_item_tcp {
813 struct rte_tcp_hdr hdr; /**< TCP header definition. */
816 /** Default mask for RTE_FLOW_ITEM_TYPE_TCP. */
818 static const struct rte_flow_item_tcp rte_flow_item_tcp_mask = {
820 .src_port = RTE_BE16(0xffff),
821 .dst_port = RTE_BE16(0xffff),
827 * RTE_FLOW_ITEM_TYPE_SCTP.
829 * Matches a SCTP header.
831 struct rte_flow_item_sctp {
832 struct rte_sctp_hdr hdr; /**< SCTP header definition. */
835 /** Default mask for RTE_FLOW_ITEM_TYPE_SCTP. */
837 static const struct rte_flow_item_sctp rte_flow_item_sctp_mask = {
839 .src_port = RTE_BE16(0xffff),
840 .dst_port = RTE_BE16(0xffff),
846 * RTE_FLOW_ITEM_TYPE_VXLAN.
848 * Matches a VXLAN header (RFC 7348).
850 struct rte_flow_item_vxlan {
851 uint8_t flags; /**< Normally 0x08 (I flag). */
852 uint8_t rsvd0[3]; /**< Reserved, normally 0x000000. */
853 uint8_t vni[3]; /**< VXLAN identifier. */
854 uint8_t rsvd1; /**< Reserved, normally 0x00. */
857 /** Default mask for RTE_FLOW_ITEM_TYPE_VXLAN. */
859 static const struct rte_flow_item_vxlan rte_flow_item_vxlan_mask = {
860 .vni = "\xff\xff\xff",
865 * RTE_FLOW_ITEM_TYPE_E_TAG.
867 * Matches a E-tag header.
869 * The corresponding standard outer EtherType (TPID) value is
870 * RTE_ETHER_TYPE_ETAG. It can be overridden by the preceding pattern item.
872 struct rte_flow_item_e_tag {
874 * E-Tag control information (E-TCI).
875 * E-PCP (3b), E-DEI (1b), ingress E-CID base (12b).
877 rte_be16_t epcp_edei_in_ecid_b;
878 /** Reserved (2b), GRP (2b), E-CID base (12b). */
879 rte_be16_t rsvd_grp_ecid_b;
880 uint8_t in_ecid_e; /**< Ingress E-CID ext. */
881 uint8_t ecid_e; /**< E-CID ext. */
882 rte_be16_t inner_type; /**< Inner EtherType or TPID. */
885 /** Default mask for RTE_FLOW_ITEM_TYPE_E_TAG. */
887 static const struct rte_flow_item_e_tag rte_flow_item_e_tag_mask = {
888 .rsvd_grp_ecid_b = RTE_BE16(0x3fff),
893 * RTE_FLOW_ITEM_TYPE_NVGRE.
895 * Matches a NVGRE header.
897 struct rte_flow_item_nvgre {
899 * Checksum (1b), undefined (1b), key bit (1b), sequence number (1b),
900 * reserved 0 (9b), version (3b).
902 * c_k_s_rsvd0_ver must have value 0x2000 according to RFC 7637.
904 rte_be16_t c_k_s_rsvd0_ver;
905 rte_be16_t protocol; /**< Protocol type (0x6558). */
906 uint8_t tni[3]; /**< Virtual subnet ID. */
907 uint8_t flow_id; /**< Flow ID. */
910 /** Default mask for RTE_FLOW_ITEM_TYPE_NVGRE. */
912 static const struct rte_flow_item_nvgre rte_flow_item_nvgre_mask = {
913 .tni = "\xff\xff\xff",
918 * RTE_FLOW_ITEM_TYPE_MPLS.
920 * Matches a MPLS header.
922 struct rte_flow_item_mpls {
924 * Label (20b), TC (3b), Bottom of Stack (1b).
926 uint8_t label_tc_s[3];
927 uint8_t ttl; /** Time-to-Live. */
930 /** Default mask for RTE_FLOW_ITEM_TYPE_MPLS. */
932 static const struct rte_flow_item_mpls rte_flow_item_mpls_mask = {
933 .label_tc_s = "\xff\xff\xf0",
938 * RTE_FLOW_ITEM_TYPE_GRE.
940 * Matches a GRE header.
942 struct rte_flow_item_gre {
944 * Checksum (1b), reserved 0 (12b), version (3b).
947 rte_be16_t c_rsvd0_ver;
948 rte_be16_t protocol; /**< Protocol type. */
951 /** Default mask for RTE_FLOW_ITEM_TYPE_GRE. */
953 static const struct rte_flow_item_gre rte_flow_item_gre_mask = {
954 .protocol = RTE_BE16(0xffff),
959 * RTE_FLOW_ITEM_TYPE_FUZZY
961 * Fuzzy pattern match, expect faster than default.
963 * This is for device that support fuzzy match option.
964 * Usually a fuzzy match is fast but the cost is accuracy.
965 * i.e. Signature Match only match pattern's hash value, but it is
966 * possible two different patterns have the same hash value.
968 * Matching accuracy level can be configure by threshold.
969 * Driver can divide the range of threshold and map to different
970 * accuracy levels that device support.
972 * Threshold 0 means perfect match (no fuzziness), while threshold
973 * 0xffffffff means fuzziest match.
975 struct rte_flow_item_fuzzy {
976 uint32_t thresh; /**< Accuracy threshold. */
979 /** Default mask for RTE_FLOW_ITEM_TYPE_FUZZY. */
981 static const struct rte_flow_item_fuzzy rte_flow_item_fuzzy_mask = {
982 .thresh = 0xffffffff,
987 * RTE_FLOW_ITEM_TYPE_GTP.
989 * Matches a GTPv1 header.
991 struct rte_flow_item_gtp {
993 * Version (3b), protocol type (1b), reserved (1b),
994 * Extension header flag (1b),
995 * Sequence number flag (1b),
996 * N-PDU number flag (1b).
998 uint8_t v_pt_rsv_flags;
999 uint8_t msg_type; /**< Message type. */
1000 rte_be16_t msg_len; /**< Message length. */
1001 rte_be32_t teid; /**< Tunnel endpoint identifier. */
1004 /** Default mask for RTE_FLOW_ITEM_TYPE_GTP. */
1006 static const struct rte_flow_item_gtp rte_flow_item_gtp_mask = {
1007 .teid = RTE_BE32(0xffffffff),
1012 * RTE_FLOW_ITEM_TYPE_ESP
1014 * Matches an ESP header.
1016 struct rte_flow_item_esp {
1017 struct rte_esp_hdr hdr; /**< ESP header definition. */
1020 /** Default mask for RTE_FLOW_ITEM_TYPE_ESP. */
1022 static const struct rte_flow_item_esp rte_flow_item_esp_mask = {
1024 .spi = RTE_BE32(0xffffffff),
1030 * RTE_FLOW_ITEM_TYPE_GENEVE.
1032 * Matches a GENEVE header.
1034 struct rte_flow_item_geneve {
1036 * Version (2b), length of the options fields (6b), OAM packet (1b),
1037 * critical options present (1b), reserved 0 (6b).
1039 rte_be16_t ver_opt_len_o_c_rsvd0;
1040 rte_be16_t protocol; /**< Protocol type. */
1041 uint8_t vni[3]; /**< Virtual Network Identifier. */
1042 uint8_t rsvd1; /**< Reserved, normally 0x00. */
1045 /** Default mask for RTE_FLOW_ITEM_TYPE_GENEVE. */
1047 static const struct rte_flow_item_geneve rte_flow_item_geneve_mask = {
1048 .vni = "\xff\xff\xff",
1053 * RTE_FLOW_ITEM_TYPE_VXLAN_GPE (draft-ietf-nvo3-vxlan-gpe-05).
1055 * Matches a VXLAN-GPE header.
1057 struct rte_flow_item_vxlan_gpe {
1058 uint8_t flags; /**< Normally 0x0c (I and P flags). */
1059 uint8_t rsvd0[2]; /**< Reserved, normally 0x0000. */
1060 uint8_t protocol; /**< Protocol type. */
1061 uint8_t vni[3]; /**< VXLAN identifier. */
1062 uint8_t rsvd1; /**< Reserved, normally 0x00. */
1065 /** Default mask for RTE_FLOW_ITEM_TYPE_VXLAN_GPE. */
1067 static const struct rte_flow_item_vxlan_gpe rte_flow_item_vxlan_gpe_mask = {
1068 .vni = "\xff\xff\xff",
1073 * RTE_FLOW_ITEM_TYPE_ARP_ETH_IPV4
1075 * Matches an ARP header for Ethernet/IPv4.
1077 struct rte_flow_item_arp_eth_ipv4 {
1078 rte_be16_t hrd; /**< Hardware type, normally 1. */
1079 rte_be16_t pro; /**< Protocol type, normally 0x0800. */
1080 uint8_t hln; /**< Hardware address length, normally 6. */
1081 uint8_t pln; /**< Protocol address length, normally 4. */
1082 rte_be16_t op; /**< Opcode (1 for request, 2 for reply). */
1083 struct rte_ether_addr sha; /**< Sender hardware address. */
1084 rte_be32_t spa; /**< Sender IPv4 address. */
1085 struct rte_ether_addr tha; /**< Target hardware address. */
1086 rte_be32_t tpa; /**< Target IPv4 address. */
1089 /** Default mask for RTE_FLOW_ITEM_TYPE_ARP_ETH_IPV4. */
1091 static const struct rte_flow_item_arp_eth_ipv4
1092 rte_flow_item_arp_eth_ipv4_mask = {
1093 .sha.addr_bytes = "\xff\xff\xff\xff\xff\xff",
1094 .spa = RTE_BE32(0xffffffff),
1095 .tha.addr_bytes = "\xff\xff\xff\xff\xff\xff",
1096 .tpa = RTE_BE32(0xffffffff),
1101 * RTE_FLOW_ITEM_TYPE_IPV6_EXT
1103 * Matches the presence of any IPv6 extension header.
1105 * Normally preceded by any of:
1107 * - RTE_FLOW_ITEM_TYPE_IPV6
1108 * - RTE_FLOW_ITEM_TYPE_IPV6_EXT
1110 struct rte_flow_item_ipv6_ext {
1111 uint8_t next_hdr; /**< Next header. */
1114 /** Default mask for RTE_FLOW_ITEM_TYPE_IPV6_EXT. */
1117 struct rte_flow_item_ipv6_ext rte_flow_item_ipv6_ext_mask = {
1123 * RTE_FLOW_ITEM_TYPE_ICMP6
1125 * Matches any ICMPv6 header.
1127 struct rte_flow_item_icmp6 {
1128 uint8_t type; /**< ICMPv6 type. */
1129 uint8_t code; /**< ICMPv6 code. */
1130 uint16_t checksum; /**< ICMPv6 checksum. */
1133 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6. */
1135 static const struct rte_flow_item_icmp6 rte_flow_item_icmp6_mask = {
1142 * RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS
1144 * Matches an ICMPv6 neighbor discovery solicitation.
1146 struct rte_flow_item_icmp6_nd_ns {
1147 uint8_t type; /**< ICMPv6 type, normally 135. */
1148 uint8_t code; /**< ICMPv6 code, normally 0. */
1149 rte_be16_t checksum; /**< ICMPv6 checksum. */
1150 rte_be32_t reserved; /**< Reserved, normally 0. */
1151 uint8_t target_addr[16]; /**< Target address. */
1154 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS. */
1157 struct rte_flow_item_icmp6_nd_ns rte_flow_item_icmp6_nd_ns_mask = {
1159 "\xff\xff\xff\xff\xff\xff\xff\xff"
1160 "\xff\xff\xff\xff\xff\xff\xff\xff",
1165 * RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA
1167 * Matches an ICMPv6 neighbor discovery advertisement.
1169 struct rte_flow_item_icmp6_nd_na {
1170 uint8_t type; /**< ICMPv6 type, normally 136. */
1171 uint8_t code; /**< ICMPv6 code, normally 0. */
1172 rte_be16_t checksum; /**< ICMPv6 checksum. */
1174 * Route flag (1b), solicited flag (1b), override flag (1b),
1177 rte_be32_t rso_reserved;
1178 uint8_t target_addr[16]; /**< Target address. */
1181 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA. */
1184 struct rte_flow_item_icmp6_nd_na rte_flow_item_icmp6_nd_na_mask = {
1186 "\xff\xff\xff\xff\xff\xff\xff\xff"
1187 "\xff\xff\xff\xff\xff\xff\xff\xff",
1192 * RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT
1194 * Matches the presence of any ICMPv6 neighbor discovery option.
1196 * Normally preceded by any of:
1198 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA
1199 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS
1200 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT
1202 struct rte_flow_item_icmp6_nd_opt {
1203 uint8_t type; /**< ND option type. */
1204 uint8_t length; /**< ND option length. */
1207 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT. */
1209 static const struct rte_flow_item_icmp6_nd_opt
1210 rte_flow_item_icmp6_nd_opt_mask = {
1216 * RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_SLA_ETH
1218 * Matches an ICMPv6 neighbor discovery source Ethernet link-layer address
1221 * Normally preceded by any of:
1223 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA
1224 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT
1226 struct rte_flow_item_icmp6_nd_opt_sla_eth {
1227 uint8_t type; /**< ND option type, normally 1. */
1228 uint8_t length; /**< ND option length, normally 1. */
1229 struct rte_ether_addr sla; /**< Source Ethernet LLA. */
1232 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_SLA_ETH. */
1234 static const struct rte_flow_item_icmp6_nd_opt_sla_eth
1235 rte_flow_item_icmp6_nd_opt_sla_eth_mask = {
1236 .sla.addr_bytes = "\xff\xff\xff\xff\xff\xff",
1241 * RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_TLA_ETH
1243 * Matches an ICMPv6 neighbor discovery target Ethernet link-layer address
1246 * Normally preceded by any of:
1248 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS
1249 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT
1251 struct rte_flow_item_icmp6_nd_opt_tla_eth {
1252 uint8_t type; /**< ND option type, normally 2. */
1253 uint8_t length; /**< ND option length, normally 1. */
1254 struct rte_ether_addr tla; /**< Target Ethernet LLA. */
1257 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_TLA_ETH. */
1259 static const struct rte_flow_item_icmp6_nd_opt_tla_eth
1260 rte_flow_item_icmp6_nd_opt_tla_eth_mask = {
1261 .tla.addr_bytes = "\xff\xff\xff\xff\xff\xff",
1266 * RTE_FLOW_ITEM_TYPE_META.
1268 * Matches a specified metadata value.
1270 struct rte_flow_item_meta {
1274 /** Default mask for RTE_FLOW_ITEM_TYPE_META. */
1276 static const struct rte_flow_item_meta rte_flow_item_meta_mask = {
1277 .data = RTE_BE32(UINT32_MAX),
1282 * RTE_FLOW_ITEM_TYPE_GTP_PSC.
1284 * Matches a GTP PDU extension header with type 0x85.
1286 struct rte_flow_item_gtp_psc {
1287 uint8_t pdu_type; /**< PDU type. */
1288 uint8_t qfi; /**< QoS flow identifier. */
1291 /** Default mask for RTE_FLOW_ITEM_TYPE_GTP_PSC. */
1293 static const struct rte_flow_item_gtp_psc
1294 rte_flow_item_gtp_psc_mask = {
1300 * RTE_FLOW_ITEM_TYPE_PPPOE.
1302 * Matches a PPPoE header.
1304 struct rte_flow_item_pppoe {
1306 * Version (4b), type (4b).
1308 uint8_t version_type;
1309 uint8_t code; /**< Message type. */
1310 rte_be16_t session_id; /**< Session identifier. */
1311 rte_be16_t length; /**< Payload length. */
1315 * RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID.
1317 * Matches a PPPoE optional proto_id field.
1319 * It only applies to PPPoE session packets.
1321 * Normally preceded by any of:
1323 * - RTE_FLOW_ITEM_TYPE_PPPOE
1324 * - RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID
1326 struct rte_flow_item_pppoe_proto_id {
1327 rte_be16_t proto_id; /**< PPP protocol identifier. */
1330 /** Default mask for RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID. */
1332 static const struct rte_flow_item_pppoe_proto_id
1333 rte_flow_item_pppoe_proto_id_mask = {
1334 .proto_id = RTE_BE16(0xffff),
1340 * @b EXPERIMENTAL: this structure may change without prior notice
1342 * RTE_FLOW_ITEM_TYPE_MARK
1344 * Matches an arbitrary integer value which was set using the ``MARK`` action
1345 * in a previously matched rule.
1347 * This item can only be specified once as a match criteria as the ``MARK``
1348 * action can only be specified once in a flow action.
1350 * This value is arbitrary and application-defined. Maximum allowed value
1351 * depends on the underlying implementation.
1353 * Depending on the underlying implementation the MARK item may be supported on
1354 * the physical device, with virtual groups in the PMD or not at all.
1356 struct rte_flow_item_mark {
1357 uint32_t id; /**< Integer value to match against. */
1362 * @b EXPERIMENTAL: this structure may change without prior notice
1364 * RTE_FLOW_ITEM_TYPE_NSH
1366 * Match network service header (NSH), RFC 8300
1369 struct rte_flow_item_nsh {
1372 uint32_t reserved:1;
1375 uint32_t reserved1:4;
1377 uint32_t next_proto:8;
1382 /** Default mask for RTE_FLOW_ITEM_TYPE_NSH. */
1384 static const struct rte_flow_item_nsh rte_flow_item_nsh_mask = {
1394 * @b EXPERIMENTAL: this structure may change without prior notice
1396 * RTE_FLOW_ITEM_TYPE_IGMP
1398 * Match Internet Group Management Protocol (IGMP), RFC 2236
1401 struct rte_flow_item_igmp {
1403 uint32_t max_resp_time:8;
1404 uint32_t checksum:16;
1405 uint32_t group_addr;
1408 /** Default mask for RTE_FLOW_ITEM_TYPE_IGMP. */
1410 static const struct rte_flow_item_igmp rte_flow_item_igmp_mask = {
1411 .group_addr = 0xffffffff,
1417 * @b EXPERIMENTAL: this structure may change without prior notice
1419 * RTE_FLOW_ITEM_TYPE_AH
1421 * Match IP Authentication Header (AH), RFC 4302
1424 struct rte_flow_item_ah {
1425 uint32_t next_hdr:8;
1426 uint32_t payload_len:8;
1427 uint32_t reserved:16;
1432 /** Default mask for RTE_FLOW_ITEM_TYPE_AH. */
1434 static const struct rte_flow_item_ah rte_flow_item_ah_mask = {
1440 * Matching pattern item definition.
1442 * A pattern is formed by stacking items starting from the lowest protocol
1443 * layer to match. This stacking restriction does not apply to meta items
1444 * which can be placed anywhere in the stack without affecting the meaning
1445 * of the resulting pattern.
1447 * Patterns are terminated by END items.
1449 * The spec field should be a valid pointer to a structure of the related
1450 * item type. It may remain unspecified (NULL) in many cases to request
1451 * broad (nonspecific) matching. In such cases, last and mask must also be
1454 * Optionally, last can point to a structure of the same type to define an
1455 * inclusive range. This is mostly supported by integer and address fields,
1456 * may cause errors otherwise. Fields that do not support ranges must be set
1457 * to 0 or to the same value as the corresponding fields in spec.
1459 * Only the fields defined to nonzero values in the default masks (see
1460 * rte_flow_item_{name}_mask constants) are considered relevant by
1461 * default. This can be overridden by providing a mask structure of the
1462 * same type with applicable bits set to one. It can also be used to
1463 * partially filter out specific fields (e.g. as an alternate mean to match
1464 * ranges of IP addresses).
1466 * Mask is a simple bit-mask applied before interpreting the contents of
1467 * spec and last, which may yield unexpected results if not used
1468 * carefully. For example, if for an IPv4 address field, spec provides
1469 * 10.1.2.3, last provides 10.3.4.5 and mask provides 255.255.0.0, the
1470 * effective range becomes 10.1.0.0 to 10.3.255.255.
1472 struct rte_flow_item {
1473 enum rte_flow_item_type type; /**< Item type. */
1474 const void *spec; /**< Pointer to item specification structure. */
1475 const void *last; /**< Defines an inclusive range (spec to last). */
1476 const void *mask; /**< Bit-mask applied to spec and last. */
1482 * Each possible action is represented by a type.
1483 * An action can have an associated configuration object.
1484 * Several actions combined in a list can be assigned
1485 * to a flow rule and are performed in order.
1487 * They fall in three categories:
1489 * - Actions that modify the fate of matching traffic, for instance by
1490 * dropping or assigning it a specific destination.
1492 * - Actions that modify matching traffic contents or its properties. This
1493 * includes adding/removing encapsulation, encryption, compression and
1496 * - Actions related to the flow rule itself, such as updating counters or
1497 * making it non-terminating.
1499 * Flow rules being terminating by default, not specifying any action of the
1500 * fate kind results in undefined behavior. This applies to both ingress and
1503 * PASSTHRU, when supported, makes a flow rule non-terminating.
1505 enum rte_flow_action_type {
1507 * End marker for action lists. Prevents further processing of
1508 * actions, thereby ending the list.
1510 * No associated configuration structure.
1512 RTE_FLOW_ACTION_TYPE_END,
1515 * Used as a placeholder for convenience. It is ignored and simply
1516 * discarded by PMDs.
1518 * No associated configuration structure.
1520 RTE_FLOW_ACTION_TYPE_VOID,
1523 * Leaves traffic up for additional processing by subsequent flow
1524 * rules; makes a flow rule non-terminating.
1526 * No associated configuration structure.
1528 RTE_FLOW_ACTION_TYPE_PASSTHRU,
1531 * RTE_FLOW_ACTION_TYPE_JUMP
1533 * Redirects packets to a group on the current device.
1535 * See struct rte_flow_action_jump.
1537 RTE_FLOW_ACTION_TYPE_JUMP,
1540 * Attaches an integer value to packets and sets PKT_RX_FDIR and
1541 * PKT_RX_FDIR_ID mbuf flags.
1543 * See struct rte_flow_action_mark.
1545 RTE_FLOW_ACTION_TYPE_MARK,
1548 * Flags packets. Similar to MARK without a specific value; only
1549 * sets the PKT_RX_FDIR mbuf flag.
1551 * No associated configuration structure.
1553 RTE_FLOW_ACTION_TYPE_FLAG,
1556 * Assigns packets to a given queue index.
1558 * See struct rte_flow_action_queue.
1560 RTE_FLOW_ACTION_TYPE_QUEUE,
1565 * PASSTHRU overrides this action if both are specified.
1567 * No associated configuration structure.
1569 RTE_FLOW_ACTION_TYPE_DROP,
1572 * Enables counters for this flow rule.
1574 * These counters can be retrieved and reset through rte_flow_query(),
1575 * see struct rte_flow_query_count.
1577 * See struct rte_flow_action_count.
1579 RTE_FLOW_ACTION_TYPE_COUNT,
1582 * Similar to QUEUE, except RSS is additionally performed on packets
1583 * to spread them among several queues according to the provided
1586 * See struct rte_flow_action_rss.
1588 RTE_FLOW_ACTION_TYPE_RSS,
1591 * Directs matching traffic to the physical function (PF) of the
1594 * No associated configuration structure.
1596 RTE_FLOW_ACTION_TYPE_PF,
1599 * Directs matching traffic to a given virtual function of the
1602 * See struct rte_flow_action_vf.
1604 RTE_FLOW_ACTION_TYPE_VF,
1607 * Directs packets to a given physical port index of the underlying
1610 * See struct rte_flow_action_phy_port.
1612 RTE_FLOW_ACTION_TYPE_PHY_PORT,
1615 * Directs matching traffic to a given DPDK port ID.
1617 * See struct rte_flow_action_port_id.
1619 RTE_FLOW_ACTION_TYPE_PORT_ID,
1622 * Traffic metering and policing (MTR).
1624 * See struct rte_flow_action_meter.
1625 * See file rte_mtr.h for MTR object configuration.
1627 RTE_FLOW_ACTION_TYPE_METER,
1630 * Redirects packets to security engine of current device for security
1631 * processing as specified by security session.
1633 * See struct rte_flow_action_security.
1635 RTE_FLOW_ACTION_TYPE_SECURITY,
1638 * Implements OFPAT_SET_MPLS_TTL ("MPLS TTL") as defined by the
1639 * OpenFlow Switch Specification.
1641 * See struct rte_flow_action_of_set_mpls_ttl.
1643 RTE_FLOW_ACTION_TYPE_OF_SET_MPLS_TTL,
1646 * Implements OFPAT_DEC_MPLS_TTL ("decrement MPLS TTL") as defined
1647 * by the OpenFlow Switch Specification.
1649 * No associated configuration structure.
1651 RTE_FLOW_ACTION_TYPE_OF_DEC_MPLS_TTL,
1654 * Implements OFPAT_SET_NW_TTL ("IP TTL") as defined by the OpenFlow
1655 * Switch Specification.
1657 * See struct rte_flow_action_of_set_nw_ttl.
1659 RTE_FLOW_ACTION_TYPE_OF_SET_NW_TTL,
1662 * Implements OFPAT_DEC_NW_TTL ("decrement IP TTL") as defined by
1663 * the OpenFlow Switch Specification.
1665 * No associated configuration structure.
1667 RTE_FLOW_ACTION_TYPE_OF_DEC_NW_TTL,
1670 * Implements OFPAT_COPY_TTL_OUT ("copy TTL "outwards" -- from
1671 * next-to-outermost to outermost") as defined by the OpenFlow
1672 * Switch Specification.
1674 * No associated configuration structure.
1676 RTE_FLOW_ACTION_TYPE_OF_COPY_TTL_OUT,
1679 * Implements OFPAT_COPY_TTL_IN ("copy TTL "inwards" -- from
1680 * outermost to next-to-outermost") as defined by the OpenFlow
1681 * Switch Specification.
1683 * No associated configuration structure.
1685 RTE_FLOW_ACTION_TYPE_OF_COPY_TTL_IN,
1688 * Implements OFPAT_POP_VLAN ("pop the outer VLAN tag") as defined
1689 * by the OpenFlow Switch Specification.
1691 * No associated configuration structure.
1693 RTE_FLOW_ACTION_TYPE_OF_POP_VLAN,
1696 * Implements OFPAT_PUSH_VLAN ("push a new VLAN tag") as defined by
1697 * the OpenFlow Switch Specification.
1699 * See struct rte_flow_action_of_push_vlan.
1701 RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN,
1704 * Implements OFPAT_SET_VLAN_VID ("set the 802.1q VLAN id") as
1705 * defined by the OpenFlow Switch Specification.
1707 * See struct rte_flow_action_of_set_vlan_vid.
1709 RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID,
1712 * Implements OFPAT_SET_LAN_PCP ("set the 802.1q priority") as
1713 * defined by the OpenFlow Switch Specification.
1715 * See struct rte_flow_action_of_set_vlan_pcp.
1717 RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP,
1720 * Implements OFPAT_POP_MPLS ("pop the outer MPLS tag") as defined
1721 * by the OpenFlow Switch Specification.
1723 * See struct rte_flow_action_of_pop_mpls.
1725 RTE_FLOW_ACTION_TYPE_OF_POP_MPLS,
1728 * Implements OFPAT_PUSH_MPLS ("push a new MPLS tag") as defined by
1729 * the OpenFlow Switch Specification.
1731 * See struct rte_flow_action_of_push_mpls.
1733 RTE_FLOW_ACTION_TYPE_OF_PUSH_MPLS,
1736 * Encapsulate flow in VXLAN tunnel as defined in
1737 * rte_flow_action_vxlan_encap action structure.
1739 * See struct rte_flow_action_vxlan_encap.
1741 RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP,
1744 * Decapsulate outer most VXLAN tunnel from matched flow.
1746 * If flow pattern does not define a valid VXLAN tunnel (as specified by
1747 * RFC7348) then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION
1750 RTE_FLOW_ACTION_TYPE_VXLAN_DECAP,
1753 * Encapsulate flow in NVGRE tunnel defined in the
1754 * rte_flow_action_nvgre_encap action structure.
1756 * See struct rte_flow_action_nvgre_encap.
1758 RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP,
1761 * Decapsulate outer most NVGRE tunnel from matched flow.
1763 * If flow pattern does not define a valid NVGRE tunnel (as specified by
1764 * RFC7637) then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION
1767 RTE_FLOW_ACTION_TYPE_NVGRE_DECAP,
1770 * Add outer header whose template is provided in its data buffer
1772 * See struct rte_flow_action_raw_encap.
1774 RTE_FLOW_ACTION_TYPE_RAW_ENCAP,
1777 * Remove outer header whose template is provided in its data buffer.
1779 * See struct rte_flow_action_raw_decap
1781 RTE_FLOW_ACTION_TYPE_RAW_DECAP,
1784 * Modify IPv4 source address in the outermost IPv4 header.
1786 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV4,
1787 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
1789 * See struct rte_flow_action_set_ipv4.
1791 RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC,
1794 * Modify IPv4 destination address in the outermost IPv4 header.
1796 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV4,
1797 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
1799 * See struct rte_flow_action_set_ipv4.
1801 RTE_FLOW_ACTION_TYPE_SET_IPV4_DST,
1804 * Modify IPv6 source address in the outermost IPv6 header.
1806 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV6,
1807 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
1809 * See struct rte_flow_action_set_ipv6.
1811 RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC,
1814 * Modify IPv6 destination address in the outermost IPv6 header.
1816 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV6,
1817 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
1819 * See struct rte_flow_action_set_ipv6.
1821 RTE_FLOW_ACTION_TYPE_SET_IPV6_DST,
1824 * Modify source port number in the outermost TCP/UDP header.
1826 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_TCP
1827 * or RTE_FLOW_ITEM_TYPE_UDP, then the PMD should return a
1828 * RTE_FLOW_ERROR_TYPE_ACTION error.
1830 * See struct rte_flow_action_set_tp.
1832 RTE_FLOW_ACTION_TYPE_SET_TP_SRC,
1835 * Modify destination port number in the outermost TCP/UDP header.
1837 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_TCP
1838 * or RTE_FLOW_ITEM_TYPE_UDP, then the PMD should return a
1839 * RTE_FLOW_ERROR_TYPE_ACTION error.
1841 * See struct rte_flow_action_set_tp.
1843 RTE_FLOW_ACTION_TYPE_SET_TP_DST,
1846 * Swap the source and destination MAC addresses in the outermost
1849 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_ETH,
1850 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
1852 * No associated configuration structure.
1854 RTE_FLOW_ACTION_TYPE_MAC_SWAP,
1857 * Decrease TTL value directly
1859 * No associated configuration structure.
1861 RTE_FLOW_ACTION_TYPE_DEC_TTL,
1866 * See struct rte_flow_action_set_ttl
1868 RTE_FLOW_ACTION_TYPE_SET_TTL,
1871 * Set source MAC address from matched flow.
1873 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_ETH,
1874 * the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
1876 * See struct rte_flow_action_set_mac.
1878 RTE_FLOW_ACTION_TYPE_SET_MAC_SRC,
1881 * Set destination MAC address from matched flow.
1883 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_ETH,
1884 * the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
1886 * See struct rte_flow_action_set_mac.
1888 RTE_FLOW_ACTION_TYPE_SET_MAC_DST,
1891 * Increase sequence number in the outermost TCP header.
1893 * Action configuration specifies the value to increase
1894 * TCP sequence number as a big-endian 32 bit integer.
1897 * @code rte_be32_t * @endcode
1899 * Using this action on non-matching traffic will result in
1900 * undefined behavior.
1902 RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ,
1905 * Decrease sequence number in the outermost TCP header.
1907 * Action configuration specifies the value to decrease
1908 * TCP sequence number as a big-endian 32 bit integer.
1911 * @code rte_be32_t * @endcode
1913 * Using this action on non-matching traffic will result in
1914 * undefined behavior.
1916 RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ,
1919 * Increase acknowledgment number in the outermost TCP header.
1921 * Action configuration specifies the value to increase
1922 * TCP acknowledgment number as a big-endian 32 bit integer.
1925 * @code rte_be32_t * @endcode
1927 * Using this action on non-matching traffic will result in
1928 * undefined behavior.
1930 RTE_FLOW_ACTION_TYPE_INC_TCP_ACK,
1933 * Decrease acknowledgment number in the outermost TCP header.
1935 * Action configuration specifies the value to decrease
1936 * TCP acknowledgment number as a big-endian 32 bit integer.
1939 * @code rte_be32_t * @endcode
1941 * Using this action on non-matching traffic will result in
1942 * undefined behavior.
1944 RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK,
1948 * RTE_FLOW_ACTION_TYPE_MARK
1950 * Attaches an integer value to packets and sets PKT_RX_FDIR and
1951 * PKT_RX_FDIR_ID mbuf flags.
1953 * This value is arbitrary and application-defined. Maximum allowed value
1954 * depends on the underlying implementation. It is returned in the
1955 * hash.fdir.hi mbuf field.
1957 struct rte_flow_action_mark {
1958 uint32_t id; /**< Integer value to return with packets. */
1963 * @b EXPERIMENTAL: this structure may change without prior notice
1965 * RTE_FLOW_ACTION_TYPE_JUMP
1967 * Redirects packets to a group on the current device.
1969 * In a hierarchy of groups, which can be used to represent physical or logical
1970 * flow tables on the device, this action allows the action to be a redirect to
1971 * a group on that device.
1973 struct rte_flow_action_jump {
1978 * RTE_FLOW_ACTION_TYPE_QUEUE
1980 * Assign packets to a given queue index.
1982 struct rte_flow_action_queue {
1983 uint16_t index; /**< Queue index to use. */
1989 * @b EXPERIMENTAL: this structure may change without prior notice
1991 * RTE_FLOW_ACTION_TYPE_COUNT
1993 * Adds a counter action to a matched flow.
1995 * If more than one count action is specified in a single flow rule, then each
1996 * action must specify a unique id.
1998 * Counters can be retrieved and reset through ``rte_flow_query()``, see
1999 * ``struct rte_flow_query_count``.
2001 * The shared flag indicates whether the counter is unique to the flow rule the
2002 * action is specified with, or whether it is a shared counter.
2004 * For a count action with the shared flag set, then then a global device
2005 * namespace is assumed for the counter id, so that any matched flow rules using
2006 * a count action with the same counter id on the same port will contribute to
2009 * For ports within the same switch domain then the counter id namespace extends
2010 * to all ports within that switch domain.
2012 struct rte_flow_action_count {
2013 uint32_t shared:1; /**< Share counter ID with other flow rules. */
2014 uint32_t reserved:31; /**< Reserved, must be zero. */
2015 uint32_t id; /**< Counter ID. */
2019 * RTE_FLOW_ACTION_TYPE_COUNT (query)
2021 * Query structure to retrieve and reset flow rule counters.
2023 struct rte_flow_query_count {
2024 uint32_t reset:1; /**< Reset counters after query [in]. */
2025 uint32_t hits_set:1; /**< hits field is set [out]. */
2026 uint32_t bytes_set:1; /**< bytes field is set [out]. */
2027 uint32_t reserved:29; /**< Reserved, must be zero [in, out]. */
2028 uint64_t hits; /**< Number of hits for this rule [out]. */
2029 uint64_t bytes; /**< Number of bytes through this rule [out]. */
2033 * Hash function types.
2035 enum rte_eth_hash_function {
2036 RTE_ETH_HASH_FUNCTION_DEFAULT = 0,
2037 RTE_ETH_HASH_FUNCTION_TOEPLITZ, /**< Toeplitz */
2038 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR, /**< Simple XOR */
2040 * Symmetric Toeplitz: src, dst will be replaced by
2041 * xor(src, dst). For the case with src/dst only,
2042 * src or dst address will xor with zero pair.
2044 RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ,
2045 RTE_ETH_HASH_FUNCTION_MAX,
2049 * RTE_FLOW_ACTION_TYPE_RSS
2051 * Similar to QUEUE, except RSS is additionally performed on packets to
2052 * spread them among several queues according to the provided parameters.
2054 * Unlike global RSS settings used by other DPDK APIs, unsetting the
2055 * @p types field does not disable RSS in a flow rule. Doing so instead
2056 * requests safe unspecified "best-effort" settings from the underlying PMD,
2057 * which depending on the flow rule, may result in anything ranging from
2058 * empty (single queue) to all-inclusive RSS.
2060 * Note: RSS hash result is stored in the hash.rss mbuf field which overlaps
2061 * hash.fdir.lo. Since the MARK action sets the hash.fdir.hi field only,
2062 * both can be requested simultaneously.
2064 struct rte_flow_action_rss {
2065 enum rte_eth_hash_function func; /**< RSS hash function to apply. */
2067 * Packet encapsulation level RSS hash @p types apply to.
2069 * - @p 0 requests the default behavior. Depending on the packet
2070 * type, it can mean outermost, innermost, anything in between or
2073 * It basically stands for the innermost encapsulation level RSS
2074 * can be performed on according to PMD and device capabilities.
2076 * - @p 1 requests RSS to be performed on the outermost packet
2077 * encapsulation level.
2079 * - @p 2 and subsequent values request RSS to be performed on the
2080 * specified inner packet encapsulation level, from outermost to
2081 * innermost (lower to higher values).
2083 * Values other than @p 0 are not necessarily supported.
2085 * Requesting a specific RSS level on unrecognized traffic results
2086 * in undefined behavior. For predictable results, it is recommended
2087 * to make the flow rule pattern match packet headers up to the
2088 * requested encapsulation level so that only matching traffic goes
2092 uint64_t types; /**< Specific RSS hash types (see ETH_RSS_*). */
2093 uint32_t key_len; /**< Hash key length in bytes. */
2094 uint32_t queue_num; /**< Number of entries in @p queue. */
2095 const uint8_t *key; /**< Hash key. */
2096 const uint16_t *queue; /**< Queue indices to use. */
2100 * RTE_FLOW_ACTION_TYPE_VF
2102 * Directs matching traffic to a given virtual function of the current
2105 * Packets matched by a VF pattern item can be redirected to their original
2106 * VF ID instead of the specified one. This parameter may not be available
2107 * and is not guaranteed to work properly if the VF part is matched by a
2108 * prior flow rule or if packets are not addressed to a VF in the first
2111 struct rte_flow_action_vf {
2112 uint32_t original:1; /**< Use original VF ID if possible. */
2113 uint32_t reserved:31; /**< Reserved, must be zero. */
2114 uint32_t id; /**< VF ID. */
2118 * RTE_FLOW_ACTION_TYPE_PHY_PORT
2120 * Directs packets to a given physical port index of the underlying
2123 * @see RTE_FLOW_ITEM_TYPE_PHY_PORT
2125 struct rte_flow_action_phy_port {
2126 uint32_t original:1; /**< Use original port index if possible. */
2127 uint32_t reserved:31; /**< Reserved, must be zero. */
2128 uint32_t index; /**< Physical port index. */
2132 * RTE_FLOW_ACTION_TYPE_PORT_ID
2134 * Directs matching traffic to a given DPDK port ID.
2136 * @see RTE_FLOW_ITEM_TYPE_PORT_ID
2138 struct rte_flow_action_port_id {
2139 uint32_t original:1; /**< Use original DPDK port ID if possible. */
2140 uint32_t reserved:31; /**< Reserved, must be zero. */
2141 uint32_t id; /**< DPDK port ID. */
2145 * RTE_FLOW_ACTION_TYPE_METER
2147 * Traffic metering and policing (MTR).
2149 * Packets matched by items of this type can be either dropped or passed to the
2150 * next item with their color set by the MTR object.
2152 struct rte_flow_action_meter {
2153 uint32_t mtr_id; /**< MTR object ID created with rte_mtr_create(). */
2157 * RTE_FLOW_ACTION_TYPE_SECURITY
2159 * Perform the security action on flows matched by the pattern items
2160 * according to the configuration of the security session.
2162 * This action modifies the payload of matched flows. For INLINE_CRYPTO, the
2163 * security protocol headers and IV are fully provided by the application as
2164 * specified in the flow pattern. The payload of matching packets is
2165 * encrypted on egress, and decrypted and authenticated on ingress.
2166 * For INLINE_PROTOCOL, the security protocol is fully offloaded to HW,
2167 * providing full encapsulation and decapsulation of packets in security
2168 * protocols. The flow pattern specifies both the outer security header fields
2169 * and the inner packet fields. The security session specified in the action
2170 * must match the pattern parameters.
2172 * The security session specified in the action must be created on the same
2173 * port as the flow action that is being specified.
2175 * The ingress/egress flow attribute should match that specified in the
2176 * security session if the security session supports the definition of the
2179 * Multiple flows can be configured to use the same security session.
2181 struct rte_flow_action_security {
2182 void *security_session; /**< Pointer to security session structure. */
2186 * RTE_FLOW_ACTION_TYPE_OF_SET_MPLS_TTL
2188 * Implements OFPAT_SET_MPLS_TTL ("MPLS TTL") as defined by the OpenFlow
2189 * Switch Specification.
2191 struct rte_flow_action_of_set_mpls_ttl {
2192 uint8_t mpls_ttl; /**< MPLS TTL. */
2196 * RTE_FLOW_ACTION_TYPE_OF_SET_NW_TTL
2198 * Implements OFPAT_SET_NW_TTL ("IP TTL") as defined by the OpenFlow Switch
2201 struct rte_flow_action_of_set_nw_ttl {
2202 uint8_t nw_ttl; /**< IP TTL. */
2206 * RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN
2208 * Implements OFPAT_PUSH_VLAN ("push a new VLAN tag") as defined by the
2209 * OpenFlow Switch Specification.
2211 struct rte_flow_action_of_push_vlan {
2212 rte_be16_t ethertype; /**< EtherType. */
2216 * RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID
2218 * Implements OFPAT_SET_VLAN_VID ("set the 802.1q VLAN id") as defined by
2219 * the OpenFlow Switch Specification.
2221 struct rte_flow_action_of_set_vlan_vid {
2222 rte_be16_t vlan_vid; /**< VLAN id. */
2226 * RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP
2228 * Implements OFPAT_SET_LAN_PCP ("set the 802.1q priority") as defined by
2229 * the OpenFlow Switch Specification.
2231 struct rte_flow_action_of_set_vlan_pcp {
2232 uint8_t vlan_pcp; /**< VLAN priority. */
2236 * RTE_FLOW_ACTION_TYPE_OF_POP_MPLS
2238 * Implements OFPAT_POP_MPLS ("pop the outer MPLS tag") as defined by the
2239 * OpenFlow Switch Specification.
2241 struct rte_flow_action_of_pop_mpls {
2242 rte_be16_t ethertype; /**< EtherType. */
2246 * RTE_FLOW_ACTION_TYPE_OF_PUSH_MPLS
2248 * Implements OFPAT_PUSH_MPLS ("push a new MPLS tag") as defined by the
2249 * OpenFlow Switch Specification.
2251 struct rte_flow_action_of_push_mpls {
2252 rte_be16_t ethertype; /**< EtherType. */
2257 * @b EXPERIMENTAL: this structure may change without prior notice
2259 * RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP
2261 * VXLAN tunnel end-point encapsulation data definition
2263 * The tunnel definition is provided through the flow item pattern, the
2264 * provided pattern must conform to RFC7348 for the tunnel specified. The flow
2265 * definition must be provided in order from the RTE_FLOW_ITEM_TYPE_ETH
2266 * definition up the end item which is specified by RTE_FLOW_ITEM_TYPE_END.
2268 * The mask field allows user to specify which fields in the flow item
2269 * definitions can be ignored and which have valid data and can be used
2272 * Note: the last field is not used in the definition of a tunnel and can be
2275 * Valid flow definition for RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP include:
2277 * - ETH / IPV4 / UDP / VXLAN / END
2278 * - ETH / IPV6 / UDP / VXLAN / END
2279 * - ETH / VLAN / IPV4 / UDP / VXLAN / END
2282 struct rte_flow_action_vxlan_encap {
2284 * Encapsulating vxlan tunnel definition
2285 * (terminated by the END pattern item).
2287 struct rte_flow_item *definition;
2292 * @b EXPERIMENTAL: this structure may change without prior notice
2294 * RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP
2296 * NVGRE tunnel end-point encapsulation data definition
2298 * The tunnel definition is provided through the flow item pattern the
2299 * provided pattern must conform with RFC7637. The flow definition must be
2300 * provided in order from the RTE_FLOW_ITEM_TYPE_ETH definition up the end item
2301 * which is specified by RTE_FLOW_ITEM_TYPE_END.
2303 * The mask field allows user to specify which fields in the flow item
2304 * definitions can be ignored and which have valid data and can be used
2307 * Note: the last field is not used in the definition of a tunnel and can be
2310 * Valid flow definition for RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP include:
2312 * - ETH / IPV4 / NVGRE / END
2313 * - ETH / VLAN / IPV6 / NVGRE / END
2316 struct rte_flow_action_nvgre_encap {
2318 * Encapsulating vxlan tunnel definition
2319 * (terminated by the END pattern item).
2321 struct rte_flow_item *definition;
2326 * @b EXPERIMENTAL: this structure may change without prior notice
2328 * RTE_FLOW_ACTION_TYPE_RAW_ENCAP
2330 * Raw tunnel end-point encapsulation data definition.
2332 * The data holds the headers definitions to be applied on the packet.
2333 * The data must start with ETH header up to the tunnel item header itself.
2334 * When used right after RAW_DECAP (for decapsulating L3 tunnel type for
2335 * example MPLSoGRE) the data will just hold layer 2 header.
2337 * The preserve parameter holds which bits in the packet the PMD is not allowed
2338 * to change, this parameter can also be NULL and then the PMD is allowed
2339 * to update any field.
2341 * size holds the number of bytes in @p data and @p preserve.
2343 struct rte_flow_action_raw_encap {
2344 uint8_t *data; /**< Encapsulation data. */
2345 uint8_t *preserve; /**< Bit-mask of @p data to preserve on output. */
2346 size_t size; /**< Size of @p data and @p preserve. */
2351 * @b EXPERIMENTAL: this structure may change without prior notice
2353 * RTE_FLOW_ACTION_TYPE_RAW_DECAP
2355 * Raw tunnel end-point decapsulation data definition.
2357 * The data holds the headers definitions to be removed from the packet.
2358 * The data must start with ETH header up to the tunnel item header itself.
2359 * When used right before RAW_DECAP (for encapsulating L3 tunnel type for
2360 * example MPLSoGRE) the data will just hold layer 2 header.
2362 * size holds the number of bytes in @p data.
2364 struct rte_flow_action_raw_decap {
2365 uint8_t *data; /**< Encapsulation data. */
2366 size_t size; /**< Size of @p data and @p preserve. */
2371 * @b EXPERIMENTAL: this structure may change without prior notice
2373 * RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC
2374 * RTE_FLOW_ACTION_TYPE_SET_IPV4_DST
2376 * Allows modification of IPv4 source (RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC)
2377 * and destination address (RTE_FLOW_ACTION_TYPE_SET_IPV4_DST) in the
2378 * specified outermost IPv4 header.
2380 struct rte_flow_action_set_ipv4 {
2381 rte_be32_t ipv4_addr;
2386 * @b EXPERIMENTAL: this structure may change without prior notice
2388 * RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC
2389 * RTE_FLOW_ACTION_TYPE_SET_IPV6_DST
2391 * Allows modification of IPv6 source (RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC)
2392 * and destination address (RTE_FLOW_ACTION_TYPE_SET_IPV6_DST) in the
2393 * specified outermost IPv6 header.
2395 struct rte_flow_action_set_ipv6 {
2396 uint8_t ipv6_addr[16];
2401 * @b EXPERIMENTAL: this structure may change without prior notice
2403 * RTE_FLOW_ACTION_TYPE_SET_TP_SRC
2404 * RTE_FLOW_ACTION_TYPE_SET_TP_DST
2406 * Allows modification of source (RTE_FLOW_ACTION_TYPE_SET_TP_SRC)
2407 * and destination (RTE_FLOW_ACTION_TYPE_SET_TP_DST) port numbers
2408 * in the specified outermost TCP/UDP header.
2410 struct rte_flow_action_set_tp {
2415 * RTE_FLOW_ACTION_TYPE_SET_TTL
2417 * Set the TTL value directly for IPv4 or IPv6
2419 struct rte_flow_action_set_ttl {
2424 * RTE_FLOW_ACTION_TYPE_SET_MAC
2426 * Set MAC address from the matched flow
2428 struct rte_flow_action_set_mac {
2429 uint8_t mac_addr[RTE_ETHER_ADDR_LEN];
2433 * Definition of a single action.
2435 * A list of actions is terminated by a END action.
2437 * For simple actions without a configuration object, conf remains NULL.
2439 struct rte_flow_action {
2440 enum rte_flow_action_type type; /**< Action type. */
2441 const void *conf; /**< Pointer to action configuration object. */
2445 * Opaque type returned after successfully creating a flow.
2447 * This handle can be used to manage and query the related flow (e.g. to
2448 * destroy it or retrieve counters).
2453 * Verbose error types.
2455 * Most of them provide the type of the object referenced by struct
2456 * rte_flow_error.cause.
2458 enum rte_flow_error_type {
2459 RTE_FLOW_ERROR_TYPE_NONE, /**< No error. */
2460 RTE_FLOW_ERROR_TYPE_UNSPECIFIED, /**< Cause unspecified. */
2461 RTE_FLOW_ERROR_TYPE_HANDLE, /**< Flow rule (handle). */
2462 RTE_FLOW_ERROR_TYPE_ATTR_GROUP, /**< Group field. */
2463 RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY, /**< Priority field. */
2464 RTE_FLOW_ERROR_TYPE_ATTR_INGRESS, /**< Ingress field. */
2465 RTE_FLOW_ERROR_TYPE_ATTR_EGRESS, /**< Egress field. */
2466 RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, /**< Transfer field. */
2467 RTE_FLOW_ERROR_TYPE_ATTR, /**< Attributes structure. */
2468 RTE_FLOW_ERROR_TYPE_ITEM_NUM, /**< Pattern length. */
2469 RTE_FLOW_ERROR_TYPE_ITEM_SPEC, /**< Item specification. */
2470 RTE_FLOW_ERROR_TYPE_ITEM_LAST, /**< Item specification range. */
2471 RTE_FLOW_ERROR_TYPE_ITEM_MASK, /**< Item specification mask. */
2472 RTE_FLOW_ERROR_TYPE_ITEM, /**< Specific pattern item. */
2473 RTE_FLOW_ERROR_TYPE_ACTION_NUM, /**< Number of actions. */
2474 RTE_FLOW_ERROR_TYPE_ACTION_CONF, /**< Action configuration. */
2475 RTE_FLOW_ERROR_TYPE_ACTION, /**< Specific action. */
2479 * Verbose error structure definition.
2481 * This object is normally allocated by applications and set by PMDs, the
2482 * message points to a constant string which does not need to be freed by
2483 * the application, however its pointer can be considered valid only as long
2484 * as its associated DPDK port remains configured. Closing the underlying
2485 * device or unloading the PMD invalidates it.
2487 * Both cause and message may be NULL regardless of the error type.
2489 struct rte_flow_error {
2490 enum rte_flow_error_type type; /**< Cause field and error types. */
2491 const void *cause; /**< Object responsible for the error. */
2492 const char *message; /**< Human-readable error message. */
2496 * Complete flow rule description.
2498 * This object type is used when converting a flow rule description.
2500 * @see RTE_FLOW_CONV_OP_RULE
2501 * @see rte_flow_conv()
2504 struct rte_flow_conv_rule {
2506 const struct rte_flow_attr *attr_ro; /**< RO attributes. */
2507 struct rte_flow_attr *attr; /**< Attributes. */
2510 const struct rte_flow_item *pattern_ro; /**< RO pattern. */
2511 struct rte_flow_item *pattern; /**< Pattern items. */
2514 const struct rte_flow_action *actions_ro; /**< RO actions. */
2515 struct rte_flow_action *actions; /**< List of actions. */
2520 * Conversion operations for flow API objects.
2522 * @see rte_flow_conv()
2524 enum rte_flow_conv_op {
2526 * No operation to perform.
2528 * rte_flow_conv() simply returns 0.
2530 RTE_FLOW_CONV_OP_NONE,
2533 * Convert attributes structure.
2535 * This is a basic copy of an attributes structure.
2538 * @code const struct rte_flow_attr * @endcode
2540 * @code struct rte_flow_attr * @endcode
2542 RTE_FLOW_CONV_OP_ATTR,
2545 * Convert a single item.
2547 * Duplicates @p spec, @p last and @p mask but not outside objects.
2550 * @code const struct rte_flow_item * @endcode
2552 * @code struct rte_flow_item * @endcode
2554 RTE_FLOW_CONV_OP_ITEM,
2557 * Convert a single action.
2559 * Duplicates @p conf but not outside objects.
2562 * @code const struct rte_flow_action * @endcode
2564 * @code struct rte_flow_action * @endcode
2566 RTE_FLOW_CONV_OP_ACTION,
2569 * Convert an entire pattern.
2571 * Duplicates all pattern items at once with the same constraints as
2572 * RTE_FLOW_CONV_OP_ITEM.
2575 * @code const struct rte_flow_item * @endcode
2577 * @code struct rte_flow_item * @endcode
2579 RTE_FLOW_CONV_OP_PATTERN,
2582 * Convert a list of actions.
2584 * Duplicates the entire list of actions at once with the same
2585 * constraints as RTE_FLOW_CONV_OP_ACTION.
2588 * @code const struct rte_flow_action * @endcode
2590 * @code struct rte_flow_action * @endcode
2592 RTE_FLOW_CONV_OP_ACTIONS,
2595 * Convert a complete flow rule description.
2597 * Comprises attributes, pattern and actions together at once with
2598 * the usual constraints.
2601 * @code const struct rte_flow_conv_rule * @endcode
2603 * @code struct rte_flow_conv_rule * @endcode
2605 RTE_FLOW_CONV_OP_RULE,
2608 * Convert item type to its name string.
2610 * Writes a NUL-terminated string to @p dst. Like snprintf(), the
2611 * returned value excludes the terminator which is always written
2615 * @code (const void *)enum rte_flow_item_type @endcode
2617 * @code char * @endcode
2619 RTE_FLOW_CONV_OP_ITEM_NAME,
2622 * Convert action type to its name string.
2624 * Writes a NUL-terminated string to @p dst. Like snprintf(), the
2625 * returned value excludes the terminator which is always written
2629 * @code (const void *)enum rte_flow_action_type @endcode
2631 * @code char * @endcode
2633 RTE_FLOW_CONV_OP_ACTION_NAME,
2636 * Convert item type to pointer to item name.
2638 * Retrieves item name pointer from its type. The string itself is
2639 * not copied; instead, a unique pointer to an internal static
2640 * constant storage is written to @p dst.
2643 * @code (const void *)enum rte_flow_item_type @endcode
2645 * @code const char ** @endcode
2647 RTE_FLOW_CONV_OP_ITEM_NAME_PTR,
2650 * Convert action type to pointer to action name.
2652 * Retrieves action name pointer from its type. The string itself is
2653 * not copied; instead, a unique pointer to an internal static
2654 * constant storage is written to @p dst.
2657 * @code (const void *)enum rte_flow_action_type @endcode
2659 * @code const char ** @endcode
2661 RTE_FLOW_CONV_OP_ACTION_NAME_PTR,
2665 * Check whether a flow rule can be created on a given port.
2667 * The flow rule is validated for correctness and whether it could be accepted
2668 * by the device given sufficient resources. The rule is checked against the
2669 * current device mode and queue configuration. The flow rule may also
2670 * optionally be validated against existing flow rules and device resources.
2671 * This function has no effect on the target device.
2673 * The returned value is guaranteed to remain valid only as long as no
2674 * successful calls to rte_flow_create() or rte_flow_destroy() are made in
2675 * the meantime and no device parameter affecting flow rules in any way are
2676 * modified, due to possible collisions or resource limitations (although in
2677 * such cases EINVAL should not be returned).
2680 * Port identifier of Ethernet device.
2682 * Flow rule attributes.
2683 * @param[in] pattern
2684 * Pattern specification (list terminated by the END pattern item).
2685 * @param[in] actions
2686 * Associated actions (list terminated by the END action).
2688 * Perform verbose error reporting if not NULL. PMDs initialize this
2689 * structure in case of error only.
2692 * 0 if flow rule is valid and can be created. A negative errno value
2693 * otherwise (rte_errno is also set), the following errors are defined:
2695 * -ENOSYS: underlying device does not support this functionality.
2697 * -EIO: underlying device is removed.
2699 * -EINVAL: unknown or invalid rule specification.
2701 * -ENOTSUP: valid but unsupported rule specification (e.g. partial
2702 * bit-masks are unsupported).
2704 * -EEXIST: collision with an existing rule. Only returned if device
2705 * supports flow rule collision checking and there was a flow rule
2706 * collision. Not receiving this return code is no guarantee that creating
2707 * the rule will not fail due to a collision.
2709 * -ENOMEM: not enough memory to execute the function, or if the device
2710 * supports resource validation, resource limitation on the device.
2712 * -EBUSY: action cannot be performed due to busy device resources, may
2713 * succeed if the affected queues or even the entire port are in a stopped
2714 * state (see rte_eth_dev_rx_queue_stop() and rte_eth_dev_stop()).
2717 rte_flow_validate(uint16_t port_id,
2718 const struct rte_flow_attr *attr,
2719 const struct rte_flow_item pattern[],
2720 const struct rte_flow_action actions[],
2721 struct rte_flow_error *error);
2724 * Create a flow rule on a given port.
2727 * Port identifier of Ethernet device.
2729 * Flow rule attributes.
2730 * @param[in] pattern
2731 * Pattern specification (list terminated by the END pattern item).
2732 * @param[in] actions
2733 * Associated actions (list terminated by the END action).
2735 * Perform verbose error reporting if not NULL. PMDs initialize this
2736 * structure in case of error only.
2739 * A valid handle in case of success, NULL otherwise and rte_errno is set
2740 * to the positive version of one of the error codes defined for
2741 * rte_flow_validate().
2744 rte_flow_create(uint16_t port_id,
2745 const struct rte_flow_attr *attr,
2746 const struct rte_flow_item pattern[],
2747 const struct rte_flow_action actions[],
2748 struct rte_flow_error *error);
2751 * Destroy a flow rule on a given port.
2753 * Failure to destroy a flow rule handle may occur when other flow rules
2754 * depend on it, and destroying it would result in an inconsistent state.
2756 * This function is only guaranteed to succeed if handles are destroyed in
2757 * reverse order of their creation.
2760 * Port identifier of Ethernet device.
2762 * Flow rule handle to destroy.
2764 * Perform verbose error reporting if not NULL. PMDs initialize this
2765 * structure in case of error only.
2768 * 0 on success, a negative errno value otherwise and rte_errno is set.
2771 rte_flow_destroy(uint16_t port_id,
2772 struct rte_flow *flow,
2773 struct rte_flow_error *error);
2776 * Destroy all flow rules associated with a port.
2778 * In the unlikely event of failure, handles are still considered destroyed
2779 * and no longer valid but the port must be assumed to be in an inconsistent
2783 * Port identifier of Ethernet device.
2785 * Perform verbose error reporting if not NULL. PMDs initialize this
2786 * structure in case of error only.
2789 * 0 on success, a negative errno value otherwise and rte_errno is set.
2792 rte_flow_flush(uint16_t port_id,
2793 struct rte_flow_error *error);
2796 * Query an existing flow rule.
2798 * This function allows retrieving flow-specific data such as counters.
2799 * Data is gathered by special actions which must be present in the flow
2802 * \see RTE_FLOW_ACTION_TYPE_COUNT
2805 * Port identifier of Ethernet device.
2807 * Flow rule handle to query.
2809 * Action definition as defined in original flow rule.
2810 * @param[in, out] data
2811 * Pointer to storage for the associated query data type.
2813 * Perform verbose error reporting if not NULL. PMDs initialize this
2814 * structure in case of error only.
2817 * 0 on success, a negative errno value otherwise and rte_errno is set.
2820 rte_flow_query(uint16_t port_id,
2821 struct rte_flow *flow,
2822 const struct rte_flow_action *action,
2824 struct rte_flow_error *error);
2827 * Restrict ingress traffic to the defined flow rules.
2829 * Isolated mode guarantees that all ingress traffic comes from defined flow
2830 * rules only (current and future).
2832 * Besides making ingress more deterministic, it allows PMDs to safely reuse
2833 * resources otherwise assigned to handle the remaining traffic, such as
2834 * global RSS configuration settings, VLAN filters, MAC address entries,
2835 * legacy filter API rules and so on in order to expand the set of possible
2838 * Calling this function as soon as possible after device initialization,
2839 * ideally before the first call to rte_eth_dev_configure(), is recommended
2840 * to avoid possible failures due to conflicting settings.
2842 * Once effective, leaving isolated mode may not be possible depending on
2843 * PMD implementation.
2845 * Additionally, the following functionality has no effect on the underlying
2846 * port and may return errors such as ENOTSUP ("not supported"):
2848 * - Toggling promiscuous mode.
2849 * - Toggling allmulticast mode.
2850 * - Configuring MAC addresses.
2851 * - Configuring multicast addresses.
2852 * - Configuring VLAN filters.
2853 * - Configuring Rx filters through the legacy API (e.g. FDIR).
2854 * - Configuring global RSS settings.
2857 * Port identifier of Ethernet device.
2859 * Nonzero to enter isolated mode, attempt to leave it otherwise.
2861 * Perform verbose error reporting if not NULL. PMDs initialize this
2862 * structure in case of error only.
2865 * 0 on success, a negative errno value otherwise and rte_errno is set.
2868 rte_flow_isolate(uint16_t port_id, int set, struct rte_flow_error *error);
2871 * Initialize flow error structure.
2874 * Pointer to flow error structure (may be NULL).
2876 * Related error code (rte_errno).
2878 * Cause field and error types.
2880 * Object responsible for the error.
2882 * Human-readable error message.
2885 * Negative error code (errno value) and rte_errno is set.
2888 rte_flow_error_set(struct rte_flow_error *error,
2890 enum rte_flow_error_type type,
2892 const char *message);
2896 * @see rte_flow_copy()
2898 struct rte_flow_desc {
2899 size_t size; /**< Allocated space including data[]. */
2900 struct rte_flow_attr attr; /**< Attributes. */
2901 struct rte_flow_item *items; /**< Items. */
2902 struct rte_flow_action *actions; /**< Actions. */
2903 uint8_t data[]; /**< Storage for items/actions. */
2908 * Copy an rte_flow rule description.
2910 * This interface is kept for compatibility with older applications but is
2911 * implemented as a wrapper to rte_flow_conv(). It is deprecated due to its
2912 * lack of flexibility and reliance on a type unusable with C++ programs
2913 * (struct rte_flow_desc).
2916 * Flow rule description.
2918 * Total size of allocated data for the flow description.
2920 * Flow rule attributes.
2922 * Pattern specification (list terminated by the END pattern item).
2923 * @param[in] actions
2924 * Associated actions (list terminated by the END action).
2927 * If len is greater or equal to the size of the flow, the total size of the
2928 * flow description and its data.
2929 * If len is lower than the size of the flow, the number of bytes that would
2930 * have been written to desc had it been sufficient. Nothing is written.
2934 rte_flow_copy(struct rte_flow_desc *fd, size_t len,
2935 const struct rte_flow_attr *attr,
2936 const struct rte_flow_item *items,
2937 const struct rte_flow_action *actions);
2940 * Flow object conversion helper.
2942 * This function performs conversion of various flow API objects to a
2943 * pre-allocated destination buffer. See enum rte_flow_conv_op for possible
2944 * operations and details about each of them.
2946 * Since destination buffer must be large enough, it works in a manner
2947 * reminiscent of snprintf():
2949 * - If @p size is 0, @p dst may be a NULL pointer, otherwise @p dst must be
2951 * - If positive, the returned value represents the number of bytes needed
2952 * to store the conversion of @p src to @p dst according to @p op
2953 * regardless of the @p size parameter.
2954 * - Since no more than @p size bytes can be written to @p dst, output is
2955 * truncated and may be inconsistent when the returned value is larger
2957 * - In case of conversion error, a negative error code is returned and
2958 * @p dst contents are unspecified.
2961 * Operation to perform, related to the object type of @p dst.
2963 * Destination buffer address. Must be suitably aligned by the caller.
2965 * Destination buffer size in bytes.
2967 * Source object to copy. Depending on @p op, its type may differ from
2970 * Perform verbose error reporting if not NULL. Initialized in case of
2974 * The number of bytes required to convert @p src to @p dst on success, a
2975 * negative errno value otherwise and rte_errno is set.
2977 * @see rte_flow_conv_op
2981 rte_flow_conv(enum rte_flow_conv_op op,
2985 struct rte_flow_error *error);
2991 #endif /* RTE_FLOW_H_ */