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

/drivers/net/wireless/tiwlan1251/common/src/TNETW_Driver/FW_Transfer/Rx_Xfer/RxXfer.c

https://bitbucket.org/cyanogenmod/cm-kernel
C | 747 lines | 382 code | 115 blank | 250 comment | 39 complexity | eadaf6f64e1e72e7c8d6539f188f3e7c 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: rxXfer.c
  38. *
  39. * PURPOSE: Rx Xfer module implementation.Responsible for reading Rx from the FW
  40. * and forward it to the upper layers.
  41. *
  42. ****************************************************************************/
  43. #include "RxXfer.h"
  44. #include "utils.h"
  45. #include "report.h"
  46. #include "shmUtils.h"
  47. #include "FwEvent_api.h"
  48. #include "tnetwCommon.h"
  49. #include "whalBus_Defs.h"
  50. #define PLCP_HEADER_LENGTH 8
  51. /************************ static function declaration *****************************/
  52. static void rxXfer_StateMachine (TI_HANDLE hRxXfer, UINT8 module_id, TI_STATUS status);
  53. static TI_STATUS rxXfer_ReadHeader (RxXfer_t *pRxXfer);
  54. static TI_STATUS rxXfer_ReadBody (RxXfer_t *pRxXfer);
  55. static void rxXfer_ForwardCB (RxXfer_t *pRxXfer);
  56. static TI_STATUS rxXfer_AckRx (RxXfer_t *pRxXfer);
  57. static void rxXfer_ConvertDescFlagsToAppFlags (UINT16 descRxFlags, UINT32 *aFlags, TI_STATUS *pPacketStatus);
  58. /****************************************************************************
  59. * RxXfer_Create()
  60. ****************************************************************************
  61. * DESCRIPTION: Create the RxXfer module object
  62. *
  63. * INPUTS: None
  64. *
  65. * OUTPUT: None
  66. *
  67. * RETURNS: The Created object
  68. ****************************************************************************/
  69. TI_HANDLE rxXfer_Create (TI_HANDLE hOs)
  70. {
  71. RxXfer_t *pRxXfer;
  72. pRxXfer = os_memoryAlloc (hOs, sizeof(RxXfer_t));
  73. if (pRxXfer == NULL)
  74. return NULL;
  75. /* For all the counters */
  76. os_memoryZero (hOs, pRxXfer, sizeof(RxXfer_t));
  77. pRxXfer->hOs = hOs;
  78. return (TI_HANDLE)pRxXfer;
  79. }
  80. /****************************************************************************
  81. * RxXfer_Destroy()
  82. ****************************************************************************
  83. * DESCRIPTION: Destroy the RxXfer module object
  84. *
  85. * INPUTS: hRxXfer - The object to free
  86. *
  87. * OUTPUT: None
  88. *
  89. * RETURNS:
  90. ****************************************************************************/
  91. void rxXfer_Destroy (TI_HANDLE hRxXfer)
  92. {
  93. RxXfer_t *pRxXfer = (RxXfer_t *)hRxXfer;
  94. if (pRxXfer)
  95. {
  96. os_memoryFree (pRxXfer->hOs, pRxXfer, sizeof(RxXfer_t));
  97. }
  98. } /* RxXfer_Destroy() */
  99. /****************************************************************************
  100. * RxXfer_Config()
  101. ****************************************************************************
  102. * DESCRIPTION: Destroy the FwEvent module object
  103. *
  104. * INPUTS: hRxXfer - FwEvent handle;
  105. *
  106. * OUTPUT: None
  107. *
  108. * RETURNS: None
  109. ****************************************************************************/
  110. void rxXfer_Config(TI_HANDLE hRxXfer,
  111. TI_HANDLE hFwEvent,
  112. TI_HANDLE hMemMgr,
  113. TI_HANDLE hReport,
  114. TI_HANDLE hTNETWIF)
  115. {
  116. RxXfer_t *pRxXfer = (RxXfer_t *)hRxXfer;
  117. pRxXfer->hFwEvent = hFwEvent;
  118. pRxXfer->hMemMgr = hMemMgr;
  119. pRxXfer->hReport = hReport;
  120. pRxXfer->hTNETWIF = hTNETWIF;
  121. pRxXfer->state = RX_XFER_STATE_IDLE;
  122. pRxXfer->currBuffer = 0; /* first buffer to read from */
  123. pRxXfer->lastPacketId = 0;
  124. FwEvent_Enable (pRxXfer->hFwEvent, ACX_INTR_RX0_DATA);
  125. FwEvent_Enable (pRxXfer->hFwEvent, ACX_INTR_RX1_DATA);
  126. #ifdef TI_DBG
  127. rxXfer_ClearStats (pRxXfer);
  128. #endif
  129. }
  130. /****************************************************************************
  131. * rxXfer_Register_CB()
  132. ****************************************************************************
  133. * DESCRIPTION: Register the function to be called for received Rx
  134. * or the function to be called for request for buffer
  135. *
  136. * INPUTS: hRxXfer - RxXfer handle;
  137. *
  138. * OUTPUT: None
  139. *
  140. * RETURNS: None
  141. ****************************************************************************/
  142. void rxXfer_Register_CB (TI_HANDLE hRxXfer, tiUINT32 CallBackID, void *CBFunc, TI_HANDLE CBObj)
  143. {
  144. RxXfer_t* pRxXfer = (RxXfer_t *)hRxXfer;
  145. WLAN_REPORT_INFORMATION (pRxXfer->hReport, HAL_RX_MODULE_LOG, ("rxXfer_Register_CB (Value = 0x%x)\n", CallBackID));
  146. switch(CallBackID)
  147. {
  148. case HAL_INT_RECEIVE_PACKET:
  149. pRxXfer->ReceivePacketCB = (packetReceiveCB_t)CBFunc;
  150. pRxXfer->ReceivePacketCB_handle = CBObj;
  151. break;
  152. case HAL_INT_REQUEST_FOR_BUFFER:
  153. pRxXfer->RequestForBufferCB = (requestForBufferCB_t)CBFunc;
  154. pRxXfer->RequestForBufferCB_handle = CBObj;
  155. break;
  156. default:
  157. WLAN_REPORT_ERROR(pRxXfer->hReport, HAL_RX_MODULE_LOG, ("rxXfer_Register_CB - Illegal value\n"));
  158. return;
  159. }
  160. }
  161. /****************************************************************************
  162. * rxXfer_SetDoubleBufferAddr()
  163. ****************************************************************************
  164. * DESCRIPTION: Store the addresses of the Double Buffer
  165. *
  166. * INPUTS: hRxXfer - RxXfer handle;
  167. *
  168. * OUTPUT: None
  169. *
  170. * RETURNS: None
  171. ****************************************************************************/
  172. void rxXfer_SetDoubleBufferAddr (TI_HANDLE hRxXfer, ACXDataPathParamsResp_t *pDataPathParams)
  173. {
  174. RxXfer_t* pRxXfer = (RxXfer_t *)hRxXfer;
  175. pRxXfer->doubleBuffer[0] = pDataPathParams->rxPacketRingAddr;
  176. pRxXfer->doubleBuffer[1] = pDataPathParams->rxPacketRingAddr + pDataPathParams->rxPacketRingChunkSize;
  177. }
  178. /****************************************************************************
  179. * rxXfer_RxEvent()
  180. ****************************************************************************
  181. * DESCRIPTION: Called upon Rx event from the FW.calls the SM
  182. *
  183. * INPUTS: hRxXfer - RxXfer handle;
  184. *
  185. * OUTPUT: None
  186. *
  187. * RETURNS: TNETWIF_OK in case of Synch mode, or TNETWIF_PENDING in case of Asynch mode
  188. * (when returning TNETWIF_PENDING, FwEvent module expects the FwEvent_EventComplete()
  189. * function call to finish the Rx Client handling
  190. *
  191. ****************************************************************************/
  192. TI_STATUS rxXfer_RxEvent (TI_HANDLE hRxXfer)
  193. {
  194. RxXfer_t* pRxXfer = (RxXfer_t *)hRxXfer;
  195. if (RX_XFER_STATE_IDLE != pRxXfer->state)
  196. {
  197. WLAN_REPORT_ERROR(pRxXfer->hReport,HAL_RX_MODULE_LOG,
  198. ("rxXfer_RxEvent called in state %d !!!\n",pRxXfer->state));
  199. return TNETWIF_ERROR;
  200. }
  201. WLAN_REPORT_INFORMATION (pRxXfer->hReport, HAL_RX_MODULE_LOG,
  202. ("rxXfer_RxEvent Calling rxXfer_StateMachine : currBuffer = %d \n",
  203. pRxXfer->currBuffer));
  204. #ifdef TI_DBG
  205. if (pRxXfer->currBuffer == 0)
  206. pRxXfer->DbgStats.numIrq0 ++;
  207. else
  208. pRxXfer->DbgStats.numIrq1 ++;
  209. #endif
  210. /* Assume that we are in synch bus until otherwise is proven */
  211. pRxXfer->bSync = TRUE;
  212. /* The packet status is OK unless we receive error */
  213. pRxXfer->packetStatus = OK;
  214. rxXfer_StateMachine (hRxXfer, 0, OK);
  215. return pRxXfer->returnValue;
  216. }
  217. /****************************************************************************
  218. * rxXfer_StateMachine()
  219. ****************************************************************************
  220. * DESCRIPTION: SM for handling Synch & Asynch read of RX from the HW.
  221. * The flow of the SM is by that order:
  222. * IDLE -> READING_HDR -> READING_PKT -> EXIT
  223. * On synch mode - each state is called in the same context in the while loop.
  224. * On Asynch mode - each state returns TNETWIF_PENDING and exits the SM.The CB of
  225. * each Asynch is the SM, that will continue the Rx handling.
  226. *
  227. * INPUTS: hRxXfer - RxXfer handle;
  228. *
  229. * OUTPUT: pRxXfer->returnValue is TNETWIF_OK in synch mode and TNETWIF_PENDING in Asynch mode.
  230. *
  231. * RETURNS:
  232. ****************************************************************************/
  233. static void rxXfer_StateMachine (TI_HANDLE hRxXfer, UINT8 module_id, TI_STATUS status)
  234. {
  235. RxXfer_t* pRxXfer = (RxXfer_t *)hRxXfer;
  236. pRxXfer->returnValue = OK;
  237. /*
  238. * This while loop will continue till the exit or when waiting for the CB due to
  239. * memory transfer operation pending for DMA to complete
  240. */
  241. while (TNETWIF_PENDING != pRxXfer->returnValue)
  242. {
  243. WLAN_REPORT_DEBUG_RX (pRxXfer->hReport, ("Rx SM: state = %d, rc = %d\n",
  244. pRxXfer->state, pRxXfer->returnValue));
  245. switch(pRxXfer->state)
  246. {
  247. case RX_XFER_STATE_IDLE:
  248. pRxXfer->state = RX_XFER_STATE_READING_HDR;
  249. pRxXfer->returnValue = rxXfer_ReadHeader (pRxXfer);
  250. break;
  251. case RX_XFER_STATE_READING_HDR:
  252. pRxXfer->state = RX_XFER_STATE_READING_PKT;
  253. pRxXfer->returnValue = rxXfer_ReadBody (pRxXfer);
  254. break;
  255. case RX_XFER_STATE_READING_PKT:
  256. pRxXfer->state = RX_XFER_STATE_EXITING;
  257. rxXfer_ForwardCB(pRxXfer);
  258. pRxXfer->returnValue = rxXfer_AckRx (pRxXfer);
  259. break;
  260. case RX_XFER_STATE_EXITING:
  261. pRxXfer->state = RX_XFER_STATE_IDLE;
  262. if (FALSE == pRxXfer->bSync)
  263. {
  264. /* Async bus - call FwEvent for notifying the completion */
  265. FwEvent_EventComplete (pRxXfer->hFwEvent, TNETWIF_OK);
  266. }
  267. else
  268. {
  269. /* This is the sync case - we should return TNETWIF_OK */
  270. pRxXfer->returnValue = TNETWIF_OK;
  271. }
  272. return;
  273. default:
  274. WLAN_REPORT_ERROR (pRxXfer->hReport, HAL_RX_MODULE_LOG,
  275. ("rxXfer_StateMachine Unknown state = %d\n",
  276. pRxXfer->state));
  277. }
  278. if (TNETWIF_ERROR == pRxXfer->returnValue)
  279. {
  280. WLAN_REPORT_ERROR (pRxXfer->hReport, HAL_RX_MODULE_LOG,
  281. ("rxXfer_StateMachine returning TNETWIF_ERROR in state %d. Next packet will be discarded!!!\n",pRxXfer->state));
  282. /* Next packet will be marked as NOK and will be discarded */
  283. pRxXfer->packetStatus = NOK;
  284. }
  285. }
  286. /* If we are here - we got TNETWIF_PENDING, so we are in Async mode */
  287. pRxXfer->bSync = FALSE;
  288. }
  289. /****************************************************************************
  290. * rxXfer_ReadHeader()
  291. ****************************************************************************
  292. * DESCRIPTION: Read the packet header (descriptor)
  293. *
  294. * INPUTS: pRxXfer - RxXfer handle;
  295. *
  296. * OUTPUT:
  297. *
  298. * RETURNS: TNETWIF_OK in synch mode and TNETWIF_PENDING in Asynch mode.
  299. ****************************************************************************/
  300. TI_STATUS rxXfer_ReadHeader(RxXfer_t *pRxXfer)
  301. {
  302. WLAN_REPORT_DEBUG_RX(pRxXfer->hReport,
  303. ("rxXfer_readHeader: Before Read Memory Addr from DB No %d Addr %x !!!! \n",pRxXfer->currBuffer,pRxXfer->doubleBuffer[pRxXfer->currBuffer]));
  304. return TNETWIF_ReadMemOpt (pRxXfer->hTNETWIF,
  305. pRxXfer->doubleBuffer[pRxXfer->currBuffer],
  306. PADREAD (&pRxXfer->rxDescriptor),
  307. RX_DESCRIPTOR_SIZE,
  308. FW_EVENT_MODULE_ID,
  309. rxXfer_StateMachine,
  310. (TI_HANDLE)pRxXfer);
  311. }
  312. /****************************************************************************
  313. * rxXfer_ReadBody()
  314. ****************************************************************************
  315. * DESCRIPTION: Read the packet body
  316. *
  317. * INPUTS: pRxXfer - RxXfer handle;
  318. *
  319. * OUTPUT:
  320. *
  321. * RETURNS: TNETWIF_OK in synch mode and TNETWIF_PENDING in Asynch mode.
  322. ****************************************************************************/
  323. TI_STATUS rxXfer_ReadBody (RxXfer_t *pRxXfer)
  324. {
  325. UINT32 uCurrPacketId; /* Current packet ID */
  326. UINT32 uLastPacketIdIncremented; /* The last received packet-ID incremented with modulo */
  327. UINT32 uAlignToWord; /* Used to align the length of the packet to a WORD */
  328. /* Check for correct length of Rx Descriptor */
  329. if (pRxXfer->rxDescriptor.length <= PLCP_HEADER_LENGTH ||
  330. pRxXfer->rxDescriptor.length > (MAX_DATA_BODY_LENGTH + PLCP_HEADER_LENGTH))
  331. {
  332. WLAN_REPORT_ERROR (pRxXfer->hReport, HAL_RX_MODULE_LOG,
  333. ("rxXfer_ReadBody: RxLength not correct! rxDescriptor.length=%d\n",
  334. pRxXfer->rxDescriptor.length));
  335. return TNETWIF_ERROR;
  336. }
  337. pRxXfer->rxDescriptor.length = pRxXfer->rxDescriptor.length - PLCP_HEADER_LENGTH;
  338. uCurrPacketId = (pRxXfer->rxDescriptor.flags & RX_DESC_SEQNUM_MASK) >> RX_DESC_PACKETID_SHIFT;
  339. uLastPacketIdIncremented = (pRxXfer->lastPacketId + 1) % (RX_MAX_PACKET_ID + 1);
  340. if (uCurrPacketId == uLastPacketIdIncremented)
  341. {
  342. pRxXfer->lastPacketId = uLastPacketIdIncremented;
  343. #ifdef GWSI_RECORDING
  344. WLAN_REPORT_GWSI_RECORDING(pRxXfer->hReport, ("GWSI Recording, rxXfer_ReadBody (request for buffer), Length = 0x%x\n", pRxXfer->rxDescriptor.length));
  345. #endif /* GWSI_RECORDING */
  346. }
  347. else
  348. {
  349. WLAN_REPORT_ERROR (pRxXfer->hReport, HAL_RX_MODULE_LOG,
  350. ("rxXfer_ReadBody: Packet ID mismatch! CurrPacketId=%d, lastPacketId=%d\n",
  351. uCurrPacketId, pRxXfer->lastPacketId));
  352. #ifdef TI_DBG
  353. pRxXfer->DbgStats.numPacketsDroppedPacketIDMismatch++;
  354. rxXfer_PrintStats ((TI_HANDLE)pRxXfer);
  355. #endif
  356. /* Reset the lastPacketId to be synchronized on the Current Packet ID read from the FW */
  357. pRxXfer->lastPacketId = uCurrPacketId;
  358. }
  359. /*
  360. * Add uAlignToWord to the body length since we have to read buffers from the FW in 4 bytes chunks.
  361. * NOTE: The size of the buffer is aligned to 4, but the packet itself is not.
  362. * Releasing the memory must be done with the actual size allocated and not the size of the packet
  363. */
  364. uAlignToWord = 4 - (pRxXfer->rxDescriptor.length & 0x3); /* (&0x3) is equal to (% 4) */
  365. uAlignToWord = (uAlignToWord == 4) ? 0 : uAlignToWord;
  366. /*
  367. * Requesting buffer from the upper layer memory manager.
  368. * Add the align to word and offset for the access to the bus
  369. * Also send the encryption status of the packet. It is used only for GWSI alignment.
  370. */
  371. pRxXfer->pPacketBuffer = (void *)pRxXfer->RequestForBufferCB (
  372. pRxXfer->RequestForBufferCB_handle,
  373. pRxXfer->rxDescriptor.length + uAlignToWord + TNETWIF_READ_OFFSET_BYTES,
  374. ((pRxXfer->rxDescriptor.flags & RX_DESC_ENCRYPTION_MASK) >> RX_DESC_FLAGS_ENCRYPTION));
  375. if (pRxXfer->pPacketBuffer != NULL)
  376. {
  377. WLAN_REPORT_DEBUG_RX (pRxXfer->hReport,
  378. (" rxXfer_ReadBody() : packetLength %d uAligntoWord = %d\n",
  379. pRxXfer->rxDescriptor.length, uAlignToWord));
  380. #ifdef TI_DBG
  381. pRxXfer->DbgStats.numPacketsRead++;
  382. pRxXfer->DbgStats.numBytesRead += pRxXfer->rxDescriptor.length;
  383. #endif
  384. /* Read the packet and return TNETWIF_OK or TNETWIF_PENDING */
  385. return TNETWIF_ReadMemOpt (pRxXfer->hTNETWIF,
  386. pRxXfer->doubleBuffer[pRxXfer->currBuffer] + RX_DESCRIPTOR_SIZE + 20,
  387. (UINT8 *)pRxXfer->pPacketBuffer,
  388. (UINT32)pRxXfer->rxDescriptor.length + uAlignToWord,
  389. FW_EVENT_MODULE_ID,
  390. rxXfer_StateMachine,
  391. (TI_HANDLE)pRxXfer);
  392. }
  393. /* If no buffer could be allocated */
  394. else
  395. {
  396. WLAN_REPORT_ERROR (pRxXfer->hReport, HAL_RX_MODULE_LOG,
  397. ("rxXfer_RecvOnePacket: pRxXfer->rxDescriptor %x NULL !!!! \n",pRxXfer->pPacketBuffer));
  398. #ifdef TI_DBG
  399. pRxXfer->DbgStats.numPacketsDroppedNoMem++;
  400. #endif
  401. }
  402. return TNETWIF_ERROR;
  403. }
  404. /****************************************************************************
  405. * rxXfer_ForwardCB()
  406. ****************************************************************************
  407. * DESCRIPTION: Parse the Packet with the descriptor and forward the results and
  408. * the packet to the registered CB
  409. *
  410. * INPUTS: pRxXfer - RxXfer handle;
  411. *
  412. * OUTPUT:
  413. *
  414. * RETURNS:
  415. ****************************************************************************/
  416. void rxXfer_ForwardCB (RxXfer_t *pRxXfer)
  417. {
  418. UINT32 aFlags = 0;
  419. rate_e eRate = DRV_RATE_AUTO;
  420. rxXfer_Reserved_t Reserved;
  421. RxIfDescriptor_t *pRxParams = &pRxXfer->rxDescriptor;
  422. WLAN_REPORT_DEBUG_RX (pRxXfer->hReport, ("rxXfer_ForwardCB ENTERING\n"));
  423. eRate = ConvertHwRateToDrvRate(pRxParams->rate, (BOOL)(OFDM_RATE_BIT & pRxParams->modPre));
  424. WLAN_REPORT_DEBUG_RX (pRxXfer->hReport,
  425. (" rxXfer_ForwardCB() HwRate = %d, modPre = %d eRate = %d:\n",pRxParams->rate,pRxParams->modPre,eRate));
  426. if ( eRate == DRV_RATE_AUTO)
  427. {
  428. WLAN_REPORT_ERROR (pRxXfer->hReport, HAL_RX_MODULE_LOG,
  429. ("rxXfer_ForwardCB: Received wrong rate from Hw = 0x%x, modPre = 0x%x\n",
  430. pRxParams->rate,pRxParams->modPre));
  431. }
  432. Reserved.packetType = (rxPacketType_e)pRxParams->type;
  433. Reserved.rssi = pRxParams->rssi;
  434. Reserved.SNR = pRxParams->snr;
  435. Reserved.band = pRxParams->band;
  436. Reserved.TimeStamp = pRxParams->timestamp;
  437. if (pRxXfer->packetStatus == OK)
  438. {
  439. /* Get the mac header from the TNETWIF_READ_OFFSET_BYTES in the packet Buffer */
  440. dot11_header_t *pMacHdr = (dot11_header_t *)((UINT8*)pRxXfer->pPacketBuffer + TNETWIF_READ_OFFSET_BYTES);
  441. #ifdef GWSI_RECORDING
  442. static char TempString[(1600 * 2) + 1];
  443. #endif /* GWSI_RECORDING */
  444. /* Handle endian for the frame control fields */
  445. pMacHdr->fc = ENDIAN_HANDLE_WORD(pMacHdr->fc);
  446. pMacHdr->duration = ENDIAN_HANDLE_WORD(pMacHdr->duration);
  447. pMacHdr->seqCtrl = ENDIAN_HANDLE_WORD(pMacHdr->seqCtrl);
  448. rxXfer_ConvertDescFlagsToAppFlags (pRxParams->flags, &aFlags, &pRxXfer->packetStatus);
  449. #ifdef GWSI_RECORDING
  450. convert_hex_to_string ((UINT8*)pRxXfer->pPacketBuffer + TNETWIF_READ_OFFSET_BYTES, TempString, pRxParams->length);
  451. WLAN_REPORT_GWSI_RECORDING (pRxXfer->hReport,
  452. ("GWSI Recording, rxXfer_RecvPacketCB, aStatus = 0x%x, aRate = 0x%x, aRCPI = 0x%x, aFlags = 0x%x\n",
  453. pRxXfer->packetStatus, aRate, pRxParams->rcpi, aFlags));
  454. WLAN_REPORT_GWSI_RECORDING (pRxXfer->hReport,
  455. ("GWSI Recording, rxXfer_RecvPacketCB, aLength = 0x%x, aFrame = %s\n",
  456. pRxParams->length, TempString));
  457. #endif /* GWSI_RECORDING */
  458. }
  459. /* Set the packet to upper layer. packet is starting after TNETWIF_READ_OFFSET_BYTES bytes */
  460. pRxXfer->ReceivePacketCB (pRxXfer->ReceivePacketCB_handle,
  461. pRxXfer->packetStatus,
  462. (const void*)pRxXfer->pPacketBuffer,
  463. pRxParams->length,
  464. (UINT32)eRate,
  465. pRxParams->rcpi,
  466. pRxParams->chanNum,
  467. (void *)&Reserved,
  468. aFlags);
  469. }
  470. /****************************************************************************
  471. * rxXfer_AckRx()
  472. ****************************************************************************
  473. * DESCRIPTION: Set Ack to the FW that the buffer was read
  474. *
  475. * INPUTS: pRxXfer - RxXfer handle;
  476. *
  477. * OUTPUT:
  478. *
  479. * RETURNS: TNETWIF_OK in synch mode and TNETWIF_PENDING in Asynch mode.
  480. ****************************************************************************/
  481. TI_STATUS rxXfer_AckRx (RxXfer_t *pRxXfer)
  482. {
  483. TI_STATUS status;
  484. /* Ack on the opposite buffer since we changed it in rxXfer_ForwardCB() */
  485. if (pRxXfer->currBuffer == 0)
  486. {
  487. WLAN_REPORT_DEBUG_RX (pRxXfer->hReport, ("Ack on Rx 0\n"));
  488. #ifdef TI_DBG
  489. pRxXfer->DbgStats.numAck0 ++;
  490. #endif
  491. status = TNETWIF_WriteRegOpt (pRxXfer->hTNETWIF,
  492. ACX_REG_INTERRUPT_TRIG,
  493. INTR_TRIG_RX_PROC0,
  494. FW_EVENT_MODULE_ID,
  495. rxXfer_StateMachine,
  496. (TI_HANDLE)pRxXfer);
  497. }
  498. else
  499. {
  500. WLAN_REPORT_DEBUG_RX (pRxXfer->hReport, ("Ack on Rx 1\n"));
  501. #ifdef TI_DBG
  502. pRxXfer->DbgStats.numAck1 ++;
  503. #endif
  504. status = TNETWIF_WriteRegOpt (pRxXfer->hTNETWIF,
  505. ACX_REG_INTERRUPT_TRIG_H,
  506. INTR_TRIG_RX_PROC1,
  507. FW_EVENT_MODULE_ID,
  508. rxXfer_StateMachine,
  509. (TI_HANDLE)pRxXfer);
  510. }
  511. /* Calculate the next buffer to read from (0 or 1) */
  512. pRxXfer->currBuffer = 1 - pRxXfer->currBuffer;
  513. return status;
  514. }
  515. /****************************************************************************
  516. * rxXfer_ConvertDescFlagsToAppFlags()
  517. ****************************************************************************
  518. * DESCRIPTION: Add some spacing before capital letters and you'll figure it out ...
  519. *
  520. * INPUTS: descRxFlags - Bits as received from Fw
  521. *
  522. * OUTPUT: aFlags - converted bits to our definition
  523. * pPacketStatus - changed status if an error was indicated
  524. * RETURNS:
  525. ****************************************************************************/
  526. static void rxXfer_ConvertDescFlagsToAppFlags (UINT16 descRxFlags, UINT32 *aFlags, TI_STATUS *pPacketStatus)
  527. {
  528. UINT32 flags = 0;
  529. if (descRxFlags & RX_DESC_MATCH_RXADDR1)
  530. {
  531. flags |= RX_PACKET_FLAGS_MATCH_RXADDR1;
  532. }
  533. if (descRxFlags & RX_DESC_MCAST)
  534. {
  535. flags |= RX_PACKET_FLAGS_GROUP_ADDR;
  536. }
  537. if (descRxFlags & RX_DESC_STAINTIM)
  538. {
  539. flags |= RX_PACKET_FLAGS_STAINTIM;
  540. }
  541. if (descRxFlags & RX_DESC_VIRTUAL_BM)
  542. {
  543. flags |= RX_PACKET_FLAGS_VIRTUAL_BM;
  544. }
  545. if (descRxFlags & RX_DESC_BCAST)
  546. {
  547. flags |= RX_PACKET_FLAGS_BCAST;
  548. }
  549. if (descRxFlags & RX_DESC_MATCH_SSID)
  550. {
  551. flags |= RX_PACKET_FLAGS_MATCH_SSID;
  552. }
  553. if (descRxFlags & RX_DESC_MATCH_BSSID)
  554. {
  555. flags |= RX_PACKET_FLAGS_MATCH_BSSID;
  556. }
  557. flags |= (descRxFlags & RX_DESC_ENCRYPTION_MASK) << RX_PACKET_FLAGS_ENCRYPTION_SHIFT_FROM_DESC;
  558. if (descRxFlags & RX_DESC_MEASURMENT)
  559. {
  560. flags |= RX_PACKET_FLAGS_MEASURMENT;
  561. }
  562. if (descRxFlags & RX_DESC_MIC_FAIL)
  563. {
  564. *pPacketStatus = RX_MIC_FAILURE_ERROR;
  565. }
  566. if (descRxFlags & RX_DESC_DECRYPT_FAIL)
  567. {
  568. *pPacketStatus = RX_DECRYPT_FAILURE;
  569. }
  570. *aFlags = flags;
  571. }
  572. #ifdef TI_DBG
  573. /****************************************************************************
  574. * rxXfer_ClearStats()
  575. ****************************************************************************
  576. * DESCRIPTION:
  577. *
  578. * INPUTS:
  579. * pRxXfer The object
  580. *
  581. * OUTPUT: None
  582. *
  583. * RETURNS: OK.
  584. ****************************************************************************/
  585. void rxXfer_ClearStats (TI_HANDLE hRxXfer)
  586. {
  587. RxXfer_t * pRxXfer = (RxXfer_t *)hRxXfer;
  588. os_memoryZero (pRxXfer->hOs, &pRxXfer->DbgStats, sizeof(RxXferStats_T));
  589. }
  590. /****************************************************************************
  591. * rxXfer_PrintStats()
  592. ****************************************************************************
  593. * DESCRIPTION: .
  594. *
  595. * INPUTS:
  596. * pRxXfer The object
  597. *
  598. * OUTPUT: None
  599. *
  600. * RETURNS: OK.
  601. ****************************************************************************/
  602. void rxXfer_PrintStats (TI_HANDLE hRxXfer)
  603. {
  604. RxXfer_t * pRxXfer = (RxXfer_t *)hRxXfer;
  605. WLAN_OS_REPORT(("Number of packets read: %d, number of bytes read:%d\n",
  606. pRxXfer->DbgStats.numPacketsRead, pRxXfer->DbgStats.numBytesRead));
  607. WLAN_OS_REPORT(("Number of frames dropped due to no memory:%d, Number of frames dropped due to packet ID mismatch:%d\n",
  608. pRxXfer->DbgStats.numPacketsDroppedNoMem, pRxXfer->DbgStats.numPacketsDroppedPacketIDMismatch));
  609. WLAN_OS_REPORT(("Number of irq0:%u, ack0:%d\n",
  610. pRxXfer->DbgStats.numIrq0, pRxXfer->DbgStats.numAck0));
  611. WLAN_OS_REPORT(("Number of irq1:%u, ack1:%d\n",
  612. pRxXfer->DbgStats.numIrq1, pRxXfer->DbgStats.numAck1));
  613. }
  614. #endif
  615. /****************************************************************************
  616. * RxXfer_ReStart()
  617. ****************************************************************************
  618. * DESCRIPTION: RxXfer_ReStart the RxXfer module object (called by the recovery)
  619. *
  620. * INPUTS: hRxXfer - The object to free
  621. *
  622. * OUTPUT: None
  623. *
  624. * RETURNS: NONE
  625. ****************************************************************************/
  626. VOID RxXfer_ReStart(TI_HANDLE hRxXfer)
  627. {
  628. RxXfer_t * pRxXfer = (RxXfer_t *)hRxXfer;
  629. pRxXfer->state = RX_XFER_STATE_IDLE;
  630. pRxXfer->currBuffer = 0; /* first buffer to read from */
  631. pRxXfer->lastPacketId = 0;
  632. } /* RxXfer_ReStart() */