aboutsummaryrefslogtreecommitdiffstats
path: root/include/asm-alpha/page.h
blob: fa0b41b164a76f04aa52481a10ac0b83d0884026 (plain) (blame)
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
#ifndef _ALPHA_PAGE_H
#define _ALPHA_PAGE_H

#include <linux/config.h>
#include <asm/pal.h>

/* PAGE_SHIFT determines the page size */
#define PAGE_SHIFT	13
#define PAGE_SIZE	(1UL << PAGE_SHIFT)
#define PAGE_MASK	(~(PAGE_SIZE-1))

#ifdef __KERNEL__

#ifndef __ASSEMBLY__

#define STRICT_MM_TYPECHECKS

extern void clear_page(void *page);
#define clear_user_page(page, vaddr, pg)	clear_page(page)

#define alloc_zeroed_user_highpage(vma, vaddr) alloc_page_vma(GFP_HIGHUSER | __GFP_ZERO, vma, vmaddr)
#define __HAVE_ARCH_ALLOC_ZEROED_USER_HIGHPAGE

extern void copy_page(void * _to, void * _from);
#define copy_user_page(to, from, vaddr, pg)	copy_page(to, from)

#ifdef STRICT_MM_TYPECHECKS
/*
 * These are used to make use of C type-checking..
 */
typedef struct { unsigned long pte; } pte_t;
typedef struct { unsigned long pmd; } pmd_t;
typedef struct { unsigned long pgd; } pgd_t;
typedef struct { unsigned long pgprot; } pgprot_t;

#define pte_val(x)	((x).pte)
#define pmd_val(x)	((x).pmd)
#define pgd_val(x)	((x).pgd)
#define pgprot_val(x)	((x).pgprot)

#define __pte(x)	((pte_t) { (x) } )
#define __pmd(x)	((pmd_t) { (x) } )
#define __pgd(x)	((pgd_t) { (x) } )
#define __pgprot(x)	((pgprot_t) { (x) } )

#else
/*
 * .. while these make it easier on the compiler
 */
typedef unsigned long pte_t;
typedef unsigned long pmd_t;
typedef unsigned long pgd_t;
typedef unsigned long pgprot_t;

#define pte_val(x)	(x)
#define pmd_val(x)	(x)
#define pgd_val(x)	(x)
#define pgprot_val(x)	(x)

#define __pte(x)	(x)
#define __pgd(x)	(x)
#define __pgprot(x)	(x)

#endif /* STRICT_MM_TYPECHECKS */

#ifdef USE_48_BIT_KSEG
#define PAGE_OFFSET		0xffff800000000000UL
#else
#define PAGE_OFFSET		0xfffffc0000000000UL
#endif

#else

#ifdef USE_48_BIT_KSEG
#define PAGE_OFFSET		0xffff800000000000
#else
#define PAGE_OFFSET		0xfffffc0000000000
#endif

#endif /* !__ASSEMBLY__ */

/* to align the pointer to the (next) page boundary */
#define PAGE_ALIGN(addr)	(((addr)+PAGE_SIZE-1)&PAGE_MASK)

#define __pa(x)			((unsigned long) (x) - PAGE_OFFSET)
#define __va(x)			((void *)((unsigned long) (x) + PAGE_OFFSET))
#ifndef CONFIG_DISCONTIGMEM
#define pfn_to_page(pfn)	(mem_map + (pfn))
#define page_to_pfn(page)	((unsigned long)((page) - mem_map))
#define virt_to_page(kaddr)	pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)

#define pfn_valid(pfn)		((pfn) < max_mapnr)
#define virt_addr_valid(kaddr)	pfn_valid(__pa(kaddr) >> PAGE_SHIFT)
#endif /* CONFIG_DISCONTIGMEM */

#define VM_DATA_DEFAULT_FLAGS		(VM_READ | VM_WRITE | VM_EXEC | \
					 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)

#endif /* __KERNEL__ */

#include <asm-generic/page.h>

#endif /* _ALPHA_PAGE_H */
er David S. Miller <davem@sunset.davemloft.net> 2007-10-10 19:52:57 -0400 [PATCH] mac80211: revamp interface and filter configuration' href='/cgit/cgit.cgi/litmus-rt.git/commit/net/mac80211/ieee80211.c?h=test&id=4150c57212ad134765dd78c654a4b9906252b66d'>4150c57212ad
53918994b7c8
4150c57212ad

53918994b7c8
4150c57212ad

8a690674e060

8cc9a73914b0

7be5086d4cb7


8cc9a73914b0










4150c57212ad
e3b90ca28412


3ac64beecd27
4150c57212ad

22bedad3ce11
3ac64beecd27

4150c57212ad


3ac64beecd27
4150c57212ad





3ac64beecd27







55de908ab292
b2c258fb11b3
1ea6f9c0d48b
675a0b049abf
55de908ab292
e8975581f638
ffd2778bb984
f0706e828e96
ffd2778bb984
675a0b049abf
7ca15a0ae865

b23b025fe246
675a0b049abf











b23b025fe246



ffd2778bb984
f0706e828e96
675a0b049abf



e8975581f638

8318d78a44d4
0f78231bffb8











0430c883470d
a8302de934b5
1ea6f9c0d48b



764152ff66f4

1ea6f9c0d48b


a8302de934b5
e8975581f638



b2c258fb11b3
55de908ab292














e8975581f638
2448798133d7
d73782fdde76
447107fb32d7
d73782fdde76

447107fb32d7








d73782fdde76
447107fb32d7
d73782fdde76
f0706e828e96
b2c258fb11b3

f0706e828e96
471b3efdfccc

d9430a32886f
471b3efdfccc

990baec022cc
471b3efdfccc

12375ef933fa
d9430a32886f

f698d856f65c
d9430a32886f
bda3933a8ace


7a5158ef8da7


d9430a32886f

f0706e828e96



f0706e828e96




51fb61e76d95
f0706e828e96

005e472b4513
f0706e828e96

f0706e828e96
005e472b4513
f0706e828e96
f4ea83dd743d
5e3f308997f5

f0706e828e96





f2753ddbadb0




bc86863de63e


d43c6b6e6f2f

bc86863de63e
f2753ddbadb0
4136c4224ccf
f2753ddbadb0







b5878a2dc5e7

b196d031f2bb


18145c69349f
445ea4e83ec5
cca07b00a56d

f2753ddbadb0
04800ada2acc






f2753ddbadb0



26b36cfefaf2
2b2c009ecf71








685429623f88
2b2c009ecf71
685429623f88
2b2c009ecf71
685429623f88
2b2c009ecf71







2b2c009ecf71
685429623f88
2b2c009ecf71




95ae6b228f81
685429623f88


2b2c009ecf71
8d61ffa5e01c
685429623f88


0f19b41e223d


685429623f88



685429623f88

53d69c399abf
0f19b41e223d
685429623f88

685429623f88
8d61ffa5e01c
2b2c009ecf71
8bd811aa6c40
2b2c009ecf71
26b36cfefaf2
2b2c009ecf71
a65240c10132


























8bd811aa6c40
a65240c10132


2e161f78e5f6




3bfda62c50b0

41e31b8b9023

2e161f78e5f6
























2ca27bcff712











2e161f78e5f6




c7108a7111cd

71839121a0f3


c7108a7111cd
f142c6b906da




2e161f78e5f6

ef96a84202cc





bc0784d95147
a2e7495d639b
9a07bf507dfc

ef96a84202cc





dd5ecfeac8d1




















ad28757eef26


f0706e828e96
f0706e828e96
96f5e66e8a79
f0706e828e96
fe57d9f5c0a2
f0706e828e96
c0af07340aae




f09603a259ff


e269d8600a8f





fe57d9f5c0a2
e269d8600a8f
f0706e828e96














1ce8e7b57b3a
f0706e828e96
ad28757eef26
f0706e828e96



2e161f78e5f6

207aba6018a7

9bc383de3709

ee971924543f
7c4ef7122cef
81ddbb5c1188



207aba6018a7
b292219fa506

1ea6f9c0d48b
a6dad6a26e15
b5dfae020b35
a6dad6a26e15
a729cff8ad51
cd2bb512cda5
5c95b940bd97


cd2bb512cda5
207aba6018a7

18a8365992a8
0c1ad2cac1cb
f0706e828e96

de95a54b1aeb
7bedd0cfad4e


f0706e828e96

1ce8e7b57b3a
f0706e828e96

fe57d9f5c0a2
f0706e828e96
e6a9854b05c1


78be49ec2a0d
df6ba5d80d6c
39e68712d757
3a25a8c8b75b
b9a5f8cab751

ac55d2fe0576


5164892184d1

219c38674c26

1ea6f9c0d48b
ef96a84202cc
dd5ecfeac8d1
f0706e828e96
e9a21949b794






79010420cc3f
2f787b0b76bf


c771c9d8da1e
a1699b75a1db
f0706e828e96
ad0e2b5a00db
3b8d81e020f7
f9e124fbd8cb
ce7c9111a974

d01a1e658606


c2b13452b283
f0706e828e96
f2753ddbadb0

164eb02d070a


3ac64beecd27
0f78231bffb8
3ac64beecd27
520eb8207699






85a9994a0a6c


a729cff8ad51

a729cff8ad51
a6a67db2bc89
2a577d98712a
a6a67db2bc89

f0706e828e96

f0706e828e96



f0706e828e96



fe67c913f1ec

2eb278e08354
21f83589644b
005e472b4513
7bedd0cfad4e


f0706e828e96
ad28757eef26
f0706e828e96
2475b1cc0d52
f0706e828e96
2475b1cc0d52


2475b1cc0d52

25e47c18ac4d
5daa8a8e691e
25e47c18ac4d



2b2ba0db1c82
00b9cfa3ff38

25e47c18ac4d

56c52da2d554

8ade538bf39b

25e47c18ac4d
8318d78a44d4
fa7e1fbcb52c

















2475b1cc0d52
fa7e1fbcb52c












2475b1cc0d52



8ade538bf39b
2475b1cc0d52





fa7e1fbcb52c
2475b1cc0d52
fa7e1fbcb52c

2475b1cc0d52
fa7e1fbcb52c




00b9cfa3ff38
2b2ba0db1c82
2475b1cc0d52
2b2ba0db1c82
2475b1cc0d52




8ade538bf39b


2475b1cc0d52
8ade538bf39b
2475b1cc0d52





2b2ba0db1c82
2475b1cc0d52
00b9cfa3ff38

2475b1cc0d52





56c52da2d554
2475b1cc0d52
56c52da2d554
8ade538bf39b

56c52da2d554
2475b1cc0d52


2475b1cc0d52


















3a25a8c8b75b




a7a6bdd0670f

8a4d32f30d11

a7a6bdd0670f

38bb3e9da62f
964dc9e2c3aa
eecc48000afe
dfb89c56add2
eecc48000afe
fe57d9f5c0a2








746a336582a7
fe57d9f5c0a2






164eb02d070a
486cf4c08fe8
164eb02d070a




486cf4c08fe8

164eb02d070a

fe57d9f5c0a2

72d7872852e1





78be49ec2a0d


04ecd2578e71

8318d78a44d4




2a5193119269
de95a54b1aeb
5ef2d41afb7f
ba0afa2f22e1
8318d78a44d4



de95a54b1aeb

fffa4b1c170a




8318d78a44d4
fffa4b1c170a




8318d78a44d4
fffa4b1c170a
de95a54b1aeb



5ef2d41afb7f
ba0afa2f22e1
04ecd2578e71






8318d78a44d4
f0706e828e96
f59ac0481660
7527a782e187



f59ac0481660

7527a782e187


55de908ab292
8e621fc90b42





8e621fc90b42





5b0ec94f9cfd










5eb5a52da6ef




1570ca59279a




a621fa4d6a7f


52512072738c
77965c970d7d
52512072738c
77965c970d7d
52512072738c




77965c970d7d
de95a54b1aeb


dc9f48ce7c7d
de95a54b1aeb

dc9f48ce7c7d

5ef2d41afb7f

de95a54b1aeb
d0e6c21acdd4
ba0afa2f22e1
d4950281d72d
ba0afa2f22e1
de95a54b1aeb















2475b1cc0d52





25e47c18ac4d
21f83589644b

a293911d4fd5
dfe018bf9953



e9a21949b794



0d06d9ba93ad

f0706e828e96

2a5193119269
f0706e828e96
e25300836091



e25300836091

e25300836091
42935ecaf4e7
d8537548c924
42935ecaf4e7
f0706e828e96



b306f4530086




33ccad35a21d
a2fe81667410
b306f4530086
e9f207f0ff90

b446918b77c7



ea95bba41e69
b446918b77c7
ea95bba41e69


ff61638105db
195e294d21e8
ba8c3d6f16a1


d4c4a9a1bce1
3473187d2459
0fb9a9ec2771

d4c4a9a1bce1
24d47300d118

b57e6b560fc2

f0706e828e96
f0706e828e96
830f903866a1

f0706e828e96
0fb9a9ec2771

f0706e828e96


8dffff216fca
e27513fbd030

6bab2e19c5ff
8dffff216fca

0fb9a9ec2771

8dffff216fca
f0706e828e96
f0706e828e96

10f644a47b76



54330bf63b49
10f644a47b76
10f644a47b76
26b36cfefaf2
2b2c009ecf71



26b36cfefaf2
2b2c009ecf71
a65240c10132






f0706e828e96

a65240c10132

93c08c329142
a65240c10132



2b2c009ecf71


93c08c329142
10f644a47b76
54330bf63b49

10f644a47b76
10f644a47b76
f0706e828e96
54330bf63b49
d4c4a9a1bce1
42935ecaf4e7
10f644a47b76
f0706e828e96
10f644a47b76
3ffc2a905b1f

11ba964d4f93
f0706e828e96



06d181a8fd58











f0706e828e96


f0706e828e96



10f644a47b76

26b36cfefaf2
2b2c009ecf71
26b36cfefaf2
a65240c10132


10f644a47b76
f0706e828e96

79010420cc3f




75636525fbfa
5b2812e925c8
f0706e828e96

258086a48b76
3ac64beecd27
18db594a1005
3ac64beecd27
f0706e828e96
f0706e828e96

f64f9e719261

0fb9a9ec2771
f0706e828e96


42935ecaf4e7
f0706e828e96


5ba63533bbf6
f0706e828e96


a729cff8ad51






f0706e828e96



c771c9d8da1e
a1699b75a1db
c771c9d8da1e
3ffc2a905b1f


a729cff8ad51



54330bf63b49

f0706e828e96



f0706e828e96




e039fa4a4195

c6a1fa12d206
f0706e828e96
cccf129f820e



ec8aa669b839



47846c9b0c10


e9f207f0ff90
f0706e828e96
47846c9b0c10
ec8aa669b839

47846c9b0c10


f0706e828e96

f0706e828e96

ec8aa669b839
cccf129f820e
ac71c691e6a5
bf7cd94dcc71
902acc7896d7
47846c9b0c10
d07c7cf49ae7

f0706e828e96


ca9938fea576
f0706e828e96



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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263



                                                  
                                                        






                                                                       







                              
                            
                         
                         
                             
                              
                         
                         
 
                        
                       
                 
                 
                
                
                
                    
 
                                                              
 
               


                                   
                                              

                                                
                                               

                                          

                                                                              

                                                     


                                                         










                                           
 


                                        
                                          

                                                        
                                                           

                                            


                             
                                                                   





                                                   







                                                                            
                                                                
 
                                            
                                              
                        
                  
                            
 
                                                                           
 

                                              
                                        











                                                                         



                                                                   
                                                                            
 



                                                                 

                                                         
 











                                                                  
                                                      
 



                                                                  

                                                              


                                                                
 



                                                       
 














                                                                   
                                           
                                                 
                  
                        

                                                                               








                                                                          
                   
                                   
         
 

                   
 

                                                                          
 

                                                     
                                                                  

                       
                                                                          

 
                                                                 
 


                                                       


                                         

 



                                                                        




                                                                   
                                                                             

                                          
                                                      

                                             
                                          
                                                             
                              
                        

                                                                           





                                           




                                                                         


                                          

                                                                     
 
                    
                                     







                                                        

                                    


                                                       
                                                                 
                                                                    

                                                                            
 






                                                                       



                                            
                  








                                                               
                               
                                            
                                            
                                           
                  







                                                           
                                              
                                        




                                                             
                                             


                                   
                              
                          


                                                     


                                                                      



                                    

                                   
                                                                               
                              

                                                                         
 
                            
 
                         
 
      
 


























                                                                        
                         


      




                                                                              

                                                        

                                                            
























                                                               











                                                               




                                                            

                                       


                                                         
          




                                                            

  





                                                                  
                                                         
                                                         

                                                                   





                                                             




















                                                                               


                                                                           
 
                                      
                         
                            
                         
 




                                                                            


                                                                         





                                                               
                             
 














                                                                            
                                                                        
 
                                                                              



                            

                                                           

                                              

                                             
                                                  
                                                 



                                                                 
 

                                                         
                                                    
                                                        
                                                          
                                                         
 
                          


                                                                      
 

                                                    
 
                                                            

                                  
 


                                 

                                
                                                                             

                         
                                         
 


                                  
                                       
                                                                         
                                                                         
                                                                    

                                                                     


                                                                          

                                                                                

                                                                  
                                                              
                                                             
                                                               
 






                                                            
                                           


                                        
                                       
                                
 
                                    
                                            
                                             

                                                       


                                             
                                                                  
 

                                                                


                                                     
                                                                      
                                              
 






                                                                       


                                                     

                                                
 
                                                    
                                                        

                                                         

                                                                      



                                               



                                                          

                                   
                                   
 
                          


                          
 
                                     
 
                                                                      
 


                                                                   

                                       
                                            
                                                             



                                         
                                           

                                           

                                                       

                                               

                                               
          
 

















                                                                                
 












                                                                             



                                                                             
                                                              





                                                              
                                                               
                         

                                                         
 




                                                                              
                                                                            
                                               
                   
                                                          




                                                       


                                                                         
                             
                                      





                                                                     
                                                         
                                                     

                                                         





                                                               
                               
                                                                 
                                                                     

                                                                     
                 


                                                                


















                                                        




                                                                            

                                                                          

                                                       

                                   
                
                                                                               
                               
      
 








                                                                             
                






                                                                               
 
                                                                              




                                                                             

                                                             

                                               

         





                                                                          


                                                     

                             




                                                        
                     
                         
                        
                         



                                                            

                                 




                                                                    
                                                   




                                                                                
                 
 



                                                         
                                                                
                                                                    






                                                                                
         
 
                                                                   



                                                                           

                                              


                                                                   
                                                                             





                                                               





                                                                               










                                                                             




                                                                             




                                                                              


                                                                   
                                                        
                                                                        
                                                                  
                                                                           




                                                 
 


                                                            
                                                                     

                                                              

                                                                       

                                                                           
 
                     
                                      
                                                             
 















                                                                          





                                                                      
 

                                                                       
 



                                                                         



                                                                           

                                                                               

                                                 
                                         
 



                                                                             

                                                  
 
                          
                                                                              
                                



                                    




                                                                     
                                                                              
                                                                 
 

                              



                                                                 
                                               
                                                  


                                                                       
                                              
 


                                                  
                                           
                       

                                                                              
 

                                                   

                                  
                    
 

                                                                          
                         

                                                                             


                               
                                                        

                                                                             
                                                                               

                                                                        

                                                                            
         
 

                      



                                                                       
                   
                                 
 
                  



                                                                  
      
 






                                                                    

                 

                           
                  



                                                           


                                                                 
      
             

                                         
                                           
           
                      
                                  
                                  
                                            
                
                                          
                     

                                                      
                                   



                                     











                                                                          


                                                        



                                                 

                                                                 
                  
                                                           
      


                                                             
 

                    




                                                               
                                           
 

                      
                                               
                                                  
                                                    
 
                                          

                                         

                                                        
                                                                     


                                                      
                                            


                                          
                                   


                                       






                                                                



                                                        
                                          
                                   
 


                                                      



                                                     

                             



                                    




                                      

                                                                         
                                                                           
 



                                      



                                         


                                     
 
                 
            

                                   


                                

 

                                       
                                   
                                
 
                          
 
                               

                      


 
                                



                                            
/*
 * Copyright 2002-2005, Instant802 Networks, Inc.
 * Copyright 2005-2006, Devicescape Software, Inc.
 * Copyright 2006-2007	Jiri Benc <jbenc@suse.cz>
 * Copyright 2013-2014  Intel Mobile Communications GmbH
 *
 * 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.
 */

#include <net/mac80211.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/netdevice.h>
#include <linux/types.h>
#include <linux/slab.h>
#include <linux/skbuff.h>
#include <linux/etherdevice.h>
#include <linux/if_arp.h>
#include <linux/rtnetlink.h>
#include <linux/bitmap.h>
#include <linux/pm_qos.h>
#include <linux/inetdevice.h>
#include <net/net_namespace.h>
#include <net/cfg80211.h>
#include <net/addrconf.h>

#include "ieee80211_i.h"
#include "driver-ops.h"
#include "rate.h"
#include "mesh.h"
#include "wep.h"
#include "led.h"
#include "cfg.h"
#include "debugfs.h"

void ieee80211_configure_filter(struct ieee80211_local *local)
{
	u64 mc;
	unsigned int changed_flags;
	unsigned int new_flags = 0;

	if (atomic_read(&local->iff_promiscs))
		new_flags |= FIF_PROMISC_IN_BSS;

	if (atomic_read(&local->iff_allmultis))
		new_flags |= FIF_ALLMULTI;

	if (local->monitors || test_bit(SCAN_SW_SCANNING, &local->scanning) ||
	    test_bit(SCAN_ONCHANNEL_SCANNING, &local->scanning))
		new_flags |= FIF_BCN_PRBRESP_PROMISC;

	if (local->fif_probe_req || local->probe_req_reg)
		new_flags |= FIF_PROBE_REQ;

	if (local->fif_fcsfail)
		new_flags |= FIF_FCSFAIL;

	if (local->fif_plcpfail)
		new_flags |= FIF_PLCPFAIL;

	if (local->fif_control)
		new_flags |= FIF_CONTROL;

	if (local->fif_other_bss)
		new_flags |= FIF_OTHER_BSS;

	if (local->fif_pspoll)
		new_flags |= FIF_PSPOLL;

	spin_lock_bh(&local->filter_lock);
	changed_flags = local->filter_flags ^ new_flags;

	mc = drv_prepare_multicast(local, &local->mc_list);
	spin_unlock_bh(&local->filter_lock);

	/* be a bit nasty */
	new_flags |= (1<<31);

	drv_configure_filter(local, changed_flags, &new_flags, mc);

	WARN_ON(new_flags & (1<<31));

	local->filter_flags = new_flags & ~(1<<31);
}

static void ieee80211_reconfig_filter(struct work_struct *work)
{
	struct ieee80211_local *local =
		container_of(work, struct ieee80211_local, reconfig_filter);

	ieee80211_configure_filter(local);
}

static u32 ieee80211_hw_conf_chan(struct ieee80211_local *local)
{
	struct ieee80211_sub_if_data *sdata;
	struct cfg80211_chan_def chandef = {};
	u32 changed = 0;
	int power;
	u32 offchannel_flag;

	offchannel_flag = local->hw.conf.flags & IEEE80211_CONF_OFFCHANNEL;

	if (local->scan_chandef.chan) {
		chandef = local->scan_chandef;
	} else if (local->tmp_channel) {
		chandef.chan = local->tmp_channel;
		chandef.width = NL80211_CHAN_WIDTH_20_NOHT;
		chandef.center_freq1 = chandef.chan->center_freq;
	} else
		chandef = local->_oper_chandef;

	WARN(!cfg80211_chandef_valid(&chandef),
	     "control:%d MHz width:%d center: %d/%d MHz",
	     chandef.chan->center_freq, chandef.width,
	     chandef.center_freq1, chandef.center_freq2);

	if (!cfg80211_chandef_identical(&chandef, &local->_oper_chandef))
		local->hw.conf.flags |= IEEE80211_CONF_OFFCHANNEL;
	else
		local->hw.conf.flags &= ~IEEE80211_CONF_OFFCHANNEL;

	offchannel_flag ^= local->hw.conf.flags & IEEE80211_CONF_OFFCHANNEL;

	if (offchannel_flag ||
	    !cfg80211_chandef_identical(&local->hw.conf.chandef,
					&local->_oper_chandef)) {
		local->hw.conf.chandef = chandef;
		changed |= IEEE80211_CONF_CHANGE_CHANNEL;
	}

	if (!conf_is_ht(&local->hw.conf)) {
		/*
		 * mac80211.h documents that this is only valid
		 * when the channel is set to an HT type, and
		 * that otherwise STATIC is used.
		 */
		local->hw.conf.smps_mode = IEEE80211_SMPS_STATIC;
	} else if (local->hw.conf.smps_mode != local->smps_mode) {
		local->hw.conf.smps_mode = local->smps_mode;
		changed |= IEEE80211_CONF_CHANGE_SMPS;
	}

	power = ieee80211_chandef_max_power(&chandef);

	rcu_read_lock();
	list_for_each_entry_rcu(sdata, &local->interfaces, list) {
		if (!rcu_access_pointer(sdata->vif.chanctx_conf))
			continue;
		if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
			continue;
		power = min(power, sdata->vif.bss_conf.txpower);
	}
	rcu_read_unlock();

	if (local->hw.conf.power_level != power) {
		changed |= IEEE80211_CONF_CHANGE_POWER;
		local->hw.conf.power_level = power;
	}

	return changed;
}

int ieee80211_hw_config(struct ieee80211_local *local, u32 changed)
{
	int ret = 0;

	might_sleep();

	if (!local->use_chanctx)
		changed |= ieee80211_hw_conf_chan(local);
	else
		changed &= ~(IEEE80211_CONF_CHANGE_CHANNEL |
			     IEEE80211_CONF_CHANGE_POWER);

	if (changed && local->open_count) {
		ret = drv_config(local, changed);
		/*
		 * Goal:
		 * HW reconfiguration should never fail, the driver has told
		 * us what it can support so it should live up to that promise.
		 *
		 * Current status:
		 * rfkill is not integrated with mac80211 and a
		 * configuration command can thus fail if hardware rfkill
		 * is enabled
		 *
		 * FIXME: integrate rfkill with mac80211 and then add this
		 * WARN_ON() back
		 *
		 */
		/* WARN_ON(ret); */
	}

	return ret;
}

void ieee80211_bss_info_change_notify(struct ieee80211_sub_if_data *sdata,
				      u32 changed)
{
	struct ieee80211_local *local = sdata->local;

	if (!changed || sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
		return;

	drv_bss_info_changed(local, sdata, &sdata->vif.bss_conf, changed);
}

u32 ieee80211_reset_erp_info(struct ieee80211_sub_if_data *sdata)
{
	sdata->vif.bss_conf.use_cts_prot = false;
	sdata->vif.bss_conf.use_short_preamble = false;
	sdata->vif.bss_conf.use_short_slot = false;
	return BSS_CHANGED_ERP_CTS_PROT |
	       BSS_CHANGED_ERP_PREAMBLE |
	       BSS_CHANGED_ERP_SLOT;
}

static void ieee80211_tasklet_handler(unsigned long data)
{
	struct ieee80211_local *local = (struct ieee80211_local *) data;
	struct sk_buff *skb;

	while ((skb = skb_dequeue(&local->skb_queue)) ||
	       (skb = skb_dequeue(&local->skb_queue_unreliable))) {
		switch (skb->pkt_type) {
		case IEEE80211_RX_MSG:
			/* Clear skb->pkt_type in order to not confuse kernel
			 * netstack. */
			skb->pkt_type = 0;
			ieee80211_rx(&local->hw, skb);
			break;
		case IEEE80211_TX_STATUS_MSG:
			skb->pkt_type = 0;
			ieee80211_tx_status(&local->hw, skb);
			break;
		default:
			WARN(1, "mac80211: Packet is of unknown type %d\n",
			     skb->pkt_type);
			dev_kfree_skb(skb);
			break;
		}
	}
}

static void ieee80211_restart_work(struct work_struct *work)
{
	struct ieee80211_local *local =
		container_of(work, struct ieee80211_local, restart_work);

	/* wait for scan work complete */
	flush_workqueue(local->workqueue);

	WARN(test_bit(SCAN_HW_SCANNING, &local->scanning),
	     "%s called with hardware scan in progress\n", __func__);

	rtnl_lock();
	ieee80211_scan_cancel(local);
	ieee80211_reconfig(local);
	rtnl_unlock();
}

void ieee80211_restart_hw(struct ieee80211_hw *hw)
{
	struct ieee80211_local *local = hw_to_local(hw);

	trace_api_restart_hw(local);

	wiphy_info(hw->wiphy,
		   "Hardware restart was requested\n");

	/* use this reason, ieee80211_reconfig will unblock it */
	ieee80211_stop_queues_by_reason(hw, IEEE80211_MAX_QUEUE_MAP,
					IEEE80211_QUEUE_STOP_REASON_SUSPEND,
					false);

	/*
	 * Stop all Rx during the reconfig. We don't want state changes
	 * or driver callbacks while this is in progress.
	 */
	local->in_reconfig = true;
	barrier();

	schedule_work(&local->restart_work);
}
EXPORT_SYMBOL(ieee80211_restart_hw);

#ifdef CONFIG_INET
static int ieee80211_ifa_changed(struct notifier_block *nb,
				 unsigned long data, void *arg)
{
	struct in_ifaddr *ifa = arg;
	struct ieee80211_local *local =
		container_of(nb, struct ieee80211_local,
			     ifa_notifier);
	struct net_device *ndev = ifa->ifa_dev->dev;
	struct wireless_dev *wdev = ndev->ieee80211_ptr;
	struct in_device *idev;
	struct ieee80211_sub_if_data *sdata;
	struct ieee80211_bss_conf *bss_conf;
	struct ieee80211_if_managed *ifmgd;
	int c = 0;

	/* Make sure it's our interface that got changed */
	if (!wdev)
		return NOTIFY_DONE;

	if (wdev->wiphy != local->hw.wiphy)
		return NOTIFY_DONE;

	sdata = IEEE80211_DEV_TO_SUB_IF(ndev);
	bss_conf = &sdata->vif.bss_conf;

	/* ARP filtering is only supported in managed mode */
	if (sdata->vif.type != NL80211_IFTYPE_STATION)
		return NOTIFY_DONE;

	idev = __in_dev_get_rtnl(sdata->dev);
	if (!idev)
		return NOTIFY_DONE;

	ifmgd = &sdata->u.mgd;
	sdata_lock(sdata);

	/* Copy the addresses to the bss_conf list */
	ifa = idev->ifa_list;
	while (ifa) {
		if (c < IEEE80211_BSS_ARP_ADDR_LIST_LEN)
			bss_conf->arp_addr_list[c] = ifa->ifa_address;
		ifa = ifa->ifa_next;
		c++;
	}

	bss_conf->arp_addr_cnt = c;

	/* Configure driver only if associated (which also implies it is up) */
	if (ifmgd->associated)
		ieee80211_bss_info_change_notify(sdata,
						 BSS_CHANGED_ARP_FILTER);

	sdata_unlock(sdata);

	return NOTIFY_OK;
}
#endif

#if IS_ENABLED(CONFIG_IPV6)
static int ieee80211_ifa6_changed(struct notifier_block *nb,
				  unsigned long data, void *arg)
{
	struct inet6_ifaddr *ifa = (struct inet6_ifaddr *)arg;
	struct inet6_dev *idev = ifa->idev;
	struct net_device *ndev = ifa->idev->dev;
	struct ieee80211_local *local =
		container_of(nb, struct ieee80211_local, ifa6_notifier);
	struct wireless_dev *wdev = ndev->ieee80211_ptr;
	struct ieee80211_sub_if_data *sdata;

	/* Make sure it's our interface that got changed */
	if (!wdev || wdev->wiphy != local->hw.wiphy)
		return NOTIFY_DONE;

	sdata = IEEE80211_DEV_TO_SUB_IF(ndev);

	/*
	 * For now only support station mode. This is mostly because
	 * doing AP would have to handle AP_VLAN in some way ...
	 */
	if (sdata->vif.type != NL80211_IFTYPE_STATION)
		return NOTIFY_DONE;

	drv_ipv6_addr_change(local, sdata, idev);

	return NOTIFY_OK;
}
#endif

/* There isn't a lot of sense in it, but you can transmit anything you like */
static const struct ieee80211_txrx_stypes
ieee80211_default_mgmt_stypes[NUM_NL80211_IFTYPES] = {
	[NL80211_IFTYPE_ADHOC] = {
		.tx = 0xffff,
		.rx = BIT(IEEE80211_STYPE_ACTION >> 4) |
			BIT(IEEE80211_STYPE_AUTH >> 4) |
			BIT(IEEE80211_STYPE_DEAUTH >> 4) |
			BIT(IEEE80211_STYPE_PROBE_REQ >> 4),
	},
	[NL80211_IFTYPE_STATION] = {
		.tx = 0xffff,
		.rx = BIT(IEEE80211_STYPE_ACTION >> 4) |
			BIT(IEEE80211_STYPE_PROBE_REQ >> 4),
	},
	[NL80211_IFTYPE_AP] = {
		.tx = 0xffff,
		.rx = BIT(IEEE80211_STYPE_ASSOC_REQ >> 4) |
			BIT(IEEE80211_STYPE_REASSOC_REQ >> 4) |
			BIT(IEEE80211_STYPE_PROBE_REQ >> 4) |
			BIT(IEEE80211_STYPE_DISASSOC >> 4) |
			BIT(IEEE80211_STYPE_AUTH >> 4) |
			BIT(IEEE80211_STYPE_DEAUTH >> 4) |
			BIT(IEEE80211_STYPE_ACTION >> 4),
	},
	[NL80211_IFTYPE_AP_VLAN] = {
		/* copy AP */
		.tx = 0xffff,
		.rx = BIT(IEEE80211_STYPE_ASSOC_REQ >> 4) |
			BIT(IEEE80211_STYPE_REASSOC_REQ >> 4) |
			BIT(IEEE80211_STYPE_PROBE_REQ >> 4) |
			BIT(IEEE80211_STYPE_DISASSOC >> 4) |
			BIT(IEEE80211_STYPE_AUTH >> 4) |
			BIT(IEEE80211_STYPE_DEAUTH >> 4) |
			BIT(IEEE80211_STYPE_ACTION >> 4),
	},
	[NL80211_IFTYPE_P2P_CLIENT] = {
		.tx = 0xffff,
		.rx = BIT(IEEE80211_STYPE_ACTION >> 4) |
			BIT(IEEE80211_STYPE_PROBE_REQ >> 4),
	},
	[NL80211_IFTYPE_P2P_GO] = {
		.tx = 0xffff,
		.rx = BIT(IEEE80211_STYPE_ASSOC_REQ >> 4) |
			BIT(IEEE80211_STYPE_REASSOC_REQ >> 4) |
			BIT(IEEE80211_STYPE_PROBE_REQ >> 4) |
			BIT(IEEE80211_STYPE_DISASSOC >> 4) |
			BIT(IEEE80211_STYPE_AUTH >> 4) |
			BIT(IEEE80211_STYPE_DEAUTH >> 4) |
			BIT(IEEE80211_STYPE_ACTION >> 4),
	},
	[NL80211_IFTYPE_MESH_POINT] = {
		.tx = 0xffff,
		.rx = BIT(IEEE80211_STYPE_ACTION >> 4) |
			BIT(IEEE80211_STYPE_AUTH >> 4) |
			BIT(IEEE80211_STYPE_DEAUTH >> 4),
	},
	[NL80211_IFTYPE_P2P_DEVICE] = {
		.tx = 0xffff,
		.rx = BIT(IEEE80211_STYPE_ACTION >> 4) |
			BIT(IEEE80211_STYPE_PROBE_REQ >> 4),
	},
};

static const struct ieee80211_ht_cap mac80211_ht_capa_mod_mask = {
	.ampdu_params_info = IEEE80211_HT_AMPDU_PARM_FACTOR |
			     IEEE80211_HT_AMPDU_PARM_DENSITY,

	.cap_info = cpu_to_le16(IEEE80211_HT_CAP_SUP_WIDTH_20_40 |
				IEEE80211_HT_CAP_MAX_AMSDU |
				IEEE80211_HT_CAP_SGI_20 |
				IEEE80211_HT_CAP_SGI_40 |
				IEEE80211_HT_CAP_LDPC_CODING |
				IEEE80211_HT_CAP_40MHZ_INTOLERANT),
	.mcs = {
		.rx_mask = { 0xff, 0xff, 0xff, 0xff, 0xff,
			     0xff, 0xff, 0xff, 0xff, 0xff, },
	},
};

static const struct ieee80211_vht_cap mac80211_vht_capa_mod_mask = {
	.vht_cap_info =
		cpu_to_le32(IEEE80211_VHT_CAP_RXLDPC |
			    IEEE80211_VHT_CAP_SHORT_GI_80 |
			    IEEE80211_VHT_CAP_SHORT_GI_160 |
			    IEEE80211_VHT_CAP_RXSTBC_1 |
			    IEEE80211_VHT_CAP_RXSTBC_2 |
			    IEEE80211_VHT_CAP_RXSTBC_3 |
			    IEEE80211_VHT_CAP_RXSTBC_4 |
			    IEEE80211_VHT_CAP_TXSTBC |
			    IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE |
			    IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE |
			    IEEE80211_VHT_CAP_TX_ANTENNA_PATTERN |
			    IEEE80211_VHT_CAP_RX_ANTENNA_PATTERN |
			    IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK),
	.supp_mcs = {
		.rx_mcs_map = cpu_to_le16(~0),
		.tx_mcs_map = cpu_to_le16(~0),
	},
};

struct ieee80211_hw *ieee80211_alloc_hw_nm(size_t priv_data_len,
					   const struct ieee80211_ops *ops,
					   const char *requested_name)
{
	struct ieee80211_local *local;
	int priv_size, i;
	struct wiphy *wiphy;
	bool use_chanctx;

	if (WARN_ON(!ops->tx || !ops->start || !ops->stop || !ops->config ||
		    !ops->add_interface || !ops->remove_interface ||
		    !ops->configure_filter))
		return NULL;

	if (WARN_ON(ops->sta_state && (ops->sta_add || ops->sta_remove)))
		return NULL;

	/* check all or no channel context operations exist */
	i = !!ops->add_chanctx + !!ops->remove_chanctx +
	    !!ops->change_chanctx + !!ops->assign_vif_chanctx +
	    !!ops->unassign_vif_chanctx;
	if (WARN_ON(i != 0 && i != 5))
		return NULL;
	use_chanctx = i == 5;

	/* Ensure 32-byte alignment of our private data and hw private data.
	 * We use the wiphy priv data for both our ieee80211_local and for
	 * the driver's private data
	 *
	 * In memory it'll be like this:
	 *
	 * +-------------------------+
	 * | struct wiphy	    |
	 * +-------------------------+
	 * | struct ieee80211_local  |
	 * +-------------------------+
	 * | driver's private data   |
	 * +-------------------------+
	 *
	 */
	priv_size = ALIGN(sizeof(*local), NETDEV_ALIGN) + priv_data_len;

	wiphy = wiphy_new_nm(&mac80211_config_ops, priv_size, requested_name);

	if (!wiphy)
		return NULL;

	wiphy->mgmt_stypes = ieee80211_default_mgmt_stypes;

	wiphy->privid = mac80211_wiphy_privid;

	wiphy->flags |= WIPHY_FLAG_NETNS_OK |
			WIPHY_FLAG_4ADDR_AP |
			WIPHY_FLAG_4ADDR_STATION |
			WIPHY_FLAG_REPORTS_OBSS |
			WIPHY_FLAG_OFFCHAN_TX;

	if (ops->remain_on_channel)
		wiphy->flags |= WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL;

	wiphy->features |= NL80211_FEATURE_SK_TX_STATUS |
			   NL80211_FEATURE_SAE |
			   NL80211_FEATURE_HT_IBSS |
			   NL80211_FEATURE_VIF_TXPOWER |
			   NL80211_FEATURE_MAC_ON_CREATE |
			   NL80211_FEATURE_USERSPACE_MPM;

	if (!ops->hw_scan)
		wiphy->features |= NL80211_FEATURE_LOW_PRIORITY_SCAN |
				   NL80211_FEATURE_AP_SCAN;


	if (!ops->set_key)
		wiphy->flags |= WIPHY_FLAG_IBSS_RSN;

	wiphy->bss_priv_size = sizeof(struct ieee80211_bss);

	local = wiphy_priv(wiphy);

	if (sta_info_init(local))
		goto err_free;

	local->hw.wiphy = wiphy;

	local->hw.priv = (char *)local + ALIGN(sizeof(*local), NETDEV_ALIGN);

	local->ops = ops;
	local->use_chanctx = use_chanctx;

	/* set up some defaults */
	local->hw.queues = 1;
	local->hw.max_rates = 1;
	local->hw.max_report_rates = 0;
	local->hw.max_rx_aggregation_subframes = IEEE80211_MAX_AMPDU_BUF;
	local->hw.max_tx_aggregation_subframes = IEEE80211_MAX_AMPDU_BUF;
	local->hw.offchannel_tx_hw_queue = IEEE80211_INVAL_HW_QUEUE;
	local->hw.conf.long_frame_max_tx_count = wiphy->retry_long;
	local->hw.conf.short_frame_max_tx_count = wiphy->retry_short;
	local->hw.radiotap_mcs_details = IEEE80211_RADIOTAP_MCS_HAVE_MCS |
					 IEEE80211_RADIOTAP_MCS_HAVE_GI |
					 IEEE80211_RADIOTAP_MCS_HAVE_BW;
	local->hw.radiotap_vht_details = IEEE80211_RADIOTAP_VHT_KNOWN_GI |
					 IEEE80211_RADIOTAP_VHT_KNOWN_BANDWIDTH;
	local->hw.uapsd_queues = IEEE80211_DEFAULT_UAPSD_QUEUES;
	local->hw.uapsd_max_sp_len = IEEE80211_DEFAULT_MAX_SP_LEN;
	local->user_power_level = IEEE80211_UNSET_POWER_LEVEL;
	wiphy->ht_capa_mod_mask = &mac80211_ht_capa_mod_mask;
	wiphy->vht_capa_mod_mask = &mac80211_vht_capa_mod_mask;

	local->ext_capa[7] = WLAN_EXT_CAPA8_OPMODE_NOTIF;

	wiphy->extended_capabilities = local->ext_capa;
	wiphy->extended_capabilities_mask = local->ext_capa;
	wiphy->extended_capabilities_len =
		ARRAY_SIZE(local->ext_capa);

	INIT_LIST_HEAD(&local->interfaces);

	__hw_addr_init(&local->mc_list);

	mutex_init(&local->iflist_mtx);
	mutex_init(&local->mtx);

	mutex_init(&local->key_mtx);
	spin_lock_init(&local->filter_lock);
	spin_lock_init(&local->rx_path_lock);
	spin_lock_init(&local->queue_stop_reason_lock);

	INIT_LIST_HEAD(&local->chanctx_list);
	mutex_init(&local->chanctx_mtx);

	INIT_DELAYED_WORK(&local->scan_work, ieee80211_scan_work);

	INIT_WORK(&local->restart_work, ieee80211_restart_work);

	INIT_WORK(&local->radar_detected_work,
		  ieee80211_dfs_radar_detected_work);

	INIT_WORK(&local->reconfig_filter, ieee80211_reconfig_filter);
	local->smps_mode = IEEE80211_SMPS_OFF;

	INIT_WORK(&local->dynamic_ps_enable_work,
		  ieee80211_dynamic_ps_enable_work);
	INIT_WORK(&local->dynamic_ps_disable_work,
		  ieee80211_dynamic_ps_disable_work);
	setup_timer(&local->dynamic_ps_timer,
		    ieee80211_dynamic_ps_timer, (unsigned long) local);

	INIT_WORK(&local->sched_scan_stopped_work,
		  ieee80211_sched_scan_stopped_work);

	spin_lock_init(&local->ack_status_lock);
	idr_init(&local->ack_status_frames);

	for (i = 0; i < IEEE80211_MAX_QUEUES; i++) {
		skb_queue_head_init(&local->pending[i]);
		atomic_set(&local->agg_queue_stop[i], 0);
	}
	tasklet_init(&local->tx_pending_tasklet, ieee80211_tx_pending,
		     (unsigned long)local);

	tasklet_init(&local->tasklet,
		     ieee80211_tasklet_handler,
		     (unsigned long) local);

	skb_queue_head_init(&local->skb_queue);
	skb_queue_head_init(&local->skb_queue_unreliable);

	ieee80211_led_names(local);

	ieee80211_roc_setup(local);

	return &local->hw;
 err_free:
	wiphy_free(wiphy);
	return NULL;
}
EXPORT_SYMBOL(ieee80211_alloc_hw_nm);

static int ieee80211_init_cipher_suites(struct ieee80211_local *local)
{
	bool have_wep = !(IS_ERR(local->wep_tx_tfm) ||
			  IS_ERR(local->wep_rx_tfm));
	bool have_mfp = local->hw.flags & IEEE80211_HW_MFP_CAPABLE;
	int n_suites = 0, r = 0, w = 0;
	u32 *suites;
	static const u32 cipher_suites[] = {
		/* keep WEP first, it may be removed below */
		WLAN_CIPHER_SUITE_WEP40,
		WLAN_CIPHER_SUITE_WEP104,
		WLAN_CIPHER_SUITE_TKIP,
		WLAN_CIPHER_SUITE_CCMP,
		WLAN_CIPHER_SUITE_CCMP_256,
		WLAN_CIPHER_SUITE_GCMP,
		WLAN_CIPHER_SUITE_GCMP_256,

		/* keep last -- depends on hw flags! */
		WLAN_CIPHER_SUITE_AES_CMAC,
		WLAN_CIPHER_SUITE_BIP_CMAC_256,
		WLAN_CIPHER_SUITE_BIP_GMAC_128,
		WLAN_CIPHER_SUITE_BIP_GMAC_256,
	};

	if (local->hw.flags & IEEE80211_HW_SW_CRYPTO_CONTROL ||
	    local->hw.wiphy->cipher_suites) {
		/* If the driver advertises, or doesn't support SW crypto,
		 * we only need to remove WEP if necessary.
		 */
		if (have_wep)
			return 0;

		/* well if it has _no_ ciphers ... fine */
		if (!local->hw.wiphy->n_cipher_suites)
			return 0;

		/* Driver provides cipher suites, but we need to exclude WEP */
		suites = kmemdup(local->hw.wiphy->cipher_suites,
				 sizeof(u32) * local->hw.wiphy->n_cipher_suites,
				 GFP_KERNEL);
		if (!suites)
			return -ENOMEM;

		for (r = 0; r < local->hw.wiphy->n_cipher_suites; r++) {
			u32 suite = local->hw.wiphy->cipher_suites[r];

			if (suite == WLAN_CIPHER_SUITE_WEP40 ||
			    suite == WLAN_CIPHER_SUITE_WEP104)
				continue;
			suites[w++] = suite;
		}
	} else if (!local->hw.cipher_schemes) {
		/* If the driver doesn't have cipher schemes, there's nothing
		 * else to do other than assign the (software supported and
		 * perhaps offloaded) cipher suites.
		 */
		local->hw.wiphy->cipher_suites = cipher_suites;