1
2
3#include "ieee80211.h"
4#include "rtl819x_HT.h"
5u8 MCS_FILTER_ALL[16] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
6
7u8 MCS_FILTER_1SS[16] = {0xff, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
8
9u16 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},
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} },
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},
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} }
30 };
31
32static const u8 UNKNOWN_BORADCOM[3] = {0x00, 0x14, 0xbf};
33static const u8 LINKSYSWRT330_LINKSYSWRT300_BROADCOM[3] = {0x00, 0x1a, 0x70};
34static const u8 LINKSYSWRT350_LINKSYSWRT150_BROADCOM[3] = {0x00, 0x1d, 0x7e};
35
36static const u8 BELKINF5D8233V1_RALINK[3] = {0x00, 0x17, 0x3f};
37static const u8 BELKINF5D82334V3_RALINK[3] = {0x00, 0x1c, 0xdf};
38static const u8 PCI_RALINK[3] = {0x00, 0x90, 0xcc};
39static const u8 EDIMAX_RALINK[3] = {0x00, 0x0e, 0x2e};
40static const u8 AIRLINK_RALINK[3] = {0x00, 0x18, 0x02};
41static const u8 DLINK_ATHEROS[3] = {0x00, 0x1c, 0xf0};
42static const u8 CISCO_BROADCOM[3] = {0x00, 0x17, 0x94};
43static const u8 LINKSYS_MARVELL_4400N[3] = {0x00, 0x14, 0xa4};
44
45
46
47
48
49
50
51
52
53
54
55void HTUpdateDefaultSetting(struct ieee80211_device* ieee)
56{
57 PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
58
59
60 pHTInfo->bRegShortGI20MHz= 1;
61 pHTInfo->bRegShortGI40MHz= 1;
62
63
64 pHTInfo->bRegBW40MHz = 1;
65
66
67 if(pHTInfo->bRegBW40MHz)
68 pHTInfo->bRegSuppCCK = 1;
69 else
70 pHTInfo->bRegSuppCCK = true;
71
72
73 pHTInfo->nAMSDU_MaxSize = 7935UL;
74 pHTInfo->bAMSDU_Support = 0;
75
76
77 pHTInfo->bAMPDUEnable = 1;
78 pHTInfo->AMPDU_Factor = 2;
79 pHTInfo->MPDU_Density = 0;
80
81
82 pHTInfo->SelfMimoPs = 3;
83 if(pHTInfo->SelfMimoPs == 2)
84 pHTInfo->SelfMimoPs = 3;
85
86 ieee->bTxDisableRateFallBack = 0;
87 ieee->bTxUseDriverAssingedRate = 0;
88
89#ifdef TO_DO_LIST
90
91 pMgntInfo->bTxEnableFwCalcDur = (BOOLEAN)pNdisCommon->bRegTxEnableFwCalcDur;
92#endif
93
94
95 pHTInfo->bRegRT2RTAggregation = 1;
96
97
98 pHTInfo->bRegRxReorderEnable = 1;
99 pHTInfo->RxReorderWinSize = 64;
100 pHTInfo->RxReorderPendingTime = 30;
101
102#ifdef USB_TX_DRIVER_AGGREGATION_ENABLE
103 pHTInfo->UsbTxAggrNum = 4;
104#endif
105#ifdef USB_RX_AGGREGATION_SUPPORT
106 pHTInfo->UsbRxFwAggrEn = 1;
107 pHTInfo->UsbRxFwAggrPageNum = 24;
108 pHTInfo->UsbRxFwAggrPacketNum = 8;
109 pHTInfo->UsbRxFwAggrTimeout = 16;
110#endif
111
112
113}
114
115
116
117
118
119
120
121
122void HTDebugHTCapability(u8* CapIE, u8* TitleString )
123{
124
125 static u8 EWC11NHTCap[] = {0x00, 0x90, 0x4c, 0x33};
126 PHT_CAPABILITY_ELE pCapELE;
127
128 if(!memcmp(CapIE, EWC11NHTCap, sizeof(EWC11NHTCap)))
129 {
130
131 IEEE80211_DEBUG(IEEE80211_DL_HT, "EWC IE in %s()\n", __FUNCTION__);
132 pCapELE = (PHT_CAPABILITY_ELE)(&CapIE[4]);
133 }else
134 pCapELE = (PHT_CAPABILITY_ELE)(&CapIE[0]);
135
136 IEEE80211_DEBUG(IEEE80211_DL_HT, "<Log HT Capability>. Called by %s\n", TitleString );
137
138 IEEE80211_DEBUG(IEEE80211_DL_HT, "\tSupported Channel Width = %s\n", (pCapELE->ChlWidth)?"20MHz": "20/40MHz");
139 IEEE80211_DEBUG(IEEE80211_DL_HT, "\tSupport Short GI for 20M = %s\n", (pCapELE->ShortGI20Mhz)?"YES": "NO");
140 IEEE80211_DEBUG(IEEE80211_DL_HT, "\tSupport Short GI for 40M = %s\n", (pCapELE->ShortGI40Mhz)?"YES": "NO");
141 IEEE80211_DEBUG(IEEE80211_DL_HT, "\tSupport TX STBC = %s\n", (pCapELE->TxSTBC)?"YES": "NO");
142 IEEE80211_DEBUG(IEEE80211_DL_HT, "\tMax AMSDU Size = %s\n", (pCapELE->MaxAMSDUSize)?"3839": "7935");
143 IEEE80211_DEBUG(IEEE80211_DL_HT, "\tSupport CCK in 20/40 mode = %s\n", (pCapELE->DssCCk)?"YES": "NO");
144 IEEE80211_DEBUG(IEEE80211_DL_HT, "\tMax AMPDU Factor = %d\n", pCapELE->MaxRxAMPDUFactor);
145 IEEE80211_DEBUG(IEEE80211_DL_HT, "\tMPDU Density = %d\n", pCapELE->MPDUDensity);
146 IEEE80211_DEBUG(IEEE80211_DL_HT, "\tMCS Rate Set = [%x][%x][%x][%x][%x]\n", pCapELE->MCS[0],\
147 pCapELE->MCS[1], pCapELE->MCS[2], pCapELE->MCS[3], pCapELE->MCS[4]);
148}
149
150
151
152
153
154
155
156
157void HTDebugHTInfo(u8* InfoIE, u8* TitleString)
158{
159
160 static u8 EWC11NHTInfo[] = {0x00, 0x90, 0x4c, 0x34};
161 PHT_INFORMATION_ELE pHTInfoEle;
162
163 if(!memcmp(InfoIE, EWC11NHTInfo, sizeof(EWC11NHTInfo)))
164 {
165
166 IEEE80211_DEBUG(IEEE80211_DL_HT, "EWC IE in %s()\n", __FUNCTION__);
167 pHTInfoEle = (PHT_INFORMATION_ELE)(&InfoIE[4]);
168 }else
169 pHTInfoEle = (PHT_INFORMATION_ELE)(&InfoIE[0]);
170
171
172 IEEE80211_DEBUG(IEEE80211_DL_HT, "<Log HT Information Element>. Called by %s\n", TitleString);
173
174 IEEE80211_DEBUG(IEEE80211_DL_HT, "\tPrimary channel = %d\n", pHTInfoEle->ControlChl);
175 IEEE80211_DEBUG(IEEE80211_DL_HT, "\tSenondary channel =");
176 switch(pHTInfoEle->ExtChlOffset)
177 {
178 case 0:
179 IEEE80211_DEBUG(IEEE80211_DL_HT, "Not Present\n");
180 break;
181 case 1:
182 IEEE80211_DEBUG(IEEE80211_DL_HT, "Upper channel\n");
183 break;
184 case 2:
185 IEEE80211_DEBUG(IEEE80211_DL_HT, "Reserved. Eooro!!!\n");
186 break;
187 case 3:
188 IEEE80211_DEBUG(IEEE80211_DL_HT, "Lower Channel\n");
189 break;
190 }
191 IEEE80211_DEBUG(IEEE80211_DL_HT, "\tRecommended channel width = %s\n", (pHTInfoEle->RecommemdedTxWidth)?"20Mhz": "40Mhz");
192
193 IEEE80211_DEBUG(IEEE80211_DL_HT, "\tOperation mode for protection = ");
194 switch(pHTInfoEle->OptMode)
195 {
196 case 0:
197 IEEE80211_DEBUG(IEEE80211_DL_HT, "No Protection\n");
198 break;
199 case 1:
200 IEEE80211_DEBUG(IEEE80211_DL_HT, "HT non-member protection mode\n");
201 break;
202 case 2:
203 IEEE80211_DEBUG(IEEE80211_DL_HT, "Suggest to open protection\n");
204 break;
205 case 3:
206 IEEE80211_DEBUG(IEEE80211_DL_HT, "HT mixed mode\n");
207 break;
208 }
209
210 IEEE80211_DEBUG(IEEE80211_DL_HT, "\tBasic MCS Rate Set = [%x][%x][%x][%x][%x]\n", pHTInfoEle->BasicMSC[0],\
211 pHTInfoEle->BasicMSC[1], pHTInfoEle->BasicMSC[2], pHTInfoEle->BasicMSC[3], pHTInfoEle->BasicMSC[4]);
212}
213
214
215
216
217bool IsHTHalfNmode40Bandwidth(struct ieee80211_device* ieee)
218{
219 bool retValue = false;
220 PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
221
222 if(pHTInfo->bCurrentHTSupport == false )
223 retValue = false;
224 else if(pHTInfo->bRegBW40MHz == false)
225 retValue = false;
226 else if (!ieee->GetHalfNmodeSupportByAPsHandler(ieee))
227 retValue = false;
228 else if(((PHT_CAPABILITY_ELE)(pHTInfo->PeerHTCapBuf))->ChlWidth)
229 retValue = true;
230 else
231 retValue = false;
232
233 return retValue;
234}
235
236bool IsHTHalfNmodeSGI(struct ieee80211_device* ieee, bool is40MHz)
237{
238 bool retValue = false;
239 PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
240
241 if(pHTInfo->bCurrentHTSupport == false )
242 retValue = false;
243 else if (!ieee->GetHalfNmodeSupportByAPsHandler(ieee))
244 retValue = false;
245 else if(is40MHz)
246 {
247 if(((PHT_CAPABILITY_ELE)(pHTInfo->PeerHTCapBuf))->ShortGI40Mhz)
248 retValue = true;
249 else
250 retValue = false;
251 }
252 else
253 {
254 if(((PHT_CAPABILITY_ELE)(pHTInfo->PeerHTCapBuf))->ShortGI20Mhz)
255 retValue = true;
256 else
257 retValue = false;
258 }
259
260 return retValue;
261}
262
263u16 HTHalfMcsToDataRate(struct ieee80211_device* ieee, u8 nMcsRate)
264{
265
266 u8 is40MHz;
267 u8 isShortGI;
268
269 is40MHz = (IsHTHalfNmode40Bandwidth(ieee))?1:0;
270 isShortGI = (IsHTHalfNmodeSGI(ieee, is40MHz))? 1:0;
271
272 return MCS_DATA_RATE[is40MHz][isShortGI][(nMcsRate&0x7f)];
273}
274
275
276u16 HTMcsToDataRate( struct ieee80211_device* ieee, u8 nMcsRate)
277{
278 PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
279
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)];
285}
286
287
288
289
290
291
292
293
294
295u16 TxCountToDataRate( struct ieee80211_device* ieee, u8 nDataRate)
296{
297
298 u16 CCKOFDMRate[12] = {0x02 , 0x04 , 0x0b , 0x16 , 0x0c , 0x12 , 0x18 , 0x24 , 0x30 , 0x48 , 0x60 , 0x6c};
299 u8 is40MHz = 0;
300 u8 isShortGI = 0;
301
302 if(nDataRate < 12)
303 {
304 return CCKOFDMRate[nDataRate];
305 }
306 else
307 {
308 if (nDataRate >= 0x10 && nDataRate <= 0x1f)
309 {
310 is40MHz = 0;
311 isShortGI = 0;
312
313
314 }
315 else if(nDataRate >=0x20 && nDataRate <= 0x2f )
316 {
317 is40MHz = 1;
318 isShortGI = 0;
319
320
321 }
322 else if(nDataRate >= 0x30 && nDataRate <= 0x3f )
323 {
324 is40MHz = 0;
325 isShortGI = 1;
326
327
328 }
329 else if(nDataRate >= 0x40 && nDataRate <= 0x4f )
330 {
331 is40MHz = 1;
332 isShortGI = 1;
333
334
335 }
336 return MCS_DATA_RATE[is40MHz][isShortGI][nDataRate&0xf];
337 }
338}
339
340
341
342bool IsHTHalfNmodeAPs(struct ieee80211_device* ieee)
343{
344 bool retValue = false;
345 struct ieee80211_network* net = &ieee->current_network;
346#if 0
347 if(ieee->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
362 (net->broadcom_cap_exist))
363 retValue = true;
364 else if(net->bssht.bdRT2RTAggregation)
365 retValue = true;
366 else
367 retValue = false;
368
369 return retValue;
370}
371
372
373
374
375
376
377
378
379void HTIOTPeerDetermine(struct ieee80211_device* ieee)
380{
381 PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
382 struct ieee80211_network* net = &ieee->current_network;
383 if(net->bssht.bdRT2RTAggregation)
384 pHTInfo->IOTPeer = HT_IOT_PEER_REALTEK;
385 else if(net->broadcom_cap_exist){
386 pHTInfo->IOTPeer = HT_IOT_PEER_BROADCOM;
387 }
388 else if((memcmp(net->bssid, UNKNOWN_BORADCOM, 3)==0) ||
389 (memcmp(net->bssid, LINKSYSWRT330_LINKSYSWRT300_BROADCOM, 3)==0)||
390 (memcmp(net->bssid, LINKSYSWRT350_LINKSYSWRT150_BROADCOM, 3)==0)){
391
392 pHTInfo->IOTPeer = HT_IOT_PEER_BROADCOM;
393 }
394 else if((memcmp(net->bssid, BELKINF5D8233V1_RALINK, 3)==0) ||
395 (memcmp(net->bssid, BELKINF5D82334V3_RALINK, 3)==0) ||
396 (memcmp(net->bssid, PCI_RALINK, 3)==0) ||
397 (memcmp(net->bssid, EDIMAX_RALINK, 3)==0) ||
398 (memcmp(net->bssid, AIRLINK_RALINK, 3)==0) ||
399 net->ralink_cap_exist)
400 pHTInfo->IOTPeer = HT_IOT_PEER_RALINK;
401 else if((net->atheros_cap_exist )|| (memcmp(net->bssid, DLINK_ATHEROS, 3) == 0))
402 pHTInfo->IOTPeer = HT_IOT_PEER_ATHEROS;
403 else if(memcmp(net->bssid, CISCO_BROADCOM, 3)==0)
404 pHTInfo->IOTPeer = HT_IOT_PEER_CISCO;
405 else if ((memcmp(net->bssid, LINKSYS_MARVELL_4400N, 3) == 0) ||
406 net->marvell_cap_exist){
407 pHTInfo->IOTPeer = HT_IOT_PEER_MARVELL;
408 }
409 else
410 pHTInfo->IOTPeer = HT_IOT_PEER_UNKNOWN;
411
412 IEEE80211_DEBUG(IEEE80211_DL_IOT, "Joseph debug!! IOTPEER: %x\n", pHTInfo->IOTPeer);
413}
414
415
416
417
418
419
420
421
422u8 HTIOTActIsDisableMCS14(struct ieee80211_device* ieee, u8* PeerMacAddr)
423{
424 u8 ret = 0;
425#if 0
426
427#if (HAL_CODE_BASE==RTL8192 && DEV_BUS_TYPE==USB_INTERFACE)
428 if((memcmp(PeerMacAddr, UNKNOWN_BORADCOM, 3)==0) ||
429 (memcmp(PeerMacAddr, LINKSYSWRT330_LINKSYSWRT300_BROADCOM, 3)==0)
430 )
431 {
432 ret = 1;
433 }
434
435
436 if(pHTInfo->bCurrentRT2RTAggregation)
437 {
438
439 ret = 1;
440 }
441#endif
442#endif
443 return ret;
444 }
445
446u8 HTIOTActIsForcedCTS2Self(struct ieee80211_device *ieee, struct ieee80211_network *network)
447{
448 u8 retValue = 0;
449
450 if(ieee->pHTInfo->IOTPeer == HT_IOT_PEER_MARVELL)
451 {
452 retValue = 1;
453 }
454
455 return retValue;
456}
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471bool HTIOTActIsDisableMCS15(struct ieee80211_device* ieee)
472{
473 bool retValue = false;
474
475#ifdef TODO
476
477#if (HAL_CODE_BASE==RTL8192)
478
479#if (DEV_BUS_TYPE == USB_INTERFACE)
480
481 retValue = true;
482#elif (DEV_BUS_TYPE == PCI_INTERFACE)
483
484
485
486
487 retValue = false;
488#endif
489#endif
490#endif
491
492
493 return retValue;
494}
495
496
497
498
499
500
501
502
503
504
505
506
507
508bool HTIOTActIsDisableMCSTwoSpatialStream(struct ieee80211_device* ieee, u8 *PeerMacAddr)
509{
510 bool retValue = false;
511
512#ifdef TODO
513
514
515
516
517 if(IS_UNDER_11N_AES_MODE(Adapter))
518 {
519 if((PlatformCompareMemory(PeerMacAddr, BELKINF5D8233V1_RALINK, 3)==0) ||
520 (PlatformCompareMemory(PeerMacAddr, PCI_RALINK, 3)==0) ||
521 (PlatformCompareMemory(PeerMacAddr, EDIMAX_RALINK, 3)==0))
522 {
523
524 retValue = false;
525 }
526 }
527
528
529#endif
530 return retValue;
531}
532
533
534
535
536
537
538
539
540u8 HTIOTActIsDisableEDCATurbo(struct ieee80211_device* ieee, u8* PeerMacAddr)
541{
542 u8 retValue = false;
543
544
545 return retValue;
546#if 0
547 if((memcmp(PeerMacAddr, UNKNOWN_BORADCOM, 3)==0)||
548 (memcmp(PeerMacAddr, LINKSYSWRT330_LINKSYSWRT300_BROADCOM, 3)==0)||
549 (memcmp(PeerMacAddr, LINKSYSWRT350_LINKSYSWRT150_BROADCOM, 3)==0)||
550 (memcmp(PeerMacAddr, NETGEAR834Bv2_BROADCOM, 3)==0))
551
552 {
553 retValue = 1;
554 }
555
556 return retValue;
557#endif
558}
559
560
561
562
563
564
565
566u8 HTIOTActIsMgntUseCCK6M(struct ieee80211_network *network)
567{
568 u8 retValue = 0;
569
570
571
572
573 if(network->broadcom_cap_exist)
574 {
575 retValue = 1;
576 }
577
578 return retValue;
579}
580
581u8 HTIOTActIsCCDFsync(u8* PeerMacAddr)
582{
583 u8 retValue = 0;
584 if( (memcmp(PeerMacAddr, UNKNOWN_BORADCOM, 3)==0) ||
585 (memcmp(PeerMacAddr, LINKSYSWRT330_LINKSYSWRT300_BROADCOM, 3)==0) ||
586 (memcmp(PeerMacAddr, LINKSYSWRT350_LINKSYSWRT150_BROADCOM, 3) ==0))
587 {
588 retValue = 1;
589 }
590
591 return retValue;
592}
593
594
595
596
597bool
598HTIOTActIsNullDataPowerSaving(struct ieee80211_device* ieee,struct ieee80211_network *network)
599{
600 bool retValue = false;
601
602 PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
603 {
604 if(pHTInfo->IOTPeer == HT_IOT_PEER_BROADCOM)
605 return true;
606
607 }
608 return retValue;
609}
610
611void HTResetIOTSetting(
612 PRT_HIGH_THROUGHPUT pHTInfo
613)
614{
615 pHTInfo->IOTAction = 0;
616 pHTInfo->IOTPeer = HT_IOT_PEER_UNKNOWN;
617}
618
619
620
621
622
623
624
625
626
627
628
629
630void HTConstructCapabilityElement(struct ieee80211_device* ieee, u8* posHTCap, u8* len, u8 IsEncrypt)
631{
632 PRT_HIGH_THROUGHPUT pHT = ieee->pHTInfo;
633 PHT_CAPABILITY_ELE pCapELE = NULL;
634
635
636 if ((posHTCap == NULL) || (pHT == NULL))
637 {
638 IEEE80211_DEBUG(IEEE80211_DL_ERR, "posHTCap or pHTInfo can't be null in HTConstructCapabilityElement()\n");
639 return;
640 }
641 memset(posHTCap, 0, *len);
642 if(pHT->ePeerHTSpecVer == HT_SPEC_VER_EWC)
643 {
644 u8 EWC11NHTCap[] = {0x00, 0x90, 0x4c, 0x33};
645 memcpy(posHTCap, EWC11NHTCap, sizeof(EWC11NHTCap));
646 pCapELE = (PHT_CAPABILITY_ELE)&(posHTCap[4]);
647 }else
648 {
649 pCapELE = (PHT_CAPABILITY_ELE)posHTCap;
650 }
651
652
653
654 pCapELE->AdvCoding = 0;
655 if (ieee->GetHalfNmodeSupportByAPsHandler(ieee))
656 {
657 pCapELE->ChlWidth = 0;
658 }
659 else
660 {
661 pCapELE->ChlWidth = (pHT->bRegBW40MHz?1:0);
662 }
663
664
665 pCapELE->MimoPwrSave = pHT->SelfMimoPs;
666 pCapELE->GreenField = 0;
667 pCapELE->ShortGI20Mhz = 1;
668 pCapELE->ShortGI40Mhz = 1;
669
670
671 pCapELE->TxSTBC = 1;
672 pCapELE->RxSTBC = 0;
673 pCapELE->DelayBA = 0;
674 pCapELE->MaxAMSDUSize = (MAX_RECEIVE_BUFFER_SIZE>=7935)?1:0;
675 pCapELE->DssCCk = ((pHT->bRegBW40MHz)?(pHT->bRegSuppCCK?1:0):0);
676 pCapELE->PSMP = 0;
677 pCapELE->LSigTxopProtect = 0;
678
679
680
681
682 IEEE80211_DEBUG(IEEE80211_DL_HT, "TX HT cap/info ele BW=%d MaxAMSDUSize:%d DssCCk:%d\n", pCapELE->ChlWidth, pCapELE->MaxAMSDUSize, pCapELE->DssCCk);
683
684 if( IsEncrypt)
685 {
686 pCapELE->MPDUDensity = 7;
687 pCapELE->MaxRxAMPDUFactor = 2;
688 }
689 else
690 {
691 pCapELE->MaxRxAMPDUFactor = 3;
692 pCapELE->MPDUDensity = 0;
693 }
694
695
696 memcpy(pCapELE->MCS, ieee->Regdot11HTOperationalRateSet, 16);
697 if(pHT->IOTAction & HT_IOT_ACT_DISABLE_MCS15)
698 pCapELE->MCS[1] &= 0x7f;
699
700 if(pHT->IOTAction & HT_IOT_ACT_DISABLE_MCS14)
701 pCapELE->MCS[1] &= 0xbf;
702
703 if(pHT->IOTAction & HT_IOT_ACT_DISABLE_ALL_2SS)
704 pCapELE->MCS[1] &= 0x00;
705
706
707
708 if (ieee->GetHalfNmodeSupportByAPsHandler(ieee))
709 {
710 int i;
711 for(i = 1; i< 16; i++)
712 pCapELE->MCS[i] = 0;
713 }
714
715
716 memset(&pCapELE->ExtHTCapInfo, 0, 2);
717
718
719
720 memset(pCapELE->TxBFCap, 0, 4);
721
722
723 pCapELE->ASCap = 0;
724
725 if(pHT->ePeerHTSpecVer == HT_SPEC_VER_EWC)
726 *len = 30 + 2;
727 else
728 *len = 26 + 2;
729}
730
731
732
733
734
735
736
737
738
739
740void HTConstructInfoElement(struct ieee80211_device* ieee, u8* posHTInfo, u8* len, u8 IsEncrypt)
741{
742 PRT_HIGH_THROUGHPUT pHT = ieee->pHTInfo;
743 PHT_INFORMATION_ELE pHTInfoEle = (PHT_INFORMATION_ELE)posHTInfo;
744 if ((posHTInfo == NULL) || (pHTInfoEle == NULL))
745 {
746 IEEE80211_DEBUG(IEEE80211_DL_ERR, "posHTInfo or pHTInfoEle can't be null in HTConstructInfoElement()\n");
747 return;
748 }
749
750 memset(posHTInfo, 0, *len);
751 if ( (ieee->iw_mode == IW_MODE_ADHOC) || (ieee->iw_mode == IW_MODE_MASTER))
752 {
753 pHTInfoEle->ControlChl = ieee->current_network.channel;
754 pHTInfoEle->ExtChlOffset = ((pHT->bRegBW40MHz == false)?HT_EXTCHNL_OFFSET_NO_EXT:
755 (ieee->current_network.channel<=6)?
756 HT_EXTCHNL_OFFSET_UPPER:HT_EXTCHNL_OFFSET_LOWER);
757 pHTInfoEle->RecommemdedTxWidth = pHT->bRegBW40MHz;
758 pHTInfoEle->RIFS = 0;
759 pHTInfoEle->PSMPAccessOnly = 0;
760 pHTInfoEle->SrvIntGranularity = 0;
761 pHTInfoEle->OptMode = pHT->CurrentOpMode;
762 pHTInfoEle->NonGFDevPresent = 0;
763 pHTInfoEle->DualBeacon = 0;
764 pHTInfoEle->SecondaryBeacon = 0;
765 pHTInfoEle->LSigTxopProtectFull = 0;
766 pHTInfoEle->PcoActive = 0;
767 pHTInfoEle->PcoPhase = 0;
768
769 memset(pHTInfoEle->BasicMSC, 0, 16);
770
771
772 *len = 22 + 2;
773
774 }
775 else
776 {
777
778 *len = 0;
779 }
780}
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809void HTConstructRT2RTAggElement(struct ieee80211_device* ieee, u8* posRT2RTAgg, u8* len)
810{
811 if (posRT2RTAgg == NULL) {
812 IEEE80211_DEBUG(IEEE80211_DL_ERR, "posRT2RTAgg can't be null in HTConstructRT2RTAggElement()\n");
813 return;
814 }
815 memset(posRT2RTAgg, 0, *len);
816 *posRT2RTAgg++ = 0x00;
817 *posRT2RTAgg++ = 0xe0;
818 *posRT2RTAgg++ = 0x4c;
819 *posRT2RTAgg++ = 0x02;
820 *posRT2RTAgg++ = 0x01;
821 *posRT2RTAgg = 0x10;
822
823 if(ieee->bSupportRemoteWakeUp) {
824 *posRT2RTAgg |= 0x08;
825 }
826
827 *len = 6 + 2;
828 return;
829#ifdef TODO
830#if(HAL_CODE_BASE == RTL8192 && DEV_BUS_TYPE == USB_INTERFACE)
831
832
833
834
835
836
837
838
839
840
841
842
843#else
844
845#endif
846
847 posRT2RTAgg->Length = 6;
848#endif
849
850
851
852
853}
854
855
856
857
858
859
860
861
862
863u8 HT_PickMCSRate(struct ieee80211_device* ieee, u8* pOperateMCS)
864{
865 u8 i;
866 if (pOperateMCS == NULL)
867 {
868 IEEE80211_DEBUG(IEEE80211_DL_ERR, "pOperateMCS can't be null in HT_PickMCSRate()\n");
869 return false;
870 }
871
872 switch(ieee->mode)
873 {
874 case IEEE_A:
875 case IEEE_B:
876 case IEEE_G:
877
878
879
880 for(i=0;i<=15;i++){
881 pOperateMCS[i] = 0;
882 }
883 break;
884
885 case IEEE_N_24G:
886 case IEEE_N_5G:
887
888
889
890
891
892 pOperateMCS[0] &=RATE_ADPT_1SS_MASK;
893 pOperateMCS[1] &=RATE_ADPT_2SS_MASK;
894 pOperateMCS[3] &=RATE_ADPT_MCS32_MASK;
895 break;
896
897
898 default:
899
900 break;
901
902 }
903
904 return true;
905}
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926u8 HTGetHighestMCSRate(struct ieee80211_device* ieee, u8* pMCSRateSet, u8* pMCSFilter)
927{
928 u8 i, j;
929 u8 bitMap;
930 u8 mcsRate = 0;
931 u8 availableMcsRate[16];
932 if (pMCSRateSet == NULL || pMCSFilter == NULL)
933 {
934 IEEE80211_DEBUG(IEEE80211_DL_ERR, "pMCSRateSet or pMCSFilter can't be null in HTGetHighestMCSRate()\n");
935 return false;
936 }
937 for(i=0; i<16; i++)
938 availableMcsRate[i] = pMCSRateSet[i] & pMCSFilter[i];
939
940 for(i = 0; i < 16; i++)
941 {
942 if(availableMcsRate[i] != 0)
943 break;
944 }
945 if(i == 16)
946 return false;
947
948 for(i = 0; i < 16; i++)
949 {
950 if(availableMcsRate[i] != 0)
951 {
952 bitMap = availableMcsRate[i];
953 for(j = 0; j < 8; j++)
954 {
955 if((bitMap%2) != 0)
956 {
957 if(HTMcsToDataRate(ieee, (8*i+j)) > HTMcsToDataRate(ieee, mcsRate))
958 mcsRate = (8*i+j);
959 }
960 bitMap = bitMap>>1;
961 }
962 }
963 }
964 return (mcsRate|0x80);
965}
966
967
968
969
970
971
972
973
974
975
976
977
978u8 HTFilterMCSRate( struct ieee80211_device* ieee, u8* pSupportMCS, u8* pOperateMCS)
979{
980
981 u8 i=0;
982
983
984 for(i=0;i<=15;i++){
985 pOperateMCS[i] = ieee->Regdot11HTOperationalRateSet[i]&pSupportMCS[i];
986 }
987
988
989
990
991
992
993 HT_PickMCSRate(ieee, pOperateMCS);
994
995
996 if (ieee->GetHalfNmodeSupportByAPsHandler(ieee))
997 pOperateMCS[1] = 0;
998
999
1000
1001
1002
1003 for(i=2; i<=15; i++)
1004 pOperateMCS[i] = 0;
1005
1006 return true;
1007}
1008void HTSetConnectBwMode(struct ieee80211_device* ieee, HT_CHANNEL_WIDTH Bandwidth, HT_EXTCHNL_OFFSET Offset);
1009void HTOnAssocRsp(struct ieee80211_device *ieee)
1010{
1011 PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
1012 PHT_CAPABILITY_ELE pPeerHTCap = NULL;
1013 PHT_INFORMATION_ELE pPeerHTInfo = NULL;
1014 u16 nMaxAMSDUSize = 0;
1015 u8* pMcsFilter = NULL;
1016
1017 static u8 EWC11NHTCap[] = {0x00, 0x90, 0x4c, 0x33};
1018 static u8 EWC11NHTInfo[] = {0x00, 0x90, 0x4c, 0x34};
1019
1020 if( pHTInfo->bCurrentHTSupport == false )
1021 {
1022 IEEE80211_DEBUG(IEEE80211_DL_ERR, "<=== HTOnAssocRsp(): HT_DISABLE\n");
1023 return;
1024 }
1025 IEEE80211_DEBUG(IEEE80211_DL_HT, "===> HTOnAssocRsp_wq(): HT_ENABLE\n");
1026
1027
1028
1029
1030
1031
1032 if(!memcmp(pHTInfo->PeerHTCapBuf,EWC11NHTCap, sizeof(EWC11NHTCap)))
1033 pPeerHTCap = (PHT_CAPABILITY_ELE)(&pHTInfo->PeerHTCapBuf[4]);
1034 else
1035 pPeerHTCap = (PHT_CAPABILITY_ELE)(pHTInfo->PeerHTCapBuf);
1036
1037 if(!memcmp(pHTInfo->PeerHTInfoBuf, EWC11NHTInfo, sizeof(EWC11NHTInfo)))
1038 pPeerHTInfo = (PHT_INFORMATION_ELE)(&pHTInfo->PeerHTInfoBuf[4]);
1039 else
1040 pPeerHTInfo = (PHT_INFORMATION_ELE)(pHTInfo->PeerHTInfoBuf);
1041
1042
1043
1044
1045
1046 IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA|IEEE80211_DL_HT, pPeerHTCap, sizeof(HT_CAPABILITY_ELE));
1047
1048
1049
1050 HTSetConnectBwMode(ieee, (HT_CHANNEL_WIDTH)(pPeerHTCap->ChlWidth), (HT_EXTCHNL_OFFSET)(pPeerHTInfo->ExtChlOffset));
1051
1052
1053 pHTInfo->bCurTxBW40MHz = ((pPeerHTInfo->RecommemdedTxWidth == 1)?true:false);
1054
1055
1056
1057
1058
1059 pHTInfo->bCurShortGI20MHz=
1060 ((pHTInfo->bRegShortGI20MHz)?((pPeerHTCap->ShortGI20Mhz==1)?true:false):false);
1061 pHTInfo->bCurShortGI40MHz=
1062 ((pHTInfo->bRegShortGI40MHz)?((pPeerHTCap->ShortGI40Mhz==1)?true:false):false);
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073 pHTInfo->bCurSuppCCK =
1074 ((pHTInfo->bRegSuppCCK)?((pPeerHTCap->DssCCk==1)?true:false):false);
1075
1076
1077
1078
1079
1080 pHTInfo->bCurrent_AMSDU_Support = pHTInfo->bAMSDU_Support;
1081 if (ieee->rtllib_ap_sec_type &&
1082 (ieee->rtllib_ap_sec_type(ieee)&(SEC_ALG_WEP|SEC_ALG_TKIP))){
1083 if( (pHTInfo->IOTPeer== HT_IOT_PEER_ATHEROS) ||
1084 (pHTInfo->IOTPeer == HT_IOT_PEER_UNKNOWN) )
1085 pHTInfo->bCurrentAMPDUEnable = false;
1086 }
1087
1088
1089 nMaxAMSDUSize = (pPeerHTCap->MaxAMSDUSize==0)?3839:7935;
1090
1091 if(pHTInfo->nAMSDU_MaxSize > nMaxAMSDUSize )
1092 pHTInfo->nCurrent_AMSDU_MaxSize = nMaxAMSDUSize;
1093 else
1094 pHTInfo->nCurrent_AMSDU_MaxSize = pHTInfo->nAMSDU_MaxSize;
1095
1096
1097
1098
1099
1100 pHTInfo->bCurrentAMPDUEnable = pHTInfo->bAMPDUEnable;
1101
1102
1103
1104
1105 if(!pHTInfo->bRegRT2RTAggregation)
1106 {
1107
1108 if(pHTInfo->AMPDU_Factor > pPeerHTCap->MaxRxAMPDUFactor)
1109 pHTInfo->CurrentAMPDUFactor = pPeerHTCap->MaxRxAMPDUFactor;
1110 else
1111 pHTInfo->CurrentAMPDUFactor = pHTInfo->AMPDU_Factor;
1112
1113 }else
1114 {
1115
1116
1117#if 0
1118 osTmp= PacketGetElement( asocpdu, EID_Vendor, OUI_SUB_REALTEK_AGG, OUI_SUBTYPE_DONT_CARE);
1119 if(osTmp.Length >= 5)
1120#endif
1121 if (ieee->current_network.bssht.bdRT2RTAggregation)
1122 {
1123 if( ieee->pairwise_key_type != KEY_TYPE_NA)
1124
1125 pHTInfo->CurrentAMPDUFactor = pPeerHTCap->MaxRxAMPDUFactor;
1126 else
1127 pHTInfo->CurrentAMPDUFactor = HT_AGG_SIZE_64K;
1128 }else
1129 {
1130 if(pPeerHTCap->MaxRxAMPDUFactor < HT_AGG_SIZE_32K)
1131 pHTInfo->CurrentAMPDUFactor = pPeerHTCap->MaxRxAMPDUFactor;
1132 else
1133 pHTInfo->CurrentAMPDUFactor = HT_AGG_SIZE_32K;
1134 }
1135 }
1136
1137
1138
1139#if 1
1140 if(pHTInfo->MPDU_Density > pPeerHTCap->MPDUDensity)
1141 pHTInfo->CurrentMPDUDensity = pHTInfo->MPDU_Density;
1142 else
1143 pHTInfo->CurrentMPDUDensity = pPeerHTCap->MPDUDensity;
1144 if(ieee->pairwise_key_type != KEY_TYPE_NA )
1145 pHTInfo->CurrentMPDUDensity = 7;
1146#else
1147 if(pHTInfo->MPDU_Density > pPeerHTCap->MPDUDensity)
1148 pHTInfo->CurrentMPDUDensity = pHTInfo->MPDU_Density;
1149 else
1150 pHTInfo->CurrentMPDUDensity = pPeerHTCap->MPDUDensity;
1151#endif
1152
1153
1154
1155
1156 if(0)
1157 {
1158
1159 pHTInfo->bCurrentAMPDUEnable = false;
1160 pHTInfo->ForcedAMSDUMode = HT_AGG_FORCE_ENABLE;
1161 pHTInfo->ForcedAMSDUMaxSize = 7935;
1162
1163 pHTInfo->IOTAction |= HT_IOT_ACT_TX_USE_AMSDU_8K;
1164 }
1165
1166
1167 pHTInfo->bCurRxReorderEnable = pHTInfo->bRegRxReorderEnable;
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177 if(pPeerHTCap->MCS[0] == 0)
1178 pPeerHTCap->MCS[0] = 0xff;
1179
1180 HTFilterMCSRate(ieee, pPeerHTCap->MCS, ieee->dot11HTOperationalRateSet);
1181
1182
1183
1184
1185 pHTInfo->PeerMimoPs = pPeerHTCap->MimoPwrSave;
1186 if(pHTInfo->PeerMimoPs == MIMO_PS_STATIC)
1187 pMcsFilter = MCS_FILTER_1SS;
1188 else
1189 pMcsFilter = MCS_FILTER_ALL;
1190
1191
1192 ieee->HTHighestOperaRate = HTGetHighestMCSRate(ieee, ieee->dot11HTOperationalRateSet, pMcsFilter);
1193 ieee->HTCurrentOperaRate = ieee->HTHighestOperaRate;
1194
1195
1196
1197
1198 pHTInfo->CurrentOpMode = pPeerHTInfo->OptMode;
1199
1200
1201
1202}
1203
1204void HTSetConnectBwModeCallback(struct ieee80211_device* ieee);
1205
1206
1207
1208
1209
1210
1211
1212
1213void HTInitializeHTInfo(struct ieee80211_device* ieee)
1214{
1215 PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
1216
1217
1218
1219
1220 IEEE80211_DEBUG(IEEE80211_DL_HT, "===========>%s()\n", __FUNCTION__);
1221 pHTInfo->bCurrentHTSupport = false;
1222
1223
1224 pHTInfo->bCurBW40MHz = false;
1225 pHTInfo->bCurTxBW40MHz = false;
1226
1227
1228 pHTInfo->bCurShortGI20MHz = false;
1229 pHTInfo->bCurShortGI40MHz = false;
1230 pHTInfo->bForcedShortGI = false;
1231
1232
1233
1234
1235
1236 pHTInfo->bCurSuppCCK = true;
1237
1238
1239 pHTInfo->bCurrent_AMSDU_Support = false;
1240 pHTInfo->nCurrent_AMSDU_MaxSize = pHTInfo->nAMSDU_MaxSize;
1241
1242
1243 pHTInfo->CurrentMPDUDensity = pHTInfo->MPDU_Density;
1244 pHTInfo->CurrentAMPDUFactor = pHTInfo->AMPDU_Factor;
1245
1246
1247
1248
1249 memset((void*)(&(pHTInfo->SelfHTCap)), 0, sizeof(pHTInfo->SelfHTCap));
1250 memset((void*)(&(pHTInfo->SelfHTInfo)), 0, sizeof(pHTInfo->SelfHTInfo));
1251 memset((void*)(&(pHTInfo->PeerHTCapBuf)), 0, sizeof(pHTInfo->PeerHTCapBuf));
1252 memset((void*)(&(pHTInfo->PeerHTInfoBuf)), 0, sizeof(pHTInfo->PeerHTInfoBuf));
1253
1254 pHTInfo->bSwBwInProgress = false;
1255 pHTInfo->ChnlOp = CHNLOP_NONE;
1256
1257
1258 pHTInfo->ePeerHTSpecVer = HT_SPEC_VER_IEEE;
1259
1260
1261 pHTInfo->bCurrentRT2RTAggregation = false;
1262 pHTInfo->bCurrentRT2RTLongSlotTime = false;
1263 pHTInfo->IOTPeer = 0;
1264 pHTInfo->IOTAction = 0;
1265
1266
1267 {
1268 u8* RegHTSuppRateSets = &(ieee->RegHTSuppRateSet[0]);
1269 RegHTSuppRateSets[0] = 0xFF;
1270 RegHTSuppRateSets[1] = 0xFF;
1271 RegHTSuppRateSets[4] = 0x01;
1272 }
1273}
1274
1275
1276
1277
1278
1279
1280
1281void HTInitializeBssDesc(PBSS_HT pBssHT)
1282{
1283
1284 pBssHT->bdSupportHT = false;
1285 memset(pBssHT->bdHTCapBuf, 0, sizeof(pBssHT->bdHTCapBuf));
1286 pBssHT->bdHTCapLen = 0;
1287 memset(pBssHT->bdHTInfoBuf, 0, sizeof(pBssHT->bdHTInfoBuf));
1288 pBssHT->bdHTInfoLen = 0;
1289
1290 pBssHT->bdHTSpecVer= HT_SPEC_VER_IEEE;
1291
1292 pBssHT->bdRT2RTAggregation = false;
1293 pBssHT->bdRT2RTLongSlotTime = false;
1294}
1295#if 0
1296
1297void
1298HTParsingHTCapElement(
1299 IN PADAPTER Adapter,
1300 IN OCTET_STRING HTCapIE,
1301 OUT PRT_WLAN_BSS pBssDesc
1302)
1303{
1304 PMGNT_INFO pMgntInfo = &Adapter->MgntInfo;
1305
1306 if( HTCapIE.Length > sizeof(pBssDesc->BssHT.bdHTCapBuf) )
1307 {
1308 RT_TRACE( COMP_HT, DBG_LOUD, ("HTParsingHTCapElement(): HT Capability Element length is too long!\n") );
1309 return;
1310 }
1311
1312
1313
1314 if(!pMgntInfo->mActingAsAp && !pMgntInfo->mAssoc)
1315 HTDebugHTCapability(DBG_TRACE, Adapter, &HTCapIE, (pu8)"HTParsingHTCapElement()");
1316
1317 HTCapIE.Length = HTCapIE.Length > sizeof(pBssDesc->BssHT.bdHTCapBuf)?\
1318 sizeof(pBssDesc->BssHT.bdHTCapBuf):HTCapIE.Length;
1319
1320 CopyMem(pBssDesc->BssHT.bdHTCapBuf, HTCapIE.Octet, HTCapIE.Length);
1321 pBssDesc->BssHT.bdHTCapLen = HTCapIE.Length;
1322
1323}
1324
1325
1326void
1327HTParsingHTInfoElement(
1328 PADAPTER Adapter,
1329 OCTET_STRING HTInfoIE,
1330 PRT_WLAN_BSS pBssDesc
1331)
1332{
1333 PMGNT_INFO pMgntInfo = &Adapter->MgntInfo;
1334
1335 if( HTInfoIE.Length > sizeof(pBssDesc->BssHT.bdHTInfoBuf))
1336 {
1337 RT_TRACE( COMP_HT, DBG_LOUD, ("HTParsingHTInfoElement(): HT Information Element length is too long!\n") );
1338 return;
1339 }
1340
1341
1342
1343 if(!pMgntInfo->mActingAsAp && !pMgntInfo->mAssoc)
1344 HTDebugHTInfo(DBG_TRACE, Adapter, &HTInfoIE, (pu8)"HTParsingHTInfoElement()");
1345
1346 HTInfoIE.Length = HTInfoIE.Length > sizeof(pBssDesc->BssHT.bdHTInfoBuf)?\
1347 sizeof(pBssDesc->BssHT.bdHTInfoBuf):HTInfoIE.Length;
1348
1349 CopyMem( pBssDesc->BssHT.bdHTInfoBuf, HTInfoIE.Octet, HTInfoIE.Length);
1350 pBssDesc->BssHT.bdHTInfoLen = HTInfoIE.Length;
1351}
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366void HTGetValueFromBeaconOrProbeRsp(
1367 PADAPTER Adapter,
1368 POCTET_STRING pSRCmmpdu,
1369 PRT_WLAN_BSS bssDesc
1370)
1371{
1372 PMGNT_INFO pMgntInfo = &Adapter->MgntInfo;
1373 PRT_HIGH_THROUGHPUT pHTInfo = GET_HT_INFO(pMgntInfo);
1374 OCTET_STRING HTCapIE, HTInfoIE, HTRealtekAgg, mmpdu;
1375 OCTET_STRING BroadcomElement, CiscoElement;
1376
1377 mmpdu.Octet = pSRCmmpdu->Octet;
1378 mmpdu.Length = pSRCmmpdu->Length;
1379
1380
1381
1382
1383
1384
1385
1386 HTInitializeBssDesc (&bssDesc->BssHT);
1387
1388
1389
1390 HTCapIE = PacketGetElement(mmpdu, EID_HTCapability, OUI_SUB_DONT_CARE, OUI_SUBTYPE_DONT_CARE);
1391 if(HTCapIE.Length == 0)
1392 {
1393 HTCapIE = PacketGetElement(mmpdu, EID_Vendor, OUI_SUB_11N_EWC_HT_CAP, OUI_SUBTYPE_DONT_CARE);
1394 if(HTCapIE.Length != 0)
1395 bssDesc->BssHT.bdHTSpecVer= HT_SPEC_VER_EWC;
1396 }
1397 if(HTCapIE.Length != 0)
1398 HTParsingHTCapElement(Adapter, HTCapIE, bssDesc);
1399
1400
1401 HTInfoIE = PacketGetElement(mmpdu, EID_HTInfo, OUI_SUB_DONT_CARE, OUI_SUBTYPE_DONT_CARE);
1402 if(HTInfoIE.Length == 0)
1403 {
1404 HTInfoIE = PacketGetElement(mmpdu, EID_Vendor, OUI_SUB_11N_EWC_HT_INFO, OUI_SUBTYPE_DONT_CARE);
1405 if(HTInfoIE.Length != 0)
1406 bssDesc->BssHT.bdHTSpecVer = HT_SPEC_VER_EWC;
1407 }
1408 if(HTInfoIE.Length != 0)
1409 HTParsingHTInfoElement(Adapter, HTInfoIE, bssDesc);
1410
1411
1412 if(HTCapIE.Length != 0)
1413 {
1414 bssDesc->BssHT.bdSupportHT = true;
1415 if(bssDesc->BssQos.bdQoSMode == QOS_DISABLE)
1416 QosSetLegacyWMMParamWithHT(Adapter, bssDesc);
1417 }
1418 else
1419 {
1420 bssDesc->BssHT.bdSupportHT = false;
1421 }
1422
1423
1424 if(pHTInfo->bRegRT2RTAggregation)
1425 {
1426 if(bssDesc->BssHT.bdSupportHT)
1427 {
1428 HTRealtekAgg = PacketGetElement(mmpdu, EID_Vendor, OUI_SUB_REALTEK_AGG, OUI_SUBTYPE_DONT_CARE);
1429 if(HTRealtekAgg.Length >=5 )
1430 {
1431 bssDesc->BssHT.bdRT2RTAggregation = true;
1432
1433 if((HTRealtekAgg.Octet[4]==1) && (HTRealtekAgg.Octet[5] & 0x02))
1434 bssDesc->BssHT.bdRT2RTLongSlotTime = true;
1435 }
1436 }
1437 }
1438
1439
1440
1441
1442
1443
1444
1445 bssDesc->bBroadcomCapExist= false;
1446
1447 if(HTCapIE.Length != 0 || HTInfoIE.Length != 0)
1448 {
1449 u4Byte Length = 0;
1450
1451 FillOctetString(BroadcomElement, NULL, 0);
1452
1453 BroadcomElement = PacketGetElement( mmpdu, EID_Vendor, OUI_SUB_BROADCOM_IE_1, OUI_SUBTYPE_DONT_CARE);
1454 Length += BroadcomElement.Length;
1455 BroadcomElement = PacketGetElement( mmpdu, EID_Vendor, OUI_SUB_BROADCOM_IE_2, OUI_SUBTYPE_DONT_CARE);
1456 Length += BroadcomElement.Length;
1457 BroadcomElement = PacketGetElement( mmpdu, EID_Vendor, OUI_SUB_BROADCOM_IE_3, OUI_SUBTYPE_DONT_CARE);
1458 Length += BroadcomElement.Length;
1459
1460 if(Length > 0)
1461 bssDesc->bBroadcomCapExist = true;
1462 }
1463
1464
1465
1466 CiscoElement = PacketGetElement( mmpdu, EID_Vendor, OUI_SUB_CISCO_IE, OUI_SUBTYPE_DONT_CARE);
1467 if(CiscoElement.Length != 0){
1468 bssDesc->bCiscoCapExist = true;
1469 }else{
1470 bssDesc->bCiscoCapExist = false;
1471 }
1472}
1473
1474
1475#endif
1476
1477
1478
1479
1480
1481
1482
1483
1484void HTResetSelfAndSavePeerSetting(struct ieee80211_device* ieee, struct ieee80211_network * pNetwork)
1485{
1486 PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
1487
1488
1489
1490
1491 u8 bIOTAction = 0;
1492
1493
1494
1495
1496 IEEE80211_DEBUG(IEEE80211_DL_HT, "==============>%s()\n", __FUNCTION__);
1497
1498
1499 if (pNetwork->bssht.bdSupportHT)
1500 {
1501 pHTInfo->bCurrentHTSupport = true;
1502 pHTInfo->ePeerHTSpecVer = pNetwork->bssht.bdHTSpecVer;
1503
1504
1505 if(pNetwork->bssht.bdHTCapLen > 0 && pNetwork->bssht.bdHTCapLen <= sizeof(pHTInfo->PeerHTCapBuf))
1506 memcpy(pHTInfo->PeerHTCapBuf, pNetwork->bssht.bdHTCapBuf, pNetwork->bssht.bdHTCapLen);
1507
1508 if(pNetwork->bssht.bdHTInfoLen > 0 && pNetwork->bssht.bdHTInfoLen <= sizeof(pHTInfo->PeerHTInfoBuf))
1509 memcpy(pHTInfo->PeerHTInfoBuf, pNetwork->bssht.bdHTInfoBuf, pNetwork->bssht.bdHTInfoLen);
1510
1511
1512 if(pHTInfo->bRegRT2RTAggregation)
1513 {
1514 pHTInfo->bCurrentRT2RTAggregation = pNetwork->bssht.bdRT2RTAggregation;
1515 pHTInfo->bCurrentRT2RTLongSlotTime = pNetwork->bssht.bdRT2RTLongSlotTime;
1516 }
1517 else
1518 {
1519 pHTInfo->bCurrentRT2RTAggregation = false;
1520 pHTInfo->bCurrentRT2RTLongSlotTime = false;
1521 }
1522
1523
1524 HTIOTPeerDetermine(ieee);
1525
1526
1527
1528 pHTInfo->IOTAction = 0;
1529 bIOTAction = HTIOTActIsDisableMCS14(ieee, pNetwork->bssid);
1530 if(bIOTAction)
1531 pHTInfo->IOTAction |= HT_IOT_ACT_DISABLE_MCS14;
1532 bIOTAction = HTIOTActIsForcedCTS2Self(ieee, pNetwork);
1533 if(bIOTAction)
1534 pHTInfo->IOTAction |= HT_IOT_ACT_FORCED_CTS2SELF;
1535
1536 bIOTAction = HTIOTActIsDisableMCS15(ieee);
1537 if(bIOTAction)
1538 pHTInfo->IOTAction |= HT_IOT_ACT_DISABLE_MCS15;
1539
1540 bIOTAction = HTIOTActIsDisableMCSTwoSpatialStream(ieee, pNetwork->bssid);
1541 if(bIOTAction)
1542 pHTInfo->IOTAction |= HT_IOT_ACT_DISABLE_ALL_2SS;
1543
1544
1545 bIOTAction = HTIOTActIsDisableEDCATurbo(ieee, pNetwork->bssid);
1546 if(bIOTAction)
1547 pHTInfo->IOTAction |= HT_IOT_ACT_DISABLE_EDCA_TURBO;
1548
1549 bIOTAction = HTIOTActIsMgntUseCCK6M(pNetwork);
1550 if(bIOTAction)
1551 pHTInfo->IOTAction |= HT_IOT_ACT_MGNT_USE_CCK_6M;
1552
1553 bIOTAction = HTIOTActIsCCDFsync(pNetwork->bssid);
1554 if(bIOTAction)
1555 pHTInfo->IOTAction |= HT_IOT_ACT_CDD_FSYNC;
1556
1557 bIOTAction = HTIOTActIsNullDataPowerSaving(ieee, pNetwork);
1558 if(bIOTAction)
1559 pHTInfo->IOTAction |= HT_IOT_ACT_NULL_DATA_POWER_SAVING;
1560
1561 }
1562 else
1563 {
1564 pHTInfo->bCurrentHTSupport = false;
1565 pHTInfo->bCurrentRT2RTAggregation = false;
1566 pHTInfo->bCurrentRT2RTLongSlotTime = false;
1567
1568 pHTInfo->IOTAction = 0;
1569 }
1570
1571}
1572
1573void HTUpdateSelfAndPeerSetting(struct ieee80211_device* ieee, struct ieee80211_network * pNetwork)
1574{
1575 PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
1576
1577 PHT_INFORMATION_ELE pPeerHTInfo = (PHT_INFORMATION_ELE)pNetwork->bssht.bdHTInfoBuf;
1578
1579 if(pHTInfo->bCurrentHTSupport)
1580 {
1581
1582
1583
1584 if(pNetwork->bssht.bdHTInfoLen != 0)
1585 pHTInfo->CurrentOpMode = pPeerHTInfo->OptMode;
1586
1587
1588
1589
1590 }
1591}
1592
1593void HTUseDefaultSetting(struct ieee80211_device* ieee)
1594{
1595 PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
1596
1597
1598 if(pHTInfo->bEnableHT)
1599 {
1600 pHTInfo->bCurrentHTSupport = true;
1601
1602 pHTInfo->bCurSuppCCK = pHTInfo->bRegSuppCCK;
1603
1604 pHTInfo->bCurBW40MHz = pHTInfo->bRegBW40MHz;
1605
1606 pHTInfo->bCurShortGI20MHz= pHTInfo->bRegShortGI20MHz;
1607
1608 pHTInfo->bCurShortGI40MHz= pHTInfo->bRegShortGI40MHz;
1609
1610 pHTInfo->bCurrent_AMSDU_Support = pHTInfo->bAMSDU_Support;
1611
1612 pHTInfo->nCurrent_AMSDU_MaxSize = pHTInfo->nAMSDU_MaxSize;
1613
1614 pHTInfo->bCurrentAMPDUEnable = pHTInfo->bAMPDUEnable;
1615
1616 pHTInfo->CurrentAMPDUFactor = pHTInfo->AMPDU_Factor;
1617
1618 pHTInfo->CurrentMPDUDensity = pHTInfo->CurrentMPDUDensity;
1619
1620
1621
1622
1623 HTFilterMCSRate(ieee, ieee->Regdot11HTOperationalRateSet, ieee->dot11HTOperationalRateSet);
1624
1625#ifdef TODO
1626 Adapter->HalFunc.InitHalRATRTableHandler( Adapter, &pMgntInfo->dot11OperationalRateSet, pMgntInfo->dot11HTOperationalRateSet);
1627#endif
1628 ieee->HTHighestOperaRate = HTGetHighestMCSRate(ieee, ieee->dot11HTOperationalRateSet, MCS_FILTER_ALL);
1629 ieee->HTCurrentOperaRate = ieee->HTHighestOperaRate;
1630
1631 }
1632 else
1633 {
1634 pHTInfo->bCurrentHTSupport = false;
1635 }
1636}
1637
1638
1639
1640
1641
1642
1643
1644
1645u8 HTCCheck(struct ieee80211_device* ieee, u8* pFrame)
1646{
1647 if(ieee->pHTInfo->bCurrentHTSupport)
1648 {
1649 if( (IsQoSDataFrame(pFrame) && Frame_Order(pFrame)) == 1)
1650 {
1651 IEEE80211_DEBUG(IEEE80211_DL_HT, "HT CONTROL FILED EXIST!!\n");
1652 return true;
1653 }
1654 }
1655 return false;
1656}
1657
1658
1659
1660
1661void HTSetConnectBwMode(struct ieee80211_device* ieee, HT_CHANNEL_WIDTH Bandwidth, HT_EXTCHNL_OFFSET Offset)
1662{
1663 PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
1664
1665
1666 if(pHTInfo->bRegBW40MHz == false)
1667 return;
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677 if(pHTInfo->bSwBwInProgress) {
1678
1679 return;
1680 }
1681
1682 if (Bandwidth==HT_CHANNEL_WIDTH_20_40 && (!ieee->GetHalfNmodeSupportByAPsHandler(ieee)))
1683 {
1684
1685 if(ieee->current_network.channel<2 && Offset==HT_EXTCHNL_OFFSET_LOWER)
1686 Offset = HT_EXTCHNL_OFFSET_NO_EXT;
1687 if(Offset==HT_EXTCHNL_OFFSET_UPPER || Offset==HT_EXTCHNL_OFFSET_LOWER) {
1688 pHTInfo->bCurBW40MHz = true;
1689 pHTInfo->CurSTAExtChnlOffset = Offset;
1690 } else {
1691 pHTInfo->bCurBW40MHz = false;
1692 pHTInfo->CurSTAExtChnlOffset = HT_EXTCHNL_OFFSET_NO_EXT;
1693 }
1694 } else {
1695 pHTInfo->bCurBW40MHz = false;
1696 pHTInfo->CurSTAExtChnlOffset = HT_EXTCHNL_OFFSET_NO_EXT;
1697 }
1698
1699 pHTInfo->bSwBwInProgress = true;
1700
1701
1702
1703
1704
1705 HTSetConnectBwModeCallback(ieee);
1706
1707
1708}
1709
1710void HTSetConnectBwModeCallback(struct ieee80211_device* ieee)
1711{
1712 PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
1713
1714 IEEE80211_DEBUG(IEEE80211_DL_HT, "======>%s()\n", __FUNCTION__);
1715
1716 if(pHTInfo->bCurBW40MHz)
1717 {
1718 if(pHTInfo->CurSTAExtChnlOffset==HT_EXTCHNL_OFFSET_UPPER)
1719 ieee->set_chan(ieee, ieee->current_network.channel+2);
1720 else if(pHTInfo->CurSTAExtChnlOffset==HT_EXTCHNL_OFFSET_LOWER)
1721 ieee->set_chan(ieee, ieee->current_network.channel-2);
1722 else
1723 ieee->set_chan(ieee, ieee->current_network.channel);
1724
1725 ieee->SetBWModeHandler(ieee, HT_CHANNEL_WIDTH_20_40, pHTInfo->CurSTAExtChnlOffset);
1726 } else {
1727 ieee->set_chan(ieee, ieee->current_network.channel);
1728 ieee->SetBWModeHandler(ieee, HT_CHANNEL_WIDTH_20, HT_EXTCHNL_OFFSET_NO_EXT);
1729 }
1730
1731 pHTInfo->bSwBwInProgress = false;
1732}
1733