[Openib-windows] [PATCH] MTHCA: always treat RKEY in network order

Fab Tillier ftillier at silverstorm.com
Thu Mar 30 21:58:49 PST 2006


Hi Leo,

In testing WSD between the old driver and the new, I discovered that the RKEY is
not handled quite right.  The stack expects the RKEY to always be returned as a
network-byte-order token.  Here's a patch that swaps the RKEY returned to users,
as well as eliminates the swaps required when posting RDMA read or write (or
atomic) requests.

With this patch, WSD will work with RDMA reads disabled (IBWSD_NO_READ
environment variable).
 
- Fab

Index: hw/mthca/kernel/hca_memory.c
===================================================================
--- hw/mthca/kernel/hca_memory.c	(revision 263)
+++ hw/mthca/kernel/hca_memory.c	(working copy)
@@ -133,7 +133,7 @@
 	mro_p->iobuf = iobuf;
 #endif
 	*p_lkey = mr_p->lkey;
-	*p_rkey = mr_p->rkey;
+	*p_rkey = _byteswap_ulong(mr_p->rkey);
 	if (ph_mr)	*ph_mr = (ib_mr_handle_t)mr_p;
 	status = IB_SUCCESS;
 
@@ -208,7 +208,7 @@
 	// results
 	if (ph_mr)	*ph_mr = (ib_mr_handle_t)mr_p;
 	*p_lkey = mr_p->lkey;
-	*p_rkey = mr_p->rkey;
+	*p_rkey = _byteswap_ulong(mr_p->rkey);
 	//NB:  p_vaddr was not changed
 	status = IB_SUCCESS;
 
Index: hw/mthca/kernel/mthca_qp.c
===================================================================
--- hw/mthca/kernel/mthca_qp.c	(revision 263)
+++ hw/mthca/kernel/mthca_qp.c	(working copy)
@@ -1540,8 +1540,7 @@
 			case MTHCA_OPCODE_ATOMIC_FA:
 				((struct mthca_raddr_seg *) wqe)->raddr =
 					cl_hton64(wr->remote_ops.vaddr);
-				((struct mthca_raddr_seg *) wqe)->rkey =
-					cl_hton32(wr->remote_ops.rkey);
+				((struct mthca_raddr_seg *) wqe)->rkey =
wr->remote_ops.rkey;
 				((struct mthca_raddr_seg *) wqe)->reserved = 0;
 
 				wqe += sizeof (struct mthca_raddr_seg);
@@ -1567,8 +1566,7 @@
 			case MTHCA_OPCODE_RDMA_WRITE_IMM:
 				((struct mthca_raddr_seg *) wqe)->raddr =
 					cl_hton64(wr->remote_ops.vaddr);
-				((struct mthca_raddr_seg *) wqe)->rkey =
-					cl_hton32(wr->remote_ops.rkey);
+				((struct mthca_raddr_seg *) wqe)->rkey =
wr->remote_ops.rkey;
 				((struct mthca_raddr_seg *) wqe)->reserved = 0;
 				wqe += sizeof (struct mthca_raddr_seg);
 				size += sizeof (struct mthca_raddr_seg) / 16;
@@ -1587,8 +1585,7 @@
 			case MTHCA_OPCODE_RDMA_WRITE_IMM:
 				((struct mthca_raddr_seg *) wqe)->raddr =
 					cl_hton64(wr->remote_ops.vaddr);
-				((struct mthca_raddr_seg *) wqe)->rkey =
-					cl_hton32(wr->remote_ops.rkey);
+				((struct mthca_raddr_seg *) wqe)->rkey =
wr->remote_ops.rkey;
 				((struct mthca_raddr_seg *) wqe)->reserved = 0;
 				wqe += sizeof (struct mthca_raddr_seg);
 				size += sizeof (struct mthca_raddr_seg) / 16;
@@ -1905,8 +1902,7 @@
 			case MTHCA_OPCODE_ATOMIC_FA:
 				((struct mthca_raddr_seg *) wqe)->raddr =
 					cl_hton64(wr->remote_ops.vaddr);
-				((struct mthca_raddr_seg *) wqe)->rkey =
-					cl_hton32(wr->remote_ops.rkey);
+				((struct mthca_raddr_seg *) wqe)->rkey =
wr->remote_ops.rkey;
 				((struct mthca_raddr_seg *) wqe)->reserved = 0;
 
 				wqe += sizeof (struct mthca_raddr_seg);
@@ -1932,8 +1928,7 @@
 			case MTHCA_OPCODE_RDMA_WRITE_IMM:
 				((struct mthca_raddr_seg *) wqe)->raddr =
 					cl_hton64(wr->remote_ops.vaddr);
-				((struct mthca_raddr_seg *) wqe)->rkey =
-					cl_hton32(wr->remote_ops.rkey);
+				((struct mthca_raddr_seg *) wqe)->rkey =
wr->remote_ops.rkey;
 				((struct mthca_raddr_seg *) wqe)->reserved = 0;
 				wqe += sizeof (struct mthca_raddr_seg);
 				size += sizeof (struct mthca_raddr_seg) / 16;
@@ -1952,8 +1947,7 @@
 			case MTHCA_OPCODE_RDMA_WRITE_IMM:
 				((struct mthca_raddr_seg *) wqe)->raddr =
 					cl_hton64(wr->remote_ops.vaddr);
-				((struct mthca_raddr_seg *) wqe)->rkey =
-					cl_hton32(wr->remote_ops.rkey);
+				((struct mthca_raddr_seg *) wqe)->rkey =
wr->remote_ops.rkey;
 				((struct mthca_raddr_seg *) wqe)->reserved = 0;
 				wqe += sizeof (struct mthca_raddr_seg);
 				size += sizeof (struct mthca_raddr_seg) / 16;
Index: hw/mthca/user/mlnx_uvp_qp.c
===================================================================
--- hw/mthca/user/mlnx_uvp_qp.c	(revision 263)
+++ hw/mthca/user/mlnx_uvp_qp.c	(working copy)
@@ -208,8 +208,7 @@
 			case MTHCA_OPCODE_ATOMIC_FA:
 				((struct mthca_raddr_seg *) wqe)->raddr =
 					cl_hton64(wr->remote_ops.vaddr);
-				((struct mthca_raddr_seg *) wqe)->rkey =
-					cl_hton32(wr->remote_ops.rkey);
+				((struct mthca_raddr_seg *) wqe)->rkey =
wr->remote_ops.rkey;
 				((struct mthca_raddr_seg *) wqe)->reserved = 0;
 
 				wqe += sizeof (struct mthca_raddr_seg);
@@ -235,8 +234,7 @@
 			case MTHCA_OPCODE_RDMA_READ:
 				((struct mthca_raddr_seg *) wqe)->raddr =
 					cl_hton64(wr->remote_ops.vaddr);
-				((struct mthca_raddr_seg *) wqe)->rkey =
-					cl_hton32(wr->remote_ops.rkey);
+				((struct mthca_raddr_seg *) wqe)->rkey =
wr->remote_ops.rkey;
 				((struct mthca_raddr_seg *) wqe)->reserved = 0;
 				wqe += sizeof (struct mthca_raddr_seg);
 				size += sizeof (struct mthca_raddr_seg) / 16;
@@ -255,8 +253,7 @@
 			case MTHCA_OPCODE_RDMA_WRITE_IMM:
 				((struct mthca_raddr_seg *) wqe)->raddr =
 					cl_hton64(wr->remote_ops.vaddr);
-				((struct mthca_raddr_seg *) wqe)->rkey =
-					cl_hton32(wr->remote_ops.rkey);
+				((struct mthca_raddr_seg *) wqe)->rkey =
wr->remote_ops.rkey;
 				((struct mthca_raddr_seg *) wqe)->reserved = 0;
 				wqe += sizeof (struct mthca_raddr_seg);
 				size += sizeof (struct mthca_raddr_seg) / 16;
@@ -587,8 +584,7 @@
 			case MTHCA_OPCODE_ATOMIC_FA:
 				((struct mthca_raddr_seg *) wqe)->raddr =
 					cl_hton64(wr->remote_ops.vaddr);
-				((struct mthca_raddr_seg *) wqe)->rkey =
-					cl_hton32((wr->remote_ops.rkey));
+				((struct mthca_raddr_seg *) wqe)->rkey =
wr->remote_ops.rkey;
 				((struct mthca_raddr_seg *) wqe)->reserved = 0;
 
 				wqe += sizeof (struct mthca_raddr_seg);
@@ -614,8 +610,7 @@
 			case MTHCA_OPCODE_RDMA_WRITE_IMM:
 				((struct mthca_raddr_seg *) wqe)->raddr =
 					cl_hton64(wr->remote_ops.vaddr);
-				((struct mthca_raddr_seg *) wqe)->rkey =
-					cl_hton32(wr->remote_ops.rkey);
+				((struct mthca_raddr_seg *) wqe)->rkey =
wr->remote_ops.rkey;
 				((struct mthca_raddr_seg *) wqe)->reserved = 0;
 				wqe += sizeof (struct mthca_raddr_seg);
 				size += sizeof (struct mthca_raddr_seg) / 16;
@@ -634,8 +629,7 @@
 			case MTHCA_OPCODE_RDMA_WRITE_IMM:
 				((struct mthca_raddr_seg *) wqe)->raddr =
 					cl_hton64(wr->remote_ops.vaddr);
-				((struct mthca_raddr_seg *) wqe)->rkey =
-					cl_hton32(wr->remote_ops.rkey);
+				((struct mthca_raddr_seg *) wqe)->rkey =
wr->remote_ops.rkey;
 				((struct mthca_raddr_seg *) wqe)->reserved = 0;
 				wqe += sizeof (struct mthca_raddr_seg);
 				size += sizeof (struct mthca_raddr_seg) / 16;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mthca_rkey.patch
Type: application/octet-stream
Size: 6146 bytes
Desc: not available
URL: <http://lists.openfabrics.org/pipermail/ofw/attachments/20060330/2a3f93fb/attachment.obj>


More information about the ofw mailing list