1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright 2020 Mellanox Technologies, Ltd
5 #ifndef RTE_PMD_MLX5_FLOW_OS_H_
6 #define RTE_PMD_MLX5_FLOW_OS_H_
9 #include "mlx5_malloc.h"
11 #if defined(HAVE_IBV_FLOW_DV_SUPPORT) || !defined(HAVE_INFINIBAND_VERBS_H)
12 extern const struct mlx5_flow_driver_ops mlx5_flow_dv_drv_ops;
16 * Get OS enforced flow type. MLX5_FLOW_TYPE_MAX means "non enforced type".
19 * Flow type (MLX5_FLOW_TYPE_MAX)
21 static inline enum mlx5_flow_drv_type
22 mlx5_flow_os_get_type(void)
24 return MLX5_FLOW_TYPE_DV;
28 * Check if item type is supported.
34 * True is this item type is supported, false if not supported.
37 mlx5_flow_os_item_supported(int item)
40 case RTE_FLOW_ITEM_TYPE_END:
41 case RTE_FLOW_ITEM_TYPE_VOID:
42 case RTE_FLOW_ITEM_TYPE_ETH:
43 case RTE_FLOW_ITEM_TYPE_IPV4:
44 case RTE_FLOW_ITEM_TYPE_UDP:
45 case RTE_FLOW_ITEM_TYPE_TCP:
46 case RTE_FLOW_ITEM_TYPE_IPV6:
54 * Check if action type is supported.
57 * Action type to check.
60 * True is this action type is supported, false if not supported.
63 mlx5_flow_os_action_supported(int action)
66 case RTE_FLOW_ACTION_TYPE_END:
67 case RTE_FLOW_ACTION_TYPE_VOID:
68 case RTE_FLOW_ACTION_TYPE_QUEUE:
69 case RTE_FLOW_ACTION_TYPE_RSS:
80 * Pointer to relevant domain.
84 * NULL (no table object required)
87 * 0 if table_id is 0, negative value otherwise and errno is set.
90 mlx5_flow_os_create_flow_tbl(void *domain, uint32_t table_id, void **table)
102 * Destroy flow table.
105 * Pointer to table to destroy.
108 * 0 on success (silently ignored).
111 mlx5_flow_os_destroy_flow_tbl(void *table)
114 /* Silently ignore */
119 * Create flow action: packet reformat.
122 * Pointer to relevant device context.
124 * Pointer to domain handler.
125 * @param[in] resource
126 * Pointer to action data resource.
128 * Pointer to a valid action on success, NULL otherwise.
132 * 0 on success, or negative value on failure and errno is set.
135 mlx5_flow_os_create_flow_action_packet_reformat(void *ctx, void *domain,
136 void *resource, void **action)
139 RTE_SET_USED(domain);
140 RTE_SET_USED(resource);
141 RTE_SET_USED(action);
147 * Create flow action: modify header.
150 * Pointer to relevant device context.
152 * Pointer to domain handler.
153 * @param[in] resource
154 * Pointer to action data resource.
155 * @param[in] actions_len
156 * Total length of actions data in resource.
158 * Pointer to a valid action on success, NULL otherwise.
162 * 0 on success, or -1 on failure and errno is set.
165 mlx5_flow_os_create_flow_action_modify_header(void *ctx,
168 uint32_t actions_len,
172 RTE_SET_USED(domain);
173 RTE_SET_USED(resource);
174 RTE_SET_USED(actions_len);
175 RTE_SET_USED(action);
181 * Create flow action: destination flow table.
184 * Pointer to destination table object.
186 * Pointer to a valid action on success, NULL otherwise.
189 * 0 on success, or negative value on failure and errno is set.
192 mlx5_flow_os_create_flow_action_dest_flow_tbl(void *tbl_obj, void **action)
194 RTE_SET_USED(tbl_obj);
195 RTE_SET_USED(action);
201 * Create flow action: destination port.
204 * Pointer to domain handler.
206 * Destination port ID.
208 * Pointer to a valid action on success, NULL otherwise.
211 * 0 on success, or negative value on failure and errno is set.
214 mlx5_flow_os_create_flow_action_dest_port(void *domain, uint32_t port_id,
217 RTE_SET_USED(domain);
218 RTE_SET_USED(port_id);
225 * Create flow action: push vlan.
228 * Pointer to domain handler.
229 * @param[in] vlan_tag
232 * Pointer to a valid action on success, NULL otherwise.
235 * 0 on success, or negative value on failure and errno is set.
238 mlx5_flow_os_create_flow_action_push_vlan(void *domain, rte_be32_t vlan_tag,
241 RTE_SET_USED(domain);
242 RTE_SET_USED(vlan_tag);
249 * Create flow action: count.
252 * Pointer to DevX counter object.
254 * Offset of counter in array.
256 * Pointer to a valid action on success, NULL otherwise.
259 * 0 on success, or negative value on failure and errno is set.
262 mlx5_flow_os_create_flow_action_count(void *cnt_obj, uint16_t offset,
265 RTE_SET_USED(cnt_obj);
266 RTE_SET_USED(offset);
273 * Create flow action: tag.
278 * Pointer to a valid action on success, NULL otherwise.
281 * 0 on success, or negative value on failure and errno is set.
284 mlx5_flow_os_create_flow_action_tag(uint32_t tag, void **action)
293 * Create flow action: drop.
296 * Pointer to a valid action on success, NULL otherwise.
299 * 0 on success, or negative value on failure and errno is set.
302 mlx5_flow_os_create_flow_action_drop(void **action)
310 * Create flow action: default miss.
313 * NULL action pointer.
319 mlx5_flow_os_create_flow_action_default_miss(void **action)
322 /* Silently ignore */
327 * Create flow action: sampler
330 * Pointer to sampler attribute
332 * Pointer to a valid action on success, NULL otherwise.
335 * 0 on success, or -1 on failure and errno is set.
338 mlx5_os_flow_dr_create_flow_action_sampler
339 (struct mlx5dv_dr_flow_sampler_attr *attr,
349 * Create flow action: dest_array
352 * Pointer to relevant domain.
353 * @param[in] num_dest
354 * Number of destinations array.
356 * Array of destination attributes.
358 * Pointer to a valid action on success, NULL otherwise.
361 * 0 on success, or -1 on failure and errno is set.
364 mlx5_os_flow_dr_create_flow_action_dest_array
367 struct mlx5dv_dr_action_dest_attr *dests[],
370 RTE_SET_USED(domain);
371 RTE_SET_USED(num_dest);
379 * OS stub for mlx5_flow_adjust_priority() API.
380 * Windows only supports flow priority 0 that cannot be adjusted.
383 * Pointer to the Ethernet device structure.
384 * @param[in] priority
385 * The rule base priority.
386 * @param[in] subpriority
387 * The priority based on the items.
392 static inline uint32_t
393 mlx5_os_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority,
394 uint32_t subpriority)
397 RTE_SET_USED(priority);
398 RTE_SET_USED(subpriority);
403 mlx5_os_flow_dr_sync_domain(void *domain, uint32_t flags)
405 RTE_SET_USED(domain);
411 int mlx5_flow_os_validate_flow_attributes(struct rte_eth_dev *dev,
412 const struct rte_flow_attr *attributes,
414 struct rte_flow_error *error);
415 int mlx5_flow_os_create_flow_matcher(void *ctx,
419 int mlx5_flow_os_destroy_flow_matcher(void *matcher);
420 int mlx5_flow_os_create_flow_action_dest_devx_tir(struct mlx5_devx_obj *tir,
422 int mlx5_flow_os_destroy_flow_action(void *action);
423 int mlx5_flow_os_create_flow(void *matcher, void *match_value,
425 void *actions[], void **flow);
426 int mlx5_flow_os_destroy_flow(void *drv_flow_ptr);
427 #endif /* RTE_PMD_MLX5_FLOW_OS_H_ */