[eth6] Add first version of ipoib NDIS 6.0 driver.
[mirror/winof/.git] / ulp / ipoib / kernel6 / ipoib_debug.h
1 /*\r
2  * Copyright (c) 2005 SilverStorm Technologies.  All rights reserved.\r
3  * Copyright (c) 2006 Mellanox Technologies.  All rights reserved.\r
4  *\r
5  * This software is available to you under the OpenIB.org BSD license\r
6  * below:\r
7  *\r
8  *     Redistribution and use in source and binary forms, with or\r
9  *     without modification, are permitted provided that the following\r
10  *     conditions are met:\r
11  *\r
12  *      - Redistributions of source code must retain the above\r
13  *        copyright notice, this list of conditions and the following\r
14  *        disclaimer.\r
15  *\r
16  *      - Redistributions in binary form must reproduce the above\r
17  *        copyright notice, this list of conditions and the following\r
18  *        disclaimer in the documentation and/or other materials\r
19  *        provided with the distribution.\r
20  *\r
21  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
22  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
23  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
24  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS\r
25  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN\r
26  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
27  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r
28  * SOFTWARE.\r
29  *\r
30  * $Id: ipoib_debug.h 3719 2009-01-07 12:31:52Z reuven $\r
31  */\r
32 \r
33 \r
34 #ifndef _IPOIB_DEBUG_H_\r
35 #define _IPOIB_DEBUG_H_\r
36 \r
37 #if defined __MODULE__\r
38 #undef __MODULE__\r
39 #endif\r
40 \r
41 #define __MODULE__      "[IPoIB]"\r
42 \r
43 #include <complib/cl_debug.h>\r
44 \r
45 \r
46 /* Object types for passing into complib. */\r
47 #define IPOIB_OBJ_INSTANCE              1\r
48 #define IPOIB_OBJ_PORT                  2\r
49 #define IPOIB_OBJ_ENDPOINT              3\r
50 \r
51 \r
52 extern uint32_t         g_ipoib_dbg_level;\r
53 extern uint32_t         g_ipoib_dbg_flags;\r
54 \r
55 \r
56 #if defined(EVENT_TRACING)\r
57 //\r
58 // Software Tracing Definitions\r
59 //\r
60 #define WPP_CONTROL_GUIDS \\r
61         WPP_DEFINE_CONTROL_GUID( \\r
62                 IPOIBCtlGuid,(3F9BC73D, EB03, 453a, B27B, 20F9A664211A), \\r
63         WPP_DEFINE_BIT(IPOIB_DBG_ERROR) \\r
64         WPP_DEFINE_BIT(IPOIB_DBG_INIT) \\r
65         WPP_DEFINE_BIT(IPOIB_DBG_PNP) \\r
66         WPP_DEFINE_BIT(IPOIB_DBG_SEND) \\r
67         WPP_DEFINE_BIT(IPOIB_DBG_RECV) \\r
68         WPP_DEFINE_BIT(IPOIB_DBG_ENDPT) \\r
69         WPP_DEFINE_BIT(IPOIB_DBG_IB) \\r
70         WPP_DEFINE_BIT(IPOIB_DBG_BUF) \\r
71         WPP_DEFINE_BIT(IPOIB_DBG_MCAST) \\r
72         WPP_DEFINE_BIT(IPOIB_DBG_ALLOC) \\r
73         WPP_DEFINE_BIT(IPOIB_DBG_OID) \\r
74         WPP_DEFINE_BIT(IPOIB_DBG_IOCTL) \\r
75         WPP_DEFINE_BIT(IPOIB_DBG_STAT) \\r
76         WPP_DEFINE_BIT(IPOIB_DBG_OBJ))\r
77 \r
78 \r
79 \r
80 #define WPP_LEVEL_FLAGS_ENABLED(lvl, flags) \\r
81         (WPP_LEVEL_ENABLED(flags) && WPP_CONTROL(WPP_BIT_ ## flags).Level  >= lvl)\r
82 #define WPP_LEVEL_FLAGS_LOGGER(lvl,flags) WPP_LEVEL_LOGGER(flags)\r
83 #define WPP_FLAG_ENABLED(flags) \\r
84         (WPP_LEVEL_ENABLED(flags) && \\r
85         WPP_CONTROL(WPP_BIT_ ## flags).Level  >= TRACE_LEVEL_VERBOSE)\r
86 #define WPP_FLAG_LOGGER(flags) WPP_LEVEL_LOGGER(flags)\r
87 \r
88 // begin_wpp config\r
89 // IPOIB_ENTER(FLAG);\r
90 // IPOIB_EXIT(FLAG);\r
91 // USEPREFIX(IPOIB_PRINT, "%!STDPREFIX! [IPoIB] :%!FUNC!() :");\r
92 // USEPREFIX(IPOIB_PRINT_EXIT, "%!STDPREFIX! [IPoIB] :%!FUNC!() :");\r
93 // USESUFFIX(IPOIB_PRINT_EXIT, "[IpoIB] :%!FUNC!():]");\r
94 // USESUFFIX(IPOIB_ENTER, " [IPoIB] :%!FUNC!():[");\r
95 // USESUFFIX(IPOIB_EXIT, " [IPoIB] :%!FUNC!():]");\r
96 // end_wpp\r
97 \r
98 #else\r
99 \r
100 #include <evntrace.h>\r
101 \r
102 \r
103 /*\r
104  * Debug macros\r
105  */\r
106 #define IPOIB_DBG_ERR   (1 << 0)\r
107 #define IPOIB_DBG_INIT  (1 << 1)\r
108 #define IPOIB_DBG_PNP   (1 << 2)\r
109 #define IPOIB_DBG_SEND  (1 << 3)\r
110 #define IPOIB_DBG_RECV  (1 << 4)\r
111 #define IPOIB_DBG_ENDPT (1 << 5)\r
112 #define IPOIB_DBG_IB    (1 << 6)\r
113 #define IPOIB_DBG_BUF   (1 << 7)\r
114 #define IPOIB_DBG_MCAST (1 << 8)\r
115 #define IPOIB_DBG_ALLOC (1 << 9)\r
116 #define IPOIB_DBG_OID   (1 << 10)\r
117 #define IPOIB_DBG_IOCTL (1 << 11)\r
118 #define IPOIB_DBG_STAT  (1 << 12)\r
119 #define IPOIB_DBG_OBJ   (1 << 13)\r
120 \r
121 #define IPOIB_DBG_ERROR (CL_DBG_ERROR | IPOIB_DBG_ERR)\r
122 #define IPOIB_DBG_ALL   CL_DBG_ALL\r
123 \r
124 \r
125 #if DBG\r
126 \r
127 // assignment of _level_ is need to to overcome warning C4127\r
128 #define IPOIB_PRINT(_level_,_flag_,_msg_) \\r
129         { \\r
130                 __pragma(warning(suppress:6326)) \\r
131                 if( g_ipoib_dbg_level >= (_level_) ) \\r
132                         CL_TRACE( _flag_, g_ipoib_dbg_flags, _msg_ ); \\r
133         }\r
134 \r
135 #define IPOIB_PRINT_EXIT(_level_,_flag_,_msg_) \\r
136         { \\r
137                 __pragma(warning(suppress:6326)) \\r
138                 if( g_ipoib_dbg_level >= (_level_) ) \\r
139                         CL_TRACE( _flag_, g_ipoib_dbg_flags, _msg_ );\\r
140                 IPOIB_EXIT(_flag_);\\r
141         }\r
142 \r
143 #define IPOIB_ENTER(_flag_) \\r
144         { \\r
145                 __pragma(warning(suppress:6326)) \\r
146                 if( g_ipoib_dbg_level >= TRACE_LEVEL_VERBOSE ) \\r
147                         CL_ENTER( _flag_, g_ipoib_dbg_flags ); \\r
148         }\r
149 \r
150 #define IPOIB_EXIT(_flag_)\\r
151         { \\r
152                 __pragma(warning(suppress:6326)) \\r
153                 if( g_ipoib_dbg_level >= TRACE_LEVEL_VERBOSE ) \\r
154                         CL_EXIT( _flag_, g_ipoib_dbg_flags ); \\r
155         }\r
156 \r
157 #define IPOIB_TRACE_BYTES( lvl, ptr, len )                                                                      \\r
158         {                                                                                                                                               \\r
159                 __pragma(warning(suppress:6326))                                                                        \\r
160                 if( g_ipoib_dbg_level >= (_level_) &&                                                           \\r
161                         (g_ipoib_dbg_flags & (_flag_)) )                                                                \\r
162                 {                                                                                                                                       \\r
163                         size_t _loop_;                                                                                                  \\r
164                         for( _loop_ = 0; _loop_ < (len); ++_loop_ )                                             \\r
165                         {                                                                                                                               \\r
166                                 cl_dbg_out( "0x%.2X ", ((uint8_t*)(ptr))[_loop_] );                     \\r
167                                 if( (_loop_ + 1)% 16 == 0 )                                                                     \\r
168                                         cl_dbg_out("\n");                                                                                       \\r
169                                 else if( (_loop_ % 4 + 1) == 0 )                                                        \\r
170                                         cl_dbg_out("  ");                                                                                       \\r
171                         }                                                                                                                               \\r
172                         cl_dbg_out("\n");                                                                                                       \\r
173                 }                                                                                                                                       \\r
174         }\r
175 \r
176 #else\r
177 \r
178 #define IPOIB_PRINT(lvl, flags, msg)\r
179 \r
180 #define IPOIB_PRINT_EXIT(_level_,_flag_,_msg_)\r
181 \r
182 #define IPOIB_ENTER(_flag_)\r
183 \r
184 #define IPOIB_EXIT(_flag_)\r
185 \r
186 #define IPOIB_TRACE_BYTES( lvl, ptr, len )\r
187 \r
188 #endif\r
189 \r
190 #endif //EVENT_TRACING\r
191 \r
192 \r
193 enum ipoib_perf_counters\r
194 {\r
195         SendBundle,\r
196         SendPackets,\r
197                 PortSend,\r
198                         GetEthHdr,\r
199                         SendMgrQueue,\r
200                                 GetEndpt,\r
201                                         EndptQueue,\r
202                         QueuePacket,\r
203                         BuildSendDesc,\r
204                                 SendMgrFilter,\r
205                                         FilterIp,\r
206                                                 QueryIp,\r
207                                                 SendTcp,\r
208                                                 FilterUdp,\r
209                                                         QueryUdp,\r
210                                                         SendUdp,\r
211                                                         FilterDhcp,\r
212                                         FilterArp,\r
213                                         SendGen,\r
214                                                 SendCopy,\r
215                         PostSend,\r
216                         ProcessFailedSends,\r
217         SendCompBundle,\r
218         SendCb,\r
219                 PollSend,\r
220                 SendComp,\r
221                 FreeSendBuf,\r
222                 RearmSend,\r
223                 PortResume,\r
224         RecvCompBundle,\r
225         RecvCb,\r
226                 PollRecv,\r
227                 FilterRecv,\r
228                         GetRecvEndpts,\r
229                                 GetEndptByGid,\r
230                                 GetEndptByLid,\r
231                                 EndptInsert,\r
232                         RecvTcp,\r
233                         RecvUdp,\r
234                         RecvDhcp,\r
235                         RecvArp,\r
236                         RecvGen,\r
237         BuildPktArray,\r
238                 PreparePkt,\r
239                         GetNdisPkt,\r
240         RecvNdisIndicate,\r
241         PutRecvList,\r
242         RepostRecv,\r
243                 GetRecv,\r
244                 PostRecv,\r
245         RearmRecv,\r
246                 ReturnPacket,\r
247                 ReturnPutRecv,\r
248                 ReturnRepostRecv,\r
249                 ReturnPreparePkt,\r
250                 ReturnNdisIndicate,\r
251 \r
252         /* Must be last! */\r
253         MaxPerf\r
254 \r
255 };\r
256 \r
257 \r
258 enum ref_cnt_buckets\r
259 {\r
260         ref_init = 0,\r
261         ref_refresh_mcast,      /* only used in refresh_mcast */\r
262         ref_send_packets,       /* only in send_packets */\r
263         ref_get_recv,\r
264         ref_repost,             /* only in __recv_mgr_repost */\r
265         ref_recv_cb,    /* only in __recv_cb */\r
266         ref_send_cb,    /* only in __send_cb */\r
267         ref_port_up,\r
268         ref_get_bcast,\r
269         ref_bcast,              /* join and create, used as base only */\r
270         ref_join_mcast,\r
271         ref_leave_mcast,\r
272         ref_endpt_track,        /* used when endpt is in port's child list. */\r
273 \r
274         ref_array_size, /* Used to size the array of ref buckets. */\r
275         ref_mask = 100, /* Used to differentiate derefs. */\r
276 \r
277         ref_failed_recv_wc = 100 + ref_get_recv,\r
278         ref_recv_inv_len = 200 + ref_get_recv,\r
279         ref_recv_loopback = 300 + ref_get_recv,\r
280         ref_recv_filter = 400 + ref_get_recv,\r
281 \r
282         ref_bcast_get_cb = 100 + ref_get_bcast,\r
283 \r
284         ref_join_bcast = 100 + ref_bcast,\r
285         ref_create_bcast = 200 + ref_bcast,\r
286         ref_bcast_inv_state = 300 + ref_bcast,\r
287         ref_bcast_req_failed = 400 + ref_bcast,\r
288         ref_bcast_error = 500 + ref_bcast,\r
289         ref_bcast_join_failed = 600 + ref_bcast,\r
290         ref_bcast_create_failed = 700 + ref_bcast,\r
291 \r
292         ref_mcast_inv_state = 100 + ref_join_mcast,\r
293         ref_mcast_req_failed = 200 + ref_join_mcast,\r
294         ref_mcast_no_endpt = 300 + ref_join_mcast,\r
295         ref_mcast_av_failed = 400 + ref_join_mcast,\r
296         ref_mcast_join_failed = 500 + ref_join_mcast,\r
297 \r
298         ref_port_info_cb = 100 + ref_port_up\r
299 \r
300 };\r
301 \r
302 \r
303 #endif  /* _IPOIB_DEBUG_H_ */\r