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:
47 case RTE_FLOW_ITEM_TYPE_VLAN:
55 * Check if action type is supported.
58 * Action type to check.
61 * True is this action type is supported, false if not supported.
64 mlx5_flow_os_action_supported(int action)
67 case RTE_FLOW_ACTION_TYPE_END:
68 case RTE_FLOW_ACTION_TYPE_VOID:
69 case RTE_FLOW_ACTION_TYPE_QUEUE:
70 case RTE_FLOW_ACTION_TYPE_RSS:
81 * Pointer to relevant domain.
85 * NULL (no table object required)
88 * 0 if table_id is 0, negative value otherwise and errno is set.
91 mlx5_flow_os_create_flow_tbl(void *domain, uint32_t table_id, void **table)
103 * Destroy flow table.
106 * Pointer to table to destroy.
109 * 0 on success (silently ignored).
112 mlx5_flow_os_destroy_flow_tbl(void *table)
115 /* Silently ignore */
120 * Create flow action: packet reformat.
123 * Pointer to relevant device context.
125 * Pointer to domain handler.
126 * @param[in] resource
127 * Pointer to action data resource.
129 * Pointer to a valid action on success, NULL otherwise.
133 * 0 on success, or negative value on failure and errno is set.
136 mlx5_flow_os_create_flow_action_packet_reformat(void *ctx, void *domain,
137 void *resource, void **action)
140 RTE_SET_USED(domain);
141 RTE_SET_USED(resource);
142 RTE_SET_USED(action);
148 * Create flow action: modify header.
151 * Pointer to relevant device context.
153 * Pointer to domain handler.
154 * @param[in] resource
155 * Pointer to action data resource.
156 * @param[in] actions_len
157 * Total length of actions data in resource.
159 * Pointer to a valid action on success, NULL otherwise.
163 * 0 on success, or -1 on failure and errno is set.
166 mlx5_flow_os_create_flow_action_modify_header(void *ctx,
169 uint32_t actions_len,
173 RTE_SET_USED(domain);
174 RTE_SET_USED(resource);
175 RTE_SET_USED(actions_len);
176 RTE_SET_USED(action);
182 * Create flow action: destination flow table.
185 * Pointer to destination table object.
187 * Pointer to a valid action on success, NULL otherwise.
190 * 0 on success, or negative value on failure and errno is set.
193 mlx5_flow_os_create_flow_action_dest_flow_tbl(void *tbl_obj, void **action)
195 RTE_SET_USED(tbl_obj);
196 RTE_SET_USED(action);
202 * Create flow action: destination port.
205 * Pointer to domain handler.
207 * Destination port ID.
209 * Pointer to a valid action on success, NULL otherwise.
212 * 0 on success, or negative value on failure and errno is set.
215 mlx5_flow_os_create_flow_action_dest_port(void *domain, uint32_t port_id,
218 RTE_SET_USED(domain);
219 RTE_SET_USED(port_id);
226 * Create flow action: push vlan.
229 * Pointer to domain handler.
230 * @param[in] vlan_tag
233 * Pointer to a valid action on success, NULL otherwise.
236 * 0 on success, or negative value on failure and errno is set.
239 mlx5_flow_os_create_flow_action_push_vlan(void *domain, rte_be32_t vlan_tag,
242 RTE_SET_USED(domain);
243 RTE_SET_USED(vlan_tag);
250 * Create flow action: count.
253 * Pointer to DevX counter object.
255 * Offset of counter in array.
257 * Pointer to a valid action on success, NULL otherwise.
260 * 0 on success, or negative value on failure and errno is set.
263 mlx5_flow_os_create_flow_action_count(void *cnt_obj, uint16_t offset,
266 RTE_SET_USED(cnt_obj);
267 RTE_SET_USED(offset);
274 * Create flow action: tag.
279 * Pointer to a valid action on success, NULL otherwise.
282 * 0 on success, or negative value on failure and errno is set.
285 mlx5_flow_os_create_flow_action_tag(uint32_t tag, void **action)
294 * Create flow action: drop.
297 * Pointer to a valid action on success, NULL otherwise.
300 * 0 on success, or negative value on failure and errno is set.
303 mlx5_flow_os_create_flow_action_drop(void **action)
311 * Create flow action: default miss.
314 * NULL action pointer.
320 mlx5_flow_os_create_flow_action_default_miss(void **action)
323 /* Silently ignore */
328 * Create flow action: sampler
331 * Pointer to sampler attribute
333 * Pointer to a valid action on success, NULL otherwise.
336 * 0 on success, or -1 on failure and errno is set.
339 mlx5_os_flow_dr_create_flow_action_sampler
340 (struct mlx5dv_dr_flow_sampler_attr *attr,
350 * Create flow action: dest_array
353 * Pointer to relevant domain.
354 * @param[in] num_dest
355 * Number of destinations array.
357 * Array of destination attributes.
359 * Pointer to a valid action on success, NULL otherwise.
362 * 0 on success, or -1 on failure and errno is set.
365 mlx5_os_flow_dr_create_flow_action_dest_array
368 struct mlx5dv_dr_action_dest_attr *dests[],
371 RTE_SET_USED(domain);
372 RTE_SET_USED(num_dest);
380 * OS stub for mlx5_flow_adjust_priority() API.
381 * Windows only supports flow priority 0 that cannot be adjusted.
384 * Pointer to the Ethernet device structure.
385 * @param[in] priority
386 * The rule base priority.
387 * @param[in] subpriority
388 * The priority based on the items.
393 static inline uint32_t
394 mlx5_os_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority,
395 uint32_t subpriority)
398 RTE_SET_USED(priority);
399 RTE_SET_USED(subpriority);
404 mlx5_os_flow_dr_sync_domain(void *domain, uint32_t flags)
406 RTE_SET_USED(domain);
412 int mlx5_flow_os_validate_flow_attributes(struct rte_eth_dev *dev,
413 const struct rte_flow_attr *attributes,
415 struct rte_flow_error *error);
416 int mlx5_flow_os_create_flow_matcher(void *ctx,
420 int mlx5_flow_os_destroy_flow_matcher(void *matcher);
421 int mlx5_flow_os_create_flow_action_dest_devx_tir(struct mlx5_devx_obj *tir,
423 int mlx5_flow_os_destroy_flow_action(void *action);
424 int mlx5_flow_os_create_flow(void *matcher, void *match_value,
426 void *actions[], void **flow);
427 int mlx5_flow_os_destroy_flow(void *drv_flow_ptr);
428 #endif /* RTE_PMD_MLX5_FLOW_OS_H_ */