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
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
5201
5202
5203
5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
5294
5295
5296
5297
5298
5299
5300
5301
5302
5303
5304
5305
5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
5327
5328
5329
5330
5331
5332
5333
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343
5344
5345
5346
5347
5348
5349
5350
5351
5352
5353
5354
5355
5356
5357
5358
5359
5360
5361
5362
5363
5364
5365
5366
5367
5368
5369
5370
5371
5372
5373
5374
5375
5376
5377
5378
5379
5380
5381
5382
5383
5384
5385
5386
5387
5388
5389
5390
5391
5392
5393
5394
5395
5396
5397
5398
5399
5400
5401
5402
5403
5404
5405
5406
5407
5408
5409
5410
5411
5412
5413
5414
5415
5416
5417
5418
5419
5420
5421
5422
5423
5424
5425
5426
5427
5428
5429
5430
5431
5432
5433
5434
5435
5436
5437
5438
5439
5440
5441
5442
5443
5444
5445
5446
5447
5448
5449
5450
5451
5452
5453
5454
5455
5456
5457
5458
5459
5460
5461
5462
5463
5464
5465
5466
5467
5468
5469
5470
5471
5472
5473
5474
5475
5476
5477
5478
5479
5480
5481
5482
5483
5484
5485
5486
5487
5488
5489
5490
5491
5492
5493
5494
5495
5496
5497
5498
5499
5500
5501
5502
5503
5504
5505
5506
5507
5508
5509
5510
5511
5512
5513
5514
5515
5516
5517
5518
5519
5520
5521
5522
5523
5524
5525
5526
5527
5528
5529
5530
5531
5532
5533
5534
5535
5536
5537
5538
5539
5540
5541
5542
5543
5544
5545
5546
5547
5548
5549
5550
5551
5552
5553
5554
5555
5556
5557
5558
5559
5560
5561
5562
5563
5564
5565
5566
5567
5568
5569
5570
5571
5572
5573
5574
5575
5576
5577
5578
5579
5580
5581
5582
5583
5584
5585
5586
5587
5588
5589
5590
5591
5592
5593
5594
5595
5596
5597
5598
5599
5600
5601
5602
5603
5604
5605
5606
5607
5608
5609
5610
5611
5612
5613
5614
5615
5616
5617
5618
5619
5620
5621
5622
5623
5624
5625
5626
5627
5628
5629
5630
5631
5632
5633
5634
5635
5636
5637
5638
5639
5640
5641
5642
5643
5644
5645
5646
5647
5648
5649
5650
5651
5652
5653
5654
5655
5656
5657
5658
5659
5660
5661
5662
5663
5664
5665
5666
5667
5668
5669
5670
5671
5672
5673
5674
5675
5676
5677
5678
5679
5680
5681
5682
5683
5684
5685
5686
5687
5688
5689
5690
5691
5692
5693
5694
5695
5696
5697
5698
5699
5700
5701
5702
5703
5704
5705
5706
5707
5708
5709
5710
5711
5712
5713
5714
5715
5716
5717
5718
5719
5720
5721
5722
5723
5724
5725
5726
5727
5728
5729
5730
5731
5732
5733
5734
5735
5736
5737
5738
5739
5740
5741
5742
5743
5744
5745
5746
5747
5748
5749
5750
5751
5752
5753
5754
5755
5756
5757
5758
5759
5760
5761
5762
5763
5764
5765
5766
5767
5768
5769
5770
5771
5772
5773
5774
5775
5776
5777
5778
5779
5780
5781
5782
5783
5784
5785
5786
5787
5788
5789
5790
5791
5792
5793
5794
5795
5796
5797
5798
5799
5800
5801
5802
5803
5804
5805
5806
5807
5808
5809
5810
5811
5812
5813
5814
5815
5816
5817
5818
5819
5820
5821
5822
5823
5824
5825
5826
5827
5828
5829
5830
5831
5832
5833
5834
5835
5836
5837
5838
5839
5840
5841
5842
5843
5844
5845
5846
5847
5848
5849
5850
5851
5852
5853
5854
5855
5856
5857
5858
5859
5860
5861
5862
5863
5864
5865
5866
5867
5868
5869
5870
5871
5872
5873
5874
5875
5876
5877
5878
5879
5880
5881
5882
5883
5884
5885
5886
5887
5888
5889
5890
5891
5892
5893
5894
5895
5896
5897
5898
5899
5900
5901
5902
5903
5904
5905
5906
5907
5908
5909
5910
5911
5912
5913
5914
5915
5916
5917
5918
5919
5920
5921
5922
5923
5924
5925
5926
5927
5928
5929
5930
5931
5932
5933
5934
5935
5936
5937
5938
5939
5940
5941
5942
5943
5944
5945
5946
5947
5948
5949
5950
5951
5952
5953
5954
5955
5956
5957
5958
5959
5960
5961
5962
5963
5964
5965
5966
5967
5968
5969
5970
5971
5972
5973
5974
5975
5976
5977
5978
5979
5980
5981
5982
5983
5984
5985
5986
5987
5988
5989
5990
5991
5992
5993
5994
5995
5996
5997
5998
5999
6000
6001
6002
6003
6004
6005
6006
6007
6008
6009
6010
6011
6012
6013
6014
6015
6016
6017
6018
6019
6020
6021
6022
6023
6024
6025
6026
6027
6028
6029
6030
6031
6032
6033
6034
6035
6036
6037
6038
6039
6040
6041
6042
6043
6044
6045
6046
6047
6048
6049
6050
6051
6052
6053
6054
6055
6056
6057
6058
6059
6060
6061
6062
6063
6064
6065
6066
6067
6068
6069
6070
6071
6072
6073
6074
6075
6076
6077
6078
6079
6080
6081
6082
6083
6084
6085
6086
6087
6088
6089
6090
6091
6092
6093
6094
6095
6096
6097
6098
6099
6100
6101
6102
6103
6104
6105
6106
6107
6108
6109
6110
6111
6112
6113
6114
6115
6116
6117
6118
6119
6120
6121
6122
6123
6124
6125
6126
6127
6128
6129
6130
6131
6132
6133
6134
6135
6136
6137
6138
6139
6140
6141
6142
6143
6144
6145
6146
6147
6148
6149
6150
6151
6152
6153
6154
6155
6156
6157
6158
6159
6160
6161
6162
6163
6164
6165
6166
6167
6168
6169
6170
6171
6172
6173
6174
6175
6176
6177
6178
6179
6180
6181
6182
6183
6184
6185
6186
6187
6188
6189
6190
6191
6192
6193
6194
6195
6196
6197
6198
6199
6200
6201
6202
6203
6204
6205
6206
6207
6208
6209
6210
6211
6212
6213
6214
6215
6216
6217
6218
6219
6220
6221
6222
6223
6224
6225
6226
6227
6228
6229
6230
6231
6232
6233
6234
6235
6236
6237
6238
6239
6240
6241
6242
6243
6244
6245
6246
6247
6248
6249
6250
6251
6252
6253
6254
6255
6256
6257
6258
6259
6260
6261
6262
6263
6264
6265
6266
6267
6268
6269
6270
6271
6272
6273
6274
6275
6276
6277
6278
6279
6280
6281
6282
6283
6284
6285
6286
6287
6288
6289
6290
6291
6292
6293
6294
6295
6296
6297
6298
6299
6300
6301
6302
6303
6304
6305
6306
6307
6308
6309
6310
6311
6312
6313
6314
6315
6316
6317
6318
6319
6320
6321
6322
6323
6324
6325
6326
6327
6328
6329
6330
6331
6332
6333
6334
6335
6336
6337
6338
6339
6340
6341
6342
6343
6344
6345
6346
6347
6348
6349
6350
6351
6352
6353
6354
6355
6356
6357
6358
6359
6360
6361
6362
6363
6364
6365
6366
6367
6368
6369
6370
6371
6372
6373
6374
6375
6376
6377
6378
6379
6380
6381
6382
6383
6384
6385
6386
6387
6388
6389
6390
6391
6392
6393
6394
6395
6396
6397
6398
6399
6400
6401
6402
6403
6404
6405
6406
6407
6408
6409
6410
6411
6412
6413
6414
6415
6416
6417
6418
6419
6420
6421
6422
6423
6424
6425
6426
6427
6428
6429
6430
6431
6432
6433
6434
6435
6436
6437
6438
6439
6440
6441
6442
6443
6444
6445
6446
6447
6448
6449
6450
6451
6452
6453
6454
6455
6456
6457
6458
6459
6460
6461
6462
6463
6464
6465
6466
6467
6468
6469
6470
6471
6472
6473
6474
6475
6476
6477
6478
6479
6480
6481
6482
6483
6484
6485
6486
6487
6488
6489
6490
6491
6492
6493
6494
6495
6496
6497
6498
6499
6500
6501
6502
6503
6504
6505
6506
6507
6508
6509
6510
6511
6512
6513
6514
6515
6516
6517
6518
6519
6520
6521
6522
6523
6524
6525
6526
6527
6528
6529
6530
6531
6532
6533
6534
6535
6536
6537
6538
6539
6540
6541
6542
6543
6544
6545
6546
6547
6548
6549
6550
6551
6552
6553
6554
6555
6556
6557
6558
6559
6560
6561
6562
6563
6564
6565
6566
6567
6568
6569
6570
6571
6572
6573
6574
6575
6576
6577
6578
6579
6580
6581
6582
6583
6584
6585
6586
6587
6588
6589
6590
6591
6592
6593
6594
6595
6596
6597
6598
6599
6600
6601
6602
6603
6604
6605
6606
6607
6608
6609
6610
6611
6612
6613
6614
6615
6616
6617
6618
6619
6620
6621
6622
6623
6624
6625
6626
6627
6628
6629
6630
6631
6632
6633
6634
6635
6636
6637
6638
6639
6640
6641
6642
6643
6644
6645
6646
6647
6648
6649
6650
6651
6652
6653
6654
6655
6656
6657
6658
6659
6660
6661
6662
6663
6664
6665
6666
6667
6668
6669
6670
6671
6672
6673
6674
6675
6676
6677
6678
6679
6680
6681
6682
6683
6684
6685
6686
6687
6688
6689
6690
6691
6692
6693
6694
6695
6696
6697
6698
6699
6700
6701
6702
6703
6704
6705
6706
6707
6708
6709
6710
6711
6712
6713
6714
6715
6716
6717
6718
6719
6720
6721
6722
6723
6724
6725
6726
6727
6728
6729
6730
6731
6732
6733
6734
6735
6736
6737
6738
6739
6740
6741
6742
6743
6744
6745
6746
6747
6748
6749
6750
6751
6752
6753
6754
6755
6756
6757
6758
6759
6760
6761
6762
6763
6764
6765
6766
6767
6768
6769
6770
6771
6772
6773
6774
6775
6776
6777
6778
6779
6780
6781
6782
6783
6784
6785
6786
6787
6788
6789
6790
6791
6792
6793
6794
6795
6796
6797
6798
6799
6800
6801
6802
6803
6804
6805
6806
6807
6808
6809
6810
6811
6812
6813
6814
6815
6816
6817
6818
6819
6820
6821
6822
6823
6824
6825
6826
6827
6828
6829
6830
6831
6832
6833
6834
6835
6836
6837
6838
6839
6840
6841
6842
6843
6844
6845
6846
6847
6848
6849
6850
6851
6852
6853
6854
6855
6856
6857
6858
6859
6860
6861
6862
6863
6864
6865
6866
6867
6868
6869
6870
6871
6872
6873
6874
6875
6876
6877
6878
6879
6880
6881
6882
6883
6884
6885
6886
6887
6888
6889
6890
6891
6892
6893
6894
6895
6896
6897
6898
6899
6900
6901
6902
6903
6904
6905
6906
6907
6908
6909
6910
6911
6912
6913
6914
6915
6916
6917
6918
6919
6920
6921
6922
6923
6924
6925
6926
6927
6928
6929
6930
6931
6932
6933
6934
6935
6936
6937
6938
6939
6940
6941
6942
6943
6944
6945
6946
6947
6948
6949
6950
6951
6952
6953
6954
6955
6956
6957
6958
6959
6960
6961
6962
6963
6964
6965
6966
6967
6968
6969
6970
6971
6972
6973
6974
6975
6976
6977
6978
6979
|
/** @file moal_ioctl.c
*
* @brief This file contains ioctl function to MLAN
*
*
* Copyright 2014-2020 NXP
*
* This software file (the File) is distributed by NXP
* under the terms of the GNU General Public License Version 2, June 1991
* (the License). You may use, redistribute and/or modify the File in
* accordance with the terms and conditions of the License, a copy of which
* is available by writing to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
* worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
*
* THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
* IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
* ARE EXPRESSLY DISCLAIMED. The License provides additional details about
* this warranty disclaimer.
*
*/
/********************************************************
Change log:
10/21/2008: initial version
********************************************************/
#include "moal_main.h"
#include "moal_eth_ioctl.h"
#ifdef SDIO
#include "moal_sdio.h"
#endif
#ifdef USB
#include "moal_usb.h"
#endif
#ifdef UAP_SUPPORT
#include "moal_uap.h"
#endif
#if defined(STA_CFG80211) || defined(UAP_CFG80211)
#include "moal_cfg80211.h"
#if CFG80211_VERSION_CODE >= KERNEL_VERSION(3, 14, 0)
#include "moal_cfg80211_util.h"
#endif
#endif
/********************************************************
Local Variables
********************************************************/
#define MRVL_TLV_HEADER_SIZE 4
/* NXP Channel config TLV ID */
#define MRVL_CHANNELCONFIG_TLV_ID (0x0100 + 0x2a) /* 0x012a */
typedef struct _hostcmd_header {
/** Command Header : Command */
t_u16 command;
/** Command Header : Size */
t_u16 size;
/** Command Header : Sequence number */
t_u16 seq_num;
/** Command Header : Result */
t_u16 result;
/** Command action */
t_u16 action;
} hostcmd_header, *phostcmd_header;
/** Region code mapping */
typedef struct _region_code_mapping_t {
/** Region */
t_u8 region[COUNTRY_CODE_LEN];
/** Code */
t_u8 code;
} region_code_mapping_t;
#define EU_REGION_CODE 0x30
/** Region code mapping table */
static region_code_mapping_t region_code_mapping[] = {
{"US", 0x10}, /* US FCC */
{"CA", 0x20}, /* IC Canada */
{"SG", 0x10}, /* Singapore */
{"EU", 0x30}, /* ETSI */
{"AU", 0x30}, /* Australia */
{"KR", 0x30}, /* Republic Of Korea */
{"JP", 0x40}, /* Japan */
{"CN", 0x50}, /* China */
{"BR", 0x09}, /* Brazil */
{"RU", 0x0f}, /* Russia */
{"IN", 0x06}, /* India */
{"MY", 0x06}, /* Malaysia */
{"MX", 0x07}, /* Mexico */
{"NE", 0x30}, /* New Zeland */
};
/** EEPROM Region code mapping table */
static region_code_mapping_t hw_region_code_mapping[] = {
{"US ", 0x10}, /* US FCC */
{"CA ", 0x20}, /* IC Canada */
{"KR ", 0x30}, /* Korea */
{"CN ", 0x50}, /* China */
{"ES ", 0x31}, /* Spain */
{"FR ", 0x32}, /* France */
{"JP ", 0x40}, /* Japan */
{"JP ", 0x41}, /* Japan */
};
/** Country code for ETSI */
static t_u8 eu_country_code_table[][COUNTRY_CODE_LEN] = {
"AL", "AD", "AT", "AU", "BY", "BE", "BA", "BG", "HR", "CY", "CZ", "DK",
"EE", "FI", "FR", "MK", "DE", "GR", "HU", "IS", "IE", "IT", "KR", "LV",
"LI", "LT", "LU", "MT", "MD", "MC", "ME", "NL", "NO", "PL", "RO", "RU",
"SM", "RS", "SI", "SK", "ES", "SE", "CH", "TR", "UA", "UK", "GB", "NE"};
/********************************************************
Global Variables
********************************************************/
#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 29)
#ifdef UAP_SUPPORT
/** Network device handlers for uAP */
extern const struct net_device_ops woal_uap_netdev_ops;
#endif
#ifdef STA_SUPPORT
/** Network device handlers for STA */
extern const struct net_device_ops woal_netdev_ops;
#endif
#endif
#ifdef MFG_CMD_SUPPORT
/** Mfg mode */
extern int mfg_mode;
#endif
/********************************************************
Local Functions
********************************************************/
/**
* @brief This function converts region string to region code
*
* @param country_code Region string
*
* @return Region code
*/
t_bool woal_is_country_code_supported(t_u8 *country_code)
{
t_u8 i;
ENTER();
for (i = 0; i < ARRAY_SIZE(region_code_mapping); i++) {
if (!memcmp(country_code, region_code_mapping[i].region,
COUNTRY_CODE_LEN - 1)) {
PRINTM(MIOCTL,
"found country code in region_code table\n");
LEAVE();
return MTRUE;
}
}
LEAVE();
return MFALSE;
}
/**
* @brief This function converts region string to region code
*
* @param region_string Region string
*
* @return Region code
*/
t_u8 region_string_2_region_code(char *region_string)
{
t_u8 i;
ENTER();
for (i = 0; i < ARRAY_SIZE(region_code_mapping); i++) {
if (!memcmp(region_string, region_code_mapping[i].region,
strlen(region_string))) {
LEAVE();
return region_code_mapping[i].code;
}
}
/* If still not found, look for code in EU country code table */
for (i = 0; i < ARRAY_SIZE(eu_country_code_table); i++) {
if (!memcmp(region_string, eu_country_code_table[i],
COUNTRY_CODE_LEN - 1)) {
PRINTM(MIOCTL, "found region code=%d in EU table\n",
EU_REGION_CODE);
LEAVE();
return EU_REGION_CODE;
}
}
/* Default is US */
LEAVE();
return region_code_mapping[0].code;
}
/**
* @brief This function converts region string to region code
*
* @param country_code Region string
*
* @return Region code
*/
t_bool woal_is_etsi_country(t_u8 *country_code)
{
t_u8 i;
ENTER();
for (i = 0; i < ARRAY_SIZE(eu_country_code_table); i++) {
if (!memcmp(country_code, eu_country_code_table[i],
COUNTRY_CODE_LEN - 1)) {
PRINTM(MIOCTL, "found region code=%d in EU table\n",
EU_REGION_CODE);
LEAVE();
return MTRUE;
}
}
LEAVE();
return MFALSE;
}
/**
* @brief This function converts region string to region code
*
* @param region_code region code
*
* @return Region string or NULL
*/
char *region_code_2_string(t_u8 region_code)
{
t_u8 i;
ENTER();
for (i = 0; i < ARRAY_SIZE(hw_region_code_mapping); i++) {
if (hw_region_code_mapping[i].code == region_code) {
LEAVE();
return hw_region_code_mapping[i].region;
}
}
LEAVE();
return NULL;
}
t_u8 woal_is_valid_alpha2(char *alpha2)
{
if (!alpha2 || strlen(alpha2) < 2)
return MFALSE;
if (isalpha(alpha2[0]) && isalpha(alpha2[1]))
return MTRUE;
return MFALSE;
}
/**
* @brief Get second channel offset
*
* @param chan channel num
* @return second channel offset
*/
t_u8 woal_get_second_channel_offset(int chan)
{
t_u8 chan2Offset = SEC_CHAN_NONE;
switch (chan) {
case 36:
case 44:
case 52:
case 60:
case 100:
case 108:
case 116:
case 124:
case 132:
case 140:
case 149:
case 157:
chan2Offset = SEC_CHAN_ABOVE;
break;
case 40:
case 48:
case 56:
case 64:
case 104:
case 112:
case 120:
case 128:
case 136:
case 144:
case 153:
case 161:
chan2Offset = SEC_CHAN_BELOW;
break;
case 165:
/* Special Case: 20Mhz-only Channel */
chan2Offset = SEC_CHAN_NONE;
break;
}
return chan2Offset;
}
/**
* @brief Copy mc address to the mlist
*
* @param mlist A pointer to mlan_multicast_list structure
* @param mac mc address
*
* @return N/A
*/
static inline void woal_copy_mc_addr(mlan_multicast_list *mlist,
mlan_802_11_mac_addr mac)
{
int i = 0;
for (i = 0; i < mlist->num_multicast_addr; i++) {
if (!memcmp(&mlist->mac_list[i], mac, ETH_ALEN))
return;
}
if (mlist->num_multicast_addr < MLAN_MAX_MULTICAST_LIST_SIZE)
moal_memcpy_ext(NULL,
&mlist->mac_list[mlist->num_multicast_addr],
mac, ETH_ALEN, sizeof(mlan_802_11_mac_addr));
mlist->num_multicast_addr++;
return;
}
/**
* @brief Copy multicast table
*
* @param mlist A pointer to mlan_multicast_list structure
* @param dev A pointer to net_device structure
*
* @return Number of multicast addresses
*/
static inline int woal_copy_mcast_addr(mlan_multicast_list *mlist,
struct net_device *dev)
{
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 35)
struct dev_mc_list *mcptr = dev->mc_list;
int i = 0;
#else
struct netdev_hw_addr *mcptr = NULL;
#endif /* < 2.6.35 */
ENTER();
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 35)
for (i = 0; i < dev->mc_count && mcptr; i++) {
woal_copy_mc_addr(mlist, mcptr->dmi_addr);
mcptr = mcptr->next;
}
#else
netdev_for_each_mc_addr (mcptr, dev)
woal_copy_mc_addr(mlist, mcptr->addr);
#endif /* < 2.6.35 */
LEAVE();
return mlist->num_multicast_addr;
}
/**
* @brief copy mc list from all the active interface
*
* @param handle A pointer to moal_handle
* @param mlist A pointer to multicast list
*
* @return total_mc_count
*/
static int woal_copy_all_mc_list(moal_handle *handle,
mlan_multicast_list *mlist)
{
int i;
moal_private *priv = NULL;
#ifdef STA_SUPPORT
int mc_count = 0;
#endif
ENTER();
for (i = 0; i < handle->priv_num && (priv = handle->priv[i]); i++) {
#ifdef STA_SUPPORT
if (GET_BSS_ROLE(handle->priv[i]) == MLAN_BSS_ROLE_STA) {
if (handle->priv[i]->media_connected == MTRUE) {
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 35)
mc_count = priv->netdev->mc_count;
#else
mc_count = netdev_mc_count(priv->netdev);
#endif
if (mc_count)
woal_copy_mcast_addr(mlist,
priv->netdev);
}
}
#endif
}
PRINTM(MIOCTL, "total mc_count=%d\n", mlist->num_multicast_addr);
LEAVE();
return mlist->num_multicast_addr;
}
/**
* @brief Fill in wait queue
*
* @param priv A pointer to moal_private structure
* @param wait A pointer to wait_queue structure
* @param wait_option Wait option
*
* @return N/A
*/
static inline void woal_fill_wait_queue(moal_private *priv, wait_queue *wait,
t_u8 wait_option)
{
ENTER();
wait->start_time = jiffies;
wait->condition = MFALSE;
wait->wait_timeout = MFALSE;
switch (wait_option) {
case MOAL_NO_WAIT:
break;
case MOAL_IOCTL_WAIT:
init_waitqueue_head(&wait->wait);
break;
case MOAL_IOCTL_WAIT_TIMEOUT:
init_waitqueue_head(&wait->wait);
wait->wait_timeout = MTRUE;
break;
}
LEAVE();
return;
}
/**
* @brief Wait mlan ioctl complete
*
* @param priv A pointer to moal_private structure
* @param req A pointer to mlan_ioctl_req structure
* @param wait_option Wait option
*
* @return N/A
*/
static inline mlan_status woal_wait_ioctl_complete(moal_private *priv,
mlan_ioctl_req *req,
t_u8 wait_option)
{
mlan_status status;
wait_queue *wait = (wait_queue *)req->reserved_1;
unsigned long flags;
ENTER();
priv->phandle->ioctl_timeout = MFALSE;
switch (wait_option) {
case MOAL_NO_WAIT:
break;
case MOAL_IOCTL_WAIT:
while (wait_event_interruptible_exclusive(
wait->wait, wait->condition) == -ERESTARTSYS &&
wait->retry < MAX_RETRY_CNT) {
wait->retry++;
}
break;
case MOAL_IOCTL_WAIT_TIMEOUT:
wait_event_timeout(wait->wait, wait->condition,
MOAL_IOCTL_TIMEOUT);
break;
}
spin_lock_irqsave(&priv->phandle->driver_lock, flags);
if (wait->condition == MFALSE) {
if (wait_option == MOAL_IOCTL_WAIT_TIMEOUT) {
priv->phandle->ioctl_timeout = MTRUE;
PRINTM(MMSG,
"wlan: IOCTL timeout %p id=0x%x, sub_id=0x%x, wait_option=%d, action=%d\n",
req, req->req_id, (*(t_u32 *)req->pbuf),
wait_option, (int)req->action);
} else {
PRINTM(MMSG,
"wlan: IOCTL by signal %p id=0x%x, sub_id=0x%x, wait_option=%d, action=%d\n",
req, req->req_id, (*(t_u32 *)req->pbuf),
wait_option, (int)req->action);
}
req->reserved_1 = 0;
status = MLAN_STATUS_PENDING;
} else {
status = wait->status;
}
spin_unlock_irqrestore(&priv->phandle->driver_lock, flags);
LEAVE();
return status;
}
/**
* @brief CAC period block cmd handler
*
* @param priv A pointer to moal_private structure
* @param req A pointer to mlan_ioctl_req buffer
*
* @return MTRUE/MFALSE
*/
static inline t_bool woal_cac_period_block_cmd(moal_private *priv,
pmlan_ioctl_req req)
{
mlan_status ret = MFALSE;
t_u32 sub_command;
ENTER();
if (req == NULL || req->pbuf == NULL)
goto done;
sub_command = *(t_u32 *)req->pbuf;
switch (req->req_id) {
case MLAN_IOCTL_SCAN:
if (sub_command == MLAN_OID_SCAN_NORMAL ||
sub_command == MLAN_OID_SCAN_SPECIFIC_SSID ||
sub_command == MLAN_OID_SCAN_USER_CONFIG)
ret = MTRUE;
break;
case MLAN_IOCTL_BSS:
if (sub_command == MLAN_OID_BSS_STOP ||
sub_command == MLAN_OID_BSS_CHANNEL
/* sub_command == MLAN_OID_BSS_ROLE */)
ret = MTRUE;
#ifdef UAP_SUPPORT
else if (sub_command == MLAN_OID_UAP_BSS_CONFIG) {
mlan_ds_bss *bss = (mlan_ds_bss *)req->pbuf;
if (bss->param.bss_config.channel)
ret = MTRUE;
else
ret = MFALSE;
}
#endif
break;
case MLAN_IOCTL_RADIO_CFG:
if (sub_command == MLAN_OID_BAND_CFG ||
sub_command == MLAN_OID_REMAIN_CHAN_CFG)
ret = MTRUE;
break;
case MLAN_IOCTL_SNMP_MIB:
if (sub_command == MLAN_OID_SNMP_MIB_DOT11D)
ret = MTRUE;
#if defined(UAP_SUPPORT)
if (sub_command == MLAN_OID_SNMP_MIB_DOT11H)
ret = MTRUE;
#endif
break;
case MLAN_IOCTL_11D_CFG:
#ifdef STA_SUPPORT
if (sub_command == MLAN_OID_11D_CFG_ENABLE)
ret = MTRUE;
#endif
#ifdef UAP_SUPPORT
if (sub_command == MLAN_OID_11D_DOMAIN_INFO)
ret = MTRUE;
#endif
if (sub_command == MLAN_OID_11D_DOMAIN_INFO_EXT)
ret = MTRUE;
break;
case MLAN_IOCTL_MISC_CFG:
if (sub_command == MLAN_OID_MISC_REGION)
ret = MTRUE;
if (sub_command == MLAN_OID_MISC_HOST_CMD) {
phostcmd_header phostcmd;
t_u8 *ptlv_buf;
t_u16 tag, length;
phostcmd =
(phostcmd_header)((pmlan_ds_misc_cfg)req->pbuf)
->param.hostcmd.cmd;
ptlv_buf = (t_u8 *)phostcmd + sizeof(hostcmd_header);
if (phostcmd->action == MLAN_ACT_SET) {
while (ptlv_buf <
(t_u8 *)phostcmd + phostcmd->size) {
tag = *(t_u16 *)ptlv_buf;
length = *(t_u16 *)(ptlv_buf + 2);
/* Check Blocking TLV here, should add
* more... */
if (tag == MRVL_CHANNELCONFIG_TLV_ID) {
ret = MTRUE;
break;
}
ptlv_buf +=
(length + MRVL_TLV_HEADER_SIZE);
}
}
}
break;
case MLAN_IOCTL_11H_CFG:
/* Prevent execute more than once */
if (sub_command == MLAN_OID_11H_CHANNEL_CHECK)
ret = MTRUE;
break;
default:
ret = MFALSE;
break;
}
done:
LEAVE();
return ret;
}
/********************************************************
Global Functions
********************************************************/
/**
* @brief Send ioctl request to MLAN
*
* @param priv A pointer to moal_private structure
* @param req A pointer to mlan_ioctl_req buffer
* @param wait_option Wait option (MOAL_WAIT or MOAL_NO_WAIT)
*
* @return MLAN_STATUS_SUCCESS/MLAN_STATUS_PENDING
* -- success, otherwise fail
*/
mlan_status woal_request_ioctl(moal_private *priv, mlan_ioctl_req *req,
t_u8 wait_option)
{
wait_queue *wait = NULL;
mlan_status status;
unsigned long flags;
t_u32 sub_command = 0;
ENTER();
if (!priv || !priv->phandle || !priv->phandle->pmlan_adapter || !req) {
PRINTM(MINFO,
"priv or priv->phandle or priv->phandle->pmlan_adapter or req is null\n");
LEAVE();
return MLAN_STATUS_FAILURE;
}
sub_command = *(t_u32 *)req->pbuf;
if (sub_command != MLAN_OID_GET_DEBUG_INFO) {
if (priv->phandle->surprise_removed == MTRUE ||
priv->phandle->driver_status) {
PRINTM(MCMND,
"IOCTL is not allowed while the device is not present or hang\n");
LEAVE();
return MLAN_STATUS_FAILURE;
}
if (priv->phandle->is_suspended == MTRUE) {
PRINTM(MCMND, "IOCTL is not allowed while suspended\n");
LEAVE();
return MLAN_STATUS_FAILURE;
}
#ifdef MFG_CMD_SUPPORT
if (mfg_mode && sub_command != MLAN_OID_MISC_HOST_CMD) {
PRINTM(MCMND, "IOCTL is not allowed while suspended\n");
LEAVE();
return MLAN_STATUS_FAILURE;
}
#endif
}
/* For MLAN_OID_MISC_HOST_CMD, action is 0, "action set" is checked
* later */
if ((req->action == MLAN_ACT_SET || req->action == 0) &&
priv->phandle->cac_period == MTRUE) {
/* CAC checking period left to complete jiffies */
long cac_left_jiffies;
/* cac_left_jiffies will be negative if and only if
* event MLAN_EVENT_ID_DRV_MEAS_REPORT recieved from FW
* after CAC measure period ends,
* usually this could be considered as a FW bug
*/
cac_left_jiffies =
priv->phandle->cac_timer_jiffies -
(jiffies - priv->phandle->meas_start_jiffies);
if (priv->phandle->cac_period_jiffies) {
cac_left_jiffies =
priv->phandle->cac_period_jiffies -
(jiffies - priv->phandle->meas_start_jiffies);
}
if (priv->phandle->cac_restart)
cac_left_jiffies = DEF_CAC_DWELL_TIME * HZ / 1000;
if (cac_left_jiffies < 0) {
/* Avoid driver hang in FW died during CAC measure
* period */
priv->phandle->cac_period = MFALSE;
PRINTM(MERROR,
"CAC measure period spends longer than scheduled time "
"or meas done event never received\n");
status = MLAN_STATUS_FAILURE;
#ifdef UAP_SUPPORT
#if defined(STA_CFG80211) || defined(UAP_CFG80211)
#if CFG80211_VERSION_CODE >= KERNEL_VERSION(3, 14, 0)
if (priv->uap_host_based &&
moal_extflg_isset(priv->phandle, EXT_DFS_OFFLOAD))
woal_cfg80211_dfs_vendor_event(
priv, event_dfs_cac_aborted,
&priv->chan);
#endif
#endif
#endif
goto done;
}
/* Check BSS START first */
if (sub_command == MLAN_OID_BSS_START) {
mlan_ds_bss *bss;
bss = (mlan_ds_bss *)req->pbuf;
/*
* Bss delay start after channel report received,
* not block the driver by delay executing. This is
* because a BSS_START cmd is always executed right
* after channel check issued.
*/
if (priv->phandle->delay_bss_start == MFALSE) {
PRINTM(MMSG,
"Received BSS Start command during CAC period, delay executing %ld seconds\n",
cac_left_jiffies / HZ);
priv->phandle->delay_bss_start = MTRUE;
moal_memcpy_ext(
priv->phandle,
&priv->phandle->delay_ssid_bssid,
&bss->param.ssid_bssid,
sizeof(mlan_ssid_bssid),
sizeof(mlan_ssid_bssid));
/* TODO: return success to allow the half below
* of routines of which calling BSS start to
* execute
*/
status = MLAN_STATUS_SUCCESS;
goto done;
} else {
/* TODO: not blocking it, just return failure */
PRINTM(MMSG,
"Only one BSS Start command allowed for delay executing!\n");
status = MLAN_STATUS_FAILURE;
goto done;
}
}
if (woal_cac_period_block_cmd(priv, req)) {
priv->phandle->meas_wait_q_woken = MFALSE;
PRINTM(MMSG,
"CAC check is on going... Blocking Command %ld seconds\n",
cac_left_jiffies / HZ);
/* blocking timeout set to 1.5 * CAC checking period
* left time */
wait_event_interruptible_timeout(
priv->phandle->meas_wait_q,
priv->phandle->meas_wait_q_woken,
cac_left_jiffies * 3 / 2);
}
}
#ifdef UAP_CFG80211
#if CFG80211_VERSION_CODE >= KERNEL_VERSION(3, 12, 0)
else if (priv->phandle->is_cac_timer_set &&
(req->action == MLAN_ACT_SET || req->action == 0)) {
if (woal_cac_period_block_cmd(priv, req)) {
PRINTM(MMSG,
"CAC check is on going... Blocking Command\n");
status = MLAN_STATUS_FAILURE;
goto done;
}
}
#endif
#endif
else if (priv->phandle->cac_period) {
PRINTM(MINFO, "Operation during CAC check period.\n");
}
wait = (wait_queue *)req->reserved_1;
req->bss_index = priv->bss_index;
if (wait_option)
woal_fill_wait_queue(priv, wait, wait_option);
else
req->reserved_1 = 0;
/* Call MLAN ioctl handle */
atomic_inc(&priv->phandle->ioctl_pending);
spin_lock_irqsave(&priv->phandle->ioctl_lock, flags);
status = mlan_ioctl(priv->phandle->pmlan_adapter, req);
spin_unlock_irqrestore(&priv->phandle->ioctl_lock, flags);
switch (status) {
case MLAN_STATUS_PENDING:
if (wait_option == MOAL_NO_WAIT)
PRINTM(MIOCTL, "IOCTL MOAL_NO_WAIT: %p\n", req);
else
PRINTM(MIOCTL,
"IOCTL pending: %p id=0x%x, sub_id=0x%x wait_option=%d, action=%d\n",
req, req->req_id, (*(t_u32 *)req->pbuf),
wait_option, (int)req->action);
/* Status pending, wake up main process */
queue_work(priv->phandle->workqueue, &priv->phandle->main_work);
/* Wait for completion */
if (wait_option)
status = woal_wait_ioctl_complete(priv, req,
wait_option);
break;
case MLAN_STATUS_SUCCESS:
case MLAN_STATUS_FAILURE:
case MLAN_STATUS_RESOURCE:
if (req)
PRINTM(MIOCTL,
"IOCTL: %p id=0x%x, sub_id=0x%x wait_option=%d, action=%d status=%d\n",
req, req->req_id, (*(t_u32 *)req->pbuf),
wait_option, (int)req->action, status);
atomic_dec(&priv->phandle->ioctl_pending);
break;
default:
atomic_dec(&priv->phandle->ioctl_pending);
break;
}
done:
LEAVE();
return status;
}
/**
* @brief Send set MAC address request to MLAN
*
* @param priv A pointer to moal_private structure
* @param wait_option wait option
*
* @return MLAN_STATUS_SUCCESS/MLAN_STATUS_PENDING
* -- success, otherwise fail
*/
mlan_status woal_request_set_mac_address(moal_private *priv, t_u8 wait_option)
{
mlan_ioctl_req *req = NULL;
mlan_ds_bss *bss = NULL;
mlan_status status;
ENTER();
/* Allocate an IOCTL request buffer */
req = (mlan_ioctl_req *)woal_alloc_mlan_ioctl_req(sizeof(mlan_ds_bss));
if (req == NULL) {
status = MLAN_STATUS_FAILURE;
goto done;
}
/* Fill request buffer */
bss = (mlan_ds_bss *)req->pbuf;
bss->sub_command = MLAN_OID_BSS_MAC_ADDR;
moal_memcpy_ext(priv->phandle, &bss->param.mac_addr, priv->current_addr,
sizeof(mlan_802_11_mac_addr),
sizeof(mlan_802_11_mac_addr));
req->req_id = MLAN_IOCTL_BSS;
req->action = MLAN_ACT_SET;
/* Send IOCTL request to MLAN */
status = woal_request_ioctl(priv, req, wait_option);
if (status == MLAN_STATUS_FAILURE) {
PRINTM(MERROR,
"set mac address failed! status=%d, error_code=0x%x\n",
status, req->status_code);
} else {
moal_memcpy_ext(priv->phandle, priv->netdev->dev_addr,
priv->current_addr, ETH_ALEN, ETH_ALEN);
HEXDUMP("priv->MacAddr:", priv->current_addr, ETH_ALEN);
}
done:
if (status != MLAN_STATUS_PENDING)
kfree(req);
LEAVE();
return status;
}
/**
* @brief Send multicast list request to MLAN
*
* @param priv A pointer to moal_private structure
* @param dev A pointer to net_device structure
*
* @return N/A
*/
void woal_request_set_multicast_list(moal_private *priv, struct net_device *dev)
{
mlan_ioctl_req *req = NULL;
mlan_ds_bss *bss = NULL;
mlan_status status;
int mc_count = 0;
ENTER();
/* Allocate an IOCTL request buffer */
req = (mlan_ioctl_req *)woal_alloc_mlan_ioctl_req(sizeof(mlan_ds_bss));
if (req == NULL) {
PRINTM(MERROR, "%s:Fail to allocate ioctl req buffer\n",
__func__);
goto done;
}
/* Fill request buffer */
bss = (mlan_ds_bss *)req->pbuf;
bss->sub_command = MLAN_OID_BSS_MULTICAST_LIST;
req->req_id = MLAN_IOCTL_BSS;
req->action = MLAN_ACT_SET;
if (dev->flags & IFF_PROMISC) {
bss->param.multicast_list.mode = MLAN_PROMISC_MODE;
} else if (dev->flags & IFF_ALLMULTI) {
bss->param.multicast_list.mode = MLAN_ALL_MULTI_MODE;
} else {
bss->param.multicast_list.mode = MLAN_MULTICAST_MODE;
mc_count = woal_copy_all_mc_list(priv->phandle,
&bss->param.multicast_list);
if (mc_count > MLAN_MAX_MULTICAST_LIST_SIZE)
bss->param.multicast_list.mode = MLAN_ALL_MULTI_MODE;
}
/* Send IOCTL request to MLAN */
status = woal_request_ioctl(priv, req, MOAL_NO_WAIT);
if (status != MLAN_STATUS_PENDING)
kfree(req);
done:
LEAVE();
return;
}
/**
* @brief Send deauth command to MLAN
*
* @param priv A pointer to moal_private structure
* @param wait_option Wait option
* @param mac MAC address to deauthenticate
* @param reason code reason code to deauthenticate
* @return MLAN_STATUS_SUCCESS/MLAN_STATUS_PENDING -- success,
* otherwise fail
*/
mlan_status woal_disconnect(moal_private *priv, t_u8 wait_option, t_u8 *mac,
t_u16 reason_code)
{
mlan_ioctl_req *req = NULL;
mlan_ds_bss *bss = NULL;
mlan_status status;
ENTER();
/* Allocate an IOCTL request buffer */
req = (mlan_ioctl_req *)woal_alloc_mlan_ioctl_req(sizeof(mlan_ds_bss));
if (req == NULL) {
status = MLAN_STATUS_FAILURE;
goto done;
}
/* Fill request buffer */
bss = (mlan_ds_bss *)req->pbuf;
bss->sub_command = MLAN_OID_BSS_STOP;
if (mac)
moal_memcpy_ext(priv->phandle,
&bss->param.deauth_param.mac_addr, mac,
sizeof(mlan_802_11_mac_addr),
sizeof(bss->param.deauth_param.mac_addr));
bss->param.deauth_param.reason_code = reason_code;
req->req_id = MLAN_IOCTL_BSS;
req->action = MLAN_ACT_SET;
/* Send IOCTL request to MLAN */
status = woal_request_ioctl(priv, req, wait_option);
done:
if (status != MLAN_STATUS_PENDING)
kfree(req);
#ifdef REASSOCIATION
priv->reassoc_required = MFALSE;
#endif /* REASSOCIATION */
LEAVE();
return status;
}
#if defined(UAP_SUPPORT)
/**
* @brief Get non-global oper class
*
* @param priv Pointer to moal_private structure
* @param bw bandwidth
* @param channel channel
* @param oper_class pointer to oper_class
* @return non-global operclass
*/
int woal_priv_get_nonglobal_operclass_by_bw_channel(moal_private *priv,
t_u8 bandwidth,
t_u8 channel,
t_u8 *oper_class)
{
int ret = 0;
mlan_ioctl_req *ioctl_req = NULL;
mlan_ds_misc_cfg *misc = NULL;
mlan_status status = MLAN_STATUS_SUCCESS;
ENTER();
ioctl_req = woal_alloc_mlan_ioctl_req(sizeof(mlan_ds_misc_cfg));
if (ioctl_req == NULL) {
ret = -ENOMEM;
goto done;
}
misc = (mlan_ds_misc_cfg *)ioctl_req->pbuf;
misc->sub_command = MLAN_OID_MISC_OPER_CLASS;
ioctl_req->req_id = MLAN_IOCTL_MISC_CFG;
ioctl_req->action = MLAN_ACT_GET;
misc->param.bw_chan_oper.bandwidth = bandwidth;
misc->param.bw_chan_oper.channel = channel;
status = woal_request_ioctl(priv, ioctl_req, MOAL_IOCTL_WAIT);
if (status != MLAN_STATUS_SUCCESS) {
ret = -EFAULT;
goto done;
}
*oper_class = misc->param.bw_chan_oper.oper_class;
done:
if (status != MLAN_STATUS_PENDING)
kfree(ioctl_req);
LEAVE();
return ret;
}
#endif
/**
* @brief Send bss_start command to MLAN
*
* @param priv A pointer to moal_private structure
* @param wait_option Wait option
* @param ssid_bssid A point to mlan_ssid_bssid structure
*
* @return MLAN_STATUS_SUCCESS/MLAN_STATUS_PENDING -- success,
* otherwise fail
*/
mlan_status woal_bss_start(moal_private *priv, t_u8 wait_option,
mlan_ssid_bssid *ssid_bssid)
{
mlan_ioctl_req *req = NULL;
mlan_ds_bss *bss = NULL;
mlan_status status;
ENTER();
/* Stop the O.S. TX queue When we are roaming */
woal_stop_queue(priv->netdev);
if (priv->media_connected == MFALSE) {
if (netif_carrier_ok(priv->netdev))
netif_carrier_off(priv->netdev);
}
/* Allocate an IOCTL request buffer */
req = (mlan_ioctl_req *)woal_alloc_mlan_ioctl_req(sizeof(mlan_ds_bss));
if (req == NULL) {
status = MLAN_STATUS_FAILURE;
goto done;
}
/* Fill request buffer */
bss = (mlan_ds_bss *)req->pbuf;
bss->sub_command = MLAN_OID_BSS_START;
if (ssid_bssid)
moal_memcpy_ext(priv->phandle, &bss->param.ssid_bssid,
ssid_bssid, sizeof(mlan_ssid_bssid),
sizeof(mlan_ssid_bssid));
req->req_id = MLAN_IOCTL_BSS;
req->action = MLAN_ACT_SET;
/* Send IOCTL request to MLAN */
status = woal_request_ioctl(priv, req, wait_option);
if (ssid_bssid)
moal_memcpy_ext(priv->phandle, ssid_bssid,
&bss->param.ssid_bssid, sizeof(mlan_ssid_bssid),
sizeof(mlan_ssid_bssid));
#ifdef STA_CFG80211
#ifdef STA_SUPPORT
priv->assoc_status = req->status_code;
#endif
#endif
done:
if (status != MLAN_STATUS_PENDING)
kfree(req);
LEAVE();
return status;
}
/**
* @brief Get BSS info
*
* @param priv A pointer to moal_private structure
* @param wait_option Wait option
* @param bss_info A pointer to mlan_bss_info structure
*
* @return MLAN_STATUS_SUCCESS/MLAN_STATUS_PENDING --
* success, otherwise fail
*/
mlan_status woal_get_bss_info(moal_private *priv, t_u8 wait_option,
mlan_bss_info *bss_info)
{
mlan_ioctl_req *req = NULL;
mlan_ds_get_info *info = NULL;
mlan_status status = MLAN_STATUS_SUCCESS;
ENTER();
/* Allocate an IOCTL request buffer */
req = woal_alloc_mlan_ioctl_req(sizeof(mlan_ds_get_info));
if (req == NULL) {
PRINTM(MERROR,
"Fail to allocate the buffer for get bss_info\n");
status = MLAN_STATUS_FAILURE;
goto done;
}
/* Fill request buffer */
info = (mlan_ds_get_info *)req->pbuf;
info->sub_command = MLAN_OID_GET_BSS_INFO;
req->req_id = MLAN_IOCTL_GET_INFO;
req->action = MLAN_ACT_GET;
/* Send IOCTL request to MLAN */
status = woal_request_ioctl(priv, req, wait_option);
if (status == MLAN_STATUS_SUCCESS) {
if (bss_info)
moal_memcpy_ext(priv->phandle, bss_info,
&info->param.bss_info,
sizeof(mlan_bss_info),
sizeof(mlan_bss_info));
}
done:
if (status != MLAN_STATUS_PENDING)
kfree(req);
LEAVE();
return status;
}
/**
* @brief Set/Get generic IE
*
* @param priv A pointer to moal_private structure
* @param action Action set or get
* @param ie Information element
* @param ie_len Length of the IE
* @param wait_option wait option
*
* @return MLAN_STATUS_SUCCESS -- success, otherwise fail
*/
mlan_status woal_set_get_gen_ie(moal_private *priv, t_u32 action, t_u8 *ie,
int *ie_len, t_u8 wait_option)
{
mlan_status ret = MLAN_STATUS_SUCCESS;
mlan_ds_misc_cfg *misc = NULL;
mlan_ioctl_req *req = NULL;
ENTER();
if ((action == MLAN_ACT_GET) && (ie == NULL || ie_len == NULL)) {
ret = MLAN_STATUS_FAILURE;
goto done;
}
if (action == MLAN_ACT_SET && *ie_len > MAX_IE_SIZE) {
ret = MLAN_STATUS_FAILURE;
goto done;
}
req = woal_alloc_mlan_ioctl_req(sizeof(mlan_ds_misc_cfg));
if (req == NULL) {
ret = MLAN_STATUS_FAILURE;
goto done;
}
misc = (mlan_ds_misc_cfg *)req->pbuf;
misc->sub_command = MLAN_OID_MISC_GEN_IE;
req->req_id = MLAN_IOCTL_MISC_CFG;
req->action = action;
misc->param.gen_ie.type = MLAN_IE_TYPE_GEN_IE;
if (action == MLAN_ACT_SET) {
misc->param.gen_ie.len = *ie_len;
if (*ie_len)
moal_memcpy_ext(priv->phandle,
misc->param.gen_ie.ie_data, ie, *ie_len,
MAX_IE_SIZE);
}
ret = woal_request_ioctl(priv, req, wait_option);
if (ret != MLAN_STATUS_SUCCESS)
goto done;
if (action == MLAN_ACT_GET) {
*ie_len = misc->param.gen_ie.len;
if (*ie_len)
moal_memcpy_ext(priv->phandle, ie,
misc->param.gen_ie.ie_data, *ie_len,
*ie_len);
}
done:
if (ret != MLAN_STATUS_PENDING)
kfree(req);
LEAVE();
return ret;
}
#ifdef STA_SUPPORT
/**
* @brief Set/Get retry count
*
* @param priv A pointer to moal_private structure
* @param action Action set or get
* @param wait_option Wait option
* @param value Retry value
*
* @return MLAN_STATUS_SUCCESS/MLAN_STATUS_PENDING --
* success, otherwise fail
*/
mlan_status woal_set_get_retry(moal_private *priv, t_u32 action,
t_u8 wait_option, int *value)
{
mlan_ioctl_req *req = NULL;
mlan_ds_snmp_mib *mib = NULL;
mlan_status ret = MLAN_STATUS_SUCCESS;
ENTER();
/* Allocate an IOCTL request buffer */
req = woal_alloc_mlan_ioctl_req(sizeof(mlan_ds_snmp_mib));
if (req == NULL) {
ret = MLAN_STATUS_FAILURE;
goto done;
}
/* Fill request buffer */
mib = (mlan_ds_snmp_mib *)req->pbuf;
mib->sub_command = MLAN_OID_SNMP_MIB_RETRY_COUNT;
req->req_id = MLAN_IOCTL_SNMP_MIB;
req->action = action;
if (action == MLAN_ACT_SET) {
if (*value < MLAN_TX_RETRY_MIN || *value > MLAN_TX_RETRY_MAX) {
ret = MLAN_STATUS_FAILURE;
goto done;
}
mib->param.retry_count = *value;
}
/* Send IOCTL request to MLAN */
ret = woal_request_ioctl(priv, req, wait_option);
if (ret == MLAN_STATUS_SUCCESS && action == MLAN_ACT_GET)
*value = mib->param.retry_count;
#ifdef STA_CFG80211
/* If set is invoked from other than iw i.e iwconfig,
* wiphy retry count should be updated as well */
if (IS_STA_CFG80211(priv->phandle->params.cfg80211_wext) &&
priv->wdev && priv->wdev->wiphy &&
(GET_BSS_ROLE(priv) == MLAN_BSS_ROLE_STA) &&
(action == MLAN_ACT_SET)) {
priv->wdev->wiphy->retry_long = (t_u8)*value;
priv->wdev->wiphy->retry_short = (t_u8)*value;
}
#endif
done:
if (ret != MLAN_STATUS_PENDING)
kfree(req);
LEAVE();
return ret;
}
/**
* @brief Performs pre-warm-reset
*
* @param priv A pointer to moal_private structure
*
* @return 0 if successful else negative value
*/
int woal_pre_warmreset(moal_private *priv)
{
moal_handle *handle = priv->phandle;
int ret = 0;
int intf_num;
#ifdef WIFI_DIRECT_SUPPORT
#if defined(STA_SUPPORT) && defined(UAP_SUPPORT)
#if defined(STA_WEXT) || defined(UAP_WEXT)
t_u8 bss_role = MLAN_BSS_ROLE_STA;
#endif
#endif
#endif /* WIFI_DIRECT_SUPPORT */
ENTER();
#ifdef USB
#ifdef CONFIG_USB_SUSPEND
if (IS_USB(handle->card_type) && handle->is_suspended &&
woal_exit_usb_suspend(handle)) {
PRINTM(MERROR, "Failed to resume the suspended device\n");
LEAVE();
return -EFAULT;
}
#endif /* CONFIG_USB_SUSPEND */
#endif
woal_cancel_cac_block(priv);
/* Reset all interfaces */
ret = woal_reset_intf(priv, MOAL_IOCTL_WAIT, MTRUE);
/* Initialize private structures */
for (intf_num = 0; intf_num < handle->priv_num; intf_num++) {
woal_init_priv(handle->priv[intf_num], MOAL_IOCTL_WAIT);
#ifdef WIFI_DIRECT_SUPPORT
#if defined(STA_SUPPORT) && defined(UAP_SUPPORT)
#if defined(STA_WEXT) || defined(UAP_WEXT)
if ((handle->priv[intf_num]->bss_type ==
MLAN_BSS_TYPE_WIFIDIRECT) &&
(GET_BSS_ROLE(handle->priv[intf_num]) ==
MLAN_BSS_ROLE_UAP)) {
if (MLAN_STATUS_SUCCESS !=
woal_bss_role_cfg(handle->priv[intf_num],
MLAN_ACT_SET, MOAL_IOCTL_WAIT,
&bss_role)) {
ret = -EFAULT;
goto done;
}
}
#endif /* STA_WEXT || UAP_WEXT */
#endif /* STA_SUPPORT && UAP_SUPPORT */
#endif /* WIFI_DIRECT_SUPPORT */
}
woal_shutdown_fw(priv, MOAL_IOCTL_WAIT);
#ifdef WIFI_DIRECT_SUPPORT
#if defined(STA_SUPPORT) && defined(UAP_SUPPORT)
#if defined(STA_WEXT) || defined(UAP_WEXT)
done:
#endif /* STA_WEXT || UAP_WEXT */
#endif /* STA_SUPPORT && UAP_SUPPORT */
#endif /* WIFI_DIRECT_SUPPORT */
LEAVE();
return ret;
}
/**
* @brief warm reset
*
* @param priv A pointer to moal_private structure
*
* @return 0 success, otherwise failure
*/
int woal_warmreset(moal_private *priv)
{
moal_handle *handle = priv->phandle;
mlan_ioctl_req *req = NULL;
mlan_ds_misc_cfg *misc = NULL;
mlan_status status = MLAN_STATUS_SUCCESS;
int ret = 0;
int intf_num;
/* Restart the firmware */
req = woal_alloc_mlan_ioctl_req(sizeof(mlan_ds_misc_cfg));
if (req) {
misc = (mlan_ds_misc_cfg *)req->pbuf;
misc->sub_command = MLAN_OID_MISC_WARM_RESET;
misc->param.fw_reload = MTRUE;
req->req_id = MLAN_IOCTL_MISC_CFG;
req->action = MLAN_ACT_SET;
status = woal_request_ioctl(priv, req, MOAL_IOCTL_WAIT);
if (status != MLAN_STATUS_SUCCESS) {
PRINTM(MERROR, "warm reset failure!\n");
ret = -EFAULT;
if (status != MLAN_STATUS_PENDING)
kfree(req);
goto done;
}
kfree(req);
}
#ifdef USB
if (IS_USB(handle->card_type) && handle->params.usb_aggr == 1) {
/* Enable USB aggregation in FW */
if (woal_usb_aggr_init(handle)) {
PRINTM(MERROR, "usb aggr init fail\n");
ret = -EFAULT;
goto done;
}
}
#endif
if (moal_extflg_isset(handle, EXT_AGGR_CTRL)) {
/* Enable aggregation in FW */
if (woal_init_aggr_ctrl(handle, MOAL_IOCTL_WAIT)) {
PRINTM(MERROR, "Fail to init aggr ctrl\n");
ret = -EFAULT;
goto done;
}
}
/* Enable interfaces */
for (intf_num = 0; intf_num < handle->priv_num; intf_num++) {
netif_device_attach(handle->priv[intf_num]->netdev);
woal_start_queue(handle->priv[intf_num]->netdev);
}
done:
LEAVE();
return ret;
}
/**
* @brief Set/Get RTS threshold
*
* @param priv A pointer to moal_private structure
* @param action Action set or get
* @param wait_option Wait option
* @param value RTS threshold value
*
* @return MLAN_STATUS_SUCCESS/MLAN_STATUS_PENDING --
* success, otherwise fail
*/
mlan_status woal_set_get_rts(moal_private *priv, t_u32 action, t_u8 wait_option,
int *value)
{
mlan_ioctl_req *req = NULL;
mlan_ds_snmp_mib *mib = NULL;
mlan_status ret = MLAN_STATUS_SUCCESS;
ENTER();
/* Allocate an IOCTL request buffer */
req = woal_alloc_mlan_ioctl_req(sizeof(mlan_ds_snmp_mib));
if (req == NULL) {
ret = MLAN_STATUS_FAILURE;
goto done;
}
/* Fill request buffer */
mib = (mlan_ds_snmp_mib *)req->pbuf;
mib->sub_command = MLAN_OID_SNMP_MIB_RTS_THRESHOLD;
req->req_id = MLAN_IOCTL_SNMP_MIB;
req->action = action;
if (action == MLAN_ACT_SET) {
if (*value < MLAN_RTS_MIN_VALUE ||
*value > MLAN_RTS_MAX_VALUE) {
ret = MLAN_STATUS_FAILURE;
goto done;
}
mib->param.rts_threshold = *value;
}
/* Send IOCTL request to MLAN */
ret = woal_request_ioctl(priv, req, wait_option);
if (ret == MLAN_STATUS_SUCCESS && action == MLAN_ACT_GET)
*value = mib->param.rts_threshold;
#ifdef STA_CFG80211
/* If set is invoked from other than iw i.e iwconfig,
* wiphy RTS threshold should be updated as well */
if (IS_STA_CFG80211(priv->phandle->params.cfg80211_wext) &&
priv->wdev && priv->wdev->wiphy &&
(GET_BSS_ROLE(priv) == MLAN_BSS_ROLE_STA) &&
(action == MLAN_ACT_SET))
priv->wdev->wiphy->rts_threshold = *value;
#endif
done:
if (ret != MLAN_STATUS_PENDING)
kfree(req);
LEAVE();
return ret;
}
/**
* @brief Set/Get Fragment threshold
*
* @param priv A pointer to moal_private structure
* @param action Action set or get
* @param wait_option Wait option
* @param value Fragment threshold value
*
* @return MLAN_STATUS_SUCCESS/MLAN_STATUS_PENDING --
* success, otherwise fail
*/
mlan_status woal_set_get_frag(moal_private *priv, t_u32 action,
t_u8 wait_option, int *value)
{
mlan_ioctl_req *req = NULL;
mlan_ds_snmp_mib *mib = NULL;
mlan_status ret = MLAN_STATUS_SUCCESS;
ENTER();
/* Allocate an IOCTL request buffer */
req = woal_alloc_mlan_ioctl_req(sizeof(mlan_ds_snmp_mib));
if (req == NULL) {
ret = MLAN_STATUS_FAILURE;
goto done;
}
/* Fill request buffer */
mib = (mlan_ds_snmp_mib *)req->pbuf;
mib->sub_command = MLAN_OID_SNMP_MIB_FRAG_THRESHOLD;
req->req_id = MLAN_IOCTL_SNMP_MIB;
req->action = action;
if (action == MLAN_ACT_SET) {
if (*value < MLAN_FRAG_MIN_VALUE ||
*value > MLAN_FRAG_MAX_VALUE) {
ret = MLAN_STATUS_FAILURE;
goto done;
}
mib->param.frag_threshold = *value;
}
/* Send IOCTL request to MLAN */
ret = woal_request_ioctl(priv, req, wait_option);
if (ret == MLAN_STATUS_SUCCESS && action == MLAN_ACT_GET)
*value = mib->param.frag_threshold;
#ifdef STA_CFG80211
/* If set is invoked from other than iw i.e iwconfig,
* wiphy fragment threshold should be updated as well */
if (IS_STA_CFG80211(priv->phandle->params.cfg80211_wext) &&
priv->wdev && priv->wdev->wiphy &&
(GET_BSS_ROLE(priv) == MLAN_BSS_ROLE_STA) &&
(action == MLAN_ACT_SET))
priv->wdev->wiphy->frag_threshold = *value;
#endif
done:
if (ret != MLAN_STATUS_PENDING)
kfree(req);
LEAVE();
return ret;
}
/**
* @brief Set/Get TX power
*
* @param priv A pointer to moal_private structure
* @param action Action set or get
* @param power_cfg A pinter to mlan_power_cfg_t structure
*
* @return MLAN_STATUS_SUCCESS/MLAN_STATUS_PENDING --
* success, otherwise fail
*/
mlan_status woal_set_get_tx_power(moal_private *priv, t_u32 action,
mlan_power_cfg_t *power_cfg)
{
mlan_ds_power_cfg *pcfg = NULL;
mlan_ioctl_req *req = NULL;
mlan_status ret = MLAN_STATUS_SUCCESS;
ENTER();
req = woal_alloc_mlan_ioctl_req(sizeof(mlan_ds_power_cfg));
if (req == NULL) {
ret = MLAN_STATUS_FAILURE;
goto done;
}
pcfg = (mlan_ds_power_cfg *)req->pbuf;
pcfg->sub_command = MLAN_OID_POWER_CFG;
req->req_id = MLAN_IOCTL_POWER_CFG;
req->action = action;
if (action == MLAN_ACT_SET && power_cfg)
moal_memcpy_ext(priv->phandle, &pcfg->param.power_cfg,
power_cfg, sizeof(mlan_power_cfg_t),
sizeof(mlan_power_cfg_t));
ret = woal_request_ioctl(priv, req, MOAL_IOCTL_WAIT);
if (ret != MLAN_STATUS_SUCCESS)
goto done;
if (ret == MLAN_STATUS_SUCCESS && power_cfg)
moal_memcpy_ext(priv->phandle, power_cfg,
&pcfg->param.power_cfg,
sizeof(mlan_power_cfg_t),
sizeof(mlan_power_cfg_t));
done:
if (ret != MLAN_STATUS_PENDING)
kfree(req);
LEAVE();
return ret;
}
/**
* @brief Set/Get IEEE power management
*
* @param priv A pointer to moal_private structure
* @param action Action set or get
* @param disabled A pointer to disabled flag
* @param power_type IEEE power type
* @param wait_option wait option
*
* @return MLAN_STATUS_SUCCESS -- success, otherwise fail
*/
mlan_status woal_set_get_power_mgmt(moal_private *priv, t_u32 action,
int *disabled, int power_type,
t_u8 wait_option)
{
mlan_status ret = MLAN_STATUS_SUCCESS;
mlan_ioctl_req *req = NULL;
mlan_ds_pm_cfg *pm_cfg = NULL;
ENTER();
req = woal_alloc_mlan_ioctl_req(sizeof(mlan_ds_pm_cfg));
if (req == NULL) {
ret = MLAN_STATUS_FAILURE;
goto done;
}
pm_cfg = (mlan_ds_pm_cfg *)req->pbuf;
pm_cfg->sub_command = MLAN_OID_PM_CFG_IEEE_PS;
req->req_id = MLAN_IOCTL_PM_CFG;
req->action = action;
if (action == MLAN_ACT_SET) {
PRINTM(MINFO, "PS_MODE set power disabled=%d power type=%#x\n",
*disabled, power_type);
if (*disabled)
pm_cfg->param.ps_mode = 0;
else {
/* Check not support case only (vwrq->disabled == FALSE)
*/
if ((power_type & MW_POWER_TYPE) == MW_POWER_TIMEOUT) {
PRINTM(MERROR,
"Setting power timeout is not supported\n");
ret = MLAN_STATUS_FAILURE;
goto done;
} else if ((power_type & MW_POWER_TYPE) ==
MW_POWER_PERIOD) {
PRINTM(MERROR,
"Setting power period is not supported\n");
ret = MLAN_STATUS_FAILURE;
goto done;
}
pm_cfg->param.ps_mode = 1;
}
}
ret = woal_request_ioctl(priv, req, wait_option);
if (ret != MLAN_STATUS_SUCCESS)
goto done;
if (ret == MLAN_STATUS_SUCCESS && action == MLAN_ACT_GET)
*disabled = pm_cfg->param.ps_mode;
#ifdef STA_CFG80211
/* If set is invoked from other than iw i.e iwconfig,
* wiphy IEEE power save mode should be updated */
if (IS_STA_CFG80211(priv->phandle->params.cfg80211_wext) &&
priv->wdev && (GET_BSS_ROLE(priv) == MLAN_BSS_ROLE_STA) &&
(action == MLAN_ACT_SET)) {
if (*disabled)
priv->wdev->ps = MFALSE;
else
priv->wdev->ps = MTRUE;
}
#endif
done:
if (ret != MLAN_STATUS_PENDING)
kfree(req);
LEAVE();
return ret;
}
/**
* @brief Set Country Code
*
* @param priv A pointer to moal_private structure
* @param region A pointer to region string
*
* @return MLAN_STATUS_SUCCESS/MLAN_STATUS_PENDING --success, otherwise
* fail
*/
int woal_set_countrycode(moal_private *priv, char *country)
{
int ret = 0;
mlan_ioctl_req *req = NULL;
mlan_ds_misc_cfg *pcfg_misc = NULL;
mlan_ds_misc_country_code *country_code = NULL;
mlan_status status = MLAN_STATUS_SUCCESS;
ENTER();
/* Allocate an IOCTL request buffer */
req = woal_alloc_mlan_ioctl_req(sizeof(mlan_ds_misc_cfg));
if (req == NULL) {
ret = -ENOMEM;
goto done;
}
/* Fill request buffer */
pcfg_misc = (mlan_ds_misc_cfg *)req->pbuf;
country_code = &pcfg_misc->param.country_code;
pcfg_misc->sub_command = MLAN_OID_MISC_COUNTRY_CODE;
req->req_id = MLAN_IOCTL_MISC_CFG;
memset(country_code->country_code, 0, COUNTRY_CODE_LEN);
moal_memcpy_ext(priv->phandle, country_code->country_code, country,
COUNTRY_CODE_LEN - 1, COUNTRY_CODE_LEN - 1);
req->action = MLAN_ACT_SET;
/* Send IOCTL request to MLAN */
status = woal_request_ioctl(priv, req, MOAL_IOCTL_WAIT);
if (status != MLAN_STATUS_SUCCESS) {
ret = -EFAULT;
goto done;
}
done:
if (status != MLAN_STATUS_PENDING)
kfree(req);
LEAVE();
return ret;
}
/**
* @brief Set region code
*
* @param priv A pointer to moal_private structure
* @param region A pointer to region string
*
* @return MLAN_STATUS_SUCCESS/MLAN_STATUS_PENDING --success, otherwise
* fail
*/
mlan_status woal_set_region_code(moal_private *priv, char *region)
{
mlan_status ret = MLAN_STATUS_SUCCESS;
mlan_ds_misc_cfg *cfg = NULL;
mlan_ioctl_req *req = NULL;
ENTER();
if (woal_is_country_code_supported(region))
return woal_set_countrycode(priv, region);
req = woal_alloc_mlan_ioctl_req(sizeof(mlan_ds_misc_cfg));
if (req == NULL) {
ret = MLAN_STATUS_FAILURE;
goto done;
}
cfg = (mlan_ds_misc_cfg *)req->pbuf;
cfg->sub_command = MLAN_OID_MISC_REGION;
req->req_id = MLAN_IOCTL_MISC_CFG;
req->action = MLAN_ACT_SET;
cfg->param.region_code = region_string_2_region_code(region);
ret = woal_request_ioctl(priv, req, MOAL_IOCTL_WAIT);
done:
if (ret != MLAN_STATUS_PENDING)
kfree(req);
LEAVE();
return ret;
}
/**
* @brief Set/Get data rate
*
* @param priv A pointer to moal_private structure
* @param action Action set or get
* @param datarate A pointer to mlan_rate_cfg_t structure
*
* @return MLAN_STATUS_SUCCESS -- success, otherwise fail
*/
mlan_status woal_set_get_data_rate(moal_private *priv, t_u8 action,
mlan_rate_cfg_t *datarate)
{
mlan_status ret = MLAN_STATUS_SUCCESS;
mlan_ds_rate *rate = NULL;
mlan_ioctl_req *req = NULL;
ENTER();
req = woal_alloc_mlan_ioctl_req(sizeof(mlan_ds_rate));
if (req == NULL) {
ret = MLAN_STATUS_FAILURE;
goto done;
}
rate = (mlan_ds_rate *)req->pbuf;
rate->param.rate_cfg.rate_type = MLAN_RATE_VALUE;
rate->sub_command = MLAN_OID_RATE_CFG;
req->req_id = MLAN_IOCTL_RATE;
req->action = action;
if (datarate && (action == MLAN_ACT_SET))
moal_memcpy_ext(priv->phandle, &rate->param.rate_cfg, datarate,
sizeof(mlan_rate_cfg_t),
sizeof(mlan_rate_cfg_t));
ret = woal_request_ioctl(priv, req, MOAL_IOCTL_WAIT);
if (ret == MLAN_STATUS_SUCCESS && datarate && action == MLAN_ACT_GET)
moal_memcpy_ext(priv->phandle, datarate, &rate->param.rate_cfg,
sizeof(mlan_rate_cfg_t),
sizeof(mlan_rate_cfg_t));
done:
if (ret != MLAN_STATUS_PENDING)
kfree(req);
LEAVE();
return ret;
}
/**
* @brief Get assoc_resp buffer
*
* @param priv A pointer to moal_private structure
* @param assoc_rsp A pointer to mlan_ds_misc_assoc_rsp structure
* @param wait_option wait option
*
* @return MLAN_STATUS_SUCCESS -- success, otherwise fail
*/
mlan_status woal_get_assoc_rsp(moal_private *priv,
mlan_ds_misc_assoc_rsp *assoc_rsp,
t_u8 wait_option)
{
mlan_status ret = MLAN_STATUS_SUCCESS;
mlan_ds_misc_cfg *misc = NULL;
mlan_ioctl_req *req = NULL;
ENTER();
req = woal_alloc_mlan_ioctl_req(sizeof(mlan_ds_misc_cfg));
if (req == NULL) {
PRINTM(MERROR, "Fail to allocate buffer for get assoc resp\n");
ret = MLAN_STATUS_FAILURE;
goto done;
}
req->req_id = MLAN_IOCTL_MISC_CFG;
misc = (pmlan_ds_misc_cfg)req->pbuf;
misc->sub_command = MLAN_OID_MISC_ASSOC_RSP;
req->action = MLAN_ACT_GET;
ret = woal_request_ioctl(priv, req, wait_option);
if (ret == MLAN_STATUS_SUCCESS && assoc_rsp)
moal_memcpy_ext(priv->phandle, assoc_rsp,
&misc->param.assoc_resp,
sizeof(mlan_ds_misc_assoc_rsp),
sizeof(mlan_ds_misc_assoc_rsp));
done:
if (ret != MLAN_STATUS_PENDING)
kfree(req);
LEAVE();
return ret;
}
#endif
/**
* @brief Send get FW info request to MLAN
*
* @param priv A pointer to moal_private structure
* @param wait_option Wait option
* @param fw_info FW information
*
* @return MLAN_STATUS_SUCCESS/MLAN_STATUS_PENDING -- success,
* otherwise fail
*/
mlan_status woal_request_get_fw_info(moal_private *priv, t_u8 wait_option,
mlan_fw_info *fw_info)
{
mlan_ioctl_req *req = NULL;
mlan_ds_get_info *info;
mlan_status status;
ENTER();
memset(priv->current_addr, 0xff, ETH_ALEN);
/* Allocate an IOCTL request buffer */
req = (mlan_ioctl_req *)woal_alloc_mlan_ioctl_req(
sizeof(mlan_ds_get_info));
if (req == NULL) {
status = MLAN_STATUS_FAILURE;
goto done;
}
/* Fill request buffer */
info = (mlan_ds_get_info *)req->pbuf;
req->req_id = MLAN_IOCTL_GET_INFO;
req->action = MLAN_ACT_GET;
info->sub_command = MLAN_OID_GET_FW_INFO;
/* Send IOCTL request to MLAN */
status = woal_request_ioctl(priv, req, wait_option);
if (status == MLAN_STATUS_SUCCESS) {
priv->phandle->fw_release_number = info->param.fw_info.fw_ver;
priv->phandle->fw_ecsa_enable = info->param.fw_info.ecsa_enable;
priv->phandle->fw_getlog_enable =
info->param.fw_info.getlog_enable;
if (priv->current_addr[0] == 0xff)
moal_memcpy_ext(priv->phandle, priv->current_addr,
&info->param.fw_info.mac_addr,
sizeof(mlan_802_11_mac_addr), ETH_ALEN);
moal_memcpy_ext(priv->phandle, priv->netdev->dev_addr,
priv->current_addr, ETH_ALEN, ETH_ALEN);
if (fw_info)
moal_memcpy_ext(priv->phandle, fw_info,
&info->param.fw_info,
sizeof(mlan_fw_info),
sizeof(mlan_fw_info));
DBG_HEXDUMP(MCMD_D, "mac", priv->current_addr, 6);
} else
PRINTM(MERROR,
"get fw info failed! status=%d, error_code=0x%x\n",
status, req->status_code);
done:
if (status != MLAN_STATUS_PENDING)
kfree(req);
LEAVE();
return status;
}
/**
* @brief Get current channel of active interface
*
* @param priv A pointer to moal_private
* @param channel A pointer to chan_band_info structure
*
* @return MLAN_STATUS_SUCCESS or MLAN_STATUS_FAILURE
*/
mlan_status woal_get_active_intf_channel(moal_private *priv,
chan_band_info *channel)
{
moal_handle *handle = priv->phandle;
int i;
for (i = 0; i < handle->priv_num; i++) {
#ifdef STA_SUPPORT
if (GET_BSS_ROLE(handle->priv[i]) == MLAN_BSS_ROLE_STA) {
if (handle->priv[i]->media_connected == MTRUE)
return woal_get_sta_channel(handle->priv[i],
MOAL_IOCTL_WAIT,
channel);
}
#endif
#ifdef UAP_SUPPORT
if (GET_BSS_ROLE(handle->priv[i]) == MLAN_BSS_ROLE_UAP) {
if (handle->priv[i]->bss_started == MTRUE)
return woal_set_get_ap_channel(handle->priv[i],
MLAN_ACT_GET,
MOAL_IOCTL_WAIT,
channel);
}
#endif
}
return MLAN_STATUS_FAILURE;
}
#ifdef STA_SUPPORT
/**
* @brief Send get ext cap info request to MLAN
*
* @param priv A pointer to moal_private structure
* @param buf data buffer
* @param len data buffer length
*
* @return number of bytes of extended capability -- success,
* otherwise error
*/
int woal_request_extcap(moal_private *priv, t_u8 *buf, t_u8 len)
{
int ret = 0;
mlan_ioctl_req *req = NULL;
mlan_ds_misc_cfg *cfg = NULL;
mlan_status status = MLAN_STATUS_SUCCESS;
ENTER();
if (buf == NULL || len <= 0 || len < sizeof(ExtCap_t)) {
ret = -EINVAL;
goto out;
}
req = woal_alloc_mlan_ioctl_req(sizeof(mlan_ds_misc_cfg));
if (req == NULL) {
ret = -ENOMEM;
goto out;
}
cfg = (mlan_ds_misc_cfg *)req->pbuf;
cfg->sub_command = MLAN_OID_MISC_EXT_CAP_CFG;
req->req_id = MLAN_IOCTL_MISC_CFG;
req->action = MLAN_ACT_GET;
status = woal_request_ioctl(priv, req, MOAL_IOCTL_WAIT);
if (status != MLAN_STATUS_SUCCESS) {
ret = -EFAULT;
goto out;
}
memset(buf, 0, len);
moal_memcpy_ext(priv->phandle, buf, &cfg->param.ext_cap,
sizeof(ExtCap_t), len);
ret = sizeof(ExtCap_t);
out:
if (status != MLAN_STATUS_PENDING)
kfree(req);
LEAVE();
return ret;
}
#endif
/**
* @brief Get debug info
*
* @param priv A pointer to moal_private structure
* @param wait_option Wait option
* @param debug_info A pointer to mlan_debug_info structure
*
* @return MLAN_STATUS_SUCCESS/MLAN_STATUS_PENDING --
* success, otherwise fail
*/
mlan_status woal_get_debug_info(moal_private *priv, t_u8 wait_option,
mlan_debug_info *debug_info)
{
int ret = 0;
mlan_ioctl_req *req = NULL;
mlan_ds_get_info *info = NULL;
mlan_status status = MLAN_STATUS_SUCCESS;
ENTER();
/* Allocate an IOCTL request buffer */
req = woal_alloc_mlan_ioctl_req(sizeof(t_u32) +
sizeof(mlan_debug_info));
if (req == NULL) {
ret = -ENOMEM;
goto done;
}
/* Fill request buffer */
info = (mlan_ds_get_info *)req->pbuf;
info->sub_command = MLAN_OID_GET_DEBUG_INFO;
req->req_id = MLAN_IOCTL_GET_INFO;
req->action = MLAN_ACT_GET;
/* Send IOCTL request to MLAN */
status = woal_request_ioctl(priv, req, wait_option);
if (status == MLAN_STATUS_SUCCESS) {
if (debug_info) {
moal_memcpy_ext(priv->phandle, debug_info,
&info->param.debug_info,
sizeof(mlan_debug_info),
sizeof(mlan_debug_info));
}
}
done:
if (status != MLAN_STATUS_PENDING)
kfree(req);
LEAVE();
return status;
}
#if defined(STA_WEXT) || defined(UAP_WEXT)
/**
* @brief host command ioctl function
*
* @param priv A pointer to moal_private structure
* @param wrq A pointer to iwreq structure
* @return 0 --success, otherwise fail
*/
int woal_host_command(moal_private *priv, struct iwreq *wrq)
{
HostCmd_Header cmd_header;
int ret = 0;
mlan_ds_misc_cfg *misc = NULL;
mlan_ioctl_req *req = NULL;
mlan_status status = MLAN_STATUS_SUCCESS;
ENTER();
/* Sanity check */
if (wrq->u.data.pointer == NULL) {
PRINTM(MERROR, "hostcmd IOCTL corrupt data\n");
ret = -EINVAL;
goto done;
}
req = woal_alloc_mlan_ioctl_req(sizeof(mlan_ds_misc_cfg));
if (req == NULL) {
ret = -ENOMEM;
goto done;
}
misc = (mlan_ds_misc_cfg *)req->pbuf;
memset(&cmd_header, 0, sizeof(cmd_header));
/* get command header */
if (copy_from_user(&cmd_header, wrq->u.data.pointer,
sizeof(HostCmd_Header))) {
PRINTM(MERROR, "copy from user failed: Host command header\n");
ret = -EFAULT;
goto done;
}
misc->param.hostcmd.len = woal_le16_to_cpu(cmd_header.size);
PRINTM(MINFO, "Host command len = %u\n", misc->param.hostcmd.len);
if (!misc->param.hostcmd.len ||
misc->param.hostcmd.len > MRVDRV_SIZE_OF_CMD_BUFFER) {
PRINTM(MERROR, "Invalid data buffer length\n");
ret = -EINVAL;
goto done;
}
/* get the whole command from user */
if (copy_from_user(misc->param.hostcmd.cmd, wrq->u.data.pointer,
woal_le16_to_cpu(cmd_header.size))) {
PRINTM(MERROR, "copy from user failed\n");
ret = -EFAULT;
goto done;
}
misc->sub_command = MLAN_OID_MISC_HOST_CMD;
req->req_id = MLAN_IOCTL_MISC_CFG;
status = woal_request_ioctl(priv, req, MOAL_IOCTL_WAIT);
if (status != MLAN_STATUS_SUCCESS) {
ret = -EFAULT;
goto done;
}
if (copy_to_user(wrq->u.data.pointer, (t_u8 *)misc->param.hostcmd.cmd,
misc->param.hostcmd.len)) {
ret = -EFAULT;
goto done;
}
wrq->u.data.length = misc->param.hostcmd.len;
done:
if (status != MLAN_STATUS_PENDING)
kfree(req);
LEAVE();
return ret;
}
#endif
#if defined(WIFI_DIRECT_SUPPORT) || defined(UAP_SUPPORT)
/**
* @brief host command ioctl function
*
* @param dev A pointer to net_device structure
* @param req A pointer to ifreq structure
* @return 0 --success, otherwise fail
*/
/********* format of ifr_data *************/
/* buf_len + Hostcmd_body */
/* buf_len: 4 bytes */
/* the length of the buf which */
/* can be used to return data */
/* to application */
/* Hostcmd_body */
/*******************************************/
int woal_hostcmd_ioctl(struct net_device *dev, struct ifreq *req)
{
moal_private *priv = (moal_private *)netdev_priv(dev);
t_u32 buf_len = 0;
HostCmd_Header cmd_header;
int ret = 0;
mlan_ds_misc_cfg *misc = NULL;
mlan_ioctl_req *ioctl_req = NULL;
mlan_status status = MLAN_STATUS_SUCCESS;
ENTER();
/* Sanity check */
if (req->ifr_data == NULL) {
PRINTM(MERROR, "uap_hostcmd_ioctl() corrupt data\n");
ret = -EFAULT;
goto done;
}
if (copy_from_user(&buf_len, req->ifr_data, sizeof(buf_len))) {
PRINTM(MERROR, "Copy from user failed\n");
ret = -EFAULT;
goto done;
}
memset(&cmd_header, 0, sizeof(cmd_header));
/* get command header */
if (copy_from_user(&cmd_header, req->ifr_data + sizeof(buf_len),
sizeof(HostCmd_Header))) {
PRINTM(MERROR, "Copy from user failed\n");
ret = -EFAULT;
goto done;
}
PRINTM(MINFO, "Host command len = %d\n",
woal_le16_to_cpu(cmd_header.size));
if (woal_le16_to_cpu(cmd_header.size) > MRVDRV_SIZE_OF_CMD_BUFFER) {
ret = -EINVAL;
goto done;
}
ioctl_req = woal_alloc_mlan_ioctl_req(sizeof(mlan_ds_misc_cfg));
if (ioctl_req == NULL) {
ret = -ENOMEM;
goto done;
}
misc = (mlan_ds_misc_cfg *)ioctl_req->pbuf;
misc->param.hostcmd.len = woal_le16_to_cpu(cmd_header.size);
/* get the whole command from user */
if (copy_from_user(misc->param.hostcmd.cmd,
req->ifr_data + sizeof(buf_len),
misc->param.hostcmd.len)) {
PRINTM(MERROR, "copy from user failed\n");
ret = -EFAULT;
goto done;
}
misc->sub_command = MLAN_OID_MISC_HOST_CMD;
ioctl_req->req_id = MLAN_IOCTL_MISC_CFG;
status = woal_request_ioctl(priv, ioctl_req, MOAL_IOCTL_WAIT);
if (status != MLAN_STATUS_SUCCESS) {
ret = -EFAULT;
goto done;
}
if (misc->param.hostcmd.len > buf_len) {
PRINTM(MERROR,
"buf_len is too small, resp_len=%d, buf_len=%d\n",
(int)misc->param.hostcmd.len, (int)buf_len);
ret = -EFAULT;
goto done;
}
if (copy_to_user(req->ifr_data + sizeof(buf_len),
(t_u8 *)misc->param.hostcmd.cmd,
misc->param.hostcmd.len)) {
ret = -EFAULT;
goto done;
}
done:
if (status != MLAN_STATUS_PENDING)
kfree(ioctl_req);
LEAVE();
return ret;
}
#endif
/**
* @brief CUSTOM_IE ioctl handler
*
* @param dev A pointer to net_device structure
* @param req A pointer to ifreq structure
* @return 0 --success, otherwise fail
*/
int woal_custom_ie_ioctl(struct net_device *dev, struct ifreq *req)
{
moal_private *priv = (moal_private *)netdev_priv(dev);
mlan_ioctl_req *ioctl_req = NULL;
mlan_ds_misc_cfg *misc = NULL;
mlan_ds_misc_custom_ie *custom_ie = NULL;
int ret = 0;
mlan_status status = MLAN_STATUS_SUCCESS;
gfp_t flag;
ENTER();
/* Sanity check */
if (req->ifr_data == NULL) {
PRINTM(MERROR, "woal_custom_ie_ioctl() corrupt data\n");
ret = -EFAULT;
goto done;
}
flag = (in_atomic() || irqs_disabled()) ? GFP_ATOMIC : GFP_KERNEL;
custom_ie = kzalloc(sizeof(mlan_ds_misc_custom_ie), flag);
if (!custom_ie) {
ret = -ENOMEM;
goto done;
}
if (copy_from_user(custom_ie, req->ifr_data,
sizeof(mlan_ds_misc_custom_ie))) {
PRINTM(MERROR, "Copy from user failed\n");
ret = -EFAULT;
goto done;
}
ioctl_req = woal_alloc_mlan_ioctl_req(sizeof(mlan_ds_misc_cfg));
if (ioctl_req == NULL) {
ret = -ENOMEM;
goto done;
}
misc = (mlan_ds_misc_cfg *)ioctl_req->pbuf;
misc->sub_command = MLAN_OID_MISC_CUSTOM_IE;
ioctl_req->req_id = MLAN_IOCTL_MISC_CFG;
if ((custom_ie->len == 0) ||
(custom_ie->len == sizeof(custom_ie->ie_data_list[0].ie_index)))
ioctl_req->action = MLAN_ACT_GET;
else
ioctl_req->action = MLAN_ACT_SET;
moal_memcpy_ext(priv->phandle, &misc->param.cust_ie, custom_ie,
sizeof(mlan_ds_misc_custom_ie),
sizeof(mlan_ds_misc_custom_ie));
status = woal_request_ioctl(priv, ioctl_req, MOAL_IOCTL_WAIT);
if (status != MLAN_STATUS_SUCCESS) {
ret = -EFAULT;
goto done;
}
if (ioctl_req->action == MLAN_ACT_GET) {
if (copy_to_user(req->ifr_data, &misc->param.cust_ie,
sizeof(mlan_ds_misc_custom_ie))) {
PRINTM(MERROR, "Copy to user failed!\n");
ret = -EFAULT;
goto done;
}
} else if (ioctl_req->status_code == MLAN_ERROR_IOCTL_FAIL) {
/* send a separate error code to indicate error from driver */
ret = EFAULT;
}
done:
if (status != MLAN_STATUS_PENDING)
kfree(ioctl_req);
kfree(custom_ie);
LEAVE();
return ret;
}
/**
* @brief send raw data packet ioctl function
*
* @param dev A pointer to net_device structure
* @param req A pointer to ifreq structure
* @return 0 --success, otherwise fail
*/
int woal_send_host_packet(struct net_device *dev, struct ifreq *req)
{
moal_private *priv = (moal_private *)netdev_priv(dev);
t_u32 packet_len = 0;
int ret = 0;
pmlan_buffer pmbuf = NULL;
mlan_status status;
ENTER();
if (!priv || !priv->phandle) {
PRINTM(MERROR, "priv or handle is NULL\n");
ret = -EFAULT;
goto done;
}
/* Sanity check */
if (req->ifr_data == NULL) {
PRINTM(MERROR, "woal_send_host_packet() corrupt data\n");
ret = -EFAULT;
goto done;
}
if (copy_from_user(&packet_len, req->ifr_data, sizeof(packet_len))) {
PRINTM(MERROR, "Copy from user failed\n");
ret = -EFAULT;
goto done;
}
#define PACKET_HEADER_LEN 8
#define MV_ETH_FRAME_LEN 1514
if (packet_len > MV_ETH_FRAME_LEN) {
PRINTM(MERROR, "Invalid packet length %d\n", packet_len);
ret = -EFAULT;
goto done;
}
pmbuf = woal_alloc_mlan_buffer(
priv->phandle, (int)(MLAN_MIN_DATA_HEADER_LEN +
(int)packet_len + PACKET_HEADER_LEN));
if (!pmbuf) {
PRINTM(MERROR, "Fail to allocate mlan_buffer\n");
ret = -ENOMEM;
goto done;
}
pmbuf->data_offset = MLAN_MIN_DATA_HEADER_LEN;
/* get whole packet and header */
if (copy_from_user(pmbuf->pbuf + pmbuf->data_offset,
req->ifr_data + sizeof(packet_len),
PACKET_HEADER_LEN + packet_len)) {
PRINTM(MERROR, "Copy from user failed\n");
ret = -EFAULT;
woal_free_mlan_buffer(priv->phandle, pmbuf);
goto done;
}
pmbuf->data_len = PACKET_HEADER_LEN + packet_len;
pmbuf->buf_type = MLAN_BUF_TYPE_RAW_DATA;
pmbuf->bss_index = priv->bss_index;
status = mlan_send_packet(priv->phandle->pmlan_adapter, pmbuf);
switch (status) {
case MLAN_STATUS_PENDING:
atomic_inc(&priv->phandle->tx_pending);
queue_work(priv->phandle->workqueue, &priv->phandle->main_work);
break;
case MLAN_STATUS_SUCCESS:
woal_free_mlan_buffer(priv->phandle, pmbuf);
break;
case MLAN_STATUS_FAILURE:
default:
woal_free_mlan_buffer(priv->phandle, pmbuf);
ret = -EFAULT;
break;
}
done:
LEAVE();
return ret;
}
#if defined(UAP_WEXT)
/**
* @brief Set/Get CUSTOM_IE ioctl handler
*
* @param priv A pointer to moal_private structure
* @param mask Mask to set or clear from caller
* @param ie IE buffer to set for beacon
* @param ie_len Length of the IE
*
* @return 0 --success, otherwise fail
*/
int woal_set_get_custom_ie(moal_private *priv, t_u16 mask, t_u8 *ie, int ie_len)
{
mlan_ioctl_req *ioctl_req = NULL;
mlan_ds_misc_cfg *misc = NULL;
mlan_ds_misc_custom_ie *misc_ie = NULL;
int ret = 0;
custom_ie *pcust_bcn_ie = NULL;
mlan_status status = MLAN_STATUS_SUCCESS;
ENTER();
ioctl_req = woal_alloc_mlan_ioctl_req(sizeof(mlan_ds_misc_cfg));
if (ioctl_req == NULL) {
LEAVE();
return -ENOMEM;
}
misc = (mlan_ds_misc_cfg *)ioctl_req->pbuf;
misc->sub_command = MLAN_OID_MISC_CUSTOM_IE;
ioctl_req->req_id = MLAN_IOCTL_MISC_CFG;
ioctl_req->action = MLAN_ACT_SET;
misc_ie = &misc->param.cust_ie;
misc_ie->type = TLV_TYPE_MGMT_IE;
misc_ie->len = (sizeof(custom_ie) - MAX_IE_SIZE) + ie_len;
pcust_bcn_ie = misc_ie->ie_data_list;
pcust_bcn_ie->ie_index = 0xffff;
pcust_bcn_ie->mgmt_subtype_mask = mask;
pcust_bcn_ie->ie_length = ie_len;
moal_memcpy_ext(priv->phandle, pcust_bcn_ie->ie_buffer, ie, ie_len,
MAX_IE_SIZE);
status = woal_request_ioctl(priv, ioctl_req, MOAL_IOCTL_WAIT);
if (status != MLAN_STATUS_SUCCESS)
ret = -EFAULT;
if (status != MLAN_STATUS_PENDING)
kfree(ioctl_req);
LEAVE();
return ret;
}
#endif /* defined(HOST_TXRX_MGMT_FRAME) && defined(UAP_WEXT) */
/**
* @brief ioctl function get BSS type
*
* @param dev A pointer to net_device structure
* @param req A pointer to ifreq structure
* @return 0 --success, otherwise fail
*/
int woal_get_bss_type(struct net_device *dev, struct ifreq *req)
{
int ret = 0;
moal_private *priv = (moal_private *)netdev_priv(dev);
int bss_type;
ENTER();
bss_type = (int)priv->bss_type;
if (copy_to_user(req->ifr_data, &bss_type, sizeof(int))) {
PRINTM(MINFO, "Copy to user failed!\n");
ret = -EFAULT;
}
LEAVE();
return ret;
}
#if defined(STA_SUPPORT) && defined(UAP_SUPPORT)
/**
* @brief Swithces BSS role of interface
*
* @param priv A pointer to moal_private structure
* @param action Action: set or get
* @param wait_option Wait option (MOAL_WAIT or MOAL_NO_WAIT)
* @param bss_role A pointer to bss role
*
* @return 0 --success, otherwise fail
*/
mlan_status woal_bss_role_cfg(moal_private *priv, t_u8 action, t_u8 wait_option,
t_u8 *bss_role)
{
int ret = 0;
mlan_ds_bss *bss = NULL;
mlan_ioctl_req *req = NULL;
struct net_device *dev = priv->netdev;
mlan_status status = MLAN_STATUS_SUCCESS;
ENTER();
req = woal_alloc_mlan_ioctl_req(sizeof(mlan_ds_bss));
if (req == NULL) {
ret = -ENOMEM;
goto done;
}
bss = (mlan_ds_bss *)req->pbuf;
bss->sub_command = MLAN_OID_BSS_ROLE;
req->req_id = MLAN_IOCTL_BSS;
req->action = action;
if (action == MLAN_ACT_SET) {
if (priv->bss_role == *bss_role) {
PRINTM(MWARN, "BSS is in desired role already\n");
goto done;
} else {
bss->param.bss_role = *bss_role;
}
}
status = woal_request_ioctl(priv, req, wait_option);
if (status != MLAN_STATUS_SUCCESS) {
ret = -EFAULT;
goto done;
}
if (action == MLAN_ACT_GET) {
*bss_role = bss->param.bss_role;
} else {
/* Update moal_private */
priv->bss_role = *bss_role;
if (priv->bss_type == MLAN_BSS_TYPE_UAP)
priv->bss_type = MLAN_BSS_TYPE_STA;
else if (priv->bss_type == MLAN_BSS_TYPE_STA)
priv->bss_type = MLAN_BSS_TYPE_UAP;
if (*bss_role == MLAN_BSS_ROLE_UAP) {
/* Switch: STA -> uAP */
/* Setup the OS Interface to our functions */
#if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 29)
dev->do_ioctl = woal_uap_do_ioctl;
dev->set_multicast_list = woal_uap_set_multicast_list;
#else
dev->netdev_ops = &woal_uap_netdev_ops;
#endif
#ifdef UAP_WEXT
if (IS_UAP_WEXT(priv->phandle->params.cfg80211_wext)) {
#if WIRELESS_EXT < 21
dev->get_wireless_stats =
woal_get_uap_wireless_stats;
#endif
dev->wireless_handlers =
(struct iw_handler_def
*)&woal_uap_handler_def;
}
#endif /* UAP_WEXT */
} else if (*bss_role == MLAN_BSS_ROLE_STA) {
/* Switch: uAP -> STA */
/* Setup the OS Interface to our functions */
#if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 29)
dev->do_ioctl = woal_do_ioctl;
dev->set_multicast_list = woal_set_multicast_list;
#else
dev->netdev_ops = &woal_netdev_ops;
#endif
#ifdef STA_WEXT
if (IS_STA_WEXT(priv->phandle->params.cfg80211_wext)) {
#if WIRELESS_EXT < 21
dev->get_wireless_stats =
woal_get_wireless_stats;
#endif
dev->wireless_handlers =
(struct iw_handler_def
*)&woal_handler_def;
}
#endif /* STA_WEXT */
}
}
done:
if (status != MLAN_STATUS_PENDING)
kfree(req);
LEAVE();
return ret;
}
#if defined(STA_WEXT) || defined(UAP_WEXT)
/**
* @brief Set/Get BSS role
*
* @param priv A pointer to moal_private structure
* @param wrq A pointer to iwreq structure
*
* @return 0 --success, otherwise fail
*/
int woal_set_get_bss_role(moal_private *priv, struct iwreq *wrq)
{
int ret = 0;
int bss_role = 0;
t_u8 action = MLAN_ACT_GET;
ENTER();
if (wrq->u.data.length) {
if (copy_from_user(&bss_role, wrq->u.data.pointer,
sizeof(int))) {
PRINTM(MERROR, "Copy from user failed\n");
ret = -EFAULT;
goto done;
}
if ((bss_role != MLAN_BSS_ROLE_STA &&
bss_role != MLAN_BSS_ROLE_UAP)
#ifdef WIFI_DIRECT_SUPPORT
|| (priv->bss_type != MLAN_BSS_TYPE_WIFIDIRECT)
#endif
) {
PRINTM(MWARN, "Invalid BSS role\n");
ret = -EINVAL;
goto done;
}
if (bss_role == GET_BSS_ROLE(priv)) {
PRINTM(MWARN, "Already BSS is in desired role\n");
ret = -EINVAL;
goto done;
}
action = MLAN_ACT_SET;
/* Reset interface */
woal_reset_intf(priv, MOAL_IOCTL_WAIT, MFALSE);
}
if (MLAN_STATUS_SUCCESS != woal_bss_role_cfg(priv, action,
MOAL_IOCTL_WAIT,
(t_u8 *)&bss_role)) {
ret = -EFAULT;
goto done;
}
if (!wrq->u.data.length) {
if (copy_to_user(wrq->u.data.pointer, &bss_role, sizeof(int))) {
ret = -EFAULT;
goto done;
}
wrq->u.data.length = 1;
} else {
#if defined(STA_CFG80211) || defined(UAP_CFG80211)
if (IS_STA_OR_UAP_CFG80211(priv->phandle->params.cfg80211_wext))
woal_clear_all_mgmt_ies(priv, MOAL_IOCTL_WAIT);
#endif
/* Initialize private structures */
woal_init_priv(priv, MOAL_IOCTL_WAIT);
/* Enable interfaces */
netif_device_attach(priv->netdev);
woal_start_queue(priv->netdev);
}
done:
LEAVE();
return ret;
}
#endif /* STA_WEXT || UAP_WEXT */
#endif /* STA_SUPPORT && UAP_SUPPORT */
/**
* @brief Set/Get DTIM period
*
* @param priv A pointer to moal_private structure
* @param action Action set or get
* @param wait_option Wait option
* @param value DTIM period
*
* @return MLAN_STATUS_SUCCESS/MLAN_STATUS_PENDING --
* success, otherwise fail
*/
mlan_status woal_set_get_dtim_period(moal_private *priv, t_u32 action,
t_u8 wait_option, t_u8 *value)
{
mlan_ioctl_req *req = NULL;
mlan_ds_snmp_mib *mib = NULL;
mlan_status ret = MLAN_STATUS_SUCCESS;
ENTER();
/* Allocate an IOCTL request buffer */
req = woal_alloc_mlan_ioctl_req(sizeof(mlan_ds_snmp_mib));
if (req == NULL) {
ret = MLAN_STATUS_FAILURE;
goto done;
}
/* Fill request buffer */
mib = (mlan_ds_snmp_mib *)req->pbuf;
mib->sub_command = MLAN_OID_SNMP_MIB_DTIM_PERIOD;
req->req_id = MLAN_IOCTL_SNMP_MIB;
req->action = action;
if (action == MLAN_ACT_SET)
mib->param.dtim_period = *value;
/* Send IOCTL request to MLAN */
ret = woal_request_ioctl(priv, req, wait_option);
if (ret == MLAN_STATUS_SUCCESS && action == MLAN_ACT_GET)
*value = (t_u8)mib->param.dtim_period;
done:
if (ret != MLAN_STATUS_PENDING)
kfree(req);
LEAVE();
return ret;
}
/**
* @brief Get Host Sleep parameters
*
* @param priv A pointer to moal_private structure
* @param action Action: set or get
* @param wait_option Wait option (MOAL_WAIT or MOAL_NO_WAIT)
* @param hscfg A pointer to mlan_ds_hs_cfg structure
*
* @return MLAN_STATUS_SUCCESS/MLAN_STATUS_PENDING -- success,
* otherwise fail
*/
mlan_status woal_set_get_hs_params(moal_private *priv, t_u16 action,
t_u8 wait_option, mlan_ds_hs_cfg *hscfg)
{
mlan_status ret = MLAN_STATUS_SUCCESS;
mlan_ds_pm_cfg *pmcfg = NULL;
mlan_ioctl_req *req = NULL;
ENTER();
/* Allocate an IOCTL request buffer */
req = woal_alloc_mlan_ioctl_req(sizeof(mlan_ds_pm_cfg));
if (req == NULL) {
ret = -ENOMEM;
goto done;
}
/* Fill request buffer */
pmcfg = (mlan_ds_pm_cfg *)req->pbuf;
pmcfg->sub_command = MLAN_OID_PM_CFG_HS_CFG;
req->req_id = MLAN_IOCTL_PM_CFG;
req->action = action;
if (action == MLAN_ACT_SET)
moal_memcpy_ext(priv->phandle, &pmcfg->param.hs_cfg, hscfg,
sizeof(mlan_ds_hs_cfg), sizeof(mlan_ds_hs_cfg));
/* Send IOCTL request to MLAN */
ret = woal_request_ioctl(priv, req, wait_option);
if (ret == MLAN_STATUS_SUCCESS) {
if (hscfg && action == MLAN_ACT_GET) {
moal_memcpy_ext(priv->phandle, hscfg,
&pmcfg->param.hs_cfg,
sizeof(mlan_ds_hs_cfg),
sizeof(mlan_ds_hs_cfg));
}
}
done:
if (ret != MLAN_STATUS_PENDING)
kfree(req);
LEAVE();
return ret;
}
/**
* @brief Get wakeup reason
*
* @param priv A pointer to moal_private structure
* @param wakeup_reason A pointer to mlan_ds_hs_wakeup_reason structure
*
* @return MLAN_STATUS_SUCCESS/MLAN_STATUS_PENDING -- success,
* otherwise fail
*/
mlan_status woal_get_wakeup_reason(moal_private *priv,
mlan_ds_hs_wakeup_reason *wakeup_reason)
{
mlan_status ret = MLAN_STATUS_SUCCESS;
mlan_ds_pm_cfg *pmcfg = NULL;
mlan_ioctl_req *req = NULL;
ENTER();
/* Allocate an IOCTL request buffer */
req = woal_alloc_mlan_ioctl_req(sizeof(mlan_ds_pm_cfg));
if (req == NULL) {
ret = -ENOMEM;
goto done;
}
/* Fill request buffer */
pmcfg = (mlan_ds_pm_cfg *)req->pbuf;
pmcfg->sub_command = MLAN_OID_PM_HS_WAKEUP_REASON;
req->req_id = MLAN_IOCTL_PM_CFG;
req->action = MLAN_ACT_GET;
/* Send IOCTL request to MLAN */
ret = woal_request_ioctl(priv, req, MOAL_IOCTL_WAIT_TIMEOUT);
if (ret == MLAN_STATUS_SUCCESS) {
wakeup_reason->hs_wakeup_reason =
pmcfg->param.wakeup_reason.hs_wakeup_reason;
}
done:
if (ret != MLAN_STATUS_PENDING)
kfree(req);
LEAVE();
return ret;
}
/**
* @brief Set or Get wowlan config
*
* @param priv A pointer to moal_private structure
* @param action Action: action to config wowlan
* @param wait_option Wait option (MOAL_WAIT or MOAL_NO_WAIT)
* @param mefcfg A pointer to mlan_ds_misc_mef_flt_cfg structure
*
* @return MLAN_STATUS_SUCCESS/MLAN_STATUS_FAILURE
*/
mlan_status woal_set_get_wowlan_config(moal_private *priv, t_u16 action,
t_u8 wait_option,
mlan_ds_misc_mef_flt_cfg *mefcfg)
{
mlan_status ret = MLAN_STATUS_SUCCESS;
mlan_ds_misc_cfg *misccfg = NULL;
mlan_ioctl_req *req = NULL;
ENTER();
/** Allocate an IOCTL request buffer*/
req = woal_alloc_mlan_ioctl_req(sizeof(mlan_ds_misc_cfg));
if (req == NULL) {
ret = -ENOMEM;
goto done;
}
/** Fill request buffer */
misccfg = (mlan_ds_misc_cfg *)req->pbuf;
misccfg->sub_command = MLAN_OID_MISC_MEF_FLT_CFG;
req->req_id = MLAN_IOCTL_MISC_CFG;
req->action = action;
moal_memcpy_ext(priv->phandle, &misccfg->param.mef_flt_cfg, mefcfg,
sizeof(mlan_ds_misc_mef_flt_cfg),
sizeof(mlan_ds_misc_mef_flt_cfg));
/* Send IOCTL request to MLAN */
ret = woal_request_ioctl(priv, req, wait_option);
if (ret == MLAN_STATUS_SUCCESS) {
if (mefcfg && action == MLAN_ACT_GET) {
moal_memcpy_ext(priv->phandle, mefcfg,
&misccfg->param.mef_flt_cfg,
sizeof(mlan_ds_misc_mef_flt_cfg),
sizeof(mlan_ds_misc_mef_flt_cfg));
}
}
if (ret != MLAN_STATUS_SUCCESS && ret != MLAN_STATUS_PENDING)
PRINTM(MIOCTL, "Set Get wowlan IOCTL failed!\n");
done:
if (ret != MLAN_STATUS_PENDING)
kfree(req);
LEAVE();
return ret;
}
/**
* @brief Cancel Host Sleep configuration
*
* @param priv A pointer to moal_private structure
* @param wait_option wait option
*
* @return MLAN_STATUS_SUCCESS, MLAN_STATUS_PENDING,
* or MLAN_STATUS_FAILURE
*/
mlan_status woal_cancel_hs(moal_private *priv, t_u8 wait_option)
{
moal_handle *handle = NULL;
mlan_status ret = MLAN_STATUS_SUCCESS;
mlan_ds_hs_cfg hscfg;
#ifdef STA_CFG80211
#if CFG80211_VERSION_CODE >= KERNEL_VERSION(3, 1, 0)
int i;
#endif
#endif
ENTER();
if (!priv) {
LEAVE();
return MLAN_STATUS_FAILURE;
}
handle = priv->phandle;
/* Cancel Host Sleep */
hscfg.conditions = HOST_SLEEP_CFG_CANCEL;
hscfg.is_invoke_hostcmd = MTRUE;
ret = woal_set_get_hs_params(priv, MLAN_ACT_SET, wait_option, &hscfg);
#ifdef STA_CFG80211
#if CFG80211_VERSION_CODE >= KERNEL_VERSION(3, 1, 0)
if (GTK_REKEY_OFFLOAD_SUSPEND == handle->params.gtk_rekey_offload) {
PRINTM(MIOCTL,
"Cancel Host Sleep... clear gtk rekey offload of FW\n");
for (i = 0; i < handle->priv_num; i++) {
if (handle->priv[i] &&
handle->priv[i]->gtk_data_ready) {
PRINTM(MCMND, "clear GTK in resume\n");
woal_set_rekey_data(handle->priv[i], NULL,
MLAN_ACT_CLEAR,
wait_option);
}
}
}
#endif
#endif
LEAVE();
return ret;
}
/** @brief This function enables the host sleep
*
* @param priv A Pointer to the moal_private structure
* @return MTRUE or MFALSE
*/
int woal_enable_hs(moal_private *priv)
{
mlan_ds_hs_cfg hscfg;
moal_handle *handle = NULL;
int hs_actived = MFALSE;
int timeout = 0;
int i;
#ifdef SDIO_SUSPEND_RESUME
mlan_ds_ps_info pm_info;
#endif
pmlan_ds_misc_keep_alive keep_alive = NULL;
ENTER();
if (priv == NULL) {
PRINTM(MERROR, "Invalid priv\n");
goto done;
}
handle = priv->phandle;
if (handle->hs_activated == MTRUE) {
PRINTM(MIOCTL, "HS Already actived\n");
hs_actived = MTRUE;
goto done;
}
for (i = 0; i < MIN(handle->priv_num, MLAN_MAX_BSS_NUM); i++) {
if (handle->priv[i] &&
(GET_BSS_ROLE(handle->priv[i]) == MLAN_BSS_ROLE_STA)) {
if (moal_extflg_isset(handle,
EXT_DISCONNECT_ON_SUSPEND) &&
handle->priv[i]->media_connected == MTRUE) {
PRINTM(MIOCTL, "disconnect on suspend\n");
woal_disconnect(handle->priv[i], MOAL_NO_WAIT,
NULL, DEF_DEAUTH_REASON_CODE);
}
}
if (handle->priv[i]) {
PRINTM(MIOCTL, "woal_delba_all on priv[%d]\n", i);
woal_delba_all(handle->priv[i], MOAL_NO_WAIT);
}
}
#if defined(STA_CFG80211) || defined(UAP_CFG80211)
#if CFG80211_VERSION_CODE >= KERNEL_VERSION(2, 6, 39)
if (priv->phandle->is_remain_timer_set) {
woal_cancel_timer(&priv->phandle->remain_timer);
woal_remain_timer_func(priv->phandle);
}
/* cancel pending remain on channel */
if (priv->phandle->remain_on_channel) {
t_u8 channel_status;
moal_private *remain_priv =
priv->phandle->priv[priv->phandle->remain_bss_index];
if (remain_priv) {
woal_cfg80211_remain_on_channel_cfg(remain_priv,
MOAL_NO_WAIT, MTRUE,
&channel_status,
NULL, 0, 0);
if (priv->phandle->cookie) {
cfg80211_remain_on_channel_expired(
#if CFG80211_VERSION_CODE < KERNEL_VERSION(3, 6, 0)
remain_priv->netdev,
#else
remain_priv->wdev,
#endif
priv->phandle->cookie,
&priv->phandle->chan,
#if CFG80211_VERSION_CODE < KERNEL_VERSION(3, 8, 0)
priv->phandle->channel_type,
#endif
GFP_ATOMIC);
priv->phandle->cookie = 0;
}
}
priv->phandle->remain_on_channel = MFALSE;
}
#endif
#endif
#ifdef STA_SUPPORT
woal_reconfig_bgscan(priv->phandle);
#endif
#ifdef STA_CFG80211
#if CFG80211_VERSION_CODE >= KERNEL_VERSION(3, 1, 0)
if (GTK_REKEY_OFFLOAD_SUSPEND == handle->params.gtk_rekey_offload) {
PRINTM(MIOCTL,
"Host Sleep enabled... set gtk rekey offload to FW\n");
for (i = 0; i < handle->priv_num; i++) {
if (handle->priv[i] &&
handle->priv[i]->gtk_data_ready) {
PRINTM(MCMND, "set GTK before suspend\n");
woal_set_rekey_data(
handle->priv[i],
&handle->priv[i]->gtk_rekey_data,
MLAN_ACT_SET, MOAL_NO_WAIT);
}
}
}
#endif
#endif
for (i = 0; i < MAX_KEEP_ALIVE_ID; i++) {
keep_alive = &handle->keep_alive[i];
if (keep_alive && keep_alive->cached && keep_alive->enable) {
keep_alive->cached = false;
woal_start_mkeep_alive(
woal_get_priv(handle, MLAN_BSS_ROLE_ANY),
keep_alive->mkeep_alive_id, keep_alive->packet,
keep_alive->pkt_len, keep_alive->src_mac,
keep_alive->dst_mac, keep_alive->send_interval,
keep_alive->retry_interval,
keep_alive->retry_count);
keep_alive->pkt_len = 0;
memset(keep_alive->packet, 0, MKEEP_ALIVE_IP_PKT_MAX);
}
}
/* Enable Host Sleep */
handle->hs_activate_wait_q_woken = MFALSE;
memset(&hscfg, 0, sizeof(mlan_ds_hs_cfg));
hscfg.is_invoke_hostcmd = MTRUE;
if (woal_set_get_hs_params(priv, MLAN_ACT_SET, MOAL_NO_WAIT, &hscfg) ==
MLAN_STATUS_FAILURE) {
PRINTM(MIOCTL, "IOCTL request HS enable failed\n");
goto done;
}
timeout = wait_event_timeout(handle->hs_activate_wait_q,
handle->hs_activate_wait_q_woken,
HS_ACTIVE_TIMEOUT);
#ifdef SDIO_MMC
if (IS_SD(handle->card_type)) {
sdio_claim_host(((struct sdio_mmc_card *)handle->card)->func);
}
#endif
#ifdef SDIO_SUSPEND_RESUME
memset(&pm_info, 0, sizeof(mlan_ds_ps_info));
#endif
if ((handle->hs_activated == MTRUE) ||
(handle->is_suspended == MTRUE)) {
PRINTM(MCMND, "suspend success! force=%u skip=%u\n",
handle->hs_force_count, handle->hs_skip_count);
hs_actived = MTRUE;
}
#ifdef SDIO_SUSPEND_RESUME
else if (IS_SD(handle->card_type)) {
handle->suspend_fail = MTRUE;
woal_get_pm_info(priv, &pm_info);
if (pm_info.is_suspend_allowed == MTRUE) {
#ifdef MMC_PM_FUNC_SUSPENDED
woal_wlan_is_suspended(priv->phandle);
#endif
handle->hs_force_count++;
PRINTM(MCMND, "suspend allowed! force=%u skip=%u\n",
handle->hs_force_count, handle->hs_skip_count);
hs_actived = MTRUE;
}
}
#endif /* SDIO_SUSPEND_RESUME*/
#ifdef SDIO_MMC
if (IS_SD(handle->card_type)) {
sdio_release_host(((struct sdio_mmc_card *)handle->card)->func);
}
#endif
if (hs_actived != MTRUE) {
handle->hs_skip_count++;
#ifdef SDIO_SUSPEND_RESUME
if (IS_SD(handle->card_type)) {
PRINTM(MCMND,
"suspend skipped! timeout=%d allow=%d force=%u skip=%u\n",
timeout, (int)pm_info.is_suspend_allowed,
handle->hs_force_count, handle->hs_skip_count);
}
#else
PRINTM(MCMND, "suspend skipped! timeout=%d skip=%u\n", timeout,
handle->hs_skip_count);
#endif
woal_cancel_hs(priv, MOAL_NO_WAIT);
}
done:
LEAVE();
return hs_actived;
}
#ifdef CONFIG_PROC_FS
/**
* @brief This function send soft_reset command to firmware
*
* @param handle A pointer to moal_handle structure
* @return MLAN_STATUS_SUCCESS/MLAN_STATUS_PENDING on success,
* otherwise failure code
*/
mlan_status woal_request_soft_reset(moal_handle *handle)
{
mlan_status ret = MLAN_STATUS_SUCCESS;
mlan_ioctl_req *req = NULL;
mlan_ds_misc_cfg *misc = NULL;
ENTER();
req = woal_alloc_mlan_ioctl_req(sizeof(mlan_ds_misc_cfg));
if (req) {
misc = (mlan_ds_misc_cfg *)req->pbuf;
misc->sub_command = MLAN_OID_MISC_SOFT_RESET;
req->req_id = MLAN_IOCTL_MISC_CFG;
req->action = MLAN_ACT_SET;
ret = woal_request_ioctl(woal_get_priv(handle,
MLAN_BSS_ROLE_ANY),
req, MOAL_IOCTL_WAIT);
}
handle->surprise_removed = MTRUE;
woal_sched_timeout(5);
if (ret != MLAN_STATUS_PENDING)
kfree(req);
LEAVE();
return ret;
}
#endif /* CONFIG_PROC_FS */
/**
* @brief Set wapi enable
*
* @param priv A pointer to moal_private structure
* @param wait_option Wait option
* @param enable MTRUE or MFALSE
*
* @return MLAN_STATUS_SUCCESS/MLAN_STATUS_PENDING --
* success, otherwise fail
*/
mlan_status woal_set_wapi_enable(moal_private *priv, t_u8 wait_option,
t_u32 enable)
{
int ret = 0;
mlan_ioctl_req *req = NULL;
mlan_ds_sec_cfg *sec = NULL;
mlan_status status = MLAN_STATUS_SUCCESS;
ENTER();
/* Allocate an IOCTL request buffer */
req = woal_alloc_mlan_ioctl_req(sizeof(mlan_ds_sec_cfg));
if (req == NULL) {
ret = -ENOMEM;
goto done;
}
/* Fill request buffer */
sec = (mlan_ds_sec_cfg *)req->pbuf;
sec->sub_command = MLAN_OID_SEC_CFG_WAPI_ENABLED;
req->req_id = MLAN_IOCTL_SEC_CFG;
req->action = MLAN_ACT_SET;
sec->param.wapi_enabled = enable;
/* Send IOCTL request to MLAN */
status = woal_request_ioctl(priv, req, wait_option);
done:
if (status != MLAN_STATUS_PENDING)
kfree(req);
LEAVE();
return status;
}
/**
* @brief Get version
*
* @param handle A pointer to moal_handle structure
* @param version A pointer to version buffer
* @param max_len max length of version buffer
*
* @return N/A
*/
void woal_get_version(moal_handle *handle, char *version, int max_len)
{
union {
t_u32 l;
t_u8 c[4];
} ver;
char fw_ver[32];
ENTER();
ver.l = handle->fw_release_number;
snprintf(fw_ver, sizeof(fw_ver), "%u.%u.%u.p%u", ver.c[2], ver.c[1],
ver.c[0], ver.c[3]);
snprintf(version, max_len, handle->driver_version, fw_ver);
LEAVE();
}
#if defined(STA_WEXT) || defined(UAP_WEXT)
/**
* @brief Get Driver Version
*
* @param priv A pointer to moal_private structure
* @param req A pointer to ifreq structure
*
* @return 0 --success, otherwise fail
*/
int woal_get_driver_version(moal_private *priv, struct ifreq *req)
{
struct iwreq *wrq = (struct iwreq *)req;
int len;
char buf[MLAN_MAX_VER_STR_LEN];
ENTER();
woal_get_version(priv->phandle, buf, sizeof(buf) - 1);
len = strlen(buf);
if (wrq->u.data.pointer) {
if (copy_to_user(wrq->u.data.pointer, buf, len)) {
PRINTM(MERROR, "Copy to user failed\n");
LEAVE();
return -EFAULT;
}
wrq->u.data.length = len;
}
PRINTM(MINFO, "MOAL VERSION: %s\n", buf);
LEAVE();
return 0;
}
/**
* @brief Get extended driver version
*
* @param priv A pointer to moal_private structure
* @param ireq A pointer to ifreq structure
*
* @return 0 --success, otherwise fail
*/
int woal_get_driver_verext(moal_private *priv, struct ifreq *ireq)
{
struct iwreq *wrq = (struct iwreq *)ireq;
mlan_ds_get_info *info = NULL;
mlan_ioctl_req *req = NULL;
int ret = 0;
mlan_status status = MLAN_STATUS_SUCCESS;
ENTER();
req = woal_alloc_mlan_ioctl_req(sizeof(mlan_ds_get_info));
if (req == NULL) {
LEAVE();
return -ENOMEM;
}
info = (mlan_ds_get_info *)req->pbuf;
info->sub_command = MLAN_OID_GET_VER_EXT;
req->req_id = MLAN_IOCTL_GET_INFO;
req->action = MLAN_ACT_GET;
if (!wrq->u.data.flags) {
info->param.ver_ext.version_str_sel =
*((int *)(wrq->u.name + SUBCMD_OFFSET));
} else {
if (copy_from_user(
&info->param.ver_ext.version_str_sel,
wrq->u.data.pointer,
sizeof(info->param.ver_ext.version_str_sel))) {
PRINTM(MERROR, "Copy from user failed\n");
ret = -EFAULT;
goto done;
} else {
if (((t_s32)(info->param.ver_ext.version_str_sel)) <
0) {
PRINTM(MERROR, "Invalid arguments!\n");
ret = -EINVAL;
goto done;
}
}
}
status = woal_request_ioctl(priv, req, MOAL_IOCTL_WAIT);
if (status != MLAN_STATUS_SUCCESS) {
ret = -EFAULT;
goto done;
}
if (wrq->u.data.pointer) {
if (copy_to_user(wrq->u.data.pointer,
info->param.ver_ext.version_str,
strlen(info->param.ver_ext.version_str))) {
PRINTM(MERROR, "Copy to user failed\n");
ret = -EFAULT;
goto done;
}
wrq->u.data.length = strlen(info->param.ver_ext.version_str);
}
PRINTM(MINFO, "MOAL EXTENDED VERSION: %s\n",
info->param.ver_ext.version_str);
done:
if (status != MLAN_STATUS_PENDING)
kfree(req);
LEAVE();
return ret;
}
#endif
#ifdef DEBUG_LEVEL1
/**
* @brief Set driver debug bit masks to mlan in order to enhance performance
*
* @param priv A pointer to moal_private structure
* @param drvdbg Driver debug level
*
* @return 0 --success, otherwise fail
*/
int woal_set_drvdbg(moal_private *priv, t_u32 drvdbg)
{
mlan_ioctl_req *req = NULL;
mlan_ds_misc_cfg *misc = NULL;
int ret = 0;
ENTER();
req = woal_alloc_mlan_ioctl_req(sizeof(mlan_ds_misc_cfg));
if (req == NULL) {
LEAVE();
return -ENOMEM;
}
misc = (mlan_ds_misc_cfg *)req->pbuf;
misc->sub_command = MLAN_OID_MISC_DRVDBG;
req->req_id = MLAN_IOCTL_MISC_CFG;
req->action = MLAN_ACT_SET;
misc->param.drvdbg = drvdbg;
ret = woal_request_ioctl(priv, req, MOAL_IOCTL_WAIT);
if (ret != MLAN_STATUS_PENDING)
kfree(req);
LEAVE();
return ret;
}
#endif
/**
* @brief Mgmt frame forward registration
*
* @param priv A pointer to moal_private structure
* @param action Action: set or get
* @param pmgmt_subtype_mask A Pointer to mgmt frame subtype mask
* @param wait_option wait option (MOAL_WAIT or MOAL_NO_WAIT)
*
* @return 0 --success, otherwise fail
*/
int woal_reg_rx_mgmt_ind(moal_private *priv, t_u16 action,
t_u32 *pmgmt_subtype_mask, t_u8 wait_option)
{
mlan_ioctl_req *req = NULL;
mlan_ds_misc_cfg *misc = NULL;
int ret = 0;
ENTER();
req = woal_alloc_mlan_ioctl_req(sizeof(mlan_ds_misc_cfg));
if (req == NULL) {
LEAVE();
return -ENOMEM;
}
misc = (mlan_ds_misc_cfg *)req->pbuf;
misc->sub_command = MLAN_OID_MISC_RX_MGMT_IND;
req->req_id = MLAN_IOCTL_MISC_CFG;
req->action = action;
misc->param.mgmt_subtype_mask = *pmgmt_subtype_mask;
if (req->action == MLAN_ACT_SET)
moal_memcpy_ext(priv->phandle, &misc->param.mgmt_subtype_mask,
pmgmt_subtype_mask,
sizeof(misc->param.mgmt_subtype_mask),
sizeof(misc->param.mgmt_subtype_mask));
ret = woal_request_ioctl(priv, req, wait_option);
if (req->action == MLAN_ACT_GET)
moal_memcpy_ext(priv->phandle, pmgmt_subtype_mask,
&misc->param.mgmt_subtype_mask,
sizeof(misc->param.mgmt_subtype_mask),
sizeof(misc->param.mgmt_subtype_mask));
if (ret != MLAN_STATUS_PENDING)
kfree(req);
LEAVE();
return ret;
}
/**
* @brief Set/Get Transmit beamforming capabilities
*
* @param priv A pointer to moal_private structure
* @param action Action: set or get
* @param tx_bf_cap A pointer to tx_buf_cap buffer
*
* @return MLAN_STATUS_SUCCESS -- success, otherwise fail
*/
mlan_status woal_set_get_tx_bf_cap(moal_private *priv, t_u16 action,
t_u32 *tx_bf_cap)
{
mlan_ioctl_req *req = NULL;
mlan_ds_11n_cfg *bf_cfg = NULL;
mlan_status ret = MLAN_STATUS_SUCCESS;
ENTER();
if (!tx_bf_cap) {
ret = MLAN_STATUS_FAILURE;
goto done;
}
/* Allocate an IOCTL request buffer */
req = woal_alloc_mlan_ioctl_req(sizeof(mlan_ds_11n_cfg));
if (req == NULL) {
ret = MLAN_STATUS_FAILURE;
goto done;
}
/* Fill request buffer */
bf_cfg = (mlan_ds_11n_cfg *)req->pbuf;
req->req_id = MLAN_IOCTL_11N_CFG;
bf_cfg->sub_command = MLAN_OID_11N_CFG_TX_BF_CAP;
req->action = action;
if (action == MLAN_ACT_SET)
bf_cfg->param.tx_bf_cap = *tx_bf_cap;
/* Send IOCTL request to MLAN */
ret = woal_request_ioctl(priv, req, MOAL_IOCTL_WAIT);
if (ret != MLAN_STATUS_SUCCESS) {
goto done;
}
if (action == MLAN_ACT_GET)
*tx_bf_cap = bf_cfg->param.tx_bf_cap;
done:
if (ret != MLAN_STATUS_PENDING)
kfree(req);
LEAVE();
return ret;
}
/**
* @brief Set/Get Transmit beamforming configuration
*
* @param priv A pointer to moal_private structure
* @param action Action: set or get
* @param tx_bf_cfg A pointer to tx_bf_cfg structure
*
* @return MLAN_STATUS_SUCCESS -- success, otherwise fail
*/
mlan_status woal_set_get_tx_bf_cfg(moal_private *priv, t_u16 action,
mlan_ds_11n_tx_bf_cfg *tx_bf_cfg)
{
mlan_status ret = MLAN_STATUS_SUCCESS;
mlan_ioctl_req *req = NULL;
mlan_ds_11n_cfg *bf_cfg = NULL;
ENTER();
/* Sanity test */
if (tx_bf_cfg == NULL) {
ret = MLAN_STATUS_FAILURE;
goto done;
}
/* Allocate an IOCTL request buffer */
req = woal_alloc_mlan_ioctl_req(sizeof(mlan_ds_11n_cfg));
if (req == NULL) {
ret = MLAN_STATUS_FAILURE;
goto done;
}
/* Fill request buffer */
bf_cfg = (mlan_ds_11n_cfg *)req->pbuf;
req->req_id = MLAN_IOCTL_11N_CFG;
bf_cfg->sub_command = MLAN_OID_11N_CFG_TX_BF_CFG;
req->action = action;
moal_memcpy_ext(priv->phandle, &bf_cfg->param.tx_bf, tx_bf_cfg,
sizeof(mlan_ds_11n_tx_bf_cfg),
sizeof(mlan_ds_11n_tx_bf_cfg));
/* Send IOCTL request to MLAN */
ret = woal_request_ioctl(priv, req, MOAL_IOCTL_WAIT);
if (ret != MLAN_STATUS_SUCCESS)
goto done;
if (action == MLAN_ACT_GET)
moal_memcpy_ext(priv->phandle, tx_bf_cfg, &bf_cfg->param.tx_bf,
sizeof(mlan_ds_11n_tx_bf_cfg),
sizeof(mlan_ds_11n_tx_bf_cfg));
done:
if (ret != MLAN_STATUS_PENDING)
kfree(req);
LEAVE();
return ret;
}
/**
* @brief Handle ioctl resp
*
* @param priv Pointer to moal_private structure
* @param req Pointer to mlan_ioctl_req structure
*
* @return N/A
*/
void woal_process_ioctl_resp(moal_private *priv, mlan_ioctl_req *req)
{
int cfg80211_wext;
ENTER();
if (priv == NULL) {
LEAVE();
return;
}
cfg80211_wext = priv->phandle->params.cfg80211_wext;
switch (req->req_id) {
case MLAN_IOCTL_GET_INFO:
#ifdef STA_WEXT
#ifdef STA_SUPPORT
if (IS_STA_WEXT(cfg80211_wext) &&
GET_BSS_ROLE(priv) == MLAN_BSS_ROLE_STA)
woal_ioctl_get_info_resp(priv,
(mlan_ds_get_info *)req->pbuf);
#endif
#endif
#ifdef UAP_WEXT
#ifdef UAP_SUPPORT
if (IS_UAP_WEXT(cfg80211_wext) &&
GET_BSS_ROLE(priv) == MLAN_BSS_ROLE_UAP)
woal_ioctl_get_uap_info_resp(
priv, (mlan_ds_get_info *)req->pbuf);
#endif
#endif
break;
#ifdef STA_WEXT
#ifdef STA_SUPPORT
case MLAN_IOCTL_BSS:
if (IS_STA_WEXT(cfg80211_wext) &&
GET_BSS_ROLE(priv) == MLAN_BSS_ROLE_STA)
woal_ioctl_get_bss_resp(priv, (mlan_ds_bss *)req->pbuf);
break;
#endif
#endif
case MLAN_IOCTL_MISC_CFG:
woal_ioctl_get_misc_conf(priv, (mlan_ds_misc_cfg *)req->pbuf);
default:
break;
}
LEAVE();
return;
}
/**
* @brief Get PM info
*
* @param priv A pointer to moal_private structure
* @param pm_info A pointer to mlan_ds_ps_info structure
*
* @return MLAN_STATUS_SUCCESS/MLAN_STATUS_PENDING --
* success, otherwise fail
*/
mlan_status woal_get_pm_info(moal_private *priv, mlan_ds_ps_info *pm_info)
{
mlan_status ret = MLAN_STATUS_SUCCESS;
mlan_ds_pm_cfg *pmcfg = NULL;
mlan_ioctl_req *req = NULL;
ENTER();
/* Allocate an IOCTL request buffer */
req = woal_alloc_mlan_ioctl_req(sizeof(mlan_ds_pm_cfg));
if (req == NULL) {
PRINTM(MERROR, "Fail to alloc mlan_ds_pm_cfg buffer\n");
ret = MLAN_STATUS_FAILURE;
goto done;
}
/* Fill request buffer */
pmcfg = (mlan_ds_pm_cfg *)req->pbuf;
pmcfg->sub_command = MLAN_OID_PM_INFO;
req->req_id = MLAN_IOCTL_PM_CFG;
req->action = MLAN_ACT_GET;
/* Send IOCTL request to MLAN */
ret = woal_request_ioctl(priv, req, MOAL_IOCTL_WAIT);
if (ret == MLAN_STATUS_SUCCESS) {
if (pm_info) {
moal_memcpy_ext(priv->phandle, pm_info,
&pmcfg->param.ps_info,
sizeof(mlan_ds_ps_info),
sizeof(mlan_ds_ps_info));
}
}
done:
if (ret != MLAN_STATUS_PENDING)
kfree(req);
LEAVE();
return ret;
}
/**
* @brief Get Deep Sleep
*
* @param priv Pointer to the moal_private driver data struct
* @param data Pointer to return deep_sleep setting
*
* @return 0 --success, otherwise fail
*/
int woal_get_deep_sleep(moal_private *priv, t_u32 *data)
{
int ret = 0;
mlan_ioctl_req *req = NULL;
mlan_ds_pm_cfg *pm = NULL;
mlan_status status = MLAN_STATUS_SUCCESS;
ENTER();
req = woal_alloc_mlan_ioctl_req(sizeof(mlan_ds_pm_cfg));
if (req == NULL) {
LEAVE();
return -ENOMEM;
}
pm = (mlan_ds_pm_cfg *)req->pbuf;
pm->sub_command = MLAN_OID_PM_CFG_DEEP_SLEEP;
req->req_id = MLAN_IOCTL_PM_CFG;
req->action = MLAN_ACT_GET;
status = woal_request_ioctl(priv, req, MOAL_IOCTL_WAIT);
if (status != MLAN_STATUS_SUCCESS) {
ret = -EFAULT;
goto done;
}
*data = pm->param.auto_deep_sleep.auto_ds;
*(data + 1) = pm->param.auto_deep_sleep.idletime;
done:
if (status != MLAN_STATUS_PENDING)
kfree(req);
LEAVE();
return ret;
}
/**
* @brief Set Deep Sleep
*
* @param priv Pointer to the moal_private driver data struct
* @param wait_option wait option
* @param bdeep_sleep TRUE--enalbe deepsleep, FALSE--disable deepsleep
* @param idletime Idle time for optimized PS API
*
* @return 0 --success, otherwise fail
*/
int woal_set_deep_sleep(moal_private *priv, t_u8 wait_option,
BOOLEAN bdeep_sleep, t_u16 idletime)
{
int ret = 0;
mlan_ioctl_req *req = NULL;
mlan_ds_pm_cfg *pm = NULL;
ENTER();
req = woal_alloc_mlan_ioctl_req(sizeof(mlan_ds_pm_cfg));
if (req == NULL) {
LEAVE();
return -ENOMEM;
}
pm = (mlan_ds_pm_cfg *)req->pbuf;
pm->sub_command = MLAN_OID_PM_CFG_DEEP_SLEEP;
req->req_id = MLAN_IOCTL_PM_CFG;
req->action = MLAN_ACT_SET;
if (bdeep_sleep == MTRUE) {
PRINTM(MIOCTL, "Deep Sleep: sleep\n");
pm->param.auto_deep_sleep.auto_ds = DEEP_SLEEP_ON;
if (idletime)
pm->param.auto_deep_sleep.idletime = idletime;
ret = woal_request_ioctl(priv, req, wait_option);
if (ret != MLAN_STATUS_SUCCESS && ret != MLAN_STATUS_PENDING) {
ret = -EFAULT;
goto done;
}
} else {
PRINTM(MIOCTL, "%lu : Deep Sleep: wakeup\n", jiffies);
pm->param.auto_deep_sleep.auto_ds = DEEP_SLEEP_OFF;
ret = woal_request_ioctl(priv, req, wait_option);
if (ret != MLAN_STATUS_SUCCESS && ret != MLAN_STATUS_PENDING) {
ret = -EFAULT;
goto done;
}
}
done:
if (ret != MLAN_STATUS_PENDING)
kfree(req);
LEAVE();
return ret;
}
/**
* @brief Cancel CAC period block
*
* @param priv A pointer to moal_private structure
*
* @return N/A
*/
void woal_cancel_cac_block(moal_private *priv)
{
ENTER();
/* if during CAC period, wake up wait queue */
if (priv->phandle->cac_period == MTRUE) {
priv->phandle->cac_period = MFALSE;
/* Make sure Chan Report is cancelled */
woal_11h_cancel_chan_report_ioctl(priv, MOAL_IOCTL_WAIT);
priv->phandle->meas_start_jiffies = 0;
if (priv->phandle->delay_bss_start == MTRUE)
priv->phandle->delay_bss_start = MFALSE;
if (priv->phandle->meas_wait_q_woken == MFALSE) {
priv->phandle->meas_wait_q_woken = MTRUE;
wake_up_interruptible(&priv->phandle->meas_wait_q);
}
#ifdef UAP_SUPPORT
#if defined(STA_CFG80211) || defined(UAP_CFG80211)
#if CFG80211_VERSION_CODE >= KERNEL_VERSION(3, 14, 0)
if (priv->uap_host_based &&
moal_extflg_isset(priv->phandle, EXT_DFS_OFFLOAD))
woal_cfg80211_dfs_vendor_event(
priv, event_dfs_cac_aborted, &priv->chan);
#endif
#endif
#endif
}
LEAVE();
}
/** MEAS report timeout value in seconds */
/**
* @brief Issue MLAN_OID_11H_CHANNEL_CHECK ioctl
*
* @param priv Pointer to the moal_private driver data struct
* @param wait_option wait option
*
* @return 0 --success, otherwise fail
*/
int woal_11h_channel_check_ioctl(moal_private *priv, t_u8 wait_option)
{
int ret = 0;
mlan_ioctl_req *req = NULL;
mlan_ds_11h_cfg *ds_11hcfg = NULL;
mlan_status status = MLAN_STATUS_SUCCESS;
ENTER();
#ifdef UAP_SUPPORT
if (priv->skip_cac) {
LEAVE();
return ret;
}
#endif
/* Skip sending request/report query when DFS_REPEATER_MODE is on. This
* would get rid of CAC timers before starting BSSes in
* DFS_REPEATER_MODE
*/
if (priv->phandle->dfs_repeater_mode) {
LEAVE();
return ret;
}
if (woal_is_any_interface_active(priv->phandle)) {
}
req = woal_alloc_mlan_ioctl_req(sizeof(mlan_ds_11h_cfg));
if (req == NULL) {
ret = -ENOMEM;
goto done;
}
ds_11hcfg = (mlan_ds_11h_cfg *)req->pbuf;
ds_11hcfg->sub_command = MLAN_OID_11H_CHANNEL_CHECK;
ds_11hcfg->param.chan_rpt_req.host_based = MFALSE;
req->req_id = MLAN_IOCTL_11H_CFG;
req->action = MLAN_ACT_SET;
/* Send Channel Check command and wait until the report is ready */
status = woal_request_ioctl(priv, req, wait_option);
if (status != MLAN_STATUS_SUCCESS) {
goto done;
}
/* set flag from here */
priv->phandle->cac_period = MTRUE;
priv->phandle->meas_start_jiffies = jiffies;
priv->phandle->cac_timer_jiffies =
ds_11hcfg->param.chan_rpt_req.millisec_dwell_time * HZ / 1000;
#ifdef UAP_SUPPORT
#if defined(STA_CFG80211) || defined(UAP_CFG80211)
#if CFG80211_VERSION_CODE >= KERNEL_VERSION(3, 14, 0)
if (priv->uap_host_based &&
moal_extflg_isset(priv->phandle, EXT_DFS_OFFLOAD))
woal_cfg80211_dfs_vendor_event(priv, event_dfs_cac_started,
&priv->chan);
#endif
#endif
#endif
done:
if (status != MLAN_STATUS_PENDING)
kfree(req);
LEAVE();
return ret;
}
/**
* @brief Issue MLAN_OID_11H_CHAN_REPORT_REQUEST ioctl to cancel dozer
*
* @param priv Pointer to the moal_private driver data struct
* @param wait_option wait option
*
* @return 0 --success, otherwise fail
*/
int woal_11h_cancel_chan_report_ioctl(moal_private *priv, t_u8 wait_option)
{
int ret = 0;
mlan_ioctl_req *req = NULL;
mlan_ds_11h_cfg *ds_11hcfg = NULL;
mlan_status status = MLAN_STATUS_SUCCESS;
ENTER();
req = woal_alloc_mlan_ioctl_req(sizeof(mlan_ds_11h_cfg));
if (req == NULL) {
ret = -ENOMEM;
goto done;
}
ds_11hcfg = (mlan_ds_11h_cfg *)req->pbuf;
ds_11hcfg->sub_command = MLAN_OID_11H_CHAN_REPORT_REQUEST;
req->req_id = MLAN_IOCTL_11H_CFG;
req->action = MLAN_ACT_SET;
ds_11hcfg->param.chan_rpt_req.millisec_dwell_time = 0;
/* Send Channel Check command and wait until the report is ready */
status = woal_request_ioctl(priv, req, wait_option);
if (status != MLAN_STATUS_SUCCESS) {
ret = -EFAULT;
goto done;
}
done:
if (status != MLAN_STATUS_PENDING)
kfree(req);
LEAVE();
return ret;
}
/**
* @brief set remain channel
*
* @param priv A pointer to moal_private structure
* @param wait_option Wait option
* @param pchan A pointer to mlan_ds_remain_chan structure
*
* @return MLAN_STATUS_SUCCESS -- success, otherwise fail
*/
mlan_status woal_set_remain_channel_ioctl(moal_private *priv, t_u8 wait_option,
mlan_ds_remain_chan *pchan)
{
mlan_status ret = MLAN_STATUS_SUCCESS;
mlan_ioctl_req *req = NULL;
mlan_ds_radio_cfg *radio_cfg = NULL;
ENTER();
req = woal_alloc_mlan_ioctl_req(sizeof(mlan_ds_radio_cfg));
if (req == NULL) {
ret = MLAN_STATUS_FAILURE;
goto done;
}
radio_cfg = (mlan_ds_radio_cfg *)req->pbuf;
radio_cfg->sub_command = MLAN_OID_REMAIN_CHAN_CFG;
req->req_id = MLAN_IOCTL_RADIO_CFG;
req->action = MLAN_ACT_SET;
moal_memcpy_ext(priv->phandle, &radio_cfg->param.remain_chan, pchan,
sizeof(mlan_ds_remain_chan),
sizeof(mlan_ds_remain_chan));
ret = woal_request_ioctl(priv, req, wait_option);
if (ret == MLAN_STATUS_SUCCESS) {
moal_memcpy_ext(priv->phandle, pchan,
&radio_cfg->param.remain_chan,
sizeof(mlan_ds_remain_chan),
sizeof(mlan_ds_remain_chan));
PRINTM(MCMND,
"Remain_chan_cfg: remove=%d, channel=%d, remain_period=%d\n",
pchan->remove, pchan->channel, pchan->remain_period);
}
done:
if (ret != MLAN_STATUS_PENDING)
kfree(req);
LEAVE();
return ret;
}
#ifdef WIFI_DIRECT_SUPPORT
/**
* @brief set/get wifi direct mode
*
* @param priv A pointer to moal_private structure
* @param action set or get
* @param mode A pointer to wifi direct mode
*
* @return MLAN_STATUS_SUCCESS -- success, otherwise fail
*/
mlan_status woal_wifi_direct_mode_cfg(moal_private *priv, t_u16 action,
t_u16 *mode)
{
mlan_status ret = MLAN_STATUS_SUCCESS;
mlan_ioctl_req *req = NULL;
mlan_ds_bss *bss = NULL;
ENTER();
req = woal_alloc_mlan_ioctl_req(sizeof(mlan_ds_bss));
if (req == NULL) {
ret = MLAN_STATUS_FAILURE;
goto done;
}
bss = (mlan_ds_bss *)req->pbuf;
bss->sub_command = MLAN_OID_WIFI_DIRECT_MODE;
req->req_id = MLAN_IOCTL_BSS;
req->action = action;
if (action == MLAN_ACT_SET)
bss->param.wfd_mode = *mode;
ret = woal_request_ioctl(priv, req, MOAL_IOCTL_WAIT);
if (ret == MLAN_STATUS_SUCCESS) {
*mode = bss->param.wfd_mode;
PRINTM(MIOCTL, "ACT=%d, wifi_direct_mode=%d\n", action, *mode);
}
done:
if (ret != MLAN_STATUS_PENDING)
kfree(req);
LEAVE();
return ret;
}
/**
* @brief Set p2p config
*
* @param priv A pointer to moal_private structure
* @param action Action set or get
* @param p2p_config A pointer to mlan_ds_wifi_direct_config structure
*
* @return MLAN_STATUS_SUCCESS -- success, otherwise fail
*/
mlan_status woal_p2p_config(moal_private *priv, t_u32 action,
mlan_ds_wifi_direct_config *p2p_config)
{
mlan_status ret = MLAN_STATUS_SUCCESS;
mlan_ioctl_req *req = NULL;
mlan_ds_misc_cfg *misc_cfg = NULL;
ENTER();
if (!p2p_config) {
LEAVE();
return MLAN_STATUS_FAILURE;
}
req = woal_alloc_mlan_ioctl_req(sizeof(mlan_ds_misc_cfg));
if (req == NULL) {
ret = MLAN_STATUS_FAILURE;
goto done;
}
misc_cfg = (mlan_ds_misc_cfg *)req->pbuf;
misc_cfg->sub_command = MLAN_OID_MISC_WIFI_DIRECT_CONFIG;
req->req_id = MLAN_IOCTL_MISC_CFG;
req->action = action;
moal_memcpy_ext(priv->phandle, &misc_cfg->param.p2p_config, p2p_config,
sizeof(mlan_ds_wifi_direct_config),
sizeof(mlan_ds_wifi_direct_config));
ret = woal_request_ioctl(priv, req, MOAL_IOCTL_WAIT);
if (ret == MLAN_STATUS_SUCCESS) {
if (action == MLAN_ACT_GET)
moal_memcpy_ext(priv->phandle, p2p_config,
&misc_cfg->param.p2p_config,
sizeof(mlan_ds_wifi_direct_config),
sizeof(mlan_ds_wifi_direct_config));
}
done:
if (ret != MLAN_STATUS_PENDING)
kfree(req);
LEAVE();
return ret;
}
#endif /* WIFI_DIRECT_SUPPORT */
#ifdef STA_SUPPORT
/**
* @brief Get STA Channel Info
*
* @param priv A pointer to moal_private structure
* @param wait_option Wait option
* @param channel A pointer to channel info
*
* @return MLAN_STATUS_SUCCESS/MLAN_STATUS_PENDING --
* success, otherwise fail
*/
mlan_status woal_get_sta_channel(moal_private *priv, t_u8 wait_option,
chan_band_info *channel)
{
int ret = 0;
mlan_ioctl_req *req = NULL;
mlan_ds_bss *bss = NULL;
mlan_status status = MLAN_STATUS_SUCCESS;
ENTER();
/* Allocate an IOCTL request buffer */
req = woal_alloc_mlan_ioctl_req(sizeof(mlan_ds_bss));
if (req == NULL) {
PRINTM(MERROR, "woal_get_sta_channel req alloc fail\n");
ret = MLAN_STATUS_FAILURE;
goto done;
}
/* Fill request buffer */
bss = (mlan_ds_bss *)req->pbuf;
bss->sub_command = MLAN_OID_BSS_CHAN_INFO;
req->req_id = MLAN_IOCTL_BSS;
req->action = MLAN_ACT_GET;
/* Send IOCTL request to MLAN */
status = woal_request_ioctl(priv, req, wait_option);
if (status == MLAN_STATUS_SUCCESS && channel)
moal_memcpy_ext(priv->phandle, channel,
&(bss->param.sta_channel),
sizeof(chan_band_info), sizeof(chan_band_info));
done:
if (status != MLAN_STATUS_PENDING)
kfree(req);
LEAVE();
return status;
}
/**
* @brief Get RSSI info
*
* @param priv A pointer to moal_private structure
* @param wait_option Wait option
* @param signal A pointer tp mlan_ds_get_signal structure
*
* @return MLAN_STATUS_SUCCESS/MLAN_STATUS_PENDING -- success,
* otherwise fail
*/
mlan_status woal_get_signal_info(moal_private *priv, t_u8 wait_option,
mlan_ds_get_signal *signal)
{
int ret = 0;
mlan_ds_get_info *info = NULL;
mlan_ioctl_req *req = NULL;
mlan_status status = MLAN_STATUS_SUCCESS;
ENTER();
/* Allocate an IOCTL request buffer */
req = woal_alloc_mlan_ioctl_req(sizeof(mlan_ds_get_info));
if (req == NULL) {
ret = -ENOMEM;
goto done;
}
/* Fill request buffer */
info = (mlan_ds_get_info *)req->pbuf;
info->sub_command = MLAN_OID_GET_SIGNAL;
info->param.signal.selector = ALL_RSSI_INFO_MASK;
req->req_id = MLAN_IOCTL_GET_INFO;
req->action = MLAN_ACT_GET;
/* Send IOCTL request to MLAN */
status = woal_request_ioctl(priv, req, wait_option);
if (status == MLAN_STATUS_SUCCESS) {
if (signal)
moal_memcpy_ext(priv->phandle, signal,
&info->param.signal,
sizeof(mlan_ds_get_signal),
sizeof(mlan_ds_get_signal));
#ifdef STA_WEXT
if (IS_STA_WEXT(priv->phandle->params.cfg80211_wext)) {
if (info->param.signal.selector & BCN_RSSI_AVG_MASK)
priv->w_stats.qual.level =
info->param.signal.bcn_rssi_avg;
if (info->param.signal.selector & BCN_NF_AVG_MASK)
priv->w_stats.qual.noise =
info->param.signal.bcn_nf_avg;
}
#endif
}
done:
if (status != MLAN_STATUS_PENDING)
kfree(req);
LEAVE();
return status;
}
/**
* @brief Get scan table
*
* @param priv A pointer to moal_private structure
* @param wait_option Wait option
* @param scan_resp A pointer to mlan_scan_resp structure
*
* @return MLAN_STATUS_SUCCESS/MLAN_STATUS_PENDING -- success,
* otherwise fail
*/
mlan_status woal_get_scan_table(moal_private *priv, t_u8 wait_option,
mlan_scan_resp *scan_resp)
{
int ret = 0;
mlan_ioctl_req *req = NULL;
mlan_ds_scan *scan = NULL;
mlan_status status = MLAN_STATUS_SUCCESS;
ENTER();
if (!scan_resp) {
LEAVE();
return MLAN_STATUS_FAILURE;
}
/* Allocate an IOCTL request buffer */
req = woal_alloc_mlan_ioctl_req(sizeof(mlan_ds_scan));
if (req == NULL) {
ret = -ENOMEM;
goto done;
}
/* Fill request buffer */
scan = (mlan_ds_scan *)req->pbuf;
scan->sub_command = MLAN_OID_SCAN_NORMAL;
req->req_id = MLAN_IOCTL_SCAN;
req->action = MLAN_ACT_GET;
moal_memcpy_ext(priv->phandle, (void *)&scan->param.scan_resp,
(void *)scan_resp, sizeof(mlan_scan_resp),
sizeof(mlan_scan_resp));
/* Send IOCTL request to MLAN */
status = woal_request_ioctl(priv, req, wait_option);
if (status == MLAN_STATUS_SUCCESS) {
if (scan_resp) {
moal_memcpy_ext(priv->phandle, scan_resp,
&scan->param.scan_resp,
sizeof(mlan_scan_resp),
sizeof(mlan_scan_resp));
}
}
done:
if (status != MLAN_STATUS_PENDING)
kfree(req);
LEAVE();
return status;
}
/**
* @brief Request a scan
*
* @param priv A pointer to moal_private structure
* @param wait_option Wait option
* @param req_ssid A pointer to mlan_802_11_ssid structure
*
* @return MLAN_STATUS_SUCCESS -- success, otherwise fail
*/
mlan_status woal_request_scan(moal_private *priv, t_u8 wait_option,
mlan_802_11_ssid *req_ssid)
{
mlan_status ret = MLAN_STATUS_SUCCESS;
moal_handle *handle = priv->phandle;
mlan_ioctl_req *ioctl_req = NULL;
mlan_ds_scan *scan = NULL;
mlan_status status = MLAN_STATUS_SUCCESS;
ENTER();
if (MOAL_ACQ_SEMAPHORE_BLOCK(&handle->async_sem)) {
PRINTM(MERROR, "Acquire semaphore error, request_scan\n");
LEAVE();
return MLAN_STATUS_FAILURE;
}
handle->scan_pending_on_block = MTRUE;
handle->scan_priv = priv;
/* Allocate an IOCTL request buffer */
ioctl_req = woal_alloc_mlan_ioctl_req(sizeof(mlan_ds_scan));
if (ioctl_req == NULL) {
ret = MLAN_STATUS_FAILURE;
goto done;
}
scan = (mlan_ds_scan *)ioctl_req->pbuf;
if (req_ssid && req_ssid->ssid_len != 0) {
/* Specific SSID scan */
ioctl_req->req_id = MLAN_IOCTL_SCAN;
ioctl_req->action = MLAN_ACT_SET;
scan->sub_command = MLAN_OID_SCAN_SPECIFIC_SSID;
moal_memcpy_ext(handle, scan->param.scan_req.scan_ssid.ssid,
req_ssid->ssid, req_ssid->ssid_len,
MLAN_MAX_SSID_LENGTH);
scan->param.scan_req.scan_ssid.ssid_len =
MIN(MLAN_MAX_SSID_LENGTH, req_ssid->ssid_len);
} else {
/* Normal scan */
ioctl_req->req_id = MLAN_IOCTL_SCAN;
ioctl_req->action = MLAN_ACT_SET;
scan->sub_command = MLAN_OID_SCAN_NORMAL;
}
/* Send IOCTL request to MLAN */
status = woal_request_ioctl(priv, ioctl_req, wait_option);
if (status == MLAN_STATUS_FAILURE) {
ret = MLAN_STATUS_FAILURE;
goto done;
}
done:
if (status != MLAN_STATUS_PENDING)
kfree(ioctl_req);
if (ret == MLAN_STATUS_FAILURE) {
handle->scan_pending_on_block = MFALSE;
handle->scan_priv = NULL;
MOAL_REL_SEMAPHORE(&handle->async_sem);
}
LEAVE();
return ret;
}
/**
* @brief Change Adhoc Channel
*
* @param priv A pointer to moal_private structure
* @param channel The channel to be set.
* @param wait_option wait_option
*
* @return MLAN_STATUS_SUCCESS--success, MLAN_STATUS_FAILURE--fail
*/
mlan_status woal_change_adhoc_chan(moal_private *priv, int channel,
t_u8 wait_option)
{
mlan_status ret = MLAN_STATUS_SUCCESS;
mlan_bss_info bss_info;
mlan_ds_bss *bss = NULL;
mlan_ioctl_req *req = NULL;
ENTER();
memset(&bss_info, 0, sizeof(bss_info));
/* Get BSS information */
if (MLAN_STATUS_SUCCESS !=
woal_get_bss_info(priv, wait_option, &bss_info)) {
ret = MLAN_STATUS_FAILURE;
goto done;
}
if (bss_info.bss_mode == MLAN_BSS_MODE_INFRA) {
ret = MLAN_STATUS_SUCCESS;
goto done;
}
/* Allocate an IOCTL request buffer */
req = woal_alloc_mlan_ioctl_req(sizeof(mlan_ds_bss));
if (req == NULL) {
ret = MLAN_STATUS_FAILURE;
goto done;
}
/* Get current channel */
bss = (mlan_ds_bss *)req->pbuf;
bss->sub_command = MLAN_OID_IBSS_CHANNEL;
req->req_id = MLAN_IOCTL_BSS;
req->action = MLAN_ACT_GET;
/* Send IOCTL request to MLAN */
ret = woal_request_ioctl(priv, req, wait_option);
if (ret != MLAN_STATUS_SUCCESS)
goto done;
if (bss->param.bss_chan.channel == (unsigned int)channel) {
ret = MLAN_STATUS_SUCCESS;
goto done;
}
PRINTM(MINFO, "Updating Channel from %d to %d\n",
(int)bss->param.bss_chan.channel, channel);
if (bss_info.media_connected != MTRUE) {
ret = MLAN_STATUS_SUCCESS;
goto done;
}
/* Do disonnect*/
bss->sub_command = MLAN_OID_BSS_STOP;
memset((t_u8 *)&bss->param.bssid, 0, ETH_ALEN);
/* Send IOCTL request to MLAN */
ret = woal_request_ioctl(priv, req, wait_option);
if (ret != MLAN_STATUS_SUCCESS)
goto done;
/* Do specific SSID scanning */
if (MLAN_STATUS_SUCCESS !=
woal_request_scan(priv, wait_option, &bss_info.ssid)) {
ret = MLAN_STATUS_FAILURE;
goto done;
}
/* Start/Join Adhoc network */
bss->sub_command = MLAN_OID_BSS_START;
memset(&bss->param.ssid_bssid, 0, sizeof(mlan_ssid_bssid));
moal_memcpy_ext(priv->phandle, &bss->param.ssid_bssid.ssid,
&bss_info.ssid, sizeof(mlan_802_11_ssid),
sizeof(mlan_802_11_ssid));
/* Send IOCTL request to MLAN */
ret = woal_request_ioctl(priv, req, wait_option);
done:
if (ret != MLAN_STATUS_PENDING)
kfree(req);
LEAVE();
return ret;
}
/**
* @brief Find the best network to associate
*
* @param priv A pointer to moal_private structure
* @param wait_option Wait option
* @param ssid_bssid A pointer to mlan_ssid_bssid structure
*
* @return MLAN_STATUS_SUCCESS/MLAN_STATUS_PENDING --
* success, otherwise fail
*/
mlan_status woal_find_best_network(moal_private *priv, t_u8 wait_option,
mlan_ssid_bssid *ssid_bssid)
{
mlan_ioctl_req *req = NULL;
mlan_ds_bss *bss = NULL;
mlan_status ret = MLAN_STATUS_SUCCESS;
t_u8 *mac = 0;
ENTER();
if (!ssid_bssid) {
ret = MLAN_STATUS_FAILURE;
goto done;
}
/* Allocate an IOCTL request buffer */
req = woal_alloc_mlan_ioctl_req(sizeof(mlan_ds_bss));
if (req == NULL) {
ret = MLAN_STATUS_FAILURE;
goto done;
}
/* Fill request buffer */
bss = (mlan_ds_bss *)req->pbuf;
req->req_id = MLAN_IOCTL_BSS;
req->action = MLAN_ACT_GET;
bss->sub_command = MLAN_OID_BSS_FIND_BSS;
moal_memcpy_ext(priv->phandle, &bss->param.ssid_bssid, ssid_bssid,
sizeof(mlan_ssid_bssid), sizeof(mlan_ssid_bssid));
/* Send IOCTL request to MLAN */
ret = woal_request_ioctl(priv, req, wait_option);
if (ret == MLAN_STATUS_SUCCESS) {
moal_memcpy_ext(priv->phandle, ssid_bssid,
&bss->param.ssid_bssid, sizeof(mlan_ssid_bssid),
sizeof(mlan_ssid_bssid));
mac = (t_u8 *)&ssid_bssid->bssid;
PRINTM(MINFO, "Find network: ssid=%s, " MACSTR ", idx=%d\n",
ssid_bssid->ssid.ssid, MAC2STR(mac),
(int)ssid_bssid->idx);
}
done:
if (ret != MLAN_STATUS_PENDING)
kfree(req);
LEAVE();
return ret;
}
/**
* @brief Find the best network to associate
*
* @param priv A pointer to moal_private structure
* @param bssid A pointer to bssid
*
* @return MLAN_STATUS_SUCCESS/MLAN_STATUS_PENDING --
* success, otherwise fail
*/
mlan_status woal_find_bssid(moal_private *priv, mlan_802_11_mac_addr bssid)
{
mlan_ioctl_req *req = NULL;
mlan_ds_bss *bss = NULL;
mlan_status ret = MLAN_STATUS_SUCCESS;
ENTER();
/* Allocate an IOCTL request buffer */
req = woal_alloc_mlan_ioctl_req(sizeof(mlan_ds_bss));
if (req == NULL) {
ret = MLAN_STATUS_FAILURE;
goto done;
}
/* Fill request buffer */
bss = (mlan_ds_bss *)req->pbuf;
req->req_id = MLAN_IOCTL_BSS;
req->action = MLAN_ACT_GET;
bss->sub_command = MLAN_OID_BSS_FIND_BSSID;
moal_memcpy_ext(priv->phandle, &bss->param.bssid, bssid,
sizeof(mlan_802_11_mac_addr),
sizeof(mlan_802_11_mac_addr));
/* Send IOCTL request to MLAN */
ret = woal_request_ioctl(priv, req, MOAL_IOCTL_WAIT);
done:
if (ret != MLAN_STATUS_PENDING)
kfree(req);
LEAVE();
return ret;
}
/**
* @brief Check if AP channel is valid for STA Region
*
* @param priv A pointer to moal_private structure
* @param wait_option Wait option
* @param ssid_bssid A pointer to mlan_ssid_bssid structure
*
* @return MLAN_STATUS_SUCCESS/MLAN_STATUS_PENDING -- success,
* otherwise fail
*/
mlan_status woal_11d_check_ap_channel(moal_private *priv, t_u8 wait_option,
mlan_ssid_bssid *ssid_bssid)
{
mlan_ioctl_req *req = NULL;
mlan_ds_bss *bss = NULL;
mlan_status ret = MLAN_STATUS_SUCCESS;
t_u8 *mac = 0;
ENTER();
if (!ssid_bssid) {
ret = MLAN_STATUS_FAILURE;
goto done;
}
/* Allocate an IOCTL request buffer */
req = woal_alloc_mlan_ioctl_req(sizeof(mlan_ds_bss));
if (req == NULL) {
ret = MLAN_STATUS_FAILURE;
goto done;
}
/* Fill request buffer */
bss = (mlan_ds_bss *)req->pbuf;
req->req_id = MLAN_IOCTL_BSS;
req->action = MLAN_ACT_GET;
bss->sub_command = MLAN_OID_BSS_11D_CHECK_CHANNEL;
moal_memcpy_ext(priv->phandle, &bss->param.ssid_bssid, ssid_bssid,
sizeof(mlan_ssid_bssid), sizeof(mlan_ssid_bssid));
mac = (t_u8 *)&ssid_bssid->bssid;
PRINTM(MINFO, "ssid=%s, " MACSTR ", idx=%d\n", ssid_bssid->ssid.ssid,
MAC2STR(mac), (int)ssid_bssid->idx);
/* Send IOCTL request to MLAN */
ret = woal_request_ioctl(priv, req, wait_option);
done:
if (ret != MLAN_STATUS_PENDING)
kfree(req);
LEAVE();
return ret;
}
/**
* @brief Get authentication mode
*
* @param priv A pointer to moal_private structure
* @param wait_option Wait option
* @param auth_mode A pointer to authentication mode
*
* @return MLAN_STATUS_SUCCESS/MLAN_STATUS_PENDING --
* success, otherwise fail
*/
mlan_status woal_get_auth_mode(moal_private *priv, t_u8 wait_option,
t_u32 *auth_mode)
{
int ret = 0;
mlan_ioctl_req *req = NULL;
mlan_ds_sec_cfg *sec = NULL;
mlan_status status = MLAN_STATUS_SUCCESS;
ENTER();
/* Allocate an IOCTL request buffer */
req = woal_alloc_mlan_ioctl_req(sizeof(mlan_ds_sec_cfg));
if (req == NULL) {
ret = -ENOMEM;
goto done;
}
/* Fill request buffer */
sec = (mlan_ds_sec_cfg *)req->pbuf;
sec->sub_command = MLAN_OID_SEC_CFG_AUTH_MODE;
req->req_id = MLAN_IOCTL_SEC_CFG;
req->action = MLAN_ACT_GET;
/* Send IOCTL request to MLAN */
status = woal_request_ioctl(priv, req, wait_option);
if (status == MLAN_STATUS_SUCCESS && auth_mode)
*auth_mode = sec->param.auth_mode;
done:
if (status != MLAN_STATUS_PENDING)
kfree(req);
LEAVE();
return status;
}
/**
* @brief Get encrypt mode
*
* @param priv A pointer to moal_private structure
* @param wait_option Wait option
* @param encrypt_mode A pointer to encrypt mode
*
* @return MLAN_STATUS_SUCCESS/MLAN_STATUS_PENDING --
* success, otherwise fail
*/
mlan_status woal_get_encrypt_mode(moal_private *priv, t_u8 wait_option,
t_u32 *encrypt_mode)
{
int ret = 0;
mlan_ioctl_req *req = NULL;
mlan_ds_sec_cfg *sec = NULL;
mlan_status status = MLAN_STATUS_SUCCESS;
ENTER();
/* Allocate an IOCTL request buffer */
req = woal_alloc_mlan_ioctl_req(sizeof(mlan_ds_sec_cfg));
if (req == NULL) {
ret = -ENOMEM;
goto done;
}
/* Fill request buffer */
sec = (mlan_ds_sec_cfg *)req->pbuf;
sec->sub_command = MLAN_OID_SEC_CFG_ENCRYPT_MODE;
req->req_id = MLAN_IOCTL_SEC_CFG;
req->action = MLAN_ACT_GET;
/* Send IOCTL request to MLAN */
status = woal_request_ioctl(priv, req, wait_option);
if (status == MLAN_STATUS_SUCCESS && encrypt_mode)
*encrypt_mode = sec->param.encrypt_mode;
done:
if (status != MLAN_STATUS_PENDING)
kfree(req);
LEAVE();
return status;
}
/**
* @brief Get WPA enable
*
* @param priv A pointer to moal_private structure
* @param wait_option Wait option
* @param enable A pointer to wpa enable status
*
* @return MLAN_STATUS_SUCCESS/MLAN_STATUS_PENDING --
* success, otherwise fail
*/
mlan_status woal_get_wpa_enable(moal_private *priv, t_u8 wait_option,
t_u32 *enable)
{
int ret = 0;
mlan_ioctl_req *req = NULL;
mlan_ds_sec_cfg *sec = NULL;
mlan_status status = MLAN_STATUS_SUCCESS;
ENTER();
/* Allocate an IOCTL request buffer */
req = woal_alloc_mlan_ioctl_req(sizeof(mlan_ds_sec_cfg));
if (req == NULL) {
ret = -ENOMEM;
goto done;
}
/* Fill request buffer */
sec = (mlan_ds_sec_cfg *)req->pbuf;
sec->sub_command = MLAN_OID_SEC_CFG_WPA_ENABLED;
req->req_id = MLAN_IOCTL_SEC_CFG;
req->action = MLAN_ACT_GET;
/* Send IOCTL request to MLAN */
status = woal_request_ioctl(priv, req, wait_option);
if (status == MLAN_STATUS_SUCCESS && enable)
*enable = sec->param.wpa_enabled;
done:
if (status != MLAN_STATUS_PENDING)
kfree(req);
LEAVE();
return status;
}
/**
* @brief Set authentication mode
*
* @param priv A pointer to moal_private structure
* @param wait_option Wait option
* @param auth_mode Authentication mode
*
* @return MLAN_STATUS_SUCCESS/MLAN_STATUS_PENDING --
* success, otherwise fail
*/
mlan_status woal_set_auth_mode(moal_private *priv, t_u8 wait_option,
t_u32 auth_mode)
{
int ret = 0;
mlan_ioctl_req *req = NULL;
mlan_ds_sec_cfg *sec = NULL;
mlan_status status = MLAN_STATUS_SUCCESS;
ENTER();
/* Allocate an IOCTL request buffer */
req = woal_alloc_mlan_ioctl_req(sizeof(mlan_ds_sec_cfg));
if (req == NULL) {
ret = -ENOMEM;
goto done;
}
/* Fill request buffer */
sec = (mlan_ds_sec_cfg *)req->pbuf;
sec->sub_command = MLAN_OID_SEC_CFG_AUTH_MODE;
req->req_id = MLAN_IOCTL_SEC_CFG;
req->action = MLAN_ACT_SET;
sec->param.auth_mode = auth_mode;
/* Send IOCTL request to MLAN */
status = woal_request_ioctl(priv, req, wait_option);
done:
if (status != MLAN_STATUS_PENDING)
kfree(req);
LEAVE();
return status;
}
/**
* @brief Set encrypt mode
*
* @param priv A pointer to moal_private structure
* @param wait_option Wait option
* @param encrypt_mode Encryption mode
*
* @return MLAN_STATUS_SUCCESS/MLAN_STATUS_PENDING --
* success, otherwise fail
*/
mlan_status woal_set_encrypt_mode(moal_private *priv, t_u8 wait_option,
t_u32 encrypt_mode)
{
int ret = 0;
mlan_ioctl_req *req = NULL;
mlan_ds_sec_cfg *sec = NULL;
mlan_status status = MLAN_STATUS_SUCCESS;
ENTER();
/* Allocate an IOCTL request buffer */
req = woal_alloc_mlan_ioctl_req(sizeof(mlan_ds_sec_cfg));
if (req == NULL) {
ret = -ENOMEM;
goto done;
}
/* Fill request buffer */
sec = (mlan_ds_sec_cfg *)req->pbuf;
sec->sub_command = MLAN_OID_SEC_CFG_ENCRYPT_MODE;
req->req_id = MLAN_IOCTL_SEC_CFG;
req->action = MLAN_ACT_SET;
sec->param.encrypt_mode = encrypt_mode;
/* Send IOCTL request to MLAN */
status = woal_request_ioctl(priv, req, wait_option);
done:
if (status != MLAN_STATUS_PENDING)
kfree(req);
LEAVE();
return status;
}
/**
* @brief Set wpa enable
*
* @param priv A pointer to moal_private structure
* @param wait_option Wait option
* @param enable MTRUE or MFALSE
*
* @return MLAN_STATUS_SUCCESS/MLAN_STATUS_PENDING --
* success, otherwise fail
*/
mlan_status woal_set_wpa_enable(moal_private *priv, t_u8 wait_option,
t_u32 enable)
{
int ret = 0;
mlan_ioctl_req *req = NULL;
mlan_ds_sec_cfg *sec = NULL;
mlan_status status = MLAN_STATUS_SUCCESS;
ENTER();
/* Allocate an IOCTL request buffer */
req = woal_alloc_mlan_ioctl_req(sizeof(mlan_ds_sec_cfg));
if (req == NULL) {
ret = -ENOMEM;
goto done;
}
/* Fill request buffer */
sec = (mlan_ds_sec_cfg *)req->pbuf;
sec->sub_command = MLAN_OID_SEC_CFG_WPA_ENABLED;
req->req_id = MLAN_IOCTL_SEC_CFG;
req->action = MLAN_ACT_SET;
sec->param.wpa_enabled = enable;
/* Send IOCTL request to MLAN */
status = woal_request_ioctl(priv, req, wait_option);
done:
if (status != MLAN_STATUS_PENDING)
kfree(req);
LEAVE();
return status;
}
/**
* @brief enable wep key
*
* @param priv A pointer to moal_private structure
* @param wait_option Wait option
*
* @return MLAN_STATUS_SUCCESS/MLAN_STATUS_PENDING --
* success, otherwise fail
*/
mlan_status woal_enable_wep_key(moal_private *priv, t_u8 wait_option)
{
int ret = 0;
mlan_ioctl_req *req = NULL;
mlan_ds_sec_cfg *sec = NULL;
mlan_status status = MLAN_STATUS_SUCCESS;
ENTER();
/* Allocate an IOCTL request buffer */
req = woal_alloc_mlan_ioctl_req(sizeof(mlan_ds_sec_cfg));
if (req == NULL) {
ret = -ENOMEM;
goto done;
}
/* Fill request buffer */
sec = (mlan_ds_sec_cfg *)req->pbuf;
sec->sub_command = MLAN_OID_SEC_CFG_ENCRYPT_KEY;
req->req_id = MLAN_IOCTL_SEC_CFG;
req->action = MLAN_ACT_SET;
sec->param.encrypt_key.key_disable = MFALSE;
sec->param.encrypt_key.key_index = MLAN_KEY_INDEX_DEFAULT;
sec->param.encrypt_key.is_current_wep_key = MTRUE;
/* Send IOCTL request to MLAN */
status = woal_request_ioctl(priv, req, wait_option);
done:
if (status != MLAN_STATUS_PENDING)
kfree(req);
LEAVE();
return status;
}
/**
* @brief Request user scan
*
* @param priv A pointer to moal_private structure
* @param wait_option Wait option
* @param scan_cfg A pointer to wlan_user_scan_config structure
*
* @return MLAN_STATUS_SUCCESS -- success, otherwise fail
*/
mlan_status woal_request_userscan(moal_private *priv, t_u8 wait_option,
wlan_user_scan_cfg *scan_cfg)
{
mlan_status ret = MLAN_STATUS_SUCCESS;
mlan_ioctl_req *ioctl_req = NULL;
mlan_ds_scan *scan = NULL;
mlan_status status = MLAN_STATUS_SUCCESS;
moal_handle *handle = priv->phandle;
ENTER();
if (MOAL_ACQ_SEMAPHORE_BLOCK(&handle->async_sem)) {
PRINTM(MERROR, "Acquire semaphore error, request_scan\n");
LEAVE();
return MLAN_STATUS_FAILURE;
}
handle->scan_pending_on_block = MTRUE;
handle->scan_priv = priv;
/* Allocate an IOCTL request buffer */
ioctl_req = woal_alloc_mlan_ioctl_req(sizeof(mlan_ds_scan) +
sizeof(wlan_user_scan_cfg));
if (ioctl_req == NULL) {
ret = MLAN_STATUS_FAILURE;
goto done;
}
scan = (mlan_ds_scan *)ioctl_req->pbuf;
scan->sub_command = MLAN_OID_SCAN_USER_CONFIG;
ioctl_req->req_id = MLAN_IOCTL_SCAN;
ioctl_req->action = MLAN_ACT_SET;
moal_memcpy_ext(handle, scan->param.user_scan.scan_cfg_buf, scan_cfg,
sizeof(wlan_user_scan_cfg), sizeof(wlan_user_scan_cfg));
/* Send IOCTL request to MLAN */
status = woal_request_ioctl(priv, ioctl_req, wait_option);
if (status == MLAN_STATUS_FAILURE) {
ret = MLAN_STATUS_FAILURE;
goto done;
}
done:
if (status != MLAN_STATUS_PENDING)
kfree(ioctl_req);
else if (wait_option != MOAL_NO_WAIT) {
PRINTM(MMSG, "scan interrupted by Signal, Cancel it...");
woal_cancel_scan(priv, MOAL_IOCTL_WAIT_TIMEOUT);
}
if (ret == MLAN_STATUS_FAILURE) {
handle->scan_pending_on_block = MFALSE;
handle->scan_priv = NULL;
MOAL_REL_SEMAPHORE(&handle->async_sem);
}
LEAVE();
return ret;
}
/**
* @brief woal_get_scan_config
*
* @param priv A pointer to moal_private structure
* @param scan_cfg A pointer to scan_cfg structure
*
* @return MLAN_STATUS_SUCCESS -- success, otherwise fail
*/
mlan_status woal_get_scan_config(moal_private *priv, mlan_scan_cfg *scan_cfg)
{
mlan_status ret = MLAN_STATUS_SUCCESS;
mlan_ds_scan *scan = NULL;
mlan_ioctl_req *req = NULL;
ENTER();
req = woal_alloc_mlan_ioctl_req(sizeof(mlan_ds_scan));
if (req == NULL) {
ret = MLAN_STATUS_FAILURE;
goto done;
}
scan = (mlan_ds_scan *)req->pbuf;
scan->sub_command = MLAN_OID_SCAN_CONFIG;
req->req_id = MLAN_IOCTL_SCAN;
req->action = MLAN_ACT_GET;
memset(&scan->param.scan_cfg, 0, sizeof(mlan_scan_cfg));
ret = woal_request_ioctl(priv, req, MOAL_IOCTL_WAIT);
if (ret == MLAN_STATUS_SUCCESS && scan_cfg)
moal_memcpy_ext(priv->phandle, scan_cfg, &scan->param.scan_cfg,
sizeof(mlan_scan_cfg), sizeof(mlan_scan_cfg));
done:
if (ret != MLAN_STATUS_PENDING)
kfree(req);
LEAVE();
return ret;
}
/**
* @brief set scan time
*
* @param priv A pointer to moal_private structure
* @param active_scan_time Active scan time
* @param passive_scan_time Passive scan time
* @param specific_scan_time Specific scan time
*
* @return MLAN_STATUS_SUCCESS -- success, otherwise fail
*/
mlan_status woal_set_scan_time(moal_private *priv, t_u16 active_scan_time,
t_u16 passive_scan_time,
t_u16 specific_scan_time)
{
mlan_status ret = MLAN_STATUS_SUCCESS;
mlan_ds_scan *scan = NULL;
mlan_ioctl_req *req = NULL;
mlan_scan_cfg scan_cfg;
ENTER();
memset(&scan_cfg, 0, sizeof(scan_cfg));
if (MLAN_STATUS_SUCCESS != woal_get_scan_config(priv, &scan_cfg)) {
ret = MLAN_STATUS_FAILURE;
goto done;
}
req = woal_alloc_mlan_ioctl_req(sizeof(mlan_ds_scan));
if (req == NULL) {
ret = MLAN_STATUS_FAILURE;
goto done;
}
scan = (mlan_ds_scan *)req->pbuf;
scan->sub_command = MLAN_OID_SCAN_CONFIG;
req->req_id = MLAN_IOCTL_SCAN;
req->action = MLAN_ACT_SET;
memset(&scan->param.scan_cfg, 0, sizeof(mlan_scan_cfg));
scan_cfg.scan_time.active_scan_time = active_scan_time;
scan_cfg.scan_time.specific_scan_time = specific_scan_time;
scan_cfg.scan_time.passive_scan_time = passive_scan_time;
PRINTM(MIOCTL, "Set specific=%d, active=%d, passive=%d\n",
(int)active_scan_time, (int)passive_scan_time,
(int)specific_scan_time);
moal_memcpy_ext(priv->phandle, &scan->param.scan_cfg, &scan_cfg,
sizeof(mlan_scan_cfg), sizeof(mlan_scan_cfg));
ret = woal_request_ioctl(priv, req, MOAL_IOCTL_WAIT);
done:
if (ret != MLAN_STATUS_PENDING)
kfree(req);
LEAVE();
return ret;
}
/**
* @brief request scan
*
* @param priv A pointer to moal_private structure
* @param scan_cfg A pointer to wlan_user_scan_cfg structure
*
* @return MLAN_STATUS_SUCCESS -- success, otherwise fail
*/
mlan_status woal_do_scan(moal_private *priv, wlan_user_scan_cfg *scan_cfg)
{
mlan_status ret = MLAN_STATUS_SUCCESS;
moal_handle *handle = priv->phandle;
ENTER();
if (handle->scan_pending_on_block == MTRUE) {
PRINTM(MINFO, "scan already in processing...\n");
LEAVE();
return ret;
}
#ifdef REASSOCIATION
if (MOAL_ACQ_SEMAPHORE_BLOCK(&handle->reassoc_sem)) {
PRINTM(MERROR, "Acquire semaphore error, woal_do_combo_scan\n");
LEAVE();
return -EBUSY;
}
#endif /* REASSOCIATION */
priv->report_scan_result = MTRUE;
if (!scan_cfg)
ret = woal_request_scan(priv, MOAL_NO_WAIT, NULL);
else
ret = woal_request_userscan(priv, MOAL_NO_WAIT, scan_cfg);
#ifdef REASSOCIATION
MOAL_REL_SEMAPHORE(&handle->reassoc_sem);
#endif
LEAVE();
return ret;
}
/**
* @brief Cancel pending scan
*
* @param priv A pointer to moal_private structure
* @return MLAN_STATUS_SUCCESS -- success, otherwise fail
*/
mlan_status woal_cancel_scan(moal_private *priv, t_u8 wait_option)
{
mlan_ioctl_req *req = NULL;
mlan_status ret = MLAN_STATUS_SUCCESS;
moal_handle *handle = priv->phandle;
moal_private *scan_priv = handle->scan_priv;
#ifdef STA_CFG80211
unsigned long flags;
#endif
/* If scan is in process, cancel the scan command */
if (!handle->scan_pending_on_block || !scan_priv)
return ret;
req = woal_alloc_mlan_ioctl_req(sizeof(mlan_ds_scan));
if (req == NULL) {
ret = MLAN_STATUS_FAILURE;
goto done;
}
req->req_id = MLAN_IOCTL_SCAN;
req->action = MLAN_ACT_SET;
((mlan_ds_scan *)req->pbuf)->sub_command = MLAN_OID_SCAN_CANCEL;
ret = woal_request_ioctl(scan_priv, req, wait_option);
handle->scan_pending_on_block = MFALSE;
MOAL_REL_SEMAPHORE(&handle->async_sem);
#ifdef STA_CFG80211
spin_lock_irqsave(&handle->scan_req_lock, flags);
if (IS_STA_CFG80211(handle->params.cfg80211_wext) &&
handle->scan_request) {
/** some supplicant can not handle SCAN abort event */
if (scan_priv->bss_type == MLAN_BSS_TYPE_STA)
woal_cfg80211_scan_done(handle->scan_request, MTRUE);
else
woal_cfg80211_scan_done(handle->scan_request, MFALSE);
handle->scan_request = NULL;
}
spin_unlock_irqrestore(&handle->scan_req_lock, flags);
#endif
/* add 10ms delay, incase firmware delay 0x7f event after scan cancel
* command response */
woal_sched_timeout(10);
handle->scan_priv = NULL;
done:
if (ret != MLAN_STATUS_PENDING)
kfree(req);
return ret;
}
/**
* @brief find ssid in scan_table
*
* @param priv A pointer to moal_private
* @param ssid_bssid A pointer to mlan_ssid_bssid structure
*
*
* @return MLAN_STATUS_SUCCESS/MLAN_STATUS_FAILURE
*/
int woal_find_essid(moal_private *priv, mlan_ssid_bssid *ssid_bssid,
t_u8 wait_option)
{
int ret = 0;
mlan_scan_resp scan_resp;
wifi_timeval t;
ENTER();
if (MLAN_STATUS_SUCCESS !=
woal_get_scan_table(priv, wait_option, &scan_resp)) {
LEAVE();
return MLAN_STATUS_FAILURE;
}
#ifdef STA_CFG80211
if (priv->ft_pre_connect || priv->ft_ie_len) {
/** skip check the scan age out */
ret = woal_find_best_network(priv, wait_option, ssid_bssid);
LEAVE();
return ret;
}
#endif
woal_get_monotonic_time(&t);
/** scan result timeout value */
#define SCAN_RESULT_AGEOUT 10
if (t.time_sec > (scan_resp.age_in_secs + SCAN_RESULT_AGEOUT)) {
LEAVE();
return MLAN_STATUS_FAILURE;
}
ret = woal_find_best_network(priv, wait_option, ssid_bssid);
LEAVE();
return ret;
}
/**
* @brief Request user scan
*
* @param priv A pointer to moal_private structure
* @param wait_option Wait option
* @param scan_cfg A pointer to wlan_bgscan_cfg structure
*
* @return MLAN_STATUS_SUCCESS -- success, otherwise fail
*/
mlan_status woal_request_bgscan(moal_private *priv, t_u8 wait_option,
wlan_bgscan_cfg *scan_cfg)
{
mlan_status ret = MLAN_STATUS_SUCCESS;
mlan_ioctl_req *ioctl_req = NULL;
mlan_ds_scan *scan = NULL;
mlan_status status = MLAN_STATUS_SUCCESS;
ENTER();
/* Allocate an IOCTL request buffer */
ioctl_req = woal_alloc_mlan_ioctl_req(sizeof(mlan_ds_scan) +
sizeof(wlan_bgscan_cfg));
if (ioctl_req == NULL) {
ret = MLAN_STATUS_FAILURE;
goto done;
}
scan = (mlan_ds_scan *)ioctl_req->pbuf;
scan->sub_command = MLAN_OID_SCAN_BGSCAN_CONFIG;
ioctl_req->req_id = MLAN_IOCTL_SCAN;
ioctl_req->action = MLAN_ACT_SET;
moal_memcpy_ext(priv->phandle, scan->param.user_scan.scan_cfg_buf,
scan_cfg, sizeof(wlan_bgscan_cfg),
sizeof(wlan_bgscan_cfg));
/* Send IOCTL request to MLAN */
status = woal_request_ioctl(priv, ioctl_req, wait_option);
if (status == MLAN_STATUS_FAILURE) {
ret = MLAN_STATUS_FAILURE;
goto done;
}
done:
if (status != MLAN_STATUS_PENDING)
kfree(ioctl_req);
LEAVE();
return ret;
}
/**
* @brief set bgscan config
*
* @param priv A pointer to moal_private structure
* @param buf A pointer to scan command buf
* @param length buf length
*
* @return MLAN_STATUS_SUCCESS -- success, otherwise fail
*/
mlan_status woal_set_bg_scan(moal_private *priv, char *buf, int length)
{
t_u8 *ptr = buf + strlen("BGSCAN-CONFIG") + 1;
int buf_left = length - (strlen("BGSCAN-CONFIG") + 1);
int band = 0;
int num_ssid = 0;
int ssid_len = 0;
mlan_status ret = MLAN_STATUS_FAILURE;
ENTER();
memset(&priv->scan_cfg, 0, sizeof(priv->scan_cfg));
priv->scan_cfg.report_condition =
BG_SCAN_SSID_MATCH | BG_SCAN_WAIT_ALL_CHAN_DONE;
while (buf_left >= 2) {
switch (*ptr) {
case WEXT_CSCAN_SSID_SECTION:
ssid_len = *(ptr + 1);
if ((buf_left < (ssid_len + 2)) ||
(ssid_len > MLAN_MAX_SSID_LENGTH)) {
PRINTM(MERROR,
"Invalid ssid, buf_left=%d, ssid_len=%d\n",
buf_left, ssid_len);
buf_left = 0;
break;
}
if (ssid_len &&
(num_ssid < (MRVDRV_MAX_SSID_LIST_LENGTH - 1))) {
strncpy(priv->scan_cfg.ssid_list[num_ssid].ssid,
ptr + 2, ssid_len);
priv->scan_cfg.ssid_list[num_ssid].max_len = 0;
PRINTM(MIOCTL, "BG scan: ssid=%s\n",
priv->scan_cfg.ssid_list[num_ssid].ssid);
num_ssid++;
}
buf_left -= ssid_len + 2;
ptr += ssid_len + 2;
break;
case WEXT_BGSCAN_RSSI_SECTION:
priv->scan_cfg.report_condition =
BG_SCAN_SSID_RSSI_MATCH |
BG_SCAN_WAIT_ALL_CHAN_DONE;
priv->scan_cfg.rssi_threshold = ptr[1];
PRINTM(MIOCTL, "BG scan: rssi_threshold=%d\n",
(int)priv->scan_cfg.rssi_threshold);
ptr += 2;
buf_left -= 2;
break;
case WEXT_BGSCAN_REPEAT_SECTION:
priv->scan_cfg.repeat_count = (t_u16)ptr[1];
PRINTM(MIOCTL, "BG scan: repeat_count=%d\n",
(int)priv->scan_cfg.repeat_count);
ptr += 2;
buf_left -= 2;
break;
case WEXT_BGSCAN_INTERVAL_SECTION:
if (buf_left < 3) {
PRINTM(MERROR,
"Invalid scan_interval, buf_left=%d\n",
buf_left);
buf_left = 0;
break;
}
priv->scan_cfg.scan_interval =
(ptr[2] << 8 | ptr[1]) * 1000;
PRINTM(MIOCTL, "BG scan: scan_interval=%d\n",
(int)priv->scan_cfg.scan_interval);
ptr += 3;
buf_left -= 3;
break;
default:
buf_left = 0;
break;
}
}
/** set bgscan when ssid_num > 0 */
if (num_ssid) {
if (MLAN_STATUS_SUCCESS != woal_get_band(priv, &band)) {
ret = MLAN_STATUS_FAILURE;
goto done;
}
switch (band) {
case WIFI_FREQUENCY_BAND_2GHZ:
priv->scan_cfg.chan_list[0].radio_type =
0 | BAND_SPECIFIED;
break;
case WIFI_FREQUENCY_BAND_5GHZ:
priv->scan_cfg.chan_list[0].radio_type =
1 | BAND_SPECIFIED;
break;
default:
break;
}
priv->scan_cfg.bss_type = MLAN_BSS_MODE_INFRA;
priv->scan_cfg.action = BG_SCAN_ACT_SET;
priv->scan_cfg.enable = MTRUE;
moal_memcpy_ext(priv->phandle, priv->scan_cfg.random_mac,
priv->random_mac, ETH_ALEN,
sizeof(priv->scan_cfg.random_mac));
ret = woal_request_bgscan(priv, MOAL_IOCTL_WAIT,
&priv->scan_cfg);
}
done:
LEAVE();
return ret;
}
#ifdef STA_CFG80211
/**
* @brief set bgscan and new rssi_low_threshold
*
* @param priv A pointer to moal_private structure
* @param set_rssi flag for set rssi_low_threshold
*
* @return N/A
*/
void woal_config_bgscan_and_rssi(moal_private *priv, t_u8 set_rssi)
{
char rssi_low[11];
mlan_bss_info bss_info;
int band = 0;
ENTER();
if (!priv->rssi_low) {
LEAVE();
return;
}
memset(&bss_info, 0, sizeof(bss_info));
woal_get_bss_info(priv, MOAL_IOCTL_WAIT, &bss_info);
if (!bss_info.media_connected) {
PRINTM(MIOCTL, "We already lost connection\n");
LEAVE();
return;
}
memset(&priv->scan_cfg, 0, sizeof(priv->scan_cfg));
strncpy(priv->scan_cfg.ssid_list[0].ssid, bss_info.ssid.ssid,
bss_info.ssid.ssid_len);
priv->scan_cfg.ssid_list[0].max_len = 0;
priv->scan_cfg.report_condition =
BG_SCAN_SSID_RSSI_MATCH | BG_SCAN_WAIT_ALL_CHAN_DONE;
priv->scan_cfg.rssi_threshold = priv->rssi_low - RSSI_HYSTERESIS;
priv->scan_cfg.repeat_count = DEF_REPEAT_COUNT;
priv->scan_cfg.scan_interval = MIN_BGSCAN_INTERVAL;
woal_get_band(priv, &band);
switch (band) {
case WIFI_FREQUENCY_BAND_2GHZ:
priv->scan_cfg.chan_list[0].radio_type = 0 | BAND_SPECIFIED;
break;
case WIFI_FREQUENCY_BAND_5GHZ:
priv->scan_cfg.chan_list[0].radio_type = 1 | BAND_SPECIFIED;
break;
default:
break;
}
priv->scan_cfg.bss_type = MLAN_BSS_MODE_INFRA;
priv->scan_cfg.action = BG_SCAN_ACT_SET;
priv->scan_cfg.enable = MTRUE;
moal_memcpy_ext(priv->phandle, priv->scan_cfg.random_mac,
priv->random_mac, ETH_ALEN,
sizeof(priv->scan_cfg.random_mac));
woal_request_bgscan(priv, MOAL_NO_WAIT, &priv->scan_cfg);
if (set_rssi &&
((priv->rssi_low + RSSI_HYSTERESIS) <= LOWEST_RSSI_THRESHOLD)) {
priv->rssi_low += RSSI_HYSTERESIS;
snprintf(rssi_low, sizeof(rssi_low), "%d", priv->rssi_low);
woal_set_rssi_low_threshold(priv, rssi_low, MOAL_NO_WAIT);
}
LEAVE();
}
#endif
/**
* @brief stop bg scan
*
* @param priv A pointer to moal_private structure
* @param wait_option wait option
*
* @return MLAN_STATUS_SUCCESS -- success, otherwise fail
*/
mlan_status woal_stop_bg_scan(moal_private *priv, t_u8 wait_option)
{
wlan_bgscan_cfg scan_cfg;
mlan_status ret = MLAN_STATUS_SUCCESS;
ENTER();
memset(&scan_cfg, 0, sizeof(scan_cfg));
scan_cfg.action = BG_SCAN_ACT_SET;
scan_cfg.enable = MFALSE;
ret = woal_request_bgscan(priv, wait_option, &scan_cfg);
LEAVE();
return ret;
}
/**
* @brief set bgscan config
*
* @param handle A pointer to moal_handle structure
*
* @return MLAN_STATUS_SUCCESS -- success, otherwise fail
*/
void woal_reconfig_bgscan(moal_handle *handle)
{
int i;
for (i = 0; i < MIN(handle->priv_num, MLAN_MAX_BSS_NUM); i++) {
if (handle->priv[i] &&
(GET_BSS_ROLE(handle->priv[i]) == MLAN_BSS_ROLE_STA)) {
if (handle->priv[i]->bg_scan_start &&
handle->priv[i]->bg_scan_reported) {
PRINTM(MIOCTL, "Reconfig BGSCAN\n");
woal_request_bgscan(handle->priv[i],
MOAL_NO_WAIT,
&handle->priv[i]->scan_cfg);
handle->priv[i]->bg_scan_reported = MFALSE;
}
}
}
}
/**
* @brief set rssi low threshold
*
* @param priv A pointer to moal_private structure
* @param rssi A pointer to low rssi
* @param wait_option Wait option
*
* @return MLAN_STATUS_SUCCESS -- success, otherwise fail
*/
mlan_status woal_set_rssi_low_threshold(moal_private *priv, char *rssi,
t_u8 wait_option)
{
mlan_status ret = MLAN_STATUS_SUCCESS;
mlan_ioctl_req *req = NULL;
mlan_ds_misc_cfg *misc = NULL;
int low_rssi = 0;
ENTER();
if (priv->media_connected == MFALSE)
goto done;
req = woal_alloc_mlan_ioctl_req(sizeof(mlan_ds_misc_cfg));
if (req == NULL) {
ret = MLAN_STATUS_FAILURE;
goto done;
}
misc = (mlan_ds_misc_cfg *)req->pbuf;
req->req_id = MLAN_IOCTL_MISC_CFG;
misc->sub_command = MLAN_OID_MISC_SUBSCRIBE_EVENT;
req->action = MLAN_ACT_SET;
misc->param.subscribe_event.evt_action = SUBSCRIBE_EVT_ACT_BITWISE_SET;
misc->param.subscribe_event.evt_bitmap = SUBSCRIBE_EVT_RSSI_LOW;
misc->param.subscribe_event.evt_bitmap |= SUBSCRIBE_EVT_PRE_BEACON_LOST;
misc->param.subscribe_event.pre_beacon_miss = DEFAULT_PRE_BEACON_MISS;
if (MLAN_STATUS_SUCCESS != woal_atoi(&low_rssi, rssi)) {
ret = MLAN_STATUS_FAILURE;
goto done;
}
#ifdef STA_CFG80211
priv->mrvl_rssi_low = low_rssi;
#endif
misc->param.subscribe_event.low_rssi = low_rssi;
misc->param.subscribe_event.low_rssi_freq = 0;
ret = woal_request_ioctl(priv, req, wait_option);
if (ret == MLAN_STATUS_FAILURE) {
PRINTM(MERROR, "request set rssi_low_threshold fail!\n");
goto done;
}
done:
if (ret != MLAN_STATUS_PENDING)
kfree(req);
LEAVE();
return ret;
}
#if defined(STA_CFG80211)
/**
* @brief set rssi low threshold
*
* @param priv A pointer to moal_private structure
* @param event_id event id.
* @param wait_option wait option
*
* @return MLAN_STATUS_SUCCESS -- success, otherwise fail
*/
mlan_status woal_set_rssi_threshold(moal_private *priv, t_u32 event_id,
t_u8 wait_option)
{
mlan_status ret = MLAN_STATUS_SUCCESS;
mlan_ioctl_req *req = NULL;
mlan_ds_misc_cfg *misc = NULL;
ENTER();
if (priv->media_connected == MFALSE)
goto done;
if (priv->mrvl_rssi_low || !priv->cqm_rssi_thold)
goto done;
if (event_id == MLAN_EVENT_ID_FW_BCN_RSSI_LOW) {
if (priv->last_rssi_low < 100)
priv->last_rssi_low += priv->cqm_rssi_hyst;
priv->last_rssi_high = abs(priv->cqm_rssi_high_thold);
} else if (event_id == MLAN_EVENT_ID_FW_BCN_RSSI_HIGH) {
priv->last_rssi_low = abs(priv->cqm_rssi_thold);
if (priv->last_rssi_high > priv->cqm_rssi_hyst)
priv->last_rssi_high -= priv->cqm_rssi_hyst;
} else {
priv->last_rssi_low = abs(priv->cqm_rssi_thold);
priv->last_rssi_high = abs(priv->cqm_rssi_high_thold);
}
req = woal_alloc_mlan_ioctl_req(sizeof(mlan_ds_misc_cfg));
if (req == NULL) {
ret = -ENOMEM;
goto done;
}
misc = (mlan_ds_misc_cfg *)req->pbuf;
req->req_id = MLAN_IOCTL_MISC_CFG;
misc->sub_command = MLAN_OID_MISC_SUBSCRIBE_EVENT;
req->action = MLAN_ACT_SET;
if (!event_id && !priv->cqm_rssi_thold && !priv->cqm_rssi_hyst)
misc->param.subscribe_event.evt_action =
SUBSCRIBE_EVT_ACT_BITWISE_CLR;
else
misc->param.subscribe_event.evt_action =
SUBSCRIBE_EVT_ACT_BITWISE_SET;
misc->param.subscribe_event.evt_bitmap =
SUBSCRIBE_EVT_RSSI_LOW | SUBSCRIBE_EVT_RSSI_HIGH;
misc->param.subscribe_event.low_rssi_freq = 0;
misc->param.subscribe_event.low_rssi = priv->last_rssi_low;
misc->param.subscribe_event.high_rssi_freq = 0;
misc->param.subscribe_event.high_rssi = priv->last_rssi_high;
PRINTM(MIOCTL, "rssi_low=%d, rssi_high=%d action=%d\n",
(int)priv->last_rssi_low, (int)priv->last_rssi_high,
misc->param.subscribe_event.evt_action);
ret = woal_request_ioctl(priv, req, wait_option);
done:
if (ret != MLAN_STATUS_PENDING)
kfree(req);
LEAVE();
return ret;
}
#endif
/**
* @brief Get power mode
*
* @param priv A pointer to moal_private structure
* @param powermode A pointer to powermode buf
*
* @return MLAN_STATUS_SUCCESS -- success, otherwise fail
*/
mlan_status woal_get_powermode(moal_private *priv, int *powermode)
{
mlan_status ret = MLAN_STATUS_SUCCESS;
int ps_mode;
ENTER();
if (MLAN_STATUS_SUCCESS != woal_set_get_power_mgmt(priv, MLAN_ACT_GET,
&ps_mode, 0,
MOAL_IOCTL_WAIT)) {
ret = MLAN_STATUS_FAILURE;
goto done;
}
if (ps_mode)
*powermode = MFALSE;
else
*powermode = MTRUE;
done:
LEAVE();
return ret;
}
/**
* @brief set scan type
*
* @param priv A pointer to moal_private structure
* @param scan_type MLAN_SCAN_TYPE_ACTIVE/MLAN_SCAN_TYPE_PASSIVE
*
* @return MLAN_STATUS_SUCCESS -- success, otherwise fail
*/
mlan_status woal_set_scan_type(moal_private *priv, t_u32 scan_type)
{
mlan_status ret = MLAN_STATUS_SUCCESS;
mlan_ds_scan *scan = NULL;
mlan_ioctl_req *req = NULL;
mlan_scan_cfg scan_cfg;
ENTER();
memset(&scan_cfg, 0, sizeof(scan_cfg));
if (MLAN_STATUS_SUCCESS != woal_get_scan_config(priv, &scan_cfg)) {
ret = MLAN_STATUS_FAILURE;
goto done;
}
req = woal_alloc_mlan_ioctl_req(sizeof(mlan_ds_scan));
if (req == NULL) {
ret = MLAN_STATUS_FAILURE;
goto done;
}
scan = (mlan_ds_scan *)req->pbuf;
scan->sub_command = MLAN_OID_SCAN_CONFIG;
req->req_id = MLAN_IOCTL_SCAN;
req->action = MLAN_ACT_SET;
memset(&scan->param.scan_cfg, 0, sizeof(mlan_scan_cfg));
scan_cfg.scan_type = scan_type;
PRINTM(MIOCTL, "Set scan_type=%d\n", (int)scan_type);
moal_memcpy_ext(priv->phandle, &scan->param.scan_cfg, &scan_cfg,
sizeof(mlan_scan_cfg), sizeof(mlan_scan_cfg));
ret = woal_request_ioctl(priv, req, MOAL_IOCTL_WAIT);
done:
if (ret != MLAN_STATUS_PENDING)
kfree(req);
LEAVE();
return ret;
}
/**
* @brief enable/disable ext_scan
*
* @param priv A pointer to moal_private structure
* @param enable MTRUE -- enable, MFALSE --disable
*
* @return MLAN_STATUS_SUCCESS -- success, otherwise fail
*/
mlan_status woal_enable_ext_scan(moal_private *priv, t_u8 enable)
{
mlan_status ret = MLAN_STATUS_SUCCESS;
mlan_ds_scan *scan = NULL;
mlan_ioctl_req *req = NULL;
mlan_scan_cfg scan_cfg;
ENTER();
memset(&scan_cfg, 0, sizeof(scan_cfg));
if (MLAN_STATUS_SUCCESS != woal_get_scan_config(priv, &scan_cfg)) {
ret = MLAN_STATUS_FAILURE;
goto done;
}
req = woal_alloc_mlan_ioctl_req(sizeof(mlan_ds_scan));
if (req == NULL) {
ret = MLAN_STATUS_FAILURE;
goto done;
}
scan = (mlan_ds_scan *)req->pbuf;
scan->sub_command = MLAN_OID_SCAN_CONFIG;
req->req_id = MLAN_IOCTL_SCAN;
req->action = MLAN_ACT_SET;
memset(&scan->param.scan_cfg, 0, sizeof(mlan_scan_cfg));
scan_cfg.ext_scan = enable;
PRINTM(MIOCTL, "Set ext_scan=%d\n", (int)enable);
moal_memcpy_ext(priv->phandle, &scan->param.scan_cfg, &scan_cfg,
sizeof(mlan_scan_cfg), sizeof(mlan_scan_cfg));
ret = woal_request_ioctl(priv, req, MOAL_IOCTL_WAIT);
done:
if (ret != MLAN_STATUS_PENDING)
kfree(req);
LEAVE();
return ret;
}
/**
* @brief set power mode
*
* @param priv A pointer to moal_private structure
* @param powermode A pointer to powermode string.
*
* @return MLAN_STATUS_SUCCESS -- success, otherwise fail
*/
mlan_status woal_set_powermode(moal_private *priv, char *powermode)
{
mlan_status ret = MLAN_STATUS_SUCCESS;
int disabled;
ENTER();
if (*powermode == '1') {
PRINTM(MIOCTL, "Disable power save\n");
disabled = 1;
} else if (*powermode == '0') {
PRINTM(MIOCTL, "Enable power save\n");
disabled = 0;
} else {
PRINTM(MERROR, "unsupported power mode\n");
ret = MLAN_STATUS_FAILURE;
goto done;
}
if (MLAN_STATUS_SUCCESS != woal_set_get_power_mgmt(priv, MLAN_ACT_SET,
&disabled, 0,
MOAL_IOCTL_WAIT))
ret = MLAN_STATUS_FAILURE;
done:
LEAVE();
return ret;
}
/**
* @brief set combo scan
*
* @param priv A pointer to moal_private structure
* @param buf A pointer to scan command buf
* @param length buf length
*
* @return 0 -- success, otherwise fail
*/
int woal_set_combo_scan(moal_private *priv, char *buf, int length)
{
int ret = 0;
wlan_user_scan_cfg scan_cfg;
t_u8 *ptr = buf + WEXT_CSCAN_HEADER_SIZE;
int buf_left = length - WEXT_CSCAN_HEADER_SIZE;
int num_ssid = 0;
int num_chan = 0;
int ssid_len = 0;
int i = 0;
t_u16 passive_scan_time = 0;
t_u16 specific_scan_time = 0;
ENTER();
memset(&scan_cfg, 0, sizeof(scan_cfg));
while (buf_left >= 2) {
switch (*ptr) {
case WEXT_CSCAN_SSID_SECTION:
ssid_len = *(ptr + 1);
if ((buf_left < (ssid_len + 2)) ||
(ssid_len > MLAN_MAX_SSID_LENGTH)) {
PRINTM(MERROR,
"Invalid ssid, buf_left=%d, ssid_len=%d\n",
buf_left, ssid_len);
buf_left = 0;
break;
}
if (ssid_len &&
(num_ssid < (MRVDRV_MAX_SSID_LIST_LENGTH - 1))) {
strncpy(scan_cfg.ssid_list[num_ssid].ssid,
ptr + 2, ssid_len);
scan_cfg.ssid_list[num_ssid].max_len = 0;
PRINTM(MIOCTL, "Combo scan: ssid=%s\n",
scan_cfg.ssid_list[num_ssid].ssid);
num_ssid++;
}
buf_left -= ssid_len + 2;
ptr += ssid_len + 2;
break;
case WEXT_CSCAN_CHANNEL_SECTION:
num_chan = ptr[1];
if ((buf_left < (num_chan + 2)) ||
(num_chan > WLAN_USER_SCAN_CHAN_MAX)) {
PRINTM(MERROR,
"Invalid channel list, buf_left=%d, num_chan=%d\n",
buf_left, num_chan);
buf_left = 0;
break;
}
for (i = 0; i < num_chan; i++) {
scan_cfg.chan_list[i].chan_number = ptr[2 + i];
PRINTM(MIOCTL, "Combo scan: chan=%d\n",
scan_cfg.chan_list[i].chan_number);
}
buf_left -= 2 + num_chan;
ptr += 2 + num_chan;
break;
case WEXT_CSCAN_PASV_DWELL_SECTION:
if (buf_left < 3) {
PRINTM(MERROR,
"Invalid PASV_DWELL_SECTION, buf_left=%d\n",
buf_left);
buf_left = 0;
break;
}
passive_scan_time = ptr[2] << 8 | ptr[1];
ptr += 3;
buf_left -= 3;
break;
case WEXT_CSCAN_HOME_DWELL_SECTION:
if (buf_left < 3) {
PRINTM(MERROR,
"Invalid HOME_DWELL_SECTION, buf_left=%d\n",
buf_left);
buf_left = 0;
break;
}
specific_scan_time = ptr[2] << 8 | ptr[1];
ptr += 3;
buf_left -= 3;
break;
default:
buf_left = 0;
break;
}
}
if (passive_scan_time || specific_scan_time) {
PRINTM(MIOCTL,
"Set passive_scan_time=%d specific_scan_time=%d\n",
passive_scan_time, specific_scan_time);
if (MLAN_STATUS_FAILURE ==
woal_set_scan_time(priv, 0, passive_scan_time,
specific_scan_time)) {
ret = -EFAULT;
goto done;
}
}
if (num_ssid || num_chan) {
if (num_ssid) {
/* Add broadcast scan to ssid_list */
scan_cfg.ssid_list[num_ssid].max_len = 0xff;
if (priv->scan_type == MLAN_SCAN_TYPE_PASSIVE)
woal_set_scan_type(priv, MLAN_SCAN_TYPE_ACTIVE);
}
if (MLAN_STATUS_FAILURE == woal_do_scan(priv, &scan_cfg))
ret = -EFAULT;
if (num_ssid && (priv->scan_type == MLAN_SCAN_TYPE_PASSIVE))
woal_set_scan_type(priv, MLAN_SCAN_TYPE_PASSIVE);
} else {
/* request broadcast scan */
if (MLAN_STATUS_FAILURE == woal_do_scan(priv, NULL))
ret = -EFAULT;
}
done:
LEAVE();
return ret;
}
/**
* @brief Get band
*
* @param priv A pointer to moal_private structure
* @param band A pointer to band buf
*
* @return MLAN_STATUS_SUCCESS -- success, otherwise fail
*/
mlan_status woal_get_band(moal_private *priv, int *band)
{
mlan_status ret = MLAN_STATUS_SUCCESS;
mlan_ioctl_req *req = NULL;
mlan_ds_radio_cfg *radio_cfg = NULL;
int support_band = 0;
ENTER();
req = woal_alloc_mlan_ioctl_req(sizeof(mlan_ds_radio_cfg));
if (req == NULL) {
ret = MLAN_STATUS_FAILURE;
goto done;
}
radio_cfg = (mlan_ds_radio_cfg *)req->pbuf;
radio_cfg->sub_command = MLAN_OID_BAND_CFG;
req->req_id = MLAN_IOCTL_RADIO_CFG;
/* Get config_bands, adhoc_start_band and adhoc_channel values from MLAN
*/
req->action = MLAN_ACT_GET;
ret = woal_request_ioctl(priv, req, MOAL_IOCTL_WAIT);
if (ret != MLAN_STATUS_SUCCESS)
goto done;
if (radio_cfg->param.band_cfg.config_bands &
(BAND_B | BAND_G | BAND_GN))
support_band |= WIFI_FREQUENCY_BAND_2GHZ;
if (radio_cfg->param.band_cfg.config_bands & (BAND_A | BAND_AN))
support_band |= WIFI_FREQUENCY_BAND_5GHZ;
*band = support_band;
if (support_band == WIFI_FREQUENCY_ALL_BAND)
*band = WIFI_FREQUENCY_BAND_AUTO;
done:
if (ret != MLAN_STATUS_PENDING)
kfree(req);
LEAVE();
return ret;
}
/**
* @brief set band
*
* @param priv A pointer to moal_private structure
* @param pband A pointer to band string.
*
* @return MLAN_STATUS_SUCCESS -- success, otherwise fail
*/
mlan_status woal_set_band(moal_private *priv, char *pband)
{
mlan_status ret = MLAN_STATUS_SUCCESS;
int band = 0;
mlan_ioctl_req *req = NULL;
mlan_ds_radio_cfg *radio_cfg = NULL;
#if defined(STA_CFG80211) || defined(UAP_CFG80211)
int cfg80211_wext = priv->phandle->params.cfg80211_wext;
#endif
ENTER();
if (priv->media_connected == MTRUE) {
PRINTM(MERROR, "Set band is not allowed in connected state\n");
ret = MLAN_STATUS_FAILURE;
goto done;
}
req = woal_alloc_mlan_ioctl_req(sizeof(mlan_ds_radio_cfg));
if (req == NULL) {
ret = MLAN_STATUS_FAILURE;
goto done;
}
radio_cfg = (mlan_ds_radio_cfg *)req->pbuf;
radio_cfg->sub_command = MLAN_OID_BAND_CFG;
req->req_id = MLAN_IOCTL_RADIO_CFG;
/* Get fw supported values from MLAN */
req->action = MLAN_ACT_GET;
ret = woal_request_ioctl(priv, req, MOAL_IOCTL_WAIT);
if (ret != MLAN_STATUS_SUCCESS)
goto done;
if (*pband == '0') {
PRINTM(MIOCTL, "Set band to AUTO\n");
band = radio_cfg->param.band_cfg.fw_bands;
#if defined(STA_CFG80211) || defined(UAP_CFG80211)
if (IS_STA_OR_UAP_CFG80211(cfg80211_wext) && priv->wdev &&
priv->wdev->wiphy) {
if (radio_cfg->param.band_cfg.fw_bands & BAND_A)
priv->wdev->wiphy->bands[IEEE80211_BAND_5GHZ] =
&cfg80211_band_5ghz;
priv->wdev->wiphy->bands[IEEE80211_BAND_2GHZ] =
&cfg80211_band_2ghz;
}
#endif
} else if (*pband == '1') {
PRINTM(MIOCTL, "Set band to 5G\n");
if (!(radio_cfg->param.band_cfg.fw_bands & BAND_A)) {
PRINTM(MERROR, "Don't support 5G band\n");
ret = MLAN_STATUS_FAILURE;
goto done;
}
band = BAND_A;
if (radio_cfg->param.band_cfg.fw_bands & BAND_AN)
band |= BAND_AN;
if (radio_cfg->param.band_cfg.fw_bands & BAND_AAC)
band |= BAND_AAC;
#if defined(STA_CFG80211) || defined(UAP_CFG80211)
if (IS_STA_OR_UAP_CFG80211(cfg80211_wext) && priv->wdev &&
priv->wdev->wiphy) {
priv->wdev->wiphy->bands[IEEE80211_BAND_5GHZ] =
&cfg80211_band_5ghz;
priv->wdev->wiphy->bands[IEEE80211_BAND_2GHZ] = NULL;
}
#endif
} else if (*pband == '2') {
PRINTM(MIOCTL, "Set band to 2G\n");
band = BAND_B | BAND_G;
band |= BAND_GN;
#if defined(STA_CFG80211) || defined(UAP_CFG80211)
if (IS_STA_OR_UAP_CFG80211(cfg80211_wext) && priv->wdev &&
priv->wdev->wiphy) {
priv->wdev->wiphy->bands[IEEE80211_BAND_5GHZ] = NULL;
priv->wdev->wiphy->bands[IEEE80211_BAND_2GHZ] =
&cfg80211_band_2ghz;
}
#endif
} else {
PRINTM(MERROR, "unsupported band\n");
ret = MLAN_STATUS_FAILURE;
goto done;
}
/* Set config_bands to MLAN */
req->action = MLAN_ACT_SET;
memset(&radio_cfg->param.band_cfg, 0, sizeof(mlan_ds_band_cfg));
radio_cfg->param.band_cfg.config_bands = band;
radio_cfg->param.band_cfg.adhoc_start_band = band;
ret = woal_request_ioctl(priv, req, MOAL_IOCTL_WAIT);
done:
if (ret != MLAN_STATUS_PENDING)
kfree(req);
LEAVE();
return ret;
}
/**
* @brief Add RX Filter
*
* @param priv A pointer to moal_private structure
* @param rxfilter A pointer to rxfilter string.
*
* @return MLAN_STATUS_SUCCESS -- success, otherwise fail
*/
mlan_status woal_add_rxfilter(moal_private *priv, char *rxfilter)
{
mlan_status ret = MLAN_STATUS_SUCCESS;
ENTER();
/* Android command:
"DRIVER RXFILTER-ADD 0"
"DRIVER RXFILTER-ADD 1"
"DRIVER RXFILTER-ADD 3" */
if (*rxfilter == '0') {
PRINTM(MIOCTL, "Add IPV4 multicast filter\n");
priv->rx_filter |= RX_FILTER_IPV4_MULTICAST;
} else if (*rxfilter == '1') {
PRINTM(MIOCTL, "Add broadcast filter\n");
priv->rx_filter |= RX_FILTER_BROADCAST;
} else if (*rxfilter == '2') {
PRINTM(MIOCTL, "Add unicast filter\n");
priv->rx_filter |= RX_FILTER_UNICAST;
} else if (*rxfilter == '3') {
PRINTM(MIOCTL, "Add IPV6 multicast fitler\n");
priv->rx_filter |= RX_FILTER_IPV6_MULTICAST;
} else {
PRINTM(MERROR, "unsupported rx fitler\n");
ret = MLAN_STATUS_FAILURE;
goto done;
}
done:
LEAVE();
return ret;
}
/**
* @brief Remove RX Filter
*
* @param priv A pointer to moal_private structure
* @param rxfilter A pointer to rxfilter string.
*
* @return MLAN_STATUS_SUCCESS -- success, otherwise fail
*/
mlan_status woal_remove_rxfilter(moal_private *priv, char *rxfilter)
{
mlan_status ret = MLAN_STATUS_SUCCESS;
ENTER();
if (*rxfilter == '0') {
PRINTM(MIOCTL, "Remove IPV4 multicast filter\n");
priv->rx_filter &= ~RX_FILTER_IPV4_MULTICAST;
} else if (*rxfilter == '1') {
PRINTM(MIOCTL, "Remove broadcast filter\n");
priv->rx_filter &= ~RX_FILTER_BROADCAST;
} else if (*rxfilter == '2') {
PRINTM(MIOCTL, "Remove unicast filter\n");
priv->rx_filter &= ~RX_FILTER_UNICAST;
} else if (*rxfilter == '3') {
PRINTM(MIOCTL, "Remove IPV6 multicast fitler\n");
priv->rx_filter &= ~RX_FILTER_IPV6_MULTICAST;
} else {
PRINTM(MERROR, "unsupported rx fitler\n");
ret = MLAN_STATUS_FAILURE;
goto done;
}
done:
LEAVE();
return ret;
}
/**
* @brief Set/Get WMM IE QoS configuration
*
* @param priv A pointer to moal_private structure
* @param action Action set or get
* @param qos_cfg A pointer to QoS configuration structure
*
* @return MLAN_STATUS_SUCCESS -- success, otherwise fail
*/
mlan_status woal_priv_qos_cfg(moal_private *priv, t_u32 action, char *qos_cfg)
{
mlan_status ret = MLAN_STATUS_SUCCESS;
mlan_ds_wmm_cfg *cfg = NULL;
mlan_ioctl_req *req = NULL;
int qosinfo = 0;
ENTER();
if (qos_cfg == NULL) {
PRINTM(MERROR, "QOS info buffer is null\n");
return MLAN_STATUS_FAILURE;
}
if ((action == MLAN_ACT_SET) &&
(MLAN_STATUS_SUCCESS != woal_atoi(&qosinfo, qos_cfg))) {
ret = MLAN_STATUS_FAILURE;
goto done;
}
req = woal_alloc_mlan_ioctl_req(sizeof(mlan_ds_wmm_cfg));
if (req == NULL) {
ret = MLAN_STATUS_FAILURE;
goto done;
}
cfg = (mlan_ds_wmm_cfg *)req->pbuf;
cfg->sub_command = MLAN_OID_WMM_CFG_QOS;
req->req_id = MLAN_IOCTL_WMM_CFG;
req->action = action;
if (action == MLAN_ACT_SET) {
cfg->param.qos_cfg = (t_u8)qosinfo;
PRINTM(MIOCTL, "set qosinfo=%d\n", qosinfo);
}
ret = woal_request_ioctl(priv, req, MOAL_IOCTL_WAIT);
if (action == MLAN_ACT_GET)
*qos_cfg = cfg->param.qos_cfg;
done:
if (ret != MLAN_STATUS_PENDING)
kfree(req);
LEAVE();
return ret;
}
/**
* @brief Set sleep period
*
* @param priv A pointer to moal_private structure
* @param psleeppd A pointer to sleep period configuration structure
*
* @return MLAN_STATUS_SUCCESS -- success, otherwise fail
*/
mlan_status woal_set_sleeppd(moal_private *priv, char *psleeppd)
{
mlan_status ret = MLAN_STATUS_SUCCESS;
mlan_ds_pm_cfg *pm_cfg = NULL;
mlan_ioctl_req *req = NULL;
int sleeppd = 0;
ENTER();
if (MLAN_STATUS_SUCCESS != woal_atoi(&sleeppd, psleeppd)) {
ret = MLAN_STATUS_FAILURE;
goto done;
}
PRINTM(MIOCTL, "set sleeppd=%d\n", sleeppd);
req = woal_alloc_mlan_ioctl_req(sizeof(mlan_ds_pm_cfg));
if (req == NULL) {
ret = MLAN_STATUS_FAILURE;
goto done;
}
pm_cfg = (mlan_ds_pm_cfg *)req->pbuf;
pm_cfg->sub_command = MLAN_OID_PM_CFG_SLEEP_PD;
req->req_id = MLAN_IOCTL_PM_CFG;
if ((sleeppd <= MAX_SLEEP_PERIOD && sleeppd >= MIN_SLEEP_PERIOD) ||
(sleeppd == 0) || (sleeppd == SLEEP_PERIOD_RESERVED_FF)) {
req->action = MLAN_ACT_SET;
pm_cfg->param.sleep_period = sleeppd;
} else {
ret = MLAN_STATUS_FAILURE;
goto done;
}
ret = woal_request_ioctl(priv, req, MOAL_IOCTL_WAIT);
done:
if (ret != MLAN_STATUS_PENDING)
kfree(req);
LEAVE();
return ret;
}
/**
* @brief Set scan period function
*
* @param priv A pointer to moal_private structure
* @param buf A pointer to scan command buf
* @param length buf length
*
* @return MLAN_STATUS_SUCCESS -- success, otherwise fail
*/
int woal_set_scan_cfg(moal_private *priv, char *buf, int length)
{
mlan_status ret = MLAN_STATUS_SUCCESS;
t_u8 *ptr = buf + NL80211_SCANCFG_HEADER_SIZE;
int buf_left = length - NL80211_SCANCFG_HEADER_SIZE;
t_u16 active_scan_time = 0;
t_u16 passive_scan_time = 0;
t_u16 specific_scan_time = 0;
ENTER();
while (buf_left >= 2) {
switch (*ptr) {
case NL80211_SCANCFG_ACTV_DWELL_SECTION:
if (buf_left < 3) {
PRINTM(MERROR,
"Invalid ACTV_DWELL_SECTION, buf_left=%d\n",
buf_left);
buf_left = 0;
break;
}
active_scan_time = ptr[2] << 8 | ptr[1];
ptr += 3;
buf_left -= 3;
break;
case NL80211_SCANCFG_PASV_DWELL_SECTION:
if (buf_left < 3) {
PRINTM(MERROR,
"Invalid PASV_DWELL_SECTION, buf_left=%d\n",
buf_left);
buf_left = 0;
break;
}
passive_scan_time = ptr[2] << 8 | ptr[1];
ptr += 3;
buf_left -= 3;
break;
case NL80211_SCANCFG_SPCF_DWELL_SECTION:
if (buf_left < 3) {
PRINTM(MERROR,
"Invalid SPCF_DWELL_SECTION, buf_left=%d\n",
buf_left);
buf_left = 0;
break;
}
specific_scan_time = ptr[2] << 8 | ptr[1];
ptr += 3;
buf_left -= 3;
break;
default:
buf_left = 0;
break;
}
}
if (active_scan_time || passive_scan_time || specific_scan_time) {
PRINTM(MIOCTL,
"Set active_scan_time= %d passive_scan_time=%d specific_scan_time=%d\n",
active_scan_time, passive_scan_time, specific_scan_time);
if (MLAN_STATUS_FAILURE ==
woal_set_scan_time(priv, active_scan_time,
passive_scan_time, specific_scan_time)) {
ret = -EFAULT;
}
}
LEAVE();
return ret;
}
/**
* @brief Set Radio On/OFF
*
* @param priv A pointer to moal_private structure
* @param option Radio Option
*
* @return 0 --success, otherwise fail
*/
int woal_set_radio(moal_private *priv, t_u8 option)
{
int ret = 0;
mlan_ds_radio_cfg *radio = NULL;
mlan_ioctl_req *req = NULL;
mlan_status status = MLAN_STATUS_SUCCESS;
ENTER();
if ((option != 0) && (option != 1)) {
ret = -EINVAL;
goto done;
}
req = woal_alloc_mlan_ioctl_req(sizeof(mlan_ds_radio_cfg));
if (req == NULL) {
ret = -ENOMEM;
goto done;
}
radio = (mlan_ds_radio_cfg *)req->pbuf;
radio->sub_command = MLAN_OID_RADIO_CTRL;
req->req_id = MLAN_IOCTL_RADIO_CFG;
req->action = MLAN_ACT_SET;
radio->param.radio_on_off = option;
status = woal_request_ioctl(priv, req, MOAL_IOCTL_WAIT);
if (status != MLAN_STATUS_SUCCESS)
ret = -EFAULT;
done:
if (status != MLAN_STATUS_PENDING)
kfree(req);
LEAVE();
return ret;
}
#endif /* STA_SUPPORT */
#ifdef USB
/**
* @brief Initialize USB packet aggregation control
*
* @param handle A pointer to moal_private structure
*
* @return MLAN_STATUS_SUCCESS -- success, otherwise fail
*/
mlan_status woal_usb_aggr_init(moal_handle *handle)
{
mlan_status ret = MLAN_STATUS_SUCCESS;
moal_private *priv = NULL;
mlan_ioctl_req *req = NULL;
mlan_ds_misc_cfg *pcfg_misc = NULL;
mlan_ds_misc_usb_aggr_ctrl *aggr_param = NULL;
t_u8 usb_aggr_enable;
struct usb_card_rec *cardp = NULL;
int i = 0, resubmit_urbs = 0;
ENTER();
if (!handle) {
PRINTM(MERROR, "Handle is null\n");
LEAVE();
return MLAN_STATUS_FAILURE;
}
priv = woal_get_priv(handle, MLAN_BSS_ROLE_STA);
if (!priv) {
PRINTM(MERROR, "STA priv is null\n");
ret = MLAN_STATUS_FAILURE;
goto done;
}
if (handle->card == NULL) {
PRINTM(MERROR, "Card is null in %s()\n", __func__);
ret = MLAN_STATUS_FAILURE;
goto done;
}
cardp = (struct usb_card_rec *)handle->card;
/* Check module parameter */
if (handle->params.usb_aggr == 0 || handle->params.usb_aggr == 2) {
usb_aggr_enable = MFALSE;
} else if (handle->params.usb_aggr == 1) {
usb_aggr_enable = MTRUE;
} else {
PRINTM(MWARN,
"Invalid module param (usb_aggr) value %d, "
"using MLAN default\n",
handle->params.usb_aggr);
handle->params.usb_aggr = 0;
usb_aggr_enable = MFALSE;
}
/* Allocate an IOCTL request buffer */
req = woal_alloc_mlan_ioctl_req(sizeof(mlan_ds_misc_cfg));
if (req == NULL) {
ret = MLAN_STATUS_FAILURE;
goto done;
}
/* Fill request buffer */
pcfg_misc = (mlan_ds_misc_cfg *)req->pbuf;
pcfg_misc->sub_command = MLAN_OID_MISC_USB_AGGR_CTRL;
req->req_id = MLAN_IOCTL_MISC_CFG;
req->action = MLAN_ACT_SET;
aggr_param = &pcfg_misc->param.usb_aggr_params;
/* Initialize TX aggr default values */
aggr_param->tx_aggr_ctrl.enable = usb_aggr_enable;
aggr_param->tx_aggr_ctrl.aggr_mode = MLAN_USB_AGGR_MODE_NUM;
aggr_param->tx_aggr_ctrl.aggr_align =
MAX(handle->params.max_tx_buf, MLAN_USB_TX_AGGR_ALIGN);
aggr_param->tx_aggr_ctrl.aggr_max = MLAN_USB_TX_MAX_AGGR_NUM;
aggr_param->tx_aggr_ctrl.aggr_tmo =
MLAN_USB_TX_AGGR_TIMEOUT_MSEC * 1000;
/* Initialize RX deaggr default values */
aggr_param->rx_deaggr_ctrl.enable = usb_aggr_enable;
aggr_param->rx_deaggr_ctrl.aggr_mode = MLAN_USB_AGGR_MODE_NUM;
aggr_param->rx_deaggr_ctrl.aggr_align = MLAN_USB_RX_ALIGN_SIZE;
aggr_param->rx_deaggr_ctrl.aggr_max = MLAN_USB_RX_MAX_AGGR_NUM;
aggr_param->rx_deaggr_ctrl.aggr_tmo = MLAN_USB_RX_DEAGGR_TIMEOUT_USEC;
/* Do not fail driver init due to command failure */
ret = woal_request_ioctl(priv, req, MOAL_IOCTL_WAIT);
/* Disable the feature if FW return failure/unsupported */
if (req->status_code)
cardp->tx_aggr_ctrl.enable = MFALSE;
else
moal_memcpy_ext(handle, &cardp->tx_aggr_ctrl,
&aggr_param->tx_aggr_ctrl,
sizeof(usb_aggr_ctrl), sizeof(usb_aggr_ctrl));
if (req->status_code) {
/* Disable the feature if FW return failure/unsupported */
cardp->rx_deaggr_ctrl.enable = MFALSE;
} else {
/* Default is disable, resubmit URBs only for enable */
if (cardp->rx_deaggr_ctrl.enable != usb_aggr_enable)
resubmit_urbs = 1;
}
if (resubmit_urbs) {
/* Indicate resubmition from here */
cardp->resubmit_urbs = 1;
/* Rx SG feature is disabled due to FW failure/unsupported,
* kill the URBs, they will be resubmitted after saving the
* parameters to USB card */
if (atomic_read(&cardp->rx_data_urb_pending)) {
for (i = 0; i < MVUSB_RX_DATA_URB; i++) {
if (cardp->rx_data_list[i].urb) {
usb_kill_urb(
cardp->rx_data_list[i].urb);
usb_init_urb(
cardp->rx_data_list[i].urb);
}
}
}
/* Default is disable, update only for enable case */
moal_memcpy_ext(handle, &cardp->rx_deaggr_ctrl,
&aggr_param->rx_deaggr_ctrl,
sizeof(usb_aggr_ctrl), sizeof(usb_aggr_ctrl));
/* Ensure the next data URBs will use the modified parameters */
if (!atomic_read(&cardp->rx_data_urb_pending)) {
/* Submit multiple Rx data URBs */
woal_usb_submit_rx_data_urbs(handle);
}
cardp->resubmit_urbs = 0;
}
done:
if (ret != MLAN_STATUS_PENDING)
kfree(req);
LEAVE();
return ret;
}
#endif
/**
* @brief Set hotspot configuration value to mlan layer
*
* @param priv A pointer to moal_private structure
* @param wait_option wait option
* @param hotspotcfg Hotspot configuration value
*
* @return MLAN_STATUS_SUCCESS/MLAN_STATUS_PENDING -- success,
* otherwise fail
*/
mlan_status woal_set_hotspotcfg(moal_private *priv, t_u8 wait_option,
t_u32 hotspotcfg)
{
mlan_status ret = MLAN_STATUS_SUCCESS;
mlan_ioctl_req *req = NULL;
mlan_ds_misc_cfg *cfg = NULL;
ENTER();
req = woal_alloc_mlan_ioctl_req(sizeof(mlan_ds_misc_cfg));
if (req == NULL) {
ret = MLAN_STATUS_FAILURE;
goto done;
}
cfg = (mlan_ds_misc_cfg *)req->pbuf;
cfg->param.hotspot_cfg = hotspotcfg;
req->action = MLAN_ACT_SET;
cfg->sub_command = MLAN_OID_MISC_HOTSPOT_CFG;
req->req_id = MLAN_IOCTL_MISC_CFG;
ret = woal_request_ioctl(priv, req, wait_option);
if (ret != MLAN_STATUS_SUCCESS)
goto done;
done:
if (ret != MLAN_STATUS_PENDING)
kfree(req);
LEAVE();
return ret;
}
/**
* @brief Send delelte all BA command to MLAN
*
* @param priv A pointer to moal_private structure
* @param wait_option Wait option
*
* @return MLAN_STATUS_SUCCESS/MLAN_STATUS_PENDING -- success,
* otherwise fail
*/
mlan_status woal_delba_all(moal_private *priv, t_u8 wait_option)
{
mlan_ioctl_req *req = NULL;
mlan_ds_11n_cfg *cfg_11n = NULL;
mlan_ds_11n_delba *del_ba = NULL;
t_u8 zero_mac[MLAN_MAC_ADDR_LENGTH] = {0};
mlan_status status = MLAN_STATUS_SUCCESS;
int ret = 0;
req = (mlan_ioctl_req *)woal_alloc_mlan_ioctl_req(
sizeof(mlan_ds_11n_cfg));
if (req == NULL) {
ret = -ENOMEM;
goto done;
}
cfg_11n = (mlan_ds_11n_cfg *)req->pbuf;
req->req_id = MLAN_IOCTL_11N_CFG;
cfg_11n->sub_command = MLAN_OID_11N_CFG_DELBA;
del_ba = &cfg_11n->param.del_ba;
memset(del_ba, 0, sizeof(mlan_ds_11n_delba));
del_ba->direction = DELBA_RX | DELBA_TX;
del_ba->tid = DELBA_ALL_TIDS;
moal_memcpy_ext(priv->phandle, del_ba->peer_mac_addr, zero_mac,
ETH_ALEN, sizeof(del_ba->peer_mac_addr));
status = woal_request_ioctl(priv, req, wait_option);
if (status != MLAN_STATUS_SUCCESS) {
ret = -EFAULT;
goto done;
}
done:
if (status != MLAN_STATUS_PENDING)
kfree(req);
LEAVE();
return ret;
}
/**
* @brief Send 11d enable/disable command to firmware.
*
* @param priv A pointer to moal_private structure
* @param wait_option Wait option
* @param enable Enable/Disable 11d
*
* @return MLAN_STATUS_SUCCESS/MLAN_STATUS_PENDING -- success,
* otherwise fail
*/
mlan_status woal_set_11d(moal_private *priv, t_u8 wait_option, t_u8 enable)
{
mlan_ioctl_req *req = NULL;
mlan_ds_snmp_mib *snmp = NULL;
mlan_status ret = MLAN_STATUS_SUCCESS;
ENTER();
req = woal_alloc_mlan_ioctl_req(sizeof(mlan_ds_snmp_mib));
if (req == NULL) {
LEAVE();
return -ENOMEM;
}
req->action = MLAN_ACT_SET;
req->req_id = MLAN_IOCTL_SNMP_MIB;
snmp = (mlan_ds_snmp_mib *)req->pbuf;
snmp->sub_command = MLAN_OID_SNMP_MIB_DOT11D;
snmp->param.oid_value = enable;
ret = woal_request_ioctl(priv, req, MOAL_IOCTL_WAIT);
if (ret != MLAN_STATUS_PENDING)
kfree(req);
LEAVE();
return ret;
}
/**
* @brief Handle miscellaneous ioctls for asynchronous command response
*
* @param priv Pointer to moal_private structure
* @param info Pointer to mlan_ds_misc_cfg structure
*
* @return N/A
*/
void woal_ioctl_get_misc_conf(moal_private *priv, mlan_ds_misc_cfg *info)
{
ENTER();
switch (info->sub_command) {
default:
break;
}
}
#ifdef CONFIG_PROC_FS
#define TX_PWR_STR_LEN 20
#define TX_CONT_STR_LEN 50
#define TX_FRAME_STR_LEN 80
/*
* @brief Parse mfg cmd tx pwr string
*
* @param s A pointer to user buffer
* @param len Length of user buffer
* @param d A pointer to mfg_cmd_generic_cfg struct
* @return 0 on success, -EINVAL otherwise
*/
static int parse_tx_pwr_string(const char *s, size_t len,
struct mfg_cmd_generic_cfg *d)
{
int ret = MLAN_STATUS_SUCCESS;
char *string = NULL;
char *tmp = NULL;
char *pos = NULL;
gfp_t flag;
ENTER();
if (!s || !d) {
LEAVE();
return -EINVAL;
}
flag = (in_atomic() || irqs_disabled()) ? GFP_ATOMIC : GFP_KERNEL;
string = kzalloc(TX_PWR_STR_LEN, flag);
if (string == NULL) {
LEAVE();
return -ENOMEM;
}
moal_memcpy_ext(NULL, string, s + strlen("tx_power="),
len - strlen("tx_power="), TX_PWR_STR_LEN - 1);
tmp = string;
string = strstrip(string);
/* tx power value */
pos = strsep(&string, " \t");
if (pos)
d->data1 = (t_u32)woal_string_to_number(pos);
/* modulation */
pos = strsep(&string, " \t");
if (pos)
d->data2 = (t_u32)woal_string_to_number(pos);
/* path id */
pos = strsep(&string, " \t");
if (pos)
d->data3 = (t_u32)woal_string_to_number(pos);
if ((d->data1 > 24) || (d->data2 > 2))
ret = -EINVAL;
kfree(tmp);
LEAVE();
return ret;
}
/*
* @brief Parse mfg cmd tx cont string
*
* @param s A pointer to user buffer
* @param len Length of user buffer
* @param d A pointer to mfg_cmd_tx_cont struct
* @return 0 on success, -EINVAL otherwise
*/
static int parse_tx_cont_string(const char *s, size_t len,
struct mfg_cmd_tx_cont *d)
{
int ret = MLAN_STATUS_SUCCESS;
char *string = NULL;
char *tmp = NULL;
char *pos = NULL;
gfp_t flag;
ENTER();
if (!s || !d) {
LEAVE();
return -EINVAL;
}
flag = (in_atomic() || irqs_disabled()) ? GFP_ATOMIC : GFP_KERNEL;
string = kzalloc(TX_CONT_STR_LEN, flag);
if (string == NULL) {
LEAVE();
return -ENOMEM;
}
moal_memcpy_ext(NULL, string, s + strlen("tx_continuous="),
len - strlen("tx_continuous="), TX_CONT_STR_LEN - 1);
tmp = string;
string = strstrip(string);
pos = strsep(&string, " \t");
if (pos)
d->enable_tx = (t_u32)woal_string_to_number(pos);
if (d->enable_tx == MFALSE)
goto done;
pos = strsep(&string, " \t");
if (pos)
d->cw_mode = (t_u32)woal_string_to_number(pos);
pos = strsep(&string, " \t");
if (pos)
d->payload_pattern = (t_u32)woal_string_to_number(pos);
pos = strsep(&string, " \t");
if (pos)
d->cs_mode = (t_u32)woal_string_to_number(pos);
pos = strsep(&string, " \t");
if (pos)
d->act_sub_ch = (t_u32)woal_string_to_number(pos);
pos = strsep(&string, " \t");
if (pos)
d->tx_rate = (t_u32)woal_string_to_number(pos);
if ((d->enable_tx > 1) || (d->cw_mode > 1) || (d->cs_mode > 1) ||
(d->act_sub_ch == 2 || d->act_sub_ch > 3))
ret = -EINVAL;
done:
kfree(tmp);
LEAVE();
return ret;
}
/*
* @brief Parse mfg cmd tx frame string
*
* @param s A pointer to user buffer
* @param len Length of user buffer
* @param d A pointer to mfg_cmd_tx_frame2 struct
* @return 0 on success, -EINVAL otherwise
*/
static int parse_tx_frame_string(const char *s, size_t len,
struct mfg_cmd_tx_frame2 *d)
{
int ret = MLAN_STATUS_SUCCESS;
char *string = NULL;
char *tmp = NULL;
char *pos = NULL;
int i;
gfp_t flag;
ENTER();
if (!s || !d) {
LEAVE();
return -EINVAL;
}
flag = (in_atomic() || irqs_disabled()) ? GFP_ATOMIC : GFP_KERNEL;
string = kzalloc(TX_FRAME_STR_LEN, flag);
if (string == NULL)
return -ENOMEM;
moal_memcpy_ext(NULL, string, s + strlen("tx_frame="),
len - strlen("tx_frame="), TX_FRAME_STR_LEN - 1);
tmp = string;
string = strstrip(string);
pos = strsep(&string, " \t");
if (pos)
d->enable = (t_u32)woal_string_to_number(pos);
if (d->enable == MFALSE)
goto done;
pos = strsep(&string, " \t");
if (pos)
d->data_rate = (t_u32)woal_string_to_number(pos);
pos = strsep(&string, " \t");
if (pos)
d->frame_pattern = (t_u32)woal_string_to_number(pos);
pos = strsep(&string, " \t");
if (pos)
d->frame_length = (t_u32)woal_string_to_number(pos);
pos = strsep(&string, " \t");
if (pos)
d->adjust_burst_sifs = (t_u16)woal_string_to_number(pos);
pos = strsep(&string, " \t");
if (pos)
d->burst_sifs_in_us = (t_u32)woal_string_to_number(pos);
pos = strsep(&string, " \t");
if (pos)
d->short_preamble = (t_u32)woal_string_to_number(pos);
pos = strsep(&string, " \t");
if (pos)
d->act_sub_ch = (t_u32)woal_string_to_number(pos);
pos = strsep(&string, " \t");
if (pos)
d->short_gi = (t_u32)woal_string_to_number(pos);
pos = strsep(&string, " \t");
if (pos)
d->adv_coding = (t_u32)woal_string_to_number(pos);
pos = strsep(&string, " \t");
if (pos)
d->tx_bf = (t_u32)woal_string_to_number(pos);
pos = strsep(&string, " \t");
if (pos)
d->gf_mode = (t_u32)woal_string_to_number(pos);
pos = strsep(&string, " \t");
if (pos)
d->stbc = (t_u32)woal_string_to_number(pos);
pos = strsep(&string, " \t");
if (pos) {
for (i = 0; i < ETH_ALEN; i++) {
pos = strsep(&string, ":");
if (pos)
d->bssid[i] = woal_atox(pos);
}
}
if ((d->enable > 1) || (d->frame_length == 0) ||
(d->adjust_burst_sifs > 1) || (d->burst_sifs_in_us > 255) ||
(d->short_preamble > 1) ||
(d->act_sub_ch == 2 || d->act_sub_ch > 3) || (d->short_gi > 1) ||
(d->adv_coding > 1) || (d->tx_bf > 1) || (d->gf_mode > 1) ||
(d->stbc > 1))
ret = -EINVAL;
done:
kfree(tmp);
LEAVE();
return ret;
}
/**
* @brief This function enables/disables RF test mode in firmware
*
* @param handle A pointer to moal_handle structure
* @return MLAN_STATUS_SUCCESS/MLAN_STATUS_PENDING on success,
* otherwise failure code
*/
mlan_status woal_process_rf_test_mode(moal_handle *handle, t_u32 mode)
{
mlan_status ret = MLAN_STATUS_FAILURE;
mlan_ioctl_req *req = NULL;
mlan_ds_misc_cfg *misc = NULL;
t_u32 flag = 0;
ENTER();
#ifdef MFG_CMD_SUPPORT
if (mfg_mode) {
LEAVE();
return ret;
}
#endif
if (mode != MFG_CMD_SET_TEST_MODE && mode != MFG_CMD_UNSET_TEST_MODE) {
LEAVE();
return ret;
}
req = woal_alloc_mlan_ioctl_req(sizeof(mlan_ds_misc_cfg));
if (req) {
misc = (mlan_ds_misc_cfg *)req->pbuf;
misc->sub_command = MLAN_OID_MISC_RF_TEST_GENERIC;
req->req_id = MLAN_IOCTL_MISC_CFG;
req->action = MLAN_ACT_SET;
if (mode == MFG_CMD_SET_TEST_MODE)
misc->param.mfg_generic_cfg.mfg_cmd =
MFG_CMD_SET_TEST_MODE;
ret = woal_request_ioctl(woal_get_priv(handle,
MLAN_BSS_ROLE_ANY),
req, MOAL_IOCTL_WAIT);
}
if (ret == MLAN_STATUS_SUCCESS && mode == MFG_CMD_SET_TEST_MODE &&
handle->rf_data == NULL) {
flag = (in_atomic() || irqs_disabled()) ? GFP_ATOMIC :
GFP_KERNEL;
/* Allocate memory to hold RF test mode data */
handle->rf_data =
kzalloc(sizeof(struct rf_test_mode_data), flag);
if (!handle->rf_data)
PRINTM(MERROR,
"Couldn't allocate memory for RF test mode\n");
handle->rf_test_mode = MTRUE;
if (handle->rf_data) {
/* antenna is set to 1 by default */
handle->rf_data->tx_antenna = 1;
handle->rf_data->rx_antenna = 1;
}
} else if (mode == MFG_CMD_UNSET_TEST_MODE) {
if (handle->rf_data) {
/* Free RF test mode data memory */
kfree(handle->rf_data);
handle->rf_data = NULL;
}
handle->rf_test_mode = MFALSE;
}
if (ret != MLAN_STATUS_PENDING)
kfree(req);
LEAVE();
return ret;
}
/**
* @brief This function sends RF test mode command in firmware
*
* @param handle A pointer to moal_handle structure
* @return MLAN_STATUS_SUCCESS/MLAN_STATUS_PENDING on success,
* otherwise failure code
*/
mlan_status woal_process_rf_test_mode_cmd(moal_handle *handle, t_u32 cmd,
const char *buffer, size_t len,
t_u32 action, t_u32 val)
{
mlan_status ret = MLAN_STATUS_FAILURE;
mlan_ioctl_req *req = NULL;
mlan_ds_misc_cfg *misc = NULL;
int err = MFALSE;
int i;
ENTER();
if (!handle->rf_test_mode || !handle->rf_data)
goto done;
req = woal_alloc_mlan_ioctl_req(sizeof(mlan_ds_misc_cfg));
if (!req)
goto done;
misc = (mlan_ds_misc_cfg *)req->pbuf;
req->req_id = MLAN_IOCTL_MISC_CFG;
misc->sub_command = MLAN_OID_MISC_RF_TEST_GENERIC;
req->action = action;
switch (cmd) {
case MFG_CMD_TX_ANT:
if (val != 1 && val != 2 && val != 3)
err = MTRUE;
break;
case MFG_CMD_RX_ANT:
if (val != 1 && val != 2 && val != 3)
err = MTRUE;
break;
case MFG_CMD_RF_BAND_AG:
if (val != 0 && val != 1)
err = MTRUE;
break;
case MFG_CMD_RF_CHANNELBW:
if (val != 0 && val != 1 &&
(val != 4 ||
(val == 4 && handle->rf_data->band == BAND_2GHZ)))
err = MTRUE;
break;
case MFG_CMD_RF_CHAN:
break;
case MFG_CMD_CLR_RX_ERR:
break;
case MFG_CMD_RFPWR:
if (parse_tx_pwr_string(buffer, len,
&misc->param.mfg_generic_cfg))
err = MTRUE;
break;
case MFG_CMD_TX_CONT:
misc->sub_command = MLAN_OID_MISC_RF_TEST_TX_CONT;
if (parse_tx_cont_string(buffer, len, &misc->param.mfg_tx_cont))
err = MTRUE;
break;
case MFG_CMD_TX_FRAME:
misc->sub_command = MLAN_OID_MISC_RF_TEST_TX_FRAME;
if (parse_tx_frame_string(buffer, len,
&misc->param.mfg_tx_frame2))
err = MTRUE;
break;
default:
err = MTRUE;
}
if (!err) {
misc->param.mfg_generic_cfg.mfg_cmd = (t_u32)cmd;
if (cmd != MFG_CMD_RFPWR &&
misc->sub_command == MLAN_OID_MISC_RF_TEST_GENERIC)
misc->param.mfg_generic_cfg.data1 = val;
ret = woal_request_ioctl(woal_get_priv(handle,
MLAN_BSS_ROLE_ANY),
req, MOAL_IOCTL_WAIT);
}
if (ret != MLAN_STATUS_SUCCESS)
goto done;
switch (cmd) {
case MFG_CMD_TX_ANT:
handle->rf_data->tx_antenna = misc->param.mfg_generic_cfg.data1;
break;
case MFG_CMD_RX_ANT:
handle->rf_data->rx_antenna = misc->param.mfg_generic_cfg.data1;
break;
case MFG_CMD_RF_BAND_AG:
handle->rf_data->band = misc->param.mfg_generic_cfg.data1;
/* set fw default bw and channel config on band change */
handle->rf_data->bandwidth = CHANNEL_BW_20MHZ;
if (handle->rf_data->band == BAND_2GHZ)
handle->rf_data->channel = 6;
else if (handle->rf_data->band == BAND_5GHZ)
handle->rf_data->channel = 36;
break;
case MFG_CMD_RF_CHANNELBW:
handle->rf_data->bandwidth = misc->param.mfg_generic_cfg.data1;
break;
case MFG_CMD_RF_CHAN:
handle->rf_data->channel = misc->param.mfg_generic_cfg.data1;
break;
case MFG_CMD_CLR_RX_ERR:
handle->rf_data->rx_tot_pkt_count =
misc->param.mfg_generic_cfg.data1;
handle->rf_data->rx_mcast_bcast_pkt_count =
misc->param.mfg_generic_cfg.data2;
handle->rf_data->rx_pkt_fcs_err_count =
misc->param.mfg_generic_cfg.data3;
break;
case MFG_CMD_RFPWR:
handle->rf_data->tx_power_data[0] =
misc->param.mfg_generic_cfg.data1;
handle->rf_data->tx_power_data[1] =
misc->param.mfg_generic_cfg.data2;
handle->rf_data->tx_power_data[2] =
misc->param.mfg_generic_cfg.data3;
break;
case MFG_CMD_TX_CONT:
handle->rf_data->tx_cont_data[0] =
misc->param.mfg_tx_cont.enable_tx;
handle->rf_data->tx_cont_data[1] =
misc->param.mfg_tx_cont.cw_mode;
handle->rf_data->tx_cont_data[2] =
misc->param.mfg_tx_cont.payload_pattern;
handle->rf_data->tx_cont_data[3] =
misc->param.mfg_tx_cont.cs_mode;
handle->rf_data->tx_cont_data[4] =
misc->param.mfg_tx_cont.act_sub_ch;
handle->rf_data->tx_cont_data[5] =
misc->param.mfg_tx_cont.tx_rate;
break;
case MFG_CMD_TX_FRAME:
handle->rf_data->tx_frame_data[0] =
misc->param.mfg_tx_frame2.enable;
handle->rf_data->tx_frame_data[1] =
misc->param.mfg_tx_frame2.data_rate;
handle->rf_data->tx_frame_data[2] =
misc->param.mfg_tx_frame2.frame_pattern;
handle->rf_data->tx_frame_data[3] =
misc->param.mfg_tx_frame2.frame_length;
handle->rf_data->tx_frame_data[4] =
misc->param.mfg_tx_frame2.adjust_burst_sifs;
handle->rf_data->tx_frame_data[5] =
misc->param.mfg_tx_frame2.burst_sifs_in_us;
handle->rf_data->tx_frame_data[6] =
misc->param.mfg_tx_frame2.short_preamble;
handle->rf_data->tx_frame_data[7] =
misc->param.mfg_tx_frame2.act_sub_ch;
handle->rf_data->tx_frame_data[8] =
misc->param.mfg_tx_frame2.short_gi;
handle->rf_data->tx_frame_data[9] =
misc->param.mfg_tx_frame2.adv_coding;
handle->rf_data->tx_frame_data[10] =
misc->param.mfg_tx_frame2.tx_bf;
handle->rf_data->tx_frame_data[11] =
misc->param.mfg_tx_frame2.gf_mode;
handle->rf_data->tx_frame_data[12] =
misc->param.mfg_tx_frame2.stbc;
for (i = 0; i < ETH_ALEN; i++) {
handle->rf_data->bssid[i] =
misc->param.mfg_tx_frame2.bssid[i];
}
break;
}
done:
if (err || ret != MLAN_STATUS_PENDING)
kfree(req);
LEAVE();
return ret;
}
#endif /* RF_TEST_MODE */
|