[ofw] [PATCH] dapl: use private_data_len for mem copies

Sean Hefty sean.hefty at intel.com
Sat Jan 23 00:18:57 PST 2010


When copying private_data out of rdma_cm events, use the
reported private_data_len for the size, and not IB maximums.
This fixes a bug running over the librdmacm on windows, where
DAPL accessed invalid memory.

Signed-off-by: Sean Hefty <sean.hefty at intel.com>
---
This is a more substantial fix to the private data length issue.
This fix is for review and the upstream dapl.git tree (eventually
making its way back into the trunk).  I do NOT recommend this for
the 2.2 release given the scope of the changes.

This change has only been lightly tested.

 trunk/ulp/dapl2/dapl/common/dapl_adapter_util.h    |    6 -
 trunk/ulp/dapl2/dapl/common/dapl_cr_callback.c     |   19 ++--
 trunk/ulp/dapl2/dapl/common/dapl_cr_util.h         |    3 -
 trunk/ulp/dapl2/dapl/common/dapl_ep_connect.c      |   11 ---
 trunk/ulp/dapl2/dapl/common/dapl_ep_util.c         |    4 -
 .../dapl2/dapl/common/dapl_evd_connection_callb.c  |   20 -----
 trunk/ulp/dapl2/dapl/common/dapl_evd_util.h        |    3 -
 trunk/ulp/dapl2/dapl/common/dapl_ia_query.c        |    3 -
 trunk/ulp/dapl2/dapl/ibal/dapl_ibal_cm.c           |   88 +++-----------------
 trunk/ulp/dapl2/dapl/openib_cma/cm.c               |   77 +++---------------
 trunk/ulp/dapl2/dapl/openib_scm/cm.c               |   58 +++----------
 trunk/ulp/dapl2/dapl/openib_ucm/cm.c               |   58 +++----------
 12 files changed, 65 insertions(+), 285 deletions(-)

diff --git a/trunk/ulp/dapl2/dapl/common/dapl_adapter_util.h b/trunk/ulp/dapl2/dapl/common/dapl_adapter_util.h
index 97ab42e..92cb9b7 100644
--- a/trunk/ulp/dapl2/dapl/common/dapl_adapter_util.h
+++ b/trunk/ulp/dapl2/dapl/common/dapl_adapter_util.h
@@ -239,10 +239,8 @@ DAT_RETURN dapls_ib_cm_remote_addr (
 	IN  DAT_HANDLE			dat_handle,
 	OUT DAT_SOCK_ADDR6		*remote_ia_address);
 
-int dapls_ib_private_data_size (
-	IN  DAPL_PRIVATE		*prd_ptr,
-	IN  DAPL_PDATA_OP		conn_op,
-	IN  DAPL_HCA			*hca_ptr);
+int dapls_ib_private_data_size(
+	IN DAPL_HCA			*hca_ptr);
 
 void 
 dapls_query_provider_specific_attr(
diff --git a/trunk/ulp/dapl2/dapl/common/dapl_cr_callback.c b/trunk/ulp/dapl2/dapl/common/dapl_cr_callback.c
index 2340489..af68f85 100644
--- a/trunk/ulp/dapl2/dapl/common/dapl_cr_callback.c
+++ b/trunk/ulp/dapl2/dapl/common/dapl_cr_callback.c
@@ -51,6 +51,7 @@
 DAT_RETURN dapli_connection_request(IN dp_ib_cm_handle_t ib_cm_handle,
 				    IN DAPL_SP * sp_ptr,
 				    IN DAPL_PRIVATE * prd_ptr,
+				    IN int private_data_size,
 				    IN DAPL_EVD * evd_ptr);
 
 DAPL_EP *dapli_get_sp_ep(IN dp_ib_cm_handle_t ib_cm_handle,
@@ -74,7 +75,8 @@ DAPL_EP *dapli_get_sp_ep(IN dp_ib_cm_handle_t ib_cm_handle,
  * 	None
  *
  */
-void dapls_cr_callback(IN dp_ib_cm_handle_t ib_cm_handle, IN const ib_cm_events_t ib_cm_event, IN const void *private_data_ptr,
/* event data */
+void dapls_cr_callback(IN dp_ib_cm_handle_t ib_cm_handle, IN const ib_cm_events_t ib_cm_event,
+		       IN const void *private_data_ptr,	IN const int private_data_size,
 		       IN const void *context)
 {
 	DAPL_EP *ep_ptr;
@@ -174,8 +176,7 @@ void dapls_cr_callback(IN dp_ib_cm_handle_t ib_cm_handle, IN const ib_cm_events_
 			 * event if appropriate.
 			 */
 			dat_status = dapli_connection_request(ib_cm_handle,
-							      sp_ptr,
-							      prd_ptr, evd_ptr);
+							      sp_ptr, prd_ptr, private_data_size, evd_ptr);
 			/* Set evd_ptr = NULL so we don't generate an event below */
 			evd_ptr = NULL;
 
@@ -308,7 +309,8 @@ void dapls_cr_callback(IN dp_ib_cm_handle_t ib_cm_handle, IN const ib_cm_events_
 DAT_RETURN
 dapli_connection_request(IN dp_ib_cm_handle_t ib_cm_handle,
 			 IN DAPL_SP * sp_ptr,
-			 IN DAPL_PRIVATE * prd_ptr, IN DAPL_EVD * evd_ptr)
+			 IN DAPL_PRIVATE * prd_ptr, IN int private_data_size,
+			 IN DAPL_EVD * evd_ptr)
 {
 	DAT_RETURN dat_status;
 
@@ -346,14 +348,7 @@ dapli_connection_request(IN dp_ib_cm_handle_t ib_cm_handle,
 
 	/* Private data size will be determined by the provider layer */
 	cr_ptr->param.private_data = cr_ptr->private_data;
-	if (prd_ptr == NULL) {
-		cr_ptr->param.private_data_size = 0;
-	} else {
-		cr_ptr->param.private_data_size =
-		    dapls_ib_private_data_size(prd_ptr, DAPL_PDATA_CONN_REQ,
-					       sp_ptr->header.owner_ia->
-					       hca_ptr);
-	}
+	cr_ptr->param.private_data_size = private_data_size;
 	if (cr_ptr->param.private_data_size > 0) {
 		dapl_os_memcpy(cr_ptr->private_data,
 			       prd_ptr->private_data,
diff --git a/trunk/ulp/dapl2/dapl/common/dapl_cr_util.h b/trunk/ulp/dapl2/dapl/common/dapl_cr_util.h
index 33aed7c..cec980f 100644
--- a/trunk/ulp/dapl2/dapl/common/dapl_cr_util.h
+++ b/trunk/ulp/dapl2/dapl/common/dapl_cr_util.h
@@ -52,7 +52,8 @@ void
 dapls_cr_callback (
     IN    dp_ib_cm_handle_t     ib_cm_handle,
     IN    const ib_cm_events_t  ib_cm_event,
-    IN	  const void 		*instant_data_p,
+    IN	  const void 		*private_data_ptr,
+    IN    const int		private_data_size,
     IN    const void         	*context);
 
 #endif /* _DAPL_CR_UTIL_H_ */
diff --git a/trunk/ulp/dapl2/dapl/common/dapl_ep_connect.c b/trunk/ulp/dapl2/dapl/common/dapl_ep_connect.c
index 5e4dc41..4e5e112 100644
--- a/trunk/ulp/dapl2/dapl/common/dapl_ep_connect.c
+++ b/trunk/ulp/dapl2/dapl/common/dapl_ep_connect.c
@@ -79,7 +79,6 @@ dapl_ep_connect(IN DAT_EP_HANDLE ep_handle,
 	DAPL_EP alloc_ep;
 	DAT_RETURN dat_status;
 	DAT_COUNT req_hdr_size;
-	DAT_UINT32 max_req_pdata_size;
 	void *private_data_ptr;
 
 	dapl_dbg_log(DAPL_DBG_TYPE_API | DAPL_DBG_TYPE_CM,
@@ -258,16 +257,6 @@ dapl_ep_connect(IN DAT_EP_HANDLE ep_handle,
 	 */
 	req_hdr_size = (sizeof(DAPL_PRIVATE) - DAPL_MAX_PRIVATE_DATA_SIZE);
 
-	max_req_pdata_size =
-	    dapls_ib_private_data_size(NULL, DAPL_PDATA_CONN_REQ,
-				       ep_ptr->header.owner_ia->hca_ptr);
-
-	if (private_data_size + req_hdr_size > (DAT_COUNT) max_req_pdata_size) {
-		dapl_os_unlock(&ep_ptr->header.lock);
-		dat_status = DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG5);
-		goto bail;
-	}
-
 	/* transition the state before requesting a connection to avoid
 	 * race conditions
 	 */
diff --git a/trunk/ulp/dapl2/dapl/common/dapl_ep_util.c b/trunk/ulp/dapl2/dapl/common/dapl_ep_util.c
index a50a6cb..505a9f2 100644
--- a/trunk/ulp/dapl2/dapl/common/dapl_ep_util.c
+++ b/trunk/ulp/dapl2/dapl/common/dapl_ep_util.c
@@ -565,11 +565,11 @@ dapl_ep_legacy_post_disconnect(DAPL_EP * ep_ptr,
 				     ep_ptr, cr_ptr->ib_cm_handle);
 
 			dapls_cr_callback(cr_ptr->ib_cm_handle,
-					  ib_cm_event, NULL, cr_ptr->sp_ptr);
+					  ib_cm_event, NULL, 0, cr_ptr->sp_ptr);
 		} else {
 			dapl_evd_connection_callback(ep_ptr->cm_handle,
 						     ib_cm_event,
-						     NULL, (void *)ep_ptr);
+						     NULL, 0, (void *)ep_ptr);
 		}
 	} else {
 		dapl_os_unlock(&ep_ptr->header.lock);
diff --git a/trunk/ulp/dapl2/dapl/common/dapl_evd_connection_callb.c b/trunk/ulp/dapl2/dapl/common/dapl_evd_connection_callb.c
index e2fb93b..8881362 100644
--- a/trunk/ulp/dapl2/dapl/common/dapl_evd_connection_callb.c
+++ b/trunk/ulp/dapl2/dapl/common/dapl_evd_connection_callb.c
@@ -65,6 +65,7 @@ void
 dapl_evd_connection_callback(IN dp_ib_cm_handle_t ib_cm_handle,
 			     IN const ib_cm_events_t ib_cm_event,
 			     IN const void *private_data_ptr,
+			     IN const int private_data_size,
 			     IN const void *context)
 {
 	DAPL_EP *ep_ptr;
@@ -72,7 +73,6 @@ dapl_evd_connection_callback(IN dp_ib_cm_handle_t ib_cm_handle,
 	DAPL_PRIVATE *prd_ptr;
 	DAT_EVENT_NUMBER dat_event_num;
 	DAT_RETURN dat_status;
-	int private_data_size;
 
 	dapl_dbg_log(DAPL_DBG_TYPE_CM | DAPL_DBG_TYPE_CALLBACK,
 		     "--> dapl_evd_connection_callback: ctxt: %p event: %x cm_handle %p\n",
@@ -96,7 +96,6 @@ dapl_evd_connection_callback(IN dp_ib_cm_handle_t ib_cm_handle,
 	DAPL_CNTR(evd_ptr, DCNT_EVD_CONN_CALLBACK);
 
 	prd_ptr = (DAPL_PRIVATE *) private_data_ptr;
-	private_data_size = 0;
 	/*
 	 * All operations effect the EP, so lock it once and unlock
 	 * when necessary
@@ -132,16 +131,6 @@ dapl_evd_connection_callback(IN dp_ib_cm_handle_t ib_cm_handle,
 			}
 			ep_ptr->param.ep_state = DAT_EP_STATE_CONNECTED;
 			ep_ptr->cm_handle = ib_cm_handle;
-			if (prd_ptr == NULL) {
-				private_data_size = 0;
-			} else {
-				private_data_size =
-				    dapls_ib_private_data_size(prd_ptr,
-							       DAPL_PDATA_CONN_REP,
-							       ep_ptr->header.
-							       owner_ia->
-							       hca_ptr);
-			}
 
 			if (private_data_size > 0) {
 				/* copy in the private data */
@@ -157,13 +146,6 @@ dapl_evd_connection_callback(IN dp_ib_cm_handle_t ib_cm_handle,
 	case DAT_CONNECTION_EVENT_PEER_REJECTED:
 		{
 			/* peer reject may include private data */
-			if (prd_ptr != NULL)
-				private_data_size =
-				    dapls_ib_private_data_size(prd_ptr,
-							       DAPL_PDATA_CONN_REJ,
-							       ep_ptr->header.
-							       owner_ia->
-							       hca_ptr);
 
 			if (private_data_size > 0)
 				dapl_os_memcpy(ep_ptr->private.private_data,
diff --git a/trunk/ulp/dapl2/dapl/common/dapl_evd_util.h b/trunk/ulp/dapl2/dapl/common/dapl_evd_util.h
index 2304435..e5a7c3f 100644
--- a/trunk/ulp/dapl2/dapl/common/dapl_evd_util.h
+++ b/trunk/ulp/dapl2/dapl/common/dapl_evd_util.h
@@ -137,7 +137,8 @@ dapls_evd_post_connection_event_ext (
 extern void dapl_evd_connection_callback (
     IN	dp_ib_cm_handle_t	ib_cm_handle,
     IN	const ib_cm_events_t	ib_cm_events,
-    IN	const void 		*instant_data_p,
+    IN	const void 		*private_data_ptr,
+    IN	const int		private_data_size,
     IN	const void *		context );
 
 /* dto verb callback */
diff --git a/trunk/ulp/dapl2/dapl/common/dapl_ia_query.c b/trunk/ulp/dapl2/dapl/common/dapl_ia_query.c
index 6fcc4a2..d530d72 100644
--- a/trunk/ulp/dapl2/dapl/common/dapl_ia_query.c
+++ b/trunk/ulp/dapl2/dapl/common/dapl_ia_query.c
@@ -150,8 +150,7 @@ dapl_ia_query(IN DAT_IA_HANDLE ia_handle,
 		 *      to 0 unless IBHOSTS_NAMING is enabled.
 		 */
 		provider_attr->max_private_data_size =
-		    dapls_ib_private_data_size(NULL, DAPL_PDATA_CONN_REQ,
-					       ia_ptr->hca_ptr) -
+		    dapls_ib_private_data_size(ia_ptr->hca_ptr) -
 		    (sizeof(DAPL_PRIVATE) - DAPL_MAX_PRIVATE_DATA_SIZE);
 		provider_attr->supports_multipath = DAT_FALSE;
 		provider_attr->ep_creator = DAT_PSP_CREATES_EP_NEVER;
diff --git a/trunk/ulp/dapl2/dapl/ibal/dapl_ibal_cm.c b/trunk/ulp/dapl2/dapl/ibal/dapl_ibal_cm.c
index 149bcbf..fac567a 100644
--- a/trunk/ulp/dapl2/dapl/ibal/dapl_ibal_cm.c
+++ b/trunk/ulp/dapl2/dapl/ibal/dapl_ibal_cm.c
@@ -216,6 +216,7 @@ dapli_ib_cm_dreq_cb (
         dapls_cr_callback ( ep_ptr->cm_handle,
                             IB_CME_DISCONNECTED,
                             (void * __ptr64) p_cm_dreq_rec->p_dreq_pdata,
+			    IB_DREQ_PDATA_SIZE,
                             (void *) (((DAPL_CR *) ep_ptr->cr_ptr)->sp_ptr) );
     }
     else
@@ -226,6 +227,7 @@ dapli_ib_cm_dreq_cb (
                                   IB_CME_DISCONNECTED,
                                   (void * __ptr64)
                                   p_cm_dreq_rec->p_dreq_pdata,
+				  IB_DREQ_PDATA_SIZE,
                                   p_cm_dreq_rec->qp_context );
     }
 }
@@ -285,6 +287,7 @@ dapli_ib_cm_drep_cb (
         dapls_cr_callback ( ep_ptr->cm_handle,
                             IB_CME_DISCONNECTED,
                            (void * __ptr64) p_cm_drep_rec->p_drep_pdata,
+			   IB_DREP_PDATA_SIZE,
                            (void *) (((DAPL_CR *) ep_ptr->cr_ptr)->sp_ptr) );
     }
     else
@@ -294,6 +297,7 @@ dapli_ib_cm_drep_cb (
                                    ep_ptr->cm_handle,
                                    IB_CME_DISCONNECTED,
                                    (void * __ptr64) p_cm_drep_rec->p_drep_pdata,
+				   IB_DREP_PDATA_SIZE,
                                    p_cm_drep_rec->qp_context );
     }
 }
@@ -371,6 +375,7 @@ dapli_ib_cm_rep_cb (
                             (dp_ib_cm_handle_t)&p_cm_rep_rec->h_cm_rep,
                             cm_cb_op,
                             (void *) prd_ptr,
+			    IB_REP_PDATA_SIZE,
                             (void * __ptr64) p_cm_rep_rec->qp_context);
 }
 
@@ -454,6 +459,7 @@ dapli_ib_cm_rej_cb (
         dapls_cr_callback ( ep_ptr->cm_handle,
                             cm_event,
                             (void * __ptr64) p_cm_rej_rec->p_rej_pdata,
+			    IB_REJ_PDATA_SIZE,
                             (void *) ((DAPL_CR *) ep_ptr->cr_ptr)->sp_ptr);
     }
     else
@@ -462,6 +468,7 @@ dapli_ib_cm_rej_cb (
                                    ep_ptr->cm_handle,
                                    cm_event,
                                    (void * __ptr64) p_cm_rej_rec->p_rej_pdata,
+				   IB_REJ_PDATA_SIZE,
                                    (void * __ptr64) p_cm_rej_rec->qp_context );
     }
 
@@ -610,6 +617,7 @@ dapli_ib_cm_req_cb ( IN  ib_cm_req_rec_t  *p_cm_req_rec )
     dapls_cr_callback ( cm_handle,
                         IB_CME_CONNECTION_REQUEST_PENDING,
                         (void * __ptr64) p_cm_req_rec->p_req_pdata,
+			IB_REQ_PDATA_SIZE,
                         (void * __ptr64) sp_ptr );
 }
 
@@ -652,6 +660,7 @@ dapli_ib_cm_rtu_cb (
         dapls_cr_callback ( ep_ptr->cm_handle,
                             IB_CME_CONNECTED,
                             (void * __ptr64) p_cm_rtu_rec->p_rtu_pdata,
+                            IB_RTU_PDATA_SIZE,
                             (void *) sp_ptr);
                             
     }
@@ -661,6 +670,7 @@ dapli_ib_cm_rtu_cb (
                             ep_ptr->cm_handle,
                             IB_CME_CONNECTED,
                             (void * __ptr64) p_cm_rtu_rec->p_rtu_pdata,
+			    IB_RTU_PDATA_SIZE,
                             (void *) ep_ptr);
     }
 }
@@ -1297,15 +1307,6 @@ dapls_ib_reject_connection ( IN  dp_ib_cm_handle_t   ib_cm_handle,
     cm_rej.p_ari        = (ib_ari_t *)&rej_table[reject_reason]; 
     cm_rej.ari_length   = (uint8_t)strlen (rej_table[reject_reason]);
 
-    if (private_data_size > 
-	dapls_ib_private_data_size(NULL,DAPL_PDATA_CONN_REJ,NULL))
-    {
-        dapl_dbg_log ( DAPL_DBG_TYPE_ERR,
-                       "--> DsRjC: private_data size(%d) > Max(%d)\n", 
-                       private_data_size, IB_MAX_REJ_PDATA_SIZE );
-	return DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG3);
-    }
-
     cm_rej.p_rej_pdata  = private_data;
     cm_rej.rej_length   = private_data_size;
 
@@ -1723,78 +1724,11 @@ dapls_ib_cr_handoff (
 }
 #endif
 
-/*
- * dapls_ib_private_data_size
- *
- * Return the size of private data given a connection op type
- *
- * Input:
- *	prd_ptr		private data pointer
- *	conn_op		connection operation type
- *	hca_ptr		hca pointer, needed for transport type
- *
- * If prd_ptr is NULL, this is a query for the max size supported by
- * the provider, otherwise it is the actual size of the private data
- * contained in prd_ptr.
- *
- * Infiniband has fixed size private data, so prd_ptr is ignored.
- *
- * Output:
- *	None
- *
- * Returns:
- * 	length of private data
- *
- */
 int
 dapls_ib_private_data_size (
-	IN      DAPL_PRIVATE		*prd_ptr,
-	IN	DAPL_PDATA_OP		conn_op,
 	IN	DAPL_HCA		*hca_ptr)
 {
-    int  size;
-
-    UNUSED_PARAM( prd_ptr );
-    UNUSED_PARAM( hca_ptr );
-
-    switch (conn_op)
-    {
-        case DAPL_PDATA_CONN_REQ:
-	{
-	    size = IB_MAX_REQ_PDATA_SIZE;
-	    break;
-	}
-        case DAPL_PDATA_CONN_REP:
-	{
-	    size = IB_MAX_REP_PDATA_SIZE;
-	    break;
-	}
-        case DAPL_PDATA_CONN_REJ:
-	{
-	    size = IB_MAX_REJ_PDATA_SIZE;
-	    break;
-	}
-        case DAPL_PDATA_CONN_DREQ:
-	{
-	    size = IB_MAX_DREQ_PDATA_SIZE;
-	    break;
-	}
-        case DAPL_PDATA_CONN_DREP:
-	{
-	    size = IB_MAX_DREP_PDATA_SIZE;
-	    break;
-	}
-        default:
-	{
-	    size = 0;
-	}
-    } /* end case */
-
-#if defined(DAPL_DBG) && 0
-    dapl_dbg_log (DAPL_DBG_TYPE_CM, "%s: returns %d\n", __FUNCTION__, size );
-#endif
-
-    return size;
+    return IB_MAX_REQ_PDATA_SIZE;
 }
 
 
diff --git a/trunk/ulp/dapl2/dapl/openib_cma/cm.c b/trunk/ulp/dapl2/dapl/openib_cma/cm.c
index c52e716..e0e034b 100644
--- a/trunk/ulp/dapl2/dapl/openib_cma/cm.c
+++ b/trunk/ulp/dapl2/dapl/openib_cma/cm.c
@@ -95,7 +95,7 @@ static void dapli_addr_resolve(struct dapl_cm_id *conn)
 			 ret, strerror(errno));
 		dapl_evd_connection_callback(conn,
 					     IB_CME_LOCAL_FAILURE,
-					     NULL, conn->ep);
+					     NULL, 0, conn->ep);
 	}
 }
 
@@ -149,7 +149,7 @@ static void dapli_route_resolve(struct dapl_cm_id *conn)
 
       bail:
 	dapl_evd_connection_callback(conn,
-				     IB_CME_LOCAL_FAILURE, NULL, conn->ep);
+				     IB_CME_LOCAL_FAILURE, NULL, 0, conn->ep);
 }
 
 dp_ib_cm_handle_t dapls_ib_cm_create(DAPL_EP *ep)
@@ -416,7 +416,8 @@ static void dapli_cm_active_cb(struct dapl_cm_id *conn,
 
 	dapl_os_unlock(lock);
 	if (conn)
-		dapl_evd_connection_callback(conn, ib_cm_event, pdata, conn->ep);
+		dapl_evd_connection_callback(conn, ib_cm_event, pdata,
+					     event->param.conn.private_data_len, conn->ep);
 }
 
 static void dapli_cm_passive_cb(struct dapl_cm_id *conn,
@@ -496,7 +497,8 @@ static void dapli_cm_passive_cb(struct dapl_cm_id *conn,
 
 	dapl_os_unlock(&conn->lock);
 	if (conn_recv)
-		dapls_cr_callback(conn_recv, ib_cm_event, pdata, conn_recv->sp);
+		dapls_cr_callback(conn_recv, ib_cm_event, pdata,
+				  event->param.conn.private_data_len, conn_recv->sp);
 }
 
 /************************ DAPL provider entry points **********************/
@@ -922,11 +924,6 @@ dapls_ib_reject_connection(IN dp_ib_cm_handle_t cm_handle,
 		return DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_CR);
 	}
 
-	if (private_data_size >
-	    dapls_ib_private_data_size(NULL, DAPL_PDATA_CONN_REJ,
-				       cm_handle->hca))
-		return DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG3);
-
 	/* setup pdata_hdr and users data, in CR pdata buffer */
 	dapl_os_memcpy(cm_handle->p_data, &pdata_hdr, offset);
 	if (private_data_size)
@@ -998,60 +995,10 @@ dapls_ib_cm_remote_addr(IN DAT_HANDLE dat_handle, OUT DAT_SOCK_ADDR6 * raddr)
 	return DAT_SUCCESS;
 }
 
-/*
- * dapls_ib_private_data_size
- *
- * Return the size of private data given a connection op type
- *
- * Input:
- *	prd_ptr		private data pointer
- *	conn_op		connection operation type
- *      hca_ptr         hca pointer, needed for transport type
- *
- * If prd_ptr is NULL, this is a query for the max size supported by
- * the provider, otherwise it is the actual size of the private data
- * contained in prd_ptr.
- *
- *
- * Output:
- *	None
- *
- * Returns:
- * 	length of private data
- *
- */
-int dapls_ib_private_data_size(IN DAPL_PRIVATE * prd_ptr,
-			       IN DAPL_PDATA_OP conn_op, IN DAPL_HCA * hca_ptr)
+int dapls_ib_private_data_size(
+	IN DAPL_HCA *hca_ptr)
 {
-	int size;
-
-	if (hca_ptr->ib_hca_handle->device->transport_type
-	    == IBV_TRANSPORT_IWARP)
-		return (IWARP_MAX_PDATA_SIZE - sizeof(struct dapl_pdata_hdr));
-
-	switch (conn_op) {
-
-	case DAPL_PDATA_CONN_REQ:
-		size = IB_MAX_REQ_PDATA_SIZE;
-		break;
-	case DAPL_PDATA_CONN_REP:
-		size = IB_MAX_REP_PDATA_SIZE;
-		break;
-	case DAPL_PDATA_CONN_REJ:
-		size = IB_MAX_REJ_PDATA_SIZE - sizeof(struct dapl_pdata_hdr);
-		break;
-	case DAPL_PDATA_CONN_DREQ:
-		size = IB_MAX_DREQ_PDATA_SIZE;
-		break;
-	case DAPL_PDATA_CONN_DREP:
-		size = IB_MAX_DREP_PDATA_SIZE;
-		break;
-	default:
-		size = 0;
-
-	}			/* end case */
-
-	return size;
+	return RDMA_MAX_PRIVATE_DATA;
 }
 
 /*
@@ -1238,7 +1185,7 @@ void dapli_cma_event_cb(void)
 
 			dapl_evd_connection_callback(conn,
 						     IB_CME_DESTINATION_UNREACHABLE,
-						     NULL, conn->ep);
+						     NULL, 0, conn->ep);
 			break;
 
 		case RDMA_CM_EVENT_ROUTE_ERROR:
@@ -1267,14 +1214,14 @@ void dapli_cma_event_cb(void)
 
 				dapl_evd_connection_callback(conn,
 							     IB_CME_DESTINATION_UNREACHABLE,
-							     NULL, conn->ep);
+							     NULL, 0, conn->ep);
 			}
 			break;
 
 		case RDMA_CM_EVENT_DEVICE_REMOVAL:
 			dapl_evd_connection_callback(conn,
 						     IB_CME_LOCAL_FAILURE,
-						     NULL, conn->ep);
+						     NULL, 0, conn->ep);
 			break;
 		case RDMA_CM_EVENT_CONNECT_REQUEST:
 		case RDMA_CM_EVENT_CONNECT_ERROR:
diff --git a/trunk/ulp/dapl2/dapl/openib_scm/cm.c b/trunk/ulp/dapl2/dapl/openib_scm/cm.c
index 105351c..4ac54dc 100644
--- a/trunk/ulp/dapl2/dapl/openib_scm/cm.c
+++ b/trunk/ulp/dapl2/dapl/openib_scm/cm.c
@@ -430,12 +430,12 @@ DAT_RETURN dapli_socket_disconnect(dp_ib_cm_handle_t cm_ptr)
 		if (ep_ptr->cr_ptr) {
 			dapls_cr_callback(cm_ptr,
 					  IB_CME_DISCONNECTED,
-					  NULL,
+					  NULL, 0,
 					  ((DAPL_CR *) ep_ptr->cr_ptr)->sp_ptr);
 		} else {
 			dapl_evd_connection_callback(ep_ptr->cm_handle,
 						     IB_CME_DISCONNECTED,
-						     NULL, ep_ptr);
+						     NULL, 0, ep_ptr);
 		}
 	}
 
@@ -506,7 +506,7 @@ static void dapli_socket_connected(dp_ib_cm_handle_t cm_ptr, int err)
 bail:
 	/* close socket, free cm structure and post error event */
 	dapls_ib_cm_free(cm_ptr, cm_ptr->ep);
-	dapl_evd_connection_callback(NULL, IB_CME_LOCAL_FAILURE, NULL, ep_ptr);
+	dapl_evd_connection_callback(NULL, IB_CME_LOCAL_FAILURE, NULL, 0, ep_ptr);
 }
 
 /*
@@ -833,7 +833,8 @@ ud_bail:
 #endif
 	{
 		ep_ptr->cm_handle = cm_ptr; /* only RC, multi CR's on UD */
-		dapl_evd_connection_callback(cm_ptr, event, cm_ptr->msg.p_data, ep_ptr);
+		dapl_evd_connection_callback(cm_ptr, event, cm_ptr->msg.p_data,
+					     DCM_MAX_PDATA_SIZE, ep_ptr);
 	}
 	return;
 
@@ -847,7 +848,8 @@ bail:
 	dapls_modify_qp_state(ep_ptr->qp_handle, IBV_QPS_ERR, 0, 0, 0);
 	closesocket(cm_ptr->socket);
 	cm_ptr->socket = DAPL_INVALID_SOCKET;
-	dapl_evd_connection_callback(NULL, event, cm_ptr->msg.p_data, ep_ptr);
+	dapl_evd_connection_callback(NULL, event, cm_ptr->msg.p_data,
+				     DCM_MAX_PDATA_SIZE, ep_ptr);
 }
 
 /*
@@ -1044,7 +1046,7 @@ static void dapli_socket_accept_data(ib_cm_srvc_handle_t acm_ptr)
 		/* trigger CR event and return SUCCESS */
 		dapls_cr_callback(acm_ptr,
 				  IB_CME_CONNECTION_REQUEST_PENDING,
-				  p_data, acm_ptr->sp);
+				  p_data, exp, acm_ptr->sp);
 	return;
 bail:
 	/* close socket, free cm structure, active will see close as rej */
@@ -1274,7 +1276,7 @@ ud_bail:
 #endif
 	{
 		cm_ptr->ep->cm_handle = cm_ptr; /* only RC, multi CR's on UD */
-		dapls_cr_callback(cm_ptr, event, NULL, cm_ptr->sp);
+		dapls_cr_callback(cm_ptr, event, NULL, 0, cm_ptr->sp);
 	}
 	return;
       
@@ -1285,7 +1287,7 @@ bail:
 #endif
 	dapls_modify_qp_state(cm_ptr->ep->qp_handle, IBV_QPS_ERR, 0, 0, 0);
 	dapls_ib_cm_free(cm_ptr, cm_ptr->ep);
-	dapls_cr_callback(cm_ptr, event, NULL, cm_ptr->sp);
+	dapls_cr_callback(cm_ptr, event, NULL, 0, cm_ptr->sp);
 }
 
 /*
@@ -1604,44 +1606,10 @@ dapls_ib_cm_remote_addr(IN DAT_HANDLE dat_handle,
 	return DAT_SUCCESS;
 }
 
-/*
- * dapls_ib_private_data_size
- *
- * Return the size of private data given a connection op type
- *
- * Input:
- *	prd_ptr		private data pointer
- *	conn_op		connection operation type
- *
- * If prd_ptr is NULL, this is a query for the max size supported by
- * the provider, otherwise it is the actual size of the private data
- * contained in prd_ptr.
- *
- *
- * Output:
- *	None
- *
- * Returns:
- * 	length of private data
- *
- */
-int dapls_ib_private_data_size(IN DAPL_PRIVATE * prd_ptr,
-			       IN DAPL_PDATA_OP conn_op, IN DAPL_HCA * hca_ptr)
+int dapls_ib_private_data_size(
+	IN DAPL_HCA *hca_ptr)
 {
-	int size;
-
-	switch (conn_op) {
-		case DAPL_PDATA_CONN_REQ:
-		case DAPL_PDATA_CONN_REP:
-		case DAPL_PDATA_CONN_REJ:
-		case DAPL_PDATA_CONN_DREQ:
-		case DAPL_PDATA_CONN_DREP:
-			size = DCM_MAX_PDATA_SIZE;
-			break;
-		default:
-			size = 0;
-	}			
-	return size;
+	return DCM_MAX_PDATA_SIZE;
 }
 
 /*
diff --git a/trunk/ulp/dapl2/dapl/openib_ucm/cm.c b/trunk/ulp/dapl2/dapl/openib_ucm/cm.c
index b51556a..d05d112 100644
--- a/trunk/ulp/dapl2/dapl/openib_ucm/cm.c
+++ b/trunk/ulp/dapl2/dapl/openib_ucm/cm.c
@@ -798,9 +798,9 @@ static void ucm_disconnect_final(dp_ib_cm_handle_t cm)
 	dapl_os_unlock(&cm->lock);
 
 	if (cm->sp) 
-		dapls_cr_callback(cm, IB_CME_DISCONNECTED, NULL, cm->sp);
+		dapls_cr_callback(cm, IB_CME_DISCONNECTED, NULL, 0, cm->sp);
 	else
-		dapl_evd_connection_callback(cm, IB_CME_DISCONNECTED, NULL, cm->ep);
+		dapl_evd_connection_callback(cm, IB_CME_DISCONNECTED, NULL, 0, cm->ep);
 }
 
 /*
@@ -911,7 +911,7 @@ dapli_cm_connect(DAPL_EP *ep, dp_ib_cm_handle_t cm)
 #endif
 		dapl_evd_connection_callback(cm, 
 					     IB_CME_DESTINATION_UNREACHABLE,
-					     NULL, ep);
+					     NULL, 0, ep);
 		
 		return DAT_ERROR(DAT_INVALID_ADDRESS, 
 				 DAT_INVALID_ADDRESS_UNREACHABLE);
@@ -1126,14 +1126,14 @@ ud_bail:
 		cm->ep->cm_handle = cm; /* only RC, multi CR's on UD */
 		dapl_evd_connection_callback(cm,
 					     IB_CME_CONNECTED,
-					     cm->msg.p_data, cm->ep);
+					     cm->msg.p_data, ntohs(cm->msg.p_size), cm->ep);
 	}
 	return;
 bail:
 	if (cm->msg.saddr.ib.qp_type != IBV_QPT_UD) 
 		dapls_ib_reinit_ep(cm->ep); /* reset QP state */
 
-	dapl_evd_connection_callback(NULL, event, cm->msg.p_data, cm->ep);
+	dapl_evd_connection_callback(NULL, event, cm->msg.p_data, ntohs(cm->msg.p_size), cm->ep);
 	dapls_ib_cm_free(cm, NULL); 
 }
 
@@ -1204,7 +1204,7 @@ static void ucm_accept(ib_cm_srvc_handle_t cm, ib_cm_msg_t *msg)
 		/* trigger CR event and return SUCCESS */
 		dapls_cr_callback(acm,
 				  IB_CME_CONNECTION_REQUEST_PENDING,
-				  acm->msg.p_data, acm->sp);
+				  acm->msg.p_data, ntohs(msg->p_size), acm->sp);
 	return;
 
 bail:
@@ -1295,14 +1295,14 @@ static void ucm_accept_rtu(dp_ib_cm_handle_t cm, ib_cm_msg_t *msg)
 	} else {
 #endif
 		cm->ep->cm_handle = cm; /* only RC, multi CR's on UD */
-		dapls_cr_callback(cm, IB_CME_CONNECTED, NULL, cm->sp);
+		dapls_cr_callback(cm, IB_CME_CONNECTED, NULL, 0, cm->sp);
 	}
 	return;
 bail:
 	if (cm->msg.saddr.ib.qp_type != IBV_QPT_UD) 
 		dapls_ib_reinit_ep(cm->ep);	/* reset QP state */
 	dapls_ib_cm_free(cm, cm->ep);
-	dapls_cr_callback(cm, IB_CME_LOCAL_FAILURE, NULL, cm->sp);
+	dapls_cr_callback(cm, IB_CME_LOCAL_FAILURE, NULL, 0, cm->sp);
 }
 
 /*
@@ -1354,7 +1354,7 @@ static int ucm_reply(dp_ib_cm_handle_t cm)
 		} else 
 #endif
 			dapls_cr_callback(cm, IB_CME_LOCAL_FAILURE, 
-					  NULL, cm->sp);
+					  NULL, 0, cm->sp);
 		return -1;
 	}
 	dapl_os_get_time(&cm->timer); /* RTU expected */
@@ -1842,44 +1842,10 @@ dapls_ib_cm_remote_addr(IN DAT_HANDLE dat_handle,
 	return DAT_SUCCESS;
 }
 
-/*
- * dapls_ib_private_data_size
- *
- * Return the size of private data given a connection op type
- *
- * Input:
- *	prd_ptr		private data pointer
- *	conn_op		connection operation type
- *
- * If prd_ptr is NULL, this is a query for the max size supported by
- * the provider, otherwise it is the actual size of the private data
- * contained in prd_ptr.
- *
- *
- * Output:
- *	None
- *
- * Returns:
- * 	length of private data
- *
- */
-int dapls_ib_private_data_size(IN DAPL_PRIVATE * prd_ptr,
-			       IN DAPL_PDATA_OP conn_op, IN DAPL_HCA * hca_ptr)
+int dapls_ib_private_data_size(
+	IN DAPL_HCA *hca_ptr)
 {
-	int size;
-
-	switch (conn_op) {
-	case DAPL_PDATA_CONN_REQ:
-	case DAPL_PDATA_CONN_REP:
-	case DAPL_PDATA_CONN_REJ:
-	case DAPL_PDATA_CONN_DREQ:
-	case DAPL_PDATA_CONN_DREP:
-		size = DCM_MAX_PDATA_SIZE;
-		break;
-	default:
-		size = 0;
-	}			
-	return size;
+	return DCM_MAX_PDATA_SIZE;
 }
 
 /*






More information about the ofw mailing list