Commit bb0ee7dc authored by Jianbo Liu's avatar Jianbo Liu Committed by Saeed Mahameed

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: default avatarJianbo Liu <jianbol@mellanox.com>
Reviewed-by: default avatarMark Bloch <markb@mellanox.com>
Signed-off-by: default avatarSaeed Mahameed <saeedm@mellanox.com>
parent 91d6291c
...@@ -65,11 +65,12 @@ static const struct uverbs_attr_spec mlx5_ib_flow_type[] = { ...@@ -65,11 +65,12 @@ static const struct uverbs_attr_spec mlx5_ib_flow_type[] = {
static int UVERBS_HANDLER(MLX5_IB_METHOD_CREATE_FLOW)( static int UVERBS_HANDLER(MLX5_IB_METHOD_CREATE_FLOW)(
struct uverbs_attr_bundle *attrs) 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_handler *flow_handler;
struct mlx5_ib_flow_matcher *fs_matcher; struct mlx5_ib_flow_matcher *fs_matcher;
struct ib_uobject **arr_flow_actions; struct ib_uobject **arr_flow_actions;
struct ib_uflow_resources *uflow_res; struct ib_uflow_resources *uflow_res;
struct mlx5_flow_act flow_act = {};
void *devx_obj; void *devx_obj;
int dest_id, dest_type; int dest_id, dest_type;
void *cmd_in; void *cmd_in;
...@@ -172,17 +173,19 @@ static int UVERBS_HANDLER(MLX5_IB_METHOD_CREATE_FLOW)( ...@@ -172,17 +173,19 @@ static int UVERBS_HANDLER(MLX5_IB_METHOD_CREATE_FLOW)(
arr_flow_actions[i]->object); 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); MLX5_IB_ATTR_CREATE_FLOW_TAG);
if (!ret) { if (!ret) {
if (flow_act.flow_tag >= BIT(24)) { if (flow_context.flow_tag >= BIT(24)) {
ret = -EINVAL; ret = -EINVAL;
goto err_out; 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, counter_id,
cmd_in, inlen, cmd_in, inlen,
dest_id, dest_type); dest_id, dest_type);
......
...@@ -2666,11 +2666,15 @@ int parse_flow_flow_action(struct mlx5_ib_flow_action *maction, ...@@ -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, static int parse_flow_attr(struct mlx5_core_dev *mdev,
u32 *match_v, const union ib_flow_spec *ib_spec, struct mlx5_flow_spec *spec,
const union ib_flow_spec *ib_spec,
const struct ib_flow_attr *flow_attr, const struct ib_flow_attr *flow_attr,
struct mlx5_flow_act *action, u32 prev_type) 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, void *misc_params_c = MLX5_ADDR_OF(fte_match_param, match_c,
misc_parameters); misc_parameters);
void *misc_params_v = MLX5_ADDR_OF(fte_match_param, match_v, 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, ...@@ -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)) if (ib_spec->flow_tag.tag_id >= BIT(24))
return -EINVAL; return -EINVAL;
action->flow_tag = ib_spec->flow_tag.tag_id; flow_context->flow_tag = ib_spec->flow_tag.tag_id;
action->flags |= FLOW_ACT_HAS_TAG; flow_context->flags |= FLOW_CONTEXT_HAS_TAG;
break; break;
case IB_FLOW_SPEC_ACTION_DROP: case IB_FLOW_SPEC_ACTION_DROP:
if (FIELDS_NOT_SUPPORTED(ib_spec->drop, if (FIELDS_NOT_SUPPORTED(ib_spec->drop,
...@@ -3084,7 +3088,8 @@ is_valid_esp_aes_gcm(struct mlx5_core_dev *mdev, ...@@ -3084,7 +3088,8 @@ is_valid_esp_aes_gcm(struct mlx5_core_dev *mdev,
return VALID_SPEC_NA; return VALID_SPEC_NA;
return is_crypto && is_ipsec && 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; VALID_SPEC_VALID : VALID_SPEC_INVALID;
} }
...@@ -3473,7 +3478,7 @@ static struct mlx5_ib_flow_handler *_create_flow_rule(struct mlx5_ib_dev *dev, ...@@ -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_flow_table *ft = ft_prio->flow_table;
struct mlx5_ib_flow_handler *handler; 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_spec *spec;
struct mlx5_flow_destination dest_arr[2] = {}; struct mlx5_flow_destination dest_arr[2] = {};
struct mlx5_flow_destination *rule_dst = dest_arr; 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, ...@@ -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++) { for (spec_index = 0; spec_index < flow_attr->num_of_specs; spec_index++) {
err = parse_flow_attr(dev->mdev, spec->match_criteria, err = parse_flow_attr(dev->mdev, spec,
spec->match_value,
ib_flow, flow_attr, &flow_act, ib_flow, flow_attr, &flow_act,
prev_type); prev_type);
if (err < 0) if (err < 0)
...@@ -3572,11 +3576,11 @@ static struct mlx5_ib_flow_handler *_create_flow_rule(struct mlx5_ib_dev *dev, ...@@ -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; 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_ALL_DEFAULT ||
flow_attr->type == IB_FLOW_ATTR_MC_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", 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; err = -EINVAL;
goto free; goto free;
} }
...@@ -3947,6 +3951,7 @@ _create_raw_flow_rule(struct mlx5_ib_dev *dev, ...@@ -3947,6 +3951,7 @@ _create_raw_flow_rule(struct mlx5_ib_dev *dev,
struct mlx5_ib_flow_prio *ft_prio, struct mlx5_ib_flow_prio *ft_prio,
struct mlx5_flow_destination *dst, struct mlx5_flow_destination *dst,
struct mlx5_ib_flow_matcher *fs_matcher, struct mlx5_ib_flow_matcher *fs_matcher,
struct mlx5_flow_context *flow_context,
struct mlx5_flow_act *flow_act, struct mlx5_flow_act *flow_act,
void *cmd_in, int inlen, void *cmd_in, int inlen,
int dst_num) int dst_num)
...@@ -3969,6 +3974,7 @@ _create_raw_flow_rule(struct mlx5_ib_dev *dev, ...@@ -3969,6 +3974,7 @@ _create_raw_flow_rule(struct mlx5_ib_dev *dev,
memcpy(spec->match_criteria, fs_matcher->matcher_mask.match_params, memcpy(spec->match_criteria, fs_matcher->matcher_mask.match_params,
fs_matcher->mask_len); fs_matcher->mask_len);
spec->match_criteria_enable = fs_matcher->match_criteria_enable; spec->match_criteria_enable = fs_matcher->match_criteria_enable;
spec->flow_context = *flow_context;
handler->rule = mlx5_add_flow_rules(ft, spec, handler->rule = mlx5_add_flow_rules(ft, spec,
flow_act, dst, dst_num); flow_act, dst, dst_num);
...@@ -4033,6 +4039,7 @@ static bool raw_fs_is_multicast(struct mlx5_ib_flow_matcher *fs_matcher, ...@@ -4033,6 +4039,7 @@ static bool raw_fs_is_multicast(struct mlx5_ib_flow_matcher *fs_matcher,
struct mlx5_ib_flow_handler * struct mlx5_ib_flow_handler *
mlx5_ib_raw_fs_rule_add(struct mlx5_ib_dev *dev, mlx5_ib_raw_fs_rule_add(struct mlx5_ib_dev *dev,
struct mlx5_ib_flow_matcher *fs_matcher, struct mlx5_ib_flow_matcher *fs_matcher,
struct mlx5_flow_context *flow_context,
struct mlx5_flow_act *flow_act, struct mlx5_flow_act *flow_act,
u32 counter_id, u32 counter_id,
void *cmd_in, int inlen, int dest_id, void *cmd_in, int inlen, int dest_id,
...@@ -4085,7 +4092,8 @@ mlx5_ib_raw_fs_rule_add(struct mlx5_ib_dev *dev, ...@@ -4085,7 +4092,8 @@ mlx5_ib_raw_fs_rule_add(struct mlx5_ib_dev *dev,
dst_num++; 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); cmd_in, inlen, dst_num);
if (IS_ERR(handler)) { if (IS_ERR(handler)) {
......
...@@ -1317,6 +1317,7 @@ extern const struct uapi_definition mlx5_ib_devx_defs[]; ...@@ -1317,6 +1317,7 @@ extern const struct uapi_definition mlx5_ib_devx_defs[];
extern const struct uapi_definition mlx5_ib_flow_defs[]; extern const struct uapi_definition mlx5_ib_flow_defs[];
struct mlx5_ib_flow_handler *mlx5_ib_raw_fs_rule_add( 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_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, struct mlx5_flow_act *flow_act, u32 counter_id,
void *cmd_in, int inlen, int dest_id, int dest_type); 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); bool mlx5_ib_devx_is_flow_dest(void *obj, int *dest_id, int *dest_type);
......
...@@ -204,7 +204,7 @@ TRACE_EVENT(mlx5_fs_set_fte, ...@@ -204,7 +204,7 @@ TRACE_EVENT(mlx5_fs_set_fte,
__entry->index = fte->index; __entry->index = fte->index;
__entry->action = fte->action.action; __entry->action = fte->action.action;
__entry->mask_enable = __entry->fg->mask.match_criteria_enable; __entry->mask_enable = __entry->fg->mask.match_criteria_enable;
__entry->flow_tag = fte->action.flow_tag; __entry->flow_tag = fte->flow_context.flow_tag;
memcpy(__entry->mask_outer, memcpy(__entry->mask_outer,
MLX5_ADDR_OF(fte_match_param, MLX5_ADDR_OF(fte_match_param,
&__entry->fg->mask.match_criteria, &__entry->fg->mask.match_criteria,
......
...@@ -426,7 +426,7 @@ add_ethtool_flow_rule(struct mlx5e_priv *priv, ...@@ -426,7 +426,7 @@ add_ethtool_flow_rule(struct mlx5e_priv *priv,
} }
spec->match_criteria_enable = (!outer_header_zero(spec->match_criteria)); spec->match_criteria_enable = (!outer_header_zero(spec->match_criteria));
flow_act.flow_tag = MLX5_FS_DEFAULT_FLOW_TAG; spec->flow_context.flow_tag = MLX5_FS_DEFAULT_FLOW_TAG;
rule = mlx5_add_flow_rules(ft, spec, &flow_act, dst, dst ? 1 : 0); rule = mlx5_add_flow_rules(ft, spec, &flow_act, dst, dst ? 1 : 0);
if (IS_ERR(rule)) { if (IS_ERR(rule)) {
err = PTR_ERR(rule); err = PTR_ERR(rule);
......
...@@ -716,19 +716,22 @@ mlx5e_tc_add_nic_flow(struct mlx5e_priv *priv, ...@@ -716,19 +716,22 @@ mlx5e_tc_add_nic_flow(struct mlx5e_priv *priv,
struct mlx5e_tc_flow *flow, struct mlx5e_tc_flow *flow,
struct netlink_ext_ack *extack) struct netlink_ext_ack *extack)
{ {
struct mlx5_flow_context *flow_context = &parse_attr->spec.flow_context;
struct mlx5_nic_flow_attr *attr = flow->nic_attr; struct mlx5_nic_flow_attr *attr = flow->nic_attr;
struct mlx5_core_dev *dev = priv->mdev; struct mlx5_core_dev *dev = priv->mdev;
struct mlx5_flow_destination dest[2] = {}; struct mlx5_flow_destination dest[2] = {};
struct mlx5_flow_act flow_act = { struct mlx5_flow_act flow_act = {
.action = attr->action, .action = attr->action,
.flow_tag = attr->flow_tag,
.reformat_id = 0, .reformat_id = 0,
.flags = FLOW_ACT_HAS_TAG | FLOW_ACT_NO_APPEND, .flags = FLOW_ACT_NO_APPEND,
}; };
struct mlx5_fc *counter = NULL; struct mlx5_fc *counter = NULL;
bool table_created = false; bool table_created = false;
int err, dest_ix = 0; int err, dest_ix = 0;
flow_context->flags |= FLOW_CONTEXT_HAS_TAG;
flow_context->flow_tag = attr->flow_tag;
if (flow->flags & MLX5E_TC_FLOW_HAIRPIN) { if (flow->flags & MLX5E_TC_FLOW_HAIRPIN) {
err = mlx5e_hairpin_flow_add(priv, flow, parse_attr, extack); err = mlx5e_hairpin_flow_add(priv, flow, parse_attr, extack);
if (err) { if (err) {
......
...@@ -636,7 +636,8 @@ static bool mlx5_is_fpga_egress_ipsec_rule(struct mlx5_core_dev *dev, ...@@ -636,7 +636,8 @@ static bool mlx5_is_fpga_egress_ipsec_rule(struct mlx5_core_dev *dev,
u8 match_criteria_enable, u8 match_criteria_enable,
const u32 *match_c, const u32 *match_c,
const u32 *match_v, const u32 *match_v,
struct mlx5_flow_act *flow_act) struct mlx5_flow_act *flow_act,
struct mlx5_flow_context *flow_context)
{ {
const void *outer_c = MLX5_ADDR_OF(fte_match_param, match_c, const void *outer_c = MLX5_ADDR_OF(fte_match_param, match_c,
outer_headers); outer_headers);
...@@ -655,7 +656,7 @@ static bool mlx5_is_fpga_egress_ipsec_rule(struct mlx5_core_dev *dev, ...@@ -655,7 +656,7 @@ static bool mlx5_is_fpga_egress_ipsec_rule(struct mlx5_core_dev *dev,
(match_criteria_enable & (match_criteria_enable &
~(MLX5_MATCH_OUTER_HEADERS | MLX5_MATCH_MISC_PARAMETERS)) || ~(MLX5_MATCH_OUTER_HEADERS | MLX5_MATCH_MISC_PARAMETERS)) ||
(flow_act->action & ~(MLX5_FLOW_CONTEXT_ACTION_ENCRYPT | MLX5_FLOW_CONTEXT_ACTION_ALLOW)) || (flow_act->action & ~(MLX5_FLOW_CONTEXT_ACTION_ENCRYPT | MLX5_FLOW_CONTEXT_ACTION_ALLOW)) ||
(flow_act->flags & FLOW_ACT_HAS_TAG)) (flow_context->flags & FLOW_CONTEXT_HAS_TAG))
return false; return false;
return true; return true;
...@@ -767,7 +768,8 @@ mlx5_fpga_ipsec_fs_create_sa_ctx(struct mlx5_core_dev *mdev, ...@@ -767,7 +768,8 @@ mlx5_fpga_ipsec_fs_create_sa_ctx(struct mlx5_core_dev *mdev,
fg->mask.match_criteria_enable, fg->mask.match_criteria_enable,
fg->mask.match_criteria, fg->mask.match_criteria,
fte->val, fte->val,
&fte->action)) &fte->action,
&fte->flow_context))
return ERR_PTR(-EINVAL); return ERR_PTR(-EINVAL);
else if (!mlx5_is_fpga_ipsec_rule(mdev, else if (!mlx5_is_fpga_ipsec_rule(mdev,
fg->mask.match_criteria_enable, fg->mask.match_criteria_enable,
......
...@@ -396,7 +396,8 @@ static int mlx5_cmd_set_fte(struct mlx5_core_dev *dev, ...@@ -396,7 +396,8 @@ static int mlx5_cmd_set_fte(struct mlx5_core_dev *dev,
in_flow_context = MLX5_ADDR_OF(set_fte_in, in, flow_context); in_flow_context = MLX5_ADDR_OF(set_fte_in, in, flow_context);
MLX5_SET(flow_context, in_flow_context, group_id, group_id); MLX5_SET(flow_context, in_flow_context, group_id, group_id);
MLX5_SET(flow_context, in_flow_context, flow_tag, fte->action.flow_tag); MLX5_SET(flow_context, in_flow_context, flow_tag,
fte->flow_context.flow_tag);
MLX5_SET(flow_context, in_flow_context, extended_destination, MLX5_SET(flow_context, in_flow_context, extended_destination,
extended_dest); extended_dest);
if (extended_dest) { if (extended_dest) {
......
...@@ -584,7 +584,7 @@ static int insert_fte(struct mlx5_flow_group *fg, struct fs_fte *fte) ...@@ -584,7 +584,7 @@ static int insert_fte(struct mlx5_flow_group *fg, struct fs_fte *fte)
} }
static struct fs_fte *alloc_fte(struct mlx5_flow_table *ft, static struct fs_fte *alloc_fte(struct mlx5_flow_table *ft,
u32 *match_value, struct mlx5_flow_spec *spec,
struct mlx5_flow_act *flow_act) struct mlx5_flow_act *flow_act)
{ {
struct mlx5_flow_steering *steering = get_steering(&ft->node); struct mlx5_flow_steering *steering = get_steering(&ft->node);
...@@ -594,9 +594,10 @@ static struct fs_fte *alloc_fte(struct mlx5_flow_table *ft, ...@@ -594,9 +594,10 @@ static struct fs_fte *alloc_fte(struct mlx5_flow_table *ft,
if (!fte) if (!fte)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
memcpy(fte->val, match_value, sizeof(fte->val)); memcpy(fte->val, &spec->match_value, sizeof(fte->val));
fte->node.type = FS_TYPE_FLOW_ENTRY; fte->node.type = FS_TYPE_FLOW_ENTRY;
fte->action = *flow_act; fte->action = *flow_act;
fte->flow_context = spec->flow_context;
tree_init_node(&fte->node, NULL, del_sw_fte); tree_init_node(&fte->node, NULL, del_sw_fte);
...@@ -1428,7 +1429,9 @@ static bool check_conflicting_actions(u32 action1, u32 action2) ...@@ -1428,7 +1429,9 @@ static bool check_conflicting_actions(u32 action1, u32 action2)
return false; return false;
} }
static int check_conflicting_ftes(struct fs_fte *fte, const struct mlx5_flow_act *flow_act) static int check_conflicting_ftes(struct fs_fte *fte,
const struct mlx5_flow_context *flow_context,
const struct mlx5_flow_act *flow_act)
{ {
if (check_conflicting_actions(flow_act->action, fte->action.action)) { if (check_conflicting_actions(flow_act->action, fte->action.action)) {
mlx5_core_warn(get_dev(&fte->node), mlx5_core_warn(get_dev(&fte->node),
...@@ -1436,12 +1439,12 @@ static int check_conflicting_ftes(struct fs_fte *fte, const struct mlx5_flow_act ...@@ -1436,12 +1439,12 @@ static int check_conflicting_ftes(struct fs_fte *fte, const struct mlx5_flow_act
return -EEXIST; return -EEXIST;
} }
if ((flow_act->flags & FLOW_ACT_HAS_TAG) && if ((flow_context->flags & FLOW_CONTEXT_HAS_TAG) &&
fte->action.flow_tag != flow_act->flow_tag) { fte->flow_context.flow_tag != flow_context->flow_tag) {
mlx5_core_warn(get_dev(&fte->node), mlx5_core_warn(get_dev(&fte->node),
"FTE flow tag %u already exists with different flow tag %u\n", "FTE flow tag %u already exists with different flow tag %u\n",
fte->action.flow_tag, fte->flow_context.flow_tag,
flow_act->flow_tag); flow_context->flow_tag);
return -EEXIST; return -EEXIST;
} }
...@@ -1449,7 +1452,7 @@ static int check_conflicting_ftes(struct fs_fte *fte, const struct mlx5_flow_act ...@@ -1449,7 +1452,7 @@ static int check_conflicting_ftes(struct fs_fte *fte, const struct mlx5_flow_act
} }
static struct mlx5_flow_handle *add_rule_fg(struct mlx5_flow_group *fg, static struct mlx5_flow_handle *add_rule_fg(struct mlx5_flow_group *fg,
u32 *match_value, struct mlx5_flow_spec *spec,
struct mlx5_flow_act *flow_act, struct mlx5_flow_act *flow_act,
struct mlx5_flow_destination *dest, struct mlx5_flow_destination *dest,
int dest_num, int dest_num,
...@@ -1460,7 +1463,7 @@ static struct mlx5_flow_handle *add_rule_fg(struct mlx5_flow_group *fg, ...@@ -1460,7 +1463,7 @@ static struct mlx5_flow_handle *add_rule_fg(struct mlx5_flow_group *fg,
int i; int i;
int ret; int ret;
ret = check_conflicting_ftes(fte, flow_act); ret = check_conflicting_ftes(fte, &spec->flow_context, flow_act);
if (ret) if (ret)
return ERR_PTR(ret); return ERR_PTR(ret);
...@@ -1635,7 +1638,7 @@ try_add_to_existing_fg(struct mlx5_flow_table *ft, ...@@ -1635,7 +1638,7 @@ try_add_to_existing_fg(struct mlx5_flow_table *ft,
u64 version; u64 version;
int err; int err;
fte = alloc_fte(ft, spec->match_value, flow_act); fte = alloc_fte(ft, spec, flow_act);
if (IS_ERR(fte)) if (IS_ERR(fte))
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
...@@ -1651,8 +1654,7 @@ try_add_to_existing_fg(struct mlx5_flow_table *ft, ...@@ -1651,8 +1654,7 @@ try_add_to_existing_fg(struct mlx5_flow_table *ft,
fte_tmp = lookup_fte_locked(g, spec->match_value, take_write); fte_tmp = lookup_fte_locked(g, spec->match_value, take_write);
if (!fte_tmp) if (!fte_tmp)
continue; continue;
rule = add_rule_fg(g, spec->match_value, rule = add_rule_fg(g, spec, flow_act, dest, dest_num, fte_tmp);
flow_act, dest, dest_num, fte_tmp);
up_write_ref_node(&fte_tmp->node, false); up_write_ref_node(&fte_tmp->node, false);
tree_put_node(&fte_tmp->node, false); tree_put_node(&fte_tmp->node, false);
kmem_cache_free(steering->ftes_cache, fte); kmem_cache_free(steering->ftes_cache, fte);
...@@ -1699,8 +1701,7 @@ try_add_to_existing_fg(struct mlx5_flow_table *ft, ...@@ -1699,8 +1701,7 @@ try_add_to_existing_fg(struct mlx5_flow_table *ft,
nested_down_write_ref_node(&fte->node, FS_LOCK_CHILD); nested_down_write_ref_node(&fte->node, FS_LOCK_CHILD);
up_write_ref_node(&g->node, false); up_write_ref_node(&g->node, false);
rule = add_rule_fg(g, spec->match_value, rule = add_rule_fg(g, spec, flow_act, dest, dest_num, fte);
flow_act, dest, dest_num, fte);
up_write_ref_node(&fte->node, false); up_write_ref_node(&fte->node, false);
tree_put_node(&fte->node, false); tree_put_node(&fte->node, false);
return rule; return rule;
...@@ -1786,7 +1787,7 @@ _mlx5_add_flow_rules(struct mlx5_flow_table *ft, ...@@ -1786,7 +1787,7 @@ _mlx5_add_flow_rules(struct mlx5_flow_table *ft,
if (err) if (err)
goto err_release_fg; goto err_release_fg;
fte = alloc_fte(ft, spec->match_value, flow_act); fte = alloc_fte(ft, spec, flow_act);
if (IS_ERR(fte)) { if (IS_ERR(fte)) {
err = PTR_ERR(fte); err = PTR_ERR(fte);
goto err_release_fg; goto err_release_fg;
...@@ -1800,8 +1801,7 @@ _mlx5_add_flow_rules(struct mlx5_flow_table *ft, ...@@ -1800,8 +1801,7 @@ _mlx5_add_flow_rules(struct mlx5_flow_table *ft,
nested_down_write_ref_node(&fte->node, FS_LOCK_CHILD); nested_down_write_ref_node(&fte->node, FS_LOCK_CHILD);
up_write_ref_node(&g->node, false); up_write_ref_node(&g->node, false);
rule = add_rule_fg(g, spec->match_value, flow_act, dest, rule = add_rule_fg(g, spec, flow_act, dest, dest_num, fte);
dest_num, fte);
up_write_ref_node(&fte->node, false); up_write_ref_node(&fte->node, false);
tree_put_node(&fte->node, false); tree_put_node(&fte->node, false);
tree_put_node(&g->node, false); tree_put_node(&g->node, false);
......
...@@ -170,6 +170,7 @@ struct fs_fte { ...@@ -170,6 +170,7 @@ struct fs_fte {
u32 val[MLX5_ST_SZ_DW_MATCH_PARAM]; u32 val[MLX5_ST_SZ_DW_MATCH_PARAM];
u32 dests_size; u32 dests_size;
u32 index; u32 index;
struct mlx5_flow_context flow_context;
struct mlx5_flow_act action; struct mlx5_flow_act action;
enum fs_fte_status status; enum fs_fte_status status;
struct mlx5_fc *counter; struct mlx5_fc *counter;
......
...@@ -88,10 +88,20 @@ struct mlx5_flow_group; ...@@ -88,10 +88,20 @@ struct mlx5_flow_group;
struct mlx5_flow_namespace; struct mlx5_flow_namespace;
struct mlx5_flow_handle; struct mlx5_flow_handle;
enum {
FLOW_CONTEXT_HAS_TAG = BIT(0),
};
struct mlx5_flow_context {
u32 flags;
u32 flow_tag;
};
struct mlx5_flow_spec { struct mlx5_flow_spec {
u8 match_criteria_enable; u8 match_criteria_enable;
u32 match_criteria[MLX5_ST_SZ_DW(fte_match_param)]; u32 match_criteria[MLX5_ST_SZ_DW(fte_match_param)];
u32 match_value[MLX5_ST_SZ_DW(fte_match_param)]; u32 match_value[MLX5_ST_SZ_DW(fte_match_param)];
struct mlx5_flow_context flow_context;
}; };
enum { enum {
...@@ -173,13 +183,11 @@ struct mlx5_fs_vlan { ...@@ -173,13 +183,11 @@ struct mlx5_fs_vlan {
#define MLX5_FS_VLAN_DEPTH 2 #define MLX5_FS_VLAN_DEPTH 2
enum { enum {
FLOW_ACT_HAS_TAG = BIT(0), FLOW_ACT_NO_APPEND = BIT(0),
FLOW_ACT_NO_APPEND = BIT(1),
}; };
struct mlx5_flow_act { struct mlx5_flow_act {
u32 action; u32 action;
u32 flow_tag;
u32 reformat_id; u32 reformat_id;
u32 modify_id; u32 modify_id;
uintptr_t esp_id; uintptr_t esp_id;
...@@ -190,7 +198,6 @@ struct mlx5_flow_act { ...@@ -190,7 +198,6 @@ struct mlx5_flow_act {
#define MLX5_DECLARE_FLOW_ACT(name) \ #define MLX5_DECLARE_FLOW_ACT(name) \
struct mlx5_flow_act name = { .action = MLX5_FLOW_CONTEXT_ACTION_FWD_DEST,\ struct mlx5_flow_act name = { .action = MLX5_FLOW_CONTEXT_ACTION_FWD_DEST,\
.flow_tag = MLX5_FS_DEFAULT_FLOW_TAG, \
.reformat_id = 0, \ .reformat_id = 0, \
.modify_id = 0, \ .modify_id = 0, \
.flags = 0, } .flags = 0, }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment