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 <linux/sched.h>
29 #include "../rt_config.h"
35 INT Show_WirelessMode_Proc(
39 INT Show_TxBurst_Proc(
43 INT Show_TxPreamble_Proc(
47 INT Show_TxPower_Proc(
51 INT Show_Channel_Proc(
55 INT Show_BGProtection_Proc(
59 INT Show_RTSThreshold_Proc(
63 INT Show_FragThreshold_Proc(
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,
107 INT Show_CountryRegion_Proc(
108 IN PRTMP_ADAPTER pAd,
111 INT Show_CountryRegionABand_Proc(
112 IN PRTMP_ADAPTER pAd,
115 INT Show_CountryCode_Proc(
116 IN PRTMP_ADAPTER pAd,
119 #ifdef AGGREGATION_SUPPORT
120 INT Show_PktAggregate_Proc(
121 IN PRTMP_ADAPTER pAd,
123 #endif // AGGREGATION_SUPPORT //
126 INT Show_WmmCapable_Proc(
127 IN PRTMP_ADAPTER pAd,
129 #endif // WMM_SUPPORT //
131 INT Show_IEEE80211H_Proc(
132 IN PRTMP_ADAPTER pAd,
135 INT Show_NetworkType_Proc(
136 IN PRTMP_ADAPTER pAd,
139 INT Show_AuthMode_Proc(
140 IN PRTMP_ADAPTER pAd,
143 INT Show_EncrypType_Proc(
144 IN PRTMP_ADAPTER pAd,
147 INT Show_DefaultKeyID_Proc(
148 IN PRTMP_ADAPTER pAd,
152 IN PRTMP_ADAPTER pAd,
156 IN PRTMP_ADAPTER pAd,
160 IN PRTMP_ADAPTER pAd,
164 IN PRTMP_ADAPTER pAd,
167 INT Show_WPAPSK_Proc(
168 IN PRTMP_ADAPTER pAd,
173 INT (*show_proc)(PRTMP_ADAPTER pAdapter, PSTRING arg);
174 } *PRTMP_PRIVATE_STA_SHOW_CFG_VALUE_PROC, RTMP_PRIVATE_STA_SHOW_CFG_VALUE_PROC[] = {
175 {"SSID", Show_SSID_Proc},
176 {"WirelessMode", Show_WirelessMode_Proc},
177 {"TxBurst", Show_TxBurst_Proc},
178 {"TxPreamble", Show_TxPreamble_Proc},
179 {"TxPower", Show_TxPower_Proc},
180 {"Channel", Show_Channel_Proc},
181 {"BGProtection", Show_BGProtection_Proc},
182 {"RTSThreshold", Show_RTSThreshold_Proc},
183 {"FragThreshold", Show_FragThreshold_Proc},
184 {"HtBw", Show_HtBw_Proc},
185 {"HtMcs", Show_HtMcs_Proc},
186 {"HtGi", Show_HtGi_Proc},
187 {"HtOpMode", Show_HtOpMode_Proc},
188 {"HtExtcha", Show_HtExtcha_Proc},
189 {"HtMpduDensity", Show_HtMpduDensity_Proc},
190 {"HtBaWinSize", Show_HtBaWinSize_Proc},
191 {"HtRdg", Show_HtRdg_Proc},
192 {"HtAmsdu", Show_HtAmsdu_Proc},
193 {"HtAutoBa", Show_HtAutoBa_Proc},
194 {"CountryRegion", Show_CountryRegion_Proc},
195 {"CountryRegionABand", Show_CountryRegionABand_Proc},
196 {"CountryCode", Show_CountryCode_Proc},
197 #ifdef AGGREGATION_SUPPORT
198 {"PktAggregate", Show_PktAggregate_Proc},
202 {"WmmCapable", Show_WmmCapable_Proc},
204 {"IEEE80211H", Show_IEEE80211H_Proc},
205 {"NetworkType", Show_NetworkType_Proc},
206 {"AuthMode", Show_AuthMode_Proc},
207 {"EncrypType", Show_EncrypType_Proc},
208 {"DefaultKeyID", Show_DefaultKeyID_Proc},
209 {"Key1", Show_Key1_Proc},
210 {"Key2", Show_Key2_Proc},
211 {"Key3", Show_Key3_Proc},
212 {"Key4", Show_Key4_Proc},
213 {"WPAPSK", Show_WPAPSK_Proc},
218 ==========================================================================
223 ==========================================================================
225 INT Set_DriverVersion_Proc(
226 IN PRTMP_ADAPTER pAd,
230 DBGPRINT(RT_DEBUG_TRACE, ("Driver version-%s\n", STA_DRIVER_VERSION));
236 ==========================================================================
239 This command will not work, if the field of CountryRegion in eeprom is programmed.
241 TRUE if all parameters are OK, FALSE otherwise
242 ==========================================================================
244 INT Set_CountryRegion_Proc(
245 IN PRTMP_ADAPTER pAd,
251 retval = RT_CfgSetCountryRegion(pAd, arg, BAND_24G);
255 // if set country region, driver needs to be reset
256 BuildChannelList(pAd);
258 DBGPRINT(RT_DEBUG_TRACE, ("Set_CountryRegion_Proc::(CountryRegion=%d)\n", pAd->CommonCfg.CountryRegion));
264 ==========================================================================
266 Set Country Region for A band.
267 This command will not work, if the field of CountryRegion in eeprom is programmed.
269 TRUE if all parameters are OK, FALSE otherwise
270 ==========================================================================
272 INT Set_CountryRegionABand_Proc(
273 IN PRTMP_ADAPTER pAd,
279 retval = RT_CfgSetCountryRegion(pAd, arg, BAND_5G);
283 // if set country region, driver needs to be reset
284 BuildChannelList(pAd);
286 DBGPRINT(RT_DEBUG_TRACE, ("Set_CountryRegionABand_Proc::(CountryRegion=%d)\n", pAd->CommonCfg.CountryRegionForABand));
292 ==========================================================================
296 TRUE if all parameters are OK, FALSE otherwise
297 ==========================================================================
299 INT Set_WirelessMode_Proc(
300 IN PRTMP_ADAPTER pAd,
305 success = RT_CfgSetWirelessMode(pAd, arg);
309 LONG WirelessMode = pAd->CommonCfg.PhyMode;
311 RTMPSetPhyMode(pAd, WirelessMode);
312 if (WirelessMode >= PHY_11ABGN_MIXED)
314 pAd->CommonCfg.BACapability.field.AutoBA = TRUE;
315 pAd->CommonCfg.REGBACapability.field.AutoBA = TRUE;
319 pAd->CommonCfg.BACapability.field.AutoBA = FALSE;
320 pAd->CommonCfg.REGBACapability.field.AutoBA = FALSE;
323 // Set AdhocMode rates
324 if (pAd->StaCfg.BssType == BSS_ADHOC)
326 MlmeUpdateTxRates(pAd, FALSE, 0);
327 MakeIbssBeacon(pAd); // re-build BEACON frame
328 AsicEnableIbssSync(pAd); // copy to on-chip memory
332 // it is needed to set SSID to take effect
334 DBGPRINT(RT_DEBUG_TRACE, ("Set_WirelessMode_Proc::(=%d)\n", pAd->CommonCfg.PhyMode));
338 DBGPRINT(RT_DEBUG_ERROR, ("Set_WirelessMode_Proc::parameters out of range\n"));
345 ==========================================================================
349 TRUE if all parameters are OK, FALSE otherwise
350 ==========================================================================
352 INT Set_Channel_Proc(
353 IN PRTMP_ADAPTER pAd,
359 Channel = (UCHAR) simple_strtol(arg, 0, 10);
361 // check if this channel is valid
362 if (ChannelSanity(pAd, Channel) == TRUE)
365 pAd->CommonCfg.Channel = Channel;
370 if (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED &&
371 pAd->CommonCfg.RegTransmitSetting.field.BW == BW_40)
374 AsicSwitchChannel(pAd, pAd->CommonCfg.CentralChannel, FALSE);
375 AsicLockChannel(pAd, pAd->CommonCfg.CentralChannel);
376 DBGPRINT(RT_DEBUG_TRACE, ("BW_40, control_channel(%d), CentralChannel(%d) \n",
377 pAd->CommonCfg.Channel, pAd->CommonCfg.CentralChannel));
381 AsicSwitchChannel(pAd, pAd->CommonCfg.Channel, FALSE);
382 AsicLockChannel(pAd, pAd->CommonCfg.Channel);
383 DBGPRINT(RT_DEBUG_TRACE, ("BW_20, Channel(%d)\n", pAd->CommonCfg.Channel));
396 DBGPRINT(RT_DEBUG_TRACE, ("Set_Channel_Proc::(Channel=%d)\n", pAd->CommonCfg.Channel));
402 ==========================================================================
404 Set Short Slot Time Enable or Disable
406 TRUE if all parameters are OK, FALSE otherwise
407 ==========================================================================
409 INT Set_ShortSlot_Proc(
410 IN PRTMP_ADAPTER pAd,
415 retval = RT_CfgSetShortSlot(pAd, arg);
417 DBGPRINT(RT_DEBUG_TRACE, ("Set_ShortSlot_Proc::(ShortSlot=%d)\n", pAd->CommonCfg.bUseShortSlotTime));
424 ==========================================================================
428 TRUE if all parameters are OK, FALSE otherwise
429 ==========================================================================
431 INT Set_TxPower_Proc(
432 IN PRTMP_ADAPTER pAd,
438 TxPower = simple_strtol(arg, 0, 10);
442 pAd->CommonCfg.TxPowerDefault = TxPower;
443 pAd->CommonCfg.TxPowerPercentage = pAd->CommonCfg.TxPowerDefault;
450 DBGPRINT(RT_DEBUG_TRACE, ("Set_TxPower_Proc::(TxPowerPercentage=%ld)\n", pAd->CommonCfg.TxPowerPercentage));
456 ==========================================================================
458 Set 11B/11G Protection
460 TRUE if all parameters are OK, FALSE otherwise
461 ==========================================================================
463 INT Set_BGProtection_Proc(
464 IN PRTMP_ADAPTER pAd,
467 switch (simple_strtol(arg, 0, 10))
470 pAd->CommonCfg.UseBGProtection = 0;
473 pAd->CommonCfg.UseBGProtection = 1;
476 pAd->CommonCfg.UseBGProtection = 2;
478 default: //Invalid argument
483 DBGPRINT(RT_DEBUG_TRACE, ("Set_BGProtection_Proc::(BGProtection=%ld)\n", pAd->CommonCfg.UseBGProtection));
489 ==========================================================================
493 TRUE if all parameters are OK, FALSE otherwise
494 ==========================================================================
496 INT Set_TxPreamble_Proc(
497 IN PRTMP_ADAPTER pAd,
500 RT_802_11_PREAMBLE Preamble;
502 Preamble = simple_strtol(arg, 0, 10);
507 case Rt802_11PreambleShort:
508 pAd->CommonCfg.TxPreamble = Preamble;
510 MlmeSetTxPreamble(pAd, Rt802_11PreambleShort);
512 case Rt802_11PreambleLong:
513 case Rt802_11PreambleAuto:
514 // if user wants AUTO, initialize to LONG here, then change according to AP's
515 // capability upon association.
516 pAd->CommonCfg.TxPreamble = Preamble;
518 MlmeSetTxPreamble(pAd, Rt802_11PreambleLong);
520 default: //Invalid argument
524 DBGPRINT(RT_DEBUG_TRACE, ("Set_TxPreamble_Proc::(TxPreamble=%ld)\n", pAd->CommonCfg.TxPreamble));
530 ==========================================================================
534 TRUE if all parameters are OK, FALSE otherwise
535 ==========================================================================
537 INT Set_RTSThreshold_Proc(
538 IN PRTMP_ADAPTER pAd,
541 NDIS_802_11_RTS_THRESHOLD RtsThresh;
543 RtsThresh = simple_strtol(arg, 0, 10);
545 if((RtsThresh > 0) && (RtsThresh <= MAX_RTS_THRESHOLD))
546 pAd->CommonCfg.RtsThreshold = (USHORT)RtsThresh;
547 else if (RtsThresh == 0)
548 pAd->CommonCfg.RtsThreshold = MAX_RTS_THRESHOLD;
550 return FALSE; //Invalid argument
552 DBGPRINT(RT_DEBUG_TRACE, ("Set_RTSThreshold_Proc::(RTSThreshold=%d)\n", pAd->CommonCfg.RtsThreshold));
558 ==========================================================================
560 Set Fragment Threshold
562 TRUE if all parameters are OK, FALSE otherwise
563 ==========================================================================
565 INT Set_FragThreshold_Proc(
566 IN PRTMP_ADAPTER pAd,
569 NDIS_802_11_FRAGMENTATION_THRESHOLD FragThresh;
571 FragThresh = simple_strtol(arg, 0, 10);
573 if (FragThresh > MAX_FRAG_THRESHOLD || FragThresh < MIN_FRAG_THRESHOLD)
575 //Illegal FragThresh so we set it to default
576 pAd->CommonCfg.FragmentThreshold = MAX_FRAG_THRESHOLD;
578 else if (FragThresh % 2 == 1)
580 // The length of each fragment shall always be an even number of octets, except for the last fragment
581 // of an MSDU or MMPDU, which may be either an even or an odd number of octets.
582 pAd->CommonCfg.FragmentThreshold = (USHORT)(FragThresh - 1);
586 pAd->CommonCfg.FragmentThreshold = (USHORT)FragThresh;
590 if (pAd->CommonCfg.FragmentThreshold == MAX_FRAG_THRESHOLD)
591 pAd->CommonCfg.bUseZeroToDisableFragment = TRUE;
593 pAd->CommonCfg.bUseZeroToDisableFragment = FALSE;
596 DBGPRINT(RT_DEBUG_TRACE, ("Set_FragThreshold_Proc::(FragThreshold=%d)\n", pAd->CommonCfg.FragmentThreshold));
602 ==========================================================================
606 TRUE if all parameters are OK, FALSE otherwise
607 ==========================================================================
609 INT Set_TxBurst_Proc(
610 IN PRTMP_ADAPTER pAd,
615 TxBurst = simple_strtol(arg, 0, 10);
617 pAd->CommonCfg.bEnableTxBurst = TRUE;
618 else if (TxBurst == 0)
619 pAd->CommonCfg.bEnableTxBurst = FALSE;
621 return FALSE; //Invalid argument
623 DBGPRINT(RT_DEBUG_TRACE, ("Set_TxBurst_Proc::(TxBurst=%d)\n", pAd->CommonCfg.bEnableTxBurst));
628 #ifdef AGGREGATION_SUPPORT
630 ==========================================================================
634 TRUE if all parameters are OK, FALSE otherwise
635 ==========================================================================
637 INT Set_PktAggregate_Proc(
638 IN PRTMP_ADAPTER pAd,
643 aggre = simple_strtol(arg, 0, 10);
646 pAd->CommonCfg.bAggregationCapable = TRUE;
648 pAd->CommonCfg.bAggregationCapable = FALSE;
650 return FALSE; //Invalid argument
653 DBGPRINT(RT_DEBUG_TRACE, ("Set_PktAggregate_Proc::(AGGRE=%d)\n", pAd->CommonCfg.bAggregationCapable));
660 ==========================================================================
663 This parameter is 1 when needs radar detection, otherwise 0
665 TRUE if all parameters are OK, FALSE otherwise
666 ==========================================================================
668 INT Set_IEEE80211H_Proc(
669 IN PRTMP_ADAPTER pAd,
674 ieee80211h = simple_strtol(arg, 0, 10);
677 pAd->CommonCfg.bIEEE80211H = TRUE;
678 else if (ieee80211h == 0)
679 pAd->CommonCfg.bIEEE80211H = FALSE;
681 return FALSE; //Invalid argument
683 DBGPRINT(RT_DEBUG_TRACE, ("Set_IEEE80211H_Proc::(IEEE80211H=%d)\n", pAd->CommonCfg.bIEEE80211H));
691 ==========================================================================
693 For Debug information
695 TRUE if all parameters are OK, FALSE otherwise
696 ==========================================================================
699 IN PRTMP_ADAPTER pAd,
702 DBGPRINT(RT_DEBUG_TRACE, ("==> Set_Debug_Proc *******************\n"));
704 if(simple_strtol(arg, 0, 10) <= RT_DEBUG_LOUD)
705 RTDebugLevel = simple_strtol(arg, 0, 10);
707 DBGPRINT(RT_DEBUG_TRACE, ("<== Set_Debug_Proc(RTDebugLevel = %ld)\n", RTDebugLevel));
713 INT Show_DescInfo_Proc(
714 IN PRTMP_ADAPTER pAd,
720 PRT28XX_RXD_STRUC pRxD;
722 PRTMP_TX_RING pTxRing = &pAd->TxRing[QueIdx];
723 PRTMP_MGMT_RING pMgmtRing = &pAd->MgmtRing;
724 PRTMP_RX_RING pRxRing = &pAd->RxRing;
726 for(i=0;i<TX_RING_SIZE;i++)
728 pTxD = (PTXD_STRUC) pTxRing->Cell[i].AllocVa;
729 DBGPRINT(RT_DEBUG_OFF, ("Desc #%d\n",i));
730 hex_dump("Tx Descriptor", (PUCHAR)pTxD, 16);
731 DBGPRINT(RT_DEBUG_OFF, ("pTxD->DMADONE = %x\n", pTxD->DMADONE));
733 DBGPRINT(RT_DEBUG_OFF, ("---------------------------------------------------\n"));
734 for(i=0;i<MGMT_RING_SIZE;i++)
736 pTxD = (PTXD_STRUC) pMgmtRing->Cell[i].AllocVa;
737 DBGPRINT(RT_DEBUG_OFF, ("Desc #%d\n",i));
738 hex_dump("Mgmt Descriptor", (PUCHAR)pTxD, 16);
739 DBGPRINT(RT_DEBUG_OFF, ("pMgmt->DMADONE = %x\n", pTxD->DMADONE));
741 DBGPRINT(RT_DEBUG_OFF, ("---------------------------------------------------\n"));
742 for(i=0;i<RX_RING_SIZE;i++)
744 pRxD = (PRT28XX_RXD_STRUC) pRxRing->Cell[i].AllocVa;
745 DBGPRINT(RT_DEBUG_OFF, ("Desc #%d\n",i));
746 hex_dump("Rx Descriptor", (PUCHAR)pRxD, 16);
747 DBGPRINT(RT_DEBUG_OFF, ("pRxD->DDONE = %x\n", pRxD->DDONE));
749 #endif // RTMP_MAC_PCI //
755 ==========================================================================
757 Reset statistics counter
760 pAdapter Pointer to our adapter
764 TRUE if all parameters are OK, FALSE otherwise
765 ==========================================================================
767 INT Set_ResetStatCounter_Proc(
768 IN PRTMP_ADAPTER pAd,
772 //MAC_TABLE_ENTRY *pEntry;
774 DBGPRINT(RT_DEBUG_TRACE, ("==>Set_ResetStatCounter_Proc\n"));
776 // add the most up-to-date h/w raw counters into software counters
777 NICUpdateRawCounters(pAd);
779 NdisZeroMemory(&pAd->WlanCounters, sizeof(COUNTER_802_11));
780 NdisZeroMemory(&pAd->Counters8023, sizeof(COUNTER_802_3));
781 NdisZeroMemory(&pAd->RalinkCounters, sizeof(COUNTER_RALINK));
783 // Reset HotSpot counter
790 ========================================================================
794 In Adhoc WPANONE, bPairwise = 0; KeyIdx = 0;
797 pAd Pointer to our adapter
798 pBuf Pointer to the where the key stored
801 NDIS_SUCCESS Add key successfully
803 IRQL = DISPATCH_LEVEL
807 ========================================================================
810 BOOLEAN RTMPCheckStrPrintAble(
816 for (i=0; i<strLen; i++)
818 if ((pInPutStr[i] < 0x21) ||
819 (pInPutStr[i] > 0x7E))
827 ========================================================================
830 Remove WPA Key process
833 pAd Pointer to our adapter
834 pBuf Pointer to the where the key stored
837 NDIS_SUCCESS Add key successfully
839 IRQL = DISPATCH_LEVEL
843 ========================================================================
845 VOID RTMPSetDesiredRates(
846 IN PRTMP_ADAPTER pAdapter,
849 NDIS_802_11_RATES aryRates;
851 memset(&aryRates, 0x00, sizeof(NDIS_802_11_RATES));
852 switch (pAdapter->CommonCfg.PhyMode)
854 case PHY_11A: // A only
858 aryRates[0] = 0x0c; // 6M
859 pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_0;
862 aryRates[0] = 0x12; // 9M
863 pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_1;
866 aryRates[0] = 0x18; // 12M
867 pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_2;
870 aryRates[0] = 0x24; // 18M
871 pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_3;
874 aryRates[0] = 0x30; // 24M
875 pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_4;
878 aryRates[0] = 0x48; // 36M
879 pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_5;
882 aryRates[0] = 0x60; // 48M
883 pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_6;
886 aryRates[0] = 0x6c; // 54M
887 pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_7;
891 aryRates[0] = 0x6c; // 54Mbps
892 aryRates[1] = 0x60; // 48Mbps
893 aryRates[2] = 0x48; // 36Mbps
894 aryRates[3] = 0x30; // 24Mbps
895 aryRates[4] = 0x24; // 18M
896 aryRates[5] = 0x18; // 12M
897 aryRates[6] = 0x12; // 9M
898 aryRates[7] = 0x0c; // 6M
899 pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_AUTO;
903 case PHY_11BG_MIXED: // B/G Mixed
904 case PHY_11B: // B only
905 case PHY_11ABG_MIXED: // A/B/G Mixed
911 pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_0;
915 pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_1;
918 aryRates[0] = 0x0b; // 5.5M
919 pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_2;
922 aryRates[0] = 0x16; // 11M
923 pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_3;
926 aryRates[0] = 0x0c; // 6M
927 pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_0;
930 aryRates[0] = 0x12; // 9M
931 pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_1;
934 aryRates[0] = 0x18; // 12M
935 pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_2;
938 aryRates[0] = 0x24; // 18M
939 pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_3;
942 aryRates[0] = 0x30; // 24M
943 pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_4;
946 aryRates[0] = 0x48; // 36M
947 pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_5;
950 aryRates[0] = 0x60; // 48M
951 pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_6;
954 aryRates[0] = 0x6c; // 54M
955 pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_7;
959 if (pAdapter->CommonCfg.PhyMode == PHY_11B)
961 aryRates[0] = 0x16; // 11Mbps
962 aryRates[1] = 0x0b; // 5.5Mbps
963 aryRates[2] = 0x04; // 2Mbps
964 aryRates[3] = 0x02; // 1Mbps
967 { //(B/G) Mixed or (A/B/G) Mixed
968 aryRates[0] = 0x6c; // 54Mbps
969 aryRates[1] = 0x60; // 48Mbps
970 aryRates[2] = 0x48; // 36Mbps
971 aryRates[3] = 0x30; // 24Mbps
972 aryRates[4] = 0x16; // 11Mbps
973 aryRates[5] = 0x0b; // 5.5Mbps
974 aryRates[6] = 0x04; // 2Mbps
975 aryRates[7] = 0x02; // 1Mbps
977 pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_AUTO;
983 NdisZeroMemory(pAdapter->CommonCfg.DesireRate, MAX_LEN_OF_SUPPORTED_RATES);
984 NdisMoveMemory(pAdapter->CommonCfg.DesireRate, &aryRates, sizeof(NDIS_802_11_RATES));
985 DBGPRINT(RT_DEBUG_TRACE, (" RTMPSetDesiredRates (%02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x)\n",
986 pAdapter->CommonCfg.DesireRate[0],pAdapter->CommonCfg.DesireRate[1],
987 pAdapter->CommonCfg.DesireRate[2],pAdapter->CommonCfg.DesireRate[3],
988 pAdapter->CommonCfg.DesireRate[4],pAdapter->CommonCfg.DesireRate[5],
989 pAdapter->CommonCfg.DesireRate[6],pAdapter->CommonCfg.DesireRate[7] ));
990 // Changing DesiredRate may affect the MAX TX rate we used to TX frames out
991 MlmeUpdateTxRates(pAdapter, FALSE, 0);
994 NDIS_STATUS RTMPWPARemoveKeyProc(
995 IN PRTMP_ADAPTER pAd,
998 PNDIS_802_11_REMOVE_KEY pKey;
1000 NDIS_STATUS Status = NDIS_STATUS_FAILURE;
1001 BOOLEAN bTxKey; // Set the key as transmit key
1002 BOOLEAN bPairwise; // Indicate the key is pairwise key
1003 BOOLEAN bKeyRSC; // indicate the receive SC set by KeyRSC value.
1004 // Otherwise, it will set by the NIC.
1005 BOOLEAN bAuthenticator; // indicate key is set by authenticator.
1008 DBGPRINT(RT_DEBUG_TRACE,("---> RTMPWPARemoveKeyProc\n"));
1010 pKey = (PNDIS_802_11_REMOVE_KEY) pBuf;
1011 KeyIdx = pKey->KeyIndex & 0xff;
1012 // Bit 31 of Add-key, Tx Key
1013 bTxKey = (pKey->KeyIndex & 0x80000000) ? TRUE : FALSE;
1014 // Bit 30 of Add-key PairwiseKey
1015 bPairwise = (pKey->KeyIndex & 0x40000000) ? TRUE : FALSE;
1016 // Bit 29 of Add-key KeyRSC
1017 bKeyRSC = (pKey->KeyIndex & 0x20000000) ? TRUE : FALSE;
1018 // Bit 28 of Add-key Authenticator
1019 bAuthenticator = (pKey->KeyIndex & 0x10000000) ? TRUE : FALSE;
1021 // 1. If bTx is TRUE, return failure information
1023 return(NDIS_STATUS_INVALID_DATA);
1025 // 2. Check Pairwise Key
1028 // a. If BSSID is broadcast, remove all pairwise keys.
1029 // b. If not broadcast, remove the pairwise specified by BSSID
1030 for (i = 0; i < SHARE_KEY_NUM; i++)
1032 if (MAC_ADDR_EQUAL(pAd->SharedKey[BSS0][i].BssId, pKey->BSSID))
1034 DBGPRINT(RT_DEBUG_TRACE,("RTMPWPARemoveKeyProc(KeyIdx=%d)\n", i));
1035 pAd->SharedKey[BSS0][i].KeyLen = 0;
1036 pAd->SharedKey[BSS0][i].CipherAlg = CIPHER_NONE;
1037 AsicRemoveSharedKeyEntry(pAd, BSS0, (UCHAR)i);
1038 Status = NDIS_STATUS_SUCCESS;
1046 // a. If BSSID is broadcast, remove all group keys indexed
1047 // b. If BSSID matched, delete the group key indexed.
1048 DBGPRINT(RT_DEBUG_TRACE,("RTMPWPARemoveKeyProc(KeyIdx=%ld)\n", KeyIdx));
1049 pAd->SharedKey[BSS0][KeyIdx].KeyLen = 0;
1050 pAd->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_NONE;
1051 AsicRemoveSharedKeyEntry(pAd, BSS0, (UCHAR)KeyIdx);
1052 Status = NDIS_STATUS_SUCCESS;
1059 ========================================================================
1061 Routine Description:
1065 pAd Pointer to our adapter
1070 IRQL = DISPATCH_LEVEL
1074 ========================================================================
1076 VOID RTMPWPARemoveAllKeys(
1077 IN PRTMP_ADAPTER pAd)
1082 DBGPRINT(RT_DEBUG_TRACE,("RTMPWPARemoveAllKeys(AuthMode=%d, WepStatus=%d)\n", pAd->StaCfg.AuthMode, pAd->StaCfg.WepStatus));
1083 RTMP_CLEAR_PSFLAG(pAd, fRTMP_PS_CAN_GO_SLEEP);
1084 // For WEP/CKIP, there is no need to remove it, since WinXP won't set it again after
1085 // Link up. And it will be replaced if user changed it.
1086 if (pAd->StaCfg.AuthMode < Ndis802_11AuthModeWPA)
1089 // For WPA-None, there is no need to remove it, since WinXP won't set it again after
1090 // Link up. And it will be replaced if user changed it.
1091 if (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPANone)
1094 // set BSSID wcid entry of the Pair-wise Key table as no-security mode
1095 AsicRemovePairwiseKeyEntry(pAd, BSS0, BSSID_WCID);
1097 // set all shared key mode as no-security.
1098 for (i = 0; i < SHARE_KEY_NUM; i++)
1100 DBGPRINT(RT_DEBUG_TRACE,("remove %s key #%d\n", CipherName[pAd->SharedKey[BSS0][i].CipherAlg], i));
1101 NdisZeroMemory(&pAd->SharedKey[BSS0][i], sizeof(CIPHER_KEY));
1103 AsicRemoveSharedKeyEntry(pAd, BSS0, i);
1105 RTMP_SET_PSFLAG(pAd, fRTMP_PS_CAN_GO_SLEEP);
1110 ========================================================================
1112 Routine Description:
1113 As STA's BSSID is a WC too, it uses shared key table.
1114 This function write correct unicast TX key to ASIC WCID.
1115 And we still make a copy in our MacTab.Content[BSSID_WCID].PairwiseKey.
1116 Caller guarantee TKIP/AES always has keyidx = 0. (pairwise key)
1117 Caller guarantee WEP calls this function when set Txkey, default key index=0~3.
1120 pAd Pointer to our adapter
1121 pKey Pointer to the where the key stored
1124 NDIS_SUCCESS Add key successfully
1126 IRQL = DISPATCH_LEVEL
1130 ========================================================================
1133 ========================================================================
1134 Routine Description:
1135 Change NIC PHY mode. Re-association may be necessary. possible settings
1136 include - PHY_11B, PHY_11BG_MIXED, PHY_11A, and PHY_11ABG_MIXED
1139 pAd - Pointer to our adapter
1142 IRQL = PASSIVE_LEVEL
1143 IRQL = DISPATCH_LEVEL
1145 ========================================================================
1147 VOID RTMPSetPhyMode(
1148 IN PRTMP_ADAPTER pAd,
1152 // the selected phymode must be supported by the RF IC encoded in E2PROM
1154 // if no change, do nothing
1156 if (pAd->CommonCfg.PhyMode == phymode)
1159 pAd->CommonCfg.PhyMode = (UCHAR)phymode;
1161 DBGPRINT(RT_DEBUG_TRACE,("RTMPSetPhyMode : PhyMode=%d, channel=%d \n", pAd->CommonCfg.PhyMode, pAd->CommonCfg.Channel));
1163 BuildChannelList(pAd);
1165 // sanity check user setting
1166 for (i = 0; i < pAd->ChannelListNum; i++)
1168 if (pAd->CommonCfg.Channel == pAd->ChannelList[i].Channel)
1172 if (i == pAd->ChannelListNum)
1174 pAd->CommonCfg.Channel = FirstChannel(pAd);
1175 DBGPRINT(RT_DEBUG_ERROR, ("RTMPSetPhyMode: channel is out of range, use first channel=%d \n", pAd->CommonCfg.Channel));
1178 NdisZeroMemory(pAd->CommonCfg.SupRate, MAX_LEN_OF_SUPPORTED_RATES);
1179 NdisZeroMemory(pAd->CommonCfg.ExtRate, MAX_LEN_OF_SUPPORTED_RATES);
1180 NdisZeroMemory(pAd->CommonCfg.DesireRate, MAX_LEN_OF_SUPPORTED_RATES);
1183 pAd->CommonCfg.SupRate[0] = 0x82; // 1 mbps, in units of 0.5 Mbps, basic rate
1184 pAd->CommonCfg.SupRate[1] = 0x84; // 2 mbps, in units of 0.5 Mbps, basic rate
1185 pAd->CommonCfg.SupRate[2] = 0x8B; // 5.5 mbps, in units of 0.5 Mbps, basic rate
1186 pAd->CommonCfg.SupRate[3] = 0x96; // 11 mbps, in units of 0.5 Mbps, basic rate
1187 pAd->CommonCfg.SupRateLen = 4;
1188 pAd->CommonCfg.ExtRateLen = 0;
1189 pAd->CommonCfg.DesireRate[0] = 2; // 1 mbps, in units of 0.5 Mbps
1190 pAd->CommonCfg.DesireRate[1] = 4; // 2 mbps, in units of 0.5 Mbps
1191 pAd->CommonCfg.DesireRate[2] = 11; // 5.5 mbps, in units of 0.5 Mbps
1192 pAd->CommonCfg.DesireRate[3] = 22; // 11 mbps, in units of 0.5 Mbps
1193 //pAd->CommonCfg.HTPhyMode.field.MODE = MODE_CCK; // This MODE is only FYI. not use
1197 case PHY_11BG_MIXED:
1198 case PHY_11ABG_MIXED:
1200 case PHY_11ABGN_MIXED:
1201 case PHY_11BGN_MIXED:
1202 case PHY_11GN_MIXED:
1203 pAd->CommonCfg.SupRate[0] = 0x82; // 1 mbps, in units of 0.5 Mbps, basic rate
1204 pAd->CommonCfg.SupRate[1] = 0x84; // 2 mbps, in units of 0.5 Mbps, basic rate
1205 pAd->CommonCfg.SupRate[2] = 0x8B; // 5.5 mbps, in units of 0.5 Mbps, basic rate
1206 pAd->CommonCfg.SupRate[3] = 0x96; // 11 mbps, in units of 0.5 Mbps, basic rate
1207 pAd->CommonCfg.SupRate[4] = 0x12; // 9 mbps, in units of 0.5 Mbps
1208 pAd->CommonCfg.SupRate[5] = 0x24; // 18 mbps, in units of 0.5 Mbps
1209 pAd->CommonCfg.SupRate[6] = 0x48; // 36 mbps, in units of 0.5 Mbps
1210 pAd->CommonCfg.SupRate[7] = 0x6c; // 54 mbps, in units of 0.5 Mbps
1211 pAd->CommonCfg.SupRateLen = 8;
1212 pAd->CommonCfg.ExtRate[0] = 0x0C; // 6 mbps, in units of 0.5 Mbps
1213 pAd->CommonCfg.ExtRate[1] = 0x18; // 12 mbps, in units of 0.5 Mbps
1214 pAd->CommonCfg.ExtRate[2] = 0x30; // 24 mbps, in units of 0.5 Mbps
1215 pAd->CommonCfg.ExtRate[3] = 0x60; // 48 mbps, in units of 0.5 Mbps
1216 pAd->CommonCfg.ExtRateLen = 4;
1217 pAd->CommonCfg.DesireRate[0] = 2; // 1 mbps, in units of 0.5 Mbps
1218 pAd->CommonCfg.DesireRate[1] = 4; // 2 mbps, in units of 0.5 Mbps
1219 pAd->CommonCfg.DesireRate[2] = 11; // 5.5 mbps, in units of 0.5 Mbps
1220 pAd->CommonCfg.DesireRate[3] = 22; // 11 mbps, in units of 0.5 Mbps
1221 pAd->CommonCfg.DesireRate[4] = 12; // 6 mbps, in units of 0.5 Mbps
1222 pAd->CommonCfg.DesireRate[5] = 18; // 9 mbps, in units of 0.5 Mbps
1223 pAd->CommonCfg.DesireRate[6] = 24; // 12 mbps, in units of 0.5 Mbps
1224 pAd->CommonCfg.DesireRate[7] = 36; // 18 mbps, in units of 0.5 Mbps
1225 pAd->CommonCfg.DesireRate[8] = 48; // 24 mbps, in units of 0.5 Mbps
1226 pAd->CommonCfg.DesireRate[9] = 72; // 36 mbps, in units of 0.5 Mbps
1227 pAd->CommonCfg.DesireRate[10] = 96; // 48 mbps, in units of 0.5 Mbps
1228 pAd->CommonCfg.DesireRate[11] = 108; // 54 mbps, in units of 0.5 Mbps
1232 case PHY_11AN_MIXED:
1233 case PHY_11AGN_MIXED:
1235 pAd->CommonCfg.SupRate[0] = 0x8C; // 6 mbps, in units of 0.5 Mbps, basic rate
1236 pAd->CommonCfg.SupRate[1] = 0x12; // 9 mbps, in units of 0.5 Mbps
1237 pAd->CommonCfg.SupRate[2] = 0x98; // 12 mbps, in units of 0.5 Mbps, basic rate
1238 pAd->CommonCfg.SupRate[3] = 0x24; // 18 mbps, in units of 0.5 Mbps
1239 pAd->CommonCfg.SupRate[4] = 0xb0; // 24 mbps, in units of 0.5 Mbps, basic rate
1240 pAd->CommonCfg.SupRate[5] = 0x48; // 36 mbps, in units of 0.5 Mbps
1241 pAd->CommonCfg.SupRate[6] = 0x60; // 48 mbps, in units of 0.5 Mbps
1242 pAd->CommonCfg.SupRate[7] = 0x6c; // 54 mbps, in units of 0.5 Mbps
1243 pAd->CommonCfg.SupRateLen = 8;
1244 pAd->CommonCfg.ExtRateLen = 0;
1245 pAd->CommonCfg.DesireRate[0] = 12; // 6 mbps, in units of 0.5 Mbps
1246 pAd->CommonCfg.DesireRate[1] = 18; // 9 mbps, in units of 0.5 Mbps
1247 pAd->CommonCfg.DesireRate[2] = 24; // 12 mbps, in units of 0.5 Mbps
1248 pAd->CommonCfg.DesireRate[3] = 36; // 18 mbps, in units of 0.5 Mbps
1249 pAd->CommonCfg.DesireRate[4] = 48; // 24 mbps, in units of 0.5 Mbps
1250 pAd->CommonCfg.DesireRate[5] = 72; // 36 mbps, in units of 0.5 Mbps
1251 pAd->CommonCfg.DesireRate[6] = 96; // 48 mbps, in units of 0.5 Mbps
1252 pAd->CommonCfg.DesireRate[7] = 108; // 54 mbps, in units of 0.5 Mbps
1253 //pAd->CommonCfg.HTPhyMode.field.MODE = MODE_OFDM; // This MODE is only FYI. not use
1261 pAd->CommonCfg.BandState = UNKNOWN_BAND;
1265 ========================================================================
1266 Routine Description:
1267 Caller ensures we has 802.11n support.
1268 Calls at setting HT from AP/STASetinformation
1271 pAd - Pointer to our adapter
1274 ========================================================================
1277 IN PRTMP_ADAPTER pAd,
1278 IN OID_SET_HT_PHYMODE *pHTPhyMode)
1283 UCHAR BBP3Value = 0;
1284 UCHAR RxStream = pAd->CommonCfg.RxStream;
1286 DBGPRINT(RT_DEBUG_TRACE, ("RTMPSetHT : HT_mode(%d), ExtOffset(%d), MCS(%d), BW(%d), STBC(%d), SHORTGI(%d)\n",
1287 pHTPhyMode->HtMode, pHTPhyMode->ExtOffset,
1288 pHTPhyMode->MCS, pHTPhyMode->BW,
1289 pHTPhyMode->STBC, pHTPhyMode->SHORTGI));
1291 // Don't zero supportedHyPhy structure.
1292 RTMPZeroMemory(&pAd->CommonCfg.HtCapability, sizeof(pAd->CommonCfg.HtCapability));
1293 RTMPZeroMemory(&pAd->CommonCfg.AddHTInfo, sizeof(pAd->CommonCfg.AddHTInfo));
1294 RTMPZeroMemory(&pAd->CommonCfg.NewExtChanOffset, sizeof(pAd->CommonCfg.NewExtChanOffset));
1295 RTMPZeroMemory(&pAd->CommonCfg.DesiredHtPhy, sizeof(pAd->CommonCfg.DesiredHtPhy));
1297 if (pAd->CommonCfg.bRdg)
1299 pAd->CommonCfg.HtCapability.ExtHtCapInfo.PlusHTC = 1;
1300 pAd->CommonCfg.HtCapability.ExtHtCapInfo.RDGSupport = 1;
1304 pAd->CommonCfg.HtCapability.ExtHtCapInfo.PlusHTC = 0;
1305 pAd->CommonCfg.HtCapability.ExtHtCapInfo.RDGSupport = 0;
1308 pAd->CommonCfg.HtCapability.HtCapParm.MaxRAmpduFactor = 3;
1309 pAd->CommonCfg.DesiredHtPhy.MaxRAmpduFactor = 3;
1311 DBGPRINT(RT_DEBUG_TRACE, ("RTMPSetHT : RxBAWinLimit = %d\n", pAd->CommonCfg.BACapability.field.RxBAWinLimit));
1313 // Mimo power save, A-MSDU size,
1314 pAd->CommonCfg.DesiredHtPhy.AmsduEnable = (USHORT)pAd->CommonCfg.BACapability.field.AmsduEnable;
1315 pAd->CommonCfg.DesiredHtPhy.AmsduSize = (UCHAR)pAd->CommonCfg.BACapability.field.AmsduSize;
1316 pAd->CommonCfg.DesiredHtPhy.MimoPs = (UCHAR)pAd->CommonCfg.BACapability.field.MMPSmode;
1317 pAd->CommonCfg.DesiredHtPhy.MpduDensity = (UCHAR)pAd->CommonCfg.BACapability.field.MpduDensity;
1319 pAd->CommonCfg.HtCapability.HtCapInfo.AMsduSize = (USHORT)pAd->CommonCfg.BACapability.field.AmsduSize;
1320 pAd->CommonCfg.HtCapability.HtCapInfo.MimoPs = (USHORT)pAd->CommonCfg.BACapability.field.MMPSmode;
1321 pAd->CommonCfg.HtCapability.HtCapParm.MpduDensity = (UCHAR)pAd->CommonCfg.BACapability.field.MpduDensity;
1323 DBGPRINT(RT_DEBUG_TRACE, ("RTMPSetHT : AMsduSize = %d, MimoPs = %d, MpduDensity = %d, MaxRAmpduFactor = %d\n",
1324 pAd->CommonCfg.DesiredHtPhy.AmsduSize,
1325 pAd->CommonCfg.DesiredHtPhy.MimoPs,
1326 pAd->CommonCfg.DesiredHtPhy.MpduDensity,
1327 pAd->CommonCfg.DesiredHtPhy.MaxRAmpduFactor));
1329 if(pHTPhyMode->HtMode == HTMODE_GF)
1331 pAd->CommonCfg.HtCapability.HtCapInfo.GF = 1;
1332 pAd->CommonCfg.DesiredHtPhy.GF = 1;
1335 pAd->CommonCfg.DesiredHtPhy.GF = 0;
1341 pAd->CommonCfg.HtCapability.MCSSet[0] = 0xff;
1342 pAd->CommonCfg.HtCapability.MCSSet[1] = 0x00;
1346 pAd->CommonCfg.HtCapability.MCSSet[0] = 0xff;
1347 pAd->CommonCfg.HtCapability.MCSSet[1] = 0xff;
1351 pAd->CommonCfg.HtCapability.MCSSet[0] = 0xff;
1352 pAd->CommonCfg.HtCapability.MCSSet[1] = 0xff;
1353 pAd->CommonCfg.HtCapability.MCSSet[2] = 0xff;
1357 if (pAd->CommonCfg.bForty_Mhz_Intolerant && (pAd->CommonCfg.Channel <= 14) && (pHTPhyMode->BW == BW_40) )
1359 pHTPhyMode->BW = BW_20;
1360 pAd->CommonCfg.HtCapability.HtCapInfo.Forty_Mhz_Intolerant = 1;
1363 if(pHTPhyMode->BW == BW_40)
1365 pAd->CommonCfg.HtCapability.MCSSet[4] = 0x1; // MCS 32
1366 pAd->CommonCfg.HtCapability.HtCapInfo.ChannelWidth = 1;
1367 if (pAd->CommonCfg.Channel <= 14)
1368 pAd->CommonCfg.HtCapability.HtCapInfo.CCKmodein40 = 1;
1370 pAd->CommonCfg.DesiredHtPhy.ChannelWidth = 1;
1371 pAd->CommonCfg.AddHTInfo.AddHtInfo.RecomWidth = 1;
1372 pAd->CommonCfg.AddHTInfo.AddHtInfo.ExtChanOffset = (pHTPhyMode->ExtOffset == EXTCHA_BELOW)? (EXTCHA_BELOW): EXTCHA_ABOVE;
1373 // Set Regsiter for extension channel position.
1374 RTMP_IO_READ32(pAd, TX_BAND_CFG, &Value);
1375 RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &BBP3Value);
1376 if ((pHTPhyMode->ExtOffset == EXTCHA_BELOW))
1379 BBP3Value |= (0x20);
1380 RTMP_IO_WRITE32(pAd, TX_BAND_CFG, Value);
1382 else if ((pHTPhyMode->ExtOffset == EXTCHA_ABOVE))
1385 BBP3Value &= (~0x20);
1386 RTMP_IO_WRITE32(pAd, TX_BAND_CFG, Value);
1389 // Turn on BBP 40MHz mode now only as AP .
1390 // Sta can turn on BBP 40MHz after connection with 40MHz AP. Sta only broadcast 40MHz capability before connection.
1391 if ((pAd->OpMode == OPMODE_AP) || INFRA_ON(pAd) || ADHOC_ON(pAd)
1394 RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &BBPValue);
1395 BBPValue &= (~0x18);
1397 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, BBPValue);
1399 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, BBP3Value);
1400 pAd->CommonCfg.BBPCurrentBW = BW_40;
1405 pAd->CommonCfg.HtCapability.HtCapInfo.ChannelWidth = 0;
1406 pAd->CommonCfg.DesiredHtPhy.ChannelWidth = 0;
1407 pAd->CommonCfg.AddHTInfo.AddHtInfo.RecomWidth = 0;
1408 pAd->CommonCfg.AddHTInfo.AddHtInfo.ExtChanOffset = EXTCHA_NONE;
1409 pAd->CommonCfg.CentralChannel = pAd->CommonCfg.Channel;
1410 // Turn on BBP 20MHz mode by request here.
1412 RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &BBPValue);
1413 BBPValue &= (~0x18);
1414 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, BBPValue);
1415 pAd->CommonCfg.BBPCurrentBW = BW_20;
1419 if(pHTPhyMode->STBC == STBC_USE)
1421 pAd->CommonCfg.HtCapability.HtCapInfo.TxSTBC = 1;
1422 pAd->CommonCfg.DesiredHtPhy.TxSTBC = 1;
1423 pAd->CommonCfg.HtCapability.HtCapInfo.RxSTBC = 1;
1424 pAd->CommonCfg.DesiredHtPhy.RxSTBC = 1;
1428 pAd->CommonCfg.DesiredHtPhy.TxSTBC = 0;
1429 pAd->CommonCfg.DesiredHtPhy.RxSTBC = 0;
1432 if(pHTPhyMode->SHORTGI == GI_400)
1434 pAd->CommonCfg.HtCapability.HtCapInfo.ShortGIfor20 = 1;
1435 pAd->CommonCfg.HtCapability.HtCapInfo.ShortGIfor40 = 1;
1436 pAd->CommonCfg.DesiredHtPhy.ShortGIfor20 = 1;
1437 pAd->CommonCfg.DesiredHtPhy.ShortGIfor40 = 1;
1441 pAd->CommonCfg.HtCapability.HtCapInfo.ShortGIfor20 = 0;
1442 pAd->CommonCfg.HtCapability.HtCapInfo.ShortGIfor40 = 0;
1443 pAd->CommonCfg.DesiredHtPhy.ShortGIfor20 = 0;
1444 pAd->CommonCfg.DesiredHtPhy.ShortGIfor40 = 0;
1447 // We support link adaptation for unsolicit MCS feedback, set to 2.
1448 pAd->CommonCfg.HtCapability.ExtHtCapInfo.MCSFeedback = MCSFBK_NONE; //MCSFBK_UNSOLICIT;
1449 pAd->CommonCfg.AddHTInfo.ControlChan = pAd->CommonCfg.Channel;
1450 // 1, the extension channel above the control channel.
1452 // EDCA parameters used for AP's own transmission
1453 if (pAd->CommonCfg.APEdcaParm.bValid == FALSE)
1455 pAd->CommonCfg.APEdcaParm.bValid = TRUE;
1456 pAd->CommonCfg.APEdcaParm.Aifsn[0] = 3;
1457 pAd->CommonCfg.APEdcaParm.Aifsn[1] = 7;
1458 pAd->CommonCfg.APEdcaParm.Aifsn[2] = 1;
1459 pAd->CommonCfg.APEdcaParm.Aifsn[3] = 1;
1461 pAd->CommonCfg.APEdcaParm.Cwmin[0] = 4;
1462 pAd->CommonCfg.APEdcaParm.Cwmin[1] = 4;
1463 pAd->CommonCfg.APEdcaParm.Cwmin[2] = 3;
1464 pAd->CommonCfg.APEdcaParm.Cwmin[3] = 2;
1466 pAd->CommonCfg.APEdcaParm.Cwmax[0] = 6;
1467 pAd->CommonCfg.APEdcaParm.Cwmax[1] = 10;
1468 pAd->CommonCfg.APEdcaParm.Cwmax[2] = 4;
1469 pAd->CommonCfg.APEdcaParm.Cwmax[3] = 3;
1471 pAd->CommonCfg.APEdcaParm.Txop[0] = 0;
1472 pAd->CommonCfg.APEdcaParm.Txop[1] = 0;
1473 pAd->CommonCfg.APEdcaParm.Txop[2] = 94;
1474 pAd->CommonCfg.APEdcaParm.Txop[3] = 47;
1476 AsicSetEdcaParm(pAd, &pAd->CommonCfg.APEdcaParm);
1479 RTMPSetIndividualHT(pAd, 0);
1485 ========================================================================
1486 Routine Description:
1487 Caller ensures we has 802.11n support.
1488 Calls at setting HT from AP/STASetinformation
1491 pAd - Pointer to our adapter
1494 ========================================================================
1496 VOID RTMPSetIndividualHT(
1497 IN PRTMP_ADAPTER pAd,
1500 PRT_HT_PHY_INFO pDesired_ht_phy = NULL;
1501 UCHAR TxStream = pAd->CommonCfg.TxStream;
1502 UCHAR DesiredMcs = MCS_AUTO;
1507 pDesired_ht_phy = &pAd->StaCfg.DesiredHtPhyInfo;
1508 DesiredMcs = pAd->StaCfg.DesiredTransmitSetting.field.MCS;
1509 //pAd->StaCfg.bAutoTxRateSwitch = (DesiredMcs == MCS_AUTO) ? TRUE : FALSE;
1514 if (pDesired_ht_phy == NULL)
1516 DBGPRINT(RT_DEBUG_ERROR, ("RTMPSetIndividualHT: invalid apidx(%d)\n", apidx));
1519 RTMPZeroMemory(pDesired_ht_phy, sizeof(RT_HT_PHY_INFO));
1521 DBGPRINT(RT_DEBUG_TRACE, ("RTMPSetIndividualHT : Desired MCS = %d\n", DesiredMcs));
1522 // Check the validity of MCS
1523 if ((TxStream == 1) && ((DesiredMcs >= MCS_8) && (DesiredMcs <= MCS_15)))
1525 DBGPRINT(RT_DEBUG_WARN, ("RTMPSetIndividualHT: MCS(%d) is invalid in 1S, reset it as MCS_7\n", DesiredMcs));
1529 if ((pAd->CommonCfg.DesiredHtPhy.ChannelWidth == BW_20) && (DesiredMcs == MCS_32))
1531 DBGPRINT(RT_DEBUG_WARN, ("RTMPSetIndividualHT: MCS_32 is only supported in 40-MHz, reset it as MCS_0\n"));
1535 pDesired_ht_phy->bHtEnable = TRUE;
1537 // Decide desired Tx MCS
1541 if (DesiredMcs == MCS_AUTO)
1543 pDesired_ht_phy->MCSSet[0]= 0xff;
1544 pDesired_ht_phy->MCSSet[1]= 0x00;
1546 else if (DesiredMcs <= MCS_7)
1548 pDesired_ht_phy->MCSSet[0]= 1<<DesiredMcs;
1549 pDesired_ht_phy->MCSSet[1]= 0x00;
1554 if (DesiredMcs == MCS_AUTO)
1556 pDesired_ht_phy->MCSSet[0]= 0xff;
1557 pDesired_ht_phy->MCSSet[1]= 0xff;
1559 else if (DesiredMcs <= MCS_15)
1563 mode = DesiredMcs / 8;
1565 pDesired_ht_phy->MCSSet[mode] = (1 << (DesiredMcs - mode * 8));
1570 if (DesiredMcs == MCS_AUTO)
1572 /* MCS0 ~ MCS23, 3 bytes */
1573 pDesired_ht_phy->MCSSet[0]= 0xff;
1574 pDesired_ht_phy->MCSSet[1]= 0xff;
1575 pDesired_ht_phy->MCSSet[2]= 0xff;
1577 else if (DesiredMcs <= MCS_23)
1581 mode = DesiredMcs / 8;
1583 pDesired_ht_phy->MCSSet[mode] = (1 << (DesiredMcs - mode * 8));
1588 if(pAd->CommonCfg.DesiredHtPhy.ChannelWidth == BW_40)
1590 if (DesiredMcs == MCS_AUTO || DesiredMcs == MCS_32)
1591 pDesired_ht_phy->MCSSet[4] = 0x1;
1594 // update HT Rate setting
1595 if (pAd->OpMode == OPMODE_STA)
1596 MlmeUpdateHtTxRates(pAd, BSS0);
1598 MlmeUpdateHtTxRates(pAd, apidx);
1603 ========================================================================
1604 Routine Description:
1605 Update HT IE from our capability.
1608 Send all HT IE in beacon/probe rsp/assoc rsp/action frame.
1611 ========================================================================
1613 VOID RTMPUpdateHTIE(
1614 IN RT_HT_CAPABILITY *pRtHt,
1616 OUT HT_CAPABILITY_IE *pHtCapability,
1617 OUT ADD_HT_INFO_IE *pAddHtInfo)
1619 RTMPZeroMemory(pHtCapability, sizeof(HT_CAPABILITY_IE));
1620 RTMPZeroMemory(pAddHtInfo, sizeof(ADD_HT_INFO_IE));
1622 pHtCapability->HtCapInfo.ChannelWidth = pRtHt->ChannelWidth;
1623 pHtCapability->HtCapInfo.MimoPs = pRtHt->MimoPs;
1624 pHtCapability->HtCapInfo.GF = pRtHt->GF;
1625 pHtCapability->HtCapInfo.ShortGIfor20 = pRtHt->ShortGIfor20;
1626 pHtCapability->HtCapInfo.ShortGIfor40 = pRtHt->ShortGIfor40;
1627 pHtCapability->HtCapInfo.TxSTBC = pRtHt->TxSTBC;
1628 pHtCapability->HtCapInfo.RxSTBC = pRtHt->RxSTBC;
1629 pHtCapability->HtCapInfo.AMsduSize = pRtHt->AmsduSize;
1630 pHtCapability->HtCapParm.MaxRAmpduFactor = pRtHt->MaxRAmpduFactor;
1631 pHtCapability->HtCapParm.MpduDensity = pRtHt->MpduDensity;
1633 pAddHtInfo->AddHtInfo.ExtChanOffset = pRtHt->ExtChanOffset ;
1634 pAddHtInfo->AddHtInfo.RecomWidth = pRtHt->RecomWidth;
1635 pAddHtInfo->AddHtInfo2.OperaionMode = pRtHt->OperaionMode;
1636 pAddHtInfo->AddHtInfo2.NonGfPresent = pRtHt->NonGfPresent;
1637 RTMPMoveMemory(pAddHtInfo->MCSSet, /*pRtHt->MCSSet*/pMcsSet, 4); // rt2860 only support MCS max=32, no need to copy all 16 uchar.
1639 DBGPRINT(RT_DEBUG_TRACE,("RTMPUpdateHTIE <== \n"));
1643 ========================================================================
1645 Add Client security information into ASIC WCID table and IVEIV table.
1647 ========================================================================
1649 VOID RTMPAddWcidAttributeEntry(
1650 IN PRTMP_ADAPTER pAd,
1654 IN MAC_TABLE_ENTRY *pEntry)
1656 UINT32 WCIDAttri = 0;
1665 DBGPRINT(RT_DEBUG_ERROR, ("RTMPAddWcidAttributeEntry: The BSS-index(%d) is out of range for Infra link. \n", BssIdx));
1669 // 1. In ADHOC mode, the AID is wcid number. And NO mesh link exists.
1670 // 2. In Infra mode, the AID:1 MUST be wcid of infra STA.
1671 // the AID:2~ assign to mesh link entry.
1679 // Update WCID attribute table
1680 offset = MAC_WCID_ATTRIBUTE_BASE + (Wcid * HW_WCID_ATTRI_SIZE);
1683 if (pEntry && pEntry->ValidAsMesh)
1684 WCIDAttri = (CipherAlg<<1) | PAIRWISEKEYTABLE;
1686 WCIDAttri = (CipherAlg<<1) | SHAREDKEYTABLE;
1689 RTMP_IO_WRITE32(pAd, offset, WCIDAttri);
1692 // Update IV/EIV table
1693 offset = MAC_IVEIV_TABLE_BASE + (Wcid * HW_IVEIV_ENTRY_SIZE);
1696 if ((CipherAlg == CIPHER_TKIP) || (CipherAlg == CIPHER_TKIP_NO_MIC) || (CipherAlg == CIPHER_AES))
1698 // Eiv bit on. keyid always is 0 for pairwise key
1699 IVEIV = (KeyIdx <<6) | 0x20;
1703 // WEP KeyIdx is default tx key.
1704 IVEIV = (KeyIdx << 6);
1707 // For key index and ext IV bit, so only need to update the position(offset+3).
1709 RTMP_IO_WRITE8(pAd, offset+3, IVEIV);
1710 #endif // RTMP_MAC_PCI //
1712 RTUSBMultiWrite_OneByte(pAd, offset+3, &IVEIV);
1713 #endif // RTMP_MAC_USB //
1715 DBGPRINT(RT_DEBUG_TRACE,("RTMPAddWcidAttributeEntry: WCID #%d, KeyIndex #%d, Alg=%s\n",Wcid, KeyIdx, CipherName[CipherAlg]));
1716 DBGPRINT(RT_DEBUG_TRACE,(" WCIDAttri = 0x%x \n", WCIDAttri));
1721 ==========================================================================
1723 Parse encryption type
1725 pAdapter Pointer to our adapter
1726 wrq Pointer to the ioctl argument
1732 ==========================================================================
1734 PSTRING GetEncryptType(CHAR enc)
1736 if(enc == Ndis802_11WEPDisabled)
1738 if(enc == Ndis802_11WEPEnabled)
1740 if(enc == Ndis802_11Encryption2Enabled)
1742 if(enc == Ndis802_11Encryption3Enabled)
1744 if(enc == Ndis802_11Encryption4Enabled)
1750 PSTRING GetAuthMode(CHAR auth)
1752 if(auth == Ndis802_11AuthModeOpen)
1754 if(auth == Ndis802_11AuthModeShared)
1756 if(auth == Ndis802_11AuthModeAutoSwitch)
1758 if(auth == Ndis802_11AuthModeWPA)
1760 if(auth == Ndis802_11AuthModeWPAPSK)
1762 if(auth == Ndis802_11AuthModeWPANone)
1764 if(auth == Ndis802_11AuthModeWPA2)
1766 if(auth == Ndis802_11AuthModeWPA2PSK)
1768 if(auth == Ndis802_11AuthModeWPA1WPA2)
1770 if(auth == Ndis802_11AuthModeWPA1PSKWPA2PSK)
1771 return "WPA1PSKWPA2PSK";
1777 ==========================================================================
1779 Get site survey results
1781 pAdapter Pointer to our adapter
1782 wrq Pointer to the ioctl argument
1789 1.) UI needs to wait 4 seconds after issue a site survey command
1790 2.) iwpriv ra0 get_site_survey
1791 3.) UI needs to prepare at least 4096bytes to get the results
1792 ==========================================================================
1794 #define LINE_LEN (4+33+20+23+9+7+7+3) // Channel+SSID+Bssid+Security+Signal+WiressMode+ExtCh+NetworkType
1795 VOID RTMPCommSiteSurveyData(
1800 UINT Rssi_Quality = 0;
1801 NDIS_802_11_NETWORK_TYPE wireless_mode;
1802 CHAR Ssid[MAX_LEN_OF_SSID +1];
1803 STRING SecurityStr[32] = {0};
1804 NDIS_802_11_ENCRYPTION_STATUS ap_cipher = Ndis802_11EncryptionDisabled;
1805 NDIS_802_11_AUTHENTICATION_MODE ap_auth_mode = Ndis802_11AuthModeOpen;
1807 memset(Ssid, 0 ,(MAX_LEN_OF_SSID +1));
1810 sprintf(msg+strlen(msg),"%-4d", pBss->Channel);
1812 memcpy(Ssid, pBss->Ssid, pBss->SsidLen);
1813 Ssid[pBss->SsidLen] = '\0';
1814 sprintf(msg+strlen(msg),"%-33s", Ssid);
1816 sprintf(msg+strlen(msg),"%02x:%02x:%02x:%02x:%02x:%02x ",
1825 if ((Ndis802_11AuthModeWPA <= pBss->AuthMode) &&
1826 (pBss->AuthMode <= Ndis802_11AuthModeWPA1PSKWPA2PSK))
1828 if (pBss->AuthModeAux == Ndis802_11AuthModeWPANone)
1830 ap_auth_mode = pBss->AuthMode;
1831 if (pBss->WPA.PairCipherAux == Ndis802_11WEPDisabled)
1832 ap_cipher = pBss->WPA.PairCipher;
1834 ap_cipher = Ndis802_11Encryption4Enabled;
1836 else if (pBss->AuthModeAux == Ndis802_11AuthModeOpen)
1838 ap_auth_mode = pBss->AuthMode;
1839 if ((ap_auth_mode == Ndis802_11AuthModeWPA) ||
1840 (ap_auth_mode == Ndis802_11AuthModeWPAPSK))
1842 if (pBss->WPA.PairCipherAux == Ndis802_11WEPDisabled)
1843 ap_cipher = pBss->WPA.PairCipher;
1845 ap_cipher = Ndis802_11Encryption4Enabled;
1847 else if ((ap_auth_mode == Ndis802_11AuthModeWPA2) ||
1848 (ap_auth_mode == Ndis802_11AuthModeWPA2PSK))
1850 if (pBss->WPA2.PairCipherAux == Ndis802_11WEPDisabled)
1851 ap_cipher = pBss->WPA2.PairCipher;
1853 ap_cipher = Ndis802_11Encryption4Enabled;
1856 else if ((pBss->AuthMode == Ndis802_11AuthModeWPAPSK) ||
1857 (pBss->AuthMode == Ndis802_11AuthModeWPA2PSK))
1859 if ((pBss->AuthModeAux == Ndis802_11AuthModeWPAPSK) ||
1860 (pBss->AuthModeAux == Ndis802_11AuthModeWPA2PSK))
1861 ap_auth_mode = Ndis802_11AuthModeWPA1PSKWPA2PSK;
1863 ap_auth_mode = pBss->AuthMode;
1865 if (pBss->WPA.PairCipher != pBss->WPA2.PairCipher)
1866 ap_cipher = Ndis802_11Encryption4Enabled;
1867 else if ((pBss->WPA.PairCipher == pBss->WPA2.PairCipher) &&
1868 (pBss->WPA.PairCipherAux != pBss->WPA2.PairCipherAux))
1869 ap_cipher = Ndis802_11Encryption4Enabled;
1870 else if ((pBss->WPA.PairCipher == pBss->WPA2.PairCipher) &&
1871 (pBss->WPA.PairCipherAux == pBss->WPA2.PairCipherAux) &&
1872 (pBss->WPA.PairCipherAux != Ndis802_11WEPDisabled))
1873 ap_cipher = Ndis802_11Encryption4Enabled;
1874 else if ((pBss->WPA.PairCipher == pBss->WPA2.PairCipher) &&
1875 (pBss->WPA.PairCipherAux == pBss->WPA2.PairCipherAux) &&
1876 (pBss->WPA.PairCipherAux == Ndis802_11WEPDisabled))
1877 ap_cipher = pBss->WPA.PairCipher;
1879 else if ((pBss->AuthMode == Ndis802_11AuthModeWPA) ||
1880 (pBss->AuthMode == Ndis802_11AuthModeWPA2))
1882 if ((pBss->AuthModeAux == Ndis802_11AuthModeWPA) ||
1883 (pBss->AuthMode == Ndis802_11AuthModeWPA2))
1884 ap_auth_mode = Ndis802_11AuthModeWPA1WPA2;
1886 ap_auth_mode = pBss->AuthMode;
1888 if (pBss->WPA.PairCipher != pBss->WPA2.PairCipher)
1889 ap_cipher = Ndis802_11Encryption4Enabled;
1890 else if ((pBss->WPA.PairCipher == pBss->WPA2.PairCipher) &&
1891 (pBss->WPA.PairCipherAux != pBss->WPA2.PairCipherAux))
1892 ap_cipher = Ndis802_11Encryption4Enabled;
1893 else if ((pBss->WPA.PairCipher == pBss->WPA2.PairCipher) &&
1894 (pBss->WPA.PairCipherAux == pBss->WPA2.PairCipherAux) &&
1895 (pBss->WPA.PairCipherAux != Ndis802_11WEPDisabled))
1896 ap_cipher = Ndis802_11Encryption4Enabled;
1897 else if ((pBss->WPA.PairCipher == pBss->WPA2.PairCipher) &&
1898 (pBss->WPA.PairCipherAux == pBss->WPA2.PairCipherAux) &&
1899 (pBss->WPA.PairCipherAux == Ndis802_11WEPDisabled))
1900 ap_cipher = pBss->WPA.PairCipher;
1903 sprintf(SecurityStr, "%s/%s", GetAuthMode((CHAR)ap_auth_mode), GetEncryptType((CHAR)ap_cipher));
1907 ap_auth_mode = pBss->AuthMode;
1908 ap_cipher = pBss->WepStatus;
1909 if (ap_cipher == Ndis802_11WEPDisabled)
1910 sprintf(SecurityStr, "NONE");
1911 else if (ap_cipher == Ndis802_11WEPEnabled)
1912 sprintf(SecurityStr, "WEP");
1914 sprintf(SecurityStr, "%s/%s", GetAuthMode((CHAR)ap_auth_mode), GetEncryptType((CHAR)ap_cipher));
1917 sprintf(msg+strlen(msg), "%-23s", SecurityStr);
1920 Rssi = (INT)pBss->Rssi;
1923 else if (Rssi >= -80) // between -50 ~ -80dbm
1924 Rssi_Quality = (UINT)(24 + ((Rssi + 80) * 26)/10);
1925 else if (Rssi >= -90) // between -80 ~ -90dbm
1926 Rssi_Quality = (UINT)(((Rssi + 90) * 26)/10);
1929 sprintf(msg+strlen(msg),"%-9d", Rssi_Quality);
1931 wireless_mode = NetworkTypeInUseSanity(pBss);
1932 if (wireless_mode == Ndis802_11FH ||
1933 wireless_mode == Ndis802_11DS)
1934 sprintf(msg+strlen(msg),"%-7s", "11b");
1935 else if (wireless_mode == Ndis802_11OFDM5)
1936 sprintf(msg+strlen(msg),"%-7s", "11a");
1937 else if (wireless_mode == Ndis802_11OFDM5_N)
1938 sprintf(msg+strlen(msg),"%-7s", "11a/n");
1939 else if (wireless_mode == Ndis802_11OFDM24)
1940 sprintf(msg+strlen(msg),"%-7s", "11b/g");
1941 else if (wireless_mode == Ndis802_11OFDM24_N)
1942 sprintf(msg+strlen(msg),"%-7s", "11b/g/n");
1944 sprintf(msg+strlen(msg),"%-7s", "unknow");
1947 if (pBss->AddHtInfoLen > 0)
1949 if (pBss->AddHtInfo.AddHtInfo.ExtChanOffset == EXTCHA_ABOVE)
1950 sprintf(msg+strlen(msg),"%-7s", " ABOVE");
1951 else if (pBss->AddHtInfo.AddHtInfo.ExtChanOffset == EXTCHA_BELOW)
1952 sprintf(msg+strlen(msg),"%-7s", " BELOW");
1954 sprintf(msg+strlen(msg),"%-7s", " NONE");
1958 sprintf(msg+strlen(msg),"%-7s", " NONE");
1962 if (pBss->BssType == BSS_ADHOC)
1963 sprintf(msg+strlen(msg),"%-3s", " Ad");
1965 sprintf(msg+strlen(msg),"%-3s", " In");
1967 sprintf(msg+strlen(msg),"\n");
1972 VOID RTMPIoctlGetSiteSurvey(
1973 IN PRTMP_ADAPTER pAdapter,
1974 IN struct iwreq *wrq)
1980 INT max_len = LINE_LEN;
1984 os_alloc_mem(NULL, (PUCHAR *)&msg, sizeof(CHAR)*((MAX_LEN_OF_BSS_TABLE)*max_len));
1988 DBGPRINT(RT_DEBUG_TRACE, ("RTMPIoctlGetSiteSurvey - msg memory alloc fail.\n"));
1992 memset(msg, 0 ,(MAX_LEN_OF_BSS_TABLE)*max_len );
1993 sprintf(msg,"%s","\n");
1994 sprintf(msg+strlen(msg),"%-4s%-33s%-20s%-23s%-9s%-7s%-7s%-3s\n",
1995 "Ch", "SSID", "BSSID", "Security", "Siganl(%)", "W-Mode", " ExtCH"," NT");
2000 pAdapter->StaCfg.bScanReqIsFromWebUI = TRUE;
2001 while ((ScanRunning(pAdapter) == TRUE) && (WaitCnt++ < 200))
2004 for(i=0; i<pAdapter->ScanTab.BssNr ;i++)
2006 pBss = &pAdapter->ScanTab.BssEntry[i];
2008 if( pBss->Channel==0)
2011 if((strlen(msg)+max_len ) >= IW_SCAN_MAX_DATA)
2015 RTMPCommSiteSurveyData(msg, pBss);
2020 pAdapter->StaCfg.bScanReqIsFromWebUI = FALSE;
2021 wrq->u.data.length = strlen(msg);
2022 Status = copy_to_user(wrq->u.data.pointer, msg, wrq->u.data.length);
2024 DBGPRINT(RT_DEBUG_TRACE, ("RTMPIoctlGetSiteSurvey - wrq->u.data.length = %d\n", wrq->u.data.length));
2025 os_free_mem(NULL, (PUCHAR)msg);
2029 #define MAC_LINE_LEN (14+4+4+10+10+10+6+6) // Addr+aid+psm+datatime+rxbyte+txbyte+current tx rate+last tx rate
2030 VOID RTMPIoctlGetMacTable(
2031 IN PRTMP_ADAPTER pAd,
2032 IN struct iwreq *wrq)
2035 RT_802_11_MAC_TABLE MacTab;
2039 for (i=0; i<MAX_LEN_OF_MAC_TABLE; i++)
2041 if (pAd->MacTab.Content[i].ValidAsCLI && (pAd->MacTab.Content[i].Sst == SST_ASSOC))
2043 COPY_MAC_ADDR(MacTab.Entry[MacTab.Num].Addr, &pAd->MacTab.Content[i].Addr);
2044 MacTab.Entry[MacTab.Num].Aid = (UCHAR)pAd->MacTab.Content[i].Aid;
2045 MacTab.Entry[MacTab.Num].Psm = pAd->MacTab.Content[i].PsMode;
2046 MacTab.Entry[MacTab.Num].MimoPs = pAd->MacTab.Content[i].MmpsMode;
2048 // Fill in RSSI per entry
2049 MacTab.Entry[MacTab.Num].AvgRssi0 = pAd->MacTab.Content[i].RssiSample.AvgRssi0;
2050 MacTab.Entry[MacTab.Num].AvgRssi1 = pAd->MacTab.Content[i].RssiSample.AvgRssi1;
2051 MacTab.Entry[MacTab.Num].AvgRssi2 = pAd->MacTab.Content[i].RssiSample.AvgRssi2;
2053 // the connected time per entry
2054 MacTab.Entry[MacTab.Num].ConnectedTime = pAd->MacTab.Content[i].StaConnectTime;
2055 MacTab.Entry[MacTab.Num].TxRate.field.MCS = pAd->MacTab.Content[i].HTPhyMode.field.MCS;
2056 MacTab.Entry[MacTab.Num].TxRate.field.BW = pAd->MacTab.Content[i].HTPhyMode.field.BW;
2057 MacTab.Entry[MacTab.Num].TxRate.field.ShortGI = pAd->MacTab.Content[i].HTPhyMode.field.ShortGI;
2058 MacTab.Entry[MacTab.Num].TxRate.field.STBC = pAd->MacTab.Content[i].HTPhyMode.field.STBC;
2059 MacTab.Entry[MacTab.Num].TxRate.field.rsv = pAd->MacTab.Content[i].HTPhyMode.field.rsv;
2060 MacTab.Entry[MacTab.Num].TxRate.field.MODE = pAd->MacTab.Content[i].HTPhyMode.field.MODE;
2061 MacTab.Entry[MacTab.Num].TxRate.word = pAd->MacTab.Content[i].HTPhyMode.word;
2066 wrq->u.data.length = sizeof(RT_802_11_MAC_TABLE);
2067 if (copy_to_user(wrq->u.data.pointer, &MacTab, wrq->u.data.length))
2069 DBGPRINT(RT_DEBUG_TRACE, ("%s: copy_to_user() fail\n", __func__));
2072 msg = kmalloc(sizeof(CHAR)*(MAX_LEN_OF_MAC_TABLE*MAC_LINE_LEN), MEM_ALLOC_FLAG);
2075 DBGPRINT(RT_DEBUG_ERROR, ("%s():Alloc memory failed\n", __func__));
2078 memset(msg, 0 ,MAX_LEN_OF_MAC_TABLE*MAC_LINE_LEN );
2079 sprintf(msg,"%s","\n");
2080 sprintf(msg+strlen(msg),"%-14s%-4s%-4s%-10s%-10s%-10s%-6s%-6s\n",
2081 "MAC", "AID", "PSM", "LDT", "RxB", "TxB","CTxR", "LTxR");
2083 for (i=0; i<MAX_LEN_OF_MAC_TABLE; i++)
2085 PMAC_TABLE_ENTRY pEntry = &pAd->MacTab.Content[i];
2086 if (pEntry->ValidAsCLI && (pEntry->Sst == SST_ASSOC))
2088 if((strlen(msg)+MAC_LINE_LEN ) >= (MAX_LEN_OF_MAC_TABLE*MAC_LINE_LEN) )
2090 sprintf(msg+strlen(msg),"%02x%02x%02x%02x%02x%02x ",
2091 pEntry->Addr[0], pEntry->Addr[1], pEntry->Addr[2],
2092 pEntry->Addr[3], pEntry->Addr[4], pEntry->Addr[5]);
2093 sprintf(msg+strlen(msg),"%-4d", (int)pEntry->Aid);
2094 sprintf(msg+strlen(msg),"%-4d", (int)pEntry->PsMode);
2095 sprintf(msg+strlen(msg),"%-10d",0/*pAd->MacTab.Content[i].HSCounter.LastDataPacketTime*/); // ToDo
2096 sprintf(msg+strlen(msg),"%-10d",0/*pAd->MacTab.Content[i].HSCounter.TotalRxByteCount*/); // ToDo
2097 sprintf(msg+strlen(msg),"%-10d",0/*pAd->MacTab.Content[i].HSCounter.TotalTxByteCount*/); // ToDo
2098 sprintf(msg+strlen(msg),"%-6d",RateIdToMbps[pAd->MacTab.Content[i].CurrTxRate]);
2099 sprintf(msg+strlen(msg),"%-6d\n",0/*RateIdToMbps[pAd->MacTab.Content[i].LastTxRate]*/); // ToDo
2102 // for compatible with old API just do the printk to console
2103 //wrq->u.data.length = strlen(msg);
2104 //if (copy_to_user(wrq->u.data.pointer, msg, wrq->u.data.length))
2106 DBGPRINT(RT_DEBUG_TRACE, ("%s", msg));
2113 INT Set_BASetup_Proc(
2114 IN PRTMP_ADAPTER pAd,
2119 STRING sepValue[] = ":", DASH = '-';
2121 MAC_TABLE_ENTRY *pEntry;
2124 The BASetup inupt string format should be xx:xx:xx:xx:xx:xx-d,
2125 =>The six 2 digit hex-decimal number previous are the Mac address,
2126 =>The seventh decimal number is the tid value.
2128 //DBGPRINT(RT_DEBUG_TRACE,("\n%s\n", arg));
2130 if(strlen(arg) < 19) //Mac address acceptable format 01:02:03:04:05:06 length 17 plus the "-" and tid value in decimal format.
2133 token = strchr(arg, DASH);
2134 if ((token != NULL) && (strlen(token)>1))
2136 tid = (UCHAR) simple_strtol((token+1), 0, 10);
2141 for (i = 0, token = rstrtok(arg, &sepValue[0]); token; token = rstrtok(NULL, &sepValue[0]), i++)
2143 if((strlen(token) != 2) || (!isxdigit(*token)) || (!isxdigit(*(token+1))))
2145 AtoH(token, (&mac[i]), 1);
2150 DBGPRINT(RT_DEBUG_OFF, ("\n%02x:%02x:%02x:%02x:%02x:%02x-%02x\n",
2151 mac[0], mac[1], mac[2], mac[3], mac[4], mac[5], tid));
2153 pEntry = MacTableLookup(pAd, (PUCHAR) mac);
2156 DBGPRINT(RT_DEBUG_OFF, ("\nSetup BA Session: Tid = %d\n", tid));
2157 BAOriSessionSetUp(pAd, pEntry, tid, 0, 100, TRUE);
2167 INT Set_BADecline_Proc(
2168 IN PRTMP_ADAPTER pAd,
2173 bBADecline = simple_strtol(arg, 0, 10);
2175 if (bBADecline == 0)
2177 pAd->CommonCfg.bBADecline = FALSE;
2179 else if (bBADecline == 1)
2181 pAd->CommonCfg.bBADecline = TRUE;
2185 return FALSE; //Invalid argument
2188 DBGPRINT(RT_DEBUG_TRACE, ("Set_BADecline_Proc::(BADecline=%d)\n", pAd->CommonCfg.bBADecline));
2193 INT Set_BAOriTearDown_Proc(
2194 IN PRTMP_ADAPTER pAd,
2199 STRING sepValue[] = ":", DASH = '-';
2201 MAC_TABLE_ENTRY *pEntry;
2203 //DBGPRINT(RT_DEBUG_TRACE,("\n%s\n", arg));
2205 The BAOriTearDown inupt string format should be xx:xx:xx:xx:xx:xx-d,
2206 =>The six 2 digit hex-decimal number previous are the Mac address,
2207 =>The seventh decimal number is the tid value.
2209 if(strlen(arg) < 19) //Mac address acceptable format 01:02:03:04:05:06 length 17 plus the "-" and tid value in decimal format.
2212 token = strchr(arg, DASH);
2213 if ((token != NULL) && (strlen(token)>1))
2215 tid = simple_strtol((token+1), 0, 10);
2216 if (tid > NUM_OF_TID)
2220 for (i = 0, token = rstrtok(arg, &sepValue[0]); token; token = rstrtok(NULL, &sepValue[0]), i++)
2222 if((strlen(token) != 2) || (!isxdigit(*token)) || (!isxdigit(*(token+1))))
2224 AtoH(token, (&mac[i]), 1);
2229 DBGPRINT(RT_DEBUG_OFF, ("\n%02x:%02x:%02x:%02x:%02x:%02x-%02x",
2230 mac[0], mac[1], mac[2], mac[3], mac[4], mac[5], tid));
2232 pEntry = MacTableLookup(pAd, (PUCHAR) mac);
2235 DBGPRINT(RT_DEBUG_OFF, ("\nTear down Ori BA Session: Tid = %d\n", tid));
2236 BAOriSessionTearDown(pAd, pEntry->Aid, tid, FALSE, TRUE);
2246 INT Set_BARecTearDown_Proc(
2247 IN PRTMP_ADAPTER pAd,
2252 STRING sepValue[] = ":", DASH = '-';
2254 MAC_TABLE_ENTRY *pEntry;
2256 //DBGPRINT(RT_DEBUG_TRACE,("\n%s\n", arg));
2258 The BARecTearDown inupt string format should be xx:xx:xx:xx:xx:xx-d,
2259 =>The six 2 digit hex-decimal number previous are the Mac address,
2260 =>The seventh decimal number is the tid value.
2262 if(strlen(arg) < 19) //Mac address acceptable format 01:02:03:04:05:06 length 17 plus the "-" and tid value in decimal format.
2265 token = strchr(arg, DASH);
2266 if ((token != NULL) && (strlen(token)>1))
2268 tid = simple_strtol((token+1), 0, 10);
2269 if (tid > NUM_OF_TID)
2273 for (i = 0, token = rstrtok(arg, &sepValue[0]); token; token = rstrtok(NULL, &sepValue[0]), i++)
2275 if((strlen(token) != 2) || (!isxdigit(*token)) || (!isxdigit(*(token+1))))
2277 AtoH(token, (&mac[i]), 1);
2282 DBGPRINT(RT_DEBUG_OFF, ("\n%02x:%02x:%02x:%02x:%02x:%02x-%02x",
2283 mac[0], mac[1], mac[2], mac[3], mac[4], mac[5], tid));
2285 pEntry = MacTableLookup(pAd, (PUCHAR) mac);
2288 DBGPRINT(RT_DEBUG_OFF, ("\nTear down Rec BA Session: Tid = %d\n", tid));
2289 BARecSessionTearDown(pAd, pEntry->Aid, tid, FALSE);
2300 IN PRTMP_ADAPTER pAd,
2305 HtBw = simple_strtol(arg, 0, 10);
2307 pAd->CommonCfg.RegTransmitSetting.field.BW = BW_40;
2308 else if (HtBw == BW_20)
2309 pAd->CommonCfg.RegTransmitSetting.field.BW = BW_20;
2311 return FALSE; //Invalid argument
2315 DBGPRINT(RT_DEBUG_TRACE, ("Set_HtBw_Proc::(HtBw=%d)\n", pAd->CommonCfg.RegTransmitSetting.field.BW));
2321 IN PRTMP_ADAPTER pAd,
2324 ULONG HtMcs, Mcs_tmp;
2325 BOOLEAN bAutoRate = FALSE;
2327 Mcs_tmp = simple_strtol(arg, 0, 10);
2329 if (Mcs_tmp <= 15 || Mcs_tmp == 32)
2335 pAd->StaCfg.DesiredTransmitSetting.field.MCS = HtMcs;
2336 pAd->StaCfg.bAutoTxRateSwitch = (HtMcs == MCS_AUTO) ? TRUE:FALSE;
2337 DBGPRINT(RT_DEBUG_TRACE, ("Set_HtMcs_Proc::(HtMcs=%d, bAutoTxRateSwitch = %d)\n",
2338 pAd->StaCfg.DesiredTransmitSetting.field.MCS, pAd->StaCfg.bAutoTxRateSwitch));
2340 if ((pAd->CommonCfg.PhyMode < PHY_11ABGN_MIXED) ||
2341 (pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE < MODE_HTMIX))
2343 if ((pAd->StaCfg.DesiredTransmitSetting.field.MCS != MCS_AUTO) &&
2344 (HtMcs >= 0 && HtMcs <= 3) &&
2345 (pAd->StaCfg.DesiredTransmitSetting.field.FixedTxMode == FIXED_TXMODE_CCK))
2347 RTMPSetDesiredRates(pAd, (LONG) (RateIdToMbps[HtMcs] * 1000000));
2349 else if ((pAd->StaCfg.DesiredTransmitSetting.field.MCS != MCS_AUTO) &&
2350 (HtMcs >= 0 && HtMcs <= 7) &&
2351 (pAd->StaCfg.DesiredTransmitSetting.field.FixedTxMode == FIXED_TXMODE_OFDM))
2353 RTMPSetDesiredRates(pAd, (LONG) (RateIdToMbps[HtMcs+4] * 1000000));
2360 pAd->StaCfg.DesiredTransmitSetting.field.MCS = MCS_AUTO;
2361 RTMPSetDesiredRates(pAd, -1);
2363 DBGPRINT(RT_DEBUG_TRACE, ("Set_HtMcs_Proc::(FixedTxMode=%d)\n",pAd->StaCfg.DesiredTransmitSetting.field.FixedTxMode));
2375 IN PRTMP_ADAPTER pAd,
2380 HtGi = simple_strtol(arg, 0, 10);
2382 if ( HtGi == GI_400)
2383 pAd->CommonCfg.RegTransmitSetting.field.ShortGI = GI_400;
2384 else if ( HtGi == GI_800 )
2385 pAd->CommonCfg.RegTransmitSetting.field.ShortGI = GI_800;
2387 return FALSE; //Invalid argument
2391 DBGPRINT(RT_DEBUG_TRACE, ("Set_HtGi_Proc::(ShortGI=%d)\n",pAd->CommonCfg.RegTransmitSetting.field.ShortGI));
2397 INT Set_HtTxBASize_Proc(
2398 IN PRTMP_ADAPTER pAd,
2403 Size = simple_strtol(arg, 0, 10);
2405 if (Size <=0 || Size >=64)
2409 pAd->CommonCfg.TxBASize = Size-1;
2410 DBGPRINT(RT_DEBUG_ERROR, ("Set_HtTxBASize ::(TxBASize= %d)\n", Size));
2415 INT Set_HtDisallowTKIP_Proc(
2416 IN PRTMP_ADAPTER pAd,
2421 Value = simple_strtol(arg, 0, 10);
2425 pAd->CommonCfg.HT_DisallowTKIP = TRUE;
2429 pAd->CommonCfg.HT_DisallowTKIP = FALSE;
2432 DBGPRINT(RT_DEBUG_TRACE, ("Set_HtDisallowTKIP_Proc ::%s\n",
2433 (pAd->CommonCfg.HT_DisallowTKIP == TRUE) ? "enabled" : "disabled"));
2438 INT Set_HtOpMode_Proc(
2439 IN PRTMP_ADAPTER pAd,
2445 Value = simple_strtol(arg, 0, 10);
2447 if (Value == HTMODE_GF)
2448 pAd->CommonCfg.RegTransmitSetting.field.HTMODE = HTMODE_GF;
2449 else if ( Value == HTMODE_MM )
2450 pAd->CommonCfg.RegTransmitSetting.field.HTMODE = HTMODE_MM;
2452 return FALSE; //Invalid argument
2456 DBGPRINT(RT_DEBUG_TRACE, ("Set_HtOpMode_Proc::(HtOpMode=%d)\n",pAd->CommonCfg.RegTransmitSetting.field.HTMODE));
2462 INT Set_HtStbc_Proc(
2463 IN PRTMP_ADAPTER pAd,
2469 Value = simple_strtol(arg, 0, 10);
2471 if (Value == STBC_USE)
2472 pAd->CommonCfg.RegTransmitSetting.field.STBC = STBC_USE;
2473 else if ( Value == STBC_NONE )
2474 pAd->CommonCfg.RegTransmitSetting.field.STBC = STBC_NONE;
2476 return FALSE; //Invalid argument
2480 DBGPRINT(RT_DEBUG_TRACE, ("Set_Stbc_Proc::(HtStbc=%d)\n",pAd->CommonCfg.RegTransmitSetting.field.STBC));
2486 IN PRTMP_ADAPTER pAd,
2492 Value = simple_strtol(arg, 0, 10);
2494 pAd->HTCEnable = FALSE;
2495 else if ( Value ==1 )
2496 pAd->HTCEnable = TRUE;
2498 return FALSE; //Invalid argument
2500 DBGPRINT(RT_DEBUG_TRACE, ("Set_HtHtc_Proc::(HtHtc=%d)\n",pAd->HTCEnable));
2505 INT Set_HtExtcha_Proc(
2506 IN PRTMP_ADAPTER pAd,
2512 Value = simple_strtol(arg, 0, 10);
2515 pAd->CommonCfg.RegTransmitSetting.field.EXTCHA = EXTCHA_BELOW;
2516 else if ( Value ==1 )
2517 pAd->CommonCfg.RegTransmitSetting.field.EXTCHA = EXTCHA_ABOVE;
2519 return FALSE; //Invalid argument
2523 DBGPRINT(RT_DEBUG_TRACE, ("Set_HtExtcha_Proc::(HtExtcha=%d)\n",pAd->CommonCfg.RegTransmitSetting.field.EXTCHA));
2528 INT Set_HtMpduDensity_Proc(
2529 IN PRTMP_ADAPTER pAd,
2534 Value = simple_strtol(arg, 0, 10);
2536 if (Value <=7 && Value >= 0)
2537 pAd->CommonCfg.BACapability.field.MpduDensity = Value;
2539 pAd->CommonCfg.BACapability.field.MpduDensity = 4;
2543 DBGPRINT(RT_DEBUG_TRACE, ("Set_HtMpduDensity_Proc::(HtMpduDensity=%d)\n",pAd->CommonCfg.BACapability.field.MpduDensity));
2548 INT Set_HtBaWinSize_Proc(
2549 IN PRTMP_ADAPTER pAd,
2554 Value = simple_strtol(arg, 0, 10);
2557 if (Value >=1 && Value <= 64)
2559 pAd->CommonCfg.REGBACapability.field.RxBAWinLimit = Value;
2560 pAd->CommonCfg.BACapability.field.RxBAWinLimit = Value;
2564 pAd->CommonCfg.REGBACapability.field.RxBAWinLimit = 64;
2565 pAd->CommonCfg.BACapability.field.RxBAWinLimit = 64;
2570 DBGPRINT(RT_DEBUG_TRACE, ("Set_HtBaWinSize_Proc::(HtBaWinSize=%d)\n",pAd->CommonCfg.BACapability.field.RxBAWinLimit));
2576 IN PRTMP_ADAPTER pAd,
2581 Value = simple_strtol(arg, 0, 10);
2584 pAd->CommonCfg.bRdg = FALSE;
2585 else if ( Value ==1 )
2587 pAd->HTCEnable = TRUE;
2588 pAd->CommonCfg.bRdg = TRUE;
2591 return FALSE; //Invalid argument
2595 DBGPRINT(RT_DEBUG_TRACE, ("Set_HtRdg_Proc::(HtRdg=%d)\n",pAd->CommonCfg.bRdg));
2600 INT Set_HtLinkAdapt_Proc(
2601 IN PRTMP_ADAPTER pAd,
2606 Value = simple_strtol(arg, 0, 10);
2608 pAd->bLinkAdapt = FALSE;
2609 else if ( Value ==1 )
2611 pAd->HTCEnable = TRUE;
2612 pAd->bLinkAdapt = TRUE;
2615 return FALSE; //Invalid argument
2617 DBGPRINT(RT_DEBUG_TRACE, ("Set_HtLinkAdapt_Proc::(HtLinkAdapt=%d)\n",pAd->bLinkAdapt));
2622 INT Set_HtAmsdu_Proc(
2623 IN PRTMP_ADAPTER pAd,
2628 Value = simple_strtol(arg, 0, 10);
2630 pAd->CommonCfg.BACapability.field.AmsduEnable = FALSE;
2631 else if ( Value == 1 )
2632 pAd->CommonCfg.BACapability.field.AmsduEnable = TRUE;
2634 return FALSE; //Invalid argument
2638 DBGPRINT(RT_DEBUG_TRACE, ("Set_HtAmsdu_Proc::(HtAmsdu=%d)\n",pAd->CommonCfg.BACapability.field.AmsduEnable));
2643 INT Set_HtAutoBa_Proc(
2644 IN PRTMP_ADAPTER pAd,
2649 Value = simple_strtol(arg, 0, 10);
2652 pAd->CommonCfg.BACapability.field.AutoBA = FALSE;
2653 pAd->CommonCfg.BACapability.field.Policy = BA_NOTUSE;
2655 else if (Value == 1)
2657 pAd->CommonCfg.BACapability.field.AutoBA = TRUE;
2658 pAd->CommonCfg.BACapability.field.Policy = IMMED_BA;
2661 return FALSE; //Invalid argument
2663 pAd->CommonCfg.REGBACapability.field.AutoBA = pAd->CommonCfg.BACapability.field.AutoBA;
2664 pAd->CommonCfg.REGBACapability.field.Policy = pAd->CommonCfg.BACapability.field.Policy;
2668 DBGPRINT(RT_DEBUG_TRACE, ("Set_HtAutoBa_Proc::(HtAutoBa=%d)\n",pAd->CommonCfg.BACapability.field.AutoBA));
2674 INT Set_HtProtect_Proc(
2675 IN PRTMP_ADAPTER pAd,
2680 Value = simple_strtol(arg, 0, 10);
2682 pAd->CommonCfg.bHTProtect = FALSE;
2683 else if (Value == 1)
2684 pAd->CommonCfg.bHTProtect = TRUE;
2686 return FALSE; //Invalid argument
2688 DBGPRINT(RT_DEBUG_TRACE, ("Set_HtProtect_Proc::(HtProtect=%d)\n",pAd->CommonCfg.bHTProtect));
2693 INT Set_SendPSMPAction_Proc(
2694 IN PRTMP_ADAPTER pAd,
2699 STRING sepValue[] = ":", DASH = '-';
2701 MAC_TABLE_ENTRY *pEntry;
2703 //DBGPRINT(RT_DEBUG_TRACE,("\n%s\n", arg));
2705 The BARecTearDown inupt string format should be xx:xx:xx:xx:xx:xx-d,
2706 =>The six 2 digit hex-decimal number previous are the Mac address,
2707 =>The seventh decimal number is the mode value.
2709 if(strlen(arg) < 19) //Mac address acceptable format 01:02:03:04:05:06 length 17 plus the "-" and mode value in decimal format.
2712 token = strchr(arg, DASH);
2713 if ((token != NULL) && (strlen(token)>1))
2715 mode = simple_strtol((token+1), 0, 10);
2716 if (mode > MMPS_ENABLE)
2720 for (i = 0, token = rstrtok(arg, &sepValue[0]); token; token = rstrtok(NULL, &sepValue[0]), i++)
2722 if((strlen(token) != 2) || (!isxdigit(*token)) || (!isxdigit(*(token+1))))
2724 AtoH(token, (&mac[i]), 1);
2729 DBGPRINT(RT_DEBUG_OFF, ("\n%02x:%02x:%02x:%02x:%02x:%02x-%02x",
2730 mac[0], mac[1], mac[2], mac[3], mac[4], mac[5], mode));
2732 pEntry = MacTableLookup(pAd, mac);
2735 DBGPRINT(RT_DEBUG_OFF, ("\nSendPSMPAction MIPS mode = %d\n", mode));
2736 SendPSMPAction(pAd, pEntry->Aid, mode);
2747 INT Set_HtMIMOPSmode_Proc(
2748 IN PRTMP_ADAPTER pAd,
2753 Value = simple_strtol(arg, 0, 10);
2755 if (Value <=3 && Value >= 0)
2756 pAd->CommonCfg.BACapability.field.MMPSmode = Value;
2758 pAd->CommonCfg.BACapability.field.MMPSmode = 3;
2762 DBGPRINT(RT_DEBUG_TRACE, ("Set_HtMIMOPSmode_Proc::(MIMOPS mode=%d)\n",pAd->CommonCfg.BACapability.field.MMPSmode));
2768 INT Set_ForceShortGI_Proc(
2769 IN PRTMP_ADAPTER pAd,
2774 Value = simple_strtol(arg, 0, 10);
2776 pAd->WIFItestbed.bShortGI = FALSE;
2777 else if (Value == 1)
2778 pAd->WIFItestbed.bShortGI = TRUE;
2780 return FALSE; //Invalid argument
2784 DBGPRINT(RT_DEBUG_TRACE, ("Set_ForceShortGI_Proc::(ForceShortGI=%d)\n", pAd->WIFItestbed.bShortGI));
2791 INT Set_ForceGF_Proc(
2792 IN PRTMP_ADAPTER pAd,
2797 Value = simple_strtol(arg, 0, 10);
2799 pAd->WIFItestbed.bGreenField = FALSE;
2800 else if (Value == 1)
2801 pAd->WIFItestbed.bGreenField = TRUE;
2803 return FALSE; //Invalid argument
2807 DBGPRINT(RT_DEBUG_TRACE, ("Set_ForceGF_Proc::(ForceGF=%d)\n", pAd->WIFItestbed.bGreenField));
2812 INT Set_HtMimoPs_Proc(
2813 IN PRTMP_ADAPTER pAd,
2818 Value = simple_strtol(arg, 0, 10);
2820 pAd->CommonCfg.bMIMOPSEnable = FALSE;
2821 else if (Value == 1)
2822 pAd->CommonCfg.bMIMOPSEnable = TRUE;
2824 return FALSE; //Invalid argument
2826 DBGPRINT(RT_DEBUG_TRACE, ("Set_HtMimoPs_Proc::(HtMimoPs=%d)\n",pAd->CommonCfg.bMIMOPSEnable));
2832 IN PRTMP_ADAPTER pAd)
2834 OID_SET_HT_PHYMODE SetHT;
2836 if (pAd->CommonCfg.PhyMode < PHY_11ABGN_MIXED)
2839 SetHT.PhyMode = pAd->CommonCfg.PhyMode;
2840 SetHT.TransmitNo = ((UCHAR)pAd->Antenna.field.TxPath);
2841 SetHT.HtMode = (UCHAR)pAd->CommonCfg.RegTransmitSetting.field.HTMODE;
2842 SetHT.ExtOffset = (UCHAR)pAd->CommonCfg.RegTransmitSetting.field.EXTCHA;
2843 SetHT.MCS = MCS_AUTO;
2844 SetHT.BW = (UCHAR)pAd->CommonCfg.RegTransmitSetting.field.BW;
2845 SetHT.STBC = (UCHAR)pAd->CommonCfg.RegTransmitSetting.field.STBC;
2846 SetHT.SHORTGI = (UCHAR)pAd->CommonCfg.RegTransmitSetting.field.ShortGI;
2848 RTMPSetHT(pAd, &SetHT);
2853 INT Set_FixedTxMode_Proc(
2854 IN PRTMP_ADAPTER pAd,
2857 UCHAR fix_tx_mode = FIXED_TXMODE_HT;
2859 if (strcmp(arg, "OFDM") == 0 || strcmp(arg, "ofdm") == 0)
2861 fix_tx_mode = FIXED_TXMODE_OFDM;
2863 else if (strcmp(arg, "CCK") == 0 || strcmp(arg, "cck") == 0)
2865 fix_tx_mode = FIXED_TXMODE_CCK;
2868 pAd->StaCfg.DesiredTransmitSetting.field.FixedTxMode = fix_tx_mode;
2870 DBGPRINT(RT_DEBUG_TRACE, ("Set_FixedTxMode_Proc::(FixedTxMode=%d)\n", fix_tx_mode));
2875 #if defined(RT305x)||defined(RT3070)
2876 INT Set_HiPower_Proc(
2877 IN PRTMP_ADAPTER pAdapter,
2880 pAdapter->CommonCfg.HighPowerPatchDisabled = !(simple_strtol(arg, 0, 10));
2882 if (pAdapter->CommonCfg.HighPowerPatchDisabled != 0)
2884 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R82, 0x62);
2885 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R67, 0x20);
2887 if ((IS_RT3070(pAdapter) && ((pAdapter->MACVersion & 0xffff) < 0x0201)))
2889 RT30xxWriteRFRegister(pAdapter, RF_R27, 0x23);
2895 INT Set_LongRetryLimit_Proc(
2896 IN PRTMP_ADAPTER pAdapter,
2899 TX_RTY_CFG_STRUC tx_rty_cfg;
2900 UCHAR LongRetryLimit = (UCHAR)simple_strtol(arg, 0, 10);
2902 RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
2903 tx_rty_cfg.field.LongRtyLimit = LongRetryLimit;
2904 RTMP_IO_WRITE32(pAdapter, TX_RTY_CFG, tx_rty_cfg.word);
2905 DBGPRINT(RT_DEBUG_TRACE, ("IF Set_LongRetryLimit_Proc::(tx_rty_cfg=0x%x)\n", tx_rty_cfg.word));
2909 INT Set_ShortRetryLimit_Proc(
2910 IN PRTMP_ADAPTER pAdapter,
2913 TX_RTY_CFG_STRUC tx_rty_cfg;
2914 UCHAR ShortRetryLimit = (UCHAR)simple_strtol(arg, 0, 10);
2916 RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
2917 tx_rty_cfg.field.ShortRtyLimit = ShortRetryLimit;
2918 RTMP_IO_WRITE32(pAdapter, TX_RTY_CFG, tx_rty_cfg.word);
2919 DBGPRINT(RT_DEBUG_TRACE, ("IF Set_ShortRetryLimit_Proc::(tx_rty_cfg=0x%x)\n", tx_rty_cfg.word));
2924 /////////////////////////////////////////////////////////////////////////
2925 PSTRING RTMPGetRalinkAuthModeStr(
2926 IN NDIS_802_11_AUTHENTICATION_MODE authMode)
2930 case Ndis802_11AuthModeOpen:
2932 case Ndis802_11AuthModeWPAPSK:
2934 case Ndis802_11AuthModeShared:
2936 case Ndis802_11AuthModeWPA:
2938 case Ndis802_11AuthModeWPA2:
2940 case Ndis802_11AuthModeWPA2PSK:
2942 case Ndis802_11AuthModeWPA1PSKWPA2PSK:
2943 return "WPAPSKWPA2PSK";
2944 case Ndis802_11AuthModeWPA1WPA2:
2946 case Ndis802_11AuthModeWPANone:
2953 PSTRING RTMPGetRalinkEncryModeStr(
2954 IN USHORT encryMode)
2958 case Ndis802_11WEPDisabled:
2960 case Ndis802_11WEPEnabled:
2962 case Ndis802_11Encryption2Enabled:
2964 case Ndis802_11Encryption3Enabled:
2966 case Ndis802_11Encryption4Enabled:
2973 INT RTMPShowCfgValue(
2974 IN PRTMP_ADAPTER pAd,
2980 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++)
2982 if (!strcmp(pName, PRTMP_PRIVATE_STA_SHOW_CFG_VALUE_PROC->name))
2984 if(PRTMP_PRIVATE_STA_SHOW_CFG_VALUE_PROC->show_proc(pAd, pBuf))
2986 break; //Exit for loop.
2990 if(PRTMP_PRIVATE_STA_SHOW_CFG_VALUE_PROC->name == NULL)
2992 sprintf(pBuf, "\n");
2993 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++)
2994 sprintf(pBuf + strlen(pBuf), "%s\n", PRTMP_PRIVATE_STA_SHOW_CFG_VALUE_PROC->name);
3001 IN PRTMP_ADAPTER pAd,
3004 sprintf(pBuf, "\t%s", pAd->CommonCfg.Ssid);
3008 INT Show_WirelessMode_Proc(
3009 IN PRTMP_ADAPTER pAd,
3012 switch(pAd->CommonCfg.PhyMode)
3014 case PHY_11BG_MIXED:
3015 sprintf(pBuf, "\t11B/G");
3018 sprintf(pBuf, "\t11B");
3021 sprintf(pBuf, "\t11A");
3023 case PHY_11ABG_MIXED:
3024 sprintf(pBuf, "\t11A/B/G");
3027 sprintf(pBuf, "\t11G");
3029 case PHY_11ABGN_MIXED:
3030 sprintf(pBuf, "\t11A/B/G/N");
3033 sprintf(pBuf, "\t11N only with 2.4G");
3035 case PHY_11GN_MIXED:
3036 sprintf(pBuf, "\t11G/N");
3038 case PHY_11AN_MIXED:
3039 sprintf(pBuf, "\t11A/N");
3041 case PHY_11BGN_MIXED:
3042 sprintf(pBuf, "\t11B/G/N");
3044 case PHY_11AGN_MIXED:
3045 sprintf(pBuf, "\t11A/G/N");
3048 sprintf(pBuf, "\t11N only with 5G");
3051 sprintf(pBuf, "\tUnknow Value(%d)", pAd->CommonCfg.PhyMode);
3058 INT Show_TxBurst_Proc(
3059 IN PRTMP_ADAPTER pAd,
3062 sprintf(pBuf, "\t%s", pAd->CommonCfg.bEnableTxBurst ? "TRUE":"FALSE");
3066 INT Show_TxPreamble_Proc(
3067 IN PRTMP_ADAPTER pAd,
3070 switch(pAd->CommonCfg.TxPreamble)
3072 case Rt802_11PreambleShort:
3073 sprintf(pBuf, "\tShort");
3075 case Rt802_11PreambleLong:
3076 sprintf(pBuf, "\tLong");
3078 case Rt802_11PreambleAuto:
3079 sprintf(pBuf, "\tAuto");
3082 sprintf(pBuf, "\tUnknow Value(%lu)", pAd->CommonCfg.TxPreamble);
3089 INT Show_TxPower_Proc(
3090 IN PRTMP_ADAPTER pAd,
3093 sprintf(pBuf, "\t%lu", pAd->CommonCfg.TxPowerPercentage);
3097 INT Show_Channel_Proc(
3098 IN PRTMP_ADAPTER pAd,
3101 sprintf(pBuf, "\t%d", pAd->CommonCfg.Channel);
3105 INT Show_BGProtection_Proc(
3106 IN PRTMP_ADAPTER pAd,
3109 switch(pAd->CommonCfg.UseBGProtection)
3112 sprintf(pBuf, "\tON");
3114 case 2: //Always OFF
3115 sprintf(pBuf, "\tOFF");
3118 sprintf(pBuf, "\tAuto");
3121 sprintf(pBuf, "\tUnknow Value(%lu)", pAd->CommonCfg.UseBGProtection);
3127 INT Show_RTSThreshold_Proc(
3128 IN PRTMP_ADAPTER pAd,
3131 sprintf(pBuf, "\t%u", pAd->CommonCfg.RtsThreshold);
3135 INT Show_FragThreshold_Proc(
3136 IN PRTMP_ADAPTER pAd,
3139 sprintf(pBuf, "\t%u", pAd->CommonCfg.FragmentThreshold);
3144 IN PRTMP_ADAPTER pAd,
3147 if (pAd->CommonCfg.RegTransmitSetting.field.BW == BW_40)
3149 sprintf(pBuf, "\t40 MHz");
3153 sprintf(pBuf, "\t20 MHz");
3158 INT Show_HtMcs_Proc(
3159 IN PRTMP_ADAPTER pAd,
3162 sprintf(pBuf, "\t%u", pAd->StaCfg.DesiredTransmitSetting.field.MCS);
3167 IN PRTMP_ADAPTER pAd,
3170 switch(pAd->CommonCfg.RegTransmitSetting.field.ShortGI)
3173 sprintf(pBuf, "\tGI_400");
3176 sprintf(pBuf, "\tGI_800");
3179 sprintf(pBuf, "\tUnknow Value(%u)", pAd->CommonCfg.RegTransmitSetting.field.ShortGI);
3185 INT Show_HtOpMode_Proc(
3186 IN PRTMP_ADAPTER pAd,
3189 switch(pAd->CommonCfg.RegTransmitSetting.field.HTMODE)
3192 sprintf(pBuf, "\tGF");
3195 sprintf(pBuf, "\tMM");
3198 sprintf(pBuf, "\tUnknow Value(%u)", pAd->CommonCfg.RegTransmitSetting.field.HTMODE);
3204 INT Show_HtExtcha_Proc(
3205 IN PRTMP_ADAPTER pAd,
3208 switch(pAd->CommonCfg.RegTransmitSetting.field.EXTCHA)
3211 sprintf(pBuf, "\tBelow");
3214 sprintf(pBuf, "\tAbove");
3217 sprintf(pBuf, "\tUnknow Value(%u)", pAd->CommonCfg.RegTransmitSetting.field.EXTCHA);
3224 INT Show_HtMpduDensity_Proc(
3225 IN PRTMP_ADAPTER pAd,
3228 sprintf(pBuf, "\t%u", pAd->CommonCfg.BACapability.field.MpduDensity);
3232 INT Show_HtBaWinSize_Proc(
3233 IN PRTMP_ADAPTER pAd,
3236 sprintf(pBuf, "\t%u", pAd->CommonCfg.BACapability.field.RxBAWinLimit);
3240 INT Show_HtRdg_Proc(
3241 IN PRTMP_ADAPTER pAd,
3244 sprintf(pBuf, "\t%s", pAd->CommonCfg.bRdg ? "TRUE":"FALSE");
3248 INT Show_HtAmsdu_Proc(
3249 IN PRTMP_ADAPTER pAd,
3252 sprintf(pBuf, "\t%s", pAd->CommonCfg.BACapability.field.AmsduEnable ? "TRUE":"FALSE");
3256 INT Show_HtAutoBa_Proc(
3257 IN PRTMP_ADAPTER pAd,
3260 sprintf(pBuf, "\t%s", pAd->CommonCfg.BACapability.field.AutoBA ? "TRUE":"FALSE");
3264 INT Show_CountryRegion_Proc(
3265 IN PRTMP_ADAPTER pAd,
3268 sprintf(pBuf, "\t%d", pAd->CommonCfg.CountryRegion);
3272 INT Show_CountryRegionABand_Proc(
3273 IN PRTMP_ADAPTER pAd,
3276 sprintf(pBuf, "\t%d", pAd->CommonCfg.CountryRegionForABand);
3280 INT Show_CountryCode_Proc(
3281 IN PRTMP_ADAPTER pAd,
3284 sprintf(pBuf, "\t%s", pAd->CommonCfg.CountryCode);
3288 #ifdef AGGREGATION_SUPPORT
3289 INT Show_PktAggregate_Proc(
3290 IN PRTMP_ADAPTER pAd,
3293 sprintf(pBuf, "\t%s", pAd->CommonCfg.bAggregationCapable ? "TRUE":"FALSE");
3296 #endif // AGGREGATION_SUPPORT //
3299 INT Show_WmmCapable_Proc(
3300 IN PRTMP_ADAPTER pAd,
3303 sprintf(pBuf, "\t%s", pAd->CommonCfg.bWmmCapable ? "TRUE":"FALSE");
3307 #endif // WMM_SUPPORT //
3309 INT Show_IEEE80211H_Proc(
3310 IN PRTMP_ADAPTER pAd,
3313 sprintf(pBuf, "\t%s", pAd->CommonCfg.bIEEE80211H ? "TRUE":"FALSE");
3317 INT Show_NetworkType_Proc(
3318 IN PRTMP_ADAPTER pAd,
3321 switch(pAd->StaCfg.BssType)
3324 sprintf(pBuf, "\tAdhoc");
3327 sprintf(pBuf, "\tInfra");
3330 sprintf(pBuf, "\tAny");
3333 sprintf(pBuf, "\tMonitor");
3336 sprintf(pBuf, "\tUnknow Value(%d)", pAd->StaCfg.BssType);
3344 INT Show_AuthMode_Proc(
3345 IN PRTMP_ADAPTER pAd,
3348 NDIS_802_11_AUTHENTICATION_MODE AuthMode = Ndis802_11AuthModeOpen;
3350 AuthMode = pAd->StaCfg.AuthMode;
3352 if ((AuthMode >= Ndis802_11AuthModeOpen) &&
3353 (AuthMode <= Ndis802_11AuthModeWPA1PSKWPA2PSK))
3354 sprintf(pBuf, "\t%s", RTMPGetRalinkAuthModeStr(AuthMode));
3356 sprintf(pBuf, "\tUnknow Value(%d)", AuthMode);
3361 INT Show_EncrypType_Proc(
3362 IN PRTMP_ADAPTER pAd,
3365 NDIS_802_11_WEP_STATUS WepStatus = Ndis802_11WEPDisabled;
3367 WepStatus = pAd->StaCfg.WepStatus;
3369 if ((WepStatus >= Ndis802_11WEPEnabled) &&
3370 (WepStatus <= Ndis802_11Encryption4KeyAbsent))
3371 sprintf(pBuf, "\t%s", RTMPGetRalinkEncryModeStr(WepStatus));
3373 sprintf(pBuf, "\tUnknow Value(%d)", WepStatus);
3378 INT Show_DefaultKeyID_Proc(
3379 IN PRTMP_ADAPTER pAd,
3382 UCHAR DefaultKeyId = 0;
3384 DefaultKeyId = pAd->StaCfg.DefaultKeyId;
3386 sprintf(pBuf, "\t%d", DefaultKeyId);
3391 INT Show_WepKey_Proc(
3392 IN PRTMP_ADAPTER pAd,
3396 UCHAR Key[16] = {0}, KeyLength = 0;
3399 KeyLength = pAd->SharedKey[index][KeyIdx].KeyLen;
3400 NdisMoveMemory(Key, pAd->SharedKey[index][KeyIdx].Key, KeyLength);
3402 //check key string is ASCII or not
3403 if (RTMPCheckStrPrintAble((PCHAR)Key, KeyLength))
3404 sprintf(pBuf, "\t%s", Key);
3408 sprintf(pBuf, "\t");
3409 for (idx = 0; idx < KeyLength; idx++)
3410 sprintf(pBuf+strlen(pBuf), "%02X", Key[idx]);
3416 IN PRTMP_ADAPTER pAd,
3419 Show_WepKey_Proc(pAd, 0, pBuf);
3424 IN PRTMP_ADAPTER pAd,
3427 Show_WepKey_Proc(pAd, 1, pBuf);
3432 IN PRTMP_ADAPTER pAd,
3435 Show_WepKey_Proc(pAd, 2, pBuf);
3440 IN PRTMP_ADAPTER pAd,
3443 Show_WepKey_Proc(pAd, 3, pBuf);
3447 INT Show_WPAPSK_Proc(
3448 IN PRTMP_ADAPTER pAd,
3452 UCHAR PMK[32] = {0};
3454 NdisMoveMemory(PMK, pAd->StaCfg.PMK, 32);
3456 sprintf(pBuf, "\tPMK = ");
3457 for (idx = 0; idx < 32; idx++)
3458 sprintf(pBuf+strlen(pBuf), "%02X", PMK[idx]);