1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright 2016 6WIND S.A.
3 * Copyright 2016 Mellanox Technologies, Ltd
6 #ifndef RTE_FLOW_DRIVER_H_
7 #define RTE_FLOW_DRIVER_H_
11 * RTE generic flow API (driver side)
13 * This file provides implementation helpers for internal use by PMDs, they
14 * are not intended to be exposed to applications and are not subject to ABI
20 #include "rte_ethdev.h"
28 * Generic flow operations structure implemented and returned by PMDs.
30 * To implement this API, PMDs must handle the RTE_ETH_FILTER_GENERIC filter
31 * type in their .filter_ctrl callback function (struct eth_dev_ops) as well
32 * as the RTE_ETH_FILTER_GET filter operation.
34 * If successful, this operation must result in a pointer to a PMD-specific
35 * struct rte_flow_ops written to the argument address as described below:
39 * // PMD filter_ctrl callback
41 * static const struct rte_flow_ops pmd_flow_ops = { ... };
43 * switch (filter_type) {
44 * case RTE_ETH_FILTER_GENERIC:
45 * if (filter_op != RTE_ETH_FILTER_GET)
47 * *(const void **)arg = &pmd_flow_ops;
53 * See also rte_flow_ops_get().
55 * These callback functions are not supposed to be used by applications
56 * directly, which must rely on the API defined in rte_flow.h.
58 * Public-facing wrapper functions perform a few consistency checks so that
59 * unimplemented (i.e. NULL) callbacks simply return -ENOTSUP. These
60 * callbacks otherwise only differ by their first argument (with port ID
61 * already resolved to a pointer to struct rte_eth_dev).
64 /** See rte_flow_validate(). */
66 (struct rte_eth_dev *,
67 const struct rte_flow_attr *,
68 const struct rte_flow_item [],
69 const struct rte_flow_action [],
70 struct rte_flow_error *);
71 /** See rte_flow_create(). */
72 struct rte_flow *(*create)
73 (struct rte_eth_dev *,
74 const struct rte_flow_attr *,
75 const struct rte_flow_item [],
76 const struct rte_flow_action [],
77 struct rte_flow_error *);
78 /** See rte_flow_destroy(). */
80 (struct rte_eth_dev *,
82 struct rte_flow_error *);
83 /** See rte_flow_flush(). */
85 (struct rte_eth_dev *,
86 struct rte_flow_error *);
87 /** See rte_flow_query(). */
89 (struct rte_eth_dev *,
91 const struct rte_flow_action *,
93 struct rte_flow_error *);
94 /** See rte_flow_isolate(). */
96 (struct rte_eth_dev *,
98 struct rte_flow_error *);
99 /** See rte_flow_dev_dump(). */
101 (struct rte_eth_dev *dev,
103 struct rte_flow_error *error);
107 * Get generic flow operations structure from a port.
110 * Port identifier to query.
112 * Pointer to flow error structure.
115 * The flow operations structure associated with port_id, NULL in case of
116 * error, in which case rte_errno is set and the error structure contains
117 * additional details.
119 const struct rte_flow_ops *
120 rte_flow_ops_get(uint16_t port_id, struct rte_flow_error *error);
122 /** Helper macro to build input graph for rte_flow_expand_rss(). */
123 #define RTE_FLOW_EXPAND_RSS_NEXT(...) \
128 /** Node object of input graph for rte_flow_expand_rss(). */
129 struct rte_flow_expand_node {
130 const int *const next;
132 * List of next node indexes. Index 0 is interpreted as a terminator.
134 const enum rte_flow_item_type type;
135 /**< Pattern item type of current node. */
138 * RSS types bit-field associated with this node
139 * (see ETH_RSS_* definitions).
143 /** Object returned by rte_flow_expand_rss(). */
144 struct rte_flow_expand_rss {
146 /**< Number of entries @p patterns and @p priorities. */
148 struct rte_flow_item *pattern; /**< Expanded pattern array. */
149 uint32_t priority; /**< Priority offset for each expansion. */
154 * Expand RSS flows into several possible flows according to the RSS hash
155 * fields requested and the driver capabilities.
157 * @b EXPERIMENTAL: this API may change without prior notice
160 * Buffer to store the result expansion.
162 * Buffer size in bytes. If 0, @p buf can be NULL.
166 * RSS types to expand (see ETH_RSS_* definitions).
168 * Input graph to expand @p pattern according to @p types.
169 * @param[in] graph_root_index
170 * Index of root node in @p graph, typically 0.
173 * A positive value representing the size of @p buf in bytes regardless of
174 * @p size on success, a negative errno value otherwise and rte_errno is
175 * set, the following errors are defined:
177 * -E2BIG: graph-depth @p graph is too deep.
181 rte_flow_expand_rss(struct rte_flow_expand_rss *buf, size_t size,
182 const struct rte_flow_item *pattern, uint64_t types,
183 const struct rte_flow_expand_node graph[],
184 int graph_root_index);
190 #endif /* RTE_FLOW_DRIVER_H_ */