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>
23 #include <rte_eth_ctrl.h>
29 #include <rte_byteorder.h>
37 * Flow rule attributes.
39 * Priorities are set on a per rule based within groups.
41 * Lower values denote higher priority, the highest priority for a flow rule
42 * is 0, so that a flow that matches for than one rule, the rule with the
43 * lowest priority value will always be matched.
45 * Although optional, applications are encouraged to group similar rules as
46 * much as possible to fully take advantage of hardware capabilities
47 * (e.g. optimized matching) and work around limitations (e.g. a single
48 * pattern type possibly allowed in a given group). Applications should be
49 * aware that groups are not linked by default, and that they must be
50 * explicitly linked by the application using the JUMP action.
52 * Priority levels are arbitrary and up to the application, they
53 * do not need to be contiguous nor start from 0, however the maximum number
54 * varies between devices and may be affected by existing flow rules.
56 * If a packet is matched by several rules of a given group for a given
57 * priority level, the outcome is undefined. It can take any path, may be
58 * duplicated or even cause unrecoverable errors.
60 * Note that support for more than a single group and priority level is not
63 * Flow rules can apply to inbound and/or outbound traffic (ingress/egress).
65 * Several pattern items and actions are valid and can be used in both
66 * directions. Those valid for only one direction are described as such.
68 * At least one direction must be specified.
70 * Specifying both directions at once for a given rule is not recommended
71 * but may be valid in a few cases (e.g. shared counter).
73 struct rte_flow_attr {
74 uint32_t group; /**< Priority group. */
75 uint32_t priority; /**< Rule priority level within group. */
76 uint32_t ingress:1; /**< Rule applies to ingress traffic. */
77 uint32_t egress:1; /**< Rule applies to egress traffic. */
79 * Instead of simply matching the properties of traffic as it would
80 * appear on a given DPDK port ID, enabling this attribute transfers
81 * a flow rule to the lowest possible level of any device endpoints
82 * found in the pattern.
84 * When supported, this effectively enables an application to
85 * re-route traffic not necessarily intended for it (e.g. coming
86 * from or addressed to different physical ports, VFs or
87 * applications) at the device level.
89 * It complements the behavior of some pattern items such as
90 * RTE_FLOW_ITEM_TYPE_PHY_PORT and is meaningless without them.
92 * When transferring flow rules, ingress and egress attributes keep
93 * their original meaning, as if processing traffic emitted or
94 * received by the application.
97 uint32_t reserved:29; /**< Reserved, must be zero. */
101 * Matching pattern item types.
103 * Pattern items fall in two categories:
105 * - Matching protocol headers and packet data, usually associated with a
106 * specification structure. These must be stacked in the same order as the
107 * protocol layers to match inside packets, starting from the lowest.
109 * - Matching meta-data or affecting pattern processing, often without a
110 * specification structure. Since they do not match packet contents, their
111 * position in the list is usually not relevant.
113 * See the description of individual types for more information. Those
114 * marked with [META] fall into the second category.
116 enum rte_flow_item_type {
120 * End marker for item lists. Prevents further processing of items,
121 * thereby ending the pattern.
123 * No associated specification structure.
125 RTE_FLOW_ITEM_TYPE_END,
130 * Used as a placeholder for convenience. It is ignored and simply
133 * No associated specification structure.
135 RTE_FLOW_ITEM_TYPE_VOID,
140 * Inverted matching, i.e. process packets that do not match the
143 * No associated specification structure.
145 RTE_FLOW_ITEM_TYPE_INVERT,
148 * Matches any protocol in place of the current layer, a single ANY
149 * may also stand for several protocol layers.
151 * See struct rte_flow_item_any.
153 RTE_FLOW_ITEM_TYPE_ANY,
158 * Matches traffic originating from (ingress) or going to (egress)
159 * the physical function of the current device.
161 * No associated specification structure.
163 RTE_FLOW_ITEM_TYPE_PF,
168 * Matches traffic originating from (ingress) or going to (egress) a
169 * given virtual function of the current device.
171 * See struct rte_flow_item_vf.
173 RTE_FLOW_ITEM_TYPE_VF,
178 * Matches traffic originating from (ingress) or going to (egress) a
179 * physical port of the underlying device.
181 * See struct rte_flow_item_phy_port.
183 RTE_FLOW_ITEM_TYPE_PHY_PORT,
188 * Matches traffic originating from (ingress) or going to (egress) a
189 * given DPDK port ID.
191 * See struct rte_flow_item_port_id.
193 RTE_FLOW_ITEM_TYPE_PORT_ID,
196 * Matches a byte string of a given length at a given offset.
198 * See struct rte_flow_item_raw.
200 RTE_FLOW_ITEM_TYPE_RAW,
203 * Matches an Ethernet header.
205 * See struct rte_flow_item_eth.
207 RTE_FLOW_ITEM_TYPE_ETH,
210 * Matches an 802.1Q/ad VLAN tag.
212 * See struct rte_flow_item_vlan.
214 RTE_FLOW_ITEM_TYPE_VLAN,
217 * Matches an IPv4 header.
219 * See struct rte_flow_item_ipv4.
221 RTE_FLOW_ITEM_TYPE_IPV4,
224 * Matches an IPv6 header.
226 * See struct rte_flow_item_ipv6.
228 RTE_FLOW_ITEM_TYPE_IPV6,
231 * Matches an ICMP header.
233 * See struct rte_flow_item_icmp.
235 RTE_FLOW_ITEM_TYPE_ICMP,
238 * Matches a UDP header.
240 * See struct rte_flow_item_udp.
242 RTE_FLOW_ITEM_TYPE_UDP,
245 * Matches a TCP header.
247 * See struct rte_flow_item_tcp.
249 RTE_FLOW_ITEM_TYPE_TCP,
252 * Matches a SCTP header.
254 * See struct rte_flow_item_sctp.
256 RTE_FLOW_ITEM_TYPE_SCTP,
259 * Matches a VXLAN header.
261 * See struct rte_flow_item_vxlan.
263 RTE_FLOW_ITEM_TYPE_VXLAN,
266 * Matches a E_TAG header.
268 * See struct rte_flow_item_e_tag.
270 RTE_FLOW_ITEM_TYPE_E_TAG,
273 * Matches a NVGRE header.
275 * See struct rte_flow_item_nvgre.
277 RTE_FLOW_ITEM_TYPE_NVGRE,
280 * Matches a MPLS header.
282 * See struct rte_flow_item_mpls.
284 RTE_FLOW_ITEM_TYPE_MPLS,
287 * Matches a GRE header.
289 * See struct rte_flow_item_gre.
291 RTE_FLOW_ITEM_TYPE_GRE,
296 * Fuzzy pattern match, expect faster than default.
298 * This is for device that support fuzzy matching option.
299 * Usually a fuzzy matching is fast but the cost is accuracy.
301 * See struct rte_flow_item_fuzzy.
303 RTE_FLOW_ITEM_TYPE_FUZZY,
306 * Matches a GTP header.
308 * Configure flow for GTP packets.
310 * See struct rte_flow_item_gtp.
312 RTE_FLOW_ITEM_TYPE_GTP,
315 * Matches a GTP header.
317 * Configure flow for GTP-C packets.
319 * See struct rte_flow_item_gtp.
321 RTE_FLOW_ITEM_TYPE_GTPC,
324 * Matches a GTP header.
326 * Configure flow for GTP-U packets.
328 * See struct rte_flow_item_gtp.
330 RTE_FLOW_ITEM_TYPE_GTPU,
333 * Matches a ESP header.
335 * See struct rte_flow_item_esp.
337 RTE_FLOW_ITEM_TYPE_ESP,
340 * Matches a GENEVE header.
342 * See struct rte_flow_item_geneve.
344 RTE_FLOW_ITEM_TYPE_GENEVE,
347 * Matches a VXLAN-GPE header.
349 * See struct rte_flow_item_vxlan_gpe.
351 RTE_FLOW_ITEM_TYPE_VXLAN_GPE,
354 * Matches an ARP header for Ethernet/IPv4.
356 * See struct rte_flow_item_arp_eth_ipv4.
358 RTE_FLOW_ITEM_TYPE_ARP_ETH_IPV4,
361 * Matches the presence of any IPv6 extension header.
363 * See struct rte_flow_item_ipv6_ext.
365 RTE_FLOW_ITEM_TYPE_IPV6_EXT,
368 * Matches any ICMPv6 header.
370 * See struct rte_flow_item_icmp6.
372 RTE_FLOW_ITEM_TYPE_ICMP6,
375 * Matches an ICMPv6 neighbor discovery solicitation.
377 * See struct rte_flow_item_icmp6_nd_ns.
379 RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS,
382 * Matches an ICMPv6 neighbor discovery advertisement.
384 * See struct rte_flow_item_icmp6_nd_na.
386 RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA,
389 * Matches the presence of any ICMPv6 neighbor discovery option.
391 * See struct rte_flow_item_icmp6_nd_opt.
393 RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT,
396 * Matches an ICMPv6 neighbor discovery source Ethernet link-layer
399 * See struct rte_flow_item_icmp6_nd_opt_sla_eth.
401 RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_SLA_ETH,
404 * Matches an ICMPv6 neighbor discovery target Ethernet link-layer
407 * See struct rte_flow_item_icmp6_nd_opt_tla_eth.
409 RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_TLA_ETH,
412 * Matches specified mark field.
414 * See struct rte_flow_item_mark.
416 RTE_FLOW_ITEM_TYPE_MARK,
420 * RTE_FLOW_ITEM_TYPE_ANY
422 * Matches any protocol in place of the current layer, a single ANY may also
423 * stand for several protocol layers.
425 * This is usually specified as the first pattern item when looking for a
426 * protocol anywhere in a packet.
428 * A zeroed mask stands for any number of layers.
430 struct rte_flow_item_any {
431 uint32_t num; /**< Number of layers covered. */
434 /** Default mask for RTE_FLOW_ITEM_TYPE_ANY. */
436 static const struct rte_flow_item_any rte_flow_item_any_mask = {
442 * RTE_FLOW_ITEM_TYPE_VF
444 * Matches traffic originating from (ingress) or going to (egress) a given
445 * virtual function of the current device.
447 * If supported, should work even if the virtual function is not managed by
448 * the application and thus not associated with a DPDK port ID.
450 * Note this pattern item does not match VF representors traffic which, as
451 * separate entities, should be addressed through their own DPDK port IDs.
453 * - Can be specified multiple times to match traffic addressed to several
455 * - Can be combined with a PF item to match both PF and VF traffic.
457 * A zeroed mask can be used to match any VF ID.
459 struct rte_flow_item_vf {
460 uint32_t id; /**< VF ID. */
463 /** Default mask for RTE_FLOW_ITEM_TYPE_VF. */
465 static const struct rte_flow_item_vf rte_flow_item_vf_mask = {
471 * RTE_FLOW_ITEM_TYPE_PHY_PORT
473 * Matches traffic originating from (ingress) or going to (egress) a
474 * physical port of the underlying device.
476 * The first PHY_PORT item overrides the physical port normally associated
477 * with the specified DPDK input port (port_id). This item can be provided
478 * several times to match additional physical ports.
480 * Note that physical ports are not necessarily tied to DPDK input ports
481 * (port_id) when those are not under DPDK control. Possible values are
482 * specific to each device, they are not necessarily indexed from zero and
483 * may not be contiguous.
485 * As a device property, the list of allowed values as well as the value
486 * associated with a port_id should be retrieved by other means.
488 * A zeroed mask can be used to match any port index.
490 struct rte_flow_item_phy_port {
491 uint32_t index; /**< Physical port index. */
494 /** Default mask for RTE_FLOW_ITEM_TYPE_PHY_PORT. */
496 static const struct rte_flow_item_phy_port rte_flow_item_phy_port_mask = {
502 * RTE_FLOW_ITEM_TYPE_PORT_ID
504 * Matches traffic originating from (ingress) or going to (egress) a given
507 * Normally only supported if the port ID in question is known by the
508 * underlying PMD and related to the device the flow rule is created
511 * This must not be confused with @p PHY_PORT which refers to the physical
512 * port of a device, whereas @p PORT_ID refers to a struct rte_eth_dev
513 * object on the application side (also known as "port representor"
514 * depending on the kind of underlying device).
516 struct rte_flow_item_port_id {
517 uint32_t id; /**< DPDK port ID. */
520 /** Default mask for RTE_FLOW_ITEM_TYPE_PORT_ID. */
522 static const struct rte_flow_item_port_id rte_flow_item_port_id_mask = {
528 * RTE_FLOW_ITEM_TYPE_RAW
530 * Matches a byte string of a given length at a given offset.
532 * Offset is either absolute (using the start of the packet) or relative to
533 * the end of the previous matched item in the stack, in which case negative
534 * values are allowed.
536 * If search is enabled, offset is used as the starting point. The search
537 * area can be delimited by setting limit to a nonzero value, which is the
538 * maximum number of bytes after offset where the pattern may start.
540 * Matching a zero-length pattern is allowed, doing so resets the relative
541 * offset for subsequent items.
543 * This type does not support ranges (struct rte_flow_item.last).
545 struct rte_flow_item_raw {
546 uint32_t relative:1; /**< Look for pattern after the previous item. */
547 uint32_t search:1; /**< Search pattern from offset (see also limit). */
548 uint32_t reserved:30; /**< Reserved, must be set to zero. */
549 int32_t offset; /**< Absolute or relative offset for pattern. */
550 uint16_t limit; /**< Search area limit for start of pattern. */
551 uint16_t length; /**< Pattern length. */
552 const uint8_t *pattern; /**< Byte string to look for. */
555 /** Default mask for RTE_FLOW_ITEM_TYPE_RAW. */
557 static const struct rte_flow_item_raw rte_flow_item_raw_mask = {
560 .reserved = 0x3fffffff,
561 .offset = 0xffffffff,
569 * RTE_FLOW_ITEM_TYPE_ETH
571 * Matches an Ethernet header.
573 * The @p type field either stands for "EtherType" or "TPID" when followed
574 * by so-called layer 2.5 pattern items such as RTE_FLOW_ITEM_TYPE_VLAN. In
575 * the latter case, @p type refers to that of the outer header, with the
576 * inner EtherType/TPID provided by the subsequent pattern item. This is the
577 * same order as on the wire.
579 struct rte_flow_item_eth {
580 struct ether_addr dst; /**< Destination MAC. */
581 struct ether_addr src; /**< Source MAC. */
582 rte_be16_t type; /**< EtherType or TPID. */
585 /** Default mask for RTE_FLOW_ITEM_TYPE_ETH. */
587 static const struct rte_flow_item_eth rte_flow_item_eth_mask = {
588 .dst.addr_bytes = "\xff\xff\xff\xff\xff\xff",
589 .src.addr_bytes = "\xff\xff\xff\xff\xff\xff",
590 .type = RTE_BE16(0x0000),
595 * RTE_FLOW_ITEM_TYPE_VLAN
597 * Matches an 802.1Q/ad VLAN tag.
599 * The corresponding standard outer EtherType (TPID) values are
600 * ETHER_TYPE_VLAN or ETHER_TYPE_QINQ. It can be overridden by the preceding
603 struct rte_flow_item_vlan {
604 rte_be16_t tci; /**< Tag control information. */
605 rte_be16_t inner_type; /**< Inner EtherType or TPID. */
608 /** Default mask for RTE_FLOW_ITEM_TYPE_VLAN. */
610 static const struct rte_flow_item_vlan rte_flow_item_vlan_mask = {
611 .tci = RTE_BE16(0x0fff),
612 .inner_type = RTE_BE16(0x0000),
617 * RTE_FLOW_ITEM_TYPE_IPV4
619 * Matches an IPv4 header.
621 * Note: IPv4 options are handled by dedicated pattern items.
623 struct rte_flow_item_ipv4 {
624 struct ipv4_hdr hdr; /**< IPv4 header definition. */
627 /** Default mask for RTE_FLOW_ITEM_TYPE_IPV4. */
629 static const struct rte_flow_item_ipv4 rte_flow_item_ipv4_mask = {
631 .src_addr = RTE_BE32(0xffffffff),
632 .dst_addr = RTE_BE32(0xffffffff),
638 * RTE_FLOW_ITEM_TYPE_IPV6.
640 * Matches an IPv6 header.
642 * Note: IPv6 options are handled by dedicated pattern items, see
643 * RTE_FLOW_ITEM_TYPE_IPV6_EXT.
645 struct rte_flow_item_ipv6 {
646 struct ipv6_hdr hdr; /**< IPv6 header definition. */
649 /** Default mask for RTE_FLOW_ITEM_TYPE_IPV6. */
651 static const struct rte_flow_item_ipv6 rte_flow_item_ipv6_mask = {
654 "\xff\xff\xff\xff\xff\xff\xff\xff"
655 "\xff\xff\xff\xff\xff\xff\xff\xff",
657 "\xff\xff\xff\xff\xff\xff\xff\xff"
658 "\xff\xff\xff\xff\xff\xff\xff\xff",
664 * RTE_FLOW_ITEM_TYPE_ICMP.
666 * Matches an ICMP header.
668 struct rte_flow_item_icmp {
669 struct icmp_hdr hdr; /**< ICMP header definition. */
672 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP. */
674 static const struct rte_flow_item_icmp rte_flow_item_icmp_mask = {
683 * RTE_FLOW_ITEM_TYPE_UDP.
685 * Matches a UDP header.
687 struct rte_flow_item_udp {
688 struct udp_hdr hdr; /**< UDP header definition. */
691 /** Default mask for RTE_FLOW_ITEM_TYPE_UDP. */
693 static const struct rte_flow_item_udp rte_flow_item_udp_mask = {
695 .src_port = RTE_BE16(0xffff),
696 .dst_port = RTE_BE16(0xffff),
702 * RTE_FLOW_ITEM_TYPE_TCP.
704 * Matches a TCP header.
706 struct rte_flow_item_tcp {
707 struct tcp_hdr hdr; /**< TCP header definition. */
710 /** Default mask for RTE_FLOW_ITEM_TYPE_TCP. */
712 static const struct rte_flow_item_tcp rte_flow_item_tcp_mask = {
714 .src_port = RTE_BE16(0xffff),
715 .dst_port = RTE_BE16(0xffff),
721 * RTE_FLOW_ITEM_TYPE_SCTP.
723 * Matches a SCTP header.
725 struct rte_flow_item_sctp {
726 struct sctp_hdr hdr; /**< SCTP header definition. */
729 /** Default mask for RTE_FLOW_ITEM_TYPE_SCTP. */
731 static const struct rte_flow_item_sctp rte_flow_item_sctp_mask = {
733 .src_port = RTE_BE16(0xffff),
734 .dst_port = RTE_BE16(0xffff),
740 * RTE_FLOW_ITEM_TYPE_VXLAN.
742 * Matches a VXLAN header (RFC 7348).
744 struct rte_flow_item_vxlan {
745 uint8_t flags; /**< Normally 0x08 (I flag). */
746 uint8_t rsvd0[3]; /**< Reserved, normally 0x000000. */
747 uint8_t vni[3]; /**< VXLAN identifier. */
748 uint8_t rsvd1; /**< Reserved, normally 0x00. */
751 /** Default mask for RTE_FLOW_ITEM_TYPE_VXLAN. */
753 static const struct rte_flow_item_vxlan rte_flow_item_vxlan_mask = {
754 .vni = "\xff\xff\xff",
759 * RTE_FLOW_ITEM_TYPE_E_TAG.
761 * Matches a E-tag header.
763 * The corresponding standard outer EtherType (TPID) value is
764 * ETHER_TYPE_ETAG. It can be overridden by the preceding pattern item.
766 struct rte_flow_item_e_tag {
768 * E-Tag control information (E-TCI).
769 * E-PCP (3b), E-DEI (1b), ingress E-CID base (12b).
771 rte_be16_t epcp_edei_in_ecid_b;
772 /** Reserved (2b), GRP (2b), E-CID base (12b). */
773 rte_be16_t rsvd_grp_ecid_b;
774 uint8_t in_ecid_e; /**< Ingress E-CID ext. */
775 uint8_t ecid_e; /**< E-CID ext. */
776 rte_be16_t inner_type; /**< Inner EtherType or TPID. */
779 /** Default mask for RTE_FLOW_ITEM_TYPE_E_TAG. */
781 static const struct rte_flow_item_e_tag rte_flow_item_e_tag_mask = {
782 .rsvd_grp_ecid_b = RTE_BE16(0x3fff),
787 * RTE_FLOW_ITEM_TYPE_NVGRE.
789 * Matches a NVGRE header.
791 struct rte_flow_item_nvgre {
793 * Checksum (1b), undefined (1b), key bit (1b), sequence number (1b),
794 * reserved 0 (9b), version (3b).
796 * c_k_s_rsvd0_ver must have value 0x2000 according to RFC 7637.
798 rte_be16_t c_k_s_rsvd0_ver;
799 rte_be16_t protocol; /**< Protocol type (0x6558). */
800 uint8_t tni[3]; /**< Virtual subnet ID. */
801 uint8_t flow_id; /**< Flow ID. */
804 /** Default mask for RTE_FLOW_ITEM_TYPE_NVGRE. */
806 static const struct rte_flow_item_nvgre rte_flow_item_nvgre_mask = {
807 .tni = "\xff\xff\xff",
812 * RTE_FLOW_ITEM_TYPE_MPLS.
814 * Matches a MPLS header.
816 struct rte_flow_item_mpls {
818 * Label (20b), TC (3b), Bottom of Stack (1b).
820 uint8_t label_tc_s[3];
821 uint8_t ttl; /** Time-to-Live. */
824 /** Default mask for RTE_FLOW_ITEM_TYPE_MPLS. */
826 static const struct rte_flow_item_mpls rte_flow_item_mpls_mask = {
827 .label_tc_s = "\xff\xff\xf0",
832 * RTE_FLOW_ITEM_TYPE_GRE.
834 * Matches a GRE header.
836 struct rte_flow_item_gre {
838 * Checksum (1b), reserved 0 (12b), version (3b).
841 rte_be16_t c_rsvd0_ver;
842 rte_be16_t protocol; /**< Protocol type. */
845 /** Default mask for RTE_FLOW_ITEM_TYPE_GRE. */
847 static const struct rte_flow_item_gre rte_flow_item_gre_mask = {
848 .protocol = RTE_BE16(0xffff),
853 * RTE_FLOW_ITEM_TYPE_FUZZY
855 * Fuzzy pattern match, expect faster than default.
857 * This is for device that support fuzzy match option.
858 * Usually a fuzzy match is fast but the cost is accuracy.
859 * i.e. Signature Match only match pattern's hash value, but it is
860 * possible two different patterns have the same hash value.
862 * Matching accuracy level can be configure by threshold.
863 * Driver can divide the range of threshold and map to different
864 * accuracy levels that device support.
866 * Threshold 0 means perfect match (no fuzziness), while threshold
867 * 0xffffffff means fuzziest match.
869 struct rte_flow_item_fuzzy {
870 uint32_t thresh; /**< Accuracy threshold. */
873 /** Default mask for RTE_FLOW_ITEM_TYPE_FUZZY. */
875 static const struct rte_flow_item_fuzzy rte_flow_item_fuzzy_mask = {
876 .thresh = 0xffffffff,
881 * RTE_FLOW_ITEM_TYPE_GTP.
883 * Matches a GTPv1 header.
885 struct rte_flow_item_gtp {
887 * Version (3b), protocol type (1b), reserved (1b),
888 * Extension header flag (1b),
889 * Sequence number flag (1b),
890 * N-PDU number flag (1b).
892 uint8_t v_pt_rsv_flags;
893 uint8_t msg_type; /**< Message type. */
894 rte_be16_t msg_len; /**< Message length. */
895 rte_be32_t teid; /**< Tunnel endpoint identifier. */
898 /** Default mask for RTE_FLOW_ITEM_TYPE_GTP. */
900 static const struct rte_flow_item_gtp rte_flow_item_gtp_mask = {
901 .teid = RTE_BE32(0xffffffff),
906 * RTE_FLOW_ITEM_TYPE_ESP
908 * Matches an ESP header.
910 struct rte_flow_item_esp {
911 struct esp_hdr hdr; /**< ESP header definition. */
914 /** Default mask for RTE_FLOW_ITEM_TYPE_ESP. */
916 static const struct rte_flow_item_esp rte_flow_item_esp_mask = {
924 * RTE_FLOW_ITEM_TYPE_GENEVE.
926 * Matches a GENEVE header.
928 struct rte_flow_item_geneve {
930 * Version (2b), length of the options fields (6b), OAM packet (1b),
931 * critical options present (1b), reserved 0 (6b).
933 rte_be16_t ver_opt_len_o_c_rsvd0;
934 rte_be16_t protocol; /**< Protocol type. */
935 uint8_t vni[3]; /**< Virtual Network Identifier. */
936 uint8_t rsvd1; /**< Reserved, normally 0x00. */
939 /** Default mask for RTE_FLOW_ITEM_TYPE_GENEVE. */
941 static const struct rte_flow_item_geneve rte_flow_item_geneve_mask = {
942 .vni = "\xff\xff\xff",
947 * RTE_FLOW_ITEM_TYPE_VXLAN_GPE (draft-ietf-nvo3-vxlan-gpe-05).
949 * Matches a VXLAN-GPE header.
951 struct rte_flow_item_vxlan_gpe {
952 uint8_t flags; /**< Normally 0x0c (I and P flags). */
953 uint8_t rsvd0[2]; /**< Reserved, normally 0x0000. */
954 uint8_t protocol; /**< Protocol type. */
955 uint8_t vni[3]; /**< VXLAN identifier. */
956 uint8_t rsvd1; /**< Reserved, normally 0x00. */
959 /** Default mask for RTE_FLOW_ITEM_TYPE_VXLAN_GPE. */
961 static const struct rte_flow_item_vxlan_gpe rte_flow_item_vxlan_gpe_mask = {
962 .vni = "\xff\xff\xff",
967 * RTE_FLOW_ITEM_TYPE_ARP_ETH_IPV4
969 * Matches an ARP header for Ethernet/IPv4.
971 struct rte_flow_item_arp_eth_ipv4 {
972 rte_be16_t hrd; /**< Hardware type, normally 1. */
973 rte_be16_t pro; /**< Protocol type, normally 0x0800. */
974 uint8_t hln; /**< Hardware address length, normally 6. */
975 uint8_t pln; /**< Protocol address length, normally 4. */
976 rte_be16_t op; /**< Opcode (1 for request, 2 for reply). */
977 struct ether_addr sha; /**< Sender hardware address. */
978 rte_be32_t spa; /**< Sender IPv4 address. */
979 struct ether_addr tha; /**< Target hardware address. */
980 rte_be32_t tpa; /**< Target IPv4 address. */
983 /** Default mask for RTE_FLOW_ITEM_TYPE_ARP_ETH_IPV4. */
985 static const struct rte_flow_item_arp_eth_ipv4
986 rte_flow_item_arp_eth_ipv4_mask = {
987 .sha.addr_bytes = "\xff\xff\xff\xff\xff\xff",
988 .spa = RTE_BE32(0xffffffff),
989 .tha.addr_bytes = "\xff\xff\xff\xff\xff\xff",
990 .tpa = RTE_BE32(0xffffffff),
995 * RTE_FLOW_ITEM_TYPE_IPV6_EXT
997 * Matches the presence of any IPv6 extension header.
999 * Normally preceded by any of:
1001 * - RTE_FLOW_ITEM_TYPE_IPV6
1002 * - RTE_FLOW_ITEM_TYPE_IPV6_EXT
1004 struct rte_flow_item_ipv6_ext {
1005 uint8_t next_hdr; /**< Next header. */
1008 /** Default mask for RTE_FLOW_ITEM_TYPE_IPV6_EXT. */
1011 struct rte_flow_item_ipv6_ext rte_flow_item_ipv6_ext_mask = {
1017 * RTE_FLOW_ITEM_TYPE_ICMP6
1019 * Matches any ICMPv6 header.
1021 struct rte_flow_item_icmp6 {
1022 uint8_t type; /**< ICMPv6 type. */
1023 uint8_t code; /**< ICMPv6 code. */
1024 uint16_t checksum; /**< ICMPv6 checksum. */
1027 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6. */
1029 static const struct rte_flow_item_icmp6 rte_flow_item_icmp6_mask = {
1036 * RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS
1038 * Matches an ICMPv6 neighbor discovery solicitation.
1040 struct rte_flow_item_icmp6_nd_ns {
1041 uint8_t type; /**< ICMPv6 type, normally 135. */
1042 uint8_t code; /**< ICMPv6 code, normally 0. */
1043 rte_be16_t checksum; /**< ICMPv6 checksum. */
1044 rte_be32_t reserved; /**< Reserved, normally 0. */
1045 uint8_t target_addr[16]; /**< Target address. */
1048 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS. */
1051 struct rte_flow_item_icmp6_nd_ns rte_flow_item_icmp6_nd_ns_mask = {
1053 "\xff\xff\xff\xff\xff\xff\xff\xff"
1054 "\xff\xff\xff\xff\xff\xff\xff\xff",
1059 * RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA
1061 * Matches an ICMPv6 neighbor discovery advertisement.
1063 struct rte_flow_item_icmp6_nd_na {
1064 uint8_t type; /**< ICMPv6 type, normally 136. */
1065 uint8_t code; /**< ICMPv6 code, normally 0. */
1066 rte_be16_t checksum; /**< ICMPv6 checksum. */
1068 * Route flag (1b), solicited flag (1b), override flag (1b),
1071 rte_be32_t rso_reserved;
1072 uint8_t target_addr[16]; /**< Target address. */
1075 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA. */
1078 struct rte_flow_item_icmp6_nd_na rte_flow_item_icmp6_nd_na_mask = {
1080 "\xff\xff\xff\xff\xff\xff\xff\xff"
1081 "\xff\xff\xff\xff\xff\xff\xff\xff",
1086 * RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT
1088 * Matches the presence of any ICMPv6 neighbor discovery option.
1090 * Normally preceded by any of:
1092 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA
1093 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS
1094 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT
1096 struct rte_flow_item_icmp6_nd_opt {
1097 uint8_t type; /**< ND option type. */
1098 uint8_t length; /**< ND option length. */
1101 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT. */
1103 static const struct rte_flow_item_icmp6_nd_opt
1104 rte_flow_item_icmp6_nd_opt_mask = {
1110 * RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_SLA_ETH
1112 * Matches an ICMPv6 neighbor discovery source Ethernet link-layer address
1115 * Normally preceded by any of:
1117 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA
1118 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT
1120 struct rte_flow_item_icmp6_nd_opt_sla_eth {
1121 uint8_t type; /**< ND option type, normally 1. */
1122 uint8_t length; /**< ND option length, normally 1. */
1123 struct ether_addr sla; /**< Source Ethernet LLA. */
1126 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_SLA_ETH. */
1128 static const struct rte_flow_item_icmp6_nd_opt_sla_eth
1129 rte_flow_item_icmp6_nd_opt_sla_eth_mask = {
1130 .sla.addr_bytes = "\xff\xff\xff\xff\xff\xff",
1135 * RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_TLA_ETH
1137 * Matches an ICMPv6 neighbor discovery target Ethernet link-layer address
1140 * Normally preceded by any of:
1142 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS
1143 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT
1145 struct rte_flow_item_icmp6_nd_opt_tla_eth {
1146 uint8_t type; /**< ND option type, normally 2. */
1147 uint8_t length; /**< ND option length, normally 1. */
1148 struct ether_addr tla; /**< Target Ethernet LLA. */
1151 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_TLA_ETH. */
1153 static const struct rte_flow_item_icmp6_nd_opt_tla_eth
1154 rte_flow_item_icmp6_nd_opt_tla_eth_mask = {
1155 .tla.addr_bytes = "\xff\xff\xff\xff\xff\xff",
1161 * @b EXPERIMENTAL: this structure may change without prior notice
1163 * RTE_FLOW_ITEM_TYPE_MARK
1165 * Matches an arbitrary integer value which was set using the ``MARK`` action
1166 * in a previously matched rule.
1168 * This item can only be specified once as a match criteria as the ``MARK``
1169 * action can only be specified once in a flow action.
1171 * This value is arbitrary and application-defined. Maximum allowed value
1172 * depends on the underlying implementation.
1174 * Depending on the underlying implementation the MARK item may be supported on
1175 * the physical device, with virtual groups in the PMD or not at all.
1177 struct rte_flow_item_mark {
1178 uint32_t id; /**< Integer value to match against. */
1182 * Matching pattern item definition.
1184 * A pattern is formed by stacking items starting from the lowest protocol
1185 * layer to match. This stacking restriction does not apply to meta items
1186 * which can be placed anywhere in the stack without affecting the meaning
1187 * of the resulting pattern.
1189 * Patterns are terminated by END items.
1191 * The spec field should be a valid pointer to a structure of the related
1192 * item type. It may remain unspecified (NULL) in many cases to request
1193 * broad (nonspecific) matching. In such cases, last and mask must also be
1196 * Optionally, last can point to a structure of the same type to define an
1197 * inclusive range. This is mostly supported by integer and address fields,
1198 * may cause errors otherwise. Fields that do not support ranges must be set
1199 * to 0 or to the same value as the corresponding fields in spec.
1201 * Only the fields defined to nonzero values in the default masks (see
1202 * rte_flow_item_{name}_mask constants) are considered relevant by
1203 * default. This can be overridden by providing a mask structure of the
1204 * same type with applicable bits set to one. It can also be used to
1205 * partially filter out specific fields (e.g. as an alternate mean to match
1206 * ranges of IP addresses).
1208 * Mask is a simple bit-mask applied before interpreting the contents of
1209 * spec and last, which may yield unexpected results if not used
1210 * carefully. For example, if for an IPv4 address field, spec provides
1211 * 10.1.2.3, last provides 10.3.4.5 and mask provides 255.255.0.0, the
1212 * effective range becomes 10.1.0.0 to 10.3.255.255.
1214 struct rte_flow_item {
1215 enum rte_flow_item_type type; /**< Item type. */
1216 const void *spec; /**< Pointer to item specification structure. */
1217 const void *last; /**< Defines an inclusive range (spec to last). */
1218 const void *mask; /**< Bit-mask applied to spec and last. */
1224 * Each possible action is represented by a type. Some have associated
1225 * configuration structures. Several actions combined in a list can be
1226 * assigned to a flow rule and are performed in order.
1228 * They fall in three categories:
1230 * - Actions that modify the fate of matching traffic, for instance by
1231 * dropping or assigning it a specific destination.
1233 * - Actions that modify matching traffic contents or its properties. This
1234 * includes adding/removing encapsulation, encryption, compression and
1237 * - Actions related to the flow rule itself, such as updating counters or
1238 * making it non-terminating.
1240 * Flow rules being terminating by default, not specifying any action of the
1241 * fate kind results in undefined behavior. This applies to both ingress and
1244 * PASSTHRU, when supported, makes a flow rule non-terminating.
1246 enum rte_flow_action_type {
1248 * End marker for action lists. Prevents further processing of
1249 * actions, thereby ending the list.
1251 * No associated configuration structure.
1253 RTE_FLOW_ACTION_TYPE_END,
1256 * Used as a placeholder for convenience. It is ignored and simply
1257 * discarded by PMDs.
1259 * No associated configuration structure.
1261 RTE_FLOW_ACTION_TYPE_VOID,
1264 * Leaves traffic up for additional processing by subsequent flow
1265 * rules; makes a flow rule non-terminating.
1267 * No associated configuration structure.
1269 RTE_FLOW_ACTION_TYPE_PASSTHRU,
1272 * RTE_FLOW_ACTION_TYPE_JUMP
1274 * Redirects packets to a group on the current device.
1276 * See struct rte_flow_action_jump.
1278 RTE_FLOW_ACTION_TYPE_JUMP,
1281 * Attaches an integer value to packets and sets PKT_RX_FDIR and
1282 * PKT_RX_FDIR_ID mbuf flags.
1284 * See struct rte_flow_action_mark.
1286 RTE_FLOW_ACTION_TYPE_MARK,
1289 * Flags packets. Similar to MARK without a specific value; only
1290 * sets the PKT_RX_FDIR mbuf flag.
1292 * No associated configuration structure.
1294 RTE_FLOW_ACTION_TYPE_FLAG,
1297 * Assigns packets to a given queue index.
1299 * See struct rte_flow_action_queue.
1301 RTE_FLOW_ACTION_TYPE_QUEUE,
1306 * PASSTHRU overrides this action if both are specified.
1308 * No associated configuration structure.
1310 RTE_FLOW_ACTION_TYPE_DROP,
1313 * Enables counters for this flow rule.
1315 * These counters can be retrieved and reset through rte_flow_query(),
1316 * see struct rte_flow_query_count.
1318 * See struct rte_flow_action_count.
1320 RTE_FLOW_ACTION_TYPE_COUNT,
1323 * Similar to QUEUE, except RSS is additionally performed on packets
1324 * to spread them among several queues according to the provided
1327 * See struct rte_flow_action_rss.
1329 RTE_FLOW_ACTION_TYPE_RSS,
1332 * Directs matching traffic to the physical function (PF) of the
1335 * No associated configuration structure.
1337 RTE_FLOW_ACTION_TYPE_PF,
1340 * Directs matching traffic to a given virtual function of the
1343 * See struct rte_flow_action_vf.
1345 RTE_FLOW_ACTION_TYPE_VF,
1348 * Directs packets to a given physical port index of the underlying
1351 * See struct rte_flow_action_phy_port.
1353 RTE_FLOW_ACTION_TYPE_PHY_PORT,
1356 * Directs matching traffic to a given DPDK port ID.
1358 * See struct rte_flow_action_port_id.
1360 RTE_FLOW_ACTION_TYPE_PORT_ID,
1363 * Traffic metering and policing (MTR).
1365 * See struct rte_flow_action_meter.
1366 * See file rte_mtr.h for MTR object configuration.
1368 RTE_FLOW_ACTION_TYPE_METER,
1371 * Redirects packets to security engine of current device for security
1372 * processing as specified by security session.
1374 * See struct rte_flow_action_security.
1376 RTE_FLOW_ACTION_TYPE_SECURITY,
1379 * Implements OFPAT_SET_MPLS_TTL ("MPLS TTL") as defined by the
1380 * OpenFlow Switch Specification.
1382 * See struct rte_flow_action_of_set_mpls_ttl.
1384 RTE_FLOW_ACTION_TYPE_OF_SET_MPLS_TTL,
1387 * Implements OFPAT_DEC_MPLS_TTL ("decrement MPLS TTL") as defined
1388 * by the OpenFlow Switch Specification.
1390 * No associated configuration structure.
1392 RTE_FLOW_ACTION_TYPE_OF_DEC_MPLS_TTL,
1395 * Implements OFPAT_SET_NW_TTL ("IP TTL") as defined by the OpenFlow
1396 * Switch Specification.
1398 * See struct rte_flow_action_of_set_nw_ttl.
1400 RTE_FLOW_ACTION_TYPE_OF_SET_NW_TTL,
1403 * Implements OFPAT_DEC_NW_TTL ("decrement IP TTL") as defined by
1404 * the OpenFlow Switch Specification.
1406 * No associated configuration structure.
1408 RTE_FLOW_ACTION_TYPE_OF_DEC_NW_TTL,
1411 * Implements OFPAT_COPY_TTL_OUT ("copy TTL "outwards" -- from
1412 * next-to-outermost to outermost") as defined by the OpenFlow
1413 * Switch Specification.
1415 * No associated configuration structure.
1417 RTE_FLOW_ACTION_TYPE_OF_COPY_TTL_OUT,
1420 * Implements OFPAT_COPY_TTL_IN ("copy TTL "inwards" -- from
1421 * outermost to next-to-outermost") as defined by the OpenFlow
1422 * Switch Specification.
1424 * No associated configuration structure.
1426 RTE_FLOW_ACTION_TYPE_OF_COPY_TTL_IN,
1429 * Implements OFPAT_POP_VLAN ("pop the outer VLAN tag") as defined
1430 * by the OpenFlow Switch Specification.
1432 * No associated configuration structure.
1434 RTE_FLOW_ACTION_TYPE_OF_POP_VLAN,
1437 * Implements OFPAT_PUSH_VLAN ("push a new VLAN tag") as defined by
1438 * the OpenFlow Switch Specification.
1440 * See struct rte_flow_action_of_push_vlan.
1442 RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN,
1445 * Implements OFPAT_SET_VLAN_VID ("set the 802.1q VLAN id") as
1446 * defined by the OpenFlow Switch Specification.
1448 * See struct rte_flow_action_of_set_vlan_vid.
1450 RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID,
1453 * Implements OFPAT_SET_LAN_PCP ("set the 802.1q priority") as
1454 * defined by the OpenFlow Switch Specification.
1456 * See struct rte_flow_action_of_set_vlan_pcp.
1458 RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP,
1461 * Implements OFPAT_POP_MPLS ("pop the outer MPLS tag") as defined
1462 * by the OpenFlow Switch Specification.
1464 * See struct rte_flow_action_of_pop_mpls.
1466 RTE_FLOW_ACTION_TYPE_OF_POP_MPLS,
1469 * Implements OFPAT_PUSH_MPLS ("push a new MPLS tag") as defined by
1470 * the OpenFlow Switch Specification.
1472 * See struct rte_flow_action_of_push_mpls.
1474 RTE_FLOW_ACTION_TYPE_OF_PUSH_MPLS,
1477 * Encapsulate flow in VXLAN tunnel as defined in
1478 * rte_flow_action_vxlan_encap action structure.
1480 * See struct rte_flow_action_vxlan_encap.
1482 RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP,
1485 * Decapsulate outer most VXLAN tunnel from matched flow.
1487 * If flow pattern does not define a valid VXLAN tunnel (as specified by
1488 * RFC7348) then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION
1491 RTE_FLOW_ACTION_TYPE_VXLAN_DECAP,
1494 * Encapsulate flow in NVGRE tunnel defined in the
1495 * rte_flow_action_nvgre_encap action structure.
1497 * See struct rte_flow_action_nvgre_encap.
1499 RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP,
1502 * Decapsulate outer most NVGRE tunnel from matched flow.
1504 * If flow pattern does not define a valid NVGRE tunnel (as specified by
1505 * RFC7637) then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION
1508 RTE_FLOW_ACTION_TYPE_NVGRE_DECAP,
1511 * Modify IPv4 source address in the outermost IPv4 header.
1513 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV4,
1514 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
1516 * See struct rte_flow_action_set_ipv4.
1518 RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC,
1521 * Modify IPv4 destination address in the outermost IPv4 header.
1523 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV4,
1524 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
1526 * See struct rte_flow_action_set_ipv4.
1528 RTE_FLOW_ACTION_TYPE_SET_IPV4_DST,
1531 * Modify IPv6 source address in the outermost IPv6 header.
1533 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV6,
1534 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
1536 * See struct rte_flow_action_set_ipv6.
1538 RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC,
1541 * Modify IPv6 destination address in the outermost IPv6 header.
1543 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV6,
1544 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
1546 * See struct rte_flow_action_set_ipv6.
1548 RTE_FLOW_ACTION_TYPE_SET_IPV6_DST,
1551 * Modify source port number in the outermost TCP/UDP header.
1553 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_TCP
1554 * or RTE_FLOW_ITEM_TYPE_UDP, then the PMD should return a
1555 * RTE_FLOW_ERROR_TYPE_ACTION error.
1557 * See struct rte_flow_action_set_tp.
1559 RTE_FLOW_ACTION_TYPE_SET_TP_SRC,
1562 * Modify destination port number in the outermost TCP/UDP header.
1564 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_TCP
1565 * or RTE_FLOW_ITEM_TYPE_UDP, then the PMD should return a
1566 * RTE_FLOW_ERROR_TYPE_ACTION error.
1568 * See struct rte_flow_action_set_tp.
1570 RTE_FLOW_ACTION_TYPE_SET_TP_DST,
1573 * Swap the source and destination MAC addresses in the outermost
1576 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_ETH,
1577 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
1579 * No associated configuration structure.
1581 RTE_FLOW_ACTION_TYPE_MAC_SWAP,
1585 * RTE_FLOW_ACTION_TYPE_MARK
1587 * Attaches an integer value to packets and sets PKT_RX_FDIR and
1588 * PKT_RX_FDIR_ID mbuf flags.
1590 * This value is arbitrary and application-defined. Maximum allowed value
1591 * depends on the underlying implementation. It is returned in the
1592 * hash.fdir.hi mbuf field.
1594 struct rte_flow_action_mark {
1595 uint32_t id; /**< Integer value to return with packets. */
1600 * @b EXPERIMENTAL: this structure may change without prior notice
1602 * RTE_FLOW_ACTION_TYPE_JUMP
1604 * Redirects packets to a group on the current device.
1606 * In a hierarchy of groups, which can be used to represent physical or logical
1607 * flow tables on the device, this action allows the action to be a redirect to
1608 * a group on that device.
1610 struct rte_flow_action_jump {
1615 * RTE_FLOW_ACTION_TYPE_QUEUE
1617 * Assign packets to a given queue index.
1619 struct rte_flow_action_queue {
1620 uint16_t index; /**< Queue index to use. */
1626 * @b EXPERIMENTAL: this structure may change without prior notice
1628 * RTE_FLOW_ACTION_TYPE_COUNT
1630 * Adds a counter action to a matched flow.
1632 * If more than one count action is specified in a single flow rule, then each
1633 * action must specify a unique id.
1635 * Counters can be retrieved and reset through ``rte_flow_query()``, see
1636 * ``struct rte_flow_query_count``.
1638 * The shared flag indicates whether the counter is unique to the flow rule the
1639 * action is specified with, or whether it is a shared counter.
1641 * For a count action with the shared flag set, then then a global device
1642 * namespace is assumed for the counter id, so that any matched flow rules using
1643 * a count action with the same counter id on the same port will contribute to
1646 * For ports within the same switch domain then the counter id namespace extends
1647 * to all ports within that switch domain.
1649 struct rte_flow_action_count {
1650 uint32_t shared:1; /**< Share counter ID with other flow rules. */
1651 uint32_t reserved:31; /**< Reserved, must be zero. */
1652 uint32_t id; /**< Counter ID. */
1656 * RTE_FLOW_ACTION_TYPE_COUNT (query)
1658 * Query structure to retrieve and reset flow rule counters.
1660 struct rte_flow_query_count {
1661 uint32_t reset:1; /**< Reset counters after query [in]. */
1662 uint32_t hits_set:1; /**< hits field is set [out]. */
1663 uint32_t bytes_set:1; /**< bytes field is set [out]. */
1664 uint32_t reserved:29; /**< Reserved, must be zero [in, out]. */
1665 uint64_t hits; /**< Number of hits for this rule [out]. */
1666 uint64_t bytes; /**< Number of bytes through this rule [out]. */
1670 * RTE_FLOW_ACTION_TYPE_RSS
1672 * Similar to QUEUE, except RSS is additionally performed on packets to
1673 * spread them among several queues according to the provided parameters.
1675 * Unlike global RSS settings used by other DPDK APIs, unsetting the
1676 * @p types field does not disable RSS in a flow rule. Doing so instead
1677 * requests safe unspecified "best-effort" settings from the underlying PMD,
1678 * which depending on the flow rule, may result in anything ranging from
1679 * empty (single queue) to all-inclusive RSS.
1681 * Note: RSS hash result is stored in the hash.rss mbuf field which overlaps
1682 * hash.fdir.lo. Since the MARK action sets the hash.fdir.hi field only,
1683 * both can be requested simultaneously.
1685 struct rte_flow_action_rss {
1686 enum rte_eth_hash_function func; /**< RSS hash function to apply. */
1688 * Packet encapsulation level RSS hash @p types apply to.
1690 * - @p 0 requests the default behavior. Depending on the packet
1691 * type, it can mean outermost, innermost, anything in between or
1694 * It basically stands for the innermost encapsulation level RSS
1695 * can be performed on according to PMD and device capabilities.
1697 * - @p 1 requests RSS to be performed on the outermost packet
1698 * encapsulation level.
1700 * - @p 2 and subsequent values request RSS to be performed on the
1701 * specified inner packet encapsulation level, from outermost to
1702 * innermost (lower to higher values).
1704 * Values other than @p 0 are not necessarily supported.
1706 * Requesting a specific RSS level on unrecognized traffic results
1707 * in undefined behavior. For predictable results, it is recommended
1708 * to make the flow rule pattern match packet headers up to the
1709 * requested encapsulation level so that only matching traffic goes
1713 uint64_t types; /**< Specific RSS hash types (see ETH_RSS_*). */
1714 uint32_t key_len; /**< Hash key length in bytes. */
1715 uint32_t queue_num; /**< Number of entries in @p queue. */
1716 const uint8_t *key; /**< Hash key. */
1717 const uint16_t *queue; /**< Queue indices to use. */
1721 * RTE_FLOW_ACTION_TYPE_VF
1723 * Directs matching traffic to a given virtual function of the current
1726 * Packets matched by a VF pattern item can be redirected to their original
1727 * VF ID instead of the specified one. This parameter may not be available
1728 * and is not guaranteed to work properly if the VF part is matched by a
1729 * prior flow rule or if packets are not addressed to a VF in the first
1732 struct rte_flow_action_vf {
1733 uint32_t original:1; /**< Use original VF ID if possible. */
1734 uint32_t reserved:31; /**< Reserved, must be zero. */
1735 uint32_t id; /**< VF ID. */
1739 * RTE_FLOW_ACTION_TYPE_PHY_PORT
1741 * Directs packets to a given physical port index of the underlying
1744 * @see RTE_FLOW_ITEM_TYPE_PHY_PORT
1746 struct rte_flow_action_phy_port {
1747 uint32_t original:1; /**< Use original port index if possible. */
1748 uint32_t reserved:31; /**< Reserved, must be zero. */
1749 uint32_t index; /**< Physical port index. */
1753 * RTE_FLOW_ACTION_TYPE_PORT_ID
1755 * Directs matching traffic to a given DPDK port ID.
1757 * @see RTE_FLOW_ITEM_TYPE_PORT_ID
1759 struct rte_flow_action_port_id {
1760 uint32_t original:1; /**< Use original DPDK port ID if possible. */
1761 uint32_t reserved:31; /**< Reserved, must be zero. */
1762 uint32_t id; /**< DPDK port ID. */
1766 * RTE_FLOW_ACTION_TYPE_METER
1768 * Traffic metering and policing (MTR).
1770 * Packets matched by items of this type can be either dropped or passed to the
1771 * next item with their color set by the MTR object.
1773 struct rte_flow_action_meter {
1774 uint32_t mtr_id; /**< MTR object ID created with rte_mtr_create(). */
1778 * RTE_FLOW_ACTION_TYPE_SECURITY
1780 * Perform the security action on flows matched by the pattern items
1781 * according to the configuration of the security session.
1783 * This action modifies the payload of matched flows. For INLINE_CRYPTO, the
1784 * security protocol headers and IV are fully provided by the application as
1785 * specified in the flow pattern. The payload of matching packets is
1786 * encrypted on egress, and decrypted and authenticated on ingress.
1787 * For INLINE_PROTOCOL, the security protocol is fully offloaded to HW,
1788 * providing full encapsulation and decapsulation of packets in security
1789 * protocols. The flow pattern specifies both the outer security header fields
1790 * and the inner packet fields. The security session specified in the action
1791 * must match the pattern parameters.
1793 * The security session specified in the action must be created on the same
1794 * port as the flow action that is being specified.
1796 * The ingress/egress flow attribute should match that specified in the
1797 * security session if the security session supports the definition of the
1800 * Multiple flows can be configured to use the same security session.
1802 struct rte_flow_action_security {
1803 void *security_session; /**< Pointer to security session structure. */
1807 * RTE_FLOW_ACTION_TYPE_OF_SET_MPLS_TTL
1809 * Implements OFPAT_SET_MPLS_TTL ("MPLS TTL") as defined by the OpenFlow
1810 * Switch Specification.
1812 struct rte_flow_action_of_set_mpls_ttl {
1813 uint8_t mpls_ttl; /**< MPLS TTL. */
1817 * RTE_FLOW_ACTION_TYPE_OF_SET_NW_TTL
1819 * Implements OFPAT_SET_NW_TTL ("IP TTL") as defined by the OpenFlow Switch
1822 struct rte_flow_action_of_set_nw_ttl {
1823 uint8_t nw_ttl; /**< IP TTL. */
1827 * RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN
1829 * Implements OFPAT_PUSH_VLAN ("push a new VLAN tag") as defined by the
1830 * OpenFlow Switch Specification.
1832 struct rte_flow_action_of_push_vlan {
1833 rte_be16_t ethertype; /**< EtherType. */
1837 * RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID
1839 * Implements OFPAT_SET_VLAN_VID ("set the 802.1q VLAN id") as defined by
1840 * the OpenFlow Switch Specification.
1842 struct rte_flow_action_of_set_vlan_vid {
1843 rte_be16_t vlan_vid; /**< VLAN id. */
1847 * RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP
1849 * Implements OFPAT_SET_LAN_PCP ("set the 802.1q priority") as defined by
1850 * the OpenFlow Switch Specification.
1852 struct rte_flow_action_of_set_vlan_pcp {
1853 uint8_t vlan_pcp; /**< VLAN priority. */
1857 * RTE_FLOW_ACTION_TYPE_OF_POP_MPLS
1859 * Implements OFPAT_POP_MPLS ("pop the outer MPLS tag") as defined by the
1860 * OpenFlow Switch Specification.
1862 struct rte_flow_action_of_pop_mpls {
1863 rte_be16_t ethertype; /**< EtherType. */
1867 * RTE_FLOW_ACTION_TYPE_OF_PUSH_MPLS
1869 * Implements OFPAT_PUSH_MPLS ("push a new MPLS tag") as defined by the
1870 * OpenFlow Switch Specification.
1872 struct rte_flow_action_of_push_mpls {
1873 rte_be16_t ethertype; /**< EtherType. */
1878 * @b EXPERIMENTAL: this structure may change without prior notice
1880 * RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP
1882 * VXLAN tunnel end-point encapsulation data definition
1884 * The tunnel definition is provided through the flow item pattern, the
1885 * provided pattern must conform to RFC7348 for the tunnel specified. The flow
1886 * definition must be provided in order from the RTE_FLOW_ITEM_TYPE_ETH
1887 * definition up the end item which is specified by RTE_FLOW_ITEM_TYPE_END.
1889 * The mask field allows user to specify which fields in the flow item
1890 * definitions can be ignored and which have valid data and can be used
1893 * Note: the last field is not used in the definition of a tunnel and can be
1896 * Valid flow definition for RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP include:
1898 * - ETH / IPV4 / UDP / VXLAN / END
1899 * - ETH / IPV6 / UDP / VXLAN / END
1900 * - ETH / VLAN / IPV4 / UDP / VXLAN / END
1903 struct rte_flow_action_vxlan_encap {
1905 * Encapsulating vxlan tunnel definition
1906 * (terminated by the END pattern item).
1908 struct rte_flow_item *definition;
1913 * @b EXPERIMENTAL: this structure may change without prior notice
1915 * RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP
1917 * NVGRE tunnel end-point encapsulation data definition
1919 * The tunnel definition is provided through the flow item pattern the
1920 * provided pattern must conform with RFC7637. The flow definition must be
1921 * provided in order from the RTE_FLOW_ITEM_TYPE_ETH definition up the end item
1922 * which is specified by RTE_FLOW_ITEM_TYPE_END.
1924 * The mask field allows user to specify which fields in the flow item
1925 * definitions can be ignored and which have valid data and can be used
1928 * Note: the last field is not used in the definition of a tunnel and can be
1931 * Valid flow definition for RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP include:
1933 * - ETH / IPV4 / NVGRE / END
1934 * - ETH / VLAN / IPV6 / NVGRE / END
1937 struct rte_flow_action_nvgre_encap {
1939 * Encapsulating vxlan tunnel definition
1940 * (terminated by the END pattern item).
1942 struct rte_flow_item *definition;
1947 * @b EXPERIMENTAL: this structure may change without prior notice
1949 * RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC
1950 * RTE_FLOW_ACTION_TYPE_SET_IPV4_DST
1952 * Allows modification of IPv4 source (RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC)
1953 * and destination address (RTE_FLOW_ACTION_TYPE_SET_IPV4_DST) in the
1954 * specified outermost IPv4 header.
1956 struct rte_flow_action_set_ipv4 {
1957 rte_be32_t ipv4_addr;
1962 * @b EXPERIMENTAL: this structure may change without prior notice
1964 * RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC
1965 * RTE_FLOW_ACTION_TYPE_SET_IPV6_DST
1967 * Allows modification of IPv6 source (RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC)
1968 * and destination address (RTE_FLOW_ACTION_TYPE_SET_IPV6_DST) in the
1969 * specified outermost IPv6 header.
1971 struct rte_flow_action_set_ipv6 {
1972 uint8_t ipv6_addr[16];
1977 * @b EXPERIMENTAL: this structure may change without prior notice
1979 * RTE_FLOW_ACTION_TYPE_SET_TP_SRC
1980 * RTE_FLOW_ACTION_TYPE_SET_TP_DST
1982 * Allows modification of source (RTE_FLOW_ACTION_TYPE_SET_TP_SRC)
1983 * and destination (RTE_FLOW_ACTION_TYPE_SET_TP_DST) port numbers
1984 * in the specified outermost TCP/UDP header.
1986 struct rte_flow_action_set_tp {
1991 * Definition of a single action.
1993 * A list of actions is terminated by a END action.
1995 * For simple actions without a configuration structure, conf remains NULL.
1997 struct rte_flow_action {
1998 enum rte_flow_action_type type; /**< Action type. */
1999 const void *conf; /**< Pointer to action configuration structure. */
2003 * Opaque type returned after successfully creating a flow.
2005 * This handle can be used to manage and query the related flow (e.g. to
2006 * destroy it or retrieve counters).
2011 * Verbose error types.
2013 * Most of them provide the type of the object referenced by struct
2014 * rte_flow_error.cause.
2016 enum rte_flow_error_type {
2017 RTE_FLOW_ERROR_TYPE_NONE, /**< No error. */
2018 RTE_FLOW_ERROR_TYPE_UNSPECIFIED, /**< Cause unspecified. */
2019 RTE_FLOW_ERROR_TYPE_HANDLE, /**< Flow rule (handle). */
2020 RTE_FLOW_ERROR_TYPE_ATTR_GROUP, /**< Group field. */
2021 RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY, /**< Priority field. */
2022 RTE_FLOW_ERROR_TYPE_ATTR_INGRESS, /**< Ingress field. */
2023 RTE_FLOW_ERROR_TYPE_ATTR_EGRESS, /**< Egress field. */
2024 RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, /**< Transfer field. */
2025 RTE_FLOW_ERROR_TYPE_ATTR, /**< Attributes structure. */
2026 RTE_FLOW_ERROR_TYPE_ITEM_NUM, /**< Pattern length. */
2027 RTE_FLOW_ERROR_TYPE_ITEM_SPEC, /**< Item specification. */
2028 RTE_FLOW_ERROR_TYPE_ITEM_LAST, /**< Item specification range. */
2029 RTE_FLOW_ERROR_TYPE_ITEM_MASK, /**< Item specification mask. */
2030 RTE_FLOW_ERROR_TYPE_ITEM, /**< Specific pattern item. */
2031 RTE_FLOW_ERROR_TYPE_ACTION_NUM, /**< Number of actions. */
2032 RTE_FLOW_ERROR_TYPE_ACTION_CONF, /**< Action configuration. */
2033 RTE_FLOW_ERROR_TYPE_ACTION, /**< Specific action. */
2037 * Verbose error structure definition.
2039 * This object is normally allocated by applications and set by PMDs, the
2040 * message points to a constant string which does not need to be freed by
2041 * the application, however its pointer can be considered valid only as long
2042 * as its associated DPDK port remains configured. Closing the underlying
2043 * device or unloading the PMD invalidates it.
2045 * Both cause and message may be NULL regardless of the error type.
2047 struct rte_flow_error {
2048 enum rte_flow_error_type type; /**< Cause field and error types. */
2049 const void *cause; /**< Object responsible for the error. */
2050 const char *message; /**< Human-readable error message. */
2054 * Complete flow rule description.
2056 * This object type is used when converting a flow rule description.
2058 * @see RTE_FLOW_CONV_OP_RULE
2059 * @see rte_flow_conv()
2062 struct rte_flow_conv_rule {
2064 const struct rte_flow_attr *attr_ro; /**< RO attributes. */
2065 struct rte_flow_attr *attr; /**< Attributes. */
2068 const struct rte_flow_item *pattern_ro; /**< RO pattern. */
2069 struct rte_flow_item *pattern; /**< Pattern items. */
2072 const struct rte_flow_action *actions_ro; /**< RO actions. */
2073 struct rte_flow_action *actions; /**< List of actions. */
2078 * Conversion operations for flow API objects.
2080 * @see rte_flow_conv()
2082 enum rte_flow_conv_op {
2084 * No operation to perform.
2086 * rte_flow_conv() simply returns 0.
2088 RTE_FLOW_CONV_OP_NONE,
2091 * Convert attributes structure.
2093 * This is a basic copy of an attributes structure.
2096 * @code const struct rte_flow_attr * @endcode
2098 * @code struct rte_flow_attr * @endcode
2100 RTE_FLOW_CONV_OP_ATTR,
2103 * Convert a single item.
2105 * Duplicates @p spec, @p last and @p mask but not outside objects.
2108 * @code const struct rte_flow_item * @endcode
2110 * @code struct rte_flow_item * @endcode
2112 RTE_FLOW_CONV_OP_ITEM,
2115 * Convert a single action.
2117 * Duplicates @p conf but not outside objects.
2120 * @code const struct rte_flow_action * @endcode
2122 * @code struct rte_flow_action * @endcode
2124 RTE_FLOW_CONV_OP_ACTION,
2127 * Convert an entire pattern.
2129 * Duplicates all pattern items at once with the same constraints as
2130 * RTE_FLOW_CONV_OP_ITEM.
2133 * @code const struct rte_flow_item * @endcode
2135 * @code struct rte_flow_item * @endcode
2137 RTE_FLOW_CONV_OP_PATTERN,
2140 * Convert a list of actions.
2142 * Duplicates the entire list of actions at once with the same
2143 * constraints as RTE_FLOW_CONV_OP_ACTION.
2146 * @code const struct rte_flow_action * @endcode
2148 * @code struct rte_flow_action * @endcode
2150 RTE_FLOW_CONV_OP_ACTIONS,
2153 * Convert a complete flow rule description.
2155 * Comprises attributes, pattern and actions together at once with
2156 * the usual constraints.
2159 * @code const struct rte_flow_conv_rule * @endcode
2161 * @code struct rte_flow_conv_rule * @endcode
2163 RTE_FLOW_CONV_OP_RULE,
2166 * Convert item type to its name string.
2168 * Writes a NUL-terminated string to @p dst. Like snprintf(), the
2169 * returned value excludes the terminator which is always written
2173 * @code (const void *)enum rte_flow_item_type @endcode
2175 * @code char * @endcode
2177 RTE_FLOW_CONV_OP_ITEM_NAME,
2180 * Convert action type to its name string.
2182 * Writes a NUL-terminated string to @p dst. Like snprintf(), the
2183 * returned value excludes the terminator which is always written
2187 * @code (const void *)enum rte_flow_action_type @endcode
2189 * @code char * @endcode
2191 RTE_FLOW_CONV_OP_ACTION_NAME,
2194 * Convert item type to pointer to item name.
2196 * Retrieves item name pointer from its type. The string itself is
2197 * not copied; instead, a unique pointer to an internal static
2198 * constant storage is written to @p dst.
2201 * @code (const void *)enum rte_flow_item_type @endcode
2203 * @code const char ** @endcode
2205 RTE_FLOW_CONV_OP_ITEM_NAME_PTR,
2208 * Convert action type to pointer to action name.
2210 * Retrieves action name pointer from its type. The string itself is
2211 * not copied; instead, a unique pointer to an internal static
2212 * constant storage is written to @p dst.
2215 * @code (const void *)enum rte_flow_action_type @endcode
2217 * @code const char ** @endcode
2219 RTE_FLOW_CONV_OP_ACTION_NAME_PTR,
2223 * Check whether a flow rule can be created on a given port.
2225 * The flow rule is validated for correctness and whether it could be accepted
2226 * by the device given sufficient resources. The rule is checked against the
2227 * current device mode and queue configuration. The flow rule may also
2228 * optionally be validated against existing flow rules and device resources.
2229 * This function has no effect on the target device.
2231 * The returned value is guaranteed to remain valid only as long as no
2232 * successful calls to rte_flow_create() or rte_flow_destroy() are made in
2233 * the meantime and no device parameter affecting flow rules in any way are
2234 * modified, due to possible collisions or resource limitations (although in
2235 * such cases EINVAL should not be returned).
2238 * Port identifier of Ethernet device.
2240 * Flow rule attributes.
2241 * @param[in] pattern
2242 * Pattern specification (list terminated by the END pattern item).
2243 * @param[in] actions
2244 * Associated actions (list terminated by the END action).
2246 * Perform verbose error reporting if not NULL. PMDs initialize this
2247 * structure in case of error only.
2250 * 0 if flow rule is valid and can be created. A negative errno value
2251 * otherwise (rte_errno is also set), the following errors are defined:
2253 * -ENOSYS: underlying device does not support this functionality.
2255 * -EIO: underlying device is removed.
2257 * -EINVAL: unknown or invalid rule specification.
2259 * -ENOTSUP: valid but unsupported rule specification (e.g. partial
2260 * bit-masks are unsupported).
2262 * -EEXIST: collision with an existing rule. Only returned if device
2263 * supports flow rule collision checking and there was a flow rule
2264 * collision. Not receiving this return code is no guarantee that creating
2265 * the rule will not fail due to a collision.
2267 * -ENOMEM: not enough memory to execute the function, or if the device
2268 * supports resource validation, resource limitation on the device.
2270 * -EBUSY: action cannot be performed due to busy device resources, may
2271 * succeed if the affected queues or even the entire port are in a stopped
2272 * state (see rte_eth_dev_rx_queue_stop() and rte_eth_dev_stop()).
2275 rte_flow_validate(uint16_t port_id,
2276 const struct rte_flow_attr *attr,
2277 const struct rte_flow_item pattern[],
2278 const struct rte_flow_action actions[],
2279 struct rte_flow_error *error);
2282 * Create a flow rule on a given port.
2285 * Port identifier of Ethernet device.
2287 * Flow rule attributes.
2288 * @param[in] pattern
2289 * Pattern specification (list terminated by the END pattern item).
2290 * @param[in] actions
2291 * Associated actions (list terminated by the END action).
2293 * Perform verbose error reporting if not NULL. PMDs initialize this
2294 * structure in case of error only.
2297 * A valid handle in case of success, NULL otherwise and rte_errno is set
2298 * to the positive version of one of the error codes defined for
2299 * rte_flow_validate().
2302 rte_flow_create(uint16_t port_id,
2303 const struct rte_flow_attr *attr,
2304 const struct rte_flow_item pattern[],
2305 const struct rte_flow_action actions[],
2306 struct rte_flow_error *error);
2309 * Destroy a flow rule on a given port.
2311 * Failure to destroy a flow rule handle may occur when other flow rules
2312 * depend on it, and destroying it would result in an inconsistent state.
2314 * This function is only guaranteed to succeed if handles are destroyed in
2315 * reverse order of their creation.
2318 * Port identifier of Ethernet device.
2320 * Flow rule handle to destroy.
2322 * Perform verbose error reporting if not NULL. PMDs initialize this
2323 * structure in case of error only.
2326 * 0 on success, a negative errno value otherwise and rte_errno is set.
2329 rte_flow_destroy(uint16_t port_id,
2330 struct rte_flow *flow,
2331 struct rte_flow_error *error);
2334 * Destroy all flow rules associated with a port.
2336 * In the unlikely event of failure, handles are still considered destroyed
2337 * and no longer valid but the port must be assumed to be in an inconsistent
2341 * Port identifier of Ethernet device.
2343 * Perform verbose error reporting if not NULL. PMDs initialize this
2344 * structure in case of error only.
2347 * 0 on success, a negative errno value otherwise and rte_errno is set.
2350 rte_flow_flush(uint16_t port_id,
2351 struct rte_flow_error *error);
2354 * Query an existing flow rule.
2356 * This function allows retrieving flow-specific data such as counters.
2357 * Data is gathered by special actions which must be present in the flow
2360 * \see RTE_FLOW_ACTION_TYPE_COUNT
2363 * Port identifier of Ethernet device.
2365 * Flow rule handle to query.
2367 * Action definition as defined in original flow rule.
2368 * @param[in, out] data
2369 * Pointer to storage for the associated query data type.
2371 * Perform verbose error reporting if not NULL. PMDs initialize this
2372 * structure in case of error only.
2375 * 0 on success, a negative errno value otherwise and rte_errno is set.
2378 rte_flow_query(uint16_t port_id,
2379 struct rte_flow *flow,
2380 const struct rte_flow_action *action,
2382 struct rte_flow_error *error);
2385 * Restrict ingress traffic to the defined flow rules.
2387 * Isolated mode guarantees that all ingress traffic comes from defined flow
2388 * rules only (current and future).
2390 * Besides making ingress more deterministic, it allows PMDs to safely reuse
2391 * resources otherwise assigned to handle the remaining traffic, such as
2392 * global RSS configuration settings, VLAN filters, MAC address entries,
2393 * legacy filter API rules and so on in order to expand the set of possible
2396 * Calling this function as soon as possible after device initialization,
2397 * ideally before the first call to rte_eth_dev_configure(), is recommended
2398 * to avoid possible failures due to conflicting settings.
2400 * Once effective, leaving isolated mode may not be possible depending on
2401 * PMD implementation.
2403 * Additionally, the following functionality has no effect on the underlying
2404 * port and may return errors such as ENOTSUP ("not supported"):
2406 * - Toggling promiscuous mode.
2407 * - Toggling allmulticast mode.
2408 * - Configuring MAC addresses.
2409 * - Configuring multicast addresses.
2410 * - Configuring VLAN filters.
2411 * - Configuring Rx filters through the legacy API (e.g. FDIR).
2412 * - Configuring global RSS settings.
2415 * Port identifier of Ethernet device.
2417 * Nonzero to enter isolated mode, attempt to leave it otherwise.
2419 * Perform verbose error reporting if not NULL. PMDs initialize this
2420 * structure in case of error only.
2423 * 0 on success, a negative errno value otherwise and rte_errno is set.
2426 rte_flow_isolate(uint16_t port_id, int set, struct rte_flow_error *error);
2429 * Initialize flow error structure.
2432 * Pointer to flow error structure (may be NULL).
2434 * Related error code (rte_errno).
2436 * Cause field and error types.
2438 * Object responsible for the error.
2440 * Human-readable error message.
2443 * Negative error code (errno value) and rte_errno is set.
2446 rte_flow_error_set(struct rte_flow_error *error,
2448 enum rte_flow_error_type type,
2450 const char *message);
2454 * @see rte_flow_copy()
2456 struct rte_flow_desc {
2457 size_t size; /**< Allocated space including data[]. */
2458 struct rte_flow_attr attr; /**< Attributes. */
2459 struct rte_flow_item *items; /**< Items. */
2460 struct rte_flow_action *actions; /**< Actions. */
2461 uint8_t data[]; /**< Storage for items/actions. */
2466 * Copy an rte_flow rule description.
2468 * This interface is kept for compatibility with older applications but is
2469 * implemented as a wrapper to rte_flow_conv(). It is deprecated due to its
2470 * lack of flexibility and reliance on a type unusable with C++ programs
2471 * (struct rte_flow_desc).
2474 * Flow rule description.
2476 * Total size of allocated data for the flow description.
2478 * Flow rule attributes.
2480 * Pattern specification (list terminated by the END pattern item).
2481 * @param[in] actions
2482 * Associated actions (list terminated by the END action).
2485 * If len is greater or equal to the size of the flow, the total size of the
2486 * flow description and its data.
2487 * If len is lower than the size of the flow, the number of bytes that would
2488 * have been written to desc had it been sufficient. Nothing is written.
2492 rte_flow_copy(struct rte_flow_desc *fd, size_t len,
2493 const struct rte_flow_attr *attr,
2494 const struct rte_flow_item *items,
2495 const struct rte_flow_action *actions);
2498 * Flow object conversion helper.
2500 * This function performs conversion of various flow API objects to a
2501 * pre-allocated destination buffer. See enum rte_flow_conv_op for possible
2502 * operations and details about each of them.
2504 * Since destination buffer must be large enough, it works in a manner
2505 * reminiscent of snprintf():
2507 * - If @p size is 0, @p dst may be a NULL pointer, otherwise @p dst must be
2509 * - If positive, the returned value represents the number of bytes needed
2510 * to store the conversion of @p src to @p dst according to @p op
2511 * regardless of the @p size parameter.
2512 * - Since no more than @p size bytes can be written to @p dst, output is
2513 * truncated and may be inconsistent when the returned value is larger
2515 * - In case of conversion error, a negative error code is returned and
2516 * @p dst contents are unspecified.
2519 * Operation to perform, related to the object type of @p dst.
2521 * Destination buffer address. Must be suitably aligned by the caller.
2523 * Destination buffer size in bytes.
2525 * Source object to copy. Depending on @p op, its type may differ from
2528 * Perform verbose error reporting if not NULL. Initialized in case of
2532 * The number of bytes required to convert @p src to @p dst on success, a
2533 * negative errno value otherwise and rte_errno is set.
2535 * @see rte_flow_conv_op
2539 rte_flow_conv(enum rte_flow_conv_op op,
2543 struct rte_flow_error *error);
2549 #endif /* RTE_FLOW_H_ */