Skip to content

Commit

Permalink
Merge pull request #611 from yishaih/mlx5_dr
Browse files Browse the repository at this point in the history
mlx5: Add support for bulk counters in the DR API over root
  • Loading branch information
yishaih committed Nov 17, 2019
2 parents e9d5a27 + 3956cf7 commit 20c588f
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 14 deletions.
1 change: 1 addition & 0 deletions kernel-headers/rdma/mlx5_user_ioctl_cmds.h
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ enum mlx5_ib_create_flow_attrs {
MLX5_IB_ATTR_CREATE_FLOW_ARR_FLOW_ACTIONS,
MLX5_IB_ATTR_CREATE_FLOW_TAG,
MLX5_IB_ATTR_CREATE_FLOW_ARR_COUNTERS_DEVX,
MLX5_IB_ATTR_CREATE_FLOW_ARR_COUNTERS_DEVX_OFFSET,
};

enum mlx5_ib_destoy_flow_attrs {
Expand Down
8 changes: 7 additions & 1 deletion providers/mlx5/dr_action.c
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,8 @@ int dr_actions_build_ste_arr(struct mlx5dv_dr_matcher *matcher,
int dr_actions_build_attr(struct mlx5dv_dr_matcher *matcher,
struct mlx5dv_dr_action *actions[],
size_t num_actions,
struct mlx5dv_flow_action_attr *attr)
struct mlx5dv_flow_action_attr *attr,
struct mlx5_flow_action_attr_aux *attr_aux)
{
struct mlx5dv_dr_domain *dmn = matcher->tbl->dmn;
int i;
Expand Down Expand Up @@ -704,6 +705,11 @@ int dr_actions_build_attr(struct mlx5dv_dr_matcher *matcher,
case DR_ACTION_TYP_CTR:
attr[i].type = MLX5DV_FLOW_ACTION_COUNTERS_DEVX;
attr[i].obj = actions[i]->ctr.devx_obj;

if (actions[i]->ctr.offset) {
attr_aux[i].type = MLX5_FLOW_ACTION_COUNTER_OFFSET;
attr_aux[i].offset = actions[i]->ctr.offset;
}
break;
case DR_ACTION_TYP_TAG:
attr[i].type = MLX5DV_FLOW_ACTION_TAG;
Expand Down
25 changes: 18 additions & 7 deletions providers/mlx5/dr_rule.c
Original file line number Diff line number Diff line change
Expand Up @@ -1224,6 +1224,7 @@ dr_rule_create_rule_root(struct mlx5dv_dr_matcher *matcher,
struct mlx5dv_dr_action *actions[])
{
struct mlx5dv_flow_action_attr *attr;
struct mlx5_flow_action_attr_aux *attr_aux;
struct mlx5dv_dr_rule *rule;
int ret;

Expand All @@ -1242,27 +1243,37 @@ dr_rule_create_rule_root(struct mlx5dv_dr_matcher *matcher,
goto free_rule;
}

ret = dr_actions_build_attr(matcher, actions, num_actions, attr);
if (ret)
attr_aux = calloc(num_actions, sizeof(*attr_aux));
if (!attr_aux) {
errno = ENOMEM;
goto free_attr;
}

ret = dr_actions_build_attr(matcher, actions, num_actions, attr, attr_aux);
if (ret)
goto free_attr_aux;

ret = dr_rule_add_action_members(rule, num_actions, actions);
if (ret)
goto free_attr;
goto free_attr_aux;

rule->flow = mlx5dv_create_flow(matcher->dv_matcher,
value,
num_actions,
attr);
rule->flow = __mlx5dv_create_flow(matcher->dv_matcher,
value,
num_actions,
attr,
attr_aux);
if (!rule->flow)
goto remove_action_members;

free(attr);
free(attr_aux);

return rule;

remove_action_members:
dr_rule_remove_action_members(rule);
free_attr_aux:
free(attr_aux);
free_attr:
free(attr);
free_rule:
Expand Down
16 changes: 16 additions & 0 deletions providers/mlx5/mlx5.h
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,22 @@ struct mlx5_devx_event_channel {
struct mlx5dv_devx_event_channel dv_event_channel;
};

enum mlx5_flow_action_type {
MLX5_FLOW_ACTION_COUNTER_OFFSET = 1,
};

struct mlx5_flow_action_attr_aux {
enum mlx5_flow_action_type type;
uint32_t offset;
};

struct ibv_flow *
__mlx5dv_create_flow(struct mlx5dv_flow_matcher *flow_matcher,
struct mlx5dv_flow_match_parameters *match_value,
size_t num_actions,
struct mlx5dv_flow_action_attr actions_attr[],
struct mlx5_flow_action_attr_aux actions_attr_aux[]);

extern int mlx5_stall_num_loop;
extern int mlx5_stall_cq_poll_min;
extern int mlx5_stall_cq_poll_max;
Expand Down
3 changes: 2 additions & 1 deletion providers/mlx5/mlx5dv_dr.h
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,8 @@ int dr_actions_build_ste_arr(struct mlx5dv_dr_matcher *matcher,
int dr_actions_build_attr(struct mlx5dv_dr_matcher *matcher,
struct mlx5dv_dr_action *actions[],
size_t num_actions,
struct mlx5dv_flow_action_attr *attr);
struct mlx5dv_flow_action_attr *attr,
struct mlx5_flow_action_attr_aux *attr_aux);

struct dr_match_spec {
uint32_t smac_47_16; /* Source MAC address of incoming packet */
Expand Down
31 changes: 26 additions & 5 deletions providers/mlx5/verbs.c
Original file line number Diff line number Diff line change
Expand Up @@ -4113,10 +4113,11 @@ int mlx5dv_destroy_flow_matcher(struct mlx5dv_flow_matcher *flow_matcher)

#define CREATE_FLOW_MAX_FLOW_ACTIONS_SUPPORTED 8
struct ibv_flow *
mlx5dv_create_flow(struct mlx5dv_flow_matcher *flow_matcher,
struct mlx5dv_flow_match_parameters *match_value,
size_t num_actions,
struct mlx5dv_flow_action_attr actions_attr[])
__mlx5dv_create_flow(struct mlx5dv_flow_matcher *flow_matcher,
struct mlx5dv_flow_match_parameters *match_value,
size_t num_actions,
struct mlx5dv_flow_action_attr actions_attr[],
struct mlx5_flow_action_attr_aux actions_attr_aux[])
{
uint32_t flow_actions[CREATE_FLOW_MAX_FLOW_ACTIONS_SUPPORTED];
struct verbs_flow_action *vaction;
Expand All @@ -4130,7 +4131,7 @@ mlx5dv_create_flow(struct mlx5dv_flow_matcher *flow_matcher,
int i;
DECLARE_COMMAND_BUFFER(cmd, UVERBS_OBJECT_FLOW,
MLX5_IB_METHOD_CREATE_FLOW,
7);
8);
struct ib_uverbs_attr *handle;
enum mlx5dv_flow_action_type type;

Expand Down Expand Up @@ -4198,6 +4199,13 @@ mlx5dv_create_flow(struct mlx5dv_flow_matcher *flow_matcher,
fill_attr_in_objs_arr(cmd,
MLX5_IB_ATTR_CREATE_FLOW_ARR_COUNTERS_DEVX,
&actions_attr[i].obj->handle, 1);

if (actions_attr_aux &&
actions_attr_aux[i].type == MLX5_FLOW_ACTION_COUNTER_OFFSET)
fill_attr_in_ptr_array(cmd,
MLX5_IB_ATTR_CREATE_FLOW_ARR_COUNTERS_DEVX_OFFSET,
&actions_attr_aux[i].offset, 1);

have_counter = true;
break;
default:
Expand All @@ -4223,6 +4231,19 @@ mlx5dv_create_flow(struct mlx5dv_flow_matcher *flow_matcher,
return NULL;
}

struct ibv_flow *
mlx5dv_create_flow(struct mlx5dv_flow_matcher *flow_matcher,
struct mlx5dv_flow_match_parameters *match_value,
size_t num_actions,
struct mlx5dv_flow_action_attr actions_attr[])
{
return __mlx5dv_create_flow(flow_matcher,
match_value,
num_actions,
actions_attr,
NULL);
}

struct mlx5dv_devx_umem *
mlx5dv_devx_umem_reg(struct ibv_context *context, void *addr, size_t size, uint32_t access)
{
Expand Down

0 comments on commit 20c588f

Please sign in to comment.