@@ -146,17 +146,15 @@ dr_matcher_supp_flex_parser_vxlan_gpe(struct mlx5dr_domain *dmn)
146146
147147int 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
168166static 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 ,
0 commit comments