spi-topcliff-pch: add recovery processing in case wait-event timeout
[zen-stable.git] / drivers / staging / rtl8192e / rtl819x_HTProc.c
blob8b7412980ebbc1c1b218207b206eca90a0babaf3
1 /******************************************************************************
2 * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved.
4 * This program is distributed in the hope that it will be useful, but WITHOUT
5 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
6 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
7 * more details.
9 * You should have received a copy of the GNU General Public License along with
10 * this program; if not, write to the Free Software Foundation, Inc.,
11 * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
13 * The full GNU General Public License is included in this distribution in the
14 * file called LICENSE.
16 * Contact Information:
17 * wlanfae <wlanfae@realtek.com>
18 ******************************************************************************/
19 #include "rtllib.h"
20 #include "rtl819x_HT.h"
21 u8 MCS_FILTER_ALL[16] = {
22 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
23 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
26 u8 MCS_FILTER_1SS[16] = {
27 0xff, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
28 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
31 u16 MCS_DATA_RATE[2][2][77] = {
32 {{13, 26, 39, 52, 78, 104, 117, 130, 26, 52, 78, 104, 156, 208, 234,
33 260, 39, 78, 117, 234, 312, 351, 390, 52, 104, 156, 208, 312, 416,
34 468, 520, 0, 78, 104, 130, 117, 156, 195, 104, 130, 130, 156, 182,
35 182, 208, 156, 195, 195, 234, 273, 273, 312, 130, 156, 181, 156,
36 181, 208, 234, 208, 234, 260, 260, 286, 195, 234, 273, 234, 273,
37 312, 351, 312, 351, 390, 390, 429} ,
38 {14, 29, 43, 58, 87, 116, 130, 144, 29, 58, 87, 116, 173, 231, 260, 289,
39 43, 87, 130, 173, 260, 347, 390, 433, 58, 116, 173, 231, 347, 462, 520,
40 578, 0, 87, 116, 144, 130, 173, 217, 116, 144, 144, 173, 202, 202, 231,
41 173, 217, 217, 260, 303, 303, 347, 144, 173, 202, 173, 202, 231, 260,
42 231, 260, 289, 289, 318, 217, 260, 303, 260, 303, 347, 390, 347, 390,
43 433, 433, 477} } ,
44 {{27, 54, 81, 108, 162, 216, 243, 270, 54, 108, 162, 216, 324, 432, 486,
45 540, 81, 162, 243, 324, 486, 648, 729, 810, 108, 216, 324, 432, 648,
46 864, 972, 1080, 12, 162, 216, 270, 243, 324, 405, 216, 270, 270, 324,
47 378, 378, 432, 324, 405, 405, 486, 567, 567, 648, 270, 324, 378, 324,
48 378, 432, 486, 432, 486, 540, 540, 594, 405, 486, 567, 486, 567, 648,
49 729, 648, 729, 810, 810, 891},
50 {30, 60, 90, 120, 180, 240, 270, 300, 60, 120, 180, 240, 360, 480, 540,
51 600, 90, 180, 270, 360, 540, 720, 810, 900, 120, 240, 360, 480, 720,
52 960, 1080, 1200, 13, 180, 240, 300, 270, 360, 450, 240, 300, 300, 360,
53 420, 420, 480, 360, 450, 450, 540, 630, 630, 720, 300, 360, 420, 360,
54 420, 480, 540, 480, 540, 600, 600, 660, 450, 540, 630, 540, 630, 720,
55 810, 720, 810, 900, 900, 990} }
58 static u8 UNKNOWN_BORADCOM[3] = {0x00, 0x14, 0xbf};
60 static u8 LINKSYSWRT330_LINKSYSWRT300_BROADCOM[3] = {0x00, 0x1a, 0x70};
62 static u8 LINKSYSWRT350_LINKSYSWRT150_BROADCOM[3] = {0x00, 0x1d, 0x7e};
64 static u8 BELKINF5D8233V1_RALINK[3] = {0x00, 0x17, 0x3f};
66 static u8 BELKINF5D82334V3_RALINK[3] = {0x00, 0x1c, 0xdf};
68 static u8 PCI_RALINK[3] = {0x00, 0x90, 0xcc};
70 static u8 EDIMAX_RALINK[3] = {0x00, 0x0e, 0x2e};
72 static u8 AIRLINK_RALINK[3] = {0x00, 0x18, 0x02};
74 static u8 DLINK_ATHEROS_1[3] = {0x00, 0x1c, 0xf0};
76 static u8 DLINK_ATHEROS_2[3] = {0x00, 0x21, 0x91};
78 static u8 CISCO_BROADCOM[3] = {0x00, 0x17, 0x94};
80 static u8 LINKSYS_MARVELL_4400N[3] = {0x00, 0x14, 0xa4};
82 void HTUpdateDefaultSetting(struct rtllib_device *ieee)
84 struct rt_hi_throughput *pHTInfo = ieee->pHTInfo;
86 pHTInfo->bAcceptAddbaReq = 1;
88 pHTInfo->bRegShortGI20MHz = 1;
89 pHTInfo->bRegShortGI40MHz = 1;
91 pHTInfo->bRegBW40MHz = 1;
93 if (pHTInfo->bRegBW40MHz)
94 pHTInfo->bRegSuppCCK = 1;
95 else
96 pHTInfo->bRegSuppCCK = true;
98 pHTInfo->nAMSDU_MaxSize = 7935UL;
99 pHTInfo->bAMSDU_Support = 0;
101 pHTInfo->bAMPDUEnable = 1;
102 pHTInfo->AMPDU_Factor = 2;
103 pHTInfo->MPDU_Density = 0;
105 pHTInfo->SelfMimoPs = 3;
106 if (pHTInfo->SelfMimoPs == 2)
107 pHTInfo->SelfMimoPs = 3;
108 ieee->bTxDisableRateFallBack = 0;
109 ieee->bTxUseDriverAssingedRate = 0;
111 ieee->bTxEnableFwCalcDur = 1;
113 pHTInfo->bRegRT2RTAggregation = 1;
115 pHTInfo->bRegRxReorderEnable = 1;
116 pHTInfo->RxReorderWinSize = 64;
117 pHTInfo->RxReorderPendingTime = 30;
120 void HTDebugHTCapability(u8 *CapIE, u8 *TitleString)
123 static u8 EWC11NHTCap[] = {0x00, 0x90, 0x4c, 0x33};
124 struct ht_capab_ele *pCapELE;
126 if (!memcmp(CapIE, EWC11NHTCap, sizeof(EWC11NHTCap))) {
127 RTLLIB_DEBUG(RTLLIB_DL_HT, "EWC IE in %s()\n", __func__);
128 pCapELE = (struct ht_capab_ele *)(&CapIE[4]);
129 } else
130 pCapELE = (struct ht_capab_ele *)(&CapIE[0]);
132 RTLLIB_DEBUG(RTLLIB_DL_HT, "<Log HT Capability>. Called by %s\n",
133 TitleString);
135 RTLLIB_DEBUG(RTLLIB_DL_HT, "\tSupported Channel Width = %s\n",
136 (pCapELE->ChlWidth) ? "20MHz" : "20/40MHz");
137 RTLLIB_DEBUG(RTLLIB_DL_HT, "\tSupport Short GI for 20M = %s\n",
138 (pCapELE->ShortGI20Mhz) ? "YES" : "NO");
139 RTLLIB_DEBUG(RTLLIB_DL_HT, "\tSupport Short GI for 40M = %s\n",
140 (pCapELE->ShortGI40Mhz) ? "YES" : "NO");
141 RTLLIB_DEBUG(RTLLIB_DL_HT, "\tSupport TX STBC = %s\n",
142 (pCapELE->TxSTBC) ? "YES" : "NO");
143 RTLLIB_DEBUG(RTLLIB_DL_HT, "\tMax AMSDU Size = %s\n",
144 (pCapELE->MaxAMSDUSize) ? "3839" : "7935");
145 RTLLIB_DEBUG(RTLLIB_DL_HT, "\tSupport CCK in 20/40 mode = %s\n",
146 (pCapELE->DssCCk) ? "YES" : "NO");
147 RTLLIB_DEBUG(RTLLIB_DL_HT, "\tMax AMPDU Factor = %d\n",
148 pCapELE->MaxRxAMPDUFactor);
149 RTLLIB_DEBUG(RTLLIB_DL_HT, "\tMPDU Density = %d\n",
150 pCapELE->MPDUDensity);
151 RTLLIB_DEBUG(RTLLIB_DL_HT, "\tMCS Rate Set = [%x][%x][%x][%x][%x]\n",
152 pCapELE->MCS[0], pCapELE->MCS[1], pCapELE->MCS[2],
153 pCapELE->MCS[3], pCapELE->MCS[4]);
154 return;
158 void HTDebugHTInfo(u8 *InfoIE, u8 *TitleString)
161 static u8 EWC11NHTInfo[] = {0x00, 0x90, 0x4c, 0x34};
162 struct ht_info_ele *pHTInfoEle;
164 if (!memcmp(InfoIE, EWC11NHTInfo, sizeof(EWC11NHTInfo))) {
165 RTLLIB_DEBUG(RTLLIB_DL_HT, "EWC IE in %s()\n", __func__);
166 pHTInfoEle = (struct ht_info_ele *)(&InfoIE[4]);
167 } else
168 pHTInfoEle = (struct ht_info_ele *)(&InfoIE[0]);
171 RTLLIB_DEBUG(RTLLIB_DL_HT, "<Log HT Information Element>. "
172 "Called by %s\n", TitleString);
174 RTLLIB_DEBUG(RTLLIB_DL_HT, "\tPrimary channel = %d\n",
175 pHTInfoEle->ControlChl);
176 RTLLIB_DEBUG(RTLLIB_DL_HT, "\tSenondary channel =");
177 switch (pHTInfoEle->ExtChlOffset) {
178 case 0:
179 RTLLIB_DEBUG(RTLLIB_DL_HT, "Not Present\n");
180 break;
181 case 1:
182 RTLLIB_DEBUG(RTLLIB_DL_HT, "Upper channel\n");
183 break;
184 case 2:
185 RTLLIB_DEBUG(RTLLIB_DL_HT, "Reserved. Eooro!!!\n");
186 break;
187 case 3:
188 RTLLIB_DEBUG(RTLLIB_DL_HT, "Lower Channel\n");
189 break;
191 RTLLIB_DEBUG(RTLLIB_DL_HT, "\tRecommended channel width = %s\n",
192 (pHTInfoEle->RecommemdedTxWidth) ? "20Mhz" : "40Mhz");
194 RTLLIB_DEBUG(RTLLIB_DL_HT, "\tOperation mode for protection = ");
195 switch (pHTInfoEle->OptMode) {
196 case 0:
197 RTLLIB_DEBUG(RTLLIB_DL_HT, "No Protection\n");
198 break;
199 case 1:
200 RTLLIB_DEBUG(RTLLIB_DL_HT, "HT non-member protection mode\n");
201 break;
202 case 2:
203 RTLLIB_DEBUG(RTLLIB_DL_HT, "Suggest to open protection\n");
204 break;
205 case 3:
206 RTLLIB_DEBUG(RTLLIB_DL_HT, "HT mixed mode\n");
207 break;
210 RTLLIB_DEBUG(RTLLIB_DL_HT, "\tBasic MCS Rate Set = [%x][%x][%x][%x]"
211 "[%x]\n", pHTInfoEle->BasicMSC[0], pHTInfoEle->BasicMSC[1],
212 pHTInfoEle->BasicMSC[2], pHTInfoEle->BasicMSC[3],
213 pHTInfoEle->BasicMSC[4]);
214 return;
217 static bool IsHTHalfNmode40Bandwidth(struct rtllib_device *ieee)
219 bool retValue = false;
220 struct rt_hi_throughput *pHTInfo = ieee->pHTInfo;
222 if (pHTInfo->bCurrentHTSupport == false)
223 retValue = false;
224 else if (pHTInfo->bRegBW40MHz == false)
225 retValue = false;
226 else if (!ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev))
227 retValue = false;
228 else if (((struct ht_capab_ele *)(pHTInfo->PeerHTCapBuf))->ChlWidth)
229 retValue = true;
230 else
231 retValue = false;
233 return retValue;
236 static bool IsHTHalfNmodeSGI(struct rtllib_device *ieee, bool is40MHz)
238 bool retValue = false;
239 struct rt_hi_throughput *pHTInfo = ieee->pHTInfo;
241 if (pHTInfo->bCurrentHTSupport == false)
242 retValue = false;
243 else if (!ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev))
244 retValue = false;
245 else if (is40MHz) {
246 if (((struct ht_capab_ele *)
247 (pHTInfo->PeerHTCapBuf))->ShortGI40Mhz)
248 retValue = true;
249 else
250 retValue = false;
251 } else {
252 if (((struct ht_capab_ele *)
253 (pHTInfo->PeerHTCapBuf))->ShortGI20Mhz)
254 retValue = true;
255 else
256 retValue = false;
259 return retValue;
262 u16 HTHalfMcsToDataRate(struct rtllib_device *ieee, u8 nMcsRate)
265 u8 is40MHz;
266 u8 isShortGI;
268 is40MHz = (IsHTHalfNmode40Bandwidth(ieee)) ? 1 : 0;
269 isShortGI = (IsHTHalfNmodeSGI(ieee, is40MHz)) ? 1 : 0;
271 return MCS_DATA_RATE[is40MHz][isShortGI][(nMcsRate & 0x7f)];
275 u16 HTMcsToDataRate(struct rtllib_device *ieee, u8 nMcsRate)
277 struct rt_hi_throughput *pHTInfo = ieee->pHTInfo;
279 u8 is40MHz = (pHTInfo->bCurBW40MHz) ? 1 : 0;
280 u8 isShortGI = (pHTInfo->bCurBW40MHz) ?
281 ((pHTInfo->bCurShortGI40MHz) ? 1 : 0) :
282 ((pHTInfo->bCurShortGI20MHz) ? 1 : 0);
283 return MCS_DATA_RATE[is40MHz][isShortGI][(nMcsRate & 0x7f)];
286 u16 TxCountToDataRate(struct rtllib_device *ieee, u8 nDataRate)
288 u16 CCKOFDMRate[12] = {0x02, 0x04, 0x0b, 0x16, 0x0c, 0x12, 0x18,
289 0x24, 0x30, 0x48, 0x60, 0x6c};
290 u8 is40MHz = 0;
291 u8 isShortGI = 0;
293 if (nDataRate < 12) {
294 return CCKOFDMRate[nDataRate];
295 } else {
296 if (nDataRate >= 0x10 && nDataRate <= 0x1f) {
297 is40MHz = 0;
298 isShortGI = 0;
299 } else if (nDataRate >= 0x20 && nDataRate <= 0x2f) {
300 is40MHz = 1;
301 isShortGI = 0;
303 } else if (nDataRate >= 0x30 && nDataRate <= 0x3f) {
304 is40MHz = 0;
305 isShortGI = 1;
306 } else if (nDataRate >= 0x40 && nDataRate <= 0x4f) {
307 is40MHz = 1;
308 isShortGI = 1;
310 return MCS_DATA_RATE[is40MHz][isShortGI][nDataRate&0xf];
314 bool IsHTHalfNmodeAPs(struct rtllib_device *ieee)
316 bool retValue = false;
317 struct rtllib_network *net = &ieee->current_network;
319 if ((memcmp(net->bssid, BELKINF5D8233V1_RALINK, 3) == 0) ||
320 (memcmp(net->bssid, BELKINF5D82334V3_RALINK, 3) == 0) ||
321 (memcmp(net->bssid, PCI_RALINK, 3) == 0) ||
322 (memcmp(net->bssid, EDIMAX_RALINK, 3) == 0) ||
323 (memcmp(net->bssid, AIRLINK_RALINK, 3) == 0) ||
324 (net->ralink_cap_exist))
325 retValue = true;
326 else if (!memcmp(net->bssid, UNKNOWN_BORADCOM, 3) ||
327 !memcmp(net->bssid, LINKSYSWRT330_LINKSYSWRT300_BROADCOM, 3) ||
328 !memcmp(net->bssid, LINKSYSWRT350_LINKSYSWRT150_BROADCOM, 3) ||
329 (net->broadcom_cap_exist))
330 retValue = true;
331 else if (net->bssht.bdRT2RTAggregation)
332 retValue = true;
333 else
334 retValue = false;
336 return retValue;
339 static void HTIOTPeerDetermine(struct rtllib_device *ieee)
341 struct rt_hi_throughput *pHTInfo = ieee->pHTInfo;
342 struct rtllib_network *net = &ieee->current_network;
343 if (net->bssht.bdRT2RTAggregation) {
344 pHTInfo->IOTPeer = HT_IOT_PEER_REALTEK;
345 if (net->bssht.RT2RT_HT_Mode & RT_HT_CAP_USE_92SE)
346 pHTInfo->IOTPeer = HT_IOT_PEER_REALTEK_92SE;
347 if (net->bssht.RT2RT_HT_Mode & RT_HT_CAP_USE_SOFTAP)
348 pHTInfo->IOTPeer = HT_IOT_PEER_92U_SOFTAP;
349 } else if (net->broadcom_cap_exist)
350 pHTInfo->IOTPeer = HT_IOT_PEER_BROADCOM;
351 else if (!memcmp(net->bssid, UNKNOWN_BORADCOM, 3) ||
352 !memcmp(net->bssid, LINKSYSWRT330_LINKSYSWRT300_BROADCOM, 3) ||
353 !memcmp(net->bssid, LINKSYSWRT350_LINKSYSWRT150_BROADCOM, 3))
354 pHTInfo->IOTPeer = HT_IOT_PEER_BROADCOM;
355 else if ((memcmp(net->bssid, BELKINF5D8233V1_RALINK, 3) == 0) ||
356 (memcmp(net->bssid, BELKINF5D82334V3_RALINK, 3) == 0) ||
357 (memcmp(net->bssid, PCI_RALINK, 3) == 0) ||
358 (memcmp(net->bssid, EDIMAX_RALINK, 3) == 0) ||
359 (memcmp(net->bssid, AIRLINK_RALINK, 3) == 0) ||
360 net->ralink_cap_exist)
361 pHTInfo->IOTPeer = HT_IOT_PEER_RALINK;
362 else if ((net->atheros_cap_exist) ||
363 (memcmp(net->bssid, DLINK_ATHEROS_1, 3) == 0) ||
364 (memcmp(net->bssid, DLINK_ATHEROS_2, 3) == 0))
365 pHTInfo->IOTPeer = HT_IOT_PEER_ATHEROS;
366 else if ((memcmp(net->bssid, CISCO_BROADCOM, 3) == 0) ||
367 net->cisco_cap_exist)
368 pHTInfo->IOTPeer = HT_IOT_PEER_CISCO;
369 else if ((memcmp(net->bssid, LINKSYS_MARVELL_4400N, 3) == 0) ||
370 net->marvell_cap_exist)
371 pHTInfo->IOTPeer = HT_IOT_PEER_MARVELL;
372 else if (net->airgo_cap_exist)
373 pHTInfo->IOTPeer = HT_IOT_PEER_AIRGO;
374 else
375 pHTInfo->IOTPeer = HT_IOT_PEER_UNKNOWN;
377 RTLLIB_DEBUG(RTLLIB_DL_IOT, "Joseph debug!! IOTPEER: %x\n",
378 pHTInfo->IOTPeer);
381 static u8 HTIOTActIsDisableMCS14(struct rtllib_device *ieee, u8 *PeerMacAddr)
383 return 0;
387 static bool HTIOTActIsDisableMCS15(struct rtllib_device *ieee)
389 bool retValue = false;
391 return retValue;
394 static bool HTIOTActIsDisableMCSTwoSpatialStream(struct rtllib_device *ieee)
396 return false;
399 static u8 HTIOTActIsDisableEDCATurbo(struct rtllib_device *ieee, u8 *PeerMacAddr)
401 return false;
404 static u8 HTIOTActIsMgntUseCCK6M(struct rtllib_device *ieee,
405 struct rtllib_network *network)
407 u8 retValue = 0;
410 if (ieee->pHTInfo->IOTPeer == HT_IOT_PEER_BROADCOM)
411 retValue = 1;
413 return retValue;
416 static u8 HTIOTActIsCCDFsync(struct rtllib_device *ieee)
418 u8 retValue = 0;
420 if (ieee->pHTInfo->IOTPeer == HT_IOT_PEER_BROADCOM)
421 retValue = 1;
422 return retValue;
425 static void HTIOTActDetermineRaFunc(struct rtllib_device *ieee, bool bPeerRx2ss)
427 struct rt_hi_throughput *pHTInfo = ieee->pHTInfo;
428 pHTInfo->IOTRaFunc &= HT_IOT_RAFUNC_DISABLE_ALL;
430 if (pHTInfo->IOTPeer == HT_IOT_PEER_RALINK && !bPeerRx2ss)
431 pHTInfo->IOTRaFunc |= HT_IOT_RAFUNC_PEER_1R;
433 if (pHTInfo->IOTAction & HT_IOT_ACT_AMSDU_ENABLE)
434 pHTInfo->IOTRaFunc |= HT_IOT_RAFUNC_TX_AMSDU;
438 void HTResetIOTSetting(struct rt_hi_throughput *pHTInfo)
440 pHTInfo->IOTAction = 0;
441 pHTInfo->IOTPeer = HT_IOT_PEER_UNKNOWN;
442 pHTInfo->IOTRaFunc = 0;
445 void HTConstructCapabilityElement(struct rtllib_device *ieee, u8 *posHTCap,
446 u8 *len, u8 IsEncrypt, bool bAssoc)
448 struct rt_hi_throughput *pHT = ieee->pHTInfo;
449 struct ht_capab_ele *pCapELE = NULL;
451 if ((posHTCap == NULL) || (pHT == NULL)) {
452 RTLLIB_DEBUG(RTLLIB_DL_ERR, "posHTCap or pHTInfo can't be "
453 "null in HTConstructCapabilityElement()\n");
454 return;
456 memset(posHTCap, 0, *len);
458 if ((bAssoc) && (pHT->ePeerHTSpecVer == HT_SPEC_VER_EWC)) {
459 u8 EWC11NHTCap[] = {0x00, 0x90, 0x4c, 0x33};
460 memcpy(posHTCap, EWC11NHTCap, sizeof(EWC11NHTCap));
461 pCapELE = (struct ht_capab_ele *)&(posHTCap[4]);
462 *len = 30 + 2;
463 } else {
464 pCapELE = (struct ht_capab_ele *)posHTCap;
465 *len = 26 + 2;
468 pCapELE->AdvCoding = 0;
469 if (ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev))
470 pCapELE->ChlWidth = 0;
471 else
472 pCapELE->ChlWidth = (pHT->bRegBW40MHz ? 1 : 0);
474 pCapELE->MimoPwrSave = pHT->SelfMimoPs;
475 pCapELE->GreenField = 0;
476 pCapELE->ShortGI20Mhz = 1;
477 pCapELE->ShortGI40Mhz = 1;
479 pCapELE->TxSTBC = 1;
480 pCapELE->RxSTBC = 0;
481 pCapELE->DelayBA = 0;
482 pCapELE->MaxAMSDUSize = (MAX_RECEIVE_BUFFER_SIZE >= 7935) ? 1 : 0;
483 pCapELE->DssCCk = ((pHT->bRegBW40MHz) ? (pHT->bRegSuppCCK ? 1 : 0) : 0);
484 pCapELE->PSMP = 0;
485 pCapELE->LSigTxopProtect = 0;
488 RTLLIB_DEBUG(RTLLIB_DL_HT, "TX HT cap/info ele BW=%d MaxAMSDUSize:%d "
489 "DssCCk:%d\n", pCapELE->ChlWidth, pCapELE->MaxAMSDUSize,
490 pCapELE->DssCCk);
492 if (IsEncrypt) {
493 pCapELE->MPDUDensity = 7;
494 pCapELE->MaxRxAMPDUFactor = 2;
495 } else {
496 pCapELE->MaxRxAMPDUFactor = 3;
497 pCapELE->MPDUDensity = 0;
500 memcpy(pCapELE->MCS, ieee->Regdot11HTOperationalRateSet, 16);
501 memset(&pCapELE->ExtHTCapInfo, 0, 2);
502 memset(pCapELE->TxBFCap, 0, 4);
504 pCapELE->ASCap = 0;
506 if (bAssoc) {
507 if (pHT->IOTAction & HT_IOT_ACT_DISABLE_MCS15)
508 pCapELE->MCS[1] &= 0x7f;
510 if (pHT->IOTAction & HT_IOT_ACT_DISABLE_MCS14)
511 pCapELE->MCS[1] &= 0xbf;
513 if (pHT->IOTAction & HT_IOT_ACT_DISABLE_ALL_2SS)
514 pCapELE->MCS[1] &= 0x00;
516 if (pHT->IOTAction & HT_IOT_ACT_DISABLE_RX_40MHZ_SHORT_GI)
517 pCapELE->ShortGI40Mhz = 0;
519 if (ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev)) {
520 pCapELE->ChlWidth = 0;
521 pCapELE->MCS[1] = 0;
524 return;
527 void HTConstructInfoElement(struct rtllib_device *ieee, u8 *posHTInfo,
528 u8 *len, u8 IsEncrypt)
530 struct rt_hi_throughput *pHT = ieee->pHTInfo;
531 struct ht_info_ele *pHTInfoEle = (struct ht_info_ele *)posHTInfo;
532 if ((posHTInfo == NULL) || (pHTInfoEle == NULL)) {
533 RTLLIB_DEBUG(RTLLIB_DL_ERR, "posHTInfo or pHTInfoEle can't be "
534 "null in HTConstructInfoElement()\n");
535 return;
538 memset(posHTInfo, 0, *len);
539 if ((ieee->iw_mode == IW_MODE_ADHOC) ||
540 (ieee->iw_mode == IW_MODE_MASTER)) {
541 pHTInfoEle->ControlChl = ieee->current_network.channel;
542 pHTInfoEle->ExtChlOffset = ((pHT->bRegBW40MHz == false) ?
543 HT_EXTCHNL_OFFSET_NO_EXT :
544 (ieee->current_network.channel <= 6)
545 ? HT_EXTCHNL_OFFSET_UPPER :
546 HT_EXTCHNL_OFFSET_LOWER);
547 pHTInfoEle->RecommemdedTxWidth = pHT->bRegBW40MHz;
548 pHTInfoEle->RIFS = 0;
549 pHTInfoEle->PSMPAccessOnly = 0;
550 pHTInfoEle->SrvIntGranularity = 0;
551 pHTInfoEle->OptMode = pHT->CurrentOpMode;
552 pHTInfoEle->NonGFDevPresent = 0;
553 pHTInfoEle->DualBeacon = 0;
554 pHTInfoEle->SecondaryBeacon = 0;
555 pHTInfoEle->LSigTxopProtectFull = 0;
556 pHTInfoEle->PcoActive = 0;
557 pHTInfoEle->PcoPhase = 0;
559 memset(pHTInfoEle->BasicMSC, 0, 16);
562 *len = 22 + 2;
564 } else {
565 *len = 0;
567 return;
570 void HTConstructRT2RTAggElement(struct rtllib_device *ieee, u8 *posRT2RTAgg,
571 u8 *len)
573 if (posRT2RTAgg == NULL) {
574 RTLLIB_DEBUG(RTLLIB_DL_ERR, "posRT2RTAgg can't be null in "
575 "HTConstructRT2RTAggElement()\n");
576 return;
578 memset(posRT2RTAgg, 0, *len);
579 *posRT2RTAgg++ = 0x00;
580 *posRT2RTAgg++ = 0xe0;
581 *posRT2RTAgg++ = 0x4c;
582 *posRT2RTAgg++ = 0x02;
583 *posRT2RTAgg++ = 0x01;
585 *posRT2RTAgg = 0x30;
587 if (ieee->bSupportRemoteWakeUp)
588 *posRT2RTAgg |= RT_HT_CAP_USE_WOW;
590 *len = 6 + 2;
592 return;
595 static u8 HT_PickMCSRate(struct rtllib_device *ieee, u8 *pOperateMCS)
597 u8 i;
598 if (pOperateMCS == NULL) {
599 RTLLIB_DEBUG(RTLLIB_DL_ERR, "pOperateMCS can't be null"
600 " in HT_PickMCSRate()\n");
601 return false;
604 switch (ieee->mode) {
605 case IEEE_A:
606 case IEEE_B:
607 case IEEE_G:
608 for (i = 0; i <= 15; i++)
609 pOperateMCS[i] = 0;
610 break;
611 case IEEE_N_24G:
612 case IEEE_N_5G:
613 pOperateMCS[0] &= RATE_ADPT_1SS_MASK;
614 pOperateMCS[1] &= RATE_ADPT_2SS_MASK;
615 pOperateMCS[3] &= RATE_ADPT_MCS32_MASK;
616 break;
617 default:
618 break;
622 return true;
625 u8 HTGetHighestMCSRate(struct rtllib_device *ieee, u8 *pMCSRateSet,
626 u8 *pMCSFilter)
628 u8 i, j;
629 u8 bitMap;
630 u8 mcsRate = 0;
631 u8 availableMcsRate[16];
632 if (pMCSRateSet == NULL || pMCSFilter == NULL) {
633 RTLLIB_DEBUG(RTLLIB_DL_ERR, "pMCSRateSet or pMCSFilter can't "
634 "be null in HTGetHighestMCSRate()\n");
635 return false;
637 for (i = 0; i < 16; i++)
638 availableMcsRate[i] = pMCSRateSet[i] & pMCSFilter[i];
640 for (i = 0; i < 16; i++) {
641 if (availableMcsRate[i] != 0)
642 break;
644 if (i == 16)
645 return false;
647 for (i = 0; i < 16; i++) {
648 if (availableMcsRate[i] != 0) {
649 bitMap = availableMcsRate[i];
650 for (j = 0; j < 8; j++) {
651 if ((bitMap%2) != 0) {
652 if (HTMcsToDataRate(ieee, (8*i+j)) >
653 HTMcsToDataRate(ieee, mcsRate))
654 mcsRate = (8*i+j);
656 bitMap = bitMap>>1;
660 return mcsRate | 0x80;
663 u8 HTFilterMCSRate(struct rtllib_device *ieee, u8 *pSupportMCS, u8 *pOperateMCS)
666 u8 i;
668 for (i = 0; i <= 15; i++)
669 pOperateMCS[i] = ieee->Regdot11TxHTOperationalRateSet[i] &
670 pSupportMCS[i];
672 HT_PickMCSRate(ieee, pOperateMCS);
674 if (ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev))
675 pOperateMCS[1] = 0;
677 for (i = 2; i <= 15; i++)
678 pOperateMCS[i] = 0;
680 return true;
683 void HTSetConnectBwMode(struct rtllib_device *ieee,
684 enum ht_channel_width Bandwidth,
685 enum ht_extchnl_offset Offset);
687 void HTOnAssocRsp(struct rtllib_device *ieee)
689 struct rt_hi_throughput *pHTInfo = ieee->pHTInfo;
690 struct ht_capab_ele *pPeerHTCap = NULL;
691 struct ht_info_ele *pPeerHTInfo = NULL;
692 u16 nMaxAMSDUSize = 0;
693 u8 *pMcsFilter = NULL;
695 static u8 EWC11NHTCap[] = {0x00, 0x90, 0x4c, 0x33};
696 static u8 EWC11NHTInfo[] = {0x00, 0x90, 0x4c, 0x34};
698 if (pHTInfo->bCurrentHTSupport == false) {
699 RTLLIB_DEBUG(RTLLIB_DL_ERR, "<=== HTOnAssocRsp(): "
700 "HT_DISABLE\n");
701 return;
703 RTLLIB_DEBUG(RTLLIB_DL_HT, "===> HTOnAssocRsp_wq(): HT_ENABLE\n");
705 if (!memcmp(pHTInfo->PeerHTCapBuf, EWC11NHTCap, sizeof(EWC11NHTCap)))
706 pPeerHTCap = (struct ht_capab_ele *)(&pHTInfo->PeerHTCapBuf[4]);
707 else
708 pPeerHTCap = (struct ht_capab_ele *)(pHTInfo->PeerHTCapBuf);
710 if (!memcmp(pHTInfo->PeerHTInfoBuf, EWC11NHTInfo, sizeof(EWC11NHTInfo)))
711 pPeerHTInfo = (struct ht_info_ele *)
712 (&pHTInfo->PeerHTInfoBuf[4]);
713 else
714 pPeerHTInfo = (struct ht_info_ele *)(pHTInfo->PeerHTInfoBuf);
716 RTLLIB_DEBUG_DATA(RTLLIB_DL_DATA | RTLLIB_DL_HT, pPeerHTCap,
717 sizeof(struct ht_capab_ele));
718 HTSetConnectBwMode(ieee, (enum ht_channel_width)(pPeerHTCap->ChlWidth),
719 (enum ht_extchnl_offset)(pPeerHTInfo->ExtChlOffset));
720 pHTInfo->bCurTxBW40MHz = ((pPeerHTInfo->RecommemdedTxWidth == 1) ?
721 true : false);
723 pHTInfo->bCurShortGI20MHz = ((pHTInfo->bRegShortGI20MHz) ?
724 ((pPeerHTCap->ShortGI20Mhz == 1) ?
725 true : false) : false);
726 pHTInfo->bCurShortGI40MHz = ((pHTInfo->bRegShortGI40MHz) ?
727 ((pPeerHTCap->ShortGI40Mhz == 1) ?
728 true : false) : false);
730 pHTInfo->bCurSuppCCK = ((pHTInfo->bRegSuppCCK) ?
731 ((pPeerHTCap->DssCCk == 1) ? true :
732 false) : false);
735 pHTInfo->bCurrent_AMSDU_Support = pHTInfo->bAMSDU_Support;
737 nMaxAMSDUSize = (pPeerHTCap->MaxAMSDUSize == 0) ? 3839 : 7935;
739 if (pHTInfo->nAMSDU_MaxSize > nMaxAMSDUSize)
740 pHTInfo->nCurrent_AMSDU_MaxSize = nMaxAMSDUSize;
741 else
742 pHTInfo->nCurrent_AMSDU_MaxSize = pHTInfo->nAMSDU_MaxSize;
744 pHTInfo->bCurrentAMPDUEnable = pHTInfo->bAMPDUEnable;
745 if (ieee->rtllib_ap_sec_type &&
746 (ieee->rtllib_ap_sec_type(ieee)&(SEC_ALG_WEP|SEC_ALG_TKIP))) {
747 if ((pHTInfo->IOTPeer == HT_IOT_PEER_ATHEROS) ||
748 (pHTInfo->IOTPeer == HT_IOT_PEER_UNKNOWN))
749 pHTInfo->bCurrentAMPDUEnable = false;
752 if (!pHTInfo->bRegRT2RTAggregation) {
753 if (pHTInfo->AMPDU_Factor > pPeerHTCap->MaxRxAMPDUFactor)
754 pHTInfo->CurrentAMPDUFactor =
755 pPeerHTCap->MaxRxAMPDUFactor;
756 else
757 pHTInfo->CurrentAMPDUFactor = pHTInfo->AMPDU_Factor;
759 } else {
760 if (ieee->current_network.bssht.bdRT2RTAggregation) {
761 if (ieee->pairwise_key_type != KEY_TYPE_NA)
762 pHTInfo->CurrentAMPDUFactor =
763 pPeerHTCap->MaxRxAMPDUFactor;
764 else
765 pHTInfo->CurrentAMPDUFactor = HT_AGG_SIZE_64K;
766 } else {
767 if (pPeerHTCap->MaxRxAMPDUFactor < HT_AGG_SIZE_32K)
768 pHTInfo->CurrentAMPDUFactor =
769 pPeerHTCap->MaxRxAMPDUFactor;
770 else
771 pHTInfo->CurrentAMPDUFactor = HT_AGG_SIZE_32K;
774 if (pHTInfo->MPDU_Density > pPeerHTCap->MPDUDensity)
775 pHTInfo->CurrentMPDUDensity = pHTInfo->MPDU_Density;
776 else
777 pHTInfo->CurrentMPDUDensity = pPeerHTCap->MPDUDensity;
778 if (pHTInfo->IOTAction & HT_IOT_ACT_TX_USE_AMSDU_8K) {
779 pHTInfo->bCurrentAMPDUEnable = false;
780 pHTInfo->ForcedAMSDUMode = HT_AGG_FORCE_ENABLE;
781 pHTInfo->ForcedAMSDUMaxSize = 7935;
783 pHTInfo->bCurRxReorderEnable = pHTInfo->bRegRxReorderEnable;
785 if (pPeerHTCap->MCS[0] == 0)
786 pPeerHTCap->MCS[0] = 0xff;
788 HTIOTActDetermineRaFunc(ieee, ((pPeerHTCap->MCS[1]) != 0));
790 HTFilterMCSRate(ieee, pPeerHTCap->MCS, ieee->dot11HTOperationalRateSet);
792 pHTInfo->PeerMimoPs = pPeerHTCap->MimoPwrSave;
793 if (pHTInfo->PeerMimoPs == MIMO_PS_STATIC)
794 pMcsFilter = MCS_FILTER_1SS;
795 else
796 pMcsFilter = MCS_FILTER_ALL;
797 ieee->HTHighestOperaRate = HTGetHighestMCSRate(ieee,
798 ieee->dot11HTOperationalRateSet, pMcsFilter);
799 ieee->HTCurrentOperaRate = ieee->HTHighestOperaRate;
801 pHTInfo->CurrentOpMode = pPeerHTInfo->OptMode;
804 void HTInitializeHTInfo(struct rtllib_device *ieee)
806 struct rt_hi_throughput *pHTInfo = ieee->pHTInfo;
808 RTLLIB_DEBUG(RTLLIB_DL_HT, "===========>%s()\n", __func__);
809 pHTInfo->bCurrentHTSupport = false;
811 pHTInfo->bCurBW40MHz = false;
812 pHTInfo->bCurTxBW40MHz = false;
814 pHTInfo->bCurShortGI20MHz = false;
815 pHTInfo->bCurShortGI40MHz = false;
816 pHTInfo->bForcedShortGI = false;
818 pHTInfo->bCurSuppCCK = true;
820 pHTInfo->bCurrent_AMSDU_Support = false;
821 pHTInfo->nCurrent_AMSDU_MaxSize = pHTInfo->nAMSDU_MaxSize;
822 pHTInfo->CurrentMPDUDensity = pHTInfo->MPDU_Density;
823 pHTInfo->CurrentAMPDUFactor = pHTInfo->AMPDU_Factor;
825 memset((void *)(&(pHTInfo->SelfHTCap)), 0,
826 sizeof(pHTInfo->SelfHTCap));
827 memset((void *)(&(pHTInfo->SelfHTInfo)), 0,
828 sizeof(pHTInfo->SelfHTInfo));
829 memset((void *)(&(pHTInfo->PeerHTCapBuf)), 0,
830 sizeof(pHTInfo->PeerHTCapBuf));
831 memset((void *)(&(pHTInfo->PeerHTInfoBuf)), 0,
832 sizeof(pHTInfo->PeerHTInfoBuf));
834 pHTInfo->bSwBwInProgress = false;
835 pHTInfo->ChnlOp = CHNLOP_NONE;
837 pHTInfo->ePeerHTSpecVer = HT_SPEC_VER_IEEE;
839 pHTInfo->bCurrentRT2RTAggregation = false;
840 pHTInfo->bCurrentRT2RTLongSlotTime = false;
841 pHTInfo->RT2RT_HT_Mode = (enum rt_ht_capability)0;
843 pHTInfo->IOTPeer = 0;
844 pHTInfo->IOTAction = 0;
845 pHTInfo->IOTRaFunc = 0;
848 u8 *RegHTSuppRateSets = &(ieee->RegHTSuppRateSet[0]);
849 RegHTSuppRateSets[0] = 0xFF;
850 RegHTSuppRateSets[1] = 0xFF;
851 RegHTSuppRateSets[4] = 0x01;
855 void HTInitializeBssDesc(struct bss_ht *pBssHT)
858 pBssHT->bdSupportHT = false;
859 memset(pBssHT->bdHTCapBuf, 0, sizeof(pBssHT->bdHTCapBuf));
860 pBssHT->bdHTCapLen = 0;
861 memset(pBssHT->bdHTInfoBuf, 0, sizeof(pBssHT->bdHTInfoBuf));
862 pBssHT->bdHTInfoLen = 0;
864 pBssHT->bdHTSpecVer = HT_SPEC_VER_IEEE;
866 pBssHT->bdRT2RTAggregation = false;
867 pBssHT->bdRT2RTLongSlotTime = false;
868 pBssHT->RT2RT_HT_Mode = (enum rt_ht_capability)0;
871 void HTResetSelfAndSavePeerSetting(struct rtllib_device *ieee,
872 struct rtllib_network *pNetwork)
874 struct rt_hi_throughput *pHTInfo = ieee->pHTInfo;
875 u8 bIOTAction = 0;
877 RTLLIB_DEBUG(RTLLIB_DL_HT, "==============>%s()\n", __func__);
878 /* unmark bEnableHT flag here is the same reason why unmarked in
879 * function rtllib_softmac_new_net. WB 2008.09.10*/
880 if (pNetwork->bssht.bdSupportHT) {
881 pHTInfo->bCurrentHTSupport = true;
882 pHTInfo->ePeerHTSpecVer = pNetwork->bssht.bdHTSpecVer;
884 if (pNetwork->bssht.bdHTCapLen > 0 &&
885 pNetwork->bssht.bdHTCapLen <= sizeof(pHTInfo->PeerHTCapBuf))
886 memcpy(pHTInfo->PeerHTCapBuf,
887 pNetwork->bssht.bdHTCapBuf,
888 pNetwork->bssht.bdHTCapLen);
890 if (pNetwork->bssht.bdHTInfoLen > 0 &&
891 pNetwork->bssht.bdHTInfoLen <=
892 sizeof(pHTInfo->PeerHTInfoBuf))
893 memcpy(pHTInfo->PeerHTInfoBuf,
894 pNetwork->bssht.bdHTInfoBuf,
895 pNetwork->bssht.bdHTInfoLen);
897 if (pHTInfo->bRegRT2RTAggregation) {
898 pHTInfo->bCurrentRT2RTAggregation =
899 pNetwork->bssht.bdRT2RTAggregation;
900 pHTInfo->bCurrentRT2RTLongSlotTime =
901 pNetwork->bssht.bdRT2RTLongSlotTime;
902 pHTInfo->RT2RT_HT_Mode = pNetwork->bssht.RT2RT_HT_Mode;
903 } else {
904 pHTInfo->bCurrentRT2RTAggregation = false;
905 pHTInfo->bCurrentRT2RTLongSlotTime = false;
906 pHTInfo->RT2RT_HT_Mode = (enum rt_ht_capability)0;
909 HTIOTPeerDetermine(ieee);
911 pHTInfo->IOTAction = 0;
912 bIOTAction = HTIOTActIsDisableMCS14(ieee, pNetwork->bssid);
913 if (bIOTAction)
914 pHTInfo->IOTAction |= HT_IOT_ACT_DISABLE_MCS14;
916 bIOTAction = HTIOTActIsDisableMCS15(ieee);
917 if (bIOTAction)
918 pHTInfo->IOTAction |= HT_IOT_ACT_DISABLE_MCS15;
920 bIOTAction = HTIOTActIsDisableMCSTwoSpatialStream(ieee);
921 if (bIOTAction)
922 pHTInfo->IOTAction |= HT_IOT_ACT_DISABLE_ALL_2SS;
925 bIOTAction = HTIOTActIsDisableEDCATurbo(ieee, pNetwork->bssid);
926 if (bIOTAction)
927 pHTInfo->IOTAction |= HT_IOT_ACT_DISABLE_EDCA_TURBO;
929 bIOTAction = HTIOTActIsMgntUseCCK6M(ieee, pNetwork);
930 if (bIOTAction)
931 pHTInfo->IOTAction |= HT_IOT_ACT_MGNT_USE_CCK_6M;
932 bIOTAction = HTIOTActIsCCDFsync(ieee);
933 if (bIOTAction)
934 pHTInfo->IOTAction |= HT_IOT_ACT_CDD_FSYNC;
935 } else {
936 pHTInfo->bCurrentHTSupport = false;
937 pHTInfo->bCurrentRT2RTAggregation = false;
938 pHTInfo->bCurrentRT2RTLongSlotTime = false;
939 pHTInfo->RT2RT_HT_Mode = (enum rt_ht_capability)0;
941 pHTInfo->IOTAction = 0;
942 pHTInfo->IOTRaFunc = 0;
946 void HT_update_self_and_peer_setting(struct rtllib_device *ieee,
947 struct rtllib_network *pNetwork)
949 struct rt_hi_throughput *pHTInfo = ieee->pHTInfo;
950 struct ht_info_ele *pPeerHTInfo =
951 (struct ht_info_ele *)pNetwork->bssht.bdHTInfoBuf;
953 if (pHTInfo->bCurrentHTSupport) {
954 if (pNetwork->bssht.bdHTInfoLen != 0)
955 pHTInfo->CurrentOpMode = pPeerHTInfo->OptMode;
958 EXPORT_SYMBOL(HT_update_self_and_peer_setting);
960 void HTUseDefaultSetting(struct rtllib_device *ieee)
962 struct rt_hi_throughput *pHTInfo = ieee->pHTInfo;
964 if (pHTInfo->bEnableHT) {
965 pHTInfo->bCurrentHTSupport = true;
966 pHTInfo->bCurSuppCCK = pHTInfo->bRegSuppCCK;
968 pHTInfo->bCurBW40MHz = pHTInfo->bRegBW40MHz;
969 pHTInfo->bCurShortGI20MHz = pHTInfo->bRegShortGI20MHz;
971 pHTInfo->bCurShortGI40MHz = pHTInfo->bRegShortGI40MHz;
973 if (ieee->iw_mode == IW_MODE_ADHOC)
974 ieee->current_network.qos_data.active =
975 ieee->current_network.qos_data.supported;
976 pHTInfo->bCurrent_AMSDU_Support = pHTInfo->bAMSDU_Support;
977 pHTInfo->nCurrent_AMSDU_MaxSize = pHTInfo->nAMSDU_MaxSize;
979 pHTInfo->bCurrentAMPDUEnable = pHTInfo->bAMPDUEnable;
980 pHTInfo->CurrentAMPDUFactor = pHTInfo->AMPDU_Factor;
982 pHTInfo->CurrentMPDUDensity = pHTInfo->CurrentMPDUDensity;
984 HTFilterMCSRate(ieee, ieee->Regdot11TxHTOperationalRateSet,
985 ieee->dot11HTOperationalRateSet);
986 ieee->HTHighestOperaRate = HTGetHighestMCSRate(ieee,
987 ieee->dot11HTOperationalRateSet,
988 MCS_FILTER_ALL);
989 ieee->HTCurrentOperaRate = ieee->HTHighestOperaRate;
991 } else {
992 pHTInfo->bCurrentHTSupport = false;
994 return;
997 u8 HTCCheck(struct rtllib_device *ieee, u8 *pFrame)
999 if (ieee->pHTInfo->bCurrentHTSupport) {
1000 if ((IsQoSDataFrame(pFrame) && Frame_Order(pFrame)) == 1) {
1001 RTLLIB_DEBUG(RTLLIB_DL_HT, "HT CONTROL FILED "
1002 "EXIST!!\n");
1003 return true;
1006 return false;
1009 static void HTSetConnectBwModeCallback(struct rtllib_device *ieee)
1011 struct rt_hi_throughput *pHTInfo = ieee->pHTInfo;
1013 RTLLIB_DEBUG(RTLLIB_DL_HT, "======>%s()\n", __func__);
1014 if (pHTInfo->bCurBW40MHz) {
1015 if (pHTInfo->CurSTAExtChnlOffset == HT_EXTCHNL_OFFSET_UPPER)
1016 ieee->set_chan(ieee->dev,
1017 ieee->current_network.channel + 2);
1018 else if (pHTInfo->CurSTAExtChnlOffset ==
1019 HT_EXTCHNL_OFFSET_LOWER)
1020 ieee->set_chan(ieee->dev,
1021 ieee->current_network.channel - 2);
1022 else
1023 ieee->set_chan(ieee->dev,
1024 ieee->current_network.channel);
1026 ieee->SetBWModeHandler(ieee->dev, HT_CHANNEL_WIDTH_20_40,
1027 pHTInfo->CurSTAExtChnlOffset);
1028 } else {
1029 ieee->set_chan(ieee->dev, ieee->current_network.channel);
1030 ieee->SetBWModeHandler(ieee->dev, HT_CHANNEL_WIDTH_20,
1031 HT_EXTCHNL_OFFSET_NO_EXT);
1034 pHTInfo->bSwBwInProgress = false;
1037 void HTSetConnectBwMode(struct rtllib_device *ieee,
1038 enum ht_channel_width Bandwidth,
1039 enum ht_extchnl_offset Offset)
1041 struct rt_hi_throughput *pHTInfo = ieee->pHTInfo;
1043 if (pHTInfo->bRegBW40MHz == false)
1044 return;
1046 if (ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev))
1047 Bandwidth = HT_CHANNEL_WIDTH_20;
1049 if (pHTInfo->bSwBwInProgress) {
1050 printk(KERN_INFO "%s: bSwBwInProgress!!\n", __func__);
1051 return;
1053 if (Bandwidth == HT_CHANNEL_WIDTH_20_40) {
1054 if (ieee->current_network.channel < 2 &&
1055 Offset == HT_EXTCHNL_OFFSET_LOWER)
1056 Offset = HT_EXTCHNL_OFFSET_NO_EXT;
1057 if (Offset == HT_EXTCHNL_OFFSET_UPPER ||
1058 Offset == HT_EXTCHNL_OFFSET_LOWER) {
1059 pHTInfo->bCurBW40MHz = true;
1060 pHTInfo->CurSTAExtChnlOffset = Offset;
1061 } else {
1062 pHTInfo->bCurBW40MHz = false;
1063 pHTInfo->CurSTAExtChnlOffset = HT_EXTCHNL_OFFSET_NO_EXT;
1065 } else {
1066 pHTInfo->bCurBW40MHz = false;
1067 pHTInfo->CurSTAExtChnlOffset = HT_EXTCHNL_OFFSET_NO_EXT;
1070 printk(KERN_INFO "%s():pHTInfo->bCurBW40MHz:%x\n", __func__,
1071 pHTInfo->bCurBW40MHz);
1073 pHTInfo->bSwBwInProgress = true;
1075 HTSetConnectBwModeCallback(ieee);