@@ -200,7 +200,7 @@ static void hws_matcher_set_rtc_attr_sz(struct mlx5hws_matcher *matcher,
200200 enum mlx5hws_matcher_rtc_type rtc_type ,
201201 bool is_mirror )
202202{
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 ;
204204 enum mlx5hws_matcher_flow_src flow_src = matcher -> attr .optimize_flow_src ;
205205 bool is_match_rtc = rtc_type == HWS_MATCHER_RTC_TYPE_MATCH ;
206206
@@ -217,8 +217,7 @@ static void hws_matcher_set_rtc_attr_sz(struct mlx5hws_matcher *matcher,
217217}
218218
219219static 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 )
222221{
223222 struct mlx5hws_matcher_attr * attr = & matcher -> attr ;
224223 struct mlx5hws_cmd_rtc_create_attr rtc_attr = {0 };
@@ -278,7 +277,7 @@ static int hws_matcher_create_rtc(struct mlx5hws_matcher *matcher,
278277 break ;
279278
280279 case HWS_MATCHER_RTC_TYPE_STE_ARRAY :
281- action_ste = & matcher -> action_ste [ action_ste_selector ] ;
280+ action_ste = & matcher -> action_ste ;
282281
283282 rtc_0_id = & action_ste -> rtc_0_id ;
284283 rtc_1_id = & action_ste -> rtc_1_id ;
@@ -350,8 +349,7 @@ static int hws_matcher_create_rtc(struct mlx5hws_matcher *matcher,
350349}
351350
352351static 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 )
355353{
356354 struct mlx5hws_matcher_action_ste * action_ste ;
357355 struct mlx5hws_table * tbl = matcher -> tbl ;
@@ -367,7 +365,7 @@ static void hws_matcher_destroy_rtc(struct mlx5hws_matcher *matcher,
367365 ste = & matcher -> match_ste .ste ;
368366 break ;
369367 case HWS_MATCHER_RTC_TYPE_STE_ARRAY :
370- action_ste = & matcher -> action_ste [ action_ste_selector ] ;
368+ action_ste = & matcher -> action_ste ;
371369 rtc_0_id = action_ste -> rtc_0_id ;
372370 rtc_1_id = action_ste -> rtc_1_id ;
373371 ste_pool = action_ste -> pool ;
@@ -458,20 +456,13 @@ static int hws_matcher_resize_init(struct mlx5hws_matcher *src_matcher)
458456 if (!resize_data )
459457 return - ENOMEM ;
460458
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 ;
475466
476467 /* Place the new resized matcher on the dst matcher's list */
477468 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)
504495 if (resize_data -> max_stes ) {
505496 mlx5hws_action_free_single_stc (matcher -> tbl -> ctx ,
506497 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 );
511499
512- if (matcher -> tbl -> type == MLX5HWS_TABLE_TYPE_FDB ) {
500+ if (matcher -> tbl -> type == MLX5HWS_TABLE_TYPE_FDB )
513501 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+
520504 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 );
526509 }
527510
528511 kfree (resize_data );
529512 }
530513}
531514
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 )
534516{
517+ bool is_jumbo = mlx5hws_matcher_mt_is_jumbo (matcher -> mt );
535518 struct mlx5hws_cmd_stc_modify_attr stc_attr = {0 };
536519 struct mlx5hws_matcher_action_ste * action_ste ;
537520 struct mlx5hws_table * tbl = matcher -> tbl ;
538521 struct mlx5hws_pool_attr pool_attr = {0 };
539522 struct mlx5hws_context * ctx = tbl -> ctx ;
540- int ret ;
523+ u32 required_stes ;
524+ u8 max_stes = 0 ;
525+ int i , ret ;
541526
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 ;
543552
544553 /* Allocate action STE mempool */
545554 pool_attr .table_type = tbl -> type ;
@@ -555,7 +564,7 @@ hws_matcher_bind_at_idx(struct mlx5hws_matcher *matcher, u8 action_ste_selector)
555564 }
556565
557566 /* 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 );
559568 if (ret ) {
560569 mlx5hws_err (ctx , "Failed to create action RTC\n" );
561570 goto free_ste_pool ;
@@ -579,84 +588,29 @@ hws_matcher_bind_at_idx(struct mlx5hws_matcher *matcher, u8 action_ste_selector)
579588 return 0 ;
580589
581590free_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 );
583592free_ste_pool :
584593 mlx5hws_pool_destroy (action_ste -> pool );
585594 return ret ;
586595}
587596
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 )
589598{
590599 struct mlx5hws_matcher_action_ste * action_ste ;
591600 struct mlx5hws_table * tbl = matcher -> tbl ;
592601
593- action_ste = & matcher -> action_ste [ action_ste_selector ] ;
602+ action_ste = & matcher -> action_ste ;
594603
595604 if (!action_ste -> max_stes ||
596605 matcher -> flags & MLX5HWS_MATCHER_FLAGS_COLLISION ||
597606 mlx5hws_matcher_is_in_resize (matcher ))
598607 return ;
599608
600609 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 );
602611 mlx5hws_pool_destroy (action_ste -> pool );
603612}
604613
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-
660614static int hws_matcher_bind_mt (struct mlx5hws_matcher * matcher )
661615{
662616 struct mlx5hws_context * ctx = matcher -> tbl -> ctx ;
@@ -802,7 +756,7 @@ static int hws_matcher_create_and_connect(struct mlx5hws_matcher *matcher)
802756 goto unbind_at ;
803757
804758 /* 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 );
806760 if (ret )
807761 goto destroy_end_ft ;
808762
@@ -814,7 +768,7 @@ static int hws_matcher_create_and_connect(struct mlx5hws_matcher *matcher)
814768 return 0 ;
815769
816770destroy_rtc :
817- hws_matcher_destroy_rtc (matcher , HWS_MATCHER_RTC_TYPE_MATCH , 0 );
771+ hws_matcher_destroy_rtc (matcher , HWS_MATCHER_RTC_TYPE_MATCH );
818772destroy_end_ft :
819773 hws_matcher_destroy_end_ft (matcher );
820774unbind_at :
@@ -828,7 +782,7 @@ static void hws_matcher_destroy_and_disconnect(struct mlx5hws_matcher *matcher)
828782{
829783 hws_matcher_resize_uninit (matcher );
830784 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 );
832786 hws_matcher_destroy_end_ft (matcher );
833787 hws_matcher_unbind_at (matcher );
834788 hws_matcher_unbind_mt (matcher );
@@ -962,10 +916,9 @@ int mlx5hws_matcher_attach_at(struct mlx5hws_matcher *matcher,
962916 return ret ;
963917
964918 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 ) {
966920 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 );
969922 return - ENOMEM ;
970923 }
971924
@@ -1149,8 +1102,7 @@ static int hws_matcher_resize_precheck(struct mlx5hws_matcher *src_matcher,
11491102 return - EINVAL ;
11501103 }
11511104
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 ) {
11541106 mlx5hws_err (ctx , "Src/dst matcher max STEs mismatch\n" );
11551107 return - EINVAL ;
11561108 }
0 commit comments