vxge-os-debug.h revision 221167
1221167Sgnn/*- 2221167Sgnn * Copyright(c) 2002-2011 Exar Corp. 3221167Sgnn * All rights reserved. 4221167Sgnn * 5221167Sgnn * Redistribution and use in source and binary forms, with or without 6221167Sgnn * modification are permitted provided the following conditions are met: 7221167Sgnn * 8221167Sgnn * 1. Redistributions of source code must retain the above copyright notice, 9221167Sgnn * this list of conditions and the following disclaimer. 10221167Sgnn * 11221167Sgnn * 2. Redistributions in binary form must reproduce the above copyright 12221167Sgnn * notice, this list of conditions and the following disclaimer in the 13221167Sgnn * documentation and/or other materials provided with the distribution. 14221167Sgnn * 15221167Sgnn * 3. Neither the name of the Exar Corporation nor the names of its 16221167Sgnn * contributors may be used to endorse or promote products derived from 17221167Sgnn * this software without specific prior written permission. 18221167Sgnn * 19221167Sgnn * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 20221167Sgnn * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21221167Sgnn * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22221167Sgnn * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 23221167Sgnn * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24221167Sgnn * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25221167Sgnn * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26221167Sgnn * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27221167Sgnn * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28221167Sgnn * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29221167Sgnn * POSSIBILITY OF SUCH DAMAGE. 30221167Sgnn */ 31221167Sgnn/*$FreeBSD: head/sys/dev/vxge/include/vxge-os-debug.h 221167 2011-04-28 14:33:15Z gnn $*/ 32221167Sgnn 33221167Sgnn#ifndef VXGE_OS_DEBUG_H 34221167Sgnn#define VXGE_OS_DEBUG_H 35221167Sgnn 36221167Sgnn__EXTERN_BEGIN_DECLS 37221167Sgnn 38221167Sgnn#ifndef VXGE_DEBUG_INLINE_FUNCTIONS 39221167Sgnn 40221167Sgnn#if defined(VXGE_TRACE_INTO_CIRCULAR_ARR) 41221167Sgnn#define vxge_trace_aux(hldev, vpid, fmt, ...) \ 42221167Sgnn vxge_os_vasprintf(hldev, vpid, fmt, __VA_ARGS__) 43221167Sgnn#else 44221167Sgnn#define vxge_trace_aux(hldev, vpid, fmt, ...) \ 45221167Sgnn vxge_os_vaprintf(hldev, vpid, fmt, __VA_ARGS__) 46221167Sgnn#endif 47221167Sgnn 48221167Sgnn#define vxge_debug(module, level, hldev, vpid, fmt, ...) \ 49221167Sgnn{ \ 50221167Sgnn if (((u32)level <= \ 51221167Sgnn ((vxge_hal_device_t *)hldev)->debug_level) && \ 52221167Sgnn ((u32)module & \ 53221167Sgnn ((vxge_hal_device_t *)hldev)->debug_module_mask)) \ 54221167Sgnn vxge_trace_aux((vxge_hal_device_h)hldev, \ 55221167Sgnn vpid, fmt, __VA_ARGS__); \ 56221167Sgnn} 57221167Sgnn 58221167Sgnn/* 59221167Sgnn * vxge_debug_driver 60221167Sgnn * @level: level of debug verbosity. 61221167Sgnn * @hldev: HAL Device 62221167Sgnn * @vpid: Vpath id 63221167Sgnn * @fmt: printf like format string 64221167Sgnn * 65221167Sgnn * Provides logging facilities for OS Dependent functions. Can be customized 66221167Sgnn * with debug levels. Input parameters, except level, are the same 67221167Sgnn * as posix printf. This function may be compiled out if DEBUG macro 68221167Sgnn * was never defined. 69221167Sgnn * See also: vxge_debug_level_e{}. 70221167Sgnn */ 71221167Sgnn#if (VXGE_COMPONENT_HAL_DRIVER & VXGE_DEBUG_MODULE_MASK) 72221167Sgnn#define vxge_debug_driver(level, hldev, vpid, fmt, ...) \ 73221167Sgnn if ((u32)level <= g_debug_level) \ 74221167Sgnn vxge_os_vaprintf((vxge_hal_device_h)hldev, \ 75221167Sgnn vpid, fmt, __VA_ARGS__); 76221167Sgnn#else 77221167Sgnn#define vxge_debug_driver(level, hldev, vpid, fmt, ...) 78221167Sgnn#endif 79221167Sgnn 80221167Sgnn/* 81221167Sgnn * vxge_debug_osdep 82221167Sgnn * @level: level of debug verbosity. 83221167Sgnn * @hldev: HAL Device 84221167Sgnn * @vpid: Vpath id 85221167Sgnn * @fmt: printf like format string 86221167Sgnn * 87221167Sgnn * Provides logging facilities for OS Dependent functions. Can be customized 88221167Sgnn * with debug levels. Input parameters, except level, are the same 89221167Sgnn * as posix printf. This function may be compiled out if DEBUG macro 90221167Sgnn * was never defined. 91221167Sgnn * See also: vxge_debug_level_e{}. 92221167Sgnn */ 93221167Sgnn#if (VXGE_COMPONENT_OSDEP & VXGE_DEBUG_MODULE_MASK) 94221167Sgnn#define vxge_debug_osdep(level, hldev, vpid, fmt, ...) \ 95221167Sgnn vxge_debug(VXGE_COMPONENT_OSDEP, level, hldev, vpid, fmt, __VA_ARGS__) 96221167Sgnn#else 97221167Sgnn#define vxge_debug_osdep(level, hldev, vpid, fmt, ...) 98221167Sgnn#endif 99221167Sgnn 100221167Sgnn/* 101221167Sgnn * vxge_debug_ll 102221167Sgnn * @level: level of debug verbosity. 103221167Sgnn * @hldev: HAL Device 104221167Sgnn * @vpid: Vpath id 105221167Sgnn * @fmt: printf like format string 106221167Sgnn * 107221167Sgnn * Provides logging facilities for LL driver. Can be customized 108221167Sgnn * with debug levels. Input parameters, except level, are the same 109221167Sgnn * as posix printf. This function may be compiled out if DEBUG macro 110221167Sgnn * was never defined. 111221167Sgnn * See also: vxge_debug_level_e{}. 112221167Sgnn */ 113221167Sgnn#if (VXGE_COMPONENT_LL & VXGE_DEBUG_MODULE_MASK) 114221167Sgnn#define vxge_debug_ll(level, hldev, vpid, fmt, ...) \ 115221167Sgnn vxge_debug(VXGE_COMPONENT_LL, level, hldev, vpid, fmt, __VA_ARGS__) 116221167Sgnn#else 117221167Sgnn#define vxge_debug_ll(level, hldev, vpid, fmt, ...) 118221167Sgnn#endif 119221167Sgnn 120221167Sgnn/* 121221167Sgnn * vxge_debug_uld 122221167Sgnn * @component: The Component mask 123221167Sgnn * @level: level of debug verbosity. 124221167Sgnn * @hldev: HAL Device 125221167Sgnn * @vpid: Vpath id 126221167Sgnn * @fmt: printf like format string 127221167Sgnn * 128221167Sgnn * Provides logging facilities for LL driver. Can be customized 129221167Sgnn * with debug levels. Input parameters, except level, are the same 130221167Sgnn * as posix printf. This function may be compiled out if DEBUG macro 131221167Sgnn * was never defined. 132221167Sgnn * See also: vxge_debug_level_e{}. 133221167Sgnn */ 134221167Sgnn#if (VXGE_COMPONENT_ULD & VXGE_DEBUG_MODULE_MASK) 135221167Sgnn#define vxge_debug_uld(component, level, hldev, vpid, fmt, ...) \ 136221167Sgnn vxge_debug(component, level, hldev, vpid, fmt, __VA_ARGS__) 137221167Sgnn#else 138221167Sgnn#define vxge_debug_uld(level, hldev, vpid, fmt, ...) 139221167Sgnn#endif 140221167Sgnn 141221167Sgnn#else /* VXGE_DEBUG_INLINE_FUNCTIONS */ 142221167Sgnn 143221167Sgnn#if defined(VXGE_TRACE_INTO_CIRCULAR_ARR) 144221167Sgnn#define vxge_trace_aux(hldev, vpid, fmt) \ 145221167Sgnn vxge_os_vasprintf(hldev, vpid, fmt) 146221167Sgnn#else 147221167Sgnn#define vxge_trace_aux(hldev, vpid, fmt) \ 148221167Sgnn vxge_os_vaprintf(hldev, vpid, fmt) 149221167Sgnn#endif 150221167Sgnn 151221167Sgnn#define vxge_debug(module, level, hldev, vpid, fmt) \ 152221167Sgnn{ \ 153221167Sgnn if (((u32)level <= ((vxge_hal_device_t *)hldev)->debug_level) && \ 154221167Sgnn ((u32)module & ((vxge_hal_device_t *)hldev)->debug_module_mask))\ 155221167Sgnn vxge_trace_aux((vxge_hal_device_h)hldev, vpid, fmt); \ 156221167Sgnn} 157221167Sgnn 158221167Sgnn/* 159221167Sgnn * vxge_debug_driver 160221167Sgnn * @level: level of debug verbosity. 161221167Sgnn * @hldev: HAL Device 162221167Sgnn * @vpid: Vpath id 163221167Sgnn * @fmt: printf like format string 164221167Sgnn * 165221167Sgnn * Provides logging facilities for OS Dependent functions. Can be customized 166221167Sgnn * with debug levels. Input parameters, except level, are the same 167221167Sgnn * as posix printf. This function may be compiled out if DEBUG macro 168221167Sgnn * was never defined. 169221167Sgnn * See also: vxge_debug_level_e{}. 170221167Sgnn */ 171221167Sgnnstatic inline void vxge_debug_driver( 172221167Sgnn vxge_debug_level_e level, 173221167Sgnn vxge_hal_device_h hldev, 174221167Sgnn u32 vpid, 175221167Sgnn char *fmt, ...) 176221167Sgnn{ 177221167Sgnn#if (VXGE_COMPONENT_HAL_DRIVER & VXGE_DEBUG_MODULE_MASK) 178221167Sgnn if ((u32) level <= g_debug_level) 179221167Sgnn vxge_os_vaprintf((vxge_hal_device_h) hldev, vpid, fmt); 180221167Sgnn#endif 181221167Sgnn} 182221167Sgnn 183221167Sgnn/* 184221167Sgnn * vxge_debug_osdep 185221167Sgnn * @level: level of debug verbosity. 186221167Sgnn * @hldev: HAL Device 187221167Sgnn * @vpid: Vpath id 188221167Sgnn * @fmt: printf like format string 189221167Sgnn * 190221167Sgnn * Provides logging facilities for OS Dependent functions. Can be customized 191221167Sgnn * with debug levels. Input parameters, except level, are the same 192221167Sgnn * as posix printf. This function may be compiled out if DEBUG macro 193221167Sgnn * was never defined. 194221167Sgnn * See also: vxge_debug_level_e{}. 195221167Sgnn */ 196221167Sgnnstatic inline void vxge_debug_osdep( 197221167Sgnn vxge_debug_level_e level, 198221167Sgnn vxge_hal_device_h hldev, 199221167Sgnn u32 vpid, 200221167Sgnn char *fmt, ...) 201221167Sgnn{ 202221167Sgnn#if (VXGE_COMPONENT_OSDEP & VXGE_DEBUG_MODULE_MASK) 203221167Sgnn vxge_debug(VXGE_COMPONENT_OSDEP, level, hldev, vpid, fmt) 204221167Sgnn#endif 205221167Sgnn} 206221167Sgnn 207221167Sgnn/* 208221167Sgnn * vxge_debug_ll 209221167Sgnn * @level: level of debug verbosity. 210221167Sgnn * @hldev: HAL Device 211221167Sgnn * @vpid: Vpath id 212221167Sgnn * @fmt: printf like format string 213221167Sgnn * 214221167Sgnn * Provides logging facilities for LL driver. Can be customized 215221167Sgnn * with debug levels. Input parameters, except level, are the same 216221167Sgnn * as posix printf. This function may be compiled out if DEBUG macro 217221167Sgnn * was never defined. 218221167Sgnn * See also: vxge_debug_level_e{}. 219221167Sgnn */ 220221167Sgnnstatic inline void vxge_debug_ll( 221221167Sgnn vxge_debug_level_e level, 222221167Sgnn vxge_hal_device_h hldev, 223221167Sgnn u32 vpid, 224221167Sgnn char *fmt, ...) 225221167Sgnn{ 226221167Sgnn#if (VXGE_COMPONENT_LL & VXGE_DEBUG_MODULE_MASK) 227221167Sgnn vxge_debug(VXGE_COMPONENT_LL, level, hldev, vpid, fmt) 228221167Sgnn#endif 229221167Sgnn} 230221167Sgnn 231221167Sgnn/* 232221167Sgnn * vxge_debug_uld 233221167Sgnn * @component: The Component mask 234221167Sgnn * @level: level of debug verbosity. 235221167Sgnn * @hldev: HAL Device 236221167Sgnn * @vpid: Vpath id 237221167Sgnn * @fmt: printf like format string 238221167Sgnn * 239221167Sgnn * Provides logging facilities for LL driver. Can be customized 240221167Sgnn * with debug levels. Input parameters, except level, are the same 241221167Sgnn * as posix printf. This function may be compiled out if DEBUG macro 242221167Sgnn * was never defined. 243221167Sgnn * See also: vxge_debug_level_e{}. 244221167Sgnn */ 245221167Sgnnstatic inline void vxge_debug_uld( 246221167Sgnn u32 component, 247221167Sgnn vxge_debug_level_e level, 248221167Sgnn vxge_hal_device_h hldev, 249221167Sgnn u32 vpid, 250221167Sgnn char *fmt, ...) 251221167Sgnn{ 252221167Sgnn#if (VXGE_COMPONENT_ULD & VXGE_DEBUG_MODULE_MASK) 253221167Sgnn vxge_debug(component, level, hldev, vpid, fmt) 254221167Sgnn#endif 255221167Sgnn} 256221167Sgnn 257221167Sgnn#endif /* end of VXGE_DEBUG_INLINE_FUNCTIONS */ 258221167Sgnn 259221167Sgnn__EXTERN_END_DECLS 260221167Sgnn 261221167Sgnn#endif /* VXGE_OS_DEBUG_H */ 262