Commit 4923938d authored by Yevgeny Kliteynik's avatar Yevgeny Kliteynik Committed by Saeed Mahameed

net/mlx5: DR, Set STEv0 ICMP flex parser dynamically

Set the flex parser ID dynamicly for ICMP instead of relying
on hardcoded values.
Signed-off-by: default avatarMuhammad Sammar <muhammads@nvidia.com>
Signed-off-by: default avatarYevgeny Kliteynik <kliteyn@nvidia.com>
Signed-off-by: default avatarSaeed Mahameed <saeedm@nvidia.com>
parent 160e9cb3
...@@ -376,13 +376,11 @@ static int dr_matcher_set_ste_builders(struct mlx5dr_matcher *matcher, ...@@ -376,13 +376,11 @@ static int dr_matcher_set_ste_builders(struct mlx5dr_matcher *matcher,
mlx5dr_ste_build_tnl_mpls(ste_ctx, &sb[idx++], mlx5dr_ste_build_tnl_mpls(ste_ctx, &sb[idx++],
&mask, inner, rx); &mask, inner, rx);
if (dr_mask_is_icmp(&mask, dmn)) { if (dr_mask_is_icmp(&mask, dmn))
ret = mlx5dr_ste_build_icmp(ste_ctx, &sb[idx++], mlx5dr_ste_build_icmp(ste_ctx, &sb[idx++],
&mask, &dmn->info.caps, &mask, &dmn->info.caps,
inner, rx); inner, rx);
if (ret)
return ret;
}
if (dr_mask_is_tnl_gre_set(&mask.misc)) if (dr_mask_is_tnl_gre_set(&mask.misc))
mlx5dr_ste_build_tnl_gre(ste_ctx, &sb[idx++], mlx5dr_ste_build_tnl_gre(ste_ctx, &sb[idx++],
&mask, inner, rx); &mask, inner, rx);
......
...@@ -1095,7 +1095,7 @@ void mlx5dr_ste_build_tnl_mpls(struct mlx5dr_ste_ctx *ste_ctx, ...@@ -1095,7 +1095,7 @@ void mlx5dr_ste_build_tnl_mpls(struct mlx5dr_ste_ctx *ste_ctx,
ste_ctx->build_tnl_mpls_init(sb, mask); ste_ctx->build_tnl_mpls_init(sb, mask);
} }
int mlx5dr_ste_build_icmp(struct mlx5dr_ste_ctx *ste_ctx, void mlx5dr_ste_build_icmp(struct mlx5dr_ste_ctx *ste_ctx,
struct mlx5dr_ste_build *sb, struct mlx5dr_ste_build *sb,
struct mlx5dr_match_param *mask, struct mlx5dr_match_param *mask,
struct mlx5dr_cmd_caps *caps, struct mlx5dr_cmd_caps *caps,
...@@ -1104,7 +1104,7 @@ int mlx5dr_ste_build_icmp(struct mlx5dr_ste_ctx *ste_ctx, ...@@ -1104,7 +1104,7 @@ int mlx5dr_ste_build_icmp(struct mlx5dr_ste_ctx *ste_ctx,
sb->rx = rx; sb->rx = rx;
sb->inner = inner; sb->inner = inner;
sb->caps = caps; sb->caps = caps;
return ste_ctx->build_icmp_init(sb, mask); ste_ctx->build_icmp_init(sb, mask);
} }
void mlx5dr_ste_build_general_purpose(struct mlx5dr_ste_ctx *ste_ctx, void mlx5dr_ste_build_general_purpose(struct mlx5dr_ste_ctx *ste_ctx,
......
...@@ -120,7 +120,7 @@ struct mlx5dr_ste_ctx { ...@@ -120,7 +120,7 @@ struct mlx5dr_ste_ctx {
void DR_STE_CTX_BUILDER(mpls); void DR_STE_CTX_BUILDER(mpls);
void DR_STE_CTX_BUILDER(tnl_gre); void DR_STE_CTX_BUILDER(tnl_gre);
void DR_STE_CTX_BUILDER(tnl_mpls); void DR_STE_CTX_BUILDER(tnl_mpls);
int DR_STE_CTX_BUILDER(icmp); void DR_STE_CTX_BUILDER(icmp);
void DR_STE_CTX_BUILDER(general_purpose); void DR_STE_CTX_BUILDER(general_purpose);
void DR_STE_CTX_BUILDER(eth_l4_misc); void DR_STE_CTX_BUILDER(eth_l4_misc);
void DR_STE_CTX_BUILDER(tnl_vxlan_gpe); void DR_STE_CTX_BUILDER(tnl_vxlan_gpe);
......
...@@ -1297,9 +1297,11 @@ dr_ste_v0_build_icmp_tag(struct mlx5dr_match_param *value, ...@@ -1297,9 +1297,11 @@ dr_ste_v0_build_icmp_tag(struct mlx5dr_match_param *value,
u32 *icmp_header_data; u32 *icmp_header_data;
int dw0_location; int dw0_location;
int dw1_location; int dw1_location;
u8 *parser_ptr;
u8 *icmp_type; u8 *icmp_type;
u8 *icmp_code; u8 *icmp_code;
bool is_ipv4; bool is_ipv4;
u32 icmp_hdr;
is_ipv4 = DR_MASK_IS_ICMPV4_SET(misc_3); is_ipv4 = DR_MASK_IS_ICMPV4_SET(misc_3);
if (is_ipv4) { if (is_ipv4) {
...@@ -1316,47 +1318,40 @@ dr_ste_v0_build_icmp_tag(struct mlx5dr_match_param *value, ...@@ -1316,47 +1318,40 @@ dr_ste_v0_build_icmp_tag(struct mlx5dr_match_param *value,
dw1_location = sb->caps->flex_parser_id_icmpv6_dw1; dw1_location = sb->caps->flex_parser_id_icmpv6_dw1;
} }
switch (dw0_location) { parser_ptr = dr_ste_calc_flex_parser_offset(tag, dw0_location);
case 4: icmp_hdr = (*icmp_type << ICMP_TYPE_OFFSET_FIRST_DW) |
MLX5_SET(ste_flex_parser_1, tag, flex_parser_4, (*icmp_code << ICMP_CODE_OFFSET_FIRST_DW);
(*icmp_type << ICMP_TYPE_OFFSET_FIRST_DW) | *(__be32 *)parser_ptr = cpu_to_be32(icmp_hdr);
(*icmp_code << ICMP_TYPE_OFFSET_FIRST_DW));
*icmp_type = 0;
*icmp_code = 0; *icmp_code = 0;
break; *icmp_type = 0;
default:
return -EINVAL;
}
switch (dw1_location) { parser_ptr = dr_ste_calc_flex_parser_offset(tag, dw1_location);
case 5: *(__be32 *)parser_ptr = cpu_to_be32(*icmp_header_data);
MLX5_SET(ste_flex_parser_1, tag, flex_parser_5,
*icmp_header_data);
*icmp_header_data = 0; *icmp_header_data = 0;
break;
default:
return -EINVAL;
}
return 0; return 0;
} }
static int static void
dr_ste_v0_build_icmp_init(struct mlx5dr_ste_build *sb, dr_ste_v0_build_icmp_init(struct mlx5dr_ste_build *sb,
struct mlx5dr_match_param *mask) struct mlx5dr_match_param *mask)
{ {
int ret; u8 parser_id;
bool is_ipv4;
ret = dr_ste_v0_build_icmp_tag(mask, sb, sb->bit_mask); dr_ste_v0_build_icmp_tag(mask, sb, sb->bit_mask);
if (ret)
return ret;
sb->lu_type = DR_STE_V0_LU_TYPE_FLEX_PARSER_1; /* STEs with lookup type FLEX_PARSER_{0/1} includes
* flex parsers_{0-3}/{4-7} respectively.
*/
is_ipv4 = DR_MASK_IS_ICMPV4_SET(&mask->misc3);
parser_id = is_ipv4 ? sb->caps->flex_parser_id_icmp_dw0 :
sb->caps->flex_parser_id_icmpv6_dw0;
sb->lu_type = parser_id > DR_STE_MAX_FLEX_0_ID ?
DR_STE_V0_LU_TYPE_FLEX_PARSER_1 :
DR_STE_V0_LU_TYPE_FLEX_PARSER_0;
sb->byte_mask = mlx5dr_ste_conv_bit_to_byte_mask(sb->bit_mask); sb->byte_mask = mlx5dr_ste_conv_bit_to_byte_mask(sb->bit_mask);
sb->ste_build_tag_func = &dr_ste_v0_build_icmp_tag; sb->ste_build_tag_func = &dr_ste_v0_build_icmp_tag;
return 0;
} }
static int static int
......
...@@ -1337,7 +1337,7 @@ static int dr_ste_v1_build_icmp_tag(struct mlx5dr_match_param *value, ...@@ -1337,7 +1337,7 @@ static int dr_ste_v1_build_icmp_tag(struct mlx5dr_match_param *value,
return 0; return 0;
} }
static int dr_ste_v1_build_icmp_init(struct mlx5dr_ste_build *sb, static void dr_ste_v1_build_icmp_init(struct mlx5dr_ste_build *sb,
struct mlx5dr_match_param *mask) struct mlx5dr_match_param *mask)
{ {
dr_ste_v1_build_icmp_tag(mask, sb, sb->bit_mask); dr_ste_v1_build_icmp_tag(mask, sb, sb->bit_mask);
...@@ -1345,8 +1345,6 @@ static int dr_ste_v1_build_icmp_init(struct mlx5dr_ste_build *sb, ...@@ -1345,8 +1345,6 @@ static int dr_ste_v1_build_icmp_init(struct mlx5dr_ste_build *sb,
sb->lu_type = DR_STE_V1_LU_TYPE_ETHL4_MISC_O; sb->lu_type = DR_STE_V1_LU_TYPE_ETHL4_MISC_O;
sb->byte_mask = mlx5dr_ste_conv_bit_to_byte_mask(sb->bit_mask); sb->byte_mask = mlx5dr_ste_conv_bit_to_byte_mask(sb->bit_mask);
sb->ste_build_tag_func = &dr_ste_v1_build_icmp_tag; sb->ste_build_tag_func = &dr_ste_v1_build_icmp_tag;
return 0;
} }
static int dr_ste_v1_build_general_purpose_tag(struct mlx5dr_match_param *value, static int dr_ste_v1_build_general_purpose_tag(struct mlx5dr_match_param *value,
......
...@@ -393,7 +393,7 @@ void mlx5dr_ste_build_tnl_mpls(struct mlx5dr_ste_ctx *ste_ctx, ...@@ -393,7 +393,7 @@ void mlx5dr_ste_build_tnl_mpls(struct mlx5dr_ste_ctx *ste_ctx,
struct mlx5dr_ste_build *sb, struct mlx5dr_ste_build *sb,
struct mlx5dr_match_param *mask, struct mlx5dr_match_param *mask,
bool inner, bool rx); bool inner, bool rx);
int mlx5dr_ste_build_icmp(struct mlx5dr_ste_ctx *ste_ctx, void mlx5dr_ste_build_icmp(struct mlx5dr_ste_ctx *ste_ctx,
struct mlx5dr_ste_build *sb, struct mlx5dr_ste_build *sb,
struct mlx5dr_match_param *mask, struct mlx5dr_match_param *mask,
struct mlx5dr_cmd_caps *caps, struct mlx5dr_cmd_caps *caps,
......
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