• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * HealthMonitorDbg.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 HealthMonitorDbg.c
35  *  \brief This file include the HealthMonitordebug module implementation
36  *  \
37  *  \date 2-Apr-2006
38  */
39 
40 #include "tidef.h"
41 #include "MacServices.h"
42 #include "ScanCncn.h"
43 #include "scanCncnDbg.h"
44 #include "healthMonitor.h"
45 #include "ScanSrv.h"
46 #include "ScanSrvSM.h"
47 #include "TWDriver.h"
48 #include "conn.h"
49 #include "PowerSrv.h"
50 #include "PowerSrvSM.h"
51 #include "MacServices_api.h"
52 #include "HealthMonitorDbg.h"
53 #include "report.h"
54 #include "timer.h"
55 #include "DrvMain.h"
56 #include "DrvMainModules.h"
57 
58 
59 static void noScanCompleteTimer (TI_HANDLE hTWD);
60 
61 
62 /** \file HealthMonitorDbg.c
63  *  \
64  *  \date 2-Apr-2006
65  * \brief Main Recovery debug function
66  *
67  * Function Scope \e Public.\n
68  * \param pStadHandles - modules handles list.\n
69  * \param funcType       - the specific debug function.\n
70  * \param pParam         - parameters for the debug function.\n
71  */
healthMonitorDebugFunction(TStadHandlesList * pStadHandles,TI_UINT32 funcType,void * pParam)72 void healthMonitorDebugFunction (TStadHandlesList *pStadHandles, TI_UINT32 funcType, void *pParam)
73 {
74     TI_HANDLE       hHealthMonitor  = pStadHandles->hHealthMonitor;
75     TI_HANDLE       hTWD            = pStadHandles->hTWD;
76     MacServices_t  *pMacServices    = ((TTwd *)hTWD)->hMacServices;
77     TI_HANDLE       hMeasurementSRV = pMacServices->hMeasurementSRV;
78     scanSRV_t      *pScanSRV        = (scanSRV_t *)pMacServices->hScanSRV;
79     PowerSrvSM_t   *pPowerSrvSM     = (PowerSrvSM_t*)((powerSrv_t*)pMacServices->hPowerSrv)->hPowerSrvSM;
80 
81     switch (funcType)
82     {
83     case DBG_HM_PRINT_HELP:
84         printHealthMonitorDbgFunctions();
85         break;
86 
87     case DBG_HM_RECOVERY_NO_SCAN_COMPLETE:
88         /* check if the no scan complete timer is running. if so - we can stop the timer and trigger recovery */
89         if (pScanSRV->bTimerRunning)
90         {
91             /* perform the recovery directly */
92             noScanCompleteTimer (hTWD);
93         }
94         else /* scan Srv is probably entering/exiting PowerSave. We won't handle this case since it happens rarely */
95         {
96             WLAN_OS_REPORT(("Scan isn't running at the moment, so try again (make sure it is enabled)\n"));
97         }
98         break;
99 
100     case DBG_HM_RECOVERY_MBOX_FAILURE:
101         TWD_CheckMailboxCb (hTWD, TI_NOK, NULL);
102         break;
103 
104     case DBG_HM_RECOVERY_HW_AWAKE_FAILURE:
105         healthMonitor_sendFailureEvent (hHealthMonitor, HW_AWAKE_FAILURE);
106         break;
107 
108     case DBG_HM_RECOVERY_TX_STUCK:
109         healthMonitor_sendFailureEvent (hHealthMonitor, TX_STUCK);
110         break;
111 
112     case DBG_HM_DISCONNECT_TIMEOUT:
113         healthMonitor_sendFailureEvent (hHealthMonitor, DISCONNECT_TIMEOUT);
114         break;
115 
116     case DBG_HM_RECOVERY_POWER_SAVE_FAILURE:
117         tmr_StopTimer (pPowerSrvSM->hPwrSrvSmTimer);  /* stop the PS guard timer */
118         healthMonitor_sendFailureEvent (hHealthMonitor, POWER_SAVE_FAILURE);
119         break;
120 
121     case DBG_HM_RECOVERY_MEASUREMENT_FAILURE:
122         MacServices_measurementSRV_startStopTimerExpired (hMeasurementSRV, TI_FALSE);
123         break;
124 
125     case DBG_HM_RECOVERY_BUS_FAILURE:
126         healthMonitor_sendFailureEvent (hHealthMonitor, BUS_FAILURE);
127         break;
128 
129     case DBG_HM_RECOVERY_FROM_CLI:
130         drvMain_Recovery (pStadHandles->hDrvMain);
131         break;
132 
133 	case DBG_HM_RECOVERY_FROM_HW_WD_EXPIRE:
134         healthMonitor_sendFailureEvent (hHealthMonitor, HW_WD_EXPIRE);
135         break;
136 
137 	case DBG_HM_RECOVERY_RX_XFER_FAILURE:
138         healthMonitor_sendFailureEvent (hHealthMonitor, RX_XFER_FAILURE);
139         break;
140 
141     default:
142         WLAN_OS_REPORT(("Invalid function type in health monitor debug function: %d\n", funcType));
143         break;
144     }
145 }
146 
147 
148 /** \file HealthMonitorDbg.c
149  *  \
150  *  \date 2-Apr-2006
151  * \brief Prints Recovery debug menu
152  *
153  * Function Scope \e Public.\n
154  */
printHealthMonitorDbgFunctions(void)155 void printHealthMonitorDbgFunctions(void)
156 {
157     WLAN_OS_REPORT(("   HealthMonitor Debug Functions       \n"));
158     WLAN_OS_REPORT(("---------------------------------------\n"));
159     WLAN_OS_REPORT(("2000 - Print HealthMonitor Debug Help  \n"));
160     WLAN_OS_REPORT(("2001 - Trigger NO_SCAN_COMPLETE        \n"));
161     WLAN_OS_REPORT(("2002 - Trigger MBOX_FAILURE            \n"));
162     WLAN_OS_REPORT(("2003 - Trigger HW_AWAKE_FAILURE        \n"));
163     WLAN_OS_REPORT(("2004 - Trigger TX_STUCK                \n"));
164     WLAN_OS_REPORT(("2005 - Trigger DISCONNECT_TIMEOUT      \n"));
165     WLAN_OS_REPORT(("2006 - Trigger POWER_SAVE_FAILURE      \n"));
166     WLAN_OS_REPORT(("2007 - Trigger MEASUREMENT_FAILURE     \n"));
167     WLAN_OS_REPORT(("2008 - Trigger BUS_FAILURE             \n"));
168     WLAN_OS_REPORT(("2009 - Start RECOVERY_FROM_CLI         \n"));
169     WLAN_OS_REPORT(("2010 - Trigger HW_WD_EXPIRE            \n"));
170     WLAN_OS_REPORT(("2011 - Trigger RX_XFER_FAILURE         \n"));
171 }
172 
noScanCompleteTimer(TI_HANDLE hTWD)173 static void noScanCompleteTimer (TI_HANDLE hTWD)
174 {
175     MacServices_t *pMacServices = ((TTwd *)hTWD)->hMacServices;
176     scanSRV_t     *pScanSRV     = (scanSRV_t *)pMacServices->hScanSRV;
177 
178 
179     /* stop the no scan complete timer in the scan SRV */
180     tmr_StopTimer (pScanSRV->hScanSrvTimer);
181     pScanSRV->bTimerRunning = TI_FALSE;
182 
183     /* simulate the timer expiry */
184     MacServices_scanSRV_scanTimerExpired ((TI_HANDLE)pScanSRV, TI_FALSE);
185 }
186