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>
36 * Flow rule attributes.
38 * Priorities are set on a per rule based within groups.
40 * Lower values denote higher priority, the highest priority for a flow rule
41 * is 0, so that a flow that matches for than one rule, the rule with the
42 * lowest priority value will always be matched.
44 * Although optional, applications are encouraged to group similar rules as
45 * much as possible to fully take advantage of hardware capabilities
46 * (e.g. optimized matching) and work around limitations (e.g. a single
47 * pattern type possibly allowed in a given group). Applications should be
48 * aware that groups are not linked by default, and that they must be
49 * explicitly linked by the application using the JUMP action.
51 * Priority levels are arbitrary and up to the application, they
52 * do not need to be contiguous nor start from 0, however the maximum number
53 * varies between devices and may be affected by existing flow rules.
55 * If a packet is matched by several rules of a given group for a given
56 * priority level, the outcome is undefined. It can take any path, may be
57 * duplicated or even cause unrecoverable errors.
59 * Note that support for more than a single group and priority level is not
62 * Flow rules can apply to inbound and/or outbound traffic (ingress/egress).
64 * Several pattern items and actions are valid and can be used in both
65 * directions. Those valid for only one direction are described as such.
67 * At least one direction must be specified.
69 * Specifying both directions at once for a given rule is not recommended
70 * but may be valid in a few cases (e.g. shared counter).
72 struct rte_flow_attr {
73 uint32_t group; /**< Priority group. */
74 uint32_t priority; /**< Rule priority level within group. */
75 uint32_t ingress:1; /**< Rule applies to ingress traffic. */
76 uint32_t egress:1; /**< Rule applies to egress traffic. */
78 * Instead of simply matching the properties of traffic as it would
79 * appear on a given DPDK port ID, enabling this attribute transfers
80 * a flow rule to the lowest possible level of any device endpoints
81 * found in the pattern.
83 * When supported, this effectively enables an application to
84 * re-route traffic not necessarily intended for it (e.g. coming
85 * from or addressed to different physical ports, VFs or
86 * applications) at the device level.
88 * It complements the behavior of some pattern items such as
89 * RTE_FLOW_ITEM_TYPE_PHY_PORT and is meaningless without them.
91 * When transferring flow rules, ingress and egress attributes keep
92 * their original meaning, as if processing traffic emitted or
93 * received by the application.
96 uint32_t reserved:29; /**< Reserved, must be zero. */
100 * Matching pattern item types.
102 * Pattern items fall in two categories:
104 * - Matching protocol headers and packet data, usually associated with a
105 * specification structure. These must be stacked in the same order as the
106 * protocol layers to match inside packets, starting from the lowest.
108 * - Matching meta-data or affecting pattern processing, often without a
109 * specification structure. Since they do not match packet contents, their
110 * position in the list is usually not relevant.
112 * See the description of individual types for more information. Those
113 * marked with [META] fall into the second category.
115 enum rte_flow_item_type {
119 * End marker for item lists. Prevents further processing of items,
120 * thereby ending the pattern.
122 * No associated specification structure.
124 RTE_FLOW_ITEM_TYPE_END,
129 * Used as a placeholder for convenience. It is ignored and simply
132 * No associated specification structure.
134 RTE_FLOW_ITEM_TYPE_VOID,
139 * Inverted matching, i.e. process packets that do not match the
142 * No associated specification structure.
144 RTE_FLOW_ITEM_TYPE_INVERT,
147 * Matches any protocol in place of the current layer, a single ANY
148 * may also stand for several protocol layers.
150 * See struct rte_flow_item_any.
152 RTE_FLOW_ITEM_TYPE_ANY,
157 * Matches traffic originating from (ingress) or going to (egress)
158 * the physical function of the current device.
160 * No associated specification structure.
162 RTE_FLOW_ITEM_TYPE_PF,
167 * Matches traffic originating from (ingress) or going to (egress) a
168 * given virtual function of the current device.
170 * See struct rte_flow_item_vf.
172 RTE_FLOW_ITEM_TYPE_VF,
177 * Matches traffic originating from (ingress) or going to (egress) a
178 * physical port of the underlying device.
180 * See struct rte_flow_item_phy_port.
182 RTE_FLOW_ITEM_TYPE_PHY_PORT,
187 * Matches traffic originating from (ingress) or going to (egress) a
188 * given DPDK port ID.
190 * See struct rte_flow_item_port_id.
192 RTE_FLOW_ITEM_TYPE_PORT_ID,
195 * Matches a byte string of a given length at a given offset.
197 * See struct rte_flow_item_raw.
199 RTE_FLOW_ITEM_TYPE_RAW,
202 * Matches an Ethernet header.
204 * See struct rte_flow_item_eth.
206 RTE_FLOW_ITEM_TYPE_ETH,
209 * Matches an 802.1Q/ad VLAN tag.
211 * See struct rte_flow_item_vlan.
213 RTE_FLOW_ITEM_TYPE_VLAN,
216 * Matches an IPv4 header.
218 * See struct rte_flow_item_ipv4.
220 RTE_FLOW_ITEM_TYPE_IPV4,
223 * Matches an IPv6 header.
225 * See struct rte_flow_item_ipv6.
227 RTE_FLOW_ITEM_TYPE_IPV6,
230 * Matches an ICMP header.
232 * See struct rte_flow_item_icmp.
234 RTE_FLOW_ITEM_TYPE_ICMP,
237 * Matches a UDP header.
239 * See struct rte_flow_item_udp.
241 RTE_FLOW_ITEM_TYPE_UDP,
244 * Matches a TCP header.
246 * See struct rte_flow_item_tcp.
248 RTE_FLOW_ITEM_TYPE_TCP,
251 * Matches a SCTP header.
253 * See struct rte_flow_item_sctp.
255 RTE_FLOW_ITEM_TYPE_SCTP,
258 * Matches a VXLAN header.
260 * See struct rte_flow_item_vxlan.
262 RTE_FLOW_ITEM_TYPE_VXLAN,
265 * Matches a E_TAG header.
267 * See struct rte_flow_item_e_tag.
269 RTE_FLOW_ITEM_TYPE_E_TAG,
272 * Matches a NVGRE header.
274 * See struct rte_flow_item_nvgre.
276 RTE_FLOW_ITEM_TYPE_NVGRE,
279 * Matches a MPLS header.
281 * See struct rte_flow_item_mpls.
283 RTE_FLOW_ITEM_TYPE_MPLS,
286 * Matches a GRE header.
288 * See struct rte_flow_item_gre.
290 RTE_FLOW_ITEM_TYPE_GRE,
295 * Fuzzy pattern match, expect faster than default.
297 * This is for device that support fuzzy matching option.
298 * Usually a fuzzy matching is fast but the cost is accuracy.
300 * See struct rte_flow_item_fuzzy.
302 RTE_FLOW_ITEM_TYPE_FUZZY,
305 * Matches a GTP header.
307 * Configure flow for GTP packets.
309 * See struct rte_flow_item_gtp.
311 RTE_FLOW_ITEM_TYPE_GTP,
314 * Matches a GTP header.
316 * Configure flow for GTP-C packets.
318 * See struct rte_flow_item_gtp.
320 RTE_FLOW_ITEM_TYPE_GTPC,
323 * Matches a GTP header.
325 * Configure flow for GTP-U packets.
327 * See struct rte_flow_item_gtp.
329 RTE_FLOW_ITEM_TYPE_GTPU,
332 * Matches a ESP header.
334 * See struct rte_flow_item_esp.
336 RTE_FLOW_ITEM_TYPE_ESP,
339 * Matches a GENEVE header.
341 * See struct rte_flow_item_geneve.
343 RTE_FLOW_ITEM_TYPE_GENEVE,
346 * Matches a VXLAN-GPE header.
348 * See struct rte_flow_item_vxlan_gpe.
350 RTE_FLOW_ITEM_TYPE_VXLAN_GPE,
353 * Matches an ARP header for Ethernet/IPv4.
355 * See struct rte_flow_item_arp_eth_ipv4.
357 RTE_FLOW_ITEM_TYPE_ARP_ETH_IPV4,
360 * Matches the presence of any IPv6 extension header.
362 * See struct rte_flow_item_ipv6_ext.
364 RTE_FLOW_ITEM_TYPE_IPV6_EXT,
367 * Matches any ICMPv6 header.
369 * See struct rte_flow_item_icmp6.
371 RTE_FLOW_ITEM_TYPE_ICMP6,
374 * Matches an ICMPv6 neighbor discovery solicitation.
376 * See struct rte_flow_item_icmp6_nd_ns.
378 RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS,
381 * Matches an ICMPv6 neighbor discovery advertisement.
383 * See struct rte_flow_item_icmp6_nd_na.
385 RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA,
388 * Matches the presence of any ICMPv6 neighbor discovery option.
390 * See struct rte_flow_item_icmp6_nd_opt.
392 RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT,
395 * Matches an ICMPv6 neighbor discovery source Ethernet link-layer
398 * See struct rte_flow_item_icmp6_nd_opt_sla_eth.
400 RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_SLA_ETH,
403 * Matches an ICMPv6 neighbor discovery target Ethernet link-layer
406 * See struct rte_flow_item_icmp6_nd_opt_tla_eth.
408 RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_TLA_ETH,
411 * Matches specified mark field.
413 * See struct rte_flow_item_mark.
415 RTE_FLOW_ITEM_TYPE_MARK,
420 * Matches a metadata value specified in mbuf metadata field.
421 * See struct rte_flow_item_meta.
423 RTE_FLOW_ITEM_TYPE_META,
426 * Matches a GRE optional key field.
428 * The value should a big-endian 32bit integer.
430 * When this item present the K bit is implicitly matched as "1"
431 * in the default mask.
434 * @code rte_be32_t * @endcode
436 RTE_FLOW_ITEM_TYPE_GRE_KEY,
439 * Matches a GTP extension header: PDU session container.
441 * Configure flow for GTP packets with extension header type 0x85.
443 * See struct rte_flow_item_gtp_psc.
445 RTE_FLOW_ITEM_TYPE_GTP_PSC,
448 * Matches a PPPoE header.
450 * Configure flow for PPPoE session packets.
452 * See struct rte_flow_item_pppoe.
454 RTE_FLOW_ITEM_TYPE_PPPOES,
457 * Matches a PPPoE header.
459 * Configure flow for PPPoE discovery packets.
461 * See struct rte_flow_item_pppoe.
463 RTE_FLOW_ITEM_TYPE_PPPOED,
466 * Matches a PPPoE optional proto_id field.
468 * It only applies to PPPoE session packets.
470 * See struct rte_flow_item_pppoe_proto_id.
472 RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID,
475 * Matches Network service header (NSH).
476 * See struct rte_flow_item_nsh.
479 RTE_FLOW_ITEM_TYPE_NSH,
482 * Matches Internet Group Management Protocol (IGMP).
483 * See struct rte_flow_item_igmp.
486 RTE_FLOW_ITEM_TYPE_IGMP,
489 * Matches IP Authentication Header (AH).
490 * See struct rte_flow_item_ah.
493 RTE_FLOW_ITEM_TYPE_AH,
497 * RTE_FLOW_ITEM_TYPE_ANY
499 * Matches any protocol in place of the current layer, a single ANY may also
500 * stand for several protocol layers.
502 * This is usually specified as the first pattern item when looking for a
503 * protocol anywhere in a packet.
505 * A zeroed mask stands for any number of layers.
507 struct rte_flow_item_any {
508 uint32_t num; /**< Number of layers covered. */
511 /** Default mask for RTE_FLOW_ITEM_TYPE_ANY. */
513 static const struct rte_flow_item_any rte_flow_item_any_mask = {
519 * RTE_FLOW_ITEM_TYPE_VF
521 * Matches traffic originating from (ingress) or going to (egress) a given
522 * virtual function of the current device.
524 * If supported, should work even if the virtual function is not managed by
525 * the application and thus not associated with a DPDK port ID.
527 * Note this pattern item does not match VF representors traffic which, as
528 * separate entities, should be addressed through their own DPDK port IDs.
530 * - Can be specified multiple times to match traffic addressed to several
532 * - Can be combined with a PF item to match both PF and VF traffic.
534 * A zeroed mask can be used to match any VF ID.
536 struct rte_flow_item_vf {
537 uint32_t id; /**< VF ID. */
540 /** Default mask for RTE_FLOW_ITEM_TYPE_VF. */
542 static const struct rte_flow_item_vf rte_flow_item_vf_mask = {
548 * RTE_FLOW_ITEM_TYPE_PHY_PORT
550 * Matches traffic originating from (ingress) or going to (egress) a
551 * physical port of the underlying device.
553 * The first PHY_PORT item overrides the physical port normally associated
554 * with the specified DPDK input port (port_id). This item can be provided
555 * several times to match additional physical ports.
557 * Note that physical ports are not necessarily tied to DPDK input ports
558 * (port_id) when those are not under DPDK control. Possible values are
559 * specific to each device, they are not necessarily indexed from zero and
560 * may not be contiguous.
562 * As a device property, the list of allowed values as well as the value
563 * associated with a port_id should be retrieved by other means.
565 * A zeroed mask can be used to match any port index.
567 struct rte_flow_item_phy_port {
568 uint32_t index; /**< Physical port index. */
571 /** Default mask for RTE_FLOW_ITEM_TYPE_PHY_PORT. */
573 static const struct rte_flow_item_phy_port rte_flow_item_phy_port_mask = {
579 * RTE_FLOW_ITEM_TYPE_PORT_ID
581 * Matches traffic originating from (ingress) or going to (egress) a given
584 * Normally only supported if the port ID in question is known by the
585 * underlying PMD and related to the device the flow rule is created
588 * This must not be confused with @p PHY_PORT which refers to the physical
589 * port of a device, whereas @p PORT_ID refers to a struct rte_eth_dev
590 * object on the application side (also known as "port representor"
591 * depending on the kind of underlying device).
593 struct rte_flow_item_port_id {
594 uint32_t id; /**< DPDK port ID. */
597 /** Default mask for RTE_FLOW_ITEM_TYPE_PORT_ID. */
599 static const struct rte_flow_item_port_id rte_flow_item_port_id_mask = {
605 * RTE_FLOW_ITEM_TYPE_RAW
607 * Matches a byte string of a given length at a given offset.
609 * Offset is either absolute (using the start of the packet) or relative to
610 * the end of the previous matched item in the stack, in which case negative
611 * values are allowed.
613 * If search is enabled, offset is used as the starting point. The search
614 * area can be delimited by setting limit to a nonzero value, which is the
615 * maximum number of bytes after offset where the pattern may start.
617 * Matching a zero-length pattern is allowed, doing so resets the relative
618 * offset for subsequent items.
620 * This type does not support ranges (struct rte_flow_item.last).
622 struct rte_flow_item_raw {
623 uint32_t relative:1; /**< Look for pattern after the previous item. */
624 uint32_t search:1; /**< Search pattern from offset (see also limit). */
625 uint32_t reserved:30; /**< Reserved, must be set to zero. */
626 int32_t offset; /**< Absolute or relative offset for pattern. */
627 uint16_t limit; /**< Search area limit for start of pattern. */
628 uint16_t length; /**< Pattern length. */
629 const uint8_t *pattern; /**< Byte string to look for. */
632 /** Default mask for RTE_FLOW_ITEM_TYPE_RAW. */
634 static const struct rte_flow_item_raw rte_flow_item_raw_mask = {
637 .reserved = 0x3fffffff,
638 .offset = 0xffffffff,
646 * RTE_FLOW_ITEM_TYPE_ETH
648 * Matches an Ethernet header.
650 * The @p type field either stands for "EtherType" or "TPID" when followed
651 * by so-called layer 2.5 pattern items such as RTE_FLOW_ITEM_TYPE_VLAN. In
652 * the latter case, @p type refers to that of the outer header, with the
653 * inner EtherType/TPID provided by the subsequent pattern item. This is the
654 * same order as on the wire.
656 struct rte_flow_item_eth {
657 struct rte_ether_addr dst; /**< Destination MAC. */
658 struct rte_ether_addr src; /**< Source MAC. */
659 rte_be16_t type; /**< EtherType or TPID. */
662 /** Default mask for RTE_FLOW_ITEM_TYPE_ETH. */
664 static const struct rte_flow_item_eth rte_flow_item_eth_mask = {
665 .dst.addr_bytes = "\xff\xff\xff\xff\xff\xff",
666 .src.addr_bytes = "\xff\xff\xff\xff\xff\xff",
667 .type = RTE_BE16(0x0000),
672 * RTE_FLOW_ITEM_TYPE_VLAN
674 * Matches an 802.1Q/ad VLAN tag.
676 * The corresponding standard outer EtherType (TPID) values are
677 * RTE_ETHER_TYPE_VLAN or RTE_ETHER_TYPE_QINQ. It can be overridden by
678 * the preceding pattern item.
680 struct rte_flow_item_vlan {
681 rte_be16_t tci; /**< Tag control information. */
682 rte_be16_t inner_type; /**< Inner EtherType or TPID. */
685 /** Default mask for RTE_FLOW_ITEM_TYPE_VLAN. */
687 static const struct rte_flow_item_vlan rte_flow_item_vlan_mask = {
688 .tci = RTE_BE16(0x0fff),
689 .inner_type = RTE_BE16(0x0000),
694 * RTE_FLOW_ITEM_TYPE_IPV4
696 * Matches an IPv4 header.
698 * Note: IPv4 options are handled by dedicated pattern items.
700 struct rte_flow_item_ipv4 {
701 struct rte_ipv4_hdr hdr; /**< IPv4 header definition. */
704 /** Default mask for RTE_FLOW_ITEM_TYPE_IPV4. */
706 static const struct rte_flow_item_ipv4 rte_flow_item_ipv4_mask = {
708 .src_addr = RTE_BE32(0xffffffff),
709 .dst_addr = RTE_BE32(0xffffffff),
715 * RTE_FLOW_ITEM_TYPE_IPV6.
717 * Matches an IPv6 header.
719 * Note: IPv6 options are handled by dedicated pattern items, see
720 * RTE_FLOW_ITEM_TYPE_IPV6_EXT.
722 struct rte_flow_item_ipv6 {
723 struct rte_ipv6_hdr hdr; /**< IPv6 header definition. */
726 /** Default mask for RTE_FLOW_ITEM_TYPE_IPV6. */
728 static const struct rte_flow_item_ipv6 rte_flow_item_ipv6_mask = {
731 "\xff\xff\xff\xff\xff\xff\xff\xff"
732 "\xff\xff\xff\xff\xff\xff\xff\xff",
734 "\xff\xff\xff\xff\xff\xff\xff\xff"
735 "\xff\xff\xff\xff\xff\xff\xff\xff",
741 * RTE_FLOW_ITEM_TYPE_ICMP.
743 * Matches an ICMP header.
745 struct rte_flow_item_icmp {
746 struct rte_icmp_hdr hdr; /**< ICMP header definition. */
749 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP. */
751 static const struct rte_flow_item_icmp rte_flow_item_icmp_mask = {
760 * RTE_FLOW_ITEM_TYPE_UDP.
762 * Matches a UDP header.
764 struct rte_flow_item_udp {
765 struct rte_udp_hdr hdr; /**< UDP header definition. */
768 /** Default mask for RTE_FLOW_ITEM_TYPE_UDP. */
770 static const struct rte_flow_item_udp rte_flow_item_udp_mask = {
772 .src_port = RTE_BE16(0xffff),
773 .dst_port = RTE_BE16(0xffff),
779 * RTE_FLOW_ITEM_TYPE_TCP.
781 * Matches a TCP header.
783 struct rte_flow_item_tcp {
784 struct rte_tcp_hdr hdr; /**< TCP header definition. */
787 /** Default mask for RTE_FLOW_ITEM_TYPE_TCP. */
789 static const struct rte_flow_item_tcp rte_flow_item_tcp_mask = {
791 .src_port = RTE_BE16(0xffff),
792 .dst_port = RTE_BE16(0xffff),
798 * RTE_FLOW_ITEM_TYPE_SCTP.
800 * Matches a SCTP header.
802 struct rte_flow_item_sctp {
803 struct rte_sctp_hdr hdr; /**< SCTP header definition. */
806 /** Default mask for RTE_FLOW_ITEM_TYPE_SCTP. */
808 static const struct rte_flow_item_sctp rte_flow_item_sctp_mask = {
810 .src_port = RTE_BE16(0xffff),
811 .dst_port = RTE_BE16(0xffff),
817 * RTE_FLOW_ITEM_TYPE_VXLAN.
819 * Matches a VXLAN header (RFC 7348).
821 struct rte_flow_item_vxlan {
822 uint8_t flags; /**< Normally 0x08 (I flag). */
823 uint8_t rsvd0[3]; /**< Reserved, normally 0x000000. */
824 uint8_t vni[3]; /**< VXLAN identifier. */
825 uint8_t rsvd1; /**< Reserved, normally 0x00. */
828 /** Default mask for RTE_FLOW_ITEM_TYPE_VXLAN. */
830 static const struct rte_flow_item_vxlan rte_flow_item_vxlan_mask = {
831 .vni = "\xff\xff\xff",
836 * RTE_FLOW_ITEM_TYPE_E_TAG.
838 * Matches a E-tag header.
840 * The corresponding standard outer EtherType (TPID) value is
841 * RTE_ETHER_TYPE_ETAG. It can be overridden by the preceding pattern item.
843 struct rte_flow_item_e_tag {
845 * E-Tag control information (E-TCI).
846 * E-PCP (3b), E-DEI (1b), ingress E-CID base (12b).
848 rte_be16_t epcp_edei_in_ecid_b;
849 /** Reserved (2b), GRP (2b), E-CID base (12b). */
850 rte_be16_t rsvd_grp_ecid_b;
851 uint8_t in_ecid_e; /**< Ingress E-CID ext. */
852 uint8_t ecid_e; /**< E-CID ext. */
853 rte_be16_t inner_type; /**< Inner EtherType or TPID. */
856 /** Default mask for RTE_FLOW_ITEM_TYPE_E_TAG. */
858 static const struct rte_flow_item_e_tag rte_flow_item_e_tag_mask = {
859 .rsvd_grp_ecid_b = RTE_BE16(0x3fff),
864 * RTE_FLOW_ITEM_TYPE_NVGRE.
866 * Matches a NVGRE header.
868 struct rte_flow_item_nvgre {
870 * Checksum (1b), undefined (1b), key bit (1b), sequence number (1b),
871 * reserved 0 (9b), version (3b).
873 * c_k_s_rsvd0_ver must have value 0x2000 according to RFC 7637.
875 rte_be16_t c_k_s_rsvd0_ver;
876 rte_be16_t protocol; /**< Protocol type (0x6558). */
877 uint8_t tni[3]; /**< Virtual subnet ID. */
878 uint8_t flow_id; /**< Flow ID. */
881 /** Default mask for RTE_FLOW_ITEM_TYPE_NVGRE. */
883 static const struct rte_flow_item_nvgre rte_flow_item_nvgre_mask = {
884 .tni = "\xff\xff\xff",
889 * RTE_FLOW_ITEM_TYPE_MPLS.
891 * Matches a MPLS header.
893 struct rte_flow_item_mpls {
895 * Label (20b), TC (3b), Bottom of Stack (1b).
897 uint8_t label_tc_s[3];
898 uint8_t ttl; /** Time-to-Live. */
901 /** Default mask for RTE_FLOW_ITEM_TYPE_MPLS. */
903 static const struct rte_flow_item_mpls rte_flow_item_mpls_mask = {
904 .label_tc_s = "\xff\xff\xf0",
909 * RTE_FLOW_ITEM_TYPE_GRE.
911 * Matches a GRE header.
913 struct rte_flow_item_gre {
915 * Checksum (1b), reserved 0 (12b), version (3b).
918 rte_be16_t c_rsvd0_ver;
919 rte_be16_t protocol; /**< Protocol type. */
922 /** Default mask for RTE_FLOW_ITEM_TYPE_GRE. */
924 static const struct rte_flow_item_gre rte_flow_item_gre_mask = {
925 .protocol = RTE_BE16(0xffff),
930 * RTE_FLOW_ITEM_TYPE_FUZZY
932 * Fuzzy pattern match, expect faster than default.
934 * This is for device that support fuzzy match option.
935 * Usually a fuzzy match is fast but the cost is accuracy.
936 * i.e. Signature Match only match pattern's hash value, but it is
937 * possible two different patterns have the same hash value.
939 * Matching accuracy level can be configure by threshold.
940 * Driver can divide the range of threshold and map to different
941 * accuracy levels that device support.
943 * Threshold 0 means perfect match (no fuzziness), while threshold
944 * 0xffffffff means fuzziest match.
946 struct rte_flow_item_fuzzy {
947 uint32_t thresh; /**< Accuracy threshold. */
950 /** Default mask for RTE_FLOW_ITEM_TYPE_FUZZY. */
952 static const struct rte_flow_item_fuzzy rte_flow_item_fuzzy_mask = {
953 .thresh = 0xffffffff,
958 * RTE_FLOW_ITEM_TYPE_GTP.
960 * Matches a GTPv1 header.
962 struct rte_flow_item_gtp {
964 * Version (3b), protocol type (1b), reserved (1b),
965 * Extension header flag (1b),
966 * Sequence number flag (1b),
967 * N-PDU number flag (1b).
969 uint8_t v_pt_rsv_flags;
970 uint8_t msg_type; /**< Message type. */
971 rte_be16_t msg_len; /**< Message length. */
972 rte_be32_t teid; /**< Tunnel endpoint identifier. */
975 /** Default mask for RTE_FLOW_ITEM_TYPE_GTP. */
977 static const struct rte_flow_item_gtp rte_flow_item_gtp_mask = {
978 .teid = RTE_BE32(0xffffffff),
983 * RTE_FLOW_ITEM_TYPE_ESP
985 * Matches an ESP header.
987 struct rte_flow_item_esp {
988 struct rte_esp_hdr hdr; /**< ESP header definition. */
991 /** Default mask for RTE_FLOW_ITEM_TYPE_ESP. */
993 static const struct rte_flow_item_esp rte_flow_item_esp_mask = {
995 .spi = RTE_BE32(0xffffffff),
1001 * RTE_FLOW_ITEM_TYPE_GENEVE.
1003 * Matches a GENEVE header.
1005 struct rte_flow_item_geneve {
1007 * Version (2b), length of the options fields (6b), OAM packet (1b),
1008 * critical options present (1b), reserved 0 (6b).
1010 rte_be16_t ver_opt_len_o_c_rsvd0;
1011 rte_be16_t protocol; /**< Protocol type. */
1012 uint8_t vni[3]; /**< Virtual Network Identifier. */
1013 uint8_t rsvd1; /**< Reserved, normally 0x00. */
1016 /** Default mask for RTE_FLOW_ITEM_TYPE_GENEVE. */
1018 static const struct rte_flow_item_geneve rte_flow_item_geneve_mask = {
1019 .vni = "\xff\xff\xff",
1024 * RTE_FLOW_ITEM_TYPE_VXLAN_GPE (draft-ietf-nvo3-vxlan-gpe-05).
1026 * Matches a VXLAN-GPE header.
1028 struct rte_flow_item_vxlan_gpe {
1029 uint8_t flags; /**< Normally 0x0c (I and P flags). */
1030 uint8_t rsvd0[2]; /**< Reserved, normally 0x0000. */
1031 uint8_t protocol; /**< Protocol type. */
1032 uint8_t vni[3]; /**< VXLAN identifier. */
1033 uint8_t rsvd1; /**< Reserved, normally 0x00. */
1036 /** Default mask for RTE_FLOW_ITEM_TYPE_VXLAN_GPE. */
1038 static const struct rte_flow_item_vxlan_gpe rte_flow_item_vxlan_gpe_mask = {
1039 .vni = "\xff\xff\xff",
1044 * RTE_FLOW_ITEM_TYPE_ARP_ETH_IPV4
1046 * Matches an ARP header for Ethernet/IPv4.
1048 struct rte_flow_item_arp_eth_ipv4 {
1049 rte_be16_t hrd; /**< Hardware type, normally 1. */
1050 rte_be16_t pro; /**< Protocol type, normally 0x0800. */
1051 uint8_t hln; /**< Hardware address length, normally 6. */
1052 uint8_t pln; /**< Protocol address length, normally 4. */
1053 rte_be16_t op; /**< Opcode (1 for request, 2 for reply). */
1054 struct rte_ether_addr sha; /**< Sender hardware address. */
1055 rte_be32_t spa; /**< Sender IPv4 address. */
1056 struct rte_ether_addr tha; /**< Target hardware address. */
1057 rte_be32_t tpa; /**< Target IPv4 address. */
1060 /** Default mask for RTE_FLOW_ITEM_TYPE_ARP_ETH_IPV4. */
1062 static const struct rte_flow_item_arp_eth_ipv4
1063 rte_flow_item_arp_eth_ipv4_mask = {
1064 .sha.addr_bytes = "\xff\xff\xff\xff\xff\xff",
1065 .spa = RTE_BE32(0xffffffff),
1066 .tha.addr_bytes = "\xff\xff\xff\xff\xff\xff",
1067 .tpa = RTE_BE32(0xffffffff),
1072 * RTE_FLOW_ITEM_TYPE_IPV6_EXT
1074 * Matches the presence of any IPv6 extension header.
1076 * Normally preceded by any of:
1078 * - RTE_FLOW_ITEM_TYPE_IPV6
1079 * - RTE_FLOW_ITEM_TYPE_IPV6_EXT
1081 struct rte_flow_item_ipv6_ext {
1082 uint8_t next_hdr; /**< Next header. */
1085 /** Default mask for RTE_FLOW_ITEM_TYPE_IPV6_EXT. */
1088 struct rte_flow_item_ipv6_ext rte_flow_item_ipv6_ext_mask = {
1094 * RTE_FLOW_ITEM_TYPE_ICMP6
1096 * Matches any ICMPv6 header.
1098 struct rte_flow_item_icmp6 {
1099 uint8_t type; /**< ICMPv6 type. */
1100 uint8_t code; /**< ICMPv6 code. */
1101 uint16_t checksum; /**< ICMPv6 checksum. */
1104 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6. */
1106 static const struct rte_flow_item_icmp6 rte_flow_item_icmp6_mask = {
1113 * RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS
1115 * Matches an ICMPv6 neighbor discovery solicitation.
1117 struct rte_flow_item_icmp6_nd_ns {
1118 uint8_t type; /**< ICMPv6 type, normally 135. */
1119 uint8_t code; /**< ICMPv6 code, normally 0. */
1120 rte_be16_t checksum; /**< ICMPv6 checksum. */
1121 rte_be32_t reserved; /**< Reserved, normally 0. */
1122 uint8_t target_addr[16]; /**< Target address. */
1125 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS. */
1128 struct rte_flow_item_icmp6_nd_ns rte_flow_item_icmp6_nd_ns_mask = {
1130 "\xff\xff\xff\xff\xff\xff\xff\xff"
1131 "\xff\xff\xff\xff\xff\xff\xff\xff",
1136 * RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA
1138 * Matches an ICMPv6 neighbor discovery advertisement.
1140 struct rte_flow_item_icmp6_nd_na {
1141 uint8_t type; /**< ICMPv6 type, normally 136. */
1142 uint8_t code; /**< ICMPv6 code, normally 0. */
1143 rte_be16_t checksum; /**< ICMPv6 checksum. */
1145 * Route flag (1b), solicited flag (1b), override flag (1b),
1148 rte_be32_t rso_reserved;
1149 uint8_t target_addr[16]; /**< Target address. */
1152 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA. */
1155 struct rte_flow_item_icmp6_nd_na rte_flow_item_icmp6_nd_na_mask = {
1157 "\xff\xff\xff\xff\xff\xff\xff\xff"
1158 "\xff\xff\xff\xff\xff\xff\xff\xff",
1163 * RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT
1165 * Matches the presence of any ICMPv6 neighbor discovery option.
1167 * Normally preceded by any of:
1169 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA
1170 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS
1171 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT
1173 struct rte_flow_item_icmp6_nd_opt {
1174 uint8_t type; /**< ND option type. */
1175 uint8_t length; /**< ND option length. */
1178 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT. */
1180 static const struct rte_flow_item_icmp6_nd_opt
1181 rte_flow_item_icmp6_nd_opt_mask = {
1187 * RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_SLA_ETH
1189 * Matches an ICMPv6 neighbor discovery source Ethernet link-layer address
1192 * Normally preceded by any of:
1194 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA
1195 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT
1197 struct rte_flow_item_icmp6_nd_opt_sla_eth {
1198 uint8_t type; /**< ND option type, normally 1. */
1199 uint8_t length; /**< ND option length, normally 1. */
1200 struct rte_ether_addr sla; /**< Source Ethernet LLA. */
1203 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_SLA_ETH. */
1205 static const struct rte_flow_item_icmp6_nd_opt_sla_eth
1206 rte_flow_item_icmp6_nd_opt_sla_eth_mask = {
1207 .sla.addr_bytes = "\xff\xff\xff\xff\xff\xff",
1212 * RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_TLA_ETH
1214 * Matches an ICMPv6 neighbor discovery target Ethernet link-layer address
1217 * Normally preceded by any of:
1219 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS
1220 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT
1222 struct rte_flow_item_icmp6_nd_opt_tla_eth {
1223 uint8_t type; /**< ND option type, normally 2. */
1224 uint8_t length; /**< ND option length, normally 1. */
1225 struct rte_ether_addr tla; /**< Target Ethernet LLA. */
1228 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_TLA_ETH. */
1230 static const struct rte_flow_item_icmp6_nd_opt_tla_eth
1231 rte_flow_item_icmp6_nd_opt_tla_eth_mask = {
1232 .tla.addr_bytes = "\xff\xff\xff\xff\xff\xff",
1237 * RTE_FLOW_ITEM_TYPE_META.
1239 * Matches a specified metadata value.
1241 struct rte_flow_item_meta {
1245 /** Default mask for RTE_FLOW_ITEM_TYPE_META. */
1247 static const struct rte_flow_item_meta rte_flow_item_meta_mask = {
1248 .data = RTE_BE32(UINT32_MAX),
1253 * RTE_FLOW_ITEM_TYPE_GTP_PSC.
1255 * Matches a GTP PDU extension header with type 0x85.
1257 struct rte_flow_item_gtp_psc {
1258 uint8_t pdu_type; /**< PDU type. */
1259 uint8_t qfi; /**< QoS flow identifier. */
1262 /** Default mask for RTE_FLOW_ITEM_TYPE_GTP_PSC. */
1264 static const struct rte_flow_item_gtp_psc
1265 rte_flow_item_gtp_psc_mask = {
1271 * RTE_FLOW_ITEM_TYPE_PPPOE.
1273 * Matches a PPPoE header.
1275 struct rte_flow_item_pppoe {
1277 * Version (4b), type (4b).
1279 uint8_t version_type;
1280 uint8_t code; /**< Message type. */
1281 rte_be16_t session_id; /**< Session identifier. */
1282 rte_be16_t length; /**< Payload length. */
1286 * RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID.
1288 * Matches a PPPoE optional proto_id field.
1290 * It only applies to PPPoE session packets.
1292 * Normally preceded by any of:
1294 * - RTE_FLOW_ITEM_TYPE_PPPOE
1295 * - RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID
1297 struct rte_flow_item_pppoe_proto_id {
1298 rte_be16_t proto_id; /**< PPP protocol identifier. */
1301 /** Default mask for RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID. */
1303 static const struct rte_flow_item_pppoe_proto_id
1304 rte_flow_item_pppoe_proto_id_mask = {
1305 .proto_id = RTE_BE16(0xffff),
1311 * @b EXPERIMENTAL: this structure may change without prior notice
1313 * RTE_FLOW_ITEM_TYPE_MARK
1315 * Matches an arbitrary integer value which was set using the ``MARK`` action
1316 * in a previously matched rule.
1318 * This item can only be specified once as a match criteria as the ``MARK``
1319 * action can only be specified once in a flow action.
1321 * This value is arbitrary and application-defined. Maximum allowed value
1322 * depends on the underlying implementation.
1324 * Depending on the underlying implementation the MARK item may be supported on
1325 * the physical device, with virtual groups in the PMD or not at all.
1327 struct rte_flow_item_mark {
1328 uint32_t id; /**< Integer value to match against. */
1333 * @b EXPERIMENTAL: this structure may change without prior notice
1335 * RTE_FLOW_ITEM_TYPE_NSH
1337 * Match network service header (NSH), RFC 8300
1340 struct rte_flow_item_nsh {
1343 uint32_t reserved:1;
1346 uint32_t reserved1:4;
1348 uint32_t next_proto:8;
1353 /** Default mask for RTE_FLOW_ITEM_TYPE_NSH. */
1355 static const struct rte_flow_item_nsh rte_flow_item_nsh_mask = {
1365 * @b EXPERIMENTAL: this structure may change without prior notice
1367 * RTE_FLOW_ITEM_TYPE_IGMP
1369 * Match Internet Group Management Protocol (IGMP), RFC 2236
1372 struct rte_flow_item_igmp {
1374 uint32_t max_resp_time:8;
1375 uint32_t checksum:16;
1376 uint32_t group_addr;
1379 /** Default mask for RTE_FLOW_ITEM_TYPE_IGMP. */
1381 static const struct rte_flow_item_igmp rte_flow_item_igmp_mask = {
1382 .group_addr = 0xffffffff,
1388 * @b EXPERIMENTAL: this structure may change without prior notice
1390 * RTE_FLOW_ITEM_TYPE_AH
1392 * Match IP Authentication Header (AH), RFC 4302
1395 struct rte_flow_item_ah {
1396 uint32_t next_hdr:8;
1397 uint32_t payload_len:8;
1398 uint32_t reserved:16;
1403 /** Default mask for RTE_FLOW_ITEM_TYPE_AH. */
1405 static const struct rte_flow_item_ah rte_flow_item_ah_mask = {
1411 * Matching pattern item definition.
1413 * A pattern is formed by stacking items starting from the lowest protocol
1414 * layer to match. This stacking restriction does not apply to meta items
1415 * which can be placed anywhere in the stack without affecting the meaning
1416 * of the resulting pattern.
1418 * Patterns are terminated by END items.
1420 * The spec field should be a valid pointer to a structure of the related
1421 * item type. It may remain unspecified (NULL) in many cases to request
1422 * broad (nonspecific) matching. In such cases, last and mask must also be
1425 * Optionally, last can point to a structure of the same type to define an
1426 * inclusive range. This is mostly supported by integer and address fields,
1427 * may cause errors otherwise. Fields that do not support ranges must be set
1428 * to 0 or to the same value as the corresponding fields in spec.
1430 * Only the fields defined to nonzero values in the default masks (see
1431 * rte_flow_item_{name}_mask constants) are considered relevant by
1432 * default. This can be overridden by providing a mask structure of the
1433 * same type with applicable bits set to one. It can also be used to
1434 * partially filter out specific fields (e.g. as an alternate mean to match
1435 * ranges of IP addresses).
1437 * Mask is a simple bit-mask applied before interpreting the contents of
1438 * spec and last, which may yield unexpected results if not used
1439 * carefully. For example, if for an IPv4 address field, spec provides
1440 * 10.1.2.3, last provides 10.3.4.5 and mask provides 255.255.0.0, the
1441 * effective range becomes 10.1.0.0 to 10.3.255.255.
1443 struct rte_flow_item {
1444 enum rte_flow_item_type type; /**< Item type. */
1445 const void *spec; /**< Pointer to item specification structure. */
1446 const void *last; /**< Defines an inclusive range (spec to last). */
1447 const void *mask; /**< Bit-mask applied to spec and last. */
1453 * Each possible action is represented by a type.
1454 * An action can have an associated configuration object.
1455 * Several actions combined in a list can be assigned
1456 * to a flow rule and are performed in order.
1458 * They fall in three categories:
1460 * - Actions that modify the fate of matching traffic, for instance by
1461 * dropping or assigning it a specific destination.
1463 * - Actions that modify matching traffic contents or its properties. This
1464 * includes adding/removing encapsulation, encryption, compression and
1467 * - Actions related to the flow rule itself, such as updating counters or
1468 * making it non-terminating.
1470 * Flow rules being terminating by default, not specifying any action of the
1471 * fate kind results in undefined behavior. This applies to both ingress and
1474 * PASSTHRU, when supported, makes a flow rule non-terminating.
1476 enum rte_flow_action_type {
1478 * End marker for action lists. Prevents further processing of
1479 * actions, thereby ending the list.
1481 * No associated configuration structure.
1483 RTE_FLOW_ACTION_TYPE_END,
1486 * Used as a placeholder for convenience. It is ignored and simply
1487 * discarded by PMDs.
1489 * No associated configuration structure.
1491 RTE_FLOW_ACTION_TYPE_VOID,
1494 * Leaves traffic up for additional processing by subsequent flow
1495 * rules; makes a flow rule non-terminating.
1497 * No associated configuration structure.
1499 RTE_FLOW_ACTION_TYPE_PASSTHRU,
1502 * RTE_FLOW_ACTION_TYPE_JUMP
1504 * Redirects packets to a group on the current device.
1506 * See struct rte_flow_action_jump.
1508 RTE_FLOW_ACTION_TYPE_JUMP,
1511 * Attaches an integer value to packets and sets PKT_RX_FDIR and
1512 * PKT_RX_FDIR_ID mbuf flags.
1514 * See struct rte_flow_action_mark.
1516 RTE_FLOW_ACTION_TYPE_MARK,
1519 * Flags packets. Similar to MARK without a specific value; only
1520 * sets the PKT_RX_FDIR mbuf flag.
1522 * No associated configuration structure.
1524 RTE_FLOW_ACTION_TYPE_FLAG,
1527 * Assigns packets to a given queue index.
1529 * See struct rte_flow_action_queue.
1531 RTE_FLOW_ACTION_TYPE_QUEUE,
1536 * PASSTHRU overrides this action if both are specified.
1538 * No associated configuration structure.
1540 RTE_FLOW_ACTION_TYPE_DROP,
1543 * Enables counters for this flow rule.
1545 * These counters can be retrieved and reset through rte_flow_query(),
1546 * see struct rte_flow_query_count.
1548 * See struct rte_flow_action_count.
1550 RTE_FLOW_ACTION_TYPE_COUNT,
1553 * Similar to QUEUE, except RSS is additionally performed on packets
1554 * to spread them among several queues according to the provided
1557 * See struct rte_flow_action_rss.
1559 RTE_FLOW_ACTION_TYPE_RSS,
1562 * Directs matching traffic to the physical function (PF) of the
1565 * No associated configuration structure.
1567 RTE_FLOW_ACTION_TYPE_PF,
1570 * Directs matching traffic to a given virtual function of the
1573 * See struct rte_flow_action_vf.
1575 RTE_FLOW_ACTION_TYPE_VF,
1578 * Directs packets to a given physical port index of the underlying
1581 * See struct rte_flow_action_phy_port.
1583 RTE_FLOW_ACTION_TYPE_PHY_PORT,
1586 * Directs matching traffic to a given DPDK port ID.
1588 * See struct rte_flow_action_port_id.
1590 RTE_FLOW_ACTION_TYPE_PORT_ID,
1593 * Traffic metering and policing (MTR).
1595 * See struct rte_flow_action_meter.
1596 * See file rte_mtr.h for MTR object configuration.
1598 RTE_FLOW_ACTION_TYPE_METER,
1601 * Redirects packets to security engine of current device for security
1602 * processing as specified by security session.
1604 * See struct rte_flow_action_security.
1606 RTE_FLOW_ACTION_TYPE_SECURITY,
1609 * Implements OFPAT_SET_MPLS_TTL ("MPLS TTL") as defined by the
1610 * OpenFlow Switch Specification.
1612 * See struct rte_flow_action_of_set_mpls_ttl.
1614 RTE_FLOW_ACTION_TYPE_OF_SET_MPLS_TTL,
1617 * Implements OFPAT_DEC_MPLS_TTL ("decrement MPLS TTL") as defined
1618 * by the OpenFlow Switch Specification.
1620 * No associated configuration structure.
1622 RTE_FLOW_ACTION_TYPE_OF_DEC_MPLS_TTL,
1625 * Implements OFPAT_SET_NW_TTL ("IP TTL") as defined by the OpenFlow
1626 * Switch Specification.
1628 * See struct rte_flow_action_of_set_nw_ttl.
1630 RTE_FLOW_ACTION_TYPE_OF_SET_NW_TTL,
1633 * Implements OFPAT_DEC_NW_TTL ("decrement IP TTL") as defined by
1634 * the OpenFlow Switch Specification.
1636 * No associated configuration structure.
1638 RTE_FLOW_ACTION_TYPE_OF_DEC_NW_TTL,
1641 * Implements OFPAT_COPY_TTL_OUT ("copy TTL "outwards" -- from
1642 * next-to-outermost to outermost") as defined by the OpenFlow
1643 * Switch Specification.
1645 * No associated configuration structure.
1647 RTE_FLOW_ACTION_TYPE_OF_COPY_TTL_OUT,
1650 * Implements OFPAT_COPY_TTL_IN ("copy TTL "inwards" -- from
1651 * outermost to next-to-outermost") as defined by the OpenFlow
1652 * Switch Specification.
1654 * No associated configuration structure.
1656 RTE_FLOW_ACTION_TYPE_OF_COPY_TTL_IN,
1659 * Implements OFPAT_POP_VLAN ("pop the outer VLAN tag") as defined
1660 * by the OpenFlow Switch Specification.
1662 * No associated configuration structure.
1664 RTE_FLOW_ACTION_TYPE_OF_POP_VLAN,
1667 * Implements OFPAT_PUSH_VLAN ("push a new VLAN tag") as defined by
1668 * the OpenFlow Switch Specification.
1670 * See struct rte_flow_action_of_push_vlan.
1672 RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN,
1675 * Implements OFPAT_SET_VLAN_VID ("set the 802.1q VLAN id") as
1676 * defined by the OpenFlow Switch Specification.
1678 * See struct rte_flow_action_of_set_vlan_vid.
1680 RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID,
1683 * Implements OFPAT_SET_LAN_PCP ("set the 802.1q priority") as
1684 * defined by the OpenFlow Switch Specification.
1686 * See struct rte_flow_action_of_set_vlan_pcp.
1688 RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP,
1691 * Implements OFPAT_POP_MPLS ("pop the outer MPLS tag") as defined
1692 * by the OpenFlow Switch Specification.
1694 * See struct rte_flow_action_of_pop_mpls.
1696 RTE_FLOW_ACTION_TYPE_OF_POP_MPLS,
1699 * Implements OFPAT_PUSH_MPLS ("push a new MPLS tag") as defined by
1700 * the OpenFlow Switch Specification.
1702 * See struct rte_flow_action_of_push_mpls.
1704 RTE_FLOW_ACTION_TYPE_OF_PUSH_MPLS,
1707 * Encapsulate flow in VXLAN tunnel as defined in
1708 * rte_flow_action_vxlan_encap action structure.
1710 * See struct rte_flow_action_vxlan_encap.
1712 RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP,
1715 * Decapsulate outer most VXLAN tunnel from matched flow.
1717 * If flow pattern does not define a valid VXLAN tunnel (as specified by
1718 * RFC7348) then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION
1721 RTE_FLOW_ACTION_TYPE_VXLAN_DECAP,
1724 * Encapsulate flow in NVGRE tunnel defined in the
1725 * rte_flow_action_nvgre_encap action structure.
1727 * See struct rte_flow_action_nvgre_encap.
1729 RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP,
1732 * Decapsulate outer most NVGRE tunnel from matched flow.
1734 * If flow pattern does not define a valid NVGRE tunnel (as specified by
1735 * RFC7637) then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION
1738 RTE_FLOW_ACTION_TYPE_NVGRE_DECAP,
1741 * Add outer header whose template is provided in its data buffer
1743 * See struct rte_flow_action_raw_encap.
1745 RTE_FLOW_ACTION_TYPE_RAW_ENCAP,
1748 * Remove outer header whose template is provided in its data buffer.
1750 * See struct rte_flow_action_raw_decap
1752 RTE_FLOW_ACTION_TYPE_RAW_DECAP,
1755 * Modify IPv4 source address in the outermost IPv4 header.
1757 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV4,
1758 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
1760 * See struct rte_flow_action_set_ipv4.
1762 RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC,
1765 * Modify IPv4 destination address in the outermost IPv4 header.
1767 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV4,
1768 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
1770 * See struct rte_flow_action_set_ipv4.
1772 RTE_FLOW_ACTION_TYPE_SET_IPV4_DST,
1775 * Modify IPv6 source address in the outermost IPv6 header.
1777 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV6,
1778 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
1780 * See struct rte_flow_action_set_ipv6.
1782 RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC,
1785 * Modify IPv6 destination address in the outermost IPv6 header.
1787 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV6,
1788 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
1790 * See struct rte_flow_action_set_ipv6.
1792 RTE_FLOW_ACTION_TYPE_SET_IPV6_DST,
1795 * Modify source port number in the outermost TCP/UDP header.
1797 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_TCP
1798 * or RTE_FLOW_ITEM_TYPE_UDP, then the PMD should return a
1799 * RTE_FLOW_ERROR_TYPE_ACTION error.
1801 * See struct rte_flow_action_set_tp.
1803 RTE_FLOW_ACTION_TYPE_SET_TP_SRC,
1806 * Modify destination port number in the outermost TCP/UDP header.
1808 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_TCP
1809 * or RTE_FLOW_ITEM_TYPE_UDP, then the PMD should return a
1810 * RTE_FLOW_ERROR_TYPE_ACTION error.
1812 * See struct rte_flow_action_set_tp.
1814 RTE_FLOW_ACTION_TYPE_SET_TP_DST,
1817 * Swap the source and destination MAC addresses in the outermost
1820 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_ETH,
1821 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
1823 * No associated configuration structure.
1825 RTE_FLOW_ACTION_TYPE_MAC_SWAP,
1828 * Decrease TTL value directly
1830 * No associated configuration structure.
1832 RTE_FLOW_ACTION_TYPE_DEC_TTL,
1837 * See struct rte_flow_action_set_ttl
1839 RTE_FLOW_ACTION_TYPE_SET_TTL,
1842 * Set source MAC address from matched flow.
1844 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_ETH,
1845 * the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
1847 * See struct rte_flow_action_set_mac.
1849 RTE_FLOW_ACTION_TYPE_SET_MAC_SRC,
1852 * Set destination MAC address from matched flow.
1854 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_ETH,
1855 * the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
1857 * See struct rte_flow_action_set_mac.
1859 RTE_FLOW_ACTION_TYPE_SET_MAC_DST,
1862 * Increase sequence number in the outermost TCP header.
1864 * Action configuration specifies the value to increase
1865 * TCP sequence number as a big-endian 32 bit integer.
1868 * @code rte_be32_t * @endcode
1870 * Using this action on non-matching traffic will result in
1871 * undefined behavior.
1873 RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ,
1876 * Decrease sequence number in the outermost TCP header.
1878 * Action configuration specifies the value to decrease
1879 * TCP sequence number as a big-endian 32 bit integer.
1882 * @code rte_be32_t * @endcode
1884 * Using this action on non-matching traffic will result in
1885 * undefined behavior.
1887 RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ,
1890 * Increase acknowledgment number in the outermost TCP header.
1892 * Action configuration specifies the value to increase
1893 * TCP acknowledgment number as a big-endian 32 bit integer.
1896 * @code rte_be32_t * @endcode
1898 * Using this action on non-matching traffic will result in
1899 * undefined behavior.
1901 RTE_FLOW_ACTION_TYPE_INC_TCP_ACK,
1904 * Decrease acknowledgment number in the outermost TCP header.
1906 * Action configuration specifies the value to decrease
1907 * TCP acknowledgment number as a big-endian 32 bit integer.
1910 * @code rte_be32_t * @endcode
1912 * Using this action on non-matching traffic will result in
1913 * undefined behavior.
1915 RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK,
1919 * RTE_FLOW_ACTION_TYPE_MARK
1921 * Attaches an integer value to packets and sets PKT_RX_FDIR and
1922 * PKT_RX_FDIR_ID mbuf flags.
1924 * This value is arbitrary and application-defined. Maximum allowed value
1925 * depends on the underlying implementation. It is returned in the
1926 * hash.fdir.hi mbuf field.
1928 struct rte_flow_action_mark {
1929 uint32_t id; /**< Integer value to return with packets. */
1934 * @b EXPERIMENTAL: this structure may change without prior notice
1936 * RTE_FLOW_ACTION_TYPE_JUMP
1938 * Redirects packets to a group on the current device.
1940 * In a hierarchy of groups, which can be used to represent physical or logical
1941 * flow tables on the device, this action allows the action to be a redirect to
1942 * a group on that device.
1944 struct rte_flow_action_jump {
1949 * RTE_FLOW_ACTION_TYPE_QUEUE
1951 * Assign packets to a given queue index.
1953 struct rte_flow_action_queue {
1954 uint16_t index; /**< Queue index to use. */
1960 * @b EXPERIMENTAL: this structure may change without prior notice
1962 * RTE_FLOW_ACTION_TYPE_COUNT
1964 * Adds a counter action to a matched flow.
1966 * If more than one count action is specified in a single flow rule, then each
1967 * action must specify a unique id.
1969 * Counters can be retrieved and reset through ``rte_flow_query()``, see
1970 * ``struct rte_flow_query_count``.
1972 * The shared flag indicates whether the counter is unique to the flow rule the
1973 * action is specified with, or whether it is a shared counter.
1975 * For a count action with the shared flag set, then then a global device
1976 * namespace is assumed for the counter id, so that any matched flow rules using
1977 * a count action with the same counter id on the same port will contribute to
1980 * For ports within the same switch domain then the counter id namespace extends
1981 * to all ports within that switch domain.
1983 struct rte_flow_action_count {
1984 uint32_t shared:1; /**< Share counter ID with other flow rules. */
1985 uint32_t reserved:31; /**< Reserved, must be zero. */
1986 uint32_t id; /**< Counter ID. */
1990 * RTE_FLOW_ACTION_TYPE_COUNT (query)
1992 * Query structure to retrieve and reset flow rule counters.
1994 struct rte_flow_query_count {
1995 uint32_t reset:1; /**< Reset counters after query [in]. */
1996 uint32_t hits_set:1; /**< hits field is set [out]. */
1997 uint32_t bytes_set:1; /**< bytes field is set [out]. */
1998 uint32_t reserved:29; /**< Reserved, must be zero [in, out]. */
1999 uint64_t hits; /**< Number of hits for this rule [out]. */
2000 uint64_t bytes; /**< Number of bytes through this rule [out]. */
2004 * Hash function types.
2006 enum rte_eth_hash_function {
2007 RTE_ETH_HASH_FUNCTION_DEFAULT = 0,
2008 RTE_ETH_HASH_FUNCTION_TOEPLITZ, /**< Toeplitz */
2009 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR, /**< Simple XOR */
2011 * Symmetric Toeplitz: src, dst will be replaced by
2012 * xor(src, dst). For the case with src/dst only,
2013 * src or dst address will xor with zero pair.
2015 RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ,
2016 RTE_ETH_HASH_FUNCTION_MAX,
2020 * RTE_FLOW_ACTION_TYPE_RSS
2022 * Similar to QUEUE, except RSS is additionally performed on packets to
2023 * spread them among several queues according to the provided parameters.
2025 * Unlike global RSS settings used by other DPDK APIs, unsetting the
2026 * @p types field does not disable RSS in a flow rule. Doing so instead
2027 * requests safe unspecified "best-effort" settings from the underlying PMD,
2028 * which depending on the flow rule, may result in anything ranging from
2029 * empty (single queue) to all-inclusive RSS.
2031 * Note: RSS hash result is stored in the hash.rss mbuf field which overlaps
2032 * hash.fdir.lo. Since the MARK action sets the hash.fdir.hi field only,
2033 * both can be requested simultaneously.
2035 struct rte_flow_action_rss {
2036 enum rte_eth_hash_function func; /**< RSS hash function to apply. */
2038 * Packet encapsulation level RSS hash @p types apply to.
2040 * - @p 0 requests the default behavior. Depending on the packet
2041 * type, it can mean outermost, innermost, anything in between or
2044 * It basically stands for the innermost encapsulation level RSS
2045 * can be performed on according to PMD and device capabilities.
2047 * - @p 1 requests RSS to be performed on the outermost packet
2048 * encapsulation level.
2050 * - @p 2 and subsequent values request RSS to be performed on the
2051 * specified inner packet encapsulation level, from outermost to
2052 * innermost (lower to higher values).
2054 * Values other than @p 0 are not necessarily supported.
2056 * Requesting a specific RSS level on unrecognized traffic results
2057 * in undefined behavior. For predictable results, it is recommended
2058 * to make the flow rule pattern match packet headers up to the
2059 * requested encapsulation level so that only matching traffic goes
2063 uint64_t types; /**< Specific RSS hash types (see ETH_RSS_*). */
2064 uint32_t key_len; /**< Hash key length in bytes. */
2065 uint32_t queue_num; /**< Number of entries in @p queue. */
2066 const uint8_t *key; /**< Hash key. */
2067 const uint16_t *queue; /**< Queue indices to use. */
2071 * RTE_FLOW_ACTION_TYPE_VF
2073 * Directs matching traffic to a given virtual function of the current
2076 * Packets matched by a VF pattern item can be redirected to their original
2077 * VF ID instead of the specified one. This parameter may not be available
2078 * and is not guaranteed to work properly if the VF part is matched by a
2079 * prior flow rule or if packets are not addressed to a VF in the first
2082 struct rte_flow_action_vf {
2083 uint32_t original:1; /**< Use original VF ID if possible. */
2084 uint32_t reserved:31; /**< Reserved, must be zero. */
2085 uint32_t id; /**< VF ID. */
2089 * RTE_FLOW_ACTION_TYPE_PHY_PORT
2091 * Directs packets to a given physical port index of the underlying
2094 * @see RTE_FLOW_ITEM_TYPE_PHY_PORT
2096 struct rte_flow_action_phy_port {
2097 uint32_t original:1; /**< Use original port index if possible. */
2098 uint32_t reserved:31; /**< Reserved, must be zero. */
2099 uint32_t index; /**< Physical port index. */
2103 * RTE_FLOW_ACTION_TYPE_PORT_ID
2105 * Directs matching traffic to a given DPDK port ID.
2107 * @see RTE_FLOW_ITEM_TYPE_PORT_ID
2109 struct rte_flow_action_port_id {
2110 uint32_t original:1; /**< Use original DPDK port ID if possible. */
2111 uint32_t reserved:31; /**< Reserved, must be zero. */
2112 uint32_t id; /**< DPDK port ID. */
2116 * RTE_FLOW_ACTION_TYPE_METER
2118 * Traffic metering and policing (MTR).
2120 * Packets matched by items of this type can be either dropped or passed to the
2121 * next item with their color set by the MTR object.
2123 struct rte_flow_action_meter {
2124 uint32_t mtr_id; /**< MTR object ID created with rte_mtr_create(). */
2128 * RTE_FLOW_ACTION_TYPE_SECURITY
2130 * Perform the security action on flows matched by the pattern items
2131 * according to the configuration of the security session.
2133 * This action modifies the payload of matched flows. For INLINE_CRYPTO, the
2134 * security protocol headers and IV are fully provided by the application as
2135 * specified in the flow pattern. The payload of matching packets is
2136 * encrypted on egress, and decrypted and authenticated on ingress.
2137 * For INLINE_PROTOCOL, the security protocol is fully offloaded to HW,
2138 * providing full encapsulation and decapsulation of packets in security
2139 * protocols. The flow pattern specifies both the outer security header fields
2140 * and the inner packet fields. The security session specified in the action
2141 * must match the pattern parameters.
2143 * The security session specified in the action must be created on the same
2144 * port as the flow action that is being specified.
2146 * The ingress/egress flow attribute should match that specified in the
2147 * security session if the security session supports the definition of the
2150 * Multiple flows can be configured to use the same security session.
2152 struct rte_flow_action_security {
2153 void *security_session; /**< Pointer to security session structure. */
2157 * RTE_FLOW_ACTION_TYPE_OF_SET_MPLS_TTL
2159 * Implements OFPAT_SET_MPLS_TTL ("MPLS TTL") as defined by the OpenFlow
2160 * Switch Specification.
2162 struct rte_flow_action_of_set_mpls_ttl {
2163 uint8_t mpls_ttl; /**< MPLS TTL. */
2167 * RTE_FLOW_ACTION_TYPE_OF_SET_NW_TTL
2169 * Implements OFPAT_SET_NW_TTL ("IP TTL") as defined by the OpenFlow Switch
2172 struct rte_flow_action_of_set_nw_ttl {
2173 uint8_t nw_ttl; /**< IP TTL. */
2177 * RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN
2179 * Implements OFPAT_PUSH_VLAN ("push a new VLAN tag") as defined by the
2180 * OpenFlow Switch Specification.
2182 struct rte_flow_action_of_push_vlan {
2183 rte_be16_t ethertype; /**< EtherType. */
2187 * RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID
2189 * Implements OFPAT_SET_VLAN_VID ("set the 802.1q VLAN id") as defined by
2190 * the OpenFlow Switch Specification.
2192 struct rte_flow_action_of_set_vlan_vid {
2193 rte_be16_t vlan_vid; /**< VLAN id. */
2197 * RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP
2199 * Implements OFPAT_SET_LAN_PCP ("set the 802.1q priority") as defined by
2200 * the OpenFlow Switch Specification.
2202 struct rte_flow_action_of_set_vlan_pcp {
2203 uint8_t vlan_pcp; /**< VLAN priority. */
2207 * RTE_FLOW_ACTION_TYPE_OF_POP_MPLS
2209 * Implements OFPAT_POP_MPLS ("pop the outer MPLS tag") as defined by the
2210 * OpenFlow Switch Specification.
2212 struct rte_flow_action_of_pop_mpls {
2213 rte_be16_t ethertype; /**< EtherType. */
2217 * RTE_FLOW_ACTION_TYPE_OF_PUSH_MPLS
2219 * Implements OFPAT_PUSH_MPLS ("push a new MPLS tag") as defined by the
2220 * OpenFlow Switch Specification.
2222 struct rte_flow_action_of_push_mpls {
2223 rte_be16_t ethertype; /**< EtherType. */
2228 * @b EXPERIMENTAL: this structure may change without prior notice
2230 * RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP
2232 * VXLAN tunnel end-point encapsulation data definition
2234 * The tunnel definition is provided through the flow item pattern, the
2235 * provided pattern must conform to RFC7348 for the tunnel specified. The flow
2236 * definition must be provided in order from the RTE_FLOW_ITEM_TYPE_ETH
2237 * definition up the end item which is specified by RTE_FLOW_ITEM_TYPE_END.
2239 * The mask field allows user to specify which fields in the flow item
2240 * definitions can be ignored and which have valid data and can be used
2243 * Note: the last field is not used in the definition of a tunnel and can be
2246 * Valid flow definition for RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP include:
2248 * - ETH / IPV4 / UDP / VXLAN / END
2249 * - ETH / IPV6 / UDP / VXLAN / END
2250 * - ETH / VLAN / IPV4 / UDP / VXLAN / END
2253 struct rte_flow_action_vxlan_encap {
2255 * Encapsulating vxlan tunnel definition
2256 * (terminated by the END pattern item).
2258 struct rte_flow_item *definition;
2263 * @b EXPERIMENTAL: this structure may change without prior notice
2265 * RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP
2267 * NVGRE tunnel end-point encapsulation data definition
2269 * The tunnel definition is provided through the flow item pattern the
2270 * provided pattern must conform with RFC7637. The flow definition must be
2271 * provided in order from the RTE_FLOW_ITEM_TYPE_ETH definition up the end item
2272 * which is specified by RTE_FLOW_ITEM_TYPE_END.
2274 * The mask field allows user to specify which fields in the flow item
2275 * definitions can be ignored and which have valid data and can be used
2278 * Note: the last field is not used in the definition of a tunnel and can be
2281 * Valid flow definition for RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP include:
2283 * - ETH / IPV4 / NVGRE / END
2284 * - ETH / VLAN / IPV6 / NVGRE / END
2287 struct rte_flow_action_nvgre_encap {
2289 * Encapsulating vxlan tunnel definition
2290 * (terminated by the END pattern item).
2292 struct rte_flow_item *definition;
2297 * @b EXPERIMENTAL: this structure may change without prior notice
2299 * RTE_FLOW_ACTION_TYPE_RAW_ENCAP
2301 * Raw tunnel end-point encapsulation data definition.
2303 * The data holds the headers definitions to be applied on the packet.
2304 * The data must start with ETH header up to the tunnel item header itself.
2305 * When used right after RAW_DECAP (for decapsulating L3 tunnel type for
2306 * example MPLSoGRE) the data will just hold layer 2 header.
2308 * The preserve parameter holds which bits in the packet the PMD is not allowed
2309 * to change, this parameter can also be NULL and then the PMD is allowed
2310 * to update any field.
2312 * size holds the number of bytes in @p data and @p preserve.
2314 struct rte_flow_action_raw_encap {
2315 uint8_t *data; /**< Encapsulation data. */
2316 uint8_t *preserve; /**< Bit-mask of @p data to preserve on output. */
2317 size_t size; /**< Size of @p data and @p preserve. */
2322 * @b EXPERIMENTAL: this structure may change without prior notice
2324 * RTE_FLOW_ACTION_TYPE_RAW_DECAP
2326 * Raw tunnel end-point decapsulation data definition.
2328 * The data holds the headers definitions to be removed from the packet.
2329 * The data must start with ETH header up to the tunnel item header itself.
2330 * When used right before RAW_DECAP (for encapsulating L3 tunnel type for
2331 * example MPLSoGRE) the data will just hold layer 2 header.
2333 * size holds the number of bytes in @p data.
2335 struct rte_flow_action_raw_decap {
2336 uint8_t *data; /**< Encapsulation data. */
2337 size_t size; /**< Size of @p data and @p preserve. */
2342 * @b EXPERIMENTAL: this structure may change without prior notice
2344 * RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC
2345 * RTE_FLOW_ACTION_TYPE_SET_IPV4_DST
2347 * Allows modification of IPv4 source (RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC)
2348 * and destination address (RTE_FLOW_ACTION_TYPE_SET_IPV4_DST) in the
2349 * specified outermost IPv4 header.
2351 struct rte_flow_action_set_ipv4 {
2352 rte_be32_t ipv4_addr;
2357 * @b EXPERIMENTAL: this structure may change without prior notice
2359 * RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC
2360 * RTE_FLOW_ACTION_TYPE_SET_IPV6_DST
2362 * Allows modification of IPv6 source (RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC)
2363 * and destination address (RTE_FLOW_ACTION_TYPE_SET_IPV6_DST) in the
2364 * specified outermost IPv6 header.
2366 struct rte_flow_action_set_ipv6 {
2367 uint8_t ipv6_addr[16];
2372 * @b EXPERIMENTAL: this structure may change without prior notice
2374 * RTE_FLOW_ACTION_TYPE_SET_TP_SRC
2375 * RTE_FLOW_ACTION_TYPE_SET_TP_DST
2377 * Allows modification of source (RTE_FLOW_ACTION_TYPE_SET_TP_SRC)
2378 * and destination (RTE_FLOW_ACTION_TYPE_SET_TP_DST) port numbers
2379 * in the specified outermost TCP/UDP header.
2381 struct rte_flow_action_set_tp {
2386 * RTE_FLOW_ACTION_TYPE_SET_TTL
2388 * Set the TTL value directly for IPv4 or IPv6
2390 struct rte_flow_action_set_ttl {
2395 * RTE_FLOW_ACTION_TYPE_SET_MAC
2397 * Set MAC address from the matched flow
2399 struct rte_flow_action_set_mac {
2400 uint8_t mac_addr[RTE_ETHER_ADDR_LEN];
2404 * Definition of a single action.
2406 * A list of actions is terminated by a END action.
2408 * For simple actions without a configuration object, conf remains NULL.
2410 struct rte_flow_action {
2411 enum rte_flow_action_type type; /**< Action type. */
2412 const void *conf; /**< Pointer to action configuration object. */
2416 * Opaque type returned after successfully creating a flow.
2418 * This handle can be used to manage and query the related flow (e.g. to
2419 * destroy it or retrieve counters).
2424 * Verbose error types.
2426 * Most of them provide the type of the object referenced by struct
2427 * rte_flow_error.cause.
2429 enum rte_flow_error_type {
2430 RTE_FLOW_ERROR_TYPE_NONE, /**< No error. */
2431 RTE_FLOW_ERROR_TYPE_UNSPECIFIED, /**< Cause unspecified. */
2432 RTE_FLOW_ERROR_TYPE_HANDLE, /**< Flow rule (handle). */
2433 RTE_FLOW_ERROR_TYPE_ATTR_GROUP, /**< Group field. */
2434 RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY, /**< Priority field. */
2435 RTE_FLOW_ERROR_TYPE_ATTR_INGRESS, /**< Ingress field. */
2436 RTE_FLOW_ERROR_TYPE_ATTR_EGRESS, /**< Egress field. */
2437 RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, /**< Transfer field. */
2438 RTE_FLOW_ERROR_TYPE_ATTR, /**< Attributes structure. */
2439 RTE_FLOW_ERROR_TYPE_ITEM_NUM, /**< Pattern length. */
2440 RTE_FLOW_ERROR_TYPE_ITEM_SPEC, /**< Item specification. */
2441 RTE_FLOW_ERROR_TYPE_ITEM_LAST, /**< Item specification range. */
2442 RTE_FLOW_ERROR_TYPE_ITEM_MASK, /**< Item specification mask. */
2443 RTE_FLOW_ERROR_TYPE_ITEM, /**< Specific pattern item. */
2444 RTE_FLOW_ERROR_TYPE_ACTION_NUM, /**< Number of actions. */
2445 RTE_FLOW_ERROR_TYPE_ACTION_CONF, /**< Action configuration. */
2446 RTE_FLOW_ERROR_TYPE_ACTION, /**< Specific action. */
2450 * Verbose error structure definition.
2452 * This object is normally allocated by applications and set by PMDs, the
2453 * message points to a constant string which does not need to be freed by
2454 * the application, however its pointer can be considered valid only as long
2455 * as its associated DPDK port remains configured. Closing the underlying
2456 * device or unloading the PMD invalidates it.
2458 * Both cause and message may be NULL regardless of the error type.
2460 struct rte_flow_error {
2461 enum rte_flow_error_type type; /**< Cause field and error types. */
2462 const void *cause; /**< Object responsible for the error. */
2463 const char *message; /**< Human-readable error message. */
2467 * Complete flow rule description.
2469 * This object type is used when converting a flow rule description.
2471 * @see RTE_FLOW_CONV_OP_RULE
2472 * @see rte_flow_conv()
2475 struct rte_flow_conv_rule {
2477 const struct rte_flow_attr *attr_ro; /**< RO attributes. */
2478 struct rte_flow_attr *attr; /**< Attributes. */
2481 const struct rte_flow_item *pattern_ro; /**< RO pattern. */
2482 struct rte_flow_item *pattern; /**< Pattern items. */
2485 const struct rte_flow_action *actions_ro; /**< RO actions. */
2486 struct rte_flow_action *actions; /**< List of actions. */
2491 * Conversion operations for flow API objects.
2493 * @see rte_flow_conv()
2495 enum rte_flow_conv_op {
2497 * No operation to perform.
2499 * rte_flow_conv() simply returns 0.
2501 RTE_FLOW_CONV_OP_NONE,
2504 * Convert attributes structure.
2506 * This is a basic copy of an attributes structure.
2509 * @code const struct rte_flow_attr * @endcode
2511 * @code struct rte_flow_attr * @endcode
2513 RTE_FLOW_CONV_OP_ATTR,
2516 * Convert a single item.
2518 * Duplicates @p spec, @p last and @p mask but not outside objects.
2521 * @code const struct rte_flow_item * @endcode
2523 * @code struct rte_flow_item * @endcode
2525 RTE_FLOW_CONV_OP_ITEM,
2528 * Convert a single action.
2530 * Duplicates @p conf but not outside objects.
2533 * @code const struct rte_flow_action * @endcode
2535 * @code struct rte_flow_action * @endcode
2537 RTE_FLOW_CONV_OP_ACTION,
2540 * Convert an entire pattern.
2542 * Duplicates all pattern items at once with the same constraints as
2543 * RTE_FLOW_CONV_OP_ITEM.
2546 * @code const struct rte_flow_item * @endcode
2548 * @code struct rte_flow_item * @endcode
2550 RTE_FLOW_CONV_OP_PATTERN,
2553 * Convert a list of actions.
2555 * Duplicates the entire list of actions at once with the same
2556 * constraints as RTE_FLOW_CONV_OP_ACTION.
2559 * @code const struct rte_flow_action * @endcode
2561 * @code struct rte_flow_action * @endcode
2563 RTE_FLOW_CONV_OP_ACTIONS,
2566 * Convert a complete flow rule description.
2568 * Comprises attributes, pattern and actions together at once with
2569 * the usual constraints.
2572 * @code const struct rte_flow_conv_rule * @endcode
2574 * @code struct rte_flow_conv_rule * @endcode
2576 RTE_FLOW_CONV_OP_RULE,
2579 * Convert item type to its name string.
2581 * Writes a NUL-terminated string to @p dst. Like snprintf(), the
2582 * returned value excludes the terminator which is always written
2586 * @code (const void *)enum rte_flow_item_type @endcode
2588 * @code char * @endcode
2590 RTE_FLOW_CONV_OP_ITEM_NAME,
2593 * Convert action type to its name string.
2595 * Writes a NUL-terminated string to @p dst. Like snprintf(), the
2596 * returned value excludes the terminator which is always written
2600 * @code (const void *)enum rte_flow_action_type @endcode
2602 * @code char * @endcode
2604 RTE_FLOW_CONV_OP_ACTION_NAME,
2607 * Convert item type to pointer to item name.
2609 * Retrieves item name pointer from its type. The string itself is
2610 * not copied; instead, a unique pointer to an internal static
2611 * constant storage is written to @p dst.
2614 * @code (const void *)enum rte_flow_item_type @endcode
2616 * @code const char ** @endcode
2618 RTE_FLOW_CONV_OP_ITEM_NAME_PTR,
2621 * Convert action type to pointer to action name.
2623 * Retrieves action name pointer from its type. The string itself is
2624 * not copied; instead, a unique pointer to an internal static
2625 * constant storage is written to @p dst.
2628 * @code (const void *)enum rte_flow_action_type @endcode
2630 * @code const char ** @endcode
2632 RTE_FLOW_CONV_OP_ACTION_NAME_PTR,
2636 * Check whether a flow rule can be created on a given port.
2638 * The flow rule is validated for correctness and whether it could be accepted
2639 * by the device given sufficient resources. The rule is checked against the
2640 * current device mode and queue configuration. The flow rule may also
2641 * optionally be validated against existing flow rules and device resources.
2642 * This function has no effect on the target device.
2644 * The returned value is guaranteed to remain valid only as long as no
2645 * successful calls to rte_flow_create() or rte_flow_destroy() are made in
2646 * the meantime and no device parameter affecting flow rules in any way are
2647 * modified, due to possible collisions or resource limitations (although in
2648 * such cases EINVAL should not be returned).
2651 * Port identifier of Ethernet device.
2653 * Flow rule attributes.
2654 * @param[in] pattern
2655 * Pattern specification (list terminated by the END pattern item).
2656 * @param[in] actions
2657 * Associated actions (list terminated by the END action).
2659 * Perform verbose error reporting if not NULL. PMDs initialize this
2660 * structure in case of error only.
2663 * 0 if flow rule is valid and can be created. A negative errno value
2664 * otherwise (rte_errno is also set), the following errors are defined:
2666 * -ENOSYS: underlying device does not support this functionality.
2668 * -EIO: underlying device is removed.
2670 * -EINVAL: unknown or invalid rule specification.
2672 * -ENOTSUP: valid but unsupported rule specification (e.g. partial
2673 * bit-masks are unsupported).
2675 * -EEXIST: collision with an existing rule. Only returned if device
2676 * supports flow rule collision checking and there was a flow rule
2677 * collision. Not receiving this return code is no guarantee that creating
2678 * the rule will not fail due to a collision.
2680 * -ENOMEM: not enough memory to execute the function, or if the device
2681 * supports resource validation, resource limitation on the device.
2683 * -EBUSY: action cannot be performed due to busy device resources, may
2684 * succeed if the affected queues or even the entire port are in a stopped
2685 * state (see rte_eth_dev_rx_queue_stop() and rte_eth_dev_stop()).
2688 rte_flow_validate(uint16_t port_id,
2689 const struct rte_flow_attr *attr,
2690 const struct rte_flow_item pattern[],
2691 const struct rte_flow_action actions[],
2692 struct rte_flow_error *error);
2695 * Create a flow rule on a given port.
2698 * Port identifier of Ethernet device.
2700 * Flow rule attributes.
2701 * @param[in] pattern
2702 * Pattern specification (list terminated by the END pattern item).
2703 * @param[in] actions
2704 * Associated actions (list terminated by the END action).
2706 * Perform verbose error reporting if not NULL. PMDs initialize this
2707 * structure in case of error only.
2710 * A valid handle in case of success, NULL otherwise and rte_errno is set
2711 * to the positive version of one of the error codes defined for
2712 * rte_flow_validate().
2715 rte_flow_create(uint16_t port_id,
2716 const struct rte_flow_attr *attr,
2717 const struct rte_flow_item pattern[],
2718 const struct rte_flow_action actions[],
2719 struct rte_flow_error *error);
2722 * Destroy a flow rule on a given port.
2724 * Failure to destroy a flow rule handle may occur when other flow rules
2725 * depend on it, and destroying it would result in an inconsistent state.
2727 * This function is only guaranteed to succeed if handles are destroyed in
2728 * reverse order of their creation.
2731 * Port identifier of Ethernet device.
2733 * Flow rule handle to destroy.
2735 * Perform verbose error reporting if not NULL. PMDs initialize this
2736 * structure in case of error only.
2739 * 0 on success, a negative errno value otherwise and rte_errno is set.
2742 rte_flow_destroy(uint16_t port_id,
2743 struct rte_flow *flow,
2744 struct rte_flow_error *error);
2747 * Destroy all flow rules associated with a port.
2749 * In the unlikely event of failure, handles are still considered destroyed
2750 * and no longer valid but the port must be assumed to be in an inconsistent
2754 * Port identifier of Ethernet device.
2756 * Perform verbose error reporting if not NULL. PMDs initialize this
2757 * structure in case of error only.
2760 * 0 on success, a negative errno value otherwise and rte_errno is set.
2763 rte_flow_flush(uint16_t port_id,
2764 struct rte_flow_error *error);
2767 * Query an existing flow rule.
2769 * This function allows retrieving flow-specific data such as counters.
2770 * Data is gathered by special actions which must be present in the flow
2773 * \see RTE_FLOW_ACTION_TYPE_COUNT
2776 * Port identifier of Ethernet device.
2778 * Flow rule handle to query.
2780 * Action definition as defined in original flow rule.
2781 * @param[in, out] data
2782 * Pointer to storage for the associated query data type.
2784 * Perform verbose error reporting if not NULL. PMDs initialize this
2785 * structure in case of error only.
2788 * 0 on success, a negative errno value otherwise and rte_errno is set.
2791 rte_flow_query(uint16_t port_id,
2792 struct rte_flow *flow,
2793 const struct rte_flow_action *action,
2795 struct rte_flow_error *error);
2798 * Restrict ingress traffic to the defined flow rules.
2800 * Isolated mode guarantees that all ingress traffic comes from defined flow
2801 * rules only (current and future).
2803 * Besides making ingress more deterministic, it allows PMDs to safely reuse
2804 * resources otherwise assigned to handle the remaining traffic, such as
2805 * global RSS configuration settings, VLAN filters, MAC address entries,
2806 * legacy filter API rules and so on in order to expand the set of possible
2809 * Calling this function as soon as possible after device initialization,
2810 * ideally before the first call to rte_eth_dev_configure(), is recommended
2811 * to avoid possible failures due to conflicting settings.
2813 * Once effective, leaving isolated mode may not be possible depending on
2814 * PMD implementation.
2816 * Additionally, the following functionality has no effect on the underlying
2817 * port and may return errors such as ENOTSUP ("not supported"):
2819 * - Toggling promiscuous mode.
2820 * - Toggling allmulticast mode.
2821 * - Configuring MAC addresses.
2822 * - Configuring multicast addresses.
2823 * - Configuring VLAN filters.
2824 * - Configuring Rx filters through the legacy API (e.g. FDIR).
2825 * - Configuring global RSS settings.
2828 * Port identifier of Ethernet device.
2830 * Nonzero to enter isolated mode, attempt to leave it otherwise.
2832 * Perform verbose error reporting if not NULL. PMDs initialize this
2833 * structure in case of error only.
2836 * 0 on success, a negative errno value otherwise and rte_errno is set.
2839 rte_flow_isolate(uint16_t port_id, int set, struct rte_flow_error *error);
2842 * Initialize flow error structure.
2845 * Pointer to flow error structure (may be NULL).
2847 * Related error code (rte_errno).
2849 * Cause field and error types.
2851 * Object responsible for the error.
2853 * Human-readable error message.
2856 * Negative error code (errno value) and rte_errno is set.
2859 rte_flow_error_set(struct rte_flow_error *error,
2861 enum rte_flow_error_type type,
2863 const char *message);
2867 * @see rte_flow_copy()
2869 struct rte_flow_desc {
2870 size_t size; /**< Allocated space including data[]. */
2871 struct rte_flow_attr attr; /**< Attributes. */
2872 struct rte_flow_item *items; /**< Items. */
2873 struct rte_flow_action *actions; /**< Actions. */
2874 uint8_t data[]; /**< Storage for items/actions. */
2879 * Copy an rte_flow rule description.
2881 * This interface is kept for compatibility with older applications but is
2882 * implemented as a wrapper to rte_flow_conv(). It is deprecated due to its
2883 * lack of flexibility and reliance on a type unusable with C++ programs
2884 * (struct rte_flow_desc).
2887 * Flow rule description.
2889 * Total size of allocated data for the flow description.
2891 * Flow rule attributes.
2893 * Pattern specification (list terminated by the END pattern item).
2894 * @param[in] actions
2895 * Associated actions (list terminated by the END action).
2898 * If len is greater or equal to the size of the flow, the total size of the
2899 * flow description and its data.
2900 * If len is lower than the size of the flow, the number of bytes that would
2901 * have been written to desc had it been sufficient. Nothing is written.
2905 rte_flow_copy(struct rte_flow_desc *fd, size_t len,
2906 const struct rte_flow_attr *attr,
2907 const struct rte_flow_item *items,
2908 const struct rte_flow_action *actions);
2911 * Flow object conversion helper.
2913 * This function performs conversion of various flow API objects to a
2914 * pre-allocated destination buffer. See enum rte_flow_conv_op for possible
2915 * operations and details about each of them.
2917 * Since destination buffer must be large enough, it works in a manner
2918 * reminiscent of snprintf():
2920 * - If @p size is 0, @p dst may be a NULL pointer, otherwise @p dst must be
2922 * - If positive, the returned value represents the number of bytes needed
2923 * to store the conversion of @p src to @p dst according to @p op
2924 * regardless of the @p size parameter.
2925 * - Since no more than @p size bytes can be written to @p dst, output is
2926 * truncated and may be inconsistent when the returned value is larger
2928 * - In case of conversion error, a negative error code is returned and
2929 * @p dst contents are unspecified.
2932 * Operation to perform, related to the object type of @p dst.
2934 * Destination buffer address. Must be suitably aligned by the caller.
2936 * Destination buffer size in bytes.
2938 * Source object to copy. Depending on @p op, its type may differ from
2941 * Perform verbose error reporting if not NULL. Initialized in case of
2945 * The number of bytes required to convert @p src to @p dst on success, a
2946 * negative errno value otherwise and rte_errno is set.
2948 * @see rte_flow_conv_op
2952 rte_flow_conv(enum rte_flow_conv_op op,
2956 struct rte_flow_error *error);
2962 #endif /* RTE_FLOW_H_ */