PageRenderTime 63ms CodeModel.GetById 12ms RepoModel.GetById 0ms app.codeStats 0ms

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

http://github.com/CyanogenMod/cm-kernel
C | 1687 lines | 750 code | 254 blank | 683 comment | 63 complexity | 274a2fad48e6a4550cc63e6fbdd69e77 MD5 | raw file
Possible License(s): AGPL-1.0, GPL-2.0, LGPL-2.0

Large files files are truncated, but you can click here to view the full file

  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: whalHwCtrl.c
  38. * PURPOSE: Implements action on the wlan hardware card (Reset, Run, SendCmd, Sw Download)
  39. *
  40. ****************************************************************************/
  41. #include "802_11Defs.h"
  42. #include "Ethernet.h"
  43. #include "whalCommon.h"
  44. #include "whalCtrl_api.h"
  45. #include "whalHwDefs.h"
  46. #include "whalHwCtrl.h"
  47. #include "whalHwMboxCmd.h"
  48. #include "whalHwMboxConfig.h"
  49. #include "eventMbox_api.h"
  50. #include "whalParams.h"
  51. #include "commonTypes.h"
  52. #include "txResult_api.h"
  53. #include "TNETW_Driver_api.h"
  54. #include "TNETW_Driver.h"
  55. #include "whalSecurity.h"
  56. #define ACX_POWER_MGMT_OPTIONS_STRUCT_DEBUG 0
  57. int whal_hwCtrl_ConfigTemplates(HwCtrl_T *pHwCtrl);
  58. int whal_hwCtrl_ConfigQueues(HwCtrl_T *pHwCtrl, UINT32 MemoryStart);
  59. void whal_hwCtrl_OverridePhyRegsDefaults(HwCtrl_T *pHwCtrl);
  60. #define CF_FORM_FACTOR 3 /* Compact Flash*/
  61. #define CB_FORM_FACTOR 1 /* Card Bus */
  62. /****************************************************************************
  63. * whal_hwCtrl_Create()
  64. ****************************************************************************
  65. * DESCRIPTION: Create the wlan hardware control object
  66. *
  67. * INPUTS:
  68. *
  69. * OUTPUT: None
  70. *
  71. * RETURNS: The Created object
  72. ****************************************************************************/
  73. HwCtrl_T *whal_hwCtrl_Create(TI_HANDLE hOs, WhalParams_T *pWhalParams)
  74. {
  75. HwCtrl_T *pHwCtrl;
  76. pHwCtrl = os_memoryAlloc(hOs, sizeof(HwCtrl_T));
  77. if (pHwCtrl == NULL)
  78. return NULL;
  79. os_memoryZero(hOs, (void*)pHwCtrl, sizeof(HwCtrl_T));
  80. pHwCtrl->hOs = hOs;
  81. pHwCtrl->pWhalParams = pWhalParams;
  82. pHwCtrl->pHwMboxCmd = whal_hwMboxCmd_Create(hOs, pHwCtrl->pWhalParams);
  83. pHwCtrl->pHwMboxCmdBit = whal_hwMboxCmdBit_Create(hOs);
  84. pHwCtrl->pHwMboxConfig = whal_hwMboxConfig_Create(hOs);
  85. pHwCtrl->hWhalBus = whalBus_Create(hOs);
  86. if ( (!pHwCtrl->pHwMboxCmd) || (!pHwCtrl->pHwMboxConfig) || (!pHwCtrl->hWhalBus) )
  87. {
  88. whal_hwCtrl_Destroy(pHwCtrl);
  89. return NULL;
  90. }
  91. return(pHwCtrl);
  92. }
  93. /****************************************************************************
  94. * whal_hwCtrl_Destroy()
  95. ****************************************************************************
  96. * DESCRIPTION: Destroy the object
  97. *
  98. * INPUTS:
  99. * pHwCtrl The object to free
  100. *
  101. * OUTPUT: None
  102. *
  103. * RETURNS: OK or NOK
  104. ****************************************************************************/
  105. int whal_hwCtrl_Destroy(HwCtrl_T *pHwCtrl)
  106. {
  107. if (pHwCtrl == NULL)
  108. return OK;
  109. whal_hwMboxCmd_Destroy(pHwCtrl->pHwMboxCmd);
  110. whal_hwMboxCmdBit_Destroy(pHwCtrl->pHwMboxCmdBit);
  111. whal_hwMboxConfig_Destroy(pHwCtrl->pHwMboxConfig);
  112. whalBus_Destroy(pHwCtrl->hWhalBus);
  113. os_memoryFree(pHwCtrl->hOs, pHwCtrl, sizeof(HwCtrl_T));
  114. return OK;
  115. }
  116. /****************************************************************************
  117. * whal_hwCtrl_GetTnentwifHandle()
  118. ****************************************************************************
  119. * DESCRIPTION: Return TNETWIF handle
  120. *
  121. * INPUTS:
  122. * pHwCtrl The object to free
  123. *
  124. * OUTPUT: None
  125. *
  126. * RETURNS: TNETWIF handle
  127. ****************************************************************************/
  128. TI_HANDLE whal_hwCtrl_GetTnentwifHandle (HwCtrl_T *pHwCtrl)
  129. {
  130. return whalBus_GetTnentwifHandle (pHwCtrl->hWhalBus);
  131. }
  132. /****************************************************************************
  133. * whal_hwCtrl_StartJoin()
  134. ****************************************************************************
  135. * DESCRIPTION: Enable Rx/Tx and send Start/Join command
  136. *
  137. * INPUTS: None
  138. *
  139. * OUTPUT: None
  140. *
  141. * RETURNS: OK or NOK
  142. ****************************************************************************/
  143. int whal_hwCtrl_StartJoin(HwCtrl_T *pHwCtrl, bssType_e BssType, void *JoinCompleteCB, TI_HANDLE CB_handle)
  144. {
  145. HwMboxCmd_T *pHwMboxCmd = pHwCtrl->pHwMboxCmd;
  146. UINT8 HwBssType;
  147. #ifdef TI_DBG
  148. UINT8 *pBssId = whal_ParamsGetBssId(pHwCtrl->pWhalParams);
  149. WLAN_REPORT_INIT(pHwCtrl->hReport, HAL_HW_CTRL_MODULE_LOG,
  150. ("whal_hwCtrl_StartJoin: Enable Tx, Rx and Start the Bss, type=%d\n", BssType));
  151. WLAN_REPORT_INIT(pHwCtrl->hReport, HAL_HW_CTRL_MODULE_LOG,
  152. ("------------------------------------------------------------\n"));
  153. WLAN_REPORT_INIT(pHwCtrl->hReport, HAL_HW_CTRL_MODULE_LOG,
  154. ("START/JOIN, SSID=%s, BSSID=%02X-%02X-%02X-%02X-%02X-%02X, Chan=%d\n", whal_ParamsGetElm_Ssid(pHwCtrl->pWhalParams)->serviceSetId, pBssId[0], pBssId[1], pBssId[2], pBssId[3], pBssId[4], pBssId[5], whal_ParamsGetRadioChannel(pHwCtrl->pWhalParams)));
  155. WLAN_REPORT_INIT(pHwCtrl->hReport, HAL_HW_CTRL_MODULE_LOG,
  156. ("------------------------------------------------------------\n"));
  157. #endif /* TI_DBG */
  158. /*
  159. * Set frame rates according to the values previously configured:
  160. * Driver join -> as configured to whalCtrl_JoinBss()
  161. * GWSI join -> as configured to the template framed before, or default values
  162. * Recovery -> Saved parameters from last Join command
  163. */
  164. whal_hwCtrl_SetFrameRate(pHwCtrl,
  165. pHwCtrl->pWhalParams->BssInfoParams.txCtrlFrmRate,
  166. pHwCtrl->pWhalParams->BssInfoParams.txCtrlFrmModulation,
  167. pHwCtrl->pWhalParams->BssInfoParams.txMgmtFrmRate,
  168. pHwCtrl->pWhalParams->BssInfoParams.txMgmtFrmModulation);
  169. /*
  170. * set RxFilter (but don't write it to the FW, this is done in the join command),
  171. * Configure templates content, ...
  172. */
  173. whal_hwCtrl_SetBssType(pHwCtrl, BssType, &HwBssType);
  174. return whal_hwMboxCmd_StartBss(pHwMboxCmd, HwBssType, JoinCompleteCB, CB_handle);
  175. }
  176. /****************************************************************************
  177. * whal_hwCtrl_switchChannel()
  178. ****************************************************************************
  179. * DESCRIPTION: Switching the serving channel
  180. *
  181. * INPUTS: channel - new channel number
  182. *
  183. * OUTPUT: None
  184. *
  185. * RETURNS: OK or NOK
  186. ****************************************************************************/
  187. int whal_hwCtrl_switchChannel(HwCtrl_T *pHwCtrl,UINT8 channel)
  188. {
  189. HwMboxCmd_T *pHwMboxCmd = pHwCtrl->pHwMboxCmd;
  190. return whal_hwMboxCmd_EnableTx(pHwMboxCmd,channel);
  191. }
  192. /****************************************************************************
  193. * whal_hwCtrl_DisableTx()
  194. ****************************************************************************
  195. * DESCRIPTION: Disable Tx path.
  196. *
  197. * INPUTS: None
  198. *
  199. * OUTPUT: None
  200. *
  201. * RETURNS: OK or NOK
  202. ****************************************************************************/
  203. int whal_hwCtrl_DisableTx(HwCtrl_T *pHwCtrl)
  204. {
  205. HwMboxCmd_T *pHwMboxCmd = pHwCtrl->pHwMboxCmd;
  206. return whal_hwMboxCmd_DisableTx(pHwMboxCmd);
  207. }
  208. /****************************************************************************
  209. * whal_hwCtrl_EnableTx()
  210. ****************************************************************************
  211. * DESCRIPTION: Disable Tx path.
  212. *
  213. * INPUTS: channel - new channel number
  214. *
  215. * OUTPUT: None
  216. *
  217. * RETURNS: OK or NOK
  218. ****************************************************************************/
  219. int whal_hwCtrl_EnableTx(HwCtrl_T *pHwCtrl, int channel)
  220. {
  221. HwMboxCmd_T *pHwMboxCmd = pHwCtrl->pHwMboxCmd;
  222. return whal_hwMboxCmd_EnableTx(pHwMboxCmd, (UINT8)channel);
  223. }
  224. /****************************************************************************
  225. * whal_hwCtrl_EnableDataPath()
  226. ****************************************************************************
  227. * DESCRIPTION: Enable Rx/Tx and send Start/Join command
  228. *
  229. * INPUTS: None
  230. *
  231. * OUTPUT: None
  232. *
  233. * RETURNS: OK or NOK
  234. ****************************************************************************/
  235. int whal_hwCtrl_EnableDataPath(HwCtrl_T *pHwCtrl)
  236. {
  237. HwMboxCmd_T *pHwMboxCmd = pHwCtrl->pHwMboxCmd;
  238. whal_hwMboxCmd_EnableRx(pHwMboxCmd);
  239. whal_hwMboxCmd_EnableTx(pHwMboxCmd, whal_ParamsGetDefaultChannel(pHwCtrl->pWhalParams));
  240. #ifdef WDBG_POLLING /* (!!!) ONLY FOR DEBUG WHEN THERE ARE NO INTERRUPTS */
  241. /* allocate OS timer memory */
  242. hal_timer = os_timerCreate(pHwCtrl->hOs, whal_hwCtrl_RxPollingTimeout, (TI_HANDLE) pHwCtrl);
  243. if (!hal_timer)
  244. return NOK;
  245. os_timerStart(pHwCtrl->hOs, hal_timer, 20, FALSE);
  246. #endif
  247. return OK;
  248. }
  249. /****************************************************************************
  250. * whal_hwCtrl_EnableDataPath()
  251. ****************************************************************************
  252. * DESCRIPTION: Enable Rx/Tx and send Start/Join command
  253. *
  254. * INPUTS: None
  255. *
  256. * OUTPUT: None
  257. *
  258. * RETURNS: OK or NOK
  259. ****************************************************************************/
  260. int whal_hwCtrl_DisableDataPath(HwCtrl_T *pHwCtrl)
  261. {
  262. #if 0
  263. HwMboxCmd_T *pHwMboxCmd = pHwCtrl->pHwMboxCmd;
  264. /*
  265. * L.M. removed because of two reasons:
  266. * 1. When the FW is dead, it only adds delay to recovery.
  267. * 2. WSP does not have it.
  268. */
  269. whal_hwMboxCmd_DisableTx(pHwMboxCmd);
  270. whal_hwMboxCmd_DisableRx(pHwMboxCmd);
  271. /* use FwEvent ... whalBus_hwIntr_Disable(pHwCtrl->hWhalBus, HAL_ALL_INTERRUPTS); */
  272. #endif
  273. return OK;
  274. }
  275. /****************************************************************************
  276. * whal_hwCtrl_SetBssType()
  277. ****************************************************************************
  278. * DESCRIPTION: Set Bss type, set RxFilter
  279. *
  280. * INPUTS: None
  281. *
  282. * OUTPUT: None
  283. *
  284. * RETURNS: OK or NOK
  285. ****************************************************************************/
  286. int whal_hwCtrl_SetBssType(HwCtrl_T *pHwCtrl, bssType_e BssType, UINT8 *HwBssType)
  287. {
  288. switch (BssType)
  289. {
  290. case BSS_AP:
  291. whal_ParamsSetBssType(pHwCtrl->pWhalParams, BSS_TYPE_AP_BSS);
  292. whal_ParamsSetRxFilter(pHwCtrl->pWhalParams, RX_CONFIG_OPTION_ANY_DST_MY_BSS, RX_FILTER_OPTION_DEF);
  293. break;
  294. case BSS_INFRASTRUCTURE:
  295. whal_ParamsSetBssType(pHwCtrl->pWhalParams, BSS_TYPE_STA_BSS);
  296. whal_ParamsSetRxFilter(pHwCtrl->pWhalParams, RX_CONFIG_OPTION_FOR_JOIN, RX_FILTER_OPTION_JOIN);
  297. break;
  298. case BSS_INDEPENDENT:
  299. whal_ParamsSetBssType(pHwCtrl->pWhalParams, BSS_TYPE_IBSS);
  300. #ifdef GWSI_LIB
  301. /* In GWSI we filter with SSID. This is not done in the full driver because of RTP version.
  302. * In the future leave only GWSI option for both cases.
  303. */
  304. whal_ParamsSetRxFilter(pHwCtrl->pWhalParams, RX_CONFIG_OPTION_FOR_IBSS_JOIN, RX_FILTER_OPTION_DEF);
  305. #else
  306. whal_ParamsSetRxFilter(pHwCtrl->pWhalParams, RX_CONFIG_OPTION_FOR_JOIN, RX_FILTER_OPTION_DEF);
  307. #endif
  308. break;
  309. default:
  310. WLAN_REPORT_FATAL_ERROR(pHwCtrl->hReport, HAL_HW_CTRL_MODULE_LOG,
  311. ("whal_hwCtrl_SetBssType: FATAL_ERROR, unknown BssType %d\n", BssType));
  312. return NOK;
  313. }
  314. *HwBssType = whal_ParamsGetBssType(pHwCtrl->pWhalParams);
  315. return OK;
  316. }
  317. /****************************************************************************
  318. * whal_hwCtrl_setRxFilters()
  319. ****************************************************************************
  320. * DESCRIPTION: Sets the filters according to the given configuration.
  321. *
  322. * INPUTS: RxConfigOption - The given Rx filters configuration
  323. * RxFilterOption - The given Rx filters options
  324. *
  325. * OUTPUT: None
  326. *
  327. * RETURNS: OK or NOK
  328. ****************************************************************************/
  329. int whal_hwCtrl_setRxFilters(HwCtrl_T *pHwCtrl, UINT32 RxConfigOption, UINT32 RxFilterOption)
  330. {
  331. whal_ParamsSetRxFilter(pHwCtrl->pWhalParams, RxConfigOption, RxFilterOption);
  332. return whal_hwInfoElemRxConfigSet (pHwCtrl->pHwMboxConfig,
  333. &pHwCtrl->pWhalParams->WlanParams.RxConfigOption,
  334. &pHwCtrl->pWhalParams->WlanParams.RxFilterOption);
  335. }
  336. /****************************************************************************
  337. * whal_hwCtrl_GetRxFilters()
  338. ****************************************************************************
  339. * DESCRIPTION: Sets the filters according to the given configuration.
  340. *
  341. * INPUTS: RxConfigOption - The given Rx filters configuration
  342. * RxFilterOption - The given Rx filters options
  343. *
  344. * OUTPUT: None
  345. *
  346. * RETURNS: OK or NOK
  347. ****************************************************************************/
  348. int whal_hwCtrl_GetRxFilters(HwCtrl_T *pHwCtrl, UINT32* pRxConfigOption, UINT32* pRxFilterOption)
  349. {
  350. whal_ParamsGetRxFilter(pHwCtrl->pWhalParams, pRxConfigOption, pRxFilterOption);
  351. return OK;
  352. }
  353. /****************************************************************************
  354. * whal_hwCtrl_setRxDataFiltersParams()
  355. ****************************************************************************
  356. * DESCRIPTION: Enables or disables Rx data filtering.
  357. *
  358. * INPUTS: enabled - 0 to disable data filtering, any other value to enable.
  359. * defaultAction - The default action to take on non-matching packets.
  360. *
  361. * OUTPUT: None
  362. *
  363. * RETURNS: OK or NOK
  364. ****************************************************************************/
  365. int whal_hwCtrl_setRxDataFiltersParams(HwCtrl_T * pHwCtrl, BOOL enabled, filter_e defaultAction)
  366. {
  367. return whal_hwInfoElemSetRxDataFiltersParams(pHwCtrl->pHwMboxConfig, enabled, defaultAction);
  368. }
  369. /****************************************************************************
  370. * whal_hwCtrl_setRxDataFilter()
  371. ****************************************************************************
  372. * DESCRIPTION: Sets the filters according to the given configuration.
  373. *
  374. * INPUTS: index - Index of the Rx Data filter
  375. * command - Add or remove the filter
  376. * action - Action to take on packets matching the pattern
  377. * numFieldPatterns - Number of field patterns in the filter
  378. * lenFieldPatterns - Length of the field pattern series
  379. * fieldPatterns - Series of field patterns
  380. *
  381. * OUTPUT: None
  382. *
  383. * RETURNS: OK or NOK
  384. ****************************************************************************/
  385. int whal_hwCtrl_setRxDataFilter(HwCtrl_T * pHwCtrl, UINT8 index, UINT8 command, filter_e action, UINT8 numFieldPatterns, UINT8 lenFieldPatterns, UINT8 * fieldPatterns)
  386. {
  387. return whal_hwInfoElemSetRxDataFilter(pHwCtrl->pHwMboxConfig,
  388. index, command, action, numFieldPatterns, lenFieldPatterns, fieldPatterns);
  389. }
  390. /****************************************************************************
  391. * whal_hwCtrl_SetarpIpAddressesTable()
  392. ****************************************************************************
  393. * DESCRIPTION: Sets the ARP IP table according to the given configuration.
  394. *
  395. * OUTPUT: None
  396. *
  397. * RETURNS: OK or NOK
  398. ****************************************************************************/
  399. int whal_hwCtrl_SetarpIpAddressesTable (HwCtrl_T *pHwCtrl, IpAddress_t *IP_addr, UINT8 isEnabled , IPver_e IP_ver)
  400. {
  401. if ( NULL == IP_addr )
  402. {
  403. WLAN_REPORT_ERROR(pHwCtrl->hReport, HAL_HW_CTRL_MODULE_LOG,
  404. ("whal_hwCtrl_SetarpIpAddressesTable: Ip Addr ptr = NULL !!!\n"));
  405. return PARAM_VALUE_NOT_VALID ;
  406. }
  407. whal_ParamsSetarpIpAddressesTable(pHwCtrl->pWhalParams, IP_addr, IP_ver);
  408. whal_ParamsSetarpIpFilterEnabled(pHwCtrl->pWhalParams, isEnabled);
  409. WLAN_REPORT_DEBUG_CONTROL (pHwCtrl->hReport,
  410. ("\n whal_hwCtrl_SetarpIpAddressesTable - ip filtering : %d.%d.%d.%d \n" , IP_addr->addr[0] , IP_addr->addr[1] , IP_addr->addr[2] , IP_addr->addr[3] )) ;
  411. /* Set the new ip with the current state (e/d) */
  412. return whal_hwInfoElemarpIpAddressesTableSet (pHwCtrl->pHwMboxConfig,
  413. IP_addr,
  414. (UINT32)isEnabled);
  415. }
  416. /****************************************************************************
  417. * whalCtrl_GetArpIpAddressesTable()
  418. ****************************************************************************
  419. * DESCRIPTION: Sets the Group table according to the given configuration.
  420. *
  421. * OUTPUT: None
  422. *
  423. * RETURNS: OK or NOK
  424. ****************************************************************************/
  425. int whalCtrl_GetArpIpAddressesTable (HwCtrl_T *pHwCtrl, IpAddress_t *IP_addr, UINT8* pisEnabled , IPver_e* pIP_ver)
  426. {
  427. if ( NULL == pHwCtrl )
  428. {
  429. WLAN_REPORT_ERROR(pHwCtrl->hReport, HAL_HW_CTRL_MODULE_LOG,
  430. ("whalCtrl_GetArpIpAddressesTable = pHwCtrl NULL !!!\n"));
  431. return PARAM_VALUE_NOT_VALID ;
  432. }
  433. if ( NULL == pHwCtrl->pWhalParams )
  434. {
  435. WLAN_REPORT_ERROR(pHwCtrl->hReport, HAL_HW_CTRL_MODULE_LOG,
  436. ("whalCtrl_GetArpIpAddressesTable = pHwCtrl->pWhalParams NULL !!!\n"));
  437. return PARAM_VALUE_NOT_VALID ;
  438. }
  439. whal_ParamsGetarpIpAddressesTable(pHwCtrl->pWhalParams, IP_addr, pIP_ver);
  440. whal_ParamsGetarpIpFilterEnabled(pHwCtrl->pWhalParams, pisEnabled);
  441. return OK;
  442. }
  443. /****************************************************************************
  444. * whal_hwCtrl_SetarpIpFilterEnabled()
  445. ****************************************************************************
  446. * DESCRIPTION: Enable\Disable the ARP filter
  447. *
  448. * OUTPUT: None
  449. *
  450. * RETURNS: OK or NOK
  451. ****************************************************************************/
  452. int whal_hwCtrl_SetarpIpFilterEnabled(HwCtrl_T *pHwCtrl, UINT8 isEnabled )
  453. {
  454. IpAddress_t *IP_addr = &(pHwCtrl->pWhalParams->WlanParams.arp_IP_addr) ;
  455. if ( NULL == pHwCtrl )
  456. {
  457. WLAN_REPORT_ERROR(pHwCtrl->hReport, HAL_HW_CTRL_MODULE_LOG,
  458. ("whal_hwCtrl_SetarpIpFilterEnabled = pHwCtrl NULL !!!\n"));
  459. return PARAM_VALUE_NOT_VALID ;
  460. }
  461. /* set the current ip address with the new state (e/d) */
  462. whal_ParamsSetarpIpFilterEnabled(pHwCtrl->pWhalParams, isEnabled);
  463. return whal_hwInfoElemarpIpAddressesTableSet (pHwCtrl->pHwMboxConfig,
  464. IP_addr,
  465. (UINT32)isEnabled);
  466. }
  467. /****************************************************************************
  468. * whal_hwCtrl_SetGroupAddressesTable()
  469. ****************************************************************************
  470. * DESCRIPTION: Sets the Group table according to the given configuration.
  471. *
  472. * OUTPUT: None
  473. *
  474. * RETURNS: OK or NOK
  475. ****************************************************************************/
  476. int whal_hwCtrl_SetGroupAddressesTable (HwCtrl_T *pHwCtrl,
  477. UINT8 numGroupAddrs,
  478. macAddress_t *Group_addr,
  479. UINT8 isEnabled)
  480. {
  481. if ( NULL == pHwCtrl )
  482. {
  483. return PARAM_VALUE_NOT_VALID;
  484. }
  485. if ( NULL == Group_addr)
  486. {
  487. WLAN_REPORT_ERROR(pHwCtrl->hReport, HAL_HW_CTRL_MODULE_LOG,
  488. ("whal_hwCtrl_SetGroupAddressesTable: numGroupAddrs=%d Group_addr=0x%x !!!\n", numGroupAddrs , Group_addr));
  489. return PARAM_VALUE_NOT_VALID;
  490. }
  491. /* Keeps the parameters in the whal */
  492. whal_ParamsSetGroupAddressesTable(pHwCtrl->pWhalParams, isEnabled, numGroupAddrs, Group_addr);
  493. /* Keeps the parameters in the whal for recovery */
  494. return whal_hwInfoElemGroupAdressesTableSet (pHwCtrl->pHwMboxConfig,
  495. &numGroupAddrs,
  496. Group_addr,
  497. &isEnabled);
  498. }
  499. /****************************************************************************
  500. * whal_hwCtrl_SetRtsThreshold()
  501. ****************************************************************************
  502. * DESCRIPTION: Sets the Rts Threshold.
  503. *
  504. * OUTPUT: None
  505. *
  506. * RETURNS: OK or NOK pWlanParams->RtsThreshold
  507. ****************************************************************************/
  508. int whal_hwCtrl_SetRtsThreshold (HwCtrl_T *pHwCtrl,UINT16 RtsThreshold)
  509. {
  510. return whal_hwInfoElemRtsThresholdSet (pHwCtrl->pHwMboxConfig, RtsThreshold);
  511. }
  512. /****************************************************************************
  513. * whal_hwCtrl_ConfigCb()
  514. ****************************************************************************
  515. * DESCRIPTION: Config the object
  516. *
  517. * INPUTS:
  518. *
  519. * OUTPUT: None
  520. *
  521. * RETURNS: OK or NOK
  522. ****************************************************************************/
  523. static void whal_hwCtrl_ConfigCb (TI_HANDLE hHwCtrl, TI_STATUS status)
  524. {
  525. HwCtrl_T *pHwCtrl = (HwCtrl_T*)hHwCtrl;
  526. WHAL_CTRL *pWhalCtrl = (WHAL_CTRL *)pHwCtrl->hWhalCtrl;
  527. whal_hwMboxCmd_Config(pHwCtrl->pHwMboxCmd, ((TnetwDrv_t*)pWhalCtrl->hTNETW_Driver)->hCmdQueue, pHwCtrl->hReport);
  528. CmdQueue_Config(((TnetwDrv_t*)pWhalCtrl->hTNETW_Driver)->hCmdQueue,
  529. ((TnetwDrv_t*)pWhalCtrl->hTNETW_Driver)->hCmdMBox, pHwCtrl->hReport);
  530. whal_hwMboxCmdBit_Config(pHwCtrl->hWhalCtrl, pHwCtrl->pHwMboxCmdBit, ((TnetwDrv_t*)pWhalCtrl->hTNETW_Driver)->hCmdQueue, pHwCtrl->hReport);
  531. whal_hwMboxConfig_Config(pHwCtrl->pHwMboxConfig, ((TnetwDrv_t*)pWhalCtrl->hTNETW_Driver)->hCmdQueue, pHwCtrl->hReport);
  532. /* This will initiate the download to the FW */
  533. status = whal_hwCtrl_Initiate (pHwCtrl);
  534. if (status == TNETWIF_ERROR)
  535. {
  536. WLAN_REPORT_ERROR (pHwCtrl->hReport, HAL_HW_CTRL_MODULE_LOG,
  537. ("whal_hwCtrl_Config: failed to initialize\n"));
  538. }
  539. }
  540. /****************************************************************************
  541. * whal_hwCtrl_GetGroupAddressesTable()
  542. ****************************************************************************
  543. * DESCRIPTION: Sets the Group table according to the given configuration.
  544. *
  545. * OUTPUT: None
  546. *
  547. * RETURNS: OK or NOK
  548. ****************************************************************************/
  549. int whal_hwCtrl_GetGroupAddressesTable (HwCtrl_T *pHwCtrl,
  550. UINT8* pisEnabled, UINT8* pnumGroupAddrs, macAddress_t *Group_addr)
  551. {
  552. if ( NULL == pHwCtrl )
  553. {
  554. return PARAM_VALUE_NOT_VALID;
  555. }
  556. if ( (NULL == pisEnabled) || (NULL == pnumGroupAddrs) || (NULL == Group_addr))
  557. {
  558. WLAN_REPORT_ERROR(pHwCtrl->hReport, HAL_HW_CTRL_MODULE_LOG,
  559. ("whal_hwCtrl_GetGroupAddressesTable: pisEnabled=0x%p pnumGroupAddrs=0x%p Group_addr=0x%p !!!\n", pisEnabled , pnumGroupAddrs, Group_addr));
  560. return PARAM_VALUE_NOT_VALID;
  561. }
  562. whal_ParamsGetGroupAddressesTable(pHwCtrl->pWhalParams, pisEnabled, pnumGroupAddrs, Group_addr);
  563. return OK;
  564. }
  565. /****************************************************************************
  566. * whal_hwCtrl_Config()
  567. ****************************************************************************
  568. * DESCRIPTION: Config the object
  569. *
  570. * INPUTS:
  571. *
  572. * OUTPUT: None
  573. *
  574. * RETURNS: OK or NOK
  575. ****************************************************************************/
  576. TI_STATUS whal_hwCtrl_Config
  577. (
  578. HwCtrl_T *pHwCtrl,
  579. TI_HANDLE hWhalCtrl,
  580. UINT8 AccessMode,
  581. UINT32 AcxRegAddr,
  582. UINT32 AcxMemAddr,
  583. TI_HANDLE hReport,
  584. TI_HANDLE hMemMgr,
  585. UINT32 *pFWImage,
  586. TI_HANDLE hEventMbox
  587. )
  588. {
  589. pHwCtrl->hReport = hReport;
  590. pHwCtrl->hWhalCtrl = hWhalCtrl;
  591. pHwCtrl->hEventMbox = hEventMbox;
  592. /*
  593. * NOTE: Save firmware image parameters before the 1st TNETWIF call.
  594. * These parameters are passed from the user application and
  595. * may be lost in a case TNETWIF call is asynchronous.
  596. */
  597. pHwCtrl->uFwBuf = pFWImage[0];
  598. pHwCtrl->uFwAddr = pFWImage[1];
  599. pHwCtrl->uEEEPROMBuf = pFWImage[2];
  600. pHwCtrl->uEEEPROMLen = pFWImage[3];
  601. return whalBus_Config (pHwCtrl->hWhalBus,
  602. hWhalCtrl,
  603. AccessMode,
  604. AcxRegAddr,
  605. AcxMemAddr,
  606. hReport,
  607. hMemMgr,
  608. whal_hwCtrl_ConfigCb,
  609. pHwCtrl);
  610. }
  611. /****************************************************************************
  612. * whal_hwCtrl_FinalizeDownloadCb2()
  613. ****************************************************************************
  614. * DESCRIPTION: Finalize all the remaining initialization after the download has finished
  615. *
  616. * INPUTS:
  617. *
  618. * OUTPUT: None
  619. *
  620. * RETURNS: OK or NOK
  621. ****************************************************************************/
  622. static void whal_hwCtrl_FinalizeDownloadCb2 (TI_HANDLE hHwCtrl, TI_STATUS status, void *pData)
  623. {
  624. HwCtrl_T *pHwCtrl = (HwCtrl_T *)hHwCtrl;
  625. whalCtrl_antennaDiversityOptions_t antennaDiversityOptions;
  626. /* Print firmware version */
  627. whal_ParamsPrintFwVersion (pHwCtrl->pWhalParams);
  628. /*
  629. * Configure antenna diversity parameters, same for both radio types.
  630. * (the only difference between DCR and WBR is the antennas number, which is
  631. * hard-coded in the mbox config function per radio type
  632. */
  633. antennaDiversityOptions.enableRxDiversity = FALSE;
  634. antennaDiversityOptions.rxSelectedAntenna = DIVS_RX_START_ANT2;
  635. antennaDiversityOptions.enableTxDiversity = FALSE;
  636. antennaDiversityOptions.txSelectedAntenna = DIVS_TX_START_ANT2;
  637. antennaDiversityOptions.rxTxSharedAnts = TRUE;
  638. whal_hwCtrl_SaveAntennaDiversityOptions (pHwCtrl, &antennaDiversityOptions);
  639. whalCtrl_FinalizeDownload (pHwCtrl->hWhalCtrl);
  640. }
  641. /****************************************************************************
  642. * whal_hwCtrl_FinalizeDownloadCb1()
  643. ****************************************************************************
  644. * DESCRIPTION: Finalize all the remaining initialization after the download has finished
  645. *
  646. * INPUTS:
  647. *
  648. * OUTPUT: None
  649. *
  650. * RETURNS: OK or NOK
  651. ****************************************************************************/
  652. static void whal_hwCtrl_FinalizeDownloadCb1 (TI_HANDLE hHwCtrl, TI_STATUS status, void *pData)
  653. {
  654. HwCtrl_T *pHwCtrl = (HwCtrl_T *)hHwCtrl;
  655. ACXRevision_t *pACXRevision = whal_ParamsGetAcxVersion (pHwCtrl->pWhalParams);
  656. UINT8 *pStationId = ((dot11StationIDStruct*)pData)->dot11StationID;
  657. UINT32 i;
  658. /* Swap bytes of the station id */
  659. for (i = 0; i < 3; i++)
  660. {
  661. UINT8 uTmp = pStationId[i];
  662. pStationId[i] = pStationId[5 - i];
  663. pStationId[5 - i] = uTmp;
  664. }
  665. whal_ParamsSetSrcMac (pHwCtrl->pWhalParams, (char*)pStationId);
  666. /* Get firmware version */
  667. whal_hwInfoElemAcxRevisionGet (pHwCtrl->pHwMboxConfig,
  668. (void *)whal_hwCtrl_FinalizeDownloadCb2,
  669. hHwCtrl,
  670. pACXRevision);
  671. }
  672. /****************************************************************************
  673. * whal_hwCtrl_FinalizeDownload()
  674. ****************************************************************************
  675. * DESCRIPTION: Finalize all the remaining initialization after the download has finished
  676. *
  677. * INPUTS:
  678. *
  679. * OUTPUT: None
  680. *
  681. * RETURNS: OK or NOK
  682. ****************************************************************************/
  683. TI_STATUS whal_hwCtrl_FinalizeDownload (TI_HANDLE hHwCtrl, BootAttr_T *pBootAttr)
  684. {
  685. HwCtrl_T *pHwCtrl= (HwCtrl_T *)hHwCtrl;
  686. /*
  687. * Just comment it since we may need it in future version when we will read from the NVS the
  688. * Configure options (for example power levels)
  689. */
  690. WlanParams_T *pWlanParams = whal_ParamsGetWlanParams (pHwCtrl->pWhalParams);
  691. /* Read NVS version */
  692. pWlanParams->radioType = pBootAttr->radioType;
  693. pWlanParams->minorE2Ver = pBootAttr->minorE2Ver;
  694. pWlanParams->majorE2Ver = pBootAttr->majorE2Ver;
  695. pWlanParams->bugfixE2Ver = pBootAttr->bugfixE2Ver;
  696. /*
  697. * Read config options (WLAN hardware EEPROM). Must be before any configuration
  698. * because the WLAN hardware put the data in the mbox after running the FW
  699. * Not used by now but keep it in code since the data may be requested later on when the
  700. * NVS data will be read from the driver and not from the INI:
  701. * For example the number of power level
  702. * whal_hwInfoElemConfigOptionsRead(pHwCtrl->pHwMboxConfig, pConfigOptions);
  703. */
  704. if (whal_hwInfoElemStationIdGet (pHwCtrl->pHwMboxConfig,
  705. (void *)whal_hwCtrl_FinalizeDownloadCb1,
  706. hHwCtrl,
  707. &pHwCtrl->mbox) != OK)
  708. {
  709. WLAN_REPORT_ERROR (pHwCtrl->hReport, HAL_HW_CTRL_MODULE_LOG,
  710. ("whal_hwCtrl_Config: Error on whal_hwInfoElemStationIdGet\n"));
  711. /* For driver debug only, don't return error */
  712. /* return NOK; */
  713. }
  714. return OK;
  715. }
  716. /****************************************************************************
  717. * whal_hwCtrl_FinalizeOnFailure()
  718. ****************************************************************************
  719. * DESCRIPTION: Finalize all the initialization upon failure
  720. *
  721. * INPUTS:
  722. *
  723. * OUTPUT: None
  724. *
  725. * RETURNS: OK or NOK
  726. ****************************************************************************/
  727. TI_STATUS whal_hwCtrl_FinalizeOnFailure (TI_HANDLE hHwCtrl)
  728. {
  729. HwCtrl_T *pHwCtrl= (HwCtrl_T *)hHwCtrl;
  730. return whalCtrl_FinalizeOnFailure (pHwCtrl->hWhalCtrl);
  731. }
  732. typedef int (*fcallback_t) (TI_HANDLE, TI_STATUS);
  733. /****************************************************************************
  734. * whal_hwCtrl_ConfigHwCb2()
  735. ****************************************************************************
  736. * DESCRIPTION: Configure the WLAN hardware
  737. *
  738. * INPUTS: None
  739. *
  740. * OUTPUT: None
  741. *
  742. * RETURNS: OK or NOK
  743. ****************************************************************************/
  744. static int whal_hwCtrl_ConfigHwCb2 (HwCtrl_T *pHwCtrl, TI_STATUS status, void *pData)
  745. {
  746. WlanParams_T *pWlanParams = whal_ParamsGetWlanParams (pHwCtrl->pWhalParams);
  747. UINT8 *pSrcMacAddr = whal_ParamsGetSrcMac (pHwCtrl->pWhalParams);
  748. UINT32 acID;
  749. whalCtrl_powerMgmtConfig_t powerMgmtConfig;
  750. /* Arrived from callback */
  751. if (pData)
  752. {
  753. ACXDataPathParamsResp_t *pCfg = &pHwCtrl->DataPathParams;
  754. WLAN_REPORT_INIT (pHwCtrl->hReport, HAL_HW_CTRL_MODULE_LOG,
  755. ("%s: rxPacketRingChunkSize = 0x%x,txPacketRingChunkSize = 0x%x,rxPacketRingAddr = 0x%x\n",
  756. __FUNCTION__,pCfg->rxPacketRingChunkSize,pCfg->txPacketRingChunkSize,pCfg->rxPacketRingAddr));
  757. WLAN_REPORT_INIT (pHwCtrl->hReport, HAL_HW_CTRL_MODULE_LOG,
  758. ("(cont')%s: txPacketRingAddr = 0x%x,rxControlAddr = 0x%x,txControlAddr = 0x%x,txCompleteAddr = 0x%x\n",
  759. __FUNCTION__,pCfg->txPacketRingAddr,pCfg->rxControlAddr,pCfg->txControlAddr,pCfg->txCompleteAddr));
  760. pCfg->rxPacketRingChunkSize = ENDIAN_HANDLE_WORD(pCfg->rxPacketRingChunkSize);
  761. pCfg->txPacketRingChunkSize = ENDIAN_HANDLE_WORD(pCfg->txPacketRingChunkSize);
  762. pCfg->rxPacketRingAddr = ENDIAN_HANDLE_LONG(pCfg->rxPacketRingAddr);
  763. pCfg->txPacketRingAddr = ENDIAN_HANDLE_LONG(pCfg->txPacketRingAddr);
  764. pCfg->rxControlAddr = ENDIAN_HANDLE_LONG(pCfg->rxControlAddr);
  765. pCfg->txControlAddr = ENDIAN_HANDLE_LONG(pCfg->txControlAddr);
  766. pCfg->txCompleteAddr = ENDIAN_HANDLE_LONG(pCfg->txCompleteAddr);
  767. }
  768. /* Configure WEP maximum space */
  769. WLAN_REPORT_INIT (pHwCtrl->hReport, HAL_HW_CTRL_MODULE_LOG, ("whal_hwCtrl_Configure: WEP cache - none\n"));
  770. #ifdef CORE_5_0
  771. whal_hwInfoElemMemoryMapPrint (pHwCtrl->pHwMboxConfig);
  772. #endif
  773. /* Override WLAN hardware defaults */
  774. whal_hwInfoElemStationIdSet (pHwCtrl->pHwMboxConfig, pSrcMacAddr);
  775. /* Configure the Rx Msdu Life Time (expiry time of de-fragmentation in FW) */
  776. whal_hwInfoElemRxMsduLifeTimeSet (pHwCtrl->pHwMboxConfig, pWlanParams->MaxRxMsduLifetime);
  777. whal_hwInfoElemRxConfigSet (pHwCtrl->pHwMboxConfig, &pWlanParams->RxConfigOption, &pWlanParams->RxFilterOption);
  778. #if 0
  779. /* Use firmware default parameters for ant. which is ant 2 for both TX and RX */
  780. whal_hwCtrl_CurrentAntennaDiversitySendCmd (pHwCtrl);
  781. #endif
  782. for (acID = 0; acID < MAX_NUM_OF_AC; acID++)
  783. {
  784. whal_hwCtrl_QueueConf (pHwCtrl, &pWlanParams->acQueuesParams[acID]);
  785. /*
  786. * NOTE: Set following parameters only if they were configured.
  787. * Otherwise, they contain garbage.
  788. */
  789. if (pHwCtrl->pWhalParams->AcParams.isAcConfigured[acID])
  790. {
  791. configureCmdCBParams_t configureCmdAc = {NULL,NULL,NULL};
  792. configureCmdAc.CB_buf = (UINT8*)&pHwCtrl->pWhalParams->AcParams.ac[acID];
  793. whal_hwCtrl_AcParamsConf (pHwCtrl, &configureCmdAc);
  794. }
  795. if (pHwCtrl->pWhalParams->QueuesParams.isQueueConfigured[acID])
  796. {
  797. whal_hwCtrl_TrafficConf (pHwCtrl, &pHwCtrl->pWhalParams->QueuesParams.queues[acID]);
  798. }
  799. }
  800. whal_hwCtrl_PacketDetectionThreshold (pHwCtrl, &pHwCtrl->pWhalParams->WlanParams.PacketDetectionThreshold);
  801. whal_hwCtrl_SetSlotTime (pHwCtrl, (slotTime_e )pWlanParams->SlotTime);
  802. whal_hwCtrl_SetarpIpAddressesTable (pHwCtrl,
  803. &pWlanParams->arp_IP_addr,
  804. pWlanParams->isArpIpFilteringEnabled,
  805. IP_VER_4);
  806. whal_hwCtrl_SetGroupAddressesTable (pHwCtrl,
  807. pWlanParams->numGroupAddrs,
  808. pWlanParams->Group_addr,
  809. pWlanParams->isMacAddrFilteringnabled);
  810. whal_hwInfoElemRxTimeOutSet (pHwCtrl->pHwMboxConfig, &pWlanParams->rxTimeOut);
  811. whal_hwCtrl_SetRtsThreshold (pHwCtrl, pWlanParams->RtsThreshold);
  812. /* Set The Beacon Filter in HAL */
  813. whal_hwCtrl_SetBeaconFiltering (pHwCtrl,
  814. pWlanParams->beaconFilterParams.desiredState,
  815. pWlanParams->beaconFilterParams.numOfElements);
  816. whal_hwCtrl_SetBeaconFilterIETable (pHwCtrl,
  817. &pWlanParams->beaconFilterIETable.numberOfIEs,
  818. pWlanParams->beaconFilterIETable.IETable,
  819. &pWlanParams->beaconFilterIETable.IETableSize);
  820. /* Set SG Params only in Init Phase. */
  821. /* In recovery it will be handled in SoftGemini_hanfleRecovery() */
  822. if (pData)
  823. {
  824. WLAN_REPORT_INIT (pHwCtrl->hReport, HAL_HW_CTRL_MODULE_LOG, ("whal_hwCtrl_Configure: Setting the Soft Gemini state\n"));
  825. /* Set the Soft Gemini state */
  826. if (pWlanParams->SoftGeminiEnable == SG_SENSE_ACTIVE)
  827. {
  828. whal_hwCtrl_SoftGeminiEnable (pHwCtrl, SG_SENSE_NO_ACTIVITY);
  829. }
  830. else
  831. {
  832. whal_hwCtrl_SoftGeminiEnable (pHwCtrl, pWlanParams->SoftGeminiEnable);
  833. }
  834. /* Set the Soft Gemini params */
  835. whal_hwCtrl_SetSoftGeminiParams (pHwCtrl, &pWlanParams->SoftGeminiParams);
  836. }
  837. /* For recovery decision */
  838. eventMbox_EvUnMask (pHwCtrl->hEventMbox, HAL_EVENT_HEALTH_REPORT);
  839. whal_hwCtrl_OverridePhyRegsDefaults (pHwCtrl);
  840. #ifdef TNETW1150
  841. whal_hwCtrl_SetACIConfiguration (pHwCtrl,
  842. pWlanParams->ACIMode,
  843. pWlanParams->inputCCA,
  844. pWlanParams->qualifiedCCA,
  845. pWlanParams->stompForRx,
  846. pWlanParams->stompForTx,
  847. pWlanParams->txCCA);
  848. #endif/*TNETW1150*/
  849. /* Beacon broadcast options */
  850. powerMgmtConfig.BcnBrcOptions = pWlanParams->BcnBrcOptions;
  851. powerMgmtConfig.ConsecutivePsPollDeliveryFailureThreshold = pWlanParams->ConsecutivePsPollDeliveryFailureThreshold;
  852. whal_hwCtrl_BcnBrcOptions (pHwCtrl, &powerMgmtConfig);
  853. /* Enable rx/tx path on the hardware */
  854. if (whal_hwCtrl_EnableDataPath (pHwCtrl) != OK)
  855. return NOK;
  856. /* ACX for a work around for Wi-Fi test */
  857. whal_hwInfoElemWiFiWmmPSWASet (pHwCtrl->pHwMboxConfig, pWlanParams->WiFiWmmPS);
  858. /* Enable the scan complete interrupt source */
  859. eventMbox_EvUnMask (pHwCtrl->hEventMbox, HAL_EVENT_SCAN_CMPLT);
  860. eventMbox_EvUnMask (pHwCtrl->hEventMbox, HAL_EVENT_SPS_SCAN_CMPLT);
  861. /* Call the upper layer callback */
  862. return (*((fcallback_t)pHwCtrl->fCb)) (pHwCtrl->hCb, OK);
  863. }
  864. /****************************************************************************
  865. * whal_hwCtrl_ConfigHwCb1()
  866. ****************************************************************************
  867. * DESCRIPTION: Configure the WLAN hardware
  868. *
  869. * INPUTS: None
  870. *
  871. * OUTPUT: None
  872. *
  873. * RETURNS: OK or NOK
  874. ****************************************************************************/
  875. static int whal_hwCtrl_ConfigHwCb1 (HwCtrl_T *pHwCtrl, TI_STATUS status, void *pData)
  876. {
  877. MemoryMap_t *pMemMap = &pHwCtrl->MemMap;
  878. DmaParams_T *pDmaParams = whal_ParamsGetDmaParams (pHwCtrl->pWhalParams);
  879. WlanParams_T *pWlanParams = whal_ParamsGetWlanParams (pHwCtrl->pWhalParams);
  880. /* Arrived from callback */
  881. if (pData)
  882. {
  883. UINT32 *pSwap, i;
  884. /* Solve endian problem (all fields are 32 bit) */
  885. pSwap = (UINT32* )&(pMemMap->codeStart);
  886. for (i = 0; i < MEM_MAP_NUM_FIELDS; i++)
  887. pSwap[i] = ENDIAN_HANDLE_LONG(pSwap[i]);
  888. }
  889. /* Save number of TX blocks */
  890. pDmaParams->NumTxBlocks = pMemMap->numTxMemBlks;
  891. /*
  892. * Configure DataPath parameters to default
  893. * values and Read the Addresses of the FW data path buffers
  894. */
  895. /* Set Data path parameters to constant value to emulate the original double buffer*/
  896. whal_hwInfoElemDataPathParamsSet (pHwCtrl->pHwMboxConfig,
  897. DP_RX_PACKET_RING_CHUNK_SIZE,
  898. DP_TX_PACKET_RING_CHUNK_SIZE,
  899. DP_RX_PACKET_RING_CHUNK_NUM,
  900. DP_TX_PACKET_RING_CHUNK_NUM,
  901. pWlanParams->TxCompleteThreshold,
  902. FW_TX_CMPLT_BLOCK_SIZE,
  903. DP_TX_COMPLETE_TIME_OUT);
  904. /* Arrived from callback */
  905. if (pData)
  906. {
  907. /* Get the double buffers and registers address values */
  908. return whal_hwInfoElemDataPathParamsGet (pHwCtrl->pHwMboxConfig,
  909. &pHwCtrl->DataPathParams,
  910. (void *)whal_hwCtrl_ConfigHwCb2,
  911. pHwCtrl);
  912. }
  913. /* Called directly */
  914. else
  915. {
  916. return whal_hwCtrl_ConfigHwCb2 (pHwCtrl, OK, NULL);
  917. }
  918. }
  919. /****************************************************************************
  920. * whal_hwCtrl_ConfigHw()
  921. ****************************************************************************
  922. * DESCRIPTION: Configure the WLAN hardware
  923. *
  924. * INPUTS: None
  925. *
  926. * OUTPUT: None
  927. *
  928. * RETURNS: OK or NOK
  929. ****************************************************************************/
  930. int whal_hwCtrl_ConfigHw (HwCtrl_T *pHwCtrl, void *fCb, TI_HANDLE hCb, BOOL bRecovery)
  931. {
  932. MemoryMap_t *pMemMap = &pHwCtrl->MemMap;
  933. /*
  934. * The addresses of the Double buffer, The Tx Path Status,
  935. * Rx Path Status, Tx Path Control, Rx Path Control
  936. */
  937. /* ACXDataPathParamsResp_t *DataPathParam = &pHwCtrl->DataPathParams; */
  938. /*
  939. * The DmaParams_T is the same struct as the halTxRxQueueGlobalsParams_t struct
  940. * but is defined in the whalBus_Defs.h and not in the paramOut.h as done by BCIL
  941. */
  942. DmaParams_T *pDmaParams = whal_ParamsGetDmaParams (pHwCtrl->pWhalParams);
  943. pHwCtrl->fCb = fCb;
  944. pHwCtrl->hCb = hCb;
  945. /* Configure the WLAN hardware memory (WEP, Templates, Queue, Buffers) */
  946. /* Configure packet templates */
  947. WLAN_REPORT_INIT (pHwCtrl->hReport, HAL_HW_CTRL_MODULE_LOG, ("whal_hwCtrl_Configure: templates \n"));
  948. whal_hwCtrl_ConfigTemplates (pHwCtrl);
  949. /* Configure RX/TX queues */
  950. WLAN_REPORT_INIT (pHwCtrl->hReport, HAL_HW_CTRL_MODULE_LOG, ("whal_hwCtrl_Configure: queues\n"));
  951. /* Configure the weight among the different hardware queues */
  952. whal_hwInfoElemConfigMemorySet (pHwCtrl->pHwMboxConfig, pDmaParams);
  953. /* Extract total number of blocks in the pool */
  954. if (bRecovery)
  955. return whal_hwCtrl_ConfigHwCb1 (pHwCtrl, OK, NULL);
  956. else
  957. return whal_hwInfoElemMemoryMapGet (pHwCtrl->pHwMboxConfig,
  958. pMemMap,
  959. (void *)whal_hwCtrl_ConfigHwCb1,
  960. pHwCtrl);
  961. }
  962. #ifdef TNETW1150
  963. /****************************************************************************
  964. * whal_hwCtrl_SetACIConfiguration()
  965. ****************************************************************************
  966. * DESCRIPTION: Set the hardware ACI configuration
  967. *
  968. * INPUTS: None
  969. *
  970. * OUTPUT: None
  971. *
  972. * RETURNS: OK or NOK
  973. ****************************************************************************/
  974. int whal_hwCtrl_SetACIConfiguration (HwCtrl_T *pHwCtrl, UINT8 ACIMode,
  975. UINT8 inputCCA, UINT8 qualifiedCCA,
  976. UINT8 stompForRx, UINT8 stompForTx,
  977. UINT8 txCCA)
  978. {
  979. return (whal_hwInfoElemACIConfigurationSet (pHwCtrl->pHwMboxConfig, ACIMode,
  980. inputCCA, qualifiedCCA, stompForRx,
  981. stompForTx, txCCA));
  982. }
  983. #endif/*TNETW1150*/
  984. /****************************************************************************
  985. * whal_hwCtrl_SetMacAddress()
  986. ****************************************************************************
  987. * DESCRIPTION:
  988. *
  989. * INPUTS: None
  990. *
  991. * OUTPUT: None
  992. *
  993. * RETURNS: OK or NOK
  994. ****************************************************************************/
  995. int whal_hwCtrl_SetMacAddress(HwCtrl_T *pHwCtrl, macAddress_t *macAddr)
  996. {
  997. whal_ParamsSetSrcMac(pHwCtrl->pWhalParams, (char*)macAddr->addr);
  998. return whal_hwInfoElemStationIdSet (pHwCtrl->pHwMboxConfig, (UINT8*)macAddr->addr);
  999. }
  1000. /****************************************************************************
  1001. * whal_hwCtrl_ConfigTemplates()
  1002. ****************************************************************************
  1003. * DESCRIPTION: Configure the packet templates
  1004. *
  1005. * AP - beacon, probe response, tim
  1006. * STA (INFRA) - probe request
  1007. * STA (IBSS) - beacon, probe response, probe request
  1008. * know yet the bss type
  1009. *
  1010. * INPUTS:
  1011. *
  1012. * OUTPUT: None
  1013. *
  1014. * RETURNS: OK or NOK
  1015. ****************************************************************************/
  1016. int whal_hwCtrl_ConfigTemplates(HwCtrl_T *pHwCtrl)
  1017. {
  1018. UINT8 PartialVirtualBmap[DOT11_PARTIAL_VIRTUAL_BITMAP_MAX];
  1019. UINT8 BmapControl;
  1020. WlanParams_T *pWlanParams = whal_ParamsGetWlanParams(pHwCtrl->pWhalParams);
  1021. /*
  1022. * Probe request template
  1023. */
  1024. whal_hwMboxCmd_ConfigureTemplateFrame(pHwCtrl->pHwMboxCmd, NULL, pWlanParams->probeRequestTemplateSize,
  1025. CMD_PROBE_REQ,NULL,NULL);
  1026. /*
  1027. * Null Data template
  1028. */
  1029. whal_hwMboxCmd_ConfigureTemplateFrame(pHwCtrl->pHwMboxCmd, NULL, pWlanParams->nullTemplateSize,
  1030. CMD_NULL_DATA,NULL,NULL);
  1031. /*
  1032. * Ps Poll template
  1033. */
  1034. whal_hwMboxCmd_ConfigureTemplateFrame(pHwCtrl->pHwMboxCmd, NULL, pWlanParams->PsPollTemplateSize,
  1035. CMD_PS_POLL,NULL,NULL);
  1036. /*
  1037. * Qos Null Data template
  1038. */
  1039. whal_hwMboxCmd_ConfigureTemplateFrame(pHwCtrl->pHwMboxCmd, NULL, pWlanParams->qosNullDataTemplateSize,
  1040. CMD_QOS_NULL_DATA,NULL,NULL);
  1041. /*
  1042. * Probe response template
  1043. */
  1044. whal_hwMboxCmd_ConfigureTemplateFrame(pHwCtrl->pHwMboxCmd, NULL, pWlanParams->probeResponseTemplateSize,
  1045. CMD_PROBE_RESP,NULL,NULL);
  1046. /*
  1047. * Beacon template
  1048. */
  1049. whal_hwMboxCmd_ConfigureTemplateFrame(pHwCtrl->pHwMboxCmd, NULL, pWlanParams->beaconTemplateSize,
  1050. CMD_BEACON,NULL,NULL);
  1051. /*
  1052. * Tim template, first reserve space (len=MAX), second init to empty
  1053. */
  1054. BmapControl = 0;
  1055. os_memoryZero(pHwCtrl->hOs, (void*)PartialVirtualBmap, DOT11_PARTIAL_VIRTUAL_BITMAP_MAX);
  1056. whal_hwMboxCmd_TimTemplate(pHwCtrl->pHwMboxCmd, BmapControl, (char*)PartialVirtualBmap, DOT11_PARTIAL_VIRTUAL_BITMAP_MAX);
  1057. whal_hwMboxCmd_TimTemplate(pHwCtrl->pHwMboxCmd, BmapControl, (char*)PartialVirtualBmap, 1);
  1058. return OK;
  1059. }
  1060. /****************************************************************************
  1061. * whal_hwCtrl_SetSlotTime()
  1062. ****************************************************************************
  1063. * DESCRIPTION: Set the Slot field in ACM_IFS_CFG1 hardware register
  1064. *
  1065. * INPUTS:
  1066. * SlotTimeVal The Short SlotTime bit value in the Capabilities
  1067. *
  1068. * OUTPUT: None
  1069. *
  1070. * RETURNS: None
  1071. ****************************************************************************/
  1072. int whal_hwCtrl_SetSlotTime(HwCtrl_T *pHwCtrl, slotTime_e SlotTimeVal)
  1073. {
  1074. UINT8 slotTime;
  1075. WLAN_REPORT_DEBUG_CONTROL(pHwCtrl->hReport,(" whal_hwCtrl_SetSlotTime: SlotTimeVal = 0x%x\n",SlotTimeVal));
  1076. if (SlotTimeVal == SLOT_TIME_LONG)
  1077. slotTime = (UINT8) SLOT_TIME_LONG;
  1078. else
  1079. slotTime = (UINT8) SLOT_TIME_SHORT;
  1080. return whal_hwInfoElemSlotTimeSet (pHwCtrl->pHwMboxConfig, &slotTime);
  1081. }
  1082. /****************************************************************************
  1083. * whal_hwCtrl_SetPreamble()
  1084. ****************************************************************************
  1085. * DESCRIPTION: Set the preamble in ?????? hardware register
  1086. *
  1087. * INPUTS:
  1088. * preambleVal
  1089. *
  1090. * OUTPUT: None
  1091. *
  1092. * RETURNS…

Large files files are truncated, but you can click here to view the full file