1 // SPDX-License-Identifier: GPL-2.0
4 * As this function is mainly ported from Windows driver, so leave the name
5 * little changed. If any confusion caused, tell me. Created by WB. 2008.05.08
9 u8 MCS_FILTER_ALL[16] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
11 u8 MCS_FILTER_1SS[16] = {0xff, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
13 u16 MCS_DATA_RATE[2][2][77] = {
14 { {13, 26, 39, 52, 78, 104, 117, 130, 26, 52, 78, 104, 156, 208, 234, 260,
15 39, 78, 117, 234, 312, 351, 390, 52, 104, 156, 208, 312, 416, 468, 520,
16 0, 78, 104, 130, 117, 156, 195, 104, 130, 130, 156, 182, 182, 208, 156, 195,
17 195, 234, 273, 273, 312, 130, 156, 181, 156, 181, 208, 234, 208, 234, 260, 260,
18 286, 195, 234, 273, 234, 273, 312, 351, 312, 351, 390, 390, 429}, // Long GI, 20MHz
19 {14, 29, 43, 58, 87, 116, 130, 144, 29, 58, 87, 116, 173, 231, 260, 289,
20 43, 87, 130, 173, 260, 347, 390, 433, 58, 116, 173, 231, 347, 462, 520, 578,
21 0, 87, 116, 144, 130, 173, 217, 116, 144, 144, 173, 202, 202, 231, 173, 217,
22 217, 260, 303, 303, 347, 144, 173, 202, 173, 202, 231, 260, 231, 260, 289, 289,
23 318, 217, 260, 303, 260, 303, 347, 390, 347, 390, 433, 433, 477} }, // Short GI, 20MHz
24 { {27, 54, 81, 108, 162, 216, 243, 270, 54, 108, 162, 216, 324, 432, 486, 540,
25 81, 162, 243, 324, 486, 648, 729, 810, 108, 216, 324, 432, 648, 864, 972, 1080,
26 12, 162, 216, 270, 243, 324, 405, 216, 270, 270, 324, 378, 378, 432, 324, 405,
27 405, 486, 567, 567, 648, 270, 324, 378, 324, 378, 432, 486, 432, 486, 540, 540,
28 594, 405, 486, 567, 486, 567, 648, 729, 648, 729, 810, 810, 891}, // Long GI, 40MHz
29 {30, 60, 90, 120, 180, 240, 270, 300, 60, 120, 180, 240, 360, 480, 540, 600,
30 90, 180, 270, 360, 540, 720, 810, 900, 120, 240, 360, 480, 720, 960, 1080, 1200,
31 13, 180, 240, 300, 270, 360, 450, 240, 300, 300, 360, 420, 420, 480, 360, 450,
32 450, 540, 630, 630, 720, 300, 360, 420, 360, 420, 480, 540, 480, 540, 600, 600,
33 660, 450, 540, 630, 540, 630, 720, 810, 720, 810, 900, 900, 990} } // Short GI, 40MHz
36 static u8 UNKNOWN_BORADCOM[3] = {0x00, 0x14, 0xbf};
37 static u8 LINKSYSWRT330_LINKSYSWRT300_BROADCOM[3] = {0x00, 0x1a, 0x70};
38 static u8 LINKSYSWRT350_LINKSYSWRT150_BROADCOM[3] = {0x00, 0x1d, 0x7e};
39 static u8 NETGEAR834Bv2_BROADCOM[3] = {0x00, 0x1b, 0x2f};
40 static u8 BELKINF5D8233V1_RALINK[3] = {0x00, 0x17, 0x3f}; //cosa 03202008
41 static u8 BELKINF5D82334V3_RALINK[3] = {0x00, 0x1c, 0xdf};
42 static u8 PCI_RALINK[3] = {0x00, 0x90, 0xcc};
43 static u8 EDIMAX_RALINK[3] = {0x00, 0x0e, 0x2e};
44 static u8 AIRLINK_RALINK[3] = {0x00, 0x18, 0x02};
45 //static u8 DLINK_ATHEROS[3] = {0x00, 0x1c, 0xf0};
46 static u8 CISCO_BROADCOM[3] = {0x00, 0x17, 0x94};
48 * 2008/04/01 MH For Cisco G mode RX TP We need to change FW duration. Should we
49 * put the code in other place??
50 * static u8 WIFI_CISCO_G_AP[3] = {0x00, 0x40, 0x96};
53 *function: This function update default settings in pHTInfo structure
54 * input: PRT_HIGH_THROUGHPUT pHTInfo
57 * notice: These value need be modified if any changes.
59 void HTUpdateDefaultSetting(struct ieee80211_device *ieee)
61 PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
62 //const typeof( ((struct ieee80211_device *)0)->pHTInfo ) *__mptr = &pHTInfo;
64 //printk("pHTinfo:%p, &pHTinfo:%p, mptr:%p, offsetof:%x\n", pHTInfo, &pHTInfo, __mptr, offsetof(struct ieee80211_device, pHTInfo));
65 //printk("===>ieee:%p,\n", ieee);
67 pHTInfo->bRegShortGI20MHz = 1;
68 pHTInfo->bRegShortGI40MHz = 1;
70 // 40MHz channel support
71 pHTInfo->bRegBW40MHz = 1;
73 // CCK rate support in 40MHz channel
74 if (pHTInfo->bRegBW40MHz)
75 pHTInfo->bRegSuppCCK = 1;
77 pHTInfo->bRegSuppCCK = true;
80 pHTInfo->nAMSDU_MaxSize = 7935UL;
81 pHTInfo->bAMSDU_Support = 0;
84 pHTInfo->bAMPDUEnable = 1;
85 pHTInfo->AMPDU_Factor = 2; //// 0: 2n13(8K), 1:2n14(16K), 2:2n15(32K), 3:2n16(64k)
86 pHTInfo->MPDU_Density = 0;// 0: No restriction, 1: 1/8usec, 2: 1/4usec, 3: 1/2usec, 4: 1usec, 5: 2usec, 6: 4usec, 7:8usec
89 pHTInfo->SelfMimoPs = 3;// 0: Static Mimo Ps, 1: Dynamic Mimo Ps, 3: No Limitation, 2: Reserved(Set to 3 automatically.)
90 if (pHTInfo->SelfMimoPs == 2)
91 pHTInfo->SelfMimoPs = 3;
92 // 8190 only. Assign rate operation mode to firmware
93 ieee->bTxDisableRateFallBack = 0;
94 ieee->bTxUseDriverAssingedRate = 0;
97 // 8190 only. Assign duration operation mode to firmware
98 pMgntInfo->bTxEnableFwCalcDur = (BOOLEAN)pNdisCommon->bRegTxEnableFwCalcDur;
101 * 8190 only, Realtek proprietary aggregation mode
102 * Set MPDUDensity=2, 1: Set MPDUDensity=2(32k) for Realtek AP and set MPDUDensity=0(8k) for others
104 pHTInfo->bRegRT2RTAggregation = 1;//0: Set MPDUDensity=2, 1: Set MPDUDensity=2(32k) for Realtek AP and set MPDUDensity=0(8k) for others
106 // For Rx Reorder Control
107 pHTInfo->bRegRxReorderEnable = 1;
108 pHTInfo->RxReorderWinSize = 64;
109 pHTInfo->RxReorderPendingTime = 30;
111 #ifdef USB_TX_DRIVER_AGGREGATION_ENABLE
112 pHTInfo->UsbTxAggrNum = 4;
114 #ifdef USB_RX_AGGREGATION_SUPPORT
115 pHTInfo->UsbRxFwAggrEn = 1;
116 pHTInfo->UsbRxFwAggrPageNum = 24;
117 pHTInfo->UsbRxFwAggrPacketNum = 8;
118 pHTInfo->UsbRxFwAggrTimeout = 16; ////usb rx FW aggregation timeout threshold.It's in units of 64us
123 *function: This function print out each field on HT capability
124 * IE mainly from (Beacon/ProbeRsp/AssocReq)
125 * input: u8* CapIE //Capability IE to be printed out
126 * u8* TitleString //mainly print out caller function
129 * notice: Driver should not print out this message by default.
131 void HTDebugHTCapability(u8 *CapIE, u8 *TitleString)
133 static u8 EWC11NHTCap[] = {0x00, 0x90, 0x4c, 0x33}; // For 11n EWC definition, 2007.07.17, by Emily
134 struct ht_capability_ele *pCapELE;
136 if (!memcmp(CapIE, EWC11NHTCap, sizeof(EWC11NHTCap))) {
138 IEEE80211_DEBUG(IEEE80211_DL_HT, "EWC IE in %s()\n", __func__);
139 pCapELE = (struct ht_capability_ele *)(&CapIE[4]);
141 pCapELE = (struct ht_capability_ele *)(&CapIE[0]);
143 IEEE80211_DEBUG(IEEE80211_DL_HT, "<Log HT Capability>. Called by %s\n", TitleString);
145 IEEE80211_DEBUG(IEEE80211_DL_HT, "\tSupported Channel Width = %s\n", (pCapELE->ChlWidth) ? "20MHz" : "20/40MHz");
146 IEEE80211_DEBUG(IEEE80211_DL_HT, "\tSupport Short GI for 20M = %s\n", (pCapELE->ShortGI20Mhz) ? "YES" : "NO");
147 IEEE80211_DEBUG(IEEE80211_DL_HT, "\tSupport Short GI for 40M = %s\n", (pCapELE->ShortGI40Mhz) ? "YES" : "NO");
148 IEEE80211_DEBUG(IEEE80211_DL_HT, "\tSupport TX STBC = %s\n", (pCapELE->TxSTBC) ? "YES" : "NO");
149 IEEE80211_DEBUG(IEEE80211_DL_HT, "\tMax AMSDU Size = %s\n", (pCapELE->MaxAMSDUSize) ? "3839" : "7935");
150 IEEE80211_DEBUG(IEEE80211_DL_HT, "\tSupport CCK in 20/40 mode = %s\n", (pCapELE->DssCCk) ? "YES" : "NO");
151 IEEE80211_DEBUG(IEEE80211_DL_HT, "\tMax AMPDU Factor = %d\n", pCapELE->MaxRxAMPDUFactor);
152 IEEE80211_DEBUG(IEEE80211_DL_HT, "\tMPDU Density = %d\n", pCapELE->MPDUDensity);
153 IEEE80211_DEBUG(IEEE80211_DL_HT, "\tMCS Rate Set = [%x][%x][%x][%x][%x]\n", pCapELE->MCS[0],\
154 pCapELE->MCS[1], pCapELE->MCS[2], pCapELE->MCS[3], pCapELE->MCS[4]);
158 *function: This function print out each field on HT Information
159 * IE mainly from (Beacon/ProbeRsp)
160 * input: u8* InfoIE //Capability IE to be printed out
161 * u8* TitleString //mainly print out caller function
164 * notice: Driver should not print out this message by default.
166 void HTDebugHTInfo(u8 *InfoIE, u8 *TitleString)
168 static u8 EWC11NHTInfo[] = {0x00, 0x90, 0x4c, 0x34}; // For 11n EWC definition, 2007.07.17, by Emily
169 PHT_INFORMATION_ELE pHTInfoEle;
171 if (!memcmp(InfoIE, EWC11NHTInfo, sizeof(EWC11NHTInfo))) {
173 IEEE80211_DEBUG(IEEE80211_DL_HT, "EWC IE in %s()\n", __func__);
174 pHTInfoEle = (PHT_INFORMATION_ELE)(&InfoIE[4]);
176 pHTInfoEle = (PHT_INFORMATION_ELE)(&InfoIE[0]);
179 IEEE80211_DEBUG(IEEE80211_DL_HT, "<Log HT Information Element>. Called by %s\n", TitleString);
181 IEEE80211_DEBUG(IEEE80211_DL_HT, "\tPrimary channel = %d\n", pHTInfoEle->ControlChl);
182 IEEE80211_DEBUG(IEEE80211_DL_HT, "\tSecondary channel =");
183 switch (pHTInfoEle->ExtChlOffset) {
185 IEEE80211_DEBUG(IEEE80211_DL_HT, "Not Present\n");
188 IEEE80211_DEBUG(IEEE80211_DL_HT, "Upper channel\n");
191 IEEE80211_DEBUG(IEEE80211_DL_HT, "Reserved. Eooro!!!\n");
194 IEEE80211_DEBUG(IEEE80211_DL_HT, "Lower Channel\n");
197 IEEE80211_DEBUG(IEEE80211_DL_HT, "\tRecommended channel width = %s\n", (pHTInfoEle->RecommemdedTxWidth) ? "20Mhz" : "40Mhz");
199 IEEE80211_DEBUG(IEEE80211_DL_HT, "\tOperation mode for protection = ");
200 switch (pHTInfoEle->OptMode) {
202 IEEE80211_DEBUG(IEEE80211_DL_HT, "No Protection\n");
205 IEEE80211_DEBUG(IEEE80211_DL_HT, "HT non-member protection mode\n");
208 IEEE80211_DEBUG(IEEE80211_DL_HT, "Suggest to open protection\n");
211 IEEE80211_DEBUG(IEEE80211_DL_HT, "HT mixed mode\n");
215 IEEE80211_DEBUG(IEEE80211_DL_HT, "\tBasic MCS Rate Set = [%x][%x][%x][%x][%x]\n", pHTInfoEle->BasicMSC[0],\
216 pHTInfoEle->BasicMSC[1], pHTInfoEle->BasicMSC[2], pHTInfoEle->BasicMSC[3], pHTInfoEle->BasicMSC[4]);
219 static u16 HTMcsToDataRate(struct ieee80211_device *ieee, u8 nMcsRate)
221 PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
223 u8 is40MHz = (pHTInfo->bCurBW40MHz) ? 1 : 0;
224 u8 isShortGI = (pHTInfo->bCurBW40MHz) ?
225 ((pHTInfo->bCurShortGI40MHz) ? 1 : 0) :
226 ((pHTInfo->bCurShortGI20MHz) ? 1 : 0);
227 return MCS_DATA_RATE[is40MHz][isShortGI][(nMcsRate & 0x7f)];
231 *function: This function returns current datarate.
232 * input: struct ieee80211_device* ieee
236 * notice: quite unsure about how to use this function //wb
238 u16 TxCountToDataRate(struct ieee80211_device *ieee, u8 nDataRate)
240 //PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
241 u16 CCKOFDMRate[12] = {0x02, 0x04, 0x0b, 0x16, 0x0c, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6c};
245 if (nDataRate < 12) {
246 return CCKOFDMRate[nDataRate];
248 if (nDataRate >= 0x10 && nDataRate <= 0x1f) { //if(nDataRate > 11 && nDataRate < 28 )
252 // nDataRate = nDataRate - 12;
253 } else if (nDataRate >= 0x20 && nDataRate <= 0x2f) { //(27, 44)
257 //nDataRate = nDataRate - 28;
258 } else if (nDataRate >= 0x30 && nDataRate <= 0x3f) { //(43, 60)
262 //nDataRate = nDataRate - 44;
263 } else if (nDataRate >= 0x40 && nDataRate <= 0x4f) { //(59, 76)
267 //nDataRate = nDataRate - 60;
269 return MCS_DATA_RATE[is40MHz][isShortGI][nDataRate & 0xf];
273 bool IsHTHalfNmodeAPs(struct ieee80211_device *ieee)
275 bool retValue = false;
276 struct ieee80211_network *net = &ieee->current_network;
278 if ((memcmp(net->bssid, BELKINF5D8233V1_RALINK, 3) == 0) ||
279 (memcmp(net->bssid, BELKINF5D82334V3_RALINK, 3) == 0) ||
280 (memcmp(net->bssid, PCI_RALINK, 3) == 0) ||
281 (memcmp(net->bssid, EDIMAX_RALINK, 3) == 0) ||
282 (memcmp(net->bssid, AIRLINK_RALINK, 3) == 0) ||
283 (net->ralink_cap_exist))
285 else if ((memcmp(net->bssid, UNKNOWN_BORADCOM, 3) == 0) ||
286 (memcmp(net->bssid, LINKSYSWRT330_LINKSYSWRT300_BROADCOM, 3) == 0) ||
287 (memcmp(net->bssid, LINKSYSWRT350_LINKSYSWRT150_BROADCOM, 3) == 0) ||
288 (memcmp(net->bssid, NETGEAR834Bv2_BROADCOM, 3) == 0) ||
289 (net->broadcom_cap_exist))
291 else if (net->bssht.bdRT2RTAggregation)
300 *function: This function returns peer IOT.
301 * input: struct ieee80211_device* ieee
306 static void HTIOTPeerDetermine(struct ieee80211_device *ieee)
308 PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
309 struct ieee80211_network *net = &ieee->current_network;
311 if (net->bssht.bdRT2RTAggregation)
312 pHTInfo->IOTPeer = HT_IOT_PEER_REALTEK;
313 else if (net->broadcom_cap_exist)
314 pHTInfo->IOTPeer = HT_IOT_PEER_BROADCOM;
315 else if ((memcmp(net->bssid, UNKNOWN_BORADCOM, 3) == 0) ||
316 (memcmp(net->bssid, LINKSYSWRT330_LINKSYSWRT300_BROADCOM, 3) == 0) ||
317 (memcmp(net->bssid, LINKSYSWRT350_LINKSYSWRT150_BROADCOM, 3) == 0) ||
318 (memcmp(net->bssid, NETGEAR834Bv2_BROADCOM, 3) == 0))
319 pHTInfo->IOTPeer = HT_IOT_PEER_BROADCOM;
320 else if ((memcmp(net->bssid, BELKINF5D8233V1_RALINK, 3) == 0) ||
321 (memcmp(net->bssid, BELKINF5D82334V3_RALINK, 3) == 0) ||
322 (memcmp(net->bssid, PCI_RALINK, 3) == 0) ||
323 (memcmp(net->bssid, EDIMAX_RALINK, 3) == 0) ||
324 (memcmp(net->bssid, AIRLINK_RALINK, 3) == 0) ||
325 net->ralink_cap_exist)
326 pHTInfo->IOTPeer = HT_IOT_PEER_RALINK;
327 else if (net->atheros_cap_exist)
328 pHTInfo->IOTPeer = HT_IOT_PEER_ATHEROS;
329 else if (memcmp(net->bssid, CISCO_BROADCOM, 3) == 0)
330 pHTInfo->IOTPeer = HT_IOT_PEER_CISCO;
332 pHTInfo->IOTPeer = HT_IOT_PEER_UNKNOWN;
334 IEEE80211_DEBUG(IEEE80211_DL_IOT, "Joseph debug!! IOTPEER: %x\n", pHTInfo->IOTPeer);
338 *function: Check whether driver should declare received rate up to MCS13
339 * only since some chipset is not good at receiving MCS14~15 frame
341 * input: struct ieee80211_device* ieee
344 * return: return 1 if driver should declare MCS13 only(otherwise return 0)
346 static u8 HTIOTActIsDisableMCS14(struct ieee80211_device *ieee, u8 *PeerMacAddr)
352 * Function: HTIOTActIsDisableMCS15
354 * Overview: Check whether driver should declare capability of receiving
361 * Return: true if driver should disable MCS15
364 static bool HTIOTActIsDisableMCS15(struct ieee80211_device *ieee)
366 bool retValue = false;
369 // Apply for 819u only
370 #if (HAL_CODE_BASE == RTL8192)
372 #if (DEV_BUS_TYPE == USB_INTERFACE)
373 // Alway disable MCS15 by Jerry Chang's request.by Emily, 2008.04.15
375 #elif (DEV_BUS_TYPE == PCI_INTERFACE)
376 // Enable MCS15 if the peer is Cisco AP. by Emily, 2008.05.12
377 // if(pBssDesc->bCiscoCapExist)
384 // Jerry Chang suggest that 8190 1x2 does not need to disable MCS15
390 * Function: HTIOTActIsDisableMCSTwoSpatialStream
392 * Overview: Check whether driver should declare capability of receiving
399 * Return: true if driver should disable all two spatial stream packet
402 static bool HTIOTActIsDisableMCSTwoSpatialStream(struct ieee80211_device *ieee,
406 // Apply for 819u only
412 *function: Check whether driver should disable EDCA turbo mode
413 * input: struct ieee80211_device* ieee
416 * return: return 1 if driver should disable EDCA turbo mode
417 * (otherwise return 0)
419 static u8 HTIOTActIsDisableEDCATurbo(struct ieee80211_device *ieee,
421 { /* default enable EDCA Turbo mode. */
426 *function: Check whether we need to use OFDM to sned MGNT frame for
428 * input: struct ieee80211_network *network //current network we live
430 * return: return 1 if true
432 static u8 HTIOTActIsMgntUseCCK6M(struct ieee80211_network *network)
436 // 2008/01/25 MH Judeg if we need to use OFDM to sned MGNT frame for broadcom AP.
437 // 2008/01/28 MH We must prevent that we select null bssid to link.
439 if (network->broadcom_cap_exist)
445 static u8 HTIOTActIsCCDFsync(u8 *PeerMacAddr)
449 if ((memcmp(PeerMacAddr, UNKNOWN_BORADCOM, 3) == 0) ||
450 (memcmp(PeerMacAddr, LINKSYSWRT330_LINKSYSWRT300_BROADCOM, 3) == 0) ||
451 (memcmp(PeerMacAddr, LINKSYSWRT350_LINKSYSWRT150_BROADCOM, 3) == 0))
457 void HTResetIOTSetting(PRT_HIGH_THROUGHPUT pHTInfo)
459 pHTInfo->IOTAction = 0;
460 pHTInfo->IOTPeer = HT_IOT_PEER_UNKNOWN;
464 *function: Construct Capablility Element in Beacon... if HTEnable is turned on
465 * input: struct ieee80211_device* ieee
466 * u8* posHTCap //pointer to store Capability Ele
467 * u8* len //store length of CE
468 * u8 IsEncrypt //whether encrypt, needed further
471 * notice: posHTCap can't be null and should be initialized before.
473 void HTConstructCapabilityElement(struct ieee80211_device *ieee, u8 *posHTCap, u8 *len, u8 IsEncrypt)
475 PRT_HIGH_THROUGHPUT pHT = ieee->pHTInfo;
476 struct ht_capability_ele *pCapELE = NULL;
477 //u8 bIsDeclareMCS13;
479 if (!posHTCap || !pHT) {
480 IEEE80211_DEBUG(IEEE80211_DL_ERR,
481 "posHTCap or pHTInfo can't be null in %s\n",
485 memset(posHTCap, 0, *len);
486 if (pHT->ePeerHTSpecVer == HT_SPEC_VER_EWC) {
487 u8 EWC11NHTCap[] = {0x00, 0x90, 0x4c, 0x33}; // For 11n EWC definition, 2007.07.17, by Emily
489 memcpy(posHTCap, EWC11NHTCap, sizeof(EWC11NHTCap));
490 pCapELE = (struct ht_capability_ele *)&posHTCap[4];
492 pCapELE = (struct ht_capability_ele *)posHTCap;
496 pCapELE->AdvCoding = 0; // This feature is not supported now!!
497 if (ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev))
498 pCapELE->ChlWidth = 0;
500 pCapELE->ChlWidth = (pHT->bRegBW40MHz ? 1 : 0);
502 // pCapELE->ChlWidth = (pHT->bRegBW40MHz?1:0);
503 pCapELE->MimoPwrSave = pHT->SelfMimoPs;
504 pCapELE->GreenField = 0; // This feature is not supported now!!
505 pCapELE->ShortGI20Mhz = 1; // We can receive Short GI!!
506 pCapELE->ShortGI40Mhz = 1; // We can receive Short GI!!
507 //DbgPrint("TX HT cap/info ele BW=%d SG20=%d SG40=%d\n\r",
508 //pCapELE->ChlWidth, pCapELE->ShortGI20Mhz, pCapELE->ShortGI40Mhz);
511 pCapELE->DelayBA = 0; // Do not support now!!
512 pCapELE->MaxAMSDUSize = (MAX_RECEIVE_BUFFER_SIZE >= 7935) ? 1 : 0;
513 pCapELE->DssCCk = ((pHT->bRegBW40MHz) ? (pHT->bRegSuppCCK ? 1 : 0) : 0);
514 pCapELE->PSMP = 0; // Do not support now!!
515 pCapELE->LSigTxopProtect = 0; // Do not support now!!
518 * MAC HT parameters info
519 * TODO: Nedd to take care of this part
521 IEEE80211_DEBUG(IEEE80211_DL_HT, "TX HT cap/info ele BW=%d MaxAMSDUSize:%d DssCCk:%d\n", pCapELE->ChlWidth, pCapELE->MaxAMSDUSize, pCapELE->DssCCk);
524 pCapELE->MPDUDensity = 7; // 8us
525 pCapELE->MaxRxAMPDUFactor = 2; // 2 is for 32 K and 3 is 64K
527 pCapELE->MaxRxAMPDUFactor = 3; // 2 is for 32 K and 3 is 64K
528 pCapELE->MPDUDensity = 0; // no density
532 memcpy(pCapELE->MCS, ieee->Regdot11HTOperationalRateSet, 16);
533 if (pHT->IOTAction & HT_IOT_ACT_DISABLE_MCS15)
534 pCapELE->MCS[1] &= 0x7f;
536 if (pHT->IOTAction & HT_IOT_ACT_DISABLE_MCS14)
537 pCapELE->MCS[1] &= 0xbf;
539 if (pHT->IOTAction & HT_IOT_ACT_DISABLE_ALL_2SS)
540 pCapELE->MCS[1] &= 0x00;
544 * For RTL819X, if pairwisekey = wep/tkip, ap is ralink, we support only MCS0~7.
546 if (ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev)) {
549 for (i = 1; i < 16; i++)
553 //Extended HT Capability Info
554 memset(&pCapELE->ExtHTCapInfo, 0, 2);
557 memset(pCapELE->TxBFCap, 0, 4);
559 //Antenna Selection Capabilities
561 //add 2 to give space for element ID and len when construct frames
562 if (pHT->ePeerHTSpecVer == HT_SPEC_VER_EWC)
567 // IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA | IEEE80211_DL_HT, posHTCap, *len -2);
570 * Print each field in detail. Driver should not print out this message
573 // HTDebugHTCapability(posHTCap, (u8*)"HTConstructCapability()");
577 *function: Construct Information Element in Beacon... if HTEnable is turned on
578 * input: struct ieee80211_device* ieee
579 * u8* posHTCap //pointer to store Information Ele
580 * u8* len //store len of
581 * u8 IsEncrypt //whether encrypt, needed further
584 * notice: posHTCap can't be null and be initialized before.
585 * Only AP and IBSS sta should do this
587 void HTConstructInfoElement(struct ieee80211_device *ieee, u8 *posHTInfo, u8 *len, u8 IsEncrypt)
589 PRT_HIGH_THROUGHPUT pHT = ieee->pHTInfo;
590 PHT_INFORMATION_ELE pHTInfoEle = (PHT_INFORMATION_ELE)posHTInfo;
592 if (!posHTInfo || !pHTInfoEle) {
593 IEEE80211_DEBUG(IEEE80211_DL_ERR,
594 "posHTInfo or pHTInfoEle can't be null in %s\n",
599 memset(posHTInfo, 0, *len);
600 if ((ieee->iw_mode == IW_MODE_ADHOC) || (ieee->iw_mode == IW_MODE_MASTER)) { //ap mode is not currently supported
601 pHTInfoEle->ControlChl = ieee->current_network.channel;
602 pHTInfoEle->ExtChlOffset = ((!pHT->bRegBW40MHz) ? HT_EXTCHNL_OFFSET_NO_EXT :
603 (ieee->current_network.channel <= 6) ?
604 HT_EXTCHNL_OFFSET_UPPER : HT_EXTCHNL_OFFSET_LOWER);
605 pHTInfoEle->RecommemdedTxWidth = pHT->bRegBW40MHz;
606 pHTInfoEle->RIFS = 0;
607 pHTInfoEle->PSMPAccessOnly = 0;
608 pHTInfoEle->SrvIntGranularity = 0;
609 pHTInfoEle->OptMode = pHT->CurrentOpMode;
610 pHTInfoEle->NonGFDevPresent = 0;
611 pHTInfoEle->DualBeacon = 0;
612 pHTInfoEle->SecondaryBeacon = 0;
613 pHTInfoEle->LSigTxopProtectFull = 0;
614 pHTInfoEle->PcoActive = 0;
615 pHTInfoEle->PcoPhase = 0;
617 memset(pHTInfoEle->BasicMSC, 0, 16);
619 *len = 22 + 2; //same above
621 //STA should not generate High Throughput Information Element
624 //IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA | IEEE80211_DL_HT, posHTInfo, *len - 2);
625 //HTDebugHTInfo(posHTInfo, "HTConstructInforElement");
629 * According to experiment, Realtek AP to STA (based on rtl8190) may achieve
630 * best performance if both STA and AP set limitation of aggregation size to
631 * 32K, that is, set AMPDU density to 2 (Ref: IEEE 11n specification).
632 * However, if Realtek STA associates to other AP, STA should set limitation of
633 * aggregation size to 8K, otherwise, performance of traffic stream from STA to
634 * AP will be much less than the traffic stream from AP to STA if both of the
635 * stream runs concurrently at the same time.
638 * Element ID Length OUI Type1 Reserved
639 * 1 byte 1 byte 3 bytes 1 byte 1 byte
641 * OUI = 0x00, 0xe0, 0x4c,
648 *function: Construct Information Element in Beacon... in RT2RT condition
649 * input: struct ieee80211_device* ieee
650 * u8* posRT2RTAgg //pointer to store Information Ele
651 * u8* len //store len
656 void HTConstructRT2RTAggElement(struct ieee80211_device *ieee, u8 *posRT2RTAgg, u8 *len)
659 IEEE80211_DEBUG(IEEE80211_DL_ERR,
660 "posRT2RTAgg can't be null in %s\n",
664 memset(posRT2RTAgg, 0, *len);
665 *posRT2RTAgg++ = 0x00;
666 *posRT2RTAgg++ = 0xe0;
667 *posRT2RTAgg++ = 0x4c;
668 *posRT2RTAgg++ = 0x02;
669 *posRT2RTAgg++ = 0x01;
670 *posRT2RTAgg = 0x10;//*posRT2RTAgg = 0x02;
672 if (ieee->bSupportRemoteWakeUp)
673 *posRT2RTAgg |= 0x08;//RT_HT_CAP_USE_WOW;
678 #if (HAL_CODE_BASE == RTL8192 && DEV_BUS_TYPE == USB_INTERFACE)
680 //Emily. If it is required to Ask Realtek AP to send AMPDU during AES mode, enable this
682 if(IS_UNDER_11N_AES_MODE(Adapter))
684 posRT2RTAgg->octet[5] |= RT_HT_CAP_USE_AMPDU;
687 posRT2RTAgg->octet[5] &= 0xfb;
694 posRT2RTAgg->Length = 6;
699 *function: Pick the right Rate Adaptive table to use
700 * input: struct ieee80211_device* ieee
701 * u8* pOperateMCS //A pointer to MCS rate bitmap
702 * return: always we return true
705 static u8 HT_PickMCSRate(struct ieee80211_device *ieee, u8 *pOperateMCS)
708 IEEE80211_DEBUG(IEEE80211_DL_ERR,
709 "pOperateMCS can't be null in %s\n",
714 switch (ieee->mode) {
718 //legacy rate routine handled at selectedrate
721 memset(pOperateMCS, 0, 16);
724 case IEEE_N_24G: //assume CCK rate ok
726 // Legacy part we only use 6, 5.5,2,1 for N_24G and 6 for N_5G.
727 // Legacy part shall be handled at SelectRateSet().
730 // TODO: may be different if we have different number of antenna
731 pOperateMCS[0] &= RATE_ADPT_1SS_MASK; //support MCS 0~7
732 pOperateMCS[1] &= RATE_ADPT_2SS_MASK;
733 pOperateMCS[3] &= RATE_ADPT_MCS32_MASK;
736 //should never reach here
746 * This function will get the highest speed rate in input MCS set.
748 * /param Adapter Pionter to Adapter entity
749 * pMCSRateSet Pointer to MCS rate bitmap
750 * pMCSFilter Pointer to MCS rate filter
752 * /return Highest MCS rate included in pMCSRateSet and filtered by pMCSFilter.
756 *function: This function will get the highest speed rate in input MCS set.
757 * input: struct ieee80211_device* ieee
758 * u8* pMCSRateSet //Pointer to MCS rate bitmap
759 * u8* pMCSFilter //Pointer to MCS rate filter
760 * return: Highest MCS rate included in pMCSRateSet and filtered by pMCSFilter
763 u8 HTGetHighestMCSRate(struct ieee80211_device *ieee, u8 *pMCSRateSet, u8 *pMCSFilter)
768 u8 availableMcsRate[16];
770 if (!pMCSRateSet || !pMCSFilter) {
771 IEEE80211_DEBUG(IEEE80211_DL_ERR,
772 "pMCSRateSet or pMCSFilter can't be null in %s\n",
776 for (i = 0; i < 16; i++)
777 availableMcsRate[i] = pMCSRateSet[i] & pMCSFilter[i];
779 for (i = 0; i < 16; i++) {
780 if (availableMcsRate[i] != 0)
786 for (i = 0; i < 16; i++) {
787 if (availableMcsRate[i] != 0) {
788 bitMap = availableMcsRate[i];
789 for (j = 0; j < 8; j++) {
790 if ((bitMap % 2) != 0) {
791 if (HTMcsToDataRate(ieee, (8 * i + j)) > HTMcsToDataRate(ieee, mcsRate))
792 mcsRate = (8 * i + j);
798 return (mcsRate | 0x80);
802 * 1.Filter our operation rate set with AP's rate set
803 * 2.shall reference channel bandwidth, STBC, Antenna number
804 * 3.generate rate adative table for firmware
807 * \pHTSupportedCap: the connected STA's supported rate Capability element
809 static u8 HTFilterMCSRate(struct ieee80211_device *ieee, u8 *pSupportMCS,
814 // filter out operational rate set not supported by AP, the length of it is 16
815 for (i = 0; i <= 15; i++)
816 pOperateMCS[i] = ieee->Regdot11HTOperationalRateSet[i] & pSupportMCS[i];
818 // TODO: adjust our operational rate set according to our channel bandwidth, STBC and Antenna number
820 * TODO: fill suggested rate adaptive rate index and give firmware info
821 * using Tx command packet we also shall suggested the first start rate
822 * set according to our signal strength
824 HT_PickMCSRate(ieee, pOperateMCS);
826 // For RTL819X, if pairwisekey = wep/tkip, we support only MCS0~7.
827 if (ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev))
831 * For RTL819X, we support only MCS0~15.
832 * And also, we do not know how to use MCS32 now.
834 for (i = 2; i <= 15; i++)
840 void HTOnAssocRsp(struct ieee80211_device *ieee)
842 PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
843 struct ht_capability_ele *pPeerHTCap = NULL;
844 PHT_INFORMATION_ELE pPeerHTInfo = NULL;
845 u16 nMaxAMSDUSize = 0;
846 u8 *pMcsFilter = NULL;
848 static u8 EWC11NHTCap[] = {0x00, 0x90, 0x4c, 0x33}; // For 11n EWC definition, 2007.07.17, by Emily
849 static u8 EWC11NHTInfo[] = {0x00, 0x90, 0x4c, 0x34}; // For 11n EWC definition, 2007.07.17, by Emily
851 if (!pHTInfo->bCurrentHTSupport) {
852 IEEE80211_DEBUG(IEEE80211_DL_ERR,
853 "<=== %s: HT_DISABLE\n",
857 IEEE80211_DEBUG(IEEE80211_DL_HT, "===> HTOnAssocRsp_wq(): HT_ENABLE\n");
858 // IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA, pHTInfo->PeerHTCapBuf, sizeof(struct ht_capability_ele));
859 // IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA, pHTInfo->PeerHTInfoBuf, sizeof(HT_INFORMATION_ELE));
861 // HTDebugHTCapability(pHTInfo->PeerHTCapBuf,"HTOnAssocRsp_wq");
862 // HTDebugHTInfo(pHTInfo->PeerHTInfoBuf,"HTOnAssocRsp_wq");
864 if (!memcmp(pHTInfo->PeerHTCapBuf, EWC11NHTCap, sizeof(EWC11NHTCap)))
865 pPeerHTCap = (struct ht_capability_ele *)(&pHTInfo->PeerHTCapBuf[4]);
867 pPeerHTCap = (struct ht_capability_ele *)(pHTInfo->PeerHTCapBuf);
869 if (!memcmp(pHTInfo->PeerHTInfoBuf, EWC11NHTInfo, sizeof(EWC11NHTInfo)))
870 pPeerHTInfo = (PHT_INFORMATION_ELE)(&pHTInfo->PeerHTInfoBuf[4]);
872 pPeerHTInfo = (PHT_INFORMATION_ELE)(pHTInfo->PeerHTInfoBuf);
874 ////////////////////////////////////////////////////////
876 ////////////////////////////////////////////////////////
877 IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA | IEEE80211_DL_HT, pPeerHTCap, sizeof(struct ht_capability_ele));
878 // IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA|IEEE80211_DL_HT, pPeerHTInfo, sizeof(HT_INFORMATION_ELE));
879 // Config Supported Channel Width setting
881 HTSetConnectBwMode(ieee, (enum ht_channel_width)(pPeerHTCap->ChlWidth), (enum ht_extension_chan_offset)(pPeerHTInfo->ExtChlOffset));
883 pHTInfo->bCurTxBW40MHz = (pPeerHTInfo->RecommemdedTxWidth == 1);
886 * Update short GI/ long GI setting
890 pHTInfo->bCurShortGI20MHz = pHTInfo->bRegShortGI20MHz &&
891 (pPeerHTCap->ShortGI20Mhz == 1);
892 pHTInfo->bCurShortGI40MHz = pHTInfo->bRegShortGI40MHz &&
893 (pPeerHTCap->ShortGI40Mhz == 1);
896 * Config TX STBC setting
902 * Config DSSS/CCK mode in 40MHz mode
906 pHTInfo->bCurSuppCCK = pHTInfo->bRegSuppCCK &&
907 (pPeerHTCap->DssCCk == 1);
910 * Config and configure A-MSDU setting
912 pHTInfo->bCurrent_AMSDU_Support = pHTInfo->bAMSDU_Support;
914 nMaxAMSDUSize = (pPeerHTCap->MaxAMSDUSize == 0) ? 3839 : 7935;
916 if (pHTInfo->nAMSDU_MaxSize > nMaxAMSDUSize)
917 pHTInfo->nCurrent_AMSDU_MaxSize = nMaxAMSDUSize;
919 pHTInfo->nCurrent_AMSDU_MaxSize = pHTInfo->nAMSDU_MaxSize;
921 * Config A-MPDU setting
923 pHTInfo->bCurrentAMPDUEnable = pHTInfo->bAMPDUEnable;
926 * <1> Decide AMPDU Factor
929 if (!pHTInfo->bRegRT2RTAggregation) {
930 // Decide AMPDU Factor according to protocol handshake
931 if (pHTInfo->AMPDU_Factor > pPeerHTCap->MaxRxAMPDUFactor)
932 pHTInfo->CurrentAMPDUFactor = pPeerHTCap->MaxRxAMPDUFactor;
934 pHTInfo->CurrentAMPDUFactor = pHTInfo->AMPDU_Factor;
937 * Set MPDU density to 2 to Realtek AP, and set it to 0 for others
938 * Replace MPDU factor declared in original association response frame format. 2007.08.20 by Emily
940 if (ieee->current_network.bssht.bdRT2RTAggregation) {
941 if (ieee->pairwise_key_type != KEY_TYPE_NA)
942 // Realtek may set 32k in security mode and 64k for others
943 pHTInfo->CurrentAMPDUFactor = pPeerHTCap->MaxRxAMPDUFactor;
945 pHTInfo->CurrentAMPDUFactor = HT_AGG_SIZE_64K;
947 if (pPeerHTCap->MaxRxAMPDUFactor < HT_AGG_SIZE_32K)
948 pHTInfo->CurrentAMPDUFactor = pPeerHTCap->MaxRxAMPDUFactor;
950 pHTInfo->CurrentAMPDUFactor = HT_AGG_SIZE_32K;
955 * <2> Set AMPDU Minimum MPDU Start Spacing
956 * 802.11n 3.0 section 9.7d.3
958 if (pHTInfo->MPDU_Density > pPeerHTCap->MPDUDensity)
959 pHTInfo->CurrentMPDUDensity = pHTInfo->MPDU_Density;
961 pHTInfo->CurrentMPDUDensity = pPeerHTCap->MPDUDensity;
962 if (ieee->pairwise_key_type != KEY_TYPE_NA)
963 pHTInfo->CurrentMPDUDensity = 7; // 8us
966 // Lanhsin: mark for tmp to avoid deauth by ap from s3
967 //if(memcmp(pMgntInfo->Bssid, NETGEAR834Bv2_BROADCOM, 3)==0)
969 pHTInfo->bCurrentAMPDUEnable = false;
970 pHTInfo->ForcedAMSDUMode = HT_AGG_FORCE_ENABLE;
971 pHTInfo->ForcedAMSDUMaxSize = 7935;
973 pHTInfo->IOTAction |= HT_IOT_ACT_TX_USE_AMSDU_8K;
976 // Rx Reorder Setting
977 pHTInfo->bCurRxReorderEnable = pHTInfo->bRegRxReorderEnable;
980 * Filter out unsupported HT rate for this AP
982 * This is only for 8190 ,8192 or later product which using firmware to
983 * handle rate adaptive mechanism.
987 * Handle Ralink AP bad MCS rate set condition. Joseph.
988 * This fix the bug of Ralink AP. This may be removed in the future.
990 if (pPeerHTCap->MCS[0] == 0)
991 pPeerHTCap->MCS[0] = 0xff;
993 HTFilterMCSRate(ieee, pPeerHTCap->MCS, ieee->dot11HTOperationalRateSet);
996 * Config MIMO Power Save setting
998 pHTInfo->PeerMimoPs = pPeerHTCap->MimoPwrSave;
999 if (pHTInfo->PeerMimoPs == MIMO_PS_STATIC)
1000 pMcsFilter = MCS_FILTER_1SS;
1002 pMcsFilter = MCS_FILTER_ALL;
1003 //WB add for MCS8 bug
1004 // pMcsFilter = MCS_FILTER_1SS;
1005 ieee->HTHighestOperaRate = HTGetHighestMCSRate(ieee, ieee->dot11HTOperationalRateSet, pMcsFilter);
1006 ieee->HTCurrentOperaRate = ieee->HTHighestOperaRate;
1009 * Config current operation mode.
1011 pHTInfo->CurrentOpMode = pPeerHTInfo->OptMode;
1015 *function: initialize HT info(struct PRT_HIGH_THROUGHPUT)
1016 * input: struct ieee80211_device* ieee
1019 * notice: This function is called when
1020 * * (1) MPInitialization Phase
1021 * * (2) Receiving of Deauthentication from AP
1023 // TODO: Should this funciton be called when receiving of Disassociation?
1024 void HTInitializeHTInfo(struct ieee80211_device *ieee)
1026 PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
1029 * These parameters will be reset when receiving deauthentication packet
1031 IEEE80211_DEBUG(IEEE80211_DL_HT, "===========>%s()\n", __func__);
1032 pHTInfo->bCurrentHTSupport = false;
1034 // 40MHz channel support
1035 pHTInfo->bCurBW40MHz = false;
1036 pHTInfo->bCurTxBW40MHz = false;
1039 pHTInfo->bCurShortGI20MHz = false;
1040 pHTInfo->bCurShortGI40MHz = false;
1041 pHTInfo->bForcedShortGI = false;
1045 * This flag is set to true to support CCK rate by default.
1046 * It will be affected by "pHTInfo->bRegSuppCCK" and AP capabilities
1047 * only when associate to 11N BSS.
1049 pHTInfo->bCurSuppCCK = true;
1052 pHTInfo->bCurrent_AMSDU_Support = false;
1053 pHTInfo->nCurrent_AMSDU_MaxSize = pHTInfo->nAMSDU_MaxSize;
1056 pHTInfo->CurrentMPDUDensity = pHTInfo->MPDU_Density;
1057 pHTInfo->CurrentAMPDUFactor = pHTInfo->AMPDU_Factor;
1059 // Initialize all of the parameters related to 11n
1060 memset(&pHTInfo->SelfHTCap, 0, sizeof(pHTInfo->SelfHTCap));
1061 memset(&pHTInfo->SelfHTInfo, 0, sizeof(pHTInfo->SelfHTInfo));
1062 memset(&pHTInfo->PeerHTCapBuf, 0, sizeof(pHTInfo->PeerHTCapBuf));
1063 memset(&pHTInfo->PeerHTInfoBuf, 0, sizeof(pHTInfo->PeerHTInfoBuf));
1065 pHTInfo->bSwBwInProgress = false;
1067 // Set default IEEE spec for Draft N
1068 pHTInfo->ePeerHTSpecVer = HT_SPEC_VER_IEEE;
1070 // Realtek proprietary aggregation mode
1071 pHTInfo->bCurrentRT2RTAggregation = false;
1072 pHTInfo->bCurrentRT2RTLongSlotTime = false;
1073 pHTInfo->IOTPeer = 0;
1074 pHTInfo->IOTAction = 0;
1076 //MCS rate initialized here
1078 u8 *RegHTSuppRateSets = &ieee->RegHTSuppRateSet[0];
1080 RegHTSuppRateSets[0] = 0xFF; //support MCS 0~7
1081 RegHTSuppRateSets[1] = 0xFF; //support MCS 8~15
1082 RegHTSuppRateSets[4] = 0x01; //support MCS 32
1087 *function: initialize Bss HT structure(struct PBSS_HT)
1088 * input: PBSS_HT pBssHT //to be initialized
1091 * notice: This function is called when initialize network structure
1093 void HTInitializeBssDesc(PBSS_HT pBssHT)
1095 pBssHT->bdSupportHT = false;
1096 memset(pBssHT->bdHTCapBuf, 0, sizeof(pBssHT->bdHTCapBuf));
1097 pBssHT->bdHTCapLen = 0;
1098 memset(pBssHT->bdHTInfoBuf, 0, sizeof(pBssHT->bdHTInfoBuf));
1099 pBssHT->bdHTInfoLen = 0;
1101 pBssHT->bdHTSpecVer = HT_SPEC_VER_IEEE;
1103 pBssHT->bdRT2RTAggregation = false;
1104 pBssHT->bdRT2RTLongSlotTime = false;
1108 *function: initialize Bss HT structure(struct PBSS_HT)
1109 * input: struct ieee80211_device *ieee
1110 * struct ieee80211_network *pNetwork //usually current network
1114 * notice: This function should ONLY be called before association
1116 void HTResetSelfAndSavePeerSetting(struct ieee80211_device *ieee, struct ieee80211_network *pNetwork)
1118 PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
1119 // u16 nMaxAMSDUSize;
1120 // struct ht_capability_ele *pPeerHTCap = (struct ht_capability_ele *)pNetwork->bssht.bdHTCapBuf;
1121 // PHT_INFORMATION_ELE pPeerHTInfo = (PHT_INFORMATION_ELE)pNetwork->bssht.bdHTInfoBuf;
1126 // Save Peer Setting before Association
1128 IEEE80211_DEBUG(IEEE80211_DL_HT, "==============>%s()\n", __func__);
1129 /*unmark bEnableHT flag here is the same reason why unmarked in function ieee80211_softmac_new_net. WB 2008.09.10*/
1130 // if( pHTInfo->bEnableHT && pNetwork->bssht.bdSupportHT)
1131 if (pNetwork->bssht.bdSupportHT) {
1132 pHTInfo->bCurrentHTSupport = true;
1133 pHTInfo->ePeerHTSpecVer = pNetwork->bssht.bdHTSpecVer;
1135 // Save HTCap and HTInfo information Element
1136 if (pNetwork->bssht.bdHTCapLen > 0 && pNetwork->bssht.bdHTCapLen <= sizeof(pHTInfo->PeerHTCapBuf))
1137 memcpy(pHTInfo->PeerHTCapBuf, pNetwork->bssht.bdHTCapBuf, pNetwork->bssht.bdHTCapLen);
1139 if (pNetwork->bssht.bdHTInfoLen > 0 && pNetwork->bssht.bdHTInfoLen <= sizeof(pHTInfo->PeerHTInfoBuf))
1140 memcpy(pHTInfo->PeerHTInfoBuf, pNetwork->bssht.bdHTInfoBuf, pNetwork->bssht.bdHTInfoLen);
1142 // Check whether RT to RT aggregation mode is enabled
1143 if (pHTInfo->bRegRT2RTAggregation) {
1144 pHTInfo->bCurrentRT2RTAggregation = pNetwork->bssht.bdRT2RTAggregation;
1145 pHTInfo->bCurrentRT2RTLongSlotTime = pNetwork->bssht.bdRT2RTLongSlotTime;
1147 pHTInfo->bCurrentRT2RTAggregation = false;
1148 pHTInfo->bCurrentRT2RTLongSlotTime = false;
1151 // Determine the IOT Peer Vendor.
1152 HTIOTPeerDetermine(ieee);
1156 * Must be called after the parameter of pHTInfo->bCurrentRT2RTAggregation is decided
1158 pHTInfo->IOTAction = 0;
1159 bIOTAction = HTIOTActIsDisableMCS14(ieee, pNetwork->bssid);
1161 pHTInfo->IOTAction |= HT_IOT_ACT_DISABLE_MCS14;
1163 bIOTAction = HTIOTActIsDisableMCS15(ieee);
1165 pHTInfo->IOTAction |= HT_IOT_ACT_DISABLE_MCS15;
1167 bIOTAction = HTIOTActIsDisableMCSTwoSpatialStream(ieee, pNetwork->bssid);
1169 pHTInfo->IOTAction |= HT_IOT_ACT_DISABLE_ALL_2SS;
1171 bIOTAction = HTIOTActIsDisableEDCATurbo(ieee, pNetwork->bssid);
1173 pHTInfo->IOTAction |= HT_IOT_ACT_DISABLE_EDCA_TURBO;
1175 bIOTAction = HTIOTActIsMgntUseCCK6M(pNetwork);
1177 pHTInfo->IOTAction |= HT_IOT_ACT_MGNT_USE_CCK_6M;
1179 bIOTAction = HTIOTActIsCCDFsync(pNetwork->bssid);
1181 pHTInfo->IOTAction |= HT_IOT_ACT_CDD_FSYNC;
1183 pHTInfo->bCurrentHTSupport = false;
1184 pHTInfo->bCurrentRT2RTAggregation = false;
1185 pHTInfo->bCurrentRT2RTLongSlotTime = false;
1187 pHTInfo->IOTAction = 0;
1191 void HTUpdateSelfAndPeerSetting(struct ieee80211_device *ieee, struct ieee80211_network *pNetwork)
1193 PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
1194 // struct ht_capability_ele *pPeerHTCap = (struct ht_capability_ele *)pNetwork->bssht.bdHTCapBuf;
1195 PHT_INFORMATION_ELE pPeerHTInfo = (PHT_INFORMATION_ELE)pNetwork->bssht.bdHTInfoBuf;
1197 if (pHTInfo->bCurrentHTSupport) {
1199 * Config current operation mode.
1201 if (pNetwork->bssht.bdHTInfoLen != 0)
1202 pHTInfo->CurrentOpMode = pPeerHTInfo->OptMode;
1205 * <TODO: Config according to OBSS non-HT STA present!!>
1209 EXPORT_SYMBOL(HTUpdateSelfAndPeerSetting);
1212 *function: check whether HT control field exists
1213 * input: struct ieee80211_device *ieee
1214 * u8* pFrame //coming skb->data
1216 * return: return true if HT control field exists(false otherwise)
1219 u8 HTCCheck(struct ieee80211_device *ieee, u8 *pFrame)
1221 if (ieee->pHTInfo->bCurrentHTSupport) {
1222 if ((IsQoSDataFrame(pFrame) && Frame_Order(pFrame)) == 1) {
1223 IEEE80211_DEBUG(IEEE80211_DL_HT, "HT CONTROL FILED EXIST!!\n");
1230 static void HTSetConnectBwModeCallback(struct ieee80211_device *ieee)
1232 PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
1234 IEEE80211_DEBUG(IEEE80211_DL_HT, "======>%s()\n", __func__);
1236 if (pHTInfo->bCurBW40MHz) {
1237 if (pHTInfo->CurSTAExtChnlOffset == HT_EXTCHNL_OFFSET_UPPER)
1238 ieee->set_chan(ieee->dev, ieee->current_network.channel + 2);
1239 else if (pHTInfo->CurSTAExtChnlOffset == HT_EXTCHNL_OFFSET_LOWER)
1240 ieee->set_chan(ieee->dev, ieee->current_network.channel - 2);
1242 ieee->set_chan(ieee->dev, ieee->current_network.channel);
1244 ieee->SetBWModeHandler(ieee->dev, HT_CHANNEL_WIDTH_20_40, pHTInfo->CurSTAExtChnlOffset);
1246 ieee->set_chan(ieee->dev, ieee->current_network.channel);
1247 ieee->SetBWModeHandler(ieee->dev, HT_CHANNEL_WIDTH_20, HT_EXTCHNL_OFFSET_NO_EXT);
1250 pHTInfo->bSwBwInProgress = false;
1254 * This function set bandwidth mode in protocol layer.
1256 void HTSetConnectBwMode(struct ieee80211_device *ieee, enum ht_channel_width Bandwidth, enum ht_extension_chan_offset Offset)
1258 PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
1261 if (!pHTInfo->bRegBW40MHz)
1264 // To reduce dummy operation
1265 // if((pHTInfo->bCurBW40MHz==false && Bandwidth==HT_CHANNEL_WIDTH_20) ||
1266 // (pHTInfo->bCurBW40MHz==true && Bandwidth==HT_CHANNEL_WIDTH_20_40 && Offset==pHTInfo->CurSTAExtChnlOffset))
1269 // spin_lock_irqsave(&(ieee->bw_spinlock), flags);
1270 if (pHTInfo->bSwBwInProgress) {
1271 // spin_unlock_irqrestore(&(ieee->bw_spinlock), flags);
1274 //if in half N mode, set to 20M bandwidth please 09.08.2008 WB.
1275 if (Bandwidth == HT_CHANNEL_WIDTH_20_40 && (!ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev))) {
1276 // Handle Illegal extension channel offset!!
1277 if (ieee->current_network.channel < 2 && Offset == HT_EXTCHNL_OFFSET_LOWER)
1278 Offset = HT_EXTCHNL_OFFSET_NO_EXT;
1279 if (Offset == HT_EXTCHNL_OFFSET_UPPER || Offset == HT_EXTCHNL_OFFSET_LOWER) {
1280 pHTInfo->bCurBW40MHz = true;
1281 pHTInfo->CurSTAExtChnlOffset = Offset;
1283 pHTInfo->bCurBW40MHz = false;
1284 pHTInfo->CurSTAExtChnlOffset = HT_EXTCHNL_OFFSET_NO_EXT;
1287 pHTInfo->bCurBW40MHz = false;
1288 pHTInfo->CurSTAExtChnlOffset = HT_EXTCHNL_OFFSET_NO_EXT;
1291 pHTInfo->bSwBwInProgress = true;
1294 * TODO: 2007.7.13 by Emily Wait 2000ms in order to guarantee that
1295 * switching bandwidth is executed after scan is finished. It is a
1296 * temporal solution because software should ganrantee the last
1297 * operation of switching bandwidth is executed properlly.
1299 HTSetConnectBwModeCallback(ieee);
1301 // spin_unlock_irqrestore(&(ieee->bw_spinlock), flags);