9
9
#include "fs_core.h"
10
10
#include "lib/ipsec_fs_roce.h"
11
11
#include "lib/fs_chains.h"
12
+ #include "esw/ipsec_fs.h"
12
13
13
14
#define NUM_IPSEC_FTE BIT(15)
14
15
#define MLX5_REFORMAT_TYPE_ADD_ESP_TRANSPORT_SIZE 16
@@ -19,29 +20,6 @@ struct mlx5e_ipsec_fc {
19
20
struct mlx5_fc * drop ;
20
21
};
21
22
22
- struct mlx5e_ipsec_ft {
23
- struct mutex mutex ; /* Protect changes to this struct */
24
- struct mlx5_flow_table * pol ;
25
- struct mlx5_flow_table * sa ;
26
- struct mlx5_flow_table * status ;
27
- u32 refcnt ;
28
- };
29
-
30
- struct mlx5e_ipsec_miss {
31
- struct mlx5_flow_group * group ;
32
- struct mlx5_flow_handle * rule ;
33
- };
34
-
35
- struct mlx5e_ipsec_rx {
36
- struct mlx5e_ipsec_ft ft ;
37
- struct mlx5e_ipsec_miss pol ;
38
- struct mlx5e_ipsec_miss sa ;
39
- struct mlx5e_ipsec_rule status ;
40
- struct mlx5e_ipsec_fc * fc ;
41
- struct mlx5_fs_chains * chains ;
42
- u8 allow_tunnel_mode : 1 ;
43
- };
44
-
45
23
struct mlx5e_ipsec_tx {
46
24
struct mlx5e_ipsec_ft ft ;
47
25
struct mlx5e_ipsec_miss pol ;
@@ -259,9 +237,9 @@ static void ipsec_rx_ft_disconnect(struct mlx5e_ipsec *ipsec, u32 family)
259
237
static void rx_destroy (struct mlx5_core_dev * mdev , struct mlx5e_ipsec * ipsec ,
260
238
struct mlx5e_ipsec_rx * rx , u32 family )
261
239
{
262
-
263
240
/* disconnect */
264
- ipsec_rx_ft_disconnect (ipsec , family );
241
+ if (rx != ipsec -> rx_esw )
242
+ ipsec_rx_ft_disconnect (ipsec , family );
265
243
266
244
if (rx -> chains ) {
267
245
ipsec_chains_destroy (rx -> chains );
@@ -276,8 +254,12 @@ static void rx_destroy(struct mlx5_core_dev *mdev, struct mlx5e_ipsec *ipsec,
276
254
mlx5_destroy_flow_table (rx -> ft .sa );
277
255
if (rx -> allow_tunnel_mode )
278
256
mlx5_eswitch_unblock_encap (mdev );
279
- mlx5_del_flow_rules (rx -> status .rule );
280
- mlx5_modify_header_dealloc (mdev , rx -> status .modify_hdr );
257
+ if (rx == ipsec -> rx_esw ) {
258
+ mlx5_esw_ipsec_rx_status_destroy (ipsec , rx );
259
+ } else {
260
+ mlx5_del_flow_rules (rx -> status .rule );
261
+ mlx5_modify_header_dealloc (mdev , rx -> status .modify_hdr );
262
+ }
281
263
mlx5_destroy_flow_table (rx -> ft .status );
282
264
283
265
mlx5_ipsec_fs_roce_rx_destroy (ipsec -> roce , family );
@@ -288,6 +270,13 @@ static void ipsec_rx_create_attr_set(struct mlx5e_ipsec *ipsec,
288
270
u32 family ,
289
271
struct mlx5e_ipsec_rx_create_attr * attr )
290
272
{
273
+ if (rx == ipsec -> rx_esw ) {
274
+ /* For packet offload in switchdev mode, RX & TX use FDB namespace */
275
+ attr -> ns = ipsec -> tx_esw -> ns ;
276
+ mlx5_esw_ipsec_rx_create_attr_set (ipsec , attr );
277
+ return ;
278
+ }
279
+
291
280
attr -> ns = mlx5e_fs_get_ns (ipsec -> fs , false);
292
281
attr -> ttc = mlx5e_fs_get_ttc (ipsec -> fs , false);
293
282
attr -> family = family ;
@@ -306,6 +295,9 @@ static int ipsec_rx_status_pass_dest_get(struct mlx5e_ipsec *ipsec,
306
295
struct mlx5_flow_table * ft ;
307
296
int err ;
308
297
298
+ if (rx == ipsec -> rx_esw )
299
+ return mlx5_esw_ipsec_rx_status_pass_dest_get (ipsec , dest );
300
+
309
301
* dest = mlx5_ttc_get_default_dest (attr -> ttc , family2tt (attr -> family ));
310
302
err = mlx5_ipsec_fs_roce_rx_create (ipsec -> mdev , ipsec -> roce , attr -> ns , dest ,
311
303
attr -> family , MLX5E_ACCEL_FS_ESP_FT_ROCE_LEVEL ,
@@ -357,7 +349,10 @@ static int rx_create(struct mlx5_core_dev *mdev, struct mlx5e_ipsec *ipsec,
357
349
358
350
dest [1 ].type = MLX5_FLOW_DESTINATION_TYPE_COUNTER ;
359
351
dest [1 ].counter_id = mlx5_fc_id (rx -> fc -> cnt );
360
- err = ipsec_status_rule (mdev , rx , dest );
352
+ if (rx == ipsec -> rx_esw )
353
+ err = mlx5_esw_ipsec_rx_status_create (ipsec , rx , dest );
354
+ else
355
+ err = ipsec_status_rule (mdev , rx , dest );
361
356
if (err )
362
357
goto err_add ;
363
358
@@ -406,7 +401,8 @@ static int rx_create(struct mlx5_core_dev *mdev, struct mlx5e_ipsec *ipsec,
406
401
407
402
connect :
408
403
/* connect */
409
- ipsec_rx_ft_connect (ipsec , rx , & attr );
404
+ if (rx != ipsec -> rx_esw )
405
+ ipsec_rx_ft_connect (ipsec , rx , & attr );
410
406
return 0 ;
411
407
412
408
err_pol_miss :
@@ -864,18 +860,22 @@ static void setup_fte_upper_proto_match(struct mlx5_flow_spec *spec, struct upsp
864
860
}
865
861
}
866
862
867
- static enum mlx5_flow_namespace_type ipsec_fs_get_ns (struct mlx5e_ipsec * ipsec , u8 dir )
863
+ static enum mlx5_flow_namespace_type ipsec_fs_get_ns (struct mlx5e_ipsec * ipsec ,
864
+ int type , u8 dir )
868
865
{
866
+ if (ipsec -> is_uplink_rep && type == XFRM_DEV_OFFLOAD_PACKET )
867
+ return MLX5_FLOW_NAMESPACE_FDB ;
868
+
869
869
if (dir == XFRM_DEV_OFFLOAD_IN )
870
870
return MLX5_FLOW_NAMESPACE_KERNEL ;
871
871
872
872
return MLX5_FLOW_NAMESPACE_EGRESS ;
873
873
}
874
874
875
- static int setup_modify_header (struct mlx5e_ipsec * ipsec , u32 val , u8 dir ,
875
+ static int setup_modify_header (struct mlx5e_ipsec * ipsec , int type , u32 val , u8 dir ,
876
876
struct mlx5_flow_act * flow_act )
877
877
{
878
- enum mlx5_flow_namespace_type ns_type = ipsec_fs_get_ns (ipsec , dir );
878
+ enum mlx5_flow_namespace_type ns_type = ipsec_fs_get_ns (ipsec , type , dir );
879
879
u8 action [MLX5_UN_SZ_BYTES (set_add_copy_action_in_auto )] = {};
880
880
struct mlx5_core_dev * mdev = ipsec -> mdev ;
881
881
struct mlx5_modify_hdr * modify_hdr ;
@@ -1085,7 +1085,8 @@ static int setup_pkt_reformat(struct mlx5e_ipsec *ipsec,
1085
1085
struct mlx5_accel_esp_xfrm_attrs * attrs ,
1086
1086
struct mlx5_flow_act * flow_act )
1087
1087
{
1088
- enum mlx5_flow_namespace_type ns_type = ipsec_fs_get_ns (ipsec , attrs -> dir );
1088
+ enum mlx5_flow_namespace_type ns_type = ipsec_fs_get_ns (ipsec , attrs -> type ,
1089
+ attrs -> dir );
1089
1090
struct mlx5_pkt_reformat_params reformat_params = {};
1090
1091
struct mlx5_core_dev * mdev = ipsec -> mdev ;
1091
1092
struct mlx5_pkt_reformat * pkt_reformat ;
@@ -1127,7 +1128,7 @@ static int rx_add_rule(struct mlx5e_ipsec_sa_entry *sa_entry)
1127
1128
struct mlx5_flow_spec * spec ;
1128
1129
struct mlx5e_ipsec_rx * rx ;
1129
1130
struct mlx5_fc * counter ;
1130
- int err ;
1131
+ int err = 0 ;
1131
1132
1132
1133
rx = rx_ft_get (mdev , ipsec , attrs -> family , attrs -> type );
1133
1134
if (IS_ERR (rx ))
@@ -1148,8 +1149,10 @@ static int rx_add_rule(struct mlx5e_ipsec_sa_entry *sa_entry)
1148
1149
setup_fte_esp (spec );
1149
1150
setup_fte_no_frags (spec );
1150
1151
1151
- err = setup_modify_header (ipsec , sa_entry -> ipsec_obj_id | BIT (31 ),
1152
- XFRM_DEV_OFFLOAD_IN , & flow_act );
1152
+ if (rx != ipsec -> rx_esw )
1153
+ err = setup_modify_header (ipsec , attrs -> type ,
1154
+ sa_entry -> ipsec_obj_id | BIT (31 ),
1155
+ XFRM_DEV_OFFLOAD_IN , & flow_act );
1153
1156
if (err )
1154
1157
goto err_mod_header ;
1155
1158
@@ -1340,7 +1343,7 @@ static int tx_add_policy(struct mlx5e_ipsec_pol_entry *pol_entry)
1340
1343
if (!attrs -> reqid )
1341
1344
break ;
1342
1345
1343
- err = setup_modify_header (ipsec , attrs -> reqid ,
1346
+ err = setup_modify_header (ipsec , attrs -> type , attrs -> reqid ,
1344
1347
XFRM_DEV_OFFLOAD_OUT , & flow_act );
1345
1348
if (err )
1346
1349
goto err_mod_header ;
@@ -1388,6 +1391,7 @@ static int rx_add_policy(struct mlx5e_ipsec_pol_entry *pol_entry)
1388
1391
{
1389
1392
struct mlx5_accel_pol_xfrm_attrs * attrs = & pol_entry -> attrs ;
1390
1393
struct mlx5_core_dev * mdev = mlx5e_ipsec_pol2dev (pol_entry );
1394
+ struct mlx5e_ipsec * ipsec = pol_entry -> ipsec ;
1391
1395
struct mlx5_flow_destination dest [2 ];
1392
1396
struct mlx5_flow_act flow_act = {};
1393
1397
struct mlx5_flow_handle * rule ;
@@ -1433,6 +1437,8 @@ static int rx_add_policy(struct mlx5e_ipsec_pol_entry *pol_entry)
1433
1437
}
1434
1438
1435
1439
flow_act .flags |= FLOW_ACT_NO_APPEND ;
1440
+ if (rx == ipsec -> rx_esw && rx -> chains )
1441
+ flow_act .flags |= FLOW_ACT_IGNORE_FLOW_LEVEL ;
1436
1442
dest [dstn ].type = MLX5_FLOW_DESTINATION_TYPE_FLOW_TABLE ;
1437
1443
dest [dstn ].ft = rx -> ft .sa ;
1438
1444
dstn ++ ;
0 commit comments