summaryrefslogtreecommitdiff
path: root/drivers/net/wireless/nxp/mxm_wifiex/wlan_src/mlan/mlan_main.h
blob: 5c4ff7136f11c2faeeb24cb470468f2f2a499d57 (plain)
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
/** @file mlan_main.h
 *
 *  @brief This file defines the private and adapter data
 *  structures and declares global function prototypes used
 *  in MLAN module.
 *
 *
 *  Copyright 2014-2020 NXP
 *
 *  This software file (the File) is distributed by NXP
 *  under the terms of the GNU General Public License Version 2, June 1991
 *  (the License).  You may use, redistribute and/or modify the File in
 *  accordance with the terms and conditions of the License, a copy of which
 *  is available by writing to the Free Software Foundation, Inc.,
 *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
 *  worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
 *
 *  THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
 *  IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
 *  ARE EXPRESSLY DISCLAIMED.  The License provides additional details about
 *  this warranty disclaimer.
 *
 */

/******************************************************
Change log:
    10/13/2008: initial version
******************************************************/

#ifndef _MLAN_MAIN_H_
#define _MLAN_MAIN_H_

#ifdef DEBUG_LEVEL1
extern t_void (*print_callback)(t_pvoid pmoal_handle, t_u32 level,
				char *pformat, IN...);

extern mlan_status (*get_sys_time_callback)(t_void *pmoal_handle, t_u32 *psec,
					    t_u32 *pusec);

extern t_u32 mlan_drvdbg;

#ifdef DEBUG_LEVEL2
#define PRINTM_MINFO(msg...)                                                   \
	do {                                                                   \
		if ((mlan_drvdbg & MINFO) && (print_callback))                 \
			print_callback(MNULL, MINFO, msg);                     \
	} while (0)
#define PRINTM_MWARN(msg...)                                                   \
	do {                                                                   \
		if ((mlan_drvdbg & MWARN) && (print_callback))                 \
			print_callback(MNULL, MWARN, msg);                     \
	} while (0)
#define PRINTM_MENTRY(msg...)                                                  \
	do {                                                                   \
		if ((mlan_drvdbg & MENTRY) && (print_callback))                \
			print_callback(MNULL, MENTRY, msg);                    \
	} while (0)
#define PRINTM_GET_SYS_TIME(level, psec, pusec)                                \
	do {                                                                   \
		if ((level & mlan_drvdbg) && (get_sys_time_callback))          \
			get_sys_time_callback(MNULL, psec, pusec);             \
	} while (0)

/** Hexdump for level-2 debugging */
#define HEXDUMP(x, y, z)                                                       \
	do {                                                                   \
		if ((mlan_drvdbg & (MHEX_DUMP | MINFO)) && (print_callback))   \
			print_callback(MNULL, MHEX_DUMP | MINFO, x, y, z);     \
	} while (0)

#else

#define PRINTM_MINFO(msg...)                                                   \
	do {                                                                   \
	} while (0)
#define PRINTM_MWARN(msg...)                                                   \
	do {                                                                   \
	} while (0)
#define PRINTM_MENTRY(msg...)                                                  \
	do {                                                                   \
	} while (0)

#define PRINTM_GET_SYS_TIME(level, psec, pusec)                                \
	do {                                                                   \
		if ((level & mlan_drvdbg) && (get_sys_time_callback) &&        \
		    (level != MINFO) && (level != MWARN))                      \
			get_sys_time_callback(MNULL, psec, pusec);             \
	} while (0)

/** Hexdump for debugging */
#define HEXDUMP(x, y, z)                                                       \
	do {                                                                   \
	} while (0)

#endif /* DEBUG_LEVEL2 */

#define PRINTM_MFW_D(msg...)                                                   \
	do {                                                                   \
		if ((mlan_drvdbg & MFW_D) && (print_callback))                 \
			print_callback(MNULL, MFW_D, msg);                     \
	} while (0)
#define PRINTM_MCMD_D(msg...)                                                  \
	do {                                                                   \
		if ((mlan_drvdbg & MCMD_D) && (print_callback))                \
			print_callback(MNULL, MCMD_D, msg);                    \
	} while (0)
#define PRINTM_MDAT_D(msg...)                                                  \
	do {                                                                   \
		if ((mlan_drvdbg & MDAT_D) && (print_callback))                \
			print_callback(MNULL, MDAT_D, msg);                    \
	} while (0)
#define PRINTM_MIF_D(msg...)                                                   \
	do {                                                                   \
		if ((mlan_drvdbg & MIF_D) && (print_callback))                 \
			print_callback(MNULL, MIF_D, msg);                     \
	} while (0)

#define PRINTM_MIOCTL(msg...)                                                  \
	do {                                                                   \
		if ((mlan_drvdbg & MIOCTL) && (print_callback))                \
			print_callback(MNULL, MIOCTL, msg);                    \
	} while (0)
#define PRINTM_MINTR(msg...)                                                   \
	do {                                                                   \
		if ((mlan_drvdbg & MINTR) && (print_callback))                 \
			print_callback(MNULL, MINTR, msg);                     \
	} while (0)
#define PRINTM_MEVENT(msg...)                                                  \
	do {                                                                   \
		if ((mlan_drvdbg & MEVENT) && (print_callback))                \
			print_callback(MNULL, MEVENT, msg);                    \
	} while (0)
#define PRINTM_MCMND(msg...)                                                   \
	do {                                                                   \
		if ((mlan_drvdbg & MCMND) && (print_callback))                 \
			print_callback(MNULL, MCMND, msg);                     \
	} while (0)
#define PRINTM_MDATA(msg...)                                                   \
	do {                                                                   \
		if ((mlan_drvdbg & MDATA) && (print_callback))                 \
			print_callback(MNULL, MDATA, msg);                     \
	} while (0)
#define PRINTM_MERROR(msg...)                                                  \
	do {                                                                   \
		if ((mlan_drvdbg & MERROR) && (print_callback))                \
			print_callback(MNULL, MERROR, msg);                    \
	} while (0)
#define PRINTM_MFATAL(msg...)                                                  \
	do {                                                                   \
		if ((mlan_drvdbg & MFATAL) && (print_callback))                \
			print_callback(MNULL, MFATAL, msg);                    \
	} while (0)
#define PRINTM_MMSG(msg...)                                                    \
	do {                                                                   \
		if ((mlan_drvdbg & MMSG) && (print_callback))                  \
			print_callback(MNULL, MMSG, msg);                      \
	} while (0)

#define PRINTM(level, msg...) PRINTM_##level((char *)msg)

/** Log debug message */
#ifdef __GNUC__
#define PRINTM_NETINTF(level, pmpriv)                                          \
	do {                                                                   \
		if ((mlan_drvdbg & level) && pmpriv &&                         \
		    pmpriv->adapter->callbacks.moal_print_netintf)             \
			pmpriv->adapter->callbacks.moal_print_netintf(         \
				pmpriv->adapter->pmoal_handle,                 \
				pmpriv->bss_index, level);                     \
	} while (0)
#endif /* __GNUC__ */

/** Max hex dump data length */
#define MAX_DATA_DUMP_LEN 64

/** Debug hexdump for level-1 debugging */
#define DBG_HEXDUMP(level, x, y, z)                                            \
	do {                                                                   \
		if ((mlan_drvdbg & level) && print_callback)                   \
			print_callback(MNULL, MHEX_DUMP | level, x, y, z);     \
	} while (0)

#else /* DEBUG_LEVEL1 */

#define PRINTM(level, msg...)                                                  \
	do {                                                                   \
	} while (0)

#define PRINTM_NETINTF(level, pmpriv)                                          \
	do {                                                                   \
	} while (0)

/** Debug hexdump for level-1 debugging */
#define DBG_HEXDUMP(level, x, y, z)                                            \
	do {                                                                   \
	} while (0)

/** Hexdump for debugging */
#define HEXDUMP(x, y, z)                                                       \
	do {                                                                   \
	} while (0)

#define PRINTM_GET_SYS_TIME(level, psec, pusec)                                \
	do {                                                                   \
	} while (0)

#endif /* DEBUG_LEVEL1 */

/* Reason Code 3: STA is leaving (or has left) IBSS or ESS */
#define DEF_DEAUTH_REASON_CODE (0x3)

/** Log entry point for debugging */
#define ENTER()                                                                \
	do {                                                                   \
		PRINTM(MENTRY, "Enter: %s\n", __func__);                       \
	} while (0)

/** Log exit point for debugging */
#define LEAVE()                                                                \
	do {                                                                   \
		PRINTM(MENTRY, "Leave: %s\n", __func__);                       \
	} while (0)

/** Find minimum */
#ifndef MIN
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#endif

/** Find maximum */
#ifndef MAX
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#endif

#ifdef memset
#undef memset
#endif
/** Memset routine */
#define memset(adapter, s, c, len)                                             \
	(adapter->callbacks.moal_memset(adapter->pmoal_handle, s, c, len))

#ifdef memmove
#undef memmove
#endif
/** Memmove routine */
#define memmove(adapter, dest, src, len)                                       \
	(adapter->callbacks.moal_memmove(adapter->pmoal_handle, dest, src, len))

#ifdef memcpy
#undef memcpy
#endif
/** Memcpy routine */
#define memcpy(adapter, to, from, len)                                         \
	(adapter->callbacks.moal_memcpy(adapter->pmoal_handle, to, from, len))
/* memcpy_ext rountine */
#define memcpy_ext(adapter, to, from, len, size)                               \
	(adapter->callbacks.moal_memcpy_ext(adapter->pmoal_handle, to, from,   \
					    len, size))

#ifdef memcmp
#undef memcmp
#endif
/** Memcmp routine */
#define memcmp(adapter, s1, s2, len)                                           \
	(adapter->callbacks.moal_memcmp(adapter->pmoal_handle, s1, s2, len))

/** Find number of elements */
#ifndef NELEMENTS
#define NELEMENTS(x) (sizeof(x) / sizeof(x[0]))
#endif

/** SWAP: swap t_u8 */
#define SWAP_U8(a, b)                                                          \
	{                                                                      \
		t_u8 t;                                                        \
		t = a;                                                         \
		a = b;                                                         \
		b = t;                                                         \
	}

/** SWAP: swap t_u8 */
#define SWAP_U16(a, b)                                                         \
	{                                                                      \
		t_u16 t;                                                       \
		t = a;                                                         \
		a = b;                                                         \
		b = t;                                                         \
	}

/** MLAN MNULL pointer */
#define MNULL (0)

/** 16 bits byte swap */
#define swap_byte_16(x)                                                        \
	((t_u16)((((t_u16)(x)&0x00ffU) << 8) | (((t_u16)(x)&0xff00U) >> 8)))

/** 32 bits byte swap */
#define swap_byte_32(x)                                                        \
	((t_u32)((((t_u32)(x)&0x000000ffUL) << 24) |                           \
		 (((t_u32)(x)&0x0000ff00UL) << 8) |                            \
		 (((t_u32)(x)&0x00ff0000UL) >> 8) |                            \
		 (((t_u32)(x)&0xff000000UL) >> 24)))

/** 64 bits byte swap */
#define swap_byte_64(x)                                                        \
	((t_u64)((t_u64)(((t_u64)(x)&0x00000000000000ffULL) << 56) |           \
		 (t_u64)(((t_u64)(x)&0x000000000000ff00ULL) << 40) |           \
		 (t_u64)(((t_u64)(x)&0x0000000000ff0000ULL) << 24) |           \
		 (t_u64)(((t_u64)(x)&0x00000000ff000000ULL) << 8) |            \
		 (t_u64)(((t_u64)(x)&0x000000ff00000000ULL) >> 8) |            \
		 (t_u64)(((t_u64)(x)&0x0000ff0000000000ULL) >> 24) |           \
		 (t_u64)(((t_u64)(x)&0x00ff000000000000ULL) >> 40) |           \
		 (t_u64)(((t_u64)(x)&0xff00000000000000ULL) >> 56)))

#ifdef BIG_ENDIAN_SUPPORT
/** Convert ulong n/w to host */
#define mlan_ntohl(x) x
/** Convert host ulong to n/w */
#define mlan_htonl(x) x
/** Convert n/w to host */
#define mlan_ntohs(x) x
/** Convert host to n/w */
#define mlan_htons(x) x
/** Convert from 16 bit little endian format to CPU format */
#define wlan_le16_to_cpu(x) swap_byte_16(x)
/** Convert from 32 bit little endian format to CPU format */
#define wlan_le32_to_cpu(x) swap_byte_32(x)
/** Convert from 64 bit little endian format to CPU format */
#define wlan_le64_to_cpu(x) swap_byte_64(x)
/** Convert to 16 bit little endian format from CPU format */
#define wlan_cpu_to_le16(x) swap_byte_16(x)
/** Convert to 32 bit little endian format from CPU format */
#define wlan_cpu_to_le32(x) swap_byte_32(x)
/** Convert to 64 bit little endian format from CPU format */
#define wlan_cpu_to_le64(x) swap_byte_64(x)

/** Convert TxPD to little endian format from CPU format */
#define endian_convert_TxPD(x)                                                 \
	{                                                                      \
		(x)->tx_pkt_length = wlan_cpu_to_le16((x)->tx_pkt_length);     \
		(x)->tx_pkt_offset = wlan_cpu_to_le16((x)->tx_pkt_offset);     \
		(x)->tx_pkt_type = wlan_cpu_to_le16((x)->tx_pkt_type);         \
		(x)->tx_control = wlan_cpu_to_le32((x)->tx_control);           \
		(x)->tx_control_1 = wlan_cpu_to_le32((x)->tx_control_1);       \
	}
/** Convert RxPD from little endian format to CPU format */
#define endian_convert_RxPD(x)                                                 \
	{                                                                      \
		(x)->rx_pkt_length = wlan_le16_to_cpu((x)->rx_pkt_length);     \
		(x)->rx_pkt_offset = wlan_le16_to_cpu((x)->rx_pkt_offset);     \
		(x)->rx_pkt_type = wlan_le16_to_cpu((x)->rx_pkt_type);         \
		(x)->seq_num = wlan_le16_to_cpu((x)->seq_num);                 \
		(x)->rx_info = wlan_le32_to_cpu((x)->rx_info);                 \
	}

#else
/** Convert ulong n/w to host */
#define mlan_ntohl(x) swap_byte_32(x)
/** Convert host ulong to n/w */
#define mlan_htonl(x) swap_byte_32(x)
/** Convert n/w to host */
#define mlan_ntohs(x) swap_byte_16(x)
/** Convert host to n/w */
#define mlan_htons(x) swap_byte_16(x)
/** Do nothing */
#define wlan_le16_to_cpu(x) x
/** Do nothing */
#define wlan_le32_to_cpu(x) x
/** Do nothing */
#define wlan_le64_to_cpu(x) x
/** Do nothing */
#define wlan_cpu_to_le16(x) x
/** Do nothing */
#define wlan_cpu_to_le32(x) x
/** Do nothing */
#define wlan_cpu_to_le64(x) x

/** Convert TxPD to little endian format from CPU format */
#define endian_convert_TxPD(x)                                                 \
	do {                                                                   \
	} while (0)
/** Convert RxPD from little endian format to CPU format */
#define endian_convert_RxPD(x)                                                 \
	do {                                                                   \
	} while (0)
#endif /* BIG_ENDIAN_SUPPORT */

/** Global moal_assert_callback */
extern t_void (*assert_callback)(t_void *pmoal_handle, t_u32 cond);

/** Assertion */
#define MASSERT(cond)                                                          \
	do {                                                                   \
		if (!(cond)) {                                                 \
			PRINTM(MFATAL, "ASSERT: %s: %i\n", __func__,           \
			       __LINE__);                                      \
			if (assert_callback) {                                 \
				assert_callback(MNULL, (t_ptr)(cond));         \
			} else {                                               \
				do {                                           \
				} while (1);                                   \
			}                                                      \
		}                                                              \
	} while (0)

/** Maximum event buffer size */
#define MAX_EVENT_SIZE (3 * 1024)

/** 60 seconds */
#define MRVDRV_TIMER_60S 60000
/** 10 seconds */
#define MRVDRV_TIMER_10S 10000
/** 5 seconds */
#define MRVDRV_TIMER_5S 5000
/** 3 seconds */
#define MRVDRV_TIMER_3S 3000
/** 1 second */
#define MRVDRV_TIMER_1S 1000

/** Maximum size of multicast list */
#define MRVDRV_MAX_MULTICAST_LIST_SIZE 32
/** Maximum size of channel */
#define MRVDRV_MAX_CHANNEL_SIZE 14
/** Maximum length of SSID */
#define MRVDRV_MAX_SSID_LENGTH 32
/** WEP list macros & data structures */
/** Size of key buffer in bytes */
#define MRVL_KEY_BUFFER_SIZE_IN_BYTE 16
/** Maximum length of WPA key */
#define MRVL_MAX_KEY_WPA_KEY_LENGTH 32

/** Default listen interval */
#define MLAN_DEFAULT_LISTEN_INTERVAL 20

/** Maximum number of region codes */
#define MRVDRV_MAX_REGION_CODE 9

/** Maximum number of CFP codes for BG */
#define MRVDRV_MAX_CFP_CODE_BG 0
/** Maximum number of CFP codes for A */
#define MRVDRV_MAX_CFP_CODE_A 5

/** high rx pending packets */
#define HIGH_RX_PENDING 100
/** low rx pending packets */
#define LOW_RX_PENDING 80

/** Default region code */
#define MRVDRV_DEFAULT_REGION_CODE 0x10
/** Default country code */
#define MRVDRV_DEFAULT_COUNTRY_CODE "US"

/** Japan country code */
#define COUNTRY_CODE_JP_40 0x40
/** Japan special country code */
#define COUNTRY_CODE_JP_FF 0xFF

/** Default factor for calculating beacon average */
#define DEFAULT_BCN_AVG_FACTOR 8
/** Default factor for calculating data average */
#define DEFAULT_DATA_AVG_FACTOR 8

/** The first valid channel for use */
#define FIRST_VALID_CHANNEL 0xff
/** Default Ad-Hoc channel */
#define DEFAULT_AD_HOC_CHANNEL 6
/** Default Ad-Hoc channel A */
#define DEFAULT_AD_HOC_CHANNEL_A 36

/** Number of WEP keys */
#define MRVL_NUM_WEP_KEY (4)

/** Default multiple DTIM */
#define MRVDRV_DEFAULT_MULTIPLE_DTIM 1

/** Default beacon missing timeout */
#define DEFAULT_BCN_MISS_TIMEOUT 10

/** Maximum buffer space for beacons retrieved from scan responses */
#define MAX_SCAN_BEACON_BUFFER 49152
/** Default buffer space for beacons retrieved from scan responses */
#define DEFAULT_SCAN_BEACON_BUFFER 4096

/**
 * @brief Buffer pad space for newly allocated beacons/probe responses
 *
 * Beacons are typically 6 bytes longer than an equivalent probe response.
 *  For each scan response stored, allocate an extra byte pad at the end to
 *  allow easy expansion to store a beacon in the same memory a probe response
 *  previously contained
 */
#define SCAN_BEACON_ENTRY_PAD 6

/** Scan time specified in the channel TLV
 *  for each channel for passive scans
 */
#define MRVDRV_PASSIVE_SCAN_CHAN_TIME 200

/** Scan time specified in the channel TLV
 *  for each channel for active scans
 */
#define MRVDRV_ACTIVE_SCAN_CHAN_TIME 200

/** Scan time specified in the channel TLV
 *  for each channel for specific scans
 */
#define MRVDRV_SPECIFIC_SCAN_CHAN_TIME 110

/**
 * Max total scan time in milliseconds
 * The total scan time should be less than scan command timeout value (20s)
 */
#define MRVDRV_MAX_TOTAL_SCAN_TIME (MRVDRV_TIMER_10S * 2 - MRVDRV_TIMER_1S)

/** Offset for GTK as it has version to skip past for GTK */
#define RSN_GTK_OUI_OFFSET 2

/** If OUI is not found */
#define MLAN_OUI_NOT_PRESENT 0
/** If OUI is found */
#define MLAN_OUI_PRESENT 1

/** Is cmd_resp, event or data packet received? */
#define IS_CARD_RX_RCVD(adapter)                                               \
	(adapter->cmd_resp_received || adapter->event_received ||              \
	 adapter->data_received)
#ifdef USB
/** Type length */
#define MLAN_TYPE_LEN 4
/** Type Command */
#define MLAN_USB_TYPE_CMD 0xF00DFACE
/** Type VDLL */
#define MLAN_USB_TYPE_VDLL 0xF00DC0DE
/** Type Data */
#define MLAN_USB_TYPE_DATA 0xBEADC0DE
/** Type Event */
#define MLAN_USB_TYPE_EVENT 0xBEEFFACE
#endif /* USB */
/** Type command */
#define MLAN_TYPE_CMD 1
/** Type data */
#define MLAN_TYPE_DATA 0
/** Type event */
#define MLAN_TYPE_EVENT 3
/** Type vdll */
#define MLAN_TYPE_VDLL 4
#ifdef SDIO
/** Type single port aggr data */
#define MLAN_TYPE_SPA_DATA 10
/** OFFSET of 512 block number */
#define OFFSET_OF_BLOCK_NUMBER 15
/** OFFSET of SDIO Header */
#define OFFSET_OF_SDIO_HEADER 28
/** sdio max rx size for cmd53, 255 * 256, reserve 1 block for DMA alignment */
#define SDIO_CMD53_MAX_SIZE 65280
#define MAX_SUPPORT_AMSDU_SIZE 4096
/** Maximum numbfer of registers to read for multiple port */
#if defined(SD8887) || defined(SD8997) || defined(SD8977) ||                   \
	defined(SD8987) || defined(SD9098) || defined(SD9097) ||               \
	defined(SD8978)
#define MAX_MP_REGS 196
#else
/* upto 0xB7 */
#define MAX_MP_REGS 184
#endif
/** Maximum port */
#define MAX_PORT 32

/** max MP REGS */
#define MAX_MP_REGS_MAX (196)

/** Multi port TX aggregation buffer size */
#define SDIO_MP_TX_AGGR_DEF_BUF_SIZE (65280) /* 64K - 256 */

/** Multi port RX aggregation buffer size */
#define SDIO_MP_RX_AGGR_DEF_BUF_SIZE (65280) /* 64K - 256 */

#endif /* SDIO */

/** Minimum BA threshold */
#define MIN_BA_THRESHOLD 16

/** High threshold at which to start drop packets */
#define RX_HIGH_THRESHOLD 1024
/** Low threshold to allow Rx BA */
#define RX_LOW_THRESHOLD 128

#define MFG_CMD_SET_TEST_MODE 1
#define MFG_CMD_UNSET_TEST_MODE 0
#define MFG_CMD_TX_ANT 0x1004
#define MFG_CMD_RX_ANT 0x1005
#define MFG_CMD_TX_CONT 0x1009
#define MFG_CMD_RF_CHAN 0x100A
#define MFG_CMD_CLR_RX_ERR 0x1010
#define MFG_CMD_TX_FRAME 0x1021
#define MFG_CMD_RF_BAND_AG 0x1034
#define MFG_CMD_RF_CHANNELBW 0x1044

/** Debug command number */
#define DBG_CMD_NUM 10

/** Info for debug purpose */
typedef struct _wlan_dbg {
	/** Number of host to card command failures */
	t_u32 num_cmd_host_to_card_failure;
	/** Number of host to card sleep confirm failures */
	t_u32 num_cmd_sleep_cfm_host_to_card_failure;
	/** Number of host to card Tx failures */
	t_u32 num_tx_host_to_card_failure;
	/** Number of card to host command/event failures */
	t_u32 num_cmdevt_card_to_host_failure;
	/** Number of card to host Rx failures */
	t_u32 num_rx_card_to_host_failure;
	/** Number of interrupt read failures */
	t_u32 num_int_read_failure;
	/** Last interrupt status */
	t_u32 last_int_status;
	/** Number of allocate buffer failure */
	t_u32 num_alloc_buffer_failure;
	/** Number of pkt dropped */
	t_u32 num_pkt_dropped;
	/** Number of deauthentication events */
	t_u32 num_event_deauth;
	/** Number of disassosiation events */
	t_u32 num_event_disassoc;
	/** Number of link lost events */
	t_u32 num_event_link_lost;
	/** Number of deauthentication commands */
	t_u32 num_cmd_deauth;
	/** Number of association comamnd successes */
	t_u32 num_cmd_assoc_success;
	/** Number of association command failures */
	t_u32 num_cmd_assoc_failure;
	/** Number of consecutive association command failures */
	t_u32 num_cons_assoc_failure;

	/** Timeout command ID */
	t_u16 timeout_cmd_id;
	/** Timeout command action */
	t_u16 timeout_cmd_act;
	/** List of last command IDs */
	t_u16 last_cmd_id[DBG_CMD_NUM];
	/** List of last command actions */
	t_u16 last_cmd_act[DBG_CMD_NUM];
	/** Last command index */
	t_u16 last_cmd_index;
	/** List of last command response IDs */
	t_u16 last_cmd_resp_id[DBG_CMD_NUM];
	/** Last command response index */
	t_u16 last_cmd_resp_index;
	/** List of last events */
	t_u16 last_event[DBG_CMD_NUM];
	/** Last event index */
	t_u16 last_event_index;
	/** Number of no free command node */
	t_u16 num_no_cmd_node;
} wlan_dbg;

/** Hardware status codes */
typedef enum _WLAN_HARDWARE_STATUS {
	WlanHardwareStatusReady,
	WlanHardwareStatusGetHwSpec,
	WlanHardwareStatusGetHwSpecdone,
	WlanHardwareStatusInitializing,
	WlanHardwareStatusInitdone,
	WlanHardwareStatusReset,
	WlanHardwareStatusClosing,
	WlanHardwareStatusNotReady
} WLAN_HARDWARE_STATUS;

/** WLAN_802_11_POWER_MODE */
typedef enum _WLAN_802_11_POWER_MODE {
	Wlan802_11PowerModeCAM,
	Wlan802_11PowerModePSP
} WLAN_802_11_POWER_MODE;

/** tx param */
typedef struct _mlan_tx_param {
	/** next packet length */
	t_u32 next_pkt_len;
} mlan_tx_param;

/** PS_STATE */
typedef enum _PS_STATE {
	PS_STATE_AWAKE,
	PS_STATE_PRE_SLEEP,
	PS_STATE_SLEEP_CFM,
	PS_STATE_SLEEP
} PS_STATE;

/** Minimum flush timer for win size of 1 is 50 ms */
#define MIN_FLUSH_TIMER_MS 50
/** Minimum flush timer for win size of 1 is 15 ms */
#define MIN_FLUSH_TIMER_15_MS 15

/** Tx BA stream table */
typedef struct _TxBAStreamTbl TxBAStreamTbl;

/** Add BA parameter data structure */
typedef struct {
	/** Window size for initiator */
	t_u32 tx_win_size;
	/** Window size for receiver */
	t_u32 rx_win_size;
	/** Block ack timeout */
	t_u32 timeout;
	/** amsdu support for ADDBA request */
	t_u8 tx_amsdu;
	/** amsdu support for ADDBA response */
	t_u8 rx_amsdu;
} add_ba_param_t;

/** Tx aggregation data structure */
typedef struct _txAggr_t {
	/** AMPDU user */
	t_u8 ampdu_user;
	/** AMPDU AP */
	t_u8 ampdu_ap;
	/** AMSDU */
	t_u8 amsdu;
} tx_aggr_t;

/** del ba threshold */
#define DEL_BA_THRESHOLD 10
/** BA stream status */
typedef enum _baStatus_e {
	BA_STREAM_NOT_SETUP = 0,
	BA_STREAM_SETUP_INPROGRESS,
	BA_STREAM_SETUP_COMPLETE
} baStatus_e;

/** RA list table */
typedef struct _raListTbl raListTbl, *praListTbl;

/** RA list table */
struct _raListTbl {
	/** Pointer to previous node */
	raListTbl *pprev;
	/** Pointer to next node */
	raListTbl *pnext;
	/** Buffer list head */
	mlan_list_head buf_head;
	/** RA list buffer */
	t_u8 ra[MLAN_MAC_ADDR_LENGTH];
	/** total packets in RA list */
	t_u16 total_pkts;
	/** packets received */
	t_u16 packet_count;
	/** packet count threshold to setup BA */
	t_u8 ba_packet_threshold;
	/** is 11n enabled */
	t_u8 is_11n_enabled;
	/** max amsdu size */
	t_u16 max_amsdu;
	/** BA stream status */
	baStatus_e ba_status;
	/** del ba count */
	t_u8 del_ba_count;
	/** amsdu in ampdu flag */
	t_u8 amsdu_in_ampdu;
	/** tx_pause flag */
	t_u8 tx_pause;
};

/** TID table */
typedef struct _tidTbl {
	/** RA list head */
	mlan_list_head ra_list;
	/** Current RA list */
	raListTbl *ra_list_curr;
} tid_tbl_t;

/** Highest priority setting for a packet (uses voice AC) */
#define WMM_HIGHEST_PRIORITY 7
/** Highest priority TID  */
#define HIGH_PRIO_TID 7
/** Lowest priority TID  */
#define LOW_PRIO_TID 0
/** No packet priority (< lowest) */
#define NO_PKT_PRIO_TID -1

/** Max driver packet delay in msec */
#define WMM_DRV_DELAY_MAX 510

/** Struct of WMM DESC */
typedef struct _wmm_desc {
	/** TID table */
	tid_tbl_t tid_tbl_ptr[MAX_NUM_TID];
	/** Packets out */
	t_u32 packets_out[MAX_NUM_TID];
	/** Packets queued */
	t_u32 pkts_queued[MAX_NUM_TID];
	/** Packets paused */
	t_u32 pkts_paused[MAX_NUM_TID];
	/** Spin lock to protect ra_list */
	t_void *ra_list_spinlock;

	/** AC status */
	WmmAcStatus_t ac_status[MAX_AC_QUEUES];
	/** AC downgraded values */
	mlan_wmm_ac_e ac_down_graded_vals[MAX_AC_QUEUES];

	/** Max driver packet delay sent to the firmware for expiry eval */
	t_u32 drv_pkt_delay_max;

	/** WMM queue priority table */
	t_u8 queue_priority[MAX_AC_QUEUES];
	/** User priority packet transmission control */
	t_u32 user_pri_pkt_tx_ctrl[WMM_HIGHEST_PRIORITY + 1]; /* UP: 0 to 7 */

	/** Number of transmit packets queued */
	mlan_scalar tx_pkts_queued;
	/** Tracks highest priority with a packet queued */
	mlan_scalar highest_queued_prio;
} wmm_desc_t;

/** Security structure */
typedef struct _wlan_802_11_security_t {
	/** WPA enabled flag */
	t_u8 wpa_enabled;
	/** E-Supplicant enabled flag */
	t_u8 ewpa_enabled;
	/** WPA2 enabled flag */
	t_u8 wpa2_enabled;
	/** WAPI enabled flag */
	t_u8 wapi_enabled;
	/** WAPI key on flag */
	t_u8 wapi_key_on;
	/** WEP status */
	WLAN_802_11_WEP_STATUS wep_status;
	/** Authentication mode */
	t_u32 authentication_mode;
	/** Encryption mode */
	t_u32 encryption_mode;
	/** Hotspot OSEN enabled */
	t_u8 osen_enabled;
} wlan_802_11_security_t;

/** Current Basic Service Set State Structure */
typedef struct {
	/** BSS descriptor */
	BSSDescriptor_t bss_descriptor;
	/** WMM enable? */
	t_u8 wmm_enabled;
	/** Uapsd enable?*/
	t_u8 wmm_uapsd_enabled;
	/** Band */
	t_u8 band;
	/** Number of rates supported */
	t_u32 num_of_rates;
	/** Supported rates*/
	t_u8 data_rates[WLAN_SUPPORTED_RATES];
	/** Host MLME flag*/
	t_u8 host_mlme;
	t_u8 use_mfp;
} current_bss_params_t;

/** Sleep_params */
typedef struct _sleep_params_t {
	/** Sleep parameter error */
	t_u16 sp_error;
	/** Sleep parameter offset */
	t_u16 sp_offset;
	/** Sleep parameter stable time */
	t_u16 sp_stable_time;
	/** Sleep parameter calibration control */
	t_u8 sp_cal_control;
	/** Sleep parameter external sleep clock */
	t_u8 sp_ext_sleep_clk;
	/** Sleep parameter reserved */
	t_u16 sp_reserved;
} sleep_params_t;

/** Sleep_period */
typedef struct sleep_period_t {
	/** Sleep period */
	t_u16 period;
	/** Reserved */
	t_u16 reserved;
} sleep_period_t;

/** mrvl_wep_key_t */
typedef struct _mrvl_wep_key_t {
	/** Length */
	t_u32 length;
	/** WEP key index */
	t_u32 key_index;
	/** WEP key length */
	t_u32 key_length;
	/** WEP keys */
	t_u8 key_material[MRVL_KEY_BUFFER_SIZE_IN_BYTE];
} mrvl_wep_key_t;

/** Maximum number of region channel */
#define MAX_REGION_CHANNEL_NUM 2

/** Region-band mapping table */
typedef struct _region_chan_t {
	/** TRUE if this entry is valid */
	t_u8 valid;
	/** Region code for US, Japan ... */
	t_u8 region;
	/** Band B/G/A, used for BAND_CONFIG cmd */
	t_u8 band;
	/** Actual No. of elements in the array below */
	t_u8 num_cfp;
	/** chan-freq-txpower mapping table */
	chan_freq_power_t *pcfp;
} region_chan_t;

/** State of 11d */
typedef enum _state_11d_t {
	DISABLE_11D = 0,
	ENABLE_11D = 1,
} state_11d_t;

#define DEFAULT_11D_STATE DISABLE_11D

/** Domain regulatory information */
typedef struct _wlan_802_11d_domain_reg {
	/** Country Code */
	t_u8 country_code[COUNTRY_CODE_LEN];
	/** band that channels in sub_band belong to */
	t_u8 band;
	/** No. of subband in below */
	t_u8 no_of_sub_band;
	/** Subband data to send/last sent */
	IEEEtypes_SubbandSet_t sub_band[MRVDRV_MAX_SUBBAND_802_11D];
} wlan_802_11d_domain_reg_t;

/** Data for state machine */
typedef struct _wlan_802_11d_state {
	/** True for enabling 11D */
	state_11d_t enable_11d;
	/** True for user enabling 11D */
	state_11d_t user_enable_11d;
} wlan_802_11d_state_t;

/** 802.11h State information kept in the 'mlan_private' driver structure */
typedef struct {
	/** Indicate 11h is enabled from host */
	t_bool is_11h_host;
	/** Indicates whether 11h is enabled in the driver */
	t_bool is_11h_enabled;
	/** Indicates whether 11h is active in the firmware */
	t_bool is_11h_active;
	/** Master device using automatic channel select */
	t_bool adhoc_auto_sel_chan;
	/** Set when driver receives a STOP TX event from fw */
	t_bool tx_disabled;
	/** Channel that ChanSwAnn was received for, non-zero = active */
	t_u8 dfs_slave_csa_chan;
	/** Expiry for above variable, seconds in system time */
	t_u32 dfs_slave_csa_expire_at_sec;
} wlan_11h_interface_state_t;

#if defined(UAP_SUPPORT)
/** UAP get info callback state kept in the 'mlan_private' driver structure */
typedef struct {
	/** UAP internal callback after wlan_uap_get_channel */
	/**  (parameter is really pointer to mlan_private)   */
	mlan_status (*get_chan_callback)(t_void *);
	/** current ioctl_req (to be completed in callback) */
	pmlan_ioctl_req pioctl_req_curr;
	/** band config from MrvlIEtypes_channel_band_t */
	Band_Config_t bandcfg;
	/** channel from MrvlIEtypes_channel_band_t */
	t_u8 channel;
	/** beacon period (in msec) from MrvlIEtypes_beacon_period_t */
	t_u16 beacon_period;
	/** dtim period (no unit) from MrvlIEtypes_dtim_period_t */
	t_u8 dtim_period;
} wlan_uap_get_info_cb_t;
#endif

/** Data structure for WPS information */
typedef struct {
	/** WPS IE */
	IEEEtypes_VendorSpecific_t wps_ie;
	/** Session enable flag */
	t_u8 session_enable;
} wps_t;

/** mlan_operations data structure */
typedef struct _mlan_operations {
	/** cmd init handler */
	mlan_status (*init_cmd)(t_void *priv, t_u8 first_bss);
	/** ioctl handler */
	mlan_status (*ioctl)(t_void *adapter, pmlan_ioctl_req pioctl_req);
	/** cmd handler */
	mlan_status (*prepare_cmd)(t_void *priv, t_u16 cmd_no, t_u16 cmd_action,
				   t_u32 cmd_oid, t_void *pioctl_buf,
				   t_void *pdata_buf, t_void *pcmd_buf);
	/** cmdresp handler */
	mlan_status (*process_cmdresp)(t_void *priv, t_u16 cmdresp_no,
				       t_void *pcmd_buf, t_void *pioctl);
	/** rx handler */
	mlan_status (*process_rx_packet)(t_void *adapter, pmlan_buffer pmbuf);
	/** event handler */
	mlan_status (*process_event)(t_void *priv);
	/** txpd handler */
	t_void *(*process_txpd)(t_void *priv, pmlan_buffer pmbuf);
	/** BSS role */
	mlan_bss_role bss_role;
} mlan_operations, *pmlan_operations;

/** Private structure for MLAN */
typedef struct _mlan_private {
	/** Pointer to mlan_adapter */
	struct _mlan_adapter *adapter;
	/** BSS index */
	t_u8 bss_index;
	/** BSS type */
	t_u8 bss_type;
	/** BSS role */
	t_u8 bss_role;
	/** BSS virtual flag */
	t_u8 bss_virtual;
	/** BSS Priority */
	t_u8 bss_priority;
	/** BSS number */
	t_u8 bss_num;
	/** Frame type */
	t_u8 frame_type;
	/** MAC address information */
	t_u8 curr_addr[MLAN_MAC_ADDR_LENGTH];
	/** Media connection status */
	t_bool media_connected;

	/** Current packet filter */
	t_u32 curr_pkt_filter;
	/** Infrastructure mode */
	t_u32 bss_mode;

	/** Tx packet control */
	t_u32 pkt_tx_ctrl;

	/** Tx power level */
	t_s16 tx_power_level;
	/** Maximum Tx power level */
	t_s8 max_tx_power_level;
	/** Minimum Tx power level */
	t_s8 min_tx_power_level;
	/** Tx rate */
	t_u8 tx_rate;
	t_u8 tx_rate_info;
	/*HE tx tone mode and DCM info*/
	t_u8 ext_tx_rate_info;
	/*HE rx tone mode and DCM info*/
	t_u8 rxpd_rx_info;
	/** rxpd_htinfo */
	t_u8 rxpd_rate_info;
	/** max amsdu size */
	t_u16 max_amsdu;
	/** amsdu disable flag */
	t_u8 amsdu_disable;
	/** 802.11n Device Capabilities for 2.4GHz */
	t_u32 usr_dot_11n_dev_cap_bg;
	/** 802.11n Device Capabilities for 5GHz */
	t_u32 usr_dot_11n_dev_cap_a;
	/** MIMO abstraction of MCSs supported by device */
	t_u8 usr_dev_mcs_support;
#ifdef UAP_SUPPORT
	/** UAP 11n flag */
	t_u8 is_11n_enabled;
#endif /* UAP_SUPPORT */
	/** UAP 11ac flag */
	t_u8 is_11ac_enabled;
	/** UAP 11ax flag */
	t_u8 is_11ax_enabled;
	/** tx vht_info */
	t_u8 tx_vhtinfo;
	/** rxpd_vhtinfo */
	t_u8 rxpd_vhtinfo;
	/** 802.11ac Device Capabilities for 2.4GHz */
	t_u32 usr_dot_11ac_dev_cap_bg;
	/** 802.11ac Device Capabilities for 5GHz */
	t_u32 usr_dot_11ac_dev_cap_a;
	/** MIMO abstraction of MCSs supported by device */
	t_u32 usr_dot_11ac_mcs_support;
	/** user dot 11ac_BW */
	t_u8 usr_dot_11ac_bw;
	/** user dot 11ac_opermode_BW */
	t_u8 usr_dot_11ac_opermode_bw;
	/** user dot 11ac_opermode_nss */
	t_u8 usr_dot_11ac_opermode_nss;
	/** length of hw he capability */
	t_u8 user_hecap_len;
	/** user configured 802.11ax HE capability */
	t_u8 user_he_cap[54];
	/** length of hw he capability */
	t_u8 user_2g_hecap_len;
	/** user configured 802.11ax HE capability */
	t_u8 user_2g_he_cap[54];
	/**  dropped pkts */
	t_u32 num_drop_pkts;
#ifdef UAP_SUPPORT
	/** packet forward control */
	t_u8 pkt_fwd;
#endif
	/** TX beamforming capability */
	t_u32 tx_bf_cap;
	/** Rx PD rate */
	t_u8 rxpd_rate;
	/** Bitmap rates */
	t_u16 bitmap_rates[MAX_BITMAP_RATES_SIZE];
	/** Data rate */
	t_u32 data_rate;
	/** Automatic data rate flag */
	t_u8 is_data_rate_auto;
	/** Factor for calculating beacon average */
	t_u16 bcn_avg_factor;
	/** Factor for calculating data average */
	t_u16 data_avg_factor;
	/** SNR */
	t_s8 snr;
	/** Noise Floor */
	t_s8 nf;
	/** Last data RSSI */
	t_s16 data_rssi_last;
	/** Last data Noise Floor */
	t_s16 data_nf_last;
	/** Average data RSSI */
	t_s16 data_rssi_avg;
	/** Averag data Noise Floor */
	t_s16 data_nf_avg;
	/** Last beacon RSSI */
	t_s16 bcn_rssi_last;
	/** Last beacon Noise Floor */
	t_s16 bcn_nf_last;
	/** Average beacon RSSI */
	t_s16 bcn_rssi_avg;
	/** Average beacon Noise Floor */
	t_s16 bcn_nf_avg;
	/** Attempted BSS descriptor */
	BSSDescriptor_t *pattempted_bss_desc;

	/** GTK rekey data*/
	mlan_ds_misc_gtk_rekey_data gtk_rekey;

	/** Current SSID/BSSID related parameters*/
	current_bss_params_t curr_bss_params;
	/** current channel flags */
	t_u32 curr_chan_flags;
	/** User selected bands */
	t_u16 config_bands;

	/** Beacon period */
	t_u16 beacon_period;
	/** Listen interval */
	t_u16 listen_interval;
	/** ATIM window */
	t_u16 atim_window;

	/** AdHoc channel */
	t_u8 adhoc_channel;
	/** AdHoc link sensed flag */
	t_u8 adhoc_is_link_sensed;
	/** AdHoc operating state */
	t_u8 adhoc_state;
#if defined(STA_SUPPORT)
	/** AdHoc operating state backup */
	t_u8 adhoc_state_prev;
	/** AdHoc previous ssid used for Start */
	mlan_802_11_ssid adhoc_last_start_ssid;
#endif
	/** FSM variable for 11d support */
	wlan_802_11d_state_t state_11d;
	/** FSM variable for 11h support */
	wlan_11h_interface_state_t intf_state_11h;
#ifdef UAP_SUPPORT
	/** Whether UAP interface has started */
	t_bool uap_bss_started;
	/** Whether UAP interface start from hostapd */
	t_bool uap_host_based;
	/**UAP operating channel*/
	t_u8 uap_channel;
	/** state variable for UAP Get Info callback */
	wlan_uap_get_info_cb_t uap_state_chan_cb;
#endif /* UAP_SUPPORT */

	/** Security related */
	/** Encryption parameter */
	wlan_802_11_security_t sec_info;
	/** WEP keys */
	mrvl_wep_key_t wep_key[MRVL_NUM_WEP_KEY];
	/** Current WEP key index */
	t_u16 wep_key_curr_index;
	/** EWPA query 0: disable, 1: enable */
	t_u8 ewpa_query;
	/** Encryption Key*/
	t_u8 wpa_ie[256];
	/** WPA IE length */
	t_u8 wpa_ie_len;
	/** GTK set flag */
	t_u8 wpa_is_gtk_set;
	/** AES key material */
	mlan_ds_encrypt_key aes_key;
#if defined(STA_SUPPORT)
	/* Mgmt Frame Protection config */
	mlan_ds_misc_pmfcfg pmfcfg;
#endif
	/** WAPI IE */
	t_u8 wapi_ie[256];
	/** WAPI IE length */
	t_u8 wapi_ie_len;
	/** OSEN IE */
	t_u8 osen_ie[256];
	/** OSEN IE length */
	t_u8 osen_ie_len;
	/** Pointer to the station table */
	mlan_list_head sta_list;

	/** MGMT IE */
	custom_ie mgmt_ie[MAX_MGMT_IE_INDEX];
	/** mgmt frame passthru mask */
	t_u32 mgmt_frame_passthru_mask;
	/** WMM required */
	t_u8 wmm_required;
	/** WMM enabled */
	t_u8 wmm_enabled;
	/** WMM qos info */
	t_u8 wmm_qosinfo;
	/** WMM related variable*/
	wmm_desc_t wmm;

	/** Pointer to the Transmit BA stream table*/
	mlan_list_head tx_ba_stream_tbl_ptr;
	/** Pointer to the priorities for AMSDU/AMPDU table*/
	tx_aggr_t aggr_prio_tbl[MAX_NUM_TID];
	/** Pointer to the priorities for AMSDU/AMPDU table*/
	t_u8 addba_reject[MAX_NUM_TID];
	/** Pointer to the priorities for AMSDU/AMPDU table*/
	t_u8 ibss_ampdu[MAX_NUM_TID];
	/** Pointer to the priorities for AMSDU/AMPDU table*/
	t_u8 ibss_addba_reject[MAX_NUM_TID];
	/** Struct to store ADDBA parameters */
	add_ba_param_t add_ba_param;
	/**  user rx_win_size */
	t_u32 user_rxwinsize;
	/** last rx_seq */
	t_u16 rx_seq[MAX_NUM_TID];
	/** Pointer to the Receive Reordering table*/
	mlan_list_head rx_reorder_tbl_ptr;
	/** Lock for Rx packets */
	t_void *rx_pkt_lock;

#ifdef STA_SUPPORT
	/** Buffer to store the association response for application retrieval
	 */
	t_u8 assoc_rsp_buf[MRVDRV_ASSOC_RSP_BUF_SIZE];
	/** Length of the data stored in assoc_rsp_buf */
	t_u32 assoc_rsp_size;

	/** Generic IEEE IEs passed from the application to be inserted into the
	 *    association request to firmware
	 */
	t_u8 gen_ie_buf[MRVDRV_GENIE_BUF_SIZE];
	/** Length of the data stored in gen_ie_buf */
	t_u8 gen_ie_buf_len;

	/** disconnect reason code*/
	t_u16 disconnect_reason_code;
	t_u8 *pcurr_bcn_buf;
	t_u32 curr_bcn_size;
	t_void *curr_bcn_buf_lock;

	/** WPS */
	wps_t wps;
#endif /* STA_SUPPORT */

	/** function table */
	mlan_operations ops;
	/** tx pause flag */
	t_u8 tx_pause;
	/** Port Control mode */
	t_u8 port_ctrl_mode;

	/** Port open flag */
	t_u8 port_open;

	/** Port open flag state at time of association attempt */
	t_u8 prior_port_status;
	/** Bypass TX queue */
	mlan_list_head bypass_txq;
	/** IP address operation */
	t_u32 op_code;
	/** IP address */
	t_u8 ip_addr[IPADDR_LEN];
	t_u32 hotspot_cfg;
#ifdef STA_SUPPORT
	ExtCap_t ext_cap;
	ExtCap_t def_ext_cap;
#endif
	/** interface header len */
	t_u8 intf_hr_len;
#ifdef USB
	/** USB data port */
	t_u32 port;
#endif
#if defined(DRV_EMBEDDED_AUTHENTICATOR) || defined(DRV_EMBEDDED_SUPPLICANT)
	t_void *psapriv;
#endif
	/** rx per packet info */
	t_u8 rx_pkt_info;
	/** received amsdu count*/
	t_u32 amsdu_rx_cnt;
	/** received msdu count in amsdu*/
	t_u32 msdu_in_rx_amsdu_cnt;
	/** tx amsdu count*/
	t_u32 amsdu_tx_cnt;
	/** tx msdu count in amsdu*/
	t_u32 msdu_in_tx_amsdu_cnt;
} mlan_private, *pmlan_private;

typedef struct _assoc_logger {
	/** vendor specific */
	t_u8 oui[3];
	t_u8 bssid[MLAN_MAC_ADDR_LENGTH];
	t_u8 ssid[MLAN_MAX_SSID_LENGTH];
	t_s32 rssi;
	t_u32 channel;
} assoc_logger_data;

/** Tx BA stream table */
struct _TxBAStreamTbl {
	/** TxBAStreamTbl previous node */
	TxBAStreamTbl *pprev;
	/** TxBAStreamTbl next node */
	TxBAStreamTbl *pnext;
	/** TID */
	int tid;
	/** RA */
	t_u8 ra[MLAN_MAC_ADDR_LENGTH];
	/** BA stream status */
	baStatus_e ba_status;
	t_u8 amsdu;
};

/** RX reorder table */
typedef struct _RxReorderTbl RxReorderTbl;

typedef struct {
	/** Timer for flushing */
	t_void *timer;
	/** Timer set flag */
	t_u8 timer_is_set;
	/** RxReorderTbl ptr */
	RxReorderTbl *ptr;
	/** Priv pointer */
	mlan_private *priv;
} reorder_tmr_cnxt_t;

/** RX reorder table */
struct _RxReorderTbl {
	/** RxReorderTbl previous node */
	RxReorderTbl *pprev;
	/** RxReorderTbl next node */
	RxReorderTbl *pnext;
	/** TID */
	int tid;
	/** TA */
	t_u8 ta[MLAN_MAC_ADDR_LENGTH];
	/** Start window */
	int start_win;
	/** last_seq */
	int last_seq;
	/** Window size */
	int win_size;
	/** Pointer to pointer to RxReorderTbl */
	t_void **rx_reorder_ptr;
	/** Timer context */
	reorder_tmr_cnxt_t timer_context;
	/** BA stream status */
	baStatus_e ba_status;
	t_u8 amsdu;
	/** no packet drop flag for rx_reorder_tbl */
	t_u8 force_no_drop;
	/** flag for check start win */
	t_u8 check_start_win;
	/** pkt receive after BA setup */
	t_u8 pkt_count;
	/** flush data flag */
	t_u8 flush_data;
};

/** BSS priority node */
typedef struct _mlan_bssprio_node mlan_bssprio_node;

/** BSS priority node */
struct _mlan_bssprio_node {
	/** Pointer to previous node */
	mlan_bssprio_node *pprev;
	/** Pointer to next node */
	mlan_bssprio_node *pnext;
	/** Pointer to priv */
	pmlan_private priv;
};

/** BSS priority table */
typedef struct _mlan_bssprio_tbl mlan_bssprio_tbl;

/** BSS priority table */
struct _mlan_bssprio_tbl {
	/** BSS priority list head */
	mlan_list_head bssprio_head;
	/** Current priority node */
	mlan_bssprio_node *bssprio_cur;
};

/** cmd_ctrl_node */
typedef struct _cmd_ctrl_node cmd_ctrl_node;

/** _cmd_ctrl_node */
struct _cmd_ctrl_node {
	/** Pointer to previous node */
	cmd_ctrl_node *pprev;
	/** Pointer to next node */
	cmd_ctrl_node *pnext;
	/** Pointer to priv */
	pmlan_private priv;
	/** Command number */
	t_u32 cmd_no;
	/** Command flag */
	t_u32 cmd_flag;
	/** Pointer to mlan_buffer */
	mlan_buffer *cmdbuf;
	/** Pointer to mlan_buffer */
	mlan_buffer *respbuf;
	/** Command parameter */
	t_void *pdata_buf;
	/** Pointer to mlan_ioctl_req if command is from IOCTL */
	t_void *pioctl_buf;
#if defined(PCIE) || defined(SDIO)
	/** pre_allocated mlan_buffer for cmd */
	mlan_buffer *pmbuf;
#endif
};

/** station node */
typedef struct _sta_node sta_node, *psta_node;

/** station node*/
struct _sta_node {
	/** previous node */
	sta_node *pprev;
	/** next node */
	sta_node *pnext;
	/** station mac address */
	t_u8 mac_addr[MLAN_MAC_ADDR_LENGTH];
	/** wmm flag */
	t_u8 is_wmm_enabled;
	/** 11n flag */
	t_u8 is_11n_enabled;
	/** AMPDU STA */
	t_u8 ampdu_sta[MAX_NUM_TID];
	/** last rx_seq */
	t_u16 rx_seq[MAX_NUM_TID];
	/** max amsdu size */
	t_u16 max_amsdu;
	/** HT cap */
	IEEEtypes_HTCap_t HTcap;
	/** 11ac flag */
	t_u8 is_11ac_enabled;
	/** UAP 11ax flag */
	t_u8 is_11ax_enabled;
	/** SNR */
	t_s8 snr;
	/** Noise Floor */
	t_s8 nf;
	/** peer capability */
	t_u16 capability;
	/** wapi key on off flag */
	t_u8 wapi_key_on;
	/** tx pause status */
	t_u8 tx_pause;
	/** station band mode */
	t_u16 bandmode;
#if defined(DRV_EMBEDDED_AUTHENTICATOR) || defined(DRV_EMBEDDED_SUPPLICANT)
	t_void *cm_connectioninfo;
#endif
	sta_stats stats;
};

/** 802.11h State information kept in the 'mlan_adapter' driver structure */
typedef struct {
	/** Min TX Power capability sent to FW for 11h use and fw power control
	 */
	t_s8 min_tx_power_capability;
	/** Max TX Power capability sent to FW for 11h use and fw power control
	 */
	t_s8 max_tx_power_capability;
	/** User provisioned local power constraint sent in association requests
	 */
	t_s8 usr_def_power_constraint;
	/** Received CHANNEL_SWITCH_ANN event */
	t_bool recvd_chanswann_event;
	/** Indicates an interface wants to enable master radar detection */
	t_bool master_radar_det_enable_pending;
	/** Indicates an interface wants to enable slave radar detection */
	t_bool slave_radar_det_enable_pending;
	/** Indicates whether master radar detection active in the firmware */
	t_bool is_master_radar_det_active;
	/** Indicates whether slave radar detection active in the firmware */
	t_bool is_slave_radar_det_active;
	/** Quiet IE */
	IEEEtypes_Quiet_t quiet_ie;
} wlan_11h_device_state_t;

/** Enumeration for DFS Timestamp represents field */
enum _dfs_timestamp_repr_e {
	/** Ignore entry */
	DFS_TS_REPR_NOT_IN_USE = 0,
	/** NOP (Non-Occupancy Period) start time */
	DFS_TS_REPR_NOP_START = 1,
	/** CAC (Channel Availability Check) completion time */
	DFS_TS_REPR_CAC_COMPLETION
};

/** DFS Timestamp type used for marking NOP/CAC events */
typedef struct _wlan_dfs_timestamp_t wlan_dfs_timestamp_t;

/** DFS Timestamp type used for marking NOP/CAC events */
struct _wlan_dfs_timestamp_t {
	/** Pointer to previous node */
	wlan_dfs_timestamp_t *pprev;
	/** Pointer to next node */
	wlan_dfs_timestamp_t *pnext;
	/** WLAN Channel number */
	t_u8 channel;
	/** What this timestamp represents */
	t_u8 represents;
	/** reserved field */
	t_u16 reserved;
	/** timestamp - seconds */
	t_u32 ts_sec;
	/** timestamp - microseconds */
	t_u32 ts_usec;
};

/** DFS State information kept in the 'mlan_adapter' driver structure */
typedef struct {
	/** Indicates whether DFS channel check is occurring in firmware */
	t_bool dfs_check_pending;
	/** Indicates whether DFS channel check found radar */
	t_bool dfs_radar_found;
	/** Channel radar is being checked on.  BAND_A is assumed. */
	t_u8 dfs_check_channel;
	/** point to the priv which start the DFS check */
	t_void *dfs_check_priv;
	/** Timestamp when we got last report,
	 * to determine if data is old or not.
	 */
	t_u32 dfs_report_time_sec;
	/** List for holding dfs_timestamps for NOP/CAC events */
	mlan_list_head dfs_ts_head;
} wlan_dfs_device_state_t;

/** Enumeration for mlan_ds_11h_radar_det_hndlg stages */
enum _mlan_ds_11h_rdh_stages {
	RDH_OFF = 0,
	RDH_CHK_INTFS = 1,
	RDH_STOP_TRAFFIC,
	RDH_GET_INFO_CHANNEL,
	RDH_GET_INFO_BEACON_DTIM,
	RDH_SET_CUSTOM_IE,
	RDH_REM_CUSTOM_IE,
	RDH_STOP_INTFS,
	RDH_SET_NEW_CHANNEL,
	RDH_RESTART_INTFS,
	RDH_RESTART_TRAFFIC
};

/** State info for Radar Detected Handling kept in 'mlan_adapter' */
typedef struct {
	/** Stage (of Operation) */
	t_u8 stage;
	/** Number of interfaces to handle */
	t_u8 priv_list_count;
	/** Index of interface in process (used by some stages) */
	t_u8 priv_curr_idx;
	/** Current Channel (to leave) */
	t_u8 curr_channel;
	/** New Channel (to switch to) */
	t_u8 new_channel;
	/** UAP band_config */
	Band_Config_t uap_band_cfg;
	/** BEACON*DTIM period (in msec; max of STA/UAP) */
	t_u16 max_bcn_dtim_ms;
	/** tx block flag */
	t_u8 tx_block;
	/** List of interfaces to handle */
	mlan_private *priv_list[MLAN_MAX_BSS_NUM];
} wlan_radar_det_hndlg_state_t;

/** DFS/RDH testing exception settings kept in 'mlan_adapter' */
typedef struct {
	/** user-configured CAC period (in msec) */
	t_u32 user_cac_period_msec;
	/** user-configured NOP period (in sec) */
	t_u16 user_nop_period_sec;
	/** user-configured skip channel change on radar */
	t_bool no_channel_change_on_radar;
	/** user-configured new channel to change to on radar */
	t_u8 fixed_new_channel_on_radar;
} wlan_dfs_testing_settings_t;

/**
 * @brief Driver measurement state held in 'mlan_adapter' structure
 *
 *  Used to record a measurement request that the driver is pending on
 *    the result (received measurement report).
 */
typedef struct {
	/**
	 * Dialog token of a pending measurement request/report.  Used to
	 *   block execution while waiting for the specific dialog token
	 */
	t_u8 meas_rpt_pend_on;

	/**
	 * Measurement report received from the firmware that we were pending on
	 */
	HostCmd_DS_MEASUREMENT_REPORT meas_rpt_returned;

} wlan_meas_state_t;

#ifdef SDIO
/**
 *  @brief Link buffer into aggregate head buffer
 *
 *  @param pmbuf_aggr	Pointer to aggregation buffer
 *  @param pmbuf		Pointer to buffer to copy
 */
static inline t_void wlan_link_buf_to_aggr(pmlan_buffer pmbuf_aggr,
					   pmlan_buffer pmbuf)
{
	/* link new buf at end of list */
	pmbuf->pnext = pmbuf_aggr;
	pmbuf->pprev = pmbuf_aggr->pprev;
	pmbuf->pparent = pmbuf_aggr;
	pmbuf_aggr->pprev->pnext = pmbuf;
	pmbuf_aggr->pprev = pmbuf;
	pmbuf_aggr->use_count++;
}

/** data structure for SDIO MPA TX */
typedef struct _sdio_mpa_tx {
	/** allocated buf for tx aggreation */
	t_u8 *head_ptr;
	/** multiport tx aggregation buffer pointer */
	t_u8 *buf;
	/** multiport tx aggregation buffer length */
	t_u32 buf_len;
	/** multiport tx aggregation packet count */
	t_u32 pkt_cnt;
	/** multiport tx aggregation ports */
	t_u32 ports;
	/** multiport tx aggregation starting port */
	t_u16 start_port;
	/** multiport tx aggregation enable/disable flag */
	t_u8 enabled;
	/** multiport tx aggregation buffer size */
	t_u32 buf_size;
	/** multiport tx aggregation pkt aggr limit */
	t_u32 pkt_aggr_limit;
	/** multiport write info */
	t_u16 mp_wr_info[SDIO_MP_AGGR_DEF_PKT_LIMIT_MAX];
	/** multiport rx aggregation mbuf array */
	pmlan_buffer mbuf_arr[SDIO_MP_AGGR_DEF_PKT_LIMIT_MAX];
} sdio_mpa_tx;

/** data structure for SDIO MPA RX */
typedef struct _sdio_mpa_rx {
	/** allocated buf for rx aggreation */
	t_u8 *head_ptr;
	/** multiport rx aggregation buffer pointer */
	t_u8 *buf;
	/** multiport rx aggregation buffer length */
	t_u32 buf_len;
	/** multiport rx aggregation packet count */
	t_u32 pkt_cnt;
	/** multiport rx aggregation ports */
	t_u32 ports;
	/** multiport rx aggregation starting port */
	t_u16 start_port;

	/** multiport rx aggregation mbuf array */
	pmlan_buffer mbuf_arr[SDIO_MP_AGGR_DEF_PKT_LIMIT_MAX];
	/** multiport rx aggregation pkt len array */
	t_u32 len_arr[SDIO_MP_AGGR_DEF_PKT_LIMIT_MAX];

	/** multiport rx aggregation enable/disable flag */
	t_u8 enabled;
	/** multiport rx aggregation buffer size */
	t_u32 buf_size;
	/** multiport rx aggregation pkt aggr limit */
	t_u32 pkt_aggr_limit;
} sdio_mpa_rx;
#endif

#ifdef USB
/** data structure for USB Rx Deaggregation */
typedef struct _usb_rx_deaggr_params {
	/** Rx aggregation control */
	usb_aggr_ctrl aggr_ctrl;
} usb_rx_deaggr_params;

#define MAX_USB_TX_PORT_NUM 1
/** data structure for USB Tx Aggregation */
typedef struct _usb_tx_aggr_params {
	/** Tx aggregation control */
	usb_aggr_ctrl aggr_ctrl;
	/** allocated pmbuf for tx aggreation */
	pmlan_buffer pmbuf_aggr;
	/** packet len used in pmbuf_aggr */
	t_u32 aggr_len;
	/** usb_tx_aggr timer */
	t_void *paggr_hold_timer;
	/** usb_tx_aggr timer set flag */
	t_u8 aggr_hold_timer_is_set;
	/** Timeout duration in milliseconds to wait for aggregation */
	t_u32 hold_timeout_msec;
	/** lock for transmission */
	t_void *paggr_lock;
	/** port for data transmission */
	t_u32 port;
	/** pointer to moal_adatper structure */
	t_void *phandle;
} usb_tx_aggr_params, *pusb_tx_aggr_params;
#endif

/** Type definition of mef_entry*/
typedef struct _mef_cfg {
	/** criteria*/
	t_u32 criteria;
	/** entry num*/
	t_u16 entry_num;
	/** entry pointer*/
	mef_entry_t *pentry;
} mef_cfg;

/** Type definition of mef_entry*/
typedef struct _mef_entry {
	/** Num for wowlan entry*/
	int num_wowlan_entry;
	/** Num for IPv6 neighbor solicitation message offload */
	int num_ipv6_ns_offload;

	/** criteria*/
	t_u32 criteria;
	/** MEF CFG Array to store etted_entry_bitmap;
	 *  Caution: 0-3 is for NVIDIA WHITE/BLACK list entries
	 *  Caution: 4   is for NVIDIA ping entry
	 *  Caution: 5   is for Auto Arp Entry
	 *  Caution: 6   is for wowlan Entry
	 *  Caution: 7   is for IPv6 Neighbor Solicitation offload Entry
	 */
	mef_entry_t entry[MAX_NUM_ENTRIES];
} mef_entry;

/** vdll_dnld_ctrl structure */
typedef struct _vdll_dnld_ctrl {
	/**  pending  VDLL block */
	t_u8 *pending_block;
	/* pending VDLL block len */
	t_u16 pending_block_len;
	/** memory for VDLL fw image */
	t_u8 *vdll_mem;
	/**  VDLL fw image len */
	t_u32 vdll_len;
#if defined(SDIO) || defined(PCIE)
	/** mlan_buffer for VDLL download */
	mlan_buffer *cmd_buf;
#endif
} vdll_dnld_ctrl, *pvdll_dnld_ctrl;

/** mlan_init_para structure */
typedef struct _mlan_init_para {
#ifdef MFG_CMD_SUPPORT
	/** MFG mode */
	t_u32 mfg_mode;
#endif
#ifdef SDIO
	/** SDIO interrupt mode (0: INT_MODE_SDIO, 1: INT_MODE_GPIO) */
	t_u32 int_mode;
	/** GPIO interrupt pin number */
	t_u32 gpio_pin;
	/** SDIO MPA Tx */
	t_u32 mpa_tx_cfg;
	/** SDIO MPA Rx */
	t_u32 mpa_rx_cfg;
#endif
	/** Auto deep sleep */
	t_u32 auto_ds;
	/** IEEE PS mode */
	t_u32 ps_mode;
	/** Max Tx buffer size */
	t_u32 max_tx_buf;
	/** 802.11d configuration */
	t_u32 cfg_11d;
	/** 802.11H DFS Master Radar Detect */
	t_u32 dfs_master_radar_det_en;
	/** 802.11H DFS Slave Radar Detect */
	t_u32 dfs_slave_radar_det_en;
	/** dev cap mask */
	t_u32 dev_cap_mask;
	/** oob independent reset mode */
	t_u32 indrstcfg;
	/** fw region */
	t_bool fw_region;
	/** passive to active scan */
	t_u8 passive_to_active_scan;
	/** uap max sta */
	t_u8 uap_max_sta;
	/** dfs w53 cfg */
	t_u8 dfs53cfg;
} mlan_init_para, *pmlan_init_para;

#ifdef SDIO
typedef struct _mlan_sdio_card_reg {
	t_u8 start_rd_port;
	t_u8 start_wr_port;
	t_u8 base_0_reg;
	t_u8 base_1_reg;
	t_u8 poll_reg;
	t_u8 host_int_enable;
	t_u8 host_int_status;
	t_u8 status_reg_0;
	t_u8 status_reg_1;
	t_u8 sdio_int_mask;
	t_u32 data_port_mask;
	t_u8 max_mp_regs;
	t_u8 rd_bitmap_l;
	t_u8 rd_bitmap_u;
	t_u8 rd_bitmap_1l;
	t_u8 rd_bitmap_1u;
	t_u8 wr_bitmap_l;
	t_u8 wr_bitmap_u;
	t_u8 wr_bitmap_1l;
	t_u8 wr_bitmap_1u;
	t_u8 rd_len_p0_l;
	t_u8 rd_len_p0_u;
	t_u8 card_config_2_1_reg;
	t_u8 cmd_config_0;
	t_u8 cmd_config_1;
	t_u8 cmd_config_2;
	t_u8 cmd_config_3;
	t_u8 cmd_rd_len_0;
	t_u8 cmd_rd_len_1;
	t_u8 cmd_rd_len_2;
	t_u8 cmd_rd_len_3;
	t_u8 io_port_0_reg;
	t_u8 io_port_1_reg;
	t_u8 io_port_2_reg;
	t_u8 host_int_rsr_reg;
	t_u8 host_int_mask_reg;
	t_u8 host_int_status_reg;
	t_u8 host_restart_reg;
	t_u8 card_to_host_event_reg;
	t_u8 host_interrupt_mask_reg;
	t_u8 card_interrupt_status_reg;
	t_u8 card_interrupt_rsr_reg;
	t_u8 card_revision_reg;
	t_u8 card_ocr_0_reg;
	t_u8 card_ocr_1_reg;
	t_u8 card_ocr_3_reg;
	t_u8 card_config_reg;
	t_u8 card_misc_cfg_reg;
	t_u8 debug_0_reg;
	t_u8 debug_1_reg;
	t_u8 debug_2_reg;
	t_u8 debug_3_reg;
	t_u32 fw_reset_reg;
	t_u8 fw_reset_val;
	t_u8 fw_dnld_offset_0_reg;
	t_u8 fw_dnld_offset_1_reg;
	t_u8 fw_dnld_offset_2_reg;
	t_u8 fw_dnld_offset_3_reg;
	t_u8 fw_dnld_status_0_reg;
	t_u8 fw_dnld_status_1_reg;
	t_u8 winner_check_reg;
} mlan_sdio_card_reg, *pmlan_sdio_card_reg;

typedef struct _mlan_sdio_card {
	const mlan_sdio_card_reg *reg;

	/** IO port */
	t_u32 ioport;
	/** number of interrupt receive */
	t_u32 num_of_irq;
	/** max SDIO single port tx size */
	t_u16 max_sp_tx_size;
	/** max SDIO single port rx size */
	t_u16 max_sp_rx_size;
	/** SDIO multiple port read bitmap */
	t_u32 mp_rd_bitmap;
	/** SDIO multiple port write bitmap */
	t_u32 mp_wr_bitmap;
	/** SDIO end port from txbufcfg */
	t_u16 mp_end_port;
	/** SDIO port mask calculated based on txbufcfg end port */
	t_u32 mp_data_port_mask;
	/** Current available port for read */
	t_u8 curr_rd_port;
	/** Current available port for write */
	t_u8 curr_wr_port;
	/** FW update port number */
	t_u32 mp_update[SDIO_MP_AGGR_DEF_PKT_LIMIT_MAX * 2];
	/** Invalid port update count */
	t_u32 mp_invalid_update;
	/** Array to store values of SDIO multiple port group registers */
	t_u8 *mp_regs;
	/** allocated buf to read SDIO multiple port group registers */
	t_u8 *mp_regs_buf;
	/** buffer to handle receive packet */
	t_u8 *rx_buf;
	/** allocated buf for receive */
	t_u8 *rx_buffer;
	/* see blk_queue_max_segment_size */
	t_u32 max_seg_size;
	/* see blk_queue_max_segments */
	t_u16 max_segs;

	/** data structure for SDIO MPA TX */
	sdio_mpa_tx mpa_tx;
	/** packet number for tx aggr */
	t_u32 mpa_tx_count[SDIO_MP_AGGR_DEF_PKT_LIMIT_MAX];
	/** no more packets count*/
	t_u32 mpa_sent_last_pkt;
	/** no write_ports count */
	t_u32 mpa_sent_no_ports;
	/** last wr_bitmap from FW */
	t_u32 last_recv_wr_bitmap;
	/** last mp_wr_bitmap */
	t_u32 last_mp_wr_bitmap[SDIO_MP_DBG_NUM];
	/** last ports for cmd53 write data */
	t_u32 last_mp_wr_ports[SDIO_MP_DBG_NUM];
	/** last length for cmd53 write data */
	t_u32 last_mp_wr_len[SDIO_MP_DBG_NUM];
	/** length info for cmd53 write data */
	t_u16 last_mp_wr_info[SDIO_MP_DBG_NUM * SDIO_MP_AGGR_DEF_PKT_LIMIT_MAX];
	/** last curr_wr_port */
	t_u8 last_curr_wr_port[SDIO_MP_DBG_NUM];

	/** buffer for mp debug */
	t_u8 *mpa_buf;
	/** length info for mp buf size */
	t_u32 mpa_buf_size;

	/** last mp_index */
	t_u8 last_mp_index;

	/** data structure for SDIO MPA RX */
	sdio_mpa_rx mpa_rx;
	/** packet number for tx aggr */
	t_u32 mpa_rx_count[SDIO_MP_AGGR_DEF_PKT_LIMIT_MAX];

	/** SDIO interrupt mode (0: INT_MODE_SDIO, 1: INT_MODE_GPIO) */
	t_u32 int_mode;
	/** GPIO interrupt pin number */
	t_u32 gpio_pin;

	/** flag for sdio rx aggr */
	t_bool sdio_rx_aggr_enable;
	/** fw rx block size */
	t_u16 sdio_rx_block_size;
} mlan_sdio_card, *pmlan_sdio_card;
#endif

#ifdef PCIE
/** 8 Event buffer ring */
#define MLAN_MAX_EVT_BD 0x08
/** 32 entry will mapping to 5*/
#define TX_RX_NUM_DESC 5
/** 8 entry will mapping to 3 */
#define EVT_NUM_DESC 3
typedef struct _mlan_pcie_card_reg {
	/* TX buffer description rd pointer */
	t_u32 reg_txbd_rdptr;
	/* TX buffer description wr pointer */
	t_u32 reg_txbd_wrptr;
	/* RX buffer description rd pointer */
	t_u32 reg_rxbd_rdptr;
	/* RX buffer description wr pointer */
	t_u32 reg_rxbd_wrptr;
	/** evtbd rdptr register */
	t_u32 reg_evtbd_rdptr;
	/** evtbd wrptr register */
	t_u32 reg_evtbd_wrptr;
	/** host int mask register */
	t_u16 reg_host_int_mask;
	/** host int status mask register*/
	t_u16 reg_host_int_status_mask;
	/** host int status register */
	t_u16 reg_host_int_status;
	/** host int status clr selection */
	t_u32 reg_host_int_clr_sel;
	/** cpu int event register */
	t_u16 reg_cpu_int_event;
	/** ip revision register */
	t_u16 reg_ip_rev;
	/** revision id register */
	t_u32 reg_rev_id;
	/** driver ready register */
	t_u16 reg_drv_ready;
	/** cpu int status register */
	t_u16 reg_cpu_int_status;
	/** scratch 0 register */
	t_u16 reg_scratch_0;
	/** scratch 1 register */
	t_u16 reg_scratch_1;
	/** scratch 2 register */
	t_u16 reg_scratch_2;
	/** scratch 3 register */
	t_u16 reg_scratch_3;
	/** scratch 6 register */
	t_u16 reg_scratch_6;
	/** scratch 7 register */
	t_u16 reg_scratch_7;
	/** host interrupt mask*/
	t_u32 host_intr_mask;
	/** data send interrupt for host*/
	t_u32 host_intr_dnld_done;
	/** Data receive interrupt for host */
	t_u32 host_intr_upld_rdy;
	/** Command sent interrupt for host */
	t_u32 host_intr_cmd_done;
	/** Event ready interrupt for host */
	t_u32 host_intr_event_rdy;
	t_u32 host_intr_cmd_dnld;
	/* TX/RX buffer description mask */
	t_u32 txrx_rw_ptr_mask;
	/* TX/RX buffer description wrap mask */
	t_u32 txrx_rw_ptr_wrap_mask;
	/* TX/RX buffer description indication */
	t_u32 txrx_rw_ptr_rollover_ind;
	/** ADMA feature */
	t_u8 use_adma;
	/** write to clear interrupt status flag */
	t_u8 msi_int_wr_clr;
} mlan_pcie_card_reg, *pmlan_pcie_card_reg;

typedef struct _mlan_pcie_card {
	const mlan_pcie_card_reg *reg;
	/** PCIE interrupt modes 0: Legacy, 1: MSI, 2:MSI-X */
	t_u32 pcie_int_mode;
	/** PCIE function number */
	t_u8 func_num;
	/** pending num of tx ring buffer in firmware */
	t_u8 txbd_pending;
	/** Write pointer for TXBD ring */
	t_u32 txbd_wrptr;
	/** Shadow copy of TXBD read pointer */
	t_u32 txbd_rdptr;
	/** TXBD ring size */
	t_u32 txbd_ring_size;
	/** Lock for protecting the TX ring */
	t_void *tx_ring_lock;
	/** Virtual base address of txbd_ring */
	t_u8 *txbd_ring_vbase;
	/** Physical base address of txbd_ring */
	t_u64 txbd_ring_pbase;
	/** Ring of buffer descriptors for TX */
	t_void *txbd_ring[MLAN_MAX_TXRX_BD];
	/** A list of mlan_buffer objects used for data tx */
	mlan_buffer *tx_buf_list[MLAN_MAX_TXRX_BD];
	/** Flush indicator for txbd_ring */
	t_bool txbd_flush;

	/** Shadow copy of RXBD write pointer */
	t_u32 rxbd_wrptr;
	/** RxBD read pointer */
	t_u32 rxbd_rdptr;
	/** RXBD ring size */
	t_u32 rxbd_ring_size;
	/** A spinlock for rxbd_ring */
	t_void *rx_ring_lock;
	/** Virtual base address of rxbd_ring */
	t_u8 *rxbd_ring_vbase;
	/** Physical base address of rxbd_ring */
	t_u64 rxbd_ring_pbase;
	/** Ring of buffer descriptors for RX */
	t_void *rxbd_ring[MLAN_MAX_TXRX_BD];
	/** A list of mlan_buffer objects used for data rx */
	mlan_buffer *rx_buf_list[MLAN_MAX_TXRX_BD];

	/** Shadow copy of cmdrsp/evt write pointer */
	t_u32 evtbd_wrptr;
	/** Read pointer for cmdrsp/evt ring */
	t_u32 evtbd_rdptr;
	/** Size of the cmdrsp/evt ring */
	t_u32 evtbd_ring_size;
	/** Virtual base address of evtbd_bd_ring */
	t_u8 *evtbd_ring_vbase;
	/** Physical base address of evtbd_bd_ring */
	t_u64 evtbd_ring_pbase;
	/** Ring of buffer descriptors for EVENT */
	t_void *evtbd_ring[MLAN_MAX_EVT_BD];
	/** A list of mlan_buffer objects used for EVENT */
	mlan_buffer *evt_buf_list[MLAN_MAX_EVT_BD];

	/** Command buffer */
	mlan_buffer *cmd_buf;
	/** Command response buffer */
	mlan_buffer *cmdrsp_buf;
	/** Command buffer */
	mlan_buffer *vdll_cmd_buf;
	/** last tx_pkt_size  */
	t_u32 last_tx_pkt_size[MLAN_MAX_TXRX_BD];
} mlan_pcie_card, *pmlan_pcie_card;
#endif

#ifdef USB
typedef struct _mlan_usb_card {
	/** data structure for USB Rx Deaggregation */
	usb_rx_deaggr_params usb_rx_deaggr;
	/** data structure for USB Tx Aggregation */
	usb_tx_aggr_params usb_tx_aggr[MAX_USB_TX_PORT_NUM];
	/** USB sggregation supported by FW */
	t_u8 fw_usb_aggr;

} mlan_usb_card, *pmlan_usb_card;

#endif

typedef struct _mlan_card_info {
	/** Max Tx buffer size */
	t_u32 max_tx_buf_size;
	/** support V16_FW_API */
	t_u8 v16_fw_api;
	/** support V17_FW_API */
	t_u8 v17_fw_api;
	/** suppress PS handshake */
	t_u8 supp_ps_handshake;
	/** DEFAULT_11N_TX_BF_CAP */
	t_u32 default_11n_tx_bf_cap;
} mlan_card_info, *pmlan_card_info;

typedef struct _mlan_adapter mlan_adapter, *pmlan_adapter;

/**Adapter_operations data structure*/
typedef struct _adapter_operations {
	/**firmware download handler*/
	mlan_status (*dnld_fw)(pmlan_adapter pmadapter, pmlan_fw_image pmfw);
	/**interrupt handler*/
	mlan_status (*interrupt)(t_u16 msg_id, pmlan_adapter pmadapter);
	/**INT process handler*/
	mlan_status (*process_int_status)(pmlan_adapter pmadapter);
	/**host to card handler*/
	mlan_status (*host_to_card)(pmlan_private pmpriv, t_u8 type,
				    mlan_buffer *pmbuf,
				    mlan_tx_param *tx_param);
	/*wakeup card*/
	mlan_status (*wakeup_card)(pmlan_adapter pmadapter, t_u8 timeout);
	/*reset the PM setting of card*/
	mlan_status (*reset_card)(pmlan_adapter adapter);
	/** Handle event/cmd complete*/
	mlan_status (*event_complete)(mlan_adapter *pmlan_adapter,
				      pmlan_buffer pmbuf, mlan_status status);
	/** Handle complete receiving data */
	mlan_status (*data_complete)(mlan_adapter *pmlan_adapter,
				     pmlan_buffer pmbuf, mlan_status status);
	/** Handle command response complete */
	mlan_status (*cmdrsp_complete)(mlan_adapter *pmlan_adapter,
				       pmlan_buffer pmbuf, mlan_status status);
	/** Handle rx packet */
	mlan_status (*handle_rx_packet)(mlan_adapter *pmadapter,
					pmlan_buffer pmbuf);
	/** handle dump interface specific info */
	mlan_status (*debug_dump)(mlan_adapter *pmadapter);
	/**Interface header length*/
	t_u32 intf_header_len;
} mlan_adapter_operations;

/** Adapter data structure for MLAN */
typedef struct _mlan_adapter {
	/** MOAL handle structure */
	t_void *pmoal_handle;
	/** BSS Attributes */
	mlan_bss_attr bss_attr[MLAN_MAX_BSS_NUM];
	/** Private pointer */
	pmlan_private priv[MLAN_MAX_BSS_NUM];
	/** Total number of Priv number */
	t_u8 priv_num;
	/** Priority table for bss */
	mlan_bssprio_tbl bssprio_tbl[MLAN_MAX_BSS_NUM];
	/** Callback table */
	mlan_callbacks callbacks;
	/** Init parameters */
	mlan_init_para init_para;
	/** mlan_lock for init/shutdown */
	t_void *pmlan_lock;
	/** main_proc_lock for main_process */
	t_void *pmain_proc_lock;
	/** mlan_processing */
	t_u32 mlan_processing;
	/** main_process_cnt */
	t_u32 main_process_cnt;
	/** mlan_rx_processing */
	t_u32 mlan_rx_processing;
	/** rx_proc_lock for main_rx_process */
	t_void *prx_proc_lock;
	/** more_rx_task_flag */
	t_u32 more_rx_task_flag;
	/** rx work enable flag */
	t_u8 rx_work_flag;
	/* number of rx pkts queued */
	t_u16 rx_pkts_queued;
	/** more task flag */
	t_u32 more_task_flag;
	/** delay task flag */
	t_u32 delay_task_flag;
	/** Max tx buf size */
	t_u16 max_tx_buf_size;
	/** Tx buf size */
	t_u16 tx_buf_size;
	/** current tx buf size in fw */
	t_u16 curr_tx_buf_size;
	/** flush data flag */
	t_u8 flush_data;
	/** STATUS variables */
	WLAN_HARDWARE_STATUS hw_status;
	/** PnP SUPPORT */
	t_u8 surprise_removed;
	/** FW hang report */
	t_u8 fw_hang_report;

	/** ECSA support */
	t_u8 ecsa_enable;

	/** Get log support */
	t_u8 getlog_enable;

	/** Radio on flag */
	t_u16 radio_on;

	/** Firmware release number */
	t_u32 fw_release_number;
	/** firmware version */
	t_u8 fw_ver;
	/** firmware minor version */
	t_u8 fw_min_ver;
	/** uap firmware version */
	t_u8 uap_fw_ver;
	/** mac address retrun from get_hw_spec */
	t_u8 permanent_addr[MLAN_MAC_ADDR_LENGTH];
	/** Number of antenna used */
	t_u16 number_of_antenna;
	/** antenna info */
	t_u8 antinfo;
	/** Firmware capability information */
	t_u32 fw_cap_info;
	/** Extended firmware capability information */
	t_u32 fw_cap_ext;
#if defined(PCIE9098) || defined(SD9098) || defined(USB9098) ||                \
	defined(PCIE9097) || defined(SD9097) || defined(USB9097)
	/** High byte for 5G, low byte for 2G, like 0x2211 0x22 for 5G, 0x11 for
	 * 2G */
	t_u16 user_htstream;
#endif
	/** vdll ctrl */
	vdll_dnld_ctrl vdll_ctrl;
#if defined(SDIO) || defined(PCIE)
	/** pint_lock for interrupt handling */
	t_void *pint_lock;
	/** Interrupt status */
	t_u32 ireg;
#endif
	/** card type */
	t_u16 card_type;
	/** card rev */
	t_u8 card_rev;
	const mlan_card_info *pcard_info;
#ifdef SDIO
	pmlan_sdio_card pcard_sd;
#endif
#ifdef PCIE
	pmlan_pcie_card pcard_pcie;
#endif
#ifdef USB
	pmlan_usb_card pcard_usb;
#endif

	/** Event cause */
	t_u32 event_cause;
	/** Event buffer */
	pmlan_buffer pmlan_buffer_event;
	/** Upload length */
	t_u32 upld_len;
	/** Upload buffer*/
	t_u8 upld_buf[WLAN_UPLD_SIZE];
	/** Data sent:
	 *       TRUE - Data is sent to fw, no Tx Done received
	 *       FALSE - Tx done received for previous Tx
	 */
	t_u8 data_sent;
	/** CMD sent:
	 *       TRUE - CMD is sent to fw, no CMD Done received
	 *       FALSE - CMD done received for previous CMD
	 */
	t_u8 cmd_sent;
	/** CMD Response received:
	 *       TRUE - CMD is response is received from fw, and yet to process
	 *       FALSE - No cmd response to process
	 */
	t_u8 cmd_resp_received;
	/** Event received:
	 *       TRUE - Event received from fw, and yet to process
	 *       FALSE - No events to process
	 */
	t_u8 event_received;

	/** Data received:
	 *       TRUE - Data received from fw
	 *       FALSE - No Data received
	 */
	t_u8 data_received;

	/** Command-related variables */
	/** Command sequence number */
	t_u16 seq_num;
	/** Command controller nodes */
	cmd_ctrl_node *cmd_pool;
	/** Current Command */
	cmd_ctrl_node *curr_cmd;
	/** mlan_lock for command */
	t_void *pmlan_cmd_lock;
	/** Number of command timeouts */
	t_u32 num_cmd_timeout;
	/** Last init fw command id */
	t_u16 last_init_cmd;
	/** Command timer */
	t_void *pmlan_cmd_timer;
	/** Command timer set flag */
	t_u8 cmd_timer_is_set;
	/** time stamp for command dnld */
	t_u32 dnld_cmd_in_secs;

	/** Command Queues */
	/** Free command buffers */
	mlan_list_head cmd_free_q;
	/** Pending command buffers */
	mlan_list_head cmd_pending_q;
	/** Command queue for scanning */
	mlan_list_head scan_pending_q;
	/** ioctl pending queue */
	mlan_list_head ioctl_pending_q;
	/** pending_ioctl flag */
	t_u8 pending_ioctl;
	pmlan_private pending_disconnect_priv;
	/** mlan_processing */
	t_u32 scan_processing;
	/** ext_scan enh support flag */
	t_u8 ext_scan_enh;
	/** scan type: 0 legacy, 1: enhance scan*/
	t_u8 ext_scan_type;
	/** ext scan timeout */
	t_u8 ext_scan_timeout;
	/** coex scan flag */
	t_u8 coex_scan;
	/** coex min scan time */
	t_u8 coex_min_scan_time;
	/** coex max scan time */
	t_u8 coex_max_scan_time;
	/** coex win size flag */
	t_u8 coex_win_size;
	/** coex amdpdu tx win size */
	t_u8 coex_tx_win_size;
	/** coex ampdu rx win size */
	t_u8 coex_rx_win_size;
	/** Region code */
	t_u16 region_code;
	/** Region Channel data */
	region_chan_t region_channel[MAX_REGION_CHANNEL_NUM];
	/** CFP table code for 2.4GHz */
	t_u8 cfp_code_bg;
	/** CFP table code for 5GHz */
	t_u8 cfp_code_a;
	wmm_ac_parameters_t ac_params[MAX_AC_QUEUES];
	/** Minimum BA Threshold */
	t_u8 min_ba_threshold;
#ifdef STA_SUPPORT
	/** Universal Channel data */
	region_chan_t universal_channel[MAX_REGION_CHANNEL_NUM];
	/** Parsed region channel */
	parsed_region_chan_11d_t parsed_region_chan;
#endif /* STA_SUPPORT */
	/** 11D and Domain Regulatory Data */
	wlan_802_11d_domain_reg_t domain_reg;
	/** Country Code */
	t_u8 country_code[COUNTRY_CODE_LEN];
	/** FSM variable for 11h support */
	wlan_11h_device_state_t state_11h;
	/** FSM variable for DFS support */
	wlan_dfs_device_state_t state_dfs;
	/** FSM variable for RDH support */
	wlan_radar_det_hndlg_state_t state_rdh;
	/** variable to configure dfs channel switch count */
	t_s8 dfs_cs_count;
	/** User configured settings for DFS testing */
	wlan_dfs_testing_settings_t dfs_test_params;
	/**  dfs w53 cfg */
	t_u8 dfs53cfg;
	/** FSM variable for MEAS support */
	wlan_meas_state_t state_meas;
	/** Scan table */
	BSSDescriptor_t *pscan_table;
	/** scan age in secs */
	t_u32 age_in_secs;
	/** Active scan for hidden ssid triggered */
	t_u8 active_scan_triggered;
	/** channel statstics */
	ChanStatistics_t *pchan_stats;
	/** Number of records in the chan_stats */
	t_u32 num_in_chan_stats;
	/** index of chan stats */
	t_u32 idx_chan_stats;
	t_u8 bgscan_reported;

	/** Number of records in the scan table */
	t_u32 num_in_scan_table;
	/** Scan probes */
	t_u16 scan_probes;

	/** Scan type */
	t_u8 scan_type;
	/** Scan mode */
	t_u32 scan_mode;
	/** Specific scan time */
	t_u16 specific_scan_time;
	/** Active scan time */
	t_u16 active_scan_time;
	/** Passive scan time */
	t_u16 passive_scan_time;
	/** Passive scan to active scan */
	t_u8 passive_to_active_scan;
	/** scan channel gap time */
	t_u16 scan_chan_gap;
	/** Scan block flag */
	t_u8 scan_block;
	/** Extended scan or legacy scan */
	t_u8 ext_scan;
	t_u16 bcn_buf_size;
	/** Beacon buffer */
	t_u8 *bcn_buf;
	/** Pointer to valid beacon buffer end */
	t_u8 *pbcn_buf_end;
	/** allocate fixed scan beacon buffer size*/
	t_u32 fixed_beacon_buffer;

	/** F/W supported bands */
	t_u16 fw_bands;
	/** User selected band to start adhoc network */
	t_u16 adhoc_start_band;
	/** User selected bands */
	t_u16 config_bands;
	/** Pointer to channel list last sent to the firmware for scanning */
	ChanScanParamSet_t *pscan_channels;

	/** Tx lock flag */
	t_u8 tx_lock_flag;
	/** Rx lock flag */
	t_u8 rx_lock_flag;
	/** main lock flag */
	t_u8 main_lock_flag;
#ifdef USB
	/** Tx CMD endpoint address */
	t_u8 tx_cmd_ep;
	/** Rx CMD/EVT endpoint address */
	t_u8 rx_cmd_ep;
	/** Rx data endpoint address */
	t_u8 rx_data_ep;
	/** Tx data endpoint address */
	t_u8 tx_data_ep;
#endif

	/** sleep_params_t */
	sleep_params_t sleep_params;
	/** sleep_period_t (Enhanced Power Save) */
	sleep_period_t sleep_period;

	/** Power Save mode */
	/**
	 * Wlan802_11PowerModeCAM = disable
	 * Wlan802_11PowerModePSP = enable
	 */
	t_u16 ps_mode;
	/** Power Save state */
	t_u32 ps_state;
	/** Need to wakeup flag */
	t_u8 need_to_wakeup;
	/** keep_wakeup */
	t_u8 keep_wakeup;

	/** Multiple DTIM */
	t_u16 multiple_dtim;
	/** Local listen interval */
	t_u16 local_listen_interval;
	/** Null packet interval */
	t_u16 null_pkt_interval;

	/** IEEE ps inactivity timout value */
	t_u16 inact_tmo;
	/** Power save confirm sleep command buffer */
	pmlan_buffer psleep_cfm;
	/** Beacon miss timeout */
	t_u16 bcn_miss_time_out;

	/** Deep Sleep flag */
	t_u8 is_deep_sleep;
	/** Idle time */
	t_u16 idle_time;
	/** Auto Deep Sleep enabled at init time */
	t_u8 init_auto_ds;

	/** delay null pkt flag */
	t_u8 delay_null_pkt;
	/** Delay to PS in milliseconds */
	t_u16 delay_to_ps;
	/** Enhanced PS mode */
	t_u16 enhanced_ps_mode;
	/** Device wakeup required flag */
	t_u8 pm_wakeup_card_req;

	/** Gen NULL pkg */
	t_u16 gen_null_pkt;

	/** PPS/UAPSD mode flag */
	t_u16 pps_uapsd_mode;
	/** Number of wakeup tries */
	t_u32 pm_wakeup_fw_try;
	/** time stamp when host try to wake up firmware */
	t_u32 pm_wakeup_in_secs;
	/** Card wakeup timer */
	t_void *pwakeup_fw_timer;
	/** Card wakeup timer */
	t_u8 wakeup_fw_timer_is_set;
	/** Number of wake up timeouts */
	t_u32 pm_wakeup_timeout;

	/** Host Sleep configured flag */
	t_u8 is_hs_configured;
	/** Host Sleep configuration */
	hs_config_param hs_cfg;
	/** Host Sleep activated flag */
	t_u8 hs_activated;
	/** mef_flt_cfg_mef configuration */
	mef_entry entry_cfg;
	/** Event body */
	t_u8 event_body[MAX_EVENT_SIZE];
	/** 802.11n device capabilities */
	t_u32 hw_dot_11n_dev_cap;
	/** Device support for MIMO abstraction of MCSs */
	t_u8 hw_dev_mcs_support;
#ifdef STA_SUPPORT
	/** Adhoc Secondary Channel Bandwidth */
	t_u8 chan_bandwidth;
#endif /* STA_SUPPORT */

	/** 802.11ac device capabilities */
	t_u32 hw_dot_11ac_dev_cap;
	/** 802.11ac device support for MIMO abstraction of MCSs */
	t_u32 hw_dot_11ac_mcs_support;
	/** length of hw he capability */
	t_u8 hw_hecap_len;
	/** 802.11ax HE capability */
	t_u8 hw_he_cap[54];
	/** length of hw 2.4G he capability */
	t_u8 hw_2g_hecap_len;
	/** 802.11ax 2.4G HE capability */
	t_u8 hw_2g_he_cap[54];
	/** max mgmt IE index in device */
	t_u16 max_mgmt_ie_index;
	/** Head of Rx data queue */
	mlan_list_head rx_data_queue;
#ifdef MFG_CMD_SUPPORT
	t_u32 mfg_mode;
#endif
	/** Debug */
	wlan_dbg dbg;

	/** RX pending for forwarding packets */
	mlan_scalar pending_bridge_pkts;

	/** Minimum delay between HsActive and HostWake (in msec) */
	t_u16 min_wake_holdoff;
	/** Host sleep wake interval(in msec) */
	t_u32 hs_wake_interval;
	/** Host sleep inactivity timeout (in msec) */
	t_u32 hs_inactivity_timeout;
	/** Parameter type for indication gpio*/
	t_u8 param_type_ind;
	/** GPIO pin for indication wakeup source */
	t_u32 ind_gpio;
	/** Level on ind_gpio pin for indication normal wakeup source */
	t_u32 level;
	/** Parameter type for extend hscfg*/
	t_u8 param_type_ext;
	/** Events that will be forced ignore */
	t_u32 event_force_ignore;
	/** Events that will use extend gap to inform host*/
	t_u32 event_use_ext_gap;
	/** Extend gap*/
	t_u8 ext_gap;
	/** GPIO wave level for extend hscfg */
	t_u8 gpio_wave;
	/** Dynamic MIMO-SISO switch for hscfg*/
	t_u8 hs_mimo_switch;
	/** management frame wakeup filter config */
	mlan_mgmt_frame_wakeup mgmt_filter[MAX_MGMT_FRAME_FILTER];
	/** Bypass TX queue pkt count  */
	t_u16 bypass_pkt_count;
#ifdef STA_SUPPORT
	/** warm-reset IOCTL request buffer pointer */
	pmlan_ioctl_req pwarm_reset_ioctl_req;
#endif
	/** SCAN IOCTL request buffer pointer */
	pmlan_ioctl_req pscan_ioctl_req;
	/** DPD data pointer */
	t_u8 *pdpd_data;
	/** DPD data length  */
	t_u32 dpd_data_len;
	/** region txpowerlimit cfg data buf pointer */
	t_u8 *ptxpwr_data;
	/** region txpowerlimit cfg data len */
	t_u32 txpwr_data_len;
	/** Cal data pointer */
	t_u8 *pcal_data;
	/** Cal data length  */
	t_u32 cal_data_len;
	/** Feature control bitmask */
	t_u32 feature_control;

	/** Control coex RX window size configuration */
	t_u8 coex_rx_winsize;
	t_bool dfs_repeater;
	t_u32 dfsr_channel;
	t_u8 chanrpt_param_bandcfg;
#if defined(PCIE)
	mlan_buffer *ssu_buf;
#endif
	/** maximum sta connection */
	t_u8 max_sta_conn;
	otp_region_info_t *otp_region;
	chan_freq_power_t *cfp_otp_bg;
	t_u8 *tx_power_table_bg;
	t_u32 tx_power_table_bg_size;
	t_u8 tx_power_table_bg_rows;
	t_u8 tx_power_table_bg_cols;
	chan_freq_power_t *cfp_otp_a;
	t_u8 *tx_power_table_a;
	t_u32 tx_power_table_a_size;
	t_u8 tx_power_table_a_rows;
	t_u8 tx_power_table_a_cols;
	/**mlan adapter operations*/
	mlan_adapter_operations ops;
#ifdef DRV_EMBEDDED_AUTHENTICATOR
	/** authenticator_priv */
	pmlan_private authenticator_priv;
#endif
} mlan_adapter, *pmlan_adapter;

/** Check if stream 2X2 enabled */
#define IS_STREAM_2X2(x) ((x)&FEATURE_CTRL_STREAM_2X2)
/** Check if DFS support enabled */
#define IS_DFS_SUPPORT(x) ((x)&FEATURE_CTRL_DFS_SUPPORT)
#ifdef USB
/** Check if winner check & not wait for FW ready event */
#define IS_USB_NEW_INIT(x) ((x)&FEATURE_CTRL_USB_NEW_INIT)
#endif

/** Ethernet packet type for EAPOL */
#define MLAN_ETHER_PKT_TYPE_EAPOL (0x888E)
#define MLAN_ETHER_PKT_TYPE_ARP (0x0806)
/** Ethernet packet type for WAPI */
#define MLAN_ETHER_PKT_TYPE_WAPI (0x88B4)
/** Ethernet packet type offset */
#define MLAN_ETHER_PKT_TYPE_OFFSET (12)

mlan_status wlan_init_lock_list(pmlan_adapter pmadapter);
mlan_status wlan_init_priv_lock_list(pmlan_adapter pmadapter, t_u8 start_index);
t_void wlan_free_lock_list(pmlan_adapter pmadapter);
mlan_status wlan_init_timer(pmlan_adapter pmadapter);
t_void wlan_free_timer(pmlan_adapter pmadapter);

/* Function prototype */
/** Initialize firmware */
mlan_status wlan_init_fw(pmlan_adapter pmadapter);

/** get hw spec complete */
mlan_status wlan_get_hw_spec_complete(pmlan_adapter pmadapter);

/** Initialize firmware complete */
mlan_status wlan_init_fw_complete(pmlan_adapter pmadapter);

/** Shutdown firmware complete */
mlan_status wlan_shutdown_fw_complete(pmlan_adapter pmadapter);

/** Receive event */
mlan_status wlan_recv_event(pmlan_private priv, mlan_event_id event_id,
			    t_void *pmevent);

/** Initialize mlan_adapter structure */
t_void wlan_init_adapter(pmlan_adapter pmadapter);

/** Initialize mlan_private structure */
mlan_status wlan_init_priv(pmlan_private priv);

mlan_status wlan_download_vdll_block(mlan_adapter *pmadapter, t_u8 *block,
				     t_u16 block_len);
mlan_status wlan_process_vdll_event(pmlan_private pmpriv, pmlan_buffer pevent);
/** Process event */
mlan_status wlan_process_event(pmlan_adapter pmadapter);

/** Prepare command */
mlan_status wlan_prepare_cmd(pmlan_private priv, t_u16 cmd_no, t_u16 cmd_action,
			     t_u32 cmd_oid, t_void *pioctl_buf,
			     t_void *pdata_buf);

/** cmd timeout handler */
t_void wlan_cmd_timeout_func(t_void *function_context);

/**
 *  @brief check if Tx pending
 *
 *  @param pmadapter	Pointer to mlan_adapter
 *  @return  MTRUE/MFALSE;
 */
static inline t_u8 wlan_is_tx_pending(mlan_adapter *pmadapter)
{
#ifdef PCIE
	if (IS_PCIE(pmadapter->card_type) &&
	    pmadapter->pcard_pcie->txbd_pending)
		return MTRUE;
#endif
	return MFALSE;
}

/** process host cmd */
mlan_status wlan_misc_ioctl_host_cmd(pmlan_adapter pmadapter,
				     pmlan_ioctl_req pioctl_req);
/** process init/shutdown cmd*/
mlan_status wlan_misc_ioctl_init_shutdown(pmlan_adapter pmadapter,
					  pmlan_ioctl_req pioctl_req);
/** process debug info */
mlan_status wlan_get_info_debug_info(pmlan_adapter pmadapter,
				     pmlan_ioctl_req pioctl_req);

#if defined(STA_SUPPORT) && defined(UAP_SUPPORT)
/** Set/Get BSS role */
mlan_status wlan_bss_ioctl_bss_role(pmlan_adapter pmadapter,
				    pmlan_ioctl_req pioctl_req);
#endif

#if defined(PCIE)
mlan_status wlan_misc_ssu(pmlan_adapter pmadapter, pmlan_ioctl_req pioctl_req);
#endif

mlan_status wlan_set_ewpa_mode(mlan_private *priv, pmlan_ds_passphrase psec_pp);
mlan_status wlan_find_bss(mlan_private *pmpriv, pmlan_ioctl_req pioctl_req);

/* block main process */
void mlan_block_main_process(mlan_adapter *pmadapter, t_u8 block);
/* block rx process */
void mlan_block_rx_process(mlan_adapter *pmadapter, t_u8 block);
/** check pending command */
int wlan_check_pending_cmd(mlan_adapter *pmadapter);
/** Allocate memory for adapter structure members */
mlan_status wlan_allocate_adapter(pmlan_adapter pmadapter);
/** Free adapter */
t_void wlan_free_adapter(pmlan_adapter pmadapter);
/** Free priv */
t_void wlan_free_priv(mlan_private *pmpriv);
/** Allocate command buffer */
mlan_status wlan_alloc_cmd_buffer(mlan_adapter *pmadapter);
/** Free command buffer */
mlan_status wlan_free_cmd_buffer(mlan_adapter *pmadapter);
/** Request command lock */
t_void wlan_request_cmd_lock(mlan_adapter *pmadapter);
/** Release command lock */
t_void wlan_release_cmd_lock(mlan_adapter *pmadapter);
#ifdef STA_SUPPORT
/** Flush the scan pending queue */
t_void wlan_flush_scan_queue(pmlan_adapter pmadapter);
mlan_status wlan_cancel_pending_scan_cmd(pmlan_adapter pmadapter,
					 pmlan_ioctl_req pioctl_req);
#endif
/**Cancel pending command */
t_void wlan_cancel_all_pending_cmd(pmlan_adapter pmadapter, t_u8 flag);
/**Cancel pending ioctl */
t_void wlan_cancel_pending_ioctl(pmlan_adapter pmadapter,
				 pmlan_ioctl_req pioctl_req);
/**Cancel bss pending ioctl */
t_void wlan_cancel_bss_pending_cmd(pmlan_adapter pmadapter, t_u32 bss_index);

/** Insert command to free queue */
t_void wlan_insert_cmd_to_free_q(mlan_adapter *pmadapter,
				 cmd_ctrl_node *pcmd_node);

/** Insert command to pending queue */
t_void wlan_insert_cmd_to_pending_q(mlan_adapter *pmadapter,
				    cmd_ctrl_node *pcmd_node, t_u32 addtail);

/** Execute next command */
mlan_status wlan_exec_next_cmd(mlan_adapter *pmadapter);
/** Proecess command response */
mlan_status wlan_process_cmdresp(mlan_adapter *pmadapter);
/** Handle received packet, has extra handling for aggregate packets */
mlan_status wlan_handle_rx_packet(pmlan_adapter pmadapter, pmlan_buffer pmbuf);
/** Process transmission */
mlan_status wlan_process_tx(pmlan_private priv, pmlan_buffer pmbuf,
			    mlan_tx_param *tx_param);
/** Transmit a null data packet */
mlan_status wlan_send_null_packet(pmlan_private priv, t_u8 flags);

#ifdef SDIO
mlan_status wlan_alloc_sdio_mpa_buffers(mlan_adapter *pmadapter,
					t_u32 mpa_tx_buf_size,
					t_u32 mpa_rx_buf_size);

mlan_status wlan_free_sdio_mpa_buffers(mlan_adapter *pmadapter);
#endif

/** Process write data complete */
mlan_status wlan_write_data_complete(pmlan_adapter pmlan_adapter,
				     pmlan_buffer pmbuf, mlan_status status);

#ifdef USB
mlan_status wlan_usb_deaggr_rx_pkt(pmlan_adapter pmadapter, pmlan_buffer pmbuf);

/**
 *  @brief  This function resets USB Tx Aggregation buffers
 *
 *  @param pmadapter	A pointer to mlan_adapter
 *
 *  @return 	N/A
 */
static INLINE t_void wlan_reset_usb_tx_aggr(pmlan_adapter pmadapter)
{
	t_s32 i = 0;
	pmlan_callbacks pcb = &pmadapter->callbacks;
	ENTER();
	for (i = 0; i < MAX_USB_TX_PORT_NUM; i++) {
		pcb->moal_spin_lock(
			pmadapter->pmoal_handle,
			pmadapter->pcard_usb->usb_tx_aggr[i].paggr_lock);
		if (pmadapter->pcard_usb->usb_tx_aggr[i].aggr_hold_timer_is_set) {
			pcb->moal_stop_timer(pmadapter->pmoal_handle,
					     pmadapter->pcard_usb
						     ->usb_tx_aggr[i]
						     .paggr_hold_timer);
			pmadapter->pcard_usb->usb_tx_aggr[i]
				.aggr_hold_timer_is_set = MFALSE;
		}
		if (pmadapter->pcard_usb->usb_tx_aggr[i].aggr_ctrl.enable &&
		    pmadapter->pcard_usb->usb_tx_aggr[i].pmbuf_aggr != MNULL) {
			wlan_write_data_complete(
				pmadapter,
				pmadapter->pcard_usb->usb_tx_aggr[i].pmbuf_aggr,
				MLAN_STATUS_FAILURE); /* did not get sent */
			pmadapter->pcard_usb->usb_tx_aggr[i].pmbuf_aggr = MNULL;
			pmadapter->pcard_usb->usb_tx_aggr[i].aggr_len = 0;
		}
		pcb->moal_spin_unlock(
			pmadapter->pmoal_handle,
			pmadapter->pcard_usb->usb_tx_aggr[i].paggr_lock);
	}
	LEAVE();
}

/**
 *  @brief  This function get usb_tx_aggr_params
 *
 *  @param pmadapter	A pointer to mlan_adapter
 *  @param port		    port for TX
 *
 *  @return	            A pointer to usb_tx_aggr_params
 */
static INLINE usb_tx_aggr_params *
wlan_get_usb_tx_aggr_params(pmlan_adapter pmadapter, t_u32 port)
{
	int i;
	ENTER();
	for (i = 0; i < MAX_USB_TX_PORT_NUM; i++) {
		if (pmadapter->pcard_usb->usb_tx_aggr[i].aggr_ctrl.enable &&
		    pmadapter->pcard_usb->usb_tx_aggr[i].port == port)
			return &pmadapter->pcard_usb->usb_tx_aggr[i];
	}
	LEAVE();
	return MNULL;
}

t_void wlan_usb_tx_aggr_timeout_func(t_void *function_context);
mlan_status wlan_usb_host_to_card_aggr(pmlan_adapter pmadapter,
				       pmlan_buffer pmbuf,
				       mlan_tx_param *tx_param,
				       usb_tx_aggr_params *aggr_params);
#endif

/** Process receive packet complete */
mlan_status wlan_recv_packet_complete(pmlan_adapter pmadapter,
				      pmlan_buffer pmbuf, mlan_status status);
/** Clean Tx Rx queues */
t_void wlan_clean_txrx(pmlan_private priv);

t_void wlan_add_buf_bypass_txqueue(mlan_adapter *pmadapter, pmlan_buffer pmbuf);
t_void wlan_process_bypass_tx(mlan_adapter *pmadapter);
t_void wlan_cleanup_bypass_txq(pmlan_private priv);
t_u8 wlan_bypass_tx_list_empty(mlan_adapter *pmadapter);

/** Check if this is the last packet */
t_u8 wlan_check_last_packet_indication(pmlan_private priv);

#define MOAL_ALLOC_MLAN_BUFFER (0)
#define MOAL_MALLOC_BUFFER (1)

#ifdef PCIE
/* This defines the direction arg to the DMA mapping routines. */
#define PCI_DMA_BIDIRECTIONAL 0
#define PCI_DMA_TODEVICE 1
#define PCI_DMA_FROMDEVICE 2
#define PCI_DMA_NONE 3
#endif

/** function to allocate a mlan_buffer */
pmlan_buffer wlan_alloc_mlan_buffer(mlan_adapter *pmadapter, t_u32 data_len,
				    t_u32 head_room, t_u32 malloc_flag);
/** function to free a mlan_buffer */
t_void wlan_free_mlan_buffer(mlan_adapter *pmadapter, pmlan_buffer pmbuf);

/** command resp handler for version ext */
mlan_status wlan_ret_ver_ext(pmlan_private pmpriv, HostCmd_DS_COMMAND *resp,
			     mlan_ioctl_req *pioctl_buf);

/** command resp handler for rx mgmt forward registration */
mlan_status wlan_ret_rx_mgmt_ind(pmlan_private pmpriv, HostCmd_DS_COMMAND *resp,
				 mlan_ioctl_req *pioctl_buf);

/** Check Power Save condition */
t_void wlan_check_ps_cond(mlan_adapter *pmadapter);

/** handle command for enhanced power save mode */
mlan_status wlan_cmd_enh_power_mode(pmlan_private pmpriv,
				    HostCmd_DS_COMMAND *cmd, t_u16 cmd_action,
				    t_u16 ps_bitmap, t_void *pdata_buf);
/** handle command resp for enhanced power save mode */
mlan_status wlan_ret_enh_power_mode(pmlan_private pmpriv,
				    HostCmd_DS_COMMAND *resp,
				    mlan_ioctl_req *pioctl_buf);

/** handle commnand for cfg data */
mlan_status wlan_cmd_cfg_data(pmlan_private pmpriv, HostCmd_DS_COMMAND *pcmd,
			      t_u16 cmd_action, t_u32 cmd_oid,
			      t_void *pdata_buf);
/** handle command resp for cfg data */
mlan_status wlan_ret_cfg_data(pmlan_private pmpriv, HostCmd_DS_COMMAND *resp,
			      t_void *pioctl_buf);

/** Process sleep confirm command response */
void wlan_process_sleep_confirm_resp(pmlan_adapter pmadapter, t_u8 *pbuf,
				     t_u32 len);

/** Perform hs related activities on receving the power up interrupt */
void wlan_process_hs_config(pmlan_adapter pmadapter);

t_void wlan_wakeup_card_timeout_func(void *function_context);

mlan_status wlan_process_802dot11_mgmt_pkt(mlan_private *priv, t_u8 *payload,
					   t_u32 payload_len, RxPD *prx_pd);

mlan_status wlan_pm_ioctl_hscfg(pmlan_adapter pmadapter,
				pmlan_ioctl_req pioctl_req);

mlan_status wlan_radio_ioctl_remain_chan_cfg(pmlan_adapter pmadapter,
					     pmlan_ioctl_req pioctl_req);
mlan_status wlan_cmd_remain_on_channel(pmlan_private pmpriv,
				       HostCmd_DS_COMMAND *cmd,
				       t_u16 cmd_action, t_void *pdata_buf);
mlan_status wlan_ret_remain_on_channel(pmlan_private pmpriv,
				       HostCmd_DS_COMMAND *resp,
				       mlan_ioctl_req *pioctl_buf);

#ifdef WIFI_DIRECT_SUPPORT
mlan_status wlan_bss_ioctl_wifi_direct_mode(pmlan_adapter pmadapter,
					    pmlan_ioctl_req pioctl_req);

mlan_status wlan_cmd_wifi_direct_mode(pmlan_private pmpriv,
				      HostCmd_DS_COMMAND *cmd, t_u16 cmd_action,
				      t_void *pdata_buf);
mlan_status wlan_ret_wifi_direct_mode(pmlan_private pmpriv,
				      HostCmd_DS_COMMAND *resp,
				      mlan_ioctl_req *pioctl_buf);
mlan_status wlan_cmd_p2p_params_config(pmlan_private pmpriv,
				       HostCmd_DS_COMMAND *cmd,
				       t_u16 cmd_action, t_void *pdata_buf);
mlan_status wlan_ret_p2p_params_config(pmlan_private pmpriv,
				       HostCmd_DS_COMMAND *resp,
				       mlan_ioctl_req *pioctl_buf);
mlan_status wlan_misc_p2p_config(pmlan_adapter pmadapter,
				 pmlan_ioctl_req pioctl_req);
#endif
/** get ralist info */
int wlan_get_ralist_info(mlan_private *priv, pralist_info buf);
/** dump ralist */
void wlan_dump_ralist(mlan_private *priv);

/** get pm info */
mlan_status wlan_get_pm_info(pmlan_adapter pmadapter,
			     pmlan_ioctl_req pioctl_req);

mlan_status wlan_bss_ioctl_bss_remove(pmlan_adapter pmadapter,
				      pmlan_ioctl_req pioctl_req);

mlan_status wlan_radio_ioctl_mimo_switch_cfg(pmlan_adapter pmadapter,
					     pmlan_ioctl_req pioctl_req);
mlan_status wlan_cmd_802_11_mimo_switch(pmlan_private pmpriv,
					HostCmd_DS_COMMAND *cmd,
					t_void *pdata_buf);

mlan_status wlan_misc_per_pkt_cfg(pmlan_adapter pmadapter,
				  pmlan_ioctl_req pioctl_req);

mlan_status wlan_config_mgmt_filter(pmlan_adapter pmadapter,
				    pmlan_ioctl_req pioctl_req);
mlan_status wlan_get_hs_wakeup_reason(pmlan_adapter pmadapter,
				      pmlan_ioctl_req pioctl_req);

mlan_status wlan_cmd_hs_wakeup_reason(pmlan_private pmpriv,
				      HostCmd_DS_COMMAND *cmd,
				      t_void *pdata_buf);

mlan_status wlan_ret_hs_wakeup_reason(pmlan_private pmpriv,
				      HostCmd_DS_COMMAND *resp,
				      mlan_ioctl_req *pioctl_buf);

mlan_status wlan_get_tx_rx_histogram(pmlan_adapter pmadapter,
				     pmlan_ioctl_req pioctl_req);
mlan_status wlan_cmd_tx_rx_pkt_stats(pmlan_private pmpriv,
				     HostCmd_DS_COMMAND *cmd,
				     pmlan_ioctl_req pioctl_buf,
				     t_void *pdata_buf);
mlan_status wlan_ret_tx_rx_pkt_stats(pmlan_private pmpriv,
				     HostCmd_DS_COMMAND *resp,
				     mlan_ioctl_req *pioctl_buf);

mlan_status wlan_radio_ioctl_radio_ctl(pmlan_adapter pmadapter,
				       pmlan_ioctl_req pioctl_req);

mlan_status wlan_radio_ioctl_ant_cfg(pmlan_adapter pmadapter,
				     pmlan_ioctl_req pioctl_req);

mlan_status wlan_cmd_tx_rate_cfg(pmlan_private pmpriv, HostCmd_DS_COMMAND *cmd,
				 t_u16 cmd_action, t_void *pdata_buf,
				 mlan_ioctl_req *pioctl_buf);
mlan_status wlan_ret_tx_rate_cfg(pmlan_private pmpriv, HostCmd_DS_COMMAND *resp,
				 mlan_ioctl_req *pioctl_buf);

mlan_status wlan_rate_ioctl_cfg(pmlan_adapter pmadapter,
				pmlan_ioctl_req pioctl_req);
mlan_status wlan_ret_802_11_tx_rate_query(pmlan_private pmpriv,
					  HostCmd_DS_COMMAND *resp,
					  mlan_ioctl_req *pioctl_buf);

mlan_status wlan_rate_ioctl_get_data_rate(pmlan_adapter pmadapter,
					  pmlan_ioctl_req pioctl_req);

t_void wlan_host_sleep_activated_event(pmlan_private priv, t_u8 activated);
/** Handles the command response of hs_cfg */
mlan_status wlan_ret_802_11_hs_cfg(pmlan_private pmpriv,
				   HostCmd_DS_COMMAND *resp,
				   mlan_ioctl_req *pioctl_buf);
/** Sends HS_WAKEUP event to applications */
t_void wlan_host_sleep_wakeup_event(pmlan_private priv);

/** Prepares command of robustcoex */
mlan_status wlan_cmd_robustcoex(pmlan_private pmpriv, HostCmd_DS_COMMAND *cmd,
				t_u16 cmd_action, t_u16 *pdata_buf);
/** Set Robustcoex gpiocfg */
mlan_status wlan_misc_robustcoex(pmlan_adapter pmadapter,
				 pmlan_ioctl_req pioctl_req);

/** Set mapping policy/get DMCS status */
mlan_status wlan_misc_dmcs_config(pmlan_adapter pmadapter,
				  pmlan_ioctl_req pioctl_req);
/** Prepares command of DMCS config */
mlan_status wlan_cmd_dmcs_config(pmlan_private pmpriv, HostCmd_DS_COMMAND *cmd,
				 t_u16 cmd_action, t_void *pdata_buf);
/** Handles command response of DMCS config */
mlan_status wlan_ret_dmcs_config(pmlan_private pmpriv, HostCmd_DS_COMMAND *resp,
				 mlan_ioctl_req *pioctl_buf);

#if defined(PCIE)
mlan_status wlan_cmd_ssu(pmlan_private pmpriv, HostCmd_DS_COMMAND *cmd,
			 t_u16 cmd_action, t_u16 *pdata_buf);
#endif

/** send get hw spec command to firmware */
mlan_status wlan_adapter_get_hw_spec(pmlan_adapter pmadapter);
/** send adapter specific init cmd to firmware */
mlan_status wlan_adapter_init_cmd(pmlan_adapter pmadapter);
/** get/set bandcfg */
mlan_status wlan_radio_ioctl_band_cfg(pmlan_adapter pmadapter,
				      pmlan_ioctl_req pioctl_req);

#ifdef RX_PACKET_COALESCE
mlan_status wlan_cmd_rx_pkt_coalesce_cfg(pmlan_private pmpriv,
					 HostCmd_DS_COMMAND *cmd,
					 t_u16 cmd_action, t_void *pdata_buf);
mlan_status wlan_ret_rx_pkt_coalesce_cfg(pmlan_private pmpriv,
					 const HostCmd_DS_COMMAND *resp,
					 mlan_ioctl_req *pioctl_buf);
#endif

#ifdef STA_SUPPORT
/** warm reset */
mlan_status wlan_misc_ioctl_warm_reset(pmlan_adapter pmadapter,
				       pmlan_ioctl_req pioctl_req);
/** Process received packet */
mlan_status wlan_process_rx_packet(pmlan_adapter pmadapter, pmlan_buffer pmbuf);
/** ioctl handler for station mode */
mlan_status wlan_ops_sta_ioctl(t_void *adapter, pmlan_ioctl_req pioctl_req);

/** cmd handler for station mode */
mlan_status wlan_ops_sta_prepare_cmd(t_void *priv, t_u16 cmd_no,
				     t_u16 cmd_action, t_u32 cmd_oid,
				     t_void *pioctl_buf, t_void *pdata_buf,
				     t_void *pcmd_buf);

/** cmdresp handler for station mode */
mlan_status wlan_ops_sta_process_cmdresp(t_void *priv, t_u16 cmdresp_no,
					 t_void *pcmd_buf, t_void *pioctl);

/** rx handler for station mode */
mlan_status wlan_ops_sta_process_rx_packet(t_void *adapter, pmlan_buffer pmbuf);

/** event handler for station mode */
mlan_status wlan_ops_sta_process_event(t_void *priv);

/** fill txpd for station mode */
t_void *wlan_ops_sta_process_txpd(t_void *priv, pmlan_buffer pmbuf);

/** send init cmd to firmware for station mode */
mlan_status wlan_ops_sta_init_cmd(t_void *priv, t_u8 first_bss);

/** Flush the scan table */
mlan_status wlan_flush_scan_table(pmlan_adapter pmadapter);

/** Scan for networks */
mlan_status wlan_scan_networks(mlan_private *pmpriv, t_void *pioctl_buf,
			       wlan_user_scan_cfg *puser_scan_in);

/** Scan for specific SSID */
mlan_status wlan_scan_specific_ssid(mlan_private *pmpriv, t_void *pioctl_buf,
				    mlan_802_11_ssid *preq_ssid);

/** Scan command handler */
mlan_status wlan_cmd_802_11_scan(pmlan_private pmpriv, HostCmd_DS_COMMAND *pcmd,
				 t_void *pdata_buf);

/** Handler for scan command response */
mlan_status wlan_ret_802_11_scan(pmlan_private pmpriv, HostCmd_DS_COMMAND *resp,
				 t_void *pioctl_buf);

/** Extended scan command handler */
mlan_status wlan_cmd_802_11_scan_ext(pmlan_private pmpriv,
				     HostCmd_DS_COMMAND *pcmd,
				     t_void *pdata_buf);
/** Handler for extended scan command response */
mlan_status wlan_ret_802_11_scan_ext(pmlan_private pmpriv,
				     HostCmd_DS_COMMAND *resp,
				     t_void *pioctl_buf);
/** Handler event for extended scan report */
mlan_status wlan_handle_event_ext_scan_report(mlan_private *pmpriv,
					      mlan_buffer *pmbuf);
mlan_status wlan_handle_event_ext_scan_status(mlan_private *pmpriv,
					      mlan_buffer *pmbuf);

/** check network compatibility */
t_s32 wlan_is_network_compatible(mlan_private *pmpriv, t_u32 index, t_u32 mode);

/** Find an SSID in a list */
t_s32 wlan_find_ssid_in_list(pmlan_private pmpriv, mlan_802_11_ssid *ssid,
			     t_u8 *bssid, t_u32 mode);

/** Find a BSSID in a list */
t_s32 wlan_find_bssid_in_list(mlan_private *pmpriv, t_u8 *bssid, t_u32 mode);

/** Find best network */
mlan_status wlan_find_best_network(mlan_private *pmpriv,
				   mlan_ssid_bssid *preq_ssid_bssid);

/** Compare two SSIDs */
t_s32 wlan_ssid_cmp(pmlan_adapter pmadapter, mlan_802_11_ssid *ssid1,
		    mlan_802_11_ssid *ssid2);

/** Associate */
mlan_status wlan_associate(mlan_private *pmpriv, IN t_void *pioctl_buf,
			   IN BSSDescriptor_t *pBSSDesc);

/** Associate command handler */
mlan_status wlan_cmd_802_11_associate(mlan_private *pmpriv,
				      HostCmd_DS_COMMAND *cmd,
				      t_void *pdata_buf);

/** Handler for association command response */
mlan_status wlan_ret_802_11_associate(mlan_private *pmpriv,
				      HostCmd_DS_COMMAND *resp,
				      t_void *pioctl_buf);

/** Reset connected state */
t_void wlan_reset_connect_state(pmlan_private priv, t_u8 drv_disconnect);

t_void wlan_2040_coex_event(pmlan_private pmpriv);

/** convert band to radio type */
t_u8 wlan_band_to_radio_type(t_u8 band);
/** convert radio_type to band */
t_u8 radio_type_to_band(t_u8 chanBand);

/** Disconnect */
mlan_status wlan_disconnect(mlan_private *pmpriv, mlan_ioctl_req *pioctl_req,
			    mlan_deauth_param *deauth_param);

/** Ad-Hoc start */
mlan_status wlan_adhoc_start(mlan_private *pmpriv, t_void *pioctl_buf,
			     mlan_802_11_ssid *padhoc_ssid);

/** Ad-Hoc join */
mlan_status wlan_adhoc_join(mlan_private *pmpriv, t_void *pioctl_buf,
			    BSSDescriptor_t *pBSSDesc);

/** Ad-Hoc start command handler */
mlan_status wlan_cmd_802_11_ad_hoc_start(mlan_private *pmpriv,
					 HostCmd_DS_COMMAND *cmd,
					 t_void *pdata_buf);

/** Ad-Hoc command handler */
mlan_status wlan_cmd_802_11_ad_hoc_join(mlan_private *pmpriv,
					HostCmd_DS_COMMAND *cmd,
					t_void *pdata_buf);

/** Handler for Ad-Hoc commands */
mlan_status wlan_ret_802_11_ad_hoc(mlan_private *pmpriv,
				   HostCmd_DS_COMMAND *resp,
				   t_void *pioctl_buf);

/** Handler for bgscan query commands */
mlan_status wlan_cmd_802_11_bg_scan_query(mlan_private *pmpriv,
					  HostCmd_DS_COMMAND *pcmd,
					  t_void *pdata_buf);
/** Handler for bgscan config command */
mlan_status wlan_cmd_bgscan_config(mlan_private *pmpriv,
				   HostCmd_DS_COMMAND *pcmd, t_void *pdata_buf);
/** Hander for bgscan config command response */
mlan_status wlan_ret_bgscan_config(mlan_private *pmpriv,
				   HostCmd_DS_COMMAND *resp,
				   mlan_ioctl_req *pioctl_buf);
mlan_status wlan_ret_802_11_bgscan_query(mlan_private *pmpriv,
					 HostCmd_DS_COMMAND *resp,
					 mlan_ioctl_req *pioctl_buf);

/** Get Channel-Frequency-Power by band and channel */
chan_freq_power_t *
wlan_get_cfp_by_band_and_channel(pmlan_adapter pmadapter, t_u8 band,
				 t_u16 channel, region_chan_t *region_channel);
/** Find Channel-Frequency-Power by band and channel */
chan_freq_power_t *wlan_find_cfp_by_band_and_channel(mlan_adapter *pmadapter,
						     t_u8 band, t_u16 channel);
/** Find Channel-Frequency-Power by band and frequency */
chan_freq_power_t *wlan_find_cfp_by_band_and_freq(mlan_adapter *pmadapter,
						  t_u8 band, t_u32 freq);
/** Get Tx power of channel from Channel-Frequency-Power */
t_u8 wlan_get_txpwr_of_chan_from_cfp(mlan_private *pmpriv, t_u8 channel);
/** find frequency from band and channel */
t_u32 wlan_find_freq_from_band_chan(t_u8, t_u8);

/*  Save a beacon buffer of the current bss descriptor */
t_void wlan_save_curr_bcn(mlan_private *pmpriv);
/*  Free a beacon buffer of the current bss descriptor */
t_void wlan_free_curr_bcn(mlan_private *pmpriv);

#endif /* STA_SUPPORT */

/* Rate related functions */
/** Convert index into data rate */
t_u32 wlan_index_to_data_rate(pmlan_adapter pmadapter, t_u8 index,
			      t_u8 rate_info, t_u8 ext_rate_info);
/** Get active data rates */
t_u32 wlan_get_active_data_rates(mlan_private *pmpriv, t_u32 bss_mode,
				 t_u16 config_bands, WLAN_802_11_RATES rates);
/** Get supported data rates */
t_u32 wlan_get_supported_rates(mlan_private *pmpriv, t_u32 bss_mode,
			       t_u16 config_bands, WLAN_802_11_RATES rates);
/** Convert data rate to index */
t_u8 wlan_data_rate_to_index(pmlan_adapter pmadapter, t_u32 rate);
/** Check if rate is auto */
t_u8 wlan_is_rate_auto(mlan_private *pmpriv);
/** Get rate index */
int wlan_get_rate_index(pmlan_adapter pmadapter, t_u16 *rateBitmap, int size);
mlan_status wlan_cmd_rxabortcfg(pmlan_private pmpriv, HostCmd_DS_COMMAND *cmd,
				t_u16 cmd_action, t_void *pdata_buf);
mlan_status wlan_ret_rxabortcfg(pmlan_private pmpriv, HostCmd_DS_COMMAND *resp,
				mlan_ioctl_req *pioctl_buf);
mlan_status wlan_cmd_rxabortcfg_ext(pmlan_private pmpriv,
				    HostCmd_DS_COMMAND *cmd, t_u16 cmd_action,
				    t_void *pdata_buf);
mlan_status wlan_ret_rxabortcfg_ext(pmlan_private pmpriv,
				    HostCmd_DS_COMMAND *resp,
				    mlan_ioctl_req *pioctl_buf);
mlan_status wlan_cmd_tx_ampdu_prot_mode(pmlan_private pmpriv,
					HostCmd_DS_COMMAND *cmd,
					t_u16 cmd_action, t_void *pdata_buf);
mlan_status wlan_ret_tx_ampdu_prot_mode(pmlan_private pmpriv,
					HostCmd_DS_COMMAND *resp,
					mlan_ioctl_req *pioctl_buf);
mlan_status wlan_cmd_dot11mc_unassoc_ftm_cfg(pmlan_private pmpriv,
					     HostCmd_DS_COMMAND *cmd,
					     t_u16 cmd_action,
					     t_void *pdata_buf);
mlan_status wlan_ret_dot11mc_unassoc_ftm_cfg(pmlan_private pmpriv,
					     HostCmd_DS_COMMAND *resp,
					     mlan_ioctl_req *pioctl_buf);

mlan_status wlan_cmd_rate_adapt_cfg(pmlan_private pmpriv,
				    HostCmd_DS_COMMAND *cmd, t_u16 cmd_action,
				    t_void *pdata_buf);
mlan_status wlan_ret_rate_adapt_cfg(pmlan_private pmpriv,
				    HostCmd_DS_COMMAND *resp,
				    mlan_ioctl_req *pioctl_buf);
mlan_status wlan_cmd_cck_desense_cfg(pmlan_private pmpriv,
				     HostCmd_DS_COMMAND *cmd, t_u16 cmd_action,
				     t_void *pdata_buf);

mlan_status wlan_ret_cck_desense_cfg(pmlan_private pmpriv,
				     HostCmd_DS_COMMAND *resp,
				     mlan_ioctl_req *pioctl_buf);

mlan_status wlan_cmd_arb_cfg(pmlan_private pmpriv, HostCmd_DS_COMMAND *cmd,
			     t_u16 cmd_action, t_void *pdata_buf);
mlan_status wlan_ret_arb_cfg(pmlan_private pmpriv, HostCmd_DS_COMMAND *resp,
			     mlan_ioctl_req *pioctl_buf);

mlan_status wlan_misc_ioctl_rxabortcfg(pmlan_adapter pmadapter,
				       pmlan_ioctl_req pioctl_req);
mlan_status wlan_misc_ioctl_rxabortcfg_ext(pmlan_adapter pmadapter,
					   pmlan_ioctl_req pioctl_req);
mlan_status wlan_misc_ioctl_tx_ampdu_prot_mode(pmlan_adapter pmadapter,
					       pmlan_ioctl_req pioctl_req);
mlan_status wlan_misc_ioctl_dot11mc_unassoc_ftm_cfg(pmlan_adapter pmadapter,
						    pmlan_ioctl_req pioctl_req);
mlan_status wlan_misc_ioctl_rate_adapt_cfg(pmlan_adapter pmadapter,
					   pmlan_ioctl_req pioctl_req);
mlan_status wlan_misc_ioctl_cck_desense_cfg(pmlan_adapter pmadapter,
					    pmlan_ioctl_req pioctl_req);
mlan_status wlan_cmd_mfg(pmlan_private pmpriv, pHostCmd_DS_COMMAND cmd,
			 t_u16 cmd_action, t_pvoid pdata_buf);
mlan_status wlan_ret_mfg(pmlan_private pmpriv, HostCmd_DS_COMMAND *resp,
			 mlan_ioctl_req *pioctl_buf);
mlan_status wlan_misc_ioctl_rf_test_cfg(pmlan_adapter pmadapter,
					pmlan_ioctl_req pioctl_req);
mlan_status wlan_misc_ioctl_range_ext(pmlan_adapter pmadapter,
				      pmlan_ioctl_req pioctl_req);
mlan_status wlan_misc_ioctl_arb_cfg(pmlan_adapter pmadapter,
				    pmlan_ioctl_req pioctl_req);
/* CFP related functions */
/** Region code index table */
extern t_u16 region_code_index[MRVDRV_MAX_REGION_CODE];
/** The table to keep CFP code for BG */
extern t_u16 cfp_code_index_bg[MRVDRV_MAX_CFP_CODE_BG];
/** The table to keep CFP code for A */
extern t_u16 cfp_code_index_a[MRVDRV_MAX_CFP_CODE_A];

/** Set region table */
mlan_status wlan_set_regiontable(mlan_private *pmpriv, t_u8 region, t_u8 band);
/** Get radar detection requirements*/
t_bool wlan_get_cfp_radar_detect(mlan_private *priv, t_u8 chnl);
/** check if scan type is passive for b/g band*/
t_bool wlan_bg_scan_type_is_passive(mlan_private *priv, t_u8 chnl);
/** check if channel is NO_IR (passive) */
t_bool wlan_is_chan_passive(mlan_private *priv, t_u8 band, t_u8 chan);
/** check if channel is disabled */
t_bool wlan_is_chan_disabled(mlan_private *priv, t_u8 band, t_u8 chan);
/** check if channel is blacklisted */
t_bool wlan_is_chan_blacklisted(mlan_private *priv, t_u8 band, t_u8 chan);
/** set blacklist setting for a channel */
t_bool wlan_set_chan_blacklist(mlan_private *priv, t_u8 band, t_u8 chan,
			       t_bool bl);

/* 802.11D related functions */
/** Initialize 11D */
t_void wlan_11d_priv_init(mlan_private *pmpriv);
/** Initialize 11D */
t_void wlan_11d_init(mlan_adapter *pmadapter);
/** Enable 11D */
mlan_status wlan_11d_enable(mlan_private *pmpriv, t_void *pioctl_buf,
			    state_11d_t flag);
/** Get if 11D is enabled */
t_bool wlan_11d_is_enabled(mlan_private *pmpriv);
/** Get if FW 11D is enabled */
t_bool wlan_fw_11d_is_enabled(mlan_private *pmpriv);
/** Get if priv is station */
t_bool wlan_is_station(mlan_private *pmpriv);
/** Command handler for 11D country info */
mlan_status wlan_cmd_802_11d_domain_info(mlan_private *pmpriv,
					 HostCmd_DS_COMMAND *pcmd,
					 t_u16 cmd_action);
/** Handler for 11D country info command response */
mlan_status wlan_ret_802_11d_domain_info(mlan_private *pmpriv,
					 HostCmd_DS_COMMAND *resp);
/** Convert channel to frequency */
t_u32 wlan_11d_chan_2_freq(pmlan_adapter pmadapter, t_u8 chan, t_u8 band);
#ifdef STA_SUPPORT
/** Set 11D universal table */
mlan_status wlan_11d_set_universaltable(mlan_private *pmpriv, t_u8 band);
/** Clear 11D region table */
mlan_status wlan_11d_clear_parsedtable(mlan_private *pmpriv);
/** Create 11D country information for downloading */
mlan_status wlan_11d_create_dnld_countryinfo(mlan_private *pmpriv, t_u8 band);
/** Get scan type from 11D info */
t_u8 wlan_11d_get_scan_type(pmlan_adapter pmadapter, t_u8 band, t_u8 chan,
			    parsed_region_chan_11d_t *parsed_region_chan);
/** Parse 11D country info */
mlan_status wlan_11d_parse_dnld_countryinfo(mlan_private *pmpriv,
					    BSSDescriptor_t *pBSSDesc);
/** Prepare 11D domain information for download */
mlan_status wlan_11d_prepare_dnld_domain_info_cmd(mlan_private *pmpriv);
/** Parse 11D country information into domain info */
mlan_status wlan_11d_parse_domain_info(
	pmlan_adapter pmadapter, IEEEtypes_CountryInfoFullSet_t *country_info,
	t_u8 band, parsed_region_chan_11d_t *parsed_region_chan);
#endif /* STA_SUPPORT */
#ifdef UAP_SUPPORT
/** Handle 11D domain information from UAP */
mlan_status wlan_11d_handle_uap_domain_info(mlan_private *pmpriv, t_u8 band,
					    t_u8 *domain_tlv,
					    t_void *pioctl_buf);
#endif
/** Configure 11D domain info command */
mlan_status wlan_11d_cfg_domain_info(pmlan_adapter pmadapter,
				     mlan_ioctl_req *pioctl_req);

/** This function converts region string to CFP table code */
mlan_status wlan_misc_country_2_cfp_table_code(pmlan_adapter pmadapter,
					       t_u8 *country_code, t_u8 *cfp_bg,
					       t_u8 *cfp_a);

/** This function finds if given country code is in EU table */
t_bool wlan_is_etsi_country(pmlan_adapter pmadapter, t_u8 *country_code);

/** check if station list is empty */
t_u8 wlan_is_station_list_empty(mlan_private *priv);
/** get station node */
sta_node *wlan_get_station_entry(mlan_private *priv, t_u8 *mac);
/** delete station list */
t_void wlan_delete_station_list(pmlan_private priv);
/** delete station entry */
t_void wlan_delete_station_entry(mlan_private *priv, t_u8 *mac);
/** add station entry */
sta_node *wlan_add_station_entry(mlan_private *priv, t_u8 *mac);
/** process uap rx packet */

void wlan_check_sta_capability(pmlan_private priv, pmlan_buffer pevent,
			       sta_node *sta_ptr);
/** find specific ie */
t_u8 *wlan_get_specific_ie(pmlan_private priv, t_u8 *ie_buf, t_u8 ie_len,
			   IEEEtypes_ElementId_e id, t_u8 ext_id);
t_u8 wlan_is_wmm_ie_present(pmlan_adapter pmadapter, t_u8 *pbuf, t_u16 buf_len);

/**
 *  @brief This function checks tx_pause flag for peer
 *
 *  @param priv     A pointer to mlan_private
 *  @param ra       Address of the receiver STA
 *
 *  @return         MTRUE or MFALSE
 */
static INLINE int wlan_is_tx_pause(mlan_private *priv, t_u8 *ra)
{
	sta_node *sta_ptr = MNULL;
	sta_ptr = wlan_get_station_entry(priv, ra);
	if (sta_ptr)
		return sta_ptr->tx_pause;
	return MFALSE;
}
t_u16 wlan_update_ralist_tx_pause(pmlan_private priv, t_u8 *mac, t_u8 tx_pause);

#ifdef UAP_SUPPORT
mlan_status wlan_process_uap_rx_packet(mlan_private *priv, pmlan_buffer pmbuf);
t_void wlan_drop_tx_pkts(pmlan_private priv);
#endif /* UAP_SUPPORT */

#ifdef UAP_SUPPORT
/* process the recevied packet and bridge the packet */
mlan_status wlan_uap_recv_packet(mlan_private *priv, pmlan_buffer pmbuf);
#endif /* UAP_SUPPORT */

mlan_status wlan_misc_ioctl_custom_ie_list(pmlan_adapter pmadapter,
					   pmlan_ioctl_req pioctl_req,
					   t_bool send_ioctl);

mlan_status wlan_cmd_get_hw_spec(pmlan_private pmpriv,
				 HostCmd_DS_COMMAND *pcmd);
mlan_status wlan_ret_get_hw_spec(pmlan_private pmpriv, HostCmd_DS_COMMAND *resp,
				 t_void *pioctl_buf);
#ifdef SDIO
mlan_status wlan_cmd_sdio_rx_aggr_cfg(HostCmd_DS_COMMAND *pcmd,
				      t_u16 cmd_action, t_void *pdata_buf);
mlan_status wlan_ret_sdio_rx_aggr_cfg(pmlan_private pmpriv,
				      HostCmd_DS_COMMAND *resp);
#endif

mlan_status wlan_misc_ioctl_mac_control(pmlan_adapter pmadapter,
					pmlan_ioctl_req pioctl_req);
mlan_status wlan_cmd_mac_control(pmlan_private pmpriv, HostCmd_DS_COMMAND *pcmd,
				 t_u16 cmd_action, t_void *pdata_buf);
mlan_status wlan_ret_mac_control(pmlan_private pmpriv, HostCmd_DS_COMMAND *resp,
				 mlan_ioctl_req *pioctl_buf);

mlan_status wlan_cmd_cw_mode_ctrl(pmlan_private pmpriv, HostCmd_DS_COMMAND *cmd,
				  t_u16 cmd_action, t_void *pdata_buf);
mlan_status wlan_ret_cw_mode_ctrl(pmlan_private pmpriv,
				  HostCmd_DS_COMMAND *resp,
				  mlan_ioctl_req *pioctl_buf);

mlan_status wlan_cmd_802_11_radio_control(pmlan_private pmpriv,
					  HostCmd_DS_COMMAND *cmd,
					  t_u16 cmd_action, t_void *pdata_buf);
mlan_status wlan_ret_802_11_radio_control(pmlan_private pmpriv,
					  HostCmd_DS_COMMAND *resp,
					  mlan_ioctl_req *pioctl_buf);

mlan_status wlan_cmd_802_11_rf_antenna(pmlan_private pmpriv,
				       HostCmd_DS_COMMAND *cmd,
				       t_u16 cmd_action, t_void *pdata_buf);
mlan_status wlan_ret_802_11_rf_antenna(pmlan_private pmpriv,
				       HostCmd_DS_COMMAND *resp,
				       mlan_ioctl_req *pioctl_buf);

mlan_status wlan_ret_reg_access(mlan_adapter *pmadapter, t_u16 type,
				HostCmd_DS_COMMAND *resp,
				mlan_ioctl_req *pioctl_buf);
mlan_status wlan_ret_mem_access(pmlan_private pmpriv, HostCmd_DS_COMMAND *resp,
				mlan_ioctl_req *pioctl_buf);

mlan_status wlan_reg_mem_ioctl_reg_rw(pmlan_adapter pmadapter,
				      pmlan_ioctl_req pioctl_req);
mlan_status wlan_reg_mem_ioctl_read_eeprom(pmlan_adapter pmadapter,
					   pmlan_ioctl_req pioctl_req);
mlan_status wlan_reg_mem_ioctl_mem_rw(pmlan_adapter pmadapter,
				      pmlan_ioctl_req pioctl_req);
mlan_status wlan_cmd_reg_access(pmlan_private pmpriv, HostCmd_DS_COMMAND *cmd,
				t_u16 cmd_action, t_void *pdata_buf);
mlan_status wlan_cmd_mem_access(HostCmd_DS_COMMAND *cmd, t_u16 cmd_action,
				t_void *pdata_buf);
mlan_status wlan_cmd_802_11_mac_address(pmlan_private pmpriv,
					HostCmd_DS_COMMAND *cmd,
					t_u16 cmd_action);
mlan_status wlan_ret_802_11_mac_address(pmlan_private pmpriv,
					HostCmd_DS_COMMAND *resp,
					mlan_ioctl_req *pioctl_buf);

mlan_status wlan_get_info_ver_ext(pmlan_adapter pmadapter,
				  pmlan_ioctl_req pioctl_req);

mlan_status wlan_ioctl_link_statistic(mlan_private *pmpriv,
				      pmlan_ioctl_req pioctl_req);

mlan_status wlan_cmd_802_11_link_statistic(pmlan_private pmpriv,
					   HostCmd_DS_COMMAND *cmd,
					   t_u16 cmd_action,
					   mlan_ioctl_req *pioctl_buf);

mlan_status wlan_ret_get_link_statistic(pmlan_private pmpriv,
					HostCmd_DS_COMMAND *resp,
					mlan_ioctl_req *pioctl_buf);

mlan_status wlan_reg_rx_mgmt_ind(pmlan_adapter pmadapter,
				 pmlan_ioctl_req pioctl_req);

#ifdef DEBUG_LEVEL1
mlan_status wlan_set_drvdbg(pmlan_adapter pmadapter,
			    pmlan_ioctl_req pioctl_req);
#endif

mlan_status wlan_misc_hotspot_cfg(pmlan_adapter pmadapter,
				  pmlan_ioctl_req pioctl_req);
#ifdef STA_SUPPORT
mlan_status wlan_misc_ext_capa_cfg(pmlan_adapter pmadapter,
				   pmlan_ioctl_req pioctl_req);

t_u32 wlan_is_ext_capa_support(mlan_private *pmpriv);
#endif

#ifdef STA_SUPPORT
void wlan_add_ext_capa_info_ie(mlan_private *pmpriv, BSSDescriptor_t *pbss_desc,
			       t_u8 **pptlv_out);
#endif

mlan_status wlan_cmd_boot_sleep(pmlan_private pmpriv, HostCmd_DS_COMMAND *cmd,
				t_u16 cmd_action, t_void *pdata_buf);

mlan_status wlan_ret_boot_sleep(pmlan_private pmpriv, HostCmd_DS_COMMAND *resp,
				mlan_ioctl_req *pioctl_buf);

#if defined(DRV_EMBEDDED_AUTHENTICATOR) || defined(DRV_EMBEDDED_SUPPLICANT)
mlan_status wlan_cmd_crypto(pmlan_private pmpriv, HostCmd_DS_COMMAND *cmd,
			    t_u16 cmd_action, t_u16 *pdata_buf);

mlan_status wlan_ret_crypto(pmlan_private pmpriv, HostCmd_DS_COMMAND *resp,
			    mlan_ioctl_req *pioctl_buf);
#endif

#define BW_20MHZ 0
#define BW_40MHZ 1
#define BW_80MHZ 2
#define BW_160MHZ 3
int wlan_add_supported_oper_class_ie(mlan_private *pmpriv, t_u8 **pptlv_out,
				     t_u8 curr_oper_class);
mlan_status wlan_get_curr_oper_class(mlan_private *pmpriv, t_u8 channel,
				     t_u8 bw, t_u8 *oper_class);
mlan_status wlan_check_operclass_validation(mlan_private *pmpriv, t_u8 channel,
					    t_u8 oper_class);
mlan_status wlan_misc_ioctl_operclass_validation(pmlan_adapter pmadapter,
						 mlan_ioctl_req *pioctl_req);
mlan_status wlan_misc_ioctl_oper_class(pmlan_adapter pmadapter,
				       mlan_ioctl_req *pioctl_req);

t_u16 wlan_adjust_data_rate(mlan_private *priv, t_u8 rx_rate, t_u8 rate_info);
t_u8 wlan_adjust_antenna(pmlan_private priv, RxPD *prx_pd);

mlan_status wlan_misc_otp_user_data(pmlan_adapter pmadapter,
				    pmlan_ioctl_req pioctl_req);

#ifdef USB
mlan_status wlan_misc_ioctl_usb_aggr_ctrl(pmlan_adapter pmadapter,
					  pmlan_ioctl_req pioctl_req);
#endif

mlan_status wlan_misc_ioctl_aggr_ctrl(pmlan_adapter pmadapter,
				      pmlan_ioctl_req pioctl_req);
mlan_status wlan_cmd_packet_aggr_ctrl(pmlan_private pmpriv,
				      HostCmd_DS_COMMAND *cmd, t_u16 cmd_action,
				      t_void *pdata_buf);
mlan_status wlan_ret_packet_aggr_ctrl(pmlan_private pmpriv,
				      HostCmd_DS_COMMAND *resp,
				      mlan_ioctl_req *pioctl_buf);
mlan_status wlan_misc_ioctl_txcontrol(pmlan_adapter pmadapter,
				      pmlan_ioctl_req pioctl_req);

mlan_status wlan_misc_ioctl_region(pmlan_adapter pmadapter,
				   pmlan_ioctl_req pioctl_req);

#ifdef RX_PACKET_COALESCE
mlan_status wlan_misc_ioctl_rx_pkt_coalesce_config(pmlan_adapter pmadapter,
						   pmlan_ioctl_req pioctl_req);
#endif

void wlan_bt_coex_wlan_param_update_event(pmlan_private priv,
					  pmlan_buffer pevent);

mlan_status wlan_misc_ioctl_dfs_repeater_cfg(pmlan_adapter pmadapter,
					     pmlan_ioctl_req pioctl_req);

t_bool wlan_check_interface_active(mlan_adapter *pmadapter);

mlan_status wlan_misc_ioctl_coalesce_cfg(pmlan_adapter pmadapter,
					 pmlan_ioctl_req pioctl_req);

mlan_status wlan_misc_ioctl_low_pwr_mode(pmlan_adapter pmadapter,
					 pmlan_ioctl_req pioctl_req);

mlan_status wlan_misc_ioctl_pmic_configure(pmlan_adapter pmadapter,
					   pmlan_ioctl_req pioctl_req);

mlan_status wlan_misc_ioctl_cwmode_ctrl(pmlan_adapter pmadapter,
					pmlan_ioctl_req pioctl_req);

mlan_status wlan_set_mef_entry(mlan_private *pmpriv, pmlan_adapter pmadapter,
			       mef_cfg *pmef);
mlan_status wlan_process_mef_cfg_cmd(mlan_private *pmpriv,
				     pmlan_adapter pmadapter);
mlan_status wlan_misc_ioctl_mef_flt_cfg(pmlan_adapter pmadapter,
					pmlan_ioctl_req pioctl_req);

mlan_status wlan_misc_ioctl_ind_rst_cfg(pmlan_adapter pmadapter,
					pmlan_ioctl_req pioctl_req);
mlan_status wlan_cmd_ind_rst_cfg(HostCmd_DS_COMMAND *cmd, t_u16 cmd_action,
				 t_void *pdata_buf);
mlan_status wlan_ret_ind_rst_cfg(pmlan_private pmpriv, HostCmd_DS_COMMAND *resp,
				 mlan_ioctl_req *pioctl_buf);

mlan_status wlan_cmd_802_11_supplicant_pmk(pmlan_private pmpriv,
					   HostCmd_DS_COMMAND *cmd,
					   t_u16 cmd_action, t_void *pdata_buf);

mlan_status wlan_ret_802_11_supplicant_pmk(pmlan_private pmpriv,
					   HostCmd_DS_COMMAND *resp,
					   mlan_ioctl_req *pioctl_buf);

mlan_status wlan_sec_ioctl_passphrase(pmlan_adapter pmadapter,
				      pmlan_ioctl_req pioctl_req);

mlan_status wlan_misc_ioctl_get_tsf(pmlan_adapter pmadapter,
				    pmlan_ioctl_req pioctl_req);
void wlan_add_fw_cfp_tables(pmlan_private pmpriv, t_u8 *buf, t_u16 buf_left);

void wlan_free_fw_cfp_tables(mlan_adapter *pmadapter);

mlan_status wlan_misc_chan_reg_cfg(pmlan_adapter pmadapter,
				   pmlan_ioctl_req pioctl_req);

mlan_status wlan_get_cfp_table(pmlan_adapter pmadapter,
			       pmlan_ioctl_req pioctl_req);
mlan_status wlan_get_cfpinfo(pmlan_adapter pmadapter,
			     pmlan_ioctl_req pioctl_req);

mlan_status wlan_cmd_get_tsf(pmlan_private pmpriv, HostCmd_DS_COMMAND *cmd,
			     t_u16 cmd_action);
mlan_status wlan_ret_get_tsf(pmlan_private pmpriv, HostCmd_DS_COMMAND *resp,
			     mlan_ioctl_req *pioctl_buf);

t_u8 wlan_ft_akm_is_used(mlan_private *pmpriv, t_u8 *rsn_ie);

mlan_status wlan_get_rgchnpwr_cfg(pmlan_adapter pmadapter,
				  mlan_ioctl_req *pioctl_req);
mlan_status wlan_get_chan_trpc_cfg(pmlan_adapter pmadapter,
				   mlan_ioctl_req *pioctl_req);
mlan_status wlan_cmd_get_chan_trpc_config(pmlan_private pmpriv,
					  HostCmd_DS_COMMAND *cmd,
					  t_u16 cmd_action, t_void *pdata_buf);
mlan_status wlan_ret_get_chan_trpc_config(pmlan_private pmpriv,
					  HostCmd_DS_COMMAND *resp,
					  mlan_ioctl_req *pioctl_buf);

mlan_status wlan_cmd_ps_inactivity_timeout(pmlan_private pmpriv,
					   HostCmd_DS_COMMAND *cmd,
					   t_u16 cmd_action, t_void *pdata_buf);

t_u8 wlan_ieee_rateid_to_mrvl_rateid(mlan_private *priv, t_u16 IeeeMacRate,
				     t_u8 *dst_mac);
t_u8 wlan_mrvl_rateid_to_ieee_rateid(t_u8 rate);

t_u8 wlan_get_center_freq_idx(mlan_private *pmpriv, t_u16 band, t_u32 pri_chan,
			      t_u8 chan_bw);

mlan_status wlan_ret_chan_region_cfg(pmlan_private pmpriv,
				     HostCmd_DS_COMMAND *resp,
				     mlan_ioctl_req *pioctl_buf);

mlan_status wlan_misc_ioctl_fw_dump_event(pmlan_adapter pmadapter,
					  mlan_ioctl_req *pioctl_req);
mlan_status wlan_cmd_fw_dump_event(pmlan_private pmpriv,
				   HostCmd_DS_COMMAND *cmd, t_u16 cmd_action,
				   t_void *pdata_buf);

mlan_status wlan_misc_bootsleep(pmlan_adapter pmadapter,
				pmlan_ioctl_req pioctl_req);

mlan_status wlan_misc_ioctl_dyn_bw(pmlan_adapter pmadapter,
				   mlan_ioctl_req *pioctl_req);
mlan_status wlan_cmd_config_dyn_bw(pmlan_private pmpriv,
				   HostCmd_DS_COMMAND *cmd, t_u16 cmd_action,
				   t_void *pdata_buf);
mlan_status wlan_ret_dyn_bw(pmlan_private pmpriv, HostCmd_DS_COMMAND *resp,
			    mlan_ioctl_req *pioctl_buf);

mlan_status wlan_power_ioctl_set_get_lpm(pmlan_adapter pmadapter,
					 pmlan_ioctl_req pioctl_req);
mlan_status wlan_cmd_set_get_low_power_mode_cfg(pmlan_private pmpriv,
						HostCmd_DS_COMMAND *cmd,
						t_u16 cmd_action,
						t_void *pdata_buf);
mlan_status wlan_ret_set_get_low_power_mode_cfg(pmlan_private pmpriv,
						HostCmd_DS_COMMAND *resp,
						mlan_ioctl_req *pioctl_buf);

mlan_status wlan_cmd_range_ext(pmlan_private pmpriv, HostCmd_DS_COMMAND *cmd,
			       t_u16 cmd_action, t_void *pdata_buf);
mlan_status wlan_ret_range_ext(pmlan_private pmpriv, HostCmd_DS_COMMAND *resp,
			       mlan_ioctl_req *pioctl_buf);

/**
 *  @brief RA based queueing
 *
 *  @param priv             A pointer to mlan_private structure
 *
 *  @return                 MTRUE or MFALSE
 */
static INLINE t_u8 queuing_ra_based(pmlan_private priv)
{
	/*
	 * Currently we assume if we are in Infra, then DA=RA. This might not be
	 * true in the future
	 */
	if ((priv->bss_mode == MLAN_BSS_MODE_INFRA) &&
	    (GET_BSS_ROLE(priv) == MLAN_BSS_ROLE_STA))
		return MFALSE;

	return MTRUE;
}

/**
 *  @brief Copy Rates
 *
 *  @param dest             A pointer to Dest Buf
 *  @param pos		        The position for copy
 *  @param src		        A pointer to Src Buf
 *  @param len              The len of Src Buf
 *
 *  @return                 Number of Rates copied
 */
static INLINE t_u32 wlan_copy_rates(t_u8 *dest, t_u32 pos, t_u8 *src, int len)
{
	int i;

	for (i = 0; i < len && src[i]; i++, pos++) {
		if (pos >= sizeof(WLAN_802_11_RATES))
			break;
		dest[pos] = src[i];
	}

	return pos;
}

/**
 *  @brief strlen
 *
 *  @param str		        A pointer to string
 *
 *  @return                 Length of string
 */
static INLINE t_u32 wlan_strlen(const char *str)
{
	t_u32 i;

	for (i = 0; str[i] != 0; i++)
		;

	return i;
}

/**
 *  @brief iscdigit
 *
 *  @param chr                  A char
 *
 *  @return                     Non zero if chr is a hex, else 0
 */
static INLINE t_u32 wlan_isxdigit(t_u8 chr)
{
	return (chr <= 'f' && chr >= 'a') || (chr <= 'F' && chr >= 'A') ||
	       (chr <= '9' && chr >= '0');
}

/**
 *  @brief isspace
 *
 *  @param                       A chr
 *
 *  @return                      Non zero if chr is space etc, else 0
 */
static INLINE t_u32 wlan_isspace(t_u8 chr)
{
	return chr <= ' ' && (chr == ' ' || (chr <= 13 && chr >= 9));
}

/** delay unit */
typedef enum _delay_unit {
	USEC,
	MSEC,
	SEC,
} t_delay_unit;

/** delay function */
t_void wlan_delay_func(mlan_adapter *pmadapter, t_u32 delay, t_delay_unit u);

/** delay function wrapper */
#define wlan_delay(p, n) wlan_delay_func(p, n, SEC)
/** delay function wrapper */
#define wlan_mdelay(p, n) wlan_delay_func(p, n, MSEC)
/** delay function wrapper */
#define wlan_udelay(p, n) wlan_delay_func(p, n, USEC)

/**
 *  @brief This function check if there are pending cmd
 *         in cmd pending Q
 *
 *  @param pmadapter  A pointer to mlan_adapter structure
 *
 *  @return  MTRUE -- cmd pending
 *           MFALSE -- no pending cmd
 */
static INLINE int wlan_is_cmd_pending(mlan_adapter *pmadapter)
{
	int ret;
	cmd_ctrl_node *pcmd_node = MNULL;
	wlan_request_cmd_lock(pmadapter);
	pcmd_node = (cmd_ctrl_node *)util_peek_list(pmadapter->pmoal_handle,
						    &pmadapter->cmd_pending_q,
						    MNULL, MNULL);
	if (pcmd_node)
		ret = MTRUE;
	else
		ret = MFALSE;
	wlan_release_cmd_lock(pmadapter);
	return ret;
}

/** Get BSS number from priv */
#define GET_BSS_NUM(priv) ((priv)->bss_num)

/**
 *  @brief This function returns priv based on the BSS num and BSS type
 *
 *  @param pmadapter A pointer to mlan_adapter
 *  @param bss_num   BSS number
 *  @param bss_type  BSS type
 *
 *  @return          Pointer to mlan_private
 */
static INLINE mlan_private *wlan_get_priv_by_id(mlan_adapter *pmadapter,
						t_u32 bss_num, t_u32 bss_type)
{
	int i;

	for (i = 0; i < MIN(pmadapter->priv_num, MLAN_MAX_BSS_NUM); i++) {
		if (pmadapter->priv[i]) {
			if ((pmadapter->priv[i]->bss_num == bss_num) &&
			    (pmadapter->priv[i]->bss_type == bss_type))
				return pmadapter->priv[i];
		}
	}
	return MNULL;
}

/**
 *  @brief This function returns first available priv
 *  based on the BSS role
 *
 *  @param pmadapter A pointer to mlan_adapter
 *  @param bss_role  BSS role or MLAN_BSS_ROLE_ANY
 *
 *  @return          Pointer to mlan_private
 */
static INLINE mlan_private *wlan_get_priv(mlan_adapter *pmadapter,
					  mlan_bss_role bss_role)
{
	int i;

	for (i = 0; i < MIN(pmadapter->priv_num, MLAN_MAX_BSS_NUM); i++) {
		if (pmadapter->priv[i]) {
			if (bss_role == MLAN_BSS_ROLE_ANY ||
			    GET_BSS_ROLE(pmadapter->priv[i]) == bss_role)
				return pmadapter->priv[i];
		}
	}
	return MNULL;
}

/**
 *  @brief This function counts the number of occurences for a certain
 *  condition among privs.  Which privs are checked can be configured
 *  via a second condition.
 *
 *  @param pmadapter  A pointer to mlan_adapter
 *  @param count_cond Function pointer to condition to count on privs
 *  @param check_cond Function pointer to condition to decide whether priv
 *                    should be counted or not.  Use MNULL to check all privs.
 *
 *  @return          Count of privs where count_cond returned MTRUE.
 */
static INLINE int
wlan_count_priv_cond(mlan_adapter *pmadapter,
		     t_bool (*count_cond)(pmlan_private pmpriv),
		     t_bool (*check_cond)(pmlan_private pmpriv))
{
	pmlan_private pmpriv;
	int count = 0;
	int i;

	if (pmadapter == MNULL || count_cond == MNULL)
		return 0;

	for (i = 0; i < pmadapter->priv_num; i++) {
		pmpriv = pmadapter->priv[i];
		if (pmpriv) {
			if ((check_cond == MNULL) ||
			    (check_cond && check_cond(pmpriv))) {
				if (count_cond(pmpriv))
					count++;
			}
		}
	}

	return count;
}

/**
 *  @brief This function runs a procedure on each priv.
 *  Which privs it is run on can be configured via a condition.
 *
 *  @param pmadapter  A pointer to mlan_adapter
 *  @param operation  Function pointer to produedure to operate on priv
 *  @param check_cond Function pointer to condition to decide whether priv
 *                    operated on or not.  Use MNULL to run on all privs.
 *
 *  @return           Number of privs that operation was run on.
 */
static INLINE int
wlan_do_task_on_privs(mlan_adapter *pmadapter,
		      t_void (*operation)(pmlan_private pmpriv),
		      t_bool (*check_cond)(pmlan_private pmpriv))
{
	pmlan_private pmpriv;
	int count = 0;
	int i;

	if (pmadapter == MNULL || operation == MNULL)
		return 0;

	for (i = 0; i < pmadapter->priv_num; i++) {
		pmpriv = pmadapter->priv[i];
		if (pmpriv) {
			if ((check_cond == MNULL) ||
			    (check_cond && check_cond(pmpriv))) {
				operation(pmpriv);
				count++;
			}
		}
	}

	return count;
}

/**
 *  @brief This function builds a list of privs that test for a condition
 *  This is useful if you need to do a number of operations on the same set
 *  of privs.  For one-off tasks, the above two functions might be better.
 *
 *  @param pmadapter  A pointer to mlan_adapter
 *  @param check_cond Function pointer to condition to decide whether priv
 *                    should be placed in the list.
 *  @param ppriv_list Output param.  Externally supplied array of mlan_private*
 *                    to hold priv's that test positive with check_cond.
 *                    Array size should be at least pmadapter->priv_num.
 *
 *  @return          Number of privs in ppriv_list
 *
 *  @sa              wlan_count_priv_cond
 */
static INLINE int
wlan_get_privs_by_cond(mlan_adapter *pmadapter,
		       t_bool (*check_cond)(pmlan_private pmpriv),
		       mlan_private **ppriv_list)
{
	pmlan_private pmpriv;
	int count = 0;
	int i;

	if (pmadapter == MNULL || check_cond == MNULL || ppriv_list == MNULL)
		return 0;

	for (i = 0; i < pmadapter->priv_num; i++) {
		pmpriv = pmadapter->priv[i];
		if (pmpriv) {
			if (check_cond(pmpriv))
				ppriv_list[count++] = pmpriv;
		}
	}

	return count;
}

/**
 *  @brief This function builds a list of privs that test against two conditions
 *  This is useful if you need to do a number of operations on the same set
 *  of privs.  Can choose whether both conditions (AND) or either condition (OR)
 *  is required.
 *
 *  @param pmadapter      A pointer to mlan_adapter
 *  @param check_cond     Function pointer to condition to decide whether priv
 *                        should be placed in the list.
 *  @param check_cond_2   Function pointer to second condition to check.
 *  @param and_conditions If MTRUE, both conditions must be met (AND),
 *                        else either condition can be met (OR).
 *  @param ppriv_list     Output param.  Externally supplied array of
 * mlan_private* to hold priv's that test positive with check_cond. Array size
 * should be at least pmadapter->priv_num.
 *
 *  @return          Number of privs in ppriv_list
 *
 *  @sa              wlan_count_priv_cond, wlan_get_privs_by_cond
 */
static INLINE int
wlan_get_privs_by_two_cond(mlan_adapter *pmadapter,
			   t_bool (*check_cond)(pmlan_private pmpriv),
			   t_bool (*check_cond_2)(pmlan_private pmpriv),
			   t_bool and_conditions, mlan_private **ppriv_list)
{
	pmlan_private pmpriv;
	int count = 0;
	int i;

	if (pmadapter == MNULL || check_cond == MNULL ||
	    check_cond_2 == MNULL || ppriv_list == MNULL)
		return 0;

	for (i = 0; i < pmadapter->priv_num; i++) {
		pmpriv = pmadapter->priv[i];
		if (pmpriv) {
			if (and_conditions) {
				if (check_cond(pmpriv) && check_cond_2(pmpriv))
					ppriv_list[count++] = pmpriv;
			} else {
				if (check_cond(pmpriv) || check_cond_2(pmpriv))
					ppriv_list[count++] = pmpriv;
			}
		}
	}

	return count;
}
#endif /* !_MLAN_MAIN_H_ */