[ofa-general] [PATCH 5 of 17] mlx4: add checksum offload support

Eli Cohen eli at mellanox.co.il
Tue Sep 11 08:54:18 PDT 2007


Add checksum offload support to mlx4

Signed-off-by: Ali Ayub <ali at mellnaox.co.il>
Signed-off-by: Eli Cohen <eli at mellnaox.co.il>

---

Index: ofa_1_3_dev_kernel/include/linux/mlx4/cq.h
===================================================================
--- ofa_1_3_dev_kernel.orig/include/linux/mlx4/cq.h	2007-09-11 21:14:35.000000000 +0300
+++ ofa_1_3_dev_kernel/include/linux/mlx4/cq.h	2007-09-11 21:15:26.000000000 +0300
@@ -45,11 +45,11 @@ struct mlx4_cqe {
 	u8			sl;
 	u8			reserved1;
 	__be16			rlid;
-	u32			reserved2;
+	__be32			ipoib_status;
 	__be32			byte_cnt;
 	__be16			wqe_index;
 	__be16			checksum;
-	u8			reserved3[3];
+	u8			reserved2[3];
 	u8			owner_sr_opcode;
 };
 
Index: ofa_1_3_dev_kernel/drivers/infiniband/hw/mlx4/cq.c
===================================================================
--- ofa_1_3_dev_kernel.orig/drivers/infiniband/hw/mlx4/cq.c	2007-09-11 21:14:35.000000000 +0300
+++ ofa_1_3_dev_kernel/drivers/infiniband/hw/mlx4/cq.c	2007-09-11 21:15:26.000000000 +0300
@@ -431,6 +431,9 @@ static int mlx4_ib_poll_one(struct mlx4_
 		wc->wc_flags      |= be32_to_cpu(cqe->g_mlpath_rqpn) & 0x80000000 ?
 			IB_WC_GRH : 0;
 		wc->pkey_index     = be32_to_cpu(cqe->immed_rss_invalid) >> 16;
+		wc->csum      = be16_to_cpu(cqe->checksum);
+		wc->csum_ok   = be32_to_cpu(cqe->ipoib_status) & 0x10000000 &&
+				wc->csum == 0xffff;
 	}
 
 	return 0;
Index: ofa_1_3_dev_kernel/drivers/infiniband/hw/mlx4/main.c
===================================================================
--- ofa_1_3_dev_kernel.orig/drivers/infiniband/hw/mlx4/main.c	2007-09-11 21:15:09.000000000 +0300
+++ ofa_1_3_dev_kernel/drivers/infiniband/hw/mlx4/main.c	2007-09-11 21:15:26.000000000 +0300
@@ -100,6 +100,8 @@ static int mlx4_ib_query_device(struct i
 		props->device_cap_flags |= IB_DEVICE_AUTO_PATH_MIG;
 	if (dev->dev->caps.flags & MLX4_DEV_CAP_FLAG_UD_AV_PORT)
 		props->device_cap_flags |= IB_DEVICE_UD_AV_PORT_ENFORCE;
+	if (dev->dev->caps.flags & MLX4_DEV_CAP_FLAG_IPOIB_CSUM)
+		props->device_cap_flags |= IB_DEVICE_IP_CSUM;
 
 	props->vendor_id	   = be32_to_cpup((__be32 *) (out_mad->data + 36)) &
 		0xffffff;
@@ -626,6 +628,9 @@ static void *mlx4_ib_add(struct mlx4_dev
 	ibdev->ib_dev.unmap_fmr		= mlx4_ib_unmap_fmr;
 	ibdev->ib_dev.dealloc_fmr	= mlx4_ib_fmr_dealloc;
 
+	if (ibdev->dev->caps.flags & MLX4_DEV_CAP_FLAG_IPOIB_CSUM)
+		ibdev->ib_dev.flags |= IB_DEVICE_IP_CSUM;
+
 	if (init_node_data(ibdev))
 		goto err_map;
 
Index: ofa_1_3_dev_kernel/drivers/infiniband/hw/mlx4/qp.c
===================================================================
--- ofa_1_3_dev_kernel.orig/drivers/infiniband/hw/mlx4/qp.c	2007-09-11 21:15:11.000000000 +0300
+++ ofa_1_3_dev_kernel/drivers/infiniband/hw/mlx4/qp.c	2007-09-11 21:15:26.000000000 +0300
@@ -1278,6 +1278,10 @@ int mlx4_ib_post_send(struct ib_qp *ibqp
 			 cpu_to_be32(MLX4_WQE_CTRL_CQ_UPDATE) : 0) |
 			(wr->send_flags & IB_SEND_SOLICITED ?
 			 cpu_to_be32(MLX4_WQE_CTRL_SOLICITED) : 0) |
+			((wr->send_flags & IB_SEND_IP_CSUM) ?
+			 cpu_to_be32(MLX4_WQE_CTRL_IP_CSUM) : 0)   |
+			((wr->send_flags & IB_SEND_UDP_TCP_CSUM) ?
+			 cpu_to_be32(MLX4_WQE_CTRL_TCP_UDP_CSUM) : 0)   |
 			qp->sq_signal_bits;
 
 		if (wr->opcode == IB_WR_SEND_WITH_IMM ||
Index: ofa_1_3_dev_kernel/include/linux/mlx4/qp.h
===================================================================
--- ofa_1_3_dev_kernel.orig/include/linux/mlx4/qp.h	2007-09-11 21:14:35.000000000 +0300
+++ ofa_1_3_dev_kernel/include/linux/mlx4/qp.h	2007-09-11 21:15:26.000000000 +0300
@@ -155,9 +155,11 @@ struct mlx4_qp_context {
 };
 
 enum {
-	MLX4_WQE_CTRL_FENCE	= 1 << 6,
-	MLX4_WQE_CTRL_CQ_UPDATE	= 3 << 2,
-	MLX4_WQE_CTRL_SOLICITED	= 1 << 1,
+	MLX4_WQE_CTRL_FENCE             = 1 << 6,
+	MLX4_WQE_CTRL_CQ_UPDATE         = 3 << 2,
+	MLX4_WQE_CTRL_SOLICITED         = 1 << 1,
+	MLX4_WQE_CTRL_IP_CSUM           = 1 << 4,
+	MLX4_WQE_CTRL_TCP_UDP_CSUM      = 1 << 5,
 };
 
 struct mlx4_wqe_ctrl_seg {
Index: ofa_1_3_dev_kernel/drivers/net/mlx4/fw.c
===================================================================
--- ofa_1_3_dev_kernel.orig/drivers/net/mlx4/fw.c	2007-09-11 21:15:03.000000000 +0300
+++ ofa_1_3_dev_kernel/drivers/net/mlx4/fw.c	2007-09-11 21:15:26.000000000 +0300
@@ -741,6 +741,9 @@ int mlx4_INIT_HCA(struct mlx4_dev *dev, 
 	MLX4_PUT(inbox, (u8) (PAGE_SHIFT - 12), INIT_HCA_UAR_PAGE_SZ_OFFSET);
 	MLX4_PUT(inbox, param->log_uar_sz,      INIT_HCA_LOG_UAR_SZ_OFFSET);
 
+	if (dev->caps.flags & MLX4_DEV_CAP_FLAG_IPOIB_CSUM)
+		*(inbox + INIT_HCA_FLAGS_OFFSET / 4) |= cpu_to_be32(1 << 3);
+
 	err = mlx4_cmd(dev, mailbox->dma, 0, 0, MLX4_CMD_INIT_HCA, 1000);
 
 	if (err)




More information about the general mailing list