[ofa-general] [PATCH 5/5][v1.2] dapl providers: fix compiler warnings in cma and scm providers

Arlin Davis arlin.r.davis at intel.com
Mon Sep 1 19:26:04 PDT 2008


dapl providers: fix compiler warnings in cma and scm providers

Include provider definitions after some key definitions required by providers.
Check results of writes and reads, print appropriate error message.

Signed-off by: Arlin Davis ardavis at ichips.intel.com
---
 dapl/include/dapl.h            |   38 +++++++++++++++++++-------------------
 dapl/openib_cma/dapl_ib_cq.c   |    5 ++++-
 dapl/openib_cma/dapl_ib_util.c |   32 +++++++++++++++++++++++++-------
 dapl/openib_cma/dapl_ib_util.h |   14 +-------------
 dapl/openib_scm/dapl_ib_cm.c   |   36 +++++++++++++++++++++++++++++-------
 dapl/openib_scm/dapl_ib_util.c |    9 ++++++++-
 dapl/openib_scm/dapl_ib_util.h |   14 +-------------
 7 files changed, 87 insertions(+), 61 deletions(-)

diff --git a/dapl/include/dapl.h b/dapl/include/dapl.h
index 80c9ff3..9d3f546 100644
--- a/dapl/include/dapl.h
+++ b/dapl/include/dapl.h
@@ -50,19 +50,6 @@
 #include "dapl_osd.h"
 #include "dapl_debug.h"
 
-#ifdef	IBAPI
-#include "dapl_ibapi_util.h"
-#elif VAPI
-#include "dapl_vapi_util.h"
-#elif __OPENIB__
-#include "dapl_openib_util.h"
-#include "dapl_openib_cm.h"
-#elif DUMMY
-#include "dapl_dummy_util.h"
-#elif OPENIB
-#include "dapl_ib_util.h"
-#endif
-
 /*********************************************************************
  *                                                                   *
  * Enumerations                                                      *
@@ -215,12 +202,6 @@ typedef struct dapl_rmr_cookie		DAPL_RMR_COOKIE;
 
 typedef struct dapl_private		DAPL_PRIVATE;
 
-typedef void (*DAPL_CONNECTION_STATE_HANDLER) (
-	IN	DAPL_EP *,
-	IN	ib_cm_events_t,
-	IN	const void *,
-	OUT	DAT_EVENT *);
-
 
 /*********************************************************************
  *                                                                   *
@@ -252,6 +233,19 @@ struct dapl_cookie_buffer
     DAPL_ATOMIC		tail;
 };
 
+#ifdef	IBAPI
+#include "dapl_ibapi_util.h"
+#elif VAPI
+#include "dapl_vapi_util.h"
+#elif __OPENIB__
+#include "dapl_openib_util.h"
+#include "dapl_openib_cm.h"
+#elif DUMMY
+#include "dapl_dummy_util.h"
+#elif OPENIB
+#include "dapl_ib_util.h"
+#endif
+
 struct dapl_hca
 {
     DAPL_OS_LOCK	lock;
@@ -673,6 +667,12 @@ void dapls_io_trc_dump (
  *                                                                   *
  *********************************************************************/
 
+typedef void (*DAPL_CONNECTION_STATE_HANDLER) (
+	IN	DAPL_EP *,
+	IN	ib_cm_events_t,
+	IN	const void *,
+	OUT	DAT_EVENT *);
+
 /*
  * DAT Mandated functions
  */
diff --git a/dapl/openib_cma/dapl_ib_cq.c b/dapl/openib_cma/dapl_ib_cq.c
index 25b4551..cf19f38 100644
--- a/dapl/openib_cma/dapl_ib_cq.c
+++ b/dapl/openib_cma/dapl_ib_cq.c
@@ -497,7 +497,10 @@ dapls_ib_wait_object_wakeup (IN ib_wait_obj_handle_t p_cq_wait_obj_handle)
 			p_cq_wait_obj_handle );
 
         /* write to pipe for wake up */
-        write(p_cq_wait_obj_handle->pipe[1], "w", sizeof "w");
+	if (write(p_cq_wait_obj_handle->pipe[1], "w", sizeof "w") == -1)
+		  dapl_log(DAPL_DBG_TYPE_UTIL,
+			   " wait object wakeup write error = %s\n",
+			   strerror(errno));
 	return DAT_SUCCESS;
 }
 
diff --git a/dapl/openib_cma/dapl_ib_util.c b/dapl/openib_cma/dapl_ib_util.c
index e76e319..afb7463 100755
--- a/dapl/openib_cma/dapl_ib_util.c
+++ b/dapl/openib_cma/dapl_ib_util.c
@@ -321,7 +321,10 @@ DAT_RETURN dapls_ib_open_hca(IN IB_HCA_NAME hca_name, IN DAPL_HCA *hca_ptr)
 	dapl_llist_add_tail(&g_hca_list, 
 			    (DAPL_LLIST_ENTRY*)&hca_ptr->ib_trans.entry, 
 			    &hca_ptr->ib_trans.entry);
-	write(g_ib_pipe[1], "w", sizeof "w");
+	if (write(g_ib_pipe[1], "w", sizeof "w") == -1)
+		dapl_log(DAPL_DBG_TYPE_UTIL,
+			 " open_hca: thread wakeup error = %s\n",
+			 strerror(errno));
 	dapl_os_unlock(&g_hca_lock);
 	
   	dapl_dbg_log(
@@ -388,14 +391,20 @@ DAT_RETURN dapls_ib_close_hca(IN DAPL_HCA *hca_ptr)
 	 * Wakeup work thread to remove from polling list
 	 */
 	hca_ptr->ib_trans.destroy = 1;
-	write(g_ib_pipe[1], "w", sizeof "w");
+	if (write(g_ib_pipe[1], "w", sizeof "w") == -1)
+		dapl_log(DAPL_DBG_TYPE_UTIL,
+			 " close_hca: thread wakeup error = %s\n",
+			 strerror(errno));
 
 	/* wait for thread to remove HCA references */
 	while (hca_ptr->ib_trans.destroy != 2) {
 		struct timespec	sleep, remain;
 		sleep.tv_sec = 0;
 		sleep.tv_nsec = 10000000; /* 10 ms */
-		write(g_ib_pipe[1], "w", sizeof "w");
+		if (write(g_ib_pipe[1], "w", sizeof "w") == -1)
+			dapl_log(DAPL_DBG_TYPE_UTIL,
+				 " close_hca: thread wakeup error = %s\n",
+				 strerror(errno));		
 		dapl_dbg_log(DAPL_DBG_TYPE_UTIL, 
 			     " ib_thread_destroy: wait on hca %p destroy\n");
 		nanosleep (&sleep, &remain);
@@ -671,14 +680,20 @@ void dapli_ib_thread_destroy(void)
 		goto bail;
 			
 	g_ib_thread_state = IB_THREAD_CANCEL;
-	write(g_ib_pipe[1], "w", sizeof "w");
+	if (write(g_ib_pipe[1], "w", sizeof "w") == -1)
+		dapl_log(DAPL_DBG_TYPE_UTIL,
+			 " destroy: thread wakeup error = %s\n",
+			 strerror(errno));	
 	while ((g_ib_thread_state != IB_THREAD_EXIT) && (retries--)) {
 		struct timespec	sleep, remain;
 		sleep.tv_sec = 0;
 		sleep.tv_nsec = 2000000; /* 2 ms */
 		dapl_dbg_log(DAPL_DBG_TYPE_UTIL, 
 			" ib_thread_destroy: waiting for ib_thread\n");
-		write(g_ib_pipe[1], "w", sizeof "w");
+		if (write(g_ib_pipe[1], "w", sizeof "w") == -1)
+			dapl_log(DAPL_DBG_TYPE_UTIL,
+				 " destroy: thread wakeup error = %s\n",
+				 strerror(errno));	
 		dapl_os_unlock( &g_hca_lock );
 		nanosleep(&sleep, &remain);
 		dapl_os_lock( &g_hca_lock );
@@ -894,8 +909,11 @@ void dapli_thread(void *arg)
 		/* check and process user events, PIPE */
 		if (ufds[0].revents == POLLIN) {
 
-			read(g_ib_pipe[0], rbuf, 2);
-			
+                       if (read(g_ib_pipe[0], rbuf, 2) == -1)
+				dapl_log(DAPL_DBG_TYPE_UTIL,
+					 " ib_thread: pipe rd err= %s\n",
+					 strerror(errno));
+	
 			/* cleanup any device on list marked for destroy */
 			for(idx=3;idx<fds;idx++) {
 				if(uhca[idx] && uhca[idx]->destroy == 1) {
diff --git a/dapl/openib_cma/dapl_ib_util.h b/dapl/openib_cma/dapl_ib_util.h
index 1e464b2..1d919d9 100755
--- a/dapl/openib_cma/dapl_ib_util.h
+++ b/dapl/openib_cma/dapl_ib_util.h
@@ -164,18 +164,6 @@ typedef enum
 
 } ib_thread_state_t;
 
-/* 
- * dapl_llist_entry in dapl.h but dapl.h depends on provider 
- * typedef's in this file first. move dapl_llist_entry out of dapl.h
- */
-struct ib_llist_entry
-{
-    struct dapl_llist_entry	*flink;
-    struct dapl_llist_entry	*blink;
-    void			*data;
-    struct dapl_llist_entry	*list_head;
-};
-
 struct dapl_cm_id {
 	DAPL_OS_LOCK			lock;
 	int				destroy;
@@ -256,7 +244,7 @@ typedef void (*ib_async_handler_t)(
 /* ib_hca_transport_t, specific to this implementation */
 typedef struct _ib_hca_transport
 { 
-	struct ib_llist_entry	entry;
+	struct dapl_llist_entry	entry;
 	int			destroy;
 	struct dapl_hca		*d_hca;
 	struct rdma_cm_id 	*cm_id;
diff --git a/dapl/openib_scm/dapl_ib_cm.c b/dapl/openib_scm/dapl_ib_cm.c
index 9f845b6..48aa82d 100644
--- a/dapl/openib_scm/dapl_ib_cm.c
+++ b/dapl/openib_scm/dapl_ib_cm.c
@@ -119,7 +119,10 @@ static void dapli_cm_destroy(struct ib_cm_handle *cm_ptr)
 	dapl_os_unlock(&cm_ptr->lock);
 
 	/* wakeup work thread */
-        write(g_scm_pipe[1], "w", sizeof "w");
+	if (write(g_scm_pipe[1], "w", sizeof "w") == -1)
+		dapl_log(DAPL_DBG_TYPE_UTIL,
+			 " cm_destroy: thread wakeup error = %s\n",
+			 strerror(errno));
 }
 
 /* queue socket for processing CM work */
@@ -133,7 +136,10 @@ static void dapli_cm_queue(struct ib_cm_handle *cm_ptr)
 	dapl_os_unlock(&cm_ptr->hca->ib_trans.lock);
 
         /* wakeup CM work thread */
-        write(g_scm_pipe[1], "w", sizeof "w");
+	if (write(g_scm_pipe[1], "w", sizeof "w") == -1)
+		dapl_log(DAPL_DBG_TYPE_UTIL,
+			 " cm_queue: thread wakeup error = %s\n",
+			 strerror(errno));
 }
 
 static uint16_t dapli_get_lid(IN struct ibv_context *ctx, IN uint8_t port)
@@ -167,7 +173,11 @@ dapli_socket_disconnect(ib_cm_handle_t	cm_ptr)
 	} else {
 		/* send disc date, close socket, schedule destroy */
 		if (cm_ptr->socket >= 0) { 
-			write(cm_ptr->socket, &disc_data, sizeof(disc_data));
+			if (write(cm_ptr->socket,
+				  &disc_data, sizeof(disc_data)) == -1)
+				dapl_log(DAPL_DBG_TYPE_WARN,
+					 " cm_disc: write error = %s\n",
+					 strerror(errno));
 			close(cm_ptr->socket);
 			cm_ptr->socket = -1;
 		}
@@ -473,7 +483,10 @@ dapli_socket_connect_rtu(ib_cm_handle_t	cm_ptr)
 	dapl_dbg_log(DAPL_DBG_TYPE_EP," connect_rtu: send RTU\n"); 
 
 	/* complete handshake after final QP state change */
-	write(cm_ptr->socket, &rtu_data, sizeof(rtu_data));
+	if (write(cm_ptr->socket, &rtu_data, sizeof(rtu_data)) == -1)
+		dapl_log(DAPL_DBG_TYPE_UTIL,
+			 " CONN_RTU: write error = %s\n",
+			 strerror(errno));
 
 	/* init cm_handle and post the event with private data */
 	ep_ptr->cm_handle = cm_ptr;
@@ -1011,7 +1024,10 @@ dapls_ib_remove_conn_listener (
 	    	/* cr_thread will free */
 		cm_ptr->state = SCM_DESTROY;
 		sp_ptr->cm_srvc_handle = NULL;
-		write(g_scm_pipe[1], "w", sizeof "w");
+		if (write(g_scm_pipe[1], "w", sizeof "w") == -1)
+			dapl_log(DAPL_DBG_TYPE_UTIL,
+				 " remove_listen: thread wakeup error = %s\n",
+				 strerror(errno));
 	}
 	return DAT_SUCCESS;
 }
@@ -1106,7 +1122,10 @@ dapls_ib_reject_connection (
 
 	/* cr_thread will destroy CR */
 	cm_ptr->state = SCM_REJECTED;
-        write(g_scm_pipe[1], "w", sizeof "w");
+	if (write(g_scm_pipe[1], "w", sizeof "w") == -1)
+		dapl_log(DAPL_DBG_TYPE_UTIL,
+			 " reject_connection: thread wakeup error = %s\n",
+			 strerror(errno));
 	return DAT_SUCCESS;
 }
 
@@ -1442,7 +1461,10 @@ void cr_thread(void *arg)
 	poll(ufds,idx+1,-1); /* infinite, all sockets and pipe */
 	/* if pipe used to wakeup, consume */
 	if (ufds[0].revents == POLLIN)
-		read(g_scm_pipe[0], rbuf, 2);
+		if (read(g_scm_pipe[0], rbuf, 2) == -1)
+			dapl_log(DAPL_DBG_TYPE_CM,
+				 " cr_thread: read pipe error = %s\n",
+				 strerror(errno));
 	dapl_dbg_log(DAPL_DBG_TYPE_CM," cr_thread: wakeup\n");
 	dapl_os_lock(&hca_ptr->ib_trans.lock);
     } 
diff --git a/dapl/openib_scm/dapl_ib_util.c b/dapl/openib_scm/dapl_ib_util.c
index 76bde89..f1f6103 100644
--- a/dapl/openib_scm/dapl_ib_util.c
+++ b/dapl/openib_scm/dapl_ib_util.c
@@ -359,11 +359,18 @@ DAT_RETURN dapls_ib_close_hca (	IN   DAPL_HCA	*hca_ptr )
 
 	/* destroy cr_thread and lock */
 	hca_ptr->ib_trans.cr_state = IB_THREAD_CANCEL;
-	write(g_scm_pipe[1], "w", sizeof "w");
+	if (write(g_scm_pipe[1], "w", sizeof "w") == -1)
+		dapl_log(DAPL_DBG_TYPE_UTIL,
+			 " close_hca: thread wakeup error = %s\n",
+			 strerror(errno));
 	while (hca_ptr->ib_trans.cr_state != IB_THREAD_EXIT) {
 		struct timespec	sleep, remain;
 		sleep.tv_sec = 0;
 		sleep.tv_nsec = 2000000; /* 2 ms */
+		if (write(g_scm_pipe[1], "w", sizeof "w") == -1)
+			dapl_log(DAPL_DBG_TYPE_UTIL,
+				 " close_hca: thread wakeup error = %s\n",
+				 strerror(errno));
 		dapl_dbg_log(DAPL_DBG_TYPE_UTIL, 
 			     " close_hca: waiting for cr_thread\n");
 		nanosleep (&sleep, &remain);
diff --git a/dapl/openib_scm/dapl_ib_util.h b/dapl/openib_scm/dapl_ib_util.h
index 8ed4fac..91a4e67 100644
--- a/dapl/openib_scm/dapl_ib_util.h
+++ b/dapl/openib_scm/dapl_ib_util.h
@@ -85,18 +85,6 @@ typedef struct _ib_qp_cm
         union ibv_gid		gid;
 } ib_qp_cm_t;
 
-/* 
- * dapl_llist_entry in dapl.h but dapl.h depends on provider 
- * typedef's in this file first. move dapl_llist_entry out of dapl.h
- */
-struct ib_llist_entry
-{
-    struct dapl_llist_entry	*flink;
-    struct dapl_llist_entry	*blink;
-    void			*data;
-    struct dapl_llist_entry	*list_head;
-};
-
 typedef enum scm_state 
 {
 	SCM_INIT,
@@ -114,7 +102,7 @@ typedef enum scm_state
 
 struct ib_cm_handle
 { 
-	struct ib_llist_entry	entry;
+	struct dapl_llist_entry	entry;
 	DAPL_OS_LOCK		lock;
 	SCM_STATE		state;
 	int			socket;
-- 
1.5.2.5





More information about the general mailing list