Commit 17091853 authored by Or Gerlitz's avatar Or Gerlitz Committed by Saeed Mahameed

net/mlx5e: Add intermediate struct for TC flow parsing attributes

Add intermediate structure to store attributes parsed from TC filter
matching/actions parts which are soon to be configured into the HW.

Currently put there the flow matching spec after being parsed. More
content to be added in down-stream patch.

This patch doesn't change any functionality.
Signed-off-by: default avatarOr Gerlitz <ogerlitz@mellanox.com>
Signed-off-by: default avatarSaeed Mahameed <saeedm@mellanox.com>
parent 3bc4b7bf
...@@ -70,6 +70,10 @@ struct mlx5e_tc_flow { ...@@ -70,6 +70,10 @@ struct mlx5e_tc_flow {
}; };
}; };
struct mlx5e_tc_flow_parse_attr {
struct mlx5_flow_spec spec;
};
enum { enum {
MLX5_HEADER_TYPE_VXLAN = 0x0, MLX5_HEADER_TYPE_VXLAN = 0x0,
MLX5_HEADER_TYPE_NVGRE = 0x1, MLX5_HEADER_TYPE_NVGRE = 0x1,
...@@ -80,7 +84,7 @@ enum { ...@@ -80,7 +84,7 @@ enum {
static struct mlx5_flow_handle * static struct mlx5_flow_handle *
mlx5e_tc_add_nic_flow(struct mlx5e_priv *priv, mlx5e_tc_add_nic_flow(struct mlx5e_priv *priv,
struct mlx5_flow_spec *spec, struct mlx5e_tc_flow_parse_attr *parse_attr,
struct mlx5_nic_flow_attr *attr) struct mlx5_nic_flow_attr *attr)
{ {
struct mlx5_core_dev *dev = priv->mdev; struct mlx5_core_dev *dev = priv->mdev;
...@@ -123,8 +127,9 @@ mlx5e_tc_add_nic_flow(struct mlx5e_priv *priv, ...@@ -123,8 +127,9 @@ mlx5e_tc_add_nic_flow(struct mlx5e_priv *priv,
table_created = true; table_created = true;
} }
spec->match_criteria_enable = MLX5_MATCH_OUTER_HEADERS; parse_attr->spec.match_criteria_enable = MLX5_MATCH_OUTER_HEADERS;
rule = mlx5_add_flow_rules(priv->fs.tc.t, spec, &flow_act, &dest, 1); rule = mlx5_add_flow_rules(priv->fs.tc.t, &parse_attr->spec,
&flow_act, &dest, 1);
if (IS_ERR(rule)) if (IS_ERR(rule))
goto err_add_rule; goto err_add_rule;
...@@ -161,7 +166,7 @@ static void mlx5e_tc_del_nic_flow(struct mlx5e_priv *priv, ...@@ -161,7 +166,7 @@ static void mlx5e_tc_del_nic_flow(struct mlx5e_priv *priv,
static struct mlx5_flow_handle * static struct mlx5_flow_handle *
mlx5e_tc_add_fdb_flow(struct mlx5e_priv *priv, mlx5e_tc_add_fdb_flow(struct mlx5e_priv *priv,
struct mlx5_flow_spec *spec, struct mlx5e_tc_flow_parse_attr *parse_attr,
struct mlx5_esw_flow_attr *attr) struct mlx5_esw_flow_attr *attr)
{ {
struct mlx5_eswitch *esw = priv->mdev->priv.eswitch; struct mlx5_eswitch *esw = priv->mdev->priv.eswitch;
...@@ -171,7 +176,7 @@ mlx5e_tc_add_fdb_flow(struct mlx5e_priv *priv, ...@@ -171,7 +176,7 @@ mlx5e_tc_add_fdb_flow(struct mlx5e_priv *priv,
if (err) if (err)
return ERR_PTR(err); return ERR_PTR(err);
return mlx5_eswitch_add_offloaded_rule(esw, spec, attr); return mlx5_eswitch_add_offloaded_rule(esw, &parse_attr->spec, attr);
} }
static void mlx5e_detach_encap(struct mlx5e_priv *priv, static void mlx5e_detach_encap(struct mlx5e_priv *priv,
...@@ -1173,8 +1178,8 @@ int mlx5e_configure_flower(struct mlx5e_priv *priv, __be16 protocol, ...@@ -1173,8 +1178,8 @@ int mlx5e_configure_flower(struct mlx5e_priv *priv, __be16 protocol,
struct tc_cls_flower_offload *f) struct tc_cls_flower_offload *f)
{ {
struct mlx5_eswitch *esw = priv->mdev->priv.eswitch; struct mlx5_eswitch *esw = priv->mdev->priv.eswitch;
struct mlx5e_tc_flow_parse_attr *parse_attr;
struct mlx5e_tc_table *tc = &priv->fs.tc; struct mlx5e_tc_table *tc = &priv->fs.tc;
struct mlx5_flow_spec *spec;
struct mlx5e_tc_flow *flow; struct mlx5e_tc_flow *flow;
int attr_size, err = 0; int attr_size, err = 0;
u8 flow_flags = 0; u8 flow_flags = 0;
...@@ -1188,8 +1193,8 @@ int mlx5e_configure_flower(struct mlx5e_priv *priv, __be16 protocol, ...@@ -1188,8 +1193,8 @@ int mlx5e_configure_flower(struct mlx5e_priv *priv, __be16 protocol,
} }
flow = kzalloc(sizeof(*flow) + attr_size, GFP_KERNEL); flow = kzalloc(sizeof(*flow) + attr_size, GFP_KERNEL);
spec = mlx5_vzalloc(sizeof(*spec)); parse_attr = mlx5_vzalloc(sizeof(*parse_attr));
if (!spec || !flow) { if (!parse_attr || !flow) {
err = -ENOMEM; err = -ENOMEM;
goto err_free; goto err_free;
} }
...@@ -1197,7 +1202,7 @@ int mlx5e_configure_flower(struct mlx5e_priv *priv, __be16 protocol, ...@@ -1197,7 +1202,7 @@ int mlx5e_configure_flower(struct mlx5e_priv *priv, __be16 protocol,
flow->cookie = f->cookie; flow->cookie = f->cookie;
flow->flags = flow_flags; flow->flags = flow_flags;
err = parse_cls_flower(priv, flow, spec, f); err = parse_cls_flower(priv, flow, &parse_attr->spec, f);
if (err < 0) if (err < 0)
goto err_free; goto err_free;
...@@ -1205,12 +1210,12 @@ int mlx5e_configure_flower(struct mlx5e_priv *priv, __be16 protocol, ...@@ -1205,12 +1210,12 @@ int mlx5e_configure_flower(struct mlx5e_priv *priv, __be16 protocol,
err = parse_tc_fdb_actions(priv, f->exts, flow); err = parse_tc_fdb_actions(priv, f->exts, flow);
if (err < 0) if (err < 0)
goto err_free; goto err_free;
flow->rule = mlx5e_tc_add_fdb_flow(priv, spec, flow->esw_attr); flow->rule = mlx5e_tc_add_fdb_flow(priv, parse_attr, flow->esw_attr);
} else { } else {
err = parse_tc_nic_actions(priv, f->exts, flow->nic_attr); err = parse_tc_nic_actions(priv, f->exts, flow->nic_attr);
if (err < 0) if (err < 0)
goto err_free; goto err_free;
flow->rule = mlx5e_tc_add_nic_flow(priv, spec, flow->nic_attr); flow->rule = mlx5e_tc_add_nic_flow(priv, parse_attr, flow->nic_attr);
} }
if (IS_ERR(flow->rule)) { if (IS_ERR(flow->rule)) {
...@@ -1231,7 +1236,7 @@ int mlx5e_configure_flower(struct mlx5e_priv *priv, __be16 protocol, ...@@ -1231,7 +1236,7 @@ int mlx5e_configure_flower(struct mlx5e_priv *priv, __be16 protocol,
err_free: err_free:
kfree(flow); kfree(flow);
out: out:
kvfree(spec); kvfree(parse_attr);
return err; return err;
} }
......
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