-
Notifications
You must be signed in to change notification settings - Fork 39
/
gl_init.c
3524 lines (3115 loc) · 112 KB
/
gl_init.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
/*
* Copyright (C) 2011-2014 MediaTek Inc.
*
* This program is free software: you can redistribute it and/or modify it under the terms of the
* GNU General Public License version 2 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this program.
* If not, see <http://www.gnu.org/licenses/>.
*/
/*
** Id: //Department/DaVinci/BRANCHES/MT6620_WIFI_DRIVER_V2_3/os/linux/gl_init.c#7
*/
/*! \file gl_init.c
\brief Main routines of Linux driver
This file contains the main routines of Linux driver for MediaTek Inc. 802.11
Wireless LAN Adapters.
*/
/*
** Log: gl_init.c
**
** 09 03 2013 cp.wu
** add path for reassociation
*
* 07 17 2012 yuche.tsai
* NULL
* Fix compile error.
*
* 07 17 2012 yuche.tsai
* NULL
* Fix compile error for JB.
*
* 07 17 2012 yuche.tsai
* NULL
* Let netdev bring up.
*
* 07 17 2012 yuche.tsai
* NULL
* Compile no error before trial run.
*
* 06 13 2012 yuche.tsai
* NULL
* Update maintrunk driver.
* Add support for driver compose assoc request frame.
*
* 05 25 2012 yuche.tsai
* NULL
* Fix reset KE issue.
*
* 05 11 2012 cp.wu
* [WCXRP00001237] [MT6620 Wi-Fi][Driver] Show MAC address and MAC address source for ACS's convenience
* show MAC address & source while initiliazation
*
* 03 02 2012 terry.wu
* NULL
* EXPORT_SYMBOL(rsnParseCheckForWFAInfoElem);.
*
* 03 02 2012 terry.wu
* NULL
* Snc CFG80211 modification for ICS migration from branch 2.2.
*
* 03 02 2012 terry.wu
* NULL
* Sync CFG80211 modification from branch 2,2.
*
* 03 02 2012 terry.wu
* NULL
* Enable CFG80211 Support.
*
* 12 22 2011 george.huang
* [WCXRP00000905] [MT6628 Wi-Fi][FW] Code refinement for ROM/ RAM module dependency
* using global variable instead of stack for setting wlanoidSetNetworkAddress(), due to buffer may be released before
* TX thread handling
*
* 11 18 2011 yuche.tsai
* NULL
* CONFIG P2P support RSSI query, default turned off.
*
* 11 14 2011 yuche.tsai
* [WCXRP00001107] [Volunteer Patch][Driver] Large Network Type index assert in FW issue.
* Fix large network type index assert in FW issue.
*
* 11 14 2011 cm.chang
* NULL
* Fix compiling warning
*
* 11 11 2011 yuche.tsai
* NULL
* Fix work thread cancel issue.
*
* 11 10 2011 cp.wu
* [WCXRP00001098] [MT6620 Wi-Fi][Driver] Replace printk by DBG LOG macros in linux porting layer
* 1. eliminaite direct calls to printk in porting layer.
* 2. replaced by DBGLOG, which would be XLOG on ALPS platforms.
*
* 10 06 2011 eddie.chen
* [WCXRP00001027] [MT6628 Wi-Fi][Firmware/Driver] Tx fragmentation
* Add rlmDomainGetChnlList symbol.
*
* 09 22 2011 cm.chang
* NULL
* Safer writng stype to avoid unitialized regitry structure
*
* 09 21 2011 cm.chang
* [WCXRP00000969] [MT6620 Wi-Fi][Driver][FW] Channel list for 5G band based on country code
* Avoid possible structure alignment problem
*
* 09 20 2011 chinglan.wang
* [WCXRP00000989] [WiFi Direct] [Driver] Add a new io control API to start the formation for the sigma test.
* .
*
* 09 08 2011 cm.chang
* [WCXRP00000969] [MT6620 Wi-Fi][Driver][FW] Channel list for 5G band based on country code
* Use new fields ucChannelListMap and ucChannelListIndex in NVRAM
*
* 08 31 2011 cm.chang
* [WCXRP00000969] [MT6620 Wi-Fi][Driver][FW] Channel list for 5G band based on country code
* .
*
* 08 11 2011 cp.wu
* [WCXRP00000830] [MT6620 Wi-Fi][Firmware] Use MDRDY counter to detect empty channel for shortening scan time
* expose scnQuerySparseChannel() for P2P-FSM.
*
* 08 11 2011 cp.wu
* [WCXRP00000830] [MT6620 Wi-Fi][Firmware] Use MDRDY counter to detect empty channel for shortening scan time
* sparse channel detection:
* driver: collect sparse channel information with scan-done event
*
* 08 02 2011 yuche.tsai
* [WCXRP00000896] [Volunteer Patch][WiFi Direct][Driver] GO with multiple client, TX deauth to a disconnecting
* device issue.
* Fix GO send deauth frame issue.
*
* 07 07 2011 wh.su
* [WCXRP00000839] [MT6620 Wi-Fi][Driver] Add the dumpMemory8 and dumpMemory32 EXPORT_SYMBOL
* Add the dumpMemory8 symbol export for debug mode.
*
* 07 06 2011 terry.wu
* [WCXRP00000735] [MT6620 Wi-Fi][BoW][FW/Driver] Protect BoW connection establishment
* Improve BoW connection establishment speed.
*
* 07 05 2011 yuche.tsai
* [WCXRP00000821] [Volunteer Patch][WiFi Direct][Driver] WiFi Direct Connection Speed Issue
* Export one symbol for enhancement.
*
* 06 13 2011 eddie.chen
* [WCXRP00000779] [MT6620 Wi-Fi][DRV] Add tx rx statistics in linux and use netif_rx_ni
* Add tx rx statistics and netif_rx_ni.
*
* 05 27 2011 cp.wu
* [WCXRP00000749] [MT6620 Wi-Fi][Driver] Add band edge tx power control to Wi-Fi NVRAM
* invoke CMD_ID_SET_EDGE_TXPWR_LIMIT when there is valid data exist in NVRAM content.
*
* 05 18 2011 cp.wu
* [WCXRP00000734] [MT6620 Wi-Fi][Driver] Pass PHY_PARAM in NVRAM to firmware domain
* pass PHY_PARAM in NVRAM from driver to firmware.
*
* 05 09 2011 jeffrey.chang
* [WCXRP00000710] [MT6620 Wi-Fi] Support pattern filter update function on IP address change
* support ARP filter through kernel notifier
*
* 05 03 2011 chinghwa.yu
* [WCXRP00000065] Update BoW design and settings
* Use kalMemAlloc to allocate event buffer for kalIndicateBOWEvent.
*
* 04 27 2011 george.huang
* [WCXRP00000684] [MT6620 Wi-Fi][Driver] Support P2P setting ARP filter
* Support P2P ARP filter setting on early suspend/ late resume
*
* 04 18 2011 terry.wu
* [WCXRP00000660] [MT6620 Wi-Fi][Driver] Remove flag CFG_WIFI_DIRECT_MOVED
* Remove flag CFG_WIFI_DIRECT_MOVED.
*
* 04 15 2011 chinghwa.yu
* [WCXRP00000065] Update BoW design and settings
* Add BOW short range mode.
*
* 04 14 2011 yuche.tsai
* [WCXRP00000646] [Volunteer Patch][MT6620][FW/Driver] Sigma Test Modification for some test case.
* Modify some driver connection flow or behavior to pass Sigma test more easier..
*
* 04 12 2011 cm.chang
* [WCXRP00000634] [MT6620 Wi-Fi][Driver][FW] 2nd BSS will not support 40MHz bandwidth for concurrency
* .
*
* 04 11 2011 george.huang
* [WCXRP00000621] [MT6620 Wi-Fi][Driver] Support P2P supplicant to set power mode
* export wlan functions to p2p
*
* 04 08 2011 pat.lu
* [WCXRP00000623] [MT6620 Wi-Fi][Driver] use ARCH define to distinguish PC Linux driver
* Use CONFIG_X86 instead of PC_LINUX_DRIVER_USE option to have proper compile setting for PC Linux driver
*
* 04 08 2011 cp.wu
* [WCXRP00000540] [MT5931][Driver] Add eHPI8/eHPI16 support to Linux Glue Layer
* glBusFreeIrq() should use the same pvCookie as glBusSetIrq() or request_irq()/free_irq() won't work as a pair.
*
* 04 08 2011 eddie.chen
* [WCXRP00000617] [MT6620 Wi-Fi][DRV/FW] Fix for sigma
* Fix for sigma
*
* 04 06 2011 cp.wu
* [WCXRP00000540] [MT5931][Driver] Add eHPI8/eHPI16 support to Linux Glue Layer
* 1. do not check for pvData inside wlanNetCreate() due to it is NULL for eHPI port
* 2. update perm_addr as well for MAC address
* 3. not calling check_mem_region() anymore for eHPI
* 4. correct MSC_CS macro for 0-based notation
*
* 03 29 2011 cp.wu
* [WCXRP00000598] [MT6620 Wi-Fi][Driver] Implementation of interface for communicating with user space process for
* RESET_START and RESET_END events
* fix typo.
*
* 03 29 2011 cp.wu
* [WCXRP00000598] [MT6620 Wi-Fi][Driver] Implementation of interface for communicating with user space process for
* RESET_START and RESET_END events
* implement kernel-to-userspace communication via generic netlink socket for whole-chip resetting mechanism
*
* 03 23 2011 cp.wu
* [WCXRP00000540] [MT5931][Driver] Add eHPI8/eHPI16 support to Linux Glue Layer
* apply multi-queue operation only for linux kernel > 2.6.26
*
* 03 22 2011 pat.lu
* [WCXRP00000592] [MT6620 Wi-Fi][Driver] Support PC Linux Environment Driver Build
* Add a compiler option "PC_LINUX_DRIVER_USE" for building driver in PC Linux environment.
*
* 03 21 2011 cp.wu
* [WCXRP00000540] [MT5931][Driver] Add eHPI8/eHPI16 support to Linux Glue Layer
* portability for compatible with linux 2.6.12.
*
* 03 21 2011 cp.wu
* [WCXRP00000540] [MT5931][Driver] Add eHPI8/eHPI16 support to Linux Glue Layer
* improve portability for awareness of early version of linux kernel and wireless extension.
*
* 03 21 2011 cp.wu
* [WCXRP00000540] [MT5931][Driver] Add eHPI8/eHPI16 support to Linux Glue Layer
* portability improvement
*
* 03 18 2011 jeffrey.chang
* [WCXRP00000512] [MT6620 Wi-Fi][Driver] modify the net device relative functions to support the H/W multiple queue
* remove early suspend functions
*
* 03 17 2011 cp.wu
* [WCXRP00000562] [MT6620 Wi-Fi][Driver] I/O buffer pre-allocation to avoid physically continuous memory shortage
* after system running for a long period
* reverse order to prevent probing racing.
*
* 03 16 2011 cp.wu
* [WCXRP00000562] [MT6620 Wi-Fi][Driver] I/O buffer pre-allocation to avoid physically continuous memory shortage
* after system running for a long period
* 1. pre-allocate physical continuous buffer while module is being loaded
* 2. use pre-allocated physical continuous buffer for TX/RX DMA transfer
*
* The windows part remained the same as before, but added similar APIs to hide the difference.
*
* 03 15 2011 jeffrey.chang
* [WCXRP00000558] [MT6620 Wi-Fi][MT6620 Wi-Fi][Driver] refine the queue selection algorithm for WMM
* refine the queue_select function
*
* 03 10 2011 cp.wu
* [WCXRP00000532] [MT6620 Wi-Fi][Driver] Migrate NVRAM configuration procedures from MT6620 E2 to MT6620 E3
* deprecate configuration used by MT6620 E2
*
* 03 10 2011 terry.wu
* [WCXRP00000505] [MT6620 Wi-Fi][Driver/FW] WiFi Direct Integration
* Remove unnecessary assert and message.
*
* 03 08 2011 terry.wu
* [WCXRP00000505] [MT6620 Wi-Fi][Driver/FW] WiFi Direct Integration
* Export nicQmUpdateWmmParms.
*
* 03 03 2011 jeffrey.chang
* [WCXRP00000512] [MT6620 Wi-Fi][Driver] modify the net device relative functions to support the H/W multiple queue
* support concurrent network
*
* 03 03 2011 jeffrey.chang
* [WCXRP00000512] [MT6620 Wi-Fi][Driver] modify the net device relative functions to support the H/W multiple queue
* modify net device relative functions to support multiple H/W queues
*
* 02 24 2011 george.huang
* [WCXRP00000495] [MT6620 Wi-Fi][FW] Support pattern filter for unwanted ARP frames
* Support ARP filter during suspended
*
* 02 21 2011 cp.wu
* [WCXRP00000482] [MT6620 Wi-Fi][Driver] Simplify logic for checking NVRAM existence in driver domain
* simplify logic for checking NVRAM existence only once.
*
* 02 17 2011 terry.wu
* [WCXRP00000459] [MT6620 Wi-Fi][Driver] Fix deference null pointer problem in wlanRemove
* Fix deference a null pointer problem in wlanRemove.
*
* 02 16 2011 jeffrey.chang
* NULL
* fix compilig error
*
* 02 16 2011 jeffrey.chang
* NULL
* Add query ipv4 and ipv6 address during early suspend and late resume
*
* 02 15 2011 jeffrey.chang
* NULL
* to support early suspend in android
*
* 02 11 2011 yuche.tsai
* [WCXRP00000431] [Volunteer Patch][MT6620][Driver] Add MLME support for deauthentication under AP(Hot-Spot) mode.
* Add one more export symbol.
*
* 02 10 2011 yuche.tsai
* [WCXRP00000431] [Volunteer Patch][MT6620][Driver] Add MLME support for deauthentication under AP(Hot-Spot) mode.
* Add RX deauthentication & disassociation process under Hot-Spot mode.
*
* 02 09 2011 terry.wu
* [WCXRP00000383] [MT6620 Wi-Fi][Driver] Separate WiFi and P2P driver into two modules
* Halt p2p module init and exit until TxThread finished p2p register and unregister.
*
* 02 08 2011 george.huang
* [WCXRP00000422] [MT6620 Wi-Fi][Driver] support query power mode OID handler
* Support querying power mode OID.
*
* 02 08 2011 yuche.tsai
* [WCXRP00000421] [Volunteer Patch][MT6620][Driver] Fix incorrect SSID length Issue
* Export Deactivation Network.
*
* 02 01 2011 jeffrey.chang
* [WCXRP00000414] KAL Timer is not unregistered when driver not loaded
* Unregister the KAL timer during driver unloading
*
* 01 26 2011 cm.chang
* [WCXRP00000395] [MT6620 Wi-Fi][Driver][FW] Search STA_REC with additional net type index argument
* Allocate system RAM if fixed message or mgmt buffer is not available
*
* 01 19 2011 cp.wu
* [WCXRP00000371] [MT6620 Wi-Fi][Driver] make linux glue layer portable for Android 2.3.1 with Linux 2.6.35.7
* add compile option to check linux version 2.6.35 for different usage of system API to improve portability
*
* 01 12 2011 cp.wu
* [WCXRP00000357] [MT6620 Wi-Fi][Driver][Bluetooth over Wi-Fi] add another net device interface for BT AMP
* implementation of separate BT_OVER_WIFI data path.
*
* 01 10 2011 cp.wu
* [WCXRP00000349] [MT6620 Wi-Fi][Driver] make kalIoctl() of linux port as a thread safe API to avoid potential issues
* due to multiple access
* use mutex to protect kalIoctl() for thread safe.
*
* 01 04 2011 cp.wu
* [WCXRP00000338] [MT6620 Wi-Fi][Driver] Separate kalMemAlloc into kmalloc and vmalloc implementations to ease
* physically continuous memory demands
* separate kalMemAlloc() into virtually-continuous and physically-continuous type to ease slab system pressure
*
* 12 15 2010 cp.wu
* [WCXRP00000265] [MT6620 Wi-Fi][Driver] Remove set_mac_address routine from legacy Wi-Fi Android driver
* remove set MAC address. MAC address is always loaded from NVRAM instead.
*
* 12 10 2010 kevin.huang
* [WCXRP00000128] [MT6620 Wi-Fi][Driver] Add proc support to Android Driver for debug and driver status check
* Add Linux Proc Support
*
* 11 01 2010 yarco.yang
* [WCXRP00000149] [MT6620 WI-Fi][Driver]Fine tune performance on MT6516 platform
* Add GPIO debug function
*
* 11 01 2010 cp.wu
* [WCXRP00000056] [MT6620 Wi-Fi][Driver] NVRAM implementation with Version Check[WCXRP00000150] [MT6620 Wi-Fi][Driver]
* Add implementation for querying current TX rate from firmware auto rate module
* 1) Query link speed (TX rate) from firmware directly with buffering mechanism to reduce overhead
* 2) Remove CNM CH-RECOVER event handling
* 3) cfg read/write API renamed with kal prefix for unified naming rules.
*
* 10 26 2010 cp.wu
* [WCXRP00000056] [MT6620 Wi-Fi][Driver] NVRAM implementation with Version Check[WCXRP00000137] [MT6620 Wi-Fi] [FW]
* Support NIC capability query command
* 1) update NVRAM content template to ver 1.02
* 2) add compile option for querying NIC capability (default: off)
* 3) modify AIS 5GHz support to run-time option, which could be turned on by registry or NVRAM setting
* 4) correct auto-rate compiler error under linux (treat warning as error)
* 5) simplify usage of NVRAM and REG_INFO_T
* 6) add version checking between driver and firmware
*
* 10 21 2010 chinghwa.yu
* [WCXRP00000065] Update BoW design and settings
* .
*
* 10 19 2010 jeffrey.chang
* [WCXRP00000120] [MT6620 Wi-Fi][Driver] Refine linux kernel module to the license of MTK propietary and enable MTK
* HIF by default
* Refine linux kernel module to the license of MTK and enable MTK HIF
*
* 10 18 2010 jeffrey.chang
* [WCXRP00000106] [MT6620 Wi-Fi][Driver] Enable setting multicast callback in Android
* .
*
* 10 18 2010 cp.wu
* [WCXRP00000056] [MT6620 Wi-Fi][Driver] NVRAM implementation with Version Check[WCXRP00000086] [MT6620 Wi-Fi][Driver]
* The mac address is all zero at android
* complete implementation of Android NVRAM access
*
* 09 27 2010 chinghwa.yu
* [WCXRP00000063] Update BCM CoEx design and settings[WCXRP00000065] Update BoW design and settings
* Update BCM/BoW design and settings.
*
* 09 23 2010 cp.wu
* [WCXRP00000051] [MT6620 Wi-Fi][Driver] WHQL test fail in MAC address changed item
* use firmware reported mac address right after wlanAdapterStart() as permanent address
*
* 09 21 2010 kevin.huang
* [WCXRP00000052] [MT6620 Wi-Fi][Driver] Eliminate Linux Compile Warning
* Eliminate Linux Compile Warning
*
* 09 03 2010 kevin.huang
* NULL
* Refine #include sequence and solve recursive/nested #include issue
*
* 09 01 2010 wh.su
* NULL
* adding the wapi support for integration test.
*
* 08 18 2010 yarco.yang
* NULL
* 1. Fixed HW checksum offload function not work under Linux issue.
* 2. Add debug message.
*
* 08 16 2010 yarco.yang
* NULL
* Support Linux x86
*
* 08 02 2010 jeffrey.chang
* NULL
* 1) modify tx service thread to avoid busy looping
* 2) add spin lock declartion for linux build
*
* 07 29 2010 jeffrey.chang
* NULL
* fix memory leak for module unloading
*
* 07 28 2010 jeffrey.chang
* NULL
* 1) remove unused spinlocks
* 2) enable encyption ioctls
* 3) fix scan ioctl which may cause supplicant to hang
*
* 07 23 2010 jeffrey.chang
*
* bug fix: allocate regInfo when disabling firmware download
*
* 07 23 2010 jeffrey.chang
*
* use glue layer api to decrease or increase counter atomically
*
* 07 22 2010 jeffrey.chang
*
* add new spinlock
*
* 07 19 2010 jeffrey.chang
*
* modify cmd/data path for new design
*
* 07 08 2010 cp.wu
*
* [WPD00003833] [MT6620 and MT5931] Driver migration - move to new repository.
*
* 06 06 2010 kevin.huang
* [WPD00003832][MT6620 5931] Create driver base
* [MT6620 5931] Create driver base
*
* 05 26 2010 jeffrey.chang
* [WPD00003826]Initial import for Linux port
* 1) Modify set mac address code
* 2) remove power management macro
*
* 05 10 2010 cp.wu
* [WPD00003831][MT6620 Wi-Fi] Add framework for Wi-Fi Direct support
* implement basic wi-fi direct framework
*
* 05 07 2010 jeffrey.chang
* [WPD00003826]Initial import for Linux port
* prevent supplicant accessing driver during resume
*
* 05 07 2010 cp.wu
* [WPD00003831][MT6620 Wi-Fi] Add framework for Wi-Fi Direct support
* add basic framework for implementating P2P driver hook.
*
* 04 27 2010 jeffrey.chang
* [WPD00003826]Initial import for Linux port
* 1) fix firmware download bug
* 2) remove query statistics for acelerating firmware download
*
* 04 27 2010 jeffrey.chang
* [WPD00003826]Initial import for Linux port
* follow Linux's firmware framework, and remove unused kal API
*
* 04 21 2010 jeffrey.chang
* [WPD00003826]Initial import for Linux port
* add for private ioctl support
*
* 04 19 2010 jeffrey.chang
* [WPD00003826]Initial import for Linux port
* Query statistics from firmware
*
* 04 19 2010 jeffrey.chang
* [WPD00003826]Initial import for Linux port
* modify tcp/ip checksum offload flags
*
* 04 16 2010 jeffrey.chang
* [WPD00003826]Initial import for Linux port
* fix tcp/ip checksum offload bug
*
* 04 13 2010 cp.wu
* [WPD00003823][MT6620 Wi-Fi] Add Bluetooth-over-Wi-Fi support
* add framework for BT-over-Wi-Fi support.
* * * * * * * * * * * * * * * * * 1) prPendingCmdInfo is replaced by queue for multiple handler
* * * * * * * * * * * * * * * * * capability
* * * * * * * * * * * * * * * * * 2) command sequence number is now increased atomically
* * * * * * * * * * * * * * * * * 3) private data could be hold and taken use for other purpose
*
* 04 09 2010 jeffrey.chang
* [WPD00003826]Initial import for Linux port
* fix spinlock usage
*
* 04 07 2010 jeffrey.chang
* [WPD00003826]Initial import for Linux port
* Set MAC address from firmware
*
* 04 07 2010 cp.wu
* [WPD00001943]Create WiFi test driver framework on WinXP
* rWlanInfo should be placed at adapter rather than glue due to most operations
* * * * * * are done in adapter layer.
*
* 04 07 2010 jeffrey.chang
* [WPD00003826]Initial import for Linux port
* (1)improve none-glue code portability
* * (2) disable set Multicast address during atomic context
*
* 04 06 2010 jeffrey.chang
* [WPD00003826]Initial import for Linux port
* adding debug module
*
* 03 31 2010 wh.su
* [WPD00003816][MT6620 Wi-Fi] Adding the security support
* modify the wapi related code for new driver's design.
*
* 03 30 2010 jeffrey.chang
* [WPD00003826]Initial import for Linux port
* emulate NDIS Pending OID facility
*
* 03 26 2010 jeffrey.chang
* [WPD00003826]Initial import for Linux port
* fix f/w download start and load address by using config.h
*
* 03 26 2010 jeffrey.chang
* [WPD00003826]Initial import for Linux port
* [WPD00003826] Initial import for Linux port
* adding firmware download support
*
* 03 24 2010 jeffrey.chang
* [WPD00003826]Initial import for Linux port
* initial import for Linux port
** \main\maintrunk.MT5921\52 2009-10-27 22:49:59 GMT mtk01090
** Fix compile error for Linux EHPI driver
** \main\maintrunk.MT5921\51 2009-10-20 17:38:22 GMT mtk01090
** Refine driver unloading and clean up procedure. Block requests, stop main thread and clean up queued requests,
** and then stop hw.
** \main\maintrunk.MT5921\50 2009-10-08 10:33:11 GMT mtk01090
** Avoid accessing private data of net_device directly. Replace with netdev_priv(). Add more checking for input
** parameters and pointers.
** \main\maintrunk.MT5921\49 2009-09-28 20:19:05 GMT mtk01090
** Add private ioctl to carry OID structures. Restructure public/private ioctl interfaces to Linux kernel.
** \main\maintrunk.MT5921\48 2009-09-03 13:58:46 GMT mtk01088
** remove non-used code
** \main\maintrunk.MT5921\47 2009-09-03 11:40:25 GMT mtk01088
** adding the module parameter for wapi
** \main\maintrunk.MT5921\46 2009-08-18 22:56:41 GMT mtk01090
** Add Linux SDIO (with mmc core) support.
** Add Linux 2.6.21, 2.6.25, 2.6.26.
** Fix compile warning in Linux.
** \main\maintrunk.MT5921\45 2009-07-06 20:53:00 GMT mtk01088
** adding the code to check the wapi 1x frame
** \main\maintrunk.MT5921\44 2009-06-23 23:18:55 GMT mtk01090
** Add build option BUILD_USE_EEPROM and compile option CFG_SUPPORT_EXT_CONFIG for NVRAM support
** \main\maintrunk.MT5921\43 2009-02-16 23:46:51 GMT mtk01461
** Revise the order of increasing u4TxPendingFrameNum because of CFG_TX_RET_TX_CTRL_EARLY
** \main\maintrunk.MT5921\42 2009-01-22 13:11:59 GMT mtk01088
** set the tid and 1x value at same packet reserved field
** \main\maintrunk.MT5921\41 2008-10-20 22:43:53 GMT mtk01104
** Fix wrong variable name "prDev" in wlanStop()
** \main\maintrunk.MT5921\40 2008-10-16 15:37:10 GMT mtk01461
** add handle WLAN_STATUS_SUCCESS in wlanHardStartXmit() for CFG_TX_RET_TX_CTRL_EARLY
** \main\maintrunk.MT5921\39 2008-09-25 15:56:21 GMT mtk01461
** Update driver for Code review
** \main\maintrunk.MT5921\38 2008-09-05 17:25:07 GMT mtk01461
** Update Driver for Code Review
** \main\maintrunk.MT5921\37 2008-09-02 10:57:06 GMT mtk01461
** Update driver for code review
** \main\maintrunk.MT5921\36 2008-08-05 01:53:28 GMT mtk01461
** Add support for linux statistics
** \main\maintrunk.MT5921\35 2008-08-04 16:52:58 GMT mtk01461
** Fix ASSERT if removing module in BG_SSID_SCAN state
** \main\maintrunk.MT5921\34 2008-06-13 22:52:24 GMT mtk01461
** Revise status code handling in wlanHardStartXmit() for WLAN_STATUS_SUCCESS
** \main\maintrunk.MT5921\33 2008-05-30 18:56:53 GMT mtk01461
** Not use wlanoidSetCurrentAddrForLinux()
** \main\maintrunk.MT5921\32 2008-05-30 14:39:40 GMT mtk01461
** Remove WMM Assoc Flag
** \main\maintrunk.MT5921\31 2008-05-23 10:26:40 GMT mtk01084
** modify wlanISR interface
** \main\maintrunk.MT5921\30 2008-05-03 18:52:36 GMT mtk01461
** Fix Unset Broadcast filter when setMulticast
** \main\maintrunk.MT5921\29 2008-05-03 15:17:26 GMT mtk01461
** Move Query Media Status to GLUE
** \main\maintrunk.MT5921\28 2008-04-24 22:48:21 GMT mtk01461
** Revise set multicast function by using windows oid style for LP own back
** \main\maintrunk.MT5921\27 2008-04-24 12:00:08 GMT mtk01461
** Fix multicast setting in Linux and add comment
** \main\maintrunk.MT5921\26 2008-03-28 10:40:22 GMT mtk01461
** Fix set mac address func in Linux
** \main\maintrunk.MT5921\25 2008-03-26 15:37:26 GMT mtk01461
** Add set MAC Address
** \main\maintrunk.MT5921\24 2008-03-26 14:24:53 GMT mtk01461
** For Linux, set net_device has feature with checksum offload by default
** \main\maintrunk.MT5921\23 2008-03-11 14:50:52 GMT mtk01461
** Fix typo
** \main\maintrunk.MT5921\22 2008-02-29 15:35:20 GMT mtk01088
** add 1x decide code for sw port control
** \main\maintrunk.MT5921\21 2008-02-21 15:01:54 GMT mtk01461
** Rearrange the set off place of GLUE spin lock in HardStartXmit
** \main\maintrunk.MT5921\20 2008-02-12 23:26:50 GMT mtk01461
** Add debug option - Packet Order for Linux and add debug level - Event
** \main\maintrunk.MT5921\19 2007-12-11 00:11:12 GMT mtk01461
** Fix SPIN_LOCK protection
** \main\maintrunk.MT5921\18 2007-11-30 17:02:25 GMT mtk01425
** 1. Set Rx multicast packets mode before setting the address list
** \main\maintrunk.MT5921\17 2007-11-26 19:44:24 GMT mtk01461
** Add OS_TIMESTAMP to packet
** \main\maintrunk.MT5921\16 2007-11-21 15:47:20 GMT mtk01088
** fixed the unload module issue
** \main\maintrunk.MT5921\15 2007-11-07 18:37:38 GMT mtk01461
** Fix compile warnning
** \main\maintrunk.MT5921\14 2007-11-02 01:03:19 GMT mtk01461
** Unify TX Path for Normal and IBSS Power Save + IBSS neighbor learning
** \main\maintrunk.MT5921\13 2007-10-30 10:42:33 GMT mtk01425
** 1. Refine for multicast list
** \main\maintrunk.MT5921\12 2007-10-25 18:08:13 GMT mtk01461
** Add VOIP SCAN Support & Refine Roaming
** Revision 1.4 2007/07/05 07:25:33 MTK01461
** Add Linux initial code, modify doc, add 11BB, RF init code
**
** Revision 1.3 2007/06/27 02:18:50 MTK01461
** Update SCAN_FSM, Initial(Can Load Module), Proc(Can do Reg R/W), TX API
**
** Revision 1.2 2007/06/25 06:16:24 MTK01461
** Update illustrations, gl_init.c, gl_kal.c, gl_kal.h, gl_os.h and RX API
**
*/
/*******************************************************************************
* C O M P I L E R F L A G S
********************************************************************************
*/
/*******************************************************************************
* E X T E R N A L R E F E R E N C E S
********************************************************************************
*/
#include "gl_os.h" //also in gl_kal.c //drivers/misc/mediatek/connectivity/wlan/gen2/os/linux/include/gl_os.h
#include "wlan_lib.h"
#include "gl_wext.h" //also in gl_kal.c
#include "gl_cfg80211.h"
#include "precomp.h"
#if CFG_SUPPORT_AGPS_ASSIST
#include "gl_kal.h"
#endif
#if defined(CONFIG_MTK_TC1_FEATURE)
#include <tc1_partition.h>
#endif
#include "gl_vendor.h"
/*******************************************************************************
* C O N S T A N T S
********************************************************************************
*/
/* #define MAX_IOREQ_NUM 10 */
BOOLEAN fgIsUnderSuspend = false;
#if CFG_ENABLE_WIFI_DIRECT
spinlock_t g_p2p_lock;
int g_u4P2PEnding = 0;
int g_u4P2POnOffing = 0;
#endif
/*******************************************************************************
* D A T A T Y P E S
********************************************************************************
*/
/* Tasklet mechanism is like buttom-half in Linux. We just want to
* send a signal to OS for interrupt defer processing. All resources
* are NOT allowed reentry, so txPacket, ISR-DPC and ioctl must avoid preempty.
*/
typedef struct _WLANDEV_INFO_T {
struct net_device *prDev;
} WLANDEV_INFO_T, *P_WLANDEV_INFO_T;
/*******************************************************************************
* P U B L I C D A T A
********************************************************************************
*/
#define CHAN2G(_channel, _freq, _flags) \
{ \
.band = NL80211_BAND_2GHZ, \
.center_freq = (_freq), \
.hw_value = (_channel), \
.flags = (_flags), \
.max_antenna_gain = 0, \
.max_power = 30, \
}
static struct ieee80211_channel mtk_2ghz_channels[] = {
CHAN2G(1, 2412, 0),
CHAN2G(2, 2417, 0),
CHAN2G(3, 2422, 0),
CHAN2G(4, 2427, 0),
CHAN2G(5, 2432, 0),
CHAN2G(6, 2437, 0),
CHAN2G(7, 2442, 0),
CHAN2G(8, 2447, 0),
CHAN2G(9, 2452, 0),
CHAN2G(10, 2457, 0),
CHAN2G(11, 2462, 0),
CHAN2G(12, 2467, 0),
CHAN2G(13, 2472, 0),
CHAN2G(14, 2484, 0),
};
#define CHAN5G(_channel, _flags) \
{ \
.band = NL80211_BAND_5GHZ, \
.center_freq = 5000 + (5 * (_channel)), \
.hw_value = (_channel), \
.flags = (_flags), \
.max_antenna_gain = 0, \
.max_power = 30, \
}
static struct ieee80211_channel mtk_5ghz_channels[] = {
CHAN5G(34, 0), CHAN5G(36, 0),
CHAN5G(38, 0), CHAN5G(40, 0),
CHAN5G(42, 0), CHAN5G(44, 0),
CHAN5G(46, 0), CHAN5G(48, 0),
CHAN5G(52, 0), CHAN5G(56, 0),
CHAN5G(60, 0), CHAN5G(64, 0),
CHAN5G(100, 0), CHAN5G(104, 0),
CHAN5G(108, 0), CHAN5G(112, 0),
CHAN5G(116, 0), CHAN5G(120, 0),
CHAN5G(124, 0), CHAN5G(128, 0),
CHAN5G(132, 0), CHAN5G(136, 0),
CHAN5G(140, 0), CHAN5G(149, 0),
CHAN5G(153, 0), CHAN5G(157, 0),
CHAN5G(161, 0), CHAN5G(165, 0),
CHAN5G(169, 0), CHAN5G(173, 0),
CHAN5G(184, 0), CHAN5G(188, 0),
CHAN5G(192, 0), CHAN5G(196, 0),
CHAN5G(200, 0), CHAN5G(204, 0),
CHAN5G(208, 0), CHAN5G(212, 0),
CHAN5G(216, 0),
};
#define RATETAB_ENT(_rate, _rateid, _flags) \
{ \
.bitrate = (_rate), \
.hw_value = (_rateid), \
.flags = (_flags), \
}
/* for cfg80211 - rate table */
static struct ieee80211_rate mtk_rates[] = {
RATETAB_ENT(10, 0x1000, 0),
RATETAB_ENT(20, 0x1001, 0),
RATETAB_ENT(55, 0x1002, 0),
RATETAB_ENT(110, 0x1003, 0), /* 802.11b */
RATETAB_ENT(60, 0x2000, 0),
RATETAB_ENT(90, 0x2001, 0),
RATETAB_ENT(120, 0x2002, 0),
RATETAB_ENT(180, 0x2003, 0),
RATETAB_ENT(240, 0x2004, 0),
RATETAB_ENT(360, 0x2005, 0),
RATETAB_ENT(480, 0x2006, 0),
RATETAB_ENT(540, 0x2007, 0), /* 802.11a/g */
};
#define mtk_a_rates (mtk_rates + 4)
#define mtk_a_rates_size (ARRAY_SIZE(mtk_rates) - 4)
#define mtk_g_rates (mtk_rates + 0)
#define mtk_g_rates_size (ARRAY_SIZE(mtk_rates) - 0)
#define WLAN_MCS_INFO \
{ \
.rx_mask = {0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0},\
.rx_highest = 0, \
.tx_params = IEEE80211_HT_MCS_TX_DEFINED, \
}
#define WLAN_HT_CAP \
{ \
.ht_supported = true, \
.cap = IEEE80211_HT_CAP_SUP_WIDTH_20_40 \
| IEEE80211_HT_CAP_SM_PS \
| IEEE80211_HT_CAP_GRN_FLD \
| IEEE80211_HT_CAP_SGI_20 \
| IEEE80211_HT_CAP_SGI_40, \
.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K, \
.ampdu_density = IEEE80211_HT_MPDU_DENSITY_NONE, \
.mcs = WLAN_MCS_INFO, \
}
/**********************************************************
* Public for both legacy Wi-Fi and P2P to access
**********************************************************/
struct ieee80211_supported_band mtk_band_2ghz = {
.band = NL80211_BAND_2GHZ,
.channels = mtk_2ghz_channels,
.n_channels = ARRAY_SIZE(mtk_2ghz_channels),
.bitrates = mtk_g_rates,
.n_bitrates = mtk_g_rates_size,
.ht_cap = WLAN_HT_CAP,
};
struct ieee80211_supported_band mtk_band_5ghz = {
.band = NL80211_BAND_5GHZ,
.channels = mtk_5ghz_channels,
.n_channels = ARRAY_SIZE(mtk_5ghz_channels),
.bitrates = mtk_a_rates,
.n_bitrates = mtk_a_rates_size,
.ht_cap = WLAN_HT_CAP,
};
const UINT_32 mtk_cipher_suites[5] = {
/* keep WEP first, it may be removed below */
WLAN_CIPHER_SUITE_WEP40,
WLAN_CIPHER_SUITE_WEP104,
WLAN_CIPHER_SUITE_TKIP,
WLAN_CIPHER_SUITE_CCMP,
/* keep last -- depends on hw flags! */
WLAN_CIPHER_SUITE_AES_CMAC
};
/*********************************************************/
#define NIC_INF_NAME "mt6625_%d" /* interface name */
#if CFG_TC1_FEATURE
#define NIC_INF_NAME_IN_AP_MODE "legacy%d"
#endif
/* support to change debug module info dynamically */
UINT_8 aucDebugModule[DBG_MODULE_NUM];
UINT_32 u4DebugModule = 0;
/* 4 2007/06/26, mikewu, now we don't use this, we just fix the number of wlan device to 1 */
static WLANDEV_INFO_T arWlanDevInfo[CFG_MAX_WLAN_DEVICES] = { {0} };
static UINT_32 u4WlanDevNum; /* How many NICs coexist now */
/**20150205 added work queue for sched_scan to avoid cfg80211 stop schedule scan dead loack**/
struct delayed_work sched_workq;
/*******************************************************************************
* P R I V A T E D A T A
********************************************************************************
*/
#if CFG_ENABLE_WIFI_DIRECT
static SUB_MODULE_HANDLER rSubModHandler[SUB_MODULE_NUM] = { {NULL} };
#endif
static struct cfg80211_ops mtk_wlan_ops = {
.suspend = mtk_cfg80211_suspend,
.resume = mtk_cfg80211_resume,
.change_virtual_intf = mtk_cfg80211_change_iface,
.add_key = mtk_cfg80211_add_key,
.get_key = mtk_cfg80211_get_key,
.del_key = mtk_cfg80211_del_key,
.set_default_key = mtk_cfg80211_set_default_key,
.set_default_mgmt_key = mtk_cfg80211_set_default_mgmt_key,
.get_station = mtk_cfg80211_get_station,
.change_station = mtk_cfg80211_change_station,
.add_station = mtk_cfg80211_add_station,
.del_station = mtk_cfg80211_del_station,
.scan = mtk_cfg80211_scan,
.connect = mtk_cfg80211_connect,
.disconnect = mtk_cfg80211_disconnect,
.join_ibss = mtk_cfg80211_join_ibss,
.leave_ibss = mtk_cfg80211_leave_ibss,
.set_power_mgmt = mtk_cfg80211_set_power_mgmt,
.set_pmksa = mtk_cfg80211_set_pmksa,
.del_pmksa = mtk_cfg80211_del_pmksa,
.flush_pmksa = mtk_cfg80211_flush_pmksa,
.assoc = mtk_cfg80211_assoc,
/* Action Frame TX/RX */
.remain_on_channel = mtk_cfg80211_remain_on_channel,
.cancel_remain_on_channel = mtk_cfg80211_cancel_remain_on_channel,
.mgmt_tx = mtk_cfg80211_mgmt_tx,
/* .mgmt_tx_cancel_wait = mtk_cfg80211_mgmt_tx_cancel_wait, */
.update_mgmt_frame_registrations = mtk_cfg80211_update_mgmt_frame_register,
#ifdef CONFIG_NL80211_TESTMODE
.testmode_cmd = mtk_cfg80211_testmode_cmd,
#endif
#if (CFG_SUPPORT_TDLS == 1)
.tdls_mgmt = TdlsexCfg80211TdlsMgmt,
.tdls_oper = TdlsexCfg80211TdlsOper,
#endif /* CFG_SUPPORT_TDLS */
#if 1 /* Remove schedule_scan because we need more verification for NLO */
.sched_scan_start = mtk_cfg80211_sched_scan_start,
.sched_scan_stop = mtk_cfg80211_sched_scan_stop,
#endif
};
static const struct wiphy_vendor_command mtk_wlan_vendor_ops[] = {
{
{
.vendor_id = GOOGLE_OUI,
.subcmd = WIFI_SUBCMD_GET_CHANNEL_LIST
},
.flags = WIPHY_VENDOR_CMD_NEED_WDEV | WIPHY_VENDOR_CMD_NEED_NETDEV,
.doit = mtk_cfg80211_vendor_get_channel_list,
.policy = wifi_vendor_test_policy
},
{
{
.vendor_id = GOOGLE_OUI,
.subcmd = WIFI_SUBCMD_SET_COUNTRY_CODE
},
.flags = WIPHY_VENDOR_CMD_NEED_WDEV | WIPHY_VENDOR_CMD_NEED_NETDEV,
.doit = mtk_cfg80211_vendor_set_country_code,
.policy = wifi_vendor_test_policy
},
/* GSCAN */
{
{
.vendor_id = GOOGLE_OUI,
.subcmd = GSCAN_SUBCMD_GET_CAPABILITIES
},
.flags = WIPHY_VENDOR_CMD_NEED_WDEV | WIPHY_VENDOR_CMD_NEED_NETDEV,
.doit = mtk_cfg80211_vendor_get_gscan_capabilities,
.policy = gscan_vendor_test_policy
},
{
{
.vendor_id = GOOGLE_OUI,
.subcmd = GSCAN_SUBCMD_SET_CONFIG
},
.flags = WIPHY_VENDOR_CMD_NEED_WDEV | WIPHY_VENDOR_CMD_NEED_NETDEV,
.doit = mtk_cfg80211_vendor_set_config,
.policy = gscan_vendor_test_policy
},
{
{
.vendor_id = GOOGLE_OUI,
.subcmd = GSCAN_SUBCMD_SET_SCAN_CONFIG
},
.flags = WIPHY_VENDOR_CMD_NEED_WDEV,
.doit = mtk_cfg80211_vendor_set_scan_config,
.policy = gscan_vendor_test_policy
},
{
{
.vendor_id = GOOGLE_OUI,
.subcmd = GSCAN_SUBCMD_ENABLE_GSCAN
},
.flags = WIPHY_VENDOR_CMD_NEED_WDEV | WIPHY_VENDOR_CMD_NEED_NETDEV,
.doit = mtk_cfg80211_vendor_enable_scan,
.policy = gscan_vendor_test_policy
},
{
{
.vendor_id = GOOGLE_OUI,
.subcmd = GSCAN_SUBCMD_ENABLE_FULL_SCAN_RESULTS
},
.flags = WIPHY_VENDOR_CMD_NEED_WDEV | WIPHY_VENDOR_CMD_NEED_NETDEV,
.doit = mtk_cfg80211_vendor_enable_full_scan_results,
.policy = gscan_vendor_test_policy
},
{
{
.vendor_id = GOOGLE_OUI,
.subcmd = GSCAN_SUBCMD_GET_SCAN_RESULTS
},
.flags = WIPHY_VENDOR_CMD_NEED_WDEV | WIPHY_VENDOR_CMD_NEED_NETDEV,
.doit = mtk_cfg80211_vendor_get_scan_results,
.policy = gscan_vendor_test_policy
},
{
{
.vendor_id = GOOGLE_OUI,