2 *************************************************************************
4 * 5F., No.36, Taiyuan St., Jhubei City,
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. *
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. *
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. *
25 *************************************************************************
28 #include "../rt_config.h"
34 INT Show_WirelessMode_Proc(
38 INT Show_TxBurst_Proc(
42 INT Show_TxPreamble_Proc(
46 INT Show_TxPower_Proc(
50 INT Show_Channel_Proc(
54 INT Show_BGProtection_Proc(
58 INT Show_RTSThreshold_Proc(
62 INT Show_FragThreshold_Proc(
66 #ifdef DOT11_N_SUPPORT
79 INT Show_HtOpMode_Proc(
83 INT Show_HtExtcha_Proc(
87 INT Show_HtMpduDensity_Proc(
91 INT Show_HtBaWinSize_Proc(
99 INT Show_HtAmsdu_Proc(
100 IN PRTMP_ADAPTER pAd,
103 INT Show_HtAutoBa_Proc(
104 IN PRTMP_ADAPTER pAd,
106 #endif // DOT11_N_SUPPORT //
108 INT Show_CountryRegion_Proc(
109 IN PRTMP_ADAPTER pAd,
112 INT Show_CountryRegionABand_Proc(
113 IN PRTMP_ADAPTER pAd,
116 INT Show_CountryCode_Proc(
117 IN PRTMP_ADAPTER pAd,
120 #ifdef AGGREGATION_SUPPORT
121 INT Show_PktAggregate_Proc(
122 IN PRTMP_ADAPTER pAd,
124 #endif // AGGREGATION_SUPPORT //
127 INT Show_WmmCapable_Proc(
128 IN PRTMP_ADAPTER pAd,
130 #endif // WMM_SUPPORT //
132 INT Show_IEEE80211H_Proc(
133 IN PRTMP_ADAPTER pAd,
136 INT Show_NetworkType_Proc(
137 IN PRTMP_ADAPTER pAd,
140 INT Show_AuthMode_Proc(
141 IN PRTMP_ADAPTER pAd,
144 INT Show_EncrypType_Proc(
145 IN PRTMP_ADAPTER pAd,
148 INT Show_DefaultKeyID_Proc(
149 IN PRTMP_ADAPTER pAd,
153 IN PRTMP_ADAPTER pAd,
157 IN PRTMP_ADAPTER pAd,
161 IN PRTMP_ADAPTER pAd,
165 IN PRTMP_ADAPTER pAd,
168 INT Show_WPAPSK_Proc(
169 IN PRTMP_ADAPTER pAd,
174 INT (*show_proc)(PRTMP_ADAPTER pAdapter, PUCHAR arg);
175 } *PRTMP_PRIVATE_STA_SHOW_CFG_VALUE_PROC, RTMP_PRIVATE_STA_SHOW_CFG_VALUE_PROC[] = {
176 {"SSID", Show_SSID_Proc},
177 {"WirelessMode", Show_WirelessMode_Proc},
178 {"TxBurst", Show_TxBurst_Proc},
179 {"TxPreamble", Show_TxPreamble_Proc},
180 {"TxPower", Show_TxPower_Proc},
181 {"Channel", Show_Channel_Proc},
182 {"BGProtection", Show_BGProtection_Proc},
183 {"RTSThreshold", Show_RTSThreshold_Proc},
184 {"FragThreshold", Show_FragThreshold_Proc},
185 #ifdef DOT11_N_SUPPORT
186 {"HtBw", Show_HtBw_Proc},
187 {"HtMcs", Show_HtMcs_Proc},
188 {"HtGi", Show_HtGi_Proc},
189 {"HtOpMode", Show_HtOpMode_Proc},
190 {"HtExtcha", Show_HtExtcha_Proc},
191 {"HtMpduDensity", Show_HtMpduDensity_Proc},
192 {"HtBaWinSize", Show_HtBaWinSize_Proc},
193 {"HtRdg", Show_HtRdg_Proc},
194 {"HtAmsdu", Show_HtAmsdu_Proc},
195 {"HtAutoBa", Show_HtAutoBa_Proc},
196 #endif // DOT11_N_SUPPORT //
197 {"CountryRegion", Show_CountryRegion_Proc},
198 {"CountryRegionABand", Show_CountryRegionABand_Proc},
199 {"CountryCode", Show_CountryCode_Proc},
200 #ifdef AGGREGATION_SUPPORT
201 {"PktAggregate", Show_PktAggregate_Proc},
205 {"WmmCapable", Show_WmmCapable_Proc},
207 {"IEEE80211H", Show_IEEE80211H_Proc},
208 {"NetworkType", Show_NetworkType_Proc},
209 {"AuthMode", Show_AuthMode_Proc},
210 {"EncrypType", Show_EncrypType_Proc},
211 {"DefaultKeyID", Show_DefaultKeyID_Proc},
212 {"Key1", Show_Key1_Proc},
213 {"Key2", Show_Key2_Proc},
214 {"Key3", Show_Key3_Proc},
215 {"Key4", Show_Key4_Proc},
216 {"WPAPSK", Show_WPAPSK_Proc},
221 ==========================================================================
226 ==========================================================================
228 INT Set_DriverVersion_Proc(
229 IN PRTMP_ADAPTER pAd,
232 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
233 DBGPRINT(RT_DEBUG_TRACE, ("Driver version-%s\n", STA_DRIVER_VERSION));
239 ==========================================================================
242 This command will not work, if the field of CountryRegion in eeprom is programmed.
244 TRUE if all parameters are OK, FALSE otherwise
245 ==========================================================================
247 INT Set_CountryRegion_Proc(
248 IN PRTMP_ADAPTER pAd,
253 region = simple_strtol(arg, 0, 10);
255 // Country can be set only when EEPROM not programmed
256 if (pAd->CommonCfg.CountryRegion & 0x80)
258 DBGPRINT(RT_DEBUG_ERROR, ("Set_CountryRegion_Proc::parameter of CountryRegion in eeprom is programmed \n"));
262 if((region >= 0) && (region <= REGION_MAXIMUM_BG_BAND))
264 pAd->CommonCfg.CountryRegion = (UCHAR) region;
266 else if (region == REGION_31_BG_BAND)
268 pAd->CommonCfg.CountryRegion = (UCHAR) region;
272 DBGPRINT(RT_DEBUG_ERROR, ("Set_CountryRegion_Proc::parameters out of range\n"));
276 // if set country region, driver needs to be reset
277 BuildChannelList(pAd);
279 DBGPRINT(RT_DEBUG_TRACE, ("Set_CountryRegion_Proc::(CountryRegion=%d)\n", pAd->CommonCfg.CountryRegion));
285 ==========================================================================
287 Set Country Region for A band.
288 This command will not work, if the field of CountryRegion in eeprom is programmed.
290 TRUE if all parameters are OK, FALSE otherwise
291 ==========================================================================
293 INT Set_CountryRegionABand_Proc(
294 IN PRTMP_ADAPTER pAd,
299 region = simple_strtol(arg, 0, 10);
301 // Country can be set only when EEPROM not programmed
302 if (pAd->CommonCfg.CountryRegionForABand & 0x80)
304 DBGPRINT(RT_DEBUG_ERROR, ("Set_CountryRegionABand_Proc::parameter of CountryRegion in eeprom is programmed \n"));
308 if((region >= 0) && (region <= REGION_MAXIMUM_A_BAND))
310 pAd->CommonCfg.CountryRegionForABand = (UCHAR) region;
314 DBGPRINT(RT_DEBUG_ERROR, ("Set_CountryRegionABand_Proc::parameters out of range\n"));
318 // if set country region, driver needs to be reset
319 BuildChannelList(pAd);
321 DBGPRINT(RT_DEBUG_TRACE, ("Set_CountryRegionABand_Proc::(CountryRegion=%d)\n", pAd->CommonCfg.CountryRegionForABand));
327 ==========================================================================
331 TRUE if all parameters are OK, FALSE otherwise
332 ==========================================================================
334 INT Set_WirelessMode_Proc(
335 IN PRTMP_ADAPTER pAd,
341 WirelessMode = simple_strtol(arg, 0, 10);
343 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
345 INT MaxPhyMode = PHY_11G;
347 #ifdef DOT11_N_SUPPORT
348 MaxPhyMode = PHY_11N_5G;
349 #endif // DOT11_N_SUPPORT //
351 if (WirelessMode <= MaxPhyMode)
353 RTMPSetPhyMode(pAd, WirelessMode);
354 #ifdef DOT11_N_SUPPORT
355 if (WirelessMode >= PHY_11ABGN_MIXED)
357 pAd->CommonCfg.BACapability.field.AutoBA = TRUE;
358 pAd->CommonCfg.REGBACapability.field.AutoBA = TRUE;
362 pAd->CommonCfg.BACapability.field.AutoBA = FALSE;
363 pAd->CommonCfg.REGBACapability.field.AutoBA = FALSE;
365 #endif // DOT11_N_SUPPORT //
366 // Set AdhocMode rates
367 if (pAd->StaCfg.BssType == BSS_ADHOC)
369 MlmeUpdateTxRates(pAd, FALSE, 0);
370 MakeIbssBeacon(pAd); // re-build BEACON frame
371 AsicEnableIbssSync(pAd); // copy to on-chip memory
380 // it is needed to set SSID to take effect
383 #ifdef DOT11_N_SUPPORT
385 #endif // DOT11_N_SUPPORT //
386 DBGPRINT(RT_DEBUG_TRACE, ("Set_WirelessMode_Proc::(=%ld)\n", WirelessMode));
390 DBGPRINT(RT_DEBUG_ERROR, ("Set_WirelessMode_Proc::parameters out of range\n"));
397 ==========================================================================
401 TRUE if all parameters are OK, FALSE otherwise
402 ==========================================================================
404 INT Set_Channel_Proc(
405 IN PRTMP_ADAPTER pAd,
411 Channel = (UCHAR) simple_strtol(arg, 0, 10);
413 // check if this channel is valid
414 if (ChannelSanity(pAd, Channel) == TRUE)
416 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
418 pAd->CommonCfg.Channel = Channel;
422 #ifdef DOT11_N_SUPPORT
424 if (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED &&
425 pAd->CommonCfg.RegTransmitSetting.field.BW == BW_40)
428 AsicSwitchChannel(pAd, pAd->CommonCfg.CentralChannel, FALSE);
429 AsicLockChannel(pAd, pAd->CommonCfg.CentralChannel);
430 DBGPRINT(RT_DEBUG_TRACE, ("BW_40, control_channel(%d), CentralChannel(%d) \n",
431 pAd->CommonCfg.Channel, pAd->CommonCfg.CentralChannel));
434 #endif // DOT11_N_SUPPORT //
436 AsicSwitchChannel(pAd, pAd->CommonCfg.Channel, FALSE);
437 AsicLockChannel(pAd, pAd->CommonCfg.Channel);
438 DBGPRINT(RT_DEBUG_TRACE, ("BW_20, Channel(%d)\n", pAd->CommonCfg.Channel));
446 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
452 DBGPRINT(RT_DEBUG_TRACE, ("Set_Channel_Proc::(Channel=%d)\n", pAd->CommonCfg.Channel));
458 ==========================================================================
460 Set Short Slot Time Enable or Disable
462 TRUE if all parameters are OK, FALSE otherwise
463 ==========================================================================
465 INT Set_ShortSlot_Proc(
466 IN PRTMP_ADAPTER pAd,
471 ShortSlot = simple_strtol(arg, 0, 10);
474 pAd->CommonCfg.bUseShortSlotTime = TRUE;
475 else if (ShortSlot == 0)
476 pAd->CommonCfg.bUseShortSlotTime = FALSE;
478 return FALSE; //Invalid argument
480 DBGPRINT(RT_DEBUG_TRACE, ("Set_ShortSlot_Proc::(ShortSlot=%d)\n", pAd->CommonCfg.bUseShortSlotTime));
486 ==========================================================================
490 TRUE if all parameters are OK, FALSE otherwise
491 ==========================================================================
493 INT Set_TxPower_Proc(
494 IN PRTMP_ADAPTER pAd,
500 TxPower = (ULONG) simple_strtol(arg, 0, 10);
503 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
505 pAd->CommonCfg.TxPowerDefault = TxPower;
506 pAd->CommonCfg.TxPowerPercentage = pAd->CommonCfg.TxPowerDefault;
513 DBGPRINT(RT_DEBUG_TRACE, ("Set_TxPower_Proc::(TxPowerPercentage=%ld)\n", pAd->CommonCfg.TxPowerPercentage));
519 ==========================================================================
521 Set 11B/11G Protection
523 TRUE if all parameters are OK, FALSE otherwise
524 ==========================================================================
526 INT Set_BGProtection_Proc(
527 IN PRTMP_ADAPTER pAd,
530 switch (simple_strtol(arg, 0, 10))
533 pAd->CommonCfg.UseBGProtection = 0;
536 pAd->CommonCfg.UseBGProtection = 1;
539 pAd->CommonCfg.UseBGProtection = 2;
541 default: //Invalid argument
546 DBGPRINT(RT_DEBUG_TRACE, ("Set_BGProtection_Proc::(BGProtection=%ld)\n", pAd->CommonCfg.UseBGProtection));
552 ==========================================================================
556 TRUE if all parameters are OK, FALSE otherwise
557 ==========================================================================
559 INT Set_TxPreamble_Proc(
560 IN PRTMP_ADAPTER pAd,
563 RT_802_11_PREAMBLE Preamble;
565 Preamble = simple_strtol(arg, 0, 10);
570 case Rt802_11PreambleShort:
571 pAd->CommonCfg.TxPreamble = Preamble;
573 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
574 MlmeSetTxPreamble(pAd, Rt802_11PreambleShort);
576 case Rt802_11PreambleLong:
577 case Rt802_11PreambleAuto:
578 // if user wants AUTO, initialize to LONG here, then change according to AP's
579 // capability upon association.
580 pAd->CommonCfg.TxPreamble = Preamble;
582 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
583 MlmeSetTxPreamble(pAd, Rt802_11PreambleLong);
585 default: //Invalid argument
589 DBGPRINT(RT_DEBUG_TRACE, ("Set_TxPreamble_Proc::(TxPreamble=%ld)\n", pAd->CommonCfg.TxPreamble));
595 ==========================================================================
599 TRUE if all parameters are OK, FALSE otherwise
600 ==========================================================================
602 INT Set_RTSThreshold_Proc(
603 IN PRTMP_ADAPTER pAd,
606 NDIS_802_11_RTS_THRESHOLD RtsThresh;
608 RtsThresh = simple_strtol(arg, 0, 10);
610 if((RtsThresh > 0) && (RtsThresh <= MAX_RTS_THRESHOLD))
611 pAd->CommonCfg.RtsThreshold = (USHORT)RtsThresh;
612 else if (RtsThresh == 0)
613 pAd->CommonCfg.RtsThreshold = MAX_RTS_THRESHOLD;
615 return FALSE; //Invalid argument
617 DBGPRINT(RT_DEBUG_TRACE, ("Set_RTSThreshold_Proc::(RTSThreshold=%d)\n", pAd->CommonCfg.RtsThreshold));
623 ==========================================================================
625 Set Fragment Threshold
627 TRUE if all parameters are OK, FALSE otherwise
628 ==========================================================================
630 INT Set_FragThreshold_Proc(
631 IN PRTMP_ADAPTER pAd,
634 NDIS_802_11_FRAGMENTATION_THRESHOLD FragThresh;
636 FragThresh = simple_strtol(arg, 0, 10);
638 if (FragThresh > MAX_FRAG_THRESHOLD || FragThresh < MIN_FRAG_THRESHOLD)
640 //Illegal FragThresh so we set it to default
641 pAd->CommonCfg.FragmentThreshold = MAX_FRAG_THRESHOLD;
643 else if (FragThresh % 2 == 1)
645 // The length of each fragment shall always be an even number of octets, except for the last fragment
646 // of an MSDU or MMPDU, which may be either an even or an odd number of octets.
647 pAd->CommonCfg.FragmentThreshold = (USHORT)(FragThresh - 1);
651 pAd->CommonCfg.FragmentThreshold = (USHORT)FragThresh;
654 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
656 if (pAd->CommonCfg.FragmentThreshold == MAX_FRAG_THRESHOLD)
657 pAd->CommonCfg.bUseZeroToDisableFragment = TRUE;
659 pAd->CommonCfg.bUseZeroToDisableFragment = FALSE;
662 DBGPRINT(RT_DEBUG_TRACE, ("Set_FragThreshold_Proc::(FragThreshold=%d)\n", pAd->CommonCfg.FragmentThreshold));
668 ==========================================================================
672 TRUE if all parameters are OK, FALSE otherwise
673 ==========================================================================
675 INT Set_TxBurst_Proc(
676 IN PRTMP_ADAPTER pAd,
681 TxBurst = simple_strtol(arg, 0, 10);
683 pAd->CommonCfg.bEnableTxBurst = TRUE;
684 else if (TxBurst == 0)
685 pAd->CommonCfg.bEnableTxBurst = FALSE;
687 return FALSE; //Invalid argument
689 DBGPRINT(RT_DEBUG_TRACE, ("Set_TxBurst_Proc::(TxBurst=%d)\n", pAd->CommonCfg.bEnableTxBurst));
694 #ifdef AGGREGATION_SUPPORT
696 ==========================================================================
700 TRUE if all parameters are OK, FALSE otherwise
701 ==========================================================================
703 INT Set_PktAggregate_Proc(
704 IN PRTMP_ADAPTER pAd,
709 aggre = simple_strtol(arg, 0, 10);
712 pAd->CommonCfg.bAggregationCapable = TRUE;
714 pAd->CommonCfg.bAggregationCapable = FALSE;
716 return FALSE; //Invalid argument
719 DBGPRINT(RT_DEBUG_TRACE, ("Set_PktAggregate_Proc::(AGGRE=%d)\n", pAd->CommonCfg.bAggregationCapable));
726 ==========================================================================
729 This parameter is 1 when needs radar detection, otherwise 0
731 TRUE if all parameters are OK, FALSE otherwise
732 ==========================================================================
734 INT Set_IEEE80211H_Proc(
735 IN PRTMP_ADAPTER pAd,
740 ieee80211h = simple_strtol(arg, 0, 10);
743 pAd->CommonCfg.bIEEE80211H = TRUE;
744 else if (ieee80211h == 0)
745 pAd->CommonCfg.bIEEE80211H = FALSE;
747 return FALSE; //Invalid argument
749 DBGPRINT(RT_DEBUG_TRACE, ("Set_IEEE80211H_Proc::(IEEE80211H=%d)\n", pAd->CommonCfg.bIEEE80211H));
757 ==========================================================================
759 For Debug information
761 TRUE if all parameters are OK, FALSE otherwise
762 ==========================================================================
765 IN PRTMP_ADAPTER pAd,
768 DBGPRINT(RT_DEBUG_TRACE, ("==> Set_Debug_Proc *******************\n"));
770 if(simple_strtol(arg, 0, 10) <= RT_DEBUG_LOUD)
771 RTDebugLevel = simple_strtol(arg, 0, 10);
773 DBGPRINT(RT_DEBUG_TRACE, ("<== Set_Debug_Proc(RTDebugLevel = %ld)\n", RTDebugLevel));
779 INT Show_DescInfo_Proc(
780 IN PRTMP_ADAPTER pAd,
788 ==========================================================================
790 Reset statistics counter
793 pAdapter Pointer to our adapter
797 TRUE if all parameters are OK, FALSE otherwise
798 ==========================================================================
800 INT Set_ResetStatCounter_Proc(
801 IN PRTMP_ADAPTER pAd,
805 //MAC_TABLE_ENTRY *pEntry;
807 DBGPRINT(RT_DEBUG_TRACE, ("==>Set_ResetStatCounter_Proc\n"));
809 // add the most up-to-date h/w raw counters into software counters
810 NICUpdateRawCounters(pAd);
812 NdisZeroMemory(&pAd->WlanCounters, sizeof(COUNTER_802_11));
813 NdisZeroMemory(&pAd->Counters8023, sizeof(COUNTER_802_3));
814 NdisZeroMemory(&pAd->RalinkCounters, sizeof(COUNTER_RALINK));
816 // Reset HotSpot counter
818 for (i = 0; i < MAX_LEN_OF_MAC_TABLE; i++)
820 pEntry = &pAd->MacTab.Content[i];
822 if ((pEntry->Valid == FALSE) || (pEntry->Sst != SST_ASSOC))
825 pEntry->HSCounter.LastDataPacketTime = 0;
826 pEntry->HSCounter.TotalRxByteCount= 0;
827 pEntry->HSCounter.TotalTxByteCount= 0;
836 ========================================================================
840 In Adhoc WPANONE, bPairwise = 0; KeyIdx = 0;
843 pAd Pointer to our adapter
844 pBuf Pointer to the where the key stored
847 NDIS_SUCCESS Add key successfully
849 IRQL = DISPATCH_LEVEL
853 ========================================================================
855 #if 0 // remove by AlbertY
856 NDIS_STATUS RTMPWPAAddKeyProc(
857 IN PRTMP_ADAPTER pAd,
860 PNDIS_802_11_KEY pKey;
862 // NDIS_STATUS Status;
863 // ULONG offset; // unused variable, snowpin 2006.07.13
865 PUCHAR pTxMic, pRxMic;
866 BOOLEAN bTxKey; // Set the key as transmit key
867 BOOLEAN bPairwise; // Indicate the key is pairwise key
868 BOOLEAN bKeyRSC; // indicate the receive SC set by KeyRSC value.
869 // Otherwise, it will set by the NIC.
870 BOOLEAN bAuthenticator; // indicate key is set by authenticator.
873 pKey = (PNDIS_802_11_KEY) pBuf;
874 KeyIdx = pKey->KeyIndex & 0xff;
875 // Bit 31 of Add-key, Tx Key
876 bTxKey = (pKey->KeyIndex & 0x80000000) ? TRUE : FALSE;
877 // Bit 30 of Add-key PairwiseKey
878 bPairwise = (pKey->KeyIndex & 0x40000000) ? TRUE : FALSE;
879 // Bit 29 of Add-key KeyRSC
880 bKeyRSC = (pKey->KeyIndex & 0x20000000) ? TRUE : FALSE;
881 // Bit 28 of Add-key Authenticator
882 bAuthenticator = (pKey->KeyIndex & 0x10000000) ? TRUE : FALSE;
884 DBGPRINT(RT_DEBUG_TRACE,("RTMPWPAAddKeyProc==>pKey->KeyIndex = %x. bPairwise= %d\n", pKey->KeyIndex, bPairwise));
885 // 1. Check Group / Pairwise Key
886 if (bPairwise) // Pairwise Key
888 // 1. KeyIdx must be 0, otherwise, return NDIS_STATUS_INVALID_DATA
890 return(NDIS_STATUS_INVALID_DATA);
892 // 2. Check bTx, it must be true, otherwise, return NDIS_STATUS_INVALID_DATA
894 return(NDIS_STATUS_INVALID_DATA);
896 // 3. If BSSID is all 0xff, return NDIS_STATUS_INVALID_DATA
897 if (MAC_ADDR_EQUAL(pKey->BSSID, BROADCAST_ADDR))
898 return(NDIS_STATUS_INVALID_DATA);
900 // 3.1 Check Pairwise key length for TKIP key. For AES, it's always 128 bits
901 //if ((pAdapter->PortCfg.WepStatus == Ndis802_11Encryption2Enabled) && (pKey->KeyLength != LEN_TKIP_KEY))
902 if ((pAd->StaCfg.PairCipher == Ndis802_11Encryption2Enabled) && (pKey->KeyLength != LEN_TKIP_KEY))
903 return(NDIS_STATUS_INVALID_DATA);
905 pAd->SharedKey[apidx][KeyIdx].Type = PAIRWISE_KEY;
907 if (pAd->ApCfg.MBSSID[apidx].AuthMode == Ndis802_11AuthModeWPA2)
909 // Send media specific event to start PMKID caching
910 RTMPIndicateWPA2Status(pAd);
915 // 1. Check BSSID, if not current BSSID or Bcast, return NDIS_STATUS_INVALID_DATA
916 if ((! MAC_ADDR_EQUAL(pKey->BSSID, BROADCAST_ADDR)) &&
917 (! MAC_ADDR_EQUAL(pKey->BSSID, pAd->ApCfg.MBSSID[apidx].Bssid)))
918 return(NDIS_STATUS_INVALID_DATA);
920 // 2. Check Key index for supported Group Key
921 if (KeyIdx >= GROUP_KEY_NUM)
922 return(NDIS_STATUS_INVALID_DATA);
924 // 3. Set as default Tx Key if bTxKey is TRUE
926 pAd->ApCfg.MBSSID[apidx].DefaultKeyId = (UCHAR) KeyIdx;
928 pAd->SharedKey[apidx][KeyIdx].Type = GROUP_KEY;
931 // 4. Select RxMic / TxMic based on Supp / Authenticator
932 if (pAd->ApCfg.MBSSID[apidx].AuthMode == Ndis802_11AuthModeWPANone)
934 // for WPA-None Tx, Rx MIC is the same
935 pTxMic = (PUCHAR) (&pKey->KeyMaterial) + 16;
938 else if (bAuthenticator == TRUE)
940 pTxMic = (PUCHAR) (&pKey->KeyMaterial) + 16;
941 pRxMic = (PUCHAR) (&pKey->KeyMaterial) + 24;
945 pRxMic = (PUCHAR) (&pKey->KeyMaterial) + 16;
946 pTxMic = (PUCHAR) (&pKey->KeyMaterial) + 24;
952 NdisMoveMemory(pAd->SharedKey[apidx][KeyIdx].RxTsc, &pKey->KeyRSC, 6);
953 NdisMoveMemory(pAd->MacTab.Content[BSSID_WCID].PairwiseKey.RxTsc, &pKey->KeyRSC, 6);
957 NdisZeroMemory(pAd->SharedKey[apidx][KeyIdx].RxTsc, 6);
960 // 7. Copy information into Pairwise Key structure.
961 // pKey->KeyLength will include TxMic and RxMic, therefore, we use 16 bytes hardcoded.
962 pAd->SharedKey[apidx][KeyIdx].KeyLen = (UCHAR) pKey->KeyLength;
963 pAd->MacTab.Content[BSSID_WCID].PairwiseKey.KeyLen = (UCHAR)pKey->KeyLength;
964 NdisMoveMemory(pAd->SharedKey[BSS0][KeyIdx].Key, &pKey->KeyMaterial, 16);
965 NdisMoveMemory(pAd->MacTab.Content[BSSID_WCID].PairwiseKey.Key, &pKey->KeyMaterial, 16);
966 if (pKey->KeyLength == LEN_TKIP_KEY)
968 // Only Key lenth equal to TKIP key have these
969 NdisMoveMemory(pAd->SharedKey[apidx][KeyIdx].RxMic, pRxMic, 8);
970 NdisMoveMemory(pAd->SharedKey[apidx][KeyIdx].TxMic, pTxMic, 8);
971 NdisMoveMemory(pAd->MacTab.Content[BSSID_WCID].PairwiseKey.RxMic, pRxMic, 8);
972 NdisMoveMemory(pAd->MacTab.Content[BSSID_WCID].PairwiseKey.TxMic, pTxMic, 8);
975 COPY_MAC_ADDR(pAd->SharedKey[BSS0][KeyIdx].BssId, pKey->BSSID);
977 // Init TxTsc to one based on WiFi WPA specs
978 pAd->SharedKey[apidx][KeyIdx].TxTsc[0] = 1;
979 pAd->SharedKey[apidx][KeyIdx].TxTsc[1] = 0;
980 pAd->SharedKey[apidx][KeyIdx].TxTsc[2] = 0;
981 pAd->SharedKey[apidx][KeyIdx].TxTsc[3] = 0;
982 pAd->SharedKey[apidx][KeyIdx].TxTsc[4] = 0;
983 pAd->SharedKey[apidx][KeyIdx].TxTsc[5] = 0;
984 // 4. Init TxTsc to one based on WiFi WPA specs
985 pAd->MacTab.Content[BSSID_WCID].PairwiseKey.TxTsc[0] = 1;
986 pAd->MacTab.Content[BSSID_WCID].PairwiseKey.TxTsc[1] = 0;
987 pAd->MacTab.Content[BSSID_WCID].PairwiseKey.TxTsc[2] = 0;
988 pAd->MacTab.Content[BSSID_WCID].PairwiseKey.TxTsc[3] = 0;
989 pAd->MacTab.Content[BSSID_WCID].PairwiseKey.TxTsc[4] = 0;
990 pAd->MacTab.Content[BSSID_WCID].PairwiseKey.TxTsc[5] = 0;
992 if (pAd->ApCfg.MBSSID[apidx].WepStatus == Ndis802_11Encryption3Enabled)
994 pAd->SharedKey[apidx][KeyIdx].CipherAlg = CIPHER_AES;
995 pAd->MacTab.Content[BSSID_WCID].PairwiseKey.CipherAlg = CIPHER_AES;
997 else if (pAd->ApCfg.MBSSID[apidx].WepStatus == Ndis802_11Encryption2Enabled)
999 pAd->SharedKey[apidx][KeyIdx].CipherAlg = CIPHER_TKIP;
1000 pAd->MacTab.Content[BSSID_WCID].PairwiseKey.CipherAlg = CIPHER_TKIP;
1002 else if (pAd->ApCfg.MBSSID[apidx].WepStatus == Ndis802_11Encryption1Enabled)
1004 if (pAd->SharedKey[apidx][KeyIdx].KeyLen == 5)
1006 pAd->SharedKey[apidx][KeyIdx].CipherAlg = CIPHER_WEP64;
1007 pAd->MacTab.Content[BSSID_WCID].PairwiseKey.CipherAlg = CIPHER_WEP64;
1009 else if (pAd->SharedKey[apidx][KeyIdx].KeyLen == 13)
1011 pAd->SharedKey[apidx][KeyIdx].CipherAlg = CIPHER_WEP128;
1012 pAd->MacTab.Content[BSSID_WCID].PairwiseKey.CipherAlg = CIPHER_WEP128;
1016 pAd->SharedKey[apidx][KeyIdx].CipherAlg = CIPHER_NONE;
1017 pAd->MacTab.Content[BSSID_WCID].PairwiseKey.CipherAlg = CIPHER_NONE;
1022 pAd->SharedKey[apidx][KeyIdx].CipherAlg = CIPHER_NONE;
1023 pAd->MacTab.Content[BSSID_WCID].PairwiseKey.CipherAlg = CIPHER_NONE;
1026 if ((pAd->OpMode == OPMODE_STA)) // Pairwise Key. Add BSSID to WCTable
1028 pAd->MacTab.Content[BSSID_WCID].PairwiseKey.CipherAlg = pAd->SharedKey[BSS0][KeyIdx].CipherAlg;
1029 pAd->MacTab.Content[BSSID_WCID].PairwiseKey.KeyLen = pAd->SharedKey[BSS0][KeyIdx].KeyLen;
1032 if ((pAd->ApCfg.MBSSID[apidx].AuthMode == Ndis802_11AuthModeWPA2) ||
1033 (pAd->ApCfg.MBSSID[apidx].AuthMode == Ndis802_11AuthModeWPA2PSK))
1036 // On WPA2, Update Group Key Cipher.
1040 if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption3Enabled)
1041 pAd->SharedKey[apidx][KeyIdx].CipherAlg = CIPHER_AES;
1042 else if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption2Enabled)
1043 pAd->SharedKey[apidx][KeyIdx].CipherAlg = CIPHER_TKIP;
1047 DBGPRINT(RT_DEBUG_TRACE, ("pAd->SharedKey[%d][%d].CipherAlg = %d\n", apidx, KeyIdx, pAd->SharedKey[apidx][KeyIdx].CipherAlg));
1050 DBGPRINT_RAW(RT_DEBUG_TRACE, ("%s Key #%d", CipherName[pAd->SharedKey[apidx][KeyIdx].CipherAlg],KeyIdx));
1051 for (i = 0; i < 16; i++)
1053 DBGPRINT_RAW(RT_DEBUG_TRACE, ("%02x:", pAd->SharedKey[apidx][KeyIdx].Key[i]));
1055 DBGPRINT_RAW(RT_DEBUG_TRACE, ("\n Rx MIC Key = "));
1056 for (i = 0; i < 8; i++)
1058 DBGPRINT_RAW(RT_DEBUG_TRACE, ("%02x:", pAd->SharedKey[apidx][KeyIdx].RxMic[i]));
1060 DBGPRINT_RAW(RT_DEBUG_TRACE, ("\n Tx MIC Key = "));
1061 for (i = 0; i < 8; i++)
1063 DBGPRINT_RAW(RT_DEBUG_TRACE, ("%02x:", pAd->SharedKey[apidx][KeyIdx].TxMic[i]));
1065 DBGPRINT_RAW(RT_DEBUG_TRACE, ("\n RxTSC = "));
1066 for (i = 0; i < 6; i++)
1068 DBGPRINT_RAW(RT_DEBUG_TRACE, ("%02x:", pAd->SharedKey[apidx][KeyIdx].RxTsc[i]));
1071 DBGPRINT_RAW(RT_DEBUG_TRACE, ("\n pKey-> BSSID:%02x:%02x:%02x:%02x:%02x:%02x \n",
1072 pKey->BSSID[0],pKey->BSSID[1],pKey->BSSID[2],pKey->BSSID[3],pKey->BSSID[4],pKey->BSSID[5]));
1074 if ((bTxKey) && (pAd->OpMode == OPMODE_STA)) // Pairwise Key. Add BSSID to WCTable
1075 RTMPAddBSSIDCipher(pAd, BSSID_WCID, pKey, pAd->SharedKey[BSS0][KeyIdx].CipherAlg);
1078 // No matter pairwise key or what leyidx is, always has a copy at on-chip SharedKeytable.
1079 AsicAddSharedKeyEntry(pAd,
1082 pAd->SharedKey[apidx][KeyIdx].CipherAlg,
1083 pAd->SharedKey[apidx][KeyIdx].Key,
1084 pAd->SharedKey[apidx][KeyIdx].TxMic,
1085 pAd->SharedKey[apidx][KeyIdx].RxMic);
1087 // The WCID key specified in used at Tx. For STA, always use pairwise key.
1089 // ad-hoc mode need to specify WAP Group key with WCID index=BSS0Mcast_WCID. Let's always set this key here.
1090 /* if (bPairwise == FALSE)
1092 offset = MAC_IVEIV_TABLE_BASE + (BSS0Mcast_WCID * HW_IVEIV_ENTRY_SIZE);
1093 NdisZeroMemory(IVEIV, 8);
1095 // Specify key index to find shared key.
1096 if ((pAd->SharedKey[BSS0][KeyIdx].CipherAlg==CIPHER_TKIP) ||
1097 (pAd->SharedKey[BSS0][KeyIdx].CipherAlg==CIPHER_AES))
1098 IVEIV[3] = 0x20; // Eiv bit on. keyid always 0 for pairwise key
1099 IVEIV[3] |= (KeyIdx<< 6); // groupkey index is not 0
1102 RTMP_IO_WRITE8(pAd, offset+i, IVEIV[i]);
1105 // 2. WCID Attribute UDF:3, BSSIdx:3, Alg:3, Keytable:use share key, BSSIdx is 0
1106 WCIDAttri = (pAd->SharedKey[BSS0][KeyIdx].CipherAlg<<1)|PAIRWISEKEYTABLE;
1107 offset = MAC_WCID_ATTRIBUTE_BASE + (BSS0Mcast_WCID* HW_WCID_ATTRI_SIZE);
1108 RTMP_IO_WRITE32(pAd, offset, WCIDAttri);
1114 if (pAd->SharedKey[apidx][KeyIdx].Type == GROUP_KEY)
1116 // 802.1x port control
1117 pAd->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
1118 DBGPRINT(RT_DEBUG_TRACE,("!!WPA_802_1X_PORT_SECURED!!\n"));
1122 return (NDIS_STATUS_SUCCESS);
1126 BOOLEAN RTMPCheckStrPrintAble(
1132 for (i=0; i<strLen; i++)
1134 if ((pInPutStr[i] < 0x21) ||
1135 (pInPutStr[i] > 0x7E))
1143 ========================================================================
1145 Routine Description:
1146 Remove WPA Key process
1149 pAd Pointer to our adapter
1150 pBuf Pointer to the where the key stored
1153 NDIS_SUCCESS Add key successfully
1155 IRQL = DISPATCH_LEVEL
1159 ========================================================================
1161 VOID RTMPSetDesiredRates(
1162 IN PRTMP_ADAPTER pAdapter,
1165 NDIS_802_11_RATES aryRates;
1167 memset(&aryRates, 0x00, sizeof(NDIS_802_11_RATES));
1168 switch (pAdapter->CommonCfg.PhyMode)
1170 case PHY_11A: // A only
1174 aryRates[0] = 0x0c; // 6M
1175 pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_0;
1178 aryRates[0] = 0x12; // 9M
1179 pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_1;
1181 case 12000000: //12M
1182 aryRates[0] = 0x18; // 12M
1183 pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_2;
1185 case 18000000: //18M
1186 aryRates[0] = 0x24; // 18M
1187 pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_3;
1189 case 24000000: //24M
1190 aryRates[0] = 0x30; // 24M
1191 pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_4;
1193 case 36000000: //36M
1194 aryRates[0] = 0x48; // 36M
1195 pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_5;
1197 case 48000000: //48M
1198 aryRates[0] = 0x60; // 48M
1199 pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_6;
1201 case 54000000: //54M
1202 aryRates[0] = 0x6c; // 54M
1203 pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_7;
1207 aryRates[0] = 0x6c; // 54Mbps
1208 aryRates[1] = 0x60; // 48Mbps
1209 aryRates[2] = 0x48; // 36Mbps
1210 aryRates[3] = 0x30; // 24Mbps
1211 aryRates[4] = 0x24; // 18M
1212 aryRates[5] = 0x18; // 12M
1213 aryRates[6] = 0x12; // 9M
1214 aryRates[7] = 0x0c; // 6M
1215 pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_AUTO;
1219 case PHY_11BG_MIXED: // B/G Mixed
1220 case PHY_11B: // B only
1221 case PHY_11ABG_MIXED: // A/B/G Mixed
1227 pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_0;
1231 pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_1;
1233 case 5000000: //5.5M
1234 aryRates[0] = 0x0b; // 5.5M
1235 pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_2;
1237 case 11000000: //11M
1238 aryRates[0] = 0x16; // 11M
1239 pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_3;
1242 aryRates[0] = 0x0c; // 6M
1243 pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_0;
1246 aryRates[0] = 0x12; // 9M
1247 pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_1;
1249 case 12000000: //12M
1250 aryRates[0] = 0x18; // 12M
1251 pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_2;
1253 case 18000000: //18M
1254 aryRates[0] = 0x24; // 18M
1255 pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_3;
1257 case 24000000: //24M
1258 aryRates[0] = 0x30; // 24M
1259 pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_4;
1261 case 36000000: //36M
1262 aryRates[0] = 0x48; // 36M
1263 pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_5;
1265 case 48000000: //48M
1266 aryRates[0] = 0x60; // 48M
1267 pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_6;
1269 case 54000000: //54M
1270 aryRates[0] = 0x6c; // 54M
1271 pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_7;
1275 if (pAdapter->CommonCfg.PhyMode == PHY_11B)
1277 aryRates[0] = 0x16; // 11Mbps
1278 aryRates[1] = 0x0b; // 5.5Mbps
1279 aryRates[2] = 0x04; // 2Mbps
1280 aryRates[3] = 0x02; // 1Mbps
1283 { //(B/G) Mixed or (A/B/G) Mixed
1284 aryRates[0] = 0x6c; // 54Mbps
1285 aryRates[1] = 0x60; // 48Mbps
1286 aryRates[2] = 0x48; // 36Mbps
1287 aryRates[3] = 0x30; // 24Mbps
1288 aryRates[4] = 0x16; // 11Mbps
1289 aryRates[5] = 0x0b; // 5.5Mbps
1290 aryRates[6] = 0x04; // 2Mbps
1291 aryRates[7] = 0x02; // 1Mbps
1293 pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_AUTO;
1299 NdisZeroMemory(pAdapter->CommonCfg.DesireRate, MAX_LEN_OF_SUPPORTED_RATES);
1300 NdisMoveMemory(pAdapter->CommonCfg.DesireRate, &aryRates, sizeof(NDIS_802_11_RATES));
1301 DBGPRINT(RT_DEBUG_TRACE, (" RTMPSetDesiredRates (%02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x)\n",
1302 pAdapter->CommonCfg.DesireRate[0],pAdapter->CommonCfg.DesireRate[1],
1303 pAdapter->CommonCfg.DesireRate[2],pAdapter->CommonCfg.DesireRate[3],
1304 pAdapter->CommonCfg.DesireRate[4],pAdapter->CommonCfg.DesireRate[5],
1305 pAdapter->CommonCfg.DesireRate[6],pAdapter->CommonCfg.DesireRate[7] ));
1306 // Changing DesiredRate may affect the MAX TX rate we used to TX frames out
1307 MlmeUpdateTxRates(pAdapter, FALSE, 0);
1310 NDIS_STATUS RTMPWPARemoveKeyProc(
1311 IN PRTMP_ADAPTER pAd,
1314 PNDIS_802_11_REMOVE_KEY pKey;
1316 NDIS_STATUS Status = NDIS_STATUS_FAILURE;
1317 BOOLEAN bTxKey; // Set the key as transmit key
1318 BOOLEAN bPairwise; // Indicate the key is pairwise key
1319 BOOLEAN bKeyRSC; // indicate the receive SC set by KeyRSC value.
1320 // Otherwise, it will set by the NIC.
1321 BOOLEAN bAuthenticator; // indicate key is set by authenticator.
1324 DBGPRINT(RT_DEBUG_TRACE,("---> RTMPWPARemoveKeyProc\n"));
1326 pKey = (PNDIS_802_11_REMOVE_KEY) pBuf;
1327 KeyIdx = pKey->KeyIndex & 0xff;
1328 // Bit 31 of Add-key, Tx Key
1329 bTxKey = (pKey->KeyIndex & 0x80000000) ? TRUE : FALSE;
1330 // Bit 30 of Add-key PairwiseKey
1331 bPairwise = (pKey->KeyIndex & 0x40000000) ? TRUE : FALSE;
1332 // Bit 29 of Add-key KeyRSC
1333 bKeyRSC = (pKey->KeyIndex & 0x20000000) ? TRUE : FALSE;
1334 // Bit 28 of Add-key Authenticator
1335 bAuthenticator = (pKey->KeyIndex & 0x10000000) ? TRUE : FALSE;
1337 // 1. If bTx is TRUE, return failure information
1339 return(NDIS_STATUS_INVALID_DATA);
1341 // 2. Check Pairwise Key
1344 // a. If BSSID is broadcast, remove all pairwise keys.
1345 // b. If not broadcast, remove the pairwise specified by BSSID
1346 for (i = 0; i < SHARE_KEY_NUM; i++)
1348 if (MAC_ADDR_EQUAL(pAd->SharedKey[BSS0][i].BssId, pKey->BSSID))
1350 DBGPRINT(RT_DEBUG_TRACE,("RTMPWPARemoveKeyProc(KeyIdx=%d)\n", i));
1351 pAd->SharedKey[BSS0][i].KeyLen = 0;
1352 pAd->SharedKey[BSS0][i].CipherAlg = CIPHER_NONE;
1353 AsicRemoveSharedKeyEntry(pAd, BSS0, (UCHAR)i);
1354 Status = NDIS_STATUS_SUCCESS;
1362 // a. If BSSID is broadcast, remove all group keys indexed
1363 // b. If BSSID matched, delete the group key indexed.
1364 DBGPRINT(RT_DEBUG_TRACE,("RTMPWPARemoveKeyProc(KeyIdx=%ld)\n", KeyIdx));
1365 pAd->SharedKey[BSS0][KeyIdx].KeyLen = 0;
1366 pAd->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_NONE;
1367 AsicRemoveSharedKeyEntry(pAd, BSS0, (UCHAR)KeyIdx);
1368 Status = NDIS_STATUS_SUCCESS;
1375 ========================================================================
1377 Routine Description:
1381 pAd Pointer to our adapter
1386 IRQL = DISPATCH_LEVEL
1390 ========================================================================
1392 VOID RTMPWPARemoveAllKeys(
1393 IN PRTMP_ADAPTER pAd)
1398 DBGPRINT(RT_DEBUG_TRACE,("RTMPWPARemoveAllKeys(AuthMode=%d, WepStatus=%d)\n", pAd->StaCfg.AuthMode, pAd->StaCfg.WepStatus));
1400 // For WEP/CKIP, there is no need to remove it, since WinXP won't set it again after
1401 // Link up. And it will be replaced if user changed it.
1402 if (pAd->StaCfg.AuthMode < Ndis802_11AuthModeWPA)
1405 // For WPA-None, there is no need to remove it, since WinXP won't set it again after
1406 // Link up. And it will be replaced if user changed it.
1407 if (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPANone)
1410 // set BSSID wcid entry of the Pair-wise Key table as no-security mode
1411 AsicRemovePairwiseKeyEntry(pAd, BSS0, BSSID_WCID);
1413 // set all shared key mode as no-security.
1414 for (i = 0; i < SHARE_KEY_NUM; i++)
1416 DBGPRINT(RT_DEBUG_TRACE,("remove %s key #%d\n", CipherName[pAd->SharedKey[BSS0][i].CipherAlg], i));
1417 NdisZeroMemory(&pAd->SharedKey[BSS0][i], sizeof(CIPHER_KEY));
1419 AsicRemoveSharedKeyEntry(pAd, BSS0, i);
1425 ========================================================================
1426 Routine Description:
1427 Change NIC PHY mode. Re-association may be necessary. possible settings
1428 include - PHY_11B, PHY_11BG_MIXED, PHY_11A, and PHY_11ABG_MIXED
1431 pAd - Pointer to our adapter
1434 IRQL = PASSIVE_LEVEL
1435 IRQL = DISPATCH_LEVEL
1437 ========================================================================
1439 VOID RTMPSetPhyMode(
1440 IN PRTMP_ADAPTER pAd,
1444 // the selected phymode must be supported by the RF IC encoded in E2PROM
1446 // if no change, do nothing
1448 if (pAd->CommonCfg.PhyMode == phymode)
1451 pAd->CommonCfg.PhyMode = (UCHAR)phymode;
1453 DBGPRINT(RT_DEBUG_TRACE,("RTMPSetPhyMode : PhyMode=%d, channel=%d \n", pAd->CommonCfg.PhyMode, pAd->CommonCfg.Channel));
1455 BuildChannelList(pAd);
1457 // sanity check user setting
1458 for (i = 0; i < pAd->ChannelListNum; i++)
1460 if (pAd->CommonCfg.Channel == pAd->ChannelList[i].Channel)
1464 if (i == pAd->ChannelListNum)
1466 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
1467 pAd->CommonCfg.Channel = FirstChannel(pAd);
1468 DBGPRINT(RT_DEBUG_ERROR, ("RTMPSetPhyMode: channel is out of range, use first channel=%d \n", pAd->CommonCfg.Channel));
1471 NdisZeroMemory(pAd->CommonCfg.SupRate, MAX_LEN_OF_SUPPORTED_RATES);
1472 NdisZeroMemory(pAd->CommonCfg.ExtRate, MAX_LEN_OF_SUPPORTED_RATES);
1473 NdisZeroMemory(pAd->CommonCfg.DesireRate, MAX_LEN_OF_SUPPORTED_RATES);
1476 pAd->CommonCfg.SupRate[0] = 0x82; // 1 mbps, in units of 0.5 Mbps, basic rate
1477 pAd->CommonCfg.SupRate[1] = 0x84; // 2 mbps, in units of 0.5 Mbps, basic rate
1478 pAd->CommonCfg.SupRate[2] = 0x8B; // 5.5 mbps, in units of 0.5 Mbps, basic rate
1479 pAd->CommonCfg.SupRate[3] = 0x96; // 11 mbps, in units of 0.5 Mbps, basic rate
1480 pAd->CommonCfg.SupRateLen = 4;
1481 pAd->CommonCfg.ExtRateLen = 0;
1482 pAd->CommonCfg.DesireRate[0] = 2; // 1 mbps, in units of 0.5 Mbps
1483 pAd->CommonCfg.DesireRate[1] = 4; // 2 mbps, in units of 0.5 Mbps
1484 pAd->CommonCfg.DesireRate[2] = 11; // 5.5 mbps, in units of 0.5 Mbps
1485 pAd->CommonCfg.DesireRate[3] = 22; // 11 mbps, in units of 0.5 Mbps
1486 //pAd->CommonCfg.HTPhyMode.field.MODE = MODE_CCK; // This MODE is only FYI. not use
1490 case PHY_11BG_MIXED:
1491 case PHY_11ABG_MIXED:
1492 #ifdef DOT11_N_SUPPORT
1494 case PHY_11ABGN_MIXED:
1495 case PHY_11BGN_MIXED:
1496 case PHY_11GN_MIXED:
1497 #endif // DOT11_N_SUPPORT //
1498 pAd->CommonCfg.SupRate[0] = 0x82; // 1 mbps, in units of 0.5 Mbps, basic rate
1499 pAd->CommonCfg.SupRate[1] = 0x84; // 2 mbps, in units of 0.5 Mbps, basic rate
1500 pAd->CommonCfg.SupRate[2] = 0x8B; // 5.5 mbps, in units of 0.5 Mbps, basic rate
1501 pAd->CommonCfg.SupRate[3] = 0x96; // 11 mbps, in units of 0.5 Mbps, basic rate
1502 pAd->CommonCfg.SupRate[4] = 0x12; // 9 mbps, in units of 0.5 Mbps
1503 pAd->CommonCfg.SupRate[5] = 0x24; // 18 mbps, in units of 0.5 Mbps
1504 pAd->CommonCfg.SupRate[6] = 0x48; // 36 mbps, in units of 0.5 Mbps
1505 pAd->CommonCfg.SupRate[7] = 0x6c; // 54 mbps, in units of 0.5 Mbps
1506 pAd->CommonCfg.SupRateLen = 8;
1507 pAd->CommonCfg.ExtRate[0] = 0x0C; // 6 mbps, in units of 0.5 Mbps
1508 pAd->CommonCfg.ExtRate[1] = 0x18; // 12 mbps, in units of 0.5 Mbps
1509 pAd->CommonCfg.ExtRate[2] = 0x30; // 24 mbps, in units of 0.5 Mbps
1510 pAd->CommonCfg.ExtRate[3] = 0x60; // 48 mbps, in units of 0.5 Mbps
1511 pAd->CommonCfg.ExtRateLen = 4;
1512 pAd->CommonCfg.DesireRate[0] = 2; // 1 mbps, in units of 0.5 Mbps
1513 pAd->CommonCfg.DesireRate[1] = 4; // 2 mbps, in units of 0.5 Mbps
1514 pAd->CommonCfg.DesireRate[2] = 11; // 5.5 mbps, in units of 0.5 Mbps
1515 pAd->CommonCfg.DesireRate[3] = 22; // 11 mbps, in units of 0.5 Mbps
1516 pAd->CommonCfg.DesireRate[4] = 12; // 6 mbps, in units of 0.5 Mbps
1517 pAd->CommonCfg.DesireRate[5] = 18; // 9 mbps, in units of 0.5 Mbps
1518 pAd->CommonCfg.DesireRate[6] = 24; // 12 mbps, in units of 0.5 Mbps
1519 pAd->CommonCfg.DesireRate[7] = 36; // 18 mbps, in units of 0.5 Mbps
1520 pAd->CommonCfg.DesireRate[8] = 48; // 24 mbps, in units of 0.5 Mbps
1521 pAd->CommonCfg.DesireRate[9] = 72; // 36 mbps, in units of 0.5 Mbps
1522 pAd->CommonCfg.DesireRate[10] = 96; // 48 mbps, in units of 0.5 Mbps
1523 pAd->CommonCfg.DesireRate[11] = 108; // 54 mbps, in units of 0.5 Mbps
1527 #ifdef DOT11_N_SUPPORT
1528 case PHY_11AN_MIXED:
1529 case PHY_11AGN_MIXED:
1531 #endif // DOT11_N_SUPPORT //
1532 pAd->CommonCfg.SupRate[0] = 0x8C; // 6 mbps, in units of 0.5 Mbps, basic rate
1533 pAd->CommonCfg.SupRate[1] = 0x12; // 9 mbps, in units of 0.5 Mbps
1534 pAd->CommonCfg.SupRate[2] = 0x98; // 12 mbps, in units of 0.5 Mbps, basic rate
1535 pAd->CommonCfg.SupRate[3] = 0x24; // 18 mbps, in units of 0.5 Mbps
1536 pAd->CommonCfg.SupRate[4] = 0xb0; // 24 mbps, in units of 0.5 Mbps, basic rate
1537 pAd->CommonCfg.SupRate[5] = 0x48; // 36 mbps, in units of 0.5 Mbps
1538 pAd->CommonCfg.SupRate[6] = 0x60; // 48 mbps, in units of 0.5 Mbps
1539 pAd->CommonCfg.SupRate[7] = 0x6c; // 54 mbps, in units of 0.5 Mbps
1540 pAd->CommonCfg.SupRateLen = 8;
1541 pAd->CommonCfg.ExtRateLen = 0;
1542 pAd->CommonCfg.DesireRate[0] = 12; // 6 mbps, in units of 0.5 Mbps
1543 pAd->CommonCfg.DesireRate[1] = 18; // 9 mbps, in units of 0.5 Mbps
1544 pAd->CommonCfg.DesireRate[2] = 24; // 12 mbps, in units of 0.5 Mbps
1545 pAd->CommonCfg.DesireRate[3] = 36; // 18 mbps, in units of 0.5 Mbps
1546 pAd->CommonCfg.DesireRate[4] = 48; // 24 mbps, in units of 0.5 Mbps
1547 pAd->CommonCfg.DesireRate[5] = 72; // 36 mbps, in units of 0.5 Mbps
1548 pAd->CommonCfg.DesireRate[6] = 96; // 48 mbps, in units of 0.5 Mbps
1549 pAd->CommonCfg.DesireRate[7] = 108; // 54 mbps, in units of 0.5 Mbps
1550 //pAd->CommonCfg.HTPhyMode.field.MODE = MODE_OFDM; // This MODE is only FYI. not use
1558 pAd->CommonCfg.BandState = UNKNOWN_BAND;
1562 #ifdef DOT11_N_SUPPORT
1564 ========================================================================
1565 Routine Description:
1566 Caller ensures we has 802.11n support.
1567 Calls at setting HT from AP/STASetinformation
1570 pAd - Pointer to our adapter
1573 ========================================================================
1576 IN PRTMP_ADAPTER pAd,
1577 IN OID_SET_HT_PHYMODE *pHTPhyMode)
1582 UCHAR BBP3Value = 0;
1583 UCHAR RxStream = pAd->CommonCfg.RxStream;
1585 DBGPRINT(RT_DEBUG_TRACE, ("RTMPSetHT : HT_mode(%d), ExtOffset(%d), MCS(%d), BW(%d), STBC(%d), SHORTGI(%d)\n",
1586 pHTPhyMode->HtMode, pHTPhyMode->ExtOffset,
1587 pHTPhyMode->MCS, pHTPhyMode->BW,
1588 pHTPhyMode->STBC, pHTPhyMode->SHORTGI));
1590 // Don't zero supportedHyPhy structure.
1591 RTMPZeroMemory(&pAd->CommonCfg.HtCapability, sizeof(pAd->CommonCfg.HtCapability));
1592 RTMPZeroMemory(&pAd->CommonCfg.AddHTInfo, sizeof(pAd->CommonCfg.AddHTInfo));
1593 RTMPZeroMemory(&pAd->CommonCfg.NewExtChanOffset, sizeof(pAd->CommonCfg.NewExtChanOffset));
1594 RTMPZeroMemory(&pAd->CommonCfg.DesiredHtPhy, sizeof(pAd->CommonCfg.DesiredHtPhy));
1596 if (pAd->CommonCfg.bRdg)
1598 pAd->CommonCfg.HtCapability.ExtHtCapInfo.PlusHTC = 1;
1599 pAd->CommonCfg.HtCapability.ExtHtCapInfo.RDGSupport = 1;
1603 pAd->CommonCfg.HtCapability.ExtHtCapInfo.PlusHTC = 0;
1604 pAd->CommonCfg.HtCapability.ExtHtCapInfo.RDGSupport = 0;
1607 pAd->CommonCfg.HtCapability.HtCapParm.MaxRAmpduFactor = 3;
1608 pAd->CommonCfg.DesiredHtPhy.MaxRAmpduFactor = 3;
1610 DBGPRINT(RT_DEBUG_TRACE, ("RTMPSetHT : RxBAWinLimit = %d\n", pAd->CommonCfg.BACapability.field.RxBAWinLimit));
1612 // Mimo power save, A-MSDU size,
1613 pAd->CommonCfg.DesiredHtPhy.AmsduEnable = (USHORT)pAd->CommonCfg.BACapability.field.AmsduEnable;
1614 pAd->CommonCfg.DesiredHtPhy.AmsduSize = (UCHAR)pAd->CommonCfg.BACapability.field.AmsduSize;
1615 pAd->CommonCfg.DesiredHtPhy.MimoPs = (UCHAR)pAd->CommonCfg.BACapability.field.MMPSmode;
1616 pAd->CommonCfg.DesiredHtPhy.MpduDensity = (UCHAR)pAd->CommonCfg.BACapability.field.MpduDensity;
1618 pAd->CommonCfg.HtCapability.HtCapInfo.AMsduSize = (USHORT)pAd->CommonCfg.BACapability.field.AmsduSize;
1619 pAd->CommonCfg.HtCapability.HtCapInfo.MimoPs = (USHORT)pAd->CommonCfg.BACapability.field.MMPSmode;
1620 pAd->CommonCfg.HtCapability.HtCapParm.MpduDensity = (UCHAR)pAd->CommonCfg.BACapability.field.MpduDensity;
1622 DBGPRINT(RT_DEBUG_TRACE, ("RTMPSetHT : AMsduSize = %d, MimoPs = %d, MpduDensity = %d, MaxRAmpduFactor = %d\n",
1623 pAd->CommonCfg.DesiredHtPhy.AmsduSize,
1624 pAd->CommonCfg.DesiredHtPhy.MimoPs,
1625 pAd->CommonCfg.DesiredHtPhy.MpduDensity,
1626 pAd->CommonCfg.DesiredHtPhy.MaxRAmpduFactor));
1628 if(pHTPhyMode->HtMode == HTMODE_GF)
1630 pAd->CommonCfg.HtCapability.HtCapInfo.GF = 1;
1631 pAd->CommonCfg.DesiredHtPhy.GF = 1;
1634 pAd->CommonCfg.DesiredHtPhy.GF = 0;
1640 pAd->CommonCfg.HtCapability.MCSSet[0] = 0xff;
1641 pAd->CommonCfg.HtCapability.MCSSet[1] = 0x00;
1645 pAd->CommonCfg.HtCapability.MCSSet[0] = 0xff;
1646 pAd->CommonCfg.HtCapability.MCSSet[1] = 0xff;
1650 pAd->CommonCfg.HtCapability.MCSSet[0] = 0xff;
1651 pAd->CommonCfg.HtCapability.MCSSet[1] = 0xff;
1652 pAd->CommonCfg.HtCapability.MCSSet[2] = 0xff;
1656 if (pAd->CommonCfg.bForty_Mhz_Intolerant && (pAd->CommonCfg.Channel <= 14) && (pHTPhyMode->BW == BW_40) )
1658 pHTPhyMode->BW = BW_20;
1659 pAd->CommonCfg.HtCapability.HtCapInfo.Forty_Mhz_Intolerant = 1;
1662 if(pHTPhyMode->BW == BW_40)
1664 pAd->CommonCfg.HtCapability.MCSSet[4] = 0x1; // MCS 32
1665 pAd->CommonCfg.HtCapability.HtCapInfo.ChannelWidth = 1;
1666 if (pAd->CommonCfg.Channel <= 14)
1667 pAd->CommonCfg.HtCapability.HtCapInfo.CCKmodein40 = 1;
1669 pAd->CommonCfg.DesiredHtPhy.ChannelWidth = 1;
1670 pAd->CommonCfg.AddHTInfo.AddHtInfo.RecomWidth = 1;
1671 pAd->CommonCfg.AddHTInfo.AddHtInfo.ExtChanOffset = (pHTPhyMode->ExtOffset == EXTCHA_BELOW)? (EXTCHA_BELOW): EXTCHA_ABOVE;
1672 // Set Regsiter for extension channel position.
1673 RTMP_IO_READ32(pAd, TX_BAND_CFG, &Value);
1674 RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &BBP3Value);
1675 if ((pHTPhyMode->ExtOffset == EXTCHA_BELOW))
1678 BBP3Value |= (0x20);
1679 RTMP_IO_WRITE32(pAd, TX_BAND_CFG, Value);
1681 else if ((pHTPhyMode->ExtOffset == EXTCHA_ABOVE))
1684 BBP3Value &= (~0x20);
1685 RTMP_IO_WRITE32(pAd, TX_BAND_CFG, Value);
1688 // Turn on BBP 40MHz mode now only as AP .
1689 // Sta can turn on BBP 40MHz after connection with 40MHz AP. Sta only broadcast 40MHz capability before connection.
1690 if ((pAd->OpMode == OPMODE_AP) || INFRA_ON(pAd) || ADHOC_ON(pAd)
1693 RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &BBPValue);
1694 BBPValue &= (~0x18);
1696 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, BBPValue);
1698 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, BBP3Value);
1699 pAd->CommonCfg.BBPCurrentBW = BW_40;
1704 pAd->CommonCfg.HtCapability.HtCapInfo.ChannelWidth = 0;
1705 pAd->CommonCfg.DesiredHtPhy.ChannelWidth = 0;
1706 pAd->CommonCfg.AddHTInfo.AddHtInfo.RecomWidth = 0;
1707 pAd->CommonCfg.AddHTInfo.AddHtInfo.ExtChanOffset = EXTCHA_NONE;
1708 pAd->CommonCfg.CentralChannel = pAd->CommonCfg.Channel;
1709 // Turn on BBP 20MHz mode by request here.
1711 RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &BBPValue);
1712 BBPValue &= (~0x18);
1713 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, BBPValue);
1714 pAd->CommonCfg.BBPCurrentBW = BW_20;
1718 if(pHTPhyMode->STBC == STBC_USE)
1720 pAd->CommonCfg.HtCapability.HtCapInfo.TxSTBC = 1;
1721 pAd->CommonCfg.DesiredHtPhy.TxSTBC = 1;
1722 pAd->CommonCfg.HtCapability.HtCapInfo.RxSTBC = 1;
1723 pAd->CommonCfg.DesiredHtPhy.RxSTBC = 1;
1727 pAd->CommonCfg.DesiredHtPhy.TxSTBC = 0;
1728 pAd->CommonCfg.DesiredHtPhy.RxSTBC = 0;
1732 /* Frank recommend ,If not, Tx maybe block in high power. Rx has no problem*/
1733 if(IS_RT3070(pAd) && ((pAd->RfIcType == RFIC_3020) || (pAd->RfIcType == RFIC_2020)))
1735 pAd->CommonCfg.HtCapability.HtCapInfo.TxSTBC = 0;
1736 pAd->CommonCfg.DesiredHtPhy.TxSTBC = 0;
1740 if(pHTPhyMode->SHORTGI == GI_400)
1742 pAd->CommonCfg.HtCapability.HtCapInfo.ShortGIfor20 = 1;
1743 pAd->CommonCfg.HtCapability.HtCapInfo.ShortGIfor40 = 1;
1744 pAd->CommonCfg.DesiredHtPhy.ShortGIfor20 = 1;
1745 pAd->CommonCfg.DesiredHtPhy.ShortGIfor40 = 1;
1749 pAd->CommonCfg.HtCapability.HtCapInfo.ShortGIfor20 = 0;
1750 pAd->CommonCfg.HtCapability.HtCapInfo.ShortGIfor40 = 0;
1751 pAd->CommonCfg.DesiredHtPhy.ShortGIfor20 = 0;
1752 pAd->CommonCfg.DesiredHtPhy.ShortGIfor40 = 0;
1755 // We support link adaptation for unsolicit MCS feedback, set to 2.
1756 pAd->CommonCfg.HtCapability.ExtHtCapInfo.MCSFeedback = MCSFBK_NONE; //MCSFBK_UNSOLICIT;
1757 pAd->CommonCfg.AddHTInfo.ControlChan = pAd->CommonCfg.Channel;
1758 // 1, the extension channel above the control channel.
1760 // EDCA parameters used for AP's own transmission
1761 if (pAd->CommonCfg.APEdcaParm.bValid == FALSE)
1763 pAd->CommonCfg.APEdcaParm.bValid = TRUE;
1764 pAd->CommonCfg.APEdcaParm.Aifsn[0] = 3;
1765 pAd->CommonCfg.APEdcaParm.Aifsn[1] = 7;
1766 pAd->CommonCfg.APEdcaParm.Aifsn[2] = 1;
1767 pAd->CommonCfg.APEdcaParm.Aifsn[3] = 1;
1769 pAd->CommonCfg.APEdcaParm.Cwmin[0] = 4;
1770 pAd->CommonCfg.APEdcaParm.Cwmin[1] = 4;
1771 pAd->CommonCfg.APEdcaParm.Cwmin[2] = 3;
1772 pAd->CommonCfg.APEdcaParm.Cwmin[3] = 2;
1774 pAd->CommonCfg.APEdcaParm.Cwmax[0] = 6;
1775 pAd->CommonCfg.APEdcaParm.Cwmax[1] = 10;
1776 pAd->CommonCfg.APEdcaParm.Cwmax[2] = 4;
1777 pAd->CommonCfg.APEdcaParm.Cwmax[3] = 3;
1779 pAd->CommonCfg.APEdcaParm.Txop[0] = 0;
1780 pAd->CommonCfg.APEdcaParm.Txop[1] = 0;
1781 pAd->CommonCfg.APEdcaParm.Txop[2] = 94;
1782 pAd->CommonCfg.APEdcaParm.Txop[3] = 47;
1784 AsicSetEdcaParm(pAd, &pAd->CommonCfg.APEdcaParm);
1786 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
1788 RTMPSetIndividualHT(pAd, 0);
1793 ========================================================================
1794 Routine Description:
1795 Caller ensures we has 802.11n support.
1796 Calls at setting HT from AP/STASetinformation
1799 pAd - Pointer to our adapter
1802 ========================================================================
1804 VOID RTMPSetIndividualHT(
1805 IN PRTMP_ADAPTER pAd,
1808 PRT_HT_PHY_INFO pDesired_ht_phy = NULL;
1809 UCHAR TxStream = pAd->CommonCfg.TxStream;
1810 UCHAR DesiredMcs = MCS_AUTO;
1814 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
1816 pDesired_ht_phy = &pAd->StaCfg.DesiredHtPhyInfo;
1817 DesiredMcs = pAd->StaCfg.DesiredTransmitSetting.field.MCS;
1818 //pAd->StaCfg.bAutoTxRateSwitch = (DesiredMcs == MCS_AUTO) ? TRUE : FALSE;
1823 if (pDesired_ht_phy == NULL)
1825 DBGPRINT(RT_DEBUG_ERROR, ("RTMPSetIndividualHT: invalid apidx(%d)\n", apidx));
1828 RTMPZeroMemory(pDesired_ht_phy, sizeof(RT_HT_PHY_INFO));
1830 DBGPRINT(RT_DEBUG_TRACE, ("RTMPSetIndividualHT : Desired MCS = %d\n", DesiredMcs));
1831 // Check the validity of MCS
1832 if ((TxStream == 1) && ((DesiredMcs >= MCS_8) && (DesiredMcs <= MCS_15)))
1834 DBGPRINT(RT_DEBUG_WARN, ("RTMPSetIndividualHT: MCS(%d) is invalid in 1S, reset it as MCS_7\n", DesiredMcs));
1838 if ((pAd->CommonCfg.DesiredHtPhy.ChannelWidth == BW_20) && (DesiredMcs == MCS_32))
1840 DBGPRINT(RT_DEBUG_WARN, ("RTMPSetIndividualHT: MCS_32 is only supported in 40-MHz, reset it as MCS_0\n"));
1844 pDesired_ht_phy->bHtEnable = TRUE;
1846 // Decide desired Tx MCS
1850 if (DesiredMcs == MCS_AUTO)
1852 pDesired_ht_phy->MCSSet[0]= 0xff;
1853 pDesired_ht_phy->MCSSet[1]= 0x00;
1855 else if (DesiredMcs <= MCS_7)
1857 pDesired_ht_phy->MCSSet[0]= 1<<DesiredMcs;
1858 pDesired_ht_phy->MCSSet[1]= 0x00;
1863 if (DesiredMcs == MCS_AUTO)
1865 pDesired_ht_phy->MCSSet[0]= 0xff;
1866 pDesired_ht_phy->MCSSet[1]= 0xff;
1868 else if (DesiredMcs <= MCS_15)
1872 mode = DesiredMcs / 8;
1874 pDesired_ht_phy->MCSSet[mode] = (1 << (DesiredMcs - mode * 8));
1879 if (DesiredMcs == MCS_AUTO)
1881 /* MCS0 ~ MCS23, 3 bytes */
1882 pDesired_ht_phy->MCSSet[0]= 0xff;
1883 pDesired_ht_phy->MCSSet[1]= 0xff;
1884 pDesired_ht_phy->MCSSet[2]= 0xff;
1886 else if (DesiredMcs <= MCS_23)
1890 mode = DesiredMcs / 8;
1892 pDesired_ht_phy->MCSSet[mode] = (1 << (DesiredMcs - mode * 8));
1897 if(pAd->CommonCfg.DesiredHtPhy.ChannelWidth == BW_40)
1899 if (DesiredMcs == MCS_AUTO || DesiredMcs == MCS_32)
1900 pDesired_ht_phy->MCSSet[4] = 0x1;
1903 // update HT Rate setting
1904 if (pAd->OpMode == OPMODE_STA)
1905 MlmeUpdateHtTxRates(pAd, BSS0);
1907 MlmeUpdateHtTxRates(pAd, apidx);
1912 ========================================================================
1913 Routine Description:
1914 Update HT IE from our capability.
1917 Send all HT IE in beacon/probe rsp/assoc rsp/action frame.
1920 ========================================================================
1922 VOID RTMPUpdateHTIE(
1923 IN RT_HT_CAPABILITY *pRtHt,
1925 OUT HT_CAPABILITY_IE *pHtCapability,
1926 OUT ADD_HT_INFO_IE *pAddHtInfo)
1928 RTMPZeroMemory(pHtCapability, sizeof(HT_CAPABILITY_IE));
1929 RTMPZeroMemory(pAddHtInfo, sizeof(ADD_HT_INFO_IE));
1931 pHtCapability->HtCapInfo.ChannelWidth = pRtHt->ChannelWidth;
1932 pHtCapability->HtCapInfo.MimoPs = pRtHt->MimoPs;
1933 pHtCapability->HtCapInfo.GF = pRtHt->GF;
1934 pHtCapability->HtCapInfo.ShortGIfor20 = pRtHt->ShortGIfor20;
1935 pHtCapability->HtCapInfo.ShortGIfor40 = pRtHt->ShortGIfor40;
1936 pHtCapability->HtCapInfo.TxSTBC = pRtHt->TxSTBC;
1937 pHtCapability->HtCapInfo.RxSTBC = pRtHt->RxSTBC;
1938 pHtCapability->HtCapInfo.AMsduSize = pRtHt->AmsduSize;
1939 pHtCapability->HtCapParm.MaxRAmpduFactor = pRtHt->MaxRAmpduFactor;
1940 pHtCapability->HtCapParm.MpduDensity = pRtHt->MpduDensity;
1942 pAddHtInfo->AddHtInfo.ExtChanOffset = pRtHt->ExtChanOffset ;
1943 pAddHtInfo->AddHtInfo.RecomWidth = pRtHt->RecomWidth;
1944 pAddHtInfo->AddHtInfo2.OperaionMode = pRtHt->OperaionMode;
1945 pAddHtInfo->AddHtInfo2.NonGfPresent = pRtHt->NonGfPresent;
1946 RTMPMoveMemory(pAddHtInfo->MCSSet, /*pRtHt->MCSSet*/pMcsSet, 4); // rt2860 only support MCS max=32, no need to copy all 16 uchar.
1948 DBGPRINT(RT_DEBUG_TRACE,("RTMPUpdateHTIE <== \n"));
1950 #endif // DOT11_N_SUPPORT //
1953 ========================================================================
1955 Add Client security information into ASIC WCID table and IVEIV table.
1957 ========================================================================
1959 VOID RTMPAddWcidAttributeEntry(
1960 IN PRTMP_ADAPTER pAd,
1964 IN MAC_TABLE_ENTRY *pEntry)
1966 UINT32 WCIDAttri = 0;
1972 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
1976 DBGPRINT(RT_DEBUG_ERROR, ("RTMPAddWcidAttributeEntry: The BSS-index(%d) is out of range for Infra link. \n", BssIdx));
1980 // 1. In ADHOC mode, the AID is wcid number. And NO mesh link exists.
1981 // 2. In Infra mode, the AID:1 MUST be wcid of infra STA.
1982 // the AID:2~ assign to mesh link entry.
1983 if (pEntry && ADHOC_ON(pAd))
1985 else if (pEntry && INFRA_ON(pAd))
1994 // Update WCID attribute table
1995 offset = MAC_WCID_ATTRIBUTE_BASE + (Wcid * HW_WCID_ATTRI_SIZE);
1997 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
1999 if (pEntry && pEntry->ValidAsMesh)
2000 WCIDAttri = (CipherAlg<<1) | PAIRWISEKEYTABLE;
2002 WCIDAttri = (CipherAlg<<1) | SHAREDKEYTABLE;
2005 RTMP_IO_WRITE32(pAd, offset, WCIDAttri);
2008 // Update IV/EIV table
2009 offset = MAC_IVEIV_TABLE_BASE + (Wcid * HW_IVEIV_ENTRY_SIZE);
2012 if ((CipherAlg == CIPHER_TKIP) || (CipherAlg == CIPHER_TKIP_NO_MIC) || (CipherAlg == CIPHER_AES))
2014 // Eiv bit on. keyid always is 0 for pairwise key
2015 IVEIV = (KeyIdx <<6) | 0x20;
2019 // WEP KeyIdx is default tx key.
2020 IVEIV = (KeyIdx << 6);
2023 // For key index and ext IV bit, so only need to update the position(offset+3).
2025 RTUSBMultiWrite_OneByte(pAd, offset+3, &IVEIV);
2028 DBGPRINT(RT_DEBUG_TRACE,("RTMPAddWcidAttributeEntry: WCID #%d, KeyIndex #%d, Alg=%s\n",Wcid, KeyIdx, CipherName[CipherAlg]));
2029 DBGPRINT(RT_DEBUG_TRACE,(" WCIDAttri = 0x%x \n", WCIDAttri));
2034 ==========================================================================
2036 Parse encryption type
2038 pAdapter Pointer to our adapter
2039 wrq Pointer to the ioctl argument
2045 ==========================================================================
2047 CHAR *GetEncryptType(CHAR enc)
2049 if(enc == Ndis802_11WEPDisabled)
2051 if(enc == Ndis802_11WEPEnabled)
2053 if(enc == Ndis802_11Encryption2Enabled)
2055 if(enc == Ndis802_11Encryption3Enabled)
2057 if(enc == Ndis802_11Encryption4Enabled)
2063 CHAR *GetAuthMode(CHAR auth)
2065 if(auth == Ndis802_11AuthModeOpen)
2067 if(auth == Ndis802_11AuthModeShared)
2069 if(auth == Ndis802_11AuthModeAutoSwitch)
2071 if(auth == Ndis802_11AuthModeWPA)
2073 if(auth == Ndis802_11AuthModeWPAPSK)
2075 if(auth == Ndis802_11AuthModeWPANone)
2077 if(auth == Ndis802_11AuthModeWPA2)
2079 if(auth == Ndis802_11AuthModeWPA2PSK)
2081 if(auth == Ndis802_11AuthModeWPA1WPA2)
2083 if(auth == Ndis802_11AuthModeWPA1PSKWPA2PSK)
2084 return "WPA1PSKWPA2PSK";
2090 ==========================================================================
2092 Get site survey results
2094 pAdapter Pointer to our adapter
2095 wrq Pointer to the ioctl argument
2102 1.) UI needs to wait 4 seconds after issue a site survey command
2103 2.) iwpriv ra0 get_site_survey
2104 3.) UI needs to prepare at least 4096bytes to get the results
2105 ==========================================================================
2107 #define LINE_LEN (4+33+20+8+10+9+7+3) // Channel+SSID+Bssid+WepStatus+AuthMode+Signal+WiressMode+NetworkType
2108 VOID RTMPIoctlGetSiteSurvey(
2109 IN PRTMP_ADAPTER pAdapter,
2110 IN struct iwreq *wrq)
2116 CHAR Ssid[MAX_LEN_OF_SSID +1];
2117 INT Rssi = 0, max_len = LINE_LEN;
2118 UINT Rssi_Quality = 0;
2119 NDIS_802_11_NETWORK_TYPE wireless_mode;
2121 os_alloc_mem(NULL, (PUCHAR *)&msg, sizeof(CHAR)*((MAX_LEN_OF_BSS_TABLE)*max_len));
2125 DBGPRINT(RT_DEBUG_TRACE, ("RTMPIoctlGetSiteSurvey - msg memory alloc fail.\n"));
2129 memset(msg, 0 ,(MAX_LEN_OF_BSS_TABLE)*max_len );
2130 memset(Ssid, 0 ,(MAX_LEN_OF_SSID +1));
2131 sprintf(msg,"%s","\n");
2132 sprintf(msg+strlen(msg),"%-4s%-33s%-20s%-8s%-10s%-9s%-7s%-3s\n",
2133 "Ch", "SSID", "BSSID", "Enc", "Auth", "Siganl(%)", "W-Mode", " NT");
2137 pAdapter->StaCfg.bScanReqIsFromWebUI = TRUE;
2139 while ((ScanRunning(pAdapter) == TRUE) && (WaitCnt++ < 200))
2142 for(i=0; i<pAdapter->ScanTab.BssNr ;i++)
2144 if( pAdapter->ScanTab.BssEntry[i].Channel==0)
2147 if((strlen(msg)+max_len ) >= IW_SCAN_MAX_DATA)
2151 sprintf(msg+strlen(msg),"%-4d", pAdapter->ScanTab.BssEntry[i].Channel);
2153 memcpy(Ssid, pAdapter->ScanTab.BssEntry[i].Ssid, pAdapter->ScanTab.BssEntry[i].SsidLen);
2154 Ssid[pAdapter->ScanTab.BssEntry[i].SsidLen] = '\0';
2155 sprintf(msg+strlen(msg),"%-33s", Ssid);
2157 sprintf(msg+strlen(msg),"%02x:%02x:%02x:%02x:%02x:%02x ",
2158 pAdapter->ScanTab.BssEntry[i].Bssid[0],
2159 pAdapter->ScanTab.BssEntry[i].Bssid[1],
2160 pAdapter->ScanTab.BssEntry[i].Bssid[2],
2161 pAdapter->ScanTab.BssEntry[i].Bssid[3],
2162 pAdapter->ScanTab.BssEntry[i].Bssid[4],
2163 pAdapter->ScanTab.BssEntry[i].Bssid[5]);
2165 sprintf(msg+strlen(msg),"%-8s",GetEncryptType(pAdapter->ScanTab.BssEntry[i].WepStatus));
2166 //Authentication Mode
2167 if (pAdapter->ScanTab.BssEntry[i].WepStatus == Ndis802_11WEPEnabled)
2168 sprintf(msg+strlen(msg),"%-10s", "UNKNOW");
2170 sprintf(msg+strlen(msg),"%-10s",GetAuthMode(pAdapter->ScanTab.BssEntry[i].AuthMode));
2172 Rssi = (INT)pAdapter->ScanTab.BssEntry[i].Rssi;
2175 else if (Rssi >= -80) // between -50 ~ -80dbm
2176 Rssi_Quality = (UINT)(24 + ((Rssi + 80) * 26)/10);
2177 else if (Rssi >= -90) // between -80 ~ -90dbm
2178 Rssi_Quality = (UINT)(((Rssi + 90) * 26)/10);
2181 sprintf(msg+strlen(msg),"%-9d", Rssi_Quality);
2183 wireless_mode = NetworkTypeInUseSanity(&pAdapter->ScanTab.BssEntry[i]);
2184 if (wireless_mode == Ndis802_11FH ||
2185 wireless_mode == Ndis802_11DS)
2186 sprintf(msg+strlen(msg),"%-7s", "11b");
2187 else if (wireless_mode == Ndis802_11OFDM5)
2188 sprintf(msg+strlen(msg),"%-7s", "11a");
2189 else if (wireless_mode == Ndis802_11OFDM5_N)
2190 sprintf(msg+strlen(msg),"%-7s", "11a/n");
2191 else if (wireless_mode == Ndis802_11OFDM24)
2192 sprintf(msg+strlen(msg),"%-7s", "11b/g");
2193 else if (wireless_mode == Ndis802_11OFDM24_N)
2194 sprintf(msg+strlen(msg),"%-7s", "11b/g/n");
2196 sprintf(msg+strlen(msg),"%-7s", "unknow");
2198 if (pAdapter->ScanTab.BssEntry[i].BssType == BSS_ADHOC)
2199 sprintf(msg+strlen(msg),"%-3s", " Ad");
2201 sprintf(msg+strlen(msg),"%-3s", " In");
2203 sprintf(msg+strlen(msg),"\n");
2206 pAdapter->StaCfg.bScanReqIsFromWebUI = FALSE;
2207 wrq->u.data.length = strlen(msg);
2208 Status = copy_to_user(wrq->u.data.pointer, msg, wrq->u.data.length);
2210 DBGPRINT(RT_DEBUG_TRACE, ("RTMPIoctlGetSiteSurvey - wrq->u.data.length = %d\n", wrq->u.data.length));
2211 os_free_mem(NULL, (PUCHAR)msg);
2215 #define MAC_LINE_LEN (14+4+4+10+10+10+6+6) // Addr+aid+psm+datatime+rxbyte+txbyte+current tx rate+last tx rate
2216 VOID RTMPIoctlGetMacTable(
2217 IN PRTMP_ADAPTER pAd,
2218 IN struct iwreq *wrq)
2221 RT_802_11_MAC_TABLE MacTab;
2225 for (i=0; i<MAX_LEN_OF_MAC_TABLE; i++)
2227 if (pAd->MacTab.Content[i].ValidAsCLI && (pAd->MacTab.Content[i].Sst == SST_ASSOC))
2229 COPY_MAC_ADDR(MacTab.Entry[MacTab.Num].Addr, &pAd->MacTab.Content[i].Addr);
2230 MacTab.Entry[MacTab.Num].Aid = (UCHAR)pAd->MacTab.Content[i].Aid;
2231 MacTab.Entry[MacTab.Num].Psm = pAd->MacTab.Content[i].PsMode;
2232 #ifdef DOT11_N_SUPPORT
2233 MacTab.Entry[MacTab.Num].MimoPs = pAd->MacTab.Content[i].MmpsMode;
2234 #endif // DOT11_N_SUPPORT //
2236 // Fill in RSSI per entry
2237 MacTab.Entry[MacTab.Num].AvgRssi0 = pAd->MacTab.Content[i].RssiSample.AvgRssi0;
2238 MacTab.Entry[MacTab.Num].AvgRssi1 = pAd->MacTab.Content[i].RssiSample.AvgRssi1;
2239 MacTab.Entry[MacTab.Num].AvgRssi2 = pAd->MacTab.Content[i].RssiSample.AvgRssi2;
2241 // the connected time per entry
2242 MacTab.Entry[MacTab.Num].ConnectedTime = pAd->MacTab.Content[i].StaConnectTime;
2244 MacTab.Entry[MacTab.Num].HSCounter.LastDataPacketTime = pAd->MacTab.Content[i].HSCounter.LastDataPacketTime;
2245 MacTab.Entry[MacTab.Num].HSCounter.TotalRxByteCount = pAd->MacTab.Content[i].HSCounter.TotalRxByteCount;
2246 MacTab.Entry[MacTab.Num].HSCounter.TotalTxByteCount = pAd->MacTab.Content[i].HSCounter.TotalTxByteCount;
2248 MacTab.Entry[MacTab.Num].TxRate.field.MCS = pAd->MacTab.Content[i].HTPhyMode.field.MCS;
2249 MacTab.Entry[MacTab.Num].TxRate.field.BW = pAd->MacTab.Content[i].HTPhyMode.field.BW;
2250 MacTab.Entry[MacTab.Num].TxRate.field.ShortGI = pAd->MacTab.Content[i].HTPhyMode.field.ShortGI;
2251 MacTab.Entry[MacTab.Num].TxRate.field.STBC = pAd->MacTab.Content[i].HTPhyMode.field.STBC;
2252 MacTab.Entry[MacTab.Num].TxRate.field.rsv = pAd->MacTab.Content[i].HTPhyMode.field.rsv;
2253 MacTab.Entry[MacTab.Num].TxRate.field.MODE = pAd->MacTab.Content[i].HTPhyMode.field.MODE;
2254 MacTab.Entry[MacTab.Num].TxRate.word = pAd->MacTab.Content[i].HTPhyMode.word;
2259 wrq->u.data.length = sizeof(RT_802_11_MAC_TABLE);
2260 if (copy_to_user(wrq->u.data.pointer, &MacTab, wrq->u.data.length))
2262 DBGPRINT(RT_DEBUG_TRACE, ("%s: copy_to_user() fail\n", __func__));
2265 msg = (CHAR *) kmalloc(sizeof(CHAR)*(MAX_LEN_OF_MAC_TABLE*MAC_LINE_LEN), MEM_ALLOC_FLAG);
2266 memset(msg, 0 ,MAX_LEN_OF_MAC_TABLE*MAC_LINE_LEN );
2267 sprintf(msg,"%s","\n");
2268 sprintf(msg+strlen(msg),"%-14s%-4s%-4s%-10s%-10s%-10s%-6s%-6s\n",
2269 "MAC", "AID", "PSM", "LDT", "RxB", "TxB","CTxR", "LTxR");
2271 for (i=0; i<MAX_LEN_OF_MAC_TABLE; i++)
2273 PMAC_TABLE_ENTRY pEntry = &pAd->MacTab.Content[i];
2274 if (pEntry->ValidAsCLI && (pEntry->Sst == SST_ASSOC))
2276 if((strlen(msg)+MAC_LINE_LEN ) >= (MAX_LEN_OF_MAC_TABLE*MAC_LINE_LEN) )
2278 sprintf(msg+strlen(msg),"%02x%02x%02x%02x%02x%02x ",
2279 pEntry->Addr[0], pEntry->Addr[1], pEntry->Addr[2],
2280 pEntry->Addr[3], pEntry->Addr[4], pEntry->Addr[5]);
2281 sprintf(msg+strlen(msg),"%-4d", (int)pEntry->Aid);
2282 sprintf(msg+strlen(msg),"%-4d", (int)pEntry->PsMode);
2283 sprintf(msg+strlen(msg),"%-10d",0/*pAd->MacTab.Content[i].HSCounter.LastDataPacketTime*/); // ToDo
2284 sprintf(msg+strlen(msg),"%-10d",0/*pAd->MacTab.Content[i].HSCounter.TotalRxByteCount*/); // ToDo
2285 sprintf(msg+strlen(msg),"%-10d",0/*pAd->MacTab.Content[i].HSCounter.TotalTxByteCount*/); // ToDo
2286 sprintf(msg+strlen(msg),"%-6d",RateIdToMbps[pAd->MacTab.Content[i].CurrTxRate]);
2287 sprintf(msg+strlen(msg),"%-6d\n",0/*RateIdToMbps[pAd->MacTab.Content[i].LastTxRate]*/); // ToDo
2290 // for compatible with old API just do the printk to console
2291 //wrq->u.data.length = strlen(msg);
2292 //if (copy_to_user(wrq->u.data.pointer, msg, wrq->u.data.length))
2294 DBGPRINT(RT_DEBUG_TRACE, ("%s", msg));
2300 #ifdef DOT11_N_SUPPORT
2301 INT Set_BASetup_Proc(
2302 IN PRTMP_ADAPTER pAd,
2306 char *token, sepValue[] = ":", DASH = '-';
2308 MAC_TABLE_ENTRY *pEntry;
2311 The BASetup inupt string format should be xx:xx:xx:xx:xx:xx-d,
2312 =>The six 2 digit hex-decimal number previous are the Mac address,
2313 =>The seventh decimal number is the tid value.
2315 //printk("\n%s\n", arg);
2317 if(strlen(arg) < 19) //Mac address acceptable format 01:02:03:04:05:06 length 17 plus the "-" and tid value in decimal format.
2320 token = strchr(arg, DASH);
2321 if ((token != NULL) && (strlen(token)>1))
2323 tid = simple_strtol((token+1), 0, 10);
2328 for (i = 0, token = rstrtok(arg, &sepValue[0]); token; token = rstrtok(NULL, &sepValue[0]), i++)
2330 if((strlen(token) != 2) || (!isxdigit(*token)) || (!isxdigit(*(token+1))))
2332 AtoH(token, (PUCHAR)(&mac[i]), 1);
2337 printk("\n%02x:%02x:%02x:%02x:%02x:%02x-%02x\n", mac[0], mac[1],
2338 mac[2], mac[3], mac[4], mac[5], tid);
2340 pEntry = MacTableLookup(pAd, mac);
2343 printk("\nSetup BA Session: Tid = %d\n", tid);
2344 BAOriSessionSetUp(pAd, pEntry, tid, 0, 100, TRUE);
2354 INT Set_BADecline_Proc(
2355 IN PRTMP_ADAPTER pAd,
2360 bBADecline = simple_strtol(arg, 0, 10);
2362 if (bBADecline == 0)
2364 pAd->CommonCfg.bBADecline = FALSE;
2366 else if (bBADecline == 1)
2368 pAd->CommonCfg.bBADecline = TRUE;
2372 return FALSE; //Invalid argument
2375 DBGPRINT(RT_DEBUG_TRACE, ("Set_BADecline_Proc::(BADecline=%d)\n", pAd->CommonCfg.bBADecline));
2380 INT Set_BAOriTearDown_Proc(
2381 IN PRTMP_ADAPTER pAd,
2385 char *token, sepValue[] = ":", DASH = '-';
2387 MAC_TABLE_ENTRY *pEntry;
2389 //printk("\n%s\n", arg);
2391 The BAOriTearDown inupt string format should be xx:xx:xx:xx:xx:xx-d,
2392 =>The six 2 digit hex-decimal number previous are the Mac address,
2393 =>The seventh decimal number is the tid value.
2395 if(strlen(arg) < 19) //Mac address acceptable format 01:02:03:04:05:06 length 17 plus the "-" and tid value in decimal format.
2398 token = strchr(arg, DASH);
2399 if ((token != NULL) && (strlen(token)>1))
2401 tid = simple_strtol((token+1), 0, 10);
2402 if (tid > NUM_OF_TID)
2406 for (i = 0, token = rstrtok(arg, &sepValue[0]); token; token = rstrtok(NULL, &sepValue[0]), i++)
2408 if((strlen(token) != 2) || (!isxdigit(*token)) || (!isxdigit(*(token+1))))
2410 AtoH(token, (PUCHAR)(&mac[i]), 1);
2415 printk("\n%02x:%02x:%02x:%02x:%02x:%02x-%02x", mac[0], mac[1],
2416 mac[2], mac[3], mac[4], mac[5], tid);
2418 pEntry = MacTableLookup(pAd, mac);
2421 printk("\nTear down Ori BA Session: Tid = %d\n", tid);
2422 BAOriSessionTearDown(pAd, pEntry->Aid, tid, FALSE, TRUE);
2432 INT Set_BARecTearDown_Proc(
2433 IN PRTMP_ADAPTER pAd,
2437 char *token, sepValue[] = ":", DASH = '-';
2439 MAC_TABLE_ENTRY *pEntry;
2441 //printk("\n%s\n", arg);
2443 The BARecTearDown inupt string format should be xx:xx:xx:xx:xx:xx-d,
2444 =>The six 2 digit hex-decimal number previous are the Mac address,
2445 =>The seventh decimal number is the tid value.
2447 if(strlen(arg) < 19) //Mac address acceptable format 01:02:03:04:05:06 length 17 plus the "-" and tid value in decimal format.
2450 token = strchr(arg, DASH);
2451 if ((token != NULL) && (strlen(token)>1))
2453 tid = simple_strtol((token+1), 0, 10);
2454 if (tid > NUM_OF_TID)
2458 for (i = 0, token = rstrtok(arg, &sepValue[0]); token; token = rstrtok(NULL, &sepValue[0]), i++)
2460 if((strlen(token) != 2) || (!isxdigit(*token)) || (!isxdigit(*(token+1))))
2462 AtoH(token, (PUCHAR)(&mac[i]), 1);
2467 printk("\n%02x:%02x:%02x:%02x:%02x:%02x-%02x", mac[0], mac[1],
2468 mac[2], mac[3], mac[4], mac[5], tid);
2470 pEntry = MacTableLookup(pAd, mac);
2473 printk("\nTear down Rec BA Session: Tid = %d\n", tid);
2474 BARecSessionTearDown(pAd, pEntry->Aid, tid, FALSE);
2485 IN PRTMP_ADAPTER pAd,
2490 HtBw = simple_strtol(arg, 0, 10);
2492 pAd->CommonCfg.RegTransmitSetting.field.BW = BW_40;
2493 else if (HtBw == BW_20)
2494 pAd->CommonCfg.RegTransmitSetting.field.BW = BW_20;
2496 return FALSE; //Invalid argument
2500 DBGPRINT(RT_DEBUG_TRACE, ("Set_HtBw_Proc::(HtBw=%d)\n", pAd->CommonCfg.RegTransmitSetting.field.BW));
2506 IN PRTMP_ADAPTER pAd,
2509 ULONG HtMcs, Mcs_tmp;
2510 BOOLEAN bAutoRate = FALSE;
2512 Mcs_tmp = simple_strtol(arg, 0, 10);
2514 if (Mcs_tmp <= 15 || Mcs_tmp == 32)
2519 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
2521 pAd->StaCfg.DesiredTransmitSetting.field.MCS = HtMcs;
2522 pAd->StaCfg.bAutoTxRateSwitch = (HtMcs == MCS_AUTO) ? TRUE:FALSE;
2523 DBGPRINT(RT_DEBUG_TRACE, ("Set_HtMcs_Proc::(HtMcs=%d, bAutoTxRateSwitch = %d)\n",
2524 pAd->StaCfg.DesiredTransmitSetting.field.MCS, pAd->StaCfg.bAutoTxRateSwitch));
2526 if ((pAd->CommonCfg.PhyMode < PHY_11ABGN_MIXED) ||
2527 (pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE < MODE_HTMIX))
2529 if ((pAd->StaCfg.DesiredTransmitSetting.field.MCS != MCS_AUTO) &&
2530 (HtMcs >= 0 && HtMcs <= 3) &&
2531 (pAd->StaCfg.DesiredTransmitSetting.field.FixedTxMode == FIXED_TXMODE_CCK))
2533 RTMPSetDesiredRates(pAd, (LONG) (RateIdToMbps[HtMcs] * 1000000));
2535 else if ((pAd->StaCfg.DesiredTransmitSetting.field.MCS != MCS_AUTO) &&
2536 (HtMcs >= 0 && HtMcs <= 7) &&
2537 (pAd->StaCfg.DesiredTransmitSetting.field.FixedTxMode == FIXED_TXMODE_OFDM))
2539 RTMPSetDesiredRates(pAd, (LONG) (RateIdToMbps[HtMcs+4] * 1000000));
2546 pAd->StaCfg.DesiredTransmitSetting.field.MCS = MCS_AUTO;
2547 RTMPSetDesiredRates(pAd, -1);
2549 DBGPRINT(RT_DEBUG_TRACE, ("Set_HtMcs_Proc::(FixedTxMode=%d)\n",pAd->StaCfg.DesiredTransmitSetting.field.FixedTxMode));
2561 IN PRTMP_ADAPTER pAd,
2566 HtGi = simple_strtol(arg, 0, 10);
2568 if ( HtGi == GI_400)
2569 pAd->CommonCfg.RegTransmitSetting.field.ShortGI = GI_400;
2570 else if ( HtGi == GI_800 )
2571 pAd->CommonCfg.RegTransmitSetting.field.ShortGI = GI_800;
2573 return FALSE; //Invalid argument
2577 DBGPRINT(RT_DEBUG_TRACE, ("Set_HtGi_Proc::(ShortGI=%d)\n",pAd->CommonCfg.RegTransmitSetting.field.ShortGI));
2583 INT Set_HtTxBASize_Proc(
2584 IN PRTMP_ADAPTER pAd,
2589 Size = simple_strtol(arg, 0, 10);
2591 if (Size <=0 || Size >=64)
2595 pAd->CommonCfg.TxBASize = Size-1;
2596 DBGPRINT(RT_DEBUG_ERROR, ("Set_HtTxBASize ::(TxBASize= %d)\n", Size));
2602 INT Set_HtOpMode_Proc(
2603 IN PRTMP_ADAPTER pAd,
2609 Value = simple_strtol(arg, 0, 10);
2611 if (Value == HTMODE_GF)
2612 pAd->CommonCfg.RegTransmitSetting.field.HTMODE = HTMODE_GF;
2613 else if ( Value == HTMODE_MM )
2614 pAd->CommonCfg.RegTransmitSetting.field.HTMODE = HTMODE_MM;
2616 return FALSE; //Invalid argument
2620 DBGPRINT(RT_DEBUG_TRACE, ("Set_HtOpMode_Proc::(HtOpMode=%d)\n",pAd->CommonCfg.RegTransmitSetting.field.HTMODE));
2626 INT Set_HtStbc_Proc(
2627 IN PRTMP_ADAPTER pAd,
2633 Value = simple_strtol(arg, 0, 10);
2635 if (Value == STBC_USE)
2636 pAd->CommonCfg.RegTransmitSetting.field.STBC = STBC_USE;
2637 else if ( Value == STBC_NONE )
2638 pAd->CommonCfg.RegTransmitSetting.field.STBC = STBC_NONE;
2640 return FALSE; //Invalid argument
2644 DBGPRINT(RT_DEBUG_TRACE, ("Set_Stbc_Proc::(HtStbc=%d)\n",pAd->CommonCfg.RegTransmitSetting.field.STBC));
2650 IN PRTMP_ADAPTER pAd,
2656 Value = simple_strtol(arg, 0, 10);
2658 pAd->HTCEnable = FALSE;
2659 else if ( Value ==1 )
2660 pAd->HTCEnable = TRUE;
2662 return FALSE; //Invalid argument
2664 DBGPRINT(RT_DEBUG_TRACE, ("Set_HtHtc_Proc::(HtHtc=%d)\n",pAd->HTCEnable));
2669 INT Set_HtExtcha_Proc(
2670 IN PRTMP_ADAPTER pAd,
2676 Value = simple_strtol(arg, 0, 10);
2679 pAd->CommonCfg.RegTransmitSetting.field.EXTCHA = EXTCHA_BELOW;
2680 else if ( Value ==1 )
2681 pAd->CommonCfg.RegTransmitSetting.field.EXTCHA = EXTCHA_ABOVE;
2683 return FALSE; //Invalid argument
2687 DBGPRINT(RT_DEBUG_TRACE, ("Set_HtExtcha_Proc::(HtExtcha=%d)\n",pAd->CommonCfg.RegTransmitSetting.field.EXTCHA));
2692 INT Set_HtMpduDensity_Proc(
2693 IN PRTMP_ADAPTER pAd,
2698 Value = simple_strtol(arg, 0, 10);
2700 if (Value <=7 && Value >= 0)
2701 pAd->CommonCfg.BACapability.field.MpduDensity = Value;
2703 pAd->CommonCfg.BACapability.field.MpduDensity = 4;
2707 DBGPRINT(RT_DEBUG_TRACE, ("Set_HtMpduDensity_Proc::(HtMpduDensity=%d)\n",pAd->CommonCfg.BACapability.field.MpduDensity));
2712 INT Set_HtBaWinSize_Proc(
2713 IN PRTMP_ADAPTER pAd,
2718 Value = simple_strtol(arg, 0, 10);
2721 if (Value >=1 && Value <= 64)
2723 pAd->CommonCfg.REGBACapability.field.RxBAWinLimit = Value;
2724 pAd->CommonCfg.BACapability.field.RxBAWinLimit = Value;
2728 pAd->CommonCfg.REGBACapability.field.RxBAWinLimit = 64;
2729 pAd->CommonCfg.BACapability.field.RxBAWinLimit = 64;
2734 DBGPRINT(RT_DEBUG_TRACE, ("Set_HtBaWinSize_Proc::(HtBaWinSize=%d)\n",pAd->CommonCfg.BACapability.field.RxBAWinLimit));
2740 IN PRTMP_ADAPTER pAd,
2745 Value = simple_strtol(arg, 0, 10);
2748 pAd->CommonCfg.bRdg = FALSE;
2749 else if ( Value ==1 )
2751 pAd->HTCEnable = TRUE;
2752 pAd->CommonCfg.bRdg = TRUE;
2755 return FALSE; //Invalid argument
2759 DBGPRINT(RT_DEBUG_TRACE, ("Set_HtRdg_Proc::(HtRdg=%d)\n",pAd->CommonCfg.bRdg));
2764 INT Set_HtLinkAdapt_Proc(
2765 IN PRTMP_ADAPTER pAd,
2770 Value = simple_strtol(arg, 0, 10);
2772 pAd->bLinkAdapt = FALSE;
2773 else if ( Value ==1 )
2775 pAd->HTCEnable = TRUE;
2776 pAd->bLinkAdapt = TRUE;
2779 return FALSE; //Invalid argument
2781 DBGPRINT(RT_DEBUG_TRACE, ("Set_HtLinkAdapt_Proc::(HtLinkAdapt=%d)\n",pAd->bLinkAdapt));
2786 INT Set_HtAmsdu_Proc(
2787 IN PRTMP_ADAPTER pAd,
2792 Value = simple_strtol(arg, 0, 10);
2794 pAd->CommonCfg.BACapability.field.AmsduEnable = FALSE;
2795 else if ( Value == 1 )
2796 pAd->CommonCfg.BACapability.field.AmsduEnable = TRUE;
2798 return FALSE; //Invalid argument
2802 DBGPRINT(RT_DEBUG_TRACE, ("Set_HtAmsdu_Proc::(HtAmsdu=%d)\n",pAd->CommonCfg.BACapability.field.AmsduEnable));
2807 INT Set_HtAutoBa_Proc(
2808 IN PRTMP_ADAPTER pAd,
2813 Value = simple_strtol(arg, 0, 10);
2815 pAd->CommonCfg.BACapability.field.AutoBA = FALSE;
2816 else if (Value == 1)
2817 pAd->CommonCfg.BACapability.field.AutoBA = TRUE;
2819 return FALSE; //Invalid argument
2821 pAd->CommonCfg.REGBACapability.field.AutoBA = pAd->CommonCfg.BACapability.field.AutoBA;
2824 DBGPRINT(RT_DEBUG_TRACE, ("Set_HtAutoBa_Proc::(HtAutoBa=%d)\n",pAd->CommonCfg.BACapability.field.AutoBA));
2830 INT Set_HtProtect_Proc(
2831 IN PRTMP_ADAPTER pAd,
2836 Value = simple_strtol(arg, 0, 10);
2838 pAd->CommonCfg.bHTProtect = FALSE;
2839 else if (Value == 1)
2840 pAd->CommonCfg.bHTProtect = TRUE;
2842 return FALSE; //Invalid argument
2844 DBGPRINT(RT_DEBUG_TRACE, ("Set_HtProtect_Proc::(HtProtect=%d)\n",pAd->CommonCfg.bHTProtect));
2849 INT Set_SendPSMPAction_Proc(
2850 IN PRTMP_ADAPTER pAd,
2854 char *token, sepValue[] = ":", DASH = '-';
2856 MAC_TABLE_ENTRY *pEntry;
2858 //printk("\n%s\n", arg);
2860 The BARecTearDown inupt string format should be xx:xx:xx:xx:xx:xx-d,
2861 =>The six 2 digit hex-decimal number previous are the Mac address,
2862 =>The seventh decimal number is the mode value.
2864 if(strlen(arg) < 19) //Mac address acceptable format 01:02:03:04:05:06 length 17 plus the "-" and mode value in decimal format.
2867 token = strchr(arg, DASH);
2868 if ((token != NULL) && (strlen(token)>1))
2870 mode = simple_strtol((token+1), 0, 10);
2871 if (mode > MMPS_ENABLE)
2875 for (i = 0, token = rstrtok(arg, &sepValue[0]); token; token = rstrtok(NULL, &sepValue[0]), i++)
2877 if((strlen(token) != 2) || (!isxdigit(*token)) || (!isxdigit(*(token+1))))
2879 AtoH(token, (PUCHAR)(&mac[i]), 1);
2884 printk("\n%02x:%02x:%02x:%02x:%02x:%02x-%02x", mac[0], mac[1],
2885 mac[2], mac[3], mac[4], mac[5], mode);
2887 pEntry = MacTableLookup(pAd, mac);
2890 printk("\nSendPSMPAction MIPS mode = %d\n", mode);
2891 SendPSMPAction(pAd, pEntry->Aid, mode);
2902 INT Set_HtMIMOPSmode_Proc(
2903 IN PRTMP_ADAPTER pAd,
2908 Value = simple_strtol(arg, 0, 10);
2910 if (Value <=3 && Value >= 0)
2911 pAd->CommonCfg.BACapability.field.MMPSmode = Value;
2913 pAd->CommonCfg.BACapability.field.MMPSmode = 3;
2917 DBGPRINT(RT_DEBUG_TRACE, ("Set_HtMIMOPSmode_Proc::(MIMOPS mode=%d)\n",pAd->CommonCfg.BACapability.field.MMPSmode));
2923 INT Set_ForceShortGI_Proc(
2924 IN PRTMP_ADAPTER pAd,
2929 Value = simple_strtol(arg, 0, 10);
2931 pAd->WIFItestbed.bShortGI = FALSE;
2932 else if (Value == 1)
2933 pAd->WIFItestbed.bShortGI = TRUE;
2935 return FALSE; //Invalid argument
2939 DBGPRINT(RT_DEBUG_TRACE, ("Set_ForceShortGI_Proc::(ForceShortGI=%d)\n", pAd->WIFItestbed.bShortGI));
2946 INT Set_ForceGF_Proc(
2947 IN PRTMP_ADAPTER pAd,
2952 Value = simple_strtol(arg, 0, 10);
2954 pAd->WIFItestbed.bGreenField = FALSE;
2955 else if (Value == 1)
2956 pAd->WIFItestbed.bGreenField = TRUE;
2958 return FALSE; //Invalid argument
2962 DBGPRINT(RT_DEBUG_TRACE, ("Set_ForceGF_Proc::(ForceGF=%d)\n", pAd->WIFItestbed.bGreenField));
2967 INT Set_HtMimoPs_Proc(
2968 IN PRTMP_ADAPTER pAd,
2973 Value = simple_strtol(arg, 0, 10);
2975 pAd->CommonCfg.bMIMOPSEnable = FALSE;
2976 else if (Value == 1)
2977 pAd->CommonCfg.bMIMOPSEnable = TRUE;
2979 return FALSE; //Invalid argument
2981 DBGPRINT(RT_DEBUG_TRACE, ("Set_HtMimoPs_Proc::(HtMimoPs=%d)\n",pAd->CommonCfg.bMIMOPSEnable));
2985 #endif // DOT11_N_SUPPORT //
2988 #ifdef DOT11_N_SUPPORT
2990 IN PRTMP_ADAPTER pAd)
2992 OID_SET_HT_PHYMODE SetHT;
2994 if (pAd->CommonCfg.PhyMode < PHY_11ABGN_MIXED)
2997 SetHT.PhyMode = pAd->CommonCfg.PhyMode;
2998 SetHT.TransmitNo = ((UCHAR)pAd->Antenna.field.TxPath);
2999 SetHT.HtMode = (UCHAR)pAd->CommonCfg.RegTransmitSetting.field.HTMODE;
3000 SetHT.ExtOffset = (UCHAR)pAd->CommonCfg.RegTransmitSetting.field.EXTCHA;
3001 SetHT.MCS = MCS_AUTO;
3002 SetHT.BW = (UCHAR)pAd->CommonCfg.RegTransmitSetting.field.BW;
3003 SetHT.STBC = (UCHAR)pAd->CommonCfg.RegTransmitSetting.field.STBC;
3004 SetHT.SHORTGI = (UCHAR)pAd->CommonCfg.RegTransmitSetting.field.ShortGI;
3006 RTMPSetHT(pAd, &SetHT);
3010 #endif // DOT11_N_SUPPORT //
3012 INT Set_FixedTxMode_Proc(
3013 IN PRTMP_ADAPTER pAd,
3016 UCHAR fix_tx_mode = FIXED_TXMODE_HT;
3018 if (strcmp(arg, "OFDM") == 0 || strcmp(arg, "ofdm") == 0)
3020 fix_tx_mode = FIXED_TXMODE_OFDM;
3022 else if (strcmp(arg, "CCK") == 0 || strcmp(arg, "cck") == 0)
3024 fix_tx_mode = FIXED_TXMODE_CCK;
3027 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
3028 pAd->StaCfg.DesiredTransmitSetting.field.FixedTxMode = fix_tx_mode;
3030 DBGPRINT(RT_DEBUG_TRACE, ("Set_FixedTxMode_Proc::(FixedTxMode=%d)\n", fix_tx_mode));
3035 /////////////////////////////////////////////////////////////////////////
3036 PCHAR RTMPGetRalinkAuthModeStr(
3037 IN NDIS_802_11_AUTHENTICATION_MODE authMode)
3041 case Ndis802_11AuthModeOpen:
3043 case Ndis802_11AuthModeWPAPSK:
3045 case Ndis802_11AuthModeShared:
3047 case Ndis802_11AuthModeWPA:
3049 case Ndis802_11AuthModeWPA2:
3051 case Ndis802_11AuthModeWPA2PSK:
3053 case Ndis802_11AuthModeWPA1PSKWPA2PSK:
3054 return "WPAPSKWPA2PSK";
3055 case Ndis802_11AuthModeWPA1WPA2:
3057 case Ndis802_11AuthModeWPANone:
3064 PCHAR RTMPGetRalinkEncryModeStr(
3065 IN USHORT encryMode)
3069 case Ndis802_11WEPDisabled:
3071 case Ndis802_11WEPEnabled:
3073 case Ndis802_11Encryption2Enabled:
3075 case Ndis802_11Encryption3Enabled:
3077 case Ndis802_11Encryption4Enabled:
3084 INT RTMPShowCfgValue(
3085 IN PRTMP_ADAPTER pAd,
3091 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++)
3093 if (!strcmp(pName, PRTMP_PRIVATE_STA_SHOW_CFG_VALUE_PROC->name))
3095 if(PRTMP_PRIVATE_STA_SHOW_CFG_VALUE_PROC->show_proc(pAd, pBuf))
3097 break; //Exit for loop.
3101 if(PRTMP_PRIVATE_STA_SHOW_CFG_VALUE_PROC->name == NULL)
3103 sprintf(pBuf, "\n");
3104 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++)
3105 sprintf(pBuf + strlen(pBuf), "%s\n", PRTMP_PRIVATE_STA_SHOW_CFG_VALUE_PROC->name);
3112 IN PRTMP_ADAPTER pAd,
3115 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
3116 sprintf(pBuf, "\t%s", pAd->CommonCfg.Ssid);
3120 INT Show_WirelessMode_Proc(
3121 IN PRTMP_ADAPTER pAd,
3124 switch(pAd->CommonCfg.PhyMode)
3126 case PHY_11BG_MIXED:
3127 sprintf(pBuf, "\t11B/G");
3130 sprintf(pBuf, "\t11B");
3133 sprintf(pBuf, "\t11A");
3135 case PHY_11ABG_MIXED:
3136 sprintf(pBuf, "\t11A/B/G");
3139 sprintf(pBuf, "\t11G");
3141 #ifdef DOT11_N_SUPPORT
3142 case PHY_11ABGN_MIXED:
3143 sprintf(pBuf, "\t11A/B/G/N");
3146 sprintf(pBuf, "\t11N only with 2.4G");
3148 case PHY_11GN_MIXED:
3149 sprintf(pBuf, "\t11G/N");
3151 case PHY_11AN_MIXED:
3152 sprintf(pBuf, "\t11A/N");
3154 case PHY_11BGN_MIXED:
3155 sprintf(pBuf, "\t11B/G/N");
3157 case PHY_11AGN_MIXED:
3158 sprintf(pBuf, "\t11A/G/N");
3161 sprintf(pBuf, "\t11N only with 5G");
3163 #endif // DOT11_N_SUPPORT //
3165 sprintf(pBuf, "\tUnknow Value(%d)", pAd->CommonCfg.PhyMode);
3172 INT Show_TxBurst_Proc(
3173 IN PRTMP_ADAPTER pAd,
3176 sprintf(pBuf, "\t%s", pAd->CommonCfg.bEnableTxBurst ? "TRUE":"FALSE");
3180 INT Show_TxPreamble_Proc(
3181 IN PRTMP_ADAPTER pAd,
3184 switch(pAd->CommonCfg.TxPreamble)
3186 case Rt802_11PreambleShort:
3187 sprintf(pBuf, "\tShort");
3189 case Rt802_11PreambleLong:
3190 sprintf(pBuf, "\tLong");
3192 case Rt802_11PreambleAuto:
3193 sprintf(pBuf, "\tAuto");
3196 sprintf(pBuf, "\tUnknow Value(%lu)", pAd->CommonCfg.TxPreamble);
3203 INT Show_TxPower_Proc(
3204 IN PRTMP_ADAPTER pAd,
3207 sprintf(pBuf, "\t%lu", pAd->CommonCfg.TxPowerPercentage);
3211 INT Show_Channel_Proc(
3212 IN PRTMP_ADAPTER pAd,
3215 sprintf(pBuf, "\t%d", pAd->CommonCfg.Channel);
3219 INT Show_BGProtection_Proc(
3220 IN PRTMP_ADAPTER pAd,
3223 switch(pAd->CommonCfg.UseBGProtection)
3226 sprintf(pBuf, "\tON");
3228 case 2: //Always OFF
3229 sprintf(pBuf, "\tOFF");
3232 sprintf(pBuf, "\tAuto");
3235 sprintf(pBuf, "\tUnknow Value(%lu)", pAd->CommonCfg.UseBGProtection);
3241 INT Show_RTSThreshold_Proc(
3242 IN PRTMP_ADAPTER pAd,
3245 sprintf(pBuf, "\t%u", pAd->CommonCfg.RtsThreshold);
3249 INT Show_FragThreshold_Proc(
3250 IN PRTMP_ADAPTER pAd,
3253 sprintf(pBuf, "\t%u", pAd->CommonCfg.FragmentThreshold);
3257 #ifdef DOT11_N_SUPPORT
3259 IN PRTMP_ADAPTER pAd,
3262 if (pAd->CommonCfg.RegTransmitSetting.field.BW == BW_40)
3264 sprintf(pBuf, "\t40 MHz");
3268 sprintf(pBuf, "\t20 MHz");
3273 INT Show_HtMcs_Proc(
3274 IN PRTMP_ADAPTER pAd,
3277 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
3278 sprintf(pBuf, "\t%u", pAd->StaCfg.DesiredTransmitSetting.field.MCS);
3283 IN PRTMP_ADAPTER pAd,
3286 switch(pAd->CommonCfg.RegTransmitSetting.field.ShortGI)
3289 sprintf(pBuf, "\tGI_400");
3292 sprintf(pBuf, "\tGI_800");
3295 sprintf(pBuf, "\tUnknow Value(%u)", pAd->CommonCfg.RegTransmitSetting.field.ShortGI);
3301 INT Show_HtOpMode_Proc(
3302 IN PRTMP_ADAPTER pAd,
3305 switch(pAd->CommonCfg.RegTransmitSetting.field.HTMODE)
3308 sprintf(pBuf, "\tGF");
3311 sprintf(pBuf, "\tMM");
3314 sprintf(pBuf, "\tUnknow Value(%u)", pAd->CommonCfg.RegTransmitSetting.field.HTMODE);
3320 INT Show_HtExtcha_Proc(
3321 IN PRTMP_ADAPTER pAd,
3324 switch(pAd->CommonCfg.RegTransmitSetting.field.EXTCHA)
3327 sprintf(pBuf, "\tBelow");
3330 sprintf(pBuf, "\tAbove");
3333 sprintf(pBuf, "\tUnknow Value(%u)", pAd->CommonCfg.RegTransmitSetting.field.EXTCHA);
3340 INT Show_HtMpduDensity_Proc(
3341 IN PRTMP_ADAPTER pAd,
3344 sprintf(pBuf, "\t%u", pAd->CommonCfg.BACapability.field.MpduDensity);
3348 INT Show_HtBaWinSize_Proc(
3349 IN PRTMP_ADAPTER pAd,
3352 sprintf(pBuf, "\t%u", pAd->CommonCfg.BACapability.field.RxBAWinLimit);
3356 INT Show_HtRdg_Proc(
3357 IN PRTMP_ADAPTER pAd,
3360 sprintf(pBuf, "\t%s", pAd->CommonCfg.bRdg ? "TRUE":"FALSE");
3364 INT Show_HtAmsdu_Proc(
3365 IN PRTMP_ADAPTER pAd,
3368 sprintf(pBuf, "\t%s", pAd->CommonCfg.BACapability.field.AmsduEnable ? "TRUE":"FALSE");
3372 INT Show_HtAutoBa_Proc(
3373 IN PRTMP_ADAPTER pAd,
3376 sprintf(pBuf, "\t%s", pAd->CommonCfg.BACapability.field.AutoBA ? "TRUE":"FALSE");
3379 #endif // DOT11_N_SUPPORT //
3381 INT Show_CountryRegion_Proc(
3382 IN PRTMP_ADAPTER pAd,
3385 sprintf(pBuf, "\t%d", pAd->CommonCfg.CountryRegion);
3389 INT Show_CountryRegionABand_Proc(
3390 IN PRTMP_ADAPTER pAd,
3393 sprintf(pBuf, "\t%d", pAd->CommonCfg.CountryRegionForABand);
3397 INT Show_CountryCode_Proc(
3398 IN PRTMP_ADAPTER pAd,
3401 sprintf(pBuf, "\t%s", pAd->CommonCfg.CountryCode);
3405 #ifdef AGGREGATION_SUPPORT
3406 INT Show_PktAggregate_Proc(
3407 IN PRTMP_ADAPTER pAd,
3410 sprintf(pBuf, "\t%s", pAd->CommonCfg.bAggregationCapable ? "TRUE":"FALSE");
3413 #endif // AGGREGATION_SUPPORT //
3416 INT Show_WmmCapable_Proc(
3417 IN PRTMP_ADAPTER pAd,
3420 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
3421 sprintf(pBuf, "\t%s", pAd->CommonCfg.bWmmCapable ? "TRUE":"FALSE");
3425 #endif // WMM_SUPPORT //
3427 INT Show_IEEE80211H_Proc(
3428 IN PRTMP_ADAPTER pAd,
3431 sprintf(pBuf, "\t%s", pAd->CommonCfg.bIEEE80211H ? "TRUE":"FALSE");
3435 INT Show_NetworkType_Proc(
3436 IN PRTMP_ADAPTER pAd,
3439 switch(pAd->StaCfg.BssType)
3442 sprintf(pBuf, "\tAdhoc");
3445 sprintf(pBuf, "\tInfra");
3448 sprintf(pBuf, "\tAny");
3451 sprintf(pBuf, "\tMonitor");
3454 sprintf(pBuf, "\tUnknow Value(%d)", pAd->StaCfg.BssType);
3460 INT Show_AuthMode_Proc(
3461 IN PRTMP_ADAPTER pAd,
3464 NDIS_802_11_AUTHENTICATION_MODE AuthMode = Ndis802_11AuthModeOpen;
3466 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
3467 AuthMode = pAd->StaCfg.AuthMode;
3469 if ((AuthMode >= Ndis802_11AuthModeOpen) &&
3470 (AuthMode <= Ndis802_11AuthModeWPA1PSKWPA2PSK))
3471 sprintf(pBuf, "\t%s", RTMPGetRalinkAuthModeStr(AuthMode));
3473 sprintf(pBuf, "\tUnknow Value(%d)", AuthMode);
3478 INT Show_EncrypType_Proc(
3479 IN PRTMP_ADAPTER pAd,
3482 NDIS_802_11_WEP_STATUS WepStatus = Ndis802_11WEPDisabled;
3484 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
3485 WepStatus = pAd->StaCfg.WepStatus;
3487 if ((WepStatus >= Ndis802_11WEPEnabled) &&
3488 (WepStatus <= Ndis802_11Encryption4KeyAbsent))
3489 sprintf(pBuf, "\t%s", RTMPGetRalinkEncryModeStr(WepStatus));
3491 sprintf(pBuf, "\tUnknow Value(%d)", WepStatus);
3496 INT Show_DefaultKeyID_Proc(
3497 IN PRTMP_ADAPTER pAd,
3500 UCHAR DefaultKeyId = 0;
3502 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
3503 DefaultKeyId = pAd->StaCfg.DefaultKeyId;
3505 sprintf(pBuf, "\t%d", DefaultKeyId);
3510 INT Show_WepKey_Proc(
3511 IN PRTMP_ADAPTER pAd,
3515 UCHAR Key[16] = {0}, KeyLength = 0;
3518 KeyLength = pAd->SharedKey[index][KeyIdx].KeyLen;
3519 NdisMoveMemory(Key, pAd->SharedKey[index][KeyIdx].Key, KeyLength);
3521 //check key string is ASCII or not
3522 if (RTMPCheckStrPrintAble(Key, KeyLength))
3523 sprintf(pBuf, "\t%s", Key);
3527 sprintf(pBuf, "\t");
3528 for (idx = 0; idx < KeyLength; idx++)
3529 sprintf(pBuf+strlen(pBuf), "%02X", Key[idx]);
3535 IN PRTMP_ADAPTER pAd,
3538 Show_WepKey_Proc(pAd, 0, pBuf);
3543 IN PRTMP_ADAPTER pAd,
3546 Show_WepKey_Proc(pAd, 1, pBuf);
3551 IN PRTMP_ADAPTER pAd,
3554 Show_WepKey_Proc(pAd, 2, pBuf);
3559 IN PRTMP_ADAPTER pAd,
3562 Show_WepKey_Proc(pAd, 3, pBuf);
3566 INT Show_WPAPSK_Proc(
3567 IN PRTMP_ADAPTER pAd,
3571 UCHAR PMK[32] = {0};
3573 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
3574 NdisMoveMemory(PMK, pAd->StaCfg.PMK, 32);
3576 sprintf(pBuf, "\tPMK = ");
3577 for (idx = 0; idx < 32; idx++)
3578 sprintf(pBuf+strlen(pBuf), "%02X", PMK[idx]);