net/mlx5: Add flow context for flow tag
Refactor the flow data structures, add new flow_context and move flow_tag into it, as flow_tag doesn't belong to the rule action. Signed-off-by: Jianbo Liu <jianbol@mellanox.com> Reviewed-by: Mark Bloch <markb@mellanox.com> Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
这个提交包含在:
@@ -65,11 +65,12 @@ static const struct uverbs_attr_spec mlx5_ib_flow_type[] = {
|
||||
static int UVERBS_HANDLER(MLX5_IB_METHOD_CREATE_FLOW)(
|
||||
struct uverbs_attr_bundle *attrs)
|
||||
{
|
||||
struct mlx5_flow_act flow_act = {.flow_tag = MLX5_FS_DEFAULT_FLOW_TAG};
|
||||
struct mlx5_flow_context flow_context = {.flow_tag = MLX5_FS_DEFAULT_FLOW_TAG};
|
||||
struct mlx5_ib_flow_handler *flow_handler;
|
||||
struct mlx5_ib_flow_matcher *fs_matcher;
|
||||
struct ib_uobject **arr_flow_actions;
|
||||
struct ib_uflow_resources *uflow_res;
|
||||
struct mlx5_flow_act flow_act = {};
|
||||
void *devx_obj;
|
||||
int dest_id, dest_type;
|
||||
void *cmd_in;
|
||||
@@ -172,17 +173,19 @@ static int UVERBS_HANDLER(MLX5_IB_METHOD_CREATE_FLOW)(
|
||||
arr_flow_actions[i]->object);
|
||||
}
|
||||
|
||||
ret = uverbs_copy_from(&flow_act.flow_tag, attrs,
|
||||
ret = uverbs_copy_from(&flow_context.flow_tag, attrs,
|
||||
MLX5_IB_ATTR_CREATE_FLOW_TAG);
|
||||
if (!ret) {
|
||||
if (flow_act.flow_tag >= BIT(24)) {
|
||||
if (flow_context.flow_tag >= BIT(24)) {
|
||||
ret = -EINVAL;
|
||||
goto err_out;
|
||||
}
|
||||
flow_act.flags |= FLOW_ACT_HAS_TAG;
|
||||
flow_context.flags |= FLOW_CONTEXT_HAS_TAG;
|
||||
}
|
||||
|
||||
flow_handler = mlx5_ib_raw_fs_rule_add(dev, fs_matcher, &flow_act,
|
||||
flow_handler = mlx5_ib_raw_fs_rule_add(dev, fs_matcher,
|
||||
&flow_context,
|
||||
&flow_act,
|
||||
counter_id,
|
||||
cmd_in, inlen,
|
||||
dest_id, dest_type);
|
||||
|
@@ -2666,11 +2666,15 @@ int parse_flow_flow_action(struct mlx5_ib_flow_action *maction,
|
||||
}
|
||||
}
|
||||
|
||||
static int parse_flow_attr(struct mlx5_core_dev *mdev, u32 *match_c,
|
||||
u32 *match_v, const union ib_flow_spec *ib_spec,
|
||||
static int parse_flow_attr(struct mlx5_core_dev *mdev,
|
||||
struct mlx5_flow_spec *spec,
|
||||
const union ib_flow_spec *ib_spec,
|
||||
const struct ib_flow_attr *flow_attr,
|
||||
struct mlx5_flow_act *action, u32 prev_type)
|
||||
{
|
||||
struct mlx5_flow_context *flow_context = &spec->flow_context;
|
||||
u32 *match_c = spec->match_criteria;
|
||||
u32 *match_v = spec->match_value;
|
||||
void *misc_params_c = MLX5_ADDR_OF(fte_match_param, match_c,
|
||||
misc_parameters);
|
||||
void *misc_params_v = MLX5_ADDR_OF(fte_match_param, match_v,
|
||||
@@ -2989,8 +2993,8 @@ static int parse_flow_attr(struct mlx5_core_dev *mdev, u32 *match_c,
|
||||
if (ib_spec->flow_tag.tag_id >= BIT(24))
|
||||
return -EINVAL;
|
||||
|
||||
action->flow_tag = ib_spec->flow_tag.tag_id;
|
||||
action->flags |= FLOW_ACT_HAS_TAG;
|
||||
flow_context->flow_tag = ib_spec->flow_tag.tag_id;
|
||||
flow_context->flags |= FLOW_CONTEXT_HAS_TAG;
|
||||
break;
|
||||
case IB_FLOW_SPEC_ACTION_DROP:
|
||||
if (FIELDS_NOT_SUPPORTED(ib_spec->drop,
|
||||
@@ -3084,7 +3088,8 @@ is_valid_esp_aes_gcm(struct mlx5_core_dev *mdev,
|
||||
return VALID_SPEC_NA;
|
||||
|
||||
return is_crypto && is_ipsec &&
|
||||
(!egress || (!is_drop && !(flow_act->flags & FLOW_ACT_HAS_TAG))) ?
|
||||
(!egress || (!is_drop &&
|
||||
!(spec->flow_context.flags & FLOW_CONTEXT_HAS_TAG))) ?
|
||||
VALID_SPEC_VALID : VALID_SPEC_INVALID;
|
||||
}
|
||||
|
||||
@@ -3473,7 +3478,7 @@ static struct mlx5_ib_flow_handler *_create_flow_rule(struct mlx5_ib_dev *dev,
|
||||
{
|
||||
struct mlx5_flow_table *ft = ft_prio->flow_table;
|
||||
struct mlx5_ib_flow_handler *handler;
|
||||
struct mlx5_flow_act flow_act = {.flow_tag = MLX5_FS_DEFAULT_FLOW_TAG};
|
||||
struct mlx5_flow_act flow_act = {};
|
||||
struct mlx5_flow_spec *spec;
|
||||
struct mlx5_flow_destination dest_arr[2] = {};
|
||||
struct mlx5_flow_destination *rule_dst = dest_arr;
|
||||
@@ -3504,8 +3509,7 @@ static struct mlx5_ib_flow_handler *_create_flow_rule(struct mlx5_ib_dev *dev,
|
||||
}
|
||||
|
||||
for (spec_index = 0; spec_index < flow_attr->num_of_specs; spec_index++) {
|
||||
err = parse_flow_attr(dev->mdev, spec->match_criteria,
|
||||
spec->match_value,
|
||||
err = parse_flow_attr(dev->mdev, spec,
|
||||
ib_flow, flow_attr, &flow_act,
|
||||
prev_type);
|
||||
if (err < 0)
|
||||
@@ -3572,11 +3576,11 @@ static struct mlx5_ib_flow_handler *_create_flow_rule(struct mlx5_ib_dev *dev,
|
||||
MLX5_FLOW_CONTEXT_ACTION_FWD_NEXT_PRIO;
|
||||
}
|
||||
|
||||
if ((flow_act.flags & FLOW_ACT_HAS_TAG) &&
|
||||
if ((spec->flow_context.flags & FLOW_CONTEXT_HAS_TAG) &&
|
||||
(flow_attr->type == IB_FLOW_ATTR_ALL_DEFAULT ||
|
||||
flow_attr->type == IB_FLOW_ATTR_MC_DEFAULT)) {
|
||||
mlx5_ib_warn(dev, "Flow tag %u and attribute type %x isn't allowed in leftovers\n",
|
||||
flow_act.flow_tag, flow_attr->type);
|
||||
spec->flow_context.flow_tag, flow_attr->type);
|
||||
err = -EINVAL;
|
||||
goto free;
|
||||
}
|
||||
@@ -3947,6 +3951,7 @@ _create_raw_flow_rule(struct mlx5_ib_dev *dev,
|
||||
struct mlx5_ib_flow_prio *ft_prio,
|
||||
struct mlx5_flow_destination *dst,
|
||||
struct mlx5_ib_flow_matcher *fs_matcher,
|
||||
struct mlx5_flow_context *flow_context,
|
||||
struct mlx5_flow_act *flow_act,
|
||||
void *cmd_in, int inlen,
|
||||
int dst_num)
|
||||
@@ -3969,6 +3974,7 @@ _create_raw_flow_rule(struct mlx5_ib_dev *dev,
|
||||
memcpy(spec->match_criteria, fs_matcher->matcher_mask.match_params,
|
||||
fs_matcher->mask_len);
|
||||
spec->match_criteria_enable = fs_matcher->match_criteria_enable;
|
||||
spec->flow_context = *flow_context;
|
||||
|
||||
handler->rule = mlx5_add_flow_rules(ft, spec,
|
||||
flow_act, dst, dst_num);
|
||||
@@ -4033,6 +4039,7 @@ static bool raw_fs_is_multicast(struct mlx5_ib_flow_matcher *fs_matcher,
|
||||
struct mlx5_ib_flow_handler *
|
||||
mlx5_ib_raw_fs_rule_add(struct mlx5_ib_dev *dev,
|
||||
struct mlx5_ib_flow_matcher *fs_matcher,
|
||||
struct mlx5_flow_context *flow_context,
|
||||
struct mlx5_flow_act *flow_act,
|
||||
u32 counter_id,
|
||||
void *cmd_in, int inlen, int dest_id,
|
||||
@@ -4085,7 +4092,8 @@ mlx5_ib_raw_fs_rule_add(struct mlx5_ib_dev *dev,
|
||||
dst_num++;
|
||||
}
|
||||
|
||||
handler = _create_raw_flow_rule(dev, ft_prio, dst, fs_matcher, flow_act,
|
||||
handler = _create_raw_flow_rule(dev, ft_prio, dst, fs_matcher,
|
||||
flow_context, flow_act,
|
||||
cmd_in, inlen, dst_num);
|
||||
|
||||
if (IS_ERR(handler)) {
|
||||
|
@@ -1317,6 +1317,7 @@ extern const struct uapi_definition mlx5_ib_devx_defs[];
|
||||
extern const struct uapi_definition mlx5_ib_flow_defs[];
|
||||
struct mlx5_ib_flow_handler *mlx5_ib_raw_fs_rule_add(
|
||||
struct mlx5_ib_dev *dev, struct mlx5_ib_flow_matcher *fs_matcher,
|
||||
struct mlx5_flow_context *flow_context,
|
||||
struct mlx5_flow_act *flow_act, u32 counter_id,
|
||||
void *cmd_in, int inlen, int dest_id, int dest_type);
|
||||
bool mlx5_ib_devx_is_flow_dest(void *obj, int *dest_id, int *dest_type);
|
||||
|
在新工单中引用
屏蔽一个用户