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
29 * $Id: hca_debug.h 46 2005-05-30 17:55:53Z sleybo $
\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
44 #if defined(EVENT_TRACING)
\r
46 // Software Tracing Definitions
\r
49 #define WPP_CONTROL_GUIDS \
\r
50 WPP_DEFINE_CONTROL_GUID(HCACtlGuid,(8BF1F640,63FE,4743,B9EF,FA38C695BFDE), \
\r
51 WPP_DEFINE_BIT( HCA_DBG_DEV) \
\r
52 WPP_DEFINE_BIT( HCA_DBG_INIT) \
\r
53 WPP_DEFINE_BIT( HCA_DBG_PNP) \
\r
54 WPP_DEFINE_BIT( HCA_DBG_MAD) \
\r
55 WPP_DEFINE_BIT( HCA_DBG_PO) \
\r
56 WPP_DEFINE_BIT( HCA_DBG_CQ) \
\r
57 WPP_DEFINE_BIT( HCA_DBG_QP) \
\r
58 WPP_DEFINE_BIT( HCA_DBG_MEMORY) \
\r
59 WPP_DEFINE_BIT( HCA_DBG_AV) \
\r
60 WPP_DEFINE_BIT( HCA_DBG_LOW) \
\r
61 WPP_DEFINE_BIT( HCA_DBG_SHIM))
\r
63 #define WPP_GLOBALLOGGER
\r
66 #define WPP_LEVEL_FLAGS_ENABLED(lvl, flags) (WPP_LEVEL_ENABLED(flags) && WPP_CONTROL(WPP_BIT_ ## flags).Level >= lvl)
\r
67 #define WPP_LEVEL_FLAGS_LOGGER(lvl,flags) WPP_LEVEL_LOGGER(flags)
\r
68 #define WPP_FLAG_ENABLED(flags)(WPP_LEVEL_ENABLED(flags) && WPP_CONTROL(WPP_BIT_ ## flags).Level >= TRACE_LEVEL_VERBOSE)
\r
69 #define WPP_FLAG_LOGGER(flags) WPP_LEVEL_LOGGER(flags)
\r
75 // USEPREFIX(HCA_PRINT, "%!STDPREFIX! %!FUNC!() :");
\r
76 // USESUFFIX(HCA_ENTER, " %!FUNC!()===>");
\r
77 // USESUFFIX(HCA_EXIT, " %!FUNC!()<===");
\r
85 #include <evntrace.h>
\r
92 #define HCA_DBG_DEV (1 << 0)
\r
93 #define HCA_DBG_INIT (1<<1)
\r
94 #define HCA_DBG_PNP (1 << 2)
\r
95 #define HCA_DBG_MAD (1 << 3)
\r
96 #define HCA_DBG_PO (1 << 4)
\r
97 #define HCA_DBG_QP (1 << 5)
\r
98 #define HCA_DBG_CQ (1 << 6)
\r
99 #define HCA_DBG_MEMORY (1 << 7)
\r
100 #define HCA_DBG_AV (1<<8)
\r
101 #define HCA_DBG_LOW (1 << 9)
\r
102 #define HCA_DBG_SHIM (1 << 10)
\r
104 static void _build_str( const char * format, ... )
\r
107 va_start(p_arg, format);
\r
108 vsprintf((char *)g_slog_buf , format , p_arg);
\r
109 swprintf(g_wlog_buf, L"%S", g_slog_buf);
\r
113 #define HCA_PRINT_TO_EVENT_LOG(_obj_,_level_,_flag_,_msg_) \
\r
115 NTSTATUS event_id; \
\r
116 switch (_level_) { \
\r
117 case TRACE_LEVEL_FATAL: case TRACE_LEVEL_ERROR: event_id = EVENT_MTHCA_ANY_ERROR; break; \
\r
118 case TRACE_LEVEL_WARNING: event_id = EVENT_MTHCA_ANY_WARN; break; \
\r
119 default: event_id = EVENT_MTHCA_ANY_INFO; break; \
\r
121 _build_str _msg_; \
\r
122 WriteEventLogEntryStr( _obj_, (ULONG)event_id, 0, 0, g_wlog_buf, 0, 0 ); \
\r
125 #define HCA_PRINT_EV_MDEV(_level_,_flag_,_msg_) \
\r
126 HCA_PRINT_TO_EVENT_LOG(mdev->ext->cl_ext.p_self_do,_level_,_flag_,_msg_)
\r
131 // assignment of _level_ is need to to overcome warning C4127
\r
132 #define HCA_PRINT(_level_,_flag_,_msg_) \
\r
134 int __lvl = _level_; \
\r
135 if (g_mthca_dbg_level >= (_level_) && \
\r
136 (g_mthca_dbg_flags & (_flag_))) { \
\r
137 DbgPrint ("[MTHCA] %s() :", __FUNCTION__); \
\r
138 if(__lvl == TRACE_LEVEL_ERROR) DbgPrint ("***ERROR*** "); \
\r
145 #define HCA_PRINT(lvl ,flags, msg)
\r
149 #define HCA_PRINT_EV(_level_,_flag_,_msg_) \
\r
151 HCA_PRINT(_level_,_flag_,_msg_) \
\r
152 HCA_PRINT_EV_MDEV(_level_,_flag_,_msg_) \
\r
155 #define HCA_ENTER(flags)\
\r
156 HCA_PRINT(TRACE_LEVEL_VERBOSE, flags,("===>\n"));
\r
158 #define HCA_EXIT(flags)\
\r
159 HCA_PRINT(TRACE_LEVEL_VERBOSE, flags, ("<===\n" ));
\r
162 #define HCA_PRINT_EXIT(_level_,_flag_,_msg_) \
\r
164 if (status != IB_SUCCESS) {\
\r
165 HCA_PRINT(_level_,_flag_,_msg_);\
\r
170 #endif //EVENT_TRACING
\r
175 #endif /*_HCA_DEBUG_H_ */
\r