@@ -200,7 +200,7 @@ static void hws_matcher_set_rtc_attr_sz(struct mlx5hws_matcher *matcher,
200
200
enum mlx5hws_matcher_rtc_type rtc_type ,
201
201
bool is_mirror )
202
202
{
203
- struct mlx5hws_pool_chunk * ste = & matcher -> action_ste [ MLX5HWS_ACTION_STE_IDX_ANY ] .ste ;
203
+ struct mlx5hws_pool_chunk * ste = & matcher -> action_ste .ste ;
204
204
enum mlx5hws_matcher_flow_src flow_src = matcher -> attr .optimize_flow_src ;
205
205
bool is_match_rtc = rtc_type == HWS_MATCHER_RTC_TYPE_MATCH ;
206
206
@@ -217,8 +217,7 @@ static void hws_matcher_set_rtc_attr_sz(struct mlx5hws_matcher *matcher,
217
217
}
218
218
219
219
static int hws_matcher_create_rtc (struct mlx5hws_matcher * matcher ,
220
- enum mlx5hws_matcher_rtc_type rtc_type ,
221
- u8 action_ste_selector )
220
+ enum mlx5hws_matcher_rtc_type rtc_type )
222
221
{
223
222
struct mlx5hws_matcher_attr * attr = & matcher -> attr ;
224
223
struct mlx5hws_cmd_rtc_create_attr rtc_attr = {0 };
@@ -278,7 +277,7 @@ static int hws_matcher_create_rtc(struct mlx5hws_matcher *matcher,
278
277
break ;
279
278
280
279
case HWS_MATCHER_RTC_TYPE_STE_ARRAY :
281
- action_ste = & matcher -> action_ste [ action_ste_selector ] ;
280
+ action_ste = & matcher -> action_ste ;
282
281
283
282
rtc_0_id = & action_ste -> rtc_0_id ;
284
283
rtc_1_id = & action_ste -> rtc_1_id ;
@@ -350,8 +349,7 @@ static int hws_matcher_create_rtc(struct mlx5hws_matcher *matcher,
350
349
}
351
350
352
351
static void hws_matcher_destroy_rtc (struct mlx5hws_matcher * matcher ,
353
- enum mlx5hws_matcher_rtc_type rtc_type ,
354
- u8 action_ste_selector )
352
+ enum mlx5hws_matcher_rtc_type rtc_type )
355
353
{
356
354
struct mlx5hws_matcher_action_ste * action_ste ;
357
355
struct mlx5hws_table * tbl = matcher -> tbl ;
@@ -367,7 +365,7 @@ static void hws_matcher_destroy_rtc(struct mlx5hws_matcher *matcher,
367
365
ste = & matcher -> match_ste .ste ;
368
366
break ;
369
367
case HWS_MATCHER_RTC_TYPE_STE_ARRAY :
370
- action_ste = & matcher -> action_ste [ action_ste_selector ] ;
368
+ action_ste = & matcher -> action_ste ;
371
369
rtc_0_id = action_ste -> rtc_0_id ;
372
370
rtc_1_id = action_ste -> rtc_1_id ;
373
371
ste_pool = action_ste -> pool ;
@@ -458,20 +456,13 @@ static int hws_matcher_resize_init(struct mlx5hws_matcher *src_matcher)
458
456
if (!resize_data )
459
457
return - ENOMEM ;
460
458
461
- resize_data -> max_stes = src_matcher -> action_ste [MLX5HWS_ACTION_STE_IDX_ANY ].max_stes ;
462
-
463
- resize_data -> action_ste [0 ].stc = src_matcher -> action_ste [0 ].stc ;
464
- resize_data -> action_ste [0 ].rtc_0_id = src_matcher -> action_ste [0 ].rtc_0_id ;
465
- resize_data -> action_ste [0 ].rtc_1_id = src_matcher -> action_ste [0 ].rtc_1_id ;
466
- resize_data -> action_ste [0 ].pool = src_matcher -> action_ste [0 ].max_stes ?
467
- src_matcher -> action_ste [0 ].pool :
468
- NULL ;
469
- resize_data -> action_ste [1 ].stc = src_matcher -> action_ste [1 ].stc ;
470
- resize_data -> action_ste [1 ].rtc_0_id = src_matcher -> action_ste [1 ].rtc_0_id ;
471
- resize_data -> action_ste [1 ].rtc_1_id = src_matcher -> action_ste [1 ].rtc_1_id ;
472
- resize_data -> action_ste [1 ].pool = src_matcher -> action_ste [1 ].max_stes ?
473
- src_matcher -> action_ste [1 ].pool :
474
- NULL ;
459
+ resize_data -> max_stes = src_matcher -> action_ste .max_stes ;
460
+
461
+ resize_data -> stc = src_matcher -> action_ste .stc ;
462
+ resize_data -> rtc_0_id = src_matcher -> action_ste .rtc_0_id ;
463
+ resize_data -> rtc_1_id = src_matcher -> action_ste .rtc_1_id ;
464
+ resize_data -> pool = src_matcher -> action_ste .max_stes ?
465
+ src_matcher -> action_ste .pool : NULL ;
475
466
476
467
/* Place the new resized matcher on the dst matcher's list */
477
468
list_add (& resize_data -> list_node , & src_matcher -> resize_dst -> resize_data );
@@ -504,42 +495,60 @@ static void hws_matcher_resize_uninit(struct mlx5hws_matcher *matcher)
504
495
if (resize_data -> max_stes ) {
505
496
mlx5hws_action_free_single_stc (matcher -> tbl -> ctx ,
506
497
matcher -> tbl -> type ,
507
- & resize_data -> action_ste [1 ].stc );
508
- mlx5hws_action_free_single_stc (matcher -> tbl -> ctx ,
509
- matcher -> tbl -> type ,
510
- & resize_data -> action_ste [0 ].stc );
498
+ & resize_data -> stc );
511
499
512
- if (matcher -> tbl -> type == MLX5HWS_TABLE_TYPE_FDB ) {
500
+ if (matcher -> tbl -> type == MLX5HWS_TABLE_TYPE_FDB )
513
501
mlx5hws_cmd_rtc_destroy (matcher -> tbl -> ctx -> mdev ,
514
- resize_data -> action_ste [1 ].rtc_1_id );
515
- mlx5hws_cmd_rtc_destroy (matcher -> tbl -> ctx -> mdev ,
516
- resize_data -> action_ste [0 ].rtc_1_id );
517
- }
518
- mlx5hws_cmd_rtc_destroy (matcher -> tbl -> ctx -> mdev ,
519
- resize_data -> action_ste [1 ].rtc_0_id );
502
+ resize_data -> rtc_1_id );
503
+
520
504
mlx5hws_cmd_rtc_destroy (matcher -> tbl -> ctx -> mdev ,
521
- resize_data -> action_ste [0 ].rtc_0_id );
522
- if (resize_data -> action_ste [MLX5HWS_ACTION_STE_IDX_ANY ].pool ) {
523
- mlx5hws_pool_destroy (resize_data -> action_ste [1 ].pool );
524
- mlx5hws_pool_destroy (resize_data -> action_ste [0 ].pool );
525
- }
505
+ resize_data -> rtc_0_id );
506
+
507
+ if (resize_data -> pool )
508
+ mlx5hws_pool_destroy (resize_data -> pool );
526
509
}
527
510
528
511
kfree (resize_data );
529
512
}
530
513
}
531
514
532
- static int
533
- hws_matcher_bind_at_idx (struct mlx5hws_matcher * matcher , u8 action_ste_selector )
515
+ static int hws_matcher_bind_at (struct mlx5hws_matcher * matcher )
534
516
{
517
+ bool is_jumbo = mlx5hws_matcher_mt_is_jumbo (matcher -> mt );
535
518
struct mlx5hws_cmd_stc_modify_attr stc_attr = {0 };
536
519
struct mlx5hws_matcher_action_ste * action_ste ;
537
520
struct mlx5hws_table * tbl = matcher -> tbl ;
538
521
struct mlx5hws_pool_attr pool_attr = {0 };
539
522
struct mlx5hws_context * ctx = tbl -> ctx ;
540
- int ret ;
523
+ u32 required_stes ;
524
+ u8 max_stes = 0 ;
525
+ int i , ret ;
541
526
542
- action_ste = & matcher -> action_ste [action_ste_selector ];
527
+ if (matcher -> flags & MLX5HWS_MATCHER_FLAGS_COLLISION )
528
+ return 0 ;
529
+
530
+ for (i = 0 ; i < matcher -> num_of_at ; i ++ ) {
531
+ struct mlx5hws_action_template * at = & matcher -> at [i ];
532
+
533
+ ret = hws_matcher_check_and_process_at (matcher , at );
534
+ if (ret ) {
535
+ mlx5hws_err (ctx , "Invalid at %d" , i );
536
+ return ret ;
537
+ }
538
+
539
+ required_stes = at -> num_of_action_stes - (!is_jumbo || at -> only_term );
540
+ max_stes = max (max_stes , required_stes );
541
+
542
+ /* Future: Optimize reparse */
543
+ }
544
+
545
+ /* There are no additional STEs required for matcher */
546
+ if (!max_stes )
547
+ return 0 ;
548
+
549
+ matcher -> action_ste .max_stes = max_stes ;
550
+
551
+ action_ste = & matcher -> action_ste ;
543
552
544
553
/* Allocate action STE mempool */
545
554
pool_attr .table_type = tbl -> type ;
@@ -555,7 +564,7 @@ hws_matcher_bind_at_idx(struct mlx5hws_matcher *matcher, u8 action_ste_selector)
555
564
}
556
565
557
566
/* Allocate action RTC */
558
- ret = hws_matcher_create_rtc (matcher , HWS_MATCHER_RTC_TYPE_STE_ARRAY , action_ste_selector );
567
+ ret = hws_matcher_create_rtc (matcher , HWS_MATCHER_RTC_TYPE_STE_ARRAY );
559
568
if (ret ) {
560
569
mlx5hws_err (ctx , "Failed to create action RTC\n" );
561
570
goto free_ste_pool ;
@@ -579,84 +588,29 @@ hws_matcher_bind_at_idx(struct mlx5hws_matcher *matcher, u8 action_ste_selector)
579
588
return 0 ;
580
589
581
590
free_rtc :
582
- hws_matcher_destroy_rtc (matcher , HWS_MATCHER_RTC_TYPE_STE_ARRAY , action_ste_selector );
591
+ hws_matcher_destroy_rtc (matcher , HWS_MATCHER_RTC_TYPE_STE_ARRAY );
583
592
free_ste_pool :
584
593
mlx5hws_pool_destroy (action_ste -> pool );
585
594
return ret ;
586
595
}
587
596
588
- static void hws_matcher_unbind_at_idx (struct mlx5hws_matcher * matcher , u8 action_ste_selector )
597
+ static void hws_matcher_unbind_at (struct mlx5hws_matcher * matcher )
589
598
{
590
599
struct mlx5hws_matcher_action_ste * action_ste ;
591
600
struct mlx5hws_table * tbl = matcher -> tbl ;
592
601
593
- action_ste = & matcher -> action_ste [ action_ste_selector ] ;
602
+ action_ste = & matcher -> action_ste ;
594
603
595
604
if (!action_ste -> max_stes ||
596
605
matcher -> flags & MLX5HWS_MATCHER_FLAGS_COLLISION ||
597
606
mlx5hws_matcher_is_in_resize (matcher ))
598
607
return ;
599
608
600
609
mlx5hws_action_free_single_stc (tbl -> ctx , tbl -> type , & action_ste -> stc );
601
- hws_matcher_destroy_rtc (matcher , HWS_MATCHER_RTC_TYPE_STE_ARRAY , action_ste_selector );
610
+ hws_matcher_destroy_rtc (matcher , HWS_MATCHER_RTC_TYPE_STE_ARRAY );
602
611
mlx5hws_pool_destroy (action_ste -> pool );
603
612
}
604
613
605
- static int hws_matcher_bind_at (struct mlx5hws_matcher * matcher )
606
- {
607
- bool is_jumbo = mlx5hws_matcher_mt_is_jumbo (matcher -> mt );
608
- struct mlx5hws_table * tbl = matcher -> tbl ;
609
- struct mlx5hws_context * ctx = tbl -> ctx ;
610
- u32 required_stes ;
611
- u8 max_stes = 0 ;
612
- int i , ret ;
613
-
614
- if (matcher -> flags & MLX5HWS_MATCHER_FLAGS_COLLISION )
615
- return 0 ;
616
-
617
- for (i = 0 ; i < matcher -> num_of_at ; i ++ ) {
618
- struct mlx5hws_action_template * at = & matcher -> at [i ];
619
-
620
- ret = hws_matcher_check_and_process_at (matcher , at );
621
- if (ret ) {
622
- mlx5hws_err (ctx , "Invalid at %d" , i );
623
- return ret ;
624
- }
625
-
626
- required_stes = at -> num_of_action_stes - (!is_jumbo || at -> only_term );
627
- max_stes = max (max_stes , required_stes );
628
-
629
- /* Future: Optimize reparse */
630
- }
631
-
632
- /* There are no additional STEs required for matcher */
633
- if (!max_stes )
634
- return 0 ;
635
-
636
- matcher -> action_ste [0 ].max_stes = max_stes ;
637
- matcher -> action_ste [1 ].max_stes = max_stes ;
638
-
639
- ret = hws_matcher_bind_at_idx (matcher , 0 );
640
- if (ret )
641
- return ret ;
642
-
643
- ret = hws_matcher_bind_at_idx (matcher , 1 );
644
- if (ret )
645
- goto free_at_0 ;
646
-
647
- return 0 ;
648
-
649
- free_at_0 :
650
- hws_matcher_unbind_at_idx (matcher , 0 );
651
- return ret ;
652
- }
653
-
654
- static void hws_matcher_unbind_at (struct mlx5hws_matcher * matcher )
655
- {
656
- hws_matcher_unbind_at_idx (matcher , 1 );
657
- hws_matcher_unbind_at_idx (matcher , 0 );
658
- }
659
-
660
614
static int hws_matcher_bind_mt (struct mlx5hws_matcher * matcher )
661
615
{
662
616
struct mlx5hws_context * ctx = matcher -> tbl -> ctx ;
@@ -802,7 +756,7 @@ static int hws_matcher_create_and_connect(struct mlx5hws_matcher *matcher)
802
756
goto unbind_at ;
803
757
804
758
/* Allocate the RTC for the new matcher */
805
- ret = hws_matcher_create_rtc (matcher , HWS_MATCHER_RTC_TYPE_MATCH , 0 );
759
+ ret = hws_matcher_create_rtc (matcher , HWS_MATCHER_RTC_TYPE_MATCH );
806
760
if (ret )
807
761
goto destroy_end_ft ;
808
762
@@ -814,7 +768,7 @@ static int hws_matcher_create_and_connect(struct mlx5hws_matcher *matcher)
814
768
return 0 ;
815
769
816
770
destroy_rtc :
817
- hws_matcher_destroy_rtc (matcher , HWS_MATCHER_RTC_TYPE_MATCH , 0 );
771
+ hws_matcher_destroy_rtc (matcher , HWS_MATCHER_RTC_TYPE_MATCH );
818
772
destroy_end_ft :
819
773
hws_matcher_destroy_end_ft (matcher );
820
774
unbind_at :
@@ -828,7 +782,7 @@ static void hws_matcher_destroy_and_disconnect(struct mlx5hws_matcher *matcher)
828
782
{
829
783
hws_matcher_resize_uninit (matcher );
830
784
hws_matcher_disconnect (matcher );
831
- hws_matcher_destroy_rtc (matcher , HWS_MATCHER_RTC_TYPE_MATCH , 0 );
785
+ hws_matcher_destroy_rtc (matcher , HWS_MATCHER_RTC_TYPE_MATCH );
832
786
hws_matcher_destroy_end_ft (matcher );
833
787
hws_matcher_unbind_at (matcher );
834
788
hws_matcher_unbind_mt (matcher );
@@ -962,10 +916,9 @@ int mlx5hws_matcher_attach_at(struct mlx5hws_matcher *matcher,
962
916
return ret ;
963
917
964
918
required_stes = at -> num_of_action_stes - (!is_jumbo || at -> only_term );
965
- if (matcher -> action_ste [ MLX5HWS_ACTION_STE_IDX_ANY ] .max_stes < required_stes ) {
919
+ if (matcher -> action_ste .max_stes < required_stes ) {
966
920
mlx5hws_dbg (ctx , "Required STEs [%d] exceeds initial action template STE [%d]\n" ,
967
- required_stes ,
968
- matcher -> action_ste [MLX5HWS_ACTION_STE_IDX_ANY ].max_stes );
921
+ required_stes , matcher -> action_ste .max_stes );
969
922
return - ENOMEM ;
970
923
}
971
924
@@ -1149,8 +1102,7 @@ static int hws_matcher_resize_precheck(struct mlx5hws_matcher *src_matcher,
1149
1102
return - EINVAL ;
1150
1103
}
1151
1104
1152
- if (src_matcher -> action_ste [MLX5HWS_ACTION_STE_IDX_ANY ].max_stes >
1153
- dst_matcher -> action_ste [0 ].max_stes ) {
1105
+ if (src_matcher -> action_ste .max_stes > dst_matcher -> action_ste .max_stes ) {
1154
1106
mlx5hws_err (ctx , "Src/dst matcher max STEs mismatch\n" );
1155
1107
return - EINVAL ;
1156
1108
}
0 commit comments