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:
52 * Check if action type is supported.
55 * Action type to check.
58 * True is this action type is supported, false if not supported.
61 mlx5_flow_os_action_supported(int action)
64 case RTE_FLOW_ACTION_TYPE_END:
65 case RTE_FLOW_ACTION_TYPE_VOID:
66 case RTE_FLOW_ACTION_TYPE_QUEUE:
67 case RTE_FLOW_ACTION_TYPE_RSS:
78 * Pointer to relevant domain.
82 * NULL (no table object required)
85 * 0 if table_id is 0, negative value otherwise and errno is set.
88 mlx5_flow_os_create_flow_tbl(void *domain, uint32_t table_id, void **table)
100 * Destroy flow table.
103 * Pointer to table to destroy.
106 * 0 on success (silently ignored).
109 mlx5_flow_os_destroy_flow_tbl(void *table)
112 /* Silently ignore */
117 * Create flow action: packet reformat.
120 * Pointer to relevant device context.
122 * Pointer to domain handler.
123 * @param[in] resource
124 * Pointer to action data resource.
126 * Pointer to a valid action on success, NULL otherwise.
130 * 0 on success, or negative value on failure and errno is set.
133 mlx5_flow_os_create_flow_action_packet_reformat(void *ctx, void *domain,
134 void *resource, void **action)
137 RTE_SET_USED(domain);
138 RTE_SET_USED(resource);
139 RTE_SET_USED(action);
145 * Create flow action: modify header.
148 * Pointer to relevant device context.
150 * Pointer to domain handler.
151 * @param[in] resource
152 * Pointer to action data resource.
153 * @param[in] actions_len
154 * Total length of actions data in resource.
156 * Pointer to a valid action on success, NULL otherwise.
160 * 0 on success, or -1 on failure and errno is set.
163 mlx5_flow_os_create_flow_action_modify_header(void *ctx,
166 uint32_t actions_len,
170 RTE_SET_USED(domain);
171 RTE_SET_USED(resource);
172 RTE_SET_USED(actions_len);
173 RTE_SET_USED(action);
179 * Create flow action: destination flow table.
182 * Pointer to destination table object.
184 * Pointer to a valid action on success, NULL otherwise.
187 * 0 on success, or negative value on failure and errno is set.
190 mlx5_flow_os_create_flow_action_dest_flow_tbl(void *tbl_obj, void **action)
192 RTE_SET_USED(tbl_obj);
193 RTE_SET_USED(action);
199 * Create flow action: destination port.
202 * Pointer to domain handler.
204 * Destination port ID.
206 * Pointer to a valid action on success, NULL otherwise.
209 * 0 on success, or negative value on failure and errno is set.
212 mlx5_flow_os_create_flow_action_dest_port(void *domain, uint32_t port_id,
215 RTE_SET_USED(domain);
216 RTE_SET_USED(port_id);
223 * Create flow action: push vlan.
226 * Pointer to domain handler.
227 * @param[in] vlan_tag
230 * Pointer to a valid action on success, NULL otherwise.
233 * 0 on success, or negative value on failure and errno is set.
236 mlx5_flow_os_create_flow_action_push_vlan(void *domain, rte_be32_t vlan_tag,
239 RTE_SET_USED(domain);
240 RTE_SET_USED(vlan_tag);
247 * Create flow action: count.
250 * Pointer to DevX counter object.
252 * Offset of counter in array.
254 * Pointer to a valid action on success, NULL otherwise.
257 * 0 on success, or negative value on failure and errno is set.
260 mlx5_flow_os_create_flow_action_count(void *cnt_obj, uint16_t offset,
263 RTE_SET_USED(cnt_obj);
264 RTE_SET_USED(offset);
271 * Create flow action: tag.
276 * Pointer to a valid action on success, NULL otherwise.
279 * 0 on success, or negative value on failure and errno is set.
282 mlx5_flow_os_create_flow_action_tag(uint32_t tag, void **action)
291 * Create flow action: drop.
294 * Pointer to a valid action on success, NULL otherwise.
297 * 0 on success, or negative value on failure and errno is set.
300 mlx5_flow_os_create_flow_action_drop(void **action)
308 * Create flow action: default miss.
311 * NULL action pointer.
317 mlx5_flow_os_create_flow_action_default_miss(void **action)
320 /* Silently ignore */
325 * OS stub for mlx5_flow_adjust_priority() API.
326 * Windows only supports flow priority 0 that cannot be adjusted.
329 * Pointer to the Ethernet device structure.
330 * @param[in] priority
331 * The rule base priority.
332 * @param[in] subpriority
333 * The priority based on the items.
338 static inline uint32_t
339 mlx5_os_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority,
340 uint32_t subpriority)
343 RTE_SET_USED(priority);
344 RTE_SET_USED(subpriority);
349 mlx5_os_flow_dr_sync_domain(void *domain, uint32_t flags)
351 RTE_SET_USED(domain);
357 int mlx5_flow_os_validate_flow_attributes(struct rte_eth_dev *dev,
358 const struct rte_flow_attr *attributes,
360 struct rte_flow_error *error);
361 int mlx5_flow_os_create_flow_matcher(void *ctx,
365 int mlx5_flow_os_destroy_flow_matcher(void *matcher);
366 int mlx5_flow_os_create_flow_action_dest_devx_tir(struct mlx5_devx_obj *tir,
368 int mlx5_flow_os_destroy_flow_action(void *action);
369 int mlx5_flow_os_create_flow(void *matcher, void *match_value,
371 void *actions[], void **flow);
372 int mlx5_flow_os_destroy_flow(void *drv_flow_ptr);
373 #endif /* RTE_PMD_MLX5_FLOW_OS_H_ */