[ofw] [PATCH] ND Provider: fix service ID byte ordering

Fab Tillier ftillier at microsoft.com
Fri Feb 11 15:18:05 PST 2011


This patch makes the ND provider treat service IDs as network byte order values.  Note that it will cause the CEP manager to validate that RDMA_CM requests are valid (minor/major version, and IP version is either 4 or 6) as originally intended.

Signed-off-by: Fab Tillier <ftillier at microsoft.com>

Index: core/al/kernel/al_cm_cep.c
===================================================================
--- core/al/kernel/al_cm_cep.c	(revision 3095)
+++ core/al/kernel/al_cm_cep.c	(working copy)
@@ -3390,7 +3390,7 @@ __cep_queue_mad(
 	// TODO: Remove - manage above core kernel CM code
 	/* NDI connection request case */
 	if ( p_cep->state == CEP_STATE_LISTEN &&
-		(p_cep->sid & ~0x0ffffffI64) == IB_REQ_CM_RDMA_SID_PREFIX )
+		(p_cep->sid & IB_REQ_CM_RDMA_SID_PREFIX_MASK) == IB_REQ_CM_RDMA_SID_PREFIX )
 	{ /* Try to complete pending IRP, if any */
 		mad_cm_req_t* p_req = (mad_cm_req_t*)ib_get_mad_buf( p_mad );
 		ib_cm_rdma_req_t *p_rdma_req = (ib_cm_rdma_req_t *)p_req->pdata;
@@ -3401,7 +3401,7 @@ __cep_queue_mad(
 			 (p_rdma_req->ipv != 0x40 && p_rdma_req->ipv != 0x60) )
 		{
 			AL_PRINT_EXIT( TRACE_LEVEL_ERROR, AL_DBG_ERROR, 
-				("NDI connection req is rejected: maj_min_ver %d, ipv %#x \n", 
+				("RDMA CM connection req is rejected: maj_min_ver %d, ipv %#x \n", 
 				p_rdma_req->maj_min_ver, p_rdma_req->ipv ) );
 			return IB_UNSUPPORTED;
 		}
Index: core/al/kernel/al_ndi_cm.c
===================================================================
--- core/al/kernel/al_ndi_cm.c	(revision 3095)
+++ core/al/kernel/al_ndi_cm.c	(working copy)
@@ -1072,7 +1072,9 @@ __ndi_fill_cm_req(
 
 	memset( p_cm_req, 0, sizeof(*p_cm_req) );
 
-	p_cm_req->service_id = IB_REQ_CM_RDMA_SID_PREFIX | (p_req->prot << 16) | p_req->dst_port;
+	p_cm_req->service_id = IB_REQ_CM_RDMA_SID_PREFIX |
+		((UINT64)p_req->prot) << 40 |
+		((UINT64)p_req->dst_port) << 48;
 	p_cm_req->p_primary_path = p_path_rec;
 
 	p_cm_req->qpn = qpn;
Index: inc/iba/ib_types.h
===================================================================
--- inc/iba/ib_types.h	(revision 3095)
+++ inc/iba/ib_types.h	(working copy)
@@ -12472,7 +12472,11 @@ typedef struct _ib_time_stamp {
 *	ib_cc_mad_t
 *********/
 
-#define IB_REQ_CM_RDMA_SID_PREFIX			0x0000000001000000
+/*
+ * The prefix and mask are defined in network order.
+ */
+#define IB_REQ_CM_RDMA_SID_PREFIX			0x0000000100000000I64
+#define IB_REQ_CM_RDMA_SID_PREFIX_MASK		0x000000FFFFFFFFFFI64
 #define IB_REQ_CM_RDMA_PDATA_SIZE			56
 #define IB_REQ_CM_RDMA_MAJOR_VERSION		0
 #define IB_REQ_CM_RDMA_MINOR_VERSION		0
-------------- next part --------------
A non-text attachment was scrubbed...
Name: nd_sid.patch
Type: application/octet-stream
Size: 2308 bytes
Desc: nd_sid.patch
URL: <http://lists.openfabrics.org/pipermail/ofw/attachments/20110211/0ebc2040/attachment.obj>


More information about the ofw mailing list