1 // SPDX-License-Identifier: GPL-2.0
3 //As this function is mainly ported from Windows driver, so leave the name little changed. If any confusion caused, tell me. Created by WB. 2008.05.08
5 #include "rtl819x_HT.h"
6 u8 MCS_FILTER_ALL[16] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
8 u8 MCS_FILTER_1SS[16] = {0xff, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
10 u16 MCS_DATA_RATE[2][2][77] =
11 { { {13, 26, 39, 52, 78, 104, 117, 130, 26, 52, 78 ,104, 156, 208, 234, 260,
12 39, 78, 117, 234, 312, 351, 390, 52, 104, 156, 208, 312, 416, 468, 520,
13 0, 78, 104, 130, 117, 156, 195, 104, 130, 130, 156, 182, 182, 208, 156, 195,
14 195, 234, 273, 273, 312, 130, 156, 181, 156, 181, 208, 234, 208, 234, 260, 260,
15 286, 195, 234, 273, 234, 273, 312, 351, 312, 351, 390, 390, 429}, // Long GI, 20MHz
16 {14, 29, 43, 58, 87, 116, 130, 144, 29, 58, 87, 116, 173, 231, 260, 289,
17 43, 87, 130, 173, 260, 347, 390, 433, 58, 116, 173, 231, 347, 462, 520, 578,
18 0, 87, 116, 144, 130, 173, 217, 116, 144, 144, 173, 202, 202, 231, 173, 217,
19 217, 260, 303, 303, 347, 144, 173, 202, 173, 202, 231, 260, 231, 260, 289, 289,
20 318, 217, 260, 303, 260, 303, 347, 390, 347, 390, 433, 433, 477} }, // Short GI, 20MHz
21 { {27, 54, 81, 108, 162, 216, 243, 270, 54, 108, 162, 216, 324, 432, 486, 540,
22 81, 162, 243, 324, 486, 648, 729, 810, 108, 216, 324, 432, 648, 864, 972, 1080,
23 12, 162, 216, 270, 243, 324, 405, 216, 270, 270, 324, 378, 378, 432, 324, 405,
24 405, 486, 567, 567, 648, 270, 324, 378, 324, 378, 432, 486, 432, 486, 540, 540,
25 594, 405, 486, 567, 486, 567, 648, 729, 648, 729, 810, 810, 891}, // Long GI, 40MHz
26 {30, 60, 90, 120, 180, 240, 270, 300, 60, 120, 180, 240, 360, 480, 540, 600,
27 90, 180, 270, 360, 540, 720, 810, 900, 120, 240, 360, 480, 720, 960, 1080, 1200,
28 13, 180, 240, 300, 270, 360, 450, 240, 300, 300, 360, 420, 420, 480, 360, 450,
29 450, 540, 630, 630, 720, 300, 360, 420, 360, 420, 480, 540, 480, 540, 600, 600,
30 660, 450, 540, 630, 540, 630, 720, 810, 720, 810, 900, 900, 990} } // Short GI, 40MHz
33 static u8 UNKNOWN_BORADCOM[3] = {0x00, 0x14, 0xbf};
34 static u8 LINKSYSWRT330_LINKSYSWRT300_BROADCOM[3] = {0x00, 0x1a, 0x70};
35 static u8 LINKSYSWRT350_LINKSYSWRT150_BROADCOM[3] = {0x00, 0x1d, 0x7e};
36 static u8 NETGEAR834Bv2_BROADCOM[3] = {0x00, 0x1b, 0x2f};
37 static u8 BELKINF5D8233V1_RALINK[3] = {0x00, 0x17, 0x3f}; //cosa 03202008
38 static u8 BELKINF5D82334V3_RALINK[3] = {0x00, 0x1c, 0xdf};
39 static u8 PCI_RALINK[3] = {0x00, 0x90, 0xcc};
40 static u8 EDIMAX_RALINK[3] = {0x00, 0x0e, 0x2e};
41 static u8 AIRLINK_RALINK[3] = {0x00, 0x18, 0x02};
42 //static u8 DLINK_ATHEROS[3] = {0x00, 0x1c, 0xf0};
43 static u8 CISCO_BROADCOM[3] = {0x00, 0x17, 0x94};
45 // 2008/04/01 MH For Cisco G mode RX TP We need to change FW duration. Should we put the
46 // code in other place??
47 //static u8 WIFI_CISCO_G_AP[3] = {0x00, 0x40, 0x96};
48 /********************************************************************************************************************
49 *function: This function update default settings in pHTInfo structure
50 * input: PRT_HIGH_THROUGHPUT pHTInfo
53 * notice: These value need be modified if any changes.
54 * *****************************************************************************************************************/
55 void HTUpdateDefaultSetting(struct ieee80211_device *ieee)
57 PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
58 //const typeof( ((struct ieee80211_device *)0)->pHTInfo ) *__mptr = &pHTInfo;
60 //printk("pHTinfo:%p, &pHTinfo:%p, mptr:%p, offsetof:%x\n", pHTInfo, &pHTInfo, __mptr, offsetof(struct ieee80211_device, pHTInfo));
61 //printk("===>ieee:%p,\n", ieee);
63 pHTInfo->bRegShortGI20MHz= 1;
64 pHTInfo->bRegShortGI40MHz= 1;
66 // 40MHz channel support
67 pHTInfo->bRegBW40MHz = 1;
69 // CCK rate support in 40MHz channel
70 if(pHTInfo->bRegBW40MHz)
71 pHTInfo->bRegSuppCCK = 1;
73 pHTInfo->bRegSuppCCK = true;
76 pHTInfo->nAMSDU_MaxSize = 7935UL;
77 pHTInfo->bAMSDU_Support = 0;
80 pHTInfo->bAMPDUEnable = 1;
81 pHTInfo->AMPDU_Factor = 2; //// 0: 2n13(8K), 1:2n14(16K), 2:2n15(32K), 3:2n16(64k)
82 pHTInfo->MPDU_Density = 0;// 0: No restriction, 1: 1/8usec, 2: 1/4usec, 3: 1/2usec, 4: 1usec, 5: 2usec, 6: 4usec, 7:8usec
85 pHTInfo->SelfMimoPs = 3;// 0: Static Mimo Ps, 1: Dynamic Mimo Ps, 3: No Limitation, 2: Reserved(Set to 3 automatically.)
86 if(pHTInfo->SelfMimoPs == 2)
87 pHTInfo->SelfMimoPs = 3;
88 // 8190 only. Assign rate operation mode to firmware
89 ieee->bTxDisableRateFallBack = 0;
90 ieee->bTxUseDriverAssingedRate = 0;
93 // 8190 only. Assign duration operation mode to firmware
94 pMgntInfo->bTxEnableFwCalcDur = (BOOLEAN)pNdisCommon->bRegTxEnableFwCalcDur;
96 // 8190 only, Realtek proprietary aggregation mode
97 // Set MPDUDensity=2, 1: Set MPDUDensity=2(32k) for Realtek AP and set MPDUDensity=0(8k) for others
98 pHTInfo->bRegRT2RTAggregation = 1;//0: Set MPDUDensity=2, 1: Set MPDUDensity=2(32k) for Realtek AP and set MPDUDensity=0(8k) for others
100 // For Rx Reorder Control
101 pHTInfo->bRegRxReorderEnable = 1;
102 pHTInfo->RxReorderWinSize = 64;
103 pHTInfo->RxReorderPendingTime = 30;
105 #ifdef USB_TX_DRIVER_AGGREGATION_ENABLE
106 pHTInfo->UsbTxAggrNum = 4;
108 #ifdef USB_RX_AGGREGATION_SUPPORT
109 pHTInfo->UsbRxFwAggrEn = 1;
110 pHTInfo->UsbRxFwAggrPageNum = 24;
111 pHTInfo->UsbRxFwAggrPacketNum = 8;
112 pHTInfo->UsbRxFwAggrTimeout = 16; ////usb rx FW aggregation timeout threshold.It's in units of 64us
117 /********************************************************************************************************************
118 *function: This function print out each field on HT capability IE mainly from (Beacon/ProbeRsp/AssocReq)
119 * input: u8* CapIE //Capability IE to be printed out
120 * u8* TitleString //mainly print out caller function
123 * notice: Driver should not print out this message by default.
124 * *****************************************************************************************************************/
125 void HTDebugHTCapability(u8 *CapIE, u8 *TitleString )
128 static u8 EWC11NHTCap[] = {0x00, 0x90, 0x4c, 0x33}; // For 11n EWC definition, 2007.07.17, by Emily
129 PHT_CAPABILITY_ELE pCapELE;
131 if(!memcmp(CapIE, EWC11NHTCap, sizeof(EWC11NHTCap)))
134 IEEE80211_DEBUG(IEEE80211_DL_HT, "EWC IE in %s()\n", __func__);
135 pCapELE = (PHT_CAPABILITY_ELE)(&CapIE[4]);
137 pCapELE = (PHT_CAPABILITY_ELE)(&CapIE[0]);
139 IEEE80211_DEBUG(IEEE80211_DL_HT, "<Log HT Capability>. Called by %s\n", TitleString );
141 IEEE80211_DEBUG(IEEE80211_DL_HT, "\tSupported Channel Width = %s\n", (pCapELE->ChlWidth)?"20MHz": "20/40MHz");
142 IEEE80211_DEBUG(IEEE80211_DL_HT, "\tSupport Short GI for 20M = %s\n", (pCapELE->ShortGI20Mhz)?"YES": "NO");
143 IEEE80211_DEBUG(IEEE80211_DL_HT, "\tSupport Short GI for 40M = %s\n", (pCapELE->ShortGI40Mhz)?"YES": "NO");
144 IEEE80211_DEBUG(IEEE80211_DL_HT, "\tSupport TX STBC = %s\n", (pCapELE->TxSTBC)?"YES": "NO");
145 IEEE80211_DEBUG(IEEE80211_DL_HT, "\tMax AMSDU Size = %s\n", (pCapELE->MaxAMSDUSize)?"3839": "7935");
146 IEEE80211_DEBUG(IEEE80211_DL_HT, "\tSupport CCK in 20/40 mode = %s\n", (pCapELE->DssCCk)?"YES": "NO");
147 IEEE80211_DEBUG(IEEE80211_DL_HT, "\tMax AMPDU Factor = %d\n", pCapELE->MaxRxAMPDUFactor);
148 IEEE80211_DEBUG(IEEE80211_DL_HT, "\tMPDU Density = %d\n", pCapELE->MPDUDensity);
149 IEEE80211_DEBUG(IEEE80211_DL_HT, "\tMCS Rate Set = [%x][%x][%x][%x][%x]\n", pCapELE->MCS[0],\
150 pCapELE->MCS[1], pCapELE->MCS[2], pCapELE->MCS[3], pCapELE->MCS[4]);
154 /********************************************************************************************************************
155 *function: This function print out each field on HT Information IE mainly from (Beacon/ProbeRsp)
156 * input: u8* InfoIE //Capability IE to be printed out
157 * u8* TitleString //mainly print out caller function
160 * notice: Driver should not print out this message by default.
161 * *****************************************************************************************************************/
162 void HTDebugHTInfo(u8 *InfoIE, u8 *TitleString)
165 static u8 EWC11NHTInfo[] = {0x00, 0x90, 0x4c, 0x34}; // For 11n EWC definition, 2007.07.17, by Emily
166 PHT_INFORMATION_ELE pHTInfoEle;
168 if(!memcmp(InfoIE, EWC11NHTInfo, sizeof(EWC11NHTInfo)))
171 IEEE80211_DEBUG(IEEE80211_DL_HT, "EWC IE in %s()\n", __func__);
172 pHTInfoEle = (PHT_INFORMATION_ELE)(&InfoIE[4]);
174 pHTInfoEle = (PHT_INFORMATION_ELE)(&InfoIE[0]);
177 IEEE80211_DEBUG(IEEE80211_DL_HT, "<Log HT Information Element>. Called by %s\n", TitleString);
179 IEEE80211_DEBUG(IEEE80211_DL_HT, "\tPrimary channel = %d\n", pHTInfoEle->ControlChl);
180 IEEE80211_DEBUG(IEEE80211_DL_HT, "\tSecondary channel =");
181 switch (pHTInfoEle->ExtChlOffset)
184 IEEE80211_DEBUG(IEEE80211_DL_HT, "Not Present\n");
187 IEEE80211_DEBUG(IEEE80211_DL_HT, "Upper channel\n");
190 IEEE80211_DEBUG(IEEE80211_DL_HT, "Reserved. Eooro!!!\n");
193 IEEE80211_DEBUG(IEEE80211_DL_HT, "Lower Channel\n");
196 IEEE80211_DEBUG(IEEE80211_DL_HT, "\tRecommended channel width = %s\n", (pHTInfoEle->RecommemdedTxWidth)?"20Mhz": "40Mhz");
198 IEEE80211_DEBUG(IEEE80211_DL_HT, "\tOperation mode for protection = ");
199 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]);
221 * Return: true if station in half n mode and AP supports 40 bw
223 static bool IsHTHalfNmode40Bandwidth(struct ieee80211_device *ieee)
225 bool retValue = false;
226 PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
228 if(!pHTInfo->bCurrentHTSupport) // wireless is n mode
230 else if(!pHTInfo->bRegBW40MHz) // station supports 40 bw
232 else if(!ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev)) // station in half n mode
234 else if(((PHT_CAPABILITY_ELE)(pHTInfo->PeerHTCapBuf))->ChlWidth) // ap support 40 bw
242 static bool IsHTHalfNmodeSGI(struct ieee80211_device *ieee, bool is40MHz)
244 bool retValue = false;
245 PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
247 if(!pHTInfo->bCurrentHTSupport) // wireless is n mode
249 else if(!ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev)) // station in half n mode
251 else if(is40MHz) // ap support 40 bw
253 if(((PHT_CAPABILITY_ELE)(pHTInfo->PeerHTCapBuf))->ShortGI40Mhz) // ap support 40 bw short GI
260 if(((PHT_CAPABILITY_ELE)(pHTInfo->PeerHTCapBuf))->ShortGI20Mhz) // ap support 40 bw short GI
269 u16 HTHalfMcsToDataRate(struct ieee80211_device *ieee, u8 nMcsRate)
275 is40MHz = (IsHTHalfNmode40Bandwidth(ieee))?1:0;
276 isShortGI = (IsHTHalfNmodeSGI(ieee, is40MHz))? 1:0;
278 return MCS_DATA_RATE[is40MHz][isShortGI][(nMcsRate&0x7f)];
282 u16 HTMcsToDataRate(struct ieee80211_device *ieee, u8 nMcsRate)
284 PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
286 u8 is40MHz = (pHTInfo->bCurBW40MHz)?1:0;
287 u8 isShortGI = (pHTInfo->bCurBW40MHz)?
288 ((pHTInfo->bCurShortGI40MHz)?1:0):
289 ((pHTInfo->bCurShortGI20MHz)?1:0);
290 return MCS_DATA_RATE[is40MHz][isShortGI][(nMcsRate&0x7f)];
293 /********************************************************************************************************************
294 *function: This function returns current datarate.
295 * input: struct ieee80211_device* ieee
299 * notice: quite unsure about how to use this function //wb
300 * *****************************************************************************************************************/
301 u16 TxCountToDataRate(struct ieee80211_device *ieee, u8 nDataRate)
303 //PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
304 u16 CCKOFDMRate[12] = {0x02 , 0x04 , 0x0b , 0x16 , 0x0c , 0x12 , 0x18 , 0x24 , 0x30 , 0x48 , 0x60 , 0x6c};
310 return CCKOFDMRate[nDataRate];
314 if (nDataRate >= 0x10 && nDataRate <= 0x1f)//if(nDataRate > 11 && nDataRate < 28 )
319 // nDataRate = nDataRate - 12;
321 else if(nDataRate >=0x20 && nDataRate <= 0x2f ) //(27, 44)
326 //nDataRate = nDataRate - 28;
328 else if(nDataRate >= 0x30 && nDataRate <= 0x3f ) //(43, 60)
333 //nDataRate = nDataRate - 44;
335 else if(nDataRate >= 0x40 && nDataRate <= 0x4f ) //(59, 76)
340 //nDataRate = nDataRate - 60;
342 return MCS_DATA_RATE[is40MHz][isShortGI][nDataRate&0xf];
348 bool IsHTHalfNmodeAPs(struct ieee80211_device *ieee)
350 bool retValue = false;
351 struct ieee80211_network *net = &ieee->current_network;
352 if((memcmp(net->bssid, BELKINF5D8233V1_RALINK, 3)==0) ||
353 (memcmp(net->bssid, BELKINF5D82334V3_RALINK, 3)==0) ||
354 (memcmp(net->bssid, PCI_RALINK, 3)==0) ||
355 (memcmp(net->bssid, EDIMAX_RALINK, 3)==0) ||
356 (memcmp(net->bssid, AIRLINK_RALINK, 3)==0) ||
357 (net->ralink_cap_exist))
359 else if((memcmp(net->bssid, UNKNOWN_BORADCOM, 3)==0) ||
360 (memcmp(net->bssid, LINKSYSWRT330_LINKSYSWRT300_BROADCOM, 3)==0)||
361 (memcmp(net->bssid, LINKSYSWRT350_LINKSYSWRT150_BROADCOM, 3)==0)||
362 (memcmp(net->bssid, NETGEAR834Bv2_BROADCOM, 3)==0) ||
363 (net->broadcom_cap_exist))
365 else if(net->bssht.bdRT2RTAggregation)
373 /********************************************************************************************************************
374 *function: This function returns peer IOT.
375 * input: struct ieee80211_device* ieee
379 * *****************************************************************************************************************/
380 static void HTIOTPeerDetermine(struct ieee80211_device *ieee)
382 PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
383 struct ieee80211_network *net = &ieee->current_network;
384 if(net->bssht.bdRT2RTAggregation)
385 pHTInfo->IOTPeer = HT_IOT_PEER_REALTEK;
386 else if(net->broadcom_cap_exist)
387 pHTInfo->IOTPeer = HT_IOT_PEER_BROADCOM;
388 else if((memcmp(net->bssid, UNKNOWN_BORADCOM, 3)==0) ||
389 (memcmp(net->bssid, LINKSYSWRT330_LINKSYSWRT300_BROADCOM, 3)==0)||
390 (memcmp(net->bssid, LINKSYSWRT350_LINKSYSWRT150_BROADCOM, 3)==0)||
391 (memcmp(net->bssid, NETGEAR834Bv2_BROADCOM, 3)==0) )
392 pHTInfo->IOTPeer = HT_IOT_PEER_BROADCOM;
393 else if((memcmp(net->bssid, BELKINF5D8233V1_RALINK, 3)==0) ||
394 (memcmp(net->bssid, BELKINF5D82334V3_RALINK, 3)==0) ||
395 (memcmp(net->bssid, PCI_RALINK, 3)==0) ||
396 (memcmp(net->bssid, EDIMAX_RALINK, 3)==0) ||
397 (memcmp(net->bssid, AIRLINK_RALINK, 3)==0) ||
398 net->ralink_cap_exist)
399 pHTInfo->IOTPeer = HT_IOT_PEER_RALINK;
400 else if(net->atheros_cap_exist)
401 pHTInfo->IOTPeer = HT_IOT_PEER_ATHEROS;
402 else if(memcmp(net->bssid, CISCO_BROADCOM, 3)==0)
403 pHTInfo->IOTPeer = HT_IOT_PEER_CISCO;
405 pHTInfo->IOTPeer = HT_IOT_PEER_UNKNOWN;
407 IEEE80211_DEBUG(IEEE80211_DL_IOT, "Joseph debug!! IOTPEER: %x\n", pHTInfo->IOTPeer);
409 /********************************************************************************************************************
410 *function: Check whether driver should declare received rate up to MCS13 only since some chipset is not good
411 * at receiving MCS14~15 frame from some AP.
412 * input: struct ieee80211_device* ieee
415 * return: return 1 if driver should declare MCS13 only(otherwise return 0)
416 * *****************************************************************************************************************/
417 static u8 HTIOTActIsDisableMCS14(struct ieee80211_device *ieee, u8 *PeerMacAddr)
424 * Function: HTIOTActIsDisableMCS15
426 * Overview: Check whether driver should declare capability of receiving MCS15
432 * Return: true if driver should disable MCS15
435 static bool HTIOTActIsDisableMCS15(struct ieee80211_device *ieee)
437 bool retValue = false;
440 // Apply for 819u only
441 #if (HAL_CODE_BASE==RTL8192)
443 #if (DEV_BUS_TYPE == USB_INTERFACE)
444 // Alway disable MCS15 by Jerry Chang's request.by Emily, 2008.04.15
446 #elif (DEV_BUS_TYPE == PCI_INTERFACE)
447 // Enable MCS15 if the peer is Cisco AP. by Emily, 2008.05.12
448 // if(pBssDesc->bCiscoCapExist)
455 // Jerry Chang suggest that 8190 1x2 does not need to disable MCS15
461 * Function: HTIOTActIsDisableMCSTwoSpatialStream
463 * Overview: Check whether driver should declare capability of receiving All 2 ss packets
469 * Return: true if driver should disable all two spatial stream packet
472 static bool HTIOTActIsDisableMCSTwoSpatialStream(struct ieee80211_device *ieee,
476 // Apply for 819u only
481 /********************************************************************************************************************
482 *function: Check whether driver should disable EDCA turbo mode
483 * input: struct ieee80211_device* ieee
486 * return: return 1 if driver should disable EDCA turbo mode(otherwise return 0)
487 * *****************************************************************************************************************/
488 static u8 HTIOTActIsDisableEDCATurbo(struct ieee80211_device *ieee,
490 { /* default enable EDCA Turbo mode. */
494 /********************************************************************************************************************
495 *function: Check whether we need to use OFDM to sned MGNT frame for broadcom AP
496 * input: struct ieee80211_network *network //current network we live
498 * return: return 1 if true
499 * *****************************************************************************************************************/
500 static u8 HTIOTActIsMgntUseCCK6M(struct ieee80211_network *network)
504 // 2008/01/25 MH Judeg if we need to use OFDM to sned MGNT frame for broadcom AP.
505 // 2008/01/28 MH We must prevent that we select null bssid to link.
507 if (network->broadcom_cap_exist)
515 static u8 HTIOTActIsCCDFsync(u8 *PeerMacAddr)
518 if( (memcmp(PeerMacAddr, UNKNOWN_BORADCOM, 3)==0) ||
519 (memcmp(PeerMacAddr, LINKSYSWRT330_LINKSYSWRT300_BROADCOM, 3)==0) ||
520 (memcmp(PeerMacAddr, LINKSYSWRT350_LINKSYSWRT150_BROADCOM, 3) ==0))
528 void HTResetIOTSetting(
529 PRT_HIGH_THROUGHPUT pHTInfo
532 pHTInfo->IOTAction = 0;
533 pHTInfo->IOTPeer = HT_IOT_PEER_UNKNOWN;
537 /********************************************************************************************************************
538 *function: Construct Capablility Element in Beacon... if HTEnable is turned on
539 * input: struct ieee80211_device* ieee
540 * u8* posHTCap //pointer to store Capability Ele
541 * u8* len //store length of CE
542 * u8 IsEncrypt //whether encrypt, needed further
545 * notice: posHTCap can't be null and should be initialized before.
546 * *****************************************************************************************************************/
547 void HTConstructCapabilityElement(struct ieee80211_device *ieee, u8 *posHTCap, u8 *len, u8 IsEncrypt)
549 PRT_HIGH_THROUGHPUT pHT = ieee->pHTInfo;
550 PHT_CAPABILITY_ELE pCapELE = NULL;
551 //u8 bIsDeclareMCS13;
553 if ((posHTCap == NULL) || (pHT == NULL))
555 IEEE80211_DEBUG(IEEE80211_DL_ERR, "posHTCap or pHTInfo can't be null in HTConstructCapabilityElement()\n");
558 memset(posHTCap, 0, *len);
559 if(pHT->ePeerHTSpecVer == HT_SPEC_VER_EWC)
561 u8 EWC11NHTCap[] = {0x00, 0x90, 0x4c, 0x33}; // For 11n EWC definition, 2007.07.17, by Emily
562 memcpy(posHTCap, EWC11NHTCap, sizeof(EWC11NHTCap));
563 pCapELE = (PHT_CAPABILITY_ELE)&(posHTCap[4]);
566 pCapELE = (PHT_CAPABILITY_ELE)posHTCap;
571 pCapELE->AdvCoding = 0; // This feature is not supported now!!
572 if(ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev))
574 pCapELE->ChlWidth = 0;
578 pCapELE->ChlWidth = (pHT->bRegBW40MHz?1:0);
581 // pCapELE->ChlWidth = (pHT->bRegBW40MHz?1:0);
582 pCapELE->MimoPwrSave = pHT->SelfMimoPs;
583 pCapELE->GreenField = 0; // This feature is not supported now!!
584 pCapELE->ShortGI20Mhz = 1; // We can receive Short GI!!
585 pCapELE->ShortGI40Mhz = 1; // We can receive Short GI!!
586 //DbgPrint("TX HT cap/info ele BW=%d SG20=%d SG40=%d\n\r",
587 //pCapELE->ChlWidth, pCapELE->ShortGI20Mhz, pCapELE->ShortGI40Mhz);
590 pCapELE->DelayBA = 0; // Do not support now!!
591 pCapELE->MaxAMSDUSize = (MAX_RECEIVE_BUFFER_SIZE>=7935)?1:0;
592 pCapELE->DssCCk = ((pHT->bRegBW40MHz)?(pHT->bRegSuppCCK?1:0):0);
593 pCapELE->PSMP = 0; // Do not support now!!
594 pCapELE->LSigTxopProtect = 0; // Do not support now!!
597 //MAC HT parameters info
598 // TODO: Nedd to take care of this part
599 IEEE80211_DEBUG(IEEE80211_DL_HT, "TX HT cap/info ele BW=%d MaxAMSDUSize:%d DssCCk:%d\n", pCapELE->ChlWidth, pCapELE->MaxAMSDUSize, pCapELE->DssCCk);
602 pCapELE->MPDUDensity = 7; // 8us
603 pCapELE->MaxRxAMPDUFactor = 2; // 2 is for 32 K and 3 is 64K
607 pCapELE->MaxRxAMPDUFactor = 3; // 2 is for 32 K and 3 is 64K
608 pCapELE->MPDUDensity = 0; // no density
612 memcpy(pCapELE->MCS, ieee->Regdot11HTOperationalRateSet, 16);
613 if(pHT->IOTAction & HT_IOT_ACT_DISABLE_MCS15)
614 pCapELE->MCS[1] &= 0x7f;
616 if(pHT->IOTAction & HT_IOT_ACT_DISABLE_MCS14)
617 pCapELE->MCS[1] &= 0xbf;
619 if(pHT->IOTAction & HT_IOT_ACT_DISABLE_ALL_2SS)
620 pCapELE->MCS[1] &= 0x00;
623 // For RTL819X, if pairwisekey = wep/tkip, ap is ralink, we support only MCS0~7.
624 if (ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev))
627 for(i = 1; i< 16; i++)
631 //Extended HT Capability Info
632 memset(&pCapELE->ExtHTCapInfo, 0, 2);
636 memset(pCapELE->TxBFCap, 0, 4);
638 //Antenna Selection Capabilities
640 //add 2 to give space for element ID and len when construct frames
641 if(pHT->ePeerHTSpecVer == HT_SPEC_VER_EWC)
648 // IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA | IEEE80211_DL_HT, posHTCap, *len -2);
650 //Print each field in detail. Driver should not print out this message by default
651 // HTDebugHTCapability(posHTCap, (u8*)"HTConstructCapability()");
655 /********************************************************************************************************************
656 *function: Construct Information Element in Beacon... if HTEnable is turned on
657 * input: struct ieee80211_device* ieee
658 * u8* posHTCap //pointer to store Information Ele
659 * u8* len //store len of
660 * u8 IsEncrypt //whether encrypt, needed further
663 * notice: posHTCap can't be null and be initialized before. only AP and IBSS sta should do this
664 * *****************************************************************************************************************/
665 void HTConstructInfoElement(struct ieee80211_device *ieee, u8 *posHTInfo, u8 *len, u8 IsEncrypt)
667 PRT_HIGH_THROUGHPUT pHT = ieee->pHTInfo;
668 PHT_INFORMATION_ELE pHTInfoEle = (PHT_INFORMATION_ELE)posHTInfo;
669 if ((posHTInfo == NULL) || (pHTInfoEle == NULL))
671 IEEE80211_DEBUG(IEEE80211_DL_ERR, "posHTInfo or pHTInfoEle can't be null in HTConstructInfoElement()\n");
675 memset(posHTInfo, 0, *len);
676 if ( (ieee->iw_mode == IW_MODE_ADHOC) || (ieee->iw_mode == IW_MODE_MASTER)) //ap mode is not currently supported
678 pHTInfoEle->ControlChl = ieee->current_network.channel;
679 pHTInfoEle->ExtChlOffset = ((!pHT->bRegBW40MHz)?HT_EXTCHNL_OFFSET_NO_EXT:
680 (ieee->current_network.channel<=6)?
681 HT_EXTCHNL_OFFSET_UPPER:HT_EXTCHNL_OFFSET_LOWER);
682 pHTInfoEle->RecommemdedTxWidth = pHT->bRegBW40MHz;
683 pHTInfoEle->RIFS = 0;
684 pHTInfoEle->PSMPAccessOnly = 0;
685 pHTInfoEle->SrvIntGranularity = 0;
686 pHTInfoEle->OptMode = pHT->CurrentOpMode;
687 pHTInfoEle->NonGFDevPresent = 0;
688 pHTInfoEle->DualBeacon = 0;
689 pHTInfoEle->SecondaryBeacon = 0;
690 pHTInfoEle->LSigTxopProtectFull = 0;
691 pHTInfoEle->PcoActive = 0;
692 pHTInfoEle->PcoPhase = 0;
694 memset(pHTInfoEle->BasicMSC, 0, 16);
697 *len = 22 + 2; //same above
702 //STA should not generate High Throughput Information Element
705 //IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA | IEEE80211_DL_HT, posHTInfo, *len - 2);
706 //HTDebugHTInfo(posHTInfo, "HTConstructInforElement");
711 * According to experiment, Realtek AP to STA (based on rtl8190) may achieve best performance
712 * if both STA and AP set limitation of aggregation size to 32K, that is, set AMPDU density to 2
713 * (Ref: IEEE 11n specification). However, if Realtek STA associates to other AP, STA should set
714 * limitation of aggregation size to 8K, otherwise, performance of traffic stream from STA to AP
715 * will be much less than the traffic stream from AP to STA if both of the stream runs concurrently
719 * Element ID Length OUI Type1 Reserved
720 * 1 byte 1 byte 3 bytes 1 byte 1 byte
722 * OUI = 0x00, 0xe0, 0x4c,
728 /********************************************************************************************************************
729 *function: Construct Information Element in Beacon... in RT2RT condition
730 * input: struct ieee80211_device* ieee
731 * u8* posRT2RTAgg //pointer to store Information Ele
732 * u8* len //store len
736 * *****************************************************************************************************************/
737 void HTConstructRT2RTAggElement(struct ieee80211_device *ieee, u8 *posRT2RTAgg, u8 *len)
739 if (posRT2RTAgg == NULL) {
740 IEEE80211_DEBUG(IEEE80211_DL_ERR, "posRT2RTAgg can't be null in HTConstructRT2RTAggElement()\n");
743 memset(posRT2RTAgg, 0, *len);
744 *posRT2RTAgg++ = 0x00;
745 *posRT2RTAgg++ = 0xe0;
746 *posRT2RTAgg++ = 0x4c;
747 *posRT2RTAgg++ = 0x02;
748 *posRT2RTAgg++ = 0x01;
749 *posRT2RTAgg = 0x10;//*posRT2RTAgg = 0x02;
751 if (ieee->bSupportRemoteWakeUp) {
752 *posRT2RTAgg |= 0x08;//RT_HT_CAP_USE_WOW;
758 #if (HAL_CODE_BASE == RTL8192 && DEV_BUS_TYPE == USB_INTERFACE)
760 //Emily. If it is required to Ask Realtek AP to send AMPDU during AES mode, enable this
762 if(IS_UNDER_11N_AES_MODE(Adapter))
764 posRT2RTAgg->Octet[5] |=RT_HT_CAP_USE_AMPDU;
767 posRT2RTAgg->Octet[5] &= 0xfb;
775 posRT2RTAgg->Length = 6;
784 /********************************************************************************************************************
785 *function: Pick the right Rate Adaptive table to use
786 * input: struct ieee80211_device* ieee
787 * u8* pOperateMCS //A pointer to MCS rate bitmap
788 * return: always we return true
790 * *****************************************************************************************************************/
791 static u8 HT_PickMCSRate(struct ieee80211_device *ieee, u8 *pOperateMCS)
794 if (pOperateMCS == NULL)
796 IEEE80211_DEBUG(IEEE80211_DL_ERR, "pOperateMCS can't be null in HT_PickMCSRate()\n");
805 //legacy rate routine handled at selectedrate
813 case IEEE_N_24G: //assume CCK rate ok
815 // Legacy part we only use 6, 5.5,2,1 for N_24G and 6 for N_5G.
816 // Legacy part shall be handled at SelectRateSet().
819 // TODO: may be different if we have different number of antenna
820 pOperateMCS[0] &=RATE_ADPT_1SS_MASK; //support MCS 0~7
821 pOperateMCS[1] &=RATE_ADPT_2SS_MASK;
822 pOperateMCS[3] &=RATE_ADPT_MCS32_MASK;
825 //should never reach here
837 * This function will get the highest speed rate in input MCS set.
839 * /param Adapter Pionter to Adapter entity
840 * pMCSRateSet Pointer to MCS rate bitmap
841 * pMCSFilter Pointer to MCS rate filter
843 * /return Highest MCS rate included in pMCSRateSet and filtered by pMCSFilter.
846 /********************************************************************************************************************
847 *function: This function will get the highest speed rate in input MCS set.
848 * input: struct ieee80211_device* ieee
849 * u8* pMCSRateSet //Pointer to MCS rate bitmap
850 * u8* pMCSFilter //Pointer to MCS rate filter
851 * return: Highest MCS rate included in pMCSRateSet and filtered by pMCSFilter
853 * *****************************************************************************************************************/
854 u8 HTGetHighestMCSRate(struct ieee80211_device *ieee, u8 *pMCSRateSet, u8 *pMCSFilter)
859 u8 availableMcsRate[16];
860 if (pMCSRateSet == NULL || pMCSFilter == NULL)
862 IEEE80211_DEBUG(IEEE80211_DL_ERR, "pMCSRateSet or pMCSFilter can't be null in HTGetHighestMCSRate()\n");
866 availableMcsRate[i] = pMCSRateSet[i] & pMCSFilter[i];
868 for(i = 0; i < 16; i++)
870 if(availableMcsRate[i] != 0)
876 for(i = 0; i < 16; i++)
878 if (availableMcsRate[i] != 0)
880 bitMap = availableMcsRate[i];
881 for(j = 0; j < 8; j++)
885 if(HTMcsToDataRate(ieee, (8*i+j)) > HTMcsToDataRate(ieee, mcsRate))
892 return (mcsRate|0x80);
899 **1.Filter our operation rate set with AP's rate set
900 **2.shall reference channel bandwidth, STBC, Antenna number
901 **3.generate rate adative table for firmware
904 ** \pHTSupportedCap: the connected STA's supported rate Capability element
906 static u8 HTFilterMCSRate(struct ieee80211_device *ieee, u8 *pSupportMCS,
912 // filter out operational rate set not supported by AP, the length of it is 16
914 pOperateMCS[i] = ieee->Regdot11HTOperationalRateSet[i]&pSupportMCS[i];
918 // TODO: adjust our operational rate set according to our channel bandwidth, STBC and Antenna number
920 // TODO: fill suggested rate adaptive rate index and give firmware info using Tx command packet
921 // we also shall suggested the first start rate set according to our singal strength
922 HT_PickMCSRate(ieee, pOperateMCS);
924 // For RTL819X, if pairwisekey = wep/tkip, we support only MCS0~7.
925 if(ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev))
929 // For RTL819X, we support only MCS0~15.
930 // And also, we do not know how to use MCS32 now.
937 void HTSetConnectBwMode(struct ieee80211_device *ieee, HT_CHANNEL_WIDTH Bandwidth, HT_EXTCHNL_OFFSET Offset);
938 void HTOnAssocRsp(struct ieee80211_device *ieee)
940 PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
941 PHT_CAPABILITY_ELE pPeerHTCap = NULL;
942 PHT_INFORMATION_ELE pPeerHTInfo = NULL;
943 u16 nMaxAMSDUSize = 0;
944 u8 *pMcsFilter = NULL;
946 static u8 EWC11NHTCap[] = {0x00, 0x90, 0x4c, 0x33}; // For 11n EWC definition, 2007.07.17, by Emily
947 static u8 EWC11NHTInfo[] = {0x00, 0x90, 0x4c, 0x34}; // For 11n EWC definition, 2007.07.17, by Emily
949 if (!pHTInfo->bCurrentHTSupport) {
950 IEEE80211_DEBUG(IEEE80211_DL_ERR, "<=== HTOnAssocRsp(): HT_DISABLE\n");
953 IEEE80211_DEBUG(IEEE80211_DL_HT, "===> HTOnAssocRsp_wq(): HT_ENABLE\n");
954 // IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA, pHTInfo->PeerHTCapBuf, sizeof(HT_CAPABILITY_ELE));
955 // IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA, pHTInfo->PeerHTInfoBuf, sizeof(HT_INFORMATION_ELE));
957 // HTDebugHTCapability(pHTInfo->PeerHTCapBuf,"HTOnAssocRsp_wq");
958 // HTDebugHTInfo(pHTInfo->PeerHTInfoBuf,"HTOnAssocRsp_wq");
960 if (!memcmp(pHTInfo->PeerHTCapBuf, EWC11NHTCap, sizeof(EWC11NHTCap)))
961 pPeerHTCap = (PHT_CAPABILITY_ELE)(&pHTInfo->PeerHTCapBuf[4]);
963 pPeerHTCap = (PHT_CAPABILITY_ELE)(pHTInfo->PeerHTCapBuf);
965 if(!memcmp(pHTInfo->PeerHTInfoBuf, EWC11NHTInfo, sizeof(EWC11NHTInfo)))
966 pPeerHTInfo = (PHT_INFORMATION_ELE)(&pHTInfo->PeerHTInfoBuf[4]);
968 pPeerHTInfo = (PHT_INFORMATION_ELE)(pHTInfo->PeerHTInfoBuf);
971 ////////////////////////////////////////////////////////
973 ////////////////////////////////////////////////////////
974 IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA|IEEE80211_DL_HT, pPeerHTCap, sizeof(HT_CAPABILITY_ELE));
975 // IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA|IEEE80211_DL_HT, pPeerHTInfo, sizeof(HT_INFORMATION_ELE));
976 // Config Supported Channel Width setting
978 HTSetConnectBwMode(ieee, (HT_CHANNEL_WIDTH)(pPeerHTCap->ChlWidth), (HT_EXTCHNL_OFFSET)(pPeerHTInfo->ExtChlOffset));
980 pHTInfo->bCurTxBW40MHz = (pPeerHTInfo->RecommemdedTxWidth == 1);
983 // Update short GI/ long GI setting
986 pHTInfo->bCurShortGI20MHz = pHTInfo->bRegShortGI20MHz &&
987 (pPeerHTCap->ShortGI20Mhz == 1);
988 pHTInfo->bCurShortGI40MHz = pHTInfo->bRegShortGI40MHz &&
989 (pPeerHTCap->ShortGI40Mhz == 1);
992 // Config TX STBC setting
997 // Config DSSS/CCK mode in 40MHz mode
1000 pHTInfo->bCurSuppCCK = pHTInfo->bRegSuppCCK &&
1001 (pPeerHTCap->DssCCk == 1);
1005 // Config and configure A-MSDU setting
1007 pHTInfo->bCurrent_AMSDU_Support = pHTInfo->bAMSDU_Support;
1009 nMaxAMSDUSize = (pPeerHTCap->MaxAMSDUSize==0)?3839:7935;
1011 if(pHTInfo->nAMSDU_MaxSize > nMaxAMSDUSize )
1012 pHTInfo->nCurrent_AMSDU_MaxSize = nMaxAMSDUSize;
1014 pHTInfo->nCurrent_AMSDU_MaxSize = pHTInfo->nAMSDU_MaxSize;
1018 // Config A-MPDU setting
1020 pHTInfo->bCurrentAMPDUEnable = pHTInfo->bAMPDUEnable;
1022 // <1> Decide AMPDU Factor
1025 if(!pHTInfo->bRegRT2RTAggregation)
1027 // Decide AMPDU Factor according to protocol handshake
1028 if(pHTInfo->AMPDU_Factor > pPeerHTCap->MaxRxAMPDUFactor)
1029 pHTInfo->CurrentAMPDUFactor = pPeerHTCap->MaxRxAMPDUFactor;
1031 pHTInfo->CurrentAMPDUFactor = pHTInfo->AMPDU_Factor;
1035 // Set MPDU density to 2 to Realtek AP, and set it to 0 for others
1036 // Replace MPDU factor declared in original association response frame format. 2007.08.20 by Emily
1037 if (ieee->current_network.bssht.bdRT2RTAggregation)
1039 if (ieee->pairwise_key_type != KEY_TYPE_NA)
1040 // Realtek may set 32k in security mode and 64k for others
1041 pHTInfo->CurrentAMPDUFactor = pPeerHTCap->MaxRxAMPDUFactor;
1043 pHTInfo->CurrentAMPDUFactor = HT_AGG_SIZE_64K;
1046 if(pPeerHTCap->MaxRxAMPDUFactor < HT_AGG_SIZE_32K)
1047 pHTInfo->CurrentAMPDUFactor = pPeerHTCap->MaxRxAMPDUFactor;
1049 pHTInfo->CurrentAMPDUFactor = HT_AGG_SIZE_32K;
1053 // <2> Set AMPDU Minimum MPDU Start Spacing
1054 // 802.11n 3.0 section 9.7d.3
1055 if(pHTInfo->MPDU_Density > pPeerHTCap->MPDUDensity)
1056 pHTInfo->CurrentMPDUDensity = pHTInfo->MPDU_Density;
1058 pHTInfo->CurrentMPDUDensity = pPeerHTCap->MPDUDensity;
1059 if(ieee->pairwise_key_type != KEY_TYPE_NA )
1060 pHTInfo->CurrentMPDUDensity = 7; // 8us
1063 // Lanhsin: mark for tmp to avoid deauth by ap from s3
1064 //if(memcmp(pMgntInfo->Bssid, NETGEAR834Bv2_BROADCOM, 3)==0)
1068 pHTInfo->bCurrentAMPDUEnable = false;
1069 pHTInfo->ForcedAMSDUMode = HT_AGG_FORCE_ENABLE;
1070 pHTInfo->ForcedAMSDUMaxSize = 7935;
1072 pHTInfo->IOTAction |= HT_IOT_ACT_TX_USE_AMSDU_8K;
1075 // Rx Reorder Setting
1076 pHTInfo->bCurRxReorderEnable = pHTInfo->bRegRxReorderEnable;
1079 // Filter out unsupported HT rate for this AP
1080 // Update RATR table
1081 // This is only for 8190 ,8192 or later product which using firmware to handle rate adaptive mechanism.
1084 // Handle Ralink AP bad MCS rate set condition. Joseph.
1085 // This fix the bug of Ralink AP. This may be removed in the future.
1086 if(pPeerHTCap->MCS[0] == 0)
1087 pPeerHTCap->MCS[0] = 0xff;
1089 HTFilterMCSRate(ieee, pPeerHTCap->MCS, ieee->dot11HTOperationalRateSet);
1092 // Config MIMO Power Save setting
1094 pHTInfo->PeerMimoPs = pPeerHTCap->MimoPwrSave;
1095 if(pHTInfo->PeerMimoPs == MIMO_PS_STATIC)
1096 pMcsFilter = MCS_FILTER_1SS;
1098 pMcsFilter = MCS_FILTER_ALL;
1099 //WB add for MCS8 bug
1100 // pMcsFilter = MCS_FILTER_1SS;
1101 ieee->HTHighestOperaRate = HTGetHighestMCSRate(ieee, ieee->dot11HTOperationalRateSet, pMcsFilter);
1102 ieee->HTCurrentOperaRate = ieee->HTHighestOperaRate;
1105 // Config current operation mode.
1107 pHTInfo->CurrentOpMode = pPeerHTInfo->OptMode;
1113 void HTSetConnectBwModeCallback(struct ieee80211_device *ieee);
1114 /********************************************************************************************************************
1115 *function: initialize HT info(struct PRT_HIGH_THROUGHPUT)
1116 * input: struct ieee80211_device* ieee
1119 * notice: This function is called when * (1) MPInitialization Phase * (2) Receiving of Deauthentication from AP
1120 ********************************************************************************************************************/
1121 // TODO: Should this funciton be called when receiving of Disassociation?
1122 void HTInitializeHTInfo(struct ieee80211_device *ieee)
1124 PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
1127 // These parameters will be reset when receiving deauthentication packet
1129 IEEE80211_DEBUG(IEEE80211_DL_HT, "===========>%s()\n", __func__);
1130 pHTInfo->bCurrentHTSupport = false;
1132 // 40MHz channel support
1133 pHTInfo->bCurBW40MHz = false;
1134 pHTInfo->bCurTxBW40MHz = false;
1137 pHTInfo->bCurShortGI20MHz = false;
1138 pHTInfo->bCurShortGI40MHz = false;
1139 pHTInfo->bForcedShortGI = false;
1142 // This flag is set to true to support CCK rate by default.
1143 // It will be affected by "pHTInfo->bRegSuppCCK" and AP capabilities only when associate to
1145 pHTInfo->bCurSuppCCK = true;
1148 pHTInfo->bCurrent_AMSDU_Support = false;
1149 pHTInfo->nCurrent_AMSDU_MaxSize = pHTInfo->nAMSDU_MaxSize;
1152 pHTInfo->CurrentMPDUDensity = pHTInfo->MPDU_Density;
1153 pHTInfo->CurrentAMPDUFactor = pHTInfo->AMPDU_Factor;
1157 // Initialize all of the parameters related to 11n
1158 memset((void *)(&(pHTInfo->SelfHTCap)), 0, sizeof(pHTInfo->SelfHTCap));
1159 memset((void *)(&(pHTInfo->SelfHTInfo)), 0, sizeof(pHTInfo->SelfHTInfo));
1160 memset((void *)(&(pHTInfo->PeerHTCapBuf)), 0, sizeof(pHTInfo->PeerHTCapBuf));
1161 memset((void *)(&(pHTInfo->PeerHTInfoBuf)), 0, sizeof(pHTInfo->PeerHTInfoBuf));
1163 pHTInfo->bSwBwInProgress = false;
1164 pHTInfo->ChnlOp = CHNLOP_NONE;
1166 // Set default IEEE spec for Draft N
1167 pHTInfo->ePeerHTSpecVer = HT_SPEC_VER_IEEE;
1169 // Realtek proprietary aggregation mode
1170 pHTInfo->bCurrentRT2RTAggregation = false;
1171 pHTInfo->bCurrentRT2RTLongSlotTime = false;
1172 pHTInfo->IOTPeer = 0;
1173 pHTInfo->IOTAction = 0;
1175 //MCS rate initialized here
1177 u8 *RegHTSuppRateSets = &(ieee->RegHTSuppRateSet[0]);
1178 RegHTSuppRateSets[0] = 0xFF; //support MCS 0~7
1179 RegHTSuppRateSets[1] = 0xFF; //support MCS 8~15
1180 RegHTSuppRateSets[4] = 0x01; //support MCS 32
1183 /********************************************************************************************************************
1184 *function: initialize Bss HT structure(struct PBSS_HT)
1185 * input: PBSS_HT pBssHT //to be initialized
1188 * notice: This function is called when initialize network structure
1189 ********************************************************************************************************************/
1190 void HTInitializeBssDesc(PBSS_HT pBssHT)
1193 pBssHT->bdSupportHT = false;
1194 memset(pBssHT->bdHTCapBuf, 0, sizeof(pBssHT->bdHTCapBuf));
1195 pBssHT->bdHTCapLen = 0;
1196 memset(pBssHT->bdHTInfoBuf, 0, sizeof(pBssHT->bdHTInfoBuf));
1197 pBssHT->bdHTInfoLen = 0;
1199 pBssHT->bdHTSpecVer= HT_SPEC_VER_IEEE;
1201 pBssHT->bdRT2RTAggregation = false;
1202 pBssHT->bdRT2RTLongSlotTime = false;
1204 /********************************************************************************************************************
1205 *function: initialize Bss HT structure(struct PBSS_HT)
1206 * input: struct ieee80211_device *ieee
1207 * struct ieee80211_network *pNetwork //usually current network we are live in
1210 * notice: This function should ONLY be called before association
1211 ********************************************************************************************************************/
1212 void HTResetSelfAndSavePeerSetting(struct ieee80211_device *ieee, struct ieee80211_network *pNetwork)
1214 PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
1215 // u16 nMaxAMSDUSize;
1216 // PHT_CAPABILITY_ELE pPeerHTCap = (PHT_CAPABILITY_ELE)pNetwork->bssht.bdHTCapBuf;
1217 // PHT_INFORMATION_ELE pPeerHTInfo = (PHT_INFORMATION_ELE)pNetwork->bssht.bdHTInfoBuf;
1222 // Save Peer Setting before Association
1224 IEEE80211_DEBUG(IEEE80211_DL_HT, "==============>%s()\n", __func__);
1225 /*unmark bEnableHT flag here is the same reason why unmarked in function ieee80211_softmac_new_net. WB 2008.09.10*/
1226 // if( pHTInfo->bEnableHT && pNetwork->bssht.bdSupportHT)
1227 if (pNetwork->bssht.bdSupportHT)
1229 pHTInfo->bCurrentHTSupport = true;
1230 pHTInfo->ePeerHTSpecVer = pNetwork->bssht.bdHTSpecVer;
1232 // Save HTCap and HTInfo information Element
1233 if(pNetwork->bssht.bdHTCapLen > 0 && pNetwork->bssht.bdHTCapLen <= sizeof(pHTInfo->PeerHTCapBuf))
1234 memcpy(pHTInfo->PeerHTCapBuf, pNetwork->bssht.bdHTCapBuf, pNetwork->bssht.bdHTCapLen);
1236 if(pNetwork->bssht.bdHTInfoLen > 0 && pNetwork->bssht.bdHTInfoLen <= sizeof(pHTInfo->PeerHTInfoBuf))
1237 memcpy(pHTInfo->PeerHTInfoBuf, pNetwork->bssht.bdHTInfoBuf, pNetwork->bssht.bdHTInfoLen);
1239 // Check whether RT to RT aggregation mode is enabled
1240 if(pHTInfo->bRegRT2RTAggregation)
1242 pHTInfo->bCurrentRT2RTAggregation = pNetwork->bssht.bdRT2RTAggregation;
1243 pHTInfo->bCurrentRT2RTLongSlotTime = pNetwork->bssht.bdRT2RTLongSlotTime;
1247 pHTInfo->bCurrentRT2RTAggregation = false;
1248 pHTInfo->bCurrentRT2RTLongSlotTime = false;
1251 // Determine the IOT Peer Vendor.
1252 HTIOTPeerDetermine(ieee);
1254 // Decide IOT Action
1255 // Must be called after the parameter of pHTInfo->bCurrentRT2RTAggregation is decided
1256 pHTInfo->IOTAction = 0;
1257 bIOTAction = HTIOTActIsDisableMCS14(ieee, pNetwork->bssid);
1259 pHTInfo->IOTAction |= HT_IOT_ACT_DISABLE_MCS14;
1261 bIOTAction = HTIOTActIsDisableMCS15(ieee);
1263 pHTInfo->IOTAction |= HT_IOT_ACT_DISABLE_MCS15;
1265 bIOTAction = HTIOTActIsDisableMCSTwoSpatialStream(ieee, pNetwork->bssid);
1267 pHTInfo->IOTAction |= HT_IOT_ACT_DISABLE_ALL_2SS;
1270 bIOTAction = HTIOTActIsDisableEDCATurbo(ieee, pNetwork->bssid);
1272 pHTInfo->IOTAction |= HT_IOT_ACT_DISABLE_EDCA_TURBO;
1274 bIOTAction = HTIOTActIsMgntUseCCK6M(pNetwork);
1276 pHTInfo->IOTAction |= HT_IOT_ACT_MGNT_USE_CCK_6M;
1278 bIOTAction = HTIOTActIsCCDFsync(pNetwork->bssid);
1280 pHTInfo->IOTAction |= HT_IOT_ACT_CDD_FSYNC;
1286 pHTInfo->bCurrentHTSupport = false;
1287 pHTInfo->bCurrentRT2RTAggregation = false;
1288 pHTInfo->bCurrentRT2RTLongSlotTime = false;
1290 pHTInfo->IOTAction = 0;
1295 void HTUpdateSelfAndPeerSetting(struct ieee80211_device *ieee, struct ieee80211_network *pNetwork)
1297 PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
1298 // PHT_CAPABILITY_ELE pPeerHTCap = (PHT_CAPABILITY_ELE)pNetwork->bssht.bdHTCapBuf;
1299 PHT_INFORMATION_ELE pPeerHTInfo = (PHT_INFORMATION_ELE)pNetwork->bssht.bdHTInfoBuf;
1301 if (pHTInfo->bCurrentHTSupport)
1304 // Config current operation mode.
1306 if(pNetwork->bssht.bdHTInfoLen != 0)
1307 pHTInfo->CurrentOpMode = pPeerHTInfo->OptMode;
1310 // <TODO: Config according to OBSS non-HT STA present!!>
1314 EXPORT_SYMBOL(HTUpdateSelfAndPeerSetting);
1316 /********************************************************************************************************************
1317 *function: check whether HT control field exists
1318 * input: struct ieee80211_device *ieee
1319 * u8* pFrame //coming skb->data
1321 * return: return true if HT control field exists(false otherwise)
1323 ********************************************************************************************************************/
1324 u8 HTCCheck(struct ieee80211_device *ieee, u8 *pFrame)
1326 if (ieee->pHTInfo->bCurrentHTSupport)
1328 if ((IsQoSDataFrame(pFrame) && Frame_Order(pFrame)) == 1) {
1329 IEEE80211_DEBUG(IEEE80211_DL_HT, "HT CONTROL FILED EXIST!!\n");
1337 // This function set bandwidth mode in protocol layer.
1339 void HTSetConnectBwMode(struct ieee80211_device *ieee, HT_CHANNEL_WIDTH Bandwidth, HT_EXTCHNL_OFFSET Offset)
1341 PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
1344 if(!pHTInfo->bRegBW40MHz)
1349 // To reduce dummy operation
1350 // if((pHTInfo->bCurBW40MHz==false && Bandwidth==HT_CHANNEL_WIDTH_20) ||
1351 // (pHTInfo->bCurBW40MHz==true && Bandwidth==HT_CHANNEL_WIDTH_20_40 && Offset==pHTInfo->CurSTAExtChnlOffset))
1354 // spin_lock_irqsave(&(ieee->bw_spinlock), flags);
1355 if (pHTInfo->bSwBwInProgress) {
1356 // spin_unlock_irqrestore(&(ieee->bw_spinlock), flags);
1359 //if in half N mode, set to 20M bandwidth please 09.08.2008 WB.
1360 if(Bandwidth==HT_CHANNEL_WIDTH_20_40 && (!ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev)))
1362 // Handle Illegal extension channel offset!!
1363 if(ieee->current_network.channel<2 && Offset==HT_EXTCHNL_OFFSET_LOWER)
1364 Offset = HT_EXTCHNL_OFFSET_NO_EXT;
1365 if(Offset==HT_EXTCHNL_OFFSET_UPPER || Offset==HT_EXTCHNL_OFFSET_LOWER) {
1366 pHTInfo->bCurBW40MHz = true;
1367 pHTInfo->CurSTAExtChnlOffset = Offset;
1369 pHTInfo->bCurBW40MHz = false;
1370 pHTInfo->CurSTAExtChnlOffset = HT_EXTCHNL_OFFSET_NO_EXT;
1373 pHTInfo->bCurBW40MHz = false;
1374 pHTInfo->CurSTAExtChnlOffset = HT_EXTCHNL_OFFSET_NO_EXT;
1377 pHTInfo->bSwBwInProgress = true;
1379 // TODO: 2007.7.13 by Emily Wait 2000ms in order to guarantee that switching
1380 // bandwidth is executed after scan is finished. It is a temporal solution
1381 // because software should ganrantee the last operation of switching bandwidth
1382 // is executed properlly.
1383 HTSetConnectBwModeCallback(ieee);
1385 // spin_unlock_irqrestore(&(ieee->bw_spinlock), flags);
1388 void HTSetConnectBwModeCallback(struct ieee80211_device *ieee)
1390 PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
1392 IEEE80211_DEBUG(IEEE80211_DL_HT, "======>%s()\n", __func__);
1394 if(pHTInfo->bCurBW40MHz)
1396 if(pHTInfo->CurSTAExtChnlOffset==HT_EXTCHNL_OFFSET_UPPER)
1397 ieee->set_chan(ieee->dev, ieee->current_network.channel+2);
1398 else if(pHTInfo->CurSTAExtChnlOffset==HT_EXTCHNL_OFFSET_LOWER)
1399 ieee->set_chan(ieee->dev, ieee->current_network.channel-2);
1401 ieee->set_chan(ieee->dev, ieee->current_network.channel);
1403 ieee->SetBWModeHandler(ieee->dev, HT_CHANNEL_WIDTH_20_40, pHTInfo->CurSTAExtChnlOffset);
1405 ieee->set_chan(ieee->dev, ieee->current_network.channel);
1406 ieee->SetBWModeHandler(ieee->dev, HT_CHANNEL_WIDTH_20, HT_EXTCHNL_OFFSET_NO_EXT);
1409 pHTInfo->bSwBwInProgress = false;