Skip to content

Commit cee137a

Browse files
rleonklassert
authored andcommitted
net/mlx5e: Handle ESN update events
Extend event logic to update ESN state (esn_msb, esn_overlap) for an IPsec Offload context. Reviewed-by: Saeed Mahameed <[email protected]> Signed-off-by: Leon Romanovsky <[email protected]> Signed-off-by: Steffen Klassert <[email protected]>
1 parent 8c582dd commit cee137a

File tree

3 files changed

+48
-3
lines changed

3 files changed

+48
-3
lines changed

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,8 @@ static void mlx5e_ipsec_init_limits(struct mlx5e_ipsec_sa_entry *sa_entry,
108108
x->lft.hard_packet_limit - x->lft.soft_packet_limit;
109109
}
110110

111-
static void
112-
mlx5e_ipsec_build_accel_xfrm_attrs(struct mlx5e_ipsec_sa_entry *sa_entry,
113-
struct mlx5_accel_esp_xfrm_attrs *attrs)
111+
void mlx5e_ipsec_build_accel_xfrm_attrs(struct mlx5e_ipsec_sa_entry *sa_entry,
112+
struct mlx5_accel_esp_xfrm_attrs *attrs)
114113
{
115114
struct xfrm_state *x = sa_entry->x;
116115
struct aes_gcm_keymat *aes_gcm = &attrs->aes_gcm;

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,8 @@ void mlx5e_ipsec_aso_update_curlft(struct mlx5e_ipsec_sa_entry *sa_entry,
230230
void mlx5e_accel_ipsec_fs_read_stats(struct mlx5e_priv *priv,
231231
void *ipsec_stats);
232232

233+
void mlx5e_ipsec_build_accel_xfrm_attrs(struct mlx5e_ipsec_sa_entry *sa_entry,
234+
struct mlx5_accel_esp_xfrm_attrs *attrs);
233235
static inline struct mlx5_core_dev *
234236
mlx5e_ipsec_sa2dev(struct mlx5e_ipsec_sa_entry *sa_entry)
235237
{

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

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
#include "ipsec.h"
77
#include "lib/mlx5.h"
88

9+
enum {
10+
MLX5_IPSEC_ASO_REMOVE_FLOW_PKT_CNT_OFFSET,
11+
};
12+
913
u32 mlx5_ipsec_device_caps(struct mlx5_core_dev *mdev)
1014
{
1115
u32 caps = 0;
@@ -260,6 +264,39 @@ void mlx5_accel_esp_modify_xfrm(struct mlx5e_ipsec_sa_entry *sa_entry,
260264
memcpy(&sa_entry->attrs, attrs, sizeof(sa_entry->attrs));
261265
}
262266

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+
263300
static void mlx5e_ipsec_handle_event(struct work_struct *_work)
264301
{
265302
struct mlx5e_ipsec_work *work =
@@ -284,6 +321,13 @@ static void mlx5e_ipsec_handle_event(struct work_struct *_work)
284321
goto unlock;
285322

286323
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+
287331
if (attrs->soft_packet_limit != XFRM_INF)
288332
if (!MLX5_GET(ipsec_aso, aso->ctx, soft_lft_arm) ||
289333
!MLX5_GET(ipsec_aso, aso->ctx, hard_lft_arm) ||

0 commit comments

Comments
 (0)