1 /* 2 * debug.c 3 * 4 * Copyright(c) 1998 - 2009 Texas Instruments. All rights reserved. 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 11 * * Redistributions of source code must retain the above copyright 12 * notice, this list of conditions and the following disclaimer. 13 * * Redistributions in binary form must reproduce the above copyright 14 * notice, this list of conditions and the following disclaimer in 15 * the documentation and/or other materials provided with the 16 * distribution. 17 * * Neither the name Texas Instruments nor the names of its 18 * contributors may be used to endorse or promote products derived 19 * from this software without specific prior written permission. 20 * 21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 */ 33 34 /** \file reportReplvl.c 35 * \brief Report level implementation 36 * 37 * \see reportReplvl.h 38 */ 39 40 /***************************************************************************/ 41 /* */ 42 /* MODULE: reportReplvl.c */ 43 /* PURPOSE: Report level implementation */ 44 /* */ 45 /***************************************************************************/ 46 #include "tidef.h" 47 #include "debug.h" 48 #include "connDebug.h" 49 #include "siteMgrDebug.h" 50 #include "dataCtrlDbg.h" 51 #include "rsnDbg.h" 52 #include "osApi.h" 53 #include "report.h" 54 #include "context.h" 55 #include "timer.h" 56 #include "qosMngrDbg.h" 57 #include "PowerMgrDebug.h" 58 #include "roamingMgrDebug.h" 59 #include "scanCncnDbg.h" 60 #include "ScanMngrDbg.h" 61 #include "scrDbg.h" 62 #include "SoftGeminiDbg.h" 63 #include "HealthMonitorDbg.h" 64 #include "smeDebug.h" 65 #include "DrvMainModules.h" 66 #include "TWDriver.h" 67 #include "fwdriverdebug.h" 68 #include "MibDbg.h" 69 #include "TwIfDebug.h" 70 #include "tracebuf_api.h" 71 72 /* Following are the modules numbers */ 73 typedef enum 74 { 75 GENERAL_DEBUG = 0, 76 TEST_ASSOC_MODULE_PARAM = 1, 77 TEST_UTILS_MODULE_PARAM = 2, 78 TEST_RX_TX_DATA_MODULE_PARAM = 3, 79 TEST_CTRL_DATA_MODULE_PARAM = 4, 80 TEST_SITE_MGR_MODULE_PARAM = 5, 81 TEST_CONN_MODULE_PARAM = 6, 82 TEST_RSN_MODULE_PARAM = 7, 83 TEST_TWD_MODULE_PARAM = 8, 84 TEST_QOS_MNGR_MODULE_PARAM = 10, 85 TEST_MEASUREMENT_MODULE_PARAM = 11, 86 TEST_POWER_MGR_MODULE_PARAM = 12, 87 TEST_HAL_CTRL_BUFFER_PARAM = 13, 88 TEST_SCAN_CNCN_MODULE_PARAM = 14, 89 TEST_SCAN_MNGR_MODULE_PARAM = 15, 90 TEST_ROAMING_MNGR_PARAM = 16, 91 TEST_SCR_PARAM = 17, 92 TEST_SG_PARAM = 18, 93 TEST_SME_PARAM = 19, 94 TEST_HEALTH_MONITOR_PARAM = 20, 95 TEST_MIB_DEBUG_PARAM = 21, 96 TEST_FW_DEBUG_PARAM = 22, 97 TEST_TWIF_DEBUG_PARAM = 23, 98 /* 99 last module - DO NOT TOUCH! 100 */ 101 NUMBER_OF_TEST_MODULES 102 103 } testModuleParam_e; 104 105 #define MAX_PARAM_TYPE (NUMBER_OF_TEST_MODULES - 1) 106 107 /* Utils debug functions */ 108 #define DBG_UTILS_PRINT_HELP 0 109 #define DBG_UTILS_PRINT_CONTEXT_INFO 1 110 #define DBG_UTILS_PRINT_TIMER_MODULE_INFO 2 111 #define DBG_UTILS_PRINT_TRACE_BUFFER 3 112 /* General Parameters Structure */ 113 typedef struct 114 { 115 TI_UINT32 paramType; 116 TI_UINT32 value; 117 } testParam_t; 118 119 extern void measurementDebugFunction(TI_HANDLE hMeasurementMgr, TI_HANDLE hSwitchChannel, TI_HANDLE hRegulatoryDomain, TI_UINT32 funcType, void *pParam); 120 static void printMenue(void); 121 static void utilsDebugFunction (TStadHandlesList *pStadHandles, TI_UINT32 funcType, void *pParam); 122 static void printUtilsDbgFunctions (void); 123 124 125 /****************************************************************** 126 * FUNCTIONS IMPLEMENTATION * 127 *******************************************************************/ 128 129 /** 130 * \fn debugFunction 131 * \brief The debug functions dispatcher 132 * 133 * Decode from the debug functionNumber the relevant module and call its debug 134 * function with the provided parameters. 135 * The functionNumber parameter is composed as follows: 136 * Module Number = functionNumber / 100 137 * Specific Functionc = functionNumber % 100 138 * 139 * \note 140 * \param pStadHandles - Pointer to the STAD modules handles 141 * \param functionNumber - The module and function numbers composed in a decimal number 142 * \param pParam - The function parameters (optional). 143 * \return 144 * \sa 145 */ 146 TI_STATUS debugFunction(TStadHandlesList *pStadHandles, TI_UINT32 functionNumber, void *pParam) 147 { 148 TI_UINT32 moduleNumber; 149 150 moduleNumber = functionNumber / 100; 151 152 if (moduleNumber > MAX_PARAM_TYPE) 153 return PARAM_MODULE_NUMBER_INVALID; 154 155 switch (moduleNumber) 156 { 157 case GENERAL_DEBUG: 158 printMenue(); 159 break; 160 161 case TEST_ASSOC_MODULE_PARAM: 162 break; 163 164 case TEST_UTILS_MODULE_PARAM: 165 utilsDebugFunction (pStadHandles, functionNumber % 100, pParam); 166 break; 167 168 case TEST_RX_TX_DATA_MODULE_PARAM: 169 if( functionNumber < 350) 170 rxTxDebugFunction(pStadHandles->hTxCtrl, functionNumber % 100, pParam); 171 else 172 rxTxDebugFunction(pStadHandles->hRxData, functionNumber % 100, pParam); 173 break; 174 175 case TEST_CTRL_DATA_MODULE_PARAM: 176 ctrlDebugFunction(pStadHandles->hCtrlData, functionNumber % 100, pParam); 177 break; 178 179 case TEST_SITE_MGR_MODULE_PARAM: 180 siteMgrDebugFunction(pStadHandles->hSiteMgr, pStadHandles, functionNumber % 100, pParam); 181 break; 182 183 case TEST_CONN_MODULE_PARAM: 184 connDebugFunction(pStadHandles->hConn, functionNumber % 100, pParam); 185 break; 186 187 case TEST_RSN_MODULE_PARAM: 188 rsnDebugFunction(pStadHandles->hRsn, functionNumber % 100, pParam); 189 break; 190 191 case TEST_TWD_MODULE_PARAM: 192 TWD_Debug (pStadHandles->hTWD, functionNumber % 100, pParam); 193 break; 194 195 case TEST_QOS_MNGR_MODULE_PARAM: 196 qosMngrDebugFunction(pStadHandles->hQosMngr, functionNumber % 100, pParam); 197 break; 198 199 case TEST_MEASUREMENT_MODULE_PARAM: 200 measurementDebugFunction (pStadHandles->hMeasurementMgr, 201 pStadHandles->hSwitchChannel, 202 pStadHandles->hRegulatoryDomain, 203 functionNumber % 100, 204 pParam); 205 break; 206 207 case TEST_POWER_MGR_MODULE_PARAM: 208 powerMgrDebugFunction(pStadHandles->hPowerMgr, 209 functionNumber % 100, 210 pParam); 211 break; 212 213 case TEST_SCAN_CNCN_MODULE_PARAM: 214 scanConcentratorDebugFunction( pStadHandles->hScanCncn, pStadHandles->hTWD ,functionNumber % 100, pParam ); 215 break; 216 217 case TEST_SCAN_MNGR_MODULE_PARAM: 218 scanMngrDebugFunction( pStadHandles->hScanMngr, functionNumber % 100, pParam, pStadHandles->hSiteMgr, pStadHandles->hCtrlData ); 219 break; 220 221 case TEST_ROAMING_MNGR_PARAM: 222 roamingMgrDebugFunction(pStadHandles->hRoamingMngr, functionNumber % 100, pParam); 223 break; 224 225 case TEST_SCR_PARAM: 226 scrDebugFunction( pStadHandles->hSCR, functionNumber % 100, pParam ); 227 break; 228 229 case TEST_SG_PARAM: 230 SoftGeminiDebugFunction( pStadHandles->hSoftGemini, functionNumber % 100, pParam ); 231 break; 232 233 case TEST_SME_PARAM: 234 smeDebugFunction( pStadHandles->hSme, functionNumber % 100, pParam ); 235 break; 236 237 case TEST_HEALTH_MONITOR_PARAM: 238 healthMonitorDebugFunction (pStadHandles, functionNumber % 100, pParam); 239 break; 240 241 case TEST_MIB_DEBUG_PARAM: 242 MibDebugFunction(pStadHandles->hTWD, functionNumber % 100, pParam); 243 break; 244 245 case TEST_FW_DEBUG_PARAM: 246 FWDebugFunction(pStadHandles->hDrvMain, 247 pStadHandles->hOs, 248 pStadHandles->hTWD, 249 pStadHandles->hMlmeSm, 250 pStadHandles->hTxMgmtQ, 251 pStadHandles->hTxCtrl, 252 functionNumber % 100, 253 pParam/*yael , packetNum*/); 254 break; 255 256 case TEST_TWIF_DEBUG_PARAM: 257 twifDebugFunction (pStadHandles->hTWD, functionNumber % 100, pParam); 258 break; 259 260 default: 261 WLAN_OS_REPORT(("Invalid debug function module number: %d\n\n", moduleNumber)); 262 break; 263 } 264 265 return TI_OK; 266 } 267 268 static void printMenue(void) 269 { 270 WLAN_OS_REPORT((" Debug main menu (p <num>)\n")); 271 WLAN_OS_REPORT(("-----------------------------\n")); 272 273 WLAN_OS_REPORT(("Association 100\n")); 274 WLAN_OS_REPORT(("Utils 200\n")); 275 WLAN_OS_REPORT(("Tx 300\n")); 276 WLAN_OS_REPORT(("Rx 350\n")); 277 WLAN_OS_REPORT(("Ctrl 400\n")); 278 WLAN_OS_REPORT(("SiteMgr 500\n")); 279 WLAN_OS_REPORT(("Connection 600\n")); 280 WLAN_OS_REPORT(("Rsn 700\n")); 281 WLAN_OS_REPORT(("Hal Ctrl 800\n")); 282 WLAN_OS_REPORT(("QOS 1000\n")); 283 WLAN_OS_REPORT(("Measurement 1100\n")); 284 WLAN_OS_REPORT(("PowerMgr 1200\n")); 285 WLAN_OS_REPORT(("HAL Ctrl Buffer 1300\n")); 286 WLAN_OS_REPORT(("Scan concentrator 1400\n")); 287 WLAN_OS_REPORT(("Scan Manager 1500\n")); 288 WLAN_OS_REPORT(("Roaming Manager 1600\n")); 289 WLAN_OS_REPORT(("SCR 1700\n")); 290 WLAN_OS_REPORT(("Soft Gemini 1800\n")); 291 WLAN_OS_REPORT(("SME 1900\n")); 292 WLAN_OS_REPORT(("Health Monitor 2000\n")); 293 WLAN_OS_REPORT(("MIB 2100\n")); 294 WLAN_OS_REPORT(("FW Debug 2200\n")); 295 WLAN_OS_REPORT(("TwIf 2300\n")); 296 } 297 298 299 /** 300 * \fn utilsDebugFunction 301 * \brief Utils debug function 302 * 303 * \param pDrvMain - handle to the DrvMain object.\n 304 * \param funcType - the specific debug function.\n 305 * \param pParam - parameters for the debug function.\n 306 */ 307 static void utilsDebugFunction (TStadHandlesList *pStadHandles, TI_UINT32 funcType, void *pParam) 308 { 309 switch (funcType) 310 { 311 case DBG_UTILS_PRINT_HELP: 312 printUtilsDbgFunctions (); 313 break; 314 315 case DBG_UTILS_PRINT_CONTEXT_INFO: 316 context_Print (pStadHandles->hContext); 317 break; 318 319 case DBG_UTILS_PRINT_TIMER_MODULE_INFO: 320 tmr_PrintModule (pStadHandles->hTimer); 321 break; 322 323 case DBG_UTILS_PRINT_TRACE_BUFFER: 324 /* tb_printf(); */ 325 break; 326 327 default: 328 WLAN_OS_REPORT(("utilsDebugFunction(): Invalid function type: %d\n", funcType)); 329 break; 330 } 331 } 332 333 /** 334 * \fn printUtilsDbgFunctions 335 * \brief Prints Utils debug menu 336 * 337 */ 338 static void printUtilsDbgFunctions (void) 339 { 340 WLAN_OS_REPORT((" Utils Debug Functions \n")); 341 WLAN_OS_REPORT(("---------------------------\n")); 342 WLAN_OS_REPORT(("200 - Print the Utils Debug Help\n")); 343 WLAN_OS_REPORT(("201 - Print Context module info\n")); 344 WLAN_OS_REPORT(("202 - Print Timer module info\n")); 345 WLAN_OS_REPORT(("203 - Print the trace buffer\n")); 346 } 347 348