[ofa-general] [PATCH 2/4][v2] dapl: add support for logging errors in non-debug build.

Davis, Arlin R arlin.r.davis at intel.com
Fri Apr 4 16:40:43 PDT 2008


Add debug logging (stdout, syslog) for error cases during
device open, cm, async, and dto operations. Default settings
are ERR for DAPL_DBG_TYPE, and stdout for DAPL_DBG_DEST.

Change default configuration to build non-debug.

Signed-off by: Arlin Davis ardavis at ichips.intel.com
---
 configure.in                   |    4 +-
 dapl/common/dapl_debug.c       |    2 -
 dapl/common/dapl_evd_util.c    |    8 +-
 dapl/include/dapl_debug.h      |   10 ++-
 dapl/openib_cma/dapl_ib_cm.c   |  196
+++++++++++++++++++++++-----------------
 dapl/openib_cma/dapl_ib_util.c |   87 +++++++++---------
 dapl/udapl/dapl_init.c         |   16 +++-
 dapl/udapl/linux/dapl_osd.h    |    2 +-
 8 files changed, 179 insertions(+), 146 deletions(-)

diff --git a/configure.in b/configure.in
index eaf597b..d1c2664 100644
--- a/configure.in
+++ b/configure.in
@@ -42,12 +42,12 @@ AM_CONDITIONAL(HAVE_LD_VERSION_SCRIPT, test
"$ac_cv_version_script" = "yes")
 
 dnl Support debug mode build - if enable-debug provided the DEBUG
variable is set 
 AC_ARG_ENABLE(debug,
-[  --enable-debug Turn on debug mode, default=on],
+[  --enable-debug Turn on debug mode, default=off],
 [case "${enableval}" in
   yes) debug=true ;;
   no)  debug=false ;;
   *) AC_MSG_ERROR(bad value ${enableval} for --enable-debug) ;;
-esac],[debug=true])
+esac],[debug=false])
 AM_CONDITIONAL(DEBUG, test x$debug = xtrue)
 
 dnl Support ib_extension build - if enable-ext-type == ib 
diff --git a/dapl/common/dapl_debug.c b/dapl/common/dapl_debug.c
index 7ddce52..cbc356c 100644
--- a/dapl/common/dapl_debug.c
+++ b/dapl/common/dapl_debug.c
@@ -32,7 +32,6 @@
 #include <stdlib.h>
 #endif /* __KDAPL__ */
 
-#ifdef DAPL_DBG
 DAPL_DBG_TYPE g_dapl_dbg_type;		/* initialized in dapl_init.c */
 DAPL_DBG_DEST g_dapl_dbg_dest;		/* initialized in dapl_init.c */
 
@@ -117,5 +116,4 @@ void dapl_dump_cntr( int cntr )
 }
 
 #endif /* DAPL_COUNTERS */
-#endif
 
diff --git a/dapl/common/dapl_evd_util.c b/dapl/common/dapl_evd_util.c
index a993b02..2ae1b59 100755
--- a/dapl/common/dapl_evd_util.c
+++ b/dapl/common/dapl_evd_util.c
@@ -1209,10 +1209,10 @@ dapli_evd_cqe_to_event (
 	    dapl_os_unlock ( &ep_ptr->header.lock );
 	}
 
-	dapl_dbg_log (DAPL_DBG_TYPE_DTO_COMP_ERR,
-		      " DTO completion ERROR: %d: op %#x (ep
disconnected)\n",
-		      DAPL_GET_CQE_STATUS (cqe_ptr),
-		      DAPL_GET_CQE_OPTYPE (cqe_ptr));
+	dapl_log(DAPL_DBG_TYPE_ERR,
+		 "DTO completion ERR: status %d, opcode %s \n",
+		 DAPL_GET_CQE_STATUS(cqe_ptr),
+		 DAPL_GET_CQE_OP_STR(cqe_ptr));
     }
 }
 
diff --git a/dapl/include/dapl_debug.h b/dapl/include/dapl_debug.h
index 76db8fd..f0de7c8 100644
--- a/dapl/include/dapl_debug.h
+++ b/dapl/include/dapl_debug.h
@@ -75,14 +75,16 @@ typedef enum
     DAPL_DBG_DEST_SYSLOG  	= 0x0002,
 } DAPL_DBG_DEST;
 
-
-#if defined(DAPL_DBG)
-
 extern DAPL_DBG_TYPE 	g_dapl_dbg_type;
 extern DAPL_DBG_DEST 	g_dapl_dbg_dest;
 
+extern void dapl_internal_dbg_log(DAPL_DBG_TYPE type,  const char *fmt,
...);
+
+#define dapl_log g_dapl_dbg_type==0 ? (void) 1 : dapl_internal_dbg_log
+
+#if defined(DAPL_DBG)
+
 #define dapl_dbg_log g_dapl_dbg_type==0 ? (void) 1 :
dapl_internal_dbg_log
-extern void dapl_internal_dbg_log ( DAPL_DBG_TYPE type,  const char
*fmt,  ...);
 
 #else  /* !DAPL_DBG */
 
diff --git a/dapl/openib_cma/dapl_ib_cm.c b/dapl/openib_cma/dapl_ib_cm.c
index a040ffb..33f299d 100755
--- a/dapl/openib_cma/dapl_ib_cm.c
+++ b/dapl/openib_cma/dapl_ib_cm.c
@@ -95,9 +95,9 @@ static void dapli_addr_resolve(struct dapl_cm_id
*conn)
 	
 	ret =  rdma_resolve_route(conn->cm_id, conn->route_timeout);
 	if (ret) {
-		dapl_dbg_log(DAPL_DBG_TYPE_ERR, 
-			     " rdma_connect failed:
%s\n",strerror(errno));
-
+		dapl_log(DAPL_DBG_TYPE_ERR, 
+			 " dapl_cma_connect: rdma_resolve_route ERR %d
%s\n",
+			 ret, strerror(errno));
 		dapl_evd_connection_callback(conn, 
 					     IB_CME_LOCAL_FAILURE, 
 					     NULL, conn->ep);
@@ -146,8 +146,9 @@ static void dapli_route_resolve(struct dapl_cm_id
*conn)
 
 	ret = rdma_connect(conn->cm_id, &conn->params);
 	if (ret) {
-		dapl_dbg_log(DAPL_DBG_TYPE_ERR, " rdma_connect failed:
%s\n",
-			     strerror(errno));
+		dapl_log(DAPL_DBG_TYPE_ERR, 
+			 " dapl_cma_connect: rdma_connect ERR %d %s\n",
+			 ret, strerror(errno));
 		goto bail;
 	}
 	return;
@@ -310,12 +311,15 @@ static void dapli_cm_active_cb(struct dapl_cm_id
*conn,
 	case RDMA_CM_EVENT_UNREACHABLE:
 	case RDMA_CM_EVENT_CONNECT_ERROR:
 	{
-		dapl_dbg_log(
-                        DAPL_DBG_TYPE_WARN,
-                        " dapli_cm_active_handler: CONN_ERR "
-                        " event=0x%x status=%d %s\n",
+		dapl_log(DAPL_DBG_TYPE_WARN,
+                        "dapl_cma_active: CONN_ERR event=0x%x"
+                        " status=%d %s DST %s, %d\n", 
                         event->event, event->status,
-                        (event->status == -ETIMEDOUT)?"TIMEOUT":"" );
+                        (event->status == -ETIMEDOUT)?"TIMEOUT":"", 
+			inet_ntoa(((struct sockaddr_in *)
+
&conn->cm_id->route.addr.dst_addr)->sin_addr),
+			ntohs(((struct sockaddr_in *)
+
&conn->cm_id->route.addr.dst_addr)->sin_port));
 
 		/* per DAT SPEC provider always returns UNREACHABLE */
 		dapl_evd_connection_callback(conn, 
@@ -327,36 +331,47 @@ static void dapli_cm_active_cb(struct dapl_cm_id
*conn,
 	{
 		ib_cm_events_t cm_event;
 
-		/* no device type specified so assume IB for now */
-		if (event->status == 28) /* IB_CM_REJ_CONSUMER_DEFINED
*/
-			cm_event =
IB_CME_DESTINATION_REJECT_PRIVATE_DATA;
-		else 
-			cm_event = IB_CME_DESTINATION_REJECT;
-
 		dapl_dbg_log(
 			DAPL_DBG_TYPE_CM,
 			" dapli_cm_active_handler: REJECTED
reason=%d\n",	
 			event->status);
-		
+
+		/* valid REJ from consumer will always contain private
data */
+		if (event->status == 28 &&
+			event->param.conn.private_data_len) 
+			cm_event =
IB_CME_DESTINATION_REJECT_PRIVATE_DATA;
+		else {
+			cm_event = IB_CME_DESTINATION_REJECT;
+			dapl_log(DAPL_DBG_TYPE_WARN, 
+				"dapl_cma_active: non-consumer REJ,"
+				" reason=%d, DST %s, %d\n", 
+				event->status,
+				inet_ntoa(((struct sockaddr_in *)
+
&conn->cm_id->route.addr.dst_addr)->sin_addr),
+				ntohs(((struct sockaddr_in *)
+
&conn->cm_id->route.addr.dst_addr)->sin_port));
+		}		
 		dapl_evd_connection_callback(conn, cm_event, NULL,
conn->ep);
 		break;
 	}
 	case RDMA_CM_EVENT_ESTABLISHED:
-			
 		dapl_dbg_log(DAPL_DBG_TYPE_CM, 
-     		     " active_cb: cm_id %d PORT %d CONNECTED to
0x%x!\n",
+     		     " active_cb: cm_id %d PORT %d CONNECTED to %s!\n",
      		     conn->cm_id,
 		     ntohs(((struct sockaddr_in *)
 			&conn->cm_id->route.addr.dst_addr)->sin_port),
-		     ntohl(((struct sockaddr_in *)
-
&conn->cm_id->route.addr.dst_addr)->sin_addr.s_addr));
+		     inet_ntoa(((struct sockaddr_in *)
+
&conn->cm_id->route.addr.dst_addr)->sin_addr));
 
 		/* setup local and remote ports for ep query */
-		conn->ep->param.remote_port_qual =
PORT_TO_SID(rdma_get_dst_port(conn->cm_id));
-		conn->ep->param.local_port_qual =
PORT_TO_SID(rdma_get_src_port(conn->cm_id));
+		conn->ep->param.remote_port_qual = 
+			PORT_TO_SID(rdma_get_dst_port(conn->cm_id));
+		conn->ep->param.local_port_qual = 
+			PORT_TO_SID(rdma_get_src_port(conn->cm_id));
 
 		dapl_evd_connection_callback(conn, IB_CME_CONNECTED,
-
event->param.conn.private_data, conn->ep);
+
event->param.conn.private_data, 
+					     conn->ep);
 		break;
 
 	case RDMA_CM_EVENT_DISCONNECTED:
@@ -383,9 +398,6 @@ static void dapli_cm_passive_cb(struct dapl_cm_id
*conn,
 			       struct rdma_cm_event *event)
 {
 	struct dapl_cm_id *new_conn;
-#ifdef DAPL_DBG
-	struct rdma_addr *ipaddr = &conn->cm_id->route.addr;
-#endif
 
 	dapl_dbg_log(DAPL_DBG_TYPE_CM, 
 		     " passive_cb: conn %p id %d event %d\n",
@@ -410,57 +422,43 @@ static void dapli_cm_passive_cb(struct dapl_cm_id
*conn,
 		break;
 	case RDMA_CM_EVENT_UNREACHABLE:
 	case RDMA_CM_EVENT_CONNECT_ERROR:
-
-		dapl_dbg_log(
-                        DAPL_DBG_TYPE_WARN,
-                        " dapli_cm_passive: CONN_ERR "
-                        " event=0x%x status=%d %s"
-                        " on SRC 0x%x,0x%x DST 0x%x,0x%x\n",
+		dapl_log(DAPL_DBG_TYPE_WARN,
+                        "dapl_cm_passive: CONN_ERR event=0x%x status=%d
%s,"
+			" DST %s,%d\n", 
                         event->event, event->status,
-                        (event->status == -110)?"TIMEOUT":"",
-                        ntohl(((struct sockaddr_in *)
-                                &ipaddr->src_addr)->sin_addr.s_addr),
-                        ntohs(((struct sockaddr_in *)
-                                &ipaddr->src_addr)->sin_port),
-                        ntohl(((struct sockaddr_in *)
-                                &ipaddr->dst_addr)->sin_addr.s_addr),
-                        ntohs(((struct sockaddr_in *)
-                                &ipaddr->dst_addr)->sin_port));
+                        (event->status == -ETIMEDOUT)?"TIMEOUT":"", 
+			inet_ntoa(((struct sockaddr_in *)
+
&conn->cm_id->route.addr.dst_addr)->sin_addr),
+			ntohs(((struct sockaddr_in *)
+
&conn->cm_id->route.addr.dst_addr)->sin_port));
 
 		dapls_cr_callback(conn, IB_CME_DESTINATION_UNREACHABLE,
-				 NULL, conn->sp);
+				  NULL, conn->sp);
 		break;
 
 	case RDMA_CM_EVENT_REJECTED:
 	{
 		ib_cm_events_t cm_event;
 
-		/* no device type specified so assume IB for now */
-		if (event->status == 28) /* IB_CM_REJ_CONSUMER_DEFINED
*/
+		/* valid REJ from consumer will always contain private
data */
+		if (event->status == 28 &&
+			event->param.conn.private_data_len) 
 			cm_event =
IB_CME_DESTINATION_REJECT_PRIVATE_DATA;
-		else 
+		else {
 			cm_event = IB_CME_DESTINATION_REJECT;
-
-		dapl_dbg_log(
-			DAPL_DBG_TYPE_WARN, 
-			" dapli_cm_passive: REJECTED reason=%d"
-			" on SRC 0x%x,0x%x DST 0x%x,0x%x\n", 
-			event->status,
-			ntohl(((struct sockaddr_in *)
-				&ipaddr->src_addr)->sin_addr.s_addr),
-			ntohs(((struct sockaddr_in *)
-				&ipaddr->src_addr)->sin_port),
-			ntohl(((struct sockaddr_in *)
-				&ipaddr->dst_addr)->sin_addr.s_addr),
-			ntohs(((struct sockaddr_in *)
-				&ipaddr->dst_addr)->sin_port));
-		
+			dapl_log(DAPL_DBG_TYPE_WARN, 
+				"dapl_cm_active: non-consumer REJ,
reason=%d,"
+				" DST %s, %d\n", 
+				event->status,
+				inet_ntoa(((struct sockaddr_in *)
+
&conn->cm_id->route.addr.dst_addr)->sin_addr),
+				ntohs(((struct sockaddr_in *)
+
&conn->cm_id->route.addr.dst_addr)->sin_port));
+		}
 		dapls_cr_callback(conn, cm_event, NULL, conn->sp);
-		
 		break;
 	}
 	case RDMA_CM_EVENT_ESTABLISHED:
-		
 		dapl_dbg_log(DAPL_DBG_TYPE_CM, 
      		     " passive_cb: cm_id %p PORT %d CONNECTED from
0x%x!\n",
      		     conn->cm_id,
@@ -559,9 +557,12 @@ DAT_RETURN dapls_ib_connect(IN DAT_EP_HANDLE
ep_handle,
 
 	if (rdma_resolve_addr(conn->cm_id, NULL, 
 			      (struct sockaddr *)&conn->r_addr, 
-			      conn->arp_timeout))
+			      conn->arp_timeout)) {
+		dapl_log(DAPL_DBG_TYPE_ERR,
+			 " dapl_cma_connect: rdma_resolve_addr ERR
%s\n", 
+			 strerror(errno));
 		return dapl_convert_errno(errno,"ib_connect");
-
+	}
 	dapl_dbg_log(DAPL_DBG_TYPE_CM, 
 		" connect: resolve_addr: cm_id %p -> %s port %d\n", 
 		conn->cm_id, 
@@ -815,9 +816,9 @@ dapls_ib_accept_connection(IN DAT_CR_HANDLE
cr_handle,
 		 */
 		dat_status = dapls_ib_qp_alloc(ia_ptr, ep_ptr, NULL);
 		if (dat_status != DAT_SUCCESS) {
-			dapl_dbg_log(DAPL_DBG_TYPE_ERR,
-				     " accept: ib_qp_alloc failed:
%d\n",
-				     dat_status);
+			dapl_log(DAPL_DBG_TYPE_ERR,
+				 " dapl_cma_accept: qp_alloc ERR %d\n",
+				 dat_status);
 			goto bail;
 		}
 	}
@@ -835,11 +836,12 @@ dapls_ib_accept_connection(IN DAT_CR_HANDLE
cr_handle,
 		ep_ptr->qp_handle->cm_id->qp = NULL;
 		dapli_destroy_conn(ep_ptr->qp_handle);
 	} else {
-		dapl_dbg_log(DAPL_DBG_TYPE_ERR, 
-			" accept: ERR dev(%p!=%p) or port
mismatch(%d!=%d)\n", 
+		dapl_log(DAPL_DBG_TYPE_ERR, 
+			" dapl_cma_accept: ERR dev(%p!=%p) or"
+			" port mismatch(%d!=%d)\n", 
 
ep_ptr->qp_handle->cm_id->verbs,cr_conn->cm_id->verbs,
-			ep_ptr->qp_handle->cm_id->port_num,
-			cr_conn->cm_id->port_num );
+			ntohs(ep_ptr->qp_handle->cm_id->port_num),
+			ntohs(cr_conn->cm_id->port_num));
 		dat_status = DAT_INTERNAL_ERROR;
 		goto bail;
 	}
@@ -850,7 +852,8 @@ dapls_ib_accept_connection(IN DAT_CR_HANDLE
cr_handle,
 
 	ret = rdma_accept(cr_conn->cm_id, &cr_conn->params);
 	if (ret) {
-		dapl_dbg_log(DAPL_DBG_TYPE_ERR," accept: ERROR %d\n",
ret);
+		dapl_log(DAPL_DBG_TYPE_ERR," dapl_cma_accept: ERR %d
%s\n", 
+			 ret, strerror(errno));
 		dat_status = dapl_convert_errno(ret, "accept");
 		goto bail;
 	}
@@ -909,6 +912,10 @@ dapls_ib_reject_connection(
 		return DAT_SUCCESS;
 	}
 
+	/*
+         * Private data is needed so peer can determine real
application 
+	 * reject from an abnormal application termination
+	 */
 	ret = rdma_reject(cm_handle->cm_id, NULL, 0);
 
 	dapli_destroy_conn(cm_handle);
@@ -1163,11 +1170,12 @@ void dapli_cma_event_cb(void)
 			break;
 
 		case RDMA_CM_EVENT_ADDR_ERROR:
-			dapl_dbg_log(DAPL_DBG_TYPE_WARN,
-				     " CM ADDR ERROR: -> %s retry
(%d)..\n", 
-				     inet_ntoa(((struct sockaddr_in *)
+			dapl_log(DAPL_DBG_TYPE_WARN,
+				 "dapl_cma_active: CM ADDR ERROR: ->"
+				 " DST %s retry (%d)..\n", 
+				 inet_ntoa(((struct sockaddr_in *)
 					&conn->r_addr)->sin_addr),
-					conn->arp_retries);
+				 conn->arp_retries);
 			
 			/* retry address resolution */
 			if ((--conn->arp_retries) && 
@@ -1188,27 +1196,47 @@ void dapli_cma_event_cb(void)
 				}
 			} 
 			/* retries exhausted or resolve_addr failed */
+			dapl_log(DAPL_DBG_TYPE_ERR,
+				"dapl_cma_active: ARP_ERR, retries(%d)"
+				" exhausted -> DST %s,%d\n", 
+                        	IB_ARP_RETRY_COUNT, 
+				inet_ntoa(((struct sockaddr_in *)
+
&conn->cm_id->route.addr.dst_addr)->sin_addr),
+				ntohs(((struct sockaddr_in *)
+
&conn->cm_id->route.addr.dst_addr)->sin_port));
+
 			dapl_evd_connection_callback(
 				conn, IB_CME_DESTINATION_UNREACHABLE, 
 				NULL, conn->ep);
 			break;
 
-
 		case RDMA_CM_EVENT_ROUTE_ERROR:
-			dapl_dbg_log(DAPL_DBG_TYPE_WARN, 
-				     " CM ROUTE ERROR: -> %s retry
(%d)..\n", 
-				     inet_ntoa(((struct sockaddr_in *)
+			dapl_log(DAPL_DBG_TYPE_WARN, 
+				 "dapl_cma_active: CM ROUTE ERROR: ->"
+				 " DST %s retry (%d)..\n", 
+				 inet_ntoa(((struct sockaddr_in *)
 					&conn->r_addr)->sin_addr),
-				     conn->route_retries );
+				 conn->route_retries );
 
 			/* retry route resolution */
 			if ((--conn->route_retries) && 
 				(event->status == -ETIMEDOUT))
 				dapli_addr_resolve(conn);
-			else 
-				dapl_evd_connection_callback( conn, 
+			else {
+			    dapl_log(DAPL_DBG_TYPE_ERR,
+                        	"dapl_cma_active: PATH_RECORD_ERR,"
+				" retries(%d) exhausted, DST %s,%d\n",
+                        	IB_ROUTE_RETRY_COUNT, 
+				inet_ntoa(((struct sockaddr_in *)
+
&conn->cm_id->route.addr.dst_addr)->sin_addr),
+				ntohs(((struct sockaddr_in *)
+
&conn->cm_id->route.addr.dst_addr)->sin_port));
+
+				dapl_evd_connection_callback( 
+					conn, 
 					IB_CME_DESTINATION_UNREACHABLE, 
 					NULL, conn->ep);
+			}
 			break;
 		
 		case RDMA_CM_EVENT_DEVICE_REMOVAL:
diff --git a/dapl/openib_cma/dapl_ib_util.c
b/dapl/openib_cma/dapl_ib_util.c
index e900b59..fcd8163 100755
--- a/dapl/openib_cma/dapl_ib_util.c
+++ b/dapl/openib_cma/dapl_ib_util.c
@@ -113,9 +113,10 @@ static int getipaddr(char *name, char *addr, int
len)
 		/* retry using network device name */
 		ret = getipaddr_netdev(name,addr,len);
 		if (ret) {
-			dapl_dbg_log(DAPL_DBG_TYPE_WARN, 
-			     " getipaddr: invalid name, addr, or
netdev(%s)\n",
-			     name);
+			dapl_log(DAPL_DBG_TYPE_ERR, 
+				 " open_hca: getaddr_netdev ERROR:"
+				 " %s. Is %s configured?\n", 
+				 strerror(errno), name);
 			return ret;
 		}
 	} else {
@@ -238,18 +239,19 @@ DAT_RETURN dapls_ib_open_hca(IN IB_HCA_NAME
hca_name, IN DAPL_HCA *hca_ptr)
 
 	/* cm_id will bind local device/GID based on IP address */
 	if (rdma_create_id(g_cm_events, &cm_id, (void*)hca_ptr,
RDMA_PS_TCP)) {
-		dapl_dbg_log (DAPL_DBG_TYPE_ERR, 
-				" open_hca: ERR with RDMA channel:
%s\n",
-				strerror(errno));
+		dapl_log(DAPL_DBG_TYPE_ERR, 
+			 " open_hca: rdma_create_id ERR %s\n", 
+			 strerror(errno));
 		return DAT_INTERNAL_ERROR;
 	}
 	ret = rdma_bind_addr(cm_id,
 			     (struct sockaddr *)&hca_ptr->hca_address);
 	if ((ret) || (cm_id->verbs == NULL)) {
                 rdma_destroy_id(cm_id); 
-		dapl_dbg_log(DAPL_DBG_TYPE_UTIL, 
-			     " open_hca: ERR bind (%d) %s \n", 
-			     ret, strerror(-ret));
+		dapl_log(DAPL_DBG_TYPE_ERR, 
+			 " open_hca: rdma_bind ERR %s."
+			 " Is %s configured?\n", 
+			 strerror(errno),hca_name);
 		return DAT_INVALID_ADDRESS;
 	}
 
@@ -282,9 +284,9 @@ DAT_RETURN dapls_ib_open_hca(IN IB_HCA_NAME
hca_name, IN DAPL_HCA *hca_ptr)
 	hca_ptr->ib_trans.ib_cq = 
 		ibv_create_comp_channel(hca_ptr->ib_hca_handle);
 	if (hca_ptr->ib_trans.ib_cq == NULL) {
-		dapl_dbg_log (DAPL_DBG_TYPE_ERR, 
-			" open_hca: ERR with CQ channel: %s\n",
-			strerror(errno));
+		dapl_log(DAPL_DBG_TYPE_ERR, 
+			 " open_hca: ibv_create_comp_channel ERR %s\n",
+			 strerror(errno));
 		goto bail;
 	}
 	dapl_dbg_log (DAPL_DBG_TYPE_UTIL, 
@@ -294,9 +296,10 @@ DAT_RETURN dapls_ib_open_hca(IN IB_HCA_NAME
hca_name, IN DAPL_HCA *hca_ptr)
 	opts = fcntl(hca_ptr->ib_trans.ib_cq->fd, F_GETFL); /* uCQ */
 	if (opts < 0 || fcntl(hca_ptr->ib_trans.ib_cq->fd, 
 			      F_SETFL, opts | O_NONBLOCK) < 0) {
-		dapl_dbg_log (DAPL_DBG_TYPE_ERR, 
-			      " open_hca: ERR with CQ FD (%d)\n", 
-			      hca_ptr->ib_trans.ib_cq->fd);
+		dapl_log(DAPL_DBG_TYPE_ERR, 
+			 " open_hca: fcntl on ib_cq->fd %d ERR %d %s\n",

+			 hca_ptr->ib_trans.ib_cq->fd, opts,
+			 strerror(errno));
 		goto bail;
 	}
 	
@@ -453,19 +456,13 @@ DAT_RETURN dapls_ib_query_hca(IN DAPL_HCA
*hca_ptr,
 		ia_attr->ia_address_ptr = 
 			(DAT_IA_ADDRESS_PTR)&hca_ptr->hca_address;
 
-		dapl_dbg_log(DAPL_DBG_TYPE_UTIL, 
-			" query_hca: %s %s  %d.%d.%d.%d\n",
hca_ptr->name,
+		dapl_log(DAPL_DBG_TYPE_UTIL, 
+			"dapl_query_hca: %s %s %s\n", hca_ptr->name,
 			((struct sockaddr_in *)
 			ia_attr->ia_address_ptr)->sin_family == AF_INET
? 
 			"AF_INET":"AF_INET6",
-			((struct sockaddr_in *)
-			ia_attr->ia_address_ptr)->sin_addr.s_addr >> 0 &
0xff,
-			((struct sockaddr_in *)
-			ia_attr->ia_address_ptr)->sin_addr.s_addr >> 8 &
0xff,
-			((struct sockaddr_in *)
-			ia_attr->ia_address_ptr)->sin_addr.s_addr >> 16
& 0xff,
-			((struct sockaddr_in *)
-			ia_attr->ia_address_ptr)->sin_addr.s_addr >> 24
& 0xff);
+			inet_ntoa(((struct sockaddr_in *)
+				ia_attr->ia_address_ptr)->sin_addr));
 		
 		ia_attr->hardware_version_major = dev_attr.hw_ver;
 		ia_attr->max_eps                  = dev_attr.max_qp;
@@ -500,14 +497,15 @@ DAT_RETURN dapls_ib_query_hca(IN DAPL_HCA
*hca_ptr,
 		ia_attr->extension_supported = DAT_EXTENSION_IB;
 		ia_attr->extension_version = DAT_IB_EXTENSION_VERSION;
 #endif
-		dapl_dbg_log(DAPL_DBG_TYPE_UTIL, 
-			" query_hca: (ver=%x) ep %d ep_q %d evd %d evd_q
%d\n", 
+		dapl_log(DAPL_DBG_TYPE_UTIL, 
+			"dapl_query_hca: (ver=%x) ep's %d ep_q %d"
+			" evd's %d evd_q %d\n", 
 			ia_attr->hardware_version_major,
 			ia_attr->max_eps, ia_attr->max_dto_per_ep,
 			ia_attr->max_evds, ia_attr->max_evd_qlen );
-		dapl_dbg_log(DAPL_DBG_TYPE_UTIL, 
-			" query_hca: msg %llu rdma %llu iov %d lmr %d
rmr %d"
-			" rd_io %d inline=%d\n", 
+		dapl_log(DAPL_DBG_TYPE_UTIL, 
+			"dapl_query_hca: msg %llu rdma %llu iov's %d"
+			" lmr %d rmr %d rd_io %d inline=%d\n", 
 			ia_attr->max_mtu_size, ia_attr->max_rdma_size,
 			ia_attr->max_iov_segments_per_dto,
ia_attr->max_lmrs, 
 			ia_attr->max_rmrs,
ia_attr->max_rdma_read_per_ep_in,
@@ -526,8 +524,9 @@ DAT_RETURN dapls_ib_query_hca(IN DAPL_HCA *hca_ptr,
 		ep_attr->max_rdma_read_out= dev_attr.max_qp_rd_atom;
 		ep_attr->max_rdma_read_iov= dev_attr.max_sge;
 		ep_attr->max_rdma_write_iov= dev_attr.max_sge;
-		dapl_dbg_log(DAPL_DBG_TYPE_UTIL, 
-			" query_hca: MAX msg %llu dto %d iov %d rdma
i%d,o%d\n", 
+		dapl_log(DAPL_DBG_TYPE_UTIL, 
+			"dapl_query_hca: MAX msg %llu dto %d iov %d"
+			" rdma i%d,o%d\n", 
 			ep_attr->max_mtu_size,
 			ep_attr->max_recv_dtos, ep_attr->max_recv_iov,
 			ep_attr->max_rdma_read_in,
ep_attr->max_rdma_read_out);
@@ -708,9 +707,9 @@ void dapli_async_event_cb(struct _ib_hca_transport
*hca)
 			struct dapl_ep *evd_ptr = 
 				event.element.cq->cq_context;
 
-			dapl_dbg_log(
-				DAPL_DBG_TYPE_WARN,
-				" async_event CQ (%p) ERR %d\n",
+			dapl_log(
+				DAPL_DBG_TYPE_ERR,
+				"dapl async_event CQ (%p) ERR %d\n",
 				evd_ptr, event.event_type);

 			
 			/* report up if async callback still setup */
@@ -724,7 +723,7 @@ void dapli_async_event_cb(struct _ib_hca_transport
*hca)
 		case	IBV_EVENT_COMM_EST:
 		{
 			/* Received msgs on connected QP before RTU */
-			dapl_dbg_log(
+			dapl_log(
 				DAPL_DBG_TYPE_UTIL,
 				" async_event COMM_EST(%p) rdata beat
RTU\n",
 				event.element.qp);	
@@ -742,9 +741,9 @@ void dapli_async_event_cb(struct _ib_hca_transport
*hca)
 			struct dapl_ep *ep_ptr = 
 				event.element.qp->qp_context;
 
-			dapl_dbg_log(
-				DAPL_DBG_TYPE_WARN,
-				" async_event QP (%p) ERR %d\n",
+			dapl_log(
+				DAPL_DBG_TYPE_ERR,
+				"dapl async_event QP (%p) ERR %d\n",
 				ep_ptr, event.event_type);	
 			
 			/* report up if async callback still setup */
@@ -764,8 +763,8 @@ void dapli_async_event_cb(struct _ib_hca_transport
*hca)
 		case	IBV_EVENT_PKEY_CHANGE:
 		case	IBV_EVENT_SM_CHANGE:
 		{
-			dapl_dbg_log(DAPL_DBG_TYPE_WARN,
-				     " async_event: DEV ERR %d\n",
+			dapl_log(DAPL_DBG_TYPE_WARN,
+				     "dapl async_event: DEV ERR %d\n",
 				     event.event_type);	
 
 			/* report up if async callback still setup */
@@ -778,13 +777,13 @@ void dapli_async_event_cb(struct _ib_hca_transport
*hca)
 		}
 		case	IBV_EVENT_CLIENT_REREGISTER:
 			/* no need to report this event this time */
-			dapl_dbg_log (DAPL_DBG_TYPE_WARN,
+			dapl_log (DAPL_DBG_TYPE_UTIL,
 				     " async_event:
IBV_EVENT_CLIENT_REREGISTER\n");
 			break;
 
 		default:
-			dapl_dbg_log (DAPL_DBG_TYPE_WARN,
-				     " async_event: %d UNKNOWN\n", 
+			dapl_log (DAPL_DBG_TYPE_WARN,
+				     "dapl async_event: %d UNKNOWN\n", 
 				     event.event_type);
 			break;
 		
diff --git a/dapl/udapl/dapl_init.c b/dapl/udapl/dapl_init.c
index ce92f9f..a4afba5 100644
--- a/dapl/udapl/dapl_init.c
+++ b/dapl/udapl/dapl_init.c
@@ -70,16 +70,19 @@ void dapl_init ( void )
 {
     DAT_RETURN		dat_status;
 
-#if defined(DAPL_DBG)
-    dapl_dbg_log (DAPL_DBG_TYPE_UTIL, "DAPL:  (dapl_init)\n");
-
     /* set up debug type */
     g_dapl_dbg_type = dapl_os_get_env_val ( "DAPL_DBG_TYPE", 
-					    DAPL_DBG_TYPE_ERR |
DAPL_DBG_TYPE_WARN);
+					    DAPL_DBG_TYPE_ERR );
     /* set up debug destination */
     g_dapl_dbg_dest = dapl_os_get_env_val ( "DAPL_DBG_DEST", 
 					    DAPL_DBG_DEST_STDOUT );
-#endif /* DAPL_DBG */
+
+    /* open log file on first logging call if necessary */
+    if (g_dapl_dbg_dest & DAPL_DBG_DEST_SYSLOG)
+	openlog("libdapl", LOG_ODELAY|LOG_PID|LOG_CONS, LOG_USER);
+	
+    dapl_log (DAPL_DBG_TYPE_UTIL, "dapl_init:
dbg_type=0x%x,dbg_dest=0x%x\n",
+	      g_dapl_dbg_type, g_dapl_dbg_dest);
 
     /* See if the user is on a loopback setup */
     g_dapl_loopback_connection = dapl_os_get_env_bool ( "DAPL_LOOPBACK"
);
@@ -156,6 +159,9 @@ void dapl_fini ( void )
 
     dapl_dbg_log (DAPL_DBG_TYPE_UTIL, "DAPL: Exit (dapl_fini)\n");
 
+    if (g_dapl_dbg_dest & DAPL_DBG_DEST_SYSLOG)
+	closelog();
+
     return;
 }
 
diff --git a/dapl/udapl/linux/dapl_osd.h b/dapl/udapl/linux/dapl_osd.h
index caf971f..42ced41 100644
--- a/dapl/udapl/linux/dapl_osd.h
+++ b/dapl/udapl/linux/dapl_osd.h
@@ -541,7 +541,7 @@ dapl_os_strtol(const char *nptr, char **endptr, int
base)
 #define dapl_os_assert(expression)	assert(expression)
 #define dapl_os_printf(...) 		printf(__VA_ARGS__)
 #define dapl_os_vprintf(fmt,args)	vprintf(fmt,args)
-#define dapl_os_syslog(fmt,args)	vsyslog (LOG_USER |
LOG_DEBUG,fmt,args)
+#define dapl_os_syslog(fmt,args)
vsyslog(LOG_USER|LOG_WARNING,fmt,args)
 
 
 
-- 
1.5.2.5




More information about the general mailing list