Staging: add rt2870 wireless driver
[linux-2.6/mini2440.git] / drivers / staging / rt2870 / common / cmm_info.c
blob40792e162374b121142fab802c4cab75733793dc
1 /*
2 *************************************************************************
3 * Ralink Tech Inc.
4 * 5F., No.36, Taiyuan St., Jhubei City,
5 * Hsinchu County 302,
6 * Taiwan, R.O.C.
8 * (c) Copyright 2002-2007, Ralink Technology, Inc.
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
14 * *
15 * This program is distributed in the hope that it will be useful, *
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
18 * GNU General Public License for more details. *
19 * *
20 * You should have received a copy of the GNU General Public License *
21 * along with this program; if not, write to the *
22 * Free Software Foundation, Inc., *
23 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
24 * *
25 *************************************************************************
28 #include "../rt_config.h"
30 INT Show_SSID_Proc(
31 IN PRTMP_ADAPTER pAd,
32 OUT PUCHAR pBuf);
34 INT Show_WirelessMode_Proc(
35 IN PRTMP_ADAPTER pAd,
36 OUT PUCHAR pBuf);
38 INT Show_TxBurst_Proc(
39 IN PRTMP_ADAPTER pAd,
40 OUT PUCHAR pBuf);
42 INT Show_TxPreamble_Proc(
43 IN PRTMP_ADAPTER pAd,
44 OUT PUCHAR pBuf);
46 INT Show_TxPower_Proc(
47 IN PRTMP_ADAPTER pAd,
48 OUT PUCHAR pBuf);
50 INT Show_Channel_Proc(
51 IN PRTMP_ADAPTER pAd,
52 OUT PUCHAR pBuf);
54 INT Show_BGProtection_Proc(
55 IN PRTMP_ADAPTER pAd,
56 OUT PUCHAR pBuf);
58 INT Show_RTSThreshold_Proc(
59 IN PRTMP_ADAPTER pAd,
60 OUT PUCHAR pBuf);
62 INT Show_FragThreshold_Proc(
63 IN PRTMP_ADAPTER pAd,
64 OUT PUCHAR pBuf);
66 #ifdef DOT11_N_SUPPORT
67 INT Show_HtBw_Proc(
68 IN PRTMP_ADAPTER pAd,
69 OUT PUCHAR pBuf);
71 INT Show_HtMcs_Proc(
72 IN PRTMP_ADAPTER pAd,
73 OUT PUCHAR pBuf);
75 INT Show_HtGi_Proc(
76 IN PRTMP_ADAPTER pAd,
77 OUT PUCHAR pBuf);
79 INT Show_HtOpMode_Proc(
80 IN PRTMP_ADAPTER pAd,
81 OUT PUCHAR pBuf);
83 INT Show_HtExtcha_Proc(
84 IN PRTMP_ADAPTER pAd,
85 OUT PUCHAR pBuf);
87 INT Show_HtMpduDensity_Proc(
88 IN PRTMP_ADAPTER pAd,
89 OUT PUCHAR pBuf);
91 INT Show_HtBaWinSize_Proc(
92 IN PRTMP_ADAPTER pAd,
93 OUT PUCHAR pBuf);
95 INT Show_HtRdg_Proc(
96 IN PRTMP_ADAPTER pAd,
97 OUT PUCHAR pBuf);
99 INT Show_HtAmsdu_Proc(
100 IN PRTMP_ADAPTER pAd,
101 OUT PUCHAR pBuf);
103 INT Show_HtAutoBa_Proc(
104 IN PRTMP_ADAPTER pAd,
105 OUT PUCHAR pBuf);
106 #endif // DOT11_N_SUPPORT //
108 INT Show_CountryRegion_Proc(
109 IN PRTMP_ADAPTER pAd,
110 OUT PUCHAR pBuf);
112 INT Show_CountryRegionABand_Proc(
113 IN PRTMP_ADAPTER pAd,
114 OUT PUCHAR pBuf);
116 INT Show_CountryCode_Proc(
117 IN PRTMP_ADAPTER pAd,
118 OUT PUCHAR pBuf);
120 #ifdef AGGREGATION_SUPPORT
121 INT Show_PktAggregate_Proc(
122 IN PRTMP_ADAPTER pAd,
123 OUT PUCHAR pBuf);
124 #endif // AGGREGATION_SUPPORT //
126 #ifdef WMM_SUPPORT
127 INT Show_WmmCapable_Proc(
128 IN PRTMP_ADAPTER pAd,
129 OUT PUCHAR pBuf);
130 #endif // WMM_SUPPORT //
132 INT Show_IEEE80211H_Proc(
133 IN PRTMP_ADAPTER pAd,
134 OUT PUCHAR pBuf);
136 #ifdef CONFIG_STA_SUPPORT
137 INT Show_NetworkType_Proc(
138 IN PRTMP_ADAPTER pAd,
139 OUT PUCHAR pBuf);
140 #endif // CONFIG_STA_SUPPORT //
142 INT Show_AuthMode_Proc(
143 IN PRTMP_ADAPTER pAd,
144 OUT PUCHAR pBuf);
146 INT Show_EncrypType_Proc(
147 IN PRTMP_ADAPTER pAd,
148 OUT PUCHAR pBuf);
150 INT Show_DefaultKeyID_Proc(
151 IN PRTMP_ADAPTER pAd,
152 OUT PUCHAR pBuf);
154 INT Show_Key1_Proc(
155 IN PRTMP_ADAPTER pAd,
156 OUT PUCHAR pBuf);
158 INT Show_Key2_Proc(
159 IN PRTMP_ADAPTER pAd,
160 OUT PUCHAR pBuf);
162 INT Show_Key3_Proc(
163 IN PRTMP_ADAPTER pAd,
164 OUT PUCHAR pBuf);
166 INT Show_Key4_Proc(
167 IN PRTMP_ADAPTER pAd,
168 OUT PUCHAR pBuf);
170 INT Show_WPAPSK_Proc(
171 IN PRTMP_ADAPTER pAd,
172 OUT PUCHAR pBuf);
174 static struct {
175 CHAR *name;
176 INT (*show_proc)(PRTMP_ADAPTER pAdapter, PUCHAR arg);
177 } *PRTMP_PRIVATE_STA_SHOW_CFG_VALUE_PROC, RTMP_PRIVATE_STA_SHOW_CFG_VALUE_PROC[] = {
178 {"SSID", Show_SSID_Proc},
179 {"WirelessMode", Show_WirelessMode_Proc},
180 {"TxBurst", Show_TxBurst_Proc},
181 {"TxPreamble", Show_TxPreamble_Proc},
182 {"TxPower", Show_TxPower_Proc},
183 {"Channel", Show_Channel_Proc},
184 {"BGProtection", Show_BGProtection_Proc},
185 {"RTSThreshold", Show_RTSThreshold_Proc},
186 {"FragThreshold", Show_FragThreshold_Proc},
187 #ifdef DOT11_N_SUPPORT
188 {"HtBw", Show_HtBw_Proc},
189 {"HtMcs", Show_HtMcs_Proc},
190 {"HtGi", Show_HtGi_Proc},
191 {"HtOpMode", Show_HtOpMode_Proc},
192 {"HtExtcha", Show_HtExtcha_Proc},
193 {"HtMpduDensity", Show_HtMpduDensity_Proc},
194 {"HtBaWinSize", Show_HtBaWinSize_Proc},
195 {"HtRdg", Show_HtRdg_Proc},
196 {"HtAmsdu", Show_HtAmsdu_Proc},
197 {"HtAutoBa", Show_HtAutoBa_Proc},
198 #endif // DOT11_N_SUPPORT //
199 {"CountryRegion", Show_CountryRegion_Proc},
200 {"CountryRegionABand", Show_CountryRegionABand_Proc},
201 {"CountryCode", Show_CountryCode_Proc},
202 #ifdef AGGREGATION_SUPPORT
203 {"PktAggregate", Show_PktAggregate_Proc},
204 #endif
206 #ifdef WMM_SUPPORT
207 {"WmmCapable", Show_WmmCapable_Proc},
208 #endif
209 {"IEEE80211H", Show_IEEE80211H_Proc},
210 #ifdef CONFIG_STA_SUPPORT
211 {"NetworkType", Show_NetworkType_Proc},
212 #endif // CONFIG_STA_SUPPORT //
213 {"AuthMode", Show_AuthMode_Proc},
214 {"EncrypType", Show_EncrypType_Proc},
215 {"DefaultKeyID", Show_DefaultKeyID_Proc},
216 {"Key1", Show_Key1_Proc},
217 {"Key2", Show_Key2_Proc},
218 {"Key3", Show_Key3_Proc},
219 {"Key4", Show_Key4_Proc},
220 {"WPAPSK", Show_WPAPSK_Proc},
221 {NULL, NULL}
225 ==========================================================================
226 Description:
227 Get Driver version.
229 Return:
230 ==========================================================================
232 INT Set_DriverVersion_Proc(
233 IN PRTMP_ADAPTER pAd,
234 IN PUCHAR arg)
237 #ifdef CONFIG_STA_SUPPORT
238 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
239 DBGPRINT(RT_DEBUG_TRACE, ("Driver version-%s\n", STA_DRIVER_VERSION));
240 #endif // CONFIG_STA_SUPPORT //
242 return TRUE;
246 ==========================================================================
247 Description:
248 Set Country Region.
249 This command will not work, if the field of CountryRegion in eeprom is programmed.
250 Return:
251 TRUE if all parameters are OK, FALSE otherwise
252 ==========================================================================
254 INT Set_CountryRegion_Proc(
255 IN PRTMP_ADAPTER pAd,
256 IN PUCHAR arg)
258 ULONG region;
260 region = simple_strtol(arg, 0, 10);
262 #ifdef EXT_BUILD_CHANNEL_LIST
263 return -EOPNOTSUPP;
264 #endif // EXT_BUILD_CHANNEL_LIST //
266 // Country can be set only when EEPROM not programmed
267 if (pAd->CommonCfg.CountryRegion & 0x80)
269 DBGPRINT(RT_DEBUG_ERROR, ("Set_CountryRegion_Proc::parameter of CountryRegion in eeprom is programmed \n"));
270 return FALSE;
273 if((region >= 0) && (region <= REGION_MAXIMUM_BG_BAND))
275 pAd->CommonCfg.CountryRegion = (UCHAR) region;
277 else if (region == REGION_31_BG_BAND)
279 pAd->CommonCfg.CountryRegion = (UCHAR) region;
281 else
283 DBGPRINT(RT_DEBUG_ERROR, ("Set_CountryRegion_Proc::parameters out of range\n"));
284 return FALSE;
287 // if set country region, driver needs to be reset
288 BuildChannelList(pAd);
290 DBGPRINT(RT_DEBUG_TRACE, ("Set_CountryRegion_Proc::(CountryRegion=%d)\n", pAd->CommonCfg.CountryRegion));
292 return TRUE;
296 ==========================================================================
297 Description:
298 Set Country Region for A band.
299 This command will not work, if the field of CountryRegion in eeprom is programmed.
300 Return:
301 TRUE if all parameters are OK, FALSE otherwise
302 ==========================================================================
304 INT Set_CountryRegionABand_Proc(
305 IN PRTMP_ADAPTER pAd,
306 IN PUCHAR arg)
308 ULONG region;
310 region = simple_strtol(arg, 0, 10);
312 #ifdef EXT_BUILD_CHANNEL_LIST
313 return -EOPNOTSUPP;
314 #endif // EXT_BUILD_CHANNEL_LIST //
316 // Country can be set only when EEPROM not programmed
317 if (pAd->CommonCfg.CountryRegionForABand & 0x80)
319 DBGPRINT(RT_DEBUG_ERROR, ("Set_CountryRegionABand_Proc::parameter of CountryRegion in eeprom is programmed \n"));
320 return FALSE;
323 if((region >= 0) && (region <= REGION_MAXIMUM_A_BAND))
325 pAd->CommonCfg.CountryRegionForABand = (UCHAR) region;
327 else
329 DBGPRINT(RT_DEBUG_ERROR, ("Set_CountryRegionABand_Proc::parameters out of range\n"));
330 return FALSE;
333 // if set country region, driver needs to be reset
334 BuildChannelList(pAd);
336 DBGPRINT(RT_DEBUG_TRACE, ("Set_CountryRegionABand_Proc::(CountryRegion=%d)\n", pAd->CommonCfg.CountryRegionForABand));
338 return TRUE;
342 ==========================================================================
343 Description:
344 Set Wireless Mode
345 Return:
346 TRUE if all parameters are OK, FALSE otherwise
347 ==========================================================================
349 INT Set_WirelessMode_Proc(
350 IN PRTMP_ADAPTER pAd,
351 IN PUCHAR arg)
353 ULONG WirelessMode;
354 INT success = TRUE;
356 WirelessMode = simple_strtol(arg, 0, 10);
359 #ifdef CONFIG_STA_SUPPORT
360 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
362 INT MaxPhyMode = PHY_11G;
364 #ifdef DOT11_N_SUPPORT
365 MaxPhyMode = PHY_11N_5G;
366 #endif // DOT11_N_SUPPORT //
368 if (WirelessMode <= MaxPhyMode)
370 RTMPSetPhyMode(pAd, WirelessMode);
371 #ifdef DOT11_N_SUPPORT
372 if (WirelessMode >= PHY_11ABGN_MIXED)
374 pAd->CommonCfg.BACapability.field.AutoBA = TRUE;
375 pAd->CommonCfg.REGBACapability.field.AutoBA = TRUE;
377 else
379 pAd->CommonCfg.BACapability.field.AutoBA = FALSE;
380 pAd->CommonCfg.REGBACapability.field.AutoBA = FALSE;
382 #endif // DOT11_N_SUPPORT //
383 // Set AdhocMode rates
384 if (pAd->StaCfg.BssType == BSS_ADHOC)
386 MlmeUpdateTxRates(pAd, FALSE, 0);
387 MakeIbssBeacon(pAd); // re-build BEACON frame
388 AsicEnableIbssSync(pAd); // copy to on-chip memory
391 else
393 success = FALSE;
396 #endif // CONFIG_STA_SUPPORT //
398 // it is needed to set SSID to take effect
399 if (success == TRUE)
401 #ifdef DOT11_N_SUPPORT
402 SetCommonHT(pAd);
403 #endif // DOT11_N_SUPPORT //
404 DBGPRINT(RT_DEBUG_TRACE, ("Set_WirelessMode_Proc::(=%ld)\n", WirelessMode));
406 else
408 DBGPRINT(RT_DEBUG_ERROR, ("Set_WirelessMode_Proc::parameters out of range\n"));
411 return success;
415 ==========================================================================
416 Description:
417 Set Channel
418 Return:
419 TRUE if all parameters are OK, FALSE otherwise
420 ==========================================================================
422 INT Set_Channel_Proc(
423 IN PRTMP_ADAPTER pAd,
424 IN PUCHAR arg)
426 INT success = TRUE;
427 UCHAR Channel;
429 Channel = (UCHAR) simple_strtol(arg, 0, 10);
431 // check if this channel is valid
432 if (ChannelSanity(pAd, Channel) == TRUE)
434 #ifdef CONFIG_STA_SUPPORT
435 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
437 pAd->CommonCfg.Channel = Channel;
439 if (MONITOR_ON(pAd))
441 #ifdef DOT11_N_SUPPORT
442 N_ChannelCheck(pAd);
443 if (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED &&
444 pAd->CommonCfg.RegTransmitSetting.field.BW == BW_40)
446 N_SetCenCh(pAd);
447 AsicSwitchChannel(pAd, pAd->CommonCfg.CentralChannel, FALSE);
448 AsicLockChannel(pAd, pAd->CommonCfg.CentralChannel);
449 DBGPRINT(RT_DEBUG_TRACE, ("BW_40, control_channel(%d), CentralChannel(%d) \n",
450 pAd->CommonCfg.Channel, pAd->CommonCfg.CentralChannel));
452 else
453 #endif // DOT11_N_SUPPORT //
455 AsicSwitchChannel(pAd, pAd->CommonCfg.Channel, FALSE);
456 AsicLockChannel(pAd, pAd->CommonCfg.Channel);
457 DBGPRINT(RT_DEBUG_TRACE, ("BW_20, Channel(%d)\n", pAd->CommonCfg.Channel));
461 #endif // CONFIG_STA_SUPPORT //
462 success = TRUE;
464 else
467 #ifdef CONFIG_STA_SUPPORT
468 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
469 success = FALSE;
470 #endif // CONFIG_STA_SUPPORT //
474 if (success == TRUE)
475 DBGPRINT(RT_DEBUG_TRACE, ("Set_Channel_Proc::(Channel=%d)\n", pAd->CommonCfg.Channel));
477 return success;
481 ==========================================================================
482 Description:
483 Set Short Slot Time Enable or Disable
484 Return:
485 TRUE if all parameters are OK, FALSE otherwise
486 ==========================================================================
488 INT Set_ShortSlot_Proc(
489 IN PRTMP_ADAPTER pAd,
490 IN PUCHAR arg)
492 ULONG ShortSlot;
494 ShortSlot = simple_strtol(arg, 0, 10);
496 if (ShortSlot == 1)
497 pAd->CommonCfg.bUseShortSlotTime = TRUE;
498 else if (ShortSlot == 0)
499 pAd->CommonCfg.bUseShortSlotTime = FALSE;
500 else
501 return FALSE; //Invalid argument
503 DBGPRINT(RT_DEBUG_TRACE, ("Set_ShortSlot_Proc::(ShortSlot=%d)\n", pAd->CommonCfg.bUseShortSlotTime));
505 return TRUE;
509 ==========================================================================
510 Description:
511 Set Tx power
512 Return:
513 TRUE if all parameters are OK, FALSE otherwise
514 ==========================================================================
516 INT Set_TxPower_Proc(
517 IN PRTMP_ADAPTER pAd,
518 IN PUCHAR arg)
520 ULONG TxPower;
521 INT success = FALSE;
523 TxPower = (ULONG) simple_strtol(arg, 0, 10);
524 if (TxPower <= 100)
527 #ifdef CONFIG_STA_SUPPORT
528 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
530 pAd->CommonCfg.TxPowerDefault = TxPower;
531 pAd->CommonCfg.TxPowerPercentage = pAd->CommonCfg.TxPowerDefault;
533 #endif // CONFIG_STA_SUPPORT //
534 success = TRUE;
536 else
537 success = FALSE;
539 DBGPRINT(RT_DEBUG_TRACE, ("Set_TxPower_Proc::(TxPowerPercentage=%ld)\n", pAd->CommonCfg.TxPowerPercentage));
541 return success;
545 ==========================================================================
546 Description:
547 Set 11B/11G Protection
548 Return:
549 TRUE if all parameters are OK, FALSE otherwise
550 ==========================================================================
552 INT Set_BGProtection_Proc(
553 IN PRTMP_ADAPTER pAd,
554 IN PUCHAR arg)
556 switch (simple_strtol(arg, 0, 10))
558 case 0: //AUTO
559 pAd->CommonCfg.UseBGProtection = 0;
560 break;
561 case 1: //Always On
562 pAd->CommonCfg.UseBGProtection = 1;
563 break;
564 case 2: //Always OFF
565 pAd->CommonCfg.UseBGProtection = 2;
566 break;
567 default: //Invalid argument
568 return FALSE;
572 DBGPRINT(RT_DEBUG_TRACE, ("Set_BGProtection_Proc::(BGProtection=%ld)\n", pAd->CommonCfg.UseBGProtection));
574 return TRUE;
578 ==========================================================================
579 Description:
580 Set TxPreamble
581 Return:
582 TRUE if all parameters are OK, FALSE otherwise
583 ==========================================================================
585 INT Set_TxPreamble_Proc(
586 IN PRTMP_ADAPTER pAd,
587 IN PUCHAR arg)
589 RT_802_11_PREAMBLE Preamble;
591 Preamble = simple_strtol(arg, 0, 10);
594 switch (Preamble)
596 case Rt802_11PreambleShort:
597 pAd->CommonCfg.TxPreamble = Preamble;
598 #ifdef CONFIG_STA_SUPPORT
599 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
600 MlmeSetTxPreamble(pAd, Rt802_11PreambleShort);
601 #endif // CONFIG_STA_SUPPORT //
602 break;
603 case Rt802_11PreambleLong:
604 #ifdef CONFIG_STA_SUPPORT
605 case Rt802_11PreambleAuto:
606 // if user wants AUTO, initialize to LONG here, then change according to AP's
607 // capability upon association.
608 #endif // CONFIG_STA_SUPPORT //
609 pAd->CommonCfg.TxPreamble = Preamble;
610 #ifdef CONFIG_STA_SUPPORT
611 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
612 MlmeSetTxPreamble(pAd, Rt802_11PreambleLong);
613 #endif // CONFIG_STA_SUPPORT //
614 break;
615 default: //Invalid argument
616 return FALSE;
619 DBGPRINT(RT_DEBUG_TRACE, ("Set_TxPreamble_Proc::(TxPreamble=%ld)\n", pAd->CommonCfg.TxPreamble));
621 return TRUE;
625 ==========================================================================
626 Description:
627 Set RTS Threshold
628 Return:
629 TRUE if all parameters are OK, FALSE otherwise
630 ==========================================================================
632 INT Set_RTSThreshold_Proc(
633 IN PRTMP_ADAPTER pAd,
634 IN PUCHAR arg)
636 NDIS_802_11_RTS_THRESHOLD RtsThresh;
638 RtsThresh = simple_strtol(arg, 0, 10);
640 if((RtsThresh > 0) && (RtsThresh <= MAX_RTS_THRESHOLD))
641 pAd->CommonCfg.RtsThreshold = (USHORT)RtsThresh;
642 #ifdef CONFIG_STA_SUPPORT
643 else if (RtsThresh == 0)
644 pAd->CommonCfg.RtsThreshold = MAX_RTS_THRESHOLD;
645 #endif // CONFIG_STA_SUPPORT //
646 else
647 return FALSE; //Invalid argument
649 DBGPRINT(RT_DEBUG_TRACE, ("Set_RTSThreshold_Proc::(RTSThreshold=%d)\n", pAd->CommonCfg.RtsThreshold));
651 return TRUE;
655 ==========================================================================
656 Description:
657 Set Fragment Threshold
658 Return:
659 TRUE if all parameters are OK, FALSE otherwise
660 ==========================================================================
662 INT Set_FragThreshold_Proc(
663 IN PRTMP_ADAPTER pAd,
664 IN PUCHAR arg)
666 NDIS_802_11_FRAGMENTATION_THRESHOLD FragThresh;
668 FragThresh = simple_strtol(arg, 0, 10);
670 if (FragThresh > MAX_FRAG_THRESHOLD || FragThresh < MIN_FRAG_THRESHOLD)
672 //Illegal FragThresh so we set it to default
673 pAd->CommonCfg.FragmentThreshold = MAX_FRAG_THRESHOLD;
675 else if (FragThresh % 2 == 1)
677 // The length of each fragment shall always be an even number of octets, except for the last fragment
678 // of an MSDU or MMPDU, which may be either an even or an odd number of octets.
679 pAd->CommonCfg.FragmentThreshold = (USHORT)(FragThresh - 1);
681 else
683 pAd->CommonCfg.FragmentThreshold = (USHORT)FragThresh;
686 #ifdef CONFIG_STA_SUPPORT
687 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
689 if (pAd->CommonCfg.FragmentThreshold == MAX_FRAG_THRESHOLD)
690 pAd->CommonCfg.bUseZeroToDisableFragment = TRUE;
691 else
692 pAd->CommonCfg.bUseZeroToDisableFragment = FALSE;
694 #endif // CONFIG_STA_SUPPORT //
696 DBGPRINT(RT_DEBUG_TRACE, ("Set_FragThreshold_Proc::(FragThreshold=%d)\n", pAd->CommonCfg.FragmentThreshold));
698 return TRUE;
702 ==========================================================================
703 Description:
704 Set TxBurst
705 Return:
706 TRUE if all parameters are OK, FALSE otherwise
707 ==========================================================================
709 INT Set_TxBurst_Proc(
710 IN PRTMP_ADAPTER pAd,
711 IN PUCHAR arg)
713 ULONG TxBurst;
715 TxBurst = simple_strtol(arg, 0, 10);
716 if (TxBurst == 1)
717 pAd->CommonCfg.bEnableTxBurst = TRUE;
718 else if (TxBurst == 0)
719 pAd->CommonCfg.bEnableTxBurst = FALSE;
720 else
721 return FALSE; //Invalid argument
723 DBGPRINT(RT_DEBUG_TRACE, ("Set_TxBurst_Proc::(TxBurst=%d)\n", pAd->CommonCfg.bEnableTxBurst));
725 return TRUE;
728 #ifdef AGGREGATION_SUPPORT
730 ==========================================================================
731 Description:
732 Set TxBurst
733 Return:
734 TRUE if all parameters are OK, FALSE otherwise
735 ==========================================================================
737 INT Set_PktAggregate_Proc(
738 IN PRTMP_ADAPTER pAd,
739 IN PUCHAR arg)
741 ULONG aggre;
743 aggre = simple_strtol(arg, 0, 10);
745 if (aggre == 1)
746 pAd->CommonCfg.bAggregationCapable = TRUE;
747 else if (aggre == 0)
748 pAd->CommonCfg.bAggregationCapable = FALSE;
749 else
750 return FALSE; //Invalid argument
753 DBGPRINT(RT_DEBUG_TRACE, ("Set_PktAggregate_Proc::(AGGRE=%d)\n", pAd->CommonCfg.bAggregationCapable));
755 return TRUE;
757 #endif
760 ==========================================================================
761 Description:
762 Set IEEE80211H.
763 This parameter is 1 when needs radar detection, otherwise 0
764 Return:
765 TRUE if all parameters are OK, FALSE otherwise
766 ==========================================================================
768 INT Set_IEEE80211H_Proc(
769 IN PRTMP_ADAPTER pAd,
770 IN PUCHAR arg)
772 ULONG ieee80211h;
774 ieee80211h = simple_strtol(arg, 0, 10);
776 if (ieee80211h == 1)
777 pAd->CommonCfg.bIEEE80211H = TRUE;
778 else if (ieee80211h == 0)
779 pAd->CommonCfg.bIEEE80211H = FALSE;
780 else
781 return FALSE; //Invalid argument
783 DBGPRINT(RT_DEBUG_TRACE, ("Set_IEEE80211H_Proc::(IEEE80211H=%d)\n", pAd->CommonCfg.bIEEE80211H));
785 return TRUE;
789 #ifdef DBG
791 ==========================================================================
792 Description:
793 For Debug information
794 Return:
795 TRUE if all parameters are OK, FALSE otherwise
796 ==========================================================================
798 INT Set_Debug_Proc(
799 IN PRTMP_ADAPTER pAd,
800 IN PUCHAR arg)
802 DBGPRINT(RT_DEBUG_TRACE, ("==> Set_Debug_Proc *******************\n"));
804 if(simple_strtol(arg, 0, 10) <= RT_DEBUG_LOUD)
805 RTDebugLevel = simple_strtol(arg, 0, 10);
807 DBGPRINT(RT_DEBUG_TRACE, ("<== Set_Debug_Proc(RTDebugLevel = %ld)\n", RTDebugLevel));
809 return TRUE;
811 #endif
813 INT Show_DescInfo_Proc(
814 IN PRTMP_ADAPTER pAd,
815 IN PUCHAR arg)
818 return TRUE;
822 ==========================================================================
823 Description:
824 Reset statistics counter
826 Arguments:
827 pAdapter Pointer to our adapter
830 Return:
831 TRUE if all parameters are OK, FALSE otherwise
832 ==========================================================================
834 INT Set_ResetStatCounter_Proc(
835 IN PRTMP_ADAPTER pAd,
836 IN PUCHAR arg)
838 //UCHAR i;
839 //MAC_TABLE_ENTRY *pEntry;
841 DBGPRINT(RT_DEBUG_TRACE, ("==>Set_ResetStatCounter_Proc\n"));
843 // add the most up-to-date h/w raw counters into software counters
844 NICUpdateRawCounters(pAd);
846 NdisZeroMemory(&pAd->WlanCounters, sizeof(COUNTER_802_11));
847 NdisZeroMemory(&pAd->Counters8023, sizeof(COUNTER_802_3));
848 NdisZeroMemory(&pAd->RalinkCounters, sizeof(COUNTER_RALINK));
850 // Reset HotSpot counter
851 #if 0 // ToDo.
852 for (i = 0; i < MAX_LEN_OF_MAC_TABLE; i++)
854 pEntry = &pAd->MacTab.Content[i];
856 if ((pEntry->Valid == FALSE) || (pEntry->Sst != SST_ASSOC))
857 continue;
859 pEntry->HSCounter.LastDataPacketTime = 0;
860 pEntry->HSCounter.TotalRxByteCount= 0;
861 pEntry->HSCounter.TotalTxByteCount= 0;
863 #endif
866 return TRUE;
870 ========================================================================
872 Routine Description:
873 Add WPA key process.
874 In Adhoc WPANONE, bPairwise = 0; KeyIdx = 0;
876 Arguments:
877 pAd Pointer to our adapter
878 pBuf Pointer to the where the key stored
880 Return Value:
881 NDIS_SUCCESS Add key successfully
883 IRQL = DISPATCH_LEVEL
885 Note:
887 ========================================================================
889 #if 0 // remove by AlbertY
890 NDIS_STATUS RTMPWPAAddKeyProc(
891 IN PRTMP_ADAPTER pAd,
892 IN PVOID pBuf)
894 PNDIS_802_11_KEY pKey;
895 ULONG KeyIdx;
896 // NDIS_STATUS Status;
897 // ULONG offset; // unused variable, snowpin 2006.07.13
899 PUCHAR pTxMic, pRxMic;
900 BOOLEAN bTxKey; // Set the key as transmit key
901 BOOLEAN bPairwise; // Indicate the key is pairwise key
902 BOOLEAN bKeyRSC; // indicate the receive SC set by KeyRSC value.
903 // Otherwise, it will set by the NIC.
904 BOOLEAN bAuthenticator; // indicate key is set by authenticator.
905 UCHAR apidx = BSS0;
907 pKey = (PNDIS_802_11_KEY) pBuf;
908 KeyIdx = pKey->KeyIndex & 0xff;
909 // Bit 31 of Add-key, Tx Key
910 bTxKey = (pKey->KeyIndex & 0x80000000) ? TRUE : FALSE;
911 // Bit 30 of Add-key PairwiseKey
912 bPairwise = (pKey->KeyIndex & 0x40000000) ? TRUE : FALSE;
913 // Bit 29 of Add-key KeyRSC
914 bKeyRSC = (pKey->KeyIndex & 0x20000000) ? TRUE : FALSE;
915 // Bit 28 of Add-key Authenticator
916 bAuthenticator = (pKey->KeyIndex & 0x10000000) ? TRUE : FALSE;
918 DBGPRINT(RT_DEBUG_TRACE,("RTMPWPAAddKeyProc==>pKey->KeyIndex = %x. bPairwise= %d\n", pKey->KeyIndex, bPairwise));
919 // 1. Check Group / Pairwise Key
920 if (bPairwise) // Pairwise Key
922 // 1. KeyIdx must be 0, otherwise, return NDIS_STATUS_INVALID_DATA
923 if (KeyIdx != 0)
924 return(NDIS_STATUS_INVALID_DATA);
926 // 2. Check bTx, it must be true, otherwise, return NDIS_STATUS_INVALID_DATA
927 if (bTxKey == FALSE)
928 return(NDIS_STATUS_INVALID_DATA);
930 // 3. If BSSID is all 0xff, return NDIS_STATUS_INVALID_DATA
931 if (MAC_ADDR_EQUAL(pKey->BSSID, BROADCAST_ADDR))
932 return(NDIS_STATUS_INVALID_DATA);
934 // 3.1 Check Pairwise key length for TKIP key. For AES, it's always 128 bits
935 //if ((pAdapter->PortCfg.WepStatus == Ndis802_11Encryption2Enabled) && (pKey->KeyLength != LEN_TKIP_KEY))
936 if ((pAd->StaCfg.PairCipher == Ndis802_11Encryption2Enabled) && (pKey->KeyLength != LEN_TKIP_KEY))
937 return(NDIS_STATUS_INVALID_DATA);
939 pAd->SharedKey[apidx][KeyIdx].Type = PAIRWISE_KEY;
941 if (pAd->ApCfg.MBSSID[apidx].AuthMode == Ndis802_11AuthModeWPA2)
943 // Send media specific event to start PMKID caching
944 RTMPIndicateWPA2Status(pAd);
947 else
949 // 1. Check BSSID, if not current BSSID or Bcast, return NDIS_STATUS_INVALID_DATA
950 if ((! MAC_ADDR_EQUAL(pKey->BSSID, BROADCAST_ADDR)) &&
951 (! MAC_ADDR_EQUAL(pKey->BSSID, pAd->ApCfg.MBSSID[apidx].Bssid)))
952 return(NDIS_STATUS_INVALID_DATA);
954 // 2. Check Key index for supported Group Key
955 if (KeyIdx >= GROUP_KEY_NUM)
956 return(NDIS_STATUS_INVALID_DATA);
958 // 3. Set as default Tx Key if bTxKey is TRUE
959 if (bTxKey == TRUE)
960 pAd->ApCfg.MBSSID[apidx].DefaultKeyId = (UCHAR) KeyIdx;
962 pAd->SharedKey[apidx][KeyIdx].Type = GROUP_KEY;
965 // 4. Select RxMic / TxMic based on Supp / Authenticator
966 if (pAd->ApCfg.MBSSID[apidx].AuthMode == Ndis802_11AuthModeWPANone)
968 // for WPA-None Tx, Rx MIC is the same
969 pTxMic = (PUCHAR) (&pKey->KeyMaterial) + 16;
970 pRxMic = pTxMic;
972 else if (bAuthenticator == TRUE)
974 pTxMic = (PUCHAR) (&pKey->KeyMaterial) + 16;
975 pRxMic = (PUCHAR) (&pKey->KeyMaterial) + 24;
977 else
979 pRxMic = (PUCHAR) (&pKey->KeyMaterial) + 16;
980 pTxMic = (PUCHAR) (&pKey->KeyMaterial) + 24;
983 // 6. Check RxTsc
984 if (bKeyRSC == TRUE)
986 NdisMoveMemory(pAd->SharedKey[apidx][KeyIdx].RxTsc, &pKey->KeyRSC, 6);
987 NdisMoveMemory(pAd->MacTab.Content[BSSID_WCID].PairwiseKey.RxTsc, &pKey->KeyRSC, 6);
989 else
991 NdisZeroMemory(pAd->SharedKey[apidx][KeyIdx].RxTsc, 6);
994 // 7. Copy information into Pairwise Key structure.
995 // pKey->KeyLength will include TxMic and RxMic, therefore, we use 16 bytes hardcoded.
996 pAd->SharedKey[apidx][KeyIdx].KeyLen = (UCHAR) pKey->KeyLength;
997 pAd->MacTab.Content[BSSID_WCID].PairwiseKey.KeyLen = (UCHAR)pKey->KeyLength;
998 NdisMoveMemory(pAd->SharedKey[BSS0][KeyIdx].Key, &pKey->KeyMaterial, 16);
999 NdisMoveMemory(pAd->MacTab.Content[BSSID_WCID].PairwiseKey.Key, &pKey->KeyMaterial, 16);
1000 if (pKey->KeyLength == LEN_TKIP_KEY)
1002 // Only Key lenth equal to TKIP key have these
1003 NdisMoveMemory(pAd->SharedKey[apidx][KeyIdx].RxMic, pRxMic, 8);
1004 NdisMoveMemory(pAd->SharedKey[apidx][KeyIdx].TxMic, pTxMic, 8);
1005 NdisMoveMemory(pAd->MacTab.Content[BSSID_WCID].PairwiseKey.RxMic, pRxMic, 8);
1006 NdisMoveMemory(pAd->MacTab.Content[BSSID_WCID].PairwiseKey.TxMic, pTxMic, 8);
1009 COPY_MAC_ADDR(pAd->SharedKey[BSS0][KeyIdx].BssId, pKey->BSSID);
1011 // Init TxTsc to one based on WiFi WPA specs
1012 pAd->SharedKey[apidx][KeyIdx].TxTsc[0] = 1;
1013 pAd->SharedKey[apidx][KeyIdx].TxTsc[1] = 0;
1014 pAd->SharedKey[apidx][KeyIdx].TxTsc[2] = 0;
1015 pAd->SharedKey[apidx][KeyIdx].TxTsc[3] = 0;
1016 pAd->SharedKey[apidx][KeyIdx].TxTsc[4] = 0;
1017 pAd->SharedKey[apidx][KeyIdx].TxTsc[5] = 0;
1018 // 4. Init TxTsc to one based on WiFi WPA specs
1019 pAd->MacTab.Content[BSSID_WCID].PairwiseKey.TxTsc[0] = 1;
1020 pAd->MacTab.Content[BSSID_WCID].PairwiseKey.TxTsc[1] = 0;
1021 pAd->MacTab.Content[BSSID_WCID].PairwiseKey.TxTsc[2] = 0;
1022 pAd->MacTab.Content[BSSID_WCID].PairwiseKey.TxTsc[3] = 0;
1023 pAd->MacTab.Content[BSSID_WCID].PairwiseKey.TxTsc[4] = 0;
1024 pAd->MacTab.Content[BSSID_WCID].PairwiseKey.TxTsc[5] = 0;
1026 if (pAd->ApCfg.MBSSID[apidx].WepStatus == Ndis802_11Encryption3Enabled)
1028 pAd->SharedKey[apidx][KeyIdx].CipherAlg = CIPHER_AES;
1029 pAd->MacTab.Content[BSSID_WCID].PairwiseKey.CipherAlg = CIPHER_AES;
1031 else if (pAd->ApCfg.MBSSID[apidx].WepStatus == Ndis802_11Encryption2Enabled)
1033 pAd->SharedKey[apidx][KeyIdx].CipherAlg = CIPHER_TKIP;
1034 pAd->MacTab.Content[BSSID_WCID].PairwiseKey.CipherAlg = CIPHER_TKIP;
1036 else if (pAd->ApCfg.MBSSID[apidx].WepStatus == Ndis802_11Encryption1Enabled)
1038 if (pAd->SharedKey[apidx][KeyIdx].KeyLen == 5)
1040 pAd->SharedKey[apidx][KeyIdx].CipherAlg = CIPHER_WEP64;
1041 pAd->MacTab.Content[BSSID_WCID].PairwiseKey.CipherAlg = CIPHER_WEP64;
1043 else if (pAd->SharedKey[apidx][KeyIdx].KeyLen == 13)
1045 pAd->SharedKey[apidx][KeyIdx].CipherAlg = CIPHER_WEP128;
1046 pAd->MacTab.Content[BSSID_WCID].PairwiseKey.CipherAlg = CIPHER_WEP128;
1048 else
1050 pAd->SharedKey[apidx][KeyIdx].CipherAlg = CIPHER_NONE;
1051 pAd->MacTab.Content[BSSID_WCID].PairwiseKey.CipherAlg = CIPHER_NONE;
1054 else
1056 pAd->SharedKey[apidx][KeyIdx].CipherAlg = CIPHER_NONE;
1057 pAd->MacTab.Content[BSSID_WCID].PairwiseKey.CipherAlg = CIPHER_NONE;
1060 if ((pAd->OpMode == OPMODE_STA)) // Pairwise Key. Add BSSID to WCTable
1062 pAd->MacTab.Content[BSSID_WCID].PairwiseKey.CipherAlg = pAd->SharedKey[BSS0][KeyIdx].CipherAlg;
1063 pAd->MacTab.Content[BSSID_WCID].PairwiseKey.KeyLen = pAd->SharedKey[BSS0][KeyIdx].KeyLen;
1066 if ((pAd->ApCfg.MBSSID[apidx].AuthMode == Ndis802_11AuthModeWPA2) ||
1067 (pAd->ApCfg.MBSSID[apidx].AuthMode == Ndis802_11AuthModeWPA2PSK))
1070 // On WPA2, Update Group Key Cipher.
1072 if (!bPairwise)
1074 if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption3Enabled)
1075 pAd->SharedKey[apidx][KeyIdx].CipherAlg = CIPHER_AES;
1076 else if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption2Enabled)
1077 pAd->SharedKey[apidx][KeyIdx].CipherAlg = CIPHER_TKIP;
1081 DBGPRINT(RT_DEBUG_TRACE, ("pAd->SharedKey[%d][%d].CipherAlg = %d\n", apidx, KeyIdx, pAd->SharedKey[apidx][KeyIdx].CipherAlg));
1083 #if 0
1084 DBGPRINT_RAW(RT_DEBUG_TRACE, ("%s Key #%d", CipherName[pAd->SharedKey[apidx][KeyIdx].CipherAlg],KeyIdx));
1085 for (i = 0; i < 16; i++)
1087 DBGPRINT_RAW(RT_DEBUG_TRACE, ("%02x:", pAd->SharedKey[apidx][KeyIdx].Key[i]));
1089 DBGPRINT_RAW(RT_DEBUG_TRACE, ("\n Rx MIC Key = "));
1090 for (i = 0; i < 8; i++)
1092 DBGPRINT_RAW(RT_DEBUG_TRACE, ("%02x:", pAd->SharedKey[apidx][KeyIdx].RxMic[i]));
1094 DBGPRINT_RAW(RT_DEBUG_TRACE, ("\n Tx MIC Key = "));
1095 for (i = 0; i < 8; i++)
1097 DBGPRINT_RAW(RT_DEBUG_TRACE, ("%02x:", pAd->SharedKey[apidx][KeyIdx].TxMic[i]));
1099 DBGPRINT_RAW(RT_DEBUG_TRACE, ("\n RxTSC = "));
1100 for (i = 0; i < 6; i++)
1102 DBGPRINT_RAW(RT_DEBUG_TRACE, ("%02x:", pAd->SharedKey[apidx][KeyIdx].RxTsc[i]));
1104 #endif
1105 DBGPRINT_RAW(RT_DEBUG_TRACE, ("\n pKey-> BSSID:%02x:%02x:%02x:%02x:%02x:%02x \n",
1106 pKey->BSSID[0],pKey->BSSID[1],pKey->BSSID[2],pKey->BSSID[3],pKey->BSSID[4],pKey->BSSID[5]));
1108 if ((bTxKey) && (pAd->OpMode == OPMODE_STA)) // Pairwise Key. Add BSSID to WCTable
1109 RTMPAddBSSIDCipher(pAd, BSSID_WCID, pKey, pAd->SharedKey[BSS0][KeyIdx].CipherAlg);
1112 // No matter pairwise key or what leyidx is, always has a copy at on-chip SharedKeytable.
1113 AsicAddSharedKeyEntry(pAd,
1114 apidx,
1115 (UCHAR)KeyIdx,
1116 pAd->SharedKey[apidx][KeyIdx].CipherAlg,
1117 pAd->SharedKey[apidx][KeyIdx].Key,
1118 pAd->SharedKey[apidx][KeyIdx].TxMic,
1119 pAd->SharedKey[apidx][KeyIdx].RxMic);
1121 // The WCID key specified in used at Tx. For STA, always use pairwise key.
1123 // ad-hoc mode need to specify WAP Group key with WCID index=BSS0Mcast_WCID. Let's always set this key here.
1124 /* if (bPairwise == FALSE)
1126 offset = MAC_IVEIV_TABLE_BASE + (BSS0Mcast_WCID * HW_IVEIV_ENTRY_SIZE);
1127 NdisZeroMemory(IVEIV, 8);
1128 // 1. IV/EIV
1129 // Specify key index to find shared key.
1130 if ((pAd->SharedKey[BSS0][KeyIdx].CipherAlg==CIPHER_TKIP) ||
1131 (pAd->SharedKey[BSS0][KeyIdx].CipherAlg==CIPHER_AES))
1132 IVEIV[3] = 0x20; // Eiv bit on. keyid always 0 for pairwise key
1133 IVEIV[3] |= (KeyIdx<< 6); // groupkey index is not 0
1134 for (i=0; i<8; i++)
1136 RTMP_IO_WRITE8(pAd, offset+i, IVEIV[i]);
1139 // 2. WCID Attribute UDF:3, BSSIdx:3, Alg:3, Keytable:use share key, BSSIdx is 0
1140 WCIDAttri = (pAd->SharedKey[BSS0][KeyIdx].CipherAlg<<1)|PAIRWISEKEYTABLE;
1141 offset = MAC_WCID_ATTRIBUTE_BASE + (BSS0Mcast_WCID* HW_WCID_ATTRI_SIZE);
1142 RTMP_IO_WRITE32(pAd, offset, WCIDAttri);
1148 if (pAd->SharedKey[apidx][KeyIdx].Type == GROUP_KEY)
1150 // 802.1x port control
1151 pAd->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
1152 DBGPRINT(RT_DEBUG_TRACE,("!!WPA_802_1X_PORT_SECURED!!\n"));
1156 return (NDIS_STATUS_SUCCESS);
1158 #endif
1160 BOOLEAN RTMPCheckStrPrintAble(
1161 IN CHAR *pInPutStr,
1162 IN UCHAR strLen)
1164 UCHAR i=0;
1166 for (i=0; i<strLen; i++)
1168 if ((pInPutStr[i] < 0x21) ||
1169 (pInPutStr[i] > 0x7E))
1170 return FALSE;
1173 return TRUE;
1177 ========================================================================
1179 Routine Description:
1180 Remove WPA Key process
1182 Arguments:
1183 pAd Pointer to our adapter
1184 pBuf Pointer to the where the key stored
1186 Return Value:
1187 NDIS_SUCCESS Add key successfully
1189 IRQL = DISPATCH_LEVEL
1191 Note:
1193 ========================================================================
1195 #ifdef CONFIG_STA_SUPPORT
1196 VOID RTMPSetDesiredRates(
1197 IN PRTMP_ADAPTER pAdapter,
1198 IN LONG Rates)
1200 NDIS_802_11_RATES aryRates;
1202 memset(&aryRates, 0x00, sizeof(NDIS_802_11_RATES));
1203 switch (pAdapter->CommonCfg.PhyMode)
1205 case PHY_11A: // A only
1206 switch (Rates)
1208 case 6000000: //6M
1209 aryRates[0] = 0x0c; // 6M
1210 pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_0;
1211 break;
1212 case 9000000: //9M
1213 aryRates[0] = 0x12; // 9M
1214 pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_1;
1215 break;
1216 case 12000000: //12M
1217 aryRates[0] = 0x18; // 12M
1218 pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_2;
1219 break;
1220 case 18000000: //18M
1221 aryRates[0] = 0x24; // 18M
1222 pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_3;
1223 break;
1224 case 24000000: //24M
1225 aryRates[0] = 0x30; // 24M
1226 pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_4;
1227 break;
1228 case 36000000: //36M
1229 aryRates[0] = 0x48; // 36M
1230 pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_5;
1231 break;
1232 case 48000000: //48M
1233 aryRates[0] = 0x60; // 48M
1234 pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_6;
1235 break;
1236 case 54000000: //54M
1237 aryRates[0] = 0x6c; // 54M
1238 pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_7;
1239 break;
1240 case -1: //Auto
1241 default:
1242 aryRates[0] = 0x6c; // 54Mbps
1243 aryRates[1] = 0x60; // 48Mbps
1244 aryRates[2] = 0x48; // 36Mbps
1245 aryRates[3] = 0x30; // 24Mbps
1246 aryRates[4] = 0x24; // 18M
1247 aryRates[5] = 0x18; // 12M
1248 aryRates[6] = 0x12; // 9M
1249 aryRates[7] = 0x0c; // 6M
1250 pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_AUTO;
1251 break;
1253 break;
1254 case PHY_11BG_MIXED: // B/G Mixed
1255 case PHY_11B: // B only
1256 case PHY_11ABG_MIXED: // A/B/G Mixed
1257 default:
1258 switch (Rates)
1260 case 1000000: //1M
1261 aryRates[0] = 0x02;
1262 pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_0;
1263 break;
1264 case 2000000: //2M
1265 aryRates[0] = 0x04;
1266 pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_1;
1267 break;
1268 case 5000000: //5.5M
1269 aryRates[0] = 0x0b; // 5.5M
1270 pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_2;
1271 break;
1272 case 11000000: //11M
1273 aryRates[0] = 0x16; // 11M
1274 pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_3;
1275 break;
1276 case 6000000: //6M
1277 aryRates[0] = 0x0c; // 6M
1278 pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_0;
1279 break;
1280 case 9000000: //9M
1281 aryRates[0] = 0x12; // 9M
1282 pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_1;
1283 break;
1284 case 12000000: //12M
1285 aryRates[0] = 0x18; // 12M
1286 pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_2;
1287 break;
1288 case 18000000: //18M
1289 aryRates[0] = 0x24; // 18M
1290 pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_3;
1291 break;
1292 case 24000000: //24M
1293 aryRates[0] = 0x30; // 24M
1294 pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_4;
1295 break;
1296 case 36000000: //36M
1297 aryRates[0] = 0x48; // 36M
1298 pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_5;
1299 break;
1300 case 48000000: //48M
1301 aryRates[0] = 0x60; // 48M
1302 pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_6;
1303 break;
1304 case 54000000: //54M
1305 aryRates[0] = 0x6c; // 54M
1306 pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_7;
1307 break;
1308 case -1: //Auto
1309 default:
1310 if (pAdapter->CommonCfg.PhyMode == PHY_11B)
1311 { //B Only
1312 aryRates[0] = 0x16; // 11Mbps
1313 aryRates[1] = 0x0b; // 5.5Mbps
1314 aryRates[2] = 0x04; // 2Mbps
1315 aryRates[3] = 0x02; // 1Mbps
1317 else
1318 { //(B/G) Mixed or (A/B/G) Mixed
1319 aryRates[0] = 0x6c; // 54Mbps
1320 aryRates[1] = 0x60; // 48Mbps
1321 aryRates[2] = 0x48; // 36Mbps
1322 aryRates[3] = 0x30; // 24Mbps
1323 aryRates[4] = 0x16; // 11Mbps
1324 aryRates[5] = 0x0b; // 5.5Mbps
1325 aryRates[6] = 0x04; // 2Mbps
1326 aryRates[7] = 0x02; // 1Mbps
1328 pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_AUTO;
1329 break;
1331 break;
1334 NdisZeroMemory(pAdapter->CommonCfg.DesireRate, MAX_LEN_OF_SUPPORTED_RATES);
1335 NdisMoveMemory(pAdapter->CommonCfg.DesireRate, &aryRates, sizeof(NDIS_802_11_RATES));
1336 DBGPRINT(RT_DEBUG_TRACE, (" RTMPSetDesiredRates (%02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x)\n",
1337 pAdapter->CommonCfg.DesireRate[0],pAdapter->CommonCfg.DesireRate[1],
1338 pAdapter->CommonCfg.DesireRate[2],pAdapter->CommonCfg.DesireRate[3],
1339 pAdapter->CommonCfg.DesireRate[4],pAdapter->CommonCfg.DesireRate[5],
1340 pAdapter->CommonCfg.DesireRate[6],pAdapter->CommonCfg.DesireRate[7] ));
1341 // Changing DesiredRate may affect the MAX TX rate we used to TX frames out
1342 MlmeUpdateTxRates(pAdapter, FALSE, 0);
1345 NDIS_STATUS RTMPWPARemoveKeyProc(
1346 IN PRTMP_ADAPTER pAd,
1347 IN PVOID pBuf)
1349 PNDIS_802_11_REMOVE_KEY pKey;
1350 ULONG KeyIdx;
1351 NDIS_STATUS Status = NDIS_STATUS_FAILURE;
1352 BOOLEAN bTxKey; // Set the key as transmit key
1353 BOOLEAN bPairwise; // Indicate the key is pairwise key
1354 BOOLEAN bKeyRSC; // indicate the receive SC set by KeyRSC value.
1355 // Otherwise, it will set by the NIC.
1356 BOOLEAN bAuthenticator; // indicate key is set by authenticator.
1357 INT i;
1359 DBGPRINT(RT_DEBUG_TRACE,("---> RTMPWPARemoveKeyProc\n"));
1361 pKey = (PNDIS_802_11_REMOVE_KEY) pBuf;
1362 KeyIdx = pKey->KeyIndex & 0xff;
1363 // Bit 31 of Add-key, Tx Key
1364 bTxKey = (pKey->KeyIndex & 0x80000000) ? TRUE : FALSE;
1365 // Bit 30 of Add-key PairwiseKey
1366 bPairwise = (pKey->KeyIndex & 0x40000000) ? TRUE : FALSE;
1367 // Bit 29 of Add-key KeyRSC
1368 bKeyRSC = (pKey->KeyIndex & 0x20000000) ? TRUE : FALSE;
1369 // Bit 28 of Add-key Authenticator
1370 bAuthenticator = (pKey->KeyIndex & 0x10000000) ? TRUE : FALSE;
1372 // 1. If bTx is TRUE, return failure information
1373 if (bTxKey == TRUE)
1374 return(NDIS_STATUS_INVALID_DATA);
1376 // 2. Check Pairwise Key
1377 if (bPairwise)
1379 // a. If BSSID is broadcast, remove all pairwise keys.
1380 // b. If not broadcast, remove the pairwise specified by BSSID
1381 for (i = 0; i < SHARE_KEY_NUM; i++)
1383 if (MAC_ADDR_EQUAL(pAd->SharedKey[BSS0][i].BssId, pKey->BSSID))
1385 DBGPRINT(RT_DEBUG_TRACE,("RTMPWPARemoveKeyProc(KeyIdx=%d)\n", i));
1386 pAd->SharedKey[BSS0][i].KeyLen = 0;
1387 pAd->SharedKey[BSS0][i].CipherAlg = CIPHER_NONE;
1388 AsicRemoveSharedKeyEntry(pAd, BSS0, (UCHAR)i);
1389 Status = NDIS_STATUS_SUCCESS;
1390 break;
1394 // 3. Group Key
1395 else
1397 // a. If BSSID is broadcast, remove all group keys indexed
1398 // b. If BSSID matched, delete the group key indexed.
1399 DBGPRINT(RT_DEBUG_TRACE,("RTMPWPARemoveKeyProc(KeyIdx=%ld)\n", KeyIdx));
1400 pAd->SharedKey[BSS0][KeyIdx].KeyLen = 0;
1401 pAd->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_NONE;
1402 AsicRemoveSharedKeyEntry(pAd, BSS0, (UCHAR)KeyIdx);
1403 Status = NDIS_STATUS_SUCCESS;
1406 return (Status);
1408 #endif // CONFIG_STA_SUPPORT //
1411 #ifdef CONFIG_STA_SUPPORT
1413 ========================================================================
1415 Routine Description:
1416 Remove All WPA Keys
1418 Arguments:
1419 pAd Pointer to our adapter
1421 Return Value:
1422 None
1424 IRQL = DISPATCH_LEVEL
1426 Note:
1428 ========================================================================
1430 VOID RTMPWPARemoveAllKeys(
1431 IN PRTMP_ADAPTER pAd)
1434 UCHAR i;
1436 DBGPRINT(RT_DEBUG_TRACE,("RTMPWPARemoveAllKeys(AuthMode=%d, WepStatus=%d)\n", pAd->StaCfg.AuthMode, pAd->StaCfg.WepStatus));
1438 // For WEP/CKIP, there is no need to remove it, since WinXP won't set it again after
1439 // Link up. And it will be replaced if user changed it.
1440 if (pAd->StaCfg.AuthMode < Ndis802_11AuthModeWPA)
1441 return;
1443 // For WPA-None, there is no need to remove it, since WinXP won't set it again after
1444 // Link up. And it will be replaced if user changed it.
1445 if (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPANone)
1446 return;
1448 // set BSSID wcid entry of the Pair-wise Key table as no-security mode
1449 AsicRemovePairwiseKeyEntry(pAd, BSS0, BSSID_WCID);
1451 // set all shared key mode as no-security.
1452 for (i = 0; i < SHARE_KEY_NUM; i++)
1454 DBGPRINT(RT_DEBUG_TRACE,("remove %s key #%d\n", CipherName[pAd->SharedKey[BSS0][i].CipherAlg], i));
1455 NdisZeroMemory(&pAd->SharedKey[BSS0][i], sizeof(CIPHER_KEY));
1457 AsicRemoveSharedKeyEntry(pAd, BSS0, i);
1461 #endif // CONFIG_STA_SUPPORT //
1464 ========================================================================
1465 Routine Description:
1466 Change NIC PHY mode. Re-association may be necessary. possible settings
1467 include - PHY_11B, PHY_11BG_MIXED, PHY_11A, and PHY_11ABG_MIXED
1469 Arguments:
1470 pAd - Pointer to our adapter
1471 phymode -
1473 IRQL = PASSIVE_LEVEL
1474 IRQL = DISPATCH_LEVEL
1476 ========================================================================
1478 VOID RTMPSetPhyMode(
1479 IN PRTMP_ADAPTER pAd,
1480 IN ULONG phymode)
1482 INT i;
1483 // the selected phymode must be supported by the RF IC encoded in E2PROM
1485 // if no change, do nothing
1486 /* bug fix
1487 if (pAd->CommonCfg.PhyMode == phymode)
1488 return;
1490 pAd->CommonCfg.PhyMode = (UCHAR)phymode;
1492 DBGPRINT(RT_DEBUG_TRACE,("RTMPSetPhyMode : PhyMode=%d, channel=%d \n", pAd->CommonCfg.PhyMode, pAd->CommonCfg.Channel));
1493 #ifdef EXT_BUILD_CHANNEL_LIST
1494 BuildChannelListEx(pAd);
1495 #else
1496 BuildChannelList(pAd);
1497 #endif // EXT_BUILD_CHANNEL_LIST //
1499 // sanity check user setting
1500 for (i = 0; i < pAd->ChannelListNum; i++)
1502 if (pAd->CommonCfg.Channel == pAd->ChannelList[i].Channel)
1503 break;
1506 if (i == pAd->ChannelListNum)
1508 #ifdef CONFIG_STA_SUPPORT
1509 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
1510 pAd->CommonCfg.Channel = FirstChannel(pAd);
1511 #endif // CONFIG_STA_SUPPORT //
1512 DBGPRINT(RT_DEBUG_ERROR, ("RTMPSetPhyMode: channel is out of range, use first channel=%d \n", pAd->CommonCfg.Channel));
1515 NdisZeroMemory(pAd->CommonCfg.SupRate, MAX_LEN_OF_SUPPORTED_RATES);
1516 NdisZeroMemory(pAd->CommonCfg.ExtRate, MAX_LEN_OF_SUPPORTED_RATES);
1517 NdisZeroMemory(pAd->CommonCfg.DesireRate, MAX_LEN_OF_SUPPORTED_RATES);
1518 switch (phymode) {
1519 case PHY_11B:
1520 pAd->CommonCfg.SupRate[0] = 0x82; // 1 mbps, in units of 0.5 Mbps, basic rate
1521 pAd->CommonCfg.SupRate[1] = 0x84; // 2 mbps, in units of 0.5 Mbps, basic rate
1522 pAd->CommonCfg.SupRate[2] = 0x8B; // 5.5 mbps, in units of 0.5 Mbps, basic rate
1523 pAd->CommonCfg.SupRate[3] = 0x96; // 11 mbps, in units of 0.5 Mbps, basic rate
1524 pAd->CommonCfg.SupRateLen = 4;
1525 pAd->CommonCfg.ExtRateLen = 0;
1526 pAd->CommonCfg.DesireRate[0] = 2; // 1 mbps, in units of 0.5 Mbps
1527 pAd->CommonCfg.DesireRate[1] = 4; // 2 mbps, in units of 0.5 Mbps
1528 pAd->CommonCfg.DesireRate[2] = 11; // 5.5 mbps, in units of 0.5 Mbps
1529 pAd->CommonCfg.DesireRate[3] = 22; // 11 mbps, in units of 0.5 Mbps
1530 //pAd->CommonCfg.HTPhyMode.field.MODE = MODE_CCK; // This MODE is only FYI. not use
1531 break;
1533 case PHY_11G:
1534 case PHY_11BG_MIXED:
1535 case PHY_11ABG_MIXED:
1536 #ifdef DOT11_N_SUPPORT
1537 case PHY_11N_2_4G:
1538 case PHY_11ABGN_MIXED:
1539 case PHY_11BGN_MIXED:
1540 case PHY_11GN_MIXED:
1541 #endif // DOT11_N_SUPPORT //
1542 pAd->CommonCfg.SupRate[0] = 0x82; // 1 mbps, in units of 0.5 Mbps, basic rate
1543 pAd->CommonCfg.SupRate[1] = 0x84; // 2 mbps, in units of 0.5 Mbps, basic rate
1544 pAd->CommonCfg.SupRate[2] = 0x8B; // 5.5 mbps, in units of 0.5 Mbps, basic rate
1545 pAd->CommonCfg.SupRate[3] = 0x96; // 11 mbps, in units of 0.5 Mbps, basic rate
1546 pAd->CommonCfg.SupRate[4] = 0x12; // 9 mbps, in units of 0.5 Mbps
1547 pAd->CommonCfg.SupRate[5] = 0x24; // 18 mbps, in units of 0.5 Mbps
1548 pAd->CommonCfg.SupRate[6] = 0x48; // 36 mbps, in units of 0.5 Mbps
1549 pAd->CommonCfg.SupRate[7] = 0x6c; // 54 mbps, in units of 0.5 Mbps
1550 pAd->CommonCfg.SupRateLen = 8;
1551 pAd->CommonCfg.ExtRate[0] = 0x0C; // 6 mbps, in units of 0.5 Mbps
1552 pAd->CommonCfg.ExtRate[1] = 0x18; // 12 mbps, in units of 0.5 Mbps
1553 pAd->CommonCfg.ExtRate[2] = 0x30; // 24 mbps, in units of 0.5 Mbps
1554 pAd->CommonCfg.ExtRate[3] = 0x60; // 48 mbps, in units of 0.5 Mbps
1555 pAd->CommonCfg.ExtRateLen = 4;
1556 pAd->CommonCfg.DesireRate[0] = 2; // 1 mbps, in units of 0.5 Mbps
1557 pAd->CommonCfg.DesireRate[1] = 4; // 2 mbps, in units of 0.5 Mbps
1558 pAd->CommonCfg.DesireRate[2] = 11; // 5.5 mbps, in units of 0.5 Mbps
1559 pAd->CommonCfg.DesireRate[3] = 22; // 11 mbps, in units of 0.5 Mbps
1560 pAd->CommonCfg.DesireRate[4] = 12; // 6 mbps, in units of 0.5 Mbps
1561 pAd->CommonCfg.DesireRate[5] = 18; // 9 mbps, in units of 0.5 Mbps
1562 pAd->CommonCfg.DesireRate[6] = 24; // 12 mbps, in units of 0.5 Mbps
1563 pAd->CommonCfg.DesireRate[7] = 36; // 18 mbps, in units of 0.5 Mbps
1564 pAd->CommonCfg.DesireRate[8] = 48; // 24 mbps, in units of 0.5 Mbps
1565 pAd->CommonCfg.DesireRate[9] = 72; // 36 mbps, in units of 0.5 Mbps
1566 pAd->CommonCfg.DesireRate[10] = 96; // 48 mbps, in units of 0.5 Mbps
1567 pAd->CommonCfg.DesireRate[11] = 108; // 54 mbps, in units of 0.5 Mbps
1568 break;
1570 case PHY_11A:
1571 #ifdef DOT11_N_SUPPORT
1572 case PHY_11AN_MIXED:
1573 case PHY_11AGN_MIXED:
1574 case PHY_11N_5G:
1575 #endif // DOT11_N_SUPPORT //
1576 pAd->CommonCfg.SupRate[0] = 0x8C; // 6 mbps, in units of 0.5 Mbps, basic rate
1577 pAd->CommonCfg.SupRate[1] = 0x12; // 9 mbps, in units of 0.5 Mbps
1578 pAd->CommonCfg.SupRate[2] = 0x98; // 12 mbps, in units of 0.5 Mbps, basic rate
1579 pAd->CommonCfg.SupRate[3] = 0x24; // 18 mbps, in units of 0.5 Mbps
1580 pAd->CommonCfg.SupRate[4] = 0xb0; // 24 mbps, in units of 0.5 Mbps, basic rate
1581 pAd->CommonCfg.SupRate[5] = 0x48; // 36 mbps, in units of 0.5 Mbps
1582 pAd->CommonCfg.SupRate[6] = 0x60; // 48 mbps, in units of 0.5 Mbps
1583 pAd->CommonCfg.SupRate[7] = 0x6c; // 54 mbps, in units of 0.5 Mbps
1584 pAd->CommonCfg.SupRateLen = 8;
1585 pAd->CommonCfg.ExtRateLen = 0;
1586 pAd->CommonCfg.DesireRate[0] = 12; // 6 mbps, in units of 0.5 Mbps
1587 pAd->CommonCfg.DesireRate[1] = 18; // 9 mbps, in units of 0.5 Mbps
1588 pAd->CommonCfg.DesireRate[2] = 24; // 12 mbps, in units of 0.5 Mbps
1589 pAd->CommonCfg.DesireRate[3] = 36; // 18 mbps, in units of 0.5 Mbps
1590 pAd->CommonCfg.DesireRate[4] = 48; // 24 mbps, in units of 0.5 Mbps
1591 pAd->CommonCfg.DesireRate[5] = 72; // 36 mbps, in units of 0.5 Mbps
1592 pAd->CommonCfg.DesireRate[6] = 96; // 48 mbps, in units of 0.5 Mbps
1593 pAd->CommonCfg.DesireRate[7] = 108; // 54 mbps, in units of 0.5 Mbps
1594 //pAd->CommonCfg.HTPhyMode.field.MODE = MODE_OFDM; // This MODE is only FYI. not use
1595 break;
1597 default:
1598 break;
1602 pAd->CommonCfg.BandState = UNKNOWN_BAND;
1606 #ifdef DOT11_N_SUPPORT
1608 ========================================================================
1609 Routine Description:
1610 Caller ensures we has 802.11n support.
1611 Calls at setting HT from AP/STASetinformation
1613 Arguments:
1614 pAd - Pointer to our adapter
1615 phymode -
1617 ========================================================================
1619 VOID RTMPSetHT(
1620 IN PRTMP_ADAPTER pAd,
1621 IN OID_SET_HT_PHYMODE *pHTPhyMode)
1623 //ULONG *pmcs;
1624 UINT32 Value = 0;
1625 UCHAR BBPValue = 0;
1626 UCHAR BBP3Value = 0;
1627 UCHAR RxStream = pAd->CommonCfg.RxStream;
1629 DBGPRINT(RT_DEBUG_TRACE, ("RTMPSetHT : HT_mode(%d), ExtOffset(%d), MCS(%d), BW(%d), STBC(%d), SHORTGI(%d)\n",
1630 pHTPhyMode->HtMode, pHTPhyMode->ExtOffset,
1631 pHTPhyMode->MCS, pHTPhyMode->BW,
1632 pHTPhyMode->STBC, pHTPhyMode->SHORTGI));
1634 // Don't zero supportedHyPhy structure.
1635 RTMPZeroMemory(&pAd->CommonCfg.HtCapability, sizeof(pAd->CommonCfg.HtCapability));
1636 RTMPZeroMemory(&pAd->CommonCfg.AddHTInfo, sizeof(pAd->CommonCfg.AddHTInfo));
1637 RTMPZeroMemory(&pAd->CommonCfg.NewExtChanOffset, sizeof(pAd->CommonCfg.NewExtChanOffset));
1638 RTMPZeroMemory(&pAd->CommonCfg.DesiredHtPhy, sizeof(pAd->CommonCfg.DesiredHtPhy));
1640 if (pAd->CommonCfg.bRdg)
1642 pAd->CommonCfg.HtCapability.ExtHtCapInfo.PlusHTC = 1;
1643 pAd->CommonCfg.HtCapability.ExtHtCapInfo.RDGSupport = 1;
1645 else
1647 pAd->CommonCfg.HtCapability.ExtHtCapInfo.PlusHTC = 0;
1648 pAd->CommonCfg.HtCapability.ExtHtCapInfo.RDGSupport = 0;
1651 pAd->CommonCfg.HtCapability.HtCapParm.MaxRAmpduFactor = 3;
1652 pAd->CommonCfg.DesiredHtPhy.MaxRAmpduFactor = 3;
1654 DBGPRINT(RT_DEBUG_TRACE, ("RTMPSetHT : RxBAWinLimit = %d\n", pAd->CommonCfg.BACapability.field.RxBAWinLimit));
1656 // Mimo power save, A-MSDU size,
1657 pAd->CommonCfg.DesiredHtPhy.AmsduEnable = (USHORT)pAd->CommonCfg.BACapability.field.AmsduEnable;
1658 pAd->CommonCfg.DesiredHtPhy.AmsduSize = (UCHAR)pAd->CommonCfg.BACapability.field.AmsduSize;
1659 pAd->CommonCfg.DesiredHtPhy.MimoPs = (UCHAR)pAd->CommonCfg.BACapability.field.MMPSmode;
1660 pAd->CommonCfg.DesiredHtPhy.MpduDensity = (UCHAR)pAd->CommonCfg.BACapability.field.MpduDensity;
1662 pAd->CommonCfg.HtCapability.HtCapInfo.AMsduSize = (USHORT)pAd->CommonCfg.BACapability.field.AmsduSize;
1663 pAd->CommonCfg.HtCapability.HtCapInfo.MimoPs = (USHORT)pAd->CommonCfg.BACapability.field.MMPSmode;
1664 pAd->CommonCfg.HtCapability.HtCapParm.MpduDensity = (UCHAR)pAd->CommonCfg.BACapability.field.MpduDensity;
1666 DBGPRINT(RT_DEBUG_TRACE, ("RTMPSetHT : AMsduSize = %d, MimoPs = %d, MpduDensity = %d, MaxRAmpduFactor = %d\n",
1667 pAd->CommonCfg.DesiredHtPhy.AmsduSize,
1668 pAd->CommonCfg.DesiredHtPhy.MimoPs,
1669 pAd->CommonCfg.DesiredHtPhy.MpduDensity,
1670 pAd->CommonCfg.DesiredHtPhy.MaxRAmpduFactor));
1672 if(pHTPhyMode->HtMode == HTMODE_GF)
1674 pAd->CommonCfg.HtCapability.HtCapInfo.GF = 1;
1675 pAd->CommonCfg.DesiredHtPhy.GF = 1;
1677 else
1678 pAd->CommonCfg.DesiredHtPhy.GF = 0;
1680 // Decide Rx MCSSet
1681 switch (RxStream)
1683 case 1:
1684 pAd->CommonCfg.HtCapability.MCSSet[0] = 0xff;
1685 pAd->CommonCfg.HtCapability.MCSSet[1] = 0x00;
1686 break;
1688 case 2:
1689 pAd->CommonCfg.HtCapability.MCSSet[0] = 0xff;
1690 pAd->CommonCfg.HtCapability.MCSSet[1] = 0xff;
1691 break;
1693 case 3: // 3*3
1694 pAd->CommonCfg.HtCapability.MCSSet[0] = 0xff;
1695 pAd->CommonCfg.HtCapability.MCSSet[1] = 0xff;
1696 pAd->CommonCfg.HtCapability.MCSSet[2] = 0xff;
1697 break;
1700 if (pAd->CommonCfg.bForty_Mhz_Intolerant && (pAd->CommonCfg.Channel <= 14) && (pHTPhyMode->BW == BW_40) )
1702 pHTPhyMode->BW = BW_20;
1703 pAd->CommonCfg.HtCapability.HtCapInfo.Forty_Mhz_Intolerant = 1;
1706 if(pHTPhyMode->BW == BW_40)
1708 pAd->CommonCfg.HtCapability.MCSSet[4] = 0x1; // MCS 32
1709 pAd->CommonCfg.HtCapability.HtCapInfo.ChannelWidth = 1;
1710 if (pAd->CommonCfg.Channel <= 14)
1711 pAd->CommonCfg.HtCapability.HtCapInfo.CCKmodein40 = 1;
1713 pAd->CommonCfg.DesiredHtPhy.ChannelWidth = 1;
1714 pAd->CommonCfg.AddHTInfo.AddHtInfo.RecomWidth = 1;
1715 pAd->CommonCfg.AddHTInfo.AddHtInfo.ExtChanOffset = (pHTPhyMode->ExtOffset == EXTCHA_BELOW)? (EXTCHA_BELOW): EXTCHA_ABOVE;
1716 // Set Regsiter for extension channel position.
1717 RTMP_IO_READ32(pAd, TX_BAND_CFG, &Value);
1718 RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &BBP3Value);
1719 if ((pHTPhyMode->ExtOffset == EXTCHA_BELOW))
1721 Value |= 0x1;
1722 BBP3Value |= (0x20);
1723 RTMP_IO_WRITE32(pAd, TX_BAND_CFG, Value);
1725 else if ((pHTPhyMode->ExtOffset == EXTCHA_ABOVE))
1727 Value &= 0xfe;
1728 BBP3Value &= (~0x20);
1729 RTMP_IO_WRITE32(pAd, TX_BAND_CFG, Value);
1732 // Turn on BBP 40MHz mode now only as AP .
1733 // Sta can turn on BBP 40MHz after connection with 40MHz AP. Sta only broadcast 40MHz capability before connection.
1734 if ((pAd->OpMode == OPMODE_AP) || INFRA_ON(pAd) || ADHOC_ON(pAd)
1737 RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &BBPValue);
1738 BBPValue &= (~0x18);
1739 BBPValue |= 0x10;
1740 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, BBPValue);
1742 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, BBP3Value);
1743 pAd->CommonCfg.BBPCurrentBW = BW_40;
1746 else
1748 pAd->CommonCfg.HtCapability.HtCapInfo.ChannelWidth = 0;
1749 pAd->CommonCfg.DesiredHtPhy.ChannelWidth = 0;
1750 pAd->CommonCfg.AddHTInfo.AddHtInfo.RecomWidth = 0;
1751 pAd->CommonCfg.AddHTInfo.AddHtInfo.ExtChanOffset = EXTCHA_NONE;
1752 pAd->CommonCfg.CentralChannel = pAd->CommonCfg.Channel;
1753 // Turn on BBP 20MHz mode by request here.
1755 RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &BBPValue);
1756 BBPValue &= (~0x18);
1757 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, BBPValue);
1758 pAd->CommonCfg.BBPCurrentBW = BW_20;
1762 if(pHTPhyMode->STBC == STBC_USE)
1764 pAd->CommonCfg.HtCapability.HtCapInfo.TxSTBC = 1;
1765 pAd->CommonCfg.DesiredHtPhy.TxSTBC = 1;
1766 pAd->CommonCfg.HtCapability.HtCapInfo.RxSTBC = 1;
1767 pAd->CommonCfg.DesiredHtPhy.RxSTBC = 1;
1769 else
1771 pAd->CommonCfg.DesiredHtPhy.TxSTBC = 0;
1772 pAd->CommonCfg.DesiredHtPhy.RxSTBC = 0;
1775 #ifdef RT2870
1776 /* Frank recommend ,If not, Tx maybe block in high power. Rx has no problem*/
1777 if(IS_RT3070(pAd) && ((pAd->RfIcType == RFIC_3020) || (pAd->RfIcType == RFIC_2020)))
1779 pAd->CommonCfg.HtCapability.HtCapInfo.TxSTBC = 0;
1780 pAd->CommonCfg.DesiredHtPhy.TxSTBC = 0;
1782 #endif // RT2870 //
1784 if(pHTPhyMode->SHORTGI == GI_400)
1786 pAd->CommonCfg.HtCapability.HtCapInfo.ShortGIfor20 = 1;
1787 pAd->CommonCfg.HtCapability.HtCapInfo.ShortGIfor40 = 1;
1788 pAd->CommonCfg.DesiredHtPhy.ShortGIfor20 = 1;
1789 pAd->CommonCfg.DesiredHtPhy.ShortGIfor40 = 1;
1791 else
1793 pAd->CommonCfg.HtCapability.HtCapInfo.ShortGIfor20 = 0;
1794 pAd->CommonCfg.HtCapability.HtCapInfo.ShortGIfor40 = 0;
1795 pAd->CommonCfg.DesiredHtPhy.ShortGIfor20 = 0;
1796 pAd->CommonCfg.DesiredHtPhy.ShortGIfor40 = 0;
1799 // We support link adaptation for unsolicit MCS feedback, set to 2.
1800 pAd->CommonCfg.HtCapability.ExtHtCapInfo.MCSFeedback = MCSFBK_NONE; //MCSFBK_UNSOLICIT;
1801 pAd->CommonCfg.AddHTInfo.ControlChan = pAd->CommonCfg.Channel;
1802 // 1, the extension channel above the control channel.
1804 // EDCA parameters used for AP's own transmission
1805 if (pAd->CommonCfg.APEdcaParm.bValid == FALSE)
1807 pAd->CommonCfg.APEdcaParm.bValid = TRUE;
1808 pAd->CommonCfg.APEdcaParm.Aifsn[0] = 3;
1809 pAd->CommonCfg.APEdcaParm.Aifsn[1] = 7;
1810 pAd->CommonCfg.APEdcaParm.Aifsn[2] = 1;
1811 pAd->CommonCfg.APEdcaParm.Aifsn[3] = 1;
1813 pAd->CommonCfg.APEdcaParm.Cwmin[0] = 4;
1814 pAd->CommonCfg.APEdcaParm.Cwmin[1] = 4;
1815 pAd->CommonCfg.APEdcaParm.Cwmin[2] = 3;
1816 pAd->CommonCfg.APEdcaParm.Cwmin[3] = 2;
1818 pAd->CommonCfg.APEdcaParm.Cwmax[0] = 6;
1819 pAd->CommonCfg.APEdcaParm.Cwmax[1] = 10;
1820 pAd->CommonCfg.APEdcaParm.Cwmax[2] = 4;
1821 pAd->CommonCfg.APEdcaParm.Cwmax[3] = 3;
1823 pAd->CommonCfg.APEdcaParm.Txop[0] = 0;
1824 pAd->CommonCfg.APEdcaParm.Txop[1] = 0;
1825 pAd->CommonCfg.APEdcaParm.Txop[2] = 94;
1826 pAd->CommonCfg.APEdcaParm.Txop[3] = 47;
1828 AsicSetEdcaParm(pAd, &pAd->CommonCfg.APEdcaParm);
1831 #ifdef CONFIG_STA_SUPPORT
1832 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
1834 RTMPSetIndividualHT(pAd, 0);
1836 #endif // CONFIG_STA_SUPPORT //
1841 ========================================================================
1842 Routine Description:
1843 Caller ensures we has 802.11n support.
1844 Calls at setting HT from AP/STASetinformation
1846 Arguments:
1847 pAd - Pointer to our adapter
1848 phymode -
1850 ========================================================================
1852 VOID RTMPSetIndividualHT(
1853 IN PRTMP_ADAPTER pAd,
1854 IN UCHAR apidx)
1856 PRT_HT_PHY_INFO pDesired_ht_phy = NULL;
1857 UCHAR TxStream = pAd->CommonCfg.TxStream;
1858 UCHAR DesiredMcs = MCS_AUTO;
1863 #ifdef CONFIG_STA_SUPPORT
1864 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
1866 pDesired_ht_phy = &pAd->StaCfg.DesiredHtPhyInfo;
1867 DesiredMcs = pAd->StaCfg.DesiredTransmitSetting.field.MCS;
1868 //pAd->StaCfg.bAutoTxRateSwitch = (DesiredMcs == MCS_AUTO) ? TRUE : FALSE;
1869 break;
1871 #endif // CONFIG_STA_SUPPORT //
1872 } while (FALSE);
1874 if (pDesired_ht_phy == NULL)
1876 DBGPRINT(RT_DEBUG_ERROR, ("RTMPSetIndividualHT: invalid apidx(%d)\n", apidx));
1877 return;
1879 RTMPZeroMemory(pDesired_ht_phy, sizeof(RT_HT_PHY_INFO));
1881 DBGPRINT(RT_DEBUG_TRACE, ("RTMPSetIndividualHT : Desired MCS = %d\n", DesiredMcs));
1882 // Check the validity of MCS
1883 if ((TxStream == 1) && ((DesiredMcs >= MCS_8) && (DesiredMcs <= MCS_15)))
1885 DBGPRINT(RT_DEBUG_WARN, ("RTMPSetIndividualHT: MCS(%d) is invalid in 1S, reset it as MCS_7\n", DesiredMcs));
1886 DesiredMcs = MCS_7;
1889 if ((pAd->CommonCfg.DesiredHtPhy.ChannelWidth == BW_20) && (DesiredMcs == MCS_32))
1891 DBGPRINT(RT_DEBUG_WARN, ("RTMPSetIndividualHT: MCS_32 is only supported in 40-MHz, reset it as MCS_0\n"));
1892 DesiredMcs = MCS_0;
1895 pDesired_ht_phy->bHtEnable = TRUE;
1897 // Decide desired Tx MCS
1898 switch (TxStream)
1900 case 1:
1901 if (DesiredMcs == MCS_AUTO)
1903 pDesired_ht_phy->MCSSet[0]= 0xff;
1904 pDesired_ht_phy->MCSSet[1]= 0x00;
1906 else if (DesiredMcs <= MCS_7)
1908 pDesired_ht_phy->MCSSet[0]= 1<<DesiredMcs;
1909 pDesired_ht_phy->MCSSet[1]= 0x00;
1911 break;
1913 case 2:
1914 if (DesiredMcs == MCS_AUTO)
1916 pDesired_ht_phy->MCSSet[0]= 0xff;
1917 pDesired_ht_phy->MCSSet[1]= 0xff;
1919 else if (DesiredMcs <= MCS_15)
1921 ULONG mode;
1923 mode = DesiredMcs / 8;
1924 if (mode < 2)
1925 pDesired_ht_phy->MCSSet[mode] = (1 << (DesiredMcs - mode * 8));
1927 break;
1929 case 3: // 3*3
1930 if (DesiredMcs == MCS_AUTO)
1932 /* MCS0 ~ MCS23, 3 bytes */
1933 pDesired_ht_phy->MCSSet[0]= 0xff;
1934 pDesired_ht_phy->MCSSet[1]= 0xff;
1935 pDesired_ht_phy->MCSSet[2]= 0xff;
1937 else if (DesiredMcs <= MCS_23)
1939 ULONG mode;
1941 mode = DesiredMcs / 8;
1942 if (mode < 3)
1943 pDesired_ht_phy->MCSSet[mode] = (1 << (DesiredMcs - mode * 8));
1945 break;
1948 if(pAd->CommonCfg.DesiredHtPhy.ChannelWidth == BW_40)
1950 if (DesiredMcs == MCS_AUTO || DesiredMcs == MCS_32)
1951 pDesired_ht_phy->MCSSet[4] = 0x1;
1954 // update HT Rate setting
1955 if (pAd->OpMode == OPMODE_STA)
1956 MlmeUpdateHtTxRates(pAd, BSS0);
1957 else
1958 MlmeUpdateHtTxRates(pAd, apidx);
1963 ========================================================================
1964 Routine Description:
1965 Update HT IE from our capability.
1967 Arguments:
1968 Send all HT IE in beacon/probe rsp/assoc rsp/action frame.
1971 ========================================================================
1973 VOID RTMPUpdateHTIE(
1974 IN RT_HT_CAPABILITY *pRtHt,
1975 IN UCHAR *pMcsSet,
1976 OUT HT_CAPABILITY_IE *pHtCapability,
1977 OUT ADD_HT_INFO_IE *pAddHtInfo)
1979 RTMPZeroMemory(pHtCapability, sizeof(HT_CAPABILITY_IE));
1980 RTMPZeroMemory(pAddHtInfo, sizeof(ADD_HT_INFO_IE));
1982 pHtCapability->HtCapInfo.ChannelWidth = pRtHt->ChannelWidth;
1983 pHtCapability->HtCapInfo.MimoPs = pRtHt->MimoPs;
1984 pHtCapability->HtCapInfo.GF = pRtHt->GF;
1985 pHtCapability->HtCapInfo.ShortGIfor20 = pRtHt->ShortGIfor20;
1986 pHtCapability->HtCapInfo.ShortGIfor40 = pRtHt->ShortGIfor40;
1987 pHtCapability->HtCapInfo.TxSTBC = pRtHt->TxSTBC;
1988 pHtCapability->HtCapInfo.RxSTBC = pRtHt->RxSTBC;
1989 pHtCapability->HtCapInfo.AMsduSize = pRtHt->AmsduSize;
1990 pHtCapability->HtCapParm.MaxRAmpduFactor = pRtHt->MaxRAmpduFactor;
1991 pHtCapability->HtCapParm.MpduDensity = pRtHt->MpduDensity;
1993 pAddHtInfo->AddHtInfo.ExtChanOffset = pRtHt->ExtChanOffset ;
1994 pAddHtInfo->AddHtInfo.RecomWidth = pRtHt->RecomWidth;
1995 pAddHtInfo->AddHtInfo2.OperaionMode = pRtHt->OperaionMode;
1996 pAddHtInfo->AddHtInfo2.NonGfPresent = pRtHt->NonGfPresent;
1997 RTMPMoveMemory(pAddHtInfo->MCSSet, /*pRtHt->MCSSet*/pMcsSet, 4); // rt2860 only support MCS max=32, no need to copy all 16 uchar.
1999 DBGPRINT(RT_DEBUG_TRACE,("RTMPUpdateHTIE <== \n"));
2001 #endif // DOT11_N_SUPPORT //
2004 ========================================================================
2005 Description:
2006 Add Client security information into ASIC WCID table and IVEIV table.
2007 Return:
2008 ========================================================================
2010 VOID RTMPAddWcidAttributeEntry(
2011 IN PRTMP_ADAPTER pAd,
2012 IN UCHAR BssIdx,
2013 IN UCHAR KeyIdx,
2014 IN UCHAR CipherAlg,
2015 IN MAC_TABLE_ENTRY *pEntry)
2017 UINT32 WCIDAttri = 0;
2018 USHORT offset;
2019 UCHAR IVEIV = 0;
2020 USHORT Wcid = 0;
2023 #ifdef CONFIG_STA_SUPPORT
2024 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
2026 if (BssIdx > BSS0)
2028 DBGPRINT(RT_DEBUG_ERROR, ("RTMPAddWcidAttributeEntry: The BSS-index(%d) is out of range for Infra link. \n", BssIdx));
2029 return;
2032 // 1. In ADHOC mode, the AID is wcid number. And NO mesh link exists.
2033 // 2. In Infra mode, the AID:1 MUST be wcid of infra STA.
2034 // the AID:2~ assign to mesh link entry.
2035 if (pEntry && ADHOC_ON(pAd))
2036 Wcid = pEntry->Aid;
2037 else if (pEntry && INFRA_ON(pAd))
2039 #ifdef QOS_DLS_SUPPORT
2040 if (pEntry->ValidAsDls == TRUE)
2041 Wcid = pEntry->Aid;
2042 else
2043 #endif // QOS_DLS_SUPPORT //
2044 Wcid = BSSID_WCID;
2046 else
2047 Wcid = MCAST_WCID;
2049 #endif // CONFIG_STA_SUPPORT //
2052 // Update WCID attribute table
2053 offset = MAC_WCID_ATTRIBUTE_BASE + (Wcid * HW_WCID_ATTRI_SIZE);
2055 #ifdef CONFIG_STA_SUPPORT
2056 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
2058 if (pEntry && pEntry->ValidAsMesh)
2059 WCIDAttri = (CipherAlg<<1) | PAIRWISEKEYTABLE;
2060 #ifdef QOS_DLS_SUPPORT
2061 else if ((pEntry) && (pEntry->ValidAsDls) &&
2062 ((CipherAlg == CIPHER_TKIP) ||
2063 (CipherAlg == CIPHER_TKIP_NO_MIC) ||
2064 (CipherAlg == CIPHER_AES) ||
2065 (CipherAlg == CIPHER_NONE)))
2066 WCIDAttri = (CipherAlg<<1) | PAIRWISEKEYTABLE;
2067 #endif // QOS_DLS_SUPPORT //
2068 else
2069 WCIDAttri = (CipherAlg<<1) | SHAREDKEYTABLE;
2071 #endif // CONFIG_STA_SUPPORT //
2073 RTMP_IO_WRITE32(pAd, offset, WCIDAttri);
2076 // Update IV/EIV table
2077 offset = MAC_IVEIV_TABLE_BASE + (Wcid * HW_IVEIV_ENTRY_SIZE);
2079 // WPA mode
2080 if ((CipherAlg == CIPHER_TKIP) || (CipherAlg == CIPHER_TKIP_NO_MIC) || (CipherAlg == CIPHER_AES))
2082 // Eiv bit on. keyid always is 0 for pairwise key
2083 IVEIV = (KeyIdx <<6) | 0x20;
2085 else
2087 // WEP KeyIdx is default tx key.
2088 IVEIV = (KeyIdx << 6);
2091 // For key index and ext IV bit, so only need to update the position(offset+3).
2092 #ifdef RT2870
2093 RTUSBMultiWrite_OneByte(pAd, offset+3, &IVEIV);
2094 #endif // RT2870 //
2096 DBGPRINT(RT_DEBUG_TRACE,("RTMPAddWcidAttributeEntry: WCID #%d, KeyIndex #%d, Alg=%s\n",Wcid, KeyIdx, CipherName[CipherAlg]));
2097 DBGPRINT(RT_DEBUG_TRACE,(" WCIDAttri = 0x%x \n", WCIDAttri));
2102 ==========================================================================
2103 Description:
2104 Parse encryption type
2105 Arguments:
2106 pAdapter Pointer to our adapter
2107 wrq Pointer to the ioctl argument
2109 Return Value:
2110 None
2112 Note:
2113 ==========================================================================
2115 CHAR *GetEncryptType(CHAR enc)
2117 if(enc == Ndis802_11WEPDisabled)
2118 return "NONE";
2119 if(enc == Ndis802_11WEPEnabled)
2120 return "WEP";
2121 if(enc == Ndis802_11Encryption2Enabled)
2122 return "TKIP";
2123 if(enc == Ndis802_11Encryption3Enabled)
2124 return "AES";
2125 if(enc == Ndis802_11Encryption4Enabled)
2126 return "TKIPAES";
2127 else
2128 return "UNKNOW";
2131 CHAR *GetAuthMode(CHAR auth)
2133 if(auth == Ndis802_11AuthModeOpen)
2134 return "OPEN";
2135 if(auth == Ndis802_11AuthModeShared)
2136 return "SHARED";
2137 if(auth == Ndis802_11AuthModeAutoSwitch)
2138 return "AUTOWEP";
2139 if(auth == Ndis802_11AuthModeWPA)
2140 return "WPA";
2141 if(auth == Ndis802_11AuthModeWPAPSK)
2142 return "WPAPSK";
2143 if(auth == Ndis802_11AuthModeWPANone)
2144 return "WPANONE";
2145 if(auth == Ndis802_11AuthModeWPA2)
2146 return "WPA2";
2147 if(auth == Ndis802_11AuthModeWPA2PSK)
2148 return "WPA2PSK";
2149 if(auth == Ndis802_11AuthModeWPA1WPA2)
2150 return "WPA1WPA2";
2151 if(auth == Ndis802_11AuthModeWPA1PSKWPA2PSK)
2152 return "WPA1PSKWPA2PSK";
2154 return "UNKNOW";
2157 #if 1 //#ifndef UCOS
2159 ==========================================================================
2160 Description:
2161 Get site survey results
2162 Arguments:
2163 pAdapter Pointer to our adapter
2164 wrq Pointer to the ioctl argument
2166 Return Value:
2167 None
2169 Note:
2170 Usage:
2171 1.) UI needs to wait 4 seconds after issue a site survey command
2172 2.) iwpriv ra0 get_site_survey
2173 3.) UI needs to prepare at least 4096bytes to get the results
2174 ==========================================================================
2176 #define LINE_LEN (4+33+20+8+10+9+7+3) // Channel+SSID+Bssid+WepStatus+AuthMode+Signal+WiressMode+NetworkType
2177 VOID RTMPIoctlGetSiteSurvey(
2178 IN PRTMP_ADAPTER pAdapter,
2179 IN struct iwreq *wrq)
2181 CHAR *msg;
2182 INT i=0;
2183 INT WaitCnt;
2184 INT Status=0;
2185 CHAR Ssid[MAX_LEN_OF_SSID +1];
2186 INT Rssi = 0, max_len = LINE_LEN;
2187 UINT Rssi_Quality = 0;
2188 NDIS_802_11_NETWORK_TYPE wireless_mode;
2190 os_alloc_mem(NULL, (PUCHAR *)&msg, sizeof(CHAR)*((MAX_LEN_OF_BSS_TABLE)*max_len));
2192 if (msg == NULL)
2194 DBGPRINT(RT_DEBUG_TRACE, ("RTMPIoctlGetSiteSurvey - msg memory alloc fail.\n"));
2195 return;
2198 memset(msg, 0 ,(MAX_LEN_OF_BSS_TABLE)*max_len );
2199 memset(Ssid, 0 ,(MAX_LEN_OF_SSID +1));
2200 sprintf(msg,"%s","\n");
2201 sprintf(msg+strlen(msg),"%-4s%-33s%-20s%-8s%-10s%-9s%-7s%-3s\n",
2202 "Ch", "SSID", "BSSID", "Enc", "Auth", "Siganl(%)", "W-Mode", " NT");
2205 WaitCnt = 0;
2206 #ifdef CONFIG_STA_SUPPORT
2207 pAdapter->StaCfg.bScanReqIsFromWebUI = TRUE;
2208 while ((ScanRunning(pAdapter) == TRUE) && (WaitCnt++ < 200))
2209 OS_WAIT(500);
2210 #endif // CONFIG_STA_SUPPORT //
2212 for(i=0; i<pAdapter->ScanTab.BssNr ;i++)
2214 if( pAdapter->ScanTab.BssEntry[i].Channel==0)
2215 break;
2217 if((strlen(msg)+max_len ) >= IW_SCAN_MAX_DATA)
2218 break;
2220 //Channel
2221 sprintf(msg+strlen(msg),"%-4d", pAdapter->ScanTab.BssEntry[i].Channel);
2222 //SSID
2223 memcpy(Ssid, pAdapter->ScanTab.BssEntry[i].Ssid, pAdapter->ScanTab.BssEntry[i].SsidLen);
2224 Ssid[pAdapter->ScanTab.BssEntry[i].SsidLen] = '\0';
2225 sprintf(msg+strlen(msg),"%-33s", Ssid);
2226 //BSSID
2227 sprintf(msg+strlen(msg),"%02x:%02x:%02x:%02x:%02x:%02x ",
2228 pAdapter->ScanTab.BssEntry[i].Bssid[0],
2229 pAdapter->ScanTab.BssEntry[i].Bssid[1],
2230 pAdapter->ScanTab.BssEntry[i].Bssid[2],
2231 pAdapter->ScanTab.BssEntry[i].Bssid[3],
2232 pAdapter->ScanTab.BssEntry[i].Bssid[4],
2233 pAdapter->ScanTab.BssEntry[i].Bssid[5]);
2234 //Encryption Type
2235 sprintf(msg+strlen(msg),"%-8s",GetEncryptType(pAdapter->ScanTab.BssEntry[i].WepStatus));
2236 //Authentication Mode
2237 if (pAdapter->ScanTab.BssEntry[i].WepStatus == Ndis802_11WEPEnabled)
2238 sprintf(msg+strlen(msg),"%-10s", "UNKNOW");
2239 else
2240 sprintf(msg+strlen(msg),"%-10s",GetAuthMode(pAdapter->ScanTab.BssEntry[i].AuthMode));
2241 // Rssi
2242 Rssi = (INT)pAdapter->ScanTab.BssEntry[i].Rssi;
2243 if (Rssi >= -50)
2244 Rssi_Quality = 100;
2245 else if (Rssi >= -80) // between -50 ~ -80dbm
2246 Rssi_Quality = (UINT)(24 + ((Rssi + 80) * 26)/10);
2247 else if (Rssi >= -90) // between -80 ~ -90dbm
2248 Rssi_Quality = (UINT)(((Rssi + 90) * 26)/10);
2249 else // < -84 dbm
2250 Rssi_Quality = 0;
2251 sprintf(msg+strlen(msg),"%-9d", Rssi_Quality);
2252 // Wireless Mode
2253 wireless_mode = NetworkTypeInUseSanity(&pAdapter->ScanTab.BssEntry[i]);
2254 if (wireless_mode == Ndis802_11FH ||
2255 wireless_mode == Ndis802_11DS)
2256 sprintf(msg+strlen(msg),"%-7s", "11b");
2257 else if (wireless_mode == Ndis802_11OFDM5)
2258 sprintf(msg+strlen(msg),"%-7s", "11a");
2259 else if (wireless_mode == Ndis802_11OFDM5_N)
2260 sprintf(msg+strlen(msg),"%-7s", "11a/n");
2261 else if (wireless_mode == Ndis802_11OFDM24)
2262 sprintf(msg+strlen(msg),"%-7s", "11b/g");
2263 else if (wireless_mode == Ndis802_11OFDM24_N)
2264 sprintf(msg+strlen(msg),"%-7s", "11b/g/n");
2265 else
2266 sprintf(msg+strlen(msg),"%-7s", "unknow");
2267 //Network Type
2268 if (pAdapter->ScanTab.BssEntry[i].BssType == BSS_ADHOC)
2269 sprintf(msg+strlen(msg),"%-3s", " Ad");
2270 else
2271 sprintf(msg+strlen(msg),"%-3s", " In");
2273 sprintf(msg+strlen(msg),"\n");
2276 #ifdef CONFIG_STA_SUPPORT
2277 pAdapter->StaCfg.bScanReqIsFromWebUI = FALSE;
2278 #endif // CONFIG_STA_SUPPORT //
2279 wrq->u.data.length = strlen(msg);
2280 Status = copy_to_user(wrq->u.data.pointer, msg, wrq->u.data.length);
2282 DBGPRINT(RT_DEBUG_TRACE, ("RTMPIoctlGetSiteSurvey - wrq->u.data.length = %d\n", wrq->u.data.length));
2283 os_free_mem(NULL, (PUCHAR)msg);
2287 #define MAC_LINE_LEN (14+4+4+10+10+10+6+6) // Addr+aid+psm+datatime+rxbyte+txbyte+current tx rate+last tx rate
2288 VOID RTMPIoctlGetMacTable(
2289 IN PRTMP_ADAPTER pAd,
2290 IN struct iwreq *wrq)
2292 INT i;
2293 RT_802_11_MAC_TABLE MacTab;
2294 char *msg;
2296 MacTab.Num = 0;
2297 for (i=0; i<MAX_LEN_OF_MAC_TABLE; i++)
2299 if (pAd->MacTab.Content[i].ValidAsCLI && (pAd->MacTab.Content[i].Sst == SST_ASSOC))
2301 COPY_MAC_ADDR(MacTab.Entry[MacTab.Num].Addr, &pAd->MacTab.Content[i].Addr);
2302 MacTab.Entry[MacTab.Num].Aid = (UCHAR)pAd->MacTab.Content[i].Aid;
2303 MacTab.Entry[MacTab.Num].Psm = pAd->MacTab.Content[i].PsMode;
2304 #ifdef DOT11_N_SUPPORT
2305 MacTab.Entry[MacTab.Num].MimoPs = pAd->MacTab.Content[i].MmpsMode;
2306 #endif // DOT11_N_SUPPORT //
2308 // Fill in RSSI per entry
2309 MacTab.Entry[MacTab.Num].AvgRssi0 = pAd->MacTab.Content[i].RssiSample.AvgRssi0;
2310 MacTab.Entry[MacTab.Num].AvgRssi1 = pAd->MacTab.Content[i].RssiSample.AvgRssi1;
2311 MacTab.Entry[MacTab.Num].AvgRssi2 = pAd->MacTab.Content[i].RssiSample.AvgRssi2;
2313 // the connected time per entry
2314 MacTab.Entry[MacTab.Num].ConnectedTime = pAd->MacTab.Content[i].StaConnectTime;
2315 #if 0 // ToDo
2316 MacTab.Entry[MacTab.Num].HSCounter.LastDataPacketTime = pAd->MacTab.Content[i].HSCounter.LastDataPacketTime;
2317 MacTab.Entry[MacTab.Num].HSCounter.TotalRxByteCount = pAd->MacTab.Content[i].HSCounter.TotalRxByteCount;
2318 MacTab.Entry[MacTab.Num].HSCounter.TotalTxByteCount = pAd->MacTab.Content[i].HSCounter.TotalTxByteCount;
2319 #endif
2320 MacTab.Entry[MacTab.Num].TxRate.field.MCS = pAd->MacTab.Content[i].HTPhyMode.field.MCS;
2321 MacTab.Entry[MacTab.Num].TxRate.field.BW = pAd->MacTab.Content[i].HTPhyMode.field.BW;
2322 MacTab.Entry[MacTab.Num].TxRate.field.ShortGI = pAd->MacTab.Content[i].HTPhyMode.field.ShortGI;
2323 MacTab.Entry[MacTab.Num].TxRate.field.STBC = pAd->MacTab.Content[i].HTPhyMode.field.STBC;
2324 MacTab.Entry[MacTab.Num].TxRate.field.rsv = pAd->MacTab.Content[i].HTPhyMode.field.rsv;
2325 MacTab.Entry[MacTab.Num].TxRate.field.MODE = pAd->MacTab.Content[i].HTPhyMode.field.MODE;
2326 MacTab.Entry[MacTab.Num].TxRate.word = pAd->MacTab.Content[i].HTPhyMode.word;
2328 MacTab.Num += 1;
2331 wrq->u.data.length = sizeof(RT_802_11_MAC_TABLE);
2332 if (copy_to_user(wrq->u.data.pointer, &MacTab, wrq->u.data.length))
2334 DBGPRINT(RT_DEBUG_TRACE, ("%s: copy_to_user() fail\n", __FUNCTION__));
2337 msg = (CHAR *) kmalloc(sizeof(CHAR)*(MAX_LEN_OF_MAC_TABLE*MAC_LINE_LEN), MEM_ALLOC_FLAG);
2338 memset(msg, 0 ,MAX_LEN_OF_MAC_TABLE*MAC_LINE_LEN );
2339 sprintf(msg,"%s","\n");
2340 sprintf(msg+strlen(msg),"%-14s%-4s%-4s%-10s%-10s%-10s%-6s%-6s\n",
2341 "MAC", "AID", "PSM", "LDT", "RxB", "TxB","CTxR", "LTxR");
2343 for (i=0; i<MAX_LEN_OF_MAC_TABLE; i++)
2345 PMAC_TABLE_ENTRY pEntry = &pAd->MacTab.Content[i];
2346 if (pEntry->ValidAsCLI && (pEntry->Sst == SST_ASSOC))
2348 if((strlen(msg)+MAC_LINE_LEN ) >= (MAX_LEN_OF_MAC_TABLE*MAC_LINE_LEN) )
2349 break;
2350 sprintf(msg+strlen(msg),"%02x%02x%02x%02x%02x%02x ",
2351 pEntry->Addr[0], pEntry->Addr[1], pEntry->Addr[2],
2352 pEntry->Addr[3], pEntry->Addr[4], pEntry->Addr[5]);
2353 sprintf(msg+strlen(msg),"%-4d", (int)pEntry->Aid);
2354 sprintf(msg+strlen(msg),"%-4d", (int)pEntry->PsMode);
2355 sprintf(msg+strlen(msg),"%-10d",0/*pAd->MacTab.Content[i].HSCounter.LastDataPacketTime*/); // ToDo
2356 sprintf(msg+strlen(msg),"%-10d",0/*pAd->MacTab.Content[i].HSCounter.TotalRxByteCount*/); // ToDo
2357 sprintf(msg+strlen(msg),"%-10d",0/*pAd->MacTab.Content[i].HSCounter.TotalTxByteCount*/); // ToDo
2358 sprintf(msg+strlen(msg),"%-6d",RateIdToMbps[pAd->MacTab.Content[i].CurrTxRate]);
2359 sprintf(msg+strlen(msg),"%-6d\n",0/*RateIdToMbps[pAd->MacTab.Content[i].LastTxRate]*/); // ToDo
2362 // for compatible with old API just do the printk to console
2363 //wrq->u.data.length = strlen(msg);
2364 //if (copy_to_user(wrq->u.data.pointer, msg, wrq->u.data.length))
2366 DBGPRINT(RT_DEBUG_TRACE, ("%s", msg));
2369 kfree(msg);
2371 #endif // UCOS //
2373 #ifdef DOT11_N_SUPPORT
2374 INT Set_BASetup_Proc(
2375 IN PRTMP_ADAPTER pAd,
2376 IN PUCHAR arg)
2378 UCHAR mac[6], tid;
2379 char *token, sepValue[] = ":", DASH = '-';
2380 INT i;
2381 MAC_TABLE_ENTRY *pEntry;
2384 The BASetup inupt string format should be xx:xx:xx:xx:xx:xx-d,
2385 =>The six 2 digit hex-decimal number previous are the Mac address,
2386 =>The seventh decimal number is the tid value.
2388 //printk("\n%s\n", arg);
2390 if(strlen(arg) < 19) //Mac address acceptable format 01:02:03:04:05:06 length 17 plus the "-" and tid value in decimal format.
2391 return FALSE;
2393 token = strchr(arg, DASH);
2394 if ((token != NULL) && (strlen(token)>1))
2396 tid = simple_strtol((token+1), 0, 10);
2397 if (tid > 15)
2398 return FALSE;
2400 *token = '\0';
2401 for (i = 0, token = rstrtok(arg, &sepValue[0]); token; token = rstrtok(NULL, &sepValue[0]), i++)
2403 if((strlen(token) != 2) || (!isxdigit(*token)) || (!isxdigit(*(token+1))))
2404 return FALSE;
2405 AtoH(token, (PUCHAR)(&mac[i]), 1);
2407 if(i != 6)
2408 return FALSE;
2410 printk("\n%02x:%02x:%02x:%02x:%02x:%02x-%02x\n", mac[0], mac[1],
2411 mac[2], mac[3], mac[4], mac[5], tid);
2413 pEntry = MacTableLookup(pAd, mac);
2415 if (pEntry) {
2416 printk("\nSetup BA Session: Tid = %d\n", tid);
2417 BAOriSessionSetUp(pAd, pEntry, tid, 0, 100, TRUE);
2420 return TRUE;
2423 return FALSE;
2427 INT Set_BADecline_Proc(
2428 IN PRTMP_ADAPTER pAd,
2429 IN PUCHAR arg)
2431 ULONG bBADecline;
2433 bBADecline = simple_strtol(arg, 0, 10);
2435 if (bBADecline == 0)
2437 pAd->CommonCfg.bBADecline = FALSE;
2439 else if (bBADecline == 1)
2441 pAd->CommonCfg.bBADecline = TRUE;
2443 else
2445 return FALSE; //Invalid argument
2448 DBGPRINT(RT_DEBUG_TRACE, ("Set_BADecline_Proc::(BADecline=%d)\n", pAd->CommonCfg.bBADecline));
2450 return TRUE;
2453 INT Set_BAOriTearDown_Proc(
2454 IN PRTMP_ADAPTER pAd,
2455 IN PUCHAR arg)
2457 UCHAR mac[6], tid;
2458 char *token, sepValue[] = ":", DASH = '-';
2459 INT i;
2460 MAC_TABLE_ENTRY *pEntry;
2462 //printk("\n%s\n", arg);
2464 The BAOriTearDown inupt string format should be xx:xx:xx:xx:xx:xx-d,
2465 =>The six 2 digit hex-decimal number previous are the Mac address,
2466 =>The seventh decimal number is the tid value.
2468 if(strlen(arg) < 19) //Mac address acceptable format 01:02:03:04:05:06 length 17 plus the "-" and tid value in decimal format.
2469 return FALSE;
2471 token = strchr(arg, DASH);
2472 if ((token != NULL) && (strlen(token)>1))
2474 tid = simple_strtol((token+1), 0, 10);
2475 if (tid > NUM_OF_TID)
2476 return FALSE;
2478 *token = '\0';
2479 for (i = 0, token = rstrtok(arg, &sepValue[0]); token; token = rstrtok(NULL, &sepValue[0]), i++)
2481 if((strlen(token) != 2) || (!isxdigit(*token)) || (!isxdigit(*(token+1))))
2482 return FALSE;
2483 AtoH(token, (PUCHAR)(&mac[i]), 1);
2485 if(i != 6)
2486 return FALSE;
2488 printk("\n%02x:%02x:%02x:%02x:%02x:%02x-%02x", mac[0], mac[1],
2489 mac[2], mac[3], mac[4], mac[5], tid);
2491 pEntry = MacTableLookup(pAd, mac);
2493 if (pEntry) {
2494 printk("\nTear down Ori BA Session: Tid = %d\n", tid);
2495 BAOriSessionTearDown(pAd, pEntry->Aid, tid, FALSE, TRUE);
2498 return TRUE;
2501 return FALSE;
2505 INT Set_BARecTearDown_Proc(
2506 IN PRTMP_ADAPTER pAd,
2507 IN PUCHAR arg)
2509 UCHAR mac[6], tid;
2510 char *token, sepValue[] = ":", DASH = '-';
2511 INT i;
2512 MAC_TABLE_ENTRY *pEntry;
2514 //printk("\n%s\n", arg);
2516 The BARecTearDown inupt string format should be xx:xx:xx:xx:xx:xx-d,
2517 =>The six 2 digit hex-decimal number previous are the Mac address,
2518 =>The seventh decimal number is the tid value.
2520 if(strlen(arg) < 19) //Mac address acceptable format 01:02:03:04:05:06 length 17 plus the "-" and tid value in decimal format.
2521 return FALSE;
2523 token = strchr(arg, DASH);
2524 if ((token != NULL) && (strlen(token)>1))
2526 tid = simple_strtol((token+1), 0, 10);
2527 if (tid > NUM_OF_TID)
2528 return FALSE;
2530 *token = '\0';
2531 for (i = 0, token = rstrtok(arg, &sepValue[0]); token; token = rstrtok(NULL, &sepValue[0]), i++)
2533 if((strlen(token) != 2) || (!isxdigit(*token)) || (!isxdigit(*(token+1))))
2534 return FALSE;
2535 AtoH(token, (PUCHAR)(&mac[i]), 1);
2537 if(i != 6)
2538 return FALSE;
2540 printk("\n%02x:%02x:%02x:%02x:%02x:%02x-%02x", mac[0], mac[1],
2541 mac[2], mac[3], mac[4], mac[5], tid);
2543 pEntry = MacTableLookup(pAd, mac);
2545 if (pEntry) {
2546 printk("\nTear down Rec BA Session: Tid = %d\n", tid);
2547 BARecSessionTearDown(pAd, pEntry->Aid, tid, FALSE);
2550 return TRUE;
2553 return FALSE;
2557 INT Set_HtBw_Proc(
2558 IN PRTMP_ADAPTER pAd,
2559 IN PUCHAR arg)
2561 ULONG HtBw;
2563 HtBw = simple_strtol(arg, 0, 10);
2564 if (HtBw == BW_40)
2565 pAd->CommonCfg.RegTransmitSetting.field.BW = BW_40;
2566 else if (HtBw == BW_20)
2567 pAd->CommonCfg.RegTransmitSetting.field.BW = BW_20;
2568 else
2569 return FALSE; //Invalid argument
2571 SetCommonHT(pAd);
2573 DBGPRINT(RT_DEBUG_TRACE, ("Set_HtBw_Proc::(HtBw=%d)\n", pAd->CommonCfg.RegTransmitSetting.field.BW));
2575 return TRUE;
2578 INT Set_HtMcs_Proc(
2579 IN PRTMP_ADAPTER pAd,
2580 IN PUCHAR arg)
2582 ULONG HtMcs, Mcs_tmp;
2583 #ifdef CONFIG_STA_SUPPORT
2584 BOOLEAN bAutoRate = FALSE;
2585 #endif // CONFIG_STA_SUPPORT //
2587 Mcs_tmp = simple_strtol(arg, 0, 10);
2589 if (Mcs_tmp <= 15 || Mcs_tmp == 32)
2590 HtMcs = Mcs_tmp;
2591 else
2592 HtMcs = MCS_AUTO;
2594 #ifdef CONFIG_STA_SUPPORT
2595 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
2597 pAd->StaCfg.DesiredTransmitSetting.field.MCS = HtMcs;
2598 pAd->StaCfg.bAutoTxRateSwitch = (HtMcs == MCS_AUTO) ? TRUE:FALSE;
2599 DBGPRINT(RT_DEBUG_TRACE, ("Set_HtMcs_Proc::(HtMcs=%d, bAutoTxRateSwitch = %d)\n",
2600 pAd->StaCfg.DesiredTransmitSetting.field.MCS, pAd->StaCfg.bAutoTxRateSwitch));
2602 if ((pAd->CommonCfg.PhyMode < PHY_11ABGN_MIXED) ||
2603 (pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE < MODE_HTMIX))
2605 if ((pAd->StaCfg.DesiredTransmitSetting.field.MCS != MCS_AUTO) &&
2606 (HtMcs >= 0 && HtMcs <= 3) &&
2607 (pAd->StaCfg.DesiredTransmitSetting.field.FixedTxMode == FIXED_TXMODE_CCK))
2609 RTMPSetDesiredRates(pAd, (LONG) (RateIdToMbps[HtMcs] * 1000000));
2611 else if ((pAd->StaCfg.DesiredTransmitSetting.field.MCS != MCS_AUTO) &&
2612 (HtMcs >= 0 && HtMcs <= 7) &&
2613 (pAd->StaCfg.DesiredTransmitSetting.field.FixedTxMode == FIXED_TXMODE_OFDM))
2615 RTMPSetDesiredRates(pAd, (LONG) (RateIdToMbps[HtMcs+4] * 1000000));
2617 else
2618 bAutoRate = TRUE;
2620 if (bAutoRate)
2622 pAd->StaCfg.DesiredTransmitSetting.field.MCS = MCS_AUTO;
2623 RTMPSetDesiredRates(pAd, -1);
2625 DBGPRINT(RT_DEBUG_TRACE, ("Set_HtMcs_Proc::(FixedTxMode=%d)\n",pAd->StaCfg.DesiredTransmitSetting.field.FixedTxMode));
2627 if (ADHOC_ON(pAd))
2628 return TRUE;
2630 #endif // CONFIG_STA_SUPPORT //
2632 SetCommonHT(pAd);
2634 return TRUE;
2637 INT Set_HtGi_Proc(
2638 IN PRTMP_ADAPTER pAd,
2639 IN PUCHAR arg)
2641 ULONG HtGi;
2643 HtGi = simple_strtol(arg, 0, 10);
2645 if ( HtGi == GI_400)
2646 pAd->CommonCfg.RegTransmitSetting.field.ShortGI = GI_400;
2647 else if ( HtGi == GI_800 )
2648 pAd->CommonCfg.RegTransmitSetting.field.ShortGI = GI_800;
2649 else
2650 return FALSE; //Invalid argument
2652 SetCommonHT(pAd);
2654 DBGPRINT(RT_DEBUG_TRACE, ("Set_HtGi_Proc::(ShortGI=%d)\n",pAd->CommonCfg.RegTransmitSetting.field.ShortGI));
2656 return TRUE;
2660 INT Set_HtTxBASize_Proc(
2661 IN PRTMP_ADAPTER pAd,
2662 IN PUCHAR arg)
2664 UCHAR Size;
2666 Size = simple_strtol(arg, 0, 10);
2668 if (Size <=0 || Size >=64)
2670 Size = 8;
2672 pAd->CommonCfg.TxBASize = Size-1;
2673 DBGPRINT(RT_DEBUG_ERROR, ("Set_HtTxBASize ::(TxBASize= %d)\n", Size));
2675 return TRUE;
2679 INT Set_HtOpMode_Proc(
2680 IN PRTMP_ADAPTER pAd,
2681 IN PUCHAR arg)
2684 ULONG Value;
2686 Value = simple_strtol(arg, 0, 10);
2688 if (Value == HTMODE_GF)
2689 pAd->CommonCfg.RegTransmitSetting.field.HTMODE = HTMODE_GF;
2690 else if ( Value == HTMODE_MM )
2691 pAd->CommonCfg.RegTransmitSetting.field.HTMODE = HTMODE_MM;
2692 else
2693 return FALSE; //Invalid argument
2695 SetCommonHT(pAd);
2697 DBGPRINT(RT_DEBUG_TRACE, ("Set_HtOpMode_Proc::(HtOpMode=%d)\n",pAd->CommonCfg.RegTransmitSetting.field.HTMODE));
2699 return TRUE;
2703 INT Set_HtStbc_Proc(
2704 IN PRTMP_ADAPTER pAd,
2705 IN PUCHAR arg)
2708 ULONG Value;
2710 Value = simple_strtol(arg, 0, 10);
2712 if (Value == STBC_USE)
2713 pAd->CommonCfg.RegTransmitSetting.field.STBC = STBC_USE;
2714 else if ( Value == STBC_NONE )
2715 pAd->CommonCfg.RegTransmitSetting.field.STBC = STBC_NONE;
2716 else
2717 return FALSE; //Invalid argument
2719 SetCommonHT(pAd);
2721 DBGPRINT(RT_DEBUG_TRACE, ("Set_Stbc_Proc::(HtStbc=%d)\n",pAd->CommonCfg.RegTransmitSetting.field.STBC));
2723 return TRUE;
2726 INT Set_HtHtc_Proc(
2727 IN PRTMP_ADAPTER pAd,
2728 IN PUCHAR arg)
2731 ULONG Value;
2733 Value = simple_strtol(arg, 0, 10);
2734 if (Value == 0)
2735 pAd->HTCEnable = FALSE;
2736 else if ( Value ==1 )
2737 pAd->HTCEnable = TRUE;
2738 else
2739 return FALSE; //Invalid argument
2741 DBGPRINT(RT_DEBUG_TRACE, ("Set_HtHtc_Proc::(HtHtc=%d)\n",pAd->HTCEnable));
2743 return TRUE;
2746 INT Set_HtExtcha_Proc(
2747 IN PRTMP_ADAPTER pAd,
2748 IN PUCHAR arg)
2751 ULONG Value;
2753 Value = simple_strtol(arg, 0, 10);
2755 if (Value == 0)
2756 pAd->CommonCfg.RegTransmitSetting.field.EXTCHA = EXTCHA_BELOW;
2757 else if ( Value ==1 )
2758 pAd->CommonCfg.RegTransmitSetting.field.EXTCHA = EXTCHA_ABOVE;
2759 else
2760 return FALSE; //Invalid argument
2762 SetCommonHT(pAd);
2764 DBGPRINT(RT_DEBUG_TRACE, ("Set_HtExtcha_Proc::(HtExtcha=%d)\n",pAd->CommonCfg.RegTransmitSetting.field.EXTCHA));
2766 return TRUE;
2769 INT Set_HtMpduDensity_Proc(
2770 IN PRTMP_ADAPTER pAd,
2771 IN PUCHAR arg)
2773 ULONG Value;
2775 Value = simple_strtol(arg, 0, 10);
2777 if (Value <=7 && Value >= 0)
2778 pAd->CommonCfg.BACapability.field.MpduDensity = Value;
2779 else
2780 pAd->CommonCfg.BACapability.field.MpduDensity = 4;
2782 SetCommonHT(pAd);
2784 DBGPRINT(RT_DEBUG_TRACE, ("Set_HtMpduDensity_Proc::(HtMpduDensity=%d)\n",pAd->CommonCfg.BACapability.field.MpduDensity));
2786 return TRUE;
2789 INT Set_HtBaWinSize_Proc(
2790 IN PRTMP_ADAPTER pAd,
2791 IN PUCHAR arg)
2793 ULONG Value;
2795 Value = simple_strtol(arg, 0, 10);
2798 if (Value >=1 && Value <= 64)
2800 pAd->CommonCfg.REGBACapability.field.RxBAWinLimit = Value;
2801 pAd->CommonCfg.BACapability.field.RxBAWinLimit = Value;
2803 else
2805 pAd->CommonCfg.REGBACapability.field.RxBAWinLimit = 64;
2806 pAd->CommonCfg.BACapability.field.RxBAWinLimit = 64;
2809 SetCommonHT(pAd);
2811 DBGPRINT(RT_DEBUG_TRACE, ("Set_HtBaWinSize_Proc::(HtBaWinSize=%d)\n",pAd->CommonCfg.BACapability.field.RxBAWinLimit));
2813 return TRUE;
2816 INT Set_HtRdg_Proc(
2817 IN PRTMP_ADAPTER pAd,
2818 IN PUCHAR arg)
2820 ULONG Value;
2822 Value = simple_strtol(arg, 0, 10);
2824 if (Value == 0)
2825 pAd->CommonCfg.bRdg = FALSE;
2826 else if ( Value ==1 )
2828 pAd->HTCEnable = TRUE;
2829 pAd->CommonCfg.bRdg = TRUE;
2831 else
2832 return FALSE; //Invalid argument
2834 SetCommonHT(pAd);
2836 DBGPRINT(RT_DEBUG_TRACE, ("Set_HtRdg_Proc::(HtRdg=%d)\n",pAd->CommonCfg.bRdg));
2838 return TRUE;
2841 INT Set_HtLinkAdapt_Proc(
2842 IN PRTMP_ADAPTER pAd,
2843 IN PUCHAR arg)
2845 ULONG Value;
2847 Value = simple_strtol(arg, 0, 10);
2848 if (Value == 0)
2849 pAd->bLinkAdapt = FALSE;
2850 else if ( Value ==1 )
2852 pAd->HTCEnable = TRUE;
2853 pAd->bLinkAdapt = TRUE;
2855 else
2856 return FALSE; //Invalid argument
2858 DBGPRINT(RT_DEBUG_TRACE, ("Set_HtLinkAdapt_Proc::(HtLinkAdapt=%d)\n",pAd->bLinkAdapt));
2860 return TRUE;
2863 INT Set_HtAmsdu_Proc(
2864 IN PRTMP_ADAPTER pAd,
2865 IN PUCHAR arg)
2867 ULONG Value;
2869 Value = simple_strtol(arg, 0, 10);
2870 if (Value == 0)
2871 pAd->CommonCfg.BACapability.field.AmsduEnable = FALSE;
2872 else if ( Value == 1 )
2873 pAd->CommonCfg.BACapability.field.AmsduEnable = TRUE;
2874 else
2875 return FALSE; //Invalid argument
2877 SetCommonHT(pAd);
2879 DBGPRINT(RT_DEBUG_TRACE, ("Set_HtAmsdu_Proc::(HtAmsdu=%d)\n",pAd->CommonCfg.BACapability.field.AmsduEnable));
2881 return TRUE;
2884 INT Set_HtAutoBa_Proc(
2885 IN PRTMP_ADAPTER pAd,
2886 IN PUCHAR arg)
2888 ULONG Value;
2890 Value = simple_strtol(arg, 0, 10);
2891 if (Value == 0)
2892 pAd->CommonCfg.BACapability.field.AutoBA = FALSE;
2893 else if (Value == 1)
2894 pAd->CommonCfg.BACapability.field.AutoBA = TRUE;
2895 else
2896 return FALSE; //Invalid argument
2898 pAd->CommonCfg.REGBACapability.field.AutoBA = pAd->CommonCfg.BACapability.field.AutoBA;
2899 SetCommonHT(pAd);
2901 DBGPRINT(RT_DEBUG_TRACE, ("Set_HtAutoBa_Proc::(HtAutoBa=%d)\n",pAd->CommonCfg.BACapability.field.AutoBA));
2903 return TRUE;
2907 INT Set_HtProtect_Proc(
2908 IN PRTMP_ADAPTER pAd,
2909 IN PUCHAR arg)
2911 ULONG Value;
2913 Value = simple_strtol(arg, 0, 10);
2914 if (Value == 0)
2915 pAd->CommonCfg.bHTProtect = FALSE;
2916 else if (Value == 1)
2917 pAd->CommonCfg.bHTProtect = TRUE;
2918 else
2919 return FALSE; //Invalid argument
2921 DBGPRINT(RT_DEBUG_TRACE, ("Set_HtProtect_Proc::(HtProtect=%d)\n",pAd->CommonCfg.bHTProtect));
2923 return TRUE;
2926 INT Set_SendPSMPAction_Proc(
2927 IN PRTMP_ADAPTER pAd,
2928 IN PUCHAR arg)
2930 UCHAR mac[6], mode;
2931 char *token, sepValue[] = ":", DASH = '-';
2932 INT i;
2933 MAC_TABLE_ENTRY *pEntry;
2935 //printk("\n%s\n", arg);
2937 The BARecTearDown inupt string format should be xx:xx:xx:xx:xx:xx-d,
2938 =>The six 2 digit hex-decimal number previous are the Mac address,
2939 =>The seventh decimal number is the mode value.
2941 if(strlen(arg) < 19) //Mac address acceptable format 01:02:03:04:05:06 length 17 plus the "-" and mode value in decimal format.
2942 return FALSE;
2944 token = strchr(arg, DASH);
2945 if ((token != NULL) && (strlen(token)>1))
2947 mode = simple_strtol((token+1), 0, 10);
2948 if (mode > MMPS_ENABLE)
2949 return FALSE;
2951 *token = '\0';
2952 for (i = 0, token = rstrtok(arg, &sepValue[0]); token; token = rstrtok(NULL, &sepValue[0]), i++)
2954 if((strlen(token) != 2) || (!isxdigit(*token)) || (!isxdigit(*(token+1))))
2955 return FALSE;
2956 AtoH(token, (PUCHAR)(&mac[i]), 1);
2958 if(i != 6)
2959 return FALSE;
2961 printk("\n%02x:%02x:%02x:%02x:%02x:%02x-%02x", mac[0], mac[1],
2962 mac[2], mac[3], mac[4], mac[5], mode);
2964 pEntry = MacTableLookup(pAd, mac);
2966 if (pEntry) {
2967 printk("\nSendPSMPAction MIPS mode = %d\n", mode);
2968 SendPSMPAction(pAd, pEntry->Aid, mode);
2971 return TRUE;
2974 return FALSE;
2979 INT Set_HtMIMOPSmode_Proc(
2980 IN PRTMP_ADAPTER pAd,
2981 IN PUCHAR arg)
2983 ULONG Value;
2985 Value = simple_strtol(arg, 0, 10);
2987 if (Value <=3 && Value >= 0)
2988 pAd->CommonCfg.BACapability.field.MMPSmode = Value;
2989 else
2990 pAd->CommonCfg.BACapability.field.MMPSmode = 3;
2992 SetCommonHT(pAd);
2994 DBGPRINT(RT_DEBUG_TRACE, ("Set_HtMIMOPSmode_Proc::(MIMOPS mode=%d)\n",pAd->CommonCfg.BACapability.field.MMPSmode));
2996 return TRUE;
3000 INT Set_ForceShortGI_Proc(
3001 IN PRTMP_ADAPTER pAd,
3002 IN PUCHAR arg)
3004 ULONG Value;
3006 Value = simple_strtol(arg, 0, 10);
3007 if (Value == 0)
3008 pAd->WIFItestbed.bShortGI = FALSE;
3009 else if (Value == 1)
3010 pAd->WIFItestbed.bShortGI = TRUE;
3011 else
3012 return FALSE; //Invalid argument
3014 SetCommonHT(pAd);
3016 DBGPRINT(RT_DEBUG_TRACE, ("Set_ForceShortGI_Proc::(ForceShortGI=%d)\n", pAd->WIFItestbed.bShortGI));
3018 return TRUE;
3023 INT Set_ForceGF_Proc(
3024 IN PRTMP_ADAPTER pAd,
3025 IN PUCHAR arg)
3027 ULONG Value;
3029 Value = simple_strtol(arg, 0, 10);
3030 if (Value == 0)
3031 pAd->WIFItestbed.bGreenField = FALSE;
3032 else if (Value == 1)
3033 pAd->WIFItestbed.bGreenField = TRUE;
3034 else
3035 return FALSE; //Invalid argument
3037 SetCommonHT(pAd);
3039 DBGPRINT(RT_DEBUG_TRACE, ("Set_ForceGF_Proc::(ForceGF=%d)\n", pAd->WIFItestbed.bGreenField));
3041 return TRUE;
3044 INT Set_HtMimoPs_Proc(
3045 IN PRTMP_ADAPTER pAd,
3046 IN PUCHAR arg)
3048 ULONG Value;
3050 Value = simple_strtol(arg, 0, 10);
3051 if (Value == 0)
3052 pAd->CommonCfg.bMIMOPSEnable = FALSE;
3053 else if (Value == 1)
3054 pAd->CommonCfg.bMIMOPSEnable = TRUE;
3055 else
3056 return FALSE; //Invalid argument
3058 DBGPRINT(RT_DEBUG_TRACE, ("Set_HtMimoPs_Proc::(HtMimoPs=%d)\n",pAd->CommonCfg.bMIMOPSEnable));
3060 return TRUE;
3062 #endif // DOT11_N_SUPPORT //
3065 #ifdef DOT11_N_SUPPORT
3066 INT SetCommonHT(
3067 IN PRTMP_ADAPTER pAd)
3069 OID_SET_HT_PHYMODE SetHT;
3071 if (pAd->CommonCfg.PhyMode < PHY_11ABGN_MIXED)
3072 return FALSE;
3074 SetHT.PhyMode = pAd->CommonCfg.PhyMode;
3075 SetHT.TransmitNo = ((UCHAR)pAd->Antenna.field.TxPath);
3076 SetHT.HtMode = (UCHAR)pAd->CommonCfg.RegTransmitSetting.field.HTMODE;
3077 SetHT.ExtOffset = (UCHAR)pAd->CommonCfg.RegTransmitSetting.field.EXTCHA;
3078 SetHT.MCS = MCS_AUTO;
3079 SetHT.BW = (UCHAR)pAd->CommonCfg.RegTransmitSetting.field.BW;
3080 SetHT.STBC = (UCHAR)pAd->CommonCfg.RegTransmitSetting.field.STBC;
3081 SetHT.SHORTGI = (UCHAR)pAd->CommonCfg.RegTransmitSetting.field.ShortGI;
3083 RTMPSetHT(pAd, &SetHT);
3085 return TRUE;
3087 #endif // DOT11_N_SUPPORT //
3089 INT Set_FixedTxMode_Proc(
3090 IN PRTMP_ADAPTER pAd,
3091 IN PUCHAR arg)
3093 UCHAR fix_tx_mode = FIXED_TXMODE_HT;
3095 if (strcmp(arg, "OFDM") == 0 || strcmp(arg, "ofdm") == 0)
3097 fix_tx_mode = FIXED_TXMODE_OFDM;
3099 else if (strcmp(arg, "CCK") == 0 || strcmp(arg, "cck") == 0)
3101 fix_tx_mode = FIXED_TXMODE_CCK;
3104 #ifdef CONFIG_STA_SUPPORT
3105 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
3106 pAd->StaCfg.DesiredTransmitSetting.field.FixedTxMode = fix_tx_mode;
3107 #endif // CONFIG_STA_SUPPORT //
3109 DBGPRINT(RT_DEBUG_TRACE, ("Set_FixedTxMode_Proc::(FixedTxMode=%d)\n", fix_tx_mode));
3111 return TRUE;
3114 #ifdef CONFIG_APSTA_MIXED_SUPPORT
3115 INT Set_OpMode_Proc(
3116 IN PRTMP_ADAPTER pAd,
3117 IN PUCHAR arg)
3119 ULONG Value;
3121 Value = simple_strtol(arg, 0, 10);
3123 #ifdef RT2870
3124 if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_START_UP))
3125 #endif // RT2870 //
3127 DBGPRINT(RT_DEBUG_ERROR, ("Can not switch operate mode on interface up !! \n"));
3128 return FALSE;
3131 if (Value == 0)
3132 pAd->OpMode = OPMODE_STA;
3133 else if (Value == 1)
3134 pAd->OpMode = OPMODE_AP;
3135 else
3136 return FALSE; //Invalid argument
3138 DBGPRINT(RT_DEBUG_TRACE, ("Set_OpMode_Proc::(OpMode=%s)\n", pAd->OpMode == 1 ? "AP Mode" : "STA Mode"));
3140 return TRUE;
3142 #endif // CONFIG_APSTA_MIXED_SUPPORT //
3145 /////////////////////////////////////////////////////////////////////////
3146 PCHAR RTMPGetRalinkAuthModeStr(
3147 IN NDIS_802_11_AUTHENTICATION_MODE authMode)
3149 switch(authMode)
3151 case Ndis802_11AuthModeOpen:
3152 return "OPEN";
3153 case Ndis802_11AuthModeWPAPSK:
3154 return "WPAPSK";
3155 case Ndis802_11AuthModeShared:
3156 return "SHARED";
3157 case Ndis802_11AuthModeWPA:
3158 return "WPA";
3159 case Ndis802_11AuthModeWPA2:
3160 return "WPA2";
3161 case Ndis802_11AuthModeWPA2PSK:
3162 return "WPA2PSK";
3163 case Ndis802_11AuthModeWPA1PSKWPA2PSK:
3164 return "WPAPSKWPA2PSK";
3165 case Ndis802_11AuthModeWPA1WPA2:
3166 return "WPA1WPA2";
3167 case Ndis802_11AuthModeWPANone:
3168 return "WPANONE";
3169 default:
3170 return "UNKNOW";
3174 PCHAR RTMPGetRalinkEncryModeStr(
3175 IN USHORT encryMode)
3177 switch(encryMode)
3179 case Ndis802_11WEPDisabled:
3180 return "NONE";
3181 case Ndis802_11WEPEnabled:
3182 return "WEP";
3183 case Ndis802_11Encryption2Enabled:
3184 return "TKIP";
3185 case Ndis802_11Encryption3Enabled:
3186 return "AES";
3187 case Ndis802_11Encryption4Enabled:
3188 return "TKIPAES";
3189 default:
3190 return "UNKNOW";
3194 INT RTMPShowCfgValue(
3195 IN PRTMP_ADAPTER pAd,
3196 IN PUCHAR pName,
3197 IN PUCHAR pBuf)
3199 INT Status = 0;
3201 for (PRTMP_PRIVATE_STA_SHOW_CFG_VALUE_PROC = RTMP_PRIVATE_STA_SHOW_CFG_VALUE_PROC; PRTMP_PRIVATE_STA_SHOW_CFG_VALUE_PROC->name; PRTMP_PRIVATE_STA_SHOW_CFG_VALUE_PROC++)
3203 if (!strcmp(pName, PRTMP_PRIVATE_STA_SHOW_CFG_VALUE_PROC->name))
3205 if(PRTMP_PRIVATE_STA_SHOW_CFG_VALUE_PROC->show_proc(pAd, pBuf))
3206 Status = -EINVAL;
3207 break; //Exit for loop.
3211 if(PRTMP_PRIVATE_STA_SHOW_CFG_VALUE_PROC->name == NULL)
3213 sprintf(pBuf, "\n");
3214 for (PRTMP_PRIVATE_STA_SHOW_CFG_VALUE_PROC = RTMP_PRIVATE_STA_SHOW_CFG_VALUE_PROC; PRTMP_PRIVATE_STA_SHOW_CFG_VALUE_PROC->name; PRTMP_PRIVATE_STA_SHOW_CFG_VALUE_PROC++)
3215 sprintf(pBuf, "%s%s\n", pBuf, PRTMP_PRIVATE_STA_SHOW_CFG_VALUE_PROC->name);
3218 return Status;
3221 INT Show_SSID_Proc(
3222 IN PRTMP_ADAPTER pAd,
3223 OUT PUCHAR pBuf)
3226 #ifdef CONFIG_STA_SUPPORT
3227 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
3228 sprintf(pBuf, "\t%s", pAd->CommonCfg.Ssid);
3229 #endif // CONFIG_STA_SUPPORT //
3230 return 0;
3233 INT Show_WirelessMode_Proc(
3234 IN PRTMP_ADAPTER pAd,
3235 OUT PUCHAR pBuf)
3237 switch(pAd->CommonCfg.PhyMode)
3239 case PHY_11BG_MIXED:
3240 sprintf(pBuf, "\t11B/G");
3241 break;
3242 case PHY_11B:
3243 sprintf(pBuf, "\t11B");
3244 break;
3245 case PHY_11A:
3246 sprintf(pBuf, "\t11A");
3247 break;
3248 case PHY_11ABG_MIXED:
3249 sprintf(pBuf, "\t11A/B/G");
3250 break;
3251 case PHY_11G:
3252 sprintf(pBuf, "\t11G");
3253 break;
3254 #ifdef DOT11_N_SUPPORT
3255 case PHY_11ABGN_MIXED:
3256 sprintf(pBuf, "\t11A/B/G/N");
3257 break;
3258 case PHY_11N_2_4G:
3259 sprintf(pBuf, "\t11N only with 2.4G");
3260 break;
3261 case PHY_11GN_MIXED:
3262 sprintf(pBuf, "\t11G/N");
3263 break;
3264 case PHY_11AN_MIXED:
3265 sprintf(pBuf, "\t11A/N");
3266 break;
3267 case PHY_11BGN_MIXED:
3268 sprintf(pBuf, "\t11B/G/N");
3269 break;
3270 case PHY_11AGN_MIXED:
3271 sprintf(pBuf, "\t11A/G/N");
3272 break;
3273 case PHY_11N_5G:
3274 sprintf(pBuf, "\t11N only with 5G");
3275 break;
3276 #endif // DOT11_N_SUPPORT //
3277 default:
3278 sprintf(pBuf, "\tUnknow Value(%d)", pAd->CommonCfg.PhyMode);
3279 break;
3281 return 0;
3285 INT Show_TxBurst_Proc(
3286 IN PRTMP_ADAPTER pAd,
3287 OUT PUCHAR pBuf)
3289 sprintf(pBuf, "\t%s", pAd->CommonCfg.bEnableTxBurst ? "TRUE":"FALSE");
3290 return 0;
3293 INT Show_TxPreamble_Proc(
3294 IN PRTMP_ADAPTER pAd,
3295 OUT PUCHAR pBuf)
3297 switch(pAd->CommonCfg.TxPreamble)
3299 case Rt802_11PreambleShort:
3300 sprintf(pBuf, "\tShort");
3301 break;
3302 case Rt802_11PreambleLong:
3303 sprintf(pBuf, "\tLong");
3304 break;
3305 case Rt802_11PreambleAuto:
3306 sprintf(pBuf, "\tAuto");
3307 break;
3308 default:
3309 sprintf(pBuf, "\tUnknow Value(%lu)", pAd->CommonCfg.TxPreamble);
3310 break;
3313 return 0;
3316 INT Show_TxPower_Proc(
3317 IN PRTMP_ADAPTER pAd,
3318 OUT PUCHAR pBuf)
3320 sprintf(pBuf, "\t%lu", pAd->CommonCfg.TxPowerPercentage);
3321 return 0;
3324 INT Show_Channel_Proc(
3325 IN PRTMP_ADAPTER pAd,
3326 OUT PUCHAR pBuf)
3328 sprintf(pBuf, "\t%d", pAd->CommonCfg.Channel);
3329 return 0;
3332 INT Show_BGProtection_Proc(
3333 IN PRTMP_ADAPTER pAd,
3334 OUT PUCHAR pBuf)
3336 switch(pAd->CommonCfg.UseBGProtection)
3338 case 1: //Always On
3339 sprintf(pBuf, "\tON");
3340 break;
3341 case 2: //Always OFF
3342 sprintf(pBuf, "\tOFF");
3343 break;
3344 case 0: //AUTO
3345 sprintf(pBuf, "\tAuto");
3346 break;
3347 default:
3348 sprintf(pBuf, "\tUnknow Value(%lu)", pAd->CommonCfg.UseBGProtection);
3349 break;
3351 return 0;
3354 INT Show_RTSThreshold_Proc(
3355 IN PRTMP_ADAPTER pAd,
3356 OUT PUCHAR pBuf)
3358 sprintf(pBuf, "\t%u", pAd->CommonCfg.RtsThreshold);
3359 return 0;
3362 INT Show_FragThreshold_Proc(
3363 IN PRTMP_ADAPTER pAd,
3364 OUT PUCHAR pBuf)
3366 sprintf(pBuf, "\t%u", pAd->CommonCfg.FragmentThreshold);
3367 return 0;
3370 #ifdef DOT11_N_SUPPORT
3371 INT Show_HtBw_Proc(
3372 IN PRTMP_ADAPTER pAd,
3373 OUT PUCHAR pBuf)
3375 if (pAd->CommonCfg.RegTransmitSetting.field.BW == BW_40)
3377 sprintf(pBuf, "\t40 MHz");
3379 else
3381 sprintf(pBuf, "\t20 MHz");
3383 return 0;
3386 INT Show_HtMcs_Proc(
3387 IN PRTMP_ADAPTER pAd,
3388 OUT PUCHAR pBuf)
3391 #ifdef CONFIG_STA_SUPPORT
3392 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
3393 sprintf(pBuf, "\t%u", pAd->StaCfg.DesiredTransmitSetting.field.MCS);
3394 #endif // CONFIG_STA_SUPPORT //
3395 return 0;
3398 INT Show_HtGi_Proc(
3399 IN PRTMP_ADAPTER pAd,
3400 OUT PUCHAR pBuf)
3402 switch(pAd->CommonCfg.RegTransmitSetting.field.ShortGI)
3404 case GI_400:
3405 sprintf(pBuf, "\tGI_400");
3406 break;
3407 case GI_800:
3408 sprintf(pBuf, "\tGI_800");
3409 break;
3410 default:
3411 sprintf(pBuf, "\tUnknow Value(%u)", pAd->CommonCfg.RegTransmitSetting.field.ShortGI);
3412 break;
3414 return 0;
3417 INT Show_HtOpMode_Proc(
3418 IN PRTMP_ADAPTER pAd,
3419 OUT PUCHAR pBuf)
3421 switch(pAd->CommonCfg.RegTransmitSetting.field.HTMODE)
3423 case HTMODE_GF:
3424 sprintf(pBuf, "\tGF");
3425 break;
3426 case HTMODE_MM:
3427 sprintf(pBuf, "\tMM");
3428 break;
3429 default:
3430 sprintf(pBuf, "\tUnknow Value(%u)", pAd->CommonCfg.RegTransmitSetting.field.HTMODE);
3431 break;
3433 return 0;
3436 INT Show_HtExtcha_Proc(
3437 IN PRTMP_ADAPTER pAd,
3438 OUT PUCHAR pBuf)
3440 switch(pAd->CommonCfg.RegTransmitSetting.field.EXTCHA)
3442 case EXTCHA_BELOW:
3443 sprintf(pBuf, "\tBelow");
3444 break;
3445 case EXTCHA_ABOVE:
3446 sprintf(pBuf, "\tAbove");
3447 break;
3448 default:
3449 sprintf(pBuf, "\tUnknow Value(%u)", pAd->CommonCfg.RegTransmitSetting.field.EXTCHA);
3450 break;
3452 return 0;
3456 INT Show_HtMpduDensity_Proc(
3457 IN PRTMP_ADAPTER pAd,
3458 OUT PUCHAR pBuf)
3460 sprintf(pBuf, "\t%u", pAd->CommonCfg.BACapability.field.MpduDensity);
3461 return 0;
3464 INT Show_HtBaWinSize_Proc(
3465 IN PRTMP_ADAPTER pAd,
3466 OUT PUCHAR pBuf)
3468 sprintf(pBuf, "\t%u", pAd->CommonCfg.BACapability.field.RxBAWinLimit);
3469 return 0;
3472 INT Show_HtRdg_Proc(
3473 IN PRTMP_ADAPTER pAd,
3474 OUT PUCHAR pBuf)
3476 sprintf(pBuf, "\t%s", pAd->CommonCfg.bRdg ? "TRUE":"FALSE");
3477 return 0;
3480 INT Show_HtAmsdu_Proc(
3481 IN PRTMP_ADAPTER pAd,
3482 OUT PUCHAR pBuf)
3484 sprintf(pBuf, "\t%s", pAd->CommonCfg.BACapability.field.AmsduEnable ? "TRUE":"FALSE");
3485 return 0;
3488 INT Show_HtAutoBa_Proc(
3489 IN PRTMP_ADAPTER pAd,
3490 OUT PUCHAR pBuf)
3492 sprintf(pBuf, "\t%s", pAd->CommonCfg.BACapability.field.AutoBA ? "TRUE":"FALSE");
3493 return 0;
3495 #endif // DOT11_N_SUPPORT //
3497 INT Show_CountryRegion_Proc(
3498 IN PRTMP_ADAPTER pAd,
3499 OUT PUCHAR pBuf)
3501 sprintf(pBuf, "\t%d", pAd->CommonCfg.CountryRegion);
3502 return 0;
3505 INT Show_CountryRegionABand_Proc(
3506 IN PRTMP_ADAPTER pAd,
3507 OUT PUCHAR pBuf)
3509 sprintf(pBuf, "\t%d", pAd->CommonCfg.CountryRegionForABand);
3510 return 0;
3513 INT Show_CountryCode_Proc(
3514 IN PRTMP_ADAPTER pAd,
3515 OUT PUCHAR pBuf)
3517 sprintf(pBuf, "\t%s", pAd->CommonCfg.CountryCode);
3518 return 0;
3521 #ifdef AGGREGATION_SUPPORT
3522 INT Show_PktAggregate_Proc(
3523 IN PRTMP_ADAPTER pAd,
3524 OUT PUCHAR pBuf)
3526 sprintf(pBuf, "\t%s", pAd->CommonCfg.bAggregationCapable ? "TRUE":"FALSE");
3527 return 0;
3529 #endif // AGGREGATION_SUPPORT //
3531 #ifdef WMM_SUPPORT
3532 INT Show_WmmCapable_Proc(
3533 IN PRTMP_ADAPTER pAd,
3534 OUT PUCHAR pBuf)
3537 #ifdef CONFIG_STA_SUPPORT
3538 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
3539 sprintf(pBuf, "\t%s", pAd->CommonCfg.bWmmCapable ? "TRUE":"FALSE");
3540 #endif // CONFIG_STA_SUPPORT //
3542 return 0;
3544 #endif // WMM_SUPPORT //
3546 INT Show_IEEE80211H_Proc(
3547 IN PRTMP_ADAPTER pAd,
3548 OUT PUCHAR pBuf)
3550 sprintf(pBuf, "\t%s", pAd->CommonCfg.bIEEE80211H ? "TRUE":"FALSE");
3551 return 0;
3554 #ifdef CONFIG_STA_SUPPORT
3555 INT Show_NetworkType_Proc(
3556 IN PRTMP_ADAPTER pAd,
3557 OUT PUCHAR pBuf)
3559 switch(pAd->StaCfg.BssType)
3561 case BSS_ADHOC:
3562 sprintf(pBuf, "\tAdhoc");
3563 break;
3564 case BSS_INFRA:
3565 sprintf(pBuf, "\tInfra");
3566 break;
3567 case BSS_ANY:
3568 sprintf(pBuf, "\tAny");
3569 break;
3570 case BSS_MONITOR:
3571 sprintf(pBuf, "\tMonitor");
3572 break;
3573 default:
3574 sprintf(pBuf, "\tUnknow Value(%d)", pAd->StaCfg.BssType);
3575 break;
3577 return 0;
3579 #endif // CONFIG_STA_SUPPORT //
3581 INT Show_AuthMode_Proc(
3582 IN PRTMP_ADAPTER pAd,
3583 OUT PUCHAR pBuf)
3585 NDIS_802_11_AUTHENTICATION_MODE AuthMode = Ndis802_11AuthModeOpen;
3587 #ifdef CONFIG_STA_SUPPORT
3588 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
3589 AuthMode = pAd->StaCfg.AuthMode;
3590 #endif // CONFIG_STA_SUPPORT //
3592 if ((AuthMode >= Ndis802_11AuthModeOpen) &&
3593 (AuthMode <= Ndis802_11AuthModeWPA1PSKWPA2PSK))
3594 sprintf(pBuf, "\t%s", RTMPGetRalinkAuthModeStr(AuthMode));
3595 else
3596 sprintf(pBuf, "\tUnknow Value(%d)", AuthMode);
3598 return 0;
3601 INT Show_EncrypType_Proc(
3602 IN PRTMP_ADAPTER pAd,
3603 OUT PUCHAR pBuf)
3605 NDIS_802_11_WEP_STATUS WepStatus = Ndis802_11WEPDisabled;
3607 #ifdef CONFIG_STA_SUPPORT
3608 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
3609 WepStatus = pAd->StaCfg.WepStatus;
3610 #endif // CONFIG_STA_SUPPORT //
3612 if ((WepStatus >= Ndis802_11WEPEnabled) &&
3613 (WepStatus <= Ndis802_11Encryption4KeyAbsent))
3614 sprintf(pBuf, "\t%s", RTMPGetRalinkEncryModeStr(WepStatus));
3615 else
3616 sprintf(pBuf, "\tUnknow Value(%d)", WepStatus);
3618 return 0;
3621 INT Show_DefaultKeyID_Proc(
3622 IN PRTMP_ADAPTER pAd,
3623 OUT PUCHAR pBuf)
3625 UCHAR DefaultKeyId = 0;
3627 #ifdef CONFIG_STA_SUPPORT
3628 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
3629 DefaultKeyId = pAd->StaCfg.DefaultKeyId;
3630 #endif // CONFIG_STA_SUPPORT //
3632 sprintf(pBuf, "\t%d", DefaultKeyId);
3634 return 0;
3637 INT Show_WepKey_Proc(
3638 IN PRTMP_ADAPTER pAd,
3639 IN INT KeyIdx,
3640 OUT PUCHAR pBuf)
3642 UCHAR Key[16] = {0}, KeyLength = 0;
3643 INT index = BSS0;
3645 KeyLength = pAd->SharedKey[index][KeyIdx].KeyLen;
3646 NdisMoveMemory(Key, pAd->SharedKey[index][KeyIdx].Key, KeyLength);
3648 //check key string is ASCII or not
3649 if (RTMPCheckStrPrintAble(Key, KeyLength))
3650 sprintf(pBuf, "\t%s", Key);
3651 else
3653 int idx;
3654 sprintf(pBuf, "\t");
3655 for (idx = 0; idx < KeyLength; idx++)
3656 sprintf(pBuf+strlen(pBuf), "%02X", Key[idx]);
3658 return 0;
3661 INT Show_Key1_Proc(
3662 IN PRTMP_ADAPTER pAd,
3663 OUT PUCHAR pBuf)
3665 Show_WepKey_Proc(pAd, 0, pBuf);
3666 return 0;
3669 INT Show_Key2_Proc(
3670 IN PRTMP_ADAPTER pAd,
3671 OUT PUCHAR pBuf)
3673 Show_WepKey_Proc(pAd, 1, pBuf);
3674 return 0;
3677 INT Show_Key3_Proc(
3678 IN PRTMP_ADAPTER pAd,
3679 OUT PUCHAR pBuf)
3681 Show_WepKey_Proc(pAd, 2, pBuf);
3682 return 0;
3685 INT Show_Key4_Proc(
3686 IN PRTMP_ADAPTER pAd,
3687 OUT PUCHAR pBuf)
3689 Show_WepKey_Proc(pAd, 3, pBuf);
3690 return 0;
3693 INT Show_WPAPSK_Proc(
3694 IN PRTMP_ADAPTER pAd,
3695 OUT PUCHAR pBuf)
3697 INT idx;
3698 UCHAR PMK[32] = {0};
3701 #ifdef CONFIG_STA_SUPPORT
3702 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
3703 NdisMoveMemory(PMK, pAd->StaCfg.PMK, 32);
3704 #endif // CONFIG_STA_SUPPORT //
3706 sprintf(pBuf, "\tPMK = ");
3707 for (idx = 0; idx < 32; idx++)
3708 sprintf(pBuf+strlen(pBuf), "%02X", PMK[idx]);
3710 return 0;