6
6
#include "ipsec.h"
7
7
#include "lib/mlx5.h"
8
8
9
+ enum {
10
+ MLX5_IPSEC_ASO_REMOVE_FLOW_PKT_CNT_OFFSET ,
11
+ };
12
+
9
13
u32 mlx5_ipsec_device_caps (struct mlx5_core_dev * mdev )
10
14
{
11
15
u32 caps = 0 ;
@@ -260,6 +264,39 @@ void mlx5_accel_esp_modify_xfrm(struct mlx5e_ipsec_sa_entry *sa_entry,
260
264
memcpy (& sa_entry -> attrs , attrs , sizeof (sa_entry -> attrs ));
261
265
}
262
266
267
+ static void
268
+ mlx5e_ipsec_aso_update_esn (struct mlx5e_ipsec_sa_entry * sa_entry ,
269
+ const struct mlx5_accel_esp_xfrm_attrs * attrs )
270
+ {
271
+ struct mlx5_wqe_aso_ctrl_seg data = {};
272
+
273
+ data .data_mask_mode = MLX5_ASO_DATA_MASK_MODE_BITWISE_64BIT << 6 ;
274
+ data .condition_1_0_operand = MLX5_ASO_ALWAYS_TRUE | MLX5_ASO_ALWAYS_TRUE
275
+ << 4 ;
276
+ data .data_offset_condition_operand = MLX5_IPSEC_ASO_REMOVE_FLOW_PKT_CNT_OFFSET ;
277
+ data .bitwise_data = cpu_to_be64 (BIT_ULL (54 ));
278
+ data .data_mask = data .bitwise_data ;
279
+
280
+ mlx5e_ipsec_aso_query (sa_entry , & data );
281
+ }
282
+
283
+ static void mlx5e_ipsec_update_esn_state (struct mlx5e_ipsec_sa_entry * sa_entry ,
284
+ u32 mode_param )
285
+ {
286
+ struct mlx5_accel_esp_xfrm_attrs attrs = {};
287
+
288
+ if (mode_param < MLX5E_IPSEC_ESN_SCOPE_MID ) {
289
+ sa_entry -> esn_state .esn ++ ;
290
+ sa_entry -> esn_state .overlap = 0 ;
291
+ } else {
292
+ sa_entry -> esn_state .overlap = 1 ;
293
+ }
294
+
295
+ mlx5e_ipsec_build_accel_xfrm_attrs (sa_entry , & attrs );
296
+ mlx5_accel_esp_modify_xfrm (sa_entry , & attrs );
297
+ mlx5e_ipsec_aso_update_esn (sa_entry , & attrs );
298
+ }
299
+
263
300
static void mlx5e_ipsec_handle_event (struct work_struct * _work )
264
301
{
265
302
struct mlx5e_ipsec_work * work =
@@ -284,6 +321,13 @@ static void mlx5e_ipsec_handle_event(struct work_struct *_work)
284
321
goto unlock ;
285
322
286
323
aso -> use_cache = true;
324
+ if (attrs -> esn_trigger &&
325
+ !MLX5_GET (ipsec_aso , aso -> ctx , esn_event_arm )) {
326
+ u32 mode_param = MLX5_GET (ipsec_aso , aso -> ctx , mode_parameter );
327
+
328
+ mlx5e_ipsec_update_esn_state (sa_entry , mode_param );
329
+ }
330
+
287
331
if (attrs -> soft_packet_limit != XFRM_INF )
288
332
if (!MLX5_GET (ipsec_aso , aso -> ctx , soft_lft_arm ) ||
289
333
!MLX5_GET (ipsec_aso , aso -> ctx , hard_lft_arm ) ||
0 commit comments