[WSD] Add perfmon counter object implementation. WSD installation now
[mirror/winof/.git] / ulp / wsd / user / ibspdebug.h
1 /*\r
2  * Copyright (c) 2005 SilverStorm Technologies.  All rights reserved.\r
3  *\r
4  * This software is available to you under the OpenIB.org BSD license\r
5  * below:\r
6  *\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
10  *\r
11  *      - Redistributions of source code must retain the above\r
12  *        copyright notice, this list of conditions and the following\r
13  *        disclaimer.\r
14  *\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
19  *\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
27  * SOFTWARE.\r
28  *\r
29  * $Id$\r
30  */\r
31 \r
32 #include "ibspdll.h"\r
33 #include <complib/cl_atomic.h>\r
34 \r
35 \r
36 extern uint32_t gdbg_lvl;\r
37 \r
38 \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
53 \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
60 \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
63 \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
74 \r
75 #if defined _DEBUG_\r
76 \r
77 //#define fzprint(a) CL_PRINT(IBSP_DBG_USER, IBSP_DBG_USER, a)\r
78 #define fzprint(a)\r
79 \r
80 //#define BREAKPOINT(x) if( gCurrentDebugLevel & x ) { DebugBreak(); }\r
81 void\r
82 DebugPrintIBSPIoctlParams(\r
83                                         uint32_t                                        level,\r
84                                         uint32_t                                        mask,\r
85                                         DWORD                                           dwIoControlCode,\r
86                                         LPVOID                                          lpvInBuffer,\r
87                                         DWORD                                           cbInBuffer,\r
88                                         LPVOID                                          lpvOutBuffer,\r
89                                         DWORD                                           cbOutBuffer,\r
90                                         LPWSAOVERLAPPED                         lpOverlapped,\r
91                                         LPWSAOVERLAPPED_COMPLETION_ROUTINE      lpCompletionRoutine,\r
92                                         LPWSATHREADID                           lpThreadId );\r
93 \r
94 void\r
95 DebugPrintSockAddr(\r
96                                         uint32_t                                        level,\r
97                                         uint32_t                                        mask,\r
98                                         struct sockaddr_in                      *sockaddr );\r
99 \r
100 void\r
101 debug_dump_buffer(\r
102                                         uint32_t                                        level,\r
103                         const   char                                            *name,\r
104                                         void                                            *buf,\r
105                                         size_t                                          len );\r
106 \r
107 void\r
108 debug_dump_overlapped(\r
109                                         uint32_t                                        level,\r
110                                         uint32_t                                        mask,\r
111                         const   char                                            *name,\r
112                                         LPWSAOVERLAPPED                         lpOverlapped );\r
113 \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
119 \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
122 \r
123 #else\r
124 \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
130 #define fzprint(a)\r
131 #define STATS(expr)\r
132 \r
133 #endif /* _DEBUG_ */\r
134 \r
135 /*\r
136  * To enable logging of all Send/Receive data for each socket\r
137  * uncomment the following line.\r
138  */\r
139 //#define IBSP_LOGGING\r
140 \r
141 #ifdef IBSP_LOGGING\r
142 \r
143 typedef struct DataLogger\r
144 {\r
145         char                            *BufferStart;\r
146         size_t                          TotalSize;\r
147         char                            *NextPrint;\r
148         size_t                          ToatalPrinted;\r
149         BOOL                            ShutdownClosed;\r
150         HANDLE                          hMapFile;\r
151 \r
152 }DataLogger;\r
153 \r
154 \r
155 VOID DataLogger_Init(\r
156                                         DataLogger                                      *pLoger,\r
157                                         char                                            *prefix,\r
158                                         struct sockaddr_in                      *addr1,\r
159                                         struct sockaddr_in                      *addr2 );\r
160 \r
161 \r
162 VOID DataLogger_WriteData(\r
163                                         DataLogger                                      *pLoger,\r
164                                         long                                            Idx,\r
165                                         char                                            *Data,\r
166                                         DWORD                                           Len );\r
167 \r
168 VOID DataLogger_Shutdown(\r
169                                         DataLogger                                      *pLoger );\r
170 \r
171 #endif  /* IBSP_LOGGING */\r