PageRenderTime 48ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 1ms

/drivers/net/wireless/tiwlan1251/common/src/TNETW_Driver/Data_Srv/Tx_Ctrl_Blk/TNETW_Driver.c

http://github.com/CyanogenMod/cm-kernel
C | 996 lines | 568 code | 162 blank | 266 comment | 95 complexity | 77939d44d387034e4265b23b3a976948 MD5 | raw file
Possible License(s): AGPL-1.0, GPL-2.0, LGPL-2.0
  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: TNETW_Driver.c
  38. * PURPOSE: TNETW_Driver layer used to handle the MAC Services
  39. * and the HAL Modules
  40. *
  41. ****************************************************************************/
  42. #include "commonTypes.h"
  43. #include "report.h"
  44. #include "TNETW_Driver_api.h"
  45. #include "MacServices_api.h"
  46. #include "txCtrlBlk_api.h"
  47. #include "txHwQueue_api.h"
  48. #include "txXfer_api.h"
  49. #include "txResult_api.h"
  50. #include "rxXfer_api.h"
  51. #include "TNETWIF.h"
  52. #include "FwEvent_api.h"
  53. #include "CmdMBox_api.h"
  54. #include "CmdQueue_api.h"
  55. #include "eventMbox_api.h"
  56. #ifdef TI_DBG
  57. #include "DebugTraceXfer_api.h"
  58. #endif /* TI_DBG */
  59. #include "osApi.h"
  60. #include "TNETW_Driver.h"
  61. #include "recoveryCtrl_API.h"
  62. #include "HwInit_api.h"
  63. static TI_STATUS TnetwDrv_SetInitParams (TI_HANDLE hTnetwDrv, TnetwDrv_InitParams_t* pInitParams);
  64. #ifdef GWSI_LIB
  65. void GWSI_FinalizeDownload(TI_HANDLE hGwsiMgr, TI_STATUS eStatus);
  66. #endif
  67. void TnetwDrv_TxXferDone (TI_HANDLE hTnetwDrv, txCtrlBlkEntry_t *pPktCtrlBlk);
  68. void TnetwDrv_TxComplete (TI_HANDLE hTnetwDrv, TxResultDescriptor_t *pTxResultInfo);
  69. void TnetwDrv_TxXferDebug (TI_HANDLE hTnetwDrv, txCtrlBlkEntry_t *pPktCtrlBlk, UINT32 uDebugInfo);
  70. static void TnetwDrv_ConfigureCb (TI_HANDLE hTnetwDrv);
  71. static void TnetwDrv_ConfigureCb1 (TI_HANDLE hTnetwDrv);
  72. /****************************************************************************/
  73. /****************************************************************************/
  74. /* TnetwDrv_Create()
  75. ****************************************************************************
  76. * DESCRIPTION: Create the Module
  77. *
  78. * INPUTS: Handle to the OS
  79. *
  80. * OUTPUT:
  81. *
  82. * RETURNS: Handle to the module on success or NULL on failure
  83. ****************************************************************************/
  84. TI_HANDLE TnetwDrv_Create (TI_HANDLE hOs)
  85. {
  86. TnetwDrv_t *pTnetwDrv;
  87. /* Allocate the TNETW_Driver module */
  88. pTnetwDrv = (TnetwDrv_t *)os_memoryAlloc (hOs, sizeof(TnetwDrv_t));
  89. if (pTnetwDrv == NULL)
  90. return NULL;
  91. os_memoryZero (hOs, pTnetwDrv, sizeof(TnetwDrv_t));
  92. pTnetwDrv->hOs = hOs;
  93. /* Create the HAL Ctrl module */
  94. pTnetwDrv->hHalCtrl = whalCtrl_Create(hOs);
  95. if (pTnetwDrv->hHalCtrl == NULL)
  96. {
  97. WLAN_OS_REPORT(("TnetwDrv whalCtrl_Create failed!!!\n"));
  98. TnetwDrv_Destroy((TI_HANDLE)pTnetwDrv);
  99. return NULL;
  100. }
  101. pTnetwDrv->hTNETWIF = whalCtrl_GetTnetwifHandle (pTnetwDrv->hHalCtrl);
  102. /* Create the MAC Services module */
  103. pTnetwDrv->hMacServices = MacServices_create(hOs);
  104. if (pTnetwDrv->hMacServices == NULL)
  105. {
  106. WLAN_OS_REPORT(("TnetwDrv MacServices_create failed!!!\n"));
  107. TnetwDrv_Destroy((TI_HANDLE)pTnetwDrv);
  108. return NULL;
  109. }
  110. /* Create the Ctrl module */
  111. pTnetwDrv->hCmdQueue = CmdQueue_Create(hOs);
  112. if (pTnetwDrv->hCmdQueue == NULL)
  113. {
  114. WLAN_OS_REPORT(("TnetwDrv CmdQueue_Create failed!!!\n"));
  115. TnetwDrv_Destroy((TI_HANDLE)pTnetwDrv);
  116. return NULL;
  117. }
  118. /*
  119. * Create the FW-Transfer modules:
  120. */
  121. pTnetwDrv->hTxXfer = txXfer_Create(hOs);
  122. if (pTnetwDrv->hTxXfer == NULL)
  123. {
  124. WLAN_OS_REPORT(("TnetwDrv txXfer_Create failed!!!\n"));
  125. TnetwDrv_Destroy((TI_HANDLE)pTnetwDrv);
  126. return NULL;
  127. }
  128. pTnetwDrv->hTxResult = txResult_Create(hOs);
  129. if (pTnetwDrv->hTxResult == NULL)
  130. {
  131. WLAN_OS_REPORT(("TnetwDrv txResult_Create failed!!!\n"));
  132. TnetwDrv_Destroy((TI_HANDLE)pTnetwDrv);
  133. return NULL;
  134. }
  135. pTnetwDrv->hRxXfer = rxXfer_Create(hOs);
  136. if (pTnetwDrv->hRxXfer == NULL)
  137. {
  138. WLAN_OS_REPORT(("TnetwDrv rxXfer_Create failed!!!\n"));
  139. TnetwDrv_Destroy((TI_HANDLE)pTnetwDrv);
  140. return NULL;
  141. }
  142. pTnetwDrv->hFwEvent = FwEvent_Create(hOs);
  143. if (pTnetwDrv->hFwEvent == NULL)
  144. {
  145. WLAN_OS_REPORT(("TnetwDrv FwEvent_Create failed!!!\n"));
  146. TnetwDrv_Destroy((TI_HANDLE)pTnetwDrv);
  147. return NULL;
  148. }
  149. pTnetwDrv->hEventMbox = eventMbox_Create(hOs);
  150. if (pTnetwDrv->hEventMbox == NULL)
  151. {
  152. WLAN_OS_REPORT(("TnetwDrv eventMbox_Create failed!!!\n"));
  153. TnetwDrv_Destroy((TI_HANDLE)pTnetwDrv);
  154. return NULL;
  155. }
  156. #ifdef TI_DBG
  157. pTnetwDrv->hDebugTrace = debugTrace_Create(hOs);
  158. if (pTnetwDrv->hDebugTrace == NULL)
  159. {
  160. WLAN_OS_REPORT(("TnetwDrv debugTrace_Create failed!!!\n"));
  161. TnetwDrv_Destroy((TI_HANDLE)pTnetwDrv);
  162. return NULL;
  163. }
  164. #endif /* TI_DBG */
  165. pTnetwDrv->hCmdMBox = CmdMBox_Create(hOs);
  166. if (pTnetwDrv->hCmdMBox == NULL)
  167. {
  168. WLAN_OS_REPORT(("TnetwDrv CmdMBox_Create failed!!!\n"));
  169. TnetwDrv_Destroy((TI_HANDLE)pTnetwDrv);
  170. return NULL;
  171. }
  172. /*
  173. * Create the Data-Services modules:
  174. */
  175. pTnetwDrv->hTxCtrlBlk = txCtrlBlk_Create(hOs);
  176. if (pTnetwDrv->hTxCtrlBlk == NULL)
  177. {
  178. WLAN_OS_REPORT(("TnetwDrv txCtrlBlk_Create failed!!!\n"));
  179. TnetwDrv_Destroy((TI_HANDLE)pTnetwDrv);
  180. return NULL;
  181. }
  182. pTnetwDrv->hTxHwQueue = txHwQueue_Create(hOs);
  183. if (pTnetwDrv->hTxHwQueue == NULL)
  184. {
  185. WLAN_OS_REPORT(("TnetwDrv txHwQueue_Create failed!!!\n"));
  186. TnetwDrv_Destroy((TI_HANDLE)pTnetwDrv);
  187. return NULL;
  188. }
  189. #if !defined(GWSI_DRIVER) && !defined(GWSI_LIB)
  190. pTnetwDrv->hRecoveryCtrl = recoveryCtrl_create(hOs);
  191. #ifdef USE_RECOVERY
  192. if (pTnetwDrv->hRecoveryCtrl == NULL)
  193. {
  194. WLAN_OS_REPORT(("TnetwDrv recoveryCtrl_create failed!!!\n"));
  195. TnetwDrv_Destroy((TI_HANDLE)pTnetwDrv);
  196. return NULL;
  197. }
  198. #endif /* USE_RECOVERY */
  199. pTnetwDrv->hHwInit = hwInit_create(hOs);
  200. #ifdef USE_RECOVERY
  201. if (pTnetwDrv->hHwInit == NULL)
  202. {
  203. WLAN_OS_REPORT(("TnetwDrv hwInit_create failed!!!\n"));
  204. TnetwDrv_Destroy((TI_HANDLE)pTnetwDrv);
  205. return NULL;
  206. }
  207. #endif /* USE_RECOVERY */
  208. pTnetwDrv->bRecoveryFlag = FALSE; /* init value is not Recovery */
  209. #endif
  210. WLAN_INIT_REPORT (("TnetwDrv_Create: CREATED !!!\n"));
  211. return (TI_HANDLE)pTnetwDrv;
  212. }
  213. /****************************************************************************/
  214. /* TnetwDrv_Destroy()
  215. ****************************************************************************
  216. * DESCRIPTION: Clear The module
  217. *
  218. * INPUTS: Handle to the module
  219. *
  220. * OUTPUT:
  221. *
  222. * RETURNS:
  223. ****************************************************************************/
  224. void TnetwDrv_Destroy (TI_HANDLE hTnetwDrv)
  225. {
  226. TnetwDrv_t *pTnetwDrv = (TnetwDrv_t *)hTnetwDrv;
  227. WLAN_INIT_REPORT(("TnetwDrv_Destroy !!!\n"));
  228. if (pTnetwDrv == NULL)
  229. {
  230. return;
  231. }
  232. /* free the hal ctrl */
  233. if (pTnetwDrv->hHalCtrl != NULL)
  234. {
  235. whalCtrl_Destroy(pTnetwDrv->hHalCtrl);
  236. pTnetwDrv->hHalCtrl = NULL;
  237. }
  238. WLAN_INIT_REPORT(("TNETW_Driver_Destroy hHalCtrl released!!!\n"));
  239. /* free the MAC Services */
  240. if (pTnetwDrv->hMacServices != NULL)
  241. {
  242. MacServices_destroy(pTnetwDrv->hMacServices);
  243. pTnetwDrv->hMacServices = NULL;
  244. }
  245. WLAN_INIT_REPORT(("TNETW_Driver_Destroy hMacServices released!!!\n"));
  246. /*
  247. * Free the Ctrl modules
  248. */
  249. if (pTnetwDrv->hCmdQueue != NULL)
  250. {
  251. CmdQueue_Destroy(pTnetwDrv->hCmdQueue);
  252. pTnetwDrv->hCmdQueue = NULL;
  253. }
  254. /*
  255. * Free the FW-Transfer modules:
  256. */
  257. if (pTnetwDrv->hTxXfer != NULL)
  258. {
  259. txXfer_Destroy(pTnetwDrv->hTxXfer);
  260. pTnetwDrv->hTxXfer = NULL;
  261. }
  262. if (pTnetwDrv->hTxResult != NULL)
  263. {
  264. txResult_Destroy(pTnetwDrv->hTxResult);
  265. pTnetwDrv->hTxResult = NULL;
  266. }
  267. if (pTnetwDrv->hRxXfer != NULL)
  268. {
  269. rxXfer_Destroy(pTnetwDrv->hRxXfer);
  270. pTnetwDrv->hRxXfer = NULL;
  271. }
  272. if (pTnetwDrv->hEventMbox != NULL)
  273. {
  274. eventMbox_Destroy(pTnetwDrv->hEventMbox);
  275. pTnetwDrv->hEventMbox = NULL;
  276. }
  277. #ifdef TI_DBG
  278. if (pTnetwDrv->hDebugTrace != NULL)
  279. {
  280. debugTrace_Destroy(pTnetwDrv->hDebugTrace);
  281. pTnetwDrv->hDebugTrace = NULL;
  282. }
  283. #endif /* TI_DBG */
  284. if (pTnetwDrv->hFwEvent != NULL)
  285. {
  286. FwEvent_Destroy(pTnetwDrv->hFwEvent);
  287. pTnetwDrv->hFwEvent = NULL;
  288. }
  289. if (pTnetwDrv->hCmdMBox != NULL)
  290. {
  291. CmdMBox_Destroy(pTnetwDrv->hCmdMBox);
  292. pTnetwDrv->hCmdMBox = NULL;
  293. }
  294. /*
  295. * Free the Data-Services modules:
  296. */
  297. if (pTnetwDrv->hTxCtrlBlk != NULL)
  298. {
  299. txCtrlBlk_Destroy(pTnetwDrv->hTxCtrlBlk);
  300. pTnetwDrv->hTxCtrlBlk = NULL;
  301. }
  302. if (pTnetwDrv->hTxHwQueue != NULL)
  303. {
  304. txHwQueue_Destroy(pTnetwDrv->hTxHwQueue);
  305. pTnetwDrv->hTxHwQueue = NULL;
  306. }
  307. #if !defined(GWSI_DRIVER) && !defined(GWSI_LIB)
  308. if (pTnetwDrv->hRecoveryCtrl != NULL)
  309. {
  310. recoveryCtrl_destroy(pTnetwDrv->hRecoveryCtrl);
  311. pTnetwDrv->hRecoveryCtrl = NULL;
  312. }
  313. if (pTnetwDrv->hHwInit != NULL)
  314. {
  315. hwInit_destroy(pTnetwDrv->hHwInit);
  316. pTnetwDrv->hHwInit = NULL;
  317. }
  318. #endif
  319. /* free the TNETW driver */
  320. if ( NULL != pTnetwDrv->pInitTableCopy )
  321. {
  322. os_memoryFree( pTnetwDrv->hOs, pTnetwDrv->pInitTableCopy, sizeof(TnetwDrv_InitParams_t) );
  323. pTnetwDrv->pInitTableCopy = NULL;
  324. }
  325. os_memoryFree(pTnetwDrv->hOs, (TI_HANDLE)pTnetwDrv, sizeof(TnetwDrv_t));
  326. pTnetwDrv = NULL;
  327. WLAN_INIT_REPORT(("TNETW_Driver_Destroy pTNETW_Driver released!!!\n"));
  328. return;
  329. }
  330. /****************************************************************************/
  331. /* TnetwDrv_Init()
  332. ****************************************************************************
  333. * DESCRIPTION: TNETW Driver Init
  334. *
  335. * INPUTS:
  336. *
  337. * OUTPUT:
  338. *
  339. * RETURNS:
  340. ****************************************************************************/
  341. TI_STATUS TnetwDrv_Init (TI_HANDLE hTnetwDrv, TI_HANDLE hReport, TI_HANDLE hMemMgr, TI_HANDLE hUser, UINT32 *pFWImage, TnetwDrv_InitParams_t* pInitParams, TnetDrv_callback_t fUserConf)
  342. {
  343. TnetwDrv_t *pTnetwDrv = (TnetwDrv_t *)hTnetwDrv;
  344. whalCtrl_config_t whalCtrl_config;
  345. TI_STATUS status;
  346. pTnetwDrv->bInitSuccess = FALSE;
  347. pTnetwDrv->hUser = hUser;
  348. pTnetwDrv->fUserConf = fUserConf;
  349. pTnetwDrv->hReport = hReport;
  350. pTnetwDrv->hMemMgr = hMemMgr;
  351. pTnetwDrv->hWhalParams = whalCtrl_GetWhalParams (pTnetwDrv->hHalCtrl);
  352. WLAN_REPORT_INIT(pTnetwDrv->hReport, HAL_CTRL_MODULE_LOG,
  353. ("TnetwDrv_Init %x\n",hReport));
  354. if (NULL != pInitParams)
  355. {
  356. if (OK != TnetwDrv_SetInitParams (hTnetwDrv, (TnetwDrv_InitParams_t *)pInitParams))
  357. {
  358. TnetwDrv_Destroy (hTnetwDrv);
  359. return NOK;
  360. }
  361. }
  362. /*
  363. * Configure the HAL Ctrl
  364. */
  365. whalCtrl_config.hMemMgr = hMemMgr;
  366. whalCtrl_config.hReport = hReport;
  367. whalCtrl_config.hFwEvent = pTnetwDrv->hFwEvent;
  368. whalCtrl_config.hRxXfer = pTnetwDrv->hRxXfer;
  369. whalCtrl_config.hTxXfer = pTnetwDrv->hTxXfer;
  370. whalCtrl_config.hTxHwQueue = pTnetwDrv->hTxHwQueue;
  371. whalCtrl_config.hTxResult = pTnetwDrv->hTxResult;
  372. whalCtrl_config.hEventMbox = pTnetwDrv->hEventMbox;
  373. /* CB at the end of TnetwDrv_Configure(). not called if no registration was done */
  374. pTnetwDrv->fConfigureCmplteteCB = NULL;
  375. pTnetwDrv->hConfigureCompleteOBj = NULL;
  376. pTnetwDrv->fConfigureEndCB = TnetwDrv_ConfigureCb1;
  377. pTnetwDrv->fConfigureEndObj= hTnetwDrv;
  378. whalCtrl_config.hCmdQueue = pTnetwDrv->hCmdQueue;
  379. #ifdef TI_DBG
  380. whalCtrl_config.hDebugTrace = pTnetwDrv->hDebugTrace;
  381. #endif /* TI_DBG */
  382. /* Call the config func */
  383. if ((status = whalCtrl_Config (pTnetwDrv->hHalCtrl, hTnetwDrv, &whalCtrl_config, pFWImage)) == TNETWIF_ERROR)
  384. {
  385. WLAN_OS_REPORT(("TNETW_Driver whalCtrl_Config failed!!!\n"));
  386. TnetwDrv_Destroy (hTnetwDrv);
  387. return NOK;
  388. }
  389. return status;
  390. }
  391. /****************************************************************************
  392. * DESCRIPTION: Configure the TNET Driver Module callback
  393. *
  394. * INPUTS:
  395. *
  396. * OUTPUT:
  397. *
  398. * RETURNS: OK if succeeded, NOK if failed in HW configuration.
  399. ****************************************************************************/
  400. void TnetwDrv_ConfigureCb (TI_HANDLE hTnetwDrv)
  401. {
  402. TnetwDrv_t *pTnetwDrv = (TnetwDrv_t *)hTnetwDrv;
  403. /* Configure the Tx-HW-Queue module */
  404. txHwQueue_Config (pTnetwDrv->hTxHwQueue, pTnetwDrv->pInitTableCopy);
  405. /* Configure the TX XFER module */
  406. txXfer_config(pTnetwDrv->hTxXfer, pTnetwDrv->pInitTableCopy);
  407. /* Configure the MAC services */
  408. MacServices_config (pTnetwDrv->hMacServices, pTnetwDrv->pInitTableCopy);
  409. #if !defined(GWSI_DRIVER) && !defined(GWSI_LIB)
  410. recoveryCtrl_config(pTnetwDrv->hRecoveryCtrl,
  411. pTnetwDrv->hReport,
  412. pTnetwDrv->hTNETWIF,
  413. pTnetwDrv->hTxXfer,
  414. pTnetwDrv->hRxXfer,
  415. pTnetwDrv->hTxResult,
  416. pTnetwDrv->hMacServices,
  417. pTnetwDrv->hTxCtrlBlk,
  418. pTnetwDrv->hTxHwQueue,
  419. pTnetwDrv->hHalCtrl,
  420. pTnetwDrv->hHwIntr,
  421. pTnetwDrv->hWhalParams,
  422. pTnetwDrv->hCmdQueue,
  423. pTnetwDrv->hFwEvent,
  424. pTnetwDrv->hCmdMBox,
  425. pTnetwDrv->hHwInit);
  426. hwInit_config(pTnetwDrv->hHwInit, pTnetwDrv->hReport, pTnetwDrv->hTNETWIF);
  427. #endif
  428. /* Register the Data Path callback functions */
  429. TnetwDrv_Register_CB (pTnetwDrv, TNETW_DRIVER_TX_XFER_SEND_PKT_TRANSFER, (void *)TnetwDrv_TxXferDone, hTnetwDrv);
  430. /* Register the send packet debug callback */
  431. #ifdef TI_DBG
  432. TnetwDrv_Register_CB (pTnetwDrv, TNETW_DRIVER_TX_XFER_SEND_PKT_DEBUG, (void *)TnetwDrv_TxXferDebug, hTnetwDrv);
  433. #endif
  434. /* Register the send packet complete callback */
  435. TnetwDrv_Register_CB (pTnetwDrv, TNETW_DRIVER_TX_RESULT_SEND_PKT_COMPLETE, (void *)TnetwDrv_TxComplete, hTnetwDrv);
  436. /* Call user application configuration callback */
  437. if (pTnetwDrv->fUserConf)
  438. (*pTnetwDrv->fUserConf) (pTnetwDrv->hUser);
  439. }
  440. /****************************************************************************
  441. * DESCRIPTION: Configure the TNET Driver Module callback
  442. *
  443. * INPUTS:
  444. *
  445. * OUTPUT:
  446. *
  447. * RETURNS: OK if succeeded, NOK if failed in HW configuration.
  448. ****************************************************************************/
  449. void TnetwDrv_ConfigureCb1 (TI_HANDLE hTnetwDrv)
  450. {
  451. TnetwDrv_t *pTnetwDrv = (TnetwDrv_t *)hTnetwDrv;
  452. /* if the configure complete function was registered, we call it here - end of TnetwDrv_Configure stage */
  453. if (pTnetwDrv->fConfigureCmplteteCB)
  454. {
  455. pTnetwDrv->fConfigureCmplteteCB(pTnetwDrv->hConfigureCompleteOBj);
  456. }
  457. #ifndef GWSI_LIB
  458. /*
  459. * This will be the last thing that will be done here so all the download
  460. * will go back down to HALto send FINISH to TNETWIF where it began
  461. */
  462. os_Complete (pTnetwDrv->hOs);
  463. #endif
  464. }
  465. /****************************************************************************
  466. * DESCRIPTION: Configure the TNET Driver Module
  467. *
  468. * INPUTS:
  469. *
  470. * OUTPUT:
  471. *
  472. * RETURNS: OK if succeeded, NOK if failed in HW configuration.
  473. ****************************************************************************/
  474. TI_STATUS TnetwDrv_Configure (TI_HANDLE hTnetwDrv, TnetwDrv_InitParams_t* pInitParams)
  475. {
  476. TnetwDrv_t *pTnetwDrv = (TnetwDrv_t *)hTnetwDrv;
  477. TnetwDrv_InitParams_t* pInitParam;
  478. if (pTnetwDrv->bInitSuccess)
  479. {
  480. /* If called with init params as null - it means that this is a recovery */
  481. if (NULL != pInitParams)
  482. {
  483. if (OK != TnetwDrv_SetInitParams (hTnetwDrv, pInitParams))
  484. {
  485. return NOK;
  486. }
  487. }
  488. #if !defined(GWSI_DRIVER) && !defined(GWSI_LIB)
  489. if(pTnetwDrv->bRecoveryFlag == TRUE)
  490. pInitParam = NULL;
  491. else
  492. #endif
  493. pInitParam = pTnetwDrv->pInitTableCopy;
  494. /* If it's recovery call function with NULL instead of ini-file params */
  495. if (whalCtrl_ConfigHw (pTnetwDrv->hHalCtrl,
  496. pInitParam,
  497. (void *)TnetwDrv_ConfigureCb,
  498. hTnetwDrv) != OK)
  499. {
  500. WLAN_REPORT_ERROR(pTnetwDrv->hReport, TNETW_DRV_MODULE_LOG,("\n.....WhalCtrl configuration failure \n"));
  501. return NOK;
  502. }
  503. return OK;
  504. }
  505. return NOK;
  506. }
  507. /****************************************************************************
  508. * TnetwDrv_FinalizeDownload()
  509. ****************************************************************************
  510. * DESCRIPTION: Finalize all the remaining initialization after the downloaD HAS FINISHED
  511. Register the ERRORS indications events to the FW
  512. *
  513. * INPUTS:
  514. *
  515. * OUTPUT: None
  516. *
  517. * RETURNS: OK or NOK
  518. ****************************************************************************/
  519. TI_STATUS TnetwDrv_FinalizeDownload (TI_HANDLE hTnetwDrv)
  520. {
  521. TnetwDrv_t *pTnetwDrv = (TnetwDrv_t *)hTnetwDrv;
  522. /* Here at the end call the Initialize Complete callback that will release the user Init semaphore */
  523. WLAN_REPORT_INIT(pTnetwDrv->hReport, HAL_CTRL_MODULE_LOG,
  524. ("hTNETW_Driver %x!!!!!\n", hTnetwDrv));
  525. /* Here at the end call the Initialize Complete callback that will release the user Init semaphore */
  526. WLAN_REPORT_INIT(pTnetwDrv->hReport, HAL_CTRL_MODULE_LOG,
  527. ("Call MacServices_init!!!!!\n"));
  528. /*
  529. * Initialize the FW-Transfer modules
  530. */
  531. txXfer_init (pTnetwDrv->hTxXfer, pTnetwDrv->hReport, pTnetwDrv->hTNETWIF, pTnetwDrv->hTxResult);
  532. txResult_init (pTnetwDrv->hTxResult, pTnetwDrv->hReport, pTnetwDrv->hTNETWIF, pTnetwDrv->hFwEvent);
  533. rxXfer_Config (pTnetwDrv->hRxXfer, pTnetwDrv->hFwEvent, pTnetwDrv->hMemMgr, pTnetwDrv->hReport,pTnetwDrv->hTNETWIF);
  534. #ifdef TI_DBG
  535. debugTrace_Config (pTnetwDrv->hDebugTrace,
  536. pTnetwDrv->hWhalParams,
  537. pTnetwDrv->hReport,
  538. pTnetwDrv->hMemMgr,
  539. pTnetwDrv->hTNETWIF,
  540. pTnetwDrv->hFwEvent);
  541. #endif /* TI_DBG */
  542. /*
  543. * Initialize the MAC Services
  544. */
  545. MacServices_init (pTnetwDrv->hMacServices,
  546. pTnetwDrv->hReport,
  547. pTnetwDrv->hHalCtrl);
  548. /*
  549. * Initialize the Data-Services modules
  550. */
  551. txCtrlBlk_init (pTnetwDrv->hTxCtrlBlk, pTnetwDrv->hReport);
  552. txHwQueue_init (pTnetwDrv->hTxHwQueue, pTnetwDrv->hReport, pTnetwDrv->hWhalParams);
  553. /* Here at the end call the Initialize Complete callback that will release the user Init semaphore */
  554. WLAN_REPORT_INIT(pTnetwDrv->hReport, HAL_CTRL_MODULE_LOG,
  555. ("Before sending the Init Complet callback !!!!!\n"));
  556. /* Sign that init has succeeded */
  557. pTnetwDrv->bInitSuccess = TRUE;
  558. /* When working with GWSI Call the Init Complete callback */
  559. #ifdef GWSI_LIB
  560. /*
  561. * The callback function does not need the handle of the GWSI
  562. * since it takes it from the global handle
  563. */
  564. GWSI_FinalizeDownload (pTnetwDrv->hUser, OK);
  565. /*
  566. * When working with CORE call the os_Init_Complete
  567. * that will release the OS semaphore that the
  568. * user is lock on it in the esta_drb to go on call the next stage
  569. */
  570. #else
  571. /* Here at the end call the Initialize Complete callback that will release the user Init semaphore */
  572. WLAN_REPORT_INIT(pTnetwDrv->hReport, HAL_CTRL_MODULE_LOG,
  573. ("Call os_Complete !!!!!\n"));
  574. /* Start configuring driver */
  575. if (TnetwDrv_Configure (hTnetwDrv, NULL) != OK)
  576. {
  577. WLAN_REPORT_ERROR (pTnetwDrv->hReport, TNETW_DRV_MODULE_LOG,
  578. ("TnetwDrv_FinalizeDownload: configuration failure!\n"));
  579. }
  580. #endif
  581. return TNETWIF_COMPLETE;
  582. }
  583. /****************************************************************************
  584. * TnetwDrv_FinalizeOnFailue()
  585. ****************************************************************************
  586. * DESCRIPTION: Finalize all the initialization upon failure
  587. *
  588. * INPUTS:
  589. *
  590. * OUTPUT: None
  591. *
  592. * RETURNS: OK or NOK
  593. ****************************************************************************/
  594. TI_STATUS TnetwDrv_FinalizeOnFailure (TI_HANDLE hTNETW_Driver)
  595. {
  596. TnetwDrv_t *pTnetwDrv = (TnetwDrv_t *)hTNETW_Driver;
  597. #ifdef GWSI_LIB
  598. /* Stop Init phase of GWSI and return TNETWIF_ERROR */
  599. GWSI_FinalizeDownload (pTnetwDrv->hUser, TNETWIF_ERROR);
  600. /* When working with CORE call the os_Init_Complete that will release the OS semaphore taht the
  601. user is lock on it in the esta_drb to go on call the next stage */
  602. #else
  603. /* Here at the end call the Initialize Complete callback that will release the user Init semaphore */
  604. WLAN_REPORT_INIT (pTnetwDrv->hReport, HAL_CTRL_MODULE_LOG, ("Call os_Complete !!!!!\n"));
  605. /*
  606. * This will be the last thing that will be done here so all the download
  607. * will go back down to HAL to send FINISH to TNETWIF where it began
  608. */
  609. os_Complete (pTnetwDrv->hOs);
  610. #endif
  611. return TNETWIF_COMPLETE;
  612. }
  613. /****************************************************************************/
  614. /* TNETW_Driver_Register_CB()
  615. ****************************************************************************
  616. * DESCRIPTION: Register the MAC Services and the HAL modules callbacks
  617. *
  618. * INPUTS:
  619. *
  620. * OUTPUT:
  621. *
  622. * RETURNS:
  623. ****************************************************************************/
  624. void TnetwDrv_Register_CB (TI_HANDLE hTnetwDrv,tiUINT32 EventID,void *CBFunc, void *pData)
  625. {
  626. TnetwDrv_t * pTnetwDrv = (TnetwDrv_t *)hTnetwDrv;
  627. WLAN_REPORT_INFORMATION(pTnetwDrv->hReport, TNETW_DRV_MODULE_LOG, ("TnetwDrv_Register_CB (Value = 0x%x)\n", EventID));
  628. /* First detect which module is the owner */
  629. switch((tiUINT16)(EventID & TNETW_DRIVER_CB_MODULE_OWNER_MASK))
  630. {
  631. case TNETW_DRIVER_TX_XFER_OWNER:
  632. EventID &= TNETW_DRIVER_CB_TYPE_MASK;
  633. WLAN_REPORT_INFORMATION(pTnetwDrv->hReport, TNETW_DRV_MODULE_LOG,("TnetwDrv_Register_CB: TNETW_DRIVER_TX_XFER_OWNER\n"));
  634. txXfer_RegisterCB(pTnetwDrv->hTxXfer, EventID, CBFunc, pData);
  635. break;
  636. case TNETW_DRIVER_TX_RESULT_OWNER:
  637. EventID &= TNETW_DRIVER_CB_TYPE_MASK;
  638. WLAN_REPORT_INFORMATION(pTnetwDrv->hReport, TNETW_DRV_MODULE_LOG,("TnetwDrv_Register_CB: TNETW_DRIVER_TX_RESULT_OWNER\n"));
  639. txResult_RegisterCB(pTnetwDrv->hTxResult, EventID, CBFunc, pData);
  640. break;
  641. case TNETW_DRIVER_RX_XFER_OWNER:
  642. EventID &= TNETW_DRIVER_CB_TYPE_MASK;
  643. WLAN_REPORT_INFORMATION(pTnetwDrv->hReport, TNETW_DRV_MODULE_LOG,("TnetwDrv_Register_CB: TNETW_DRIVER_RX_XFER_OWNER\n"));
  644. rxXfer_Register_CB(pTnetwDrv->hRxXfer, EventID,CBFunc,pData);
  645. break;
  646. case TNETW_DRIVER_HAL_CTRL_OWNER:
  647. EventID &= TNETW_DRIVER_CB_TYPE_MASK;
  648. whalCtrl_Register_CB(pTnetwDrv->hHalCtrl, EventID,CBFunc,pData);
  649. break;
  650. case TNETW_DRIVER_MAC_SERVICES_OWNER:
  651. switch (EventID & TNETW_DRIVER_CB_TYPE_MASK)
  652. {
  653. case HAL_EVENT_SCAN_CMPLT:
  654. MacServices_scanSRV_registerScanCompleteCB(pTnetwDrv->hMacServices, (scan_srvCompleteCB_t)CBFunc, pData);
  655. break;
  656. default:
  657. WLAN_REPORT_WARNING(pTnetwDrv->hReport, TNETW_DRV_MODULE_LOG,("TNETW_DRIVER_MAC_SERVICES_OWNER - Illegal value\n"));
  658. }
  659. break;
  660. case TNETW_DRIVER_TWD_OWNER:
  661. WLAN_REPORT_INFORMATION(pTnetwDrv->hReport, TNETW_DRV_MODULE_LOG,("TnetwDrv_Register_CB: TNETW_DRIVER_TWD_OWNER\n"));
  662. pTnetwDrv->fConfigureCmplteteCB = (TnetDrv_callback_t)CBFunc;
  663. pTnetwDrv->hConfigureCompleteOBj = (TI_HANDLE)pData;
  664. break;
  665. default:
  666. if (EventID == HAL_INTERNAL_EVENT_FAILURE)
  667. {
  668. /* register the Hal failure event callback including the RX
  669. in the Hal Cttl the errors are :
  670. MBOX_FAILURE,
  671. BUS_ERROR,
  672. DEVICE_ERROR,
  673. DISCONNECT_TIMEOUT,*/
  674. EventID &= TNETW_DRIVER_CB_TYPE_MASK;
  675. whalCtrl_Register_CB(pTnetwDrv->hHalCtrl, EventID,CBFunc,pData);
  676. /* register the Elp controller failure event callback to the TNET interface
  677. HW_AWAKE_FAILURE*/
  678. TNETWIF_RegisterFailureEventCB(pTnetwDrv->hTNETWIF,CBFunc,pData);
  679. /* register the Mac services failure events callbacks
  680. POWER_SAVE_FAILURE,
  681. MEASUREMENT_FAILURE,
  682. NO_SCAN_COMPLETE_FAILURE,*/
  683. MacServices_registerFailureEventCB(pTnetwDrv->hMacServices, CBFunc, pData);
  684. /* register the TX failure call back in the Xfer
  685. TX_STUCK,*/
  686. txXfer_RegisterFailureEventCB(pTnetwDrv->hTxXfer, CBFunc, pData);
  687. }
  688. else
  689. WLAN_REPORT_WARNING(pTnetwDrv->hReport, TNETW_DRV_MODULE_LOG,("TnetwDrv_Register_CB - Illegal value\n"));
  690. }
  691. return;
  692. }
  693. /****************************************************************************/
  694. /* TnetwDrv_SetInitParams()
  695. ****************************************************************************/
  696. static TI_STATUS TnetwDrv_SetInitParams (TI_HANDLE hTnetwDrv, TnetwDrv_InitParams_t* pInitParams)
  697. {
  698. TnetwDrv_t * pTnetwDrv = (TnetwDrv_t *)hTnetwDrv;
  699. TnetwDrv_InitParams_t *pInitTableCopy;
  700. UINT32 index;
  701. pInitTableCopy = pTnetwDrv->pInitTableCopy = os_memoryAlloc (pTnetwDrv->hOs, sizeof(TnetwDrv_InitParams_t));
  702. if (pTnetwDrv->pInitTableCopy != NULL)
  703. {
  704. os_memoryZero (pTnetwDrv->hOs, pTnetwDrv->pInitTableCopy, sizeof(TnetwDrv_InitParams_t));
  705. /* Copy the init info to the buffer */
  706. os_memoryCopy (pTnetwDrv->hOs, pTnetwDrv->pInitTableCopy, pInitParams, sizeof(TnetwDrv_InitParams_t));
  707. /* Change the Severity table to character */
  708. for (index = 0; index < sizeof(((report_t *)pTnetwDrv->hReport)->SeverityTable); index++)
  709. {
  710. pInitTableCopy->reportParams.SeverityTable[index] += '0';
  711. }
  712. /* Change the module table to character */
  713. for (index = 0; index < sizeof(((report_t *)pTnetwDrv->hReport)->ModuleTable); index++)
  714. {
  715. pInitTableCopy->reportParams.ModuleTable[index] += '0';
  716. }
  717. }
  718. else
  719. {
  720. WLAN_REPORT_ERROR(pTnetwDrv->hReport, TNETW_DRV_MODULE_LOG,
  721. ("TnetwDrv_SetInitParams: unable to allocate init params buffer!\n") );
  722. return NOK;
  723. }
  724. return OK;
  725. }
  726. /****************************************************************************/
  727. /* TnetwDrv_GetInitParams()
  728. ****************************************************************************/
  729. void TnetwDrv_GetInitParams (TI_HANDLE hTnetwDrv, UINT8 *pcommand, UINT16 *OutBufLen)
  730. {
  731. TnetwDrv_t * pTnetwDrv = (TnetwDrv_t *)hTnetwDrv;
  732. if (pTnetwDrv->pInitTableCopy)
  733. {
  734. *(UINT32 *)pcommand = sizeof(TnetwDrv_InitParams_t);
  735. pcommand += sizeof(UINT32);
  736. os_memoryCopy(NULL, (void *)pcommand, (void *)pTnetwDrv->pInitTableCopy, sizeof(TnetwDrv_InitParams_t));
  737. }
  738. else
  739. {
  740. /* The table information is not available */
  741. *(UINT32 *)pcommand = 0;
  742. WLAN_OS_REPORT(("TNETW_Driver_GetInitParams :ERROR Getting Buffer for the INI File !!!\n"));
  743. }
  744. *OutBufLen = (sizeof(TnetwDrv_InitParams_t) + sizeof(UINT32));
  745. }
  746. /****************************************************************************/
  747. /* TnetwDrv_PrintInfo()
  748. ****************************************************************************
  749. * DESCRIPTION: Call the requested print function.
  750. ****************************************************************************/
  751. void TnetwDrv_PrintInfo (TI_HANDLE hTnetwDrv, TnetwDrv_PrintInfoType_e printInfo)
  752. {
  753. TnetwDrv_t *pTnetwDrv = (TnetwDrv_t *)hTnetwDrv;
  754. switch(printInfo)
  755. {
  756. case TNETW_DRV_PRINT_TX_CTRL_BLK_TBL:
  757. txCtrlBlk_printTable(pTnetwDrv->hTxCtrlBlk);
  758. break;
  759. case TNETW_DRV_PRINT_TX_HW_QUEUE_INFO:
  760. txHwQueue_printInfo(pTnetwDrv->hTxHwQueue);
  761. break;
  762. case TNETW_DRV_PRINT_TX_XFER_INFO:
  763. txXfer_printInfo(pTnetwDrv->hTxXfer);
  764. break;
  765. case TNETW_DRV_PRINT_TX_RESULT_INFO:
  766. txResult_printInfo(pTnetwDrv->hTxResult);
  767. break;
  768. case TNETW_DRV_CLEAR_TX_RESULT_INFO:
  769. txResult_clearInfo(pTnetwDrv->hTxResult);
  770. break;
  771. default:
  772. WLAN_REPORT_ERROR( pTnetwDrv->hReport, TNETW_DRV_MODULE_LOG,
  773. ("$s: invalid print info request code: %d\n", __FUNCTION__, printInfo) );
  774. }
  775. }
  776. /****************************************************************************/
  777. /* TnetwDrv_TEMP_GetHandles()
  778. ****************************************************************************
  779. * DESCRIPTION:
  780. TEMPORARY!! - untill the new TNETW-Driver architecture is completed!!
  781. In the new architecture all external calls to the driver will be through
  782. the hTnetwDrv handle.
  783. Called by the driver creation process.
  784. Gets the TNETW-Driver modules handles needed externally.
  785. ****************************************************************************/
  786. void TnetwDrv_TEMP_GetHandles(TI_HANDLE hTnetwDrv, TI_HANDLE *pHalCtrl, TI_HANDLE *pMacServices)
  787. {
  788. TnetwDrv_t *pTnetwDrv = (TnetwDrv_t *)hTnetwDrv;
  789. *pHalCtrl = pTnetwDrv->hHalCtrl;
  790. *pMacServices = pTnetwDrv->hMacServices;
  791. }
  792. #if !defined(GWSI_DRIVER) && !defined(GWSI_LIB)
  793. /****************************************************************************/
  794. /* TnetwDrv_StartRecovery()
  795. ****************************************************************************
  796. * DESCRIPTION:
  797. API function called by RecoverMgr to start TWD recovery process
  798. ****************************************************************************/
  799. void TnetwDrv_StartRecovery(TI_HANDLE hTnetwDrv, void *endOfRecoveryCB, TI_HANDLE hRecoveryMgr)
  800. {
  801. TnetwDrv_t *pTnetwDrv = (TnetwDrv_t *)hTnetwDrv;
  802. pTnetwDrv->bRecoveryFlag = TRUE;
  803. recoveryCtrl_restartTWD(pTnetwDrv->hRecoveryCtrl, endOfRecoveryCB, hRecoveryMgr);
  804. }
  805. /****************************************************************************/
  806. /* TnetwDrv_InitHw_FinalizeDownload()
  807. ****************************************************************************
  808. * DESCRIPTION:
  809. API function called by RecoverMgr to start TWD recovery process
  810. ****************************************************************************/
  811. TI_STATUS TnetwDrv_InitHw_FinalizeDownload(TI_HANDLE hTnetwDrv)
  812. {
  813. TnetwDrv_t *pTnetwDrv = (TnetwDrv_t *)hTnetwDrv;
  814. if (pTnetwDrv->bRecoveryFlag)
  815. {
  816. pTnetwDrv->bRecoveryFlag = FALSE;
  817. return InitHw_FinalizeDownload(pTnetwDrv->hHwInit);
  818. }
  819. else
  820. {
  821. return TnetwDrv_FinalizeDownload(hTnetwDrv);
  822. }
  823. }
  824. #endif
  825. #ifdef GWSI_SPI_TEST
  826. TI_HANDLE TnetwDrv_GetTnetwifHandle (TI_HANDLE hTnetwDrv)
  827. {
  828. return ((TnetwDrv_t *)hTnetwDrv)->hTNETWIF;
  829. }
  830. #endif /* GWSI_SPI_TEST */