1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright (c) 2021 NVIDIA CORPORATION. All rights reserved.
7 #if defined(HAVE_IBV_FLOW_DV_SUPPORT) || !defined(HAVE_INFINIBAND_VERBS_H)
11 * The following null stubs are prepared in order not to break the linkage
12 * before the HW steering low-level implementation is added.
15 /* Open a context used for direct rule insertion using hardware steering.
16 * Each context can contain multiple tables of different types.
19 * The ibv context to used for HWS.
21 * Attributes used for context open.
22 * @return pointer to mlx5dr_context on success NULL otherwise.
24 __rte_weak struct mlx5dr_context *
25 mlx5dr_context_open(void *ibv_ctx,
26 struct mlx5dr_context_attr *attr)
33 /* Close a context used for direct hardware steering.
36 * mlx5dr context to close.
37 * @return zero on success non zero otherwise.
40 mlx5dr_context_close(struct mlx5dr_context *ctx)
46 /* Create a new direct rule table. Each table can contain multiple matchers.
49 * The context in which the new table will be opened.
51 * Attributes used for table creation.
52 * @return pointer to mlx5dr_table on success NULL otherwise.
54 __rte_weak struct mlx5dr_table *
55 mlx5dr_table_create(struct mlx5dr_context *ctx,
56 struct mlx5dr_table_attr *attr)
63 /* Destroy direct rule table.
66 * mlx5dr table to destroy.
67 * @return zero on success non zero otherwise.
69 __rte_weak int mlx5dr_table_destroy(struct mlx5dr_table *tbl)
75 /* Create new match template based on items mask, the match template
76 * will be used for matcher creation.
79 * Describe the mask for template creation
81 * Template creation flags
82 * @return pointer to mlx5dr_match_template on success NULL otherwise
84 __rte_weak struct mlx5dr_match_template *
85 mlx5dr_match_template_create(const struct rte_flow_item items[],
86 enum mlx5dr_match_template_flags flags)
93 /* Destroy match template.
96 * Match template to destroy.
97 * @return zero on success non zero otherwise.
100 mlx5dr_match_template_destroy(struct mlx5dr_match_template *mt)
106 /* Create a new direct rule matcher. Each matcher can contain multiple rules.
107 * Matchers on the table will be processed by priority. Matching fields and
108 * mask are described by the match template. In some cases multiple match
109 * templates can be used on the same matcher.
112 * The table in which the new matcher will be opened.
114 * Array of match templates to be used on matcher.
115 * @param[in] num_of_mt
116 * Number of match templates in mt array.
118 * Attributes used for matcher creation.
119 * @return pointer to mlx5dr_matcher on success NULL otherwise.
121 __rte_weak struct mlx5dr_matcher *
122 mlx5dr_matcher_create(struct mlx5dr_table *table __rte_unused,
123 struct mlx5dr_match_template *mt[] __rte_unused,
124 uint8_t num_of_mt __rte_unused,
125 struct mlx5dr_matcher_attr *attr __rte_unused)
130 /* Destroy direct rule matcher.
133 * Matcher to destroy.
134 * @return zero on success non zero otherwise.
137 mlx5dr_matcher_destroy(struct mlx5dr_matcher *matcher __rte_unused)
142 /* Enqueue create rule operation.
145 * The matcher in which the new rule will be created.
147 * Match template index to create the rule with.
149 * The items used for the value matching.
150 * @param[in] rule_actions
151 * Rule action to be executed on match.
152 * @param[in] num_of_actions
153 * Number of rule actions.
155 * Rule creation attributes.
156 * @param[in, out] rule_handle
157 * A valid rule handle. The handle doesn't require any initialization.
158 * @return zero on successful enqueue non zero otherwise.
161 mlx5dr_rule_create(struct mlx5dr_matcher *matcher __rte_unused,
162 uint8_t mt_idx __rte_unused,
163 const struct rte_flow_item items[] __rte_unused,
164 struct mlx5dr_rule_action rule_actions[] __rte_unused,
165 uint8_t num_of_actions __rte_unused,
166 struct mlx5dr_rule_attr *attr __rte_unused,
167 struct mlx5dr_rule *rule_handle __rte_unused)
172 /* Enqueue destroy rule operation.
175 * The rule destruction to enqueue.
177 * Rule destruction attributes.
178 * @return zero on successful enqueue non zero otherwise.
181 mlx5dr_rule_destroy(struct mlx5dr_rule *rule __rte_unused,
182 struct mlx5dr_rule_attr *attr __rte_unused)
187 /* Create direct rule drop action.
190 * The context in which the new action will be created.
192 * Action creation flags. (enum mlx5dr_action_flags)
193 * @return pointer to mlx5dr_action on success NULL otherwise.
195 __rte_weak struct mlx5dr_action *
196 mlx5dr_action_create_dest_drop(struct mlx5dr_context *ctx __rte_unused,
197 uint32_t flags __rte_unused)
202 /* Create direct rule default miss action.
203 * Defaults are RX: Drop TX: Wire.
206 * The context in which the new action will be created.
208 * Action creation flags. (enum mlx5dr_action_flags)
209 * @return pointer to mlx5dr_action on success NULL otherwise.
211 __rte_weak struct mlx5dr_action *
212 mlx5dr_action_create_default_miss(struct mlx5dr_context *ctx __rte_unused,
213 uint32_t flags __rte_unused)
218 /* Create direct rule goto table action.
221 * The context in which the new action will be created.
225 * Action creation flags. (enum mlx5dr_action_flags)
226 * @return pointer to mlx5dr_action on success NULL otherwise.
228 __rte_weak struct mlx5dr_action *
229 mlx5dr_action_create_dest_table(struct mlx5dr_context *ctx __rte_unused,
230 struct mlx5dr_table *tbl __rte_unused,
231 uint32_t flags __rte_unused)
236 /* Create direct rule goto TIR action.
239 * The context in which the new action will be created.
241 * Direct rule TIR devx object.
243 * Action creation flags. (enum mlx5dr_action_flags)
244 * @return pointer to mlx5dr_action on success NULL otherwise.
246 __rte_weak struct mlx5dr_action *
247 mlx5dr_action_create_dest_tir(struct mlx5dr_context *ctx __rte_unused,
248 struct mlx5dr_devx_obj *obj __rte_unused,
249 uint32_t flags __rte_unused)
254 /* Create direct rule TAG action.
257 * The context in which the new action will be created.
259 * Action creation flags. (enum mlx5dr_action_flags)
260 * @return pointer to mlx5dr_action on success NULL otherwise.
262 __rte_weak struct mlx5dr_action *
263 mlx5dr_action_create_tag(struct mlx5dr_context *ctx __rte_unused,
264 uint32_t flags __rte_unused)
269 /* Create direct rule counter action.
272 * The context in which the new action will be created.
274 * Direct rule counter devx object.
276 * Action creation flags. (enum mlx5dr_action_flags)
277 * @return pointer to mlx5dr_action on success NULL otherwise.
279 __rte_weak struct mlx5dr_action *
280 mlx5dr_action_create_counter(struct mlx5dr_context *ctx,
281 struct mlx5dr_devx_obj *obj,
284 /* Create direct rule reformat action.
287 * The context in which the new action will be created.
288 * @param[in] reformat_type
291 * Size in bytes of data.
292 * @param[in] inline_data
293 * Header data array in case of inline action.
294 * @param[in] log_bulk_size
295 * Number of unique values used with this pattern.
297 * Action creation flags. (enum mlx5dr_action_flags)
298 * @return pointer to mlx5dr_action on success NULL otherwise.
300 __rte_weak struct mlx5dr_action *
301 mlx5dr_action_create_reformat(struct mlx5dr_context *ctx __rte_unused,
302 enum mlx5dr_action_reformat_type reformat_type __rte_unused,
303 size_t data_sz __rte_unused,
304 void *inline_data __rte_unused,
305 uint32_t log_bulk_size __rte_unused,
306 uint32_t flags __rte_unused)
311 /* Create direct rule modify header action.
314 * The context in which the new action will be created.
315 * @param[in] pattern_sz
316 * Byte size of the pattern array.
318 * PRM format modify pattern action array.
319 * @param[in] log_bulk_size
320 * Number of unique values used with this pattern.
322 * Action creation flags. (enum mlx5dr_action_flags)
323 * @return pointer to mlx5dr_action on success NULL otherwise.
325 __rte_weak struct mlx5dr_action *
326 mlx5dr_action_create_modify_header(struct mlx5dr_context *ctx,
328 rte_be64_t pattern[],
329 uint32_t log_bulk_size,
332 /* Destroy direct rule action.
335 * The action to destroy.
336 * @return zero on success non zero otherwise.
339 mlx5dr_action_destroy(struct mlx5dr_action *action __rte_unused)
344 /* Poll queue for rule creation and deletions completions.
347 * The context to which the queue belong to.
348 * @param[in] queue_id
349 * The id of the queue to poll.
350 * @param[in, out] res
353 * Maximum number of results to return.
354 * @return negative number on failure, the number of completions otherwise.
357 mlx5dr_send_queue_poll(struct mlx5dr_context *ctx __rte_unused,
358 uint16_t queue_id __rte_unused,
359 struct rte_flow_op_result res[] __rte_unused,
360 uint32_t res_nb __rte_unused)
365 /* Perform an action on the queue
368 * The context to which the queue belong to.
369 * @param[in] queue_id
370 * The id of the queue to perform the action on.
372 * Actions to perform on the queue. (enum mlx5dr_send_queue_actions)
373 * @return zero on success non zero otherwise.
376 mlx5dr_send_queue_action(struct mlx5dr_context *ctx __rte_unused,
377 uint16_t queue_id __rte_unused,
378 uint32_t actions __rte_unused)