PageRenderTime 53ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/drivers/net/wireless/tiwlan1251/common/src/TNETW_Driver/FW_Transfer/EventMbox/eventMbox.c

https://bitbucket.org/cyanogenmod/cm-kernel
C | 759 lines | 377 code | 123 blank | 259 comment | 32 complexity | 6164fbc10a9ec2104d4181bad8728b77 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.0, AGPL-1.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: EventMbox.c : event Mail Box
  38. * PURPOSE: Handle any event interrupt from the FW
  39. *
  40. ****************************************************************************/
  41. #include "commonTypes.h"
  42. #include "FwEvent_api.h"
  43. #include "whalBus_Api.h"
  44. #include "eventMbox_api.h"
  45. #include "whalCtrl_api.h"
  46. #include "TNETWIF.h"
  47. /*******************************************************************************
  48. *
  49. * Macros
  50. *
  51. *******************************************************************************/
  52. #define IS_EVENT_BIT_ON(EvVector,EvBit) ( (EvBit) == ( (EvVector) & (EvBit) ) )
  53. #define IS_EVENT_BIT_OFF(EvVector,EvBit) ( ~(EvBit) == ( (EvVector) | ~(EvBit) ) )
  54. #define SET_EVENT_BIT(EvVector,EvBit) ( (EvVector) |= (EvBit) )
  55. #define CLEAR_EVENT_BIT(EvVector,EvBit) ( (EvVector) &= ~(EvBit) )
  56. #define EVENT_REPORT_SIZE 80
  57. #define EVMBX_DBG 1
  58. /*****************************************************************************
  59. ** Enumerations **
  60. *****************************************************************************/
  61. typedef enum
  62. {
  63. EVENT_MBOX_STATE_IDLE,
  64. EVENT_MBOX_STATE_READ_BUF,
  65. EVENT_MBOX_STATE_ACK_EVENT
  66. } EventMboxState_e;
  67. /*****************************************************************************
  68. ** Structures **
  69. *****************************************************************************/
  70. /*
  71. * Definition for the Event Table
  72. */
  73. typedef struct
  74. {
  75. /* Event bit mask */
  76. UINT32 bitMask;
  77. /* Event trace string */
  78. char* str;
  79. /* Event data length */
  80. UINT8 dataLen;
  81. } EventEntry_t;
  82. /*
  83. * Event callback structure
  84. */
  85. typedef struct
  86. {
  87. /* Event callback function */
  88. void* fCb;
  89. /* Event callback module handle */
  90. TI_HANDLE hCb;
  91. /* Event data offset */
  92. UINT8* pDataOffs;
  93. /* Event callback counter */
  94. UINT32 uCount;
  95. } EventCB_t;
  96. /*
  97. * Event Mailbox object
  98. */
  99. typedef struct
  100. {
  101. /* Offset for event A (0) or event B (1) */
  102. UINT32 offset[2];
  103. /* 0 or 1 according to event A or B */
  104. UINT32 currentEvent;
  105. /* Event mail box state machine state */
  106. EventMboxState_e state;
  107. /* Return value */
  108. TI_STATUS returnValue;
  109. /* Init complete flag */
  110. BOOL bInitComplete;
  111. /* Indicate if we are in synchronous bus or not */
  112. BOOL bSync;
  113. /* Callback table */
  114. EventCB_t cbTable[MAX_NUM_OF_EVENT];
  115. /* Use a struct to read buffers from the bus - used for extra bytes reserving */
  116. PADDING (EventMailBox_t CompoundEvent)
  117. /* Handles */
  118. TI_HANDLE hFwEvent;
  119. TI_HANDLE hTNETWIF;
  120. TI_HANDLE hOs;
  121. TI_HANDLE hReport;
  122. TI_HANDLE hWhalCtrl;
  123. #ifdef TI_DBG
  124. /* Count the compound event */
  125. UINT32 uCompounEvCount;
  126. /* Count the total number of event sending in the compound */
  127. UINT32 uTotalEvCount;
  128. #endif /* TI_DBG */
  129. TNETWIF_callback_t fCb;
  130. TI_HANDLE hCb;
  131. } EventMbox_t;
  132. /********************************************************************************/
  133. /* Internal functions prototypes. */
  134. /********************************************************************************/
  135. static void eventMbox_HandleEvent (TI_HANDLE hEventMbox);
  136. static void eventMbox_StateMachine (TI_HANDLE hEventMbox, UINT8 module_id, TI_STATUS status);
  137. static void eventMbox_InitCbTable (TI_HANDLE hEventMbox);
  138. static const EventEntry_t eventTable [MAX_NUM_OF_EVENT] =
  139. {
  140. /*==================================================================================
  141. | |
  142. | EVENT TABLE |
  143. | |
  144. ===================================================================================
  145. | Id | Event Mask Bit | Event String | Length |
  146. ===================================================================================*/
  147. /*0*/ { MEASUREMENT_START_EVENT_ID, "MEASUREMENT START " , 0},
  148. /*1*/ { SCAN_COMPLETE_EVENT_ID , "SCAN CMPLT " , 3},
  149. /*2*/ { CALIBRATION_COMPLETE_EVENT_ID, "CALIB CMPLT " , 0},
  150. /*3*/ { ROAMING_TRIGGER_LOW_RSSI_EVENT_ID , "RSSI LEVEL " , 1},
  151. /*4*/ { PS_REPORT_EVENT_ID, "PS_REPORT " , 1},
  152. /*5*/ { SYNCHRONIZATION_TIMEOUT_EVENT_ID, "SYNCHRONIZATION TIMEOUT ", 0},
  153. /*6*/ { HEALTH_REPORT_EVENT_ID, "HEALTH REPORT " , 2},
  154. /*7*/ { ACI_DETECTION_EVENT_ID , "ACI INDICATION " , 2},
  155. /*8*/ { DEBUG_REPORT_EVENT_ID, "DEBUG REPORT " , 8},
  156. /*9*/ { MAC_STATUS_EVENT_ID, "MAC STATUS " , 8},
  157. /*10*/{ DISCONNECT_EVENT_COMPLETE_ID, "DISCONNECT COMPLETE " , 0},
  158. /*11*/{ JOIN_EVENT_COMPLETE_ID, "JOIN CMPLT " , 0},
  159. /*12*/{ CHANNEL_SWITCH_COMPLETE_EVENT_ID, "SWITCH CHANNEL CMPLT " , 0},
  160. /*13*/{ BSS_LOSE_EVENT_ID, "BSS LOST " , 0},
  161. /*14*/{ ROAMING_TRIGGER_MAX_TX_RETRY_EVENT_ID, "MAX TX RETRY " , 0},
  162. /*15*/{ MEASUREMENT_COMPLETE_EVENT_ID, "BSS LOSE " , 0},
  163. /*16*/{ AP_DISCOVERY_COMPLETE_EVENT_ID, "MAX TX RETRY " , 0},
  164. /*17*/{ SCHEDULED_SCAN_COMPLETE_EVENT_ID, "SPS SCAN CMPLT " , 3},
  165. /*18*/{ REGAINED_BSS_EVENT_ID, "REGAINED BSS " , 0},
  166. /*19*/{ ROAMING_TRIGGER_REGAINED_RSSI_EVENT_ID, "REGAINED RSSI " , 1},
  167. /*20*/{ ROAMING_TRIGGER_LOW_SNR_EVENT_ID, "LOW SNR " , 1},
  168. /*21*/{ SOFT_GEMINI_SENSE_EVENT_ID, "SOFT GEMINI SENSE " , 1},
  169. /*22*/{ SOFT_GEMINI_PREDICTION_EVENT_ID, "SOFT GEMINI PREDICTION " , 1},
  170. /*23*/{ SOFT_GEMINI_AVALANCHE_EVENT_ID, "SOFT GEMINI AVALANCHE " , 0},
  171. /*24*/{ PLT_RX_CALIBRATION_COMPLETE_EVENT_ID, "PLT RX CALIBR. COMPLETE ", 0},
  172. /*25*/{ PSPOLL_DELIVERY_FAILURE_EVENT_ID, "PS-POLL DELIVERY FAILURE", 0},
  173. /*26*/{ RESET_BSS_EVENT_ID, "EVENT RESET BSS " , 0},
  174. /*27*/{ EVENT_MBOX_ALL_EVENT_ID, "ALL EVENTS " , 0},
  175. };
  176. /********************************************************************************/
  177. /* functions implementation */
  178. /********************************************************************************/
  179. /****************************************************************************
  180. * eventMbox_InitCbTable()
  181. ****************************************************************************
  182. * DESCRIPTION: Initialization of callback table
  183. *
  184. * INPUTS: hEventMbox eventMbox module handle
  185. *
  186. * RETURNS: none
  187. ****************************************************************************/
  188. void eventMbox_InitCbTable (TI_HANDLE hEventMbox)
  189. {
  190. EventMbox_t *pEventMbox = (EventMbox_t *)hEventMbox;
  191. UINT32 EvID;
  192. for (EvID = 0; EvID < MAX_NUM_OF_EVENT; EvID++)
  193. {
  194. pEventMbox->cbTable[EvID].pDataOffs = (UINT8*)&pEventMbox->CompoundEvent;
  195. }
  196. pEventMbox->cbTable[ 3].pDataOffs += offsetof (EventMailBox_t, averageRssiLevel);
  197. pEventMbox->cbTable[ 4].pDataOffs += offsetof (EventMailBox_t, psStatus);
  198. pEventMbox->cbTable[ 6].pDataOffs += offsetof (EventMailBox_t, healthReport);
  199. pEventMbox->cbTable[ 7].pDataOffs += offsetof (EventMailBox_t, badFFTCorrelationCounter);
  200. pEventMbox->cbTable[ 8].pDataOffs += offsetof (EventMailBox_t, debugReport);
  201. pEventMbox->cbTable[ 9].pDataOffs += offsetof (EventMailBox_t, consFcsErrCnt);
  202. pEventMbox->cbTable[17].pDataOffs += offsetof (EventMailBox_t, scheduledScanStatus);
  203. pEventMbox->cbTable[19].pDataOffs += offsetof (EventMailBox_t, averageRssiLevel);
  204. pEventMbox->cbTable[20].pDataOffs += offsetof (EventMailBox_t, averageSNRLevel);
  205. pEventMbox->cbTable[21].pDataOffs += offsetof (EventMailBox_t, softGeminiSenseInfo);
  206. pEventMbox->cbTable[22].pDataOffs += offsetof (EventMailBox_t, softGeminiProtectiveInfo);
  207. }
  208. /****************************************************************************
  209. * eventMbox_Create()
  210. ****************************************************************************
  211. * DESCRIPTION: Create the Bus Access mailbox object
  212. *
  213. * RETURNS: The Created object
  214. ****************************************************************************/
  215. TI_HANDLE eventMbox_Create (TI_HANDLE hOs)
  216. {
  217. EventMbox_t *pEventMbox;
  218. pEventMbox = os_memoryAlloc (hOs, sizeof(EventMbox_t));
  219. if (pEventMbox == NULL)
  220. {
  221. WLAN_OS_REPORT (("eventMbox_Create: Error creating EventMbox object\n"));
  222. return NULL;
  223. }
  224. os_memoryZero (hOs, pEventMbox, sizeof(EventMbox_t));
  225. pEventMbox->hOs = hOs;
  226. pEventMbox->CompoundEvent.eventsMask = EVENT_MBOX_ALL_EVENT_ID;
  227. return (TI_HANDLE)pEventMbox;
  228. }
  229. /****************************************************************************
  230. * eventMbox_Destroy()
  231. ****************************************************************************
  232. * DESCRIPTION: Destroy the object
  233. *
  234. ****************************************************************************/
  235. void eventMbox_Destroy (TI_HANDLE hEventMbox)
  236. {
  237. EventMbox_t *pEventMbox = (EventMbox_t *)hEventMbox;
  238. if (pEventMbox)
  239. {
  240. os_memoryFree (pEventMbox->hOs, pEventMbox, sizeof(EventMbox_t));
  241. }
  242. }
  243. /****************************************************************************
  244. * eventMbox_Config()
  245. ****************************************************************************
  246. * DESCRIPTION: Configure the object
  247. *
  248. * INPUTS: pEventMbox this
  249. * pHwIntr Interrupt Object object
  250. * hReport Report Object
  251. *
  252. * RETURNS: OK or NOK
  253. ****************************************************************************/
  254. void eventMbox_Config (TI_HANDLE hEventMbox, TI_HANDLE hTNETWIF, TI_HANDLE hHwIntr,
  255. TI_HANDLE hReport, TI_HANDLE hFwEvent, TI_HANDLE hWhalCtrl)
  256. {
  257. EventMbox_t *pEventMbox = (EventMbox_t *)hEventMbox;
  258. pEventMbox->hTNETWIF = hTNETWIF;
  259. pEventMbox->hReport = hReport;
  260. pEventMbox->hFwEvent = hFwEvent;
  261. pEventMbox->hWhalCtrl = hWhalCtrl;
  262. pEventMbox->hReport = hReport;
  263. pEventMbox->state = EVENT_MBOX_STATE_IDLE;
  264. pEventMbox->bInitComplete = FALSE;
  265. pEventMbox->CompoundEvent.eventsVector = 0;
  266. pEventMbox->currentEvent = 0;
  267. /*
  268. * NOTE: don't set eventsMask = 0xffffffff;
  269. * its value is used after recovery has finished
  270. */
  271. /* Init callback table */
  272. eventMbox_InitCbTable (hEventMbox);
  273. }
  274. /****************************************************************************
  275. * eventMbox_InitComplete()
  276. ****************************************************************************
  277. * DESCRIPTION: ReConfigure the object, Send the Mask Vector to the FW
  278. *
  279. * INPUTS: pEventMbox this
  280. *
  281. * RETURNS:
  282. ****************************************************************************/
  283. void eventMbox_InitComplete (TI_HANDLE hEventMbox)
  284. {
  285. EventMbox_t *pEventMbox = (EventMbox_t *)hEventMbox;
  286. WLAN_REPORT_INFORMATION(pEventMbox->hReport, EVENT_MBOX_MODULE_LOG,
  287. ("eventMbox_InitComplete: mask=0x%x\n", pEventMbox->CompoundEvent.eventsMask));
  288. pEventMbox->bInitComplete = TRUE;
  289. /* Enable Events Interrupts */
  290. FwEvent_Enable (pEventMbox->hFwEvent, ACX_INTR_EVENT_A);
  291. FwEvent_Enable (pEventMbox->hFwEvent, ACX_INTR_EVENT_B);
  292. whalCtrl_SetInfoElemEventMask (pEventMbox->hWhalCtrl, pEventMbox->CompoundEvent.eventsMask);
  293. }
  294. /****************************************************************************
  295. * eventMbox_Stop()
  296. ****************************************************************************
  297. * DESCRIPTION: Stop the object while recovery until Init Complete.
  298. *
  299. * RETURNS: OK or NOK
  300. ****************************************************************************/
  301. int eventMbox_Stop(TI_HANDLE hEventMbox)
  302. {
  303. EventMbox_t *pEventMbox = (EventMbox_t *)hEventMbox;
  304. pEventMbox->state = EVENT_MBOX_STATE_IDLE;
  305. pEventMbox->CompoundEvent.eventsVector = 0;
  306. pEventMbox->currentEvent = 0;
  307. pEventMbox->bInitComplete = FALSE;
  308. return OK;
  309. }
  310. /****************************************************************************
  311. * eventMbox_ConfigCb()
  312. ****************************************************************************
  313. * DESCRIPTION:Read the SRAM Event mailbox address callback
  314. *
  315. * RETURNS: None
  316. ****************************************************************************/
  317. static void eventMbox_ConfigCb (TI_HANDLE hEventMbox, UINT8 module_id, TI_STATUS status)
  318. {
  319. EventMbox_t *pEventMbox = (EventMbox_t *)hEventMbox;
  320. pEventMbox->offset[1] = pEventMbox->offset[0] + sizeof(EventMailBox_t);
  321. WLAN_REPORT_INIT (pEventMbox->hReport, EVENT_MBOX_MODULE_LOG,
  322. ("eventMbox_ConfigCb: event A offset=0x%x, event B offset=0x%x, sizeof=%d\n",
  323. pEventMbox->offset[0], pEventMbox->offset[1], sizeof(EventMailBox_t)));
  324. /* Call upper layer callback */
  325. pEventMbox->fCb (pEventMbox->hCb, module_id, OK);
  326. }
  327. /****************************************************************************
  328. * eventMbox_ConfigHw()
  329. ****************************************************************************
  330. * DESCRIPTION:Read the SRAM Event mailbox address
  331. *
  332. * RETURNS: None
  333. ****************************************************************************/
  334. TI_STATUS eventMbox_ConfigHw (TI_HANDLE hEventMbox, UINT8 module_id, fnotify_t fCb, TI_HANDLE hCb)
  335. {
  336. EventMbox_t *pEventMbox = (EventMbox_t *)hEventMbox;
  337. TI_STATUS status;
  338. pEventMbox->fCb = (TNETWIF_callback_t)fCb;
  339. pEventMbox->hCb = hCb;
  340. /*
  341. * Get the event mailbox pointer
  342. */
  343. status = TNETWIF_ReadRegOpt (pEventMbox->hTNETWIF,
  344. REG_EVENT_MAILBOX_PTR,
  345. &pEventMbox->offset[0],
  346. module_id,
  347. eventMbox_ConfigCb,
  348. hEventMbox);
  349. if (status == TNETWIF_COMPLETE)
  350. {
  351. pEventMbox->offset[1] = pEventMbox->offset[0] + sizeof(EventMailBox_t);
  352. WLAN_REPORT_INIT (pEventMbox->hReport, EVENT_MBOX_MODULE_LOG,
  353. ("eventMbox_ConfigHw: event A offset=0x%x, event B offset=0x%x, sizeof=%d\n",
  354. pEventMbox->offset[0], pEventMbox->offset[1], sizeof(EventMailBox_t)));
  355. }
  356. return status;
  357. }
  358. /****************************************************************************
  359. * eventMbox_RegisterEventCB()
  360. ****************************************************************************
  361. * DESCRIPTION: register callback function for Events
  362. *
  363. * INPUTS: EvID Event ID
  364. * fCb Call Back
  365. * hCb Call Back Handle
  366. *
  367. * RETURNS: OK or NOK
  368. ****************************************************************************/
  369. int eventMbox_RegisterEventCB (TI_HANDLE hEventMbox, UINT32 EvID, void* fCb, TI_HANDLE hCb)
  370. {
  371. EventMbox_t *pEventMbox = (EventMbox_t *)hEventMbox;
  372. if (fCb == NULL || hCb == NULL)
  373. {
  374. WLAN_REPORT_ERROR (pEventMbox->hReport, EVENT_MBOX_MODULE_LOG, ("eventMbox_RegisterEventCB: NULL parameters\n"));
  375. return NOK;
  376. }
  377. if (EvID >= HAL_EVENT_ALL)
  378. {
  379. WLAN_REPORT_ERROR(pEventMbox->hReport, EVENT_MBOX_MODULE_LOG, ("eventMbox_RegisterEventCB: invalid ID\n"));
  380. return NOK;
  381. }
  382. pEventMbox->cbTable[EvID].fCb = fCb;
  383. pEventMbox->cbTable[EvID].hCb = hCb;
  384. WLAN_REPORT_INFORMATION(pEventMbox->hReport, EVENT_MBOX_MODULE_LOG,
  385. ("eventMbox_RegisterEventCB: EVENT %s has registered\n", eventTable[EvID].str));
  386. return OK;
  387. }
  388. /****************************************************************************
  389. * eventMbox_EvMask()
  390. ****************************************************************************
  391. * DESCRIPTION: The function Mask the Event in the Local Mask Vector
  392. * And in the FW Mask Vector
  393. *
  394. * INPUTS: Evid: The Event ID
  395. *
  396. * RETURNS: OK or NOK
  397. ****************************************************************************/
  398. int eventMbox_EvMask (TI_HANDLE hEventMbox, UINT32 EvID)
  399. {
  400. EventMbox_t *pEventMbox = (EventMbox_t *)hEventMbox;
  401. UINT32 *pEvMask = (UINT32*)&pEventMbox->CompoundEvent.eventsMask;
  402. if (EvID >= HAL_EVENT_ALL)
  403. {
  404. WLAN_REPORT_ERROR(pEventMbox->hReport, EVENT_MBOX_MODULE_LOG, ("eventMbox_EvMask: invalid ID\n"));
  405. return NOK;
  406. }
  407. *pEvMask |= eventTable[EvID].bitMask;
  408. WLAN_REPORT_INFORMATION(pEventMbox->hReport, EVENT_MBOX_MODULE_LOG,
  409. ("eventMbox_EvMask: EVENT %s is masked\n", eventTable[EvID].str));
  410. if (pEventMbox->bInitComplete == TRUE)
  411. {
  412. whalCtrl_SetInfoElemEventMask (pEventMbox->hWhalCtrl, *pEvMask);
  413. }
  414. return OK;
  415. }
  416. /****************************************************************************
  417. * eventMbox_EvUnMask()
  418. ****************************************************************************
  419. * DESCRIPTION: The function UnMask the Event in the Local Mask Vector
  420. * And in the FW Mask Vector
  421. *
  422. * INPUTS: Evid: The Event ID
  423. *
  424. * RETURNS: OK or NOK
  425. ****************************************************************************/
  426. int eventMbox_EvUnMask (TI_HANDLE hEventMbox, UINT32 EvID)
  427. {
  428. EventMbox_t *pEventMbox = (EventMbox_t *)hEventMbox;
  429. UINT32 *pEvMask = (UINT32*)&pEventMbox->CompoundEvent.eventsMask;
  430. if (EvID >= HAL_EVENT_ALL)
  431. {
  432. WLAN_REPORT_ERROR(pEventMbox->hReport, EVENT_MBOX_MODULE_LOG, ("eventMbox_EvUnMask: invalid ID\n"));
  433. return NOK;
  434. }
  435. *pEvMask &= ~eventTable[EvID].bitMask;
  436. WLAN_REPORT_INFORMATION (pEventMbox->hReport, EVENT_MBOX_MODULE_LOG,
  437. ("eventMbox_EvUnMask: EVENT %s is unmasked\n", eventTable[EvID].str));
  438. if (pEventMbox->bInitComplete == TRUE)
  439. {
  440. whalCtrl_SetInfoElemEventMask (pEventMbox->hWhalCtrl, *pEvMask);
  441. }
  442. return OK;
  443. }
  444. /****************************************************************************
  445. * eventMbox_Event()
  446. *****************************************************************************
  447. * DESCRIPTION: Called when Event A or B interrupt occur
  448. *
  449. * INPUTS: hEventMbox - The object
  450. *
  451. * RETURNS: TNETWIF_PENDING in case of Async and TNETWIF_OK on Sync
  452. *
  453. *****************************************************************************/
  454. TI_STATUS eventMbox_Event (TI_HANDLE hEventMbox)
  455. {
  456. EventMbox_t *pEventMbox = (EventMbox_t *)hEventMbox;
  457. /* Assume the driver is synchronous until opposite is proven */
  458. pEventMbox->bSync = TRUE;
  459. eventMbox_StateMachine (pEventMbox, FW_EVENT_MODULE_ID, OK);
  460. return pEventMbox->returnValue;
  461. }
  462. /********************************************************************************/
  463. /* Internal functions implementation. */
  464. /********************************************************************************/
  465. /****************************************************************************
  466. * eventMbox_StateMachine()
  467. ****************************************************************************
  468. * DESCRIPTION: Manage the EventMbox state machine
  469. *
  470. * The SM is running one event at a time (A or B) .
  471. * The order of the states is always the same: IDLE --> READ_BUF --> ACK_EVENT
  472. * The difference is whether we are using Synch or Asynch API.
  473. * In the Synch case (SDIO) we are looping in the while-loop till we return to IDLE, and we return
  474. * to FwEvent module a TNETWIF_OK status.
  475. * In the Asynch case we use the SM CB to return to the SM after each Asynch call
  476. * (In that case the return status is TNETWIF_PENDING, and we are waiting for the CB).
  477. * In the Asynch case the FwEvent module gets TNETWIF_PENDING in return, and waits for
  478. * the FwEvent_EventComplete() call in order to move the FwEvent SM.
  479. *
  480. * INPUTS: hFwEvent - The object
  481. * module_id - not used (for CB API only)
  482. * status - not used (for CB API only)
  483. *
  484. * OUTPUT: None
  485. *
  486. * RETURNS: TNETWIF_PENDING in case of Async and TNETWIF_OK on Sync
  487. ****************************************************************************/
  488. static void eventMbox_StateMachine (TI_HANDLE hEventMbox, UINT8 module_id, TI_STATUS status)
  489. {
  490. EventMbox_t *pEventMbox = (EventMbox_t *)hEventMbox;
  491. pEventMbox->returnValue = OK;
  492. while (pEventMbox->returnValue != TNETWIF_PENDING)
  493. {
  494. switch (pEventMbox->state)
  495. {
  496. case EVENT_MBOX_STATE_IDLE:
  497. pEventMbox->returnValue = TNETWIF_ReadMemOpt (pEventMbox->hTNETWIF,
  498. pEventMbox->offset[pEventMbox->currentEvent],
  499. PADREAD (&pEventMbox->CompoundEvent),
  500. EVENT_REPORT_SIZE,
  501. FW_EVENT_MODULE_ID,
  502. eventMbox_StateMachine,
  503. hEventMbox);
  504. pEventMbox->state = EVENT_MBOX_STATE_READ_BUF;
  505. break;
  506. case EVENT_MBOX_STATE_READ_BUF:
  507. /* Notify The appropriate layer about the incoming event */
  508. eventMbox_HandleEvent (hEventMbox);
  509. /* Trigger the FW when finishing handle the event */
  510. pEventMbox->returnValue = TNETWIF_WriteRegOpt (pEventMbox->hTNETWIF,
  511. ACX_REG_INTERRUPT_TRIG,
  512. INTR_TRIG_EVENT_ACK,
  513. FW_EVENT_MODULE_ID,
  514. eventMbox_StateMachine,
  515. hEventMbox);
  516. pEventMbox->state = EVENT_MBOX_STATE_ACK_EVENT;
  517. break;
  518. case EVENT_MBOX_STATE_ACK_EVENT:
  519. /* Handling of the event is done. Switch to the next buffer for the next time */
  520. pEventMbox->currentEvent = 1 - pEventMbox->currentEvent;
  521. if (FALSE == pEventMbox->bSync)
  522. {
  523. /* Asynchronous bus - call FwEvent for notifying the completion */
  524. FwEvent_EventComplete (pEventMbox->hFwEvent, TNETWIF_OK);
  525. }
  526. else
  527. {
  528. /* This is the Sync case and we return TNETWIF_OK */
  529. pEventMbox->returnValue = TNETWIF_OK;
  530. }
  531. /* Exit SM */
  532. pEventMbox->state = EVENT_MBOX_STATE_IDLE;
  533. return;
  534. default:
  535. WLAN_REPORT_ERROR(pEventMbox->hReport, EVENT_MBOX_MODULE_LOG,
  536. ("eventMbox_StateMachine: unknown state !!!\n"));
  537. break;
  538. }
  539. }
  540. /* If we are here - we got TNETWIF_PENDING, so we are in asynchronous mode */
  541. pEventMbox->bSync = FALSE;
  542. }
  543. /****************************************************************************
  544. * eventMbox_HandleEvent()
  545. ****************************************************************************
  546. * DESCRIPTION: The functions reads the parameters in the Event mailBox
  547. * and activates the appropriate CallBack function.
  548. *
  549. * INPUTS:
  550. *
  551. * OUTPUT: None
  552. *
  553. * RETURNS: OK.
  554. ****************************************************************************/
  555. static void eventMbox_HandleEvent (TI_HANDLE hEventMbox)
  556. {
  557. EventMbox_t *pEventMbox = (EventMbox_t *)hEventMbox;
  558. EventCB_t *pEventCb;
  559. UINT32 EvID;
  560. UINT32 EvMask = pEventMbox->CompoundEvent.eventsMask;
  561. UINT32 EvVector = pEventMbox->CompoundEvent.eventsVector;
  562. #ifdef TI_DBG
  563. pEventMbox->uCompounEvCount++;
  564. #endif /* TI_DBG */
  565. #if EVMBX_DBG
  566. WLAN_REPORT_INFORMATION(pEventMbox->hReport, EVENT_MBOX_MODULE_LOG,
  567. ("eventMbox_HandleEvent: Event Vector = 0x%x\n", EvVector));
  568. #endif
  569. /*
  570. Handle Events
  571. */
  572. for (EvID = 0; EvID < HAL_EVENT_ALL; EvID++)
  573. {
  574. pEventCb = &pEventMbox->cbTable[EvID];
  575. /* Check if the Event Bit in the vector in set */
  576. if (IS_EVENT_BIT_ON (EvVector, eventTable[EvID].bitMask))
  577. {
  578. #ifdef TI_DBG
  579. pEventMbox->uTotalEvCount++;
  580. #endif /* TI_DBG */
  581. pEventCb->uCount++;
  582. /* Check if the Mask Bit in the Mask vector in off */
  583. if (IS_EVENT_BIT_OFF (EvMask, eventTable[EvID].bitMask))
  584. {
  585. #if EVMBX_DBG
  586. WLAN_REPORT_INFORMATION(pEventMbox->hReport, EVENT_MBOX_MODULE_LOG,
  587. ("eventMbox_HandleEvent: EVENT %s has occurred\n", eventTable[EvID].str));
  588. #endif
  589. if (pEventCb->fCb != NULL)
  590. {
  591. if (eventTable[EvID].dataLen)
  592. {
  593. ((whal_hwMboxDataEvCB)pEventCb->fCb) (pEventCb->hCb,
  594. (char *)pEventMbox->cbTable[EvID].pDataOffs,
  595. eventTable[EvID].dataLen);
  596. }
  597. else
  598. {
  599. ((whal_hwMboxEvCB)pEventCb->fCb) (pEventCb->hCb);
  600. }
  601. }
  602. }
  603. }
  604. } /*End for*/
  605. }
  606. /*
  607. * eventMbox_Print: print the Event Mailbox statistic :Number 890
  608. */
  609. void eventMbox_Print (TI_HANDLE hEventMbox)
  610. {
  611. #ifdef TI_DBG
  612. EventMbox_t *pEventMbox = (EventMbox_t *)hEventMbox;
  613. UINT32 i;
  614. UINT32 EvMask = pEventMbox->CompoundEvent.eventsMask;
  615. UINT32 EvVector = pEventMbox->CompoundEvent.eventsVector;
  616. WLAN_REPORT_REPLY(pEventMbox->hReport, EVENT_MBOX_MODULE_LOG,
  617. ("------------------------- EventMbox Print ----------------------------\n"));
  618. WLAN_REPORT_INFORMATION(pEventMbox->hReport, EVENT_MBOX_MODULE_LOG,
  619. (" eventMbox_HandleEvent: Event Vector = 0x%x\n", EvVector));
  620. WLAN_REPORT_INFORMATION(pEventMbox->hReport, EVENT_MBOX_MODULE_LOG,
  621. (" eventMbox_HandleEvent: Event Mask = 0x%x\n", EvMask));
  622. WLAN_REPORT_REPLY(pEventMbox->hReport, EVENT_MBOX_MODULE_LOG,
  623. (" Total Number Of Compound Event = %d: \n", pEventMbox->uCompounEvCount));
  624. WLAN_REPORT_REPLY(pEventMbox->hReport, EVENT_MBOX_MODULE_LOG,
  625. (" Total Number Of Events = %d: \n", pEventMbox->uTotalEvCount));
  626. WLAN_REPORT_REPLY(pEventMbox->hReport, EVENT_MBOX_MODULE_LOG,("\t\t\t\t *** Event Counters *** :\n"));
  627. for (i = 0; i < HAL_EVENT_ALL; i++)
  628. {
  629. WLAN_REPORT_REPLY(pEventMbox->hReport, EVENT_MBOX_MODULE_LOG,
  630. (" %d) Event Name = EVENT %s, Number of Event = %d\n",
  631. i, eventTable[i].str, pEventMbox->cbTable[i].uCount));
  632. }
  633. WLAN_REPORT_REPLY(pEventMbox->hReport, EVENT_MBOX_MODULE_LOG,
  634. ("------------------------- EventMbox Print End ----------------------------\n"));
  635. #endif /* TI_DBG */
  636. }