[WSD] add WPP support
authorsleybo <sleybo@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Wed, 7 Feb 2007 10:48:15 +0000 (10:48 +0000)
committersleybo <sleybo@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Wed, 7 Feb 2007 10:48:15 +0000 (10:48 +0000)
git-svn-id: svn://openib.tc.cornell.edu/gen1/trunk@574 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86

15 files changed:
ulp/wsd/user/SOURCES
ulp/wsd/user/extensions.c
ulp/wsd/user/ib_cm.c
ulp/wsd/user/ibsp_duplicate.c
ulp/wsd/user/ibsp_iblow.c
ulp/wsd/user/ibsp_ip.c
ulp/wsd/user/ibsp_mem.c
ulp/wsd/user/ibsp_perfmon.c
ulp/wsd/user/ibsp_pnp.c
ulp/wsd/user/ibspdebug.c
ulp/wsd/user/ibspdebug.h
ulp/wsd/user/ibspdll.c
ulp/wsd/user/ibspstruct.h
ulp/wsd/user/misc.c
ulp/wsd/user/sockinfo.c

index c844ae6..9da1354 100644 (file)
@@ -5,6 +5,11 @@ DLLENTRY=DllMain
 DLLDEF=ibspdll.def\r
 USE_NTDLL=1\r
 \r
+!if $(FREEBUILD)\r
+ENABLE_EVENT_TRACING=1 \r
+!endif\r
+\r
+\r
 SOURCES=\\r
        ibspdll.rc              \\r
        extensions.c    \\r
@@ -22,7 +27,8 @@ SOURCES=\
 \r
 INCLUDES=..\..\..\inc;..\..\..\inc\user;$(DDK_INC_PATH);\r
 \r
-USER_C_FLAGS=$(USER_C_FLAGS) -DCL_NO_TRACK_MEM -DPERFMON_ENABLED\r
+USER_C_FLAGS=$(USER_C_FLAGS) -DCL_NO_TRACK_MEM -DPERFMON_ENABLED -DWPP_OLDCC\r
+\r
 \r
 TARGETLIBS=\\r
                        $(SDK_LIB_PATH)\kernel32.lib \\r
@@ -38,4 +44,18 @@ TARGETLIBS=\
                        $(TARGETPATH)\*\ibald.lib\r
 !endif\r
 \r
+!IFDEF ENABLE_EVENT_TRACING\r
+\r
+C_DEFINES = $(C_DEFINES) -DEVENT_TRACING\r
+\r
+RUN_WPP= $(SOURCES) -ext: .c .h -dll  \\r
+       -scan:ibspdebug.h\\r
+       -func:IBSP_PRINT(LEVEL,FLAGS,(MSG,...)) \\r
+       -func:IBSP_PRINT_EXIT(LEVEL,FLAGS,(MSG,...)) \\r
+       -func:IBSP_ERROR{LEVEL=TRACE_LEVEL_ERROR,FLAGS=IBSP_DBG_ERROR}((MSG,...)) \\r
+       -func:IBSP_ERROR_EXIT{LEVEL=TRACE_LEVEL_ERROR,FLAGS=IBSP_DBG_ERROR}((MSG,...))\r
+  \r
+!ENDIF\r
+\r
+\r
 MSC_WARNING_LEVEL= /W4\r
index 6af9f96..f22c1b8 100644 (file)
@@ -1,5 +1,6 @@
 /*\r
  * Copyright (c) 2005 SilverStorm Technologies.  All rights reserved.\r
+ * Copyright (c) 2006 Mellanox Technologies.  All rights reserved.\r
  *\r
  * This software is available to you under the OpenIB.org BSD license\r
  * below:\r
  * $Id$\r
  */\r
 \r
+\r
+#include "ibspdebug.h"\r
+\r
+#if defined(EVENT_TRACING)\r
+#ifdef offsetof\r
+#undef offsetof\r
+#endif\r
+#include "extensions.tmh"\r
+#endif\r
+\r
 #include "ibspdll.h"\r
 \r
 \r
@@ -55,14 +66,14 @@ IBSPRegisterMemory(
 \r
        if( lpBuffer == NULL )\r
        {\r
-               IBSP_ERROR_EXIT( ("invalid buffer %p\n", lpBuffer) );\r
+               IBSP_ERROR_EXIT( ( "invalid buffer %p\n", lpBuffer ) );\r
                *lpErrno = WSAEFAULT;\r
                return NULL;\r
        }\r
 \r
        if( dwBufferLength > socket_info->socket_options.max_msg_size )\r
        {\r
-               IBSP_ERROR_EXIT( ("invalid buffer length %d\n", dwBufferLength) );\r
+               IBSP_ERROR_EXIT( ( "invalid buffer length %d\n", dwBufferLength ) );\r
                *lpErrno = WSAEFAULT;\r
                return NULL;\r
        }\r
@@ -97,13 +108,13 @@ IBSPRegisterMemory(
 \r
        if( node == NULL )\r
        {\r
-               IBSP_ERROR_EXIT(\r
-                       ("ibsp_reg_mem failed (pd=%p)\n", socket_info->hca_pd) );\r
+               IBSP_ERROR( ("ibsp_reg_mem failed (pd=%p)\n", socket_info->hca_pd) );\r
                *lpErrno = WSAENOBUFS;\r
        }\r
        else\r
        {\r
-               IBSP_TRACE_EXIT( IBSP_DBG_MEM, ("returning node %p\n", node) );\r
+               IBSP_PRINT(TRACE_LEVEL_INFORMATION,\r
+                       IBSP_DBG_MEM, ("returning node %p\n", node) );\r
                *lpErrno = 0;\r
        }\r
 \r
@@ -133,7 +144,7 @@ IBSPDeregisterMemory(
 \r
        if( s == INVALID_SOCKET )\r
        {\r
-               IBSP_ERROR( ("invalid socket handle %x\n", s) );\r
+               IBSP_ERROR_EXIT( ("invalid socket handle %Ix\n", s) );\r
                *lpErrno = WSAENOTSOCK;\r
                return SOCKET_ERROR;\r
        }\r
@@ -177,8 +188,7 @@ IBSPRegisterRdmaMemory(
        if( *lpdwDescriptorLength < sizeof(struct rdma_memory_desc) )\r
        {\r
                /* This is the probe from the switch to learn the length of the descriptor. */\r
-               IBSP_ERROR_EXIT(\r
-                       ("invalid descriptor length %d (usually not an error)\n",\r
+               IBSP_ERROR_EXIT( ("invalid descriptor length %d (usually not an error)\n",\r
                        *lpdwDescriptorLength) );\r
                *lpdwDescriptorLength = sizeof(struct rdma_memory_desc);\r
                *lpErrno = WSAEFAULT;\r
@@ -241,11 +251,12 @@ IBSPRegisterRdmaMemory(
 \r
        *lpErrno = 0;\r
 \r
-       IBSP_TRACE1( IBSP_DBG_MEM,\r
-               ("Socket %p registered RDMA MEM at %p, len %d, for access %d, "\r
+       IBSP_PRINT(TRACE_LEVEL_INFORMATION, IBSP_DBG_MEM,\r
+               ("Socket %Ix registered RDMA MEM at %p, len %d, for access %d, "\r
                "returning handle %p, rkey %08x\n",\r
                s, lpBuffer, dwBufferLength, dwFlags, node, desc->rkey));\r
 \r
+\r
        IBSP_EXIT( IBSP_DBG_MEM );\r
 \r
        return 0;\r
@@ -275,7 +286,7 @@ IBSPDeregisterRdmaMemory(
        {\r
                /* Seen in real life with overlap/client test.\r
                 * The switch closes a socket then calls this. Why? */\r
-               IBSP_ERROR_EXIT( ("invalid socket handle %x\n", s) );\r
+               IBSP_ERROR_EXIT( ("invalid socket handle %Ix\n", s) );\r
                *lpErrno = WSAENOTSOCK;\r
                return SOCKET_ERROR;\r
        }\r
@@ -284,8 +295,7 @@ IBSPDeregisterRdmaMemory(
 \r
        if( dwDescriptorLength < sizeof(struct rdma_memory_desc) )\r
        {\r
-               IBSP_ERROR_EXIT(\r
-                       ("invalid descriptor length %d)\n", dwDescriptorLength) );\r
+               IBSP_ERROR_EXIT( ("invalid descriptor length %d)\n", dwDescriptorLength) );\r
                *lpErrno = WSAEINVAL;\r
                return SOCKET_ERROR;\r
        }\r
@@ -339,8 +349,7 @@ do_rdma_op(
 \r
        default:\r
                cl_spinlock_release( &socket_info->mutex );\r
-               IBSP_ERROR_EXIT(\r
-                       ("Socket is not in connected socket_state state=%s\n",\r
+               IBSP_ERROR_EXIT( ("Socket is not in connected socket_state state=%s\n",\r
                        IBSP_SOCKET_STATE_STR( socket_info->socket_state )) );\r
                *lpErrno = WSAENOTCONN;\r
                return SOCKET_ERROR;\r
@@ -349,8 +358,7 @@ do_rdma_op(
 \r
        if( socket_info->qp_error )\r
        {\r
-               IBSP_ERROR_EXIT(\r
-                       ("QP is in error state %d\n", socket_info->qp_error) );\r
+               IBSP_ERROR_EXIT( ("QP is in error state %d\n", socket_info->qp_error) );\r
                *lpErrno = socket_info->qp_error;\r
                return SOCKET_ERROR;\r
        }\r
@@ -360,7 +368,7 @@ do_rdma_op(
        {\r
                CL_ASSERT( dwBufferCount <= QP_ATTRIB_SQ_SGE );\r
                /* TODO - support splitting large requests into multiple RDMA operations. */\r
-               IBSP_ERROR_EXIT(\r
+               IBSP_ERROR_EXIT( \r
                        ("dwBufferCount is greater than %d\n", QP_ATTRIB_SQ_SGE) );\r
                *lpErrno = WSAEINVAL;\r
                return SOCKET_ERROR;\r
@@ -368,8 +376,8 @@ do_rdma_op(
 \r
        if( dwTargetDescriptorLength != sizeof(struct rdma_memory_desc) )\r
        {\r
-               IBSP_ERROR_EXIT(\r
-                       ("invalid descriptor length %d)\n", dwTargetDescriptorLength) );\r
+               IBSP_ERROR_EXIT( (\r
+                       "invalid descriptor length %d)\n", dwTargetDescriptorLength) );\r
                *lpErrno = WSAEINVAL;\r
                return SOCKET_ERROR;\r
        }\r
@@ -470,8 +478,8 @@ do_rdma_op(
 \r
                *lpErrno = WSA_IO_PENDING;\r
 \r
-               IBSP_TRACE1( IBSP_DBG_IO,\r
-                       ("Posted RDMA: socket=%p, ov=%p, type=%d, local=%p, len=%d, "\r
+               IBSP_PRINT(TRACE_LEVEL_INFORMATION, IBSP_DBG_IO,\r
+                       ("Posted RDMA: socket=%Ix, ov=%p, type=%d, local=%p, len=%d, "\r
                        "dest=%016I64x, rkey=%08x\n",\r
                        s, lpOverlapped, wr_type, lpBuffers[0].buf, lpBuffers[0].len,\r
                        send_wr.remote_ops.vaddr, send_wr.remote_ops.rkey) );\r
@@ -481,8 +489,7 @@ do_rdma_op(
        }\r
        else\r
        {\r
-               IBSP_ERROR(\r
-                       ("ib_post_send returned %s\n", ib_get_err_str( status )) );\r
+               IBSP_ERROR( ("ib_post_send returned %s\n", ib_get_err_str( status )) );\r
 \r
 #ifdef _DEBUG_\r
 \r
@@ -542,7 +549,7 @@ IBSPRdmaWrite(
 \r
        if( s == INVALID_SOCKET )\r
        {\r
-               IBSP_ERROR_EXIT( ("invalid socket handle %x\n", s) );\r
+               IBSP_ERROR_EXIT( ("invalid socket handle %Ix\n", s) );\r
                *lpErrno = WSAENOTSOCK;\r
                return SOCKET_ERROR;\r
        }\r
index 3fe4f71..2c77be9 100644 (file)
@@ -1,5 +1,6 @@
 /*\r
  * Copyright (c) 2005 SilverStorm Technologies.  All rights reserved.\r
+ * Copyright (c) 2006 Mellanox Technologies.  All rights reserved.\r
  *\r
  * This software is available to you under the OpenIB.org BSD license\r
  * below:\r
  *\r
  * $Id$\r
  */\r
+#include "ibspdebug.h"\r
+#if defined(EVENT_TRACING)\r
+#include "ib_cm.tmh"\r
+#endif\r
 \r
 #include "ibspdll.h"\r
 \r
@@ -67,13 +72,13 @@ ibsp_post_select_event(
        switch( event )\r
        {\r
        case FD_CONNECT:\r
-               IBSP_TRACE1( IBSP_DBG_NEV,\r
+               IBSP_PRINT(TRACE_LEVEL_INFORMATION, IBSP_DBG_NEV,\r
                        ("socket %p FD_CONNECT\n", socket_info) );\r
                socket_info->errno_connect = error;\r
                break;\r
 \r
        case FD_ACCEPT:\r
-               IBSP_TRACE1( IBSP_DBG_NEV,\r
+               IBSP_PRINT(TRACE_LEVEL_INFORMATION, IBSP_DBG_NEV,\r
                        ("socket %p FD_ACCEPT\n", socket_info) );\r
                break;\r
 \r
@@ -89,7 +94,7 @@ ibsp_post_select_event(
        /* Check for event notification request and signal as needed. */\r
        if( (socket_info->event_mask & event) && h_event )\r
        {\r
-               IBSP_TRACE2( IBSP_DBG_NEV,\r
+               IBSP_PRINT(TRACE_LEVEL_INFORMATION, IBSP_DBG_NEV,\r
                        ("Signaling eventHandle %p at time %I64d.\n",\r
                        h_event, cl_get_time_stamp() ) );\r
                SetEvent( h_event );\r
@@ -125,7 +130,7 @@ cm_req_callback(
                        socket_info->listen.backlog )\r
                {\r
                        /* Already too many connection requests are queued */\r
-                       IBSP_TRACE1( IBSP_DBG_CM,\r
+                       IBSP_PRINT(TRACE_LEVEL_INFORMATION, IBSP_DBG_CM,\r
                                ("already too many incoming connections, rejecting\n") );\r
                        ib_reject( p_cm_req_rec->h_cm_req, IB_REJ_USER_DEFINED );\r
                        break;\r
@@ -168,8 +173,8 @@ cm_req_callback(
                        if( ret )\r
                        {\r
                                cl_spinlock_release( &socket_info->mutex );\r
-                               IBSP_ERROR(\r
-                                       ("ib_accept for duplicate socket returned %d, rejecting\n",\r
+                               IBSP_ERROR( (\r
+                                       "ib_accept for duplicate socket returned %d, rejecting\n",\r
                                        ret) );\r
                                /* Call ib_destroy_socket for above ib_create_socket() call */\r
                                ib_destroy_socket( socket_info );\r
@@ -358,8 +363,8 @@ cm_rtu_callback(
                        }\r
                        else\r
                        {\r
-                               IBSP_ERROR(\r
-                                       ("ib_post_recv returned %s for reposted buffer\n",\r
+                               IBSP_ERROR( (\r
+                                       "ib_post_recv returned %s for reposted buffer\n",\r
                                        ib_get_err_str( status )) );\r
 \r
                                cl_atomic_dec( &socket_info->recv_cnt );\r
@@ -377,8 +382,7 @@ cm_rtu_callback(
        else if( socket_info->socket_state != IBSP_CONNECTED )\r
        {\r
                /* The Socket might be closing */\r
-               IBSP_ERROR(\r
-                       ("Got RTU while in socket_state %s - ignoring\n",\r
+               IBSP_ERROR( ("Got RTU while in socket_state %s - ignoring\n",\r
                        IBSP_SOCKET_STATE_STR( socket_info->socket_state )) );\r
        }\r
 \r
@@ -421,7 +425,7 @@ cm_rej_callback(
 \r
        IBSP_ENTER( IBSP_DBG_CM );\r
 \r
-       IBSP_TRACE( IBSP_DBG_CM, ("socket %p connect reject, reason=%d\n",\r
+       IBSP_PRINT(TRACE_LEVEL_INFORMATION, IBSP_DBG_CM, ("socket %p connect reject, reason=%d\n",\r
                socket_info, cl_ntoh16(p_cm_rej_rec->rej_status)) );\r
 \r
        cl_spinlock_acquire( &socket_info->mutex );\r
@@ -503,7 +507,7 @@ cm_dreq_callback(
                (struct ibsp_socket_info * __ptr64)p_cm_dreq_rec->qp_context;\r
 \r
        IBSP_ENTER( IBSP_DBG_CM );\r
-       IBSP_TRACE1( IBSP_DBG_CM,\r
+       IBSP_PRINT(TRACE_LEVEL_INFORMATION, IBSP_DBG_CM,\r
                ("socket=%p state=%s\n",\r
                socket_info, IBSP_SOCKET_STATE_STR( socket_info->socket_state )) );\r
 \r
@@ -611,7 +615,7 @@ cm_apr_callback(
 \r
        UNUSED_PARAM( p_cm_apr_rec );\r
 \r
-       IBSP_ERROR( ("not implemented"));\r
+       IBSP_ERROR( ("not implemented") );\r
 \r
        CL_ASSERT( 0 );\r
 \r
@@ -634,7 +638,7 @@ cm_lap_callback(
 \r
        UNUSED_PARAM( p_cm_lap_rec );\r
 \r
-       IBSP_ERROR( ("not implemented"));\r
+       IBSP_ERROR( ("not implemented") );\r
 \r
        CL_ASSERT( 0 );\r
 \r
@@ -694,7 +698,7 @@ ib_listen(
 \r
        STAT_INC( listen_num );\r
 \r
-       IBSP_TRACE_EXIT( IBSP_DBG_CM,\r
+       IBSP_PRINT_EXIT(TRACE_LEVEL_INFORMATION, IBSP_DBG_CM,\r
                ("started listening for port %d\n",\r
                CL_HTON16( socket_info->local_addr.sin_port )) );\r
 \r
@@ -739,8 +743,8 @@ ib_listen_cancel(
        status = ib_cm_cancel( socket_info->listen.handle, ib_sync_destroy );\r
        if( status )\r
        {\r
-               IBSP_ERROR(\r
-                       ("ib_cm_cancel returned %s\n", ib_get_err_str( status )) );\r
+               IBSP_ERROR( (\r
+                       "ib_cm_cancel returned %s\n", ib_get_err_str( status )) );\r
        }\r
        else\r
        {\r
@@ -773,10 +777,10 @@ ib_connect(
        fzprint(("%s():%d:0x%x:0x%x: socket=0x%p \n", __FUNCTION__,\r
                         __LINE__, GetCurrentProcessId(), GetCurrentThreadId(), socket_info));\r
 \r
-       IBSP_TRACE( IBSP_DBG_CM, ("From:\n") );\r
-       DebugPrintSockAddr( IBSP_DBG_CM, gdbg_lvl, &socket_info->local_addr );\r
-       IBSP_TRACE( IBSP_DBG_CM, ("To:\n") );\r
-       DebugPrintSockAddr( IBSP_DBG_CM, gdbg_lvl, &socket_info->peer_addr );\r
+       IBSP_PRINT(TRACE_LEVEL_INFORMATION, IBSP_DBG_CM, ("From:\n") );\r
+       DebugPrintSockAddr( IBSP_DBG_CM, &socket_info->local_addr );\r
+       IBSP_PRINT(TRACE_LEVEL_INFORMATION, IBSP_DBG_CM, ("To:\n") );\r
+       DebugPrintSockAddr( IBSP_DBG_CM, &socket_info->peer_addr );\r
 \r
        /* Insert into the connection map. */\r
        if( !ibsp_conn_insert( socket_info ) )\r
@@ -798,10 +802,10 @@ ib_connect(
        params.listen_req_param.dwProcessId = socket_info->duplicate.dwProcessId;\r
        params.listen_req_param.identifier = socket_info->duplicate.identifier;\r
 \r
-       IBSP_TRACE( IBSP_DBG_CM,\r
-               ("ib_connect listen params: %x %x\n", params.listen_req_param.dwProcessId,\r
-               params.listen_req_param.identifier) );\r
-       IBSP_TRACE( IBSP_DBG_CM,\r
+       IBSP_PRINT(TRACE_LEVEL_INFORMATION, IBSP_DBG_CM,\r
+               ("ib_connect listen params: %x \n", params.listen_req_param.dwProcessId\r
+               /*params.listen_req_param.identifier*/));\r
+       IBSP_PRINT(TRACE_LEVEL_INFORMATION, IBSP_DBG_CM,\r
                ("connecting to port %d, SID=%016I64x\n", socket_info->peer_addr.sin_port,\r
                cm_req.svc_id) );\r
 \r
@@ -921,8 +925,7 @@ ib_accept(
                /* Remove from connection map. */\r
                ibsp_conn_remove( socket_info );\r
 \r
-               IBSP_ERROR_EXIT(\r
-                       ("ib_cm_rep failed (0x%d) at time %I64d\n",\r
+               IBSP_ERROR_EXIT( ("ib_cm_rep failed (0x%s) at time %I64d\n",\r
                        ib_get_err_str( status ), cl_get_time_stamp()) );\r
                return WSAEACCES;\r
        }\r
index 0c49c81..d22a109 100644 (file)
@@ -1,5 +1,6 @@
 /*\r
  * Copyright (c) 2005 SilverStorm Technologies.  All rights reserved.\r
+ * Copyright (c) 2006 Mellanox Technologies.  All rights reserved.\r
  *\r
  * This software is available to you under the OpenIB.org BSD license\r
  * below:\r
  * $Id$\r
  */\r
 \r
+\r
+#include "ibspdebug.h"\r
+#if defined(EVENT_TRACING)\r
+\r
+#include "ibsp_duplicate.tmh"\r
+#endif\r
+\r
 #include "ibspdll.h"\r
 #include "rpc.h"\r
 \r
@@ -200,7 +208,7 @@ IBSPDuplicateSocket(
 \r
        IBSP_ENTER( IBSP_DBG_DUP );\r
 \r
-       IBSP_TRACE4( IBSP_DBG_DUP,\r
+       IBSP_PRINT(TRACE_LEVEL_INFORMATION, IBSP_DBG_DUP,\r
                ("Duplicating socket=0x%p to dwProcessId=0x%x \n",\r
                socket_info, dwProcessId) );\r
 \r
@@ -208,7 +216,7 @@ IBSPDuplicateSocket(
        if( socket_info->socket_state != IBSP_CONNECTED )\r
        {\r
                cl_spinlock_release( &socket_info->mutex );\r
-               IBSP_TRACE_EXIT( IBSP_DBG_DUP,\r
+               IBSP_PRINT_EXIT(TRACE_LEVEL_INFORMATION, IBSP_DBG_DUP,\r
                        ("Socket state not IBSP_CONNECTED, state=%s.\n",\r
                        IBSP_SOCKET_STATE_STR( socket_info->socket_state )) );\r
                *lpErrno = WSAENOTCONN;\r
@@ -224,8 +232,7 @@ IBSPDuplicateSocket(
        if( !h_dup_info )\r
        {\r
                cl_spinlock_release( &socket_info->mutex );\r
-               IBSP_ERROR_EXIT(\r
-                       ("CreateFileMapping for %s failed with %d\n",\r
+               IBSP_ERROR_EXIT( ("CreateFileMapping for %s failed with %d\n",\r
                        fname, GetLastError()) );\r
                *lpErrno = WSAENETDOWN;\r
                return SOCKET_ERROR;\r
@@ -236,8 +243,7 @@ IBSPDuplicateSocket(
        if( !dup_info )\r
        {\r
                cl_spinlock_release( &socket_info->mutex );\r
-               IBSP_ERROR_EXIT(\r
-                       ("MapViewOfFile failed with %d\n", GetLastError()) );\r
+               IBSP_ERROR_EXIT( ("MapViewOfFile failed with %d\n", GetLastError()) );\r
                CloseHandle( h_dup_info );\r
                *lpErrno = WSAENETDOWN;\r
                return SOCKET_ERROR;\r
@@ -261,8 +267,7 @@ IBSPDuplicateSocket(
        if( !h_target_process )\r
        {\r
                cl_spinlock_release( &socket_info->mutex );\r
-               IBSP_ERROR_EXIT(\r
-                       ("OpenProcess failed with %d\n", GetLastError()) );\r
+               IBSP_ERROR_EXIT( ("OpenProcess failed with %d\n", GetLastError()) );\r
                CloseHandle( h_dup_info );\r
                *lpErrno = WSAENETDOWN;\r
                return SOCKET_ERROR;\r
@@ -273,8 +278,7 @@ IBSPDuplicateSocket(
                DUPLICATE_CLOSE_SOURCE | DUPLICATE_SAME_ACCESS ) )\r
        {\r
                cl_spinlock_release( &socket_info->mutex );\r
-               IBSP_ERROR_EXIT(\r
-                       ("DuplicateHandle failed with %d\n", GetLastError()) );\r
+               IBSP_ERROR_EXIT( ("DuplicateHandle failed with %d\n", GetLastError()) );\r
                CloseHandle( h_target_process );\r
                CloseHandle( h_dup_info );\r
                *lpErrno = WSAENETDOWN;\r
index dade094..ab33d36 100644 (file)
@@ -1,5 +1,6 @@
 /*\r
  * Copyright (c) 2005 SilverStorm Technologies.  All rights reserved.\r
+ * Copyright (c) 2006 Mellanox Technologies.  All rights reserved.\r
  *\r
  * This software is available to you under the OpenIB.org BSD license\r
  * below:\r
  *\r
  * $Id$\r
  */\r
+#include "ibspdebug.h"\r
+\r
+#if defined(EVENT_TRACING)\r
+#ifdef offsetof\r
+#undef offsetof\r
+#endif\r
+#include "ibsp_iblow.tmh"\r
+#endif\r
 \r
 #include "ibspdll.h"\r
 \r
@@ -67,7 +76,7 @@ complete_wq(
 \r
        lpOverlapped = wr->lpOverlapped;\r
 \r
-       IBSP_TRACE4( IBSP_DBG_IO,\r
+       IBSP_PRINT(TRACE_LEVEL_INFORMATION, IBSP_DBG_IO,\r
                ("socket %p, ov %p, work completion status=%s, wc_type=%s\n",\r
                socket_info, lpOverlapped, ib_get_wc_status_str( wc->status ),\r
                ib_get_wc_type_str( wc->wc_type )) );\r
@@ -210,7 +219,7 @@ complete_wq(
                        IBSP_ERROR( ("%s (%s:%d to ",\r
                                comp_name, inet_ntoa( socket_info->local_addr.sin_addr ),\r
                                socket_info->local_addr.sin_port) );\r
-                       IBSP_ERROR( ("%s:%d) %s error: %s (vendor specific %i64x)\n",\r
+                       IBSP_ERROR( ("%s:%d) %s error: %s (vendor specific %I64x)\n",\r
                                inet_ntoa( socket_info->peer_addr.sin_addr ),\r
                                socket_info->peer_addr.sin_port,\r
                                ib_get_wc_type_str( wc->wc_type ),\r
@@ -248,7 +257,7 @@ complete_wq(
 \r
                if( wc->status == IB_SUCCESS && p_recv_wr->ds_array[0].length >= 40 )\r
                {\r
-                       debug_dump_buffer( IBSP_DBG_WQ | IBSP_DBG_LEVEL4, "RECV",\r
+                       debug_dump_buffer( IBSP_DBG_WQ, "RECV",\r
                                (void * __ptr64)p_recv_wr->ds_array[0].vaddr, 40 );\r
                }\r
 \r
@@ -287,11 +296,12 @@ complete_wq(
                memset( wr, 0x33, sizeof(struct _wr) );\r
        }\r
 #endif\r
-\r
-       IBSP_TRACE4( IBSP_DBG_IO,\r
-               ("overlapped=%p, InternalHigh=%d, hEvent=%x\n",\r
+       IBSP_PRINT(TRACE_LEVEL_INFORMATION, IBSP_DBG_IO,\r
+               ("overlapped=%p, InternalHigh=%Id, hEvent=%p\n",\r
                lpOverlapped, lpOverlapped->InternalHigh,\r
-               (uintptr_t) lpOverlapped->hEvent) );\r
+                lpOverlapped->hEvent) );\r
+       \r
+\r
 \r
        /* Don't notify the switch for that completion only if:\r
         *   - the switch don't want a notification\r
@@ -313,9 +323,9 @@ complete_wq(
                                 g_ibsp.overlap_h1_comp_count, g_ibsp.send_count, g_ibsp.recv_count));\r
 #endif\r
 \r
-               IBSP_TRACE1( IBSP_DBG_IO,\r
+               IBSP_PRINT(TRACE_LEVEL_INFORMATION, IBSP_DBG_IO,\r
                        ("Not calling lpWPUCompleteOverlappedRequest: "\r
-                       "socket=%p, ov=%p OffsetHigh=%d, InternalHigh=%d hEvent=%p\n",\r
+                       "socket=%p, ov=%p OffsetHigh=%d, InternalHigh=%Id hEvent=%p\n",\r
                        socket_info, lpOverlapped, lpOverlapped->OffsetHigh,\r
                        lpOverlapped->InternalHigh, lpOverlapped->hEvent) );\r
 \r
@@ -387,9 +397,8 @@ ib_cq_comp(
 \r
                status = ib_poll_cq( cq_tinfo->cq, &free_wclist, &done_wclist );\r
 \r
-               IBSP_TRACE( IBSP_DBG_WQ,\r
-                       ("%s():%d:0x%x:0x%x: poll CQ got status %d, free=%p, done=%p\n",\r
-                       __FUNCTION__, __LINE__, GetCurrentProcessId(), GetCurrentThreadId(),\r
+               IBSP_PRINT(TRACE_LEVEL_INFORMATION, IBSP_DBG_WQ,\r
+                       ("poll CQ got status %d, free=%p, done=%p\n",\r
                        status, free_wclist, done_wclist) );\r
 \r
                switch( status )\r
@@ -401,13 +410,13 @@ ib_cq_comp(
                case IB_INVALID_CQ_HANDLE:\r
                        /* This happens when the switch closes the socket while the \r
                         * execution thread was calling lpWPUCompleteOverlappedRequest. */\r
-                       IBSP_ERROR(\r
-                               ("ib_poll_cq returned IB_INVLALID_CQ_HANDLE\n") );\r
+                       IBSP_ERROR( (\r
+                               "ib_poll_cq returned IB_INVLALID_CQ_HANDLE\n") );\r
                        goto done;\r
 \r
                default:\r
-                       IBSP_ERROR(\r
-                               ("ib_poll_cq failed returned %s\n", ib_get_err_str( status )) );\r
+                       IBSP_ERROR( (\r
+                               "ib_poll_cq failed returned %s\n", ib_get_err_str( status )) );\r
                        break;\r
                }\r
 \r
@@ -434,10 +443,10 @@ ib_cq_comp(
 \r
                        if( info[i].p_ov )\r
                        {\r
-                               IBSP_TRACE1( IBSP_DBG_IO,\r
+                               IBSP_PRINT(TRACE_LEVEL_INFORMATION, IBSP_DBG_IO,\r
                                        ("Calling lpWPUCompleteOverlappedRequest: "\r
                                        "socket=%p, ov=%p OffsetHigh=%d "\r
-                                       "InternalHigh=%d hEvent=%p\n",\r
+                                       "InternalHigh=%Id hEvent=%p\n",\r
                                        info[i].p_socket, info[i].p_ov, info[i].p_ov->OffsetHigh,\r
                                        info[i].p_ov->InternalHigh, info[i].p_ov->hEvent) );\r
 \r
@@ -496,9 +505,9 @@ ib_cq_thread(
 \r
        old_afinity = SetThreadAffinityMask (GetCurrentThread (),g_dwPollThreadAffinityMask);\r
        if (old_afinity == 0) {\r
-               OutputDebugString("SetThreadAffinityMask failed\n");\r
+               IBSP_ERROR(("SetThreadAffinityMask failed\n"));\r
        } else {\r
-               OutputDebugString("SetThreadAffinityMask succeeded\n");\r
+               IBSP_PRINT(TRACE_LEVEL_INFORMATION, IBSP_DBG_DLL,("SetThreadAffinityMask succeeded\n"));\r
        }\r
 \r
 \r
@@ -507,8 +516,8 @@ ib_cq_thread(
                cl_status = cl_waitobj_wait_on( cq_tinfo->cq_waitobj, EVENT_NO_TIMEOUT, TRUE );\r
                if( cl_status != CL_SUCCESS )\r
                {\r
-                       IBSP_ERROR(\r
-                               ("cl_waitobj_wait_on() (%d)\n", cl_status) );\r
+                       IBSP_ERROR( (\r
+                               "cl_waitobj_wait_on() (%d)\n", cl_status) );\r
                }\r
 \r
                /* \r
@@ -537,8 +546,8 @@ ib_cq_thread(
                        status = ib_rearm_cq( cq_tinfo->cq, FALSE );\r
                        if( status != IB_SUCCESS )\r
                        {\r
-                               IBSP_ERROR(\r
-                                       ("ib_rearm_cq returned %s)\n", ib_get_err_str( status )) );\r
+                               IBSP_ERROR( (\r
+                                       "ib_rearm_cq returned %s)\n", ib_get_err_str( status )) );\r
                        }\r
                }\r
 \r
@@ -547,8 +556,8 @@ ib_cq_thread(
        cl_status = cl_waitobj_destroy( cq_tinfo->cq_waitobj );\r
        if( cl_status != CL_SUCCESS )\r
        {\r
-               IBSP_ERROR(\r
-                       ("cl_waitobj_destroy() returned %s\n", CL_STATUS_MSG(cl_status)) );\r
+               IBSP_ERROR( (\r
+                       "cl_waitobj_destroy() returned %s\n", CL_STATUS_MSG(cl_status)) );\r
        }\r
        HeapFree( g_ibsp.heap, 0, cq_tinfo );\r
 \r
@@ -584,8 +593,8 @@ ib_alloc_cq_tinfo(
        {\r
                cq_tinfo->cq_waitobj = NULL;\r
                ib_destroy_cq_tinfo( cq_tinfo );\r
-               IBSP_ERROR_EXIT(\r
-                       ("cl_waitobj_create() returned %s\n", CL_STATUS_MSG(cl_status)) );\r
+               IBSP_ERROR_EXIT( (\r
+                       "cl_waitobj_create() returned %s\n", CL_STATUS_MSG(cl_status)) );\r
                return NULL;\r
        }\r
 \r
@@ -615,8 +624,8 @@ ib_alloc_cq_tinfo(
        if( status )\r
        {\r
                ib_destroy_cq_tinfo( cq_tinfo );\r
-               IBSP_ERROR_EXIT(\r
-                       ("ib_create_cq returned %s\n", ib_get_err_str( status )) );\r
+               IBSP_ERROR_EXIT( (\r
+                       "ib_create_cq returned %s\n", ib_get_err_str( status )) );\r
                return NULL;\r
        }\r
 \r
@@ -626,8 +635,8 @@ ib_alloc_cq_tinfo(
        if( status )\r
        {\r
                ib_destroy_cq_tinfo( cq_tinfo );\r
-               IBSP_ERROR_EXIT(\r
-                       ("ib_rearm_cq returned %s\n", ib_get_err_str( status )) );\r
+               IBSP_ERROR_EXIT( (\r
+                       "ib_rearm_cq returned %s\n", ib_get_err_str( status )) );\r
                return NULL;\r
        }\r
 \r
@@ -680,11 +689,11 @@ ib_destroy_cq_tinfo(
                while( ib_poll_cq(\r
                        cq_tinfo->cq, &free_wclist, &done_wclist ) == IB_SUCCESS )\r
                {\r
-                       IBSP_TRACE1( IBSP_DBG_WQ,\r
+                       IBSP_PRINT(TRACE_LEVEL_INFORMATION, IBSP_DBG_WQ,\r
                                ("free=%p, done=%p\n", free_wclist, done_wclist) );\r
                }\r
 \r
-               IBSP_TRACE4( IBSP_DBG_WQ, ("ib_destroy_cq() start..\n") );\r
+               IBSP_PRINT(TRACE_LEVEL_INFORMATION, IBSP_DBG_WQ, ("ib_destroy_cq() start..\n") );\r
 \r
                /*\r
                 * Called from cleanup thread, okay to block.\r
@@ -692,12 +701,12 @@ ib_destroy_cq_tinfo(
                status = ib_destroy_cq( cq_tinfo->cq, ib_sync_destroy );\r
                if( status )\r
                {\r
-                       IBSP_ERROR(\r
-                               ("ib_destroy_cq returned %s\n", ib_get_err_str( status )) );\r
+                       IBSP_ERROR( (\r
+                               "ib_destroy_cq returned %s\n", ib_get_err_str( status )) );\r
                }\r
                else\r
                {\r
-                       IBSP_TRACE4( IBSP_DBG_WQ, ("ib_destroy_cq() finished.\n") );\r
+                       IBSP_PRINT(TRACE_LEVEL_INFORMATION, IBSP_DBG_WQ, ("ib_destroy_cq() finished.\n") );\r
 \r
                        cq_tinfo->cq = NULL;\r
 \r
@@ -800,8 +809,8 @@ ib_acquire_cq_tinfo(
                        break;\r
 \r
                default:\r
-                       IBSP_ERROR_EXIT(\r
-                               ("ib_modify_cq() returned %s\n", ib_get_err_str(status)) );\r
+                       IBSP_ERROR_EXIT( (\r
+                               "ib_modify_cq() returned %s\n", ib_get_err_str(status)) );\r
                case IB_INVALID_CQ_SIZE:\r
                case IB_UNSUPPORTED:\r
                        cq_tinfo = PARENT_STRUCT(\r
@@ -871,12 +880,12 @@ ib_release(void)
                                 status));\r
                if( status != IB_SUCCESS )\r
                {\r
-                       IBSP_ERROR(\r
-                               ("ib_close_al returned %s\n", ib_get_err_str( status )) );\r
+                       IBSP_ERROR( (\r
+                               "ib_close_al returned %s\n", ib_get_err_str( status )) );\r
                }\r
                else\r
                {\r
-                       IBSP_TRACE( IBSP_DBG_HW, ("ib_close_al success\n") );\r
+                       IBSP_PRINT(TRACE_LEVEL_INFORMATION, IBSP_DBG_HW, ("ib_close_al success\n") );\r
                        STAT_DEC( al_num );\r
                }\r
                g_ibsp.al_handle = NULL;\r
@@ -911,7 +920,7 @@ ibsp_initialize(void)
        /* Open the IB library */\r
        status = ib_open_al( &g_ibsp.al_handle );\r
 \r
-       IBSP_TRACE( IBSP_DBG_HW, ("open is %d %p\n", status, g_ibsp.al_handle) );\r
+       IBSP_PRINT(TRACE_LEVEL_INFORMATION, IBSP_DBG_HW, ("open is %d %p\n", status, g_ibsp.al_handle) );\r
 \r
        if( status != IB_SUCCESS )\r
        {\r
@@ -1020,8 +1029,8 @@ ib_create_socket(
        if( status )\r
        {\r
                ib_release_cq_tinfo( socket_info->cq_tinfo );\r
-               IBSP_ERROR_EXIT(\r
-                       ("ib_create_qp returned %s\n", ib_get_err_str( status )) );\r
+               IBSP_ERROR_EXIT( (\r
+                       "ib_create_qp returned %s\n", ib_get_err_str( status )) );\r
                return WSAENOBUFS;\r
        }\r
 \r
@@ -1111,9 +1120,9 @@ ibsp_dup_overlap_abort(
                                         g_ibsp.overlap_h1_comp_count, g_ibsp.send_count, g_ibsp.recv_count));\r
 #endif\r
 \r
-                       CL_TRACE(IBSP_DBG_WQ, gdbg_lvl,\r
-                                        ("%s: set internal overlapped=0x%p Internal=%d OffsetHigh=%d\n",\r
-                                         __FUNCTION__, lpOverlapped, lpOverlapped->Internal,\r
+                       IBSP_PRINT(TRACE_LEVEL_INFORMATION,IBSP_DBG_WQ, \r
+                                        ("set internal overlapped=0x%p Internal=%Id OffsetHigh=%d\n",\r
+                                         lpOverlapped, lpOverlapped->Internal,\r
                                          lpOverlapped->OffsetHigh));\r
 \r
                        lpOverlapped->Internal = 0;\r
@@ -1130,9 +1139,10 @@ ibsp_dup_overlap_abort(
                                         g_ibsp.overlap_h0_count, g_ibsp.overlap_h1_count,\r
                                         g_ibsp.overlap_h1_comp_count, g_ibsp.send_count, g_ibsp.recv_count));\r
 #endif\r
-                       CL_TRACE(IBSP_DBG_WQ, gdbg_lvl,\r
-                                        ("%s: calls lpWPUCompleteOverlappedRequest, overlapped=0x%p OffsetHigh=%d InternalHigh=%d hEvent=%d\n",\r
-                                         __FUNCTION__, lpOverlapped, lpOverlapped->OffsetHigh,\r
+                       IBSP_PRINT(TRACE_LEVEL_INFORMATION,IBSP_DBG_WQ,\r
+                                        (" calls lpWPUCompleteOverlappedRequest, overlapped=0x%p OffsetHigh=%d "\r
+                                        "InternalHigh=%Id hEvent=%p\n",\r
+                                          lpOverlapped, lpOverlapped->OffsetHigh,\r
                                          lpOverlapped->InternalHigh, lpOverlapped->hEvent));\r
 \r
                        ret = g_ibsp.up_call_table.lpWPUCompleteOverlappedRequest\r
@@ -1142,9 +1152,7 @@ ibsp_dup_overlap_abort(
 \r
                        if( ret != 0 )\r
                        {\r
-                               CL_ERROR(IBSP_DBG_EP, gdbg_lvl,\r
-                                                ("lpWPUCompleteOverlappedRequest failed with %d/%d\n", ret,\r
-                                                 error));\r
+                               IBSP_ERROR( ("lpWPUCompleteOverlappedRequest failed with %d/%d\n", ret, error) );\r
                        }\r
                }\r
                cl_atomic_dec( &socket_info->dup_cnt );\r
index 8c14db4..b0a9572 100644 (file)
@@ -1,5 +1,6 @@
 /*\r
  * Copyright (c) 2005 SilverStorm Technologies.  All rights reserved.\r
+ * Copyright (c) 2006 Mellanox Technologies.  All rights reserved.\r
  *\r
  * This software is available to you under the OpenIB.org BSD license\r
  * below:\r
 /* Builds and returns the list of IP addresses available from all\r
  * adapters. */\r
 \r
+#include "ibspdebug.h"\r
+#if defined(EVENT_TRACING)\r
+#ifdef offsetof\r
+#undef offsetof\r
+#endif\r
+#include "ibsp_ip.tmh"\r
+#endif\r
+\r
 #include "ibspdll.h"\r
 \r
 /*--------------------------------------------------------------------------*/\r
@@ -117,8 +126,8 @@ query_ip_address(
                        &in, sizeof(in), p_out, size, &size, NULL ) )\r
                {\r
                        HeapFree( g_ibsp.heap, 0, p_out );\r
-                       IBSP_ERROR_EXIT(\r
-                               ("IOCTL_IBAT_IP_ADDRESSES for port %I64x failed (%x).\n",\r
+                       IBSP_ERROR_EXIT( (\r
+                               "IOCTL_IBAT_IP_ADDRESSES for port %I64x failed (%x).\n",\r
                                p_port->guid, GetLastError()) );\r
                        return -1;\r
                }\r
@@ -132,7 +141,7 @@ query_ip_address(
 \r
        } while( !p_out );\r
 \r
-       IBSP_TRACE( IBSP_DBG_HW, ("Port %I64x has %d IP addresses.\n",\r
+       IBSP_PRINT(TRACE_LEVEL_INFORMATION, IBSP_DBG_HW, ("Port %I64x has %d IP addresses.\n",\r
                p_port->guid, p_out->AddressCount) );\r
 \r
        for( i = 0; i < p_out->AddressCount; i++ )\r
@@ -156,13 +165,13 @@ query_ip_address(
                if( p_item != &ip_addr->item )\r
                {\r
                        /* Duplicate!  Should never happen. */\r
-                       IBSP_ERROR(\r
-                               ("Got duplicate addr %s\n", inet_ntoa( ip_addr->ip_addr )) );\r
+                       IBSP_ERROR( (\r
+                               "Got duplicate addr %s\n", inet_ntoa( ip_addr->ip_addr )) );\r
                        HeapFree( g_ibsp.heap, 0, ip_addr );\r
                        continue;\r
                }\r
 \r
-               IBSP_TRACE( IBSP_DBG_HW,\r
+               IBSP_PRINT(TRACE_LEVEL_INFORMATION, IBSP_DBG_HW,\r
                        ("Got addr %s\n", inet_ntoa( ip_addr->ip_addr )) );\r
        }\r
 \r
@@ -191,8 +200,8 @@ update_ip_addresses(
        ret = query_ip_address( port, &dup_ip );\r
        if( ret )\r
        {\r
-               IBSP_ERROR_EXIT(\r
-                       ("query_ip_address failed (%d)\n", ret) );\r
+               IBSP_ERROR_EXIT( (\r
+                       "query_ip_address failed (%d)\n", ret) );\r
                return 1;\r
        }\r
 \r
@@ -266,7 +275,7 @@ query_guid_callback(
        ib_service_record_t *service_record;\r
 \r
        IBSP_ENTER( IBSP_DBG_HW );\r
-       IBSP_TRACE( IBSP_DBG_HW,\r
+       IBSP_PRINT(TRACE_LEVEL_INFORMATION, IBSP_DBG_HW,\r
                ("status is %d, count is %d\n", p_query_rec->status,\r
                p_query_rec->result_cnt) );\r
 \r
@@ -350,7 +359,7 @@ query_guid_address(
 \r
        if( query_context.status != IB_SUCCESS )\r
        {\r
-               IBSP_TRACE( IBSP_DBG_HW,\r
+               IBSP_PRINT(TRACE_LEVEL_INFORMATION, IBSP_DBG_HW,\r
                        ("query success, but no GUID for IP address %x (query status %d)\n",\r
                        ip_addr, query_context.status) );\r
                goto error;\r
@@ -387,7 +396,7 @@ query_pr_callback(
        ib_api_status_t status;\r
 \r
        IBSP_ENTER( IBSP_DBG_HW );\r
-       IBSP_TRACE( IBSP_DBG_HW, ("status is %d\n", p_query_rec->status) );\r
+       IBSP_PRINT(TRACE_LEVEL_INFORMATION, IBSP_DBG_HW, ("status is %d\n", p_query_rec->status) );\r
 \r
        if( p_query_rec->status == IB_SUCCESS && p_query_rec->result_cnt )\r
        {\r
@@ -447,7 +456,7 @@ query_pr(
        fzprint(("%s():%d:0x%x:0x%x: Calling ib_query()..\n", __FUNCTION__,\r
                         __LINE__, GetCurrentProcessId(), GetCurrentThreadId()));\r
 \r
-       IBSP_TRACE( IBSP_DBG_HW,\r
+       IBSP_PRINT(TRACE_LEVEL_INFORMATION, IBSP_DBG_HW,\r
                ("Query for path from %I64x to %I64x\n",\r
                port->guid, dest_port_guid) );\r
 \r
@@ -534,7 +543,7 @@ build_ip_list(
 \r
        num_ip = cl_fmap_count( &g_ibsp.ip_map );\r
 \r
-       IBSP_TRACE( IBSP_DBG_HW, ("     num ip = %d\n", num_ip) );\r
+       IBSP_PRINT(TRACE_LEVEL_INFORMATION, IBSP_DBG_HW, ("     num ip = %Id\n", num_ip) );\r
 \r
        /* Note: the required size computed is a few bytes larger than necessary, \r
         * but that keeps the code clean. */\r
@@ -568,8 +577,8 @@ build_ip_list(
                cl_spinlock_release( &g_ibsp.ip_mutex );\r
                *ip_list_size = (DWORD) size_req;\r
                *lpErrno = WSAEFAULT;\r
-               IBSP_ERROR_EXIT(\r
-                       ("returning efault, size %d (usually not an error)", size_req) );\r
+               IBSP_ERROR_EXIT( (\r
+                       "returning efault, size %Id (usually not an error)", size_req) );\r
                return SOCKET_ERROR;\r
        }\r
 \r
@@ -627,7 +636,7 @@ get_port_from_ip_address(
        if( p_item != cl_fmap_end( &g_ibsp.ip_map ) )\r
                p_port = PARENT_STRUCT(p_item, struct ibsp_ip_addr, item)->p_port;\r
        else\r
-               IBSP_TRACE( IBSP_DBG_HW, ("not found\n") );\r
+               IBSP_PRINT(TRACE_LEVEL_INFORMATION, IBSP_DBG_HW, ("not found\n") );\r
 \r
        cl_spinlock_release( &g_ibsp.ip_mutex );\r
 \r
index a1f431c..a8a695e 100644 (file)
@@ -1,5 +1,6 @@
 /*\r
  * Copyright (c) 2005 SilverStorm Technologies.  All rights reserved.\r
+ * Copyright (c) 2006 Mellanox Technologies.  All rights reserved.\r
  *\r
  * This software is available to you under the OpenIB.org BSD license\r
  * below:\r
  */\r
 \r
 /* Registers a memory region */\r
+#include "ibspdebug.h"\r
+#if defined(EVENT_TRACING)\r
+#ifdef offsetof\r
+#undef offsetof\r
+#endif\r
+#include "ibsp_mem.tmh"\r
+#endif\r
 \r
 #include "ibspdll.h"\r
 \r
@@ -81,7 +89,7 @@ lookup_partial_mr(
 \r
        cl_spinlock_release( &s->port->hca->rdma_mem_list.mutex );\r
 \r
-       IBSP_TRACE_EXIT( IBSP_DBG_MEM, ("mr not found\n") );\r
+       IBSP_PRINT_EXIT(TRACE_LEVEL_INFORMATION, IBSP_DBG_MEM, ("mr not found\n") );\r
        return NULL;\r
 }\r
 \r
@@ -114,8 +122,7 @@ ibsp_reg_mem(
        p_node = HeapAlloc( g_ibsp.heap, 0, sizeof(struct memory_node) );\r
        if( !p_node )\r
        {\r
-               IBSP_ERROR_EXIT(\r
-                       ("AllocateOverlappedBuf:HeapAlloc() failed: %d\n",\r
+               IBSP_ERROR_EXIT( ("AllocateOverlappedBuf:HeapAlloc() failed: %d\n",\r
                        GetLastError()) );\r
                *lpErrno = WSAENOBUFS;\r
                return NULL;\r
@@ -149,8 +156,7 @@ ibsp_reg_mem(
 \r
        if( !p_reg )\r
        {\r
-               IBSP_ERROR_EXIT(\r
-                       ("AllocateOverlappedBuf:HeapAlloc() failed: %d\n",\r
+               IBSP_ERROR_EXIT( ("AllocateOverlappedBuf:HeapAlloc() failed: %d\n",\r
                        GetLastError()) );\r
                cl_spinlock_release( &s->port->hca->rdma_mem_list.mutex );\r
                HeapFree( g_ibsp.heap, 0, p_node );\r
@@ -165,7 +171,7 @@ ibsp_reg_mem(
        p_reg->type.length = len;\r
        p_reg->type.access_ctrl = access_ctrl;\r
 \r
-       IBSP_TRACE2( IBSP_DBG_MEM, ("pinning memory node %p\n", p_node) );\r
+       IBSP_PRINT(TRACE_LEVEL_INFORMATION, IBSP_DBG_MEM, ("pinning memory node %p\n", p_node) );\r
        status = ib_reg_mem(\r
                pd, &p_reg->type, &p_reg->lkey, &p_reg->rkey, &p_reg->mr_handle );\r
 \r
@@ -175,8 +181,7 @@ ibsp_reg_mem(
                HeapFree( g_ibsp.heap, 0, p_reg );\r
                HeapFree( g_ibsp.heap, 0, p_node );\r
 \r
-               IBSP_ERROR_EXIT(\r
-                       ("ib_reg_mem returned %s\n", ib_get_err_str(status)) );\r
+               IBSP_ERROR_EXIT( ("ib_reg_mem returned %s\n", ib_get_err_str(status)) );\r
 \r
                *lpErrno = WSAEFAULT;\r
                return NULL;\r
@@ -251,8 +256,8 @@ ibsp_dereg_hca(
        IBSP_ENTER( IBSP_DBG_MEM );\r
 \r
        cl_spinlock_acquire( &mem_list->mutex );\r
-       IBSP_TRACE1( IBSP_DBG_MEM,\r
-               ("%d registrations.\n", cl_qlist_count( &mem_list->list )) );\r
+       IBSP_PRINT(TRACE_LEVEL_INFORMATION, IBSP_DBG_MEM,\r
+               ("%Id registrations.\n", cl_qlist_count( &mem_list->list )) );\r
 \r
        for( item = cl_qlist_remove_head( &mem_list->list );\r
                item != cl_qlist_end( &mem_list->list );\r
@@ -274,12 +279,12 @@ ibsp_dereg_hca(
                        p_node->p_reg = NULL;\r
                }\r
 \r
-               IBSP_TRACE2( IBSP_DBG_MEM, ("unpinning ,memory reg %p\n", p_reg) );\r
+               IBSP_PRINT(TRACE_LEVEL_INFORMATION, IBSP_DBG_MEM, ("unpinning ,memory reg %p\n", p_reg) );\r
                status = ib_dereg_mr( p_reg->mr_handle );\r
                if( status )\r
                {\r
-                       IBSP_ERROR(\r
-                               ("ib_dereg_mem returned %s\n", ib_get_err_str( status )) );\r
+                       IBSP_ERROR( (\r
+                               "ib_dereg_mem returned %s\n", ib_get_err_str( status )) );\r
                }\r
                else\r
                {\r
@@ -312,8 +317,8 @@ ibsp_dereg_socket(
        }\r
 \r
        cl_spinlock_acquire( &s->port->hca->rdma_mem_list.mutex );\r
-       IBSP_TRACE1( IBSP_DBG_MEM,\r
-               ("%d registrations.\n", cl_qlist_count( &s->mr_list )) );\r
+       IBSP_PRINT(TRACE_LEVEL_INFORMATION, IBSP_DBG_MEM,\r
+               ("%Id registrations.\n", cl_qlist_count( &s->mr_list )) );\r
 \r
        while( cl_qlist_count( &s->mr_list ) )\r
        {\r
@@ -380,8 +385,8 @@ ibsp_hca_flush_mr_cache(
                status = ib_dereg_mr( p_reg->mr_handle );\r
                if( status != IB_SUCCESS )\r
                {\r
-                       IBSP_ERROR(\r
-                               ("ib_dereg_mr returned %s\n", ib_get_err_str(status)) );\r
+                       IBSP_ERROR( (\r
+                               "ib_dereg_mr returned %s\n", ib_get_err_str(status)) );\r
                }\r
 \r
                HeapFree( g_ibsp.heap, 0, p_reg );\r
index bbfb56c..2b0bdcc 100644 (file)
@@ -1,5 +1,6 @@
 /*\r
  * Copyright (c) 2005 SilverStorm Technologies.  All rights reserved.\r
+ * Copyright (c) 2006 Mellanox Technologies.  All rights reserved.\r
  *\r
  * This software is available to you under the OpenIB.org BSD license\r
  * below:\r
  */\r
 \r
 \r
+#include "ibspdebug.h"\r
+#if defined(EVENT_TRACING)\r
+#include "ibsp_perfmon.tmh"\r
+#endif\r
+\r
 #include <string.h>\r
 #include "ibspdll.h"\r
 #include "ibsp_perfmon.h"\r
@@ -169,7 +175,7 @@ IBSPPmGetSlot( void )
 \r
                g_pm_stat.idx = idx;\r
                g_pm_stat.pdata = g_pm_stat.p_shmem->obj[idx].data;\r
-               IBSP_TRACE2( IBSP_DBG_PERFMON,\r
+               IBSP_PRINT(TRACE_LEVEL_INFORMATION, IBSP_DBG_PERFMON,\r
                        ("%S got slot %d\n", p_slot->app_name, idx) );\r
                break;\r
        }\r
@@ -276,8 +282,7 @@ IBSPPmOpen(
        if( status != ERROR_SUCCESS )\r
        {\r
                g_pm_stat.threads--;\r
-               IBSP_ERROR_EXIT(\r
-                       ("RegOpenKeyEx for perf information returned %d.\n", status) );\r
+               IBSP_ERROR_EXIT( ("RegOpenKeyEx for perf information returned %d.\n", status) );\r
                return status;\r
        }\r
 \r
@@ -289,8 +294,7 @@ IBSPPmOpen(
        {\r
                RegCloseKey(pm_hkey);\r
                g_pm_stat.threads--;\r
-               IBSP_ERROR_EXIT(\r
-                       ("RegQueryValueEx for \"First Counter\" returned %d.\n", status) );\r
+               IBSP_ERROR_EXIT( ("RegQueryValueEx for \"First Counter\" returned %d.\n", status) );\r
                return status;\r
        }\r
 \r
@@ -303,8 +307,7 @@ IBSPPmOpen(
        if( status != ERROR_SUCCESS )\r
        {\r
                g_pm_stat.threads--;\r
-               IBSP_ERROR_EXIT(\r
-                       ("RegQueryValueEx for \"First Help\" returned %d.\n", status) );\r
+               IBSP_ERROR_EXIT( ("RegQueryValueEx for \"First Help\" returned %d.\n", status) );\r
                return status;\r
        }\r
 \r
@@ -427,7 +430,7 @@ IBSPPmCollectData(
 \r
        if( !__PmIsQuerySupported(lpValueName ) )\r
        {\r
-               IBSP_TRACE1( IBSP_DBG_PERFMON, ("Unsupported query\n") );\r
+               IBSP_PRINT(TRACE_LEVEL_INFORMATION, IBSP_DBG_PERFMON, ("Unsupported query\n") );\r
                goto done;\r
        }\r
 \r
@@ -469,7 +472,7 @@ done:
                num_instances++;\r
        }\r
 \r
-       IBSP_TRACE1( IBSP_DBG_PERFMON, ("%d instances.\n", num_instances) );\r
+       IBSP_PRINT(TRACE_LEVEL_INFORMATION, IBSP_DBG_PERFMON, ("%d instances.\n", num_instances) );\r
 \r
        /* calc buffer size required for data return */\r
        use_bytes = sizeof(ibsp_pm_definition_t) + \\r
index c1686b2..72593bb 100644 (file)
@@ -1,5 +1,6 @@
 /*\r
  * Copyright (c) 2005 SilverStorm Technologies.  All rights reserved.\r
+ * Copyright (c) 2006 Mellanox Technologies.  All rights reserved.\r
  *\r
  * This software is available to you under the OpenIB.org BSD license\r
  * below:\r
 \r
 /* TODO: right now, hotplug is not supported. */\r
 \r
+#include "ibspdebug.h"\r
+#if defined(EVENT_TRACING)\r
+#ifdef offsetof\r
+#undef offsetof\r
+#endif\r
+#include "ibsp_pnp.tmh"\r
+#endif\r
+\r
 #include "ibspdll.h"\r
 \r
 \r
@@ -79,8 +88,7 @@ pnp_ca_add(
        hca = HeapAlloc( g_ibsp.heap, HEAP_ZERO_MEMORY, sizeof(struct ibsp_hca) );\r
        if( hca == NULL )\r
        {\r
-               IBSP_ERROR(\r
-                       ("can't get enough memory (%d)\n", sizeof(struct ibsp_hca)) );\r
+               IBSP_ERROR( ("can't get enough memory (%d)\n", sizeof(struct ibsp_hca)) );\r
                status = IB_INSUFFICIENT_MEMORY;\r
                goto pnp_ca_add_err1;\r
        }\r
@@ -94,7 +102,7 @@ pnp_ca_add(
        cl_spinlock_init( &hca->cq_lock );\r
 \r
        /* HCA handle */\r
-       IBSP_TRACE( IBSP_DBG_HW,\r
+       IBSP_PRINT(TRACE_LEVEL_INFORMATION, IBSP_DBG_HW,\r
                         ("handle is %p %016I64x\n", g_ibsp.al_handle, hca->guid) );\r
        status =\r
                ib_open_ca( g_ibsp.al_handle, hca->guid, NULL, hca, &hca->hca_handle );\r
@@ -113,7 +121,7 @@ pnp_ca_add(
        {\r
                STAT_INC( pd_num );\r
 \r
-               IBSP_TRACE( IBSP_DBG_EP, ("allocated PD %p for HCA\n", hca->pd) );\r
+               IBSP_PRINT(TRACE_LEVEL_INFORMATION, IBSP_DBG_EP, ("allocated PD %p for HCA\n", hca->pd) );\r
 \r
                /* Success */\r
                cl_spinlock_acquire( &g_ibsp.hca_mutex );\r
@@ -193,10 +201,13 @@ pnp_ca_remove(
                 */\r
                status = ib_dealloc_pd( hca->pd, NULL );\r
                if( status )\r
+               {\r
                        IBSP_ERROR( ("ib_dealloc_pd failed (%d)\n", status) );\r
+               }\r
                else\r
+               {\r
                        STAT_DEC( pd_num );\r
-\r
+               }\r
                hca->pd = NULL;\r
        }\r
 \r
@@ -238,8 +249,7 @@ pnp_port_add(
        hca = lookup_hca( p_port_rec->p_ca_attr->ca_guid );\r
        if( !hca )\r
        {\r
-               IBSP_ERROR(\r
-                       ("Failed to lookup HCA (%016I64x) for new port (%016I64x)\n",\r
+               IBSP_ERROR( ("Failed to lookup HCA (%016I64x) for new port (%016I64x)\n",\r
                        p_port_rec->p_ca_attr->ca_guid, p_port_rec->p_port_attr->port_guid) );\r
                IBSP_EXIT( IBSP_DBG_HW );\r
                return IB_INVALID_GUID;\r
@@ -248,8 +258,7 @@ pnp_port_add(
        port = HeapAlloc( g_ibsp.heap, HEAP_ZERO_MEMORY, sizeof(struct ibsp_port) );\r
        if( port == NULL )\r
        {\r
-               IBSP_ERROR(\r
-                                ("HeapAlloc failed (%d)\n", sizeof(struct ibsp_port)) );\r
+               IBSP_ERROR( ("HeapAlloc failed (%d)\n", sizeof(struct ibsp_port)) );\r
                IBSP_EXIT( IBSP_DBG_HW );\r
                return IB_INSUFFICIENT_MEMORY;\r
        }\r
@@ -300,7 +309,7 @@ pnp_callback(
        ib_pnp_port_rec_t*              p_port_rec = (ib_pnp_port_rec_t*)pnp_rec;\r
 \r
        IBSP_ENTER( IBSP_DBG_HW );\r
-       IBSP_TRACE( IBSP_DBG_HW, ("event is %x\n", pnp_rec->pnp_event) );\r
+       IBSP_PRINT(TRACE_LEVEL_INFORMATION, IBSP_DBG_HW, ("event is %x\n", pnp_rec->pnp_event) );\r
 \r
        switch( pnp_rec->pnp_event )\r
        {\r
@@ -334,8 +343,7 @@ pnp_callback(
        case IB_PNP_GID_CHANGE:\r
        case IB_PNP_LID_CHANGE:\r
        case IB_PNP_SUBNET_TIMEOUT_CHANGE:\r
-               IBSP_ERROR(\r
-                       ("pnp_callback: unsupported event %x\n", pnp_rec->pnp_event) );\r
+               IBSP_ERROR( ("pnp_callback: unsupported event %x\n", pnp_rec->pnp_event) );\r
                break;\r
 \r
                /* Discovery complete event */\r
@@ -343,8 +351,7 @@ pnp_callback(
                break;\r
 \r
        default:\r
-               IBSP_ERROR(\r
-                       ("pnp_callback: unsupported event %x\n", pnp_rec->pnp_event) );\r
+               IBSP_ERROR( ("pnp_callback: unsupported event %x\n", pnp_rec->pnp_event) );\r
                break;\r
        }\r
 \r
@@ -371,8 +378,7 @@ register_pnp(void)
        status = ib_reg_pnp( g_ibsp.al_handle, &pnp_req, &g_ibsp.pnp_handle_port );\r
        if( status != IB_SUCCESS )\r
        {\r
-               IBSP_ERROR(\r
-                       ("register_pnp: ib_reg_pnp for PORT failed (%d)\n", status) );\r
+               IBSP_ERROR( ("register_pnp: ib_reg_pnp for PORT failed (%d)\n", status) );\r
                goto done;\r
        }\r
 \r
@@ -382,8 +388,7 @@ register_pnp(void)
        status = ib_reg_pnp( g_ibsp.al_handle, &pnp_req, &g_ibsp.pnp_handle_port );\r
        if( status != IB_SUCCESS )\r
        {\r
-               IBSP_ERROR(\r
-                       ("register_pnp: ib_reg_pnp for PORT failed (%d)\n", status) );\r
+               IBSP_ERROR( ("register_pnp: ib_reg_pnp for PORT failed (%d)\n", status) );\r
                goto done;\r
        }\r
 \r
@@ -414,8 +419,8 @@ unregister_pnp(void)
                status = ib_dereg_pnp( g_ibsp.pnp_handle_port, ib_sync_destroy );\r
                if( status != IB_SUCCESS )\r
                {\r
-                       IBSP_ERROR(\r
-                               ("unregister_pnp: ib_dereg_pnp for PORT failed (%d)\n", status) );\r
+                       IBSP_ERROR( ("unregister_pnp: ib_dereg_pnp for PORT failed (%d)\n",\r
+                               status) );\r
                }\r
 \r
                g_ibsp.pnp_handle_port = NULL;\r
@@ -426,8 +431,8 @@ unregister_pnp(void)
                status = ib_dereg_pnp( g_ibsp.pnp_handle_ca, ib_sync_destroy );\r
                if( status != IB_SUCCESS )\r
                {\r
-                       IBSP_ERROR(\r
-                               ("unregister_pnp: ib_dereg_pnp for PORT failed (%d)\n", status) );\r
+                       IBSP_ERROR( ("unregister_pnp: ib_dereg_pnp for PORT failed (%d)\n",\r
+                               status) );\r
                }\r
 \r
                g_ibsp.pnp_handle_ca = NULL;\r
index 8460b6f..c67a84d 100644 (file)
@@ -1,5 +1,6 @@
 /*\r
  * Copyright (c) 2005 SilverStorm Technologies.  All rights reserved.\r
+ * Copyright (c) 2006 Mellanox Technologies.  All rights reserved.\r
  *\r
  * This software is available to you under the OpenIB.org BSD license\r
  * below:\r
 \r
 #ifdef _DEBUG_\r
 \r
-//uint32_t gdbg_lvl = CL_DBG_DISABLE;\r
-uint32_t gdbg_lvl = CL_DBG_ERROR;\r
-//uint32_t gdbg_lvl = CL_DBG_ALL;\r
-//uint32_t gdbg_lvl = IBSP_DBG_CONN | IBSP_DBG_DLL | IBSP_DBG_INIT | IBSP_DBG_CM | IBSP_DBG_EP; \r
-\r
 \r
 void\r
 DebugPrintIBSPIoctlParams(\r
-                                       uint32_t                                        level,\r
-                                       uint32_t                                        mask,\r
+                                       uint32_t                                                flags,\r
                                        DWORD                                           dwIoControlCode,\r
                                        LPVOID                                          lpvInBuffer,\r
                                        DWORD                                           cbInBuffer,\r
@@ -54,45 +49,48 @@ DebugPrintIBSPIoctlParams(
 {\r
        UNUSED_PARAM( lpThreadId );\r
 \r
-       if( (level & mask) != level )\r
-               return;\r
-\r
-       CL_PRINT( level, mask, ("\tdwIoControlCode :") );\r
+       IBSP_PRINT( TRACE_LEVEL_INFORMATION, flags,("\tdwIoControlCode :") );\r
        switch( dwIoControlCode )\r
        {\r
        case SIO_GET_QOS:\r
-               CL_PRINT( level, mask, ("SIO_GET_QOS\n") );\r
+               IBSP_PRINT( TRACE_LEVEL_INFORMATION, flags,("SIO_GET_QOS\n") );\r
                break;\r
        case SIO_GET_GROUP_QOS:\r
-               CL_PRINT( level, mask, ("SIO_GET_GROUP_QOS\n") );\r
+               IBSP_PRINT( TRACE_LEVEL_INFORMATION, flags,("SIO_GET_GROUP_QOS\n") );\r
                break;\r
        case SIO_SET_QOS:\r
-               CL_PRINT( level, mask, ("SIO_SET_QOS\n") );\r
+               IBSP_PRINT( TRACE_LEVEL_INFORMATION, flags,("SIO_SET_QOS\n") );\r
                break;\r
        case SIO_SET_GROUP_QOS:\r
-               CL_PRINT( level, mask, ("SIO_SET_GROUP_QOS\n") );\r
+               IBSP_PRINT( TRACE_LEVEL_INFORMATION, flags,("SIO_SET_GROUP_QOS\n") );\r
                break;\r
        case SIO_ADDRESS_LIST_QUERY:\r
-               CL_PRINT( level, mask, ("SIO_ADDRESS_LIST_QUERY\n") );\r
+               IBSP_PRINT( TRACE_LEVEL_INFORMATION, flags,("SIO_ADDRESS_LIST_QUERY\n") );\r
                break;\r
        default:\r
-               CL_PRINT( level, mask, ("UNKNOWN control code 0x%x)\n", dwIoControlCode) );\r
+               IBSP_PRINT( TRACE_LEVEL_INFORMATION, flags,("UNKNOWN control code 0x%x)\n", dwIoControlCode) );\r
                break;\r
        }\r
 \r
        if( lpvInBuffer == NULL )\r
-               CL_PRINT( level, mask, ("\tInput Buffer pointer is NULL\n") );\r
+       {\r
+               IBSP_PRINT( TRACE_LEVEL_INFORMATION, flags,("\tInput Buffer pointer is NULL\n") );\r
+       }\r
        else\r
-               CL_PRINT( level, mask, ("\tInput buffer len (%d)\n", cbInBuffer) );\r
-\r
+       {\r
+               IBSP_PRINT( TRACE_LEVEL_INFORMATION, flags,("\tInput buffer len (%d)\n", cbInBuffer) );\r
+       }\r
        if( lpvOutBuffer == NULL )\r
-               CL_PRINT( level, mask, ("\tOutput Buffer pointer is NULL\n") );\r
+       {\r
+               IBSP_PRINT( TRACE_LEVEL_INFORMATION, flags,("\tOutput Buffer pointer is NULL\n") );\r
+       }\r
        else\r
-               CL_PRINT( level, mask, ("\tOutput buffer len (%d)\n", cbOutBuffer) );\r
-\r
-       CL_PRINT( level, mask,\r
+       {\r
+               IBSP_PRINT( TRACE_LEVEL_INFORMATION, flags,("\tOutput buffer len (%d)\n", cbOutBuffer) );\r
+       }\r
+       IBSP_PRINT( TRACE_LEVEL_INFORMATION, flags,\r
                ("\tOverlapped IO is (%s)\n", ( lpOverlapped == NULL) ? "FALSE" : "TRUE") );\r
-       CL_PRINT( level, mask,\r
+       IBSP_PRINT( TRACE_LEVEL_INFORMATION, flags,\r
                ("\tCompletion Routine is %s\n",\r
                ( lpCompletionRoutine == NULL) ? "NULL" : "non NULL") );\r
 }\r
@@ -100,22 +98,19 @@ DebugPrintIBSPIoctlParams(
 \r
 void\r
 DebugPrintSockAddr(\r
-                                       uint32_t                                        level,\r
-                                       uint32_t                                        mask,\r
+                                       uint32_t                                        flags,\r
                                        struct sockaddr_in                      *pSockAddr )\r
 {\r
-       if( (level & mask) != level )\r
-               return;\r
 \r
-       CL_PRINT( level, mask, ("\tAddressFamily (0x%x)\n", pSockAddr->sin_family) );\r
-       CL_PRINT( level, mask, ("\tPortNumber (0x%x)\n", pSockAddr->sin_port) );\r
-       CL_PRINT( level, mask, ("\tIPAddress (%s)\n", inet_ntoa(pSockAddr->sin_addr )) );\r
+       IBSP_PRINT( TRACE_LEVEL_INFORMATION, flags,("\tAddressFamily (0x%x)\n", pSockAddr->sin_family) );\r
+       IBSP_PRINT( TRACE_LEVEL_INFORMATION, flags,("\tPortNumber (0x%x)\n", pSockAddr->sin_port) );\r
+       IBSP_PRINT( TRACE_LEVEL_INFORMATION, flags,("\tIPAddress (%s)\n", inet_ntoa(pSockAddr->sin_addr )) );\r
 }\r
 \r
 \r
 void\r
 debug_dump_buffer(\r
-                                       uint32_t                                        level,\r
+                                       uint32_t                                        flags,\r
                                        const char                                      *name,\r
                                        void                                            *buf,\r
                                        size_t                                          len )\r
@@ -128,36 +123,35 @@ debug_dump_buffer(
        s = str;\r
        *s = 0;\r
 \r
-       CL_PRINT( level, gdbg_lvl, ("HEX for %s:\n", name) );\r
+       IBSP_PRINT( TRACE_LEVEL_VERBOSE, flags,("HEX for %s:\n", name) );\r
 \r
        for( i = 0; i < len; i++ )\r
        {\r
                s += sprintf( s, "%02x ", p[i] );\r
                if( i % 16 == 15 )\r
                {\r
-                       CL_PRINT( level, gdbg_lvl, ("HEX:%s: %s\n", name, str) );\r
+                       IBSP_PRINT( TRACE_LEVEL_VERBOSE, flags, ("HEX:%s: %s\n", name, str) );\r
                        s = str;\r
                        *s = 0;\r
                }\r
        }\r
-       CL_PRINT( level, gdbg_lvl, ("HEX:%s: %s\n", name, str) );\r
+       IBSP_PRINT( TRACE_LEVEL_VERBOSE, flags, ("HEX:%s: %s\n", name, str) );\r
 }\r
 \r
 \r
 void\r
 debug_dump_overlapped(\r
-                                       uint32_t                                        level,\r
-                                       uint32_t                                        mask,\r
+                                       uint32_t                                        flags,\r
                        const   char                                            *name,\r
                                        LPWSAOVERLAPPED                         lpOverlapped )\r
 {\r
-       CL_PRINT( level, mask, ("dumping OVERLAPPED %s:\n", name) );\r
-       CL_PRINT( level, mask, ("  lpOverlapped = %p\n", lpOverlapped) );\r
-       CL_PRINT( level, mask, ("  Internal = %x\n", lpOverlapped->Internal) );\r
-       CL_PRINT( level, mask, ("  InternalHigh = %d\n", lpOverlapped->InternalHigh) );\r
-       CL_PRINT( level, mask, ("  Offset = %d\n", lpOverlapped->Offset) );\r
-       CL_PRINT( level, mask, ("  OffsetHigh = %d %\n", lpOverlapped->OffsetHigh) );\r
-       CL_PRINT( level, mask, ("  hEvent = %x\n", (uintptr_t) lpOverlapped->hEvent) );\r
+       IBSP_PRINT( TRACE_LEVEL_INFORMATION, flags, ("dumping OVERLAPPED %s:\n", name) );\r
+       IBSP_PRINT( TRACE_LEVEL_INFORMATION, flags, ("  lpOverlapped = %p\n", lpOverlapped) );\r
+       IBSP_PRINT( TRACE_LEVEL_INFORMATION, flags, ("  Internal = %x\n", lpOverlapped->Internal) );\r
+       IBSP_PRINT( TRACE_LEVEL_INFORMATION, flags, ("  InternalHigh = %d\n", lpOverlapped->InternalHigh) );\r
+       IBSP_PRINT( TRACE_LEVEL_INFORMATION, flags, ("  Offset = %d\n", lpOverlapped->Offset) );\r
+       IBSP_PRINT( TRACE_LEVEL_INFORMATION, flags, ("  OffsetHigh = %d %\n", lpOverlapped->OffsetHigh) );\r
+       IBSP_PRINT( TRACE_LEVEL_INFORMATION, flags, ("  hEvent = %x\n", (uintptr_t) lpOverlapped->hEvent) );\r
 }\r
 \r
 #endif /* _DEBUG_ */\r
index cd5aa6e..98d95a1 100644 (file)
@@ -1,5 +1,6 @@
 /*\r
  * Copyright (c) 2005 SilverStorm Technologies.  All rights reserved.\r
+ * Copyright (c) 2006 Mellanox Technologies.  All rights reserved.\r
  *\r
  * This software is available to you under the OpenIB.org BSD license\r
  * below:\r
 \r
 #include "ibspdll.h"\r
 #include <complib/cl_atomic.h>\r
+#include <complib/cl_debug.h>\r
 \r
+#ifndef __MODULE__\r
+#define __MODULE__     "[IBSP]"\r
+#endif\r
 \r
-extern uint32_t gdbg_lvl;\r
 \r
 \r
-#define IBSP_DBG_DLL           0x00000001      /* DLL */\r
-#define IBSP_DBG_SI                    0x00000002      /* socket info */\r
-#define IBSP_DBG_INIT          0x00000004      /* initialization code */\r
-#define IBSP_DBG_WQ                    0x00000008      /* WQ related functions */\r
-#define IBSP_DBG_EP                    0x00000010      /* Enpoints related functions */\r
-#define IBSP_DBG_MEM           0x00000020      /* memory registration */\r
-#define IBSP_DBG_CM                    0x00000040      /* CM */\r
-#define IBSP_DBG_CONN          0x00000080      /* connections */\r
+\r
+extern uint32_t                        g_ibsp_dbg_level;\r
+extern uint32_t                        g_ibsp_dbg_flags;\r
+\r
+#if defined(EVENT_TRACING)\r
+//\r
+// Software Tracing Definitions \r
+//\r
+\r
+\r
+#define WPP_CONTROL_GUIDS \\r
+       WPP_DEFINE_CONTROL_GUID(IBSPCtlGuid,(156A98A5,8FDC,4d00,A673,0638123DF336), \\r
+       WPP_DEFINE_BIT( IBSP_DBG_ERROR) \\r
+       WPP_DEFINE_BIT( IBSP_DBG_DLL) \\r
+       WPP_DEFINE_BIT( IBSP_DBG_SI) \\r
+       WPP_DEFINE_BIT( IBSP_DBG_INIT) \\r
+       WPP_DEFINE_BIT( IBSP_DBG_WQ) \\r
+       WPP_DEFINE_BIT( IBSP_DBG_EP) \\r
+       WPP_DEFINE_BIT( IBSP_DBG_MEM) \\r
+       WPP_DEFINE_BIT( IBSP_DBG_CM) \\r
+       WPP_DEFINE_BIT( IBSP_DBG_CONN) \\r
+       WPP_DEFINE_BIT( IBSP_DBG_OPT) \\r
+       WPP_DEFINE_BIT( IBSP_DBG_NEV) \\r
+       WPP_DEFINE_BIT( IBSP_DBG_HW) \\r
+       WPP_DEFINE_BIT( IBSP_DBG_IO) \\r
+       WPP_DEFINE_BIT( IBSP_DBG_DUP) \\r
+       WPP_DEFINE_BIT( IBSP_DBG_PERFMON))\r
+\r
+\r
+\r
+#define WPP_LEVEL_FLAGS_ENABLED(lvl, flags) (WPP_LEVEL_ENABLED(flags) && WPP_CONTROL(WPP_BIT_ ## flags).Level  >= lvl)\r
+#define WPP_LEVEL_FLAGS_LOGGER(lvl,flags) WPP_LEVEL_LOGGER(flags)\r
+#define WPP_FLAG_ENABLED(flags)(WPP_LEVEL_ENABLED(flags) && WPP_CONTROL(WPP_BIT_ ## flags).Level  >= TRACE_LEVEL_VERBOSE)\r
+#define WPP_FLAG_LOGGER(flags) WPP_LEVEL_LOGGER(flags)\r
+\r
+\r
+// begin_wpp config\r
+// IBSP_ENTER( FLAG );\r
+// IBSP_EXIT( FLAG );\r
+// USEPREFIX(IBSP_PRINT, "%!STDPREFIX! %!FUNC!() :");\r
+// USEPREFIX(IBSP_PRINT_EXIT, "%!STDPREFIX! %!FUNC!() :");\r
+// USEPREFIX(IBSP_ERROR, "%!STDPREFIX! %!FUNC!() :ERR***");\r
+// USEPREFIX(IBSP_ERROR_EXIT, "%!STDPREFIX! %!FUNC!() :ERR***");\r
+// USESUFFIX(IBSP_ENTER, " %!FUNC!():[");\r
+// USESUFFIX(IBSP_EXIT, " %!FUNC!():]");\r
+// end_wpp\r
+\r
+\r
+\r
+#define STAT_INC(name)\r
+#define STAT_DEC(name)\r
+#define BREAKPOINT(x)\r
+#define DebugPrintIBSPIoctlParams(a,b,c,d,e,f,g,h,i)\r
+#define DebugPrintSockAddr(a,b)\r
+#define fzprint(a)\r
+#define STATS(expr)\r
+\r
+#else\r
+\r
+#include <wmistr.h>\r
+#include <evntrace.h>\r
+\r
+/*\r
+ * Debug macros\r
+ */\r
+\r
+\r
+\r
+#define IBSP_DBG_ERR           0x00000001      /* error */\r
+#define IBSP_DBG_DLL           0x00000002      /* DLL */\r
+#define IBSP_DBG_SI                    0x00000004      /* socket info */\r
+#define IBSP_DBG_INIT          0x00000008      /* initialization code */\r
+#define IBSP_DBG_WQ            0x00000010      /* WQ related functions */\r
+#define IBSP_DBG_EP                    0x00000020      /* Enpoints related functions */\r
+#define IBSP_DBG_MEM           0x00000040      /* memory registration */\r
+#define IBSP_DBG_CM                    0x00000080      /* CM */\r
+#define IBSP_DBG_CONN          0x00000100      /* connections */\r
 #define IBSP_DBG_OPT           0x00000200      /* socket options */\r
 #define IBSP_DBG_NEV           0x00000400      /* network events */\r
-#define IBSP_DBG_HW                    0x00000800      /* Hardware */\r
+#define IBSP_DBG_HW            0x00000800      /* Hardware */\r
 #define IBSP_DBG_IO                    0x00001000      /* Overlapped I/O request */\r
 #define IBSP_DBG_DUP           0x00002000      /* Socket Duplication */\r
 #define IBSP_DBG_PERFMON       0x00004000      /* Performance Monitoring */\r
 \r
-#define IBSP_DBG_LEVEL4                0x01000000      /* debug use */\r
-#define IBSP_DBG_LEVEL3                0x02000000      /* debug use */\r
-#define IBSP_DBG_LEVEL2                0x04000000      /* debug use */\r
-#define IBSP_DBG_LEVEL1                0x08000000      /* debug use */\r
-#define IBSP_DBG_FUNC          0x20000000      /* Function enter/exit */\r
-#define IBSP_DBG_WARN          0x40000000      /* Warnings */\r
-\r
-#define CL_ERROR(a, b, c) CL_TRACE((a|CL_DBG_ERROR), b, c)\r
-#define CL_EXIT_ERROR(a, b, c) CL_TRACE_EXIT((a|CL_DBG_ERROR), b, c)\r
-\r
-#define IBSP_ERROR( m )                                CL_TRACE( CL_DBG_ERROR, gdbg_lvl, m )\r
-#define IBSP_ERROR_EXIT( m )           CL_TRACE_EXIT( CL_DBG_ERROR, gdbg_lvl, m )\r
-#define IBSP_TRACE( l, m )                     CL_TRACE( (l), gdbg_lvl, m )\r
-#define IBSP_TRACE1( l, m )                    CL_TRACE( (l | IBSP_DBG_LEVEL1), gdbg_lvl, m )\r
-#define IBSP_TRACE2( l, m )                    CL_TRACE( (l | IBSP_DBG_LEVEL2), gdbg_lvl, m )\r
-#define IBSP_TRACE3( l, m )                    CL_TRACE( (l | IBSP_DBG_LEVEL3), gdbg_lvl, m )\r
-#define IBSP_TRACE4( l, m )                    CL_TRACE( (l | IBSP_DBG_LEVEL4), gdbg_lvl, m )\r
-#define IBSP_TRACE_EXIT( l, m )                CL_TRACE_EXIT( (l | IBSP_DBG_FUNC), gdbg_lvl, m )\r
-#define IBSP_ENTER( l )                                CL_ENTER( (l | IBSP_DBG_FUNC), gdbg_lvl )\r
-#define IBSP_EXIT( l )                         CL_EXIT( (l | IBSP_DBG_FUNC), gdbg_lvl )\r
-\r
-#if defined _DEBUG_\r
+#define IBSP_DBG_ERROR         (CL_DBG_ERROR | IBSP_DBG_ERR)\r
+\r
+\r
+\r
+#if DBG\r
+\r
+// assignment of _level_ is need to to overcome warning C4127\r
+#define IBSP_PRINT( _level_,_flag_,_msg_)  \\r
+       { \\r
+               if( g_ibsp_dbg_level >= (_level_) ) \\r
+                       CL_TRACE( _flag_, g_ibsp_dbg_flags, _msg_ ); \\r
+       }\r
+\r
+\r
+#define IBSP_PRINT_EXIT( _level_,_flag_,_msg_) \\r
+       { \\r
+               if( g_ibsp_dbg_level >= (_level_) ) \\r
+                       CL_TRACE( _flag_, g_ibsp_dbg_flags, _msg_ );\\r
+               IBSP_EXIT( _flag_ );\\r
+       }\r
+\r
+#define IBSP_ENTER( _flag_) \\r
+       { \\r
+               if( g_ibsp_dbg_level >= TRACE_LEVEL_VERBOSE ) \\r
+                       CL_ENTER( _flag_, g_ibsp_dbg_flags ); \\r
+       }\r
+\r
+#define IBSP_EXIT( _flag_)\\r
+       { \\r
+               if( g_ibsp_dbg_level >= TRACE_LEVEL_VERBOSE ) \\r
+                       CL_EXIT( _flag_, g_ibsp_dbg_flags ); \\r
+       }\r
+\r
 \r
 //#define fzprint(a) CL_PRINT(IBSP_DBG_USER, IBSP_DBG_USER, a)\r
 #define fzprint(a)\r
@@ -84,8 +168,7 @@ extern uint32_t gdbg_lvl;
 //#define BREAKPOINT(x) if( gCurrentDebugLevel & x ) { DebugBreak(); }\r
 void\r
 DebugPrintIBSPIoctlParams(\r
-                                       uint32_t                                        level,\r
-                                       uint32_t                                        mask,\r
+                                       uint32_t                                                flags,\r
                                        DWORD                                           dwIoControlCode,\r
                                        LPVOID                                          lpvInBuffer,\r
                                        DWORD                                           cbInBuffer,\r
@@ -95,23 +178,22 @@ DebugPrintIBSPIoctlParams(
                                        LPWSAOVERLAPPED_COMPLETION_ROUTINE      lpCompletionRoutine,\r
                                        LPWSATHREADID                           lpThreadId );\r
 \r
+\r
 void\r
 DebugPrintSockAddr(\r
-                                       uint32_t                                        level,\r
-                                       uint32_t                                        mask,\r
+                                       uint32_t                                                flags,\r
                                        struct sockaddr_in                      *sockaddr );\r
 \r
 void\r
 debug_dump_buffer(\r
-                                       uint32_t                                        level,\r
+                                       uint32_t                                                flags,\r
                        const   char                                            *name,\r
                                        void                                            *buf,\r
                                        size_t                                          len );\r
 \r
 void\r
 debug_dump_overlapped(\r
-                                       uint32_t                                        level,\r
-                                       uint32_t                                        mask,\r
+                                       uint32_t                                                flags,\r
                        const   char                                            *name,\r
                                        LPWSAOVERLAPPED                         lpOverlapped );\r
 \r
@@ -126,15 +208,23 @@ debug_dump_overlapped(
 \r
 #else\r
 \r
-#define STAT_INC(name)\r
-#define STAT_DEC(name)\r
-#define BREAKPOINT(x)\r
-#define DebugPrintIBSPIoctlParams(a,b,c,d,e,f,g,h,i,j)\r
-#define DebugPrintSockAddr(a,b,c)\r
+\r
+#define IBSP_PRINT( _level_,_flag_,_msg_)\r
+#define IBSP_PRINT_EXIT( _level_,_flag_,_msg_)\r
+#define IBSP_ENTER( _flag_)\r
+#define IBSP_EXIT( _flag_)\r
 #define fzprint(a)\r
-#define STATS(expr)\r
+#endif /* DBG */\r
+\r
+\r
+#define IBSP_ERROR( _msg_) \\r
+       IBSP_PRINT( TRACE_LEVEL_ERROR, IBSP_DBG_ERROR, _msg_)\r
+\r
+#define IBSP_ERROR_EXIT( _msg_) \\r
+       IBSP_PRINT_EXIT( TRACE_LEVEL_ERROR, IBSP_DBG_ERROR, _msg_)\r
+\r
 \r
-#endif /* _DEBUG_ */\r
+#endif /* EVENT_TRACING */\r
 \r
 /*\r
  * To enable logging of all Send/Receive data for each socket\r
index def0ea6..e29b0cc 100644 (file)
@@ -1,5 +1,6 @@
 /*\r
  * Copyright (c) 2005 SilverStorm Technologies.  All rights reserved.\r
+ * Copyright (c) 2006 Mellanox Technologies.  All rights reserved.\r
  *\r
  * This software is available to you under the OpenIB.org BSD license\r
  * below:\r
  *\r
  * $Id$\r
  */\r
+\r
+#include "ibspdebug.h"\r
+#if defined(EVENT_TRACING)\r
+#include "ibspdll.tmh"\r
+#endif\r
+\r
\r
 #include <tchar.h>\r
 #include <stdlib.h>\r
 #include "ibspdll.h"\r
@@ -60,6 +68,8 @@ uint8_t                       g_pkt_life_modifier = 0;
 uint8_t                        g_qp_retries = QP_ATTRIB_RETRY_COUNT;\r
 DWORD_PTR              g_dwPollThreadAffinityMask = 0;\r
 \r
+uint32_t                               g_ibsp_dbg_level = TRACE_LEVEL_ERROR;\r
+uint32_t                               g_ibsp_dbg_flags = 0x1;\r
 \r
 /*\r
  * Function: DllMain\r
@@ -103,18 +113,46 @@ _DllMain(
        switch( dwReason )\r
        {\r
        case DLL_PROCESS_ATTACH:\r
-               IBSP_TRACE( IBSP_DBG_DLL, ("DllMain: DLL_PROCESS_ATTACH\n") );\r
 \r
-#ifdef _DEBUG_\r
-               i = GetEnvironmentVariable( "IBWSD_DBG", env_var, sizeof(env_var) );\r
+\r
+#if defined(EVENT_TRACING)\r
+#if DBG\r
+               WPP_INIT_TRACING(L"ibspdll.dll");\r
+#else\r
+               WPP_INIT_TRACING(L"ibspdll.dll");\r
+#endif\r
+#endif         \r
+\r
+\r
+\r
+               IBSP_PRINT(TRACE_LEVEL_INFORMATION, IBSP_DBG_DLL, ("DllMain: DLL_PROCESS_ATTACH\n") );\r
+\r
+\r
+#if !defined(EVENT_TRACING)\r
+#if DBG \r
+\r
+               i = GetEnvironmentVariable( "IBWSD_DBG_LEVEL", env_var, sizeof(env_var) );\r
                if( i && i <= 16 )\r
                {\r
-                       gdbg_lvl = _tcstoul( env_var, NULL, 16 );\r
-                       IBSP_TRACE( IBSP_DBG_DLL,\r
-                               ("Given IBWSD_DBG debug level:0x%X\n",\r
-                               gdbg_lvl) );\r
+                       g_ibsp_dbg_level = _tcstoul( env_var, NULL, 16 );\r
                }\r
+\r
+               i = GetEnvironmentVariable( "IBWSD_DBG_FLAGS", env_var, sizeof(env_var) );\r
+               if( i && i <= 16 )\r
+               {\r
+                       g_ibsp_dbg_flags = _tcstoul( env_var, NULL, 16 );\r
+               }\r
+\r
+               if( g_ibsp_dbg_flags & IBSP_DBG_ERR )\r
+                       g_ibsp_dbg_flags |= CL_DBG_ERROR;\r
+\r
+               IBSP_PRINT(TRACE_LEVEL_INFORMATION ,IBSP_DBG_DLL ,\r
+                       ("Given IBAL_UAL_DBG debug level:%d  debug flags 0x%x\n",\r
+                       g_ibsp_dbg_level ,g_ibsp_dbg_flags) );\r
+\r
 #endif\r
+#endif\r
+\r
 \r
                /* See if the user wants to disable RDMA reads. */\r
                no_read = GetEnvironmentVariable( "IBWSD_NO_READ", NULL, 0 );\r
@@ -135,6 +173,9 @@ _DllMain(
                        DWORD_PTR xx;\r
                        BOOL ret = GetProcessAffinityMask(GetCurrentProcess(), &g_dwPollThreadAffinityMask, &xx);\r
                        CL_ASSERT(ret != 0);\r
+                       if (ret == 0) {\r
+                               IBSP_ERROR( ("GetProcessAffinityMask Failed (not a fatal error)\n") );\r
+                       }\r
                        ret = ret; \r
                }    \r
 \r
@@ -185,15 +226,15 @@ _DllMain(
                break;\r
 \r
        case DLL_THREAD_ATTACH:\r
-               IBSP_TRACE( IBSP_DBG_DLL, ("DllMain: DLL_THREAD_ATTACH\n") );\r
+               IBSP_PRINT(TRACE_LEVEL_INFORMATION, IBSP_DBG_DLL, ("DllMain: DLL_THREAD_ATTACH\n") );\r
                break;\r
 \r
        case DLL_THREAD_DETACH:\r
-               IBSP_TRACE( IBSP_DBG_DLL, ("DllMain: DLL_THREAD_DETACH\n") );\r
+               IBSP_PRINT(TRACE_LEVEL_INFORMATION, IBSP_DBG_DLL, ("DllMain: DLL_THREAD_DETACH\n") );\r
                break;\r
 \r
        case DLL_PROCESS_DETACH:\r
-               IBSP_TRACE( IBSP_DBG_DLL, ("DllMain: DLL_PROCESS_DETACH\n") );\r
+               IBSP_PRINT(TRACE_LEVEL_INFORMATION, IBSP_DBG_DLL, ("DllMain: DLL_PROCESS_DETACH\n") );\r
 \r
 #ifdef _DEBUG_\r
                {\r
@@ -217,12 +258,12 @@ _DllMain(
                        cl_spinlock_release( &g_ibsp.socket_info_mutex );\r
 \r
                        IBSP_ERROR( ("Statistics:\n") );\r
-                       IBSP_ERROR(\r
-                                        ("  overlap_h0_count = %d\n", g_ibsp.overlap_h0_count) );\r
-                       IBSP_ERROR(\r
-                                        ("  max_comp_count = %d\n", g_ibsp.max_comp_count) );\r
-                       IBSP_ERROR(\r
-                                        ("  overlap_h1_count = %d\n", g_ibsp.overlap_h1_count) );\r
+                       IBSP_ERROR( (\r
+                                        "  overlap_h0_count = %d\n", g_ibsp.overlap_h0_count) );\r
+                       IBSP_ERROR( (\r
+                                        "  max_comp_count = %d\n", g_ibsp.max_comp_count) );\r
+                       IBSP_ERROR( (\r
+                                        "  overlap_h1_count = %d\n", g_ibsp.overlap_h1_count) );\r
 \r
                        IBSP_ERROR( ("  send_count = %d\n", g_ibsp.send_count) );\r
 \r
@@ -232,27 +273,27 @@ _DllMain(
 \r
                        IBSP_ERROR( ("  total_recv_compleated = %d\n", g_ibsp.total_recv_compleated) );\r
 \r
-                       IBSP_ERROR(\r
-                                        ("  number of QPs left = %d\n", g_ibsp.qp_num) );\r
-                       IBSP_ERROR(\r
-                                        ("  number of CQs left = %d\n", g_ibsp.cq_num) );\r
-                       IBSP_ERROR(\r
-                                        ("  number of PDs left = %d\n", g_ibsp.pd_num) );\r
-                       IBSP_ERROR(\r
-                                        ("  number of ALs left = %d\n", g_ibsp.al_num) );\r
-                       IBSP_ERROR(\r
-                                        ("  number of MRs left = %d\n", g_ibsp.mr_num) );\r
-                       IBSP_ERROR(\r
-                                        ("  number of listens left = %d\n", g_ibsp.listen_num) );\r
-                       IBSP_ERROR(\r
-                                        ("  number of PNPs left = %d\n", g_ibsp.pnp_num) );\r
-                       IBSP_ERROR(\r
-                                        ("  number of threads left = %d\n", g_ibsp.thread_num) );\r
-                       IBSP_ERROR(\r
-                                        ("  number of WPU sockets left = %d\n", g_ibsp.wpusocket_num) );\r
-\r
-                       IBSP_ERROR(\r
-                                        ("  CloseSocket_count = %d\n", g_ibsp.CloseSocket_count) );\r
+                       IBSP_ERROR( (\r
+                                       "  number of QPs left = %d\n", g_ibsp.qp_num) );\r
+                       IBSP_ERROR( (\r
+                                       "  number of CQs left = %d\n", g_ibsp.cq_num) );\r
+                       IBSP_ERROR( (\r
+                                       "  number of PDs left = %d\n", g_ibsp.pd_num) );\r
+                       IBSP_ERROR( (\r
+                                       "  number of ALs left = %d\n", g_ibsp.al_num) );\r
+                       IBSP_ERROR( (\r
+                                        "  number of MRs left = %d\n", g_ibsp.mr_num) );\r
+                       IBSP_ERROR( (\r
+                                       "  number of listens left = %d\n", g_ibsp.listen_num) );\r
+                       IBSP_ERROR( (\r
+                                       "  number of PNPs left = %d\n", g_ibsp.pnp_num) );\r
+                       IBSP_ERROR( (\r
+                                       "  number of threads left = %d\n", g_ibsp.thread_num) );\r
+                       IBSP_ERROR( (\r
+                                       "  number of WPU sockets left = %d\n", g_ibsp.wpusocket_num) );\r
+\r
+                       IBSP_ERROR( (\r
+                                       "  CloseSocket_count = %d\n", g_ibsp.CloseSocket_count) );\r
 \r
                }\r
 #endif\r
@@ -260,6 +301,11 @@ _DllMain(
 #ifdef PERFMON_ENABLED\r
                IBSPPmClose();\r
 #endif\r
+\r
+\r
+#if defined(EVENT_TRACING)\r
+               WPP_CLEANUP();\r
+#endif\r
                break;\r
        }\r
 \r
@@ -347,9 +393,9 @@ accept_socket(
        /* Copy the socket context info from parent socket context */\r
        new_socket_info->socket_options = p_socket->socket_options;\r
 \r
-       IBSP_TRACE( IBSP_DBG_CONN,\r
+       IBSP_PRINT(TRACE_LEVEL_INFORMATION, IBSP_DBG_CONN,\r
                ("The socket address of connecting entity is\n") );\r
-       DebugPrintSockAddr( IBSP_DBG_CONN, gdbg_lvl, &p_incoming->params.source );\r
+       DebugPrintSockAddr( IBSP_DBG_CONN, &p_incoming->params.source );\r
 \r
        new_socket_info->peer_addr = p_incoming->params.source;\r
 \r
@@ -393,7 +439,7 @@ accept_socket(
 \r
        cl_spinlock_release( &new_socket_info->mutex );\r
 \r
-       IBSP_TRACE_EXIT( IBSP_DBG_CONN,\r
+       IBSP_PRINT_EXIT(TRACE_LEVEL_INFORMATION, IBSP_DBG_CONN,\r
                ("returns new socket (0x%p)\n", new_socket_info) );\r
        return (SOCKET)new_socket_info;\r
 }\r
@@ -464,7 +510,7 @@ IBSPAccept(
                return INVALID_SOCKET;\r
        }\r
 \r
-       IBSP_TRACE( IBSP_DBG_CONN,\r
+       IBSP_PRINT(TRACE_LEVEL_INFORMATION, IBSP_DBG_CONN,\r
                ("IBSPAccept: Found pending connection on this socket\n") );\r
 \r
        incoming = PARENT_STRUCT(cl_qlist_remove_head( &socket_info->listen.list ),\r
@@ -485,8 +531,7 @@ IBSPAccept(
                port = get_port_from_ip_address( incoming->params.dest.sin_addr );\r
                if( !port )\r
                {\r
-                       IBSP_ERROR(\r
-                               ("incoming destination IP address not local (%s)\n",\r
+                       IBSP_ERROR( ("incoming destination IP address not local (%s)\n",\r
                                inet_ntoa( incoming->params.dest.sin_addr )) );\r
                        goto reject;\r
                }\r
@@ -495,8 +540,8 @@ IBSPAccept(
        /* Cross-check with the path info to make sure we are conectiong correctly */\r
        if( port->guid != ib_gid_get_guid( &incoming->cm_req_received.primary_path.sgid ) )\r
        {\r
-               IBSP_ERROR(\r
-                       ("GUIDs of port for destination IP address and primary path do not match (%016I64x, %016I64x)\n",\r
+               IBSP_ERROR( (\r
+                       "GUIDs of port for destination IP address and primary path do not match (%016I64x, %016I64x)\n",\r
                        port->guid,\r
                        ib_gid_get_guid( &incoming->cm_req_received.primary_path.sgid )) );\r
 \r
@@ -521,7 +566,7 @@ reject:
        callee_id.buf = (char *)&incoming->params.dest;\r
        callee_id.len = sizeof(incoming->params.dest);\r
 \r
-       IBSP_TRACE( IBSP_DBG_CONN,\r
+       IBSP_PRINT(TRACE_LEVEL_INFORMATION, IBSP_DBG_CONN,\r
                ("Got incoming conn from %s/%d-%d to %s/%d-%d\n",\r
                inet_ntoa( incoming->params.source.sin_addr ),\r
                cl_ntoh16( incoming->params.source.sin_port ),\r
@@ -536,12 +581,11 @@ reject:
        {\r
        default:\r
                /* Should never happen */\r
-               IBSP_ERROR(\r
-                       ("Conditional routine returned undocumented code\n") );\r
+               IBSP_ERROR( ("Conditional routine returned undocumented code\n") );\r
                /* Fall through. */\r
 \r
        case CF_REJECT:\r
-               IBSP_TRACE1( IBSP_DBG_CONN,\r
+               IBSP_PRINT(TRACE_LEVEL_INFORMATION, IBSP_DBG_CONN,\r
                        ("Conditional routine returned CF_REJECT\n") );\r
 \r
                ib_reject( incoming->cm_req_received.h_cm_req, IB_REJ_USER_DEFINED );\r
@@ -563,7 +607,7 @@ reject:
                cl_qlist_insert_head( &socket_info->listen.list, &incoming->item );\r
                cl_spinlock_release( &socket_info->mutex );\r
 \r
-               IBSP_TRACE1( IBSP_DBG_CONN,\r
+               IBSP_PRINT(TRACE_LEVEL_INFORMATION, IBSP_DBG_CONN,\r
                        ("Conditional routine returned CF_DEFER\n") );\r
 \r
                *lpErrno = WSATRY_AGAIN;\r
@@ -612,16 +656,15 @@ IBSPBind(
        fzprint(("%s():%d:0x%x:0x%x: socket=0x%p \n", __FUNCTION__,\r
                         __LINE__, GetCurrentProcessId(), GetCurrentThreadId(), s));\r
 \r
-       IBSP_TRACE( IBSP_DBG_CONN, ("Address to bind to:\n") );\r
-       DebugPrintSockAddr( IBSP_DBG_CONN, gdbg_lvl, addr );\r
+       IBSP_PRINT(TRACE_LEVEL_INFORMATION, IBSP_DBG_CONN, ("Address to bind to:\n") );\r
+       DebugPrintSockAddr( IBSP_DBG_CONN, addr );\r
 \r
        fzprint(("binding to IP %s\n", inet_ntoa( addr->sin_addr )));\r
 \r
        /* Sanity checks */\r
        if( namelen != sizeof(struct sockaddr_in) )\r
        {\r
-               IBSP_ERROR(\r
-                       ("invalid namelen (%d instead of %d)\n",\r
+               IBSP_ERROR( ("invalid namelen (%d instead of %d)\n",\r
                        namelen, sizeof(struct sockaddr_in)) );\r
                *lpErrno = WSAEFAULT;\r
                goto error;\r
@@ -640,8 +683,8 @@ IBSPBind(
                port = get_port_from_ip_address( addr->sin_addr );\r
                if( port == NULL )\r
                {\r
-                       IBSP_ERROR(\r
-                               ("This IP address does not belong to that host (%08x)\n",\r
+                       IBSP_ERROR( (\r
+                               "This IP address does not belong to that host (%08x)\n",\r
                                addr->sin_addr.S_un.S_addr) );\r
                        *lpErrno = WSAEADDRNOTAVAIL;\r
                        goto error;\r
@@ -660,8 +703,8 @@ IBSPBind(
        if( socket_info->socket_state != IBSP_CREATE )\r
        {\r
                cl_spinlock_release( &socket_info->mutex );\r
-               IBSP_ERROR(\r
-                       ("Invalid socket state (%s)\n",\r
+               IBSP_ERROR( (\r
+                       "Invalid socket state (%s)\n",\r
                        IBSP_SOCKET_STATE_STR( socket_info->socket_state )) );\r
                *lpErrno = WSAEINVAL;\r
                goto error;\r
@@ -694,7 +737,7 @@ IBSPBind(
 \r
 error:\r
        CL_ASSERT( *lpErrno != 0 );\r
-       IBSP_TRACE_EXIT( IBSP_DBG_CONN, ("failed with error %d\n", *lpErrno) );\r
+       IBSP_PRINT_EXIT(TRACE_LEVEL_INFORMATION, IBSP_DBG_CONN, ("failed with error %d\n", *lpErrno) );\r
        return SOCKET_ERROR;\r
 }\r
 \r
@@ -721,7 +764,7 @@ IBSPCloseSocket(
 \r
        if( s == INVALID_SOCKET )\r
        {\r
-               IBSP_ERROR_EXIT( ("invalid socket handle %x\n", s) );\r
+               IBSP_ERROR_EXIT( ("invalid socket handle %Ix\n", s) );\r
                *lpErrno = WSAENOTSOCK;\r
                return SOCKET_ERROR;\r
        }\r
@@ -771,7 +814,7 @@ IBSPConnect(
                         __LINE__, GetCurrentProcessId(),\r
                         GetCurrentThreadId(), s, IBSP_SOCKET_STATE_STR( socket_info->socket_state )));\r
 \r
-       IBSP_TRACE( IBSP_DBG_CONN,\r
+       IBSP_PRINT(TRACE_LEVEL_INFORMATION, IBSP_DBG_CONN,\r
                ("lpCallerData=%p, lpCalleeData=%p\n", lpCallerData, lpCalleeData) );\r
 \r
        /* Sanity checks */\r
@@ -785,8 +828,8 @@ IBSPConnect(
 \r
        if( namelen < sizeof(struct sockaddr_in) )\r
        {\r
-               IBSP_ERROR_EXIT(\r
-                       ("invalid remote address (%d)\n", socket_info->socket_state) );\r
+               IBSP_ERROR_EXIT( (\r
+                       "invalid remote address (%d)\n", socket_info->socket_state) );\r
                *lpErrno = WSAEFAULT;\r
                return SOCKET_ERROR;\r
        }\r
@@ -795,8 +838,7 @@ IBSPConnect(
        if( addr->sin_family != AF_INET ||\r
                addr->sin_port == 0 || addr->sin_addr.s_addr == INADDR_ANY )\r
        {\r
-               IBSP_ERROR_EXIT(\r
-                       ("peer entity address is invalid (%d, %d, %x)\n",\r
+               IBSP_ERROR_EXIT( ("peer entity address is invalid (%d, %d, %x)\n",\r
                        addr->sin_family, addr->sin_port, addr->sin_addr.s_addr) );\r
                *lpErrno = WSAEADDRNOTAVAIL;\r
                return SOCKET_ERROR;\r
@@ -805,7 +847,7 @@ IBSPConnect(
        if( socket_info->local_addr.sin_addr.S_un.S_addr == addr->sin_addr.S_un.S_addr )\r
        {\r
                /* Loopback - let the regular stack take care of that. */\r
-               IBSP_TRACE_EXIT( IBSP_DBG_CONN | IBSP_DBG_LEVEL1, ("Loopback!\n") );\r
+               IBSP_PRINT_EXIT(TRACE_LEVEL_INFORMATION, IBSP_DBG_CONN, ("Loopback!\n") );\r
                *lpErrno = WSAEADDRNOTAVAIL;\r
                return SOCKET_ERROR;\r
        }\r
@@ -814,19 +856,18 @@ IBSPConnect(
        ret = query_guid_address( socket_info->port, addr->sin_addr.s_addr, &dest_port_guid );\r
        if( ret )\r
        {\r
-               IBSP_ERROR_EXIT(\r
-                       ("query_guid_address failed for IP %08x\n",\r
+               IBSP_ERROR_EXIT( ("query_guid_address failed for IP %08x\n",\r
                        addr->sin_addr.s_addr) );\r
                *lpErrno = g_connect_err;\r
                return SOCKET_ERROR;\r
        }\r
 \r
-       IBSP_TRACE( IBSP_DBG_CONN, ("got GUID %I64x for IP %s\n",\r
+       IBSP_PRINT(TRACE_LEVEL_INFORMATION, IBSP_DBG_CONN, ("got GUID %I64x for IP %s\n",\r
                CL_NTOH64( dest_port_guid ), inet_ntoa( addr->sin_addr )) );\r
 \r
        if( dest_port_guid == socket_info->port->guid )\r
        {\r
-               IBSP_TRACE_EXIT( IBSP_DBG_CONN | IBSP_DBG_LEVEL1, ("Loopback!\n") );\r
+               IBSP_PRINT_EXIT(TRACE_LEVEL_INFORMATION, IBSP_DBG_CONN, ("Loopback!\n") );\r
                *lpErrno = WSAEADDRNOTAVAIL;\r
                return SOCKET_ERROR;\r
        }\r
@@ -835,8 +876,8 @@ IBSPConnect(
        ret = query_pr( socket_info->port, dest_port_guid, &path_rec );\r
        if( ret )\r
        {\r
-               IBSP_ERROR_EXIT(\r
-                       ("query_pr failed for IP %08x\n", addr->sin_addr.s_addr) );\r
+               IBSP_ERROR_EXIT( (\r
+                       "query_pr failed for IP %08x\n", addr->sin_addr.s_addr) );\r
                *lpErrno = g_connect_err;\r
                return SOCKET_ERROR;\r
        }\r
@@ -925,7 +966,7 @@ IBSPEnumNetworkEvents(
 \r
        if( lpNetworkEvents->lNetworkEvents & FD_ACCEPT )\r
        {\r
-               IBSP_TRACE1( IBSP_DBG_NEV,\r
+               IBSP_PRINT(TRACE_LEVEL_INFORMATION, IBSP_DBG_NEV,\r
                        ("socket %p notify FD_ACCEPT at time %I64d\n",\r
                        socket_info, cl_get_time_stamp()) );\r
                lpNetworkEvents->iErrorCode[FD_ACCEPT_BIT] = 0;\r
@@ -933,7 +974,7 @@ IBSPEnumNetworkEvents(
 \r
        if( lpNetworkEvents->lNetworkEvents & FD_CONNECT )\r
        {\r
-               IBSP_TRACE1( IBSP_DBG_NEV,\r
+               IBSP_PRINT(TRACE_LEVEL_INFORMATION, IBSP_DBG_NEV,\r
                        ("socket %p notify FD_CONNECT %d at time %I64d\n",\r
                        socket_info, socket_info->errno_connect, cl_get_time_stamp()) );\r
                lpNetworkEvents->iErrorCode[FD_CONNECT_BIT] = socket_info->errno_connect;\r
@@ -963,13 +1004,13 @@ IBSPEventSelect(
 \r
        IBSP_ENTER( IBSP_DBG_NEV );\r
 \r
-       IBSP_TRACE4( IBSP_DBG_NEV,\r
-               ("Socket %p requesting notifiction of %d on event %p.\n",\r
-               s, lNetworkEvents, hEventObject) );\r
+       IBSP_PRINT(TRACE_LEVEL_INFORMATION, IBSP_DBG_NEV,\r
+               ("Socket %Ix requesting notifiction of %d on event %p.\n",\r
+               s, lNetworkEvents, hEventObject));\r
 \r
        if( (lNetworkEvents & ~(FD_ACCEPT | FD_CONNECT)) != 0 )\r
        {\r
-               IBSP_TRACE_EXIT(IBSP_DBG_NEV,\r
+               IBSP_PRINT_EXIT(TRACE_LEVEL_INFORMATION,IBSP_DBG_NEV,\r
                        ("Unknown lNetworkEvents flag given (%x)\n", lNetworkEvents) );\r
                *lpErrno = WSAEINVAL;\r
                return SOCKET_ERROR;\r
@@ -984,7 +1025,7 @@ IBSPEventSelect(
        /* Check for existing events and signal as appropriate. */\r
        if( (socket_info->event_mask & events) && hEventObject )\r
        {\r
-               IBSP_TRACE2( IBSP_DBG_NEV,\r
+               IBSP_PRINT(TRACE_LEVEL_INFORMATION, IBSP_DBG_NEV,\r
                        ("Signaling eventHandle %p .\n", socket_info->event_select) );\r
                SetEvent( hEventObject );\r
        }\r
@@ -1030,7 +1071,7 @@ IBSPGetOverlappedResult(
        {\r
                /* Seen in real life with overlap/client test.\r
                 * The switch closes a socket then calls this. Why? */\r
-               IBSP_ERROR_EXIT( ("invalid socket handle %x\n", s) );\r
+               IBSP_ERROR_EXIT( ("invalid socket handle %Ix\n", s) );\r
                *lpErrno = WSAENOTSOCK;\r
                return SOCKET_ERROR;\r
        }\r
@@ -1061,16 +1102,16 @@ IBSPGetOverlappedResult(
 \r
                fzprint(("%s():%d:0x%x:0x%x: socket=0x%p completed overlap=0x%x overlap_h0_count=%d overlap_h1_count=%d\n", __FUNCTION__, __LINE__, GetCurrentProcessId(), GetCurrentThreadId(), s, lpOverlapped, g_ibsp.overlap_h0_count, g_ibsp.overlap_h1_count));\r
 #endif\r
-               IBSP_TRACE1( IBSP_DBG_IO,\r
-                       ("socket=%p completed ov=%p\n", s, lpOverlapped) );\r
+               IBSP_PRINT(TRACE_LEVEL_INFORMATION, IBSP_DBG_IO,\r
+                       ("socket=%p completed ov=%p\n", (void*)s, lpOverlapped));\r
        }\r
        else\r
        {\r
                /* Operation is still in progress */\r
                *lpErrno = WSA_IO_INCOMPLETE;\r
-               IBSP_TRACE1( IBSP_DBG_IO,\r
+               IBSP_PRINT(TRACE_LEVEL_INFORMATION, IBSP_DBG_IO,\r
                        ("socket=%p ov=%p hEvent=%p, operation in progress\n",\r
-                       s, lpOverlapped, lpOverlapped->hEvent));\r
+                       (void*)s, lpOverlapped, lpOverlapped->hEvent));\r
        }\r
 \r
        *lpcbTransfer = (DWORD)lpOverlapped->InternalHigh;\r
@@ -1120,8 +1161,7 @@ IBSPGetSockOpt(
 \r
        if( optval == NULL || optlen == NULL )\r
        {\r
-               IBSP_ERROR_EXIT(\r
-                                         ("invalid optval=%p or optlen=%p", optval, optlen) );\r
+               IBSP_ERROR_EXIT( ("invalid optval=%p or optlen=%p", optval, optlen) );\r
                *lpErrno = WSAEFAULT;\r
                return SOCKET_ERROR;\r
        }\r
@@ -1129,11 +1169,10 @@ IBSPGetSockOpt(
        switch( optname )\r
        {\r
        case SO_DEBUG:\r
-               IBSP_TRACE( IBSP_DBG_OPT, ("Option name SO_DEBUG\n") );\r
+               IBSP_PRINT(TRACE_LEVEL_INFORMATION, IBSP_DBG_OPT, ("Option name SO_DEBUG\n") );\r
                if( *optlen < sizeof(BOOL) )\r
                {\r
-                       IBSP_ERROR_EXIT(\r
-                               ("option len is invalid (0x%x)\n", *optlen) );\r
+                       IBSP_ERROR_EXIT( ("option len is invalid (0x%x)\n", *optlen) );\r
                        *optlen = sizeof(BOOL);\r
                        *lpErrno = WSAEFAULT;\r
                        return SOCKET_ERROR;\r
@@ -1144,11 +1183,10 @@ IBSPGetSockOpt(
                break;\r
 \r
        case SO_GROUP_ID:\r
-               IBSP_TRACE( IBSP_DBG_OPT, ("Option name SO_GROUP_ID\n") );\r
+               IBSP_PRINT(TRACE_LEVEL_INFORMATION, IBSP_DBG_OPT, ("Option name SO_GROUP_ID\n") );\r
                if( *optlen < sizeof(GROUP) )\r
                {\r
-                       IBSP_ERROR_EXIT(\r
-                               ("option len is invalid (0x%x)\n", *optlen) );\r
+                       IBSP_ERROR_EXIT( ("option len is invalid (0x%x)\n", *optlen) );\r
                        *optlen = sizeof(GROUP);\r
                        *lpErrno = WSAEFAULT;\r
                        return SOCKET_ERROR;\r
@@ -1159,12 +1197,11 @@ IBSPGetSockOpt(
                break;\r
 \r
        case SO_GROUP_PRIORITY:\r
-               IBSP_TRACE( IBSP_DBG_OPT, ("Option name SO_GROUP_PRIORITY\n") );\r
+               IBSP_PRINT(TRACE_LEVEL_INFORMATION, IBSP_DBG_OPT, ("Option name SO_GROUP_PRIORITY\n") );\r
 \r
                if( *optlen < sizeof(int) )\r
                {\r
-                       IBSP_ERROR_EXIT(\r
-                               ("option len is invalid (0x%x)\n", *optlen) );\r
+                       IBSP_ERROR_EXIT( ("option len is invalid (0x%x)\n", *optlen) );\r
                        *optlen = sizeof(int);\r
                        *lpErrno = WSAEFAULT;\r
                        return SOCKET_ERROR;\r
@@ -1175,12 +1212,11 @@ IBSPGetSockOpt(
                break;\r
 \r
        case SO_MAX_MSG_SIZE:\r
-               IBSP_TRACE( IBSP_DBG_OPT, ("Option name SO_MAX_MSG_SIZE\n") );\r
+               IBSP_PRINT(TRACE_LEVEL_INFORMATION, IBSP_DBG_OPT, ("Option name SO_MAX_MSG_SIZE\n") );\r
 \r
                if( *optlen < sizeof(unsigned int) )\r
                {\r
-                       IBSP_ERROR_EXIT(\r
-                               ("option len is invalid (0x%x)\n", *optlen) );\r
+                       IBSP_ERROR_EXIT( ("option len is invalid (0x%x)\n", *optlen) );\r
                        *optlen = sizeof(unsigned int);\r
                        *lpErrno = WSAEFAULT;\r
                        return SOCKET_ERROR;\r
@@ -1191,12 +1227,11 @@ IBSPGetSockOpt(
                break;\r
 \r
        case SO_MAX_RDMA_SIZE:\r
-               IBSP_TRACE( IBSP_DBG_OPT, ("Option name SO_MAX_RDMA_SIZE\n") );\r
+               IBSP_PRINT(TRACE_LEVEL_INFORMATION, IBSP_DBG_OPT, ("Option name SO_MAX_RDMA_SIZE\n") );\r
 \r
                if( *optlen < sizeof(unsigned int) )\r
                {\r
-                       IBSP_ERROR_EXIT(\r
-                               ("option len is invalid (0x%x)\n", *optlen) );\r
+                       IBSP_ERROR_EXIT( ("option len is invalid (0x%x)\n", *optlen) );\r
                        *optlen = sizeof(unsigned int);\r
                        *lpErrno = WSAEFAULT;\r
                        return SOCKET_ERROR;\r
@@ -1207,12 +1242,11 @@ IBSPGetSockOpt(
                break;\r
 \r
        case SO_RDMA_THRESHOLD_SIZE:\r
-               IBSP_TRACE( IBSP_DBG_OPT, ("Option name SO_RDMA_THRESHOLD_SIZE\n") );\r
+               IBSP_PRINT(TRACE_LEVEL_INFORMATION, IBSP_DBG_OPT, ("Option name SO_RDMA_THRESHOLD_SIZE\n") );\r
 \r
                if( *optlen < sizeof(unsigned int) )\r
                {\r
-                       IBSP_ERROR_EXIT(\r
-                               ("option len is invalid (0x%x)\n", *optlen) );\r
+                       IBSP_ERROR_EXIT( ("option len is invalid (0x%x)\n", *optlen) );\r
                        *optlen = sizeof(unsigned int);\r
                        *lpErrno = WSAEFAULT;\r
                        return SOCKET_ERROR;\r
@@ -1307,7 +1341,7 @@ IBSPIoctl(
        if( dwIoControlCode == SIO_GET_EXTENSION_FUNCTION_POINTER )\r
        {\r
                /* This a special case. The socket handle passed is not valid. */\r
-               IBSP_TRACE1( IBSP_DBG_OPT, ("Get extension function pointer\n") );\r
+               IBSP_PRINT(TRACE_LEVEL_INFORMATION, IBSP_DBG_OPT, ("Get extension function pointer\n") );\r
 \r
                if( memcmp( lpvInBuffer, &SANRegisterMemory, sizeof(GUID) ) == 0 )\r
                {\r
@@ -1338,7 +1372,7 @@ IBSPIoctl(
                {\r
                        if( no_read )\r
                        {\r
-                               IBSP_TRACE( IBSP_DBG_WARN | IBSP_DBG_OPT,\r
+                               IBSP_PRINT(TRACE_LEVEL_WARNING, IBSP_DBG_OPT,\r
                                        ("RDMA_READ disabled.\n") );\r
                                *lpErrno = WSAEOPNOTSUPP;\r
                                return SOCKET_ERROR;\r
@@ -1370,7 +1404,7 @@ IBSPIoctl(
 \r
        /* Verify the state of the socket */\r
        /* Not sure which state socket should be in to receive this call */\r
-       DebugPrintIBSPIoctlParams( IBSP_DBG_OPT, gdbg_lvl,\r
+       DebugPrintIBSPIoctlParams( IBSP_DBG_OPT, \r
                                                          dwIoControlCode,\r
                                                          lpvInBuffer,\r
                                                          cbInBuffer,\r
@@ -1385,8 +1419,7 @@ IBSPIoctl(
        case SIO_SET_GROUP_QOS:\r
                /* We don't support that. dwServiceFlags1 in installSP \r
                 * wasn't set. */\r
-               IBSP_ERROR_EXIT(\r
-                       ("unsupported dwIoControlCode %d\n", dwIoControlCode) );\r
+               IBSP_ERROR_EXIT( ("unsupported dwIoControlCode %d\n", dwIoControlCode) );\r
                *lpErrno = WSAENOPROTOOPT;\r
                return SOCKET_ERROR;\r
                break;\r
@@ -1405,8 +1438,7 @@ IBSPIoctl(
                break;\r
 \r
        default:\r
-               IBSP_ERROR_EXIT(\r
-                       ("invalid dwIoControlCode %d\n", dwIoControlCode) );\r
+               IBSP_ERROR_EXIT( ("invalid dwIoControlCode %d\n", dwIoControlCode) );\r
 \r
                *lpErrno = WSAENOPROTOOPT;\r
                return SOCKET_ERROR;\r
@@ -1439,7 +1471,7 @@ IBSPListen(
 \r
        cl_spinlock_acquire( &socket_info->mutex );\r
 \r
-       IBSP_TRACE( IBSP_DBG_CONN, ("socket_state is %s\n",\r
+       IBSP_PRINT(TRACE_LEVEL_INFORMATION, IBSP_DBG_CONN, ("socket_state is %s\n",\r
                IBSP_SOCKET_STATE_STR( socket_info->socket_state )) );\r
 \r
        /* Verify the state of the socket */\r
@@ -1470,8 +1502,7 @@ IBSPListen(
                break;\r
 \r
        default:\r
-               IBSP_ERROR(\r
-                       ("Invalid socket_state (%s)\n",\r
+               IBSP_ERROR( ("Invalid socket_state (%s)\n",\r
                        IBSP_SOCKET_STATE_STR( socket_info->socket_state )) );\r
                ret = WSAEINVAL;\r
                break;\r
@@ -1531,8 +1562,8 @@ IBSPRecv(
        {\r
                /* Seen in real life with overlap/client test. \r
                 * The switch closes a socket then calls this. Why? */\r
-               IBSP_TRACE_EXIT( IBSP_DBG_WARN | IBSP_DBG_IO,\r
-                       ("invalid socket handle %x\n", s) );\r
+               IBSP_PRINT_EXIT(TRACE_LEVEL_WARNING, IBSP_DBG_IO,\r
+                       ("invalid socket handle %Ix\n", s) );\r
                *lpErrno = WSAENOTSOCK;\r
                return SOCKET_ERROR;\r
        }\r
@@ -1546,8 +1577,7 @@ IBSPRecv(
 \r
        default:\r
                cl_spinlock_release( &socket_info->mutex );\r
-               IBSP_ERROR_EXIT(\r
-                       ("Socket is not in connected socket_state state=%s\n",\r
+               IBSP_ERROR_EXIT( ("Socket is not in connected socket_state state=%s\n",\r
                        IBSP_SOCKET_STATE_STR( socket_info->socket_state )) );\r
                *lpErrno = WSAENOTCONN;\r
                return SOCKET_ERROR;\r
@@ -1556,8 +1586,7 @@ IBSPRecv(
 \r
        if( socket_info->qp_error != 0 )\r
        {\r
-               IBSP_ERROR_EXIT(\r
-                       ("QP is in error state %d\n", socket_info->qp_error) );\r
+               IBSP_ERROR_EXIT( ("QP is in error state %d\n", socket_info->qp_error) );\r
                *lpErrno = socket_info->qp_error;\r
                return SOCKET_ERROR;\r
        }\r
@@ -1567,8 +1596,8 @@ IBSPRecv(
        if( dwBufferCount > QP_ATTRIB_RQ_SGE )\r
        {\r
                CL_ASSERT( dwBufferCount <= QP_ATTRIB_RQ_SGE );\r
-               IBSP_ERROR_EXIT(\r
-                       ("dwBufferCount is greater than %d\n", QP_ATTRIB_RQ_SGE) );\r
+               IBSP_ERROR_EXIT( ("dwBufferCount is greater than %d\n", \r
+                       QP_ATTRIB_RQ_SGE) );\r
                *lpErrno = WSAEINVAL;\r
                return SOCKET_ERROR;\r
        }\r
@@ -1672,16 +1701,15 @@ IBSPRecv(
                        socket_info->recv_idx = 0;\r
 #endif\r
 \r
-               IBSP_TRACE1( IBSP_DBG_IO,\r
+               IBSP_PRINT(TRACE_LEVEL_INFORMATION, IBSP_DBG_IO,\r
                        ("Posted RECV: socket=%p, ov=%p, addr=%p, len=%d\n",\r
-                       s, lpOverlapped, lpBuffers[0].buf, lpBuffers[0].len) );\r
+                       (void*)s, lpOverlapped, lpBuffers[0].buf, lpBuffers[0].len));\r
 \r
                *lpErrno = WSA_IO_PENDING;\r
        }\r
        else\r
        {\r
-               IBSP_ERROR(\r
-                       ("ib_post_recv returned %s\n", ib_get_err_str( status )) );\r
+               IBSP_ERROR( ("ib_post_recv returned %s\n", ib_get_err_str( status )) );\r
 #ifdef _DEBUG_\r
                if( lpOverlapped->hEvent == 0 )\r
                {\r
@@ -1748,7 +1776,7 @@ IBSPSend(
 \r
        if( s == INVALID_SOCKET )\r
        {\r
-               IBSP_ERROR_EXIT( ("invalid socket handle %x\n", s) );\r
+               IBSP_ERROR_EXIT( ("invalid socket handle %Ix\n", s) );\r
                *lpErrno = WSAENOTSOCK;\r
                return SOCKET_ERROR;\r
        }\r
@@ -1765,8 +1793,7 @@ IBSPSend(
 \r
        default:\r
                cl_spinlock_release( &socket_info->mutex );\r
-               IBSP_ERROR_EXIT(\r
-                       ("Socket is not in connected socket_state state=%s\n",\r
+               IBSP_ERROR_EXIT( ("Socket is not in connected socket_state state=%s\n",\r
                        IBSP_SOCKET_STATE_STR( socket_info->socket_state )) );\r
                *lpErrno = WSAENOTCONN;\r
                return SOCKET_ERROR;\r
@@ -1775,8 +1802,7 @@ IBSPSend(
 \r
        if( socket_info->qp_error )\r
        {\r
-               IBSP_ERROR_EXIT(\r
-                       ("QP is in error state %d\n", socket_info->qp_error) );\r
+               IBSP_ERROR_EXIT( ("QP is in error state %d\n", socket_info->qp_error) );\r
                *lpErrno = socket_info->qp_error;\r
                return SOCKET_ERROR;\r
        }\r
@@ -1785,8 +1811,7 @@ IBSPSend(
        if( dwBufferCount > QP_ATTRIB_SQ_SGE )\r
        {\r
                CL_ASSERT( dwBufferCount <= QP_ATTRIB_SQ_SGE );\r
-               IBSP_ERROR_EXIT(\r
-                       ("dwBufferCount is greater than %d\n", QP_ATTRIB_SQ_SGE) );\r
+               IBSP_ERROR_EXIT( ("dwBufferCount is greater than %d\n", QP_ATTRIB_SQ_SGE) );\r
                *lpErrno = WSAEINVAL;\r
                return SOCKET_ERROR;\r
        }\r
@@ -1897,7 +1922,7 @@ IBSPSend(
 #ifdef _DEBUG_\r
        if( lpBuffers[0].len >= 40 )\r
        {\r
-               debug_dump_buffer( IBSP_DBG_WQ | IBSP_DBG_LEVEL4, "SEND",\r
+               debug_dump_buffer( IBSP_DBG_WQ , "SEND",\r
                        lpBuffers[0].buf, 40 );\r
        }\r
 #endif\r
@@ -1931,9 +1956,9 @@ IBSPSend(
 #endif\r
 \r
 \r
-               IBSP_TRACE1( IBSP_DBG_IO,\r
+               IBSP_PRINT(TRACE_LEVEL_INFORMATION, IBSP_DBG_IO,\r
                        ("Posted SEND: socket=%p, ov=%p, addr=%p, len=%d\n",\r
-                       s, lpOverlapped, lpBuffers[0].buf, lpBuffers[0].len) );\r
+                       (void*)s, lpOverlapped, lpBuffers[0].buf, lpBuffers[0].len));\r
 \r
                *lpErrno = WSA_IO_PENDING;\r
        }\r
@@ -2008,11 +2033,10 @@ IBSPSetSockOpt(
        switch( optname )\r
        {\r
        case SO_DEBUG:\r
-               IBSP_TRACE( IBSP_DBG_OPT, ("Option name SO_DEBUG\n") );\r
+               IBSP_PRINT(TRACE_LEVEL_INFORMATION, IBSP_DBG_OPT, ("Option name SO_DEBUG\n") );\r
                if( optlen != sizeof(BOOL) )\r
                {\r
-                       IBSP_ERROR_EXIT(\r
-                               ("option len is invalid (0x%x)\n", optlen) );\r
+                       IBSP_ERROR_EXIT( ("option len is invalid (0x%x)\n", optlen) );\r
                        *lpErrno = WSAEFAULT;\r
                        return SOCKET_ERROR;\r
                }\r
@@ -2020,11 +2044,10 @@ IBSPSetSockOpt(
                break;\r
 \r
        case SO_GROUP_PRIORITY:\r
-               IBSP_TRACE( IBSP_DBG_OPT, ("Option name SO_GROUP_PRIORITY\n") );\r
+               IBSP_PRINT(TRACE_LEVEL_INFORMATION, IBSP_DBG_OPT, ("Option name SO_GROUP_PRIORITY\n") );\r
                if( optlen != sizeof(int) )\r
                {\r
-                       IBSP_ERROR_EXIT(\r
-                               ("option len is invalid (0x%x)\n", optlen) );\r
+                       IBSP_ERROR_EXIT( ("option len is invalid (0x%x)\n", optlen) );\r
                        *lpErrno = WSAEFAULT;\r
                        return SOCKET_ERROR;\r
                }\r
@@ -2073,32 +2096,28 @@ IBSPSocket(
 \r
        if( af != AF_INET )\r
        {\r
-               IBSP_ERROR_EXIT(\r
-                       ("bad family %d instead of %d\n", af, AF_INET) );\r
+               IBSP_ERROR_EXIT( ("bad family %d instead of %d\n", af, AF_INET) );\r
                *lpErrno = WSAEAFNOSUPPORT;\r
                return INVALID_SOCKET;\r
        }\r
 \r
        if( type != SOCK_STREAM )\r
        {\r
-               IBSP_ERROR_EXIT(\r
-                       ("bad type %d instead of %d\n", type, SOCK_STREAM) );\r
+               IBSP_ERROR_EXIT( ("bad type %d instead of %d\n", type, SOCK_STREAM) );\r
                *lpErrno = WSAEPROTOTYPE;\r
                return INVALID_SOCKET;\r
        }\r
 \r
        if( protocol != IPPROTO_TCP )\r
        {\r
-               IBSP_ERROR_EXIT(\r
-                       ("bad protocol %d instead of %d\n", protocol, IPPROTO_TCP) );\r
+               IBSP_ERROR_EXIT( ("bad protocol %d instead of %d\n", protocol, IPPROTO_TCP) );\r
                *lpErrno = WSAEPROTONOSUPPORT;\r
                return INVALID_SOCKET;\r
        }\r
 \r
        if( (dwFlags != WSA_FLAG_OVERLAPPED) )\r
        {\r
-               IBSP_ERROR_EXIT(\r
-                       ("dwFlags is not WSA_FLAG_OVERLAPPED (%x)\n", dwFlags) );\r
+               IBSP_ERROR_EXIT( ("dwFlags is not WSA_FLAG_OVERLAPPED (%x)\n", dwFlags) );\r
                *lpErrno = WSAEINVAL;\r
                return INVALID_SOCKET;\r
        }\r
@@ -2118,8 +2137,7 @@ IBSPSocket(
                if( *lpErrno )\r
                {\r
                        deref_socket_info( socket_info );\r
-                       IBSP_ERROR(\r
-                               ("setup_duplicate_socket failed with %d\n", *lpErrno) );\r
+                       IBSP_ERROR( ("setup_duplicate_socket failed with %d\n", *lpErrno) );\r
                        return INVALID_SOCKET;\r
                }\r
        }\r
@@ -2142,7 +2160,7 @@ IBSPSocket(
        fzprint(("%s():%d:0x%x:0x%x: socket=0x%p\n", __FUNCTION__,\r
                         __LINE__, GetCurrentProcessId(), GetCurrentThreadId(), socket_info));\r
 \r
-       IBSP_TRACE_EXIT( IBSP_DBG_SI,\r
+       IBSP_PRINT_EXIT(TRACE_LEVEL_INFORMATION, IBSP_DBG_SI,\r
                ("returning socket handle %p\n", socket_info) );\r
 \r
        return (SOCKET) socket_info;\r
@@ -2179,11 +2197,11 @@ IBSPCleanup(
        /* Decrement the entry count */\r
        g_ibsp.entry_count--;\r
 \r
-       IBSP_TRACE( IBSP_DBG_INIT, ("WSPCleanup: %d\n", g_ibsp.entry_count) );\r
+       IBSP_PRINT(TRACE_LEVEL_INFORMATION, IBSP_DBG_INIT, ("WSPCleanup: %d\n", g_ibsp.entry_count) );\r
 \r
        if( g_ibsp.entry_count == 0 )\r
        {\r
-               IBSP_TRACE( IBSP_DBG_INIT, ("entry_count is 0 => cleaning up\n") );\r
+               IBSP_PRINT(TRACE_LEVEL_INFORMATION, IBSP_DBG_INIT, ("entry_count is 0 => cleaning up\n") );\r
                ib_release();\r
 \r
 #ifdef PERFMON_ENABLED\r
@@ -2223,13 +2241,12 @@ WSPStartupEx(
           major version and the high byte is the minor version. */\r
        if( (LOBYTE(wVersion) < 2) || ((LOBYTE(wVersion) == 2) && (HIBYTE(wVersion) < 2)) )\r
        {\r
-               IBSP_ERROR_EXIT(\r
-                       ("Invalid winsock version requested %x\n", wVersion) );\r
+               IBSP_ERROR_EXIT( ("Invalid winsock version requested %x\n", wVersion) );\r
 \r
                return WSAVERNOTSUPPORTED;\r
        }\r
 \r
-       IBSP_TRACE( IBSP_DBG_INIT, ("entry_count=%d)\n", g_ibsp.entry_count) );\r
+       IBSP_PRINT(TRACE_LEVEL_INFORMATION, IBSP_DBG_INIT, ("entry_count=%d)\n", g_ibsp.entry_count) );\r
 \r
        cl_spinlock_acquire( &g_ibsp.mutex );\r
 \r
@@ -2279,8 +2296,7 @@ WSPStartupEx(
                ret = ibsp_initialize();\r
                if( ret )\r
                {\r
-                       IBSP_ERROR_EXIT(\r
-                               ("ibsp_initialize failed (%d)\n", ret) );\r
+                       IBSP_ERROR_EXIT( ("ibsp_initialize failed (%d)\n", ret) );\r
                        return ret;\r
                }\r
        }\r
index 76c9550..5d7ae89 100644 (file)
@@ -36,6 +36,7 @@
 #include <complib/cl_debug.h>\r
 \r
 \r
+\r
 enum ibsp_socket_state\r
 {\r
        IBSP_CREATE = 0,\r
@@ -352,15 +353,9 @@ ibsp_css(
        /* IBSP_CLOSED is a dead end state */\r
        if( old_state == IBSP_CLOSED )\r
        {\r
-               fzprint(("%s():0x%x:0x%x: socket=0x%p cannot change from %s to %s, called by %s():%d\n", __FUNCTION__, GetCurrentProcessId(), GetCurrentThreadId(), s, IBSP_SOCKET_STATE_STR(old_state), IBSP_SOCKET_STATE_STR(new_state), calling_func, line));\r
                return;\r
        }\r
 \r
-       fzprint(("%s():0x%x:0x%x: socket=0x%p %s to %s, called by %s():%d\n", __FUNCTION__,\r
-                        GetCurrentProcessId(),\r
-                        GetCurrentThreadId(), s,\r
-                        IBSP_SOCKET_STATE_STR(old_state),\r
-                        IBSP_SOCKET_STATE_STR(new_state), calling_func, line));\r
 \r
        s->socket_state = new_state;\r
 }\r
index 2f92f82..5d81bb5 100644 (file)
@@ -1,5 +1,6 @@
 /*\r
  * Copyright (c) 2005 SilverStorm Technologies.  All rights reserved.\r
+ * Copyright (c) 2006 Mellanox Technologies.  All rights reserved.\r
  *\r
  * This software is available to you under the OpenIB.org BSD license\r
  * below:\r
  * $Id$\r
  */\r
 \r
+#include "ibspdebug.h"\r
+#if defined(EVENT_TRACING)\r
+#ifdef offsetof\r
+#undef offsetof\r
+#endif\r
+#include "misc.tmh"\r
+#endif\r
+\r
 #include "ibspdll.h"\r
 \r
 char *ibsp_socket_state_str[IBSP_NUM_STATES] = {\r
@@ -87,8 +96,7 @@ init_globals( void )
        g_ibsp.heap = HeapCreate( 0, 128000, 0 );\r
        if( g_ibsp.heap == NULL)\r
        {\r
-               IBSP_ERROR_EXIT(\r
-                       ("HeapCreate() failed: %d\n", GetLastError()) );\r
+               IBSP_ERROR_EXIT( ("HeapCreate() failed: %d\n", GetLastError()) );\r
                return 1;\r
        }\r
 \r
index b5af1ac..1109b01 100644 (file)
@@ -1,5 +1,6 @@
 /*\r
  * Copyright (c) 2005 SilverStorm Technologies.  All rights reserved.\r
+ * Copyright (c) 2006 Mellanox Technologies.  All rights reserved.\r
  *\r
  * This software is available to you under the OpenIB.org BSD license\r
  * below:\r
  * $Id$\r
  */\r
 \r
+#include "ibspdebug.h"\r
+#if defined(EVENT_TRACING)\r
+#include "sockinfo.tmh"\r
+#endif\r
+\r
 #include "ibspdll.h"\r
 \r
 \r
@@ -54,7 +60,7 @@ create_socket_info(
                HEAP_ZERO_MEMORY, sizeof(struct ibsp_socket_info) );\r
        if( socket_info == NULL )\r
        {\r
-               IBSP_TRACE_EXIT( IBSP_DBG_SI,\r
+               IBSP_PRINT_EXIT(TRACE_LEVEL_INFORMATION, IBSP_DBG_SI,\r
                        ("HeapAlloc() failed: %d\n", GetLastError()) );\r
                *lpErrno = WSAENOBUFS;\r
                return NULL;\r
@@ -87,8 +93,7 @@ create_socket_info(
 \r
        if( socket_info->switch_socket == INVALID_SOCKET )\r
        {\r
-               IBSP_ERROR(\r
-                       ("WPUCreateSocketHandle() failed: %d", *lpErrno) );\r
+               IBSP_ERROR( ("WPUCreateSocketHandle() failed: %d", *lpErrno) );\r
 err:\r
                free_socket_info( socket_info );\r
                IBSP_EXIT( IBSP_DBG_SI );\r
@@ -103,8 +108,8 @@ err:
         */\r
        socket_info->ref_cnt = 1;\r
 \r
-       IBSP_TRACE( IBSP_DBG_SI, ("socket_info (%p), switch socket (%p)\n",\r
-               socket_info, socket_info->switch_socket) );\r
+       IBSP_PRINT(TRACE_LEVEL_INFORMATION, IBSP_DBG_SI, ("socket_info (%p), switch socket (%p)\n",\r
+               socket_info, (void*)socket_info->switch_socket) );\r
 \r
        IBSP_EXIT( IBSP_DBG_SI );\r
        return socket_info;\r
@@ -120,17 +125,20 @@ free_socket_info(
        if( p_socket->switch_socket != INVALID_SOCKET )\r
        {\r
                /* ref_cnt hit zero - destroy the switch socket. */\r
-               IBSP_TRACE1( IBSP_DBG_SI,\r
+               IBSP_PRINT(TRACE_LEVEL_INFORMATION, IBSP_DBG_SI,\r
                        ("socket=0x%p calling lpWPUCloseSocketHandle=0x%p\n",\r
-                       p_socket, p_socket->switch_socket) );\r
+                       p_socket, (void*)p_socket->switch_socket) );\r
 \r
                ret = g_ibsp.up_call_table.lpWPUCloseSocketHandle(\r
                        p_socket->switch_socket, &error );\r
                if( ret == SOCKET_ERROR )\r
+               {\r
                        IBSP_ERROR( ("WPUCloseSocketHandle failed: %d\n", error) );\r
+               }\r
                else\r
+               {\r
                        STAT_DEC( wpusocket_num );\r
-\r
+               }\r
                p_socket->switch_socket = INVALID_SOCKET;\r
        }\r
 \r
@@ -162,7 +170,7 @@ deref_socket_info(
        if( !cl_atomic_dec( &p_socket->ref_cnt ) )\r
        {\r
                free_socket_info( p_socket );\r
-               IBSP_TRACE( IBSP_DBG_SI, ("Freed socket_info (%p)\n", p_socket) );\r
+               IBSP_PRINT(TRACE_LEVEL_INFORMATION, IBSP_DBG_SI, ("Freed socket_info (%p)\n", p_socket) );\r
        }\r
        IBSP_EXIT( IBSP_DBG_SI );\r
 }\r