All of lore.kernel.org
 help / color / mirror / Atom feed
* [pull request][net 00/15] Mellanox, mlx5 kTLS fixes 18-10-2019
@ 2019-10-18 19:37 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
                   ` (15 more replies)
  0 siblings, 16 replies; 27+ messages in thread
From: Saeed Mahameed @ 2019-10-18 19:37 UTC (permalink / raw)
  To: David S. Miller; +Cc: netdev, Saeed Mahameed

Hi Dave,

This series introduces kTLS related fixes to mlx5 driver from Tariq,
and two misc memory leak fixes form Navid Emamdoost.

Please pull and let me know if there is any problem.

I would appreciate it if you queue up kTLS fixes from the list below to
stable kernel v5.3 !

For -stable v4.13:
  nett/mlx5: prevent memory leak in mlx5_fpga_conn_create_cq 

For -stable v5.3:
  net/mlx5: fix memory leak in mlx5_fw_fatal_reporter_dump
  net/mlx5e: Tx, Fix assumption of single WQEBB of NOP in cleanup flow
  net/mlx5e: Tx, Zero-memset WQE info struct upon update
  net/mlx5e: kTLS, Release reference on DUMPed fragments in shutdown flow
  net/mlx5e: kTLS, Size of a Dump WQE is fixed
  net/mlx5e: kTLS, Save only the frag page to release at completion
  net/mlx5e: kTLS, Save by-value copy of the record frags
  net/mlx5e: kTLS, Fix page refcnt leak in TX resync error flow
  net/mlx5e: kTLS, Fix missing SQ edge fill
  net/mlx5e: kTLS, Limit DUMP wqe size
  net/mlx5e: kTLS, Remove unneeded cipher type checks
  net/mlx5e: kTLS, Save a copy of the crypto info
  net/mlx5e: kTLS, Enhance TX resync flow
  net/mlx5e: TX, Fix consumer index of error cqe dump

Thanks,
Saeed.

---
The following changes since commit 38b4fe320119859c11b1dc06f6b4987a16344fa1:

  net: usb: lan78xx: Connect PHY before registering MAC (2019-10-18 10:22:04 -0700)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux.git tags/mlx5-fixes-2019-10-18

for you to fetch changes up to c7ed6d0183d5ea9bc31bcaeeba4070bd62546471:

  net/mlx5: fix memory leak in mlx5_fw_fatal_reporter_dump (2019-10-18 12:11:55 -0700)

----------------------------------------------------------------
mlx5-fixes-2019-10-18

----------------------------------------------------------------
Navid Emamdoost (2):
      net/mlx5: prevent memory leak in mlx5_fpga_conn_create_cq
      net/mlx5: fix memory leak in mlx5_fw_fatal_reporter_dump

Tariq Toukan (13):
      net/mlx5e: Tx, Fix assumption of single WQEBB of NOP in cleanup flow
      net/mlx5e: Tx, Zero-memset WQE info struct upon update
      net/mlx5e: kTLS, Release reference on DUMPed fragments in shutdown flow
      net/mlx5e: kTLS, Size of a Dump WQE is fixed
      net/mlx5e: kTLS, Save only the frag page to release at completion
      net/mlx5e: kTLS, Save by-value copy of the record frags
      net/mlx5e: kTLS, Fix page refcnt leak in TX resync error flow
      net/mlx5e: kTLS, Fix missing SQ edge fill
      net/mlx5e: kTLS, Limit DUMP wqe size
      net/mlx5e: kTLS, Remove unneeded cipher type checks
      net/mlx5e: kTLS, Save a copy of the crypto info
      net/mlx5e: kTLS, Enhance TX resync flow
      net/mlx5e: TX, Fix consumer index of error cqe dump

 drivers/net/ethernet/mellanox/mlx5/core/en.h       |   3 +-
 drivers/net/ethernet/mellanox/mlx5/core/en/txrx.h  |  13 +-
 .../ethernet/mellanox/mlx5/core/en_accel/ktls.c    |   2 +-
 .../ethernet/mellanox/mlx5/core/en_accel/ktls.h    |  29 +++-
 .../ethernet/mellanox/mlx5/core/en_accel/ktls_tx.c | 190 ++++++++++++---------
 drivers/net/ethernet/mellanox/mlx5/core/en_main.c  |  13 +-
 drivers/net/ethernet/mellanox/mlx5/core/en_stats.c |  16 +-
 drivers/net/ethernet/mellanox/mlx5/core/en_stats.h |  10 +-
 drivers/net/ethernet/mellanox/mlx5/core/en_tx.c    |  35 ++--
 .../net/ethernet/mellanox/mlx5/core/fpga/conn.c    |   4 +-
 drivers/net/ethernet/mellanox/mlx5/core/health.c   |   2 +-
 11 files changed, 199 insertions(+), 118 deletions(-)

^ permalink raw reply	[flat|nested] 27+ messages in thread

* [net 01/15] net/mlx5e: Tx, Fix assumption of single WQEBB of NOP in cleanup flow
  2019-10-18 19:37 [pull request][net 00/15] Mellanox, mlx5 kTLS fixes 18-10-2019 Saeed Mahameed
@ 2019-10-18 19:38 ` Saeed Mahameed
  2019-10-18 19:38 ` [net 02/15] net/mlx5e: Tx, Zero-memset WQE info struct upon update Saeed Mahameed
                   ` (14 subsequent siblings)
  15 siblings, 0 replies; 27+ messages in thread
From: Saeed Mahameed @ 2019-10-18 19:38 UTC (permalink / raw)
  To: David S. Miller; +Cc: netdev, Tariq Toukan, Eran Ben Elisha, Saeed Mahameed

From: Tariq Toukan <tariqt@mellanox.com>

Cited patch removed the assumption only in datapath.
Here we remove it also form control/cleanup flow.

Fixes: 9ab0233728ca ("net/mlx5e: Tx, Don't implicitly assume SKB-less wqe has one WQEBB")
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_main.c | 6 +++++-
 drivers/net/ethernet/mellanox/mlx5/core/en_tx.c   | 4 ++--
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
index 7569287f8f3c..b476b007f093 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
@@ -1349,9 +1349,13 @@ static void mlx5e_deactivate_txqsq(struct mlx5e_txqsq *sq)
 	/* last doorbell out, godspeed .. */
 	if (mlx5e_wqc_has_room_for(wq, sq->cc, sq->pc, 1)) {
 		u16 pi = mlx5_wq_cyc_ctr2ix(wq, sq->pc);
+		struct mlx5e_tx_wqe_info *wi;
 		struct mlx5e_tx_wqe *nop;
 
-		sq->db.wqe_info[pi].skb = NULL;
+		wi = &sq->db.wqe_info[pi];
+
+		memset(wi, 0, sizeof(*wi));
+		wi->num_wqebbs = 1;
 		nop = mlx5e_post_nop(wq, sq->sqn, &sq->pc);
 		mlx5e_notify_hw(wq, sq->pc, sq->uar_map, &nop->ctrl);
 	}
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c
index d3a67a9b4eba..9094e9519db7 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c
@@ -550,8 +550,8 @@ void mlx5e_free_txqsq_descs(struct mlx5e_txqsq *sq)
 		wi = &sq->db.wqe_info[ci];
 		skb = wi->skb;
 
-		if (!skb) { /* nop */
-			sq->cc++;
+		if (!skb) {
+			sq->cc += wi->num_wqebbs;
 			continue;
 		}
 
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [net 02/15] net/mlx5e: Tx, Zero-memset WQE info struct upon update
  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 ` Saeed Mahameed
  2019-10-18 19:38 ` [net 03/15] net/mlx5e: kTLS, Release reference on DUMPed fragments in shutdown flow Saeed Mahameed
                   ` (13 subsequent siblings)
  15 siblings, 0 replies; 27+ messages in thread
From: Saeed Mahameed @ 2019-10-18 19:38 UTC (permalink / raw)
  To: David S. Miller; +Cc: netdev, Tariq Toukan, Eran Ben Elisha, Saeed Mahameed

From: Tariq Toukan <tariqt@mellanox.com>

Not all fields of WQE info are being written in the function,
having some leftovers from previous rounds.
Zero-memset it upon update.

Particularly, not nullifying the wi->resync_dump_frag field
will cause double free of the kTLS DUMPed frags.

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/txrx.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/txrx.h b/drivers/net/ethernet/mellanox/mlx5/core/en/txrx.h
index 87be96747902..182d5c5664eb 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en/txrx.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en/txrx.h
@@ -92,7 +92,7 @@ mlx5e_fill_sq_frag_edge(struct mlx5e_txqsq *sq, struct mlx5_wq_cyc *wq,
 
 	/* fill sq frag edge with nops to avoid wqe wrapping two pages */
 	for (; wi < edge_wi; wi++) {
-		wi->skb        = NULL;
+		memset(wi, 0, sizeof(*wi));
 		wi->num_wqebbs = 1;
 		mlx5e_post_nop(wq, sq->sqn, &sq->pc);
 	}
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [net 03/15] net/mlx5e: kTLS, Release reference on DUMPed fragments in shutdown flow
  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 ` Saeed Mahameed
  2019-10-18 19:38 ` [net 04/15] net/mlx5e: kTLS, Size of a Dump WQE is fixed Saeed Mahameed
                   ` (12 subsequent siblings)
  15 siblings, 0 replies; 27+ messages in thread
From: Saeed Mahameed @ 2019-10-18 19:38 UTC (permalink / raw)
  To: David S. Miller; +Cc: netdev, Tariq Toukan, Eran Ben Elisha, Saeed Mahameed

From: Tariq Toukan <tariqt@mellanox.com>

A call to kTLS completion handler was missing in the TXQSQ release
flow. Add it.

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>
---
 .../mellanox/mlx5/core/en_accel/ktls.h        |  7 ++++-
 .../mellanox/mlx5/core/en_accel/ktls_tx.c     | 11 ++++++--
 .../net/ethernet/mellanox/mlx5/core/en_tx.c   | 28 ++++++++++---------
 3 files changed, 30 insertions(+), 16 deletions(-)

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 b7298f9ee3d3..c4c128908b6e 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls.h
@@ -86,7 +86,7 @@ struct sk_buff *mlx5e_ktls_handle_tx_skb(struct net_device *netdev,
 					 struct mlx5e_tx_wqe **wqe, u16 *pi);
 void mlx5e_ktls_tx_handle_resync_dump_comp(struct mlx5e_txqsq *sq,
 					   struct mlx5e_tx_wqe_info *wi,
-					   struct mlx5e_sq_dma *dma);
+					   u32 *dma_fifo_cc);
 
 #else
 
@@ -94,6 +94,11 @@ static inline void mlx5e_ktls_build_netdev(struct mlx5e_priv *priv)
 {
 }
 
+static inline void
+mlx5e_ktls_tx_handle_resync_dump_comp(struct mlx5e_txqsq *sq,
+				      struct mlx5e_tx_wqe_info *wi,
+				      u32 *dma_fifo_cc) {}
+
 #endif
 
 #endif /* __MLX5E_TLS_H__ */
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 d195366461c9..90c6ce530a18 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
@@ -303,9 +303,16 @@ tx_post_resync_dump(struct mlx5e_txqsq *sq, skb_frag_t *frag, u32 tisn, bool fir
 
 void mlx5e_ktls_tx_handle_resync_dump_comp(struct mlx5e_txqsq *sq,
 					   struct mlx5e_tx_wqe_info *wi,
-					   struct mlx5e_sq_dma *dma)
+					   u32 *dma_fifo_cc)
 {
-	struct mlx5e_sq_stats *stats = sq->stats;
+	struct mlx5e_sq_stats *stats;
+	struct mlx5e_sq_dma *dma;
+
+	if (!wi->resync_dump_frag)
+		return;
+
+	dma = mlx5e_dma_get(sq, (*dma_fifo_cc)++);
+	stats = sq->stats;
 
 	mlx5e_tx_dma_unmap(sq->pdev, dma);
 	__skb_frag_unref(wi->resync_dump_frag);
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c
index 9094e9519db7..8dd8f0be101b 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c
@@ -479,14 +479,7 @@ bool mlx5e_poll_tx_cq(struct mlx5e_cq *cq, int napi_budget)
 			skb = wi->skb;
 
 			if (unlikely(!skb)) {
-#ifdef CONFIG_MLX5_EN_TLS
-				if (wi->resync_dump_frag) {
-					struct mlx5e_sq_dma *dma =
-						mlx5e_dma_get(sq, dma_fifo_cc++);
-
-					mlx5e_ktls_tx_handle_resync_dump_comp(sq, wi, dma);
-				}
-#endif
+				mlx5e_ktls_tx_handle_resync_dump_comp(sq, wi, &dma_fifo_cc);
 				sqcc += wi->num_wqebbs;
 				continue;
 			}
@@ -542,29 +535,38 @@ void mlx5e_free_txqsq_descs(struct mlx5e_txqsq *sq)
 {
 	struct mlx5e_tx_wqe_info *wi;
 	struct sk_buff *skb;
+	u32 dma_fifo_cc;
+	u16 sqcc;
 	u16 ci;
 	int i;
 
-	while (sq->cc != sq->pc) {
-		ci = mlx5_wq_cyc_ctr2ix(&sq->wq, sq->cc);
+	sqcc = sq->cc;
+	dma_fifo_cc = sq->dma_fifo_cc;
+
+	while (sqcc != sq->pc) {
+		ci = mlx5_wq_cyc_ctr2ix(&sq->wq, sqcc);
 		wi = &sq->db.wqe_info[ci];
 		skb = wi->skb;
 
 		if (!skb) {
-			sq->cc += wi->num_wqebbs;
+			mlx5e_ktls_tx_handle_resync_dump_comp(sq, wi, &dma_fifo_cc);
+			sqcc += wi->num_wqebbs;
 			continue;
 		}
 
 		for (i = 0; i < wi->num_dma; i++) {
 			struct mlx5e_sq_dma *dma =
-				mlx5e_dma_get(sq, sq->dma_fifo_cc++);
+				mlx5e_dma_get(sq, dma_fifo_cc++);
 
 			mlx5e_tx_dma_unmap(sq->pdev, dma);
 		}
 
 		dev_kfree_skb_any(skb);
-		sq->cc += wi->num_wqebbs;
+		sqcc += wi->num_wqebbs;
 	}
+
+	sq->dma_fifo_cc = dma_fifo_cc;
+	sq->cc = sqcc;
 }
 
 #ifdef CONFIG_MLX5_CORE_IPOIB
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [net 04/15] net/mlx5e: kTLS, Size of a Dump WQE is fixed
  2019-10-18 19:37 [pull request][net 00/15] Mellanox, mlx5 kTLS fixes 18-10-2019 Saeed Mahameed
                   ` (2 preceding siblings ...)
  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 ` Saeed Mahameed
  2019-10-18 23:13   ` Jakub Kicinski
  2019-10-18 19:38 ` [net 05/15] net/mlx5e: kTLS, Save only the frag page to release at completion Saeed Mahameed
                   ` (11 subsequent siblings)
  15 siblings, 1 reply; 27+ messages in thread
From: Saeed Mahameed @ 2019-10-18 19:38 UTC (permalink / raw)
  To: David S. Miller; +Cc: netdev, Tariq Toukan, Eran Ben Elisha, Saeed Mahameed

From: Tariq Toukan <tariqt@mellanox.com>

No Eth segment, so no dynamic inline headers.
The size of a Dump WQE is fixed, use constants and remove
unnecessary checks.

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>
---
 .../net/ethernet/mellanox/mlx5/core/en/txrx.h   |  2 +-
 .../ethernet/mellanox/mlx5/core/en_accel/ktls.h |  9 ++++++++-
 .../mellanox/mlx5/core/en_accel/ktls_tx.c       | 17 +++--------------
 3 files changed, 12 insertions(+), 16 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/txrx.h b/drivers/net/ethernet/mellanox/mlx5/core/en/txrx.h
index 182d5c5664eb..25f9dda578ac 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en/txrx.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en/txrx.h
@@ -23,7 +23,7 @@
 #define MLX5E_SQ_TLS_ROOM  \
 	(MLX5_SEND_WQE_MAX_WQEBBS + \
 	 MLX5E_KTLS_STATIC_WQEBBS + MLX5E_KTLS_PROGRESS_WQEBBS + \
-	 MAX_SKB_FRAGS * MLX5E_KTLS_MAX_DUMP_WQEBBS)
+	 MAX_SKB_FRAGS * MLX5E_KTLS_DUMP_WQEBBS)
 #endif
 
 #define INL_HDR_START_SZ (sizeof(((struct mlx5_wqe_eth_seg *)NULL)->inline_hdr.start))
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 c4c128908b6e..eb692feba4a6 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls.h
@@ -21,7 +21,14 @@
 	 MLX5_ST_SZ_BYTES(tls_progress_params))
 #define MLX5E_KTLS_PROGRESS_WQEBBS \
 	(DIV_ROUND_UP(MLX5E_KTLS_PROGRESS_WQE_SZ, MLX5_SEND_WQE_BB))
-#define MLX5E_KTLS_MAX_DUMP_WQEBBS 2
+
+struct mlx5e_dump_wqe {
+	struct mlx5_wqe_ctrl_seg ctrl;
+	struct mlx5_wqe_data_seg data;
+};
+
+#define MLX5E_KTLS_DUMP_WQEBBS \
+	(DIV_ROUND_UP(sizeof(struct mlx5e_dump_wqe), MLX5_SEND_WQE_BB))
 
 enum {
 	MLX5E_TLS_PROGRESS_PARAMS_AUTH_STATE_NO_OFFLOAD     = 0,
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 90c6ce530a18..ac54767b7d86 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
@@ -250,11 +250,6 @@ tx_post_resync_params(struct mlx5e_txqsq *sq,
 	mlx5e_ktls_tx_post_param_wqes(sq, priv_tx, skip_static_post, true);
 }
 
-struct mlx5e_dump_wqe {
-	struct mlx5_wqe_ctrl_seg ctrl;
-	struct mlx5_wqe_data_seg data;
-};
-
 static int
 tx_post_resync_dump(struct mlx5e_txqsq *sq, skb_frag_t *frag, u32 tisn, bool first)
 {
@@ -262,7 +257,6 @@ tx_post_resync_dump(struct mlx5e_txqsq *sq, skb_frag_t *frag, u32 tisn, bool fir
 	struct mlx5_wqe_data_seg *dseg;
 	struct mlx5e_dump_wqe *wqe;
 	dma_addr_t dma_addr = 0;
-	u8  num_wqebbs;
 	u16 ds_cnt;
 	int fsz;
 	u16 pi;
@@ -270,7 +264,6 @@ tx_post_resync_dump(struct mlx5e_txqsq *sq, skb_frag_t *frag, u32 tisn, bool fir
 	wqe = mlx5e_sq_fetch_wqe(sq, sizeof(*wqe), &pi);
 
 	ds_cnt = sizeof(*wqe) / MLX5_SEND_WQE_DS;
-	num_wqebbs = DIV_ROUND_UP(ds_cnt, MLX5_SEND_WQEBB_NUM_DS);
 
 	cseg = &wqe->ctrl;
 	dseg = &wqe->data;
@@ -291,12 +284,8 @@ tx_post_resync_dump(struct mlx5e_txqsq *sq, skb_frag_t *frag, u32 tisn, bool fir
 	dseg->byte_count = cpu_to_be32(fsz);
 	mlx5e_dma_push(sq, dma_addr, fsz, MLX5E_DMA_MAP_PAGE);
 
-	tx_fill_wi(sq, pi, num_wqebbs, frag, fsz);
-	sq->pc += num_wqebbs;
-
-	WARN(num_wqebbs > MLX5E_KTLS_MAX_DUMP_WQEBBS,
-	     "unexpected DUMP num_wqebbs, %d > %d",
-	     num_wqebbs, MLX5E_KTLS_MAX_DUMP_WQEBBS);
+	tx_fill_wi(sq, pi, MLX5E_KTLS_DUMP_WQEBBS, frag, fsz);
+	sq->pc += MLX5E_KTLS_DUMP_WQEBBS;
 
 	return 0;
 }
@@ -368,7 +357,7 @@ mlx5e_ktls_tx_handle_ooo(struct mlx5e_ktls_offload_context_tx *priv_tx,
 	stats->tls_ooo++;
 
 	num_wqebbs = MLX5E_KTLS_STATIC_WQEBBS + MLX5E_KTLS_PROGRESS_WQEBBS +
-		(info.nr_frags ? info.nr_frags * MLX5E_KTLS_MAX_DUMP_WQEBBS : 1);
+		(info.nr_frags ? info.nr_frags * MLX5E_KTLS_DUMP_WQEBBS : 1);
 	pi = mlx5_wq_cyc_ctr2ix(wq, sq->pc);
 	contig_wqebbs_room = mlx5_wq_cyc_get_contig_wqebbs(wq, pi);
 	if (unlikely(contig_wqebbs_room < num_wqebbs))
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [net 05/15] net/mlx5e: kTLS, Save only the frag page to release at completion
  2019-10-18 19:37 [pull request][net 00/15] Mellanox, mlx5 kTLS fixes 18-10-2019 Saeed Mahameed
                   ` (3 preceding siblings ...)
  2019-10-18 19:38 ` [net 04/15] net/mlx5e: kTLS, Size of a Dump WQE is fixed Saeed Mahameed
@ 2019-10-18 19:38 ` Saeed Mahameed
  2019-10-18 19:38 ` [net 06/15] net/mlx5e: kTLS, Save by-value copy of the record frags Saeed Mahameed
                   ` (10 subsequent siblings)
  15 siblings, 0 replies; 27+ messages in thread
From: Saeed Mahameed @ 2019-10-18 19:38 UTC (permalink / raw)
  To: David S. Miller; +Cc: netdev, Tariq Toukan, Eran Ben Elisha, Saeed Mahameed

From: Tariq Toukan <tariqt@mellanox.com>

In TX resync flow where DUMP WQEs are posted, keep a pointer to
the fragment page to unref it upon completion, instead of saving
the whole fragment.

In addition, move it the end of the arguments list in tx_fill_wi().

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.h  |  2 +-
 .../mellanox/mlx5/core/en_accel/ktls_tx.c     | 27 +++++++++----------
 2 files changed, 14 insertions(+), 15 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en.h b/drivers/net/ethernet/mellanox/mlx5/core/en.h
index 8d76452cacdc..cb6f7b87e38f 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en.h
@@ -345,7 +345,7 @@ struct mlx5e_tx_wqe_info {
 	u8  num_wqebbs;
 	u8  num_dma;
 #ifdef CONFIG_MLX5_EN_TLS
-	skb_frag_t *resync_dump_frag;
+	struct page *resync_dump_frag_page;
 #endif
 };
 
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 ac54767b7d86..6dfb22d705b2 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
@@ -108,16 +108,15 @@ build_progress_params(struct mlx5e_tx_wqe *wqe, u16 pc, u32 sqn,
 }
 
 static void tx_fill_wi(struct mlx5e_txqsq *sq,
-		       u16 pi, u8 num_wqebbs,
-		       skb_frag_t *resync_dump_frag,
-		       u32 num_bytes)
+		       u16 pi, u8 num_wqebbs, u32 num_bytes,
+		       struct page *page)
 {
 	struct mlx5e_tx_wqe_info *wi = &sq->db.wqe_info[pi];
 
-	wi->skb              = NULL;
-	wi->num_wqebbs       = num_wqebbs;
-	wi->resync_dump_frag = resync_dump_frag;
-	wi->num_bytes        = num_bytes;
+	memset(wi, 0, sizeof(*wi));
+	wi->num_wqebbs = num_wqebbs;
+	wi->num_bytes  = num_bytes;
+	wi->resync_dump_frag_page = page;
 }
 
 void mlx5e_ktls_tx_offload_set_pending(struct mlx5e_ktls_offload_context_tx *priv_tx)
@@ -145,7 +144,7 @@ post_static_params(struct mlx5e_txqsq *sq,
 
 	umr_wqe = mlx5e_sq_fetch_wqe(sq, MLX5E_KTLS_STATIC_UMR_WQE_SZ, &pi);
 	build_static_params(umr_wqe, sq->pc, sq->sqn, priv_tx, fence);
-	tx_fill_wi(sq, pi, MLX5E_KTLS_STATIC_WQEBBS, NULL, 0);
+	tx_fill_wi(sq, pi, MLX5E_KTLS_STATIC_WQEBBS, 0, NULL);
 	sq->pc += MLX5E_KTLS_STATIC_WQEBBS;
 }
 
@@ -159,7 +158,7 @@ post_progress_params(struct mlx5e_txqsq *sq,
 
 	wqe = mlx5e_sq_fetch_wqe(sq, MLX5E_KTLS_PROGRESS_WQE_SZ, &pi);
 	build_progress_params(wqe, sq->pc, sq->sqn, priv_tx, fence);
-	tx_fill_wi(sq, pi, MLX5E_KTLS_PROGRESS_WQEBBS, NULL, 0);
+	tx_fill_wi(sq, pi, MLX5E_KTLS_PROGRESS_WQEBBS, 0, NULL);
 	sq->pc += MLX5E_KTLS_PROGRESS_WQEBBS;
 }
 
@@ -211,7 +210,7 @@ static bool tx_sync_info_get(struct mlx5e_ktls_offload_context_tx *priv_tx,
 	while (remaining > 0) {
 		skb_frag_t *frag = &record->frags[i];
 
-		__skb_frag_ref(frag);
+		get_page(skb_frag_page(frag));
 		remaining -= skb_frag_size(frag);
 		info->frags[i++] = frag;
 	}
@@ -284,7 +283,7 @@ tx_post_resync_dump(struct mlx5e_txqsq *sq, skb_frag_t *frag, u32 tisn, bool fir
 	dseg->byte_count = cpu_to_be32(fsz);
 	mlx5e_dma_push(sq, dma_addr, fsz, MLX5E_DMA_MAP_PAGE);
 
-	tx_fill_wi(sq, pi, MLX5E_KTLS_DUMP_WQEBBS, frag, fsz);
+	tx_fill_wi(sq, pi, MLX5E_KTLS_DUMP_WQEBBS, fsz, skb_frag_page(frag));
 	sq->pc += MLX5E_KTLS_DUMP_WQEBBS;
 
 	return 0;
@@ -297,14 +296,14 @@ void mlx5e_ktls_tx_handle_resync_dump_comp(struct mlx5e_txqsq *sq,
 	struct mlx5e_sq_stats *stats;
 	struct mlx5e_sq_dma *dma;
 
-	if (!wi->resync_dump_frag)
+	if (!wi->resync_dump_frag_page)
 		return;
 
 	dma = mlx5e_dma_get(sq, (*dma_fifo_cc)++);
 	stats = sq->stats;
 
 	mlx5e_tx_dma_unmap(sq->pdev, dma);
-	__skb_frag_unref(wi->resync_dump_frag);
+	put_page(wi->resync_dump_frag_page);
 	stats->tls_dump_packets++;
 	stats->tls_dump_bytes += wi->num_bytes;
 }
@@ -314,7 +313,7 @@ static void tx_post_fence_nop(struct mlx5e_txqsq *sq)
 	struct mlx5_wq_cyc *wq = &sq->wq;
 	u16 pi = mlx5_wq_cyc_ctr2ix(wq, sq->pc);
 
-	tx_fill_wi(sq, pi, 1, NULL, 0);
+	tx_fill_wi(sq, pi, 1, 0, NULL);
 
 	mlx5e_post_nop_fence(wq, sq->sqn, &sq->pc);
 }
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [net 06/15] net/mlx5e: kTLS, Save by-value copy of the record frags
  2019-10-18 19:37 [pull request][net 00/15] Mellanox, mlx5 kTLS fixes 18-10-2019 Saeed Mahameed
                   ` (4 preceding siblings ...)
  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 ` Saeed Mahameed
  2019-10-18 19:38 ` [net 07/15] net/mlx5e: kTLS, Fix page refcnt leak in TX resync error flow Saeed Mahameed
                   ` (9 subsequent siblings)
  15 siblings, 0 replies; 27+ messages in thread
From: Saeed Mahameed @ 2019-10-18 19:38 UTC (permalink / raw)
  To: David S. Miller; +Cc: netdev, Tariq Toukan, Eran Ben Elisha, Saeed Mahameed

From: Tariq Toukan <tariqt@mellanox.com>

Access the record fragments only under the TLS ctx lock.
In the resync flow, save a copy of them to be used when
preparing and posting the required DUMP WQEs.

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>
---
 .../net/ethernet/mellanox/mlx5/core/en_accel/ktls_tx.c    | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

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 6dfb22d705b2..334808b1863b 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
@@ -179,7 +179,7 @@ struct tx_sync_info {
 	u64 rcd_sn;
 	s32 sync_len;
 	int nr_frags;
-	skb_frag_t *frags[MAX_SKB_FRAGS];
+	skb_frag_t frags[MAX_SKB_FRAGS];
 };
 
 static bool tx_sync_info_get(struct mlx5e_ktls_offload_context_tx *priv_tx,
@@ -212,11 +212,11 @@ static bool tx_sync_info_get(struct mlx5e_ktls_offload_context_tx *priv_tx,
 
 		get_page(skb_frag_page(frag));
 		remaining -= skb_frag_size(frag);
-		info->frags[i++] = frag;
+		info->frags[i++] = *frag;
 	}
 	/* reduce the part which will be sent with the original SKB */
 	if (remaining < 0)
-		skb_frag_size_add(info->frags[i - 1], remaining);
+		skb_frag_size_add(&info->frags[i - 1], remaining);
 	info->nr_frags = i;
 out:
 	spin_unlock_irqrestore(&tx_ctx->lock, flags);
@@ -365,7 +365,7 @@ mlx5e_ktls_tx_handle_ooo(struct mlx5e_ktls_offload_context_tx *priv_tx,
 	tx_post_resync_params(sq, priv_tx, info.rcd_sn);
 
 	for (i = 0; i < info.nr_frags; i++)
-		if (tx_post_resync_dump(sq, info.frags[i], priv_tx->tisn, !i))
+		if (tx_post_resync_dump(sq, &info.frags[i], priv_tx->tisn, !i))
 			goto err_out;
 
 	/* If no dump WQE was sent, we need to have a fence NOP WQE before the
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [net 07/15] net/mlx5e: kTLS, Fix page refcnt leak in TX resync error flow
  2019-10-18 19:37 [pull request][net 00/15] Mellanox, mlx5 kTLS fixes 18-10-2019 Saeed Mahameed
                   ` (5 preceding siblings ...)
  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 ` Saeed Mahameed
  2019-10-18 19:38 ` [net 08/15] net/mlx5e: kTLS, Fix missing SQ edge fill Saeed Mahameed
                   ` (8 subsequent siblings)
  15 siblings, 0 replies; 27+ messages in thread
From: Saeed Mahameed @ 2019-10-18 19:38 UTC (permalink / raw)
  To: David S. Miller; +Cc: netdev, Tariq Toukan, Eran Ben Elisha, Saeed Mahameed

From: Tariq Toukan <tariqt@mellanox.com>

All references for frag pages that are obtained in tx_sync_info_get()
should be released.
Release usually occurs in the corresponding CQE of the WQE.
In error flows, not all fragments have a WQE posted for them, hence
no matching CQE will be generated.
For these pages, release the reference in the error flow.

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_tx.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

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 334808b1863b..5f1d18fb644e 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
@@ -329,7 +329,7 @@ mlx5e_ktls_tx_handle_ooo(struct mlx5e_ktls_offload_context_tx *priv_tx,
 	struct tx_sync_info info = {};
 	u16 contig_wqebbs_room, pi;
 	u8 num_wqebbs;
-	int i;
+	int i = 0;
 
 	if (!tx_sync_info_get(priv_tx, seq, &info)) {
 		/* We might get here if a retransmission reaches the driver
@@ -364,7 +364,7 @@ mlx5e_ktls_tx_handle_ooo(struct mlx5e_ktls_offload_context_tx *priv_tx,
 
 	tx_post_resync_params(sq, priv_tx, info.rcd_sn);
 
-	for (i = 0; i < info.nr_frags; i++)
+	for (; i < info.nr_frags; i++)
 		if (tx_post_resync_dump(sq, &info.frags[i], priv_tx->tisn, !i))
 			goto err_out;
 
@@ -377,6 +377,9 @@ mlx5e_ktls_tx_handle_ooo(struct mlx5e_ktls_offload_context_tx *priv_tx,
 	return skb;
 
 err_out:
+	for (; i < info.nr_frags; i++)
+		put_page(skb_frag_page(&info.frags[i]));
+
 	dev_kfree_skb_any(skb);
 	return NULL;
 }
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [net 08/15] net/mlx5e: kTLS, Fix missing SQ edge fill
  2019-10-18 19:37 [pull request][net 00/15] Mellanox, mlx5 kTLS fixes 18-10-2019 Saeed Mahameed
                   ` (6 preceding siblings ...)
  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 ` Saeed Mahameed
  2019-10-18 19:38 ` [net 09/15] net/mlx5e: kTLS, Limit DUMP wqe size Saeed Mahameed
                   ` (7 subsequent siblings)
  15 siblings, 0 replies; 27+ messages in thread
From: Saeed Mahameed @ 2019-10-18 19:38 UTC (permalink / raw)
  To: David S. Miller; +Cc: netdev, Tariq Toukan, Eran Ben Elisha, Saeed Mahameed

From: Tariq Toukan <tariqt@mellanox.com>

Before posting the context params WQEs, make sure there is enough
contiguous room for them, and fill frag edge if needed.

When posting only a nop, no need for room check, as it needs a single
WQEBB, meaning no contiguity issue.

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>
---
 .../mellanox/mlx5/core/en_accel/ktls_tx.c     | 28 +++++++++++++------
 1 file changed, 20 insertions(+), 8 deletions(-)

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 5f1d18fb644e..59e3f48470d9 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
@@ -168,6 +168,14 @@ mlx5e_ktls_tx_post_param_wqes(struct mlx5e_txqsq *sq,
 			      bool skip_static_post, bool fence_first_post)
 {
 	bool progress_fence = skip_static_post || !fence_first_post;
+	struct mlx5_wq_cyc *wq = &sq->wq;
+	u16 contig_wqebbs_room, pi;
+
+	pi = mlx5_wq_cyc_ctr2ix(wq, sq->pc);
+	contig_wqebbs_room = mlx5_wq_cyc_get_contig_wqebbs(wq, pi);
+	if (unlikely(contig_wqebbs_room <
+		     MLX5E_KTLS_STATIC_WQEBBS + MLX5E_KTLS_PROGRESS_WQEBBS))
+		mlx5e_fill_sq_frag_edge(sq, wq, pi, contig_wqebbs_room);
 
 	if (!skip_static_post)
 		post_static_params(sq, priv_tx, fence_first_post);
@@ -355,10 +363,20 @@ mlx5e_ktls_tx_handle_ooo(struct mlx5e_ktls_offload_context_tx *priv_tx,
 
 	stats->tls_ooo++;
 
-	num_wqebbs = MLX5E_KTLS_STATIC_WQEBBS + MLX5E_KTLS_PROGRESS_WQEBBS +
-		(info.nr_frags ? info.nr_frags * MLX5E_KTLS_DUMP_WQEBBS : 1);
+	tx_post_resync_params(sq, priv_tx, info.rcd_sn);
+
+	/* If no dump WQE was sent, we need to have a fence NOP WQE before the
+	 * actual data xmit.
+	 */
+	if (!info.nr_frags) {
+		tx_post_fence_nop(sq);
+		return skb;
+	}
+
+	num_wqebbs = info.nr_frags * MLX5E_KTLS_DUMP_WQEBBS;
 	pi = mlx5_wq_cyc_ctr2ix(wq, sq->pc);
 	contig_wqebbs_room = mlx5_wq_cyc_get_contig_wqebbs(wq, pi);
+
 	if (unlikely(contig_wqebbs_room < num_wqebbs))
 		mlx5e_fill_sq_frag_edge(sq, wq, pi, contig_wqebbs_room);
 
@@ -368,12 +386,6 @@ mlx5e_ktls_tx_handle_ooo(struct mlx5e_ktls_offload_context_tx *priv_tx,
 		if (tx_post_resync_dump(sq, &info.frags[i], priv_tx->tisn, !i))
 			goto err_out;
 
-	/* If no dump WQE was sent, we need to have a fence NOP WQE before the
-	 * actual data xmit.
-	 */
-	if (!info.nr_frags)
-		tx_post_fence_nop(sq);
-
 	return skb;
 
 err_out:
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [net 09/15] net/mlx5e: kTLS, Limit DUMP wqe size
  2019-10-18 19:37 [pull request][net 00/15] Mellanox, mlx5 kTLS fixes 18-10-2019 Saeed Mahameed
                   ` (7 preceding siblings ...)
  2019-10-18 19:38 ` [net 08/15] net/mlx5e: kTLS, Fix missing SQ edge fill Saeed Mahameed
@ 2019-10-18 19:38 ` Saeed Mahameed
  2019-10-18 19:38 ` [net 10/15] net/mlx5e: kTLS, Remove unneeded cipher type checks Saeed Mahameed
                   ` (6 subsequent siblings)
  15 siblings, 0 replies; 27+ messages in thread
From: Saeed Mahameed @ 2019-10-18 19:38 UTC (permalink / raw)
  To: David S. Miller; +Cc: netdev, Tariq Toukan, Eran Ben Elisha, Saeed Mahameed

From: Tariq Toukan <tariqt@mellanox.com>

HW expects the data size in DUMP WQEs to be up to MTU.
Make sure they are in range.

We elevate the frag page refcount by 'n-1', in addition to the
one obtained in tx_sync_info_get(), having an overall of 'n'
references. We bulk increments by using a single page_ref_add()
command, to optimize perfermance.
The refcounts are released one by one, by the corresponding completions.

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.h  |  1 +
 .../net/ethernet/mellanox/mlx5/core/en/txrx.h | 11 +++---
 .../mellanox/mlx5/core/en_accel/ktls.h        | 11 +++++-
 .../mellanox/mlx5/core/en_accel/ktls_tx.c     | 34 ++++++++++++++++---
 .../net/ethernet/mellanox/mlx5/core/en_main.c |  7 +++-
 5 files changed, 52 insertions(+), 12 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en.h b/drivers/net/ethernet/mellanox/mlx5/core/en.h
index cb6f7b87e38f..f1a7bc46f1c0 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en.h
@@ -410,6 +410,7 @@ struct mlx5e_txqsq {
 	struct device             *pdev;
 	__be32                     mkey_be;
 	unsigned long              state;
+	unsigned int               hw_mtu;
 	struct hwtstamp_config    *tstamp;
 	struct mlx5_clock         *clock;
 
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/txrx.h b/drivers/net/ethernet/mellanox/mlx5/core/en/txrx.h
index 25f9dda578ac..7c8796d9743f 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en/txrx.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en/txrx.h
@@ -15,15 +15,14 @@
 #else
 /* TLS offload requires additional stop_room for:
  *  - a resync SKB.
- * kTLS offload requires additional stop_room for:
- * - static params WQE,
- * - progress params WQE, and
- * - resync DUMP per frag.
+ * kTLS offload requires fixed additional stop_room for:
+ * - a static params WQE, and a progress params WQE.
+ * The additional MTU-depending room for the resync DUMP WQEs
+ * will be calculated and added in runtime.
  */
 #define MLX5E_SQ_TLS_ROOM  \
 	(MLX5_SEND_WQE_MAX_WQEBBS + \
-	 MLX5E_KTLS_STATIC_WQEBBS + MLX5E_KTLS_PROGRESS_WQEBBS + \
-	 MAX_SKB_FRAGS * MLX5E_KTLS_DUMP_WQEBBS)
+	 MLX5E_KTLS_STATIC_WQEBBS + MLX5E_KTLS_PROGRESS_WQEBBS)
 #endif
 
 #define INL_HDR_START_SZ (sizeof(((struct mlx5_wqe_eth_seg *)NULL)->inline_hdr.start))
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 eb692feba4a6..929966e6fbc4 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls.h
@@ -94,7 +94,16 @@ struct sk_buff *mlx5e_ktls_handle_tx_skb(struct net_device *netdev,
 void mlx5e_ktls_tx_handle_resync_dump_comp(struct mlx5e_txqsq *sq,
 					   struct mlx5e_tx_wqe_info *wi,
 					   u32 *dma_fifo_cc);
-
+static inline u8
+mlx5e_ktls_dumps_num_wqebbs(struct mlx5e_txqsq *sq, unsigned int nfrags,
+			    unsigned int sync_len)
+{
+	/* Given the MTU and sync_len, calculates an upper bound for the
+	 * number of WQEBBs needed for the TX resync DUMP WQEs of a record.
+	 */
+	return MLX5E_KTLS_DUMP_WQEBBS *
+		(nfrags + DIV_ROUND_UP(sync_len, sq->hw_mtu));
+}
 #else
 
 static inline void mlx5e_ktls_build_netdev(struct mlx5e_priv *priv)
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 59e3f48470d9..e10b0bb696da 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
@@ -373,7 +373,7 @@ mlx5e_ktls_tx_handle_ooo(struct mlx5e_ktls_offload_context_tx *priv_tx,
 		return skb;
 	}
 
-	num_wqebbs = info.nr_frags * MLX5E_KTLS_DUMP_WQEBBS;
+	num_wqebbs = mlx5e_ktls_dumps_num_wqebbs(sq, info.nr_frags, info.sync_len);
 	pi = mlx5_wq_cyc_ctr2ix(wq, sq->pc);
 	contig_wqebbs_room = mlx5_wq_cyc_get_contig_wqebbs(wq, pi);
 
@@ -382,14 +382,40 @@ mlx5e_ktls_tx_handle_ooo(struct mlx5e_ktls_offload_context_tx *priv_tx,
 
 	tx_post_resync_params(sq, priv_tx, info.rcd_sn);
 
-	for (; i < info.nr_frags; i++)
-		if (tx_post_resync_dump(sq, &info.frags[i], priv_tx->tisn, !i))
-			goto err_out;
+	for (; i < info.nr_frags; i++) {
+		unsigned int orig_fsz, frag_offset = 0, n = 0;
+		skb_frag_t *f = &info.frags[i];
+
+		orig_fsz = skb_frag_size(f);
+
+		do {
+			bool fence = !(i || frag_offset);
+			unsigned int fsz;
+
+			n++;
+			fsz = min_t(unsigned int, sq->hw_mtu, orig_fsz - frag_offset);
+			skb_frag_size_set(f, fsz);
+			if (tx_post_resync_dump(sq, f, priv_tx->tisn, fence)) {
+				page_ref_add(skb_frag_page(f), n - 1);
+				goto err_out;
+			}
+
+			skb_frag_off_add(f, fsz);
+			frag_offset += fsz;
+		} while (frag_offset < orig_fsz);
+
+		page_ref_add(skb_frag_page(f), n - 1);
+	}
 
 	return skb;
 
 err_out:
 	for (; i < info.nr_frags; i++)
+		/* The put_page() here undoes the page ref obtained in tx_sync_info_get().
+		 * Page refs obtained for the DUMP WQEs above (by page_ref_add) will be
+		 * released only upon their completions (or in mlx5e_free_txqsq_descs,
+		 * if channel closes).
+		 */
 		put_page(skb_frag_page(&info.frags[i]));
 
 	dev_kfree_skb_any(skb);
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
index b476b007f093..772bfdbdeb9c 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
@@ -1128,6 +1128,7 @@ static int mlx5e_alloc_txqsq(struct mlx5e_channel *c,
 	sq->txq_ix    = txq_ix;
 	sq->uar_map   = mdev->mlx5e_res.bfreg.map;
 	sq->min_inline_mode = params->tx_min_inline_mode;
+	sq->hw_mtu    = MLX5E_SW2HW_MTU(params, params->sw_mtu);
 	sq->stats     = &c->priv->channel_stats[c->ix].sq[tc];
 	sq->stop_room = MLX5E_SQ_STOP_ROOM;
 	INIT_WORK(&sq->recover_work, mlx5e_tx_err_cqe_work);
@@ -1135,10 +1136,14 @@ static int mlx5e_alloc_txqsq(struct mlx5e_channel *c,
 		set_bit(MLX5E_SQ_STATE_VLAN_NEED_L2_INLINE, &sq->state);
 	if (MLX5_IPSEC_DEV(c->priv->mdev))
 		set_bit(MLX5E_SQ_STATE_IPSEC, &sq->state);
+#ifdef CONFIG_MLX5_EN_TLS
 	if (mlx5_accel_is_tls_device(c->priv->mdev)) {
 		set_bit(MLX5E_SQ_STATE_TLS, &sq->state);
-		sq->stop_room += MLX5E_SQ_TLS_ROOM;
+		sq->stop_room += MLX5E_SQ_TLS_ROOM +
+			mlx5e_ktls_dumps_num_wqebbs(sq, MAX_SKB_FRAGS,
+						    TLS_MAX_PAYLOAD_SIZE);
 	}
+#endif
 
 	param->wq.db_numa_node = cpu_to_node(c->cpu);
 	err = mlx5_wq_cyc_create(mdev, &param->wq, sqc_wq, wq, &sq->wq_ctrl);
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [net 10/15] net/mlx5e: kTLS, Remove unneeded cipher type checks
  2019-10-18 19:37 [pull request][net 00/15] Mellanox, mlx5 kTLS fixes 18-10-2019 Saeed Mahameed
                   ` (8 preceding siblings ...)
  2019-10-18 19:38 ` [net 09/15] net/mlx5e: kTLS, Limit DUMP wqe size Saeed Mahameed
@ 2019-10-18 19:38 ` Saeed Mahameed
  2019-10-18 23:13   ` Jakub Kicinski
  2019-10-18 19:38 ` [net 11/15] net/mlx5e: kTLS, Save a copy of the crypto info Saeed Mahameed
                   ` (5 subsequent siblings)
  15 siblings, 1 reply; 27+ messages in thread
From: Saeed Mahameed @ 2019-10-18 19:38 UTC (permalink / raw)
  To: David S. Miller; +Cc: netdev, Tariq Toukan, Eran Ben Elisha, Saeed Mahameed

From: Tariq Toukan <tariqt@mellanox.com>

Cipher type is checked upon connection addition.
No need to recheck it per every TX resync invocation.

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_tx.c | 6 ------
 1 file changed, 6 deletions(-)

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 e10b0bb696da..1bfeb558ff78 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
@@ -31,9 +31,6 @@ fill_static_params_ctx(void *ctx, struct mlx5e_ktls_offload_context_tx *priv_tx)
 	char *salt, *rec_seq;
 	u8 tls_version;
 
-	if (WARN_ON(crypto_info->cipher_type != TLS_CIPHER_AES_GCM_128))
-		return;
-
 	info = (struct tls12_crypto_info_aes_gcm_128 *)crypto_info;
 	EXTRACT_INFO_FIELDS;
 
@@ -243,9 +240,6 @@ tx_post_resync_params(struct mlx5e_txqsq *sq,
 	u16 rec_seq_sz;
 	char *rec_seq;
 
-	if (WARN_ON(crypto_info->cipher_type != TLS_CIPHER_AES_GCM_128))
-		return;
-
 	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


^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [net 11/15] net/mlx5e: kTLS, Save a copy of the crypto info
  2019-10-18 19:37 [pull request][net 00/15] Mellanox, mlx5 kTLS fixes 18-10-2019 Saeed Mahameed
                   ` (9 preceding siblings ...)
  2019-10-18 19:38 ` [net 10/15] net/mlx5e: kTLS, Remove unneeded cipher type checks Saeed Mahameed
@ 2019-10-18 19:38 ` Saeed Mahameed
  2019-10-18 23:16   ` Jakub Kicinski
  2019-10-18 19:38 ` [net 12/15] net/mlx5e: kTLS, Enhance TX resync flow Saeed Mahameed
                   ` (4 subsequent siblings)
  15 siblings, 1 reply; 27+ messages in thread
From: Saeed Mahameed @ 2019-10-18 19:38 UTC (permalink / raw)
  To: David S. Miller; +Cc: netdev, Tariq Toukan, Eran Ben Elisha, Saeed Mahameed

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


^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [net 12/15] net/mlx5e: kTLS, Enhance TX resync flow
  2019-10-18 19:37 [pull request][net 00/15] Mellanox, mlx5 kTLS fixes 18-10-2019 Saeed Mahameed
                   ` (10 preceding siblings ...)
  2019-10-18 19:38 ` [net 11/15] net/mlx5e: kTLS, Save a copy of the crypto info Saeed Mahameed
@ 2019-10-18 19:38 ` Saeed Mahameed
  2019-10-19  1:51   ` Jakub Kicinski
  2019-10-18 19:38 ` [net 13/15] net/mlx5e: TX, Fix consumer index of error cqe dump Saeed Mahameed
                   ` (3 subsequent siblings)
  15 siblings, 1 reply; 27+ messages in thread
From: Saeed Mahameed @ 2019-10-18 19:38 UTC (permalink / raw)
  To: David S. Miller; +Cc: netdev, Tariq Toukan, Saeed Mahameed

From: Tariq Toukan <tariqt@mellanox.com>

Once the kTLS TX resync function is called, it used to return
a binary value, for success or failure.

However, in case the TLS SKB is a retransmission of the connection
handshake, it initiates the resync flow (as the tcp seq check holds),
while regular packet handle is expected.

In this patch, we identify this case and skip the resync operation
accordingly.

Counters:
- Add a counter (tls_skip_no_sync_data) to monitor this.
- Bump the dump counters up as they are used more frequently.
- Add a missing counter descriptor declaration for tls_resync_bytes
  in sq_stats_desc.

Fixes: d2ead1f360e8 ("net/mlx5e: Add kTLS TX HW offload support")
Signed-off-by: Tariq Toukan <tariqt@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
---
 .../mellanox/mlx5/core/en_accel/ktls_tx.c     | 58 +++++++++++--------
 .../ethernet/mellanox/mlx5/core/en_stats.c    | 16 +++--
 .../ethernet/mellanox/mlx5/core/en_stats.h    | 10 ++--
 3 files changed, 51 insertions(+), 33 deletions(-)

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 badc6fd26a14..778dab1af8fc 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
@@ -185,26 +185,33 @@ struct tx_sync_info {
 	skb_frag_t frags[MAX_SKB_FRAGS];
 };
 
-static bool tx_sync_info_get(struct mlx5e_ktls_offload_context_tx *priv_tx,
-			     u32 tcp_seq, struct tx_sync_info *info)
+enum mlx5e_ktls_sync_retval {
+	MLX5E_KTLS_SYNC_DONE,
+	MLX5E_KTLS_SYNC_FAIL,
+	MLX5E_KTLS_SYNC_SKIP_NO_DATA,
+};
+
+static enum mlx5e_ktls_sync_retval
+tx_sync_info_get(struct mlx5e_ktls_offload_context_tx *priv_tx,
+		 u32 tcp_seq, struct tx_sync_info *info)
 {
 	struct tls_offload_context_tx *tx_ctx = priv_tx->tx_ctx;
+	enum mlx5e_ktls_sync_retval ret = MLX5E_KTLS_SYNC_DONE;
 	struct tls_record_info *record;
 	int remaining, i = 0;
 	unsigned long flags;
-	bool ret = true;
 
 	spin_lock_irqsave(&tx_ctx->lock, flags);
 	record = tls_get_record(tx_ctx, tcp_seq, &info->rcd_sn);
 
 	if (unlikely(!record)) {
-		ret = false;
+		ret = MLX5E_KTLS_SYNC_FAIL;
 		goto out;
 	}
 
 	if (unlikely(tcp_seq < tls_record_start_seq(record))) {
-		if (!tls_record_is_start_marker(record))
-			ret = false;
+		ret = tls_record_is_start_marker(record) ?
+			MLX5E_KTLS_SYNC_SKIP_NO_DATA : MLX5E_KTLS_SYNC_FAIL;
 		goto out;
 	}
 
@@ -316,20 +323,26 @@ static void tx_post_fence_nop(struct mlx5e_txqsq *sq)
 	mlx5e_post_nop_fence(wq, sq->sqn, &sq->pc);
 }
 
-static struct sk_buff *
+static enum mlx5e_ktls_sync_retval
 mlx5e_ktls_tx_handle_ooo(struct mlx5e_ktls_offload_context_tx *priv_tx,
 			 struct mlx5e_txqsq *sq,
-			 struct sk_buff *skb,
+			 int datalen,
 			 u32 seq)
 {
 	struct mlx5e_sq_stats *stats = sq->stats;
 	struct mlx5_wq_cyc *wq = &sq->wq;
+	enum mlx5e_ktls_sync_retval ret;
 	struct tx_sync_info info = {};
 	u16 contig_wqebbs_room, pi;
 	u8 num_wqebbs;
 	int i = 0;
 
-	if (!tx_sync_info_get(priv_tx, seq, &info)) {
+	ret = tx_sync_info_get(priv_tx, seq, &info);
+	if (unlikely(ret != MLX5E_KTLS_SYNC_DONE)) {
+		if (ret == MLX5E_KTLS_SYNC_SKIP_NO_DATA) {
+			stats->tls_skip_no_sync_data++;
+			return MLX5E_KTLS_SYNC_SKIP_NO_DATA;
+		}
 		/* We might get here if a retransmission reaches the driver
 		 * after the relevant record is acked.
 		 * It should be safe to drop the packet in this case
@@ -339,13 +352,8 @@ mlx5e_ktls_tx_handle_ooo(struct mlx5e_ktls_offload_context_tx *priv_tx,
 	}
 
 	if (unlikely(info.sync_len < 0)) {
-		u32 payload;
-		int headln;
-
-		headln = skb_transport_offset(skb) + tcp_hdrlen(skb);
-		payload = skb->len - headln;
-		if (likely(payload <= -info.sync_len))
-			return skb;
+		if (likely(datalen <= -info.sync_len))
+			return MLX5E_KTLS_SYNC_DONE;
 
 		stats->tls_drop_bypass_req++;
 		goto err_out;
@@ -360,7 +368,7 @@ mlx5e_ktls_tx_handle_ooo(struct mlx5e_ktls_offload_context_tx *priv_tx,
 	 */
 	if (!info.nr_frags) {
 		tx_post_fence_nop(sq);
-		return skb;
+		return MLX5E_KTLS_SYNC_DONE;
 	}
 
 	num_wqebbs = mlx5e_ktls_dumps_num_wqebbs(sq, info.nr_frags, info.sync_len);
@@ -397,7 +405,7 @@ mlx5e_ktls_tx_handle_ooo(struct mlx5e_ktls_offload_context_tx *priv_tx,
 		page_ref_add(skb_frag_page(f), n - 1);
 	}
 
-	return skb;
+	return MLX5E_KTLS_SYNC_DONE;
 
 err_out:
 	for (; i < info.nr_frags; i++)
@@ -408,8 +416,7 @@ mlx5e_ktls_tx_handle_ooo(struct mlx5e_ktls_offload_context_tx *priv_tx,
 		 */
 		put_page(skb_frag_page(&info.frags[i]));
 
-	dev_kfree_skb_any(skb);
-	return NULL;
+	return MLX5E_KTLS_SYNC_FAIL;
 }
 
 struct sk_buff *mlx5e_ktls_handle_tx_skb(struct net_device *netdev,
@@ -445,10 +452,15 @@ struct sk_buff *mlx5e_ktls_handle_tx_skb(struct net_device *netdev,
 
 	seq = ntohl(tcp_hdr(skb)->seq);
 	if (unlikely(priv_tx->expected_seq != seq)) {
-		skb = mlx5e_ktls_tx_handle_ooo(priv_tx, sq, skb, seq);
-		if (unlikely(!skb))
+		enum mlx5e_ktls_sync_retval ret =
+			mlx5e_ktls_tx_handle_ooo(priv_tx, sq, datalen, seq);
+
+		if (likely(ret == MLX5E_KTLS_SYNC_DONE))
+			*wqe = mlx5e_sq_fetch_wqe(sq, sizeof(**wqe), pi);
+		else if (ret == MLX5E_KTLS_SYNC_FAIL)
+			goto err_out;
+		else /* ret == MLX5E_KTLS_SYNC_SKIP_NO_DATA */
 			goto out;
-		*wqe = mlx5e_sq_fetch_wqe(sq, sizeof(**wqe), pi);
 	}
 
 	priv_tx->expected_seq = seq + datalen;
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_stats.c b/drivers/net/ethernet/mellanox/mlx5/core/en_stats.c
index ac6fdcda7019..7e6ebd0505cc 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_stats.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_stats.c
@@ -52,11 +52,12 @@ static const struct counter_desc sw_stats_desc[] = {
 	{ MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_tls_encrypted_bytes) },
 	{ MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_tls_ctx) },
 	{ MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_tls_ooo) },
+	{ MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_tls_dump_packets) },
+	{ MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_tls_dump_bytes) },
 	{ MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_tls_resync_bytes) },
+	{ MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_tls_skip_no_sync_data) },
 	{ MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_tls_drop_no_sync_data) },
 	{ MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_tls_drop_bypass_req) },
-	{ MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_tls_dump_packets) },
-	{ MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_tls_dump_bytes) },
 #endif
 
 	{ MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_lro_packets) },
@@ -288,11 +289,12 @@ static void mlx5e_grp_sw_update_stats(struct mlx5e_priv *priv)
 			s->tx_tls_encrypted_bytes   += sq_stats->tls_encrypted_bytes;
 			s->tx_tls_ctx               += sq_stats->tls_ctx;
 			s->tx_tls_ooo               += sq_stats->tls_ooo;
+			s->tx_tls_dump_bytes        += sq_stats->tls_dump_bytes;
+			s->tx_tls_dump_packets      += sq_stats->tls_dump_packets;
 			s->tx_tls_resync_bytes      += sq_stats->tls_resync_bytes;
+			s->tx_tls_skip_no_sync_data += sq_stats->tls_skip_no_sync_data;
 			s->tx_tls_drop_no_sync_data += sq_stats->tls_drop_no_sync_data;
 			s->tx_tls_drop_bypass_req   += sq_stats->tls_drop_bypass_req;
-			s->tx_tls_dump_bytes        += sq_stats->tls_dump_bytes;
-			s->tx_tls_dump_packets      += sq_stats->tls_dump_packets;
 #endif
 			s->tx_cqes		+= sq_stats->cqes;
 		}
@@ -1472,10 +1474,12 @@ static const struct counter_desc sq_stats_desc[] = {
 	{ MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, tls_encrypted_bytes) },
 	{ MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, tls_ctx) },
 	{ MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, tls_ooo) },
-	{ MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, tls_drop_no_sync_data) },
-	{ MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, tls_drop_bypass_req) },
 	{ MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, tls_dump_packets) },
 	{ MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, tls_dump_bytes) },
+	{ MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, tls_resync_bytes) },
+	{ MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, tls_skip_no_sync_data) },
+	{ MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, tls_drop_no_sync_data) },
+	{ MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, tls_drop_bypass_req) },
 #endif
 	{ MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, csum_none) },
 	{ MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, stopped) },
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_stats.h b/drivers/net/ethernet/mellanox/mlx5/core/en_stats.h
index 79f261bf86ac..869f3502f631 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_stats.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_stats.h
@@ -129,11 +129,12 @@ struct mlx5e_sw_stats {
 	u64 tx_tls_encrypted_bytes;
 	u64 tx_tls_ctx;
 	u64 tx_tls_ooo;
+	u64 tx_tls_dump_packets;
+	u64 tx_tls_dump_bytes;
 	u64 tx_tls_resync_bytes;
+	u64 tx_tls_skip_no_sync_data;
 	u64 tx_tls_drop_no_sync_data;
 	u64 tx_tls_drop_bypass_req;
-	u64 tx_tls_dump_packets;
-	u64 tx_tls_dump_bytes;
 #endif
 
 	u64 rx_xsk_packets;
@@ -273,11 +274,12 @@ struct mlx5e_sq_stats {
 	u64 tls_encrypted_bytes;
 	u64 tls_ctx;
 	u64 tls_ooo;
+	u64 tls_dump_packets;
+	u64 tls_dump_bytes;
 	u64 tls_resync_bytes;
+	u64 tls_skip_no_sync_data;
 	u64 tls_drop_no_sync_data;
 	u64 tls_drop_bypass_req;
-	u64 tls_dump_packets;
-	u64 tls_dump_bytes;
 #endif
 	/* less likely accessed in data path */
 	u64 csum_none;
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [net 13/15] net/mlx5e: TX, Fix consumer index of error cqe dump
  2019-10-18 19:37 [pull request][net 00/15] Mellanox, mlx5 kTLS fixes 18-10-2019 Saeed Mahameed
                   ` (11 preceding siblings ...)
  2019-10-18 19:38 ` [net 12/15] net/mlx5e: kTLS, Enhance TX resync flow Saeed Mahameed
@ 2019-10-18 19:38 ` Saeed Mahameed
  2019-10-18 19:38 ` [net 14/15] net/mlx5: prevent memory leak in mlx5_fpga_conn_create_cq Saeed Mahameed
                   ` (2 subsequent siblings)
  15 siblings, 0 replies; 27+ messages in thread
From: Saeed Mahameed @ 2019-10-18 19:38 UTC (permalink / raw)
  To: David S. Miller; +Cc: netdev, Tariq Toukan, Saeed Mahameed

From: Tariq Toukan <tariqt@mellanox.com>

The completion queue consumer index increments upon a call to
mlx5_cqwq_pop().
When dumping an error CQE, the index is already incremented.
Decrease one for the print command.

Fixes: 16cc14d81733 ("net/mlx5e: Dump xmit error completions")
Signed-off-by: Tariq Toukan <tariqt@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
---
 drivers/net/ethernet/mellanox/mlx5/core/en_tx.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c
index 8dd8f0be101b..67dc4f0921b6 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c
@@ -403,7 +403,10 @@ netdev_tx_t mlx5e_xmit(struct sk_buff *skb, struct net_device *dev)
 static void mlx5e_dump_error_cqe(struct mlx5e_txqsq *sq,
 				 struct mlx5_err_cqe *err_cqe)
 {
-	u32 ci = mlx5_cqwq_get_ci(&sq->cq.wq);
+	struct mlx5_cqwq *wq = &sq->cq.wq;
+	u32 ci;
+
+	ci = mlx5_cqwq_ctr2ix(wq, wq->cc - 1);
 
 	netdev_err(sq->channel->netdev,
 		   "Error cqe on cqn 0x%x, ci 0x%x, sqn 0x%x, opcode 0x%x, syndrome 0x%x, vendor syndrome 0x%x\n",
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [net 14/15] net/mlx5: prevent memory leak in mlx5_fpga_conn_create_cq
  2019-10-18 19:37 [pull request][net 00/15] Mellanox, mlx5 kTLS fixes 18-10-2019 Saeed Mahameed
                   ` (12 preceding siblings ...)
  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 ` 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
  15 siblings, 0 replies; 27+ messages in thread
From: Saeed Mahameed @ 2019-10-18 19:38 UTC (permalink / raw)
  To: David S. Miller; +Cc: netdev, Navid Emamdoost, Saeed Mahameed

From: Navid Emamdoost <navid.emamdoost@gmail.com>

In mlx5_fpga_conn_create_cq if mlx5_vector2eqn fails the allocated
memory should be released.

Fixes: 537a50574175 ("net/mlx5: FPGA, Add high-speed connection routines")
Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
---
 drivers/net/ethernet/mellanox/mlx5/core/fpga/conn.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fpga/conn.c b/drivers/net/ethernet/mellanox/mlx5/core/fpga/conn.c
index 4c50efe4e7f1..61021133029e 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/fpga/conn.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/fpga/conn.c
@@ -464,8 +464,10 @@ static int mlx5_fpga_conn_create_cq(struct mlx5_fpga_conn *conn, int cq_size)
 	}
 
 	err = mlx5_vector2eqn(mdev, smp_processor_id(), &eqn, &irqn);
-	if (err)
+	if (err) {
+		kvfree(in);
 		goto err_cqwq;
+	}
 
 	cqc = MLX5_ADDR_OF(create_cq_in, in, cq_context);
 	MLX5_SET(cqc, cqc, log_cq_size, ilog2(cq_size));
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [net 15/15] net/mlx5: fix memory leak in mlx5_fw_fatal_reporter_dump
  2019-10-18 19:37 [pull request][net 00/15] Mellanox, mlx5 kTLS fixes 18-10-2019 Saeed Mahameed
                   ` (13 preceding siblings ...)
  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 ` Saeed Mahameed
  2019-10-21 16:19 ` [pull request][net 00/15] Mellanox, mlx5 kTLS fixes 18-10-2019 David Miller
  15 siblings, 0 replies; 27+ messages in thread
From: Saeed Mahameed @ 2019-10-18 19:38 UTC (permalink / raw)
  To: David S. Miller; +Cc: netdev, Navid Emamdoost, Saeed Mahameed

From: Navid Emamdoost <navid.emamdoost@gmail.com>

In mlx5_fw_fatal_reporter_dump if mlx5_crdump_collect fails the
allocated memory for cr_data must be released otherwise there will be
memory leak. To fix this, this commit changes the return instruction
into goto error handling.

Fixes: 9b1f29823605 ("net/mlx5: Add support for FW fatal reporter dump")
Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
---
 drivers/net/ethernet/mellanox/mlx5/core/health.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/health.c b/drivers/net/ethernet/mellanox/mlx5/core/health.c
index d685122d9ff7..c07f3154437c 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/health.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/health.c
@@ -572,7 +572,7 @@ mlx5_fw_fatal_reporter_dump(struct devlink_health_reporter *reporter,
 		return -ENOMEM;
 	err = mlx5_crdump_collect(dev, cr_data);
 	if (err)
-		return err;
+		goto free_data;
 
 	if (priv_ctx) {
 		struct mlx5_fw_reporter_ctx *fw_reporter_ctx = priv_ctx;
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 27+ messages in thread

* Re: [net 04/15] net/mlx5e: kTLS, Size of a Dump WQE is fixed
  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
  0 siblings, 1 reply; 27+ messages in thread
From: Jakub Kicinski @ 2019-10-18 23:13 UTC (permalink / raw)
  To: Saeed Mahameed; +Cc: David S. Miller, netdev, Tariq Toukan, Eran Ben Elisha

On Fri, 18 Oct 2019 19:38:09 +0000, Saeed Mahameed wrote:
> From: Tariq Toukan <tariqt@mellanox.com>
> 
> No Eth segment, so no dynamic inline headers.
> The size of a Dump WQE is fixed, use constants and remove
> unnecessary checks.
> 
> 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>

Is this a fix?

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [net 10/15] net/mlx5e: kTLS, Remove unneeded cipher type checks
  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
  0 siblings, 0 replies; 27+ messages in thread
From: Jakub Kicinski @ 2019-10-18 23:13 UTC (permalink / raw)
  To: Saeed Mahameed; +Cc: David S. Miller, netdev, Tariq Toukan, Eran Ben Elisha

On Fri, 18 Oct 2019 19:38:20 +0000, Saeed Mahameed wrote:
> From: Tariq Toukan <tariqt@mellanox.com>
> 
> Cipher type is checked upon connection addition.
> No need to recheck it per every TX resync invocation.
> 
> 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>

Is this a fix?

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [net 11/15] net/mlx5e: kTLS, Save a copy of the crypto info
  2019-10-18 19:38 ` [net 11/15] net/mlx5e: kTLS, Save a copy of the crypto info Saeed Mahameed
@ 2019-10-18 23:16   ` Jakub Kicinski
  2019-10-20  7:46     ` Tariq Toukan
  0 siblings, 1 reply; 27+ messages in thread
From: Jakub Kicinski @ 2019-10-18 23:16 UTC (permalink / raw)
  To: Saeed Mahameed; +Cc: David S. Miller, netdev, Tariq Toukan, Eran Ben Elisha

On Fri, 18 Oct 2019 19:38:22 +0000, Saeed Mahameed wrote:
> 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.

It should be around as long as the driver knows about the socket, no?

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [net 12/15] net/mlx5e: kTLS, Enhance TX resync flow
  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
  0 siblings, 1 reply; 27+ messages in thread
From: Jakub Kicinski @ 2019-10-19  1:51 UTC (permalink / raw)
  To: Saeed Mahameed; +Cc: David S. Miller, netdev, Tariq Toukan

On Fri, 18 Oct 2019 19:38:24 +0000, Saeed Mahameed wrote:
> From: Tariq Toukan <tariqt@mellanox.com>
> 
> Once the kTLS TX resync function is called, it used to return
> a binary value, for success or failure.
> 
> However, in case the TLS SKB is a retransmission of the connection
> handshake, it initiates the resync flow (as the tcp seq check holds),
> while regular packet handle is expected.
> 
> In this patch, we identify this case and skip the resync operation
> accordingly.
> 
> Counters:
> - Add a counter (tls_skip_no_sync_data) to monitor this.
> - Bump the dump counters up as they are used more frequently.
> - Add a missing counter descriptor declaration for tls_resync_bytes
>   in sq_stats_desc.
> 
> Fixes: d2ead1f360e8 ("net/mlx5e: Add kTLS TX HW offload support")
> Signed-off-by: Tariq Toukan <tariqt@mellanox.com>
> Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>

Could you document the new counter in tls-offload.rst?

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [net 11/15] net/mlx5e: kTLS, Save a copy of the crypto info
  2019-10-18 23:16   ` Jakub Kicinski
@ 2019-10-20  7:46     ` Tariq Toukan
  2019-10-20 17:08       ` Jakub Kicinski
  0 siblings, 1 reply; 27+ messages in thread
From: Tariq Toukan @ 2019-10-20  7:46 UTC (permalink / raw)
  To: Jakub Kicinski, Saeed Mahameed
  Cc: David S. Miller, netdev, Tariq Toukan, Eran Ben Elisha



On 10/19/2019 2:16 AM, Jakub Kicinski wrote:
> On Fri, 18 Oct 2019 19:38:22 +0000, Saeed Mahameed wrote:
>> 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.
> 
> It should be around as long as the driver knows about the socket, no?
> 

The crypto info instance passed to the driver (as parameter in 
connection creation callback) might be modified/zeroed/reused, so the 
driver is expected to save its own copy, not just the pointer.

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [net 11/15] net/mlx5e: kTLS, Save a copy of the crypto info
  2019-10-20  7:46     ` Tariq Toukan
@ 2019-10-20 17:08       ` Jakub Kicinski
  0 siblings, 0 replies; 27+ messages in thread
From: Jakub Kicinski @ 2019-10-20 17:08 UTC (permalink / raw)
  To: Tariq Toukan; +Cc: Saeed Mahameed, David S. Miller, netdev, Eran Ben Elisha

On Sun, 20 Oct 2019 07:46:00 +0000, Tariq Toukan wrote:
> On 10/19/2019 2:16 AM, Jakub Kicinski wrote:
> > On Fri, 18 Oct 2019 19:38:22 +0000, Saeed Mahameed wrote:  
> >> 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.  
> > 
> > It should be around as long as the driver knows about the socket, no?
> 
> The crypto info instance passed to the driver (as parameter in 
> connection creation callback) might be modified/zeroed/reused, so the 
> driver is expected to save its own copy, not just the pointer.

Can you point to a code path where that happens today?

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [pull request][net 00/15] Mellanox, mlx5 kTLS fixes 18-10-2019
  2019-10-18 19:37 [pull request][net 00/15] Mellanox, mlx5 kTLS fixes 18-10-2019 Saeed Mahameed
                   ` (14 preceding siblings ...)
  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 ` David Miller
  15 siblings, 0 replies; 27+ messages in thread
From: David Miller @ 2019-10-21 16:19 UTC (permalink / raw)
  To: saeedm; +Cc: netdev

From: Saeed Mahameed <saeedm@mellanox.com>
Date: Fri, 18 Oct 2019 19:37:59 +0000

> This series introduces kTLS related fixes to mlx5 driver from Tariq,
> and two misc memory leak fixes form Navid Emamdoost.
> 
> Please pull and let me know if there is any problem.

Puleld.

> I would appreciate it if you queue up kTLS fixes from the list below to
> stable kernel v5.3 !
> 
> For -stable v4.13:
>   nett/mlx5: prevent memory leak in mlx5_fpga_conn_create_cq 
> 
> For -stable v5.3:
>   net/mlx5: fix memory leak in mlx5_fw_fatal_reporter_dump
>   net/mlx5e: Tx, Fix assumption of single WQEBB of NOP in cleanup flow
>   net/mlx5e: Tx, Zero-memset WQE info struct upon update
>   net/mlx5e: kTLS, Release reference on DUMPed fragments in shutdown flow
>   net/mlx5e: kTLS, Size of a Dump WQE is fixed
>   net/mlx5e: kTLS, Save only the frag page to release at completion
>   net/mlx5e: kTLS, Save by-value copy of the record frags
>   net/mlx5e: kTLS, Fix page refcnt leak in TX resync error flow
>   net/mlx5e: kTLS, Fix missing SQ edge fill
>   net/mlx5e: kTLS, Limit DUMP wqe size
>   net/mlx5e: kTLS, Remove unneeded cipher type checks
>   net/mlx5e: kTLS, Save a copy of the crypto info
>   net/mlx5e: kTLS, Enhance TX resync flow
>   net/mlx5e: TX, Fix consumer index of error cqe dump

Queued up.

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [net 04/15] net/mlx5e: kTLS, Size of a Dump WQE is fixed
  2019-10-18 23:13   ` Jakub Kicinski
@ 2019-10-22 18:06     ` Saeed Mahameed
  0 siblings, 0 replies; 27+ messages in thread
From: Saeed Mahameed @ 2019-10-22 18:06 UTC (permalink / raw)
  To: jakub.kicinski; +Cc: Eran Ben Elisha, davem, netdev, Tariq Toukan

On Fri, 2019-10-18 at 16:13 -0700, Jakub Kicinski wrote:
> On Fri, 18 Oct 2019 19:38:09 +0000, Saeed Mahameed wrote:
> > From: Tariq Toukan <tariqt@mellanox.com>
> > 
> > No Eth segment, so no dynamic inline headers.
> > The size of a Dump WQE is fixed, use constants and remove
> > unnecessary checks.
> > 
> > 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>
> 
> Is this a fix?


sort of, this patch fundamentally changes the way mlx5 treats kTLS TX
descriptors, to make downstream patches simpler and more correct.

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [net 12/15] net/mlx5e: kTLS, Enhance TX resync flow
  2019-10-19  1:51   ` Jakub Kicinski
@ 2019-10-22 18:10     ` Saeed Mahameed
  2019-10-22 18:42       ` Jakub Kicinski
  0 siblings, 1 reply; 27+ messages in thread
From: Saeed Mahameed @ 2019-10-22 18:10 UTC (permalink / raw)
  To: jakub.kicinski; +Cc: davem, netdev, Tariq Toukan

On Fri, 2019-10-18 at 18:51 -0700, Jakub Kicinski wrote:
> On Fri, 18 Oct 2019 19:38:24 +0000, Saeed Mahameed wrote:
> > From: Tariq Toukan <tariqt@mellanox.com>
> > 
> > Once the kTLS TX resync function is called, it used to return
> > a binary value, for success or failure.
> > 
> > However, in case the TLS SKB is a retransmission of the connection
> > handshake, it initiates the resync flow (as the tcp seq check
> > holds),
> > while regular packet handle is expected.
> > 
> > In this patch, we identify this case and skip the resync operation
> > accordingly.
> > 
> > Counters:
> > - Add a counter (tls_skip_no_sync_data) to monitor this.
> > - Bump the dump counters up as they are used more frequently.
> > - Add a missing counter descriptor declaration for tls_resync_bytes
> >   in sq_stats_desc.
> > 
> > Fixes: d2ead1f360e8 ("net/mlx5e: Add kTLS TX HW offload support")
> > Signed-off-by: Tariq Toukan <tariqt@mellanox.com>
> > Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
> 
> Could you document the new counter in tls-offload.rst?

Tariq already prepared the patch, do we want this in net or net-next ? 
most of our kTLS users are going to use 5.3/5.4 stable kernels, but i
am not sure this should go to net.. 

Thanks,
Saeed. 

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [net 12/15] net/mlx5e: kTLS, Enhance TX resync flow
  2019-10-22 18:10     ` Saeed Mahameed
@ 2019-10-22 18:42       ` Jakub Kicinski
  2019-10-22 18:52         ` Saeed Mahameed
  0 siblings, 1 reply; 27+ messages in thread
From: Jakub Kicinski @ 2019-10-22 18:42 UTC (permalink / raw)
  To: Saeed Mahameed; +Cc: davem, netdev, Tariq Toukan

On Tue, 22 Oct 2019 18:10:11 +0000, Saeed Mahameed wrote:
> On Fri, 2019-10-18 at 18:51 -0700, Jakub Kicinski wrote:
> > On Fri, 18 Oct 2019 19:38:24 +0000, Saeed Mahameed wrote:  
> > > From: Tariq Toukan <tariqt@mellanox.com>
> > > 
> > > Once the kTLS TX resync function is called, it used to return
> > > a binary value, for success or failure.
> > > 
> > > However, in case the TLS SKB is a retransmission of the connection
> > > handshake, it initiates the resync flow (as the tcp seq check
> > > holds),
> > > while regular packet handle is expected.
> > > 
> > > In this patch, we identify this case and skip the resync operation
> > > accordingly.
> > > 
> > > Counters:
> > > - Add a counter (tls_skip_no_sync_data) to monitor this.
> > > - Bump the dump counters up as they are used more frequently.
> > > - Add a missing counter descriptor declaration for tls_resync_bytes
> > >   in sq_stats_desc.
> > > 
> > > Fixes: d2ead1f360e8 ("net/mlx5e: Add kTLS TX HW offload support")
> > > Signed-off-by: Tariq Toukan <tariqt@mellanox.com>
> > > Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>  
> > 
> > Could you document the new counter in tls-offload.rst?  
> 
> Tariq already prepared the patch, do we want this in net or net-next ? 
> most of our kTLS users are going to use 5.3/5.4 stable kernels, but i
> am not sure this should go to net.. 

Thanks, I asked Dave recently about docs and he said we can apply to net
(since doc changes can't really break any code). Since the code is in
net, I think net would be appropriate for the doc as well.

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [net 12/15] net/mlx5e: kTLS, Enhance TX resync flow
  2019-10-22 18:42       ` Jakub Kicinski
@ 2019-10-22 18:52         ` Saeed Mahameed
  0 siblings, 0 replies; 27+ messages in thread
From: Saeed Mahameed @ 2019-10-22 18:52 UTC (permalink / raw)
  To: jakub.kicinski; +Cc: davem, netdev, Tariq Toukan

On Tue, 2019-10-22 at 11:42 -0700, Jakub Kicinski wrote:
> On Tue, 22 Oct 2019 18:10:11 +0000, Saeed Mahameed wrote:
> > On Fri, 2019-10-18 at 18:51 -0700, Jakub Kicinski wrote:
> > > On Fri, 18 Oct 2019 19:38:24 +0000, Saeed Mahameed wrote:  
> > > > From: Tariq Toukan <tariqt@mellanox.com>
> > > > 
> > > > Once the kTLS TX resync function is called, it used to return
> > > > a binary value, for success or failure.
> > > > 
> > > > However, in case the TLS SKB is a retransmission of the
> > > > connection
> > > > handshake, it initiates the resync flow (as the tcp seq check
> > > > holds),
> > > > while regular packet handle is expected.
> > > > 
> > > > In this patch, we identify this case and skip the resync
> > > > operation
> > > > accordingly.
> > > > 
> > > > Counters:
> > > > - Add a counter (tls_skip_no_sync_data) to monitor this.
> > > > - Bump the dump counters up as they are used more frequently.
> > > > - Add a missing counter descriptor declaration for
> > > > tls_resync_bytes
> > > >   in sq_stats_desc.
> > > > 
> > > > Fixes: d2ead1f360e8 ("net/mlx5e: Add kTLS TX HW offload
> > > > support")
> > > > Signed-off-by: Tariq Toukan <tariqt@mellanox.com>
> > > > Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>  
> > > 
> > > Could you document the new counter in tls-offload.rst?  
> > 
> > Tariq already prepared the patch, do we want this in net or net-
> > next ? 
> > most of our kTLS users are going to use 5.3/5.4 stable kernels, but
> > i
> > am not sure this should go to net.. 
> 
> Thanks, I asked Dave recently about docs and he said we can apply to
> net
> (since doc changes can't really break any code). Since the code is in
> net, I think net would be appropriate for the doc as well. 

Alright! will send it in my next batch of fixes to net.

Thanks,
Saeed.

^ permalink raw reply	[flat|nested] 27+ messages in thread

end of thread, other threads:[~2019-10-22 18:52 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [net 11/15] net/mlx5e: kTLS, Save a copy of the crypto info Saeed Mahameed
2019-10-18 23:16   ` 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

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.