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;
13 extern const struct mlx5_flow_driver_ops mlx5_flow_hw_drv_ops;
17 * Get OS enforced flow type. MLX5_FLOW_TYPE_MAX means "non enforced type".
20 * Flow type (MLX5_FLOW_TYPE_MAX)
22 static inline enum mlx5_flow_drv_type
23 mlx5_flow_os_get_type(void)
25 return MLX5_FLOW_TYPE_DV;
29 * Check if item type is supported.
35 * True is this item type is supported, false if not supported.
38 mlx5_flow_os_item_supported(int item)
41 case RTE_FLOW_ITEM_TYPE_END:
42 case RTE_FLOW_ITEM_TYPE_VOID:
43 case RTE_FLOW_ITEM_TYPE_ETH:
44 case RTE_FLOW_ITEM_TYPE_IPV4:
45 case RTE_FLOW_ITEM_TYPE_UDP:
46 case RTE_FLOW_ITEM_TYPE_TCP:
47 case RTE_FLOW_ITEM_TYPE_IPV6:
48 case RTE_FLOW_ITEM_TYPE_VLAN:
56 * Check if action type is supported.
59 * Action type to check.
62 * True is this action type is supported, false if not supported.
65 mlx5_flow_os_action_supported(int action)
68 case RTE_FLOW_ACTION_TYPE_END:
69 case RTE_FLOW_ACTION_TYPE_VOID:
70 case RTE_FLOW_ACTION_TYPE_QUEUE:
71 case RTE_FLOW_ACTION_TYPE_RSS:
82 * Pointer to relevant domain.
86 * NULL (no table object required)
89 * 0 if table_id is 0, negative value otherwise and errno is set.
92 mlx5_flow_os_create_flow_tbl(void *domain, uint32_t table_id, void **table)
104 * Destroy flow table.
107 * Pointer to table to destroy.
110 * 0 on success (silently ignored).
113 mlx5_flow_os_destroy_flow_tbl(void *table)
116 /* Silently ignore */
121 * Create flow action: packet reformat.
124 * Pointer to relevant device context.
126 * Pointer to domain handler.
127 * @param[in] resource
128 * Pointer to action data resource.
130 * Pointer to a valid action on success, NULL otherwise.
134 * 0 on success, or negative value on failure and errno is set.
137 mlx5_flow_os_create_flow_action_packet_reformat(void *ctx, void *domain,
138 void *resource, void **action)
141 RTE_SET_USED(domain);
142 RTE_SET_USED(resource);
143 RTE_SET_USED(action);
149 * Create flow action: modify header.
152 * Pointer to relevant device context.
154 * Pointer to domain handler.
155 * @param[in] resource
156 * Pointer to action data resource.
157 * @param[in] actions_len
158 * Total length of actions data in resource.
160 * Pointer to a valid action on success, NULL otherwise.
164 * 0 on success, or -1 on failure and errno is set.
167 mlx5_flow_os_create_flow_action_modify_header(void *ctx,
170 uint32_t actions_len,
174 RTE_SET_USED(domain);
175 RTE_SET_USED(resource);
176 RTE_SET_USED(actions_len);
177 RTE_SET_USED(action);
183 * Create flow action: destination flow table.
186 * Pointer to destination table object.
188 * Pointer to a valid action on success, NULL otherwise.
191 * 0 on success, or negative value on failure and errno is set.
194 mlx5_flow_os_create_flow_action_dest_flow_tbl(void *tbl_obj, void **action)
196 RTE_SET_USED(tbl_obj);
197 RTE_SET_USED(action);
203 * Create flow action: destination port.
206 * Pointer to domain handler.
208 * Destination port ID.
210 * Pointer to a valid action on success, NULL otherwise.
213 * 0 on success, or negative value on failure and errno is set.
216 mlx5_flow_os_create_flow_action_dest_port(void *domain, uint32_t port_id,
219 RTE_SET_USED(domain);
220 RTE_SET_USED(port_id);
227 * Create flow action: push vlan.
230 * Pointer to domain handler.
231 * @param[in] vlan_tag
234 * Pointer to a valid action on success, NULL otherwise.
237 * 0 on success, or negative value on failure and errno is set.
240 mlx5_flow_os_create_flow_action_push_vlan(void *domain, rte_be32_t vlan_tag,
243 RTE_SET_USED(domain);
244 RTE_SET_USED(vlan_tag);
251 * Create flow action: count.
254 * Pointer to DevX counter object.
256 * Offset of counter in array.
258 * Pointer to a valid action on success, NULL otherwise.
261 * 0 on success, or negative value on failure and errno is set.
264 mlx5_flow_os_create_flow_action_count(void *cnt_obj, uint16_t offset,
267 RTE_SET_USED(cnt_obj);
268 RTE_SET_USED(offset);
275 * Create flow action: tag.
280 * Pointer to a valid action on success, NULL otherwise.
283 * 0 on success, or negative value on failure and errno is set.
286 mlx5_flow_os_create_flow_action_tag(uint32_t tag, void **action)
295 * Create flow action: drop.
298 * Pointer to a valid action on success, NULL otherwise.
301 * 0 on success, or negative value on failure and errno is set.
304 mlx5_flow_os_create_flow_action_drop(void **action)
312 * Create flow action: default miss.
315 * NULL action pointer.
321 mlx5_flow_os_create_flow_action_default_miss(void **action)
324 /* Silently ignore */
329 * Create flow action: sampler
332 * Pointer to sampler attribute
334 * Pointer to a valid action on success, NULL otherwise.
337 * 0 on success, or -1 on failure and errno is set.
340 mlx5_os_flow_dr_create_flow_action_sampler
341 (struct mlx5dv_dr_flow_sampler_attr *attr,
351 * Create flow action: dest_array
354 * Pointer to relevant domain.
355 * @param[in] num_dest
356 * Number of destinations array.
358 * Array of destination attributes.
360 * Pointer to a valid action on success, NULL otherwise.
363 * 0 on success, or -1 on failure and errno is set.
366 mlx5_os_flow_dr_create_flow_action_dest_array
369 struct mlx5dv_dr_action_dest_attr *dests[],
372 RTE_SET_USED(domain);
373 RTE_SET_USED(num_dest);
381 * OS stub for mlx5_flow_adjust_priority() API.
382 * Windows only supports flow priority 0 that cannot be adjusted.
385 * Pointer to the Ethernet device structure.
386 * @param[in] priority
387 * The rule base priority.
388 * @param[in] subpriority
389 * The priority based on the items.
394 static inline uint32_t
395 mlx5_os_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority,
396 uint32_t subpriority)
399 RTE_SET_USED(priority);
400 RTE_SET_USED(subpriority);
405 mlx5_os_flow_dr_sync_domain(void *domain, uint32_t flags)
407 RTE_SET_USED(domain);
413 int mlx5_flow_os_validate_flow_attributes(struct rte_eth_dev *dev,
414 const struct rte_flow_attr *attributes,
416 struct rte_flow_error *error);
417 int mlx5_flow_os_create_flow_matcher(void *ctx,
421 int mlx5_flow_os_destroy_flow_matcher(void *matcher);
422 int mlx5_flow_os_create_flow_action_dest_devx_tir(struct mlx5_devx_obj *tir,
424 int mlx5_flow_os_destroy_flow_action(void *action);
425 int mlx5_flow_os_create_flow(void *matcher, void *match_value,
427 void *actions[], void **flow);
428 int mlx5_flow_os_destroy_flow(void *drv_flow_ptr);
429 #endif /* RTE_PMD_MLX5_FLOW_OS_H_ */