PageRenderTime 50ms CodeModel.GetById 22ms RepoModel.GetById 1ms app.codeStats 0ms

/drivers/net/wireless/tiwlan1251/common/src/TNETW_Driver/TNETWIF/TNETWArbiter/TNETWArb.c

http://github.com/CyanogenMod/cm-kernel
C | 616 lines | 238 code | 113 blank | 265 comment | 29 complexity | 4c89bb0da4194200a59d2870cd543fe6 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: GWSI_Synchronizer.c
  38. * PURPOSE: GWSI Synchronizer used to synchronize between the CMD,INT,TX
  39. *
  40. ****************************************************************************/
  41. #include "commonTypes.h"
  42. #include "memMngrEx.h" /* MSDU */
  43. #include "report.h"
  44. /* First the TNETW Arbiter interface needs the HAL definitions to use them in its API */
  45. #include "TNETWArb.h"
  46. #include "TNETWIF.h"
  47. /* Those are functions that he client can send to the GWSI Synchronizer */
  48. /* The client wants to start its process */
  49. /***********************************************************************************
  50. Internal Synchronizer function use
  51. **************************************************************************************/
  52. /****************************************************************************
  53. * TNETWArb_Init()
  54. ****************************************************************************
  55. * DESCRIPTION: Initialize the synchronizer database.
  56. *
  57. * INPUTS: TI_HANDLE hOs
  58. *
  59. * OUTPUT:
  60. *
  61. * RETURNS: TI_HANDLE hTNETWArb - Handle of the TNETW Arbiter module
  62. ****************************************************************************/
  63. TI_HANDLE TNETWArb_Init (TI_HANDLE hOs)
  64. {
  65. /* Handle to TNETW Arbiter struct */
  66. TNETWArb_t *pTNETWArb;
  67. pTNETWArb = (TNETWArb_t *)os_memoryAlloc (hOs, sizeof(TNETWArb_t));
  68. if (pTNETWArb == NULL)
  69. return NULL;
  70. os_memoryZero (hOs, pTNETWArb, sizeof(TNETWArb_t));
  71. pTNETWArb->hOs = hOs;
  72. /* Get the TNETW Arbiter SM handle */
  73. pTNETWArb->hTNETWArbSM = TNETWArbSM_Create(hOs);
  74. return (TI_HANDLE)pTNETWArb;
  75. }
  76. /****************************************************************************
  77. * TNETWArb_Config()
  78. ****************************************************************************
  79. * DESCRIPTION: Configure the TNETWIF module
  80. *
  81. * INPUTS: TI_HANDLE hTNETWArb
  82. * TI_HANDLE hReport
  83. * TI_HANDLE hELPCtrl
  84. *
  85. * OUTPUT: void
  86. *
  87. * RETURNS: void
  88. ****************************************************************************/
  89. void TNETWArb_Config (TI_HANDLE hTNETWArb,TI_HANDLE hReport,TI_HANDLE hELPCtrl)
  90. {
  91. /* Handle to TNETW Arbiter struct */
  92. TNETWArb_t *pTNETWArb = (TNETWArb_t *)hTNETWArb;
  93. UINT8 index;
  94. pTNETWArb->hReport = hReport;
  95. /* Init buffer Q lists */
  96. for(index = 0 ; index < NUM_OF_TNETWARB_QUEUES ; index++)
  97. {
  98. TNETWArb_init_q (&(pTNETWArb->TNETWArbiter_Queues[index]));
  99. }
  100. /* CAll the TNETW Arbiter Initializeto set the buffer free and their next buffer to NULL */
  101. TNETWArb_buffer_init(&(pTNETWArb->TNETWArb_Client_Instance_Array[0][0]));
  102. /* Clear the Event to dispatch bit */
  103. pTNETWArb->event_to_dispatch&=~TNETWARB_IS_EVENT_PENDING;
  104. /* For now the Handle to theBus Arbiter is NULL */
  105. TNETWArbSM_Init(pTNETWArb->hTNETWArbSM,pTNETWArb->hReport,hTNETWArb,hELPCtrl,NULL);
  106. }
  107. /****************************************************************************/
  108. /* TNETWIF_Destroy()
  109. ****************************************************************************
  110. * DESCRIPTION: Destroy The TNETWIF Module
  111. *
  112. * INPUTS:
  113. *
  114. * OUTPUT: String the name of the Queue
  115. *
  116. * RETURNS:
  117. ****************************************************************************/
  118. TI_STATUS TNETWArb_Destroy (TI_HANDLE hTNETWArb)
  119. {
  120. /* Handle to TNETW Arbiter struct */
  121. TNETWArb_t *pTNETWArb = (TNETWArb_t *)hTNETWArb;
  122. /* Call the TNETWArb SM Destruction function */
  123. if (pTNETWArb->hTNETWArbSM)
  124. TNETWArbSM_Destroy (pTNETWArb->hTNETWArbSM);
  125. /* Free the TNETW Arbiter memory */
  126. if (pTNETWArb)
  127. os_memoryFree(pTNETWArb->hOs, pTNETWArb, sizeof(TNETWArb_t));
  128. return OK;
  129. }
  130. /****************************************************************************
  131. * TNETWArb_register_handler()
  132. ****************************************************************************
  133. * DESCRIPTION: Register the Client Callback function to the TNETW Arbiter
  134. * This function will be called in case of DMA Done i.e BusTXn Complete
  135. *
  136. * INPUTS: TI_HANDLE hTNETWArb
  137. * UINT8 module_id
  138. * TNETWIF_callback_t module_CB_Func
  139. * TI_HANDLE module_handle
  140. *
  141. * OUTPUT: void
  142. *
  143. * RETURNS: void
  144. ****************************************************************************/
  145. void TNETWArb_register_handler(TI_HANDLE hTNETWArb,UINT8 module_id,TNETWIF_callback_t module_CB_Func,TI_HANDLE module_handle)
  146. {
  147. /* Handle to TNETW Arbiter struct */
  148. TNETWArb_t *pTNETWArb = (TNETWArb_t *)hTNETWArb;
  149. TNETWARB_INSTANCE_T *pTNETWARB_Inst;
  150. /* Get the pointer to the TNETWARB_INSTANCE struct */
  151. pTNETWARB_Inst = (TNETWARB_INSTANCE_T *) (&(pTNETWArb->TNETWArb_Client_Instance_Array[module_id][BUFFER_HDR_SIZE]));
  152. pTNETWARB_Inst->module_id = module_id;
  153. pTNETWARB_Inst->instance_callback = module_CB_Func;
  154. pTNETWARB_Inst->instance_handle = module_handle;
  155. if (module_id == DEFAULT_MODULE_ID)
  156. pTNETWArb->pDefInst = pTNETWARB_Inst;
  157. }
  158. /****************************************************************************
  159. * TNETWArb_Start()
  160. ****************************************************************************
  161. * DESCRIPTION: Client registration to the TNETW Arbiter whishing to have **
  162. ** access to the Bus
  163. *
  164. * INPUTS: TI_HANDLE hTNETWArb
  165. * UINT8 module_id
  166. * TI_HANDLE ClientCallBack_Handle
  167. * TNETWIF_callback_t module_CB_Func
  168. *
  169. * OUTPUT: void
  170. *
  171. * RETURNS: TI_STATUS - TNETWIF_ERROR - In case that the Client is already registered to the TNETWIF
  172. * TNETWIF_COMPLETE - In case that the Client callback has been immediately called
  173. * TNETWIF_PENDING - In case that the Client will be called later
  174. ****************************************************************************/
  175. TI_STATUS TNETWArb_Start (TI_HANDLE hTNETWArb, UINT8 module_id, TI_HANDLE ClientCallBack_Handle, TNETWIF_callback_t ClientCallBack_Func)
  176. {
  177. /* Handle to TNETW Arbiter struct */
  178. TNETWArb_t *pTNETWArb = (TNETWArb_t *)hTNETWArb;
  179. TNETWARB_INSTANCE_T *pTNETWARB_Inst;
  180. TI_STATUS ret;
  181. WLAN_REPORT_INFORMATION (pTNETWArb->hReport, TNETW_ARBITER_MODULE_LOG,
  182. ("\n TNETWArb_Start: Register START to Synchronizer from module_id %x \n",module_id));
  183. #ifdef TI_DBG
  184. pTNETWArb->stat.uStart ++;
  185. #endif
  186. /* Get the instance buffer matching to the module_id */
  187. pTNETWARB_Inst = (TNETWARB_INSTANCE_T *) TNETWArb_getpoolbuf(hTNETWArb,module_id);
  188. /* If the instance is already allocated then return error to Client caller */
  189. if(pTNETWARB_Inst == NULL)
  190. {
  191. WLAN_REPORT_ERROR(pTNETWArb->hReport,TNETW_ARBITER_MODULE_LOG,("\n TNETWArb_Start Module %s Already requested TNETWIF!!!! \n", TNETWIF_ModuleIdToString(module_id)));
  192. TNETWIF_printErrorLog();
  193. return TNETWIF_ERROR;
  194. }
  195. TNETWArb_Enqueue (&(pTNETWArb->TNETWArbiter_Queues[TODO_LIST_INDEX]), (void*)pTNETWARB_Inst);
  196. WLAN_REPORT_INFORMATION(pTNETWArb->hReport,TNETW_ARBITER_MODULE_LOG,("TNETWArb_Start: Enqueue in TODO: module %s, pTNETWARB_Inst %x instance_handle: %X\n", TNETWIF_ModuleIdToString(module_id), pTNETWARB_Inst,ClientCallBack_Handle));
  197. /* Fill the Client instance with the callback handle and function passed in the call */
  198. pTNETWARB_Inst->module_id = module_id;
  199. pTNETWARB_Inst->instance_callback = ClientCallBack_Func;
  200. pTNETWARB_Inst->instance_handle = ClientCallBack_Handle;
  201. WLAN_REPORT_INFORMATION (pTNETWArb->hReport, TNETW_ARBITER_MODULE_LOG,
  202. ("\n TNETWArb_Start: Call TNETWArbSM_SMEvent with TNETWARBSM_EV_START for module %s \n",TNETWIF_ModuleIdToString(module_id)));
  203. /* Send the event EV_REG to the TNETW Arbiter for handling and take appropriate actions */
  204. ret = TNETWArbSM_SMEvent (pTNETWArb->hTNETWArbSM,
  205. (module_id == FW_EVENT_MODULE_ID) ? TNETWARBSM_EV_HW_AVAIL : TNETWARBSM_EV_START);
  206. return ret;
  207. }
  208. /*********************************************************************************************************
  209. ** **
  210. ** Function Name: TNETWArb_Restart **
  211. ** **
  212. ** Description: Client Re-registration to the TNETW Arbiter whishing to **
  213. ** regain access to the Bus **
  214. ** This will do the following: **
  215. ** 1) Remove the instance from the Running Instance **
  216. ** 2) Add it to the TODO Queue **
  217. ** 3) Will set the Current event to be dispatched later on **
  218. ** from where the Restart was called inside the TNETW Arbiter **
  219. ** This is done to prevent nesting operations from within the Client context **
  220. ** **
  221. **********************************************************************************************************/
  222. TI_STATUS TNETWArb_Restart (TI_HANDLE hTNETWArb,UINT8 module_id,TI_HANDLE ClientCallBack_Handle,TNETWIF_callback_t ClientCallBack_Func)
  223. {
  224. /* Handle to TNETW Arbiter struct */
  225. TNETWArb_t *pTNETWArb = (TNETWArb_t *)hTNETWArb;
  226. TNETWARB_INSTANCE_T *pTNETWARB_Inst;
  227. #ifdef TNETWARB_DEBUG
  228. /* For debug, verify that the running instance is not NULL. */
  229. if(pTNETWArb->TNETWArb_Running_instance == NULL )
  230. {
  231. WLAN_REPORT_ERROR(pTNETWArb->hReport,TNETW_ARBITER_MODULE_LOG,
  232. ("TNETWArb_Restart: There is no module running, requested by module %d\n", module_id));
  233. return TNETWIF_ERROR;
  234. }
  235. /* For debug check that the instance requesting restart is really the running instance */
  236. if(pTNETWArb->TNETWArb_Running_instance->module_id != module_id )
  237. {
  238. /* In this case return to caller ERROR */
  239. return TNETWIF_ERROR;
  240. }
  241. #endif
  242. #ifdef TI_DBG
  243. pTNETWArb->stat.uRestart ++;
  244. #endif
  245. /* Take the Running instance control block */
  246. pTNETWARB_Inst = pTNETWArb->TNETWArb_Running_instance ;
  247. /* First indicate that there is not any handle in the Running instance */
  248. pTNETWArb->TNETWArb_Running_instance = NULL;
  249. /* Enqueue the client request or i.e its instance in the TODO List */
  250. TNETWArb_Enqueue(&(pTNETWArb->TNETWArbiter_Queues[TODO_LIST_INDEX]), (void*)pTNETWARB_Inst);
  251. WLAN_REPORT_INFORMATION(pTNETWArb->hReport,TNETW_ARBITER_MODULE_LOG,("TNETWArb_Restart: Enqueue in TODO: module %s, instance_handle: %X\n", TNETWIF_ModuleIdToString(module_id), ClientCallBack_Handle));
  252. /* Fill the Client instance with the callback handle and function given by the call */
  253. pTNETWARB_Inst->module_id = module_id;
  254. pTNETWARB_Inst->instance_callback = ClientCallBack_Func;
  255. pTNETWARB_Inst->instance_handle = ClientCallBack_Handle;
  256. /* Set the event to dispatch so that when this function will return back then the context will return to the TNETW Arbiter */
  257. /* Then the TNETW Arbiter will dispatch the event to the STate Machine within its context and not within the Client context
  258. to prevent nesting of many calls and prevent to increse the stack */
  259. pTNETWArb->event_to_dispatch = TNETWARBSM_EV_RESTART;
  260. pTNETWArb->event_to_dispatch|=TNETWARB_IS_EVENT_PENDING;
  261. /* Return Pending since the Restart will be handled in a later context */
  262. return TNETWIF_PENDING;
  263. }
  264. /*********************************************************************************************************
  265. ** **
  266. ** Function Name: TNETWArb_Finish **
  267. ** **
  268. ** Description: Client De-registration to the TNETW Arbiter whishing to **
  269. ** release access to the Bus **
  270. ** This will do the following: **
  271. ** 1) Remove the instance from the Running Instance **
  272. ** 3) Will set the Current event to be dispatched later on **
  273. ** from where the Finish was called inside the TNETW Arbiter **
  274. ** This is done to prevent nesting operations from within the Client context **
  275. ** **
  276. **********************************************************************************************************/
  277. TI_STATUS TNETWArb_Finish (TI_HANDLE hTNETWArb,UINT8 module_id,TI_HANDLE ClientCallBack_Handle,TNETWIF_callback_t ClientCallBack_Func)
  278. {
  279. /* Handle to TNETW Arbiter struct */
  280. TNETWArb_t *pTNETWArb = (TNETWArb_t *)hTNETWArb;
  281. TNETWARB_INSTANCE_T *pTNETWARB_Inst;
  282. #ifdef TNETWARB_DEBUG
  283. /* For debug, verify that the running instance is not NULL. */
  284. if(pTNETWArb->TNETWArb_Running_instance == NULL )
  285. {
  286. WLAN_REPORT_ERROR(pTNETWArb->hReport,TNETW_ARBITER_MODULE_LOG,
  287. ("TNETWArb_Finish: There is no module running, requested by module %d\n", module_id));
  288. return TNETWIF_ERROR;
  289. }
  290. /* For debug check that the instance requesting restart is really the running instance */
  291. if(pTNETWArb->TNETWArb_Running_instance->module_id != module_id )
  292. {
  293. WLAN_REPORT_ERROR(pTNETWArb->hReport,TNETW_ARBITER_MODULE_LOG,
  294. ("TNETWArb_Finish: Module %s is not Running module %s is Running \n",
  295. TNETWIF_ModuleIdToString(module_id),
  296. TNETWIF_ModuleIdToString(pTNETWArb->TNETWArb_Running_instance->module_id)));
  297. /* In this case return to caller ERROR */
  298. return TNETWIF_ERROR;
  299. }
  300. #endif
  301. #ifdef TI_DBG
  302. pTNETWArb->stat.uFinish ++;
  303. #endif
  304. /* Take the Running instance control block */
  305. pTNETWARB_Inst = pTNETWArb->TNETWArb_Running_instance ;
  306. WLAN_REPORT_INFORMATION(pTNETWArb->hReport,TNETW_ARBITER_MODULE_LOG,
  307. ("TNETWArb_Finish: module %s, instance_handle: %X\n",
  308. TNETWIF_ModuleIdToString(module_id),
  309. pTNETWARB_Inst->instance_handle));
  310. /* Free the buffer instance */
  311. TNETWArb_freebuf((void *)pTNETWARB_Inst);
  312. /* Indicate that there is not any handle in the Running instance */
  313. pTNETWArb->TNETWArb_Running_instance = NULL;
  314. /* Fill the Client instance with NULL callback to ease debugging */
  315. pTNETWARB_Inst->module_id = module_id;
  316. pTNETWARB_Inst->instance_callback = NULL;
  317. pTNETWARB_Inst->instance_handle = NULL;
  318. /* Now check the Event to send to the TNETW Arbiter State Machine */
  319. /* If there are more reequest in the TODO Queue then Send PROCESS_NEXT_EV else send FINISH event to TNETW Arbiter */
  320. if(TNETWArb_getfirst(&(pTNETWArb->TNETWArbiter_Queues[TODO_LIST_INDEX])))
  321. {
  322. /* Set the event to dispatch so that when this function will return back then the context will return to the TNETW Arbiter */
  323. /* Then the TNETW Arbiter will dispatch the event to the STate Machine within its context and not within the Client context
  324. to prevent nesting of many calls and prevent to increse the stack */
  325. pTNETWArb->event_to_dispatch = TNETWARBSM_EV_RESTART;
  326. WLAN_REPORT_INFORMATION(pTNETWArb->hReport,TNETW_ARBITER_MODULE_LOG ,
  327. ("TNETWArb_Finish: module %s, instance_handle: %x Send TNETWARBSM_EV_RESTART \n",
  328. TNETWIF_ModuleIdToString(module_id),
  329. pTNETWARB_Inst->instance_handle));
  330. }
  331. else
  332. {
  333. /* Set the event to dispatch so that when this function will return back then the context will return to the TNETW Arbiter */
  334. /* Then the TNETW Arbiter will dispatch the event to the STate Machine within its context and not within the Client context
  335. to prevent nesting of many calls and prevent to increse the stack */
  336. pTNETWArb->event_to_dispatch = TNETWARBSM_EV_FINISH;
  337. WLAN_REPORT_INFORMATION(pTNETWArb->hReport,TNETW_ARBITER_MODULE_LOG,
  338. ("TNETWArb_Finish: module %s, TNETWARBSM_EV_FINISH \n",
  339. TNETWIF_ModuleIdToString(module_id),
  340. pTNETWARB_Inst->instance_handle));
  341. }
  342. pTNETWArb->event_to_dispatch|=TNETWARB_IS_EVENT_PENDING;
  343. /* Return Pending since the Process_Next/Finish Event will be handled in a later context */
  344. return TNETWIF_COMPLETE;
  345. }
  346. /****************************************************************************
  347. * TNETWArb_CallTxnCb()
  348. ****************************************************************************
  349. * DESCRIPTION: This function is used to call the client callback function that was previously
  350. * supplied to the TNETWIF via 2 ways:
  351. * 1) When the Client requested with TNETWIF_Start to access the Bus
  352. * 2) When the Client call the TNETWIF with Async or Optimzed mode.
  353. * In this case the callback will be called when the DMA will finish.
  354. *
  355. * Note :The Client can request FINISHor RESTART bu the TNETW Arbiter state machine will
  356. * be sent the event only after that the client function callback returns.
  357. * This is done to prevent a deep nesting in case of RESTART.
  358. *
  359. * INPUTS: TI_HANDLE hTNETWArb
  360. *
  361. * OUTPUT: void
  362. *
  363. * RETURNS: void
  364. ****************************************************************************/
  365. TI_STATUS TNETWArb_CallTxnCb (TI_HANDLE hTNETWArb)
  366. {
  367. TNETWArb_t *pTNETWArb = (TNETWArb_t *)hTNETWArb;
  368. TNETWARB_INSTANCE_T *pTNETWArbInst;
  369. /*
  370. * If the pDefInst is not NULL it is a special arbiter client (ELP control).
  371. * Call the ELP control callback.
  372. */
  373. if (pTNETWArb->pDefInst != NULL)
  374. {
  375. pTNETWArbInst = pTNETWArb->pDefInst;
  376. pTNETWArb->pDefInst = NULL;
  377. if (pTNETWArbInst->instance_callback != NULL)
  378. ((TNETWIF_callback_t)(pTNETWArbInst->instance_callback))
  379. (pTNETWArbInst->instance_handle, pTNETWArbInst->module_id, OK);
  380. return TNETWIF_COMPLETE;
  381. }
  382. /* Otherwise, call a regular arbiter client callback */
  383. else
  384. {
  385. return TNETWArb_CallClientCallback (hTNETWArb);
  386. }
  387. }
  388. /****************************************************************************
  389. * TNETWArb_CallClientCallback()
  390. ****************************************************************************
  391. * DESCRIPTION: This function is used to call the client callback function that was previously
  392. * supplied to the TNETWIF via 2 ways:
  393. * 1) When the Client requested with TNETWIF_Start to access the Bus
  394. * 2) When the Client call the TNETWIF with Async or Optimzed mode.
  395. * In this case the callback will be called when the DMA will finish.
  396. *
  397. * Note :The Client can request FINISHor RESTART bu the TNETW Arbiter state machine will
  398. * be sent the event only after that the client function callback returns.
  399. * This is done to prevent a deep nesting in case of RESTART.
  400. *
  401. * INPUTS: TI_HANDLE hTNETWArb
  402. *
  403. * OUTPUT: void
  404. *
  405. * RETURNS: void
  406. ****************************************************************************/
  407. TI_STATUS TNETWArb_CallClientCallback (TI_HANDLE hTNETWArb)
  408. {
  409. /* Handle to TNETW Arbiter struct */
  410. TNETWArb_t *pTNETWArb = (TNETWArb_t *)hTNETWArb;
  411. TNETWARB_INSTANCE_T *pTNETWARB_Inst;
  412. /* Take the Running instance control block */
  413. if (pTNETWArb->TNETWArb_Running_instance != NULL)
  414. {
  415. pTNETWARB_Inst = pTNETWArb->TNETWArb_Running_instance;
  416. }
  417. else
  418. {
  419. WLAN_REPORT_ERROR (pTNETWArb->hReport, TNETW_ARBITER_MODULE_LOG,
  420. ("TNETWArb_CallClientCallback: no running instance\n"));
  421. TNETWIF_printErrorLog();
  422. return TNETWIF_ERROR;
  423. }
  424. /* Call the client callback */
  425. if (pTNETWARB_Inst->instance_callback != NULL)
  426. ((TNETWIF_callback_t)(pTNETWARB_Inst->instance_callback))
  427. (pTNETWARB_Inst->instance_handle, pTNETWARB_Inst->module_id, OK);
  428. /* Check if there is an event to be dispatch */
  429. if (pTNETWArb->event_to_dispatch & TNETWARB_IS_EVENT_PENDING)
  430. {
  431. TI_STATUS status;
  432. pTNETWArb->event_to_dispatch &= ~TNETWARB_IS_EVENT_PENDING;
  433. /* Now check the Event to send to the TNETW Arbiter State Machine */
  434. /* If there are more request in the TODO Queue then Send PROCESS_NEXT_EV else send FINISH event to TNETW Arbiter */
  435. if (TNETWArb_getfirst (&pTNETWArb->TNETWArbiter_Queues[TODO_LIST_INDEX]))
  436. {
  437. /* Set the event to dispatch so that when this function will return back then the context will return to the TNETW Arbiter */
  438. /* Then the TNETW Arbiter will dispatch the event to the STate Machine within its context and not within the Client context
  439. to prevent nesting of many calls and prevent to increase the stack */
  440. pTNETWArb->event_to_dispatch = TNETWARBSM_EV_RESTART;
  441. status = TNETWIF_PENDING;
  442. WLAN_REPORT_INFORMATION (pTNETWArb->hReport,TNETW_ARBITER_MODULE_LOG ,("TNETWArb_CallClientCallback: module %s, instance_handle: %x Send TNETWARBSM_EV_RESTART \n", TNETWIF_ModuleIdToString(pTNETWARB_Inst->module_id), pTNETWARB_Inst->instance_handle));
  443. }
  444. else
  445. {
  446. /* Set the event to dispatch so that when this function will return back then the context will return to the TNETW Arbiter */
  447. /* Then the TNETW Arbiter will dispatch the event to the STate Machine within its context and not within the Client context
  448. to prevent nesting of many calls and prevent to increase the stack */
  449. pTNETWArb->event_to_dispatch = TNETWARBSM_EV_FINISH;
  450. status = TNETWIF_COMPLETE;
  451. WLAN_REPORT_INFORMATION (pTNETWArb->hReport,TNETW_ARBITER_MODULE_LOG,("TNETWArb_CallClientCallback: module %s, TNETWARBSM_EV_FINISH \n", TNETWIF_ModuleIdToString(pTNETWARB_Inst->module_id), pTNETWARB_Inst->instance_handle));
  452. }
  453. WLAN_REPORT_INFORMATION (pTNETWArb->hReport, TNETW_ARBITER_MODULE_LOG, ("TNETWArb_CallClientCallback: module %s, instance_handle: %x Send pTNETWArb->event_to_dispatch %d \n", TNETWIF_ModuleIdToString(pTNETWARB_Inst->module_id), pTNETWARB_Inst->instance_handle, pTNETWArb->event_to_dispatch));
  454. TNETWArbSM_SMEvent (pTNETWArb->hTNETWArbSM, pTNETWArb->event_to_dispatch);
  455. return status;
  456. }
  457. return TNETWIF_PENDING;
  458. }
  459. /****************************************************************************
  460. * TNETWArb_TxnCb()
  461. ****************************************************************************
  462. * DESCRIPTION: ELP Controller Callabck - Indicate to the TNETWArb that the HW is now Available
  463. * The FW has waken up.
  464. *
  465. * INPUTS: hTNETWArb - the handle to the TNETW Arbiter
  466. *
  467. * OUTPUT:
  468. *
  469. * RETURNS: OK
  470. ****************************************************************************/
  471. void TNETWArb_TxnCb (TI_HANDLE hTNETWArb, UINT8 module_id, TI_STATUS status)
  472. {
  473. TNETWArb_t *pTNETWArb = (TNETWArb_t *)hTNETWArb;
  474. TNETWArbSM_TxnCb (pTNETWArb->hTNETWArbSM);
  475. }
  476. #ifdef TI_DBG
  477. void TNETWArb_PrintStat (TI_HANDLE hTNETWArb)
  478. {
  479. TNETWArb_t *pTNETWArb = (TNETWArb_t *)hTNETWArb;
  480. WLAN_OS_REPORT (("Num of start = %u\n", pTNETWArb->stat.uStart));
  481. WLAN_OS_REPORT (("Num of restart = %u\n", pTNETWArb->stat.uRestart));
  482. WLAN_OS_REPORT (("Num of finish = %u\n", pTNETWArb->stat.uFinish));
  483. TNETWIF_printErrorLog();
  484. }
  485. #endif
  486. /****************************************************************************
  487. * BusArbiter_Recovery()
  488. ****************************************************************************
  489. * DESCRIPTION: handles the recovery
  490. *
  491. * INPUTS: TI_HANDLE hBusArbiter
  492. *
  493. * OUTPUT: void
  494. *
  495. * RETURNS: void
  496. ****************************************************************************/
  497. TI_STATUS TNETWArb_Recovery(TI_HANDLE hTNETWArb, TI_HANDLE hELPCtrl)
  498. {
  499. TNETWArb_t *pTNETWArb = (TNETWArb_t *)hTNETWArb;
  500. /* should be updated - see CE20 */
  501. TNETWArb_Config (hTNETWArb, pTNETWArb->hReport, hELPCtrl);
  502. return OK;
  503. }