Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1 | /* |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 2 | * Copyright (c) 2012, The Linux Foundation. All rights reserved. |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3 | * |
| 4 | * Previously licensed under the ISC license by Qualcomm Atheros, Inc. |
| 5 | * |
| 6 | * |
| 7 | * Permission to use, copy, modify, and/or distribute this software for |
| 8 | * any purpose with or without fee is hereby granted, provided that the |
| 9 | * above copyright notice and this permission notice appear in all |
| 10 | * copies. |
| 11 | * |
| 12 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL |
| 13 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED |
| 14 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE |
| 15 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL |
| 16 | * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR |
| 17 | * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER |
| 18 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
| 19 | * PERFORMANCE OF THIS SOFTWARE. |
| 20 | */ |
| 21 | |
| 22 | |
| 23 | #if !defined( __I_VOS_TRACE_H ) |
| 24 | #define __I_VOS_TRACE_H |
| 25 | |
| 26 | /**========================================================================= |
| 27 | |
| 28 | \file i_vos_trace.h |
| 29 | |
| 30 | \brief Linux-specific definitions for VOSS trace |
| 31 | |
| 32 | Copyright 2008 (c) Qualcomm, Incorporated. All Rights Reserved. |
| 33 | |
| 34 | Qualcomm Confidential and Proprietary. |
| 35 | |
| 36 | ========================================================================*/ |
| 37 | |
| 38 | /* $Header$ */ |
| 39 | |
| 40 | /*-------------------------------------------------------------------------- |
| 41 | Include Files |
| 42 | ------------------------------------------------------------------------*/ |
| 43 | |
| 44 | /**---------------------------------------------------------------------------- |
| 45 | |
| 46 | \brief VOS_TRACE() / vos_trace_msg() - Trace / logging API |
| 47 | |
| 48 | Users wishing to add tracing information to their code should use |
| 49 | VOS_TRACE. VOS_TRACE() will compile into a call to vos_trace_msg() when |
| 50 | tracing is enabled. |
| 51 | |
| 52 | \param module - module identifier. A member of the VOS_MODULE_ID |
| 53 | enumeration that identifies the module issuing the trace message. |
| 54 | |
| 55 | \param level - trace level. A member of the VOS_TRACE_LEVEL |
| 56 | enumeration indicating the severity of the condition causing the |
| 57 | trace message to be issued. More severe conditions are more |
| 58 | likely to be logged. |
| 59 | |
| 60 | \param strFormat - format string. The message to be logged. This format |
| 61 | string contains printf-like replacement parameters, which follow |
| 62 | this parameter in the variable argument list. |
| 63 | |
| 64 | \return nothing |
| 65 | |
| 66 | --------------------------------------------------------------------------*/ |
| 67 | void vos_trace_msg( VOS_MODULE_ID module, VOS_TRACE_LEVEL level, char *strFormat, ... ); |
| 68 | |
| 69 | void vos_trace_display(void); |
| 70 | |
| 71 | void vos_trace_setValue( VOS_MODULE_ID module, VOS_TRACE_LEVEL level, v_U8_t on ); |
| 72 | |
| 73 | |
| 74 | // VOS_TRACE is the macro invoked to add trace messages to code. See the |
| 75 | // documenation for vos_trace_msg() for the parameters etc. for this function. |
| 76 | // |
| 77 | // NOTE: Code VOS_TRACE() macros into the source code. Do not code directly |
| 78 | // to the vos_trace_msg() function. |
| 79 | // |
| 80 | // NOTE 2: vos tracing is totally turned off if WLAN_DEBUG is *not* defined. |
| 81 | // This allows us to build 'performance' builds where we can measure performance |
| 82 | // without being bogged down by all the tracing in the code. |
| 83 | #if defined( WLAN_DEBUG ) |
| 84 | #define VOS_TRACE vos_trace_msg |
| 85 | #else |
| 86 | #define VOS_TRACE(arg...) |
| 87 | #endif |
| 88 | |
| 89 | |
| 90 | void vos_snprintf(char *strBuffer, unsigned int size, char *strFormat, ...); |
| 91 | #define VOS_SNPRINTF vos_snprintf |
| 92 | |
| 93 | #ifdef VOS_ENABLE_TRACING |
| 94 | |
| 95 | |
Madan Mohan Koyyalamudi | a53c4dc | 2012-11-13 10:35:42 -0800 | [diff] [blame] | 96 | #define VOS_ASSERT( _condition ) do { \ |
| 97 | if ( ! ( _condition ) ) \ |
| 98 | { \ |
| 99 | printk(KERN_CRIT "VOS ASSERT in %s Line %d\n", __func__, __LINE__); \ |
| 100 | WARN_ON(1); \ |
| 101 | } \ |
| 102 | } while(0) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 103 | |
| 104 | #else |
| 105 | |
| 106 | |
| 107 | // This code will be used for compilation if tracing is to be compiled out |
| 108 | // of the code so these functions/macros are 'do nothing' |
| 109 | VOS_INLINE_FN void vos_trace_msg( VOS_MODULE_ID module, ... ){} |
| 110 | |
| 111 | #define VOS_ASSERT( _condition ) |
| 112 | |
| 113 | #endif |
| 114 | |
| 115 | #ifdef PANIC_ON_BUG |
| 116 | |
Madan Mohan Koyyalamudi | a53c4dc | 2012-11-13 10:35:42 -0800 | [diff] [blame] | 117 | #define VOS_BUG( _condition ) do { \ |
| 118 | if ( ! ( _condition ) ) \ |
| 119 | { \ |
| 120 | printk(KERN_CRIT "VOS BUG in %s Line %d\n", __func__, __LINE__); \ |
| 121 | BUG_ON(1); \ |
| 122 | } \ |
| 123 | } while(0) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 124 | |
| 125 | #else |
| 126 | |
Madan Mohan Koyyalamudi | a53c4dc | 2012-11-13 10:35:42 -0800 | [diff] [blame] | 127 | #define VOS_BUG( _condition ) do { \ |
| 128 | if ( ! ( _condition ) ) \ |
| 129 | { \ |
| 130 | printk(KERN_CRIT "VOS BUG in %s Line %d\n", __func__, __LINE__); \ |
| 131 | WARN_ON(1); \ |
| 132 | } \ |
| 133 | } while(0) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 134 | |
| 135 | #endif |
| 136 | |
| 137 | #endif |