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

/drivers/net/wireless/tiwlan1251/common/src/hal/hw_ctrl/whalHwMboxCmdBit.c

http://github.com/CyanogenMod/cm-kernel
C | 815 lines | 412 code | 132 blank | 271 comment | 50 complexity | a31102b55fb922feeda760d5771dfcbf 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: whalHwMboxCmdBit.c
  38. * PURPOSE: wlan hardware BIT commands handler
  39. *
  40. ****************************************************************************/
  41. #include "whalCommon.h"
  42. #include "CmdQueue_api.h"
  43. #include "public_infoele.h"
  44. #include "commonTypes.h"
  45. #include "whalHwMboxCmdBit.h"
  46. /*******************************************
  47. * Wlan hardware Test (BIT)
  48. * =================
  49. *
  50. * Tests description:
  51. * ==================
  52. * FCC = Continuous modulated transmission (should not emit carrier)
  53. * TELEC = Continuous unmodulated carrier transmission (carrier only)
  54. * PER_TX_STOP = Stops the TX test in progress (FCC or TELEC).
  55. * ReadRegister = Read a register value.
  56. * WriteRegister = Sets a register value.
  57. *
  58. * Rx PER test
  59. * ========
  60. * PerRxStart = Start or resume the PER measurement. This function will put the device in promiscuous mode, and resume counters update.
  61. * PerRxStop = Stop Rx PER measurements. This function stop counters update and make it is safe to read the PER test result.
  62. * PerRxGetResults = Get the last Rx PER test results.
  63. * PerRxClear = Clear the Rx PER test results.
  64. */
  65. enum
  66. {
  67. /* 0 */ TEST_MOD_QPSK,
  68. /* 1 */ TEST_MOD_CCK,
  69. /* 2 */ TEST_MOD_PBCC,
  70. TEST_MOD_NUMOF
  71. };
  72. enum
  73. {
  74. /* 0 */ TEST_MOD_LONG_PREAMBLE,
  75. /* 1 */ TEST_MOD_SHORT_PREAMBLE
  76. };
  77. enum
  78. {
  79. /* 0 */ TEST_BAND_2_4GHZ,
  80. /* 1 */ TEST_BAND_5GHZ,
  81. /* 2 */ TEST_BAND_4_9GHZ
  82. };
  83. #define TEST_MOD_MIN_GAP 200
  84. #define TEST_MOD_MIN_TX_BODYLEN 0
  85. #define TEST_MOD_MAX_TX_BODYLEN 2304
  86. #define TEST_RX_CAL_SAFE_TIME 5000 /*uSec*/
  87. #define TEST_MOD_IS_GAP_OK(gap) ((gap) >= TEST_MOD_MIN_GAP)
  88. #define TEST_MOD_IS_TX_BODYLEN_OK(len) \
  89. (INRANGE((len), TEST_MOD_MIN_TX_BODYLEN, TEST_MOD_MAX_TX_BODYLEN) && \
  90. (((len) & 3) == 0) )
  91. #define TEST_MOD_IS_PREAMBLE_OK(p) \
  92. INRANGE((p), TEST_MOD_LONG_PREAMBLE, TEST_MOD_SHORT_PREAMBLE)
  93. void whal_hwCmdBit_RxPer_Clear_CB(TI_HANDLE objectHandle,UINT16 MboxStatus,void *InterrogateParamsBuf);
  94. void whal_hwCmdBit_RxPer_GetResults_CB(TI_HANDLE objectHandle,UINT16 MboxStatus,void *InterrogateParamsBuf);
  95. void whal_hwCmdBit_RxCal_CB(TI_HANDLE objectHandle,UINT16 MboxStatus,void *InterrogateParamsBuf);
  96. void whal_hwCmdBit_RxCal_Complete_Event_CB( TI_HANDLE objectHandle, char* str, UINT32 strLen );
  97. /****************************************************************************
  98. * whal_hwMboxCmdBit_Create()
  99. ****************************************************************************
  100. * DESCRIPTION: Create the mailbox BIT commands object
  101. *
  102. * INPUTS:
  103. *
  104. * OUTPUT: None
  105. *
  106. * RETURNS: The Created object
  107. ****************************************************************************/
  108. HwMboxCmdBit_T *whal_hwMboxCmdBit_Create(TI_HANDLE hOs)
  109. {
  110. HwMboxCmdBit_T *pObj;
  111. pObj = os_memoryAlloc(hOs, sizeof(HwMboxCmdBit_T));
  112. if (pObj == NULL)
  113. return NULL;
  114. os_memoryZero(hOs, (void *)pObj, sizeof(HwMboxCmdBit_T));
  115. pObj->hOs = hOs;
  116. return(pObj);
  117. }
  118. /****************************************************************************
  119. * whal_hwMboxCmdBit_Destroy()
  120. ****************************************************************************
  121. * DESCRIPTION: Destroy the object
  122. *
  123. * INPUTS:
  124. * pHwMboxCmdBit The object to free
  125. *
  126. * OUTPUT: None
  127. *
  128. * RETURNS: OK or NOK
  129. ****************************************************************************/
  130. int whal_hwMboxCmdBit_Destroy(HwMboxCmdBit_T *pHwMboxCmdBit)
  131. {
  132. if (pHwMboxCmdBit)
  133. {
  134. whalCtrl_EventMbox_Disable( pHwMboxCmdBit->hWhalCtr, HAL_EVENT_PLT_RX_CALIBRATION_COMPLETE );
  135. os_memoryFree(pHwMboxCmdBit->hOs, pHwMboxCmdBit, sizeof(HwMboxCmdBit_T));
  136. }
  137. return OK;
  138. }
  139. /****************************************************************************
  140. * whal_hwMboxCmdBit_Config()
  141. ****************************************************************************
  142. * DESCRIPTION: Configure the object
  143. *
  144. * INPUTS:
  145. *
  146. * OUTPUT: None
  147. *
  148. * RETURNS: OK or NOK
  149. ****************************************************************************/
  150. int whal_hwMboxCmdBit_Config(TI_HANDLE hWhalCtr, HwMboxCmdBit_T *pHwMboxCmdBit, TI_HANDLE hCmdQueue, TI_HANDLE hReport)
  151. {
  152. pHwMboxCmdBit->hReport = hReport;
  153. pHwMboxCmdBit->hCmdQueue = hCmdQueue;
  154. pHwMboxCmdBit->hWhalCtr = hWhalCtr;
  155. whalCtrl_EventMbox_RegisterForEvent( hWhalCtr,
  156. HAL_EVENT_PLT_RX_CALIBRATION_COMPLETE,
  157. (void *)whal_hwCmdBit_RxCal_Complete_Event_CB,
  158. (void*)pHwMboxCmdBit);
  159. whalCtrl_EventMbox_Enable( hWhalCtr, HAL_EVENT_PLT_RX_CALIBRATION_COMPLETE );
  160. pHwMboxCmdBit->PltData.RxTxCal.lastStatus = OK;
  161. return OK;
  162. }
  163. /*******************
  164. Helper functions
  165. *******************/
  166. static void errPrint_ChID(HwMboxCmdBit_T *pHwMboxCmdBit, int chID)
  167. {
  168. WLAN_REPORT_REPLY(pHwMboxCmdBit->hReport, HAL_HW_CTRL_MODULE_LOG,
  169. ("Channel ID (%d) is out of range, use [%d..%d] for 2.4Ghz, [%d..%d] for 5Ghz and [%d %d %d] for 4.9Ghz.\n",
  170. chID,
  171. HAL_CTRL_CALIBRATION_CHANNEL_2_4_MIN, HAL_CTRL_CALIBRATION_CHANNEL_2_4_MAX,
  172. HAL_CTRL_CALIBRATION_CHANNEL_5_0_MIN, HAL_CTRL_CALIBRATION_CHANNEL_5_0_MAX,
  173. HAL_CTRL_CALIBRATION_CHANNEL_4_9_MIN, HAL_CTRL_CALIBRATION_CHANNEL_4_9_DEF, HAL_CTRL_CALIBRATION_CHANNEL_4_9_MAX));
  174. }
  175. static void errPrint_BandID(HwMboxCmdBit_T *pHwMboxCmdBit, int bandID)
  176. {
  177. WLAN_REPORT_REPLY(pHwMboxCmdBit->hReport, HAL_HW_CTRL_MODULE_LOG,
  178. ("PLT whal_hwCmdBit_Fcc: Wrong band parameter 0x%x(must be 0x%x for 2.4Ghz or 0x%x for 5Ghz or 0x%x for 4.9Ghz).\n",
  179. bandID, TEST_BAND_2_4GHZ, TEST_BAND_5GHZ, TEST_BAND_4_9GHZ));
  180. }
  181. /* MACROS */
  182. int VALIDATE_BAND_CHID(HwMboxCmdBit_T *pHwMboxCmdBit, int chID, int bandID)
  183. {
  184. int minVal, maxVal;
  185. switch(bandID)
  186. {
  187. case TEST_BAND_2_4GHZ:
  188. minVal = HAL_CTRL_CALIBRATION_CHANNEL_2_4_MIN;
  189. maxVal = HAL_CTRL_CALIBRATION_CHANNEL_2_4_MAX;
  190. break;
  191. case TEST_BAND_5GHZ:
  192. minVal = HAL_CTRL_CALIBRATION_CHANNEL_5_0_MIN;
  193. maxVal = HAL_CTRL_CALIBRATION_CHANNEL_5_0_MAX;
  194. break;
  195. case TEST_BAND_4_9GHZ:
  196. minVal = HAL_CTRL_CALIBRATION_CHANNEL_4_9_MIN;
  197. maxVal = HAL_CTRL_CALIBRATION_CHANNEL_4_9_MAX;
  198. break;
  199. default:
  200. errPrint_BandID(pHwMboxCmdBit, bandID);
  201. return NOK;
  202. }
  203. if(!INRANGE(chID, minVal, maxVal))
  204. {
  205. errPrint_ChID(pHwMboxCmdBit, chID);
  206. return NOK;
  207. }
  208. return(OK);
  209. }
  210. /****************************************************************************
  211. * whal_hwCmdBit_Fcc()
  212. ****************************************************************************
  213. * DESCRIPTION: Performs FCC test
  214. *
  215. * INPUTS: chID, rate, Modulation, preamble, band, TestMode
  216. *
  217. * OUTPUT: None
  218. *
  219. * RETURNS: OK or NOK
  220. ****************************************************************************/
  221. int whal_hwCmdBit_Fcc(HwMboxCmdBit_T *pHwMboxCmdBit,
  222. int chID,
  223. int rate,
  224. int preamble,
  225. int bandID,
  226. int InterPacketDelay,
  227. int TestMode,
  228. uint32 numFrames,
  229. uint32 seqNumMode,
  230. uint32 frameBodySize,
  231. uint8 *PeerMacAddr,
  232. void *CB_Func, TI_HANDLE CB_Handle, void *CB_Buf)
  233. {
  234. int Modulation;
  235. TestCmd_t TestCmd;
  236. os_memoryZero(pHwMboxCmdBit->hOs, (void *)&TestCmd, sizeof(TestCmd));
  237. WLAN_REPORT_INFORMATION(pHwMboxCmdBit->hReport, HAL_HW_CTRL_MODULE_LOG,
  238. ("whal_hwCmdBit_Fcc:\n chID = %d\n rate = %d preamble = %d, bandID %d, InterPacketDelay %d, TestMode %d numOfFrames %d\n ",
  239. chID, rate, preamble,
  240. bandID, InterPacketDelay, TestMode, numFrames));
  241. /*Check Channel and band*/
  242. if (VALIDATE_BAND_CHID(pHwMboxCmdBit, chID, bandID) == NOK)
  243. return NOK;
  244. /*Check rate and set Modulation*/
  245. if ((rate >= 1) && (rate <= 4))
  246. Modulation = MOD_CCK;
  247. else if ((rate >= 6) && (rate <= 13))
  248. Modulation = MOD_OFDM;
  249. else
  250. {
  251. WLAN_REPORT_REPLY(pHwMboxCmdBit->hReport, HAL_HW_CTRL_MODULE_LOG,
  252. ("PLT whal_hwCmdBit_Fcc: Wrong rate parameter %d(must be 1-4 to CCK modulation or 6-13 for OFDM modulation) .\n",
  253. rate));
  254. return NOK;
  255. }
  256. /*Set FW rate */
  257. TestCmd.testCmd_u.fcc.dataRate = ConvertDrvRate2HwRate((rate_e)rate);
  258. /*Validate preamble*/
  259. if ((preamble!=0) && preamble != CTL_PREAMBLE)
  260. {
  261. WLAN_REPORT_REPLY(pHwMboxCmdBit->hReport, HAL_HW_CTRL_MODULE_LOG,
  262. ("PLT whal_hwCmdBit_Fcc: Wrong preamble parameter 0x%x(must be (0x%x) for long preamble or short(0x%x)) .\n",
  263. preamble, 0, CTL_PREAMBLE));
  264. return NOK;
  265. }
  266. /*Validate test mode*/
  267. if ((TestMode != TEST_MODE_ZOZO_DATA) && (TestMode != TEST_MODE_RANDOM_DATA))
  268. {
  269. WLAN_REPORT_REPLY(pHwMboxCmdBit->hReport, HAL_HW_CTRL_MODULE_LOG,
  270. ("PLT whal_hwCmdBit_Fcc: Wrong TestMode parameter 0x%x(must be RANDOM_DATA(0x%x) or ZOZO_DATA(0x%x)) .\n",
  271. TestMode, TEST_MODE_RANDOM_DATA, TEST_MODE_ZOZO_DATA));
  272. /*Not returning NOX for enabling GAP bit*/
  273. }
  274. /*Validate seq num mode*/
  275. if ((seqNumMode != TEST_SEQ_NUM_MODE_FIXED) && (seqNumMode != TEST_SEQ_NUM_MODE_INCREMENTED))
  276. {
  277. WLAN_REPORT_REPLY(pHwMboxCmdBit->hReport, HAL_HW_CTRL_MODULE_LOG,
  278. ("PLT whal_hwCmdBit_Fcc: Wrong seqNumMode parameter 0x%x(must be TEST_SEQ_NUM_MODE_FIXED(0x%x) or TEST_SEQ_NUM_MODE_INCREMENTED(0x%x)) .\n",
  279. seqNumMode, TEST_SEQ_NUM_MODE_FIXED, TEST_SEQ_NUM_MODE_INCREMENTED));
  280. return NOK;
  281. }
  282. TestCmd.testCmd_u.fcc.seqNumMode = seqNumMode;
  283. TestCmd.testCmd_u.fcc.frameBodySize = frameBodySize;
  284. os_memoryCopy(pHwMboxCmdBit->hOs , TestCmd.testCmd_u.fcc.dest, PeerMacAddr,NUM_OF_MAC_ADDR_ELEMENTS);
  285. WLAN_REPORT_INFORMATION(pHwMboxCmdBit->hReport, HAL_HW_CTRL_MODULE_LOG,
  286. ("whal_hwCmdBit_Fcc: \n seqNumMode = %d ,frameBodySize = 0x%x",
  287. TestCmd.testCmd_u.fcc.seqNumMode,
  288. TestCmd.testCmd_u.fcc.frameBodySize));
  289. WLAN_REPORT_INFORMATION(pHwMboxCmdBit->hReport, HAL_HW_CTRL_MODULE_LOG,
  290. ("whal_hwCmdBit_Fcc: \n Dest = %02x:%02x:%02x:%02x:%02x:%02x",
  291. TestCmd.testCmd_u.fcc.dest[0],
  292. TestCmd.testCmd_u.fcc.dest[1],
  293. TestCmd.testCmd_u.fcc.dest[2],
  294. TestCmd.testCmd_u.fcc.dest[3],
  295. TestCmd.testCmd_u.fcc.dest[4],
  296. TestCmd.testCmd_u.fcc.dest[5]));
  297. TestCmd.testCmd_u.fcc.channel = chID;
  298. switch (Modulation)
  299. {
  300. case MOD_PBCC:
  301. Modulation = PBCC_MODULATION_MASK;
  302. break;
  303. case MOD_CCK:
  304. Modulation = 0x00;
  305. break;
  306. case MOD_OFDM:
  307. Modulation = OFDM_MODULATION_MASK;
  308. break;
  309. }
  310. /*Build preamble parameter*/
  311. TestCmd.testCmd_u.fcc.modPreamble = preamble;
  312. TestCmd.testCmd_u.fcc.band = bandID;
  313. TestCmd.testCmd_u.fcc.modulation = Modulation;
  314. TestCmd.testCmd_u.fcc.testModeCtrl = TestMode;
  315. /* Set command fields */
  316. TestCmd.testCmdId = TEST_CMD_FCC;
  317. WLAN_REPORT_INFORMATION(pHwMboxCmdBit->hReport, HAL_HW_CTRL_MODULE_LOG,
  318. ("whal_hwCmdBit_Fcc: \n AcxCmd_TestFCC.channel = %d ,AcxCmd_TestFCC.dataRate = 0x%x, AcxCmd_TestFCC.modPreamble = 0x%x, AcxCmd_TestFCC.testModeCtrl = 0x%x\n ",
  319. TestCmd.testCmd_u.fcc.channel,
  320. TestCmd.testCmd_u.fcc.dataRate,
  321. TestCmd.testCmd_u.fcc.modPreamble,
  322. TestCmd.testCmd_u.fcc.testModeCtrl));
  323. /*Set InterPacketDelay*/
  324. /*TestCmd.testCmd_u.fcc.interFrameGap = 1000 * InterPacketDelay; */ /*Convert ms to us*/
  325. TestCmd.testCmd_u.fcc.interFrameGap = InterPacketDelay; /*(uSec)*/
  326. /*Set numFrames */
  327. TestCmd.testCmd_u.fcc.numFrames = numFrames;
  328. return whal_hwCmdBit_TestCmd(pHwMboxCmdBit, CB_Func, CB_Handle, &TestCmd);
  329. }/* END whal_hwCmdBit_Fcc() */
  330. /****************************************************************************
  331. * whal_hwCmdBit_Telec()
  332. ****************************************************************************
  333. * DESCRIPTION: Performs TELEC test
  334. *
  335. * INPUTS: chID - Channel number, between 1 (MIN_CHANNEL_ID) to 14 (MAX_CHANNEL_ID).
  336. * bandID - Band ID number, 0 - 2.4Ghz, 1 - 5Ghz.
  337. *
  338. * OUTPUT: None
  339. *
  340. * RETURNS: OK or NOK
  341. ****************************************************************************/
  342. int whal_hwCmdBit_Telec(HwMboxCmdBit_T *pHwMboxCmdBit, int chID, int bandID, void *CB_Func, TI_HANDLE CB_Handle, void *CB_Buf)
  343. {
  344. TestCmd_t TestCmd;
  345. TestCmd_t *pCmd = &TestCmd;
  346. WLAN_REPORT_INFORMATION(pHwMboxCmdBit->hReport, HAL_HW_CTRL_MODULE_LOG,
  347. ("whal_hwCmdBit_Telec: chID = %d bandID = %d\n ", chID, bandID));
  348. /*Check Channel and band*/
  349. if (VALIDATE_BAND_CHID(pHwMboxCmdBit, chID, bandID) == NOK)
  350. return NOK;
  351. /* Set command fields; param1 = chID, param2 = BandID */
  352. os_memoryZero(pHwMboxCmdBit->hOs, (void *)pCmd, sizeof(*pCmd ));
  353. pCmd->testCmdId = TEST_CMD_TELEC;
  354. pCmd->testCmd_u.telec.channel = (UINT8)chID;
  355. pCmd->testCmd_u.telec.band = (UINT8)bandID;
  356. /* Send the command */
  357. return whal_hwCmdBit_TestCmd(pHwMboxCmdBit, CB_Func, CB_Handle, &TestCmd);
  358. }/* END whal_hwCmdBit_Telec() */
  359. /**************************
  360. REGISTER HANDLING
  361. *************************/
  362. /****************************************************************************
  363. * whal_hwCmdBit_ReadRegister()
  364. ****************************************************************************
  365. * DESCRIPTION: Performs PLT read register
  366. *
  367. * INPUTS: RegAddress - the address of the register to read
  368. *
  369. * OUTPUT: None
  370. *
  371. * RETURNS: OK or NOK
  372. ****************************************************************************/
  373. int whal_hwCmdBit_ReadRegister(HwMboxCmdBit_T *pHwMboxCmdBit, TI_HANDLE CB_Handle, void *CB_Func, void *CB_Buf)
  374. {
  375. ReadWriteCommand_t* pCmd = CB_Buf;
  376. /* Send the command */
  377. return (CmdQueue_CommandWithCb(pHwMboxCmdBit->hCmdQueue, CMD_READ_MEMORY, (char *)pCmd, sizeof(*pCmd), CB_Func, CB_Handle, CB_Buf));
  378. }/* END whal_hwCmdBit_ReadRegister() */
  379. /****************************************************************************
  380. * whal_hwCmdBit_WriteRegister()
  381. ****************************************************************************
  382. * DESCRIPTION: Performs PLT write register
  383. *
  384. * INPUTS: RegAddress - the address of the register to write to
  385. * RegData - the data to write
  386. *
  387. * OUTPUT: None
  388. *
  389. * RETURNS: OK or NOK
  390. ****************************************************************************/
  391. int whal_hwCmdBit_WriteRegister(HwMboxCmdBit_T *pHwMboxCmdBit, TI_HANDLE CB_Handle, void *CB_Func, void *Command_Buf)
  392. {
  393. /* Send the command */
  394. if (CB_Func)
  395. return (CmdQueue_CommandWithCb(pHwMboxCmdBit->hCmdQueue, CMD_WRITE_MEMORY, (char *)Command_Buf, sizeof(ReadWriteCommand_t), CB_Func, CB_Handle, NULL));
  396. else
  397. return (CmdQueue_Command(pHwMboxCmdBit->hCmdQueue, CMD_WRITE_MEMORY, (char *)Command_Buf, sizeof(ReadWriteCommand_t)));
  398. }/* END whal_hwCmdBit_WriteRegister() */
  399. /****************************************************************************
  400. * whal_hwCmdBit_perTxStop()
  401. ****************************************************************************
  402. * DESCRIPTION: Packet Error Rate - stop test, no params.
  403. * Does not clear statistics.
  404. * INPUTS: None
  405. *
  406. * OUTPUT: None
  407. *
  408. * RETURNS: OK or NOK
  409. ****************************************************************************/
  410. int whal_hwCmdBit_perTxStop(HwMboxCmdBit_T *pHwMboxCmdBit, void *CB_Func, TI_HANDLE CB_Handle, void *CB_Buf)
  411. {
  412. TestCmd_t TestCmd;
  413. TestCmd_t *pCmd = &TestCmd;
  414. /* Set command fields*/
  415. os_memoryZero(pHwMboxCmdBit->hOs, (void *)pCmd, sizeof(*pCmd ));
  416. pCmd->testCmdId = TEST_CMD_PLT_FCC_TELEC_TX_STOP;
  417. /* Send the command */
  418. return whal_hwCmdBit_TestCmd(pHwMboxCmdBit, CB_Func, CB_Handle, pCmd);
  419. }/* END whal_hwCmdBit_perTxStop() */
  420. /****************************************************************************
  421. * whal_hwCmdBit_RxPER()
  422. ****************************************************************************
  423. * DESCRIPTION: RX PER main function - All other RX per function are called using this function
  424. * INPUTS: None
  425. *
  426. * OUTPUT: None
  427. *
  428. * RETURNS: OK or NOK
  429. ****************************************************************************/
  430. int whal_hwCmdBit_RxPER(HwMboxCmdBit_T *pHwMboxCmdBit, PLT_RxPerCmd_e eRxPerCmd, TI_HANDLE CB_Handle, void *CB_Func)
  431. {
  432. int ret = OK;
  433. ACXErrorCounters_t ACXErrorCounters;
  434. TestCmd_t TestCmd;
  435. TestCmd_t *pCmd = &TestCmd;
  436. /*Defining a local function that will support the Rx PER process
  437. in a sync mode (for the core) as well as Async mode (for GWSI, as callbacks)*/
  438. CmdQueue_InterrogateCB_t PltRxPerCBArr[PLT_RX_PER_MAX] =
  439. {
  440. NULL, //PLT_RX_PER_START
  441. NULL, //PLT_RX_PER_STOP
  442. whal_hwCmdBit_RxPer_Clear_CB, //PLT_RX_PER_CLEAR
  443. whal_hwCmdBit_RxPer_GetResults_CB //PLT_RX_PER_GETRESULTS
  444. };
  445. WLAN_REPORT_INFORMATION(pHwMboxCmdBit->hReport, HAL_HW_CTRL_MODULE_LOG,
  446. ("whal_hwCmdBit_RxPER eRxPerCmd=%d, CB_Handle=0x%p, CB_Func=0x%p\n", eRxPerCmd, CB_Handle, CB_Func));
  447. /*
  448. * Set information element header
  449. * Each call to ACX_ERROR_CNT - retrieve the F.W Rx Per and reset them.
  450. */
  451. ACXErrorCounters.EleHdr.id = ACX_ERROR_CNT;
  452. ACXErrorCounters.EleHdr.len = sizeof(ACXErrorCounters) - sizeof(EleHdrStruct);
  453. if ((UINT32)eRxPerCmd >= (UINT32)PLT_RX_PER_MAX)
  454. return PARAM_VALUE_NOT_VALID;
  455. pHwMboxCmdBit->PltData.RxPer.CB_Func = CB_Func;
  456. pHwMboxCmdBit->PltData.RxPer.CB_Handle = CB_Handle;
  457. pHwMboxCmdBit->PltData.RxPer.CB_RxPerCmd = eRxPerCmd;
  458. /*
  459. * Send the interrogation command
  460. */
  461. if((PLT_RX_PER_GETRESULTS == eRxPerCmd) || (PLT_RX_PER_CLEAR == eRxPerCmd))
  462. {
  463. ret = CmdQueue_CmdInterrogateWithCb(pHwMboxCmdBit->hCmdQueue,
  464. &ACXErrorCounters, sizeof(ACXErrorCounters),
  465. (void *) PltRxPerCBArr[eRxPerCmd], pHwMboxCmdBit,
  466. &pHwMboxCmdBit->PltData.RxPer.ACXErrCountTable);
  467. return ret;
  468. }
  469. /* Set command fields*/
  470. os_memoryZero(pHwMboxCmdBit->hOs, (void *)pCmd, sizeof(*pCmd ));
  471. if(PLT_RX_PER_START == eRxPerCmd)
  472. {
  473. pCmd->testCmdId = TEST_CMD_RX_PER_START;
  474. /* Send the command */
  475. if (CB_Func != NULL) {
  476. return (CmdQueue_CommandWithCb(pHwMboxCmdBit->hCmdQueue, CMD_TEST, (char *)pCmd, sizeof(*pCmd),CB_Func , CB_Handle, NULL));
  477. }
  478. else
  479. {
  480. return (CmdQueue_Command(pHwMboxCmdBit->hCmdQueue, CMD_TEST, (char *)pCmd, sizeof(*pCmd) ));
  481. }
  482. }
  483. if(PLT_RX_PER_STOP == eRxPerCmd)
  484. {
  485. pCmd->testCmdId = TEST_CMD_RX_PER_STOP;
  486. /* Send the command */
  487. if (CB_Func != NULL) {
  488. return (CmdQueue_CommandWithCb(pHwMboxCmdBit->hCmdQueue, CMD_TEST, (char *)pCmd, sizeof(*pCmd),CB_Func, CB_Handle, NULL));
  489. }
  490. else
  491. {
  492. return (CmdQueue_Command(pHwMboxCmdBit->hCmdQueue, CMD_TEST, (char *)pCmd, sizeof(*pCmd) ));
  493. }
  494. }
  495. return NOK;
  496. }
  497. /****************************************************************************
  498. * whal_hwCmdBit_RxPer_Clear_CB()
  499. ****************************************************************************
  500. * DESCRIPTION: Clear the RX per counters
  501. *.
  502. * INPUTS: None
  503. *
  504. * OUTPUT: None
  505. *
  506. * RETURNS: OK or NOK
  507. ****************************************************************************/
  508. void whal_hwCmdBit_RxPer_Clear_CB(TI_HANDLE objectHandle,UINT16 MboxStatus,void *InterrogateParamsBuf)
  509. {
  510. HwMboxCmdBit_T *pHwMboxCmdBit = (HwMboxCmdBit_T*)objectHandle;
  511. CmdQueue_InterrogateCB_t CB_Func;
  512. /*Add the latest F.W. counter result to the total RX per counters*/
  513. pHwMboxCmdBit->PltData.RxPer.PltRxPer.FCSErrorCount = 0;
  514. pHwMboxCmdBit->PltData.RxPer.PltRxPer.TotalFrameCount = 0;
  515. pHwMboxCmdBit->PltData.RxPer.PltRxPer.PLCPErrorCount = 0;
  516. pHwMboxCmdBit->PltData.RxPer.PltRxPer.SeqNumMissCountRef = pHwMboxCmdBit->PltData.RxPer.ACXErrCountTable.seqNumMissCount; /* set as reference point for the mesurements */
  517. /* Call the saved CB function (if any)*/
  518. if (pHwMboxCmdBit->PltData.RxPer.CB_Func)
  519. {
  520. CB_Func = (CmdQueue_InterrogateCB_t)(pHwMboxCmdBit->PltData.RxPer.CB_Func);
  521. CB_Func(pHwMboxCmdBit->PltData.RxPer.CB_Handle, MboxStatus, &pHwMboxCmdBit->PltData.RxPer);
  522. }
  523. }
  524. /****************************************************************************
  525. * whal_hwCmdBit_RxPer_GetResults_CB()
  526. ****************************************************************************
  527. * DESCRIPTION: Returns the accumulated counters.
  528. * INPUTS: None
  529. *
  530. * OUTPUT: None
  531. *
  532. * RETURNS: OK or NOK
  533. ****************************************************************************/
  534. void whal_hwCmdBit_RxPer_GetResults_CB(TI_HANDLE objectHandle,UINT16 MboxStatus,void *InterrogateParamsBuf)
  535. {
  536. HwMboxCmdBit_T *pHwMboxCmdBit = (HwMboxCmdBit_T*)objectHandle;
  537. CmdQueue_InterrogateCB_t CB_Func;
  538. /*Accumulate the RX PER counters */
  539. pHwMboxCmdBit->PltData.RxPer.PltRxPer.FCSErrorCount += (UINT16)pHwMboxCmdBit->PltData.RxPer.ACXErrCountTable.FCSErrorCount;
  540. pHwMboxCmdBit->PltData.RxPer.PltRxPer.PLCPErrorCount += (UINT16)pHwMboxCmdBit->PltData.RxPer.ACXErrCountTable.PLCPErrorCount;
  541. pHwMboxCmdBit->PltData.RxPer.PltRxPer.TotalFrameCount += (UINT16)pHwMboxCmdBit->PltData.RxPer.ACXErrCountTable.validFrameCount;
  542. pHwMboxCmdBit->PltData.RxPer.PltRxPer.SeqNumMissCount = (UINT16)(pHwMboxCmdBit->PltData.RxPer.ACXErrCountTable.seqNumMissCount -
  543. pHwMboxCmdBit->PltData.RxPer.PltRxPer.SeqNumMissCountRef);
  544. /* Call the saved CB function (if any)*/
  545. if (pHwMboxCmdBit->PltData.RxPer.CB_Func)
  546. {
  547. CB_Func = (CmdQueue_InterrogateCB_t)(pHwMboxCmdBit->PltData.RxPer.CB_Func);
  548. CB_Func(pHwMboxCmdBit->PltData.RxPer.CB_Handle, MboxStatus, &(pHwMboxCmdBit->PltData.RxPer));
  549. }
  550. }
  551. /****************************************************************************
  552. * whal_hwCmdBit_TestCmd()
  553. ****************************************************************************
  554. * DESCRIPTION:
  555. * INPUTS: None
  556. *
  557. * OUTPUT: None
  558. *
  559. * RETURNS: OK or NOK
  560. ****************************************************************************/
  561. int whal_hwCmdBit_TestCmd(HwMboxCmdBit_T *pHwMboxCmdBit, void *CB_Func, TI_HANDLE CB_Handle, TestCmd_t* pTestCmd_Buf)
  562. {
  563. int bIsCBfuncNecessary=TRUE;
  564. WLAN_REPORT_INFORMATION(pHwMboxCmdBit->hReport, HAL_HW_CTRL_MODULE_LOG,
  565. ("%s CB_Handle=0x%p, CB_Func=0x%p, pTestCmd_Buf=%p\n",__FUNCTION__, CB_Handle, CB_Func, pTestCmd_Buf));
  566. if (NULL == pTestCmd_Buf)
  567. {
  568. WLAN_REPORT_ERROR(pHwMboxCmdBit->hReport, HAL_HW_CTRL_MODULE_LOG,
  569. ("%s pTestCmd_Buf = NULL!!!\n",__FUNCTION__));
  570. return NOK;
  571. }
  572. WLAN_REPORT_INFORMATION(pHwMboxCmdBit->hReport, HAL_HW_CTRL_MODULE_LOG,
  573. ("%s pTestCmd_Buf->testCmdId=%d\n",__FUNCTION__, pTestCmd_Buf->testCmdId));
  574. WLAN_REPORT_INFORMATION(pHwMboxCmdBit->hReport, HAL_HW_CTRL_MODULE_LOG,
  575. ("%s pTestCmd_Buf (HEX DUMP):\n",__FUNCTION__));
  576. WLAN_REPORT_HEX_INFORMATION(pHwMboxCmdBit->hReport, HAL_HW_CTRL_MODULE_LOG,
  577. (PUINT8)pTestCmd_Buf, sizeof(TestCmd_t));
  578. switch((TestCmdID_enum)pTestCmd_Buf->testCmdId)
  579. {
  580. case TEST_CMD_FCC:
  581. case TEST_CMD_TELEC:
  582. case TEST_CMD_PLT_FCC_TELEC_TX_STOP:
  583. case TEST_CMD_RADIO_TUNE:
  584. bIsCBfuncNecessary = FALSE;
  585. break;
  586. case TEST_CMD_PLT_GAIN_ADJUST:
  587. case TEST_CMD_PLT_TXPOWER_CAL_START:
  588. case TEST_CMD_PLT_TXPOWER_CAL_STOP:
  589. case TEST_CMD_PLT_GAIN_GET:
  590. case TEST_CMD_PLT_GET_NVS_UPDATE_BUFFER:
  591. bIsCBfuncNecessary = TRUE;
  592. break;
  593. case TEST_CMD_PLT_RX_CALIBRATION:
  594. /* Mark that a calibration operation is pending */
  595. pHwMboxCmdBit->PltData.RxTxCal.lastStatus = PENDING;
  596. /* Save the CB for the command response (GWSI oriented) */
  597. pHwMboxCmdBit->PltData.RxTxCal.CB_Func = CB_Func;
  598. pHwMboxCmdBit->PltData.RxTxCal.CB_Handle = CB_Handle;
  599. CB_Func = (void*)whal_hwCmdBit_RxCal_CB;
  600. CB_Handle = (TI_HANDLE)pHwMboxCmdBit;
  601. bIsCBfuncNecessary = TRUE;
  602. break;
  603. default:
  604. WLAN_REPORT_WARNING(pHwMboxCmdBit->hReport, HAL_HW_CTRL_MODULE_LOG,
  605. ("%s Unsupported TestCmdId (%d)\n",__FUNCTION__, pTestCmd_Buf->testCmdId));
  606. break;
  607. }
  608. /* Send the command */
  609. if (CB_Func)
  610. {
  611. return (CmdQueue_CommandWithCb(pHwMboxCmdBit->hCmdQueue, CMD_TEST, (char *)pTestCmd_Buf, sizeof(*pTestCmd_Buf),
  612. CB_Func, CB_Handle, (void*)pTestCmd_Buf));
  613. }
  614. else
  615. {
  616. if (bIsCBfuncNecessary)
  617. return NOK;
  618. else
  619. return (CmdQueue_Command(pHwMboxCmdBit->hCmdQueue, CMD_TEST, (char *)pTestCmd_Buf, sizeof(*pTestCmd_Buf) ));
  620. }
  621. }/* END whal_hwCmdBit_TestCmd() */
  622. /****************************************************************************
  623. * whal_hwCmdBit_RxCal_CB()
  624. ****************************************************************************
  625. * DESCRIPTION: Returns the accumulated counters.
  626. * INPUTS: None
  627. *
  628. * OUTPUT: None
  629. *
  630. * RETURNS: OK or NOK
  631. ****************************************************************************/
  632. void whal_hwCmdBit_RxCal_CB(TI_HANDLE objectHandle,UINT16 MboxStatus,void *InterrogateParamsBuf)
  633. {
  634. HwMboxCmdBit_T *pHwMboxCmdBit = (HwMboxCmdBit_T*)objectHandle;
  635. CmdQueue_InterrogateCB_t CB_Func;
  636. WLAN_REPORT_INFORMATION(pHwMboxCmdBit->hReport, HAL_HW_CTRL_MODULE_LOG,
  637. ("%s MboxStatus = 0x%x\n",
  638. __FUNCTION__, MboxStatus));
  639. /* If there was an error in the RX Calibration command, mark the NOK status here rather than
  640. from the RX calibration complete event callback function (the event won't be sent)*/
  641. if (OK != MboxStatus)
  642. {
  643. pHwMboxCmdBit->PltData.RxTxCal.lastStatus = NOK;
  644. }
  645. /* Call the saved CB function (if any)*/
  646. if (pHwMboxCmdBit->PltData.RxTxCal.CB_Func)
  647. {
  648. CB_Func = (CmdQueue_InterrogateCB_t)(pHwMboxCmdBit->PltData.RxTxCal.CB_Func);
  649. CB_Func(pHwMboxCmdBit->PltData.RxTxCal.CB_Handle, MboxStatus, &pHwMboxCmdBit->PltData.RxTxCal);
  650. }
  651. }
  652. /****************************************************************************
  653. * whal_hwCmdBit_RxCal_Complete_Event_CB()
  654. ****************************************************************************
  655. * DESCRIPTION: Returns the accumulated counters.
  656. * INPUTS: None
  657. *
  658. * OUTPUT: None
  659. *
  660. * RETURNS: OK or NOK
  661. ****************************************************************************/
  662. void whal_hwCmdBit_RxCal_Complete_Event_CB( TI_HANDLE objectHandle, char* str, UINT32 strLen )
  663. {
  664. HwMboxCmdBit_T *pHwMboxCmdBit = (HwMboxCmdBit_T*)objectHandle;
  665. /* mark the status as completed */
  666. pHwMboxCmdBit->PltData.RxTxCal.lastStatus = OK;
  667. }
  668. /****************************************************************************
  669. * whal_hwCmdBit_GetPltRxCalibrationStatus()
  670. ****************************************************************************
  671. * DESCRIPTION: Returns whether the last RX calibration is pending.
  672. * INPUTS: None
  673. *
  674. * OUTPUT: None
  675. *
  676. * RETURNS: None
  677. ****************************************************************************/
  678. void whal_hwCmdBit_GetPltRxCalibrationStatus( TI_HANDLE objectHandle, TI_STATUS* pLastStatus )
  679. {
  680. HwMboxCmdBit_T *pHwMboxCmdBit = (HwMboxCmdBit_T*)objectHandle;
  681. /* return the status of the last RX calibration */
  682. *pLastStatus = pHwMboxCmdBit->PltData.RxTxCal.lastStatus;
  683. }