Skip to content

Commit 1d19449

Browse files
OphirMunkFerruh Yigit
authored andcommitted
net/mlx5: create flow rule on Windows
This commit implements mlx5_flow_os_create_flow() API. It is equivalent to Linux rdma-core implementation. The API receives the matcher mask, matcher value and an array of actions. They are copied into a PRM-like struct devx_fs_rule_add_in. Then glue API devx_fs_rule_add() is called. Signed-off-by: Ophir Munk <ophirmu@nvidia.com> Acked-by: Matan Azrad <matan@nvidia.com>
1 parent 68e2859 commit 1d19449

File tree

2 files changed

+42
-10
lines changed

2 files changed

+42
-10
lines changed

drivers/common/mlx5/mlx5_prm.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -825,6 +825,12 @@ struct mlx5_ifc_fte_match_param_bits {
825825
#endif
826826
};
827827

828+
struct mlx5_ifc_dest_format_struct_bits {
829+
u8 destination_type[0x8];
830+
u8 destination_id[0x18];
831+
u8 reserved_0[0x20];
832+
};
833+
828834
enum {
829835
MLX5_MATCH_CRITERIA_ENABLE_OUTER_BIT,
830836
MLX5_MATCH_CRITERIA_ENABLE_MISC_BIT,

drivers/net/mlx5/windows/mlx5_flow_os.c

Lines changed: 36 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -187,13 +187,41 @@ mlx5_flow_os_create_flow(void *matcher, void *match_value,
187187
size_t num_actions,
188188
void *actions[], void **flow)
189189
{
190-
RTE_SET_USED(matcher);
191-
RTE_SET_USED(match_value);
192-
RTE_SET_USED(num_actions);
193-
RTE_SET_USED(actions);
194-
*flow = NULL;
195-
rte_errno = ENOTSUP;
196-
return -rte_errno;
190+
struct mlx5_action *action;
191+
int i;
192+
struct mlx5_matcher *mlx5_matcher = matcher;
193+
struct mlx5_flow_dv_match_params *mlx5_match_value = match_value;
194+
uint32_t in[MLX5_ST_SZ_DW(devx_fs_rule_add_in)] = {0};
195+
void *matcher_c = MLX5_ADDR_OF(devx_fs_rule_add_in, in,
196+
match_criteria);
197+
void *matcher_v = MLX5_ADDR_OF(devx_fs_rule_add_in, in,
198+
match_value);
199+
200+
MLX5_ASSERT(mlx5_matcher->ctx);
201+
memcpy(matcher_c, mlx5_matcher->match_buf,
202+
mlx5_match_value->size);
203+
/* Use mlx5_match_value->size for match criteria */
204+
memcpy(matcher_v, mlx5_match_value->buf,
205+
mlx5_match_value->size);
206+
for (i = 0; i < num_actions; i++) {
207+
action = actions[i];
208+
switch (action->type) {
209+
case MLX5_FLOW_CONTEXT_DEST_TYPE_TIR:
210+
MLX5_SET(devx_fs_rule_add_in, in,
211+
dest.destination_type,
212+
MLX5_FLOW_CONTEXT_DEST_TYPE_TIR);
213+
MLX5_SET(devx_fs_rule_add_in, in,
214+
dest.destination_id,
215+
action->dest_tir.id);
216+
break;
217+
default:
218+
break;
219+
}
220+
MLX5_SET(devx_fs_rule_add_in, in, match_criteria_enable,
221+
MLX5_MATCH_OUTER_HEADERS);
222+
}
223+
*flow = mlx5_glue->devx_fs_rule_add(mlx5_matcher->ctx, in, sizeof(in));
224+
return (*flow) ? 0 : -1;
197225
}
198226

199227
/**
@@ -208,7 +236,5 @@ mlx5_flow_os_create_flow(void *matcher, void *match_value,
208236
int
209237
mlx5_flow_os_destroy_flow(void *drv_flow_ptr)
210238
{
211-
RTE_SET_USED(dev_flow_ptr);
212-
rte_errno = ENOTSUP;
213-
return -rte_errno;
239+
return mlx5_glue->devx_fs_rule_del(drv_flow_ptr);
214240
}

0 commit comments

Comments
 (0)