blob: 538f58d0225807c0d80088e568c4a78412546d8b [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Abhishek Singh837adf22015-10-01 17:37:37 +05302 * Copyright (c) 2011-2015 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( __VOS_TRACE_H )
29#define __VOS_TRACE_H
30
31/**=========================================================================
32
33 \file vos_trace.h
34
35 \brief virtual Operating System Servies (vOS)
36
37 Trace, logging, and debugging definitions and APIs
38
Jeff Johnson295189b2012-06-20 16:38:30 -070039 ========================================================================*/
40
41/* $Header$ */
42
43/*--------------------------------------------------------------------------
44 Include Files
45 ------------------------------------------------------------------------*/
46#include <vos_types.h> // For VOS_MODULE_ID...
47#include <stdarg.h> // For va_list...
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -070048#include <vos_status.h>
49#include <i_vos_types.h>
Jeff Johnson295189b2012-06-20 16:38:30 -070050
51/*--------------------------------------------------------------------------
52 Type declarations
53 ------------------------------------------------------------------------*/
54
55typedef enum
56{
57 // NONE means NO traces will be logged. This value is in place for the
58 // vos_trace_setlevel() to allow the user to turn off all traces.
59 VOS_TRACE_LEVEL_NONE = 0,
60
61 // the following trace levels are the ones that 'callers' of VOS_TRACE()
62 // can specify in for the VOS_TRACE_LEVEL parameter. Traces are classified
63 // by severity (FATAL being more serious than INFO for example).
64 VOS_TRACE_LEVEL_FATAL,
65 VOS_TRACE_LEVEL_ERROR,
66 VOS_TRACE_LEVEL_WARN,
67 VOS_TRACE_LEVEL_INFO,
68 VOS_TRACE_LEVEL_INFO_HIGH,
69 VOS_TRACE_LEVEL_INFO_MED,
70 VOS_TRACE_LEVEL_INFO_LOW,
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -080071 VOS_TRACE_LEVEL_DEBUG,
Jeff Johnson295189b2012-06-20 16:38:30 -070072
73 // ALL means all trace levels will be active. This value is in place for the
74 // vos_trace_setlevel() to allow the user to turn ON all traces.
75 VOS_TRACE_LEVEL_ALL,
76
77
78 // not a real level. Used to identify the maximum number of
79 // VOS_TRACE_LEVELs defined.
80 VOS_TRACE_LEVEL_MAX
81
82} VOS_TRACE_LEVEL;
83
Sachin Ahuja715aafc2015-07-21 23:35:10 +053084/* Log types. These types are defined in mailbox*/
85typedef enum
86{
87 WLAN_MGMT_FRAME_LOGS = 0,
Hanumantha Reddy Pothulae00a7e22015-09-15 20:11:30 +053088 WLAN_FW_LOGS = 1,
Sachin Ahuja715aafc2015-07-21 23:35:10 +053089 WLAN_FW_MEMORY_DUMP = 2
90}FrameLoggingType;
91
Jeff Johnson295189b2012-06-20 16:38:30 -070092/*--------------------------------------------------------------------------
93 Preprocessor definitions and constants
94 ------------------------------------------------------------------------*/
95#define ASSERT_BUFFER_SIZE ( 512 )
96
97// below definition is obsolete and is no longer being used in BMP and WM
98// TODO: remove this once this is not used on Android
99#define VOS_ENABLE_TRACING
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700100#define MAX_VOS_TRACE_RECORDS 4000
101#define INVALID_VOS_TRACE_ADDR 0xffffffff
102#define DEFAULT_VOS_TRACE_DUMP_COUNT 0
Jeff Johnson295189b2012-06-20 16:38:30 -0700103
104#include <i_vos_trace.h>
105
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700106#ifdef TRACE_RECORD
107
Daram Sudha1f7e0e92013-12-17 07:52:31 +0530108#define CASE_RETURN_STRING( str ) \
109 case ( ( str ) ): return( (tANI_U8*)(#str) );
110
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700111#define MTRACE(p) p
112#define NO_SESSION 0xFF
113
114#else
115#define MTRACE(p) { }
116
117#endif
118
119/*--------------------------------------------------------------------------
120 Structure definition
121 ------------------------------------------------------------------------*/
122typedef struct svosTraceRecord
123{
124 v_U32_t time;
125 v_U8_t module;
126 v_U8_t code;
127 v_U8_t session;
128 v_U32_t data;
129}tvosTraceRecord, *tpvosTraceRecord;
130
131typedef struct svosTraceData
132{
133 // MTRACE logs are stored in ring buffer where head represents the position
134 // of first record, tail represents the position of last record added till
135 // now and num is the count of total record added.
136 v_U32_t head;
137 v_U32_t tail;
138 v_U32_t num;
139 v_U16_t numSinceLastDump;
140
141 //Config for controlling the trace
142 v_U8_t enable;
143 v_U16_t dumpCount; //will dump after number of records reach this number.
144
145}tvosTraceData;
146
147
Jeff Johnson295189b2012-06-20 16:38:30 -0700148/*-------------------------------------------------------------------------
149 Function declarations and documenation
150 ------------------------------------------------------------------------*/
151
152
153/*----------------------------------------------------------------------------
154
155 \brief vos_trace_setLevel() - Set the trace level for a particular module
156
157 This is an external API that allows trace levels to be set for each module.
158
159 \param level - trace level. A member of the VOS_TRACE_LEVEL
160 enumeration indicating the severity of the condition causing the
161 trace message to be issued. More severe conditions are more
162 likely to be logged.
163
164 \return nothing
165
166 \sa
167 --------------------------------------------------------------------------*/
168void vos_trace_setLevel( VOS_MODULE_ID module, VOS_TRACE_LEVEL level );
169
170/**----------------------------------------------------------------------------
171
172 \brief vos_trace_getLevel() - Get the trace level
173
174 This is an external API that returns a boolean value to signify if a
175 particular trace level is set for the specified module.
176
177 \param level - trace level. A member of the VOS_TRACE_LEVEL enumeration
178 indicating the severity of the condition causing the trace
179 message to be issued.
180
181 Note that individual trace levels are the only valid values
182 for this API. VOS_TRACE_LEVEL_NONE and VOS_TRACE_LEVEL_ALL
183 are not valid input and will return FALSE
184
185 \return VOS_FALSE - the specified trace level for the specified module is OFF
186
187 VOS_TRUE - the specified trace level for the specified module is ON
188
189 \sa vos_trace_setLevel()
190 --------------------------------------------------------------------------*/
191v_BOOL_t vos_trace_getLevel( VOS_MODULE_ID module, VOS_TRACE_LEVEL level );
192
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700193typedef void (*tpvosTraceCb) (void *pMac, tpvosTraceRecord, v_U16_t);
Padma, Santhosh Kumar9093b202015-07-21 15:37:38 +0530194typedef void (*tp_vos_state_info_cb) (void);
195
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700196void vos_trace(v_U8_t module, v_U8_t code, v_U8_t session, v_U32_t data);
197void vosTraceRegister(VOS_MODULE_ID, tpvosTraceCb);
Padma, Santhosh Kumar9093b202015-07-21 15:37:38 +0530198void vos_register_debug_callback(VOS_MODULE_ID moduleID,
199 tp_vos_state_info_cb vosStateInfoCb);
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700200VOS_STATUS vos_trace_spin_lock_init(void);
201void vosTraceInit(void);
Padma, Santhosh Kumar9093b202015-07-21 15:37:38 +0530202void vos_register_debugcb_init(void);
Katya Nigamc2f29dc2014-01-20 19:29:30 +0530203void vosTraceEnable(v_U32_t, v_U8_t enable);
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700204void vosTraceDumpAll(void*, v_U8_t, v_U8_t, v_U32_t, v_U32_t);
Padma, Santhosh Kumar9093b202015-07-21 15:37:38 +0530205void vos_state_info_dump_all(void);
Jeff Johnson295189b2012-06-20 16:38:30 -0700206#endif