@@ -146,17 +146,15 @@ dr_matcher_supp_flex_parser_vxlan_gpe(struct mlx5dr_domain *dmn)
146
146
147
147
int mlx5dr_matcher_select_builders (struct mlx5dr_matcher * matcher ,
148
148
struct mlx5dr_matcher_rx_tx * nic_matcher ,
149
- bool ipv6 )
149
+ enum mlx5dr_ipv outer_ipv ,
150
+ enum mlx5dr_ipv inner_ipv )
150
151
{
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 ];
158
156
159
- if (!nic_matcher -> num_of_builders ) {
157
+ if (!nic_matcher -> ste_builder ) {
160
158
mlx5dr_dbg (matcher -> tbl -> dmn ,
161
159
"Rule not supported on this matcher due to IP related fields\n" );
162
160
return - EINVAL ;
@@ -167,26 +165,19 @@ int mlx5dr_matcher_select_builders(struct mlx5dr_matcher *matcher,
167
165
168
166
static int dr_matcher_set_ste_builders (struct mlx5dr_matcher * matcher ,
169
167
struct mlx5dr_matcher_rx_tx * nic_matcher ,
170
- bool ipv6 )
168
+ enum mlx5dr_ipv outer_ipv ,
169
+ enum mlx5dr_ipv inner_ipv )
171
170
{
172
171
struct mlx5dr_domain_rx_tx * nic_dmn = nic_matcher -> nic_tbl -> nic_dmn ;
173
172
struct mlx5dr_domain * dmn = matcher -> tbl -> dmn ;
174
173
struct mlx5dr_match_param mask = {};
175
174
struct mlx5dr_match_misc3 * misc3 ;
176
175
struct mlx5dr_ste_build * sb ;
177
- u8 * num_of_builders ;
178
176
bool inner , rx ;
179
177
int idx = 0 ;
180
178
int ret , i ;
181
179
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 ];
190
181
rx = nic_dmn -> ste_type == MLX5DR_STE_TYPE_RX ;
191
182
192
183
/* 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,
249
240
if (DR_MASK_IS_L2_DST (mask .outer , mask .misc , outer ))
250
241
mlx5dr_ste_build_eth_l2_dst (& sb [idx ++ ], & mask , inner , rx );
251
242
252
- if (ipv6 ) {
243
+ if (outer_ipv == DR_RULE_IPV6 ) {
253
244
if (dr_mask_is_dst_addr_set (& mask .outer ))
254
245
mlx5dr_ste_build_eth_l3_ipv6_dst (& sb [idx ++ ], & mask ,
255
246
inner , rx );
@@ -325,7 +316,7 @@ static int dr_matcher_set_ste_builders(struct mlx5dr_matcher *matcher,
325
316
if (DR_MASK_IS_L2_DST (mask .inner , mask .misc , inner ))
326
317
mlx5dr_ste_build_eth_l2_dst (& sb [idx ++ ], & mask , inner , rx );
327
318
328
- if (ipv6 ) {
319
+ if (inner_ipv == DR_RULE_IPV6 ) {
329
320
if (dr_mask_is_dst_addr_set (& mask .inner ))
330
321
mlx5dr_ste_build_eth_l3_ipv6_dst (& sb [idx ++ ], & mask ,
331
322
inner , rx );
@@ -373,7 +364,8 @@ static int dr_matcher_set_ste_builders(struct mlx5dr_matcher *matcher,
373
364
}
374
365
}
375
366
376
- * num_of_builders = idx ;
367
+ nic_matcher -> ste_builder = sb ;
368
+ nic_matcher -> num_of_builders_arr [outer_ipv ][inner_ipv ] = idx ;
377
369
378
370
return 0 ;
379
371
}
@@ -524,24 +516,33 @@ static void dr_matcher_uninit(struct mlx5dr_matcher *matcher)
524
516
}
525
517
}
526
518
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 )
529
521
{
530
522
struct mlx5dr_domain * dmn = matcher -> tbl -> dmn ;
531
- int ret , ret_v4 , ret_v6 ;
532
523
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 );
535
528
536
- if (ret_v4 && ret_v6 ) {
529
+ if (! nic_matcher -> ste_builder ) {
537
530
mlx5dr_dbg (dmn , "Cannot generate IPv4 or IPv6 rules with given mask\n" );
538
531
return - EINVAL ;
539
532
}
540
533
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 ;
545
546
546
547
nic_matcher -> e_anchor = mlx5dr_ste_htbl_alloc (dmn -> ste_icm_pool ,
547
548
DR_CHUNK_SIZE_1 ,
0 commit comments