[IPoIB] fix ref counter indexes enumeration.
[mirror/winof/.git] / ulp / ipoib / kernel / 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$\r
31  */\r
32 \r
33 \r
34 #ifndef _IPOIB_DEBUG_H_\r
35 #define _IPOIB_DEBUG_H_\r
36 \r
37 \r
38 #define __MODULE__      "[IPoIB]"\r
39 \r
40 #include <complib/cl_debug.h>\r
41 \r
42 \r
43 /* Object types for passing into complib. */\r
44 #define IPOIB_OBJ_INSTANCE              1\r
45 #define IPOIB_OBJ_PORT                  2\r
46 #define IPOIB_OBJ_ENDPOINT              3\r
47 \r
48 \r
49 extern uint32_t         g_ipoib_dbg_level;\r
50 extern uint32_t         g_ipoib_dbg_flags;\r
51 \r
52 \r
53 #if defined(EVENT_TRACING)\r
54 //\r
55 // Software Tracing Definitions\r
56 //\r
57 #define WPP_CONTROL_GUIDS \\r
58         WPP_DEFINE_CONTROL_GUID( \\r
59                 IPOIBCtlGuid,(3F9BC73D, EB03, 453a, B27B, 20F9A664211A), \\r
60         WPP_DEFINE_BIT(IPOIB_DBG_ERROR) \\r
61         WPP_DEFINE_BIT(IPOIB_DBG_INIT) \\r
62         WPP_DEFINE_BIT(IPOIB_DBG_PNP) \\r
63         WPP_DEFINE_BIT(IPOIB_DBG_SEND) \\r
64         WPP_DEFINE_BIT(IPOIB_DBG_RECV) \\r
65         WPP_DEFINE_BIT(IPOIB_DBG_ENDPT) \\r
66         WPP_DEFINE_BIT(IPOIB_DBG_IB) \\r
67         WPP_DEFINE_BIT(IPOIB_DBG_BUF) \\r
68         WPP_DEFINE_BIT(IPOIB_DBG_MCAST) \\r
69         WPP_DEFINE_BIT(IPOIB_DBG_ALLOC) \\r
70         WPP_DEFINE_BIT(IPOIB_DBG_OID) \\r
71         WPP_DEFINE_BIT(IPOIB_DBG_IOCTL) \\r
72         WPP_DEFINE_BIT(IPOIB_DBG_STAT) \\r
73         WPP_DEFINE_BIT(IPOIB_DBG_OBJ))\r
74 \r
75 \r
76 \r
77 #define WPP_LEVEL_FLAGS_ENABLED(lvl, flags) \\r
78         (WPP_LEVEL_ENABLED(flags) && WPP_CONTROL(WPP_BIT_ ## flags).Level  >= lvl)\r
79 #define WPP_LEVEL_FLAGS_LOGGER(lvl,flags) WPP_LEVEL_LOGGER(flags)\r
80 #define WPP_FLAG_ENABLED(flags) \\r
81         (WPP_LEVEL_ENABLED(flags) && \\r
82         WPP_CONTROL(WPP_BIT_ ## flags).Level  >= TRACE_LEVEL_VERBOSE)\r
83 #define WPP_FLAG_LOGGER(flags) WPP_LEVEL_LOGGER(flags)\r
84 \r
85 // begin_wpp config\r
86 // IPOIB_ENTER(FLAG);\r
87 // IPOIB_EXIT(FLAG);\r
88 // USEPREFIX(IPOIB_PRINT, "%!STDPREFIX! [IPoIB] :%!FUNC!() :");\r
89 // USEPREFIX(IPOIB_PRINT_EXIT, "%!STDPREFIX! [IPoIB] :%!FUNC!() :");\r
90 // USESUFFIX(IPOIB_PRINT_EXIT, "[IpoIB] :%!FUNC!():]");\r
91 // USESUFFIX(IPOIB_ENTER, " [IPoIB] :%!FUNC!():[");\r
92 // USESUFFIX(IPOIB_EXIT, " [IPoIB] :%!FUNC!():]");\r
93 // end_wpp\r
94 \r
95 #else\r
96 \r
97 #include <evntrace.h>\r
98 \r
99 \r
100 /*\r
101  * Debug macros\r
102  */\r
103 #define IPOIB_DBG_ERR   (1 << 0)\r
104 #define IPOIB_DBG_INIT  (1 << 1)\r
105 #define IPOIB_DBG_PNP   (1 << 2)\r
106 #define IPOIB_DBG_SEND  (1 << 3)\r
107 #define IPOIB_DBG_RECV  (1 << 4)\r
108 #define IPOIB_DBG_ENDPT (1 << 5)\r
109 #define IPOIB_DBG_IB    (1 << 6)\r
110 #define IPOIB_DBG_BUF   (1 << 7)\r
111 #define IPOIB_DBG_MCAST (1 << 8)\r
112 #define IPOIB_DBG_ALLOC (1 << 9)\r
113 #define IPOIB_DBG_OID   (1 << 10)\r
114 #define IPOIB_DBG_IOCTL (1 << 11)\r
115 #define IPOIB_DBG_STAT  (1 << 12)\r
116 #define IPOIB_DBG_OBJ   (1 << 13)\r
117 \r
118 #define IPOIB_DBG_ERROR (CL_DBG_ERROR | IPOIB_DBG_ERR)\r
119 #define IPOIB_DBG_ALL   CL_DBG_ALL\r
120 \r
121 \r
122 #if DBG\r
123 \r
124 // assignment of _level_ is need to to overcome warning C4127\r
125 #define IPOIB_PRINT(_level_,_flag_,_msg_) \\r
126         { \\r
127                 __pragma(warning(suppress:6326)) \\r
128                 if( g_ipoib_dbg_level >= (_level_) ) \\r
129                         CL_TRACE( _flag_, g_ipoib_dbg_flags, _msg_ ); \\r
130         }\r
131 \r
132 #define IPOIB_PRINT_EXIT(_level_,_flag_,_msg_) \\r
133         { \\r
134                 __pragma(warning(suppress:6326)) \\r
135                 if( g_ipoib_dbg_level >= (_level_) ) \\r
136                         CL_TRACE( _flag_, g_ipoib_dbg_flags, _msg_ );\\r
137                 IPOIB_EXIT(_flag_);\\r
138         }\r
139 \r
140 #define IPOIB_ENTER(_flag_) \\r
141         { \\r
142                 __pragma(warning(suppress:6326)) \\r
143                 if( g_ipoib_dbg_level >= TRACE_LEVEL_VERBOSE ) \\r
144                         CL_ENTER( _flag_, g_ipoib_dbg_flags ); \\r
145         }\r
146 \r
147 #define IPOIB_EXIT(_flag_)\\r
148         { \\r
149                 __pragma(warning(suppress:6326)) \\r
150                 if( g_ipoib_dbg_level >= TRACE_LEVEL_VERBOSE ) \\r
151                         CL_EXIT( _flag_, g_ipoib_dbg_flags ); \\r
152         }\r
153 \r
154 #define IPOIB_TRACE_BYTES( lvl, ptr, len )                                                                      \\r
155         {                                                                                                                                               \\r
156                 __pragma(warning(suppress:6326))                                                                        \\r
157                 if( g_ipoib_dbg_level >= (_level_) &&                                                           \\r
158                         (g_ipoib_dbg_flags & (_flag_)) )                                                                \\r
159                 {                                                                                                                                       \\r
160                         size_t _loop_;                                                                                                  \\r
161                         for( _loop_ = 0; _loop_ < (len); ++_loop_ )                                             \\r
162                         {                                                                                                                               \\r
163                                 DbgPrint( "0x%.2X ", ((uint8_t*)(ptr))[_loop_] );                       \\r
164                                 if( (_loop_ + 1)% 16 == 0 )                                                                     \\r
165                                         DbgPrint("\n");                                                                                 \\r
166                                 else if( (_loop_ % 4 + 1) == 0 )                                                        \\r
167                                         DbgPrint("  ");                                                                                 \\r
168                         }                                                                                                                               \\r
169                         DbgPrint("\n");                                                                                                 \\r
170                 }                                                                                                                                       \\r
171         }\r
172 \r
173 #else\r
174 \r
175 #define IPOIB_PRINT(lvl, flags, msg)\r
176 \r
177 #define IPOIB_PRINT_EXIT(_level_,_flag_,_msg_)\r
178 \r
179 #define IPOIB_ENTER(_flag_)\r
180 \r
181 #define IPOIB_EXIT(_flag_)\r
182 \r
183 #define IPOIB_TRACE_BYTES( lvl, ptr, len )\r
184 \r
185 #endif\r
186 \r
187 #endif //EVENT_TRACING\r
188 \r
189 \r
190 enum ipoib_perf_counters\r
191 {\r
192         SendBundle,\r
193         SendPackets,\r
194                 PortSend,\r
195                         GetEthHdr,\r
196                         SendMgrQueue,\r
197                                 GetEndpt,\r
198                                         EndptQueue,\r
199                         QueuePacket,\r
200                         BuildSendDesc,\r
201                                 SendMgrFilter,\r
202                                         FilterIp,\r
203                                                 QueryIp,\r
204                                                 SendTcp,\r
205                                                 FilterUdp,\r
206                                                         QueryUdp,\r
207                                                         SendUdp,\r
208                                                         FilterDhcp,\r
209                                         FilterArp,\r
210                                         SendGen,\r
211                                                 SendCopy,\r
212                         PostSend,\r
213                         ProcessFailedSends,\r
214         SendCompBundle,\r
215         SendCb,\r
216                 PollSend,\r
217                 SendComp,\r
218                 FreeSendBuf,\r
219                 RearmSend,\r
220                 PortResume,\r
221         RecvCompBundle,\r
222         RecvCb,\r
223                 PollRecv,\r
224                 FilterRecv,\r
225                         GetRecvEndpts,\r
226                                 GetEndptByGid,\r
227                                 GetEndptByLid,\r
228                                 EndptInsert,\r
229                         RecvTcp,\r
230                         RecvUdp,\r
231                         RecvDhcp,\r
232                         RecvArp,\r
233                         RecvGen,\r
234         BuildPktArray,\r
235                 PreparePkt,\r
236                         GetNdisPkt,\r
237         RecvNdisIndicate,\r
238         PutRecvList,\r
239         RepostRecv,\r
240                 GetRecv,\r
241                 PostRecv,\r
242         RearmRecv,\r
243                 ReturnPacket,\r
244                 ReturnPutRecv,\r
245                 ReturnRepostRecv,\r
246                 ReturnPreparePkt,\r
247                 ReturnNdisIndicate,\r
248 \r
249         /* Must be last! */\r
250         MaxPerf\r
251 \r
252 };\r
253 \r
254 \r
255 enum ref_cnt_buckets\r
256 {\r
257         ref_init = 0,\r
258         ref_refresh_mcast,      /* only used in refresh_mcast */\r
259         ref_send_packets,       /* only in send_packets */\r
260         ref_get_recv,\r
261         ref_repost,             /* only in __recv_mgr_repost */\r
262         ref_recv_cb,    /* only in __recv_cb */\r
263         ref_send_cb,    /* only in __send_cb */\r
264         ref_port_up,\r
265         ref_get_bcast,\r
266         ref_bcast,              /* join and create, used as base only */\r
267         ref_join_mcast,\r
268         ref_leave_mcast,\r
269         ref_endpt_track,        /* used when endpt is in port's child list. */\r
270 \r
271         ref_array_size, /* Used to size the array of ref buckets. */\r
272         ref_mask = 100, /* Used to differentiate derefs. */\r
273 \r
274         ref_failed_recv_wc = 100 + ref_get_recv,\r
275         ref_recv_inv_len = 200 + ref_get_recv,\r
276         ref_recv_loopback = 300 + ref_get_recv,\r
277         ref_recv_filter = 400 + ref_get_recv,\r
278 \r
279         ref_bcast_get_cb = 100 + ref_get_bcast,\r
280 \r
281         ref_join_bcast = 100 + ref_bcast,\r
282         ref_create_bcast = 200 + ref_bcast,\r
283         ref_bcast_inv_state = 300 + ref_bcast,\r
284         ref_bcast_req_failed = 400 + ref_bcast,\r
285         ref_bcast_error = 500 + ref_bcast,\r
286         ref_bcast_join_failed = 600 + ref_bcast,\r
287         ref_bcast_create_failed = 700 + ref_bcast,\r
288 \r
289         ref_mcast_inv_state = 100 + ref_join_mcast,\r
290         ref_mcast_req_failed = 200 + ref_join_mcast,\r
291         ref_mcast_no_endpt = 300 + ref_join_mcast,\r
292         ref_mcast_av_failed = 400 + ref_join_mcast,\r
293         ref_mcast_join_failed = 500 + ref_join_mcast,\r
294 \r
295         ref_port_info_cb = 100 + ref_port_up\r
296 \r
297 };\r
298 \r
299 \r
300 #endif  /* _IPOIB_DEBUG_H_ */\r