@@ -249,13 +249,19 @@ static int ipsec_miss_create(struct mlx5_core_dev *mdev,
249
249
return err ;
250
250
}
251
251
252
+ static void ipsec_rx_ft_disconnect (struct mlx5e_ipsec * ipsec , u32 family )
253
+ {
254
+ struct mlx5_ttc_table * ttc = mlx5e_fs_get_ttc (ipsec -> fs , false);
255
+
256
+ mlx5_ttc_fwd_default_dest (ttc , family2tt (family ));
257
+ }
258
+
252
259
static void rx_destroy (struct mlx5_core_dev * mdev , struct mlx5e_ipsec * ipsec ,
253
260
struct mlx5e_ipsec_rx * rx , u32 family )
254
261
{
255
- struct mlx5_ttc_table * ttc = mlx5e_fs_get_ttc (ipsec -> fs , false);
256
262
257
263
/* disconnect */
258
- mlx5_ttc_fwd_default_dest ( ttc , family2tt ( family ) );
264
+ ipsec_rx_ft_disconnect ( ipsec , family );
259
265
260
266
if (rx -> chains ) {
261
267
ipsec_chains_destroy (rx -> chains );
@@ -277,41 +283,78 @@ static void rx_destroy(struct mlx5_core_dev *mdev, struct mlx5e_ipsec *ipsec,
277
283
mlx5_ipsec_fs_roce_rx_destroy (ipsec -> roce , family );
278
284
}
279
285
286
+ static void ipsec_rx_create_attr_set (struct mlx5e_ipsec * ipsec ,
287
+ struct mlx5e_ipsec_rx * rx ,
288
+ u32 family ,
289
+ struct mlx5e_ipsec_rx_create_attr * attr )
290
+ {
291
+ attr -> ns = mlx5e_fs_get_ns (ipsec -> fs , false);
292
+ attr -> ttc = mlx5e_fs_get_ttc (ipsec -> fs , false);
293
+ attr -> family = family ;
294
+ attr -> prio = MLX5E_NIC_PRIO ;
295
+ attr -> pol_level = MLX5E_ACCEL_FS_POL_FT_LEVEL ;
296
+ attr -> sa_level = MLX5E_ACCEL_FS_ESP_FT_LEVEL ;
297
+ attr -> status_level = MLX5E_ACCEL_FS_ESP_FT_ERR_LEVEL ;
298
+ attr -> chains_ns = MLX5_FLOW_NAMESPACE_KERNEL ;
299
+ }
300
+
301
+ static int ipsec_rx_status_pass_dest_get (struct mlx5e_ipsec * ipsec ,
302
+ struct mlx5e_ipsec_rx * rx ,
303
+ struct mlx5e_ipsec_rx_create_attr * attr ,
304
+ struct mlx5_flow_destination * dest )
305
+ {
306
+ struct mlx5_flow_table * ft ;
307
+ int err ;
308
+
309
+ * dest = mlx5_ttc_get_default_dest (attr -> ttc , family2tt (attr -> family ));
310
+ err = mlx5_ipsec_fs_roce_rx_create (ipsec -> mdev , ipsec -> roce , attr -> ns , dest ,
311
+ attr -> family , MLX5E_ACCEL_FS_ESP_FT_ROCE_LEVEL ,
312
+ attr -> prio );
313
+ if (err )
314
+ return err ;
315
+
316
+ ft = mlx5_ipsec_fs_roce_ft_get (ipsec -> roce , attr -> family );
317
+ if (ft ) {
318
+ dest -> type = MLX5_FLOW_DESTINATION_TYPE_FLOW_TABLE ;
319
+ dest -> ft = ft ;
320
+ }
321
+
322
+ return 0 ;
323
+ }
324
+
325
+ static void ipsec_rx_ft_connect (struct mlx5e_ipsec * ipsec ,
326
+ struct mlx5e_ipsec_rx * rx ,
327
+ struct mlx5e_ipsec_rx_create_attr * attr )
328
+ {
329
+ struct mlx5_flow_destination dest = {};
330
+
331
+ dest .type = MLX5_FLOW_DESTINATION_TYPE_FLOW_TABLE ;
332
+ dest .ft = rx -> ft .pol ;
333
+ mlx5_ttc_fwd_dest (attr -> ttc , family2tt (attr -> family ), & dest );
334
+ }
335
+
280
336
static int rx_create (struct mlx5_core_dev * mdev , struct mlx5e_ipsec * ipsec ,
281
337
struct mlx5e_ipsec_rx * rx , u32 family )
282
338
{
283
- struct mlx5_flow_namespace * ns = mlx5e_fs_get_ns (ipsec -> fs , false);
284
- struct mlx5_ttc_table * ttc = mlx5e_fs_get_ttc (ipsec -> fs , false);
285
- struct mlx5_flow_destination default_dest ;
339
+ struct mlx5e_ipsec_rx_create_attr attr ;
286
340
struct mlx5_flow_destination dest [2 ];
287
341
struct mlx5_flow_table * ft ;
288
342
u32 flags = 0 ;
289
343
int err ;
290
344
291
- default_dest = mlx5_ttc_get_default_dest (ttc , family2tt (family ));
292
- err = mlx5_ipsec_fs_roce_rx_create (mdev , ipsec -> roce , ns , & default_dest ,
293
- family , MLX5E_ACCEL_FS_ESP_FT_ROCE_LEVEL ,
294
- MLX5E_NIC_PRIO );
345
+ ipsec_rx_create_attr_set (ipsec , rx , family , & attr );
346
+
347
+ err = ipsec_rx_status_pass_dest_get (ipsec , rx , & attr , & dest [0 ]);
295
348
if (err )
296
349
return err ;
297
350
298
- ft = ipsec_ft_create (ns , MLX5E_ACCEL_FS_ESP_FT_ERR_LEVEL ,
299
- MLX5E_NIC_PRIO , 1 , 0 );
351
+ ft = ipsec_ft_create (attr .ns , attr .status_level , attr .prio , 1 , 0 );
300
352
if (IS_ERR (ft )) {
301
353
err = PTR_ERR (ft );
302
354
goto err_fs_ft_status ;
303
355
}
304
-
305
356
rx -> ft .status = ft ;
306
357
307
- ft = mlx5_ipsec_fs_roce_ft_get (ipsec -> roce , family );
308
- if (ft ) {
309
- dest [0 ].type = MLX5_FLOW_DESTINATION_TYPE_FLOW_TABLE ;
310
- dest [0 ].ft = ft ;
311
- } else {
312
- dest [0 ] = default_dest ;
313
- }
314
-
315
358
dest [1 ].type = MLX5_FLOW_DESTINATION_TYPE_COUNTER ;
316
359
dest [1 ].counter_id = mlx5_fc_id (rx -> fc -> cnt );
317
360
err = ipsec_status_rule (mdev , rx , dest );
@@ -323,8 +366,7 @@ static int rx_create(struct mlx5_core_dev *mdev, struct mlx5e_ipsec *ipsec,
323
366
rx -> allow_tunnel_mode = mlx5_eswitch_block_encap (mdev );
324
367
if (rx -> allow_tunnel_mode )
325
368
flags = MLX5_FLOW_TABLE_TUNNEL_EN_REFORMAT ;
326
- ft = ipsec_ft_create (ns , MLX5E_ACCEL_FS_ESP_FT_LEVEL , MLX5E_NIC_PRIO , 2 ,
327
- flags );
369
+ ft = ipsec_ft_create (attr .ns , attr .sa_level , attr .prio , 2 , flags );
328
370
if (IS_ERR (ft )) {
329
371
err = PTR_ERR (ft );
330
372
goto err_fs_ft ;
@@ -337,9 +379,9 @@ static int rx_create(struct mlx5_core_dev *mdev, struct mlx5e_ipsec *ipsec,
337
379
338
380
if (mlx5_ipsec_device_caps (mdev ) & MLX5_IPSEC_CAP_PRIO ) {
339
381
rx -> chains = ipsec_chains_create (mdev , rx -> ft .sa ,
340
- MLX5_FLOW_NAMESPACE_KERNEL ,
341
- MLX5E_NIC_PRIO ,
342
- MLX5E_ACCEL_FS_POL_FT_LEVEL ,
382
+ attr . chains_ns ,
383
+ attr . prio ,
384
+ attr . pol_level ,
343
385
& rx -> ft .pol );
344
386
if (IS_ERR (rx -> chains )) {
345
387
err = PTR_ERR (rx -> chains );
@@ -349,8 +391,7 @@ static int rx_create(struct mlx5_core_dev *mdev, struct mlx5e_ipsec *ipsec,
349
391
goto connect ;
350
392
}
351
393
352
- ft = ipsec_ft_create (ns , MLX5E_ACCEL_FS_POL_FT_LEVEL , MLX5E_NIC_PRIO ,
353
- 2 , 0 );
394
+ ft = ipsec_ft_create (attr .ns , attr .pol_level , attr .prio , 2 , 0 );
354
395
if (IS_ERR (ft )) {
355
396
err = PTR_ERR (ft );
356
397
goto err_pol_ft ;
@@ -365,10 +406,7 @@ static int rx_create(struct mlx5_core_dev *mdev, struct mlx5e_ipsec *ipsec,
365
406
366
407
connect :
367
408
/* connect */
368
- memset (dest , 0x00 , sizeof (* dest ));
369
- dest [0 ].type = MLX5_FLOW_DESTINATION_TYPE_FLOW_TABLE ;
370
- dest [0 ].ft = rx -> ft .pol ;
371
- mlx5_ttc_fwd_dest (ttc , family2tt (family ), & dest [0 ]);
409
+ ipsec_rx_ft_connect (ipsec , rx , & attr );
372
410
return 0 ;
373
411
374
412
err_pol_miss :
0 commit comments