Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. |
| 3 | * All rights reserved. |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation; either version 2 of the License, or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License along |
| 16 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 18 | * |
| 19 | * File: datarate.c |
| 20 | * |
| 21 | * Purpose: Handles the auto fallback & data rates functions |
| 22 | * |
| 23 | * Author: Lyndon Chen |
| 24 | * |
| 25 | * Date: July 17, 2002 |
| 26 | * |
| 27 | * Functions: |
| 28 | * RATEvParseMaxRate - Parsing the highest basic & support rate in rate field of frame |
| 29 | * RATEvTxRateFallBack - Rate fallback Algorithm Implementaion |
| 30 | * RATEuSetIE- Set rate IE field. |
| 31 | * |
| 32 | * Revision History: |
| 33 | * |
| 34 | */ |
| 35 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 36 | #include "tmacro.h" |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 37 | #include "mac.h" |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 38 | #include "80211mgr.h" |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 39 | #include "bssdb.h" |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 40 | #include "datarate.h" |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 41 | #include "card.h" |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 42 | #include "baseband.h" |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 43 | #include "srom.h" |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 44 | #include "rf.h" |
Jim Lieb | 9d26d60 | 2009-08-12 14:54:08 -0700 | [diff] [blame] | 45 | |
Andres More | 84cf5fc | 2013-01-31 15:20:42 -0500 | [diff] [blame] | 46 | /* static int msglevel = MSG_LEVEL_DEBUG; */ |
Nandini Hanumanthagowda | 3cef1a2 | 2013-10-24 00:20:11 +0530 | [diff] [blame^] | 47 | static int msglevel = MSG_LEVEL_INFO; |
| 48 | const u8 acbyIERate[MAX_RATE] = {0x02, 0x04, 0x0B, 0x16, 0x0C, 0x12, 0x18, |
| 49 | 0x24, 0x30, 0x48, 0x60, 0x6C}; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 50 | |
| 51 | #define AUTORATE_TXOK_CNT 0x0400 |
| 52 | #define AUTORATE_TXFAIL_CNT 0x0064 |
| 53 | #define AUTORATE_TIMEOUT 10 |
| 54 | |
Andres More | 8611a29 | 2010-05-01 14:25:00 -0300 | [diff] [blame] | 55 | void s_vResetCounter(PKnownNodeDB psNodeDBTable); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 56 | |
Andres More | 8611a29 | 2010-05-01 14:25:00 -0300 | [diff] [blame] | 57 | void s_vResetCounter(PKnownNodeDB psNodeDBTable) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 58 | { |
Nandini Hanumanthagowda | 3cef1a2 | 2013-10-24 00:20:11 +0530 | [diff] [blame^] | 59 | u8 ii; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 60 | |
Nandini Hanumanthagowda | 3cef1a2 | 2013-10-24 00:20:11 +0530 | [diff] [blame^] | 61 | /* clear statistics counter for auto_rate */ |
| 62 | for (ii = 0; ii <= MAX_RATE; ii++) { |
| 63 | psNodeDBTable->uTxOk[ii] = 0; |
| 64 | psNodeDBTable->uTxFail[ii] = 0; |
| 65 | } |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 66 | } |
| 67 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 68 | /*+ |
| 69 | * |
| 70 | * Routine Description: |
| 71 | * Rate fallback Algorithm Implementaion |
| 72 | * |
| 73 | * Parameters: |
| 74 | * In: |
| 75 | * pDevice - Pointer to the adapter |
| 76 | * psNodeDBTable - Pointer to Node Data Base |
| 77 | * Out: |
| 78 | * none |
| 79 | * |
| 80 | * Return Value: none |
| 81 | * |
| 82 | -*/ |
| 83 | #define AUTORATE_TXCNT_THRESHOLD 20 |
| 84 | #define AUTORATE_INC_THRESHOLD 30 |
| 85 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 86 | /*+ |
| 87 | * |
| 88 | * Description: |
| 89 | * Get RateIdx from the value in SuppRates IE or ExtSuppRates IE |
| 90 | * |
| 91 | * Parameters: |
| 92 | * In: |
Andres More | b902fbf | 2013-02-25 20:32:51 -0500 | [diff] [blame] | 93 | * u8 - Rate value in SuppRates IE or ExtSuppRates IE |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 94 | * Out: |
| 95 | * none |
| 96 | * |
| 97 | * Return Value: RateIdx |
| 98 | * |
| 99 | -*/ |
Nandini Hanumanthagowda | 3cef1a2 | 2013-10-24 00:20:11 +0530 | [diff] [blame^] | 100 | u16 RATEwGetRateIdx(u8 byRate) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 101 | { |
Nandini Hanumanthagowda | 3cef1a2 | 2013-10-24 00:20:11 +0530 | [diff] [blame^] | 102 | u16 ii; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 103 | |
Nandini Hanumanthagowda | 3cef1a2 | 2013-10-24 00:20:11 +0530 | [diff] [blame^] | 104 | /* erase BasicRate flag */ |
| 105 | byRate = byRate & 0x7F; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 106 | |
Nandini Hanumanthagowda | 3cef1a2 | 2013-10-24 00:20:11 +0530 | [diff] [blame^] | 107 | for (ii = 0; ii < MAX_RATE; ii++) { |
| 108 | if (acbyIERate[ii] == byRate) |
| 109 | return ii; |
| 110 | } |
| 111 | return 0; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 112 | } |
| 113 | |
| 114 | /*+ |
| 115 | * |
| 116 | * Description: |
| 117 | * Parsing the highest basic & support rate in rate field of frame. |
| 118 | * |
| 119 | * Parameters: |
| 120 | * In: |
| 121 | * pDevice - Pointer to the adapter |
| 122 | * pItemRates - Pointer to Rate field defined in 802.11 spec. |
| 123 | * pItemExtRates - Pointer to Extended Rate field defined in 802.11 spec. |
| 124 | * Out: |
| 125 | * pwMaxBasicRate - Maximum Basic Rate |
| 126 | * pwMaxSuppRate - Maximum Supported Rate |
| 127 | * pbyTopCCKRate - Maximum Basic Rate in CCK mode |
| 128 | * pbyTopOFDMRate - Maximum Basic Rate in OFDM mode |
| 129 | * |
| 130 | * Return Value: none |
| 131 | * |
| 132 | -*/ |
Malcolm Priestley | 45c73bb | 2013-01-17 23:17:21 +0000 | [diff] [blame] | 133 | |
| 134 | void RATEvParseMaxRate(struct vnt_private *pDevice, |
| 135 | PWLAN_IE_SUPP_RATES pItemRates, PWLAN_IE_SUPP_RATES pItemExtRates, |
| 136 | int bUpdateBasicRate, u16 *pwMaxBasicRate, u16 *pwMaxSuppRate, |
| 137 | u16 *pwSuppRate, u8 *pbyTopCCKRate, u8 *pbyTopOFDMRate) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 138 | { |
Nandini Hanumanthagowda | 3cef1a2 | 2013-10-24 00:20:11 +0530 | [diff] [blame^] | 139 | int ii; |
Malcolm Priestley | 45c73bb | 2013-01-17 23:17:21 +0000 | [diff] [blame] | 140 | u8 byHighSuppRate = 0, byRate = 0; |
| 141 | u16 wOldBasicRate = pDevice->wBasicRate; |
| 142 | u32 uRateLen; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 143 | |
Malcolm Priestley | 45c73bb | 2013-01-17 23:17:21 +0000 | [diff] [blame] | 144 | if (pItemRates == NULL) |
| 145 | return; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 146 | |
Nandini Hanumanthagowda | 3cef1a2 | 2013-10-24 00:20:11 +0530 | [diff] [blame^] | 147 | *pwSuppRate = 0; |
| 148 | uRateLen = pItemRates->len; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 149 | |
Nandini Hanumanthagowda | 3cef1a2 | 2013-10-24 00:20:11 +0530 | [diff] [blame^] | 150 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ParseMaxRate Len: %d\n", uRateLen); |
| 151 | if (pDevice->byBBType != BB_TYPE_11B) { |
| 152 | if (uRateLen > WLAN_RATES_MAXLEN) |
| 153 | uRateLen = WLAN_RATES_MAXLEN; |
| 154 | } else { |
| 155 | if (uRateLen > WLAN_RATES_MAXLEN_11B) |
| 156 | uRateLen = WLAN_RATES_MAXLEN_11B; |
| 157 | } |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 158 | |
Nandini Hanumanthagowda | 3cef1a2 | 2013-10-24 00:20:11 +0530 | [diff] [blame^] | 159 | for (ii = 0; ii < uRateLen; ii++) { |
| 160 | byRate = (u8)(pItemRates->abyRates[ii]); |
| 161 | if (WLAN_MGMT_IS_BASICRATE(byRate) && |
| 162 | (bUpdateBasicRate == true)) { |
| 163 | /* |
| 164 | * add to basic rate set, update pDevice->byTopCCKBasicRate and |
| 165 | * pDevice->byTopOFDMBasicRate |
| 166 | */ |
| 167 | CARDbAddBasicRate((void *)pDevice, RATEwGetRateIdx(byRate)); |
| 168 | DBG_PRT(MSG_LEVEL_DEBUG, |
| 169 | KERN_INFO"ParseMaxRate AddBasicRate: %d\n", |
| 170 | RATEwGetRateIdx(byRate)); |
| 171 | } |
| 172 | byRate = (u8)(pItemRates->abyRates[ii]&0x7F); |
| 173 | if (byHighSuppRate == 0) |
| 174 | byHighSuppRate = byRate; |
| 175 | if (byRate > byHighSuppRate) |
| 176 | byHighSuppRate = byRate; |
| 177 | *pwSuppRate |= (1<<RATEwGetRateIdx(byRate)); |
| 178 | } |
| 179 | if ((pItemExtRates != NULL) && (pItemExtRates->byElementID == WLAN_EID_EXTSUPP_RATES) && |
| 180 | (pDevice->byBBType != BB_TYPE_11B)) { |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 181 | |
Nandini Hanumanthagowda | 3cef1a2 | 2013-10-24 00:20:11 +0530 | [diff] [blame^] | 182 | unsigned int uExtRateLen = pItemExtRates->len; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 183 | |
Nandini Hanumanthagowda | 3cef1a2 | 2013-10-24 00:20:11 +0530 | [diff] [blame^] | 184 | if (uExtRateLen > WLAN_RATES_MAXLEN) |
| 185 | uExtRateLen = WLAN_RATES_MAXLEN; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 186 | |
Nandini Hanumanthagowda | 3cef1a2 | 2013-10-24 00:20:11 +0530 | [diff] [blame^] | 187 | for (ii = 0; ii < uExtRateLen; ii++) { |
| 188 | byRate = (u8)(pItemExtRates->abyRates[ii]); |
| 189 | /* select highest basic rate */ |
| 190 | if (WLAN_MGMT_IS_BASICRATE(pItemExtRates->abyRates[ii])) { |
| 191 | /* |
| 192 | * add to basic rate set, update pDevice->byTopCCKBasicRate and |
| 193 | * pDevice->byTopOFDMBasicRate |
| 194 | */ |
| 195 | CARDbAddBasicRate((void *)pDevice, RATEwGetRateIdx(byRate)); |
| 196 | DBG_PRT(MSG_LEVEL_DEBUG, |
| 197 | KERN_INFO"ParseMaxRate AddBasicRate: %d\n", |
| 198 | RATEwGetRateIdx(byRate)); |
| 199 | } |
| 200 | byRate = (u8)(pItemExtRates->abyRates[ii]&0x7F); |
| 201 | if (byHighSuppRate == 0) |
| 202 | byHighSuppRate = byRate; |
| 203 | if (byRate > byHighSuppRate) |
| 204 | byHighSuppRate = byRate; |
| 205 | *pwSuppRate |= (1<<RATEwGetRateIdx(byRate)); |
Andres More | 84cf5fc | 2013-01-31 15:20:42 -0500 | [diff] [blame] | 206 | |
Nandini Hanumanthagowda | 3cef1a2 | 2013-10-24 00:20:11 +0530 | [diff] [blame^] | 207 | /* DBG_PRN_GRP09(("ParseMaxRate : HighSuppRate: %d, %X\n", |
| 208 | * RATEwGetRateIdx(byRate), byRate)); |
| 209 | */ |
| 210 | } |
| 211 | } |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 212 | |
Nandini Hanumanthagowda | 3cef1a2 | 2013-10-24 00:20:11 +0530 | [diff] [blame^] | 213 | if ((pDevice->byPacketType == PK_TYPE_11GB) |
| 214 | && CARDbIsOFDMinBasicRate((void *)pDevice)) { |
| 215 | pDevice->byPacketType = PK_TYPE_11GA; |
| 216 | } |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 217 | |
Nandini Hanumanthagowda | 3cef1a2 | 2013-10-24 00:20:11 +0530 | [diff] [blame^] | 218 | *pbyTopCCKRate = pDevice->byTopCCKBasicRate; |
| 219 | *pbyTopOFDMRate = pDevice->byTopOFDMBasicRate; |
| 220 | *pwMaxSuppRate = RATEwGetRateIdx(byHighSuppRate); |
| 221 | if ((pDevice->byPacketType == PK_TYPE_11B) || (pDevice->byPacketType == PK_TYPE_11GB)) |
| 222 | *pwMaxBasicRate = pDevice->byTopCCKBasicRate; |
| 223 | else |
| 224 | *pwMaxBasicRate = pDevice->byTopOFDMBasicRate; |
| 225 | if (wOldBasicRate != pDevice->wBasicRate) |
| 226 | CARDvSetRSPINF((void *)pDevice, pDevice->byBBType); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 227 | |
Nandini Hanumanthagowda | 3cef1a2 | 2013-10-24 00:20:11 +0530 | [diff] [blame^] | 228 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Exit ParseMaxRate\n"); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 229 | } |
| 230 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 231 | /*+ |
| 232 | * |
| 233 | * Routine Description: |
| 234 | * Rate fallback Algorithm Implementaion |
| 235 | * |
| 236 | * Parameters: |
| 237 | * In: |
| 238 | * pDevice - Pointer to the adapter |
| 239 | * psNodeDBTable - Pointer to Node Data Base |
| 240 | * Out: |
| 241 | * none |
| 242 | * |
| 243 | * Return Value: none |
| 244 | * |
| 245 | -*/ |
| 246 | #define AUTORATE_TXCNT_THRESHOLD 20 |
| 247 | #define AUTORATE_INC_THRESHOLD 30 |
| 248 | |
Malcolm Priestley | 45c73bb | 2013-01-17 23:17:21 +0000 | [diff] [blame] | 249 | void RATEvTxRateFallBack(struct vnt_private *pDevice, |
| 250 | PKnownNodeDB psNodeDBTable) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 251 | { |
Malcolm Priestley | 45c73bb | 2013-01-17 23:17:21 +0000 | [diff] [blame] | 252 | struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; |
| 253 | u16 wIdxDownRate = 0; |
| 254 | int ii; |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 255 | int bAutoRate[MAX_RATE] = {true, true, true, true, false, false, true, |
| 256 | true, true, true, true, true}; |
Malcolm Priestley | 45c73bb | 2013-01-17 23:17:21 +0000 | [diff] [blame] | 257 | u32 dwThroughputTbl[MAX_RATE] = {10, 20, 55, 110, 60, 90, 120, 180, |
| 258 | 240, 360, 480, 540}; |
| 259 | u32 dwThroughput = 0; |
| 260 | u16 wIdxUpRate = 0; |
| 261 | u32 dwTxDiff = 0; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 262 | |
Malcolm Priestley | 45c73bb | 2013-01-17 23:17:21 +0000 | [diff] [blame] | 263 | if (pMgmt->eScanState != WMAC_NO_SCANNING) |
| 264 | return; /* Don't do Fallback when scanning Channel */ |
| 265 | |
| 266 | psNodeDBTable->uTimeCount++; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 267 | |
Nandini Hanumanthagowda | 3cef1a2 | 2013-10-24 00:20:11 +0530 | [diff] [blame^] | 268 | if (psNodeDBTable->uTxFail[MAX_RATE] > psNodeDBTable->uTxOk[MAX_RATE]) |
| 269 | dwTxDiff = psNodeDBTable->uTxFail[MAX_RATE] - psNodeDBTable->uTxOk[MAX_RATE]; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 270 | |
Nandini Hanumanthagowda | 3cef1a2 | 2013-10-24 00:20:11 +0530 | [diff] [blame^] | 271 | if ((psNodeDBTable->uTxOk[MAX_RATE] < AUTORATE_TXOK_CNT) && |
| 272 | (dwTxDiff < AUTORATE_TXFAIL_CNT) && |
| 273 | (psNodeDBTable->uTimeCount < AUTORATE_TIMEOUT)) { |
| 274 | return; |
| 275 | } |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 276 | |
Nandini Hanumanthagowda | 3cef1a2 | 2013-10-24 00:20:11 +0530 | [diff] [blame^] | 277 | if (psNodeDBTable->uTimeCount >= AUTORATE_TIMEOUT) { |
| 278 | psNodeDBTable->uTimeCount = 0; |
| 279 | } |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 280 | |
Nandini Hanumanthagowda | 3cef1a2 | 2013-10-24 00:20:11 +0530 | [diff] [blame^] | 281 | for (ii = 0; ii < MAX_RATE; ii++) { |
| 282 | if (psNodeDBTable->wSuppRate & (0x0001<<ii)) { |
| 283 | if (bAutoRate[ii] == true) { |
| 284 | wIdxUpRate = (u16) ii; |
| 285 | } |
| 286 | } else { |
| 287 | bAutoRate[ii] = false; |
| 288 | } |
| 289 | } |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 290 | |
Nandini Hanumanthagowda | 3cef1a2 | 2013-10-24 00:20:11 +0530 | [diff] [blame^] | 291 | for (ii = 0; ii <= psNodeDBTable->wTxDataRate; ii++) { |
| 292 | if ((psNodeDBTable->uTxOk[ii] != 0) || |
| 293 | (psNodeDBTable->uTxFail[ii] != 0)) { |
| 294 | dwThroughputTbl[ii] *= psNodeDBTable->uTxOk[ii]; |
| 295 | if (ii < RATE_11M) { |
| 296 | psNodeDBTable->uTxFail[ii] *= 4; |
| 297 | } |
| 298 | dwThroughputTbl[ii] /= (psNodeDBTable->uTxOk[ii] + psNodeDBTable->uTxFail[ii]); |
| 299 | } |
| 300 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Rate %d,Ok: %d, Fail:%d, Throughput:%d\n", |
| 301 | ii, (int)psNodeDBTable->uTxOk[ii], (int)psNodeDBTable->uTxFail[ii], (int)dwThroughputTbl[ii]); |
| 302 | } |
| 303 | dwThroughput = dwThroughputTbl[psNodeDBTable->wTxDataRate]; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 304 | |
Nandini Hanumanthagowda | 3cef1a2 | 2013-10-24 00:20:11 +0530 | [diff] [blame^] | 305 | wIdxDownRate = psNodeDBTable->wTxDataRate; |
| 306 | for (ii = psNodeDBTable->wTxDataRate; ii > 0;) { |
| 307 | ii--; |
| 308 | if ((dwThroughputTbl[ii] > dwThroughput) && |
| 309 | (bAutoRate[ii] == true)) { |
| 310 | dwThroughput = dwThroughputTbl[ii]; |
| 311 | wIdxDownRate = (u16) ii; |
| 312 | } |
| 313 | } |
| 314 | psNodeDBTable->wTxDataRate = wIdxDownRate; |
| 315 | if (psNodeDBTable->uTxOk[MAX_RATE]) { |
| 316 | if (psNodeDBTable->uTxOk[MAX_RATE] > |
| 317 | (psNodeDBTable->uTxFail[MAX_RATE] * 4)) { |
| 318 | psNodeDBTable->wTxDataRate = wIdxUpRate; |
| 319 | } |
| 320 | } else { /* adhoc, if uTxOk(total) == 0 & uTxFail(total) == 0 */ |
| 321 | if (psNodeDBTable->uTxFail[MAX_RATE] == 0) |
| 322 | psNodeDBTable->wTxDataRate = wIdxUpRate; |
| 323 | } |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 324 | |
Nandini Hanumanthagowda | 3cef1a2 | 2013-10-24 00:20:11 +0530 | [diff] [blame^] | 325 | if (pDevice->byBBType == BB_TYPE_11A) { |
| 326 | if (psNodeDBTable->wTxDataRate <= RATE_11M) |
| 327 | psNodeDBTable->wTxDataRate = RATE_6M; |
| 328 | } |
| 329 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"uTxOk[MAX_RATE] %d, uTxFail[MAX_RATE]:%d\n", (int)psNodeDBTable->uTxOk[MAX_RATE], (int)psNodeDBTable->uTxFail[MAX_RATE]); |
| 330 | s_vResetCounter(psNodeDBTable); |
| 331 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Rate: %d, U:%d, D:%d\n", (int)psNodeDBTable->wTxDataRate, (int)wIdxUpRate, (int)wIdxDownRate); |
| 332 | return; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 333 | } |
| 334 | |
| 335 | /*+ |
| 336 | * |
| 337 | * Description: |
| 338 | * This routine is used to assemble available Rate IE. |
| 339 | * |
| 340 | * Parameters: |
| 341 | * In: |
| 342 | * pDevice |
| 343 | * Out: |
| 344 | * |
| 345 | * Return Value: None |
| 346 | * |
| 347 | -*/ |
Nandini Hanumanthagowda | 3cef1a2 | 2013-10-24 00:20:11 +0530 | [diff] [blame^] | 348 | u8 RATEuSetIE(PWLAN_IE_SUPP_RATES pSrcRates, PWLAN_IE_SUPP_RATES pDstRates, |
| 349 | unsigned int uRateLen) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 350 | { |
Nandini Hanumanthagowda | 3cef1a2 | 2013-10-24 00:20:11 +0530 | [diff] [blame^] | 351 | unsigned int ii, uu, uRateCnt = 0; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 352 | |
Nandini Hanumanthagowda | 3cef1a2 | 2013-10-24 00:20:11 +0530 | [diff] [blame^] | 353 | if ((pSrcRates == NULL) || (pDstRates == NULL)) |
| 354 | return 0; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 355 | |
Nandini Hanumanthagowda | 3cef1a2 | 2013-10-24 00:20:11 +0530 | [diff] [blame^] | 356 | if (pSrcRates->len == 0) |
| 357 | return 0; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 358 | |
Nandini Hanumanthagowda | 3cef1a2 | 2013-10-24 00:20:11 +0530 | [diff] [blame^] | 359 | for (ii = 0; ii < uRateLen; ii++) { |
| 360 | for (uu = 0; uu < pSrcRates->len; uu++) { |
| 361 | if ((pSrcRates->abyRates[uu] & 0x7F) == acbyIERate[ii]) { |
| 362 | pDstRates->abyRates[uRateCnt++] = pSrcRates->abyRates[uu]; |
| 363 | break; |
| 364 | } |
| 365 | } |
| 366 | } |
| 367 | return (u8)uRateCnt; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 368 | } |