Commit 8377629e authored by Eli Britstein's avatar Eli Britstein Committed by Saeed Mahameed

net/mlx5e: Use helpers to get headers criteria and value pointers

The headers criteria and value pointers may be either of the inner
packet, if a tunnel exists, or of the outer. Simplify the code by using
helper functions to retrieve them.
Signed-off-by: default avatarEli Britstein <elibr@mellanox.com>
Reviewed-by: default avatarRoi Dayan <roid@mellanox.com>
Signed-off-by: default avatarSaeed Mahameed <saeedm@mellanox.com>
parent 2cc1cb1d
...@@ -1438,6 +1438,26 @@ static int parse_tunnel_attr(struct mlx5e_priv *priv, ...@@ -1438,6 +1438,26 @@ static int parse_tunnel_attr(struct mlx5e_priv *priv,
return 0; return 0;
} }
static void *get_match_headers_criteria(u32 flags,
struct mlx5_flow_spec *spec)
{
return (flags & MLX5_FLOW_CONTEXT_ACTION_DECAP) ?
MLX5_ADDR_OF(fte_match_param, spec->match_criteria,
inner_headers) :
MLX5_ADDR_OF(fte_match_param, spec->match_criteria,
outer_headers);
}
static void *get_match_headers_value(u32 flags,
struct mlx5_flow_spec *spec)
{
return (flags & MLX5_FLOW_CONTEXT_ACTION_DECAP) ?
MLX5_ADDR_OF(fte_match_param, spec->match_value,
inner_headers) :
MLX5_ADDR_OF(fte_match_param, spec->match_value,
outer_headers);
}
static int __parse_cls_flower(struct mlx5e_priv *priv, static int __parse_cls_flower(struct mlx5e_priv *priv,
struct mlx5_flow_spec *spec, struct mlx5_flow_spec *spec,
struct tc_cls_flower_offload *f, struct tc_cls_flower_offload *f,
...@@ -1503,10 +1523,10 @@ static int __parse_cls_flower(struct mlx5e_priv *priv, ...@@ -1503,10 +1523,10 @@ static int __parse_cls_flower(struct mlx5e_priv *priv,
/* In decap flow, header pointers should point to the inner /* In decap flow, header pointers should point to the inner
* headers, outer header were already set by parse_tunnel_attr * headers, outer header were already set by parse_tunnel_attr
*/ */
headers_c = MLX5_ADDR_OF(fte_match_param, spec->match_criteria, headers_c = get_match_headers_criteria(MLX5_FLOW_CONTEXT_ACTION_DECAP,
inner_headers); spec);
headers_v = MLX5_ADDR_OF(fte_match_param, spec->match_value, headers_v = get_match_headers_value(MLX5_FLOW_CONTEXT_ACTION_DECAP,
inner_headers); spec);
} }
if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_BASIC)) { if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_BASIC)) {
...@@ -2184,11 +2204,7 @@ static bool modify_header_match_supported(struct mlx5_flow_spec *spec, ...@@ -2184,11 +2204,7 @@ static bool modify_header_match_supported(struct mlx5_flow_spec *spec,
u16 ethertype; u16 ethertype;
int i; int i;
if (actions & MLX5_FLOW_CONTEXT_ACTION_DECAP) headers_v = get_match_headers_value(actions, spec);
headers_v = MLX5_ADDR_OF(fte_match_param, spec->match_value, inner_headers);
else
headers_v = MLX5_ADDR_OF(fte_match_param, spec->match_value, outer_headers);
ethertype = MLX5_GET(fte_match_set_lyr_2_4, headers_v, ethertype); ethertype = MLX5_GET(fte_match_set_lyr_2_4, headers_v, ethertype);
/* for non-IP we only re-write MACs, so we're okay */ /* for non-IP we only re-write MACs, so we're okay */
......
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