[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/dev/nxge/include/xge-debug.h

Version: -  FREEBSD  -  FREEBSD8  -  FREEBSD7  -  FREEBSD72  -  FREEBSD71  -  FREEBSD70  -  FREEBSD6  -  FREEBSD64  -  FREEBSD63  -  FREEBSD62  -  FREEBSD61  -  FREEBSD60  -  FREEBSD5  -  FREEBSD55  -  FREEBSD54  -  FREEBSD53  -  FREEBSD52  -  FREEBSD51  -  FREEBSD50  -  FREEBSD4  -  FREEBSD3  -  FREEBSD22  -  linux-2.6  -  linux-2.4.22  -  MK83  -  MK84  -  PLAN9  -  DFBSD  -  NETBSD  -  NETBSD5  -  NETBSD4  -  NETBSD3  -  NETBSD20  -  OPENBSD  -  xnu-517  -  xnu-792  -  xnu-792.6.70  -  xnu-1228  -  xnu-1456.1.26  -  OPENSOLARIS  -  minix-3-1-1  -  FREEBSD-LIBC  -  FREEBSD7-LIBC  -  FREEBSD6-LIBC  -  GLIBC27 
SearchContext: -  none  -  excerpts  -  bigexcerpts 

    1 /*-
    2  * Copyright (c) 2002-2007 Neterion, Inc.
    3  * All rights reserved.
    4  *
    5  * Redistribution and use in source and binary forms, with or without
    6  * modification, are permitted provided that the following conditions
    7  * are met:
    8  * 1. Redistributions of source code must retain the above copyright
    9  *    notice, this list of conditions and the following disclaimer.
   10  * 2. Redistributions in binary form must reproduce the above copyright
   11  *    notice, this list of conditions and the following disclaimer in the
   12  *    documentation and/or other materials provided with the distribution.
   13  *
   14  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
   15  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   16  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   17  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
   18  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   19  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   20  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   21  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   22  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   23  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   24  * SUCH DAMAGE.
   25  *
   26  * $FreeBSD$
   27  */
   28 
   29 #ifndef XGE_DEBUG_H
   30 #define XGE_DEBUG_H
   31 
   32 #include <dev/nxge/include/xge-os-pal.h>
   33 
   34 __EXTERN_BEGIN_DECLS
   35 
   36 /*
   37  * __FUNCTION__ is, together with __PRETTY_FUNCTION__ or something similar,
   38  * a gcc extension. we'll have to #ifdef around that, and provide some
   39  * meaningful replacement for those, so to make some gcc versions happier
   40  */
   41 #ifndef __func__
   42 #ifdef __FUNCTION__
   43 #define __func__ __FUNCTION__
   44 #endif
   45 #endif
   46 
   47 
   48 #ifdef XGE_DEBUG_FP
   49 #define XGE_DEBUG_FP_DEVICE             0x1
   50 #define XGE_DEBUG_FP_CHANNEL    0x2
   51 #define XGE_DEBUG_FP_FIFO               0x4
   52 #define XGE_DEBUG_FP_RING               0x8
   53 #define XGE_DEBUG_FP_ALL                0xff
   54 #endif
   55 
   56 /**
   57  * enum xge_debug_level_e
   58  * @XGE_NONE: debug disabled
   59  * @XGE_ERR: all errors going to be logged out
   60  * @XGE_TRACE: all errors plus all kind of verbose tracing print outs
   61  *                 going to be logged out. Very noisy.
   62  *
   63  * This enumeration going to be used to switch between different
   64  * debug levels during runtime if DEBUG macro defined during
   65  * compilation. If DEBUG macro not defined than code will be
   66  * compiled out.
   67  */
   68 typedef enum xge_debug_level_e {
   69         XGE_NONE   = 0,
   70         XGE_TRACE  = 1,
   71         XGE_ERR    = 2,
   72 } xge_debug_level_e;
   73 
   74 #define XGE_DEBUG_MODULE_MASK_DEF       0x30000030
   75 #define XGE_DEBUG_LEVEL_DEF             XGE_ERR
   76 
   77 #if defined(XGE_DEBUG_TRACE_MASK) || defined(XGE_DEBUG_ERR_MASK)
   78 
   79 extern unsigned long *g_module_mask;
   80 extern int *g_level;
   81 
   82 #ifndef XGE_DEBUG_TRACE_MASK
   83 #define XGE_DEBUG_TRACE_MASK 0
   84 #endif
   85 
   86 #ifndef XGE_DEBUG_ERR_MASK
   87 #define XGE_DEBUG_ERR_MASK 0
   88 #endif
   89 
   90 /*
   91  * @XGE_COMPONENT_HAL_CONFIG: do debug for xge core config module
   92  * @XGE_COMPONENT_HAL_FIFO: do debug for xge core fifo module
   93  * @XGE_COMPONENT_HAL_RING: do debug for xge core ring module
   94  * @XGE_COMPONENT_HAL_CHANNEL: do debug for xge core channel module
   95  * @XGE_COMPONENT_HAL_DEVICE: do debug for xge core device module
   96  * @XGE_COMPONENT_HAL_DMQ: do debug for xge core DMQ module
   97  * @XGE_COMPONENT_HAL_UMQ: do debug for xge core UMQ module
   98  * @XGE_COMPONENT_HAL_SQ: do debug for xge core SQ module
   99  * @XGE_COMPONENT_HAL_SRQ: do debug for xge core SRQ module
  100  * @XGE_COMPONENT_HAL_CQRQ: do debug for xge core CRQ module
  101  * @XGE_COMPONENT_HAL_POOL: do debug for xge core memory pool module
  102  * @XGE_COMPONENT_HAL_BITMAP: do debug for xge core BITMAP module
  103  * @XGE_COMPONENT_CORE: do debug for xge KMA core module
  104  * @XGE_COMPONENT_OSDEP: do debug for xge KMA os dependent parts
  105  * @XGE_COMPONENT_LL: do debug for xge link layer module
  106  * @XGE_COMPONENT_ALL: activate debug for all modules with no exceptions
  107  *
  108  * This enumeration going to be used to distinguish modules
  109  * or libraries during compilation and runtime.  Makefile must declare
  110  * XGE_DEBUG_MODULE_MASK macro and set it to proper value.
  111  */
  112 #define XGE_COMPONENT_HAL_CONFIG                0x00000001
  113 #define XGE_COMPONENT_HAL_FIFO                  0x00000002
  114 #define XGE_COMPONENT_HAL_RING                  0x00000004
  115 #define XGE_COMPONENT_HAL_CHANNEL               0x00000008
  116 #define XGE_COMPONENT_HAL_DEVICE                0x00000010
  117 #define XGE_COMPONENT_HAL_MM                    0x00000020
  118 #define XGE_COMPONENT_HAL_QUEUE         0x00000040
  119 #define XGE_COMPONENT_HAL_INTERRUPT     0x00000080
  120 #define XGE_COMPONENT_HAL_STATS         0x00000100
  121 
  122         /* space for CORE_XXX */
  123 #define XGE_COMPONENT_OSDEP                     0x10000000
  124 #define XGE_COMPONENT_LL                        0x20000000
  125 #define XGE_COMPONENT_ALL                       0xffffffff
  126 
  127 #ifndef XGE_DEBUG_MODULE_MASK
  128 #error "XGE_DEBUG_MODULE_MASK macro must be defined for DEBUG mode..."
  129 #endif
  130 
  131 #ifndef __GNUC__
  132 #ifdef XGE_TRACE_INTO_CIRCULAR_ARR
  133             #define xge_trace_aux(fmt) xge_os_vatrace(g_xge_os_tracebuf, fmt)
  134 #else
  135             #define xge_trace_aux(fmt) xge_os_vaprintf(fmt)
  136 #endif
  137 
  138 /**
  139  * xge_debug
  140  * @level: level of debug verbosity.
  141  * @fmt: printf like format string
  142  *
  143  * Provides logging facilities. Can be customized on per-module
  144  * basis or/and with debug levels. Input parameters, except
  145  * module and level, are the same as posix printf. This function
  146  * may be compiled out if DEBUG macro was never defined.
  147  * See also: xge_debug_level_e{}.
  148  */
  149 #define xge_debug(module, level, fmt) { \
  150 if (((level >= XGE_TRACE && ((module & XGE_DEBUG_TRACE_MASK) == module)) || \
  151         (level >= XGE_ERR && ((module & XGE_DEBUG_ERR_MASK) == module))) && \
  152         level >= *g_level && module & *(unsigned int *)g_module_mask) { \
  153                     xge_trace_aux(fmt); \
  154         } \
  155 }
  156 #else /* __GNUC__ */
  157 
  158 #ifdef XGE_TRACE_INTO_CIRCULAR_ARR
  159             #define xge_trace_aux(fmt...) xge_os_trace(g_xge_os_tracebuf, fmt)
  160 #else
  161             #define xge_trace_aux(fmt...) xge_os_printf(fmt)
  162 #endif
  163 
  164 #define xge_debug(module, level, fmt...) { \
  165 if (((level >= XGE_TRACE && ((module & XGE_DEBUG_TRACE_MASK) == module)) || \
  166         (level >= XGE_ERR && ((module & XGE_DEBUG_ERR_MASK) == module))) && \
  167         level >= *g_level && module & *(unsigned int *)g_module_mask) { \
  168                     xge_trace_aux(fmt); \
  169         } \
  170 }
  171 #endif /* __GNUC__ */
  172 
  173 #if (XGE_COMPONENT_HAL_STATS & XGE_DEBUG_MODULE_MASK)
  174 #ifndef __GNUC__
  175 static inline void xge_debug_stats(xge_debug_level_e level, char *fmt, ...) {
  176         u32 module = XGE_COMPONENT_HAL_STATS;
  177         xge_debug(module, level, fmt);
  178 }
  179 #else /* __GNUC__ */
  180 #define xge_debug_stats(level, fmt...) \
  181         xge_debug(XGE_COMPONENT_HAL_STATS, level, fmt)
  182 #endif /* __GNUC__ */
  183 #else
  184 #ifndef __GNUC__
  185 static inline void xge_debug_stats(xge_debug_level_e level, char *fmt, ...) {}
  186 #else /* __GNUC__ */
  187 #define xge_debug_stats(level, fmt...)
  188 #endif /* __GNUC__ */
  189 #endif
  190 
  191 /* Interrupt Related */
  192 #if (XGE_COMPONENT_HAL_INTERRUPT & XGE_DEBUG_MODULE_MASK)
  193 #ifndef __GNUC__
  194 static inline void xge_debug_interrupt(xge_debug_level_e level, char *fmt, ...) {
  195         u32 module = XGE_COMPONENT_HAL_INTERRUPT;
  196         xge_debug(module, level, fmt);
  197 }
  198 #else /* __GNUC__ */
  199 #define xge_debug_interrupt(level, fmt...) \
  200         xge_debug(XGE_COMPONENT_HAL_INTERRUPT, level, fmt)
  201 #endif /* __GNUC__ */
  202 #else
  203 #ifndef __GNUC__
  204 static inline void xge_debug_interrupt(xge_debug_level_e level, char *fmt, ...) {}
  205 #else /* __GNUC__ */
  206 #define xge_debug_interrupt(level, fmt...)
  207 #endif /* __GNUC__ */
  208 #endif
  209 
  210 #if (XGE_COMPONENT_HAL_QUEUE & XGE_DEBUG_MODULE_MASK)
  211 #ifndef __GNUC__
  212 static inline void xge_debug_queue(xge_debug_level_e level, char *fmt, ...) {
  213         u32 module = XGE_COMPONENT_HAL_QUEUE;
  214         xge_debug(module, level, fmt);
  215 }
  216 #else /* __GNUC__ */
  217 #define xge_debug_queue(level, fmt...) \
  218         xge_debug(XGE_COMPONENT_HAL_QUEUE, level, fmt)
  219 #endif /* __GNUC__ */
  220 #else
  221 #ifndef __GNUC__
  222 static inline void xge_debug_queue(xge_debug_level_e level, char *fmt,
  223 ...) {}
  224 #else /* __GNUC__ */
  225 #define xge_debug_queue(level, fmt...)
  226 #endif /* __GNUC__ */
  227 #endif
  228 
  229 #if (XGE_COMPONENT_HAL_MM & XGE_DEBUG_MODULE_MASK)
  230 #ifndef __GNUC__
  231 static inline void xge_debug_mm(xge_debug_level_e level, char *fmt, ...)
  232 {
  233         u32 module = XGE_COMPONENT_HAL_MM;
  234         xge_debug(module, level, fmt);
  235 }
  236 #else /* __GNUC__ */
  237 #define xge_debug_mm(level, fmt...) \
  238         xge_debug(XGE_COMPONENT_HAL_MM, level, fmt)
  239 #endif /* __GNUC__ */
  240 #else
  241 #ifndef __GNUC__
  242 static inline void xge_debug_mm(xge_debug_level_e level, char *fmt, ...)
  243 {}
  244 #else /* __GNUC__ */
  245 #define xge_debug_mm(level, fmt...)
  246 #endif /* __GNUC__ */
  247 #endif
  248 
  249 #if (XGE_COMPONENT_HAL_CONFIG & XGE_DEBUG_MODULE_MASK)
  250 #ifndef __GNUC__
  251 static inline void xge_debug_config(xge_debug_level_e level, char *fmt, ...) {
  252         u32 module = XGE_COMPONENT_HAL_CONFIG;
  253         xge_debug(module, level, fmt);
  254 }
  255 #else /* __GNUC__ */
  256 #define xge_debug_config(level, fmt...) \
  257         xge_debug(XGE_COMPONENT_HAL_CONFIG, level, fmt)
  258 #endif /* __GNUC__ */
  259 #else
  260 #ifndef __GNUC__
  261 static inline void xge_debug_config(xge_debug_level_e level, char *fmt,
  262 ...) {}
  263 #else /* __GNUC__ */
  264 #define xge_debug_config(level, fmt...)
  265 #endif /* __GNUC__ */
  266 #endif
  267 
  268 #if (XGE_COMPONENT_HAL_FIFO & XGE_DEBUG_MODULE_MASK)
  269 #ifndef __GNUC__
  270 static inline void xge_debug_fifo(xge_debug_level_e level, char *fmt, ...) {
  271         u32 module = XGE_COMPONENT_HAL_FIFO;
  272         xge_debug(module, level, fmt);
  273 }
  274 #else /* __GNUC__ */
  275 #define xge_debug_fifo(level, fmt...) \
  276         xge_debug(XGE_COMPONENT_HAL_FIFO, level, fmt)
  277 #endif /* __GNUC__ */
  278 #else
  279 #ifndef __GNUC__
  280 static inline void xge_debug_fifo(xge_debug_level_e level, char *fmt, ...) {}
  281 #else /* __GNUC__ */
  282 #define xge_debug_fifo(level, fmt...)
  283 #endif /* __GNUC__ */
  284 #endif
  285 
  286 #if (XGE_COMPONENT_HAL_RING & XGE_DEBUG_MODULE_MASK)
  287 #ifndef __GNUC__
  288 static inline void xge_debug_ring(xge_debug_level_e level, char *fmt, ...) {
  289         u32 module = XGE_COMPONENT_HAL_RING;
  290         xge_debug(module, level, fmt);
  291 }
  292 #else /* __GNUC__ */
  293 #define xge_debug_ring(level, fmt...) \
  294         xge_debug(XGE_COMPONENT_HAL_RING, level, fmt)
  295 #endif /* __GNUC__ */
  296 #else
  297 #ifndef __GNUC__
  298 static inline void xge_debug_ring(xge_debug_level_e level, char *fmt, ...) {}
  299 #else /* __GNUC__ */
  300 #define xge_debug_ring(level, fmt...)
  301 #endif /* __GNUC__ */
  302 #endif
  303 
  304 #if (XGE_COMPONENT_HAL_CHANNEL & XGE_DEBUG_MODULE_MASK)
  305 #ifndef __GNUC__
  306 static inline void xge_debug_channel(xge_debug_level_e level, char *fmt, ...) {
  307         u32 module = XGE_COMPONENT_HAL_CHANNEL;
  308         xge_debug(module, level, fmt);
  309 }
  310 #else /* __GNUC__ */
  311 #define xge_debug_channel(level, fmt...) \
  312         xge_debug(XGE_COMPONENT_HAL_CHANNEL, level, fmt)
  313 #endif /* __GNUC__ */
  314 #else
  315 #ifndef __GNUC__
  316 static inline void xge_debug_channel(xge_debug_level_e level, char *fmt, ...) {}
  317 #else /* __GNUC__ */
  318 #define xge_debug_channel(level, fmt...)
  319 #endif /* __GNUC__ */
  320 #endif
  321 
  322 #if (XGE_COMPONENT_HAL_DEVICE & XGE_DEBUG_MODULE_MASK)
  323 #ifndef __GNUC__
  324 static inline void xge_debug_device(xge_debug_level_e level, char *fmt, ...) {
  325         u32 module = XGE_COMPONENT_HAL_DEVICE;
  326         xge_debug(module, level, fmt);
  327 }
  328 #else /* __GNUC__ */
  329 #define xge_debug_device(level, fmt...) \
  330         xge_debug(XGE_COMPONENT_HAL_DEVICE, level, fmt)
  331 #endif /* __GNUC__ */
  332 #else
  333 #ifndef __GNUC__
  334 static inline void xge_debug_device(xge_debug_level_e level, char *fmt, ...) {}
  335 #else /* __GNUC__ */
  336 #define xge_debug_device(level, fmt...)
  337 #endif /* __GNUC__ */
  338 #endif
  339 
  340 #if (XGE_COMPONENT_OSDEP & XGE_DEBUG_MODULE_MASK)
  341 #ifndef __GNUC__
  342 static inline void xge_debug_osdep(xge_debug_level_e level, char *fmt, ...) {
  343         u32 module = XGE_COMPONENT_OSDEP;
  344         xge_debug(module, level, fmt);
  345 }
  346 #else /* __GNUC__ */
  347 #define xge_debug_osdep(level, fmt...) \
  348         xge_debug(XGE_COMPONENT_OSDEP, level, fmt)
  349 #endif /* __GNUC__ */
  350 #else
  351 #ifndef __GNUC__
  352 static inline void xge_debug_osdep(xge_debug_level_e level, char *fmt, ...) {}
  353 #else /* __GNUC__ */
  354 #define xge_debug_osdep(level, fmt...)
  355 #endif /* __GNUC__ */
  356 #endif
  357 
  358 #if (XGE_COMPONENT_LL & XGE_DEBUG_MODULE_MASK)
  359 #ifndef __GNUC__
  360 static inline void xge_debug_ll(xge_debug_level_e level, char *fmt, ...)
  361 {
  362         u32 module = XGE_COMPONENT_LL;
  363         xge_debug(module, level, fmt);
  364 }
  365 #else /* __GNUC__ */
  366 #define xge_debug_ll(level, fmt...) \
  367         xge_debug(XGE_COMPONENT_LL, level, fmt)
  368 #endif /* __GNUC__ */
  369 #else
  370 #ifndef __GNUC__
  371 static inline void xge_debug_ll(xge_debug_level_e level, char *fmt, ...) {}
  372 #else /* __GNUC__ */
  373 #define xge_debug_ll(level, fmt...)
  374 #endif /* __GNUC__ */
  375 #endif
  376 
  377 #else
  378 
  379 static inline void xge_debug_interrupt(xge_debug_level_e level, char *fmt, ...) {}
  380 static inline void xge_debug_stats(xge_debug_level_e level, char *fmt, ...) {}
  381 static inline void xge_debug_queue(xge_debug_level_e level, char *fmt, ...) {}
  382 static inline void xge_debug_mm(xge_debug_level_e level, char *fmt, ...) {}
  383 static inline void xge_debug_config(xge_debug_level_e level, char *fmt, ...) {}
  384 static inline void xge_debug_fifo(xge_debug_level_e level, char *fmt, ...) {}
  385 static inline void xge_debug_ring(xge_debug_level_e level, char *fmt, ...) {}
  386 static inline void xge_debug_channel(xge_debug_level_e level, char *fmt, ...) {}
  387 static inline void xge_debug_device(xge_debug_level_e level, char *fmt, ...) {}
  388 static inline void xge_debug_hal(xge_debug_level_e level, char *fmt, ...) {}
  389 static inline void xge_debug_osdep(xge_debug_level_e level, char *fmt, ...) {}
  390 static inline void xge_debug_ll(xge_debug_level_e level, char *fmt, ...) {}
  391 
  392 #endif /* end of XGE_DEBUG_*_MASK */
  393 
  394 #ifdef XGE_DEBUG_ASSERT
  395 
  396 /**
  397  * xge_assert
  398  * @test: C-condition to check
  399  * @fmt: printf like format string
  400  *
  401  * This function implements traditional assert. By default assertions
  402  * are enabled. It can be disabled by defining XGE_DEBUG_ASSERT macro in
  403  * compilation
  404  * time.
  405  */
  406 #define xge_assert(test) { \
  407             if (!(test)) xge_os_bug("bad cond: "#test" at %s:%d\n", \
  408         __FILE__, __LINE__); }
  409 #else
  410 #define xge_assert(test)
  411 #endif /* end of XGE_DEBUG_ASSERT */
  412 
  413 __EXTERN_END_DECLS
  414 
  415 #endif /* XGE_DEBUG_H */

Cache object: a88f44a62bfb8d829404251266b63282


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.