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 #ifdef CONFIG_STA_SUPPORT
137 INT Show_NetworkType_Proc(
138 IN PRTMP_ADAPTER pAd,
140 #endif // CONFIG_STA_SUPPORT //
142 INT Show_AuthMode_Proc(
143 IN PRTMP_ADAPTER pAd,
146 INT Show_EncrypType_Proc(
147 IN PRTMP_ADAPTER pAd,
150 INT Show_DefaultKeyID_Proc(
151 IN PRTMP_ADAPTER pAd,
155 IN PRTMP_ADAPTER pAd,
159 IN PRTMP_ADAPTER pAd,
163 IN PRTMP_ADAPTER pAd,
167 IN PRTMP_ADAPTER pAd,
170 INT Show_WPAPSK_Proc(
171 IN PRTMP_ADAPTER pAd,
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},
207 {"WmmCapable", Show_WmmCapable_Proc},
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},
225 ==========================================================================
230 ==========================================================================
232 INT Set_DriverVersion_Proc(
233 IN PRTMP_ADAPTER pAd,
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 //
246 ==========================================================================
249 This command will not work, if the field of CountryRegion in eeprom is programmed.
251 TRUE if all parameters are OK, FALSE otherwise
252 ==========================================================================
254 INT Set_CountryRegion_Proc(
255 IN PRTMP_ADAPTER pAd,
260 region = simple_strtol(arg, 0, 10);
262 // Country can be set only when EEPROM not programmed
263 if (pAd->CommonCfg.CountryRegion & 0x80)
265 DBGPRINT(RT_DEBUG_ERROR, ("Set_CountryRegion_Proc::parameter of CountryRegion in eeprom is programmed \n"));
269 if((region >= 0) && (region <= REGION_MAXIMUM_BG_BAND))
271 pAd->CommonCfg.CountryRegion = (UCHAR) region;
273 else if (region == REGION_31_BG_BAND)
275 pAd->CommonCfg.CountryRegion = (UCHAR) region;
279 DBGPRINT(RT_DEBUG_ERROR, ("Set_CountryRegion_Proc::parameters out of range\n"));
283 // if set country region, driver needs to be reset
284 BuildChannelList(pAd);
286 DBGPRINT(RT_DEBUG_TRACE, ("Set_CountryRegion_Proc::(CountryRegion=%d)\n", pAd->CommonCfg.CountryRegion));
292 ==========================================================================
294 Set Country Region for A band.
295 This command will not work, if the field of CountryRegion in eeprom is programmed.
297 TRUE if all parameters are OK, FALSE otherwise
298 ==========================================================================
300 INT Set_CountryRegionABand_Proc(
301 IN PRTMP_ADAPTER pAd,
306 region = simple_strtol(arg, 0, 10);
308 // Country can be set only when EEPROM not programmed
309 if (pAd->CommonCfg.CountryRegionForABand & 0x80)
311 DBGPRINT(RT_DEBUG_ERROR, ("Set_CountryRegionABand_Proc::parameter of CountryRegion in eeprom is programmed \n"));
315 if((region >= 0) && (region <= REGION_MAXIMUM_A_BAND))
317 pAd->CommonCfg.CountryRegionForABand = (UCHAR) region;
321 DBGPRINT(RT_DEBUG_ERROR, ("Set_CountryRegionABand_Proc::parameters out of range\n"));
325 // if set country region, driver needs to be reset
326 BuildChannelList(pAd);
328 DBGPRINT(RT_DEBUG_TRACE, ("Set_CountryRegionABand_Proc::(CountryRegion=%d)\n", pAd->CommonCfg.CountryRegionForABand));
334 ==========================================================================
338 TRUE if all parameters are OK, FALSE otherwise
339 ==========================================================================
341 INT Set_WirelessMode_Proc(
342 IN PRTMP_ADAPTER pAd,
348 WirelessMode = simple_strtol(arg, 0, 10);
351 #ifdef CONFIG_STA_SUPPORT
352 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
354 INT MaxPhyMode = PHY_11G;
356 #ifdef DOT11_N_SUPPORT
357 MaxPhyMode = PHY_11N_5G;
358 #endif // DOT11_N_SUPPORT //
360 if (WirelessMode <= MaxPhyMode)
362 RTMPSetPhyMode(pAd, WirelessMode);
363 #ifdef DOT11_N_SUPPORT
364 if (WirelessMode >= PHY_11ABGN_MIXED)
366 pAd->CommonCfg.BACapability.field.AutoBA = TRUE;
367 pAd->CommonCfg.REGBACapability.field.AutoBA = TRUE;
371 pAd->CommonCfg.BACapability.field.AutoBA = FALSE;
372 pAd->CommonCfg.REGBACapability.field.AutoBA = FALSE;
374 #endif // DOT11_N_SUPPORT //
375 // Set AdhocMode rates
376 if (pAd->StaCfg.BssType == BSS_ADHOC)
378 MlmeUpdateTxRates(pAd, FALSE, 0);
379 MakeIbssBeacon(pAd); // re-build BEACON frame
380 AsicEnableIbssSync(pAd); // copy to on-chip memory
388 #endif // CONFIG_STA_SUPPORT //
390 // it is needed to set SSID to take effect
393 #ifdef DOT11_N_SUPPORT
395 #endif // DOT11_N_SUPPORT //
396 DBGPRINT(RT_DEBUG_TRACE, ("Set_WirelessMode_Proc::(=%ld)\n", WirelessMode));
400 DBGPRINT(RT_DEBUG_ERROR, ("Set_WirelessMode_Proc::parameters out of range\n"));
407 ==========================================================================
411 TRUE if all parameters are OK, FALSE otherwise
412 ==========================================================================
414 INT Set_Channel_Proc(
415 IN PRTMP_ADAPTER pAd,
421 Channel = (UCHAR) simple_strtol(arg, 0, 10);
423 // check if this channel is valid
424 if (ChannelSanity(pAd, Channel) == TRUE)
426 #ifdef CONFIG_STA_SUPPORT
427 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
429 pAd->CommonCfg.Channel = Channel;
433 #ifdef DOT11_N_SUPPORT
435 if (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED &&
436 pAd->CommonCfg.RegTransmitSetting.field.BW == BW_40)
439 AsicSwitchChannel(pAd, pAd->CommonCfg.CentralChannel, FALSE);
440 AsicLockChannel(pAd, pAd->CommonCfg.CentralChannel);
441 DBGPRINT(RT_DEBUG_TRACE, ("BW_40, control_channel(%d), CentralChannel(%d) \n",
442 pAd->CommonCfg.Channel, pAd->CommonCfg.CentralChannel));
445 #endif // DOT11_N_SUPPORT //
447 AsicSwitchChannel(pAd, pAd->CommonCfg.Channel, FALSE);
448 AsicLockChannel(pAd, pAd->CommonCfg.Channel);
449 DBGPRINT(RT_DEBUG_TRACE, ("BW_20, Channel(%d)\n", pAd->CommonCfg.Channel));
453 #endif // CONFIG_STA_SUPPORT //
459 #ifdef CONFIG_STA_SUPPORT
460 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
462 #endif // CONFIG_STA_SUPPORT //
467 DBGPRINT(RT_DEBUG_TRACE, ("Set_Channel_Proc::(Channel=%d)\n", pAd->CommonCfg.Channel));
473 ==========================================================================
475 Set Short Slot Time Enable or Disable
477 TRUE if all parameters are OK, FALSE otherwise
478 ==========================================================================
480 INT Set_ShortSlot_Proc(
481 IN PRTMP_ADAPTER pAd,
486 ShortSlot = simple_strtol(arg, 0, 10);
489 pAd->CommonCfg.bUseShortSlotTime = TRUE;
490 else if (ShortSlot == 0)
491 pAd->CommonCfg.bUseShortSlotTime = FALSE;
493 return FALSE; //Invalid argument
495 DBGPRINT(RT_DEBUG_TRACE, ("Set_ShortSlot_Proc::(ShortSlot=%d)\n", pAd->CommonCfg.bUseShortSlotTime));
501 ==========================================================================
505 TRUE if all parameters are OK, FALSE otherwise
506 ==========================================================================
508 INT Set_TxPower_Proc(
509 IN PRTMP_ADAPTER pAd,
515 TxPower = (ULONG) simple_strtol(arg, 0, 10);
519 #ifdef CONFIG_STA_SUPPORT
520 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
522 pAd->CommonCfg.TxPowerDefault = TxPower;
523 pAd->CommonCfg.TxPowerPercentage = pAd->CommonCfg.TxPowerDefault;
525 #endif // CONFIG_STA_SUPPORT //
531 DBGPRINT(RT_DEBUG_TRACE, ("Set_TxPower_Proc::(TxPowerPercentage=%ld)\n", pAd->CommonCfg.TxPowerPercentage));
537 ==========================================================================
539 Set 11B/11G Protection
541 TRUE if all parameters are OK, FALSE otherwise
542 ==========================================================================
544 INT Set_BGProtection_Proc(
545 IN PRTMP_ADAPTER pAd,
548 switch (simple_strtol(arg, 0, 10))
551 pAd->CommonCfg.UseBGProtection = 0;
554 pAd->CommonCfg.UseBGProtection = 1;
557 pAd->CommonCfg.UseBGProtection = 2;
559 default: //Invalid argument
564 DBGPRINT(RT_DEBUG_TRACE, ("Set_BGProtection_Proc::(BGProtection=%ld)\n", pAd->CommonCfg.UseBGProtection));
570 ==========================================================================
574 TRUE if all parameters are OK, FALSE otherwise
575 ==========================================================================
577 INT Set_TxPreamble_Proc(
578 IN PRTMP_ADAPTER pAd,
581 RT_802_11_PREAMBLE Preamble;
583 Preamble = simple_strtol(arg, 0, 10);
588 case Rt802_11PreambleShort:
589 pAd->CommonCfg.TxPreamble = Preamble;
590 #ifdef CONFIG_STA_SUPPORT
591 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
592 MlmeSetTxPreamble(pAd, Rt802_11PreambleShort);
593 #endif // CONFIG_STA_SUPPORT //
595 case Rt802_11PreambleLong:
596 #ifdef CONFIG_STA_SUPPORT
597 case Rt802_11PreambleAuto:
598 // if user wants AUTO, initialize to LONG here, then change according to AP's
599 // capability upon association.
600 #endif // CONFIG_STA_SUPPORT //
601 pAd->CommonCfg.TxPreamble = Preamble;
602 #ifdef CONFIG_STA_SUPPORT
603 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
604 MlmeSetTxPreamble(pAd, Rt802_11PreambleLong);
605 #endif // CONFIG_STA_SUPPORT //
607 default: //Invalid argument
611 DBGPRINT(RT_DEBUG_TRACE, ("Set_TxPreamble_Proc::(TxPreamble=%ld)\n", pAd->CommonCfg.TxPreamble));
617 ==========================================================================
621 TRUE if all parameters are OK, FALSE otherwise
622 ==========================================================================
624 INT Set_RTSThreshold_Proc(
625 IN PRTMP_ADAPTER pAd,
628 NDIS_802_11_RTS_THRESHOLD RtsThresh;
630 RtsThresh = simple_strtol(arg, 0, 10);
632 if((RtsThresh > 0) && (RtsThresh <= MAX_RTS_THRESHOLD))
633 pAd->CommonCfg.RtsThreshold = (USHORT)RtsThresh;
634 #ifdef CONFIG_STA_SUPPORT
635 else if (RtsThresh == 0)
636 pAd->CommonCfg.RtsThreshold = MAX_RTS_THRESHOLD;
637 #endif // CONFIG_STA_SUPPORT //
639 return FALSE; //Invalid argument
641 DBGPRINT(RT_DEBUG_TRACE, ("Set_RTSThreshold_Proc::(RTSThreshold=%d)\n", pAd->CommonCfg.RtsThreshold));
647 ==========================================================================
649 Set Fragment Threshold
651 TRUE if all parameters are OK, FALSE otherwise
652 ==========================================================================
654 INT Set_FragThreshold_Proc(
655 IN PRTMP_ADAPTER pAd,
658 NDIS_802_11_FRAGMENTATION_THRESHOLD FragThresh;
660 FragThresh = simple_strtol(arg, 0, 10);
662 if (FragThresh > MAX_FRAG_THRESHOLD || FragThresh < MIN_FRAG_THRESHOLD)
664 //Illegal FragThresh so we set it to default
665 pAd->CommonCfg.FragmentThreshold = MAX_FRAG_THRESHOLD;
667 else if (FragThresh % 2 == 1)
669 // The length of each fragment shall always be an even number of octets, except for the last fragment
670 // of an MSDU or MMPDU, which may be either an even or an odd number of octets.
671 pAd->CommonCfg.FragmentThreshold = (USHORT)(FragThresh - 1);
675 pAd->CommonCfg.FragmentThreshold = (USHORT)FragThresh;
678 #ifdef CONFIG_STA_SUPPORT
679 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
681 if (pAd->CommonCfg.FragmentThreshold == MAX_FRAG_THRESHOLD)
682 pAd->CommonCfg.bUseZeroToDisableFragment = TRUE;
684 pAd->CommonCfg.bUseZeroToDisableFragment = FALSE;
686 #endif // CONFIG_STA_SUPPORT //
688 DBGPRINT(RT_DEBUG_TRACE, ("Set_FragThreshold_Proc::(FragThreshold=%d)\n", pAd->CommonCfg.FragmentThreshold));
694 ==========================================================================
698 TRUE if all parameters are OK, FALSE otherwise
699 ==========================================================================
701 INT Set_TxBurst_Proc(
702 IN PRTMP_ADAPTER pAd,
707 TxBurst = simple_strtol(arg, 0, 10);
709 pAd->CommonCfg.bEnableTxBurst = TRUE;
710 else if (TxBurst == 0)
711 pAd->CommonCfg.bEnableTxBurst = FALSE;
713 return FALSE; //Invalid argument
715 DBGPRINT(RT_DEBUG_TRACE, ("Set_TxBurst_Proc::(TxBurst=%d)\n", pAd->CommonCfg.bEnableTxBurst));
720 #ifdef AGGREGATION_SUPPORT
722 ==========================================================================
726 TRUE if all parameters are OK, FALSE otherwise
727 ==========================================================================
729 INT Set_PktAggregate_Proc(
730 IN PRTMP_ADAPTER pAd,
735 aggre = simple_strtol(arg, 0, 10);
738 pAd->CommonCfg.bAggregationCapable = TRUE;
740 pAd->CommonCfg.bAggregationCapable = FALSE;
742 return FALSE; //Invalid argument
745 DBGPRINT(RT_DEBUG_TRACE, ("Set_PktAggregate_Proc::(AGGRE=%d)\n", pAd->CommonCfg.bAggregationCapable));
752 ==========================================================================
755 This parameter is 1 when needs radar detection, otherwise 0
757 TRUE if all parameters are OK, FALSE otherwise
758 ==========================================================================
760 INT Set_IEEE80211H_Proc(
761 IN PRTMP_ADAPTER pAd,
766 ieee80211h = simple_strtol(arg, 0, 10);
769 pAd->CommonCfg.bIEEE80211H = TRUE;
770 else if (ieee80211h == 0)
771 pAd->CommonCfg.bIEEE80211H = FALSE;
773 return FALSE; //Invalid argument
775 DBGPRINT(RT_DEBUG_TRACE, ("Set_IEEE80211H_Proc::(IEEE80211H=%d)\n", pAd->CommonCfg.bIEEE80211H));
783 ==========================================================================
785 For Debug information
787 TRUE if all parameters are OK, FALSE otherwise
788 ==========================================================================
791 IN PRTMP_ADAPTER pAd,
794 DBGPRINT(RT_DEBUG_TRACE, ("==> Set_Debug_Proc *******************\n"));
796 if(simple_strtol(arg, 0, 10) <= RT_DEBUG_LOUD)
797 RTDebugLevel = simple_strtol(arg, 0, 10);
799 DBGPRINT(RT_DEBUG_TRACE, ("<== Set_Debug_Proc(RTDebugLevel = %ld)\n", RTDebugLevel));
805 INT Show_DescInfo_Proc(
806 IN PRTMP_ADAPTER pAd,
814 ==========================================================================
816 Reset statistics counter
819 pAdapter Pointer to our adapter
823 TRUE if all parameters are OK, FALSE otherwise
824 ==========================================================================
826 INT Set_ResetStatCounter_Proc(
827 IN PRTMP_ADAPTER pAd,
831 //MAC_TABLE_ENTRY *pEntry;
833 DBGPRINT(RT_DEBUG_TRACE, ("==>Set_ResetStatCounter_Proc\n"));
835 // add the most up-to-date h/w raw counters into software counters
836 NICUpdateRawCounters(pAd);
838 NdisZeroMemory(&pAd->WlanCounters, sizeof(COUNTER_802_11));
839 NdisZeroMemory(&pAd->Counters8023, sizeof(COUNTER_802_3));
840 NdisZeroMemory(&pAd->RalinkCounters, sizeof(COUNTER_RALINK));
842 // Reset HotSpot counter
844 for (i = 0; i < MAX_LEN_OF_MAC_TABLE; i++)
846 pEntry = &pAd->MacTab.Content[i];
848 if ((pEntry->Valid == FALSE) || (pEntry->Sst != SST_ASSOC))
851 pEntry->HSCounter.LastDataPacketTime = 0;
852 pEntry->HSCounter.TotalRxByteCount= 0;
853 pEntry->HSCounter.TotalTxByteCount= 0;
862 ========================================================================
866 In Adhoc WPANONE, bPairwise = 0; KeyIdx = 0;
869 pAd Pointer to our adapter
870 pBuf Pointer to the where the key stored
873 NDIS_SUCCESS Add key successfully
875 IRQL = DISPATCH_LEVEL
879 ========================================================================
881 #if 0 // remove by AlbertY
882 NDIS_STATUS RTMPWPAAddKeyProc(
883 IN PRTMP_ADAPTER pAd,
886 PNDIS_802_11_KEY pKey;
888 // NDIS_STATUS Status;
889 // ULONG offset; // unused variable, snowpin 2006.07.13
891 PUCHAR pTxMic, pRxMic;
892 BOOLEAN bTxKey; // Set the key as transmit key
893 BOOLEAN bPairwise; // Indicate the key is pairwise key
894 BOOLEAN bKeyRSC; // indicate the receive SC set by KeyRSC value.
895 // Otherwise, it will set by the NIC.
896 BOOLEAN bAuthenticator; // indicate key is set by authenticator.
899 pKey = (PNDIS_802_11_KEY) pBuf;
900 KeyIdx = pKey->KeyIndex & 0xff;
901 // Bit 31 of Add-key, Tx Key
902 bTxKey = (pKey->KeyIndex & 0x80000000) ? TRUE : FALSE;
903 // Bit 30 of Add-key PairwiseKey
904 bPairwise = (pKey->KeyIndex & 0x40000000) ? TRUE : FALSE;
905 // Bit 29 of Add-key KeyRSC
906 bKeyRSC = (pKey->KeyIndex & 0x20000000) ? TRUE : FALSE;
907 // Bit 28 of Add-key Authenticator
908 bAuthenticator = (pKey->KeyIndex & 0x10000000) ? TRUE : FALSE;
910 DBGPRINT(RT_DEBUG_TRACE,("RTMPWPAAddKeyProc==>pKey->KeyIndex = %x. bPairwise= %d\n", pKey->KeyIndex, bPairwise));
911 // 1. Check Group / Pairwise Key
912 if (bPairwise) // Pairwise Key
914 // 1. KeyIdx must be 0, otherwise, return NDIS_STATUS_INVALID_DATA
916 return(NDIS_STATUS_INVALID_DATA);
918 // 2. Check bTx, it must be true, otherwise, return NDIS_STATUS_INVALID_DATA
920 return(NDIS_STATUS_INVALID_DATA);
922 // 3. If BSSID is all 0xff, return NDIS_STATUS_INVALID_DATA
923 if (MAC_ADDR_EQUAL(pKey->BSSID, BROADCAST_ADDR))
924 return(NDIS_STATUS_INVALID_DATA);
926 // 3.1 Check Pairwise key length for TKIP key. For AES, it's always 128 bits
927 //if ((pAdapter->PortCfg.WepStatus == Ndis802_11Encryption2Enabled) && (pKey->KeyLength != LEN_TKIP_KEY))
928 if ((pAd->StaCfg.PairCipher == Ndis802_11Encryption2Enabled) && (pKey->KeyLength != LEN_TKIP_KEY))
929 return(NDIS_STATUS_INVALID_DATA);
931 pAd->SharedKey[apidx][KeyIdx].Type = PAIRWISE_KEY;
933 if (pAd->ApCfg.MBSSID[apidx].AuthMode == Ndis802_11AuthModeWPA2)
935 // Send media specific event to start PMKID caching
936 RTMPIndicateWPA2Status(pAd);
941 // 1. Check BSSID, if not current BSSID or Bcast, return NDIS_STATUS_INVALID_DATA
942 if ((! MAC_ADDR_EQUAL(pKey->BSSID, BROADCAST_ADDR)) &&
943 (! MAC_ADDR_EQUAL(pKey->BSSID, pAd->ApCfg.MBSSID[apidx].Bssid)))
944 return(NDIS_STATUS_INVALID_DATA);
946 // 2. Check Key index for supported Group Key
947 if (KeyIdx >= GROUP_KEY_NUM)
948 return(NDIS_STATUS_INVALID_DATA);
950 // 3. Set as default Tx Key if bTxKey is TRUE
952 pAd->ApCfg.MBSSID[apidx].DefaultKeyId = (UCHAR) KeyIdx;
954 pAd->SharedKey[apidx][KeyIdx].Type = GROUP_KEY;
957 // 4. Select RxMic / TxMic based on Supp / Authenticator
958 if (pAd->ApCfg.MBSSID[apidx].AuthMode == Ndis802_11AuthModeWPANone)
960 // for WPA-None Tx, Rx MIC is the same
961 pTxMic = (PUCHAR) (&pKey->KeyMaterial) + 16;
964 else if (bAuthenticator == TRUE)
966 pTxMic = (PUCHAR) (&pKey->KeyMaterial) + 16;
967 pRxMic = (PUCHAR) (&pKey->KeyMaterial) + 24;
971 pRxMic = (PUCHAR) (&pKey->KeyMaterial) + 16;
972 pTxMic = (PUCHAR) (&pKey->KeyMaterial) + 24;
978 NdisMoveMemory(pAd->SharedKey[apidx][KeyIdx].RxTsc, &pKey->KeyRSC, 6);
979 NdisMoveMemory(pAd->MacTab.Content[BSSID_WCID].PairwiseKey.RxTsc, &pKey->KeyRSC, 6);
983 NdisZeroMemory(pAd->SharedKey[apidx][KeyIdx].RxTsc, 6);
986 // 7. Copy information into Pairwise Key structure.
987 // pKey->KeyLength will include TxMic and RxMic, therefore, we use 16 bytes hardcoded.
988 pAd->SharedKey[apidx][KeyIdx].KeyLen = (UCHAR) pKey->KeyLength;
989 pAd->MacTab.Content[BSSID_WCID].PairwiseKey.KeyLen = (UCHAR)pKey->KeyLength;
990 NdisMoveMemory(pAd->SharedKey[BSS0][KeyIdx].Key, &pKey->KeyMaterial, 16);
991 NdisMoveMemory(pAd->MacTab.Content[BSSID_WCID].PairwiseKey.Key, &pKey->KeyMaterial, 16);
992 if (pKey->KeyLength == LEN_TKIP_KEY)
994 // Only Key lenth equal to TKIP key have these
995 NdisMoveMemory(pAd->SharedKey[apidx][KeyIdx].RxMic, pRxMic, 8);
996 NdisMoveMemory(pAd->SharedKey[apidx][KeyIdx].TxMic, pTxMic, 8);
997 NdisMoveMemory(pAd->MacTab.Content[BSSID_WCID].PairwiseKey.RxMic, pRxMic, 8);
998 NdisMoveMemory(pAd->MacTab.Content[BSSID_WCID].PairwiseKey.TxMic, pTxMic, 8);
1001 COPY_MAC_ADDR(pAd->SharedKey[BSS0][KeyIdx].BssId, pKey->BSSID);
1003 // Init TxTsc to one based on WiFi WPA specs
1004 pAd->SharedKey[apidx][KeyIdx].TxTsc[0] = 1;
1005 pAd->SharedKey[apidx][KeyIdx].TxTsc[1] = 0;
1006 pAd->SharedKey[apidx][KeyIdx].TxTsc[2] = 0;
1007 pAd->SharedKey[apidx][KeyIdx].TxTsc[3] = 0;
1008 pAd->SharedKey[apidx][KeyIdx].TxTsc[4] = 0;
1009 pAd->SharedKey[apidx][KeyIdx].TxTsc[5] = 0;
1010 // 4. Init TxTsc to one based on WiFi WPA specs
1011 pAd->MacTab.Content[BSSID_WCID].PairwiseKey.TxTsc[0] = 1;
1012 pAd->MacTab.Content[BSSID_WCID].PairwiseKey.TxTsc[1] = 0;
1013 pAd->MacTab.Content[BSSID_WCID].PairwiseKey.TxTsc[2] = 0;
1014 pAd->MacTab.Content[BSSID_WCID].PairwiseKey.TxTsc[3] = 0;
1015 pAd->MacTab.Content[BSSID_WCID].PairwiseKey.TxTsc[4] = 0;
1016 pAd->MacTab.Content[BSSID_WCID].PairwiseKey.TxTsc[5] = 0;
1018 if (pAd->ApCfg.MBSSID[apidx].WepStatus == Ndis802_11Encryption3Enabled)
1020 pAd->SharedKey[apidx][KeyIdx].CipherAlg = CIPHER_AES;
1021 pAd->MacTab.Content[BSSID_WCID].PairwiseKey.CipherAlg = CIPHER_AES;
1023 else if (pAd->ApCfg.MBSSID[apidx].WepStatus == Ndis802_11Encryption2Enabled)
1025 pAd->SharedKey[apidx][KeyIdx].CipherAlg = CIPHER_TKIP;
1026 pAd->MacTab.Content[BSSID_WCID].PairwiseKey.CipherAlg = CIPHER_TKIP;
1028 else if (pAd->ApCfg.MBSSID[apidx].WepStatus == Ndis802_11Encryption1Enabled)
1030 if (pAd->SharedKey[apidx][KeyIdx].KeyLen == 5)
1032 pAd->SharedKey[apidx][KeyIdx].CipherAlg = CIPHER_WEP64;
1033 pAd->MacTab.Content[BSSID_WCID].PairwiseKey.CipherAlg = CIPHER_WEP64;
1035 else if (pAd->SharedKey[apidx][KeyIdx].KeyLen == 13)
1037 pAd->SharedKey[apidx][KeyIdx].CipherAlg = CIPHER_WEP128;
1038 pAd->MacTab.Content[BSSID_WCID].PairwiseKey.CipherAlg = CIPHER_WEP128;
1042 pAd->SharedKey[apidx][KeyIdx].CipherAlg = CIPHER_NONE;
1043 pAd->MacTab.Content[BSSID_WCID].PairwiseKey.CipherAlg = CIPHER_NONE;
1048 pAd->SharedKey[apidx][KeyIdx].CipherAlg = CIPHER_NONE;
1049 pAd->MacTab.Content[BSSID_WCID].PairwiseKey.CipherAlg = CIPHER_NONE;
1052 if ((pAd->OpMode == OPMODE_STA)) // Pairwise Key. Add BSSID to WCTable
1054 pAd->MacTab.Content[BSSID_WCID].PairwiseKey.CipherAlg = pAd->SharedKey[BSS0][KeyIdx].CipherAlg;
1055 pAd->MacTab.Content[BSSID_WCID].PairwiseKey.KeyLen = pAd->SharedKey[BSS0][KeyIdx].KeyLen;
1058 if ((pAd->ApCfg.MBSSID[apidx].AuthMode == Ndis802_11AuthModeWPA2) ||
1059 (pAd->ApCfg.MBSSID[apidx].AuthMode == Ndis802_11AuthModeWPA2PSK))
1062 // On WPA2, Update Group Key Cipher.
1066 if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption3Enabled)
1067 pAd->SharedKey[apidx][KeyIdx].CipherAlg = CIPHER_AES;
1068 else if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption2Enabled)
1069 pAd->SharedKey[apidx][KeyIdx].CipherAlg = CIPHER_TKIP;
1073 DBGPRINT(RT_DEBUG_TRACE, ("pAd->SharedKey[%d][%d].CipherAlg = %d\n", apidx, KeyIdx, pAd->SharedKey[apidx][KeyIdx].CipherAlg));
1076 DBGPRINT_RAW(RT_DEBUG_TRACE, ("%s Key #%d", CipherName[pAd->SharedKey[apidx][KeyIdx].CipherAlg],KeyIdx));
1077 for (i = 0; i < 16; i++)
1079 DBGPRINT_RAW(RT_DEBUG_TRACE, ("%02x:", pAd->SharedKey[apidx][KeyIdx].Key[i]));
1081 DBGPRINT_RAW(RT_DEBUG_TRACE, ("\n Rx MIC Key = "));
1082 for (i = 0; i < 8; i++)
1084 DBGPRINT_RAW(RT_DEBUG_TRACE, ("%02x:", pAd->SharedKey[apidx][KeyIdx].RxMic[i]));
1086 DBGPRINT_RAW(RT_DEBUG_TRACE, ("\n Tx MIC Key = "));
1087 for (i = 0; i < 8; i++)
1089 DBGPRINT_RAW(RT_DEBUG_TRACE, ("%02x:", pAd->SharedKey[apidx][KeyIdx].TxMic[i]));
1091 DBGPRINT_RAW(RT_DEBUG_TRACE, ("\n RxTSC = "));
1092 for (i = 0; i < 6; i++)
1094 DBGPRINT_RAW(RT_DEBUG_TRACE, ("%02x:", pAd->SharedKey[apidx][KeyIdx].RxTsc[i]));
1097 DBGPRINT_RAW(RT_DEBUG_TRACE, ("\n pKey-> BSSID:%02x:%02x:%02x:%02x:%02x:%02x \n",
1098 pKey->BSSID[0],pKey->BSSID[1],pKey->BSSID[2],pKey->BSSID[3],pKey->BSSID[4],pKey->BSSID[5]));
1100 if ((bTxKey) && (pAd->OpMode == OPMODE_STA)) // Pairwise Key. Add BSSID to WCTable
1101 RTMPAddBSSIDCipher(pAd, BSSID_WCID, pKey, pAd->SharedKey[BSS0][KeyIdx].CipherAlg);
1104 // No matter pairwise key or what leyidx is, always has a copy at on-chip SharedKeytable.
1105 AsicAddSharedKeyEntry(pAd,
1108 pAd->SharedKey[apidx][KeyIdx].CipherAlg,
1109 pAd->SharedKey[apidx][KeyIdx].Key,
1110 pAd->SharedKey[apidx][KeyIdx].TxMic,
1111 pAd->SharedKey[apidx][KeyIdx].RxMic);
1113 // The WCID key specified in used at Tx. For STA, always use pairwise key.
1115 // ad-hoc mode need to specify WAP Group key with WCID index=BSS0Mcast_WCID. Let's always set this key here.
1116 /* if (bPairwise == FALSE)
1118 offset = MAC_IVEIV_TABLE_BASE + (BSS0Mcast_WCID * HW_IVEIV_ENTRY_SIZE);
1119 NdisZeroMemory(IVEIV, 8);
1121 // Specify key index to find shared key.
1122 if ((pAd->SharedKey[BSS0][KeyIdx].CipherAlg==CIPHER_TKIP) ||
1123 (pAd->SharedKey[BSS0][KeyIdx].CipherAlg==CIPHER_AES))
1124 IVEIV[3] = 0x20; // Eiv bit on. keyid always 0 for pairwise key
1125 IVEIV[3] |= (KeyIdx<< 6); // groupkey index is not 0
1128 RTMP_IO_WRITE8(pAd, offset+i, IVEIV[i]);
1131 // 2. WCID Attribute UDF:3, BSSIdx:3, Alg:3, Keytable:use share key, BSSIdx is 0
1132 WCIDAttri = (pAd->SharedKey[BSS0][KeyIdx].CipherAlg<<1)|PAIRWISEKEYTABLE;
1133 offset = MAC_WCID_ATTRIBUTE_BASE + (BSS0Mcast_WCID* HW_WCID_ATTRI_SIZE);
1134 RTMP_IO_WRITE32(pAd, offset, WCIDAttri);
1140 if (pAd->SharedKey[apidx][KeyIdx].Type == GROUP_KEY)
1142 // 802.1x port control
1143 pAd->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
1144 DBGPRINT(RT_DEBUG_TRACE,("!!WPA_802_1X_PORT_SECURED!!\n"));
1148 return (NDIS_STATUS_SUCCESS);
1152 BOOLEAN RTMPCheckStrPrintAble(
1158 for (i=0; i<strLen; i++)
1160 if ((pInPutStr[i] < 0x21) ||
1161 (pInPutStr[i] > 0x7E))
1169 ========================================================================
1171 Routine Description:
1172 Remove WPA Key process
1175 pAd Pointer to our adapter
1176 pBuf Pointer to the where the key stored
1179 NDIS_SUCCESS Add key successfully
1181 IRQL = DISPATCH_LEVEL
1185 ========================================================================
1187 #ifdef CONFIG_STA_SUPPORT
1188 VOID RTMPSetDesiredRates(
1189 IN PRTMP_ADAPTER pAdapter,
1192 NDIS_802_11_RATES aryRates;
1194 memset(&aryRates, 0x00, sizeof(NDIS_802_11_RATES));
1195 switch (pAdapter->CommonCfg.PhyMode)
1197 case PHY_11A: // A only
1201 aryRates[0] = 0x0c; // 6M
1202 pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_0;
1205 aryRates[0] = 0x12; // 9M
1206 pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_1;
1208 case 12000000: //12M
1209 aryRates[0] = 0x18; // 12M
1210 pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_2;
1212 case 18000000: //18M
1213 aryRates[0] = 0x24; // 18M
1214 pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_3;
1216 case 24000000: //24M
1217 aryRates[0] = 0x30; // 24M
1218 pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_4;
1220 case 36000000: //36M
1221 aryRates[0] = 0x48; // 36M
1222 pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_5;
1224 case 48000000: //48M
1225 aryRates[0] = 0x60; // 48M
1226 pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_6;
1228 case 54000000: //54M
1229 aryRates[0] = 0x6c; // 54M
1230 pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_7;
1234 aryRates[0] = 0x6c; // 54Mbps
1235 aryRates[1] = 0x60; // 48Mbps
1236 aryRates[2] = 0x48; // 36Mbps
1237 aryRates[3] = 0x30; // 24Mbps
1238 aryRates[4] = 0x24; // 18M
1239 aryRates[5] = 0x18; // 12M
1240 aryRates[6] = 0x12; // 9M
1241 aryRates[7] = 0x0c; // 6M
1242 pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_AUTO;
1246 case PHY_11BG_MIXED: // B/G Mixed
1247 case PHY_11B: // B only
1248 case PHY_11ABG_MIXED: // A/B/G Mixed
1254 pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_0;
1258 pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_1;
1260 case 5000000: //5.5M
1261 aryRates[0] = 0x0b; // 5.5M
1262 pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_2;
1264 case 11000000: //11M
1265 aryRates[0] = 0x16; // 11M
1266 pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_3;
1269 aryRates[0] = 0x0c; // 6M
1270 pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_0;
1273 aryRates[0] = 0x12; // 9M
1274 pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_1;
1276 case 12000000: //12M
1277 aryRates[0] = 0x18; // 12M
1278 pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_2;
1280 case 18000000: //18M
1281 aryRates[0] = 0x24; // 18M
1282 pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_3;
1284 case 24000000: //24M
1285 aryRates[0] = 0x30; // 24M
1286 pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_4;
1288 case 36000000: //36M
1289 aryRates[0] = 0x48; // 36M
1290 pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_5;
1292 case 48000000: //48M
1293 aryRates[0] = 0x60; // 48M
1294 pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_6;
1296 case 54000000: //54M
1297 aryRates[0] = 0x6c; // 54M
1298 pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_7;
1302 if (pAdapter->CommonCfg.PhyMode == PHY_11B)
1304 aryRates[0] = 0x16; // 11Mbps
1305 aryRates[1] = 0x0b; // 5.5Mbps
1306 aryRates[2] = 0x04; // 2Mbps
1307 aryRates[3] = 0x02; // 1Mbps
1310 { //(B/G) Mixed or (A/B/G) Mixed
1311 aryRates[0] = 0x6c; // 54Mbps
1312 aryRates[1] = 0x60; // 48Mbps
1313 aryRates[2] = 0x48; // 36Mbps
1314 aryRates[3] = 0x30; // 24Mbps
1315 aryRates[4] = 0x16; // 11Mbps
1316 aryRates[5] = 0x0b; // 5.5Mbps
1317 aryRates[6] = 0x04; // 2Mbps
1318 aryRates[7] = 0x02; // 1Mbps
1320 pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_AUTO;
1326 NdisZeroMemory(pAdapter->CommonCfg.DesireRate, MAX_LEN_OF_SUPPORTED_RATES);
1327 NdisMoveMemory(pAdapter->CommonCfg.DesireRate, &aryRates, sizeof(NDIS_802_11_RATES));
1328 DBGPRINT(RT_DEBUG_TRACE, (" RTMPSetDesiredRates (%02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x)\n",
1329 pAdapter->CommonCfg.DesireRate[0],pAdapter->CommonCfg.DesireRate[1],
1330 pAdapter->CommonCfg.DesireRate[2],pAdapter->CommonCfg.DesireRate[3],
1331 pAdapter->CommonCfg.DesireRate[4],pAdapter->CommonCfg.DesireRate[5],
1332 pAdapter->CommonCfg.DesireRate[6],pAdapter->CommonCfg.DesireRate[7] ));
1333 // Changing DesiredRate may affect the MAX TX rate we used to TX frames out
1334 MlmeUpdateTxRates(pAdapter, FALSE, 0);
1337 NDIS_STATUS RTMPWPARemoveKeyProc(
1338 IN PRTMP_ADAPTER pAd,
1341 PNDIS_802_11_REMOVE_KEY pKey;
1343 NDIS_STATUS Status = NDIS_STATUS_FAILURE;
1344 BOOLEAN bTxKey; // Set the key as transmit key
1345 BOOLEAN bPairwise; // Indicate the key is pairwise key
1346 BOOLEAN bKeyRSC; // indicate the receive SC set by KeyRSC value.
1347 // Otherwise, it will set by the NIC.
1348 BOOLEAN bAuthenticator; // indicate key is set by authenticator.
1351 DBGPRINT(RT_DEBUG_TRACE,("---> RTMPWPARemoveKeyProc\n"));
1353 pKey = (PNDIS_802_11_REMOVE_KEY) pBuf;
1354 KeyIdx = pKey->KeyIndex & 0xff;
1355 // Bit 31 of Add-key, Tx Key
1356 bTxKey = (pKey->KeyIndex & 0x80000000) ? TRUE : FALSE;
1357 // Bit 30 of Add-key PairwiseKey
1358 bPairwise = (pKey->KeyIndex & 0x40000000) ? TRUE : FALSE;
1359 // Bit 29 of Add-key KeyRSC
1360 bKeyRSC = (pKey->KeyIndex & 0x20000000) ? TRUE : FALSE;
1361 // Bit 28 of Add-key Authenticator
1362 bAuthenticator = (pKey->KeyIndex & 0x10000000) ? TRUE : FALSE;
1364 // 1. If bTx is TRUE, return failure information
1366 return(NDIS_STATUS_INVALID_DATA);
1368 // 2. Check Pairwise Key
1371 // a. If BSSID is broadcast, remove all pairwise keys.
1372 // b. If not broadcast, remove the pairwise specified by BSSID
1373 for (i = 0; i < SHARE_KEY_NUM; i++)
1375 if (MAC_ADDR_EQUAL(pAd->SharedKey[BSS0][i].BssId, pKey->BSSID))
1377 DBGPRINT(RT_DEBUG_TRACE,("RTMPWPARemoveKeyProc(KeyIdx=%d)\n", i));
1378 pAd->SharedKey[BSS0][i].KeyLen = 0;
1379 pAd->SharedKey[BSS0][i].CipherAlg = CIPHER_NONE;
1380 AsicRemoveSharedKeyEntry(pAd, BSS0, (UCHAR)i);
1381 Status = NDIS_STATUS_SUCCESS;
1389 // a. If BSSID is broadcast, remove all group keys indexed
1390 // b. If BSSID matched, delete the group key indexed.
1391 DBGPRINT(RT_DEBUG_TRACE,("RTMPWPARemoveKeyProc(KeyIdx=%ld)\n", KeyIdx));
1392 pAd->SharedKey[BSS0][KeyIdx].KeyLen = 0;
1393 pAd->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_NONE;
1394 AsicRemoveSharedKeyEntry(pAd, BSS0, (UCHAR)KeyIdx);
1395 Status = NDIS_STATUS_SUCCESS;
1400 #endif // CONFIG_STA_SUPPORT //
1403 #ifdef CONFIG_STA_SUPPORT
1405 ========================================================================
1407 Routine Description:
1411 pAd Pointer to our adapter
1416 IRQL = DISPATCH_LEVEL
1420 ========================================================================
1422 VOID RTMPWPARemoveAllKeys(
1423 IN PRTMP_ADAPTER pAd)
1428 DBGPRINT(RT_DEBUG_TRACE,("RTMPWPARemoveAllKeys(AuthMode=%d, WepStatus=%d)\n", pAd->StaCfg.AuthMode, pAd->StaCfg.WepStatus));
1430 // For WEP/CKIP, there is no need to remove it, since WinXP won't set it again after
1431 // Link up. And it will be replaced if user changed it.
1432 if (pAd->StaCfg.AuthMode < Ndis802_11AuthModeWPA)
1435 // For WPA-None, there is no need to remove it, since WinXP won't set it again after
1436 // Link up. And it will be replaced if user changed it.
1437 if (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPANone)
1440 // set BSSID wcid entry of the Pair-wise Key table as no-security mode
1441 AsicRemovePairwiseKeyEntry(pAd, BSS0, BSSID_WCID);
1443 // set all shared key mode as no-security.
1444 for (i = 0; i < SHARE_KEY_NUM; i++)
1446 DBGPRINT(RT_DEBUG_TRACE,("remove %s key #%d\n", CipherName[pAd->SharedKey[BSS0][i].CipherAlg], i));
1447 NdisZeroMemory(&pAd->SharedKey[BSS0][i], sizeof(CIPHER_KEY));
1449 AsicRemoveSharedKeyEntry(pAd, BSS0, i);
1453 #endif // CONFIG_STA_SUPPORT //
1456 ========================================================================
1457 Routine Description:
1458 Change NIC PHY mode. Re-association may be necessary. possible settings
1459 include - PHY_11B, PHY_11BG_MIXED, PHY_11A, and PHY_11ABG_MIXED
1462 pAd - Pointer to our adapter
1465 IRQL = PASSIVE_LEVEL
1466 IRQL = DISPATCH_LEVEL
1468 ========================================================================
1470 VOID RTMPSetPhyMode(
1471 IN PRTMP_ADAPTER pAd,
1475 // the selected phymode must be supported by the RF IC encoded in E2PROM
1477 // if no change, do nothing
1479 if (pAd->CommonCfg.PhyMode == phymode)
1482 pAd->CommonCfg.PhyMode = (UCHAR)phymode;
1484 DBGPRINT(RT_DEBUG_TRACE,("RTMPSetPhyMode : PhyMode=%d, channel=%d \n", pAd->CommonCfg.PhyMode, pAd->CommonCfg.Channel));
1486 BuildChannelList(pAd);
1488 // sanity check user setting
1489 for (i = 0; i < pAd->ChannelListNum; i++)
1491 if (pAd->CommonCfg.Channel == pAd->ChannelList[i].Channel)
1495 if (i == pAd->ChannelListNum)
1497 #ifdef CONFIG_STA_SUPPORT
1498 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
1499 pAd->CommonCfg.Channel = FirstChannel(pAd);
1500 #endif // CONFIG_STA_SUPPORT //
1501 DBGPRINT(RT_DEBUG_ERROR, ("RTMPSetPhyMode: channel is out of range, use first channel=%d \n", pAd->CommonCfg.Channel));
1504 NdisZeroMemory(pAd->CommonCfg.SupRate, MAX_LEN_OF_SUPPORTED_RATES);
1505 NdisZeroMemory(pAd->CommonCfg.ExtRate, MAX_LEN_OF_SUPPORTED_RATES);
1506 NdisZeroMemory(pAd->CommonCfg.DesireRate, MAX_LEN_OF_SUPPORTED_RATES);
1509 pAd->CommonCfg.SupRate[0] = 0x82; // 1 mbps, in units of 0.5 Mbps, basic rate
1510 pAd->CommonCfg.SupRate[1] = 0x84; // 2 mbps, in units of 0.5 Mbps, basic rate
1511 pAd->CommonCfg.SupRate[2] = 0x8B; // 5.5 mbps, in units of 0.5 Mbps, basic rate
1512 pAd->CommonCfg.SupRate[3] = 0x96; // 11 mbps, in units of 0.5 Mbps, basic rate
1513 pAd->CommonCfg.SupRateLen = 4;
1514 pAd->CommonCfg.ExtRateLen = 0;
1515 pAd->CommonCfg.DesireRate[0] = 2; // 1 mbps, in units of 0.5 Mbps
1516 pAd->CommonCfg.DesireRate[1] = 4; // 2 mbps, in units of 0.5 Mbps
1517 pAd->CommonCfg.DesireRate[2] = 11; // 5.5 mbps, in units of 0.5 Mbps
1518 pAd->CommonCfg.DesireRate[3] = 22; // 11 mbps, in units of 0.5 Mbps
1519 //pAd->CommonCfg.HTPhyMode.field.MODE = MODE_CCK; // This MODE is only FYI. not use
1523 case PHY_11BG_MIXED:
1524 case PHY_11ABG_MIXED:
1525 #ifdef DOT11_N_SUPPORT
1527 case PHY_11ABGN_MIXED:
1528 case PHY_11BGN_MIXED:
1529 case PHY_11GN_MIXED:
1530 #endif // DOT11_N_SUPPORT //
1531 pAd->CommonCfg.SupRate[0] = 0x82; // 1 mbps, in units of 0.5 Mbps, basic rate
1532 pAd->CommonCfg.SupRate[1] = 0x84; // 2 mbps, in units of 0.5 Mbps, basic rate
1533 pAd->CommonCfg.SupRate[2] = 0x8B; // 5.5 mbps, in units of 0.5 Mbps, basic rate
1534 pAd->CommonCfg.SupRate[3] = 0x96; // 11 mbps, in units of 0.5 Mbps, basic rate
1535 pAd->CommonCfg.SupRate[4] = 0x12; // 9 mbps, in units of 0.5 Mbps
1536 pAd->CommonCfg.SupRate[5] = 0x24; // 18 mbps, in units of 0.5 Mbps
1537 pAd->CommonCfg.SupRate[6] = 0x48; // 36 mbps, in units of 0.5 Mbps
1538 pAd->CommonCfg.SupRate[7] = 0x6c; // 54 mbps, in units of 0.5 Mbps
1539 pAd->CommonCfg.SupRateLen = 8;
1540 pAd->CommonCfg.ExtRate[0] = 0x0C; // 6 mbps, in units of 0.5 Mbps
1541 pAd->CommonCfg.ExtRate[1] = 0x18; // 12 mbps, in units of 0.5 Mbps
1542 pAd->CommonCfg.ExtRate[2] = 0x30; // 24 mbps, in units of 0.5 Mbps
1543 pAd->CommonCfg.ExtRate[3] = 0x60; // 48 mbps, in units of 0.5 Mbps
1544 pAd->CommonCfg.ExtRateLen = 4;
1545 pAd->CommonCfg.DesireRate[0] = 2; // 1 mbps, in units of 0.5 Mbps
1546 pAd->CommonCfg.DesireRate[1] = 4; // 2 mbps, in units of 0.5 Mbps
1547 pAd->CommonCfg.DesireRate[2] = 11; // 5.5 mbps, in units of 0.5 Mbps
1548 pAd->CommonCfg.DesireRate[3] = 22; // 11 mbps, in units of 0.5 Mbps
1549 pAd->CommonCfg.DesireRate[4] = 12; // 6 mbps, in units of 0.5 Mbps
1550 pAd->CommonCfg.DesireRate[5] = 18; // 9 mbps, in units of 0.5 Mbps
1551 pAd->CommonCfg.DesireRate[6] = 24; // 12 mbps, in units of 0.5 Mbps
1552 pAd->CommonCfg.DesireRate[7] = 36; // 18 mbps, in units of 0.5 Mbps
1553 pAd->CommonCfg.DesireRate[8] = 48; // 24 mbps, in units of 0.5 Mbps
1554 pAd->CommonCfg.DesireRate[9] = 72; // 36 mbps, in units of 0.5 Mbps
1555 pAd->CommonCfg.DesireRate[10] = 96; // 48 mbps, in units of 0.5 Mbps
1556 pAd->CommonCfg.DesireRate[11] = 108; // 54 mbps, in units of 0.5 Mbps
1560 #ifdef DOT11_N_SUPPORT
1561 case PHY_11AN_MIXED:
1562 case PHY_11AGN_MIXED:
1564 #endif // DOT11_N_SUPPORT //
1565 pAd->CommonCfg.SupRate[0] = 0x8C; // 6 mbps, in units of 0.5 Mbps, basic rate
1566 pAd->CommonCfg.SupRate[1] = 0x12; // 9 mbps, in units of 0.5 Mbps
1567 pAd->CommonCfg.SupRate[2] = 0x98; // 12 mbps, in units of 0.5 Mbps, basic rate
1568 pAd->CommonCfg.SupRate[3] = 0x24; // 18 mbps, in units of 0.5 Mbps
1569 pAd->CommonCfg.SupRate[4] = 0xb0; // 24 mbps, in units of 0.5 Mbps, basic rate
1570 pAd->CommonCfg.SupRate[5] = 0x48; // 36 mbps, in units of 0.5 Mbps
1571 pAd->CommonCfg.SupRate[6] = 0x60; // 48 mbps, in units of 0.5 Mbps
1572 pAd->CommonCfg.SupRate[7] = 0x6c; // 54 mbps, in units of 0.5 Mbps
1573 pAd->CommonCfg.SupRateLen = 8;
1574 pAd->CommonCfg.ExtRateLen = 0;
1575 pAd->CommonCfg.DesireRate[0] = 12; // 6 mbps, in units of 0.5 Mbps
1576 pAd->CommonCfg.DesireRate[1] = 18; // 9 mbps, in units of 0.5 Mbps
1577 pAd->CommonCfg.DesireRate[2] = 24; // 12 mbps, in units of 0.5 Mbps
1578 pAd->CommonCfg.DesireRate[3] = 36; // 18 mbps, in units of 0.5 Mbps
1579 pAd->CommonCfg.DesireRate[4] = 48; // 24 mbps, in units of 0.5 Mbps
1580 pAd->CommonCfg.DesireRate[5] = 72; // 36 mbps, in units of 0.5 Mbps
1581 pAd->CommonCfg.DesireRate[6] = 96; // 48 mbps, in units of 0.5 Mbps
1582 pAd->CommonCfg.DesireRate[7] = 108; // 54 mbps, in units of 0.5 Mbps
1583 //pAd->CommonCfg.HTPhyMode.field.MODE = MODE_OFDM; // This MODE is only FYI. not use
1591 pAd->CommonCfg.BandState = UNKNOWN_BAND;
1595 #ifdef DOT11_N_SUPPORT
1597 ========================================================================
1598 Routine Description:
1599 Caller ensures we has 802.11n support.
1600 Calls at setting HT from AP/STASetinformation
1603 pAd - Pointer to our adapter
1606 ========================================================================
1609 IN PRTMP_ADAPTER pAd,
1610 IN OID_SET_HT_PHYMODE *pHTPhyMode)
1615 UCHAR BBP3Value = 0;
1616 UCHAR RxStream = pAd->CommonCfg.RxStream;
1618 DBGPRINT(RT_DEBUG_TRACE, ("RTMPSetHT : HT_mode(%d), ExtOffset(%d), MCS(%d), BW(%d), STBC(%d), SHORTGI(%d)\n",
1619 pHTPhyMode->HtMode, pHTPhyMode->ExtOffset,
1620 pHTPhyMode->MCS, pHTPhyMode->BW,
1621 pHTPhyMode->STBC, pHTPhyMode->SHORTGI));
1623 // Don't zero supportedHyPhy structure.
1624 RTMPZeroMemory(&pAd->CommonCfg.HtCapability, sizeof(pAd->CommonCfg.HtCapability));
1625 RTMPZeroMemory(&pAd->CommonCfg.AddHTInfo, sizeof(pAd->CommonCfg.AddHTInfo));
1626 RTMPZeroMemory(&pAd->CommonCfg.NewExtChanOffset, sizeof(pAd->CommonCfg.NewExtChanOffset));
1627 RTMPZeroMemory(&pAd->CommonCfg.DesiredHtPhy, sizeof(pAd->CommonCfg.DesiredHtPhy));
1629 if (pAd->CommonCfg.bRdg)
1631 pAd->CommonCfg.HtCapability.ExtHtCapInfo.PlusHTC = 1;
1632 pAd->CommonCfg.HtCapability.ExtHtCapInfo.RDGSupport = 1;
1636 pAd->CommonCfg.HtCapability.ExtHtCapInfo.PlusHTC = 0;
1637 pAd->CommonCfg.HtCapability.ExtHtCapInfo.RDGSupport = 0;
1640 pAd->CommonCfg.HtCapability.HtCapParm.MaxRAmpduFactor = 3;
1641 pAd->CommonCfg.DesiredHtPhy.MaxRAmpduFactor = 3;
1643 DBGPRINT(RT_DEBUG_TRACE, ("RTMPSetHT : RxBAWinLimit = %d\n", pAd->CommonCfg.BACapability.field.RxBAWinLimit));
1645 // Mimo power save, A-MSDU size,
1646 pAd->CommonCfg.DesiredHtPhy.AmsduEnable = (USHORT)pAd->CommonCfg.BACapability.field.AmsduEnable;
1647 pAd->CommonCfg.DesiredHtPhy.AmsduSize = (UCHAR)pAd->CommonCfg.BACapability.field.AmsduSize;
1648 pAd->CommonCfg.DesiredHtPhy.MimoPs = (UCHAR)pAd->CommonCfg.BACapability.field.MMPSmode;
1649 pAd->CommonCfg.DesiredHtPhy.MpduDensity = (UCHAR)pAd->CommonCfg.BACapability.field.MpduDensity;
1651 pAd->CommonCfg.HtCapability.HtCapInfo.AMsduSize = (USHORT)pAd->CommonCfg.BACapability.field.AmsduSize;
1652 pAd->CommonCfg.HtCapability.HtCapInfo.MimoPs = (USHORT)pAd->CommonCfg.BACapability.field.MMPSmode;
1653 pAd->CommonCfg.HtCapability.HtCapParm.MpduDensity = (UCHAR)pAd->CommonCfg.BACapability.field.MpduDensity;
1655 DBGPRINT(RT_DEBUG_TRACE, ("RTMPSetHT : AMsduSize = %d, MimoPs = %d, MpduDensity = %d, MaxRAmpduFactor = %d\n",
1656 pAd->CommonCfg.DesiredHtPhy.AmsduSize,
1657 pAd->CommonCfg.DesiredHtPhy.MimoPs,
1658 pAd->CommonCfg.DesiredHtPhy.MpduDensity,
1659 pAd->CommonCfg.DesiredHtPhy.MaxRAmpduFactor));
1661 if(pHTPhyMode->HtMode == HTMODE_GF)
1663 pAd->CommonCfg.HtCapability.HtCapInfo.GF = 1;
1664 pAd->CommonCfg.DesiredHtPhy.GF = 1;
1667 pAd->CommonCfg.DesiredHtPhy.GF = 0;
1673 pAd->CommonCfg.HtCapability.MCSSet[0] = 0xff;
1674 pAd->CommonCfg.HtCapability.MCSSet[1] = 0x00;
1678 pAd->CommonCfg.HtCapability.MCSSet[0] = 0xff;
1679 pAd->CommonCfg.HtCapability.MCSSet[1] = 0xff;
1683 pAd->CommonCfg.HtCapability.MCSSet[0] = 0xff;
1684 pAd->CommonCfg.HtCapability.MCSSet[1] = 0xff;
1685 pAd->CommonCfg.HtCapability.MCSSet[2] = 0xff;
1689 if (pAd->CommonCfg.bForty_Mhz_Intolerant && (pAd->CommonCfg.Channel <= 14) && (pHTPhyMode->BW == BW_40) )
1691 pHTPhyMode->BW = BW_20;
1692 pAd->CommonCfg.HtCapability.HtCapInfo.Forty_Mhz_Intolerant = 1;
1695 if(pHTPhyMode->BW == BW_40)
1697 pAd->CommonCfg.HtCapability.MCSSet[4] = 0x1; // MCS 32
1698 pAd->CommonCfg.HtCapability.HtCapInfo.ChannelWidth = 1;
1699 if (pAd->CommonCfg.Channel <= 14)
1700 pAd->CommonCfg.HtCapability.HtCapInfo.CCKmodein40 = 1;
1702 pAd->CommonCfg.DesiredHtPhy.ChannelWidth = 1;
1703 pAd->CommonCfg.AddHTInfo.AddHtInfo.RecomWidth = 1;
1704 pAd->CommonCfg.AddHTInfo.AddHtInfo.ExtChanOffset = (pHTPhyMode->ExtOffset == EXTCHA_BELOW)? (EXTCHA_BELOW): EXTCHA_ABOVE;
1705 // Set Regsiter for extension channel position.
1706 RTMP_IO_READ32(pAd, TX_BAND_CFG, &Value);
1707 RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &BBP3Value);
1708 if ((pHTPhyMode->ExtOffset == EXTCHA_BELOW))
1711 BBP3Value |= (0x20);
1712 RTMP_IO_WRITE32(pAd, TX_BAND_CFG, Value);
1714 else if ((pHTPhyMode->ExtOffset == EXTCHA_ABOVE))
1717 BBP3Value &= (~0x20);
1718 RTMP_IO_WRITE32(pAd, TX_BAND_CFG, Value);
1721 // Turn on BBP 40MHz mode now only as AP .
1722 // Sta can turn on BBP 40MHz after connection with 40MHz AP. Sta only broadcast 40MHz capability before connection.
1723 if ((pAd->OpMode == OPMODE_AP) || INFRA_ON(pAd) || ADHOC_ON(pAd)
1726 RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &BBPValue);
1727 BBPValue &= (~0x18);
1729 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, BBPValue);
1731 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, BBP3Value);
1732 pAd->CommonCfg.BBPCurrentBW = BW_40;
1737 pAd->CommonCfg.HtCapability.HtCapInfo.ChannelWidth = 0;
1738 pAd->CommonCfg.DesiredHtPhy.ChannelWidth = 0;
1739 pAd->CommonCfg.AddHTInfo.AddHtInfo.RecomWidth = 0;
1740 pAd->CommonCfg.AddHTInfo.AddHtInfo.ExtChanOffset = EXTCHA_NONE;
1741 pAd->CommonCfg.CentralChannel = pAd->CommonCfg.Channel;
1742 // Turn on BBP 20MHz mode by request here.
1744 RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &BBPValue);
1745 BBPValue &= (~0x18);
1746 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, BBPValue);
1747 pAd->CommonCfg.BBPCurrentBW = BW_20;
1751 if(pHTPhyMode->STBC == STBC_USE)
1753 pAd->CommonCfg.HtCapability.HtCapInfo.TxSTBC = 1;
1754 pAd->CommonCfg.DesiredHtPhy.TxSTBC = 1;
1755 pAd->CommonCfg.HtCapability.HtCapInfo.RxSTBC = 1;
1756 pAd->CommonCfg.DesiredHtPhy.RxSTBC = 1;
1760 pAd->CommonCfg.DesiredHtPhy.TxSTBC = 0;
1761 pAd->CommonCfg.DesiredHtPhy.RxSTBC = 0;
1765 /* Frank recommend ,If not, Tx maybe block in high power. Rx has no problem*/
1766 if(IS_RT3070(pAd) && ((pAd->RfIcType == RFIC_3020) || (pAd->RfIcType == RFIC_2020)))
1768 pAd->CommonCfg.HtCapability.HtCapInfo.TxSTBC = 0;
1769 pAd->CommonCfg.DesiredHtPhy.TxSTBC = 0;
1773 if(pHTPhyMode->SHORTGI == GI_400)
1775 pAd->CommonCfg.HtCapability.HtCapInfo.ShortGIfor20 = 1;
1776 pAd->CommonCfg.HtCapability.HtCapInfo.ShortGIfor40 = 1;
1777 pAd->CommonCfg.DesiredHtPhy.ShortGIfor20 = 1;
1778 pAd->CommonCfg.DesiredHtPhy.ShortGIfor40 = 1;
1782 pAd->CommonCfg.HtCapability.HtCapInfo.ShortGIfor20 = 0;
1783 pAd->CommonCfg.HtCapability.HtCapInfo.ShortGIfor40 = 0;
1784 pAd->CommonCfg.DesiredHtPhy.ShortGIfor20 = 0;
1785 pAd->CommonCfg.DesiredHtPhy.ShortGIfor40 = 0;
1788 // We support link adaptation for unsolicit MCS feedback, set to 2.
1789 pAd->CommonCfg.HtCapability.ExtHtCapInfo.MCSFeedback = MCSFBK_NONE; //MCSFBK_UNSOLICIT;
1790 pAd->CommonCfg.AddHTInfo.ControlChan = pAd->CommonCfg.Channel;
1791 // 1, the extension channel above the control channel.
1793 // EDCA parameters used for AP's own transmission
1794 if (pAd->CommonCfg.APEdcaParm.bValid == FALSE)
1796 pAd->CommonCfg.APEdcaParm.bValid = TRUE;
1797 pAd->CommonCfg.APEdcaParm.Aifsn[0] = 3;
1798 pAd->CommonCfg.APEdcaParm.Aifsn[1] = 7;
1799 pAd->CommonCfg.APEdcaParm.Aifsn[2] = 1;
1800 pAd->CommonCfg.APEdcaParm.Aifsn[3] = 1;
1802 pAd->CommonCfg.APEdcaParm.Cwmin[0] = 4;
1803 pAd->CommonCfg.APEdcaParm.Cwmin[1] = 4;
1804 pAd->CommonCfg.APEdcaParm.Cwmin[2] = 3;
1805 pAd->CommonCfg.APEdcaParm.Cwmin[3] = 2;
1807 pAd->CommonCfg.APEdcaParm.Cwmax[0] = 6;
1808 pAd->CommonCfg.APEdcaParm.Cwmax[1] = 10;
1809 pAd->CommonCfg.APEdcaParm.Cwmax[2] = 4;
1810 pAd->CommonCfg.APEdcaParm.Cwmax[3] = 3;
1812 pAd->CommonCfg.APEdcaParm.Txop[0] = 0;
1813 pAd->CommonCfg.APEdcaParm.Txop[1] = 0;
1814 pAd->CommonCfg.APEdcaParm.Txop[2] = 94;
1815 pAd->CommonCfg.APEdcaParm.Txop[3] = 47;
1817 AsicSetEdcaParm(pAd, &pAd->CommonCfg.APEdcaParm);
1820 #ifdef CONFIG_STA_SUPPORT
1821 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
1823 RTMPSetIndividualHT(pAd, 0);
1825 #endif // CONFIG_STA_SUPPORT //
1830 ========================================================================
1831 Routine Description:
1832 Caller ensures we has 802.11n support.
1833 Calls at setting HT from AP/STASetinformation
1836 pAd - Pointer to our adapter
1839 ========================================================================
1841 VOID RTMPSetIndividualHT(
1842 IN PRTMP_ADAPTER pAd,
1845 PRT_HT_PHY_INFO pDesired_ht_phy = NULL;
1846 UCHAR TxStream = pAd->CommonCfg.TxStream;
1847 UCHAR DesiredMcs = MCS_AUTO;
1852 #ifdef CONFIG_STA_SUPPORT
1853 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
1855 pDesired_ht_phy = &pAd->StaCfg.DesiredHtPhyInfo;
1856 DesiredMcs = pAd->StaCfg.DesiredTransmitSetting.field.MCS;
1857 //pAd->StaCfg.bAutoTxRateSwitch = (DesiredMcs == MCS_AUTO) ? TRUE : FALSE;
1860 #endif // CONFIG_STA_SUPPORT //
1863 if (pDesired_ht_phy == NULL)
1865 DBGPRINT(RT_DEBUG_ERROR, ("RTMPSetIndividualHT: invalid apidx(%d)\n", apidx));
1868 RTMPZeroMemory(pDesired_ht_phy, sizeof(RT_HT_PHY_INFO));
1870 DBGPRINT(RT_DEBUG_TRACE, ("RTMPSetIndividualHT : Desired MCS = %d\n", DesiredMcs));
1871 // Check the validity of MCS
1872 if ((TxStream == 1) && ((DesiredMcs >= MCS_8) && (DesiredMcs <= MCS_15)))
1874 DBGPRINT(RT_DEBUG_WARN, ("RTMPSetIndividualHT: MCS(%d) is invalid in 1S, reset it as MCS_7\n", DesiredMcs));
1878 if ((pAd->CommonCfg.DesiredHtPhy.ChannelWidth == BW_20) && (DesiredMcs == MCS_32))
1880 DBGPRINT(RT_DEBUG_WARN, ("RTMPSetIndividualHT: MCS_32 is only supported in 40-MHz, reset it as MCS_0\n"));
1884 pDesired_ht_phy->bHtEnable = TRUE;
1886 // Decide desired Tx MCS
1890 if (DesiredMcs == MCS_AUTO)
1892 pDesired_ht_phy->MCSSet[0]= 0xff;
1893 pDesired_ht_phy->MCSSet[1]= 0x00;
1895 else if (DesiredMcs <= MCS_7)
1897 pDesired_ht_phy->MCSSet[0]= 1<<DesiredMcs;
1898 pDesired_ht_phy->MCSSet[1]= 0x00;
1903 if (DesiredMcs == MCS_AUTO)
1905 pDesired_ht_phy->MCSSet[0]= 0xff;
1906 pDesired_ht_phy->MCSSet[1]= 0xff;
1908 else if (DesiredMcs <= MCS_15)
1912 mode = DesiredMcs / 8;
1914 pDesired_ht_phy->MCSSet[mode] = (1 << (DesiredMcs - mode * 8));
1919 if (DesiredMcs == MCS_AUTO)
1921 /* MCS0 ~ MCS23, 3 bytes */
1922 pDesired_ht_phy->MCSSet[0]= 0xff;
1923 pDesired_ht_phy->MCSSet[1]= 0xff;
1924 pDesired_ht_phy->MCSSet[2]= 0xff;
1926 else if (DesiredMcs <= MCS_23)
1930 mode = DesiredMcs / 8;
1932 pDesired_ht_phy->MCSSet[mode] = (1 << (DesiredMcs - mode * 8));
1937 if(pAd->CommonCfg.DesiredHtPhy.ChannelWidth == BW_40)
1939 if (DesiredMcs == MCS_AUTO || DesiredMcs == MCS_32)
1940 pDesired_ht_phy->MCSSet[4] = 0x1;
1943 // update HT Rate setting
1944 if (pAd->OpMode == OPMODE_STA)
1945 MlmeUpdateHtTxRates(pAd, BSS0);
1947 MlmeUpdateHtTxRates(pAd, apidx);
1952 ========================================================================
1953 Routine Description:
1954 Update HT IE from our capability.
1957 Send all HT IE in beacon/probe rsp/assoc rsp/action frame.
1960 ========================================================================
1962 VOID RTMPUpdateHTIE(
1963 IN RT_HT_CAPABILITY *pRtHt,
1965 OUT HT_CAPABILITY_IE *pHtCapability,
1966 OUT ADD_HT_INFO_IE *pAddHtInfo)
1968 RTMPZeroMemory(pHtCapability, sizeof(HT_CAPABILITY_IE));
1969 RTMPZeroMemory(pAddHtInfo, sizeof(ADD_HT_INFO_IE));
1971 pHtCapability->HtCapInfo.ChannelWidth = pRtHt->ChannelWidth;
1972 pHtCapability->HtCapInfo.MimoPs = pRtHt->MimoPs;
1973 pHtCapability->HtCapInfo.GF = pRtHt->GF;
1974 pHtCapability->HtCapInfo.ShortGIfor20 = pRtHt->ShortGIfor20;
1975 pHtCapability->HtCapInfo.ShortGIfor40 = pRtHt->ShortGIfor40;
1976 pHtCapability->HtCapInfo.TxSTBC = pRtHt->TxSTBC;
1977 pHtCapability->HtCapInfo.RxSTBC = pRtHt->RxSTBC;
1978 pHtCapability->HtCapInfo.AMsduSize = pRtHt->AmsduSize;
1979 pHtCapability->HtCapParm.MaxRAmpduFactor = pRtHt->MaxRAmpduFactor;
1980 pHtCapability->HtCapParm.MpduDensity = pRtHt->MpduDensity;
1982 pAddHtInfo->AddHtInfo.ExtChanOffset = pRtHt->ExtChanOffset ;
1983 pAddHtInfo->AddHtInfo.RecomWidth = pRtHt->RecomWidth;
1984 pAddHtInfo->AddHtInfo2.OperaionMode = pRtHt->OperaionMode;
1985 pAddHtInfo->AddHtInfo2.NonGfPresent = pRtHt->NonGfPresent;
1986 RTMPMoveMemory(pAddHtInfo->MCSSet, /*pRtHt->MCSSet*/pMcsSet, 4); // rt2860 only support MCS max=32, no need to copy all 16 uchar.
1988 DBGPRINT(RT_DEBUG_TRACE,("RTMPUpdateHTIE <== \n"));
1990 #endif // DOT11_N_SUPPORT //
1993 ========================================================================
1995 Add Client security information into ASIC WCID table and IVEIV table.
1997 ========================================================================
1999 VOID RTMPAddWcidAttributeEntry(
2000 IN PRTMP_ADAPTER pAd,
2004 IN MAC_TABLE_ENTRY *pEntry)
2006 UINT32 WCIDAttri = 0;
2012 #ifdef CONFIG_STA_SUPPORT
2013 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
2017 DBGPRINT(RT_DEBUG_ERROR, ("RTMPAddWcidAttributeEntry: The BSS-index(%d) is out of range for Infra link. \n", BssIdx));
2021 // 1. In ADHOC mode, the AID is wcid number. And NO mesh link exists.
2022 // 2. In Infra mode, the AID:1 MUST be wcid of infra STA.
2023 // the AID:2~ assign to mesh link entry.
2024 if (pEntry && ADHOC_ON(pAd))
2026 else if (pEntry && INFRA_ON(pAd))
2033 #endif // CONFIG_STA_SUPPORT //
2036 // Update WCID attribute table
2037 offset = MAC_WCID_ATTRIBUTE_BASE + (Wcid * HW_WCID_ATTRI_SIZE);
2039 #ifdef CONFIG_STA_SUPPORT
2040 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
2042 if (pEntry && pEntry->ValidAsMesh)
2043 WCIDAttri = (CipherAlg<<1) | PAIRWISEKEYTABLE;
2045 WCIDAttri = (CipherAlg<<1) | SHAREDKEYTABLE;
2047 #endif // CONFIG_STA_SUPPORT //
2049 RTMP_IO_WRITE32(pAd, offset, WCIDAttri);
2052 // Update IV/EIV table
2053 offset = MAC_IVEIV_TABLE_BASE + (Wcid * HW_IVEIV_ENTRY_SIZE);
2056 if ((CipherAlg == CIPHER_TKIP) || (CipherAlg == CIPHER_TKIP_NO_MIC) || (CipherAlg == CIPHER_AES))
2058 // Eiv bit on. keyid always is 0 for pairwise key
2059 IVEIV = (KeyIdx <<6) | 0x20;
2063 // WEP KeyIdx is default tx key.
2064 IVEIV = (KeyIdx << 6);
2067 // For key index and ext IV bit, so only need to update the position(offset+3).
2069 RTUSBMultiWrite_OneByte(pAd, offset+3, &IVEIV);
2072 DBGPRINT(RT_DEBUG_TRACE,("RTMPAddWcidAttributeEntry: WCID #%d, KeyIndex #%d, Alg=%s\n",Wcid, KeyIdx, CipherName[CipherAlg]));
2073 DBGPRINT(RT_DEBUG_TRACE,(" WCIDAttri = 0x%x \n", WCIDAttri));
2078 ==========================================================================
2080 Parse encryption type
2082 pAdapter Pointer to our adapter
2083 wrq Pointer to the ioctl argument
2089 ==========================================================================
2091 CHAR *GetEncryptType(CHAR enc)
2093 if(enc == Ndis802_11WEPDisabled)
2095 if(enc == Ndis802_11WEPEnabled)
2097 if(enc == Ndis802_11Encryption2Enabled)
2099 if(enc == Ndis802_11Encryption3Enabled)
2101 if(enc == Ndis802_11Encryption4Enabled)
2107 CHAR *GetAuthMode(CHAR auth)
2109 if(auth == Ndis802_11AuthModeOpen)
2111 if(auth == Ndis802_11AuthModeShared)
2113 if(auth == Ndis802_11AuthModeAutoSwitch)
2115 if(auth == Ndis802_11AuthModeWPA)
2117 if(auth == Ndis802_11AuthModeWPAPSK)
2119 if(auth == Ndis802_11AuthModeWPANone)
2121 if(auth == Ndis802_11AuthModeWPA2)
2123 if(auth == Ndis802_11AuthModeWPA2PSK)
2125 if(auth == Ndis802_11AuthModeWPA1WPA2)
2127 if(auth == Ndis802_11AuthModeWPA1PSKWPA2PSK)
2128 return "WPA1PSKWPA2PSK";
2134 ==========================================================================
2136 Get site survey results
2138 pAdapter Pointer to our adapter
2139 wrq Pointer to the ioctl argument
2146 1.) UI needs to wait 4 seconds after issue a site survey command
2147 2.) iwpriv ra0 get_site_survey
2148 3.) UI needs to prepare at least 4096bytes to get the results
2149 ==========================================================================
2151 #define LINE_LEN (4+33+20+8+10+9+7+3) // Channel+SSID+Bssid+WepStatus+AuthMode+Signal+WiressMode+NetworkType
2152 VOID RTMPIoctlGetSiteSurvey(
2153 IN PRTMP_ADAPTER pAdapter,
2154 IN struct iwreq *wrq)
2160 CHAR Ssid[MAX_LEN_OF_SSID +1];
2161 INT Rssi = 0, max_len = LINE_LEN;
2162 UINT Rssi_Quality = 0;
2163 NDIS_802_11_NETWORK_TYPE wireless_mode;
2165 os_alloc_mem(NULL, (PUCHAR *)&msg, sizeof(CHAR)*((MAX_LEN_OF_BSS_TABLE)*max_len));
2169 DBGPRINT(RT_DEBUG_TRACE, ("RTMPIoctlGetSiteSurvey - msg memory alloc fail.\n"));
2173 memset(msg, 0 ,(MAX_LEN_OF_BSS_TABLE)*max_len );
2174 memset(Ssid, 0 ,(MAX_LEN_OF_SSID +1));
2175 sprintf(msg,"%s","\n");
2176 sprintf(msg+strlen(msg),"%-4s%-33s%-20s%-8s%-10s%-9s%-7s%-3s\n",
2177 "Ch", "SSID", "BSSID", "Enc", "Auth", "Siganl(%)", "W-Mode", " NT");
2181 #ifdef CONFIG_STA_SUPPORT
2182 pAdapter->StaCfg.bScanReqIsFromWebUI = TRUE;
2183 while ((ScanRunning(pAdapter) == TRUE) && (WaitCnt++ < 200))
2185 #endif // CONFIG_STA_SUPPORT //
2187 for(i=0; i<pAdapter->ScanTab.BssNr ;i++)
2189 if( pAdapter->ScanTab.BssEntry[i].Channel==0)
2192 if((strlen(msg)+max_len ) >= IW_SCAN_MAX_DATA)
2196 sprintf(msg+strlen(msg),"%-4d", pAdapter->ScanTab.BssEntry[i].Channel);
2198 memcpy(Ssid, pAdapter->ScanTab.BssEntry[i].Ssid, pAdapter->ScanTab.BssEntry[i].SsidLen);
2199 Ssid[pAdapter->ScanTab.BssEntry[i].SsidLen] = '\0';
2200 sprintf(msg+strlen(msg),"%-33s", Ssid);
2202 sprintf(msg+strlen(msg),"%02x:%02x:%02x:%02x:%02x:%02x ",
2203 pAdapter->ScanTab.BssEntry[i].Bssid[0],
2204 pAdapter->ScanTab.BssEntry[i].Bssid[1],
2205 pAdapter->ScanTab.BssEntry[i].Bssid[2],
2206 pAdapter->ScanTab.BssEntry[i].Bssid[3],
2207 pAdapter->ScanTab.BssEntry[i].Bssid[4],
2208 pAdapter->ScanTab.BssEntry[i].Bssid[5]);
2210 sprintf(msg+strlen(msg),"%-8s",GetEncryptType(pAdapter->ScanTab.BssEntry[i].WepStatus));
2211 //Authentication Mode
2212 if (pAdapter->ScanTab.BssEntry[i].WepStatus == Ndis802_11WEPEnabled)
2213 sprintf(msg+strlen(msg),"%-10s", "UNKNOW");
2215 sprintf(msg+strlen(msg),"%-10s",GetAuthMode(pAdapter->ScanTab.BssEntry[i].AuthMode));
2217 Rssi = (INT)pAdapter->ScanTab.BssEntry[i].Rssi;
2220 else if (Rssi >= -80) // between -50 ~ -80dbm
2221 Rssi_Quality = (UINT)(24 + ((Rssi + 80) * 26)/10);
2222 else if (Rssi >= -90) // between -80 ~ -90dbm
2223 Rssi_Quality = (UINT)(((Rssi + 90) * 26)/10);
2226 sprintf(msg+strlen(msg),"%-9d", Rssi_Quality);
2228 wireless_mode = NetworkTypeInUseSanity(&pAdapter->ScanTab.BssEntry[i]);
2229 if (wireless_mode == Ndis802_11FH ||
2230 wireless_mode == Ndis802_11DS)
2231 sprintf(msg+strlen(msg),"%-7s", "11b");
2232 else if (wireless_mode == Ndis802_11OFDM5)
2233 sprintf(msg+strlen(msg),"%-7s", "11a");
2234 else if (wireless_mode == Ndis802_11OFDM5_N)
2235 sprintf(msg+strlen(msg),"%-7s", "11a/n");
2236 else if (wireless_mode == Ndis802_11OFDM24)
2237 sprintf(msg+strlen(msg),"%-7s", "11b/g");
2238 else if (wireless_mode == Ndis802_11OFDM24_N)
2239 sprintf(msg+strlen(msg),"%-7s", "11b/g/n");
2241 sprintf(msg+strlen(msg),"%-7s", "unknow");
2243 if (pAdapter->ScanTab.BssEntry[i].BssType == BSS_ADHOC)
2244 sprintf(msg+strlen(msg),"%-3s", " Ad");
2246 sprintf(msg+strlen(msg),"%-3s", " In");
2248 sprintf(msg+strlen(msg),"\n");
2251 #ifdef CONFIG_STA_SUPPORT
2252 pAdapter->StaCfg.bScanReqIsFromWebUI = FALSE;
2253 #endif // CONFIG_STA_SUPPORT //
2254 wrq->u.data.length = strlen(msg);
2255 Status = copy_to_user(wrq->u.data.pointer, msg, wrq->u.data.length);
2257 DBGPRINT(RT_DEBUG_TRACE, ("RTMPIoctlGetSiteSurvey - wrq->u.data.length = %d\n", wrq->u.data.length));
2258 os_free_mem(NULL, (PUCHAR)msg);
2262 #define MAC_LINE_LEN (14+4+4+10+10+10+6+6) // Addr+aid+psm+datatime+rxbyte+txbyte+current tx rate+last tx rate
2263 VOID RTMPIoctlGetMacTable(
2264 IN PRTMP_ADAPTER pAd,
2265 IN struct iwreq *wrq)
2268 RT_802_11_MAC_TABLE MacTab;
2272 for (i=0; i<MAX_LEN_OF_MAC_TABLE; i++)
2274 if (pAd->MacTab.Content[i].ValidAsCLI && (pAd->MacTab.Content[i].Sst == SST_ASSOC))
2276 COPY_MAC_ADDR(MacTab.Entry[MacTab.Num].Addr, &pAd->MacTab.Content[i].Addr);
2277 MacTab.Entry[MacTab.Num].Aid = (UCHAR)pAd->MacTab.Content[i].Aid;
2278 MacTab.Entry[MacTab.Num].Psm = pAd->MacTab.Content[i].PsMode;
2279 #ifdef DOT11_N_SUPPORT
2280 MacTab.Entry[MacTab.Num].MimoPs = pAd->MacTab.Content[i].MmpsMode;
2281 #endif // DOT11_N_SUPPORT //
2283 // Fill in RSSI per entry
2284 MacTab.Entry[MacTab.Num].AvgRssi0 = pAd->MacTab.Content[i].RssiSample.AvgRssi0;
2285 MacTab.Entry[MacTab.Num].AvgRssi1 = pAd->MacTab.Content[i].RssiSample.AvgRssi1;
2286 MacTab.Entry[MacTab.Num].AvgRssi2 = pAd->MacTab.Content[i].RssiSample.AvgRssi2;
2288 // the connected time per entry
2289 MacTab.Entry[MacTab.Num].ConnectedTime = pAd->MacTab.Content[i].StaConnectTime;
2291 MacTab.Entry[MacTab.Num].HSCounter.LastDataPacketTime = pAd->MacTab.Content[i].HSCounter.LastDataPacketTime;
2292 MacTab.Entry[MacTab.Num].HSCounter.TotalRxByteCount = pAd->MacTab.Content[i].HSCounter.TotalRxByteCount;
2293 MacTab.Entry[MacTab.Num].HSCounter.TotalTxByteCount = pAd->MacTab.Content[i].HSCounter.TotalTxByteCount;
2295 MacTab.Entry[MacTab.Num].TxRate.field.MCS = pAd->MacTab.Content[i].HTPhyMode.field.MCS;
2296 MacTab.Entry[MacTab.Num].TxRate.field.BW = pAd->MacTab.Content[i].HTPhyMode.field.BW;
2297 MacTab.Entry[MacTab.Num].TxRate.field.ShortGI = pAd->MacTab.Content[i].HTPhyMode.field.ShortGI;
2298 MacTab.Entry[MacTab.Num].TxRate.field.STBC = pAd->MacTab.Content[i].HTPhyMode.field.STBC;
2299 MacTab.Entry[MacTab.Num].TxRate.field.rsv = pAd->MacTab.Content[i].HTPhyMode.field.rsv;
2300 MacTab.Entry[MacTab.Num].TxRate.field.MODE = pAd->MacTab.Content[i].HTPhyMode.field.MODE;
2301 MacTab.Entry[MacTab.Num].TxRate.word = pAd->MacTab.Content[i].HTPhyMode.word;
2306 wrq->u.data.length = sizeof(RT_802_11_MAC_TABLE);
2307 if (copy_to_user(wrq->u.data.pointer, &MacTab, wrq->u.data.length))
2309 DBGPRINT(RT_DEBUG_TRACE, ("%s: copy_to_user() fail\n", __func__));
2312 msg = (CHAR *) kmalloc(sizeof(CHAR)*(MAX_LEN_OF_MAC_TABLE*MAC_LINE_LEN), MEM_ALLOC_FLAG);
2313 memset(msg, 0 ,MAX_LEN_OF_MAC_TABLE*MAC_LINE_LEN );
2314 sprintf(msg,"%s","\n");
2315 sprintf(msg+strlen(msg),"%-14s%-4s%-4s%-10s%-10s%-10s%-6s%-6s\n",
2316 "MAC", "AID", "PSM", "LDT", "RxB", "TxB","CTxR", "LTxR");
2318 for (i=0; i<MAX_LEN_OF_MAC_TABLE; i++)
2320 PMAC_TABLE_ENTRY pEntry = &pAd->MacTab.Content[i];
2321 if (pEntry->ValidAsCLI && (pEntry->Sst == SST_ASSOC))
2323 if((strlen(msg)+MAC_LINE_LEN ) >= (MAX_LEN_OF_MAC_TABLE*MAC_LINE_LEN) )
2325 sprintf(msg+strlen(msg),"%02x%02x%02x%02x%02x%02x ",
2326 pEntry->Addr[0], pEntry->Addr[1], pEntry->Addr[2],
2327 pEntry->Addr[3], pEntry->Addr[4], pEntry->Addr[5]);
2328 sprintf(msg+strlen(msg),"%-4d", (int)pEntry->Aid);
2329 sprintf(msg+strlen(msg),"%-4d", (int)pEntry->PsMode);
2330 sprintf(msg+strlen(msg),"%-10d",0/*pAd->MacTab.Content[i].HSCounter.LastDataPacketTime*/); // ToDo
2331 sprintf(msg+strlen(msg),"%-10d",0/*pAd->MacTab.Content[i].HSCounter.TotalRxByteCount*/); // ToDo
2332 sprintf(msg+strlen(msg),"%-10d",0/*pAd->MacTab.Content[i].HSCounter.TotalTxByteCount*/); // ToDo
2333 sprintf(msg+strlen(msg),"%-6d",RateIdToMbps[pAd->MacTab.Content[i].CurrTxRate]);
2334 sprintf(msg+strlen(msg),"%-6d\n",0/*RateIdToMbps[pAd->MacTab.Content[i].LastTxRate]*/); // ToDo
2337 // for compatible with old API just do the printk to console
2338 //wrq->u.data.length = strlen(msg);
2339 //if (copy_to_user(wrq->u.data.pointer, msg, wrq->u.data.length))
2341 DBGPRINT(RT_DEBUG_TRACE, ("%s", msg));
2347 #ifdef DOT11_N_SUPPORT
2348 INT Set_BASetup_Proc(
2349 IN PRTMP_ADAPTER pAd,
2353 char *token, sepValue[] = ":", DASH = '-';
2355 MAC_TABLE_ENTRY *pEntry;
2358 The BASetup inupt string format should be xx:xx:xx:xx:xx:xx-d,
2359 =>The six 2 digit hex-decimal number previous are the Mac address,
2360 =>The seventh decimal number is the tid value.
2362 //printk("\n%s\n", arg);
2364 if(strlen(arg) < 19) //Mac address acceptable format 01:02:03:04:05:06 length 17 plus the "-" and tid value in decimal format.
2367 token = strchr(arg, DASH);
2368 if ((token != NULL) && (strlen(token)>1))
2370 tid = simple_strtol((token+1), 0, 10);
2375 for (i = 0, token = rstrtok(arg, &sepValue[0]); token; token = rstrtok(NULL, &sepValue[0]), i++)
2377 if((strlen(token) != 2) || (!isxdigit(*token)) || (!isxdigit(*(token+1))))
2379 AtoH(token, (PUCHAR)(&mac[i]), 1);
2384 printk("\n%02x:%02x:%02x:%02x:%02x:%02x-%02x\n", mac[0], mac[1],
2385 mac[2], mac[3], mac[4], mac[5], tid);
2387 pEntry = MacTableLookup(pAd, mac);
2390 printk("\nSetup BA Session: Tid = %d\n", tid);
2391 BAOriSessionSetUp(pAd, pEntry, tid, 0, 100, TRUE);
2401 INT Set_BADecline_Proc(
2402 IN PRTMP_ADAPTER pAd,
2407 bBADecline = simple_strtol(arg, 0, 10);
2409 if (bBADecline == 0)
2411 pAd->CommonCfg.bBADecline = FALSE;
2413 else if (bBADecline == 1)
2415 pAd->CommonCfg.bBADecline = TRUE;
2419 return FALSE; //Invalid argument
2422 DBGPRINT(RT_DEBUG_TRACE, ("Set_BADecline_Proc::(BADecline=%d)\n", pAd->CommonCfg.bBADecline));
2427 INT Set_BAOriTearDown_Proc(
2428 IN PRTMP_ADAPTER pAd,
2432 char *token, sepValue[] = ":", DASH = '-';
2434 MAC_TABLE_ENTRY *pEntry;
2436 //printk("\n%s\n", arg);
2438 The BAOriTearDown inupt string format should be xx:xx:xx:xx:xx:xx-d,
2439 =>The six 2 digit hex-decimal number previous are the Mac address,
2440 =>The seventh decimal number is the tid value.
2442 if(strlen(arg) < 19) //Mac address acceptable format 01:02:03:04:05:06 length 17 plus the "-" and tid value in decimal format.
2445 token = strchr(arg, DASH);
2446 if ((token != NULL) && (strlen(token)>1))
2448 tid = simple_strtol((token+1), 0, 10);
2449 if (tid > NUM_OF_TID)
2453 for (i = 0, token = rstrtok(arg, &sepValue[0]); token; token = rstrtok(NULL, &sepValue[0]), i++)
2455 if((strlen(token) != 2) || (!isxdigit(*token)) || (!isxdigit(*(token+1))))
2457 AtoH(token, (PUCHAR)(&mac[i]), 1);
2462 printk("\n%02x:%02x:%02x:%02x:%02x:%02x-%02x", mac[0], mac[1],
2463 mac[2], mac[3], mac[4], mac[5], tid);
2465 pEntry = MacTableLookup(pAd, mac);
2468 printk("\nTear down Ori BA Session: Tid = %d\n", tid);
2469 BAOriSessionTearDown(pAd, pEntry->Aid, tid, FALSE, TRUE);
2479 INT Set_BARecTearDown_Proc(
2480 IN PRTMP_ADAPTER pAd,
2484 char *token, sepValue[] = ":", DASH = '-';
2486 MAC_TABLE_ENTRY *pEntry;
2488 //printk("\n%s\n", arg);
2490 The BARecTearDown inupt string format should be xx:xx:xx:xx:xx:xx-d,
2491 =>The six 2 digit hex-decimal number previous are the Mac address,
2492 =>The seventh decimal number is the tid value.
2494 if(strlen(arg) < 19) //Mac address acceptable format 01:02:03:04:05:06 length 17 plus the "-" and tid value in decimal format.
2497 token = strchr(arg, DASH);
2498 if ((token != NULL) && (strlen(token)>1))
2500 tid = simple_strtol((token+1), 0, 10);
2501 if (tid > NUM_OF_TID)
2505 for (i = 0, token = rstrtok(arg, &sepValue[0]); token; token = rstrtok(NULL, &sepValue[0]), i++)
2507 if((strlen(token) != 2) || (!isxdigit(*token)) || (!isxdigit(*(token+1))))
2509 AtoH(token, (PUCHAR)(&mac[i]), 1);
2514 printk("\n%02x:%02x:%02x:%02x:%02x:%02x-%02x", mac[0], mac[1],
2515 mac[2], mac[3], mac[4], mac[5], tid);
2517 pEntry = MacTableLookup(pAd, mac);
2520 printk("\nTear down Rec BA Session: Tid = %d\n", tid);
2521 BARecSessionTearDown(pAd, pEntry->Aid, tid, FALSE);
2532 IN PRTMP_ADAPTER pAd,
2537 HtBw = simple_strtol(arg, 0, 10);
2539 pAd->CommonCfg.RegTransmitSetting.field.BW = BW_40;
2540 else if (HtBw == BW_20)
2541 pAd->CommonCfg.RegTransmitSetting.field.BW = BW_20;
2543 return FALSE; //Invalid argument
2547 DBGPRINT(RT_DEBUG_TRACE, ("Set_HtBw_Proc::(HtBw=%d)\n", pAd->CommonCfg.RegTransmitSetting.field.BW));
2553 IN PRTMP_ADAPTER pAd,
2556 ULONG HtMcs, Mcs_tmp;
2557 #ifdef CONFIG_STA_SUPPORT
2558 BOOLEAN bAutoRate = FALSE;
2559 #endif // CONFIG_STA_SUPPORT //
2561 Mcs_tmp = simple_strtol(arg, 0, 10);
2563 if (Mcs_tmp <= 15 || Mcs_tmp == 32)
2568 #ifdef CONFIG_STA_SUPPORT
2569 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
2571 pAd->StaCfg.DesiredTransmitSetting.field.MCS = HtMcs;
2572 pAd->StaCfg.bAutoTxRateSwitch = (HtMcs == MCS_AUTO) ? TRUE:FALSE;
2573 DBGPRINT(RT_DEBUG_TRACE, ("Set_HtMcs_Proc::(HtMcs=%d, bAutoTxRateSwitch = %d)\n",
2574 pAd->StaCfg.DesiredTransmitSetting.field.MCS, pAd->StaCfg.bAutoTxRateSwitch));
2576 if ((pAd->CommonCfg.PhyMode < PHY_11ABGN_MIXED) ||
2577 (pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE < MODE_HTMIX))
2579 if ((pAd->StaCfg.DesiredTransmitSetting.field.MCS != MCS_AUTO) &&
2580 (HtMcs >= 0 && HtMcs <= 3) &&
2581 (pAd->StaCfg.DesiredTransmitSetting.field.FixedTxMode == FIXED_TXMODE_CCK))
2583 RTMPSetDesiredRates(pAd, (LONG) (RateIdToMbps[HtMcs] * 1000000));
2585 else if ((pAd->StaCfg.DesiredTransmitSetting.field.MCS != MCS_AUTO) &&
2586 (HtMcs >= 0 && HtMcs <= 7) &&
2587 (pAd->StaCfg.DesiredTransmitSetting.field.FixedTxMode == FIXED_TXMODE_OFDM))
2589 RTMPSetDesiredRates(pAd, (LONG) (RateIdToMbps[HtMcs+4] * 1000000));
2596 pAd->StaCfg.DesiredTransmitSetting.field.MCS = MCS_AUTO;
2597 RTMPSetDesiredRates(pAd, -1);
2599 DBGPRINT(RT_DEBUG_TRACE, ("Set_HtMcs_Proc::(FixedTxMode=%d)\n",pAd->StaCfg.DesiredTransmitSetting.field.FixedTxMode));
2604 #endif // CONFIG_STA_SUPPORT //
2612 IN PRTMP_ADAPTER pAd,
2617 HtGi = simple_strtol(arg, 0, 10);
2619 if ( HtGi == GI_400)
2620 pAd->CommonCfg.RegTransmitSetting.field.ShortGI = GI_400;
2621 else if ( HtGi == GI_800 )
2622 pAd->CommonCfg.RegTransmitSetting.field.ShortGI = GI_800;
2624 return FALSE; //Invalid argument
2628 DBGPRINT(RT_DEBUG_TRACE, ("Set_HtGi_Proc::(ShortGI=%d)\n",pAd->CommonCfg.RegTransmitSetting.field.ShortGI));
2634 INT Set_HtTxBASize_Proc(
2635 IN PRTMP_ADAPTER pAd,
2640 Size = simple_strtol(arg, 0, 10);
2642 if (Size <=0 || Size >=64)
2646 pAd->CommonCfg.TxBASize = Size-1;
2647 DBGPRINT(RT_DEBUG_ERROR, ("Set_HtTxBASize ::(TxBASize= %d)\n", Size));
2653 INT Set_HtOpMode_Proc(
2654 IN PRTMP_ADAPTER pAd,
2660 Value = simple_strtol(arg, 0, 10);
2662 if (Value == HTMODE_GF)
2663 pAd->CommonCfg.RegTransmitSetting.field.HTMODE = HTMODE_GF;
2664 else if ( Value == HTMODE_MM )
2665 pAd->CommonCfg.RegTransmitSetting.field.HTMODE = HTMODE_MM;
2667 return FALSE; //Invalid argument
2671 DBGPRINT(RT_DEBUG_TRACE, ("Set_HtOpMode_Proc::(HtOpMode=%d)\n",pAd->CommonCfg.RegTransmitSetting.field.HTMODE));
2677 INT Set_HtStbc_Proc(
2678 IN PRTMP_ADAPTER pAd,
2684 Value = simple_strtol(arg, 0, 10);
2686 if (Value == STBC_USE)
2687 pAd->CommonCfg.RegTransmitSetting.field.STBC = STBC_USE;
2688 else if ( Value == STBC_NONE )
2689 pAd->CommonCfg.RegTransmitSetting.field.STBC = STBC_NONE;
2691 return FALSE; //Invalid argument
2695 DBGPRINT(RT_DEBUG_TRACE, ("Set_Stbc_Proc::(HtStbc=%d)\n",pAd->CommonCfg.RegTransmitSetting.field.STBC));
2701 IN PRTMP_ADAPTER pAd,
2707 Value = simple_strtol(arg, 0, 10);
2709 pAd->HTCEnable = FALSE;
2710 else if ( Value ==1 )
2711 pAd->HTCEnable = TRUE;
2713 return FALSE; //Invalid argument
2715 DBGPRINT(RT_DEBUG_TRACE, ("Set_HtHtc_Proc::(HtHtc=%d)\n",pAd->HTCEnable));
2720 INT Set_HtExtcha_Proc(
2721 IN PRTMP_ADAPTER pAd,
2727 Value = simple_strtol(arg, 0, 10);
2730 pAd->CommonCfg.RegTransmitSetting.field.EXTCHA = EXTCHA_BELOW;
2731 else if ( Value ==1 )
2732 pAd->CommonCfg.RegTransmitSetting.field.EXTCHA = EXTCHA_ABOVE;
2734 return FALSE; //Invalid argument
2738 DBGPRINT(RT_DEBUG_TRACE, ("Set_HtExtcha_Proc::(HtExtcha=%d)\n",pAd->CommonCfg.RegTransmitSetting.field.EXTCHA));
2743 INT Set_HtMpduDensity_Proc(
2744 IN PRTMP_ADAPTER pAd,
2749 Value = simple_strtol(arg, 0, 10);
2751 if (Value <=7 && Value >= 0)
2752 pAd->CommonCfg.BACapability.field.MpduDensity = Value;
2754 pAd->CommonCfg.BACapability.field.MpduDensity = 4;
2758 DBGPRINT(RT_DEBUG_TRACE, ("Set_HtMpduDensity_Proc::(HtMpduDensity=%d)\n",pAd->CommonCfg.BACapability.field.MpduDensity));
2763 INT Set_HtBaWinSize_Proc(
2764 IN PRTMP_ADAPTER pAd,
2769 Value = simple_strtol(arg, 0, 10);
2772 if (Value >=1 && Value <= 64)
2774 pAd->CommonCfg.REGBACapability.field.RxBAWinLimit = Value;
2775 pAd->CommonCfg.BACapability.field.RxBAWinLimit = Value;
2779 pAd->CommonCfg.REGBACapability.field.RxBAWinLimit = 64;
2780 pAd->CommonCfg.BACapability.field.RxBAWinLimit = 64;
2785 DBGPRINT(RT_DEBUG_TRACE, ("Set_HtBaWinSize_Proc::(HtBaWinSize=%d)\n",pAd->CommonCfg.BACapability.field.RxBAWinLimit));
2791 IN PRTMP_ADAPTER pAd,
2796 Value = simple_strtol(arg, 0, 10);
2799 pAd->CommonCfg.bRdg = FALSE;
2800 else if ( Value ==1 )
2802 pAd->HTCEnable = TRUE;
2803 pAd->CommonCfg.bRdg = TRUE;
2806 return FALSE; //Invalid argument
2810 DBGPRINT(RT_DEBUG_TRACE, ("Set_HtRdg_Proc::(HtRdg=%d)\n",pAd->CommonCfg.bRdg));
2815 INT Set_HtLinkAdapt_Proc(
2816 IN PRTMP_ADAPTER pAd,
2821 Value = simple_strtol(arg, 0, 10);
2823 pAd->bLinkAdapt = FALSE;
2824 else if ( Value ==1 )
2826 pAd->HTCEnable = TRUE;
2827 pAd->bLinkAdapt = TRUE;
2830 return FALSE; //Invalid argument
2832 DBGPRINT(RT_DEBUG_TRACE, ("Set_HtLinkAdapt_Proc::(HtLinkAdapt=%d)\n",pAd->bLinkAdapt));
2837 INT Set_HtAmsdu_Proc(
2838 IN PRTMP_ADAPTER pAd,
2843 Value = simple_strtol(arg, 0, 10);
2845 pAd->CommonCfg.BACapability.field.AmsduEnable = FALSE;
2846 else if ( Value == 1 )
2847 pAd->CommonCfg.BACapability.field.AmsduEnable = TRUE;
2849 return FALSE; //Invalid argument
2853 DBGPRINT(RT_DEBUG_TRACE, ("Set_HtAmsdu_Proc::(HtAmsdu=%d)\n",pAd->CommonCfg.BACapability.field.AmsduEnable));
2858 INT Set_HtAutoBa_Proc(
2859 IN PRTMP_ADAPTER pAd,
2864 Value = simple_strtol(arg, 0, 10);
2866 pAd->CommonCfg.BACapability.field.AutoBA = FALSE;
2867 else if (Value == 1)
2868 pAd->CommonCfg.BACapability.field.AutoBA = TRUE;
2870 return FALSE; //Invalid argument
2872 pAd->CommonCfg.REGBACapability.field.AutoBA = pAd->CommonCfg.BACapability.field.AutoBA;
2875 DBGPRINT(RT_DEBUG_TRACE, ("Set_HtAutoBa_Proc::(HtAutoBa=%d)\n",pAd->CommonCfg.BACapability.field.AutoBA));
2881 INT Set_HtProtect_Proc(
2882 IN PRTMP_ADAPTER pAd,
2887 Value = simple_strtol(arg, 0, 10);
2889 pAd->CommonCfg.bHTProtect = FALSE;
2890 else if (Value == 1)
2891 pAd->CommonCfg.bHTProtect = TRUE;
2893 return FALSE; //Invalid argument
2895 DBGPRINT(RT_DEBUG_TRACE, ("Set_HtProtect_Proc::(HtProtect=%d)\n",pAd->CommonCfg.bHTProtect));
2900 INT Set_SendPSMPAction_Proc(
2901 IN PRTMP_ADAPTER pAd,
2905 char *token, sepValue[] = ":", DASH = '-';
2907 MAC_TABLE_ENTRY *pEntry;
2909 //printk("\n%s\n", arg);
2911 The BARecTearDown inupt string format should be xx:xx:xx:xx:xx:xx-d,
2912 =>The six 2 digit hex-decimal number previous are the Mac address,
2913 =>The seventh decimal number is the mode value.
2915 if(strlen(arg) < 19) //Mac address acceptable format 01:02:03:04:05:06 length 17 plus the "-" and mode value in decimal format.
2918 token = strchr(arg, DASH);
2919 if ((token != NULL) && (strlen(token)>1))
2921 mode = simple_strtol((token+1), 0, 10);
2922 if (mode > MMPS_ENABLE)
2926 for (i = 0, token = rstrtok(arg, &sepValue[0]); token; token = rstrtok(NULL, &sepValue[0]), i++)
2928 if((strlen(token) != 2) || (!isxdigit(*token)) || (!isxdigit(*(token+1))))
2930 AtoH(token, (PUCHAR)(&mac[i]), 1);
2935 printk("\n%02x:%02x:%02x:%02x:%02x:%02x-%02x", mac[0], mac[1],
2936 mac[2], mac[3], mac[4], mac[5], mode);
2938 pEntry = MacTableLookup(pAd, mac);
2941 printk("\nSendPSMPAction MIPS mode = %d\n", mode);
2942 SendPSMPAction(pAd, pEntry->Aid, mode);
2953 INT Set_HtMIMOPSmode_Proc(
2954 IN PRTMP_ADAPTER pAd,
2959 Value = simple_strtol(arg, 0, 10);
2961 if (Value <=3 && Value >= 0)
2962 pAd->CommonCfg.BACapability.field.MMPSmode = Value;
2964 pAd->CommonCfg.BACapability.field.MMPSmode = 3;
2968 DBGPRINT(RT_DEBUG_TRACE, ("Set_HtMIMOPSmode_Proc::(MIMOPS mode=%d)\n",pAd->CommonCfg.BACapability.field.MMPSmode));
2974 INT Set_ForceShortGI_Proc(
2975 IN PRTMP_ADAPTER pAd,
2980 Value = simple_strtol(arg, 0, 10);
2982 pAd->WIFItestbed.bShortGI = FALSE;
2983 else if (Value == 1)
2984 pAd->WIFItestbed.bShortGI = TRUE;
2986 return FALSE; //Invalid argument
2990 DBGPRINT(RT_DEBUG_TRACE, ("Set_ForceShortGI_Proc::(ForceShortGI=%d)\n", pAd->WIFItestbed.bShortGI));
2997 INT Set_ForceGF_Proc(
2998 IN PRTMP_ADAPTER pAd,
3003 Value = simple_strtol(arg, 0, 10);
3005 pAd->WIFItestbed.bGreenField = FALSE;
3006 else if (Value == 1)
3007 pAd->WIFItestbed.bGreenField = TRUE;
3009 return FALSE; //Invalid argument
3013 DBGPRINT(RT_DEBUG_TRACE, ("Set_ForceGF_Proc::(ForceGF=%d)\n", pAd->WIFItestbed.bGreenField));
3018 INT Set_HtMimoPs_Proc(
3019 IN PRTMP_ADAPTER pAd,
3024 Value = simple_strtol(arg, 0, 10);
3026 pAd->CommonCfg.bMIMOPSEnable = FALSE;
3027 else if (Value == 1)
3028 pAd->CommonCfg.bMIMOPSEnable = TRUE;
3030 return FALSE; //Invalid argument
3032 DBGPRINT(RT_DEBUG_TRACE, ("Set_HtMimoPs_Proc::(HtMimoPs=%d)\n",pAd->CommonCfg.bMIMOPSEnable));
3036 #endif // DOT11_N_SUPPORT //
3039 #ifdef DOT11_N_SUPPORT
3041 IN PRTMP_ADAPTER pAd)
3043 OID_SET_HT_PHYMODE SetHT;
3045 if (pAd->CommonCfg.PhyMode < PHY_11ABGN_MIXED)
3048 SetHT.PhyMode = pAd->CommonCfg.PhyMode;
3049 SetHT.TransmitNo = ((UCHAR)pAd->Antenna.field.TxPath);
3050 SetHT.HtMode = (UCHAR)pAd->CommonCfg.RegTransmitSetting.field.HTMODE;
3051 SetHT.ExtOffset = (UCHAR)pAd->CommonCfg.RegTransmitSetting.field.EXTCHA;
3052 SetHT.MCS = MCS_AUTO;
3053 SetHT.BW = (UCHAR)pAd->CommonCfg.RegTransmitSetting.field.BW;
3054 SetHT.STBC = (UCHAR)pAd->CommonCfg.RegTransmitSetting.field.STBC;
3055 SetHT.SHORTGI = (UCHAR)pAd->CommonCfg.RegTransmitSetting.field.ShortGI;
3057 RTMPSetHT(pAd, &SetHT);
3061 #endif // DOT11_N_SUPPORT //
3063 INT Set_FixedTxMode_Proc(
3064 IN PRTMP_ADAPTER pAd,
3067 UCHAR fix_tx_mode = FIXED_TXMODE_HT;
3069 if (strcmp(arg, "OFDM") == 0 || strcmp(arg, "ofdm") == 0)
3071 fix_tx_mode = FIXED_TXMODE_OFDM;
3073 else if (strcmp(arg, "CCK") == 0 || strcmp(arg, "cck") == 0)
3075 fix_tx_mode = FIXED_TXMODE_CCK;
3078 #ifdef CONFIG_STA_SUPPORT
3079 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
3080 pAd->StaCfg.DesiredTransmitSetting.field.FixedTxMode = fix_tx_mode;
3081 #endif // CONFIG_STA_SUPPORT //
3083 DBGPRINT(RT_DEBUG_TRACE, ("Set_FixedTxMode_Proc::(FixedTxMode=%d)\n", fix_tx_mode));
3088 /////////////////////////////////////////////////////////////////////////
3089 PCHAR RTMPGetRalinkAuthModeStr(
3090 IN NDIS_802_11_AUTHENTICATION_MODE authMode)
3094 case Ndis802_11AuthModeOpen:
3096 case Ndis802_11AuthModeWPAPSK:
3098 case Ndis802_11AuthModeShared:
3100 case Ndis802_11AuthModeWPA:
3102 case Ndis802_11AuthModeWPA2:
3104 case Ndis802_11AuthModeWPA2PSK:
3106 case Ndis802_11AuthModeWPA1PSKWPA2PSK:
3107 return "WPAPSKWPA2PSK";
3108 case Ndis802_11AuthModeWPA1WPA2:
3110 case Ndis802_11AuthModeWPANone:
3117 PCHAR RTMPGetRalinkEncryModeStr(
3118 IN USHORT encryMode)
3122 case Ndis802_11WEPDisabled:
3124 case Ndis802_11WEPEnabled:
3126 case Ndis802_11Encryption2Enabled:
3128 case Ndis802_11Encryption3Enabled:
3130 case Ndis802_11Encryption4Enabled:
3137 INT RTMPShowCfgValue(
3138 IN PRTMP_ADAPTER pAd,
3144 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++)
3146 if (!strcmp(pName, PRTMP_PRIVATE_STA_SHOW_CFG_VALUE_PROC->name))
3148 if(PRTMP_PRIVATE_STA_SHOW_CFG_VALUE_PROC->show_proc(pAd, pBuf))
3150 break; //Exit for loop.
3154 if(PRTMP_PRIVATE_STA_SHOW_CFG_VALUE_PROC->name == NULL)
3156 sprintf(pBuf, "\n");
3157 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++)
3158 sprintf(pBuf + strlen(pBuf), "%s\n", PRTMP_PRIVATE_STA_SHOW_CFG_VALUE_PROC->name);
3165 IN PRTMP_ADAPTER pAd,
3169 #ifdef CONFIG_STA_SUPPORT
3170 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
3171 sprintf(pBuf, "\t%s", pAd->CommonCfg.Ssid);
3172 #endif // CONFIG_STA_SUPPORT //
3176 INT Show_WirelessMode_Proc(
3177 IN PRTMP_ADAPTER pAd,
3180 switch(pAd->CommonCfg.PhyMode)
3182 case PHY_11BG_MIXED:
3183 sprintf(pBuf, "\t11B/G");
3186 sprintf(pBuf, "\t11B");
3189 sprintf(pBuf, "\t11A");
3191 case PHY_11ABG_MIXED:
3192 sprintf(pBuf, "\t11A/B/G");
3195 sprintf(pBuf, "\t11G");
3197 #ifdef DOT11_N_SUPPORT
3198 case PHY_11ABGN_MIXED:
3199 sprintf(pBuf, "\t11A/B/G/N");
3202 sprintf(pBuf, "\t11N only with 2.4G");
3204 case PHY_11GN_MIXED:
3205 sprintf(pBuf, "\t11G/N");
3207 case PHY_11AN_MIXED:
3208 sprintf(pBuf, "\t11A/N");
3210 case PHY_11BGN_MIXED:
3211 sprintf(pBuf, "\t11B/G/N");
3213 case PHY_11AGN_MIXED:
3214 sprintf(pBuf, "\t11A/G/N");
3217 sprintf(pBuf, "\t11N only with 5G");
3219 #endif // DOT11_N_SUPPORT //
3221 sprintf(pBuf, "\tUnknow Value(%d)", pAd->CommonCfg.PhyMode);
3228 INT Show_TxBurst_Proc(
3229 IN PRTMP_ADAPTER pAd,
3232 sprintf(pBuf, "\t%s", pAd->CommonCfg.bEnableTxBurst ? "TRUE":"FALSE");
3236 INT Show_TxPreamble_Proc(
3237 IN PRTMP_ADAPTER pAd,
3240 switch(pAd->CommonCfg.TxPreamble)
3242 case Rt802_11PreambleShort:
3243 sprintf(pBuf, "\tShort");
3245 case Rt802_11PreambleLong:
3246 sprintf(pBuf, "\tLong");
3248 case Rt802_11PreambleAuto:
3249 sprintf(pBuf, "\tAuto");
3252 sprintf(pBuf, "\tUnknow Value(%lu)", pAd->CommonCfg.TxPreamble);
3259 INT Show_TxPower_Proc(
3260 IN PRTMP_ADAPTER pAd,
3263 sprintf(pBuf, "\t%lu", pAd->CommonCfg.TxPowerPercentage);
3267 INT Show_Channel_Proc(
3268 IN PRTMP_ADAPTER pAd,
3271 sprintf(pBuf, "\t%d", pAd->CommonCfg.Channel);
3275 INT Show_BGProtection_Proc(
3276 IN PRTMP_ADAPTER pAd,
3279 switch(pAd->CommonCfg.UseBGProtection)
3282 sprintf(pBuf, "\tON");
3284 case 2: //Always OFF
3285 sprintf(pBuf, "\tOFF");
3288 sprintf(pBuf, "\tAuto");
3291 sprintf(pBuf, "\tUnknow Value(%lu)", pAd->CommonCfg.UseBGProtection);
3297 INT Show_RTSThreshold_Proc(
3298 IN PRTMP_ADAPTER pAd,
3301 sprintf(pBuf, "\t%u", pAd->CommonCfg.RtsThreshold);
3305 INT Show_FragThreshold_Proc(
3306 IN PRTMP_ADAPTER pAd,
3309 sprintf(pBuf, "\t%u", pAd->CommonCfg.FragmentThreshold);
3313 #ifdef DOT11_N_SUPPORT
3315 IN PRTMP_ADAPTER pAd,
3318 if (pAd->CommonCfg.RegTransmitSetting.field.BW == BW_40)
3320 sprintf(pBuf, "\t40 MHz");
3324 sprintf(pBuf, "\t20 MHz");
3329 INT Show_HtMcs_Proc(
3330 IN PRTMP_ADAPTER pAd,
3334 #ifdef CONFIG_STA_SUPPORT
3335 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
3336 sprintf(pBuf, "\t%u", pAd->StaCfg.DesiredTransmitSetting.field.MCS);
3337 #endif // CONFIG_STA_SUPPORT //
3342 IN PRTMP_ADAPTER pAd,
3345 switch(pAd->CommonCfg.RegTransmitSetting.field.ShortGI)
3348 sprintf(pBuf, "\tGI_400");
3351 sprintf(pBuf, "\tGI_800");
3354 sprintf(pBuf, "\tUnknow Value(%u)", pAd->CommonCfg.RegTransmitSetting.field.ShortGI);
3360 INT Show_HtOpMode_Proc(
3361 IN PRTMP_ADAPTER pAd,
3364 switch(pAd->CommonCfg.RegTransmitSetting.field.HTMODE)
3367 sprintf(pBuf, "\tGF");
3370 sprintf(pBuf, "\tMM");
3373 sprintf(pBuf, "\tUnknow Value(%u)", pAd->CommonCfg.RegTransmitSetting.field.HTMODE);
3379 INT Show_HtExtcha_Proc(
3380 IN PRTMP_ADAPTER pAd,
3383 switch(pAd->CommonCfg.RegTransmitSetting.field.EXTCHA)
3386 sprintf(pBuf, "\tBelow");
3389 sprintf(pBuf, "\tAbove");
3392 sprintf(pBuf, "\tUnknow Value(%u)", pAd->CommonCfg.RegTransmitSetting.field.EXTCHA);
3399 INT Show_HtMpduDensity_Proc(
3400 IN PRTMP_ADAPTER pAd,
3403 sprintf(pBuf, "\t%u", pAd->CommonCfg.BACapability.field.MpduDensity);
3407 INT Show_HtBaWinSize_Proc(
3408 IN PRTMP_ADAPTER pAd,
3411 sprintf(pBuf, "\t%u", pAd->CommonCfg.BACapability.field.RxBAWinLimit);
3415 INT Show_HtRdg_Proc(
3416 IN PRTMP_ADAPTER pAd,
3419 sprintf(pBuf, "\t%s", pAd->CommonCfg.bRdg ? "TRUE":"FALSE");
3423 INT Show_HtAmsdu_Proc(
3424 IN PRTMP_ADAPTER pAd,
3427 sprintf(pBuf, "\t%s", pAd->CommonCfg.BACapability.field.AmsduEnable ? "TRUE":"FALSE");
3431 INT Show_HtAutoBa_Proc(
3432 IN PRTMP_ADAPTER pAd,
3435 sprintf(pBuf, "\t%s", pAd->CommonCfg.BACapability.field.AutoBA ? "TRUE":"FALSE");
3438 #endif // DOT11_N_SUPPORT //
3440 INT Show_CountryRegion_Proc(
3441 IN PRTMP_ADAPTER pAd,
3444 sprintf(pBuf, "\t%d", pAd->CommonCfg.CountryRegion);
3448 INT Show_CountryRegionABand_Proc(
3449 IN PRTMP_ADAPTER pAd,
3452 sprintf(pBuf, "\t%d", pAd->CommonCfg.CountryRegionForABand);
3456 INT Show_CountryCode_Proc(
3457 IN PRTMP_ADAPTER pAd,
3460 sprintf(pBuf, "\t%s", pAd->CommonCfg.CountryCode);
3464 #ifdef AGGREGATION_SUPPORT
3465 INT Show_PktAggregate_Proc(
3466 IN PRTMP_ADAPTER pAd,
3469 sprintf(pBuf, "\t%s", pAd->CommonCfg.bAggregationCapable ? "TRUE":"FALSE");
3472 #endif // AGGREGATION_SUPPORT //
3475 INT Show_WmmCapable_Proc(
3476 IN PRTMP_ADAPTER pAd,
3480 #ifdef CONFIG_STA_SUPPORT
3481 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
3482 sprintf(pBuf, "\t%s", pAd->CommonCfg.bWmmCapable ? "TRUE":"FALSE");
3483 #endif // CONFIG_STA_SUPPORT //
3487 #endif // WMM_SUPPORT //
3489 INT Show_IEEE80211H_Proc(
3490 IN PRTMP_ADAPTER pAd,
3493 sprintf(pBuf, "\t%s", pAd->CommonCfg.bIEEE80211H ? "TRUE":"FALSE");
3497 #ifdef CONFIG_STA_SUPPORT
3498 INT Show_NetworkType_Proc(
3499 IN PRTMP_ADAPTER pAd,
3502 switch(pAd->StaCfg.BssType)
3505 sprintf(pBuf, "\tAdhoc");
3508 sprintf(pBuf, "\tInfra");
3511 sprintf(pBuf, "\tAny");
3514 sprintf(pBuf, "\tMonitor");
3517 sprintf(pBuf, "\tUnknow Value(%d)", pAd->StaCfg.BssType);
3522 #endif // CONFIG_STA_SUPPORT //
3524 INT Show_AuthMode_Proc(
3525 IN PRTMP_ADAPTER pAd,
3528 NDIS_802_11_AUTHENTICATION_MODE AuthMode = Ndis802_11AuthModeOpen;
3530 #ifdef CONFIG_STA_SUPPORT
3531 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
3532 AuthMode = pAd->StaCfg.AuthMode;
3533 #endif // CONFIG_STA_SUPPORT //
3535 if ((AuthMode >= Ndis802_11AuthModeOpen) &&
3536 (AuthMode <= Ndis802_11AuthModeWPA1PSKWPA2PSK))
3537 sprintf(pBuf, "\t%s", RTMPGetRalinkAuthModeStr(AuthMode));
3539 sprintf(pBuf, "\tUnknow Value(%d)", AuthMode);
3544 INT Show_EncrypType_Proc(
3545 IN PRTMP_ADAPTER pAd,
3548 NDIS_802_11_WEP_STATUS WepStatus = Ndis802_11WEPDisabled;
3550 #ifdef CONFIG_STA_SUPPORT
3551 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
3552 WepStatus = pAd->StaCfg.WepStatus;
3553 #endif // CONFIG_STA_SUPPORT //
3555 if ((WepStatus >= Ndis802_11WEPEnabled) &&
3556 (WepStatus <= Ndis802_11Encryption4KeyAbsent))
3557 sprintf(pBuf, "\t%s", RTMPGetRalinkEncryModeStr(WepStatus));
3559 sprintf(pBuf, "\tUnknow Value(%d)", WepStatus);
3564 INT Show_DefaultKeyID_Proc(
3565 IN PRTMP_ADAPTER pAd,
3568 UCHAR DefaultKeyId = 0;
3570 #ifdef CONFIG_STA_SUPPORT
3571 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
3572 DefaultKeyId = pAd->StaCfg.DefaultKeyId;
3573 #endif // CONFIG_STA_SUPPORT //
3575 sprintf(pBuf, "\t%d", DefaultKeyId);
3580 INT Show_WepKey_Proc(
3581 IN PRTMP_ADAPTER pAd,
3585 UCHAR Key[16] = {0}, KeyLength = 0;
3588 KeyLength = pAd->SharedKey[index][KeyIdx].KeyLen;
3589 NdisMoveMemory(Key, pAd->SharedKey[index][KeyIdx].Key, KeyLength);
3591 //check key string is ASCII or not
3592 if (RTMPCheckStrPrintAble(Key, KeyLength))
3593 sprintf(pBuf, "\t%s", Key);
3597 sprintf(pBuf, "\t");
3598 for (idx = 0; idx < KeyLength; idx++)
3599 sprintf(pBuf+strlen(pBuf), "%02X", Key[idx]);
3605 IN PRTMP_ADAPTER pAd,
3608 Show_WepKey_Proc(pAd, 0, pBuf);
3613 IN PRTMP_ADAPTER pAd,
3616 Show_WepKey_Proc(pAd, 1, pBuf);
3621 IN PRTMP_ADAPTER pAd,
3624 Show_WepKey_Proc(pAd, 2, pBuf);
3629 IN PRTMP_ADAPTER pAd,
3632 Show_WepKey_Proc(pAd, 3, pBuf);
3636 INT Show_WPAPSK_Proc(
3637 IN PRTMP_ADAPTER pAd,
3641 UCHAR PMK[32] = {0};
3644 #ifdef CONFIG_STA_SUPPORT
3645 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
3646 NdisMoveMemory(PMK, pAd->StaCfg.PMK, 32);
3647 #endif // CONFIG_STA_SUPPORT //
3649 sprintf(pBuf, "\tPMK = ");
3650 for (idx = 0; idx < 32; idx++)
3651 sprintf(pBuf+strlen(pBuf), "%02X", PMK[idx]);