[ofa-general] [PATCH] uDAPL v2: scm, ucm: UD QP support was broken when porting to common openib code base.

Arlin Davis arlin.r.davis at intel.com
Thu Sep 3 12:28:13 PDT 2009


create remote_ah was moved out of modify_qp_state function but not
included in the RTU and ACCEPT code for UD QP's. qp type check
should be on daddr not saddr in ucm cm code.

QP number must be converted to host order before supplying remote_ah,
and qp number to consumer.

Modify QP state to RTR for UD QP mask setting incorrect.

Signed-off-by: Arlin Davis <arlin.r.davis at intel.com>
---
 dapl/openib_common/qp.c |    1 +
 dapl/openib_scm/cm.c    |   32 ++++++++++++++++++++++++++++----
 dapl/openib_ucm/cm.c    |    6 +++---
 3 files changed, 32 insertions(+), 7 deletions(-)

diff --git a/dapl/openib_common/qp.c b/dapl/openib_common/qp.c
index 73d2c3f..581fc83 100644
--- a/dapl/openib_common/qp.c
+++ b/dapl/openib_common/qp.c
@@ -415,6 +415,7 @@ dapls_modify_qp_state(IN ib_qp_handle_t		qp_handle,
 
 		/* UD: already in RTR, RTS state */
 		if (qp_handle->qp_type == IBV_QPT_UD) {
+			mask = IBV_QP_STATE;
 			if (ep_ptr->qp_state == IBV_QPS_RTR ||
 				ep_ptr->qp_state == IBV_QPS_RTS)
 				return DAT_SUCCESS;
diff --git a/dapl/openib_scm/cm.c b/dapl/openib_scm/cm.c
index 8b85e15..06fff95 100644
--- a/dapl/openib_scm/cm.c
+++ b/dapl/openib_scm/cm.c
@@ -772,11 +772,16 @@ ud_bail:
 			goto bail;
 		}
 
+		dapl_log(DAPL_DBG_TYPE_CM, 
+			" CONN_RTU: UD AH %p for lid 0x%x qpn 0x%x\n", 
+			cm_ptr->ah, ntohs(cm_ptr->msg.saddr.ib.lid),
+			ntohl(cm_ptr->msg.saddr.ib.qpn));
+
 		/* post EVENT, modify_qp created ah */
 		xevent.status = 0;
 		xevent.type = DAT_IB_UD_REMOTE_AH;
 		xevent.remote_ah.ah = cm_ptr->ah;
-		xevent.remote_ah.qpn = cm_ptr->msg.saddr.ib.qpn;
+		xevent.remote_ah.qpn = ntohl(cm_ptr->msg.saddr.ib.qpn);
 		dapl_os_memcpy(&xevent.remote_ah.ia_addr,
 			       &ep_ptr->remote_ia_address,
 			       sizeof(union dcm_addr));
@@ -1153,6 +1158,7 @@ dapli_socket_accept_usr(DAPL_EP * ep_ptr,
 void dapli_socket_accept_rtu(dp_ib_cm_handle_t cm_ptr)
 {
 	int len;
+	ib_cm_events_t event = IB_CME_CONNECTED;
 
 	/* complete handshake after final QP state change, VER and OP */
 	len = recv(cm_ptr->socket, (char *)&cm_ptr->msg, 4, 0);
@@ -1162,6 +1168,7 @@ void dapli_socket_accept_rtu(dp_ib_cm_handle_t cm_ptr)
 			 len, ntohs(cm_ptr->msg.op),
 			 inet_ntoa(((struct sockaddr_in *)
 				    &cm_ptr->msg.daddr.so)->sin_addr));
+		event = IB_CME_DESTINATION_REJECT;
 		goto bail;
 	}
 
@@ -1175,11 +1182,28 @@ void dapli_socket_accept_rtu(dp_ib_cm_handle_t cm_ptr)
 	if (cm_ptr->msg.saddr.ib.qp_type == IBV_QPT_UD) {
 		DAT_IB_EXTENSION_EVENT_DATA xevent;
 
+		ib_pd_handle_t pd_handle = 
+			((DAPL_PZ *)cm_ptr->ep->param.pz_handle)->pd_handle;
+
+		cm_ptr->ah = dapls_create_ah(cm_ptr->hca, pd_handle,
+					     cm_ptr->ep->qp_handle,
+					     cm_ptr->msg.saddr.ib.lid, 
+					     NULL);
+		if (!cm_ptr->ah) {
+			event = IB_CME_LOCAL_FAILURE;
+			goto bail;
+		}
+
+		dapl_log(DAPL_DBG_TYPE_CM, 
+			" CONN_RTU: UD AH %p for lid 0x%x qpn 0x%x\n", 
+			cm_ptr->ah, ntohs(cm_ptr->msg.saddr.ib.lid),
+			ntohl(cm_ptr->msg.saddr.ib.qpn));
+
 		/* post EVENT, modify_qp created ah */
 		xevent.status = 0;
 		xevent.type = DAT_IB_UD_PASSIVE_REMOTE_AH;
 		xevent.remote_ah.ah = cm_ptr->ah;
-		xevent.remote_ah.qpn = cm_ptr->msg.saddr.ib.qpn;
+		xevent.remote_ah.qpn = ntohl(cm_ptr->msg.saddr.ib.qpn);
 		dapl_os_memcpy(&xevent.remote_ah.ia_addr,
 			       &cm_ptr->msg.daddr.so,
 			       sizeof(union dcm_addr));
@@ -1200,14 +1224,14 @@ void dapli_socket_accept_rtu(dp_ib_cm_handle_t cm_ptr)
 	} else {
 #endif
 		cm_ptr->ep->cm_handle = cm_ptr; /* only RC, multi CR's on UD */
-		dapls_cr_callback(cm_ptr, IB_CME_CONNECTED, NULL, cm_ptr->sp);
+		dapls_cr_callback(cm_ptr, event, NULL, cm_ptr->sp);
 	}
 	return;
       
 bail:
 	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, IB_CME_DESTINATION_REJECT, NULL, cm_ptr->sp);
+	dapls_cr_callback(cm_ptr, event, NULL, cm_ptr->sp);
 }
 
 /*
diff --git a/dapl/openib_ucm/cm.c b/dapl/openib_ucm/cm.c
index ab3823e..a2db64e 100644
--- a/dapl/openib_ucm/cm.c
+++ b/dapl/openib_ucm/cm.c
@@ -930,7 +930,7 @@ ud_bail:
 		xevent.status = 0;
 		xevent.type = DAT_IB_UD_REMOTE_AH;
 		xevent.remote_ah.ah = cm->hca->ib_trans.ah[lid];
-		xevent.remote_ah.qpn = cm->msg.daddr.ib.qpn;
+		xevent.remote_ah.qpn = ntohl(cm->msg.daddr.ib.qpn);
 		dapl_os_memcpy(&xevent.remote_ah.ia_addr,
 			       &cm->msg.daddr,
 			       sizeof(union dcm_addr));
@@ -1070,7 +1070,7 @@ static void ucm_accept_rtu(dp_ib_cm_handle_t cm, ib_cm_msg_t *msg)
 	dapl_dbg_log(DAPL_DBG_TYPE_CM, " PASSIVE: connected!\n");
 
 #ifdef DAT_EXTENSIONS
-	if (cm->msg.saddr.ib.qp_type == IBV_QPT_UD) {
+	if (cm->msg.daddr.ib.qp_type == IBV_QPT_UD) {
 		DAT_IB_EXTENSION_EVENT_DATA xevent;
 		uint16_t lid = ntohs(cm->msg.daddr.ib.lid);
 		
@@ -1078,7 +1078,7 @@ static void ucm_accept_rtu(dp_ib_cm_handle_t cm, ib_cm_msg_t *msg)
 		xevent.status = 0;
 		xevent.type = DAT_IB_UD_PASSIVE_REMOTE_AH;
 		xevent.remote_ah.ah = cm->hca->ib_trans.ah[lid];
-		xevent.remote_ah.qpn = cm->msg.daddr.ib.qpn;
+		xevent.remote_ah.qpn = ntohl(cm->msg.daddr.ib.qpn);
 		dapl_os_memcpy(&xevent.remote_ah.ia_addr,
 			       &cm->msg.daddr,
 			       sizeof(cm->msg.daddr));
-- 
1.5.2.5





More information about the general mailing list