PageRenderTime 71ms CodeModel.GetById 28ms RepoModel.GetById 0ms app.codeStats 0ms

/drivers/net/wireless/tiwlan1251/common/src/core/data_ctrl/Ctrl/RateAdaptation.c

https://bitbucket.org/cyanogenmod/cm-kernel
C | 1231 lines | 753 code | 200 blank | 278 comment | 155 complexity | bac9416843c3c8ecd4eaa500497c54bb MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.0, AGPL-1.0
  1. /****************************************************************************
  2. **+-----------------------------------------------------------------------+**
  3. **| |**
  4. **| Copyright(c) 1998 - 2008 Texas Instruments. All rights reserved. |**
  5. **| All rights reserved. |**
  6. **| |**
  7. **| Redistribution and use in source and binary forms, with or without |**
  8. **| modification, are permitted provided that the following conditions |**
  9. **| are met: |**
  10. **| |**
  11. **| * Redistributions of source code must retain the above copyright |**
  12. **| notice, this list of conditions and the following disclaimer. |**
  13. **| * Redistributions in binary form must reproduce the above copyright |**
  14. **| notice, this list of conditions and the following disclaimer in |**
  15. **| the documentation and/or other materials provided with the |**
  16. **| distribution. |**
  17. **| * Neither the name Texas Instruments nor the names of its |**
  18. **| contributors may be used to endorse or promote products derived |**
  19. **| from this software without specific prior written permission. |**
  20. **| |**
  21. **| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |**
  22. **| "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |**
  23. **| LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |**
  24. **| A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |**
  25. **| OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |**
  26. **| SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |**
  27. **| LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |**
  28. **| DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |**
  29. **| THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |**
  30. **| (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |**
  31. **| OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |**
  32. **| |**
  33. **+-----------------------------------------------------------------------+**
  34. ****************************************************************************/
  35. /**************************************************************************/
  36. /* */
  37. /* MODULE: Rate Adaptation.c */
  38. /* */
  39. /**************************************************************************/
  40. #include "RateAdaptation.h"
  41. #include "DataCtrl_Api.h"
  42. #include "802_11Defs.h"
  43. #include "osApi.h"
  44. #include "report.h"
  45. #include "utils.h"
  46. #include "EvHandler.h"
  47. #include "apConn.h"
  48. static TI_STATUS rateAdaptationa_rateToIndexInRateMapTable(rateAdaptation_t* pRateAdaptation,
  49. rate_e rate, UINT8* Index);
  50. static modulationType_e setModulationForRate(rateAdaptation_t *pRateAdaptation,
  51. rate_e rate,
  52. modulationType_e modulation,
  53. bssType_e bssType);
  54. BOOL rateAdaptation_isRateInTable(ctrlData_rateAdapt_t *currTable,
  55. rate_e rate);
  56. void rateAdaptation_getFallBackStepUp(ctrlData_rateAdapt_t *currTable,
  57. rate_e rate,UINT8* FB,UINT8* SU);
  58. static void rateAdaptation_rxTimeOut(TI_HANDLE hRateAdaptation);
  59. static BOOL set4xEnableForRate(rateAdaptation_t* pRateAdaptation,
  60. rate_e rate,
  61. BOOL enable4x,
  62. bssType_e bssType);
  63. /*************************************************************************
  64. * ctrlData_create
  65. **************************************************************************
  66. * DESCRIPTION: This function create the rateAdaptation module.
  67. *
  68. * INPUT: hOs - handle to Os Abstraction Layer
  69. *
  70. * OUTPUT:
  71. *
  72. * RETURN: Handle to the allocated rateAdaptation block
  73. ************************************************************************/
  74. rateAdaptation_t* rateAdaptation_create(TI_HANDLE hOs)
  75. {
  76. rateAdaptation_t* pRateAdaptation;
  77. void *pTimer;
  78. if( hOs == NULL )
  79. {
  80. WLAN_OS_REPORT(("FATAL ERROR: rateAdaptation_create(): OS handle Error - Aborting\n"));
  81. return NULL;
  82. }
  83. /* alocate RateAdaptation block */
  84. pRateAdaptation = os_memoryAlloc(hOs, (sizeof(rateAdaptation_t)));
  85. if(!pRateAdaptation)
  86. return NULL;
  87. /* alocate Timer to use in PowerSave algorithm */
  88. pTimer = os_timerCreate(hOs, rateAdaptation_rxTimeOut, pRateAdaptation);
  89. if (!pTimer)
  90. {
  91. utils_nullMemoryFree(hOs, pRateAdaptation, sizeof(rateAdaptation_t));
  92. WLAN_OS_REPORT(("FATAL ERROR: rateAdaptation_create(): Error Creating rateAdaptation Module - Aborting\n"));
  93. return NULL;
  94. }
  95. /* reset RateAdaptation module block */
  96. os_memoryZero(hOs, pRateAdaptation, (sizeof(rateAdaptation_t)));
  97. pRateAdaptation->pTimer = pTimer;
  98. pRateAdaptation->hOs = hOs;
  99. return(pRateAdaptation);
  100. }
  101. /***************************************************************************
  102. * rateAdaptation_config
  103. ****************************************************************************
  104. * DESCRIPTION: This function initialize the Rate Adaptation algorithm
  105. *
  106. * INPUTS: pRateAdaptation - the object
  107. * hOs - Handle to the Os Abstraction Layer
  108. * hReport - Handle to the Report object
  109. * rateAdaptationInitParam - pointer to Rate Adaptation
  110. * module init parameters
  111. *
  112. * OUTPUT:
  113. *
  114. * RETURNS: void
  115. ***************************************************************************/
  116. TI_STATUS rateAdaptation_config(rateAdaptation_t* pRateAdaptation,
  117. TI_HANDLE hOs,
  118. TI_HANDLE hReport,
  119. TI_HANDLE hCtrlData,
  120. TI_HANDLE hEvHandler,
  121. TI_HANDLE hAPConnection,
  122. rateAdaptationInitParam_t* rateAdaptationInitParam)
  123. {
  124. UINT32 i;
  125. if( (pRateAdaptation == NULL) || (hOs == NULL) ||
  126. (hReport == NULL) || (rateAdaptationInitParam == NULL) )
  127. {
  128. WLAN_OS_REPORT(("FATAL ERROR: rateAdaptation_config(): Parameters Error - Aborting\n"));
  129. return NOK;
  130. }
  131. pRateAdaptation->hOs = hOs;
  132. pRateAdaptation->hReport = hReport;
  133. pRateAdaptation->hCtrlData = hCtrlData;
  134. pRateAdaptation->hEvHandler = hEvHandler;
  135. pRateAdaptation->hAPConnection = hAPConnection;
  136. pRateAdaptation->contTxPacketsThreshold = rateAdaptationInitParam->contTxPacketsThreshold;
  137. pRateAdaptation->stepUpTxPacketsThreshold = rateAdaptationInitParam->stepUpTxPacketsThreshold;
  138. pRateAdaptation->ctrlDataFBShortInterval = rateAdaptationInitParam->ctrlDataFBShortInterval;
  139. pRateAdaptation->ctrlDataFBLongInterval = rateAdaptationInitParam->ctrlDataFBLongInterval;
  140. pRateAdaptation->lowRateThreshold = DEF_LOW_RATE_THRESHOLD;
  141. pRateAdaptation->rateAdapt_timeout = 1000*rateAdaptationInitParam->rateAdapt_timeout;
  142. pRateAdaptation->txCount = 0;
  143. pRateAdaptation->txSkipCount = 0;
  144. pRateAdaptation->txFailCount = 0;
  145. pRateAdaptation->txRateFallBackCount = 0;
  146. pRateAdaptation->stepUpFlag = FALSE;
  147. /* resset Tspecs Rate Parameters */
  148. for(i = 0 ; i < MAX_NUM_OF_AC ; i++)
  149. {
  150. pRateAdaptation->tspecsRateParameters[i].enableEvent = FALSE;
  151. if(rateAdaptationInitParam->tspecsRateParameters[i].highRateThreshold < rateAdaptationInitParam->tspecsRateParameters[i].lowRateThreshold)
  152. {
  153. WLAN_REPORT_ERROR(pRateAdaptation->hReport, RATE_ADAPTATION_MODULE_LOG,
  154. (" rateAdaptation_config() ERROR: highRateThreshold < lowRateThreshold, ac = %d\n",i));
  155. pRateAdaptation->tspecsRateParameters[i].highRateThreshold = 0;
  156. pRateAdaptation->tspecsRateParameters[i].lowRateThreshold = 0;
  157. }
  158. /* if either one of the threshold is zero all threshold should be with zero default value */
  159. else if( (rateAdaptationInitParam->tspecsRateParameters[i].highRateThreshold == 0) ||
  160. (rateAdaptationInitParam->tspecsRateParameters[i].lowRateThreshold == 0))
  161. {
  162. pRateAdaptation->tspecsRateParameters[i].highRateThreshold = 0;
  163. pRateAdaptation->tspecsRateParameters[i].lowRateThreshold = 0;
  164. }
  165. else
  166. {
  167. pRateAdaptation->tspecsRateParameters[i].highRateThreshold = rateAdaptationInitParam->tspecsRateParameters[i].highRateThreshold;
  168. pRateAdaptation->tspecsRateParameters[i].lowRateThreshold = rateAdaptationInitParam->tspecsRateParameters[i].lowRateThreshold;
  169. }
  170. }
  171. WLAN_REPORT_INFORMATION(pRateAdaptation->hReport, RATE_ADAPTATION_MODULE_LOG,
  172. (" Rate Adaptation initialize success\n"));
  173. return OK;
  174. }
  175. /***************************************************************************
  176. * rateAdaptation_destroy
  177. ****************************************************************************
  178. * DESCRIPTION: This function destroy the rateAdaptation object.
  179. *
  180. * INPUTS: rateAdaptation - the object
  181. *
  182. * RETURNS: OK - Unload succesfull
  183. * NOK - Unload unsuccesfull
  184. ***************************************************************************/
  185. TI_STATUS rateAdaptation_destroy(rateAdaptation_t* pRateAdaptation)
  186. {
  187. /* check parameters validity */
  188. if( pRateAdaptation == NULL )
  189. {
  190. WLAN_REPORT_ERROR(pRateAdaptation->hReport, RATE_ADAPTATION_MODULE_LOG,
  191. (" rateAdaptation_destroy() : parametrs value error \n"));
  192. return NOK;
  193. }
  194. /* free timer */
  195. os_timerStop(pRateAdaptation->hOs, pRateAdaptation->pTimer);
  196. utils_nullTimerDestroy(pRateAdaptation->hOs, pRateAdaptation->pTimer);
  197. /* free rateAdaptation block */
  198. os_memoryFree(pRateAdaptation->hOs, pRateAdaptation, sizeof(rateAdaptation_t));
  199. return OK;
  200. }
  201. /***************************************************************************
  202. * rateAdaptation_rxTimeOut
  203. ****************************************************************************
  204. * DESCRIPTION:
  205. ****************************************************************************/
  206. static void rateAdaptation_rxTimeOut(TI_HANDLE hRateAdaptation)
  207. {
  208. rateAdaptation_t* pRateAdaptation = (rateAdaptation_t *) hRateAdaptation;
  209. UINT8 prevIndex = pRateAdaptation->currRateIndex,i;
  210. OS_802_11_THRESHOLD_CROSS_INDICATION_PARAMS tspecRateCross;
  211. os_timerStop(pRateAdaptation->hOs, pRateAdaptation->pTimer);
  212. os_timerStart(pRateAdaptation->hOs, pRateAdaptation->pTimer,pRateAdaptation->rateAdapt_timeout,FALSE);
  213. pRateAdaptation->txCount = 0;
  214. pRateAdaptation->txSkipCount = 0;
  215. pRateAdaptation->txFailCount = 0;
  216. pRateAdaptation->txRateFallBackCount = 0;
  217. pRateAdaptation->currRateIndex = pRateAdaptation->maxRateIndex;
  218. /* update OS with the current rate */
  219. if(prevIndex != pRateAdaptation->currRateIndex)
  220. {
  221. UINT32 statusData;
  222. paramInfo_t param;
  223. pRateAdaptation->expirTimeTick = os_timeStampMs(pRateAdaptation->hOs) + pRateAdaptation->ctrlDataFBShortInterval;
  224. pRateAdaptation->stepUpFlag = TRUE;
  225. WLAN_REPORT_WARNING(pRateAdaptation->hReport, RATE_ADAPTATION_MODULE_LOG,
  226. (" RateAdapt() : Time: %d, (60sec) OldRate(Index,Rate): %d,%d, NewRate(Index,Rate): %d,%d\n",
  227. os_timeStampMs(pRateAdaptation->hOs),
  228. prevIndex,pRateAdaptation->RatesMap[prevIndex].rateNumber,
  229. pRateAdaptation->currRateIndex, pRateAdaptation->RatesMap[pRateAdaptation->currRateIndex].rateNumber ));
  230. /* update OS with the current rate */
  231. param.paramType = CTRL_DATA_FOUR_X_CURRRENT_STATUS_PARAM;
  232. param.content.ctrlDataCerruentFourXstate = pRateAdaptation->RatesMap[pRateAdaptation->currRateIndex].fourXEnable;
  233. ctrlData_setParam(pRateAdaptation->hCtrlData, &param);
  234. /* update OS with the current rate */
  235. statusData = hostToUtilityRate(pRateAdaptation->RatesMap[pRateAdaptation->currRateIndex].rate);
  236. EvHandlerSendEvent(pRateAdaptation->hEvHandler, IPC_EVENT_LINK_SPEED, (UINT8 *)&statusData,sizeof(UINT32));
  237. /* send Tspecs Rate Event */
  238. for(i = 0 ; i < MAX_NUM_OF_AC ; i++)
  239. {
  240. if(pRateAdaptation->tspecsRateParameters[i].enableEvent == FALSE)
  241. {
  242. continue;
  243. }
  244. else
  245. {
  246. if( ((pRateAdaptation->RatesMap[prevIndex].rateNumber) < (pRateAdaptation->tspecsRateParameters[i].highRateThreshold)) &&
  247. (pRateAdaptation->RatesMap[pRateAdaptation->currRateIndex].rateNumber >= (pRateAdaptation->tspecsRateParameters[i].highRateThreshold)) )
  248. {
  249. tspecRateCross.uAC = i;
  250. tspecRateCross.uHighOrLowThresholdFlag = HIGH_THRESHOLD_CROSS;
  251. tspecRateCross.uAboveOrBelowFlag = CROSS_ABOVE;
  252. EvHandlerSendEvent(pRateAdaptation->hEvHandler, IPC_EVENT_TSPEC_RATE_STATUS, (UINT8 *)&tspecRateCross,sizeof(tspecRateCross));
  253. }
  254. else
  255. if( ((pRateAdaptation->RatesMap[prevIndex].rateNumber) < (pRateAdaptation->tspecsRateParameters[i].lowRateThreshold)) &&
  256. (hostRateToNumber((rate_e)pRateAdaptation->RatesMap[pRateAdaptation->currRateIndex].rateNumber) >= (pRateAdaptation->tspecsRateParameters[i].lowRateThreshold)) )
  257. {
  258. tspecRateCross.uAC = i;
  259. tspecRateCross.uHighOrLowThresholdFlag = LOW_THRESHOLD_CROSS;
  260. tspecRateCross.uAboveOrBelowFlag = CROSS_ABOVE;
  261. EvHandlerSendEvent(pRateAdaptation->hEvHandler, IPC_EVENT_TSPEC_RATE_STATUS, (UINT8 *)&tspecRateCross,sizeof(OS_802_11_THRESHOLD_CROSS_INDICATION_PARAMS));
  262. }
  263. }
  264. }
  265. }
  266. else {
  267. /* no change */
  268. pRateAdaptation->expirTimeTick = os_timeStampMs(pRateAdaptation->hOs) + pRateAdaptation->ctrlDataFBLongInterval;
  269. pRateAdaptation->stepUpFlag = FALSE;
  270. }
  271. }
  272. /***************************************************************************
  273. * rateAdaptation_getCurrent
  274. ****************************************************************************
  275. * DESCRIPTION: get current state - Rate and Modulation
  276. * Note: since a pointer to the rates map is returned,
  277. * Its content should be treated as READ ONLY!!!
  278. ****************************************************************************/
  279. rateModulation4x_table_t* rateAdaptation_getCurrent(rateAdaptation_t* pRateAdaptation)
  280. {
  281. return &(pRateAdaptation->RatesMap[pRateAdaptation->currRateIndex]);
  282. }
  283. /***************************************************************************
  284. * rateAdaptation_getCurrentRate
  285. ****************************************************************************
  286. * DESCRIPTION: get current Rate
  287. ****************************************************************************/
  288. rate_e rateAdaptation_getCurrentRate(rateAdaptation_t* pRateAdaptation)
  289. {
  290. return pRateAdaptation->RatesMap[pRateAdaptation->currRateIndex].rate;
  291. }
  292. /***************************************************************************
  293. * rateAdaptation_getCurrentModulation *
  294. ****************************************************************************
  295. * DESCRIPTION: get current Modulation
  296. ****************************************************************************/
  297. modulationType_e rateAdaptation_getCurrentModulation(rateAdaptation_t* pRateAdaptation)
  298. {
  299. return pRateAdaptation->RatesMap[pRateAdaptation->currRateIndex].modulation;
  300. }
  301. /***************************************************************************
  302. * rateAdaptation_getCurrentFourXEnable *
  303. ****************************************************************************
  304. * DESCRIPTION: get current fourx status
  305. ****************************************************************************/
  306. BOOL rateAdaptation_getCurrentFourXEnable(rateAdaptation_t* pRateAdaptation)
  307. {
  308. return pRateAdaptation->RatesMap[pRateAdaptation->currRateIndex].fourXEnable;
  309. }
  310. /***************************************************************************
  311. * rateAdaptation_buildRateMapTable *
  312. ****************************************************************************
  313. * DESCRIPTION: build the rate map table
  314. ****************************************************************************/
  315. TI_STATUS rateAdaptation_buildRateMapTable(rateAdaptation_t *pRateAdaptation,
  316. ctrlData_rateAdapt_t *currTable,
  317. UINT32 supportedBitMap,
  318. UINT32 clientBitMap,
  319. modulationType_e modulation,
  320. BOOL enable4x,
  321. bssType_e bssType)
  322. {
  323. UINT8 i = 0;
  324. UINT8 index = 0;
  325. UINT32 statusData;
  326. UINT8 fallBack,stepUp;
  327. /*
  328. Note : allRates[] is changed due to the fact that rate_e was set in the
  329. wrong order : 6,9 were in higher numeric value then 5.5 and 11 !!!
  330. */
  331. rate_e allRates[] = {DRV_RATE_1M,
  332. DRV_RATE_2M,
  333. DRV_RATE_5_5M,
  334. DRV_RATE_6M,
  335. DRV_RATE_9M,
  336. DRV_RATE_11M,
  337. DRV_RATE_12M,
  338. DRV_RATE_18M,
  339. DRV_RATE_22M,
  340. DRV_RATE_24M,
  341. DRV_RATE_36M,
  342. DRV_RATE_48M,
  343. DRV_RATE_54M
  344. };
  345. while(i < DRV_RATE_MAX)
  346. {
  347. if(rateAdaptation_Utils_IsRateInBitmap(pRateAdaptation,
  348. supportedBitMap,
  349. allRates[i]) == OK)
  350. {
  351. /* update rates parameters */
  352. pRateAdaptation->RatesMap[index].rate = allRates[i];
  353. pRateAdaptation->RatesMap[index].rateNumber = hostRateToNumber(allRates[i]);
  354. if((rateAdaptation_isRateInTable(currTable,pRateAdaptation->RatesMap[index].rate)) &&
  355. (rateAdaptation_Utils_IsRateInBitmap(pRateAdaptation,
  356. clientBitMap,
  357. allRates[i]) == OK))
  358. {
  359. pRateAdaptation->RatesMap[index].valid = TRUE;
  360. rateAdaptation_getFallBackStepUp(currTable,pRateAdaptation->RatesMap[index].rate,&fallBack,&stepUp);
  361. pRateAdaptation->RatesMap[index].rateAdaptFallBack = fallBack;
  362. pRateAdaptation->RatesMap[index].rateAdaptStepUp = stepUp;
  363. /* update modulation parameter */
  364. pRateAdaptation->RatesMap[index].modulation = setModulationForRate(pRateAdaptation,
  365. pRateAdaptation->RatesMap[index].rate,
  366. modulation,bssType);
  367. /* update 4x enable parameter */
  368. pRateAdaptation->RatesMap[index].fourXEnable = set4xEnableForRate(pRateAdaptation,
  369. pRateAdaptation->RatesMap[index].rate,
  370. enable4x, bssType);
  371. pRateAdaptation->maxRateIndex = index;
  372. pRateAdaptation->currRateIndex = index;
  373. }
  374. else
  375. {
  376. pRateAdaptation->RatesMap[index].valid = FALSE;
  377. pRateAdaptation->RatesMap[index].modulation = setModulationForRate(pRateAdaptation,
  378. pRateAdaptation->RatesMap[index].rate,
  379. modulation,bssType);
  380. }
  381. index++;
  382. }
  383. i++;
  384. }
  385. /* report the current rate to OS */
  386. statusData = hostToUtilityRate(pRateAdaptation->RatesMap[pRateAdaptation->currRateIndex].rate);
  387. EvHandlerSendEvent(pRateAdaptation->hEvHandler, IPC_EVENT_LINK_SPEED, (UINT8 *)&statusData,sizeof(UINT32));
  388. return OK;
  389. }
  390. /***************************************************************************
  391. * buildRateBitMap *
  392. ****************************************************************************
  393. * DESCRIPTION:
  394. ****************************************************************************/
  395. UINT32 rateAdaptation_Utils_buildRateBitMap(rateAdaptation_t *pRateAdaptation,
  396. ctrlData_rateAdapt_t *currTable,
  397. rate_e rate,
  398. UINT32 supportedBitMap,
  399. UINT32 clientBitMap)
  400. {
  401. UINT32 buildRateBitMap = 0;
  402. UINT8 rateNumber = hostRateToNumber(rate);
  403. if( (rateNumber >= hostRateToNumber(DRV_RATE_1M)) && (rateAdaptation_isRateInTable(currTable, DRV_RATE_1M) ) ) buildRateBitMap |= (clientBitMap & supportedBitMap & DRV_RATE_MASK_1_BARKER);
  404. if( (rateNumber >= hostRateToNumber(DRV_RATE_2M)) && (rateAdaptation_isRateInTable(currTable, DRV_RATE_2M) ) ) buildRateBitMap |= (clientBitMap & supportedBitMap & DRV_RATE_MASK_2_BARKER);
  405. if( (rateNumber >= hostRateToNumber(DRV_RATE_5_5M)) && (rateAdaptation_isRateInTable(currTable, DRV_RATE_5_5M) ) ) buildRateBitMap |= (clientBitMap & supportedBitMap & DRV_RATE_MASK_5_5_CCK);
  406. if( (rateNumber >= hostRateToNumber(DRV_RATE_11M)) && (rateAdaptation_isRateInTable(currTable, DRV_RATE_11M) ) ) buildRateBitMap |= (clientBitMap & supportedBitMap & DRV_RATE_MASK_11_CCK);
  407. if( (rateNumber >= hostRateToNumber(DRV_RATE_22M)) && (rateAdaptation_isRateInTable(currTable, DRV_RATE_22M) ) ) buildRateBitMap |= (clientBitMap & supportedBitMap & DRV_RATE_MASK_22_PBCC);
  408. if( (rateNumber >= hostRateToNumber(DRV_RATE_6M)) && (rateAdaptation_isRateInTable(currTable, DRV_RATE_6M) ) ) buildRateBitMap |= (clientBitMap & supportedBitMap & DRV_RATE_MASK_6_OFDM);
  409. if( (rateNumber >= hostRateToNumber(DRV_RATE_9M)) && (rateAdaptation_isRateInTable(currTable, DRV_RATE_9M) ) ) buildRateBitMap |= (clientBitMap & supportedBitMap & DRV_RATE_MASK_9_OFDM);
  410. if( (rateNumber >= hostRateToNumber(DRV_RATE_12M)) && (rateAdaptation_isRateInTable(currTable, DRV_RATE_12M) ) ) buildRateBitMap |= (clientBitMap & supportedBitMap & DRV_RATE_MASK_12_OFDM);
  411. if( (rateNumber >= hostRateToNumber(DRV_RATE_18M)) && (rateAdaptation_isRateInTable(currTable, DRV_RATE_18M) ) ) buildRateBitMap |= (clientBitMap & supportedBitMap & DRV_RATE_MASK_18_OFDM);
  412. if( (rateNumber >= hostRateToNumber(DRV_RATE_24M)) && (rateAdaptation_isRateInTable(currTable, DRV_RATE_24M) ) ) buildRateBitMap |= (clientBitMap & supportedBitMap & DRV_RATE_MASK_24_OFDM);
  413. if( (rateNumber >= hostRateToNumber(DRV_RATE_36M)) && (rateAdaptation_isRateInTable(currTable, DRV_RATE_36M) ) ) buildRateBitMap |= (clientBitMap & supportedBitMap & DRV_RATE_MASK_36_OFDM);
  414. if( (rateNumber >= hostRateToNumber(DRV_RATE_48M)) && (rateAdaptation_isRateInTable(currTable, DRV_RATE_48M) ) ) buildRateBitMap |= (clientBitMap & supportedBitMap & DRV_RATE_MASK_48_OFDM);
  415. if( (rateNumber >= hostRateToNumber(DRV_RATE_54M)) && (rateAdaptation_isRateInTable(currTable, DRV_RATE_54M) ) ) buildRateBitMap |= (clientBitMap & supportedBitMap & DRV_RATE_MASK_54_OFDM);
  416. return buildRateBitMap;
  417. }
  418. /***************************************************************************
  419. * rateAdaptation_isRateInTable *
  420. ****************************************************************************
  421. * DESCRIPTION: check if a specific rate is in a rates table
  422. ****************************************************************************/
  423. BOOL rateAdaptation_isRateInTable(ctrlData_rateAdapt_t *currTable,
  424. rate_e rate)
  425. {
  426. UINT8 i = 0;
  427. while(i <= currTable->len)
  428. {
  429. if(currTable->rateAdaptRatesTable[i++] == rate)
  430. return TRUE;
  431. }
  432. return FALSE;
  433. }
  434. /***************************************************************************
  435. * rateAdaptation_getFallBackStepUp *
  436. ****************************************************************************
  437. * DESCRIPTION: return Fall Back & Step UP values of a certain rate
  438. ****************************************************************************/
  439. void rateAdaptation_getFallBackStepUp(ctrlData_rateAdapt_t *currTable,
  440. rate_e rate,UINT8* FB,UINT8* SU)
  441. {
  442. UINT8 i = 0;
  443. while(i <= currTable->len)
  444. {
  445. if(currTable->rateAdaptRatesTable[i++] == rate)
  446. {
  447. *FB = currTable->rateAdaptFBTable[--i];
  448. *SU = currTable->rateAdaptSUTable[i];
  449. return;
  450. }
  451. }
  452. *FB = 0;
  453. *SU = 0;
  454. }
  455. /***************************************************************************
  456. * IsRateInBitmap *
  457. ****************************************************************************
  458. * DESCRIPTION: check if a specific rate is in a rates bitmap
  459. ****************************************************************************/
  460. TI_STATUS rateAdaptation_Utils_IsRateInBitmap(rateAdaptation_t *pRateAdaptation,
  461. UINT32 ratesBitMap,
  462. rate_e rate)
  463. {
  464. if( ( (rate == DRV_RATE_1M) && (ratesBitMap & DRV_RATE_MASK_1_BARKER) )||
  465. ( (rate == DRV_RATE_2M) && (ratesBitMap & DRV_RATE_MASK_2_BARKER) ) ||
  466. ( (rate == DRV_RATE_5_5M) && (ratesBitMap & DRV_RATE_MASK_5_5_CCK) ) ||
  467. ( (rate == DRV_RATE_11M) && (ratesBitMap & DRV_RATE_MASK_11_CCK) ) ||
  468. ( (rate == DRV_RATE_22M) && (ratesBitMap & DRV_RATE_MASK_22_PBCC) ) ||
  469. ( (rate == DRV_RATE_6M) && (ratesBitMap & DRV_RATE_MASK_6_OFDM) ) ||
  470. ( (rate == DRV_RATE_9M) && (ratesBitMap & DRV_RATE_MASK_9_OFDM) ) ||
  471. ( (rate == DRV_RATE_12M) && (ratesBitMap & DRV_RATE_MASK_12_OFDM) ) ||
  472. ( (rate == DRV_RATE_18M) && (ratesBitMap & DRV_RATE_MASK_18_OFDM) ) ||
  473. ( (rate == DRV_RATE_24M) && (ratesBitMap & DRV_RATE_MASK_24_OFDM) ) ||
  474. ( (rate == DRV_RATE_36M) && (ratesBitMap & DRV_RATE_MASK_36_OFDM) ) ||
  475. ( (rate == DRV_RATE_48M) && (ratesBitMap & DRV_RATE_MASK_48_OFDM) ) ||
  476. ( (rate == DRV_RATE_54M) && (ratesBitMap & DRV_RATE_MASK_54_OFDM) ) )
  477. {
  478. return OK;
  479. }
  480. return NOK;
  481. }
  482. /***************************************************************************
  483. * setModulationForRate *
  484. ****************************************************************************
  485. * DESCRIPTION: set modulation for the rate map table
  486. ****************************************************************************/
  487. static modulationType_e setModulationForRate(rateAdaptation_t *pRateAdaptation,
  488. rate_e rate,
  489. modulationType_e modulation,
  490. bssType_e bssType)
  491. {
  492. switch(rate)
  493. {
  494. case DRV_RATE_1M:
  495. return DRV_MODULATION_QPSK;
  496. case DRV_RATE_2M:
  497. return DRV_MODULATION_QPSK;
  498. case DRV_RATE_5_5M:
  499. if( (modulation == DRV_MODULATION_PBCC) &&
  500. (bssType == BSS_INFRASTRUCTURE) )
  501. return DRV_MODULATION_PBCC;
  502. else
  503. return DRV_MODULATION_CCK;
  504. case DRV_RATE_11M:
  505. if( (modulation == DRV_MODULATION_PBCC) &&
  506. (bssType == BSS_INFRASTRUCTURE) )
  507. return DRV_MODULATION_PBCC;
  508. else
  509. return DRV_MODULATION_CCK;
  510. case DRV_RATE_22M:
  511. return DRV_MODULATION_PBCC;
  512. case DRV_RATE_6M:
  513. return DRV_MODULATION_OFDM;
  514. case DRV_RATE_9M:
  515. return DRV_MODULATION_OFDM;
  516. case DRV_RATE_18M:
  517. return DRV_MODULATION_OFDM;
  518. case DRV_RATE_12M:
  519. return DRV_MODULATION_OFDM;
  520. case DRV_RATE_24M:
  521. return DRV_MODULATION_OFDM;
  522. case DRV_RATE_36M:
  523. return DRV_MODULATION_OFDM;
  524. case DRV_RATE_48M:
  525. return DRV_MODULATION_OFDM;
  526. case DRV_RATE_54M:
  527. return DRV_MODULATION_OFDM;
  528. default:
  529. WLAN_REPORT_ERROR(pRateAdaptation->hReport, RATE_ADAPTATION_MODULE_LOG,
  530. (" setModulationForRate(): unKnown rate !!! \n"));
  531. return DRV_MODULATION_NONE;
  532. }
  533. }
  534. static BOOL set4xEnableForRate(rateAdaptation_t* pRateAdaptation,
  535. rate_e rate,
  536. BOOL enable4x,
  537. bssType_e bssType)
  538. {
  539. if(bssType == BSS_INDEPENDENT)
  540. return FALSE;
  541. switch(rate)
  542. {
  543. case DRV_RATE_1M:
  544. return FALSE;
  545. case DRV_RATE_2M:
  546. return FALSE;
  547. case DRV_RATE_5_5M:
  548. return FALSE;
  549. case DRV_RATE_11M:
  550. return enable4x;
  551. case DRV_RATE_22M:
  552. return enable4x;
  553. case DRV_RATE_6M:
  554. return FALSE;
  555. case DRV_RATE_9M:
  556. return FALSE;
  557. case DRV_RATE_18M:
  558. return enable4x;
  559. case DRV_RATE_12M:
  560. return enable4x;
  561. case DRV_RATE_24M:
  562. return enable4x;
  563. case DRV_RATE_36M:
  564. return enable4x;
  565. case DRV_RATE_48M:
  566. return enable4x;
  567. case DRV_RATE_54M:
  568. return enable4x;
  569. default:
  570. WLAN_REPORT_ERROR(pRateAdaptation->hReport, RATE_ADAPTATION_MODULE_LOG,
  571. (" set4xEnableForRate(): unKnown rate !!! \n"));
  572. return DRV_MODULATION_NONE;
  573. }
  574. }
  575. /***************************************************************************
  576. * rateAdaptation_setMaxActivRate
  577. ****************************************************************************
  578. * DESCRIPTION: set current rate
  579. ****************************************************************************/
  580. TI_STATUS rateAdaptation_setMaxActivRate(rateAdaptation_t* pRateAdaptation, rate_e rate)
  581. {
  582. UINT8 index;
  583. UINT32 status;
  584. status = rateAdaptationa_rateToIndexInRateMapTable(pRateAdaptation, rate, &index);
  585. if(status != OK)
  586. return NOK;
  587. pRateAdaptation->maxRateIndex = index;
  588. return OK;
  589. }
  590. /***************************************************************************
  591. * rateAdaptation_configLowRateThrsh
  592. ****************************************************************************
  593. * DESCRIPTION: set low rate threshold
  594. ****************************************************************************/
  595. TI_STATUS rateAdaptation_configLowRateThrsh(rateAdaptation_t *pRateAdaptation, UINT8 rate)
  596. {
  597. pRateAdaptation->lowRateThreshold = rate;
  598. WLAN_REPORT_INFORMATION(pRateAdaptation->hReport, RATE_ADAPTATION_MODULE_LOG,
  599. (" \nrateAdaptation_configLowRateThrsh:rate %d, translated to %d \n", rate, pRateAdaptation->lowRateThreshold));
  600. return OK;
  601. }
  602. /***************************************************************************
  603. * rateAdaptation_updateModulation
  604. ****************************************************************************
  605. * DESCRIPTION: set current rate
  606. ****************************************************************************/
  607. void rateAdaptation_updateModulation(rateAdaptation_t* pRateAdaptation,
  608. modulationType_e modulation,
  609. bssType_e bssType)
  610. {
  611. UINT8 index = 0;
  612. for(index = 0 ; index < pRateAdaptation->maxRateIndex ; index++)
  613. {
  614. pRateAdaptation->RatesMap[index].modulation = setModulationForRate(pRateAdaptation,
  615. pRateAdaptation->RatesMap[index].rate,
  616. modulation,
  617. bssType);
  618. }
  619. }
  620. /***************************************************************************
  621. * rateAdaptation_updateModulation
  622. ****************************************************************************
  623. * DESCRIPTION: set current rate
  624. ****************************************************************************/
  625. void rateAdaptation_update4xEnable(rateAdaptation_t* pRateAdaptation,
  626. BOOL enable4x,
  627. bssType_e bssType)
  628. {
  629. UINT8 index = 0;
  630. for(index = 0 ; index < pRateAdaptation->maxRateIndex ; index++)
  631. {
  632. pRateAdaptation->RatesMap[index].fourXEnable = set4xEnableForRate(pRateAdaptation,
  633. pRateAdaptation->RatesMap[index].rate,
  634. enable4x, bssType);
  635. }
  636. }
  637. /***************************************************************************
  638. * ctrlData_rateAdaptationStart
  639. ****************************************************************************
  640. * DESCRIPTION: This function start the Rate Adaptation algorithm
  641. ***************************************************************************/
  642. TI_STATUS rateAdaptation_start(rateAdaptation_t* pRateAdaptation)
  643. {
  644. UINT32 statusData;
  645. pRateAdaptation->txCount = 0;
  646. pRateAdaptation->txSkipCount = 0;
  647. pRateAdaptation->txFailCount = 0;
  648. pRateAdaptation->txRateFallBackCount = 0;
  649. pRateAdaptation->stepUpFlag = FALSE;
  650. os_timerStart(pRateAdaptation->hOs, pRateAdaptation->pTimer,pRateAdaptation->rateAdapt_timeout,FALSE);
  651. pRateAdaptation->expirTimeTick = os_timeStampMs(pRateAdaptation->hOs) + pRateAdaptation->ctrlDataFBLongInterval;
  652. /* update OS with the current rate */
  653. statusData = hostToUtilityRate(pRateAdaptation->RatesMap[pRateAdaptation->currRateIndex].rate);
  654. EvHandlerSendEvent(pRateAdaptation->hEvHandler, IPC_EVENT_LINK_SPEED, (UINT8 *)&statusData,sizeof(UINT32));
  655. return OK;
  656. }
  657. /***************************************************************************
  658. * ctrlData_rateAdaptationStop
  659. ****************************************************************************
  660. * DESCRIPTION: This function stop the rate adaptation algorithm
  661. ***************************************************************************/
  662. TI_STATUS rateAdaptation_stop(rateAdaptation_t* pRateAdaptation)
  663. {
  664. os_timerStop(pRateAdaptation->hOs, pRateAdaptation->pTimer);
  665. pRateAdaptation->txCount = 0;
  666. pRateAdaptation->txSkipCount = 0;
  667. pRateAdaptation->txFailCount = 0;
  668. pRateAdaptation->txRateFallBackCount = 0;
  669. pRateAdaptation->stepUpFlag = FALSE;
  670. pRateAdaptation->expirTimeTick = 0;
  671. pRateAdaptation->currRateIndex = pRateAdaptation->maxRateIndex;
  672. return OK;
  673. }
  674. /***************************************************************************
  675. * rateAdaptation_stopTimer
  676. ****************************************************************************
  677. * DESCRIPTION: This function stop the rate adaptation timer
  678. ***************************************************************************/
  679. TI_STATUS rateAdaptation_stopTimer(rateAdaptation_t* pRateAdaptation)
  680. {
  681. os_timerStop(pRateAdaptation->hOs, pRateAdaptation->pTimer);
  682. return OK;
  683. }
  684. /***************************************************************************
  685. * rateAdaptation_setCurrentRate
  686. ****************************************************************************
  687. * DESCRIPTION: set current rate
  688. ****************************************************************************/
  689. TI_STATUS rateAdaptation_setCurrentRate(rateAdaptation_t* pRateAdaptation,rate_e rate)
  690. {
  691. UINT8 index;
  692. UINT32 statusData;
  693. if(rateAdaptationa_rateToIndexInRateMapTable(pRateAdaptation, rate, &index) == OK)
  694. pRateAdaptation->currRateIndex = index;
  695. else
  696. pRateAdaptation->currRateIndex = pRateAdaptation->maxRateIndex;
  697. /* report the current rate to OS */
  698. statusData = hostToUtilityRate(pRateAdaptation->RatesMap[pRateAdaptation->currRateIndex].rate);
  699. EvHandlerSendEvent(pRateAdaptation->hEvHandler, IPC_EVENT_LINK_SPEED, (UINT8 *)&statusData,sizeof(UINT32));
  700. return OK;
  701. }
  702. /***************************************************************************
  703. * ctrlData_rateToIndexInRateMapTable
  704. ****************************************************************************
  705. * DESCRIPTION: This function convert a specific rate to index in the
  706. * Rate Adaptation algorithm ratemap table
  707. *
  708. * INPUTS: pRateAdaptation - the object
  709. * rate - the rate to convert
  710. *
  711. * OUTPUT: Index - the index of the rate in the table.
  712. *
  713. * RETURNS: If the rate is not in the table - return NOK otherwise OK
  714. ***************************************************************************/
  715. static TI_STATUS rateAdaptationa_rateToIndexInRateMapTable(rateAdaptation_t* pRateAdaptation,
  716. rate_e rate, UINT8* Index)
  717. {
  718. UINT8 i;
  719. for(i = 0 ; i <= pRateAdaptation->maxRateIndex ; i++)
  720. {
  721. if(pRateAdaptation->RatesMap[i].rate == rate)
  722. {
  723. *Index = i;
  724. return OK;
  725. }
  726. }
  727. return NOK;
  728. }
  729. /***************************************************************************
  730. * getPrevRate
  731. ****************************************************************************
  732. * DESCRIPTION:
  733. *
  734. * INPUTS: pRateAdaptation - the object
  735. *
  736. * RETURNS: new rate
  737. ****************************************************************************/
  738. UINT8 getPrevRate(rateAdaptation_t *pRateAdaptation)
  739. {
  740. INT16 i;
  741. if(pRateAdaptation->currRateIndex != 0)
  742. {
  743. for(i = pRateAdaptation->currRateIndex - 1; i > 0; i--)
  744. {
  745. if(pRateAdaptation->RatesMap[i].valid)
  746. return (UINT8)i;
  747. }
  748. }
  749. return pRateAdaptation->currRateIndex;
  750. }
  751. /***************************************************************************
  752. * getNextRate
  753. ****************************************************************************
  754. * DESCRIPTION:
  755. *
  756. * INPUTS: pRateAdaptation - the object
  757. *
  758. * RETURNS: new rate
  759. ****************************************************************************/
  760. UINT8 getNextRate(rateAdaptation_t *pRateAdaptation)
  761. {
  762. UINT32 i;
  763. for(i = pRateAdaptation->currRateIndex + 1; i <= pRateAdaptation->maxRateIndex; i++)
  764. {
  765. if(pRateAdaptation->RatesMap[i].valid)
  766. return i;
  767. }
  768. return pRateAdaptation->currRateIndex;
  769. }
  770. /***************************************************************************
  771. * rateAdaptation_updateRateAdaptation
  772. ****************************************************************************
  773. * DESCRIPTION: This function perform the Rate Adaptation algorithm. It
  774. * called for every tx complete.
  775. *
  776. * INPUTS: pRateAdaptation - the object
  777. * actualTxRate - the actual tx rate
  778. * requestTxRate - the request tx rate
  779. * TxStatus - the tx status
  780. * txNumWaiting - the number of descriptors in the HW with previous rate
  781. *
  782. * RETURNS: OK/NOK
  783. ****************************************************************************/
  784. TI_STATUS rateAdaptation_updateRateAdaptation(rateAdaptation_t* pRateAdaptation,
  785. rate_e actualTxRate,
  786. rate_e requestTxRate,
  787. UINT32 TxStatus,
  788. int txNumWaiting)
  789. {
  790. UINT32 txFailPercent;
  791. UINT32 timeStamp;
  792. UINT8 actualTxRateNumber = hostRateToNumber(actualTxRate);
  793. UINT8 requestTxRateNumber = hostRateToNumber(requestTxRate);
  794. OS_802_11_THRESHOLD_CROSS_INDICATION_PARAMS tspecRateCross;
  795. UINT8 i,prevIndex = pRateAdaptation->currRateIndex;
  796. /* Check if need to skip some packets due to rate update */
  797. if (pRateAdaptation->txSkipCount > 0) {
  798. pRateAdaptation->txSkipCount--;
  799. return OK;
  800. }
  801. timeStamp = os_timeStampMs(pRateAdaptation->hOs);
  802. pRateAdaptation->txCount++;
  803. /* if the TxStatus wasn't SUCCESS or the rate was falling back - we will update the mechanism, unless */
  804. /* the TxStatus is LIFETIME_EXCEEDED and there were no retries - we won't update the mechanism */
  805. if(((TxStatus != SEND_COMPLETE_SUCCESS) && (TxStatus != SEND_COMPLETE_LIFETIME_EXCEEDED))
  806. || (actualTxRateNumber < requestTxRateNumber))
  807. {
  808. pRateAdaptation->txFailCount++;
  809. if (actualTxRateNumber < requestTxRateNumber)
  810. pRateAdaptation->txRateFallBackCount++;
  811. }
  812. /* Verify if the checking time has come. */
  813. if( TS_EXCEEDS(timeStamp, pRateAdaptation->expirTimeTick) )
  814. {
  815. /* If step up has just done wait for 10 packets only. */
  816. if((pRateAdaptation->stepUpFlag == TRUE) &&
  817. (pRateAdaptation->txCount > pRateAdaptation->stepUpTxPacketsThreshold ))
  818. {
  819. /* Calculate the packet fail percent. */
  820. txFailPercent = (pRateAdaptation->txFailCount * 100) / pRateAdaptation->txCount;
  821. pRateAdaptation->stepUpFlag = FALSE; /* Flag is off for next time. */
  822. if( (txFailPercent > pRateAdaptation->RatesMap[pRateAdaptation->currRateIndex].rateAdaptFallBack) &&
  823. (pRateAdaptation->currRateIndex > 0) )
  824. {
  825. pRateAdaptation->currRateIndex = getPrevRate(pRateAdaptation);
  826. }
  827. }
  828. else if (pRateAdaptation->txCount > pRateAdaptation->contTxPacketsThreshold )
  829. {
  830. /* Calculate the packet fail percents. */
  831. txFailPercent = (pRateAdaptation->txFailCount * 100) / pRateAdaptation->txCount;
  832. if ( (txFailPercent > pRateAdaptation->RatesMap[pRateAdaptation->currRateIndex].rateAdaptFallBack) &&
  833. (pRateAdaptation->currRateIndex > 0) )
  834. {
  835. pRateAdaptation->currRateIndex = getPrevRate(pRateAdaptation);
  836. }
  837. else if ((txFailPercent < pRateAdaptation->RatesMap[pRateAdaptation->currRateIndex].rateAdaptStepUp) &&
  838. (pRateAdaptation->currRateIndex < pRateAdaptation->maxRateIndex))
  839. {
  840. pRateAdaptation->currRateIndex = getNextRate(pRateAdaptation);
  841. pRateAdaptation->stepUpFlag = TRUE; /* Flag is on for next time. */
  842. }
  843. }
  844. else
  845. {
  846. return OK;
  847. }
  848. /* update OS with the current rate */
  849. if(prevIndex != pRateAdaptation->currRateIndex)
  850. {
  851. UINT32 statusData;
  852. paramInfo_t param;
  853. rate_e currentRate = pRateAdaptation->RatesMap[pRateAdaptation->currRateIndex].rate;
  854. UINT8 currentRateNumber = pRateAdaptation->RatesMap[pRateAdaptation->currRateIndex].rateNumber;
  855. WLAN_REPORT_WARNING(pRateAdaptation->hReport, RATE_ADAPTATION_MODULE_LOG,
  856. (" RateAdapt() : Time: %d, Fail: %d, Count: %d,Skip: %d\n",
  857. timeStamp,pRateAdaptation->txFailCount,pRateAdaptation->txCount,txNumWaiting));
  858. WLAN_REPORT_WARNING(pRateAdaptation->hReport, RATE_ADAPTATION_MODULE_LOG,
  859. (" OldRate(Index,Rate): %d,%d\n ",prevIndex,pRateAdaptation->RatesMap[prevIndex].rateNumber));
  860. WLAN_REPORT_WARNING(pRateAdaptation->hReport, RATE_ADAPTATION_MODULE_LOG,
  861. (" NewRate(Index,Rate): %d,%d\n ",pRateAdaptation->currRateIndex,currentRateNumber));
  862. /* If the current rate is lower or equal to the roaming threshold, issue roaming trigger. */
  863. if (currentRateNumber <= pRateAdaptation->lowRateThreshold)
  864. {
  865. roamingEventData_u RoamingEventData;
  866. RoamingEventData.rate = currentRate;
  867. apConn_reportRoamingEvent(pRateAdaptation->hAPConnection, ROAMING_TRIGGER_LOW_TX_RATE, &RoamingEventData);
  868. }
  869. /* Rate update - initialize the skip counter for packets that are already in the queue with old rates */
  870. if ((txNumWaiting >= 0) && (txNumWaiting <= 100)) {
  871. /* In reasonable range */
  872. pRateAdaptation->txSkipCount = (UINT32)txNumWaiting;
  873. } else {
  874. pRateAdaptation->txSkipCount = 30; /* something happened, at least skip 30 packets */
  875. }
  876. /* update OS with the current rate */
  877. param.paramType = CTRL_DATA_FOUR_X_CURRRENT_STATUS_PARAM;
  878. param.content.ctrlDataCerruentFourXstate = pRateAdaptation->RatesMap[pRateAdaptation->currRateIndex].fourXEnable;
  879. ctrlData_setParam(pRateAdaptation->hCtrlData, &param);
  880. /* update OS with the current rate */
  881. statusData = hostToUtilityRate(currentRate);
  882. EvHandlerSendEvent(pRateAdaptation->hEvHandler, IPC_EVENT_LINK_SPEED, (UINT8 *)&statusData,sizeof(UINT32));
  883. /* send Tspecs Rate Event */
  884. for(i = 0 ; i < MAX_NUM_OF_AC ; i++)
  885. {
  886. if(pRateAdaptation->tspecsRateParameters[i].enableEvent == FALSE)
  887. {
  888. continue;
  889. }
  890. else
  891. {
  892. if ( (pRateAdaptation->RatesMap[prevIndex].rateNumber < pRateAdaptation->tspecsRateParameters[i].highRateThreshold) &&
  893. (currentRateNumber >= pRateAdaptation->tspecsRateParameters[i].highRateThreshold) )
  894. {
  895. tspecRateCross.uAC = i;
  896. tspecRateCross.uHighOrLowThresholdFlag = HIGH_THRESHOLD_CROSS;
  897. tspecRateCross.uAboveOrBelowFlag = CROSS_ABOVE;
  898. EvHandlerSendEvent(pRateAdaptation->hEvHandler, IPC_EVENT_TSPEC_RATE_STATUS, (UINT8 *)&tspecRateCross,sizeof(OS_802_11_THRESHOLD_CROSS_INDICATION_PARAMS));
  899. }
  900. else
  901. if( (pRateAdaptation->RatesMap[prevIndex].rateNumber >= pRateAdaptation->tspecsRateParameters[i].highRateThreshold) &&
  902. (currentRateNumber < pRateAdaptation->tspecsRateParameters[i].highRateThreshold) )
  903. {
  904. tspecRateCross.uAC = i;
  905. tspecRateCross.uHighOrLowThresholdFlag = HIGH_THRESHOLD_CROSS;
  906. tspecRateCross.uAboveOrBelowFlag = CROSS_BELOW;
  907. EvHandlerSendEvent(pRateAdaptation->hEvHandler, IPC_EVENT_TSPEC_RATE_STATUS, (UINT8 *)&tspecRateCross,sizeof(OS_802_11_THRESHOLD_CROSS_INDICATION_PARAMS));
  908. }
  909. else
  910. if( (pRateAdaptation->RatesMap[prevIndex].rateNumber >= pRateAdaptation->tspecsRateParameters[i].lowRateThreshold) &&
  911. (currentRateNumber < pRateAdaptation->tspecsRateParameters[i].lowRateThreshold) )
  912. {
  913. tspecRateCross.uAC = i;
  914. tspecRateCross.uHighOrLowThresholdFlag = LOW_THRESHOLD_CROSS;
  915. tspecRateCross.uAboveOrBelowFlag = CROSS_BELOW;
  916. EvHandlerSendEvent(pRateAdaptation->hEvHandler, IPC_EVENT_TSPEC_RATE_STATUS, (UINT8 *)&tspecRateCross,sizeof(OS_802_11_THRESHOLD_CROSS_INDICATION_PARAMS));
  917. }
  918. else
  919. if( (pRateAdaptation->RatesMap[prevIndex].rateNumber < pRateAdaptation->tspecsRateParameters[i].lowRateThreshold) &&
  920. (currentRateNumber >= pRateAdaptation->tspecsRateParameters[i].lowRateThreshold) )
  921. {
  922. tspecRateCross.uAC = i;
  923. tspecRateCross.uHighOrLowThresholdFlag = LOW_THRESHOLD_CROSS;
  924. tspecRateCross.uAboveOrBelowFlag = CROSS_ABOVE;
  925. EvHandlerSendEvent(pRateAdaptation->hEvHandler, IPC_EVENT_TSPEC_RATE_STATUS, (UINT8 *)&tspecRateCross,sizeof(OS_802_11_THRESHOLD_CROSS_INDICATION_PARAMS));
  926. }
  927. }
  928. }
  929. }
  930. pRateAdaptation->txCount = 0;
  931. pRateAdaptation->txFailCount = 0;
  932. pRateAdaptation->txRateFallBackCount = 0;
  933. TS_ADVANCE( timeStamp, pRateAdaptation->expirTimeTick,
  934. (pRateAdaptation->stepUpFlag ? pRateAdaptation->ctrlDataFBShortInterval : pRateAdaptation->ctrlDataFBLongInterval));
  935. }
  936. return OK;
  937. }
  938. /***************************************************************************
  939. * rateAdaptation_setTspecsRateParams
  940. ****************************************************************************
  941. * DESCRIPTION:
  942. *
  943. * INPUTS: pRateAdaptation - the object
  944. **
  945. * RETURNS: OK/NOK
  946. ****************************************************************************/
  947. void rateAdaptation_setTspecsRateEvent(rateAdaptation_t* pRateAdaptation,
  948. UINT8 acID,
  949. BOOL enableEvent)
  950. {
  951. /* Prevent ENABLE_EVENTS if one of the threshold of that AC is ZERO */
  952. if (((pRateAdaptation->tspecsRateParameters[acID].highRateThreshold == 0) ||
  953. (pRateAdaptation->tspecsRateParameters[acID].lowRateThreshold == 0)) && (enableEvent == TRUE))
  954. return;
  955. pRateAdaptation->tspecsRateParameters[acID].enableEvent = enableEvent;
  956. }
  957. /***************************************************************************
  958. * rateAdaptation_setTspecsRateThresholds
  959. ****************************************************************************
  960. * DESCRIPTION:
  961. *
  962. * INPUTS: pRateAdaptation - the object
  963. **
  964. * RETURNS: OK/NOK
  965. ****************************************************************************/
  966. void rateAdaptation_setTspecsRateThresholds(rateAdaptation_t* pRateAdaptation,
  967. UINT8 acID,
  968. UINT8 highRateThreshold,
  969. UINT8 lowRateThreshold)
  970. {
  971. if(highRateThreshold < lowRateThreshold)
  972. {
  973. WLAN_REPORT_ERROR(pRateAdaptation->hReport, RATE_ADAPTATION_MODULE_LOG,
  974. (" rateAdaptation_setTspecsRateThresholds() ERROR: highRateThreshold < lowRateThreshold, ac = %d\n",acID));
  975. pRateAdaptation->tspecsRateParameters[acID].highRateThreshold = 0;
  976. pRateAdaptation->tspecsRateParameters[acID].lowRateThreshold = 0;
  977. }
  978. else
  979. {
  980. pRateAdaptation->tspecsRateParameters[acID].highRateThreshold = highRateThreshold;
  981. pRateAdaptation->tspecsRateParameters[acID].lowRateThreshold = lowRateThreshold;
  982. }
  983. }
  984. /*************************************************************************
  985. * *
  986. * DEBUG FUNCTIONS *
  987. * *
  988. *************************************************************************/
  989. void rateAdaptation_print(rateAdaptation_t *pRateAdaptation)
  990. {
  991. UINT32 count;
  992. WLAN_OS_REPORT((" Rate Adaptation Parameters \n"));
  993. WLAN_OS_REPORT(("-----------------------------------\n"));
  994. WLAN_OS_REPORT(("txCount = %d\n",pRateAdaptation->txCount));
  995. WLAN_OS_REPORT(("txFailCount = %d\n",pRateAdaptation->txFailCount));
  996. WLAN_OS_REPORT(("txRateFallBackCount = %d\n",pRateAdaptation->txRateFallBackCount));
  997. WLAN_OS_REPORT(("txSkipCount = %d\n",pRateAdaptation->txSkipCount));
  998. WLAN_OS_REPORT(("currRateIndex = %d\n",pRateAdaptation->currRateIndex));
  999. WLAN_OS_REPORT(("currRate Number = %d\n",pRateAdaptation->RatesMap[pRateAdaptation->currRateIndex].rateNumber));
  1000. WLAN_OS_REPORT(("maxRateIndex = %d\n",pRateAdaptation->maxRateIndex));
  1001. WLAN_OS_REPORT(("maxRate Number = %d\n",pRateAdaptation->RatesMap[pRateAdaptation->maxRateIndex].rateNumber));
  1002. WLAN_OS_REPORT(("stepUpFlag = %d\n",pRateAdaptation->stepUpFlag));
  1003. WLAN_OS_REPORT(("expirTimeTick = %d\n",pRateAdaptation->expirTimeTick));
  1004. WLAN_OS_REPORT(("stepUpTxPacketsThreshold = %d\n",pRateAdaptation->stepUpTxPacketsThreshold));
  1005. WLAN_OS_REPORT(("contTxPacketsThreshold = %d\n",pRateAdaptation->contTxPacketsThreshold));
  1006. WLAN_OS_REPORT(("ctrlDataFBShortInterval = %d\n",pRateAdaptation->ctrlDataFBShortInterval));
  1007. WLAN_OS_REPORT(("ctrlDataFBLongInterval = %d\n",pRateAdaptation->ctrlDataFBLongInterval));
  1008. WLAN_OS_REPORT((" Rate Adaptation Table \n"));
  1009. WLAN_OS_REPORT(("-----------------------------\n"));
  1010. for(count = 0 ; count < MAX_SUPPORTED_RATES ; count++)
  1011. {
  1012. WLAN_OS_REPORT(("Index = %d ,RateNumber = %d,StepUp = %d ,FallBack = %d , Modulation = %d 4X = %d valid = %d,\n",
  1013. count,
  1014. pRateAdaptation->RatesMap[count].rateNumber,
  1015. pRateAdaptation->RatesMap[count].rateAdaptStepUp,
  1016. pRateAdaptation->RatesMap[count].rateAdaptFallBack,
  1017. pRateAdaptation->RatesMap[count].modulation,
  1018. pRateAdaptation->RatesMap[count].fourXEnable,
  1019. pRateAdaptation->RatesMap[count].valid));
  1020. }
  1021. WLAN_OS_REPORT(("Tspecs Rate Parameters AC = %d \n",count));
  1022. WLAN_OS_REPORT(("-----------------------------\n"));
  1023. for(count = 0 ; count < MAX_NUM_OF_AC ; count++)
  1024. {
  1025. WLAN_OS_REPORT(("AC = %d \n",count));
  1026. WLAN_OS_REPORT(("---------\n"));
  1027. WLAN_OS_REPORT(("enableEvent = %d \n",pRateAdaptation->tspecsRateParameters[count].enableEvent));
  1028. WLAN_OS_REPORT(("highRateThreshold = %d \n",pRateAdaptation->tspecsRateParameters[count].highRateThreshold));
  1029. WLAN_OS_REPORT(("lowRateThreshold = %d \n",pRateAdaptation->tspecsRateParameters[count].lowRateThreshold));
  1030. }
  1031. }