@@ -62,6 +62,7 @@ static int mlx5_fs_init_hws_actions_pool(struct mlx5_core_dev *dev,
6262 xa_init (& hws_pool -> el2tol3tnl_pools );
6363 xa_init (& hws_pool -> el2tol2tnl_pools );
6464 xa_init (& hws_pool -> mh_pools );
65+ xa_init (& hws_pool -> table_dests );
6566 return 0 ;
6667
6768cleanup_insert_hdr :
@@ -87,6 +88,7 @@ static void mlx5_fs_cleanup_hws_actions_pool(struct mlx5_fs_hws_context *fs_ctx)
8788 struct mlx5_fs_pool * pool ;
8889 unsigned long i ;
8990
91+ xa_destroy (& hws_pool -> table_dests );
9092 xa_for_each (& hws_pool -> mh_pools , i , pool )
9193 mlx5_fs_destroy_mh_pool (pool , & hws_pool -> mh_pools , i );
9294 xa_destroy (& hws_pool -> mh_pools );
@@ -173,6 +175,50 @@ static int mlx5_fs_set_ft_default_miss(struct mlx5_flow_root_namespace *ns,
173175 return 0 ;
174176}
175177
178+ static int mlx5_fs_add_flow_table_dest_action (struct mlx5_flow_root_namespace * ns ,
179+ struct mlx5_flow_table * ft )
180+ {
181+ u32 flags = MLX5HWS_ACTION_FLAG_HWS_FDB | MLX5HWS_ACTION_FLAG_SHARED ;
182+ struct mlx5_fs_hws_context * fs_ctx = & ns -> fs_hws_context ;
183+ struct mlx5hws_action * dest_ft_action ;
184+ struct xarray * dests_xa ;
185+ int err ;
186+
187+ dest_ft_action = mlx5hws_action_create_dest_table_num (fs_ctx -> hws_ctx ,
188+ ft -> id , flags );
189+ if (!dest_ft_action ) {
190+ mlx5_core_err (ns -> dev , "Failed creating dest table action\n" );
191+ return - ENOMEM ;
192+ }
193+
194+ dests_xa = & fs_ctx -> hws_pool .table_dests ;
195+ err = xa_insert (dests_xa , ft -> id , dest_ft_action , GFP_KERNEL );
196+ if (err )
197+ mlx5hws_action_destroy (dest_ft_action );
198+ return err ;
199+ }
200+
201+ static int mlx5_fs_del_flow_table_dest_action (struct mlx5_flow_root_namespace * ns ,
202+ struct mlx5_flow_table * ft )
203+ {
204+ struct mlx5_fs_hws_context * fs_ctx = & ns -> fs_hws_context ;
205+ struct mlx5hws_action * dest_ft_action ;
206+ struct xarray * dests_xa ;
207+ int err ;
208+
209+ dests_xa = & fs_ctx -> hws_pool .table_dests ;
210+ dest_ft_action = xa_erase (dests_xa , ft -> id );
211+ if (!dest_ft_action ) {
212+ mlx5_core_err (ns -> dev , "Failed to erase dest ft action\n" );
213+ return - ENOENT ;
214+ }
215+
216+ err = mlx5hws_action_destroy (dest_ft_action );
217+ if (err )
218+ mlx5_core_err (ns -> dev , "Failed to destroy dest ft action\n" );
219+ return err ;
220+ }
221+
176222static int mlx5_cmd_hws_create_flow_table (struct mlx5_flow_root_namespace * ns ,
177223 struct mlx5_flow_table * ft ,
178224 struct mlx5_flow_table_attr * ft_attr ,
@@ -183,9 +229,16 @@ static int mlx5_cmd_hws_create_flow_table(struct mlx5_flow_root_namespace *ns,
183229 struct mlx5hws_table * tbl ;
184230 int err ;
185231
186- if (mlx5_fs_cmd_is_fw_term_table (ft ))
187- return mlx5_fs_cmd_get_fw_cmds ()-> create_flow_table (ns , ft , ft_attr ,
188- next_ft );
232+ if (mlx5_fs_cmd_is_fw_term_table (ft )) {
233+ err = mlx5_fs_cmd_get_fw_cmds ()-> create_flow_table (ns , ft , ft_attr ,
234+ next_ft );
235+ if (err )
236+ return err ;
237+ err = mlx5_fs_add_flow_table_dest_action (ns , ft );
238+ if (err )
239+ mlx5_fs_cmd_get_fw_cmds ()-> destroy_flow_table (ns , ft );
240+ return err ;
241+ }
189242
190243 if (ns -> table_type != FS_FT_FDB ) {
191244 mlx5_core_err (ns -> dev , "Table type %d not supported for HWS\n" ,
@@ -212,8 +265,13 @@ static int mlx5_cmd_hws_create_flow_table(struct mlx5_flow_root_namespace *ns,
212265
213266 ft -> max_fte = INT_MAX ;
214267
268+ err = mlx5_fs_add_flow_table_dest_action (ns , ft );
269+ if (err )
270+ goto clear_ft_miss ;
215271 return 0 ;
216272
273+ clear_ft_miss :
274+ mlx5_fs_set_ft_default_miss (ns , ft , NULL );
217275destroy_table :
218276 mlx5hws_table_destroy (tbl );
219277 ft -> fs_hws_table .hws_table = NULL ;
@@ -225,6 +283,10 @@ static int mlx5_cmd_hws_destroy_flow_table(struct mlx5_flow_root_namespace *ns,
225283{
226284 int err ;
227285
286+ err = mlx5_fs_del_flow_table_dest_action (ns , ft );
287+ if (err )
288+ mlx5_core_err (ns -> dev , "Failed to remove dest action (%d)\n" , err );
289+
228290 if (mlx5_fs_cmd_is_fw_term_table (ft ))
229291 return mlx5_fs_cmd_get_fw_cmds ()-> destroy_flow_table (ns , ft );
230292
0 commit comments