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,
427 * RTE_FLOW_ITEM_TYPE_ANY
429 * Matches any protocol in place of the current layer, a single ANY may also
430 * stand for several protocol layers.
432 * This is usually specified as the first pattern item when looking for a
433 * protocol anywhere in a packet.
435 * A zeroed mask stands for any number of layers.
437 struct rte_flow_item_any {
438 uint32_t num; /**< Number of layers covered. */
441 /** Default mask for RTE_FLOW_ITEM_TYPE_ANY. */
443 static const struct rte_flow_item_any rte_flow_item_any_mask = {
449 * RTE_FLOW_ITEM_TYPE_VF
451 * Matches traffic originating from (ingress) or going to (egress) a given
452 * virtual function of the current device.
454 * If supported, should work even if the virtual function is not managed by
455 * the application and thus not associated with a DPDK port ID.
457 * Note this pattern item does not match VF representors traffic which, as
458 * separate entities, should be addressed through their own DPDK port IDs.
460 * - Can be specified multiple times to match traffic addressed to several
462 * - Can be combined with a PF item to match both PF and VF traffic.
464 * A zeroed mask can be used to match any VF ID.
466 struct rte_flow_item_vf {
467 uint32_t id; /**< VF ID. */
470 /** Default mask for RTE_FLOW_ITEM_TYPE_VF. */
472 static const struct rte_flow_item_vf rte_flow_item_vf_mask = {
478 * RTE_FLOW_ITEM_TYPE_PHY_PORT
480 * Matches traffic originating from (ingress) or going to (egress) a
481 * physical port of the underlying device.
483 * The first PHY_PORT item overrides the physical port normally associated
484 * with the specified DPDK input port (port_id). This item can be provided
485 * several times to match additional physical ports.
487 * Note that physical ports are not necessarily tied to DPDK input ports
488 * (port_id) when those are not under DPDK control. Possible values are
489 * specific to each device, they are not necessarily indexed from zero and
490 * may not be contiguous.
492 * As a device property, the list of allowed values as well as the value
493 * associated with a port_id should be retrieved by other means.
495 * A zeroed mask can be used to match any port index.
497 struct rte_flow_item_phy_port {
498 uint32_t index; /**< Physical port index. */
501 /** Default mask for RTE_FLOW_ITEM_TYPE_PHY_PORT. */
503 static const struct rte_flow_item_phy_port rte_flow_item_phy_port_mask = {
509 * RTE_FLOW_ITEM_TYPE_PORT_ID
511 * Matches traffic originating from (ingress) or going to (egress) a given
514 * Normally only supported if the port ID in question is known by the
515 * underlying PMD and related to the device the flow rule is created
518 * This must not be confused with @p PHY_PORT which refers to the physical
519 * port of a device, whereas @p PORT_ID refers to a struct rte_eth_dev
520 * object on the application side (also known as "port representor"
521 * depending on the kind of underlying device).
523 struct rte_flow_item_port_id {
524 uint32_t id; /**< DPDK port ID. */
527 /** Default mask for RTE_FLOW_ITEM_TYPE_PORT_ID. */
529 static const struct rte_flow_item_port_id rte_flow_item_port_id_mask = {
535 * RTE_FLOW_ITEM_TYPE_RAW
537 * Matches a byte string of a given length at a given offset.
539 * Offset is either absolute (using the start of the packet) or relative to
540 * the end of the previous matched item in the stack, in which case negative
541 * values are allowed.
543 * If search is enabled, offset is used as the starting point. The search
544 * area can be delimited by setting limit to a nonzero value, which is the
545 * maximum number of bytes after offset where the pattern may start.
547 * Matching a zero-length pattern is allowed, doing so resets the relative
548 * offset for subsequent items.
550 * This type does not support ranges (struct rte_flow_item.last).
552 struct rte_flow_item_raw {
553 uint32_t relative:1; /**< Look for pattern after the previous item. */
554 uint32_t search:1; /**< Search pattern from offset (see also limit). */
555 uint32_t reserved:30; /**< Reserved, must be set to zero. */
556 int32_t offset; /**< Absolute or relative offset for pattern. */
557 uint16_t limit; /**< Search area limit for start of pattern. */
558 uint16_t length; /**< Pattern length. */
559 const uint8_t *pattern; /**< Byte string to look for. */
562 /** Default mask for RTE_FLOW_ITEM_TYPE_RAW. */
564 static const struct rte_flow_item_raw rte_flow_item_raw_mask = {
567 .reserved = 0x3fffffff,
568 .offset = 0xffffffff,
576 * RTE_FLOW_ITEM_TYPE_ETH
578 * Matches an Ethernet header.
580 * The @p type field either stands for "EtherType" or "TPID" when followed
581 * by so-called layer 2.5 pattern items such as RTE_FLOW_ITEM_TYPE_VLAN. In
582 * the latter case, @p type refers to that of the outer header, with the
583 * inner EtherType/TPID provided by the subsequent pattern item. This is the
584 * same order as on the wire.
586 struct rte_flow_item_eth {
587 struct rte_ether_addr dst; /**< Destination MAC. */
588 struct rte_ether_addr src; /**< Source MAC. */
589 rte_be16_t type; /**< EtherType or TPID. */
592 /** Default mask for RTE_FLOW_ITEM_TYPE_ETH. */
594 static const struct rte_flow_item_eth rte_flow_item_eth_mask = {
595 .dst.addr_bytes = "\xff\xff\xff\xff\xff\xff",
596 .src.addr_bytes = "\xff\xff\xff\xff\xff\xff",
597 .type = RTE_BE16(0x0000),
602 * RTE_FLOW_ITEM_TYPE_VLAN
604 * Matches an 802.1Q/ad VLAN tag.
606 * The corresponding standard outer EtherType (TPID) values are
607 * RTE_ETHER_TYPE_VLAN or RTE_ETHER_TYPE_QINQ. It can be overridden by
608 * the preceding pattern item.
610 struct rte_flow_item_vlan {
611 rte_be16_t tci; /**< Tag control information. */
612 rte_be16_t inner_type; /**< Inner EtherType or TPID. */
615 /** Default mask for RTE_FLOW_ITEM_TYPE_VLAN. */
617 static const struct rte_flow_item_vlan rte_flow_item_vlan_mask = {
618 .tci = RTE_BE16(0x0fff),
619 .inner_type = RTE_BE16(0x0000),
624 * RTE_FLOW_ITEM_TYPE_IPV4
626 * Matches an IPv4 header.
628 * Note: IPv4 options are handled by dedicated pattern items.
630 struct rte_flow_item_ipv4 {
631 struct rte_ipv4_hdr hdr; /**< IPv4 header definition. */
634 /** Default mask for RTE_FLOW_ITEM_TYPE_IPV4. */
636 static const struct rte_flow_item_ipv4 rte_flow_item_ipv4_mask = {
638 .src_addr = RTE_BE32(0xffffffff),
639 .dst_addr = RTE_BE32(0xffffffff),
645 * RTE_FLOW_ITEM_TYPE_IPV6.
647 * Matches an IPv6 header.
649 * Note: IPv6 options are handled by dedicated pattern items, see
650 * RTE_FLOW_ITEM_TYPE_IPV6_EXT.
652 struct rte_flow_item_ipv6 {
653 struct rte_ipv6_hdr hdr; /**< IPv6 header definition. */
656 /** Default mask for RTE_FLOW_ITEM_TYPE_IPV6. */
658 static const struct rte_flow_item_ipv6 rte_flow_item_ipv6_mask = {
661 "\xff\xff\xff\xff\xff\xff\xff\xff"
662 "\xff\xff\xff\xff\xff\xff\xff\xff",
664 "\xff\xff\xff\xff\xff\xff\xff\xff"
665 "\xff\xff\xff\xff\xff\xff\xff\xff",
671 * RTE_FLOW_ITEM_TYPE_ICMP.
673 * Matches an ICMP header.
675 struct rte_flow_item_icmp {
676 struct rte_icmp_hdr hdr; /**< ICMP header definition. */
679 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP. */
681 static const struct rte_flow_item_icmp rte_flow_item_icmp_mask = {
690 * RTE_FLOW_ITEM_TYPE_UDP.
692 * Matches a UDP header.
694 struct rte_flow_item_udp {
695 struct rte_udp_hdr hdr; /**< UDP header definition. */
698 /** Default mask for RTE_FLOW_ITEM_TYPE_UDP. */
700 static const struct rte_flow_item_udp rte_flow_item_udp_mask = {
702 .src_port = RTE_BE16(0xffff),
703 .dst_port = RTE_BE16(0xffff),
709 * RTE_FLOW_ITEM_TYPE_TCP.
711 * Matches a TCP header.
713 struct rte_flow_item_tcp {
714 struct rte_tcp_hdr hdr; /**< TCP header definition. */
717 /** Default mask for RTE_FLOW_ITEM_TYPE_TCP. */
719 static const struct rte_flow_item_tcp rte_flow_item_tcp_mask = {
721 .src_port = RTE_BE16(0xffff),
722 .dst_port = RTE_BE16(0xffff),
728 * RTE_FLOW_ITEM_TYPE_SCTP.
730 * Matches a SCTP header.
732 struct rte_flow_item_sctp {
733 struct rte_sctp_hdr hdr; /**< SCTP header definition. */
736 /** Default mask for RTE_FLOW_ITEM_TYPE_SCTP. */
738 static const struct rte_flow_item_sctp rte_flow_item_sctp_mask = {
740 .src_port = RTE_BE16(0xffff),
741 .dst_port = RTE_BE16(0xffff),
747 * RTE_FLOW_ITEM_TYPE_VXLAN.
749 * Matches a VXLAN header (RFC 7348).
751 struct rte_flow_item_vxlan {
752 uint8_t flags; /**< Normally 0x08 (I flag). */
753 uint8_t rsvd0[3]; /**< Reserved, normally 0x000000. */
754 uint8_t vni[3]; /**< VXLAN identifier. */
755 uint8_t rsvd1; /**< Reserved, normally 0x00. */
758 /** Default mask for RTE_FLOW_ITEM_TYPE_VXLAN. */
760 static const struct rte_flow_item_vxlan rte_flow_item_vxlan_mask = {
761 .vni = "\xff\xff\xff",
766 * RTE_FLOW_ITEM_TYPE_E_TAG.
768 * Matches a E-tag header.
770 * The corresponding standard outer EtherType (TPID) value is
771 * RTE_ETHER_TYPE_ETAG. It can be overridden by the preceding pattern item.
773 struct rte_flow_item_e_tag {
775 * E-Tag control information (E-TCI).
776 * E-PCP (3b), E-DEI (1b), ingress E-CID base (12b).
778 rte_be16_t epcp_edei_in_ecid_b;
779 /** Reserved (2b), GRP (2b), E-CID base (12b). */
780 rte_be16_t rsvd_grp_ecid_b;
781 uint8_t in_ecid_e; /**< Ingress E-CID ext. */
782 uint8_t ecid_e; /**< E-CID ext. */
783 rte_be16_t inner_type; /**< Inner EtherType or TPID. */
786 /** Default mask for RTE_FLOW_ITEM_TYPE_E_TAG. */
788 static const struct rte_flow_item_e_tag rte_flow_item_e_tag_mask = {
789 .rsvd_grp_ecid_b = RTE_BE16(0x3fff),
794 * RTE_FLOW_ITEM_TYPE_NVGRE.
796 * Matches a NVGRE header.
798 struct rte_flow_item_nvgre {
800 * Checksum (1b), undefined (1b), key bit (1b), sequence number (1b),
801 * reserved 0 (9b), version (3b).
803 * c_k_s_rsvd0_ver must have value 0x2000 according to RFC 7637.
805 rte_be16_t c_k_s_rsvd0_ver;
806 rte_be16_t protocol; /**< Protocol type (0x6558). */
807 uint8_t tni[3]; /**< Virtual subnet ID. */
808 uint8_t flow_id; /**< Flow ID. */
811 /** Default mask for RTE_FLOW_ITEM_TYPE_NVGRE. */
813 static const struct rte_flow_item_nvgre rte_flow_item_nvgre_mask = {
814 .tni = "\xff\xff\xff",
819 * RTE_FLOW_ITEM_TYPE_MPLS.
821 * Matches a MPLS header.
823 struct rte_flow_item_mpls {
825 * Label (20b), TC (3b), Bottom of Stack (1b).
827 uint8_t label_tc_s[3];
828 uint8_t ttl; /** Time-to-Live. */
831 /** Default mask for RTE_FLOW_ITEM_TYPE_MPLS. */
833 static const struct rte_flow_item_mpls rte_flow_item_mpls_mask = {
834 .label_tc_s = "\xff\xff\xf0",
839 * RTE_FLOW_ITEM_TYPE_GRE.
841 * Matches a GRE header.
843 struct rte_flow_item_gre {
845 * Checksum (1b), reserved 0 (12b), version (3b).
848 rte_be16_t c_rsvd0_ver;
849 rte_be16_t protocol; /**< Protocol type. */
852 /** Default mask for RTE_FLOW_ITEM_TYPE_GRE. */
854 static const struct rte_flow_item_gre rte_flow_item_gre_mask = {
855 .protocol = RTE_BE16(0xffff),
860 * RTE_FLOW_ITEM_TYPE_FUZZY
862 * Fuzzy pattern match, expect faster than default.
864 * This is for device that support fuzzy match option.
865 * Usually a fuzzy match is fast but the cost is accuracy.
866 * i.e. Signature Match only match pattern's hash value, but it is
867 * possible two different patterns have the same hash value.
869 * Matching accuracy level can be configure by threshold.
870 * Driver can divide the range of threshold and map to different
871 * accuracy levels that device support.
873 * Threshold 0 means perfect match (no fuzziness), while threshold
874 * 0xffffffff means fuzziest match.
876 struct rte_flow_item_fuzzy {
877 uint32_t thresh; /**< Accuracy threshold. */
880 /** Default mask for RTE_FLOW_ITEM_TYPE_FUZZY. */
882 static const struct rte_flow_item_fuzzy rte_flow_item_fuzzy_mask = {
883 .thresh = 0xffffffff,
888 * RTE_FLOW_ITEM_TYPE_GTP.
890 * Matches a GTPv1 header.
892 struct rte_flow_item_gtp {
894 * Version (3b), protocol type (1b), reserved (1b),
895 * Extension header flag (1b),
896 * Sequence number flag (1b),
897 * N-PDU number flag (1b).
899 uint8_t v_pt_rsv_flags;
900 uint8_t msg_type; /**< Message type. */
901 rte_be16_t msg_len; /**< Message length. */
902 rte_be32_t teid; /**< Tunnel endpoint identifier. */
905 /** Default mask for RTE_FLOW_ITEM_TYPE_GTP. */
907 static const struct rte_flow_item_gtp rte_flow_item_gtp_mask = {
908 .teid = RTE_BE32(0xffffffff),
913 * RTE_FLOW_ITEM_TYPE_ESP
915 * Matches an ESP header.
917 struct rte_flow_item_esp {
918 struct rte_esp_hdr hdr; /**< ESP header definition. */
921 /** Default mask for RTE_FLOW_ITEM_TYPE_ESP. */
923 static const struct rte_flow_item_esp rte_flow_item_esp_mask = {
931 * RTE_FLOW_ITEM_TYPE_GENEVE.
933 * Matches a GENEVE header.
935 struct rte_flow_item_geneve {
937 * Version (2b), length of the options fields (6b), OAM packet (1b),
938 * critical options present (1b), reserved 0 (6b).
940 rte_be16_t ver_opt_len_o_c_rsvd0;
941 rte_be16_t protocol; /**< Protocol type. */
942 uint8_t vni[3]; /**< Virtual Network Identifier. */
943 uint8_t rsvd1; /**< Reserved, normally 0x00. */
946 /** Default mask for RTE_FLOW_ITEM_TYPE_GENEVE. */
948 static const struct rte_flow_item_geneve rte_flow_item_geneve_mask = {
949 .vni = "\xff\xff\xff",
954 * RTE_FLOW_ITEM_TYPE_VXLAN_GPE (draft-ietf-nvo3-vxlan-gpe-05).
956 * Matches a VXLAN-GPE header.
958 struct rte_flow_item_vxlan_gpe {
959 uint8_t flags; /**< Normally 0x0c (I and P flags). */
960 uint8_t rsvd0[2]; /**< Reserved, normally 0x0000. */
961 uint8_t protocol; /**< Protocol type. */
962 uint8_t vni[3]; /**< VXLAN identifier. */
963 uint8_t rsvd1; /**< Reserved, normally 0x00. */
966 /** Default mask for RTE_FLOW_ITEM_TYPE_VXLAN_GPE. */
968 static const struct rte_flow_item_vxlan_gpe rte_flow_item_vxlan_gpe_mask = {
969 .vni = "\xff\xff\xff",
974 * RTE_FLOW_ITEM_TYPE_ARP_ETH_IPV4
976 * Matches an ARP header for Ethernet/IPv4.
978 struct rte_flow_item_arp_eth_ipv4 {
979 rte_be16_t hrd; /**< Hardware type, normally 1. */
980 rte_be16_t pro; /**< Protocol type, normally 0x0800. */
981 uint8_t hln; /**< Hardware address length, normally 6. */
982 uint8_t pln; /**< Protocol address length, normally 4. */
983 rte_be16_t op; /**< Opcode (1 for request, 2 for reply). */
984 struct rte_ether_addr sha; /**< Sender hardware address. */
985 rte_be32_t spa; /**< Sender IPv4 address. */
986 struct rte_ether_addr tha; /**< Target hardware address. */
987 rte_be32_t tpa; /**< Target IPv4 address. */
990 /** Default mask for RTE_FLOW_ITEM_TYPE_ARP_ETH_IPV4. */
992 static const struct rte_flow_item_arp_eth_ipv4
993 rte_flow_item_arp_eth_ipv4_mask = {
994 .sha.addr_bytes = "\xff\xff\xff\xff\xff\xff",
995 .spa = RTE_BE32(0xffffffff),
996 .tha.addr_bytes = "\xff\xff\xff\xff\xff\xff",
997 .tpa = RTE_BE32(0xffffffff),
1002 * RTE_FLOW_ITEM_TYPE_IPV6_EXT
1004 * Matches the presence of any IPv6 extension header.
1006 * Normally preceded by any of:
1008 * - RTE_FLOW_ITEM_TYPE_IPV6
1009 * - RTE_FLOW_ITEM_TYPE_IPV6_EXT
1011 struct rte_flow_item_ipv6_ext {
1012 uint8_t next_hdr; /**< Next header. */
1015 /** Default mask for RTE_FLOW_ITEM_TYPE_IPV6_EXT. */
1018 struct rte_flow_item_ipv6_ext rte_flow_item_ipv6_ext_mask = {
1024 * RTE_FLOW_ITEM_TYPE_ICMP6
1026 * Matches any ICMPv6 header.
1028 struct rte_flow_item_icmp6 {
1029 uint8_t type; /**< ICMPv6 type. */
1030 uint8_t code; /**< ICMPv6 code. */
1031 uint16_t checksum; /**< ICMPv6 checksum. */
1034 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6. */
1036 static const struct rte_flow_item_icmp6 rte_flow_item_icmp6_mask = {
1043 * RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS
1045 * Matches an ICMPv6 neighbor discovery solicitation.
1047 struct rte_flow_item_icmp6_nd_ns {
1048 uint8_t type; /**< ICMPv6 type, normally 135. */
1049 uint8_t code; /**< ICMPv6 code, normally 0. */
1050 rte_be16_t checksum; /**< ICMPv6 checksum. */
1051 rte_be32_t reserved; /**< Reserved, normally 0. */
1052 uint8_t target_addr[16]; /**< Target address. */
1055 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS. */
1058 struct rte_flow_item_icmp6_nd_ns rte_flow_item_icmp6_nd_ns_mask = {
1060 "\xff\xff\xff\xff\xff\xff\xff\xff"
1061 "\xff\xff\xff\xff\xff\xff\xff\xff",
1066 * RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA
1068 * Matches an ICMPv6 neighbor discovery advertisement.
1070 struct rte_flow_item_icmp6_nd_na {
1071 uint8_t type; /**< ICMPv6 type, normally 136. */
1072 uint8_t code; /**< ICMPv6 code, normally 0. */
1073 rte_be16_t checksum; /**< ICMPv6 checksum. */
1075 * Route flag (1b), solicited flag (1b), override flag (1b),
1078 rte_be32_t rso_reserved;
1079 uint8_t target_addr[16]; /**< Target address. */
1082 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA. */
1085 struct rte_flow_item_icmp6_nd_na rte_flow_item_icmp6_nd_na_mask = {
1087 "\xff\xff\xff\xff\xff\xff\xff\xff"
1088 "\xff\xff\xff\xff\xff\xff\xff\xff",
1093 * RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT
1095 * Matches the presence of any ICMPv6 neighbor discovery option.
1097 * Normally preceded by any of:
1099 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA
1100 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS
1101 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT
1103 struct rte_flow_item_icmp6_nd_opt {
1104 uint8_t type; /**< ND option type. */
1105 uint8_t length; /**< ND option length. */
1108 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT. */
1110 static const struct rte_flow_item_icmp6_nd_opt
1111 rte_flow_item_icmp6_nd_opt_mask = {
1117 * RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_SLA_ETH
1119 * Matches an ICMPv6 neighbor discovery source Ethernet link-layer address
1122 * Normally preceded by any of:
1124 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA
1125 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT
1127 struct rte_flow_item_icmp6_nd_opt_sla_eth {
1128 uint8_t type; /**< ND option type, normally 1. */
1129 uint8_t length; /**< ND option length, normally 1. */
1130 struct rte_ether_addr sla; /**< Source Ethernet LLA. */
1133 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_SLA_ETH. */
1135 static const struct rte_flow_item_icmp6_nd_opt_sla_eth
1136 rte_flow_item_icmp6_nd_opt_sla_eth_mask = {
1137 .sla.addr_bytes = "\xff\xff\xff\xff\xff\xff",
1142 * RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_TLA_ETH
1144 * Matches an ICMPv6 neighbor discovery target Ethernet link-layer address
1147 * Normally preceded by any of:
1149 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS
1150 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT
1152 struct rte_flow_item_icmp6_nd_opt_tla_eth {
1153 uint8_t type; /**< ND option type, normally 2. */
1154 uint8_t length; /**< ND option length, normally 1. */
1155 struct rte_ether_addr tla; /**< Target Ethernet LLA. */
1158 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_TLA_ETH. */
1160 static const struct rte_flow_item_icmp6_nd_opt_tla_eth
1161 rte_flow_item_icmp6_nd_opt_tla_eth_mask = {
1162 .tla.addr_bytes = "\xff\xff\xff\xff\xff\xff",
1167 * RTE_FLOW_ITEM_TYPE_META.
1169 * Matches a specified metadata value.
1171 struct rte_flow_item_meta {
1175 /** Default mask for RTE_FLOW_ITEM_TYPE_META. */
1177 static const struct rte_flow_item_meta rte_flow_item_meta_mask = {
1178 .data = RTE_BE32(UINT32_MAX),
1184 * @b EXPERIMENTAL: this structure may change without prior notice
1186 * RTE_FLOW_ITEM_TYPE_MARK
1188 * Matches an arbitrary integer value which was set using the ``MARK`` action
1189 * in a previously matched rule.
1191 * This item can only be specified once as a match criteria as the ``MARK``
1192 * action can only be specified once in a flow action.
1194 * This value is arbitrary and application-defined. Maximum allowed value
1195 * depends on the underlying implementation.
1197 * Depending on the underlying implementation the MARK item may be supported on
1198 * the physical device, with virtual groups in the PMD or not at all.
1200 struct rte_flow_item_mark {
1201 uint32_t id; /**< Integer value to match against. */
1205 * Matching pattern item definition.
1207 * A pattern is formed by stacking items starting from the lowest protocol
1208 * layer to match. This stacking restriction does not apply to meta items
1209 * which can be placed anywhere in the stack without affecting the meaning
1210 * of the resulting pattern.
1212 * Patterns are terminated by END items.
1214 * The spec field should be a valid pointer to a structure of the related
1215 * item type. It may remain unspecified (NULL) in many cases to request
1216 * broad (nonspecific) matching. In such cases, last and mask must also be
1219 * Optionally, last can point to a structure of the same type to define an
1220 * inclusive range. This is mostly supported by integer and address fields,
1221 * may cause errors otherwise. Fields that do not support ranges must be set
1222 * to 0 or to the same value as the corresponding fields in spec.
1224 * Only the fields defined to nonzero values in the default masks (see
1225 * rte_flow_item_{name}_mask constants) are considered relevant by
1226 * default. This can be overridden by providing a mask structure of the
1227 * same type with applicable bits set to one. It can also be used to
1228 * partially filter out specific fields (e.g. as an alternate mean to match
1229 * ranges of IP addresses).
1231 * Mask is a simple bit-mask applied before interpreting the contents of
1232 * spec and last, which may yield unexpected results if not used
1233 * carefully. For example, if for an IPv4 address field, spec provides
1234 * 10.1.2.3, last provides 10.3.4.5 and mask provides 255.255.0.0, the
1235 * effective range becomes 10.1.0.0 to 10.3.255.255.
1237 struct rte_flow_item {
1238 enum rte_flow_item_type type; /**< Item type. */
1239 const void *spec; /**< Pointer to item specification structure. */
1240 const void *last; /**< Defines an inclusive range (spec to last). */
1241 const void *mask; /**< Bit-mask applied to spec and last. */
1247 * Each possible action is represented by a type.
1248 * An action can have an associated configuration object.
1249 * Several actions combined in a list can be assigned
1250 * to a flow rule and are performed in order.
1252 * They fall in three categories:
1254 * - Actions that modify the fate of matching traffic, for instance by
1255 * dropping or assigning it a specific destination.
1257 * - Actions that modify matching traffic contents or its properties. This
1258 * includes adding/removing encapsulation, encryption, compression and
1261 * - Actions related to the flow rule itself, such as updating counters or
1262 * making it non-terminating.
1264 * Flow rules being terminating by default, not specifying any action of the
1265 * fate kind results in undefined behavior. This applies to both ingress and
1268 * PASSTHRU, when supported, makes a flow rule non-terminating.
1270 enum rte_flow_action_type {
1272 * End marker for action lists. Prevents further processing of
1273 * actions, thereby ending the list.
1275 * No associated configuration structure.
1277 RTE_FLOW_ACTION_TYPE_END,
1280 * Used as a placeholder for convenience. It is ignored and simply
1281 * discarded by PMDs.
1283 * No associated configuration structure.
1285 RTE_FLOW_ACTION_TYPE_VOID,
1288 * Leaves traffic up for additional processing by subsequent flow
1289 * rules; makes a flow rule non-terminating.
1291 * No associated configuration structure.
1293 RTE_FLOW_ACTION_TYPE_PASSTHRU,
1296 * RTE_FLOW_ACTION_TYPE_JUMP
1298 * Redirects packets to a group on the current device.
1300 * See struct rte_flow_action_jump.
1302 RTE_FLOW_ACTION_TYPE_JUMP,
1305 * Attaches an integer value to packets and sets PKT_RX_FDIR and
1306 * PKT_RX_FDIR_ID mbuf flags.
1308 * See struct rte_flow_action_mark.
1310 RTE_FLOW_ACTION_TYPE_MARK,
1313 * Flags packets. Similar to MARK without a specific value; only
1314 * sets the PKT_RX_FDIR mbuf flag.
1316 * No associated configuration structure.
1318 RTE_FLOW_ACTION_TYPE_FLAG,
1321 * Assigns packets to a given queue index.
1323 * See struct rte_flow_action_queue.
1325 RTE_FLOW_ACTION_TYPE_QUEUE,
1330 * PASSTHRU overrides this action if both are specified.
1332 * No associated configuration structure.
1334 RTE_FLOW_ACTION_TYPE_DROP,
1337 * Enables counters for this flow rule.
1339 * These counters can be retrieved and reset through rte_flow_query(),
1340 * see struct rte_flow_query_count.
1342 * See struct rte_flow_action_count.
1344 RTE_FLOW_ACTION_TYPE_COUNT,
1347 * Similar to QUEUE, except RSS is additionally performed on packets
1348 * to spread them among several queues according to the provided
1351 * See struct rte_flow_action_rss.
1353 RTE_FLOW_ACTION_TYPE_RSS,
1356 * Directs matching traffic to the physical function (PF) of the
1359 * No associated configuration structure.
1361 RTE_FLOW_ACTION_TYPE_PF,
1364 * Directs matching traffic to a given virtual function of the
1367 * See struct rte_flow_action_vf.
1369 RTE_FLOW_ACTION_TYPE_VF,
1372 * Directs packets to a given physical port index of the underlying
1375 * See struct rte_flow_action_phy_port.
1377 RTE_FLOW_ACTION_TYPE_PHY_PORT,
1380 * Directs matching traffic to a given DPDK port ID.
1382 * See struct rte_flow_action_port_id.
1384 RTE_FLOW_ACTION_TYPE_PORT_ID,
1387 * Traffic metering and policing (MTR).
1389 * See struct rte_flow_action_meter.
1390 * See file rte_mtr.h for MTR object configuration.
1392 RTE_FLOW_ACTION_TYPE_METER,
1395 * Redirects packets to security engine of current device for security
1396 * processing as specified by security session.
1398 * See struct rte_flow_action_security.
1400 RTE_FLOW_ACTION_TYPE_SECURITY,
1403 * Implements OFPAT_SET_MPLS_TTL ("MPLS TTL") as defined by the
1404 * OpenFlow Switch Specification.
1406 * See struct rte_flow_action_of_set_mpls_ttl.
1408 RTE_FLOW_ACTION_TYPE_OF_SET_MPLS_TTL,
1411 * Implements OFPAT_DEC_MPLS_TTL ("decrement MPLS TTL") as defined
1412 * by the OpenFlow Switch Specification.
1414 * No associated configuration structure.
1416 RTE_FLOW_ACTION_TYPE_OF_DEC_MPLS_TTL,
1419 * Implements OFPAT_SET_NW_TTL ("IP TTL") as defined by the OpenFlow
1420 * Switch Specification.
1422 * See struct rte_flow_action_of_set_nw_ttl.
1424 RTE_FLOW_ACTION_TYPE_OF_SET_NW_TTL,
1427 * Implements OFPAT_DEC_NW_TTL ("decrement IP TTL") as defined by
1428 * the OpenFlow Switch Specification.
1430 * No associated configuration structure.
1432 RTE_FLOW_ACTION_TYPE_OF_DEC_NW_TTL,
1435 * Implements OFPAT_COPY_TTL_OUT ("copy TTL "outwards" -- from
1436 * next-to-outermost to outermost") as defined by the OpenFlow
1437 * Switch Specification.
1439 * No associated configuration structure.
1441 RTE_FLOW_ACTION_TYPE_OF_COPY_TTL_OUT,
1444 * Implements OFPAT_COPY_TTL_IN ("copy TTL "inwards" -- from
1445 * outermost to next-to-outermost") as defined by the OpenFlow
1446 * Switch Specification.
1448 * No associated configuration structure.
1450 RTE_FLOW_ACTION_TYPE_OF_COPY_TTL_IN,
1453 * Implements OFPAT_POP_VLAN ("pop the outer VLAN tag") as defined
1454 * by the OpenFlow Switch Specification.
1456 * No associated configuration structure.
1458 RTE_FLOW_ACTION_TYPE_OF_POP_VLAN,
1461 * Implements OFPAT_PUSH_VLAN ("push a new VLAN tag") as defined by
1462 * the OpenFlow Switch Specification.
1464 * See struct rte_flow_action_of_push_vlan.
1466 RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN,
1469 * Implements OFPAT_SET_VLAN_VID ("set the 802.1q VLAN id") as
1470 * defined by the OpenFlow Switch Specification.
1472 * See struct rte_flow_action_of_set_vlan_vid.
1474 RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID,
1477 * Implements OFPAT_SET_LAN_PCP ("set the 802.1q priority") as
1478 * defined by the OpenFlow Switch Specification.
1480 * See struct rte_flow_action_of_set_vlan_pcp.
1482 RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP,
1485 * Implements OFPAT_POP_MPLS ("pop the outer MPLS tag") as defined
1486 * by the OpenFlow Switch Specification.
1488 * See struct rte_flow_action_of_pop_mpls.
1490 RTE_FLOW_ACTION_TYPE_OF_POP_MPLS,
1493 * Implements OFPAT_PUSH_MPLS ("push a new MPLS tag") as defined by
1494 * the OpenFlow Switch Specification.
1496 * See struct rte_flow_action_of_push_mpls.
1498 RTE_FLOW_ACTION_TYPE_OF_PUSH_MPLS,
1501 * Encapsulate flow in VXLAN tunnel as defined in
1502 * rte_flow_action_vxlan_encap action structure.
1504 * See struct rte_flow_action_vxlan_encap.
1506 RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP,
1509 * Decapsulate outer most VXLAN tunnel from matched flow.
1511 * If flow pattern does not define a valid VXLAN tunnel (as specified by
1512 * RFC7348) then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION
1515 RTE_FLOW_ACTION_TYPE_VXLAN_DECAP,
1518 * Encapsulate flow in NVGRE tunnel defined in the
1519 * rte_flow_action_nvgre_encap action structure.
1521 * See struct rte_flow_action_nvgre_encap.
1523 RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP,
1526 * Decapsulate outer most NVGRE tunnel from matched flow.
1528 * If flow pattern does not define a valid NVGRE tunnel (as specified by
1529 * RFC7637) then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION
1532 RTE_FLOW_ACTION_TYPE_NVGRE_DECAP,
1535 * Add outer header whose template is provided in its data buffer
1537 * See struct rte_flow_action_raw_encap.
1539 RTE_FLOW_ACTION_TYPE_RAW_ENCAP,
1542 * Remove outer header whose template is provided in its data buffer.
1544 * See struct rte_flow_action_raw_decap
1546 RTE_FLOW_ACTION_TYPE_RAW_DECAP,
1549 * Modify IPv4 source address in the outermost IPv4 header.
1551 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV4,
1552 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
1554 * See struct rte_flow_action_set_ipv4.
1556 RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC,
1559 * Modify IPv4 destination address in the outermost IPv4 header.
1561 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV4,
1562 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
1564 * See struct rte_flow_action_set_ipv4.
1566 RTE_FLOW_ACTION_TYPE_SET_IPV4_DST,
1569 * Modify IPv6 source address in the outermost IPv6 header.
1571 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV6,
1572 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
1574 * See struct rte_flow_action_set_ipv6.
1576 RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC,
1579 * Modify IPv6 destination address in the outermost IPv6 header.
1581 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV6,
1582 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
1584 * See struct rte_flow_action_set_ipv6.
1586 RTE_FLOW_ACTION_TYPE_SET_IPV6_DST,
1589 * Modify source port number in the outermost TCP/UDP header.
1591 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_TCP
1592 * or RTE_FLOW_ITEM_TYPE_UDP, then the PMD should return a
1593 * RTE_FLOW_ERROR_TYPE_ACTION error.
1595 * See struct rte_flow_action_set_tp.
1597 RTE_FLOW_ACTION_TYPE_SET_TP_SRC,
1600 * Modify destination port number in the outermost TCP/UDP header.
1602 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_TCP
1603 * or RTE_FLOW_ITEM_TYPE_UDP, then the PMD should return a
1604 * RTE_FLOW_ERROR_TYPE_ACTION error.
1606 * See struct rte_flow_action_set_tp.
1608 RTE_FLOW_ACTION_TYPE_SET_TP_DST,
1611 * Swap the source and destination MAC addresses in the outermost
1614 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_ETH,
1615 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
1617 * No associated configuration structure.
1619 RTE_FLOW_ACTION_TYPE_MAC_SWAP,
1622 * Decrease TTL value directly
1624 * No associated configuration structure.
1626 RTE_FLOW_ACTION_TYPE_DEC_TTL,
1631 * See struct rte_flow_action_set_ttl
1633 RTE_FLOW_ACTION_TYPE_SET_TTL,
1636 * Set source MAC address from matched flow.
1638 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_ETH,
1639 * the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
1641 * See struct rte_flow_action_set_mac.
1643 RTE_FLOW_ACTION_TYPE_SET_MAC_SRC,
1646 * Set destination MAC address from matched flow.
1648 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_ETH,
1649 * the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
1651 * See struct rte_flow_action_set_mac.
1653 RTE_FLOW_ACTION_TYPE_SET_MAC_DST,
1656 * Increase sequence number in the outermost TCP header.
1658 * Action configuration specifies the value to increase
1659 * TCP sequence number as a big-endian 32 bit integer.
1662 * @code rte_be32_t * @endcode
1664 * Using this action on non-matching traffic will result in
1665 * undefined behavior.
1667 RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ,
1670 * Decrease sequence number in the outermost TCP header.
1672 * Action configuration specifies the value to decrease
1673 * TCP sequence number as a big-endian 32 bit integer.
1676 * @code rte_be32_t * @endcode
1678 * Using this action on non-matching traffic will result in
1679 * undefined behavior.
1681 RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ,
1684 * Increase acknowledgment number in the outermost TCP header.
1686 * Action configuration specifies the value to increase
1687 * TCP acknowledgment number as a big-endian 32 bit integer.
1690 * @code rte_be32_t * @endcode
1692 * Using this action on non-matching traffic will result in
1693 * undefined behavior.
1695 RTE_FLOW_ACTION_TYPE_INC_TCP_ACK,
1698 * Decrease acknowledgment number in the outermost TCP header.
1700 * Action configuration specifies the value to decrease
1701 * TCP acknowledgment number as a big-endian 32 bit integer.
1704 * @code rte_be32_t * @endcode
1706 * Using this action on non-matching traffic will result in
1707 * undefined behavior.
1709 RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK,
1713 * RTE_FLOW_ACTION_TYPE_MARK
1715 * Attaches an integer value to packets and sets PKT_RX_FDIR and
1716 * PKT_RX_FDIR_ID mbuf flags.
1718 * This value is arbitrary and application-defined. Maximum allowed value
1719 * depends on the underlying implementation. It is returned in the
1720 * hash.fdir.hi mbuf field.
1722 struct rte_flow_action_mark {
1723 uint32_t id; /**< Integer value to return with packets. */
1728 * @b EXPERIMENTAL: this structure may change without prior notice
1730 * RTE_FLOW_ACTION_TYPE_JUMP
1732 * Redirects packets to a group on the current device.
1734 * In a hierarchy of groups, which can be used to represent physical or logical
1735 * flow tables on the device, this action allows the action to be a redirect to
1736 * a group on that device.
1738 struct rte_flow_action_jump {
1743 * RTE_FLOW_ACTION_TYPE_QUEUE
1745 * Assign packets to a given queue index.
1747 struct rte_flow_action_queue {
1748 uint16_t index; /**< Queue index to use. */
1754 * @b EXPERIMENTAL: this structure may change without prior notice
1756 * RTE_FLOW_ACTION_TYPE_COUNT
1758 * Adds a counter action to a matched flow.
1760 * If more than one count action is specified in a single flow rule, then each
1761 * action must specify a unique id.
1763 * Counters can be retrieved and reset through ``rte_flow_query()``, see
1764 * ``struct rte_flow_query_count``.
1766 * The shared flag indicates whether the counter is unique to the flow rule the
1767 * action is specified with, or whether it is a shared counter.
1769 * For a count action with the shared flag set, then then a global device
1770 * namespace is assumed for the counter id, so that any matched flow rules using
1771 * a count action with the same counter id on the same port will contribute to
1774 * For ports within the same switch domain then the counter id namespace extends
1775 * to all ports within that switch domain.
1777 struct rte_flow_action_count {
1778 uint32_t shared:1; /**< Share counter ID with other flow rules. */
1779 uint32_t reserved:31; /**< Reserved, must be zero. */
1780 uint32_t id; /**< Counter ID. */
1784 * RTE_FLOW_ACTION_TYPE_COUNT (query)
1786 * Query structure to retrieve and reset flow rule counters.
1788 struct rte_flow_query_count {
1789 uint32_t reset:1; /**< Reset counters after query [in]. */
1790 uint32_t hits_set:1; /**< hits field is set [out]. */
1791 uint32_t bytes_set:1; /**< bytes field is set [out]. */
1792 uint32_t reserved:29; /**< Reserved, must be zero [in, out]. */
1793 uint64_t hits; /**< Number of hits for this rule [out]. */
1794 uint64_t bytes; /**< Number of bytes through this rule [out]. */
1798 * Hash function types.
1800 enum rte_eth_hash_function {
1801 RTE_ETH_HASH_FUNCTION_DEFAULT = 0,
1802 RTE_ETH_HASH_FUNCTION_TOEPLITZ, /**< Toeplitz */
1803 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR, /**< Simple XOR */
1804 RTE_ETH_HASH_FUNCTION_MAX,
1808 * RTE_FLOW_ACTION_TYPE_RSS
1810 * Similar to QUEUE, except RSS is additionally performed on packets to
1811 * spread them among several queues according to the provided parameters.
1813 * Unlike global RSS settings used by other DPDK APIs, unsetting the
1814 * @p types field does not disable RSS in a flow rule. Doing so instead
1815 * requests safe unspecified "best-effort" settings from the underlying PMD,
1816 * which depending on the flow rule, may result in anything ranging from
1817 * empty (single queue) to all-inclusive RSS.
1819 * Note: RSS hash result is stored in the hash.rss mbuf field which overlaps
1820 * hash.fdir.lo. Since the MARK action sets the hash.fdir.hi field only,
1821 * both can be requested simultaneously.
1823 struct rte_flow_action_rss {
1824 enum rte_eth_hash_function func; /**< RSS hash function to apply. */
1826 * Packet encapsulation level RSS hash @p types apply to.
1828 * - @p 0 requests the default behavior. Depending on the packet
1829 * type, it can mean outermost, innermost, anything in between or
1832 * It basically stands for the innermost encapsulation level RSS
1833 * can be performed on according to PMD and device capabilities.
1835 * - @p 1 requests RSS to be performed on the outermost packet
1836 * encapsulation level.
1838 * - @p 2 and subsequent values request RSS to be performed on the
1839 * specified inner packet encapsulation level, from outermost to
1840 * innermost (lower to higher values).
1842 * Values other than @p 0 are not necessarily supported.
1844 * Requesting a specific RSS level on unrecognized traffic results
1845 * in undefined behavior. For predictable results, it is recommended
1846 * to make the flow rule pattern match packet headers up to the
1847 * requested encapsulation level so that only matching traffic goes
1851 uint64_t types; /**< Specific RSS hash types (see ETH_RSS_*). */
1852 uint32_t key_len; /**< Hash key length in bytes. */
1853 uint32_t queue_num; /**< Number of entries in @p queue. */
1854 const uint8_t *key; /**< Hash key. */
1855 const uint16_t *queue; /**< Queue indices to use. */
1859 * RTE_FLOW_ACTION_TYPE_VF
1861 * Directs matching traffic to a given virtual function of the current
1864 * Packets matched by a VF pattern item can be redirected to their original
1865 * VF ID instead of the specified one. This parameter may not be available
1866 * and is not guaranteed to work properly if the VF part is matched by a
1867 * prior flow rule or if packets are not addressed to a VF in the first
1870 struct rte_flow_action_vf {
1871 uint32_t original:1; /**< Use original VF ID if possible. */
1872 uint32_t reserved:31; /**< Reserved, must be zero. */
1873 uint32_t id; /**< VF ID. */
1877 * RTE_FLOW_ACTION_TYPE_PHY_PORT
1879 * Directs packets to a given physical port index of the underlying
1882 * @see RTE_FLOW_ITEM_TYPE_PHY_PORT
1884 struct rte_flow_action_phy_port {
1885 uint32_t original:1; /**< Use original port index if possible. */
1886 uint32_t reserved:31; /**< Reserved, must be zero. */
1887 uint32_t index; /**< Physical port index. */
1891 * RTE_FLOW_ACTION_TYPE_PORT_ID
1893 * Directs matching traffic to a given DPDK port ID.
1895 * @see RTE_FLOW_ITEM_TYPE_PORT_ID
1897 struct rte_flow_action_port_id {
1898 uint32_t original:1; /**< Use original DPDK port ID if possible. */
1899 uint32_t reserved:31; /**< Reserved, must be zero. */
1900 uint32_t id; /**< DPDK port ID. */
1904 * RTE_FLOW_ACTION_TYPE_METER
1906 * Traffic metering and policing (MTR).
1908 * Packets matched by items of this type can be either dropped or passed to the
1909 * next item with their color set by the MTR object.
1911 struct rte_flow_action_meter {
1912 uint32_t mtr_id; /**< MTR object ID created with rte_mtr_create(). */
1916 * RTE_FLOW_ACTION_TYPE_SECURITY
1918 * Perform the security action on flows matched by the pattern items
1919 * according to the configuration of the security session.
1921 * This action modifies the payload of matched flows. For INLINE_CRYPTO, the
1922 * security protocol headers and IV are fully provided by the application as
1923 * specified in the flow pattern. The payload of matching packets is
1924 * encrypted on egress, and decrypted and authenticated on ingress.
1925 * For INLINE_PROTOCOL, the security protocol is fully offloaded to HW,
1926 * providing full encapsulation and decapsulation of packets in security
1927 * protocols. The flow pattern specifies both the outer security header fields
1928 * and the inner packet fields. The security session specified in the action
1929 * must match the pattern parameters.
1931 * The security session specified in the action must be created on the same
1932 * port as the flow action that is being specified.
1934 * The ingress/egress flow attribute should match that specified in the
1935 * security session if the security session supports the definition of the
1938 * Multiple flows can be configured to use the same security session.
1940 struct rte_flow_action_security {
1941 void *security_session; /**< Pointer to security session structure. */
1945 * RTE_FLOW_ACTION_TYPE_OF_SET_MPLS_TTL
1947 * Implements OFPAT_SET_MPLS_TTL ("MPLS TTL") as defined by the OpenFlow
1948 * Switch Specification.
1950 struct rte_flow_action_of_set_mpls_ttl {
1951 uint8_t mpls_ttl; /**< MPLS TTL. */
1955 * RTE_FLOW_ACTION_TYPE_OF_SET_NW_TTL
1957 * Implements OFPAT_SET_NW_TTL ("IP TTL") as defined by the OpenFlow Switch
1960 struct rte_flow_action_of_set_nw_ttl {
1961 uint8_t nw_ttl; /**< IP TTL. */
1965 * RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN
1967 * Implements OFPAT_PUSH_VLAN ("push a new VLAN tag") as defined by the
1968 * OpenFlow Switch Specification.
1970 struct rte_flow_action_of_push_vlan {
1971 rte_be16_t ethertype; /**< EtherType. */
1975 * RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID
1977 * Implements OFPAT_SET_VLAN_VID ("set the 802.1q VLAN id") as defined by
1978 * the OpenFlow Switch Specification.
1980 struct rte_flow_action_of_set_vlan_vid {
1981 rte_be16_t vlan_vid; /**< VLAN id. */
1985 * RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP
1987 * Implements OFPAT_SET_LAN_PCP ("set the 802.1q priority") as defined by
1988 * the OpenFlow Switch Specification.
1990 struct rte_flow_action_of_set_vlan_pcp {
1991 uint8_t vlan_pcp; /**< VLAN priority. */
1995 * RTE_FLOW_ACTION_TYPE_OF_POP_MPLS
1997 * Implements OFPAT_POP_MPLS ("pop the outer MPLS tag") as defined by the
1998 * OpenFlow Switch Specification.
2000 struct rte_flow_action_of_pop_mpls {
2001 rte_be16_t ethertype; /**< EtherType. */
2005 * RTE_FLOW_ACTION_TYPE_OF_PUSH_MPLS
2007 * Implements OFPAT_PUSH_MPLS ("push a new MPLS tag") as defined by the
2008 * OpenFlow Switch Specification.
2010 struct rte_flow_action_of_push_mpls {
2011 rte_be16_t ethertype; /**< EtherType. */
2016 * @b EXPERIMENTAL: this structure may change without prior notice
2018 * RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP
2020 * VXLAN tunnel end-point encapsulation data definition
2022 * The tunnel definition is provided through the flow item pattern, the
2023 * provided pattern must conform to RFC7348 for the tunnel specified. The flow
2024 * definition must be provided in order from the RTE_FLOW_ITEM_TYPE_ETH
2025 * definition up the end item which is specified by RTE_FLOW_ITEM_TYPE_END.
2027 * The mask field allows user to specify which fields in the flow item
2028 * definitions can be ignored and which have valid data and can be used
2031 * Note: the last field is not used in the definition of a tunnel and can be
2034 * Valid flow definition for RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP include:
2036 * - ETH / IPV4 / UDP / VXLAN / END
2037 * - ETH / IPV6 / UDP / VXLAN / END
2038 * - ETH / VLAN / IPV4 / UDP / VXLAN / END
2041 struct rte_flow_action_vxlan_encap {
2043 * Encapsulating vxlan tunnel definition
2044 * (terminated by the END pattern item).
2046 struct rte_flow_item *definition;
2051 * @b EXPERIMENTAL: this structure may change without prior notice
2053 * RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP
2055 * NVGRE tunnel end-point encapsulation data definition
2057 * The tunnel definition is provided through the flow item pattern the
2058 * provided pattern must conform with RFC7637. The flow definition must be
2059 * provided in order from the RTE_FLOW_ITEM_TYPE_ETH definition up the end item
2060 * which is specified by RTE_FLOW_ITEM_TYPE_END.
2062 * The mask field allows user to specify which fields in the flow item
2063 * definitions can be ignored and which have valid data and can be used
2066 * Note: the last field is not used in the definition of a tunnel and can be
2069 * Valid flow definition for RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP include:
2071 * - ETH / IPV4 / NVGRE / END
2072 * - ETH / VLAN / IPV6 / NVGRE / END
2075 struct rte_flow_action_nvgre_encap {
2077 * Encapsulating vxlan tunnel definition
2078 * (terminated by the END pattern item).
2080 struct rte_flow_item *definition;
2085 * @b EXPERIMENTAL: this structure may change without prior notice
2087 * RTE_FLOW_ACTION_TYPE_RAW_ENCAP
2089 * Raw tunnel end-point encapsulation data definition.
2091 * The data holds the headers definitions to be applied on the packet.
2092 * The data must start with ETH header up to the tunnel item header itself.
2093 * When used right after RAW_DECAP (for decapsulating L3 tunnel type for
2094 * example MPLSoGRE) the data will just hold layer 2 header.
2096 * The preserve parameter holds which bits in the packet the PMD is not allowed
2097 * to change, this parameter can also be NULL and then the PMD is allowed
2098 * to update any field.
2100 * size holds the number of bytes in @p data and @p preserve.
2102 struct rte_flow_action_raw_encap {
2103 uint8_t *data; /**< Encapsulation data. */
2104 uint8_t *preserve; /**< Bit-mask of @p data to preserve on output. */
2105 size_t size; /**< Size of @p data and @p preserve. */
2110 * @b EXPERIMENTAL: this structure may change without prior notice
2112 * RTE_FLOW_ACTION_TYPE_RAW_DECAP
2114 * Raw tunnel end-point decapsulation data definition.
2116 * The data holds the headers definitions to be removed from the packet.
2117 * The data must start with ETH header up to the tunnel item header itself.
2118 * When used right before RAW_DECAP (for encapsulating L3 tunnel type for
2119 * example MPLSoGRE) the data will just hold layer 2 header.
2121 * size holds the number of bytes in @p data.
2123 struct rte_flow_action_raw_decap {
2124 uint8_t *data; /**< Encapsulation data. */
2125 size_t size; /**< Size of @p data and @p preserve. */
2130 * @b EXPERIMENTAL: this structure may change without prior notice
2132 * RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC
2133 * RTE_FLOW_ACTION_TYPE_SET_IPV4_DST
2135 * Allows modification of IPv4 source (RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC)
2136 * and destination address (RTE_FLOW_ACTION_TYPE_SET_IPV4_DST) in the
2137 * specified outermost IPv4 header.
2139 struct rte_flow_action_set_ipv4 {
2140 rte_be32_t ipv4_addr;
2145 * @b EXPERIMENTAL: this structure may change without prior notice
2147 * RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC
2148 * RTE_FLOW_ACTION_TYPE_SET_IPV6_DST
2150 * Allows modification of IPv6 source (RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC)
2151 * and destination address (RTE_FLOW_ACTION_TYPE_SET_IPV6_DST) in the
2152 * specified outermost IPv6 header.
2154 struct rte_flow_action_set_ipv6 {
2155 uint8_t ipv6_addr[16];
2160 * @b EXPERIMENTAL: this structure may change without prior notice
2162 * RTE_FLOW_ACTION_TYPE_SET_TP_SRC
2163 * RTE_FLOW_ACTION_TYPE_SET_TP_DST
2165 * Allows modification of source (RTE_FLOW_ACTION_TYPE_SET_TP_SRC)
2166 * and destination (RTE_FLOW_ACTION_TYPE_SET_TP_DST) port numbers
2167 * in the specified outermost TCP/UDP header.
2169 struct rte_flow_action_set_tp {
2174 * RTE_FLOW_ACTION_TYPE_SET_TTL
2176 * Set the TTL value directly for IPv4 or IPv6
2178 struct rte_flow_action_set_ttl {
2183 * RTE_FLOW_ACTION_TYPE_SET_MAC
2185 * Set MAC address from the matched flow
2187 struct rte_flow_action_set_mac {
2188 uint8_t mac_addr[RTE_ETHER_ADDR_LEN];
2192 * Definition of a single action.
2194 * A list of actions is terminated by a END action.
2196 * For simple actions without a configuration object, conf remains NULL.
2198 struct rte_flow_action {
2199 enum rte_flow_action_type type; /**< Action type. */
2200 const void *conf; /**< Pointer to action configuration object. */
2204 * Opaque type returned after successfully creating a flow.
2206 * This handle can be used to manage and query the related flow (e.g. to
2207 * destroy it or retrieve counters).
2212 * Verbose error types.
2214 * Most of them provide the type of the object referenced by struct
2215 * rte_flow_error.cause.
2217 enum rte_flow_error_type {
2218 RTE_FLOW_ERROR_TYPE_NONE, /**< No error. */
2219 RTE_FLOW_ERROR_TYPE_UNSPECIFIED, /**< Cause unspecified. */
2220 RTE_FLOW_ERROR_TYPE_HANDLE, /**< Flow rule (handle). */
2221 RTE_FLOW_ERROR_TYPE_ATTR_GROUP, /**< Group field. */
2222 RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY, /**< Priority field. */
2223 RTE_FLOW_ERROR_TYPE_ATTR_INGRESS, /**< Ingress field. */
2224 RTE_FLOW_ERROR_TYPE_ATTR_EGRESS, /**< Egress field. */
2225 RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, /**< Transfer field. */
2226 RTE_FLOW_ERROR_TYPE_ATTR, /**< Attributes structure. */
2227 RTE_FLOW_ERROR_TYPE_ITEM_NUM, /**< Pattern length. */
2228 RTE_FLOW_ERROR_TYPE_ITEM_SPEC, /**< Item specification. */
2229 RTE_FLOW_ERROR_TYPE_ITEM_LAST, /**< Item specification range. */
2230 RTE_FLOW_ERROR_TYPE_ITEM_MASK, /**< Item specification mask. */
2231 RTE_FLOW_ERROR_TYPE_ITEM, /**< Specific pattern item. */
2232 RTE_FLOW_ERROR_TYPE_ACTION_NUM, /**< Number of actions. */
2233 RTE_FLOW_ERROR_TYPE_ACTION_CONF, /**< Action configuration. */
2234 RTE_FLOW_ERROR_TYPE_ACTION, /**< Specific action. */
2238 * Verbose error structure definition.
2240 * This object is normally allocated by applications and set by PMDs, the
2241 * message points to a constant string which does not need to be freed by
2242 * the application, however its pointer can be considered valid only as long
2243 * as its associated DPDK port remains configured. Closing the underlying
2244 * device or unloading the PMD invalidates it.
2246 * Both cause and message may be NULL regardless of the error type.
2248 struct rte_flow_error {
2249 enum rte_flow_error_type type; /**< Cause field and error types. */
2250 const void *cause; /**< Object responsible for the error. */
2251 const char *message; /**< Human-readable error message. */
2255 * Complete flow rule description.
2257 * This object type is used when converting a flow rule description.
2259 * @see RTE_FLOW_CONV_OP_RULE
2260 * @see rte_flow_conv()
2263 struct rte_flow_conv_rule {
2265 const struct rte_flow_attr *attr_ro; /**< RO attributes. */
2266 struct rte_flow_attr *attr; /**< Attributes. */
2269 const struct rte_flow_item *pattern_ro; /**< RO pattern. */
2270 struct rte_flow_item *pattern; /**< Pattern items. */
2273 const struct rte_flow_action *actions_ro; /**< RO actions. */
2274 struct rte_flow_action *actions; /**< List of actions. */
2279 * Conversion operations for flow API objects.
2281 * @see rte_flow_conv()
2283 enum rte_flow_conv_op {
2285 * No operation to perform.
2287 * rte_flow_conv() simply returns 0.
2289 RTE_FLOW_CONV_OP_NONE,
2292 * Convert attributes structure.
2294 * This is a basic copy of an attributes structure.
2297 * @code const struct rte_flow_attr * @endcode
2299 * @code struct rte_flow_attr * @endcode
2301 RTE_FLOW_CONV_OP_ATTR,
2304 * Convert a single item.
2306 * Duplicates @p spec, @p last and @p mask but not outside objects.
2309 * @code const struct rte_flow_item * @endcode
2311 * @code struct rte_flow_item * @endcode
2313 RTE_FLOW_CONV_OP_ITEM,
2316 * Convert a single action.
2318 * Duplicates @p conf but not outside objects.
2321 * @code const struct rte_flow_action * @endcode
2323 * @code struct rte_flow_action * @endcode
2325 RTE_FLOW_CONV_OP_ACTION,
2328 * Convert an entire pattern.
2330 * Duplicates all pattern items at once with the same constraints as
2331 * RTE_FLOW_CONV_OP_ITEM.
2334 * @code const struct rte_flow_item * @endcode
2336 * @code struct rte_flow_item * @endcode
2338 RTE_FLOW_CONV_OP_PATTERN,
2341 * Convert a list of actions.
2343 * Duplicates the entire list of actions at once with the same
2344 * constraints as RTE_FLOW_CONV_OP_ACTION.
2347 * @code const struct rte_flow_action * @endcode
2349 * @code struct rte_flow_action * @endcode
2351 RTE_FLOW_CONV_OP_ACTIONS,
2354 * Convert a complete flow rule description.
2356 * Comprises attributes, pattern and actions together at once with
2357 * the usual constraints.
2360 * @code const struct rte_flow_conv_rule * @endcode
2362 * @code struct rte_flow_conv_rule * @endcode
2364 RTE_FLOW_CONV_OP_RULE,
2367 * Convert item type to its name string.
2369 * Writes a NUL-terminated string to @p dst. Like snprintf(), the
2370 * returned value excludes the terminator which is always written
2374 * @code (const void *)enum rte_flow_item_type @endcode
2376 * @code char * @endcode
2378 RTE_FLOW_CONV_OP_ITEM_NAME,
2381 * Convert action type to its name string.
2383 * Writes a NUL-terminated string to @p dst. Like snprintf(), the
2384 * returned value excludes the terminator which is always written
2388 * @code (const void *)enum rte_flow_action_type @endcode
2390 * @code char * @endcode
2392 RTE_FLOW_CONV_OP_ACTION_NAME,
2395 * Convert item type to pointer to item name.
2397 * Retrieves item name pointer from its type. The string itself is
2398 * not copied; instead, a unique pointer to an internal static
2399 * constant storage is written to @p dst.
2402 * @code (const void *)enum rte_flow_item_type @endcode
2404 * @code const char ** @endcode
2406 RTE_FLOW_CONV_OP_ITEM_NAME_PTR,
2409 * Convert action type to pointer to action name.
2411 * Retrieves action name pointer from its type. The string itself is
2412 * not copied; instead, a unique pointer to an internal static
2413 * constant storage is written to @p dst.
2416 * @code (const void *)enum rte_flow_action_type @endcode
2418 * @code const char ** @endcode
2420 RTE_FLOW_CONV_OP_ACTION_NAME_PTR,
2424 * Check whether a flow rule can be created on a given port.
2426 * The flow rule is validated for correctness and whether it could be accepted
2427 * by the device given sufficient resources. The rule is checked against the
2428 * current device mode and queue configuration. The flow rule may also
2429 * optionally be validated against existing flow rules and device resources.
2430 * This function has no effect on the target device.
2432 * The returned value is guaranteed to remain valid only as long as no
2433 * successful calls to rte_flow_create() or rte_flow_destroy() are made in
2434 * the meantime and no device parameter affecting flow rules in any way are
2435 * modified, due to possible collisions or resource limitations (although in
2436 * such cases EINVAL should not be returned).
2439 * Port identifier of Ethernet device.
2441 * Flow rule attributes.
2442 * @param[in] pattern
2443 * Pattern specification (list terminated by the END pattern item).
2444 * @param[in] actions
2445 * Associated actions (list terminated by the END action).
2447 * Perform verbose error reporting if not NULL. PMDs initialize this
2448 * structure in case of error only.
2451 * 0 if flow rule is valid and can be created. A negative errno value
2452 * otherwise (rte_errno is also set), the following errors are defined:
2454 * -ENOSYS: underlying device does not support this functionality.
2456 * -EIO: underlying device is removed.
2458 * -EINVAL: unknown or invalid rule specification.
2460 * -ENOTSUP: valid but unsupported rule specification (e.g. partial
2461 * bit-masks are unsupported).
2463 * -EEXIST: collision with an existing rule. Only returned if device
2464 * supports flow rule collision checking and there was a flow rule
2465 * collision. Not receiving this return code is no guarantee that creating
2466 * the rule will not fail due to a collision.
2468 * -ENOMEM: not enough memory to execute the function, or if the device
2469 * supports resource validation, resource limitation on the device.
2471 * -EBUSY: action cannot be performed due to busy device resources, may
2472 * succeed if the affected queues or even the entire port are in a stopped
2473 * state (see rte_eth_dev_rx_queue_stop() and rte_eth_dev_stop()).
2476 rte_flow_validate(uint16_t port_id,
2477 const struct rte_flow_attr *attr,
2478 const struct rte_flow_item pattern[],
2479 const struct rte_flow_action actions[],
2480 struct rte_flow_error *error);
2483 * Create a flow rule on a given port.
2486 * Port identifier of Ethernet device.
2488 * Flow rule attributes.
2489 * @param[in] pattern
2490 * Pattern specification (list terminated by the END pattern item).
2491 * @param[in] actions
2492 * Associated actions (list terminated by the END action).
2494 * Perform verbose error reporting if not NULL. PMDs initialize this
2495 * structure in case of error only.
2498 * A valid handle in case of success, NULL otherwise and rte_errno is set
2499 * to the positive version of one of the error codes defined for
2500 * rte_flow_validate().
2503 rte_flow_create(uint16_t port_id,
2504 const struct rte_flow_attr *attr,
2505 const struct rte_flow_item pattern[],
2506 const struct rte_flow_action actions[],
2507 struct rte_flow_error *error);
2510 * Destroy a flow rule on a given port.
2512 * Failure to destroy a flow rule handle may occur when other flow rules
2513 * depend on it, and destroying it would result in an inconsistent state.
2515 * This function is only guaranteed to succeed if handles are destroyed in
2516 * reverse order of their creation.
2519 * Port identifier of Ethernet device.
2521 * Flow rule handle to destroy.
2523 * Perform verbose error reporting if not NULL. PMDs initialize this
2524 * structure in case of error only.
2527 * 0 on success, a negative errno value otherwise and rte_errno is set.
2530 rte_flow_destroy(uint16_t port_id,
2531 struct rte_flow *flow,
2532 struct rte_flow_error *error);
2535 * Destroy all flow rules associated with a port.
2537 * In the unlikely event of failure, handles are still considered destroyed
2538 * and no longer valid but the port must be assumed to be in an inconsistent
2542 * Port identifier of Ethernet device.
2544 * Perform verbose error reporting if not NULL. PMDs initialize this
2545 * structure in case of error only.
2548 * 0 on success, a negative errno value otherwise and rte_errno is set.
2551 rte_flow_flush(uint16_t port_id,
2552 struct rte_flow_error *error);
2555 * Query an existing flow rule.
2557 * This function allows retrieving flow-specific data such as counters.
2558 * Data is gathered by special actions which must be present in the flow
2561 * \see RTE_FLOW_ACTION_TYPE_COUNT
2564 * Port identifier of Ethernet device.
2566 * Flow rule handle to query.
2568 * Action definition as defined in original flow rule.
2569 * @param[in, out] data
2570 * Pointer to storage for the associated query data type.
2572 * Perform verbose error reporting if not NULL. PMDs initialize this
2573 * structure in case of error only.
2576 * 0 on success, a negative errno value otherwise and rte_errno is set.
2579 rte_flow_query(uint16_t port_id,
2580 struct rte_flow *flow,
2581 const struct rte_flow_action *action,
2583 struct rte_flow_error *error);
2586 * Restrict ingress traffic to the defined flow rules.
2588 * Isolated mode guarantees that all ingress traffic comes from defined flow
2589 * rules only (current and future).
2591 * Besides making ingress more deterministic, it allows PMDs to safely reuse
2592 * resources otherwise assigned to handle the remaining traffic, such as
2593 * global RSS configuration settings, VLAN filters, MAC address entries,
2594 * legacy filter API rules and so on in order to expand the set of possible
2597 * Calling this function as soon as possible after device initialization,
2598 * ideally before the first call to rte_eth_dev_configure(), is recommended
2599 * to avoid possible failures due to conflicting settings.
2601 * Once effective, leaving isolated mode may not be possible depending on
2602 * PMD implementation.
2604 * Additionally, the following functionality has no effect on the underlying
2605 * port and may return errors such as ENOTSUP ("not supported"):
2607 * - Toggling promiscuous mode.
2608 * - Toggling allmulticast mode.
2609 * - Configuring MAC addresses.
2610 * - Configuring multicast addresses.
2611 * - Configuring VLAN filters.
2612 * - Configuring Rx filters through the legacy API (e.g. FDIR).
2613 * - Configuring global RSS settings.
2616 * Port identifier of Ethernet device.
2618 * Nonzero to enter isolated mode, attempt to leave it otherwise.
2620 * Perform verbose error reporting if not NULL. PMDs initialize this
2621 * structure in case of error only.
2624 * 0 on success, a negative errno value otherwise and rte_errno is set.
2627 rte_flow_isolate(uint16_t port_id, int set, struct rte_flow_error *error);
2630 * Initialize flow error structure.
2633 * Pointer to flow error structure (may be NULL).
2635 * Related error code (rte_errno).
2637 * Cause field and error types.
2639 * Object responsible for the error.
2641 * Human-readable error message.
2644 * Negative error code (errno value) and rte_errno is set.
2647 rte_flow_error_set(struct rte_flow_error *error,
2649 enum rte_flow_error_type type,
2651 const char *message);
2655 * @see rte_flow_copy()
2657 struct rte_flow_desc {
2658 size_t size; /**< Allocated space including data[]. */
2659 struct rte_flow_attr attr; /**< Attributes. */
2660 struct rte_flow_item *items; /**< Items. */
2661 struct rte_flow_action *actions; /**< Actions. */
2662 uint8_t data[]; /**< Storage for items/actions. */
2667 * Copy an rte_flow rule description.
2669 * This interface is kept for compatibility with older applications but is
2670 * implemented as a wrapper to rte_flow_conv(). It is deprecated due to its
2671 * lack of flexibility and reliance on a type unusable with C++ programs
2672 * (struct rte_flow_desc).
2675 * Flow rule description.
2677 * Total size of allocated data for the flow description.
2679 * Flow rule attributes.
2681 * Pattern specification (list terminated by the END pattern item).
2682 * @param[in] actions
2683 * Associated actions (list terminated by the END action).
2686 * If len is greater or equal to the size of the flow, the total size of the
2687 * flow description and its data.
2688 * If len is lower than the size of the flow, the number of bytes that would
2689 * have been written to desc had it been sufficient. Nothing is written.
2693 rte_flow_copy(struct rte_flow_desc *fd, size_t len,
2694 const struct rte_flow_attr *attr,
2695 const struct rte_flow_item *items,
2696 const struct rte_flow_action *actions);
2699 * Flow object conversion helper.
2701 * This function performs conversion of various flow API objects to a
2702 * pre-allocated destination buffer. See enum rte_flow_conv_op for possible
2703 * operations and details about each of them.
2705 * Since destination buffer must be large enough, it works in a manner
2706 * reminiscent of snprintf():
2708 * - If @p size is 0, @p dst may be a NULL pointer, otherwise @p dst must be
2710 * - If positive, the returned value represents the number of bytes needed
2711 * to store the conversion of @p src to @p dst according to @p op
2712 * regardless of the @p size parameter.
2713 * - Since no more than @p size bytes can be written to @p dst, output is
2714 * truncated and may be inconsistent when the returned value is larger
2716 * - In case of conversion error, a negative error code is returned and
2717 * @p dst contents are unspecified.
2720 * Operation to perform, related to the object type of @p dst.
2722 * Destination buffer address. Must be suitably aligned by the caller.
2724 * Destination buffer size in bytes.
2726 * Source object to copy. Depending on @p op, its type may differ from
2729 * Perform verbose error reporting if not NULL. Initialized in case of
2733 * The number of bytes required to convert @p src to @p dst on success, a
2734 * negative errno value otherwise and rte_errno is set.
2736 * @see rte_flow_conv_op
2740 rte_flow_conv(enum rte_flow_conv_op op,
2744 struct rte_flow_error *error);
2750 #endif /* RTE_FLOW_H_ */