summaryrefslogtreecommitdiff
path: root/network/wlan/WDI/HEADER/TypeDef.h
blob: acdcea3c369901b7bc87a594ab0c660c6a904c08 (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
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
#ifndef __INC_TYPEDEF_H
#define __INC_TYPEDEF_H


//=============================================================================
// MAX_TX_QUEUE Should be the MAX Tx queue number
//=============================================================================

#define MAX_TX_QUEUE							9	// BK, BE, VI, VO, HCCA, MANAGEMENT, COMMAND, HIGH, BEACON. 
#define MAX_RX_QUEUE							1	// MSDU packet queue, After C serie no Rx Command Queue
//

#define MAX_SUBFRAME_COUNT					64	// Max number of subframe per A-MSDU
#define MAX_FRAGMENT_COUNT					8	// Max number of MPDU per MSDU

#define MAX_PER_PACKET_VIRTUAL_BUF_NUM		24
#define MAX_PER_PACKET_PHYSICAL_BUF_NUM		MAX_PER_PACKET_VIRTUAL_BUF_NUM
#define MAX_PER_PACKET_BUFFER_LIST_LENGTH	(MAX_PER_PACKET_PHYSICAL_BUF_NUM+MAX_FRAGMENT_COUNT+4+16)		// +4 is for FirmwareInfo, Header, LLC and trailer, MAX_FRAGMENT_COUNT for max fragment overhead
														// +16 is for A-MSDU aggregation. Add this to aggregate more frames.

#define RTL8192EE_SEG_NUM	1 // 0:2 seg, 1: 4 seg, 2: 8 seg
#define RTL8814AE_SEG_NUM	1 // 0:2 seg, 1: 4 seg, 2: 8 seg
#define RTL8821BE_SEG_NUM	1 // 0:2 seg, 1: 4 seg, 2: 8 seg
#define RTL8822BE_SEG_NUM	1 // 0:2 seg, 1: 4 seg, 2: 8 seg
#define RTL8723DE_SEG_NUM	1 // 0:2 seg, 1: 4 seg, 2: 8 seg


#define	MAX_TX_REG_NUM		20
#define	MAX_RX_REG_NUM		20
//=============================================================
// TCB buffer management related definition 
//=============================================================
#define MAX_FIRMWARE_INFORMATION_SIZE		32 //2006/04/30 by Emily forRTL8190
// TODO: MAX_802_11_HEADER_LENGTH should be hardware platform independent
// Emily: The reason to set this value differently on different hardware platform 
// is because  if we set this value more than 40 , and use 8187b with TKIP mode, 
// system crash for some unknown reason. 2006.10.20. After we fix this bug, we
// should modify this definition

#define MAX_802_11_HEADER_LENGTH		40
#define	MAX_PKT_AGG_NUM		256

#define MAX_LLC_LENGTH							20
#define MAX_802_11_TRAILER_LENGTH				8	// 8(Sucurity trailer)

#define AMSDU_SUBHEADER_LENGTH				17  // 17(A-MSDU subheaders+A-MSDU paddings)
#define MAX_AMSDU_PADDING_LENGTH			3	// 3(A-MSDU paddings)


#define MAX_MCAST_LIST_NUM					32		// multicast list size
#define MAX_DEFRAG_PEER						16
#define RT_MAX_LD_SLOT_NUM					10

// Increase link retry count, fast to connect to ap within 10 second
#define MAX_JOIN_RETRY_COUNT					3 // 1 // 5


#define ASSOCIATE_ENTRY_NUM					64 // Max size of AsocEntry[].
#define MAX_LOCKED_STA_LIST_NUM				32	// Max size of LockedSTAList.
#define MAX_STA_DATARATE_LIST_NUM			ASSOCIATE_ENTRY_NUM	// Max size of ForcedDataRateStaList[]. 


// Excluded MAC address list.
#define MAX_EXCLUDED_MAC_ADDRESS_LIST		4
#define MAX_REJECTED_ACCESS_AP				4

#define AMSDU_MAX_NUM							16 // Test A-MSDU

// Number of SSID supported in scan process. 2006.12.19, by shien chang.
#define MAX_SSID_TO_SCAN						8

// Default check for hang period in second
#define	RT_CHECK_FOR_HANG_PERIOD			2 // 2 secs

#define	RT_ACTION_FRAME_DELAY_CNT		2	// based on check for hang timer 2 secs to count

#define	RX_REORDER_ENTRY_NUM		512  // m

#define	RT_SCAN_EMPTY_DUMP_REG_CNT		3


// The number of Max(ICs)
#define EARLY_MODE_MAX_PKT_NUM		15
#define EARLY_MODE_MAX_PKT_NUM_8812 15
#define EARLY_MODE_MAX_PKT_NUM_88E 	10
#define EARLY_MODE_MAX_PKT_NUM_92D 	5
#define EARLY_MODE_MAX_PKT_NUM_8723B 15
#define EARLY_MODE_MAX_PKT_NUM_8814A 15
#define EARLY_MODE_MAX_PKT_NUM_8821B 15
#define EARLY_MODE_MAX_PKT_NUM_8822B 15



//MAC0 will wirte PHY1
#define	MAC0_ACCESS_PHY1	0x4000
//MAC1 will wirte PHY0
#define	MAC1_ACCESS_PHY0	0x2000


#define MAX_H2C_CMD_DATA_SIZE		7 // The largest size of an H2C cmd is 8 bytes (after 88E series), the first bytes is CMDID.

#define	BATCH_INDICATION_LEVEL_NUM						10
#define	BATCH_INDICATION_MAX_SHAKE_NUM					8
#define	BATCH_INDICATION_SHAKE_TO_STABLE					2
#define	BATCH_INDICATION_STABLE_NUM						4
#define	BATCH_INDICATION_START_POINT						5000//3000  //YJ,mod for 88E,111229
#define	BATCH_INDICATION_PERCENTAGE_OF_DATA_RATE		38
#define	MAX_BATCH_INDICATION_NUMBER						24 
#define	MAX_BATCH_INDICATION_NUMBER_8814A				127 //add by ylb 20130729 

#define	MAX_TCP_SEQ_ENTRY_NUM	512

#define	TX_DESC_NUM_92E				512
#define	RX_DESC_NUM_92E				512

#define	TX_DESC_NUM_8723D				512
#define	RX_DESC_NUM_8723D				512

#define	TX_DESC_NUM_8814A				1024//2048 change by ylb 20130624
#define	RX_DESC_NUM_8814A				1024 //512 change by ylb 20130624
#define	EXT_TX_DESC_BLOCK_NUM_8814A			(768)//add by ylb 20141124

#define	TX_DESC_NUM_8821B				512
#define	RX_DESC_NUM_8821B				512

#define	TX_DESC_NUM_8822B				512
#define	RX_DESC_NUM_8822B				512

#define	RFD_LOWER_BOUND		32

#define RF_PATH_MAX_NUM					8

#define RTS_CTS       				0
#define CTS_TO_SELF                 1


typedef struct _RT_FILE_HANDLER {
	NDIS_HANDLE	FileHandler;
	pu1Byte		MappedFile;
	u4Byte		FileLength;

} RT_FILE_HANDLER, *PRT_FILE_HANDLER;

typedef struct _RT_SSIDS_TO_SCAN {
	OCTET_STRING		Ssid[MAX_SSID_TO_SCAN];
	u1Byte				SsidBuf[MAX_SSID_TO_SCAN][MAX_SSID_LEN];
	u1Byte				NumSsid;
} RT_SSIDS_TO_SCAN, *PRT_SSIDS_TO_SCAN;


typedef enum _WIRELESS_MODE {
	WIRELESS_MODE_UNKNOWN = 0x00,
	WIRELESS_MODE_A = 0x01,
	WIRELESS_MODE_B = 0x02,
	WIRELESS_MODE_G = 0x04,
	WIRELESS_MODE_AUTO = 0x08,
	WIRELESS_MODE_N_24G = 0x10,
	WIRELESS_MODE_N_5G = 0x20,
	WIRELESS_MODE_AC_5G = 0x40,
	WIRELESS_MODE_AC_24G  = 0x80,
	WIRELESS_MODE_AC_ONLY  = 0x100,
	WIRELESS_MODE_MAX  = 0x800,
	WIRELESS_MODE_ALL =0xFFFF //Isaiah for MacOS compiler
} WIRELESS_MODE;

typedef enum _HT_MODE {
	HT_MODE_UNDEFINED	= 0x00,
	HT_MODE_DISABLE		= 0x01,
	HT_MODE_HT			= 0x02,
	HT_MODE_VHT			= 0x04
} HT_MODE;


typedef enum _RESET_TYPE {
	RESET_TYPE_NORESET = 0x00,
	RESET_TYPE_NORMAL = 0x01,
	RESET_TYPE_SILENT = 0x02
} RESET_TYPE;

typedef enum _PS_BBREGBACKUP{
	PSBBREG_RF0 = 0,
	PSBBREG_RF1,
	PSBBREG_RF2,
	PSBBREG_AFE0,
	PSBBREG_MAX,
} PS_BBREGBACKUP;

typedef enum _PA_MODE {
	PA_MODE_EXTERNAL = 0x00,
	PA_MODE_INTERNAL_SP3T = 0x01,
	PA_MODE_INTERNAL_SPDT = 0x02	
} PA_MODE;

// Added for different registry settings to adjust TxPwr index. added by Roger, 2010.03.09.
typedef enum _TX_PWR_PERCENTAGE{
	TX_PWR_PERCENTAGE_0 = 0x01, // 12.5%
	TX_PWR_PERCENTAGE_1 = 0x02, // 25%
	TX_PWR_PERCENTAGE_2 = 0x04, // 50%
	TX_PWR_PERCENTAGE_3 = 0x08, //100%, default target output power.	
} TX_PWR_PERCENTAGE;


// Joseph TODO:
// This shall be modified for 8190
#define MAX_WIRELESS_MODE_CNT	3

#define IS_WIRELESS_MODE_A(_Adapter)		((_Adapter)->MgntInfo.dot11CurrentWirelessMode == WIRELESS_MODE_A)
#define IS_WIRELESS_MODE_B(_Adapter)		((_Adapter)->MgntInfo.dot11CurrentWirelessMode == WIRELESS_MODE_B)
#define IS_WIRELESS_MODE_G(_Adapter)		((_Adapter)->MgntInfo.dot11CurrentWirelessMode == WIRELESS_MODE_G)
#define IS_WIRELESS_MODE_N_24G(_Adapter)	((_Adapter)->MgntInfo.dot11CurrentWirelessMode == WIRELESS_MODE_N_24G)
#define IS_WIRELESS_MODE_N_5G(_Adapter)	((_Adapter)->MgntInfo.dot11CurrentWirelessMode == WIRELESS_MODE_N_5G)
#define IS_WIRELESS_MODE_AC_24G(_Adapter)	((_Adapter)->MgntInfo.dot11CurrentWirelessMode == WIRELESS_MODE_AC_24G)
#define IS_WIRELESS_MODE_AC_5G(_Adapter)	((_Adapter)->MgntInfo.dot11CurrentWirelessMode == WIRELESS_MODE_AC_5G)
#define IS_WIRELESS_MODE_AC_5G_ONLY(_Adapter)	((_Adapter)->MgntInfo.dot11CurrentWirelessMode == WIRELESS_MODE_AC_ONLY)


#define IS_WIRELESS_MODE_24G(_Adapter)	(IS_WIRELESS_MODE_B(_Adapter) || IS_WIRELESS_MODE_G(_Adapter) || IS_WIRELESS_MODE_N_24G(_Adapter) || IS_WIRELESS_MODE_AC_24G(_Adapter))
#define IS_WIRELESS_MODE_5G(_Adapter)		(IS_WIRELESS_MODE_A(_Adapter) || IS_WIRELESS_MODE_N_5G(_Adapter) || IS_WIRELESS_MODE_AC_5G(_Adapter) || IS_WIRELESS_MODE_AC_5G_ONLY(_Adapter))
#define IS_WIRELESS_MODE_N(_Adapter)		((_Adapter)->MgntInfo.dot11CurrentWirelessMode >= WIRELESS_MODE_N_24G)
#define IS_WIRELESS_MODE_HT_24G(_Adapter)	(IS_WIRELESS_MODE_N_24G(_Adapter) || IS_WIRELESS_MODE_AC_24G(_Adapter))
#define IS_WIRELESS_MODE_AC(_Adapter)		(IS_WIRELESS_MODE_AC_24G(_Adapter) || IS_WIRELESS_MODE_AC_5G(_Adapter) || IS_WIRELESS_MODE_AC_5G_ONLY(_Adapter))
#define IS_WIRELESS_OFDM_24G(_Adapter)	(IS_WIRELESS_MODE_G(_Adapter) || IS_WIRELESS_MODE_N_24G(_Adapter) || IS_WIRELESS_MODE_AC_24G(_Adapter))

#define IS_24G_WIRELESS_MODE(_WIRELESS_MODE)		((_WIRELESS_MODE)&(WIRELESS_MODE_B|WIRELESS_MODE_G|WIRELESS_MODE_N_24G|WIRELESS_MODE_AC_24G))
#define IS_5G_WIRELESS_MODE(_WIRELESS_MODE)			((_WIRELESS_MODE)&(WIRELESS_MODE_A|WIRELESS_MODE_N_5G|WIRELESS_MODE_AC_5G|WIRELESS_MODE_AC_ONLY))
#define IS_N_WIRELESS_MODE(_WIRELESS_MODE)			((_WIRELESS_MODE)&(WIRELESS_MODE_N_5G|WIRELESS_MODE_AC_5G|WIRELESS_MODE_N_24G|WIRELESS_MODE_AC_24G))
#define IS_AC_WIRELESS_MODE(_WIRELESS_MODE)			((_WIRELESS_MODE)&(WIRELESS_MODE_AC_5G|WIRELESS_MODE_AC_24G|WIRELESS_MODE_AC_ONLY))

// Add for advanced wireless mode
#define IS_WIRELESS_MODE_A_ONLY(_WIRELESS_MODE)		(_WIRELESS_MODE == WIRELESS_MODE_A)
#define IS_WIRELESS_MODE_B_ONLY(_WIRELESS_MODE)		(_WIRELESS_MODE == WIRELESS_MODE_B)
#define IS_WIRELESS_MODE_WITHOUT_B(_WIRELESS_MODE)	(!(_WIRELESS_MODE & WIRELESS_MODE_B))
#define IS_WIRELESS_MODE_G_AND_BG(_WIRELESS_MODE)	((_WIRELESS_MODE & WIRELESS_MODE_G) && !(_WIRELESS_MODE & WIRELESS_MODE_A))

#define IS_HT_SUPPORTED(_Adapter)		(_Adapter->RegHTMode >= HT_MODE_HT)
#define IS_VHT_SUPPORTED(_Adapter)		(_Adapter->RegHTMode >= HT_MODE_VHT)

//
// <Roger_Notes> Auto channel selection mechanism for P2P GO, i.e., Operation channel
// 2015.05.15.
//
#if (AUTO_CHNL_SEL_NHM ==1)	
#define IS_AUTO_CHNL_SUPPORT(_Adapter)	(GetDefaultAdapter(_Adapter)->MgntInfo.AutoChnlSel.bAutoChnlSel)
#define IS_AUTO_CHNL_IN_PROGRESS(_Adapter)	(_Adapter->MgntInfo.AutoChnlSel.AutoChnlSelCalInProgress)
#define GET_AUTO_CHNL_SELECTED_NUM(_Adapter)		(GetDefaultAdapter(_Adapter)->MgntInfo.AutoChnlSel.AutoChnlNumberSelected)
#define GET_AUTO_CHNL_STATE(_Adapter)		(GetDefaultAdapter(_Adapter)->MgntInfo.AutoChnlSel.AutoChnlStep)
#define SET_AUTO_CHNL_STATE(_Adapter, _State)\
{\
	PADAPTER pLoopAdapter = GetDefaultAdapter(_Adapter);\
	while(pLoopAdapter)\
	{\
		PlatformAcquireSpinLock(_Adapter, RT_ACS_SPINLOCK);\
		pLoopAdapter->MgntInfo.AutoChnlSel.AutoChnlStep= _State;\
		PlatformReleaseSpinLock(_Adapter, RT_ACS_SPINLOCK);\
		pLoopAdapter = GetNextExtAdapter(pLoopAdapter);\
	}\
}

#define SET_AUTO_CHNL_PROGRESS(_Adapter, _bInProgress)\
{\
	PADAPTER pLoopAdapter = GetDefaultAdapter(_Adapter);\
	while(pLoopAdapter)\
	{\
		PlatformAcquireSpinLock(_Adapter, RT_ACS_SPINLOCK);\
		pLoopAdapter->MgntInfo.AutoChnlSel.AutoChnlSelCalInProgress = _bInProgress;\
		PlatformReleaseSpinLock(_Adapter, RT_ACS_SPINLOCK);\
		pLoopAdapter = GetNextExtAdapter(pLoopAdapter);\
	}\
}

#define SET_AUTO_CHNL_SCAN_PERIOD(_Adapter, _Period)\
{\
	PADAPTER pLoopAdapter = GetDefaultAdapter(_Adapter);\
	while(pLoopAdapter)\
	{\
		PlatformAcquireSpinLock(_Adapter, RT_ACS_SPINLOCK);\
		pLoopAdapter->MgntInfo.AutoChnlSel.AutoChnlSelPeriod = _Period;\
		PlatformReleaseSpinLock(_Adapter, RT_ACS_SPINLOCK);\
		pLoopAdapter = GetNextExtAdapter(pLoopAdapter);\
	}\
}

typedef enum _AUTO_CHNL_SEL_STATE{
	ACS_BEFORE_NHM = 0,	// Before NHM measurement
	ACS_IN_NHM = 1,	// ACS is Calculating by NHM measurement
	ACS_AFTER_NHM = 2,		// ACS by NHM measurement is done
} AUTO_CHNL_SEL_STATE, *PAUTO_CHNL_SEL_STATE;

typedef   struct _RT_AUTO_CHNL_SEL
{	
	BOOLEAN			bAutoChnlSel;	
	RT_WORK_ITEM	AutoChnlSelWorkitem;
	u1Byte			AutoChnlSelCalInProgress;
	u1Byte			AutoChnlStep;	
	u2Byte			AutoChnlSelPeriod; // NHM measured period
	u1Byte			AutoChnlNumberSelected; // Channel number selected by NHM
}RT_AUTO_CHNL_SEL, *PRT_AUTO_CHNL_SEL;

#else
#define IS_AUTO_CHNL_SUPPORT(_Adapter)	FALSE
#define IS_AUTO_CHNL_IN_PROGRESS(_Adapter)	FALSE
#define GET_AUTO_CHNL_SELECTED_NUM(_Adapter)		1
#define SET_AUTO_CHNL_STATE(_Adapter, _State)
#endif

typedef enum _RT_TCB_BUFFER_TYPE{
	RT_TCB_BUFFER_TYPE_NONE,
	RT_TCB_BUFFER_TYPE_SYSTEM,				// Packet is from upper layer
	RT_TCB_BUFFER_TYPE_RFD,					// Receive forwarding packet
	RT_TCB_BUFFER_TYPE_LOCAL,				// Management
	RT_TCB_BUFFER_TYPE_FW_LOCAL,			// Firmware download buffer
	RT_TCB_BUFFER_TYPE_BT_LOCAL,				// BT 3.0
}RT_TCB_BUFFER_TYPE,*PRT_TCB_BUFFER_TYPE;

typedef enum _RT_PROTOCOL_TYPE{
	RT_PROTOCOL_802_3,
	RT_PROTOCOL_802_11,
	RT_PROTOCOL_COMMAND
}PROTOCOL_TYPE, *PPROTOCOL_TYPE;

typedef enum _RT_OP_MODE{
	RT_OP_MODE_AP,
	RT_OP_MODE_INFRASTRUCTURE,
	RT_OP_MODE_IBSS,
	RT_OP_MODE_NO_LINK,
}RT_OP_MODE, *PRT_OP_MODE;


typedef enum _RT_JOIN_NETWORKTYPE{
	RT_JOIN_NETWORKTYPE_INFRA = 1,
	RT_JOIN_NETWORKTYPE_ADHOC = 2,
	RT_JOIN_NETWORKTYPE_AUTO  = 3,
}RT_JOIN_NETWORKTYPE;

typedef enum _RT_JOIN_ACTION{
	RT_JOIN_INFRA   = 1,
	RT_JOIN_IBSS  = 2,
	RT_START_IBSS = 3,
	RT_NO_ACTION  = 4,
}RT_JOIN_ACTION;

typedef enum _RT_LED_ASSOC_STATE{
	LED_ASSOC_SECURITY_BEGIN	= 1,
	LED_ASSOC_SECURITY_END	= 2,	
	LED_ASSOC_SECURITY_NONE	= 3,
}RT_LED_ASSOC_STATE;

typedef enum _RT_802_11_RELOAD_DEFAULTS{
	RT802_11ReloadWEPKeys
}RT_802_11_RELOAD_DEFAULTS, *PRT_802_11_RELOAD_DEFAULTS;


typedef enum{
	MLMESTARTREQ_NONE  = 0,
	MLMESTARTREQ_INIT  = 1,
	MLMESTARTREQ_NWTYPE_CHANGE  = 2,
	MLMESTARTREQ_AUTH_CHANGE  = 3,
	MLMESTARTREQ_KEY_CHANGE  = 4,
	MLMESTARTREQ_PRIVACY_CHANGE  = 5,
}RT_MLMESTARTREQ_RSN;



typedef enum{
	ROAMINGSTATE_IDLE  = 0,
	ROAMINGSTATE_SCANNING  = 1,
	ROAMINGSTATE_AUTHENTICATION  = 2,
	ROAMINGSTATE_REASSOCIATION  = 3,
}RT_ROAMING_STATE;

//
// Indication of roaming status, by Bruce, 2008-05-16.
//
typedef enum _RT_ROAM_TYPE{
	RT_ROAMING_NONE = 0,	// Non-roaming. 
	RT_ROAMING_NORMAL,		// Standard 802.11 roaming procedure. (= bRoaming)
	RT_ROAMING_BY_DEAUTH,	// Not real 802.11 roaming, just for Ndis event to keep re-connecting to the original AP. ( = bRoamingByDeauth)
	RT_ROAMING_BY_SLEEP,	// Not real 802.11 roaming, just for Ndis event to keep re-connecting to the original AP after S3/S4. ( = bRoamingbySleep)
	RT_ROAMING_BY_DISCONNECT_POOR_LINK,	// Become disconnected by poor link, just find a better AP or try to join the original one.
} RT_ROAM_TYPE, *PRT_ROAM_TYPE;



//2004-04-07 for RTL8185
typedef struct _CHANNEL_ACCESS_SETTING
{
	u1Byte	CWminIndex;
	u1Byte	CWmaxIndex;
} CHANNEL_ACCESS_SETTING, *PCHANNEL_ACCESS_SETTING;

typedef enum _PROTECTION_MECHANISM {
	PROTECTION_MECHANISM_NONE = 0x00,
	PROTECTION_MECHANISM_RTS_CTS = 0x01,
	PROTECTION_MECHANISM_CTS_TO_SELF = 0x02,
} PROTECTION_MECHANISM;

//test joseph
typedef enum _IO_READ_WRITE_TYPE{
	IO_READ_WRITE_TYPE_BYTE,
	IO_READ_WRITE_TYPE_WORD,
	IO_READ_WRITE_TYPE_DWORD,
}IO_READ_WRITE_TYPE, *PIO_READ_WRITE_TYPE;

typedef enum _IO_READ_WITE_OPERATION{
	IO_READ_WRITE_OPERATION_READ = 0,
	IO_READ_WRITE_OPERATION_WRITE = 1,
}IO_READ_WRITE_OPERATION, *PIO_READ_WRITE_OPERATION;	
//end test joseph

typedef enum _MAC_FILTER_TYPE{
	MAC_FILTER_DISABLE,
	MAC_FILTER_ACCEPT,
	MAC_FILTER_REJECT,
	MAC_FILTER_LOCK,
}MAC_FILTER_TYPE, *PMAC_FLTER_TYPE;

typedef enum _ASOCENTRY_UPDATE_ASOC_INFO_ACTION
{
	ALLOCATE_ASOC_REQ,
	ALLOCATE_ASOC_RSP,
	ALLOCATE_ASOC_RSP_IE_FROM_OS,
	UPDATE_ASOC_REQ,
	UPDATE_ASOC_RSP,
	UPDATE_ASOC_RSP_IE_FROM_OS,
	FREE_ASOC_REQ,
	FREE_ASOC_RSP,
	FREE_ASOC_RSP_IE_FROM_OS
} ASOCENTRY_UPDATE_ASOC_INFO_ACTION, *PASOCENTRY_UPDATE_ASOC_INFO_ACTION;

typedef enum _NDIS_VERSION_BASE{
	NDIS_VERSION_BASE_6_50 	= 0x00060032,	// 6.50 : Threshold (Microsoft Temporarily Assigned, Not Published, 2014.08.19)
	NDIS_VERSION_BASE_6_40 	= 0x00060028,	// 6.40 : WinBlue (Microsoft Temporarily Assigned, Not Published, 2013.03.29)
	NDIS_VERSION_BASE_6_30 	= 0x0006001E,	// 6.30 : Win8
	NDIS_VERSION_BASE_6_20 	= 0x00060014,	// 6.20 : Win7
	NDIS_VERSION_BASE_6_1 	= 0x00060001,
	NDIS_VERSION_BASE_6_0 	= 0x00060000,
	NDIS_VERSION_BASE_5_2 	= 0x00050002,
	NDIS_VERSION_BASE_5_1 	= 0x00050001,
	NDIS_VERSION_BASE_5_0 	= 0x00050000,
} NDIS_VERSION_BASE, *PNDIS_VERSION_BASE;


typedef enum _RT_NDIS_VERSION{
	RT_NDIS_VERSION_NONE_NDIS,
	RT_NDIS_VERSION_5_0,
	RT_NDIS_VERSION_5_1,
	RT_NDIS_VERSION_6_0,
	RT_NDIS_VERSION_6_1,
	RT_NDIS_VERSION_6_20,
	RT_NDIS_VERSION_6_30,
	RT_NDIS_VERSION_6_40,	
	RT_NDIS_VERSION_6_50,	
}RT_NDIS_VERSION, *PRT_NDIS_VERSION;

typedef enum _RT_STA_INDICATE_STATE
{
	RT_STA_STATE_INITIAL = 			0x0001,
	RT_STA_STATE_DISASOC =			0x0020,
	RT_STA_STATE_AP_INCOMING_ASOC_STARTED = 0X0100,
	RT_STA_STATE_AP_INCOMING_ASOC_REQ_RECVD = 0X200,
	RT_STA_STATE_AP_INCOMING_ASOC_COMPLETE = 0X400
} RT_STA_INDICATE_STATE, *PRT_STA_INDICATE_STATE;

typedef struct _RT_STA_INDICATE_STATE_MACHINE
{
	RT_STA_INDICATE_STATE	CurrentState;
	u4Byte					NextState;
} RT_STA_INDICATE_STATE_MACHINE, *PRT_STA_INDICATE_STATE_MACHINE;


typedef struct _RT_TX_LOCAL_BUFFER{
	RT_LIST_ENTRY		List;
	SHARED_MEMORY		Buffer;
	u1Byte				RefCount;
}RT_TX_LOCAL_BUFFER, *PRT_TX_LOCAL_BUFFER;

typedef struct _RT_TX_AGG_COALES_BUF{
	PRT_TX_LOCAL_BUFFER	pCoalesceBuffer;
	PRT_TCB 			pLastTcb;
	u4Byte				Offset;
	u4Byte				Length;
	u1Byte				AggCnt;
}RT_TX_AGG_COALES_BUF, *PRT_TX_AGG_COALES_BUF;


typedef struct _RT_GEN_TEMP_BUFFER{
	RT_LIST_ENTRY		List;
	VIRTUAL_MEMORY		Buffer;
	BOOLEAN				isDynaAlloc;	// Dynamical Allocated or Static Allocated
}RT_GEN_TEMP_BUFFER, *PRT_GEN_TEMP_BUFFER;

typedef enum _TWO_PORT_STATUS
{
	TWO_PORT_STATUS__DEFAULT_ONLY,				// Win7, XP				
	TWO_PORT_STATUS__EXTENSION_ONLY,			// Win7, XP(AP)							
	TWO_PORT_STATUS__EXTENSION_FOLLOW_DEFAULT,	// Win7, XP				
	TWO_PORT_STATUS__DEFAULT_G_EXTENSION_N20,	// Win7, XP
	TWO_PORT_STATUS__DEFAULT_A_EXTENSION_N20,	// Win7, XP
	TWO_PORT_STATUS__ADHOC,						// Win7, XP				
	TWO_PORT_STATUS__WITHOUT_ANY_ASSOCIATE		// Win7, XP				
}TWO_PORT_STATUS;

typedef enum _TWO_PORT_SHARED_OBJECT
{
	TWO_PORT_SHARED_OBJECT__STATUS,//
	TWO_PORT_SHARED_OBJECT__SET_OF_pStaQos,
	TWO_PORT_SHARED_OBJECT__SET_OF_pStaQos_WMMParamEle,	//
	TWO_PORT_SHARED_OBJECT__BW, //
}TWO_PORT_SHARED_OBJECT;

enum _BWSGNL{
	BWSGNL_Auto = 0,
	BWSGNL_Enable = 1,
	BWSGNL_Disable = 2,
};

enum _TX_IPTYPE{
	TX_IPTYPE_UNKNOWN = 0,
	TX_IPTYPE_UDP = 1,
	TX_IPTYPE_TCP = 2,
};


typedef struct _RT_RFD_STATUS{
	//
	// The section must be the same as _ODM_Phy_Status_Info_ If someone add one
	// element in ODM structure you need to update the element in the RFD status 
	// structure and in the end of the relative area.
	//
	// _ODM_Phy_Status_Info_ Start
	//
	u4Byte			RxPWDBAll;	
	u1Byte			SignalQuality;	 		// in 0-100 index. 
	s1Byte			RxMIMOSignalQuality[4];	//per-path's EVM
	u1Byte			RxMIMOEVMdbm[4]; 		//per-path's EVM dbm
	u1Byte			RxMIMOSignalStrength[4];// in 0~100 index

	s2Byte			Cfo_short[4]; 			// per-path's Cfo_short
	s2Byte			Cfo_tail[4];				// per-path's Cfo_tail

	s1Byte			RxPower; 				// in dBm Translate from PWdB
	s1Byte			RecvSignalPower;		// Real power in dBm for this packet, no beautification and aggregation. Keep this raw info to be used for the other procedures.
	u1Byte			BTRxRSSIPercentage;	
	u1Byte			SignalStrength; 			// in 0-100 index.

	s1Byte			RxPwr[4];				//per-path's pwdb
	s1Byte			RxSNR[4];				//per-path's SNR	
#if ((RTL8822B_SUPPORT == 1) || (RTL8723D_SUPPORT == 1))
	u1Byte			RxCount:2;					/* RX path counter---*/
	u1Byte			BandWidth:2;
	u1Byte			rxsc:4;						/* sub-channel---*/
#else
	u1Byte			BandWidth;
#endif
	u1Byte			btCoexPwrAdjust;		// adjust rssi for bt coex(agc table on/1ant coex type, need to add the power offset back)
#if ((RTL8822B_SUPPORT == 1) || (RTL8723D_SUPPORT == 1))
	u1Byte			channel;						/* channel number---*/
	BOOLEAN			bMuPacket;					/* is MU packet or not---*/
	BOOLEAN			bBeamformed;				/* BF packet---*/
#endif
	//
	//	_ODM_Phy_Status_Info_ End
	//

	//
	// The section must be the same as _ODM_Per_Pkt_Info_ If someone add one
	// element in ODM structure you need to update the element in the RFD status 
	// structure and in the end of the relative area.
	//
	//	_ODM_Per_Pkt_Info_ Start
	//	
	u1Byte			RawData;		// Accordign Luke, ODM want to use raw data.
	u1Byte			StationID;
	BOOLEAN			bPacketMatchBSSID;
	BOOLEAN			bPacketToSelf;
	BOOLEAN			bPacketBeacon;
	BOOLEAN			bToSelf;
	//
	//	_ODM_Per_Pkt_Info_ End
	//

	u2Byte				Length;

	u1Byte				DataRate;
	BOOLEAN				bIsCCK;
	
	u2Byte				bHwError:1;
	u2Byte				bCRC:1;
	u2Byte				bICV:1;
	u2Byte				bShortPreamble:1;
	u2Byte				bShift:1;
	u2Byte				Decrypted:1;
	u2Byte				Wakeup:1;
	u2Byte				bSTBC:1;
	u2Byte				bLDPC:1;
	u2Byte				bIsAMPDU:1;
	u2Byte				bFirstMPDU:1;
	u2Byte				bContainHTC:1;
	u2Byte				bRxMFPPacket:1;
	u2Byte				bIndicateToIhv:1;		// Mark if this packet should be indicated to IHV service.
	u2Byte				Reserved0:1;
	u1Byte				AGC;
	u1Byte				DataRateIdx;			// The rate index in the Rx Desc
	u4Byte				TimeStampLow;
	u4Byte				TimeStampHigh;
	BOOLEAN				bIsQosData;		// Added by Annie, 2005-12-22.
	u1Byte				UserPriority;

	u1Byte				RxDrvInfoSize;
	u1Byte				RxBufShift;
	u1Byte				PacketReportType;	
	
	u2Byte				Seq_Num;
	PRX_TS_RECORD		pRxTS;
	
	u4Byte				MacID;
	u1Byte				WakeMatch;
	
	u4Byte				MacIDValidEntry[2];	// 64 bits present 64 entry.
	BOOLEAN				bForward;

	//
	// PLCP in phy status [32:7]
	//
	u1Byte				Vht_Group_Id;
	u2Byte				Vht_Nsts_Aid;
	u1Byte				Vht_Txop_Not_Allow:1;
	u1Byte				Vht_Nsym_Dis:1;
	u1Byte				Vht_Ldpc_Extra:1;
	u1Byte				Vht_Su_Mcs:4;
	u1Byte				Vht_Beamformed:1;
	//
	// End of PLCP phy status
	//

}RT_RFD_STATUS,*PRT_RFD_STATUS;


typedef struct _RT_TCB_STATUS{
	u2Byte	DataRetryCount:8;
	u2Byte	TOK:1;
	u4Byte	FrameLength:12;
}RT_TCB_STATUS,*PRT_TCB_STATUS;

typedef struct _RT_TCB{
	RT_LIST_ENTRY		List;
	u4Byte				tcbFlags;
	PADAPTER			pAdapter;
	PADAPTER			SourceAdapt;
	//2 Packet content
	RT_TCB_BUFFER_TYPE	BufferType;			// Tell you how to return this packet

	//2 Buffer description
	u4Byte				PacketLength;
	u2Byte				BufferCount;
	SHARED_MEMORY		BufferList[MAX_PER_PACKET_BUFFER_LIST_LENGTH];
	//2 Header and tail buffer
	SHARED_MEMORY		LLC;
	SHARED_MEMORY		Header[MAX_FRAGMENT_COUNT];
	SHARED_MEMORY		Tailer;				// Per MSDU trailer. If it is used, its address should be appended to buffer list.
	SHARED_MEMORY		FirewareInfo; 		        //Pass Transmission configuration for each packet to Firmware
	SHARED_MEMORY		AMSDU_SubHeader;	// A-MSDU subframe headers
	SHARED_MEMORY		Buffer;				// Shared memory used for headers and trailer
	//2 Information for returning packet
	PVOID				Reserved;			// This variable depends on BufferType
	PVOID				ReservedBack;			// This variable for Indicate to OS later
	BOOLEAN				bTxCompleteLater;		// This variable for Indicate to OS later

	//2 Tx Desc information
	u1Byte				nDescUsed;
	RT_TCB_STATUS		status;

	//2 Coalesce buffer(dynamic allocate)
	PRT_TX_LOCAL_BUFFER	pCoalesceBuffer;
	//2 Fragment information
	u2Byte				FragCount;
	u2Byte				FragLength[MAX_FRAGMENT_COUNT];
	u2Byte				FragBufCount[MAX_FRAGMENT_COUNT];
	u1Byte				nFragSent; // Number of fragment sent to lower layer. 2005.04.14, by rcnjko.
	u1Byte				nFragCompleted; // Number of fragment completed from lower layer. 070423, by rcnjko.

	//add by ylb for ExtTxBD
	BOOLEAN				isUseExtTxBDBlock;
	RT_LIST_ENTRY		ExtTxBDBlockUsedQueue;		

	//2004/07/22, kcwu
	STA_ENC_INFO_T		EncInfo;

	// CCX related.
	u4Byte				CcxIappPacketType;
	u2Byte				CcxLtFrameNumber;

	u1Byte			nStuckCount;

	//1!!!!!!!!!!!!!!!!!!!!!!!!!!!
	//1//1Attention Please!!!<11n or 8190 specific code should be put below this line>
	//1!!!!!!!!!!!!!!!!!!!!!!!!!!!
	u2Byte			TxDescDuration[MAX_FRAGMENT_COUNT];
	u2Byte			DurationFieldVal[MAX_FRAGMENT_COUNT];


#if TX_AGGREGATION
	BOOLEAN			outPending;		// for fill tx descriptor and don't bulk out
	BOOLEAN			isUsbTxAgg;
	BOOLEAN			isLastAgg;
	RT_LIST_ENTRY	aggListHead;
	u1Byte			aggNum;
	u4Byte			aggOffset;
	u2Byte			aggRequiredTxPageNum; 	// Toal Tx page number of one aggregation packet.
#endif

	//2 Joseph: This can be List instead.
	PRT_TCB				AggregatedTCB[AMSDU_MAX_NUM];
	u1Byte				AggregateNum;


	//guangan add it for sending initial cmd packet on usb interface
	BOOLEAN			bLastInitPacket;

	// Joseph 20090617: Fix TP low due to DHCP issue.
	u1Byte			specialDataType;
	u1Byte			IPType;

	// Identify FW image and H2C CMD, added by Roger, 2009.11.11.
	u1Byte		 	DescPktType;

	//Added for 92D early mode
	BOOLEAN		bEnableEarlyMode;
	BOOLEAN		bInsert8BytesForEarlyMode;
	u1Byte		EMPktNum;
	u4Byte		EMPktLen[EARLY_MODE_MAX_PKT_NUM];//The max value by HW

	//Partial Coalesce for 8192DE & 8812
	u1Byte				ColoaseMethod;
	SHARED_MEMORY		BufferListBack[MAX_PER_PACKET_BUFFER_LIST_LENGTH];
	u2Byte				ColoaseBufferCount;
	u2Byte				BufferBackCount;
	u1Byte				SubHdrIndexAry[AMSDU_MAX_NUM];

	// TxFeedback Tcb Context Place Holder for Private Data: -----------------------------
	//	+ Only access this private data inside the module by TxFeedbackGetTcbZone()	
	PRIVATE_DATA_ZONE 	TxFeedbackTcbZone[TX_FEEDBACK_SIZE_OF_TCB_ZONE];
	// ----------------------------------------------------------------------------

//1 The section is used for shortcut entry. 
/*******************************************************************************************
Sinda 2011/12/09
1. All of these variable used by RT_TCB and TXSC_TCB_ENTRY.
2. If need to add new one which do not used by TXSC_TCB_ENTRY, do not add it here.Otherwise, add it here.
3. the sequence of these variables must be the same with structure of TXSC_TCB_ENTRY.
4. Please keep the first element is "ProtocolType" and the last element is "MACHeardLen"
*******************************************************************************************/

	PROTOCOL_TYPE		ProtocolType;		// If it is RT_PROTOCOL_802_11, its content will not be changed
	u2Byte				DataRate;			// In 0.5 Mbps
	u1Byte				SpecifiedQueueID;	// Only for management queue. Otherwise set it to UNSPECIFIED_QUEUE_ID
	u1Byte				priority;
	u1Byte				TSID;				// Traffic Stream ID. WMM: 0-7, CAC: 8/9, 11e: 8-15. 070614, by rcnjko.
	u1Byte				DestinationAddress[ETHERNET_ADDRESS_LENGTH];
	u1Byte				SourceAddress[ETHERNET_ADDRESS_LENGTH];

	//3 TX Setting
	u1Byte			bLDPC:1;
	u1Byte			bSTBC:1;
	u1Byte			bEncrypt:1;
	u1Byte			bUseShortPreamble:1; 
	u1Byte			bUseShortGI:1;	//This Match "SHORT" field in TxFwInfo in datasheet.
	u1Byte			bSpecifShortGI:1;
	u1Byte			bTxDisableRateFallBack:1;
	u1Byte			bTxUseDriverAssingedRate:1;
	u1Byte			bBroadcast:1;
	u1Byte			bMulticast:1; 
	u1Byte			bBTTxPacket:1;
	u1Byte			bFromUpperLayer:1;

	u1Byte			bNeedAckReply:1;
	u1Byte			bNeedCRCAppend:1;	
	u1Byte			bTxEnableSwCalcDur:1;
	u1Byte			bTxCalculatedSwDur:1;

	//3 Protection Mode
	u1Byte			RTSSC;
	u1Byte			RTSCCA;
	u1Byte			RTSBW;
	u2Byte			RTSRate; 
	u1Byte			bHwProtection:1;
	u1Byte			bCTSEnable:1;
	u1Byte			bRTSEnable:1;
	u1Byte			bRTSSTBC:1;
	u1Byte			bRTSShort:1;
	u1Byte			bRTSReserved:3;

	//3 AMSDU and AMPDU related
	u1Byte			bAggregate:1;
	u1Byte			bAggregateBreakForBufferCount:1;//add by ylb for test 201300802
	u1Byte			bAMSDUProcessed:1;
	u1Byte			bAMPDUEnable:1;
	u1Byte			bAMPDUReserved:4;
	u1Byte			AMPDUFactor;
	u1Byte			AMPDUDensity;
	u2Byte			AMPDUBufferSize;

	// Driver assign macId for rate adaptive table
	u1Byte			macId;
	u1Byte			OdmAid;		// For ODM Luke's requirement for antenna switch.
	u2Byte			P_AID;
	u1Byte			G_ID;	
	u1Byte			RATRIndex;

	// BT
	u1Byte			BT_macId;
	
	BOOLEAN			bTDLPacket;
	BOOLEAN			bNeedTxReport;
	BOOLEAN			bSendPTIRsp;
	BOOLEAN			bSleepPkt;

	// Add for TCpChecksum
	u4Byte			TcpOffloadMode;	
	u4Byte			MACHeardLen;
//1 The section is used for shortcut entry. 

	s1Byte			SNForShortcut;

	CHANNEL_WIDTH	BWOfPacket;
	
	u2Byte			CurrentWritePoint;

	u8Byte			sysTime[4];

#if WLAN_ETW_SUPPORT
	u2Byte			TcbSequence;
	u4Byte			TcbFrameUniqueueID;
#endif

	// Beamforming packet
	u1Byte			TxBFPktType;

}RT_TCB,*PRT_TCB;

typedef struct _RX_AGGR_INFO{
	u1Byte	bIsRxAggr:1;
	u1Byte	bIsLastPkt:1;
	u1Byte	Reserved:6;
} RX_AGGR_INFO, *PRX_AGGR_INFO;

typedef enum _RX_IPTYPE{
	TCP_PACKET		= 0,
	UDP_PACKET		= 1,
} RX_IPTYPE, *PRX_IPTYPE;

typedef enum _RX_IPVER{
	IPV4		= 0,
	IPV6		= 1,
} RX_IPVER, *PRX_IPVER;

typedef enum _RX_MAC_PACKET_TYPE { 
  	RXPacketTypeUndefined  	= 0,
  	RXPacketTypeUnicast    	= 1,
  	RXPacketTypeMulticast  	= 2,
  	RXPacketTypeBroadcast  	= 3,
  	RXPacketTypeMaximum    	= 4
} RX_MAC_PACKET_TYPE, *PRX_MAC_PACKET_TYPE;

typedef struct _RX_FILTER_INFO{
	// MAC
	pu1Byte		pDA;
	pu1Byte		pSA;
	u1Byte		PacketType;  // RX_PACKET_TYPE
	pu1Byte		pEtherType;  // 2 bytes : IPv4 , IPv6 , ARP ...  
	// IP
	pu1Byte		ARPOption;  // 2 bytes Request or Response 
	pu1Byte		ARPSPA;      // 4 bytes ARP Sender IP 
	pu1Byte		ARPTPA;      // 4 bytes ARP Target IP 
	u1Byte		Protocol;      // UDP : 0x11  , TCP : 0x06
	//UDP
	pu1Byte		pDestinationPort; // 2 bytes
}RX_FILTER_INFO,*PRX_FILTER_INFO;

typedef struct _RT_RFD{	
	RT_LIST_ENTRY			List;	
	u2Byte				PacketLength;			// Total packet length: Must equal to sum of all FragLength
	u2Byte				FragLength;			// FragLength should equal to PacketLength in non-fragment case
	u2Byte				FragOffset;			// Data offset for this fragment
	u2Byte				nTotalFrag;
	pu1Byte				SubframeArray[MAX_SUBFRAME_COUNT];
	u2Byte				SubframeLenArray[MAX_SUBFRAME_COUNT];
	u1Byte				nTotalSubframe;
	BOOLEAN				bIsAggregateFrame;
	RT_RFD_STATUS		Status;
	ALIGNED_SHARED_MEMORY  Buffer;			//SHARED_MEMORY		Buffer;
	PVOID				DriverReserved;
	// 2007/01/12 MH add a element to record RX queue ID for test
	u2Byte				queue_id;
	struct _RT_RFD			*NextRfd;	

	// If this flag is set, this RFD must contain bad data; therefore, insert into its own RFD queue
	BOOLEAN				bReturnDirectly;

	BOOLEAN				bIsTemp;
#if RX_AGGREGATION
	RX_AGGR_INFO		RxAggrInfo;
	u1Byte				nChildCnt;
	struct _RT_RFD			*ParentRfd;
#endif

	u2Byte				SeqNum;
	u2Byte				ValidPacketLength;
	BOOLEAN				bRxBTdata;
	BOOLEAN				bTDLPacket;
	u1Byte				Address3[6];

	u1Byte				WapiTempPN[16];
	u1Byte				WapiSrcAddr[6];
	BOOLEAN				bWapiCheckPNInDecrypt;

	// TCP Offload 
	BOOLEAN				bHWChecksum;
	RX_IPVER				IPver;
	RX_IPTYPE			IPType;
	BOOLEAN				bCheckErr;

	// D0 Parse Packet Information
	RX_FILTER_INFO 		D0FilterCoalPktInfo;

	//ODM_PHY_INFO_T			PhyInfo;//must discuss with MH
#if (MULTIPORT_SUPPORT == 1)
	// NOTE: ----------------------------------------------------------------
	// This flag is used to decide if FeedPacketToMultipleAdapter() should be executed.
	BOOLEAN				bFeedPacketToSingleAdapter;
	// ----------------------------------------------------------------------

	// Data Buffer --------------------------------
	MEMORY_BUFFER		mbCloneRfdDataBuffer;
	// ------------------------------------------
	
#endif


	u4Byte				SdioTransferLength;

#if WLAN_ETW_SUPPORT
	u4Byte			RfdFrameUniqueueID;
#endif

}RT_RFD,*PRT_RFD;

typedef struct _DEFRAG_ENTRY
{
	BOOLEAN				bUsed;
	u1Byte				SenderAddr[6];
	u1Byte				TID;
	u2Byte				SeqNum;
	u1Byte				LastFragNum;
	u8Byte				usMaxLifeTimeStamp;
	u8Byte				usLastArriveTimeStamp;
	PRT_RFD				pRfdHead;
	PRT_RFD				pRfdTail;

}DEFRAG_ENTRY, *PDEFRAG_ENTRY;

typedef struct _RX_REORDER_ENTRY
{
	RT_LIST_ENTRY	List;
	u2Byte			SeqNum;
	PRT_RFD			pRfd;
} RX_REORDER_ENTRY, *PRX_REORDER_ENTRY;


typedef	struct _RT_9X_TX_RATE_HISTORY {
	u4Byte		CCK[4];
	u4Byte		OFDM[8];
	// HT_MCS[0][]: BW=0 SG=0
	// HT_MCS[1][]: BW=1 SG=0
	// HT_MCS[2][]: BW=0 SG=1
	// HT_MCS[3][]: BW=1 SG=1
	u4Byte		HT_MCS[4][16];
}RT_TX_RAHIS_T, *PRT_TX_RAHIS_T;

typedef	struct _RT_SMOOTH_DATA {
	u4Byte	elements[100];	//array to store values
	u4Byte	index;			//index to current array to store
	u4Byte	TotalNum;		//num of valid elements
	u4Byte	TotalVal;		//sum of valid elements
}RT_SMOOTH_DATA, *PRT_SMOOTH_DATA;

typedef	struct _RT_SMOOTH_DATA_4RF {
	s1Byte	elements[4][100];//array to store values
	u4Byte	index;			//index to current array to store
	u4Byte	TotalNum;		//num of valid elements
	u4Byte	TotalVal[4];		//sum of valid elements
}RT_SMOOTH_DATA_4RF, *PRT_SMOOTH_DATA_4RF;


typedef union _MGN_RATE{
	u2Byte	RawValue;

	struct {
		u1Byte	RateIdx;
		u1Byte	Rsvd:5;
		u1Byte	SGI:1;
		u1Byte	Bw:1;
		u1Byte	HT:1;
	};
} MGN_RATE;

typedef enum _RATE_INDEX{
	RATE_CCK_1M			= 0,
	RATE_CCK_2M			= 1,
	RATE_CCK_5_5M		= 2,
	RATE_CCK_11M		= 3,
	RATE_OFDM_6M		= 4,
	RATE_OFDM_9M		= 5,
	RATE_OFDM_12M		= 6,
	RATE_OFDM_18M		= 7,
	RATE_OFDM_24M		= 8,
	RATE_OFDM_36M		= 9,
	RATE_OFDM_48M		= 10,
	RATE_OFDM_54M		= 11,
	RATE_MCS_0			= 12,
	RATE_MCS_1			= 13,
	RATE_MCS_2			= 14,
	RATE_MCS_3			= 15,
	RATE_MCS_4			= 16,
	RATE_MCS_5			= 17,
	RATE_MCS_6			= 18,
	RATE_MCS_7			= 19,
	RATE_MCS_8			= 20,
	RATE_MCS_9			= 21,
	RATE_MCS_10			= 22,
	RATE_MCS_11			= 23,
	RATE_MCS_12			= 24,
	RATE_MCS_13			= 25,
	RATE_MCS_14			= 26,
	RATE_MCS_15			= 27,
	RATE_MCS_16			= 28,
	RATE_MCS_17			= 29,
	RATE_MCS_18			= 30,
	RATE_MCS_19			= 31,
	RATE_MCS_20			= 32,
	RATE_MCS_21			= 33,
	RATE_MCS_22			= 34,
	RATE_MCS_23			= 35,
	RATE_MCS_24			= 36,
	RATE_MCS_25			= 37,
	RATE_MCS_26			= 38,
	RATE_MCS_27			= 39,
	RATE_MCS_28			= 40,
	RATE_MCS_29			= 41,
	RATE_MCS_30			= 42,
	RATE_MCS_31			= 43,
	RATE_VHT_1SS_MCS_0	= 44,
	RATE_VHT_1SS_MCS_1	= 45,	
	RATE_VHT_1SS_MCS_2	= 46,
	RATE_VHT_1SS_MCS_3	= 47,
	RATE_VHT_1SS_MCS_4	= 48,
	RATE_VHT_1SS_MCS_5	= 49,
	RATE_VHT_1SS_MCS_6	= 50, 
	RATE_VHT_1SS_MCS_7	= 51,
	RATE_VHT_1SS_MCS_8	= 52,
	RATE_VHT_1SS_MCS_9	= 53,
	RATE_VHT_2SS_MCS_0	= 54,
	RATE_VHT_2SS_MCS_1	= 55,
	RATE_VHT_2SS_MCS_2	= 56,
	RATE_VHT_2SS_MCS_3	= 57,
	RATE_VHT_2SS_MCS_4	= 58,
	RATE_VHT_2SS_MCS_5	= 59,
	RATE_VHT_2SS_MCS_6	= 60,
	RATE_VHT_2SS_MCS_7	= 61,
	RATE_VHT_2SS_MCS_8	= 62,
	RATE_VHT_2SS_MCS_9	= 63,
	RATE_VHT_3SS_MCS_0	= 64,
	RATE_VHT_3SS_MCS_1	= 65,
	RATE_VHT_3SS_MCS_2	= 66,
	RATE_VHT_3SS_MCS_3	= 67,
	RATE_VHT_3SS_MCS_4	= 68,
	RATE_VHT_3SS_MCS_5	= 69,
	RATE_VHT_3SS_MCS_6	= 70,
	RATE_VHT_3SS_MCS_7	= 71,
	RATE_VHT_3SS_MCS_8	= 72,
	RATE_VHT_3SS_MCS_9	= 73,
	RATE_VHT_4SS_MCS_0	= 74,
	RATE_VHT_4SS_MCS_1	= 75,
	RATE_VHT_4SS_MCS_2	= 76,
	RATE_VHT_4SS_MCS_3	= 77,
	RATE_VHT_4SS_MCS_4	= 78,
	RATE_VHT_4SS_MCS_5	= 79,
	RATE_VHT_4SS_MCS_6	= 80,
	RATE_VHT_4SS_MCS_7	= 81,
	RATE_VHT_4SS_MCS_8	= 82,
	RATE_VHT_4SS_MCS_9	= 83,
	RATE_MCS_32			= 84,
	RATE_UNKNOWN		= 85,	
	PKT_MGNT			= 86,
	PKT_CTRL			= 87,
	PKT_UNKNOWN			= 88,
	PKT_NOT_FOR_ME		= 89,
	RATE_MAX
} RATE_INDEX, *PRATE_INDEX;

typedef	struct _RT_TX_STATISTICS {
	u8Byte		NumTxMulticast;
	u8Byte		NumTxBroadcast;
	u8Byte		NumTxUnicast;
	u8Byte		NumTxOkTotal;
	u8Byte		NumTxBytesUnicast;
	u8Byte		NumTxBytesBroadcast;
	u8Byte		NumTxBytesMulticast;
	u8Byte		NumTxOkBytesTotal;
	u8Byte		NumTxErrTotal;
	u8Byte		NumTxErrBytesTotal;
	u8Byte		NumTxErrUnicast;
	u8Byte		NumTxErrBroadcast;
	u8Byte		NumTxErrMulticast;
	u8Byte		NumTxRetryCount;
	u4Byte		NumTxBeaconOk;
	u4Byte		NumTxBeaconErr;
	u4Byte		NumTxBeaconUpdate;
	//cosa add for debug 10/18/2007
	u4Byte		NumTxInterrupt;
	u4Byte		NumTxSemaphore;
	u4Byte		NumTxDescClosed[MAX_TX_QUEUE];
	u4Byte		NumTxDescFill[MAX_TX_QUEUE];
	//cosa add for debug 08/23/2007
	u4Byte		NumMpSendPacketsCalled;
	u4Byte		NumOutOfTCB;
	u4Byte		numTcbOk;
	u4Byte		NumTransmitTCBCalled[MAX_TX_QUEUE];
	u4Byte		NumTransmitTCBAvailable[MAX_TX_QUEUE];
	u4Byte		NumTransmitTCBNotAvailable[MAX_TX_QUEUE];
	u4Byte		NumTransmitTCBInsertTcbBusyQueue[MAX_TX_QUEUE];
	// for debug
	u4Byte		NumTxFeedBack;
	u4Byte		NumTxFeedBackRetry;
	u4Byte		NumTxFeedBackOk;
	u4Byte		NumTxFeedBackFail;

	u4Byte		TransmittedRateHistogram[RATE_MAX];	
	u4Byte		AllTransmittedRateHistogram[RATE_MAX];	
	u4Byte		TransmittedRateRetry[RATE_MAX];	
	u4Byte		AllTransmittedRateRetry[RATE_MAX];

	u4Byte		TxAMSDUSizeHistogram[5];		// level: (<1k), (1k~2k), (2k~4k), (4k~6k), (6K~8K)
	u4Byte		TxAMSDUNumHistogram[5];		// level: (<3), (3~5), (6~9), (10~19), (>20)
	
	// For AMSDU efficiency, added by Emily, 2007.10.01
	u4Byte		AMSDUTxBufferNotAvaliable;
	u4Byte		AMSDUTxDescNotAvaliable;

	u1Byte		LastPacketRate;	//cosa add for debug 11/19/2007

	// 2008/03/35 MH Collect all transmit rate history for 9x series.
	RT_TX_RAHIS_T	TxRate;		

	//for show Tx DataRate , by Jacken 2008/03/28
	u1Byte		CurrentInitTxRate;
	u4Byte		CurrentTxTP;
	u4Byte		CurrentTxTP_Kbps;

	//Added for remember last tx ok packet for every adapter 20130116
	//by sherry
	u4Byte		LastNumTxOkBytesTotal; 
	u8Byte		StartNumTxOkBytesTotal;
}RT_TX_STATISTICS, *PRT_TX_STATISTICS;

typedef struct _TX_GENERAL{
	RT_THREAD			txGenThread;
	PlatformSemaphore	txGenSemaphore;
	

}TX_GENERAL, *PTX_GENERAL;


typedef struct _RT_RX_STATISTICS {
	u8Byte		NumRxBroadcast;
	u8Byte		NumRxUnicast;
	u8Byte		NumRxMulticast;
	u8Byte		NumRxOkTotal;
	u8Byte		NumRxErrTotalUnicast;
	u8Byte		NumRxErrTotalMulticast;
	u8Byte		NumRxBytesUnicast;
	u8Byte		NumRxBytesMulticast;
	u8Byte		NumRxBytesBroadcast;
	u8Byte		NumRxOkBytesTotal;
	u8Byte		NumRxRetryCount;
	u8Byte		NumRxOKSmallPacket;
	u8Byte		NumRxOKMiddlePacket;
	u8Byte		NumRxOKLargePacket;
	u8Byte		NumRxRetrySmallPacket;
	u8Byte		NumRxRetryMiddlePacket;
	u8Byte		NumRxRetryLargePacket;
	u8Byte		NumRxCrcErrSmallPacket;
	u8Byte		NumRxCrxErrorPacket;
	u8Byte		NumRxCrcErrMiddlePacket;
	u8Byte		NumRxCrcErrLargePacket;
	u8Byte		NumRxIcvErr;
	u8Byte		NumRxExcludeUnencryptedUnicast;
	u8Byte		NumRxExcludeUnencryptedMulticast;
	u8Byte		NumRxExcludeUnencryptedBroadcast;
	u8Byte		NumRxTKIPLocalMICFailuresUnicast;
	u8Byte		NumRxTKIPLocalMICFailuresMulticast;
	u8Byte		NumRxTKIPLocalMICFailuresBroadcast;
	u8Byte		NumRxTKIPICVErrorUnicast;
	u8Byte		NumRxTKIPICVErrorMulticast;
	u8Byte		NumRxTKIPICVErrorBroadcast;
	u8Byte		NumRxCCMPDecryptErrorsUnicast;
	u8Byte		NumRxCCMPDecryptErrorsMulticast;
	u8Byte		NumRxCCMPDecryptErrorsBroadcast;
	u8Byte		NumRxWEPICVErrorUnicast;
	u8Byte		NumRxWEPICVErrorMulticast;
	u8Byte		NumRxWEPICVErrorBroadcast;
	u8Byte		NumRxWEPUndecryptableUnicast;	
	u8Byte		NumRxWEPUndecryptableMulticast;
	u8Byte		NumRxWEPUndecryptableBroadcast;
	u8Byte		NumRxTKIPReplayMulticast;
	u8Byte		NumRxTKIPReplayUnicast;
	u8Byte		NumRxCCMPReplayMulticast;
	u8Byte		NumRxCCMPReplayUnicast;
	u8Byte		NumRxDecryptSuccessUnicast;		//fake, for Ndistest
	u8Byte		NumRxDecryptSuccessMulticast;		//fake, for Ndistest
	u8Byte		NumRxDecryptSuccessBroadcast;		//fake, for Ndistest	
	u8Byte		NumRxDecryptFailureUnicast;		//fake, for Ndistest
	u8Byte		NumRxDecryptFailureMulticast;		//fake, for Ndistest
	u8Byte		NumRxDecryptFailureBroadcast;		//fake, for Ndistest
	u8Byte		NumRxMgntTKIPICVError;			// CCXv5, S67 MFP TKIP
	u8Byte		NumRxMgntTKIPNoEncrypt;			// CCXv5, S67 MFP TKIP
	u8Byte		NumRxMgntTKIPMICFailures;		// CCXv5, S67 MFP TKIP
	u8Byte		NumRxMgntTKIPMHDRError;			// CCXv5, S67 MFP TKIP
	u8Byte		NumRxMgntTKIPReplay;			// CCXv5, S67 MFP TKIP
	u8Byte		NumRxMgntCCMPDecryptError;		// CCXv5, S67 MFP AES
	u8Byte		NumRxMgntCCMPNoEncrypt;			// CCXv5, S67 MFP AES
	u8Byte		NumRxMgntCCMPReplay;			// CCXv5, S67 MFP AES
	u8Byte		NumRxMgntDisassocBroadcast;		// CCXv5, S67 MFP
	u8Byte		NumRxMgntDeauthBroadcast; 		// CCXv5, S67 MFP
	u8Byte		NumRxMgntActionBroadcast;		// CCXv5, S67 MFP
	u8Byte		NumRxReceivedFrameCount;
	u8Byte		NumRxCmdPkt[4];		//07/03/09 MH rx cmd element txfeedback/bcn report/cfg set/query
	u8Byte		NumRxMgntPacket;	//Add by Maddest for DTM 1.0c 070823
	s4Byte		SignalStrength; // Transformed, in dbm. Beautified signal strength for UI, not correct.
	s4Byte		RecvSignalPower;	// Correct smoothed ss in Dbm, only used in driver to report real power now.
	u4Byte		RssiOldCalculateCnt;	// counter for Old RSSI calculation for Antenna lock test
	u4Byte		RssiCalculateCnt;	// counter for RSSI calculation for Antenna lock test
	u4Byte		PWDBAllCnt;
	u4Byte		PWDBAllOldCnt;
	

	RT_SMOOTH_DATA 		ui_rssi;
	RT_SMOOTH_DATA 		ui_link_quality;

	s4Byte		LastSignalQualityInPercent; // In percentange, used for smoothing, e.g. Moving Average.
	u1Byte		LastLinkQuality;
	s4Byte		SignalQuality; // Transformed.
	u1Byte		QueryAfterFirstReset;		//20061208 for ndistest by David. 
	u8Byte		NumRxFramgment;
	u4Byte		ReceivedRateHistogram[RATE_MAX];	//2013/05/16 revised by cosa
	u4Byte		ReceivedRateHwErr[RATE_MAX];		//2013/08/14 cosa added for bt coex
	BOOLEAN		RxRateHistory;
		
	// used for bt coex, cosa add 2013/08/15
	u4Byte		ReceivedRateHistogramBtCoex[RATE_MAX];
	u4Byte		ReceivedRateHwErrBtCoex[RATE_MAX];
	
	u4Byte		RxAMPDUSizeHistogram[5]; // level: (<4K), (4K~8K), (8K~16K), (16K~32K), (32K~64K)
	u4Byte		RxAMPDUNumHistogram[5]; // level: (<5), (5~10), (10~20), (20~40), (>40)
	u4Byte		RxAMSDUSizeHistogram[5];		// level: (<1k), (1k~2k), (2k~4k), (4k~6k), (6K~8K)
	u4Byte		RxAMSDUNumHistogram[5];		// level: (<3), (3~5), (6~9), (10~19), (>20)
	// 2012/11/07 MH Add for BB team VHT debug
	u4Byte		PacketAbilityCnt[4];	// 0/1/2/3=

	s4Byte		RxSNRdB[4];
	u1Byte		RxRSSIPercentage[4];
	
	u1Byte		RxEVMdbm[4]; 		
	u1Byte		RxEVMPercentage[2];

	s2Byte		RxCfoShort[4];
	s2Byte		RxCfoTail[4];

	u4Byte		NumRx20MHzPacket;
	u4Byte		NumRx40MHzPacket;
	//10/18/2007 cosa add for rx statistics
	u4Byte		NumRxInterrupt;
	u4Byte		NumRxDescFilled[MAX_RX_QUEUE];
	u4Byte		NumRxDescReturn[MAX_RX_QUEUE];
	
	u8Byte		NumQryPhyStatus;		// debug use only.
	u8Byte		NumQryPhyStatusCCK;	// debug use only.
	u8Byte		NumQryPhyStatusHT;		// debug use only.
	u8Byte		NumPacketMatchBSSID;	// debug use only.
	u8Byte		NumPacketToSelf;		// debug use only.
	u8Byte		NumProcessPhyInfo;		// debug use only.
	u8Byte		NumNotCMPKRXQID;		// debug use only.
	u8Byte		NumCMPKRXQID;			// debug use only.

	//for show Rx DataRate , by Jacken 2008/03/12
	u4Byte		ReceivePacketDataRateCounter[77];
	MGN_RATE	CurRxDataRate;
	u4Byte		CurRxOfdmNum;
	u4Byte		CurRxCckNum;

	u4Byte		CurRxSniffMediaPktCnt;
	u4Byte		LastRxSniffMediaPktCnt;

	u4Byte		ReceivedRateFromAPHistogram[32];

	u4Byte		CurrentRxTP;
	u4Byte		CurrentRxTP_Kbps;
	
	//Added for remember last rx ok packet for every adapter 20130116
	//by sherry
	u4Byte		LastNumRxOkBytesTotal;
	u8Byte		StartNumRxOkBytesTotal;
}RT_RX_STATISTICS, *PRT_RX_STATISTICS;

//----------------------------------------------------------------------------
// For 8186 Realtek element parsing. Added by Roger, 2006.12.07.
//
typedef	struct _RT_TURBO_MODE_IE_VALUE{
	u1Byte		Type;
	u1Byte		Length;
	u1Byte		Value;
}RT_TURBO_MODE_IE_VALUE, *PRT_TURBO_MODE_IE_VALUE;

//
// For 8186 Realtek element parsing. Added by Roger, 2006.12.07.
//
typedef	enum _RT_IE_TYPES
{
	eRT_IE_TYPE1_TURBO_MODE = 1,
	eRT_IE_TYPE2_AGGREGATION_MODE =2,
	eRT_IE_TYPE_MAX
}RT_IE_TYPES, *PRT_IE_TYPES;


//
// For 8186 Realtek element parsing.
//
#define GET_RTIE_CAPABILITY_TURBO_MODE(_pStart)			((u1Byte)LE_BITS_TO_2BYTE( ((pu1Byte)(_pStart)), 0, 1))
#define SET_RTIE_CAPABILITY_TURBO_MODE(_pStart, _value)		SET_BITS_TO_LE_2BYTE( ((pu1Byte)(_pStart)), 0, 1, (u1Byte)(_value))

#define GET_RTIE_CAPABILITY_DISABLE_TURBO(_pStart)		((u1Byte)LE_BITS_TO_2BYTE( ((pu1Byte)(_pStart)), 1, 1))
#define SET_RTIE_CAPABILITY_DISABLE_TURBO(_pStart, _value)	SET_BITS_TO_LE_2BYTE( ((pu1Byte)(_pStart)), 1, 1, (u1Byte)(_value))

//----------------------------------------------------------------------------


typedef struct _RT_LINK_DETECT_T{

	u4Byte				NumRecvBcnInPeriod;
	u4Byte				NumRecvDataInPeriod;

	BOOLEAN 			bClientAskForFCS; //When Client is asking for FCS, GO shall skip scanning. 
	u4Byte				ClientAskForFCSNum;	// number of Client asking for FCS
	u4Byte				RxNullDataNum;	// number of Rx Null Data

	u4Byte				RxBcnNum[RT_MAX_LD_SLOT_NUM];	// number of Rx beacon / CheckForHang_period  to determine link status
	u4Byte				RxDataNum[RT_MAX_LD_SLOT_NUM];	// number of Rx data / CheckForHang_period  to determine link status
	u2Byte				SlotNum;	// number of CheckForHang period to determine link status
	u2Byte				SlotIndex;

	u4Byte				NumTxOkInPeriod;
	u4Byte				NumRxOkInPeriod;
	u4Byte				NumRxUnicastOkInPeriod;
	u1Byte				NumRxUnicastThresh;
	u1Byte				NumRxOkThresh;
	u1Byte				NumRxUnicastTxOkThresh;

	BOOLEAN				bBusyTraffic;
	u4Byte				continuousIdleCnt;
	BOOLEAN				bTxBusyTraffic;
	BOOLEAN				bRxBusyTraffic;
	BOOLEAN				bHigherBusyTraffic; // For interrupt migration purpose.
	BOOLEAN				bHigherBusyRxTraffic; // We may disable Tx interrupt according as Rx traffic.
	BOOLEAN				bVeryHigherBusyTraffic; // For interrupt migration purpose.
	BOOLEAN				bVeryHigherBusyRxTraffic; // We may disable Tx interrupt according as Rx traffic.
	BOOLEAN				bVeryHigherBusyTxTraffic; // We may disable Tx interrupt according as Rx traffic.
	u4Byte				LastNumTxOkInPeriod;
	u4Byte				LastNumRxOkInPeriod;
	BOOLEAN				bStableHigherBusyTraffic;	//by tynli.

	BOOLEAN				bBusyTrafficAccordingTP;
	BOOLEAN				bTxBusyTrafficAccordingTP;
	BOOLEAN				bRxBusyTrafficAccordingTP;

	u1Byte 				LastConnectedCenterFrequency;
	CHANNEL_WIDTH 		LastConnectedBandwidth;	
	u4Byte				ConnectButNoBcnInPeriodCnt;			//debug only
	u4Byte				ConnectButNoDataInPeriodCnt;		//debug only
	u4Byte				OnBeaconCnt_OnBeacon;				//debug only
	u4Byte				OnBeaconScanCnt_OnBeacon_Scan;	//debug only
	u4Byte				OnBeaconJoinCnt_OnBeacon_Join;		//debug only
	u4Byte				OnBeaconBssCnt_OnBeacon_Bss;		//debug only
	u4Byte				OnBeaconIbssCnt_OnBeacon_Ibss;	//debug only
	u4Byte				OnDeauthCnt;						//debug only
	u4Byte				OnDisassocCnt;						//debug only
	u4Byte				BecomeDisconnectedCnt;				//debug only
	u4Byte				InfraDisconnectRoamingStartCnt;		//debug only
	u4Byte				InfraDisconnectRoamingFailCnt;		//debug only
	u4Byte				AdhocDisconnectCnt;					//debug only
	u4Byte				ConnectResumeFromRoaming;		//debug only
	u4Byte				IndicateDisconnectCnt;				//debug only
	u4Byte				BecomeDisconnectedIndex;			//debug only
	u8Byte				BecomeDisconnectedTime[10];		//debug only
}RT_LINK_DETECT_T, *PRT_LINK_DETECT_T;



typedef struct _IbssParms{
	u2Byte   atimWin;
}IbssParms, *PIbssParms;


//
// For AP mode force per-sta data rate (ASUS WiFi-Phone project), 2006.04.18, by rcnjko.
//
typedef struct _RT_STA_DATARATE{
	u1Byte			StaAddr[6];
	u2Byte			DataRate; // in unit of 0.5 Mbps
}RT_STA_DATARATE, *PRT_STA_DATARATE;


#define MAX_BSS_DESC   512	// 40=>64, 2005.03.31, by rcnjko.

//
// 2010/12/09 MH When merging the linux code from SC, we find that the XP linker pop
// up error information. OnBeacon_Join can not be refernced in mgntengine.c object. It is 
// caused by the linker stack limitation. We declare too much local variable in the function.
// To solve the problem temporarily we decrease the max BSS_IE_BUF_LEN to 1024. Because
// linux declare two buffer as 256+256. The right way is not to use so much local buffer in stack
// We need to merge 92S code to fix the problem.
//
//#define BSS_IE_BUF_LEN   2048

#define BSS_IE_BUF_LEN   1024
#define WCN_IE_BUF_LEN 256
#define MAX_WPA_IE_BUF_LEN 256
#define MAX_RSN_IE_BUF_LEN 256


#define MAX_RFD_ARRAY_NUM 2048

//
// Define the receiving packet type in scanning. By Bruce, 2008-05-23.
//
#define	BSS_PKT_BEACON		BIT1
#define	BSS_PKT_PROBE_RSP	BIT2


typedef struct _ChnlSwitchAnnouncement{
	BOOLEAN				bWithCSA;
	u1Byte				channelSwtichMode;
	u1Byte				NewChnlNum;
	u1Byte				channelSwitchCnt;	
}ChnlSwitchAnnouncement, *PChnlSwitchAnnouncement;


typedef struct _RT_WLAN_BSS{
	u1Byte			bdBssIdBuf[6];
	u1Byte			bdSsIdBuf[33];
	u1Byte			bdSsIdLen;
	u2Byte			bdBcnPer;		 // beacon period in Time Units
	u1Byte			bdDtimPer;		// DTIM period in beacon periods
	u8Byte			bdTstamp;		// 8 Octets from ProbeRsp/Beacon
	u2Byte			bdCap;			// capability information

	u1Byte			bdMacAddressBuf[6];

	u1Byte			bdSupportRateEXBuf[MAX_NUM_RATES];
	u2Byte			bdSupportRateEXLen;

	IbssParms		bdIbssParms;	// empty if infrastructure BSS
	u1Byte			ChannelNumber;
	u1Byte			RegulatoryClass;	// Regulatory Class from 0 to 255
	CHANNEL_WIDTH	bdBandWidth;

	u1Byte			RSSI; // 0-100.
	s4Byte			RecvSignalPower; // In dBm. (equal to last recv beacon directly)
	s4Byte			CumRecvSignalPower;	// In dBm. (Cumulate with weighted ratio and a small in/decrease)
	u1Byte			SignalQuality; // 0-100
	u1Byte			BssPacketType; // The packet type received when scanning.
	s4Byte			Noise; // In dBm.

	u1Byte			bdERPInfo;
	BOOLEAN			bERPInfoValid;

	WIRELESS_MODE	wirelessmode;

	// Our TSF when receving thisp packet.
	u4Byte			RecvTsfLow;
	u4Byte			RecvTsfHigh;
	
	u2Byte						SecVersion;

	RT_ENC_ALG					GroupCipherSuite;
	RT_ENC_ALG					PairwiseCipherSuite[MAX_CIPHER_SUITE_NUM];
	u2Byte						PairwiseCipherCount;
	AKM_SUITE_TYPE				AuthSuite[MAX_AUTH_SUITE_NUM];
	u2Byte						AuthSuiteCount;	

	u2Byte						PMKIDCount;
	RT_PMKID_TYPE				PMKIDList[1];
	BOOLEAN						bPreAuth;
	u1Byte						NumOfPTKReplayCounter;
	u1Byte						NumOfGTKReplayCounter;

	u1Byte						bMFPR;
	u1Byte						bMFPC;
	u1Byte						bMFPBIP;

	// Qos related. Added by Annie, 2005-11-01.
	BSS_QOS						BssQos;
	u1Byte						LastChnlUpdatecount;


	// For 8186 auto-turbo advertising. Added by Roger, 2006.12.07.
	BOOLEAN						bRealtekCapType1Exist;	// Added for 8186 auto-turbo advertising.
	u2Byte						RealtekCap;
	BOOLEAN						bRealtekAggCapExist;

	//2004/06/29, kcwu, for WPA
	u1Byte						IEBuf[BSS_IE_BUF_LEN];
	OCTET_STRING				IE;
	RT_SECURITY_LEVEL			SecLvl;
	
	u1Byte						WpaIeBuf[MAX_WPA_IE_BUF_LEN];
	OCTET_STRING	 			WpaIe;

	u1Byte						RsnIeBuf[MAX_RSN_IE_BUF_LEN];
	OCTET_STRING	 			RsnIe;

#if (WPS_SUPPORT == 1)
	u1Byte						BeaconWcnIeBuf[WCN_IE_BUF_LEN];
	OCTET_STRING				osBeaconWcnIe;

	u1Byte						ProbeRspWcnIeBuf[WCN_IE_BUF_LEN];
	OCTET_STRING	 			osProbeRspWcnIe;

	//
	//david add 20061002 simple config IE
	//
	u1Byte						bdSimpleConfIEBuf[MAX_SIMPLE_CONFIG_IE_LEN_V2];	// Note: we should not allocate too large buffer, or 98 will encounter BSOD. Annie, 2006-10-19.
	OCTET_STRING				bdSimpleConfIE;
#endif

	//
	// 802.11d Country IE
	//
	u1Byte						bdCountryIEBuf[MAX_IE_LEN];
	OCTET_STRING				bdCountryIE;

	//
	// WMM parameter IE 
	//
	OCTET_STRING				osWmmAcParaIE;
	u1Byte						WmmAcParaBuf[WMM_PARAM_ELEMENT_SIZE];	// Max WMM parameter size is 24 octets.

	//
	// Power Constraint IE
	//
	OCTET_STRING				osPowerConstraintIe;
	u1Byte						PowerConstraintBuf[MAX_DOT11_POWER_CONSTRAINT_IE_LEN];

	// HT Related, by Emily, 2006.08.14
	BSS_HT						BssHT;
	BSS_VHT						BssVHT;
	u1Byte					 	Vender;	
	u1Byte						SubTypeOfVender;
	u8Byte						HistoryTime;
	u1Byte						HistoryCount;	
		
	//
	// For Chiper check !! add by CCW 2008/0918
	//
	u1Byte						PairwiseChiper;
	u1Byte						GroupChiper;
	u4Byte						AKMsuit;


#if (P2P_SUPPORT == 1)
	u1Byte						P2PManagedInfo; // Wlan AP supports P2P managed device capability.
#endif

#if (DFS_SUPPORT == 1)
	//
	// For 802.11h, dfs, channel switch announcement add by cosa 2010/09/02
	//
	ChnlSwitchAnnouncement		CSA;
#endif

}RT_WLAN_BSS, *PRT_WLAN_BSS;

typedef struct _RT_WLAN_RSSI{
	u1Byte			bdBssIdBuf[6];
	u1Byte			bdSsIdBuf[33];
	u1Byte			bdSsIdLen;

	s4Byte			CumRecvSignalPower;	// In dBm. (Cumulate with weighted ratio and a small in/decrease)
	
}RT_WLAN_RSSI, *PRT_WLAN_RSSI;

#pragma pack(4)
typedef struct _RT_WLAN_BSS_Customized{
	u1Byte			SsIdBuf[33];
	u1Byte			SsIdLen;
	u1Byte			BssPacketType; // The packet type received when scanning.
	u1Byte			ChannelNumber;
	s4Byte			RecvSignalPower; // In dBm. (equal to last recv beacon directly)
	u8Byte			TimeStamp;		// 8 Octets from ProbeRsp/Beacon
	s4Byte			Noise; // In dBm.
	u1Byte			BssIdBuf[6];
	u1Byte			Reserved[2];
}RT_WLAN_BSS_Customized, *PRT_WLAN_BSS_Customized;
#pragma pack()

//
// 061122, rcnjko: 
// We SHALL use this macro to change RT_WLA_BSS's IE to 
// prevent malicious buffer overflow attack. 
//
#define CopyRtWlanBssIE(__pRtWlanBss, __pBuf, __BufLen) \
			(__pRtWlanBss)->IE.Octet = (__pRtWlanBss)->IEBuf; \
			(__pRtWlanBss)->IE.Length = ( ((__BufLen) > BSS_IE_BUF_LEN) ? BSS_IE_BUF_LEN: (__BufLen) ); \
			CopyMem((__pRtWlanBss)->IE.Octet, (__pBuf), (__pRtWlanBss)->IE.Length)

typedef struct _SW_CAM_TABLE{
	
	u1Byte				macAddress[6];
	BOOLEAN			       bUsed;
	u1Byte				pucKey[PTK_LEN];
	u4Byte 				ulEncAlg;
	u4Byte				ulUseDK;
	u4Byte				ulKeyId;				// CAM entry in CAM
	u1Byte			        portNumber;			//vivi added for new cam search flow, 20091028...ID different port
	
}SW_CAM_TABLE,*PSW_CAM_TABLE;

typedef struct _RSSI_STA{
	s4Byte	UndecoratedSmoothedPWDB;
	s4Byte	UndecoratedSmoothedCCK;
	s4Byte					UndecoratedSmoothedOFDM;
	u8Byte					PacketMap;
	u4Byte					OFDM_pkt;
	u1Byte					ValidBit;
	s4Byte					RxRSSIPercentage[4];
	s4Byte					RSSI_CCK_Path[4];
	s4Byte					RSSI_CCK_Path_cnt[4];
	u4Byte					OFDM_Pkt_Cnt;
	u4Byte					CCK_Pkt_Cnt;
	
}RSSI_STA, *PRSSI_STA;

typedef enum	_RT_STA_EOSP_STATE
{
	RT_STA_EOSP_STATE_OPENED = 0,	// The SP is opend.
	RT_STA_EOSP_STATE_ENDING = 1, // The SP is ending.
	RT_STA_EOSP_STATE_ENDED = 2, // The SP is ended.
}RT_STA_EOSP_STATE, *PRT_STA_EOSP_STATE;

typedef struct _RT_WLAN_STA{
	BOOLEAN				bUsed;			// TRUE if this entry is used.
	BOOLEAN				bLocked;		// TRUE if this STA MAC Address is locked.
	u1Byte				Sum;			// Sum of MacAddr, used for hash purpose.
	u1Byte				MacAddr[6];		// Mac address of this STA.
	AUTH_ALGORITHM		AuthAlg;		// AuthAlg of the STA. 
	RT_AUTH_MODE		AuthMode;
	u1Byte				AuthPassSeq;	// 0: Not yet authenticated / 2: STA has receive an successful Auth2. / 4: STA has received an successful Auth4.
	BOOLEAN				bAssociated;	// TRUE if this STA is associated to this BSS.
	BOOLEAN				bDisassociated;
	u2Byte				AID;			// AID

	// HalMacID used for this peer ---------------------------
	u1Byte				AssociatedMacId;
	// --------------------------------------------------

	u1Byte				MultiPortStationIdx;
	
	u8Byte				LastActiveTime; // Last active time in ms. 
	u1Byte				WmmStaQosInfo;	// Qos Info field when sent from WMM STA in the (re-)association packet.
	BOOLEAN				bPowerSave;		// TRUE if the STA is in power save mode, FALSE is for active one.
	RT_LIST_ENTRY		PsQueue;		// Packet queued for this STA if it is in legacy power save mode.
	RT_LIST_ENTRY		WmmPsQueue;		// Packets belong to WMM APSD ACs queued.
	RT_STA_EOSP_STATE	WmmEosp;		// If true, the USP is end now for this STA.	

	AUTH_PKEY_MGNT_TAG	perSTAKeyInfo;	// WPA-PSK related variable

	u1Byte				bdSupportRateEXBuf[MAX_NUM_RATES]; // Rate supported by the STA.
	u2Byte				bdSupportRateEXLen; 	// Length of bdSupportRateEXBuf[].
	u1Byte				HighestOperaRate;		// Highest supported rate in bdSupportRateEXBuf.
	QOS_MODE			QosMode;				//STA QoS Mode

	WIRELESS_MODE		WirelessMode;			// Wireless mode of STA associated.
	CHANNEL_WIDTH		BandWidth;

	BOOLEAN				FillTIMFlags;
	BOOLEAN				FillTIM;

	u2Byte				DataRate;
	BOOLEAN				bUseShortGI;
	//add for HW enc ,By CCW
	u4Byte				keyindex;

	// add to Clear PS tcb 
	u1Byte				PSIdleCunt;


	RT_HTINFO_STA_ENTRY		HTInfo;
	RT_VHTINFO_STA_ENTRY	VHTInfo;
	u1Byte					ratr_index;
	u1Byte					Ratr_State;
	u4Byte					IOTAction;	
	u2Byte				IOTMaxMpduLen;


	// Win7
	pu1Byte				AP_RecvAsocReq;
	u4Byte				AP_RecvAsocReqLength;
	pu1Byte				AP_SendAsocResp;
	u4Byte				AP_SendAsocRespLength;
	
	pu1Byte				AP_AsocRspIEFromOS;
	u4Byte				AP_AsocRspIEFromOSLength;
	
	u2Byte				Capability;
	u2Byte				usListenInterval;
	u8Byte				AssociationUpTime;

	BOOLEAN 			bOsDecisionMade;
	BOOLEAN 			bNotAcceptedByOs; // Use "NotAccepted" instead of  "Accepted" because 0 is the default value we want after reset.
	u2Byte				OsReasonCode;
	
	RT_STA_INDICATE_STATE_MACHINE 	IndicationEngine;	

	RSSI_STA			rssi_stat;

	// For preventing duplicate packet indications ------
	u1Byte				LastRxUniFragNum;
	u2Byte				LastRxUniSeqNum;
	// ------------------------------------------
	
#if (P2P_SUPPORT == 1)
	BOOLEAN 			bP2PClient;
	P2P_CLIENT_INFO_DISCRIPTOR P2PClientInfoDesc;
#endif	//#if (P2P_SUPPORT == 1)

#if (WPS_SUPPORT == 1)
	OCTET_STRING		SimpleConfigInfo;
#endif


	//
	// ================ODM Relative Info=======================
	// Please be care, dont declare too much structure here. It will cost memory * STA support num.
	//
	//
	UINT8		IOTPeer;			// Enum value.	HT_IOT_PEER_E Every team define independent enum.

	// ODM Write
	//1 PHY_STATUS_INFO
	UINT8		RSSI_Path[4];		// 
	UINT8		RSSI_Ave;
	UINT8		RXEVM[4];
	UINT8		RXSNR[4];
	
}RT_WLAN_STA,*PRT_WLAN_STA;

typedef struct _RT_802_11_BSSID_LIST
{
	u4Byte			NumberOfItems;      // in list below, at least 1
	RT_WLAN_BSS	*pbssidentry;
} RT_802_11_BSSID_LIST, *PRT_802_11_BSSID_LIST;

typedef struct _RT_802_11_BSSID_LIST_Customized
{
	u4Byte					NumberOfItems;      // in list below, at least 1
	RT_WLAN_BSS_Customized	bssidentry[1024];
} RT_802_11_BSSID_LIST_Customized, *PRT_802_11_BSSID_LIST_Customized;

// WDS Mode, 2006.06.12, by rcnjko.
#define	WDS_DISABLED		0
#define	WDS_AP_MODE			1

//
// Customer ID, note that: 
// This variable is initiailzed through EEPROM or registry, 
// however, its definition may be different with that in EEPROM for 
// EEPROM size consideration. So, we have to perform proper translation between them.
// Besides, CustomerID of registry has precedence of that of EEPROM.
// defined below. 060703, by rcnjko.
//
typedef enum _RT_CUSTOMER_ID
{
	RT_CID_DEFAULT = 0,
	RT_CID_WHQL = 5,
	
}RT_CUSTOMER_ID, *PRT_CUSTOMER_ID;

//----------------------------------------
//add for ROGUE AP 2007.07.28 , by CCW
//----------------------------------------
typedef struct _MH_CCX_ROGUE_AP_ENTEY{
	u4Byte   code;
	u1Byte   bssid[6];
	BOOLEAN bused;
} MH_CCX_ROGUE_AP_ENTEY,*PMH_CCX_ROGUE_AP_ENTEY;


#define SIZE_ROGUE_AP_ENTEY		64
#define ASOC_INFO_IE_SIZE		2500

//
// Store the lastest association information. 2006.11.14, by shien chang.
//

typedef struct _ASOC_INFO{
	u1Byte				AuthSeq1[ASOC_INFO_IE_SIZE];
	u4Byte				AuthSeq1Length;
	u1Byte				AuthSeq2[ASOC_INFO_IE_SIZE];
	u4Byte				AuthSeq2Length;
	u1Byte				AsocReq[ASOC_INFO_IE_SIZE];
	u4Byte				AsocReqLength;
	u1Byte				AsocResp[ASOC_INFO_IE_SIZE];
	u4Byte				AsocRespLength;
	u1Byte				Beacon[ASOC_INFO_IE_SIZE];
	u4Byte				BeaconLength;
	u1Byte				PeerAddr[6];
	BOOLEAN				FlagReAsocReq;
	BOOLEAN				FlagReAsocResp;

	BOOLEAN				bDeauthAddrValid; // TRUE if the DeauAddr is valid and will be reset to FALSE in context of DrvIFIndicateDisassociation().
	u1Byte				DeauthAddr[6]; // TA of deauth frame we recevied.

} ASOC_INFO, *PASOC_INFO;

typedef enum _UPDATE_ASOC_INTO_ACTION{
	UpdateAuthSeq1,
	UpdateAuthSeq2,
	UpdateAsocReq,
	UpdateAsocResp,
	UpdateAsocBeacon,
	UpdateAsocPeerAddr,
	UpdateFlagReAsocReq,
	UpdateFlagReAsocResp,
	UpdateDeauthAddr,
} UPDATE_ASOC_INFO_ACTION, *PUPDATE_ASOC_INFO_ACTION;

//
//	Auto Select Channel related.
//
typedef	struct	_CHANNEL_INFO
{
	u1Byte	ChannelNumber;
	int		Weight;
}CHANNEL_INFO, *PCHANNEL_INFO;

typedef enum _CHANNEL_SELECT_MODE
{
	CH_SEL_DECREASE	= 0,
	CH_SEL_INCREASE	= 1,
	CH_SEL_RANDOM		= 2,
}CHANNEL_SELECT_MODE, *PCHANNEL_SELECT_MODE;

typedef enum _CHANNEL_START_MODE
{
	CH_START_MIN		= 0,
	CH_START_MIDDLE	= 1,
	CH_START_MAX		= 2,
}CHANNEL_START_MODE, *PCHANNEL_START_MODE;

//
// For Turbo mode. Added by Roger, 2006.12.07.
//
typedef struct _RT_TURBO_CA
{
	BOOLEAN		bEnabled; // TRUE if TCA is ON, FALSE o.w..

	// Periodical timer for TCA checking.
	RT_TIMER	TcaCheckTimer;
	u4Byte		CheckCnt; // Min: 1, Max: CheckInterVal.
	u4Byte		CheckInterval;

	// Per-packet contention window for TCA on. 
	// Note that, this is one of means of TCA, 
	// we also can information of other means here.
	//u1Byte		ECWMin;	// For Restore.
	//u1Byte		ECWMax;//For Restore.

	// Statistics in last TCA_CHECK_INTERVAL. 
	RT_TX_STATISTICS	LastTxStats;
	RT_RX_STATISTICS	LastRxStats;
	u4Byte		LastTxRetryCnt;
	u4Byte		TxThroughput; // in KBps. 
	u4Byte		RxThroughput; // in KBps. 
	u4Byte		TotalThroughput; //in MBps

	// Statistics in last nomal channel access setting. 
	RT_TX_STATISTICS	LastNormalTxStats;
	RT_RX_STATISTICS	LastNormalRxStats;
	u4Byte		NormalTotalThroughput; // in KBps. 
}RT_TURBO_CA, *PRT_TURBO_CA;


// Add for Real WOW 
#define 	MAX_RS_PACKET_LEN		1024
#define 	MAX_RealWoW_KCP_SIZE 	124 //(100 + 24) 
#define 	MAX_RealWoW_KAP_SIZE 	48
#define 	MAX_RealWoW_Payload 		64
#pragma pack (1)	// Set our value.
typedef struct _TEREDOINFO
{
	 u1Byte			DIPv4[4];
	 u1Byte 			MacID[6];
	 u2Byte			TeredoPort;
	 u1Byte 			TeredoIP[16];
	 u1Byte 			HashPtn[16];
	 u1Byte 			HashAuth[16];
	 unsigned int 		DHCPExpireTime;
	 u2Byte 			RALostCnt;
}TEREDOINFO,*PTEREDOINFO;


typedef struct _KCPInfo{
	u4Byte			nId; // = id 
	int 				destAddr;
	u1Byte			MacID[6];
	u2Byte			desPort;
	u2Byte 			PKTLEN;
}KCPInfo, *PKCPInfo;

typedef struct _KCPContent{
	u4Byte 			id; // = id 
	u4Byte 			mSec; // = msec 
	u4Byte 			size; // =size
	u1Byte 			bPacket[MAX_RealWoW_KCP_SIZE]; // put packet here
} KCPContent, *PKCPContent;

typedef struct _RealWoWAckPktInfo { 
	u2Byte			ackLostCnt;
	u2Byte		 	patterntSize;
	u1Byte 			pattern[MAX_RealWoW_Payload];
}RealWoWAckPktInfo,*PRealWoWAckPktInfo;

typedef struct _RealWoWWPInfo { 
	u2Byte 			patterntSize;
	u1Byte 			pattern[MAX_RealWoW_Payload];
}RealWoWWPInfo,*PRealWoWWPInfo; 

typedef struct _RT_S5WakeUPInfo { 
	 u1Byte			PSK[PASSPHRASE_LEN];
	 u4Byte			PSKLen;
}RT_S5WakeUPInfo,*PRT_S5WakeUPInfo; 


#pragma pack()


typedef struct _WIRELESS_SETTING_BEFORE_SCAN
{
	/*WirelessModeScanInProgress is designed for driver to keep the previous band(2.4G/5G)
	   during scan. It is only meaningful for a/b/g device which require to switch band twice 
	   during scan (either 2.4->5->2.4 or 5->2.4->5*/
	WIRELESS_MODE		WirelessModeScanInProgress;	

	/*WirelessMode is designed to keep the original wireless mode setting before scan*/
	WIRELESS_MODE		WirelessMode;		

	/*ChannelNumber is designd to keep the original channel number before scan*/
	u1Byte				ChannelNumber;

	/*ChannelBandwidth is designed to keep the original channel bandwidth(20/40MHz) before scan*/
	CHANNEL_WIDTH		ChannelBandwidth;

	/* Extension channel offset before scan. This is useful when channel bandwidth is 40MHz. */
	EXTCHNL_OFFSET		Ext20MHzChnlOffsetOf40MHz;

	EXTCHNL_OFFSET		Ext40MHzChnlOffsetOf80MHz;

	u1Byte				CenterFrequencyIndex1;

	BOOLEAN			RestoreTo40MBW;	//for Dual band scan.

	u1Byte				WMMParamEle[WMM_PARAM_ELEMENT_SIZE];//add by ylb 20130627 for restore WMMParamEle after scan, Fix WMMParamEle changed during scan and set the wrong value of QOS Parameter( TxOP)
}WIRELESS_SETTING_BEFORE_SCAN, *PWIRELESS_SETTING_BEFORE_SCAN;

typedef struct _INIT_GAIN
{
	u1Byte				XAAGCCore1;
	u1Byte				XBAGCCore1;
	u1Byte				XCAGCCore1;
	u1Byte				XDAGCCore1;
	u1Byte				CCA;

} INIT_GAIN, *PINIT_GAIN;
/*---------------------Define local Tx BB Gain Table-----------------------*/
#define 	OFDM_TABLE_SIZE_92C	37
#define		CCK_TABLE_SIZE	33
#define		CCK_TABLE_SIZE_88F 21
#define		OFDM_TABLE_SIZE 	43

#define TxBBGainTableLength 37
#define	CCKTxBBGainTableLength 33
typedef struct _TXBBGain_Struct
{
	s4Byte	TxBBIQAmplifyGain;
	u4Byte	TXBBGainValue;
} TXBBGain_Struct, *PTXBBGain_Struct;
typedef struct _CCKTXBBGain_Struct
{
	//The Value is from a22 to a29 one Byte one time is much Safer 
	u1Byte	CCKTXBBValueArray[8];
} CCKTXBBGain_Struct,*PCCKTXBBGain_Struct;
/*---------------------End Define--------------------------------------*/


/*---------------------Define Power Save Related-----------------------*/
typedef enum _IPS_CALLBACK_FUNCION
{
	IPS_CALLBACK_NONE = 0,
	IPS_CALLBACK_MGNT_LINK_REQUEST = 1,
	IPS_CALLBACK_JOIN_REQUEST = 2,
}IPS_CALLBACK_FUNCION;

typedef enum _Fsync_State{
	Default_Fsync,
	HW_Fsync,
	SW_Fsync
}Fsync_State;	

typedef enum _RT_AP_TYPE
{
	RT_AP_TYPE_NONE = 0,		// NOT in AP mode
	RT_AP_TYPE_NORMAL,			// N5 and !n6_fake
	RT_AP_TYPE_IBSS_EMULATED,	// N6, N62 and n6_fake
	RT_AP_TYPE_VWIFI_AP,		// N62 and !n6_fake
	RT_AP_TYPE_EXT_AP,
	RT_AP_TYPE_LINUX,
} RT_AP_TYPE, *PRT_AP_TYPE;



/** Define AP states */
typedef enum _AP_STATE
{
    AP_STATE_STOPPED = 0,                   // AP INIT state
    AP_STATE_STARTING,
    AP_STATE_STARTED,
    AP_STATE_STOPPING,
    AP_STATE_INVALID = 0xFFFFFFFF           // When MP is not in AP mode
} AP_STATE, *PAP_STATE;

// RT_CUSTOM_EVENT
typedef	u4Byte	RT_CUSTOM_EVENT, *PRT_CUSTOM_EVENT;

//
// These events are realtek proprietary status indicated to varies of upper layer or receiver.
// They are common for all platform and may be mapped to the specified events to the
// platform besed events respectively.
// Different events also can be defined as the same number, because they may be indicated to
// different target.
// By Bruce, 2011-06-10.
//
#define	RT_CUSTOM_EVENT_WOL_GTK										((RT_CUSTOM_EVENT)0x00210001)	//	Wol by GTK updating
#define	RT_CUSTOM_EVENT_IRP_UNLOAD									((RT_CUSTOM_EVENT)0x00220000)	// IRP event indicated to the upper layer to notify the driver unload event

// TDLS
#define	RT_CUSTOM_EVENT_TDLS_START									((RT_CUSTOM_EVENT)0x00230000)	// TDLS peer Start event.
#define	RT_CUSTOM_EVENT_TDLS_PEER_SETUP								((RT_CUSTOM_EVENT)0x00230000)	// TDLS peer is setup.
#define	RT_CUSTOM_EVENT_TDLS_TEAR_DOWN_TO_PEER						((RT_CUSTOM_EVENT)0x00230001)	// TDLS peer is teared down.
#define	RT_CUSTOM_EVENT_TDLS_TEAR_DOWN_FROM_PEER					((RT_CUSTOM_EVENT)0x00230002)	// TDLS peer is teared down.
#define	RT_CUSTOM_EVENT_TDLS_SETUP_FAILURE							((RT_CUSTOM_EVENT)0x00230003)	// TDLS setup fails.
#define	RT_CUSTOM_EVENT_TDLS_STATUS_PEER_REJECT_CH_SWITCH			((RT_CUSTOM_EVENT)0x00230010)	// The target peer rejected the channel switch request.
#define	RT_CUSTOM_EVENT_TDLS_STATUS_CH_SWITCH_PROHIBITED			((RT_CUSTOM_EVENT)0x00230011)	// Channel switch is prohibited by AP.
#define	RT_CUSTOM_EVENT_TDLS_STATUS_PEER_NO_CH_SWITCH				((RT_CUSTOM_EVENT)0x00230012)	// Peer didn't support channel switch.
#define	RT_CUSTOM_EVENT_TDLS_STATUS_PEER_NO_PUAPSD					((RT_CUSTOM_EVENT)0x00230013)	// Target peer didn't support PUAPSD.
#define	RT_CUSTOM_EVENT_TDLS_END									((RT_CUSTOM_EVENT)0x00230FFF)	// TDLS peer End event

// WPS
#define	RT_CUSTOM_EVENT_WPS_RECV_PKT								((RT_CUSTOM_EVENT)0x00240000)	// Reveived the WPS packet

// Trouble Shooting Event
#define	RT_CUSTOM_EVENT_TRO_SH_START								((RT_CUSTOM_EVENT)0x00231000)	//	Trouble shooting event Start
#define	RT_CUSTOM_EVENT_TRO_SH_TX_RPT_HANG							((RT_CUSTOM_EVENT)0x00231001)	//	Tx Report Hang
#define	RT_CUSTOM_EVENT_TRO_SH_END									((RT_CUSTOM_EVENT)0x00231FFF)	//	Trouble shooting event End

// VHT
#define	RT_CUSTOM_EVENT_VHT_RECV_GID_MGNT_FRAME					((RT_CUSTOM_EVENT)0x00250000)		// BFee recv GID mgnt frame

#define RT_CUSTOM_EVENT_P2P_START_AP_REQ 							((RT_CUSTOM_EVENT)0x40040000)
#define RT_CUSTOM_EVENT_P2P_STOP_AP_REQ 							((RT_CUSTOM_EVENT)0x40040001)
#define RT_CUSTOM_EVENT_P2P_CONNECT_CLIENT_REQ 						((RT_CUSTOM_EVENT)0x40040002)
#define RT_CUSTOM_EVENT_P2P_DISCONNECT_CLIENT_REQ 					((RT_CUSTOM_EVENT)0x40040003)
#define RT_CUSTOM_EVENT_P2P_INDICATE_CURRENT_STATE					((RT_CUSTOM_EVENT)0x40040004)
#define RT_CUSTOM_EVENT_P2P_INDICATE_GO_FORMATED					((RT_CUSTOM_EVENT)0x40040005)
#define RT_CUSTOM_EVENT_P2P_INDICATE_ON_PROVISION_DISC_REQ			((RT_CUSTOM_EVENT)0x40040006)
#define RT_CUSTOM_EVENT_P2P_INDICATE_ON_PROVISION_DISC_RSP			((RT_CUSTOM_EVENT)0x40040007)
#define RT_CUSTOM_EVENT_P2P_INDICATE_ON_INVITATION_REQ				((RT_CUSTOM_EVENT)0x40040008)
#define RT_CUSTOM_EVENT_P2P_INDICATE_ON_INVITATION_RSP				((RT_CUSTOM_EVENT)0x40040009)
#define RT_CUSTOM_EVENT_P2P_INDICATE_CURRENT_DEV_PASSWD_ID			((RT_CUSTOM_EVENT)0x4004000A)
#define RT_CUSTOM_EVENT_P2P_INDICATE_DEV_REQ_CLIENT_GO_FORMATION	((RT_CUSTOM_EVENT)0x4004000B)
#define RT_CUSTOM_EVENT_P2P_INDICATE_ENABLE_ICS						((RT_CUSTOM_EVENT)0x4004000C)
#define RT_CUSTOM_EVENT_P2P_INDICATE_CLIENT_CONNECTED				((RT_CUSTOM_EVENT)0x4004000D)
#define RT_CUSTOM_EVENT_P2P_INDICATE_CLIENT_DISCONNECTED			((RT_CUSTOM_EVENT)0x4004000E)
#define RT_CUSTOM_EVENT_P2P_INDICATE_CURRENT_ROLE					((RT_CUSTOM_EVENT)0x4004000F)
#define RT_CUSTOM_EVENT_P2P_INDICATE_DEV_DISC_COMPLETE				((RT_CUSTOM_EVENT)0x40040010)
#define RT_CUSTOM_EVENT_P2P_INDICATE_SD_RSP							((RT_CUSTOM_EVENT)0x40040011)
#define RT_CUSTOM_EVENT_P2P_INDICATE_SD_REQ							((RT_CUSTOM_EVENT)0x40040012)
#define RT_CUSTOM_EVENT_P2P_INDICATE_SCAN_LIST						((RT_CUSTOM_EVENT)0x40040013)
#define RT_CUSTOM_EVENT_P2P_SVC										((RT_CUSTOM_EVENT)0x40040014)
#define RT_CUSTOM_EVENT_P2P_CHANGING_AP_CHANNEL						((RT_CUSTOM_EVENT)0x40040015)
#define RT_CUSTOM_EVENT_NAN_INDICATE_SDF							((RT_CUSTOM_EVENT)0x40040016)

// WDI ((RT_CUSTOM_EVENT)0xFF000000)
#define	RT_CUSTOM_EVENT_WDI_START									((RT_CUSTOM_EVENT)0xFF000000)	//	WDI event start
#define	RT_CUSTOM_EVENT_WDI_FT_ASSOC_NEEDED							((RT_CUSTOM_EVENT)0xFF000001)	//	FT association request parameter needed
#define	RT_CUSTOM_EVENT_WDI_END										((RT_CUSTOM_EVENT)0xFF0000FF)	//	WDI event end



// RT_CUSTOM_INDI_TARGET is the target indicated for RT_CUSTOM_EVENT
#define	RT_CUSTOM_INDI_TARGET_NONE			0
#define	RT_CUSTOM_INDI_TARGET_IHV			BIT0			// Indicate to IHV (for Ndis 6)
#define	RT_CUSTOM_INDI_TARGET_IRP			BIT1			// Indicate to all receivers who bound this adapter by IRP.
#define	RT_CUSTOM_INDI_TARGET_WDI			BIT2			// Indicate to Windows WDI



//
//About WOL pattern info, by tynli. 2009.06.18.
//
#define	MAX_SUPPORT_WOL_PATTERN_NUM_88E		22  //64 // 22 is on Win8.1 WHQL requirement
#define	MAX_SUPPORT_WOL_PATTERN_NUM_8723A	16
#define	MAX_SUPPORT_WOL_PATTERN_NUM_92C		8
#define	MAX_SUPPORT_WOL_PATTERN_NUM_8814A 	22 // add by ylb 20130812
#if 0
#define	MAX_SUPPORT_WOL_PATTERN_NUM_COMM	\
	((MAX_SUPPORT_WOL_PATTERN_NUM_88E > MAX_SUPPORT_WOL_PATTERN_NUM_92C)? (MAX_SUPPORT_WOL_PATTERN_NUM_88E) : (MAX_SUPPORT_WOL_PATTERN_NUM_92C))
#else 
#define 	MAX2(a, b) (a>b?a:b)
#define 	MAX4(a,b,c,d) (MAX2(MAX2(a,b), MAX2(c,d)))
#define	MAX_SUPPORT_WOL_PATTERN_NUM_COMM (MAX4(MAX_SUPPORT_WOL_PATTERN_NUM_88E,MAX_SUPPORT_WOL_PATTERN_NUM_8723A,MAX_SUPPORT_WOL_PATTERN_NUM_92C,MAX_SUPPORT_WOL_PATTERN_NUM_8814A))
#endif
// 88C supports 8 WOL patterns, 8723A supports 16 patterns, otherwise is the same as the pattern number of 88E. by tynli 2012.10.12.
#define MAX_SUPPORT_WOL_PATTERN_NUM(_Adapter)	\
	(IS_HARDWARE_TYPE_8814A(_Adapter) ? (MAX_SUPPORT_WOL_PATTERN_NUM_8814A): (MAX_SUPPORT_WOL_PATTERN_NUM_88E))

#define	RSVD_WOL_PATTERN_NUM				1	// pattern num for user defined

#define	WKFMCAM_ADDR_NUM		6
#define	WKFMCAM_SIZE			24

#define	MAX_WOL_BIT_MASK_SIZE		16 //unit: byte
#define	MAX_WOL_PATTERN_SIZE		128

#define	MAX_HW_PATTERN_MATCH_NUM_8723A	12 // 8723A Hw capability
#if 0
#define	USE_FW_PATTERN_MATCH(_pAdapter)	\
	(IS_HARDWARE_TYPE_8723A(_pAdapter) ? ((GET_POWER_SAVE_CONTROL(&(_pAdapter->MgntInfo))->WoLPatternNum > MAX_HW_PATTERN_MATCH_NUM_8723A) ? TRUE: FALSE): FALSE)
#else
#define	USE_FW_PATTERN_MATCH(_pAdapter)	FALSE	
#endif
typedef enum _WOLPATTERN_TYPE
{
	eUnicastPattern = 0,
	eMulticastPattern = 1,
	eBroadcastPattern = 2,
	eDontCareDA = 3,
	eUnknownType = 4,
}WOLPATTERN_TYPE;

// The H2C WoL pattern match info format is defined for Fw pattern match mechanism.
typedef struct _H2C_WOL_PATTERN_MATCH_INFO{
	u1Byte	PatternContent[128];
	u1Byte	BitMask[16];
	u1Byte	ValidBitNum;
}H2C_WOL_PATTERN_MATCH_INFO, *PH2C_WOL_PATTERN_MATCH_INFO;

typedef struct _RT_PM_WOL_PATTERN_INFO
{
	u4Byte	PatternId; // PatternId is set from N62 OID, N5/N6 can ignore it.
	u4Byte	Mask[4];	// The mask format is special for Hw.
	u2Byte	CrcRemainder;
	u1Byte	IsPatternMatch; // if the value is set to 1, the masks and CRC value will be download to Hw.
	WOLPATTERN_TYPE	PatternType;
	u1Byte	IsUserDefined;	// 0: from OS, 1: User defined

	// For 8723A Hw insufficient capability issue.------->
	u1Byte	IsSupportedByFW;	// Fw will parse some patterns that they cannot support by Hw.
	u1Byte	HwWFMIndex; // CAM index
	H2C_WOL_PATTERN_MATCH_INFO	FwPattern;
	// <------------------------------------------
}RT_PM_WOL_PATTERN_INFO, *PRT_PM_WOL_PATTERN_INFO;

typedef enum _PM_PROTOCOL_OFFLOAD_ID_IDX
{
	eGTKOffloadIdx = 0,
	eARPOffloadIdx = 1,
	eNSOffloadIdx1 = 2,
	eNSOffloadIdx2 = 3,
}PM_PROTOCOL_OFFLOAD_ID_IDX;


#define ACTING_AS_AP(_pAdapter) (MgntActQuery_ApType(_pAdapter) > 0)
#define ACTING_AS_IBSS(_pAdapter) (_pAdapter->MgntInfo.mIbss)

#define	RT_SET_PS_LEVEL(_pAdapter, _PS_FLAG)	(GET_POWER_SAVE_CONTROL(&(_pAdapter->MgntInfo))->CurPsLevel |= _PS_FLAG)
#define	RT_CLEAR_PS_LEVEL(_pAdapter, _PS_FLAG)	(GET_POWER_SAVE_CONTROL(&(_pAdapter->MgntInfo))->CurPsLevel &= (~(_PS_FLAG)))
#define	RT_GET_CUR_PS_LEVEL(_pAdapter)	(GET_POWER_SAVE_CONTROL(&(_pAdapter->MgntInfo))->CurPsLevel)
#define	RT_IN_PS_LEVEL(_pAdapter, _PS_FLAG)	((RT_GET_CUR_PS_LEVEL(_pAdapter) & _PS_FLAG) ? TRUE : FALSE)


typedef struct _RT_POWER_SAVE_CONTROL
{
	//
	// Inactive Power Save(IPS) : Disable RF when disconnected
	//		
	BOOLEAN				bInactivePs;
	// When AP mode stop in DC mode,  STA mode will return to IPS enable by this backup.
	BOOLEAN				bIPSModeBackup;
	BOOLEAN				bHaltAdapterClkRQ;
	BOOLEAN				bSwRfProcessing;
	RT_RF_POWER_STATE	eInactivePowerState;
	RT_WORK_ITEM		InactivePsWorkItem;
	RT_TIMER			InactivePsTimer;
	RT_IPS_STATE			IPSState;
	u1Byte				IPSDisableReason;

	// Return point for join action
	IPS_CALLBACK_FUNCION	ReturnPoint;
	
	// Recored Parameters for rescheduled JoinRequest
	PADAPTER			ptmpAdapter;// for reschedule reason, need to use original port, 2015.01.07 hsiao_ho
	                                // because we need to use the correct port to restart JOIN / MGNTLINK Request
	BOOLEAN				bTmpBssDesc;
	RT_JOIN_ACTION		tmpJoinAction;
	RT_WLAN_BSS		tmpBssDesc;

	// Recored Parameters for rescheduled MgntLinkRequest
	BOOLEAN				bTmpScanOnly;
	BOOLEAN				bTmpActiveScan;
	BOOLEAN				bTmpFilterHiddenAP;
	BOOLEAN				bTmpUpdateParms;
	u1Byte				tmpSsidBuf[33];
	OCTET_STRING		tmpSsid2Scan;
	BOOLEAN				bTmpSsid2Scan;
	u1Byte				tmpNetworkType;
	u1Byte				tmpChannelNumber;
	u2Byte				tmpBcnPeriod;
	u1Byte				tmpDtimPeriod;
	u2Byte				tmpmCap;
	OCTET_STRING		tmpSuppRateSet;
	u1Byte				tmpSuppRateBuf[MAX_NUM_RATES];
	BOOLEAN				bTmpSuppRate;
	IbssParms			tmpIbpm;
	BOOLEAN				bTmpIbpm;

	//
	// Leisre Poswer Save : Disable RF if connected but traffic is not busy
	//		
	BOOLEAN				bLeisurePs;
	// When AP mode stop in DC mode,  STA mode will return to LPS enable by this backup.
	BOOLEAN				bLeisurePsModeBackup;
	u1Byte				LpsIdleCount;
	u1Byte				PowerSetting;
	u1Byte				PowerPolicy;	
	u4Byte				PowerProfile;
	u4Byte				PowerSaveLevel;	
	u4Byte				ConnectionQuality;	
	u1Byte				PowerMode;
	u1Byte				RegMaxLPSAwakeIntvl;
	u1Byte				LPSAwakeIntvl;
	BOOLEAN				RegAdvancedLPs;
    UINT8 				MaximumOffChannelOperationTime; // Maximum number of milliseconds to be off channel
    UINT8 				RoamingNeededLinkQualityThreshold; // Link quality below which its OK to send a roaming needed indication

	//RF OFF Level
	u4Byte				CurPsLevel;
	u4Byte				RegRfPsLevel;
	u1Byte				RegAMDPciASPM;
	
	// 2009/10/28 MH Add for DMA 64 bit support switch
	u1Byte				RegDMA64Support;

	//Fw Control LPS
	BOOLEAN				bFwCtrlLPS;
	u1Byte				FWCtrlPSMode;
	BOOLEAN				bLowPowerEnable;	// 32k
	RT_WORK_ITEM		FwPsClockOnWorkitem;

	//2009.01.01 added by tynli
	// Record if there is a link request in IPS RF off progress.
	BOOLEAN				LinkReqInIPSRFOffPgs;
	// To make sure that connect info should be executed, so we set the bit to filter the link info which comes after the connect info.
	BOOLEAN				BufConnectinfoBefore;

	//GPIO polling HW Radio On/Off.
	BOOLEAN				bGpioRfSw;

	// WoWLAN
	u1Byte				WoWLANMode;
	BOOLEAN				bWakeOnDisconnect;
	u1Byte				APOffloadEnable;
	BOOLEAN				bEnterLPSDuringSuspend;	// For WoWLAN, enter LPS during S3/S4.
	u1Byte				WoWLANLPSLevel;
	u1Byte				ARPOffloadEnable; // controlled by NDIS OID in WHCK test
	u1Byte				GTKOffloadEnable; // controlled by NDIS OID in WHCK test
	u1Byte				NSOffloadEnable; // controlled by NDIS OID in WHCK test
	u1Byte				RegARPOffloadEnable; // set by registry
	u1Byte				RegGTKOffloadEnable; // set by registry
	u1Byte				RegNSOffloadEnable;
	u1Byte				ProtocolOffloadDecision;
	u1Byte				FSSDetection;
	BOOLEAN				bOSSupportProtocolOffload;
	BOOLEAN				bSetPMParameters;
	u1Byte				WoWLANS5Support;
	u4Byte				EapolRequestIdMessagePatternId;
	u4Byte				MagicPacketPatternId;
	u4Byte				IPv4TcpSynPatternId;
	u4Byte				IPv6TcpSynPatternId;
	BOOLEAN				bSupportWakeUp;
	u1Byte				D2ListenIntvl;
	u4Byte				PMProtocolOffloadIDs[4]; // GTK offload, ARP offoad, NS offload*2
	BOOLEAN				bFakeWoWLAN;
	BOOLEAN				bPnpEnterD2; // for 8723BS connected standby setting.
	BOOLEAN				DxNLOEnable; // FW supports NLO in D2/D3 state.
	RT_AOAC_REPORT		AOACReport;

	// FW IPS
	BOOLEAN				bFwCtrlPwrOff;	// Apply to RF off and IPS state
	BOOLEAN				bInDxFwIPSPeriod; // IPS during device state in Dx (x=1~3)
	BOOLEAN				CardDisableInLowClk;
	u1Byte				FwIPSLevel;
	
	//  Record wake up frame for WoWLAN. by tynli. 2009.06.10.
	RT_PM_WOL_PATTERN_INFO		PmWoLPatternInfo[MAX_SUPPORT_WOL_PATTERN_NUM_COMM]; //by tynli. To keep the WoWLAN wake up pattern information, ex: pattern Id, bit mask.
	u1Byte						WoLPatternNum;
	u1Byte						WoLPktNoPtnNum;
	BOOLEAN						bFindWakePacket;

	// Control LPS by OID. by tynli. 2011.01.04.
	BOOLEAN				bDisableLPSByOID;
	u1Byte				RegLeisurePsMode;
	u1Byte				RegPowerSaveMode;

	u4Byte						WakeUpReason;	// Used for WOL, indicates the reason for waking event.
	u4Byte						SleepMode;		// Record the sleep mode.
	u8Byte						LastWakeUpTime;	// Record the last waking time for comparison with setting key.

	// PNP sleep/wake related info.
	u4Byte				PnpSleepEnterD2Cnt;
	u4Byte				PnpSleepEnterD3Cnt;
	u4Byte				PnpSleepEnterUnknownDxCnt;
	u4Byte				PnpWakeD0Cnt;
	u8Byte				LastPnpSleepTime;
	u8Byte				LastPnpWakeTime;
	u8Byte				LastLPSEnterTime;
	u8Byte				LastLPSLeaveTime;

	//Close power of IO during LPS32K, The feature is only for 8723D 20150623
	BOOLEAN				bRegLPSDeepSleepEnable;
}RT_POWER_SAVE_CONTROL,*PRT_POWER_SAVE_CONTROL;

typedef enum _RT_FRAME_HEADER
{
    RTFrameHeaderUndefined,
    RTFrameHeaderMac,
    RTFrameHeaderArp,
    RTFrameHeaderIPv4,
    RTFrameHeaderIPv6,
    RTFrameHeaderUdp,
    RTFrameHeaderMaximum
}RT_FRAME_HEADER, *PRT_FRAME_HEADER;

typedef enum _RT_MAC_HEADER_FIELD
{
    RTMacHeaderFieldUndefined,
    RTMacHeaderFieldDestinationAddress,
    RTMacHeaderFieldSourceAddress,
    RTMacHeaderFieldProtocol,
    RTMacHeaderFieldVlanId,
    RTMacHeaderFieldPriority,
    RTMacHeaderFieldPacketType,
    RTMacHeaderFieldMaximum
}RT_MAC_HEADER_FIELD, *PRT_MAC_HEADER_FIELD;

typedef enum _RT_MAC_PACKET_TYPE
{
    RTMacPacketTypeUndefined = 0,
    RTMacPacketTypeUnicast = 1,
    RTMacPacketTypeMulticast = 2,
    RTMacPacketTypeBroadcast = 3,
    RTMacPacketTypeMaximum
} RT_MAC_PACKET_TYPE, *PRT_MAC_PACKET_TYPE;

typedef enum _RT_ARP_HEADER_FIELD
{
    RTARPHeaderFieldUndefined,
    RTARPHeaderFieldOperation, // request or response
    RTARPHeaderFieldSPA, // source protocol address
    RTARPHeaderFieldTPA, //  target protocol address
    RTARPHeaderFieldMaximum
} RT_ARP_HEADER_FIELD, *PRT_ARP_HEADER_FIELD;

typedef enum _RT_IPV4_HEADER_FIELD
{
    RTIPv4HeaderFieldUndefined,
    RTIPv4HeaderFieldProtocol,
    RTIPv4HeaderFieldMaximum
}RT_IPV4_HEADER_FIELD, *PRT_IPV4_HEADER_FIELD;

typedef enum _RT_IPV6_HEADER_FIELD
{
    RTIPv6HeaderFieldUndefined,
    RTIPv6HeaderFieldProtocol,
    RTIPv6HeaderFieldMaximum
}RT_IPV6_HEADER_FIELD, *PRT_IPV6_HEADER_FIELD;

typedef enum _RT_UDP_HEADER_FIELD
{
    RTUdpHeaderFieldUndefined,
    RTUdpHeaderFieldDestinationPort,
    RTUdpHeaderFieldMaximum
}RT_UDP_HEADER_FIELD, *PRT_UDP_HEADER_FIELD;

typedef enum _RT_RECEIVE_FILTER_TEST
{
    RTReceiveFilterTestUndefined,
    RTReceiveFilterTestEqual,
    RTReceiveFilterTestMaskEqual,
    RTReceiveFilterTestNotEqual,
    RTReceiveFilterTestMaximum
}RT_RECEIVE_FILTER_TEST, *PRT_RECEIVE_FILTER_TEST;

typedef struct _RT_DO_COALESICING_FIELD_INFO
{
	u1Byte							Heard[8];   // Resvad for ndis 
	RT_FRAME_HEADER				FrameHead;
	RT_RECEIVE_FILTER_TEST			FilterTest;
	
	 union
    	{
	        RT_MAC_HEADER_FIELD       	MacHeaderField;
	        RT_ARP_HEADER_FIELD        	ArpHeaderField;
	        RT_IPV4_HEADER_FIELD      	IPv4HeaderField;
	        RT_IPV6_HEADER_FIELD      	IPv6HeaderField;
	        RT_UDP_HEADER_FIELD       	UdpHeaderField;
    	}HeaderField;
    	
	union 
	{
	        u1Byte			FieldByteValue;
	        u2Byte			FieldShortValue;
	        ULONG               	FieldLongValue;
	        ULONGLONG		FieldLong64Value;
	        u1Byte               	FieldByteArrayValue[16];
	 }FieldValue;

	union                          // used when test operation is MaskEqual
    	{
	        u1Byte               	ResultByteValue;
	        u2Byte              	ResultShortValue;
	        ULONG               	ResultLongValue;
	        ULONGLONG   	ResultLong64Value;
	        u1Byte               	ResultByteArrayValue[16];
    	}ResultValue;
    	
	
}RT_DO_COALESICING_FIELD_INFO,*PRT_DO_COALESICING_FIELD_INFO;


typedef struct _RT_DO_COALESICING_FILTER_PARAMETER
{
	u4Byte									FilterID;       		// != 0 : in used !!
	u4Byte									Delaytime;   	 	// how long to flush packet  
	u4Byte									NumOfElem; 	// For keep number of field !!
	RT_DO_COALESICING_FIELD_INFO			dFieldArry[5];     // We define in 5 in windows 8.1  !! 
	
}RT_DO_COALESICING_FILTER_PARAMETER,*PRT_DO_COALESICING_FILTER_PARAMETER;

typedef struct _RT_DO_COALESICING_FILTER_INFO
{
	BOOLEAN									bEnable;   // Do or not !!
	RT_DO_COALESICING_FILTER_PARAMETER	dFilterArry[10]; // We define in 10 in windows 8.1  !! 
	
}RT_DO_COALESICING_FILTER_INFO,*PRT_DO_COALESICING_FILTER_INFO;

typedef struct _RT_DBG_CONTROL
{
	BOOLEAN		PowerSaveDisable;		// if lock is true, leave and don't do power save anymore.
}RT_DBG_CONTROL, *PRT_DBG_CONTROL;
/*---------------------End Define--------------------------------------*/

#pragma pack(1)

typedef struct _CUSTOMIZED_SCAN_REQUEST{
	BOOLEAN bEnabled; // specifies whether this customized scan request is valid
	u1Byte Channels[MAX_CHANNEL_NUM]; // channels to scan
	u1Byte nChannels; // num of items in Channels[]
	RT_SCAN_TYPE ScanType; // passive/active scan
	u2Byte Duration; // scan duration on each channel of Channels[]
	u1Byte DataRate; // data rate used to send probe req
	u2Byte ProbeReqLen; // length of the customized probe req
	u1Byte ProbeReqBuf[1]; // the customized probe req
} CUSTOMIZED_SCAN_REQUEST, *PCUSTOMIZED_SCAN_REQUEST;

#pragma pack()

#define	IHV_SUPPORT_TYPE				u1Byte
#define	PIHV_SUPPORT_TYPE				pu1Byte

#define	IHV_SUPPORT_NONE				0		// No IHV support
#define	IHV_SUPPORT_DEFAULT				BIT0	// The IHV support default (realtek) functions
#define	IHV_SUPPORT_CCX_SERVICE			BIT1	// The IHV support CCX service

typedef enum BEACON_SEND_STATE {
	BEACON_STOP = 0,			// The configuration is in the stopped state. The SW stopped the SW timer.
	BEACON_STARTING = 1,		// It's in HW/SW beacon configuration state and the Beacon is not sent yet.
	BEACON_STARTED = 2,			// The fist beacon has been sent and the beacons are continuously sent.
} BEACON_SEND_STATE, *PBEACON_SEND_STATE;

typedef   struct _Check_Stable_Traffic
{
	BOOLEAN			bGetValue;
	BOOLEAN			bShake;
	BOOLEAN			bDetectIndicationNumber;
	u1Byte			count;
	u1Byte			ErrorCount;
	u1Byte			levelCount ;
	u1Byte			shakeCount ;
	u1Byte			stableCount ;
	u1Byte			stableIndicationNumber;
}Check_Stable_Traffic, *PCheck_Stable_Traffic;

#define	FT_INFO_VALID				BIT0	// This entry is valid
#define	FT_INFO_WAIT_OS_DECISION	BIT1	// Wait the OS's decision
#define	FT_INFO_OS_DECISION_MADE	BIT2	// OS has made the FT association info.
typedef struct _FT_INFO_ENTRY
{
	u1Byte		Flag;	// FT_INFO_xxx
	u1Byte		targetAddr[6];

	u4Byte		osAssocInfoStatus;

	u2Byte		MDELen;
	u1Byte		MDE[MAX_MD_IE_LEN + SIZE_EID_AND_LEN];

	u2Byte		FTELen;
	u1Byte		FTE[MAX_FT_IE_LEN + SIZE_EID_AND_LEN];

	u2Byte		PMKR0NameLen;
	u1Byte		PMKR0Name[PMKID_LEN]; // PMKR0Name is used to identify the PMK-R0

	u2Byte		RSNELen;
	u1Byte		RSNE[MAX_IE_LEN];	// Including ID and Length of IE
}FT_INFO_ENTRY, *PFT_INFO_ENTRY;
#define	MAX_FT_ENTRY_NUM	6

typedef enum _FT_ENTRY_ACTION
{
	FT_ENTRY_ACTION_DEL_TARGET = 0,
	FT_ENTRY_ACTION_UPDATE_MDE,
	FT_ENTRY_ACTION_UPDATE_FTE,
	FT_ENTRY_ACTION_UPDATE_PMKR0_NAME,
	FT_ENTRY_ACTION_UPDATE_RSNE,
	FT_ENTRY_ACTION_UPDATE_ASSOC_INFO_STATUS,
	FT_WAIT_OS_DECISION,
	FT_OS_DECISION_MADE,
	//=== Insert new method above this line === //
	FT_ENTRY_ACTION_MAX,	// Reserved
	FT_ENTRY_ACTION_FORCE_UINT32 = 0xFFFFFFFF	//Reserved, force this enumeration to compile to 32 bits in size (by Win SDK 8.0).
}FT_ENTRY_ACTION, *PFT_ENTRY_ACTION;

typedef struct _MGNT_INFO{

	// -- Driver operation mode --
	RT_OP_MODE			OpMode;
	u1Byte				Bssid[6];
	OCTET_STRING		Ssid;
	u1Byte				SsidBuf[33];

        // add for 92D hidden ssid scan issue
	//BOOLEAN				bHiddenSSID92D;
	u1Byte				hiddenChannel;
	BOOLEAN				bNeedSkipScan;
	BOOLEAN				bCompleteScan;
	BOOLEAN				bResetScan;
	BOOLEAN				bScanTimeExceed;

	BOOLEAN				bScanOnly;
	BOOLEAN				bDisableScanByOID;
	BOOLEAN				bIbssStarter;
	BOOLEAN				bIbssCoordinator; // TRUE if we are winner of latest Beacon contention and should be the coordinator in this Beacon Period, FALSE otherwise, 2005.12.15, by rcnjko.

	BOOLEAN				bMediaConnect;
	BOOLEAN				init_adpt_in_progress;

	

	BOOLEAN				bFlushScanList; // If this flag is set true when querying scan list, it means the OS has flushed the scan list.

	BOOLEAN				RequestFromUplayer;
	BOOLEAN				RfRequestFromUplayer; //Record Rf state from Windows UI.
	BOOLEAN				bDisconnectRequest;
	BOOLEAN				bRoamRequest;
	BOOLEAN				bPrepareRoaming;
	RT_PREPARE_ROAM_TYPE	PrepareRoamState;
	
	// Set when authentication type, capability changes.
	// Refered in MgntActSet_802_11_SSID().
	RT_MLMESTARTREQ_RSN	bMlmeStartReqRsn;

	RT_JOIN_ACTION			JoinAction;


	RT_LINK_DETECT_T	LinkDetectInfo;
	u2Byte				DisconnectedSlotCount;

	u2Byte				FragThreshold;

	// Scanning flags
	// -----------------------------------------
	BOOLEAN				bScanInProgress;
	BOOLEAN				bActiveScan;
	u1Byte				Scancount;			//To distinguish each scan
	RT_TIMER			ScanTimer;
	u1Byte				ScanStep;
	BOOLEAN				bScanAntDetect;

	// Replace the Windows Ndis6 CheckforHang Timer -----------------------
	RT_TIMER			WatchDogTimer;
	BOOLEAN				WatchDogReturnFlag;
	BOOLEAN				bSetWatchDogTimerByDriver;
	// ---------------------------------------------------------------

#if (DFS_SUPPORT == 1)	
	DFS_MGNT			DFSMgnt;
#endif
	WIRELESS_SETTING_BEFORE_SCAN	SettingBeforeScan;

	RT_CHANNEL_DOMAIN	ChannelPlan;		// The current channel plan.
	u2Byte				RegChannelPlan; 	// Channel Plan specifed by user, read from INF.
	BOOLEAN				bChnlPlanFromHW;	// TRUE is channel plan is defined by HW and can't changed by SW(OID/INF).

        BOOLEAN                    bLoadIMRandIQKSettingFor2G;// True if IMR or IQK  have done  for 2.4G in scan progress

	// bDualModeScanStep
	//  - 0:idle, only one mode
	//  - 1:scanning mode need to change
	//  - 2:scanning mode change to the mode 2
	//  - 3:Complete scan, change to mode 3
	u1Byte				bDualModeScanStep;

	// SSIDs to be scan, 2006.12.19, by shien chang.
	RT_SSIDS_TO_SCAN	SsidsToScan;

	// Join flags
	// -----------------------------------------
	BOOLEAN				bIbssNeedAuth;

	RT_TIMER			JoinTimer;
	RT_TIMER			JoinConfirmTimer;
	RT_TIMER			JoinProbeReqTimer;
	RT_TIMER			WaitingKeyTimer;
	u2Byte				JoinRetryCount;
	BOOLEAN				bJoinInProgress;

	BOOLEAN				bResetInProgress;

	u1Byte				state_Synchronization_Sta;
	u1Byte				state_Synchronization_Sta_BeforeScan;
	u1Byte				FilterHiddenAP;

	// BSS List
	// -----------------------------------------
	u2Byte				NumBssDesc;
	RT_WLAN_BSS			bssDesc[MAX_BSS_DESC];

	// Joseph add for antenna switch
	u2Byte				tmpNumBssDesc;
	RT_WLAN_BSS			tmpbssDesc[MAX_BSS_DESC];

	// For ON_BEACON use. Fix lower memory verifier or BSOD.
	RT_WLAN_BSS			bssDesc_OnBeacon;

	u2Byte				NumBssDesc4Query;
	RT_WLAN_BSS			bssDesc4Query[MAX_BSS_DESC];

	u2Byte				NumBssDesc4Rssi;
	RT_WLAN_RSSI		bssDesc4Rssi[MAX_BSS_DESC];

	RT_WLAN_BSS			targetBSS;	// Target BSS information to connect

	// Current status
	// -----------------------------------------
	WIRELESS_MODE		dot11CurrentWirelessMode;
	WIRELESS_MODE		CurrentBssWirelessMode; // For damn Netgear's request: they want to get wireless mode of BSS not that of STA. 2005.02.17, by rcnjko.
	BOOLEAN				bHalfWiirelessN24GMode;
	u1Byte				dot11CurrentChannelNumber;
	CHANNEL_WIDTH		dot11CurrentChannelBandWidth;
	u2Byte				dot11BeaconPeriod;
	u1Byte				dot11DtimPeriod;
	u1Byte				mDtimCount; // 0 at TBTT of beacon with DTIM.

	u2Byte				dot11AtimWindow;
	u2Byte				dot11RtsThreshold;
	u2Byte				ListenInterval;
	u2Byte				ListenIntervalInDX;

	u2Byte				mCap;

	EXTCHNL_OFFSET		ChannelOffset;
	// 802.11n related HT info
	PRT_CHANNEL_INFO			pChannelInfo;
	PRT_HIGH_THROUGHPUT			pHTInfo;
	PRT_VERY_HIGH_THROUGHPUT	pVHTInfo;

	RT_WORK_ITEM		ChangeBwChnlFromPeerWorkitem;

	u1Byte				ratr_index;
	u1Byte				BT_RatrInx;
	u1Byte				Multi_RatrInx;
	u1Byte				Ratr_State;
	u1Byte				mBratesBuf[MAX_NUM_RATES];
	OCTET_STRING		mBrates;

	u1Byte				HighestBasicRate;
	u1Byte				LowestBasicRate;	
	u1Byte				HighestOperaRate;
	u1Byte				CurrentBasicRate;
	u1Byte				CurrentOperaRate;

	OCTET_STRING		dot11OperationalRateSet;
	u1Byte				dot11OperationalRateBuf[MAX_NUM_RATES];
	OCTET_STRING		Regdot11OperationalRateSet;
	u1Byte				Regdot11OperationalRateBuf[MAX_NUM_RATES];

	// -- Supported Rate --
	OCTET_STRING		SupportedRates; 
	u1Byte				SupportedRatesBuf[MAX_NUM_RATES];
	OCTET_STRING		RegSuppRateSets[MAX_WIRELESS_MODE_CNT];
	u1Byte				RegSuppRateSetsBuf[MAX_WIRELESS_MODE_CNT][MAX_NUM_RATES];

	u1Byte				HTHighestOperaRate;
	u1Byte				RegHTSuppRateSet[16];
	u1Byte				dot11HTOperationalRateSet[16];			//use RATR format
	u1Byte				Regdot11HTOperationalRateSet[16];		//use RATR format

	u1Byte				VHTHighestOperaRate;
	u1Byte				RegVHTHighestOperaRate;
	u1Byte				RegVHTSuppRateSet[2];
	u1Byte				dot11VHTOperationalRateSet[2];		
	u1Byte				Regdot11VHTOperationalRateSet[2];		

	// For basic rate set maintain. 2010.11.03. by tynli.
	u1Byte				SupportRatesfromBCNBuf[MAX_NUM_RATES];
	OCTET_STRING		SupportRatesfromBCN;
	
        // For Min spacing configurations, Added by Roger, 2008.08.30.
	u1Byte				MinSpaceCfg;

	u2Byte				SequenceNumber;
	u1Byte				SoundingSequence;

	// Set TRUE before associate to AP or join an IBSS network
	// Set FALSE when (1) associate to AP, (2) Join an IBSS, (3) AP mode
	BOOLEAN				mDisable;

	// Set TRUE after receiving association response from AP.
	BOOLEAN				mAssoc;
	BOOLEAN				bStartDelayActionFrame;

	// Set TRUE after joining an IBSS or starting an IBSS.
	BOOLEAN				mIbss; //Boolean:= false,
	u1Byte				mMacId;
	u1Byte				mcastMacId;	// macId used for multicast/broadcast
	u2Byte				mAId;
	RT_AP_TYPE			ApType;
	AP_STATE			APState;
	BOOLEAN				bSwitchingAsApInProgress;
	BOOLEAN				bSwitchingSTAStateInProgress;
	BOOLEAN				bDelaySwitchToApMode;
	// For AP mode delay mechanism test ,.
	BOOLEAN				bDelayApBeaconMode;
	u4Byte				DelayApBeaconCnt;
	
	RT_WORK_ITEM		IbssStartRequestWorkItem;
	RT_WORK_ITEM		ApStartRequestWorkItem;
	RT_WORK_ITEM		ApSendDisassocWithOldChnlWorkitem;	 

	// To protect drop packet progress
	BOOLEAN				bDropPktInProgress;
	RT_WORK_ITEM		DropPacketWorkItem;
	
	IbssParms			mIbssParms;    // empty if infrastructure BSS

	
	u1Byte				dot11CurrentPreambleMode; // It represents current preamble mode. 2005.01.06, by rcnjko.

	BOOLEAN				bDisableUseProtection; // TRUE if protection mode forced disabled by User.
	BOOLEAN				bUseProtection; // TRUE if the BSS is now in protection mode.
	BOOLEAN				bProtection;	// The protection status of default port or extension port, the value is independent to each port. by tynli.

	// Authentication status
	// -----------------------------------------
	RT_TIMER			AuthTimer;
	u1Byte				State_AuthReqService;
	u1Byte				AuthReq_auAlg;	// where to set?
	u1Byte				AuthRetryCount;
	u1Byte				AuthStatus; //Indicate OID

	u2Byte				RspCapability;
	u2Byte				RspStatusCode;
	u2Byte				RspAssociationID;

	// Association status
	// -----------------------------------------
	RT_TIMER			AsocTimer;
	u1Byte				State_AsocService;
	u1Byte				AsocRetryCount;
	u8Byte				AsocTimestamp;

	// Beacon frame
	// -----------------------------------------
	OCTET_STRING		beaconframe;
	SHARED_MEMORY		BcnSharedMemory;

	// SW Beacon.
	// -----------------------------------------
	RT_TIMER			SwBeaconTimer;
	BEACON_SEND_STATE	BeaconState;	// The current sending state of Beacon
	RT_WORK_ITEM		TbttPollingWorkItem; // Workitem to simulate TBTT notification by polling MAC.TSF, 070124, by rcnjko.
	
	u4Byte				MaxBeaconSize;	//2010.06.23. Added by tynli. To observe the max beacon size.
	
	// Roaming flags
	// -----------------------------------------
	RT_ROAM_TYPE		RoamingType;
	RT_ROAMING_STATE	RoamingState;
	u1Byte				APaddrbeforeRoaming[6];
	u1Byte				PrepareRoamingCount;
	u1Byte				RoamingFailCount;
	u1Byte				RegRoamingLimitCount;		// Max Roaming count.

	//
	// When wake up, AP would be reset by MgntActSet_802_11_SSID().
	// We should not restart beaconning under win7. 
	// This flag is for AP_StartAPRequest() to determine whether to start beaconning.
	//
	BOOLEAN				bStartApDueToWakeup;
	//default setting ==================
	u1Byte				Regdot11ChannelNumber;
	u1Byte				Regdot112GChannelNumber;
	u1Byte				Regdot115GChannelNumber;
	u2Byte				Regdot11BeaconPeriod;
	u1Byte				Regdot11DtimPeriod;

	//Set when load default value and MgntActSet_802_11_INFRASTRUCTURE_MODE()
	u1Byte				Regdot11networktype; 
	u2Byte				RegmCap;

	
	u1Byte				RegPreambleMode; // It represents default setting about preamble mode. 2006.01.06, by rcnjko. 

	// Power Save Ralated
	BOOLEAN				RegRfOff;
	BOOLEAN				RFChangeInProgress; // RF Chnage in progress, by Bruce, 2007-10-30.
	RT_POWER_SAVE_CONTROL	PowerSaveControl;

	BOOLEAN				bHwWpsPbc;
	BOOLEAN				bSdioDpcIsr;

	u1Byte				LastRxUniSrcAddr[6];		// added by Annie, 2005-07-25.
	u1Byte				LastRxUniFragNum;
	u2Byte				LastRxUniSeqNum;

	// 2005.01.13, by rcnjko.
	u2Byte				ForcedDataRate; // Force Data Rate. 0: Auto, 0x02: 1M ~ 0x6C: 54M.
	u2Byte				ForcedBstDataRate;
	BOOLEAN				ForcedTxDisableRateFallBack;

	u1Byte				bRegHwParaFile;

	u2Byte				RoamingCount;
	u2Byte				DisconnectCount;

	// 2006.09.04, by shien chang.
	BOOLEAN				bPSPXlinkMode; // Current enable XLink mode (promicuous mode).
	BOOLEAN				bDefaultPSPXlinkMode; // Enable XLink mode (promicuous mode) for default settings, i.e., from registry or UI.
	BOOLEAN				bNetMonitorMode;  // 2007.08.06, by shien chang.
	
	//----------------------------------------------------------------------------
	// Power save mode, 070104, by rcnjko.
	//----------------------------------------------------------------------------
	RT_PS_MODE			dot11PowerSaveMode; // Power save mode configured.
	u1Byte				PsPollType;			// 0: Auto, 1: Forced PsPoll, 2: Forced PsNonPoll (null frame)
	RT_PS_STATE			mPss; // Current power save state of the device.
	BOOLEAN				bAwakePktSent; // TRUE if we had sent a packet with PwrMgt bit == 0 since mPss becom eAwake.
	RT_WORK_ITEM		DozeWorkItem;
	RT_TIMER			AwakeTimer;
	RT_WORK_ITEM		AwakeWorkItem;
	u1Byte				TxPollingTimes;
	BOOLEAN				BcnIntvalKeepAwake;

	//----------------------------------------------------------------------------
	// AP mode related, 2005.05.27, by rcnjko.
	//----------------------------------------------------------------------------

	u1Byte				arChalng[128]; // Challenge text for shared-key authenticatin. 

#if 1//(AP_MODE_SUPPORT == 1)
	// 2012/01/12 MH Add one RT_WLAN_STA for ODM default port conpatiable with other SW team.
	// If STA mode is more than 2 we can add the array number.
	RT_WLAN_STA		DefaultPort[1];
	RT_WLAN_STA		AsocEntry[ASSOCIATE_ENTRY_NUM]; // Information of STAs. <RJ_TODO_AP> Revise the data type name and its variables.
#endif
	u2Byte				AvailableAsocEntryNum; // # of entries of AsocEntry[] available.
	u2Byte				PowerSaveStationNum; // # of STA in PS mode. <RJ_TODO_AP> 
	RT_LIST_ENTRY		GroupPsQueue; // Mcst/Bcst packet queued for one or more STA is in power-save mode.
	OCTET_STRING		Tim; // A octet string for TIM IE.
	u1Byte 				TimBuf[254]; // 254=3+251, Buffer for TIM IE.
	int					LiveTime;	// Station live time. (in second)
	u1Byte				AvailableAIDTable[ASSOCIATE_ENTRY_NUM];
	u2Byte				MaxMACID;  //YJ,add for TX RPT,111213

	RT_TIMER			DelaySendBeaconTimer;
	// AP mode global security related data: added by Annie, 2005-06-28.
	AUTH_GLOBAL_KEY_TAG	globalKeyInfo;
	// Annie TOADD: VirtualCAM

	// for indication
	PRT_WLAN_STA		pCurrentSta; // the STA we are dealing with for indication. we get the state machine through here, similar as pMgntInfo->AsocInfo 

	// Additonal IEs for beacon
	u4Byte                   		AdditionalBeaconIESize;
	PVOID                   		AdditionalBeaconIEData; // Allocated when OID_DOT11_ADDITIONAL_IE is set.

	//Additonal IEs for probe response
	u4Byte                   		AdditionalResponseIESize;
	PVOID                   		AdditionalResponseIEData;   

	u4Byte				AdditionalAssocReqIESize;
	PVOID				AdditionalAssocReqIEData;

	u4Byte				AdditionalProbeReqIESize;
	PVOID				AdditionalProbeReqIEData;

	//
	// Customer ID, 060703, by rcnjko.
	//
	RT_CUSTOMER_ID		CustomerID;

	//
	// For Turbo mode. Added by Roger, 2006.12.07.
	//
	RT_TURBO_CA			TurboChannelAccess;
	
	// Security Information
	RT_SECURITY_T		SecurityInfo;

	// 802.11e and WMM Traffic Stream Info (TX)
	RT_LIST_ENTRY		Tx_TS_Admit_List;
	RT_LIST_ENTRY		Tx_TS_Pending_List;
	RT_LIST_ENTRY		Tx_TS_Unused_List;
	TX_TS_RECORD		TxTsRecord[TOTAL_TS_NUM];

	// 802.11e and WMM Traffic Stream Info (RX)
	RT_LIST_ENTRY		Rx_TS_Admit_List;
	RT_LIST_ENTRY		Rx_TS_Pending_List;
	RT_LIST_ENTRY		Rx_TS_Unused_List;
	RX_TS_RECORD		RxTsRecord[TOTAL_TS_NUM];
	RX_REORDER_ENTRY	RxReorderEntry[RX_REORDER_ENTRY_NUM];
	RT_LIST_ENTRY		RxReorder_Unused_List;
#if RX_AGGREGATION
	// Rx Aggr Batch indication
	u1Byte 				IndicateTsCnt;
	PRX_TS_RECORD 		IndicateTsArray[TOTAL_TS_NUM];
#endif

	// Qos related. Added by Annie, 2005-11-01.
	PSTA_QOS			pStaQos;
	
	BOOLEAN				bUpdateTxPowerInProgress; // TRUE if the operation to update all tx power of all channel is in progress.
	s4Byte				PowerToUpdateInDbm; // Tx power to update in dBm.
	s4Byte				ClientConfigPwrInDbm; // Client configured power in dbm for CCX
	RT_WORK_ITEM		UpdateTxPowerWorkItem; // Workitem to update Tx power.

	BOOLEAN				bScanWithMagicPacket; // TRUE if we send magic instead of ProbeReq in scan process for WOL. 2005.06.27, by rcnjko.
	u1Byte				MagicPacketDstAddr[6]; // Destination address of magic packet, i.e. the MAC address of the STA we want to wake up. 2005.06.27, by rcnjko.
	BOOLEAN				bHiddenSSIDEnable;

	//  Auto select channel by an evaluation algorithm when start an AP mode, 2005.12.27, by rcnjko.
	//	<RJ_TODO> It can be applied to IBSS mode too.
	BOOLEAN				bAutoSelChnl;	// TRUE if we will select a channel, FALSE otherwise.
	u1Byte				ChnlWeightMode;	// There are max 10 modes, see also: AutoSelectChannel(). Added by Annie, 2006-07-26.
	//

	// AP mode Hidden SSID flag. Added bY Annie, 2006-02-14.
	BOOLEAN				bHiddenSSID;

	// AP mode locked STA list. Added by Annie, 2006-02-14.
	u1Byte				LockType;
	u1Byte				LockedSTAList[MAX_LOCKED_STA_LIST_NUM][ETHERNET_ADDRESS_LENGTH];
	u4Byte				LockedSTACount;
	// AP mode locked STA list. Added by Ken 2014-02-20.
	u1Byte				LockedSTAList_Reject[MAX_LOCKED_STA_LIST_NUM][ETHERNET_ADDRESS_LENGTH];
	u4Byte				LockedSTACount_Reject;
	BOOLEAN				bDefaultPermited;

	//Cloud Key Offset. requested by 360
	u1Byte				cloud_key_offset;

	//AP Mode Station Count
	u1Byte				StaCount;

	// AP mode: force per-station data rate. 2006.04.11, by rcnjko.
	RT_STA_DATARATE	StaDataRateList[MAX_STA_DATARATE_LIST_NUM];
	u4Byte				StaDataRateCount; // # of entries used in StaDataRateList[].
	u1Byte				RegApModeDefPerStaDataRate;

	// WDS, 2006.06.11, by rcnjko.
	u1Byte				WdsMode;
	u1Byte				WdsApAddr[6];
	
	//
	// For RF state maintance.
	//
	RT_RF_CHANGE_SOURCE	RfOffReason;	
	BOOLEAN				ClkReqState;	

	CHANNEL_ACCESS_SETTING	ChannelAccessSetting;
	
	//ADD for AP HW ENC ,CCW
	BOOLEAN				bAPGlobRest;
	SW_CAM_TABLE           SWCamTable[32];

	//----------------------------------------
	//add for ROGUE AP 2007.07.27 , by CCW
	//----------------------------------------
	BOOLEAN					bROGUEAP;
	MH_CCX_ROGUE_AP_ENTEY	ROGUE_AP_ENTEY[SIZE_ROGUE_AP_ENTEY];
	//----------------------------------------
	//add for ROGUE AP 2007.07.28 , by CCW
	//----------------------------------------
	BOOLEAN				bNETWORKEAP;

	// Workaround by shien chang, please see ASSO_INFO. 2006.10.28, by shien chang.
	ASOC_INFO			AsocInfo;

	//----------------------------------------
	// Connectivity feature, 2006.11.01, by shien chang.
	//----------------------------------------
	u1Byte				ExcludedMacAddr[MAX_EXCLUDED_MAC_ADDRESS_LIST][6];
	u4Byte				ExcludedMacAddrListLength;

	// For smart connect. 2006.11.21, by shien chang.
	u1Byte				RejectedAsocAP[MAX_REJECTED_ACCESS_AP][6];
	u1Byte				NumRejectedAsocAP;

	BOOLEAN				bExcludeUnencrypted;
	BOOLEAN				SafeModeEnabled;	

	//For NDIS6 RSNA ,by CCW
	BOOLEAN				bRSNAPSKMode;

	// For turbo mode. Added by Roger, 2006.12.07.
	// -----------------------------------------
	BOOLEAN				bAutoTurboBy8186;		// 8186 "AutoTurbo" mode switch.
	BOOLEAN				bSupportTurboMode;		// 8187 Turbo mode switch.	
	BOOLEAN				bRealtekAggCapExist;
	//The following variables have NOT checked yet....Roger, 2006.12.07
	BOOLEAN				bRealtekCapType1Exist ;		// 8186 "AutoTurbo" mode: 8186 IE exists or not in current association.
	u1Byte				RTIEType2Buffer[7];			// 8186 "AutoTurbo" mode: Realtek IE buffer, used in AsocReq/ReasocReq/ProbeReq. 00-E0-4C-01-02-01-00.

	RT_RF_POWER_STATE	eSwRfPowerState;		// SW RF power state, 2006.12.18, by shien chang.

	// disable tx power+ by rate 
	BOOLEAN				bDisableTXPowerByRate;
	// disable tx power training
	BOOLEAN				bDisableTXPowerTraining;
	BOOLEAN				bSetTXPowerTrainingByOid;
	BOOLEAN				bDecreaseTXPowerTraining;
	
        //
	// For simple config. by CCW - copy from 818x
	//
#if (WPS_SUPPORT == 1)	
	PVOID				pSimpleConfig;
#endif
	BOOLEAN				bPbcPressed;		

	//For alpha LED control
	u1Byte				CustomizedPbcPressTimer;
	u1Byte				CustomizedLedStateOff;   //when > 0, means LED off, and record origin led state

	// Indication when AP not exist.
	BOOLEAN				bIndicateConnectEvent;

	// <Roger_Notes> Sync from 91su branch, 2009.04.27.
	BOOLEAN				bInToSleep;

	u2Byte				ResumeBeaconTime;
	//
	// For 802.11d.
	//
	PVOID				pDot11dInfo;	

	PVOID				pChannelList;	
	
	//
	// IHV Support Type
	//
	IHV_SUPPORT_TYPE	IhvType;
	
	//
	// For CCX related information.
	//
	// Pointer to a RT_RM_CONTEXT object, which encapulats Radio Measurement related stuff. 2006.04.26, by rcnjko.
	PVOID				pRmInfo;
	PVOID				pCcxInfo;

	//For generic parser.
	PVOID				pGenericParser;
		
	// For AP mode information
#if 1//(AP_MODE_SUPPORT == 1)
	PVOID				pApModeInfo;
#endif

#if (P2P_SUPPORT == 1)
	PVOID				pP2PInfo;
#endif

#if (NAN_SUPPORT == 1)
	PVOID				pNanInfo;
#endif

	// For 802.11z
	PVOID				pTDLSTInfo;
			
#if (MULTICHANNEL_SUPPORT == 1)
	PVOID				pMultiChnl;	
#endif

	PVOID				pCustomScanInfo;

	PVOID				pOffChnlTx;

	//1 if sniffer mode. 0 turn off sniffer mode
	BOOLEAN				SnifferTurnOnFlag;
	u4Byte				SnifferSavedRCR;
	
	// Protection mode related
	u1Byte				ForcedProtectionMode;
	u1Byte				ForcedProtectRate;
	u1Byte				ForcedProtectBW;
	u1Byte				ForcedProtectSC;
	u1Byte				ForcedProtectCCA;
	BOOLEAN				bForcedProtectRTSFrame;
	BOOLEAN				bForcedProtectCTSFrame;
	
	// for HT operation rate set.  we use this one for HT data rate to seperate different descriptors
	//the way fill this is the same as in the IE

	BOOLEAN				bReg11nAdhoc;
	BOOLEAN				bRegIOTBcm256QAM;
	u1Byte				bRegVht24g;
		
	BOOLEAN				bScan_20MHz;

	//For Backup Initial Gain
	INIT_GAIN			InitGain_Backup;

	// WiFi Config
	BOOLEAN				bWiFiConfg;

	u1Byte				DM_Type;
	//Dynamic Tx power for near/far range enable/Disable  , by Jacken , 2008-03-06
	BOOLEAN				bDynamicTxPowerEnable;   

	//2008-05-09  indicate set power progress
	BOOLEAN				bSetPnpPwrInProgress;

	//tx rate display added by cosa 06162008
	u1Byte				OSTxRateDisplayType;
	// 06/19/2008 Action frame allowed flag
	u1Byte				CntAfterLink;

	// Firmware information
	u2Byte				FirmwareVersion;
	u2Byte				FirmwareVersionRev;
	u2Byte				FirmwareSubVersion;
	u2Byte				FirmwareSignature;
	
	// For IOT issue.
	u1Byte				IOTPeer;
	u1Byte				IOTPeerSubtype;
	u4Byte				IOTAction;
	u2Byte				IOTMaxMpduLen;
	BOOLEAN				IOTVhtAmsduSupport;
	BOOLEAN				bDmDisableProtect;

	// 2008/05/19 MH Add for NIC verify packet.
	// 2008/05/20 MH For verification console.
#if DBG_CMD
	RT_WORK_ITEM		NICVerify;
#endif	
	BOOLEAN				bNicVerifyPkt;

	// Roam Sensitive Level 
	s1Byte				RegROAMSensitiveLevel;

	// Roam Hysteresis
	u1Byte				RegRoamHysteresis;

	// For leisure power save in connection state, 2007-12-17 by Isaiah
	u1Byte				LPSDelayCnt;
	
	// Keep Alive mechanism
	u1Byte				keepAliveLevel;

	u8Byte				uConnectedTime;
	//TX power Level For Lenovo
	int					TxPowerLevel;

	u8Byte				DelayLPSLastTimeStamp; // Delay to enter LeisurePS when the nic sent DHCP, ARP, or EAPOL packet. By tynli.

	u1Byte				mDeauthCount; // For Deauth link retry

	u1Byte				AntennaTest;
	u1Byte				AntCurIdx;

	// dm control initial gain flag
	BOOLEAN				bDMInitialGainEnable;

	//Record NDIS Version For Compatibile 
	RT_NDIS_VERSION 		NdisVersion;

	RT_TIMER				PnpWakeUpJoinTimer;

	u4Byte				OutstandingNdisPackets;
	u4Byte				CompleteFlag;

	// Indicate event immediately when reciecing deauth/disassoc. By Bruce, 2009-05-19.
	BOOLEAN				IndicateByDeauth;

	u1Byte				ShowRateMode;
	BOOLEAN				bForcedShowRxRate;
	BOOLEAN				bForcedShowRateStill;

	// 2009/08/05 MH To protect halt adapter process.
	BOOLEAN				bHaltInProgress;
	
	//2009/08/10 This is asked by AzWava Mr. Six. To Make TKIP in N mode
	BOOLEAN				bTKIPinNmodeFromReg;
	BOOLEAN				bWEPinNmodeFromReg;
	BOOLEAN				bTKIPinNmode;

	BOOLEAN				bPwrSaveState;
	BOOLEAN				bDriverIsGoingToSleep;

	BOOLEAN				bRegClevoDriver;
	RT_DBG_CONTROL		dbg_ctrl;

	BOOLEAN				bBTMode;
	u1Byte				btHsMode;

	u1Byte				bDefaultAntenna;

	u8Byte				TSFValue; //by tynli, from Rx beacon
	u8Byte				NowTSF;
	u8Byte				NextBeacon;	

	BOOLEAN				bUseRxInterruptWorkItem;

	BOOLEAN				bWakeupAutoLinkInProgressing;

	u4Byte				uLastDecryptedErrorSeqNum;	

	BOOLEAN				bDisableCck;
	BOOLEAN				bRegVelocity;
	u4Byte				AcceptFirstEAPOLPacket;	

	BOOLEAN				bAPTimExtend;
	BOOLEAN				bConcurrentMode;

	BOOLEAN				bDumpRegs;
	u1Byte				dumpcounter;
	u1Byte				NumforRxFastbatch;


	// 2010/05/11 MH Add a timer for GPIO detect.
	// 2011/11/03 MH Use the same GPIO timer.
	RT_TIMER			GpioDetectTimer;	
	BOOLEAN				GpioDetectTimerStart;
	BOOLEAN				HwPBCDetectTimerStart;

	// 2010/05/18 MH Add for GPIO setting.
	u1Byte				bRegTimerGPIO;
	u2Byte				bRegGPIODelay;
	u2Byte				bRegGPIOBack;

	// 2010/08/25 MH Add to support pdn mode switch.
	u1Byte				bRegPDNMode;
	
	// 2010/09/01 MH According to PM's request, we support dongle selective suspend mode switch.	
	u1Byte				bRegDongleSS;
	
	// 2010/09/13 MH According to PM's request, we support different SS power seave level.	
	u1Byte				bRegSSPwrLvl;
	
	// 2011/02/16 MH Add for SS HW radio detect workaround temporarily.
	u1Byte				bRegSSWakeCnt;
	
	// 2010/12/17 MH Add for RX aggregation mode switch according to TX/RX traffic.	
	u1Byte				bRegAggDMEnable;
        BOOLEAN			bSendPacketByTimer;	

	// 2010/12/31 MH Add for UPHY dynamic chaneg.	
	u1Byte				bRegUPDMEnable;

	// 2011/07/08 MH Add for different link speed display.
	u1Byte				bRegLinkSpeedLevel;	

	u1Byte				RSSI2GridMode;
	
	// 2011/07/14 MH Add for rx short cut.	
	u1Byte				bRegRxSC;

	// 2011/07/15 Sinda Add for tx short cut.	
	u1Byte				bRegTxSC;

	// 2011/09/15 MH Add registry for switching packet compete method.
	u1Byte				RegTxMode;

	// 2012/09/14 MH Add for EDCA turbo mode switch threshold.
	// 2012/09/14 MH Add for 88E rate adaptive mode siwtch.
	u2Byte				RegEdcaThresh;
	u2Byte				NumNonBePkt;
	u2Byte				NumBePkt;
	u2Byte				RegRALvl;

	// 2012/10/26 MH Add for 8812/8821 AC series dynamic switch.
	u1Byte				RegAcUsbDmaTime;
	u1Byte				RegAcUsbDmaSize;
	u1Byte				RegAcUsbDmaTime2;
	u1Byte				RegAcUsbDmaSize2;

	// 2012/10/31 MH Add for power limit table constraint.
	u4Byte				RegTxPwrLimit;

	// 2012/11/28 MH Add for BB team AMPDU test.
	u1Byte				RegAMfactor;	
	u1Byte				RegVHTRSec;

	// 2012/11/07 Awk add PowerBase for customers to define their power base.
	u1Byte				RegPowerBase;

	// 2012/11/23 Awk add RegEnablePowerLimit for enabling/disabling power limit
	u1Byte				RegEnableTxPowerLimit;
	u1Byte				RegEnableTxPowerByRate;

	// 2015/02/11 VincentL Add for primary/secondary power limit table selection (used as initial one)
	u1Byte				RegTxPowerLimitTableSel;
	u1Byte				RegTxPwrLmtDynamicLoading;

	// 2015/04/27 VincentL Add for Toggle Support for TxPwrTable Dump Feature
	u1Byte				RegSupportTxPwrTableDump;

	// 2015/02/25 VincentL Add for UEFI method
	u1Byte				RegLoadSystemSKUfromUEFI;
	u1Byte				RegUEFIProfile;

	// 2015/07/07 VincentL Add for SMBIOS method
	u1Byte				RegLoadSystemSKUfromSMBIOS;
	u1Byte				RegLoadProcessorIDfromSMBIOS;

	OCTET_STRING		RegPwrByRateFile;
	OCTET_STRING		RegPwrLimitFile;
	OCTET_STRING		RegSecondaryPwrLimitFile;
	OCTET_STRING		RegChannelPlan2G;
	OCTET_STRING		RegChannelPlan5G;	
	u1Byte				RegDecryptCustomFile;

	// 2013/04/16 VincentLan Add to switch Spur Calibration Method
	u1Byte				RegSpurCalMethod;
	// 2013/01/23 VincentLan Add to enable IQK Firmware Offload
	u1Byte				RegIQKFWOffload;
	// 2013/11/23 VincentLan add for for KFree Feature Requested by RF David
	u1Byte				RegRfKFreeEnable;

	
	
	u1Byte				RegTxDutyEnable;
	
	// 2011/11/15 MH Add for user can select different region and map to dedicated power gain offset table.
	u1Byte				RegPwrTblSel;

	u1Byte				RegTxPwrLevel;

	// 2011/11/15 MH Add for user can select different tx power by rate switch by default value and registry value.
	u1Byte				RegPwrByRate;	
	u4Byte				RegPwrRaTbl1;	
	u4Byte				RegPwrRaTbl2;	
	u4Byte				RegPwrRaTbl3;	
	u4Byte				RegPwrRaTbl4;	
	u4Byte				RegPwrRaTbl5;	
	u4Byte				RegPwrRaTbl6;	
	u4Byte				RegPwrRaTbl7;	
	u4Byte				RegPwrRaTbl8;	
	u4Byte				RegPwrRaTbl9;	
	u4Byte				RegPwrRaTbl10;	
	u4Byte				RegPwrRaTbl11;	
	u4Byte				RegPwrRaTbl12;	
	u4Byte				RegPwrRaTbl13;	
	u4Byte				RegPwrRaTbl14;	
	u4Byte				RegPwrRaTbl15;	
	u4Byte				RegPwrRaTbl16;	

	// 2012/07/24 MH Add for win8 usb whql tst & WFD multi channel.
	u1Byte				RegUseDefaultCID;

	u1Byte				RegWfdTime;
	u1Byte				RegWfdChnl;
	
#if 1//HARDWARE_TYPE_IS_RTL8192D == 1 // Disable by MH
	//for checkEDCATurbo
	u8Byte			lastTxOkCnt ;
	u8Byte			lastRxOkCnt ;
	u8Byte 			Ext_lastTxOkCnt ;
	u8Byte 			Ext_lastRxOkCnt ;
#endif

	// Justin: Timer for Tx/Rx LED blinking
	RT_TIMER		LedTimer;
	
	// Add for USB/PCIE rx packetr indicate header.
	u1Byte			header[100][(sMacHdrLng+N6_LLC_SIZE)];

	BOOLEAN		bDisSwDmaBcn;

	// If WFD is not support, this pointer shall be NULL.
	// Note:
	//	Do not access this variable outside of WFD_xxx() functoions.
	PVOID				pWFDInfo;

	// Just for need report  power save state to OS or not ( Win8 )!! 
	BOOLEAN				bInAutoPowerSavemode;

	u1Byte				RegFakeRoamSignal[3];	// For testing only, RegFakeRoamSignal[0] = initial signal, RegFakeRoamSignal[1] = reducing signal
	u4Byte				RegCapAKMSuite;
	BOOLEAN				bInBIPMFPMode;
	u4Byte				targetAKMSuite;

	FT_INFO_ENTRY		FtEntryList[MAX_FT_ENTRY_NUM];
		
	OCTET_STRING		TIE;
	u1Byte		TIEBuff[8];

#if (WPS_SUPPORT == 1)
	// Add for customized association IE
	BOOLEAN		bCustomizedAsocIE;
	u2Byte		CustomizedAsocIELength;
	u1Byte		CustomizedAsocIEBuf[MAX_IE_LEN];
#endif	

	// For 92D CCK hang issue when dual band.
	BOOLEAN			bDisableCCKForDualBand;
	BOOLEAN			bRestoreCCKForDualBand;

	// TCP Sequence Reorder
	BOOLEAN			bTcpReorderEnable;
#if TCPREORDER_SUPPORT
	TCP_SEQ_CHECKER		TcpReorderChecker;
	TCP_SEQ_REORDER_ENTRY	TcpReorderEntry[MAX_TCP_SEQ_ENTRY_NUM];
	RT_LIST_ENTRY			TcpSeq_Unused_List;
	RT_LIST_ENTRY			TcpSeqList;
	RT_TIMER				TcpSendTimer;
	u4Byte					AvailCnt;
	u4Byte					QueuedCnt;
	BOOLEAN					bPauseTcpReorder;
#endif

	// For tracking last received mgnt frame seq number
	u2Byte				last_auth_seq;
	u2Byte				last_asoc_req_seq;
	u2Byte				last_asoc_rsp_seq;
	u2Byte				last_Disassoc_seq;
	u2Byte				last_Deauth_seq;

	// For memory management to record the objects allocation info.
	RT_LIST_ENTRY		ObjectList;

       // add for stable  traffic check 
	Check_Stable_Traffic           CheckTraffic;
	   
	BOOLEAN		bDisableCCKRateForVWIFIChangeChannel;

	//For GTK/ARP offload. by tynli.
	u1Byte					rx_mic_key[8];
	RT_PM_IPV4_ARP_PARAMETERS PMIPV4ARPPara;
	RT_PM_IPV6_NS_PARAMETERS PMIPV6NSPara[2];
	RT_PM_DOT11_RSN_REKEY_PARAMETERS PMDot11RSNRekeyPara;
	
	// Add for TCP_CHECK
	RT_SUPPORT_TCPOFFLOAD_CAP		TCPOffloadCap;
	RT_SUPPORT_TCPOFFLOAD_CAP		CurrTCPOffloadCap;
	RT_SUPPORT_TCPOFFLOAD_MODE	RegSupTCPOffload;
	RT_SUPPORT_TCPOFFLOAD_MODE	CurSupTCPOffload;

	// For Ad-hoc mode which is not support WoWLAN. 2011.09.14. by tynli.
	BOOLEAN				bIbssBeforeSleep;

	// For LC
	BOOLEAN				bStopScan;
	BOOLEAN				bReceiveSystemPSOID;		// LC S5 WoWLAN

	// For Intel Bay Trail low power platform.
	BOOLEAN				bIntelPatchPNP;

	//for PCIe Bus work on 2.5GHz or 5GHz  by gw
	BOOLEAN                    ForcePCIeRate;

	// ending
	u1Byte				TestAID;

	//sherry added for support txpacketbuffercolease for 8192DU-VC
	BOOLEAN		bSupportTxPacketBufferColease;
	//Sherry added to allow user disable 1 band in advanced setting of device management
	u1Byte				CurrentWirelessBand;

   	BOOLEAN     bSMSPSupport1by1;

	// Add for Real WOW
	TEREDOINFO			dTeredoInfo;

	// Add S5 WPA Re-Key !!
	u1Byte				mbS5SNose[32];
	u1Byte				mbS5ANose[32];
	char				mbPassphrase[PASSPHRASE_LEN];
	u4Byte				mPasspharseLen;
	u1Byte				mbS5PMK[PMK_LEN];
	u1Byte				mbS5PTK[PTK_LEN_TKIP];

	// Add for D0 filter coalesci 
	RT_DO_COALESICING_FILTER_INFO		mRtD0ColesFilterInfo;

	BOOLEAN				bEDCCASupport;

	u1Byte				RegNByteAccess;  //20121106 page add for Nbyte access BB reg switch
	u1Byte				RegFWOffload;
	u1Byte				RegDownloadFW;

	CHANNEL_WIDTH		currentRABw;
	
	u2Byte				RegScanLarge;
	u2Byte				RegScanMiddle;
	u2Byte				RegScanNormal;
	u2Byte				RegScanActive;
	u2Byte				RegForcedScanPeriod;

	u2Byte				RegPreferBand;

	// Pre-transition for OID_PNP_SET_POWER OID wake up handling, added by Roger, 2012.11.28.
	BOOLEAN		bPreTransPnP;

	BOOLEAN 	bDisconnectInProgress; //indicate disconnect in progress 20130117
	
	//20130117 Used for Invitation No/After to Pass, with skip scan when Go is connected
	u1Byte		bGoSkipScanForWFD;
	u1Byte		bClientSkipScanForWFD;
	
	BOOLEAN		bForceGoTxData20MBw;
	u1Byte		bWaitBeforeGoSkipScan;
	

	BOOLEAN				bHWRTSEnable;

	u1Byte		ScanOffloadType;
	
	// 2013/02/05 MH Add for streamMode switch.
	u1Byte				RegStreamMode;
	// 2013/02/06 MH Add Transmit power control level for all customer in the future.
	u1Byte				RegTPCLvl;
	u1Byte				RegTPCLvlD;
	u1Byte				RegTPCLvl5g;
	u1Byte				RegTPCLvl5gD;

	u1Byte				RegEnableAdaptivity;
	u1Byte				RegL2HForAdaptivity;
	u1Byte				RegHLDiffForAdaptivity;
	u2Byte				RegEnableCarrierSense;
	u2Byte				RegNHMEnable;
	u1Byte				RegDmLinkAdaptivity;
	u1Byte				RegDCbackoff;
	u1Byte				RegAPNumTH;

	BOOLEAN				RegPacketDrop;

	u1Byte				EnableResetTxStuck;

	u1Byte				RegSifsThresh;
	
	u1Byte				RegFwload;	

	u1Byte				RegUsbSafetySwitch;

	u1Byte				RegRspPwr;

	//20130220 ylb Add for 8814A FPGA Verification.
	u1Byte				Reg8814AFPGAVerification;
	u1Byte				bRegAdhocUseHWSec;

	//20140526 haiso_ho Add for 8822B FPGA Verification.
	u1Byte				Reg8822BFPGAVerification;

	BOOLEAN 	RegClearAMDWakeUpStatus; // zhiyuan add for 88ee Lenovo AMD platform
	
	BOOLEAN		RegbCustomizedScanPeriod;
	u2Byte		RegIntelCustomizedScanPeriod;
	u2Byte		RegAMDCustomizedScanPeriod;

	u2Byte		RegDisableBTCoexist;

	RT_LED_ASSOC_STATE	LEDAssocState;

	BOOLEAN		EnableMA;// For Lenovo Mutual Authentication function, added by Roger, 2013.05.03.

	u1Byte				VhtWeakSecurity;
	u1Byte				RegPassiveScan;

	BOOLEAN		bSupportPacketCoalescing;
	BOOLEAN 	IsAMDIOIC;	
	
	BOOLEAN		bPendScanOID;
	BOOLEAN		bCheckScanTime;
	u8Byte		ScanOnlyStartTime;	
	u1Byte		RegMultiChannelFcsMode;
	BOOLEAN		bFcsUpdateTSF;
	u1Byte		WFDOpChannel;

	u4Byte		RegWmmPage;
	u1Byte		WFDPeerOpChannel;
	u2Byte		ConnectionConfigTimeIntv;	
	u4Byte				Regbcndelay;
	BOOLEAN		bWPSProcess;
	u1Byte		RetryTimes;
	u4Byte		RegPktIndicate;

	u1Byte		RegDisableAC;
	u4Byte		RegLedInterval;
	u1Byte		Reg8814auEfuse;
	u1Byte		RegValidRFPath;

	// Network list offload info.
	RT_NLO_INFO			NLOInfo;

#if(AUTO_CHNL_SEL_NHM == 1)
	//
	// Auto Channel Selection mechanism for P2P GO, added by Roger, 2014.05.15.
	//
	RT_AUTO_CHNL_SEL		AutoChnlSel;
#endif

	BOOLEAN		bDisableRtkSupportedP2P;

	u1Byte		DumpDbgRegCnt;

	// For AOAC reconnection policy. 2014.11.05, added by tynli.
	BOOLEAN		bPerformPnpReconnect;
	BOOLEAN		bRegPnpKeepLink;

	// SDIO polling interrupt mode
	BOOLEAN 	bSdioPollIntrHandler;
	u2Byte		SdioIntrPollingLimit;
    
    // For Rx Reorder Control
    u1Byte				RegRxReorder;
    u1Byte				RegRxReorder_WinSize;
    u1Byte				RegRxReorder_PendTime;
   u1Byte			RegPreInitMem;
   u1Byte				Reg88EIOTAction;


	u2Byte		RegTxSendAsap;
	u2Byte		CurTxSendAsap;

	// MAC Address Randomization 
	u1Byte		RegSupportMACRandom;

	//ECSA
	u1Byte		RegSupportECSA;

	// FT
	u1Byte		RegSupportFT;

	// authentication frame
	OCTET_STRING		authReqframe;
	OCTET_STRING		authRspframe;

	u1Byte		RegSuspendTimerInLowPwr;
}MGNT_INFO, *PMGNT_INFO;

typedef struct _IRP_DBG_INFO{
	// For IRP buf/queue initialize info
	BOOLEAN				bListInit;
	BOOLEAN				bAmpAsocBuf;
	BOOLEAN				bBTLocalBufPtr;
	u4Byte				BTLocalBufAllocCnt;
	u4Byte				BTLocalBufFreeCnt;
}IRP_DBG_INFO, *PIRP_DBG_INFO;


#define 	MPHAL_INBUF_SIZE			100
#define 	MPHAL_OUTBUF_SIZE			100

typedef VOID (*DbgActFunc)(IN	PVOID		Adapter);
typedef struct _RT_NDIS_DBG_CONTEXT
{
	BOOLEAN			bDbgDrvUnload;

	// Work Item for debugging. 
	RT_WORK_ITEM 	DbgWorkItem;
	PlatformEvent	DbgWorkItemEvent;
	NDIS_SPIN_LOCK	DbgWorkItemSpinLock; // To protect the following variables.
	BOOLEAN 		bDbgWorkItemInProgress; // Indicate a DbgWorkItem is scheduled and not yet finished.

	DbgActFunc CurrDbgAct; // An instance which implements function and context of DbgWorkItem.

	// Variable needed in each implementation of CurrDbgAct.
	ULONG	DbgActType; // Type of action performed in CurrDbgAct.
	ULONG	DbgIoOffset; // The type of IO operation is depend of DbgActType.  
	ULONG	DbgIoValue; // The type of IO operation is depend of DbgActType.
	ULONG	DbgOutLen;
    u1Byte	DbgOutBuf[100];
	UCHAR	DbgIoBuf[64];
	ULONG	DbgRfPath;	// The RF path of IO operation. Added by Roger, 2008.09.10.

	//cosa add for bt control	
	// Event used to sync H2c for BT control
	PlatformEvent	dbgH2cRspEvent;
	PlatformEvent	dbgBtC2hEvent;
	PlatformEvent	dbgBtCoexEvent;
	u1Byte			h2cReqNum;
	u1Byte			btInBuf[100];	
} RT_NDIS_DBG_CONTEXT, *PRT_NDIS_DBG_CONTEXT;
//
// Reason code for surprisely removing.
//
#define HALT_BY_TX			0x01000000
#define HALT_BY_TX_REQUEST	0x01000001
#define HALT_BY_TX_COMPLETE	0x01000002
#define HALT_BY_RX			0x02000000
#define HALT_BY_RX_REQUEST	0x02000001
#define HALT_BY_RX_COMPLETE	0x02000002
#define HALT_BY_IO			0x04000000
#define HALT_BY_IO_SYNC		0x04000001
#define HALT_BY_IO_ASYNC	0x04000002
#define HALT_BY_PNP_EVENT	0x08000000
#define HALT_BY_DRV_STOP	0x10000000

//
// Function disabled.
//
#define DF_TX_BIT		BIT0
#define DF_RX_BIT		BIT1
#define DF_IO_BIT		BIT2
#define DF_IO_D3_BIT			BIT3

#define RT_DF_TYPE		u4Byte
#define RT_DISABLE_FUNC(__pAdapter, __FuncBits) ((__pAdapter)->DisabledFunctions |= ((RT_DF_TYPE)(__FuncBits)))
#define RT_ENABLE_FUNC(__pAdapter, __FuncBits) ((__pAdapter)->DisabledFunctions &= (~((RT_DF_TYPE)(__FuncBits))))
#define RT_IS_FUNC_DISABLED(__pAdapter, __FuncBits) ( (__pAdapter)->DisabledFunctions & (__FuncBits) )

//
// Driver State
//
#define ADAPTER_STATUS_FIRST_INIT				0x00000001
#define ADAPTER_STATUS_WAKE_UP				0x00000002
#define ADAPTER_STATUS_FW_DOWNLOAD_FAILURE	0x00000004
#define ADAPTER_STATUS_BB_CONFIG_FAILURE		0x00000005 //added by vivi, bb config failure

#define ADAPTER_SET_STATUS_FLAG(_M, _F)            PLATFORM_INTERLOCKED_SET_BITS(&((_M)->Status), (_F))
#define ADAPTER_CLEAR_STATUS_FLAG(_M, _F)        PLATFORM_INTERLOCKED_CLEAR_BITS(&((_M)->Status), (_F))
#define ADAPTER_TEST_STATUS_FLAG(_M, _F)          (((_M)->Status & (_F)) != 0)

#if 0
typedef enum _DUAL_MAC_SCENARIOS_TYPE{
	No_Scenarios = 0,
	STA_STA = 1,
	STA_AP	 = 2,
	STA_P2P = 3
}DUAL_MAC_SCENARIOS_TYPE,*PDUAL_MAC_SCENARIOS_TYPE;


typedef enum _DUAL_MAC_EASY_COCURRENT_CHECK_STATE{
	RT_DO_NOTHING = 0,
	RT_NEED_RETRY = 1,
	RT_NEED_RESCHEDULE = 2
}DUAL_MAC_EASY_COCURRENT_CHECK_STATE,*PDUAL_MAC_EASY_COCURRENT_CHECK_STATE;

typedef enum _DUAL_MAC_TWO_STA_CONCURRENT_MODE{
	RT_NO_SET = 0,
	RT_SECONDARY_DISABLE = 1,
	RT_SECONDARY_ENABLE = 2,
	RT_SECONDARY_AUTO = 3
}DUAL_MAC_TWO_STA_CONCURRENT_MODE,*PDUAL_MAC_TWO_STA_CONCURRENT_MODE;


typedef struct _DUAL_MAC_DMSP_CONTROL{
	BOOLEAN			bActiveScanForSlaveOfDMSP;
	BOOLEAN			bScanForAnotherMacForDMSP;
	BOOLEAN			bScanForItSelfForDMSP;
	BOOLEAN			bWriteDigForAnotherMacOfDMSP;
	u4Byte			CurDigValueForAnotherMacOfDMSP;
	BOOLEAN			bChangeCCKPDStateForAnotherMacOfDMSP;
	u1Byte			CurCCKPDStateForAnotherMacOfDMSP;
	BOOLEAN			bChangeTxHighPowerLvlForAnotherMacOfDMSP;
	u1Byte			CurTxHighLvlForAnotherMacOfDMSP;
	s4Byte			RssiValMinForAnotherMacOfDMSP;
}DUAL_MAC_DMSP_CONTROL,*PDUAL_MAC_DMSP_CONTROL;

typedef struct _DUAL_MAC_EASY_SMART_CONCURRENT_CAHANEL_SETTING_CONTROL{
	BOOLEAN		bConfiguredByUser;
	BAND_TYPE	BandToSet;
	u1Byte		ChannelNumberToSet;
	BOOLEAN		bChangeChannelOnly;
}DUAL_MAC_EASY_SMART_CONCURRENT_CAHANEL_SETTING_CONTROL,*PDUAL_MAC_EASY_SMART_CONCURRENT_CAHANEL_SETTING_CONTROL;

typedef struct _DUAL_MAC_EASY_CONCURRENT_CONTROL{
	BOOLEAN			bConfigurationByUI;
	BOOLEAN			bRegSTAAndSTAEasySmartConcurrentSupport;
	u1Byte			RegTwoStaConcurrentMode;
	u1Byte			CurrentTwoStaConcurrentMode;
	BOOLEAN			bSupportSTAAndSTASmartConcurrent;
	BOOLEAN			bSupportSTAAndAPSmartConcurrent;
	BOOLEAN			bSkipChangeMacPhyMode;
	BOOLEAN			bDisableCCKRateDuringMacPhyModeChange;
	RT_WORK_ITEM	DualMacEasyConcurrentWorkItem;
	RT_TIMER		DualMacEasyConcurrentRetryTimer;
	BOOLEAN			bJoinRequestReschedule;
	BOOLEAN			bJoinRequestRescheduleRetry;
	BOOLEAN			bRestartAPRescheduleRetry;
	BOOLEAN			bRestartAPReschedule;
	BOOLEAN			bNeedSendMimoPs;
	BOOLEAN			bNeedRestartAP;
	u1Byte			BandSetBackForDMDP;
	u1Byte			CurrentBandTypeBackForDMDP;
	u1Byte			ConnectionChannelWidthBack;
	u1Byte			ConnectionChannelOffsetBack;
	u1Byte			DualMacScenariosToSet;
	BOOLEAN			bCloseBBAndRFForDMSP;
	BOOLEAN			bChangeToDMDP;
	BOOLEAN			bChangeToDMSP;
	BOOLEAN			bSwitchInProcess;
	u1Byte			JoinAction;
	RT_WLAN_BSS	BssDesc;	
	BOOLEAN			bTmpBssDesc;
	BOOLEAN			bLinkWithNAP;
	BOOLEAN			bRestartAPForMac0ConnectOnDmsp;  
	BOOLEAN			bLinkInProgress;
	BOOLEAN			bDynamicSwitchToDmspInProgress;
	BOOLEAN			bDynamicSwitchToDmspRetry;
	BOOLEAN			bChangeTwoStaConcurrentModeInProgress;
	BOOLEAN			bChangeTwoStaConcurrentModeRetry;
	BOOLEAN			bAutoSelChnl;
	BOOLEAN			bTxPacketBufferColease;
	BOOLEAN			bMacReconfig;
	BOOLEAN			bMacReconfigIsInProgress;
	BOOLEAN			bOnlyMacConfigToDisassembleTxPacketBuffer;
}DUAL_MAC_EASY_CONCURRENT_CONTROL,*PDUAL_MAC_EASY_CONCURRENT_CONTROL;
#endif
typedef	enum _RT_RF_TYPE_DEFINITION
{
	RF_1T2R			= 0,
	RF_2T4R			= 1,
	RF_2T2R			= 2,
	RF_1T1R			= 3,
	RF_2T2R_GREEN	= 4,
	RF_3T3R			= 5,
	RF_4T4R			= 6,
	RF_2T3R			= 7,
	RF_3T4R			= 8,

	RF_MAX_TYPE     = 0xF, // u1Byte
}RT_RF_TYPE_DEF_E;

// 2010/12/27 Move from type.h to here.
typedef enum _BAND_TYPE{
	BAND_ON_2_4G = 0,
	BAND_ON_5G ,
	BAND_ON_BOTH,
	BANDMAX
}BAND_TYPE,*PBAND_TYPE;


typedef struct _PORT_COMMON_INFO
{

	PADAPTER pDefaultAdapter;


	// ================================================================================================
	// Extracted From RT_NDIS_COMMON: pNdisCommon
	// ================================================================================================


	// Handle All Software Timer ---------------------------------------------------------
	RT_SPIN_LOCK		TimerLock; 					// For timer synchronization
	u4Byte				uNumberOfAllocatedTimers;	// Number of Allocated RT_TIMER objects
	u4Byte				uNumberOfReleasedTimers;	// Number of Released RT_TIMER objects
	s4Byte				ActiveTimerCallbackCount;	// Default 1, only 0 when in Halt state
	RT_EVENT			AllTimerCompletedEvent;		// Notification of all timer completion

#if (DEBUG_RESOURCE_TIMER == 1)
	DEBUG_RESOURCE_TIMER_MONITOR	ResourceTimerMonitor[DEBUG_RESOURCE_TIMER_MONITOR_SIZE];	// For Debugging Purposes
#endif
	// -------------------------------------------------------------------------------


	// ================================================================================================


		PPORT_HELPER	pPortHelper;	
	
	// MacId Context Place Holder for Private Data: ------------------------------------
	//	+ Only access this private data inside the module by MacIdGetCommonContext()
	PRIVATE_DATA_ZONE MacIdCommon[HAL_MAC_ID_SIZE_OF_COMMON_CONTEXT];
	// -------------------------------------------------------------------------------

	// ActionTimer Context Place Holder for Private Data: ------------------------------------
	//	+ Only access this private data inside the module by ActionTimerGetCommonContext()
	PRIVATE_DATA_ZONE ActionTimerCommon[ACTION_TIMER_SIZE_OF_COMMON_CONTEXT];
	// -------------------------------------------------------------------------------

	
#if (MULTIPORT_SUPPORT == 1)

	// MultiPort Common Context Place Holder for Private Data: ----------------------------
	//	+ Only access this private data inside the module by MultiPortGetCommonContext()
	PRIVATE_DATA_ZONE MultiPortCommon[MULTIPORT_SIZE_OF_COMMON_CONTEXT];
	// ---------------------------------------------------------------------------


#if (MULTICHANNEL_SUPPORT == 1)

	// MultiChannel Common Context Place Holder for Private Data: ----------------------------
	//	+ Only access this private data inside the module by MultiChannelGetCommonContext()
	PRIVATE_DATA_ZONE MultiChannelCommon[MULTICHANNEL_SIZE_OF_COMMON_CONTEXT];
	// -------------------------------------------------------------------------------
	
#endif
#endif



	WDI_DATA_STRUCT		WdiData;

	PCHANNEL_COMMON_CONTEXT	pChnlCommInfo;

	RT_LIST_ENTRY			TimerResourceList; // Timer resource list for further handling
	u4Byte					uNumberOfInsertedTimerRes; // Number of Timer resource has been inserted for handling
	
} PORT_COMMON_INFO, * PPORT_COMMON_INFO;

typedef enum
{
	RT_ERR_SUCCESS = 0,
	RT_ERR_DRIVER_FAILURE,
	RT_ERR_IO_FAILURE,
	RT_ERR_WI_TIMEOUT,
	RT_ERR_WI_BUSY,
	RT_ERR_BAD_FORMAT,
	RT_ERR_INVALID_DATA,
	RT_ERR_NOT_ENOUGH_SPACE,
	RT_ERR_WRITE_PROTECT,
	RT_ERR_READ_BACK_FAIL,
	RT_ERR_OUT_OF_RANGE
} RT_ERROR_CODE;

typedef struct _RT_PEER_ENTRY {
	BOOLEAN			bUsed;
	u1Byte			uPeerId;
	u2Byte			uPortId;
	u1Byte			PeerAddr[6];
} RT_PEER_ENTRY, *PRT_PEER_ENTRY;


typedef struct _ADAPTER{
	RT_SDIO_DEVICE			NdisSdioDev;
	PRT_NDIS_COMMON		pNdisCommon;

		PRT_NDIS62_COMMON	pNdis62Common;
	
	//=====================================================
	// Please put tx related variables in TX_GENERAL.
	//=====================================================
	TX_GENERAL			txGen;
	//=====================================================

	// MultiPort Architecture ======================================================
	//	- Final Goal: All Adapter's Common Information should be merged into this structure.
	// =======================================================================
	PPORT_COMMON_INFO	pPortCommonInfo;
	// --------------------------------------------------------------------------------


#if (MULTIPORT_SUPPORT == 1)

	// MultiPort Port Context Place Holder for Private Data: ----------------------------
	//	+ Only access this private data inside the module by MultiPortGetPortContext()
	PRIVATE_DATA_ZONE MultiPort[MULTIPORT_SIZE_OF_PORT_CONTEXT];
	// ------------------------------------------------------------------------

#if (MULTICHANNEL_SUPPORT == 1)

	// MultiChannel Port Context Place Holder for Private Data: ---------------------------
	//	+ Only access this private data inside the module by MultiChannelGetPortContext()	
	PRIVATE_DATA_ZONE MultiChannel[MULTICHANNEL_SIZE_OF_PORT_CONTEXT];
	// --------------------------------------------------------------------------
	
#endif
#endif


	BOOLEAN 		bMPMode;
	RT_ERROR_CODE		LastError; // <20130613, Kordan> Only the functions associated with MP records the error code by now.

	RT_NDIS_DBG_CONTEXT	ndisDbgCtx;

	NDIS_INTERRUPT_TYPE  			InterruptType;
	PIO_INTERRUPT_MESSAGE_INFO		MessageInfoTable;


	BOOLEAN 			bIMRDisable;

	BOOLEAN				bvWifiStopBeforeSleep;	
	BOOLEAN				bDriverStopped;
	BOOLEAN				bSurpriseRemoved;
	u4Byte				SurpriseRemovedReason;
	u1Byte    			MaxIRPPengding;
	u1Byte    			TXPacketShiftBytes;
	u1Byte				HWDescHeadLength;
	u1Byte                        Addr_ePHY;


	u2Byte				MAX_NUM_RFD;
	u2Byte				MAX_NUM_RX_DESC;	
	u2Byte				MAX_RECEIVE_BUFFER_SIZE;
	u2Byte				MAX_SUBFRAME_TOTAL_COUNT;

	u1Byte	 			TotalCamEntry;
    u1Byte 				HalfCamEntry;
   	u1Byte 				CamExtApMaxEntery;
   	u1Byte 				CamExtApP2pStartIndex;
   	u1Byte 				CamExtApP2pMaxEntry;
   	u1Byte 				CamExtStaPairwiseKeyPosition;
   	u1Byte 				CamBtStartIndex;
   	u1Byte 				BtHwCamStart;

	u2Byte				RT_TCB_NUM;
	u2Byte				RT_LOCAL_BUF_NUM;
	u2Byte				RT_LOCAL_FW_BUF_NUM;
	u2Byte				RT_TXDESC_NUM;
	u2Byte				RT_TXDESC_NUM_BE_QUEUE;
	u2Byte				MAX_TRANSMIT_BUFFER_SIZE;
	BOOLEAN				bEarlyQueueTimeout;
	//
	// Union of functions disabled. 
	// Each bit indicated one function that is disabled, such as Tx, Rx, IO.
	// See DF_XX_BIT and related operation defined above.
	//
	RT_DF_TYPE			DisabledFunctions;

	HAL_INTERFACE		HalFunc;
	PVOID				HalData;
	PVOID				pHalBusInfo;

	u2Byte				HardwareType;
	u1Byte				EepromAddressSize;
	u1Byte				PermanentAddress[6];
	u1Byte				CurrentAddress[6];

	WIRELESS_MODE		RegOrigWirelessMode;
	WIRELESS_MODE		RegWirelessMode;
	HT_MODE				RegHTMode;
	
	BOOLEAN				bFWReady;
	BOOLEAN				bHWInitReady;	
	BOOLEAN				bSWInitReady;
	BOOLEAN				bInitializeInProgress;
	BOOLEAN				bInitComplete;

//===========================================
	//2 Transmit related variables
	BOOLEAN				bTxLocked;	// For debugging RT_TX_SPINLOCK. Note that! we SHOULD ONLY change it at PlatformXXXSpinLock(). 2005.11.17, by rcnjko.
	VIRTUAL_MEMORY		TcbBuffer;
	u2Byte				NumTcb;
	u2Byte				NumIdleTcb;
	u2Byte				NumTxDesc[MAX_TX_QUEUE];
	u2Byte				AvailableDescToWrite[MAX_TX_QUEUE];
	u2Byte				CurrentTXWritePoint[MAX_TX_QUEUE];
	u2Byte				CurrentTXReadPoint[MAX_TX_QUEUE];
	//=======================================
	// debug use
	u4Byte				sameTxReadPointCnt;
	u2Byte				CurrentTxReadPointBeQLogIndex;
	u2Byte				CurrentTxReadPointBeQLog[10];
	u2Byte				CurrentTxWritePointBeQLog[10];
	u8Byte				updateBeQReadPointTime[10];
	u8Byte				latestUpdatedTxDescTime;
	u4Byte				wrongrwTxpointCnt;
	
	u4Byte				abnormalAvaiDescLogIndex[MAX_TX_QUEUE];
	u2Byte				abnormalCurrentTXWritePoint[MAX_TX_QUEUE][10];
	//=======================================
	RT_LIST_ENTRY		TcbIdleQueue;
	RT_LIST_ENTRY		TcbWaitQueue[MAX_TX_QUEUE];
	u4Byte				TcbWaitQueueCnt[MAX_TX_QUEUE];

	RT_LIST_ENTRY		TcbBusyQueue[MAX_TX_QUEUE];
	RT_LIST_ENTRY		TcbAggrQueue[MAX_TX_QUEUE]; // For A-MSDU aggreagtion, Joseph
	u4Byte				TcbCountInAggrQueue[MAX_TX_QUEUE];
	RT_TX_AGG_COALES_BUF	TcbAggCoalesBuf[MAX_TX_QUEUE];

	u2Byte				NextTxDescToFill[MAX_TX_QUEUE];
	u2Byte				NextTxDescToCheck[MAX_TX_QUEUE];
	u2Byte				nBufInTxDesc[MAX_TX_QUEUE];
	u1Byte				nFragDescUsed;
	
	// For WIN7 Context switch
	LIST_ENTRY			HVLContextLinked;	

	//2 Receive related variables
	BOOLEAN				bRxLocked;	// For debugging RT_RX_SPINLOCK. Note that! we SHOULD ONLY change it at PlatformXXXSpinLock(). 2005.11.17, by rcnjko.
	VIRTUAL_MEMORY		RfdBuffer;
	u2Byte				NumRfd;
	u2Byte				NumIdleRfd;
	u4Byte				NumBusyRfd[MAX_RX_QUEUE];
	u2Byte				NumRxDesc[MAX_RX_QUEUE];
	RT_LIST_ENTRY		RfdIdleQueue;
	RT_LIST_ENTRY		RfdBusyQueue[MAX_RX_QUEUE];
#if( WDI_SUPPORT == TRUE )
	PNDIS_RECEIVE_THROTTLE_PARAMETERS pThrottle;
	BOOLEAN				bFirstMpduOfInterrupt;
#endif
	
	u2Byte				NextRxDescToFill[MAX_RX_QUEUE];
	u2Byte				NextRxDescToCheck[MAX_RX_QUEUE];
	u2Byte				nBufInRxDesc[MAX_RX_QUEUE];
	DEFRAG_ENTRY		DefragArray[MAX_DEFRAG_PEER];
	u2Byte				LowRfdThreshold;
	u4Byte				RcvRefCount;  // number of packets that have not been returned back
	PALIGNED_SHARED_MEMORY	pAMSDU; // Copy subframe of AMSDU into one contineous buffer before indication (Vista only)
	u2Byte				AmsduIndex;


	//2 Transmit local buffer
	u2Byte				NumLocalBuffer;
	u2Byte				NumLocalBufferIdle;
	u2Byte				NumLocalFWBuffer;	// For download Firmware
	u2Byte				NumLocalFWBufferIdle;	//tynli_test
	VIRTUAL_MEMORY		LocalBufferArray;
	VIRTUAL_MEMORY		LocalFWBufferArray;	// For download Firmware
	RT_LIST_ENTRY		LocalBufferQueue;	
	RT_LIST_ENTRY		LocalFWBufferQueue;	// For download Firmware

	//2 Receive local buffer
	pu4Byte				RfdListAddr[MAX_RFD_ARRAY_NUM + 1];
	pu4Byte				RfdVirtualAddr[MAX_RFD_ARRAY_NUM + 1];
#if RX_AGGREGATION
	RT_RFD				RfdTmpArray[MAX_PKT_AGG_NUM];
	RT_LIST_ENTRY		RfdTmpList;
#endif


	//2 Statictics
	RT_TX_STATISTICS	TxStats;
	RT_RX_STATISTICS	RxStats;
	u4Byte			numInterrupt;

	//2 General Templorary Buffer
	VIRTUAL_MEMORY		GenTempBufferArray;		// for General Templorary Buffer
	RT_LIST_ENTRY		GenTempBufferQueue;	
	u4Byte				NumGenTempBufferIdle;
	u1Byte				TempBufferforcoalsece[2000];

	//2 Management Information
	MGNT_INFO			MgntInfo;
	u1Byte				MCList[MAX_MCAST_LIST_NUM][6];
	u4Byte				MCAddrCount;
	RT_WLAN_BSS			bssDescList[MAX_BSS_DESC];
	u4Byte 				AP_EDCA_PARAM[4];
	u4Byte 				STA_EDCA_PARAM[4];

	// MISC.	
	u8Byte				DriverUpTime; // Yves: Driver up time.
	u8Byte				lastscantime;//lastscantime
	u8Byte				LastScanCompleteTime;	// Last scan complete time.
	u8Byte				LastConnectStartIndicationTime;
	u8Byte				LastRoamingStartIndicationTime;
	u8Byte				LastConnectionActionTime;

	// For PnP Working Time Calculation
	BOOLEAN				bCtrlPnPTime;
	LARGE_INTEGER		PnPTotalTime;
	LARGE_INTEGER		PnPIOTime;

	// For HCT test, 2005.07.15, by rcnjko.
	BOOLEAN				bInHctTest;	
	BOOLEAN				bInWFDTest;	
	BOOLEAN				bScanTimeCheck;	
	BOOLEAN				bFixedMacAddr;
	
	BOOLEAN				bReduceImr;
	
	BOOLEAN				bInChaosTest;
	BOOLEAN 			bDisable11ac;

	// For USB IF test, 060505, by rcnjko.
	BOOLEAN				bInUsbIfTest;
	
	//2 System Reset
	RESET_TYPE			ResetProgress;
	u4Byte				ResetCount;
	BOOLEAN				bForcedSilentReset;
	BOOLEAN				bResetInProgress;

	// General Adapter Status
	u4Byte				Status;

	// Tx/Rx LED
	u2Byte				LedTxCnt;
	u2Byte				LedRxCnt;

	//
	// Pointer to the memory block storing pointers to DRV_LOG_POOL_T objects.
	// Each log pool is corresponding to one type of log.
	// Use GET_DRV_LOG_POOL() and SET_DRV_LOG_POOL() to manipulate log pool, 
	// see LogMgnt.c for details.
	//
#if DRV_LOG
	VOID**				ppLogPools; 

#endif

	//2 Power related variables
	BOOLEAN   			bInSetPower;
	BOOLEAN 			bEnterPnpSleep; // Just for S3/S4 !!!
	BOOLEAN 			bWakeFromPnpSleep;	// Just for S3/S4 !!!
	BOOLEAN				bUnloadDriverwhenS3S4;
	BOOLEAN				bDriverIsGoingToUnload;
	BOOLEAN				bHWSecurityInWoL; //by tynli
	BOOLEAN				bDriverIsGoingToPnpSetPowerSleep;
	BOOLEAN				bIntoIPS;
	BOOLEAN				bReceiveCpwmInt;
	BOOLEAN				bDriverShutdown;
	u4Byte				ipsEnterCnt;
	BOOLEAN				bInWoWLANPowerState;
	BOOLEAN				bReInitHW; // record

	// Interrupt debug message	
	u4Byte				handleIntFailCnt;
	u8Byte				lastHandleIntFailTime[10];
	u8Byte				preHandlIntTime;
	u8Byte				curHandleIntTime;
	u4Byte				intLogTimeIndex;
	u8Byte				handleIntTime[10];

	// Tx hang debug info 
	HW_REG_VALUE		txMacReg[MAX_TX_REG_NUM];
	HW_REG_VALUE		txBbReg[MAX_TX_REG_NUM];
	BOOLEAN				bTxHangCheck;
	u1Byte				dropPktByMacIdCnt;
	u8Byte				txHangHwCollectTime;
	u8Byte				firsttxHangHwTime;
	BOOLEAN				bTcbBusyQEmpty[MAX_TX_QUEUE];
	u8Byte				firstTcbSysTime[MAX_TX_QUEUE];
	u4Byte				txOwnCloseTimeIndex[MAX_TX_QUEUE];
	u8Byte				curTxOwnCloseTime[MAX_TX_QUEUE];
	u8Byte				txOwnCloseTime[MAX_TX_QUEUE][10];

	// Rx hang debug info
	HW_REG_VALUE		rxMacReg[MAX_RX_REG_NUM];
	HW_REG_VALUE		rxBbReg[MAX_RX_REG_NUM];
	BOOLEAN				bRxHangCheck;
	u8Byte				rxHangHwCollectTime;

	// Tx/Rx hang debug info
	HW_REG_VALUE		rfReg[MAX_TX_REG_NUM];


	BOOLEAN				bInitByExtPort;
	BOOLEAN				bSilentReseted;
	BOOLEAN				initfinish;

	BOOLEAN				bStartVwifi;

	//Rx reorder related Reference variables	
	u4Byte				rxReorderRefCount;
	u4Byte				rxReorderIndEnterCnt;
	u4Byte				rxReorderIndAllowCnt;
	u4Byte				rxReorderIndRejectCnt[3];

	//2 Interrupt related variables
	u4Byte				IntrTxRefCount;
	u4Byte				IntrRxRefCount;
	u4Byte				IntrCCKRefCount;
#if TCPREORDER_SUPPORT
	u4Byte				IntrTcpSeqRefCount;
#endif

	u4Byte				IntrNBLRefCount;

	u4Byte				IntrInterruptRefCount;
	u4Byte				RxPktPendingTimeoutRefCount;
	
	BOOLEAN				bIntInProgress; // Interrupt handling is in progress
	PlatformSemaphore	InterruptSema;	//For interrupt sync flow control
	

	// Interrupt Thread
	BOOLEAN				bUseThreadHandleInterrupt;
	RT_THREAD			InterruptThread;
	u8Byte				InterruptThreadCnt;
	BOOLEAN				bDPCISRTest;

	//
	// We need to declare the strcute in other place later!!!
	//
	// 2010/12/25 MH Add for _DFS support flag.
	// 2010/12/27 MH Add for Dual Mode switch support flag
	// 2010/12/28 MH Add for Dual Mode smart concurrent support flag
	// 2010/12/30 MH Add WAPI and other fucuter support support flag.	
#ifdef REMOVE_PACK
#pragma pack(1)
#endif
	UINT32		DFSSupport:1;				// 802.11h support
	//UINT32		DualMacSupport:1;			// dual mac switch support
	//UINT32		DualMacSmartConcurrent:1;	// smart concurrent support
	UINT32		FwProcVenCmdSupport:1;		//??
	// 2010/12/30 MH Add to support in the future.
	UINT32		IcVerifyPhase:2;				// FPGA/Test chip/ASIC
	UINT32		FwLoadFromHeader:1;		// From header/read files
	UINT32		InterfaceType:3;				// USB/PCI/PCIE/SDIO/...
	UINT32		DebugPhase:2;				// Free build/chk build/ debug module.
	UINT32		MpSupport:1;				// Normal or MP driver
	UINT32		MsiSupport:2;				// PCIE different interrupt type support traditional/ MIS/ MSI_X based on different PCIE spec
	UINT32		EthSupport:1;				// Ethner simulation switch. for 8715 in the future.or IC verification	
	UINT32		TDLSSupport:1;
#ifdef REMOVE_PACK
#pragma pack()
#endif
	UINT32		NANSupport:2;
	UINT32		P2PSupport:2;
	UINT32		WPSSupport:1;
	UINT32		TXSCSupport:1;
	UINT32		RXSCSupport:1;
	UINT32		RASupport:1;
	UINT32		Reserve:7;	

	//2 92D related variables
	u1Byte 			MacPhyModeFor8192D;
	// dual MAC: 0--Mac0 1--Mac1
	u1Byte			interfaceIndex;
	u1Byte			EarlyMode_Threshold;
	u1Byte			EarlyMode_QueueNum[8]; //The tid from 0--7
	u1Byte			EarlyModebuf[1600];
		
	// 2010/12/27 MH We need to reduce the declareation to prevent occupying too much memory 
	// The better way is to ise the union structure for bit declaration in the future.
	RT_LIST_ENTRY	List;
	//PADAPTER		BuddyAdapter;   
	//BOOLEAN			bMasterOfDMSP;
	//BOOLEAN			bSlaveOfDMSP;

	u1Byte			RegTwoStaConcurrentMode;
	//DUAL_MAC_DMSP_CONTROL		       DualMacDMSPControl;
	//DUM_CTRL_INFO	DumCtrlInfo;
	//DUSC_INFO		DuscInfo;

	//for 92D HW tx retry bug.	// HARDWARE_TYPE_IS_RTL8192D disable by MH
	u1Byte		CurrentFWTxRate;

	PD_T		DM_PDTable;

	u4Byte 		PS_BBRegBackup[PSBBREG_MAX];

	RT_LIST_ENTRY		ListEntry;
	
	u1Byte				ShortcutIndex;	//record entry index of array for shortcut and it's 1 based
	s1Byte				SNForShortcut;
	
	BOOLEAN				bNeedToTriggerLA;
	
	BOOLEAN				bBtFwSupport;

	BOOLEAN				bNromalRQPN;

#if USB_TX_THREAD_ENABLE
	BOOLEAN				bUseUsbTxThread; // Dynamically enable USB Tx thread. 2012.06.18. by tynli.
#endif	

	BOOLEAN				bRemoveTsInRxPath;

	BOOLEAN				bAPChannelInprogressForNewconnected;

	BOOLEAN				bRecvEnterPSForGo; //to indicate P2P client is active or not
	WIRELESS_MODE		BackupWirelessMode;

	//
	// <Roger_DBG> Using following state flag to trace vWiFi and power transaction event for some vWiFi bus BSOD issue.
	// 2013.1213
	//
#if DRV_LOG_REGISTRY
	u4Byte				DrvState;	
	u4Byte				WriteRegRefCount;
	BOOLEAN				bDrvStateError;
#endif

#if WLAN_ETW_SUPPORT
	u4Byte				TxFrameUniqueueID;
	u4Byte				RxFrameUniqueueID;
#endif

	BOOLEAN				bFixBTTdma;
	u4Byte				CPWMTimeoutCount;
	BOOLEAN				bRxPsWorkAround;
	
	RT_THREAD			RxNotifyThread;	

	// Rx queue.
	RT_SINGLE_LIST_HEAD		RxPeerQueue[MAX_PEER_NUM];
	RT_PEER_ENTRY			RxPeerTable[MAX_PEER_NUM];
	u1Byte					RxPeerUsedCount;
	RES_MON_OBJ			ResMonObjWdi;
}ADAPTER,*PADAPTER;

typedef struct _RT_NDIS_DRIVER_CONTEXT	*PRT_NDIS_DRIVER_CONTEXT, RT_NDIS_DRIVER_CONTEXT;

// The Driver(Module) Context in Driver-Wide variables.
typedef	struct	_RT_DRIVER_CONTEXT
{
	RT_NDIS_DRIVER_CONTEXT	NdisContext;	// The Ndis global context

	RT_LIST_ENTRY	AdapterList; // The list of adapters
	RT_SPIN_LOCK	ContextLock; // To protect the content of RT_DRIVER_CONTEXT.
}RT_DRIVER_CONTEXT, *PRT_DRIVER_CONTEXT;

#define	INSERT_GLOBAL_ADAPTER_LIST(__pAdapter)	\
{	\
	PLATFORM_ACQUIRE_RT_SPINLOCK(GlobalRtDriverContext.ContextLock);	\
	RTInsertTailList(&(GlobalRtDriverContext.AdapterList), &((__pAdapter)->ListEntry));	\
	PLATFORM_RELEASE_RT_SPINLOCK(GlobalRtDriverContext.ContextLock);	\
}

#define	REMOVE_GLOBAL_ADAPTER_LIST(__pAdapter)	\
{	\
	PLATFORM_ACQUIRE_RT_SPINLOCK(GlobalRtDriverContext.ContextLock);	\
	RTRemoveEntryList(&((__pAdapter)->ListEntry));	\
	PLATFORM_RELEASE_RT_SPINLOCK(GlobalRtDriverContext.ContextLock);	\
}

extern	RT_DRIVER_CONTEXT	GlobalRtDriverContext;

//----End of Define RT_SPIN_LOCK for all platform.-----//

#endif // #ifndef __INC_TYPEDEF_H