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
33 #ifndef _HCA_DEBUG_H_
\r
34 #define _HCA_DEBUG_H_
\r
37 extern uint32_t g_mthca_dbg_level;
\r
38 extern uint32_t g_mthca_dbg_flags;
\r
39 #define MAX_LOG_BUF_LEN 512
\r
40 extern WCHAR g_wlog_buf[ MAX_LOG_BUF_LEN ];
\r
41 extern UCHAR g_slog_buf[ MAX_LOG_BUF_LEN ];
\r
43 static void _build_str( const char * format, ... )
\r
46 va_start(p_arg, format);
\r
47 vsprintf((char *)g_slog_buf , format , p_arg);
\r
48 swprintf(g_wlog_buf, L"%S", g_slog_buf);
\r
52 #define HCA_PRINT_TO_EVENT_LOG(_obj_,_level_,_flag_,_msg_) \
\r
54 NTSTATUS event_id; \
\r
55 __pragma(warning(suppress:6326)) \
\r
56 switch (_level_) { \
\r
57 case TRACE_LEVEL_FATAL: case TRACE_LEVEL_ERROR: event_id = EVENT_MTHCA_ANY_ERROR; break; \
\r
58 case TRACE_LEVEL_WARNING: event_id = EVENT_MTHCA_ANY_WARN; break; \
\r
59 default: event_id = EVENT_MTHCA_ANY_INFO; break; \
\r
62 WriteEventLogEntryStr( _obj_, (ULONG)event_id, 0, 0, g_wlog_buf, 0, 0 ); \
\r
65 #define HCA_PRINT_EV_MDEV(_level_,_flag_,_msg_) \
\r
68 HCA_PRINT_TO_EVENT_LOG(mdev->ext->cl_ext.p_self_do,_level_,_flag_,_msg_)\
\r
73 #if defined(EVENT_TRACING)
\r
75 // Software Tracing Definitions
\r
78 #define WPP_CONTROL_GUIDS \
\r
79 WPP_DEFINE_CONTROL_GUID(HCACtlGuid,(8BF1F640,63FE,4743,B9EF,FA38C695BFDE), \
\r
80 WPP_DEFINE_BIT( HCA_DBG_DEV) \
\r
81 WPP_DEFINE_BIT( HCA_DBG_PNP) \
\r
82 WPP_DEFINE_BIT( HCA_DBG_INIT) \
\r
83 WPP_DEFINE_BIT( HCA_DBG_MAD) \
\r
84 WPP_DEFINE_BIT( HCA_DBG_PO) \
\r
85 WPP_DEFINE_BIT( HCA_DBG_PD)\
\r
86 WPP_DEFINE_BIT( HCA_DBG_CQ) \
\r
87 WPP_DEFINE_BIT( HCA_DBG_QP) \
\r
88 WPP_DEFINE_BIT( HCA_DBG_MEMORY) \
\r
89 WPP_DEFINE_BIT( HCA_DBG_AV) \
\r
90 WPP_DEFINE_BIT( HCA_DBG_SRQ) \
\r
91 WPP_DEFINE_BIT( HCA_DBG_MCAST) \
\r
92 WPP_DEFINE_BIT( HCA_DBG_LOW) \
\r
93 WPP_DEFINE_BIT( HCA_DBG_SHIM))
\r
96 #define WPP_GLOBALLOGGER
\r
99 #define WPP_LEVEL_FLAGS_ENABLED(lvl, flags) (WPP_LEVEL_ENABLED(flags) && WPP_CONTROL(WPP_BIT_ ## flags).Level >= lvl)
\r
100 #define WPP_LEVEL_FLAGS_LOGGER(lvl,flags) WPP_LEVEL_LOGGER(flags)
\r
101 #define WPP_FLAG_ENABLED(flags)(WPP_LEVEL_ENABLED(flags) && WPP_CONTROL(WPP_BIT_ ## flags).Level >= TRACE_LEVEL_VERBOSE)
\r
102 #define WPP_FLAG_LOGGER(flags) WPP_LEVEL_LOGGER(flags)
\r
105 // begin_wpp config
\r
106 // HCA_ENTER(FLAG);
\r
108 // USEPREFIX(HCA_PRINT, "%!STDPREFIX! [MTHCA] :%!FUNC!() :");
\r
109 // USESUFFIX(HCA_ENTER, " [MTHCA] :%!FUNC!()[");
\r
110 // USESUFFIX(HCA_EXIT, " [MTHCA] :%!FUNC!()]");
\r
115 #define HCA_PRINT_EV(_level_,_flag_,_msg_) \
\r
117 HCA_PRINT_EV_MDEV(_level_,_flag_,_msg_) \
\r
124 #include <evntrace.h>
\r
131 #define HCA_DBG_DEV (1 << 0)
\r
132 #define HCA_DBG_PNP (1<<1)
\r
133 #define HCA_DBG_INIT (1 << 2)
\r
134 #define HCA_DBG_MAD (1 << 3)
\r
135 #define HCA_DBG_PO (1 << 4)
\r
136 #define HCA_DBG_PD (1<<5)
\r
137 #define HCA_DBG_QP (1 << 6)
\r
138 #define HCA_DBG_CQ (1 << 7)
\r
139 #define HCA_DBG_MEMORY (1 << 8)
\r
140 #define HCA_DBG_AV (1<<9)
\r
141 #define HCA_DBG_SRQ (1 << 10)
\r
142 #define HCA_DBG_MCAST (1<<11)
\r
143 #define HCA_DBG_LOW (1 << 12)
\r
144 #define HCA_DBG_SHIM (1 << 13)
\r
149 // assignment of _level_ is need to to overcome warning C4127
\r
150 #define HCA_PRINT(_level_,_flag_,_msg_) \
\r
152 int __lvl = _level_; \
\r
153 if (g_mthca_dbg_level >= (_level_) && \
\r
154 (g_mthca_dbg_flags & (_flag_))) { \
\r
155 cl_dbg_out ("~%d:[MTHCA] %s() :", KeGetCurrentProcessorNumber(), __FUNCTION__); \
\r
156 if(__lvl == TRACE_LEVEL_ERROR) cl_dbg_out ("***ERROR*** "); \
\r
157 cl_dbg_out _msg_; \
\r
163 #define HCA_PRINT(lvl ,flags, msg)
\r
167 #define HCA_PRINT_EV(_level_,_flag_,_msg_) \
\r
169 HCA_PRINT(_level_,_flag_,_msg_) \
\r
170 HCA_PRINT_EV_MDEV(_level_,_flag_,_msg_) \
\r
173 #define HCA_ENTER(flags)\
\r
174 HCA_PRINT(TRACE_LEVEL_VERBOSE, flags,("[\n"));
\r
176 #define HCA_EXIT(flags)\
\r
177 HCA_PRINT(TRACE_LEVEL_VERBOSE, flags, ("]\n" ));
\r
180 #endif //EVENT_TRACING
\r
183 #endif /*_HCA_DEBUG_H_ */
\r