Skip to content

Commit e4d38c4

Browse files
rleonSaeed Mahameed
authored andcommitted
net/mlx5e: Protect global IPsec ASO
ASO operations are global to whole IPsec as they share one DMA address for all operations. As such all WQE operations need to be protected with lock. In this case, it must be spinlock to allow mlx5e_ipsec_aso_query() operate in atomic context. Fixes: 1ed78fc ("net/mlx5e: Update IPsec soft and hard limits") Reviewed-by: Jianbo Liu <[email protected]> Signed-off-by: Leon Romanovsky <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]>
1 parent 16bccba commit e4d38c4

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@ struct mlx5e_ipsec_aso {
122122
u8 ctx[MLX5_ST_SZ_BYTES(ipsec_aso)];
123123
dma_addr_t dma_addr;
124124
struct mlx5_aso *aso;
125+
/* Protect ASO WQ access, as it is global to whole IPsec */
126+
spinlock_t lock;
125127
};
126128

127129
struct mlx5e_ipsec {

drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_offload.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,7 @@ int mlx5e_ipsec_aso_init(struct mlx5e_ipsec *ipsec)
396396
goto err_aso_create;
397397
}
398398

399+
spin_lock_init(&aso->lock);
399400
ipsec->nb.notifier_call = mlx5e_ipsec_event;
400401
mlx5_notifier_register(mdev, &ipsec->nb);
401402

@@ -454,10 +455,12 @@ int mlx5e_ipsec_aso_query(struct mlx5e_ipsec_sa_entry *sa_entry,
454455
struct mlx5e_hw_objs *res;
455456
struct mlx5_aso_wqe *wqe;
456457
u8 ds_cnt;
458+
int ret;
457459

458460
lockdep_assert_held(&sa_entry->x->lock);
459461
res = &mdev->mlx5e_res.hw_objs;
460462

463+
spin_lock_bh(&aso->lock);
461464
memset(aso->ctx, 0, sizeof(aso->ctx));
462465
wqe = mlx5_aso_get_wqe(aso->aso);
463466
ds_cnt = DIV_ROUND_UP(sizeof(*wqe), MLX5_SEND_WQE_DS);
@@ -472,7 +475,9 @@ int mlx5e_ipsec_aso_query(struct mlx5e_ipsec_sa_entry *sa_entry,
472475
mlx5e_ipsec_aso_copy(ctrl, data);
473476

474477
mlx5_aso_post_wqe(aso->aso, false, &wqe->ctrl);
475-
return mlx5_aso_poll_cq(aso->aso, false);
478+
ret = mlx5_aso_poll_cq(aso->aso, false);
479+
spin_unlock_bh(&aso->lock);
480+
return ret;
476481
}
477482

478483
void mlx5e_ipsec_aso_update_curlft(struct mlx5e_ipsec_sa_entry *sa_entry,

0 commit comments

Comments
 (0)