From beebe0066b47d7bf476925ff280bad2a3db38324 Mon Sep 17 00:00:00 2001 From: Arlin Davis Date: Fri, 19 Jun 2009 20:52:51 -0700 Subject: [PATCH] common,scm: add debug capabilities to print in-process CM lists Add a new debug bit DAPL_DBG_TYPE_CM_LIST. If set, the pending CM requests will be dumped when dat_print_counters is called. Only provided when built with -DDAPL_COUNTERS Add new dapl_cm_state_str() call for state to string conversion for debug prints. Signed-off-by: Arlin Davis --- dapl/common/dapl_debug.c | 6 ++++++ dapl/include/dapl_debug.h | 3 ++- dapl/openib_cma/dapl_ib_util.h | 5 +++++ dapl/openib_scm/dapl_ib_cm.c | 37 ++++++++++++++++++++++++++++++++++ dapl/openib_scm/dapl_ib_util.h | 19 +++++++++++++++++ 5 files changed, 69 insertions(+), 1 deletion(-) diff --git a/dapl/common/dapl_debug.c b/dapl/common/dapl_debug.c index 6723217..18b6e7e 100644 --- a/dapl/common/dapl_debug.c +++ b/dapl/common/dapl_debug.c @@ -232,6 +232,12 @@ void dapl_print_counter(DAT_HANDLE dh, int counter, int reset) p_cntrs[i] = 0; } } + + /* Print in process CR's for this IA, if debug type set */ + if ((type == DAT_HANDLE_TYPE_IA) && + (g_dapl_dbg_type & DAPL_DBG_TYPE_CM_LIST)) { + dapls_print_cm_list((DAPL_IA*)dh); + } return; } diff --git a/dapl/include/dapl_debug.h b/dapl/include/dapl_debug.h index bb823d9..92e3d3b 100644 --- a/dapl/include/dapl_debug.h +++ b/dapl/include/dapl_debug.h @@ -65,7 +65,8 @@ typedef enum DAPL_DBG_TYPE_RTN = 0x0200, DAPL_DBG_TYPE_EXCEPTION = 0x0400, DAPL_DBG_TYPE_SRQ = 0x0800, - DAPL_DBG_TYPE_CNTR = 0x1000 + DAPL_DBG_TYPE_CNTR = 0x1000, + DAPL_DBG_TYPE_CM_LIST = 0x2000 } DAPL_DBG_TYPE; diff --git a/dapl/openib_cma/dapl_ib_util.h b/dapl/openib_cma/dapl_ib_util.h index 46c9b35..dde5fac 100755 --- a/dapl/openib_cma/dapl_ib_util.h +++ b/dapl/openib_cma/dapl_ib_util.h @@ -286,6 +286,11 @@ STATIC _INLINE_ void dapl_ib_release_name (IN IB_HCA_NAME name) return; } +STATIC _INLINE_ void dapls_print_cm_list(IN DAPL_IA * ia_ptr) +{ + return; +} + /* * Convert errno to DAT_RETURN values */ diff --git a/dapl/openib_scm/dapl_ib_cm.c b/dapl/openib_scm/dapl_ib_cm.c index 6d39a4a..27defb6 100644 --- a/dapl/openib_scm/dapl_ib_cm.c +++ b/dapl/openib_scm/dapl_ib_cm.c @@ -1723,3 +1723,40 @@ void cr_thread(void *arg) hca_ptr->ib_trans.cr_state = IB_THREAD_EXIT; dapl_dbg_log(DAPL_DBG_TYPE_UTIL, " cr_thread(hca %p) exit\n", hca_ptr); } + + +#ifdef DAPL_COUNTERS +/* Debug aid: List all Connections in process and state */ +void dapls_print_cm_list(IN DAPL_IA *ia_ptr) +{ + /* Print in process CR's for this IA, if debug type set */ + int i = 0; + dp_ib_cm_handle_t cr, next_cr; + + dapl_os_lock(&ia_ptr->hca_ptr->ib_trans.lock); + if (!dapl_llist_is_empty((DAPL_LLIST_HEAD*) + &ia_ptr->hca_ptr->ib_trans.list)) + next_cr = dapl_llist_peek_head((DAPL_LLIST_HEAD*) + &ia_ptr->hca_ptr->ib_trans.list); + else + next_cr = NULL; + + printf("\n DAPL IA CONNECTIONS IN PROCESS:\n"); + while (next_cr) { + cr = next_cr; + next_cr = dapl_llist_next_entry((DAPL_LLIST_HEAD*) + &ia_ptr->hca_ptr->ib_trans.list, + (DAPL_LLIST_ENTRY*)&cr->entry); + + printf( " CONN[%d]: sp %p ep %p sock %d %s %s -> %s\n", + i, cr->sp, cr->ep, cr->socket, + cr->dst.qp_type == IBV_QPT_RC ? "RC" : "UD", + dapl_cm_state_str(cr->state), + inet_ntoa(((struct sockaddr_in *) + &cr->dst.ia_address)->sin_addr)); + i++; + } + printf("\n"); + dapl_os_unlock(&ia_ptr->hca_ptr->ib_trans.lock); +} +#endif diff --git a/dapl/openib_scm/dapl_ib_util.h b/dapl/openib_scm/dapl_ib_util.h index ef98ab6..294ef3d 100644 --- a/dapl/openib_scm/dapl_ib_util.h +++ b/dapl/openib_scm/dapl_ib_util.h @@ -317,6 +317,7 @@ void cr_thread(void *arg); int dapli_cq_thread_init(struct dapl_hca *hca_ptr); void dapli_cq_thread_destroy(struct dapl_hca *hca_ptr); DAT_RETURN dapli_socket_disconnect(dp_ib_cm_handle_t cm_ptr); +void dapls_print_cm_list(IN DAPL_IA *ia_ptr); DAT_RETURN dapls_modify_qp_state ( IN ib_qp_handle_t qp_handle, @@ -369,6 +370,24 @@ dapl_convert_errno( IN int err, IN const char *str ) } } +STATIC _INLINE_ char * dapl_cm_state_str(IN int st) +{ + static char *cm_state[] = { + "SCM_INIT", + "SCM_LISTEN", + "SCM_CONN_PENDING", + "SCM_RTU_PENDING", + "SCM_ACCEPTING", + "SCM_ACCEPTING_DATA", + "SCM_ACCEPTED", + "SCM_REJECTED", + "SCM_CONNECTED", + "SCM_DISCONNECTED", + "SCM_DESTROY" + }; + return ((st < 0 || st > 10) ? "Invalid CM state?" : cm_state[st]); +} + /* * Definitions required only for DAT 1.1 builds */ -- 2.46.0