Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1 | /* |
Sravan Kumar Kairam | be03722 | 2016-06-19 12:56:24 +0530 | [diff] [blame] | 2 | * Copyright (c) 2012-2013, 2016 The Linux Foundation. All rights reserved. |
Kiet Lam | 1ed83fc | 2014-02-19 01:15:45 -0800 | [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. |
Gopichand Nakkala | 92f07d8 | 2013-01-08 21:16:34 -0800 | [diff] [blame] | 20 | */ |
Kiet Lam | 1ed83fc | 2014-02-19 01:15:45 -0800 | [diff] [blame] | 21 | |
| 22 | /* |
| 23 | * This file was originally distributed by Qualcomm Atheros, Inc. |
| 24 | * under proprietary terms before Copyright ownership was assigned |
| 25 | * to the Linux Foundation. |
| 26 | */ |
| 27 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 28 | #if !defined( __I_VOS_TRACE_H ) |
| 29 | #define __I_VOS_TRACE_H |
| 30 | |
Jeff Johnson | 40d09f7 | 2013-11-11 12:10:25 -0800 | [diff] [blame] | 31 | #if !defined(__printf) |
| 32 | #define __printf(a,b) |
| 33 | #endif |
| 34 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 35 | /**========================================================================= |
| 36 | |
| 37 | \file i_vos_trace.h |
| 38 | |
| 39 | \brief Linux-specific definitions for VOSS trace |
| 40 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 41 | |
| 42 | ========================================================================*/ |
| 43 | |
| 44 | /* $Header$ */ |
| 45 | |
| 46 | /*-------------------------------------------------------------------------- |
| 47 | Include Files |
| 48 | ------------------------------------------------------------------------*/ |
| 49 | |
| 50 | /**---------------------------------------------------------------------------- |
| 51 | |
| 52 | \brief VOS_TRACE() / vos_trace_msg() - Trace / logging API |
| 53 | |
| 54 | Users wishing to add tracing information to their code should use |
| 55 | VOS_TRACE. VOS_TRACE() will compile into a call to vos_trace_msg() when |
| 56 | tracing is enabled. |
| 57 | |
| 58 | \param module - module identifier. A member of the VOS_MODULE_ID |
| 59 | enumeration that identifies the module issuing the trace message. |
| 60 | |
| 61 | \param level - trace level. A member of the VOS_TRACE_LEVEL |
| 62 | enumeration indicating the severity of the condition causing the |
| 63 | trace message to be issued. More severe conditions are more |
| 64 | likely to be logged. |
| 65 | |
| 66 | \param strFormat - format string. The message to be logged. This format |
| 67 | string contains printf-like replacement parameters, which follow |
| 68 | this parameter in the variable argument list. |
| 69 | |
| 70 | \return nothing |
| 71 | |
| 72 | --------------------------------------------------------------------------*/ |
Jeff Johnson | 40d09f7 | 2013-11-11 12:10:25 -0800 | [diff] [blame] | 73 | void __printf(3,4) vos_trace_msg( VOS_MODULE_ID module, VOS_TRACE_LEVEL level, |
| 74 | char *strFormat, ... ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 75 | |
Madan Mohan Koyyalamudi | 99af06e | 2013-08-08 02:17:17 +0530 | [diff] [blame] | 76 | void vos_trace_hex_dump( VOS_MODULE_ID module, VOS_TRACE_LEVEL level, |
| 77 | void *data, int buf_len ); |
| 78 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 79 | void vos_trace_display(void); |
| 80 | |
| 81 | void vos_trace_setValue( VOS_MODULE_ID module, VOS_TRACE_LEVEL level, v_U8_t on ); |
| 82 | |
| 83 | |
| 84 | // VOS_TRACE is the macro invoked to add trace messages to code. See the |
| 85 | // documenation for vos_trace_msg() for the parameters etc. for this function. |
| 86 | // |
| 87 | // NOTE: Code VOS_TRACE() macros into the source code. Do not code directly |
| 88 | // to the vos_trace_msg() function. |
| 89 | // |
| 90 | // NOTE 2: vos tracing is totally turned off if WLAN_DEBUG is *not* defined. |
| 91 | // This allows us to build 'performance' builds where we can measure performance |
| 92 | // without being bogged down by all the tracing in the code. |
| 93 | #if defined( WLAN_DEBUG ) |
| 94 | #define VOS_TRACE vos_trace_msg |
Madan Mohan Koyyalamudi | 99af06e | 2013-08-08 02:17:17 +0530 | [diff] [blame] | 95 | #define VOS_TRACE_HEX_DUMP vos_trace_hex_dump |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 96 | #else |
Madan Mohan Koyyalamudi | 99af06e | 2013-08-08 02:17:17 +0530 | [diff] [blame] | 97 | #define VOS_TRACE(arg...) |
| 98 | #define VOS_TRACE_HEX_DUMP(arg...) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 99 | #endif |
| 100 | |
| 101 | |
Jeff Johnson | 40d09f7 | 2013-11-11 12:10:25 -0800 | [diff] [blame] | 102 | void __printf(3,4) vos_snprintf(char *strBuffer, unsigned int size, |
| 103 | char *strFormat, ...); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 104 | #define VOS_SNPRINTF vos_snprintf |
| 105 | |
| 106 | #ifdef VOS_ENABLE_TRACING |
| 107 | |
| 108 | |
Madan Mohan Koyyalamudi | a53c4dc | 2012-11-13 10:35:42 -0800 | [diff] [blame] | 109 | #define VOS_ASSERT( _condition ) do { \ |
| 110 | if ( ! ( _condition ) ) \ |
| 111 | { \ |
| 112 | printk(KERN_CRIT "VOS ASSERT in %s Line %d\n", __func__, __LINE__); \ |
| 113 | WARN_ON(1); \ |
| 114 | } \ |
| 115 | } while(0) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 116 | |
| 117 | #else |
| 118 | |
| 119 | |
| 120 | // This code will be used for compilation if tracing is to be compiled out |
| 121 | // of the code so these functions/macros are 'do nothing' |
| 122 | VOS_INLINE_FN void vos_trace_msg( VOS_MODULE_ID module, ... ){} |
| 123 | |
| 124 | #define VOS_ASSERT( _condition ) |
| 125 | |
| 126 | #endif |
| 127 | |
| 128 | #ifdef PANIC_ON_BUG |
| 129 | |
Madan Mohan Koyyalamudi | a53c4dc | 2012-11-13 10:35:42 -0800 | [diff] [blame] | 130 | #define VOS_BUG( _condition ) do { \ |
| 131 | if ( ! ( _condition ) ) \ |
| 132 | { \ |
| 133 | printk(KERN_CRIT "VOS BUG in %s Line %d\n", __func__, __LINE__); \ |
| 134 | BUG_ON(1); \ |
| 135 | } \ |
| 136 | } while(0) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 137 | |
| 138 | #else |
| 139 | |
Madan Mohan Koyyalamudi | a53c4dc | 2012-11-13 10:35:42 -0800 | [diff] [blame] | 140 | #define VOS_BUG( _condition ) do { \ |
| 141 | if ( ! ( _condition ) ) \ |
| 142 | { \ |
| 143 | printk(KERN_CRIT "VOS BUG in %s Line %d\n", __func__, __LINE__); \ |
| 144 | WARN_ON(1); \ |
| 145 | } \ |
| 146 | } while(0) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 147 | |
| 148 | #endif |
| 149 | |
Katya Nigam | b901df9 | 2014-05-08 12:45:30 +0530 | [diff] [blame] | 150 | #define VOS_RETURN_ADDRESS __builtin_return_address(0) |
| 151 | |
Sravan Kumar Kairam | be03722 | 2016-06-19 12:56:24 +0530 | [diff] [blame] | 152 | #define VOS_SMP_MB smp_mb() |
| 153 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 154 | #endif |