mirror of
https://github.com/torvalds/linux.git
synced 2024-12-20 18:11:47 +00:00
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: Muhammad Sammar <muhammads@nvidia.com> Signed-off-by: Yevgeny Kliteynik <kliteyn@nvidia.com> Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
This commit is contained in:
parent
160e9cb37a
commit
4923938d2f
@ -376,13 +376,11 @@ static int dr_matcher_set_ste_builders(struct mlx5dr_matcher *matcher,
|
||||
mlx5dr_ste_build_tnl_mpls(ste_ctx, &sb[idx++],
|
||||
&mask, inner, rx);
|
||||
|
||||
if (dr_mask_is_icmp(&mask, dmn)) {
|
||||
ret = mlx5dr_ste_build_icmp(ste_ctx, &sb[idx++],
|
||||
&mask, &dmn->info.caps,
|
||||
inner, rx);
|
||||
if (ret)
|
||||
return ret;
|
||||
}
|
||||
if (dr_mask_is_icmp(&mask, dmn))
|
||||
mlx5dr_ste_build_icmp(ste_ctx, &sb[idx++],
|
||||
&mask, &dmn->info.caps,
|
||||
inner, rx);
|
||||
|
||||
if (dr_mask_is_tnl_gre_set(&mask.misc))
|
||||
mlx5dr_ste_build_tnl_gre(ste_ctx, &sb[idx++],
|
||||
&mask, inner, rx);
|
||||
|
@ -1095,16 +1095,16 @@ void mlx5dr_ste_build_tnl_mpls(struct mlx5dr_ste_ctx *ste_ctx,
|
||||
ste_ctx->build_tnl_mpls_init(sb, mask);
|
||||
}
|
||||
|
||||
int mlx5dr_ste_build_icmp(struct mlx5dr_ste_ctx *ste_ctx,
|
||||
struct mlx5dr_ste_build *sb,
|
||||
struct mlx5dr_match_param *mask,
|
||||
struct mlx5dr_cmd_caps *caps,
|
||||
bool inner, bool rx)
|
||||
void mlx5dr_ste_build_icmp(struct mlx5dr_ste_ctx *ste_ctx,
|
||||
struct mlx5dr_ste_build *sb,
|
||||
struct mlx5dr_match_param *mask,
|
||||
struct mlx5dr_cmd_caps *caps,
|
||||
bool inner, bool rx)
|
||||
{
|
||||
sb->rx = rx;
|
||||
sb->inner = inner;
|
||||
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,
|
||||
|
@ -120,7 +120,7 @@ struct mlx5dr_ste_ctx {
|
||||
void DR_STE_CTX_BUILDER(mpls);
|
||||
void DR_STE_CTX_BUILDER(tnl_gre);
|
||||
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(eth_l4_misc);
|
||||
void DR_STE_CTX_BUILDER(tnl_vxlan_gpe);
|
||||
|
@ -1297,9 +1297,11 @@ dr_ste_v0_build_icmp_tag(struct mlx5dr_match_param *value,
|
||||
u32 *icmp_header_data;
|
||||
int dw0_location;
|
||||
int dw1_location;
|
||||
u8 *parser_ptr;
|
||||
u8 *icmp_type;
|
||||
u8 *icmp_code;
|
||||
bool is_ipv4;
|
||||
u32 icmp_hdr;
|
||||
|
||||
is_ipv4 = DR_MASK_IS_ICMPV4_SET(misc_3);
|
||||
if (is_ipv4) {
|
||||
@ -1316,47 +1318,40 @@ dr_ste_v0_build_icmp_tag(struct mlx5dr_match_param *value,
|
||||
dw1_location = sb->caps->flex_parser_id_icmpv6_dw1;
|
||||
}
|
||||
|
||||
switch (dw0_location) {
|
||||
case 4:
|
||||
MLX5_SET(ste_flex_parser_1, tag, flex_parser_4,
|
||||
(*icmp_type << ICMP_TYPE_OFFSET_FIRST_DW) |
|
||||
(*icmp_code << ICMP_TYPE_OFFSET_FIRST_DW));
|
||||
parser_ptr = dr_ste_calc_flex_parser_offset(tag, dw0_location);
|
||||
icmp_hdr = (*icmp_type << ICMP_TYPE_OFFSET_FIRST_DW) |
|
||||
(*icmp_code << ICMP_CODE_OFFSET_FIRST_DW);
|
||||
*(__be32 *)parser_ptr = cpu_to_be32(icmp_hdr);
|
||||
*icmp_code = 0;
|
||||
*icmp_type = 0;
|
||||
|
||||
*icmp_type = 0;
|
||||
*icmp_code = 0;
|
||||
break;
|
||||
default:
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
switch (dw1_location) {
|
||||
case 5:
|
||||
MLX5_SET(ste_flex_parser_1, tag, flex_parser_5,
|
||||
*icmp_header_data);
|
||||
*icmp_header_data = 0;
|
||||
break;
|
||||
default:
|
||||
return -EINVAL;
|
||||
}
|
||||
parser_ptr = dr_ste_calc_flex_parser_offset(tag, dw1_location);
|
||||
*(__be32 *)parser_ptr = cpu_to_be32(*icmp_header_data);
|
||||
*icmp_header_data = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
static void
|
||||
dr_ste_v0_build_icmp_init(struct mlx5dr_ste_build *sb,
|
||||
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);
|
||||
if (ret)
|
||||
return ret;
|
||||
dr_ste_v0_build_icmp_tag(mask, sb, sb->bit_mask);
|
||||
|
||||
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->ste_build_tag_func = &dr_ste_v0_build_icmp_tag;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -1337,16 +1337,14 @@ static int dr_ste_v1_build_icmp_tag(struct mlx5dr_match_param *value,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int dr_ste_v1_build_icmp_init(struct mlx5dr_ste_build *sb,
|
||||
struct mlx5dr_match_param *mask)
|
||||
static void dr_ste_v1_build_icmp_init(struct mlx5dr_ste_build *sb,
|
||||
struct mlx5dr_match_param *mask)
|
||||
{
|
||||
dr_ste_v1_build_icmp_tag(mask, sb, sb->bit_mask);
|
||||
|
||||
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->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,
|
||||
|
@ -393,11 +393,11 @@ void mlx5dr_ste_build_tnl_mpls(struct mlx5dr_ste_ctx *ste_ctx,
|
||||
struct mlx5dr_ste_build *sb,
|
||||
struct mlx5dr_match_param *mask,
|
||||
bool inner, bool rx);
|
||||
int mlx5dr_ste_build_icmp(struct mlx5dr_ste_ctx *ste_ctx,
|
||||
struct mlx5dr_ste_build *sb,
|
||||
struct mlx5dr_match_param *mask,
|
||||
struct mlx5dr_cmd_caps *caps,
|
||||
bool inner, bool rx);
|
||||
void mlx5dr_ste_build_icmp(struct mlx5dr_ste_ctx *ste_ctx,
|
||||
struct mlx5dr_ste_build *sb,
|
||||
struct mlx5dr_match_param *mask,
|
||||
struct mlx5dr_cmd_caps *caps,
|
||||
bool inner, bool rx);
|
||||
void mlx5dr_ste_build_tnl_vxlan_gpe(struct mlx5dr_ste_ctx *ste_ctx,
|
||||
struct mlx5dr_ste_build *sb,
|
||||
struct mlx5dr_match_param *mask,
|
||||
|
Loading…
Reference in New Issue
Block a user