Skip to content

Commit

Permalink
xfrm: Support ESN context update to hardware for TX
Browse files Browse the repository at this point in the history
Previously xfrm_dev_state_advance_esn() was added for RX only. But
it's possible that ESN context also need to be synced to hardware for
TX, so call it for outbound in this patch.

Signed-off-by: Jianbo Liu <jianbol@nvidia.com>
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
  • Loading branch information
Jianbo Liu authored and Steffen Klassert committed Jan 7, 2025
1 parent 59af653 commit 373b79a
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Documentation/networking/xfrm_device.rst
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,8 @@ the stack in xfrm_input().

hand the packet to napi_gro_receive() as usual

In ESN mode, xdo_dev_state_advance_esn() is called from xfrm_replay_advance_esn().
In ESN mode, xdo_dev_state_advance_esn() is called from
xfrm_replay_advance_esn() for RX, and xfrm_replay_overflow_offload_esn for TX.
Driver will check packet seq number and update HW ESN state machine if needed.

Packet offload mode:
Expand Down
3 changes: 3 additions & 0 deletions drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -6559,6 +6559,9 @@ static void cxgb4_advance_esn_state(struct xfrm_state *x)
{
struct adapter *adap = netdev2adap(x->xso.dev);

if (x->xso.dir != XFRM_DEV_OFFLOAD_IN)
return;

if (!mutex_trylock(&uld_mutex)) {
dev_dbg(adap->pdev_dev,
"crypto uld critical resource is under use\n");
Expand Down
3 changes: 3 additions & 0 deletions drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.c
Original file line number Diff line number Diff line change
Expand Up @@ -980,6 +980,9 @@ static void mlx5e_xfrm_advance_esn_state(struct xfrm_state *x)
struct mlx5e_ipsec_sa_entry *sa_entry_shadow;
bool need_update;

if (x->xso.dir != XFRM_DEV_OFFLOAD_IN)
return;

need_update = mlx5e_ipsec_update_esn_state(sa_entry);
if (!need_update)
return;
Expand Down
1 change: 1 addition & 0 deletions net/xfrm/xfrm_replay.c
Original file line number Diff line number Diff line change
Expand Up @@ -729,6 +729,7 @@ static int xfrm_replay_overflow_offload_esn(struct xfrm_state *x, struct sk_buff
}

replay_esn->oseq = oseq;
xfrm_dev_state_advance_esn(x);

if (xfrm_aevent_is_on(net))
xfrm_replay_notify(x, XFRM_REPLAY_UPDATE);
Expand Down

0 comments on commit 373b79a

Please sign in to comment.