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
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 "ieee80211.h"
20 #include "rtl819x_HT.h"
21 u8 MCS_FILTER_ALL[16] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
23 u8 MCS_FILTER_1SS[16] = {0xff, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
25 u16 MCS_DATA_RATE[2][2][77] =
26 { { {13, 26, 39, 52, 78, 104, 117, 130, 26, 52, 78 ,104, 156, 208, 234, 260,
27 39, 78, 117, 234, 312, 351, 390, 52, 104, 156, 208, 312, 416, 468, 520,
28 0, 78, 104, 130, 117, 156, 195, 104, 130, 130, 156, 182, 182, 208, 156, 195,
29 195, 234, 273, 273, 312, 130, 156, 181, 156, 181, 208, 234, 208, 234, 260, 260,
30 286, 195, 234, 273, 234, 273, 312, 351, 312, 351, 390, 390, 429},
31 {14, 29, 43, 58, 87, 116, 130, 144, 29, 58, 87, 116, 173, 231, 260, 289,
32 43, 87, 130, 173, 260, 347, 390, 433, 58, 116, 173, 231, 347, 462, 520, 578,
33 0, 87, 116, 144, 130, 173, 217, 116, 144, 144, 173, 202, 202, 231, 173, 217,
34 217, 260, 303, 303, 347, 144, 173, 202, 173, 202, 231, 260, 231, 260, 289, 289,
35 318, 217, 260, 303, 260, 303, 347, 390, 347, 390, 433, 433, 477} },
36 { {27, 54, 81, 108, 162, 216, 243, 270, 54, 108, 162, 216, 324, 432, 486, 540,
37 81, 162, 243, 324, 486, 648, 729, 810, 108, 216, 324, 432, 648, 864, 972, 1080,
38 12, 162, 216, 270, 243, 324, 405, 216, 270, 270, 324, 378, 378, 432, 324, 405,
39 405, 486, 567, 567, 648, 270, 324, 378, 324, 378, 432, 486, 432, 486, 540, 540,
40 594, 405, 486, 567, 486, 567, 648, 729, 648, 729, 810, 810, 891},
41 {30, 60, 90, 120, 180, 240, 270, 300, 60, 120, 180, 240, 360, 480, 540, 600,
42 90, 180, 270, 360, 540, 720, 810, 900, 120, 240, 360, 480, 720, 960, 1080, 1200,
43 13, 180, 240, 300, 270, 360, 450, 240, 300, 300, 360, 420, 420, 480, 360, 450,
44 450, 540, 630, 630, 720, 300, 360, 420, 360, 420, 480, 540, 480, 540, 600, 600,
45 660, 450, 540, 630, 540, 630, 720, 810, 720, 810, 900, 900, 990} }
48 static u8 UNKNOWN_BORADCOM[3] = {0x00, 0x14, 0xbf};
49 static u8 LINKSYSWRT330_LINKSYSWRT300_BROADCOM[3] = {0x00, 0x1a, 0x70};
50 static u8 LINKSYSWRT350_LINKSYSWRT150_BROADCOM[3] = {0x00, 0x1d, 0x7e};
51 static u8 BELKINF5D8233V1_RALINK[3] = {0x00, 0x17, 0x3f};
52 static u8 BELKINF5D82334V3_RALINK[3] = {0x00, 0x1c, 0xdf};
53 static u8 PCI_RALINK[3] = {0x00, 0x90, 0xcc};
54 static u8 EDIMAX_RALINK[3] = {0x00, 0x0e, 0x2e};
55 static u8 AIRLINK_RALINK[3] = {0x00, 0x18, 0x02};
56 static u8 DLINK_ATHEROS_1[3] = {0x00, 0x1c, 0xf0};
57 static u8 DLINK_ATHEROS_2[3] = {0x00, 0x21, 0x91};
58 static u8 CISCO_BROADCOM[3] = {0x00, 0x17, 0x94};
59 static u8 NETGEAR_BROADCOM[3] = {0x00, 0x1f, 0x33};
60 static u8 LINKSYS_MARVELL_4400N[3] = {0x00, 0x14, 0xa4};
62 /********************************************************************************************************************
63 *function: This function update default settings in pHTInfo structure
64 * input: PRT_HIGH_THROUGHPUT pHTInfo
67 * notice: These value need be modified if any changes.
68 * *****************************************************************************************************************/
69 void HTUpdateDefaultSetting(struct ieee80211_device* ieee)
71 PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
74 pHTInfo->bRegShortGI20MHz= 1;
75 pHTInfo->bRegShortGI40MHz= 1;
77 // 40MHz channel support
78 pHTInfo->bRegBW40MHz = 1;
80 // CCK rate support in 40MHz channel
81 if(pHTInfo->bRegBW40MHz)
82 pHTInfo->bRegSuppCCK = 1;
84 pHTInfo->bRegSuppCCK = true;
87 pHTInfo->nAMSDU_MaxSize = 7935UL;
88 pHTInfo->bAMSDU_Support = 0;
91 pHTInfo->bAMPDUEnable = 1; //YJ,test,090311
92 pHTInfo->AMPDU_Factor = 2; //// 0: 2n13(8K), 1:2n14(16K), 2:2n15(32K), 3:2n16(64k)
93 pHTInfo->MPDU_Density = 0;// 0: No restriction, 1: 1/8usec, 2: 1/4usec, 3: 1/2usec, 4: 1usec, 5: 2usec, 6: 4usec, 7:8usec
96 pHTInfo->SelfMimoPs = 3;// 0: Static Mimo Ps, 1: Dynamic Mimo Ps, 3: No Limitation, 2: Reserved(Set to 3 automatically.)
97 if(pHTInfo->SelfMimoPs == 2)
98 pHTInfo->SelfMimoPs = 3;
99 // 8190 only. Assign rate operation mode to firmware
100 ieee->bTxDisableRateFallBack = 0;
101 ieee->bTxUseDriverAssingedRate = 0;
104 // 8190 only. Assign duration operation mode to firmware
105 pMgntInfo->bTxEnableFwCalcDur = (BOOLEAN)pNdisCommon->bRegTxEnableFwCalcDur;
107 // 8190 only, Realtek proprietary aggregation mode
108 // Set MPDUDensity=2, 1: Set MPDUDensity=2(32k) for Realtek AP and set MPDUDensity=0(8k) for others
109 pHTInfo->bRegRT2RTAggregation = 1;//0: Set MPDUDensity=2, 1: Set MPDUDensity=2(32k) for Realtek AP and set MPDUDensity=0(8k) for others
111 // For Rx Reorder Control
112 pHTInfo->bRegRxReorderEnable = 1;//YJ,test,090311
113 pHTInfo->RxReorderWinSize = 64;
114 pHTInfo->RxReorderPendingTime = 30;
119 /********************************************************************************************************************
120 *function: This function print out each field on HT capability IE mainly from (Beacon/ProbeRsp/AssocReq)
121 * input: u8* CapIE //Capability IE to be printed out
122 * u8* TitleString //mainly print out caller function
125 * notice: Driver should not print out this message by default.
126 * *****************************************************************************************************************/
127 void HTDebugHTCapability(u8* CapIE, u8* TitleString )
130 static u8 EWC11NHTCap[] = {0x00, 0x90, 0x4c, 0x33}; // For 11n EWC definition, 2007.07.17, by Emily
131 PHT_CAPABILITY_ELE pCapELE;
133 if(!memcmp(CapIE, EWC11NHTCap, sizeof(EWC11NHTCap)))
136 IEEE80211_DEBUG(IEEE80211_DL_HT, "EWC IE in %s()\n", __FUNCTION__);
137 pCapELE = (PHT_CAPABILITY_ELE)(&CapIE[4]);
139 pCapELE = (PHT_CAPABILITY_ELE)(&CapIE[0]);
141 IEEE80211_DEBUG(IEEE80211_DL_HT, "<Log HT Capability>. Called by %s\n", TitleString );
143 IEEE80211_DEBUG(IEEE80211_DL_HT, "\tSupported Channel Width = %s\n", (pCapELE->ChlWidth)?"20MHz": "20/40MHz");
144 IEEE80211_DEBUG(IEEE80211_DL_HT, "\tSupport Short GI for 20M = %s\n", (pCapELE->ShortGI20Mhz)?"YES": "NO");
145 IEEE80211_DEBUG(IEEE80211_DL_HT, "\tSupport Short GI for 40M = %s\n", (pCapELE->ShortGI40Mhz)?"YES": "NO");
146 IEEE80211_DEBUG(IEEE80211_DL_HT, "\tSupport TX STBC = %s\n", (pCapELE->TxSTBC)?"YES": "NO");
147 IEEE80211_DEBUG(IEEE80211_DL_HT, "\tMax AMSDU Size = %s\n", (pCapELE->MaxAMSDUSize)?"3839": "7935");
148 IEEE80211_DEBUG(IEEE80211_DL_HT, "\tSupport CCK in 20/40 mode = %s\n", (pCapELE->DssCCk)?"YES": "NO");
149 IEEE80211_DEBUG(IEEE80211_DL_HT, "\tMax AMPDU Factor = %d\n", pCapELE->MaxRxAMPDUFactor);
150 IEEE80211_DEBUG(IEEE80211_DL_HT, "\tMPDU Density = %d\n", pCapELE->MPDUDensity);
151 IEEE80211_DEBUG(IEEE80211_DL_HT, "\tMCS Rate Set = [%x][%x][%x][%x][%x]\n", pCapELE->MCS[0],\
152 pCapELE->MCS[1], pCapELE->MCS[2], pCapELE->MCS[3], pCapELE->MCS[4]);
156 /********************************************************************************************************************
157 *function: This function print out each field on HT Information IE mainly from (Beacon/ProbeRsp)
158 * input: u8* InfoIE //Capability IE to be printed out
159 * u8* TitleString //mainly print out caller function
162 * notice: Driver should not print out this message by default.
163 * *****************************************************************************************************************/
164 void HTDebugHTInfo(u8* InfoIE, u8* TitleString)
167 static u8 EWC11NHTInfo[] = {0x00, 0x90, 0x4c, 0x34}; // For 11n EWC definition, 2007.07.17, by Emily
168 PHT_INFORMATION_ELE pHTInfoEle;
170 if(!memcmp(InfoIE, EWC11NHTInfo, sizeof(EWC11NHTInfo)))
173 IEEE80211_DEBUG(IEEE80211_DL_HT, "EWC IE in %s()\n", __FUNCTION__);
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, "\tSenondary channel =");
183 switch(pHTInfoEle->ExtChlOffset)
186 IEEE80211_DEBUG(IEEE80211_DL_HT, "Not Present\n");
189 IEEE80211_DEBUG(IEEE80211_DL_HT, "Upper channel\n");
192 IEEE80211_DEBUG(IEEE80211_DL_HT, "Reserved. Eooro!!!\n");
195 IEEE80211_DEBUG(IEEE80211_DL_HT, "Lower Channel\n");
198 IEEE80211_DEBUG(IEEE80211_DL_HT, "\tRecommended channel width = %s\n", (pHTInfoEle->RecommemdedTxWidth)?"20Mhz": "40Mhz");
200 IEEE80211_DEBUG(IEEE80211_DL_HT, "\tOperation mode for protection = ");
201 switch(pHTInfoEle->OptMode)
204 IEEE80211_DEBUG(IEEE80211_DL_HT, "No Protection\n");
207 IEEE80211_DEBUG(IEEE80211_DL_HT, "HT non-member protection mode\n");
210 IEEE80211_DEBUG(IEEE80211_DL_HT, "Suggest to open protection\n");
213 IEEE80211_DEBUG(IEEE80211_DL_HT, "HT mixed mode\n");
217 IEEE80211_DEBUG(IEEE80211_DL_HT, "\tBasic MCS Rate Set = [%x][%x][%x][%x][%x]\n", pHTInfoEle->BasicMSC[0],\
218 pHTInfoEle->BasicMSC[1], pHTInfoEle->BasicMSC[2], pHTInfoEle->BasicMSC[3], pHTInfoEle->BasicMSC[4]);
223 * Return: true if station in half n mode and AP supports 40 bw
225 bool IsHTHalfNmode40Bandwidth(struct ieee80211_device* ieee)
227 bool retValue = false;
228 PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
230 if(pHTInfo->bCurrentHTSupport == false ) // wireless is n mode
232 else if(pHTInfo->bRegBW40MHz == false) // station supports 40 bw
234 else if(!ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev)) // station in half n mode
236 else if(((PHT_CAPABILITY_ELE)(pHTInfo->PeerHTCapBuf))->ChlWidth) // ap support 40 bw
244 bool IsHTHalfNmodeSGI(struct ieee80211_device* ieee, bool is40MHz)
246 bool retValue = false;
247 PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
249 if(pHTInfo->bCurrentHTSupport == false ) // wireless is n mode
251 else if(!ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev)) // station in half n mode
253 else if(is40MHz) // ap support 40 bw
255 if(((PHT_CAPABILITY_ELE)(pHTInfo->PeerHTCapBuf))->ShortGI40Mhz) // ap support 40 bw short GI
262 if(((PHT_CAPABILITY_ELE)(pHTInfo->PeerHTCapBuf))->ShortGI20Mhz) // ap support 40 bw short GI
271 u16 HTHalfMcsToDataRate(struct ieee80211_device* ieee, u8 nMcsRate)
277 is40MHz = (IsHTHalfNmode40Bandwidth(ieee))?1:0;
278 isShortGI = (IsHTHalfNmodeSGI(ieee, is40MHz))? 1:0;
280 return MCS_DATA_RATE[is40MHz][isShortGI][(nMcsRate&0x7f)];
284 u16 HTMcsToDataRate( struct ieee80211_device* ieee, u8 nMcsRate)
286 PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
288 u8 is40MHz = (pHTInfo->bCurBW40MHz)?1:0;
289 u8 isShortGI = (pHTInfo->bCurBW40MHz)?
290 ((pHTInfo->bCurShortGI40MHz)?1:0):
291 ((pHTInfo->bCurShortGI20MHz)?1:0);
292 return MCS_DATA_RATE[is40MHz][isShortGI][(nMcsRate&0x7f)];
295 /********************************************************************************************************************
296 *function: This function returns current datarate.
297 * input: struct ieee80211_device* ieee
301 * notice: quite unsure about how to use this function //wb
302 * *****************************************************************************************************************/
303 u16 TxCountToDataRate( struct ieee80211_device* ieee, u8 nDataRate)
305 u16 CCKOFDMRate[12] = {0x02 , 0x04 , 0x0b , 0x16 , 0x0c , 0x12 , 0x18 , 0x24 , 0x30 , 0x48 , 0x60 , 0x6c};
311 return CCKOFDMRate[nDataRate];
315 if (nDataRate >= 0x10 && nDataRate <= 0x1f)//if(nDataRate > 11 && nDataRate < 28 )
321 else if(nDataRate >=0x20 && nDataRate <= 0x2f ) //(27, 44)
327 else if(nDataRate >= 0x30 && nDataRate <= 0x3f ) //(43, 60)
333 else if(nDataRate >= 0x40 && nDataRate <= 0x4f ) //(59, 76)
339 return MCS_DATA_RATE[is40MHz][isShortGI][nDataRate&0xf];
345 bool IsHTHalfNmodeAPs(struct ieee80211_device* ieee)
347 bool retValue = false;
348 struct ieee80211_network* net = &ieee->current_network;
350 if((memcmp(net->bssid, BELKINF5D8233V1_RALINK, 3)==0) ||
351 (memcmp(net->bssid, BELKINF5D82334V3_RALINK, 3)==0) ||
352 (memcmp(net->bssid, PCI_RALINK, 3)==0) ||
353 (memcmp(net->bssid, EDIMAX_RALINK, 3)==0) ||
354 (memcmp(net->bssid, AIRLINK_RALINK, 3)==0) ||
355 (net->ralink_cap_exist))
357 else if((memcmp(net->bssid, UNKNOWN_BORADCOM, 3)==0) ||
358 (memcmp(net->bssid, LINKSYSWRT330_LINKSYSWRT300_BROADCOM, 3)==0)||
359 (memcmp(net->bssid, LINKSYSWRT350_LINKSYSWRT150_BROADCOM, 3)==0)||
360 (net->broadcom_cap_exist))
362 else if(net->bssht.bdRT2RTAggregation)
370 /********************************************************************************************************************
371 *function: This function returns peer IOT.
372 * input: struct ieee80211_device* ieee
376 * *****************************************************************************************************************/
377 void HTIOTPeerDetermine(struct ieee80211_device* ieee)
379 PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
380 struct ieee80211_network* net = &ieee->current_network;
381 //FIXME: need to decide 92U_SOFTAP //LZM,090320
382 if(net->bssht.bdRT2RTAggregation){
383 pHTInfo->IOTPeer = HT_IOT_PEER_REALTEK;
384 if(net->bssht.RT2RT_HT_Mode & RT_HT_CAP_USE_92SE){
385 pHTInfo->IOTPeer = HT_IOT_PEER_REALTEK_92SE;
387 if(net->bssht.RT2RT_HT_Mode & RT_HT_CAP_USE_SOFTAP){
388 pHTInfo->IOTPeer = HT_IOT_PEER_92U_SOFTAP;
391 else if(net->broadcom_cap_exist)
392 pHTInfo->IOTPeer = HT_IOT_PEER_BROADCOM;
393 else if((memcmp(net->bssid, UNKNOWN_BORADCOM, 3)==0) ||
394 (memcmp(net->bssid, LINKSYSWRT330_LINKSYSWRT300_BROADCOM, 3)==0)||
395 (memcmp(net->bssid, LINKSYSWRT350_LINKSYSWRT150_BROADCOM, 3)==0))
396 pHTInfo->IOTPeer = HT_IOT_PEER_BROADCOM;
397 else if((memcmp(net->bssid, BELKINF5D8233V1_RALINK, 3)==0) ||
398 (memcmp(net->bssid, BELKINF5D82334V3_RALINK, 3)==0) ||
399 (memcmp(net->bssid, PCI_RALINK, 3)==0) ||
400 (memcmp(net->bssid, EDIMAX_RALINK, 3)==0) ||
401 (memcmp(net->bssid, AIRLINK_RALINK, 3)==0) ||
402 net->ralink_cap_exist)
403 pHTInfo->IOTPeer = HT_IOT_PEER_RALINK;
404 else if((net->atheros_cap_exist )||
405 (memcmp(net->bssid, DLINK_ATHEROS_1, 3) == 0)||
406 (memcmp(net->bssid, DLINK_ATHEROS_2, 3) == 0))
407 pHTInfo->IOTPeer = HT_IOT_PEER_ATHEROS;
408 else if ((memcmp(net->bssid, CISCO_BROADCOM, 3)==0)||net->cisco_cap_exist)
409 pHTInfo->IOTPeer = HT_IOT_PEER_CISCO;
410 else if ((memcmp(net->bssid, LINKSYS_MARVELL_4400N, 3) == 0) ||
411 net->marvell_cap_exist)
412 pHTInfo->IOTPeer = HT_IOT_PEER_MARVELL;
414 pHTInfo->IOTPeer = HT_IOT_PEER_UNKNOWN;
416 IEEE80211_DEBUG(IEEE80211_DL_IOT, "Joseph debug!! IOTPEER: %x\n", pHTInfo->IOTPeer);
418 /********************************************************************************************************************
419 *function: Check whether driver should declare received rate up to MCS13 only since some chipset is not good
420 * at receiving MCS14~15 frame from some AP.
421 * input: struct ieee80211_device* ieee
424 * return: return 1 if driver should declare MCS13 only(otherwise return 0)
425 * *****************************************************************************************************************/
426 u8 HTIOTActIsDisableMCS14(struct ieee80211_device* ieee, u8* PeerMacAddr)
435 * Function: HTIOTActIsDisableMCS15
437 * Overview: Check whether driver should declare capability of receving MCS15
443 * Return: true if driver should disable MCS15
446 bool HTIOTActIsDisableMCS15(struct ieee80211_device* ieee)
448 bool retValue = false;
453 * Function: HTIOTActIsDisableMCSTwoSpatialStream
455 * Overview: Check whether driver should declare capability of receving All 2 ss packets
461 * Return: true if driver should disable all two spatial stream packet
464 bool HTIOTActIsDisableMCSTwoSpatialStream(struct ieee80211_device* ieee)
466 bool retValue = false;
468 // Apply for 819u only
469 //#if (HAL_CODE_BASE==RTL8192)
471 //This rule only apply to Belkin(Ralink) AP
472 if(IS_UNDER_11N_AES_MODE(Adapter))
474 if((PlatformCompareMemory(PeerMacAddr, BELKINF5D8233V1_RALINK, 3)==0) ||
475 (PlatformCompareMemory(PeerMacAddr, PCI_RALINK, 3)==0) ||
476 (PlatformCompareMemory(PeerMacAddr, EDIMAX_RALINK, 3)==0))
478 //Set True to disable this function. Disable by default, Emily, 2008.04.23
486 PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
487 if(ieee->is_ap_in_wep_tkip && ieee->is_ap_in_wep_tkip(ieee->dev))
489 if( (pHTInfo->IOTPeer != HT_IOT_PEER_ATHEROS) &&
490 (pHTInfo->IOTPeer != HT_IOT_PEER_UNKNOWN) &&
491 (pHTInfo->IOTPeer != HT_IOT_PEER_MARVELL) )
498 /********************************************************************************************************************
499 *function: Check whether driver should disable EDCA turbo mode
500 * input: struct ieee80211_device* ieee
503 * return: return 1 if driver should disable EDCA turbo mode(otherwise return 0)
504 * *****************************************************************************************************************/
505 u8 HTIOTActIsDisableEDCATurbo(struct ieee80211_device* ieee, u8* PeerMacAddr)
507 u8 retValue = false; // default enable EDCA Turbo mode.
508 // Set specific EDCA parameter for different AP in DM handler.
513 /********************************************************************************************************************
514 *function: Check whether we need to use OFDM to sned MGNT frame for broadcom AP
515 * input: struct ieee80211_network *network //current network we live
517 * return: return 1 if true
518 * *****************************************************************************************************************/
519 u8 HTIOTActIsMgntUseCCK6M(struct ieee80211_network *network)
523 // 2008/01/25 MH Judeg if we need to use OFDM to sned MGNT frame for broadcom AP.
524 // 2008/01/28 MH We must prevent that we select null bssid to link.
526 if(network->broadcom_cap_exist)
534 u8 HTIOTActIsForcedCTS2Self(struct ieee80211_network *network)
538 if(network->marvell_cap_exist)
546 u8 HTIOTActIsForcedRTSCTS(struct ieee80211_device *ieee, struct ieee80211_network *network)
549 printk("============>%s(), %d\n", __FUNCTION__, network->realtek_cap_exit);
551 if(ieee->pHTInfo->bCurrentHTSupport)
553 //if(!network->realtek_cap_exit)
554 if((ieee->pHTInfo->IOTPeer != HT_IOT_PEER_REALTEK)&&
555 (ieee->pHTInfo->IOTPeer != HT_IOT_PEER_REALTEK_92SE))
557 if((ieee->pHTInfo->IOTAction & HT_IOT_ACT_TX_NO_AGGREGATION) == 0)
565 HTIOTActIsForcedAMSDU8K(struct ieee80211_device *ieee, struct ieee80211_network *network)
572 u8 HTIOTActIsCCDFsync(u8* PeerMacAddr)
575 if( (memcmp(PeerMacAddr, UNKNOWN_BORADCOM, 3)==0) ||
576 (memcmp(PeerMacAddr, LINKSYSWRT330_LINKSYSWRT300_BROADCOM, 3)==0) ||
577 (memcmp(PeerMacAddr, LINKSYSWRT350_LINKSYSWRT150_BROADCOM, 3) ==0))
585 * 819xS single chip b-cut series cannot handle BAR
588 HTIOCActRejcectADDBARequest(struct ieee80211_network *network)
591 //if(IS_HARDWARE_TYPE_8192SE(Adapter) ||
592 // IS_HARDWARE_TYPE_8192SU(Adapter)
595 // Do not reject ADDBA REQ because some of the AP may
596 // keep on sending ADDBA REQ qhich cause DHCP fail or ping loss!
597 // by HPFan, 2008/12/30
599 //if(pBssDesc->Vender == HT_IOT_PEER_MARVELL)
609 * EDCA parameters bias on downlink
612 HTIOTActIsEDCABiasRx(struct ieee80211_device* ieee,struct ieee80211_network *network)
615 PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
617 if(pHTInfo->IOTPeer==HT_IOT_PEER_ATHEROS ||
618 pHTInfo->IOTPeer==HT_IOT_PEER_BROADCOM ||
619 pHTInfo->IOTPeer==HT_IOT_PEER_RALINK)
627 HTIOTActDisableShortGI(struct ieee80211_device* ieee,struct ieee80211_network *network)
630 PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
632 if(pHTInfo->IOTPeer==HT_IOT_PEER_RALINK)
641 HTIOTActDisableHighPower(struct ieee80211_device* ieee,struct ieee80211_network *network)
644 PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
646 if(pHTInfo->IOTPeer==HT_IOT_PEER_RALINK ||
647 pHTInfo->IOTPeer==HT_IOT_PEER_REALTEK ||
648 pHTInfo->IOTPeer==HT_IOT_PEER_REALTEK_92SE)
657 HTIOTActDetermineRaFunc(struct ieee80211_device* ieee, bool bPeerRx2ss)
659 PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
660 pHTInfo->IOTRaFunc &= HT_IOT_RAFUNC_DISABLE_ALL;
662 if(pHTInfo->IOTPeer == HT_IOT_PEER_RALINK && !bPeerRx2ss)
663 pHTInfo->IOTRaFunc |= HT_IOT_RAFUNC_PEER_1R;
665 if(pHTInfo->IOTAction & HT_IOT_ACT_AMSDU_ENABLE)
666 pHTInfo->IOTRaFunc |= HT_IOT_RAFUNC_TX_AMSDU;
668 printk("!!!!!!!!!!!!!!!!!!!!!!!!!!!IOTRaFunc = %8.8x\n", pHTInfo->IOTRaFunc);
673 HTIOTActIsDisableTx40MHz(struct ieee80211_device* ieee,struct ieee80211_network *network)
677 PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
678 if( (KEY_TYPE_WEP104 == ieee->pairwise_key_type) ||
679 (KEY_TYPE_WEP40 == ieee->pairwise_key_type) ||
680 (KEY_TYPE_WEP104 == ieee->group_key_type) ||
681 (KEY_TYPE_WEP40 == ieee->group_key_type) ||
682 (KEY_TYPE_TKIP == ieee->pairwise_key_type) )
684 if((pHTInfo->IOTPeer==HT_IOT_PEER_REALTEK) && (network->bssht.bdSupportHT))
692 HTIOTActIsTxNoAggregation(struct ieee80211_device* ieee,struct ieee80211_network *network)
696 PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
697 if( (KEY_TYPE_WEP104 == ieee->pairwise_key_type) ||
698 (KEY_TYPE_WEP40 == ieee->pairwise_key_type) ||
699 (KEY_TYPE_WEP104 == ieee->group_key_type) ||
700 (KEY_TYPE_WEP40 == ieee->group_key_type) ||
701 (KEY_TYPE_TKIP == ieee->pairwise_key_type) )
703 if(pHTInfo->IOTPeer==HT_IOT_PEER_REALTEK)
712 HTIOTActIsDisableTx2SS(struct ieee80211_device* ieee,struct ieee80211_network *network)
716 PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
717 if( (KEY_TYPE_WEP104 == ieee->pairwise_key_type) ||
718 (KEY_TYPE_WEP40 == ieee->pairwise_key_type) ||
719 (KEY_TYPE_WEP104 == ieee->group_key_type) ||
720 (KEY_TYPE_WEP40 == ieee->group_key_type) ||
721 (KEY_TYPE_TKIP == ieee->pairwise_key_type) )
723 if((pHTInfo->IOTPeer==HT_IOT_PEER_REALTEK) && (network->bssht.bdSupportHT))
731 bool HTIOCActAllowPeerAggOnePacket(struct ieee80211_device* ieee,struct ieee80211_network *network)
733 bool retValue = false;
734 PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
735 if(pHTInfo->IOTPeer == HT_IOT_PEER_BROADCOM)
737 if((memcmp(network->bssid, NETGEAR_BROADCOM, 3)==0)
738 && (network->bssht.bdBandWidth == HT_CHANNEL_WIDTH_20_40))
744 void HTResetIOTSetting(
745 PRT_HIGH_THROUGHPUT pHTInfo
748 pHTInfo->IOTAction = 0;
749 pHTInfo->IOTPeer = HT_IOT_PEER_UNKNOWN;
750 pHTInfo->IOTRaFunc = 0;
754 /********************************************************************************************************************
755 *function: Construct Capablility Element in Beacon... if HTEnable is turned on
756 * input: struct ieee80211_device* ieee
757 * u8* posHTCap //pointer to store Capability Ele
758 * u8* len //store length of CE
759 * u8 IsEncrypt //whether encrypt, needed further
762 * notice: posHTCap can't be null and should be initialized before.
763 * *****************************************************************************************************************/
764 void HTConstructCapabilityElement(struct ieee80211_device* ieee, u8* posHTCap, u8* len, u8 IsEncrypt)
766 PRT_HIGH_THROUGHPUT pHT = ieee->pHTInfo;
767 PHT_CAPABILITY_ELE pCapELE = NULL;
769 if ((posHTCap == NULL) || (pHT == NULL))
771 IEEE80211_DEBUG(IEEE80211_DL_ERR, "posHTCap or pHTInfo can't be null in HTConstructCapabilityElement()\n");
774 memset(posHTCap, 0, *len);
775 if(pHT->ePeerHTSpecVer == HT_SPEC_VER_EWC)
777 u8 EWC11NHTCap[] = {0x00, 0x90, 0x4c, 0x33}; // For 11n EWC definition, 2007.07.17, by Emily
778 memcpy(posHTCap, EWC11NHTCap, sizeof(EWC11NHTCap));
779 pCapELE = (PHT_CAPABILITY_ELE)&(posHTCap[4]);
782 pCapELE = (PHT_CAPABILITY_ELE)posHTCap;
787 pCapELE->AdvCoding = 0; // This feature is not supported now!!
788 if(ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev))
790 pCapELE->ChlWidth = 0;
794 pCapELE->ChlWidth = (pHT->bRegBW40MHz?1:0);
797 pCapELE->MimoPwrSave = pHT->SelfMimoPs;
798 pCapELE->GreenField = 0; // This feature is not supported now!!
799 pCapELE->ShortGI20Mhz = 1; // We can receive Short GI!!
800 pCapELE->ShortGI40Mhz = 1; // We can receive Short GI!!
804 pCapELE->DelayBA = 0; // Do not support now!!
805 pCapELE->MaxAMSDUSize = (MAX_RECEIVE_BUFFER_SIZE>=7935)?1:0;
806 pCapELE->DssCCk = ((pHT->bRegBW40MHz)?(pHT->bRegSuppCCK?1:0):0);
807 pCapELE->PSMP = 0; // Do not support now!!
808 pCapELE->LSigTxopProtect = 0; // Do not support now!!
811 //MAC HT parameters info
812 // TODO: Nedd to take care of this part
813 IEEE80211_DEBUG(IEEE80211_DL_HT, "TX HT cap/info ele BW=%d MaxAMSDUSize:%d DssCCk:%d\n", pCapELE->ChlWidth, pCapELE->MaxAMSDUSize, pCapELE->DssCCk);
817 pCapELE->MPDUDensity = 7; // 8us
818 pCapELE->MaxRxAMPDUFactor = 2; // 2 is for 32 K and 3 is 64K
822 pCapELE->MaxRxAMPDUFactor = 3; // 2 is for 32 K and 3 is 64K
823 pCapELE->MPDUDensity = 0; // no density
827 memcpy(pCapELE->MCS, ieee->Regdot11HTOperationalRateSet, 16);
828 if(pHT->IOTAction & HT_IOT_ACT_DISABLE_MCS15)
829 pCapELE->MCS[1] &= 0x7f;
831 if(pHT->IOTAction & HT_IOT_ACT_DISABLE_MCS14)
832 pCapELE->MCS[1] &= 0xbf;
834 if(pHT->IOTAction & HT_IOT_ACT_DISABLE_ALL_2SS)
835 pCapELE->MCS[1] &= 0x00;
838 // For RTL819X, if pairwisekey = wep/tkip, ap is ralink, we support only MCS0~7.
839 if(ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev))
842 for(i = 1; i< 16; i++)
846 //Extended HT Capability Info
847 memset(&pCapELE->ExtHTCapInfo, 0, 2);
851 memset(pCapELE->TxBFCap, 0, 4);
853 //Antenna Selection Capabilities
855 //add 2 to give space for element ID and len when construct frames
856 if(pHT->ePeerHTSpecVer == HT_SPEC_VER_EWC)
864 /********************************************************************************************************************
865 *function: Construct Information Element in Beacon... if HTEnable is turned on
866 * input: struct ieee80211_device* ieee
867 * u8* posHTCap //pointer to store Information Ele
868 * u8* len //store len of
869 * u8 IsEncrypt //whether encrypt, needed further
872 * notice: posHTCap can't be null and be initialized before. only AP and IBSS sta should do this
873 * *****************************************************************************************************************/
874 void HTConstructInfoElement(struct ieee80211_device* ieee, u8* posHTInfo, u8* len, u8 IsEncrypt)
876 PRT_HIGH_THROUGHPUT pHT = ieee->pHTInfo;
877 PHT_INFORMATION_ELE pHTInfoEle = (PHT_INFORMATION_ELE)posHTInfo;
878 if ((posHTInfo == NULL) || (pHTInfoEle == NULL))
880 IEEE80211_DEBUG(IEEE80211_DL_ERR, "posHTInfo or pHTInfoEle can't be null in HTConstructInfoElement()\n");
884 memset(posHTInfo, 0, *len);
885 if ( (ieee->iw_mode == IW_MODE_ADHOC) || (ieee->iw_mode == IW_MODE_MASTER)) //ap mode is not currently supported
887 pHTInfoEle->ControlChl = ieee->current_network.channel;
888 pHTInfoEle->ExtChlOffset = ((pHT->bRegBW40MHz == false)?HT_EXTCHNL_OFFSET_NO_EXT:
889 (ieee->current_network.channel<=6)?
890 HT_EXTCHNL_OFFSET_UPPER:HT_EXTCHNL_OFFSET_LOWER);
891 pHTInfoEle->RecommemdedTxWidth = pHT->bRegBW40MHz;
892 pHTInfoEle->RIFS = 0;
893 pHTInfoEle->PSMPAccessOnly = 0;
894 pHTInfoEle->SrvIntGranularity = 0;
895 pHTInfoEle->OptMode = pHT->CurrentOpMode;
896 pHTInfoEle->NonGFDevPresent = 0;
897 pHTInfoEle->DualBeacon = 0;
898 pHTInfoEle->SecondaryBeacon = 0;
899 pHTInfoEle->LSigTxopProtectFull = 0;
900 pHTInfoEle->PcoActive = 0;
901 pHTInfoEle->PcoPhase = 0;
903 memset(pHTInfoEle->BasicMSC, 0, 16);
906 *len = 22 + 2; //same above
911 //STA should not generate High Throughput Information Element
918 * According to experiment, Realtek AP to STA (based on rtl8190) may achieve best performance
919 * if both STA and AP set limitation of aggregation size to 32K, that is, set AMPDU density to 2
920 * (Ref: IEEE 11n specification). However, if Realtek STA associates to other AP, STA should set
921 * limitation of aggregation size to 8K, otherwise, performance of traffic stream from STA to AP
922 * will be much less than the traffic stream from AP to STA if both of the stream runs concurrently
926 * Element ID Length OUI Type1 Reserved
927 * 1 byte 1 byte 3 bytes 1 byte 1 byte
929 * OUI = 0x00, 0xe0, 0x4c,
935 /********************************************************************************************************************
936 *function: Construct Information Element in Beacon... in RT2RT condition
937 * input: struct ieee80211_device* ieee
938 * u8* posRT2RTAgg //pointer to store Information Ele
939 * u8* len //store len
943 * *****************************************************************************************************************/
944 void HTConstructRT2RTAggElement(struct ieee80211_device* ieee, u8* posRT2RTAgg, u8* len)
946 if (posRT2RTAgg == NULL) {
947 IEEE80211_DEBUG(IEEE80211_DL_ERR, "posRT2RTAgg can't be null in HTConstructRT2RTAggElement()\n");
950 memset(posRT2RTAgg, 0, *len);
951 *posRT2RTAgg++ = 0x00;
952 *posRT2RTAgg++ = 0xe0;
953 *posRT2RTAgg++ = 0x4c;
954 *posRT2RTAgg++ = 0x02;
955 *posRT2RTAgg++ = 0x01;
956 *posRT2RTAgg = 0x10;//*posRT2RTAgg = 0x02;
958 if(ieee->bSupportRemoteWakeUp) {
959 *posRT2RTAgg |= 0x08;//RT_HT_CAP_USE_WOW;
965 #if(HAL_CODE_BASE == RTL8192 && DEV_BUS_TYPE == USB_INTERFACE)
967 //Emily. If it is required to Ask Realtek AP to send AMPDU during AES mode, enable this
969 if(IS_UNDER_11N_AES_MODE(Adapter))
971 posRT2RTAgg->Octet[5] |=RT_HT_CAP_USE_AMPDU;
974 posRT2RTAgg->Octet[5] &= 0xfb;
981 posRT2RTAgg->Length = 6;
990 /********************************************************************************************************************
991 *function: Pick the right Rate Adaptive table to use
992 * input: struct ieee80211_device* ieee
993 * u8* pOperateMCS //A pointer to MCS rate bitmap
994 * return: always we return true
996 * *****************************************************************************************************************/
997 u8 HT_PickMCSRate(struct ieee80211_device* ieee, u8* pOperateMCS)
1000 if (pOperateMCS == NULL)
1002 IEEE80211_DEBUG(IEEE80211_DL_ERR, "pOperateMCS can't be null in HT_PickMCSRate()\n");
1011 //legacy rate routine handled at selectedrate
1019 case IEEE_N_24G: //assume CCK rate ok
1021 // Legacy part we only use 6, 5.5,2,1 for N_24G and 6 for N_5G.
1022 // Legacy part shall be handled at SelectRateSet().
1025 // TODO: may be different if we have different number of antenna
1026 pOperateMCS[0] &=RATE_ADPT_1SS_MASK; //support MCS 0~7
1027 pOperateMCS[1] &=RATE_ADPT_2SS_MASK;
1028 pOperateMCS[3] &=RATE_ADPT_MCS32_MASK;
1031 //should never reach here
1043 * This function will get the highest speed rate in input MCS set.
1045 * /param Adapter Pionter to Adapter entity
1046 * pMCSRateSet Pointer to MCS rate bitmap
1047 * pMCSFilter Pointer to MCS rate filter
1049 * /return Highest MCS rate included in pMCSRateSet and filtered by pMCSFilter.
1052 /********************************************************************************************************************
1053 *function: This function will get the highest speed rate in input MCS set.
1054 * input: struct ieee80211_device* ieee
1055 * u8* pMCSRateSet //Pointer to MCS rate bitmap
1056 * u8* pMCSFilter //Pointer to MCS rate filter
1057 * return: Highest MCS rate included in pMCSRateSet and filtered by pMCSFilter
1059 * *****************************************************************************************************************/
1060 u8 HTGetHighestMCSRate(struct ieee80211_device* ieee, u8* pMCSRateSet, u8* pMCSFilter)
1065 u8 availableMcsRate[16];
1066 if (pMCSRateSet == NULL || pMCSFilter == NULL)
1068 IEEE80211_DEBUG(IEEE80211_DL_ERR, "pMCSRateSet or pMCSFilter can't be null in HTGetHighestMCSRate()\n");
1072 availableMcsRate[i] = pMCSRateSet[i] & pMCSFilter[i];
1074 for(i = 0; i < 16; i++)
1076 if(availableMcsRate[i] != 0)
1082 for(i = 0; i < 16; i++)
1084 if(availableMcsRate[i] != 0)
1086 bitMap = availableMcsRate[i];
1087 for(j = 0; j < 8; j++)
1091 if(HTMcsToDataRate(ieee, (8*i+j)) > HTMcsToDataRate(ieee, mcsRate))
1098 return (mcsRate|0x80);
1105 **1.Filter our operation rate set with AP's rate set
1106 **2.shall reference channel bandwidth, STBC, Antenna number
1107 **3.generate rate adative table for firmware
1110 ** \pHTSupportedCap: the connected STA's supported rate Capability element
1112 u8 HTFilterMCSRate( struct ieee80211_device* ieee, u8* pSupportMCS, u8* pOperateMCS)
1117 // filter out operational rate set not supported by AP, the lenth of it is 16
1119 pOperateMCS[i] = ieee->Regdot11HTOperationalRateSet[i]&pSupportMCS[i];
1123 // TODO: adjust our operational rate set according to our channel bandwidth, STBC and Antenna number
1125 // TODO: fill suggested rate adaptive rate index and give firmware info using Tx command packet
1126 // we also shall suggested the first start rate set according to our singal strength
1127 HT_PickMCSRate(ieee, pOperateMCS);
1129 // For RTL819X, if pairwisekey = wep/tkip, we support only MCS0~7.
1130 if(ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev))
1134 // For RTL819X, we support only MCS0~15.
1135 // And also, we do not know how to use MCS32 now.
1137 for(i=2; i<=15; i++)
1142 void HTSetConnectBwMode(struct ieee80211_device* ieee, HT_CHANNEL_WIDTH Bandwidth, HT_EXTCHNL_OFFSET Offset);
1144 void HTOnAssocRsp(struct ieee80211_device *ieee)
1146 PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
1147 PHT_CAPABILITY_ELE pPeerHTCap = NULL;
1148 PHT_INFORMATION_ELE pPeerHTInfo = NULL;
1149 u16 nMaxAMSDUSize = 0;
1150 u8* pMcsFilter = NULL;
1152 static u8 EWC11NHTCap[] = {0x00, 0x90, 0x4c, 0x33}; // For 11n EWC definition, 2007.07.17, by Emily
1153 static u8 EWC11NHTInfo[] = {0x00, 0x90, 0x4c, 0x34}; // For 11n EWC definition, 2007.07.17, by Emily
1155 if( pHTInfo->bCurrentHTSupport == false )
1157 IEEE80211_DEBUG(IEEE80211_DL_ERR, "<=== HTOnAssocRsp(): HT_DISABLE\n");
1160 IEEE80211_DEBUG(IEEE80211_DL_HT, "===> HTOnAssocRsp_wq(): HT_ENABLE\n");
1162 if(!memcmp(pHTInfo->PeerHTCapBuf,EWC11NHTCap, sizeof(EWC11NHTCap)))
1163 pPeerHTCap = (PHT_CAPABILITY_ELE)(&pHTInfo->PeerHTCapBuf[4]);
1165 pPeerHTCap = (PHT_CAPABILITY_ELE)(pHTInfo->PeerHTCapBuf);
1167 if(!memcmp(pHTInfo->PeerHTInfoBuf, EWC11NHTInfo, sizeof(EWC11NHTInfo)))
1168 pPeerHTInfo = (PHT_INFORMATION_ELE)(&pHTInfo->PeerHTInfoBuf[4]);
1170 pPeerHTInfo = (PHT_INFORMATION_ELE)(pHTInfo->PeerHTInfoBuf);
1173 ////////////////////////////////////////////////////////
1175 ////////////////////////////////////////////////////////
1176 IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA|IEEE80211_DL_HT, pPeerHTCap, sizeof(HT_CAPABILITY_ELE));
1178 HTSetConnectBwMode(ieee, (HT_CHANNEL_WIDTH)(pPeerHTCap->ChlWidth), (HT_EXTCHNL_OFFSET)(pPeerHTInfo->ExtChlOffset));
1180 if(pHTInfo->bCurBW40MHz == true)
1181 pHTInfo->bCurTxBW40MHz = ((pPeerHTInfo->RecommemdedTxWidth == 1)?true:false);
1184 // Update short GI/ long GI setting
1187 pHTInfo->bCurShortGI20MHz=
1188 ((pHTInfo->bRegShortGI20MHz)?((pPeerHTCap->ShortGI20Mhz==1)?true:false):false);
1189 pHTInfo->bCurShortGI40MHz=
1190 ((pHTInfo->bRegShortGI40MHz)?((pPeerHTCap->ShortGI40Mhz==1)?true:false):false);
1193 // Config TX STBC setting
1198 // Config DSSS/CCK mode in 40MHz mode
1201 pHTInfo->bCurSuppCCK =
1202 ((pHTInfo->bRegSuppCCK)?((pPeerHTCap->DssCCk==1)?true:false):false);
1206 // Config and configure A-MSDU setting
1208 pHTInfo->bCurrent_AMSDU_Support = pHTInfo->bAMSDU_Support;
1210 nMaxAMSDUSize = (pPeerHTCap->MaxAMSDUSize==0)?3839:7935;
1212 if(pHTInfo->nAMSDU_MaxSize > nMaxAMSDUSize )
1213 pHTInfo->nCurrent_AMSDU_MaxSize = nMaxAMSDUSize;
1215 pHTInfo->nCurrent_AMSDU_MaxSize = pHTInfo->nAMSDU_MaxSize;
1218 // Config A-MPDU setting
1220 pHTInfo->bCurrentAMPDUEnable = pHTInfo->bAMPDUEnable;
1221 if(ieee->is_ap_in_wep_tkip && ieee->is_ap_in_wep_tkip(ieee->dev))
1223 if( (pHTInfo->IOTPeer== HT_IOT_PEER_ATHEROS) ||
1224 (pHTInfo->IOTPeer == HT_IOT_PEER_UNKNOWN) )
1225 pHTInfo->bCurrentAMPDUEnable = false;
1228 // <1> Decide AMPDU Factor
1231 if(!pHTInfo->bRegRT2RTAggregation)
1233 // Decide AMPDU Factor according to protocol handshake
1234 if(pHTInfo->AMPDU_Factor > pPeerHTCap->MaxRxAMPDUFactor)
1235 pHTInfo->CurrentAMPDUFactor = pPeerHTCap->MaxRxAMPDUFactor;
1237 pHTInfo->CurrentAMPDUFactor = pHTInfo->AMPDU_Factor;
1241 // Set MPDU density to 2 to Realtek AP, and set it to 0 for others
1242 // Replace MPDU factor declared in original association response frame format. 2007.08.20 by Emily
1243 if (ieee->current_network.bssht.bdRT2RTAggregation)
1245 if( ieee->pairwise_key_type != KEY_TYPE_NA)
1246 // Realtek may set 32k in security mode and 64k for others
1247 pHTInfo->CurrentAMPDUFactor = pPeerHTCap->MaxRxAMPDUFactor;
1249 pHTInfo->CurrentAMPDUFactor = HT_AGG_SIZE_64K;
1252 if(pPeerHTCap->MaxRxAMPDUFactor < HT_AGG_SIZE_32K)
1253 pHTInfo->CurrentAMPDUFactor = pPeerHTCap->MaxRxAMPDUFactor;
1255 pHTInfo->CurrentAMPDUFactor = HT_AGG_SIZE_32K;
1259 // <2> Set AMPDU Minimum MPDU Start Spacing
1260 // 802.11n 3.0 section 9.7d.3
1262 if(pHTInfo->MPDU_Density > pPeerHTCap->MPDUDensity)
1263 pHTInfo->CurrentMPDUDensity = pHTInfo->MPDU_Density;
1265 pHTInfo->CurrentMPDUDensity = pPeerHTCap->MPDUDensity;
1266 if(ieee->pairwise_key_type != KEY_TYPE_NA )
1267 pHTInfo->CurrentMPDUDensity = 7; // 8us
1269 if(pHTInfo->MPDU_Density > pPeerHTCap->MPDUDensity)
1270 pHTInfo->CurrentMPDUDensity = pHTInfo->MPDU_Density;
1272 pHTInfo->CurrentMPDUDensity = pPeerHTCap->MPDUDensity;
1276 // Lanhsin: mark for tmp to avoid deauth by ap from s3
1277 //if(memcmp(pMgntInfo->Bssid, NETGEAR834Bv2_BROADCOM, 3)==0)
1278 if(pHTInfo->IOTAction & HT_IOT_ACT_TX_USE_AMSDU_8K)
1281 pHTInfo->bCurrentAMPDUEnable = false;
1282 pHTInfo->ForcedAMSDUMode = HT_AGG_FORCE_ENABLE;
1283 pHTInfo->ForcedAMSDUMaxSize = 7935;
1286 // Rx Reorder Setting
1287 pHTInfo->bCurRxReorderEnable = pHTInfo->bRegRxReorderEnable;
1290 // Filter out unsupported HT rate for this AP
1291 // Update RATR table
1292 // This is only for 8190 ,8192 or later product which using firmware to handle rate adaptive mechanism.
1295 // Handle Ralink AP bad MCS rate set condition. Joseph.
1296 // This fix the bug of Ralink AP. This may be removed in the future.
1297 if(pPeerHTCap->MCS[0] == 0)
1298 pPeerHTCap->MCS[0] = 0xff;
1300 // Joseph test //LZM ADD 090318
1301 HTIOTActDetermineRaFunc(ieee, ((pPeerHTCap->MCS[1])!=0));
1303 HTFilterMCSRate(ieee, pPeerHTCap->MCS, ieee->dot11HTOperationalRateSet);
1306 // Config MIMO Power Save setting
1308 pHTInfo->PeerMimoPs = pPeerHTCap->MimoPwrSave;
1309 if(pHTInfo->PeerMimoPs == MIMO_PS_STATIC)
1310 pMcsFilter = MCS_FILTER_1SS;
1312 pMcsFilter = MCS_FILTER_ALL;
1313 //WB add for MCS8 bug
1314 // pMcsFilter = MCS_FILTER_1SS;
1315 ieee->HTHighestOperaRate = HTGetHighestMCSRate(ieee, ieee->dot11HTOperationalRateSet, pMcsFilter);
1316 ieee->HTCurrentOperaRate = ieee->HTHighestOperaRate;
1319 // Config current operation mode.
1321 pHTInfo->CurrentOpMode = pPeerHTInfo->OptMode;
1327 void HTSetConnectBwModeCallback(struct ieee80211_device* ieee);
1328 /********************************************************************************************************************
1329 *function: initialize HT info(struct PRT_HIGH_THROUGHPUT)
1330 * input: struct ieee80211_device* ieee
1333 * notice: This function is called when * (1) MPInitialization Phase * (2) Receiving of Deauthentication from AP
1334 ********************************************************************************************************************/
1335 // TODO: Should this funciton be called when receiving of Disassociation?
1336 void HTInitializeHTInfo(struct ieee80211_device* ieee)
1338 PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
1341 // These parameters will be reset when receiving deauthentication packet
1343 IEEE80211_DEBUG(IEEE80211_DL_HT, "===========>%s()\n", __FUNCTION__);
1344 pHTInfo->bCurrentHTSupport = false;
1346 // 40MHz channel support
1347 pHTInfo->bCurBW40MHz = false;
1348 pHTInfo->bCurTxBW40MHz = false;
1351 pHTInfo->bCurShortGI20MHz = false;
1352 pHTInfo->bCurShortGI40MHz = false;
1353 pHTInfo->bForcedShortGI = false;
1356 // This flag is set to true to support CCK rate by default.
1357 // It will be affected by "pHTInfo->bRegSuppCCK" and AP capabilities only when associate to
1359 pHTInfo->bCurSuppCCK = true;
1362 pHTInfo->bCurrent_AMSDU_Support = false;
1363 pHTInfo->nCurrent_AMSDU_MaxSize = pHTInfo->nAMSDU_MaxSize;
1366 pHTInfo->CurrentMPDUDensity = pHTInfo->MPDU_Density;
1367 pHTInfo->CurrentAMPDUFactor = pHTInfo->AMPDU_Factor;
1371 // Initialize all of the parameters related to 11n
1372 memset((void*)(&(pHTInfo->SelfHTCap)), 0, sizeof(pHTInfo->SelfHTCap));
1373 memset((void*)(&(pHTInfo->SelfHTInfo)), 0, sizeof(pHTInfo->SelfHTInfo));
1374 memset((void*)(&(pHTInfo->PeerHTCapBuf)), 0, sizeof(pHTInfo->PeerHTCapBuf));
1375 memset((void*)(&(pHTInfo->PeerHTInfoBuf)), 0, sizeof(pHTInfo->PeerHTInfoBuf));
1377 pHTInfo->bSwBwInProgress = false;
1378 pHTInfo->ChnlOp = CHNLOP_NONE;
1380 // Set default IEEE spec for Draft N
1381 pHTInfo->ePeerHTSpecVer = HT_SPEC_VER_IEEE;
1383 // Realtek proprietary aggregation mode
1384 pHTInfo->bCurrentRT2RTAggregation = false;
1385 pHTInfo->bCurrentRT2RTLongSlotTime = false;
1386 pHTInfo->RT2RT_HT_Mode = (RT_HT_CAPBILITY)0;
1388 pHTInfo->IOTPeer = 0;
1389 pHTInfo->IOTAction = 0;
1390 pHTInfo->IOTRaFunc = 0;
1392 //MCS rate initialized here
1394 u8* RegHTSuppRateSets = &(ieee->RegHTSuppRateSet[0]);
1395 RegHTSuppRateSets[0] = 0xFF; //support MCS 0~7
1396 RegHTSuppRateSets[1] = 0xFF; //support MCS 8~15
1397 RegHTSuppRateSets[4] = 0x01; //support MCS 32
1400 /********************************************************************************************************************
1401 *function: initialize Bss HT structure(struct PBSS_HT)
1402 * input: PBSS_HT pBssHT //to be initialized
1405 * notice: This function is called when initialize network structure
1406 ********************************************************************************************************************/
1407 void HTInitializeBssDesc(PBSS_HT pBssHT)
1410 pBssHT->bdSupportHT = false;
1411 memset(pBssHT->bdHTCapBuf, 0, sizeof(pBssHT->bdHTCapBuf));
1412 pBssHT->bdHTCapLen = 0;
1413 memset(pBssHT->bdHTInfoBuf, 0, sizeof(pBssHT->bdHTInfoBuf));
1414 pBssHT->bdHTInfoLen = 0;
1416 pBssHT->bdHTSpecVer= HT_SPEC_VER_IEEE;
1418 pBssHT->bdRT2RTAggregation = false;
1419 pBssHT->bdRT2RTLongSlotTime = false;
1420 pBssHT->RT2RT_HT_Mode = (RT_HT_CAPBILITY)0;
1423 /********************************************************************************************************************
1424 *function: initialize Bss HT structure(struct PBSS_HT)
1425 * input: struct ieee80211_device *ieee
1426 * struct ieee80211_network *pNetwork //usually current network we are live in
1429 * notice: This function should ONLY be called before association
1430 ********************************************************************************************************************/
1431 void HTResetSelfAndSavePeerSetting(struct ieee80211_device* ieee, struct ieee80211_network * pNetwork)
1433 PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
1434 // u16 nMaxAMSDUSize;
1435 // PHT_CAPABILITY_ELE pPeerHTCap = (PHT_CAPABILITY_ELE)pNetwork->bssht.bdHTCapBuf;
1436 // PHT_INFORMATION_ELE pPeerHTInfo = (PHT_INFORMATION_ELE)pNetwork->bssht.bdHTInfoBuf;
1441 // Save Peer Setting before Association
1443 IEEE80211_DEBUG(IEEE80211_DL_HT, "==============>%s()\n", __FUNCTION__);
1444 /*unmark bEnableHT flag here is the same reason why unmarked in function ieee80211_softmac_new_net. WB 2008.09.10*/
1445 // if( pHTInfo->bEnableHT && pNetwork->bssht.bdSupportHT)
1446 if (pNetwork->bssht.bdSupportHT)
1448 pHTInfo->bCurrentHTSupport = true;
1449 pHTInfo->ePeerHTSpecVer = pNetwork->bssht.bdHTSpecVer;
1451 // Save HTCap and HTInfo information Element
1452 if(pNetwork->bssht.bdHTCapLen > 0 && pNetwork->bssht.bdHTCapLen <= sizeof(pHTInfo->PeerHTCapBuf))
1453 memcpy(pHTInfo->PeerHTCapBuf, pNetwork->bssht.bdHTCapBuf, pNetwork->bssht.bdHTCapLen);
1455 if(pNetwork->bssht.bdHTInfoLen > 0 && pNetwork->bssht.bdHTInfoLen <= sizeof(pHTInfo->PeerHTInfoBuf))
1456 memcpy(pHTInfo->PeerHTInfoBuf, pNetwork->bssht.bdHTInfoBuf, pNetwork->bssht.bdHTInfoLen);
1458 // Check whether RT to RT aggregation mode is enabled
1459 if(pHTInfo->bRegRT2RTAggregation)
1461 pHTInfo->bCurrentRT2RTAggregation = pNetwork->bssht.bdRT2RTAggregation;
1462 pHTInfo->bCurrentRT2RTLongSlotTime = pNetwork->bssht.bdRT2RTLongSlotTime;
1463 pHTInfo->RT2RT_HT_Mode = pNetwork->bssht.RT2RT_HT_Mode;
1467 pHTInfo->bCurrentRT2RTAggregation = false;
1468 pHTInfo->bCurrentRT2RTLongSlotTime = false;
1469 pHTInfo->RT2RT_HT_Mode = (RT_HT_CAPBILITY)0;
1472 // Determine the IOT Peer Vendor.
1473 HTIOTPeerDetermine(ieee);
1475 // Decide IOT Action
1476 // Must be called after the parameter of pHTInfo->bCurrentRT2RTAggregation is decided
1477 pHTInfo->IOTAction = 0;
1478 bIOTAction = HTIOTActIsDisableMCS14(ieee, pNetwork->bssid);
1480 pHTInfo->IOTAction |= HT_IOT_ACT_DISABLE_MCS14;
1482 bIOTAction = HTIOTActIsDisableMCS15(ieee);
1484 pHTInfo->IOTAction |= HT_IOT_ACT_DISABLE_MCS15;
1486 bIOTAction = HTIOTActIsDisableMCSTwoSpatialStream(ieee);
1488 pHTInfo->IOTAction |= HT_IOT_ACT_DISABLE_ALL_2SS;
1491 bIOTAction = HTIOTActIsDisableEDCATurbo(ieee, pNetwork->bssid);
1493 pHTInfo->IOTAction |= HT_IOT_ACT_DISABLE_EDCA_TURBO;
1495 bIOTAction = HTIOTActIsMgntUseCCK6M(pNetwork);
1497 pHTInfo->IOTAction |= HT_IOT_ACT_MGNT_USE_CCK_6M;
1499 bIOTAction = HTIOTActIsCCDFsync(pNetwork->bssid);
1501 pHTInfo->IOTAction |= HT_IOT_ACT_CDD_FSYNC;
1503 bIOTAction = HTIOTActIsForcedCTS2Self(pNetwork);
1505 pHTInfo->IOTAction |= HT_IOT_ACT_FORCED_CTS2SELF;
1507 //bIOTAction = HTIOTActIsForcedRTSCTS(ieee, pNetwork);
1509 // pHTInfo->IOTAction |= HT_IOT_ACT_FORCED_RTS;
1511 bIOTAction = HTIOCActRejcectADDBARequest(pNetwork);
1513 pHTInfo->IOTAction |= HT_IOT_ACT_REJECT_ADDBA_REQ;
1515 bIOTAction = HTIOCActAllowPeerAggOnePacket(ieee, pNetwork);
1517 pHTInfo->IOTAction |= HT_IOT_ACT_ALLOW_PEER_AGG_ONE_PKT;
1519 bIOTAction = HTIOTActIsEDCABiasRx(ieee, pNetwork);
1521 pHTInfo->IOTAction |= HT_IOT_ACT_EDCA_BIAS_ON_RX;
1523 bIOTAction = HTIOTActDisableShortGI(ieee, pNetwork);
1525 pHTInfo->IOTAction |= HT_IOT_ACT_DISABLE_SHORT_GI;
1527 bIOTAction = HTIOTActDisableHighPower(ieee, pNetwork);
1529 pHTInfo->IOTAction |= HT_IOT_ACT_DISABLE_HIGH_POWER;
1531 bIOTAction = HTIOTActIsForcedAMSDU8K(ieee, pNetwork);
1533 pHTInfo->IOTAction |= HT_IOT_ACT_TX_USE_AMSDU_8K;
1535 bIOTAction = HTIOTActIsTxNoAggregation(ieee, pNetwork);
1537 pHTInfo->IOTAction |= HT_IOT_ACT_TX_NO_AGGREGATION;
1539 bIOTAction = HTIOTActIsDisableTx40MHz(ieee, pNetwork);
1541 pHTInfo->IOTAction |= HT_IOT_ACT_DISABLE_TX_40_MHZ;
1543 bIOTAction = HTIOTActIsDisableTx2SS(ieee, pNetwork);
1545 pHTInfo->IOTAction |= HT_IOT_ACT_DISABLE_TX_2SS;
1546 //must after HT_IOT_ACT_TX_NO_AGGREGATION
1547 bIOTAction = HTIOTActIsForcedRTSCTS(ieee, pNetwork);
1549 pHTInfo->IOTAction |= HT_IOT_ACT_FORCED_RTS;
1551 printk("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!IOTAction = %8.8x\n", pHTInfo->IOTAction);
1555 pHTInfo->bCurrentHTSupport = false;
1556 pHTInfo->bCurrentRT2RTAggregation = false;
1557 pHTInfo->bCurrentRT2RTLongSlotTime = false;
1558 pHTInfo->RT2RT_HT_Mode = (RT_HT_CAPBILITY)0;
1560 pHTInfo->IOTAction = 0;
1561 pHTInfo->IOTRaFunc = 0;
1566 void HTUpdateSelfAndPeerSetting(struct ieee80211_device* ieee, struct ieee80211_network * pNetwork)
1568 PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
1569 // PHT_CAPABILITY_ELE pPeerHTCap = (PHT_CAPABILITY_ELE)pNetwork->bssht.bdHTCapBuf;
1570 PHT_INFORMATION_ELE pPeerHTInfo = (PHT_INFORMATION_ELE)pNetwork->bssht.bdHTInfoBuf;
1572 if(pHTInfo->bCurrentHTSupport)
1575 // Config current operation mode.
1577 if(pNetwork->bssht.bdHTInfoLen != 0)
1578 pHTInfo->CurrentOpMode = pPeerHTInfo->OptMode;
1581 // <TODO: Config according to OBSS non-HT STA present!!>
1586 void HTUseDefaultSetting(struct ieee80211_device* ieee)
1588 PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
1591 if(pHTInfo->bEnableHT)
1593 pHTInfo->bCurrentHTSupport = true;
1595 pHTInfo->bCurSuppCCK = pHTInfo->bRegSuppCCK;
1597 pHTInfo->bCurBW40MHz = pHTInfo->bRegBW40MHz;
1599 pHTInfo->bCurShortGI20MHz= pHTInfo->bRegShortGI20MHz;
1601 pHTInfo->bCurShortGI40MHz= pHTInfo->bRegShortGI40MHz;
1603 pHTInfo->bCurrent_AMSDU_Support = pHTInfo->bAMSDU_Support;
1605 pHTInfo->nCurrent_AMSDU_MaxSize = pHTInfo->nAMSDU_MaxSize;
1607 pHTInfo->bCurrentAMPDUEnable = pHTInfo->bAMPDUEnable;
1609 pHTInfo->CurrentAMPDUFactor = pHTInfo->AMPDU_Factor;
1611 pHTInfo->CurrentMPDUDensity = pHTInfo->CurrentMPDUDensity;
1613 // Set BWOpMode register
1615 //update RATR index0
1616 HTFilterMCSRate(ieee, ieee->Regdot11HTOperationalRateSet, ieee->dot11HTOperationalRateSet);
1617 //function below is not implemented at all. WB
1619 Adapter->HalFunc.InitHalRATRTableHandler( Adapter, &pMgntInfo->dot11OperationalRateSet, pMgntInfo->dot11HTOperationalRateSet);
1621 ieee->HTHighestOperaRate = HTGetHighestMCSRate(ieee, ieee->dot11HTOperationalRateSet, MCS_FILTER_ALL);
1622 ieee->HTCurrentOperaRate = ieee->HTHighestOperaRate;
1627 pHTInfo->bCurrentHTSupport = false;
1631 /********************************************************************************************************************
1632 *function: check whether HT control field exists
1633 * input: struct ieee80211_device *ieee
1634 * u8* pFrame //coming skb->data
1636 * return: return true if HT control field exists(false otherwise)
1638 ********************************************************************************************************************/
1639 u8 HTCCheck(struct ieee80211_device* ieee, u8* pFrame)
1641 if(ieee->pHTInfo->bCurrentHTSupport)
1643 if( (IsQoSDataFrame(pFrame) && Frame_Order(pFrame)) == 1)
1645 IEEE80211_DEBUG(IEEE80211_DL_HT, "HT CONTROL FILED EXIST!!\n");
1653 // This function set bandwidth mode in protocol layer.
1655 void HTSetConnectBwMode(struct ieee80211_device* ieee, HT_CHANNEL_WIDTH Bandwidth, HT_EXTCHNL_OFFSET Offset)
1657 PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
1660 if(pHTInfo->bRegBW40MHz == false)
1665 // To reduce dummy operation
1666 // if((pHTInfo->bCurBW40MHz==false && Bandwidth==HT_CHANNEL_WIDTH_20) ||
1667 // (pHTInfo->bCurBW40MHz==true && Bandwidth==HT_CHANNEL_WIDTH_20_40 && Offset==pHTInfo->CurSTAExtChnlOffset))
1670 // spin_lock_irqsave(&(ieee->bw_spinlock), flags);
1671 if(pHTInfo->bSwBwInProgress) {
1672 // spin_unlock_irqrestore(&(ieee->bw_spinlock), flags);
1675 //if in half N mode, set to 20M bandwidth please 09.08.2008 WB.
1676 if(Bandwidth==HT_CHANNEL_WIDTH_20_40 && (!ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev)))
1678 // Handle Illegal extention channel offset!!
1679 if(ieee->current_network.channel<2 && Offset==HT_EXTCHNL_OFFSET_LOWER)
1680 Offset = HT_EXTCHNL_OFFSET_NO_EXT;
1681 if(Offset==HT_EXTCHNL_OFFSET_UPPER || Offset==HT_EXTCHNL_OFFSET_LOWER) {
1682 pHTInfo->bCurBW40MHz = true;
1683 pHTInfo->CurSTAExtChnlOffset = Offset;
1685 pHTInfo->bCurBW40MHz = false;
1686 pHTInfo->CurSTAExtChnlOffset = HT_EXTCHNL_OFFSET_NO_EXT;
1689 pHTInfo->bCurBW40MHz = false;
1690 pHTInfo->CurSTAExtChnlOffset = HT_EXTCHNL_OFFSET_NO_EXT;
1693 pHTInfo->bSwBwInProgress = true;
1695 // TODO: 2007.7.13 by Emily Wait 2000ms in order to garantee that switching
1696 // bandwidth is executed after scan is finished. It is a temporal solution
1697 // because software should ganrantee the last operation of switching bandwidth
1698 // is executed properlly.
1699 HTSetConnectBwModeCallback(ieee);
1701 // spin_unlock_irqrestore(&(ieee->bw_spinlock), flags);
1704 void HTSetConnectBwModeCallback(struct ieee80211_device* ieee)
1706 PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
1708 IEEE80211_DEBUG(IEEE80211_DL_HT, "======>%s()\n", __FUNCTION__);
1709 if(pHTInfo->bCurBW40MHz)
1711 if(pHTInfo->CurSTAExtChnlOffset==HT_EXTCHNL_OFFSET_UPPER)
1712 ieee->set_chan(ieee->dev, ieee->current_network.channel+2);
1713 else if(pHTInfo->CurSTAExtChnlOffset==HT_EXTCHNL_OFFSET_LOWER)
1714 ieee->set_chan(ieee->dev, ieee->current_network.channel-2);
1716 ieee->set_chan(ieee->dev, ieee->current_network.channel);
1718 ieee->SetBWModeHandler(ieee->dev, HT_CHANNEL_WIDTH_20_40, pHTInfo->CurSTAExtChnlOffset);
1720 ieee->set_chan(ieee->dev, ieee->current_network.channel);
1721 ieee->SetBWModeHandler(ieee->dev, HT_CHANNEL_WIDTH_20, HT_EXTCHNL_OFFSET_NO_EXT);
1724 pHTInfo->bSwBwInProgress = false;