IB/mlx5: Pass mlx5_flow_act struct instead of multiple arguments

Group and pass all function arguments of parse_flow_attr call in one
common struct mlx5_flow_act.

This patch passes all the action arguments of parse_flow_attr in one common
struct mlx5_flow_act. It allows us to scale the number of actions without adding
new arguments to the function.

Signed-off-by: Matan Barak <matanb@mellanox.com>
Signed-off-by: Boris Pismenny <borisp@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
Acked-by: Jason Gunthorpe <jgg@mellanox.com>
This commit is contained in:
Boris Pismenny 2017-08-16 09:33:30 +03:00 committed by Saeed Mahameed
parent 04e87170b0
commit 075572d4b7
1 changed files with 8 additions and 12 deletions

View File

@ -2316,7 +2316,7 @@ static void set_tos(void *outer_c, void *outer_v, u8 mask, u8 val)
#define IPV6_VERSION 6 #define IPV6_VERSION 6
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_c,
u32 *match_v, const union ib_flow_spec *ib_spec, u32 *match_v, const union ib_flow_spec *ib_spec,
u32 *tag_id, bool *is_drop) struct mlx5_flow_act *action)
{ {
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);
@ -2534,13 +2534,13 @@ 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;
*tag_id = ib_spec->flow_tag.tag_id; action->flow_tag = ib_spec->flow_tag.tag_id;
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,
LAST_DROP_FIELD)) LAST_DROP_FIELD))
return -EOPNOTSUPP; return -EOPNOTSUPP;
*is_drop = true; action->action |= MLX5_FLOW_CONTEXT_ACTION_DROP;
break; break;
default: default:
return -EINVAL; return -EINVAL;
@ -2793,13 +2793,11 @@ 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 = {0}; struct mlx5_flow_act flow_act = {.flow_tag = MLX5_FS_DEFAULT_FLOW_TAG};
struct mlx5_flow_spec *spec; struct mlx5_flow_spec *spec;
struct mlx5_flow_destination *rule_dst = dst; struct mlx5_flow_destination *rule_dst = dst;
const void *ib_flow = (const void *)flow_attr + sizeof(*flow_attr); const void *ib_flow = (const void *)flow_attr + sizeof(*flow_attr);
unsigned int spec_index; unsigned int spec_index;
u32 flow_tag = MLX5_FS_DEFAULT_FLOW_TAG;
bool is_drop = false;
int err = 0; int err = 0;
int dest_num = 1; int dest_num = 1;
@ -2818,7 +2816,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->match_criteria,
spec->match_value, spec->match_value,
ib_flow, &flow_tag, &is_drop); ib_flow, &flow_act);
if (err < 0) if (err < 0)
goto free; goto free;
@ -2841,8 +2839,7 @@ static struct mlx5_ib_flow_handler *_create_flow_rule(struct mlx5_ib_dev *dev,
} }
spec->match_criteria_enable = get_match_criteria_enable(spec->match_criteria); spec->match_criteria_enable = get_match_criteria_enable(spec->match_criteria);
if (is_drop) { if (flow_act.action & MLX5_FLOW_CONTEXT_ACTION_DROP) {
flow_act.action = MLX5_FLOW_CONTEXT_ACTION_DROP;
rule_dst = NULL; rule_dst = NULL;
dest_num = 0; dest_num = 0;
} else { } else {
@ -2850,15 +2847,14 @@ 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_tag != MLX5_FS_DEFAULT_FLOW_TAG && if (flow_act.flow_tag != MLX5_FS_DEFAULT_FLOW_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_tag, flow_attr->type); flow_act.flow_tag, flow_attr->type);
err = -EINVAL; err = -EINVAL;
goto free; goto free;
} }
flow_act.flow_tag = flow_tag;
handler->rule = mlx5_add_flow_rules(ft, spec, handler->rule = mlx5_add_flow_rules(ft, spec,
&flow_act, &flow_act,
rule_dst, dest_num); rule_dst, dest_num);