@@ -62,6 +62,7 @@ static int mlx5_fs_init_hws_actions_pool(struct mlx5_core_dev *dev,
62
62
xa_init (& hws_pool -> el2tol3tnl_pools );
63
63
xa_init (& hws_pool -> el2tol2tnl_pools );
64
64
xa_init (& hws_pool -> mh_pools );
65
+ xa_init (& hws_pool -> table_dests );
65
66
return 0 ;
66
67
67
68
cleanup_insert_hdr :
@@ -87,6 +88,7 @@ static void mlx5_fs_cleanup_hws_actions_pool(struct mlx5_fs_hws_context *fs_ctx)
87
88
struct mlx5_fs_pool * pool ;
88
89
unsigned long i ;
89
90
91
+ xa_destroy (& hws_pool -> table_dests );
90
92
xa_for_each (& hws_pool -> mh_pools , i , pool )
91
93
mlx5_fs_destroy_mh_pool (pool , & hws_pool -> mh_pools , i );
92
94
xa_destroy (& hws_pool -> mh_pools );
@@ -173,6 +175,50 @@ static int mlx5_fs_set_ft_default_miss(struct mlx5_flow_root_namespace *ns,
173
175
return 0 ;
174
176
}
175
177
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
+
176
222
static int mlx5_cmd_hws_create_flow_table (struct mlx5_flow_root_namespace * ns ,
177
223
struct mlx5_flow_table * ft ,
178
224
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,
183
229
struct mlx5hws_table * tbl ;
184
230
int err ;
185
231
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
+ }
189
242
190
243
if (ns -> table_type != FS_FT_FDB ) {
191
244
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,
212
265
213
266
ft -> max_fte = INT_MAX ;
214
267
268
+ err = mlx5_fs_add_flow_table_dest_action (ns , ft );
269
+ if (err )
270
+ goto clear_ft_miss ;
215
271
return 0 ;
216
272
273
+ clear_ft_miss :
274
+ mlx5_fs_set_ft_default_miss (ns , ft , NULL );
217
275
destroy_table :
218
276
mlx5hws_table_destroy (tbl );
219
277
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,
225
283
{
226
284
int err ;
227
285
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
+
228
290
if (mlx5_fs_cmd_is_fw_term_table (ft ))
229
291
return mlx5_fs_cmd_get_fw_cmds ()-> destroy_flow_table (ns , ft );
230
292
0 commit comments