Skip to content

Commit 7082a6d

Browse files
Jianbo Liuklassert
Jianbo Liu
authored andcommitted
net/mlx5e: Update TX ESN context for IPSec hardware offload
ESN context must be synced between software and hardware for both RX and TX. As the call to xfrm_dev_state_advance_esn() is added for TX, this patch add the missing logic for TX. So the update is also checked on every packet sent, to see if need to trigger ESN update worker. Signed-off-by: Jianbo Liu <[email protected]> Signed-off-by: Tariq Toukan <[email protected]> Signed-off-by: Leon Romanovsky <[email protected]> Signed-off-by: Steffen Klassert <[email protected]>
1 parent 373b79a commit 7082a6d

File tree

1 file changed

+15
-25
lines changed
  • drivers/net/ethernet/mellanox/mlx5/core/en_accel

1 file changed

+15
-25
lines changed

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

Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -94,25 +94,14 @@ static bool mlx5e_ipsec_update_esn_state(struct mlx5e_ipsec_sa_entry *sa_entry)
9494
u32 esn, esn_msb;
9595
u8 overlap;
9696

97-
switch (x->xso.type) {
98-
case XFRM_DEV_OFFLOAD_PACKET:
99-
switch (x->xso.dir) {
100-
case XFRM_DEV_OFFLOAD_IN:
101-
esn = x->replay_esn->seq;
102-
esn_msb = x->replay_esn->seq_hi;
103-
break;
104-
case XFRM_DEV_OFFLOAD_OUT:
105-
esn = x->replay_esn->oseq;
106-
esn_msb = x->replay_esn->oseq_hi;
107-
break;
108-
default:
109-
WARN_ON(true);
110-
return false;
111-
}
112-
break;
113-
case XFRM_DEV_OFFLOAD_CRYPTO:
114-
/* Already parsed by XFRM core */
97+
switch (x->xso.dir) {
98+
case XFRM_DEV_OFFLOAD_IN:
11599
esn = x->replay_esn->seq;
100+
esn_msb = x->replay_esn->seq_hi;
101+
break;
102+
case XFRM_DEV_OFFLOAD_OUT:
103+
esn = x->replay_esn->oseq;
104+
esn_msb = x->replay_esn->oseq_hi;
116105
break;
117106
default:
118107
WARN_ON(true);
@@ -121,11 +110,15 @@ static bool mlx5e_ipsec_update_esn_state(struct mlx5e_ipsec_sa_entry *sa_entry)
121110

122111
overlap = sa_entry->esn_state.overlap;
123112

124-
if (esn >= x->replay_esn->replay_window)
125-
seq_bottom = esn - x->replay_esn->replay_window + 1;
113+
if (!x->replay_esn->replay_window) {
114+
seq_bottom = esn;
115+
} else {
116+
if (esn >= x->replay_esn->replay_window)
117+
seq_bottom = esn - x->replay_esn->replay_window + 1;
126118

127-
if (x->xso.type == XFRM_DEV_OFFLOAD_CRYPTO)
128-
esn_msb = xfrm_replay_seqhi(x, htonl(seq_bottom));
119+
if (x->xso.type == XFRM_DEV_OFFLOAD_CRYPTO)
120+
esn_msb = xfrm_replay_seqhi(x, htonl(seq_bottom));
121+
}
129122

130123
if (sa_entry->esn_state.esn_msb)
131124
sa_entry->esn_state.esn = esn;
@@ -980,9 +973,6 @@ static void mlx5e_xfrm_advance_esn_state(struct xfrm_state *x)
980973
struct mlx5e_ipsec_sa_entry *sa_entry_shadow;
981974
bool need_update;
982975

983-
if (x->xso.dir != XFRM_DEV_OFFLOAD_IN)
984-
return;
985-
986976
need_update = mlx5e_ipsec_update_esn_state(sa_entry);
987977
if (!need_update)
988978
return;

0 commit comments

Comments
 (0)