Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1 | /* |
Abhishek Singh | 837adf2 | 2015-10-01 17:37:37 +0530 | [diff] [blame] | 2 | * Copyright (c) 2011-2015 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( __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 Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 39 | ========================================================================*/ |
| 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 Chirala | 57af269 | 2013-04-10 22:39:51 -0700 | [diff] [blame] | 48 | #include <vos_status.h> |
| 49 | #include <i_vos_types.h> |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 50 | |
| 51 | /*-------------------------------------------------------------------------- |
| 52 | Type declarations |
| 53 | ------------------------------------------------------------------------*/ |
| 54 | |
| 55 | typedef 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 Yeturu | f68abd6 | 2013-02-11 14:05:06 -0800 | [diff] [blame] | 71 | VOS_TRACE_LEVEL_DEBUG, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 72 | |
| 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 Ahuja | 715aafc | 2015-07-21 23:35:10 +0530 | [diff] [blame] | 84 | /* Log types. These types are defined in mailbox*/ |
| 85 | typedef enum |
| 86 | { |
| 87 | WLAN_MGMT_FRAME_LOGS = 0, |
Hanumantha Reddy Pothula | e00a7e2 | 2015-09-15 20:11:30 +0530 | [diff] [blame] | 88 | WLAN_FW_LOGS = 1, |
Sachin Ahuja | 715aafc | 2015-07-21 23:35:10 +0530 | [diff] [blame] | 89 | WLAN_FW_MEMORY_DUMP = 2 |
| 90 | }FrameLoggingType; |
| 91 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 92 | /*-------------------------------------------------------------------------- |
| 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 Chirala | 57af269 | 2013-04-10 22:39:51 -0700 | [diff] [blame] | 100 | #define MAX_VOS_TRACE_RECORDS 4000 |
| 101 | #define INVALID_VOS_TRACE_ADDR 0xffffffff |
| 102 | #define DEFAULT_VOS_TRACE_DUMP_COUNT 0 |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 103 | |
| 104 | #include <i_vos_trace.h> |
| 105 | |
Leela Venkata Kiran Kumar Reddy Chirala | 57af269 | 2013-04-10 22:39:51 -0700 | [diff] [blame] | 106 | #ifdef TRACE_RECORD |
| 107 | |
Daram Sudha | 1f7e0e9 | 2013-12-17 07:52:31 +0530 | [diff] [blame] | 108 | #define CASE_RETURN_STRING( str ) \ |
| 109 | case ( ( str ) ): return( (tANI_U8*)(#str) ); |
| 110 | |
Leela Venkata Kiran Kumar Reddy Chirala | 57af269 | 2013-04-10 22:39:51 -0700 | [diff] [blame] | 111 | #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 | ------------------------------------------------------------------------*/ |
| 122 | typedef 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 | |
| 131 | typedef 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 Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 148 | /*------------------------------------------------------------------------- |
| 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 | --------------------------------------------------------------------------*/ |
| 168 | void 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 | --------------------------------------------------------------------------*/ |
| 191 | v_BOOL_t vos_trace_getLevel( VOS_MODULE_ID module, VOS_TRACE_LEVEL level ); |
| 192 | |
Leela Venkata Kiran Kumar Reddy Chirala | 57af269 | 2013-04-10 22:39:51 -0700 | [diff] [blame] | 193 | typedef void (*tpvosTraceCb) (void *pMac, tpvosTraceRecord, v_U16_t); |
Padma, Santhosh Kumar | 9093b20 | 2015-07-21 15:37:38 +0530 | [diff] [blame^] | 194 | typedef void (*tp_vos_state_info_cb) (void); |
| 195 | |
Leela Venkata Kiran Kumar Reddy Chirala | 57af269 | 2013-04-10 22:39:51 -0700 | [diff] [blame] | 196 | void vos_trace(v_U8_t module, v_U8_t code, v_U8_t session, v_U32_t data); |
| 197 | void vosTraceRegister(VOS_MODULE_ID, tpvosTraceCb); |
Padma, Santhosh Kumar | 9093b20 | 2015-07-21 15:37:38 +0530 | [diff] [blame^] | 198 | void vos_register_debug_callback(VOS_MODULE_ID moduleID, |
| 199 | tp_vos_state_info_cb vosStateInfoCb); |
Leela Venkata Kiran Kumar Reddy Chirala | 57af269 | 2013-04-10 22:39:51 -0700 | [diff] [blame] | 200 | VOS_STATUS vos_trace_spin_lock_init(void); |
| 201 | void vosTraceInit(void); |
Padma, Santhosh Kumar | 9093b20 | 2015-07-21 15:37:38 +0530 | [diff] [blame^] | 202 | void vos_register_debugcb_init(void); |
Katya Nigam | c2f29dc | 2014-01-20 19:29:30 +0530 | [diff] [blame] | 203 | void vosTraceEnable(v_U32_t, v_U8_t enable); |
Leela Venkata Kiran Kumar Reddy Chirala | 57af269 | 2013-04-10 22:39:51 -0700 | [diff] [blame] | 204 | void vosTraceDumpAll(void*, v_U8_t, v_U8_t, v_U32_t, v_U32_t); |
Padma, Santhosh Kumar | 9093b20 | 2015-07-21 15:37:38 +0530 | [diff] [blame^] | 205 | void vos_state_info_dump_all(void); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 206 | #endif |