From: Leon Romanovsky <leon@kernel.org>
To: Steffen Klassert <steffen.klassert@secunet.com>
Cc: Leon Romanovsky <leonro@nvidia.com>,
Herbert Xu <herbert@gondor.apana.org.au>,
netdev@vger.kernel.org, Patrisious Haddad <phaddad@nvidia.com>,
Raed Salem <raeds@nvidia.com>, Saeed Mahameed <saeedm@nvidia.com>
Subject: [PATCH xfrm-next 3/9] net/mlx5e: Honor user choice of IPsec replay window size
Date: Mon, 16 Oct 2023 12:15:11 +0300 [thread overview]
Message-ID: <7ccb58e49acabc433281c79c29358dff182c7f95.1697444728.git.leon@kernel.org> (raw)
In-Reply-To: <cover.1697444728.git.leon@kernel.org>
From: Leon Romanovsky <leonro@nvidia.com>
Users can configure IPsec replay window size, but mlx5 driver didn't
honor their choice and set always 32bits. Fix assignment logic to
configure right size from the beginning.
Fixes: 7db21ef4566e ("net/mlx5e: Set IPsec replay sequence numbers")
Reviewed-by: Patrisious Haddad <phaddad@nvidia.com>
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
---
.../mellanox/mlx5/core/en_accel/ipsec.c | 21 +++++++++++++++++++
.../mlx5/core/en_accel/ipsec_offload.c | 2 +-
include/linux/mlx5/mlx5_ifc.h | 7 +++++++
3 files changed, 29 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.c b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.c
index 9bfffdeb0fe8..ddd2230f04aa 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.c
@@ -335,6 +335,27 @@ void mlx5e_ipsec_build_accel_xfrm_attrs(struct mlx5e_ipsec_sa_entry *sa_entry,
attrs->replay_esn.esn = sa_entry->esn_state.esn;
attrs->replay_esn.esn_msb = sa_entry->esn_state.esn_msb;
attrs->replay_esn.overlap = sa_entry->esn_state.overlap;
+ switch (x->replay_esn->replay_window) {
+ case 32:
+ attrs->replay_esn.replay_window =
+ MLX5_IPSEC_ASO_REPLAY_WIN_32BIT;
+ break;
+ case 64:
+ attrs->replay_esn.replay_window =
+ MLX5_IPSEC_ASO_REPLAY_WIN_64BIT;
+ break;
+ case 128:
+ attrs->replay_esn.replay_window =
+ MLX5_IPSEC_ASO_REPLAY_WIN_128BIT;
+ break;
+ case 256:
+ attrs->replay_esn.replay_window =
+ MLX5_IPSEC_ASO_REPLAY_WIN_256BIT;
+ break;
+ default:
+ WARN_ON(true);
+ return;
+ }
}
attrs->dir = x->xso.dir;
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_offload.c b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_offload.c
index a91f772dc981..4e018fba2d5f 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_offload.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_offload.c
@@ -95,7 +95,7 @@ static void mlx5e_ipsec_packet_setup(void *obj, u32 pdn,
if (attrs->dir == XFRM_DEV_OFFLOAD_IN) {
MLX5_SET(ipsec_aso, aso_ctx, window_sz,
- attrs->replay_esn.replay_window / 64);
+ attrs->replay_esn.replay_window);
MLX5_SET(ipsec_aso, aso_ctx, mode,
MLX5_IPSEC_ASO_REPLAY_PROTECTION);
}
diff --git a/include/linux/mlx5/mlx5_ifc.h b/include/linux/mlx5/mlx5_ifc.h
index 4df6d1c12437..6ceafbd8edc5 100644
--- a/include/linux/mlx5/mlx5_ifc.h
+++ b/include/linux/mlx5/mlx5_ifc.h
@@ -11995,6 +11995,13 @@ enum {
MLX5_IPSEC_ASO_INC_SN = 0x2,
};
+enum {
+ MLX5_IPSEC_ASO_REPLAY_WIN_32BIT = 0x0,
+ MLX5_IPSEC_ASO_REPLAY_WIN_64BIT = 0x1,
+ MLX5_IPSEC_ASO_REPLAY_WIN_128BIT = 0x2,
+ MLX5_IPSEC_ASO_REPLAY_WIN_256BIT = 0x3,
+};
+
struct mlx5_ifc_ipsec_aso_bits {
u8 valid[0x1];
u8 reserved_at_201[0x1];
--
2.41.0
next prev parent reply other threads:[~2023-10-16 9:15 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-16 9:15 [PATCH xfrm-next 0/9] mlx5 IPsec replay window enhancement and XFRM core statistics Leon Romanovsky
2023-10-16 9:15 ` [PATCH xfrm-next 1/9] xfrm: generalize xdo_dev_state_update_curlft to allow statistics update Leon Romanovsky
2023-10-16 9:15 ` [PATCH xfrm-next 2/9] xfrm: get global statistics from the offloaded device Leon Romanovsky
2023-10-16 9:15 ` Leon Romanovsky [this message]
2023-10-16 9:15 ` [PATCH xfrm-next 4/9] net/mlx5e: Ensure that IPsec sequence packet number starts from 1 Leon Romanovsky
2023-10-16 9:15 ` [PATCH xfrm-next 5/9] net/mlx5e: Unify esw and normal IPsec status table creation/destruction Leon Romanovsky
2023-10-17 9:38 ` Steffen Klassert
2023-10-17 12:13 ` Leon Romanovsky
2023-10-18 5:13 ` Leon Romanovsky
2023-10-19 8:46 ` Steffen Klassert
2023-10-19 11:01 ` Leon Romanovsky
2023-10-16 9:15 ` [PATCH xfrm-next 6/9] net/mlx5e: Remove exposure of IPsec RX flow steering struct Leon Romanovsky
2023-10-16 9:15 ` [PATCH xfrm-next 7/9] net/mlx5e: Add IPsec and ASO syndromes check in HW Leon Romanovsky
2023-10-16 9:15 ` [PATCH xfrm-next 8/9] net/mlx5e: Connect mlx5 IPsec statistics with XFRM core Leon Romanovsky
2023-10-16 9:15 ` [PATCH xfrm-next 9/9] net/mlx5e: Delete obsolete IPsec code Leon Romanovsky
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7ccb58e49acabc433281c79c29358dff182c7f95.1697444728.git.leon@kernel.org \
--to=leon@kernel.org \
--cc=herbert@gondor.apana.org.au \
--cc=leonro@nvidia.com \
--cc=netdev@vger.kernel.org \
--cc=phaddad@nvidia.com \
--cc=raeds@nvidia.com \
--cc=saeedm@nvidia.com \
--cc=steffen.klassert@secunet.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).