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 switch (_level_) { \
\r
56 case TRACE_LEVEL_FATAL: case TRACE_LEVEL_ERROR: event_id = EVENT_MTHCA_ANY_ERROR; break; \
\r
57 case TRACE_LEVEL_WARNING: event_id = EVENT_MTHCA_ANY_WARN; break; \
\r
58 default: event_id = EVENT_MTHCA_ANY_INFO; break; \
\r
61 WriteEventLogEntryStr( _obj_, (ULONG)event_id, 0, 0, g_wlog_buf, 0, 0 ); \
\r
64 #define HCA_PRINT_EV_MDEV(_level_,_flag_,_msg_) \
\r
65 HCA_PRINT_TO_EVENT_LOG(mdev->ext->cl_ext.p_self_do,_level_,_flag_,_msg_)
\r
68 #if defined(EVENT_TRACING)
\r
70 // Software Tracing Definitions
\r
73 #define WPP_CONTROL_GUIDS \
\r
74 WPP_DEFINE_CONTROL_GUID(HCACtlGuid,(8BF1F640,63FE,4743,B9EF,FA38C695BFDE), \
\r
75 WPP_DEFINE_BIT( HCA_DBG_DEV) \
\r
76 WPP_DEFINE_BIT( HCA_DBG_PNP) \
\r
77 WPP_DEFINE_BIT( HCA_DBG_INIT) \
\r
78 WPP_DEFINE_BIT( HCA_DBG_MAD) \
\r
79 WPP_DEFINE_BIT( HCA_DBG_PO) \
\r
80 WPP_DEFINE_BIT( HCA_DBG_CQ) \
\r
81 WPP_DEFINE_BIT( HCA_DBG_QP) \
\r
82 WPP_DEFINE_BIT( HCA_DBG_MEMORY) \
\r
83 WPP_DEFINE_BIT( HCA_DBG_AV) \
\r
84 WPP_DEFINE_BIT( HCA_DBG_SRQ) \
\r
85 WPP_DEFINE_BIT( HCA_DBG_LOW) \
\r
86 WPP_DEFINE_BIT( HCA_DBG_SHIM))
\r
88 #define WPP_GLOBALLOGGER
\r
91 #define WPP_LEVEL_FLAGS_ENABLED(lvl, flags) (WPP_LEVEL_ENABLED(flags) && WPP_CONTROL(WPP_BIT_ ## flags).Level >= lvl)
\r
92 #define WPP_LEVEL_FLAGS_LOGGER(lvl,flags) WPP_LEVEL_LOGGER(flags)
\r
93 #define WPP_FLAG_ENABLED(flags)(WPP_LEVEL_ENABLED(flags) && WPP_CONTROL(WPP_BIT_ ## flags).Level >= TRACE_LEVEL_VERBOSE)
\r
94 #define WPP_FLAG_LOGGER(flags) WPP_LEVEL_LOGGER(flags)
\r
100 // USEPREFIX(HCA_PRINT, "%!STDPREFIX! [MTHCA] :%!FUNC!() :");
\r
101 // USESUFFIX(HCA_ENTER, " [MTHCA] :%!FUNC!()[");
\r
102 // USESUFFIX(HCA_EXIT, " [MTHCA] :%!FUNC!()]");
\r
103 // USEPREFIX(HCA_PRINT_EXIT, "%!STDPREFIX! [MTHCA] :%!FUNC!() :");
\r
104 // USESUFFIX(HCA_PRINT_EXIT, "[MTHCA] :%!FUNC!():]");
\r
108 #define HCA_PRINT_EV(_level_,_flag_,_msg_) \
\r
110 HCA_PRINT_EV_MDEV(_level_,_flag_,_msg_) \
\r
117 #include <evntrace.h>
\r
124 #define HCA_DBG_DEV (1 << 0)
\r
125 #define HCA_DBG_PNP (1<<1)
\r
126 #define HCA_DBG_INIT (1 << 2)
\r
127 #define HCA_DBG_MAD (1 << 3)
\r
128 #define HCA_DBG_PO (1 << 4)
\r
129 #define HCA_DBG_QP (1 << 5)
\r
130 #define HCA_DBG_CQ (1 << 6)
\r
131 #define HCA_DBG_MEMORY (1 << 7)
\r
132 #define HCA_DBG_AV (1<<8)
\r
133 #define HCA_DBG_SRQ (1 << 9)
\r
134 #define HCA_DBG_LOW (1 << 10)
\r
135 #define HCA_DBG_SHIM (1 << 11)
\r
140 // assignment of _level_ is need to to overcome warning C4127
\r
141 #define HCA_PRINT(_level_,_flag_,_msg_) \
\r
143 int __lvl = _level_; \
\r
144 if (g_mthca_dbg_level >= (_level_) && \
\r
145 (g_mthca_dbg_flags & (_flag_))) { \
\r
146 DbgPrint ("[MTHCA] %s() :", __FUNCTION__); \
\r
147 if(__lvl == TRACE_LEVEL_ERROR) DbgPrint ("***ERROR*** "); \
\r
154 #define HCA_PRINT(lvl ,flags, msg)
\r
158 #define HCA_PRINT_EV(_level_,_flag_,_msg_) \
\r
160 HCA_PRINT(_level_,_flag_,_msg_) \
\r
161 HCA_PRINT_EV_MDEV(_level_,_flag_,_msg_) \
\r
164 #define HCA_ENTER(flags)\
\r
165 HCA_PRINT(TRACE_LEVEL_VERBOSE, flags,("[\n"));
\r
167 #define HCA_EXIT(flags)\
\r
168 HCA_PRINT(TRACE_LEVEL_VERBOSE, flags, ("]\n" ));
\r
171 #define HCA_PRINT_EXIT(_level_,_flag_,_msg_) \
\r
173 if (status != IB_SUCCESS) {\
\r
174 HCA_PRINT(_level_,_flag_,_msg_);\
\r
179 #endif //EVENT_TRACING
\r
182 #endif /*_HCA_DEBUG_H_ */
\r