dc27bad6bb3f44c152755f3b60463d36be8f725f
[mirror/winof/.git] / ulp / ipoib / kernel / ipoib_debug.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 \r
33 #ifndef _IPOIB_DEBUG_H_\r
34 #define _IPOIB_DEBUG_H_\r
35 \r
36 \r
37 #define __MODULE__      "[IPoIB]"\r
38 \r
39 #include <complib/cl_debug.h>\r
40 \r
41 \r
42 /* Object types for passing into complib. */\r
43 #define IPOIB_OBJ_INSTANCE              1\r
44 #define IPOIB_OBJ_PORT                  2\r
45 #define IPOIB_OBJ_ENDPOINT              3\r
46 \r
47 \r
48 extern uint32_t         g_ipoib_dbg_level;\r
49 extern uint32_t         g_ipoib_dbg_flags;\r
50 \r
51 \r
52 #if defined(EVENT_TRACING)\r
53 //\r
54 // Software Tracing Definitions\r
55 //\r
56 #define WPP_CONTROL_GUIDS \\r
57         WPP_DEFINE_CONTROL_GUID( \\r
58                 IPOIBCtlGuid,(3F9BC73D, EB03, 453a, B27B, 20F9A664211A), \\r
59         WPP_DEFINE_BIT(IPOIB_DBG_ERROR) \\r
60         WPP_DEFINE_BIT(IPOIB_DBG_INIT) \\r
61         WPP_DEFINE_BIT(IPOIB_DBG_PNP) \\r
62         WPP_DEFINE_BIT(IPOIB_DBG_SEND) \\r
63         WPP_DEFINE_BIT(IPOIB_DBG_RECV) \\r
64         WPP_DEFINE_BIT(IPOIB_DBG_ENDPT) \\r
65         WPP_DEFINE_BIT(IPOIB_DBG_IB) \\r
66         WPP_DEFINE_BIT(IPOIB_DBG_BUF) \\r
67         WPP_DEFINE_BIT(IPOIB_DBG_MCAST) \\r
68         WPP_DEFINE_BIT(IPOIB_DBG_ALLOC) \\r
69         WPP_DEFINE_BIT(IPOIB_DBG_OID) \\r
70         WPP_DEFINE_BIT(IPOIB_DBG_IOCTL) \\r
71         WPP_DEFINE_BIT(IPOIB_DBG_STAT))\r
72 \r
73 \r
74 \r
75 #define WPP_LEVEL_FLAGS_ENABLED(lvl, flags) \\r
76         (WPP_LEVEL_ENABLED(flags) && WPP_CONTROL(WPP_BIT_ ## flags).Level  >= lvl)\r
77 #define WPP_LEVEL_FLAGS_LOGGER(lvl,flags) WPP_LEVEL_LOGGER(flags)\r
78 #define WPP_FLAG_ENABLED(flags) \\r
79         (WPP_LEVEL_ENABLED(flags) && \\r
80         WPP_CONTROL(WPP_BIT_ ## flags).Level  >= TRACE_LEVEL_VERBOSE)\r
81 #define WPP_FLAG_LOGGER(flags) WPP_LEVEL_LOGGER(flags)\r
82 \r
83 // begin_wpp config\r
84 // IPOIB_ENTER(FLAG);\r
85 // IPOIB_EXIT(FLAG);\r
86 // USEPREFIX(IPOIB_PRINT, "%!STDPREFIX! [IPoIB] :%!FUNC!() :");\r
87 // USEPREFIX(IPOIB_PRINT_EXIT, "%!STDPREFIX! [IPoIB] :%!FUNC!() :");\r
88 // USESUFFIX(IPOIB_PRINT_EXIT, "[IpoIB] :%!FUNC!():]");\r
89 // USESUFFIX(IPOIB_ENTER, " [IPoIB] :%!FUNC!():[");\r
90 // USESUFFIX(IPOIB_EXIT, " [IPoIB] :%!FUNC!():]");\r
91 // end_wpp\r
92 \r
93 #else\r
94 \r
95 #include <evntrace.h>\r
96 \r
97 \r
98 /*\r
99  * Debug macros\r
100  */\r
101 #define IPOIB_DBG_ERR   (1 << 0)\r
102 #define IPOIB_DBG_INIT  (1 << 1)\r
103 #define IPOIB_DBG_PNP   (1 << 2)\r
104 #define IPOIB_DBG_SEND  (1 << 3)\r
105 #define IPOIB_DBG_RECV  (1 << 4)\r
106 #define IPOIB_DBG_ENDPT (1 << 5)\r
107 #define IPOIB_DBG_IB    (1 << 6)\r
108 #define IPOIB_DBG_BUF   (1 << 7)\r
109 #define IPOIB_DBG_MCAST (1 << 8)\r
110 #define IPOIB_DBG_ALLOC (1 << 9)\r
111 #define IPOIB_DBG_OID   (1 << 10)\r
112 #define IPOIB_DBG_IOCTL (1 << 11)\r
113 #define IPOIB_DBG_STAT  (1 << 12)\r
114 \r
115 #define IPOIB_DBG_ERROR (CL_DBG_ERROR | IPOIB_DBG_ERR)\r
116 #define IPOIB_DBG_ALL   CL_DBG_ALL\r
117 \r
118 \r
119 #if DBG\r
120 \r
121 // assignment of _level_ is need to to overcome warning C4127\r
122 #define IPOIB_PRINT(_level_,_flag_,_msg_) \\r
123         { \\r
124                 if( g_ipoib_dbg_level >= (_level_) ) \\r
125                         CL_TRACE( _flag_, g_ipoib_dbg_flags, _msg_ ); \\r
126         }\r
127 \r
128 #define IPOIB_PRINT_EXIT(_level_,_flag_,_msg_) \\r
129         { \\r
130                 if( g_ipoib_dbg_level >= (_level_) ) \\r
131                         CL_TRACE( _flag_, g_ipoib_dbg_flags, _msg_ );\\r
132                 IPOIB_EXIT(_flag_);\\r
133         }\r
134 \r
135 #define IPOIB_ENTER(_flag_) \\r
136         { \\r
137                 if( g_ipoib_dbg_level >= TRACE_LEVEL_VERBOSE ) \\r
138                         CL_ENTER( _flag_, g_ipoib_dbg_flags ); \\r
139         }\r
140 \r
141 #define IPOIB_EXIT(_flag_)\\r
142         { \\r
143                 if( g_ipoib_dbg_level >= TRACE_LEVEL_VERBOSE ) \\r
144                         CL_EXIT( _flag_, g_ipoib_dbg_flags ); \\r
145         }\r
146 \r
147 #define IPOIB_TRACE_BYTES( lvl, ptr, len )                                                                      \\r
148         {                                                                                                                                               \\r
149                 if( g_ipoib_dbg_level >= (_level_) &&                                                           \\r
150                         (g_ipoib_dbg_flags & (_flag_)) )                                                                \\r
151                 {                                                                                                                                       \\r
152                         size_t _loop_;                                                                                                  \\r
153                         for( _loop_ = 0; _loop_ < (len); ++_loop_ )                                             \\r
154                         {                                                                                                                               \\r
155                                 DbgPrint( "0x%.2X ", ((uint8_t*)(ptr))[_loop_] );                       \\r
156                                 if( (_loop_ + 1)% 16 == 0 )                                                                     \\r
157                                         DbgPrint("\n");                                                                                 \\r
158                                 else if( (_loop_ % 4 + 1) == 0 )                                                        \\r
159                                         DbgPrint("  ");                                                                                 \\r
160                         }                                                                                                                               \\r
161                         DbgPrint("\n");                                                                                                 \\r
162                 }                                                                                                                                       \\r
163         }\r
164 \r
165 #else\r
166 \r
167 #define IPOIB_PRINT(lvl, flags, msg)\r
168 \r
169 #define IPOIB_PRINT_EXIT(_level_,_flag_,_msg_)\r
170 \r
171 #define IPOIB_ENTER(_flag_)\r
172 \r
173 #define IPOIB_EXIT(_flag_)\r
174 \r
175 #define IPOIB_TRACE_BYTES( lvl, ptr, len )\r
176 \r
177 #endif\r
178 \r
179 #endif //EVENT_TRACING\r
180 \r
181 \r
182 enum ipoib_perf_counters\r
183 {\r
184         SendBundle,\r
185         SendPackets,\r
186                 PortSend,\r
187                         GetEthHdr,\r
188                         SendMgrQueue,\r
189                                 GetEndpt,\r
190                                         EndptQueue,\r
191                         QueuePacket,\r
192                         BuildSendDesc,\r
193                                 SendMgrFilter,\r
194                                         FilterIp,\r
195                                                 QueryIp,\r
196                                                 SendTcp,\r
197                                                 FilterUdp,\r
198                                                         QueryUdp,\r
199                                                         SendUdp,\r
200                                                         FilterDhcp,\r
201                                         FilterArp,\r
202                                         SendGen,\r
203                                                 SendCopy,\r
204                         PostSend,\r
205                         ProcessFailedSends,\r
206         SendCompBundle,\r
207         SendCb,\r
208                 PollSend,\r
209                 SendComp,\r
210                 FreeSendBuf,\r
211                 RearmSend,\r
212                 PortResume,\r
213         RecvCompBundle,\r
214         RecvCb,\r
215                 PollRecv,\r
216                 FilterRecv,\r
217                         GetRecvEndpts,\r
218                                 GetEndptByGid,\r
219                                 GetEndptByLid,\r
220                                 EndptInsert,\r
221                         RecvTcp,\r
222                         RecvUdp,\r
223                         RecvDhcp,\r
224                         RecvArp,\r
225                         RecvGen,\r
226         BuildPktArray,\r
227                 PreparePkt,\r
228                         GetNdisPkt,\r
229         RecvNdisIndicate,\r
230         PutRecvList,\r
231         RepostRecv,\r
232                 GetRecv,\r
233                 PostRecv,\r
234         RearmRecv,\r
235                 ReturnPacket,\r
236                 ReturnPutRecv,\r
237                 ReturnRepostRecv,\r
238                 ReturnPreparePkt,\r
239                 ReturnNdisIndicate,\r
240 \r
241         /* Must be last! */\r
242         MaxPerf\r
243 \r
244 };\r
245 \r
246 #endif  /* _IPOIB_DEBUG_H_ */\r