6
6
#include "en/fs.h"
7
7
#include "ipsec.h"
8
8
#include "fs_core.h"
9
+ #include "lib/ipsec_fs_roce.h"
9
10
10
11
#define NUM_IPSEC_FTE BIT(15)
11
12
@@ -166,7 +167,8 @@ static int ipsec_miss_create(struct mlx5_core_dev *mdev,
166
167
return err ;
167
168
}
168
169
169
- static void rx_destroy (struct mlx5_core_dev * mdev , struct mlx5e_ipsec_rx * rx )
170
+ static void rx_destroy (struct mlx5_core_dev * mdev , struct mlx5e_ipsec * ipsec ,
171
+ struct mlx5e_ipsec_rx * rx , u32 family )
170
172
{
171
173
mlx5_del_flow_rules (rx -> pol .rule );
172
174
mlx5_destroy_flow_group (rx -> pol .group );
@@ -179,25 +181,44 @@ static void rx_destroy(struct mlx5_core_dev *mdev, struct mlx5e_ipsec_rx *rx)
179
181
mlx5_del_flow_rules (rx -> status .rule );
180
182
mlx5_modify_header_dealloc (mdev , rx -> status .modify_hdr );
181
183
mlx5_destroy_flow_table (rx -> ft .status );
184
+
185
+ mlx5_ipsec_fs_roce_rx_destroy (ipsec -> roce , family );
182
186
}
183
187
184
188
static int rx_create (struct mlx5_core_dev * mdev , struct mlx5e_ipsec * ipsec ,
185
189
struct mlx5e_ipsec_rx * rx , u32 family )
186
190
{
187
191
struct mlx5_flow_namespace * ns = mlx5e_fs_get_ns (ipsec -> fs , false);
188
192
struct mlx5_ttc_table * ttc = mlx5e_fs_get_ttc (ipsec -> fs , false);
193
+ struct mlx5_flow_destination default_dest ;
189
194
struct mlx5_flow_destination dest [2 ];
190
195
struct mlx5_flow_table * ft ;
191
196
int err ;
192
197
198
+ default_dest = mlx5_ttc_get_default_dest (ttc , family2tt (family ));
199
+ err = mlx5_ipsec_fs_roce_rx_create (mdev , ipsec -> roce , ns , & default_dest ,
200
+ family , MLX5E_ACCEL_FS_ESP_FT_ROCE_LEVEL ,
201
+ MLX5E_NIC_PRIO );
202
+ if (err )
203
+ return err ;
204
+
193
205
ft = ipsec_ft_create (ns , MLX5E_ACCEL_FS_ESP_FT_ERR_LEVEL ,
194
206
MLX5E_NIC_PRIO , 1 );
195
- if (IS_ERR (ft ))
196
- return PTR_ERR (ft );
207
+ if (IS_ERR (ft )) {
208
+ err = PTR_ERR (ft );
209
+ goto err_fs_ft_status ;
210
+ }
197
211
198
212
rx -> ft .status = ft ;
199
213
200
- dest [0 ] = mlx5_ttc_get_default_dest (ttc , family2tt (family ));
214
+ ft = mlx5_ipsec_fs_roce_ft_get (ipsec -> roce , family );
215
+ if (ft ) {
216
+ dest [0 ].type = MLX5_FLOW_DESTINATION_TYPE_FLOW_TABLE ;
217
+ dest [0 ].ft = ft ;
218
+ } else {
219
+ dest [0 ] = default_dest ;
220
+ }
221
+
201
222
dest [1 ].type = MLX5_FLOW_DESTINATION_TYPE_COUNTER ;
202
223
dest [1 ].counter_id = mlx5_fc_id (rx -> fc -> cnt );
203
224
err = ipsec_status_rule (mdev , rx , dest );
@@ -245,6 +266,8 @@ static int rx_create(struct mlx5_core_dev *mdev, struct mlx5e_ipsec *ipsec,
245
266
mlx5_modify_header_dealloc (mdev , rx -> status .modify_hdr );
246
267
err_add :
247
268
mlx5_destroy_flow_table (rx -> ft .status );
269
+ err_fs_ft_status :
270
+ mlx5_ipsec_fs_roce_rx_destroy (ipsec -> roce , family );
248
271
return err ;
249
272
}
250
273
@@ -304,7 +327,7 @@ static void rx_ft_put(struct mlx5_core_dev *mdev, struct mlx5e_ipsec *ipsec,
304
327
mlx5_ttc_fwd_default_dest (ttc , family2tt (family ));
305
328
306
329
/* remove FT */
307
- rx_destroy (mdev , rx );
330
+ rx_destroy (mdev , ipsec , rx , family );
308
331
309
332
out :
310
333
mutex_unlock (& rx -> ft .mutex );
@@ -1008,6 +1031,9 @@ void mlx5e_accel_ipsec_fs_cleanup(struct mlx5e_ipsec *ipsec)
1008
1031
if (!ipsec -> tx )
1009
1032
return ;
1010
1033
1034
+ if (mlx5_ipsec_device_caps (ipsec -> mdev ) & MLX5_IPSEC_CAP_ROCE )
1035
+ mlx5_ipsec_fs_roce_cleanup (ipsec -> roce );
1036
+
1011
1037
ipsec_fs_destroy_counters (ipsec );
1012
1038
mutex_destroy (& ipsec -> tx -> ft .mutex );
1013
1039
WARN_ON (ipsec -> tx -> ft .refcnt );
@@ -1024,6 +1050,7 @@ void mlx5e_accel_ipsec_fs_cleanup(struct mlx5e_ipsec *ipsec)
1024
1050
1025
1051
int mlx5e_accel_ipsec_fs_init (struct mlx5e_ipsec * ipsec )
1026
1052
{
1053
+ struct mlx5_core_dev * mdev = ipsec -> mdev ;
1027
1054
struct mlx5_flow_namespace * ns ;
1028
1055
int err = - ENOMEM ;
1029
1056
@@ -1053,6 +1080,9 @@ int mlx5e_accel_ipsec_fs_init(struct mlx5e_ipsec *ipsec)
1053
1080
mutex_init (& ipsec -> rx_ipv6 -> ft .mutex );
1054
1081
ipsec -> tx -> ns = ns ;
1055
1082
1083
+ if (mlx5_ipsec_device_caps (mdev ) & MLX5_IPSEC_CAP_ROCE )
1084
+ ipsec -> roce = mlx5_ipsec_fs_roce_init (mdev );
1085
+
1056
1086
return 0 ;
1057
1087
1058
1088
err_counters :
0 commit comments