staging: more sched.h fixes
[linux-2.6/btrfs-unstable.git] / drivers / staging / rt3090 / common / cmm_info.c
blob3e51e98b474c95ae6f6ceda764ac9bd5ea1a594a
1 /*
2 *************************************************************************
3 * Ralink Tech Inc.
4 * 5F., No.36, Taiyuan St., Jhubei City,
5 * Hsinchu County 302,
6 * Taiwan, R.O.C.
8 * (c) Copyright 2002-2007, Ralink Technology, Inc.
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
14 * *
15 * This program is distributed in the hope that it will be useful, *
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
18 * GNU General Public License for more details. *
19 * *
20 * You should have received a copy of the GNU General Public License *
21 * along with this program; if not, write to the *
22 * Free Software Foundation, Inc., *
23 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
24 * *
25 *************************************************************************
27 Module Name:
28 cmm_info.c
30 Abstract:
32 Revision History:
33 Who When What
34 --------- ---------- ----------------------------------------------
37 #include <linux/sched.h>
38 #include "../rt_config.h"
41 INT Show_SSID_Proc(
42 IN PRTMP_ADAPTER pAd,
43 OUT PSTRING pBuf);
45 INT Show_WirelessMode_Proc(
46 IN PRTMP_ADAPTER pAd,
47 OUT PSTRING pBuf);
49 INT Show_TxBurst_Proc(
50 IN PRTMP_ADAPTER pAd,
51 OUT PSTRING pBuf);
53 INT Show_TxPreamble_Proc(
54 IN PRTMP_ADAPTER pAd,
55 OUT PSTRING pBuf);
57 INT Show_TxPower_Proc(
58 IN PRTMP_ADAPTER pAd,
59 OUT PSTRING pBuf);
61 INT Show_Channel_Proc(
62 IN PRTMP_ADAPTER pAd,
63 OUT PSTRING pBuf);
65 INT Show_BGProtection_Proc(
66 IN PRTMP_ADAPTER pAd,
67 OUT PSTRING pBuf);
69 INT Show_RTSThreshold_Proc(
70 IN PRTMP_ADAPTER pAd,
71 OUT PSTRING pBuf);
73 INT Show_FragThreshold_Proc(
74 IN PRTMP_ADAPTER pAd,
75 OUT PSTRING pBuf);
77 #ifdef DOT11_N_SUPPORT
78 INT Show_HtBw_Proc(
79 IN PRTMP_ADAPTER pAd,
80 OUT PSTRING pBuf);
82 INT Show_HtMcs_Proc(
83 IN PRTMP_ADAPTER pAd,
84 OUT PSTRING pBuf);
86 INT Show_HtGi_Proc(
87 IN PRTMP_ADAPTER pAd,
88 OUT PSTRING pBuf);
90 INT Show_HtOpMode_Proc(
91 IN PRTMP_ADAPTER pAd,
92 OUT PSTRING pBuf);
94 INT Show_HtExtcha_Proc(
95 IN PRTMP_ADAPTER pAd,
96 OUT PSTRING pBuf);
98 INT Show_HtMpduDensity_Proc(
99 IN PRTMP_ADAPTER pAd,
100 OUT PSTRING pBuf);
102 INT Show_HtBaWinSize_Proc(
103 IN PRTMP_ADAPTER pAd,
104 OUT PSTRING pBuf);
106 INT Show_HtRdg_Proc(
107 IN PRTMP_ADAPTER pAd,
108 OUT PSTRING pBuf);
110 INT Show_HtAmsdu_Proc(
111 IN PRTMP_ADAPTER pAd,
112 OUT PSTRING pBuf);
114 INT Show_HtAutoBa_Proc(
115 IN PRTMP_ADAPTER pAd,
116 OUT PSTRING pBuf);
117 #endif // DOT11_N_SUPPORT //
119 INT Show_CountryRegion_Proc(
120 IN PRTMP_ADAPTER pAd,
121 OUT PSTRING pBuf);
123 INT Show_CountryRegionABand_Proc(
124 IN PRTMP_ADAPTER pAd,
125 OUT PSTRING pBuf);
127 INT Show_CountryCode_Proc(
128 IN PRTMP_ADAPTER pAd,
129 OUT PSTRING pBuf);
131 #ifdef AGGREGATION_SUPPORT
132 INT Show_PktAggregate_Proc(
133 IN PRTMP_ADAPTER pAd,
134 OUT PSTRING pBuf);
135 #endif // AGGREGATION_SUPPORT //
137 #ifdef WMM_SUPPORT
138 INT Show_WmmCapable_Proc(
139 IN PRTMP_ADAPTER pAd,
140 OUT PSTRING pBuf);
141 #endif // WMM_SUPPORT //
143 INT Show_IEEE80211H_Proc(
144 IN PRTMP_ADAPTER pAd,
145 OUT PSTRING pBuf);
147 #ifdef CONFIG_STA_SUPPORT
148 INT Show_NetworkType_Proc(
149 IN PRTMP_ADAPTER pAd,
150 OUT PSTRING pBuf);
152 #endif // CONFIG_STA_SUPPORT //
154 INT Show_AuthMode_Proc(
155 IN PRTMP_ADAPTER pAd,
156 OUT PSTRING pBuf);
158 INT Show_EncrypType_Proc(
159 IN PRTMP_ADAPTER pAd,
160 OUT PSTRING pBuf);
162 INT Show_DefaultKeyID_Proc(
163 IN PRTMP_ADAPTER pAd,
164 OUT PSTRING pBuf);
166 INT Show_Key1_Proc(
167 IN PRTMP_ADAPTER pAd,
168 OUT PSTRING pBuf);
170 INT Show_Key2_Proc(
171 IN PRTMP_ADAPTER pAd,
172 OUT PSTRING pBuf);
174 INT Show_Key3_Proc(
175 IN PRTMP_ADAPTER pAd,
176 OUT PSTRING pBuf);
178 INT Show_Key4_Proc(
179 IN PRTMP_ADAPTER pAd,
180 OUT PSTRING pBuf);
182 INT Show_WPAPSK_Proc(
183 IN PRTMP_ADAPTER pAd,
184 OUT PSTRING pBuf);
186 static struct {
187 PSTRING name;
188 INT (*show_proc)(PRTMP_ADAPTER pAdapter, PSTRING arg);
189 } *PRTMP_PRIVATE_STA_SHOW_CFG_VALUE_PROC, RTMP_PRIVATE_STA_SHOW_CFG_VALUE_PROC[] = {
190 {"SSID", Show_SSID_Proc},
191 {"WirelessMode", Show_WirelessMode_Proc},
192 {"TxBurst", Show_TxBurst_Proc},
193 {"TxPreamble", Show_TxPreamble_Proc},
194 {"TxPower", Show_TxPower_Proc},
195 {"Channel", Show_Channel_Proc},
196 {"BGProtection", Show_BGProtection_Proc},
197 {"RTSThreshold", Show_RTSThreshold_Proc},
198 {"FragThreshold", Show_FragThreshold_Proc},
199 #ifdef DOT11_N_SUPPORT
200 {"HtBw", Show_HtBw_Proc},
201 {"HtMcs", Show_HtMcs_Proc},
202 {"HtGi", Show_HtGi_Proc},
203 {"HtOpMode", Show_HtOpMode_Proc},
204 {"HtExtcha", Show_HtExtcha_Proc},
205 {"HtMpduDensity", Show_HtMpduDensity_Proc},
206 {"HtBaWinSize", Show_HtBaWinSize_Proc},
207 {"HtRdg", Show_HtRdg_Proc},
208 {"HtAmsdu", Show_HtAmsdu_Proc},
209 {"HtAutoBa", Show_HtAutoBa_Proc},
210 #endif // DOT11_N_SUPPORT //
211 {"CountryRegion", Show_CountryRegion_Proc},
212 {"CountryRegionABand", Show_CountryRegionABand_Proc},
213 {"CountryCode", Show_CountryCode_Proc},
214 #ifdef AGGREGATION_SUPPORT
215 {"PktAggregate", Show_PktAggregate_Proc},
216 #endif
218 #ifdef WMM_SUPPORT
219 {"WmmCapable", Show_WmmCapable_Proc},
220 #endif
221 {"IEEE80211H", Show_IEEE80211H_Proc},
222 #ifdef CONFIG_STA_SUPPORT
223 {"NetworkType", Show_NetworkType_Proc},
224 #endif // CONFIG_STA_SUPPORT //
225 {"AuthMode", Show_AuthMode_Proc},
226 {"EncrypType", Show_EncrypType_Proc},
227 {"DefaultKeyID", Show_DefaultKeyID_Proc},
228 {"Key1", Show_Key1_Proc},
229 {"Key2", Show_Key2_Proc},
230 {"Key3", Show_Key3_Proc},
231 {"Key4", Show_Key4_Proc},
232 {"WPAPSK", Show_WPAPSK_Proc},
233 {NULL, NULL}
237 ==========================================================================
238 Description:
239 Get Driver version.
241 Return:
242 ==========================================================================
244 INT Set_DriverVersion_Proc(
245 IN PRTMP_ADAPTER pAd,
246 IN PSTRING arg)
249 #ifdef CONFIG_STA_SUPPORT
250 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
251 DBGPRINT(RT_DEBUG_TRACE, ("Driver version-%s\n", STA_DRIVER_VERSION));
252 #endif // CONFIG_STA_SUPPORT //
255 return TRUE;
259 ==========================================================================
260 Description:
261 Set Country Region.
262 This command will not work, if the field of CountryRegion in eeprom is programmed.
263 Return:
264 TRUE if all parameters are OK, FALSE otherwise
265 ==========================================================================
267 INT Set_CountryRegion_Proc(
268 IN PRTMP_ADAPTER pAd,
269 IN PSTRING arg)
271 int retval;
273 #ifdef EXT_BUILD_CHANNEL_LIST
274 return -EOPNOTSUPP;
275 #endif // EXT_BUILD_CHANNEL_LIST //
277 retval = RT_CfgSetCountryRegion(pAd, arg, BAND_24G);
278 if (retval == FALSE)
279 return FALSE;
281 // if set country region, driver needs to be reset
282 BuildChannelList(pAd);
284 DBGPRINT(RT_DEBUG_TRACE, ("Set_CountryRegion_Proc::(CountryRegion=%d)\n", pAd->CommonCfg.CountryRegion));
286 return TRUE;
291 ==========================================================================
292 Description:
293 Set Country Region for A band.
294 This command will not work, if the field of CountryRegion in eeprom is programmed.
295 Return:
296 TRUE if all parameters are OK, FALSE otherwise
297 ==========================================================================
299 INT Set_CountryRegionABand_Proc(
300 IN PRTMP_ADAPTER pAd,
301 IN PSTRING arg)
303 int retval;
305 #ifdef EXT_BUILD_CHANNEL_LIST
306 return -EOPNOTSUPP;
307 #endif // EXT_BUILD_CHANNEL_LIST //
309 retval = RT_CfgSetCountryRegion(pAd, arg, BAND_5G);
310 if (retval == FALSE)
311 return FALSE;
313 // if set country region, driver needs to be reset
314 BuildChannelList(pAd);
316 DBGPRINT(RT_DEBUG_TRACE, ("Set_CountryRegionABand_Proc::(CountryRegion=%d)\n", pAd->CommonCfg.CountryRegionForABand));
318 return TRUE;
323 ==========================================================================
324 Description:
325 Set Wireless Mode
326 Return:
327 TRUE if all parameters are OK, FALSE otherwise
328 ==========================================================================
330 INT Set_WirelessMode_Proc(
331 IN PRTMP_ADAPTER pAd,
332 IN PSTRING arg)
334 INT success = TRUE;
336 success = RT_CfgSetWirelessMode(pAd, arg);
337 if (success)
340 #ifdef CONFIG_STA_SUPPORT
341 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
343 LONG WirelessMode = pAd->CommonCfg.PhyMode;
345 RTMPSetPhyMode(pAd, WirelessMode);
346 #ifdef DOT11_N_SUPPORT
347 if (WirelessMode >= PHY_11ABGN_MIXED)
349 pAd->CommonCfg.BACapability.field.AutoBA = TRUE;
350 pAd->CommonCfg.REGBACapability.field.AutoBA = TRUE;
352 else
354 pAd->CommonCfg.BACapability.field.AutoBA = FALSE;
355 pAd->CommonCfg.REGBACapability.field.AutoBA = FALSE;
357 #endif // DOT11_N_SUPPORT //
358 // Set AdhocMode rates
359 if (pAd->StaCfg.BssType == BSS_ADHOC)
361 MlmeUpdateTxRates(pAd, FALSE, 0);
362 MakeIbssBeacon(pAd); // re-build BEACON frame
363 AsicEnableIbssSync(pAd); // copy to on-chip memory
366 #endif // CONFIG_STA_SUPPORT //
368 // it is needed to set SSID to take effect
369 #ifdef DOT11_N_SUPPORT
370 SetCommonHT(pAd);
371 #endif // DOT11_N_SUPPORT //
372 DBGPRINT(RT_DEBUG_TRACE, ("Set_WirelessMode_Proc::(=%d)\n", pAd->CommonCfg.PhyMode));
374 else
376 DBGPRINT(RT_DEBUG_ERROR, ("Set_WirelessMode_Proc::parameters out of range\n"));
379 return success;
383 ==========================================================================
384 Description:
385 Set Channel
386 Return:
387 TRUE if all parameters are OK, FALSE otherwise
388 ==========================================================================
390 INT Set_Channel_Proc(
391 IN PRTMP_ADAPTER pAd,
392 IN PSTRING arg)
394 INT success = TRUE;
395 UCHAR Channel;
397 Channel = (UCHAR) simple_strtol(arg, 0, 10);
399 // check if this channel is valid
400 if (ChannelSanity(pAd, Channel) == TRUE)
402 #ifdef CONFIG_STA_SUPPORT
403 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
405 pAd->CommonCfg.Channel = Channel;
407 if (MONITOR_ON(pAd))
409 #ifdef DOT11_N_SUPPORT
410 N_ChannelCheck(pAd);
411 if (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED &&
412 pAd->CommonCfg.RegTransmitSetting.field.BW == BW_40)
414 N_SetCenCh(pAd);
415 AsicSwitchChannel(pAd, pAd->CommonCfg.CentralChannel, FALSE);
416 AsicLockChannel(pAd, pAd->CommonCfg.CentralChannel);
417 DBGPRINT(RT_DEBUG_TRACE, ("BW_40, control_channel(%d), CentralChannel(%d) \n",
418 pAd->CommonCfg.Channel, pAd->CommonCfg.CentralChannel));
420 else
421 #endif // DOT11_N_SUPPORT //
423 AsicSwitchChannel(pAd, pAd->CommonCfg.Channel, FALSE);
424 AsicLockChannel(pAd, pAd->CommonCfg.Channel);
425 DBGPRINT(RT_DEBUG_TRACE, ("BW_20, Channel(%d)\n", pAd->CommonCfg.Channel));
429 #endif // CONFIG_STA_SUPPORT //
430 success = TRUE;
432 else
435 #ifdef CONFIG_STA_SUPPORT
436 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
437 success = FALSE;
438 #endif // CONFIG_STA_SUPPORT //
442 if (success == TRUE)
443 DBGPRINT(RT_DEBUG_TRACE, ("Set_Channel_Proc::(Channel=%d)\n", pAd->CommonCfg.Channel));
445 return success;
450 ==========================================================================
451 Description:
452 Set Short Slot Time Enable or Disable
453 Return:
454 TRUE if all parameters are OK, FALSE otherwise
455 ==========================================================================
457 INT Set_ShortSlot_Proc(
458 IN PRTMP_ADAPTER pAd,
459 IN PSTRING arg)
461 int retval;
463 retval = RT_CfgSetShortSlot(pAd, arg);
464 if (retval == TRUE)
465 DBGPRINT(RT_DEBUG_TRACE, ("Set_ShortSlot_Proc::(ShortSlot=%d)\n", pAd->CommonCfg.bUseShortSlotTime));
467 return retval;
472 ==========================================================================
473 Description:
474 Set Tx power
475 Return:
476 TRUE if all parameters are OK, FALSE otherwise
477 ==========================================================================
479 INT Set_TxPower_Proc(
480 IN PRTMP_ADAPTER pAd,
481 IN PSTRING arg)
483 LONG TxPower;
484 INT success = FALSE;
486 TxPower = simple_strtol(arg, 0, 10);
487 if (TxPower <= 100)
490 #ifdef CONFIG_STA_SUPPORT
491 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
493 pAd->CommonCfg.TxPowerDefault = TxPower;
494 pAd->CommonCfg.TxPowerPercentage = pAd->CommonCfg.TxPowerDefault;
496 #endif // CONFIG_STA_SUPPORT //
497 success = TRUE;
499 else
500 success = FALSE;
502 DBGPRINT(RT_DEBUG_TRACE, ("Set_TxPower_Proc::(TxPowerPercentage=%ld)\n", pAd->CommonCfg.TxPowerPercentage));
504 return success;
508 ==========================================================================
509 Description:
510 Set 11B/11G Protection
511 Return:
512 TRUE if all parameters are OK, FALSE otherwise
513 ==========================================================================
515 INT Set_BGProtection_Proc(
516 IN PRTMP_ADAPTER pAd,
517 IN PSTRING arg)
519 switch (simple_strtol(arg, 0, 10))
521 case 0: //AUTO
522 pAd->CommonCfg.UseBGProtection = 0;
523 break;
524 case 1: //Always On
525 pAd->CommonCfg.UseBGProtection = 1;
526 break;
527 case 2: //Always OFF
528 pAd->CommonCfg.UseBGProtection = 2;
529 break;
530 default: //Invalid argument
531 return FALSE;
535 DBGPRINT(RT_DEBUG_TRACE, ("Set_BGProtection_Proc::(BGProtection=%ld)\n", pAd->CommonCfg.UseBGProtection));
537 return TRUE;
541 ==========================================================================
542 Description:
543 Set TxPreamble
544 Return:
545 TRUE if all parameters are OK, FALSE otherwise
546 ==========================================================================
548 INT Set_TxPreamble_Proc(
549 IN PRTMP_ADAPTER pAd,
550 IN PSTRING arg)
552 RT_802_11_PREAMBLE Preamble;
554 Preamble = simple_strtol(arg, 0, 10);
557 switch (Preamble)
559 case Rt802_11PreambleShort:
560 pAd->CommonCfg.TxPreamble = Preamble;
561 #ifdef CONFIG_STA_SUPPORT
562 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
563 MlmeSetTxPreamble(pAd, Rt802_11PreambleShort);
564 #endif // CONFIG_STA_SUPPORT //
565 break;
566 case Rt802_11PreambleLong:
567 #ifdef CONFIG_STA_SUPPORT
568 case Rt802_11PreambleAuto:
569 // if user wants AUTO, initialize to LONG here, then change according to AP's
570 // capability upon association.
571 #endif // CONFIG_STA_SUPPORT //
572 pAd->CommonCfg.TxPreamble = Preamble;
573 #ifdef CONFIG_STA_SUPPORT
574 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
575 MlmeSetTxPreamble(pAd, Rt802_11PreambleLong);
576 #endif // CONFIG_STA_SUPPORT //
577 break;
578 default: //Invalid argument
579 return FALSE;
582 DBGPRINT(RT_DEBUG_TRACE, ("Set_TxPreamble_Proc::(TxPreamble=%ld)\n", pAd->CommonCfg.TxPreamble));
584 return TRUE;
588 ==========================================================================
589 Description:
590 Set RTS Threshold
591 Return:
592 TRUE if all parameters are OK, FALSE otherwise
593 ==========================================================================
595 INT Set_RTSThreshold_Proc(
596 IN PRTMP_ADAPTER pAd,
597 IN PSTRING arg)
599 NDIS_802_11_RTS_THRESHOLD RtsThresh;
601 RtsThresh = simple_strtol(arg, 0, 10);
603 if((RtsThresh > 0) && (RtsThresh <= MAX_RTS_THRESHOLD))
604 pAd->CommonCfg.RtsThreshold = (USHORT)RtsThresh;
605 #ifdef CONFIG_STA_SUPPORT
606 else if (RtsThresh == 0)
607 pAd->CommonCfg.RtsThreshold = MAX_RTS_THRESHOLD;
608 #endif // CONFIG_STA_SUPPORT //
609 else
610 return FALSE; //Invalid argument
612 DBGPRINT(RT_DEBUG_TRACE, ("Set_RTSThreshold_Proc::(RTSThreshold=%d)\n", pAd->CommonCfg.RtsThreshold));
614 return TRUE;
618 ==========================================================================
619 Description:
620 Set Fragment Threshold
621 Return:
622 TRUE if all parameters are OK, FALSE otherwise
623 ==========================================================================
625 INT Set_FragThreshold_Proc(
626 IN PRTMP_ADAPTER pAd,
627 IN PSTRING arg)
629 NDIS_802_11_FRAGMENTATION_THRESHOLD FragThresh;
631 FragThresh = simple_strtol(arg, 0, 10);
633 if (FragThresh > MAX_FRAG_THRESHOLD || FragThresh < MIN_FRAG_THRESHOLD)
635 //Illegal FragThresh so we set it to default
636 pAd->CommonCfg.FragmentThreshold = MAX_FRAG_THRESHOLD;
638 else if (FragThresh % 2 == 1)
640 // The length of each fragment shall always be an even number of octets, except for the last fragment
641 // of an MSDU or MMPDU, which may be either an even or an odd number of octets.
642 pAd->CommonCfg.FragmentThreshold = (USHORT)(FragThresh - 1);
644 else
646 pAd->CommonCfg.FragmentThreshold = (USHORT)FragThresh;
649 #ifdef CONFIG_STA_SUPPORT
650 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
652 if (pAd->CommonCfg.FragmentThreshold == MAX_FRAG_THRESHOLD)
653 pAd->CommonCfg.bUseZeroToDisableFragment = TRUE;
654 else
655 pAd->CommonCfg.bUseZeroToDisableFragment = FALSE;
657 #endif // CONFIG_STA_SUPPORT //
659 DBGPRINT(RT_DEBUG_TRACE, ("Set_FragThreshold_Proc::(FragThreshold=%d)\n", pAd->CommonCfg.FragmentThreshold));
661 return TRUE;
665 ==========================================================================
666 Description:
667 Set TxBurst
668 Return:
669 TRUE if all parameters are OK, FALSE otherwise
670 ==========================================================================
672 INT Set_TxBurst_Proc(
673 IN PRTMP_ADAPTER pAd,
674 IN PSTRING arg)
676 LONG TxBurst;
678 TxBurst = simple_strtol(arg, 0, 10);
679 if (TxBurst == 1)
680 pAd->CommonCfg.bEnableTxBurst = TRUE;
681 else if (TxBurst == 0)
682 pAd->CommonCfg.bEnableTxBurst = FALSE;
683 else
684 return FALSE; //Invalid argument
686 DBGPRINT(RT_DEBUG_TRACE, ("Set_TxBurst_Proc::(TxBurst=%d)\n", pAd->CommonCfg.bEnableTxBurst));
688 return TRUE;
691 #ifdef AGGREGATION_SUPPORT
693 ==========================================================================
694 Description:
695 Set TxBurst
696 Return:
697 TRUE if all parameters are OK, FALSE otherwise
698 ==========================================================================
700 INT Set_PktAggregate_Proc(
701 IN PRTMP_ADAPTER pAd,
702 IN PSTRING arg)
704 LONG aggre;
706 aggre = simple_strtol(arg, 0, 10);
708 if (aggre == 1)
709 pAd->CommonCfg.bAggregationCapable = TRUE;
710 else if (aggre == 0)
711 pAd->CommonCfg.bAggregationCapable = FALSE;
712 else
713 return FALSE; //Invalid argument
716 DBGPRINT(RT_DEBUG_TRACE, ("Set_PktAggregate_Proc::(AGGRE=%d)\n", pAd->CommonCfg.bAggregationCapable));
718 return TRUE;
720 #endif
723 #ifdef INF_AMAZON_PPA
724 INT Set_INF_AMAZON_SE_PPA_Proc(
725 IN PRTMP_ADAPTER pAd,
726 IN PUCHAR arg)
728 ULONG aggre;
729 UINT status;
731 aggre = simple_strtol(arg, 0, 10);
733 if (aggre == 1)
735 if(pAd->PPAEnable==TRUE)
737 printk("INF_AMAZON_SE_PPA already enabled \n");
739 else
741 if (ppa_hook_directpath_register_dev_fn)
743 UINT32 g_if_id;
745 if (pAd->pDirectpathCb == NULL)
747 pAd->pDirectpathCb = (PPA_DIRECTPATH_CB *) kmalloc (sizeof(PPA_DIRECTPATH_CB), GFP_ATOMIC);
748 printk("Realloc memory for pDirectpathCb ??\n");
751 /* register callback */
752 pAd->pDirectpathCb->rx_fn = NULL;
753 pAd->pDirectpathCb->stop_tx_fn = NULL;
754 pAd->pDirectpathCb->start_tx_fn = NULL;
756 status = ppa_hook_directpath_register_dev_fn(&g_if_id, pAd->net_dev, pAd->pDirectpathCb, PPA_F_DIRECTPATH_ETH_IF);
758 if(status==1)
760 pAd->g_if_id=g_if_id;
761 printk("register INF_AMAZON_SE_PPA success :ret:%d id:%d:%d\n",status,pAd->g_if_id,g_if_id);
762 pAd->PPAEnable=TRUE;
764 else
766 printk("register INF_AMAZON_SE_PPA fail :ret:%d\n",status);
770 else
772 printk("INF_AMAZON_SE_PPA enable fail : there is no INF_AMAZON_SE_PPA module . \n");
778 else if (aggre == 0)
780 if(pAd->PPAEnable==FALSE)
783 printk("INF_AMAZON_SE_PPA already disable \n");
785 else
787 if (ppa_hook_directpath_register_dev_fn)
789 UINT32 g_if_id;
790 g_if_id=pAd->g_if_id;
791 printk("g_if_id=%d \n",pAd->g_if_id);
792 status=ppa_hook_directpath_register_dev_fn(&g_if_id, pAd->net_dev, NULL, PPA_F_DIRECTPATH_DEREGISTER);
794 if(status==1)
796 pAd->g_if_id=0;
797 printk("unregister INF_AMAZON_SE_PPA success :ret:%d\n",status);
798 pAd->PPAEnable=FALSE;
800 else
802 printk("unregister INF_AMAZON_SE_PPA fail :ret:%d\n",status);
806 else
808 printk("INF_AMAZON_SE_PPA enable fail : there is no INF_AMAZON_SE_PPA module . \n");
813 else
815 printk("Invalid argument %d \n",aggre);
816 return FALSE; //Invalid argument
819 return TRUE;
822 #endif // INF_AMAZON_PPA //
826 ==========================================================================
827 Description:
828 Set IEEE80211H.
829 This parameter is 1 when needs radar detection, otherwise 0
830 Return:
831 TRUE if all parameters are OK, FALSE otherwise
832 ==========================================================================
834 INT Set_IEEE80211H_Proc(
835 IN PRTMP_ADAPTER pAd,
836 IN PSTRING arg)
838 LONG ieee80211h;
840 ieee80211h = simple_strtol(arg, 0, 10);
842 if (ieee80211h == 1)
843 pAd->CommonCfg.bIEEE80211H = TRUE;
844 else if (ieee80211h == 0)
845 pAd->CommonCfg.bIEEE80211H = FALSE;
846 else
847 return FALSE; //Invalid argument
849 DBGPRINT(RT_DEBUG_TRACE, ("Set_IEEE80211H_Proc::(IEEE80211H=%d)\n", pAd->CommonCfg.bIEEE80211H));
851 return TRUE;
855 #ifdef DBG
857 ==========================================================================
858 Description:
859 For Debug information
860 Return:
861 TRUE if all parameters are OK, FALSE otherwise
862 ==========================================================================
864 INT Set_Debug_Proc(
865 IN PRTMP_ADAPTER pAd,
866 IN PSTRING arg)
868 DBGPRINT(RT_DEBUG_TRACE, ("==> Set_Debug_Proc *******************\n"));
870 if(simple_strtol(arg, 0, 10) <= RT_DEBUG_LOUD)
871 RTDebugLevel = simple_strtol(arg, 0, 10);
873 DBGPRINT(RT_DEBUG_TRACE, ("<== Set_Debug_Proc(RTDebugLevel = %ld)\n", RTDebugLevel));
875 return TRUE;
877 #endif
879 INT Show_DescInfo_Proc(
880 IN PRTMP_ADAPTER pAd,
881 IN PSTRING arg)
883 #ifdef RTMP_MAC_PCI
884 INT i, QueIdx=0;
885 // ULONG RegValue;
886 PRT28XX_RXD_STRUC pRxD;
887 PTXD_STRUC pTxD;
888 PRTMP_TX_RING pTxRing = &pAd->TxRing[QueIdx];
889 PRTMP_MGMT_RING pMgmtRing = &pAd->MgmtRing;
890 PRTMP_RX_RING pRxRing = &pAd->RxRing;
892 for(i=0;i<TX_RING_SIZE;i++)
894 pTxD = (PTXD_STRUC) pTxRing->Cell[i].AllocVa;
895 DBGPRINT(RT_DEBUG_OFF, ("Desc #%d\n",i));
896 hex_dump("Tx Descriptor", (PUCHAR)pTxD, 16);
897 DBGPRINT(RT_DEBUG_OFF, ("pTxD->DMADONE = %x\n", pTxD->DMADONE));
899 DBGPRINT(RT_DEBUG_OFF, ("---------------------------------------------------\n"));
900 for(i=0;i<MGMT_RING_SIZE;i++)
902 pTxD = (PTXD_STRUC) pMgmtRing->Cell[i].AllocVa;
903 DBGPRINT(RT_DEBUG_OFF, ("Desc #%d\n",i));
904 hex_dump("Mgmt Descriptor", (PUCHAR)pTxD, 16);
905 DBGPRINT(RT_DEBUG_OFF, ("pMgmt->DMADONE = %x\n", pTxD->DMADONE));
907 DBGPRINT(RT_DEBUG_OFF, ("---------------------------------------------------\n"));
908 for(i=0;i<RX_RING_SIZE;i++)
910 pRxD = (PRT28XX_RXD_STRUC) pRxRing->Cell[i].AllocVa;
911 DBGPRINT(RT_DEBUG_OFF, ("Desc #%d\n",i));
912 hex_dump("Rx Descriptor", (PUCHAR)pRxD, 16);
913 DBGPRINT(RT_DEBUG_OFF, ("pRxD->DDONE = %x\n", pRxD->DDONE));
915 #endif // RTMP_MAC_PCI //
917 return TRUE;
921 ==========================================================================
922 Description:
923 Reset statistics counter
925 Arguments:
926 pAdapter Pointer to our adapter
929 Return:
930 TRUE if all parameters are OK, FALSE otherwise
931 ==========================================================================
933 INT Set_ResetStatCounter_Proc(
934 IN PRTMP_ADAPTER pAd,
935 IN PSTRING arg)
937 //UCHAR i;
938 //MAC_TABLE_ENTRY *pEntry;
940 DBGPRINT(RT_DEBUG_TRACE, ("==>Set_ResetStatCounter_Proc\n"));
942 // add the most up-to-date h/w raw counters into software counters
943 NICUpdateRawCounters(pAd);
945 NdisZeroMemory(&pAd->WlanCounters, sizeof(COUNTER_802_11));
946 NdisZeroMemory(&pAd->Counters8023, sizeof(COUNTER_802_3));
947 NdisZeroMemory(&pAd->RalinkCounters, sizeof(COUNTER_RALINK));
949 // Reset HotSpot counter
952 return TRUE;
956 ========================================================================
958 Routine Description:
959 Add WPA key process.
960 In Adhoc WPANONE, bPairwise = 0; KeyIdx = 0;
962 Arguments:
963 pAd Pointer to our adapter
964 pBuf Pointer to the where the key stored
966 Return Value:
967 NDIS_SUCCESS Add key successfully
969 IRQL = DISPATCH_LEVEL
971 Note:
973 ========================================================================
976 BOOLEAN RTMPCheckStrPrintAble(
977 IN CHAR *pInPutStr,
978 IN UCHAR strLen)
980 UCHAR i=0;
982 for (i=0; i<strLen; i++)
984 if ((pInPutStr[i] < 0x21) ||
985 (pInPutStr[i] > 0x7E))
986 return FALSE;
989 return TRUE;
993 ========================================================================
995 Routine Description:
996 Remove WPA Key process
998 Arguments:
999 pAd Pointer to our adapter
1000 pBuf Pointer to the where the key stored
1002 Return Value:
1003 NDIS_SUCCESS Add key successfully
1005 IRQL = DISPATCH_LEVEL
1007 Note:
1009 ========================================================================
1011 #ifdef CONFIG_STA_SUPPORT
1012 VOID RTMPSetDesiredRates(
1013 IN PRTMP_ADAPTER pAdapter,
1014 IN LONG Rates)
1016 NDIS_802_11_RATES aryRates;
1018 memset(&aryRates, 0x00, sizeof(NDIS_802_11_RATES));
1019 switch (pAdapter->CommonCfg.PhyMode)
1021 case PHY_11A: // A only
1022 switch (Rates)
1024 case 6000000: //6M
1025 aryRates[0] = 0x0c; // 6M
1026 pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_0;
1027 break;
1028 case 9000000: //9M
1029 aryRates[0] = 0x12; // 9M
1030 pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_1;
1031 break;
1032 case 12000000: //12M
1033 aryRates[0] = 0x18; // 12M
1034 pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_2;
1035 break;
1036 case 18000000: //18M
1037 aryRates[0] = 0x24; // 18M
1038 pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_3;
1039 break;
1040 case 24000000: //24M
1041 aryRates[0] = 0x30; // 24M
1042 pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_4;
1043 break;
1044 case 36000000: //36M
1045 aryRates[0] = 0x48; // 36M
1046 pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_5;
1047 break;
1048 case 48000000: //48M
1049 aryRates[0] = 0x60; // 48M
1050 pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_6;
1051 break;
1052 case 54000000: //54M
1053 aryRates[0] = 0x6c; // 54M
1054 pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_7;
1055 break;
1056 case -1: //Auto
1057 default:
1058 aryRates[0] = 0x6c; // 54Mbps
1059 aryRates[1] = 0x60; // 48Mbps
1060 aryRates[2] = 0x48; // 36Mbps
1061 aryRates[3] = 0x30; // 24Mbps
1062 aryRates[4] = 0x24; // 18M
1063 aryRates[5] = 0x18; // 12M
1064 aryRates[6] = 0x12; // 9M
1065 aryRates[7] = 0x0c; // 6M
1066 pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_AUTO;
1067 break;
1069 break;
1070 case PHY_11BG_MIXED: // B/G Mixed
1071 case PHY_11B: // B only
1072 case PHY_11ABG_MIXED: // A/B/G Mixed
1073 default:
1074 switch (Rates)
1076 case 1000000: //1M
1077 aryRates[0] = 0x02;
1078 pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_0;
1079 break;
1080 case 2000000: //2M
1081 aryRates[0] = 0x04;
1082 pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_1;
1083 break;
1084 case 5000000: //5.5M
1085 aryRates[0] = 0x0b; // 5.5M
1086 pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_2;
1087 break;
1088 case 11000000: //11M
1089 aryRates[0] = 0x16; // 11M
1090 pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_3;
1091 break;
1092 case 6000000: //6M
1093 aryRates[0] = 0x0c; // 6M
1094 pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_0;
1095 break;
1096 case 9000000: //9M
1097 aryRates[0] = 0x12; // 9M
1098 pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_1;
1099 break;
1100 case 12000000: //12M
1101 aryRates[0] = 0x18; // 12M
1102 pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_2;
1103 break;
1104 case 18000000: //18M
1105 aryRates[0] = 0x24; // 18M
1106 pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_3;
1107 break;
1108 case 24000000: //24M
1109 aryRates[0] = 0x30; // 24M
1110 pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_4;
1111 break;
1112 case 36000000: //36M
1113 aryRates[0] = 0x48; // 36M
1114 pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_5;
1115 break;
1116 case 48000000: //48M
1117 aryRates[0] = 0x60; // 48M
1118 pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_6;
1119 break;
1120 case 54000000: //54M
1121 aryRates[0] = 0x6c; // 54M
1122 pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_7;
1123 break;
1124 case -1: //Auto
1125 default:
1126 if (pAdapter->CommonCfg.PhyMode == PHY_11B)
1127 { //B Only
1128 aryRates[0] = 0x16; // 11Mbps
1129 aryRates[1] = 0x0b; // 5.5Mbps
1130 aryRates[2] = 0x04; // 2Mbps
1131 aryRates[3] = 0x02; // 1Mbps
1133 else
1134 { //(B/G) Mixed or (A/B/G) Mixed
1135 aryRates[0] = 0x6c; // 54Mbps
1136 aryRates[1] = 0x60; // 48Mbps
1137 aryRates[2] = 0x48; // 36Mbps
1138 aryRates[3] = 0x30; // 24Mbps
1139 aryRates[4] = 0x16; // 11Mbps
1140 aryRates[5] = 0x0b; // 5.5Mbps
1141 aryRates[6] = 0x04; // 2Mbps
1142 aryRates[7] = 0x02; // 1Mbps
1144 pAdapter->StaCfg.DesiredTransmitSetting.field.MCS = MCS_AUTO;
1145 break;
1147 break;
1150 NdisZeroMemory(pAdapter->CommonCfg.DesireRate, MAX_LEN_OF_SUPPORTED_RATES);
1151 NdisMoveMemory(pAdapter->CommonCfg.DesireRate, &aryRates, sizeof(NDIS_802_11_RATES));
1152 DBGPRINT(RT_DEBUG_TRACE, (" RTMPSetDesiredRates (%02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x)\n",
1153 pAdapter->CommonCfg.DesireRate[0],pAdapter->CommonCfg.DesireRate[1],
1154 pAdapter->CommonCfg.DesireRate[2],pAdapter->CommonCfg.DesireRate[3],
1155 pAdapter->CommonCfg.DesireRate[4],pAdapter->CommonCfg.DesireRate[5],
1156 pAdapter->CommonCfg.DesireRate[6],pAdapter->CommonCfg.DesireRate[7] ));
1157 // Changing DesiredRate may affect the MAX TX rate we used to TX frames out
1158 MlmeUpdateTxRates(pAdapter, FALSE, 0);
1161 NDIS_STATUS RTMPWPARemoveKeyProc(
1162 IN PRTMP_ADAPTER pAd,
1163 IN PVOID pBuf)
1165 PNDIS_802_11_REMOVE_KEY pKey;
1166 ULONG KeyIdx;
1167 NDIS_STATUS Status = NDIS_STATUS_FAILURE;
1168 BOOLEAN bTxKey; // Set the key as transmit key
1169 BOOLEAN bPairwise; // Indicate the key is pairwise key
1170 BOOLEAN bKeyRSC; // indicate the receive SC set by KeyRSC value.
1171 // Otherwise, it will set by the NIC.
1172 BOOLEAN bAuthenticator; // indicate key is set by authenticator.
1173 INT i;
1175 DBGPRINT(RT_DEBUG_TRACE,("---> RTMPWPARemoveKeyProc\n"));
1177 pKey = (PNDIS_802_11_REMOVE_KEY) pBuf;
1178 KeyIdx = pKey->KeyIndex & 0xff;
1179 // Bit 31 of Add-key, Tx Key
1180 bTxKey = (pKey->KeyIndex & 0x80000000) ? TRUE : FALSE;
1181 // Bit 30 of Add-key PairwiseKey
1182 bPairwise = (pKey->KeyIndex & 0x40000000) ? TRUE : FALSE;
1183 // Bit 29 of Add-key KeyRSC
1184 bKeyRSC = (pKey->KeyIndex & 0x20000000) ? TRUE : FALSE;
1185 // Bit 28 of Add-key Authenticator
1186 bAuthenticator = (pKey->KeyIndex & 0x10000000) ? TRUE : FALSE;
1188 // 1. If bTx is TRUE, return failure information
1189 if (bTxKey == TRUE)
1190 return(NDIS_STATUS_INVALID_DATA);
1192 // 2. Check Pairwise Key
1193 if (bPairwise)
1195 // a. If BSSID is broadcast, remove all pairwise keys.
1196 // b. If not broadcast, remove the pairwise specified by BSSID
1197 for (i = 0; i < SHARE_KEY_NUM; i++)
1199 if (MAC_ADDR_EQUAL(pAd->SharedKey[BSS0][i].BssId, pKey->BSSID))
1201 DBGPRINT(RT_DEBUG_TRACE,("RTMPWPARemoveKeyProc(KeyIdx=%d)\n", i));
1202 pAd->SharedKey[BSS0][i].KeyLen = 0;
1203 pAd->SharedKey[BSS0][i].CipherAlg = CIPHER_NONE;
1204 AsicRemoveSharedKeyEntry(pAd, BSS0, (UCHAR)i);
1205 Status = NDIS_STATUS_SUCCESS;
1206 break;
1210 // 3. Group Key
1211 else
1213 // a. If BSSID is broadcast, remove all group keys indexed
1214 // b. If BSSID matched, delete the group key indexed.
1215 DBGPRINT(RT_DEBUG_TRACE,("RTMPWPARemoveKeyProc(KeyIdx=%ld)\n", KeyIdx));
1216 pAd->SharedKey[BSS0][KeyIdx].KeyLen = 0;
1217 pAd->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_NONE;
1218 AsicRemoveSharedKeyEntry(pAd, BSS0, (UCHAR)KeyIdx);
1219 Status = NDIS_STATUS_SUCCESS;
1222 return (Status);
1224 #endif // CONFIG_STA_SUPPORT //
1227 #ifdef CONFIG_STA_SUPPORT
1229 ========================================================================
1231 Routine Description:
1232 Remove All WPA Keys
1234 Arguments:
1235 pAd Pointer to our adapter
1237 Return Value:
1238 None
1240 IRQL = DISPATCH_LEVEL
1242 Note:
1244 ========================================================================
1246 VOID RTMPWPARemoveAllKeys(
1247 IN PRTMP_ADAPTER pAd)
1250 UCHAR i;
1252 DBGPRINT(RT_DEBUG_TRACE,("RTMPWPARemoveAllKeys(AuthMode=%d, WepStatus=%d)\n", pAd->StaCfg.AuthMode, pAd->StaCfg.WepStatus));
1253 RTMP_CLEAR_PSFLAG(pAd, fRTMP_PS_CAN_GO_SLEEP);
1254 // For WEP/CKIP, there is no need to remove it, since WinXP won't set it again after
1255 // Link up. And it will be replaced if user changed it.
1256 if (pAd->StaCfg.AuthMode < Ndis802_11AuthModeWPA)
1257 return;
1259 // For WPA-None, there is no need to remove it, since WinXP won't set it again after
1260 // Link up. And it will be replaced if user changed it.
1261 if (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPANone)
1262 return;
1264 // set BSSID wcid entry of the Pair-wise Key table as no-security mode
1265 AsicRemovePairwiseKeyEntry(pAd, BSS0, BSSID_WCID);
1267 // set all shared key mode as no-security.
1268 for (i = 0; i < SHARE_KEY_NUM; i++)
1270 DBGPRINT(RT_DEBUG_TRACE,("remove %s key #%d\n", CipherName[pAd->SharedKey[BSS0][i].CipherAlg], i));
1271 NdisZeroMemory(&pAd->SharedKey[BSS0][i], sizeof(CIPHER_KEY));
1273 AsicRemoveSharedKeyEntry(pAd, BSS0, i);
1275 RTMP_SET_PSFLAG(pAd, fRTMP_PS_CAN_GO_SLEEP);
1278 #endif // CONFIG_STA_SUPPORT //
1282 ========================================================================
1284 Routine Description:
1285 As STA's BSSID is a WC too, it uses shared key table.
1286 This function write correct unicast TX key to ASIC WCID.
1287 And we still make a copy in our MacTab.Content[BSSID_WCID].PairwiseKey.
1288 Caller guarantee TKIP/AES always has keyidx = 0. (pairwise key)
1289 Caller guarantee WEP calls this function when set Txkey, default key index=0~3.
1291 Arguments:
1292 pAd Pointer to our adapter
1293 pKey Pointer to the where the key stored
1295 Return Value:
1296 NDIS_SUCCESS Add key successfully
1298 IRQL = DISPATCH_LEVEL
1300 Note:
1302 ========================================================================
1305 ========================================================================
1306 Routine Description:
1307 Change NIC PHY mode. Re-association may be necessary. possible settings
1308 include - PHY_11B, PHY_11BG_MIXED, PHY_11A, and PHY_11ABG_MIXED
1310 Arguments:
1311 pAd - Pointer to our adapter
1312 phymode -
1314 IRQL = PASSIVE_LEVEL
1315 IRQL = DISPATCH_LEVEL
1317 ========================================================================
1319 VOID RTMPSetPhyMode(
1320 IN PRTMP_ADAPTER pAd,
1321 IN ULONG phymode)
1323 INT i;
1324 // the selected phymode must be supported by the RF IC encoded in E2PROM
1326 // if no change, do nothing
1327 /* bug fix
1328 if (pAd->CommonCfg.PhyMode == phymode)
1329 return;
1331 pAd->CommonCfg.PhyMode = (UCHAR)phymode;
1333 DBGPRINT(RT_DEBUG_TRACE,("RTMPSetPhyMode : PhyMode=%d, channel=%d \n", pAd->CommonCfg.PhyMode, pAd->CommonCfg.Channel));
1334 #ifdef EXT_BUILD_CHANNEL_LIST
1335 BuildChannelListEx(pAd);
1336 #else
1337 BuildChannelList(pAd);
1338 #endif // EXT_BUILD_CHANNEL_LIST //
1340 // sanity check user setting
1341 for (i = 0; i < pAd->ChannelListNum; i++)
1343 if (pAd->CommonCfg.Channel == pAd->ChannelList[i].Channel)
1344 break;
1347 if (i == pAd->ChannelListNum)
1349 #ifdef CONFIG_STA_SUPPORT
1350 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
1351 pAd->CommonCfg.Channel = FirstChannel(pAd);
1352 #endif // CONFIG_STA_SUPPORT //
1353 DBGPRINT(RT_DEBUG_ERROR, ("RTMPSetPhyMode: channel is out of range, use first channel=%d \n", pAd->CommonCfg.Channel));
1356 NdisZeroMemory(pAd->CommonCfg.SupRate, MAX_LEN_OF_SUPPORTED_RATES);
1357 NdisZeroMemory(pAd->CommonCfg.ExtRate, MAX_LEN_OF_SUPPORTED_RATES);
1358 NdisZeroMemory(pAd->CommonCfg.DesireRate, MAX_LEN_OF_SUPPORTED_RATES);
1359 switch (phymode) {
1360 case PHY_11B:
1361 pAd->CommonCfg.SupRate[0] = 0x82; // 1 mbps, in units of 0.5 Mbps, basic rate
1362 pAd->CommonCfg.SupRate[1] = 0x84; // 2 mbps, in units of 0.5 Mbps, basic rate
1363 pAd->CommonCfg.SupRate[2] = 0x8B; // 5.5 mbps, in units of 0.5 Mbps, basic rate
1364 pAd->CommonCfg.SupRate[3] = 0x96; // 11 mbps, in units of 0.5 Mbps, basic rate
1365 pAd->CommonCfg.SupRateLen = 4;
1366 pAd->CommonCfg.ExtRateLen = 0;
1367 pAd->CommonCfg.DesireRate[0] = 2; // 1 mbps, in units of 0.5 Mbps
1368 pAd->CommonCfg.DesireRate[1] = 4; // 2 mbps, in units of 0.5 Mbps
1369 pAd->CommonCfg.DesireRate[2] = 11; // 5.5 mbps, in units of 0.5 Mbps
1370 pAd->CommonCfg.DesireRate[3] = 22; // 11 mbps, in units of 0.5 Mbps
1371 //pAd->CommonCfg.HTPhyMode.field.MODE = MODE_CCK; // This MODE is only FYI. not use
1372 break;
1374 case PHY_11G:
1375 case PHY_11BG_MIXED:
1376 case PHY_11ABG_MIXED:
1377 #ifdef DOT11_N_SUPPORT
1378 case PHY_11N_2_4G:
1379 case PHY_11ABGN_MIXED:
1380 case PHY_11BGN_MIXED:
1381 case PHY_11GN_MIXED:
1382 #endif // DOT11_N_SUPPORT //
1383 pAd->CommonCfg.SupRate[0] = 0x82; // 1 mbps, in units of 0.5 Mbps, basic rate
1384 pAd->CommonCfg.SupRate[1] = 0x84; // 2 mbps, in units of 0.5 Mbps, basic rate
1385 pAd->CommonCfg.SupRate[2] = 0x8B; // 5.5 mbps, in units of 0.5 Mbps, basic rate
1386 pAd->CommonCfg.SupRate[3] = 0x96; // 11 mbps, in units of 0.5 Mbps, basic rate
1387 pAd->CommonCfg.SupRate[4] = 0x12; // 9 mbps, in units of 0.5 Mbps
1388 pAd->CommonCfg.SupRate[5] = 0x24; // 18 mbps, in units of 0.5 Mbps
1389 pAd->CommonCfg.SupRate[6] = 0x48; // 36 mbps, in units of 0.5 Mbps
1390 pAd->CommonCfg.SupRate[7] = 0x6c; // 54 mbps, in units of 0.5 Mbps
1391 pAd->CommonCfg.SupRateLen = 8;
1392 pAd->CommonCfg.ExtRate[0] = 0x0C; // 6 mbps, in units of 0.5 Mbps
1393 pAd->CommonCfg.ExtRate[1] = 0x18; // 12 mbps, in units of 0.5 Mbps
1394 pAd->CommonCfg.ExtRate[2] = 0x30; // 24 mbps, in units of 0.5 Mbps
1395 pAd->CommonCfg.ExtRate[3] = 0x60; // 48 mbps, in units of 0.5 Mbps
1396 pAd->CommonCfg.ExtRateLen = 4;
1397 pAd->CommonCfg.DesireRate[0] = 2; // 1 mbps, in units of 0.5 Mbps
1398 pAd->CommonCfg.DesireRate[1] = 4; // 2 mbps, in units of 0.5 Mbps
1399 pAd->CommonCfg.DesireRate[2] = 11; // 5.5 mbps, in units of 0.5 Mbps
1400 pAd->CommonCfg.DesireRate[3] = 22; // 11 mbps, in units of 0.5 Mbps
1401 pAd->CommonCfg.DesireRate[4] = 12; // 6 mbps, in units of 0.5 Mbps
1402 pAd->CommonCfg.DesireRate[5] = 18; // 9 mbps, in units of 0.5 Mbps
1403 pAd->CommonCfg.DesireRate[6] = 24; // 12 mbps, in units of 0.5 Mbps
1404 pAd->CommonCfg.DesireRate[7] = 36; // 18 mbps, in units of 0.5 Mbps
1405 pAd->CommonCfg.DesireRate[8] = 48; // 24 mbps, in units of 0.5 Mbps
1406 pAd->CommonCfg.DesireRate[9] = 72; // 36 mbps, in units of 0.5 Mbps
1407 pAd->CommonCfg.DesireRate[10] = 96; // 48 mbps, in units of 0.5 Mbps
1408 pAd->CommonCfg.DesireRate[11] = 108; // 54 mbps, in units of 0.5 Mbps
1409 break;
1411 case PHY_11A:
1412 #ifdef DOT11_N_SUPPORT
1413 case PHY_11AN_MIXED:
1414 case PHY_11AGN_MIXED:
1415 case PHY_11N_5G:
1416 #endif // DOT11_N_SUPPORT //
1417 pAd->CommonCfg.SupRate[0] = 0x8C; // 6 mbps, in units of 0.5 Mbps, basic rate
1418 pAd->CommonCfg.SupRate[1] = 0x12; // 9 mbps, in units of 0.5 Mbps
1419 pAd->CommonCfg.SupRate[2] = 0x98; // 12 mbps, in units of 0.5 Mbps, basic rate
1420 pAd->CommonCfg.SupRate[3] = 0x24; // 18 mbps, in units of 0.5 Mbps
1421 pAd->CommonCfg.SupRate[4] = 0xb0; // 24 mbps, in units of 0.5 Mbps, basic rate
1422 pAd->CommonCfg.SupRate[5] = 0x48; // 36 mbps, in units of 0.5 Mbps
1423 pAd->CommonCfg.SupRate[6] = 0x60; // 48 mbps, in units of 0.5 Mbps
1424 pAd->CommonCfg.SupRate[7] = 0x6c; // 54 mbps, in units of 0.5 Mbps
1425 pAd->CommonCfg.SupRateLen = 8;
1426 pAd->CommonCfg.ExtRateLen = 0;
1427 pAd->CommonCfg.DesireRate[0] = 12; // 6 mbps, in units of 0.5 Mbps
1428 pAd->CommonCfg.DesireRate[1] = 18; // 9 mbps, in units of 0.5 Mbps
1429 pAd->CommonCfg.DesireRate[2] = 24; // 12 mbps, in units of 0.5 Mbps
1430 pAd->CommonCfg.DesireRate[3] = 36; // 18 mbps, in units of 0.5 Mbps
1431 pAd->CommonCfg.DesireRate[4] = 48; // 24 mbps, in units of 0.5 Mbps
1432 pAd->CommonCfg.DesireRate[5] = 72; // 36 mbps, in units of 0.5 Mbps
1433 pAd->CommonCfg.DesireRate[6] = 96; // 48 mbps, in units of 0.5 Mbps
1434 pAd->CommonCfg.DesireRate[7] = 108; // 54 mbps, in units of 0.5 Mbps
1435 //pAd->CommonCfg.HTPhyMode.field.MODE = MODE_OFDM; // This MODE is only FYI. not use
1436 break;
1438 default:
1439 break;
1443 pAd->CommonCfg.BandState = UNKNOWN_BAND;
1447 #ifdef DOT11_N_SUPPORT
1449 ========================================================================
1450 Routine Description:
1451 Caller ensures we has 802.11n support.
1452 Calls at setting HT from AP/STASetinformation
1454 Arguments:
1455 pAd - Pointer to our adapter
1456 phymode -
1458 ========================================================================
1460 VOID RTMPSetHT(
1461 IN PRTMP_ADAPTER pAd,
1462 IN OID_SET_HT_PHYMODE *pHTPhyMode)
1464 //ULONG *pmcs;
1465 UINT32 Value = 0;
1466 UCHAR BBPValue = 0;
1467 UCHAR BBP3Value = 0;
1468 UCHAR RxStream = pAd->CommonCfg.RxStream;
1470 DBGPRINT(RT_DEBUG_TRACE, ("RTMPSetHT : HT_mode(%d), ExtOffset(%d), MCS(%d), BW(%d), STBC(%d), SHORTGI(%d)\n",
1471 pHTPhyMode->HtMode, pHTPhyMode->ExtOffset,
1472 pHTPhyMode->MCS, pHTPhyMode->BW,
1473 pHTPhyMode->STBC, pHTPhyMode->SHORTGI));
1475 // Don't zero supportedHyPhy structure.
1476 RTMPZeroMemory(&pAd->CommonCfg.HtCapability, sizeof(pAd->CommonCfg.HtCapability));
1477 RTMPZeroMemory(&pAd->CommonCfg.AddHTInfo, sizeof(pAd->CommonCfg.AddHTInfo));
1478 RTMPZeroMemory(&pAd->CommonCfg.NewExtChanOffset, sizeof(pAd->CommonCfg.NewExtChanOffset));
1479 RTMPZeroMemory(&pAd->CommonCfg.DesiredHtPhy, sizeof(pAd->CommonCfg.DesiredHtPhy));
1481 if (pAd->CommonCfg.bRdg)
1483 pAd->CommonCfg.HtCapability.ExtHtCapInfo.PlusHTC = 1;
1484 pAd->CommonCfg.HtCapability.ExtHtCapInfo.RDGSupport = 1;
1486 else
1488 pAd->CommonCfg.HtCapability.ExtHtCapInfo.PlusHTC = 0;
1489 pAd->CommonCfg.HtCapability.ExtHtCapInfo.RDGSupport = 0;
1492 pAd->CommonCfg.HtCapability.HtCapParm.MaxRAmpduFactor = 3;
1493 pAd->CommonCfg.DesiredHtPhy.MaxRAmpduFactor = 3;
1495 DBGPRINT(RT_DEBUG_TRACE, ("RTMPSetHT : RxBAWinLimit = %d\n", pAd->CommonCfg.BACapability.field.RxBAWinLimit));
1497 // Mimo power save, A-MSDU size,
1498 pAd->CommonCfg.DesiredHtPhy.AmsduEnable = (USHORT)pAd->CommonCfg.BACapability.field.AmsduEnable;
1499 pAd->CommonCfg.DesiredHtPhy.AmsduSize = (UCHAR)pAd->CommonCfg.BACapability.field.AmsduSize;
1500 pAd->CommonCfg.DesiredHtPhy.MimoPs = (UCHAR)pAd->CommonCfg.BACapability.field.MMPSmode;
1501 pAd->CommonCfg.DesiredHtPhy.MpduDensity = (UCHAR)pAd->CommonCfg.BACapability.field.MpduDensity;
1503 pAd->CommonCfg.HtCapability.HtCapInfo.AMsduSize = (USHORT)pAd->CommonCfg.BACapability.field.AmsduSize;
1504 pAd->CommonCfg.HtCapability.HtCapInfo.MimoPs = (USHORT)pAd->CommonCfg.BACapability.field.MMPSmode;
1505 pAd->CommonCfg.HtCapability.HtCapParm.MpduDensity = (UCHAR)pAd->CommonCfg.BACapability.field.MpduDensity;
1507 DBGPRINT(RT_DEBUG_TRACE, ("RTMPSetHT : AMsduSize = %d, MimoPs = %d, MpduDensity = %d, MaxRAmpduFactor = %d\n",
1508 pAd->CommonCfg.DesiredHtPhy.AmsduSize,
1509 pAd->CommonCfg.DesiredHtPhy.MimoPs,
1510 pAd->CommonCfg.DesiredHtPhy.MpduDensity,
1511 pAd->CommonCfg.DesiredHtPhy.MaxRAmpduFactor));
1513 if(pHTPhyMode->HtMode == HTMODE_GF)
1515 pAd->CommonCfg.HtCapability.HtCapInfo.GF = 1;
1516 pAd->CommonCfg.DesiredHtPhy.GF = 1;
1518 else
1519 pAd->CommonCfg.DesiredHtPhy.GF = 0;
1521 // Decide Rx MCSSet
1522 switch (RxStream)
1524 case 1:
1525 pAd->CommonCfg.HtCapability.MCSSet[0] = 0xff;
1526 pAd->CommonCfg.HtCapability.MCSSet[1] = 0x00;
1527 break;
1529 case 2:
1530 pAd->CommonCfg.HtCapability.MCSSet[0] = 0xff;
1531 pAd->CommonCfg.HtCapability.MCSSet[1] = 0xff;
1532 break;
1534 case 3: // 3*3
1535 pAd->CommonCfg.HtCapability.MCSSet[0] = 0xff;
1536 pAd->CommonCfg.HtCapability.MCSSet[1] = 0xff;
1537 pAd->CommonCfg.HtCapability.MCSSet[2] = 0xff;
1538 break;
1541 if (pAd->CommonCfg.bForty_Mhz_Intolerant && (pAd->CommonCfg.Channel <= 14) && (pHTPhyMode->BW == BW_40) )
1543 pHTPhyMode->BW = BW_20;
1544 pAd->CommonCfg.HtCapability.HtCapInfo.Forty_Mhz_Intolerant = 1;
1547 if(pHTPhyMode->BW == BW_40)
1549 pAd->CommonCfg.HtCapability.MCSSet[4] = 0x1; // MCS 32
1550 pAd->CommonCfg.HtCapability.HtCapInfo.ChannelWidth = 1;
1551 if (pAd->CommonCfg.Channel <= 14)
1552 pAd->CommonCfg.HtCapability.HtCapInfo.CCKmodein40 = 1;
1554 pAd->CommonCfg.DesiredHtPhy.ChannelWidth = 1;
1555 pAd->CommonCfg.AddHTInfo.AddHtInfo.RecomWidth = 1;
1556 pAd->CommonCfg.AddHTInfo.AddHtInfo.ExtChanOffset = (pHTPhyMode->ExtOffset == EXTCHA_BELOW)? (EXTCHA_BELOW): EXTCHA_ABOVE;
1557 // Set Regsiter for extension channel position.
1558 RTMP_IO_READ32(pAd, TX_BAND_CFG, &Value);
1559 RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &BBP3Value);
1560 if ((pHTPhyMode->ExtOffset == EXTCHA_BELOW))
1562 Value |= 0x1;
1563 BBP3Value |= (0x20);
1564 RTMP_IO_WRITE32(pAd, TX_BAND_CFG, Value);
1566 else if ((pHTPhyMode->ExtOffset == EXTCHA_ABOVE))
1568 Value &= 0xfe;
1569 BBP3Value &= (~0x20);
1570 RTMP_IO_WRITE32(pAd, TX_BAND_CFG, Value);
1573 // Turn on BBP 40MHz mode now only as AP .
1574 // Sta can turn on BBP 40MHz after connection with 40MHz AP. Sta only broadcast 40MHz capability before connection.
1575 if ((pAd->OpMode == OPMODE_AP) || INFRA_ON(pAd) || ADHOC_ON(pAd)
1578 RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &BBPValue);
1579 BBPValue &= (~0x18);
1580 BBPValue |= 0x10;
1581 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, BBPValue);
1583 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, BBP3Value);
1584 pAd->CommonCfg.BBPCurrentBW = BW_40;
1587 else
1589 pAd->CommonCfg.HtCapability.HtCapInfo.ChannelWidth = 0;
1590 pAd->CommonCfg.DesiredHtPhy.ChannelWidth = 0;
1591 pAd->CommonCfg.AddHTInfo.AddHtInfo.RecomWidth = 0;
1592 pAd->CommonCfg.AddHTInfo.AddHtInfo.ExtChanOffset = EXTCHA_NONE;
1593 pAd->CommonCfg.CentralChannel = pAd->CommonCfg.Channel;
1594 // Turn on BBP 20MHz mode by request here.
1596 RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &BBPValue);
1597 BBPValue &= (~0x18);
1598 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, BBPValue);
1599 pAd->CommonCfg.BBPCurrentBW = BW_20;
1603 if(pHTPhyMode->STBC == STBC_USE)
1605 pAd->CommonCfg.HtCapability.HtCapInfo.TxSTBC = 1;
1606 pAd->CommonCfg.DesiredHtPhy.TxSTBC = 1;
1607 pAd->CommonCfg.HtCapability.HtCapInfo.RxSTBC = 1;
1608 pAd->CommonCfg.DesiredHtPhy.RxSTBC = 1;
1610 else
1612 pAd->CommonCfg.DesiredHtPhy.TxSTBC = 0;
1613 pAd->CommonCfg.DesiredHtPhy.RxSTBC = 0;
1616 if(pHTPhyMode->SHORTGI == GI_400)
1618 pAd->CommonCfg.HtCapability.HtCapInfo.ShortGIfor20 = 1;
1619 pAd->CommonCfg.HtCapability.HtCapInfo.ShortGIfor40 = 1;
1620 pAd->CommonCfg.DesiredHtPhy.ShortGIfor20 = 1;
1621 pAd->CommonCfg.DesiredHtPhy.ShortGIfor40 = 1;
1623 else
1625 pAd->CommonCfg.HtCapability.HtCapInfo.ShortGIfor20 = 0;
1626 pAd->CommonCfg.HtCapability.HtCapInfo.ShortGIfor40 = 0;
1627 pAd->CommonCfg.DesiredHtPhy.ShortGIfor20 = 0;
1628 pAd->CommonCfg.DesiredHtPhy.ShortGIfor40 = 0;
1631 // We support link adaptation for unsolicit MCS feedback, set to 2.
1632 pAd->CommonCfg.HtCapability.ExtHtCapInfo.MCSFeedback = MCSFBK_NONE; //MCSFBK_UNSOLICIT;
1633 pAd->CommonCfg.AddHTInfo.ControlChan = pAd->CommonCfg.Channel;
1634 // 1, the extension channel above the control channel.
1636 // EDCA parameters used for AP's own transmission
1637 if (pAd->CommonCfg.APEdcaParm.bValid == FALSE)
1639 pAd->CommonCfg.APEdcaParm.bValid = TRUE;
1640 pAd->CommonCfg.APEdcaParm.Aifsn[0] = 3;
1641 pAd->CommonCfg.APEdcaParm.Aifsn[1] = 7;
1642 pAd->CommonCfg.APEdcaParm.Aifsn[2] = 1;
1643 pAd->CommonCfg.APEdcaParm.Aifsn[3] = 1;
1645 pAd->CommonCfg.APEdcaParm.Cwmin[0] = 4;
1646 pAd->CommonCfg.APEdcaParm.Cwmin[1] = 4;
1647 pAd->CommonCfg.APEdcaParm.Cwmin[2] = 3;
1648 pAd->CommonCfg.APEdcaParm.Cwmin[3] = 2;
1650 pAd->CommonCfg.APEdcaParm.Cwmax[0] = 6;
1651 pAd->CommonCfg.APEdcaParm.Cwmax[1] = 10;
1652 pAd->CommonCfg.APEdcaParm.Cwmax[2] = 4;
1653 pAd->CommonCfg.APEdcaParm.Cwmax[3] = 3;
1655 pAd->CommonCfg.APEdcaParm.Txop[0] = 0;
1656 pAd->CommonCfg.APEdcaParm.Txop[1] = 0;
1657 pAd->CommonCfg.APEdcaParm.Txop[2] = 94;
1658 pAd->CommonCfg.APEdcaParm.Txop[3] = 47;
1660 AsicSetEdcaParm(pAd, &pAd->CommonCfg.APEdcaParm);
1663 #ifdef CONFIG_STA_SUPPORT
1664 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
1666 RTMPSetIndividualHT(pAd, 0);
1668 #endif // CONFIG_STA_SUPPORT //
1673 ========================================================================
1674 Routine Description:
1675 Caller ensures we has 802.11n support.
1676 Calls at setting HT from AP/STASetinformation
1678 Arguments:
1679 pAd - Pointer to our adapter
1680 phymode -
1682 ========================================================================
1684 VOID RTMPSetIndividualHT(
1685 IN PRTMP_ADAPTER pAd,
1686 IN UCHAR apidx)
1688 PRT_HT_PHY_INFO pDesired_ht_phy = NULL;
1689 UCHAR TxStream = pAd->CommonCfg.TxStream;
1690 UCHAR DesiredMcs = MCS_AUTO;
1695 #ifdef CONFIG_STA_SUPPORT
1696 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
1698 pDesired_ht_phy = &pAd->StaCfg.DesiredHtPhyInfo;
1699 DesiredMcs = pAd->StaCfg.DesiredTransmitSetting.field.MCS;
1700 //pAd->StaCfg.bAutoTxRateSwitch = (DesiredMcs == MCS_AUTO) ? TRUE : FALSE;
1701 break;
1703 #endif // CONFIG_STA_SUPPORT //
1704 } while (FALSE);
1706 if (pDesired_ht_phy == NULL)
1708 DBGPRINT(RT_DEBUG_ERROR, ("RTMPSetIndividualHT: invalid apidx(%d)\n", apidx));
1709 return;
1711 RTMPZeroMemory(pDesired_ht_phy, sizeof(RT_HT_PHY_INFO));
1713 DBGPRINT(RT_DEBUG_TRACE, ("RTMPSetIndividualHT : Desired MCS = %d\n", DesiredMcs));
1714 // Check the validity of MCS
1715 if ((TxStream == 1) && ((DesiredMcs >= MCS_8) && (DesiredMcs <= MCS_15)))
1717 DBGPRINT(RT_DEBUG_WARN, ("RTMPSetIndividualHT: MCS(%d) is invalid in 1S, reset it as MCS_7\n", DesiredMcs));
1718 DesiredMcs = MCS_7;
1721 if ((pAd->CommonCfg.DesiredHtPhy.ChannelWidth == BW_20) && (DesiredMcs == MCS_32))
1723 DBGPRINT(RT_DEBUG_WARN, ("RTMPSetIndividualHT: MCS_32 is only supported in 40-MHz, reset it as MCS_0\n"));
1724 DesiredMcs = MCS_0;
1727 pDesired_ht_phy->bHtEnable = TRUE;
1729 // Decide desired Tx MCS
1730 switch (TxStream)
1732 case 1:
1733 if (DesiredMcs == MCS_AUTO)
1735 pDesired_ht_phy->MCSSet[0]= 0xff;
1736 pDesired_ht_phy->MCSSet[1]= 0x00;
1738 else if (DesiredMcs <= MCS_7)
1740 pDesired_ht_phy->MCSSet[0]= 1<<DesiredMcs;
1741 pDesired_ht_phy->MCSSet[1]= 0x00;
1743 break;
1745 case 2:
1746 if (DesiredMcs == MCS_AUTO)
1748 pDesired_ht_phy->MCSSet[0]= 0xff;
1749 pDesired_ht_phy->MCSSet[1]= 0xff;
1751 else if (DesiredMcs <= MCS_15)
1753 ULONG mode;
1755 mode = DesiredMcs / 8;
1756 if (mode < 2)
1757 pDesired_ht_phy->MCSSet[mode] = (1 << (DesiredMcs - mode * 8));
1759 break;
1761 case 3: // 3*3
1762 if (DesiredMcs == MCS_AUTO)
1764 /* MCS0 ~ MCS23, 3 bytes */
1765 pDesired_ht_phy->MCSSet[0]= 0xff;
1766 pDesired_ht_phy->MCSSet[1]= 0xff;
1767 pDesired_ht_phy->MCSSet[2]= 0xff;
1769 else if (DesiredMcs <= MCS_23)
1771 ULONG mode;
1773 mode = DesiredMcs / 8;
1774 if (mode < 3)
1775 pDesired_ht_phy->MCSSet[mode] = (1 << (DesiredMcs - mode * 8));
1777 break;
1780 if(pAd->CommonCfg.DesiredHtPhy.ChannelWidth == BW_40)
1782 if (DesiredMcs == MCS_AUTO || DesiredMcs == MCS_32)
1783 pDesired_ht_phy->MCSSet[4] = 0x1;
1786 // update HT Rate setting
1787 if (pAd->OpMode == OPMODE_STA)
1788 MlmeUpdateHtTxRates(pAd, BSS0);
1789 else
1790 MlmeUpdateHtTxRates(pAd, apidx);
1795 ========================================================================
1796 Routine Description:
1797 Update HT IE from our capability.
1799 Arguments:
1800 Send all HT IE in beacon/probe rsp/assoc rsp/action frame.
1803 ========================================================================
1805 VOID RTMPUpdateHTIE(
1806 IN RT_HT_CAPABILITY *pRtHt,
1807 IN UCHAR *pMcsSet,
1808 OUT HT_CAPABILITY_IE *pHtCapability,
1809 OUT ADD_HT_INFO_IE *pAddHtInfo)
1811 RTMPZeroMemory(pHtCapability, sizeof(HT_CAPABILITY_IE));
1812 RTMPZeroMemory(pAddHtInfo, sizeof(ADD_HT_INFO_IE));
1814 pHtCapability->HtCapInfo.ChannelWidth = pRtHt->ChannelWidth;
1815 pHtCapability->HtCapInfo.MimoPs = pRtHt->MimoPs;
1816 pHtCapability->HtCapInfo.GF = pRtHt->GF;
1817 pHtCapability->HtCapInfo.ShortGIfor20 = pRtHt->ShortGIfor20;
1818 pHtCapability->HtCapInfo.ShortGIfor40 = pRtHt->ShortGIfor40;
1819 pHtCapability->HtCapInfo.TxSTBC = pRtHt->TxSTBC;
1820 pHtCapability->HtCapInfo.RxSTBC = pRtHt->RxSTBC;
1821 pHtCapability->HtCapInfo.AMsduSize = pRtHt->AmsduSize;
1822 pHtCapability->HtCapParm.MaxRAmpduFactor = pRtHt->MaxRAmpduFactor;
1823 pHtCapability->HtCapParm.MpduDensity = pRtHt->MpduDensity;
1825 pAddHtInfo->AddHtInfo.ExtChanOffset = pRtHt->ExtChanOffset ;
1826 pAddHtInfo->AddHtInfo.RecomWidth = pRtHt->RecomWidth;
1827 pAddHtInfo->AddHtInfo2.OperaionMode = pRtHt->OperaionMode;
1828 pAddHtInfo->AddHtInfo2.NonGfPresent = pRtHt->NonGfPresent;
1829 RTMPMoveMemory(pAddHtInfo->MCSSet, /*pRtHt->MCSSet*/pMcsSet, 4); // rt2860 only support MCS max=32, no need to copy all 16 uchar.
1831 DBGPRINT(RT_DEBUG_TRACE,("RTMPUpdateHTIE <== \n"));
1833 #endif // DOT11_N_SUPPORT //
1836 ========================================================================
1837 Description:
1838 Add Client security information into ASIC WCID table and IVEIV table.
1839 Return:
1840 ========================================================================
1842 VOID RTMPAddWcidAttributeEntry(
1843 IN PRTMP_ADAPTER pAd,
1844 IN UCHAR BssIdx,
1845 IN UCHAR KeyIdx,
1846 IN UCHAR CipherAlg,
1847 IN MAC_TABLE_ENTRY *pEntry)
1849 UINT32 WCIDAttri = 0;
1850 USHORT offset;
1851 UCHAR IVEIV = 0;
1852 USHORT Wcid = 0;
1855 #ifdef CONFIG_STA_SUPPORT
1856 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
1858 if (BssIdx > BSS0)
1860 DBGPRINT(RT_DEBUG_ERROR, ("RTMPAddWcidAttributeEntry: The BSS-index(%d) is out of range for Infra link. \n", BssIdx));
1861 return;
1864 // 1. In ADHOC mode, the AID is wcid number. And NO mesh link exists.
1865 // 2. In Infra mode, the AID:1 MUST be wcid of infra STA.
1866 // the AID:2~ assign to mesh link entry.
1867 if (pEntry)
1868 Wcid = pEntry->Aid;
1869 else
1870 Wcid = MCAST_WCID;
1872 #endif // CONFIG_STA_SUPPORT //
1875 // Update WCID attribute table
1876 offset = MAC_WCID_ATTRIBUTE_BASE + (Wcid * HW_WCID_ATTRI_SIZE);
1878 #ifdef CONFIG_STA_SUPPORT
1879 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
1881 if (pEntry && pEntry->ValidAsMesh)
1882 WCIDAttri = (CipherAlg<<1) | PAIRWISEKEYTABLE;
1883 #ifdef QOS_DLS_SUPPORT
1884 else if ((pEntry) && (pEntry->ValidAsDls) &&
1885 ((CipherAlg == CIPHER_TKIP) ||
1886 (CipherAlg == CIPHER_TKIP_NO_MIC) ||
1887 (CipherAlg == CIPHER_AES) ||
1888 (CipherAlg == CIPHER_NONE)))
1889 WCIDAttri = (CipherAlg<<1) | PAIRWISEKEYTABLE;
1890 #endif // QOS_DLS_SUPPORT //
1891 else
1892 WCIDAttri = (CipherAlg<<1) | SHAREDKEYTABLE;
1894 #endif // CONFIG_STA_SUPPORT //
1896 RTMP_IO_WRITE32(pAd, offset, WCIDAttri);
1899 // Update IV/EIV table
1900 offset = MAC_IVEIV_TABLE_BASE + (Wcid * HW_IVEIV_ENTRY_SIZE);
1902 // WPA mode
1903 if ((CipherAlg == CIPHER_TKIP) || (CipherAlg == CIPHER_TKIP_NO_MIC) || (CipherAlg == CIPHER_AES))
1905 // Eiv bit on. keyid always is 0 for pairwise key
1906 IVEIV = (KeyIdx <<6) | 0x20;
1908 else
1910 // WEP KeyIdx is default tx key.
1911 IVEIV = (KeyIdx << 6);
1914 // For key index and ext IV bit, so only need to update the position(offset+3).
1915 #ifdef RTMP_MAC_PCI
1916 RTMP_IO_WRITE8(pAd, offset+3, IVEIV);
1917 #endif // RTMP_MAC_PCI //
1919 DBGPRINT(RT_DEBUG_TRACE,("RTMPAddWcidAttributeEntry: WCID #%d, KeyIndex #%d, Alg=%s\n",Wcid, KeyIdx, CipherName[CipherAlg]));
1920 DBGPRINT(RT_DEBUG_TRACE,(" WCIDAttri = 0x%x \n", WCIDAttri));
1925 ==========================================================================
1926 Description:
1927 Parse encryption type
1928 Arguments:
1929 pAdapter Pointer to our adapter
1930 wrq Pointer to the ioctl argument
1932 Return Value:
1933 None
1935 Note:
1936 ==========================================================================
1938 PSTRING GetEncryptType(CHAR enc)
1940 if(enc == Ndis802_11WEPDisabled)
1941 return "NONE";
1942 if(enc == Ndis802_11WEPEnabled)
1943 return "WEP";
1944 if(enc == Ndis802_11Encryption2Enabled)
1945 return "TKIP";
1946 if(enc == Ndis802_11Encryption3Enabled)
1947 return "AES";
1948 if(enc == Ndis802_11Encryption4Enabled)
1949 return "TKIPAES";
1950 else
1951 return "UNKNOW";
1954 PSTRING GetAuthMode(CHAR auth)
1956 if(auth == Ndis802_11AuthModeOpen)
1957 return "OPEN";
1958 if(auth == Ndis802_11AuthModeShared)
1959 return "SHARED";
1960 if(auth == Ndis802_11AuthModeAutoSwitch)
1961 return "AUTOWEP";
1962 if(auth == Ndis802_11AuthModeWPA)
1963 return "WPA";
1964 if(auth == Ndis802_11AuthModeWPAPSK)
1965 return "WPAPSK";
1966 if(auth == Ndis802_11AuthModeWPANone)
1967 return "WPANONE";
1968 if(auth == Ndis802_11AuthModeWPA2)
1969 return "WPA2";
1970 if(auth == Ndis802_11AuthModeWPA2PSK)
1971 return "WPA2PSK";
1972 if(auth == Ndis802_11AuthModeWPA1WPA2)
1973 return "WPA1WPA2";
1974 if(auth == Ndis802_11AuthModeWPA1PSKWPA2PSK)
1975 return "WPA1PSKWPA2PSK";
1977 return "UNKNOW";
1982 ==========================================================================
1983 Description:
1984 Get site survey results
1985 Arguments:
1986 pAdapter Pointer to our adapter
1987 wrq Pointer to the ioctl argument
1989 Return Value:
1990 None
1992 Note:
1993 Usage:
1994 1.) UI needs to wait 4 seconds after issue a site survey command
1995 2.) iwpriv ra0 get_site_survey
1996 3.) UI needs to prepare at least 4096bytes to get the results
1997 ==========================================================================
1999 #define LINE_LEN (4+33+20+23+9+7+3) // Channel+SSID+Bssid+Security+Signal+WiressMode+NetworkType
2000 #ifdef CONFIG_STA_SUPPORT
2001 #endif // CONFIG_STA_SUPPORT //
2002 VOID RTMPCommSiteSurveyData(
2003 IN PSTRING msg,
2004 IN PBSS_ENTRY pBss)
2006 INT Rssi = 0;
2007 UINT Rssi_Quality = 0;
2008 NDIS_802_11_NETWORK_TYPE wireless_mode;
2009 CHAR Ssid[MAX_LEN_OF_SSID +1];
2010 STRING SecurityStr[32] = {0};
2011 NDIS_802_11_ENCRYPTION_STATUS ap_cipher = Ndis802_11EncryptionDisabled;
2012 NDIS_802_11_AUTHENTICATION_MODE ap_auth_mode = Ndis802_11AuthModeOpen;
2014 memset(Ssid, 0 ,(MAX_LEN_OF_SSID +1));
2016 //Channel
2017 sprintf(msg+strlen(msg),"%-4d", pBss->Channel);
2018 //SSID
2019 memcpy(Ssid, pBss->Ssid, pBss->SsidLen);
2020 Ssid[pBss->SsidLen] = '\0';
2021 sprintf(msg+strlen(msg),"%-33s", Ssid);
2022 //BSSID
2023 sprintf(msg+strlen(msg),"%02x:%02x:%02x:%02x:%02x:%02x ",
2024 pBss->Bssid[0],
2025 pBss->Bssid[1],
2026 pBss->Bssid[2],
2027 pBss->Bssid[3],
2028 pBss->Bssid[4],
2029 pBss->Bssid[5]);
2031 //Security
2032 if ((Ndis802_11AuthModeWPA <= pBss->AuthMode) &&
2033 (pBss->AuthMode <= Ndis802_11AuthModeWPA1PSKWPA2PSK))
2035 if (pBss->AuthModeAux == Ndis802_11AuthModeWPANone)
2037 ap_auth_mode = pBss->AuthMode;
2038 if (pBss->WPA.PairCipherAux == Ndis802_11WEPDisabled)
2039 ap_cipher = pBss->WPA.PairCipher;
2040 else
2041 ap_cipher = Ndis802_11Encryption4Enabled;
2043 else if (pBss->AuthModeAux == Ndis802_11AuthModeOpen)
2045 ap_auth_mode = pBss->AuthMode;
2046 if ((ap_auth_mode == Ndis802_11AuthModeWPA) ||
2047 (ap_auth_mode == Ndis802_11AuthModeWPAPSK))
2049 if (pBss->WPA.PairCipherAux == Ndis802_11WEPDisabled)
2050 ap_cipher = pBss->WPA.PairCipher;
2051 else
2052 ap_cipher = Ndis802_11Encryption4Enabled;
2054 else if ((ap_auth_mode == Ndis802_11AuthModeWPA2) ||
2055 (ap_auth_mode == Ndis802_11AuthModeWPA2PSK))
2057 if (pBss->WPA2.PairCipherAux == Ndis802_11WEPDisabled)
2058 ap_cipher = pBss->WPA2.PairCipher;
2059 else
2060 ap_cipher = Ndis802_11Encryption4Enabled;
2063 else if ((pBss->AuthMode == Ndis802_11AuthModeWPAPSK) ||
2064 (pBss->AuthMode == Ndis802_11AuthModeWPA2PSK))
2066 if ((pBss->AuthModeAux == Ndis802_11AuthModeWPAPSK) ||
2067 (pBss->AuthModeAux == Ndis802_11AuthModeWPA2PSK))
2068 ap_auth_mode = Ndis802_11AuthModeWPA1PSKWPA2PSK;
2069 else
2070 ap_auth_mode = pBss->AuthMode;
2072 if (pBss->WPA.PairCipher != pBss->WPA2.PairCipher)
2073 ap_cipher = Ndis802_11Encryption4Enabled;
2074 else if ((pBss->WPA.PairCipher == pBss->WPA2.PairCipher) &&
2075 (pBss->WPA.PairCipherAux != pBss->WPA2.PairCipherAux))
2076 ap_cipher = Ndis802_11Encryption4Enabled;
2077 else if ((pBss->WPA.PairCipher == pBss->WPA2.PairCipher) &&
2078 (pBss->WPA.PairCipherAux == pBss->WPA2.PairCipherAux) &&
2079 (pBss->WPA.PairCipherAux != Ndis802_11WEPDisabled))
2080 ap_cipher = Ndis802_11Encryption4Enabled;
2081 else if ((pBss->WPA.PairCipher == pBss->WPA2.PairCipher) &&
2082 (pBss->WPA.PairCipherAux == pBss->WPA2.PairCipherAux) &&
2083 (pBss->WPA.PairCipherAux == Ndis802_11WEPDisabled))
2084 ap_cipher = pBss->WPA.PairCipher;
2086 else if ((pBss->AuthMode == Ndis802_11AuthModeWPA) ||
2087 (pBss->AuthMode == Ndis802_11AuthModeWPA2))
2089 if ((pBss->AuthModeAux == Ndis802_11AuthModeWPA) ||
2090 (pBss->AuthMode == Ndis802_11AuthModeWPA2))
2091 ap_auth_mode = Ndis802_11AuthModeWPA1WPA2;
2092 else
2093 ap_auth_mode = pBss->AuthMode;
2095 if (pBss->WPA.PairCipher != pBss->WPA2.PairCipher)
2096 ap_cipher = Ndis802_11Encryption4Enabled;
2097 else if ((pBss->WPA.PairCipher == pBss->WPA2.PairCipher) &&
2098 (pBss->WPA.PairCipherAux != pBss->WPA2.PairCipherAux))
2099 ap_cipher = Ndis802_11Encryption4Enabled;
2100 else if ((pBss->WPA.PairCipher == pBss->WPA2.PairCipher) &&
2101 (pBss->WPA.PairCipherAux == pBss->WPA2.PairCipherAux) &&
2102 (pBss->WPA.PairCipherAux != Ndis802_11WEPDisabled))
2103 ap_cipher = Ndis802_11Encryption4Enabled;
2104 else if ((pBss->WPA.PairCipher == pBss->WPA2.PairCipher) &&
2105 (pBss->WPA.PairCipherAux == pBss->WPA2.PairCipherAux) &&
2106 (pBss->WPA.PairCipherAux == Ndis802_11WEPDisabled))
2107 ap_cipher = pBss->WPA.PairCipher;
2110 sprintf(SecurityStr, "%s/%s", GetAuthMode((CHAR)ap_auth_mode), GetEncryptType((CHAR)ap_cipher));
2112 else
2114 ap_auth_mode = pBss->AuthMode;
2115 ap_cipher = pBss->WepStatus;
2116 if (ap_cipher == Ndis802_11WEPDisabled)
2117 sprintf(SecurityStr, "NONE");
2118 else if (ap_cipher == Ndis802_11WEPEnabled)
2119 sprintf(SecurityStr, "WEP");
2120 else
2121 sprintf(SecurityStr, "%s/%s", GetAuthMode((CHAR)ap_auth_mode), GetEncryptType((CHAR)ap_cipher));
2124 sprintf(msg+strlen(msg), "%-23s", SecurityStr);
2126 // Rssi
2127 Rssi = (INT)pBss->Rssi;
2128 if (Rssi >= -50)
2129 Rssi_Quality = 100;
2130 else if (Rssi >= -80) // between -50 ~ -80dbm
2131 Rssi_Quality = (UINT)(24 + ((Rssi + 80) * 26)/10);
2132 else if (Rssi >= -90) // between -80 ~ -90dbm
2133 Rssi_Quality = (UINT)(((Rssi + 90) * 26)/10);
2134 else // < -84 dbm
2135 Rssi_Quality = 0;
2136 sprintf(msg+strlen(msg),"%-9d", Rssi_Quality);
2137 // Wireless Mode
2138 wireless_mode = NetworkTypeInUseSanity(pBss);
2139 if (wireless_mode == Ndis802_11FH ||
2140 wireless_mode == Ndis802_11DS)
2141 sprintf(msg+strlen(msg),"%-7s", "11b");
2142 else if (wireless_mode == Ndis802_11OFDM5)
2143 sprintf(msg+strlen(msg),"%-7s", "11a");
2144 else if (wireless_mode == Ndis802_11OFDM5_N)
2145 sprintf(msg+strlen(msg),"%-7s", "11a/n");
2146 else if (wireless_mode == Ndis802_11OFDM24)
2147 sprintf(msg+strlen(msg),"%-7s", "11b/g");
2148 else if (wireless_mode == Ndis802_11OFDM24_N)
2149 sprintf(msg+strlen(msg),"%-7s", "11b/g/n");
2150 else
2151 sprintf(msg+strlen(msg),"%-7s", "unknow");
2152 //Network Type
2153 if (pBss->BssType == BSS_ADHOC)
2154 sprintf(msg+strlen(msg),"%-3s", " Ad");
2155 else
2156 sprintf(msg+strlen(msg),"%-3s", " In");
2158 sprintf(msg+strlen(msg),"\n");
2160 return;
2163 VOID RTMPIoctlGetSiteSurvey(
2164 IN PRTMP_ADAPTER pAdapter,
2165 IN struct iwreq *wrq)
2167 PSTRING msg;
2168 INT i=0;
2169 INT WaitCnt;
2170 INT Status=0;
2171 INT max_len = LINE_LEN;
2172 PBSS_ENTRY pBss;
2174 #ifdef CONFIG_STA_SUPPORT
2175 #endif // CONFIG_STA_SUPPORT //
2177 os_alloc_mem(NULL, (PUCHAR *)&msg, sizeof(CHAR)*((MAX_LEN_OF_BSS_TABLE)*max_len));
2179 if (msg == NULL)
2181 DBGPRINT(RT_DEBUG_TRACE, ("RTMPIoctlGetSiteSurvey - msg memory alloc fail.\n"));
2182 return;
2185 memset(msg, 0 ,(MAX_LEN_OF_BSS_TABLE)*max_len );
2186 sprintf(msg,"%s","\n");
2187 sprintf(msg+strlen(msg),"%-4s%-33s%-20s%-23s%-9s%-7s%-3s\n",
2188 "Ch", "SSID", "BSSID", "Security", "Siganl(%)", "W-Mode", " NT");
2190 #ifdef CONFIG_STA_SUPPORT
2192 #endif // CONFIG_STA_SUPPORT //
2194 WaitCnt = 0;
2195 #ifdef CONFIG_STA_SUPPORT
2196 pAdapter->StaCfg.bScanReqIsFromWebUI = TRUE;
2197 while ((ScanRunning(pAdapter) == TRUE) && (WaitCnt++ < 200))
2198 OS_WAIT(500);
2199 #endif // CONFIG_STA_SUPPORT //
2201 for(i=0; i<pAdapter->ScanTab.BssNr ;i++)
2203 pBss = &pAdapter->ScanTab.BssEntry[i];
2205 if( pBss->Channel==0)
2206 break;
2208 if((strlen(msg)+max_len ) >= IW_SCAN_MAX_DATA)
2209 break;
2212 RTMPCommSiteSurveyData(msg, pBss);
2214 #ifdef CONFIG_STA_SUPPORT
2216 #endif // CONFIG_STA_SUPPORT //
2219 #ifdef CONFIG_STA_SUPPORT
2220 pAdapter->StaCfg.bScanReqIsFromWebUI = FALSE;
2221 #endif // CONFIG_STA_SUPPORT //
2222 wrq->u.data.length = strlen(msg);
2223 Status = copy_to_user(wrq->u.data.pointer, msg, wrq->u.data.length);
2225 DBGPRINT(RT_DEBUG_TRACE, ("RTMPIoctlGetSiteSurvey - wrq->u.data.length = %d\n", wrq->u.data.length));
2226 os_free_mem(NULL, (PUCHAR)msg);
2229 #define MAC_LINE_LEN (14+4+4+10+10+10+6+6) // Addr+aid+psm+datatime+rxbyte+txbyte+current tx rate+last tx rate
2230 VOID RTMPIoctlGetMacTable(
2231 IN PRTMP_ADAPTER pAd,
2232 IN struct iwreq *wrq)
2234 INT i;
2235 RT_802_11_MAC_TABLE MacTab;
2236 char *msg;
2238 MacTab.Num = 0;
2239 for (i=0; i<MAX_LEN_OF_MAC_TABLE; i++)
2241 if (pAd->MacTab.Content[i].ValidAsCLI && (pAd->MacTab.Content[i].Sst == SST_ASSOC))
2243 COPY_MAC_ADDR(MacTab.Entry[MacTab.Num].Addr, &pAd->MacTab.Content[i].Addr);
2244 MacTab.Entry[MacTab.Num].Aid = (UCHAR)pAd->MacTab.Content[i].Aid;
2245 MacTab.Entry[MacTab.Num].Psm = pAd->MacTab.Content[i].PsMode;
2246 #ifdef DOT11_N_SUPPORT
2247 MacTab.Entry[MacTab.Num].MimoPs = pAd->MacTab.Content[i].MmpsMode;
2248 #endif // DOT11_N_SUPPORT //
2250 // Fill in RSSI per entry
2251 MacTab.Entry[MacTab.Num].AvgRssi0 = pAd->MacTab.Content[i].RssiSample.AvgRssi0;
2252 MacTab.Entry[MacTab.Num].AvgRssi1 = pAd->MacTab.Content[i].RssiSample.AvgRssi1;
2253 MacTab.Entry[MacTab.Num].AvgRssi2 = pAd->MacTab.Content[i].RssiSample.AvgRssi2;
2255 // the connected time per entry
2256 MacTab.Entry[MacTab.Num].ConnectedTime = pAd->MacTab.Content[i].StaConnectTime;
2257 MacTab.Entry[MacTab.Num].TxRate.field.MCS = pAd->MacTab.Content[i].HTPhyMode.field.MCS;
2258 MacTab.Entry[MacTab.Num].TxRate.field.BW = pAd->MacTab.Content[i].HTPhyMode.field.BW;
2259 MacTab.Entry[MacTab.Num].TxRate.field.ShortGI = pAd->MacTab.Content[i].HTPhyMode.field.ShortGI;
2260 MacTab.Entry[MacTab.Num].TxRate.field.STBC = pAd->MacTab.Content[i].HTPhyMode.field.STBC;
2261 MacTab.Entry[MacTab.Num].TxRate.field.rsv = pAd->MacTab.Content[i].HTPhyMode.field.rsv;
2262 MacTab.Entry[MacTab.Num].TxRate.field.MODE = pAd->MacTab.Content[i].HTPhyMode.field.MODE;
2263 MacTab.Entry[MacTab.Num].TxRate.word = pAd->MacTab.Content[i].HTPhyMode.word;
2265 MacTab.Num += 1;
2268 wrq->u.data.length = sizeof(RT_802_11_MAC_TABLE);
2269 if (copy_to_user(wrq->u.data.pointer, &MacTab, wrq->u.data.length))
2271 DBGPRINT(RT_DEBUG_TRACE, ("%s: copy_to_user() fail\n", __FUNCTION__));
2274 msg = kmalloc(sizeof(CHAR)*(MAX_LEN_OF_MAC_TABLE*MAC_LINE_LEN), MEM_ALLOC_FLAG);
2275 if (msg == NULL)
2277 DBGPRINT(RT_DEBUG_ERROR, ("%s():Alloc memory failed\n", __FUNCTION__));
2278 return;
2280 memset(msg, 0 ,MAX_LEN_OF_MAC_TABLE*MAC_LINE_LEN );
2281 sprintf(msg,"%s","\n");
2282 sprintf(msg+strlen(msg),"%-14s%-4s%-4s%-10s%-10s%-10s%-6s%-6s\n",
2283 "MAC", "AID", "PSM", "LDT", "RxB", "TxB","CTxR", "LTxR");
2285 for (i=0; i<MAX_LEN_OF_MAC_TABLE; i++)
2287 PMAC_TABLE_ENTRY pEntry = &pAd->MacTab.Content[i];
2288 if (pEntry->ValidAsCLI && (pEntry->Sst == SST_ASSOC))
2290 if((strlen(msg)+MAC_LINE_LEN ) >= (MAX_LEN_OF_MAC_TABLE*MAC_LINE_LEN) )
2291 break;
2292 sprintf(msg+strlen(msg),"%02x%02x%02x%02x%02x%02x ",
2293 pEntry->Addr[0], pEntry->Addr[1], pEntry->Addr[2],
2294 pEntry->Addr[3], pEntry->Addr[4], pEntry->Addr[5]);
2295 sprintf(msg+strlen(msg),"%-4d", (int)pEntry->Aid);
2296 sprintf(msg+strlen(msg),"%-4d", (int)pEntry->PsMode);
2297 sprintf(msg+strlen(msg),"%-10d",0/*pAd->MacTab.Content[i].HSCounter.LastDataPacketTime*/); // ToDo
2298 sprintf(msg+strlen(msg),"%-10d",0/*pAd->MacTab.Content[i].HSCounter.TotalRxByteCount*/); // ToDo
2299 sprintf(msg+strlen(msg),"%-10d",0/*pAd->MacTab.Content[i].HSCounter.TotalTxByteCount*/); // ToDo
2300 sprintf(msg+strlen(msg),"%-6d",RateIdToMbps[pAd->MacTab.Content[i].CurrTxRate]);
2301 sprintf(msg+strlen(msg),"%-6d\n",0/*RateIdToMbps[pAd->MacTab.Content[i].LastTxRate]*/); // ToDo
2304 // for compatible with old API just do the printk to console
2305 //wrq->u.data.length = strlen(msg);
2306 //if (copy_to_user(wrq->u.data.pointer, msg, wrq->u.data.length))
2308 DBGPRINT(RT_DEBUG_TRACE, ("%s", msg));
2311 kfree(msg);
2315 #ifdef DOT11_N_SUPPORT
2316 INT Set_BASetup_Proc(
2317 IN PRTMP_ADAPTER pAd,
2318 IN PSTRING arg)
2320 UCHAR mac[6], tid;
2321 PSTRING token;
2322 STRING sepValue[] = ":", DASH = '-';
2323 INT i;
2324 MAC_TABLE_ENTRY *pEntry;
2327 The BASetup inupt string format should be xx:xx:xx:xx:xx:xx-d,
2328 =>The six 2 digit hex-decimal number previous are the Mac address,
2329 =>The seventh decimal number is the tid value.
2331 //DBGPRINT(RT_DEBUG_TRACE,("\n%s\n", arg));
2333 if(strlen(arg) < 19) //Mac address acceptable format 01:02:03:04:05:06 length 17 plus the "-" and tid value in decimal format.
2334 return FALSE;
2336 token = strchr(arg, DASH);
2337 if ((token != NULL) && (strlen(token)>1))
2339 tid = (UCHAR) simple_strtol((token+1), 0, 10);
2340 if (tid > 15)
2341 return FALSE;
2343 *token = '\0';
2344 for (i = 0, token = rstrtok(arg, &sepValue[0]); token; token = rstrtok(NULL, &sepValue[0]), i++)
2346 if((strlen(token) != 2) || (!isxdigit(*token)) || (!isxdigit(*(token+1))))
2347 return FALSE;
2348 AtoH(token, (&mac[i]), 1);
2350 if(i != 6)
2351 return FALSE;
2353 DBGPRINT(RT_DEBUG_OFF, ("\n%02x:%02x:%02x:%02x:%02x:%02x-%02x\n",
2354 mac[0], mac[1], mac[2], mac[3], mac[4], mac[5], tid));
2356 pEntry = MacTableLookup(pAd, (PUCHAR) mac);
2358 if (pEntry) {
2359 DBGPRINT(RT_DEBUG_OFF, ("\nSetup BA Session: Tid = %d\n", tid));
2360 BAOriSessionSetUp(pAd, pEntry, tid, 0, 100, TRUE);
2363 return TRUE;
2366 return FALSE;
2370 INT Set_BADecline_Proc(
2371 IN PRTMP_ADAPTER pAd,
2372 IN PSTRING arg)
2374 ULONG bBADecline;
2376 bBADecline = simple_strtol(arg, 0, 10);
2378 if (bBADecline == 0)
2380 pAd->CommonCfg.bBADecline = FALSE;
2382 else if (bBADecline == 1)
2384 pAd->CommonCfg.bBADecline = TRUE;
2386 else
2388 return FALSE; //Invalid argument
2391 DBGPRINT(RT_DEBUG_TRACE, ("Set_BADecline_Proc::(BADecline=%d)\n", pAd->CommonCfg.bBADecline));
2393 return TRUE;
2396 INT Set_BAOriTearDown_Proc(
2397 IN PRTMP_ADAPTER pAd,
2398 IN PSTRING arg)
2400 UCHAR mac[6], tid;
2401 PSTRING token;
2402 STRING sepValue[] = ":", DASH = '-';
2403 INT i;
2404 MAC_TABLE_ENTRY *pEntry;
2406 //DBGPRINT(RT_DEBUG_TRACE,("\n%s\n", arg));
2408 The BAOriTearDown inupt string format should be xx:xx:xx:xx:xx:xx-d,
2409 =>The six 2 digit hex-decimal number previous are the Mac address,
2410 =>The seventh decimal number is the tid value.
2412 if(strlen(arg) < 19) //Mac address acceptable format 01:02:03:04:05:06 length 17 plus the "-" and tid value in decimal format.
2413 return FALSE;
2415 token = strchr(arg, DASH);
2416 if ((token != NULL) && (strlen(token)>1))
2418 tid = simple_strtol((token+1), 0, 10);
2419 if (tid > NUM_OF_TID)
2420 return FALSE;
2422 *token = '\0';
2423 for (i = 0, token = rstrtok(arg, &sepValue[0]); token; token = rstrtok(NULL, &sepValue[0]), i++)
2425 if((strlen(token) != 2) || (!isxdigit(*token)) || (!isxdigit(*(token+1))))
2426 return FALSE;
2427 AtoH(token, (&mac[i]), 1);
2429 if(i != 6)
2430 return FALSE;
2432 DBGPRINT(RT_DEBUG_OFF, ("\n%02x:%02x:%02x:%02x:%02x:%02x-%02x",
2433 mac[0], mac[1], mac[2], mac[3], mac[4], mac[5], tid));
2435 pEntry = MacTableLookup(pAd, (PUCHAR) mac);
2437 if (pEntry) {
2438 DBGPRINT(RT_DEBUG_OFF, ("\nTear down Ori BA Session: Tid = %d\n", tid));
2439 BAOriSessionTearDown(pAd, pEntry->Aid, tid, FALSE, TRUE);
2442 return TRUE;
2445 return FALSE;
2449 INT Set_BARecTearDown_Proc(
2450 IN PRTMP_ADAPTER pAd,
2451 IN PSTRING arg)
2453 UCHAR mac[6], tid;
2454 PSTRING token;
2455 STRING sepValue[] = ":", DASH = '-';
2456 INT i;
2457 MAC_TABLE_ENTRY *pEntry;
2459 //DBGPRINT(RT_DEBUG_TRACE,("\n%s\n", arg));
2461 The BARecTearDown inupt string format should be xx:xx:xx:xx:xx:xx-d,
2462 =>The six 2 digit hex-decimal number previous are the Mac address,
2463 =>The seventh decimal number is the tid value.
2465 if(strlen(arg) < 19) //Mac address acceptable format 01:02:03:04:05:06 length 17 plus the "-" and tid value in decimal format.
2466 return FALSE;
2468 token = strchr(arg, DASH);
2469 if ((token != NULL) && (strlen(token)>1))
2471 tid = simple_strtol((token+1), 0, 10);
2472 if (tid > NUM_OF_TID)
2473 return FALSE;
2475 *token = '\0';
2476 for (i = 0, token = rstrtok(arg, &sepValue[0]); token; token = rstrtok(NULL, &sepValue[0]), i++)
2478 if((strlen(token) != 2) || (!isxdigit(*token)) || (!isxdigit(*(token+1))))
2479 return FALSE;
2480 AtoH(token, (&mac[i]), 1);
2482 if(i != 6)
2483 return FALSE;
2485 DBGPRINT(RT_DEBUG_OFF, ("\n%02x:%02x:%02x:%02x:%02x:%02x-%02x",
2486 mac[0], mac[1], mac[2], mac[3], mac[4], mac[5], tid));
2488 pEntry = MacTableLookup(pAd, (PUCHAR) mac);
2490 if (pEntry) {
2491 DBGPRINT(RT_DEBUG_OFF, ("\nTear down Rec BA Session: Tid = %d\n", tid));
2492 BARecSessionTearDown(pAd, pEntry->Aid, tid, FALSE);
2495 return TRUE;
2498 return FALSE;
2502 INT Set_HtBw_Proc(
2503 IN PRTMP_ADAPTER pAd,
2504 IN PSTRING arg)
2506 ULONG HtBw;
2508 HtBw = simple_strtol(arg, 0, 10);
2509 if (HtBw == BW_40)
2510 pAd->CommonCfg.RegTransmitSetting.field.BW = BW_40;
2511 else if (HtBw == BW_20)
2512 pAd->CommonCfg.RegTransmitSetting.field.BW = BW_20;
2513 else
2514 return FALSE; //Invalid argument
2516 SetCommonHT(pAd);
2518 DBGPRINT(RT_DEBUG_TRACE, ("Set_HtBw_Proc::(HtBw=%d)\n", pAd->CommonCfg.RegTransmitSetting.field.BW));
2520 return TRUE;
2523 INT Set_HtMcs_Proc(
2524 IN PRTMP_ADAPTER pAd,
2525 IN PSTRING arg)
2527 ULONG HtMcs, Mcs_tmp;
2528 #ifdef CONFIG_STA_SUPPORT
2529 BOOLEAN bAutoRate = FALSE;
2530 #endif // CONFIG_STA_SUPPORT //
2532 Mcs_tmp = simple_strtol(arg, 0, 10);
2534 if (Mcs_tmp <= 15 || Mcs_tmp == 32)
2535 HtMcs = Mcs_tmp;
2536 else
2537 HtMcs = MCS_AUTO;
2539 #ifdef CONFIG_STA_SUPPORT
2540 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
2542 pAd->StaCfg.DesiredTransmitSetting.field.MCS = HtMcs;
2543 pAd->StaCfg.bAutoTxRateSwitch = (HtMcs == MCS_AUTO) ? TRUE:FALSE;
2544 DBGPRINT(RT_DEBUG_TRACE, ("Set_HtMcs_Proc::(HtMcs=%d, bAutoTxRateSwitch = %d)\n",
2545 pAd->StaCfg.DesiredTransmitSetting.field.MCS, pAd->StaCfg.bAutoTxRateSwitch));
2547 if ((pAd->CommonCfg.PhyMode < PHY_11ABGN_MIXED) ||
2548 (pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE < MODE_HTMIX))
2550 if ((pAd->StaCfg.DesiredTransmitSetting.field.MCS != MCS_AUTO) &&
2551 (HtMcs >= 0 && HtMcs <= 3) &&
2552 (pAd->StaCfg.DesiredTransmitSetting.field.FixedTxMode == FIXED_TXMODE_CCK))
2554 RTMPSetDesiredRates(pAd, (LONG) (RateIdToMbps[HtMcs] * 1000000));
2556 else if ((pAd->StaCfg.DesiredTransmitSetting.field.MCS != MCS_AUTO) &&
2557 (HtMcs >= 0 && HtMcs <= 7) &&
2558 (pAd->StaCfg.DesiredTransmitSetting.field.FixedTxMode == FIXED_TXMODE_OFDM))
2560 RTMPSetDesiredRates(pAd, (LONG) (RateIdToMbps[HtMcs+4] * 1000000));
2562 else
2563 bAutoRate = TRUE;
2565 if (bAutoRate)
2567 pAd->StaCfg.DesiredTransmitSetting.field.MCS = MCS_AUTO;
2568 RTMPSetDesiredRates(pAd, -1);
2570 DBGPRINT(RT_DEBUG_TRACE, ("Set_HtMcs_Proc::(FixedTxMode=%d)\n",pAd->StaCfg.DesiredTransmitSetting.field.FixedTxMode));
2572 if (ADHOC_ON(pAd))
2573 return TRUE;
2575 #endif // CONFIG_STA_SUPPORT //
2577 SetCommonHT(pAd);
2579 return TRUE;
2582 INT Set_HtGi_Proc(
2583 IN PRTMP_ADAPTER pAd,
2584 IN PSTRING arg)
2586 ULONG HtGi;
2588 HtGi = simple_strtol(arg, 0, 10);
2590 if ( HtGi == GI_400)
2591 pAd->CommonCfg.RegTransmitSetting.field.ShortGI = GI_400;
2592 else if ( HtGi == GI_800 )
2593 pAd->CommonCfg.RegTransmitSetting.field.ShortGI = GI_800;
2594 else
2595 return FALSE; //Invalid argument
2597 SetCommonHT(pAd);
2599 DBGPRINT(RT_DEBUG_TRACE, ("Set_HtGi_Proc::(ShortGI=%d)\n",pAd->CommonCfg.RegTransmitSetting.field.ShortGI));
2601 return TRUE;
2605 INT Set_HtTxBASize_Proc(
2606 IN PRTMP_ADAPTER pAd,
2607 IN PSTRING arg)
2609 UCHAR Size;
2611 Size = simple_strtol(arg, 0, 10);
2613 if (Size <=0 || Size >=64)
2615 Size = 8;
2617 pAd->CommonCfg.TxBASize = Size-1;
2618 DBGPRINT(RT_DEBUG_ERROR, ("Set_HtTxBASize ::(TxBASize= %d)\n", Size));
2620 return TRUE;
2623 INT Set_HtDisallowTKIP_Proc(
2624 IN PRTMP_ADAPTER pAd,
2625 IN PSTRING arg)
2627 ULONG Value;
2629 Value = simple_strtol(arg, 0, 10);
2631 if (Value == 1)
2633 pAd->CommonCfg.HT_DisallowTKIP = TRUE;
2635 else
2637 pAd->CommonCfg.HT_DisallowTKIP = FALSE;
2640 DBGPRINT(RT_DEBUG_TRACE, ("Set_HtDisallowTKIP_Proc ::%s\n",
2641 (pAd->CommonCfg.HT_DisallowTKIP == TRUE) ? "enabled" : "disabled"));
2643 return TRUE;
2646 INT Set_HtOpMode_Proc(
2647 IN PRTMP_ADAPTER pAd,
2648 IN PSTRING arg)
2651 ULONG Value;
2653 Value = simple_strtol(arg, 0, 10);
2655 if (Value == HTMODE_GF)
2656 pAd->CommonCfg.RegTransmitSetting.field.HTMODE = HTMODE_GF;
2657 else if ( Value == HTMODE_MM )
2658 pAd->CommonCfg.RegTransmitSetting.field.HTMODE = HTMODE_MM;
2659 else
2660 return FALSE; //Invalid argument
2662 SetCommonHT(pAd);
2664 DBGPRINT(RT_DEBUG_TRACE, ("Set_HtOpMode_Proc::(HtOpMode=%d)\n",pAd->CommonCfg.RegTransmitSetting.field.HTMODE));
2666 return TRUE;
2670 INT Set_HtStbc_Proc(
2671 IN PRTMP_ADAPTER pAd,
2672 IN PSTRING arg)
2675 ULONG Value;
2677 Value = simple_strtol(arg, 0, 10);
2679 if (Value == STBC_USE)
2680 pAd->CommonCfg.RegTransmitSetting.field.STBC = STBC_USE;
2681 else if ( Value == STBC_NONE )
2682 pAd->CommonCfg.RegTransmitSetting.field.STBC = STBC_NONE;
2683 else
2684 return FALSE; //Invalid argument
2686 SetCommonHT(pAd);
2688 DBGPRINT(RT_DEBUG_TRACE, ("Set_Stbc_Proc::(HtStbc=%d)\n",pAd->CommonCfg.RegTransmitSetting.field.STBC));
2690 return TRUE;
2693 INT Set_HtHtc_Proc(
2694 IN PRTMP_ADAPTER pAd,
2695 IN PSTRING arg)
2698 ULONG Value;
2700 Value = simple_strtol(arg, 0, 10);
2701 if (Value == 0)
2702 pAd->HTCEnable = FALSE;
2703 else if ( Value ==1 )
2704 pAd->HTCEnable = TRUE;
2705 else
2706 return FALSE; //Invalid argument
2708 DBGPRINT(RT_DEBUG_TRACE, ("Set_HtHtc_Proc::(HtHtc=%d)\n",pAd->HTCEnable));
2710 return TRUE;
2713 INT Set_HtExtcha_Proc(
2714 IN PRTMP_ADAPTER pAd,
2715 IN PSTRING arg)
2718 ULONG Value;
2720 Value = simple_strtol(arg, 0, 10);
2722 if (Value == 0)
2723 pAd->CommonCfg.RegTransmitSetting.field.EXTCHA = EXTCHA_BELOW;
2724 else if ( Value ==1 )
2725 pAd->CommonCfg.RegTransmitSetting.field.EXTCHA = EXTCHA_ABOVE;
2726 else
2727 return FALSE; //Invalid argument
2729 SetCommonHT(pAd);
2731 DBGPRINT(RT_DEBUG_TRACE, ("Set_HtExtcha_Proc::(HtExtcha=%d)\n",pAd->CommonCfg.RegTransmitSetting.field.EXTCHA));
2733 return TRUE;
2736 INT Set_HtMpduDensity_Proc(
2737 IN PRTMP_ADAPTER pAd,
2738 IN PSTRING arg)
2740 ULONG Value;
2742 Value = simple_strtol(arg, 0, 10);
2744 if (Value <=7 && Value >= 0)
2745 pAd->CommonCfg.BACapability.field.MpduDensity = Value;
2746 else
2747 pAd->CommonCfg.BACapability.field.MpduDensity = 4;
2749 SetCommonHT(pAd);
2751 DBGPRINT(RT_DEBUG_TRACE, ("Set_HtMpduDensity_Proc::(HtMpduDensity=%d)\n",pAd->CommonCfg.BACapability.field.MpduDensity));
2753 return TRUE;
2756 INT Set_HtBaWinSize_Proc(
2757 IN PRTMP_ADAPTER pAd,
2758 IN PSTRING arg)
2760 ULONG Value;
2762 Value = simple_strtol(arg, 0, 10);
2765 if (Value >=1 && Value <= 64)
2767 pAd->CommonCfg.REGBACapability.field.RxBAWinLimit = Value;
2768 pAd->CommonCfg.BACapability.field.RxBAWinLimit = Value;
2770 else
2772 pAd->CommonCfg.REGBACapability.field.RxBAWinLimit = 64;
2773 pAd->CommonCfg.BACapability.field.RxBAWinLimit = 64;
2776 SetCommonHT(pAd);
2778 DBGPRINT(RT_DEBUG_TRACE, ("Set_HtBaWinSize_Proc::(HtBaWinSize=%d)\n",pAd->CommonCfg.BACapability.field.RxBAWinLimit));
2780 return TRUE;
2783 INT Set_HtRdg_Proc(
2784 IN PRTMP_ADAPTER pAd,
2785 IN PSTRING arg)
2787 ULONG Value;
2789 Value = simple_strtol(arg, 0, 10);
2791 if (Value == 0)
2792 pAd->CommonCfg.bRdg = FALSE;
2793 else if ( Value ==1 )
2795 pAd->HTCEnable = TRUE;
2796 pAd->CommonCfg.bRdg = TRUE;
2798 else
2799 return FALSE; //Invalid argument
2801 SetCommonHT(pAd);
2803 DBGPRINT(RT_DEBUG_TRACE, ("Set_HtRdg_Proc::(HtRdg=%d)\n",pAd->CommonCfg.bRdg));
2805 return TRUE;
2808 INT Set_HtLinkAdapt_Proc(
2809 IN PRTMP_ADAPTER pAd,
2810 IN PSTRING arg)
2812 ULONG Value;
2814 Value = simple_strtol(arg, 0, 10);
2815 if (Value == 0)
2816 pAd->bLinkAdapt = FALSE;
2817 else if ( Value ==1 )
2819 pAd->HTCEnable = TRUE;
2820 pAd->bLinkAdapt = TRUE;
2822 else
2823 return FALSE; //Invalid argument
2825 DBGPRINT(RT_DEBUG_TRACE, ("Set_HtLinkAdapt_Proc::(HtLinkAdapt=%d)\n",pAd->bLinkAdapt));
2827 return TRUE;
2830 INT Set_HtAmsdu_Proc(
2831 IN PRTMP_ADAPTER pAd,
2832 IN PSTRING arg)
2834 ULONG Value;
2836 Value = simple_strtol(arg, 0, 10);
2837 if (Value == 0)
2838 pAd->CommonCfg.BACapability.field.AmsduEnable = FALSE;
2839 else if ( Value == 1 )
2840 pAd->CommonCfg.BACapability.field.AmsduEnable = TRUE;
2841 else
2842 return FALSE; //Invalid argument
2844 SetCommonHT(pAd);
2846 DBGPRINT(RT_DEBUG_TRACE, ("Set_HtAmsdu_Proc::(HtAmsdu=%d)\n",pAd->CommonCfg.BACapability.field.AmsduEnable));
2848 return TRUE;
2851 INT Set_HtAutoBa_Proc(
2852 IN PRTMP_ADAPTER pAd,
2853 IN PSTRING arg)
2855 ULONG Value;
2857 Value = simple_strtol(arg, 0, 10);
2858 if (Value == 0)
2860 pAd->CommonCfg.BACapability.field.AutoBA = FALSE;
2861 pAd->CommonCfg.BACapability.field.Policy = BA_NOTUSE;
2863 else if (Value == 1)
2865 pAd->CommonCfg.BACapability.field.AutoBA = TRUE;
2866 pAd->CommonCfg.BACapability.field.Policy = IMMED_BA;
2868 else
2869 return FALSE; //Invalid argument
2871 pAd->CommonCfg.REGBACapability.field.AutoBA = pAd->CommonCfg.BACapability.field.AutoBA;
2872 pAd->CommonCfg.REGBACapability.field.Policy = pAd->CommonCfg.BACapability.field.Policy;
2873 SetCommonHT(pAd);
2875 DBGPRINT(RT_DEBUG_TRACE, ("Set_HtAutoBa_Proc::(HtAutoBa=%d)\n",pAd->CommonCfg.BACapability.field.AutoBA));
2877 return TRUE;
2881 INT Set_HtProtect_Proc(
2882 IN PRTMP_ADAPTER pAd,
2883 IN PSTRING arg)
2885 ULONG Value;
2887 Value = simple_strtol(arg, 0, 10);
2888 if (Value == 0)
2889 pAd->CommonCfg.bHTProtect = FALSE;
2890 else if (Value == 1)
2891 pAd->CommonCfg.bHTProtect = TRUE;
2892 else
2893 return FALSE; //Invalid argument
2895 DBGPRINT(RT_DEBUG_TRACE, ("Set_HtProtect_Proc::(HtProtect=%d)\n",pAd->CommonCfg.bHTProtect));
2897 return TRUE;
2900 INT Set_SendPSMPAction_Proc(
2901 IN PRTMP_ADAPTER pAd,
2902 IN PSTRING arg)
2904 UCHAR mac[6], mode;
2905 PSTRING token;
2906 STRING sepValue[] = ":", DASH = '-';
2907 INT i;
2908 MAC_TABLE_ENTRY *pEntry;
2910 //DBGPRINT(RT_DEBUG_TRACE,("\n%s\n", arg));
2912 The BARecTearDown inupt string format should be xx:xx:xx:xx:xx:xx-d,
2913 =>The six 2 digit hex-decimal number previous are the Mac address,
2914 =>The seventh decimal number is the mode value.
2916 if(strlen(arg) < 19) //Mac address acceptable format 01:02:03:04:05:06 length 17 plus the "-" and mode value in decimal format.
2917 return FALSE;
2919 token = strchr(arg, DASH);
2920 if ((token != NULL) && (strlen(token)>1))
2922 mode = simple_strtol((token+1), 0, 10);
2923 if (mode > MMPS_ENABLE)
2924 return FALSE;
2926 *token = '\0';
2927 for (i = 0, token = rstrtok(arg, &sepValue[0]); token; token = rstrtok(NULL, &sepValue[0]), i++)
2929 if((strlen(token) != 2) || (!isxdigit(*token)) || (!isxdigit(*(token+1))))
2930 return FALSE;
2931 AtoH(token, (&mac[i]), 1);
2933 if(i != 6)
2934 return FALSE;
2936 DBGPRINT(RT_DEBUG_OFF, ("\n%02x:%02x:%02x:%02x:%02x:%02x-%02x",
2937 mac[0], mac[1], mac[2], mac[3], mac[4], mac[5], mode));
2939 pEntry = MacTableLookup(pAd, mac);
2941 if (pEntry) {
2942 DBGPRINT(RT_DEBUG_OFF, ("\nSendPSMPAction MIPS mode = %d\n", mode));
2943 SendPSMPAction(pAd, pEntry->Aid, mode);
2946 return TRUE;
2949 return FALSE;
2954 INT Set_HtMIMOPSmode_Proc(
2955 IN PRTMP_ADAPTER pAd,
2956 IN PSTRING arg)
2958 ULONG Value;
2960 Value = simple_strtol(arg, 0, 10);
2962 if (Value <=3 && Value >= 0)
2963 pAd->CommonCfg.BACapability.field.MMPSmode = Value;
2964 else
2965 pAd->CommonCfg.BACapability.field.MMPSmode = 3;
2967 SetCommonHT(pAd);
2969 DBGPRINT(RT_DEBUG_TRACE, ("Set_HtMIMOPSmode_Proc::(MIMOPS mode=%d)\n",pAd->CommonCfg.BACapability.field.MMPSmode));
2971 return TRUE;
2975 INT Set_ForceShortGI_Proc(
2976 IN PRTMP_ADAPTER pAd,
2977 IN PSTRING arg)
2979 ULONG Value;
2981 Value = simple_strtol(arg, 0, 10);
2982 if (Value == 0)
2983 pAd->WIFItestbed.bShortGI = FALSE;
2984 else if (Value == 1)
2985 pAd->WIFItestbed.bShortGI = TRUE;
2986 else
2987 return FALSE; //Invalid argument
2989 SetCommonHT(pAd);
2991 DBGPRINT(RT_DEBUG_TRACE, ("Set_ForceShortGI_Proc::(ForceShortGI=%d)\n", pAd->WIFItestbed.bShortGI));
2993 return TRUE;
2998 INT Set_ForceGF_Proc(
2999 IN PRTMP_ADAPTER pAd,
3000 IN PSTRING arg)
3002 ULONG Value;
3004 Value = simple_strtol(arg, 0, 10);
3005 if (Value == 0)
3006 pAd->WIFItestbed.bGreenField = FALSE;
3007 else if (Value == 1)
3008 pAd->WIFItestbed.bGreenField = TRUE;
3009 else
3010 return FALSE; //Invalid argument
3012 SetCommonHT(pAd);
3014 DBGPRINT(RT_DEBUG_TRACE, ("Set_ForceGF_Proc::(ForceGF=%d)\n", pAd->WIFItestbed.bGreenField));
3016 return TRUE;
3019 INT Set_HtMimoPs_Proc(
3020 IN PRTMP_ADAPTER pAd,
3021 IN PSTRING arg)
3023 ULONG Value;
3025 Value = simple_strtol(arg, 0, 10);
3026 if (Value == 0)
3027 pAd->CommonCfg.bMIMOPSEnable = FALSE;
3028 else if (Value == 1)
3029 pAd->CommonCfg.bMIMOPSEnable = TRUE;
3030 else
3031 return FALSE; //Invalid argument
3033 DBGPRINT(RT_DEBUG_TRACE, ("Set_HtMimoPs_Proc::(HtMimoPs=%d)\n",pAd->CommonCfg.bMIMOPSEnable));
3035 return TRUE;
3037 #endif // DOT11_N_SUPPORT //
3040 #ifdef DOT11_N_SUPPORT
3041 INT SetCommonHT(
3042 IN PRTMP_ADAPTER pAd)
3044 OID_SET_HT_PHYMODE SetHT;
3046 if (pAd->CommonCfg.PhyMode < PHY_11ABGN_MIXED)
3047 return FALSE;
3049 SetHT.PhyMode = pAd->CommonCfg.PhyMode;
3050 SetHT.TransmitNo = ((UCHAR)pAd->Antenna.field.TxPath);
3051 SetHT.HtMode = (UCHAR)pAd->CommonCfg.RegTransmitSetting.field.HTMODE;
3052 SetHT.ExtOffset = (UCHAR)pAd->CommonCfg.RegTransmitSetting.field.EXTCHA;
3053 SetHT.MCS = MCS_AUTO;
3054 SetHT.BW = (UCHAR)pAd->CommonCfg.RegTransmitSetting.field.BW;
3055 SetHT.STBC = (UCHAR)pAd->CommonCfg.RegTransmitSetting.field.STBC;
3056 SetHT.SHORTGI = (UCHAR)pAd->CommonCfg.RegTransmitSetting.field.ShortGI;
3058 RTMPSetHT(pAd, &SetHT);
3060 return TRUE;
3062 #endif // DOT11_N_SUPPORT //
3064 INT Set_FixedTxMode_Proc(
3065 IN PRTMP_ADAPTER pAd,
3066 IN PSTRING arg)
3068 UCHAR fix_tx_mode = FIXED_TXMODE_HT;
3070 if (strcmp(arg, "OFDM") == 0 || strcmp(arg, "ofdm") == 0)
3072 fix_tx_mode = FIXED_TXMODE_OFDM;
3074 else if (strcmp(arg, "CCK") == 0 || strcmp(arg, "cck") == 0)
3076 fix_tx_mode = FIXED_TXMODE_CCK;
3079 #ifdef CONFIG_STA_SUPPORT
3080 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
3081 pAd->StaCfg.DesiredTransmitSetting.field.FixedTxMode = fix_tx_mode;
3082 #endif // CONFIG_STA_SUPPORT //
3084 DBGPRINT(RT_DEBUG_TRACE, ("Set_FixedTxMode_Proc::(FixedTxMode=%d)\n", fix_tx_mode));
3086 return TRUE;
3089 #ifdef CONFIG_APSTA_MIXED_SUPPORT
3090 INT Set_OpMode_Proc(
3091 IN PRTMP_ADAPTER pAd,
3092 IN PSTRING arg)
3094 ULONG Value;
3096 Value = simple_strtol(arg, 0, 10);
3098 #ifdef RTMP_MAC_PCI
3099 if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE))
3100 #endif // RTMP_MAC_PCI //
3102 DBGPRINT(RT_DEBUG_ERROR, ("Can not switch operate mode on interface up !! \n"));
3103 return FALSE;
3106 if (Value == 0)
3107 pAd->OpMode = OPMODE_STA;
3108 else if (Value == 1)
3109 pAd->OpMode = OPMODE_AP;
3110 else
3111 return FALSE; //Invalid argument
3113 DBGPRINT(RT_DEBUG_TRACE, ("Set_OpMode_Proc::(OpMode=%s)\n", pAd->OpMode == 1 ? "AP Mode" : "STA Mode"));
3115 return TRUE;
3117 #endif // CONFIG_APSTA_MIXED_SUPPORT //
3121 INT Set_LongRetryLimit_Proc(
3122 IN PRTMP_ADAPTER pAdapter,
3123 IN PSTRING arg)
3125 TX_RTY_CFG_STRUC tx_rty_cfg;
3126 UCHAR LongRetryLimit = (UCHAR)simple_strtol(arg, 0, 10);
3128 RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
3129 tx_rty_cfg.field.LongRtyLimit = LongRetryLimit;
3130 RTMP_IO_WRITE32(pAdapter, TX_RTY_CFG, tx_rty_cfg.word);
3131 DBGPRINT(RT_DEBUG_TRACE, ("IF Set_LongRetryLimit_Proc::(tx_rty_cfg=0x%x)\n", tx_rty_cfg.word));
3132 return TRUE;
3135 INT Set_ShortRetryLimit_Proc(
3136 IN PRTMP_ADAPTER pAdapter,
3137 IN PSTRING arg)
3139 TX_RTY_CFG_STRUC tx_rty_cfg;
3140 UCHAR ShortRetryLimit = (UCHAR)simple_strtol(arg, 0, 10);
3142 RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
3143 tx_rty_cfg.field.ShortRtyLimit = ShortRetryLimit;
3144 RTMP_IO_WRITE32(pAdapter, TX_RTY_CFG, tx_rty_cfg.word);
3145 DBGPRINT(RT_DEBUG_TRACE, ("IF Set_ShortRetryLimit_Proc::(tx_rty_cfg=0x%x)\n", tx_rty_cfg.word));
3146 return TRUE;
3150 /////////////////////////////////////////////////////////////////////////
3151 PSTRING RTMPGetRalinkAuthModeStr(
3152 IN NDIS_802_11_AUTHENTICATION_MODE authMode)
3154 switch(authMode)
3156 case Ndis802_11AuthModeOpen:
3157 return "OPEN";
3158 case Ndis802_11AuthModeWPAPSK:
3159 return "WPAPSK";
3160 case Ndis802_11AuthModeShared:
3161 return "SHARED";
3162 case Ndis802_11AuthModeWPA:
3163 return "WPA";
3164 case Ndis802_11AuthModeWPA2:
3165 return "WPA2";
3166 case Ndis802_11AuthModeWPA2PSK:
3167 return "WPA2PSK";
3168 case Ndis802_11AuthModeWPA1PSKWPA2PSK:
3169 return "WPAPSKWPA2PSK";
3170 case Ndis802_11AuthModeWPA1WPA2:
3171 return "WPA1WPA2";
3172 case Ndis802_11AuthModeWPANone:
3173 return "WPANONE";
3174 default:
3175 return "UNKNOW";
3179 PSTRING RTMPGetRalinkEncryModeStr(
3180 IN USHORT encryMode)
3182 switch(encryMode)
3184 case Ndis802_11WEPDisabled:
3185 return "NONE";
3186 case Ndis802_11WEPEnabled:
3187 return "WEP";
3188 case Ndis802_11Encryption2Enabled:
3189 return "TKIP";
3190 case Ndis802_11Encryption3Enabled:
3191 return "AES";
3192 case Ndis802_11Encryption4Enabled:
3193 return "TKIPAES";
3194 default:
3195 return "UNKNOW";
3199 INT RTMPShowCfgValue(
3200 IN PRTMP_ADAPTER pAd,
3201 IN PSTRING pName,
3202 IN PSTRING pBuf)
3204 INT Status = 0;
3206 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++)
3208 if (!strcmp(pName, PRTMP_PRIVATE_STA_SHOW_CFG_VALUE_PROC->name))
3210 if(PRTMP_PRIVATE_STA_SHOW_CFG_VALUE_PROC->show_proc(pAd, pBuf))
3211 Status = -EINVAL;
3212 break; //Exit for loop.
3216 if(PRTMP_PRIVATE_STA_SHOW_CFG_VALUE_PROC->name == NULL)
3218 sprintf(pBuf, "\n");
3219 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++)
3220 sprintf(pBuf, "%s%s\n", pBuf, PRTMP_PRIVATE_STA_SHOW_CFG_VALUE_PROC->name);
3223 return Status;
3226 INT Show_SSID_Proc(
3227 IN PRTMP_ADAPTER pAd,
3228 OUT PSTRING pBuf)
3231 #ifdef CONFIG_STA_SUPPORT
3232 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
3233 sprintf(pBuf, "\t%s", pAd->CommonCfg.Ssid);
3234 #endif // CONFIG_STA_SUPPORT //
3235 return 0;
3238 INT Show_WirelessMode_Proc(
3239 IN PRTMP_ADAPTER pAd,
3240 OUT PSTRING pBuf)
3242 switch(pAd->CommonCfg.PhyMode)
3244 case PHY_11BG_MIXED:
3245 sprintf(pBuf, "\t11B/G");
3246 break;
3247 case PHY_11B:
3248 sprintf(pBuf, "\t11B");
3249 break;
3250 case PHY_11A:
3251 sprintf(pBuf, "\t11A");
3252 break;
3253 case PHY_11ABG_MIXED:
3254 sprintf(pBuf, "\t11A/B/G");
3255 break;
3256 case PHY_11G:
3257 sprintf(pBuf, "\t11G");
3258 break;
3259 #ifdef DOT11_N_SUPPORT
3260 case PHY_11ABGN_MIXED:
3261 sprintf(pBuf, "\t11A/B/G/N");
3262 break;
3263 case PHY_11N_2_4G:
3264 sprintf(pBuf, "\t11N only with 2.4G");
3265 break;
3266 case PHY_11GN_MIXED:
3267 sprintf(pBuf, "\t11G/N");
3268 break;
3269 case PHY_11AN_MIXED:
3270 sprintf(pBuf, "\t11A/N");
3271 break;
3272 case PHY_11BGN_MIXED:
3273 sprintf(pBuf, "\t11B/G/N");
3274 break;
3275 case PHY_11AGN_MIXED:
3276 sprintf(pBuf, "\t11A/G/N");
3277 break;
3278 case PHY_11N_5G:
3279 sprintf(pBuf, "\t11N only with 5G");
3280 break;
3281 #endif // DOT11_N_SUPPORT //
3282 default:
3283 sprintf(pBuf, "\tUnknow Value(%d)", pAd->CommonCfg.PhyMode);
3284 break;
3286 return 0;
3290 INT Show_TxBurst_Proc(
3291 IN PRTMP_ADAPTER pAd,
3292 OUT PSTRING pBuf)
3294 sprintf(pBuf, "\t%s", pAd->CommonCfg.bEnableTxBurst ? "TRUE":"FALSE");
3295 return 0;
3298 INT Show_TxPreamble_Proc(
3299 IN PRTMP_ADAPTER pAd,
3300 OUT PSTRING pBuf)
3302 switch(pAd->CommonCfg.TxPreamble)
3304 case Rt802_11PreambleShort:
3305 sprintf(pBuf, "\tShort");
3306 break;
3307 case Rt802_11PreambleLong:
3308 sprintf(pBuf, "\tLong");
3309 break;
3310 case Rt802_11PreambleAuto:
3311 sprintf(pBuf, "\tAuto");
3312 break;
3313 default:
3314 sprintf(pBuf, "\tUnknow Value(%lu)", pAd->CommonCfg.TxPreamble);
3315 break;
3318 return 0;
3321 INT Show_TxPower_Proc(
3322 IN PRTMP_ADAPTER pAd,
3323 OUT PSTRING pBuf)
3325 sprintf(pBuf, "\t%lu", pAd->CommonCfg.TxPowerPercentage);
3326 return 0;
3329 INT Show_Channel_Proc(
3330 IN PRTMP_ADAPTER pAd,
3331 OUT PSTRING pBuf)
3333 sprintf(pBuf, "\t%d", pAd->CommonCfg.Channel);
3334 return 0;
3337 INT Show_BGProtection_Proc(
3338 IN PRTMP_ADAPTER pAd,
3339 OUT PSTRING pBuf)
3341 switch(pAd->CommonCfg.UseBGProtection)
3343 case 1: //Always On
3344 sprintf(pBuf, "\tON");
3345 break;
3346 case 2: //Always OFF
3347 sprintf(pBuf, "\tOFF");
3348 break;
3349 case 0: //AUTO
3350 sprintf(pBuf, "\tAuto");
3351 break;
3352 default:
3353 sprintf(pBuf, "\tUnknow Value(%lu)", pAd->CommonCfg.UseBGProtection);
3354 break;
3356 return 0;
3359 INT Show_RTSThreshold_Proc(
3360 IN PRTMP_ADAPTER pAd,
3361 OUT PSTRING pBuf)
3363 sprintf(pBuf, "\t%u", pAd->CommonCfg.RtsThreshold);
3364 return 0;
3367 INT Show_FragThreshold_Proc(
3368 IN PRTMP_ADAPTER pAd,
3369 OUT PSTRING pBuf)
3371 sprintf(pBuf, "\t%u", pAd->CommonCfg.FragmentThreshold);
3372 return 0;
3375 #ifdef DOT11_N_SUPPORT
3376 INT Show_HtBw_Proc(
3377 IN PRTMP_ADAPTER pAd,
3378 OUT PSTRING pBuf)
3380 if (pAd->CommonCfg.RegTransmitSetting.field.BW == BW_40)
3382 sprintf(pBuf, "\t40 MHz");
3384 else
3386 sprintf(pBuf, "\t20 MHz");
3388 return 0;
3391 INT Show_HtMcs_Proc(
3392 IN PRTMP_ADAPTER pAd,
3393 OUT PSTRING pBuf)
3396 #ifdef CONFIG_STA_SUPPORT
3397 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
3398 sprintf(pBuf, "\t%u", pAd->StaCfg.DesiredTransmitSetting.field.MCS);
3399 #endif // CONFIG_STA_SUPPORT //
3400 return 0;
3403 INT Show_HtGi_Proc(
3404 IN PRTMP_ADAPTER pAd,
3405 OUT PSTRING pBuf)
3407 switch(pAd->CommonCfg.RegTransmitSetting.field.ShortGI)
3409 case GI_400:
3410 sprintf(pBuf, "\tGI_400");
3411 break;
3412 case GI_800:
3413 sprintf(pBuf, "\tGI_800");
3414 break;
3415 default:
3416 sprintf(pBuf, "\tUnknow Value(%u)", pAd->CommonCfg.RegTransmitSetting.field.ShortGI);
3417 break;
3419 return 0;
3422 INT Show_HtOpMode_Proc(
3423 IN PRTMP_ADAPTER pAd,
3424 OUT PSTRING pBuf)
3426 switch(pAd->CommonCfg.RegTransmitSetting.field.HTMODE)
3428 case HTMODE_GF:
3429 sprintf(pBuf, "\tGF");
3430 break;
3431 case HTMODE_MM:
3432 sprintf(pBuf, "\tMM");
3433 break;
3434 default:
3435 sprintf(pBuf, "\tUnknow Value(%u)", pAd->CommonCfg.RegTransmitSetting.field.HTMODE);
3436 break;
3438 return 0;
3441 INT Show_HtExtcha_Proc(
3442 IN PRTMP_ADAPTER pAd,
3443 OUT PSTRING pBuf)
3445 switch(pAd->CommonCfg.RegTransmitSetting.field.EXTCHA)
3447 case EXTCHA_BELOW:
3448 sprintf(pBuf, "\tBelow");
3449 break;
3450 case EXTCHA_ABOVE:
3451 sprintf(pBuf, "\tAbove");
3452 break;
3453 default:
3454 sprintf(pBuf, "\tUnknow Value(%u)", pAd->CommonCfg.RegTransmitSetting.field.EXTCHA);
3455 break;
3457 return 0;
3461 INT Show_HtMpduDensity_Proc(
3462 IN PRTMP_ADAPTER pAd,
3463 OUT PSTRING pBuf)
3465 sprintf(pBuf, "\t%u", pAd->CommonCfg.BACapability.field.MpduDensity);
3466 return 0;
3469 INT Show_HtBaWinSize_Proc(
3470 IN PRTMP_ADAPTER pAd,
3471 OUT PSTRING pBuf)
3473 sprintf(pBuf, "\t%u", pAd->CommonCfg.BACapability.field.RxBAWinLimit);
3474 return 0;
3477 INT Show_HtRdg_Proc(
3478 IN PRTMP_ADAPTER pAd,
3479 OUT PSTRING pBuf)
3481 sprintf(pBuf, "\t%s", pAd->CommonCfg.bRdg ? "TRUE":"FALSE");
3482 return 0;
3485 INT Show_HtAmsdu_Proc(
3486 IN PRTMP_ADAPTER pAd,
3487 OUT PSTRING pBuf)
3489 sprintf(pBuf, "\t%s", pAd->CommonCfg.BACapability.field.AmsduEnable ? "TRUE":"FALSE");
3490 return 0;
3493 INT Show_HtAutoBa_Proc(
3494 IN PRTMP_ADAPTER pAd,
3495 OUT PSTRING pBuf)
3497 sprintf(pBuf, "\t%s", pAd->CommonCfg.BACapability.field.AutoBA ? "TRUE":"FALSE");
3498 return 0;
3500 #endif // DOT11_N_SUPPORT //
3502 INT Show_CountryRegion_Proc(
3503 IN PRTMP_ADAPTER pAd,
3504 OUT PSTRING pBuf)
3506 sprintf(pBuf, "\t%d", pAd->CommonCfg.CountryRegion);
3507 return 0;
3510 INT Show_CountryRegionABand_Proc(
3511 IN PRTMP_ADAPTER pAd,
3512 OUT PSTRING pBuf)
3514 sprintf(pBuf, "\t%d", pAd->CommonCfg.CountryRegionForABand);
3515 return 0;
3518 INT Show_CountryCode_Proc(
3519 IN PRTMP_ADAPTER pAd,
3520 OUT PSTRING pBuf)
3522 sprintf(pBuf, "\t%s", pAd->CommonCfg.CountryCode);
3523 return 0;
3526 #ifdef AGGREGATION_SUPPORT
3527 INT Show_PktAggregate_Proc(
3528 IN PRTMP_ADAPTER pAd,
3529 OUT PSTRING pBuf)
3531 sprintf(pBuf, "\t%s", pAd->CommonCfg.bAggregationCapable ? "TRUE":"FALSE");
3532 return 0;
3534 #endif // AGGREGATION_SUPPORT //
3536 #ifdef WMM_SUPPORT
3537 INT Show_WmmCapable_Proc(
3538 IN PRTMP_ADAPTER pAd,
3539 OUT PSTRING pBuf)
3542 #ifdef CONFIG_STA_SUPPORT
3543 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
3544 sprintf(pBuf, "\t%s", pAd->CommonCfg.bWmmCapable ? "TRUE":"FALSE");
3545 #endif // CONFIG_STA_SUPPORT //
3547 return 0;
3549 #endif // WMM_SUPPORT //
3551 INT Show_IEEE80211H_Proc(
3552 IN PRTMP_ADAPTER pAd,
3553 OUT PSTRING pBuf)
3555 sprintf(pBuf, "\t%s", pAd->CommonCfg.bIEEE80211H ? "TRUE":"FALSE");
3556 return 0;
3559 #ifdef CONFIG_STA_SUPPORT
3560 INT Show_NetworkType_Proc(
3561 IN PRTMP_ADAPTER pAd,
3562 OUT PSTRING pBuf)
3564 switch(pAd->StaCfg.BssType)
3566 case BSS_ADHOC:
3567 sprintf(pBuf, "\tAdhoc");
3568 break;
3569 case BSS_INFRA:
3570 sprintf(pBuf, "\tInfra");
3571 break;
3572 case BSS_ANY:
3573 sprintf(pBuf, "\tAny");
3574 break;
3575 case BSS_MONITOR:
3576 sprintf(pBuf, "\tMonitor");
3577 break;
3578 default:
3579 sprintf(pBuf, "\tUnknow Value(%d)", pAd->StaCfg.BssType);
3580 break;
3582 return 0;
3586 #endif // CONFIG_STA_SUPPORT //
3588 INT Show_AuthMode_Proc(
3589 IN PRTMP_ADAPTER pAd,
3590 OUT PSTRING pBuf)
3592 NDIS_802_11_AUTHENTICATION_MODE AuthMode = Ndis802_11AuthModeOpen;
3594 #ifdef CONFIG_STA_SUPPORT
3595 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
3596 AuthMode = pAd->StaCfg.AuthMode;
3597 #endif // CONFIG_STA_SUPPORT //
3599 if ((AuthMode >= Ndis802_11AuthModeOpen) &&
3600 (AuthMode <= Ndis802_11AuthModeWPA1PSKWPA2PSK))
3601 sprintf(pBuf, "\t%s", RTMPGetRalinkAuthModeStr(AuthMode));
3602 else
3603 sprintf(pBuf, "\tUnknow Value(%d)", AuthMode);
3605 return 0;
3608 INT Show_EncrypType_Proc(
3609 IN PRTMP_ADAPTER pAd,
3610 OUT PSTRING pBuf)
3612 NDIS_802_11_WEP_STATUS WepStatus = Ndis802_11WEPDisabled;
3614 #ifdef CONFIG_STA_SUPPORT
3615 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
3616 WepStatus = pAd->StaCfg.WepStatus;
3617 #endif // CONFIG_STA_SUPPORT //
3619 if ((WepStatus >= Ndis802_11WEPEnabled) &&
3620 (WepStatus <= Ndis802_11Encryption4KeyAbsent))
3621 sprintf(pBuf, "\t%s", RTMPGetRalinkEncryModeStr(WepStatus));
3622 else
3623 sprintf(pBuf, "\tUnknow Value(%d)", WepStatus);
3625 return 0;
3628 INT Show_DefaultKeyID_Proc(
3629 IN PRTMP_ADAPTER pAd,
3630 OUT PSTRING pBuf)
3632 UCHAR DefaultKeyId = 0;
3634 #ifdef CONFIG_STA_SUPPORT
3635 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
3636 DefaultKeyId = pAd->StaCfg.DefaultKeyId;
3637 #endif // CONFIG_STA_SUPPORT //
3639 sprintf(pBuf, "\t%d", DefaultKeyId);
3641 return 0;
3644 INT Show_WepKey_Proc(
3645 IN PRTMP_ADAPTER pAd,
3646 IN INT KeyIdx,
3647 OUT PSTRING pBuf)
3649 UCHAR Key[16] = {0}, KeyLength = 0;
3650 INT index = BSS0;
3652 KeyLength = pAd->SharedKey[index][KeyIdx].KeyLen;
3653 NdisMoveMemory(Key, pAd->SharedKey[index][KeyIdx].Key, KeyLength);
3655 //check key string is ASCII or not
3656 if (RTMPCheckStrPrintAble((PCHAR)Key, KeyLength))
3657 sprintf(pBuf, "\t%s", Key);
3658 else
3660 int idx;
3661 sprintf(pBuf, "\t");
3662 for (idx = 0; idx < KeyLength; idx++)
3663 sprintf(pBuf+strlen(pBuf), "%02X", Key[idx]);
3665 return 0;
3668 INT Show_Key1_Proc(
3669 IN PRTMP_ADAPTER pAd,
3670 OUT PSTRING pBuf)
3672 Show_WepKey_Proc(pAd, 0, pBuf);
3673 return 0;
3676 INT Show_Key2_Proc(
3677 IN PRTMP_ADAPTER pAd,
3678 OUT PSTRING pBuf)
3680 Show_WepKey_Proc(pAd, 1, pBuf);
3681 return 0;
3684 INT Show_Key3_Proc(
3685 IN PRTMP_ADAPTER pAd,
3686 OUT PSTRING pBuf)
3688 Show_WepKey_Proc(pAd, 2, pBuf);
3689 return 0;
3692 INT Show_Key4_Proc(
3693 IN PRTMP_ADAPTER pAd,
3694 OUT PSTRING pBuf)
3696 Show_WepKey_Proc(pAd, 3, pBuf);
3697 return 0;
3700 INT Show_WPAPSK_Proc(
3701 IN PRTMP_ADAPTER pAd,
3702 OUT PSTRING pBuf)
3704 INT idx;
3705 UCHAR PMK[32] = {0};
3708 #ifdef CONFIG_STA_SUPPORT
3709 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
3710 NdisMoveMemory(PMK, pAd->StaCfg.PMK, 32);
3711 #endif // CONFIG_STA_SUPPORT //
3713 sprintf(pBuf, "\tPMK = ");
3714 for (idx = 0; idx < 32; idx++)
3715 sprintf(pBuf+strlen(pBuf), "%02X", PMK[idx]);
3717 return 0;