2 * Copyright(c) 2002-2011 Exar Corp.
5 * Redistribution and use in source and binary forms, with or without
6 * modification are permitted provided the following conditions are met:
8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of the Exar Corporation nor the names of its
16 * contributors may be used to endorse or promote products derived from
17 * this software without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
23 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
33 #ifndef VXGE_OS_DEBUG_H
34 #define VXGE_OS_DEBUG_H
38 #ifndef VXGE_DEBUG_INLINE_FUNCTIONS
40 #if defined(VXGE_TRACE_INTO_CIRCULAR_ARR)
41 #define vxge_trace_aux(hldev, vpid, fmt, ...) \
42 vxge_os_vasprintf(hldev, vpid, fmt, __VA_ARGS__)
44 #define vxge_trace_aux(hldev, vpid, fmt, ...) \
45 vxge_os_vaprintf(hldev, vpid, fmt, __VA_ARGS__)
48 #define vxge_debug(module, level, hldev, vpid, fmt, ...) \
51 ((vxge_hal_device_t *)hldev)->debug_level) && \
53 ((vxge_hal_device_t *)hldev)->debug_module_mask)) \
54 vxge_trace_aux((vxge_hal_device_h)hldev, \
55 vpid, fmt, __VA_ARGS__); \
60 * @level: level of debug verbosity.
63 * @fmt: printf like format string
65 * Provides logging facilities for OS Dependent functions. Can be customized
66 * with debug levels. Input parameters, except level, are the same
67 * as posix printf. This function may be compiled out if DEBUG macro
69 * See also: vxge_debug_level_e{}.
71 #if (VXGE_COMPONENT_HAL_DRIVER & VXGE_DEBUG_MODULE_MASK)
72 #define vxge_debug_driver(level, hldev, vpid, fmt, ...) \
73 if ((u32)level <= g_debug_level) \
74 vxge_os_vaprintf((vxge_hal_device_h)hldev, \
75 vpid, fmt, __VA_ARGS__);
77 #define vxge_debug_driver(level, hldev, vpid, fmt, ...)
82 * @level: level of debug verbosity.
85 * @fmt: printf like format string
87 * Provides logging facilities for OS Dependent functions. Can be customized
88 * with debug levels. Input parameters, except level, are the same
89 * as posix printf. This function may be compiled out if DEBUG macro
91 * See also: vxge_debug_level_e{}.
93 #if (VXGE_COMPONENT_OSDEP & VXGE_DEBUG_MODULE_MASK)
94 #define vxge_debug_osdep(level, hldev, vpid, fmt, ...) \
95 vxge_debug(VXGE_COMPONENT_OSDEP, level, hldev, vpid, fmt, __VA_ARGS__)
97 #define vxge_debug_osdep(level, hldev, vpid, fmt, ...)
102 * @level: level of debug verbosity.
105 * @fmt: printf like format string
107 * Provides logging facilities for LL driver. Can be customized
108 * with debug levels. Input parameters, except level, are the same
109 * as posix printf. This function may be compiled out if DEBUG macro
111 * See also: vxge_debug_level_e{}.
113 #if (VXGE_COMPONENT_LL & VXGE_DEBUG_MODULE_MASK)
114 #define vxge_debug_ll(level, hldev, vpid, fmt, ...) \
115 vxge_debug(VXGE_COMPONENT_LL, level, hldev, vpid, fmt, __VA_ARGS__)
117 #define vxge_debug_ll(level, hldev, vpid, fmt, ...)
122 * @component: The Component mask
123 * @level: level of debug verbosity.
126 * @fmt: printf like format string
128 * Provides logging facilities for LL driver. Can be customized
129 * with debug levels. Input parameters, except level, are the same
130 * as posix printf. This function may be compiled out if DEBUG macro
132 * See also: vxge_debug_level_e{}.
134 #if (VXGE_COMPONENT_ULD & VXGE_DEBUG_MODULE_MASK)
135 #define vxge_debug_uld(component, level, hldev, vpid, fmt, ...) \
136 vxge_debug(component, level, hldev, vpid, fmt, __VA_ARGS__)
138 #define vxge_debug_uld(level, hldev, vpid, fmt, ...)
141 #else /* VXGE_DEBUG_INLINE_FUNCTIONS */
143 #if defined(VXGE_TRACE_INTO_CIRCULAR_ARR)
144 #define vxge_trace_aux(hldev, vpid, fmt) \
145 vxge_os_vasprintf(hldev, vpid, fmt)
147 #define vxge_trace_aux(hldev, vpid, fmt) \
148 vxge_os_vaprintf(hldev, vpid, fmt)
151 #define vxge_debug(module, level, hldev, vpid, fmt) \
153 if (((u32)level <= ((vxge_hal_device_t *)hldev)->debug_level) && \
154 ((u32)module & ((vxge_hal_device_t *)hldev)->debug_module_mask))\
155 vxge_trace_aux((vxge_hal_device_h)hldev, vpid, fmt); \
160 * @level: level of debug verbosity.
163 * @fmt: printf like format string
165 * Provides logging facilities for OS Dependent functions. Can be customized
166 * with debug levels. Input parameters, except level, are the same
167 * as posix printf. This function may be compiled out if DEBUG macro
169 * See also: vxge_debug_level_e{}.
171 static inline void vxge_debug_driver(
172 vxge_debug_level_e level,
173 vxge_hal_device_h hldev,
177 #if (VXGE_COMPONENT_HAL_DRIVER & VXGE_DEBUG_MODULE_MASK)
178 if ((u32) level <= g_debug_level)
179 vxge_os_vaprintf((vxge_hal_device_h) hldev, vpid, fmt);
185 * @level: level of debug verbosity.
188 * @fmt: printf like format string
190 * Provides logging facilities for OS Dependent functions. Can be customized
191 * with debug levels. Input parameters, except level, are the same
192 * as posix printf. This function may be compiled out if DEBUG macro
194 * See also: vxge_debug_level_e{}.
196 static inline void vxge_debug_osdep(
197 vxge_debug_level_e level,
198 vxge_hal_device_h hldev,
202 #if (VXGE_COMPONENT_OSDEP & VXGE_DEBUG_MODULE_MASK)
203 vxge_debug(VXGE_COMPONENT_OSDEP, level, hldev, vpid, fmt)
209 * @level: level of debug verbosity.
212 * @fmt: printf like format string
214 * Provides logging facilities for LL driver. Can be customized
215 * with debug levels. Input parameters, except level, are the same
216 * as posix printf. This function may be compiled out if DEBUG macro
218 * See also: vxge_debug_level_e{}.
220 static inline void vxge_debug_ll(
221 vxge_debug_level_e level,
222 vxge_hal_device_h hldev,
226 #if (VXGE_COMPONENT_LL & VXGE_DEBUG_MODULE_MASK)
227 vxge_debug(VXGE_COMPONENT_LL, level, hldev, vpid, fmt)
233 * @component: The Component mask
234 * @level: level of debug verbosity.
237 * @fmt: printf like format string
239 * Provides logging facilities for LL driver. Can be customized
240 * with debug levels. Input parameters, except level, are the same
241 * as posix printf. This function may be compiled out if DEBUG macro
243 * See also: vxge_debug_level_e{}.
245 static inline void vxge_debug_uld(
247 vxge_debug_level_e level,
248 vxge_hal_device_h hldev,
252 #if (VXGE_COMPONENT_ULD & VXGE_DEBUG_MODULE_MASK)
253 vxge_debug(component, level, hldev, vpid, fmt)
257 #endif /* end of VXGE_DEBUG_INLINE_FUNCTIONS */
261 #endif /* VXGE_OS_DEBUG_H */