/drivers/net/wireless/tiwlan1251/common/src/Management/RecoveryMgr/recoveryMgr.c

http://github.com/CyanogenMod/cm-kernel · C · 417 lines · 184 code · 64 blank · 169 comment · 7 complexity · 5f68306287e6b0b60b4c892f65309886 MD5 · raw file

  1. /****************************************************************************
  2. **+-----------------------------------------------------------------------+**
  3. **| |**
  4. **| Copyright(c) 1998 - 2008 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. ****************************************************************************/
  35. /*******************************************************************************/
  36. /* */
  37. /* MODULE: recoveryMgr.c */
  38. /* PURPOSE: The responsibility of RecoveryMgr module is to provide main API */
  39. /* to HelthMonitor that invokes the recovery process if failure is */
  40. /* detected. It performs disable/enable inputs from outside, calls */
  41. /* restart of TWD and informs STAD modules that recovery has been */
  42. /* performed. */
  43. /* */
  44. /*******************************************************************************/
  45. #include "paramOut.h"
  46. #include "osApi.h"
  47. #include "DataCtrl_Api.h"
  48. #include "report.h"
  49. #include "recoveryMgr.h"
  50. #include "recoveryMgr_API.h"
  51. #include "TNETW_Driver_api.h"
  52. #include "healthMonitor.h"
  53. #include "PowerMgr_API.h"
  54. #include "siteMgrApi.h"
  55. #include "currBss.h"
  56. #include "whalCtrl.h"
  57. #include "TNETW_Driver.h"
  58. #include "TNETWIF.h"
  59. #include "SoftGeminiApi.h"
  60. /* static function */
  61. #ifdef USE_RECOVERY
  62. static void recoveryMgr_SM(TI_HANDLE hRecoveryMgr);
  63. static TI_STATUS recoveryMgr_notifyStadAboutRecovery(TI_HANDLE hRecoveryMgr);
  64. #endif /* USE_RECOVERY */
  65. /*******************************************************************************
  66. * PUBLIC FUNCTIONS IMPLEMENTATION *
  67. ********************************************************************************/
  68. /*************************************************************************
  69. * recoveryMgr_create *
  70. **************************************************************************
  71. * DESCRIPTION: This function initializes the RecoveryMgr module.
  72. *
  73. * INPUT: hOs - handle to Os Abstraction Layer
  74. *
  75. * RETURN: Handle to the allocated RecoveryMgr module
  76. *************************************************************************/
  77. TI_HANDLE recoveryMgr_create(TI_HANDLE hOs)
  78. {
  79. #ifdef USE_RECOVERY
  80. recoverMgr_t *hRecoveryMgr;
  81. /* allocate RecoverMgr module */
  82. hRecoveryMgr = os_memoryAlloc(hOs, (sizeof(recoverMgr_t)));
  83. if(!hRecoveryMgr)
  84. {
  85. WLAN_OS_REPORT(("Error allocating the RecoverMgr Module\n"));
  86. return NULL;
  87. }
  88. /* Reset RecoverMgr module */
  89. os_memoryZero(hOs, hRecoveryMgr, (sizeof(recoverMgr_t)));
  90. hRecoveryMgr->hOs = hOs;
  91. return(hRecoveryMgr);
  92. #else
  93. return NULL;
  94. #endif /* USE_RECOVERY */
  95. } /* recoveryMgr_create */
  96. /***************************************************************************
  97. * recoveryMgr_config *
  98. ****************************************************************************
  99. * DESCRIPTION: This function configures the recoveryMgr module
  100. *
  101. * RETURNS: OK - Configuration successful
  102. * NOK - Configuration unsuccessful
  103. ***************************************************************************/
  104. TI_STATUS recoveryMgr_config(TI_HANDLE hRecoveryMgr,
  105. TI_HANDLE hReport,
  106. TI_HANDLE hTxData,
  107. TI_HANDLE hTnetwDrv,
  108. TI_HANDLE hScr,
  109. TI_HANDLE hCurrBss,
  110. TI_HANDLE hPowerMgr,
  111. TI_HANDLE hHealthMonitor,
  112. TI_HANDLE hSoftGemini)
  113. {
  114. #ifdef USE_RECOVERY
  115. recoverMgr_t *pRecoverMgr = (recoverMgr_t *)hRecoveryMgr;
  116. /* configure modules handles */
  117. pRecoverMgr->hReport = hReport;
  118. pRecoverMgr->hTxData = hTxData;
  119. pRecoverMgr->hTnetwDrv = hTnetwDrv;
  120. pRecoverMgr->hScr = hScr;
  121. pRecoverMgr->hCurrBss = hCurrBss;
  122. pRecoverMgr->hPowerMgr = hPowerMgr;
  123. pRecoverMgr->hHealthMonitor = hHealthMonitor;
  124. pRecoverMgr->hSoftGemini = hSoftGemini;
  125. pRecoverMgr->fRecoveryInProcess = FALSE;
  126. pRecoverMgr->smState = REC_MGR_STATE_IDLE;
  127. WLAN_REPORT_INIT(pRecoverMgr->hReport, RECOVERY_MGR_MODULE_LOG,
  128. (".....RecoveryMgr configured successfully\n"));
  129. #endif /* USE_RECOVERY */
  130. return OK;
  131. } /* recoveryMgr_config */
  132. /***************************************************************************
  133. * recoveryMgr_destroy *
  134. ****************************************************************************
  135. * DESCRIPTION: This function unload the RecoverMgr module. It frees
  136. * the RecoveryMgr module
  137. *
  138. * INPUTS: hRecoveryMgr - the object
  139. *
  140. * OUTPUT:
  141. *
  142. * RETURNS: OK - Unload succesfull
  143. * NOK - Unload unsuccesfull
  144. ***************************************************************************/
  145. TI_STATUS recoveryMgr_destroy(TI_HANDLE hRecoveryMgr)
  146. {
  147. #ifdef USE_RECOVERY
  148. recoverMgr_t *pRecoverMgr = (recoverMgr_t *)hRecoveryMgr;
  149. /* free RecoverMgr Module */
  150. os_memoryFree(pRecoverMgr->hOs, pRecoverMgr, sizeof(recoverMgr_t));
  151. #endif /* USE_RECOVERY */
  152. return OK;
  153. }
  154. /**********************************************************************************************
  155. * recoveryMgr_SM()
  156. **********************************************************************************************
  157. * DESCRIPTION:
  158. ============
  159. This is the recoveryMgr state machine.
  160. The inceptive event for RecoveryMgr SM is invoking the recovery process by HelthMonitor.
  161. After disabling Outside Inputs and starting TWD Restart, RecoveryMgr SM waits end of TWD Restart,
  162. then informs STAD about recovery and enables Outside Inputs.
  163. The SM supports both Sync and Async accesses to the HW.
  164. It loops and progresses from state to state as long as the HW is accessed synchronously.
  165. Once the access is Asynchronous (TNETWIF_PENDING), it exits and is called later
  166. by the TNETWIF when the HW is ready.
  167. That's why it uses unspecified-mode accesses (e.g. TNETWIF_ReadMemOpt) which
  168. selects either Sync or Async automatically according to the platform and length.
  169. Yet, the short transactions (EOB and Interrupt-Request 32 bit writes) are done using Sync
  170. access to simplify the SM
  171. NOTE: MCS projects may require full Sync/Async support, so the Sync accesses may need to be modified.
  172. NOTE: The recoveryMgr-SM detailed description is provided in "CE-2.0 Recovery LLD.doc".
  173. **********************************************************************************************/
  174. #ifdef USE_RECOVERY
  175. static void recoveryMgr_SM(TI_HANDLE hRecoveryMgr)
  176. {
  177. recoverMgr_t *pRecoverMgr = (recoverMgr_t *)hRecoveryMgr;
  178. healthMonitor_t *pHealthMonitor = (healthMonitor_t *)pRecoverMgr->hHealthMonitor;
  179. #ifdef TI_DBG
  180. if (hRecoveryMgr == NULL)
  181. {
  182. WLAN_REPORT_ERROR(pRecoverMgr->hReport, RECOVERY_MGR_MODULE_LOG,
  183. ("recoveryMgr_SM(): **** Called with NULL handle!! ****\n"));
  184. return;
  185. }
  186. #endif /* TI_DBG */
  187. WLAN_REPORT_INFORMATION(pRecoverMgr->hReport, RECOVERY_MGR_MODULE_LOG,
  188. ("recoveryMgr_SM(): smState=%d\n", pRecoverMgr->smState));
  189. /*
  190. * Loop through the states sequence as long as the process is synchronous.
  191. * Exit when finished or if an Asynchronous process is required. In this case
  192. * the SM process will be resumed later (called back by TNETWIF).
  193. */
  194. switch (pRecoverMgr->smState)
  195. {
  196. case REC_MGR_STATE_IDLE:
  197. WLAN_REPORT_INFORMATION(pRecoverMgr->hReport, RECOVERY_MGR_MODULE_LOG,
  198. (".....REC_MGR_STATE_IDLE\n"));
  199. healthMonitor_suspendPeriodicTest(pRecoverMgr->hHealthMonitor);
  200. /* disabling Outside Inputs and starting TWD Restart */
  201. pRecoverMgr->fDisableInputsFromOs = TRUE;
  202. /* suspend TX */
  203. txData_stop(pHealthMonitor->hTxData);
  204. /* Disabling the IRQ line so the recovery will be an atomic action */
  205. os_disableIrq (pRecoverMgr->hOs);
  206. pRecoverMgr->smState = REC_MGR_STATE_WAIT_TWD_RESTART;
  207. TnetwDrv_StartRecovery(pRecoverMgr->hTnetwDrv,
  208. (void*)recoveryMgr_endOfRecovery,
  209. hRecoveryMgr);
  210. return;
  211. case REC_MGR_STATE_WAIT_TWD_RESTART:
  212. WLAN_REPORT_INFORMATION(pRecoverMgr->hReport, RECOVERY_MGR_MODULE_LOG,
  213. (".....REC_MGR_STATE_WAIT_TWD_RESTART\n"));
  214. /* informs STAD about recovery */
  215. recoveryMgr_notifyStadAboutRecovery(hRecoveryMgr);
  216. /* TX resume */
  217. txData_startAfterRecovery(pHealthMonitor->hTxData);
  218. pRecoverMgr->fDisableInputsFromOs = FALSE;
  219. /* call inside CmdMBox_SetModeNormal */
  220. whalCtrl_exitFromInitMode(((healthMonitor_t *)pRecoverMgr->hHealthMonitor)->hHalCtrl);
  221. /* send the min power level to the FW */
  222. MacServices_powerAutho_ExitFromInit(((TnetwDrv_t *)pRecoverMgr->hTnetwDrv)->hMacServices);
  223. /* Soft Gemini Section */
  224. SoftGemini_handleRecovery(pRecoverMgr->hSoftGemini);
  225. WLAN_OS_REPORT((".....recoveryMgr: End Of Recovery\n"));
  226. healthMonitor_resumePeriodicTest(pRecoverMgr->hHealthMonitor);
  227. pRecoverMgr->fRecoveryInProcess = FALSE;
  228. pRecoverMgr->smState = REC_MGR_STATE_IDLE;
  229. return; /* recovery process ended */
  230. default:
  231. WLAN_REPORT_ERROR(pRecoverMgr->hReport, RECOVERY_MGR_MODULE_LOG,
  232. ("recoveryMgr_SM(): Unexpected state, smState=%d\n", pRecoverMgr->smState));
  233. return;
  234. } /* switch (pRecoverMgr->smState) */
  235. } /* recoveryMgr_SM */
  236. #endif /* USE_RECOVERY */
  237. /***************************************************************************
  238. * recoveryMgr_recoveryProcess *
  239. ****************************************************************************
  240. * DESCRIPTION: Main interface that called if the WLAN driver detects error
  241. * during the Monitoring process.
  242. *
  243. * INPUTS: hRecoveryMgr - the object
  244. *
  245. * OUTPUT:
  246. *
  247. * RETURNS: OK - Recovery Process started
  248. * NOK - Recovery cannot started because it's in process already
  249. ***************************************************************************/
  250. TI_STATUS recoveryMgr_recoveryProcess(TI_HANDLE hRecoveryMgr)
  251. {
  252. #ifdef USE_RECOVERY
  253. recoverMgr_t *pRecoverMgr = (recoverMgr_t *)hRecoveryMgr;
  254. healthMonitor_t *pHealthMonitor = (healthMonitor_t *)pRecoverMgr->hHealthMonitor;
  255. WHAL_CTRL *pWhalCtrl = (WHAL_CTRL *)pHealthMonitor->hHalCtrl;
  256. WlanParams_T *pWlanParams = whal_ParamsGetWlanParams(pWhalCtrl->pWhalParams);
  257. if(!pWlanParams->RecoveryEnable)
  258. {
  259. WLAN_OS_REPORT(("recoveryMgr_recoveryProcess: Recovery is disabled in tiwlan.ini, abort recovery process\n"));
  260. return OK;
  261. }
  262. else
  263. WLAN_OS_REPORT((".....recoveryMgr_recoveryProcess\n"));
  264. if(pRecoverMgr->fRecoveryInProcess == FALSE)
  265. {
  266. pHealthMonitor->numOfRecoveryPerformed++;
  267. pRecoverMgr->fRecoveryInProcess = TRUE;
  268. recoveryMgr_SM(hRecoveryMgr);
  269. return OK;
  270. }
  271. else
  272. {
  273. WLAN_REPORT_ERROR(pRecoverMgr->hReport, RECOVERY_MGR_MODULE_LOG,
  274. ("recoveryProcess(): **** Recovery in process already!! ****\n"));
  275. return NOK;
  276. }
  277. #else
  278. return OK;
  279. #endif /* USE_RECOVERY */
  280. } /* recoveryMgr_recoveryProcess */
  281. /***************************************************************************
  282. * recoveryMgr_endOfRecovery *
  283. ****************************************************************************
  284. * DESCRIPTION: This function is the CB from the RecoveryCtrl that will
  285. * issue the "EndOfTwdRestart" event to the RecoveryMgr SM.
  286. * Indicates that TWD has performed its recovery.
  287. *
  288. * INPUTS: hRecoveryMgr - the object
  289. *
  290. * OUTPUT:
  291. *
  292. * RETURNS: OK - succesfull
  293. * NOK - unsuccesfull
  294. ***************************************************************************/
  295. TI_STATUS recoveryMgr_endOfRecovery(TI_HANDLE hRecoveryMgr)
  296. {
  297. #ifdef USE_RECOVERY
  298. recoverMgr_t *pRecoverMgr = (recoverMgr_t *)hRecoveryMgr;
  299. WLAN_REPORT_INIT(pRecoverMgr->hReport, RECOVERY_MGR_MODULE_LOG,
  300. (".....recoveryMgr_endOfRecovery\n"));
  301. recoveryMgr_SM(hRecoveryMgr);
  302. #endif /* USE_RECOVERY */
  303. return OK;
  304. } /* recoveryMgr_endOfRecovery */
  305. /***************************************************************************
  306. * recoveryMgr_notifyStadAboutRecovery *
  307. ****************************************************************************
  308. * DESCRIPTION: Inform STAD that recovery has been performed: inform TX,
  309. * SCR, Current BSS and Power Mgr about FW reset.
  310. *
  311. * INPUTS: hRecoveryMgr - the object
  312. *
  313. * OUTPUT:
  314. *
  315. * RETURNS: OK - succesfull
  316. * NOK - unsuccesfull
  317. ***************************************************************************/
  318. #ifdef USE_RECOVERY
  319. static TI_STATUS recoveryMgr_notifyStadAboutRecovery(TI_HANDLE hRecoveryMgr)
  320. {
  321. recoverMgr_t *pRecoverMgr = (recoverMgr_t *)hRecoveryMgr;
  322. healthMonitor_t *pHealthMonitor = (healthMonitor_t *)pRecoverMgr->hHealthMonitor;
  323. txData_recoveryIndication (pHealthMonitor->hTxData);
  324. TnetwDrv_RecoveryCtrlBlk(pHealthMonitor->hTnetwDrv);
  325. scr_notifyFWReset( pRecoverMgr->hScr );
  326. currBSS_performRecovery(pRecoverMgr->hCurrBss);
  327. PowerMgr_notifyFWReset(pRecoverMgr->hPowerMgr);
  328. return OK;
  329. } /* recoveryMgr_notifyStadAboutRecovery */
  330. #endif /* USE_RECOVERY */
  331. /***************************************************************************
  332. * recoveryMgr_recoveryProcess *
  333. ****************************************************************************
  334. * DESCRIPTION: check if Inputs From OS are Disabled.
  335. *
  336. * INPUTS: hRecoveryMgr - the object
  337. *
  338. * OUTPUT:
  339. *
  340. * RETURN: TRUE - Inputs From OS are Disabled
  341. * FALSE - Inputs From OS are not Disabled
  342. ***************************************************************************/
  343. BOOL recoveryMgr_areInputsFromOsDisabled(TI_HANDLE hRecoveryMgr)
  344. {
  345. #ifdef USE_RECOVERY
  346. recoverMgr_t *pRecoverMgr = (recoverMgr_t *)hRecoveryMgr;
  347. return (pRecoverMgr->fDisableInputsFromOs);
  348. #else
  349. return FALSE;
  350. #endif /* USE_RECOVERY */
  351. } /* recoveryMgr_recoveryProcess */