PageRenderTime 48ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/drivers/net/wireless/tiwlan1251/common/src/core/data_ctrl/Ctrl/4X/fourXManager.c

http://github.com/CyanogenMod/cm-kernel
C | 430 lines | 285 code | 70 blank | 75 comment | 34 complexity | b55d9a26d7b1780757d80b244bf54438 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: */
  38. /* PURPOSE: */
  39. /* */
  40. /***************************************************************************/
  41. #include "fourX.h"
  42. #include "report.h"
  43. #include "osApi.h"
  44. #include "utils.h"
  45. static void fourXManager_resetAll4xCapabilities(fourX_t* pFourX);
  46. static void fourXManager_resetAll_AP_4xCapabilities(fourX_t* pFourX);
  47. static TI_STATUS fourXManager_InfoElementParsing(fourX_t* pFourX,
  48. dot11_4X_t* site4xParams,
  49. fourX_Capabilities_t* pFourX_Capabilities);
  50. static void setDefault4xCapabilities(fourX_Capabilities_t* pFourX_Capabilities);
  51. static TI_STATUS build4XInfoElementVersion0(fourX_t* pFourX,
  52. dot11_4X_t* fourXInfoElemnt);
  53. static TI_STATUS build4XInfoElementVersion1(fourX_t* pFourX,
  54. dot11_4X_t* fourXInfoElemnt);
  55. /* 4X manager */
  56. TI_STATUS fourXManager_evalSite(fourX_t* pFourX,
  57. dot11_4X_t* site4xParams,
  58. UINT32 *matchingLevel)
  59. {
  60. /* TODO - define 4x matching level */
  61. return OK;
  62. }
  63. TI_STATUS fourXManager_setSite(fourX_t* pFourX,
  64. dot11_4X_t* site4xParams)
  65. {
  66. TI_STATUS status;
  67. whalParamInfo_t param;
  68. status = fourXManager_InfoElementParsing(pFourX,
  69. site4xParams,
  70. &pFourX->ApFourX_Capabilities);
  71. if(status != OK)
  72. {
  73. /* set all 4x capabilities to 0 */
  74. fourXManager_resetAll4xCapabilities(pFourX);
  75. return NOK;
  76. }
  77. /*
  78. * configure fourX module and driver 4x Parameters
  79. */
  80. /* configure concatenation parameters */
  81. if( (pFourX->desiredConcatenationEnable == TRUE) &&
  82. (pFourX->ApFourX_Capabilities.concatenationParams.enableDisable == TRUE) )
  83. {
  84. pFourX->concatenationEnable = TRUE;
  85. }
  86. else
  87. {
  88. pFourX->concatenationEnable = FALSE;
  89. }
  90. pFourX->currentMaxConcatSize = MIN(pFourX->desiredMaxConcatSize,pFourX->ApFourX_Capabilities.concatenationParams.concatenationSize);
  91. /*
  92. * set Hal Parameters
  93. */
  94. param.paramType = HAL_CTRL_RTS_THRESHOLD_PARAM;
  95. param.content.halCtrlRtsThreshold = HAL_CTRL_RTS_THRESHOLD_MAX;
  96. whalCtrl_SetParam(pFourX->hWhalCtrl, &param);
  97. /* configure contentionWindow parameters */
  98. if( (pFourX->desiredCWMinEnable == TRUE) &&
  99. (pFourX->ApFourX_Capabilities.contentionWindowParams.enableDisable == TRUE) )
  100. {
  101. pFourX->CWMinEnable = TRUE;
  102. }
  103. else
  104. {
  105. pFourX->CWMinEnable = FALSE;
  106. }
  107. pFourX->currentCWMax = MIN(pFourX->desiredCWMax,pFourX->ApFourX_Capabilities.contentionWindowParams.CWMax);
  108. pFourX->currentCWMax = MAX(pFourX->desiredCWMin,pFourX->ApFourX_Capabilities.contentionWindowParams.CWMin);
  109. /* configure CWCombo parameters - DO NOT Supported */
  110. if( (pFourX->desiredCWComboEnable == TRUE) &&
  111. (pFourX->ApFourX_Capabilities.CWCombParams.enableDisable == TRUE) )
  112. {
  113. pFourX->CWComboEnable = TRUE;
  114. }
  115. else
  116. {
  117. pFourX->CWComboEnable = FALSE;
  118. }
  119. /* configure CWCombo parameters */
  120. if( (pFourX->desiredAckEmulationEnable == TRUE) &&
  121. (pFourX->ApFourX_Capabilities.ackEmulationParams.enableDisable == TRUE) )
  122. {
  123. #ifdef ACK_EMUL
  124. pFourX->ackEmulationEnable = TRUE;
  125. #else
  126. pFourX->ackEmulationEnable = FALSE;
  127. #endif
  128. }
  129. else
  130. {
  131. pFourX->ackEmulationEnable = FALSE;
  132. }
  133. /* configure CWCombo parameters - DO NOT Supported */
  134. if( (pFourX->desiredERP_ProtectionEnable == TRUE) &&
  135. (pFourX->ApFourX_Capabilities.ERP_ProtectionParams.enableDisable == TRUE) )
  136. {
  137. pFourX->ERP_ProtectionEnable = TRUE;
  138. }
  139. else
  140. {
  141. pFourX->ERP_ProtectionEnable = FALSE;
  142. }
  143. return OK;
  144. }
  145. static TI_STATUS fourXManager_InfoElementParsing(fourX_t* pFourX,
  146. dot11_4X_t* site4xParams,
  147. fourX_Capabilities_t* pFourX_Capabilities)
  148. {
  149. char *capPtr;
  150. UINT32 len;
  151. UINT16 capLen;
  152. WlanTIcap_t cap_type;
  153. UINT8 ti_oui[] = TI_OUI;
  154. if(site4xParams == NULL)
  155. {
  156. fourXManager_resetAll_AP_4xCapabilities(pFourX);
  157. return NOK;
  158. }
  159. /*
  160. * IE parsing
  161. */
  162. if( (site4xParams->hdr.eleId != DOT11_4X_ELE_ID) ||
  163. (site4xParams->hdr.eleLen > DOT11_4X_MAX_LEN) ||
  164. (os_memoryCompare(pFourX->hOs ,ti_oui, (PUINT8)site4xParams->fourXCapabilities, DOT11_OUI_LEN) != 0) )
  165. {
  166. fourXManager_resetAll_AP_4xCapabilities(pFourX);
  167. return NOK;
  168. }
  169. /*
  170. * check protocol version
  171. */
  172. if( ((site4xParams->fourXCapabilities[DOT11_OUI_LEN]) & 0xF) == FOUR_X_PROTOCOL_VERSION_0)
  173. {
  174. /*
  175. * version 0
  176. */
  177. pFourX_Capabilities->fourXProtocolVersion = FOUR_X_PROTOCOL_VERSION_0;
  178. setDefault4xCapabilities(pFourX_Capabilities);
  179. return OK;
  180. }
  181. else
  182. if( ((site4xParams->fourXCapabilities[DOT11_OUI_LEN]) & 0xF) == FOUR_X_PROTOCOL_VERSION_1)
  183. {
  184. /*
  185. * version 1
  186. */
  187. pFourX_Capabilities->fourXProtocolVersion = FOUR_X_PROTOCOL_VERSION_1;
  188. capPtr = (char *)site4xParams;
  189. capPtr += (sizeof(dot11_eleHdr_t) + DOT11_OUI_LEN + 1); /*IE header + TI_OUI + version field */;
  190. len = DOT11_OUI_LEN+1; /* TI_OUI + version field */
  191. while(len < (UINT32)(site4xParams->hdr.eleLen)) /* Dm: Security fix */
  192. {
  193. cap_type = (WlanTIcap_t)(*((UINT16*)(capPtr)));
  194. switch(cap_type)
  195. {
  196. case TI_CAP_4X_CONCATENATION:
  197. pFourX_Capabilities->concatenationParams.enableDisable = TRUE;
  198. capPtr += 2;
  199. capLen = *((UINT16*)(capPtr));
  200. capPtr += 2;
  201. pFourX_Capabilities->concatenationParams.concatenationSize = *((UINT16*)(capPtr));
  202. capPtr += 2;
  203. len += sizeof(UINT16) /* type field */ + sizeof(UINT16) /* len field */ + (UINT32)capLen /* val fields */;
  204. break;
  205. case TI_CAP_4X_CONT_WINDOW:
  206. pFourX_Capabilities->contentionWindowParams.enableDisable = TRUE;
  207. capPtr += 2;
  208. capLen = *((UINT16*)(capPtr));
  209. capPtr += 2;
  210. pFourX_Capabilities->contentionWindowParams.CWMin = *((UINT16*)(capPtr));
  211. capPtr += 2;
  212. pFourX_Capabilities->contentionWindowParams.CWMax = *((UINT16*)(capPtr));
  213. capPtr += 2;
  214. len += sizeof(UINT16) /* type field */ + sizeof(UINT16) /* len field */ + (UINT32)capLen /* val field */;
  215. break;
  216. case TI_CAP_4X_CONT_WINDOW_COMBO:
  217. pFourX_Capabilities->CWCombParams.enableDisable = TRUE;
  218. capPtr += 2;
  219. capLen = *((UINT16*)(capPtr));
  220. capPtr += 2;
  221. pFourX_Capabilities->CWCombParams.DIFS = *((UINT16*)(capPtr));
  222. capPtr += 2;
  223. pFourX_Capabilities->CWCombParams.SLOT = *((UINT16*)(capPtr));
  224. capPtr += 2;
  225. pFourX_Capabilities->CWCombParams.CWMin = *((UINT16*)(capPtr));
  226. capPtr += 2;
  227. len += sizeof(UINT16) /* type field */ + sizeof(UINT16) /* len field */ + (UINT32)capLen /* val field */;
  228. break;
  229. case TI_CAP_4X_TCP_ACK_EMUL:
  230. pFourX_Capabilities->ackEmulationParams.enableDisable = TRUE;
  231. capPtr += 2;
  232. capLen = *((UINT16*)(capPtr));
  233. capPtr += 2;
  234. len += sizeof(UINT16) /* type field */ + sizeof(UINT16) /* len field */ + (UINT32)capLen /* val field */;
  235. break;
  236. case TI_CAP_TRICK_PACKET_ERP:
  237. pFourX_Capabilities->ERP_ProtectionParams.enableDisable = TRUE;
  238. capPtr += 2;
  239. capLen = *((UINT16*)(capPtr));
  240. capPtr += 2;
  241. len += sizeof(UINT16) /* type field */ + sizeof(UINT16) /* len field */ + (UINT32)capLen /* val field */;
  242. break;
  243. default:
  244. WLAN_REPORT_INFORMATION(pFourX->hReport, FOUR_X_MODULE_LOG,
  245. ("unrecognized capability in TI IE: %d\n",cap_type));
  246. return NOK;
  247. }
  248. }
  249. }
  250. else
  251. {
  252. /*
  253. * unknown version
  254. */
  255. fourXManager_resetAll_AP_4xCapabilities(pFourX);
  256. return NOK;
  257. }
  258. return OK;
  259. }
  260. TI_STATUS fourXManager_get4xInfoElemnt(fourX_t* pFourX,
  261. dot11_4X_t* fourXInfoElemnt)
  262. {
  263. TI_STATUS Status;
  264. if(pFourX->ApFourX_Capabilities.fourXProtocolVersion == FOUR_X_PROTOCOL_VERSION_0)
  265. {
  266. Status = build4XInfoElementVersion0(pFourX, fourXInfoElemnt);
  267. }
  268. else
  269. if(pFourX->ApFourX_Capabilities.fourXProtocolVersion == FOUR_X_PROTOCOL_VERSION_1)
  270. {
  271. Status = build4XInfoElementVersion1(pFourX, fourXInfoElemnt);
  272. }
  273. else
  274. {
  275. WLAN_REPORT_INFORMATION(pFourX->hReport, FOUR_X_MODULE_LOG,
  276. ("fourXManager_get4xInfoElemnt: Versionm unknown\n"));
  277. return NOK;
  278. }
  279. return Status;
  280. }
  281. static TI_STATUS build4XInfoElementVersion0(fourX_t* pFourX,
  282. dot11_4X_t* fourXInfoElemnt)
  283. {
  284. UINT8 ti_oui[] = TI_OUI;
  285. WLAN_REPORT_INFORMATION(pFourX->hReport, FOUR_X_MODULE_LOG,
  286. ("build4XInfoElementVersion0: build IE version 0\n"));
  287. /* 4x Protocol version should support ALL version 0 features */
  288. if( (pFourX->desiredConcatenationEnable == FALSE) ||
  289. (pFourX->desiredCWMinEnable == FALSE) )
  290. {
  291. return NOK;
  292. }
  293. fourXInfoElemnt->hdr.eleId = TI_4X_IE_ID;
  294. fourXInfoElemnt->hdr.eleLen = FOUR_X_INFO_ELEMENT_VERSION_0_LEN;
  295. os_memoryCopy(pFourX->hOs, (PUINT8)fourXInfoElemnt->fourXCapabilities, ti_oui, DOT11_OUI_LEN);
  296. fourXInfoElemnt->fourXCapabilities[DOT11_OUI_LEN] = FOUR_X_PROTOCOL_VERSION_0;
  297. return OK;
  298. }
  299. static TI_STATUS build4XInfoElementVersion1(fourX_t* pFourX,
  300. dot11_4X_t* fourXInfoElemnt)
  301. {
  302. UINT8 len = 0;
  303. UINT8 *capPtr;
  304. UINT8 ti_oui[] = TI_OUI;
  305. WLAN_REPORT_INFORMATION(pFourX->hReport, FOUR_X_MODULE_LOG,
  306. ("build4XInfoElementVersion0: build IE version 1\n"));
  307. fourXInfoElemnt->hdr.eleId = TI_4X_IE_ID;
  308. capPtr = (UINT8 *)fourXInfoElemnt->fourXCapabilities;
  309. os_memoryCopy(pFourX->hOs, capPtr, ti_oui, DOT11_OUI_LEN);
  310. capPtr += DOT11_OUI_LEN ;
  311. len += DOT11_OUI_LEN ;
  312. *capPtr = FOUR_X_PROTOCOL_VERSION_1;
  313. capPtr += 1;
  314. len += 1;
  315. if(pFourX->desiredConcatenationEnable == TRUE)
  316. {
  317. *((UINT16*)capPtr) = FOUR_X_CONCAT_CAP_ID;
  318. capPtr += 2;
  319. len += 2;
  320. *((UINT16*)capPtr) = FOUR_X_CONCAT_CAP_LEN;
  321. capPtr += 2;
  322. len += 2;
  323. *((UINT16*)capPtr) = 4095;
  324. capPtr += 2;
  325. len += 2;
  326. }
  327. fourXInfoElemnt->hdr.eleLen = len;
  328. return OK;
  329. }
  330. static void fourXManager_resetAll4xCapabilities(fourX_t* pFourX)
  331. {
  332. pFourX->concatenationEnable = FALSE;
  333. pFourX->CWMinEnable = FALSE;
  334. pFourX->CWComboEnable = FALSE;
  335. pFourX->ackEmulationEnable = FALSE;
  336. pFourX->ERP_ProtectionEnable = FALSE;
  337. }
  338. static void fourXManager_resetAll_AP_4xCapabilities(fourX_t* pFourX)
  339. {
  340. os_memoryZero(pFourX->hOs, &pFourX->ApFourX_Capabilities, (sizeof(fourX_Capabilities_t)));
  341. }
  342. static void setDefault4xCapabilities(fourX_Capabilities_t* pFourX_Capabilities)
  343. {
  344. /* Concatenation */
  345. pFourX_Capabilities->concatenationParams.enableDisable = TRUE;
  346. pFourX_Capabilities->concatenationParams.concatenationSize = MAX_CONCAT_SIZE_DEF;
  347. /* CW min */
  348. pFourX_Capabilities->contentionWindowParams.enableDisable = TRUE;
  349. pFourX_Capabilities->contentionWindowParams.CWMax = DEF_CW_MAX;
  350. pFourX_Capabilities->contentionWindowParams.CWMin = DEF_CW_MIN;
  351. /* CW combo */
  352. pFourX_Capabilities->CWCombParams.enableDisable = FALSE;
  353. pFourX_Capabilities->CWCombParams.CWMin = DEF_CW_COMBO_CW_MIN;
  354. pFourX_Capabilities->CWCombParams.DIFS = DEF_CW_COMBO_DIFS;
  355. pFourX_Capabilities->CWCombParams.SLOT = DEF_CW_COMBO_SLOT;
  356. /* Ack Emulation */
  357. pFourX_Capabilities->ackEmulationParams.enableDisable = TRUE;
  358. /* ERP protection */
  359. pFourX_Capabilities->ERP_ProtectionParams.enableDisable = FALSE;
  360. }