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,
449 * RTE_FLOW_ITEM_TYPE_ANY
451 * Matches any protocol in place of the current layer, a single ANY may also
452 * stand for several protocol layers.
454 * This is usually specified as the first pattern item when looking for a
455 * protocol anywhere in a packet.
457 * A zeroed mask stands for any number of layers.
459 struct rte_flow_item_any {
460 uint32_t num; /**< Number of layers covered. */
463 /** Default mask for RTE_FLOW_ITEM_TYPE_ANY. */
465 static const struct rte_flow_item_any rte_flow_item_any_mask = {
471 * RTE_FLOW_ITEM_TYPE_VF
473 * Matches traffic originating from (ingress) or going to (egress) a given
474 * virtual function of the current device.
476 * If supported, should work even if the virtual function is not managed by
477 * the application and thus not associated with a DPDK port ID.
479 * Note this pattern item does not match VF representors traffic which, as
480 * separate entities, should be addressed through their own DPDK port IDs.
482 * - Can be specified multiple times to match traffic addressed to several
484 * - Can be combined with a PF item to match both PF and VF traffic.
486 * A zeroed mask can be used to match any VF ID.
488 struct rte_flow_item_vf {
489 uint32_t id; /**< VF ID. */
492 /** Default mask for RTE_FLOW_ITEM_TYPE_VF. */
494 static const struct rte_flow_item_vf rte_flow_item_vf_mask = {
500 * RTE_FLOW_ITEM_TYPE_PHY_PORT
502 * Matches traffic originating from (ingress) or going to (egress) a
503 * physical port of the underlying device.
505 * The first PHY_PORT item overrides the physical port normally associated
506 * with the specified DPDK input port (port_id). This item can be provided
507 * several times to match additional physical ports.
509 * Note that physical ports are not necessarily tied to DPDK input ports
510 * (port_id) when those are not under DPDK control. Possible values are
511 * specific to each device, they are not necessarily indexed from zero and
512 * may not be contiguous.
514 * As a device property, the list of allowed values as well as the value
515 * associated with a port_id should be retrieved by other means.
517 * A zeroed mask can be used to match any port index.
519 struct rte_flow_item_phy_port {
520 uint32_t index; /**< Physical port index. */
523 /** Default mask for RTE_FLOW_ITEM_TYPE_PHY_PORT. */
525 static const struct rte_flow_item_phy_port rte_flow_item_phy_port_mask = {
531 * RTE_FLOW_ITEM_TYPE_PORT_ID
533 * Matches traffic originating from (ingress) or going to (egress) a given
536 * Normally only supported if the port ID in question is known by the
537 * underlying PMD and related to the device the flow rule is created
540 * This must not be confused with @p PHY_PORT which refers to the physical
541 * port of a device, whereas @p PORT_ID refers to a struct rte_eth_dev
542 * object on the application side (also known as "port representor"
543 * depending on the kind of underlying device).
545 struct rte_flow_item_port_id {
546 uint32_t id; /**< DPDK port ID. */
549 /** Default mask for RTE_FLOW_ITEM_TYPE_PORT_ID. */
551 static const struct rte_flow_item_port_id rte_flow_item_port_id_mask = {
557 * RTE_FLOW_ITEM_TYPE_RAW
559 * Matches a byte string of a given length at a given offset.
561 * Offset is either absolute (using the start of the packet) or relative to
562 * the end of the previous matched item in the stack, in which case negative
563 * values are allowed.
565 * If search is enabled, offset is used as the starting point. The search
566 * area can be delimited by setting limit to a nonzero value, which is the
567 * maximum number of bytes after offset where the pattern may start.
569 * Matching a zero-length pattern is allowed, doing so resets the relative
570 * offset for subsequent items.
572 * This type does not support ranges (struct rte_flow_item.last).
574 struct rte_flow_item_raw {
575 uint32_t relative:1; /**< Look for pattern after the previous item. */
576 uint32_t search:1; /**< Search pattern from offset (see also limit). */
577 uint32_t reserved:30; /**< Reserved, must be set to zero. */
578 int32_t offset; /**< Absolute or relative offset for pattern. */
579 uint16_t limit; /**< Search area limit for start of pattern. */
580 uint16_t length; /**< Pattern length. */
581 const uint8_t *pattern; /**< Byte string to look for. */
584 /** Default mask for RTE_FLOW_ITEM_TYPE_RAW. */
586 static const struct rte_flow_item_raw rte_flow_item_raw_mask = {
589 .reserved = 0x3fffffff,
590 .offset = 0xffffffff,
598 * RTE_FLOW_ITEM_TYPE_ETH
600 * Matches an Ethernet header.
602 * The @p type field either stands for "EtherType" or "TPID" when followed
603 * by so-called layer 2.5 pattern items such as RTE_FLOW_ITEM_TYPE_VLAN. In
604 * the latter case, @p type refers to that of the outer header, with the
605 * inner EtherType/TPID provided by the subsequent pattern item. This is the
606 * same order as on the wire.
608 struct rte_flow_item_eth {
609 struct rte_ether_addr dst; /**< Destination MAC. */
610 struct rte_ether_addr src; /**< Source MAC. */
611 rte_be16_t type; /**< EtherType or TPID. */
614 /** Default mask for RTE_FLOW_ITEM_TYPE_ETH. */
616 static const struct rte_flow_item_eth rte_flow_item_eth_mask = {
617 .dst.addr_bytes = "\xff\xff\xff\xff\xff\xff",
618 .src.addr_bytes = "\xff\xff\xff\xff\xff\xff",
619 .type = RTE_BE16(0x0000),
624 * RTE_FLOW_ITEM_TYPE_VLAN
626 * Matches an 802.1Q/ad VLAN tag.
628 * The corresponding standard outer EtherType (TPID) values are
629 * RTE_ETHER_TYPE_VLAN or RTE_ETHER_TYPE_QINQ. It can be overridden by
630 * the preceding pattern item.
632 struct rte_flow_item_vlan {
633 rte_be16_t tci; /**< Tag control information. */
634 rte_be16_t inner_type; /**< Inner EtherType or TPID. */
637 /** Default mask for RTE_FLOW_ITEM_TYPE_VLAN. */
639 static const struct rte_flow_item_vlan rte_flow_item_vlan_mask = {
640 .tci = RTE_BE16(0x0fff),
641 .inner_type = RTE_BE16(0x0000),
646 * RTE_FLOW_ITEM_TYPE_IPV4
648 * Matches an IPv4 header.
650 * Note: IPv4 options are handled by dedicated pattern items.
652 struct rte_flow_item_ipv4 {
653 struct rte_ipv4_hdr hdr; /**< IPv4 header definition. */
656 /** Default mask for RTE_FLOW_ITEM_TYPE_IPV4. */
658 static const struct rte_flow_item_ipv4 rte_flow_item_ipv4_mask = {
660 .src_addr = RTE_BE32(0xffffffff),
661 .dst_addr = RTE_BE32(0xffffffff),
667 * RTE_FLOW_ITEM_TYPE_IPV6.
669 * Matches an IPv6 header.
671 * Note: IPv6 options are handled by dedicated pattern items, see
672 * RTE_FLOW_ITEM_TYPE_IPV6_EXT.
674 struct rte_flow_item_ipv6 {
675 struct rte_ipv6_hdr hdr; /**< IPv6 header definition. */
678 /** Default mask for RTE_FLOW_ITEM_TYPE_IPV6. */
680 static const struct rte_flow_item_ipv6 rte_flow_item_ipv6_mask = {
683 "\xff\xff\xff\xff\xff\xff\xff\xff"
684 "\xff\xff\xff\xff\xff\xff\xff\xff",
686 "\xff\xff\xff\xff\xff\xff\xff\xff"
687 "\xff\xff\xff\xff\xff\xff\xff\xff",
693 * RTE_FLOW_ITEM_TYPE_ICMP.
695 * Matches an ICMP header.
697 struct rte_flow_item_icmp {
698 struct rte_icmp_hdr hdr; /**< ICMP header definition. */
701 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP. */
703 static const struct rte_flow_item_icmp rte_flow_item_icmp_mask = {
712 * RTE_FLOW_ITEM_TYPE_UDP.
714 * Matches a UDP header.
716 struct rte_flow_item_udp {
717 struct rte_udp_hdr hdr; /**< UDP header definition. */
720 /** Default mask for RTE_FLOW_ITEM_TYPE_UDP. */
722 static const struct rte_flow_item_udp rte_flow_item_udp_mask = {
724 .src_port = RTE_BE16(0xffff),
725 .dst_port = RTE_BE16(0xffff),
731 * RTE_FLOW_ITEM_TYPE_TCP.
733 * Matches a TCP header.
735 struct rte_flow_item_tcp {
736 struct rte_tcp_hdr hdr; /**< TCP header definition. */
739 /** Default mask for RTE_FLOW_ITEM_TYPE_TCP. */
741 static const struct rte_flow_item_tcp rte_flow_item_tcp_mask = {
743 .src_port = RTE_BE16(0xffff),
744 .dst_port = RTE_BE16(0xffff),
750 * RTE_FLOW_ITEM_TYPE_SCTP.
752 * Matches a SCTP header.
754 struct rte_flow_item_sctp {
755 struct rte_sctp_hdr hdr; /**< SCTP header definition. */
758 /** Default mask for RTE_FLOW_ITEM_TYPE_SCTP. */
760 static const struct rte_flow_item_sctp rte_flow_item_sctp_mask = {
762 .src_port = RTE_BE16(0xffff),
763 .dst_port = RTE_BE16(0xffff),
769 * RTE_FLOW_ITEM_TYPE_VXLAN.
771 * Matches a VXLAN header (RFC 7348).
773 struct rte_flow_item_vxlan {
774 uint8_t flags; /**< Normally 0x08 (I flag). */
775 uint8_t rsvd0[3]; /**< Reserved, normally 0x000000. */
776 uint8_t vni[3]; /**< VXLAN identifier. */
777 uint8_t rsvd1; /**< Reserved, normally 0x00. */
780 /** Default mask for RTE_FLOW_ITEM_TYPE_VXLAN. */
782 static const struct rte_flow_item_vxlan rte_flow_item_vxlan_mask = {
783 .vni = "\xff\xff\xff",
788 * RTE_FLOW_ITEM_TYPE_E_TAG.
790 * Matches a E-tag header.
792 * The corresponding standard outer EtherType (TPID) value is
793 * RTE_ETHER_TYPE_ETAG. It can be overridden by the preceding pattern item.
795 struct rte_flow_item_e_tag {
797 * E-Tag control information (E-TCI).
798 * E-PCP (3b), E-DEI (1b), ingress E-CID base (12b).
800 rte_be16_t epcp_edei_in_ecid_b;
801 /** Reserved (2b), GRP (2b), E-CID base (12b). */
802 rte_be16_t rsvd_grp_ecid_b;
803 uint8_t in_ecid_e; /**< Ingress E-CID ext. */
804 uint8_t ecid_e; /**< E-CID ext. */
805 rte_be16_t inner_type; /**< Inner EtherType or TPID. */
808 /** Default mask for RTE_FLOW_ITEM_TYPE_E_TAG. */
810 static const struct rte_flow_item_e_tag rte_flow_item_e_tag_mask = {
811 .rsvd_grp_ecid_b = RTE_BE16(0x3fff),
816 * RTE_FLOW_ITEM_TYPE_NVGRE.
818 * Matches a NVGRE header.
820 struct rte_flow_item_nvgre {
822 * Checksum (1b), undefined (1b), key bit (1b), sequence number (1b),
823 * reserved 0 (9b), version (3b).
825 * c_k_s_rsvd0_ver must have value 0x2000 according to RFC 7637.
827 rte_be16_t c_k_s_rsvd0_ver;
828 rte_be16_t protocol; /**< Protocol type (0x6558). */
829 uint8_t tni[3]; /**< Virtual subnet ID. */
830 uint8_t flow_id; /**< Flow ID. */
833 /** Default mask for RTE_FLOW_ITEM_TYPE_NVGRE. */
835 static const struct rte_flow_item_nvgre rte_flow_item_nvgre_mask = {
836 .tni = "\xff\xff\xff",
841 * RTE_FLOW_ITEM_TYPE_MPLS.
843 * Matches a MPLS header.
845 struct rte_flow_item_mpls {
847 * Label (20b), TC (3b), Bottom of Stack (1b).
849 uint8_t label_tc_s[3];
850 uint8_t ttl; /** Time-to-Live. */
853 /** Default mask for RTE_FLOW_ITEM_TYPE_MPLS. */
855 static const struct rte_flow_item_mpls rte_flow_item_mpls_mask = {
856 .label_tc_s = "\xff\xff\xf0",
861 * RTE_FLOW_ITEM_TYPE_GRE.
863 * Matches a GRE header.
865 struct rte_flow_item_gre {
867 * Checksum (1b), reserved 0 (12b), version (3b).
870 rte_be16_t c_rsvd0_ver;
871 rte_be16_t protocol; /**< Protocol type. */
874 /** Default mask for RTE_FLOW_ITEM_TYPE_GRE. */
876 static const struct rte_flow_item_gre rte_flow_item_gre_mask = {
877 .protocol = RTE_BE16(0xffff),
882 * RTE_FLOW_ITEM_TYPE_FUZZY
884 * Fuzzy pattern match, expect faster than default.
886 * This is for device that support fuzzy match option.
887 * Usually a fuzzy match is fast but the cost is accuracy.
888 * i.e. Signature Match only match pattern's hash value, but it is
889 * possible two different patterns have the same hash value.
891 * Matching accuracy level can be configure by threshold.
892 * Driver can divide the range of threshold and map to different
893 * accuracy levels that device support.
895 * Threshold 0 means perfect match (no fuzziness), while threshold
896 * 0xffffffff means fuzziest match.
898 struct rte_flow_item_fuzzy {
899 uint32_t thresh; /**< Accuracy threshold. */
902 /** Default mask for RTE_FLOW_ITEM_TYPE_FUZZY. */
904 static const struct rte_flow_item_fuzzy rte_flow_item_fuzzy_mask = {
905 .thresh = 0xffffffff,
910 * RTE_FLOW_ITEM_TYPE_GTP.
912 * Matches a GTPv1 header.
914 struct rte_flow_item_gtp {
916 * Version (3b), protocol type (1b), reserved (1b),
917 * Extension header flag (1b),
918 * Sequence number flag (1b),
919 * N-PDU number flag (1b).
921 uint8_t v_pt_rsv_flags;
922 uint8_t msg_type; /**< Message type. */
923 rte_be16_t msg_len; /**< Message length. */
924 rte_be32_t teid; /**< Tunnel endpoint identifier. */
927 /** Default mask for RTE_FLOW_ITEM_TYPE_GTP. */
929 static const struct rte_flow_item_gtp rte_flow_item_gtp_mask = {
930 .teid = RTE_BE32(0xffffffff),
935 * RTE_FLOW_ITEM_TYPE_ESP
937 * Matches an ESP header.
939 struct rte_flow_item_esp {
940 struct rte_esp_hdr hdr; /**< ESP header definition. */
943 /** Default mask for RTE_FLOW_ITEM_TYPE_ESP. */
945 static const struct rte_flow_item_esp rte_flow_item_esp_mask = {
947 .spi = RTE_BE32(0xffffffff),
953 * RTE_FLOW_ITEM_TYPE_GENEVE.
955 * Matches a GENEVE header.
957 struct rte_flow_item_geneve {
959 * Version (2b), length of the options fields (6b), OAM packet (1b),
960 * critical options present (1b), reserved 0 (6b).
962 rte_be16_t ver_opt_len_o_c_rsvd0;
963 rte_be16_t protocol; /**< Protocol type. */
964 uint8_t vni[3]; /**< Virtual Network Identifier. */
965 uint8_t rsvd1; /**< Reserved, normally 0x00. */
968 /** Default mask for RTE_FLOW_ITEM_TYPE_GENEVE. */
970 static const struct rte_flow_item_geneve rte_flow_item_geneve_mask = {
971 .vni = "\xff\xff\xff",
976 * RTE_FLOW_ITEM_TYPE_VXLAN_GPE (draft-ietf-nvo3-vxlan-gpe-05).
978 * Matches a VXLAN-GPE header.
980 struct rte_flow_item_vxlan_gpe {
981 uint8_t flags; /**< Normally 0x0c (I and P flags). */
982 uint8_t rsvd0[2]; /**< Reserved, normally 0x0000. */
983 uint8_t protocol; /**< Protocol type. */
984 uint8_t vni[3]; /**< VXLAN identifier. */
985 uint8_t rsvd1; /**< Reserved, normally 0x00. */
988 /** Default mask for RTE_FLOW_ITEM_TYPE_VXLAN_GPE. */
990 static const struct rte_flow_item_vxlan_gpe rte_flow_item_vxlan_gpe_mask = {
991 .vni = "\xff\xff\xff",
996 * RTE_FLOW_ITEM_TYPE_ARP_ETH_IPV4
998 * Matches an ARP header for Ethernet/IPv4.
1000 struct rte_flow_item_arp_eth_ipv4 {
1001 rte_be16_t hrd; /**< Hardware type, normally 1. */
1002 rte_be16_t pro; /**< Protocol type, normally 0x0800. */
1003 uint8_t hln; /**< Hardware address length, normally 6. */
1004 uint8_t pln; /**< Protocol address length, normally 4. */
1005 rte_be16_t op; /**< Opcode (1 for request, 2 for reply). */
1006 struct rte_ether_addr sha; /**< Sender hardware address. */
1007 rte_be32_t spa; /**< Sender IPv4 address. */
1008 struct rte_ether_addr tha; /**< Target hardware address. */
1009 rte_be32_t tpa; /**< Target IPv4 address. */
1012 /** Default mask for RTE_FLOW_ITEM_TYPE_ARP_ETH_IPV4. */
1014 static const struct rte_flow_item_arp_eth_ipv4
1015 rte_flow_item_arp_eth_ipv4_mask = {
1016 .sha.addr_bytes = "\xff\xff\xff\xff\xff\xff",
1017 .spa = RTE_BE32(0xffffffff),
1018 .tha.addr_bytes = "\xff\xff\xff\xff\xff\xff",
1019 .tpa = RTE_BE32(0xffffffff),
1024 * RTE_FLOW_ITEM_TYPE_IPV6_EXT
1026 * Matches the presence of any IPv6 extension header.
1028 * Normally preceded by any of:
1030 * - RTE_FLOW_ITEM_TYPE_IPV6
1031 * - RTE_FLOW_ITEM_TYPE_IPV6_EXT
1033 struct rte_flow_item_ipv6_ext {
1034 uint8_t next_hdr; /**< Next header. */
1037 /** Default mask for RTE_FLOW_ITEM_TYPE_IPV6_EXT. */
1040 struct rte_flow_item_ipv6_ext rte_flow_item_ipv6_ext_mask = {
1046 * RTE_FLOW_ITEM_TYPE_ICMP6
1048 * Matches any ICMPv6 header.
1050 struct rte_flow_item_icmp6 {
1051 uint8_t type; /**< ICMPv6 type. */
1052 uint8_t code; /**< ICMPv6 code. */
1053 uint16_t checksum; /**< ICMPv6 checksum. */
1056 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6. */
1058 static const struct rte_flow_item_icmp6 rte_flow_item_icmp6_mask = {
1065 * RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS
1067 * Matches an ICMPv6 neighbor discovery solicitation.
1069 struct rte_flow_item_icmp6_nd_ns {
1070 uint8_t type; /**< ICMPv6 type, normally 135. */
1071 uint8_t code; /**< ICMPv6 code, normally 0. */
1072 rte_be16_t checksum; /**< ICMPv6 checksum. */
1073 rte_be32_t reserved; /**< Reserved, normally 0. */
1074 uint8_t target_addr[16]; /**< Target address. */
1077 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS. */
1080 struct rte_flow_item_icmp6_nd_ns rte_flow_item_icmp6_nd_ns_mask = {
1082 "\xff\xff\xff\xff\xff\xff\xff\xff"
1083 "\xff\xff\xff\xff\xff\xff\xff\xff",
1088 * RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA
1090 * Matches an ICMPv6 neighbor discovery advertisement.
1092 struct rte_flow_item_icmp6_nd_na {
1093 uint8_t type; /**< ICMPv6 type, normally 136. */
1094 uint8_t code; /**< ICMPv6 code, normally 0. */
1095 rte_be16_t checksum; /**< ICMPv6 checksum. */
1097 * Route flag (1b), solicited flag (1b), override flag (1b),
1100 rte_be32_t rso_reserved;
1101 uint8_t target_addr[16]; /**< Target address. */
1104 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA. */
1107 struct rte_flow_item_icmp6_nd_na rte_flow_item_icmp6_nd_na_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_OPT
1117 * Matches the presence of any ICMPv6 neighbor discovery option.
1119 * Normally preceded by any of:
1121 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA
1122 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS
1123 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT
1125 struct rte_flow_item_icmp6_nd_opt {
1126 uint8_t type; /**< ND option type. */
1127 uint8_t length; /**< ND option length. */
1130 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT. */
1132 static const struct rte_flow_item_icmp6_nd_opt
1133 rte_flow_item_icmp6_nd_opt_mask = {
1139 * RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_SLA_ETH
1141 * Matches an ICMPv6 neighbor discovery source Ethernet link-layer address
1144 * Normally preceded by any of:
1146 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA
1147 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT
1149 struct rte_flow_item_icmp6_nd_opt_sla_eth {
1150 uint8_t type; /**< ND option type, normally 1. */
1151 uint8_t length; /**< ND option length, normally 1. */
1152 struct rte_ether_addr sla; /**< Source Ethernet LLA. */
1155 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_SLA_ETH. */
1157 static const struct rte_flow_item_icmp6_nd_opt_sla_eth
1158 rte_flow_item_icmp6_nd_opt_sla_eth_mask = {
1159 .sla.addr_bytes = "\xff\xff\xff\xff\xff\xff",
1164 * RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_TLA_ETH
1166 * Matches an ICMPv6 neighbor discovery target Ethernet link-layer address
1169 * Normally preceded by any of:
1171 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS
1172 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT
1174 struct rte_flow_item_icmp6_nd_opt_tla_eth {
1175 uint8_t type; /**< ND option type, normally 2. */
1176 uint8_t length; /**< ND option length, normally 1. */
1177 struct rte_ether_addr tla; /**< Target Ethernet LLA. */
1180 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_TLA_ETH. */
1182 static const struct rte_flow_item_icmp6_nd_opt_tla_eth
1183 rte_flow_item_icmp6_nd_opt_tla_eth_mask = {
1184 .tla.addr_bytes = "\xff\xff\xff\xff\xff\xff",
1189 * RTE_FLOW_ITEM_TYPE_META.
1191 * Matches a specified metadata value.
1193 struct rte_flow_item_meta {
1197 /** Default mask for RTE_FLOW_ITEM_TYPE_META. */
1199 static const struct rte_flow_item_meta rte_flow_item_meta_mask = {
1200 .data = RTE_BE32(UINT32_MAX),
1205 * RTE_FLOW_ITEM_TYPE_GTP_PSC.
1207 * Matches a GTP PDU extension header with type 0x85.
1209 struct rte_flow_item_gtp_psc {
1210 uint8_t pdu_type; /**< PDU type. */
1211 uint8_t qfi; /**< QoS flow identifier. */
1214 /** Default mask for RTE_FLOW_ITEM_TYPE_GTP_PSC. */
1216 static const struct rte_flow_item_gtp_psc
1217 rte_flow_item_gtp_psc_mask = {
1224 * @b EXPERIMENTAL: this structure may change without prior notice
1226 * RTE_FLOW_ITEM_TYPE_MARK
1228 * Matches an arbitrary integer value which was set using the ``MARK`` action
1229 * in a previously matched rule.
1231 * This item can only be specified once as a match criteria as the ``MARK``
1232 * action can only be specified once in a flow action.
1234 * This value is arbitrary and application-defined. Maximum allowed value
1235 * depends on the underlying implementation.
1237 * Depending on the underlying implementation the MARK item may be supported on
1238 * the physical device, with virtual groups in the PMD or not at all.
1240 struct rte_flow_item_mark {
1241 uint32_t id; /**< Integer value to match against. */
1245 * Matching pattern item definition.
1247 * A pattern is formed by stacking items starting from the lowest protocol
1248 * layer to match. This stacking restriction does not apply to meta items
1249 * which can be placed anywhere in the stack without affecting the meaning
1250 * of the resulting pattern.
1252 * Patterns are terminated by END items.
1254 * The spec field should be a valid pointer to a structure of the related
1255 * item type. It may remain unspecified (NULL) in many cases to request
1256 * broad (nonspecific) matching. In such cases, last and mask must also be
1259 * Optionally, last can point to a structure of the same type to define an
1260 * inclusive range. This is mostly supported by integer and address fields,
1261 * may cause errors otherwise. Fields that do not support ranges must be set
1262 * to 0 or to the same value as the corresponding fields in spec.
1264 * Only the fields defined to nonzero values in the default masks (see
1265 * rte_flow_item_{name}_mask constants) are considered relevant by
1266 * default. This can be overridden by providing a mask structure of the
1267 * same type with applicable bits set to one. It can also be used to
1268 * partially filter out specific fields (e.g. as an alternate mean to match
1269 * ranges of IP addresses).
1271 * Mask is a simple bit-mask applied before interpreting the contents of
1272 * spec and last, which may yield unexpected results if not used
1273 * carefully. For example, if for an IPv4 address field, spec provides
1274 * 10.1.2.3, last provides 10.3.4.5 and mask provides 255.255.0.0, the
1275 * effective range becomes 10.1.0.0 to 10.3.255.255.
1277 struct rte_flow_item {
1278 enum rte_flow_item_type type; /**< Item type. */
1279 const void *spec; /**< Pointer to item specification structure. */
1280 const void *last; /**< Defines an inclusive range (spec to last). */
1281 const void *mask; /**< Bit-mask applied to spec and last. */
1287 * Each possible action is represented by a type.
1288 * An action can have an associated configuration object.
1289 * Several actions combined in a list can be assigned
1290 * to a flow rule and are performed in order.
1292 * They fall in three categories:
1294 * - Actions that modify the fate of matching traffic, for instance by
1295 * dropping or assigning it a specific destination.
1297 * - Actions that modify matching traffic contents or its properties. This
1298 * includes adding/removing encapsulation, encryption, compression and
1301 * - Actions related to the flow rule itself, such as updating counters or
1302 * making it non-terminating.
1304 * Flow rules being terminating by default, not specifying any action of the
1305 * fate kind results in undefined behavior. This applies to both ingress and
1308 * PASSTHRU, when supported, makes a flow rule non-terminating.
1310 enum rte_flow_action_type {
1312 * End marker for action lists. Prevents further processing of
1313 * actions, thereby ending the list.
1315 * No associated configuration structure.
1317 RTE_FLOW_ACTION_TYPE_END,
1320 * Used as a placeholder for convenience. It is ignored and simply
1321 * discarded by PMDs.
1323 * No associated configuration structure.
1325 RTE_FLOW_ACTION_TYPE_VOID,
1328 * Leaves traffic up for additional processing by subsequent flow
1329 * rules; makes a flow rule non-terminating.
1331 * No associated configuration structure.
1333 RTE_FLOW_ACTION_TYPE_PASSTHRU,
1336 * RTE_FLOW_ACTION_TYPE_JUMP
1338 * Redirects packets to a group on the current device.
1340 * See struct rte_flow_action_jump.
1342 RTE_FLOW_ACTION_TYPE_JUMP,
1345 * Attaches an integer value to packets and sets PKT_RX_FDIR and
1346 * PKT_RX_FDIR_ID mbuf flags.
1348 * See struct rte_flow_action_mark.
1350 RTE_FLOW_ACTION_TYPE_MARK,
1353 * Flags packets. Similar to MARK without a specific value; only
1354 * sets the PKT_RX_FDIR mbuf flag.
1356 * No associated configuration structure.
1358 RTE_FLOW_ACTION_TYPE_FLAG,
1361 * Assigns packets to a given queue index.
1363 * See struct rte_flow_action_queue.
1365 RTE_FLOW_ACTION_TYPE_QUEUE,
1370 * PASSTHRU overrides this action if both are specified.
1372 * No associated configuration structure.
1374 RTE_FLOW_ACTION_TYPE_DROP,
1377 * Enables counters for this flow rule.
1379 * These counters can be retrieved and reset through rte_flow_query(),
1380 * see struct rte_flow_query_count.
1382 * See struct rte_flow_action_count.
1384 RTE_FLOW_ACTION_TYPE_COUNT,
1387 * Similar to QUEUE, except RSS is additionally performed on packets
1388 * to spread them among several queues according to the provided
1391 * See struct rte_flow_action_rss.
1393 RTE_FLOW_ACTION_TYPE_RSS,
1396 * Directs matching traffic to the physical function (PF) of the
1399 * No associated configuration structure.
1401 RTE_FLOW_ACTION_TYPE_PF,
1404 * Directs matching traffic to a given virtual function of the
1407 * See struct rte_flow_action_vf.
1409 RTE_FLOW_ACTION_TYPE_VF,
1412 * Directs packets to a given physical port index of the underlying
1415 * See struct rte_flow_action_phy_port.
1417 RTE_FLOW_ACTION_TYPE_PHY_PORT,
1420 * Directs matching traffic to a given DPDK port ID.
1422 * See struct rte_flow_action_port_id.
1424 RTE_FLOW_ACTION_TYPE_PORT_ID,
1427 * Traffic metering and policing (MTR).
1429 * See struct rte_flow_action_meter.
1430 * See file rte_mtr.h for MTR object configuration.
1432 RTE_FLOW_ACTION_TYPE_METER,
1435 * Redirects packets to security engine of current device for security
1436 * processing as specified by security session.
1438 * See struct rte_flow_action_security.
1440 RTE_FLOW_ACTION_TYPE_SECURITY,
1443 * Implements OFPAT_SET_MPLS_TTL ("MPLS TTL") as defined by the
1444 * OpenFlow Switch Specification.
1446 * See struct rte_flow_action_of_set_mpls_ttl.
1448 RTE_FLOW_ACTION_TYPE_OF_SET_MPLS_TTL,
1451 * Implements OFPAT_DEC_MPLS_TTL ("decrement MPLS TTL") as defined
1452 * by the OpenFlow Switch Specification.
1454 * No associated configuration structure.
1456 RTE_FLOW_ACTION_TYPE_OF_DEC_MPLS_TTL,
1459 * Implements OFPAT_SET_NW_TTL ("IP TTL") as defined by the OpenFlow
1460 * Switch Specification.
1462 * See struct rte_flow_action_of_set_nw_ttl.
1464 RTE_FLOW_ACTION_TYPE_OF_SET_NW_TTL,
1467 * Implements OFPAT_DEC_NW_TTL ("decrement IP TTL") as defined by
1468 * the OpenFlow Switch Specification.
1470 * No associated configuration structure.
1472 RTE_FLOW_ACTION_TYPE_OF_DEC_NW_TTL,
1475 * Implements OFPAT_COPY_TTL_OUT ("copy TTL "outwards" -- from
1476 * next-to-outermost to outermost") as defined by the OpenFlow
1477 * Switch Specification.
1479 * No associated configuration structure.
1481 RTE_FLOW_ACTION_TYPE_OF_COPY_TTL_OUT,
1484 * Implements OFPAT_COPY_TTL_IN ("copy TTL "inwards" -- from
1485 * outermost to next-to-outermost") as defined by the OpenFlow
1486 * Switch Specification.
1488 * No associated configuration structure.
1490 RTE_FLOW_ACTION_TYPE_OF_COPY_TTL_IN,
1493 * Implements OFPAT_POP_VLAN ("pop the outer VLAN tag") as defined
1494 * by the OpenFlow Switch Specification.
1496 * No associated configuration structure.
1498 RTE_FLOW_ACTION_TYPE_OF_POP_VLAN,
1501 * Implements OFPAT_PUSH_VLAN ("push a new VLAN tag") as defined by
1502 * the OpenFlow Switch Specification.
1504 * See struct rte_flow_action_of_push_vlan.
1506 RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN,
1509 * Implements OFPAT_SET_VLAN_VID ("set the 802.1q VLAN id") as
1510 * defined by the OpenFlow Switch Specification.
1512 * See struct rte_flow_action_of_set_vlan_vid.
1514 RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID,
1517 * Implements OFPAT_SET_LAN_PCP ("set the 802.1q priority") as
1518 * defined by the OpenFlow Switch Specification.
1520 * See struct rte_flow_action_of_set_vlan_pcp.
1522 RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP,
1525 * Implements OFPAT_POP_MPLS ("pop the outer MPLS tag") as defined
1526 * by the OpenFlow Switch Specification.
1528 * See struct rte_flow_action_of_pop_mpls.
1530 RTE_FLOW_ACTION_TYPE_OF_POP_MPLS,
1533 * Implements OFPAT_PUSH_MPLS ("push a new MPLS tag") as defined by
1534 * the OpenFlow Switch Specification.
1536 * See struct rte_flow_action_of_push_mpls.
1538 RTE_FLOW_ACTION_TYPE_OF_PUSH_MPLS,
1541 * Encapsulate flow in VXLAN tunnel as defined in
1542 * rte_flow_action_vxlan_encap action structure.
1544 * See struct rte_flow_action_vxlan_encap.
1546 RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP,
1549 * Decapsulate outer most VXLAN tunnel from matched flow.
1551 * If flow pattern does not define a valid VXLAN tunnel (as specified by
1552 * RFC7348) then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION
1555 RTE_FLOW_ACTION_TYPE_VXLAN_DECAP,
1558 * Encapsulate flow in NVGRE tunnel defined in the
1559 * rte_flow_action_nvgre_encap action structure.
1561 * See struct rte_flow_action_nvgre_encap.
1563 RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP,
1566 * Decapsulate outer most NVGRE tunnel from matched flow.
1568 * If flow pattern does not define a valid NVGRE tunnel (as specified by
1569 * RFC7637) then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION
1572 RTE_FLOW_ACTION_TYPE_NVGRE_DECAP,
1575 * Add outer header whose template is provided in its data buffer
1577 * See struct rte_flow_action_raw_encap.
1579 RTE_FLOW_ACTION_TYPE_RAW_ENCAP,
1582 * Remove outer header whose template is provided in its data buffer.
1584 * See struct rte_flow_action_raw_decap
1586 RTE_FLOW_ACTION_TYPE_RAW_DECAP,
1589 * Modify IPv4 source address in the outermost IPv4 header.
1591 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV4,
1592 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
1594 * See struct rte_flow_action_set_ipv4.
1596 RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC,
1599 * Modify IPv4 destination address in the outermost IPv4 header.
1601 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV4,
1602 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
1604 * See struct rte_flow_action_set_ipv4.
1606 RTE_FLOW_ACTION_TYPE_SET_IPV4_DST,
1609 * Modify IPv6 source address in the outermost IPv6 header.
1611 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV6,
1612 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
1614 * See struct rte_flow_action_set_ipv6.
1616 RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC,
1619 * Modify IPv6 destination address in the outermost IPv6 header.
1621 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV6,
1622 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
1624 * See struct rte_flow_action_set_ipv6.
1626 RTE_FLOW_ACTION_TYPE_SET_IPV6_DST,
1629 * Modify source port number in the outermost TCP/UDP header.
1631 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_TCP
1632 * or RTE_FLOW_ITEM_TYPE_UDP, then the PMD should return a
1633 * RTE_FLOW_ERROR_TYPE_ACTION error.
1635 * See struct rte_flow_action_set_tp.
1637 RTE_FLOW_ACTION_TYPE_SET_TP_SRC,
1640 * Modify destination port number in the outermost TCP/UDP header.
1642 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_TCP
1643 * or RTE_FLOW_ITEM_TYPE_UDP, then the PMD should return a
1644 * RTE_FLOW_ERROR_TYPE_ACTION error.
1646 * See struct rte_flow_action_set_tp.
1648 RTE_FLOW_ACTION_TYPE_SET_TP_DST,
1651 * Swap the source and destination MAC addresses in the outermost
1654 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_ETH,
1655 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
1657 * No associated configuration structure.
1659 RTE_FLOW_ACTION_TYPE_MAC_SWAP,
1662 * Decrease TTL value directly
1664 * No associated configuration structure.
1666 RTE_FLOW_ACTION_TYPE_DEC_TTL,
1671 * See struct rte_flow_action_set_ttl
1673 RTE_FLOW_ACTION_TYPE_SET_TTL,
1676 * Set source MAC address from matched flow.
1678 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_ETH,
1679 * the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
1681 * See struct rte_flow_action_set_mac.
1683 RTE_FLOW_ACTION_TYPE_SET_MAC_SRC,
1686 * Set destination MAC address from matched flow.
1688 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_ETH,
1689 * the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
1691 * See struct rte_flow_action_set_mac.
1693 RTE_FLOW_ACTION_TYPE_SET_MAC_DST,
1696 * Increase sequence number in the outermost TCP header.
1698 * Action configuration specifies the value to increase
1699 * TCP sequence number as a big-endian 32 bit integer.
1702 * @code rte_be32_t * @endcode
1704 * Using this action on non-matching traffic will result in
1705 * undefined behavior.
1707 RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ,
1710 * Decrease sequence number in the outermost TCP header.
1712 * Action configuration specifies the value to decrease
1713 * TCP sequence number as a big-endian 32 bit integer.
1716 * @code rte_be32_t * @endcode
1718 * Using this action on non-matching traffic will result in
1719 * undefined behavior.
1721 RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ,
1724 * Increase acknowledgment number in the outermost TCP header.
1726 * Action configuration specifies the value to increase
1727 * TCP acknowledgment number as a big-endian 32 bit integer.
1730 * @code rte_be32_t * @endcode
1732 * Using this action on non-matching traffic will result in
1733 * undefined behavior.
1735 RTE_FLOW_ACTION_TYPE_INC_TCP_ACK,
1738 * Decrease acknowledgment number in the outermost TCP header.
1740 * Action configuration specifies the value to decrease
1741 * TCP acknowledgment number as a big-endian 32 bit integer.
1744 * @code rte_be32_t * @endcode
1746 * Using this action on non-matching traffic will result in
1747 * undefined behavior.
1749 RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK,
1753 * RTE_FLOW_ACTION_TYPE_MARK
1755 * Attaches an integer value to packets and sets PKT_RX_FDIR and
1756 * PKT_RX_FDIR_ID mbuf flags.
1758 * This value is arbitrary and application-defined. Maximum allowed value
1759 * depends on the underlying implementation. It is returned in the
1760 * hash.fdir.hi mbuf field.
1762 struct rte_flow_action_mark {
1763 uint32_t id; /**< Integer value to return with packets. */
1768 * @b EXPERIMENTAL: this structure may change without prior notice
1770 * RTE_FLOW_ACTION_TYPE_JUMP
1772 * Redirects packets to a group on the current device.
1774 * In a hierarchy of groups, which can be used to represent physical or logical
1775 * flow tables on the device, this action allows the action to be a redirect to
1776 * a group on that device.
1778 struct rte_flow_action_jump {
1783 * RTE_FLOW_ACTION_TYPE_QUEUE
1785 * Assign packets to a given queue index.
1787 struct rte_flow_action_queue {
1788 uint16_t index; /**< Queue index to use. */
1794 * @b EXPERIMENTAL: this structure may change without prior notice
1796 * RTE_FLOW_ACTION_TYPE_COUNT
1798 * Adds a counter action to a matched flow.
1800 * If more than one count action is specified in a single flow rule, then each
1801 * action must specify a unique id.
1803 * Counters can be retrieved and reset through ``rte_flow_query()``, see
1804 * ``struct rte_flow_query_count``.
1806 * The shared flag indicates whether the counter is unique to the flow rule the
1807 * action is specified with, or whether it is a shared counter.
1809 * For a count action with the shared flag set, then then a global device
1810 * namespace is assumed for the counter id, so that any matched flow rules using
1811 * a count action with the same counter id on the same port will contribute to
1814 * For ports within the same switch domain then the counter id namespace extends
1815 * to all ports within that switch domain.
1817 struct rte_flow_action_count {
1818 uint32_t shared:1; /**< Share counter ID with other flow rules. */
1819 uint32_t reserved:31; /**< Reserved, must be zero. */
1820 uint32_t id; /**< Counter ID. */
1824 * RTE_FLOW_ACTION_TYPE_COUNT (query)
1826 * Query structure to retrieve and reset flow rule counters.
1828 struct rte_flow_query_count {
1829 uint32_t reset:1; /**< Reset counters after query [in]. */
1830 uint32_t hits_set:1; /**< hits field is set [out]. */
1831 uint32_t bytes_set:1; /**< bytes field is set [out]. */
1832 uint32_t reserved:29; /**< Reserved, must be zero [in, out]. */
1833 uint64_t hits; /**< Number of hits for this rule [out]. */
1834 uint64_t bytes; /**< Number of bytes through this rule [out]. */
1838 * Hash function types.
1840 enum rte_eth_hash_function {
1841 RTE_ETH_HASH_FUNCTION_DEFAULT = 0,
1842 RTE_ETH_HASH_FUNCTION_TOEPLITZ, /**< Toeplitz */
1843 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR, /**< Simple XOR */
1844 RTE_ETH_HASH_FUNCTION_MAX,
1848 * RTE_FLOW_ACTION_TYPE_RSS
1850 * Similar to QUEUE, except RSS is additionally performed on packets to
1851 * spread them among several queues according to the provided parameters.
1853 * Unlike global RSS settings used by other DPDK APIs, unsetting the
1854 * @p types field does not disable RSS in a flow rule. Doing so instead
1855 * requests safe unspecified "best-effort" settings from the underlying PMD,
1856 * which depending on the flow rule, may result in anything ranging from
1857 * empty (single queue) to all-inclusive RSS.
1859 * Note: RSS hash result is stored in the hash.rss mbuf field which overlaps
1860 * hash.fdir.lo. Since the MARK action sets the hash.fdir.hi field only,
1861 * both can be requested simultaneously.
1863 struct rte_flow_action_rss {
1864 enum rte_eth_hash_function func; /**< RSS hash function to apply. */
1866 * Packet encapsulation level RSS hash @p types apply to.
1868 * - @p 0 requests the default behavior. Depending on the packet
1869 * type, it can mean outermost, innermost, anything in between or
1872 * It basically stands for the innermost encapsulation level RSS
1873 * can be performed on according to PMD and device capabilities.
1875 * - @p 1 requests RSS to be performed on the outermost packet
1876 * encapsulation level.
1878 * - @p 2 and subsequent values request RSS to be performed on the
1879 * specified inner packet encapsulation level, from outermost to
1880 * innermost (lower to higher values).
1882 * Values other than @p 0 are not necessarily supported.
1884 * Requesting a specific RSS level on unrecognized traffic results
1885 * in undefined behavior. For predictable results, it is recommended
1886 * to make the flow rule pattern match packet headers up to the
1887 * requested encapsulation level so that only matching traffic goes
1891 uint64_t types; /**< Specific RSS hash types (see ETH_RSS_*). */
1892 uint32_t key_len; /**< Hash key length in bytes. */
1893 uint32_t queue_num; /**< Number of entries in @p queue. */
1894 const uint8_t *key; /**< Hash key. */
1895 const uint16_t *queue; /**< Queue indices to use. */
1899 * RTE_FLOW_ACTION_TYPE_VF
1901 * Directs matching traffic to a given virtual function of the current
1904 * Packets matched by a VF pattern item can be redirected to their original
1905 * VF ID instead of the specified one. This parameter may not be available
1906 * and is not guaranteed to work properly if the VF part is matched by a
1907 * prior flow rule or if packets are not addressed to a VF in the first
1910 struct rte_flow_action_vf {
1911 uint32_t original:1; /**< Use original VF ID if possible. */
1912 uint32_t reserved:31; /**< Reserved, must be zero. */
1913 uint32_t id; /**< VF ID. */
1917 * RTE_FLOW_ACTION_TYPE_PHY_PORT
1919 * Directs packets to a given physical port index of the underlying
1922 * @see RTE_FLOW_ITEM_TYPE_PHY_PORT
1924 struct rte_flow_action_phy_port {
1925 uint32_t original:1; /**< Use original port index if possible. */
1926 uint32_t reserved:31; /**< Reserved, must be zero. */
1927 uint32_t index; /**< Physical port index. */
1931 * RTE_FLOW_ACTION_TYPE_PORT_ID
1933 * Directs matching traffic to a given DPDK port ID.
1935 * @see RTE_FLOW_ITEM_TYPE_PORT_ID
1937 struct rte_flow_action_port_id {
1938 uint32_t original:1; /**< Use original DPDK port ID if possible. */
1939 uint32_t reserved:31; /**< Reserved, must be zero. */
1940 uint32_t id; /**< DPDK port ID. */
1944 * RTE_FLOW_ACTION_TYPE_METER
1946 * Traffic metering and policing (MTR).
1948 * Packets matched by items of this type can be either dropped or passed to the
1949 * next item with their color set by the MTR object.
1951 struct rte_flow_action_meter {
1952 uint32_t mtr_id; /**< MTR object ID created with rte_mtr_create(). */
1956 * RTE_FLOW_ACTION_TYPE_SECURITY
1958 * Perform the security action on flows matched by the pattern items
1959 * according to the configuration of the security session.
1961 * This action modifies the payload of matched flows. For INLINE_CRYPTO, the
1962 * security protocol headers and IV are fully provided by the application as
1963 * specified in the flow pattern. The payload of matching packets is
1964 * encrypted on egress, and decrypted and authenticated on ingress.
1965 * For INLINE_PROTOCOL, the security protocol is fully offloaded to HW,
1966 * providing full encapsulation and decapsulation of packets in security
1967 * protocols. The flow pattern specifies both the outer security header fields
1968 * and the inner packet fields. The security session specified in the action
1969 * must match the pattern parameters.
1971 * The security session specified in the action must be created on the same
1972 * port as the flow action that is being specified.
1974 * The ingress/egress flow attribute should match that specified in the
1975 * security session if the security session supports the definition of the
1978 * Multiple flows can be configured to use the same security session.
1980 struct rte_flow_action_security {
1981 void *security_session; /**< Pointer to security session structure. */
1985 * RTE_FLOW_ACTION_TYPE_OF_SET_MPLS_TTL
1987 * Implements OFPAT_SET_MPLS_TTL ("MPLS TTL") as defined by the OpenFlow
1988 * Switch Specification.
1990 struct rte_flow_action_of_set_mpls_ttl {
1991 uint8_t mpls_ttl; /**< MPLS TTL. */
1995 * RTE_FLOW_ACTION_TYPE_OF_SET_NW_TTL
1997 * Implements OFPAT_SET_NW_TTL ("IP TTL") as defined by the OpenFlow Switch
2000 struct rte_flow_action_of_set_nw_ttl {
2001 uint8_t nw_ttl; /**< IP TTL. */
2005 * RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN
2007 * Implements OFPAT_PUSH_VLAN ("push a new VLAN tag") as defined by the
2008 * OpenFlow Switch Specification.
2010 struct rte_flow_action_of_push_vlan {
2011 rte_be16_t ethertype; /**< EtherType. */
2015 * RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID
2017 * Implements OFPAT_SET_VLAN_VID ("set the 802.1q VLAN id") as defined by
2018 * the OpenFlow Switch Specification.
2020 struct rte_flow_action_of_set_vlan_vid {
2021 rte_be16_t vlan_vid; /**< VLAN id. */
2025 * RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP
2027 * Implements OFPAT_SET_LAN_PCP ("set the 802.1q priority") as defined by
2028 * the OpenFlow Switch Specification.
2030 struct rte_flow_action_of_set_vlan_pcp {
2031 uint8_t vlan_pcp; /**< VLAN priority. */
2035 * RTE_FLOW_ACTION_TYPE_OF_POP_MPLS
2037 * Implements OFPAT_POP_MPLS ("pop the outer MPLS tag") as defined by the
2038 * OpenFlow Switch Specification.
2040 struct rte_flow_action_of_pop_mpls {
2041 rte_be16_t ethertype; /**< EtherType. */
2045 * RTE_FLOW_ACTION_TYPE_OF_PUSH_MPLS
2047 * Implements OFPAT_PUSH_MPLS ("push a new MPLS tag") as defined by the
2048 * OpenFlow Switch Specification.
2050 struct rte_flow_action_of_push_mpls {
2051 rte_be16_t ethertype; /**< EtherType. */
2056 * @b EXPERIMENTAL: this structure may change without prior notice
2058 * RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP
2060 * VXLAN tunnel end-point encapsulation data definition
2062 * The tunnel definition is provided through the flow item pattern, the
2063 * provided pattern must conform to RFC7348 for the tunnel specified. The flow
2064 * definition must be provided in order from the RTE_FLOW_ITEM_TYPE_ETH
2065 * definition up the end item which is specified by RTE_FLOW_ITEM_TYPE_END.
2067 * The mask field allows user to specify which fields in the flow item
2068 * definitions can be ignored and which have valid data and can be used
2071 * Note: the last field is not used in the definition of a tunnel and can be
2074 * Valid flow definition for RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP include:
2076 * - ETH / IPV4 / UDP / VXLAN / END
2077 * - ETH / IPV6 / UDP / VXLAN / END
2078 * - ETH / VLAN / IPV4 / UDP / VXLAN / END
2081 struct rte_flow_action_vxlan_encap {
2083 * Encapsulating vxlan tunnel definition
2084 * (terminated by the END pattern item).
2086 struct rte_flow_item *definition;
2091 * @b EXPERIMENTAL: this structure may change without prior notice
2093 * RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP
2095 * NVGRE tunnel end-point encapsulation data definition
2097 * The tunnel definition is provided through the flow item pattern the
2098 * provided pattern must conform with RFC7637. The flow definition must be
2099 * provided in order from the RTE_FLOW_ITEM_TYPE_ETH definition up the end item
2100 * which is specified by RTE_FLOW_ITEM_TYPE_END.
2102 * The mask field allows user to specify which fields in the flow item
2103 * definitions can be ignored and which have valid data and can be used
2106 * Note: the last field is not used in the definition of a tunnel and can be
2109 * Valid flow definition for RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP include:
2111 * - ETH / IPV4 / NVGRE / END
2112 * - ETH / VLAN / IPV6 / NVGRE / END
2115 struct rte_flow_action_nvgre_encap {
2117 * Encapsulating vxlan tunnel definition
2118 * (terminated by the END pattern item).
2120 struct rte_flow_item *definition;
2125 * @b EXPERIMENTAL: this structure may change without prior notice
2127 * RTE_FLOW_ACTION_TYPE_RAW_ENCAP
2129 * Raw tunnel end-point encapsulation data definition.
2131 * The data holds the headers definitions to be applied on the packet.
2132 * The data must start with ETH header up to the tunnel item header itself.
2133 * When used right after RAW_DECAP (for decapsulating L3 tunnel type for
2134 * example MPLSoGRE) the data will just hold layer 2 header.
2136 * The preserve parameter holds which bits in the packet the PMD is not allowed
2137 * to change, this parameter can also be NULL and then the PMD is allowed
2138 * to update any field.
2140 * size holds the number of bytes in @p data and @p preserve.
2142 struct rte_flow_action_raw_encap {
2143 uint8_t *data; /**< Encapsulation data. */
2144 uint8_t *preserve; /**< Bit-mask of @p data to preserve on output. */
2145 size_t size; /**< Size of @p data and @p preserve. */
2150 * @b EXPERIMENTAL: this structure may change without prior notice
2152 * RTE_FLOW_ACTION_TYPE_RAW_DECAP
2154 * Raw tunnel end-point decapsulation data definition.
2156 * The data holds the headers definitions to be removed from the packet.
2157 * The data must start with ETH header up to the tunnel item header itself.
2158 * When used right before RAW_DECAP (for encapsulating L3 tunnel type for
2159 * example MPLSoGRE) the data will just hold layer 2 header.
2161 * size holds the number of bytes in @p data.
2163 struct rte_flow_action_raw_decap {
2164 uint8_t *data; /**< Encapsulation data. */
2165 size_t size; /**< Size of @p data and @p preserve. */
2170 * @b EXPERIMENTAL: this structure may change without prior notice
2172 * RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC
2173 * RTE_FLOW_ACTION_TYPE_SET_IPV4_DST
2175 * Allows modification of IPv4 source (RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC)
2176 * and destination address (RTE_FLOW_ACTION_TYPE_SET_IPV4_DST) in the
2177 * specified outermost IPv4 header.
2179 struct rte_flow_action_set_ipv4 {
2180 rte_be32_t ipv4_addr;
2185 * @b EXPERIMENTAL: this structure may change without prior notice
2187 * RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC
2188 * RTE_FLOW_ACTION_TYPE_SET_IPV6_DST
2190 * Allows modification of IPv6 source (RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC)
2191 * and destination address (RTE_FLOW_ACTION_TYPE_SET_IPV6_DST) in the
2192 * specified outermost IPv6 header.
2194 struct rte_flow_action_set_ipv6 {
2195 uint8_t ipv6_addr[16];
2200 * @b EXPERIMENTAL: this structure may change without prior notice
2202 * RTE_FLOW_ACTION_TYPE_SET_TP_SRC
2203 * RTE_FLOW_ACTION_TYPE_SET_TP_DST
2205 * Allows modification of source (RTE_FLOW_ACTION_TYPE_SET_TP_SRC)
2206 * and destination (RTE_FLOW_ACTION_TYPE_SET_TP_DST) port numbers
2207 * in the specified outermost TCP/UDP header.
2209 struct rte_flow_action_set_tp {
2214 * RTE_FLOW_ACTION_TYPE_SET_TTL
2216 * Set the TTL value directly for IPv4 or IPv6
2218 struct rte_flow_action_set_ttl {
2223 * RTE_FLOW_ACTION_TYPE_SET_MAC
2225 * Set MAC address from the matched flow
2227 struct rte_flow_action_set_mac {
2228 uint8_t mac_addr[RTE_ETHER_ADDR_LEN];
2232 * Definition of a single action.
2234 * A list of actions is terminated by a END action.
2236 * For simple actions without a configuration object, conf remains NULL.
2238 struct rte_flow_action {
2239 enum rte_flow_action_type type; /**< Action type. */
2240 const void *conf; /**< Pointer to action configuration object. */
2244 * Opaque type returned after successfully creating a flow.
2246 * This handle can be used to manage and query the related flow (e.g. to
2247 * destroy it or retrieve counters).
2252 * Verbose error types.
2254 * Most of them provide the type of the object referenced by struct
2255 * rte_flow_error.cause.
2257 enum rte_flow_error_type {
2258 RTE_FLOW_ERROR_TYPE_NONE, /**< No error. */
2259 RTE_FLOW_ERROR_TYPE_UNSPECIFIED, /**< Cause unspecified. */
2260 RTE_FLOW_ERROR_TYPE_HANDLE, /**< Flow rule (handle). */
2261 RTE_FLOW_ERROR_TYPE_ATTR_GROUP, /**< Group field. */
2262 RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY, /**< Priority field. */
2263 RTE_FLOW_ERROR_TYPE_ATTR_INGRESS, /**< Ingress field. */
2264 RTE_FLOW_ERROR_TYPE_ATTR_EGRESS, /**< Egress field. */
2265 RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, /**< Transfer field. */
2266 RTE_FLOW_ERROR_TYPE_ATTR, /**< Attributes structure. */
2267 RTE_FLOW_ERROR_TYPE_ITEM_NUM, /**< Pattern length. */
2268 RTE_FLOW_ERROR_TYPE_ITEM_SPEC, /**< Item specification. */
2269 RTE_FLOW_ERROR_TYPE_ITEM_LAST, /**< Item specification range. */
2270 RTE_FLOW_ERROR_TYPE_ITEM_MASK, /**< Item specification mask. */
2271 RTE_FLOW_ERROR_TYPE_ITEM, /**< Specific pattern item. */
2272 RTE_FLOW_ERROR_TYPE_ACTION_NUM, /**< Number of actions. */
2273 RTE_FLOW_ERROR_TYPE_ACTION_CONF, /**< Action configuration. */
2274 RTE_FLOW_ERROR_TYPE_ACTION, /**< Specific action. */
2278 * Verbose error structure definition.
2280 * This object is normally allocated by applications and set by PMDs, the
2281 * message points to a constant string which does not need to be freed by
2282 * the application, however its pointer can be considered valid only as long
2283 * as its associated DPDK port remains configured. Closing the underlying
2284 * device or unloading the PMD invalidates it.
2286 * Both cause and message may be NULL regardless of the error type.
2288 struct rte_flow_error {
2289 enum rte_flow_error_type type; /**< Cause field and error types. */
2290 const void *cause; /**< Object responsible for the error. */
2291 const char *message; /**< Human-readable error message. */
2295 * Complete flow rule description.
2297 * This object type is used when converting a flow rule description.
2299 * @see RTE_FLOW_CONV_OP_RULE
2300 * @see rte_flow_conv()
2303 struct rte_flow_conv_rule {
2305 const struct rte_flow_attr *attr_ro; /**< RO attributes. */
2306 struct rte_flow_attr *attr; /**< Attributes. */
2309 const struct rte_flow_item *pattern_ro; /**< RO pattern. */
2310 struct rte_flow_item *pattern; /**< Pattern items. */
2313 const struct rte_flow_action *actions_ro; /**< RO actions. */
2314 struct rte_flow_action *actions; /**< List of actions. */
2319 * Conversion operations for flow API objects.
2321 * @see rte_flow_conv()
2323 enum rte_flow_conv_op {
2325 * No operation to perform.
2327 * rte_flow_conv() simply returns 0.
2329 RTE_FLOW_CONV_OP_NONE,
2332 * Convert attributes structure.
2334 * This is a basic copy of an attributes structure.
2337 * @code const struct rte_flow_attr * @endcode
2339 * @code struct rte_flow_attr * @endcode
2341 RTE_FLOW_CONV_OP_ATTR,
2344 * Convert a single item.
2346 * Duplicates @p spec, @p last and @p mask but not outside objects.
2349 * @code const struct rte_flow_item * @endcode
2351 * @code struct rte_flow_item * @endcode
2353 RTE_FLOW_CONV_OP_ITEM,
2356 * Convert a single action.
2358 * Duplicates @p conf but not outside objects.
2361 * @code const struct rte_flow_action * @endcode
2363 * @code struct rte_flow_action * @endcode
2365 RTE_FLOW_CONV_OP_ACTION,
2368 * Convert an entire pattern.
2370 * Duplicates all pattern items at once with the same constraints as
2371 * RTE_FLOW_CONV_OP_ITEM.
2374 * @code const struct rte_flow_item * @endcode
2376 * @code struct rte_flow_item * @endcode
2378 RTE_FLOW_CONV_OP_PATTERN,
2381 * Convert a list of actions.
2383 * Duplicates the entire list of actions at once with the same
2384 * constraints as RTE_FLOW_CONV_OP_ACTION.
2387 * @code const struct rte_flow_action * @endcode
2389 * @code struct rte_flow_action * @endcode
2391 RTE_FLOW_CONV_OP_ACTIONS,
2394 * Convert a complete flow rule description.
2396 * Comprises attributes, pattern and actions together at once with
2397 * the usual constraints.
2400 * @code const struct rte_flow_conv_rule * @endcode
2402 * @code struct rte_flow_conv_rule * @endcode
2404 RTE_FLOW_CONV_OP_RULE,
2407 * Convert item type to its name string.
2409 * Writes a NUL-terminated string to @p dst. Like snprintf(), the
2410 * returned value excludes the terminator which is always written
2414 * @code (const void *)enum rte_flow_item_type @endcode
2416 * @code char * @endcode
2418 RTE_FLOW_CONV_OP_ITEM_NAME,
2421 * Convert action type to its name string.
2423 * Writes a NUL-terminated string to @p dst. Like snprintf(), the
2424 * returned value excludes the terminator which is always written
2428 * @code (const void *)enum rte_flow_action_type @endcode
2430 * @code char * @endcode
2432 RTE_FLOW_CONV_OP_ACTION_NAME,
2435 * Convert item type to pointer to item name.
2437 * Retrieves item name pointer from its type. The string itself is
2438 * not copied; instead, a unique pointer to an internal static
2439 * constant storage is written to @p dst.
2442 * @code (const void *)enum rte_flow_item_type @endcode
2444 * @code const char ** @endcode
2446 RTE_FLOW_CONV_OP_ITEM_NAME_PTR,
2449 * Convert action type to pointer to action name.
2451 * Retrieves action name pointer from its type. The string itself is
2452 * not copied; instead, a unique pointer to an internal static
2453 * constant storage is written to @p dst.
2456 * @code (const void *)enum rte_flow_action_type @endcode
2458 * @code const char ** @endcode
2460 RTE_FLOW_CONV_OP_ACTION_NAME_PTR,
2464 * Check whether a flow rule can be created on a given port.
2466 * The flow rule is validated for correctness and whether it could be accepted
2467 * by the device given sufficient resources. The rule is checked against the
2468 * current device mode and queue configuration. The flow rule may also
2469 * optionally be validated against existing flow rules and device resources.
2470 * This function has no effect on the target device.
2472 * The returned value is guaranteed to remain valid only as long as no
2473 * successful calls to rte_flow_create() or rte_flow_destroy() are made in
2474 * the meantime and no device parameter affecting flow rules in any way are
2475 * modified, due to possible collisions or resource limitations (although in
2476 * such cases EINVAL should not be returned).
2479 * Port identifier of Ethernet device.
2481 * Flow rule attributes.
2482 * @param[in] pattern
2483 * Pattern specification (list terminated by the END pattern item).
2484 * @param[in] actions
2485 * Associated actions (list terminated by the END action).
2487 * Perform verbose error reporting if not NULL. PMDs initialize this
2488 * structure in case of error only.
2491 * 0 if flow rule is valid and can be created. A negative errno value
2492 * otherwise (rte_errno is also set), the following errors are defined:
2494 * -ENOSYS: underlying device does not support this functionality.
2496 * -EIO: underlying device is removed.
2498 * -EINVAL: unknown or invalid rule specification.
2500 * -ENOTSUP: valid but unsupported rule specification (e.g. partial
2501 * bit-masks are unsupported).
2503 * -EEXIST: collision with an existing rule. Only returned if device
2504 * supports flow rule collision checking and there was a flow rule
2505 * collision. Not receiving this return code is no guarantee that creating
2506 * the rule will not fail due to a collision.
2508 * -ENOMEM: not enough memory to execute the function, or if the device
2509 * supports resource validation, resource limitation on the device.
2511 * -EBUSY: action cannot be performed due to busy device resources, may
2512 * succeed if the affected queues or even the entire port are in a stopped
2513 * state (see rte_eth_dev_rx_queue_stop() and rte_eth_dev_stop()).
2516 rte_flow_validate(uint16_t port_id,
2517 const struct rte_flow_attr *attr,
2518 const struct rte_flow_item pattern[],
2519 const struct rte_flow_action actions[],
2520 struct rte_flow_error *error);
2523 * Create a flow rule on a given port.
2526 * Port identifier of Ethernet device.
2528 * Flow rule attributes.
2529 * @param[in] pattern
2530 * Pattern specification (list terminated by the END pattern item).
2531 * @param[in] actions
2532 * Associated actions (list terminated by the END action).
2534 * Perform verbose error reporting if not NULL. PMDs initialize this
2535 * structure in case of error only.
2538 * A valid handle in case of success, NULL otherwise and rte_errno is set
2539 * to the positive version of one of the error codes defined for
2540 * rte_flow_validate().
2543 rte_flow_create(uint16_t port_id,
2544 const struct rte_flow_attr *attr,
2545 const struct rte_flow_item pattern[],
2546 const struct rte_flow_action actions[],
2547 struct rte_flow_error *error);
2550 * Destroy a flow rule on a given port.
2552 * Failure to destroy a flow rule handle may occur when other flow rules
2553 * depend on it, and destroying it would result in an inconsistent state.
2555 * This function is only guaranteed to succeed if handles are destroyed in
2556 * reverse order of their creation.
2559 * Port identifier of Ethernet device.
2561 * Flow rule handle to destroy.
2563 * Perform verbose error reporting if not NULL. PMDs initialize this
2564 * structure in case of error only.
2567 * 0 on success, a negative errno value otherwise and rte_errno is set.
2570 rte_flow_destroy(uint16_t port_id,
2571 struct rte_flow *flow,
2572 struct rte_flow_error *error);
2575 * Destroy all flow rules associated with a port.
2577 * In the unlikely event of failure, handles are still considered destroyed
2578 * and no longer valid but the port must be assumed to be in an inconsistent
2582 * Port identifier of Ethernet device.
2584 * Perform verbose error reporting if not NULL. PMDs initialize this
2585 * structure in case of error only.
2588 * 0 on success, a negative errno value otherwise and rte_errno is set.
2591 rte_flow_flush(uint16_t port_id,
2592 struct rte_flow_error *error);
2595 * Query an existing flow rule.
2597 * This function allows retrieving flow-specific data such as counters.
2598 * Data is gathered by special actions which must be present in the flow
2601 * \see RTE_FLOW_ACTION_TYPE_COUNT
2604 * Port identifier of Ethernet device.
2606 * Flow rule handle to query.
2608 * Action definition as defined in original flow rule.
2609 * @param[in, out] data
2610 * Pointer to storage for the associated query data type.
2612 * Perform verbose error reporting if not NULL. PMDs initialize this
2613 * structure in case of error only.
2616 * 0 on success, a negative errno value otherwise and rte_errno is set.
2619 rte_flow_query(uint16_t port_id,
2620 struct rte_flow *flow,
2621 const struct rte_flow_action *action,
2623 struct rte_flow_error *error);
2626 * Restrict ingress traffic to the defined flow rules.
2628 * Isolated mode guarantees that all ingress traffic comes from defined flow
2629 * rules only (current and future).
2631 * Besides making ingress more deterministic, it allows PMDs to safely reuse
2632 * resources otherwise assigned to handle the remaining traffic, such as
2633 * global RSS configuration settings, VLAN filters, MAC address entries,
2634 * legacy filter API rules and so on in order to expand the set of possible
2637 * Calling this function as soon as possible after device initialization,
2638 * ideally before the first call to rte_eth_dev_configure(), is recommended
2639 * to avoid possible failures due to conflicting settings.
2641 * Once effective, leaving isolated mode may not be possible depending on
2642 * PMD implementation.
2644 * Additionally, the following functionality has no effect on the underlying
2645 * port and may return errors such as ENOTSUP ("not supported"):
2647 * - Toggling promiscuous mode.
2648 * - Toggling allmulticast mode.
2649 * - Configuring MAC addresses.
2650 * - Configuring multicast addresses.
2651 * - Configuring VLAN filters.
2652 * - Configuring Rx filters through the legacy API (e.g. FDIR).
2653 * - Configuring global RSS settings.
2656 * Port identifier of Ethernet device.
2658 * Nonzero to enter isolated mode, attempt to leave it otherwise.
2660 * Perform verbose error reporting if not NULL. PMDs initialize this
2661 * structure in case of error only.
2664 * 0 on success, a negative errno value otherwise and rte_errno is set.
2667 rte_flow_isolate(uint16_t port_id, int set, struct rte_flow_error *error);
2670 * Initialize flow error structure.
2673 * Pointer to flow error structure (may be NULL).
2675 * Related error code (rte_errno).
2677 * Cause field and error types.
2679 * Object responsible for the error.
2681 * Human-readable error message.
2684 * Negative error code (errno value) and rte_errno is set.
2687 rte_flow_error_set(struct rte_flow_error *error,
2689 enum rte_flow_error_type type,
2691 const char *message);
2695 * @see rte_flow_copy()
2697 struct rte_flow_desc {
2698 size_t size; /**< Allocated space including data[]. */
2699 struct rte_flow_attr attr; /**< Attributes. */
2700 struct rte_flow_item *items; /**< Items. */
2701 struct rte_flow_action *actions; /**< Actions. */
2702 uint8_t data[]; /**< Storage for items/actions. */
2707 * Copy an rte_flow rule description.
2709 * This interface is kept for compatibility with older applications but is
2710 * implemented as a wrapper to rte_flow_conv(). It is deprecated due to its
2711 * lack of flexibility and reliance on a type unusable with C++ programs
2712 * (struct rte_flow_desc).
2715 * Flow rule description.
2717 * Total size of allocated data for the flow description.
2719 * Flow rule attributes.
2721 * Pattern specification (list terminated by the END pattern item).
2722 * @param[in] actions
2723 * Associated actions (list terminated by the END action).
2726 * If len is greater or equal to the size of the flow, the total size of the
2727 * flow description and its data.
2728 * If len is lower than the size of the flow, the number of bytes that would
2729 * have been written to desc had it been sufficient. Nothing is written.
2733 rte_flow_copy(struct rte_flow_desc *fd, size_t len,
2734 const struct rte_flow_attr *attr,
2735 const struct rte_flow_item *items,
2736 const struct rte_flow_action *actions);
2739 * Flow object conversion helper.
2741 * This function performs conversion of various flow API objects to a
2742 * pre-allocated destination buffer. See enum rte_flow_conv_op for possible
2743 * operations and details about each of them.
2745 * Since destination buffer must be large enough, it works in a manner
2746 * reminiscent of snprintf():
2748 * - If @p size is 0, @p dst may be a NULL pointer, otherwise @p dst must be
2750 * - If positive, the returned value represents the number of bytes needed
2751 * to store the conversion of @p src to @p dst according to @p op
2752 * regardless of the @p size parameter.
2753 * - Since no more than @p size bytes can be written to @p dst, output is
2754 * truncated and may be inconsistent when the returned value is larger
2756 * - In case of conversion error, a negative error code is returned and
2757 * @p dst contents are unspecified.
2760 * Operation to perform, related to the object type of @p dst.
2762 * Destination buffer address. Must be suitably aligned by the caller.
2764 * Destination buffer size in bytes.
2766 * Source object to copy. Depending on @p op, its type may differ from
2769 * Perform verbose error reporting if not NULL. Initialized in case of
2773 * The number of bytes required to convert @p src to @p dst on success, a
2774 * negative errno value otherwise and rte_errno is set.
2776 * @see rte_flow_conv_op
2780 rte_flow_conv(enum rte_flow_conv_op op,
2784 struct rte_flow_error *error);
2790 #endif /* RTE_FLOW_H_ */