PageRenderTime 59ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 1ms

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

http://github.com/CyanogenMod/cm-kernel
C | 584 lines | 269 code | 106 blank | 209 comment | 39 complexity | 9be105625bf66acb64a0b5e12676a0a2 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_Tx.c
  38. *
  39. * PURPOSE: TNETW_Driver Tx API functions needed externally to the driver.
  40. *
  41. ****************************************************************************/
  42. #include "whalParams.h"
  43. #include "report.h"
  44. #include "TNETW_Driver_api.h"
  45. #include "txCtrlBlk_api.h"
  46. #include "txHwQueue_api.h"
  47. #include "txXfer_api.h"
  48. #include "txResult_api.h"
  49. #include "TNETW_Driver.h"
  50. static systemStatus_e ConvertTxResultStatus(TxDescStatus_enum txResultStatus);
  51. /****************************************************************************
  52. * Tx Control Block API functions *
  53. ****************************************************************************/
  54. txCtrlBlkEntry_t *TnetwDrv_txCtrlBlk_alloc(TI_HANDLE hTnetwDrv)
  55. {
  56. TnetwDrv_t *pTnetwDrv = (TnetwDrv_t *)hTnetwDrv;
  57. return txCtrlBlk_alloc(pTnetwDrv->hTxCtrlBlk);
  58. }
  59. void TnetwDrv_txCtrlBlk_free(TI_HANDLE hTnetwDrv, txCtrlBlkEntry_t *pCurrentEntry)
  60. {
  61. TnetwDrv_t *pTnetwDrv = (TnetwDrv_t *)hTnetwDrv;
  62. txCtrlBlk_free(pTnetwDrv->hTxCtrlBlk, pCurrentEntry);
  63. }
  64. txCtrlBlkEntry_t *TnetwDrv_txCtrlBlk_GetPointer(TI_HANDLE hTnetwDrv, UINT8 descId)
  65. {
  66. TnetwDrv_t *pTnetwDrv = (TnetwDrv_t *)hTnetwDrv;
  67. return txCtrlBlk_GetPointer(pTnetwDrv->hTxCtrlBlk, descId);
  68. }
  69. /****************************************************************************
  70. * Tx HW Queue API functions *
  71. ****************************************************************************/
  72. TI_STATUS TnetwDrv_txHwQueue_alloc(TI_HANDLE hTnetwDrv, txCtrlBlkEntry_t *pPktCtrlBlk)
  73. {
  74. TnetwDrv_t *pTnetwDrv = (TnetwDrv_t *)hTnetwDrv;
  75. return txHwQueue_alloc(pTnetwDrv->hTxHwQueue, pPktCtrlBlk);
  76. }
  77. TI_STATUS TnetwDrv_txHwQueue_free(TI_HANDLE hTnetwDrv, txCtrlBlkEntry_t *pPktCtrlBlk)
  78. {
  79. TnetwDrv_t *pTnetwDrv = (TnetwDrv_t *)hTnetwDrv;
  80. return txHwQueue_free(pTnetwDrv->hTxHwQueue, pPktCtrlBlk);
  81. }
  82. UINT8 TnetwDrv_txHwQueue_GetUsedHwBlks(TI_HANDLE hTnetwDrv, int TxQid)
  83. {
  84. TnetwDrv_t *pTnetwDrv = (TnetwDrv_t *)hTnetwDrv;
  85. return txHwQueue_GetUsedHwBlks(pTnetwDrv->hTxHwQueue, TxQid);
  86. }
  87. /****************************************************************************
  88. * Tx Xfer API functions *
  89. ****************************************************************************/
  90. systemStatus_e TnetwDrv_txXfer_sendPacket(TI_HANDLE hTnetwDrv,
  91. const void *aFrame, /* Pointer to the packet content. points to */
  92. /* the place that the actual packet begins. */
  93. /* a size of TX_TOTAL_OFFSET_BEFORE_DATA */
  94. /* must be saved before that pointer */
  95. UINT16 aLength, /* MSDU length from first byte of MAC */
  96. /* header to last byteof frame body. */
  97. UINT8 aQueueId, /* Tx queue as defined in ConfigureQueue. */
  98. UINT8 aTxRateClassId, /* Tx rate class ID defined in txRatePolicy.*/
  99. UINT16 aMaxTransmitRate,/* A bit mask that specifies the initial */
  100. /* (highest) rate to use. */
  101. BOOL aMore, /* Tells if there is another packet coming */
  102. /* shortly after this one. */
  103. UINT32 aPacketId, /* Packet identifier used as a context by */
  104. /* the host driver. */
  105. UINT8 aPowerLevel, /* Transmission power level. */
  106. UINT32 aExpiryTime, /* Time left for this MSDU to live. */
  107. void *aReserved) /* Optional parameters pointer. */
  108. {
  109. TnetwDrv_t *pTnetwDrv = (TnetwDrv_t *)hTnetwDrv;
  110. TxDescCtrl_t txAttr, *pTxAttr = &txAttr; /* A union for setting the txAttr bit fields. */
  111. dot11_header_t *pDot11Hdr;
  112. systemStatus_e status;
  113. txCtrlBlkEntry_t *pPktCtrlBlk;
  114. WhalParams_T *pWhalParams = (WhalParams_T *)(pTnetwDrv->hWhalParams);
  115. BOOL bIsMultiCastAndIBSS; /* used for the Ack policy */
  116. #ifdef TI_DBG
  117. /* If queue number is invalid return ERROR. */
  118. if (aQueueId >= MAX_NUM_OF_TX_QUEUES)
  119. {
  120. WLAN_REPORT_ERROR(pTnetwDrv->hReport, TNETW_DRV_MODULE_LOG,
  121. ("TnetwDrv_txXfer_sendPacket(): Invalid aQueueId = %d !!!\n", aQueueId));
  122. return SEND_PACKET_ERROR;
  123. }
  124. #endif
  125. /*****************************************************************************************/
  126. /* 1) Allocates a Control-Block for the packet Tx parameters and descriptor. */
  127. /*****************************************************************************************/
  128. pPktCtrlBlk = TnetwDrv_txCtrlBlk_alloc(pTnetwDrv);
  129. #ifdef TI_DBG
  130. pTnetwDrv->dbgCountSentPackets[aQueueId]++; /* Count packets sent from upper driver. */
  131. #endif
  132. /* If null entry (not expected to happen) return ERROR. */
  133. if (!pPktCtrlBlk)
  134. {
  135. #ifdef TI_DBG
  136. WLAN_REPORT_ERROR(pTnetwDrv->hReport, TNETW_DRV_MODULE_LOG,
  137. ("TnetwDrv_txXfer_sendPacket(): Tx Ctrl-Blk allocation failed!!!\n"));
  138. #endif
  139. return SEND_PACKET_ERROR;
  140. }
  141. /*****************************************************************************************/
  142. /* 2) Set the packet control block parameters (including descriptor structure). */
  143. /*****************************************************************************************/
  144. /* Note that the following params are currently not used: aMore, aPowerLevel, aReserved. */
  145. /* Note that the following descriptor params are for future use, so they are left zeroed:
  146. pktType and xferPadding fields in txAttr, and tid. */
  147. /* Note that the other params are set later in the Tx process (e.g. fragThresh and numMemBlks). */
  148. /* aFrame points to the start of the data, but we need to reserve place for descriptor + TNETWIF_WRITE_OFFSET_BYTES */
  149. pPktCtrlBlk->txPktParams.pFrame = (void*)((UINT8 *)aFrame - TX_TOTAL_OFFSET_BEFORE_DATA);
  150. pPktCtrlBlk->txDescriptor.length = aLength;
  151. pPktCtrlBlk->txDescriptor.xmitQueue = aQueueId;
  152. pPktCtrlBlk->txDescriptor.rate = aMaxTransmitRate;
  153. pPktCtrlBlk->txPktParams.packetId = aPacketId;
  154. pPktCtrlBlk->txDescriptor.expiryTime = aExpiryTime << SHIFT_BETWEEN_TU_AND_USEC; /* Convert TUs to microseconds. */
  155. pDot11Hdr = (dot11_header_t*)(aFrame); /* aFrame points to the start of the data */
  156. pPktCtrlBlk->txPktParams.headerFrameCtrl = pDot11Hdr->fc; /* Save frame-control field from MAC header. */
  157. /* Set descriptor control bit-mask fields and write the whole word to the descriptor. */
  158. *(uint16 *)pTxAttr = 0; /* Clear temporary union. */
  159. txAttr.ratePolicy = aTxRateClassId;
  160. /* Configure the Ack policy */
  161. bIsMultiCastAndIBSS = ((BSS_INDEPENDENT == (bssType_e)(whal_ParamsGetReqBssType(pWhalParams)))
  162. && (MAC_MULTICAST(GET_DA_FROM_DOT11_HEADER_T(pDot11Hdr))));
  163. txAttr.ackPolicy = TnetwDrv_txGetAckPolicy(pTnetwDrv, aQueueId , bIsMultiCastAndIBSS);
  164. if (IS_QOS_FRAME(pDot11Hdr->fc)) /* Check if frame is QoS-Data or QoS-Null. */
  165. txAttr.qosFrame = 1;
  166. /* if this is a management frame, request immediate TX complete indication */
  167. if ( (pDot11Hdr->fc & DOT11_FC_TYPE_MASK) == DOT11_FC_TYPE_MGMT )
  168. {
  169. txAttr.txCmpltRequired = 1;
  170. }
  171. pPktCtrlBlk->txDescriptor.txAttr = *(uint16 *)pTxAttr;
  172. pPktCtrlBlk->txPktParams.flags = 0;
  173. /************************************************************************************************/
  174. /* 3) Call HwQueue for Hw resources allocation. If not available free CtrlBlk and return BUSY. */
  175. /************************************************************************************************/
  176. /* Note that the HwQueue calls first the fragThreshold and numMemBlks calculation. */
  177. if ( TnetwDrv_txHwQueue_alloc(pTnetwDrv, pPktCtrlBlk) != OK )
  178. {
  179. TnetwDrv_txCtrlBlk_free(pTnetwDrv, pPktCtrlBlk);
  180. return SEND_PACKET_BUSY;
  181. }
  182. #ifdef TI_DBG
  183. /* Just for debug, write per queue sequence number to packet ctrl-blk (after allocation success!). */
  184. pTnetwDrv->dbgPktSeqNum[aQueueId]++;
  185. pPktCtrlBlk->txPktParams.dbgPktSeqNum = pTnetwDrv->dbgPktSeqNum[aQueueId];
  186. pTnetwDrv->dbgCountQueueAvailable[aQueueId]++; /* Count packets sent and queue not busy. */
  187. #endif
  188. /*****************************************************************************************/
  189. /* 4) Copy the descriptor to the frame . */
  190. /*****************************************************************************************/
  191. os_memoryCopy(pTnetwDrv->hOs, (void *)((UINT8*)aFrame - sizeof(DbTescriptor)), &(pPktCtrlBlk->txDescriptor), sizeof(DbTescriptor));
  192. /*****************************************************************************************/
  193. /* 5) Call the Tx-Xfer to start packet transfer to the FW and return its result. */
  194. /*****************************************************************************************/
  195. status = txXfer_sendPacket(pTnetwDrv->hTxXfer, pPktCtrlBlk);
  196. /* If the packet was transfered in this context and Tx-complete already occured, free the ctrl-blk. */
  197. if (status == SEND_PACKET_XFER_DONE)
  198. {
  199. if (pPktCtrlBlk->txPktParams.flags & TX_CTRL_BLK_FLAGS_TX_COMPLETE_ISSUED)
  200. TnetwDrv_txCtrlBlk_free(pTnetwDrv, pPktCtrlBlk);
  201. else
  202. pPktCtrlBlk->txPktParams.flags |= TX_CTRL_BLK_FLAGS_XFER_DONE_ISSUED;
  203. }
  204. #ifdef TI_DBG
  205. if (status == SEND_PACKET_XFER_DONE)
  206. pTnetwDrv->dbgCountXferDone[aQueueId]++;
  207. else if (status == SEND_PACKET_SUCCESS)
  208. pTnetwDrv->dbgCountXferSuccess[aQueueId]++;
  209. else if (status == SEND_PACKET_PENDING)
  210. pTnetwDrv->dbgCountXferPending[aQueueId]++;
  211. else
  212. pTnetwDrv->dbgCountXferError[aQueueId]++;
  213. #endif
  214. return status;
  215. }
  216. /****************************************************************************
  217. * Tx API functions needed for GWSI interface *
  218. ****************************************************************************/
  219. UINT8 TnetwDrv_txGetAckPolicy(TI_HANDLE hTnetwDrv, int TxQid , BOOL bIsMultiCastAndIBSS)
  220. {
  221. TnetwDrv_t *pTnetwDrv = (TnetwDrv_t *)hTnetwDrv;
  222. WhalParams_T *pWhalParams = (WhalParams_T *)(pTnetwDrv->hWhalParams);
  223. /* If we are in IBSS and we are transmitting a Multicast/Broadcast frame -> we don't expect an Ack packet */
  224. if (bIsMultiCastAndIBSS)
  225. {
  226. return ACK_POLICY_NO_ACK;
  227. }
  228. return (pWhalParams->QueuesParams.queues[TxQid].ackPolicy);
  229. }
  230. /*************************************************************************
  231. * TnetwDrv_TxXferDone *
  232. **************************************************************************
  233. * DESCRIPTION:
  234. ============
  235. Called upon Xfer-Done of transmitted packet.
  236. Calls the upper driver's Xfer-Done handler.
  237. *
  238. * INPUT: hDummyHandle - Just to support the CB API.
  239. * pPktCtrlBlk - The packet's control block pointer.
  240. *
  241. * OUTPUT:
  242. *
  243. * RETURN:
  244. *************************************************************************/
  245. void TnetwDrv_TxXferDone(TI_HANDLE hTnetwDrv, txCtrlBlkEntry_t *pPktCtrlBlk)
  246. {
  247. /* Make a working copy of TNETDriver Handle */
  248. TnetwDrv_t *pTnetwDrv = (TnetwDrv_t *)hTnetwDrv;
  249. #ifdef TI_DBG
  250. pTnetwDrv->dbgCountXferDoneCB[pPktCtrlBlk->txDescriptor.xmitQueue]++;
  251. #endif
  252. /* If the pointed entry is already free, print error and exit (not expected to happen). */
  253. if (pPktCtrlBlk->pNextFreeEntry != NULL)
  254. {
  255. #ifdef TI_DBG
  256. WLAN_REPORT_ERROR(pTnetwDrv->hReport, TNETW_DRV_MODULE_LOG,
  257. ("TnetwDrv_TxXferDone(): Pkt already free!!, DescID=%d, dbgPktSeqNum=%d, flags=%d, packetId=0x%x, Queue=%d\n",
  258. pPktCtrlBlk->txDescriptor.descID, pPktCtrlBlk->txPktParams.dbgPktSeqNum, pPktCtrlBlk->txPktParams.flags,
  259. pPktCtrlBlk->txPktParams.packetId, pPktCtrlBlk->txDescriptor.xmitQueue));
  260. #endif
  261. return;
  262. }
  263. /* If Tx-complete already occurred, free the ctrl-blk. */
  264. /* Note that this may happen when the Xfer-SM delays the Xfer-Done (for pipeline sequence). */
  265. if (pPktCtrlBlk->txPktParams.flags & TX_CTRL_BLK_FLAGS_TX_COMPLETE_ISSUED)
  266. TnetwDrv_txCtrlBlk_free(pTnetwDrv, pPktCtrlBlk);
  267. else
  268. pPktCtrlBlk->txPktParams.flags |= TX_CTRL_BLK_FLAGS_XFER_DONE_ISSUED;
  269. /* Call the upper driver's Xfer-Done handler with the packet-ID. */
  270. /* Note that depending on the type of compilation, the upper layers vary: */
  271. /* It may be either CoreAdaptTx or GWSIAdaptTx */
  272. /* Both functions are called the same */
  273. SendPacketTransfer (pTnetwDrv->hUser, pPktCtrlBlk->txPktParams.packetId);
  274. }
  275. /*************************************************************************
  276. * TnetwDrv_TxComplete *
  277. **************************************************************************
  278. * DESCRIPTION:
  279. ============
  280. Called upon Tx-complete of transmitted packet.
  281. Handles it as follows:
  282. 1) Update the HwQueue to free queue resources.
  283. 2) Call the upper driver's tx-complete handler.
  284. 3) Free the packet's Control-Block if Xfer-Done already occured.
  285. *
  286. * INPUT: hDummyHandle - Just to support the CB API.
  287. * pTxResultInfo - The packet's Tx result information.
  288. *
  289. * OUTPUT:
  290. *
  291. * RETURN:
  292. *************************************************************************/
  293. void TnetwDrv_TxComplete(TI_HANDLE hTnetwDrv, TxResultDescriptor_t *pTxResultInfo)
  294. {
  295. txCtrlBlkEntry_t *pPktCtrlBlk;
  296. /* Make a working copy of TNETDriver Handle */
  297. TnetwDrv_t *pTnetwDrv = (TnetwDrv_t *)hTnetwDrv;
  298. /* Get the packet's control block pointer by the descId index. */
  299. pPktCtrlBlk = TnetwDrv_txCtrlBlk_GetPointer(pTnetwDrv, pTxResultInfo->descID);
  300. #ifdef TI_DBG
  301. WLAN_REPORT_INFORMATION(pTnetwDrv->hReport, TNETW_DRV_MODULE_LOG,
  302. ("TnetwDrv_TxComplete(): DescID=%d, dbgPktSeqNum=%d, flags=%d, packetId=0x%x, Queue=%d\n",
  303. pTxResultInfo->descID, pPktCtrlBlk->txPktParams.dbgPktSeqNum, pPktCtrlBlk->txPktParams.flags,
  304. pPktCtrlBlk->txPktParams.packetId, pPktCtrlBlk->txDescriptor.xmitQueue));
  305. pTnetwDrv->dbgCountTxCompleteCB[pPktCtrlBlk->txDescriptor.xmitQueue]++;
  306. #endif
  307. /* If the pointed entry is already free, print error and exit (not expected to happen). */
  308. if (pPktCtrlBlk->pNextFreeEntry != NULL)
  309. {
  310. #ifdef TI_DBG
  311. WLAN_REPORT_ERROR(pTnetwDrv->hReport, TNETW_DRV_MODULE_LOG,
  312. ("TnetwDrv_TxComplete(): Pkt already free!!, DescID=%d, dbgPktSeqNum=%d, flags=%d, packetId=0x%x, Queue=%d\n",
  313. pTxResultInfo->descID, pPktCtrlBlk->txPktParams.dbgPktSeqNum, pPktCtrlBlk->txPktParams.flags,
  314. pPktCtrlBlk->txPktParams.packetId, pPktCtrlBlk->txDescriptor.xmitQueue));
  315. #endif
  316. return;
  317. }
  318. /* Update the HwQueue to free queue resources. */
  319. TnetwDrv_txHwQueue_free(pTnetwDrv, pPktCtrlBlk);
  320. /* @@@ Note: Add Security Sequence Number handling. */
  321. /* Update the TKIP/AES sequence-number according to the Tx data packet security-seq-num. */
  322. /* Note: The FW always provides the last used seq-num so no need to check if the current
  323. packet is data and WEP is on. */
  324. whalCtrl_updateSecuritySeqNum(pTnetwDrv->hHalCtrl, pTxResultInfo->lsbSecuritySequenceNumber);
  325. /* Call the upper driver's tx-complete handler. */
  326. /* Note that depending on the type of compilation, the upper layeres varry: */
  327. /* It may be either CoreAdaptTx or GWSIAdaptTx */
  328. /* Both functions are called the same */
  329. SendPacketComplete (pTnetwDrv->hUser,
  330. ConvertTxResultStatus((TxDescStatus_enum)pTxResultInfo->status),
  331. pPktCtrlBlk->txPktParams.packetId,
  332. pTxResultInfo->actualRate,
  333. pTxResultInfo->ackFailures,
  334. (UINT32)pTxResultInfo->mediumUsage,
  335. pTxResultInfo->fwHandlingTime,
  336. pTxResultInfo->mediumDelay);
  337. /* If Xfer-Done already occured, free the ctrl-blk (otherwise Xfer-Done will do it). */
  338. /* Note that the Xfer-SM may delay the Xfer-Done (for pipeline sequence). */
  339. if (pPktCtrlBlk->txPktParams.flags & TX_CTRL_BLK_FLAGS_XFER_DONE_ISSUED)
  340. TnetwDrv_txCtrlBlk_free(pTnetwDrv, pPktCtrlBlk);
  341. else
  342. pPktCtrlBlk->txPktParams.flags |= TX_CTRL_BLK_FLAGS_TX_COMPLETE_ISSUED;
  343. }
  344. /*************************************************************************
  345. * TnetwDrv_RecoveryCtrlBlk *
  346. **************************************************************************
  347. * DESCRIPTION:
  348. ============
  349. Called upon recovery.
  350. Handles it as follows:
  351. 1) Update the HwQueue to free queue resources.
  352. 3) Free the packet's Control-Block if Xfer-Done already occured.
  353. *
  354. * INPUT: hDummyHandle - Just to support the CB API.
  355. *
  356. * OUTPUT:
  357. *
  358. * RETURN:
  359. *************************************************************************/
  360. void TnetwDrv_RecoveryCtrlBlk(TI_HANDLE hTnetwDrv)
  361. {
  362. txCtrlBlkEntry_t *pPktCtrlBlk;
  363. /* Make a working copy of TNETDriver Handle */
  364. TnetwDrv_t *pTnetwDrv = (TnetwDrv_t *)hTnetwDrv;
  365. UINT32 entry;
  366. const UINT32 MAX_CTRL_BLK_ENTRY = 64;
  367. for (entry = 0; entry < MAX_CTRL_BLK_ENTRY-1; entry++)
  368. {
  369. /* Get the packet's control block pointer by the descId index. */
  370. pPktCtrlBlk = TnetwDrv_txCtrlBlk_GetPointer(pTnetwDrv, entry);
  371. if (pPktCtrlBlk->pNextFreeEntry == NULL)
  372. {
  373. TnetwDrv_txHwQueue_free(pTnetwDrv, pPktCtrlBlk);
  374. TnetwDrv_txCtrlBlk_free(pTnetwDrv, pPktCtrlBlk);
  375. }
  376. }
  377. }
  378. /*************************************************************************
  379. * TnetwDrv_TxXferDebug *
  380. **************************************************************************
  381. * DESCRIPTION:
  382. ============
  383. Called upon issuing interrupt to firmware.
  384. Calls the upper driver's Xfer-Debug handler.
  385. *
  386. * INPUT: hDummyHandle - Just to support the CB API.
  387. * pPktCtrlBlk - The packet's control block pointer.
  388. uDebugInfo - Additional debug info
  389. *
  390. * OUTPUT:
  391. *
  392. * RETURN:
  393. *************************************************************************/
  394. #ifdef TI_DBG
  395. void TnetwDrv_TxXferDebug (TI_HANDLE hTnetwDrv, txCtrlBlkEntry_t *pPktCtrlBlk, UINT32 uDebugInfo)
  396. {
  397. TnetwDrv_t *pTnetwDrv = (TnetwDrv_t *)hTnetwDrv;
  398. /* Call the upper driver's Xfer-Done handler with the packet-ID. */
  399. /* Note that depending on the type of compilation, the upper layeres varry: */
  400. /* It may be either CoreAdaptTx or GWSIAdaptTx */
  401. /* Both functions are called the same */
  402. SendPacketDebug (pTnetwDrv->hUser, pPktCtrlBlk->txPktParams.packetId, uDebugInfo);
  403. }
  404. #endif
  405. /****************************************************************************
  406. * ConvertTxResultStatus
  407. ****************************************************************************
  408. * DESCRIPTION: Convert the status bit field in the TxDone descriptor, indexed
  409. * by the given index, to a driver status bit field
  410. *
  411. * INPUTS: txResultStatus - Status value received from the FW
  412. *
  413. * OUTPUT: None
  414. *
  415. * RETURNS: The converted value
  416. ****************************************************************************/
  417. systemStatus_e ConvertTxResultStatus(TxDescStatus_enum txResultStatus)
  418. {
  419. /* Convert Tx-Result from FW to GWSI values. */
  420. /* Note: only 1 bit in the entire status field should be set */
  421. switch (txResultStatus)
  422. {
  423. case TX_SUCCESS:
  424. return SEND_COMPLETE_SUCCESS;
  425. case TX_RETRY_EXCEEDED:
  426. return SEND_COMPLETE_RETRY_EXCEEDED;
  427. case TX_TIMEOUT:
  428. return SEND_COMPLETE_LIFETIME_EXCEEDED;
  429. default:
  430. return SEND_COMPLETE_NO_LINK;
  431. }
  432. }
  433. /****************************************************************************
  434. * TnetwDrv_printInfo()
  435. ****************************************************************************
  436. * DESCRIPTION: Print the txXfer object main fields.
  437. ****************************************************************************/
  438. void TnetwDrv_printInfo(TI_HANDLE hTnetwDrv)
  439. {
  440. #ifdef TI_DBG
  441. TnetwDrv_t *pTnetwDrv = (TnetwDrv_t *)hTnetwDrv;
  442. int qIndex;
  443. WLAN_OS_REPORT(("TNETW Driver Tx Counters per Queue:\n"));
  444. WLAN_OS_REPORT(("===========================\n"));
  445. WLAN_OS_REPORT(("-------------- packets sent from upper driver ---------------\n"));
  446. for(qIndex = 0; qIndex < MAX_NUM_OF_TX_QUEUES; qIndex++)
  447. WLAN_OS_REPORT(("Queue %d = %d\n",qIndex, pTnetwDrv->dbgCountSentPackets[qIndex]));
  448. WLAN_OS_REPORT(("-------------- packets sent and queue not busy ---------------\n"));
  449. for(qIndex = 0; qIndex < MAX_NUM_OF_TX_QUEUES; qIndex++)
  450. WLAN_OS_REPORT(("Queue %d = %d\n",qIndex, pTnetwDrv->dbgCountQueueAvailable[qIndex]));
  451. WLAN_OS_REPORT(("-------------- XferDone value returned from Xfer ---------------\n"));
  452. for(qIndex = 0; qIndex < MAX_NUM_OF_TX_QUEUES; qIndex++)
  453. WLAN_OS_REPORT(("Queue %d = %d\n",qIndex, pTnetwDrv->dbgCountXferDone[qIndex]));
  454. WLAN_OS_REPORT(("-------------- Success value returned from Xfer ---------------\n"));
  455. for(qIndex = 0; qIndex < MAX_NUM_OF_TX_QUEUES; qIndex++)
  456. WLAN_OS_REPORT(("Queue %d = %d\n",qIndex, pTnetwDrv->dbgCountXferSuccess[qIndex]));
  457. WLAN_OS_REPORT(("-------------- Pending value returned from Xfer ---------------\n"));
  458. for(qIndex = 0; qIndex < MAX_NUM_OF_TX_QUEUES; qIndex++)
  459. WLAN_OS_REPORT(("Queue %d = %d\n",qIndex, pTnetwDrv->dbgCountXferPending[qIndex]));
  460. WLAN_OS_REPORT(("-------------- Error value returned from Xfer ---------------\n"));
  461. for(qIndex = 0; qIndex < MAX_NUM_OF_TX_QUEUES; qIndex++)
  462. WLAN_OS_REPORT(("Queue %d = %d\n",qIndex, pTnetwDrv->dbgCountXferError[qIndex]));
  463. WLAN_OS_REPORT(("-------------- XferDone callback calls ---------------\n"));
  464. for(qIndex = 0; qIndex < MAX_NUM_OF_TX_QUEUES; qIndex++)
  465. WLAN_OS_REPORT(("Queue %d = %d\n",qIndex, pTnetwDrv->dbgCountXferDoneCB[qIndex]));
  466. WLAN_OS_REPORT(("-------------- TxComplete callback calls ---------------\n"));
  467. for(qIndex = 0; qIndex < MAX_NUM_OF_TX_QUEUES; qIndex++)
  468. WLAN_OS_REPORT(("Queue %d = %d\n",qIndex, pTnetwDrv->dbgCountTxCompleteCB[qIndex]));
  469. #endif /* TI_DBG */
  470. }