blob: 4708a3ed1ad9a6a7b40a0c914b39e5ce0a78305f [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Sravan Kumar Kairambe037222016-06-19 12:56:24 +05302 * Copyright (c) 2012-2013, 2016 The Linux Foundation. All rights reserved.
Kiet Lam1ed83fc2014-02-19 01:15:45 -08003 *
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 Nakkala92f07d82013-01-08 21:16:34 -080020 */
Kiet Lam1ed83fc2014-02-19 01:15:45 -080021
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 Johnson295189b2012-06-20 16:38:30 -070028#if !defined( __I_VOS_TRACE_H )
29#define __I_VOS_TRACE_H
30
Jeff Johnson40d09f72013-11-11 12:10:25 -080031#if !defined(__printf)
32#define __printf(a,b)
33#endif
34
Jeff Johnson295189b2012-06-20 16:38:30 -070035/**=========================================================================
36
37 \file i_vos_trace.h
38
39 \brief Linux-specific definitions for VOSS trace
40
Jeff Johnson295189b2012-06-20 16:38:30 -070041
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 Johnson40d09f72013-11-11 12:10:25 -080073void __printf(3,4) vos_trace_msg( VOS_MODULE_ID module, VOS_TRACE_LEVEL level,
74 char *strFormat, ... );
Jeff Johnson295189b2012-06-20 16:38:30 -070075
Madan Mohan Koyyalamudi99af06e2013-08-08 02:17:17 +053076void vos_trace_hex_dump( VOS_MODULE_ID module, VOS_TRACE_LEVEL level,
77 void *data, int buf_len );
78
Jeff Johnson295189b2012-06-20 16:38:30 -070079void vos_trace_display(void);
80
81void 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 Koyyalamudi99af06e2013-08-08 02:17:17 +053095#define VOS_TRACE_HEX_DUMP vos_trace_hex_dump
Jeff Johnson295189b2012-06-20 16:38:30 -070096#else
Madan Mohan Koyyalamudi99af06e2013-08-08 02:17:17 +053097#define VOS_TRACE(arg...)
98#define VOS_TRACE_HEX_DUMP(arg...)
Jeff Johnson295189b2012-06-20 16:38:30 -070099#endif
100
101
Jeff Johnson40d09f72013-11-11 12:10:25 -0800102void __printf(3,4) vos_snprintf(char *strBuffer, unsigned int size,
103 char *strFormat, ...);
Jeff Johnson295189b2012-06-20 16:38:30 -0700104#define VOS_SNPRINTF vos_snprintf
105
106#ifdef VOS_ENABLE_TRACING
107
108
Madan Mohan Koyyalamudia53c4dc2012-11-13 10:35:42 -0800109#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 Johnson295189b2012-06-20 16:38:30 -0700116
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 Koyyalamudia53c4dc2012-11-13 10:35:42 -0800130#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 Johnson295189b2012-06-20 16:38:30 -0700137
138#else
139
Madan Mohan Koyyalamudia53c4dc2012-11-13 10:35:42 -0800140#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 Johnson295189b2012-06-20 16:38:30 -0700147
148#endif
149
Katya Nigamb901df92014-05-08 12:45:30 +0530150#define VOS_RETURN_ADDRESS __builtin_return_address(0)
151
Sravan Kumar Kairambe037222016-06-19 12:56:24 +0530152#define VOS_SMP_MB smp_mb()
153
Jeff Johnson295189b2012-06-20 16:38:30 -0700154#endif