All of lore.kernel.org
 help / color / mirror / Atom feed
From: Saeed Mahameed <saeedm@mellanox.com>
To: "David S. Miller" <davem@davemloft.net>
Cc: "netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	Tariq Toukan <tariqt@mellanox.com>,
	Eran Ben Elisha <eranbe@mellanox.com>,
	Saeed Mahameed <saeedm@mellanox.com>
Subject: [net 11/15] net/mlx5e: kTLS, Save a copy of the crypto info
Date: Fri, 18 Oct 2019 19:38:22 +0000	[thread overview]
Message-ID: <20191018193737.13959-12-saeedm@mellanox.com> (raw)
In-Reply-To: <20191018193737.13959-1-saeedm@mellanox.com>

From: Tariq Toukan <tariqt@mellanox.com>

Do not assume the crypto info is accessible during the
connection lifetime. Save a copy of it in the private
TX context.

Fixes: d2ead1f360e8 ("net/mlx5e: Add kTLS TX HW offload support")
Signed-off-by: Tariq Toukan <tariqt@mellanox.com>
Reviewed-by: Eran Ben Elisha <eranbe@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
---
 drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls.c   | 2 +-
 drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls.h   | 2 +-
 .../net/ethernet/mellanox/mlx5/core/en_accel/ktls_tx.c    | 8 ++------
 3 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls.c b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls.c
index d2ff74d52720..46725cd743a3 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls.c
@@ -38,7 +38,7 @@ static int mlx5e_ktls_add(struct net_device *netdev, struct sock *sk,
 		return -ENOMEM;
 
 	tx_priv->expected_seq = start_offload_tcp_sn;
-	tx_priv->crypto_info  = crypto_info;
+	tx_priv->crypto_info  = *(struct tls12_crypto_info_aes_gcm_128 *)crypto_info;
 	mlx5e_set_ktls_tx_priv_ctx(tls_ctx, tx_priv);
 
 	/* tc and underlay_qpn values are not in use for tls tis */
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls.h b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls.h
index 929966e6fbc4..a3efa29a4629 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls.h
@@ -44,7 +44,7 @@ enum {
 
 struct mlx5e_ktls_offload_context_tx {
 	struct tls_offload_context_tx *tx_ctx;
-	struct tls_crypto_info *crypto_info;
+	struct tls12_crypto_info_aes_gcm_128 crypto_info;
 	u32 expected_seq;
 	u32 tisn;
 	u32 key_id;
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_tx.c b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_tx.c
index 1bfeb558ff78..badc6fd26a14 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_tx.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_tx.c
@@ -24,14 +24,12 @@ enum {
 static void
 fill_static_params_ctx(void *ctx, struct mlx5e_ktls_offload_context_tx *priv_tx)
 {
-	struct tls_crypto_info *crypto_info = priv_tx->crypto_info;
-	struct tls12_crypto_info_aes_gcm_128 *info;
+	struct tls12_crypto_info_aes_gcm_128 *info = &priv_tx->crypto_info;
 	char *initial_rn, *gcm_iv;
 	u16 salt_sz, rec_seq_sz;
 	char *salt, *rec_seq;
 	u8 tls_version;
 
-	info = (struct tls12_crypto_info_aes_gcm_128 *)crypto_info;
 	EXTRACT_INFO_FIELDS;
 
 	gcm_iv      = MLX5_ADDR_OF(tls_static_params, ctx, gcm_iv);
@@ -233,14 +231,12 @@ tx_post_resync_params(struct mlx5e_txqsq *sq,
 		      struct mlx5e_ktls_offload_context_tx *priv_tx,
 		      u64 rcd_sn)
 {
-	struct tls_crypto_info *crypto_info = priv_tx->crypto_info;
-	struct tls12_crypto_info_aes_gcm_128 *info;
+	struct tls12_crypto_info_aes_gcm_128 *info = &priv_tx->crypto_info;
 	__be64 rn_be = cpu_to_be64(rcd_sn);
 	bool skip_static_post;
 	u16 rec_seq_sz;
 	char *rec_seq;
 
-	info = (struct tls12_crypto_info_aes_gcm_128 *)crypto_info;
 	rec_seq = info->rec_seq;
 	rec_seq_sz = sizeof(info->rec_seq);
 
-- 
2.21.0


  parent reply	other threads:[~2019-10-18 19:38 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-18 19:37 [pull request][net 00/15] Mellanox, mlx5 kTLS fixes 18-10-2019 Saeed Mahameed
2019-10-18 19:38 ` [net 01/15] net/mlx5e: Tx, Fix assumption of single WQEBB of NOP in cleanup flow Saeed Mahameed
2019-10-18 19:38 ` [net 02/15] net/mlx5e: Tx, Zero-memset WQE info struct upon update Saeed Mahameed
2019-10-18 19:38 ` [net 03/15] net/mlx5e: kTLS, Release reference on DUMPed fragments in shutdown flow Saeed Mahameed
2019-10-18 19:38 ` [net 04/15] net/mlx5e: kTLS, Size of a Dump WQE is fixed Saeed Mahameed
2019-10-18 23:13   ` Jakub Kicinski
2019-10-22 18:06     ` Saeed Mahameed
2019-10-18 19:38 ` [net 05/15] net/mlx5e: kTLS, Save only the frag page to release at completion Saeed Mahameed
2019-10-18 19:38 ` [net 06/15] net/mlx5e: kTLS, Save by-value copy of the record frags Saeed Mahameed
2019-10-18 19:38 ` [net 07/15] net/mlx5e: kTLS, Fix page refcnt leak in TX resync error flow Saeed Mahameed
2019-10-18 19:38 ` [net 08/15] net/mlx5e: kTLS, Fix missing SQ edge fill Saeed Mahameed
2019-10-18 19:38 ` [net 09/15] net/mlx5e: kTLS, Limit DUMP wqe size Saeed Mahameed
2019-10-18 19:38 ` [net 10/15] net/mlx5e: kTLS, Remove unneeded cipher type checks Saeed Mahameed
2019-10-18 23:13   ` Jakub Kicinski
2019-10-18 19:38 ` Saeed Mahameed [this message]
2019-10-18 23:16   ` [net 11/15] net/mlx5e: kTLS, Save a copy of the crypto info Jakub Kicinski
2019-10-20  7:46     ` Tariq Toukan
2019-10-20 17:08       ` Jakub Kicinski
2019-10-18 19:38 ` [net 12/15] net/mlx5e: kTLS, Enhance TX resync flow Saeed Mahameed
2019-10-19  1:51   ` Jakub Kicinski
2019-10-22 18:10     ` Saeed Mahameed
2019-10-22 18:42       ` Jakub Kicinski
2019-10-22 18:52         ` Saeed Mahameed
2019-10-18 19:38 ` [net 13/15] net/mlx5e: TX, Fix consumer index of error cqe dump Saeed Mahameed
2019-10-18 19:38 ` [net 14/15] net/mlx5: prevent memory leak in mlx5_fpga_conn_create_cq Saeed Mahameed
2019-10-18 19:38 ` [net 15/15] net/mlx5: fix memory leak in mlx5_fw_fatal_reporter_dump Saeed Mahameed
2019-10-21 16:19 ` [pull request][net 00/15] Mellanox, mlx5 kTLS fixes 18-10-2019 David Miller

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=20191018193737.13959-12-saeedm@mellanox.com \
    --to=saeedm@mellanox.com \
    --cc=davem@davemloft.net \
    --cc=eranbe@mellanox.com \
    --cc=netdev@vger.kernel.org \
    --cc=tariqt@mellanox.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.