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_
10 #if defined(HAVE_IBV_FLOW_DV_SUPPORT) || !defined(HAVE_INFINIBAND_VERBS_H)
11 extern const struct mlx5_flow_driver_ops mlx5_flow_dv_drv_ops;
15 * Get OS enforced flow type. MLX5_FLOW_TYPE_MAX means "non enforced type".
18 * Flow type (MLX5_FLOW_TYPE_MAX)
20 static inline enum mlx5_flow_drv_type
21 mlx5_flow_os_get_type(void)
23 return MLX5_FLOW_TYPE_DV;
27 * Check if item type is supported.
33 * True is this item type is supported, false if not supported.
36 mlx5_flow_os_item_supported(int item)
39 case RTE_FLOW_ITEM_TYPE_END:
40 case RTE_FLOW_ITEM_TYPE_VOID:
41 case RTE_FLOW_ITEM_TYPE_ETH:
42 case RTE_FLOW_ITEM_TYPE_IPV4:
43 case RTE_FLOW_ITEM_TYPE_UDP:
51 * Check if action type is supported.
54 * Action type to check.
57 * True is this action type is supported, false if not supported.
60 mlx5_flow_os_action_supported(int action)
63 case RTE_FLOW_ACTION_TYPE_END:
64 case RTE_FLOW_ACTION_TYPE_VOID:
65 case RTE_FLOW_ACTION_TYPE_QUEUE:
66 case RTE_FLOW_ACTION_TYPE_RSS:
77 * Pointer to relevant domain.
81 * NULL (no table object required)
84 * 0 if table_id is 0, negative value otherwise and errno is set.
87 mlx5_flow_os_create_flow_tbl(void *domain, uint32_t table_id, void **table)
102 * Pointer to table to destroy.
105 * 0 on success (silently ignored).
108 mlx5_flow_os_destroy_flow_tbl(void *table)
111 /* Silently ignore */
116 * Create flow action: packet reformat.
119 * Pointer to relevant device context.
121 * Pointer to domain handler.
122 * @param[in] resource
123 * Pointer to action data resource.
125 * Pointer to a valid action on success, NULL otherwise.
129 * 0 on success, or negative value on failure and errno is set.
132 mlx5_flow_os_create_flow_action_packet_reformat(void *ctx, void *domain,
133 void *resource, void **action)
136 RTE_SET_USED(domain);
137 RTE_SET_USED(resource);
138 RTE_SET_USED(action);
144 * Create flow action: modify header.
147 * Pointer to relevant device context.
149 * Pointer to domain handler.
150 * @param[in] resource
151 * Pointer to action data resource.
152 * @param[in] actions_len
153 * Total length of actions data in resource.
155 * Pointer to a valid action on success, NULL otherwise.
159 * 0 on success, or -1 on failure and errno is set.
162 mlx5_flow_os_create_flow_action_modify_header(void *ctx,
165 uint32_t actions_len,
169 RTE_SET_USED(domain);
170 RTE_SET_USED(resource);
171 RTE_SET_USED(actions_len);
172 RTE_SET_USED(action);
178 * Create flow action: destination flow table.
181 * Pointer to destination table object.
183 * Pointer to a valid action on success, NULL otherwise.
186 * 0 on success, or negative value on failure and errno is set.
189 mlx5_flow_os_create_flow_action_dest_flow_tbl(void *tbl_obj, void **action)
191 RTE_SET_USED(tbl_obj);
192 RTE_SET_USED(action);
198 * Create flow action: destination port.
201 * Pointer to domain handler.
203 * Destination port ID.
205 * Pointer to a valid action on success, NULL otherwise.
208 * 0 on success, or negative value on failure and errno is set.
211 mlx5_flow_os_create_flow_action_dest_port(void *domain, uint32_t port_id,
214 RTE_SET_USED(domain);
215 RTE_SET_USED(port_id);
222 * Create flow action: push vlan.
225 * Pointer to domain handler.
226 * @param[in] vlan_tag
229 * Pointer to a valid action on success, NULL otherwise.
232 * 0 on success, or negative value on failure and errno is set.
235 mlx5_flow_os_create_flow_action_push_vlan(void *domain, rte_be32_t vlan_tag,
238 RTE_SET_USED(domain);
239 RTE_SET_USED(vlan_tag);
246 * Create flow action: count.
249 * Pointer to DevX counter object.
251 * Offset of counter in array.
253 * Pointer to a valid action on success, NULL otherwise.
256 * 0 on success, or negative value on failure and errno is set.
259 mlx5_flow_os_create_flow_action_count(void *cnt_obj, uint16_t offset,
262 RTE_SET_USED(cnt_obj);
263 RTE_SET_USED(offset);
270 * Create flow action: tag.
275 * Pointer to a valid action on success, NULL otherwise.
278 * 0 on success, or negative value on failure and errno is set.
281 mlx5_flow_os_create_flow_action_tag(uint32_t tag, void **action)
290 * Create flow action: drop.
293 * Pointer to a valid action on success, NULL otherwise.
296 * 0 on success, or negative value on failure and errno is set.
299 mlx5_flow_os_create_flow_action_drop(void **action)
307 * Create flow action: default miss.
310 * NULL action pointer.
316 mlx5_flow_os_create_flow_action_default_miss(void **action)
319 /* Silently ignore */
324 * OS stub for mlx5_flow_adjust_priority() API.
325 * Windows only supports flow priority 0 that cannot be adjusted.
328 * Pointer to the Ethernet device structure.
329 * @param[in] priority
330 * The rule base priority.
331 * @param[in] subpriority
332 * The priority based on the items.
337 static inline uint32_t
338 mlx5_os_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority,
339 uint32_t subpriority)
342 RTE_SET_USED(priority);
343 RTE_SET_USED(subpriority);
347 int mlx5_flow_os_validate_flow_attributes(struct rte_eth_dev *dev,
348 const struct rte_flow_attr *attributes,
350 struct rte_flow_error *error);
351 int mlx5_flow_os_create_flow_matcher(void *ctx,
355 int mlx5_flow_os_destroy_flow_matcher(void *matcher);
356 int mlx5_flow_os_create_flow_action_dest_devx_tir(struct mlx5_devx_obj *tir,
358 int mlx5_flow_os_destroy_flow_action(void *action);
359 int mlx5_flow_os_create_flow(void *matcher, void *match_value,
361 void *actions[], void **flow);
362 int mlx5_flow_os_destroy_flow(void *drv_flow_ptr);
363 #endif /* RTE_PMD_MLX5_FLOW_OS_H_ */