Commit 466fa6d2 authored by Maor Gottlieb's avatar Maor Gottlieb Committed by Doug Ledford

IB/mlx5: Add support of more IPv6 fields to flow steering

Add support to receive Traffic Class, specific IPv6 protocol
or IPv6 flow label.
Signed-off-by: default avatarMaor Gottlieb <maorg@mellanox.com>
Reviewed-by: default avatarSagi Grimberg <sagi@grimberg.me>
Signed-off-by: default avatarLeon Romanovsky <leon@kernel.org>
Signed-off-by: default avatarDoug Ledford <dledford@redhat.com>
parent ca0d4753
...@@ -1425,15 +1425,31 @@ static int mlx5_ib_dealloc_pd(struct ib_pd *pd) ...@@ -1425,15 +1425,31 @@ static int mlx5_ib_dealloc_pd(struct ib_pd *pd)
return 0; return 0;
} }
static bool outer_header_zero(u32 *match_criteria) enum {
MATCH_CRITERIA_ENABLE_OUTER_BIT,
MATCH_CRITERIA_ENABLE_MISC_BIT,
MATCH_CRITERIA_ENABLE_INNER_BIT
};
#define HEADER_IS_ZERO(match_criteria, headers) \
!(memchr_inv(MLX5_ADDR_OF(fte_match_param, match_criteria, headers), \
0, MLX5_FLD_SZ_BYTES(fte_match_param, headers))) \
static u8 get_match_criteria_enable(u32 *match_criteria)
{ {
int size = MLX5_ST_SZ_BYTES(fte_match_param); u8 match_criteria_enable;
char *outer_headers_c = MLX5_ADDR_OF(fte_match_param, match_criteria,
outer_headers); match_criteria_enable =
(!HEADER_IS_ZERO(match_criteria, outer_headers)) <<
MATCH_CRITERIA_ENABLE_OUTER_BIT;
match_criteria_enable |=
(!HEADER_IS_ZERO(match_criteria, misc_parameters)) <<
MATCH_CRITERIA_ENABLE_MISC_BIT;
match_criteria_enable |=
(!HEADER_IS_ZERO(match_criteria, inner_headers)) <<
MATCH_CRITERIA_ENABLE_INNER_BIT;
return outer_headers_c[0] == 0 && !memcmp(outer_headers_c, return match_criteria_enable;
outer_headers_c + 1,
size - 1);
} }
static void set_proto(void *outer_c, void *outer_v, u8 mask, u8 val) static void set_proto(void *outer_c, void *outer_v, u8 mask, u8 val)
...@@ -1453,7 +1469,7 @@ static void set_tos(void *outer_c, void *outer_v, u8 mask, u8 val) ...@@ -1453,7 +1469,7 @@ static void set_tos(void *outer_c, void *outer_v, u8 mask, u8 val)
#define LAST_ETH_FIELD vlan_tag #define LAST_ETH_FIELD vlan_tag
#define LAST_IB_FIELD sl #define LAST_IB_FIELD sl
#define LAST_IPV4_FIELD tos #define LAST_IPV4_FIELD tos
#define LAST_IPV6_FIELD dst_ip #define LAST_IPV6_FIELD traffic_class
#define LAST_TCP_UDP_FIELD src_port #define LAST_TCP_UDP_FIELD src_port
/* Field is the last supported field */ /* Field is the last supported field */
...@@ -1471,6 +1487,11 @@ static int parse_flow_attr(u32 *match_c, u32 *match_v, ...@@ -1471,6 +1487,11 @@ static int parse_flow_attr(u32 *match_c, u32 *match_v,
outer_headers); outer_headers);
void *outer_headers_v = MLX5_ADDR_OF(fte_match_param, match_v, void *outer_headers_v = MLX5_ADDR_OF(fte_match_param, match_v,
outer_headers); outer_headers);
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,
misc_parameters);
switch (ib_spec->type) { switch (ib_spec->type) {
case IB_FLOW_SPEC_ETH: case IB_FLOW_SPEC_ETH:
if (FIELDS_NOT_SUPPORTED(ib_spec->eth.mask, LAST_ETH_FIELD)) if (FIELDS_NOT_SUPPORTED(ib_spec->eth.mask, LAST_ETH_FIELD))
...@@ -1570,6 +1591,21 @@ static int parse_flow_attr(u32 *match_c, u32 *match_v, ...@@ -1570,6 +1591,21 @@ static int parse_flow_attr(u32 *match_c, u32 *match_v,
dst_ipv4_dst_ipv6.ipv6_layout.ipv6), dst_ipv4_dst_ipv6.ipv6_layout.ipv6),
&ib_spec->ipv6.val.dst_ip, &ib_spec->ipv6.val.dst_ip,
sizeof(ib_spec->ipv6.val.dst_ip)); sizeof(ib_spec->ipv6.val.dst_ip));
set_tos(outer_headers_c, outer_headers_v,
ib_spec->ipv6.mask.traffic_class,
ib_spec->ipv6.val.traffic_class);
set_proto(outer_headers_c, outer_headers_v,
ib_spec->ipv6.mask.next_hdr,
ib_spec->ipv6.val.next_hdr);
MLX5_SET(fte_match_set_misc, misc_params_c,
outer_ipv6_flow_label,
ntohl(ib_spec->ipv6.mask.flow_label));
MLX5_SET(fte_match_set_misc, misc_params_v,
outer_ipv6_flow_label,
ntohl(ib_spec->ipv6.val.flow_label));
break; break;
case IB_FLOW_SPEC_TCP: case IB_FLOW_SPEC_TCP:
if (FIELDS_NOT_SUPPORTED(ib_spec->tcp_udp.mask, if (FIELDS_NOT_SUPPORTED(ib_spec->tcp_udp.mask,
...@@ -1817,9 +1853,7 @@ static struct mlx5_ib_flow_handler *create_flow_rule(struct mlx5_ib_dev *dev, ...@@ -1817,9 +1853,7 @@ static struct mlx5_ib_flow_handler *create_flow_rule(struct mlx5_ib_dev *dev,
ib_flow += ((union ib_flow_spec *)ib_flow)->size; ib_flow += ((union ib_flow_spec *)ib_flow)->size;
} }
/* Outer header support only */ spec->match_criteria_enable = get_match_criteria_enable(spec->match_criteria);
spec->match_criteria_enable = (!outer_header_zero(spec->match_criteria))
<< 0;
action = dst ? MLX5_FLOW_CONTEXT_ACTION_FWD_DEST : action = dst ? MLX5_FLOW_CONTEXT_ACTION_FWD_DEST :
MLX5_FLOW_CONTEXT_ACTION_FWD_NEXT_PRIO; MLX5_FLOW_CONTEXT_ACTION_FWD_NEXT_PRIO;
handler->rule = mlx5_add_flow_rule(ft, spec, handler->rule = mlx5_add_flow_rule(ft, spec,
......
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