Skip to content

Commit 667f264

Browse files
alexveskerSaeed Mahameed
authored andcommitted
net/mlx5: DR, Support IPv4 and IPv6 mixed matcher
Until now SW steering supported matchers that are IPv4 and IPv6. The limitation was mixed matchers in which the outer header IP version was different from the inner header IP version. To support the mixed matcher we create all the possible ste_builder combinations, once we create a rule we select the correct one to be used for rule creation. Signed-off-by: Alex Vesker <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]>
1 parent 1cdc14e commit 667f264

File tree

3 files changed

+52
-43
lines changed

3 files changed

+52
-43
lines changed

drivers/net/ethernet/mellanox/mlx5/core/steering/dr_matcher.c

Lines changed: 33 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -146,17 +146,15 @@ dr_matcher_supp_flex_parser_vxlan_gpe(struct mlx5dr_domain *dmn)
146146

147147
int mlx5dr_matcher_select_builders(struct mlx5dr_matcher *matcher,
148148
struct mlx5dr_matcher_rx_tx *nic_matcher,
149-
bool ipv6)
149+
enum mlx5dr_ipv outer_ipv,
150+
enum mlx5dr_ipv inner_ipv)
150151
{
151-
if (ipv6) {
152-
nic_matcher->ste_builder = nic_matcher->ste_builder6;
153-
nic_matcher->num_of_builders = nic_matcher->num_of_builders6;
154-
} else {
155-
nic_matcher->ste_builder = nic_matcher->ste_builder4;
156-
nic_matcher->num_of_builders = nic_matcher->num_of_builders4;
157-
}
152+
nic_matcher->ste_builder =
153+
nic_matcher->ste_builder_arr[outer_ipv][inner_ipv];
154+
nic_matcher->num_of_builders =
155+
nic_matcher->num_of_builders_arr[outer_ipv][inner_ipv];
158156

159-
if (!nic_matcher->num_of_builders) {
157+
if (!nic_matcher->ste_builder) {
160158
mlx5dr_dbg(matcher->tbl->dmn,
161159
"Rule not supported on this matcher due to IP related fields\n");
162160
return -EINVAL;
@@ -167,26 +165,19 @@ int mlx5dr_matcher_select_builders(struct mlx5dr_matcher *matcher,
167165

168166
static int dr_matcher_set_ste_builders(struct mlx5dr_matcher *matcher,
169167
struct mlx5dr_matcher_rx_tx *nic_matcher,
170-
bool ipv6)
168+
enum mlx5dr_ipv outer_ipv,
169+
enum mlx5dr_ipv inner_ipv)
171170
{
172171
struct mlx5dr_domain_rx_tx *nic_dmn = nic_matcher->nic_tbl->nic_dmn;
173172
struct mlx5dr_domain *dmn = matcher->tbl->dmn;
174173
struct mlx5dr_match_param mask = {};
175174
struct mlx5dr_match_misc3 *misc3;
176175
struct mlx5dr_ste_build *sb;
177-
u8 *num_of_builders;
178176
bool inner, rx;
179177
int idx = 0;
180178
int ret, i;
181179

182-
if (ipv6) {
183-
sb = nic_matcher->ste_builder6;
184-
num_of_builders = &nic_matcher->num_of_builders6;
185-
} else {
186-
sb = nic_matcher->ste_builder4;
187-
num_of_builders = &nic_matcher->num_of_builders4;
188-
}
189-
180+
sb = nic_matcher->ste_builder_arr[outer_ipv][inner_ipv];
190181
rx = nic_dmn->ste_type == MLX5DR_STE_TYPE_RX;
191182

192183
/* Create a temporary mask to track and clear used mask fields */
@@ -249,7 +240,7 @@ static int dr_matcher_set_ste_builders(struct mlx5dr_matcher *matcher,
249240
if (DR_MASK_IS_L2_DST(mask.outer, mask.misc, outer))
250241
mlx5dr_ste_build_eth_l2_dst(&sb[idx++], &mask, inner, rx);
251242

252-
if (ipv6) {
243+
if (outer_ipv == DR_RULE_IPV6) {
253244
if (dr_mask_is_dst_addr_set(&mask.outer))
254245
mlx5dr_ste_build_eth_l3_ipv6_dst(&sb[idx++], &mask,
255246
inner, rx);
@@ -325,7 +316,7 @@ static int dr_matcher_set_ste_builders(struct mlx5dr_matcher *matcher,
325316
if (DR_MASK_IS_L2_DST(mask.inner, mask.misc, inner))
326317
mlx5dr_ste_build_eth_l2_dst(&sb[idx++], &mask, inner, rx);
327318

328-
if (ipv6) {
319+
if (inner_ipv == DR_RULE_IPV6) {
329320
if (dr_mask_is_dst_addr_set(&mask.inner))
330321
mlx5dr_ste_build_eth_l3_ipv6_dst(&sb[idx++], &mask,
331322
inner, rx);
@@ -373,7 +364,8 @@ static int dr_matcher_set_ste_builders(struct mlx5dr_matcher *matcher,
373364
}
374365
}
375366

376-
*num_of_builders = idx;
367+
nic_matcher->ste_builder = sb;
368+
nic_matcher->num_of_builders_arr[outer_ipv][inner_ipv] = idx;
377369

378370
return 0;
379371
}
@@ -524,24 +516,33 @@ static void dr_matcher_uninit(struct mlx5dr_matcher *matcher)
524516
}
525517
}
526518

527-
static int dr_matcher_init_nic(struct mlx5dr_matcher *matcher,
528-
struct mlx5dr_matcher_rx_tx *nic_matcher)
519+
static int dr_matcher_set_all_ste_builders(struct mlx5dr_matcher *matcher,
520+
struct mlx5dr_matcher_rx_tx *nic_matcher)
529521
{
530522
struct mlx5dr_domain *dmn = matcher->tbl->dmn;
531-
int ret, ret_v4, ret_v6;
532523

533-
ret_v4 = dr_matcher_set_ste_builders(matcher, nic_matcher, false);
534-
ret_v6 = dr_matcher_set_ste_builders(matcher, nic_matcher, true);
524+
dr_matcher_set_ste_builders(matcher, nic_matcher, DR_RULE_IPV4, DR_RULE_IPV4);
525+
dr_matcher_set_ste_builders(matcher, nic_matcher, DR_RULE_IPV4, DR_RULE_IPV6);
526+
dr_matcher_set_ste_builders(matcher, nic_matcher, DR_RULE_IPV6, DR_RULE_IPV4);
527+
dr_matcher_set_ste_builders(matcher, nic_matcher, DR_RULE_IPV6, DR_RULE_IPV6);
535528

536-
if (ret_v4 && ret_v6) {
529+
if (!nic_matcher->ste_builder) {
537530
mlx5dr_dbg(dmn, "Cannot generate IPv4 or IPv6 rules with given mask\n");
538531
return -EINVAL;
539532
}
540533

541-
if (!ret_v4)
542-
nic_matcher->ste_builder = nic_matcher->ste_builder4;
543-
else
544-
nic_matcher->ste_builder = nic_matcher->ste_builder6;
534+
return 0;
535+
}
536+
537+
static int dr_matcher_init_nic(struct mlx5dr_matcher *matcher,
538+
struct mlx5dr_matcher_rx_tx *nic_matcher)
539+
{
540+
struct mlx5dr_domain *dmn = matcher->tbl->dmn;
541+
int ret;
542+
543+
ret = dr_matcher_set_all_ste_builders(matcher, nic_matcher);
544+
if (ret)
545+
return ret;
545546

546547
nic_matcher->e_anchor = mlx5dr_ste_htbl_alloc(dmn->ste_icm_pool,
547548
DR_CHUNK_SIZE_1,

drivers/net/ethernet/mellanox/mlx5/core/steering/dr_rule.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -954,12 +954,12 @@ static int dr_rule_destroy_rule(struct mlx5dr_rule *rule)
954954
return 0;
955955
}
956956

957-
static bool dr_rule_is_ipv6(struct mlx5dr_match_param *param)
957+
static enum mlx5dr_ipv dr_rule_get_ipv(struct mlx5dr_match_spec *spec)
958958
{
959-
return (param->outer.ip_version == 6 ||
960-
param->inner.ip_version == 6 ||
961-
param->outer.ethertype == ETH_P_IPV6 ||
962-
param->inner.ethertype == ETH_P_IPV6);
959+
if (spec->ip_version == 6 || spec->ethertype == ETH_P_IPV6)
960+
return DR_RULE_IPV6;
961+
962+
return DR_RULE_IPV4;
963963
}
964964

965965
static bool dr_rule_skip(enum mlx5dr_domain_type domain,
@@ -1023,7 +1023,8 @@ dr_rule_create_rule_nic(struct mlx5dr_rule *rule,
10231023

10241024
ret = mlx5dr_matcher_select_builders(matcher,
10251025
nic_matcher,
1026-
dr_rule_is_ipv6(param));
1026+
dr_rule_get_ipv(&param->outer),
1027+
dr_rule_get_ipv(&param->inner));
10271028
if (ret)
10281029
goto out_err;
10291030

drivers/net/ethernet/mellanox/mlx5/core/steering/dr_types.h

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,12 @@ enum mlx5dr_action_type {
106106
DR_ACTION_TYP_MAX,
107107
};
108108

109+
enum mlx5dr_ipv {
110+
DR_RULE_IPV4,
111+
DR_RULE_IPV6,
112+
DR_RULE_IPV_MAX,
113+
};
114+
109115
struct mlx5dr_icm_pool;
110116
struct mlx5dr_icm_chunk;
111117
struct mlx5dr_icm_bucket;
@@ -679,11 +685,11 @@ struct mlx5dr_matcher_rx_tx {
679685
struct mlx5dr_ste_htbl *s_htbl;
680686
struct mlx5dr_ste_htbl *e_anchor;
681687
struct mlx5dr_ste_build *ste_builder;
682-
struct mlx5dr_ste_build ste_builder4[DR_RULE_MAX_STES];
683-
struct mlx5dr_ste_build ste_builder6[DR_RULE_MAX_STES];
688+
struct mlx5dr_ste_build ste_builder_arr[DR_RULE_IPV_MAX]
689+
[DR_RULE_IPV_MAX]
690+
[DR_RULE_MAX_STES];
684691
u8 num_of_builders;
685-
u8 num_of_builders4;
686-
u8 num_of_builders6;
692+
u8 num_of_builders_arr[DR_RULE_IPV_MAX][DR_RULE_IPV_MAX];
687693
u64 default_icm_addr;
688694
struct mlx5dr_table_rx_tx *nic_tbl;
689695
};
@@ -812,7 +818,8 @@ mlx5dr_matcher_supp_flex_parser_icmp_v6(struct mlx5dr_cmd_caps *caps)
812818

813819
int mlx5dr_matcher_select_builders(struct mlx5dr_matcher *matcher,
814820
struct mlx5dr_matcher_rx_tx *nic_matcher,
815-
bool ipv6);
821+
enum mlx5dr_ipv outer_ipv,
822+
enum mlx5dr_ipv inner_ipv);
816823

817824
static inline u32
818825
mlx5dr_icm_pool_chunk_size_to_entries(enum mlx5dr_icm_chunk_size chunk_size)

0 commit comments

Comments
 (0)