@@ -310,10 +310,11 @@ static void mlx5e_ipsec_aso_update(struct mlx5e_ipsec_sa_entry *sa_entry,
310310 mlx5e_ipsec_aso_query (sa_entry , data );
311311}
312312
313- static void mlx5e_ipsec_update_esn_state (struct mlx5e_ipsec_sa_entry * sa_entry ,
314- u32 mode_param )
313+ static void
314+ mlx5e_ipsec_update_esn_state (struct mlx5e_ipsec_sa_entry * sa_entry ,
315+ u32 mode_param ,
316+ struct mlx5_accel_esp_xfrm_attrs * attrs )
315317{
316- struct mlx5_accel_esp_xfrm_attrs attrs = {};
317318 struct mlx5_wqe_aso_ctrl_seg data = {};
318319
319320 if (mode_param < MLX5E_IPSEC_ESN_SCOPE_MID ) {
@@ -323,18 +324,7 @@ static void mlx5e_ipsec_update_esn_state(struct mlx5e_ipsec_sa_entry *sa_entry,
323324 sa_entry -> esn_state .overlap = 1 ;
324325 }
325326
326- mlx5e_ipsec_build_accel_xfrm_attrs (sa_entry , & attrs );
327-
328- /* It is safe to execute the modify below unlocked since the only flows
329- * that could affect this HW object, are create, destroy and this work.
330- *
331- * Creation flow can't co-exist with this modify work, the destruction
332- * flow would cancel this work, and this work is a single entity that
333- * can't conflict with it self.
334- */
335- spin_unlock_bh (& sa_entry -> x -> lock );
336- mlx5_accel_esp_modify_xfrm (sa_entry , & attrs );
337- spin_lock_bh (& sa_entry -> x -> lock );
327+ mlx5e_ipsec_build_accel_xfrm_attrs (sa_entry , attrs );
338328
339329 data .data_offset_condition_operand =
340330 MLX5_IPSEC_ASO_REMOVE_FLOW_PKT_CNT_OFFSET ;
@@ -370,20 +360,18 @@ static void mlx5e_ipsec_aso_update_soft(struct mlx5e_ipsec_sa_entry *sa_entry,
370360static void mlx5e_ipsec_handle_limits (struct mlx5e_ipsec_sa_entry * sa_entry )
371361{
372362 struct mlx5_accel_esp_xfrm_attrs * attrs = & sa_entry -> attrs ;
373- struct mlx5e_ipsec * ipsec = sa_entry -> ipsec ;
374- struct mlx5e_ipsec_aso * aso = ipsec -> aso ;
375363 bool soft_arm , hard_arm ;
376364 u64 hard_cnt ;
377365
378366 lockdep_assert_held (& sa_entry -> x -> lock );
379367
380- soft_arm = !MLX5_GET (ipsec_aso , aso -> ctx , soft_lft_arm );
381- hard_arm = !MLX5_GET (ipsec_aso , aso -> ctx , hard_lft_arm );
368+ soft_arm = !MLX5_GET (ipsec_aso , sa_entry -> ctx , soft_lft_arm );
369+ hard_arm = !MLX5_GET (ipsec_aso , sa_entry -> ctx , hard_lft_arm );
382370 if (!soft_arm && !hard_arm )
383371 /* It is not lifetime event */
384372 return ;
385373
386- hard_cnt = MLX5_GET (ipsec_aso , aso -> ctx , remove_flow_pkt_cnt );
374+ hard_cnt = MLX5_GET (ipsec_aso , sa_entry -> ctx , remove_flow_pkt_cnt );
387375 if (!hard_cnt || hard_arm ) {
388376 /* It is possible to see packet counter equal to zero without
389377 * hard limit event armed. Such situation can be if packet
@@ -453,30 +441,34 @@ static void mlx5e_ipsec_handle_event(struct work_struct *_work)
453441 struct mlx5e_ipsec_work * work =
454442 container_of (_work , struct mlx5e_ipsec_work , work );
455443 struct mlx5e_ipsec_sa_entry * sa_entry = work -> data ;
444+ struct mlx5_accel_esp_xfrm_attrs tmp = {};
456445 struct mlx5_accel_esp_xfrm_attrs * attrs ;
457- struct mlx5e_ipsec_aso * aso ;
446+ bool need_modify = false ;
458447 int ret ;
459448
460- aso = sa_entry -> ipsec -> aso ;
461449 attrs = & sa_entry -> attrs ;
462450
463451 spin_lock_bh (& sa_entry -> x -> lock );
464452 ret = mlx5e_ipsec_aso_query (sa_entry , NULL );
465453 if (ret )
466454 goto unlock ;
467455
456+ if (attrs -> lft .soft_packet_limit != XFRM_INF )
457+ mlx5e_ipsec_handle_limits (sa_entry );
458+
468459 if (attrs -> replay_esn .trigger &&
469- !MLX5_GET (ipsec_aso , aso -> ctx , esn_event_arm )) {
470- u32 mode_param = MLX5_GET (ipsec_aso , aso -> ctx , mode_parameter );
460+ !MLX5_GET (ipsec_aso , sa_entry -> ctx , esn_event_arm )) {
461+ u32 mode_param = MLX5_GET (ipsec_aso , sa_entry -> ctx ,
462+ mode_parameter );
471463
472- mlx5e_ipsec_update_esn_state (sa_entry , mode_param );
464+ mlx5e_ipsec_update_esn_state (sa_entry , mode_param , & tmp );
465+ need_modify = true;
473466 }
474467
475- if (attrs -> lft .soft_packet_limit != XFRM_INF )
476- mlx5e_ipsec_handle_limits (sa_entry );
477-
478468unlock :
479469 spin_unlock_bh (& sa_entry -> x -> lock );
470+ if (need_modify )
471+ mlx5_accel_esp_modify_xfrm (sa_entry , & tmp );
480472 kfree (work );
481473}
482474
@@ -629,6 +621,8 @@ int mlx5e_ipsec_aso_query(struct mlx5e_ipsec_sa_entry *sa_entry,
629621 /* We are in atomic context */
630622 udelay (10 );
631623 } while (ret && time_is_after_jiffies (expires ));
624+ if (!ret )
625+ memcpy (sa_entry -> ctx , aso -> ctx , MLX5_ST_SZ_BYTES (ipsec_aso ));
632626 spin_unlock_bh (& aso -> lock );
633627 return ret ;
634628}
0 commit comments