Staging: rtl8192su: remove USB_RX_AGGREGATION_SUPPORT ifdefs
[firewire-audio.git] / drivers / staging / rtl8192su / ieee80211 / rtl819x_HTProc.c
blobeca9ac27c2c69df6993ab37621ecae27c662d43b
2 //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
3 #include "ieee80211.h"
4 #include "rtl819x_HT.h"
5 u8 MCS_FILTER_ALL[16] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
7 u8 MCS_FILTER_1SS[16] = {0xff, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
9 u16 MCS_DATA_RATE[2][2][77] =
10 { { {13, 26, 39, 52, 78, 104, 117, 130, 26, 52, 78 ,104, 156, 208, 234, 260,
11 39, 78, 117, 234, 312, 351, 390, 52, 104, 156, 208, 312, 416, 468, 520,
12 0, 78, 104, 130, 117, 156, 195, 104, 130, 130, 156, 182, 182, 208, 156, 195,
13 195, 234, 273, 273, 312, 130, 156, 181, 156, 181, 208, 234, 208, 234, 260, 260,
14 286, 195, 234, 273, 234, 273, 312, 351, 312, 351, 390, 390, 429}, // Long GI, 20MHz
15 {14, 29, 43, 58, 87, 116, 130, 144, 29, 58, 87, 116, 173, 231, 260, 289,
16 43, 87, 130, 173, 260, 347, 390, 433, 58, 116, 173, 231, 347, 462, 520, 578,
17 0, 87, 116, 144, 130, 173, 217, 116, 144, 144, 173, 202, 202, 231, 173, 217,
18 217, 260, 303, 303, 347, 144, 173, 202, 173, 202, 231, 260, 231, 260, 289, 289,
19 318, 217, 260, 303, 260, 303, 347, 390, 347, 390, 433, 433, 477} }, // Short GI, 20MHz
20 { {27, 54, 81, 108, 162, 216, 243, 270, 54, 108, 162, 216, 324, 432, 486, 540,
21 81, 162, 243, 324, 486, 648, 729, 810, 108, 216, 324, 432, 648, 864, 972, 1080,
22 12, 162, 216, 270, 243, 324, 405, 216, 270, 270, 324, 378, 378, 432, 324, 405,
23 405, 486, 567, 567, 648, 270, 324, 378, 324, 378, 432, 486, 432, 486, 540, 540,
24 594, 405, 486, 567, 486, 567, 648, 729, 648, 729, 810, 810, 891}, // Long GI, 40MHz
25 {30, 60, 90, 120, 180, 240, 270, 300, 60, 120, 180, 240, 360, 480, 540, 600,
26 90, 180, 270, 360, 540, 720, 810, 900, 120, 240, 360, 480, 720, 960, 1080, 1200,
27 13, 180, 240, 300, 270, 360, 450, 240, 300, 300, 360, 420, 420, 480, 360, 450,
28 450, 540, 630, 630, 720, 300, 360, 420, 360, 420, 480, 540, 480, 540, 600, 600,
29 660, 450, 540, 630, 540, 630, 720, 810, 720, 810, 900, 900, 990} } // Short GI, 40MHz
32 static u8 UNKNOWN_BORADCOM[3] = {0x00, 0x14, 0xbf};
33 static u8 LINKSYSWRT330_LINKSYSWRT300_BROADCOM[3] = {0x00, 0x1a, 0x70};
34 static u8 LINKSYSWRT350_LINKSYSWRT150_BROADCOM[3] = {0x00, 0x1d, 0x7e};
35 static u8 NETGEAR834Bv2_BROADCOM[3] = {0x00, 0x1b, 0x2f};
36 static u8 BELKINF5D8233V1_RALINK[3] = {0x00, 0x17, 0x3f}; //cosa 03202008
37 static u8 BELKINF5D82334V3_RALINK[3] = {0x00, 0x1c, 0xdf};
38 static u8 PCI_RALINK[3] = {0x00, 0x90, 0xcc};
39 static u8 EDIMAX_RALINK[3] = {0x00, 0x0e, 0x2e};
40 static u8 AIRLINK_RALINK[3] = {0x00, 0x18, 0x02};
41 static u8 DLINK_ATHEROS_1[3] = {0x00, 0x1c, 0xf0};
42 static u8 DLINK_ATHEROS_2[3] = {0x00, 0x21, 0x91};
43 static u8 CISCO_BROADCOM[3] = {0x00, 0x17, 0x94};
44 static u8 LINKSYS_MARVELL_4400N[3] = {0x00, 0x14, 0xa4};
45 // 2008/04/01 MH For Cisco G mode RX TP We need to change FW duration. Shoud 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
51 * output: none
52 * return: none
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);
62 // ShortGI support
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;
72 else
73 pHTInfo->bRegSuppCCK = true;
75 // AMSDU related
76 pHTInfo->nAMSDU_MaxSize = 7935UL;
77 pHTInfo->bAMSDU_Support = 0;
79 // AMPDU related
80 pHTInfo->bAMPDUEnable = 1; //YJ,test,090311
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
84 // MIMO Power Save
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;
92 #ifdef TO_DO_LIST
93 // 8190 only. Assign duration operation mode to firmware
94 pMgntInfo->bTxEnableFwCalcDur = (BOOLEAN)pNdisCommon->bRegTxEnableFwCalcDur;
95 #endif
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;//YJ,test,090311
102 pHTInfo->RxReorderWinSize = 64;
103 pHTInfo->RxReorderPendingTime = 30;
105 #ifdef USB_TX_DRIVER_AGGREGATION_ENABLE
106 pHTInfo->UsbTxAggrNum = 4;
107 #endif
111 /********************************************************************************************************************
112 *function: This function print out each field on HT capability IE mainly from (Beacon/ProbeRsp/AssocReq)
113 * input: u8* CapIE //Capability IE to be printed out
114 * u8* TitleString //mainly print out caller function
115 * output: none
116 * return: none
117 * notice: Driver should not print out this message by default.
118 * *****************************************************************************************************************/
119 void HTDebugHTCapability(u8* CapIE, u8* TitleString )
122 static u8 EWC11NHTCap[] = {0x00, 0x90, 0x4c, 0x33}; // For 11n EWC definition, 2007.07.17, by Emily
123 PHT_CAPABILITY_ELE pCapELE;
125 if(!memcmp(CapIE, EWC11NHTCap, sizeof(EWC11NHTCap)))
127 //EWC IE
128 IEEE80211_DEBUG(IEEE80211_DL_HT, "EWC IE in %s()\n", __FUNCTION__);
129 pCapELE = (PHT_CAPABILITY_ELE)(&CapIE[4]);
130 }else
131 pCapELE = (PHT_CAPABILITY_ELE)(&CapIE[0]);
133 IEEE80211_DEBUG(IEEE80211_DL_HT, "<Log HT Capability>. Called by %s\n", TitleString );
135 IEEE80211_DEBUG(IEEE80211_DL_HT, "\tSupported Channel Width = %s\n", (pCapELE->ChlWidth)?"20MHz": "20/40MHz");
136 IEEE80211_DEBUG(IEEE80211_DL_HT, "\tSupport Short GI for 20M = %s\n", (pCapELE->ShortGI20Mhz)?"YES": "NO");
137 IEEE80211_DEBUG(IEEE80211_DL_HT, "\tSupport Short GI for 40M = %s\n", (pCapELE->ShortGI40Mhz)?"YES": "NO");
138 IEEE80211_DEBUG(IEEE80211_DL_HT, "\tSupport TX STBC = %s\n", (pCapELE->TxSTBC)?"YES": "NO");
139 IEEE80211_DEBUG(IEEE80211_DL_HT, "\tMax AMSDU Size = %s\n", (pCapELE->MaxAMSDUSize)?"3839": "7935");
140 IEEE80211_DEBUG(IEEE80211_DL_HT, "\tSupport CCK in 20/40 mode = %s\n", (pCapELE->DssCCk)?"YES": "NO");
141 IEEE80211_DEBUG(IEEE80211_DL_HT, "\tMax AMPDU Factor = %d\n", pCapELE->MaxRxAMPDUFactor);
142 IEEE80211_DEBUG(IEEE80211_DL_HT, "\tMPDU Density = %d\n", pCapELE->MPDUDensity);
143 IEEE80211_DEBUG(IEEE80211_DL_HT, "\tMCS Rate Set = [%x][%x][%x][%x][%x]\n", pCapELE->MCS[0],\
144 pCapELE->MCS[1], pCapELE->MCS[2], pCapELE->MCS[3], pCapELE->MCS[4]);
145 return;
148 /********************************************************************************************************************
149 *function: This function print out each field on HT Information IE mainly from (Beacon/ProbeRsp)
150 * input: u8* InfoIE //Capability IE to be printed out
151 * u8* TitleString //mainly print out caller function
152 * output: none
153 * return: none
154 * notice: Driver should not print out this message by default.
155 * *****************************************************************************************************************/
156 void HTDebugHTInfo(u8* InfoIE, u8* TitleString)
159 static u8 EWC11NHTInfo[] = {0x00, 0x90, 0x4c, 0x34}; // For 11n EWC definition, 2007.07.17, by Emily
160 PHT_INFORMATION_ELE pHTInfoEle;
162 if(!memcmp(InfoIE, EWC11NHTInfo, sizeof(EWC11NHTInfo)))
164 // Not EWC IE
165 IEEE80211_DEBUG(IEEE80211_DL_HT, "EWC IE in %s()\n", __FUNCTION__);
166 pHTInfoEle = (PHT_INFORMATION_ELE)(&InfoIE[4]);
167 }else
168 pHTInfoEle = (PHT_INFORMATION_ELE)(&InfoIE[0]);
171 IEEE80211_DEBUG(IEEE80211_DL_HT, "<Log HT Information Element>. Called by %s\n", TitleString);
173 IEEE80211_DEBUG(IEEE80211_DL_HT, "\tPrimary channel = %d\n", pHTInfoEle->ControlChl);
174 IEEE80211_DEBUG(IEEE80211_DL_HT, "\tSenondary channel =");
175 switch(pHTInfoEle->ExtChlOffset)
177 case 0:
178 IEEE80211_DEBUG(IEEE80211_DL_HT, "Not Present\n");
179 break;
180 case 1:
181 IEEE80211_DEBUG(IEEE80211_DL_HT, "Upper channel\n");
182 break;
183 case 2:
184 IEEE80211_DEBUG(IEEE80211_DL_HT, "Reserved. Eooro!!!\n");
185 break;
186 case 3:
187 IEEE80211_DEBUG(IEEE80211_DL_HT, "Lower Channel\n");
188 break;
190 IEEE80211_DEBUG(IEEE80211_DL_HT, "\tRecommended channel width = %s\n", (pHTInfoEle->RecommemdedTxWidth)?"20Mhz": "40Mhz");
192 IEEE80211_DEBUG(IEEE80211_DL_HT, "\tOperation mode for protection = ");
193 switch(pHTInfoEle->OptMode)
195 case 0:
196 IEEE80211_DEBUG(IEEE80211_DL_HT, "No Protection\n");
197 break;
198 case 1:
199 IEEE80211_DEBUG(IEEE80211_DL_HT, "HT non-member protection mode\n");
200 break;
201 case 2:
202 IEEE80211_DEBUG(IEEE80211_DL_HT, "Suggest to open protection\n");
203 break;
204 case 3:
205 IEEE80211_DEBUG(IEEE80211_DL_HT, "HT mixed mode\n");
206 break;
209 IEEE80211_DEBUG(IEEE80211_DL_HT, "\tBasic MCS Rate Set = [%x][%x][%x][%x][%x]\n", pHTInfoEle->BasicMSC[0],\
210 pHTInfoEle->BasicMSC[1], pHTInfoEle->BasicMSC[2], pHTInfoEle->BasicMSC[3], pHTInfoEle->BasicMSC[4]);
211 return;
215 * Return: true if station in half n mode and AP supports 40 bw
217 bool IsHTHalfNmode40Bandwidth(struct ieee80211_device* ieee)
219 bool retValue = false;
220 PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
222 if(pHTInfo->bCurrentHTSupport == false ) // wireless is n mode
223 retValue = false;
224 else if(pHTInfo->bRegBW40MHz == false) // station supports 40 bw
225 retValue = false;
226 else if(!ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev)) // station in half n mode
227 retValue = false;
228 else if(((PHT_CAPABILITY_ELE)(pHTInfo->PeerHTCapBuf))->ChlWidth) // ap support 40 bw
229 retValue = true;
230 else
231 retValue = false;
233 return retValue;
236 bool IsHTHalfNmodeSGI(struct ieee80211_device* ieee, bool is40MHz)
238 bool retValue = false;
239 PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
241 if(pHTInfo->bCurrentHTSupport == false ) // wireless is n mode
242 retValue = false;
243 else if(!ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev)) // station in half n mode
244 retValue = false;
245 else if(is40MHz) // ap support 40 bw
247 if(((PHT_CAPABILITY_ELE)(pHTInfo->PeerHTCapBuf))->ShortGI40Mhz) // ap support 40 bw short GI
248 retValue = true;
249 else
250 retValue = false;
252 else
254 if(((PHT_CAPABILITY_ELE)(pHTInfo->PeerHTCapBuf))->ShortGI20Mhz) // ap support 40 bw short GI
255 retValue = true;
256 else
257 retValue = false;
260 return retValue;
263 u16 HTHalfMcsToDataRate(struct ieee80211_device* ieee, u8 nMcsRate)
266 u8 is40MHz;
267 u8 isShortGI;
269 is40MHz = (IsHTHalfNmode40Bandwidth(ieee))?1:0;
270 isShortGI = (IsHTHalfNmodeSGI(ieee, is40MHz))? 1:0;
272 return MCS_DATA_RATE[is40MHz][isShortGI][(nMcsRate&0x7f)];
276 u16 HTMcsToDataRate( struct ieee80211_device* ieee, u8 nMcsRate)
278 PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
280 u8 is40MHz = (pHTInfo->bCurBW40MHz)?1:0;
281 u8 isShortGI = (pHTInfo->bCurBW40MHz)?
282 ((pHTInfo->bCurShortGI40MHz)?1:0):
283 ((pHTInfo->bCurShortGI20MHz)?1:0);
284 return MCS_DATA_RATE[is40MHz][isShortGI][(nMcsRate&0x7f)];
287 /********************************************************************************************************************
288 *function: This function returns current datarate.
289 * input: struct ieee80211_device* ieee
290 * u8 nDataRate
291 * output: none
292 * return: tx rate
293 * notice: quite unsure about how to use this function //wb
294 * *****************************************************************************************************************/
295 u16 TxCountToDataRate( struct ieee80211_device* ieee, u8 nDataRate)
297 //PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
298 u16 CCKOFDMRate[12] = {0x02 , 0x04 , 0x0b , 0x16 , 0x0c , 0x12 , 0x18 , 0x24 , 0x30 , 0x48 , 0x60 , 0x6c};
299 u8 is40MHz = 0;
300 u8 isShortGI = 0;
302 if(nDataRate < 12)
304 return CCKOFDMRate[nDataRate];
306 else
308 if (nDataRate >= 0x10 && nDataRate <= 0x1f)//if(nDataRate > 11 && nDataRate < 28 )
310 is40MHz = 0;
311 isShortGI = 0;
313 // nDataRate = nDataRate - 12;
315 else if(nDataRate >=0x20 && nDataRate <= 0x2f ) //(27, 44)
317 is40MHz = 1;
318 isShortGI = 0;
320 //nDataRate = nDataRate - 28;
322 else if(nDataRate >= 0x30 && nDataRate <= 0x3f ) //(43, 60)
324 is40MHz = 0;
325 isShortGI = 1;
327 //nDataRate = nDataRate - 44;
329 else if(nDataRate >= 0x40 && nDataRate <= 0x4f ) //(59, 76)
331 is40MHz = 1;
332 isShortGI = 1;
334 //nDataRate = nDataRate - 60;
336 return MCS_DATA_RATE[is40MHz][isShortGI][nDataRate&0xf];
342 bool IsHTHalfNmodeAPs(struct ieee80211_device* ieee)
344 bool retValue = false;
345 struct ieee80211_network* net = &ieee->current_network;
346 #if 0
347 if(pMgntInfo->bHalfNMode == false)
348 retValue = false;
349 else
350 #endif
351 if((memcmp(net->bssid, BELKINF5D8233V1_RALINK, 3)==0) ||
352 (memcmp(net->bssid, BELKINF5D82334V3_RALINK, 3)==0) ||
353 (memcmp(net->bssid, PCI_RALINK, 3)==0) ||
354 (memcmp(net->bssid, EDIMAX_RALINK, 3)==0) ||
355 (memcmp(net->bssid, AIRLINK_RALINK, 3)==0) ||
356 (net->ralink_cap_exist))
357 retValue = true;
358 else if((memcmp(net->bssid, UNKNOWN_BORADCOM, 3)==0) ||
359 (memcmp(net->bssid, LINKSYSWRT330_LINKSYSWRT300_BROADCOM, 3)==0)||
360 (memcmp(net->bssid, LINKSYSWRT350_LINKSYSWRT150_BROADCOM, 3)==0)||
361 (memcmp(net->bssid, NETGEAR834Bv2_BROADCOM, 3)==0) ||
362 (net->broadcom_cap_exist))
363 retValue = true;
364 else if(net->bssht.bdRT2RTAggregation)
365 retValue = true;
366 else
367 retValue = false;
369 return retValue;
372 /********************************************************************************************************************
373 *function: This function returns peer IOT.
374 * input: struct ieee80211_device* ieee
375 * output: none
376 * return:
377 * notice:
378 * *****************************************************************************************************************/
379 void HTIOTPeerDetermine(struct ieee80211_device* ieee)
381 PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
382 struct ieee80211_network* net = &ieee->current_network;
383 //FIXME: need to decide 92U_SOFTAP //LZM,090320
384 if(net->bssht.bdRT2RTAggregation){
385 pHTInfo->IOTPeer = HT_IOT_PEER_REALTEK;
386 if(net->bssht.RT2RT_HT_Mode & RT_HT_CAP_USE_92SE){
387 pHTInfo->IOTPeer = HT_IOT_PEER_REALTEK_92SE;
390 else if(net->broadcom_cap_exist)
391 pHTInfo->IOTPeer = HT_IOT_PEER_BROADCOM;
392 else if((memcmp(net->bssid, UNKNOWN_BORADCOM, 3)==0) ||
393 (memcmp(net->bssid, LINKSYSWRT330_LINKSYSWRT300_BROADCOM, 3)==0)||
394 (memcmp(net->bssid, LINKSYSWRT350_LINKSYSWRT150_BROADCOM, 3)==0)||
395 (memcmp(net->bssid, NETGEAR834Bv2_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)
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;
413 else
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
422 * u8 * PeerMacAddr
423 * output: none
424 * return: return 1 if driver should declare MCS13 only(otherwise return 0)
425 * *****************************************************************************************************************/
426 u8 HTIOTActIsDisableMCS14(struct ieee80211_device* ieee, u8* PeerMacAddr)
428 u8 ret = 0;
429 #if 0
430 // Apply for 819u only
431 #if (HAL_CODE_BASE==RTL8192 && DEV_BUS_TYPE==USB_INTERFACE)
432 if((memcmp(PeerMacAddr, UNKNOWN_BORADCOM, 3)==0) ||
433 (memcmp(PeerMacAddr, LINKSYSWRT330_LINKSYSWRT300_BROADCOM, 3)==0)
436 ret = 1;
440 if(pHTInfo->bCurrentRT2RTAggregation)
442 // The parameter of pHTInfo->bCurrentRT2RTAggregation must be decided previously
443 ret = 1;
445 #endif
446 #endif
447 return ret;
452 * Function: HTIOTActIsDisableMCS15
454 * Overview: Check whether driver should declare capability of receving MCS15
456 * Input:
457 * PADAPTER Adapter,
459 * Output: None
460 * Return: true if driver should disable MCS15
461 * 2008.04.15 Emily
463 bool HTIOTActIsDisableMCS15(struct ieee80211_device* ieee)
465 bool retValue = false;
467 #ifdef TODO
468 // Apply for 819u only
469 #if (HAL_CODE_BASE==RTL8192)
471 #if (DEV_BUS_TYPE == USB_INTERFACE)
472 // Alway disable MCS15 by Jerry Chang's request.by Emily, 2008.04.15
473 retValue = true;
474 #elif (DEV_BUS_TYPE == PCI_INTERFACE)
475 // Enable MCS15 if the peer is Cisco AP. by Emily, 2008.05.12
476 // if(pBssDesc->bCiscoCapExist)
477 // retValue = false;
478 // else
479 retValue = false;
480 #endif
481 #endif
482 #endif
483 // Jerry Chang suggest that 8190 1x2 does not need to disable MCS15
485 return retValue;
489 * Function: HTIOTActIsDisableMCSTwoSpatialStream
491 * Overview: Check whether driver should declare capability of receving All 2 ss packets
493 * Input:
494 * PADAPTER Adapter,
496 * Output: None
497 * Return: true if driver should disable all two spatial stream packet
498 * 2008.04.21 Emily
500 bool HTIOTActIsDisableMCSTwoSpatialStream(struct ieee80211_device* ieee)
502 bool retValue = false;
503 #ifdef TODO
504 // Apply for 819u only
505 //#if (HAL_CODE_BASE==RTL8192)
507 //This rule only apply to Belkin(Ralink) AP
508 if(IS_UNDER_11N_AES_MODE(Adapter))
510 if((PlatformCompareMemory(PeerMacAddr, BELKINF5D8233V1_RALINK, 3)==0) ||
511 (PlatformCompareMemory(PeerMacAddr, PCI_RALINK, 3)==0) ||
512 (PlatformCompareMemory(PeerMacAddr, EDIMAX_RALINK, 3)==0))
514 //Set True to disable this function. Disable by default, Emily, 2008.04.23
515 retValue = false;
519 //#endif
520 #endif
521 #if 1
522 #if (defined(RTL8192SE) || (defined(RTL8192SU)))
523 PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
524 if(ieee->is_ap_in_wep_tkip && ieee->is_ap_in_wep_tkip(ieee->dev))
526 if( (pHTInfo->IOTPeer != HT_IOT_PEER_ATHEROS) &&
527 (pHTInfo->IOTPeer != HT_IOT_PEER_UNKNOWN) &&
528 (pHTInfo->IOTPeer != HT_IOT_PEER_MARVELL) )
529 retValue = true;
531 #endif
532 #endif
533 return retValue;
536 /********************************************************************************************************************
537 *function: Check whether driver should disable EDCA turbo mode
538 * input: struct ieee80211_device* ieee
539 * u8* PeerMacAddr
540 * output: none
541 * return: return 1 if driver should disable EDCA turbo mode(otherwise return 0)
542 * *****************************************************************************************************************/
543 u8 HTIOTActIsDisableEDCATurbo(struct ieee80211_device* ieee, u8* PeerMacAddr)
545 u8 retValue = false; // default enable EDCA Turbo mode.
546 // Set specific EDCA parameter for different AP in DM handler.
548 return retValue;
549 #if 0
550 if((memcmp(PeerMacAddr, UNKNOWN_BORADCOM, 3)==0)||
551 (memcmp(PeerMacAddr, LINKSYSWRT330_LINKSYSWRT300_BROADCOM, 3)==0)||
552 (memcmp(PeerMacAddr, LINKSYSWRT350_LINKSYSWRT150_BROADCOM, 3)==0)||
553 (memcmp(PeerMacAddr, NETGEAR834Bv2_BROADCOM, 3)==0))
556 retValue = 1; //Linksys disable EDCA turbo mode
559 return retValue;
560 #endif
563 /********************************************************************************************************************
564 *function: Check whether we need to use OFDM to sned MGNT frame for broadcom AP
565 * input: struct ieee80211_network *network //current network we live
566 * output: none
567 * return: return 1 if true
568 * *****************************************************************************************************************/
569 u8 HTIOTActIsMgntUseCCK6M(struct ieee80211_network *network)
571 u8 retValue = 0;
573 // 2008/01/25 MH Judeg if we need to use OFDM to sned MGNT frame for broadcom AP.
574 // 2008/01/28 MH We must prevent that we select null bssid to link.
576 if(network->broadcom_cap_exist)
578 retValue = 1;
581 return retValue;
584 u8 HTIOTActIsForcedCTS2Self(struct ieee80211_network *network)
586 u8 retValue = 0;
588 if(network->marvell_cap_exist)
590 retValue = 1;
593 return retValue;
596 u8 HTIOTActIsForcedRTSCTS(struct ieee80211_device *ieee, struct ieee80211_network *network)
598 u8 retValue = 0;
599 printk("============>%s(), %d\n", __FUNCTION__, network->realtek_cap_exit);
600 // Force protection
601 #if defined(RTL8192SE) || defined(RTL8192SU)
602 if(ieee->pHTInfo->bCurrentHTSupport)
604 //if(!network->realtek_cap_exit)
605 if((ieee->pHTInfo->IOTPeer != HT_IOT_PEER_REALTEK)&&
606 (ieee->pHTInfo->IOTPeer != HT_IOT_PEER_REALTEK_92SE))
608 if((ieee->pHTInfo->IOTAction & HT_IOT_ACT_TX_NO_AGGREGATION) == 0)
609 retValue = 1;
612 #endif
613 return retValue;
617 HTIOTActIsForcedAMSDU8K(struct ieee80211_device *ieee, struct ieee80211_network *network)
619 u8 retValue = 0;
621 return retValue;
624 u8 HTIOTActIsCCDFsync(u8* PeerMacAddr)
626 u8 retValue = 0;
627 #ifndef RTL8192SE
628 if( (memcmp(PeerMacAddr, UNKNOWN_BORADCOM, 3)==0) ||
629 (memcmp(PeerMacAddr, LINKSYSWRT330_LINKSYSWRT300_BROADCOM, 3)==0) ||
630 (memcmp(PeerMacAddr, LINKSYSWRT350_LINKSYSWRT150_BROADCOM, 3) ==0))
632 retValue = 1;
634 #endif
635 return retValue;
639 * 819xS single chip b-cut series cannot handle BAR
642 HTIOCActRejcectADDBARequest(struct ieee80211_network *network)
644 u8 retValue = 0;
645 //if(IS_HARDWARE_TYPE_8192SE(Adapter) ||
646 // IS_HARDWARE_TYPE_8192SU(Adapter)
648 #if (defined RTL8192SE || defined RTL8192SU)
650 // Do not reject ADDBA REQ because some of the AP may
651 // keep on sending ADDBA REQ qhich cause DHCP fail or ping loss!
652 // by HPFan, 2008/12/30
654 //if(pBssDesc->Vender == HT_IOT_PEER_MARVELL)
655 // return FALSE;
658 #endif
660 return retValue;
665 * EDCA parameters bias on downlink
668 HTIOTActIsEDCABiasRx(struct ieee80211_device* ieee,struct ieee80211_network *network)
670 u8 retValue = 0;
671 //if(IS_HARDWARE_TYPE_8192SU(Adapter))
672 #ifdef RTL8192SU
673 PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
675 //#if UNDER_VISTA
676 // if(pBssDesc->Vender==HT_IOT_PEER_ATHEROS ||
677 // pBssDesc->Vender==HT_IOT_PEER_RALINK)
678 //#else
679 if(pHTInfo->IOTPeer==HT_IOT_PEER_ATHEROS ||
680 pHTInfo->IOTPeer==HT_IOT_PEER_BROADCOM ||
681 pHTInfo->IOTPeer==HT_IOT_PEER_RALINK)
682 //#endif
683 return 1;
686 #endif
687 return retValue;
691 HTIOTActDisableShortGI(struct ieee80211_device* ieee,struct ieee80211_network *network)
693 u8 retValue = 0;
694 PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
696 if(pHTInfo->IOTPeer==HT_IOT_PEER_RALINK)
698 if(network->bssht.bdHT1R)
699 retValue = 1;
702 return retValue;
706 HTIOTActDisableHighPower(struct ieee80211_device* ieee,struct ieee80211_network *network)
708 u8 retValue = 0;
709 PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
711 if(pHTInfo->IOTPeer==HT_IOT_PEER_RALINK)
713 if(network->bssht.bdHT1R)
714 retValue = 1;
717 return retValue;
720 void
721 HTIOTActDetermineRaFunc(struct ieee80211_device* ieee, bool bPeerRx2ss)
723 PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
724 pHTInfo->IOTRaFunc &= HT_IOT_RAFUNC_DISABLE_ALL;
726 if(pHTInfo->IOTPeer == HT_IOT_PEER_RALINK && !bPeerRx2ss)
727 pHTInfo->IOTRaFunc |= HT_IOT_RAFUNC_PEER_1R;
729 if(pHTInfo->IOTAction & HT_IOT_ACT_AMSDU_ENABLE)
730 pHTInfo->IOTRaFunc |= HT_IOT_RAFUNC_TX_AMSDU;
732 printk("!!!!!!!!!!!!!!!!!!!!!!!!!!!IOTRaFunc = %8.8x\n", pHTInfo->IOTRaFunc);
737 HTIOTActIsDisableTx40MHz(struct ieee80211_device* ieee,struct ieee80211_network *network)
739 u8 retValue = 0;
741 #if (defined RTL8192SU || defined RTL8192SE)
742 PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
743 if( (KEY_TYPE_WEP104 == ieee->pairwise_key_type) ||
744 (KEY_TYPE_WEP40 == ieee->pairwise_key_type) ||
745 (KEY_TYPE_WEP104 == ieee->group_key_type) ||
746 (KEY_TYPE_WEP40 == ieee->group_key_type) ||
747 (KEY_TYPE_TKIP == ieee->pairwise_key_type) )
749 if((pHTInfo->IOTPeer==HT_IOT_PEER_REALTEK) && (network->bssht.bdSupportHT))
750 retValue = 1;
752 #endif
754 return retValue;
758 HTIOTActIsTxNoAggregation(struct ieee80211_device* ieee,struct ieee80211_network *network)
760 u8 retValue = 0;
762 #if (defined RTL8192SU || defined RTL8192SE)
763 PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
764 if( (KEY_TYPE_WEP104 == ieee->pairwise_key_type) ||
765 (KEY_TYPE_WEP40 == ieee->pairwise_key_type) ||
766 (KEY_TYPE_WEP104 == ieee->group_key_type) ||
767 (KEY_TYPE_WEP40 == ieee->group_key_type) ||
768 (KEY_TYPE_TKIP == ieee->pairwise_key_type) )
770 if(pHTInfo->IOTPeer==HT_IOT_PEER_REALTEK ||
771 pHTInfo->IOTPeer==HT_IOT_PEER_UNKNOWN)
772 retValue = 1;
774 #endif
776 return retValue;
781 HTIOTActIsDisableTx2SS(struct ieee80211_device* ieee,struct ieee80211_network *network)
783 u8 retValue = 0;
785 #if (defined RTL8192SU || defined RTL8192SE)
786 PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
787 if( (KEY_TYPE_WEP104 == ieee->pairwise_key_type) ||
788 (KEY_TYPE_WEP40 == ieee->pairwise_key_type) ||
789 (KEY_TYPE_WEP104 == ieee->group_key_type) ||
790 (KEY_TYPE_WEP40 == ieee->group_key_type) ||
791 (KEY_TYPE_TKIP == ieee->pairwise_key_type) )
793 if((pHTInfo->IOTPeer==HT_IOT_PEER_REALTEK) && (network->bssht.bdSupportHT))
794 retValue = 1;
796 #endif
798 return retValue;
802 bool HTIOCActAllowPeerAggOnePacket(struct ieee80211_device* ieee,struct ieee80211_network *network)
804 bool retValue = false;
805 #if defined(RTL8192SE) || defined(RTL8192SU)
806 PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
808 if(pHTInfo->IOTPeer == HT_IOT_PEER_MARVELL)
809 return true;
812 #endif
813 return retValue;
816 void HTResetIOTSetting(
817 PRT_HIGH_THROUGHPUT pHTInfo
820 pHTInfo->IOTAction = 0;
821 pHTInfo->IOTPeer = HT_IOT_PEER_UNKNOWN;
822 pHTInfo->IOTRaFunc = 0;
826 /********************************************************************************************************************
827 *function: Construct Capablility Element in Beacon... if HTEnable is turned on
828 * input: struct ieee80211_device* ieee
829 * u8* posHTCap //pointer to store Capability Ele
830 * u8* len //store length of CE
831 * u8 IsEncrypt //whether encrypt, needed further
832 * output: none
833 * return: none
834 * notice: posHTCap can't be null and should be initialized before.
835 * *****************************************************************************************************************/
836 void HTConstructCapabilityElement(struct ieee80211_device* ieee, u8* posHTCap, u8* len, u8 IsEncrypt)
838 PRT_HIGH_THROUGHPUT pHT = ieee->pHTInfo;
839 PHT_CAPABILITY_ELE pCapELE = NULL;
840 //u8 bIsDeclareMCS13;
842 if ((posHTCap == NULL) || (pHT == NULL))
844 IEEE80211_DEBUG(IEEE80211_DL_ERR, "posHTCap or pHTInfo can't be null in HTConstructCapabilityElement()\n");
845 return;
847 memset(posHTCap, 0, *len);
848 if(pHT->ePeerHTSpecVer == HT_SPEC_VER_EWC)
850 u8 EWC11NHTCap[] = {0x00, 0x90, 0x4c, 0x33}; // For 11n EWC definition, 2007.07.17, by Emily
851 memcpy(posHTCap, EWC11NHTCap, sizeof(EWC11NHTCap));
852 pCapELE = (PHT_CAPABILITY_ELE)&(posHTCap[4]);
853 }else
855 pCapELE = (PHT_CAPABILITY_ELE)posHTCap;
859 //HT capability info
860 pCapELE->AdvCoding = 0; // This feature is not supported now!!
861 if(ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev))
863 pCapELE->ChlWidth = 0;
865 else
867 pCapELE->ChlWidth = (pHT->bRegBW40MHz?1:0);
870 // pCapELE->ChlWidth = (pHT->bRegBW40MHz?1:0);
871 pCapELE->MimoPwrSave = pHT->SelfMimoPs;
872 pCapELE->GreenField = 0; // This feature is not supported now!!
873 pCapELE->ShortGI20Mhz = 1; // We can receive Short GI!!
874 pCapELE->ShortGI40Mhz = 1; // We can receive Short GI!!
875 //DbgPrint("TX HT cap/info ele BW=%d SG20=%d SG40=%d\n\r",
876 //pCapELE->ChlWidth, pCapELE->ShortGI20Mhz, pCapELE->ShortGI40Mhz);
877 pCapELE->TxSTBC = 1;
878 pCapELE->RxSTBC = 0;
879 pCapELE->DelayBA = 0; // Do not support now!!
880 pCapELE->MaxAMSDUSize = (MAX_RECEIVE_BUFFER_SIZE>=7935)?1:0;
881 pCapELE->DssCCk = ((pHT->bRegBW40MHz)?(pHT->bRegSuppCCK?1:0):0);
882 pCapELE->PSMP = 0; // Do not support now!!
883 pCapELE->LSigTxopProtect = 0; // Do not support now!!
886 //MAC HT parameters info
887 // TODO: Nedd to take care of this part
888 IEEE80211_DEBUG(IEEE80211_DL_HT, "TX HT cap/info ele BW=%d MaxAMSDUSize:%d DssCCk:%d\n", pCapELE->ChlWidth, pCapELE->MaxAMSDUSize, pCapELE->DssCCk);
890 if( IsEncrypt)
892 pCapELE->MPDUDensity = 7; // 8us
893 pCapELE->MaxRxAMPDUFactor = 2; // 2 is for 32 K and 3 is 64K
895 else
897 pCapELE->MaxRxAMPDUFactor = 3; // 2 is for 32 K and 3 is 64K
898 pCapELE->MPDUDensity = 0; // no density
901 //Supported MCS set
902 memcpy(pCapELE->MCS, ieee->Regdot11HTOperationalRateSet, 16);
903 if(pHT->IOTAction & HT_IOT_ACT_DISABLE_MCS15)
904 pCapELE->MCS[1] &= 0x7f;
906 if(pHT->IOTAction & HT_IOT_ACT_DISABLE_MCS14)
907 pCapELE->MCS[1] &= 0xbf;
909 if(pHT->IOTAction & HT_IOT_ACT_DISABLE_ALL_2SS)
910 pCapELE->MCS[1] &= 0x00;
912 // 2008.06.12
913 // For RTL819X, if pairwisekey = wep/tkip, ap is ralink, we support only MCS0~7.
914 if(ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev))
916 int i;
917 for(i = 1; i< 16; i++)
918 pCapELE->MCS[i] = 0;
921 //Extended HT Capability Info
922 memset(&pCapELE->ExtHTCapInfo, 0, 2);
925 //TXBF Capabilities
926 memset(pCapELE->TxBFCap, 0, 4);
928 //Antenna Selection Capabilities
929 pCapELE->ASCap = 0;
930 //add 2 to give space for element ID and len when construct frames
931 if(pHT->ePeerHTSpecVer == HT_SPEC_VER_EWC)
932 *len = 30 + 2;
933 else
934 *len = 26 + 2;
938 // IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA | IEEE80211_DL_HT, posHTCap, *len -2);
940 //Print each field in detail. Driver should not print out this message by default
941 // HTDebugHTCapability(posHTCap, (u8*)"HTConstructCapability()");
942 return;
945 /********************************************************************************************************************
946 *function: Construct Information Element in Beacon... if HTEnable is turned on
947 * input: struct ieee80211_device* ieee
948 * u8* posHTCap //pointer to store Information Ele
949 * u8* len //store len of
950 * u8 IsEncrypt //whether encrypt, needed further
951 * output: none
952 * return: none
953 * notice: posHTCap can't be null and be initialized before. only AP and IBSS sta should do this
954 * *****************************************************************************************************************/
955 void HTConstructInfoElement(struct ieee80211_device* ieee, u8* posHTInfo, u8* len, u8 IsEncrypt)
957 PRT_HIGH_THROUGHPUT pHT = ieee->pHTInfo;
958 PHT_INFORMATION_ELE pHTInfoEle = (PHT_INFORMATION_ELE)posHTInfo;
959 if ((posHTInfo == NULL) || (pHTInfoEle == NULL))
961 IEEE80211_DEBUG(IEEE80211_DL_ERR, "posHTInfo or pHTInfoEle can't be null in HTConstructInfoElement()\n");
962 return;
965 memset(posHTInfo, 0, *len);
966 if ( (ieee->iw_mode == IW_MODE_ADHOC) || (ieee->iw_mode == IW_MODE_MASTER)) //ap mode is not currently supported
968 pHTInfoEle->ControlChl = ieee->current_network.channel;
969 pHTInfoEle->ExtChlOffset = ((pHT->bRegBW40MHz == false)?HT_EXTCHNL_OFFSET_NO_EXT:
970 (ieee->current_network.channel<=6)?
971 HT_EXTCHNL_OFFSET_UPPER:HT_EXTCHNL_OFFSET_LOWER);
972 pHTInfoEle->RecommemdedTxWidth = pHT->bRegBW40MHz;
973 pHTInfoEle->RIFS = 0;
974 pHTInfoEle->PSMPAccessOnly = 0;
975 pHTInfoEle->SrvIntGranularity = 0;
976 pHTInfoEle->OptMode = pHT->CurrentOpMode;
977 pHTInfoEle->NonGFDevPresent = 0;
978 pHTInfoEle->DualBeacon = 0;
979 pHTInfoEle->SecondaryBeacon = 0;
980 pHTInfoEle->LSigTxopProtectFull = 0;
981 pHTInfoEle->PcoActive = 0;
982 pHTInfoEle->PcoPhase = 0;
984 memset(pHTInfoEle->BasicMSC, 0, 16);
987 *len = 22 + 2; //same above
990 else
992 //STA should not generate High Throughput Information Element
993 *len = 0;
995 //IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA | IEEE80211_DL_HT, posHTInfo, *len - 2);
996 //HTDebugHTInfo(posHTInfo, "HTConstructInforElement");
997 return;
1001 * According to experiment, Realtek AP to STA (based on rtl8190) may achieve best performance
1002 * if both STA and AP set limitation of aggregation size to 32K, that is, set AMPDU density to 2
1003 * (Ref: IEEE 11n specification). However, if Realtek STA associates to other AP, STA should set
1004 * limitation of aggregation size to 8K, otherwise, performance of traffic stream from STA to AP
1005 * will be much less than the traffic stream from AP to STA if both of the stream runs concurrently
1006 * at the same time.
1008 * Frame Format
1009 * Element ID Length OUI Type1 Reserved
1010 * 1 byte 1 byte 3 bytes 1 byte 1 byte
1012 * OUI = 0x00, 0xe0, 0x4c,
1013 * Type = 0x02
1014 * Reserved = 0x00
1016 * 2007.8.21 by Emily
1018 /********************************************************************************************************************
1019 *function: Construct Information Element in Beacon... in RT2RT condition
1020 * input: struct ieee80211_device* ieee
1021 * u8* posRT2RTAgg //pointer to store Information Ele
1022 * u8* len //store len
1023 * output: none
1024 * return: none
1025 * notice:
1026 * *****************************************************************************************************************/
1027 void HTConstructRT2RTAggElement(struct ieee80211_device* ieee, u8* posRT2RTAgg, u8* len)
1029 if (posRT2RTAgg == NULL) {
1030 IEEE80211_DEBUG(IEEE80211_DL_ERR, "posRT2RTAgg can't be null in HTConstructRT2RTAggElement()\n");
1031 return;
1033 memset(posRT2RTAgg, 0, *len);
1034 *posRT2RTAgg++ = 0x00;
1035 *posRT2RTAgg++ = 0xe0;
1036 *posRT2RTAgg++ = 0x4c;
1037 *posRT2RTAgg++ = 0x02;
1038 *posRT2RTAgg++ = 0x01;
1039 *posRT2RTAgg = 0x10;//*posRT2RTAgg = 0x02;
1041 if(ieee->bSupportRemoteWakeUp) {
1042 *posRT2RTAgg |= 0x08;//RT_HT_CAP_USE_WOW;
1045 *len = 6 + 2;
1046 return;
1047 #ifdef TODO
1048 #if(HAL_CODE_BASE == RTL8192 && DEV_BUS_TYPE == USB_INTERFACE)
1050 //Emily. If it is required to Ask Realtek AP to send AMPDU during AES mode, enable this
1051 section of code.
1052 if(IS_UNDER_11N_AES_MODE(Adapter))
1054 posRT2RTAgg->Octet[5] |=RT_HT_CAP_USE_AMPDU;
1055 }else
1057 posRT2RTAgg->Octet[5] &= 0xfb;
1061 #else
1062 // Do Nothing
1063 #endif
1065 posRT2RTAgg->Length = 6;
1066 #endif
1074 /********************************************************************************************************************
1075 *function: Pick the right Rate Adaptive table to use
1076 * input: struct ieee80211_device* ieee
1077 * u8* pOperateMCS //A pointer to MCS rate bitmap
1078 * return: always we return true
1079 * notice:
1080 * *****************************************************************************************************************/
1081 u8 HT_PickMCSRate(struct ieee80211_device* ieee, u8* pOperateMCS)
1083 u8 i;
1084 if (pOperateMCS == NULL)
1086 IEEE80211_DEBUG(IEEE80211_DL_ERR, "pOperateMCS can't be null in HT_PickMCSRate()\n");
1087 return false;
1090 switch(ieee->mode)
1092 case IEEE_A:
1093 case IEEE_B:
1094 case IEEE_G:
1095 //legacy rate routine handled at selectedrate
1097 //no MCS rate
1098 for(i=0;i<=15;i++){
1099 pOperateMCS[i] = 0;
1101 break;
1103 case IEEE_N_24G: //assume CCK rate ok
1104 case IEEE_N_5G:
1105 // Legacy part we only use 6, 5.5,2,1 for N_24G and 6 for N_5G.
1106 // Legacy part shall be handled at SelectRateSet().
1108 //HT part
1109 // TODO: may be different if we have different number of antenna
1110 pOperateMCS[0] &=RATE_ADPT_1SS_MASK; //support MCS 0~7
1111 pOperateMCS[1] &=RATE_ADPT_2SS_MASK;
1112 pOperateMCS[3] &=RATE_ADPT_MCS32_MASK;
1113 break;
1115 //should never reach here
1116 default:
1118 break;
1122 return true;
1126 * Description:
1127 * This function will get the highest speed rate in input MCS set.
1129 * /param Adapter Pionter to Adapter entity
1130 * pMCSRateSet Pointer to MCS rate bitmap
1131 * pMCSFilter Pointer to MCS rate filter
1133 * /return Highest MCS rate included in pMCSRateSet and filtered by pMCSFilter.
1136 /********************************************************************************************************************
1137 *function: This function will get the highest speed rate in input MCS set.
1138 * input: struct ieee80211_device* ieee
1139 * u8* pMCSRateSet //Pointer to MCS rate bitmap
1140 * u8* pMCSFilter //Pointer to MCS rate filter
1141 * return: Highest MCS rate included in pMCSRateSet and filtered by pMCSFilter
1142 * notice:
1143 * *****************************************************************************************************************/
1144 u8 HTGetHighestMCSRate(struct ieee80211_device* ieee, u8* pMCSRateSet, u8* pMCSFilter)
1146 u8 i, j;
1147 u8 bitMap;
1148 u8 mcsRate = 0;
1149 u8 availableMcsRate[16];
1150 if (pMCSRateSet == NULL || pMCSFilter == NULL)
1152 IEEE80211_DEBUG(IEEE80211_DL_ERR, "pMCSRateSet or pMCSFilter can't be null in HTGetHighestMCSRate()\n");
1153 return false;
1155 for(i=0; i<16; i++)
1156 availableMcsRate[i] = pMCSRateSet[i] & pMCSFilter[i];
1158 for(i = 0; i < 16; i++)
1160 if(availableMcsRate[i] != 0)
1161 break;
1163 if(i == 16)
1164 return false;
1166 for(i = 0; i < 16; i++)
1168 if(availableMcsRate[i] != 0)
1170 bitMap = availableMcsRate[i];
1171 for(j = 0; j < 8; j++)
1173 if((bitMap%2) != 0)
1175 if(HTMcsToDataRate(ieee, (8*i+j)) > HTMcsToDataRate(ieee, mcsRate))
1176 mcsRate = (8*i+j);
1178 bitMap = bitMap>>1;
1182 return (mcsRate|0x80);
1189 **1.Filter our operation rate set with AP's rate set
1190 **2.shall reference channel bandwidth, STBC, Antenna number
1191 **3.generate rate adative table for firmware
1192 **David 20060906
1194 ** \pHTSupportedCap: the connected STA's supported rate Capability element
1196 u8 HTFilterMCSRate( struct ieee80211_device* ieee, u8* pSupportMCS, u8* pOperateMCS)
1199 u8 i=0;
1201 // filter out operational rate set not supported by AP, the lenth of it is 16
1202 for(i=0;i<=15;i++){
1203 pOperateMCS[i] = ieee->Regdot11HTOperationalRateSet[i]&pSupportMCS[i];
1207 // TODO: adjust our operational rate set according to our channel bandwidth, STBC and Antenna number
1209 // TODO: fill suggested rate adaptive rate index and give firmware info using Tx command packet
1210 // we also shall suggested the first start rate set according to our singal strength
1211 HT_PickMCSRate(ieee, pOperateMCS);
1213 // For RTL819X, if pairwisekey = wep/tkip, we support only MCS0~7.
1214 if(ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev))
1215 pOperateMCS[1] = 0;
1218 // For RTL819X, we support only MCS0~15.
1219 // And also, we do not know how to use MCS32 now.
1221 for(i=2; i<=15; i++)
1222 pOperateMCS[i] = 0;
1224 return true;
1226 void HTSetConnectBwMode(struct ieee80211_device* ieee, HT_CHANNEL_WIDTH Bandwidth, HT_EXTCHNL_OFFSET Offset);
1227 #if 0
1228 //I need move this function to other places, such as rx?
1229 void HTOnAssocRsp_wq(struct work_struct *work)
1231 struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, ht_onAssRsp);
1232 #endif
1233 void HTOnAssocRsp(struct ieee80211_device *ieee)
1235 PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
1236 PHT_CAPABILITY_ELE pPeerHTCap = NULL;
1237 PHT_INFORMATION_ELE pPeerHTInfo = NULL;
1238 u16 nMaxAMSDUSize = 0;
1239 u8* pMcsFilter = NULL;
1241 static u8 EWC11NHTCap[] = {0x00, 0x90, 0x4c, 0x33}; // For 11n EWC definition, 2007.07.17, by Emily
1242 static u8 EWC11NHTInfo[] = {0x00, 0x90, 0x4c, 0x34}; // For 11n EWC definition, 2007.07.17, by Emily
1244 if( pHTInfo->bCurrentHTSupport == false )
1246 IEEE80211_DEBUG(IEEE80211_DL_ERR, "<=== HTOnAssocRsp(): HT_DISABLE\n");
1247 return;
1249 IEEE80211_DEBUG(IEEE80211_DL_HT, "===> HTOnAssocRsp_wq(): HT_ENABLE\n");
1250 // IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA, pHTInfo->PeerHTCapBuf, sizeof(HT_CAPABILITY_ELE));
1251 // IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA, pHTInfo->PeerHTInfoBuf, sizeof(HT_INFORMATION_ELE));
1253 // HTDebugHTCapability(pHTInfo->PeerHTCapBuf,"HTOnAssocRsp_wq");
1254 // HTDebugHTInfo(pHTInfo->PeerHTInfoBuf,"HTOnAssocRsp_wq");
1256 if(!memcmp(pHTInfo->PeerHTCapBuf,EWC11NHTCap, sizeof(EWC11NHTCap)))
1257 pPeerHTCap = (PHT_CAPABILITY_ELE)(&pHTInfo->PeerHTCapBuf[4]);
1258 else
1259 pPeerHTCap = (PHT_CAPABILITY_ELE)(pHTInfo->PeerHTCapBuf);
1261 if(!memcmp(pHTInfo->PeerHTInfoBuf, EWC11NHTInfo, sizeof(EWC11NHTInfo)))
1262 pPeerHTInfo = (PHT_INFORMATION_ELE)(&pHTInfo->PeerHTInfoBuf[4]);
1263 else
1264 pPeerHTInfo = (PHT_INFORMATION_ELE)(pHTInfo->PeerHTInfoBuf);
1267 ////////////////////////////////////////////////////////
1268 // Configurations:
1269 ////////////////////////////////////////////////////////
1270 IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA|IEEE80211_DL_HT, pPeerHTCap, sizeof(HT_CAPABILITY_ELE));
1271 // IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA|IEEE80211_DL_HT, pPeerHTInfo, sizeof(HT_INFORMATION_ELE));
1272 // Config Supported Channel Width setting
1274 HTSetConnectBwMode(ieee, (HT_CHANNEL_WIDTH)(pPeerHTCap->ChlWidth), (HT_EXTCHNL_OFFSET)(pPeerHTInfo->ExtChlOffset));
1276 // if(pHTInfo->bCurBW40MHz == true)
1277 pHTInfo->bCurTxBW40MHz = ((pPeerHTInfo->RecommemdedTxWidth == 1)?true:false);
1280 // Update short GI/ long GI setting
1282 // TODO:
1283 pHTInfo->bCurShortGI20MHz=
1284 ((pHTInfo->bRegShortGI20MHz)?((pPeerHTCap->ShortGI20Mhz==1)?true:false):false);
1285 pHTInfo->bCurShortGI40MHz=
1286 ((pHTInfo->bRegShortGI40MHz)?((pPeerHTCap->ShortGI40Mhz==1)?true:false):false);
1289 // Config TX STBC setting
1291 // TODO:
1294 // Config DSSS/CCK mode in 40MHz mode
1296 // TODO:
1297 pHTInfo->bCurSuppCCK =
1298 ((pHTInfo->bRegSuppCCK)?((pPeerHTCap->DssCCk==1)?true:false):false);
1302 // Config and configure A-MSDU setting
1304 pHTInfo->bCurrent_AMSDU_Support = pHTInfo->bAMSDU_Support;
1306 nMaxAMSDUSize = (pPeerHTCap->MaxAMSDUSize==0)?3839:7935;
1308 if(pHTInfo->nAMSDU_MaxSize > nMaxAMSDUSize )
1309 pHTInfo->nCurrent_AMSDU_MaxSize = nMaxAMSDUSize;
1310 else
1311 pHTInfo->nCurrent_AMSDU_MaxSize = pHTInfo->nAMSDU_MaxSize;
1314 // Config A-MPDU setting
1316 pHTInfo->bCurrentAMPDUEnable = pHTInfo->bAMPDUEnable;
1317 if(ieee->is_ap_in_wep_tkip && ieee->is_ap_in_wep_tkip(ieee->dev))
1319 if( (pHTInfo->IOTPeer== HT_IOT_PEER_ATHEROS) ||
1320 (pHTInfo->IOTPeer == HT_IOT_PEER_UNKNOWN) )
1321 pHTInfo->bCurrentAMPDUEnable = false;
1324 // <1> Decide AMPDU Factor
1326 // By Emily
1327 if(!pHTInfo->bRegRT2RTAggregation)
1329 // Decide AMPDU Factor according to protocol handshake
1330 if(pHTInfo->AMPDU_Factor > pPeerHTCap->MaxRxAMPDUFactor)
1331 pHTInfo->CurrentAMPDUFactor = pPeerHTCap->MaxRxAMPDUFactor;
1332 else
1333 pHTInfo->CurrentAMPDUFactor = pHTInfo->AMPDU_Factor;
1335 }else
1337 // Set MPDU density to 2 to Realtek AP, and set it to 0 for others
1338 // Replace MPDU factor declared in original association response frame format. 2007.08.20 by Emily
1339 #if 0
1340 osTmp= PacketGetElement( asocpdu, EID_Vendor, OUI_SUB_REALTEK_AGG, OUI_SUBTYPE_DONT_CARE);
1341 if(osTmp.Length >= 5) //00:e0:4c:02:00
1342 #endif
1343 if (ieee->current_network.bssht.bdRT2RTAggregation)
1345 if( ieee->pairwise_key_type != KEY_TYPE_NA)
1346 // Realtek may set 32k in security mode and 64k for others
1347 pHTInfo->CurrentAMPDUFactor = pPeerHTCap->MaxRxAMPDUFactor;
1348 else
1349 pHTInfo->CurrentAMPDUFactor = HT_AGG_SIZE_64K;
1350 }else
1352 if(pPeerHTCap->MaxRxAMPDUFactor < HT_AGG_SIZE_32K)
1353 pHTInfo->CurrentAMPDUFactor = pPeerHTCap->MaxRxAMPDUFactor;
1354 else
1355 pHTInfo->CurrentAMPDUFactor = HT_AGG_SIZE_32K;
1359 // <2> Set AMPDU Minimum MPDU Start Spacing
1360 // 802.11n 3.0 section 9.7d.3
1361 #if 1
1362 if(pHTInfo->MPDU_Density > pPeerHTCap->MPDUDensity)
1363 pHTInfo->CurrentMPDUDensity = pHTInfo->MPDU_Density;
1364 else
1365 pHTInfo->CurrentMPDUDensity = pPeerHTCap->MPDUDensity;
1366 if(ieee->pairwise_key_type != KEY_TYPE_NA )
1367 pHTInfo->CurrentMPDUDensity = 7; // 8us
1368 #else
1369 if(pHTInfo->MPDU_Density > pPeerHTCap->MPDUDensity)
1370 pHTInfo->CurrentMPDUDensity = pHTInfo->MPDU_Density;
1371 else
1372 pHTInfo->CurrentMPDUDensity = pPeerHTCap->MPDUDensity;
1373 #endif
1374 // Force TX AMSDU
1376 // Lanhsin: mark for tmp to avoid deauth by ap from s3
1377 //if(memcmp(pMgntInfo->Bssid, NETGEAR834Bv2_BROADCOM, 3)==0)
1378 if(pHTInfo->IOTAction & HT_IOT_ACT_TX_USE_AMSDU_8K)
1381 pHTInfo->bCurrentAMPDUEnable = false;
1382 pHTInfo->ForcedAMSDUMode = HT_AGG_FORCE_ENABLE;
1383 pHTInfo->ForcedAMSDUMaxSize = 7935;
1386 // Rx Reorder Setting
1387 pHTInfo->bCurRxReorderEnable = pHTInfo->bRegRxReorderEnable;
1390 // Filter out unsupported HT rate for this AP
1391 // Update RATR table
1392 // This is only for 8190 ,8192 or later product which using firmware to handle rate adaptive mechanism.
1395 // Handle Ralink AP bad MCS rate set condition. Joseph.
1396 // This fix the bug of Ralink AP. This may be removed in the future.
1397 if(pPeerHTCap->MCS[0] == 0)
1398 pPeerHTCap->MCS[0] = 0xff;
1400 // Joseph test //LZM ADD 090318
1401 HTIOTActDetermineRaFunc(ieee, ((pPeerHTCap->MCS[1])!=0));
1403 HTFilterMCSRate(ieee, pPeerHTCap->MCS, ieee->dot11HTOperationalRateSet);
1406 // Config MIMO Power Save setting
1408 pHTInfo->PeerMimoPs = pPeerHTCap->MimoPwrSave;
1409 if(pHTInfo->PeerMimoPs == MIMO_PS_STATIC)
1410 pMcsFilter = MCS_FILTER_1SS;
1411 else
1412 pMcsFilter = MCS_FILTER_ALL;
1413 //WB add for MCS8 bug
1414 // pMcsFilter = MCS_FILTER_1SS;
1415 ieee->HTHighestOperaRate = HTGetHighestMCSRate(ieee, ieee->dot11HTOperationalRateSet, pMcsFilter);
1416 ieee->HTCurrentOperaRate = ieee->HTHighestOperaRate;
1419 // Config current operation mode.
1421 pHTInfo->CurrentOpMode = pPeerHTInfo->OptMode;
1427 void HTSetConnectBwModeCallback(struct ieee80211_device* ieee);
1428 /********************************************************************************************************************
1429 *function: initialize HT info(struct PRT_HIGH_THROUGHPUT)
1430 * input: struct ieee80211_device* ieee
1431 * output: none
1432 * return: none
1433 * notice: This function is called when * (1) MPInitialization Phase * (2) Receiving of Deauthentication from AP
1434 ********************************************************************************************************************/
1435 // TODO: Should this funciton be called when receiving of Disassociation?
1436 void HTInitializeHTInfo(struct ieee80211_device* ieee)
1438 PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
1441 // These parameters will be reset when receiving deauthentication packet
1443 IEEE80211_DEBUG(IEEE80211_DL_HT, "===========>%s()\n", __FUNCTION__);
1444 pHTInfo->bCurrentHTSupport = false;
1446 // 40MHz channel support
1447 pHTInfo->bCurBW40MHz = false;
1448 pHTInfo->bCurTxBW40MHz = false;
1450 // Short GI support
1451 pHTInfo->bCurShortGI20MHz = false;
1452 pHTInfo->bCurShortGI40MHz = false;
1453 pHTInfo->bForcedShortGI = false;
1455 // CCK rate support
1456 // This flag is set to true to support CCK rate by default.
1457 // It will be affected by "pHTInfo->bRegSuppCCK" and AP capabilities only when associate to
1458 // 11N BSS.
1459 pHTInfo->bCurSuppCCK = true;
1461 // AMSDU related
1462 pHTInfo->bCurrent_AMSDU_Support = false;
1463 pHTInfo->nCurrent_AMSDU_MaxSize = pHTInfo->nAMSDU_MaxSize;
1465 // AMPUD related
1466 pHTInfo->CurrentMPDUDensity = pHTInfo->MPDU_Density;
1467 pHTInfo->CurrentAMPDUFactor = pHTInfo->AMPDU_Factor;
1471 // Initialize all of the parameters related to 11n
1472 memset((void*)(&(pHTInfo->SelfHTCap)), 0, sizeof(pHTInfo->SelfHTCap));
1473 memset((void*)(&(pHTInfo->SelfHTInfo)), 0, sizeof(pHTInfo->SelfHTInfo));
1474 memset((void*)(&(pHTInfo->PeerHTCapBuf)), 0, sizeof(pHTInfo->PeerHTCapBuf));
1475 memset((void*)(&(pHTInfo->PeerHTInfoBuf)), 0, sizeof(pHTInfo->PeerHTInfoBuf));
1477 pHTInfo->bSwBwInProgress = false;
1478 pHTInfo->ChnlOp = CHNLOP_NONE;
1480 // Set default IEEE spec for Draft N
1481 pHTInfo->ePeerHTSpecVer = HT_SPEC_VER_IEEE;
1483 // Realtek proprietary aggregation mode
1484 pHTInfo->bCurrentRT2RTAggregation = false;
1485 pHTInfo->bCurrentRT2RTLongSlotTime = false;
1486 pHTInfo->RT2RT_HT_Mode = (RT_HT_CAPBILITY)0;
1488 pHTInfo->IOTPeer = 0;
1489 pHTInfo->IOTAction = 0;
1490 pHTInfo->IOTRaFunc = 0;
1492 //MCS rate initialized here
1494 u8* RegHTSuppRateSets = &(ieee->RegHTSuppRateSet[0]);
1495 RegHTSuppRateSets[0] = 0xFF; //support MCS 0~7
1496 RegHTSuppRateSets[1] = 0xFF; //support MCS 8~15
1497 RegHTSuppRateSets[4] = 0x01; //support MCS 32
1500 /********************************************************************************************************************
1501 *function: initialize Bss HT structure(struct PBSS_HT)
1502 * input: PBSS_HT pBssHT //to be initialized
1503 * output: none
1504 * return: none
1505 * notice: This function is called when initialize network structure
1506 ********************************************************************************************************************/
1507 void HTInitializeBssDesc(PBSS_HT pBssHT)
1510 pBssHT->bdSupportHT = false;
1511 memset(pBssHT->bdHTCapBuf, 0, sizeof(pBssHT->bdHTCapBuf));
1512 pBssHT->bdHTCapLen = 0;
1513 memset(pBssHT->bdHTInfoBuf, 0, sizeof(pBssHT->bdHTInfoBuf));
1514 pBssHT->bdHTInfoLen = 0;
1516 pBssHT->bdHTSpecVer= HT_SPEC_VER_IEEE;
1518 pBssHT->bdRT2RTAggregation = false;
1519 pBssHT->bdRT2RTLongSlotTime = false;
1520 pBssHT->RT2RT_HT_Mode = (RT_HT_CAPBILITY)0;
1522 #if 0
1523 //below function has merged into ieee80211_network_init() in ieee80211_rx.c
1524 void
1525 HTParsingHTCapElement(
1526 IN PADAPTER Adapter,
1527 IN OCTET_STRING HTCapIE,
1528 OUT PRT_WLAN_BSS pBssDesc
1531 PMGNT_INFO pMgntInfo = &Adapter->MgntInfo;
1533 if( HTCapIE.Length > sizeof(pBssDesc->BssHT.bdHTCapBuf) )
1535 RT_TRACE( COMP_HT, DBG_LOUD, ("HTParsingHTCapElement(): HT Capability Element length is too long!\n") );
1536 return;
1539 // TODO: Check the correctness of HT Cap
1540 //Print each field in detail. Driver should not print out this message by default
1541 if(!pMgntInfo->mActingAsAp && !pMgntInfo->mAssoc)
1542 HTDebugHTCapability(DBG_TRACE, Adapter, &HTCapIE, (pu8)"HTParsingHTCapElement()");
1544 HTCapIE.Length = HTCapIE.Length > sizeof(pBssDesc->BssHT.bdHTCapBuf)?\
1545 sizeof(pBssDesc->BssHT.bdHTCapBuf):HTCapIE.Length; //prevent from overflow
1547 CopyMem(pBssDesc->BssHT.bdHTCapBuf, HTCapIE.Octet, HTCapIE.Length);
1548 pBssDesc->BssHT.bdHTCapLen = HTCapIE.Length;
1553 void
1554 HTParsingHTInfoElement(
1555 PADAPTER Adapter,
1556 OCTET_STRING HTInfoIE,
1557 PRT_WLAN_BSS pBssDesc
1560 PMGNT_INFO pMgntInfo = &Adapter->MgntInfo;
1562 if( HTInfoIE.Length > sizeof(pBssDesc->BssHT.bdHTInfoBuf))
1564 RT_TRACE( COMP_HT, DBG_LOUD, ("HTParsingHTInfoElement(): HT Information Element length is too long!\n") );
1565 return;
1568 // TODO: Check the correctness of HT Info
1569 //Print each field in detail. Driver should not print out this message by default
1570 if(!pMgntInfo->mActingAsAp && !pMgntInfo->mAssoc)
1571 HTDebugHTInfo(DBG_TRACE, Adapter, &HTInfoIE, (pu8)"HTParsingHTInfoElement()");
1573 HTInfoIE.Length = HTInfoIE.Length > sizeof(pBssDesc->BssHT.bdHTInfoBuf)?\
1574 sizeof(pBssDesc->BssHT.bdHTInfoBuf):HTInfoIE.Length; //prevent from overflow
1576 CopyMem( pBssDesc->BssHT.bdHTInfoBuf, HTInfoIE.Octet, HTInfoIE.Length);
1577 pBssDesc->BssHT.bdHTInfoLen = HTInfoIE.Length;
1581 * Get HT related information from beacon and save it in BssDesc
1583 * (1) Parse HTCap, and HTInfo, and record whether it is 11n AP
1584 * (2) If peer is HT, but not WMM, call QosSetLegacyWMMParamWithHT()
1585 * (3) Check whether peer is Realtek AP (for Realtek proprietary aggregation mode).
1586 * Input:
1587 * PADAPTER Adapter
1589 * Output:
1590 * PRT_TCB BssDesc
1593 void HTGetValueFromBeaconOrProbeRsp(
1594 PADAPTER Adapter,
1595 POCTET_STRING pSRCmmpdu,
1596 PRT_WLAN_BSS bssDesc
1599 PMGNT_INFO pMgntInfo = &Adapter->MgntInfo;
1600 PRT_HIGH_THROUGHPUT pHTInfo = GET_HT_INFO(pMgntInfo);
1601 OCTET_STRING HTCapIE, HTInfoIE, HTRealtekAgg, mmpdu;
1602 OCTET_STRING BroadcomElement, CiscoElement;
1604 mmpdu.Octet = pSRCmmpdu->Octet;
1605 mmpdu.Length = pSRCmmpdu->Length;
1607 //2Note:
1608 // Mark for IOT testing using Linksys WRT350N, This AP does not contain WMM IE when
1609 // it is configured at pure-N mode.
1610 // if(bssDesc->BssQos.bdQoSMode & QOS_WMM)
1613 HTInitializeBssDesc (&bssDesc->BssHT);
1615 //2<1> Parse HTCap, and HTInfo
1616 // Get HT Capability IE: (1) Get IEEE Draft N IE or (2) Get EWC IE
1617 HTCapIE = PacketGetElement(mmpdu, EID_HTCapability, OUI_SUB_DONT_CARE, OUI_SUBTYPE_DONT_CARE);
1618 if(HTCapIE.Length == 0)
1620 HTCapIE = PacketGetElement(mmpdu, EID_Vendor, OUI_SUB_11N_EWC_HT_CAP, OUI_SUBTYPE_DONT_CARE);
1621 if(HTCapIE.Length != 0)
1622 bssDesc->BssHT.bdHTSpecVer= HT_SPEC_VER_EWC;
1624 if(HTCapIE.Length != 0)
1625 HTParsingHTCapElement(Adapter, HTCapIE, bssDesc);
1627 // Get HT Information IE: (1) Get IEEE Draft N IE or (2) Get EWC IE
1628 HTInfoIE = PacketGetElement(mmpdu, EID_HTInfo, OUI_SUB_DONT_CARE, OUI_SUBTYPE_DONT_CARE);
1629 if(HTInfoIE.Length == 0)
1631 HTInfoIE = PacketGetElement(mmpdu, EID_Vendor, OUI_SUB_11N_EWC_HT_INFO, OUI_SUBTYPE_DONT_CARE);
1632 if(HTInfoIE.Length != 0)
1633 bssDesc->BssHT.bdHTSpecVer = HT_SPEC_VER_EWC;
1635 if(HTInfoIE.Length != 0)
1636 HTParsingHTInfoElement(Adapter, HTInfoIE, bssDesc);
1638 //2<2>If peer is HT, but not WMM, call QosSetLegacyWMMParamWithHT()
1639 if(HTCapIE.Length != 0)
1641 bssDesc->BssHT.bdSupportHT = true;
1642 if(bssDesc->BssQos.bdQoSMode == QOS_DISABLE)
1643 QosSetLegacyWMMParamWithHT(Adapter, bssDesc);
1645 else
1647 bssDesc->BssHT.bdSupportHT = false;
1650 //2<3>Check whether the peer is Realtek AP/STA
1651 if(pHTInfo->bRegRT2RTAggregation)
1653 if(bssDesc->BssHT.bdSupportHT)
1655 HTRealtekAgg = PacketGetElement(mmpdu, EID_Vendor, OUI_SUB_REALTEK_AGG, OUI_SUBTYPE_DONT_CARE);
1656 if(HTRealtekAgg.Length >=5 )
1658 bssDesc->BssHT.bdRT2RTAggregation = true;
1660 if((HTRealtekAgg.Octet[4]==1) && (HTRealtekAgg.Octet[5] & 0x02))
1661 bssDesc->BssHT.bdRT2RTLongSlotTime = true;
1667 // 2008/01/25 MH Get Broadcom AP IE for manamgent frame CCK rate problem.
1668 // AP can not receive CCK managemtn from from 92E.
1671 // Initialize every new bss broadcom cap exist as false..
1672 bssDesc->bBroadcomCapExist= false;
1674 if(HTCapIE.Length != 0 || HTInfoIE.Length != 0)
1676 u4Byte Length = 0;
1678 FillOctetString(BroadcomElement, NULL, 0);
1680 BroadcomElement = PacketGetElement( mmpdu, EID_Vendor, OUI_SUB_BROADCOM_IE_1, OUI_SUBTYPE_DONT_CARE);
1681 Length += BroadcomElement.Length;
1682 BroadcomElement = PacketGetElement( mmpdu, EID_Vendor, OUI_SUB_BROADCOM_IE_2, OUI_SUBTYPE_DONT_CARE);
1683 Length += BroadcomElement.Length;
1684 BroadcomElement = PacketGetElement( mmpdu, EID_Vendor, OUI_SUB_BROADCOM_IE_3, OUI_SUBTYPE_DONT_CARE);
1685 Length += BroadcomElement.Length;
1687 if(Length > 0)
1688 bssDesc->bBroadcomCapExist = true;
1692 // For Cisco IOT issue
1693 CiscoElement = PacketGetElement( mmpdu, EID_Vendor, OUI_SUB_CISCO_IE, OUI_SUBTYPE_DONT_CARE);
1694 if(CiscoElement.Length != 0){ // 3: 0x00, 0x40, 0x96 ....
1695 bssDesc->bCiscoCapExist = true;
1696 }else{
1697 bssDesc->bCiscoCapExist = false;
1702 #endif
1703 /********************************************************************************************************************
1704 *function: initialize Bss HT structure(struct PBSS_HT)
1705 * input: struct ieee80211_device *ieee
1706 * struct ieee80211_network *pNetwork //usually current network we are live in
1707 * output: none
1708 * return: none
1709 * notice: This function should ONLY be called before association
1710 ********************************************************************************************************************/
1711 void HTResetSelfAndSavePeerSetting(struct ieee80211_device* ieee, struct ieee80211_network * pNetwork)
1713 PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
1714 // u16 nMaxAMSDUSize;
1715 // PHT_CAPABILITY_ELE pPeerHTCap = (PHT_CAPABILITY_ELE)pNetwork->bssht.bdHTCapBuf;
1716 // PHT_INFORMATION_ELE pPeerHTInfo = (PHT_INFORMATION_ELE)pNetwork->bssht.bdHTInfoBuf;
1717 // u8* pMcsFilter;
1718 u8 bIOTAction = 0;
1721 // Save Peer Setting before Association
1723 IEEE80211_DEBUG(IEEE80211_DL_HT, "==============>%s()\n", __FUNCTION__);
1724 /*unmark bEnableHT flag here is the same reason why unmarked in function ieee80211_softmac_new_net. WB 2008.09.10*/
1725 // if( pHTInfo->bEnableHT && pNetwork->bssht.bdSupportHT)
1726 if (pNetwork->bssht.bdSupportHT)
1728 pHTInfo->bCurrentHTSupport = true;
1729 pHTInfo->ePeerHTSpecVer = pNetwork->bssht.bdHTSpecVer;
1731 // Save HTCap and HTInfo information Element
1732 if(pNetwork->bssht.bdHTCapLen > 0 && pNetwork->bssht.bdHTCapLen <= sizeof(pHTInfo->PeerHTCapBuf))
1733 memcpy(pHTInfo->PeerHTCapBuf, pNetwork->bssht.bdHTCapBuf, pNetwork->bssht.bdHTCapLen);
1735 if(pNetwork->bssht.bdHTInfoLen > 0 && pNetwork->bssht.bdHTInfoLen <= sizeof(pHTInfo->PeerHTInfoBuf))
1736 memcpy(pHTInfo->PeerHTInfoBuf, pNetwork->bssht.bdHTInfoBuf, pNetwork->bssht.bdHTInfoLen);
1738 // Check whether RT to RT aggregation mode is enabled
1739 if(pHTInfo->bRegRT2RTAggregation)
1741 pHTInfo->bCurrentRT2RTAggregation = pNetwork->bssht.bdRT2RTAggregation;
1742 pHTInfo->bCurrentRT2RTLongSlotTime = pNetwork->bssht.bdRT2RTLongSlotTime;
1743 pHTInfo->RT2RT_HT_Mode = pNetwork->bssht.RT2RT_HT_Mode;
1745 else
1747 pHTInfo->bCurrentRT2RTAggregation = false;
1748 pHTInfo->bCurrentRT2RTLongSlotTime = false;
1749 pHTInfo->RT2RT_HT_Mode = (RT_HT_CAPBILITY)0;
1752 // Determine the IOT Peer Vendor.
1753 HTIOTPeerDetermine(ieee);
1755 // Decide IOT Action
1756 // Must be called after the parameter of pHTInfo->bCurrentRT2RTAggregation is decided
1757 pHTInfo->IOTAction = 0;
1758 bIOTAction = HTIOTActIsDisableMCS14(ieee, pNetwork->bssid);
1759 if(bIOTAction)
1760 pHTInfo->IOTAction |= HT_IOT_ACT_DISABLE_MCS14;
1762 bIOTAction = HTIOTActIsDisableMCS15(ieee);
1763 if(bIOTAction)
1764 pHTInfo->IOTAction |= HT_IOT_ACT_DISABLE_MCS15;
1766 bIOTAction = HTIOTActIsDisableMCSTwoSpatialStream(ieee);
1767 if(bIOTAction)
1768 pHTInfo->IOTAction |= HT_IOT_ACT_DISABLE_ALL_2SS;
1771 bIOTAction = HTIOTActIsDisableEDCATurbo(ieee, pNetwork->bssid);
1772 if(bIOTAction)
1773 pHTInfo->IOTAction |= HT_IOT_ACT_DISABLE_EDCA_TURBO;
1775 bIOTAction = HTIOTActIsMgntUseCCK6M(pNetwork);
1776 if(bIOTAction)
1777 pHTInfo->IOTAction |= HT_IOT_ACT_MGNT_USE_CCK_6M;
1779 bIOTAction = HTIOTActIsCCDFsync(pNetwork->bssid);
1780 if(bIOTAction)
1781 pHTInfo->IOTAction |= HT_IOT_ACT_CDD_FSYNC;
1783 bIOTAction = HTIOTActIsForcedCTS2Self(pNetwork);
1784 if(bIOTAction)
1785 pHTInfo->IOTAction |= HT_IOT_ACT_FORCED_CTS2SELF;
1787 //bIOTAction = HTIOTActIsForcedRTSCTS(ieee, pNetwork);
1788 //if(bIOTAction)
1789 // pHTInfo->IOTAction |= HT_IOT_ACT_FORCED_RTS;
1791 #if defined(RTL8192SU)
1792 bIOTAction = HTIOCActRejcectADDBARequest(pNetwork);
1793 if(bIOTAction)
1794 pHTInfo->IOTAction |= HT_IOT_ACT_REJECT_ADDBA_REQ;
1795 #endif
1797 bIOTAction = HTIOCActAllowPeerAggOnePacket(ieee, pNetwork);
1798 if(bIOTAction)
1799 pHTInfo->IOTAction |= HT_IOT_ACT_ALLOW_PEER_AGG_ONE_PKT;
1801 bIOTAction = HTIOTActIsEDCABiasRx(ieee, pNetwork);
1802 if(bIOTAction)
1803 pHTInfo->IOTAction |= HT_IOT_ACT_EDCA_BIAS_ON_RX;
1805 #if defined(RTL8192SU)
1806 bIOTAction = HTIOTActDisableShortGI(ieee, pNetwork);
1807 if(bIOTAction)
1808 pHTInfo->IOTAction |= HT_IOT_ACT_DISABLE_SHORT_GI;
1810 bIOTAction = HTIOTActDisableHighPower(ieee, pNetwork);
1811 if(bIOTAction)
1812 pHTInfo->IOTAction |= HT_IOT_ACT_DISABLE_HIGH_POWER;
1813 #endif
1815 bIOTAction = HTIOTActIsForcedAMSDU8K(ieee, pNetwork);
1816 if(bIOTAction)
1817 pHTInfo->IOTAction |= HT_IOT_ACT_TX_USE_AMSDU_8K;
1819 #if defined(RTL8192SU)
1820 bIOTAction = HTIOTActIsTxNoAggregation(ieee, pNetwork);
1821 if(bIOTAction)
1822 pHTInfo->IOTAction |= HT_IOT_ACT_TX_NO_AGGREGATION;
1824 bIOTAction = HTIOTActIsDisableTx40MHz(ieee, pNetwork);
1825 if(bIOTAction)
1826 pHTInfo->IOTAction |= HT_IOT_ACT_DISABLE_TX_40_MHZ;
1828 bIOTAction = HTIOTActIsDisableTx2SS(ieee, pNetwork);
1829 if(bIOTAction)
1830 pHTInfo->IOTAction |= HT_IOT_ACT_DISABLE_TX_2SS;
1831 #endif
1832 //must after HT_IOT_ACT_TX_NO_AGGREGATION
1833 bIOTAction = HTIOTActIsForcedRTSCTS(ieee, pNetwork);
1834 if(bIOTAction)
1835 pHTInfo->IOTAction |= HT_IOT_ACT_FORCED_RTS;
1837 printk("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!IOTAction = %8.8x\n", pHTInfo->IOTAction);
1839 else
1841 pHTInfo->bCurrentHTSupport = false;
1842 pHTInfo->bCurrentRT2RTAggregation = false;
1843 pHTInfo->bCurrentRT2RTLongSlotTime = false;
1844 pHTInfo->RT2RT_HT_Mode = (RT_HT_CAPBILITY)0;
1846 pHTInfo->IOTAction = 0;
1847 pHTInfo->IOTRaFunc = 0;
1852 void HTUpdateSelfAndPeerSetting(struct ieee80211_device* ieee, struct ieee80211_network * pNetwork)
1854 PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
1855 // PHT_CAPABILITY_ELE pPeerHTCap = (PHT_CAPABILITY_ELE)pNetwork->bssht.bdHTCapBuf;
1856 PHT_INFORMATION_ELE pPeerHTInfo = (PHT_INFORMATION_ELE)pNetwork->bssht.bdHTInfoBuf;
1858 if(pHTInfo->bCurrentHTSupport)
1861 // Config current operation mode.
1863 if(pNetwork->bssht.bdHTInfoLen != 0)
1864 pHTInfo->CurrentOpMode = pPeerHTInfo->OptMode;
1867 // <TODO: Config according to OBSS non-HT STA present!!>
1872 void HTUseDefaultSetting(struct ieee80211_device* ieee)
1874 PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
1875 // u8 regBwOpMode;
1877 if(pHTInfo->bEnableHT)
1879 pHTInfo->bCurrentHTSupport = true;
1881 pHTInfo->bCurSuppCCK = pHTInfo->bRegSuppCCK;
1883 pHTInfo->bCurBW40MHz = pHTInfo->bRegBW40MHz;
1885 pHTInfo->bCurShortGI20MHz= pHTInfo->bRegShortGI20MHz;
1887 pHTInfo->bCurShortGI40MHz= pHTInfo->bRegShortGI40MHz;
1889 pHTInfo->bCurrent_AMSDU_Support = pHTInfo->bAMSDU_Support;
1891 pHTInfo->nCurrent_AMSDU_MaxSize = pHTInfo->nAMSDU_MaxSize;
1893 pHTInfo->bCurrentAMPDUEnable = pHTInfo->bAMPDUEnable;
1895 pHTInfo->CurrentAMPDUFactor = pHTInfo->AMPDU_Factor;
1897 pHTInfo->CurrentMPDUDensity = pHTInfo->CurrentMPDUDensity;
1899 // Set BWOpMode register
1901 //update RATR index0
1902 HTFilterMCSRate(ieee, ieee->Regdot11HTOperationalRateSet, ieee->dot11HTOperationalRateSet);
1903 //function below is not implemented at all. WB
1904 #ifdef TODO
1905 Adapter->HalFunc.InitHalRATRTableHandler( Adapter, &pMgntInfo->dot11OperationalRateSet, pMgntInfo->dot11HTOperationalRateSet);
1906 #endif
1907 ieee->HTHighestOperaRate = HTGetHighestMCSRate(ieee, ieee->dot11HTOperationalRateSet, MCS_FILTER_ALL);
1908 ieee->HTCurrentOperaRate = ieee->HTHighestOperaRate;
1911 else
1913 pHTInfo->bCurrentHTSupport = false;
1915 return;
1917 /********************************************************************************************************************
1918 *function: check whether HT control field exists
1919 * input: struct ieee80211_device *ieee
1920 * u8* pFrame //coming skb->data
1921 * output: none
1922 * return: return true if HT control field exists(false otherwise)
1923 * notice:
1924 ********************************************************************************************************************/
1925 u8 HTCCheck(struct ieee80211_device* ieee, u8* pFrame)
1927 if(ieee->pHTInfo->bCurrentHTSupport)
1929 if( (IsQoSDataFrame(pFrame) && Frame_Order(pFrame)) == 1)
1931 IEEE80211_DEBUG(IEEE80211_DL_HT, "HT CONTROL FILED EXIST!!\n");
1932 return true;
1935 return false;
1939 // This function set bandwidth mode in protocol layer.
1941 void HTSetConnectBwMode(struct ieee80211_device* ieee, HT_CHANNEL_WIDTH Bandwidth, HT_EXTCHNL_OFFSET Offset)
1943 PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
1944 // u32 flags = 0;
1946 if(pHTInfo->bRegBW40MHz == false)
1947 return;
1951 // To reduce dummy operation
1952 // if((pHTInfo->bCurBW40MHz==false && Bandwidth==HT_CHANNEL_WIDTH_20) ||
1953 // (pHTInfo->bCurBW40MHz==true && Bandwidth==HT_CHANNEL_WIDTH_20_40 && Offset==pHTInfo->CurSTAExtChnlOffset))
1954 // return;
1956 // spin_lock_irqsave(&(ieee->bw_spinlock), flags);
1957 if(pHTInfo->bSwBwInProgress) {
1958 // spin_unlock_irqrestore(&(ieee->bw_spinlock), flags);
1959 return;
1961 //if in half N mode, set to 20M bandwidth please 09.08.2008 WB.
1962 if(Bandwidth==HT_CHANNEL_WIDTH_20_40 && (!ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev)))
1964 // Handle Illegal extention channel offset!!
1965 if(ieee->current_network.channel<2 && Offset==HT_EXTCHNL_OFFSET_LOWER)
1966 Offset = HT_EXTCHNL_OFFSET_NO_EXT;
1967 if(Offset==HT_EXTCHNL_OFFSET_UPPER || Offset==HT_EXTCHNL_OFFSET_LOWER) {
1968 pHTInfo->bCurBW40MHz = true;
1969 pHTInfo->CurSTAExtChnlOffset = Offset;
1970 } else {
1971 pHTInfo->bCurBW40MHz = false;
1972 pHTInfo->CurSTAExtChnlOffset = HT_EXTCHNL_OFFSET_NO_EXT;
1974 } else {
1975 pHTInfo->bCurBW40MHz = false;
1976 pHTInfo->CurSTAExtChnlOffset = HT_EXTCHNL_OFFSET_NO_EXT;
1979 pHTInfo->bSwBwInProgress = true;
1981 // TODO: 2007.7.13 by Emily Wait 2000ms in order to garantee that switching
1982 // bandwidth is executed after scan is finished. It is a temporal solution
1983 // because software should ganrantee the last operation of switching bandwidth
1984 // is executed properlly.
1985 HTSetConnectBwModeCallback(ieee);
1987 // spin_unlock_irqrestore(&(ieee->bw_spinlock), flags);
1990 void HTSetConnectBwModeCallback(struct ieee80211_device* ieee)
1992 PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
1994 IEEE80211_DEBUG(IEEE80211_DL_HT, "======>%s()\n", __FUNCTION__);
1995 if(pHTInfo->bCurBW40MHz)
1997 if(pHTInfo->CurSTAExtChnlOffset==HT_EXTCHNL_OFFSET_UPPER)
1998 ieee->set_chan(ieee->dev, ieee->current_network.channel+2);
1999 else if(pHTInfo->CurSTAExtChnlOffset==HT_EXTCHNL_OFFSET_LOWER)
2000 ieee->set_chan(ieee->dev, ieee->current_network.channel-2);
2001 else
2002 ieee->set_chan(ieee->dev, ieee->current_network.channel);
2004 ieee->SetBWModeHandler(ieee->dev, HT_CHANNEL_WIDTH_20_40, pHTInfo->CurSTAExtChnlOffset);
2005 } else {
2006 ieee->set_chan(ieee->dev, ieee->current_network.channel);
2007 ieee->SetBWModeHandler(ieee->dev, HT_CHANNEL_WIDTH_20, HT_EXTCHNL_OFFSET_NO_EXT);
2010 pHTInfo->bSwBwInProgress = false;
2013 EXPORT_SYMBOL(HTUpdateSelfAndPeerSetting);