[ofa-general] [PATCH] mlx4 checksum offload

Eli Cohen eli at mellanox.co.il
Sun Aug 12 04:44:02 PDT 2007


Add checksum support to mlx4

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

---

Index: linux-2.6.23-rc1/include/linux/mlx4/cq.h
===================================================================
--- linux-2.6.23-rc1.orig/include/linux/mlx4/cq.h	2007-07-10
21:56:30.000000000 +0300
+++ linux-2.6.23-rc1/include/linux/mlx4/cq.h	2007-08-02
17:30:52.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: linux-2.6.23-rc1/drivers/infiniband/hw/mlx4/cq.c
===================================================================
--- linux-2.6.23-rc1.orig/drivers/infiniband/hw/mlx4/cq.c	2007-07-10
21:56:30.000000000 +0300
+++ linux-2.6.23-rc1/drivers/infiniband/hw/mlx4/cq.c	2007-08-02
17:32:46.000000000 +0300
@@ -431,6 +431,8 @@ 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->checksum_ok    = (be32_to_cpu(cqe->ipoib_status) & 0x10000000) !=
0;
+		wc->checksum       = be16_to_cpu(cqe->checksum);
 	}
 
 	return 0;
Index: linux-2.6.23-rc1/drivers/infiniband/hw/mlx4/main.c
===================================================================
--- linux-2.6.23-rc1.orig/drivers/infiniband/hw/mlx4/main.c	2007-08-02
11:44:43.000000000 +0300
+++ linux-2.6.23-rc1/drivers/infiniband/hw/mlx4/main.c	2007-08-02
17:35:08.000000000 +0300
@@ -99,6 +99,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;
@@ -568,6 +570,9 @@ static void *mlx4_ib_add(struct mlx4_dev
 	ibdev->ib_dev.detach_mcast	= mlx4_ib_mcg_detach;
 	ibdev->ib_dev.process_mad	= mlx4_ib_process_mad;
 
+	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: linux-2.6.23-rc1/drivers/infiniband/hw/mlx4/qp.c
===================================================================
--- linux-2.6.23-rc1.orig/drivers/infiniband/hw/mlx4/qp.c	2007-08-02
11:44:43.000000000 +0300
+++ linux-2.6.23-rc1/drivers/infiniband/hw/mlx4/qp.c	2007-08-02
17:38:37.000000000 +0300
@@ -1258,6 +1258,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: linux-2.6.23-rc1/include/linux/mlx4/qp.h
===================================================================
--- linux-2.6.23-rc1.orig/include/linux/mlx4/qp.h	2007-08-02
11:44:45.000000000 +0300
+++ linux-2.6.23-rc1/include/linux/mlx4/qp.h	2007-08-02
17:40:52.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: linux-2.6.23-rc1/drivers/net/mlx4/fw.c
===================================================================
--- linux-2.6.23-rc1.orig/drivers/net/mlx4/fw.c	2007-08-02
11:44:44.000000000 +0300
+++ linux-2.6.23-rc1/drivers/net/mlx4/fw.c	2007-08-02 17:42:55.000000000
+0300
@@ -736,6 +736,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