2 * Copyright (c) 2005 SilverStorm Technologies. All rights reserved.
\r
4 * This software is available to you under the OpenIB.org BSD license
\r
7 * Redistribution and use in source and binary forms, with or
\r
8 * without modification, are permitted provided that the following
\r
9 * conditions are met:
\r
11 * - Redistributions of source code must retain the above
\r
12 * copyright notice, this list of conditions and the following
\r
15 * - Redistributions in binary form must reproduce the above
\r
16 * copyright notice, this list of conditions and the following
\r
17 * disclaimer in the documentation and/or other materials
\r
18 * provided with the distribution.
\r
20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
\r
21 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
\r
22 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
\r
23 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
\r
24 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
\r
25 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
\r
26 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
\r
32 #include "ibspdll.h"
\r
33 #include <complib/cl_atomic.h>
\r
36 extern uint32_t gdbg_lvl;
\r
39 #define IBSP_DBG_DLL 0x00000001 /* DLL */
\r
40 #define IBSP_DBG_SI 0x00000002 /* socket info */
\r
41 #define IBSP_DBG_INIT 0x00000004 /* initialization code */
\r
42 #define IBSP_DBG_WQ 0x00000008 /* WQ related functions */
\r
43 #define IBSP_DBG_EP 0x00000010 /* Enpoints related functions */
\r
44 #define IBSP_DBG_MEM 0x00000020 /* memory registration */
\r
45 #define IBSP_DBG_CM 0x00000040 /* CM */
\r
46 #define IBSP_DBG_CONN 0x00000080 /* connections */
\r
47 #define IBSP_DBG_OPT 0x00000200 /* socket options */
\r
48 #define IBSP_DBG_NEV 0x00000400 /* network events */
\r
49 #define IBSP_DBG_HW 0x00000800 /* Hardware */
\r
50 #define IBSP_DBG_IO 0x00001000 /* Overlapped I/O request */
\r
51 #define IBSP_DBG_DUP 0x00002000 /* Socket Duplication */
\r
52 #define IBSP_DBG_PERFMON 0x00004000 /* Performance Monitoring */
\r
54 #define IBSP_DBG_LEVEL4 0x01000000 /* debug use */
\r
55 #define IBSP_DBG_LEVEL3 0x02000000 /* debug use */
\r
56 #define IBSP_DBG_LEVEL2 0x04000000 /* debug use */
\r
57 #define IBSP_DBG_LEVEL1 0x08000000 /* debug use */
\r
58 #define IBSP_DBG_FUNC 0x20000000 /* Function enter/exit */
\r
59 #define IBSP_DBG_WARN 0x40000000 /* Warnings */
\r
61 #define CL_ERROR(a, b, c) CL_TRACE((a|CL_DBG_ERROR), b, c)
\r
62 #define CL_EXIT_ERROR(a, b, c) CL_TRACE_EXIT((a|CL_DBG_ERROR), b, c)
\r
64 #define IBSP_ERROR( m ) CL_TRACE( CL_DBG_ERROR, gdbg_lvl, m )
\r
65 #define IBSP_ERROR_EXIT( m ) CL_TRACE_EXIT( CL_DBG_ERROR, gdbg_lvl, m )
\r
66 #define IBSP_TRACE( l, m ) CL_TRACE( (l), gdbg_lvl, m )
\r
67 #define IBSP_TRACE1( l, m ) CL_TRACE( (l | IBSP_DBG_LEVEL1), gdbg_lvl, m )
\r
68 #define IBSP_TRACE2( l, m ) CL_TRACE( (l | IBSP_DBG_LEVEL2), gdbg_lvl, m )
\r
69 #define IBSP_TRACE3( l, m ) CL_TRACE( (l | IBSP_DBG_LEVEL3), gdbg_lvl, m )
\r
70 #define IBSP_TRACE4( l, m ) CL_TRACE( (l | IBSP_DBG_LEVEL4), gdbg_lvl, m )
\r
71 #define IBSP_TRACE_EXIT( l, m ) CL_TRACE_EXIT( (l | IBSP_DBG_FUNC), gdbg_lvl, m )
\r
72 #define IBSP_ENTER( l ) CL_ENTER( (l | IBSP_DBG_FUNC), gdbg_lvl )
\r
73 #define IBSP_EXIT( l ) CL_EXIT( (l | IBSP_DBG_FUNC), gdbg_lvl )
\r
77 //#define fzprint(a) CL_PRINT(IBSP_DBG_USER, IBSP_DBG_USER, a)
\r
80 //#define BREAKPOINT(x) if( gCurrentDebugLevel & x ) { DebugBreak(); }
\r
82 DebugPrintIBSPIoctlParams(
\r
85 DWORD dwIoControlCode,
\r
88 LPVOID lpvOutBuffer,
\r
90 LPWSAOVERLAPPED lpOverlapped,
\r
91 LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine,
\r
92 LPWSATHREADID lpThreadId );
\r
98 struct sockaddr_in *sockaddr );
\r
108 debug_dump_overlapped(
\r
112 LPWSAOVERLAPPED lpOverlapped );
\r
114 /* Activate memory tracking debugging */
\r
115 #define HeapAlloc(a,b,c) cl_zalloc(c)
\r
116 #define HeapFree(a,b,c) (cl_free(c), TRUE)
\r
117 #define HeapCreate(a,b,c) ((HANDLE)(-1))
\r
118 #define HeapDestroy(a)
\r
120 #define STAT_INC(name) cl_atomic_inc( &g_ibsp.name )
\r
121 #define STAT_DEC(name) cl_atomic_dec( &g_ibsp.name )
\r
125 #define STAT_INC(name)
\r
126 #define STAT_DEC(name)
\r
127 #define BREAKPOINT(x)
\r
128 #define DebugPrintIBSPIoctlParams(a,b,c,d,e,f,g,h,i,j)
\r
129 #define DebugPrintSockAddr(a,b,c)
\r
131 #define STATS(expr)
\r
133 #endif /* _DEBUG_ */
\r
136 * To enable logging of all Send/Receive data for each socket
\r
137 * uncomment the following line.
\r
139 //#define IBSP_LOGGING
\r
141 #ifdef IBSP_LOGGING
\r
143 typedef struct DataLogger
\r
148 size_t ToatalPrinted;
\r
149 BOOL ShutdownClosed;
\r
155 VOID DataLogger_Init(
\r
156 DataLogger *pLoger,
\r
158 struct sockaddr_in *addr1,
\r
159 struct sockaddr_in *addr2 );
\r
162 VOID DataLogger_WriteData(
\r
163 DataLogger *pLoger,
\r
168 VOID DataLogger_Shutdown(
\r
169 DataLogger *pLoger );
\r
171 #endif /* IBSP_LOGGING */
\r