[ofa-general] [PATCH] ib_mthca checksum offload support

Eli Cohen eli at mellanox.co.il
Sun Aug 12 04:43:48 PDT 2007


Add checksum offload support

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

---

Index: linux-2.6.23-rc1/drivers/infiniband/hw/mthca/mthca_cmd.c
===================================================================
--- linux-2.6.23-rc1.orig/drivers/infiniband/hw/mthca/mthca_cmd.c	2007-08-02 17:14:45.000000000 +0300
+++ linux-2.6.23-rc1/drivers/infiniband/hw/mthca/mthca_cmd.c	2007-08-02 17:15:41.000000000 +0300
@@ -1377,6 +1377,9 @@ int mthca_INIT_HCA(struct mthca_dev *dev
 		MTHCA_PUT(inbox, param->uarc_base,   INIT_HCA_UAR_CTX_BASE_OFFSET);
 	}
 
+	if (dev->device_cap_flags & IB_DEVICE_IP_CSUM)
+		*(inbox + INIT_HCA_FLAGS2_OFFSET / 4) |= cpu_to_be32(7 << 3);
+
 	err = mthca_cmd(dev, mailbox->dma, 0, 0, CMD_INIT_HCA, HZ, status);
 
 	mthca_free_mailbox(dev, mailbox);
Index: linux-2.6.23-rc1/drivers/infiniband/hw/mthca/mthca_cmd.h
===================================================================
--- linux-2.6.23-rc1.orig/drivers/infiniband/hw/mthca/mthca_cmd.h	2007-08-02 17:14:45.000000000 +0300
+++ linux-2.6.23-rc1/drivers/infiniband/hw/mthca/mthca_cmd.h	2007-08-02 17:15:41.000000000 +0300
@@ -103,6 +103,7 @@ enum {
 	DEV_LIM_FLAG_RAW_IPV6           = 1 << 4,
 	DEV_LIM_FLAG_RAW_ETHER          = 1 << 5,
 	DEV_LIM_FLAG_SRQ                = 1 << 6,
+        DEV_LIM_FLAG_IPOIB_CSUM		= 1 << 7,
 	DEV_LIM_FLAG_BAD_PKEY_CNTR      = 1 << 8,
 	DEV_LIM_FLAG_BAD_QKEY_CNTR      = 1 << 9,
 	DEV_LIM_FLAG_MW                 = 1 << 16,
Index: linux-2.6.23-rc1/drivers/infiniband/hw/mthca/mthca_cq.c
===================================================================
--- linux-2.6.23-rc1.orig/drivers/infiniband/hw/mthca/mthca_cq.c	2007-08-02 17:14:45.000000000 +0300
+++ linux-2.6.23-rc1/drivers/infiniband/hw/mthca/mthca_cq.c	2007-08-02 17:15:41.000000000 +0300
@@ -646,6 +646,9 @@ static inline int mthca_poll_one(struct 
 		entry->pkey_index  = be32_to_cpu(cqe->imm_etype_pkey_eec) >> 16;
 		entry->wc_flags   |= be16_to_cpu(cqe->sl_g_mlpath) & 0x80 ?
 					IB_WC_GRH : 0;
+		entry->checksum_ok = (be16_to_cpu(cqe->sl_g_mlpath) & 0x100) != 0;
+		entry->checksum = (be32_to_cpu(cqe->rqpn) >> 24) |
+					((be32_to_cpu(cqe->my_ee) >> 16) & 0xff00);
 	}
 
 	entry->status = IB_WC_SUCCESS;
Index: linux-2.6.23-rc1/drivers/infiniband/hw/mthca/mthca_main.c
===================================================================
--- linux-2.6.23-rc1.orig/drivers/infiniband/hw/mthca/mthca_main.c	2007-08-02 17:14:45.000000000 +0300
+++ linux-2.6.23-rc1/drivers/infiniband/hw/mthca/mthca_main.c	2007-08-02 17:15:41.000000000 +0300
@@ -289,6 +289,10 @@ static int mthca_dev_lim(struct mthca_de
 	if (dev_lim->flags & DEV_LIM_FLAG_SRQ)
 		mdev->mthca_flags |= MTHCA_FLAG_SRQ;
 
+	if (mthca_is_memfree(mdev))
+		if (dev_lim->flags & DEV_LIM_FLAG_IPOIB_CSUM)
+			mdev->device_cap_flags |= IB_DEVICE_IP_CSUM;
+
 	return 0;
 }
 
Index: linux-2.6.23-rc1/drivers/infiniband/hw/mthca/mthca_qp.c
===================================================================
--- linux-2.6.23-rc1.orig/drivers/infiniband/hw/mthca/mthca_qp.c	2007-08-02 17:14:45.000000000 +0300
+++ linux-2.6.23-rc1/drivers/infiniband/hw/mthca/mthca_qp.c	2007-08-02 17:15:41.000000000 +0300
@@ -2024,6 +2024,10 @@ int mthca_arbel_post_send(struct ib_qp *
 			 cpu_to_be32(MTHCA_NEXT_CQ_UPDATE) : 0) |
 			((wr->send_flags & IB_SEND_SOLICITED) ?
 			 cpu_to_be32(MTHCA_NEXT_SOLICIT) : 0)   |
+			((wr->send_flags & IB_SEND_IP_CSUM) ?
+			 cpu_to_be32(MTHCA_NEXT_IP_CSUM) : 0)   |
+			((wr->send_flags & IB_SEND_UDP_TCP_CSUM) ?
+			 cpu_to_be32(MTHCA_NEXT_TCP_UDP_CSUM) : 0)   |
 			cpu_to_be32(1);
 		if (wr->opcode == IB_WR_SEND_WITH_IMM ||
 		    wr->opcode == IB_WR_RDMA_WRITE_WITH_IMM)
Index: linux-2.6.23-rc1/drivers/infiniband/hw/mthca/mthca_wqe.h
===================================================================
--- linux-2.6.23-rc1.orig/drivers/infiniband/hw/mthca/mthca_wqe.h	2007-08-02 17:14:45.000000000 +0300
+++ linux-2.6.23-rc1/drivers/infiniband/hw/mthca/mthca_wqe.h	2007-08-02 17:15:41.000000000 +0300
@@ -38,14 +38,15 @@
 #include <linux/types.h>
 
 enum {
-	MTHCA_NEXT_DBD       = 1 << 7,
-	MTHCA_NEXT_FENCE     = 1 << 6,
-	MTHCA_NEXT_CQ_UPDATE = 1 << 3,
-	MTHCA_NEXT_EVENT_GEN = 1 << 2,
-	MTHCA_NEXT_SOLICIT   = 1 << 1,
-
-	MTHCA_MLX_VL15       = 1 << 17,
-	MTHCA_MLX_SLR        = 1 << 16
+	MTHCA_NEXT_DBD          = 1 << 7,
+	MTHCA_NEXT_FENCE        = 1 << 6,
+	MTHCA_NEXT_CQ_UPDATE    = 1 << 3,
+	MTHCA_NEXT_EVENT_GEN    = 1 << 2,
+	MTHCA_NEXT_SOLICIT      = 1 << 1,
+	MTHCA_NEXT_IP_CSUM      = 1 << 4,
+	MTHCA_NEXT_TCP_UDP_CSUM = 1 << 5,
+	MTHCA_MLX_VL15          = 1 << 17,
+	MTHCA_MLX_SLR           = 1 << 16
 };
 
 enum {
Index: linux-2.6.23-rc1/include/rdma/ib_verbs.h
===================================================================
--- linux-2.6.23-rc1.orig/include/rdma/ib_verbs.h	2007-07-10 21:56:30.000000000 +0300
+++ linux-2.6.23-rc1/include/rdma/ib_verbs.h	2007-08-02 17:25:03.000000000 +0300
@@ -93,7 +93,8 @@ enum ib_device_cap_flags {
 	IB_DEVICE_N_NOTIFY_CQ		= (1<<14),
 	IB_DEVICE_ZERO_STAG		= (1<<15),
 	IB_DEVICE_SEND_W_INV		= (1<<16),
-	IB_DEVICE_MEM_WINDOW		= (1<<17)
+	IB_DEVICE_MEM_WINDOW		= (1<<17),
+	IB_DEVICE_IP_CSUM               = (1<<18)
 };
 
 enum ib_atomic_cap {
@@ -429,6 +430,8 @@ struct ib_wc {
 	u8			sl;
 	u8			dlid_path_bits;
 	u8			port_num;	/* valid only for DR SMPs on switches */
+	u8                      checksum_ok;
+	u16                     checksum;
 };
 
 enum ib_cq_notify_flags {
@@ -613,7 +616,9 @@ enum ib_send_flags {
 	IB_SEND_FENCE		= 1,
 	IB_SEND_SIGNALED	= (1<<1),
 	IB_SEND_SOLICITED	= (1<<2),
-	IB_SEND_INLINE		= (1<<3)
+	IB_SEND_INLINE		= (1<<3),
+	IB_SEND_IP_CSUM         = (1<<4),
+	IB_SEND_UDP_TCP_CSUM    = (1<<5)
 };
 
 struct ib_sge {




More information about the general mailing list