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>
30 #include <rte_higig.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,
421 * Matches a metadata value specified in mbuf metadata field.
422 * See struct rte_flow_item_meta.
424 RTE_FLOW_ITEM_TYPE_META,
427 * Matches a GRE optional key field.
429 * The value should a big-endian 32bit integer.
431 * When this item present the K bit is implicitly matched as "1"
432 * in the default mask.
435 * @code rte_be32_t * @endcode
437 RTE_FLOW_ITEM_TYPE_GRE_KEY,
440 * Matches a GTP extension header: PDU session container.
442 * Configure flow for GTP packets with extension header type 0x85.
444 * See struct rte_flow_item_gtp_psc.
446 RTE_FLOW_ITEM_TYPE_GTP_PSC,
449 * Matches a PPPoE header.
451 * Configure flow for PPPoE session packets.
453 * See struct rte_flow_item_pppoe.
455 RTE_FLOW_ITEM_TYPE_PPPOES,
458 * Matches a PPPoE header.
460 * Configure flow for PPPoE discovery packets.
462 * See struct rte_flow_item_pppoe.
464 RTE_FLOW_ITEM_TYPE_PPPOED,
467 * Matches a PPPoE optional proto_id field.
469 * It only applies to PPPoE session packets.
471 * See struct rte_flow_item_pppoe_proto_id.
473 RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID,
476 * Matches Network service header (NSH).
477 * See struct rte_flow_item_nsh.
480 RTE_FLOW_ITEM_TYPE_NSH,
483 * Matches Internet Group Management Protocol (IGMP).
484 * See struct rte_flow_item_igmp.
487 RTE_FLOW_ITEM_TYPE_IGMP,
490 * Matches IP Authentication Header (AH).
491 * See struct rte_flow_item_ah.
494 RTE_FLOW_ITEM_TYPE_AH,
497 * Matches a HIGIG header.
498 * see struct rte_flow_item_higig2_hdr.
500 RTE_FLOW_ITEM_TYPE_HIGIG2,
505 * Matches a tag value.
507 * See struct rte_flow_item_tag.
509 RTE_FLOW_ITEM_TYPE_TAG,
514 * RTE_FLOW_ITEM_TYPE_HIGIG2
515 * Matches higig2 header
518 struct rte_flow_item_higig2_hdr {
519 struct rte_higig2_hdr hdr;
522 /** Default mask for RTE_FLOW_ITEM_TYPE_HIGIG2. */
524 static const struct rte_flow_item_higig2_hdr rte_flow_item_higig2_hdr_mask = {
527 .classification = 0xffff,
535 * RTE_FLOW_ITEM_TYPE_ANY
537 * Matches any protocol in place of the current layer, a single ANY may also
538 * stand for several protocol layers.
540 * This is usually specified as the first pattern item when looking for a
541 * protocol anywhere in a packet.
543 * A zeroed mask stands for any number of layers.
545 struct rte_flow_item_any {
546 uint32_t num; /**< Number of layers covered. */
549 /** Default mask for RTE_FLOW_ITEM_TYPE_ANY. */
551 static const struct rte_flow_item_any rte_flow_item_any_mask = {
557 * RTE_FLOW_ITEM_TYPE_VF
559 * Matches traffic originating from (ingress) or going to (egress) a given
560 * virtual function of the current device.
562 * If supported, should work even if the virtual function is not managed by
563 * the application and thus not associated with a DPDK port ID.
565 * Note this pattern item does not match VF representors traffic which, as
566 * separate entities, should be addressed through their own DPDK port IDs.
568 * - Can be specified multiple times to match traffic addressed to several
570 * - Can be combined with a PF item to match both PF and VF traffic.
572 * A zeroed mask can be used to match any VF ID.
574 struct rte_flow_item_vf {
575 uint32_t id; /**< VF ID. */
578 /** Default mask for RTE_FLOW_ITEM_TYPE_VF. */
580 static const struct rte_flow_item_vf rte_flow_item_vf_mask = {
586 * RTE_FLOW_ITEM_TYPE_PHY_PORT
588 * Matches traffic originating from (ingress) or going to (egress) a
589 * physical port of the underlying device.
591 * The first PHY_PORT item overrides the physical port normally associated
592 * with the specified DPDK input port (port_id). This item can be provided
593 * several times to match additional physical ports.
595 * Note that physical ports are not necessarily tied to DPDK input ports
596 * (port_id) when those are not under DPDK control. Possible values are
597 * specific to each device, they are not necessarily indexed from zero and
598 * may not be contiguous.
600 * As a device property, the list of allowed values as well as the value
601 * associated with a port_id should be retrieved by other means.
603 * A zeroed mask can be used to match any port index.
605 struct rte_flow_item_phy_port {
606 uint32_t index; /**< Physical port index. */
609 /** Default mask for RTE_FLOW_ITEM_TYPE_PHY_PORT. */
611 static const struct rte_flow_item_phy_port rte_flow_item_phy_port_mask = {
617 * RTE_FLOW_ITEM_TYPE_PORT_ID
619 * Matches traffic originating from (ingress) or going to (egress) a given
622 * Normally only supported if the port ID in question is known by the
623 * underlying PMD and related to the device the flow rule is created
626 * This must not be confused with @p PHY_PORT which refers to the physical
627 * port of a device, whereas @p PORT_ID refers to a struct rte_eth_dev
628 * object on the application side (also known as "port representor"
629 * depending on the kind of underlying device).
631 struct rte_flow_item_port_id {
632 uint32_t id; /**< DPDK port ID. */
635 /** Default mask for RTE_FLOW_ITEM_TYPE_PORT_ID. */
637 static const struct rte_flow_item_port_id rte_flow_item_port_id_mask = {
643 * RTE_FLOW_ITEM_TYPE_RAW
645 * Matches a byte string of a given length at a given offset.
647 * Offset is either absolute (using the start of the packet) or relative to
648 * the end of the previous matched item in the stack, in which case negative
649 * values are allowed.
651 * If search is enabled, offset is used as the starting point. The search
652 * area can be delimited by setting limit to a nonzero value, which is the
653 * maximum number of bytes after offset where the pattern may start.
655 * Matching a zero-length pattern is allowed, doing so resets the relative
656 * offset for subsequent items.
658 * This type does not support ranges (struct rte_flow_item.last).
660 struct rte_flow_item_raw {
661 uint32_t relative:1; /**< Look for pattern after the previous item. */
662 uint32_t search:1; /**< Search pattern from offset (see also limit). */
663 uint32_t reserved:30; /**< Reserved, must be set to zero. */
664 int32_t offset; /**< Absolute or relative offset for pattern. */
665 uint16_t limit; /**< Search area limit for start of pattern. */
666 uint16_t length; /**< Pattern length. */
667 const uint8_t *pattern; /**< Byte string to look for. */
670 /** Default mask for RTE_FLOW_ITEM_TYPE_RAW. */
672 static const struct rte_flow_item_raw rte_flow_item_raw_mask = {
675 .reserved = 0x3fffffff,
676 .offset = 0xffffffff,
684 * RTE_FLOW_ITEM_TYPE_ETH
686 * Matches an Ethernet header.
688 * The @p type field either stands for "EtherType" or "TPID" when followed
689 * by so-called layer 2.5 pattern items such as RTE_FLOW_ITEM_TYPE_VLAN. In
690 * the latter case, @p type refers to that of the outer header, with the
691 * inner EtherType/TPID provided by the subsequent pattern item. This is the
692 * same order as on the wire.
694 struct rte_flow_item_eth {
695 struct rte_ether_addr dst; /**< Destination MAC. */
696 struct rte_ether_addr src; /**< Source MAC. */
697 rte_be16_t type; /**< EtherType or TPID. */
700 /** Default mask for RTE_FLOW_ITEM_TYPE_ETH. */
702 static const struct rte_flow_item_eth rte_flow_item_eth_mask = {
703 .dst.addr_bytes = "\xff\xff\xff\xff\xff\xff",
704 .src.addr_bytes = "\xff\xff\xff\xff\xff\xff",
705 .type = RTE_BE16(0x0000),
710 * RTE_FLOW_ITEM_TYPE_VLAN
712 * Matches an 802.1Q/ad VLAN tag.
714 * The corresponding standard outer EtherType (TPID) values are
715 * RTE_ETHER_TYPE_VLAN or RTE_ETHER_TYPE_QINQ. It can be overridden by
716 * the preceding pattern item.
718 struct rte_flow_item_vlan {
719 rte_be16_t tci; /**< Tag control information. */
720 rte_be16_t inner_type; /**< Inner EtherType or TPID. */
723 /** Default mask for RTE_FLOW_ITEM_TYPE_VLAN. */
725 static const struct rte_flow_item_vlan rte_flow_item_vlan_mask = {
726 .tci = RTE_BE16(0x0fff),
727 .inner_type = RTE_BE16(0x0000),
732 * RTE_FLOW_ITEM_TYPE_IPV4
734 * Matches an IPv4 header.
736 * Note: IPv4 options are handled by dedicated pattern items.
738 struct rte_flow_item_ipv4 {
739 struct rte_ipv4_hdr hdr; /**< IPv4 header definition. */
742 /** Default mask for RTE_FLOW_ITEM_TYPE_IPV4. */
744 static const struct rte_flow_item_ipv4 rte_flow_item_ipv4_mask = {
746 .src_addr = RTE_BE32(0xffffffff),
747 .dst_addr = RTE_BE32(0xffffffff),
753 * RTE_FLOW_ITEM_TYPE_IPV6.
755 * Matches an IPv6 header.
757 * Note: IPv6 options are handled by dedicated pattern items, see
758 * RTE_FLOW_ITEM_TYPE_IPV6_EXT.
760 struct rte_flow_item_ipv6 {
761 struct rte_ipv6_hdr hdr; /**< IPv6 header definition. */
764 /** Default mask for RTE_FLOW_ITEM_TYPE_IPV6. */
766 static const struct rte_flow_item_ipv6 rte_flow_item_ipv6_mask = {
769 "\xff\xff\xff\xff\xff\xff\xff\xff"
770 "\xff\xff\xff\xff\xff\xff\xff\xff",
772 "\xff\xff\xff\xff\xff\xff\xff\xff"
773 "\xff\xff\xff\xff\xff\xff\xff\xff",
779 * RTE_FLOW_ITEM_TYPE_ICMP.
781 * Matches an ICMP header.
783 struct rte_flow_item_icmp {
784 struct rte_icmp_hdr hdr; /**< ICMP header definition. */
787 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP. */
789 static const struct rte_flow_item_icmp rte_flow_item_icmp_mask = {
798 * RTE_FLOW_ITEM_TYPE_UDP.
800 * Matches a UDP header.
802 struct rte_flow_item_udp {
803 struct rte_udp_hdr hdr; /**< UDP header definition. */
806 /** Default mask for RTE_FLOW_ITEM_TYPE_UDP. */
808 static const struct rte_flow_item_udp rte_flow_item_udp_mask = {
810 .src_port = RTE_BE16(0xffff),
811 .dst_port = RTE_BE16(0xffff),
817 * RTE_FLOW_ITEM_TYPE_TCP.
819 * Matches a TCP header.
821 struct rte_flow_item_tcp {
822 struct rte_tcp_hdr hdr; /**< TCP header definition. */
825 /** Default mask for RTE_FLOW_ITEM_TYPE_TCP. */
827 static const struct rte_flow_item_tcp rte_flow_item_tcp_mask = {
829 .src_port = RTE_BE16(0xffff),
830 .dst_port = RTE_BE16(0xffff),
836 * RTE_FLOW_ITEM_TYPE_SCTP.
838 * Matches a SCTP header.
840 struct rte_flow_item_sctp {
841 struct rte_sctp_hdr hdr; /**< SCTP header definition. */
844 /** Default mask for RTE_FLOW_ITEM_TYPE_SCTP. */
846 static const struct rte_flow_item_sctp rte_flow_item_sctp_mask = {
848 .src_port = RTE_BE16(0xffff),
849 .dst_port = RTE_BE16(0xffff),
855 * RTE_FLOW_ITEM_TYPE_VXLAN.
857 * Matches a VXLAN header (RFC 7348).
859 struct rte_flow_item_vxlan {
860 uint8_t flags; /**< Normally 0x08 (I flag). */
861 uint8_t rsvd0[3]; /**< Reserved, normally 0x000000. */
862 uint8_t vni[3]; /**< VXLAN identifier. */
863 uint8_t rsvd1; /**< Reserved, normally 0x00. */
866 /** Default mask for RTE_FLOW_ITEM_TYPE_VXLAN. */
868 static const struct rte_flow_item_vxlan rte_flow_item_vxlan_mask = {
869 .vni = "\xff\xff\xff",
874 * RTE_FLOW_ITEM_TYPE_E_TAG.
876 * Matches a E-tag header.
878 * The corresponding standard outer EtherType (TPID) value is
879 * RTE_ETHER_TYPE_ETAG. It can be overridden by the preceding pattern item.
881 struct rte_flow_item_e_tag {
883 * E-Tag control information (E-TCI).
884 * E-PCP (3b), E-DEI (1b), ingress E-CID base (12b).
886 rte_be16_t epcp_edei_in_ecid_b;
887 /** Reserved (2b), GRP (2b), E-CID base (12b). */
888 rte_be16_t rsvd_grp_ecid_b;
889 uint8_t in_ecid_e; /**< Ingress E-CID ext. */
890 uint8_t ecid_e; /**< E-CID ext. */
891 rte_be16_t inner_type; /**< Inner EtherType or TPID. */
894 /** Default mask for RTE_FLOW_ITEM_TYPE_E_TAG. */
896 static const struct rte_flow_item_e_tag rte_flow_item_e_tag_mask = {
897 .rsvd_grp_ecid_b = RTE_BE16(0x3fff),
902 * RTE_FLOW_ITEM_TYPE_NVGRE.
904 * Matches a NVGRE header.
906 struct rte_flow_item_nvgre {
908 * Checksum (1b), undefined (1b), key bit (1b), sequence number (1b),
909 * reserved 0 (9b), version (3b).
911 * c_k_s_rsvd0_ver must have value 0x2000 according to RFC 7637.
913 rte_be16_t c_k_s_rsvd0_ver;
914 rte_be16_t protocol; /**< Protocol type (0x6558). */
915 uint8_t tni[3]; /**< Virtual subnet ID. */
916 uint8_t flow_id; /**< Flow ID. */
919 /** Default mask for RTE_FLOW_ITEM_TYPE_NVGRE. */
921 static const struct rte_flow_item_nvgre rte_flow_item_nvgre_mask = {
922 .tni = "\xff\xff\xff",
927 * RTE_FLOW_ITEM_TYPE_MPLS.
929 * Matches a MPLS header.
931 struct rte_flow_item_mpls {
933 * Label (20b), TC (3b), Bottom of Stack (1b).
935 uint8_t label_tc_s[3];
936 uint8_t ttl; /** Time-to-Live. */
939 /** Default mask for RTE_FLOW_ITEM_TYPE_MPLS. */
941 static const struct rte_flow_item_mpls rte_flow_item_mpls_mask = {
942 .label_tc_s = "\xff\xff\xf0",
947 * RTE_FLOW_ITEM_TYPE_GRE.
949 * Matches a GRE header.
951 struct rte_flow_item_gre {
953 * Checksum (1b), reserved 0 (12b), version (3b).
956 rte_be16_t c_rsvd0_ver;
957 rte_be16_t protocol; /**< Protocol type. */
960 /** Default mask for RTE_FLOW_ITEM_TYPE_GRE. */
962 static const struct rte_flow_item_gre rte_flow_item_gre_mask = {
963 .protocol = RTE_BE16(0xffff),
968 * RTE_FLOW_ITEM_TYPE_FUZZY
970 * Fuzzy pattern match, expect faster than default.
972 * This is for device that support fuzzy match option.
973 * Usually a fuzzy match is fast but the cost is accuracy.
974 * i.e. Signature Match only match pattern's hash value, but it is
975 * possible two different patterns have the same hash value.
977 * Matching accuracy level can be configure by threshold.
978 * Driver can divide the range of threshold and map to different
979 * accuracy levels that device support.
981 * Threshold 0 means perfect match (no fuzziness), while threshold
982 * 0xffffffff means fuzziest match.
984 struct rte_flow_item_fuzzy {
985 uint32_t thresh; /**< Accuracy threshold. */
988 /** Default mask for RTE_FLOW_ITEM_TYPE_FUZZY. */
990 static const struct rte_flow_item_fuzzy rte_flow_item_fuzzy_mask = {
991 .thresh = 0xffffffff,
996 * RTE_FLOW_ITEM_TYPE_GTP.
998 * Matches a GTPv1 header.
1000 struct rte_flow_item_gtp {
1002 * Version (3b), protocol type (1b), reserved (1b),
1003 * Extension header flag (1b),
1004 * Sequence number flag (1b),
1005 * N-PDU number flag (1b).
1007 uint8_t v_pt_rsv_flags;
1008 uint8_t msg_type; /**< Message type. */
1009 rte_be16_t msg_len; /**< Message length. */
1010 rte_be32_t teid; /**< Tunnel endpoint identifier. */
1013 /** Default mask for RTE_FLOW_ITEM_TYPE_GTP. */
1015 static const struct rte_flow_item_gtp rte_flow_item_gtp_mask = {
1016 .teid = RTE_BE32(0xffffffff),
1021 * RTE_FLOW_ITEM_TYPE_ESP
1023 * Matches an ESP header.
1025 struct rte_flow_item_esp {
1026 struct rte_esp_hdr hdr; /**< ESP header definition. */
1029 /** Default mask for RTE_FLOW_ITEM_TYPE_ESP. */
1031 static const struct rte_flow_item_esp rte_flow_item_esp_mask = {
1033 .spi = RTE_BE32(0xffffffff),
1039 * RTE_FLOW_ITEM_TYPE_GENEVE.
1041 * Matches a GENEVE header.
1043 struct rte_flow_item_geneve {
1045 * Version (2b), length of the options fields (6b), OAM packet (1b),
1046 * critical options present (1b), reserved 0 (6b).
1048 rte_be16_t ver_opt_len_o_c_rsvd0;
1049 rte_be16_t protocol; /**< Protocol type. */
1050 uint8_t vni[3]; /**< Virtual Network Identifier. */
1051 uint8_t rsvd1; /**< Reserved, normally 0x00. */
1054 /** Default mask for RTE_FLOW_ITEM_TYPE_GENEVE. */
1056 static const struct rte_flow_item_geneve rte_flow_item_geneve_mask = {
1057 .vni = "\xff\xff\xff",
1062 * RTE_FLOW_ITEM_TYPE_VXLAN_GPE (draft-ietf-nvo3-vxlan-gpe-05).
1064 * Matches a VXLAN-GPE header.
1066 struct rte_flow_item_vxlan_gpe {
1067 uint8_t flags; /**< Normally 0x0c (I and P flags). */
1068 uint8_t rsvd0[2]; /**< Reserved, normally 0x0000. */
1069 uint8_t protocol; /**< Protocol type. */
1070 uint8_t vni[3]; /**< VXLAN identifier. */
1071 uint8_t rsvd1; /**< Reserved, normally 0x00. */
1074 /** Default mask for RTE_FLOW_ITEM_TYPE_VXLAN_GPE. */
1076 static const struct rte_flow_item_vxlan_gpe rte_flow_item_vxlan_gpe_mask = {
1077 .vni = "\xff\xff\xff",
1082 * RTE_FLOW_ITEM_TYPE_ARP_ETH_IPV4
1084 * Matches an ARP header for Ethernet/IPv4.
1086 struct rte_flow_item_arp_eth_ipv4 {
1087 rte_be16_t hrd; /**< Hardware type, normally 1. */
1088 rte_be16_t pro; /**< Protocol type, normally 0x0800. */
1089 uint8_t hln; /**< Hardware address length, normally 6. */
1090 uint8_t pln; /**< Protocol address length, normally 4. */
1091 rte_be16_t op; /**< Opcode (1 for request, 2 for reply). */
1092 struct rte_ether_addr sha; /**< Sender hardware address. */
1093 rte_be32_t spa; /**< Sender IPv4 address. */
1094 struct rte_ether_addr tha; /**< Target hardware address. */
1095 rte_be32_t tpa; /**< Target IPv4 address. */
1098 /** Default mask for RTE_FLOW_ITEM_TYPE_ARP_ETH_IPV4. */
1100 static const struct rte_flow_item_arp_eth_ipv4
1101 rte_flow_item_arp_eth_ipv4_mask = {
1102 .sha.addr_bytes = "\xff\xff\xff\xff\xff\xff",
1103 .spa = RTE_BE32(0xffffffff),
1104 .tha.addr_bytes = "\xff\xff\xff\xff\xff\xff",
1105 .tpa = RTE_BE32(0xffffffff),
1110 * RTE_FLOW_ITEM_TYPE_IPV6_EXT
1112 * Matches the presence of any IPv6 extension header.
1114 * Normally preceded by any of:
1116 * - RTE_FLOW_ITEM_TYPE_IPV6
1117 * - RTE_FLOW_ITEM_TYPE_IPV6_EXT
1119 struct rte_flow_item_ipv6_ext {
1120 uint8_t next_hdr; /**< Next header. */
1123 /** Default mask for RTE_FLOW_ITEM_TYPE_IPV6_EXT. */
1126 struct rte_flow_item_ipv6_ext rte_flow_item_ipv6_ext_mask = {
1132 * RTE_FLOW_ITEM_TYPE_ICMP6
1134 * Matches any ICMPv6 header.
1136 struct rte_flow_item_icmp6 {
1137 uint8_t type; /**< ICMPv6 type. */
1138 uint8_t code; /**< ICMPv6 code. */
1139 uint16_t checksum; /**< ICMPv6 checksum. */
1142 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6. */
1144 static const struct rte_flow_item_icmp6 rte_flow_item_icmp6_mask = {
1151 * RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS
1153 * Matches an ICMPv6 neighbor discovery solicitation.
1155 struct rte_flow_item_icmp6_nd_ns {
1156 uint8_t type; /**< ICMPv6 type, normally 135. */
1157 uint8_t code; /**< ICMPv6 code, normally 0. */
1158 rte_be16_t checksum; /**< ICMPv6 checksum. */
1159 rte_be32_t reserved; /**< Reserved, normally 0. */
1160 uint8_t target_addr[16]; /**< Target address. */
1163 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS. */
1166 struct rte_flow_item_icmp6_nd_ns rte_flow_item_icmp6_nd_ns_mask = {
1168 "\xff\xff\xff\xff\xff\xff\xff\xff"
1169 "\xff\xff\xff\xff\xff\xff\xff\xff",
1174 * RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA
1176 * Matches an ICMPv6 neighbor discovery advertisement.
1178 struct rte_flow_item_icmp6_nd_na {
1179 uint8_t type; /**< ICMPv6 type, normally 136. */
1180 uint8_t code; /**< ICMPv6 code, normally 0. */
1181 rte_be16_t checksum; /**< ICMPv6 checksum. */
1183 * Route flag (1b), solicited flag (1b), override flag (1b),
1186 rte_be32_t rso_reserved;
1187 uint8_t target_addr[16]; /**< Target address. */
1190 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA. */
1193 struct rte_flow_item_icmp6_nd_na rte_flow_item_icmp6_nd_na_mask = {
1195 "\xff\xff\xff\xff\xff\xff\xff\xff"
1196 "\xff\xff\xff\xff\xff\xff\xff\xff",
1201 * RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT
1203 * Matches the presence of any ICMPv6 neighbor discovery option.
1205 * Normally preceded by any of:
1207 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA
1208 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS
1209 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT
1211 struct rte_flow_item_icmp6_nd_opt {
1212 uint8_t type; /**< ND option type. */
1213 uint8_t length; /**< ND option length. */
1216 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT. */
1218 static const struct rte_flow_item_icmp6_nd_opt
1219 rte_flow_item_icmp6_nd_opt_mask = {
1225 * RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_SLA_ETH
1227 * Matches an ICMPv6 neighbor discovery source Ethernet link-layer address
1230 * Normally preceded by any of:
1232 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA
1233 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT
1235 struct rte_flow_item_icmp6_nd_opt_sla_eth {
1236 uint8_t type; /**< ND option type, normally 1. */
1237 uint8_t length; /**< ND option length, normally 1. */
1238 struct rte_ether_addr sla; /**< Source Ethernet LLA. */
1241 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_SLA_ETH. */
1243 static const struct rte_flow_item_icmp6_nd_opt_sla_eth
1244 rte_flow_item_icmp6_nd_opt_sla_eth_mask = {
1245 .sla.addr_bytes = "\xff\xff\xff\xff\xff\xff",
1250 * RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_TLA_ETH
1252 * Matches an ICMPv6 neighbor discovery target Ethernet link-layer address
1255 * Normally preceded by any of:
1257 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS
1258 * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT
1260 struct rte_flow_item_icmp6_nd_opt_tla_eth {
1261 uint8_t type; /**< ND option type, normally 2. */
1262 uint8_t length; /**< ND option length, normally 1. */
1263 struct rte_ether_addr tla; /**< Target Ethernet LLA. */
1266 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_TLA_ETH. */
1268 static const struct rte_flow_item_icmp6_nd_opt_tla_eth
1269 rte_flow_item_icmp6_nd_opt_tla_eth_mask = {
1270 .tla.addr_bytes = "\xff\xff\xff\xff\xff\xff",
1275 * RTE_FLOW_ITEM_TYPE_META.
1277 * Matches a specified metadata value.
1279 struct rte_flow_item_meta {
1283 /** Default mask for RTE_FLOW_ITEM_TYPE_META. */
1285 static const struct rte_flow_item_meta rte_flow_item_meta_mask = {
1286 .data = RTE_BE32(UINT32_MAX),
1291 * RTE_FLOW_ITEM_TYPE_GTP_PSC.
1293 * Matches a GTP PDU extension header with type 0x85.
1295 struct rte_flow_item_gtp_psc {
1296 uint8_t pdu_type; /**< PDU type. */
1297 uint8_t qfi; /**< QoS flow identifier. */
1300 /** Default mask for RTE_FLOW_ITEM_TYPE_GTP_PSC. */
1302 static const struct rte_flow_item_gtp_psc
1303 rte_flow_item_gtp_psc_mask = {
1309 * RTE_FLOW_ITEM_TYPE_PPPOE.
1311 * Matches a PPPoE header.
1313 struct rte_flow_item_pppoe {
1315 * Version (4b), type (4b).
1317 uint8_t version_type;
1318 uint8_t code; /**< Message type. */
1319 rte_be16_t session_id; /**< Session identifier. */
1320 rte_be16_t length; /**< Payload length. */
1324 * RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID.
1326 * Matches a PPPoE optional proto_id field.
1328 * It only applies to PPPoE session packets.
1330 * Normally preceded by any of:
1332 * - RTE_FLOW_ITEM_TYPE_PPPOE
1333 * - RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID
1335 struct rte_flow_item_pppoe_proto_id {
1336 rte_be16_t proto_id; /**< PPP protocol identifier. */
1339 /** Default mask for RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID. */
1341 static const struct rte_flow_item_pppoe_proto_id
1342 rte_flow_item_pppoe_proto_id_mask = {
1343 .proto_id = RTE_BE16(0xffff),
1349 * @b EXPERIMENTAL: this structure may change without prior notice
1351 * RTE_FLOW_ITEM_TYPE_TAG
1353 * Matches a specified tag value at the specified index.
1355 struct rte_flow_item_tag {
1360 /** Default mask for RTE_FLOW_ITEM_TYPE_TAG. */
1362 static const struct rte_flow_item_tag rte_flow_item_tag_mask = {
1370 * @b EXPERIMENTAL: this structure may change without prior notice
1372 * RTE_FLOW_ITEM_TYPE_MARK
1374 * Matches an arbitrary integer value which was set using the ``MARK`` action
1375 * in a previously matched rule.
1377 * This item can only be specified once as a match criteria as the ``MARK``
1378 * action can only be specified once in a flow action.
1380 * This value is arbitrary and application-defined. Maximum allowed value
1381 * depends on the underlying implementation.
1383 * Depending on the underlying implementation the MARK item may be supported on
1384 * the physical device, with virtual groups in the PMD or not at all.
1386 struct rte_flow_item_mark {
1387 uint32_t id; /**< Integer value to match against. */
1390 /** Default mask for RTE_FLOW_ITEM_TYPE_MARK. */
1392 static const struct rte_flow_item_mark rte_flow_item_mark_mask = {
1399 * @b EXPERIMENTAL: this structure may change without prior notice
1401 * RTE_FLOW_ITEM_TYPE_NSH
1403 * Match network service header (NSH), RFC 8300
1406 struct rte_flow_item_nsh {
1409 uint32_t reserved:1;
1412 uint32_t reserved1:4;
1414 uint32_t next_proto:8;
1419 /** Default mask for RTE_FLOW_ITEM_TYPE_NSH. */
1421 static const struct rte_flow_item_nsh rte_flow_item_nsh_mask = {
1431 * @b EXPERIMENTAL: this structure may change without prior notice
1433 * RTE_FLOW_ITEM_TYPE_IGMP
1435 * Match Internet Group Management Protocol (IGMP), RFC 2236
1438 struct rte_flow_item_igmp {
1440 uint32_t max_resp_time:8;
1441 uint32_t checksum:16;
1442 uint32_t group_addr;
1445 /** Default mask for RTE_FLOW_ITEM_TYPE_IGMP. */
1447 static const struct rte_flow_item_igmp rte_flow_item_igmp_mask = {
1448 .group_addr = 0xffffffff,
1454 * @b EXPERIMENTAL: this structure may change without prior notice
1456 * RTE_FLOW_ITEM_TYPE_AH
1458 * Match IP Authentication Header (AH), RFC 4302
1461 struct rte_flow_item_ah {
1462 uint32_t next_hdr:8;
1463 uint32_t payload_len:8;
1464 uint32_t reserved:16;
1469 /** Default mask for RTE_FLOW_ITEM_TYPE_AH. */
1471 static const struct rte_flow_item_ah rte_flow_item_ah_mask = {
1477 * Matching pattern item definition.
1479 * A pattern is formed by stacking items starting from the lowest protocol
1480 * layer to match. This stacking restriction does not apply to meta items
1481 * which can be placed anywhere in the stack without affecting the meaning
1482 * of the resulting pattern.
1484 * Patterns are terminated by END items.
1486 * The spec field should be a valid pointer to a structure of the related
1487 * item type. It may remain unspecified (NULL) in many cases to request
1488 * broad (nonspecific) matching. In such cases, last and mask must also be
1491 * Optionally, last can point to a structure of the same type to define an
1492 * inclusive range. This is mostly supported by integer and address fields,
1493 * may cause errors otherwise. Fields that do not support ranges must be set
1494 * to 0 or to the same value as the corresponding fields in spec.
1496 * Only the fields defined to nonzero values in the default masks (see
1497 * rte_flow_item_{name}_mask constants) are considered relevant by
1498 * default. This can be overridden by providing a mask structure of the
1499 * same type with applicable bits set to one. It can also be used to
1500 * partially filter out specific fields (e.g. as an alternate mean to match
1501 * ranges of IP addresses).
1503 * Mask is a simple bit-mask applied before interpreting the contents of
1504 * spec and last, which may yield unexpected results if not used
1505 * carefully. For example, if for an IPv4 address field, spec provides
1506 * 10.1.2.3, last provides 10.3.4.5 and mask provides 255.255.0.0, the
1507 * effective range becomes 10.1.0.0 to 10.3.255.255.
1509 struct rte_flow_item {
1510 enum rte_flow_item_type type; /**< Item type. */
1511 const void *spec; /**< Pointer to item specification structure. */
1512 const void *last; /**< Defines an inclusive range (spec to last). */
1513 const void *mask; /**< Bit-mask applied to spec and last. */
1519 * Each possible action is represented by a type.
1520 * An action can have an associated configuration object.
1521 * Several actions combined in a list can be assigned
1522 * to a flow rule and are performed in order.
1524 * They fall in three categories:
1526 * - Actions that modify the fate of matching traffic, for instance by
1527 * dropping or assigning it a specific destination.
1529 * - Actions that modify matching traffic contents or its properties. This
1530 * includes adding/removing encapsulation, encryption, compression and
1533 * - Actions related to the flow rule itself, such as updating counters or
1534 * making it non-terminating.
1536 * Flow rules being terminating by default, not specifying any action of the
1537 * fate kind results in undefined behavior. This applies to both ingress and
1540 * PASSTHRU, when supported, makes a flow rule non-terminating.
1542 enum rte_flow_action_type {
1544 * End marker for action lists. Prevents further processing of
1545 * actions, thereby ending the list.
1547 * No associated configuration structure.
1549 RTE_FLOW_ACTION_TYPE_END,
1552 * Used as a placeholder for convenience. It is ignored and simply
1553 * discarded by PMDs.
1555 * No associated configuration structure.
1557 RTE_FLOW_ACTION_TYPE_VOID,
1560 * Leaves traffic up for additional processing by subsequent flow
1561 * rules; makes a flow rule non-terminating.
1563 * No associated configuration structure.
1565 RTE_FLOW_ACTION_TYPE_PASSTHRU,
1568 * RTE_FLOW_ACTION_TYPE_JUMP
1570 * Redirects packets to a group on the current device.
1572 * See struct rte_flow_action_jump.
1574 RTE_FLOW_ACTION_TYPE_JUMP,
1577 * Attaches an integer value to packets and sets PKT_RX_FDIR and
1578 * PKT_RX_FDIR_ID mbuf flags.
1580 * See struct rte_flow_action_mark.
1582 RTE_FLOW_ACTION_TYPE_MARK,
1585 * Flags packets. Similar to MARK without a specific value; only
1586 * sets the PKT_RX_FDIR mbuf flag.
1588 * No associated configuration structure.
1590 RTE_FLOW_ACTION_TYPE_FLAG,
1593 * Assigns packets to a given queue index.
1595 * See struct rte_flow_action_queue.
1597 RTE_FLOW_ACTION_TYPE_QUEUE,
1602 * PASSTHRU overrides this action if both are specified.
1604 * No associated configuration structure.
1606 RTE_FLOW_ACTION_TYPE_DROP,
1609 * Enables counters for this flow rule.
1611 * These counters can be retrieved and reset through rte_flow_query(),
1612 * see struct rte_flow_query_count.
1614 * See struct rte_flow_action_count.
1616 RTE_FLOW_ACTION_TYPE_COUNT,
1619 * Similar to QUEUE, except RSS is additionally performed on packets
1620 * to spread them among several queues according to the provided
1623 * See struct rte_flow_action_rss.
1625 RTE_FLOW_ACTION_TYPE_RSS,
1628 * Directs matching traffic to the physical function (PF) of the
1631 * No associated configuration structure.
1633 RTE_FLOW_ACTION_TYPE_PF,
1636 * Directs matching traffic to a given virtual function of the
1639 * See struct rte_flow_action_vf.
1641 RTE_FLOW_ACTION_TYPE_VF,
1644 * Directs packets to a given physical port index of the underlying
1647 * See struct rte_flow_action_phy_port.
1649 RTE_FLOW_ACTION_TYPE_PHY_PORT,
1652 * Directs matching traffic to a given DPDK port ID.
1654 * See struct rte_flow_action_port_id.
1656 RTE_FLOW_ACTION_TYPE_PORT_ID,
1659 * Traffic metering and policing (MTR).
1661 * See struct rte_flow_action_meter.
1662 * See file rte_mtr.h for MTR object configuration.
1664 RTE_FLOW_ACTION_TYPE_METER,
1667 * Redirects packets to security engine of current device for security
1668 * processing as specified by security session.
1670 * See struct rte_flow_action_security.
1672 RTE_FLOW_ACTION_TYPE_SECURITY,
1675 * Implements OFPAT_SET_MPLS_TTL ("MPLS TTL") as defined by the
1676 * OpenFlow Switch Specification.
1678 * See struct rte_flow_action_of_set_mpls_ttl.
1680 RTE_FLOW_ACTION_TYPE_OF_SET_MPLS_TTL,
1683 * Implements OFPAT_DEC_MPLS_TTL ("decrement MPLS TTL") as defined
1684 * by the OpenFlow Switch Specification.
1686 * No associated configuration structure.
1688 RTE_FLOW_ACTION_TYPE_OF_DEC_MPLS_TTL,
1691 * Implements OFPAT_SET_NW_TTL ("IP TTL") as defined by the OpenFlow
1692 * Switch Specification.
1694 * See struct rte_flow_action_of_set_nw_ttl.
1696 RTE_FLOW_ACTION_TYPE_OF_SET_NW_TTL,
1699 * Implements OFPAT_DEC_NW_TTL ("decrement IP TTL") as defined by
1700 * the OpenFlow Switch Specification.
1702 * No associated configuration structure.
1704 RTE_FLOW_ACTION_TYPE_OF_DEC_NW_TTL,
1707 * Implements OFPAT_COPY_TTL_OUT ("copy TTL "outwards" -- from
1708 * next-to-outermost to outermost") as defined by the OpenFlow
1709 * Switch Specification.
1711 * No associated configuration structure.
1713 RTE_FLOW_ACTION_TYPE_OF_COPY_TTL_OUT,
1716 * Implements OFPAT_COPY_TTL_IN ("copy TTL "inwards" -- from
1717 * outermost to next-to-outermost") as defined by the OpenFlow
1718 * Switch Specification.
1720 * No associated configuration structure.
1722 RTE_FLOW_ACTION_TYPE_OF_COPY_TTL_IN,
1725 * Implements OFPAT_POP_VLAN ("pop the outer VLAN tag") as defined
1726 * by the OpenFlow Switch Specification.
1728 * No associated configuration structure.
1730 RTE_FLOW_ACTION_TYPE_OF_POP_VLAN,
1733 * Implements OFPAT_PUSH_VLAN ("push a new VLAN tag") as defined by
1734 * the OpenFlow Switch Specification.
1736 * See struct rte_flow_action_of_push_vlan.
1738 RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN,
1741 * Implements OFPAT_SET_VLAN_VID ("set the 802.1q VLAN id") as
1742 * defined by the OpenFlow Switch Specification.
1744 * See struct rte_flow_action_of_set_vlan_vid.
1746 RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID,
1749 * Implements OFPAT_SET_LAN_PCP ("set the 802.1q priority") as
1750 * defined by the OpenFlow Switch Specification.
1752 * See struct rte_flow_action_of_set_vlan_pcp.
1754 RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP,
1757 * Implements OFPAT_POP_MPLS ("pop the outer MPLS tag") as defined
1758 * by the OpenFlow Switch Specification.
1760 * See struct rte_flow_action_of_pop_mpls.
1762 RTE_FLOW_ACTION_TYPE_OF_POP_MPLS,
1765 * Implements OFPAT_PUSH_MPLS ("push a new MPLS tag") as defined by
1766 * the OpenFlow Switch Specification.
1768 * See struct rte_flow_action_of_push_mpls.
1770 RTE_FLOW_ACTION_TYPE_OF_PUSH_MPLS,
1773 * Encapsulate flow in VXLAN tunnel as defined in
1774 * rte_flow_action_vxlan_encap action structure.
1776 * See struct rte_flow_action_vxlan_encap.
1778 RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP,
1781 * Decapsulate outer most VXLAN tunnel from matched flow.
1783 * If flow pattern does not define a valid VXLAN tunnel (as specified by
1784 * RFC7348) then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION
1787 RTE_FLOW_ACTION_TYPE_VXLAN_DECAP,
1790 * Encapsulate flow in NVGRE tunnel defined in the
1791 * rte_flow_action_nvgre_encap action structure.
1793 * See struct rte_flow_action_nvgre_encap.
1795 RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP,
1798 * Decapsulate outer most NVGRE tunnel from matched flow.
1800 * If flow pattern does not define a valid NVGRE tunnel (as specified by
1801 * RFC7637) then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION
1804 RTE_FLOW_ACTION_TYPE_NVGRE_DECAP,
1807 * Add outer header whose template is provided in its data buffer
1809 * See struct rte_flow_action_raw_encap.
1811 RTE_FLOW_ACTION_TYPE_RAW_ENCAP,
1814 * Remove outer header whose template is provided in its data buffer.
1816 * See struct rte_flow_action_raw_decap
1818 RTE_FLOW_ACTION_TYPE_RAW_DECAP,
1821 * Modify IPv4 source address in the outermost IPv4 header.
1823 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV4,
1824 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
1826 * See struct rte_flow_action_set_ipv4.
1828 RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC,
1831 * Modify IPv4 destination address in the outermost IPv4 header.
1833 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV4,
1834 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
1836 * See struct rte_flow_action_set_ipv4.
1838 RTE_FLOW_ACTION_TYPE_SET_IPV4_DST,
1841 * Modify IPv6 source address in the outermost IPv6 header.
1843 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV6,
1844 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
1846 * See struct rte_flow_action_set_ipv6.
1848 RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC,
1851 * Modify IPv6 destination address in the outermost IPv6 header.
1853 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV6,
1854 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
1856 * See struct rte_flow_action_set_ipv6.
1858 RTE_FLOW_ACTION_TYPE_SET_IPV6_DST,
1861 * Modify source port number in the outermost TCP/UDP header.
1863 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_TCP
1864 * or RTE_FLOW_ITEM_TYPE_UDP, then the PMD should return a
1865 * RTE_FLOW_ERROR_TYPE_ACTION error.
1867 * See struct rte_flow_action_set_tp.
1869 RTE_FLOW_ACTION_TYPE_SET_TP_SRC,
1872 * Modify destination port number in the outermost TCP/UDP header.
1874 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_TCP
1875 * or RTE_FLOW_ITEM_TYPE_UDP, then the PMD should return a
1876 * RTE_FLOW_ERROR_TYPE_ACTION error.
1878 * See struct rte_flow_action_set_tp.
1880 RTE_FLOW_ACTION_TYPE_SET_TP_DST,
1883 * Swap the source and destination MAC addresses in the outermost
1886 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_ETH,
1887 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
1889 * No associated configuration structure.
1891 RTE_FLOW_ACTION_TYPE_MAC_SWAP,
1894 * Decrease TTL value directly
1896 * No associated configuration structure.
1898 RTE_FLOW_ACTION_TYPE_DEC_TTL,
1903 * See struct rte_flow_action_set_ttl
1905 RTE_FLOW_ACTION_TYPE_SET_TTL,
1908 * Set source MAC address from matched flow.
1910 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_ETH,
1911 * the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
1913 * See struct rte_flow_action_set_mac.
1915 RTE_FLOW_ACTION_TYPE_SET_MAC_SRC,
1918 * Set destination MAC address from matched flow.
1920 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_ETH,
1921 * the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
1923 * See struct rte_flow_action_set_mac.
1925 RTE_FLOW_ACTION_TYPE_SET_MAC_DST,
1928 * Increase sequence number in the outermost TCP header.
1930 * Action configuration specifies the value to increase
1931 * TCP sequence number as a big-endian 32 bit integer.
1934 * @code rte_be32_t * @endcode
1936 * Using this action on non-matching traffic will result in
1937 * undefined behavior.
1939 RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ,
1942 * Decrease sequence number in the outermost TCP header.
1944 * Action configuration specifies the value to decrease
1945 * TCP sequence number as a big-endian 32 bit integer.
1948 * @code rte_be32_t * @endcode
1950 * Using this action on non-matching traffic will result in
1951 * undefined behavior.
1953 RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ,
1956 * Increase acknowledgment number in the outermost TCP header.
1958 * Action configuration specifies the value to increase
1959 * TCP acknowledgment number as a big-endian 32 bit integer.
1962 * @code rte_be32_t * @endcode
1964 * Using this action on non-matching traffic will result in
1965 * undefined behavior.
1967 RTE_FLOW_ACTION_TYPE_INC_TCP_ACK,
1970 * Decrease acknowledgment number in the outermost TCP header.
1972 * Action configuration specifies the value to decrease
1973 * TCP acknowledgment number as a big-endian 32 bit integer.
1976 * @code rte_be32_t * @endcode
1978 * Using this action on non-matching traffic will result in
1979 * undefined behavior.
1981 RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK,
1986 * Tag is for internal flow usage only and
1987 * is not delivered to the application.
1989 * See struct rte_flow_action_set_tag.
1991 RTE_FLOW_ACTION_TYPE_SET_TAG,
1995 * RTE_FLOW_ACTION_TYPE_MARK
1997 * Attaches an integer value to packets and sets PKT_RX_FDIR and
1998 * PKT_RX_FDIR_ID mbuf flags.
2000 * This value is arbitrary and application-defined. Maximum allowed value
2001 * depends on the underlying implementation. It is returned in the
2002 * hash.fdir.hi mbuf field.
2004 struct rte_flow_action_mark {
2005 uint32_t id; /**< Integer value to return with packets. */
2010 * @b EXPERIMENTAL: this structure may change without prior notice
2012 * RTE_FLOW_ACTION_TYPE_JUMP
2014 * Redirects packets to a group on the current device.
2016 * In a hierarchy of groups, which can be used to represent physical or logical
2017 * flow tables on the device, this action allows the action to be a redirect to
2018 * a group on that device.
2020 struct rte_flow_action_jump {
2025 * RTE_FLOW_ACTION_TYPE_QUEUE
2027 * Assign packets to a given queue index.
2029 struct rte_flow_action_queue {
2030 uint16_t index; /**< Queue index to use. */
2036 * @b EXPERIMENTAL: this structure may change without prior notice
2038 * RTE_FLOW_ACTION_TYPE_COUNT
2040 * Adds a counter action to a matched flow.
2042 * If more than one count action is specified in a single flow rule, then each
2043 * action must specify a unique id.
2045 * Counters can be retrieved and reset through ``rte_flow_query()``, see
2046 * ``struct rte_flow_query_count``.
2048 * The shared flag indicates whether the counter is unique to the flow rule the
2049 * action is specified with, or whether it is a shared counter.
2051 * For a count action with the shared flag set, then then a global device
2052 * namespace is assumed for the counter id, so that any matched flow rules using
2053 * a count action with the same counter id on the same port will contribute to
2056 * For ports within the same switch domain then the counter id namespace extends
2057 * to all ports within that switch domain.
2059 struct rte_flow_action_count {
2060 uint32_t shared:1; /**< Share counter ID with other flow rules. */
2061 uint32_t reserved:31; /**< Reserved, must be zero. */
2062 uint32_t id; /**< Counter ID. */
2066 * RTE_FLOW_ACTION_TYPE_COUNT (query)
2068 * Query structure to retrieve and reset flow rule counters.
2070 struct rte_flow_query_count {
2071 uint32_t reset:1; /**< Reset counters after query [in]. */
2072 uint32_t hits_set:1; /**< hits field is set [out]. */
2073 uint32_t bytes_set:1; /**< bytes field is set [out]. */
2074 uint32_t reserved:29; /**< Reserved, must be zero [in, out]. */
2075 uint64_t hits; /**< Number of hits for this rule [out]. */
2076 uint64_t bytes; /**< Number of bytes through this rule [out]. */
2080 * Hash function types.
2082 enum rte_eth_hash_function {
2083 RTE_ETH_HASH_FUNCTION_DEFAULT = 0,
2084 RTE_ETH_HASH_FUNCTION_TOEPLITZ, /**< Toeplitz */
2085 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR, /**< Simple XOR */
2087 * Symmetric Toeplitz: src, dst will be replaced by
2088 * xor(src, dst). For the case with src/dst only,
2089 * src or dst address will xor with zero pair.
2091 RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ,
2092 RTE_ETH_HASH_FUNCTION_MAX,
2096 * RTE_FLOW_ACTION_TYPE_RSS
2098 * Similar to QUEUE, except RSS is additionally performed on packets to
2099 * spread them among several queues according to the provided parameters.
2101 * Unlike global RSS settings used by other DPDK APIs, unsetting the
2102 * @p types field does not disable RSS in a flow rule. Doing so instead
2103 * requests safe unspecified "best-effort" settings from the underlying PMD,
2104 * which depending on the flow rule, may result in anything ranging from
2105 * empty (single queue) to all-inclusive RSS.
2107 * Note: RSS hash result is stored in the hash.rss mbuf field which overlaps
2108 * hash.fdir.lo. Since the MARK action sets the hash.fdir.hi field only,
2109 * both can be requested simultaneously.
2111 struct rte_flow_action_rss {
2112 enum rte_eth_hash_function func; /**< RSS hash function to apply. */
2114 * Packet encapsulation level RSS hash @p types apply to.
2116 * - @p 0 requests the default behavior. Depending on the packet
2117 * type, it can mean outermost, innermost, anything in between or
2120 * It basically stands for the innermost encapsulation level RSS
2121 * can be performed on according to PMD and device capabilities.
2123 * - @p 1 requests RSS to be performed on the outermost packet
2124 * encapsulation level.
2126 * - @p 2 and subsequent values request RSS to be performed on the
2127 * specified inner packet encapsulation level, from outermost to
2128 * innermost (lower to higher values).
2130 * Values other than @p 0 are not necessarily supported.
2132 * Requesting a specific RSS level on unrecognized traffic results
2133 * in undefined behavior. For predictable results, it is recommended
2134 * to make the flow rule pattern match packet headers up to the
2135 * requested encapsulation level so that only matching traffic goes
2139 uint64_t types; /**< Specific RSS hash types (see ETH_RSS_*). */
2140 uint32_t key_len; /**< Hash key length in bytes. */
2141 uint32_t queue_num; /**< Number of entries in @p queue. */
2142 const uint8_t *key; /**< Hash key. */
2143 const uint16_t *queue; /**< Queue indices to use. */
2147 * RTE_FLOW_ACTION_TYPE_VF
2149 * Directs matching traffic to a given virtual function of the current
2152 * Packets matched by a VF pattern item can be redirected to their original
2153 * VF ID instead of the specified one. This parameter may not be available
2154 * and is not guaranteed to work properly if the VF part is matched by a
2155 * prior flow rule or if packets are not addressed to a VF in the first
2158 struct rte_flow_action_vf {
2159 uint32_t original:1; /**< Use original VF ID if possible. */
2160 uint32_t reserved:31; /**< Reserved, must be zero. */
2161 uint32_t id; /**< VF ID. */
2165 * RTE_FLOW_ACTION_TYPE_PHY_PORT
2167 * Directs packets to a given physical port index of the underlying
2170 * @see RTE_FLOW_ITEM_TYPE_PHY_PORT
2172 struct rte_flow_action_phy_port {
2173 uint32_t original:1; /**< Use original port index if possible. */
2174 uint32_t reserved:31; /**< Reserved, must be zero. */
2175 uint32_t index; /**< Physical port index. */
2179 * RTE_FLOW_ACTION_TYPE_PORT_ID
2181 * Directs matching traffic to a given DPDK port ID.
2183 * @see RTE_FLOW_ITEM_TYPE_PORT_ID
2185 struct rte_flow_action_port_id {
2186 uint32_t original:1; /**< Use original DPDK port ID if possible. */
2187 uint32_t reserved:31; /**< Reserved, must be zero. */
2188 uint32_t id; /**< DPDK port ID. */
2192 * RTE_FLOW_ACTION_TYPE_METER
2194 * Traffic metering and policing (MTR).
2196 * Packets matched by items of this type can be either dropped or passed to the
2197 * next item with their color set by the MTR object.
2199 struct rte_flow_action_meter {
2200 uint32_t mtr_id; /**< MTR object ID created with rte_mtr_create(). */
2204 * RTE_FLOW_ACTION_TYPE_SECURITY
2206 * Perform the security action on flows matched by the pattern items
2207 * according to the configuration of the security session.
2209 * This action modifies the payload of matched flows. For INLINE_CRYPTO, the
2210 * security protocol headers and IV are fully provided by the application as
2211 * specified in the flow pattern. The payload of matching packets is
2212 * encrypted on egress, and decrypted and authenticated on ingress.
2213 * For INLINE_PROTOCOL, the security protocol is fully offloaded to HW,
2214 * providing full encapsulation and decapsulation of packets in security
2215 * protocols. The flow pattern specifies both the outer security header fields
2216 * and the inner packet fields. The security session specified in the action
2217 * must match the pattern parameters.
2219 * The security session specified in the action must be created on the same
2220 * port as the flow action that is being specified.
2222 * The ingress/egress flow attribute should match that specified in the
2223 * security session if the security session supports the definition of the
2226 * Multiple flows can be configured to use the same security session.
2228 struct rte_flow_action_security {
2229 void *security_session; /**< Pointer to security session structure. */
2233 * RTE_FLOW_ACTION_TYPE_OF_SET_MPLS_TTL
2235 * Implements OFPAT_SET_MPLS_TTL ("MPLS TTL") as defined by the OpenFlow
2236 * Switch Specification.
2238 struct rte_flow_action_of_set_mpls_ttl {
2239 uint8_t mpls_ttl; /**< MPLS TTL. */
2243 * RTE_FLOW_ACTION_TYPE_OF_SET_NW_TTL
2245 * Implements OFPAT_SET_NW_TTL ("IP TTL") as defined by the OpenFlow Switch
2248 struct rte_flow_action_of_set_nw_ttl {
2249 uint8_t nw_ttl; /**< IP TTL. */
2253 * RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN
2255 * Implements OFPAT_PUSH_VLAN ("push a new VLAN tag") as defined by the
2256 * OpenFlow Switch Specification.
2258 struct rte_flow_action_of_push_vlan {
2259 rte_be16_t ethertype; /**< EtherType. */
2263 * RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID
2265 * Implements OFPAT_SET_VLAN_VID ("set the 802.1q VLAN id") as defined by
2266 * the OpenFlow Switch Specification.
2268 struct rte_flow_action_of_set_vlan_vid {
2269 rte_be16_t vlan_vid; /**< VLAN id. */
2273 * RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP
2275 * Implements OFPAT_SET_LAN_PCP ("set the 802.1q priority") as defined by
2276 * the OpenFlow Switch Specification.
2278 struct rte_flow_action_of_set_vlan_pcp {
2279 uint8_t vlan_pcp; /**< VLAN priority. */
2283 * RTE_FLOW_ACTION_TYPE_OF_POP_MPLS
2285 * Implements OFPAT_POP_MPLS ("pop the outer MPLS tag") as defined by the
2286 * OpenFlow Switch Specification.
2288 struct rte_flow_action_of_pop_mpls {
2289 rte_be16_t ethertype; /**< EtherType. */
2293 * RTE_FLOW_ACTION_TYPE_OF_PUSH_MPLS
2295 * Implements OFPAT_PUSH_MPLS ("push a new MPLS tag") as defined by the
2296 * OpenFlow Switch Specification.
2298 struct rte_flow_action_of_push_mpls {
2299 rte_be16_t ethertype; /**< EtherType. */
2304 * @b EXPERIMENTAL: this structure may change without prior notice
2306 * RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP
2308 * VXLAN tunnel end-point encapsulation data definition
2310 * The tunnel definition is provided through the flow item pattern, the
2311 * provided pattern must conform to RFC7348 for the tunnel specified. The flow
2312 * definition must be provided in order from the RTE_FLOW_ITEM_TYPE_ETH
2313 * definition up the end item which is specified by RTE_FLOW_ITEM_TYPE_END.
2315 * The mask field allows user to specify which fields in the flow item
2316 * definitions can be ignored and which have valid data and can be used
2319 * Note: the last field is not used in the definition of a tunnel and can be
2322 * Valid flow definition for RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP include:
2324 * - ETH / IPV4 / UDP / VXLAN / END
2325 * - ETH / IPV6 / UDP / VXLAN / END
2326 * - ETH / VLAN / IPV4 / UDP / VXLAN / END
2329 struct rte_flow_action_vxlan_encap {
2331 * Encapsulating vxlan tunnel definition
2332 * (terminated by the END pattern item).
2334 struct rte_flow_item *definition;
2339 * @b EXPERIMENTAL: this structure may change without prior notice
2341 * RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP
2343 * NVGRE tunnel end-point encapsulation data definition
2345 * The tunnel definition is provided through the flow item pattern the
2346 * provided pattern must conform with RFC7637. The flow definition must be
2347 * provided in order from the RTE_FLOW_ITEM_TYPE_ETH definition up the end item
2348 * which is specified by RTE_FLOW_ITEM_TYPE_END.
2350 * The mask field allows user to specify which fields in the flow item
2351 * definitions can be ignored and which have valid data and can be used
2354 * Note: the last field is not used in the definition of a tunnel and can be
2357 * Valid flow definition for RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP include:
2359 * - ETH / IPV4 / NVGRE / END
2360 * - ETH / VLAN / IPV6 / NVGRE / END
2363 struct rte_flow_action_nvgre_encap {
2365 * Encapsulating vxlan tunnel definition
2366 * (terminated by the END pattern item).
2368 struct rte_flow_item *definition;
2373 * @b EXPERIMENTAL: this structure may change without prior notice
2375 * RTE_FLOW_ACTION_TYPE_RAW_ENCAP
2377 * Raw tunnel end-point encapsulation data definition.
2379 * The data holds the headers definitions to be applied on the packet.
2380 * The data must start with ETH header up to the tunnel item header itself.
2381 * When used right after RAW_DECAP (for decapsulating L3 tunnel type for
2382 * example MPLSoGRE) the data will just hold layer 2 header.
2384 * The preserve parameter holds which bits in the packet the PMD is not allowed
2385 * to change, this parameter can also be NULL and then the PMD is allowed
2386 * to update any field.
2388 * size holds the number of bytes in @p data and @p preserve.
2390 struct rte_flow_action_raw_encap {
2391 uint8_t *data; /**< Encapsulation data. */
2392 uint8_t *preserve; /**< Bit-mask of @p data to preserve on output. */
2393 size_t size; /**< Size of @p data and @p preserve. */
2398 * @b EXPERIMENTAL: this structure may change without prior notice
2400 * RTE_FLOW_ACTION_TYPE_RAW_DECAP
2402 * Raw tunnel end-point decapsulation data definition.
2404 * The data holds the headers definitions to be removed from the packet.
2405 * The data must start with ETH header up to the tunnel item header itself.
2406 * When used right before RAW_DECAP (for encapsulating L3 tunnel type for
2407 * example MPLSoGRE) the data will just hold layer 2 header.
2409 * size holds the number of bytes in @p data.
2411 struct rte_flow_action_raw_decap {
2412 uint8_t *data; /**< Encapsulation data. */
2413 size_t size; /**< Size of @p data and @p preserve. */
2418 * @b EXPERIMENTAL: this structure may change without prior notice
2420 * RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC
2421 * RTE_FLOW_ACTION_TYPE_SET_IPV4_DST
2423 * Allows modification of IPv4 source (RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC)
2424 * and destination address (RTE_FLOW_ACTION_TYPE_SET_IPV4_DST) in the
2425 * specified outermost IPv4 header.
2427 struct rte_flow_action_set_ipv4 {
2428 rte_be32_t ipv4_addr;
2433 * @b EXPERIMENTAL: this structure may change without prior notice
2435 * RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC
2436 * RTE_FLOW_ACTION_TYPE_SET_IPV6_DST
2438 * Allows modification of IPv6 source (RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC)
2439 * and destination address (RTE_FLOW_ACTION_TYPE_SET_IPV6_DST) in the
2440 * specified outermost IPv6 header.
2442 struct rte_flow_action_set_ipv6 {
2443 uint8_t ipv6_addr[16];
2448 * @b EXPERIMENTAL: this structure may change without prior notice
2450 * RTE_FLOW_ACTION_TYPE_SET_TP_SRC
2451 * RTE_FLOW_ACTION_TYPE_SET_TP_DST
2453 * Allows modification of source (RTE_FLOW_ACTION_TYPE_SET_TP_SRC)
2454 * and destination (RTE_FLOW_ACTION_TYPE_SET_TP_DST) port numbers
2455 * in the specified outermost TCP/UDP header.
2457 struct rte_flow_action_set_tp {
2462 * RTE_FLOW_ACTION_TYPE_SET_TTL
2464 * Set the TTL value directly for IPv4 or IPv6
2466 struct rte_flow_action_set_ttl {
2471 * RTE_FLOW_ACTION_TYPE_SET_MAC
2473 * Set MAC address from the matched flow
2475 struct rte_flow_action_set_mac {
2476 uint8_t mac_addr[RTE_ETHER_ADDR_LEN];
2481 * @b EXPERIMENTAL: this structure may change without prior notice
2483 * RTE_FLOW_ACTION_TYPE_SET_TAG
2485 * Set a tag which is a transient data used during flow matching. This is not
2486 * delivered to application. Multiple tags are supported by specifying index.
2488 struct rte_flow_action_set_tag {
2495 * Definition of a single action.
2497 * A list of actions is terminated by a END action.
2499 * For simple actions without a configuration object, conf remains NULL.
2501 struct rte_flow_action {
2502 enum rte_flow_action_type type; /**< Action type. */
2503 const void *conf; /**< Pointer to action configuration object. */
2507 * Opaque type returned after successfully creating a flow.
2509 * This handle can be used to manage and query the related flow (e.g. to
2510 * destroy it or retrieve counters).
2515 * Verbose error types.
2517 * Most of them provide the type of the object referenced by struct
2518 * rte_flow_error.cause.
2520 enum rte_flow_error_type {
2521 RTE_FLOW_ERROR_TYPE_NONE, /**< No error. */
2522 RTE_FLOW_ERROR_TYPE_UNSPECIFIED, /**< Cause unspecified. */
2523 RTE_FLOW_ERROR_TYPE_HANDLE, /**< Flow rule (handle). */
2524 RTE_FLOW_ERROR_TYPE_ATTR_GROUP, /**< Group field. */
2525 RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY, /**< Priority field. */
2526 RTE_FLOW_ERROR_TYPE_ATTR_INGRESS, /**< Ingress field. */
2527 RTE_FLOW_ERROR_TYPE_ATTR_EGRESS, /**< Egress field. */
2528 RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, /**< Transfer field. */
2529 RTE_FLOW_ERROR_TYPE_ATTR, /**< Attributes structure. */
2530 RTE_FLOW_ERROR_TYPE_ITEM_NUM, /**< Pattern length. */
2531 RTE_FLOW_ERROR_TYPE_ITEM_SPEC, /**< Item specification. */
2532 RTE_FLOW_ERROR_TYPE_ITEM_LAST, /**< Item specification range. */
2533 RTE_FLOW_ERROR_TYPE_ITEM_MASK, /**< Item specification mask. */
2534 RTE_FLOW_ERROR_TYPE_ITEM, /**< Specific pattern item. */
2535 RTE_FLOW_ERROR_TYPE_ACTION_NUM, /**< Number of actions. */
2536 RTE_FLOW_ERROR_TYPE_ACTION_CONF, /**< Action configuration. */
2537 RTE_FLOW_ERROR_TYPE_ACTION, /**< Specific action. */
2541 * Verbose error structure definition.
2543 * This object is normally allocated by applications and set by PMDs, the
2544 * message points to a constant string which does not need to be freed by
2545 * the application, however its pointer can be considered valid only as long
2546 * as its associated DPDK port remains configured. Closing the underlying
2547 * device or unloading the PMD invalidates it.
2549 * Both cause and message may be NULL regardless of the error type.
2551 struct rte_flow_error {
2552 enum rte_flow_error_type type; /**< Cause field and error types. */
2553 const void *cause; /**< Object responsible for the error. */
2554 const char *message; /**< Human-readable error message. */
2558 * Complete flow rule description.
2560 * This object type is used when converting a flow rule description.
2562 * @see RTE_FLOW_CONV_OP_RULE
2563 * @see rte_flow_conv()
2566 struct rte_flow_conv_rule {
2568 const struct rte_flow_attr *attr_ro; /**< RO attributes. */
2569 struct rte_flow_attr *attr; /**< Attributes. */
2572 const struct rte_flow_item *pattern_ro; /**< RO pattern. */
2573 struct rte_flow_item *pattern; /**< Pattern items. */
2576 const struct rte_flow_action *actions_ro; /**< RO actions. */
2577 struct rte_flow_action *actions; /**< List of actions. */
2582 * Conversion operations for flow API objects.
2584 * @see rte_flow_conv()
2586 enum rte_flow_conv_op {
2588 * No operation to perform.
2590 * rte_flow_conv() simply returns 0.
2592 RTE_FLOW_CONV_OP_NONE,
2595 * Convert attributes structure.
2597 * This is a basic copy of an attributes structure.
2600 * @code const struct rte_flow_attr * @endcode
2602 * @code struct rte_flow_attr * @endcode
2604 RTE_FLOW_CONV_OP_ATTR,
2607 * Convert a single item.
2609 * Duplicates @p spec, @p last and @p mask but not outside objects.
2612 * @code const struct rte_flow_item * @endcode
2614 * @code struct rte_flow_item * @endcode
2616 RTE_FLOW_CONV_OP_ITEM,
2619 * Convert a single action.
2621 * Duplicates @p conf but not outside objects.
2624 * @code const struct rte_flow_action * @endcode
2626 * @code struct rte_flow_action * @endcode
2628 RTE_FLOW_CONV_OP_ACTION,
2631 * Convert an entire pattern.
2633 * Duplicates all pattern items at once with the same constraints as
2634 * RTE_FLOW_CONV_OP_ITEM.
2637 * @code const struct rte_flow_item * @endcode
2639 * @code struct rte_flow_item * @endcode
2641 RTE_FLOW_CONV_OP_PATTERN,
2644 * Convert a list of actions.
2646 * Duplicates the entire list of actions at once with the same
2647 * constraints as RTE_FLOW_CONV_OP_ACTION.
2650 * @code const struct rte_flow_action * @endcode
2652 * @code struct rte_flow_action * @endcode
2654 RTE_FLOW_CONV_OP_ACTIONS,
2657 * Convert a complete flow rule description.
2659 * Comprises attributes, pattern and actions together at once with
2660 * the usual constraints.
2663 * @code const struct rte_flow_conv_rule * @endcode
2665 * @code struct rte_flow_conv_rule * @endcode
2667 RTE_FLOW_CONV_OP_RULE,
2670 * Convert item type to its name string.
2672 * Writes a NUL-terminated string to @p dst. Like snprintf(), the
2673 * returned value excludes the terminator which is always written
2677 * @code (const void *)enum rte_flow_item_type @endcode
2679 * @code char * @endcode
2681 RTE_FLOW_CONV_OP_ITEM_NAME,
2684 * Convert action type to its name string.
2686 * Writes a NUL-terminated string to @p dst. Like snprintf(), the
2687 * returned value excludes the terminator which is always written
2691 * @code (const void *)enum rte_flow_action_type @endcode
2693 * @code char * @endcode
2695 RTE_FLOW_CONV_OP_ACTION_NAME,
2698 * Convert item type to pointer to item name.
2700 * Retrieves item name pointer from its type. The string itself is
2701 * not copied; instead, a unique pointer to an internal static
2702 * constant storage is written to @p dst.
2705 * @code (const void *)enum rte_flow_item_type @endcode
2707 * @code const char ** @endcode
2709 RTE_FLOW_CONV_OP_ITEM_NAME_PTR,
2712 * Convert action type to pointer to action name.
2714 * Retrieves action name pointer from its type. The string itself is
2715 * not copied; instead, a unique pointer to an internal static
2716 * constant storage is written to @p dst.
2719 * @code (const void *)enum rte_flow_action_type @endcode
2721 * @code const char ** @endcode
2723 RTE_FLOW_CONV_OP_ACTION_NAME_PTR,
2727 * Check whether a flow rule can be created on a given port.
2729 * The flow rule is validated for correctness and whether it could be accepted
2730 * by the device given sufficient resources. The rule is checked against the
2731 * current device mode and queue configuration. The flow rule may also
2732 * optionally be validated against existing flow rules and device resources.
2733 * This function has no effect on the target device.
2735 * The returned value is guaranteed to remain valid only as long as no
2736 * successful calls to rte_flow_create() or rte_flow_destroy() are made in
2737 * the meantime and no device parameter affecting flow rules in any way are
2738 * modified, due to possible collisions or resource limitations (although in
2739 * such cases EINVAL should not be returned).
2742 * Port identifier of Ethernet device.
2744 * Flow rule attributes.
2745 * @param[in] pattern
2746 * Pattern specification (list terminated by the END pattern item).
2747 * @param[in] actions
2748 * Associated actions (list terminated by the END action).
2750 * Perform verbose error reporting if not NULL. PMDs initialize this
2751 * structure in case of error only.
2754 * 0 if flow rule is valid and can be created. A negative errno value
2755 * otherwise (rte_errno is also set), the following errors are defined:
2757 * -ENOSYS: underlying device does not support this functionality.
2759 * -EIO: underlying device is removed.
2761 * -EINVAL: unknown or invalid rule specification.
2763 * -ENOTSUP: valid but unsupported rule specification (e.g. partial
2764 * bit-masks are unsupported).
2766 * -EEXIST: collision with an existing rule. Only returned if device
2767 * supports flow rule collision checking and there was a flow rule
2768 * collision. Not receiving this return code is no guarantee that creating
2769 * the rule will not fail due to a collision.
2771 * -ENOMEM: not enough memory to execute the function, or if the device
2772 * supports resource validation, resource limitation on the device.
2774 * -EBUSY: action cannot be performed due to busy device resources, may
2775 * succeed if the affected queues or even the entire port are in a stopped
2776 * state (see rte_eth_dev_rx_queue_stop() and rte_eth_dev_stop()).
2779 rte_flow_validate(uint16_t port_id,
2780 const struct rte_flow_attr *attr,
2781 const struct rte_flow_item pattern[],
2782 const struct rte_flow_action actions[],
2783 struct rte_flow_error *error);
2786 * Create a flow rule on a given port.
2789 * Port identifier of Ethernet device.
2791 * Flow rule attributes.
2792 * @param[in] pattern
2793 * Pattern specification (list terminated by the END pattern item).
2794 * @param[in] actions
2795 * Associated actions (list terminated by the END action).
2797 * Perform verbose error reporting if not NULL. PMDs initialize this
2798 * structure in case of error only.
2801 * A valid handle in case of success, NULL otherwise and rte_errno is set
2802 * to the positive version of one of the error codes defined for
2803 * rte_flow_validate().
2806 rte_flow_create(uint16_t port_id,
2807 const struct rte_flow_attr *attr,
2808 const struct rte_flow_item pattern[],
2809 const struct rte_flow_action actions[],
2810 struct rte_flow_error *error);
2813 * Destroy a flow rule on a given port.
2815 * Failure to destroy a flow rule handle may occur when other flow rules
2816 * depend on it, and destroying it would result in an inconsistent state.
2818 * This function is only guaranteed to succeed if handles are destroyed in
2819 * reverse order of their creation.
2822 * Port identifier of Ethernet device.
2824 * Flow rule handle to destroy.
2826 * Perform verbose error reporting if not NULL. PMDs initialize this
2827 * structure in case of error only.
2830 * 0 on success, a negative errno value otherwise and rte_errno is set.
2833 rte_flow_destroy(uint16_t port_id,
2834 struct rte_flow *flow,
2835 struct rte_flow_error *error);
2838 * Destroy all flow rules associated with a port.
2840 * In the unlikely event of failure, handles are still considered destroyed
2841 * and no longer valid but the port must be assumed to be in an inconsistent
2845 * Port identifier of Ethernet device.
2847 * Perform verbose error reporting if not NULL. PMDs initialize this
2848 * structure in case of error only.
2851 * 0 on success, a negative errno value otherwise and rte_errno is set.
2854 rte_flow_flush(uint16_t port_id,
2855 struct rte_flow_error *error);
2858 * Query an existing flow rule.
2860 * This function allows retrieving flow-specific data such as counters.
2861 * Data is gathered by special actions which must be present in the flow
2864 * \see RTE_FLOW_ACTION_TYPE_COUNT
2867 * Port identifier of Ethernet device.
2869 * Flow rule handle to query.
2871 * Action definition as defined in original flow rule.
2872 * @param[in, out] data
2873 * Pointer to storage for the associated query data type.
2875 * Perform verbose error reporting if not NULL. PMDs initialize this
2876 * structure in case of error only.
2879 * 0 on success, a negative errno value otherwise and rte_errno is set.
2882 rte_flow_query(uint16_t port_id,
2883 struct rte_flow *flow,
2884 const struct rte_flow_action *action,
2886 struct rte_flow_error *error);
2889 * Restrict ingress traffic to the defined flow rules.
2891 * Isolated mode guarantees that all ingress traffic comes from defined flow
2892 * rules only (current and future).
2894 * Besides making ingress more deterministic, it allows PMDs to safely reuse
2895 * resources otherwise assigned to handle the remaining traffic, such as
2896 * global RSS configuration settings, VLAN filters, MAC address entries,
2897 * legacy filter API rules and so on in order to expand the set of possible
2900 * Calling this function as soon as possible after device initialization,
2901 * ideally before the first call to rte_eth_dev_configure(), is recommended
2902 * to avoid possible failures due to conflicting settings.
2904 * Once effective, leaving isolated mode may not be possible depending on
2905 * PMD implementation.
2907 * Additionally, the following functionality has no effect on the underlying
2908 * port and may return errors such as ENOTSUP ("not supported"):
2910 * - Toggling promiscuous mode.
2911 * - Toggling allmulticast mode.
2912 * - Configuring MAC addresses.
2913 * - Configuring multicast addresses.
2914 * - Configuring VLAN filters.
2915 * - Configuring Rx filters through the legacy API (e.g. FDIR).
2916 * - Configuring global RSS settings.
2919 * Port identifier of Ethernet device.
2921 * Nonzero to enter isolated mode, attempt to leave it otherwise.
2923 * Perform verbose error reporting if not NULL. PMDs initialize this
2924 * structure in case of error only.
2927 * 0 on success, a negative errno value otherwise and rte_errno is set.
2930 rte_flow_isolate(uint16_t port_id, int set, struct rte_flow_error *error);
2933 * Initialize flow error structure.
2936 * Pointer to flow error structure (may be NULL).
2938 * Related error code (rte_errno).
2940 * Cause field and error types.
2942 * Object responsible for the error.
2944 * Human-readable error message.
2947 * Negative error code (errno value) and rte_errno is set.
2950 rte_flow_error_set(struct rte_flow_error *error,
2952 enum rte_flow_error_type type,
2954 const char *message);
2958 * @see rte_flow_copy()
2960 struct rte_flow_desc {
2961 size_t size; /**< Allocated space including data[]. */
2962 struct rte_flow_attr attr; /**< Attributes. */
2963 struct rte_flow_item *items; /**< Items. */
2964 struct rte_flow_action *actions; /**< Actions. */
2965 uint8_t data[]; /**< Storage for items/actions. */
2970 * Copy an rte_flow rule description.
2972 * This interface is kept for compatibility with older applications but is
2973 * implemented as a wrapper to rte_flow_conv(). It is deprecated due to its
2974 * lack of flexibility and reliance on a type unusable with C++ programs
2975 * (struct rte_flow_desc).
2978 * Flow rule description.
2980 * Total size of allocated data for the flow description.
2982 * Flow rule attributes.
2984 * Pattern specification (list terminated by the END pattern item).
2985 * @param[in] actions
2986 * Associated actions (list terminated by the END action).
2989 * If len is greater or equal to the size of the flow, the total size of the
2990 * flow description and its data.
2991 * If len is lower than the size of the flow, the number of bytes that would
2992 * have been written to desc had it been sufficient. Nothing is written.
2996 rte_flow_copy(struct rte_flow_desc *fd, size_t len,
2997 const struct rte_flow_attr *attr,
2998 const struct rte_flow_item *items,
2999 const struct rte_flow_action *actions);
3002 * Flow object conversion helper.
3004 * This function performs conversion of various flow API objects to a
3005 * pre-allocated destination buffer. See enum rte_flow_conv_op for possible
3006 * operations and details about each of them.
3008 * Since destination buffer must be large enough, it works in a manner
3009 * reminiscent of snprintf():
3011 * - If @p size is 0, @p dst may be a NULL pointer, otherwise @p dst must be
3013 * - If positive, the returned value represents the number of bytes needed
3014 * to store the conversion of @p src to @p dst according to @p op
3015 * regardless of the @p size parameter.
3016 * - Since no more than @p size bytes can be written to @p dst, output is
3017 * truncated and may be inconsistent when the returned value is larger
3019 * - In case of conversion error, a negative error code is returned and
3020 * @p dst contents are unspecified.
3023 * Operation to perform, related to the object type of @p dst.
3025 * Destination buffer address. Must be suitably aligned by the caller.
3027 * Destination buffer size in bytes.
3029 * Source object to copy. Depending on @p op, its type may differ from
3032 * Perform verbose error reporting if not NULL. Initialized in case of
3036 * The number of bytes required to convert @p src to @p dst on success, a
3037 * negative errno value otherwise and rte_errno is set.
3039 * @see rte_flow_conv_op
3043 rte_flow_conv(enum rte_flow_conv_op op,
3047 struct rte_flow_error *error);
3053 #endif /* RTE_FLOW_H_ */