All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH rdma-next] RDMA/mlx4: Redo TX checksum offload in line with docs
@ 2019-12-19 13:48 Leon Romanovsky
  2020-01-03 20:39 ` Jason Gunthorpe
  0 siblings, 1 reply; 2+ messages in thread
From: Leon Romanovsky @ 2019-12-19 13:48 UTC (permalink / raw)
  To: Doug Ledford, Jason Gunthorpe
  Cc: Eugene Crosser, RDMA mailing list, Jack Wang, Leon Romanovsky

From: Eugene Crosser <evgenii.cherkashin@profitbricks.com>

Ingress checksum offload was not working for IPv6 frames because the
conditional expression that checks validation status passed from the
hardware was not matching the algorithm described in the documentation.

This patch defines L4_CSUM flag (which falls inside the badfcs_enc
field in the existing definition of the CQE layout) and replaces the
conditional expression with the one defined in the "ConnectX(r)
Family Programmer's Manual" document.

Signed-off-by: Eugene Crosser <evgenii.cherkashin@profitbricks.com>
Reviewed-by: Jack Wang <jinpu.wang@profitbricks.com>
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
---
 drivers/infiniband/hw/mlx4/cq.c | 18 +++++++-----------
 include/linux/mlx4/cq.h         |  5 +++++
 2 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/drivers/infiniband/hw/mlx4/cq.c b/drivers/infiniband/hw/mlx4/cq.c
index 306b21281fa2..72eeb9a85bc5 100644
--- a/drivers/infiniband/hw/mlx4/cq.c
+++ b/drivers/infiniband/hw/mlx4/cq.c
@@ -568,18 +568,13 @@ static void mlx4_ib_handle_error_cqe(struct mlx4_err_cqe *cqe,
 	wc->vendor_err = cqe->vendor_err_syndrome;
 }
 
-static int mlx4_ib_ipoib_csum_ok(__be16 status, __be16 checksum)
+static int mlx4_ib_ipoib_csum_ok(__be16 status, u8 badfcs_enc, __be16 checksum)
 {
-	return ((status & cpu_to_be16(MLX4_CQE_STATUS_IPV4      |
-				      MLX4_CQE_STATUS_IPV4F     |
-				      MLX4_CQE_STATUS_IPV4OPT   |
-				      MLX4_CQE_STATUS_IPV6      |
-				      MLX4_CQE_STATUS_IPOK)) ==
-		cpu_to_be16(MLX4_CQE_STATUS_IPV4        |
-			    MLX4_CQE_STATUS_IPOK))              &&
-		(status & cpu_to_be16(MLX4_CQE_STATUS_UDP       |
-				      MLX4_CQE_STATUS_TCP))     &&
-		checksum == cpu_to_be16(0xffff);
+	return ((badfcs_enc & MLX4_CQE_STATUS_L4_CSUM) ||
+		((status & cpu_to_be16(MLX4_CQE_STATUS_IPOK)) &&
+		 (status & cpu_to_be16(MLX4_CQE_STATUS_TCP |
+				       MLX4_CQE_STATUS_UDP)) &&
+		 (checksum == cpu_to_be16(0xffff))));
 }
 
 static void use_tunnel_data(struct mlx4_ib_qp *qp, struct mlx4_ib_cq *cq, struct ib_wc *wc,
@@ -855,6 +850,7 @@ static int mlx4_ib_poll_one(struct mlx4_ib_cq *cq,
 		wc->wc_flags	  |= g_mlpath_rqpn & 0x80000000 ? IB_WC_GRH : 0;
 		wc->pkey_index     = be32_to_cpu(cqe->immed_rss_invalid) & 0x7f;
 		wc->wc_flags	  |= mlx4_ib_ipoib_csum_ok(cqe->status,
+					cqe->badfcs_enc,
 					cqe->checksum) ? IB_WC_IP_CSUM_OK : 0;
 		if (is_eth) {
 			wc->slid = 0;
diff --git a/include/linux/mlx4/cq.h b/include/linux/mlx4/cq.h
index 508e8cc5ee86..653d2a0aa44c 100644
--- a/include/linux/mlx4/cq.h
+++ b/include/linux/mlx4/cq.h
@@ -130,6 +130,11 @@ enum {
 	MLX4_CQE_STATUS_IPOK		= 1 << 12,
 };
 
+/* L4_CSUM is logically part of status, but has to checked against badfcs_enc */
+enum {
+	MLX4_CQE_STATUS_L4_CSUM		= 1 << 2,
+};
+
 enum {
 	MLX4_CQE_LLC                     = 1,
 	MLX4_CQE_SNAP                    = 1 << 1,
-- 
2.20.1


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

* Re: [PATCH rdma-next] RDMA/mlx4: Redo TX checksum offload in line with docs
  2019-12-19 13:48 [PATCH rdma-next] RDMA/mlx4: Redo TX checksum offload in line with docs Leon Romanovsky
@ 2020-01-03 20:39 ` Jason Gunthorpe
  0 siblings, 0 replies; 2+ messages in thread
From: Jason Gunthorpe @ 2020-01-03 20:39 UTC (permalink / raw)
  To: Leon Romanovsky
  Cc: Doug Ledford, Eugene Crosser, RDMA mailing list, Jack Wang,
	Leon Romanovsky

On Thu, Dec 19, 2019 at 03:48:47PM +0200, Leon Romanovsky wrote:
> From: Eugene Crosser <evgenii.cherkashin@profitbricks.com>
> 
> Ingress checksum offload was not working for IPv6 frames because the
> conditional expression that checks validation status passed from the
> hardware was not matching the algorithm described in the documentation.
> 
> This patch defines L4_CSUM flag (which falls inside the badfcs_enc
> field in the existing definition of the CQE layout) and replaces the
> conditional expression with the one defined in the "ConnectX(r)
> Family Programmer's Manual" document.
> 
> Signed-off-by: Eugene Crosser <evgenii.cherkashin@profitbricks.com>
> Reviewed-by: Jack Wang <jinpu.wang@profitbricks.com>
> Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
> ---
>  drivers/infiniband/hw/mlx4/cq.c | 18 +++++++-----------
>  include/linux/mlx4/cq.h         |  5 +++++
>  2 files changed, 12 insertions(+), 11 deletions(-)

Applied to for-next, thanks

Jason

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

end of thread, other threads:[~2020-01-03 20:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-19 13:48 [PATCH rdma-next] RDMA/mlx4: Redo TX checksum offload in line with docs Leon Romanovsky
2020-01-03 20:39 ` Jason Gunthorpe

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.