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
|
//------------------------------------------------------------------------------
// Copyright (c) 2004-2010 Atheros Communications Inc.
// All rights reserved.
//
//
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
//
//
//
// Author(s): ="Atheros"
//------------------------------------------------------------------------------
#include "ar6000_drv.h"
#include "ieee80211_ioctl.h"
#include "ar6kap_common.h"
#include "targaddrs.h"
#include "a_hci.h"
#include "wlan_config.h"
extern int enablerssicompensation;
A_UINT32 tcmdRxFreq;
extern unsigned int wmitimeout;
extern A_WAITQUEUE_HEAD arEvent;
extern int tspecCompliance;
extern int bmienable;
extern int bypasswmi;
extern int loghci;
static int
ar6000_ioctl_get_roam_tbl(struct net_device *dev, struct ifreq *rq)
{
AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
if (ar->arWmiReady == FALSE) {
return -EIO;
}
if(wmi_get_roam_tbl_cmd(ar->arWmi) != A_OK) {
return -EIO;
}
return 0;
}
static int
ar6000_ioctl_get_roam_data(struct net_device *dev, struct ifreq *rq)
{
AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
if (ar->arWmiReady == FALSE) {
return -EIO;
}
/* currently assume only roam times are required */
if(wmi_get_roam_data_cmd(ar->arWmi, ROAM_DATA_TIME) != A_OK) {
return -EIO;
}
return 0;
}
static int
ar6000_ioctl_set_roam_ctrl(struct net_device *dev, char *userdata)
{
AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
WMI_SET_ROAM_CTRL_CMD cmd;
A_UINT8 size = sizeof(cmd);
if (ar->arWmiReady == FALSE) {
return -EIO;
}
if (copy_from_user(&cmd, userdata, size)) {
return -EFAULT;
}
if (cmd.roamCtrlType == WMI_SET_HOST_BIAS) {
if (cmd.info.bssBiasInfo.numBss > 1) {
size += (cmd.info.bssBiasInfo.numBss - 1) * sizeof(WMI_BSS_BIAS);
}
}
if (copy_from_user(&cmd, userdata, size)) {
return -EFAULT;
}
if(wmi_set_roam_ctrl_cmd(ar->arWmi, &cmd, size) != A_OK) {
return -EIO;
}
return 0;
}
static int
ar6000_ioctl_set_powersave_timers(struct net_device *dev, char *userdata)
{
AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
WMI_POWERSAVE_TIMERS_POLICY_CMD cmd;
A_UINT8 size = sizeof(cmd);
if (ar->arWmiReady == FALSE) {
return -EIO;
}
if (copy_from_user(&cmd, userdata, size)) {
return -EFAULT;
}
if (copy_from_user(&cmd, userdata, size)) {
return -EFAULT;
}
if(wmi_set_powersave_timers_cmd(ar->arWmi, &cmd, size) != A_OK) {
return -EIO;
}
return 0;
}
static int
ar6000_ioctl_set_qos_supp(struct net_device *dev, struct ifreq *rq)
{
AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
WMI_SET_QOS_SUPP_CMD cmd;
A_STATUS ret;
if ((dev->flags & IFF_UP) != IFF_UP) {
return -EIO;
}
if (ar->arWmiReady == FALSE) {
return -EIO;
}
if (copy_from_user(&cmd, (char *)((unsigned int*)rq->ifr_data + 1),
sizeof(cmd)))
{
return -EFAULT;
}
ret = wmi_set_qos_supp_cmd(ar->arWmi, cmd.status);
switch (ret) {
case A_OK:
return 0;
case A_EBUSY :
return -EBUSY;
case A_NO_MEMORY:
return -ENOMEM;
case A_EINVAL:
default:
return -EFAULT;
}
}
static int
ar6000_ioctl_set_wmm(struct net_device *dev, struct ifreq *rq)
{
AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
WMI_SET_WMM_CMD cmd;
A_STATUS ret;
if ((dev->flags & IFF_UP) != IFF_UP) {
return -EIO;
}
if (ar->arWmiReady == FALSE) {
return -EIO;
}
if (copy_from_user(&cmd, (char *)((unsigned int*)rq->ifr_data + 1),
sizeof(cmd)))
{
return -EFAULT;
}
if (cmd.status == WMI_WMM_ENABLED) {
ar->arWmmEnabled = TRUE;
} else {
ar->arWmmEnabled = FALSE;
}
ret = wmi_set_wmm_cmd(ar->arWmi, cmd.status);
switch (ret) {
case A_OK:
return 0;
case A_EBUSY :
return -EBUSY;
case A_NO_MEMORY:
return -ENOMEM;
case A_EINVAL:
default:
return -EFAULT;
}
}
static int
ar6000_ioctl_set_txop(struct net_device *dev, struct ifreq *rq)
{
AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
WMI_SET_WMM_TXOP_CMD cmd;
A_STATUS ret;
if ((dev->flags & IFF_UP) != IFF_UP) {
return -EIO;
}
if (ar->arWmiReady == FALSE) {
return -EIO;
}
if (copy_from_user(&cmd, (char *)((unsigned int*)rq->ifr_data + 1),
sizeof(cmd)))
{
return -EFAULT;
}
ret = wmi_set_wmm_txop(ar->arWmi, cmd.txopEnable);
switch (ret) {
case A_OK:
return 0;
case A_EBUSY :
return -EBUSY;
case A_NO_MEMORY:
return -ENOMEM;
case A_EINVAL:
default:
return -EFAULT;
}
}
static int
ar6000_ioctl_get_rd(struct net_device *dev, struct ifreq *rq)
{
AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
A_STATUS ret = 0;
if ((dev->flags & IFF_UP) != IFF_UP || ar->arWmiReady == FALSE) {
return -EIO;
}
if(copy_to_user((char *)((unsigned int*)rq->ifr_data + 1),
&ar->arRegCode, sizeof(ar->arRegCode)))
ret = -EFAULT;
return ret;
}
static int
ar6000_ioctl_set_country(struct net_device *dev, struct ifreq *rq)
{
AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
WMI_AP_SET_COUNTRY_CMD cmd;
A_STATUS ret;
if ((dev->flags & IFF_UP) != IFF_UP) {
return -EIO;
}
if (ar->arWmiReady == FALSE) {
return -EIO;
}
if (copy_from_user(&cmd, (char *)((unsigned int*)rq->ifr_data + 1),
sizeof(cmd)))
{
return -EFAULT;
}
ar->ap_profile_flag = 1; /* There is a change in profile */
ret = wmi_set_country(ar->arWmi, cmd.countryCode);
A_MEMCPY(ar->ap_country_code, cmd.countryCode, 3);
switch (ret) {
case A_OK:
return 0;
case A_EBUSY :
return -EBUSY;
case A_NO_MEMORY:
return -ENOMEM;
case A_EINVAL:
default:
return -EFAULT;
}
}
/* Get power mode command */
static int
ar6000_ioctl_get_power_mode(struct net_device *dev, struct ifreq *rq)
{
AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
WMI_POWER_MODE_CMD power_mode;
int ret = 0;
if (ar->arWmiReady == FALSE) {
return -EIO;
}
power_mode.powerMode = wmi_get_power_mode_cmd(ar->arWmi);
if (copy_to_user(rq->ifr_data, &power_mode, sizeof(WMI_POWER_MODE_CMD))) {
ret = -EFAULT;
}
return ret;
}
static int
ar6000_ioctl_set_channelParams(struct net_device *dev, struct ifreq *rq)
{
AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
WMI_CHANNEL_PARAMS_CMD cmd, *cmdp;
int ret = 0;
if (ar->arWmiReady == FALSE) {
return -EIO;
}
if (copy_from_user(&cmd, rq->ifr_data, sizeof(cmd))) {
return -EFAULT;
}
if( (ar->arNextMode == AP_NETWORK) && (cmd.numChannels || cmd.scanParam) ) {
A_PRINTF("ERROR: Only wmode is allowed in AP mode\n");
return -EIO;
}
if (cmd.numChannels > 1) {
cmdp = A_MALLOC(130);
if (copy_from_user(cmdp, rq->ifr_data,
sizeof (*cmdp) +
((cmd.numChannels - 1) * sizeof(A_UINT16))))
{
kfree(cmdp);
return -EFAULT;
}
} else {
cmdp = &cmd;
}
if ((ar->arPhyCapability == WMI_11G_CAPABILITY) &&
((cmdp->phyMode == WMI_11A_MODE) || (cmdp->phyMode == WMI_11AG_MODE)))
{
ret = -EINVAL;
}
if (!ret &&
(wmi_set_channelParams_cmd(ar->arWmi, cmdp->scanParam, cmdp->phyMode,
cmdp->numChannels, cmdp->channelList)
!= A_OK))
{
ret = -EIO;
}
if (cmd.numChannels > 1) {
kfree(cmdp);
}
ar->ap_wmode = cmdp->phyMode;
/* Set the profile change flag to allow a commit cmd */
ar->ap_profile_flag = 1;
return ret;
}
static int
ar6000_ioctl_set_snr_threshold(struct net_device *dev, struct ifreq *rq)
{
AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
WMI_SNR_THRESHOLD_PARAMS_CMD cmd;
int ret = 0;
if (ar->arWmiReady == FALSE) {
return -EIO;
}
if (copy_from_user(&cmd, rq->ifr_data, sizeof(cmd))) {
return -EFAULT;
}
if( wmi_set_snr_threshold_params(ar->arWmi, &cmd) != A_OK ) {
ret = -EIO;
}
return ret;
}
static int
ar6000_ioctl_set_rssi_threshold(struct net_device *dev, struct ifreq *rq)
{
#define SWAP_THOLD(thold1, thold2) do { \
USER_RSSI_THOLD tmpThold; \
tmpThold.tag = thold1.tag; \
tmpThold.rssi = thold1.rssi; \
thold1.tag = thold2.tag; \
thold1.rssi = thold2.rssi; \
thold2.tag = tmpThold.tag; \
thold2.rssi = tmpThold.rssi; \
} while (0)
AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
WMI_RSSI_THRESHOLD_PARAMS_CMD cmd;
USER_RSSI_PARAMS rssiParams;
A_INT32 i, j;
int ret = 0;
if (ar->arWmiReady == FALSE) {
return -EIO;
}
if (copy_from_user((char *)&rssiParams, (char *)((unsigned int *)rq->ifr_data + 1), sizeof(USER_RSSI_PARAMS))) {
return -EFAULT;
}
cmd.weight = rssiParams.weight;
cmd.pollTime = rssiParams.pollTime;
A_MEMCPY(ar->rssi_map, &rssiParams.tholds, sizeof(ar->rssi_map));
/*
* only 6 elements, so use bubble sorting, in ascending order
*/
for (i = 5; i > 0; i--) {
for (j = 0; j < i; j++) { /* above tholds */
if (ar->rssi_map[j+1].rssi < ar->rssi_map[j].rssi) {
SWAP_THOLD(ar->rssi_map[j+1], ar->rssi_map[j]);
} else if (ar->rssi_map[j+1].rssi == ar->rssi_map[j].rssi) {
return EFAULT;
}
}
}
for (i = 11; i > 6; i--) {
for (j = 6; j < i; j++) { /* below tholds */
if (ar->rssi_map[j+1].rssi < ar->rssi_map[j].rssi) {
SWAP_THOLD(ar->rssi_map[j+1], ar->rssi_map[j]);
} else if (ar->rssi_map[j+1].rssi == ar->rssi_map[j].rssi) {
return EFAULT;
}
}
}
#ifdef DEBUG
for (i = 0; i < 12; i++) {
AR_DEBUG_PRINTF(ATH_DEBUG_INFO,("thold[%d].tag: %d, thold[%d].rssi: %d \n",
i, ar->rssi_map[i].tag, i, ar->rssi_map[i].rssi));
}
#endif
if (enablerssicompensation) {
for (i = 0; i < 6; i++)
ar->rssi_map[i].rssi = rssi_compensation_reverse_calc(ar, ar->rssi_map[i].rssi, TRUE);
for (i = 6; i < 12; i++)
ar->rssi_map[i].rssi = rssi_compensation_reverse_calc(ar, ar->rssi_map[i].rssi, FALSE);
}
cmd.thresholdAbove1_Val = ar->rssi_map[0].rssi;
cmd.thresholdAbove2_Val = ar->rssi_map[1].rssi;
cmd.thresholdAbove3_Val = ar->rssi_map[2].rssi;
cmd.thresholdAbove4_Val = ar->rssi_map[3].rssi;
cmd.thresholdAbove5_Val = ar->rssi_map[4].rssi;
cmd.thresholdAbove6_Val = ar->rssi_map[5].rssi;
cmd.thresholdBelow1_Val = ar->rssi_map[6].rssi;
cmd.thresholdBelow2_Val = ar->rssi_map[7].rssi;
cmd.thresholdBelow3_Val = ar->rssi_map[8].rssi;
cmd.thresholdBelow4_Val = ar->rssi_map[9].rssi;
cmd.thresholdBelow5_Val = ar->rssi_map[10].rssi;
cmd.thresholdBelow6_Val = ar->rssi_map[11].rssi;
if( wmi_set_rssi_threshold_params(ar->arWmi, &cmd) != A_OK ) {
ret = -EIO;
}
return ret;
}
static int
ar6000_ioctl_set_lq_threshold(struct net_device *dev, struct ifreq *rq)
{
AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
WMI_LQ_THRESHOLD_PARAMS_CMD cmd;
int ret = 0;
if (ar->arWmiReady == FALSE) {
return -EIO;
}
if (copy_from_user(&cmd, (char *)((unsigned int *)rq->ifr_data + 1), sizeof(cmd))) {
return -EFAULT;
}
if( wmi_set_lq_threshold_params(ar->arWmi, &cmd) != A_OK ) {
ret = -EIO;
}
return ret;
}
static int
ar6000_ioctl_set_probedSsid(struct net_device *dev, struct ifreq *rq)
{
AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
WMI_PROBED_SSID_CMD cmd;
int ret = 0;
if (ar->arWmiReady == FALSE) {
return -EIO;
}
if (copy_from_user(&cmd, rq->ifr_data, sizeof(cmd))) {
return -EFAULT;
}
if (wmi_probedSsid_cmd(ar->arWmi, cmd.entryIndex, cmd.flag, cmd.ssidLength,
cmd.ssid) != A_OK)
{
ret = -EIO;
}
return ret;
}
static int
ar6000_ioctl_set_badAp(struct net_device *dev, struct ifreq *rq)
{
AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
WMI_ADD_BAD_AP_CMD cmd;
int ret = 0;
if (ar->arWmiReady == FALSE) {
return -EIO;
}
if (copy_from_user(&cmd, rq->ifr_data, sizeof(cmd))) {
return -EFAULT;
}
if (cmd.badApIndex > WMI_MAX_BAD_AP_INDEX) {
return -EIO;
}
if (A_MEMCMP(cmd.bssid, null_mac, AR6000_ETH_ADDR_LEN) == 0) {
/*
* This is a delete badAP.
*/
if (wmi_deleteBadAp_cmd(ar->arWmi, cmd.badApIndex) != A_OK) {
ret = -EIO;
}
} else {
if (wmi_addBadAp_cmd(ar->arWmi, cmd.badApIndex, cmd.bssid) != A_OK) {
ret = -EIO;
}
}
return ret;
}
static int
ar6000_ioctl_create_qos(struct net_device *dev, struct ifreq *rq)
{
AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
WMI_CREATE_PSTREAM_CMD cmd;
A_STATUS ret;
if (ar->arWmiReady == FALSE) {
return -EIO;
}
if (copy_from_user(&cmd, rq->ifr_data, sizeof(cmd))) {
return -EFAULT;
}
ret = wmi_verify_tspec_params(&cmd, tspecCompliance);
if (ret == A_OK)
ret = wmi_create_pstream_cmd(ar->arWmi, &cmd);
switch (ret) {
case A_OK:
return 0;
case A_EBUSY :
return -EBUSY;
case A_NO_MEMORY:
return -ENOMEM;
case A_EINVAL:
default:
return -EFAULT;
}
}
static int
ar6000_ioctl_delete_qos(struct net_device *dev, struct ifreq *rq)
{
AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
WMI_DELETE_PSTREAM_CMD cmd;
int ret = 0;
if (ar->arWmiReady == FALSE) {
return -EIO;
}
if (copy_from_user(&cmd, rq->ifr_data, sizeof(cmd))) {
return -EFAULT;
}
ret = wmi_delete_pstream_cmd(ar->arWmi, cmd.trafficClass, cmd.tsid);
switch (ret) {
case A_OK:
return 0;
case A_EBUSY :
return -EBUSY;
case A_NO_MEMORY:
return -ENOMEM;
case A_EINVAL:
default:
return -EFAULT;
}
}
static int
ar6000_ioctl_get_qos_queue(struct net_device *dev, struct ifreq *rq)
{
AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
struct ar6000_queuereq qreq;
int ret = 0;
if (ar->arWmiReady == FALSE) {
return -EIO;
}
if( copy_from_user(&qreq, rq->ifr_data,
sizeof(struct ar6000_queuereq)))
return -EFAULT;
qreq.activeTsids = wmi_get_mapped_qos_queue(ar->arWmi, qreq.trafficClass);
if (copy_to_user(rq->ifr_data, &qreq,
sizeof(struct ar6000_queuereq)))
{
ret = -EFAULT;
}
return ret;
}
#ifdef CONFIG_HOST_TCMD_SUPPORT
static A_STATUS
ar6000_ioctl_tcmd_get_rx_report(struct net_device *dev,
struct ifreq *rq, A_UINT8 *data, A_UINT32 len)
{
AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
A_UINT32 buf[4+TCMD_MAX_RATES];
int ret = 0;
if (ar->bIsDestroyProgress) {
return -EBUSY;
}
if (ar->arWmiReady == FALSE) {
return -EIO;
}
if (down_interruptible(&ar->arSem)) {
return -ERESTARTSYS;
}
if (ar->bIsDestroyProgress) {
up(&ar->arSem);
return -EBUSY;
}
ar->tcmdRxReport = 0;
if (wmi_test_cmd(ar->arWmi, data, len) != A_OK) {
up(&ar->arSem);
return -EIO;
}
wait_event_interruptible_timeout(arEvent, ar->tcmdRxReport != 0, wmitimeout * HZ);
if (signal_pending(current)) {
ret = -EINTR;
}
buf[0] = ar->tcmdRxTotalPkt;
buf[1] = ar->tcmdRxRssi;
buf[2] = ar->tcmdRxcrcErrPkt;
buf[3] = ar->tcmdRxsecErrPkt;
A_MEMCPY(((A_UCHAR *)buf)+(4*sizeof(A_UINT32)), ar->tcmdRateCnt, sizeof(ar->tcmdRateCnt));
A_MEMCPY(((A_UCHAR *)buf)+(4*sizeof(A_UINT32))+(TCMD_MAX_RATES *sizeof(A_UINT16)), ar->tcmdRateCntShortGuard, sizeof(ar->tcmdRateCntShortGuard));
if (!ret && copy_to_user(rq->ifr_data, buf, sizeof(buf))) {
ret = -EFAULT;
}
up(&ar->arSem);
return ret;
}
void
ar6000_tcmd_rx_report_event(void *devt, A_UINT8 * results, int len)
{
AR_SOFTC_T *ar = (AR_SOFTC_T *)devt;
TCMD_CONT_RX * rx_rep = (TCMD_CONT_RX *)results;
if (enablerssicompensation) {
rx_rep->u.report.rssiInDBm = rssi_compensation_calc_tcmd(tcmdRxFreq, rx_rep->u.report.rssiInDBm,rx_rep->u.report.totalPkt);
}
ar->tcmdRxTotalPkt = rx_rep->u.report.totalPkt;
ar->tcmdRxRssi = rx_rep->u.report.rssiInDBm;
ar->tcmdRxcrcErrPkt = rx_rep->u.report.crcErrPkt;
ar->tcmdRxsecErrPkt = rx_rep->u.report.secErrPkt;
ar->tcmdRxReport = 1;
A_MEMZERO(ar->tcmdRateCnt, sizeof(ar->tcmdRateCnt));
A_MEMZERO(ar->tcmdRateCntShortGuard, sizeof(ar->tcmdRateCntShortGuard));
A_MEMCPY(ar->tcmdRateCnt, rx_rep->u.report.rateCnt, sizeof(ar->tcmdRateCnt));
A_MEMCPY(ar->tcmdRateCntShortGuard, rx_rep->u.report.rateCntShortGuard, sizeof(ar->tcmdRateCntShortGuard));
wake_up(&arEvent);
}
#endif /* CONFIG_HOST_TCMD_SUPPORT*/
static int
ar6000_ioctl_set_error_report_bitmask(struct net_device *dev, struct ifreq *rq)
{
AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
WMI_TARGET_ERROR_REPORT_BITMASK cmd;
int ret = 0;
if (ar->arWmiReady == FALSE) {
return -EIO;
}
if (copy_from_user(&cmd, rq->ifr_data, sizeof(cmd))) {
return -EFAULT;
}
ret = wmi_set_error_report_bitmask(ar->arWmi, cmd.bitmask);
return (ret==0 ? ret : -EINVAL);
}
static int
ar6000_clear_target_stats(struct net_device *dev)
{
AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
TARGET_STATS *pStats = &ar->arTargetStats;
int ret = 0;
if (ar->arWmiReady == FALSE) {
return -EIO;
}
AR6000_SPIN_LOCK(&ar->arLock, 0);
A_MEMZERO(pStats, sizeof(TARGET_STATS));
AR6000_SPIN_UNLOCK(&ar->arLock, 0);
return ret;
}
static int
ar6000_ioctl_get_target_stats(struct net_device *dev, struct ifreq *rq)
{
AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
TARGET_STATS_CMD cmd;
TARGET_STATS *pStats = &ar->arTargetStats;
int ret = 0;
if (ar->bIsDestroyProgress) {
return -EBUSY;
}
if (ar->arWmiReady == FALSE) {
return -EIO;
}
if (copy_from_user(&cmd, rq->ifr_data, sizeof(cmd))) {
return -EFAULT;
}
if (down_interruptible(&ar->arSem)) {
return -ERESTARTSYS;
}
if (ar->bIsDestroyProgress) {
up(&ar->arSem);
return -EBUSY;
}
ar->statsUpdatePending = TRUE;
if(wmi_get_stats_cmd(ar->arWmi) != A_OK) {
up(&ar->arSem);
return -EIO;
}
wait_event_interruptible_timeout(arEvent, ar->statsUpdatePending == FALSE, wmitimeout * HZ);
if (signal_pending(current)) {
ret = -EINTR;
}
if (!ret && copy_to_user(rq->ifr_data, pStats, sizeof(*pStats))) {
ret = -EFAULT;
}
if (cmd.clearStats == 1) {
ret = ar6000_clear_target_stats(dev);
}
up(&ar->arSem);
return ret;
}
static int
ar6000_ioctl_get_ap_stats(struct net_device *dev, struct ifreq *rq)
{
AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
A_UINT32 action; /* Allocating only the desired space on the frame. Declaring is as a WMI_AP_MODE_STAT variable results in exceeding the compiler imposed limit on the maximum frame size */
WMI_AP_MODE_STAT *pStats = &ar->arAPStats;
int ret = 0;
if (ar->arWmiReady == FALSE) {
return -EIO;
}
if (copy_from_user(&action, (char *)((unsigned int*)rq->ifr_data + 1),
sizeof(A_UINT32)))
{
return -EFAULT;
}
if (action == AP_CLEAR_STATS) {
A_UINT8 i;
AR6000_SPIN_LOCK(&ar->arLock, 0);
for(i = 0; i < AP_MAX_NUM_STA; i++) {
pStats->sta[i].tx_bytes = 0;
pStats->sta[i].tx_pkts = 0;
pStats->sta[i].tx_error = 0;
pStats->sta[i].tx_discard = 0;
pStats->sta[i].rx_bytes = 0;
pStats->sta[i].rx_pkts = 0;
pStats->sta[i].rx_error = 0;
pStats->sta[i].rx_discard = 0;
}
AR6000_SPIN_UNLOCK(&ar->arLock, 0);
return ret;
}
if (down_interruptible(&ar->arSem)) {
return -ERESTARTSYS;
}
ar->statsUpdatePending = TRUE;
if(wmi_get_stats_cmd(ar->arWmi) != A_OK) {
up(&ar->arSem);
return -EIO;
}
wait_event_interruptible_timeout(arEvent, ar->statsUpdatePending == FALSE, wmitimeout * HZ);
if (signal_pending(current)) {
ret = -EINTR;
}
if (!ret && copy_to_user(rq->ifr_data, pStats, sizeof(*pStats))) {
ret = -EFAULT;
}
up(&ar->arSem);
return ret;
}
static int
ar6000_ioctl_set_access_params(struct net_device *dev, struct ifreq *rq)
{
AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
WMI_SET_ACCESS_PARAMS_CMD cmd;
int ret = 0;
if (ar->arWmiReady == FALSE) {
return -EIO;
}
if (copy_from_user(&cmd, rq->ifr_data, sizeof(cmd))) {
return -EFAULT;
}
if (wmi_set_access_params_cmd(ar->arWmi, cmd.ac, cmd.txop, cmd.eCWmin, cmd.eCWmax,
cmd.aifsn) == A_OK)
{
ret = 0;
} else {
ret = -EINVAL;
}
return (ret);
}
static int
ar6000_ioctl_set_disconnect_timeout(struct net_device *dev, struct ifreq *rq)
{
AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
WMI_DISC_TIMEOUT_CMD cmd;
int ret = 0;
if (ar->arWmiReady == FALSE) {
return -EIO;
}
if (copy_from_user(&cmd, rq->ifr_data, sizeof(cmd))) {
return -EFAULT;
}
if (wmi_disctimeout_cmd(ar->arWmi, cmd.disconnectTimeout) == A_OK)
{
ret = 0;
} else {
ret = -EINVAL;
}
return (ret);
}
static int
ar6000_xioctl_set_voice_pkt_size(struct net_device *dev, char * userdata)
{
AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
WMI_SET_VOICE_PKT_SIZE_CMD cmd;
int ret = 0;
if (ar->arWmiReady == FALSE) {
return -EIO;
}
if (copy_from_user(&cmd, userdata, sizeof(cmd))) {
return -EFAULT;
}
if (wmi_set_voice_pkt_size_cmd(ar->arWmi, cmd.voicePktSize) == A_OK)
{
ret = 0;
} else {
ret = -EINVAL;
}
return (ret);
}
static int
ar6000_xioctl_set_max_sp_len(struct net_device *dev, char * userdata)
{
AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
WMI_SET_MAX_SP_LEN_CMD cmd;
int ret = 0;
if (ar->arWmiReady == FALSE) {
return -EIO;
}
if (copy_from_user(&cmd, userdata, sizeof(cmd))) {
return -EFAULT;
}
if (wmi_set_max_sp_len_cmd(ar->arWmi, cmd.maxSPLen) == A_OK)
{
ret = 0;
} else {
ret = -EINVAL;
}
return (ret);
}
static int
ar6000_xioctl_set_bt_status_cmd(struct net_device *dev, char * userdata)
{
AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
WMI_SET_BT_STATUS_CMD cmd;
int ret = 0;
if (ar->arWmiReady == FALSE) {
return -EIO;
}
if (copy_from_user(&cmd, userdata, sizeof(cmd))) {
return -EFAULT;
}
if (wmi_set_bt_status_cmd(ar->arWmi, cmd.streamType, cmd.status) == A_OK)
{
ret = 0;
} else {
ret = -EINVAL;
}
return (ret);
}
static int
ar6000_xioctl_set_bt_params_cmd(struct net_device *dev, char * userdata)
{
AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
WMI_SET_BT_PARAMS_CMD cmd;
int ret = 0;
if (ar->arWmiReady == FALSE) {
return -EIO;
}
if (copy_from_user(&cmd, userdata, sizeof(cmd))) {
return -EFAULT;
}
if (wmi_set_bt_params_cmd(ar->arWmi, &cmd) == A_OK)
{
ret = 0;
} else {
ret = -EINVAL;
}
return (ret);
}
static int
ar6000_xioctl_set_btcoex_fe_ant_cmd(struct net_device * dev, char * userdata)
{
AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
WMI_SET_BTCOEX_FE_ANT_CMD cmd;
int ret = 0;
if (ar->arWmiReady == FALSE) {
return -EIO;
}
if (copy_from_user(&cmd, userdata, sizeof(cmd))) {
return -EFAULT;
}
if (wmi_set_btcoex_fe_ant_cmd(ar->arWmi, &cmd) == A_OK)
{
ret = 0;
} else {
ret = -EINVAL;
}
return(ret);
}
static int
ar6000_xioctl_set_btcoex_colocated_bt_dev_cmd(struct net_device * dev, char * userdata)
{
AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
WMI_SET_BTCOEX_COLOCATED_BT_DEV_CMD cmd;
int ret = 0;
if (ar->arWmiReady == FALSE) {
return -EIO;
}
if (copy_from_user(&cmd, userdata, sizeof(cmd))) {
return -EFAULT;
}
if (wmi_set_btcoex_colocated_bt_dev_cmd(ar->arWmi, &cmd) == A_OK)
{
ret = 0;
} else {
ret = -EINVAL;
}
return(ret);
}
static int
ar6000_xioctl_set_btcoex_btinquiry_page_config_cmd(struct net_device * dev, char * userdata)
{
AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
WMI_SET_BTCOEX_BTINQUIRY_PAGE_CONFIG_CMD cmd;
int ret = 0;
if (ar->arWmiReady == FALSE) {
return -EIO;
}
if (copy_from_user(&cmd, userdata, sizeof(cmd))) {
return -EFAULT;
}
if (wmi_set_btcoex_btinquiry_page_config_cmd(ar->arWmi, &cmd) == A_OK)
{
ret = 0;
} else {
ret = -EINVAL;
}
return(ret);
}
static int
ar6000_xioctl_set_btcoex_sco_config_cmd(struct net_device * dev, char * userdata)
{
AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
WMI_SET_BTCOEX_SCO_CONFIG_CMD cmd;
int ret = 0;
if (ar->arWmiReady == FALSE) {
return -EIO;
}
if (copy_from_user(&cmd, userdata, sizeof(cmd))) {
return -EFAULT;
}
if (wmi_set_btcoex_sco_config_cmd(ar->arWmi, &cmd) == A_OK)
{
ret = 0;
} else {
ret = -EINVAL;
}
return(ret);
}
static int
ar6000_xioctl_set_btcoex_a2dp_config_cmd(struct net_device * dev,
char * userdata)
{
AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
WMI_SET_BTCOEX_A2DP_CONFIG_CMD cmd;
int ret = 0;
if (ar->arWmiReady == FALSE) {
return -EIO;
}
if (copy_from_user(&cmd, userdata, sizeof(cmd))) {
return -EFAULT;
}
if (wmi_set_btcoex_a2dp_config_cmd(ar->arWmi, &cmd) == A_OK)
{
ret = 0;
} else {
ret = -EINVAL;
}
return(ret);
}
static int
ar6000_xioctl_set_btcoex_aclcoex_config_cmd(struct net_device * dev, char * userdata)
{
AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
WMI_SET_BTCOEX_ACLCOEX_CONFIG_CMD cmd;
int ret = 0;
if (ar->arWmiReady == FALSE) {
return -EIO;
}
if (copy_from_user(&cmd, userdata, sizeof(cmd))) {
return -EFAULT;
}
if (wmi_set_btcoex_aclcoex_config_cmd(ar->arWmi, &cmd) == A_OK)
{
ret = 0;
} else {
ret = -EINVAL;
}
return(ret);
}
static int
ar60000_xioctl_set_btcoex_debug_cmd(struct net_device * dev, char * userdata)
{
AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
WMI_SET_BTCOEX_DEBUG_CMD cmd;
int ret = 0;
if (ar->arWmiReady == FALSE) {
return -EIO;
}
if (copy_from_user(&cmd, userdata, sizeof(cmd))) {
return -EFAULT;
}
if (wmi_set_btcoex_debug_cmd(ar->arWmi, &cmd) == A_OK)
{
ret = 0;
} else {
ret = -EINVAL;
}
return(ret);
}
static int
ar6000_xioctl_set_btcoex_bt_operating_status_cmd(struct net_device * dev, char * userdata)
{
AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
WMI_SET_BTCOEX_BT_OPERATING_STATUS_CMD cmd;
int ret = 0;
if (ar->arWmiReady == FALSE) {
return -EIO;
}
if (copy_from_user(&cmd, userdata, sizeof(cmd))) {
return -EFAULT;
}
if (wmi_set_btcoex_bt_operating_status_cmd(ar->arWmi, &cmd) == A_OK)
{
ret = 0;
} else {
ret = -EINVAL;
}
return(ret);
}
static int
ar6000_xioctl_get_btcoex_config_cmd(struct net_device * dev, char * userdata,
struct ifreq *rq)
{
AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
AR6000_BTCOEX_CONFIG btcoexConfig;
WMI_BTCOEX_CONFIG_EVENT *pbtcoexConfigEv = &ar->arBtcoexConfig;
int ret = 0;
if (ar->bIsDestroyProgress) {
return -EBUSY;
}
if (ar->arWmiReady == FALSE) {
return -EIO;
}
if (copy_from_user(&btcoexConfig.configCmd, userdata, sizeof(AR6000_BTCOEX_CONFIG))) {
return -EFAULT;
}
if (down_interruptible(&ar->arSem)) {
return -ERESTARTSYS;
}
if (wmi_get_btcoex_config_cmd(ar->arWmi, (WMI_GET_BTCOEX_CONFIG_CMD *)&btcoexConfig.configCmd) != A_OK)
{
up(&ar->arSem);
return -EIO;
}
ar->statsUpdatePending = TRUE;
wait_event_interruptible_timeout(arEvent, ar->statsUpdatePending == FALSE, wmitimeout * HZ);
if (signal_pending(current)) {
ret = -EINTR;
}
if (!ret && copy_to_user(btcoexConfig.configEvent, pbtcoexConfigEv, sizeof(WMI_BTCOEX_CONFIG_EVENT))) {
ret = -EFAULT;
}
up(&ar->arSem);
return ret;
}
static int
ar6000_xioctl_get_btcoex_stats_cmd(struct net_device * dev, char * userdata, struct ifreq *rq)
{
AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
AR6000_BTCOEX_STATS btcoexStats;
WMI_BTCOEX_STATS_EVENT *pbtcoexStats = &ar->arBtcoexStats;
int ret = 0;
if (ar->bIsDestroyProgress) {
return -EBUSY;
}
if (ar->arWmiReady == FALSE) {
return -EIO;
}
if (down_interruptible(&ar->arSem)) {
return -ERESTARTSYS;
}
if (copy_from_user(&btcoexStats.statsEvent, userdata, sizeof(AR6000_BTCOEX_CONFIG))) {
return -EFAULT;
}
if (wmi_get_btcoex_stats_cmd(ar->arWmi) != A_OK)
{
up(&ar->arSem);
return -EIO;
}
ar->statsUpdatePending = TRUE;
wait_event_interruptible_timeout(arEvent, ar->statsUpdatePending == FALSE, wmitimeout * HZ);
if (signal_pending(current)) {
ret = -EINTR;
}
if (!ret && copy_to_user(btcoexStats.statsEvent, pbtcoexStats, sizeof(WMI_BTCOEX_STATS_EVENT))) {
ret = -EFAULT;
}
up(&ar->arSem);
return(ret);
}
#ifdef CONFIG_HOST_GPIO_SUPPORT
struct ar6000_gpio_intr_wait_cmd_s gpio_intr_results;
/* gpio_reg_results and gpio_data_available are protected by arSem */
static struct ar6000_gpio_register_cmd_s gpio_reg_results;
static A_BOOL gpio_data_available; /* Requested GPIO data available */
static A_BOOL gpio_intr_available; /* GPIO interrupt info available */
static A_BOOL gpio_ack_received; /* GPIO ack was received */
/* Host-side initialization for General Purpose I/O support */
void ar6000_gpio_init(void)
{
gpio_intr_available = FALSE;
gpio_data_available = FALSE;
gpio_ack_received = FALSE;
}
/*
* Called when a GPIO interrupt is received from the Target.
* intr_values shows which GPIO pins have interrupted.
* input_values shows a recent value of GPIO pins.
*/
void
ar6000_gpio_intr_rx(A_UINT32 intr_mask, A_UINT32 input_values)
{
gpio_intr_results.intr_mask = intr_mask;
gpio_intr_results.input_values = input_values;
*((volatile A_BOOL *)&gpio_intr_available) = TRUE;
wake_up(&arEvent);
}
/*
* This is called when a response is received from the Target
* for a previous or ar6000_gpio_input_get or ar6000_gpio_register_get
* call.
*/
void
ar6000_gpio_data_rx(A_UINT32 reg_id, A_UINT32 value)
{
gpio_reg_results.gpioreg_id = reg_id;
gpio_reg_results.value = value;
*((volatile A_BOOL *)&gpio_data_available) = TRUE;
wake_up(&arEvent);
}
/*
* This is called when an acknowledgement is received from the Target
* for a previous or ar6000_gpio_output_set or ar6000_gpio_register_set
* call.
*/
void
ar6000_gpio_ack_rx(void)
{
gpio_ack_received = TRUE;
wake_up(&arEvent);
}
A_STATUS
ar6000_gpio_output_set(struct net_device *dev,
A_UINT32 set_mask,
A_UINT32 clear_mask,
A_UINT32 enable_mask,
A_UINT32 disable_mask)
{
AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
gpio_ack_received = FALSE;
return wmi_gpio_output_set(ar->arWmi,
set_mask, clear_mask, enable_mask, disable_mask);
}
static A_STATUS
ar6000_gpio_input_get(struct net_device *dev)
{
AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
*((volatile A_BOOL *)&gpio_data_available) = FALSE;
return wmi_gpio_input_get(ar->arWmi);
}
static A_STATUS
ar6000_gpio_register_set(struct net_device *dev,
A_UINT32 gpioreg_id,
A_UINT32 value)
{
AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
gpio_ack_received = FALSE;
return wmi_gpio_register_set(ar->arWmi, gpioreg_id, value);
}
static A_STATUS
ar6000_gpio_register_get(struct net_device *dev,
A_UINT32 gpioreg_id)
{
AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
*((volatile A_BOOL *)&gpio_data_available) = FALSE;
return wmi_gpio_register_get(ar->arWmi, gpioreg_id);
}
static A_STATUS
ar6000_gpio_intr_ack(struct net_device *dev,
A_UINT32 ack_mask)
{
AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
gpio_intr_available = FALSE;
return wmi_gpio_intr_ack(ar->arWmi, ack_mask);
}
#endif /* CONFIG_HOST_GPIO_SUPPORT */
#if defined(CONFIG_TARGET_PROFILE_SUPPORT)
static struct prof_count_s prof_count_results;
static A_BOOL prof_count_available; /* Requested GPIO data available */
static A_STATUS
prof_count_get(struct net_device *dev)
{
AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
*((volatile A_BOOL *)&prof_count_available) = FALSE;
return wmi_prof_count_get_cmd(ar->arWmi);
}
/*
* This is called when a response is received from the Target
* for a previous prof_count_get call.
*/
void
prof_count_rx(A_UINT32 addr, A_UINT32 count)
{
prof_count_results.addr = addr;
prof_count_results.count = count;
*((volatile A_BOOL *)&prof_count_available) = TRUE;
wake_up(&arEvent);
}
#endif /* CONFIG_TARGET_PROFILE_SUPPORT */
static A_STATUS
ar6000_create_acl_data_osbuf(struct net_device *dev, A_UINT8 *userdata, void **p_osbuf)
{
void *osbuf = NULL;
A_UINT8 tmp_space[8];
HCI_ACL_DATA_PKT *acl;
A_UINT8 hdr_size, *datap=NULL;
A_STATUS ret = A_OK;
/* ACL is in data path. There is a need to create pool
* mechanism for allocating and freeing NETBUFs - ToDo later.
*/
*p_osbuf = NULL;
acl = (HCI_ACL_DATA_PKT *)tmp_space;
hdr_size = sizeof(acl->hdl_and_flags) + sizeof(acl->data_len);
do {
if (a_copy_from_user(acl, userdata, hdr_size)) {
ret = A_EFAULT;
break;
}
osbuf = A_NETBUF_ALLOC(hdr_size + acl->data_len);
if (osbuf == NULL) {
ret = A_NO_MEMORY;
break;
}
A_NETBUF_PUT(osbuf, hdr_size + acl->data_len);
datap = (A_UINT8 *)A_NETBUF_DATA(osbuf);
/* Real copy to osbuf */
acl = (HCI_ACL_DATA_PKT *)(datap);
A_MEMCPY(acl, tmp_space, hdr_size);
if (a_copy_from_user(acl->data, userdata + hdr_size, acl->data_len)) {
ret = A_EFAULT;
break;
}
} while(FALSE);
if (ret == A_OK) {
*p_osbuf = osbuf;
} else {
A_NETBUF_FREE(osbuf);
}
return ret;
}
int
ar6000_ioctl_ap_setparam(AR_SOFTC_T *ar, int param, int value)
{
int ret=0;
switch(param) {
case IEEE80211_PARAM_WPA:
switch (value) {
case WPA_MODE_WPA1:
ar->arAuthMode = WPA_AUTH;
break;
case WPA_MODE_WPA2:
ar->arAuthMode = WPA2_AUTH;
break;
case WPA_MODE_AUTO:
ar->arAuthMode = WPA_AUTH | WPA2_AUTH;
break;
case WPA_MODE_NONE:
ar->arAuthMode = NONE_AUTH;
break;
}
break;
case IEEE80211_PARAM_AUTHMODE:
if(value == IEEE80211_AUTH_WPA_PSK) {
if (WPA_AUTH == ar->arAuthMode) {
ar->arAuthMode = WPA_PSK_AUTH;
} else if (WPA2_AUTH == ar->arAuthMode) {
ar->arAuthMode = WPA2_PSK_AUTH;
} else if ((WPA_AUTH | WPA2_AUTH) == ar->arAuthMode) {
ar->arAuthMode = WPA_PSK_AUTH | WPA2_PSK_AUTH;
} else {
AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Error - Setting PSK "\
"mode when WPA param was set to %d\n",
ar->arAuthMode));
ret = -EIO;
}
}
break;
case IEEE80211_PARAM_UCASTCIPHER:
ar->arPairwiseCrypto = 0;
if(value & (1<<IEEE80211_CIPHER_AES_CCM)) {
ar->arPairwiseCrypto |= AES_CRYPT;
}
if(value & (1<<IEEE80211_CIPHER_TKIP)) {
ar->arPairwiseCrypto |= TKIP_CRYPT;
}
if(!ar->arPairwiseCrypto) {
AR_DEBUG_PRINTF(ATH_DEBUG_ERR,
("Error - Invalid cipher in WPA \n"));
ret = -EIO;
}
break;
case IEEE80211_PARAM_PRIVACY:
if(value == 0) {
ar->arDot11AuthMode = OPEN_AUTH;
ar->arAuthMode = NONE_AUTH;
ar->arPairwiseCrypto = NONE_CRYPT;
ar->arPairwiseCryptoLen = 0;
ar->arGroupCrypto = NONE_CRYPT;
ar->arGroupCryptoLen = 0;
}
break;
#ifdef WAPI_ENABLE
case IEEE80211_PARAM_WAPI:
A_PRINTF("WAPI Policy: %d\n", value);
ar->arDot11AuthMode = OPEN_AUTH;
ar->arAuthMode = NONE_AUTH;
if(value & 0x1) {
ar->arPairwiseCrypto = WAPI_CRYPT;
ar->arGroupCrypto = WAPI_CRYPT;
} else {
ar->arPairwiseCrypto = NONE_CRYPT;
ar->arGroupCrypto = NONE_CRYPT;
}
break;
#endif
}
return ret;
}
int
ar6000_ioctl_setparam(AR_SOFTC_T *ar, int param, int value)
{
A_BOOL profChanged = FALSE;
int ret=0;
if(ar->arNextMode == AP_NETWORK) {
ar->ap_profile_flag = 1; /* There is a change in profile */
switch (param) {
case IEEE80211_PARAM_WPA:
case IEEE80211_PARAM_AUTHMODE:
case IEEE80211_PARAM_UCASTCIPHER:
case IEEE80211_PARAM_PRIVACY:
case IEEE80211_PARAM_WAPI:
ret = ar6000_ioctl_ap_setparam(ar, param, value);
return ret;
}
}
switch (param) {
case IEEE80211_PARAM_WPA:
switch (value) {
case WPA_MODE_WPA1:
ar->arAuthMode = WPA_AUTH;
profChanged = TRUE;
break;
case WPA_MODE_WPA2:
ar->arAuthMode = WPA2_AUTH;
profChanged = TRUE;
break;
case WPA_MODE_NONE:
ar->arAuthMode = NONE_AUTH;
profChanged = TRUE;
break;
}
break;
case IEEE80211_PARAM_AUTHMODE:
switch(value) {
case IEEE80211_AUTH_WPA_PSK:
if (WPA_AUTH == ar->arAuthMode) {
ar->arAuthMode = WPA_PSK_AUTH;
profChanged = TRUE;
} else if (WPA2_AUTH == ar->arAuthMode) {
ar->arAuthMode = WPA2_PSK_AUTH;
profChanged = TRUE;
} else {
AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Error - Setting PSK "\
"mode when WPA param was set to %d\n",
ar->arAuthMode));
ret = -EIO;
}
break;
case IEEE80211_AUTH_WPA_CCKM:
if (WPA2_AUTH == ar->arAuthMode) {
ar->arAuthMode = WPA2_AUTH_CCKM;
} else {
ar->arAuthMode = WPA_AUTH_CCKM;
}
break;
default:
break;
}
break;
case IEEE80211_PARAM_UCASTCIPHER:
switch (value) {
case IEEE80211_CIPHER_AES_CCM:
ar->arPairwiseCrypto = AES_CRYPT;
profChanged = TRUE;
break;
case IEEE80211_CIPHER_TKIP:
ar->arPairwiseCrypto = TKIP_CRYPT;
profChanged = TRUE;
break;
case IEEE80211_CIPHER_WEP:
ar->arPairwiseCrypto = WEP_CRYPT;
profChanged = TRUE;
break;
case IEEE80211_CIPHER_NONE:
ar->arPairwiseCrypto = NONE_CRYPT;
profChanged = TRUE;
break;
}
break;
case IEEE80211_PARAM_UCASTKEYLEN:
if (!IEEE80211_IS_VALID_WEP_CIPHER_LEN(value)) {
ret = -EIO;
} else {
ar->arPairwiseCryptoLen = value;
}
break;
case IEEE80211_PARAM_MCASTCIPHER:
switch (value) {
case IEEE80211_CIPHER_AES_CCM:
ar->arGroupCrypto = AES_CRYPT;
profChanged = TRUE;
break;
case IEEE80211_CIPHER_TKIP:
ar->arGroupCrypto = TKIP_CRYPT;
profChanged = TRUE;
break;
case IEEE80211_CIPHER_WEP:
ar->arGroupCrypto = WEP_CRYPT;
profChanged = TRUE;
break;
case IEEE80211_CIPHER_NONE:
ar->arGroupCrypto = NONE_CRYPT;
profChanged = TRUE;
break;
}
break;
case IEEE80211_PARAM_MCASTKEYLEN:
if (!IEEE80211_IS_VALID_WEP_CIPHER_LEN(value)) {
ret = -EIO;
} else {
ar->arGroupCryptoLen = value;
}
break;
case IEEE80211_PARAM_COUNTERMEASURES:
if (ar->arWmiReady == FALSE) {
return -EIO;
}
wmi_set_tkip_countermeasures_cmd(ar->arWmi, value);
break;
default:
break;
}
if ((ar->arNextMode != AP_NETWORK) && (profChanged == TRUE)) {
/*
* profile has changed. Erase ssid to signal change
*/
A_MEMZERO(ar->arSsid, sizeof(ar->arSsid));
}
return ret;
}
int
ar6000_ioctl_setkey(AR_SOFTC_T *ar, struct ieee80211req_key *ik)
{
KEY_USAGE keyUsage;
A_STATUS status;
CRYPTO_TYPE keyType = NONE_CRYPT;
#ifdef USER_KEYS
ar->user_saved_keys.keyOk = FALSE;
#endif
if ( (0 == memcmp(ik->ik_macaddr, null_mac, IEEE80211_ADDR_LEN)) ||
(0 == memcmp(ik->ik_macaddr, bcast_mac, IEEE80211_ADDR_LEN)) ) {
keyUsage = GROUP_USAGE;
if(ar->arNextMode == AP_NETWORK) {
A_MEMCPY(&ar->ap_mode_bkey, ik,
sizeof(struct ieee80211req_key));
#ifdef WAPI_ENABLE
if(ar->arPairwiseCrypto == WAPI_CRYPT) {
return ap_set_wapi_key(ar, ik);
}
#endif
}
#ifdef USER_KEYS
A_MEMCPY(&ar->user_saved_keys.bcast_ik, ik,
sizeof(struct ieee80211req_key));
#endif
} else {
keyUsage = PAIRWISE_USAGE;
#ifdef USER_KEYS
A_MEMCPY(&ar->user_saved_keys.ucast_ik, ik,
sizeof(struct ieee80211req_key));
#endif
#ifdef WAPI_ENABLE
if(ar->arNextMode == AP_NETWORK) {
if(ar->arPairwiseCrypto == WAPI_CRYPT) {
return ap_set_wapi_key(ar, ik);
}
}
#endif
}
switch (ik->ik_type) {
case IEEE80211_CIPHER_WEP:
keyType = WEP_CRYPT;
break;
case IEEE80211_CIPHER_TKIP:
keyType = TKIP_CRYPT;
break;
case IEEE80211_CIPHER_AES_CCM:
keyType = AES_CRYPT;
break;
default:
break;
}
#ifdef USER_KEYS
ar->user_saved_keys.keyType = keyType;
#endif
if (IEEE80211_CIPHER_CCKM_KRK != ik->ik_type) {
if (NONE_CRYPT == keyType) {
return -EIO;
}
if ((WEP_CRYPT == keyType)&&(!ar->arConnected)) {
int index = ik->ik_keyix;
if (!IEEE80211_IS_VALID_WEP_CIPHER_LEN(ik->ik_keylen)) {
return -EIO;
}
A_MEMZERO(ar->arWepKeyList[index].arKey,
sizeof(ar->arWepKeyList[index].arKey));
A_MEMCPY(ar->arWepKeyList[index].arKey, ik->ik_keydata, ik->ik_keylen);
ar->arWepKeyList[index].arKeyLen = ik->ik_keylen;
if(ik->ik_flags & IEEE80211_KEY_DEFAULT){
ar->arDefTxKeyIndex = index;
}
return 0;
}
if (((WPA_PSK_AUTH == ar->arAuthMode) || (WPA2_PSK_AUTH == ar->arAuthMode)) &&
(GROUP_USAGE & keyUsage))
{
A_UNTIMEOUT(&ar->disconnect_timer);
}
status = wmi_addKey_cmd(ar->arWmi, ik->ik_keyix, keyType, keyUsage,
ik->ik_keylen, (A_UINT8 *)&ik->ik_keyrsc,
ik->ik_keydata, KEY_OP_INIT_VAL, ik->ik_macaddr,
SYNC_BOTH_WMIFLAG);
if (status != A_OK) {
return -EIO;
}
} else {
status = wmi_add_krk_cmd(ar->arWmi, ik->ik_keydata);
}
#ifdef USER_KEYS
ar->user_saved_keys.keyOk = TRUE;
#endif
return 0;
}
int ar6000_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
{
AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
HIF_DEVICE *hifDevice = ar->arHifDevice;
int ret = 0, param;
unsigned int address = 0;
unsigned int length = 0;
unsigned char *buffer;
char *userdata;
A_UINT32 connectCtrlFlags;
WMI_SET_AKMP_PARAMS_CMD akmpParams;
WMI_SET_PMKID_LIST_CMD pmkidInfo;
WMI_SET_HT_CAP_CMD htCap;
WMI_SET_HT_OP_CMD htOp;
/*
* ioctl operations may have to wait for the Target, so we cannot hold rtnl.
* Prevent the device from disappearing under us and release the lock during
* the ioctl operation.
*/
dev_hold(dev);
rtnl_unlock();
if (cmd == AR6000_IOCTL_EXTENDED) {
/*
* This allows for many more wireless ioctls than would otherwise
* be available. Applications embed the actual ioctl command in
* the first word of the parameter block, and use the command
* AR6000_IOCTL_EXTENDED_CMD on the ioctl call.
*/
get_user(cmd, (int *)rq->ifr_data);
userdata = (char *)(((unsigned int *)rq->ifr_data)+1);
if(is_xioctl_allowed(ar->arNextMode, cmd) != A_OK) {
A_PRINTF("xioctl: cmd=%d not allowed in this mode\n",cmd);
ret = -EOPNOTSUPP;
goto ioctl_done;
}
} else {
A_STATUS ret = is_iwioctl_allowed(ar->arNextMode, cmd);
if(ret == A_ENOTSUP) {
A_PRINTF("iwioctl: cmd=0x%x not allowed in this mode\n", cmd);
ret = -EOPNOTSUPP;
goto ioctl_done;
} else if (ret == A_ERROR) {
/* It is not our ioctl (out of range ioctl) */
ret = -EOPNOTSUPP;
goto ioctl_done;
}
userdata = (char *)rq->ifr_data;
}
if ((ar->arWlanState == WLAN_DISABLED) &&
((cmd != AR6000_XIOCTRL_WMI_SET_WLAN_STATE) &&
(cmd != AR6000_XIOCTL_GET_WLAN_SLEEP_STATE) &&
(cmd != AR6000_XIOCTL_DIAG_READ) &&
(cmd != AR6000_XIOCTL_DIAG_WRITE) &&
(cmd != AR6000_XIOCTL_SET_BT_HW_POWER_STATE) &&
(cmd != AR6000_XIOCTL_GET_BT_HW_POWER_STATE) &&
(cmd != AR6000_XIOCTL_ADD_AP_INTERFACE) &&
(cmd != AR6000_XIOCTL_REMOVE_AP_INTERFACE) &&
(cmd != AR6000_IOCTL_WMI_GETREV)))
{
ret = -EIO;
goto ioctl_done;
}
ret = 0;
switch(cmd)
{
case IEEE80211_IOCTL_SETPARAM:
{
int param, value;
int *ptr = (int *)rq->ifr_ifru.ifru_newname;
if (ar->arWmiReady == FALSE) {
ret = -EIO;
} else {
param = *ptr++;
value = *ptr;
ret = ar6000_ioctl_setparam(ar,param,value);
}
break;
}
case IEEE80211_IOCTL_SETKEY:
{
struct ieee80211req_key keydata;
if (ar->arWmiReady == FALSE) {
ret = -EIO;
} else if (copy_from_user(&keydata, userdata,
sizeof(struct ieee80211req_key))) {
ret = -EFAULT;
} else {
ar6000_ioctl_setkey(ar, &keydata);
}
break;
}
case IEEE80211_IOCTL_DELKEY:
case IEEE80211_IOCTL_SETOPTIE:
{
//ret = -EIO;
break;
}
case IEEE80211_IOCTL_SETMLME:
{
struct ieee80211req_mlme mlme;
if (ar->arWmiReady == FALSE) {
ret = -EIO;
} else if (copy_from_user(&mlme, userdata,
sizeof(struct ieee80211req_mlme))) {
ret = -EFAULT;
} else {
switch (mlme.im_op) {
case IEEE80211_MLME_AUTHORIZE:
A_PRINTF("setmlme AUTHORIZE %02X:%02X\n",
mlme.im_macaddr[4], mlme.im_macaddr[5]);
break;
case IEEE80211_MLME_UNAUTHORIZE:
A_PRINTF("setmlme UNAUTHORIZE %02X:%02X\n",
mlme.im_macaddr[4], mlme.im_macaddr[5]);
break;
case IEEE80211_MLME_DEAUTH:
A_PRINTF("setmlme DEAUTH %02X:%02X\n",
mlme.im_macaddr[4], mlme.im_macaddr[5]);
//remove_sta(ar, mlme.im_macaddr);
break;
case IEEE80211_MLME_DISASSOC:
A_PRINTF("setmlme DISASSOC %02X:%02X\n",
mlme.im_macaddr[4], mlme.im_macaddr[5]);
//remove_sta(ar, mlme.im_macaddr);
break;
default:
ret = 0;
goto ioctl_done;
}
wmi_ap_set_mlme(ar->arWmi, mlme.im_op, mlme.im_macaddr,
mlme.im_reason);
}
break;
}
case IEEE80211_IOCTL_ADDPMKID:
{
struct ieee80211req_addpmkid req;
if (ar->arWmiReady == FALSE) {
ret = -EIO;
} else if (copy_from_user(&req, userdata, sizeof(struct ieee80211req_addpmkid))) {
ret = -EFAULT;
} else {
A_STATUS status;
AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_CONNECT,("Add pmkid for %2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x en=%d\n",
req.pi_bssid[0], req.pi_bssid[1], req.pi_bssid[2],
req.pi_bssid[3], req.pi_bssid[4], req.pi_bssid[5],
req.pi_enable));
status = wmi_setPmkid_cmd(ar->arWmi, req.pi_bssid, req.pi_pmkid,
req.pi_enable);
if (status != A_OK) {
ret = -EIO;
goto ioctl_done;
}
}
break;
}
#ifdef CONFIG_HOST_TCMD_SUPPORT
case AR6000_XIOCTL_TCMD_CONT_TX:
{
TCMD_CONT_TX txCmd;
if ((ar->tcmdPm == TCMD_PM_SLEEP) ||
(ar->tcmdPm == TCMD_PM_DEEPSLEEP))
{
A_PRINTF("Can NOT send tx tcmd when target is asleep! \n");
ret = -EFAULT;
goto ioctl_done;
}
if(copy_from_user(&txCmd, userdata, sizeof(TCMD_CONT_TX))) {
ret = -EFAULT;
goto ioctl_done;
} else {
wmi_test_cmd(ar->arWmi,(A_UINT8 *)&txCmd, sizeof(TCMD_CONT_TX));
}
}
break;
case AR6000_XIOCTL_TCMD_CONT_RX:
{
TCMD_CONT_RX rxCmd;
if ((ar->tcmdPm == TCMD_PM_SLEEP) ||
(ar->tcmdPm == TCMD_PM_DEEPSLEEP))
{
A_PRINTF("Can NOT send rx tcmd when target is asleep! \n");
ret = -EFAULT;
goto ioctl_done;
}
if(copy_from_user(&rxCmd, userdata, sizeof(TCMD_CONT_RX))) {
ret = -EFAULT;
goto ioctl_done;
}
switch(rxCmd.act)
{
case TCMD_CONT_RX_PROMIS:
case TCMD_CONT_RX_FILTER:
case TCMD_CONT_RX_SETMAC:
case TCMD_CONT_RX_SET_ANT_SWITCH_TABLE:
wmi_test_cmd(ar->arWmi,(A_UINT8 *)&rxCmd,
sizeof(TCMD_CONT_RX));
tcmdRxFreq = rxCmd.u.para.freq;
break;
case TCMD_CONT_RX_REPORT:
ar6000_ioctl_tcmd_get_rx_report(dev, rq,
(A_UINT8 *)&rxCmd, sizeof(TCMD_CONT_RX));
break;
default:
A_PRINTF("Unknown Cont Rx mode: %d\n",rxCmd.act);
ret = -EINVAL;
goto ioctl_done;
}
}
break;
case AR6000_XIOCTL_TCMD_PM:
{
TCMD_PM pmCmd;
if(copy_from_user(&pmCmd, userdata, sizeof(TCMD_PM))) {
ret = -EFAULT;
goto ioctl_done;
}
ar->tcmdPm = pmCmd.mode;
wmi_test_cmd(ar->arWmi, (A_UINT8*)&pmCmd, sizeof(TCMD_PM));
}
break;
#endif /* CONFIG_HOST_TCMD_SUPPORT */
case AR6000_XIOCTL_BMI_DONE:
if(bmienable)
{
rtnl_lock(); /* ar6000_init expects to be called holding rtnl lock */
ret = ar6000_init(dev);
rtnl_unlock();
}
else
{
ret = BMIDone(hifDevice);
}
break;
case AR6000_XIOCTL_BMI_READ_MEMORY:
get_user(address, (unsigned int *)userdata);
get_user(length, (unsigned int *)userdata + 1);
AR_DEBUG_PRINTF(ATH_DEBUG_INFO,("Read Memory (address: 0x%x, length: %d)\n",
address, length));
if ((buffer = (unsigned char *)A_MALLOC(length)) != NULL) {
A_MEMZERO(buffer, length);
ret = BMIReadMemory(hifDevice, address, buffer, length);
if (copy_to_user(rq->ifr_data, buffer, length)) {
ret = -EFAULT;
}
A_FREE(buffer);
} else {
ret = -ENOMEM;
}
break;
case AR6000_XIOCTL_BMI_WRITE_MEMORY:
get_user(address, (unsigned int *)userdata);
get_user(length, (unsigned int *)userdata + 1);
AR_DEBUG_PRINTF(ATH_DEBUG_INFO,("Write Memory (address: 0x%x, length: %d)\n",
address, length));
if ((buffer = (unsigned char *)A_MALLOC(length)) != NULL) {
A_MEMZERO(buffer, length);
if (copy_from_user(buffer, &userdata[sizeof(address) +
sizeof(length)], length))
{
ret = -EFAULT;
} else {
ret = BMIWriteMemory(hifDevice, address, buffer, length);
}
A_FREE(buffer);
} else {
ret = -ENOMEM;
}
break;
case AR6000_XIOCTL_BMI_TEST:
AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("No longer supported\n"));
ret = -EOPNOTSUPP;
break;
case AR6000_XIOCTL_BMI_EXECUTE:
get_user(address, (unsigned int *)userdata);
get_user(param, (unsigned int *)userdata + 1);
AR_DEBUG_PRINTF(ATH_DEBUG_INFO,("Execute (address: 0x%x, param: %d)\n",
address, param));
ret = BMIExecute(hifDevice, address, (A_UINT32*)¶m);
put_user(param, (unsigned int *)rq->ifr_data); /* return value */
break;
case AR6000_XIOCTL_BMI_SET_APP_START:
get_user(address, (unsigned int *)userdata);
AR_DEBUG_PRINTF(ATH_DEBUG_INFO,("Set App Start (address: 0x%x)\n", address));
ret = BMISetAppStart(hifDevice, address);
break;
case AR6000_XIOCTL_BMI_READ_SOC_REGISTER:
get_user(address, (unsigned int *)userdata);
ret = BMIReadSOCRegister(hifDevice, address, (A_UINT32*)¶m);
put_user(param, (unsigned int *)rq->ifr_data); /* return value */
break;
case AR6000_XIOCTL_BMI_WRITE_SOC_REGISTER:
get_user(address, (unsigned int *)userdata);
get_user(param, (unsigned int *)userdata + 1);
ret = BMIWriteSOCRegister(hifDevice, address, param);
break;
#ifdef HTC_RAW_INTERFACE
case AR6000_XIOCTL_HTC_RAW_OPEN:
ret = A_OK;
if (!arRawIfEnabled(ar)) {
/* make sure block size is set in case the target was reset since last
* BMI phase (i.e. flashup downloads) */
ret = ar6000_set_htc_params(ar->arHifDevice,
ar->arTargetType,
0, /* use default yield */
0 /* use default number of HTC ctrl buffers */
);
if (A_FAILED(ret)) {
break;
}
/* Terminate the BMI phase */
ret = BMIDone(hifDevice);
if (ret == A_OK) {
ret = ar6000_htc_raw_open(ar);
}
}
break;
case AR6000_XIOCTL_HTC_RAW_CLOSE:
if (arRawIfEnabled(ar)) {
ret = ar6000_htc_raw_close(ar);
arRawIfEnabled(ar) = FALSE;
} else {
ret = A_ERROR;
}
break;
case AR6000_XIOCTL_HTC_RAW_READ:
if (arRawIfEnabled(ar)) {
unsigned int streamID;
get_user(streamID, (unsigned int *)userdata);
get_user(length, (unsigned int *)userdata + 1);
buffer = (unsigned char*)rq->ifr_data + sizeof(length);
ret = ar6000_htc_raw_read(ar, (HTC_RAW_STREAM_ID)streamID,
(char*)buffer, length);
put_user(ret, (unsigned int *)rq->ifr_data);
} else {
ret = A_ERROR;
}
break;
case AR6000_XIOCTL_HTC_RAW_WRITE:
if (arRawIfEnabled(ar)) {
unsigned int streamID;
get_user(streamID, (unsigned int *)userdata);
get_user(length, (unsigned int *)userdata + 1);
buffer = (unsigned char*)userdata + sizeof(streamID) + sizeof(length);
ret = ar6000_htc_raw_write(ar, (HTC_RAW_STREAM_ID)streamID,
(char*)buffer, length);
put_user(ret, (unsigned int *)rq->ifr_data);
} else {
ret = A_ERROR;
}
break;
#endif /* HTC_RAW_INTERFACE */
case AR6000_XIOCTL_BMI_LZ_STREAM_START:
get_user(address, (unsigned int *)userdata);
AR_DEBUG_PRINTF(ATH_DEBUG_INFO,("Start Compressed Stream (address: 0x%x)\n", address));
ret = BMILZStreamStart(hifDevice, address);
break;
case AR6000_XIOCTL_BMI_LZ_DATA:
get_user(length, (unsigned int *)userdata);
AR_DEBUG_PRINTF(ATH_DEBUG_INFO,("Send Compressed Data (length: %d)\n", length));
if ((buffer = (unsigned char *)A_MALLOC(length)) != NULL) {
A_MEMZERO(buffer, length);
if (copy_from_user(buffer, &userdata[sizeof(length)], length))
{
ret = -EFAULT;
} else {
ret = BMILZData(hifDevice, buffer, length);
}
A_FREE(buffer);
} else {
ret = -ENOMEM;
}
break;
#if defined(CONFIG_TARGET_PROFILE_SUPPORT)
/*
* Optional support for Target-side profiling.
* Not needed in production.
*/
/* Configure Target-side profiling */
case AR6000_XIOCTL_PROF_CFG:
{
A_UINT32 period;
A_UINT32 nbins;
get_user(period, (unsigned int *)userdata);
get_user(nbins, (unsigned int *)userdata + 1);
if (wmi_prof_cfg_cmd(ar->arWmi, period, nbins) != A_OK) {
ret = -EIO;
}
break;
}
/* Start a profiling bucket/bin at the specified address */
case AR6000_XIOCTL_PROF_ADDR_SET:
{
A_UINT32 addr;
get_user(addr, (unsigned int *)userdata);
if (wmi_prof_addr_set_cmd(ar->arWmi, addr) != A_OK) {
ret = -EIO;
}
break;
}
/* START Target-side profiling */
case AR6000_XIOCTL_PROF_START:
wmi_prof_start_cmd(ar->arWmi);
break;
/* STOP Target-side profiling */
case AR6000_XIOCTL_PROF_STOP:
wmi_prof_stop_cmd(ar->arWmi);
break;
case AR6000_XIOCTL_PROF_COUNT_GET:
{
if (ar->bIsDestroyProgress) {
ret = -EBUSY;
goto ioctl_done;
}
if (ar->arWmiReady == FALSE) {
ret = -EIO;
goto ioctl_done;
}
if (down_interruptible(&ar->arSem)) {
ret = -ERESTARTSYS;
goto ioctl_done;
}
if (ar->bIsDestroyProgress) {
up(&ar->arSem);
ret = -EBUSY;
goto ioctl_done;
}
prof_count_available = FALSE;
ret = prof_count_get(dev);
if (ret != A_OK) {
up(&ar->arSem);
ret = -EIO;
goto ioctl_done;
}
/* Wait for Target to respond. */
wait_event_interruptible(arEvent, prof_count_available);
if (signal_pending(current)) {
ret = -EINTR;
} else {
if (copy_to_user(userdata, &prof_count_results,
sizeof(prof_count_results)))
{
ret = -EFAULT;
}
}
up(&ar->arSem);
break;
}
#endif /* CONFIG_TARGET_PROFILE_SUPPORT */
case AR6000_IOCTL_WMI_GETREV:
{
if (copy_to_user(rq->ifr_data, &ar->arVersion,
sizeof(ar->arVersion)))
{
ret = -EFAULT;
}
break;
}
case AR6000_IOCTL_WMI_SETPWR:
{
WMI_POWER_MODE_CMD pwrModeCmd;
if (ar->arWmiReady == FALSE) {
ret = -EIO;
} else if (copy_from_user(&pwrModeCmd, userdata,
sizeof(pwrModeCmd)))
{
ret = -EFAULT;
} else {
if (wmi_powermode_cmd(ar->arWmi, pwrModeCmd.powerMode)
!= A_OK)
{
ret = -EIO;
}
}
break;
}
case AR6000_IOCTL_WMI_SET_IBSS_PM_CAPS:
{
WMI_IBSS_PM_CAPS_CMD ibssPmCaps;
if (ar->arWmiReady == FALSE) {
ret = -EIO;
} else if (copy_from_user(&ibssPmCaps, userdata,
sizeof(ibssPmCaps)))
{
ret = -EFAULT;
} else {
if (wmi_ibsspmcaps_cmd(ar->arWmi, ibssPmCaps.power_saving, ibssPmCaps.ttl,
ibssPmCaps.atim_windows, ibssPmCaps.timeout_value) != A_OK)
{
ret = -EIO;
}
AR6000_SPIN_LOCK(&ar->arLock, 0);
ar->arIbssPsEnable = ibssPmCaps.power_saving;
AR6000_SPIN_UNLOCK(&ar->arLock, 0);
}
break;
}
case AR6000_XIOCTL_WMI_SET_AP_PS:
{
WMI_AP_PS_CMD apPsCmd;
if (ar->arWmiReady == FALSE) {
ret = -EIO;
} else if (copy_from_user(&apPsCmd, userdata,
sizeof(apPsCmd)))
{
ret = -EFAULT;
} else {
if (wmi_apps_cmd(ar->arWmi, apPsCmd.psType, apPsCmd.idle_time,
apPsCmd.ps_period, apPsCmd.sleep_period) != A_OK)
{
ret = -EIO;
}
}
break;
}
case AR6000_IOCTL_WMI_SET_PMPARAMS:
{
WMI_POWER_PARAMS_CMD pmParams;
if (ar->arWmiReady == FALSE) {
ret = -EIO;
} else if (copy_from_user(&pmParams, userdata,
sizeof(pmParams)))
{
ret = -EFAULT;
} else {
if (wmi_pmparams_cmd(ar->arWmi, pmParams.idle_period,
pmParams.pspoll_number,
pmParams.dtim_policy,
pmParams.tx_wakeup_policy,
pmParams.num_tx_to_wakeup,
#if WLAN_CONFIG_IGNORE_POWER_SAVE_FAIL_EVENT_DURING_SCAN
IGNORE_POWER_SAVE_FAIL_EVENT_DURING_SCAN
#else
SEND_POWER_SAVE_FAIL_EVENT_ALWAYS
#endif
) != A_OK)
{
ret = -EIO;
}
}
break;
}
case AR6000_IOCTL_WMI_SETSCAN:
{
if (ar->arWmiReady == FALSE) {
ret = -EIO;
} else if (copy_from_user(&ar->scParams, userdata,
sizeof(ar->scParams)))
{
ret = -EFAULT;
} else {
if (CAN_SCAN_IN_CONNECT(ar->scParams.scanCtrlFlags)) {
ar->arSkipScan = FALSE;
} else {
ar->arSkipScan = TRUE;
}
if (wmi_scanparams_cmd(ar->arWmi, ar->scParams.fg_start_period,
ar->scParams.fg_end_period,
ar->scParams.bg_period,
ar->scParams.minact_chdwell_time,
ar->scParams.maxact_chdwell_time,
ar->scParams.pas_chdwell_time,
ar->scParams.shortScanRatio,
ar->scParams.scanCtrlFlags,
ar->scParams.max_dfsch_act_time,
ar->scParams.maxact_scan_per_ssid) != A_OK)
{
ret = -EIO;
}
}
break;
}
case AR6000_IOCTL_WMI_SETLISTENINT:
{
WMI_LISTEN_INT_CMD listenCmd;
if (ar->arWmiReady == FALSE) {
ret = -EIO;
} else if (copy_from_user(&listenCmd, userdata,
sizeof(listenCmd)))
{
ret = -EFAULT;
} else {
if (wmi_listeninterval_cmd(ar->arWmi, listenCmd.listenInterval, listenCmd.numBeacons) != A_OK) {
ret = -EIO;
} else {
AR6000_SPIN_LOCK(&ar->arLock, 0);
ar->arListenIntervalT = listenCmd.listenInterval;
ar->arListenIntervalB = listenCmd.numBeacons;
AR6000_SPIN_UNLOCK(&ar->arLock, 0);
}
}
break;
}
case AR6000_IOCTL_WMI_SET_BMISS_TIME:
{
WMI_BMISS_TIME_CMD bmissCmd;
if (ar->arWmiReady == FALSE) {
ret = -EIO;
} else if (copy_from_user(&bmissCmd, userdata,
sizeof(bmissCmd)))
{
ret = -EFAULT;
} else {
if (wmi_bmisstime_cmd(ar->arWmi, bmissCmd.bmissTime, bmissCmd.numBeacons) != A_OK) {
ret = -EIO;
}
}
break;
}
case AR6000_IOCTL_WMI_SETBSSFILTER:
{
WMI_BSS_FILTER_CMD filt;
if (ar->arWmiReady == FALSE) {
ret = -EIO;
} else if (copy_from_user(&filt, userdata,
sizeof(filt)))
{
ret = -EFAULT;
} else {
if (wmi_bssfilter_cmd(ar->arWmi, filt.bssFilter, filt.ieMask)
!= A_OK) {
ret = -EIO;
} else {
ar->arUserBssFilter = param;
}
}
break;
}
case AR6000_IOCTL_WMI_SET_SNRTHRESHOLD:
{
ret = ar6000_ioctl_set_snr_threshold(dev, rq);
break;
}
case AR6000_XIOCTL_WMI_SET_RSSITHRESHOLD:
{
ret = ar6000_ioctl_set_rssi_threshold(dev, rq);
break;
}
case AR6000_XIOCTL_WMI_CLR_RSSISNR:
{
if (ar->arWmiReady == FALSE) {
ret = -EIO;
}
ret = wmi_clr_rssi_snr(ar->arWmi);
break;
}
case AR6000_XIOCTL_WMI_SET_LQTHRESHOLD:
{
ret = ar6000_ioctl_set_lq_threshold(dev, rq);
break;
}
case AR6000_XIOCTL_WMI_SET_LPREAMBLE:
{
WMI_SET_LPREAMBLE_CMD setLpreambleCmd;
if (ar->arWmiReady == FALSE) {
ret = -EIO;
} else if (copy_from_user(&setLpreambleCmd, userdata,
sizeof(setLpreambleCmd)))
{
ret = -EFAULT;
} else {
if (wmi_set_lpreamble_cmd(ar->arWmi, setLpreambleCmd.status,
#if WLAN_CONFIG_DONOT_IGNORE_BARKER_IN_ERP
WMI_DONOT_IGNORE_BARKER_IN_ERP
#else
WMI_IGNORE_BARKER_IN_ERP
#endif
) != A_OK)
{
ret = -EIO;
}
}
break;
}
case AR6000_XIOCTL_WMI_SET_RTS:
{
WMI_SET_RTS_CMD rtsCmd;
if (ar->arWmiReady == FALSE) {
ret = -EIO;
} else if (copy_from_user(&rtsCmd, userdata,
sizeof(rtsCmd)))
{
ret = -EFAULT;
} else {
ar->arRTS = rtsCmd.threshold;
if (wmi_set_rts_cmd(ar->arWmi, rtsCmd.threshold)
!= A_OK)
{
ret = -EIO;
}
}
break;
}
case AR6000_XIOCTL_WMI_SET_WMM:
{
ret = ar6000_ioctl_set_wmm(dev, rq);
break;
}
case AR6000_XIOCTL_WMI_SET_QOS_SUPP:
{
ret = ar6000_ioctl_set_qos_supp(dev, rq);
break;
}
case AR6000_XIOCTL_WMI_SET_TXOP:
{
ret = ar6000_ioctl_set_txop(dev, rq);
break;
}
case AR6000_XIOCTL_WMI_GET_RD:
{
ret = ar6000_ioctl_get_rd(dev, rq);
break;
}
case AR6000_IOCTL_WMI_SET_CHANNELPARAMS:
{
ret = ar6000_ioctl_set_channelParams(dev, rq);
break;
}
case AR6000_IOCTL_WMI_SET_PROBEDSSID:
{
ret = ar6000_ioctl_set_probedSsid(dev, rq);
break;
}
case AR6000_IOCTL_WMI_SET_BADAP:
{
ret = ar6000_ioctl_set_badAp(dev, rq);
break;
}
case AR6000_IOCTL_WMI_CREATE_QOS:
{
ret = ar6000_ioctl_create_qos(dev, rq);
break;
}
case AR6000_IOCTL_WMI_DELETE_QOS:
{
ret = ar6000_ioctl_delete_qos(dev, rq);
break;
}
case AR6000_IOCTL_WMI_GET_QOS_QUEUE:
{
ret = ar6000_ioctl_get_qos_queue(dev, rq);
break;
}
case AR6000_IOCTL_WMI_GET_TARGET_STATS:
{
ret = ar6000_ioctl_get_target_stats(dev, rq);
break;
}
case AR6000_IOCTL_WMI_SET_ERROR_REPORT_BITMASK:
{
ret = ar6000_ioctl_set_error_report_bitmask(dev, rq);
break;
}
case AR6000_IOCTL_WMI_SET_ASSOC_INFO:
{
WMI_SET_ASSOC_INFO_CMD cmd;
A_UINT8 assocInfo[WMI_MAX_ASSOC_INFO_LEN];
if (ar->arWmiReady == FALSE) {
ret = -EIO;
} else {
get_user(cmd.ieType, userdata);
if (cmd.ieType >= WMI_MAX_ASSOC_INFO_TYPE) {
ret = -EIO;
} else {
get_user(cmd.bufferSize, userdata + 1);
if (cmd.bufferSize > WMI_MAX_ASSOC_INFO_LEN) {
ret = -EFAULT;
break;
}
if (copy_from_user(assocInfo, userdata + 2,
cmd.bufferSize))
{
ret = -EFAULT;
} else {
if (wmi_associnfo_cmd(ar->arWmi, cmd.ieType,
cmd.bufferSize,
assocInfo) != A_OK)
{
ret = -EIO;
}
}
}
}
break;
}
case AR6000_IOCTL_WMI_SET_ACCESS_PARAMS:
{
ret = ar6000_ioctl_set_access_params(dev, rq);
break;
}
case AR6000_IOCTL_WMI_SET_DISC_TIMEOUT:
{
ret = ar6000_ioctl_set_disconnect_timeout(dev, rq);
break;
}
case AR6000_XIOCTL_FORCE_TARGET_RESET:
{
if (ar->arHtcTarget)
{
// HTCForceReset(htcTarget);
}
else
{
AR_DEBUG_PRINTF(ATH_DEBUG_WARN,("ar6000_ioctl cannot attempt reset.\n"));
}
break;
}
case AR6000_XIOCTL_TARGET_INFO:
case AR6000_XIOCTL_CHECK_TARGET_READY: /* backwards compatibility */
{
/* If we made it to here, then the Target exists and is ready. */
if (cmd == AR6000_XIOCTL_TARGET_INFO) {
if (copy_to_user((A_UINT32 *)rq->ifr_data, &ar->arVersion.target_ver,
sizeof(ar->arVersion.target_ver)))
{
ret = -EFAULT;
}
if (copy_to_user(((A_UINT32 *)rq->ifr_data)+1, &ar->arTargetType,
sizeof(ar->arTargetType)))
{
ret = -EFAULT;
}
}
break;
}
case AR6000_XIOCTL_WMI_SET_HB_CHALLENGE_RESP_PARAMS:
{
WMI_SET_HB_CHALLENGE_RESP_PARAMS_CMD hbparam;
if (copy_from_user(&hbparam, userdata, sizeof(hbparam)))
{
ret = -EFAULT;
} else {
AR6000_SPIN_LOCK(&ar->arLock, 0);
/* Start a cyclic timer with the parameters provided. */
if (hbparam.frequency) {
ar->arHBChallengeResp.frequency = hbparam.frequency;
}
if (hbparam.threshold) {
ar->arHBChallengeResp.missThres = hbparam.threshold;
}
/* Delete the pending timer and start a new one */
if (timer_pending(&ar->arHBChallengeResp.timer)) {
A_UNTIMEOUT(&ar->arHBChallengeResp.timer);
}
A_TIMEOUT_MS(&ar->arHBChallengeResp.timer, ar->arHBChallengeResp.frequency * 1000, 0);
AR6000_SPIN_UNLOCK(&ar->arLock, 0);
}
break;
}
case AR6000_XIOCTL_WMI_GET_HB_CHALLENGE_RESP:
{
A_UINT32 cookie;
if (copy_from_user(&cookie, userdata, sizeof(cookie))) {
ret = -EFAULT;
goto ioctl_done;
}
/* Send the challenge on the control channel */
if (wmi_get_challenge_resp_cmd(ar->arWmi, cookie, APP_HB_CHALLENGE) != A_OK) {
ret = -EIO;
goto ioctl_done;
}
break;
}
#ifdef USER_KEYS
case AR6000_XIOCTL_USER_SETKEYS:
{
ar->user_savedkeys_stat = USER_SAVEDKEYS_STAT_RUN;
if (copy_from_user(&ar->user_key_ctrl, userdata,
sizeof(ar->user_key_ctrl)))
{
ret = -EFAULT;
goto ioctl_done;
}
A_PRINTF("ar6000 USER set key %x\n", ar->user_key_ctrl);
break;
}
#endif /* USER_KEYS */
#ifdef CONFIG_HOST_GPIO_SUPPORT
case AR6000_XIOCTL_GPIO_OUTPUT_SET:
{
struct ar6000_gpio_output_set_cmd_s gpio_output_set_cmd;
if (ar->bIsDestroyProgress) {
ret = -EBUSY;
goto ioctl_done;
}
if (ar->arWmiReady == FALSE) {
ret = -EIO;
goto ioctl_done;
}
if (down_interruptible(&ar->arSem)) {
ret = -ERESTARTSYS;
goto ioctl_done;
}
if (ar->bIsDestroyProgress) {
up(&ar->arSem);
ret = -EBUSY;
goto ioctl_done;
}
if (copy_from_user(&gpio_output_set_cmd, userdata,
sizeof(gpio_output_set_cmd)))
{
ret = -EFAULT;
} else {
ret = ar6000_gpio_output_set(dev,
gpio_output_set_cmd.set_mask,
gpio_output_set_cmd.clear_mask,
gpio_output_set_cmd.enable_mask,
gpio_output_set_cmd.disable_mask);
if (ret != A_OK) {
ret = EIO;
}
}
up(&ar->arSem);
break;
}
case AR6000_XIOCTL_GPIO_INPUT_GET:
{
if (ar->bIsDestroyProgress) {
ret = -EBUSY;
goto ioctl_done;
}
if (ar->arWmiReady == FALSE) {
ret = -EIO;
goto ioctl_done;
}
if (down_interruptible(&ar->arSem)) {
ret = -ERESTARTSYS;
goto ioctl_done;
}
if (ar->bIsDestroyProgress) {
up(&ar->arSem);
ret = -EBUSY;
goto ioctl_done;
}
ret = ar6000_gpio_input_get(dev);
if (ret != A_OK) {
up(&ar->arSem);
ret = -EIO;
goto ioctl_done;
}
/* Wait for Target to respond. */
wait_event_interruptible(arEvent, gpio_data_available);
if (signal_pending(current)) {
ret = -EINTR;
} else {
A_ASSERT(gpio_reg_results.gpioreg_id == GPIO_ID_NONE);
if (copy_to_user(userdata, &gpio_reg_results.value,
sizeof(gpio_reg_results.value)))
{
ret = -EFAULT;
}
}
up(&ar->arSem);
break;
}
case AR6000_XIOCTL_GPIO_REGISTER_SET:
{
struct ar6000_gpio_register_cmd_s gpio_register_cmd;
if (ar->bIsDestroyProgress) {
ret = -EBUSY;
goto ioctl_done;
}
if (ar->arWmiReady == FALSE) {
ret = -EIO;
goto ioctl_done;
}
if (down_interruptible(&ar->arSem)) {
ret = -ERESTARTSYS;
goto ioctl_done;
}
if (ar->bIsDestroyProgress) {
up(&ar->arSem);
ret = -EBUSY;
goto ioctl_done;
}
if (copy_from_user(&gpio_register_cmd, userdata,
sizeof(gpio_register_cmd)))
{
ret = -EFAULT;
} else {
ret = ar6000_gpio_register_set(dev,
gpio_register_cmd.gpioreg_id,
gpio_register_cmd.value);
if (ret != A_OK) {
ret = EIO;
}
/* Wait for acknowledgement from Target */
wait_event_interruptible(arEvent, gpio_ack_received);
if (signal_pending(current)) {
ret = -EINTR;
}
}
up(&ar->arSem);
break;
}
case AR6000_XIOCTL_GPIO_REGISTER_GET:
{
struct ar6000_gpio_register_cmd_s gpio_register_cmd;
if (ar->bIsDestroyProgress) {
ret = -EBUSY;
goto ioctl_done;
}
if (ar->arWmiReady == FALSE) {
ret = -EIO;
goto ioctl_done;
}
if (down_interruptible(&ar->arSem)) {
ret = -ERESTARTSYS;
goto ioctl_done;
}
if (ar->bIsDestroyProgress) {
up(&ar->arSem);
ret = -EBUSY;
goto ioctl_done;
}
if (copy_from_user(&gpio_register_cmd, userdata,
sizeof(gpio_register_cmd)))
{
ret = -EFAULT;
} else {
ret = ar6000_gpio_register_get(dev, gpio_register_cmd.gpioreg_id);
if (ret != A_OK) {
up(&ar->arSem);
ret = -EIO;
goto ioctl_done;
}
/* Wait for Target to respond. */
wait_event_interruptible(arEvent, gpio_data_available);
if (signal_pending(current)) {
ret = -EINTR;
} else {
A_ASSERT(gpio_register_cmd.gpioreg_id == gpio_reg_results.gpioreg_id);
if (copy_to_user(userdata, &gpio_reg_results,
sizeof(gpio_reg_results)))
{
ret = -EFAULT;
}
}
}
up(&ar->arSem);
break;
}
case AR6000_XIOCTL_GPIO_INTR_ACK:
{
struct ar6000_gpio_intr_ack_cmd_s gpio_intr_ack_cmd;
if (ar->bIsDestroyProgress) {
ret = -EBUSY;
goto ioctl_done;
}
if (ar->arWmiReady == FALSE) {
ret = -EIO;
goto ioctl_done;
}
if (down_interruptible(&ar->arSem)) {
ret = -ERESTARTSYS;
goto ioctl_done;
}
if (ar->bIsDestroyProgress) {
up(&ar->arSem);
ret = -EBUSY;
goto ioctl_done;
}
if (copy_from_user(&gpio_intr_ack_cmd, userdata,
sizeof(gpio_intr_ack_cmd)))
{
ret = -EFAULT;
} else {
ret = ar6000_gpio_intr_ack(dev, gpio_intr_ack_cmd.ack_mask);
if (ret != A_OK) {
ret = EIO;
}
}
up(&ar->arSem);
break;
}
case AR6000_XIOCTL_GPIO_INTR_WAIT:
{
/* Wait for Target to report an interrupt. */
wait_event_interruptible(arEvent, gpio_intr_available);
if (signal_pending(current)) {
ret = -EINTR;
} else {
if (copy_to_user(userdata, &gpio_intr_results,
sizeof(gpio_intr_results)))
{
ret = -EFAULT;
}
}
break;
}
#endif /* CONFIG_HOST_GPIO_SUPPORT */
case AR6000_XIOCTL_DBGLOG_CFG_MODULE:
{
struct ar6000_dbglog_module_config_s config;
if (copy_from_user(&config, userdata, sizeof(config))) {
ret = -EFAULT;
goto ioctl_done;
}
/* Send the challenge on the control channel */
if (wmi_config_debug_module_cmd(ar->arWmi, config.mmask,
config.tsr, config.rep,
config.size, config.valid) != A_OK)
{
ret = -EIO;
goto ioctl_done;
}
break;
}
case AR6000_XIOCTL_DBGLOG_GET_DEBUG_LOGS:
{
/* Send the challenge on the control channel */
if (ar6000_dbglog_get_debug_logs(ar) != A_OK)
{
ret = -EIO;
goto ioctl_done;
}
break;
}
case AR6000_XIOCTL_SET_ADHOC_BSSID:
{
WMI_SET_ADHOC_BSSID_CMD adhocBssid;
if (ar->arWmiReady == FALSE) {
ret = -EIO;
} else if (copy_from_user(&adhocBssid, userdata,
sizeof(adhocBssid)))
{
ret = -EFAULT;
} else if (A_MEMCMP(adhocBssid.bssid, bcast_mac,
AR6000_ETH_ADDR_LEN) == 0)
{
ret = -EFAULT;
} else {
A_MEMCPY(ar->arReqBssid, adhocBssid.bssid, sizeof(ar->arReqBssid));
}
break;
}
case AR6000_XIOCTL_SET_OPT_MODE:
{
WMI_SET_OPT_MODE_CMD optModeCmd;
AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
if (ar->arWmiReady == FALSE) {
ret = -EIO;
} else if (copy_from_user(&optModeCmd, userdata,
sizeof(optModeCmd)))
{
ret = -EFAULT;
} else if (ar->arConnected && optModeCmd.optMode == SPECIAL_ON) {
ret = -EFAULT;
} else if (wmi_set_opt_mode_cmd(ar->arWmi, optModeCmd.optMode)
!= A_OK)
{
ret = -EIO;
}
break;
}
case AR6000_XIOCTL_OPT_SEND_FRAME:
{
WMI_OPT_TX_FRAME_CMD optTxFrmCmd;
A_UINT8 data[MAX_OPT_DATA_LEN];
if (ar->arWmiReady == FALSE) {
ret = -EIO;
} else if (copy_from_user(&optTxFrmCmd, userdata,
sizeof(optTxFrmCmd)))
{
ret = -EFAULT;
} else if (copy_from_user(data,
userdata+sizeof(WMI_OPT_TX_FRAME_CMD)-1,
optTxFrmCmd.optIEDataLen))
{
ret = -EFAULT;
} else {
ret = wmi_opt_tx_frame_cmd(ar->arWmi,
optTxFrmCmd.frmType,
optTxFrmCmd.dstAddr,
optTxFrmCmd.bssid,
optTxFrmCmd.optIEDataLen,
data);
}
break;
}
case AR6000_XIOCTL_WMI_SETRETRYLIMITS:
{
WMI_SET_RETRY_LIMITS_CMD setRetryParams;
if (ar->arWmiReady == FALSE) {
ret = -EIO;
} else if (copy_from_user(&setRetryParams, userdata,
sizeof(setRetryParams)))
{
ret = -EFAULT;
} else {
if (wmi_set_retry_limits_cmd(ar->arWmi, setRetryParams.frameType,
setRetryParams.trafficClass,
setRetryParams.maxRetries,
setRetryParams.enableNotify) != A_OK)
{
ret = -EIO;
}
AR6000_SPIN_LOCK(&ar->arLock, 0);
ar->arMaxRetries = setRetryParams.maxRetries;
AR6000_SPIN_UNLOCK(&ar->arLock, 0);
}
break;
}
case AR6000_XIOCTL_SET_BEACON_INTVAL:
{
WMI_BEACON_INT_CMD bIntvlCmd;
if (ar->arWmiReady == FALSE) {
ret = -EIO;
} else if (copy_from_user(&bIntvlCmd, userdata,
sizeof(bIntvlCmd)))
{
ret = -EFAULT;
} else if (wmi_set_adhoc_bconIntvl_cmd(ar->arWmi, bIntvlCmd.beaconInterval)
!= A_OK)
{
ret = -EIO;
}
if(ret == 0) {
ar->ap_beacon_interval = bIntvlCmd.beaconInterval;
ar->ap_profile_flag = 1; /* There is a change in profile */
}
break;
}
case IEEE80211_IOCTL_SETAUTHALG:
{
AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
struct ieee80211req_authalg req;
if (ar->arWmiReady == FALSE) {
ret = -EIO;
} else if (copy_from_user(&req, userdata,
sizeof(struct ieee80211req_authalg)))
{
ret = -EFAULT;
} else {
if (req.auth_alg & AUTH_ALG_OPEN_SYSTEM) {
ar->arDot11AuthMode |= OPEN_AUTH;
ar->arPairwiseCrypto = NONE_CRYPT;
ar->arGroupCrypto = NONE_CRYPT;
}
if (req.auth_alg & AUTH_ALG_SHARED_KEY) {
ar->arDot11AuthMode |= SHARED_AUTH;
ar->arPairwiseCrypto = WEP_CRYPT;
ar->arGroupCrypto = WEP_CRYPT;
ar->arAuthMode = NONE_AUTH;
}
if (req.auth_alg == AUTH_ALG_LEAP) {
ar->arDot11AuthMode = LEAP_AUTH;
}
}
break;
}
case AR6000_XIOCTL_SET_VOICE_PKT_SIZE:
ret = ar6000_xioctl_set_voice_pkt_size(dev, userdata);
break;
case AR6000_XIOCTL_SET_MAX_SP:
ret = ar6000_xioctl_set_max_sp_len(dev, userdata);
break;
case AR6000_XIOCTL_WMI_GET_ROAM_TBL:
ret = ar6000_ioctl_get_roam_tbl(dev, rq);
break;
case AR6000_XIOCTL_WMI_SET_ROAM_CTRL:
ret = ar6000_ioctl_set_roam_ctrl(dev, userdata);
break;
case AR6000_XIOCTRL_WMI_SET_POWERSAVE_TIMERS:
ret = ar6000_ioctl_set_powersave_timers(dev, userdata);
break;
case AR6000_XIOCTRL_WMI_GET_POWER_MODE:
ret = ar6000_ioctl_get_power_mode(dev, rq);
break;
case AR6000_XIOCTRL_WMI_SET_WLAN_STATE:
{
AR6000_WLAN_STATE state;
get_user(state, (unsigned int *)userdata);
if (ar6000_set_wlan_state(ar, state)!=A_OK) {
ret = -EIO;
}
break;
}
case AR6000_XIOCTL_WMI_GET_ROAM_DATA:
ret = ar6000_ioctl_get_roam_data(dev, rq);
break;
case AR6000_XIOCTL_WMI_SET_BT_STATUS:
ret = ar6000_xioctl_set_bt_status_cmd(dev, userdata);
break;
case AR6000_XIOCTL_WMI_SET_BT_PARAMS:
ret = ar6000_xioctl_set_bt_params_cmd(dev, userdata);
break;
case AR6000_XIOCTL_WMI_SET_BTCOEX_FE_ANT:
ret = ar6000_xioctl_set_btcoex_fe_ant_cmd(dev, userdata);
break;
case AR6000_XIOCTL_WMI_SET_BTCOEX_COLOCATED_BT_DEV:
ret = ar6000_xioctl_set_btcoex_colocated_bt_dev_cmd(dev, userdata);
break;
case AR6000_XIOCTL_WMI_SET_BTCOEX_BTINQUIRY_PAGE_CONFIG:
ret = ar6000_xioctl_set_btcoex_btinquiry_page_config_cmd(dev, userdata);
break;
case AR6000_XIOCTL_WMI_SET_BTCOEX_SCO_CONFIG:
ret = ar6000_xioctl_set_btcoex_sco_config_cmd( dev, userdata);
break;
case AR6000_XIOCTL_WMI_SET_BTCOEX_A2DP_CONFIG:
ret = ar6000_xioctl_set_btcoex_a2dp_config_cmd(dev, userdata);
break;
case AR6000_XIOCTL_WMI_SET_BTCOEX_ACLCOEX_CONFIG:
ret = ar6000_xioctl_set_btcoex_aclcoex_config_cmd(dev, userdata);
break;
case AR6000_XIOCTL_WMI_SET_BTCOEX_DEBUG:
ret = ar60000_xioctl_set_btcoex_debug_cmd(dev, userdata);
break;
case AR6000_XIOCTL_WMI_SET_BT_OPERATING_STATUS:
ret = ar6000_xioctl_set_btcoex_bt_operating_status_cmd(dev, userdata);
break;
case AR6000_XIOCTL_WMI_GET_BTCOEX_CONFIG:
ret = ar6000_xioctl_get_btcoex_config_cmd(dev, userdata, rq);
break;
case AR6000_XIOCTL_WMI_GET_BTCOEX_STATS:
ret = ar6000_xioctl_get_btcoex_stats_cmd(dev, userdata, rq);
break;
case AR6000_XIOCTL_WMI_STARTSCAN:
{
WMI_START_SCAN_CMD setStartScanCmd, *cmdp;
if (ar->arWmiReady == FALSE) {
ret = -EIO;
} else if (copy_from_user(&setStartScanCmd, userdata,
sizeof(setStartScanCmd)))
{
ret = -EFAULT;
} else {
if (setStartScanCmd.numChannels > 1) {
cmdp = A_MALLOC(130);
if (copy_from_user(cmdp, userdata,
sizeof (*cmdp) +
((setStartScanCmd.numChannels - 1) *
sizeof(A_UINT16))))
{
kfree(cmdp);
ret = -EFAULT;
goto ioctl_done;
}
} else {
cmdp = &setStartScanCmd;
}
if (wmi_startscan_cmd(ar->arWmi, cmdp->scanType,
cmdp->forceFgScan,
cmdp->isLegacy,
cmdp->homeDwellTime,
cmdp->forceScanInterval,
cmdp->numChannels,
cmdp->channelList) != A_OK)
{
ret = -EIO;
}
}
break;
}
case AR6000_XIOCTL_WMI_SETFIXRATES:
{
WMI_FIX_RATES_CMD setFixRatesCmd;
A_STATUS returnStatus;
if (ar->arWmiReady == FALSE) {
ret = -EIO;
} else if (copy_from_user(&setFixRatesCmd, userdata,
sizeof(setFixRatesCmd)))
{
ret = -EFAULT;
} else {
returnStatus = wmi_set_fixrates_cmd(ar->arWmi, setFixRatesCmd.fixRateMask);
if (returnStatus == A_EINVAL) {
ret = -EINVAL;
} else if(returnStatus != A_OK) {
ret = -EIO;
} else {
ar->ap_profile_flag = 1; /* There is a change in profile */
}
}
break;
}
case AR6000_XIOCTL_WMI_GETFIXRATES:
{
WMI_FIX_RATES_CMD getFixRatesCmd;
AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
int ret = 0;
if (ar->bIsDestroyProgress) {
ret = -EBUSY;
goto ioctl_done;
}
if (ar->arWmiReady == FALSE) {
ret = -EIO;
goto ioctl_done;
}
if (down_interruptible(&ar->arSem)) {
ret = -ERESTARTSYS;
goto ioctl_done;
}
if (ar->bIsDestroyProgress) {
up(&ar->arSem);
ret = -EBUSY;
goto ioctl_done;
}
/* Used copy_from_user/copy_to_user to access user space data */
if (copy_from_user(&getFixRatesCmd, userdata, sizeof(getFixRatesCmd))) {
ret = -EFAULT;
} else {
ar->arRateMask = 0xFFFFFFFF;
if (wmi_get_ratemask_cmd(ar->arWmi) != A_OK) {
up(&ar->arSem);
ret = -EIO;
goto ioctl_done;
}
wait_event_interruptible_timeout(arEvent, ar->arRateMask != 0xFFFFFFFF, wmitimeout * HZ);
if (signal_pending(current)) {
ret = -EINTR;
}
if (!ret) {
getFixRatesCmd.fixRateMask = ar->arRateMask;
}
if(copy_to_user(userdata, &getFixRatesCmd, sizeof(getFixRatesCmd))) {
ret = -EFAULT;
}
up(&ar->arSem);
}
break;
}
case AR6000_XIOCTL_WMI_SET_AUTHMODE:
{
WMI_SET_AUTH_MODE_CMD setAuthMode;
if (ar->arWmiReady == FALSE) {
ret = -EIO;
} else if (copy_from_user(&setAuthMode, userdata,
sizeof(setAuthMode)))
{
ret = -EFAULT;
} else {
if (wmi_set_authmode_cmd(ar->arWmi, setAuthMode.mode) != A_OK)
{
ret = -EIO;
}
}
break;
}
case AR6000_XIOCTL_WMI_SET_REASSOCMODE:
{
WMI_SET_REASSOC_MODE_CMD setReassocMode;
if (ar->arWmiReady == FALSE) {
ret = -EIO;
} else if (copy_from_user(&setReassocMode, userdata,
sizeof(setReassocMode)))
{
ret = -EFAULT;
} else {
if (wmi_set_reassocmode_cmd(ar->arWmi, setReassocMode.mode) != A_OK)
{
ret = -EIO;
}
}
break;
}
case AR6000_XIOCTL_DIAG_READ:
{
A_UINT32 addr, data;
get_user(addr, (unsigned int *)userdata);
addr = TARG_VTOP(ar->arTargetType, addr);
if (ar6000_ReadRegDiag(ar->arHifDevice, &addr, &data) != A_OK) {
ret = -EIO;
}
put_user(data, (unsigned int *)userdata + 1);
break;
}
case AR6000_XIOCTL_DIAG_WRITE:
{
A_UINT32 addr, data;
get_user(addr, (unsigned int *)userdata);
get_user(data, (unsigned int *)userdata + 1);
addr = TARG_VTOP(ar->arTargetType, addr);
if (ar6000_WriteRegDiag(ar->arHifDevice, &addr, &data) != A_OK) {
ret = -EIO;
}
break;
}
case AR6000_XIOCTL_WMI_SET_KEEPALIVE:
{
WMI_SET_KEEPALIVE_CMD setKeepAlive;
if (ar->arWmiReady == FALSE) {
ret = -EIO;
goto ioctl_done;
} else if (copy_from_user(&setKeepAlive, userdata,
sizeof(setKeepAlive))){
ret = -EFAULT;
} else {
if (wmi_set_keepalive_cmd(ar->arWmi, setKeepAlive.keepaliveInterval) != A_OK) {
ret = -EIO;
}
}
break;
}
case AR6000_XIOCTL_WMI_SET_PARAMS:
{
WMI_SET_PARAMS_CMD cmd;
if (ar->arWmiReady == FALSE) {
ret = -EIO;
goto ioctl_done;
} else if (copy_from_user(&cmd, userdata,
sizeof(cmd))){
ret = -EFAULT;
} else if (copy_from_user(&cmd, userdata,
sizeof(cmd) + cmd.length))
{
ret = -EFAULT;
} else {
if (wmi_set_params_cmd(ar->arWmi, cmd.opcode, cmd.length, cmd.buffer) != A_OK) {
ret = -EIO;
}
}
break;
}
case AR6000_XIOCTL_WMI_SET_MCAST_FILTER:
{
WMI_SET_MCAST_FILTER_CMD cmd;
if (ar->arWmiReady == FALSE) {
ret = -EIO;
goto ioctl_done;
} else if (copy_from_user(&cmd, userdata,
sizeof(cmd))){
ret = -EFAULT;
} else {
if (wmi_set_mcast_filter_cmd(ar->arWmi, cmd.multicast_mac[0],
cmd.multicast_mac[1],
cmd.multicast_mac[2],
cmd.multicast_mac[3]) != A_OK) {
ret = -EIO;
}
}
break;
}
case AR6000_XIOCTL_WMI_DEL_MCAST_FILTER:
{
WMI_SET_MCAST_FILTER_CMD cmd;
if (ar->arWmiReady == FALSE) {
ret = -EIO;
goto ioctl_done;
} else if (copy_from_user(&cmd, userdata,
sizeof(cmd))){
ret = -EFAULT;
} else {
if (wmi_del_mcast_filter_cmd(ar->arWmi, cmd.multicast_mac[0],
cmd.multicast_mac[1],
cmd.multicast_mac[2],
cmd.multicast_mac[3]) != A_OK) {
ret = -EIO;
}
}
break;
}
case AR6000_XIOCTL_WMI_MCAST_FILTER:
{
WMI_MCAST_FILTER_CMD cmd;
if (ar->arWmiReady == FALSE) {
ret = -EIO;
goto ioctl_done;
} else if (copy_from_user(&cmd, userdata,
sizeof(cmd))){
ret = -EFAULT;
} else {
if (wmi_mcast_filter_cmd(ar->arWmi, cmd.enable) != A_OK) {
ret = -EIO;
}
}
break;
}
case AR6000_XIOCTL_WMI_GET_KEEPALIVE:
{
AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
WMI_GET_KEEPALIVE_CMD getKeepAlive;
int ret = 0;
if (ar->bIsDestroyProgress) {
ret =-EBUSY;
goto ioctl_done;
}
if (ar->arWmiReady == FALSE) {
ret = -EIO;
goto ioctl_done;
}
if (down_interruptible(&ar->arSem)) {
ret = -ERESTARTSYS;
goto ioctl_done;
}
if (ar->bIsDestroyProgress) {
up(&ar->arSem);
ret = -EBUSY;
goto ioctl_done;
}
if (copy_from_user(&getKeepAlive, userdata,sizeof(getKeepAlive))) {
ret = -EFAULT;
} else {
getKeepAlive.keepaliveInterval = wmi_get_keepalive_cmd(ar->arWmi);
ar->arKeepaliveConfigured = 0xFF;
if (wmi_get_keepalive_configured(ar->arWmi) != A_OK){
up(&ar->arSem);
ret = -EIO;
goto ioctl_done;
}
wait_event_interruptible_timeout(arEvent, ar->arKeepaliveConfigured != 0xFF, wmitimeout * HZ);
if (signal_pending(current)) {
ret = -EINTR;
}
if (!ret) {
getKeepAlive.configured = ar->arKeepaliveConfigured;
}
if (copy_to_user(userdata, &getKeepAlive, sizeof(getKeepAlive))) {
ret = -EFAULT;
}
up(&ar->arSem);
}
break;
}
case AR6000_XIOCTL_WMI_SET_APPIE:
{
WMI_SET_APPIE_CMD appIEcmd;
A_UINT8 appIeInfo[IEEE80211_APPIE_FRAME_MAX_LEN];
A_UINT32 fType,ieLen;
if (ar->arWmiReady == FALSE) {
ret = -EIO;
goto ioctl_done;
}
get_user(fType, (A_UINT32 *)userdata);
appIEcmd.mgmtFrmType = fType;
if (appIEcmd.mgmtFrmType >= IEEE80211_APPIE_NUM_OF_FRAME) {
ret = -EIO;
} else {
get_user(ieLen, (A_UINT32 *)(userdata + 4));
appIEcmd.ieLen = ieLen;
A_PRINTF("WPSIE: Type-%d, Len-%d\n",appIEcmd.mgmtFrmType, appIEcmd.ieLen);
if (appIEcmd.ieLen > IEEE80211_APPIE_FRAME_MAX_LEN) {
ret = -EIO;
break;
}
if (copy_from_user(appIeInfo, userdata + 8, appIEcmd.ieLen)) {
ret = -EFAULT;
} else {
if (wmi_set_appie_cmd(ar->arWmi, appIEcmd.mgmtFrmType,
appIEcmd.ieLen, appIeInfo) != A_OK)
{
ret = -EIO;
}
}
}
break;
}
case AR6000_XIOCTL_WMI_SET_MGMT_FRM_RX_FILTER:
{
WMI_BSS_FILTER_CMD cmd;
A_UINT32 filterType;
if (copy_from_user(&filterType, userdata, sizeof(A_UINT32)))
{
ret = -EFAULT;
goto ioctl_done;
}
if (filterType & (IEEE80211_FILTER_TYPE_BEACON |
IEEE80211_FILTER_TYPE_PROBE_RESP))
{
cmd.bssFilter = ALL_BSS_FILTER;
} else {
cmd.bssFilter = NONE_BSS_FILTER;
}
if (wmi_bssfilter_cmd(ar->arWmi, cmd.bssFilter, 0) != A_OK) {
ret = -EIO;
} else {
ar->arUserBssFilter = cmd.bssFilter;
}
AR6000_SPIN_LOCK(&ar->arLock, 0);
ar->arMgmtFilter = filterType;
AR6000_SPIN_UNLOCK(&ar->arLock, 0);
break;
}
case AR6000_XIOCTL_WMI_SET_WSC_STATUS:
{
A_UINT32 wsc_status;
if (ar->arWmiReady == FALSE) {
ret = -EIO;
goto ioctl_done;
} else if (copy_from_user(&wsc_status, userdata, sizeof(A_UINT32)))
{
ret = -EFAULT;
goto ioctl_done;
}
if (wmi_set_wsc_status_cmd(ar->arWmi, wsc_status) != A_OK) {
ret = -EIO;
}
break;
}
case AR6000_XIOCTL_BMI_ROMPATCH_INSTALL:
{
A_UINT32 ROM_addr;
A_UINT32 RAM_addr;
A_UINT32 nbytes;
A_UINT32 do_activate;
A_UINT32 rompatch_id;
get_user(ROM_addr, (A_UINT32 *)userdata);
get_user(RAM_addr, (A_UINT32 *)userdata + 1);
get_user(nbytes, (A_UINT32 *)userdata + 2);
get_user(do_activate, (A_UINT32 *)userdata + 3);
AR_DEBUG_PRINTF(ATH_DEBUG_INFO,("Install rompatch from ROM: 0x%x to RAM: 0x%x length: %d\n",
ROM_addr, RAM_addr, nbytes));
ret = BMIrompatchInstall(hifDevice, ROM_addr, RAM_addr,
nbytes, do_activate, &rompatch_id);
if (ret == A_OK) {
put_user(rompatch_id, (unsigned int *)rq->ifr_data); /* return value */
}
break;
}
case AR6000_XIOCTL_BMI_ROMPATCH_UNINSTALL:
{
A_UINT32 rompatch_id;
get_user(rompatch_id, (A_UINT32 *)userdata);
AR_DEBUG_PRINTF(ATH_DEBUG_INFO,("UNinstall rompatch_id %d\n", rompatch_id));
ret = BMIrompatchUninstall(hifDevice, rompatch_id);
break;
}
case AR6000_XIOCTL_BMI_ROMPATCH_ACTIVATE:
case AR6000_XIOCTL_BMI_ROMPATCH_DEACTIVATE:
{
A_UINT32 rompatch_count;
get_user(rompatch_count, (A_UINT32 *)userdata);
AR_DEBUG_PRINTF(ATH_DEBUG_INFO,("Change rompatch activation count=%d\n", rompatch_count));
length = sizeof(A_UINT32) * rompatch_count;
if ((buffer = (unsigned char *)A_MALLOC(length)) != NULL) {
A_MEMZERO(buffer, length);
if (copy_from_user(buffer, &userdata[sizeof(rompatch_count)], length))
{
ret = -EFAULT;
} else {
if (cmd == AR6000_XIOCTL_BMI_ROMPATCH_ACTIVATE) {
ret = BMIrompatchActivate(hifDevice, rompatch_count, (A_UINT32 *)buffer);
} else {
ret = BMIrompatchDeactivate(hifDevice, rompatch_count, (A_UINT32 *)buffer);
}
}
A_FREE(buffer);
} else {
ret = -ENOMEM;
}
break;
}
case AR6000_XIOCTL_SET_IP:
{
WMI_SET_IP_CMD setIP;
if (ar->arWmiReady == FALSE) {
ret = -EIO;
} else if (copy_from_user(&setIP, userdata,
sizeof(setIP)))
{
ret = -EFAULT;
} else {
if (wmi_set_ip_cmd(ar->arWmi,
&setIP) != A_OK)
{
ret = -EIO;
}
}
break;
}
case AR6000_XIOCTL_WMI_SET_HOST_SLEEP_MODE:
{
WMI_SET_HOST_SLEEP_MODE_CMD setHostSleepMode;
if (ar->arWmiReady == FALSE) {
ret = -EIO;
} else if (copy_from_user(&setHostSleepMode, userdata,
sizeof(setHostSleepMode)))
{
ret = -EFAULT;
} else {
if (wmi_set_host_sleep_mode_cmd(ar->arWmi,
&setHostSleepMode) != A_OK)
{
ret = -EIO;
}
}
break;
}
case AR6000_XIOCTL_WMI_SET_WOW_MODE:
{
WMI_SET_WOW_MODE_CMD setWowMode;
if (ar->arWmiReady == FALSE) {
ret = -EIO;
} else if (copy_from_user(&setWowMode, userdata,
sizeof(setWowMode)))
{
ret = -EFAULT;
} else {
if (wmi_set_wow_mode_cmd(ar->arWmi,
&setWowMode) != A_OK)
{
ret = -EIO;
}
}
break;
}
case AR6000_XIOCTL_WMI_GET_WOW_LIST:
{
WMI_GET_WOW_LIST_CMD getWowList;
if (ar->arWmiReady == FALSE) {
ret = -EIO;
} else if (copy_from_user(&getWowList, userdata,
sizeof(getWowList)))
{
ret = -EFAULT;
} else {
if (wmi_get_wow_list_cmd(ar->arWmi,
&getWowList) != A_OK)
{
ret = -EIO;
}
}
break;
}
case AR6000_XIOCTL_WMI_ADD_WOW_PATTERN:
{
#define WOW_PATTERN_SIZE 64
#define WOW_MASK_SIZE 64
WMI_ADD_WOW_PATTERN_CMD cmd;
A_UINT8 mask_data[WOW_PATTERN_SIZE]={0};
A_UINT8 pattern_data[WOW_PATTERN_SIZE]={0};
do {
if (ar->arWmiReady == FALSE) {
ret = -EIO;
break;
}
if(copy_from_user(&cmd, userdata,
sizeof(WMI_ADD_WOW_PATTERN_CMD)))
{
ret = -EFAULT;
break;
}
if (copy_from_user(pattern_data,
userdata + 3,
cmd.filter_size))
{
ret = -EFAULT;
break;
}
if (copy_from_user(mask_data,
(userdata + 3 + cmd.filter_size),
cmd.filter_size))
{
ret = -EFAULT;
break;
}
if (wmi_add_wow_pattern_cmd(ar->arWmi,
&cmd, pattern_data, mask_data, cmd.filter_size) != A_OK)
{
ret = -EIO;
}
} while(FALSE);
#undef WOW_PATTERN_SIZE
#undef WOW_MASK_SIZE
break;
}
case AR6000_XIOCTL_WMI_DEL_WOW_PATTERN:
{
WMI_DEL_WOW_PATTERN_CMD delWowPattern;
if (ar->arWmiReady == FALSE) {
ret = -EIO;
} else if (copy_from_user(&delWowPattern, userdata,
sizeof(delWowPattern)))
{
ret = -EFAULT;
} else {
if (wmi_del_wow_pattern_cmd(ar->arWmi,
&delWowPattern) != A_OK)
{
ret = -EIO;
}
}
break;
}
case AR6000_XIOCTL_DUMP_HTC_CREDIT_STATE:
if (ar->arHtcTarget != NULL) {
#ifdef ATH_DEBUG_MODULE
HTCDumpCreditStates(ar->arHtcTarget);
#endif /* ATH_DEBUG_MODULE */
#ifdef HTC_EP_STAT_PROFILING
{
HTC_ENDPOINT_STATS stats;
int i;
for (i = 0; i < 5; i++) {
if (HTCGetEndpointStatistics(ar->arHtcTarget,
i,
HTC_EP_STAT_SAMPLE_AND_CLEAR,
&stats)) {
A_PRINTF(KERN_ALERT"------- Profiling Endpoint : %d \n", i);
A_PRINTF(KERN_ALERT"TxCreditLowIndications : %d \n", stats.TxCreditLowIndications);
A_PRINTF(KERN_ALERT"TxIssued : %d \n", stats.TxIssued);
A_PRINTF(KERN_ALERT"TxDropped: %d \n", stats.TxDropped);
A_PRINTF(KERN_ALERT"TxPacketsBundled : %d \n", stats.TxPacketsBundled);
A_PRINTF(KERN_ALERT"TxBundles : %d \n", stats.TxBundles);
A_PRINTF(KERN_ALERT"TxCreditRpts : %d \n", stats.TxCreditRpts);
A_PRINTF(KERN_ALERT"TxCreditsRptsFromRx : %d \n", stats.TxCreditRptsFromRx);
A_PRINTF(KERN_ALERT"TxCreditsRptsFromOther : %d \n", stats.TxCreditRptsFromOther);
A_PRINTF(KERN_ALERT"TxCreditsRptsFromEp0 : %d \n", stats.TxCreditRptsFromEp0);
A_PRINTF(KERN_ALERT"TxCreditsFromRx : %d \n", stats.TxCreditsFromRx);
A_PRINTF(KERN_ALERT"TxCreditsFromOther : %d \n", stats.TxCreditsFromOther);
A_PRINTF(KERN_ALERT"TxCreditsFromEp0 : %d \n", stats.TxCreditsFromEp0);
A_PRINTF(KERN_ALERT"TxCreditsConsummed : %d \n", stats.TxCreditsConsummed);
A_PRINTF(KERN_ALERT"TxCreditsReturned : %d \n", stats.TxCreditsReturned);
A_PRINTF(KERN_ALERT"RxReceived : %d \n", stats.RxReceived);
A_PRINTF(KERN_ALERT"RxPacketsBundled : %d \n", stats.RxPacketsBundled);
A_PRINTF(KERN_ALERT"RxLookAheads : %d \n", stats.RxLookAheads);
A_PRINTF(KERN_ALERT"RxBundleLookAheads : %d \n", stats.RxBundleLookAheads);
A_PRINTF(KERN_ALERT"RxBundleIndFromHdr : %d \n", stats.RxBundleIndFromHdr);
A_PRINTF(KERN_ALERT"RxAllocThreshHit : %d \n", stats.RxAllocThreshHit);
A_PRINTF(KERN_ALERT"RxAllocThreshBytes : %d \n", stats.RxAllocThreshBytes);
A_PRINTF(KERN_ALERT"---- \n");
}
}
}
#endif
}
break;
case AR6000_XIOCTL_TRAFFIC_ACTIVITY_CHANGE:
if (ar->arHtcTarget != NULL) {
struct ar6000_traffic_activity_change data;
if (copy_from_user(&data, userdata, sizeof(data)))
{
ret = -EFAULT;
goto ioctl_done;
}
/* note, this is used for testing (mbox ping testing), indicate activity
* change using the stream ID as the traffic class */
ar6000_indicate_tx_activity(ar,
(A_UINT8)data.StreamID,
data.Active ? TRUE : FALSE);
}
break;
case AR6000_XIOCTL_WMI_SET_CONNECT_CTRL_FLAGS:
if (ar->arWmiReady == FALSE) {
ret = -EIO;
} else if (copy_from_user(&connectCtrlFlags, userdata,
sizeof(connectCtrlFlags)))
{
ret = -EFAULT;
} else {
ar->arConnectCtrlFlags = connectCtrlFlags;
}
break;
case AR6000_XIOCTL_WMI_SET_AKMP_PARAMS:
if (ar->arWmiReady == FALSE) {
ret = -EIO;
} else if (copy_from_user(&akmpParams, userdata,
sizeof(WMI_SET_AKMP_PARAMS_CMD)))
{
ret = -EFAULT;
} else {
if (wmi_set_akmp_params_cmd(ar->arWmi, &akmpParams) != A_OK) {
ret = -EIO;
}
}
break;
case AR6000_XIOCTL_WMI_SET_PMKID_LIST:
if (ar->arWmiReady == FALSE) {
ret = -EIO;
} else {
if (copy_from_user(&pmkidInfo.numPMKID, userdata,
sizeof(pmkidInfo.numPMKID)))
{
ret = -EFAULT;
break;
}
if (copy_from_user(&pmkidInfo.pmkidList,
userdata + sizeof(pmkidInfo.numPMKID),
pmkidInfo.numPMKID * sizeof(WMI_PMKID)))
{
ret = -EFAULT;
break;
}
if (wmi_set_pmkid_list_cmd(ar->arWmi, &pmkidInfo) != A_OK) {
ret = -EIO;
}
}
break;
case AR6000_XIOCTL_WMI_GET_PMKID_LIST:
if (ar->arWmiReady == FALSE) {
ret = -EIO;
} else {
if (wmi_get_pmkid_list_cmd(ar->arWmi) != A_OK) {
ret = -EIO;
}
}
break;
case AR6000_XIOCTL_WMI_ABORT_SCAN:
if (ar->arWmiReady == FALSE) {
ret = -EIO;
}
ret = wmi_abort_scan_cmd(ar->arWmi);
break;
case AR6000_XIOCTL_AP_HIDDEN_SSID:
{
A_UINT8 hidden_ssid;
if (ar->arWmiReady == FALSE) {
ret = -EIO;
} else if (copy_from_user(&hidden_ssid, userdata, sizeof(hidden_ssid))) {
ret = -EFAULT;
} else {
wmi_ap_set_hidden_ssid(ar->arWmi, hidden_ssid);
ar->ap_hidden_ssid = hidden_ssid;
ar->ap_profile_flag = 1; /* There is a change in profile */
}
break;
}
case AR6000_XIOCTL_AP_GET_STA_LIST:
{
if (ar->arWmiReady == FALSE) {
ret = -EIO;
} else {
A_UINT8 i;
ap_get_sta_t temp;
A_MEMZERO(&temp, sizeof(temp));
for(i=0;i<AP_MAX_NUM_STA;i++) {
A_MEMCPY(temp.sta[i].mac, ar->sta_list[i].mac, ATH_MAC_LEN);
temp.sta[i].aid = ar->sta_list[i].aid;
temp.sta[i].keymgmt = ar->sta_list[i].keymgmt;
temp.sta[i].ucipher = ar->sta_list[i].ucipher;
temp.sta[i].auth = ar->sta_list[i].auth;
}
if(copy_to_user((ap_get_sta_t *)rq->ifr_data, &temp,
sizeof(ar->sta_list))) {
ret = -EFAULT;
}
}
break;
}
case AR6000_XIOCTL_AP_SET_NUM_STA:
{
A_UINT8 num_sta;
if (ar->arWmiReady == FALSE) {
ret = -EIO;
} else if (copy_from_user(&num_sta, userdata, sizeof(num_sta))) {
ret = -EFAULT;
} else if(num_sta > AP_MAX_NUM_STA) {
/* value out of range */
ret = -EINVAL;
} else {
wmi_ap_set_num_sta(ar->arWmi, num_sta);
}
break;
}
case AR6000_XIOCTL_AP_SET_ACL_POLICY:
{
A_UINT8 policy;
if (ar->arWmiReady == FALSE) {
ret = -EIO;
} else if (copy_from_user(&policy, userdata, sizeof(policy))) {
ret = -EFAULT;
} else if(policy == ar->g_acl.policy) {
/* No change in policy */
} else {
if(!(policy & AP_ACL_RETAIN_LIST_MASK)) {
/* clear ACL list */
memset(&ar->g_acl,0,sizeof(WMI_AP_ACL));
}
ar->g_acl.policy = policy;
wmi_ap_set_acl_policy(ar->arWmi, policy);
}
break;
}
case AR6000_XIOCTL_AP_SET_ACL_MAC:
{
WMI_AP_ACL_MAC_CMD acl;
if (ar->arWmiReady == FALSE) {
ret = -EIO;
} else if (copy_from_user(&acl, userdata, sizeof(acl))) {
ret = -EFAULT;
} else {
if(acl_add_del_mac(&ar->g_acl, &acl)) {
wmi_ap_acl_mac_list(ar->arWmi, &acl);
} else {
A_PRINTF("ACL list error\n");
ret = -EIO;
}
}
break;
}
case AR6000_XIOCTL_AP_GET_ACL_LIST:
{
if (ar->arWmiReady == FALSE) {
ret = -EIO;
} else if(copy_to_user((WMI_AP_ACL *)rq->ifr_data, &ar->g_acl,
sizeof(WMI_AP_ACL))) {
ret = -EFAULT;
}
break;
}
case AR6000_XIOCTL_AP_COMMIT_CONFIG:
{
ret = ar6000_ap_mode_profile_commit(ar);
break;
}
case IEEE80211_IOCTL_GETWPAIE:
{
struct ieee80211req_wpaie wpaie;
if (ar->arWmiReady == FALSE) {
ret = -EIO;
} else if (copy_from_user(&wpaie, userdata, sizeof(wpaie))) {
ret = -EFAULT;
} else if (ar6000_ap_mode_get_wpa_ie(ar, &wpaie)) {
ret = -EFAULT;
} else if(copy_to_user(userdata, &wpaie, sizeof(wpaie))) {
ret = -EFAULT;
}
break;
}
case AR6000_XIOCTL_AP_CONN_INACT_TIME:
{
A_UINT32 period;
if (ar->arWmiReady == FALSE) {
ret = -EIO;
} else if (copy_from_user(&period, userdata, sizeof(period))) {
ret = -EFAULT;
} else {
wmi_ap_conn_inact_time(ar->arWmi, period);
}
break;
}
case AR6000_XIOCTL_AP_PROT_SCAN_TIME:
{
WMI_AP_PROT_SCAN_TIME_CMD bgscan;
if (ar->arWmiReady == FALSE) {
ret = -EIO;
} else if (copy_from_user(&bgscan, userdata, sizeof(bgscan))) {
ret = -EFAULT;
} else {
wmi_ap_bgscan_time(ar->arWmi, bgscan.period_min, bgscan.dwell_ms);
}
break;
}
case AR6000_XIOCTL_AP_SET_COUNTRY:
{
ret = ar6000_ioctl_set_country(dev, rq);
break;
}
case AR6000_XIOCTL_AP_SET_DTIM:
{
WMI_AP_SET_DTIM_CMD d;
if (ar->arWmiReady == FALSE) {
ret = -EIO;
} else if (copy_from_user(&d, userdata, sizeof(d))) {
ret = -EFAULT;
} else {
if(d.dtim > 0 && d.dtim < 11) {
ar->ap_dtim_period = d.dtim;
wmi_ap_set_dtim(ar->arWmi, d.dtim);
ar->ap_profile_flag = 1; /* There is a change in profile */
} else {
A_PRINTF("DTIM out of range. Valid range is [1-10]\n");
ret = -EIO;
}
}
break;
}
case AR6000_XIOCTL_WMI_TARGET_EVENT_REPORT:
{
WMI_SET_TARGET_EVENT_REPORT_CMD evtCfgCmd;
if (ar->arWmiReady == FALSE) {
ret = -EIO;
}
if (copy_from_user(&evtCfgCmd, userdata,
sizeof(evtCfgCmd))) {
ret = -EFAULT;
break;
}
ret = wmi_set_target_event_report_cmd(ar->arWmi, &evtCfgCmd);
break;
}
case AR6000_XIOCTL_AP_INTRA_BSS_COMM:
{
A_UINT8 intra=0;
if (ar->arWmiReady == FALSE) {
ret = -EIO;
} else if (copy_from_user(&intra, userdata, sizeof(intra))) {
ret = -EFAULT;
} else {
ar->intra_bss = (intra?1:0);
}
break;
}
case AR6000_XIOCTL_DUMP_MODULE_DEBUG_INFO:
{
struct drv_debug_module_s moduleinfo;
if (copy_from_user(&moduleinfo, userdata, sizeof(moduleinfo))) {
ret = -EFAULT;
break;
}
a_dump_module_debug_info_by_name(moduleinfo.modulename);
ret = 0;
break;
}
case AR6000_XIOCTL_MODULE_DEBUG_SET_MASK:
{
struct drv_debug_module_s moduleinfo;
if (copy_from_user(&moduleinfo, userdata, sizeof(moduleinfo))) {
ret = -EFAULT;
break;
}
if (A_FAILED(a_set_module_mask(moduleinfo.modulename, moduleinfo.mask))) {
ret = -EFAULT;
}
break;
}
case AR6000_XIOCTL_MODULE_DEBUG_GET_MASK:
{
struct drv_debug_module_s moduleinfo;
if (copy_from_user(&moduleinfo, userdata, sizeof(moduleinfo))) {
ret = -EFAULT;
break;
}
if (A_FAILED(a_get_module_mask(moduleinfo.modulename, &moduleinfo.mask))) {
ret = -EFAULT;
break;
}
if (copy_to_user(userdata, &moduleinfo, sizeof(moduleinfo))) {
ret = -EFAULT;
break;
}
break;
}
#ifdef ATH_AR6K_11N_SUPPORT
case AR6000_XIOCTL_DUMP_RCV_AGGR_STATS:
{
PACKET_LOG *copy_of_pkt_log;
aggr_dump_stats(ar->aggr_cntxt, ©_of_pkt_log);
if (copy_to_user(rq->ifr_data, copy_of_pkt_log, sizeof(PACKET_LOG))) {
ret = -EFAULT;
}
break;
}
case AR6000_XIOCTL_SETUP_AGGR:
{
WMI_ADDBA_REQ_CMD cmd;
if (ar->arWmiReady == FALSE) {
ret = -EIO;
} else if (copy_from_user(&cmd, userdata, sizeof(cmd))) {
ret = -EFAULT;
} else {
wmi_setup_aggr_cmd(ar->arWmi, cmd.tid);
}
}
break;
case AR6000_XIOCTL_DELE_AGGR:
{
WMI_DELBA_REQ_CMD cmd;
if (ar->arWmiReady == FALSE) {
ret = -EIO;
} else if (copy_from_user(&cmd, userdata, sizeof(cmd))) {
ret = -EFAULT;
} else {
wmi_delete_aggr_cmd(ar->arWmi, cmd.tid, cmd.is_sender_initiator);
}
}
break;
case AR6000_XIOCTL_ALLOW_AGGR:
{
WMI_ALLOW_AGGR_CMD cmd;
if (ar->arWmiReady == FALSE) {
ret = -EIO;
} else if (copy_from_user(&cmd, userdata, sizeof(cmd))) {
ret = -EFAULT;
} else {
wmi_allow_aggr_cmd(ar->arWmi, cmd.tx_allow_aggr, cmd.rx_allow_aggr);
}
}
break;
case AR6000_XIOCTL_SET_HT_CAP:
{
if (ar->arWmiReady == FALSE) {
ret = -EIO;
} else if (copy_from_user(&htCap, userdata,
sizeof(htCap)))
{
ret = -EFAULT;
} else {
if (wmi_set_ht_cap_cmd(ar->arWmi, &htCap) != A_OK)
{
ret = -EIO;
}
}
break;
}
case AR6000_XIOCTL_SET_HT_OP:
{
if (ar->arWmiReady == FALSE) {
ret = -EIO;
} else if (copy_from_user(&htOp, userdata,
sizeof(htOp)))
{
ret = -EFAULT;
} else {
if (wmi_set_ht_op_cmd(ar->arWmi, htOp.sta_chan_width) != A_OK)
{
ret = -EIO;
}
}
break;
}
#endif
case AR6000_XIOCTL_ACL_DATA:
{
void *osbuf = NULL;
if (ar->arWmiReady == FALSE) {
ret = -EIO;
} else if (ar6000_create_acl_data_osbuf(dev, (A_UINT8*)userdata, &osbuf) != A_OK) {
ret = -EIO;
} else {
if (wmi_data_hdr_add(ar->arWmi, osbuf, DATA_MSGTYPE, 0, WMI_DATA_HDR_DATA_TYPE_ACL,0,NULL) != A_OK) {
AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("XIOCTL_ACL_DATA - wmi_data_hdr_add failed\n"));
} else {
/* Send data buffer over HTC */
ar6000_acl_data_tx(osbuf, ar->arNetDev);
}
}
break;
}
case AR6000_XIOCTL_HCI_CMD:
{
char tmp_buf[512];
A_INT8 i;
WMI_HCI_CMD *cmd = (WMI_HCI_CMD *)tmp_buf;
A_UINT8 size;
size = sizeof(cmd->cmd_buf_sz);
if (ar->arWmiReady == FALSE) {
ret = -EIO;
} else if (copy_from_user(cmd, userdata, size)) {
ret = -EFAULT;
} else if(copy_from_user(cmd->buf, userdata + size, cmd->cmd_buf_sz)) {
ret = -EFAULT;
} else {
if (wmi_send_hci_cmd(ar->arWmi, cmd->buf, cmd->cmd_buf_sz) != A_OK) {
ret = -EIO;
}else if(loghci) {
A_PRINTF_LOG("HCI Command To PAL --> \n");
for(i = 0; i < cmd->cmd_buf_sz; i++) {
A_PRINTF_LOG("0x%02x ",cmd->buf[i]);
if((i % 10) == 0) {
A_PRINTF_LOG("\n");
}
}
A_PRINTF_LOG("\n");
A_PRINTF_LOG("==================================\n");
}
}
break;
}
case AR6000_XIOCTL_WLAN_CONN_PRECEDENCE:
{
WMI_SET_BT_WLAN_CONN_PRECEDENCE cmd;
if (ar->arWmiReady == FALSE) {
ret = -EIO;
} else if (copy_from_user(&cmd, userdata, sizeof(cmd))) {
ret = -EFAULT;
} else {
if (cmd.precedence == BT_WLAN_CONN_PRECDENCE_WLAN ||
cmd.precedence == BT_WLAN_CONN_PRECDENCE_PAL) {
if ( wmi_set_wlan_conn_precedence_cmd(ar->arWmi, cmd.precedence) != A_OK) {
ret = -EIO;
}
} else {
ret = -EINVAL;
}
}
break;
}
case AR6000_XIOCTL_AP_GET_STAT:
{
ret = ar6000_ioctl_get_ap_stats(dev, rq);
break;
}
case AR6000_XIOCTL_SET_TX_SELECT_RATES:
{
WMI_SET_TX_SELECT_RATES_CMD masks;
if (ar->arWmiReady == FALSE) {
ret = -EIO;
} else if (copy_from_user(&masks, userdata,
sizeof(masks)))
{
ret = -EFAULT;
} else {
if (wmi_set_tx_select_rates_cmd(ar->arWmi, masks.rateMasks) != A_OK)
{
ret = -EIO;
}
}
break;
}
case AR6000_XIOCTL_AP_GET_HIDDEN_SSID:
{
WMI_AP_HIDDEN_SSID_CMD ssid;
ssid.hidden_ssid = ar->ap_hidden_ssid;
if (ar->arWmiReady == FALSE) {
ret = -EIO;
} else if(copy_to_user((WMI_AP_HIDDEN_SSID_CMD *)rq->ifr_data,
&ssid, sizeof(WMI_AP_HIDDEN_SSID_CMD))) {
ret = -EFAULT;
}
break;
}
case AR6000_XIOCTL_AP_GET_COUNTRY:
{
WMI_AP_SET_COUNTRY_CMD cty;
A_MEMCPY(cty.countryCode, ar->ap_country_code, 3);
if (ar->arWmiReady == FALSE) {
ret = -EIO;
} else if(copy_to_user((WMI_AP_SET_COUNTRY_CMD *)rq->ifr_data,
&cty, sizeof(WMI_AP_SET_COUNTRY_CMD))) {
ret = -EFAULT;
}
break;
}
case AR6000_XIOCTL_AP_GET_WMODE:
{
if (ar->arWmiReady == FALSE) {
ret = -EIO;
} else if(copy_to_user((A_UINT8 *)rq->ifr_data,
&ar->ap_wmode, sizeof(A_UINT8))) {
ret = -EFAULT;
}
break;
}
case AR6000_XIOCTL_AP_GET_DTIM:
{
WMI_AP_SET_DTIM_CMD dtim;
dtim.dtim = ar->ap_dtim_period;
if (ar->arWmiReady == FALSE) {
ret = -EIO;
} else if(copy_to_user((WMI_AP_SET_DTIM_CMD *)rq->ifr_data,
&dtim, sizeof(WMI_AP_SET_DTIM_CMD))) {
ret = -EFAULT;
}
break;
}
case AR6000_XIOCTL_AP_GET_BINTVL:
{
WMI_BEACON_INT_CMD bi;
bi.beaconInterval = ar->ap_beacon_interval;
if (ar->arWmiReady == FALSE) {
ret = -EIO;
} else if(copy_to_user((WMI_BEACON_INT_CMD *)rq->ifr_data,
&bi, sizeof(WMI_BEACON_INT_CMD))) {
ret = -EFAULT;
}
break;
}
case AR6000_XIOCTL_AP_GET_RTS:
{
WMI_SET_RTS_CMD rts;
rts.threshold = ar->arRTS;
if (ar->arWmiReady == FALSE) {
ret = -EIO;
} else if(copy_to_user((WMI_SET_RTS_CMD *)rq->ifr_data,
&rts, sizeof(WMI_SET_RTS_CMD))) {
ret = -EFAULT;
}
break;
}
case AR6000_XIOCTL_FETCH_TARGET_REGS:
{
A_UINT32 targregs[AR6003_FETCH_TARG_REGS_COUNT];
if (ar->arTargetType == TARGET_TYPE_AR6003) {
ar6k_FetchTargetRegs(hifDevice, targregs);
if (copy_to_user((A_UINT32 *)rq->ifr_data, &targregs, sizeof(targregs)))
{
ret = -EFAULT;
}
} else {
ret = -EOPNOTSUPP;
}
break;
}
case AR6000_XIOCTL_AP_SET_11BG_RATESET:
{
WMI_AP_SET_11BG_RATESET_CMD rate;
if (ar->arWmiReady == FALSE) {
ret = -EIO;
} else if (copy_from_user(&rate, userdata, sizeof(rate))) {
ret = -EFAULT;
} else {
wmi_ap_set_rateset(ar->arWmi, rate.rateset);
}
break;
}
case AR6000_XIOCTL_GET_WLAN_SLEEP_STATE:
{
WMI_REPORT_SLEEP_STATE_EVENT wmiSleepEvent ;
if (ar->arWlanState == WLAN_ENABLED) {
wmiSleepEvent.sleepState = WMI_REPORT_SLEEP_STATUS_IS_AWAKE;
} else {
wmiSleepEvent.sleepState = WMI_REPORT_SLEEP_STATUS_IS_DEEP_SLEEP;
}
rq->ifr_ifru.ifru_ivalue = ar->arWlanState; /* return value */
ar6000_send_event_to_app(ar, WMI_REPORT_SLEEP_STATE_EVENTID, (A_UINT8*)&wmiSleepEvent,
sizeof(WMI_REPORT_SLEEP_STATE_EVENTID));
break;
}
#ifdef CONFIG_PM
case AR6000_XIOCTL_SET_BT_HW_POWER_STATE:
{
unsigned int state;
get_user(state, (unsigned int *)userdata);
if (ar6000_set_bt_hw_state(ar, state)!=A_OK) {
ret = -EIO;
}
}
break;
case AR6000_XIOCTL_GET_BT_HW_POWER_STATE:
rq->ifr_ifru.ifru_ivalue = !ar->arBTOff; /* return value */
break;
#endif
case AR6000_XIOCTL_WMI_SET_TX_SGI_PARAM:
{
WMI_SET_TX_SGI_PARAM_CMD SGICmd;
if (ar->arWmiReady == FALSE) {
ret = -EIO;
} else if (copy_from_user(&SGICmd, userdata,
sizeof(SGICmd))){
ret = -EFAULT;
} else{
if (wmi_SGI_cmd(ar->arWmi, SGICmd.sgiMask, SGICmd.sgiPERThreshold) != A_OK) {
ret = -EIO;
}
}
break;
}
case AR6000_XIOCTL_ADD_AP_INTERFACE:
#ifdef CONFIG_AP_VIRTUAL_ADAPTER_SUPPORT
{
char ap_ifname[IFNAMSIZ] = {0,};
if (copy_from_user(ap_ifname, userdata, IFNAMSIZ)) {
ret = -EFAULT;
} else {
if (ar6000_add_ap_interface(ar, ap_ifname) != A_OK) {
ret = -EIO;
}
}
}
#else
ret = -EOPNOTSUPP;
#endif
break;
case AR6000_XIOCTL_REMOVE_AP_INTERFACE:
#ifdef CONFIG_AP_VIRTUAL_ADAPTER_SUPPORT
if (ar6000_remove_ap_interface(ar) != A_OK) {
ret = -EIO;
}
#else
ret = -EOPNOTSUPP;
#endif
break;
default:
ret = -EOPNOTSUPP;
}
ioctl_done:
rtnl_lock(); /* restore rtnl state */
dev_put(dev);
return ret;
}
A_UINT8 mac_cmp_wild(A_UINT8 *mac, A_UINT8 *new_mac, A_UINT8 wild, A_UINT8 new_wild)
{
A_UINT8 i;
for(i=0;i<ATH_MAC_LEN;i++) {
if((wild & 1<<i) && (new_wild & 1<<i)) continue;
if(mac[i] != new_mac[i]) return 1;
}
if((A_MEMCMP(new_mac, null_mac, 6)==0) && new_wild &&
(wild != new_wild)) {
return 1;
}
return 0;
}
A_UINT8 acl_add_del_mac(WMI_AP_ACL *a, WMI_AP_ACL_MAC_CMD *acl)
{
A_INT8 already_avail=-1, free_slot=-1, i;
/* To check whether this mac is already there in our list */
for(i=AP_ACL_SIZE-1;i>=0;i--)
{
if(mac_cmp_wild(a->acl_mac[i], acl->mac, a->wildcard[i],
acl->wildcard)==0)
already_avail = i;
if(!((1 << i) & a->index))
free_slot = i;
}
if(acl->action == ADD_MAC_ADDR)
{
/* Dont add mac if it is already available */
if((already_avail >= 0) || (free_slot == -1))
return 0;
A_MEMCPY(a->acl_mac[free_slot], acl->mac, ATH_MAC_LEN);
a->index = a->index | (1 << free_slot);
acl->index = free_slot;
a->wildcard[free_slot] = acl->wildcard;
return 1;
}
else if(acl->action == DEL_MAC_ADDR)
{
if(acl->index > AP_ACL_SIZE)
return 0;
if(!(a->index & (1 << acl->index)))
return 0;
A_MEMZERO(a->acl_mac[acl->index],ATH_MAC_LEN);
a->index = a->index & ~(1 << acl->index);
a->wildcard[acl->index] = 0;
return 1;
}
return 0;
}
|