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"
21 #include "rte_ethdev_driver.h"
29 * Generic flow operations structure implemented and returned by PMDs.
31 * To implement this API, PMDs must handle the RTE_ETH_FILTER_GENERIC filter
32 * type in their .filter_ctrl callback function (struct eth_dev_ops) as well
33 * as the RTE_ETH_FILTER_GET filter operation.
35 * If successful, this operation must result in a pointer to a PMD-specific
36 * struct rte_flow_ops written to the argument address as described below:
40 * // PMD filter_ctrl callback
42 * static const struct rte_flow_ops pmd_flow_ops = { ... };
44 * switch (filter_type) {
45 * case RTE_ETH_FILTER_GENERIC:
46 * if (filter_op != RTE_ETH_FILTER_GET)
48 * *(const void **)arg = &pmd_flow_ops;
54 * See also rte_flow_ops_get().
56 * These callback functions are not supposed to be used by applications
57 * directly, which must rely on the API defined in rte_flow.h.
59 * Public-facing wrapper functions perform a few consistency checks so that
60 * unimplemented (i.e. NULL) callbacks simply return -ENOTSUP. These
61 * callbacks otherwise only differ by their first argument (with port ID
62 * already resolved to a pointer to struct rte_eth_dev).
65 /** See rte_flow_validate(). */
67 (struct rte_eth_dev *,
68 const struct rte_flow_attr *,
69 const struct rte_flow_item [],
70 const struct rte_flow_action [],
71 struct rte_flow_error *);
72 /** See rte_flow_create(). */
73 struct rte_flow *(*create)
74 (struct rte_eth_dev *,
75 const struct rte_flow_attr *,
76 const struct rte_flow_item [],
77 const struct rte_flow_action [],
78 struct rte_flow_error *);
79 /** See rte_flow_destroy(). */
81 (struct rte_eth_dev *,
83 struct rte_flow_error *);
84 /** See rte_flow_flush(). */
86 (struct rte_eth_dev *,
87 struct rte_flow_error *);
88 /** See rte_flow_query(). */
90 (struct rte_eth_dev *,
92 const struct rte_flow_action *,
94 struct rte_flow_error *);
95 /** See rte_flow_isolate(). */
97 (struct rte_eth_dev *,
99 struct rte_flow_error *);
100 /** See rte_flow_dev_dump(). */
102 (struct rte_eth_dev *dev,
104 struct rte_flow_error *error);
105 /** See rte_flow_get_aged_flows() */
106 int (*get_aged_flows)
107 (struct rte_eth_dev *dev,
109 uint32_t nb_contexts,
110 struct rte_flow_error *err);
114 * Get generic flow operations structure from a port.
117 * Port identifier to query.
119 * Pointer to flow error structure.
122 * The flow operations structure associated with port_id, NULL in case of
123 * error, in which case rte_errno is set and the error structure contains
124 * additional details.
126 const struct rte_flow_ops *
127 rte_flow_ops_get(uint16_t port_id, struct rte_flow_error *error);
129 /** Helper macro to build input graph for rte_flow_expand_rss(). */
130 #define RTE_FLOW_EXPAND_RSS_NEXT(...) \
135 /** Node object of input graph for rte_flow_expand_rss(). */
136 struct rte_flow_expand_node {
137 const int *const next;
139 * List of next node indexes. Index 0 is interpreted as a terminator.
141 const enum rte_flow_item_type type;
142 /**< Pattern item type of current node. */
145 * RSS types bit-field associated with this node
146 * (see ETH_RSS_* definitions).
150 /** Object returned by rte_flow_expand_rss(). */
151 struct rte_flow_expand_rss {
153 /**< Number of entries @p patterns and @p priorities. */
155 struct rte_flow_item *pattern; /**< Expanded pattern array. */
156 uint32_t priority; /**< Priority offset for each expansion. */
161 * Expand RSS flows into several possible flows according to the RSS hash
162 * fields requested and the driver capabilities.
165 * Buffer to store the result expansion.
167 * Buffer size in bytes. If 0, @p buf can be NULL.
171 * RSS types to expand (see ETH_RSS_* definitions).
173 * Input graph to expand @p pattern according to @p types.
174 * @param[in] graph_root_index
175 * Index of root node in @p graph, typically 0.
178 * A positive value representing the size of @p buf in bytes regardless of
179 * @p size on success, a negative errno value otherwise and rte_errno is
180 * set, the following errors are defined:
182 * -E2BIG: graph-depth @p graph is too deep.
186 rte_flow_expand_rss(struct rte_flow_expand_rss *buf, size_t size,
187 const struct rte_flow_item *pattern, uint64_t types,
188 const struct rte_flow_expand_node graph[],
189 int graph_root_index);
195 #endif /* RTE_FLOW_DRIVER_H_ */