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.
34 #ifndef RTE_FLOW_DRIVER_H_
35 #define RTE_FLOW_DRIVER_H_
39 * RTE generic flow API (driver side)
41 * This file provides implementation helpers for internal use by PMDs, they
42 * are not intended to be exposed to applications and are not subject to ABI
48 #include <rte_errno.h>
49 #include "rte_ethdev.h"
57 * Generic flow operations structure implemented and returned by PMDs.
59 * To implement this API, PMDs must handle the RTE_ETH_FILTER_GENERIC filter
60 * type in their .filter_ctrl callback function (struct eth_dev_ops) as well
61 * as the RTE_ETH_FILTER_GET filter operation.
63 * If successful, this operation must result in a pointer to a PMD-specific
64 * struct rte_flow_ops written to the argument address as described below:
68 * // PMD filter_ctrl callback
70 * static const struct rte_flow_ops pmd_flow_ops = { ... };
72 * switch (filter_type) {
73 * case RTE_ETH_FILTER_GENERIC:
74 * if (filter_op != RTE_ETH_FILTER_GET)
76 * *(const void **)arg = &pmd_flow_ops;
82 * See also rte_flow_ops_get().
84 * These callback functions are not supposed to be used by applications
85 * directly, which must rely on the API defined in rte_flow.h.
87 * Public-facing wrapper functions perform a few consistency checks so that
88 * unimplemented (i.e. NULL) callbacks simply return -ENOTSUP. These
89 * callbacks otherwise only differ by their first argument (with port ID
90 * already resolved to a pointer to struct rte_eth_dev).
93 /** See rte_flow_validate(). */
95 (struct rte_eth_dev *,
96 const struct rte_flow_attr *,
97 const struct rte_flow_item [],
98 const struct rte_flow_action [],
99 struct rte_flow_error *);
100 /** See rte_flow_create(). */
101 struct rte_flow *(*create)
102 (struct rte_eth_dev *,
103 const struct rte_flow_attr *,
104 const struct rte_flow_item [],
105 const struct rte_flow_action [],
106 struct rte_flow_error *);
107 /** See rte_flow_destroy(). */
109 (struct rte_eth_dev *,
111 struct rte_flow_error *);
112 /** See rte_flow_flush(). */
114 (struct rte_eth_dev *,
115 struct rte_flow_error *);
116 /** See rte_flow_query(). */
118 (struct rte_eth_dev *,
120 enum rte_flow_action_type,
122 struct rte_flow_error *);
126 * Initialize generic flow error structure.
128 * This function also sets rte_errno to a given value.
131 * Pointer to flow error structure (may be NULL).
133 * Related error code (rte_errno).
135 * Cause field and error types.
137 * Object responsible for the error.
139 * Human-readable error message.
145 rte_flow_error_set(struct rte_flow_error *error,
147 enum rte_flow_error_type type,
152 *error = (struct rte_flow_error){
163 * Get generic flow operations structure from a port.
166 * Port identifier to query.
168 * Pointer to flow error structure.
171 * The flow operations structure associated with port_id, NULL in case of
172 * error, in which case rte_errno is set and the error structure contains
173 * additional details.
175 const struct rte_flow_ops *
176 rte_flow_ops_get(uint8_t port_id, struct rte_flow_error *error);
182 #endif /* RTE_FLOW_DRIVER_H_ */