[ofa-general] [PATCH 6/6][uDAPL v1] dapl scm: better cm debug output in non-debug builds

Arlin Davis arlin.r.davis at intel.com
Thu Aug 14 16:20:01 PDT 2008



Signed-off by: Arlin Davis ardavis at ichips.intel.com
---
 dapl/openib_scm/dapl_ib_cm.c |  161 ++++++++++++++++++++++++++++--------------
 1 files changed, 109 insertions(+), 52 deletions(-)

diff --git a/dapl/openib_scm/dapl_ib_cm.c b/dapl/openib_scm/dapl_ib_cm.c
index 03b0f12..3dcdbad 100644
--- a/dapl/openib_scm/dapl_ib_cm.c
+++ b/dapl/openib_scm/dapl_ib_cm.c
@@ -229,8 +229,10 @@ dapli_socket_connected(ib_cm_handle_t cm_ptr, int err)
 	len = writev(cm_ptr->socket, iovec, (cm_ptr->dst.p_size ? 2:1));
     	if (len != (ntohl(cm_ptr->dst.p_size) + sizeof(ib_qp_cm_t))) {
 		dapl_log(DAPL_DBG_TYPE_ERR, 
-			 " connect write: ERR %s, wcnt=%d\n",
-			 strerror(errno), len); 
+			 " CONN_PENDING write: ERR %s, wcnt=%d -> %s\n",
+			 strerror(errno), len,
+			 inet_ntoa(((struct sockaddr_in *)
+		           ep_ptr->param.remote_ia_address_ptr)->sin_addr)); 
 		goto bail;
 	}
 	dapl_dbg_log(DAPL_DBG_TYPE_CM, 
@@ -288,7 +290,7 @@ dapli_socket_connect(DAPL_EP		*ep_ptr,
         if (ret < 0 || fcntl(cm_ptr->socket,
                               F_SETFL, ret | O_NONBLOCK) < 0) {
                 dapl_log(DAPL_DBG_TYPE_ERR,
-                         " connect: fcntl on socket %d ERR %d %s\n",
+                         " socket connect: fcntl on socket %d ERR %d %s\n",
                          cm_ptr->socket, ret,
                          strerror(errno));
                 goto bail;
@@ -298,10 +300,10 @@ dapli_socket_connect(DAPL_EP		*ep_ptr,
 	ret = connect(cm_ptr->socket, r_addr, sizeof(*r_addr));
 	if (ret && errno != EINPROGRESS) {
 		dapl_log(DAPL_DBG_TYPE_ERR,
-			     " connect ERROR: %s on %s r_qual %d\n",
-			     strerror(errno), 
-		     	     inet_ntoa(((struct sockaddr_in *)r_addr)->sin_addr),
-			     (unsigned int)r_qual);
+			 " socket connect ERROR: %s -> %s r_qual %d\n",
+			 strerror(errno), 
+		     	 inet_ntoa(((struct sockaddr_in *)r_addr)->sin_addr),
+			 (unsigned int)r_qual);
 		dapli_cm_destroy(cm_ptr);
 		return DAT_INVALID_ADDRESS;
 	} 
@@ -312,15 +314,24 @@ dapli_socket_connect(DAPL_EP		*ep_ptr,
 	cm_ptr->dst.lid = 
 		htons(dapli_get_lid(ia_ptr->hca_ptr->ib_hca_handle, 
 				    (uint8_t)ia_ptr->hca_ptr->port_num));
-	if (cm_ptr->dst.lid == 0xffff)
+	if (cm_ptr->dst.lid == 0xffff) {
+		dapl_log(DAPL_DBG_TYPE_ERR, 
+			 " CONNECT: query LID ERR %s -> %s\n",
+			 strerror(errno), 
+			 inet_ntoa(((struct sockaddr_in *)r_addr)->sin_addr));
 		goto bail;
+	}
 
         /* in network order */
         if (ibv_query_gid(ia_ptr->hca_ptr->ib_hca_handle,
 				    (uint8_t)ia_ptr->hca_ptr->port_num,
-				    0,
-                                    &cm_ptr->dst.gid))
+				    0, &cm_ptr->dst.gid)) {
+		dapl_log(DAPL_DBG_TYPE_ERR, 
+			 " CONNECT: query GID ERR %s -> %s\n",
+			 strerror(errno), 
+			 inet_ntoa(((struct sockaddr_in *)r_addr)->sin_addr));
 		goto bail;
+	}
 
 	/* save references */
 	cm_ptr->hca = ia_ptr->hca_ptr;
@@ -347,8 +358,9 @@ dapli_socket_connect(DAPL_EP		*ep_ptr,
 	return DAT_SUCCESS;
 bail:
 	dapl_log(DAPL_DBG_TYPE_ERR,
-		 " connect ERROR: %s query lid(0x%x)/gid on %s r_qual %d\n",
-		 strerror(errno),ntohs(cm_ptr->dst.lid), 
+		 " socket connect ERROR: %s query lid(0x%x)/gid"
+		 " -> %s r_qual %d\n",
+		 strerror(errno), ntohs(cm_ptr->dst.lid), 
 		 inet_ntoa(((struct sockaddr_in *)r_addr)->sin_addr),
 		 (unsigned int)r_qual);
 
@@ -377,16 +389,20 @@ dapli_socket_connect_rtu(ib_cm_handle_t	cm_ptr)
 	iovec[0].iov_len  = sizeof(ib_qp_cm_t);
 	len = readv(cm_ptr->socket, iovec, 1);
 	if (len != sizeof(ib_qp_cm_t) || ntohs(cm_ptr->dst.ver) != DSCM_VER) {
-		dapl_dbg_log(DAPL_DBG_TYPE_ERR, 
-			     " connect_rtu read: ERR %s, rcnt=%d, ver=%d\n",
-			     strerror(errno), len, cm_ptr->dst.ver); 
+		dapl_log(DAPL_DBG_TYPE_ERR, 
+		     " CONN_RTU read: ERR %s, rcnt=%d, ver=%d -> %s\n",
+		     strerror(errno), len, cm_ptr->dst.ver,
+		     inet_ntoa(((struct sockaddr_in *)
+		         ep_ptr->param.remote_ia_address_ptr)->sin_addr)); 
 		goto bail;
 	}
 	/* check for consumer reject */
 	if (cm_ptr->dst.rej) {
-		dapl_dbg_log(DAPL_DBG_TYPE_CM, 
-			     " connect_rtu read: PEER REJ reason=0x%x\n",
-			     ntohs(cm_ptr->dst.rej)); 
+		dapl_log(DAPL_DBG_TYPE_CM, 
+			 " CONN_RTU read: PEER REJ reason=0x%x -> %s\n",
+			 ntohs(cm_ptr->dst.rej),
+			 inet_ntoa(((struct sockaddr_in *)
+			   ep_ptr->param.remote_ia_address_ptr)->sin_addr));
 		event = IB_CME_DESTINATION_REJECT_PRIVATE_DATA;
 		goto bail;
 	}
@@ -403,16 +419,18 @@ dapli_socket_connect_rtu(ib_cm_handle_t	cm_ptr)
 			sizeof(ep_ptr->remote_ia_address));
 
 	dapl_dbg_log(DAPL_DBG_TYPE_EP, 
-		     " connect_rtu: DST %s port=0x%x lid=0x%x, qpn=0x%x, psize=%d\n",
+		     " CONN_RTU: DST %s port=0x%x lid=0x%x, qpn=0x%x, psize=%d\n",
 		     inet_ntoa(((struct sockaddr_in *)&cm_ptr->dst.ia_address)->sin_addr),
 		     cm_ptr->dst.port, cm_ptr->dst.lid, 
 		     cm_ptr->dst.qpn, cm_ptr->dst.p_size); 
 
 	/* validate private data size before reading */
 	if (cm_ptr->dst.p_size > IB_MAX_REP_PDATA_SIZE) {
-		dapl_dbg_log(DAPL_DBG_TYPE_ERR, 
-			     " connect_rtu read: psize (%d) wrong\n",
-			     cm_ptr->dst.p_size ); 
+		dapl_log(DAPL_DBG_TYPE_ERR, 
+			 " CONN_RTU read: psize (%d) wrong -> %s\n",
+			 cm_ptr->dst.p_size,
+			 inet_ntoa(((struct sockaddr_in *)
+			   ep_ptr->param.remote_ia_address_ptr)->sin_addr)); 
 		goto bail;
 	}
 
@@ -423,21 +441,35 @@ dapli_socket_connect_rtu(ib_cm_handle_t	cm_ptr)
 		iovec[0].iov_len  = cm_ptr->dst.p_size;
 		len = readv(cm_ptr->socket, iovec, 1);
 		if (len != cm_ptr->dst.p_size) {
-			dapl_dbg_log(DAPL_DBG_TYPE_ERR, 
-				" connect_rtu read pdata: ERR %s, rcnt=%d\n",
-				strerror(errno), len); 
+			dapl_log(DAPL_DBG_TYPE_ERR, 
+			    " CONN_RTU read pdata: ERR %s, rcnt=%d -> %s\n",
+			    strerror(errno), len,
+			    inet_ntoa(((struct sockaddr_in *)
+			      ep_ptr->param.remote_ia_address_ptr)->sin_addr)); 
 			goto bail;
 		}
 	}
 
 	/* modify QP to RTR and then to RTS with remote info */
 	if (dapls_modify_qp_state(ep_ptr->qp_handle, 
-				  IBV_QPS_RTR, &cm_ptr->dst) != DAT_SUCCESS)
+				  IBV_QPS_RTR, &cm_ptr->dst) != DAT_SUCCESS) {
+		dapl_log(DAPL_DBG_TYPE_ERR, 
+			 " CONN_RTU: QPS_RTR ERR %s -> %s\n",
+			 strerror(errno), 
+			 inet_ntoa(((struct sockaddr_in *)
+			   ep_ptr->param.remote_ia_address_ptr)->sin_addr)); 
 		goto bail;
+	}
 
 	if (dapls_modify_qp_state(ep_ptr->qp_handle, 
-				   IBV_QPS_RTS, &cm_ptr->dst) != DAT_SUCCESS)
+				  IBV_QPS_RTS, &cm_ptr->dst) != DAT_SUCCESS) {
+		dapl_log(DAPL_DBG_TYPE_ERR, 
+			 " CONN_RTU: QPS_RTS ERR %s -> %s\n",
+			 strerror(errno), 
+			 inet_ntoa(((struct sockaddr_in *)
+			   ep_ptr->param.remote_ia_address_ptr)->sin_addr)); 
 		goto bail;
+	}
 		 
 	ep_ptr->qp_state = IB_QP_STATE_RTS;
 
@@ -488,8 +520,9 @@ dapli_socket_listen(DAPL_IA		*ia_ptr,
 	
 	/* bind, listen, set sockopt, accept, exchange data */
 	if ((cm_ptr->socket = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
-		dapl_dbg_log (DAPL_DBG_TYPE_ERR, 
-				"socket for listen returned %d\n", errno);
+		dapl_log(DAPL_DBG_TYPE_ERR, 
+			 " ERR: listen socket create: %s\n", 
+			 strerror(errno));
 		dat_status = DAT_INSUFFICIENT_RESOURCES;
 		goto bail;
 	}
@@ -501,9 +534,9 @@ dapli_socket_listen(DAPL_IA		*ia_ptr,
 
 	if ((bind(cm_ptr->socket,(struct sockaddr*)&addr, sizeof(addr)) < 0) ||
 	    (listen(cm_ptr->socket, 128) < 0)) {
-		dapl_dbg_log( DAPL_DBG_TYPE_CM,
-				" listen: ERROR %s on conn_qual 0x%x\n",
-				strerror(errno),serviceID); 
+		dapl_dbg_log(DAPL_DBG_TYPE_CM,
+			     " listen: ERROR %s on conn_qual 0x%x\n",
+			     strerror(errno),serviceID); 
 		if (errno == EADDRINUSE)
 			dat_status = DAT_CONN_QUAL_IN_USE;
 		else
@@ -556,7 +589,7 @@ dapli_socket_accept(ib_cm_srvc_handle_t cm_ptr)
 				(struct sockaddr*)&acm_ptr->dst.ia_address, 
 				(socklen_t*)&len);
 	if (acm_ptr->socket < 0) {
-		dapl_dbg_log(DAPL_DBG_TYPE_ERR, 
+		dapl_log(DAPL_DBG_TYPE_ERR, 
 			" accept: ERR %s on FD %d l_cr %p\n",
 			strerror(errno),cm_ptr->socket,cm_ptr); 
 		goto bail;
@@ -589,7 +622,7 @@ dapli_socket_accept_data(ib_cm_srvc_handle_t acm_ptr)
 	len = read(acm_ptr->socket, &acm_ptr->dst, sizeof(ib_qp_cm_t));
 	if (len != sizeof(ib_qp_cm_t) || 
 	    ntohs(acm_ptr->dst.ver) != DSCM_VER) {
-		dapl_dbg_log(DAPL_DBG_TYPE_ERR, 
+		dapl_log(DAPL_DBG_TYPE_ERR, 
 			     " accept read: ERR %s, rcnt=%d, ver=%d\n",
 			     strerror(errno), len, acm_ptr->dst.ver); 
 		goto bail;
@@ -622,7 +655,7 @@ dapli_socket_accept_data(ib_cm_srvc_handle_t acm_ptr)
 		len = read( acm_ptr->socket, 
 			    acm_ptr->p_data, acm_ptr->dst.p_size);
 		if (len != acm_ptr->dst.p_size) {
-			dapl_dbg_log(DAPL_DBG_TYPE_ERR, 
+			dapl_log(DAPL_DBG_TYPE_ERR, 
 				     " accept read pdata: ERR %s, rcnt=%d\n",
 				     strerror(errno), len); 
 			goto bail;
@@ -669,20 +702,30 @@ dapli_socket_accept_usr(DAPL_EP		*ep_ptr,
 		return DAT_INTERNAL_ERROR;
 	
 	dapl_dbg_log(DAPL_DBG_TYPE_EP, 
-		     " accept_usr: remote port=0x%x lid=0x%x"
+		     " ACCEPT_USR: remote port=0x%x lid=0x%x"
 		     " qpn=0x%x psize=%d\n",
 		     cm_ptr->dst.port, cm_ptr->dst.lid,
 		     cm_ptr->dst.qpn, cm_ptr->dst.p_size); 
 
 	/* modify QP to RTR and then to RTS with remote info already read */
 	if (dapls_modify_qp_state(ep_ptr->qp_handle, 
-				  IBV_QPS_RTR, &cm_ptr->dst) != DAT_SUCCESS)
+				  IBV_QPS_RTR, &cm_ptr->dst) != DAT_SUCCESS) {
+		dapl_log(DAPL_DBG_TYPE_ERR, 
+			 " ACCEPT_USR: QPS_RTR ERR %s -> %s\n",
+			 strerror(errno), 
+			 inet_ntoa(((struct sockaddr_in *)
+				&cm_ptr->dst.ia_address)->sin_addr)); 
 		goto bail;
-
+	}
 	if (dapls_modify_qp_state(ep_ptr->qp_handle, 
-				  IBV_QPS_RTS, &cm_ptr->dst) != DAT_SUCCESS)
+				  IBV_QPS_RTS, &cm_ptr->dst) != DAT_SUCCESS) {
+		dapl_log(DAPL_DBG_TYPE_ERR, 
+			 " ACCEPT_USR: QPS_RTS ERR %s -> %s\n",
+			 strerror(errno), 
+			 inet_ntoa(((struct sockaddr_in *)
+				&cm_ptr->dst.ia_address)->sin_addr)); 
 		goto bail;
-
+	}
 	ep_ptr->qp_state = IB_QP_STATE_RTS;
 	
 	/* save remote address information */
@@ -695,15 +738,26 @@ dapli_socket_accept_usr(DAPL_EP		*ep_ptr,
 	cm_ptr->dst.port = htons(ia_ptr->hca_ptr->port_num);
 	cm_ptr->dst.lid = htons(dapli_get_lid(ia_ptr->hca_ptr->ib_hca_handle, 
 				        (uint8_t)ia_ptr->hca_ptr->port_num));
-	if (cm_ptr->dst.lid == 0xffff)
+	if (cm_ptr->dst.lid == 0xffff) {
+		dapl_log(DAPL_DBG_TYPE_ERR, 
+			 " ACCEPT_USR: query LID ERR %s -> %s\n",
+			 strerror(errno), 
+			 inet_ntoa(((struct sockaddr_in *)
+				&cm_ptr->dst.ia_address)->sin_addr)); 
 		goto bail;
+	}
 
         /* in network order */
 	if (ibv_query_gid(ia_ptr->hca_ptr->ib_hca_handle,
 			  (uint8_t)ia_ptr->hca_ptr->port_num,
-			  0,
-			  &cm_ptr->dst.gid))
+			  0, &cm_ptr->dst.gid)) {
+		dapl_log(DAPL_DBG_TYPE_ERR, 
+			 " ACCEPT_USR: query GID ERR %s -> %s\n",
+			 strerror(errno), 
+			 inet_ntoa(((struct sockaddr_in *)
+				&cm_ptr->dst.ia_address)->sin_addr)); 
 		goto bail;
+	}
 
 	cm_ptr->dst.ia_address = ia_ptr->hca_ptr->hca_address;
 	cm_ptr->dst.p_size = htonl(p_size);
@@ -715,18 +769,20 @@ dapli_socket_accept_usr(DAPL_EP		*ep_ptr,
 	}
 	len = writev(cm_ptr->socket, iovec, (p_size ? 2:1));
     	if (len != (p_size + sizeof(ib_qp_cm_t))) {
-		dapl_dbg_log(DAPL_DBG_TYPE_ERR, 
-			     " accept_rtu: ERR %s, wcnt=%d\n",
-			     strerror(errno), len); 
+		dapl_log(DAPL_DBG_TYPE_ERR, 
+			 " ACCEPT_USR: ERR %s, wcnt=%d -> %s\n",
+			 strerror(errno), len,
+			 inet_ntoa(((struct sockaddr_in *)
+			     &cm_ptr->dst.ia_address)->sin_addr)); 
 		goto bail;
 	}
 	dapl_dbg_log(DAPL_DBG_TYPE_CM, 
-		     " accept_usr: local port=0x%x lid=0x%x"
+		     " ACCEPT_USR: local port=0x%x lid=0x%x"
 		     " qpn=0x%x psize=%d\n",
 		     ntohs(cm_ptr->dst.port), ntohs(cm_ptr->dst.lid), 
 		     ntohl(cm_ptr->dst.qpn), ntohl(cm_ptr->dst.p_size)); 
         dapl_dbg_log(DAPL_DBG_TYPE_CM,
-                     " accept_usr SRC GID subnet %016llx id %016llx\n",
+                     " ACCEPT_USR SRC GID subnet %016llx id %016llx\n",
                      (unsigned long long) 
 			cpu_to_be64(cm_ptr->dst.gid.global.subnet_prefix),
                      (unsigned long long) 
@@ -745,7 +801,6 @@ dapli_socket_accept_usr(DAPL_EP		*ep_ptr,
 	dapl_dbg_log( DAPL_DBG_TYPE_EP," PASSIVE: accepted!\n" ); 
 	return DAT_SUCCESS;
 bail:
-	dapl_dbg_log(DAPL_DBG_TYPE_ERR," accept_rtu: ERR !QP_RTR_RTS \n"); 
 	dapli_cm_destroy(cm_ptr);
 	dapls_ib_reinit_ep(ep_ptr); /* reset QP state */
 	return DAT_INTERNAL_ERROR;
@@ -763,9 +818,11 @@ dapli_socket_accept_rtu(ib_cm_handle_t	cm_ptr)
 	/* complete handshake after final QP state change */
 	len = read(cm_ptr->socket, &rtu_data, sizeof(rtu_data));
 	if (len != sizeof(rtu_data) || ntohs(rtu_data) != 0x0e0f) {
-		dapl_dbg_log(DAPL_DBG_TYPE_ERR, 
-			     " accept_rtu: ERR %s, rcnt=%d rdata=%x\n",
-			     strerror(errno), len, ntohs(rtu_data)); 
+		dapl_log(DAPL_DBG_TYPE_ERR, 
+			 " ACCEPT_RTU: ERR %s, rcnt=%d rdata=%x\n",
+			 strerror(errno), len, ntohs(rtu_data),
+			 inet_ntoa(((struct sockaddr_in *)
+				&cm_ptr->dst.ia_address)->sin_addr)); 
 		goto bail;
 	}
 
-- 
1.5.2.5





More information about the general mailing list