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,
476 * RTE_FLOW_ITEM_TYPE_ANY
478 * Matches any protocol in place of the current layer, a single ANY may also
479 * stand for several protocol layers.
481 * This is usually specified as the first pattern item when looking for a
482 * protocol anywhere in a packet.
484 * A zeroed mask stands for any number of layers.
486 struct rte_flow_item_any {
487 uint32_t num; /**< Number of layers covered. */
490 /** Default mask for RTE_FLOW_ITEM_TYPE_ANY. */
492 static const struct rte_flow_item_any rte_flow_item_any_mask = {
498 * RTE_FLOW_ITEM_TYPE_VF
500 * Matches traffic originating from (ingress) or going to (egress) a given
501 * virtual function of the current device.
503 * If supported, should work even if the virtual function is not managed by
504 * the application and thus not associated with a DPDK port ID.
506 * Note this pattern item does not match VF representors traffic which, as
507 * separate entities, should be addressed through their own DPDK port IDs.
509 * - Can be specified multiple times to match traffic addressed to several
511 * - Can be combined with a PF item to match both PF and VF traffic.
513 * A zeroed mask can be used to match any VF ID.
515 struct rte_flow_item_vf {
516 uint32_t id; /**< VF ID. */
519 /** Default mask for RTE_FLOW_ITEM_TYPE_VF. */
521 static const struct rte_flow_item_vf rte_flow_item_vf_mask = {
527 * RTE_FLOW_ITEM_TYPE_PHY_PORT
529 * Matches traffic originating from (ingress) or going to (egress) a
530 * physical port of the underlying device.
532 * The first PHY_PORT item overrides the physical port normally associated
533 * with the specified DPDK input port (port_id). This item can be provided
534 * several times to match additional physical ports.
536 * Note that physical ports are not necessarily tied to DPDK input ports
537 * (port_id) when those are not under DPDK control. Possible values are
538 * specific to each device, they are not necessarily indexed from zero and
539 * may not be contiguous.
541 * As a device property, the list of allowed values as well as the value
542 * associated with a port_id should be retrieved by other means.
544 * A zeroed mask can be used to match any port index.
546 struct rte_flow_item_phy_port {
547 uint32_t index; /**< Physical port index. */
550 /** Default mask for RTE_FLOW_ITEM_TYPE_PHY_PORT. */
552 static const struct rte_flow_item_phy_port rte_flow_item_phy_port_mask = {
558 * RTE_FLOW_ITEM_TYPE_PORT_ID
560 * Matches traffic originating from (ingress) or going to (egress) a given
563 * Normally only supported if the port ID in question is known by the
564 * underlying PMD and related to the device the flow rule is created
567 * This must not be confused with @p PHY_PORT which refers to the physical
568 * port of a device, whereas @p PORT_ID refers to a struct rte_eth_dev
569 * object on the application side (also known as "port representor"
570 * depending on the kind of underlying device).
572 struct rte_flow_item_port_id {
573 uint32_t id; /**< DPDK port ID. */
576 /** Default mask for RTE_FLOW_ITEM_TYPE_PORT_ID. */
578 static const struct rte_flow_item_port_id rte_flow_item_port_id_mask = {
584 * RTE_FLOW_ITEM_TYPE_RAW
586 * Matches a byte string of a given length at a given offset.
588 * Offset is either absolute (using the start of the packet) or relative to
589 * the end of the previous matched item in the stack, in which case negative
590 * values are allowed.
592 * If search is enabled, offset is used as the starting point. The search
593 * area can be delimited by setting limit to a nonzero value, which is the
594 * maximum number of bytes after offset where the pattern may start.
596 * Matching a zero-length pattern is allowed, doing so resets the relative
597 * offset for subsequent items.
599 * This type does not support ranges (struct rte_flow_item.last).
601 struct rte_flow_item_raw {
602 uint32_t relative:1; /**< Look for pattern after the previous item. */
603 uint32_t search:1; /**< Search pattern from offset (see also limit). */
604 uint32_t reserved:30; /**< Reserved, must be set to zero. */
605 int32_t offset; /**< Absolute or relative offset for pattern. */
606 uint16_t limit; /**< Search area limit for start of pattern. */
607 uint16_t length; /**< Pattern length. */
608 const uint8_t *pattern; /**< Byte string to look for. */
611 /** Default mask for RTE_FLOW_ITEM_TYPE_RAW. */
613 static const struct rte_flow_item_raw rte_flow_item_raw_mask = {
616 .reserved = 0x3fffffff,
617 .offset = 0xffffffff,
625 * RTE_FLOW_ITEM_TYPE_ETH
627 * Matches an Ethernet header.
629 * The @p type field either stands for "EtherType" or "TPID" when followed
630 * by so-called layer 2.5 pattern items such as RTE_FLOW_ITEM_TYPE_VLAN. In
631 * the latter case, @p type refers to that of the outer header, with the
632 * inner EtherType/TPID provided by the subsequent pattern item. This is the
633 * same order as on the wire.
635 struct rte_flow_item_eth {
636 struct rte_ether_addr dst; /**< Destination MAC. */
637 struct rte_ether_addr src; /**< Source MAC. */
638 rte_be16_t type; /**< EtherType or TPID. */
641 /** Default mask for RTE_FLOW_ITEM_TYPE_ETH. */
643 static const struct rte_flow_item_eth rte_flow_item_eth_mask = {
644 .dst.addr_bytes = "\xff\xff\xff\xff\xff\xff",
645 .src.addr_bytes = "\xff\xff\xff\xff\xff\xff",
646 .type = RTE_BE16(0x0000),
651 * RTE_FLOW_ITEM_TYPE_VLAN
653 * Matches an 802.1Q/ad VLAN tag.
655 * The corresponding standard outer EtherType (TPID) values are
656 * RTE_ETHER_TYPE_VLAN or RTE_ETHER_TYPE_QINQ. It can be overridden by
657 * the preceding pattern item.
659 struct rte_flow_item_vlan {
660 rte_be16_t tci; /**< Tag control information. */
661 rte_be16_t inner_type; /**< Inner EtherType or TPID. */
664 /** Default mask for RTE_FLOW_ITEM_TYPE_VLAN. */
666 static const struct rte_flow_item_vlan rte_flow_item_vlan_mask = {
667 .tci = RTE_BE16(0x0fff),
668 .inner_type = RTE_BE16(0x0000),
673 * RTE_FLOW_ITEM_TYPE_IPV4
675 * Matches an IPv4 header.
677 * Note: IPv4 options are handled by dedicated pattern items.
679 struct rte_flow_item_ipv4 {
680 struct rte_ipv4_hdr hdr; /**< IPv4 header definition. */
683 /** Default mask for RTE_FLOW_ITEM_TYPE_IPV4. */
685 static const struct rte_flow_item_ipv4 rte_flow_item_ipv4_mask = {
687 .src_addr = RTE_BE32(0xffffffff),
688 .dst_addr = RTE_BE32(0xffffffff),
694 * RTE_FLOW_ITEM_TYPE_IPV6.
696 * Matches an IPv6 header.
698 * Note: IPv6 options are handled by dedicated pattern items, see
699 * RTE_FLOW_ITEM_TYPE_IPV6_EXT.
701 struct rte_flow_item_ipv6 {
702 struct rte_ipv6_hdr hdr; /**< IPv6 header definition. */
705 /** Default mask for RTE_FLOW_ITEM_TYPE_IPV6. */
707 static const struct rte_flow_item_ipv6 rte_flow_item_ipv6_mask = {
710 "\xff\xff\xff\xff\xff\xff\xff\xff"
711 "\xff\xff\xff\xff\xff\xff\xff\xff",
713 "\xff\xff\xff\xff\xff\xff\xff\xff"
714 "\xff\xff\xff\xff\xff\xff\xff\xff",
720 * RTE_FLOW_ITEM_TYPE_ICMP.
722 * Matches an ICMP header.
724 struct rte_flow_item_icmp {
725 struct rte_icmp_hdr hdr; /**< ICMP header definition. */
728 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP. */
730 static const struct rte_flow_item_icmp rte_flow_item_icmp_mask = {
739 * RTE_FLOW_ITEM_TYPE_UDP.
741 * Matches a UDP header.
743 struct rte_flow_item_udp {
744 struct rte_udp_hdr hdr; /**< UDP header definition. */
747 /** Default mask for RTE_FLOW_ITEM_TYPE_UDP. */
749 static const struct rte_flow_item_udp rte_flow_item_udp_mask = {
751 .src_port = RTE_BE16(0xffff),
752 .dst_port = RTE_BE16(0xffff),
758 * RTE_FLOW_ITEM_TYPE_TCP.
760 * Matches a TCP header.
762 struct rte_flow_item_tcp {
763 struct rte_tcp_hdr hdr; /**< TCP header definition. */
766 /** Default mask for RTE_FLOW_ITEM_TYPE_TCP. */
768 static const struct rte_flow_item_tcp rte_flow_item_tcp_mask = {
770 .src_port = RTE_BE16(0xffff),
771 .dst_port = RTE_BE16(0xffff),
777 * RTE_FLOW_ITEM_TYPE_SCTP.
779 * Matches a SCTP header.
781 struct rte_flow_item_sctp {
782 struct rte_sctp_hdr hdr; /**< SCTP header definition. */
785 /** Default mask for RTE_FLOW_ITEM_TYPE_SCTP. */
787 static const struct rte_flow_item_sctp rte_flow_item_sctp_mask = {
789 .src_port = RTE_BE16(0xffff),
790 .dst_port = RTE_BE16(0xffff),
796 * RTE_FLOW_ITEM_TYPE_VXLAN.
798 * Matches a VXLAN header (RFC 7348).
800 struct rte_flow_item_vxlan {
801 uint8_t flags; /**< Normally 0x08 (I flag). */
802 uint8_t rsvd0[3]; /**< Reserved, normally 0x000000. */
803 uint8_t vni[3]; /**< VXLAN identifier. */
804 uint8_t rsvd1; /**< Reserved, normally 0x00. */
807 /** Default mask for RTE_FLOW_ITEM_TYPE_VXLAN. */
809 static const struct rte_flow_item_vxlan rte_flow_item_vxlan_mask = {
810 .vni = "\xff\xff\xff",
815 * RTE_FLOW_ITEM_TYPE_E_TAG.
817 * Matches a E-tag header.
819 * The corresponding standard outer EtherType (TPID) value is
820 * RTE_ETHER_TYPE_ETAG. It can be overridden by the preceding pattern item.
822 struct rte_flow_item_e_tag {
824 * E-Tag control information (E-TCI).
825 * E-PCP (3b), E-DEI (1b), ingress E-CID base (12b).
827 rte_be16_t epcp_edei_in_ecid_b;
828 /** Reserved (2b), GRP (2b), E-CID base (12b). */
829 rte_be16_t rsvd_grp_ecid_b;
830 uint8_t in_ecid_e; /**< Ingress E-CID ext. */
831 uint8_t ecid_e; /**< E-CID ext. */
832 rte_be16_t inner_type; /**< Inner EtherType or TPID. */
835 /** Default mask for RTE_FLOW_ITEM_TYPE_E_TAG. */
837 static const struct rte_flow_item_e_tag rte_flow_item_e_tag_mask = {
838 .rsvd_grp_ecid_b = RTE_BE16(0x3fff),
843 * RTE_FLOW_ITEM_TYPE_NVGRE.
845 * Matches a NVGRE header.
847 struct rte_flow_item_nvgre {
849 * Checksum (1b), undefined (1b), key bit (1b), sequence number (1b),
850 * reserved 0 (9b), version (3b).
852 * c_k_s_rsvd0_ver must have value 0x2000 according to RFC 7637.
854 rte_be16_t c_k_s_rsvd0_ver;
855 rte_be16_t protocol; /**< Protocol type (0x6558). */
856 uint8_t tni[3]; /**< Virtual subnet ID. */
857 uint8_t flow_id; /**< Flow ID. */
860 /** Default mask for RTE_FLOW_ITEM_TYPE_NVGRE. */
862 static const struct rte_flow_item_nvgre rte_flow_item_nvgre_mask = {
863 .tni = "\xff\xff\xff",
868 * RTE_FLOW_ITEM_TYPE_MPLS.
870 * Matches a MPLS header.
872 struct rte_flow_item_mpls {
874 * Label (20b), TC (3b), Bottom of Stack (1b).
876 uint8_t label_tc_s[3];
877 uint8_t ttl; /** Time-to-Live. */
880 /** Default mask for RTE_FLOW_ITEM_TYPE_MPLS. */
882 static const struct rte_flow_item_mpls rte_flow_item_mpls_mask = {
883 .label_tc_s = "\xff\xff\xf0",
888 * RTE_FLOW_ITEM_TYPE_GRE.
890 * Matches a GRE header.
892 struct rte_flow_item_gre {
894 * Checksum (1b), reserved 0 (12b), version (3b).
897 rte_be16_t c_rsvd0_ver;
898 rte_be16_t protocol; /**< Protocol type. */
901 /** Default mask for RTE_FLOW_ITEM_TYPE_GRE. */
903 static const struct rte_flow_item_gre rte_flow_item_gre_mask = {
904 .protocol = RTE_BE16(0xffff),
909 * RTE_FLOW_ITEM_TYPE_FUZZY
911 * Fuzzy pattern match, expect faster than default.
913 * This is for device that support fuzzy match option.
914 * Usually a fuzzy match is fast but the cost is accuracy.
915 * i.e. Signature Match only match pattern's hash value, but it is
916 * possible two different patterns have the same hash value.
918 * Matching accuracy level can be configure by threshold.
919 * Driver can divide the range of threshold and map to different
920 * accuracy levels that device support.
922 * Threshold 0 means perfect match (no fuzziness), while threshold
923 * 0xffffffff means fuzziest match.
925 struct rte_flow_item_fuzzy {
926 uint32_t thresh; /**< Accuracy threshold. */
929 /** Default mask for RTE_FLOW_ITEM_TYPE_FUZZY. */
931 static const struct rte_flow_item_fuzzy rte_flow_item_fuzzy_mask = {
932 .thresh = 0xffffffff,
937 * RTE_FLOW_ITEM_TYPE_GTP.
939 * Matches a GTPv1 header.
941 struct rte_flow_item_gtp {
943 * Version (3b), protocol type (1b), reserved (1b),
944 * Extension header flag (1b),
945 * Sequence number flag (1b),
946 * N-PDU number flag (1b).
948 uint8_t v_pt_rsv_flags;
949 uint8_t msg_type; /**< Message type. */
950 rte_be16_t msg_len; /**< Message length. */
951 rte_be32_t teid; /**< Tunnel endpoint identifier. */
954 /** Default mask for RTE_FLOW_ITEM_TYPE_GTP. */
956 static const struct rte_flow_item_gtp rte_flow_item_gtp_mask = {
957 .teid = RTE_BE32(0xffffffff),
962 * RTE_FLOW_ITEM_TYPE_ESP
964 * Matches an ESP header.
966 struct rte_flow_item_esp {
967 struct rte_esp_hdr hdr; /**< ESP header definition. */
970 /** Default mask for RTE_FLOW_ITEM_TYPE_ESP. */
972 static const struct rte_flow_item_esp rte_flow_item_esp_mask = {
974 .spi = RTE_BE32(0xffffffff),
980 * RTE_FLOW_ITEM_TYPE_GENEVE.
982 * Matches a GENEVE header.
984 struct rte_flow_item_geneve {
986 * Version (2b), length of the options fields (6b), OAM packet (1b),
987 * critical options present (1b), reserved 0 (6b).
989 rte_be16_t ver_opt_len_o_c_rsvd0;
990 rte_be16_t protocol; /**< Protocol type. */
991 uint8_t vni[3]; /**< Virtual Network Identifier. */
992 uint8_t rsvd1; /**< Reserved, normally 0x00. */
995 /** Default mask for RTE_FLOW_ITEM_TYPE_GENEVE. */
997 static const struct rte_flow_item_geneve rte_flow_item_geneve_mask = {
998 .vni = "\xff\xff\xff",
1003 * RTE_FLOW_ITEM_TYPE_VXLAN_GPE (draft-ietf-nvo3-vxlan-gpe-05).
1005 * Matches a VXLAN-GPE header.
1007 struct rte_flow_item_vxlan_gpe {
1008 uint8_t flags; /**< Normally 0x0c (I and P flags). */
1009 uint8_t rsvd0[2]; /**< Reserved, normally 0x0000. */
1010 uint8_t protocol; /**< Protocol type. */
1011 uint8_t vni[3]; /**< VXLAN identifier. */
1012 uint8_t rsvd1; /**< Reserved, normally 0x00. */
1015 /** Default mask for RTE_FLOW_ITEM_TYPE_VXLAN_GPE. */
1017 static const struct rte_flow_item_vxlan_gpe rte_flow_item_vxlan_gpe_mask = {
1018 .vni = "\xff\xff\xff",
1023 * RTE_FLOW_ITEM_TYPE_ARP_ETH_IPV4
1025 * Matches an ARP header for Ethernet/IPv4.
1027 struct rte_flow_item_arp_eth_ipv4 {
1028 rte_be16_t hrd; /**< Hardware type, normally 1. */
1029 rte_be16_t pro; /**< Protocol type, normally 0x0800. */
1030 uint8_t hln; /**< Hardware address length, normally 6. */
1031 uint8_t pln; /**< Protocol address length, normally 4. */
1032 rte_be16_t op; /**< Opcode (1 for request, 2 for reply). */
1033 struct rte_ether_addr sha; /**< Sender hardware address. */
1034 rte_be32_t spa; /**< Sender IPv4 address. */
1035 struct rte_ether_addr tha; /**< Target hardware address. */
1036 rte_be32_t tpa; /**< Target IPv4 address. */
1039 /** Default mask for RTE_FLOW_ITEM_TYPE_ARP_ETH_IPV4. */
1041 static const struct rte_flow_item_arp_eth_ipv4
1042 rte_flow_item_arp_eth_ipv4_mask = {
1043 .sha.addr_bytes = "\xff\xff\xff\xff\xff\xff",
1044 .spa = RTE_BE32(0xffffffff),
1045 .tha.addr_bytes = "\xff\xff\xff\xff\xff\xff",
1046 .tpa = RTE_BE32(0xffffffff),
1051 * RTE_FLOW_ITEM_TYPE_IPV6_EXT
1053 * Matches the presence of any IPv6 extension header.
1055 * Normally preceded by any of:
1057 * - RTE_FLOW_ITEM_TYPE_IPV6
1058 * - RTE_FLOW_ITEM_TYPE_IPV6_EXT
1060 struct rte_flow_item_ipv6_ext {
1061 uint8_t next_hdr; /**< Next header. */
1064 /** Default mask for RTE_FLOW_ITEM_TYPE_IPV6_EXT. */
1067 struct rte_flow_item_ipv6_ext rte_flow_item_ipv6_ext_mask = {
1073 * RTE_FLOW_ITEM_TYPE_ICMP6
1075 * Matches any ICMPv6 header.
1077 struct rte_flow_item_icmp6 {
1078 uint8_t type; /**< ICMPv6 type. */
1079 uint8_t code; /**< ICMPv6 code. */
1080 uint16_t checksum; /**< ICMPv6 checksum. */
1083 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6. */
1085 static const struct rte_flow_item_icmp6 rte_flow_item_icmp6_mask = {
1092 * RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS
1094 * Matches an ICMPv6 neighbor discovery solicitation.
1096 struct rte_flow_item_icmp6_nd_ns {
1097 uint8_t type; /**< ICMPv6 type, normally 135. */
1098 uint8_t code; /**< ICMPv6 code, normally 0. */
1099 rte_be16_t checksum; /**< ICMPv6 checksum. */
1100 rte_be32_t reserved; /**< Reserved, normally 0. */
1101 uint8_t target_addr[16]; /**< Target address. */
1104 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS. */
1107 struct rte_flow_item_icmp6_nd_ns rte_flow_item_icmp6_nd_ns_mask = {
1109 "\xff\xff\xff\xff\xff\xff\xff\xff"
1110 "\xff\xff\xff\xff\xff\xff\xff\xff",
1115 * RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA
1117 * Matches an ICMPv6 neighbor discovery advertisement.
1119 struct rte_flow_item_icmp6_nd_na {
1120 uint8_t type; /**< ICMPv6 type, normally 136. */
1121 uint8_t code; /**< ICMPv6 code, normally 0. */
1122 rte_be16_t checksum; /**< ICMPv6 checksum. */
1124 * Route flag (1b), solicited flag (1b), override flag (1b),
1127 rte_be32_t rso_reserved;
1128 uint8_t target_addr[16]; /**< Target address. */
1131 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA. */
1134 struct rte_flow_item_icmp6_nd_na rte_flow_item_icmp6_nd_na_mask = {
1136 "\xff\xff\xff\xff\xff\xff\xff\xff"
1137 "\xff\xff\xff\xff\xff\xff\xff\xff",
1142 * RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT
1144 * Matches the presence of any ICMPv6 neighbor discovery option.
1146 * Normally preceded by any of:
1148 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA
1149 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS
1150 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT
1152 struct rte_flow_item_icmp6_nd_opt {
1153 uint8_t type; /**< ND option type. */
1154 uint8_t length; /**< ND option length. */
1157 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT. */
1159 static const struct rte_flow_item_icmp6_nd_opt
1160 rte_flow_item_icmp6_nd_opt_mask = {
1166 * RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_SLA_ETH
1168 * Matches an ICMPv6 neighbor discovery source Ethernet link-layer address
1171 * Normally preceded by any of:
1173 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA
1174 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT
1176 struct rte_flow_item_icmp6_nd_opt_sla_eth {
1177 uint8_t type; /**< ND option type, normally 1. */
1178 uint8_t length; /**< ND option length, normally 1. */
1179 struct rte_ether_addr sla; /**< Source Ethernet LLA. */
1182 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_SLA_ETH. */
1184 static const struct rte_flow_item_icmp6_nd_opt_sla_eth
1185 rte_flow_item_icmp6_nd_opt_sla_eth_mask = {
1186 .sla.addr_bytes = "\xff\xff\xff\xff\xff\xff",
1191 * RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_TLA_ETH
1193 * Matches an ICMPv6 neighbor discovery target Ethernet link-layer address
1196 * Normally preceded by any of:
1198 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS
1199 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT
1201 struct rte_flow_item_icmp6_nd_opt_tla_eth {
1202 uint8_t type; /**< ND option type, normally 2. */
1203 uint8_t length; /**< ND option length, normally 1. */
1204 struct rte_ether_addr tla; /**< Target Ethernet LLA. */
1207 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_TLA_ETH. */
1209 static const struct rte_flow_item_icmp6_nd_opt_tla_eth
1210 rte_flow_item_icmp6_nd_opt_tla_eth_mask = {
1211 .tla.addr_bytes = "\xff\xff\xff\xff\xff\xff",
1216 * RTE_FLOW_ITEM_TYPE_META.
1218 * Matches a specified metadata value.
1220 struct rte_flow_item_meta {
1224 /** Default mask for RTE_FLOW_ITEM_TYPE_META. */
1226 static const struct rte_flow_item_meta rte_flow_item_meta_mask = {
1227 .data = RTE_BE32(UINT32_MAX),
1232 * RTE_FLOW_ITEM_TYPE_GTP_PSC.
1234 * Matches a GTP PDU extension header with type 0x85.
1236 struct rte_flow_item_gtp_psc {
1237 uint8_t pdu_type; /**< PDU type. */
1238 uint8_t qfi; /**< QoS flow identifier. */
1241 /** Default mask for RTE_FLOW_ITEM_TYPE_GTP_PSC. */
1243 static const struct rte_flow_item_gtp_psc
1244 rte_flow_item_gtp_psc_mask = {
1250 * RTE_FLOW_ITEM_TYPE_PPPOE.
1252 * Matches a PPPoE header.
1254 struct rte_flow_item_pppoe {
1256 * Version (4b), type (4b).
1258 uint8_t version_type;
1259 uint8_t code; /**< Message type. */
1260 rte_be16_t session_id; /**< Session identifier. */
1261 rte_be16_t length; /**< Payload length. */
1265 * RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID.
1267 * Matches a PPPoE optional proto_id field.
1269 * It only applies to PPPoE session packets.
1271 * Normally preceded by any of:
1273 * - RTE_FLOW_ITEM_TYPE_PPPOE
1274 * - RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID
1276 struct rte_flow_item_pppoe_proto_id {
1277 rte_be16_t proto_id; /**< PPP protocol identifier. */
1280 /** Default mask for RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID. */
1282 static const struct rte_flow_item_pppoe_proto_id
1283 rte_flow_item_pppoe_proto_id_mask = {
1284 .proto_id = RTE_BE16(0xffff),
1290 * @b EXPERIMENTAL: this structure may change without prior notice
1292 * RTE_FLOW_ITEM_TYPE_MARK
1294 * Matches an arbitrary integer value which was set using the ``MARK`` action
1295 * in a previously matched rule.
1297 * This item can only be specified once as a match criteria as the ``MARK``
1298 * action can only be specified once in a flow action.
1300 * This value is arbitrary and application-defined. Maximum allowed value
1301 * depends on the underlying implementation.
1303 * Depending on the underlying implementation the MARK item may be supported on
1304 * the physical device, with virtual groups in the PMD or not at all.
1306 struct rte_flow_item_mark {
1307 uint32_t id; /**< Integer value to match against. */
1311 * Matching pattern item definition.
1313 * A pattern is formed by stacking items starting from the lowest protocol
1314 * layer to match. This stacking restriction does not apply to meta items
1315 * which can be placed anywhere in the stack without affecting the meaning
1316 * of the resulting pattern.
1318 * Patterns are terminated by END items.
1320 * The spec field should be a valid pointer to a structure of the related
1321 * item type. It may remain unspecified (NULL) in many cases to request
1322 * broad (nonspecific) matching. In such cases, last and mask must also be
1325 * Optionally, last can point to a structure of the same type to define an
1326 * inclusive range. This is mostly supported by integer and address fields,
1327 * may cause errors otherwise. Fields that do not support ranges must be set
1328 * to 0 or to the same value as the corresponding fields in spec.
1330 * Only the fields defined to nonzero values in the default masks (see
1331 * rte_flow_item_{name}_mask constants) are considered relevant by
1332 * default. This can be overridden by providing a mask structure of the
1333 * same type with applicable bits set to one. It can also be used to
1334 * partially filter out specific fields (e.g. as an alternate mean to match
1335 * ranges of IP addresses).
1337 * Mask is a simple bit-mask applied before interpreting the contents of
1338 * spec and last, which may yield unexpected results if not used
1339 * carefully. For example, if for an IPv4 address field, spec provides
1340 * 10.1.2.3, last provides 10.3.4.5 and mask provides 255.255.0.0, the
1341 * effective range becomes 10.1.0.0 to 10.3.255.255.
1343 struct rte_flow_item {
1344 enum rte_flow_item_type type; /**< Item type. */
1345 const void *spec; /**< Pointer to item specification structure. */
1346 const void *last; /**< Defines an inclusive range (spec to last). */
1347 const void *mask; /**< Bit-mask applied to spec and last. */
1353 * Each possible action is represented by a type.
1354 * An action can have an associated configuration object.
1355 * Several actions combined in a list can be assigned
1356 * to a flow rule and are performed in order.
1358 * They fall in three categories:
1360 * - Actions that modify the fate of matching traffic, for instance by
1361 * dropping or assigning it a specific destination.
1363 * - Actions that modify matching traffic contents or its properties. This
1364 * includes adding/removing encapsulation, encryption, compression and
1367 * - Actions related to the flow rule itself, such as updating counters or
1368 * making it non-terminating.
1370 * Flow rules being terminating by default, not specifying any action of the
1371 * fate kind results in undefined behavior. This applies to both ingress and
1374 * PASSTHRU, when supported, makes a flow rule non-terminating.
1376 enum rte_flow_action_type {
1378 * End marker for action lists. Prevents further processing of
1379 * actions, thereby ending the list.
1381 * No associated configuration structure.
1383 RTE_FLOW_ACTION_TYPE_END,
1386 * Used as a placeholder for convenience. It is ignored and simply
1387 * discarded by PMDs.
1389 * No associated configuration structure.
1391 RTE_FLOW_ACTION_TYPE_VOID,
1394 * Leaves traffic up for additional processing by subsequent flow
1395 * rules; makes a flow rule non-terminating.
1397 * No associated configuration structure.
1399 RTE_FLOW_ACTION_TYPE_PASSTHRU,
1402 * RTE_FLOW_ACTION_TYPE_JUMP
1404 * Redirects packets to a group on the current device.
1406 * See struct rte_flow_action_jump.
1408 RTE_FLOW_ACTION_TYPE_JUMP,
1411 * Attaches an integer value to packets and sets PKT_RX_FDIR and
1412 * PKT_RX_FDIR_ID mbuf flags.
1414 * See struct rte_flow_action_mark.
1416 RTE_FLOW_ACTION_TYPE_MARK,
1419 * Flags packets. Similar to MARK without a specific value; only
1420 * sets the PKT_RX_FDIR mbuf flag.
1422 * No associated configuration structure.
1424 RTE_FLOW_ACTION_TYPE_FLAG,
1427 * Assigns packets to a given queue index.
1429 * See struct rte_flow_action_queue.
1431 RTE_FLOW_ACTION_TYPE_QUEUE,
1436 * PASSTHRU overrides this action if both are specified.
1438 * No associated configuration structure.
1440 RTE_FLOW_ACTION_TYPE_DROP,
1443 * Enables counters for this flow rule.
1445 * These counters can be retrieved and reset through rte_flow_query(),
1446 * see struct rte_flow_query_count.
1448 * See struct rte_flow_action_count.
1450 RTE_FLOW_ACTION_TYPE_COUNT,
1453 * Similar to QUEUE, except RSS is additionally performed on packets
1454 * to spread them among several queues according to the provided
1457 * See struct rte_flow_action_rss.
1459 RTE_FLOW_ACTION_TYPE_RSS,
1462 * Directs matching traffic to the physical function (PF) of the
1465 * No associated configuration structure.
1467 RTE_FLOW_ACTION_TYPE_PF,
1470 * Directs matching traffic to a given virtual function of the
1473 * See struct rte_flow_action_vf.
1475 RTE_FLOW_ACTION_TYPE_VF,
1478 * Directs packets to a given physical port index of the underlying
1481 * See struct rte_flow_action_phy_port.
1483 RTE_FLOW_ACTION_TYPE_PHY_PORT,
1486 * Directs matching traffic to a given DPDK port ID.
1488 * See struct rte_flow_action_port_id.
1490 RTE_FLOW_ACTION_TYPE_PORT_ID,
1493 * Traffic metering and policing (MTR).
1495 * See struct rte_flow_action_meter.
1496 * See file rte_mtr.h for MTR object configuration.
1498 RTE_FLOW_ACTION_TYPE_METER,
1501 * Redirects packets to security engine of current device for security
1502 * processing as specified by security session.
1504 * See struct rte_flow_action_security.
1506 RTE_FLOW_ACTION_TYPE_SECURITY,
1509 * Implements OFPAT_SET_MPLS_TTL ("MPLS TTL") as defined by the
1510 * OpenFlow Switch Specification.
1512 * See struct rte_flow_action_of_set_mpls_ttl.
1514 RTE_FLOW_ACTION_TYPE_OF_SET_MPLS_TTL,
1517 * Implements OFPAT_DEC_MPLS_TTL ("decrement MPLS TTL") as defined
1518 * by the OpenFlow Switch Specification.
1520 * No associated configuration structure.
1522 RTE_FLOW_ACTION_TYPE_OF_DEC_MPLS_TTL,
1525 * Implements OFPAT_SET_NW_TTL ("IP TTL") as defined by the OpenFlow
1526 * Switch Specification.
1528 * See struct rte_flow_action_of_set_nw_ttl.
1530 RTE_FLOW_ACTION_TYPE_OF_SET_NW_TTL,
1533 * Implements OFPAT_DEC_NW_TTL ("decrement IP TTL") as defined by
1534 * the OpenFlow Switch Specification.
1536 * No associated configuration structure.
1538 RTE_FLOW_ACTION_TYPE_OF_DEC_NW_TTL,
1541 * Implements OFPAT_COPY_TTL_OUT ("copy TTL "outwards" -- from
1542 * next-to-outermost to outermost") as defined by the OpenFlow
1543 * Switch Specification.
1545 * No associated configuration structure.
1547 RTE_FLOW_ACTION_TYPE_OF_COPY_TTL_OUT,
1550 * Implements OFPAT_COPY_TTL_IN ("copy TTL "inwards" -- from
1551 * outermost to next-to-outermost") as defined by the OpenFlow
1552 * Switch Specification.
1554 * No associated configuration structure.
1556 RTE_FLOW_ACTION_TYPE_OF_COPY_TTL_IN,
1559 * Implements OFPAT_POP_VLAN ("pop the outer VLAN tag") as defined
1560 * by the OpenFlow Switch Specification.
1562 * No associated configuration structure.
1564 RTE_FLOW_ACTION_TYPE_OF_POP_VLAN,
1567 * Implements OFPAT_PUSH_VLAN ("push a new VLAN tag") as defined by
1568 * the OpenFlow Switch Specification.
1570 * See struct rte_flow_action_of_push_vlan.
1572 RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN,
1575 * Implements OFPAT_SET_VLAN_VID ("set the 802.1q VLAN id") as
1576 * defined by the OpenFlow Switch Specification.
1578 * See struct rte_flow_action_of_set_vlan_vid.
1580 RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID,
1583 * Implements OFPAT_SET_LAN_PCP ("set the 802.1q priority") as
1584 * defined by the OpenFlow Switch Specification.
1586 * See struct rte_flow_action_of_set_vlan_pcp.
1588 RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP,
1591 * Implements OFPAT_POP_MPLS ("pop the outer MPLS tag") as defined
1592 * by the OpenFlow Switch Specification.
1594 * See struct rte_flow_action_of_pop_mpls.
1596 RTE_FLOW_ACTION_TYPE_OF_POP_MPLS,
1599 * Implements OFPAT_PUSH_MPLS ("push a new MPLS tag") as defined by
1600 * the OpenFlow Switch Specification.
1602 * See struct rte_flow_action_of_push_mpls.
1604 RTE_FLOW_ACTION_TYPE_OF_PUSH_MPLS,
1607 * Encapsulate flow in VXLAN tunnel as defined in
1608 * rte_flow_action_vxlan_encap action structure.
1610 * See struct rte_flow_action_vxlan_encap.
1612 RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP,
1615 * Decapsulate outer most VXLAN tunnel from matched flow.
1617 * If flow pattern does not define a valid VXLAN tunnel (as specified by
1618 * RFC7348) then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION
1621 RTE_FLOW_ACTION_TYPE_VXLAN_DECAP,
1624 * Encapsulate flow in NVGRE tunnel defined in the
1625 * rte_flow_action_nvgre_encap action structure.
1627 * See struct rte_flow_action_nvgre_encap.
1629 RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP,
1632 * Decapsulate outer most NVGRE tunnel from matched flow.
1634 * If flow pattern does not define a valid NVGRE tunnel (as specified by
1635 * RFC7637) then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION
1638 RTE_FLOW_ACTION_TYPE_NVGRE_DECAP,
1641 * Add outer header whose template is provided in its data buffer
1643 * See struct rte_flow_action_raw_encap.
1645 RTE_FLOW_ACTION_TYPE_RAW_ENCAP,
1648 * Remove outer header whose template is provided in its data buffer.
1650 * See struct rte_flow_action_raw_decap
1652 RTE_FLOW_ACTION_TYPE_RAW_DECAP,
1655 * Modify IPv4 source address in the outermost IPv4 header.
1657 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV4,
1658 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
1660 * See struct rte_flow_action_set_ipv4.
1662 RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC,
1665 * Modify IPv4 destination address in the outermost IPv4 header.
1667 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV4,
1668 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
1670 * See struct rte_flow_action_set_ipv4.
1672 RTE_FLOW_ACTION_TYPE_SET_IPV4_DST,
1675 * Modify IPv6 source address in the outermost IPv6 header.
1677 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV6,
1678 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
1680 * See struct rte_flow_action_set_ipv6.
1682 RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC,
1685 * Modify IPv6 destination address in the outermost IPv6 header.
1687 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV6,
1688 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
1690 * See struct rte_flow_action_set_ipv6.
1692 RTE_FLOW_ACTION_TYPE_SET_IPV6_DST,
1695 * Modify source port number in the outermost TCP/UDP header.
1697 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_TCP
1698 * or RTE_FLOW_ITEM_TYPE_UDP, then the PMD should return a
1699 * RTE_FLOW_ERROR_TYPE_ACTION error.
1701 * See struct rte_flow_action_set_tp.
1703 RTE_FLOW_ACTION_TYPE_SET_TP_SRC,
1706 * Modify destination port number in the outermost TCP/UDP header.
1708 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_TCP
1709 * or RTE_FLOW_ITEM_TYPE_UDP, then the PMD should return a
1710 * RTE_FLOW_ERROR_TYPE_ACTION error.
1712 * See struct rte_flow_action_set_tp.
1714 RTE_FLOW_ACTION_TYPE_SET_TP_DST,
1717 * Swap the source and destination MAC addresses in the outermost
1720 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_ETH,
1721 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
1723 * No associated configuration structure.
1725 RTE_FLOW_ACTION_TYPE_MAC_SWAP,
1728 * Decrease TTL value directly
1730 * No associated configuration structure.
1732 RTE_FLOW_ACTION_TYPE_DEC_TTL,
1737 * See struct rte_flow_action_set_ttl
1739 RTE_FLOW_ACTION_TYPE_SET_TTL,
1742 * Set source MAC address from matched flow.
1744 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_ETH,
1745 * the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
1747 * See struct rte_flow_action_set_mac.
1749 RTE_FLOW_ACTION_TYPE_SET_MAC_SRC,
1752 * Set destination MAC address from matched flow.
1754 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_ETH,
1755 * the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
1757 * See struct rte_flow_action_set_mac.
1759 RTE_FLOW_ACTION_TYPE_SET_MAC_DST,
1762 * Increase sequence number in the outermost TCP header.
1764 * Action configuration specifies the value to increase
1765 * TCP sequence number as a big-endian 32 bit integer.
1768 * @code rte_be32_t * @endcode
1770 * Using this action on non-matching traffic will result in
1771 * undefined behavior.
1773 RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ,
1776 * Decrease sequence number in the outermost TCP header.
1778 * Action configuration specifies the value to decrease
1779 * TCP sequence number as a big-endian 32 bit integer.
1782 * @code rte_be32_t * @endcode
1784 * Using this action on non-matching traffic will result in
1785 * undefined behavior.
1787 RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ,
1790 * Increase acknowledgment number in the outermost TCP header.
1792 * Action configuration specifies the value to increase
1793 * TCP acknowledgment number as a big-endian 32 bit integer.
1796 * @code rte_be32_t * @endcode
1798 * Using this action on non-matching traffic will result in
1799 * undefined behavior.
1801 RTE_FLOW_ACTION_TYPE_INC_TCP_ACK,
1804 * Decrease acknowledgment number in the outermost TCP header.
1806 * Action configuration specifies the value to decrease
1807 * TCP acknowledgment number as a big-endian 32 bit integer.
1810 * @code rte_be32_t * @endcode
1812 * Using this action on non-matching traffic will result in
1813 * undefined behavior.
1815 RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK,
1819 * RTE_FLOW_ACTION_TYPE_MARK
1821 * Attaches an integer value to packets and sets PKT_RX_FDIR and
1822 * PKT_RX_FDIR_ID mbuf flags.
1824 * This value is arbitrary and application-defined. Maximum allowed value
1825 * depends on the underlying implementation. It is returned in the
1826 * hash.fdir.hi mbuf field.
1828 struct rte_flow_action_mark {
1829 uint32_t id; /**< Integer value to return with packets. */
1834 * @b EXPERIMENTAL: this structure may change without prior notice
1836 * RTE_FLOW_ACTION_TYPE_JUMP
1838 * Redirects packets to a group on the current device.
1840 * In a hierarchy of groups, which can be used to represent physical or logical
1841 * flow tables on the device, this action allows the action to be a redirect to
1842 * a group on that device.
1844 struct rte_flow_action_jump {
1849 * RTE_FLOW_ACTION_TYPE_QUEUE
1851 * Assign packets to a given queue index.
1853 struct rte_flow_action_queue {
1854 uint16_t index; /**< Queue index to use. */
1860 * @b EXPERIMENTAL: this structure may change without prior notice
1862 * RTE_FLOW_ACTION_TYPE_COUNT
1864 * Adds a counter action to a matched flow.
1866 * If more than one count action is specified in a single flow rule, then each
1867 * action must specify a unique id.
1869 * Counters can be retrieved and reset through ``rte_flow_query()``, see
1870 * ``struct rte_flow_query_count``.
1872 * The shared flag indicates whether the counter is unique to the flow rule the
1873 * action is specified with, or whether it is a shared counter.
1875 * For a count action with the shared flag set, then then a global device
1876 * namespace is assumed for the counter id, so that any matched flow rules using
1877 * a count action with the same counter id on the same port will contribute to
1880 * For ports within the same switch domain then the counter id namespace extends
1881 * to all ports within that switch domain.
1883 struct rte_flow_action_count {
1884 uint32_t shared:1; /**< Share counter ID with other flow rules. */
1885 uint32_t reserved:31; /**< Reserved, must be zero. */
1886 uint32_t id; /**< Counter ID. */
1890 * RTE_FLOW_ACTION_TYPE_COUNT (query)
1892 * Query structure to retrieve and reset flow rule counters.
1894 struct rte_flow_query_count {
1895 uint32_t reset:1; /**< Reset counters after query [in]. */
1896 uint32_t hits_set:1; /**< hits field is set [out]. */
1897 uint32_t bytes_set:1; /**< bytes field is set [out]. */
1898 uint32_t reserved:29; /**< Reserved, must be zero [in, out]. */
1899 uint64_t hits; /**< Number of hits for this rule [out]. */
1900 uint64_t bytes; /**< Number of bytes through this rule [out]. */
1904 * Hash function types.
1906 enum rte_eth_hash_function {
1907 RTE_ETH_HASH_FUNCTION_DEFAULT = 0,
1908 RTE_ETH_HASH_FUNCTION_TOEPLITZ, /**< Toeplitz */
1909 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR, /**< Simple XOR */
1911 * Symmetric Toeplitz: src, dst will be replaced by
1912 * xor(src, dst). For the case with src/dst only,
1913 * src or dst address will xor with zero pair.
1915 RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ,
1916 RTE_ETH_HASH_FUNCTION_MAX,
1920 * RTE_FLOW_ACTION_TYPE_RSS
1922 * Similar to QUEUE, except RSS is additionally performed on packets to
1923 * spread them among several queues according to the provided parameters.
1925 * Unlike global RSS settings used by other DPDK APIs, unsetting the
1926 * @p types field does not disable RSS in a flow rule. Doing so instead
1927 * requests safe unspecified "best-effort" settings from the underlying PMD,
1928 * which depending on the flow rule, may result in anything ranging from
1929 * empty (single queue) to all-inclusive RSS.
1931 * Note: RSS hash result is stored in the hash.rss mbuf field which overlaps
1932 * hash.fdir.lo. Since the MARK action sets the hash.fdir.hi field only,
1933 * both can be requested simultaneously.
1935 struct rte_flow_action_rss {
1936 enum rte_eth_hash_function func; /**< RSS hash function to apply. */
1938 * Packet encapsulation level RSS hash @p types apply to.
1940 * - @p 0 requests the default behavior. Depending on the packet
1941 * type, it can mean outermost, innermost, anything in between or
1944 * It basically stands for the innermost encapsulation level RSS
1945 * can be performed on according to PMD and device capabilities.
1947 * - @p 1 requests RSS to be performed on the outermost packet
1948 * encapsulation level.
1950 * - @p 2 and subsequent values request RSS to be performed on the
1951 * specified inner packet encapsulation level, from outermost to
1952 * innermost (lower to higher values).
1954 * Values other than @p 0 are not necessarily supported.
1956 * Requesting a specific RSS level on unrecognized traffic results
1957 * in undefined behavior. For predictable results, it is recommended
1958 * to make the flow rule pattern match packet headers up to the
1959 * requested encapsulation level so that only matching traffic goes
1963 uint64_t types; /**< Specific RSS hash types (see ETH_RSS_*). */
1964 uint32_t key_len; /**< Hash key length in bytes. */
1965 uint32_t queue_num; /**< Number of entries in @p queue. */
1966 const uint8_t *key; /**< Hash key. */
1967 const uint16_t *queue; /**< Queue indices to use. */
1971 * RTE_FLOW_ACTION_TYPE_VF
1973 * Directs matching traffic to a given virtual function of the current
1976 * Packets matched by a VF pattern item can be redirected to their original
1977 * VF ID instead of the specified one. This parameter may not be available
1978 * and is not guaranteed to work properly if the VF part is matched by a
1979 * prior flow rule or if packets are not addressed to a VF in the first
1982 struct rte_flow_action_vf {
1983 uint32_t original:1; /**< Use original VF ID if possible. */
1984 uint32_t reserved:31; /**< Reserved, must be zero. */
1985 uint32_t id; /**< VF ID. */
1989 * RTE_FLOW_ACTION_TYPE_PHY_PORT
1991 * Directs packets to a given physical port index of the underlying
1994 * @see RTE_FLOW_ITEM_TYPE_PHY_PORT
1996 struct rte_flow_action_phy_port {
1997 uint32_t original:1; /**< Use original port index if possible. */
1998 uint32_t reserved:31; /**< Reserved, must be zero. */
1999 uint32_t index; /**< Physical port index. */
2003 * RTE_FLOW_ACTION_TYPE_PORT_ID
2005 * Directs matching traffic to a given DPDK port ID.
2007 * @see RTE_FLOW_ITEM_TYPE_PORT_ID
2009 struct rte_flow_action_port_id {
2010 uint32_t original:1; /**< Use original DPDK port ID if possible. */
2011 uint32_t reserved:31; /**< Reserved, must be zero. */
2012 uint32_t id; /**< DPDK port ID. */
2016 * RTE_FLOW_ACTION_TYPE_METER
2018 * Traffic metering and policing (MTR).
2020 * Packets matched by items of this type can be either dropped or passed to the
2021 * next item with their color set by the MTR object.
2023 struct rte_flow_action_meter {
2024 uint32_t mtr_id; /**< MTR object ID created with rte_mtr_create(). */
2028 * RTE_FLOW_ACTION_TYPE_SECURITY
2030 * Perform the security action on flows matched by the pattern items
2031 * according to the configuration of the security session.
2033 * This action modifies the payload of matched flows. For INLINE_CRYPTO, the
2034 * security protocol headers and IV are fully provided by the application as
2035 * specified in the flow pattern. The payload of matching packets is
2036 * encrypted on egress, and decrypted and authenticated on ingress.
2037 * For INLINE_PROTOCOL, the security protocol is fully offloaded to HW,
2038 * providing full encapsulation and decapsulation of packets in security
2039 * protocols. The flow pattern specifies both the outer security header fields
2040 * and the inner packet fields. The security session specified in the action
2041 * must match the pattern parameters.
2043 * The security session specified in the action must be created on the same
2044 * port as the flow action that is being specified.
2046 * The ingress/egress flow attribute should match that specified in the
2047 * security session if the security session supports the definition of the
2050 * Multiple flows can be configured to use the same security session.
2052 struct rte_flow_action_security {
2053 void *security_session; /**< Pointer to security session structure. */
2057 * RTE_FLOW_ACTION_TYPE_OF_SET_MPLS_TTL
2059 * Implements OFPAT_SET_MPLS_TTL ("MPLS TTL") as defined by the OpenFlow
2060 * Switch Specification.
2062 struct rte_flow_action_of_set_mpls_ttl {
2063 uint8_t mpls_ttl; /**< MPLS TTL. */
2067 * RTE_FLOW_ACTION_TYPE_OF_SET_NW_TTL
2069 * Implements OFPAT_SET_NW_TTL ("IP TTL") as defined by the OpenFlow Switch
2072 struct rte_flow_action_of_set_nw_ttl {
2073 uint8_t nw_ttl; /**< IP TTL. */
2077 * RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN
2079 * Implements OFPAT_PUSH_VLAN ("push a new VLAN tag") as defined by the
2080 * OpenFlow Switch Specification.
2082 struct rte_flow_action_of_push_vlan {
2083 rte_be16_t ethertype; /**< EtherType. */
2087 * RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID
2089 * Implements OFPAT_SET_VLAN_VID ("set the 802.1q VLAN id") as defined by
2090 * the OpenFlow Switch Specification.
2092 struct rte_flow_action_of_set_vlan_vid {
2093 rte_be16_t vlan_vid; /**< VLAN id. */
2097 * RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP
2099 * Implements OFPAT_SET_LAN_PCP ("set the 802.1q priority") as defined by
2100 * the OpenFlow Switch Specification.
2102 struct rte_flow_action_of_set_vlan_pcp {
2103 uint8_t vlan_pcp; /**< VLAN priority. */
2107 * RTE_FLOW_ACTION_TYPE_OF_POP_MPLS
2109 * Implements OFPAT_POP_MPLS ("pop the outer MPLS tag") as defined by the
2110 * OpenFlow Switch Specification.
2112 struct rte_flow_action_of_pop_mpls {
2113 rte_be16_t ethertype; /**< EtherType. */
2117 * RTE_FLOW_ACTION_TYPE_OF_PUSH_MPLS
2119 * Implements OFPAT_PUSH_MPLS ("push a new MPLS tag") as defined by the
2120 * OpenFlow Switch Specification.
2122 struct rte_flow_action_of_push_mpls {
2123 rte_be16_t ethertype; /**< EtherType. */
2128 * @b EXPERIMENTAL: this structure may change without prior notice
2130 * RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP
2132 * VXLAN tunnel end-point encapsulation data definition
2134 * The tunnel definition is provided through the flow item pattern, the
2135 * provided pattern must conform to RFC7348 for the tunnel specified. The flow
2136 * definition must be provided in order from the RTE_FLOW_ITEM_TYPE_ETH
2137 * definition up the end item which is specified by RTE_FLOW_ITEM_TYPE_END.
2139 * The mask field allows user to specify which fields in the flow item
2140 * definitions can be ignored and which have valid data and can be used
2143 * Note: the last field is not used in the definition of a tunnel and can be
2146 * Valid flow definition for RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP include:
2148 * - ETH / IPV4 / UDP / VXLAN / END
2149 * - ETH / IPV6 / UDP / VXLAN / END
2150 * - ETH / VLAN / IPV4 / UDP / VXLAN / END
2153 struct rte_flow_action_vxlan_encap {
2155 * Encapsulating vxlan tunnel definition
2156 * (terminated by the END pattern item).
2158 struct rte_flow_item *definition;
2163 * @b EXPERIMENTAL: this structure may change without prior notice
2165 * RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP
2167 * NVGRE tunnel end-point encapsulation data definition
2169 * The tunnel definition is provided through the flow item pattern the
2170 * provided pattern must conform with RFC7637. The flow definition must be
2171 * provided in order from the RTE_FLOW_ITEM_TYPE_ETH definition up the end item
2172 * which is specified by RTE_FLOW_ITEM_TYPE_END.
2174 * The mask field allows user to specify which fields in the flow item
2175 * definitions can be ignored and which have valid data and can be used
2178 * Note: the last field is not used in the definition of a tunnel and can be
2181 * Valid flow definition for RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP include:
2183 * - ETH / IPV4 / NVGRE / END
2184 * - ETH / VLAN / IPV6 / NVGRE / END
2187 struct rte_flow_action_nvgre_encap {
2189 * Encapsulating vxlan tunnel definition
2190 * (terminated by the END pattern item).
2192 struct rte_flow_item *definition;
2197 * @b EXPERIMENTAL: this structure may change without prior notice
2199 * RTE_FLOW_ACTION_TYPE_RAW_ENCAP
2201 * Raw tunnel end-point encapsulation data definition.
2203 * The data holds the headers definitions to be applied on the packet.
2204 * The data must start with ETH header up to the tunnel item header itself.
2205 * When used right after RAW_DECAP (for decapsulating L3 tunnel type for
2206 * example MPLSoGRE) the data will just hold layer 2 header.
2208 * The preserve parameter holds which bits in the packet the PMD is not allowed
2209 * to change, this parameter can also be NULL and then the PMD is allowed
2210 * to update any field.
2212 * size holds the number of bytes in @p data and @p preserve.
2214 struct rte_flow_action_raw_encap {
2215 uint8_t *data; /**< Encapsulation data. */
2216 uint8_t *preserve; /**< Bit-mask of @p data to preserve on output. */
2217 size_t size; /**< Size of @p data and @p preserve. */
2222 * @b EXPERIMENTAL: this structure may change without prior notice
2224 * RTE_FLOW_ACTION_TYPE_RAW_DECAP
2226 * Raw tunnel end-point decapsulation data definition.
2228 * The data holds the headers definitions to be removed from the packet.
2229 * The data must start with ETH header up to the tunnel item header itself.
2230 * When used right before RAW_DECAP (for encapsulating L3 tunnel type for
2231 * example MPLSoGRE) the data will just hold layer 2 header.
2233 * size holds the number of bytes in @p data.
2235 struct rte_flow_action_raw_decap {
2236 uint8_t *data; /**< Encapsulation data. */
2237 size_t size; /**< Size of @p data and @p preserve. */
2242 * @b EXPERIMENTAL: this structure may change without prior notice
2244 * RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC
2245 * RTE_FLOW_ACTION_TYPE_SET_IPV4_DST
2247 * Allows modification of IPv4 source (RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC)
2248 * and destination address (RTE_FLOW_ACTION_TYPE_SET_IPV4_DST) in the
2249 * specified outermost IPv4 header.
2251 struct rte_flow_action_set_ipv4 {
2252 rte_be32_t ipv4_addr;
2257 * @b EXPERIMENTAL: this structure may change without prior notice
2259 * RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC
2260 * RTE_FLOW_ACTION_TYPE_SET_IPV6_DST
2262 * Allows modification of IPv6 source (RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC)
2263 * and destination address (RTE_FLOW_ACTION_TYPE_SET_IPV6_DST) in the
2264 * specified outermost IPv6 header.
2266 struct rte_flow_action_set_ipv6 {
2267 uint8_t ipv6_addr[16];
2272 * @b EXPERIMENTAL: this structure may change without prior notice
2274 * RTE_FLOW_ACTION_TYPE_SET_TP_SRC
2275 * RTE_FLOW_ACTION_TYPE_SET_TP_DST
2277 * Allows modification of source (RTE_FLOW_ACTION_TYPE_SET_TP_SRC)
2278 * and destination (RTE_FLOW_ACTION_TYPE_SET_TP_DST) port numbers
2279 * in the specified outermost TCP/UDP header.
2281 struct rte_flow_action_set_tp {
2286 * RTE_FLOW_ACTION_TYPE_SET_TTL
2288 * Set the TTL value directly for IPv4 or IPv6
2290 struct rte_flow_action_set_ttl {
2295 * RTE_FLOW_ACTION_TYPE_SET_MAC
2297 * Set MAC address from the matched flow
2299 struct rte_flow_action_set_mac {
2300 uint8_t mac_addr[RTE_ETHER_ADDR_LEN];
2304 * Definition of a single action.
2306 * A list of actions is terminated by a END action.
2308 * For simple actions without a configuration object, conf remains NULL.
2310 struct rte_flow_action {
2311 enum rte_flow_action_type type; /**< Action type. */
2312 const void *conf; /**< Pointer to action configuration object. */
2316 * Opaque type returned after successfully creating a flow.
2318 * This handle can be used to manage and query the related flow (e.g. to
2319 * destroy it or retrieve counters).
2324 * Verbose error types.
2326 * Most of them provide the type of the object referenced by struct
2327 * rte_flow_error.cause.
2329 enum rte_flow_error_type {
2330 RTE_FLOW_ERROR_TYPE_NONE, /**< No error. */
2331 RTE_FLOW_ERROR_TYPE_UNSPECIFIED, /**< Cause unspecified. */
2332 RTE_FLOW_ERROR_TYPE_HANDLE, /**< Flow rule (handle). */
2333 RTE_FLOW_ERROR_TYPE_ATTR_GROUP, /**< Group field. */
2334 RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY, /**< Priority field. */
2335 RTE_FLOW_ERROR_TYPE_ATTR_INGRESS, /**< Ingress field. */
2336 RTE_FLOW_ERROR_TYPE_ATTR_EGRESS, /**< Egress field. */
2337 RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, /**< Transfer field. */
2338 RTE_FLOW_ERROR_TYPE_ATTR, /**< Attributes structure. */
2339 RTE_FLOW_ERROR_TYPE_ITEM_NUM, /**< Pattern length. */
2340 RTE_FLOW_ERROR_TYPE_ITEM_SPEC, /**< Item specification. */
2341 RTE_FLOW_ERROR_TYPE_ITEM_LAST, /**< Item specification range. */
2342 RTE_FLOW_ERROR_TYPE_ITEM_MASK, /**< Item specification mask. */
2343 RTE_FLOW_ERROR_TYPE_ITEM, /**< Specific pattern item. */
2344 RTE_FLOW_ERROR_TYPE_ACTION_NUM, /**< Number of actions. */
2345 RTE_FLOW_ERROR_TYPE_ACTION_CONF, /**< Action configuration. */
2346 RTE_FLOW_ERROR_TYPE_ACTION, /**< Specific action. */
2350 * Verbose error structure definition.
2352 * This object is normally allocated by applications and set by PMDs, the
2353 * message points to a constant string which does not need to be freed by
2354 * the application, however its pointer can be considered valid only as long
2355 * as its associated DPDK port remains configured. Closing the underlying
2356 * device or unloading the PMD invalidates it.
2358 * Both cause and message may be NULL regardless of the error type.
2360 struct rte_flow_error {
2361 enum rte_flow_error_type type; /**< Cause field and error types. */
2362 const void *cause; /**< Object responsible for the error. */
2363 const char *message; /**< Human-readable error message. */
2367 * Complete flow rule description.
2369 * This object type is used when converting a flow rule description.
2371 * @see RTE_FLOW_CONV_OP_RULE
2372 * @see rte_flow_conv()
2375 struct rte_flow_conv_rule {
2377 const struct rte_flow_attr *attr_ro; /**< RO attributes. */
2378 struct rte_flow_attr *attr; /**< Attributes. */
2381 const struct rte_flow_item *pattern_ro; /**< RO pattern. */
2382 struct rte_flow_item *pattern; /**< Pattern items. */
2385 const struct rte_flow_action *actions_ro; /**< RO actions. */
2386 struct rte_flow_action *actions; /**< List of actions. */
2391 * Conversion operations for flow API objects.
2393 * @see rte_flow_conv()
2395 enum rte_flow_conv_op {
2397 * No operation to perform.
2399 * rte_flow_conv() simply returns 0.
2401 RTE_FLOW_CONV_OP_NONE,
2404 * Convert attributes structure.
2406 * This is a basic copy of an attributes structure.
2409 * @code const struct rte_flow_attr * @endcode
2411 * @code struct rte_flow_attr * @endcode
2413 RTE_FLOW_CONV_OP_ATTR,
2416 * Convert a single item.
2418 * Duplicates @p spec, @p last and @p mask but not outside objects.
2421 * @code const struct rte_flow_item * @endcode
2423 * @code struct rte_flow_item * @endcode
2425 RTE_FLOW_CONV_OP_ITEM,
2428 * Convert a single action.
2430 * Duplicates @p conf but not outside objects.
2433 * @code const struct rte_flow_action * @endcode
2435 * @code struct rte_flow_action * @endcode
2437 RTE_FLOW_CONV_OP_ACTION,
2440 * Convert an entire pattern.
2442 * Duplicates all pattern items at once with the same constraints as
2443 * RTE_FLOW_CONV_OP_ITEM.
2446 * @code const struct rte_flow_item * @endcode
2448 * @code struct rte_flow_item * @endcode
2450 RTE_FLOW_CONV_OP_PATTERN,
2453 * Convert a list of actions.
2455 * Duplicates the entire list of actions at once with the same
2456 * constraints as RTE_FLOW_CONV_OP_ACTION.
2459 * @code const struct rte_flow_action * @endcode
2461 * @code struct rte_flow_action * @endcode
2463 RTE_FLOW_CONV_OP_ACTIONS,
2466 * Convert a complete flow rule description.
2468 * Comprises attributes, pattern and actions together at once with
2469 * the usual constraints.
2472 * @code const struct rte_flow_conv_rule * @endcode
2474 * @code struct rte_flow_conv_rule * @endcode
2476 RTE_FLOW_CONV_OP_RULE,
2479 * Convert item type to its name string.
2481 * Writes a NUL-terminated string to @p dst. Like snprintf(), the
2482 * returned value excludes the terminator which is always written
2486 * @code (const void *)enum rte_flow_item_type @endcode
2488 * @code char * @endcode
2490 RTE_FLOW_CONV_OP_ITEM_NAME,
2493 * Convert action type to its name string.
2495 * Writes a NUL-terminated string to @p dst. Like snprintf(), the
2496 * returned value excludes the terminator which is always written
2500 * @code (const void *)enum rte_flow_action_type @endcode
2502 * @code char * @endcode
2504 RTE_FLOW_CONV_OP_ACTION_NAME,
2507 * Convert item type to pointer to item name.
2509 * Retrieves item name pointer from its type. The string itself is
2510 * not copied; instead, a unique pointer to an internal static
2511 * constant storage is written to @p dst.
2514 * @code (const void *)enum rte_flow_item_type @endcode
2516 * @code const char ** @endcode
2518 RTE_FLOW_CONV_OP_ITEM_NAME_PTR,
2521 * Convert action type to pointer to action name.
2523 * Retrieves action name pointer from its type. The string itself is
2524 * not copied; instead, a unique pointer to an internal static
2525 * constant storage is written to @p dst.
2528 * @code (const void *)enum rte_flow_action_type @endcode
2530 * @code const char ** @endcode
2532 RTE_FLOW_CONV_OP_ACTION_NAME_PTR,
2536 * Check whether a flow rule can be created on a given port.
2538 * The flow rule is validated for correctness and whether it could be accepted
2539 * by the device given sufficient resources. The rule is checked against the
2540 * current device mode and queue configuration. The flow rule may also
2541 * optionally be validated against existing flow rules and device resources.
2542 * This function has no effect on the target device.
2544 * The returned value is guaranteed to remain valid only as long as no
2545 * successful calls to rte_flow_create() or rte_flow_destroy() are made in
2546 * the meantime and no device parameter affecting flow rules in any way are
2547 * modified, due to possible collisions or resource limitations (although in
2548 * such cases EINVAL should not be returned).
2551 * Port identifier of Ethernet device.
2553 * Flow rule attributes.
2554 * @param[in] pattern
2555 * Pattern specification (list terminated by the END pattern item).
2556 * @param[in] actions
2557 * Associated actions (list terminated by the END action).
2559 * Perform verbose error reporting if not NULL. PMDs initialize this
2560 * structure in case of error only.
2563 * 0 if flow rule is valid and can be created. A negative errno value
2564 * otherwise (rte_errno is also set), the following errors are defined:
2566 * -ENOSYS: underlying device does not support this functionality.
2568 * -EIO: underlying device is removed.
2570 * -EINVAL: unknown or invalid rule specification.
2572 * -ENOTSUP: valid but unsupported rule specification (e.g. partial
2573 * bit-masks are unsupported).
2575 * -EEXIST: collision with an existing rule. Only returned if device
2576 * supports flow rule collision checking and there was a flow rule
2577 * collision. Not receiving this return code is no guarantee that creating
2578 * the rule will not fail due to a collision.
2580 * -ENOMEM: not enough memory to execute the function, or if the device
2581 * supports resource validation, resource limitation on the device.
2583 * -EBUSY: action cannot be performed due to busy device resources, may
2584 * succeed if the affected queues or even the entire port are in a stopped
2585 * state (see rte_eth_dev_rx_queue_stop() and rte_eth_dev_stop()).
2588 rte_flow_validate(uint16_t port_id,
2589 const struct rte_flow_attr *attr,
2590 const struct rte_flow_item pattern[],
2591 const struct rte_flow_action actions[],
2592 struct rte_flow_error *error);
2595 * Create a flow rule on a given port.
2598 * Port identifier of Ethernet device.
2600 * Flow rule attributes.
2601 * @param[in] pattern
2602 * Pattern specification (list terminated by the END pattern item).
2603 * @param[in] actions
2604 * Associated actions (list terminated by the END action).
2606 * Perform verbose error reporting if not NULL. PMDs initialize this
2607 * structure in case of error only.
2610 * A valid handle in case of success, NULL otherwise and rte_errno is set
2611 * to the positive version of one of the error codes defined for
2612 * rte_flow_validate().
2615 rte_flow_create(uint16_t port_id,
2616 const struct rte_flow_attr *attr,
2617 const struct rte_flow_item pattern[],
2618 const struct rte_flow_action actions[],
2619 struct rte_flow_error *error);
2622 * Destroy a flow rule on a given port.
2624 * Failure to destroy a flow rule handle may occur when other flow rules
2625 * depend on it, and destroying it would result in an inconsistent state.
2627 * This function is only guaranteed to succeed if handles are destroyed in
2628 * reverse order of their creation.
2631 * Port identifier of Ethernet device.
2633 * Flow rule handle to destroy.
2635 * Perform verbose error reporting if not NULL. PMDs initialize this
2636 * structure in case of error only.
2639 * 0 on success, a negative errno value otherwise and rte_errno is set.
2642 rte_flow_destroy(uint16_t port_id,
2643 struct rte_flow *flow,
2644 struct rte_flow_error *error);
2647 * Destroy all flow rules associated with a port.
2649 * In the unlikely event of failure, handles are still considered destroyed
2650 * and no longer valid but the port must be assumed to be in an inconsistent
2654 * Port identifier of Ethernet device.
2656 * Perform verbose error reporting if not NULL. PMDs initialize this
2657 * structure in case of error only.
2660 * 0 on success, a negative errno value otherwise and rte_errno is set.
2663 rte_flow_flush(uint16_t port_id,
2664 struct rte_flow_error *error);
2667 * Query an existing flow rule.
2669 * This function allows retrieving flow-specific data such as counters.
2670 * Data is gathered by special actions which must be present in the flow
2673 * \see RTE_FLOW_ACTION_TYPE_COUNT
2676 * Port identifier of Ethernet device.
2678 * Flow rule handle to query.
2680 * Action definition as defined in original flow rule.
2681 * @param[in, out] data
2682 * Pointer to storage for the associated query data type.
2684 * Perform verbose error reporting if not NULL. PMDs initialize this
2685 * structure in case of error only.
2688 * 0 on success, a negative errno value otherwise and rte_errno is set.
2691 rte_flow_query(uint16_t port_id,
2692 struct rte_flow *flow,
2693 const struct rte_flow_action *action,
2695 struct rte_flow_error *error);
2698 * Restrict ingress traffic to the defined flow rules.
2700 * Isolated mode guarantees that all ingress traffic comes from defined flow
2701 * rules only (current and future).
2703 * Besides making ingress more deterministic, it allows PMDs to safely reuse
2704 * resources otherwise assigned to handle the remaining traffic, such as
2705 * global RSS configuration settings, VLAN filters, MAC address entries,
2706 * legacy filter API rules and so on in order to expand the set of possible
2709 * Calling this function as soon as possible after device initialization,
2710 * ideally before the first call to rte_eth_dev_configure(), is recommended
2711 * to avoid possible failures due to conflicting settings.
2713 * Once effective, leaving isolated mode may not be possible depending on
2714 * PMD implementation.
2716 * Additionally, the following functionality has no effect on the underlying
2717 * port and may return errors such as ENOTSUP ("not supported"):
2719 * - Toggling promiscuous mode.
2720 * - Toggling allmulticast mode.
2721 * - Configuring MAC addresses.
2722 * - Configuring multicast addresses.
2723 * - Configuring VLAN filters.
2724 * - Configuring Rx filters through the legacy API (e.g. FDIR).
2725 * - Configuring global RSS settings.
2728 * Port identifier of Ethernet device.
2730 * Nonzero to enter isolated mode, attempt to leave it otherwise.
2732 * Perform verbose error reporting if not NULL. PMDs initialize this
2733 * structure in case of error only.
2736 * 0 on success, a negative errno value otherwise and rte_errno is set.
2739 rte_flow_isolate(uint16_t port_id, int set, struct rte_flow_error *error);
2742 * Initialize flow error structure.
2745 * Pointer to flow error structure (may be NULL).
2747 * Related error code (rte_errno).
2749 * Cause field and error types.
2751 * Object responsible for the error.
2753 * Human-readable error message.
2756 * Negative error code (errno value) and rte_errno is set.
2759 rte_flow_error_set(struct rte_flow_error *error,
2761 enum rte_flow_error_type type,
2763 const char *message);
2767 * @see rte_flow_copy()
2769 struct rte_flow_desc {
2770 size_t size; /**< Allocated space including data[]. */
2771 struct rte_flow_attr attr; /**< Attributes. */
2772 struct rte_flow_item *items; /**< Items. */
2773 struct rte_flow_action *actions; /**< Actions. */
2774 uint8_t data[]; /**< Storage for items/actions. */
2779 * Copy an rte_flow rule description.
2781 * This interface is kept for compatibility with older applications but is
2782 * implemented as a wrapper to rte_flow_conv(). It is deprecated due to its
2783 * lack of flexibility and reliance on a type unusable with C++ programs
2784 * (struct rte_flow_desc).
2787 * Flow rule description.
2789 * Total size of allocated data for the flow description.
2791 * Flow rule attributes.
2793 * Pattern specification (list terminated by the END pattern item).
2794 * @param[in] actions
2795 * Associated actions (list terminated by the END action).
2798 * If len is greater or equal to the size of the flow, the total size of the
2799 * flow description and its data.
2800 * If len is lower than the size of the flow, the number of bytes that would
2801 * have been written to desc had it been sufficient. Nothing is written.
2805 rte_flow_copy(struct rte_flow_desc *fd, size_t len,
2806 const struct rte_flow_attr *attr,
2807 const struct rte_flow_item *items,
2808 const struct rte_flow_action *actions);
2811 * Flow object conversion helper.
2813 * This function performs conversion of various flow API objects to a
2814 * pre-allocated destination buffer. See enum rte_flow_conv_op for possible
2815 * operations and details about each of them.
2817 * Since destination buffer must be large enough, it works in a manner
2818 * reminiscent of snprintf():
2820 * - If @p size is 0, @p dst may be a NULL pointer, otherwise @p dst must be
2822 * - If positive, the returned value represents the number of bytes needed
2823 * to store the conversion of @p src to @p dst according to @p op
2824 * regardless of the @p size parameter.
2825 * - Since no more than @p size bytes can be written to @p dst, output is
2826 * truncated and may be inconsistent when the returned value is larger
2828 * - In case of conversion error, a negative error code is returned and
2829 * @p dst contents are unspecified.
2832 * Operation to perform, related to the object type of @p dst.
2834 * Destination buffer address. Must be suitably aligned by the caller.
2836 * Destination buffer size in bytes.
2838 * Source object to copy. Depending on @p op, its type may differ from
2841 * Perform verbose error reporting if not NULL. Initialized in case of
2845 * The number of bytes required to convert @p src to @p dst on success, a
2846 * negative errno value otherwise and rte_errno is set.
2848 * @see rte_flow_conv_op
2852 rte_flow_conv(enum rte_flow_conv_op op,
2856 struct rte_flow_error *error);
2862 #endif /* RTE_FLOW_H_ */