4 * Copyright 2016 6WIND S.A.
5 * Copyright 2016 Mellanox.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
17 * * Neither the name of 6WIND S.A. nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39 * RTE generic flow API
41 * This interface provides the ability to program packet matching and
42 * associated actions in hardware through flow rules.
46 #include <rte_ether.h>
58 * Flow rule attributes.
60 * Priorities are set on two levels: per group and per rule within groups.
62 * Lower values denote higher priority, the highest priority for both levels
63 * is 0, so that a rule with priority 0 in group 8 is always matched after a
64 * rule with priority 8 in group 0.
66 * Although optional, applications are encouraged to group similar rules as
67 * much as possible to fully take advantage of hardware capabilities
68 * (e.g. optimized matching) and work around limitations (e.g. a single
69 * pattern type possibly allowed in a given group).
71 * Group and priority levels are arbitrary and up to the application, they
72 * do not need to be contiguous nor start from 0, however the maximum number
73 * varies between devices and may be affected by existing flow rules.
75 * If a packet is matched by several rules of a given group for a given
76 * priority level, the outcome is undefined. It can take any path, may be
77 * duplicated or even cause unrecoverable errors.
79 * Note that support for more than a single group and priority level is not
82 * Flow rules can apply to inbound and/or outbound traffic (ingress/egress).
84 * Several pattern items and actions are valid and can be used in both
85 * directions. Those valid for only one direction are described as such.
87 * At least one direction must be specified.
89 * Specifying both directions at once for a given rule is not recommended
90 * but may be valid in a few cases (e.g. shared counter).
92 struct rte_flow_attr {
93 uint32_t group; /**< Priority group. */
94 uint32_t priority; /**< Priority level within group. */
95 uint32_t ingress:1; /**< Rule applies to ingress traffic. */
96 uint32_t egress:1; /**< Rule applies to egress traffic. */
97 uint32_t reserved:30; /**< Reserved, must be zero. */
101 * Matching pattern item types.
103 * Pattern items fall in two categories:
105 * - Matching protocol headers and packet data (ANY, RAW, ETH, VLAN, IPV4,
106 * IPV6, ICMP, UDP, TCP, SCTP, VXLAN and so on), usually associated with a
107 * specification structure. These must be stacked in the same order as the
108 * protocol layers to match, starting from the lowest.
110 * - Matching meta-data or affecting pattern processing (END, VOID, INVERT,
111 * PF, VF, PORT and so on), often without a specification structure. Since
112 * they do not match packet contents, these can be specified anywhere
113 * within item lists without affecting others.
115 * See the description of individual types for more information. Those
116 * marked with [META] fall into the second category.
118 enum rte_flow_item_type {
122 * End marker for item lists. Prevents further processing of items,
123 * thereby ending the pattern.
125 * No associated specification structure.
127 RTE_FLOW_ITEM_TYPE_END,
132 * Used as a placeholder for convenience. It is ignored and simply
135 * No associated specification structure.
137 RTE_FLOW_ITEM_TYPE_VOID,
142 * Inverted matching, i.e. process packets that do not match the
145 * No associated specification structure.
147 RTE_FLOW_ITEM_TYPE_INVERT,
150 * Matches any protocol in place of the current layer, a single ANY
151 * may also stand for several protocol layers.
153 * See struct rte_flow_item_any.
155 RTE_FLOW_ITEM_TYPE_ANY,
160 * Matches packets addressed to the physical function of the device.
162 * If the underlying device function differs from the one that would
163 * normally receive the matched traffic, specifying this item
164 * prevents it from reaching that device unless the flow rule
165 * contains a PF action. Packets are not duplicated between device
166 * instances by default.
168 * No associated specification structure.
170 RTE_FLOW_ITEM_TYPE_PF,
175 * Matches packets addressed to a virtual function ID of the device.
177 * If the underlying device function differs from the one that would
178 * normally receive the matched traffic, specifying this item
179 * prevents it from reaching that device unless the flow rule
180 * contains a VF action. Packets are not duplicated between device
181 * instances by default.
183 * See struct rte_flow_item_vf.
185 RTE_FLOW_ITEM_TYPE_VF,
190 * Matches packets coming from the specified physical port of the
193 * The first PORT item overrides the physical port normally
194 * associated with the specified DPDK input port (port_id). This
195 * item can be provided several times to match additional physical
198 * See struct rte_flow_item_port.
200 RTE_FLOW_ITEM_TYPE_PORT,
203 * Matches a byte string of a given length at a given offset.
205 * See struct rte_flow_item_raw.
207 RTE_FLOW_ITEM_TYPE_RAW,
210 * Matches an Ethernet header.
212 * See struct rte_flow_item_eth.
214 RTE_FLOW_ITEM_TYPE_ETH,
217 * Matches an 802.1Q/ad VLAN tag.
219 * See struct rte_flow_item_vlan.
221 RTE_FLOW_ITEM_TYPE_VLAN,
224 * Matches an IPv4 header.
226 * See struct rte_flow_item_ipv4.
228 RTE_FLOW_ITEM_TYPE_IPV4,
231 * Matches an IPv6 header.
233 * See struct rte_flow_item_ipv6.
235 RTE_FLOW_ITEM_TYPE_IPV6,
238 * Matches an ICMP header.
240 * See struct rte_flow_item_icmp.
242 RTE_FLOW_ITEM_TYPE_ICMP,
245 * Matches a UDP header.
247 * See struct rte_flow_item_udp.
249 RTE_FLOW_ITEM_TYPE_UDP,
252 * Matches a TCP header.
254 * See struct rte_flow_item_tcp.
256 RTE_FLOW_ITEM_TYPE_TCP,
259 * Matches a SCTP header.
261 * See struct rte_flow_item_sctp.
263 RTE_FLOW_ITEM_TYPE_SCTP,
266 * Matches a VXLAN header.
268 * See struct rte_flow_item_vxlan.
270 RTE_FLOW_ITEM_TYPE_VXLAN,
274 * RTE_FLOW_ITEM_TYPE_ANY
276 * Matches any protocol in place of the current layer, a single ANY may also
277 * stand for several protocol layers.
279 * This is usually specified as the first pattern item when looking for a
280 * protocol anywhere in a packet.
282 * A zeroed mask stands for any number of layers.
284 struct rte_flow_item_any {
285 uint32_t num; /* Number of layers covered. */
289 * RTE_FLOW_ITEM_TYPE_VF
291 * Matches packets addressed to a virtual function ID of the device.
293 * If the underlying device function differs from the one that would
294 * normally receive the matched traffic, specifying this item prevents it
295 * from reaching that device unless the flow rule contains a VF
296 * action. Packets are not duplicated between device instances by default.
298 * - Likely to return an error or never match any traffic if this causes a
299 * VF device to match traffic addressed to a different VF.
300 * - Can be specified multiple times to match traffic addressed to several
302 * - Can be combined with a PF item to match both PF and VF traffic.
304 * A zeroed mask can be used to match any VF ID.
306 struct rte_flow_item_vf {
307 uint32_t id; /**< Destination VF ID. */
311 * RTE_FLOW_ITEM_TYPE_PORT
313 * Matches packets coming from the specified physical port of the underlying
316 * The first PORT item overrides the physical port normally associated with
317 * the specified DPDK input port (port_id). This item can be provided
318 * several times to match additional physical ports.
320 * Note that physical ports are not necessarily tied to DPDK input ports
321 * (port_id) when those are not under DPDK control. Possible values are
322 * specific to each device, they are not necessarily indexed from zero and
323 * may not be contiguous.
325 * As a device property, the list of allowed values as well as the value
326 * associated with a port_id should be retrieved by other means.
328 * A zeroed mask can be used to match any port index.
330 struct rte_flow_item_port {
331 uint32_t index; /**< Physical port index. */
335 * RTE_FLOW_ITEM_TYPE_RAW
337 * Matches a byte string of a given length at a given offset.
339 * Offset is either absolute (using the start of the packet) or relative to
340 * the end of the previous matched item in the stack, in which case negative
341 * values are allowed.
343 * If search is enabled, offset is used as the starting point. The search
344 * area can be delimited by setting limit to a nonzero value, which is the
345 * maximum number of bytes after offset where the pattern may start.
347 * Matching a zero-length pattern is allowed, doing so resets the relative
348 * offset for subsequent items.
350 * This type does not support ranges (struct rte_flow_item.last).
352 struct rte_flow_item_raw {
353 uint32_t relative:1; /**< Look for pattern after the previous item. */
354 uint32_t search:1; /**< Search pattern from offset (see also limit). */
355 uint32_t reserved:30; /**< Reserved, must be set to zero. */
356 int32_t offset; /**< Absolute or relative offset for pattern. */
357 uint16_t limit; /**< Search area limit for start of pattern. */
358 uint16_t length; /**< Pattern length. */
359 uint8_t pattern[]; /**< Byte string to look for. */
363 * RTE_FLOW_ITEM_TYPE_ETH
365 * Matches an Ethernet header.
367 struct rte_flow_item_eth {
368 struct ether_addr dst; /**< Destination MAC. */
369 struct ether_addr src; /**< Source MAC. */
370 uint16_t type; /**< EtherType. */
374 * RTE_FLOW_ITEM_TYPE_VLAN
376 * Matches an 802.1Q/ad VLAN tag.
378 * This type normally follows either RTE_FLOW_ITEM_TYPE_ETH or
379 * RTE_FLOW_ITEM_TYPE_VLAN.
381 struct rte_flow_item_vlan {
382 uint16_t tpid; /**< Tag protocol identifier. */
383 uint16_t tci; /**< Tag control information. */
387 * RTE_FLOW_ITEM_TYPE_IPV4
389 * Matches an IPv4 header.
391 * Note: IPv4 options are handled by dedicated pattern items.
393 struct rte_flow_item_ipv4 {
394 struct ipv4_hdr hdr; /**< IPv4 header definition. */
398 * RTE_FLOW_ITEM_TYPE_IPV6.
400 * Matches an IPv6 header.
402 * Note: IPv6 options are handled by dedicated pattern items.
404 struct rte_flow_item_ipv6 {
405 struct ipv6_hdr hdr; /**< IPv6 header definition. */
409 * RTE_FLOW_ITEM_TYPE_ICMP.
411 * Matches an ICMP header.
413 struct rte_flow_item_icmp {
414 struct icmp_hdr hdr; /**< ICMP header definition. */
418 * RTE_FLOW_ITEM_TYPE_UDP.
420 * Matches a UDP header.
422 struct rte_flow_item_udp {
423 struct udp_hdr hdr; /**< UDP header definition. */
427 * RTE_FLOW_ITEM_TYPE_TCP.
429 * Matches a TCP header.
431 struct rte_flow_item_tcp {
432 struct tcp_hdr hdr; /**< TCP header definition. */
436 * RTE_FLOW_ITEM_TYPE_SCTP.
438 * Matches a SCTP header.
440 struct rte_flow_item_sctp {
441 struct sctp_hdr hdr; /**< SCTP header definition. */
445 * RTE_FLOW_ITEM_TYPE_VXLAN.
447 * Matches a VXLAN header (RFC 7348).
449 struct rte_flow_item_vxlan {
450 uint8_t flags; /**< Normally 0x08 (I flag). */
451 uint8_t rsvd0[3]; /**< Reserved, normally 0x000000. */
452 uint8_t vni[3]; /**< VXLAN identifier. */
453 uint8_t rsvd1; /**< Reserved, normally 0x00. */
457 * Matching pattern item definition.
459 * A pattern is formed by stacking items starting from the lowest protocol
460 * layer to match. This stacking restriction does not apply to meta items
461 * which can be placed anywhere in the stack without affecting the meaning
462 * of the resulting pattern.
464 * Patterns are terminated by END items.
466 * The spec field should be a valid pointer to a structure of the related
467 * item type. It may be set to NULL in many cases to use default values.
469 * Optionally, last can point to a structure of the same type to define an
470 * inclusive range. This is mostly supported by integer and address fields,
471 * may cause errors otherwise. Fields that do not support ranges must be set
472 * to 0 or to the same value as the corresponding fields in spec.
474 * By default all fields present in spec are considered relevant (see note
475 * below). This behavior can be altered by providing a mask structure of the
476 * same type with applicable bits set to one. It can also be used to
477 * partially filter out specific fields (e.g. as an alternate mean to match
478 * ranges of IP addresses).
480 * Mask is a simple bit-mask applied before interpreting the contents of
481 * spec and last, which may yield unexpected results if not used
482 * carefully. For example, if for an IPv4 address field, spec provides
483 * 10.1.2.3, last provides 10.3.4.5 and mask provides 255.255.0.0, the
484 * effective range becomes 10.1.0.0 to 10.3.255.255.
486 * Note: the defaults for data-matching items such as IPv4 when mask is not
487 * specified actually depend on the underlying implementation since only
488 * recognized fields can be taken into account.
490 struct rte_flow_item {
491 enum rte_flow_item_type type; /**< Item type. */
492 const void *spec; /**< Pointer to item specification structure. */
493 const void *last; /**< Defines an inclusive range (spec to last). */
494 const void *mask; /**< Bit-mask applied to spec and last. */
500 * Each possible action is represented by a type. Some have associated
501 * configuration structures. Several actions combined in a list can be
502 * affected to a flow rule. That list is not ordered.
504 * They fall in three categories:
506 * - Terminating actions (such as QUEUE, DROP, RSS, PF, VF) that prevent
507 * processing matched packets by subsequent flow rules, unless overridden
510 * - Non terminating actions (PASSTHRU, DUP) that leave matched packets up
511 * for additional processing by subsequent flow rules.
513 * - Other non terminating meta actions that do not affect the fate of
514 * packets (END, VOID, MARK, FLAG, COUNT).
516 * When several actions are combined in a flow rule, they should all have
517 * different types (e.g. dropping a packet twice is not possible).
519 * Only the last action of a given type is taken into account. PMDs still
520 * perform error checking on the entire list.
522 * Note that PASSTHRU is the only action able to override a terminating
525 enum rte_flow_action_type {
529 * End marker for action lists. Prevents further processing of
530 * actions, thereby ending the list.
532 * No associated configuration structure.
534 RTE_FLOW_ACTION_TYPE_END,
539 * Used as a placeholder for convenience. It is ignored and simply
542 * No associated configuration structure.
544 RTE_FLOW_ACTION_TYPE_VOID,
547 * Leaves packets up for additional processing by subsequent flow
548 * rules. This is the default when a rule does not contain a
549 * terminating action, but can be specified to force a rule to
550 * become non-terminating.
552 * No associated configuration structure.
554 RTE_FLOW_ACTION_TYPE_PASSTHRU,
559 * Attaches a 32 bit value to packets.
561 * See struct rte_flow_action_mark.
563 RTE_FLOW_ACTION_TYPE_MARK,
568 * Flag packets. Similar to MARK but only affects ol_flags.
570 * Note: a distinctive flag must be defined for it.
572 * No associated configuration structure.
574 RTE_FLOW_ACTION_TYPE_FLAG,
577 * Assigns packets to a given queue index.
579 * See struct rte_flow_action_queue.
581 RTE_FLOW_ACTION_TYPE_QUEUE,
586 * PASSTHRU overrides this action if both are specified.
588 * No associated configuration structure.
590 RTE_FLOW_ACTION_TYPE_DROP,
595 * Enables counters for this rule.
597 * These counters can be retrieved and reset through rte_flow_query(),
598 * see struct rte_flow_query_count.
600 * No associated configuration structure.
602 RTE_FLOW_ACTION_TYPE_COUNT,
605 * Duplicates packets to a given queue index.
607 * This is normally combined with QUEUE, however when used alone, it
608 * is actually similar to QUEUE + PASSTHRU.
610 * See struct rte_flow_action_dup.
612 RTE_FLOW_ACTION_TYPE_DUP,
615 * Similar to QUEUE, except RSS is additionally performed on packets
616 * to spread them among several queues according to the provided
619 * See struct rte_flow_action_rss.
621 RTE_FLOW_ACTION_TYPE_RSS,
624 * Redirects packets to the physical function (PF) of the current
627 * No associated configuration structure.
629 RTE_FLOW_ACTION_TYPE_PF,
632 * Redirects packets to the virtual function (VF) of the current
633 * device with the specified ID.
635 * See struct rte_flow_action_vf.
637 RTE_FLOW_ACTION_TYPE_VF,
641 * RTE_FLOW_ACTION_TYPE_MARK
643 * Attaches a 32 bit value to packets.
645 * This value is arbitrary and application-defined. For compatibility with
646 * FDIR it is returned in the hash.fdir.hi mbuf field. PKT_RX_FDIR_ID is
647 * also set in ol_flags.
649 struct rte_flow_action_mark {
650 uint32_t id; /**< 32 bit value to return with packets. */
654 * RTE_FLOW_ACTION_TYPE_QUEUE
656 * Assign packets to a given queue index.
658 * Terminating by default.
660 struct rte_flow_action_queue {
661 uint16_t index; /**< Queue index to use. */
665 * RTE_FLOW_ACTION_TYPE_COUNT (query)
667 * Query structure to retrieve and reset flow rule counters.
669 struct rte_flow_query_count {
670 uint32_t reset:1; /**< Reset counters after query [in]. */
671 uint32_t hits_set:1; /**< hits field is set [out]. */
672 uint32_t bytes_set:1; /**< bytes field is set [out]. */
673 uint32_t reserved:29; /**< Reserved, must be zero [in, out]. */
674 uint64_t hits; /**< Number of hits for this rule [out]. */
675 uint64_t bytes; /**< Number of bytes through this rule [out]. */
679 * RTE_FLOW_ACTION_TYPE_DUP
681 * Duplicates packets to a given queue index.
683 * This is normally combined with QUEUE, however when used alone, it is
684 * actually similar to QUEUE + PASSTHRU.
686 * Non-terminating by default.
688 struct rte_flow_action_dup {
689 uint16_t index; /**< Queue index to duplicate packets to. */
693 * RTE_FLOW_ACTION_TYPE_RSS
695 * Similar to QUEUE, except RSS is additionally performed on packets to
696 * spread them among several queues according to the provided parameters.
698 * Note: RSS hash result is normally stored in the hash.rss mbuf field,
699 * however it conflicts with the MARK action as they share the same
700 * space. When both actions are specified, the RSS hash is discarded and
701 * PKT_RX_RSS_HASH is not set in ol_flags. MARK has priority. The mbuf
702 * structure should eventually evolve to store both.
704 * Terminating by default.
706 struct rte_flow_action_rss {
707 const struct rte_eth_rss_conf *rss_conf; /**< RSS parameters. */
708 uint16_t num; /**< Number of entries in queue[]. */
709 uint16_t queue[]; /**< Queues indices to use. */
713 * RTE_FLOW_ACTION_TYPE_VF
715 * Redirects packets to a virtual function (VF) of the current device.
717 * Packets matched by a VF pattern item can be redirected to their original
718 * VF ID instead of the specified one. This parameter may not be available
719 * and is not guaranteed to work properly if the VF part is matched by a
720 * prior flow rule or if packets are not addressed to a VF in the first
723 * Terminating by default.
725 struct rte_flow_action_vf {
726 uint32_t original:1; /**< Use original VF ID if possible. */
727 uint32_t reserved:31; /**< Reserved, must be zero. */
728 uint32_t id; /**< VF ID to redirect packets to. */
732 * Definition of a single action.
734 * A list of actions is terminated by a END action.
736 * For simple actions without a configuration structure, conf remains NULL.
738 struct rte_flow_action {
739 enum rte_flow_action_type type; /**< Action type. */
740 const void *conf; /**< Pointer to action configuration structure. */
744 * Opaque type returned after successfully creating a flow.
746 * This handle can be used to manage and query the related flow (e.g. to
747 * destroy it or retrieve counters).
752 * Verbose error types.
754 * Most of them provide the type of the object referenced by struct
755 * rte_flow_error.cause.
757 enum rte_flow_error_type {
758 RTE_FLOW_ERROR_TYPE_NONE, /**< No error. */
759 RTE_FLOW_ERROR_TYPE_UNSPECIFIED, /**< Cause unspecified. */
760 RTE_FLOW_ERROR_TYPE_HANDLE, /**< Flow rule (handle). */
761 RTE_FLOW_ERROR_TYPE_ATTR_GROUP, /**< Group field. */
762 RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY, /**< Priority field. */
763 RTE_FLOW_ERROR_TYPE_ATTR_INGRESS, /**< Ingress field. */
764 RTE_FLOW_ERROR_TYPE_ATTR_EGRESS, /**< Egress field. */
765 RTE_FLOW_ERROR_TYPE_ATTR, /**< Attributes structure. */
766 RTE_FLOW_ERROR_TYPE_ITEM_NUM, /**< Pattern length. */
767 RTE_FLOW_ERROR_TYPE_ITEM, /**< Specific pattern item. */
768 RTE_FLOW_ERROR_TYPE_ACTION_NUM, /**< Number of actions. */
769 RTE_FLOW_ERROR_TYPE_ACTION, /**< Specific action. */
773 * Verbose error structure definition.
775 * This object is normally allocated by applications and set by PMDs, the
776 * message points to a constant string which does not need to be freed by
777 * the application, however its pointer can be considered valid only as long
778 * as its associated DPDK port remains configured. Closing the underlying
779 * device or unloading the PMD invalidates it.
781 * Both cause and message may be NULL regardless of the error type.
783 struct rte_flow_error {
784 enum rte_flow_error_type type; /**< Cause field and error types. */
785 const void *cause; /**< Object responsible for the error. */
786 const char *message; /**< Human-readable error message. */
790 * Check whether a flow rule can be created on a given port.
792 * While this function has no effect on the target device, the flow rule is
793 * validated against its current configuration state and the returned value
794 * should be considered valid by the caller for that state only.
796 * The returned value is guaranteed to remain valid only as long as no
797 * successful calls to rte_flow_create() or rte_flow_destroy() are made in
798 * the meantime and no device parameter affecting flow rules in any way are
799 * modified, due to possible collisions or resource limitations (although in
800 * such cases EINVAL should not be returned).
803 * Port identifier of Ethernet device.
805 * Flow rule attributes.
807 * Pattern specification (list terminated by the END pattern item).
809 * Associated actions (list terminated by the END action).
811 * Perform verbose error reporting if not NULL. PMDs initialize this
812 * structure in case of error only.
815 * 0 if flow rule is valid and can be created. A negative errno value
816 * otherwise (rte_errno is also set), the following errors are defined:
818 * -ENOSYS: underlying device does not support this functionality.
820 * -EINVAL: unknown or invalid rule specification.
822 * -ENOTSUP: valid but unsupported rule specification (e.g. partial
823 * bit-masks are unsupported).
825 * -EEXIST: collision with an existing rule.
827 * -ENOMEM: not enough resources.
829 * -EBUSY: action cannot be performed due to busy device resources, may
830 * succeed if the affected queues or even the entire port are in a stopped
831 * state (see rte_eth_dev_rx_queue_stop() and rte_eth_dev_stop()).
834 rte_flow_validate(uint8_t port_id,
835 const struct rte_flow_attr *attr,
836 const struct rte_flow_item pattern[],
837 const struct rte_flow_action actions[],
838 struct rte_flow_error *error);
841 * Create a flow rule on a given port.
844 * Port identifier of Ethernet device.
846 * Flow rule attributes.
848 * Pattern specification (list terminated by the END pattern item).
850 * Associated actions (list terminated by the END action).
852 * Perform verbose error reporting if not NULL. PMDs initialize this
853 * structure in case of error only.
856 * A valid handle in case of success, NULL otherwise and rte_errno is set
857 * to the positive version of one of the error codes defined for
858 * rte_flow_validate().
861 rte_flow_create(uint8_t port_id,
862 const struct rte_flow_attr *attr,
863 const struct rte_flow_item pattern[],
864 const struct rte_flow_action actions[],
865 struct rte_flow_error *error);
868 * Destroy a flow rule on a given port.
870 * Failure to destroy a flow rule handle may occur when other flow rules
871 * depend on it, and destroying it would result in an inconsistent state.
873 * This function is only guaranteed to succeed if handles are destroyed in
874 * reverse order of their creation.
877 * Port identifier of Ethernet device.
879 * Flow rule handle to destroy.
881 * Perform verbose error reporting if not NULL. PMDs initialize this
882 * structure in case of error only.
885 * 0 on success, a negative errno value otherwise and rte_errno is set.
888 rte_flow_destroy(uint8_t port_id,
889 struct rte_flow *flow,
890 struct rte_flow_error *error);
893 * Destroy all flow rules associated with a port.
895 * In the unlikely event of failure, handles are still considered destroyed
896 * and no longer valid but the port must be assumed to be in an inconsistent
900 * Port identifier of Ethernet device.
902 * Perform verbose error reporting if not NULL. PMDs initialize this
903 * structure in case of error only.
906 * 0 on success, a negative errno value otherwise and rte_errno is set.
909 rte_flow_flush(uint8_t port_id,
910 struct rte_flow_error *error);
913 * Query an existing flow rule.
915 * This function allows retrieving flow-specific data such as counters.
916 * Data is gathered by special actions which must be present in the flow
919 * \see RTE_FLOW_ACTION_TYPE_COUNT
922 * Port identifier of Ethernet device.
924 * Flow rule handle to query.
926 * Action type to query.
927 * @param[in, out] data
928 * Pointer to storage for the associated query data type.
930 * Perform verbose error reporting if not NULL. PMDs initialize this
931 * structure in case of error only.
934 * 0 on success, a negative errno value otherwise and rte_errno is set.
937 rte_flow_query(uint8_t port_id,
938 struct rte_flow *flow,
939 enum rte_flow_action_type action,
941 struct rte_flow_error *error);
947 #endif /* RTE_FLOW_H_ */