-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy pathcmm_info.c
8255 lines (6923 loc) · 222 KB
/
cmm_info.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/****************************************************************************
* Ralink Tech Inc.
* 4F, No. 2 Technology 5th Rd.
* Science-based Industrial Park
* Hsin-chu, Taiwan, R.O.C.
* (c) Copyright 2002, Ralink Technology, Inc.
*
* All rights reserved. Ralink's source code is an unpublished work and the
* use of a copyright notice does not imply otherwise. This source code
* contains confidential trade secret material of Ralink Tech. Any attemp
* or participation in deciphering, decoding, reverse engineering or in any
* way altering the source code is stricitly prohibited, unless the prior
* written consent of Ralink Technology, Inc. is obtained.
****************************************************************************
Module Name:
cmm_info.c
Abstract:
Revision History:
Who When What
--------- ---------- ----------------------------------------------
*/
#include "rt_config.h"
/*
==========================================================================
Description:
Get Driver version.
Return:
==========================================================================
*/
INT Set_DriverVersion_Proc(
IN PRTMP_ADAPTER pAd,
IN PSTRING arg)
{
#ifdef CONFIG_AP_SUPPORT
IF_DEV_CONFIG_OPMODE_ON_AP(pAd)
DBGPRINT(RT_DEBUG_OFF, ("Driver version-%s %s %s\n", AP_DRIVER_VERSION));
#endif /* CONFIG_AP_SUPPORT */
#ifdef CONFIG_STA_SUPPORT
IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
DBGPRINT(RT_DEBUG_OFF, ("Driver version-%s %s %s\n", STA_DRIVER_VERSION));
#endif /* CONFIG_STA_SUPPORT */
#ifdef CONFIG_ANDES_SUPPORT
if (pAd->chipCap.MCUType == ANDES) {
UINT32 loop = 0;
RTMP_CHIP_CAP *cap = &pAd->chipCap;
if (pAd->chipCap.need_load_fw) {
USHORT fw_ver, build_ver;
fw_ver = (*(cap->FWImageName + 11) << 8) | (*(cap->FWImageName + 10));
build_ver = (*(cap->FWImageName + 9) << 8) | (*(cap->FWImageName + 8));
DBGPRINT(RT_DEBUG_OFF, ("fw version:%d.%d.%02d ", (fw_ver & 0xf000) >> 8,
(fw_ver & 0x0f00) >> 8, fw_ver & 0x00ff));
DBGPRINT(RT_DEBUG_OFF, ("build:%x\n", build_ver));
DBGPRINT(RT_DEBUG_OFF, ("build time:"));
for (loop = 0; loop < 16; loop++)
DBGPRINT(RT_DEBUG_OFF, ("%c", *(cap->FWImageName + 16 + loop)));
DBGPRINT(RT_DEBUG_OFF, ("\n"));
}
if (pAd->chipCap.need_load_rom_patch) {
DBGPRINT(RT_DEBUG_OFF, ("rom patch version = \n"));
for (loop = 0; loop < 4; loop++)
DBGPRINT(RT_DEBUG_OFF, ("%c", *(cap->rom_patch + 24 + loop)));
DBGPRINT(RT_DEBUG_OFF, ("\n"));
DBGPRINT(RT_DEBUG_OFF, ("build time = \n"));
for (loop = 0; loop < 16; loop++)
DBGPRINT(RT_DEBUG_OFF, ("%c", *(cap->rom_patch + loop)));
DBGPRINT(RT_DEBUG_OFF, ("\n"));
}
}
#endif
return TRUE;
}
/*
==========================================================================
Description:
Set Country Region.
This command will not work, if the field of CountryRegion in eeprom is programmed.
Return:
TRUE if all parameters are OK, FALSE otherwise
==========================================================================
*/
INT Set_CountryRegion_Proc(
IN PRTMP_ADAPTER pAd,
IN PSTRING arg)
{
int retval;
#ifdef EXT_BUILD_CHANNEL_LIST
return -EOPNOTSUPP;
#endif /* EXT_BUILD_CHANNEL_LIST */
retval = RT_CfgSetCountryRegion(pAd, arg, BAND_24G);
if (retval == FALSE)
return FALSE;
/* if set country region, driver needs to be reset*/
BuildChannelList(pAd);
DBGPRINT(RT_DEBUG_TRACE, ("Set_CountryRegion_Proc::(CountryRegion=%d)\n", pAd->CommonCfg.CountryRegion));
return TRUE;
}
/*
==========================================================================
Description:
Set Country Region for A band.
This command will not work, if the field of CountryRegion in eeprom is programmed.
Return:
TRUE if all parameters are OK, FALSE otherwise
==========================================================================
*/
INT Set_CountryRegionABand_Proc(
IN PRTMP_ADAPTER pAd,
IN PSTRING arg)
{
int retval;
#ifdef EXT_BUILD_CHANNEL_LIST
return -EOPNOTSUPP;
#endif /* EXT_BUILD_CHANNEL_LIST */
retval = RT_CfgSetCountryRegion(pAd, arg, BAND_5G);
if (retval == FALSE)
return FALSE;
/* if set country region, driver needs to be reset*/
BuildChannelList(pAd);
DBGPRINT(RT_DEBUG_TRACE, ("Set_CountryRegionABand_Proc::(CountryRegion=%d)\n", pAd->CommonCfg.CountryRegionForABand));
return TRUE;
}
INT Set_Cmm_WirelessMode_Proc(
IN RTMP_ADAPTER *pAd,
IN PSTRING arg,
IN BOOLEAN FlgIsDiffMbssModeUsed)
{
INT success = TRUE;
#ifdef CONFIG_AP_SUPPORT
UINT32 i = 0;
#ifdef MBSS_SUPPORT
POS_COOKIE pObj = (POS_COOKIE) pAd->OS_Cookie;
if (FlgIsDiffMbssModeUsed) {
LONG cfg_mode = simple_strtol(arg, 0, 10);
/* assign wireless mode for the BSS */
pAd->ApCfg.MBSSID[pObj->ioctl_if].wdev.PhyMode =
cfgmode_2_wmode((UCHAR)cfg_mode);
/*
If the band is different with other BSS, we will correct it in
RT_CfgSetMbssWirelessMode()
*/
success = RT_CfgSetMbssWirelessMode(pAd, arg);
}
else
#endif /* MBSS_SUPPORT */
#endif /* CONFIG_AP_SUPPORT */
success = RT_CfgSetWirelessMode(pAd, arg);
if (success)
{
#ifdef CONFIG_AP_SUPPORT
IF_DEV_CONFIG_OPMODE_ON_AP(pAd)
{
/* recover Wmm Capable for "each" BSS */
/* all phy mode of MBSS are the same */
for(i=0; i<pAd->ApCfg.BssidNum; i++)
{
pAd->ApCfg.MBSSID[i].wdev.bWmmCapable = \
pAd->ApCfg.MBSSID[i].bWmmCapableOrg;
#ifdef MBSS_SUPPORT
/* In Same-MBSS Mode, all phy modes are the same */
if (FlgIsDiffMbssModeUsed == 0)
pAd->ApCfg.MBSSID[i].wdev.PhyMode = pAd->CommonCfg.PhyMode;
#endif /* MBSS_SUPPORT */
}
RTMPSetPhyMode(pAd, pAd->CommonCfg.PhyMode);
}
#endif /* CONFIG_AP_SUPPORT */
#ifdef CONFIG_STA_SUPPORT
IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
{
/* clean up previous SCAN result */
BssTableInit(&pAd->ScanTab);
pAd->StaCfg.LastScanTime = 0;
RTMPSetPhyMode(pAd, pAd->CommonCfg.PhyMode);
#ifdef DOT11_N_SUPPORT
if (WMODE_CAP_N(pAd->CommonCfg.PhyMode))
{
pAd->CommonCfg.BACapability.field.AutoBA = TRUE;
pAd->CommonCfg.REGBACapability.field.AutoBA = TRUE;
}
else
{
pAd->CommonCfg.BACapability.field.AutoBA = FALSE;
pAd->CommonCfg.REGBACapability.field.AutoBA = FALSE;
}
#endif /* DOT11_N_SUPPORT */
/* Set AdhocMode rates*/
if (pAd->StaCfg.BssType == BSS_ADHOC)
{
MlmeUpdateTxRates(pAd, FALSE, 0);
MakeIbssBeacon(pAd); /* re-build BEACON frame*/
AsicEnableIbssSync(pAd); /* copy to on-chip memory*/
}
}
#endif /* CONFIG_STA_SUPPORT */
#ifdef CONFIG_AP_SUPPORT
#ifdef MBSS_SUPPORT
DBGPRINT(RT_DEBUG_TRACE, ("Set_Cmm_WirelessMode_Proc::(=%d)\n", pAd->CommonCfg.PhyMode));
DBGPRINT(RT_DEBUG_TRACE, ("Set_Cmm_WirelessMode_Proc::(BSS%d=%d)\n",
pObj->ioctl_if, pAd->ApCfg.MBSSID[pObj->ioctl_if].wdev.PhyMode));
for(i=0; i<pAd->ApCfg.BssidNum; i++)
{
/*
When last mode is not 11B-only, new mode is 11B, we need to re-make
beacon frame content.
Because we put support rate/extend support rate element in
APMakeBssBeacon(), not APUpdateBeaconFrame().
*/
APMakeBssBeacon(pAd, i);
}
#endif /* MBSS_SUPPORT */
#endif /* CONFIG_AP_SUPPORT */
}
else
{
DBGPRINT(RT_DEBUG_ERROR, ("Set_WirelessMode_Proc::parameters out of range\n"));
}
return success;
}
#ifdef CONFIG_AP_SUPPORT
#ifdef MBSS_SUPPORT
/*
==========================================================================
Description:
Set Wireless Mode for MBSS
Return:
TRUE if all parameters are OK, FALSE otherwise
==========================================================================
*/
INT Set_MBSS_WirelessMode_Proc(
IN PRTMP_ADAPTER pAd,
IN PSTRING arg)
{
return Set_Cmm_WirelessMode_Proc(pAd, arg, 1);
}
#endif /* MBSS_SUPPORT */
#endif /* CONFIG_AP_SUPPORT */
/*
==========================================================================
Description:
Set Wireless Mode
Return:
TRUE if all parameters are OK, FALSE otherwise
==========================================================================
*/
INT Set_WirelessMode_Proc(RTMP_ADAPTER *pAd, PSTRING arg)
{
return Set_Cmm_WirelessMode_Proc(pAd, arg, 0);
}
#ifdef RT_CFG80211_SUPPORT
INT Set_DisableCfg2040Scan_Proc(RTMP_ADAPTER *pAd, PSTRING arg)
{
pAd->cfg80211_ctrl.FlgCfg8021Disable2040Scan = (UCHAR) simple_strtol(arg, 0, 10);
DBGPRINT(RT_DEBUG_TRACE, ("pAd->cfg80211_ctrl.FlgCfg8021Disable2040Scan %d \n",pAd->cfg80211_ctrl.FlgCfg8021Disable2040Scan ));
return TRUE;
}
#endif
/*
==========================================================================
Description:
Set Channel
Return:
TRUE if all parameters are OK, FALSE otherwise
==========================================================================
*/
INT Set_Channel_Proc(
IN PRTMP_ADAPTER pAd,
IN PSTRING arg)
{
#ifdef CONFIG_AP_SUPPORT
INT i;
#endif /* CONFIG_AP_SUPPORT */
INT success = TRUE;
UCHAR Channel;
Channel = (UCHAR) simple_strtol(arg, 0, 10);
#ifdef APCLI_AUTO_CONNECT_SUPPORT
if (pAd->ApCfg.ApCliAutoConnectChannelSwitching == FALSE)
pAd->ApCfg.ApCliAutoConnectChannelSwitching = TRUE;
#endif /* APCLI_AUTO_CONNECT_SUPPORT */
/* check if this channel is valid*/
if (ChannelSanity(pAd, Channel) == TRUE)
{
#ifdef CONFIG_STA_SUPPORT
IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
{
pAd->CommonCfg.Channel = Channel;
/* Save the channel on MlmeAux for CntlOidRTBssidProc used. */
pAd->MlmeAux.Channel = Channel;
if (MONITOR_ON(pAd))
{
UCHAR rf_channel;
#ifdef DOT11_N_SUPPORT
N_ChannelCheck(pAd);
if (WMODE_CAP_N(pAd->CommonCfg.PhyMode) &&
pAd->CommonCfg.RegTransmitSetting.field.BW == BW_40)
rf_channel = N_SetCenCh(pAd, pAd->CommonCfg.Channel);
else
#endif /* DOT11_N_SUPPORT */
rf_channel = pAd->CommonCfg.Channel;
AsicSwitchChannel(pAd, rf_channel, FALSE);
AsicLockChannel(pAd, rf_channel);
DBGPRINT(RT_DEBUG_TRACE, ("%s(): CtrlChannel(%d), CentralChannel(%d) \n",
__FUNCTION__, pAd->CommonCfg.Channel,
pAd->CommonCfg.CentralChannel));
}
}
#endif /* CONFIG_STA_SUPPORT */
success = TRUE;
}
else
{
#ifdef CONFIG_AP_SUPPORT
IF_DEV_CONFIG_OPMODE_ON_AP(pAd)
{
Channel = FirstChannel(pAd);
DBGPRINT(RT_DEBUG_WARN,("This channel is out of channel list, set as the first channel(%d) \n ", Channel));
}
#endif /* CONFIG_AP_SUPPORT */
#ifdef CONFIG_STA_SUPPORT
IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
success = FALSE;
DBGPRINT(RT_DEBUG_WARN,("This channel is out of channel list, nothing to do!\n "));
#endif /* CONFIG_STA_SUPPORT */
}
#ifdef CONFIG_AP_SUPPORT
IF_DEV_CONFIG_OPMODE_ON_AP(pAd)
{
if ((WMODE_CAP_5G(pAd->CommonCfg.PhyMode))
&& (pAd->CommonCfg.bIEEE80211H == TRUE))
{
for (i = 0; i < pAd->ChannelListNum; i++)
{
if (pAd->ChannelList[i].Channel == Channel)
{
if (pAd->ChannelList[i].RemainingTimeForUse > 0)
{
DBGPRINT(RT_DEBUG_ERROR, ("ERROR: previous detection of a radar on this channel(Channel=%d)\n", Channel));
success = FALSE;
break;
}
else
{
DBGPRINT(RT_DEBUG_INFO, ("RemainingTimeForUse %d ,Channel %d\n",
pAd->ChannelList[i].RemainingTimeForUse, Channel));
}
}
}
}
if (success == TRUE)
{
if ((pAd->CommonCfg.Channel > 14 )
&& (pAd->CommonCfg.bIEEE80211H == TRUE))
{
pAd->Dot11_H.org_ch = pAd->CommonCfg.Channel;
}
pAd->CommonCfg.Channel = Channel;
#ifdef DOT11_N_SUPPORT
N_ChannelCheck(pAd);
#endif /* DOT11_N_SUPPORT */
if ((pAd->CommonCfg.Channel > 14 )
&& (pAd->CommonCfg.bIEEE80211H == TRUE))
{
if (pAd->Dot11_H.RDMode == RD_SILENCE_MODE)
{
APStop(pAd);
APStartUp(pAd);
}
else
{
NotifyChSwAnnToPeerAPs(pAd, ZERO_MAC_ADDR, pAd->CurrentAddress, 1, pAd->CommonCfg.Channel);
pAd->Dot11_H.RDMode = RD_SWITCHING_MODE;
pAd->Dot11_H.CSCount = 0;
pAd->Dot11_H.new_channel = Channel;
}
}
else
{
APStop(pAd);
APStartUp(pAd);
}
}
}
#endif /* CONFIG_AP_SUPPORT */
if (success == TRUE) {
DBGPRINT(RT_DEBUG_TRACE, ("Set_Channel_Proc::(Channel=%d)\n",
pAd->CommonCfg.Channel));
#ifdef DFS_ATP_SUPPORT
pAd->CommonCfg.RadarDetect.atp_set_channel_ready = TRUE;
if ((pAd->CommonCfg.RadarDetect.atp_set_ht_bw
|| pAd->CommonCfg.RadarDetect.atp_set_vht_bw)
&& pAd->CommonCfg.RadarDetect.atp_set_channel_ready) {
printk ("BW and Channel is ready\n");
}
#endif /* DFS_ATP_SUPPORT */
}
#ifdef APCLI_AUTO_CONNECT_SUPPORT
pAd->ApCfg.ApCliAutoConnectChannelSwitching = FALSE;
#endif /* APCLI_AUTO_CONNECT_SUPPORT */
return success;
}
/*
==========================================================================
Description:
Set Short Slot Time Enable or Disable
Return:
TRUE if all parameters are OK, FALSE otherwise
==========================================================================
*/
INT Set_ShortSlot_Proc(
IN PRTMP_ADAPTER pAd,
IN PSTRING arg)
{
int retval;
retval = RT_CfgSetShortSlot(pAd, arg);
if (retval == TRUE)
DBGPRINT(RT_DEBUG_TRACE, ("Set_ShortSlot_Proc::(ShortSlot=%d)\n", pAd->CommonCfg.bUseShortSlotTime));
return retval;
}
/*
==========================================================================
Description:
Set Tx power
Return:
TRUE if all parameters are OK, FALSE otherwise
==========================================================================
*/
INT Set_TxPower_Proc(
IN PRTMP_ADAPTER pAd,
IN PSTRING arg)
{
LONG TxPower;
INT success = FALSE;
TxPower = simple_strtol(arg, 0, 10);
if (TxPower <= 100)
{
#ifdef CONFIG_AP_SUPPORT
IF_DEV_CONFIG_OPMODE_ON_AP(pAd)
pAd->CommonCfg.TxPowerPercentage = TxPower;
#endif /* CONFIG_AP_SUPPORT */
#ifdef CONFIG_STA_SUPPORT
IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
{
pAd->CommonCfg.TxPowerDefault = TxPower;
pAd->CommonCfg.TxPowerPercentage = pAd->CommonCfg.TxPowerDefault;
}
#endif /* CONFIG_STA_SUPPORT */
success = TRUE;
}
else
success = FALSE;
DBGPRINT(RT_DEBUG_TRACE, ("Set_TxPower_Proc::(TxPowerPercentage=%ld)\n", pAd->CommonCfg.TxPowerPercentage));
return success;
}
/*
==========================================================================
Description:
Set 11B/11G Protection
Return:
TRUE if all parameters are OK, FALSE otherwise
==========================================================================
*/
INT Set_BGProtection_Proc(
IN PRTMP_ADAPTER pAd,
IN PSTRING arg)
{
switch (simple_strtol(arg, 0, 10))
{
case 0: /*AUTO*/
pAd->CommonCfg.UseBGProtection = 0;
break;
case 1: /*Always On*/
pAd->CommonCfg.UseBGProtection = 1;
break;
case 2: /*Always OFF*/
pAd->CommonCfg.UseBGProtection = 2;
break;
default: /*Invalid argument */
return FALSE;
}
#ifdef CONFIG_AP_SUPPORT
IF_DEV_CONFIG_OPMODE_ON_AP(pAd)
APUpdateCapabilityAndErpIe(pAd);
#endif /* CONFIG_AP_SUPPORT */
DBGPRINT(RT_DEBUG_TRACE, ("Set_BGProtection_Proc::(BGProtection=%ld)\n", pAd->CommonCfg.UseBGProtection));
return TRUE;
}
/*
==========================================================================
Description:
Set TxPreamble
Return:
TRUE if all parameters are OK, FALSE otherwise
==========================================================================
*/
INT Set_TxPreamble_Proc(
IN PRTMP_ADAPTER pAd,
IN PSTRING arg)
{
RT_802_11_PREAMBLE Preamble;
Preamble = (RT_802_11_PREAMBLE)simple_strtol(arg, 0, 10);
#ifdef CONFIG_AP_SUPPORT
IF_DEV_CONFIG_OPMODE_ON_AP(pAd)
if (Preamble == Rt802_11PreambleAuto)
return FALSE;
#endif /* CONFIG_AP_SUPPORT */
switch (Preamble)
{
case Rt802_11PreambleShort:
pAd->CommonCfg.TxPreamble = Preamble;
#ifdef CONFIG_STA_SUPPORT
IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
MlmeSetTxPreamble(pAd, Rt802_11PreambleShort);
#endif /* CONFIG_STA_SUPPORT */
break;
case Rt802_11PreambleLong:
#ifdef CONFIG_STA_SUPPORT
case Rt802_11PreambleAuto:
/*
If user wants AUTO, initialize to LONG here, then change according to AP's
capability upon association
*/
#endif /* CONFIG_STA_SUPPORT */
pAd->CommonCfg.TxPreamble = Preamble;
#ifdef CONFIG_STA_SUPPORT
IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
MlmeSetTxPreamble(pAd, Rt802_11PreambleLong);
#endif /* CONFIG_STA_SUPPORT */
break;
default: /*Invalid argument */
return FALSE;
}
DBGPRINT(RT_DEBUG_TRACE, ("Set_TxPreamble_Proc::(TxPreamble=%ld)\n", pAd->CommonCfg.TxPreamble));
return TRUE;
}
/*
==========================================================================
Description:
Set RTS Threshold
Return:
TRUE if all parameters are OK, FALSE otherwise
==========================================================================
*/
INT Set_RTSThreshold_Proc(
IN PRTMP_ADAPTER pAd,
IN PSTRING arg)
{
NDIS_802_11_RTS_THRESHOLD RtsThresh;
RtsThresh = simple_strtol(arg, 0, 10);
if((RtsThresh > 0) && (RtsThresh <= MAX_RTS_THRESHOLD))
pAd->CommonCfg.RtsThreshold = (USHORT)RtsThresh;
#ifdef CONFIG_STA_SUPPORT
else if (RtsThresh == 0)
pAd->CommonCfg.RtsThreshold = MAX_RTS_THRESHOLD;
#endif /* CONFIG_STA_SUPPORT */
else
return FALSE; /*Invalid argument */
DBGPRINT(RT_DEBUG_TRACE, ("Set_RTSThreshold_Proc::(RTSThreshold=%d)\n", pAd->CommonCfg.RtsThreshold));
return TRUE;
}
/*
==========================================================================
Description:
Set Fragment Threshold
Return:
TRUE if all parameters are OK, FALSE otherwise
==========================================================================
*/
INT Set_FragThreshold_Proc(
IN PRTMP_ADAPTER pAd,
IN PSTRING arg)
{
NDIS_802_11_FRAGMENTATION_THRESHOLD FragThresh;
FragThresh = simple_strtol(arg, 0, 10);
if (FragThresh > MAX_FRAG_THRESHOLD || FragThresh < MIN_FRAG_THRESHOLD)
{
/*Illegal FragThresh so we set it to default*/
pAd->CommonCfg.FragmentThreshold = MAX_FRAG_THRESHOLD;
}
else if (FragThresh % 2 == 1)
{
/*
The length of each fragment shall always be an even number of octets,
except for the last fragment of an MSDU or MMPDU, which may be either
an even or an odd number of octets.
*/
pAd->CommonCfg.FragmentThreshold = (USHORT)(FragThresh - 1);
}
else
{
pAd->CommonCfg.FragmentThreshold = (USHORT)FragThresh;
}
#ifdef CONFIG_STA_SUPPORT
IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
{
if (pAd->CommonCfg.FragmentThreshold == MAX_FRAG_THRESHOLD)
pAd->CommonCfg.bUseZeroToDisableFragment = TRUE;
else
pAd->CommonCfg.bUseZeroToDisableFragment = FALSE;
}
#endif /* CONFIG_STA_SUPPORT */
DBGPRINT(RT_DEBUG_TRACE, ("Set_FragThreshold_Proc::(FragThreshold=%d)\n", pAd->CommonCfg.FragmentThreshold));
return TRUE;
}
/*
==========================================================================
Description:
Set TxBurst
Return:
TRUE if all parameters are OK, FALSE otherwise
==========================================================================
*/
INT Set_TxBurst_Proc(
IN PRTMP_ADAPTER pAd,
IN PSTRING arg)
{
LONG TxBurst;
TxBurst = simple_strtol(arg, 0, 10);
if (TxBurst == 1)
pAd->CommonCfg.bEnableTxBurst = TRUE;
else if (TxBurst == 0)
pAd->CommonCfg.bEnableTxBurst = FALSE;
else
return FALSE; /*Invalid argument */
DBGPRINT(RT_DEBUG_TRACE, ("Set_TxBurst_Proc::(TxBurst=%d)\n", pAd->CommonCfg.bEnableTxBurst));
return TRUE;
}
#ifdef AGGREGATION_SUPPORT
/*
==========================================================================
Description:
Set TxBurst
Return:
TRUE if all parameters are OK, FALSE otherwise
==========================================================================
*/
INT Set_PktAggregate_Proc(
IN PRTMP_ADAPTER pAd,
IN PSTRING arg)
{
LONG aggre;
aggre = simple_strtol(arg, 0, 10);
if (aggre == 1)
pAd->CommonCfg.bAggregationCapable = TRUE;
else if (aggre == 0)
pAd->CommonCfg.bAggregationCapable = FALSE;
else
return FALSE; /*Invalid argument */
#ifdef CONFIG_AP_SUPPORT
#ifdef PIGGYBACK_SUPPORT
IF_DEV_CONFIG_OPMODE_ON_AP(pAd)
{
pAd->CommonCfg.bPiggyBackCapable = pAd->CommonCfg.bAggregationCapable;
RTMPSetPiggyBack(pAd, pAd->CommonCfg.bPiggyBackCapable);
}
#endif /* PIGGYBACK_SUPPORT */
#endif /* CONFIG_AP_SUPPORT */
DBGPRINT(RT_DEBUG_TRACE, ("Set_PktAggregate_Proc::(AGGRE=%d)\n", pAd->CommonCfg.bAggregationCapable));
return TRUE;
}
#endif
#ifdef INF_PPA_SUPPORT
INT Set_INF_AMAZON_SE_PPA_Proc(
IN PRTMP_ADAPTER pAd,
IN PUCHAR arg)
{
UINT status;
UCHAR aggre;
UINT32 g_if_id;
NDIS_STATUS re_val;
aggre = simple_strtol(arg, 0, 10);
if (ppa_hook_directpath_register_dev_fn == NULL)
{
DBGPRINT(RT_DEBUG_TRACE, ("%s::There is no PPA module\n", __FUNCTION__));
return FALSE;
}
if (aggre == 1)
{
if (pAd->PPAEnable == TRUE)
{
DBGPRINT(RT_DEBUG_TRACE, ("PPA already enabled\n"));
}
else
{
if (pAd->pDirectpathCb == NULL)
{
DBGPRINT(RT_DEBUG_TRACE, ("Allocate memory for pDirectpathCb\n"));
re_val = os_alloc_mem(NULL, (UCHAR **)&(pAd->pDirectpathCb), sizeof(PPA_DIRECTPATH_CB));
if (re_val != NDIS_STATUS_SUCCESS)
return FALSE;
}
/* Register callback */
pAd->pDirectpathCb->rx_fn = ifx_ra_start_xmit;
pAd->pDirectpathCb->stop_tx_fn = NULL;
pAd->pDirectpathCb->start_tx_fn = NULL;
status = ppa_hook_directpath_register_dev_fn(
&g_if_id, pAd->net_dev, pAd->pDirectpathCb, PPA_F_DIRECTPATH_REGISTER|PPA_F_DIRECTPATH_ETH_IF);
if (status == IFX_SUCCESS)
{
pAd->g_if_id = g_if_id;
pAd->PPAEnable = TRUE;
DBGPRINT(RT_DEBUG_TRACE, ("Register PPA success::ret=%d, id=%d\n", status, pAd->g_if_id));
}
else
DBGPRINT(RT_DEBUG_TRACE, ("Register PPA fail::ret=%d\n", status));
}
}
else if (aggre == 0)
{
if (pAd->PPAEnable == FALSE)
{
DBGPRINT(RT_DEBUG_TRACE, ("PPA already disabled\n"));
}
else
{
g_if_id = pAd->g_if_id;
status = ppa_hook_directpath_register_dev_fn(&g_if_id, pAd->net_dev, NULL, 0 /*PPA_F_DIRECTPATH_REGISTER*/);
if (status == IFX_SUCCESS)
{
pAd->g_if_id = 0;
pAd->PPAEnable = FALSE;
DBGPRINT(RT_DEBUG_TRACE, ("Unregister PPA success::ret=%d, if_id=%d\n", status, pAd->g_if_id));
}
else
DBGPRINT(RT_DEBUG_TRACE, ("Unregister PPA fail::ret=%d\n", status));
}
}
else
{
DBGPRINT(RT_DEBUG_TRACE, ("%s::Invalid argument=%d\n", __FUNCTION__, aggre));
return FALSE;
}
return TRUE;
}
#endif /* INF_PPA_SUPPORT */
/*
==========================================================================
Description:
Set IEEE80211H.
This parameter is 1 when needs radar detection, otherwise 0
Return:
TRUE if all parameters are OK, FALSE otherwise
==========================================================================
*/
INT Set_IEEE80211H_Proc(
IN PRTMP_ADAPTER pAd,
IN PSTRING arg)
{
LONG ieee80211h;
ieee80211h = simple_strtol(arg, 0, 10);
if (ieee80211h == 1)
pAd->CommonCfg.bIEEE80211H = TRUE;
else if (ieee80211h == 0)
pAd->CommonCfg.bIEEE80211H = FALSE;
else
return FALSE; /*Invalid argument */
DBGPRINT(RT_DEBUG_TRACE, ("Set_IEEE80211H_Proc::(IEEE80211H=%d)\n", pAd->CommonCfg.bIEEE80211H));
return TRUE;
}
#ifdef EXT_BUILD_CHANNEL_LIST
/*
==========================================================================
Description:
Set Country Code.
Return:
TRUE if all parameters are OK, FALSE otherwise
==========================================================================
*/
INT Set_ExtCountryCode_Proc(
IN PRTMP_ADAPTER pAd,
IN PSTRING arg)
{
if (RTMP_DRIVER_IOCTL_SANITY_CHECK(pAd, NULL) == NDIS_STATUS_SUCCESS)
{
DBGPRINT(RT_DEBUG_TRACE, ("%s can only be used when interface is down.\n", __FUNCTION__));
return TRUE;
}
if(strlen(arg) == 2)
{
NdisMoveMemory(pAd->CommonCfg.CountryCode, arg, 2);
pAd->CommonCfg.bCountryFlag = TRUE;
}
else
{
NdisZeroMemory(pAd->CommonCfg.CountryCode, 3);
pAd->CommonCfg.bCountryFlag = FALSE;
}
{
UCHAR CountryCode[3] = {0};
NdisMoveMemory(CountryCode, pAd->CommonCfg.CountryCode, 2);
DBGPRINT(RT_DEBUG_TRACE, ("Set_CountryCode_Proc::(bCountryFlag=%d, CountryCode=%s)\n",
pAd->CommonCfg.bCountryFlag,
CountryCode));
}
return TRUE;
}
/*
==========================================================================
Description:
Set Ext DFS Type
Return:
TRUE if all parameters are OK, FALSE otherwise
==========================================================================
*/
INT Set_ExtDfsType_Proc(
IN PRTMP_ADAPTER pAd,
IN PSTRING arg)
{
UCHAR *pDfsType = &pAd->CommonCfg.DfsType;
if (RTMP_DRIVER_IOCTL_SANITY_CHECK(pAd, NULL) == NDIS_STATUS_SUCCESS)
{
DBGPRINT(RT_DEBUG_TRACE, ("%s can only be used when interface is down.\n", __FUNCTION__));
return TRUE;
}
if (!strcmp(arg, "CE"))
*pDfsType = CE;
else if (!strcmp(arg, "FCC"))
*pDfsType = FCC;
else if (!strcmp(arg, "JAP"))
*pDfsType = JAP;
else
DBGPRINT(RT_DEBUG_TRACE, ("Unsupported DFS type:%s (Legal types are: CE, FCC, JAP)\n", arg));
return TRUE;
}
/*
==========================================================================
Description:
Add new channel list
Return:
TRUE if all parameters are OK, FALSE otherwise
==========================================================================
*/
INT Set_ChannelListAdd_Proc(
IN PRTMP_ADAPTER pAd,
IN PSTRING arg)
{
CH_DESP inChDesp;
PCH_REGION pChRegion = NULL;
if (RTMP_DRIVER_IOCTL_SANITY_CHECK(pAd, NULL) == NDIS_STATUS_SUCCESS)
{
DBGPRINT(RT_DEBUG_TRACE, ("%s can only be used when interface is down.\n", __FUNCTION__));
return TRUE;
}
/* Get Channel Region (CountryCode)*/
{
INT loop = 0;
while (strcmp((PSTRING) ChRegion[loop].CountReg, "") != 0)
{
if (strncmp((PSTRING) ChRegion[loop].CountReg, pAd->CommonCfg.CountryCode, 2) == 0)
{
pChRegion = &ChRegion[loop];
break;
}
loop++;
}
if (pChRegion == NULL)
{
DBGPRINT(RT_DEBUG_TRACE, ("CountryCode is not configured or not valid\n"));
return TRUE;
}
}