hc
2023-12-06 d38611ca164021d018c1b23eee65bbebc09c63e0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
5201
5202
5203
5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
5294
5295
5296
5297
5298
5299
5300
5301
5302
5303
5304
5305
5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
5327
5328
5329
5330
5331
5332
5333
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343
5344
5345
5346
5347
5348
5349
5350
5351
5352
5353
5354
5355
5356
5357
5358
5359
5360
5361
5362
5363
5364
5365
5366
5367
5368
5369
5370
5371
5372
5373
5374
5375
5376
5377
5378
5379
5380
5381
5382
5383
5384
5385
5386
5387
5388
5389
5390
5391
5392
5393
5394
5395
5396
5397
5398
5399
5400
5401
5402
5403
5404
5405
5406
5407
5408
5409
5410
5411
5412
5413
5414
5415
5416
5417
5418
5419
5420
5421
5422
5423
5424
5425
5426
5427
5428
5429
5430
5431
5432
5433
5434
5435
5436
5437
5438
5439
5440
5441
5442
5443
5444
5445
5446
5447
5448
5449
5450
5451
5452
5453
5454
5455
5456
5457
5458
5459
5460
5461
5462
5463
5464
5465
5466
5467
5468
5469
5470
5471
5472
5473
5474
5475
5476
5477
5478
5479
5480
5481
5482
5483
5484
5485
5486
5487
5488
5489
5490
5491
5492
5493
5494
5495
5496
5497
5498
5499
5500
5501
5502
5503
5504
5505
5506
5507
5508
5509
5510
5511
5512
5513
5514
5515
5516
5517
5518
5519
5520
5521
5522
5523
5524
5525
5526
5527
5528
5529
5530
5531
5532
5533
5534
5535
5536
5537
5538
5539
5540
5541
5542
5543
5544
5545
5546
5547
5548
5549
5550
5551
5552
5553
5554
5555
5556
5557
5558
5559
5560
5561
5562
5563
5564
5565
5566
5567
5568
5569
5570
5571
5572
5573
5574
5575
5576
5577
5578
5579
5580
5581
5582
5583
5584
5585
5586
5587
5588
5589
5590
5591
5592
5593
5594
5595
5596
5597
5598
5599
5600
5601
5602
5603
5604
5605
5606
5607
5608
5609
5610
5611
5612
5613
5614
5615
5616
5617
5618
5619
5620
5621
5622
5623
5624
5625
5626
5627
5628
5629
5630
5631
5632
5633
5634
5635
5636
5637
5638
5639
5640
5641
5642
5643
5644
5645
5646
5647
5648
5649
5650
5651
5652
5653
5654
5655
5656
5657
5658
5659
5660
5661
5662
5663
5664
5665
5666
5667
5668
5669
5670
5671
5672
5673
5674
5675
5676
5677
5678
5679
5680
5681
5682
5683
5684
5685
5686
5687
5688
5689
5690
5691
5692
5693
5694
5695
5696
5697
5698
5699
5700
5701
5702
5703
5704
5705
5706
5707
5708
5709
5710
5711
5712
5713
5714
5715
5716
5717
5718
5719
5720
5721
5722
5723
5724
5725
5726
5727
5728
5729
5730
5731
5732
5733
5734
5735
5736
5737
5738
5739
5740
5741
5742
5743
5744
5745
5746
5747
5748
5749
5750
5751
5752
5753
5754
5755
5756
5757
5758
5759
5760
5761
5762
5763
5764
5765
5766
5767
5768
5769
5770
5771
5772
5773
5774
5775
5776
5777
5778
5779
5780
5781
5782
5783
5784
5785
5786
5787
5788
5789
5790
5791
5792
5793
5794
5795
5796
5797
5798
5799
5800
5801
5802
5803
5804
5805
5806
5807
5808
5809
5810
5811
5812
5813
5814
5815
5816
5817
5818
5819
5820
5821
5822
5823
5824
5825
5826
5827
5828
5829
5830
5831
5832
5833
5834
5835
5836
5837
5838
5839
5840
5841
5842
5843
5844
5845
5846
5847
5848
5849
5850
5851
5852
5853
5854
5855
5856
5857
5858
5859
5860
5861
5862
5863
5864
5865
5866
5867
5868
5869
5870
5871
5872
5873
5874
5875
5876
5877
5878
5879
5880
5881
5882
5883
5884
5885
5886
5887
5888
5889
5890
5891
5892
5893
5894
5895
5896
5897
5898
5899
5900
5901
5902
5903
5904
5905
5906
5907
5908
5909
5910
5911
5912
5913
5914
5915
5916
5917
5918
5919
5920
5921
5922
5923
5924
5925
5926
5927
5928
5929
5930
5931
5932
5933
5934
5935
5936
5937
5938
5939
5940
5941
5942
5943
5944
5945
5946
5947
5948
5949
5950
5951
5952
5953
5954
5955
5956
5957
5958
5959
5960
5961
5962
5963
5964
5965
5966
5967
5968
5969
5970
5971
5972
5973
5974
5975
5976
5977
5978
5979
5980
5981
5982
5983
5984
5985
5986
5987
5988
5989
5990
5991
5992
5993
5994
5995
5996
5997
5998
5999
6000
6001
6002
6003
6004
6005
6006
6007
6008
6009
6010
6011
6012
6013
6014
6015
6016
6017
6018
6019
6020
6021
6022
6023
6024
6025
6026
6027
6028
6029
6030
6031
6032
6033
6034
6035
6036
6037
6038
6039
6040
6041
6042
6043
6044
6045
6046
6047
6048
6049
6050
6051
6052
6053
6054
6055
/*
 * Chip-specific hardware definitions for
 * Broadcom 802.11abg Networking Device Driver
 *
 * Broadcom Proprietary and Confidential. Copyright (C) 2020,
 * All Rights Reserved.
 *
 * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Broadcom;
 * the contents of this file may not be disclosed to third parties,
 * copied or duplicated in any form, in whole or in part, without
 * the prior written permission of Broadcom.
 *
 *
 * <<Broadcom-WL-IPTag/Proprietary:>>
 */
 
#ifndef    _D11_H
#define    _D11_H
 
/*
 * Notes:
 * 1. pre40/pre rev40: corerev < 40
 * 2. pre80/pre rev80: 40 <= corerev < 80
 * 3. rev40/D11AC: 80 > corerev >= 40
 * 4. rev80: corerev >= 80
 */
 
#include <typedefs.h>
#include <hndsoc.h>
#include <sbhnddma.h>
#include <802.11.h>
 
#if defined(BCMDONGLEHOST) || defined(WL_UNITTEST)
typedef struct {
   uint32 pad;
} shmdefs_t;
#else    /* defined(BCMDONGLEHOST)|| defined(WL_UNITTEST) */
#include <d11shm.h>
#ifdef USE_BCMCONF_H
#include <bcmconf.h>
#else
#include <wlc_cfg.h>
#endif
#endif /* !defined(BCMDONGLEHOST)|| !defined(WL_UNITTEST) */
 
#include <d11regs.h>
 
/* This marks the start of a packed structure section. */
#include <packed_section_start.h>
 
/* cpp contortions to concatenate w/arg prescan */
#ifndef    PAD
#define    _PADLINE(line)    pad ## line
#define    _XSTR(line)    _PADLINE(line)
#define    PAD        _XSTR(__LINE__)
#endif
 
#define    D11AC_BCN_TMPL_LEN    640    /**< length of the BCN template area for 11AC */
 
#define LPRS_TMPL_LEN        512    /**< length of the legacy PRS template area */
 
/* RX FIFO numbers */
#define    RX_FIFO            0    /**< data and ctl frames */
#define    RX_FIFO1        1    /**< ctl frames */
#define RX_FIFO2        2    /**< ctl frames */
#define RX_FIFO_NUMBER        3
 
/* TX FIFO numbers using WME Access Classes */
#define    TX_AC_BK_FIFO        0    /**< Access Category Background TX FIFO */
#define    TX_AC_BE_FIFO        1    /**< Access Category Best-Effort TX FIFO */
#define    TX_AC_VI_FIFO        2    /**< Access Class Video TX FIFO */
#define    TX_AC_VO_FIFO        3    /**< Access Class Voice TX FIFO */
#define    TX_BCMC_FIFO        4    /**< Broadcast/Multicast TX FIFO */
#define    TX_ATIM_FIFO        5    /**< TX fifo for ATIM window info */
#define    TX_AC_N_DATA_FIFO    4    /**< Number of legacy Data Fifos (BK, BE, VI, VO) */
 
/* TX FIFO numbers for trigger queues for HE STA only chips (i.e
 * This is valid only for 4369 or similar STA chips that supports
 * a single HE STA connection.
 */
#define    TX_TRIG_BK_FIFO        6    /**< Access Category Background TX FIFO */
#define    TX_TRIG_BE_FIFO        7    /**< Access Category Best-Effort TX FIFO */
#define    TX_TRIG_VI_FIFO        8    /**< Access Class Video TX FIFO */
#define    TX_TRIG_VO_FIFO        9    /**< Access Class Voice TX FIFO */
#define    TX_TRIG_HP_FIFO        10    /**< Access High Priority TX FIFO */
#define    TX_TRIG_N_DATA_FIFO    4    /**< Number of Trigger Data Fifos (BK, BE, VI, VO) */
 
#if defined(WL11AX_TRIGGERQ) && !defined(WL11AX_TRIGGERQ_DISABLED)
#define IS_TRIG_FIFO(fifo) \
   (((fifo) >= TX_TRIG_BK_FIFO) && ((fifo) < (TX_TRIG_BK_FIFO + TX_TRIG_N_DATA_FIFO)))
#else
#define IS_TRIG_FIFO(fifo) FALSE
#endif /* defined(WL11AX_TRIGGERQ) && !defined(WL11AX_TRIGGERQ_DISABLED) */
 
#define IS_AC_FIFO(fifo) \
   ((fifo) < (TX_AC_BK_FIFO + TX_AC_N_DATA_FIFO))
 
/** Legacy TX FIFO numbers */
#define    TX_DATA_FIFO        TX_AC_BE_FIFO
#define    TX_CTL_FIFO        TX_AC_VO_FIFO
 
/** Trig TX FIFO numbers */
#define    TX_TRIG_DATA_FIFO    TX_TRIG_BE_FIFO
#define    TX_TRIG_CTL_FIFO    TX_TRIG_VO_FIFO
 
/* Extended FIFOs for corerev >= 64 */
#define TX_FIFO_6        6
#define TX_FIFO_7        7
#define TX_FIFO_16        16
#define TX_FIFO_23        23
#define TX_FIFO_25        25
 
#define TX_FIFO_EXT_START    TX_FIFO_6    /* Starting index of extendied HW TX FIFOs */
#define TX_FIFO_MU_START    8        /* index at which MU TX FIFOs start */
 
#define D11REG_IHR_WBASE    0x200
#define D11REG_IHR_BASE        (D11REG_IHR_WBASE << 1)
 
#define    PIHR_BASE    0x0400        /**< byte address of packed IHR region */
 
/* biststatus */
#define    BT_DONE        (1U << 31)    /**< bist done */
#define    BT_B2S        (1 << 30)    /**< bist2 ram summary bit */
 
/* DMA intstatus and intmask */
#define    I_PC        (1 << 10)    /**< pci descriptor error */
#define    I_PD        (1 << 11)    /**< pci data error */
#define    I_DE        (1 << 12)    /**< descriptor protocol error */
#define    I_RU        (1 << 13)    /**< receive descriptor underflow */
#define    I_RO        (1 << 14)    /**< receive fifo overflow */
#define    I_XU        (1 << 15)    /**< transmit fifo underflow */
#define    I_RI        (1 << 16)    /**< receive interrupt */
#define    I_XI        (1 << 24)    /**< transmit interrupt */
 
/* interrupt receive lazy */
#define    IRL_TO_MASK        0x00ffffff    /**< timeout */
#define    IRL_FC_MASK        0xff000000    /**< frame count */
#define    IRL_FC_SHIFT        24        /**< frame count */
#define    IRL_DISABLE        0x01000000    /**< Disabled value: int on 1 frame, zero time */
 
/** for correv >= 80. prev rev uses bit 21 */
#define    MCTL_BCNS_PROMISC_SHIFT    21
/** for correv < 80. prev rev uses bit 20 */
#define    MCTL_BCNS_PROMISC_SHIFT_LT80    20
 
/* maccontrol register */
#define    MCTL_GMODE        (1U << 31)
#define    MCTL_DISCARD_PMQ    (1 << 30)
#define    MCTL_DISCARD_TXSTATUS    (1 << 29)
#define    MCTL_TBTT_HOLD        (1 << 28)
#define    MCTL_CLOSED_NETWORK    (1 << 27)
#define    MCTL_WAKE        (1 << 26)
#define    MCTL_HPS        (1 << 25)
#define    MCTL_PROMISC        (1 << 24)
#define    MCTL_KEEPBADFCS        (1 << 23)
#define    MCTL_KEEPCONTROL    (1 << 22)
#define    MCTL_BCNS_PROMISC    (1 << MCTL_BCNS_PROMISC_SHIFT)
#define    MCTL_BCNS_PROMISC_LT80    (1 << MCTL_BCNS_PROMISC_SHIFT_LT80)
#define    MCTL_NO_TXDMA_LAST_PTR    (1 << 20)    /** for correv >= 85 */
#define    MCTL_LOCK_RADIO        (1 << 19)
#define    MCTL_AP            (1 << 18)
#define    MCTL_INFRA        (1 << 17)
#define    MCTL_BIGEND        (1 << 16)
#define    MCTL_DISABLE_CT        (1 << 14)   /** for corerev >= 83.1 */
#define    MCTL_GPOUT_SEL_MASK    (3 << 14)
#define    MCTL_GPOUT_SEL_SHIFT    14
#define    MCTL_EN_PSMDBG        (1 << 13)
#define    MCTL_IHR_EN        (1 << 10)
#define    MCTL_SHM_UPPER        (1 <<  9)
#define    MCTL_SHM_EN        (1 <<  8)
#define    MCTL_PSM_JMP_0        (1 <<  2)
#define    MCTL_PSM_RUN        (1 <<  1)
#define    MCTL_EN_MAC        (1 <<  0)
 
/* maccontrol1 register */
#define MCTL1_GCPS            (1u << 0u)
#define MCTL1_EGS_MASK            0x0000c000
#define MCTL1_EGS_SHIFT            14u
#define MCTL1_AVB_ENABLE        (1u << 1u)
#define MCTL1_GPIOSEL_SHIFT        8u
#define MCTL1_GPIOSEL            (0x3F)
#define MCTL1_GPIOSEL_MASK        (MCTL1_GPIOSEL << MCTL1_GPIOSEL_SHIFT)
/* Select MAC_SMPL_CPTR debug data that is placed in pc<7:1> & ifs_gpio_out<8:0> GPIOs */
#define MCTL1_GPIOSEL_TSF_PC_IFS(_corerev)    (D11REV_GE(_corerev, 85) ? 0x3b : 0x36)
#define MCTL1_AVB_TRIGGER        (1u << 2u)
#define MCTL1_THIRD_AXI1_FOR_PSM    (1u << 3u)
#define MCTL1_AXI1_FOR_RX        (1u << 4u)
#define MCTL1_TXDMA_ENABLE_PASS        (1u << 5u)
/* SampleCollectPlayCtrl */
#define SC_PLAYCTRL_MASK_ENABLE        (1u << 8u)
#define SC_PLAYCTRL_TRANS_MODE        (1u << 6u)
#define SC_PLAYCTRL_SRC_SHIFT        3u
#define SC_PLAYCTRL_SRC_MASK        (3u << SC_PLAYCTRL_SRC_SHIFT)
#define SC_PLAYCTRL_SRC_PHY_DBG        (3u << SC_PLAYCTRL_SRC_SHIFT)
#define SC_PLAYCTRL_SRC_GPIO_OUT    (2u << SC_PLAYCTRL_SRC_SHIFT)
#define SC_PLAYCTRL_SRC_GPIO_IN        (1u << SC_PLAYCTRL_SRC_SHIFT)
#define SC_PLAYCTRL_SRC_PHY_SMPL    (0u << SC_PLAYCTRL_SRC_SHIFT)
#define SC_PLAYCTRL_STOP        (1u << 2u)
#define SC_PLAYCTRL_PAUSE        (1u << 1u)
#define SC_PLAYCTRL_START        (1u << 0u)
/* SCPortalSel fields */
#define SC_PORTAL_SEL_AUTO_INCR        (1u << 15u)    /* Autoincr */
#define SC_PORTAL_SEL_STORE_MASK    (0u << 5u)    /* Bits 14:5 SCStoreMask15to0 */
#define SC_PORTAL_SEL_MATCH_MASK    (4u << 5u)    /* Bits 14:5 SCMatchMask15to0 */
#define SC_PORTAL_SEL_MATCH_VALUE    (8u << 5u)    /* Bits 14:5 SCMatchValue15to0 */
#define SC_PORTAL_SEL_TRIGGER_MASK    (12u << 0u)    /* Bits 4:0 SCTriggerMask15to0 */
#define SC_PORTAL_SEL_TRIGGER_VALUE    (16u << 0u)    /* Bits 4:0 SCTriggerValue15to0 */
#define SC_PORTAL_SEL_TRANS_MASK    (20u << 0u)    /* Bits 4:0 SCTransMask15to0 */
 
/* GpioOut register */
#define MGPIO_OUT_RXQ1_IFIFO_CNT_MASK    0x1fc0u
#define MGPIO_OUT_RXQ1_IFIFO_CNT_SHIFT    6u
 
#define MAC_RXQ1_IFIFO_CNT_ADDR      0x26u
#define MAC_RXQ1_IFIFO_MAXLEN      3u
 
/* maccommand register */
#define    MCMD_BCN0VLD        (1 <<  0)
#define    MCMD_BCN1VLD        (1 <<  1)
#define    MCMD_DIRFRMQVAL        (1 <<  2)
#define    MCMD_CCA        (1 <<  3)
#define    MCMD_BG_NOISE        (1 <<  4)
#define    MCMD_SKIP_SHMINIT    (1 <<  5)    /**< only used for simulation */
#define MCMD_SLOWCAL        (1 <<  6)
#define MCMD_SAMPLECOLL        MCMD_SKIP_SHMINIT    /**< reuse for sample collect */
#define MCMD_IF_DOWN        (1 << 8 )    /**< indicate interface is going down  */
#define MCMD_TOF        (1 << 9) /**< wifi ranging processing in ucode for rxd frames */
#define MCMD_TSYNC        (1 << 10) /**< start timestamp sync process in ucode */
#define MCMD_RADIO_DOWN        (1 << 11) /**< radio down by ucode */
#define MCMD_RADIO_UP        (1 << 12) /**< radio up by ucode */
#define MCMD_TXPU        (1 << 13) /**< txpu control by ucode */
 
/* macintstatus/macintmask */
#define    MI_MACSSPNDD     (1 <<  0)    /**< MAC has gracefully suspended */
#define    MI_BCNTPL        (1 <<  1)    /**< beacon template available */
#define    MI_TBTT          (1 <<  2)    /**< TBTT indication */
#define    MI_BCNSUCCESS    (1 <<  3)    /**< beacon successfully tx'd */
#define    MI_BCNCANCLD     (1 <<  4)    /**< beacon canceled (IBSS) */
#define    MI_ATIMWINEND    (1 <<  5)    /**< end of ATIM-window (IBSS) */
#define    MI_PMQ           (1 <<  6)    /**< PMQ entries available */
#define    MI_ALTTFS        (1 <<  7)    /**< TX status interrupt for ARM offloads */
#define    MI_NSPECGEN_1    (1 <<  8)    /**< non-specific gen-stat bits that are set by PSM */
#define    MI_MACTXERR      (1 <<  9)    /**< MAC level Tx error */
#define MI_PMQERR        (1 << 10)
#define    MI_PHYTXERR      (1 << 11)    /**< PHY Tx error */
#define    MI_PME           (1 << 12)    /**< Power Management Event */
#define    MI_GP0           (1 << 13)    /**< General-purpose timer0 */
#define    MI_GP1           (1 << 14)    /**< General-purpose timer1 */
#define    MI_DMAINT        (1 << 15)    /**< (ORed) DMA-interrupts */
#define    MI_TXSTOP        (1 << 16)    /**< MAC has completed a TX FIFO Suspend/Flush */
#define    MI_CCA           (1 << 17)    /**< MAC has completed a CCA measurement */
#define    MI_BG_NOISE      (1 << 18)    /**< MAC has collected background noise samples */
#define    MI_DTIM_TBTT     (1 << 19)    /**< MBSS DTIM TBTT indication */
#define MI_PRQ           (1 << 20)    /**< Probe response queue needs attention */
#define    MI_HEB           (1 << 21)    /**< HEB (Hardware Event Block) interrupt - 11ax cores */
#define    MI_BT_RFACT_STUCK    (1 << 22)    /**< MAC has detected invalid BT_RFACT pin,
                        * valid when rev < 15
                        */
#define MI_TTTT          (1 << 22)    /**< Target TIM Transmission Time,
                        * valid in rev = 26/29, or rev >= 42
                        */
#define    MI_BT_PRED_REQ   (1 << 23)    /**< MAC requested driver BTCX predictor calc */
#define    MI_BCNTRIM_RX     (1 << 24)    /**< PSM received a partial beacon */
#define MI_P2P           (1 << 25)    /**< WiFi P2P interrupt */
#define MI_DMATX         (1 << 26)    /**< MAC new frame ready */
#define MI_TSSI_LIMIT    (1 << 27)    /**< Tssi Limit Reach, TxIdx=0/127 Interrupt */
#define MI_HWACI_NOTIFY  (1 << 27)    /**< HWACI detects ACI, Apply Mitigation settings */
#define MI_RFDISABLE     (1 << 28)    /**< MAC detected a change on RF Disable input
                        * (corerev >= 10)
                        */
#define    MI_TFS           (1 << 29)    /**< MAC has completed a TX (corerev >= 5) */
#define    MI_LEGACY_BUS_ERROR    (1 << 30)    /**< uCode indicated bus error */
#define    MI_TO            (1U << 31)    /**< general purpose timeout (corerev >= 3) */
 
#define MI_RXOV                 MI_NSPECGEN_1   /**< rxfifo overflow interrupt */
 
/* macintstatus_ext/macintmask_ext */
#define    MI_BUS_ERROR        (1U << 0u)    /**< uCode indicated bus error */
#define    MI_VCOPLL        (1U << 1u)    /**< uCode indicated PLL lock issue */
#define    MI_EXT_PS_CHG        (1U << 2u)    /**< Power state is changing (PS 0 <-> 1) */
#define MI_DIS_ULOFDMA        (1U << 3u)    /**< ucode indicated disabling ULOFDMA request */
#define    MI_EXT_PM_OFFLOAD    (1U << 4u)    /**< PM offload */
#define MI_OBSS_INTR        (1U << 5u)    /**< OBSS detection interrupt */
#define MI_SENSORC_CX_REQ    (1U << 6u)    /**< SensorC Mitigation Request interrupt */
#define MI_RLL_NAV_HOF        (1U << 7u)    /**< RLLW Switch */
 
#define MI_EXT_TXE_SHARED_ERR  (1U << 28u)     /* Error event in blocks inside TXE shared
                       * (BMC/AQM/AQM-DMA/MIF)
                       */
 
/* Mac capabilities registers */
#define    MCAP_TKIPMIC        0x80000000    /**< TKIP MIC hardware present */
#define    MCAP_TKIPPH2KEY        0x40000000    /**< TKIP phase 2 key hardware present */
#define    MCAP_BTCX        0x20000000    /**< BT coexistence hardware and pins present */
#define    MCAP_MBSS        0x10000000    /**< Multi-BSS hardware present */
#define    MCAP_RXFSZ_MASK        0x0ff80000    /**< Rx fifo size in blocks (revid >= 16) */
#define    MCAP_RXFSZ_SHIFT    19
#define    MCAP_NRXQ_MASK        0x00070000    /**< Max Rx queues supported - 1 */
#define    MCAP_NRXQ_SHIFT        16
#define    MCAP_UCMSZ_MASK        0x0000e000    /**< Ucode memory size */
#define    MCAP_UCMSZ_3K3        0        /**< 3328 Words Ucode memory, in unit of 50-bit */
#define    MCAP_UCMSZ_4K        1        /**< 4096 Words Ucode memory */
#define    MCAP_UCMSZ_5K        2        /**< 5120 Words Ucode memory */
#define    MCAP_UCMSZ_6K        3        /**< 6144 Words Ucode memory */
#define    MCAP_UCMSZ_8K        4        /**< 8192 Words Ucode memory */
#define    MCAP_UCMSZ_SHIFT    13
#define    MCAP_TXFSZ_MASK        0x00000ff8    /**< Tx fifo size (* 512 bytes) */
#define    MCAP_TXFSZ_SHIFT    3
#define    MCAP_NTXQ_MASK        0x00000007    /**< Max Tx queues supported - 1 */
#define    MCAP_NTXQ_SHIFT        0
 
#define    MCAP_BTCX_SUP(corerev)    (MCAP_BTCX)
 
#define    MCAP_UCMSZ_TYPES    8        /**< different Ucode memory size types */
 
/* machwcap1 */
#define    MCAP1_ERC_MASK        0x00000001    /**< external radio coexistence */
#define    MCAP1_ERC_SHIFT        0
#define    MCAP1_SHMSZ_MASK    0x0000000e    /**< shm size (corerev >= 16) */
#define    MCAP1_SHMSZ_SHIFT    1
#define MCAP1_SHMSZ_1K        0        /**< 1024 words in unit of 32-bit */
#define MCAP1_SHMSZ_2K        1        /**< 1536 words in unit of 32-bit */
#define MCAP1_NUMMACCHAINS    0x00003000    /**< Indicates one less than the
                           number of MAC Chains in the MAC.
                           */
#define MCAP1_NUMMACCHAINS_SHIFT    12
#define MCAP1_RXBLMAX_MASK    0x1800000u
#define MCAP1_RXBLMAX_SHIFT    23u
#define MCAP1_NUM_HEB_MASK    0xE0000000u
#define MCAP1_NUM_HEB_SHIFT    29u
#define MCAP1_NUM_HEB_FACTOR    3u
#define MCAP1_CT_CAPABLE_SHIFT    17
 
/* BTCX control */
#define BTCX_CTRL_EN        0x0001    /**< Enable BTCX module */
#define BTCX_CTRL_SW        0x0002    /**< Enable software override */
#define BTCX_CTRL_DSBLBTCXOUT    0x8000 /* Disable txconf/prisel signal output from btcx module */
 
#define BTCX_CTRL_PRI_POL    0x0080  /* Invert prisel polarity */
#define BTCX_CTRL_TXC_POL    0x0020  /* Invert txconf polarity */
 
#define SW_PRI_ON        1    /* switch prisel polarity */
#define SW_TXC_ON        2    /* switch txconf polarity */
 
/* BTCX status */
#define BTCX_STAT_RA        0x0001    /**< RF_ACTIVE state */
 
/* BTCX transaction control */
#define BTCX_TRANS_ANTSEL    0x0040    /**< ANTSEL output */
#define BTCX_TRANS_TXCONF    0x0080    /**< TX_CONF output */
 
/* pmqhost data */
#define    PMQH_DATA_MASK        0xffff0000    /**< data entry of head pmq entry */
#define    PMQH_BSSCFG        0x00100000    /**< PM entry for BSS config */
#define    PMQH_PMOFF        0x00010000    /**< PM Mode OFF: power save off */
#define    PMQH_PMON        0x00020000    /**< PM Mode ON: power save on */
#define    PMQH_PMPS        0x00200000    /**< PM Mode PRETEND */
#define    PMQH_DASAT        0x00040000    /**< Dis-associated or De-authenticated */
#define    PMQH_ATIMFAIL        0x00080000    /**< ATIM not acknowledged */
#define    PMQH_DEL_ENTRY        0x00000001    /**< delete head entry */
#define    PMQH_DEL_MULT        0x00000002    /**< delete head entry to cur read pointer -1 */
#define    PMQH_OFLO        0x00000004    /**< pmq overflow indication */
#define    PMQH_NOT_EMPTY        0x00000008    /**< entries are present in pmq */
 
/* phydebug (corerev >= 3) */
#define    PDBG_CRS        (1 << 0)  /**< phy is asserting carrier sense */
#define    PDBG_TXA        (1 << 1)  /**< phy is taking xmit byte from mac this cycle */
#define    PDBG_TXF        (1 << 2)  /**< mac is instructing the phy to transmit a frame */
#define    PDBG_TXE        (1 << 3)  /**< phy is signaling a transmit Error to the mac */
#define    PDBG_RXF        (1 << 4)  /**< phy detected the end of a valid frame preamble */
#define    PDBG_RXS        (1 << 5)  /**< phy detected the end of a valid PLCP header */
#define    PDBG_RXFRG        (1 << 6)  /**< rx start not asserted */
#define    PDBG_RXV        (1 << 7)  /**< mac is taking receive byte from phy this cycle */
#define    PDBG_RFD        (1 << 16) /**< RF portion of the radio is disabled */
 
/* objaddr register */
#define    OBJADDR_UCM_SEL        0x00000000
#define    OBJADDR_SHM_SEL        0x00010000
#define    OBJADDR_SCR_SEL        0x00020000
#define    OBJADDR_IHR_SEL        0x00030000
#define    OBJADDR_RCMTA_SEL    0x00040000
#define    OBJADDR_AMT_SEL        0x00040000
#define    OBJADDR_SRCHM_SEL    0x00060000
#define    OBJADDR_KEYTBL_SEL    0x000c0000
#define    OBJADDR_HEB_SEL        0x00120000
#define    OBJADDR_TXDC_TBL_SEL    0x00140000
#define    OBJADDR_TXDC_RIB_SEL    0x00150000
#define    OBJADDR_FCBS_SEL    0x00160000
#define    OBJADDR_LIT_SEL        0x00170000
#define    OBJADDR_LIB_SEL        0x00180000
#define    OBJADDR_WINC        0x01000000
#define    OBJADDR_RINC        0x02000000
#define    OBJADDR_AUTO_INC    0x03000000
/* SHM/SCR/IHR/SHMX/SCRX/IHRX allow 2 bytes read/write, else only 4 bytes */
#define    OBJADDR_2BYTES_ACCESS(sel)    \
   (((sel & 0x70000) == OBJADDR_SHM_SEL) || \
   ((sel & 0x70000) == OBJADDR_SCR_SEL) || \
   ((sel & 0x70000) == OBJADDR_IHR_SEL))
 
/* objdata register */
#define    OBJDATA_WR_COMPLT    0x00000001
 
/* frmtxstatus */
#define    TXS_V            (1 << 0)    /**< valid bit */
 
#define    TXS_STATUS_MASK        0xffff
/* sw mask to map txstatus for corerevs <= 4 to be the same as for corerev > 4 */
#define    TXS_COMPAT_MASK        0x3
#define    TXS_COMPAT_SHIFT    1
#define    TXS_FID_MASK        0xffff0000
#define    TXS_FID_SHIFT        16
 
/* frmtxstatus2 */
#define    TXS_SEQ_MASK        0xffff
#define    TXS_PTX_MASK        0xff0000
#define    TXS_PTX_SHIFT        16
#define    TXS_MU_MASK        0x01000000
#define    TXS_MU_SHIFT        24
 
/* clk_ctl_st, corerev >= 17 */
#define CCS_ERSRC_REQ_D11PLL    0x00000100    /**< d11 core pll request */
#define CCS_ERSRC_REQ_PHYPLL    0x00000200    /**< PHY pll request */
#define CCS_ERSRC_REQ_PTMPLL    0x00001000    /* PTM clock request */
#define CCS_ERSRC_AVAIL_D11PLL    0x01000000    /**< d11 core pll available */
#define CCS_ERSRC_AVAIL_PHYPLL    0x02000000    /**< PHY pll available */
#define CCS_ERSRC_AVAIL_PTMPLL    0x10000000    /**< PHY pll available */
 
/* tsf_cfprep register */
#define    CFPREP_CBI_MASK        0xffffffc0
#define    CFPREP_CBI_SHIFT    6
#define    CFPREP_CFPP        0x00000001
 
/* receive fifo control */
#define    RFC_FR            (1 << 0)    /**< frame ready */
#define    RFC_DR            (1 << 1)    /**< data ready */
 
/* tx fifo sizes for corerev >= 9 */
/* tx fifo sizes values are in terms of 256 byte blocks */
#define TXFIFOCMD_RESET_MASK    (1 << 15)    /**< reset */
#define TXFIFOCMD_FIFOSEL_SHIFT    8        /**< fifo */
#define TXFIFOCMD_FIFOSEL_SET(val)    ((val & 0x7) << TXFIFOCMD_FIFOSEL_SHIFT)    /* fifo */
#define TXFIFOCMD_FIFOSEL_GET(val)    ((val >> TXFIFOCMD_FIFOSEL_SHIFT) & 0x7)    /* fifo */
#define TXFIFO_FIFOTOP_SHIFT    8        /**< fifo start */
 
#define TXFIFO_FIFO_START(def, def1)    ((def & 0xFF) | ((def1 & 0xFF) << 8))
#define TXFIFO_FIFO_END(def, def1)    (((def & 0xFF00) >> 8) | (def1 & 0xFF00))
 
/* Must redefine to 65 for 16 MBSS */
#ifdef WLLPRS
#define TXFIFO_START_BLK16    (65+16)    /**< Base address + 32 * 512 B/P + 8 * 512 11g P */
#else /* WLLPRS */
#define TXFIFO_START_BLK16    65    /**< Base address + 32 * 512 B/P */
#endif /* WLLPRS */
#define TXFIFO_START_BLK    6    /**< Base address + 6 * 256 B */
#define TXFIFO_START_BLK_NIN    7    /**< Base address + 6 * 256 B */
 
#define TXFIFO_AC_SIZE_PER_UNIT    512    /**< one unit corresponds to 512 bytes */
 
#define MBSS16_TEMPLMEM_MINBLKS    65    /**< one unit corresponds to 256 bytes */
 
/* phy versions, PhyVersion:Revision field */
#define    PV_AV_MASK        0xf000        /**< analog block version */
#define    PV_AV_SHIFT        12        /**< analog block version bitfield offset */
#define    PV_PT_MASK        0x0f00        /**< phy type */
#define    PV_PT_SHIFT        8        /**< phy type bitfield offset */
#define    PV_PV_MASK        0x00ff        /**< phy version */
#define    PHY_TYPE(v)        ((v & PV_PT_MASK) >> PV_PT_SHIFT)
 
/* phy types, PhyVersion:PhyType field */
#ifndef USE_BCMCONF_H
#define    PHY_TYPE_A        0    /**< A-Phy value */
#define    PHY_TYPE_B        1    /**< B-Phy value */
#define    PHY_TYPE_G        2    /**< G-Phy value */
#define    PHY_TYPE_N        4    /**< N-Phy value */
/* #define    PHY_TYPE_LP        5 */    /**< LP-Phy value */
/* #define    PHY_TYPE_SSN        6 */    /**< SSLPN-Phy value */
#define    PHY_TYPE_HT        7    /**< 3x3 HTPhy value */
#define    PHY_TYPE_LCN        8    /**< LCN-Phy value */
#define    PHY_TYPE_LCNXN        9    /**< LCNXN-Phy value */
#define    PHY_TYPE_LCN40        10    /**< LCN40-Phy value */
#define    PHY_TYPE_AC        11    /**< AC-Phy value */
#define    PHY_TYPE_LCN20        12    /**< LCN20-Phy value */
#define    PHY_TYPE_HE        13    /**< HE-Phy value */
#define    PHY_TYPE_NULL        0xf    /**< Invalid Phy value */
#endif /* USE_BCMCONF_H */
 
/* analog types, PhyVersion:AnalogType field */
#define    ANA_11G_018        1
#define    ANA_11G_018_ALL        2
#define    ANA_11G_018_ALLI    3
#define    ANA_11G_013        4
#define    ANA_11N_013        5
#define    ANA_11LP_013        6
 
/** 802.11a PLCP header def */
typedef struct ofdm_phy_hdr ofdm_phy_hdr_t;
BWL_PRE_PACKED_STRUCT struct ofdm_phy_hdr {
   uint8    rlpt[3];    /**< rate, length, parity, tail */
   uint16    service;
   uint8    pad;
} BWL_POST_PACKED_STRUCT;
 
#define    D11A_PHY_HDR_GRATE(phdr)    ((phdr)->rlpt[0] & 0x0f)
#define    D11A_PHY_HDR_GRES(phdr)        (((phdr)->rlpt[0] >> 4) & 0x01)
#define    D11A_PHY_HDR_GLENGTH(phdr)    (((*((uint32 *)((phdr)->rlpt))) >> 5) & 0x0fff)
#define    D11A_PHY_HDR_GPARITY(phdr)    (((phdr)->rlpt[3] >> 1) & 0x01)
#define    D11A_PHY_HDR_GTAIL(phdr)    (((phdr)->rlpt[3] >> 2) & 0x3f)
 
/** rate encoded per 802.11a-1999 sec 17.3.4.1 */
#define    D11A_PHY_HDR_SRATE(phdr, rate)        \
   ((phdr)->rlpt[0] = ((phdr)->rlpt[0] & 0xf0) | ((rate) & 0xf))
/** set reserved field to zero */
#define    D11A_PHY_HDR_SRES(phdr)        ((phdr)->rlpt[0] &= 0xef)
/** length is number of octets in PSDU */
#define    D11A_PHY_HDR_SLENGTH(phdr, length)    \
   (*(uint32 *)((phdr)->rlpt) = *(uint32 *)((phdr)->rlpt) | \
   (((length) & 0x0fff) << 5))
/** set the tail to all zeros */
#define    D11A_PHY_HDR_STAIL(phdr)    ((phdr)->rlpt[3] &= 0x03)
 
#define    D11A_PHY_HDR_LEN_L    3    /**< low-rate part of PLCP header */
#define    D11A_PHY_HDR_LEN_R    2    /**< high-rate part of PLCP header */
 
#define    D11A_PHY_TX_DELAY    (2)    /**< 2.1 usec */
 
#define    D11A_PHY_HDR_TIME    (4)    /**< low-rate part of PLCP header */
#define    D11A_PHY_PRE_TIME    (16)
#define    D11A_PHY_PREHDR_TIME    (D11A_PHY_PRE_TIME + D11A_PHY_HDR_TIME)
 
/** 802.11b PLCP header def */
typedef struct cck_phy_hdr cck_phy_hdr_t;
BWL_PRE_PACKED_STRUCT struct cck_phy_hdr {
   uint8    signal;
   uint8    service;
   uint16    length;
   uint16    crc;
} BWL_POST_PACKED_STRUCT;
 
#define    D11B_PHY_HDR_LEN    6
 
#define    D11B_PHY_TX_DELAY    (3)    /**< 3.4 usec */
 
#define    D11B_PHY_LHDR_TIME    (D11B_PHY_HDR_LEN << 3)
#define    D11B_PHY_LPRE_TIME    (144)
#define    D11B_PHY_LPREHDR_TIME    (D11B_PHY_LPRE_TIME + D11B_PHY_LHDR_TIME)
 
#define    D11B_PHY_SHDR_TIME    (D11B_PHY_LHDR_TIME >> 1)
#define    D11B_PHY_SPRE_TIME    (D11B_PHY_LPRE_TIME >> 1)
#define    D11B_PHY_SPREHDR_TIME    (D11B_PHY_SPRE_TIME + D11B_PHY_SHDR_TIME)
 
#define    D11B_PLCP_SIGNAL_LOCKED    (1 << 2)
#define    D11B_PLCP_SIGNAL_LE    (1 << 7)
 
/* AMPDUXXX: move to ht header file once it is ready: Mimo PLCP */
#define MIMO_PLCP_MCS_MASK    0x7f    /**< mcs index */
#define MIMO_PLCP_40MHZ        0x80    /**< 40 Hz frame */
#define MIMO_PLCP_AMPDU        0x08    /**< ampdu */
 
#define WLC_GET_CCK_PLCP_LEN(plcp) (plcp[4] + (plcp[5] << 8))
#define WLC_GET_MIMO_PLCP_LEN(plcp) (plcp[1] + (plcp[2] << 8))
#define WLC_SET_MIMO_PLCP_LEN(plcp, len) \
   plcp[1] = len & 0xff; plcp[2] = ((len >> 8) & 0xff);
 
#define WLC_SET_MIMO_PLCP_AMPDU(plcp) (plcp[3] |= MIMO_PLCP_AMPDU)
#define WLC_CLR_MIMO_PLCP_AMPDU(plcp) (plcp[3] &= ~MIMO_PLCP_AMPDU)
#define WLC_IS_MIMO_PLCP_AMPDU(plcp) (plcp[3] & MIMO_PLCP_AMPDU)
 
/**
 * The dot11a PLCP header is 5 bytes.  To simplify the software (so that we don't need eg different
 * tx DMA headers for 11a and 11b), the PLCP header has padding added in the ucode.
 */
#define    D11_PHY_HDR_LEN    6u
 
/** For the AC phy PLCP is 12 bytes and not all bytes are used for all the modulations */
#define D11AC_PHY_HDR_LEN    12
#define D11AC_PHY_VHT_PLCP_OFFSET    0
#define D11AC_PHY_HTMM_PLCP_OFFSET    0
#define D11AC_PHY_HTGF_PLCP_OFFSET    3
#define D11AC_PHY_OFDM_PLCP_OFFSET    3
#define D11AC_PHY_CCK_PLCP_OFFSET    6
#define D11AC_PHY_BEACON_PLCP_OFFSET    0
 
#define D11_PHY_RXPLCP_LEN(rev)        (D11_PHY_HDR_LEN)
#define D11_PHY_RXPLCP_OFF(rev)        (0)
 
/** TX descriptor - pre40 */
typedef struct d11txh_pre40 d11txh_pre40_t;
BWL_PRE_PACKED_STRUCT struct d11txh_pre40 {
   uint16    MacTxControlLow;        /* 0x0 */
   uint16    MacTxControlHigh;        /* 0x1 */
   uint16    MacFrameControl;        /* 0x2 */
   uint16    TxFesTimeNormal;        /* 0x3 */
   uint16    PhyTxControlWord;        /* 0x4 */
   uint16    PhyTxControlWord_1;        /* 0x5 */
   uint16    PhyTxControlWord_1_Fbr;        /* 0x6 */
   uint16    PhyTxControlWord_1_Rts;        /* 0x7 */
   uint16    PhyTxControlWord_1_FbrRts;    /* 0x8 */
   uint16    MainRates;            /* 0x9 */
   uint16    XtraFrameTypes;            /* 0xa */
   uint8    IV[16];                /* 0x0b - 0x12 */
   uint8    TxFrameRA[6];            /* 0x13 - 0x15 */
   uint16    TxFesTimeFallback;        /* 0x16 */
   uint8    RTSPLCPFallback[6];        /* 0x17 - 0x19 */
   uint16    RTSDurFallback;            /* 0x1a */
   uint8    FragPLCPFallback[6];        /* 0x1b - 1d */
   uint16    FragDurFallback;        /* 0x1e */
   uint16    MModeLen;            /* 0x1f */
   uint16    MModeFbrLen;            /* 0x20 */
   uint16    TstampLow;            /* 0x21 */
   uint16    TstampHigh;            /* 0x22 */
   uint16    ABI_MimoAntSel;            /* 0x23 */
   uint16    PreloadSize;            /* 0x24 */
   uint16    AmpduSeqCtl;            /* 0x25 */
   uint16    TxFrameID;            /* 0x26 */
   uint16    TxStatus;            /* 0x27 */
   uint16    MaxNMpdus;            /* 0x28 corerev >=16 */
   BWL_PRE_PACKED_STRUCT union {
       uint16 MaxAggDur;        /* 0x29 corerev >=16 */
       uint16 MaxAggLen;
   } BWL_POST_PACKED_STRUCT u1;
   BWL_PRE_PACKED_STRUCT union {
       BWL_PRE_PACKED_STRUCT struct {    /* 0x29 corerev >=16 */
           uint8 MaxRNum;
           uint8 MaxAggBytes;    /* Max Agg Bytes in power of 2 */
       } BWL_POST_PACKED_STRUCT s1;
       uint16    MaxAggLen_FBR;
   } BWL_POST_PACKED_STRUCT u2;
   uint16    MinMBytes;            /* 0x2b corerev >=16 */
   uint8    RTSPhyHeader[D11_PHY_HDR_LEN];    /* 0x2c - 0x2e */
   struct    dot11_rts_frame rts_frame;    /* 0x2f - 0x36 */
   uint16    pad;                /* 0x37 */
} BWL_POST_PACKED_STRUCT;
 
#define    D11_TXH_LEN        112    /**< bytes */
 
/* Frame Types */
#define FT_LEGACY    (-1)
#define FT_CCK        0
#define FT_OFDM        1
#define FT_HT        2
#define FT_VHT        3
#define FT_HE        4
#define FT_EHT        6
 
/* HE PPDU type */
#define HE_SU_PPDU              0
#define HE_SU_RE_PPDU           1
#define HE_MU_PPDU              2
#define HE_TRIG_PPDU            3
 
/* Position of MPDU inside A-MPDU; indicated with bits 10:9 of MacTxControlLow */
#define TXC_AMPDU_SHIFT        9    /**< shift for ampdu settings */
#define TXC_AMPDU_NONE        0    /**< Regular MPDU, not an A-MPDU */
#define TXC_AMPDU_FIRST        1    /**< first MPDU of an A-MPDU */
#define TXC_AMPDU_MIDDLE    2    /**< intermediate MPDU of an A-MPDU */
#define TXC_AMPDU_LAST        3    /**< last (or single) MPDU of an A-MPDU */
 
/* MacTxControlLow */
#define TXC_AMIC        0x8000
#define TXC_USERIFS        0x4000
#define TXC_LIFETIME        0x2000
#define    TXC_FRAMEBURST        0x1000
#define    TXC_SENDCTS        0x0800
#define TXC_AMPDU_MASK        0x0600
#define TXC_BW_40        0x0100
#define TXC_FREQBAND_5G        0x0080
#define    TXC_DFCS        0x0040
#define    TXC_IGNOREPMQ        0x0020
#define    TXC_HWSEQ        0x0010
#define    TXC_STARTMSDU        0x0008
#define    TXC_SENDRTS        0x0004
#define    TXC_LONGFRAME        0x0002
#define    TXC_IMMEDACK        0x0001
 
/* MacTxControlHigh */
#define TXC_PREAMBLE_RTS_FB_SHORT    0x8000    /* RTS fallback preamble type 1 = SHORT 0 = LONG */
#define TXC_PREAMBLE_RTS_MAIN_SHORT    0x4000    /* RTS main rate preamble type 1 = SHORT 0 = LONG */
#define TXC_PREAMBLE_DATA_FB_SHORT    0x2000    /**< Main fallback rate preamble type
                    * 1 = SHORT for OFDM/GF for MIMO
                    * 0 = LONG for CCK/MM for MIMO
                    */
/* TXC_PREAMBLE_DATA_MAIN is in PhyTxControl bit 5 */
#define    TXC_AMPDU_FBR        0x1000    /**< use fallback rate for this AMPDU */
#define    TXC_SECKEY_MASK        0x0FF0
#define    TXC_SECKEY_SHIFT    4
#define    TXC_ALT_TXPWR        0x0008    /**< Use alternate txpwr defined at loc. M_ALT_TXPWR_IDX */
#define    TXC_SECTYPE_MASK    0x0007
#define    TXC_SECTYPE_SHIFT    0
 
/* Null delimiter for Fallback rate */
#define AMPDU_FBR_NULL_DELIM  5        /**< Location of Null delimiter count for AMPDU */
 
/* PhyTxControl for Mimophy */
#define    PHY_TXC_PWR_MASK    0xFC00
#define    PHY_TXC_PWR_SHIFT    10
#define    PHY_TXC_ANT_MASK    0x03C0    /**< bit 6, 7, 8, 9 */
#define    PHY_TXC_ANT_SHIFT    6
#define    PHY_TXC_ANT_0_1        0x00C0    /**< auto, last rx */
#define    PHY_TXC_LPPHY_ANT_LAST    0x0000
#define    PHY_TXC_ANT_3        0x0200    /**< virtual antenna 3 */
#define    PHY_TXC_ANT_2        0x0100    /**< virtual antenna 2 */
#define    PHY_TXC_ANT_1        0x0080    /**< virtual antenna 1 */
#define    PHY_TXC_ANT_0        0x0040    /**< virtual antenna 0 */
 
#define    PHY_TXC_SHORT_HDR    0x0010
#define PHY_TXC_FT_MASK        0x0003
 
#define    PHY_TXC_FT_CCK        0x0000
#define    PHY_TXC_FT_OFDM        0x0001
#define    PHY_TXC_FT_HT        0x0002
#define    PHY_TXC_FT_VHT        0x0003
#define PHY_TXC_FT_HE        0x0004
#define PHY_TXC_FT_EHT        0x0006
 
#define    PHY_TXC_OLD_ANT_0    0x0000
#define    PHY_TXC_OLD_ANT_1    0x0100
#define    PHY_TXC_OLD_ANT_LAST    0x0300
 
/** PhyTxControl_1 for Mimophy */
#define PHY_TXC1_BW_MASK        0x0007
#define PHY_TXC1_BW_10MHZ        0
#define PHY_TXC1_BW_10MHZ_UP        1
#define PHY_TXC1_BW_20MHZ        2
#define PHY_TXC1_BW_20MHZ_UP        3
#define PHY_TXC1_BW_40MHZ        4
#define PHY_TXC1_BW_40MHZ_DUP        5
#define PHY_TXC1_MODE_SHIFT        3
#define PHY_TXC1_MODE_MASK        0x0038
#define PHY_TXC1_MODE_SISO        0
#define PHY_TXC1_MODE_CDD        1
#define PHY_TXC1_MODE_STBC        2
#define PHY_TXC1_MODE_SDM        3
#define PHY_TXC1_CODE_RATE_SHIFT    8
#define PHY_TXC1_CODE_RATE_MASK        0x0700
#define PHY_TXC1_CODE_RATE_1_2        0
#define PHY_TXC1_CODE_RATE_2_3        1
#define PHY_TXC1_CODE_RATE_3_4        2
#define PHY_TXC1_CODE_RATE_4_5        3
#define PHY_TXC1_CODE_RATE_5_6        4
#define PHY_TXC1_CODE_RATE_7_8        6
#define PHY_TXC1_MOD_SCHEME_SHIFT    11
#define PHY_TXC1_MOD_SCHEME_MASK    0x3800
#define PHY_TXC1_MOD_SCHEME_BPSK    0
#define PHY_TXC1_MOD_SCHEME_QPSK    1
#define PHY_TXC1_MOD_SCHEME_QAM16    2
#define PHY_TXC1_MOD_SCHEME_QAM64    3
#define PHY_TXC1_MOD_SCHEME_QAM256    4
 
/* PhyTxControl for HTphy that are different from Mimophy */
#define    PHY_TXC_HTANT_MASK        0x3fC0    /**< bit 6, 7, 8, 9, 10, 11, 12, 13 */
#define    PHY_TXC_HTCORE_MASK        0x03C0    /**< core enable core3:core0, 1=enable, 0=disable */
#define    PHY_TXC_HTCORE_SHIFT        6    /**< bit 6, 7, 8, 9 */
#define    PHY_TXC_HTANT_IDX_MASK        0x3C00    /**< 4-bit, 16 possible antenna configuration */
#define    PHY_TXC_HTANT_IDX_SHIFT        10
#define    PHY_TXC_HTANT_IDX0        0
#define    PHY_TXC_HTANT_IDX1        1
#define    PHY_TXC_HTANT_IDX2        2
#define    PHY_TXC_HTANT_IDX3        3
 
/* PhyTxControl_1 for HTphy that are different from Mimophy */
#define PHY_TXC1_HTSPARTIAL_MAP_MASK    0x7C00    /**< bit 14:10 */
#define PHY_TXC1_HTSPARTIAL_MAP_SHIFT    10
#define PHY_TXC1_HTTXPWR_OFFSET_MASK    0x01f8    /**< bit 8:3 */
#define PHY_TXC1_HTTXPWR_OFFSET_SHIFT    3
 
/* TxControl word follows new interface for AX */
/* PhyTxControl_6 for AXphy */
#define PHY_TXC5_AXTXPWR_OFFSET_C0_MASK 0xff00 /**< bit 15:8 */
#define PHY_TXC5_AXTXPWR_OFFSET_C0_SHIFT 8
#define PHY_TXC6_AXTXPWR_OFFSET_C1_MASK 0x00ff /**< bit 7:0 */
#define PHY_TXC6_AXTXPWR_OFFSET_C1_SHIFT 0
#define PHY_TXC5_AXTXPWR_OFFSET_C2_MASK 0x00ff /**< bit 7:0 */
#define PHY_TXC5_AXTXPWR_OFFSET_C2_SHIFT 0
 
/* XtraFrameTypes */
#define XFTS_RTS_FT_SHIFT    2
#define XFTS_FBRRTS_FT_SHIFT    4
#define XFTS_CHANNEL_SHIFT    8
 
/** Antenna diversity bit in ant_wr_settle */
#define    PHY_AWS_ANTDIV        0x2000
 
/* IFS ctl */
#define IFS_USEEDCF    (1 << 2)
 
/* IFS ctl1 */
#define IFS_CTL1_EDCRS    (1 << 3)
#define IFS_CTL1_EDCRS_20L (1 << 4)
#define IFS_CTL1_EDCRS_40 (1 << 5)
#define IFS_EDCRS_MASK    (IFS_CTL1_EDCRS | IFS_CTL1_EDCRS_20L | IFS_CTL1_EDCRS_40)
#define IFS_EDCRS_SHIFT    3
 
/* IFS ctl sel pricrs  */
#define IFS_CTL_CRS_SEL_20LL    1
#define IFS_CTL_CRS_SEL_20LU    2
#define IFS_CTL_CRS_SEL_20UL    4
#define IFS_CTL_CRS_SEL_20UU    8
#define IFS_CTL_CRS_SEL_MASK    (IFS_CTL_CRS_SEL_20LL | IFS_CTL_CRS_SEL_20LU | \
               IFS_CTL_CRS_SEL_20UL | IFS_CTL_CRS_SEL_20UU)
#define IFS_CTL_ED_SEL_20LL     (1 << 8)
#define IFS_CTL_ED_SEL_20LU     (1 << 9)
#define IFS_CTL_ED_SEL_20UL     (1 << 10)
#define IFS_CTL_ED_SEL_20UU     (1 << 11)
#define IFS_CTL_ED_SEL_MASK     (IFS_CTL_ED_SEL_20LL | IFS_CTL_ED_SEL_20LU | \
               IFS_CTL_ED_SEL_20UL | IFS_CTL_ED_SEL_20UU)
 
/* ABI_MimoAntSel */
#define ABI_MAS_ADDR_BMP_IDX_MASK    0x0f00
#define ABI_MAS_ADDR_BMP_IDX_SHIFT    8
#define ABI_MAS_FBR_ANT_PTN_MASK    0x00f0
#define ABI_MAS_FBR_ANT_PTN_SHIFT    4
#define ABI_MAS_MRT_ANT_PTN_MASK    0x000f
 
#ifdef WLAWDL
#define ABI_MAS_AWDL_TS_INSERT        0x1000    /**< bit 12 */
#endif
 
#define ABI_MAS_TIMBC_TSF        0x2000    /**< Enable TIMBC tsf field present */
 
/* MinMBytes */
#define MINMBYTES_PKT_LEN_MASK                  0x0300
#define MINMBYTES_FBRATE_PWROFFSET_MASK         0xFC00
#define MINMBYTES_FBRATE_PWROFFSET_SHIFT        10
 
/* Rev40 template constants */
 
/** templates include a longer PLCP header that matches the MAC / PHY interface */
#define    D11_VHT_PLCP_LEN    12
 
/* 11AC TX DMA buffer header */
 
#define D11AC_TXH_NUM_RATES            4
 
/** per rate info - rev40 */
typedef struct d11actxh_rate d11actxh_rate_t;
BWL_PRE_PACKED_STRUCT struct d11actxh_rate {
   uint16  PhyTxControlWord_0;             /* 0 - 1 */
   uint16  PhyTxControlWord_1;             /* 2 - 3 */
   uint16  PhyTxControlWord_2;             /* 4 - 5 */
   uint8   plcp[D11_PHY_HDR_LEN];          /* 6 - 11 */
   uint16  FbwInfo;                        /* 12 -13, fall back bandwidth info */
   uint16  TxRate;                         /* 14 */
   uint16  RtsCtsControl;                  /* 16 */
   uint16  Bfm0;                           /* 18 */
} BWL_POST_PACKED_STRUCT;
 
/* Bit definition for FbwInfo field */
#define FBW_BW_MASK             3
#define FBW_BW_SHIFT            0
#define FBW_TXBF                4
#define FBW_TXBF_SHIFT          2
/* this needs to be re-visited if we want to use this feature */
#define FBW_BFM0_TXPWR_MASK     0x1F8
#define FBW_BFM0_TXPWR_SHIFT    3
#define FBW_BFM_TXPWR_MASK      0x7E00
#define FBW_BFM_TXPWR_SHIFT     9
 
/* Bit definition for Bfm0 field */
#define BFM0_TXPWR_MASK         0x3f
#define BFM0_STBC_SHIFT         6
#define BFM0_STBC               (1 << BFM0_STBC_SHIFT)
/* should find a chance to converge the two */
#define D11AC2_BFM0_TXPWR_MASK  0x7f
#define D11AC2_BFM0_STBC_SHIFT  7
#define D11AC2_BFM0_STBC        (1 << D11AC2_BFM0_STBC_SHIFT)
 
/* per packet info */
typedef struct d11pktinfo_common d11pktinfo_common_t;
typedef struct d11pktinfo_common d11actxh_pkt_t;
BWL_PRE_PACKED_STRUCT struct d11pktinfo_common {
   /* Per pkt info */
   uint16  TSOInfo;                        /* 0 */
   uint16  MacTxControlLow;                /* 2 */
   uint16  MacTxControlHigh;               /* 4 */
   uint16  Chanspec;                       /* 6 */
   uint8   IVOffset;                       /* 8 */
   uint8   PktCacheLen;                    /* 9 */
   uint16  FrameLen;                       /* 10. In [bytes] units. */
   uint16  TxFrameID;                      /* 12 */
   uint16  Seq;                            /* 14 */
   uint16  Tstamp;                         /* 16 */
   uint16  TxStatus;                       /* 18 */
} BWL_POST_PACKED_STRUCT;
 
/* common cache info between rev40 and rev80 formats */
typedef struct d11txh_cache_common d11txh_cache_common_t;
BWL_PRE_PACKED_STRUCT struct d11txh_cache_common {
   uint8   BssIdEncAlg;                    /* 0 */
   uint8   KeyIdx;                         /* 1 */
   uint8   PrimeMpduMax;                   /* 2 */
   uint8   FallbackMpduMax;                /* 3 */
   uint16  AmpduDur;                       /* 4 - 5 */
   uint8   BAWin;                          /* 6 */
   uint8   MaxAggLen;                      /* 7 */
} BWL_POST_PACKED_STRUCT;
 
/** Per cache info - rev40 */
typedef struct d11actxh_cache d11actxh_cache_t;
BWL_PRE_PACKED_STRUCT struct d11actxh_cache {
   d11txh_cache_common_t common;        /*  0 -  7 */
   uint8   TkipPH1Key[10];                 /*  8 - 17 */
   uint8   TSCPN[6];                       /* 18 - 23 */
} BWL_POST_PACKED_STRUCT;
 
/** Long format tx descriptor - rev40 */
typedef struct d11actxh d11actxh_t;
BWL_PRE_PACKED_STRUCT struct d11actxh {
   /* Per pkt info */
   d11actxh_pkt_t    PktInfo;            /* 0 - 19 */
 
   union {
 
       /** Rev 40 to rev 63 layout */
       struct {
           /** Per rate info */
           d11actxh_rate_t RateInfo[D11AC_TXH_NUM_RATES];  /* 20 - 99 */
 
           /** Per cache info */
           d11actxh_cache_t    CacheInfo;                    /* 100 - 123 */
       } rev40;
 
       /** Rev >= 64 layout */
       struct {
           /** Per cache info */
           d11actxh_cache_t    CacheInfo;                    /* 20 - 43 */
 
           /** Per rate info */
           d11actxh_rate_t RateInfo[D11AC_TXH_NUM_RATES];  /* 44 - 123 */
       } rev64;
 
   };
} BWL_POST_PACKED_STRUCT;
 
#define D11AC_TXH_LEN        sizeof(d11actxh_t)    /* 124 bytes */
 
/* Short format tx descriptor only has per packet info */
#define D11AC_TXH_SHORT_LEN    sizeof(d11actxh_pkt_t)    /* 20 bytes */
 
/* -TXDC-TxH Excluding Rate Info 41 bytes (Note 1 byte of RATEINFO is removed */
#define D11AC_TXH_SHORT_EXT_LEN        (sizeof(d11txh_rev80_t) - 1)
 
/* Retry limit regs */
/* Current retries for the fallback rates are hardcoded */
#define D11AC_TXDC_SRL_FB    (3u)    /* Short Retry Limit - Fallback */
#define D11AC_TXDC_LRL_FB    (2u)    /* Long Retry Limit - Fallback */
 
#define D11AC_TXDC_RET_LIM_MASK (0x000Fu)
#define D11AC_TXDC_SRL_SHIFT    (0u)    /* Short Retry Limit */
#define D11AC_TXDC_SRL_FB_SHIFT (4u)    /* Short Retry Limit - Fallback */
#define D11AC_TXDC_LRL_SHIFT    (8u)    /* Long Retry Limit */
#define D11AC_TXDC_LRL_FB_SHIFT (12u)    /* Long Retry Limit - Fallback */
 
/* MacTxControlLow */
#define D11AC_TXC_HDR_FMT_SHORT        0x0001    /**< 0: long format, 1: short format */
#define D11AC_TXC_UPD_CACHE        0x0002
#define D11AC_TXC_CACHE_IDX_MASK    0x003C    /**< Cache index 0 .. 15 */
#define D11AC_TXC_CACHE_IDX_SHIFT    2
 
#define D11AC_TXDC_IDX_SHIFT        1
#define D11AC_TXDC_CPG_SHIFT        5
#define D11REV80_TXDC_RIB_CPG        0x0020  /**< Cache Index CPG (Bit 5)   -TXDC- */
#define D11REV80_TXDC_RIB_DEL_MASK    0x001E  /**< Cache index CIPX 0 .. 15 (Bit 1-4 -TXDC- */
#define D11REV80_TXDC_RIB_IMM_MASK    0x003E    /**< Cache index CIPX 0 .. 31 (Bit 1-5) -TXDC- */
#define D11AC_TXC_AMPDU            0x0040    /**< Is aggregate-able */
#define D11AC_TXC_IACK            0x0080    /**< Expect immediate ACK */
#define D11AC_TXC_LFRM            0x0100    /**< Use long/short retry frame count/limit */
#define D11AC_TXC_IPMQ            0x0200    /**< Ignore PMQ */
#define D11AC_TXC_MBURST        0x0400    /**< Burst mode */
#define D11AC_TXC_ASEQ            0x0800    /**< Add ucode generated seq num */
#define D11AC_TXC_AGING            0x1000    /**< Use lifetime */
#define D11AC_TXC_AMIC            0x2000    /**< Compute and add TKIP MIC */
#define D11AC_TXC_STMSDU        0x4000    /**< First MSDU */
#define D11AC_TXC_URIFS            0x8000    /**< Use RIFS */
 
/* MacTxControlHigh */
#define D11AC_TXC_DISFCS        0x0001    /**< Discard FCS */
#define D11AC_TXC_FIX_RATE        0x0002    /**< Use primary rate only */
#define D11AC_TXC_SVHT            0x0004    /**< Single VHT mpdu ampdu */
#define D11AC_TXC_PPS            0x0008    /**< Enable PS Pretend feature */
#define D11AC_TXC_UCODE_SEQ        0x0010    /* Sequence counter for BK traffic, for offloads */
#define D11AC_TXC_TIMBC_TSF        0x0020    /**< Enable TIMBC tsf field present */
#define D11AC_TXC_TCPACK        0x0040
#define D11AC_TXC_AWDL_PHYTT     0x0080 /**< Fill in PHY Transmission Time for AWDL action frames */
#define D11AC_TXC_TOF            0x0100 /**< Enable wifi ranging processing for rxd frames */
#define D11AC_TXC_MU            0x0200 /**< MU Tx data */
#define D11AC_TXC_BFIX            0x0800 /**< BFI from SHMx */
#define D11AC_TXC_NORETRY        0x0800 /**< Disable retry for tsync frames */
#define D11AC_TXC_UFP            0x1000    /**< UFP */
#define D11AC_TXC_OVERRIDE_NAV        0x1000 /**< if set, ucode will tx without honoring NAV */
#define D11AC_TXC_DYNBW            0x2000    /**< Dynamic BW */
#define D11AC_TXC_TXPROF_EN        0x8000    /**< TxProfile Enable TODO: support multiple idx */
#define D11AC_TXC_SLTF            0x8000    /**< 11az Secure Ranging frame */
 
#define D11AC_TSTAMP_SHIFT        8    /**< Tstamp in 256us units */
 
/* PhyTxControlWord_0 */
#define D11AC_PHY_TXC_FT_MASK        0x0003
 
/* vht txctl0 */
#define D11AC_PHY_TXC_NON_SOUNDING    0x0004
#define D11AC_PHY_TXC_BFM            0x0008
#define D11AC_PHY_TXC_SHORT_PREAMBLE    0x0010
#define D11AC2_PHY_TXC_STBC        0x0020
#define D11AC_PHY_TXC_ANT_MASK        0x3FC0
#define D11AC_PHY_TXC_CORE_MASK        0x03C0
#define D11AC_PHY_TXC_CORE_SHIFT    6
#define D11AC_PHY_TXC_ANT_IDX_MASK    0x3C00
#define D11AC_PHY_TXC_ANT_IDX_SHIFT    10
#define D11AC_PHY_TXC_BW_MASK        0xC000
#define D11AC_PHY_TXC_BW_SHIFT        14
#define D11AC_PHY_TXC_BW_20MHZ        0x0000
#define D11AC_PHY_TXC_BW_40MHZ        0x4000
#define D11AC_PHY_TXC_BW_80MHZ        0x8000
#define D11AC_PHY_TXC_BW_160MHZ        0xC000
 
/* PhyTxControlWord_1 */
#define D11AC_PHY_TXC_PRIM_SUBBAND_MASK        0x0007
#define D11AC_PHY_TXC_PRIM_SUBBAND_LLL        0x0000
#define D11AC_PHY_TXC_PRIM_SUBBAND_LLU        0x0001
#define D11AC_PHY_TXC_PRIM_SUBBAND_LUL        0x0002
#define D11AC_PHY_TXC_PRIM_SUBBAND_LUU        0x0003
#define D11AC_PHY_TXC_PRIM_SUBBAND_ULL        0x0004
#define D11AC_PHY_TXC_PRIM_SUBBAND_ULU        0x0005
#define D11AC_PHY_TXC_PRIM_SUBBAND_UUL        0x0006
#define D11AC_PHY_TXC_PRIM_SUBBAND_UUU        0x0007
#define D11AC_PHY_TXC_TXPWR_OFFSET_MASK     0x01F8
#define D11AC_PHY_TXC_TXPWR_OFFSET_SHIFT    3
#define D11AC2_PHY_TXC_TXPWR_OFFSET_MASK     0x03F8
#define D11AC2_PHY_TXC_TXPWR_OFFSET_SHIFT    3
#define D11AC_PHY_TXC_TXBF_USER_IDX_MASK    0x7C00
#define D11AC_PHY_TXC_TXBF_USER_IDX_SHIFT    10
#define D11AC2_PHY_TXC_DELTA_TXPWR_OFFSET_MASK     0x7C00
#define D11AC2_PHY_TXC_DELTA_TXPWR_OFFSET_SHIFT    10
/* Rather awkward bit mapping to keep pctl1 word same as legacy, for proprietary 11n rate support */
#define D11AC_PHY_TXC_11N_PROP_MCS        0x8000 /* this represents bit mcs[6] */
#define D11AC2_PHY_TXC_MU            0x8000
 
/* PhyTxControlWord_2 phy rate */
#define D11AC_PHY_TXC_PHY_RATE_MASK        0x003F
#define D11AC2_PHY_TXC_PHY_RATE_MASK        0x007F
 
/* 11b phy rate */
#define D11AC_PHY_TXC_11B_PHY_RATE_MASK        0x0003
#define D11AC_PHY_TXC_11B_PHY_RATE_1        0x0000
#define D11AC_PHY_TXC_11B_PHY_RATE_2        0x0001
#define D11AC_PHY_TXC_11B_PHY_RATE_5_5        0x0002
#define D11AC_PHY_TXC_11B_PHY_RATE_11        0x0003
 
/* 11a/g phy rate */
#define D11AC_PHY_TXC_11AG_PHY_RATE_MASK    0x0007
#define D11AC_PHY_TXC_11AG_PHY_RATE_6        0x0000
#define D11AC_PHY_TXC_11AG_PHY_RATE_9        0x0001
#define D11AC_PHY_TXC_11AG_PHY_RATE_12        0x0002
#define D11AC_PHY_TXC_11AG_PHY_RATE_18        0x0003
#define D11AC_PHY_TXC_11AG_PHY_RATE_24        0x0004
#define D11AC_PHY_TXC_11AG_PHY_RATE_36        0x0005
#define D11AC_PHY_TXC_11AG_PHY_RATE_48        0x0006
#define D11AC_PHY_TXC_11AG_PHY_RATE_54        0x0007
 
/* 11ac phy rate */
#define D11AC_PHY_TXC_11AC_MCS_MASK        0x000F
#define D11AC_PHY_TXC_11AC_NSS_MASK        0x0030
#define D11AC_PHY_TXC_11AC_NSS_SHIFT        4
 
/* 11n phy rate */
#define D11AC_PHY_TXC_11N_MCS_MASK        0x003F
#define D11AC2_PHY_TXC_11N_MCS_MASK        0x007F
#define D11AC2_PHY_TXC_11N_PROP_MCS        0x0040 /* this represents bit mcs[6] */
 
/* PhyTxControlWord_2 rest */
#define D11AC_PHY_TXC_STBC            0x0040
#define D11AC_PHY_TXC_DYN_BW_IN_NON_HT_PRESENT    0x0080
#define D11AC_PHY_TXC_DYN_BW_IN_NON_HT_DYNAMIC    0x0100
#define D11AC2_PHY_TXC_TXBF_USER_IDX_MASK    0xFE00
#define D11AC2_PHY_TXC_TXBF_USER_IDX_SHIFT    9
 
/* RtsCtsControl */
#define D11AC_RTSCTS_FRM_TYPE_MASK    0x0001    /**< frame type */
#define D11AC_RTSCTS_FRM_TYPE_11B    0x0000    /**< 11b */
#define D11AC_RTSCTS_FRM_TYPE_11AG    0x0001    /**< 11a/g */
#define D11AC_RTSCTS_USE_RTS        0x0004    /**< Use RTS */
#define D11AC_RTSCTS_USE_CTS        0x0008    /**< Use CTS */
#define D11AC_RTSCTS_SHORT_PREAMBLE    0x0010    /**< Long/short preamble: 0 - long, 1 - short? */
#define D11AC_RTSCTS_LAST_RATE        0x0020    /**< this is last rate */
#define D11AC_RTSCTS_IMBF        0x0040    /**< Implicit TxBF */
#define D11AC_RTSCTS_MIMOPS_RTS        0x8000    /**< Use RTS for mimops */
#define D11AC_RTSCTS_DPCU_VALID        0x0080    /**< DPCU Valid : Same bitfield as above */
#define D11AC_RTSCTS_BF_IDX_MASK    0xF000    /**< 4-bit index to the beamforming block */
#define D11AC_RTSCTS_BF_IDX_SHIFT    12
#define D11AC_RTSCTS_RATE_MASK        0x0F00    /**< Rate table offset: bit 3-0 of PLCP byte 0 */
#define D11AC_RTSCTS_USE_RATE_SHIFT    8
 
/* BssIdEncAlg */
#define D11AC_BSSID_MASK        0x000F    /**< BSS index */
#define D11AC_BSSID_SHIFT        0
#define D11AC_ENCRYPT_ALG_MASK        0x00F0    /**< Encryption algoritm */
#define D11AC_ENCRYPT_ALG_SHIFT        4
#define D11AC_ENCRYPT_ALG_NOSEC        0x0000    /**< No security */
#define D11AC_ENCRYPT_ALG_WEP        0x0010    /**< WEP */
#define D11AC_ENCRYPT_ALG_TKIP        0x0020    /**< TKIP */
#define D11AC_ENCRYPT_ALG_AES        0x0030    /**< AES */
#define D11AC_ENCRYPT_ALG_WEP128    0x0040    /**< WEP128 */
#define D11AC_ENCRYPT_ALG_NA        0x0050    /**< N/A */
#define D11AC_ENCRYPT_ALG_WAPI        0x0060    /**< WAPI */
 
/* AmpduDur */
#define D11AC_AMPDU_MIN_DUR_IDX_MASK    0x000F    /**< AMPDU minimum duration index */
#define D11AC_AMPDU_MIN_DUR_IDX_SHIFT    0
#define D11AC_AMPDU_MAX_DUR_MASK    0xFFF0    /**< AMPDU maximum duration in unit 16 usec */
#define D11AC_AMPDU_MAX_DUR_SHIFT    4
 
/**
 * TX Descriptor definitions for supporting rev80 (HE)
 */
/* Maximum number of TX fallback rates per packet */
#define D11_REV80_TXH_NUM_RATES            4
#define D11_REV80_TXH_PHYTXCTL_MIN_LENGTH    1
 
/** per rate info - fixed portion - rev80 */
typedef struct d11txh_rev80_rate_fixed d11txh_rev80_rate_fixed_t;
BWL_PRE_PACKED_STRUCT struct d11txh_rev80_rate_fixed {
   uint16    TxRate;            /* rate in 500Kbps */
   uint16    RtsCtsControl;        /* RTS - CTS control */
   uint8    plcp[D11_PHY_HDR_LEN];    /* 6 bytes */
} BWL_POST_PACKED_STRUCT;
 
/* rev80 specific per packet info fields */
typedef struct d11pktinfo_rev80 d11pktinfo_rev80_t;
BWL_PRE_PACKED_STRUCT struct d11pktinfo_rev80 {
   uint16    HEModeControl;            /* 20 */
   uint16  length;                /* 22 - length of txd in bytes */
} BWL_POST_PACKED_STRUCT;
 
#define D11_REV80_TXH_TX_MODE_SHIFT        0    /* Bits 2:0 of HeModeControl */
#define D11_REV80_TXH_TX_MODE_MASK        0x3
#define D11_REV80_TXH_HTC_OFFSET_SHIFT        4    /* Bits 8:4 of HeModeControl */
#define D11_REV80_TXH_HTC_OFFSET_MASK        0x01F0u
#define D11_REV80_TXH_TWT_EOSP            0x0200u    /* bit 9 indicate TWT EOSP */
#define D11_REV80_TXH_QSZ_QOS_CTL_IND_SHIFT    10    /* Bit 10 of HeModeControl */
#define D11_REV80_TXH_QSZ_QOS_CTL_IND_MASK    (1 << D11_REV80_TXH_QSZ_QOS_CTL_IND_SHIFT)
#define D11_REV80_TXH_USE_BSSCOLOR_SHM_SHIFT    15    /* Bit 15 of HEModeControl */
#define D11_REV80_TXH_USE_BSSCOLOR_SHM_MASK    (1 << D11_REV80_TXH_USE_BSSCOLOR_SHM_SHIFT)
 
/* Calculate Length for short format TXD */
#define D11_TXH_SHORT_LEN(__corerev__)        (D11REV_GE(__corerev__, 80) ? \
                        D11_REV80_TXH_SHORT_LEN :    \
                        D11AC_TXH_SHORT_LEN)
 
/* Calculate Length for short format TXD  (TXDC and/or FMF) */
#define D11_TXH_SHORT_EX_LEN(__corerev__)    (D11REV_GE(__corerev__, 80) ? \
                        D11_REV80_TXH_SHORT_EX_LEN : \
                        D11AC_TXH_SHORT_LEN)
 
#define D11_REV80_TXH_IS_HE_AMPDU_SHIFT        11    /* Bit 11 of HeModeControl */
#define D11_REV80_TXH_IS_HE_AMPDU_MASK        (1 << D11_REV80_TXH_IS_HE_AMPDU_SHIFT)
 
#define D11_REV80_PHY_TXC_EDCA            0x00
#define D11_REV80_PHY_TXC_OFDMA_RA        0x01    /* Use Random Access Trigger for Tx */
#define D11_REV80_PHY_TXC_OFDMA_DT        0x02    /* Use Directed Trigger for Tx */
#define D11_REV80_PHY_TXC_OFDMA_ET        0x03    /* Use earliest Trigger Opportunity */
 
/** Per cache info - rev80 */
typedef struct d11txh_rev80_cache d11txh_rev80_cache_t;
BWL_PRE_PACKED_STRUCT struct d11txh_rev80_cache {
   d11txh_cache_common_t common;        /* 0 - 7 */
   uint16    ampdu_mpdu_all;            /* 8 - 9 */
   uint16    aggid;                /* 10 - 11 */
   uint8    tkipph1_index;            /* 12 */
   uint8    pktext;                /* 13 */
   uint16    hebid_map;            /* 14 -15: HEB ID bitmap */
} BWL_POST_PACKED_STRUCT;
 
/** Fixed size portion of TX descriptor - rev80 */
typedef struct d11txh_rev80 d11txh_rev80_t;
BWL_PRE_PACKED_STRUCT struct d11txh_rev80 {
   /**
    * Per pkt info fields (common + rev80 specific)
    *
    * Note : Ensure that PktInfo field is always the first member
    * of the d11txh_rev80 struct (that is at OFFSET - 0)
    */
   d11pktinfo_common_t PktInfo;    /* 0 - 19 */
   d11pktinfo_rev80_t PktInfoExt;    /* 20 - 23 */
 
   /** Per cache info */
   d11txh_rev80_cache_t CacheInfo;    /* 24 - 39 */
 
   /**
    * D11_REV80_TXH_NUM_RATES number of Rate Info blocks
    * contribute to the variable size portion of the TXD.
    * Each Rate Info element (block) is a funtion of
    * (N_PwrOffset, N_RU, N_User).
    */
   uint8 RateInfoBlock[1];
} BWL_POST_PACKED_STRUCT;
 
/* Size of fixed portion in TX descriptor (without CacheInfo(Link info) and RateInfoBlock)
 * this portion never change regardless of TXDC/FMF support.
 */
/* OFFSETOF() is available in bcmutils.h but including it will cause
 * recursive inclusion of d11.h specifically on NDIS platforms.
 */
#ifdef BCMFUZZ
   /* use 0x10 offset to avoid undefined behavior error due to NULL access */
#define D11_REV80_TXH_FIXED_LEN    (((uint)(uintptr)&((d11txh_rev80_t *)0x10)->CacheInfo) - 0x10)
#else
#define D11_REV80_TXH_FIXED_LEN    ((uint)(uintptr)&((d11txh_rev80_t *)0)->CacheInfo)
#endif /* BCMFUZZ */
 
/* Short format tx descriptor only has per packet info (24 bytes) */
#define D11_REV80_TXH_SHORT_LEN    (sizeof(d11pktinfo_common_t) + sizeof(d11pktinfo_rev80_t))
 
/* Size of CacheInfo(Link info) in TX descriptor */
#define D11_REV80_TXH_LINK_INFO_LEN    (sizeof(d11txh_rev80_cache_t))
 
/* Size of Short format TX descriptor
 * with TXDC - Short TXD(40 bytes) shall include PktInfo and Cache info without Rate info
 * with TXDC+FMF - Short TXD(24 bytes) shall include PktInfo only without Link info and Rate info
 * do NOT use D11_REV80_TXH_SHORT_EX_LEN to calculate long TXD length, value depends on FMF feature
 */
#if defined(FMF_LIT) && !defined(FMF_LIT_DISABLED)
#define D11_REV80_TXH_SHORT_EX_LEN    D11_REV80_TXH_FIXED_LEN
#else
#define D11_REV80_TXH_SHORT_EX_LEN    (D11_REV80_TXH_FIXED_LEN + D11_REV80_TXH_LINK_INFO_LEN)
#endif /* FMF_LIT && !FMF_LIT_DISABLED */
 
/* Length of BFM0 field in RateInfo Blk */
#define    D11_REV80_TXH_BFM0_FIXED_LEN(pwr_offs)        2u
 
/**
 * Length of FBWInfo field in RateInfo Blk
 *
 * Note : for now return fixed length of 1 word
 */
#define    D11_REV80_TXH_FBWINFO_FIXED_LEN(pwr_offs)    2
 
#define D11_REV80_TXH_FIXED_RATEINFO_LEN    sizeof(d11txh_rev80_rate_fixed_t)
 
/**
 * Macros to find size of N-RUs field in the PhyTxCtlWord.
 */
#define D11_REV80_TXH_TXC_N_RUs_FIELD_SIZE        1
#define D11_REV80_TXH_TXC_PER_RU_INFO_SIZE        4
#define D11_REV80_TXH_TXC_PER_RU_MIN_SIZE        2
 
#define D11_REV80_TXH_TXC_RU_FIELD_SIZE(n_rus)    ((n_rus == 1) ? \
                       (D11_REV80_TXH_TXC_PER_RU_MIN_SIZE) : \
                       ((D11_REV80_TXH_TXC_N_RUs_FIELD_SIZE) + \
                       ((n_rus) * D11_REV80_TXH_TXC_PER_RU_INFO_SIZE)))
 
/**
 * Macros to find size of N-Users field in the TXCTL_EXT
 */
#define D11_REV80_TXH_TXC_EXT_N_USERs_FIELD_SIZE    1
#define D11_REV80_TXH_TXC_EXT_PER_USER_INFO_SIZE    4
 
#define D11_REV80_TXH_TXC_N_USERs_FIELD_SIZE(n_users) \
   ((n_users) ? \
    (((n_users) * \
      (D11_REV80_TXH_TXC_EXT_PER_USER_INFO_SIZE)) + \
     (D11_REV80_TXH_TXC_EXT_N_USERs_FIELD_SIZE)) :    \
    (n_users))
 
/**
 * Size of each Tx Power Offset field in PhyTxCtlWord.
 */
#define D11_REV80_TXH_TXC_PWR_OFFSET_SIZE        1u
 
/**
 * Size of fixed / static fields in PhyTxCtlWord (all fields except N-RUs, N-Users and Pwr offsets)
 */
#define D11_REV80_TXH_TXC_CONST_FIELDS_SIZE        6u
 
/**
 * Macros used for filling PhyTxCtlWord
 */
 
/* PhyTxCtl Byte 0 */
#define D11_REV80_PHY_TXC_FT_MASK        0x0007u
#define D11_REV80_PHY_TXC_HE_FMT_MASK        0x0018u
#define D11_REV80_PHY_TXC_SOFT_AP_MODE        0x0020u
#define D11_REV80_PHY_TXC_NON_SOUNDING        0x0040u
#define D11_REV80_PHY_TXC_SHORT_PREAMBLE    0x0080u
#define D11_REV80_PHY_TXC_FRAME_TYPE_VHT    0X0003u
#define D11_REV80_PHY_TXC_FRAME_TYPE_HT        0X0002u
#define D11_REV80_PHY_TXC_FRAME_TYPE_LEG    0X0001u
 
#define D11_REV80_PHY_TXC_HE_FMT_SHIFT        3u
 
/* PhyTxCtl Byte 1 */
#define D11_REV80_PHY_TXC_STBC            0x0080u
 
/* PhyTxCtl Word 1 (Bytes 2 - 3) */
#define D11_REV80_PHY_TXC_DPCU_SUBBAND_SHIFT    5u
#define D11_REV80_PHY_TXC_DYNBW_PRESENT        0x2000u
#define D11_REV80_PHY_TXC_DYNBW_MODE        0x4000u
#define D11_REV80_PHY_TXC_MU            0x8000u
#define D11_REV80_PHY_TXC_BW_MASK        0x0003u
#define D11_REV80_PHY_TXC_BW_20MHZ        0x0000u
#define D11_REV80_PHY_TXC_BW_40MHZ        0x0001u
#define D11_REV80_PHY_TXC_BW_80MHZ        0x0002u
#define D11_REV80_PHY_TXC_BW_160MHZ        0x0003u
/* PhyTxCtl Word 2 (Bytes 4 -5) */
/* Though the width antennacfg, coremask fields are 8-bits,
 * only 4 bits is valid for 4369a0, hence masking only 4 bits
 */
#define D11_REV80_PHY_TXC_ANT_CONFIG_MASK        0x00F0u
#define D11_REV80_PHY_TXC_CORE_MASK            0x000Fu
#define D11_REV80_PHY_TXC_ANT_CONFIG_SHIFT        4u
/* upper byte- Ant. cfg, lower byte - Core  */
#define D11_REV80_PHY_TXC_ANT_CORE_MASK        0x0F0Fu
 
/* PhyTxCtl BFM field */
#define D11_REV80_PHY_TXC_BFM            0x80u
 
/* PhyTxCtl power offsets */
#define D11_REV80_PHY_TXC_PWROFS0_BYTE_POS    6u
 
/* Phytx Ctl Sub band location */
#define D11_REV80_PHY_TXC_SB_SHIFT        2u
#define D11_REV80_PHY_TXC_SB_MASK        0x001Cu
 
/* 11n phy rate */
#define D11_REV80_PHY_TXC_11N_MCS_MASK        0x003Fu
#define D11_REV80_PHY_TXC_11N_PROP_MCS        0x0040u /* this represents bit mcs[6] */
 
/* 11ac phy rate */
#define D11_REV80_PHY_TXC_11AC_NSS_SHIFT    4u
 
/* PhyTxCtl Word0  */
#define D11_REV80_PHY_TXC_MCS_NSS_MASK        0x7F00u
#define D11_REV80_PHY_TXC_MCS_MASK        0xF00u
#define D11_REV80_PHY_TXC_MCS_NSS_SHIFT        8u
 
/* 11ax phy rate */
#define D11_REV80_PHY_TXC_11AX_NSS_SHIFT    4u
 
#define D11_PHY_TXC_FT_MASK(corerev)    ((D11REV_GE(corerev, 80)) ? D11_REV80_PHY_TXC_FT_MASK : \
                   D11AC_PHY_TXC_FT_MASK)
 
/* PhyTxCtl Word 4 */
#define D11_REV80_PHY_TXC_HEHL_ENABLE              0x2000u
 
/* PhyTxCtl Word 5 */
#define D11_REV80_PHY_TXC_CORE0_PWR_OFFSET_SHIFT   8u
#define D11_REV80_PHY_TXC_CORE0_PWR_OFFSET_MASK    0xFF00u
/* PhyTxCtl Word 6 */
#define D11_REV80_PHY_TXC_CORE1_PWR_OFFSET_MASK    0x00FFu
/* Number of RU assigned */
#define D11_REV80_PHY_TXC_NRU                      0x0100u
 
/* A wrapper structure for all versions of TxD/d11txh structures */
typedef union d11txhdr {
   d11txh_pre40_t pre40;
   d11actxh_t rev40;
   d11txh_rev80_t rev80;
} d11txhdr_t;
 
/**
 * Generic tx status packet for software use. This is independent of hardware
 * structure for a particular core. Hardware structure should be read and converted
 * to this structure before being sent for the sofware consumption.
 */
typedef struct tx_status tx_status_t;
typedef struct tx_status_macinfo tx_status_macinfo_t;
 
BWL_PRE_PACKED_STRUCT struct tx_status_macinfo {
   int8 pad0;
   int8 is_intermediate;
   int8 pm_indicated;
   int8 pad1;
   uint8 suppr_ind;
   int8 was_acked;
   uint16 rts_tx_cnt;
   uint16 frag_tx_cnt;
   uint16 cts_rx_cnt;
   uint16 raw_bits;
   uint32 s3;
   uint32 s4;
   uint32 s5;
   uint32 s8;
   uint32 s9;
   uint32 s10;
   uint32 s11;
   uint32 s12;
   uint32 s13;
   uint32 s14;
   /* 128BA support */
   uint16 ncons_ext;
   uint16 s15;
   uint32 ack_map[8];
   /* pktlat */
   uint16 pkt_fetch_ts;    /* PSM Packet Fetch Time */
   uint16 med_acc_dly;    /* Medium Access Delay */
   uint16 rx_dur;        /* Rx duration */
   uint16 mac_susp_dur;    /* Mac Suspend Duration */
   uint16 txstatus_ts;    /* TxStatus Time */
   uint16 tx_en_cnt;    /* Number of times Tx was enabled */
   uint16 oac_txs_cnt;    /* Other AC TxStatus count */
   uint16 data_retx_cnt;    /* DataRetry count */
   uint16 pktlat_rsvd;    /* reserved */
} BWL_POST_PACKED_STRUCT;
 
BWL_PRE_PACKED_STRUCT struct tx_status {
   uint16 framelen;
   uint16 frameid;
   uint16 sequence;
   uint16 phyerr;
   uint32 lasttxtime;
   uint16 ackphyrxsh;
   uint16 procflags;    /* tx status processing flags */
   uint32 dequeuetime;
   tx_status_macinfo_t status;
} BWL_POST_PACKED_STRUCT;
 
/* Bits in struct tx_status procflags */
#define TXS_PROCFLAG_AMPDU_BA_PKG2_READ_REQD    0x1    /* AMPDU BA txs pkg2 read required */
 
/* status field bit definitions */
#define    TX_STATUS_FRM_RTX_MASK    0xF000
#define    TX_STATUS_FRM_RTX_SHIFT    12
#define    TX_STATUS_RTS_RTX_MASK    0x0F00
#define    TX_STATUS_RTS_RTX_SHIFT    8
#define TX_STATUS_MASK        0x00FE
#define    TX_STATUS_PMINDCTD    (1 << 7)    /**< PM mode indicated to AP */
#define    TX_STATUS_INTERMEDIATE    (1 << 6)    /**< intermediate or 1st ampdu pkg */
#define    TX_STATUS_AMPDU        (1 << 5)    /**< AMPDU status */
#define TX_STATUS_SUPR_MASK    0x1C        /**< suppress status bits (4:2) */
#define TX_STATUS_SUPR_SHIFT    2
#define    TX_STATUS_ACK_RCV    (1 << 1)    /**< ACK received */
#define    TX_STATUS_VALID        (1 << 0)    /**< Tx status valid (corerev >= 5) */
#define    TX_STATUS_NO_ACK    0
#define TX_STATUS_BE        (TX_STATUS_ACK_RCV | TX_STATUS_PMINDCTD)
 
/* TX_STATUS for fw initiated pktfree event */
#define TX_STATUS_SW_Q_FLUSH    0x10000
 
/* status field bit definitions phy rev > 40 */
#define TX_STATUS40_FIRST        0x0002
#define TX_STATUS40_INTERMEDIATE    0x0004
#define TX_STATUS40_PMINDCTD        0x0008
 
#define TX_STATUS40_SUPR        0x00f0
#define TX_STATUS40_SUPR_SHIFT        4
 
#define TX_STATUS40_NCONS        0x7f00
 
#define TX_STATUS40_NCONS_SHIFT        8
 
#define TX_STATUS40_ACK_RCV        0x8000
 
/* tx status bytes 8-16 */
#define TX_STATUS40_TXCNT_RATE0_MASK    0x000000ff
#define TX_STATUS40_TXCNT_RATE0_SHIFT    0
 
#define TX_STATUS40_TXCNT_RATE1_MASK    0x00ff0000
#define TX_STATUS40_TXCNT_RATE1_SHIFT    16
 
#define TX_STATUS40_MEDIUM_DELAY_MASK   0xFFFF
 
#define TX_STATUS40_TXCNT(s3, s4) \
   (((s3 & TX_STATUS40_TXCNT_RATE0_MASK) >> TX_STATUS40_TXCNT_RATE0_SHIFT) + \
   ((s3 & TX_STATUS40_TXCNT_RATE1_MASK) >> TX_STATUS40_TXCNT_RATE1_SHIFT) + \
   ((s4 & TX_STATUS40_TXCNT_RATE0_MASK) >> TX_STATUS40_TXCNT_RATE0_SHIFT) + \
   ((s4 & TX_STATUS40_TXCNT_RATE1_MASK) >> TX_STATUS40_TXCNT_RATE1_SHIFT))
 
#define TX_STATUS40_TXCNT_RT0(s3) \
   ((s3 & TX_STATUS40_TXCNT_RATE0_MASK) >> TX_STATUS40_TXCNT_RATE0_SHIFT)
 
#define TX_STATUS_EXTBA_TXCNT_BITS    0x3u
#define TX_STATUS_EXTBA_TXSUCCNT_BITS    0x1u
#define TX_STATUS_EXTBA_TXSIZE_RT    0x4u
 
#define TX_STATUS_EXTBA_TXCNT_RATE_MASK        0x7u
#define TX_STATUS_EXTBA_TXSUCCNT_RATE_MASK    0x8u
 
#define TX_STATUS_EXTBA_TXCNT_RATE_SHIFT    0x8u
#define TX_STATUS_EXTBA_TXSUCCNT_RATE_SHIFT    0x8u
 
#define TX_STATUS_EXTBA_TXCNT_RT(s15, rt) \
   ((((s15) & (TX_STATUS_EXTBA_TXCNT_RATE_MASK << ((rt) * TX_STATUS_EXTBA_TXSIZE_RT))) >> \
   ((rt) * TX_STATUS_EXTBA_TXSIZE_RT)) << TX_STATUS_EXTBA_TXCNT_RATE_SHIFT)
 
#define TX_STATUS_EXTBA_TXSUCCNT_RT(s15, rt) \
   ((((s15) & (TX_STATUS_EXTBA_TXSUCCNT_RATE_MASK << ((rt) * TX_STATUS_EXTBA_TXSIZE_RT))) >> \
   (((rt) * TX_STATUS_EXTBA_TXSIZE_RT))) << TX_STATUS_EXTBA_TXSUCCNT_RATE_SHIFT)
 
#define TX_STATUS40_TX_MEDIUM_DELAY(txs)    ((txs)->status.s8 & TX_STATUS40_MEDIUM_DELAY_MASK)
 
/* chip rev 40 pkg 2 fields */
#define TX_STATUS40_IMPBF_MASK        0x0000000Cu    /* implicit bf applied */
#define TX_STATUS40_IMPBF_BAD_MASK    0x00000010u    /* impl bf applied but ack frm has no bfm */
#define TX_STATUS40_IMPBF_LOW_MASK    0x00000020u    /* ack received with low rssi */
#define TX_STATUS40_BFTX        0x00000040u    /* Beamformed pkt TXed */
/* pkt two status field bit definitions mac rev > 64 */
#define TX_STATUS64_MUTX        0x00000080u    /* Not used in STA-dongle chips */
 
/* pkt two status field bit definitions mac rev > 80 */
 
/* TXS rate cookie contains
 * mac rev 81/82 : RIT idx in bit[4:0] of RIB CtrlStat[0]
 * mac rev >= 83 : RIB version in bit[4:0] of RIB CtrlStat[1]
 */
#define TX_STATUS80_RATE_COOKIE_MASK    0x00003E00u
#define TX_STATUS80_RATE_COOKIE_SHIFT    9u
#define TX_STATUS80_NAV_HDR        0x00004000u /* NAV Overriden */
 
#define TX_STATUS80_TBPPDU_MASK        0x00000040u /* Indicates TBPPDU TX */
#define TX_STATUS80_TBPPDU_SHIFT    6u
#define TX_STATUS40_RTS_RTX_MASK    0x00ff0000u
#define TX_STATUS40_RTS_RTX_SHIFT    16u
#define TX_STATUS40_CTS_RRX_MASK    0xff000000u
#define TX_STATUS40_CTS_RRX_SHIFT    24u
 
/*
 * Intermediate status for TBPPDU (for stats purposes)
 * First uint16 word (word0 - status): VALID, !FIRST, INTERMEDIATE
 * Remaining word0 bits (3 - 15) are unasisgned
 */
#define TX_ITBSTATUS(status)        \
   (((status) & (TX_STATUS40_FIRST | TX_STATUS40_INTERMEDIATE)) == TX_STATUS40_INTERMEDIATE)
/* Remainder of first uint32 (words 0 and  1) */
#define TX_ITBSTATUS_LSIG_MASK        0x0000fff0u
#define TX_ITBSTATUS_LSIG_SHIFT        4u
#define TX_ITBSTATUS_TXPOWER_MASK    0xffff0000u
#define TX_ITBSTATUS_TXPOWER_SHIFT    16u
/* Second uint32  (words 2 and 3) */
#define TX_ITBSTATUS_NULL_DELIMS_MASK    0x0007ffffu /* 19 bits * 4B => ~2M bytes */
#define TX_ITBSTATUS_NULL_DELIMS_SHIFT    0u
#define TX_ITBSTATUS_ACKED_MPDUS_MASK    0x3ff80000u /* 11 bits: 0-2047 */
#define TX_ITBSTATUS_ACKED_MPDUS_SHIFT    19u
/* Third uint32 (words 4 and 5) */
#define TX_ITBSTATUS_SENT_MPDUS_MASK    0x0000ffe0u /* 11 bits: 0-2047 */
#define TX_ITBSTATUS_SENT_MPDUS_SHIFT    5u
#define TX_ITBSTATUS_APTXPWR_MASK    0x003f0000u /* 0-60 => -20 - 40 */
#define TX_ITBSTATUS_APTXPWR_SHIFT    16u
#define TX_ITBSTATUS_ULPKTEXT_MASK    0x01c00000u
#define TX_ITBSTATUS_ULPKTEXT_SHIFT    22u
#define TX_ITBSTATUS_MORETF_MASK    0x02000000u
#define TX_ITBSTATUS_MORETF_SHIFT    25u
#define TX_ITBSTATUS_CSREQ_MASK        0x04000000u
#define TX_ITBSTATUS_CSREQ_SHIFT    26u
#define TX_ITBSTATUS_ULBW_MASK        0x18000000u
#define TX_ITBSTATUS_ULBW_SHIFT        27u
#define TX_ITBSTATUS_GI_LTF_MASK    0x60000000u
#define TX_ITBSTATUS_GI_LTF_SHIFT    29u
#define TX_ITBSTATUS_MUMIMO_LTF_MASK    0x80000000u
#define TX_ITBSTATUS_MUMIMO_LTF_SHIFT    30u
/* Fourth uint32 (words 6 and 7) */
#define TX_ITBSTATUS_CODING_TYPE_MASK    0x00000001u
#define TX_ITBSTATUS_CODING_TYPE_SHIFT    0u
#define TX_ITBSTATUS_MCS_MASK        0x0000001eu
#define TX_ITBSTATUS_MCS_SHIFT        1u
#define TX_ITBSTATUS_DCM_MASK        0x00000020u
#define TX_ITBSTATUS_DCM_SHIFT        5u
#define TX_ITBSTATUS_RU_ALLOC_MASK    0x00003fc0u
#define TX_ITBSTATUS_RU_ALLOC_SHIFT    6u
/* Bits 14 and 15 unassigned */
#define TX_ITBSTATUS_NSS_MASK        0x00030000u
#define TX_ITBSTATUS_NSS_SHIFT        16u
#define TX_ITBSTATUS_TARGET_RSSI_MASK    0x03fc0000u
#define TX_ITBSTATUS_TARGET_RSSI_SHIFT    18u
#define TX_ITBSTATUS_RA_RU_MASK        0x04000000u
#define TX_ITBSTATUS_RA_RU_SHIFT    26u
/* Bits 27 through 31 unassigned */
/* End of intermediate TBPPDU txstatus definitions */
 
/* MU group info txstatus field (s3 b[31:16]) */
#define TX_STATUS64_MU_GID_MASK        0x003f0000u
#define TX_STATUS64_MU_GID_SHIFT    16u
#define TX_STATUS64_MU_BW_MASK        0x00c00000u
#define TX_STATUS64_MU_BW_SHIFT        22u
#define TX_STATUS64_MU_TXPWR_MASK    0x7f000000u
#define TX_STATUS64_MU_TXPWR_SHIFT    24u
#define TX_STATUS64_MU_SGI_MASK        0x80000080u
#define TX_STATUS64_MU_SGI_SHIFT    31u
#define TX_STATUS64_INTERM_MUTXCNT(s3) \
   ((s3 & TX_STATUS40_TXCNT_RATE0_MASK) >> TX_STATUS40_TXCNT_RATE0_SHIFT)
 
#define TX_STATUS64_MU_GID(s3) ((s3 & TX_STATUS64_MU_GID_MASK) >> TX_STATUS64_MU_GID_SHIFT)
#define TX_STATUS64_MU_BW(s3) ((s3 & TX_STATUS64_MU_BW_MASK) >> TX_STATUS64_MU_BW_SHIFT)
#define TX_STATUS64_MU_TXPWR(s3) ((s3 & TX_STATUS64_MU_TXPWR_MASK) >> TX_STATUS64_MU_TXPWR_SHIFT)
#define TX_STATUS64_MU_SGI(s3) ((s3 & TX_STATUS64_MU_SGI_MASK) >> TX_STATUS64_MU_SGI_SHIFT)
 
/* MU user info0 txstatus field (s4 b[15:0]) */
#define TX_STATUS64_MU_MCS_MASK        0x0000000f
#define TX_STATUS64_MU_MCS_SHIFT    0
#define TX_STATUS64_MU_NSS_MASK        0x00000070
#define TX_STATUS64_MU_NSS_SHIFT    4
#define TX_STATUS64_MU_SNR_MASK        0x0000ff00
#define TX_STATUS64_MU_SNR_SHIFT    8
 
#define TX_STATUS64_MU_MCS(s4) ((s4 & TX_STATUS64_MU_MCS_MASK) >> TX_STATUS64_MU_MCS_SHIFT)
#define TX_STATUS64_MU_NSS(s4) ((s4 & TX_STATUS64_MU_NSS_MASK) >> TX_STATUS64_MU_NSS_SHIFT)
#define TX_STATUS64_MU_SNR(s4) ((s4 & TX_STATUS64_MU_SNR_MASK) >> TX_STATUS64_MU_SNR_SHIFT)
 
/* MU txstatus rspec field (NSS | MCS) */
#define TX_STATUS64_MU_RSPEC_MASK    (TX_STATUS64_MU_NSS_MASK | TX_STATUS64_MU_MCS_MASK)
#define TX_STATUS64_MU_RSPEC_SHIFT    0
 
#define TX_STATUS64_MU_RSPEC(s4) ((s4 & TX_STATUS64_MU_RSPEC_MASK) >> TX_STATUS64_MU_RSPEC_SHIFT)
 
/* MU user info0 txstatus field (s4 b[31:16]) */
#define TX_STATUS64_MU_GBMP_MASK    0x000f0000
#define TX_STATUS64_MU_GBMP_SHIFT    16
#define TX_STATUS64_MU_GPOS_MASK    0x00300000
#define TX_STATUS64_MU_GPOS_SHIFT    20
#define TX_STATUS64_MU_TXCNT_MASK    0x0fc00000
#define TX_STATUS64_MU_TXCNT_SHIFT    22
 
#define TX_STATUS64_MU_GBMP(s4) ((s4 & TX_STATUS64_MU_GBMP_MASK) >> TX_STATUS64_MU_GBMP_SHIFT)
#define TX_STATUS64_MU_GPOS(s4) ((s4 & TX_STATUS64_MU_GPOS_MASK) >> TX_STATUS64_MU_GPOS_SHIFT)
#define TX_STATUS64_MU_TXCNT(s4) ((s4 & TX_STATUS64_MU_TXCNT_MASK) >> TX_STATUS64_MU_TXCNT_SHIFT)
 
#define HE_MU_APTX_PWR_MAX            60u
#define HE_TXS_MU_APTX_PWR_DBM(aptx_pwr)    ((aptx_pwr) - 20u)
 
#define HE_TXS_MU_TARGET_RSSI_RANG        90
#define HE_TXS_MU_TARGET_RSSI_MAX_PWR        127
#define HE_TXS_MU_TARGET_RSSI_DBM(rssi)        ((rssi) - 110)
 
#define HE_TXS_W4_MU_GET_RU_INDEX(index)    ((index <= HE_MAX_26_TONE_RU_INDX) ? 0u : \
                       ((index) <= HE_MAX_52_TONE_RU_INDX) ? 1u : \
                       ((index) <= HE_MAX_106_TONE_RU_INDX) ? 2u : \
                       ((index) <= HE_MAX_242_TONE_RU_INDX) ? 3u : \
                       ((index) <= HE_MAX_484_TONE_RU_INDX) ? 4u :\
                       ((index) <= HE_MAX_996_TONE_RU_INDX) ? 5u : 6u)
 
/* Bit 8 indicates upper 80 MHz */
#define HE_TXS_W4_MU_RU_INDEX_RU_INDEX_MASK    0x7Fu
#define HE_TXS_W4_MU_RU_INDEX_TONE(index)    HE_TXS_W4_MU_GET_RU_INDEX(((index) & \
                       HE_TXS_W4_MU_RU_INDEX_RU_INDEX_MASK))
 
#define HE_TXS_W3_MU_APTX_PWR_MASK        0x003F0000u
#define HE_TXS_W3_MU_APTX_PWR_SHIFT        16u
#define HE_TXS_W3_MU_PKT_EXT_MASK        0x01C00000u
#define HE_TXS_W3_MU_PKT_EXT_SHIFT        22u
#define HE_TXS_W3_MU_MORE_TF_MASK        0x02000000u
#define HE_TXS_W3_MU_MORE_TF_SHIFT        25u
#define HE_TXS_W3_MU_CS_REQ_MASK        0x04000000u
#define HE_TXS_W3_MU_CS_REQ_SHIFT        26u
#define HE_TXS_W3_MU_UL_BW_MASK            0x18000000u
#define HE_TXS_W3_MU_UL_BW_SHIFT        27u
#define HE_TXS_W3_MU_GI_LTF_MASK        0x60000000u
#define HE_TXS_W3_MU_GI_LTF_SHIFT        29u
#define HE_TXS_W3_MU_MIMO_LTF_MASK        0x80000000u
#define HE_TXS_W3_MU_MIMO_LTF_SHIFT        31u
 
#define HE_TXS_W3_MU_APTX_PWR(s3)        (((s3) & HE_TXS_W3_MU_APTX_PWR_MASK) >> \
                       HE_TXS_W3_MU_APTX_PWR_SHIFT)
#define HE_TXS_W3_MU_PKT_EXT(s3)        (((s3) & HE_TXS_W3_MU_PKT_EXT_MASK) >> \
                       HE_TXS_W3_MU_PKT_EXT_SHIFT)
#define HE_TXS_W3_MU_MORE_TF(s3)        (((s3) & HE_TXS_W3_MU_MORE_TF_MASK) >> \
                       HE_TXS_W3_MU_MORE_TF_SHIFT)
#define HE_TXS_W3_MU_CS_REQ(s3)            (((s3) & HE_TXS_W3_MU_CS_REQ_MASK) >> \
                       HE_TXS_W3_MU_CS_REQ_SHIFT)
#define HE_TXS_W3_MU_UL_BW(s3)            (((s3) & HE_TXS_W3_MU_UL_BW_MASK) >> \
                       HE_TXS_W3_MU_UL_BW_SHIFT)
#define HE_TXS_W3_MU_GI_LTF(s3)            (((s3) & HE_TXS_W3_MU_GI_LTF_MASK) >> \
                       HE_TXS_W3_MU_GI_LTF_SHIFT)
#define HE_TXS_W3_MU_MIMO_LT(s3)        (((s3) & HE_TXS_W3_MU_MIMO_LTF_MASK) >> \
                       HE_TXS_W3_MU_MIMO_LTF_SHIFT)
 
#define HE_TXS_W4_MU_CODINF_TYPE_MASK        0x00000001u
#define HE_TXS_W4_MU_CODINF_TYPE_SHIFT        0u
#define HE_TXS_W4_MU_MCS_MASK            0x0000001Eu
#define HE_TXS_W4_MU_MCS_SHIFT            1u
#define HE_TXS_W4_MU_DCM_MASK            0x00000020u
#define HE_TXS_W4_MU_DCM_SHIFT            5u
#define HE_TXS_W4_RU_ALLOCATION_MASK        0x00003FC0u
#define HE_TXS_W4_RU_ALLOCATION_SHIFT        6u
 
#define HE_TXS_W4_MU_CODINF_TYPE(s4)        (((s4) & HE_TXS_W4_MU_CODINF_TYPE_MASK) >> \
                       HE_TXS_W4_MU_CODINF_TYPE_SHIFT)
#define HE_TXS_W4_MU_MCS(s4)            (((s4) & HE_TXS_W4_MU_MCS_MASK) >> \
                       HE_TXS_W4_MU_MCS_SHIFT)
#define HE_TXS_W4_MU_DCM(s4)            (((s4) & HE_TXS_W4_MU_DCM_MASK) >> \
                       HE_TXS_W4_MU_DCM_SHIFT)
#define HE_TXS_W4_RU_ALLOCATION(s4)        (((s4) & HE_TXS_W4_RU_ALLOCATION_MASK) >> \
                       HE_TXS_W4_RU_ALLOCATION_SHIFT)
 
#define HE_TXS_W4_MU_NSS_MASK            0x00030000u
#define HE_TXS_W4_MU_NSS_SHIFT            16u
#define HE_TXS_W4_MU_TARGET_RSSI_MASK        0x03FC0000u
#define HE_TXS_W4_MU_TARGET_RSSI_SHIFT        18u
 
#define HE_TXS_W4_MU_NSS(s4)            (((s4) & HE_TXS_W4_MU_NSS_MASK) >> \
                       HE_TXS_W4_MU_NSS_SHIFT)
#define HE_TXS_W4_MU_TARGET_RSSI(s4)        (((s4) & HE_TXS_W4_MU_TARGET_RSSI_MASK) >> \
                       HE_TXS_W4_MU_TARGET_RSSI_SHIFT)
 
/* WARNING: Modifying suppress reason codes?
 * Update wlc_tx_status_t and TX_STS_REASON_STRINGS and
 * wlc_tx_status_map_hw_to_sw_supr_code() also
 */
/* status field bit definitions */
/** suppress status reason codes */
enum  {
   TX_STATUS_SUPR_NONE =       0,
   TX_STATUS_SUPR_PMQ =        1,    /**< PMQ entry */
   TX_STATUS_SUPR_FLUSH =      2,    /**< flush request */
   TX_STATUS_SUPR_FRAG =       3,    /**< previous frag failure */
   TX_STATUS_SUPR_TBTT =       3,    /**< SHARED: Probe response supr for TBTT */
   TX_STATUS_SUPR_BADCH =      4,    /**< channel mismatch */
   TX_STATUS_SUPR_EXPTIME =    5,    /**< lifetime expiry */
   TX_STATUS_SUPR_UF =         6,    /**< underflow */
#ifdef WLP2P_UCODE
   TX_STATUS_SUPR_NACK_ABS =   7,    /**< BSS entered ABSENCE period */
#endif
   TX_STATUS_SUPR_PPS   =      8,    /**< Pretend PS */
   TX_STATUS_SUPR_PHASE1_KEY = 9,    /**< Request new TKIP phase-1 key */
   TX_STATUS_UNUSED =          10,    /**< Unused in trunk */
   TX_STATUS_INT_XFER_ERR =    11, /**< Internal DMA xfer error */
   TX_STATUS_SUPR_TWT_SP_OUT = 12, /**< Suppress Tx outside TWTSP */
   NUM_TX_STATUS_SUPR
};
 
/** Unexpected tx status for rate update */
#define TX_STATUS_UNEXP(status) \
   ((((status.is_intermediate))) && \
    TX_STATUS_UNEXP_AMPDU(status))
 
/** Unexpected tx status for A-MPDU rate update */
#ifdef WLP2P_UCODE
#define TX_STATUS_UNEXP_AMPDU(status) \
   ((((status.suppr_ind)) != TX_STATUS_SUPR_NONE) && \
    (((status.suppr_ind)) != TX_STATUS_SUPR_EXPTIME) && \
    (((status.suppr_ind)) != TX_STATUS_SUPR_NACK_ABS))
#else
#define TX_STATUS_UNEXP_AMPDU(status) \
   ((((status.suppr_ind)) != TX_STATUS_SUPR_NONE) && \
    (((status.suppr_ind)) != TX_STATUS_SUPR_EXPTIME))
#endif
 
/**
 * This defines the collection of supp reasons (including none)
 * for which mac has done its (re-)transmission in any of ucode retx schemes
 * which include ucode/hw/aqm agg
 */
#define TXS_SUPR_MAGG_DONE_MASK ((1 << TX_STATUS_SUPR_NONE) | \
       (1 << TX_STATUS_SUPR_UF) |   \
       (1 << TX_STATUS_SUPR_FRAG) | \
       (1 << TX_STATUS_SUPR_EXPTIME))
#define TXS_SUPR_MAGG_DONE(suppr_ind) \
       ((1 << (suppr_ind)) & TXS_SUPR_MAGG_DONE_MASK)
 
#define TX_STATUS_BA_BMAP03_MASK    0xF000    /**< ba bitmap 0:3 in 1st pkg */
#define TX_STATUS_BA_BMAP03_SHIFT    12    /**< ba bitmap 0:3 in 1st pkg */
#define TX_STATUS_BA_BMAP47_MASK    0x001E    /**< ba bitmap 4:7 in 2nd pkg */
#define TX_STATUS_BA_BMAP47_SHIFT    3    /**< ba bitmap 4:7 in 2nd pkg */
 
/* RXE (Receive Engine) */
 
/* RCM_CTL */
#define    RCM_INC_MASK_H        0x0080
#define    RCM_INC_MASK_L        0x0040
#define    RCM_INC_DATA        0x0020
#define    RCM_INDEX_MASK        0x001F
#define    RCM_SIZE        15
 
#define    RCM_MAC_OFFSET        0    /**< current MAC address */
#define    RCM_BSSID_OFFSET    3    /**< current BSSID address */
#define    RCM_F_BSSID_0_OFFSET    6    /**< foreign BSS CFP tracking */
#define    RCM_F_BSSID_1_OFFSET    9    /**< foreign BSS CFP tracking */
#define    RCM_F_BSSID_2_OFFSET    12    /**< foreign BSS CFP tracking */
 
#define RCM_WEP_TA0_OFFSET    16
#define RCM_WEP_TA1_OFFSET    19
#define RCM_WEP_TA2_OFFSET    22
#define RCM_WEP_TA3_OFFSET    25
 
/* AMT - Address Match Table */
 
/* AMT Attribute bits */
#define AMT_ATTR_VALID          0x8000    /**< Mark the table entry valid */
#define AMT_ATTR_A1             0x0008    /**< Match for A1 */
#define AMT_ATTR_A2             0x0004    /**< Match for A2 */
#define AMT_ATTR_A3             0x0002    /**< Match for A3 */
 
/* AMT Index defines */
#define AMT_SIZE_64        64  /* number of AMT entries */
#define AMT_SIZE_128        128 /* number of AMT entries for corerev >= 64 */
#define AMT_IDX_MAC        63    /**< device MAC */
#define AMT_IDX_BSSID        62    /**< BSSID match */
#define AMT_IDX_TRANSMITTED_BSSID      60 /**< transmitted BSSID in multiple BSSID set */
#define AMT_WORD_CNT        2    /* Number of word count per AMT entry */
 
#define AMT_SIZE(_corerev)    (D11REV_GE(_corerev, 64) ? \
   (D11REV_GE(_corerev, 80) ? AMT_SIZE_64 : AMT_SIZE_128) : \
   AMT_SIZE_64)
 
/* RMC entries */
#define AMT_IDX_MCAST_ADDR    61    /**< MCAST address for Reliable Mcast feature */
#define AMT_IDX_MCAST_ADDR1    59    /**< MCAST address for Reliable Mcast feature */
#define AMT_IDX_MCAST_ADDR2    58    /**< MCAST address for Reliable Mcast feature */
#define AMT_IDX_MCAST_ADDR3    57    /**< MCAST address for Reliable Mcast feature */
 
#ifdef WLMESH
/* note: this is max supported by ucode. But ARM-driver can
 * only mesh_info->mesh_max_peers which should be <= this value.
 */
 
#define AMT_MAX_MESH_PEER        10
#define AMT_MAXIDX_MESH_PEER            60
#define AMT_MAXIDX_P2P_USE    \
   (AMT_MAXIDX_MESH_PEER - AMT_MAX_MESH_PEER)
#else
#define AMT_MAXIDX_P2P_USE    60    /**< Max P2P entry to use */
#endif /* WL_STA_MONITOR */
#define AMT_MAX_TXBF_ENTRIES    7    /**< Max tx beamforming entry */
/* PSTA AWARE AP: Max PSTA Tx beamforming entry */
#define AMT_MAX_TXBF_PSTA_ENTRIES    20
 
/* M_AMT_INFO SHM bit field definition */
#define AMTINFO_BMP_IBSS    (1u << 0u)    /* IBSS Station */
#define AMTINFO_BMP_MESH    (1u << 1u)    /* MESH Station */
#define AMTINFO_BMP_BSSID    (1u << 2u)    /* BSSID-only */
#define AMTINFO_BMP_IS_WAPI    (1u << 3u)    /* For WAPI keyid extraction */
#define AMTINFO_BMP_IS_HE    (1u << 13u)    /* For HE peer indication */
 
#define AUXPMQ_ENTRIES        64  /* number of AUX PMQ entries */
#define AUXPMQ_ENTRY_SIZE       8
 
/* PSM Block */
 
/* psm_phy_hdr_param bits */
#define MAC_PHY_RESET        1
#define MAC_PHY_CLOCK_EN    2
#define MAC_PHY_FORCE_CLK    4
#define MAC_IHRP_CLOCK_EN    15
 
/* PSMCoreControlStatus (IHR Address 0x078) bit definitions */
#define PSM_CORE_CTL_AR        (1 << 0)
#define PSM_CORE_CTL_HR        (1 << 1)
#define PSM_CORE_CTL_IR        (1 << 2)
#define PSM_CORE_CTL_AAR    (1 << 3)
#define PSM_CORE_CTL_HAR    (1 << 4)
#define PSM_CORE_CTL_PPAR    (1 << 5)
#define PSM_CORE_CTL_SS        (1 << 6)
#define PSM_CORE_CTL_REHE    (1 << 7)
#define PSM_CORE_CTL_PPAS    (1 << 13)
#define PSM_CORE_CTL_AAS    (1 << 14)
#define PSM_CORE_CTL_HAS    (1 << 15)
 
#define PSM_CORE_CTL_LTR_BIT    9
#define PSM_CORE_CTL_LTR_MASK    0x3
 
#define PSM_SBACCESS_FIFO_MODE    (1 << 1)
#define PSM_SBACCESS_EXT_ERR    (1 << 11)
 
/* WEP Block */
 
/* WEP_WKEY */
#define    WKEY_START        (1 << 8)
#define    WKEY_SEL_MASK        0x1F
 
/* WEP data formats */
 
/* the number of RCMTA entries */
#define RCMTA_SIZE 50
 
/* max keys in M_TKMICKEYS_BLK - 96 * sizeof(uint16) */
#define    WSEC_MAX_TKMIC_ENGINE_KEYS(_corerev) ((D11REV_GE(_corerev, 64)) ? \
   AMT_SIZE(_corerev) : 12) /* 8 + 4 default - 2 mic keys 8 bytes each */
 
/* max keys in M_WAPIMICKEYS_BLK - 64 * sizeof(uint16) */
#define    WSEC_MAX_SMS4MIC_ENGINE_KEYS(_corerev) ((D11REV_GE(_corerev, 64)) ? \
   AMT_SIZE(_corerev) : 8)  /* 4 + 4 default  - 16 bytes each */
 
/* max RXE match registers */
#define WSEC_MAX_RXE_KEYS    4
 
/* SECKINDXALGO (Security Key Index & Algorithm Block) word format */
/* SKL (Security Key Lookup) */
#define    SKL_POST80_ALGO_MASK    0x000F
#define    SKL_PRE80_ALGO_MASK    0x0007
#define    SKL_ALGO_SHIFT        0
 
#define    SKL_ALGO_MASK(_corerev)    (D11REV_GE(_corerev, 80) ? SKL_POST80_ALGO_MASK : \
               SKL_PRE80_ALGO_MASK)
 
#define    SKL_WAPI_KEYID_MASK    0x8000
#define    SKL_WAPI_KEYID_SHIFT    15
#define    SKL_INDEX_SHIFT        4
 
#define    SKL_PRE80_WAPI_KEYID_MASK    0x0008
#define    SKL_PRE80_WAPI_KEYID_SHIFT    3
 
#define SKL_INDEX_MASK(_corerev)   ((D11REV_GE(_corerev, 64)) ? \
   (0x0FF0) : (0x03F0))
#define SKL_GRP_ALGO_MASK(_corerev)   ((D11REV_GE(_corerev, 64)) ? \
   ((D11REV_GE(_corerev, 80)) ? (0xE000) : (0x7000)) : (0x1c00))
#define SKL_GRP_ALGO_SHIFT(_corerev)   ((D11REV_GE(_corerev, 64)) ? \
   ((D11REV_GE(_corerev, 80)) ? (13) : (12)) : (10))
 
#define    SKL_STAMON_NBIT        0x8000 /* STA monitor bit */
 
/* additional bits defined for IBSS group key support */
#define    SKL_IBSS_INDEX_MASK    0x01F0
#define    SKL_IBSS_INDEX_SHIFT    4
#define    SKL_IBSS_KEYID1_MASK    0x0600
#define    SKL_IBSS_KEYID1_SHIFT    9
#define    SKL_IBSS_KEYID2_MASK    0x1800
#define    SKL_IBSS_KEYID2_SHIFT    11
#define    SKL_IBSS_KEYALGO_MASK    0xE000
#define    SKL_IBSS_KEYALGO_SHIFT    13
 
#define    WSEC_MODE_OFF        0
#define    WSEC_MODE_HW        1
#define    WSEC_MODE_SW        2
 
/* Mapped as per HW_ALGO */
#define    WSEC_ALGO_OFF            0
#define    WSEC_ALGO_WEP1            1
#define    WSEC_ALGO_TKIP            2
#define    WSEC_ALGO_WEP128        3
#define    WSEC_ALGO_AES_LEGACY        4
#define    WSEC_ALGO_AES            5
#define    WSEC_ALGO_SMS4            6
#define    WSEC_ALGO_SMS4_DFT_2005_09_07    7    /**< Not used right now */
#define    WSEC_ALGO_NALG            8
 
/* For CORE_REV 80 */
#define    WSEC_ALGO_AES_GCM        8
#define    WSEC_ALGO_AES_GCM256        9
 
/* For CORE_REV Less than 80 and */
#define    WSEC_ALGO_AES_PRE80_GCM        6
#define    WSEC_ALGO_AES_PRE80_GCM256    8
 
/* D11 MAX TTAK INDEX */
#define TSC_TTAK_PRE80_MAX_INDEX 50
#define TSC_TTAK_MAX_INDEX 8
/* D11 COREREV 80 TTAK KEY INDEX SHIFT */
#define    SKL_TTAK_INDEX_SHIFT        13
#define    SKL_TTAK_INDEX_MASK    0xE000
 
/* D11 PRECOREREV 40 Hw algos...changed from corerev 40 */
#define    D11_PRE40_WSEC_ALGO_AES        3
#define    D11_PRE40_WSEC_ALGO_WEP128    4
#define    D11_PRE40_WSEC_ALGO_AES_LEGACY    5
#define    D11_PRE40_WSEC_ALGO_SMS4    6
#define    D11_PRE40_WSEC_ALGO_NALG    7
 
#define D11_WSEC_ALGO_AES(_corerev)    WSEC_ALGO_AES
 
#define    AES_MODE_NONE        0
#define    AES_MODE_CCM        1
#define    AES_MODE_OCB_MSDU    2
#define    AES_MODE_OCB_MPDU    3
#define    AES_MODE_CMAC        4
#define    AES_MODE_GCM        5
#define    AES_MODE_GMAC        6
 
/* WEP_CTL (Rev 0) */
#define    WECR0_KEYREG_SHIFT    0
#define    WECR0_KEYREG_MASK    0x7
#define    WECR0_DECRYPT        (1 << 3)
#define    WECR0_IVINLINE        (1 << 4)
#define    WECR0_WEPALG_SHIFT    5
#define    WECR0_WEPALG_MASK    (0x7 << 5)
#define    WECR0_WKEYSEL_SHIFT    8
#define    WECR0_WKEYSEL_MASK    (0x7 << 8)
#define    WECR0_WKEYSTART        (1 << 11)
#define    WECR0_WEPINIT        (1 << 14)
#define    WECR0_ICVERR        (1 << 15)
 
/* Frame template map byte offsets */
#define    T_ACTS_TPL_BASE        (0)
#define    T_NULL_TPL_BASE        (0xc * 2)
#define    T_QNULL_TPL_BASE    (0x1c * 2)
#define    T_RR_TPL_BASE        (0x2c * 2)
#define    T_BCN0_TPL_BASE        (0x34 * 2)
#define    T_PRS_TPL_BASE        (0x134 * 2)
#define    T_BCN1_TPL_BASE        (0x234 * 2)
#define    T_P2P_NULL_TPL_BASE    (0x340 * 2)
#define    T_P2P_NULL_TPL_SIZE    (32)
#define T_TRIG_TPL_BASE        (0x90 * 2)
 
/* FCBS base addresses and sizes in BM */
 
#define FCBS_DS0_BM_CMD_SZ_CORE0    0x0200    /* 512 bytes */
#define FCBS_DS0_BM_DAT_SZ_CORE0    0x0200    /* 512 bytes */
 
#ifndef FCBS_DS0_BM_CMDPTR_BASE_CORE0
#define FCBS_DS0_BM_CMDPTR_BASE_CORE0    0x3000
#endif
#define FCBS_DS0_BM_DATPTR_BASE_CORE0    (FCBS_DS0_BM_CMDPTR_BASE_CORE0 + FCBS_DS0_BM_CMD_SZ_CORE0)
 
#define FCBS_DS0_BM_CMD_SZ_CORE1    0x0200    /* 512 bytes */
#define FCBS_DS0_BM_DAT_SZ_CORE1    0x0200    /* 512 bytes */
 
#ifndef FCBS_DS0_BM_CMDPTR_BASE_CORE1
#define FCBS_DS0_BM_CMDPTR_BASE_CORE1    0x2400
#endif
#define FCBS_DS0_BM_DATPTR_BASE_CORE1    (FCBS_DS0_BM_CMDPTR_BASE_CORE1 + FCBS_DS0_BM_CMD_SZ_CORE1)
 
#define FCBS_DS0_BM_CMD_SZ_CORE2    0x0200    /* 512 bytes */
#define FCBS_DS0_BM_DAT_SZ_CORE2    0x0200    /* 512 bytes */
 
#define FCBS_DS1_BM_CMD_SZ_CORE0    0x2000    /* Not used */
#define FCBS_DS1_BM_DAT_SZ_CORE0    0x2000    /* Not used */
 
#define FCBS_DS1_BM_CMDPTR_BASE_CORE0    0x17B4
#define FCBS_DS1_BM_DATPTR_BASE_CORE0    (FCBS_DS1_BM_CMDPTR_BASE_CORE0 + FCBS_DS1_BM_CMD_SZ_CORE0)
 
#define FCBS_DS1_BM_CMD_SZ_CORE1    0x2000    /* Not used */
#define FCBS_DS1_BM_DAT_SZ_CORE1    0x2000    /* Not used */
 
#define FCBS_DS1_BM_CMDPTR_BASE_CORE1    0x17B4
#define FCBS_DS1_BM_DATPTR_BASE_CORE1    (FCBS_DS1_BM_CMDPTR_BASE_CORE1 + FCBS_DS1_BM_CMD_SZ_CORE1)
 
#define T_BA_TPL_BASE        T_QNULL_TPL_BASE    /**< template area for BA */
 
#define T_RAM_ACCESS_SZ        4    /**< template ram is 4 byte access only */
 
#define TPLBLKS_PER_BCN_NUM    2
#define TPLBLKS_AC_PER_BCN_NUM    1
 
#if defined(WLLPRS) && defined(MBSS)
#define TPLBLKS_PER_PRS_NUM    4
#define TPLBLKS_AC_PER_PRS_NUM    2
#else
#define TPLBLKS_PER_PRS_NUM    2
#define TPLBLKS_AC_PER_PRS_NUM    1
#endif /* WLLPRS && MBSS */
 
/* MAC Sample Collect Params */
 
/* SampleCapture set-up options in
 * different registers based on CoreRev
 */
/* CoreRev >= 50, use SMP_CTRL in TXE_IHR */
#define SC_SRC_MAC        2 /* MAC as Sample Collect Src */
#define SC_SRC_SHIFT        3 /* SC_SRC bits [3:4] */
#define    SC_TRIG_SHIFT        5
#define SC_TRANS_SHIFT        6
#define SC_MATCH_SHIFT        7
#define SC_STORE_SHIFT        8
 
#define SC_STRT        1
#define SC_TRIG_EN    (1 << SC_TRIG_SHIFT)
#define SC_TRANS_EN    (1 << SC_TRANS_SHIFT)
#define SC_MATCH_EN    (1 << SC_MATCH_SHIFT)
#define SC_STORE_EN    (1 << SC_STORE_SHIFT)
 
/* CoreRev < 50, use PHY_CTL in PSM_IHR */
#define PHYCTL_PHYCLKEN        (1 << 1)
#define PHYCTL_FORCE_GATED_CLK_ON        (1 << 2)
#define PHYCTL_SC_STRT        (1 << 4)
#define PHYCTL_SC_SRC_LB    (1 << 7)
#define PHYCTL_SC_TRIG_EN    (1 << 8)
#define PHYCTL_SC_TRANS_EN    (1 << 9)
#define PHYCTL_SC_STR_EN    (1 << 10)
#define PHYCTL_IHRP_CLK_EN    (1 << 15)
/* End MAC Sample Collect Params */
 
#define ANTSEL_CLKDIV_4MHZ    6
#define MIMO_ANTSEL_BUSY    0x4000        /**< bit 14 (busy) */
#define MIMO_ANTSEL_SEL        0x8000        /**< bit 15 write the value */
#define MIMO_ANTSEL_WAIT    50        /**< 50us wait */
#define MIMO_ANTSEL_OVERRIDE    0x8000        /**< flag */
 
typedef struct shm_acparams shm_acparams_t;
BWL_PRE_PACKED_STRUCT struct shm_acparams {
   uint16    txop;
   uint16    cwmin;
   uint16    cwmax;
   uint16    cwcur;
   uint16    aifs;
   uint16    bslots;
   uint16    reggap;
   uint16    status;
   uint16  txcnt;
   uint16    rsvd[7];
} BWL_POST_PACKED_STRUCT;
 
#define WME_STATUS_NEWAC    (1 << 8)
 
/* M_HOST_FLAGS */
#define MHFMAX        5 /* Number of valid hostflag half-word (uint16) */
#define MHF1        0 /* Hostflag 1 index */
#define MHF2        1 /* Hostflag 2 index */
#define MHF3        2 /* Hostflag 3 index */
#define MHF4        3 /* Hostflag 4 index */
#define MHF5        4 /* Hostflag 5 index */
 
#define MXHFMAX        1 /* Number of valid PSMx hostflag half-word (uint16) */
#define MXHF0        64 /* PSMx Hostflag 0 index */
 
/* Flags in M_HOST_FLAGS */
#define    MHF1_D11AC_DYNBW    0x0001    /**< dynamic bw */
#define MHF1_WLAN_CRITICAL    0x0002    /**< WLAN is in critical state */
#define    MHF1_MBSS_EN        0x0004    /**< Enable MBSS: RXPUWAR deprecated for rev >= 9 */
#define    MHF1_BTCOEXIST        0x0010    /**< Enable Bluetooth / WLAN coexistence */
#define    MHF1_P2P_SKIP_TIME_UPD    0x0020    /**< Skip P2P SHM updates and P2P event generations */
#define    MHF1_TXMUTE_WAR        0x0040    /**< ucode based Tx mute */
#define    MHF1_RXFIFO1        0x0080    /**< Switch data reception from RX fifo 0 to fifo 1 */
#define    MHF1_EDCF        0x0100    /**< Enable EDCF access control */
#define MHF1_ULP        0x0200    /**< Force Ucode to put chip in low power state */
#define    MHF1_FORCE_SEND_BCN    0x0800    /**< Force send bcn, even if rcvd from peer STA (IBSS) */
#define    MHF1_TIMBC_EN        0x1000    /**< Enable Target TIM Transmission Time function */
#define MHF1_RADARWAR        0x2000    /**< Enable Radar Detect WAR PR 16559 */
#define MHF1_DEFKEYVALID    0x4000    /**< Enable use of the default keys */
#define    MHF1_CTS2SELF        0x8000    /**< Enable CTS to self full phy bw protection */
 
/* Flags in M_HOST_FLAGS2 */
#define MHF2_DISABLE_PRB_RESP    0x0001    /**< disable Probe Response in ucode */
#define MHF2_HIB_FEATURE_ENABLE    0x0008    /* Enable HIB feature in ucode (60<=rev<80) */
#define MHF2_SKIP_ADJTSF    0x0010    /**< skip TSF update when receiving bcn/probeRsp */
#define MHF2_RSPBW20        0x0020    /**< Uses bw20 for response frames ack/ba/cts */
#define MHF2_TXBCMC_NOW        0x0040    /**< Flush BCMC FIFO immediately */
#define MHF2_PPR_HWPWRCTL    0x0080    /**< TSSI_DIV WAR (rev<80) */
#define MHF2_BTC2WIRE_ALTGPIO    0x0100    /**< BTC 2wire in alternate pins */
#define MHF2_BTCPREMPT        0x0200    /**< BTC enable bluetooth check during tx */
#define MHF2_SKIP_CFP_UPDATE    0x0400    /**< Skip CFP update ; for d11 rev <= 80 */
#define MHF2_TX_TMSTMP        0x0800    /**< Enable passing tx-timestamps in tx-status */
#define MHF2_UFC_GE84        0x2000    /**< Enable UFC in CT mode */
#define MHF2_NAV_NORST_WAR    0x4000    /**< WAR to use rogue NAV duration */
#define MHF2_BTCANTMODE        0x4000    // OBSOLETE (TO BE REMOVED)
 
/* Flags in M_HOST_FLAGS3 */
#define MHF3_ANTSEL_EN        0x0001    /**< enabled mimo antenna selection (REV<80) */
#define MHF3_TKIP_FRAG_WAR    0x0001    /**< TKIP fragment corrupt WAR (REV>=80) */
#define MHF3_TXSHAPER_EN    0x0002    /** enable tx shaper for non-OFDM-A frames */
#define MHF3_ANTSEL_MODE    0x0002    /**< antenna selection mode: 0: 2x3, 1: 2x4 (REV<80) */
#define MHF3_BTCX_DEF_BT    0x0004    /**< corerev >= 13 BT Coex. */
#define MHF3_BTCX_ACTIVE_PROT    0x0008    /**< corerev >= 13 BT Coex. */
#define MHF3_PKTENG_PROMISC    0x0010    /**< pass frames to driver in packet engine Rx mode */
#define MHF3_SCANCORE_PM_EN    0x0040    /**< enable ScanCore PM from ucode */
#define MHF3_PM_BCNRX        0x0080    /**< PM single core beacon RX for power reduction */
#define MHF3_BTCX_SIM_RSP    0x0100    /**< allow limited lwo power tx when BT is active */
#define MHF3_BTCX_PS_PROTECT    0x0200    /**< use PS mode to protect BT activity */
#define MHF3_BTCX_SIM_TX_LP    0x0400    /**< use low power for simultaneous tx responses */
#define MHF3_SELECT_RXF1    0x0800    /**< enable frame classification in pcie FD */
#define MHF3_BTCX_ECI        0x1000    /**< Enable BTCX ECI interface */
#define MHF3_NOISECAL_ENHANCE   0x2000
 
/* Flags in M_HOST_FLAGS4 */
#define MHF4_RCMTA_BSSID_EN    0x0002  /**< BTAMP: multiSta BSSIDs matching in RCMTA area */
#define MHF4_SC_MIX_EN        0x0002  /**< set to enable 4389a0 specific changes */
#define    MHF4_BCN_ROT_RR        0x0004    /**< MBSSID: beacon rotate in round-robin fashion */
#define    MHF4_OPT_SLEEP        0x0008    /**< enable opportunistic sleep (REV<80) */
#define MHF4_PM_OFFLOAD        0x0008    /**< enable PM offload */
#define    MHF4_PROXY_STA        0x0010    /**< enable proxy-STA feature */
#define MHF4_AGING        0x0020    /**< Enable aging threshold for RF awareness */
#define MHF4_STOP_BA_ON_NDP    0x0080    /**< Stop BlockAck to AP to get chance to send NULL data */
#define MHF4_NOPHYHANGWAR    0x0100  /**< disable ucode WAR for idletssi cal (rev=61) */
#define MHF4_WMAC_ACKTMOUT    0x0200    /**< reserved for WMAC testing */
#define MHF4_NAPPING_ENABLE    0x0400    /**< Napping enable (REV<80) */
#define MHF4_IBSS_SEC        0x0800    /**< IBSS WPA2-PSK operating mode */
#define MHF4_SISO_BCMC_RX    0x1000    /* Disable switch to MIMO on recving multicast TIM */
#define MHF4_RSDB_CR1_MINIPMU_CAL_EN    0x8000        /* for 4349B0. JIRA:SW4349-1469 */
 
/* Flags in M_HOST_FLAGS5 */
#define MHF5_BTCX_LIGHT         0x0002    /**< light coex mode, off txpu only for critical BT */
#define MHF5_BTCX_PARALLEL      0x0004    /**< BT and WLAN run in parallel. */
#define MHF5_BTCX_DEFANT        0x0008    /**< default position for shared antenna */
#define MHF5_P2P_MODE        0x0010    /**< Enable P2P mode */
#define MHF5_LEGACY_PRS        0x0020    /**< Enable legacy probe resp support */
#define MHF5_HWRSSI_EN        0x0800    /**< Enable HW RSSI (ac) */
#define MHF5_HIBERNATE        0x1000    /**< Force ucode to power save until wake-bit */
#define MHF5_BTCX_GPIO_DEBUG    0x4000    /**< Enable gpio pins for btcoex ECI signals */
#define MHF5_SUPPRESS_PRB_REQ    0x8000    /**< Suppress probe requests at ucode level */
 
/* Flags in M_HOST_FLAGS6 */
#define MHF6_TXPWRCAP_RST_EN    0x0001 /** < Ucode clear phyreg after each tx */
#define MHF6_TXPWRCAP_EN        0x0002 /** < Enable TX power capping in ucode */
#define MHF6_TSYNC_AVB          0x0004  /** Enable AVB for timestamping */
#define MHF6_TSYNC_3PKG        0x0020 /** < Enable 3rd txstatus package */
#define MHF6_TDMTX        0x0040 /** < Enable SDB TDM in ucode */
#define MHF6_TSYNC_NODEEPSLP    0x0080 /** < Disable deep sleep to keep AVB clock */
#define MHF6_TSYNC_CAL          0x0100 /** < Enable Tsync cal in ucode */
#define MHF6_TXPWRCAP_IOS_NBIT  0x0200 /** < Enable IOS mode of operation for Txpwrcap (REV>=80) */
#define MHF6_MULBSSID_NBIT      0x0400 /** < associated to AP belonging to a multiple BSSID set */
#define MHF6_HEBCN_TX_NBIT      0x0800 /** < HE BCN-TX */
#define MHF6_LATENCY_EN        0x2000 /** < Enable Latency instrumentation in ucode */
#define MHF6_PTMSTS_EN          0x4000 /** < Enable PTM Status */
 
/* MX_HOST_FLAGS */
/* Flags for MX_HOST_FLAGS0 */
#define MXHF0_RSV0        0x0001        /* ucode internal, not exposed yet */
#define MXHF0_TXDRATE        0x0002        /* mu txrate to use rate from txd */
#define MXHF0_CHKFID        0x0004        /* check if frameid->fifo matches hw txfifo idx */
#define MXHF0_DISWAR        0x0008        /* disable some WAR. */
 
/* M_AXC_HOST_FLAGS0 */
#define MAXCHF0_WAIT_TRIG    0x0001        /* Hold frames till trigger frame is rxed */
#define MAXCHF0_HTC_SUPPORT    0x0002        /* 11AX HTC field support */
#define MAXCHF0_AX_ASSOC_SHIFT    0x0003        /* 11AX association indicator */
#define MAXCHF0_HEB_CONFIG    0x0004        /* HEB configuration */
#define MAXCHF0_ACI_DET        0x0008        /* ACI detect soft enable */
#define MAXCHF0_TRIGRES_LP    0x0010        /* Lite-Point testing */
#define MAXCHF0_HDRCONV_SHIFT    5u        /* Enable header conversion */
#define MAXCHF0_HDRCONV        (1 << MAXCHF0_HDRCONV_SHIFT)
#define MAXCHF0_FORCE_ZERO_PPR_SHIFT    6u    /* Force PPR value to 0 for ULTPC */
#define MAXCHF0_FORCE_ZERO_PPR    (1 << MAXCHF0_FORCE_ZERO_PPR_SHIFT)
#define MAXCHF0_DISABLE_PYLDECWAR_SHIFT    7u    /* Disable WAR for Paydecode issue */
#define MAXCHF0_DISABLE_PYLDECWAR (1 << MAXCHF0_DISABLE_PYLDECWAR_SHIFT)
#define MAXCHF0_BSR_SUPPORT_SHIFT    8u    /* BSR is supported */
#define MAXCHF0_BSR_SUPPORT (1 << MAXCHF0_BSR_SUPPORT_SHIFT)
#define MAXCHF0_MUEDCA_VALID_SHIFT    9u    /* MUEDCA information is valid */
#define MAXCHF0_MUEDCA_VALID (1 << MAXCHF0_MUEDCA_VALID_SHIFT)
/* Bit 10 definition missing? */
#define MAXCHF0_TWT_PKTSUPP_SHIFT    11u    /* Enable pkt suppress outside TWT SP */
#define MAXCHF0_TWT_PKTSUPP_EN    (1 << MAXCHF0_TWT_PKTSUPP_SHIFT)
#define MAXCHF0_TBPPDU_STATUS_SHIFT    12u
#define MAXCHF0_TBPPDU_STATUS_EN    (1 << MAXCHF0_TBPPDU_STATUS_SHIFT)
#define MAXCHF0_11AX_TXSTATUS_EXT_SHIFT 13u     /* Enable 128 BA pkg in TX status */
#define MAXCHF0_11AX_TXSTATUS_EXT_EN    (1u << MAXCHF0_11AX_TXSTATUS_EXT_SHIFT)
#define MAXCHF1_11AX_TXSTATUS_EXT_SHIFT 0u  /* Enable 256 BA pkg in TX status */
#define MAXCHF1_11AX_TXSTATUS_EXT_EN    (1u << MAXCHF1_11AX_TXSTATUS_EXT_SHIFT)
/* Bit 14 for UORA_EN */
#define MAXCHF0_11AX_UORA_SHIFT        14u    /* Enable UORA support */
#define MAXCHF0_11AX_UORA_EN        (1u << MAXCHF0_11AX_UORA_SHIFT)
 
/* M_AXC_HOST_FLAGS1 */
#define MAXCHF1_ITXSTATUS_EN        0x0004u          /* Enable intermediate txs for TB PPDU */
#define MAXCHF1_OBSSHWSTATS_EN        0x0008u    /* Enable ucode OBSS stats monitoring */
 
/* M_SC_HOST_FLAGS */
#define C_SCCX_STATS_EN            0x0001u        /* Enable SC stats */
#define C_SC_BTMC_COEX_EN        0x0002u        /* Enable WLSC-BTMC coex */
 
/** Short version of receive frame status. Only used for non-last MSDU of AMSDU - rev61.1 */
typedef struct d11rxhdrshort_rev61_1 d11rxhdrshort_rev61_1_t;
BWL_PRE_PACKED_STRUCT struct d11rxhdrshort_rev61_1 {
   uint16 RxFrameSize;    /**< Actual byte length of the frame data received */
 
   /* These two 8-bit fields remain in the same order regardless of
    * processor byte order.
    */
   uint8 dma_flags;    /**< bit 0 indicates short or long rx status. 1 == short. */
   uint8 fifo;         /**< rx fifo number */
   uint16 mrxs;        /**< MAC Rx Status */
   uint16 RxFrameSize0;    /**< rxframesize for fifo-0 (in bytes). */
   uint16 HdrConvSt;   /**< hdr conversion status. Copy of ihr(RCV_HDR_CTLSTS). */
   uint16 RxTSFTimeL;  /**< RxTSFTime time of first MAC symbol + M_PHY_PLCPRX_DLY */
   uint16 RxTSFTimeH;  /**< RxTSFTime time of first MAC symbol + M_PHY_PLCPRX_DLY */
   uint16 aux_status;  /**< DMA writes into this field. ucode treats as reserved. */
} BWL_POST_PACKED_STRUCT;
 
/** Short version of receive frame status. Only used for non-last MSDU of AMSDU - pre80 */
typedef struct d11rxhdrshort_lt80 d11rxhdrshort_lt80_t;
BWL_PRE_PACKED_STRUCT struct d11rxhdrshort_lt80 {
   uint16 RxFrameSize;    /**< Actual byte length of the frame data received */
 
   /* These two 8-bit fields remain in the same order regardless of
    * processor byte order.
    */
   uint8 dma_flags;    /**< bit 0 indicates short or long rx status. 1 == short. */
   uint8 fifo;         /**< rx fifo number */
   uint16 mrxs;        /**< MAC Rx Status */
   uint16 RxTSFTime;   /**< RxTSFTime time of first MAC symbol + M_PHY_PLCPRX_DLY */
   uint16 HdrConvSt;   /**< hdr conversion status. Copy of ihr(RCV_HDR_CTLSTS). */
   uint16 aux_status;  /**< DMA writes into this field. ucode treats as reserved. */
} BWL_POST_PACKED_STRUCT;
 
/* Errflag bits for ge80 */
#define ERRFLAGS_ERR_STATE           0x0003u
#define ERRFLAGS_GREATER_MSDU_LEN    0x0001u
#define ERRFLAGS_AMSDU_TRUNCATED     0x0002u
#define ERRFLAGS_HDRCONV_MASK        0x00F0u
#define ERRFLAGS_HDRCONV_SHIFT            4u
#define ERRFLAGS_CSI_LEN_64K         0x0100u
#define ERRFLAGS_MESH_FMT_ERR        0x0200u
 
/* Register 'D11_RXE_ERRVAL' bits for ge80 */
#define RXEERR_GREATER_MSDU_LEN     (1u << 6)
 
/* 128 BA configuration */
/* Register D11_TXBA_DataSel bits for ge80 */
#define TXBA_DATASEL_WSIZE_BITMAP_LEN_ENC_SEL   (1u << 0u)
 
/* Register D11_TXBA_Data bits (ge80) */
#define TXBA_DATA_WSIZE_256             (0x100u)
#define TXBA_DATA_WSIZE_128             (0x80u)
#define TXBA_DATA_WSIZE_64              (0x40u)
 
/* HW optimisation to generate bitmap based on start SSN & max SSN */
#define TXBA_DATA_HW_CONST              (0xfu << 12)
 
/* Register D11_RXE_BA_LEN bits (ge80) */
#define RXE_BA_LEN_RXBA_64              (0x0u)
#define RXE_BA_LEN_RXBA_128             (0x1u)
#define RXE_BA_LEN_RXBA_256             (0x2u)
#define RXE_BA_LEN_TID0_SHIFT           (0u)
#define RXE_BA_LEN_TID1_SHIFT           (2u)
#define RXE_BA_LEN_TID2_SHIFT           (4u)
#define RXE_BA_LEN_TID3_SHIFT           (6u)
#define RXE_BA_LEN_TID4_SHIFT           (8u)
#define RXE_BA_LEN_TID5_SHIFT           (10u)
#define RXE_BA_LEN_TID6_SHIFT           (12u)
#define RXE_BA_LEN_TID7_SHIFT           (14u)
 
/* Register D11_RXE_BA_LEN_ENC bits (ge80) */
#define RXE_BA_LEN_ENC_BA32_VAL         (0x3u << 0u)
#define RXE_BA_LEN_ENC_BA64_VAL         (0x0u << 2u)
#define RXE_BA_LEN_ENC_BA128_VAL        (0x1u << 4u)
#define RXE_BA_LEN_ENC_BA256_VAL        (0x2u << 6u)
 
/* Register D11_RXE_TXBA_CTL2 (ge80) */
#define RXE_TXBA_CTL2_CONIG_SINGLE_TID  (0x0u << 0u)
#define RXE_TXBA_CTL2_CONIG_ALL_TID     (0x1u << 0u)
#define RXE_TXBA_CTL2_SEL_TID0          (0x0u << 12u)
#define RXE_TXBA_CTL2_SEL_TID1          (0x1u << 12u)
#define RXE_TXBA_CTL2_SEL_TID2          (0x2u << 12u)
#define RXE_TXBA_CTL2_SEL_TID3          (0x3u << 12u)
#define RXE_TXBA_CTL2_SEL_TID4          (0x4u << 12u)
#define RXE_TXBA_CTL2_SEL_TID5          (0x5u << 12u)
#define RXE_TXBA_CTL2_SEL_TID6          (0x6u << 12u)
#define RXE_TXBA_CTL2_SEL_TID7          (0x7u << 12u)
 
/**
 * Special Notes
 * #1: dma_flags, fifo
 * These two 8-bit fields remain in the same order regardless of
 * processor byte order.
 * #2: pktclass
 * 16 bit bitmap is a result of Packet (or Flow ) Classification.
 *
 *    0    :    Flow ID Different
 *    1,2,3    :    A1, A2, A3 Different
 *    4    :    TID Different
 *    5, 6    :    DA, SA from AMSDU SubFrame Different
 *    7    :    FC Different
 *    8    :    AMPDU boundary
 *    9 - 15    :    Reserved
 * #3: errflags
 * These bits indicate specific errors detected by the HW on the Rx Path.
 * However, these will be relevant for Last MSDU Status only.
 *
 * Whenever there is an error at any MSDU, HW treats it as last
 * MSDU and send out last MSDU status.
 */
 
#define D11RXHDR_HW_STATUS_GE80 \
   uint16 RxFrameSize;    /**< Actual byte length of the frame data received */ \
   /* For comments see special note #1 above */\
   uint8 dma_flags;    /**< bit 0 indicates short or long rx status. 1 == short. */ \
   uint8 fifo;        /**< rx fifo number */ \
   \
   uint16 mrxs;        /**< MAC Rx Status */ \
   uint16 RxFrameSize0;    /**< rxframesize for fifo-0 (in bytes). */ \
   uint16 HdrConvSt;    /**< hdr conversion status. Copy of ihr(RCV_HDR_CTLSTS). */ \
   uint16 pktclass; \
   uint32 filtermap;    /**< 32 bit bitmap indicates which "Filters" have matched. */ \
   /* For comments see special note #2 above */ \
   uint16 flowid;        /**< result of Flow ID Look Up performed by the HW. */ \
   /* For comments see special note #3 above */\
   uint16 errflags;
 
#define D11RXHDR_UCODE_STATUS_GE80 \
   /**< Ucode Generated Status (16 Bytes) */ \
   uint16 RxStatus1;        /**< MAC Rx Status */ \
   uint16 RxStatus2;        /**< extended MAC Rx status */ \
   uint16 RxChan;            /**< Rx channel info or chanspec */ \
   uint16 AvbRxTimeL;        /**< AVB RX timestamp low16 */ \
   uint16 AvbRxTimeH;        /**< AVB RX timestamp high16 */ \
   uint16 RxTSFTime;        /**< Lower 16 bits of Rx timestamp */ \
   uint16 RxTsfTimeH;        /**< Higher 16 bits of Rx timestamp */ \
   uint16 MuRate;            /**< MU rate info (bit3:0 MCS, bit6:4 NSTS) */
 
#define D11RXHDR_HW_STATUS_GE87_1       /**< HW Generated 24 bytes RX Status           */ \
   D11RXHDR_HW_STATUS_GE80        /**< First 20 bytes are same as mac rev >= 80  */ \
   uint16 roe_hw_sts;        /**< ROE HW status                             */ \
   uint16 roe_err_flags;        /**< ROE error flags                           */
 
#define D11RXHDR_UCODE_STATUS_GE87_1    /**< Ucode Generated Status (22 Bytes)         */ \
   uint16 RxStatus1;        /**< MAC Rx Status                             */ \
   uint16 RxStatus2;        /**< extended MAC Rx status                    */ \
   uint16 RxChan;            /**< Rx channel info or chanspec               */ \
   uint16 MuRate;            /**< MU rate info (bit3:0 MCS, bit6:4 NSTS)    */ \
   uint32 AVBRxTime;        /**< 32 bit AVB timestamp                      */ \
   uint32 TSFRxTime;        /**< 32 bit TSF timestamp                      */ \
   uint64 PTMRxTime;        /**< 64 bit PTM timestamp                      */
 
   /**< HW Generated Status (20 Bytes) */
/** Short version of receive frame status. Only used for non-last MSDU of AMSDU - rev80 */
typedef struct d11rxhdrshort_ge87_1 d11rxhdrshort_ge87_1_t;
BWL_PRE_PACKED_STRUCT struct d11rxhdrshort_ge87_1 {
 
   D11RXHDR_HW_STATUS_GE87_1
 
} BWL_POST_PACKED_STRUCT;
 
/** Mid version of receive frame status. Only used for MPDU of AMPDU - rev80 */
typedef struct d11rxhdrmid_ge87_1 d11rxhdrmid_ge87_1_t;
BWL_PRE_PACKED_STRUCT struct d11rxhdrmid_ge87_1 {
 
   D11RXHDR_HW_STATUS_GE87_1
   D11RXHDR_UCODE_STATUS_GE87_1
} BWL_POST_PACKED_STRUCT;
 
/** Short version of receive frame status. Only used for non-last MSDU of AMSDU - rev80 */
typedef struct d11rxhdrshort_ge80 d11rxhdrshort_ge80_t;
BWL_PRE_PACKED_STRUCT struct d11rxhdrshort_ge80 {
 
   D11RXHDR_HW_STATUS_GE80
 
} BWL_POST_PACKED_STRUCT;
 
/** Mid version of receive frame status. Only used for MPDU of AMPDU - rev80 */
typedef struct d11rxhdrmid_ge80 d11rxhdrmid_ge80_t;
BWL_PRE_PACKED_STRUCT struct d11rxhdrmid_ge80 {
 
   D11RXHDR_HW_STATUS_GE80
   D11RXHDR_UCODE_STATUS_GE80
 
} BWL_POST_PACKED_STRUCT;
 
/** Receive Frame Data Header - pre80 */
typedef struct d11rxhdr_lt80 d11rxhdr_lt80_t;
BWL_PRE_PACKED_STRUCT struct d11rxhdr_lt80 {
   uint16 RxFrameSize;    /**< Actual byte length of the frame data received */
 
   /**
    * These two 8-bit fields remain in the same order regardless of
    * processor byte order.
    */
   uint8 dma_flags;    /* bit 0 indicates short or long rx status. 1 == short. */
   uint8 fifo;         /* rx fifo number */
 
   uint16 PhyRxStatus_0;    /**< PhyRxStatus 15:0 */
   uint16 PhyRxStatus_1;    /**< PhyRxStatus 31:16 */
   uint16 PhyRxStatus_2;    /**< PhyRxStatus 47:32 */
   uint16 PhyRxStatus_3;    /**< PhyRxStatus 63:48 */
   uint16 PhyRxStatus_4;    /**< PhyRxStatus 79:64 */
   uint16 PhyRxStatus_5;    /**< PhyRxStatus 95:80 */
   uint16 RxStatus1;    /**< MAC Rx Status */
   uint16 RxStatus2;    /**< extended MAC Rx status */
 
   /**
    * - RxTSFTime time of first MAC symbol + M_PHY_PLCPRX_DLY
    */
   uint16 RxTSFTime;
 
   uint16 RxChan;        /**< Rx channel info or chanspec */
   uint16 RxFrameSize0;    /**< size of rx-frame in fifo-0 in case frame is copied to fifo-1 */
   uint16 HdrConvSt;    /**< hdr conversion status. Copy of ihr(RCV_HDR_CTLSTS). */
   uint16 AvbRxTimeL;    /**< AVB RX timestamp low16 */
   uint16 AvbRxTimeH;    /**< AVB RX timestamp high16 */
   uint16 MuRate;        /**< MU rate info (bit3:0 MCS, bit6:4 NSTS) */
   /**
    * These bits indicate specific errors detected by the HW on the Rx Path.
    * However, these will be relevant for Last MSDU Status only.
    *
    * Whenever there is an error at any MSDU, HW treats it as last
    * MSDU and send out last MSDU status.
    */
   uint16 errflags;
} BWL_POST_PACKED_STRUCT;
 
#define N_PRXS_GE80    16        /* Total number of PhyRx status words for corerev >= 80 */
#define N_PRXS_LT80    6        /* Total number of PhyRx status words for corerev < 80 */
 
/* number of PhyRx status words newly added for (corerev >= 80) */
#define N_PRXS_REM_GE80    (N_PRXS_GE80 - N_PRXS_LT80)
 
/** RX Hdr definition - rev80 */
typedef struct d11rxhdr_ge80 d11rxhdr_ge80_t;
BWL_PRE_PACKED_STRUCT struct d11rxhdr_ge80 {
   /**
    * Even though rxhdr can be in short or long format, always declare it here
    * to be in long format. So the offsets for the other fields are always the same.
    */
 
   /**< HW Generated Status (20 Bytes) */
   D11RXHDR_HW_STATUS_GE80
   D11RXHDR_UCODE_STATUS_GE80
 
   /**< PHY Generated Status (32 Bytes) */
   uint16 PhyRxStatus_0;        /**< PhyRxStatus 15:0 */
   uint16 PhyRxStatus_1;        /**< PhyRxStatus 31:16 */
   uint16 PhyRxStatus_2;        /**< PhyRxStatus 47:32 */
   uint16 PhyRxStatus_3;        /**< PhyRxStatus 63:48 */
   uint16 PhyRxStatus_4;        /**< PhyRxStatus 79:64 */
   uint16 PhyRxStatus_5;        /**< PhyRxStatus 95:80 */
   uint16 phyrxs_rem[N_PRXS_REM_GE80];    /**< 20 bytes of remaining prxs (corerev >= 80) */
   /* Currently only 6 words are being pushed out of uCode: 6, 9, 16, 17, 21, 23 */
} BWL_POST_PACKED_STRUCT;
 
#define N_PRXS_GE85    32u    // total number of PhyRxStatus BYTEs for rev >= 85
 
typedef struct d11rxhdr_ge87_1 d11rxhdr_ge87_1_t;
BWL_PRE_PACKED_STRUCT struct d11rxhdr_ge87_1 {
   /**
    * Even though rxhdr can be in short or long format, always declare it here
    * to be in long format. So the offsets for the other fields are always the same.
    */
 
   D11RXHDR_HW_STATUS_GE87_1       /**< HW Generated Status (24 Bytes)    */
   D11RXHDR_UCODE_STATUS_GE87_1    /**< uCode Generated Status (24 Bytes) */
   uint8 PHYRXSTATUS[N_PRXS_GE85]; /**< PHY Generated Status (32 Bytes)   */
} BWL_POST_PACKED_STRUCT;
 
/* A wrapper structure for all versions of d11rxh short structures */
typedef struct d11rxhdr_ge85 d11rxhdr_ge85_t;
BWL_PRE_PACKED_STRUCT struct d11rxhdr_ge85 {
   /**
    * Even though rxhdr can be in short or long format, always declare it here
    * to be in long format. So the offsets for the other fields are always the same.
    */
 
   /**< HW Generated Status (20 Bytes) */
   D11RXHDR_HW_STATUS_GE80
   D11RXHDR_UCODE_STATUS_GE80
 
   /**< PHY Generated Status (32 Bytes) */
   uint8 PHYRXSTATUS[N_PRXS_GE85];
} BWL_POST_PACKED_STRUCT;
 
/* A wrapper structure for all versions of d11rxh short structures */
typedef union d11rxhdrshort {
   d11rxhdrshort_rev61_1_t rev61_1;
   d11rxhdrshort_lt80_t lt80;
   d11rxhdrshort_ge80_t ge80;
   d11rxhdrshort_ge87_1_t ge87_1;
} d11rxhdrshort_t;
 
/* A wrapper structure for all versions of d11rxh mid structures */
typedef union d11rxhdrmid {
   d11rxhdrmid_ge80_t ge80;
   d11rxhdrmid_ge87_1_t ge87_1;
} d11rxhdrmid_t;
 
/* A wrapper structure for all versions of d11rxh structures */
typedef union d11rxhdr {
   d11rxhdr_lt80_t lt80;
   d11rxhdr_ge80_t ge80;
   d11rxhdr_ge85_t ge85;
   d11rxhdr_ge87_1_t ge87_1;
} d11rxhdr_t;
 
#define D11RXHDRSHORT_GE87_1_ACCESS_REF(srxh, member) \
   (&((((d11rxhdrshort_t *)(srxh))->ge87_1).member))
 
#define D11RXHDRMID_GE87_1_ACCESS_REF(mrxh, member) \
   (&((((d11rxhdrmid_t *)(mrxh))->ge87_1).member))
 
#define D11RXHDRSHORT_GE87_1_ACCESS_VAL(srxh, member) \
   ((((d11rxhdrshort_t *)(srxh))->ge87_1).member)
 
#define D11RXHDRMID_GE87_1_ACCESS_VAL(mrxh, member) \
   ((((d11rxhdrmid_t *)(mrxh))->ge87_1).member)
 
#define D11RXHDR_GE87_1_ACCESS_REF(rxh, member) \
   (&((rxh)->ge87_1).member)
 
#define D11RXHDR_GE87_1_ACCESS_VAL(rxh, member) \
   (((rxh)->ge87_1).member)
 
#define D11RXHDR_GE87_1_SET_VAL(rxh, member, value) \
   (((rxh)->ge87_1).member = value)
 
#define D11RXHDRSHORT_GE80_ACCESS_REF(srxh, member) \
   (&((((d11rxhdrshort_t *)(srxh))->ge80).member))
 
#define D11RXHDRMID_GE80_ACCESS_REF(mrxh, member) \
   (&((((d11rxhdrmid_t *)(mrxh))->ge80).member))
 
#define D11RXHDRSHORT_LT80_ACCESS_REF(srxh, member) \
   (&((((d11rxhdrshort_t *)(srxh))->lt80).member))
 
#define D11RXHDRSHORT_GE80_ACCESS_VAL(srxh, member) \
   ((((d11rxhdrshort_t *)(srxh))->ge80).member)
 
#define D11RXHDRMID_GE80_ACCESS_VAL(mrxh, member) \
   ((((d11rxhdrmid_t *)(mrxh))->ge80).member)
 
#define D11RXHDRSHORT_LT80_ACCESS_VAL(srxh, member) \
   ((((d11rxhdrshort_t *)(srxh))->lt80).member)
 
#define D11RXHDR_GE80_ACCESS_REF(rxh, member) \
   (&((rxh)->ge80).member)
 
#define D11RXHDR_LT80_ACCESS_REF(rxh, member) \
   (&((rxh)->lt80).member)
 
#define D11RXHDR_GE80_ACCESS_VAL(rxh, member) \
   (((rxh)->ge80).member)
 
#define D11RXHDR_GE80_SET_VAL(rxh, member, value) \
   (((rxh)->ge80).member = value)
 
#define D11RXHDR_LT80_ACCESS_VAL(rxh, member) \
   (((rxh)->lt80).member)
 
#define D11RXHDR_LT80_SET_VAL(rxh, member, value) \
   (((rxh)->lt80).member = value)
 
/** For accessing members of d11rxhdrshort_t by reference (address of members) */
#define D11RXHDRSHORT_ACCESS_REF(srxh, corerev, corerev_minor, member) \
   (D11REV_MAJ_MIN_GE(corerev, corerev_minor, 87, 1) ? \
       D11RXHDRSHORT_GE87_1_ACCESS_REF(srxh, member) : \
   D11REV_GE(corerev, 80) ? D11RXHDRSHORT_GE80_ACCESS_REF(srxh, member) : \
   D11RXHDRSHORT_LT80_ACCESS_REF(srxh, member))
 
/** For accessing members of d11rxhdrshort_t by value (only value stored inside members accessed) */
#define D11RXHDRSHORT_ACCESS_VAL(srxh, corerev, corerev_minor, member) \
   (D11REV_MAJ_MIN_GE(corerev, corerev_minor, 87, 1) ? \
       D11RXHDRSHORT_GE87_1_ACCESS_VAL(srxh, member) : \
   D11REV_GE(corerev, 80) ? D11RXHDRSHORT_GE80_ACCESS_VAL(srxh, member) : \
   D11RXHDRSHORT_LT80_ACCESS_VAL(srxh, member))
 
/** For accessing members of d11rxhdrmid_t by reference (address of members) */
#define D11RXHDRMID_ACCESS_REF(mrxh, corerev, corerev_minor, member) \
   (D11REV_MAJ_MIN_GE(corerev, corerev_minor, 87, 1) ? \
       D11RXHDRMID_GE87_1_ACCESS_REF(mrxh, member) : \
   D11REV_GE(corerev, 80) ? D11RXHDRMID_GE80_ACCESS_REF(mrxh, member) : NULL)
 
/** For accessing members of d11rxhdrmid_t by value (only value stored inside members accessed) */
#define D11RXHDRMID_ACCESS_VAL(mrxh, corerev, corerev_minor, member) \
   (D11REV_MAJ_MIN_GE(corerev, corerev_minor, 87, 1) ? \
       D11RXHDRMID_GE87_1_ACCESS_VAL(mrxh, member) : \
   D11REV_GE(corerev, 80) ? D11RXHDRMID_GE80_ACCESS_VAL(mrxh, member) : NULL)
 
/** For accessing members of d11rxhdr_t by reference (address of members) */
#define D11RXHDR_ACCESS_REF(rxh, corerev, corerev_minor, member) \
   (D11REV_MAJ_MIN_GE(corerev, corerev_minor, 87, 1) ? \
   D11RXHDR_GE87_1_ACCESS_REF(rxh, member) : \
   D11REV_GE(corerev, 80) ? D11RXHDR_GE80_ACCESS_REF(rxh, member) : \
   D11RXHDR_LT80_ACCESS_REF(rxh, member))
 
/** For accessing members of d11rxhdr_t by value (only value stored inside members accessed) */
#define D11RXHDR_ACCESS_VAL(rxh, corerev, corerev_minor, member) \
   (D11REV_MAJ_MIN_GE(corerev, corerev_minor, 87, 1) ? \
   D11RXHDR_GE87_1_ACCESS_VAL(rxh, member) : \
   D11REV_GE(corerev, 80) ? D11RXHDR_GE80_ACCESS_VAL(rxh, member) : \
   D11RXHDR_LT80_ACCESS_VAL(rxh, member))
 
/** For accessing members of d11rxhdr_t by value (only value stored inside members accessed) */
#define D11RXHDR_SET_VAL(rxh, corerev, corerev_minor, member, value) \
   (D11REV_MAJ_MIN_GE(corerev, corerev_minor, 87, 1) ? \
       D11RXHDR_GE87_1_SET_VAL(rxh, member, value) : \
   D11REV_GE(corerev, 80) ? D11RXHDR_GE80_SET_VAL(rxh, member, value) : \
   D11RXHDR_LT80_SET_VAL(rxh, member, value))
 
#define D11RXHDR_PTM(rxh, corerev, corerev_minor) \
   (D11REV_MAJ_MIN_GE(corerev, corerev_minor, 87, 1) ? \
       D11RXHDR_GE87_1_ACCESS_VAL(rxh, PTMRxTime) : 0)
 
#define D11RXHDR_AVB(rxh, corerev, corerev_minor) \
   (D11REV_MAJ_MIN_GE(corerev, corerev_minor, 87, 1) ? \
       (uint32)D11RXHDR_GE87_1_ACCESS_VAL(rxh, AVBRxTime) : \
   D11REV_GE(corerev, 80) ? ((uint32)D11RXHDR_GE80_ACCESS_VAL(rxh, AvbRxTimeL) | \
       ((uint32)D11RXHDR_GE80_ACCESS_VAL(rxh, AvbRxTimeH) << 16u)) : \
       ((uint32)D11RXHDR_LT80_ACCESS_VAL(rxh, AvbRxTimeL) | \
       ((uint32)D11RXHDR_LT80_ACCESS_VAL(rxh, AvbRxTimeH) << 16u)))
 
#define D11RXHDR_TSF_REF(rxh, corerev, corerev_minor) \
   (D11REV_MAJ_MIN_GE(corerev, corerev_minor, 87, 1) ? \
       D11RXHDR_GE87_1_ACCESS_REF(rxh, TSFRxTime) : \
   D11REV_GE(corerev, 80) ? (uint32*)D11RXHDR_GE80_ACCESS_REF(rxh, RxTSFTime) : \
       (uint32*)D11RXHDR_LT80_ACCESS_REF(rxh, RxTSFTime))
 
#define D11RXHDR_TSF(rxh, corerev, corerev_minor) \
   (D11REV_MAJ_MIN_GE(corerev, corerev_minor, 87, 1) ? \
       D11RXHDR_GE87_1_ACCESS_VAL(rxh, TSFRxTime) : \
   D11REV_GE(corerev, 80) ? D11RXHDR_GE80_ACCESS_VAL(rxh, RxTSFTime) : \
       D11RXHDR_LT80_ACCESS_VAL(rxh, RxTSFTime))
 
#define RXS_SHORT_ENAB(rev)    (D11REV_GE(rev, 64) || \
               D11REV_IS(rev, 60) || \
               D11REV_IS(rev, 62))
 
#define RXS_MID_ENAB(rev)    (D11REV_GE(rev, 80))
#define RXS_LONG_ENAB(rev)    (D11REV_GE(rev, 80))
 
#define IS_D11RXHDRSHORT(rxh, rev, rev_min) ((RXS_SHORT_ENAB(rev) && \
   ((D11RXHDR_ACCESS_VAL((rxh), (rev), (rev_min), dma_flags)) & RXS_SHORT_MASK)) != 0)
 
#define IS_D11RXHDRMID(rxh, rev, rev_min) ((RXS_MID_ENAB(rev) && \
   ((D11RXHDR_ACCESS_VAL((rxh), (rev), (rev_min), dma_flags)) == 0)))
 
#define IS_D11RXHDRLONG(rxh, rev, rev_min) \
       ((!(IS_D11RXHDRSHORT((rxh), (rev), (rev_min)))) && \
           (!(IS_D11RXHDRMID((rxh), (rev), (rev_min)))))
 
#define D11RXHDR_HAS_UCODE_STATUS(rxhdr, corerev, corerev_minor) \
       ((!IS_D11RXHDRSHORT((rxhdr), (corerev), (corerev_minor))) || \
           (IS_D11RXHDRMID((rxhdr), (corerev), (corerev_minor))))
 
#define IS_PHYRXHDR_VALID(rxh, corerev, corerev_minor) \
   (D11REV_MAJ_MIN_GE(corerev, corerev_minor, 87, 1) ? \
   (D11RXHDR_GE87_1_ACCESS_VAL(rxh, dma_flags) == RXS_PHYRXST_VALID_REV_GE80) : \
   D11REV_GE(corerev, 80) ? \
   (D11RXHDR_GE80_ACCESS_VAL(rxh, dma_flags) == RXS_PHYRXST_VALID_REV_GE80) : \
   (D11RXHDR_LT80_ACCESS_VAL(rxh, RxStatus2) & RXS_PHYRXST_VALID))
 
#define RXHDR_GET_PAD_LEN(rxh, corerev, corerev_minor) (D11REV_GE(corerev, 80) ? \
   ((((D11REV_MAJ_MIN_GE(corerev, corerev_minor, 87, 1) ? \
   D11RXHDR_GE87_1_ACCESS_VAL(rxh, mrxs) : \
   D11RXHDR_GE80_ACCESS_VAL(rxh, mrxs)) & RXSS_PBPRES) != 0) ? HDRCONV_PAD : 0) : \
   (IS_D11RXHDRSHORT(rxh, corerev, corerev_minor) ? \
   (((D11RXHDRSHORT_ACCESS_VAL(rxh, corerev, corerev_minor, mrxs) & \
   RXSS_PBPRES) != 0) ? HDRCONV_PAD : 0) : \
   (((D11RXHDR_LT80_ACCESS_VAL(rxh, RxStatus1) & RXS_PBPRES) != 0) ? HDRCONV_PAD : 0)))
 
#define RXHDR_GET_PAD_PRES(rxh, corerev, corerev_minor) (D11REV_GE(corerev, 80) ? \
   (((D11REV_MAJ_MIN_GE(corerev, corerev_minor, 87, 1) ? \
   D11RXHDR_GE87_1_ACCESS_VAL(rxh, mrxs) : \
   D11RXHDR_GE80_ACCESS_VAL(rxh, mrxs)) & RXSS_PBPRES) != 0) : \
   (IS_D11RXHDRSHORT(rxh, corerev, corerev_minor) ? \
   ((D11RXHDRSHORT_ACCESS_VAL(rxh, corerev, corerev_minor, mrxs) & \
   RXSS_PBPRES) != 0) : \
   (((D11RXHDR_LT80_ACCESS_VAL(rxh, RxStatus1) & RXS_PBPRES) != 0))))
 
#define RXHDR_GET_CONV_TYPE(rxh, corerev, corerev_minor) \
   (IS_D11RXHDRSHORT(rxh, corerev, corerev_minor) ? \
   ((D11RXHDRSHORT_ACCESS_VAL(rxh, corerev, corerev_minor, \
   HdrConvSt) & HDRCONV_ETH_FRAME) != 0) : ((D11RXHDR_ACCESS_VAL(rxh, \
   corerev, corerev_minor, HdrConvSt) & HDRCONV_ETH_FRAME) != 0))
 
#define RXHDR_GET_ROE_ERR_STS(rxh, corerev, corerev_minor) \
   (D11REV_MAJ_MIN_GE(corerev, corerev_minor, 87, 1) ? \
   ((D11RXHDR_GE87_1_ACCESS_VAL(rxh, roe_err_flags))) : 0)
 
#define RXHDR_GET_ROE_L3_TYPE(rxh, corerev, corerev_minor) \
   (D11REV_MAJ_MIN_GE(corerev, corerev_minor, 87, 1) ? \
   ((D11RXHDR_GE87_1_ACCESS_VAL(rxh, roe_hw_sts)) & ROE_L3_PROT_TYPE_MASK) : 0)
 
#define RXHDR_GET_ROE_L4_TYPE(rxh, corerev, corerev_minor) \
   (D11REV_MAJ_MIN_GE(corerev, corerev_minor, 87, 1) ? \
   ((D11RXHDR_GE87_1_ACCESS_VAL(rxh, roe_hw_sts)) & ROE_L4_PROT_TYPE_MASK) : 0)
 
#define RXHDR_GET_ROE_L3_STATUS(rxh, corerev, corerev_minor) \
   (D11REV_MAJ_MIN_GE(corerev, corerev_minor, 87, 1) ? \
   ((D11RXHDR_GE87_1_ACCESS_VAL(rxh, roe_hw_sts)) & ROE_L3_CHKSUM_STATUS_MASK) : 0)
 
#define RXHDR_GET_ROE_L4_STATUS(rxh, corerev, corerev_minor) \
   (D11REV_MAJ_MIN_GE(corerev, corerev_minor, 87, 1) ? \
   ((D11RXHDR_GE87_1_ACCESS_VAL(rxh, roe_hw_sts)) & ROE_L4_CHKSUM_STATUS_MASK) : 0)
 
#define RXHDR_GET_AGG_TYPE(rxh, corerev, corerev_minor) \
   (D11REV_GE(corerev, 80) ? \
   (((D11REV_MAJ_MIN_GE(corerev, corerev_minor, 87, 1) ? \
   D11RXHDR_GE87_1_ACCESS_VAL(rxh, mrxs) : \
   D11RXHDR_GE80_ACCESS_VAL(rxh, mrxs)) & RXSS_AGGTYPE_MASK) >> RXSS_AGGTYPE_SHIFT) : \
   (IS_D11RXHDRSHORT(rxh, corerev, corerev_minor) ? \
   ((D11RXHDRSHORT_ACCESS_VAL(rxh, corerev, corerev_minor, mrxs) \
    & RXSS_AGGTYPE_MASK) >> RXSS_AGGTYPE_SHIFT) : \
   ((D11RXHDR_LT80_ACCESS_VAL(rxh, RxStatus2) & RXS_AGGTYPE_MASK) >> RXS_AGGTYPE_SHIFT)))
 
#define RXHDR_GET_PBPRS_REF(rxh, corerev, corerev_minor) (D11REV_GE(corerev, 80) ? \
   (D11REV_MAJ_MIN_GE(corerev, corerev_minor, 87, 1) ? \
   D11RXHDR_GE87_1_ACCESS_REF(rxh, mrxs) : \
   D11RXHDR_GE80_ACCESS_REF(rxh, mrxs)) : \
   (IS_D11RXHDRSHORT(rxh, corerev, corerev_minor) ? \
   ((D11RXHDRSHORT_ACCESS_REF(rxh, corerev, corerev_minor, mrxs))) : \
   (D11RXHDR_LT80_ACCESS_REF(rxh, RxStatus1))))
 
#define RXHDR_GET_IS_DEFRAG(rxh, corerev, corerev_minor) (D11REV_GE(corerev, 80) ? \
   (D11RXHDR_ACCESS_VAL(rxh, corerev, corerev_minor, RxStatus1) & RXS_IS_DEFRAG) : 0)
 
#define SET_RXHDR_PBPRS_REF_VAL(rxh, corerev, corerev_minor, val) \
   (D11REV_GE(corerev, 80) ? \
   (*val |= RXSS_PBPRES) : \
   (IS_D11RXHDRSHORT(rxh, corerev, corerev_minor) ? (*val |= RXSS_PBPRES) : \
   (*val |= RXS_PBPRES)))
 
#define CLEAR_RXHDR_PBPRS_REF_VAL(rxh, corerev, corerev_minor, val) \
   (D11REV_GE(corerev, 80) ? \
   (*val &= ~RXSS_PBPRES) : \
   (IS_D11RXHDRSHORT(rxh, corerev, corerev_minor) ? (*val &= ~RXSS_PBPRES) : \
   (*val &= ~RXS_PBPRES)))
 
#define RXHDR_GET_AMSDU(rxh, corerev, corerev_minor) (D11REV_GE(corerev, 80) ? \
   (((D11REV_MAJ_MIN_GE(corerev, corerev_minor, 87, 1) ? \
   D11RXHDR_GE87_1_ACCESS_VAL(rxh, mrxs) : \
   D11RXHDR_GE80_ACCESS_VAL(rxh, mrxs)) & RXSS_AMSDU_MASK) != 0) : \
   (IS_D11RXHDRSHORT(rxh, corerev, corerev_minor) ? \
   ((D11RXHDRSHORT_ACCESS_VAL(rxh, corerev, corerev_minor, \
   mrxs) & RXSS_AMSDU_MASK) != 0) : \
   ((D11RXHDR_LT80_ACCESS_VAL(rxh, RxStatus2) & RXS_AMSDU_MASK) != 0)))
 
#ifdef BCMDBG
#define RXHDR_GET_MSDU_COUNT(rxh, corerev, corerev_minor) (D11REV_GE(corerev, 80) ? \
   (((D11REV_MAJ_MIN_GE(corerev, corerev_minor, 87, 1) ? \
   D11RXHDR_GE87_1_ACCESS_VAL(rxh, mrxs) : \
   D11RXHDR_GE80_ACCESS_VAL(rxh, mrxs)) & RXSS_MSDU_CNT_MASK) >> RXSS_MSDU_CNT_SHIFT) : \
   IS_D11RXHDRSHORT(rxh, corerev, corerev_minor) ? \
   (((D11RXHDRSHORT_ACCESS_VAL(rxh, corerev, corerev_minor, mrxs)) & \
   RXSS_MSDU_CNT_MASK) >> RXSS_MSDU_CNT_SHIFT) : 0)
 
#endif /* BCMDBG */
 
/** Length of HW RX status in RxStatus */
#define HW_RXHDR_LEN_REV_GE87_1    (sizeof(d11rxhdrshort_ge87_1_t))    /* 24 bytes */
#define HW_RXHDR_LEN_REV_GE80    (sizeof(d11rxhdrshort_ge80_t))        /* 20 bytes */
#define HW_RXHDR_LEN_REV_LT80    (sizeof(d11rxhdrshort_lt80_t))        /* 12 bytes */
#define HW_RXHDR_LEN_REV_61_1    (sizeof(d11rxhdrshort_rev61_1_t))    /* 16 bytes */
 
/** Length of HW RX status + ucode Rx status in RxStatus */
#define MID_RXHDR_LEN_REV_GE87_1 (sizeof(d11rxhdrmid_ge87_1_t))        /* 48 bytes */
#define MID_RXHDR_LEN_REV_GE80   (sizeof(d11rxhdrmid_ge80_t))        /* 36 bytes */
 
/** Length of HW RX status + ucode RX status + PHY RX status + padding(if need align) */
#define D11_RXHDR_LEN_REV_GE87_1 (sizeof(d11rxhdr_ge87_1_t))        /* 80 bytes */
#define D11_RXHDR_LEN_REV_GE80   (sizeof(d11rxhdr_ge80_t))        /* 68 bytes */
#define D11_RXHDR_LEN_REV_LT80   (sizeof(d11rxhdr_lt80_t))        /* 36 bytes */
 
#define HW_RXHDR_LEN(corerev, corerev_minor) \
   (D11REV_MAJ_MIN_GE(corerev, corerev_minor, 87, 1) ? HW_RXHDR_LEN_REV_GE87_1 : \
   D11REV_GE(corerev, 80) ? HW_RXHDR_LEN_REV_GE80 : HW_RXHDR_LEN_REV_LT80)
 
#define MID_RXHDR_LEN(corerev, corerev_minor) \
   (D11REV_MAJ_MIN_GE(corerev, corerev_minor, 87, 1) ? MID_RXHDR_LEN_REV_GE87_1 : \
   D11REV_GE(corerev, 80) ? \
       MID_RXHDR_LEN_REV_GE80 : NULL)
 
#define D11_RXHDR_LEN(corerev, corerev_minor) \
   (D11REV_MAJ_MIN_GE(corerev, corerev_minor, 87, 1) ? D11_RXHDR_LEN_REV_GE87_1 : \
   D11REV_GE(corerev, 80) ? D11_RXHDR_LEN_REV_GE80 : \
   D11_RXHDR_LEN_REV_LT80)
 
#define    FRAMELEN(corerev, corerev_minor, rxh) \
   D11RXHDR_ACCESS_VAL(rxh, corerev, corerev_minor, RxFrameSize)
 
#define RXS_SHORT_MASK  0x01    /**< Short vs full rx status in dma_flags field of d11rxhdr */
 
/** validate chip specific phychain info for MCSSQ snr.
 *  should sync with uCode reporting.
 *  please add a condition with decending order to avoid any wrong skip
 *  Note: this macro can be removed once NEWT no longer needs 4368a0.
 */
#define IS_MCSSQ_ANT3_VALID_GE80(corerev, corerev_minor)    \
   (D11REV_IS(corerev, 83) && (D11MINORREV_IS(corerev_minor, 1)))
 
/* Header conversion status register bit fields */
#define HDRCONV_USR_ENAB    0x0001
#define HDRCONV_ENAB        0x0100
#define HDRCONV_ETH_FRAME    0x0200
#define HDRCONV_STATUS_VALID    0x8000
 
#define ROE_L3_PROT_TYPE_IPV4   (0x10u)
#define ROE_L3_PROT_TYPE_IPV6    (0x20u)
#define ROE_L3_PROT_TYPE_MASK    (0x30u)
#define ROE_L3_PROT_TYPE_SHIFT    (4u)
 
#define ROE_L4_PROT_TYPE_TCP    (0x40u)
#define ROE_L4_PROT_TYPE_UDP    (0x80u)
#define ROE_L4_PROT_TYPE_MASK    (0xC0u)
#define ROE_L4_PROT_TYPE_SHIFT    (6u)
 
#define ROE_L3_CHKSUM_STATUS_FAIL    (0x100u)
#define ROE_L3_CHKSUM_STATUS_SUCCESS    (0x200u)
#define ROE_L3_CHKSUM_STATUS_MASK    (0x300u)
#define ROE_L3_CHKSUM_STATUS_SHIFT    (8u)
 
#define ROE_L4_CHKSUM_STATUS_FAIL    (0x400u)
#define ROE_L4_CHKSUM_STATUS_SUCCESS    (0x800u)
#define ROE_L4_CHKSUM_STATUS_MASK    (0xC00u)
#define ROE_L4_CHKSUM_STATUS_SHIFT    (10u)
 
/** NOTE: Due to precommit issue, _d11_autophyrxsts_ will be moved
 *        to a separated file when 4387 trunk build is stable
 */
#ifndef _d11_autophyrxsts_
#define _d11_autophyrxsts_
 
#define APRXS_WD0_L_EN_GE85        1u
#define APRXS_WD0_H_EN_GE85        1u
#define APRXS_WD1_L_EN_GE85        1u
#define APRXS_WD1_H_EN_GE85        1u
#define APRXS_WD2_L_EN_GE85        1u
#define APRXS_WD2_H_EN_GE85        1u
#define APRXS_WD3_L_EN_GE85        1u
#define APRXS_WD3_H_EN_GE85        0u // DO NOT ENABLE WD3_H
#define APRXS_WD4_L_EN_GE85        1u
#define APRXS_WD4_H_EN_GE85        1u
#define APRXS_WD5_L_EN_GE85        1u
#define APRXS_WD5_H_EN_GE85        1u
#define APRXS_WD6_L_EN_GE85        0u
#define APRXS_WD6_H_EN_GE85        0u
#define APRXS_WD7_L_EN_GE85        0u
#define APRXS_WD7_H_EN_GE85        0u
#define APRXS_WD8_L_EN_GE85        0u
#define APRXS_WD8_H_EN_GE85        1u
#define APRXS_WD9_L_EN_GE85        0u
#define APRXS_WD9_H_EN_GE85        0u
#define APRXS_WD10_L_EN_GE85        0u
#define APRXS_WD10_H_EN_GE85        0u
#define APRXS_WD11_L_EN_GE85        0u
#define APRXS_WD11_H_EN_GE85        0u
#define APRXS_WD12_L_EN_GE85        0u
#define APRXS_WD12_H_EN_GE85        0u
#define APRXS_WD13_L_EN_GE85        0u
#define APRXS_WD13_H_EN_GE85        0u
#define APRXS_WD14_L_EN_GE85        0u
#define APRXS_WD14_H_EN_GE85        0u
#define APRXS_WD15_L_EN_GE85        0u
#define APRXS_WD15_H_EN_GE85        0u
#define APRXS_WD16_L_EN_GE85        1u
#define APRXS_WD16_H_EN_GE85        0u
#define APRXS_WD17_L_EN_GE85        0u
#define APRXS_WD17_H_EN_GE85        0u
#define APRXS_WD18_L_EN_GE85        1u
#define APRXS_WD18_H_EN_GE85        0u
#define APRXS_WD19_L_EN_GE85        0u
#define APRXS_WD19_H_EN_GE85        0u
#define APRXS_WD20_L_EN_GE85        1u
#define APRXS_WD20_H_EN_GE85        1u
#define APRXS_WD21_L_EN_GE85        0u
#define APRXS_WD21_H_EN_GE85        1u
#define APRXS_WD22_L_EN_GE85        1u
#define APRXS_WD22_H_EN_GE85        1u
#define APRXS_WD23_L_EN_GE85        1u
#define APRXS_WD23_H_EN_GE85        1u
#define APRXS_WD24_L_EN_GE85        0u
#define APRXS_WD24_H_EN_GE85        0u
#define APRXS_WD25_L_EN_GE85        0u
#define APRXS_WD25_H_EN_GE85        0u
 
enum {
   APRXS_WD0_L_SHIFT = 0,    // frameType, unsupportedRate, band, lostCRS, shortPreamble
   APRXS_WD0_H_SHIFT,    // PLCPViolation, MFCRSFired, ACCRSFired, MUPPDU, OBSSStat
   APRXS_WD1_L_SHIFT,    // coremask, antcfg,
   APRXS_WD1_H_SHIFT,    // BWclassification
   APRXS_WD2_L_SHIFT,    // RxPwrAnt0
   APRXS_WD2_H_SHIFT,    // RxPwrAnt1
   APRXS_WD3_L_SHIFT,    // RxPwrAnt2
   APRXS_WD3_H_SHIFT,    // RxPwrAnt3, OCL
   APRXS_WD4_L_SHIFT,    // RSSI factional bit
   APRXS_WD4_H_SHIFT,    // AGC type, ACI mitigation state, ClipCount, DynBWInNonHT
   APRXS_WD5_L_SHIFT,    // MCSSQSNRCore0
   APRXS_WD5_H_SHIFT,    // MCSSQSNRCore1
   APRXS_WD6_L_SHIFT,    // MCSSQSNRCore2
   APRXS_WD6_H_SHIFT,    // MCSSQSNRCore3, OCL 1
   APRXS_WD7_L_SHIFT,    // MUIntProcessType,
   APRXS_WD7_H_SHIFT,    // coarse freq_offset, packet abort
   APRXS_WD8_L_SHIFT = 0,    // fine freq offset
   APRXS_WD8_H_SHIFT,    // ChBWInNonHT, MLUsed, SINRBasedACIDet
   APRXS_WD9_L_SHIFT,    // SpatialSQCnt
   APRXS_WD9_H_SHIFT,    // packet gain
   APRXS_WD10_L_SHIFT,    // RxPwrAntExt
   APRXS_WD10_H_SHIFT,    // coarse freq_offset of 2nd 80mhz
   APRXS_WD11_L_SHIFT,    // fine freq_offset of 2nd 80mhz
   APRXS_WD11_H_SHIFT,
   APRXS_WD12_L_SHIFT,
   APRXS_WD12_H_SHIFT,
   APRXS_WD13_L_SHIFT,
   APRXS_WD13_H_SHIFT,
   APRXS_WD14_L_SHIFT,
   APRXS_WD14_H_SHIFT,
   APRXS_WD15_L_SHIFT,
   APRXS_WD15_H_SHIFT,
   APRXS_WD16_L_SHIFT = 0,
   APRXS_WD16_H_SHIFT,
   APRXS_WD17_L_SHIFT,
   APRXS_WD17_H_SHIFT,
   APRXS_WD18_L_SHIFT,
   APRXS_WD18_H_SHIFT,
   APRXS_WD19_L_SHIFT,
   APRXS_WD19_H_SHIFT,
   APRXS_WD20_L_SHIFT,
   APRXS_WD20_H_SHIFT,
   APRXS_WD21_L_SHIFT,
   APRXS_WD21_H_SHIFT,
   APRXS_WD22_L_SHIFT,    // STA ID
   APRXS_WD22_H_SHIFT,    // STA ID, NSTS, TXBF, DCM
   APRXS_WD23_L_SHIFT,
   APRXS_WD23_H_SHIFT,
   APRXS_WD24_L_SHIFT = 0,
   APRXS_WD24_H_SHIFT,
   APRXS_WD25_L_SHIFT,
   APRXS_WD25_H_SHIFT
};
 
#define APRXS_WD0_L_EN(rev)    ((D11REV_GE(rev, 85)) ? \
                APRXS_WD0_L_EN_GE85 : 0)
#define APRXS_WD0_H_EN(rev)    ((D11REV_GE(rev, 85)) ? \
                APRXS_WD0_H_EN_GE85 : 0)
#define APRXS_WD1_L_EN(rev)    ((D11REV_GE(rev, 85)) ? \
                APRXS_WD1_L_EN_GE85 : 0)
#define APRXS_WD1_H_EN(rev)    ((D11REV_GE(rev, 85)) ? \
                APRXS_WD1_H_EN_GE85 : 0)
#define APRXS_WD2_L_EN(rev)    ((D11REV_GE(rev, 85)) ? \
                APRXS_WD2_L_EN_GE85 : 0)
#define APRXS_WD2_H_EN(rev)    ((D11REV_GE(rev, 85)) ? \
                APRXS_WD2_H_EN_GE85 : 0)
#define APRXS_WD3_L_EN(rev)    ((D11REV_GE(rev, 85)) ? \
                APRXS_WD3_L_EN_GE85 : 0)
#define APRXS_WD3_H_EN(rev)    ((D11REV_GE(rev, 85)) ? \
                APRXS_WD3_H_EN_GE85 : 0)
#define APRXS_WD4_L_EN(rev)    ((D11REV_GE(rev, 85)) ? \
                APRXS_WD4_L_EN_GE85 : 0)
#define APRXS_WD4_H_EN(rev)    ((D11REV_GE(rev, 85)) ? \
                APRXS_WD4_H_EN_GE85 : 0)
#define APRXS_WD5_L_EN(rev)    ((D11REV_GE(rev, 85)) ? \
                APRXS_WD5_L_EN_GE85 : 0)
#define APRXS_WD5_H_EN(rev)    ((D11REV_GE(rev, 85)) ? \
                APRXS_WD5_H_EN_GE85 : 0)
#define APRXS_WD6_L_EN(rev)    ((D11REV_GE(rev, 85)) ? \
                APRXS_WD6_L_EN_GE85 : 0)
#define APRXS_WD6_H_EN(rev)    ((D11REV_GE(rev, 85)) ? \
                APRXS_WD6_H_EN_GE85 : 0)
#define APRXS_WD7_L_EN(rev)    ((D11REV_GE(rev, 85)) ? \
                APRXS_WD7_L_EN_GE85 : 0)
#define APRXS_WD7_H_EN(rev)    ((D11REV_GE(rev, 85)) ? \
                APRXS_WD7_H_EN_GE85 : 0)
#define APRXS_WD8_L_EN(rev)    ((D11REV_GE(rev, 85)) ? \
                APRXS_WD8_L_EN_GE85 : 0)
#define APRXS_WD8_H_EN(rev)    ((D11REV_GE(rev, 85)) ? \
                APRXS_WD8_H_EN_GE85 : 0)
#define APRXS_WD9_L_EN(rev)    ((D11REV_GE(rev, 85)) ? \
                APRXS_WD9_L_EN_GE85 : 0)
#define APRXS_WD9_H_EN(rev)    ((D11REV_GE(rev, 85)) ? \
                APRXS_WD9_H_EN_GE85 : 0)
#define APRXS_WD10_L_EN(rev)    ((D11REV_GE(rev, 85)) ? \
                APRXS_WD10_L_EN_GE85 : 0)
#define APRXS_WD10_H_EN(rev)    ((D11REV_GE(rev, 85)) ? \
                APRXS_WD10_H_EN_GE85 : 0)
#define APRXS_WD11_L_EN(rev)    ((D11REV_GE(rev, 85)) ? \
                APRXS_WD11_L_EN_GE85 : 0)
#define APRXS_WD11_H_EN(rev)    ((D11REV_GE(rev, 85)) ? \
                APRXS_WD11_H_EN_GE85 : 0)
#define APRXS_WD12_L_EN(rev)    ((D11REV_GE(rev, 85)) ? \
                APRXS_WD12_L_EN_GE85 : 0)
#define APRXS_WD12_H_EN(rev)    ((D11REV_GE(rev, 85)) ? \
                APRXS_WD12_H_EN_GE85 : 0)
#define APRXS_WD13_L_EN(rev)    ((D11REV_GE(rev, 85)) ? \
                APRXS_WD13_L_EN_GE85 : 0)
#define APRXS_WD13_H_EN(rev)    ((D11REV_GE(rev, 85)) ? \
                APRXS_WD13_H_EN_GE85 : 0)
#define APRXS_WD14_L_EN(rev)    ((D11REV_GE(rev, 85)) ? \
                APRXS_WD14_L_EN_GE85 : 0)
#define APRXS_WD14_H_EN(rev)    ((D11REV_GE(rev, 85)) ? \
                APRXS_WD14_H_EN_GE85 : 0)
#define APRXS_WD15_L_EN(rev)    ((D11REV_GE(rev, 85)) ? \
                APRXS_WD15_L_EN_GE85 : 0)
#define APRXS_WD15_H_EN(rev)    ((D11REV_GE(rev, 85)) ? \
                APRXS_WD15_H_EN_GE85 : 0)
#define APRXS_WD16_L_EN(rev)    ((D11REV_GE(rev, 85)) ? \
                APRXS_WD16_L_EN_GE85 : 0)
#define APRXS_WD16_H_EN(rev)    ((D11REV_GE(rev, 85)) ? \
                APRXS_WD16_H_EN_GE85 : 0)
#define APRXS_WD17_L_EN(rev)    ((D11REV_GE(rev, 85)) ? \
                APRXS_WD17_L_EN_GE85 : 0)
#define APRXS_WD17_H_EN(rev)    ((D11REV_GE(rev, 85)) ? \
                APRXS_WD17_H_EN_GE85 : 0)
#define APRXS_WD18_L_EN(rev)    ((D11REV_GE(rev, 85)) ? \
                APRXS_WD18_L_EN_GE85 : 0)
#define APRXS_WD18_H_EN(rev)    ((D11REV_GE(rev, 85)) ? \
                APRXS_WD18_H_EN_GE85 : 0)
#define APRXS_WD19_L_EN(rev)    ((D11REV_GE(rev, 85)) ? \
                APRXS_WD19_L_EN_GE85 : 0)
#define APRXS_WD19_H_EN(rev)    ((D11REV_GE(rev, 85)) ? \
                APRXS_WD19_H_EN_GE85 : 0)
#define APRXS_WD20_L_EN(rev)    ((D11REV_GE(rev, 85)) ? \
                APRXS_WD20_L_EN_GE85 : 0)
#define APRXS_WD20_H_EN(rev)    ((D11REV_GE(rev, 85)) ? \
                APRXS_WD20_H_EN_GE85 : 0)
#define APRXS_WD21_L_EN(rev)    ((D11REV_GE(rev, 85)) ? \
                APRXS_WD21_L_EN_GE85 : 0)
#define APRXS_WD21_H_EN(rev)    ((D11REV_GE(rev, 85)) ? \
                APRXS_WD21_H_EN_GE85 : 0)
#define APRXS_WD22_L_EN(rev)    ((D11REV_GE(rev, 85)) ? \
                APRXS_WD22_L_EN_GE85 : 0)
#define APRXS_WD22_H_EN(rev)    ((D11REV_GE(rev, 85)) ? \
                APRXS_WD22_H_EN_GE85 : 0)
#define APRXS_WD23_L_EN(rev)    ((D11REV_GE(rev, 85)) ? \
                APRXS_WD23_L_EN_GE85 : 0)
#define APRXS_WD23_H_EN(rev)    ((D11REV_GE(rev, 85)) ? \
                APRXS_WD23_H_EN_GE85 : 0)
#define APRXS_WD24_L_EN(rev)    ((D11REV_GE(rev, 85)) ? \
                APRXS_WD24_L_EN_GE85 : 0)
#define APRXS_WD24_H_EN(rev)    ((D11REV_GE(rev, 85)) ? \
                APRXS_WD24_H_EN_GE85 : 0)
#define APRXS_WD25_L_EN(rev)    ((D11REV_GE(rev, 85)) ? \
                APRXS_WD25_L_EN_GE85 : 0)
#define APRXS_WD25_H_EN(rev)    ((D11REV_GE(rev, 85)) ? \
                APRXS_WD25_H_EN_GE85 : 0)
 
#define APRXS_BMAP0(rev)    ((APRXS_WD0_L_EN(rev) << APRXS_WD0_L_SHIFT) | \
               (APRXS_WD0_H_EN(rev) << APRXS_WD0_H_SHIFT) |\
               (APRXS_WD1_L_EN(rev) << APRXS_WD1_L_SHIFT) |\
               (APRXS_WD1_H_EN(rev) << APRXS_WD1_H_SHIFT) |\
               (APRXS_WD2_L_EN(rev) << APRXS_WD2_L_SHIFT) |\
               (APRXS_WD2_H_EN(rev) << APRXS_WD2_H_SHIFT) |\
               (APRXS_WD3_L_EN(rev) << APRXS_WD3_L_SHIFT) |\
               (APRXS_WD3_H_EN(rev) << APRXS_WD3_H_SHIFT) |\
               (APRXS_WD4_L_EN(rev) << APRXS_WD4_L_SHIFT) |\
               (APRXS_WD4_H_EN(rev) << APRXS_WD4_H_SHIFT) |\
               (APRXS_WD5_L_EN(rev) << APRXS_WD5_L_SHIFT) |\
               (APRXS_WD5_H_EN(rev) << APRXS_WD5_H_SHIFT) |\
               (APRXS_WD6_L_EN(rev) << APRXS_WD6_L_SHIFT) |\
               (APRXS_WD6_H_EN(rev) << APRXS_WD6_H_SHIFT) |\
               (APRXS_WD7_L_EN(rev) << APRXS_WD7_L_SHIFT) |\
               (APRXS_WD7_H_EN(rev) << APRXS_WD7_H_SHIFT))
 
#define APRXS_BMAP1(rev)    ((APRXS_WD8_L_EN(rev) << APRXS_WD8_L_SHIFT) | \
               (APRXS_WD8_H_EN(rev) << APRXS_WD8_H_SHIFT) |\
               (APRXS_WD9_L_EN(rev) << APRXS_WD9_L_SHIFT) |\
               (APRXS_WD9_H_EN(rev) << APRXS_WD9_H_SHIFT) |\
               (APRXS_WD10_L_EN(rev) << APRXS_WD10_L_SHIFT) |\
               (APRXS_WD10_H_EN(rev) << APRXS_WD10_H_SHIFT) |\
               (APRXS_WD11_L_EN(rev) << APRXS_WD11_L_SHIFT) |\
               (APRXS_WD11_H_EN(rev) << APRXS_WD11_H_SHIFT) |\
               (APRXS_WD12_L_EN(rev) << APRXS_WD12_L_SHIFT) |\
               (APRXS_WD12_H_EN(rev) << APRXS_WD12_H_SHIFT) |\
               (APRXS_WD13_L_EN(rev) << APRXS_WD13_L_SHIFT) |\
               (APRXS_WD13_H_EN(rev) << APRXS_WD13_H_SHIFT) |\
               (APRXS_WD14_L_EN(rev) << APRXS_WD14_L_SHIFT) |\
               (APRXS_WD14_H_EN(rev) << APRXS_WD14_H_SHIFT) |\
               (APRXS_WD15_L_EN(rev) << APRXS_WD15_L_SHIFT) |\
               (APRXS_WD15_H_EN(rev) << APRXS_WD15_H_SHIFT))
 
#define APRXS_BMAP2(rev)    ((APRXS_WD16_L_EN(rev) << APRXS_WD16_L_SHIFT) | \
               (APRXS_WD16_H_EN(rev) << APRXS_WD16_H_SHIFT) |\
               (APRXS_WD17_L_EN(rev) << APRXS_WD17_L_SHIFT) |\
               (APRXS_WD17_H_EN(rev) << APRXS_WD17_H_SHIFT) |\
               (APRXS_WD18_L_EN(rev) << APRXS_WD18_L_SHIFT) |\
               (APRXS_WD18_H_EN(rev) << APRXS_WD18_H_SHIFT) |\
               (APRXS_WD19_L_EN(rev) << APRXS_WD19_L_SHIFT) |\
               (APRXS_WD19_H_EN(rev) << APRXS_WD19_H_SHIFT) |\
               (APRXS_WD20_L_EN(rev) << APRXS_WD20_L_SHIFT) |\
               (APRXS_WD20_H_EN(rev) << APRXS_WD20_H_SHIFT) |\
               (APRXS_WD21_L_EN(rev) << APRXS_WD21_L_SHIFT) |\
               (APRXS_WD21_H_EN(rev) << APRXS_WD21_H_SHIFT) |\
               (APRXS_WD22_L_EN(rev) << APRXS_WD22_L_SHIFT) |\
               (APRXS_WD22_H_EN(rev) << APRXS_WD22_H_SHIFT) |\
               (APRXS_WD23_L_EN(rev) << APRXS_WD23_L_SHIFT) |\
               (APRXS_WD23_H_EN(rev) << APRXS_WD23_H_SHIFT))
 
#define APRXS_BMAP3(rev)    ((APRXS_WD24_L_EN(rev) << APRXS_WD24_L_SHIFT) | \
               (APRXS_WD24_H_EN(rev) << APRXS_WD24_H_SHIFT) |\
               (APRXS_WD25_L_EN(rev) << APRXS_WD25_L_SHIFT) |\
               (APRXS_WD25_H_EN(rev) << APRXS_WD25_H_SHIFT))
/* byte position */
#define APRXS_WD0_L_POS(rev)    0u
#define APRXS_WD0_H_POS(rev)    (APRXS_WD0_L_POS(rev) + APRXS_WD0_L_EN(rev))    /*  1 */
#define APRXS_WD1_L_POS(rev)    (APRXS_WD0_H_POS(rev) + APRXS_WD0_H_EN(rev))    /*  2 */
#define APRXS_WD1_H_POS(rev)    (APRXS_WD1_L_POS(rev) + APRXS_WD1_L_EN(rev))    /*  3 */
#define APRXS_WD2_L_POS(rev)    (APRXS_WD1_H_POS(rev) + APRXS_WD1_H_EN(rev))    /*  4 */
#define APRXS_WD2_H_POS(rev)    (APRXS_WD2_L_POS(rev) + APRXS_WD2_L_EN(rev))    /*  5 */
#define APRXS_WD3_L_POS(rev)    (APRXS_WD2_H_POS(rev) + APRXS_WD2_H_EN(rev))    /*  6 */
#define APRXS_WD3_H_POS(rev)    (APRXS_WD3_L_POS(rev) + APRXS_WD3_L_EN(rev))    /*  7 */
#define APRXS_WD4_L_POS(rev)    (APRXS_WD3_H_POS(rev) + APRXS_WD3_H_EN(rev))    /*  7 */
#define APRXS_WD4_H_POS(rev)    (APRXS_WD4_L_POS(rev) + APRXS_WD4_L_EN(rev))    /*  8 */
#define APRXS_WD5_L_POS(rev)    (APRXS_WD4_H_POS(rev) + APRXS_WD4_H_EN(rev))    /*  9 */
#define APRXS_WD5_H_POS(rev)    (APRXS_WD5_L_POS(rev) + APRXS_WD5_L_EN(rev))    /* 10 */
#define APRXS_WD6_L_POS(rev)    (APRXS_WD5_H_POS(rev) + APRXS_WD5_H_EN(rev))    /* 11 */
#define APRXS_WD6_H_POS(rev)    (APRXS_WD6_L_POS(rev) + APRXS_WD6_L_EN(rev))    /* 11 */
#define APRXS_WD7_L_POS(rev)    (APRXS_WD6_H_POS(rev) + APRXS_WD6_H_EN(rev))    /* 11 */
#define APRXS_WD7_H_POS(rev)    (APRXS_WD7_L_POS(rev) + APRXS_WD7_L_EN(rev))    /* 11 */
#define APRXS_WD8_L_POS(rev)    (APRXS_WD7_H_POS(rev) + APRXS_WD7_H_EN(rev))    /* 11 */
#define APRXS_WD8_H_POS(rev)    (APRXS_WD8_L_POS(rev) + APRXS_WD8_L_EN(rev))    /* 11 */
#define APRXS_WD9_L_POS(rev)    (APRXS_WD8_H_POS(rev) + APRXS_WD8_H_EN(rev))    /* 12 */
#define APRXS_WD9_H_POS(rev)    (APRXS_WD9_L_POS(rev) + APRXS_WD9_L_EN(rev))    /* 12 */
#define APRXS_WD10_L_POS(rev)    (APRXS_WD9_H_POS(rev) + APRXS_WD9_H_EN(rev))    /* 12 */
#define APRXS_WD10_H_POS(rev)    (APRXS_WD10_L_POS(rev) + APRXS_WD10_L_EN(rev))    /* 12 */
#define APRXS_WD11_L_POS(rev)    (APRXS_WD10_H_POS(rev) + APRXS_WD10_H_EN(rev))    /* 12 */
#define APRXS_WD11_H_POS(rev)    (APRXS_WD11_L_POS(rev) + APRXS_WD11_L_EN(rev))    /* 12 */
#define APRXS_WD12_L_POS(rev)    (APRXS_WD11_H_POS(rev) + APRXS_WD11_H_EN(rev))    /* 12 */
#define APRXS_WD12_H_POS(rev)    (APRXS_WD12_L_POS(rev) + APRXS_WD12_L_EN(rev))    /* 12 */
#define APRXS_WD13_L_POS(rev)    (APRXS_WD12_H_POS(rev) + APRXS_WD12_H_EN(rev))    /* 12 */
#define APRXS_WD13_H_POS(rev)    (APRXS_WD13_L_POS(rev) + APRXS_WD13_L_EN(rev))    /* 12 */
#define APRXS_WD14_L_POS(rev)    (APRXS_WD13_H_POS(rev) + APRXS_WD13_H_EN(rev))    /* 12 */
#define APRXS_WD14_H_POS(rev)    (APRXS_WD14_L_POS(rev) + APRXS_WD14_L_EN(rev))    /* 12 */
#define APRXS_WD15_L_POS(rev)    (APRXS_WD14_H_POS(rev) + APRXS_WD14_H_EN(rev))    /* 12 */
#define APRXS_WD15_H_POS(rev)    (APRXS_WD15_L_POS(rev) + APRXS_WD15_L_EN(rev))    /* 12 */
#define APRXS_WD16_L_POS(rev)    (APRXS_WD15_H_POS(rev) + APRXS_WD15_H_EN(rev))    /* 12 */
#define APRXS_WD16_H_POS(rev)    (APRXS_WD16_L_POS(rev) + APRXS_WD16_L_EN(rev))    /* 13 */
#define APRXS_WD17_L_POS(rev)    (APRXS_WD16_H_POS(rev) + APRXS_WD16_H_EN(rev))    /* 13 */
#define APRXS_WD17_H_POS(rev)    (APRXS_WD17_L_POS(rev) + APRXS_WD17_L_EN(rev))    /* 13 */
#define APRXS_WD18_L_POS(rev)    (APRXS_WD17_H_POS(rev) + APRXS_WD17_H_EN(rev))    /* 13 */
#define APRXS_WD18_H_POS(rev)    (APRXS_WD18_L_POS(rev) + APRXS_WD18_L_EN(rev))    /* 14 */
#define APRXS_WD19_L_POS(rev)    (APRXS_WD18_H_POS(rev) + APRXS_WD18_H_EN(rev))    /* 14 */
#define APRXS_WD19_H_POS(rev)    (APRXS_WD19_L_POS(rev) + APRXS_WD19_L_EN(rev))    /* 14 */
#define APRXS_WD20_L_POS(rev)    (APRXS_WD19_H_POS(rev) + APRXS_WD19_H_EN(rev))    /* 14 */
#define APRXS_WD20_H_POS(rev)    (APRXS_WD20_L_POS(rev) + APRXS_WD20_L_EN(rev))    /* 15 */
#define APRXS_WD21_L_POS(rev)    (APRXS_WD20_H_POS(rev) + APRXS_WD20_H_EN(rev))    /* 16 */
#define APRXS_WD21_H_POS(rev)    (APRXS_WD21_L_POS(rev) + APRXS_WD21_L_EN(rev))    /* 16 */
#define APRXS_WD22_L_POS(rev)    (APRXS_WD21_H_POS(rev) + APRXS_WD21_H_EN(rev))    /* 17 */
#define APRXS_WD22_H_POS(rev)    (APRXS_WD22_L_POS(rev) + APRXS_WD22_L_EN(rev))    /* 18 */
#define APRXS_WD23_L_POS(rev)    (APRXS_WD22_H_POS(rev) + APRXS_WD22_H_EN(rev))    /* 19 */
#define APRXS_WD23_H_POS(rev)    (APRXS_WD23_L_POS(rev) + APRXS_WD23_L_EN(rev))    /* 20 */
#define APRXS_WD24_L_POS(rev)    (APRXS_WD23_H_POS(rev) + APRXS_WD23_H_EN(rev))    /* 21 */
#define APRXS_WD24_H_POS(rev)    (APRXS_WD24_L_POS(rev) + APRXS_WD24_L_EN(rev))    /* 21 */
#define APRXS_WD25_L_POS(rev)    (APRXS_WD24_H_POS(rev) + APRXS_WD24_H_EN(rev))    /* 22 */
#define APRXS_WD25_H_POS(rev)    (APRXS_WD25_L_POS(rev) + APRXS_WD25_L_EN(rev))    /* 23 */
 
#define APRXS_NBYTES(rev)    (APRXS_WD25_H_POS(rev)) // total number of bytes enabled
 
// frame type
#define APRXS_FT_POS(rev)        APRXS_WD0_L_POS(rev)
#define APRXS_FT_MASK            0xFu
#define APRXS_FT(rxh, rev, min_rev) \
   ((D11REV_MAJ_MIN_GE(rev, min_rev, 87, 1) ? \
       (rxh)->ge87_1.PHYRXSTATUS[APRXS_FT_POS(rev)] : \
       (rxh)->ge85.PHYRXSTATUS[APRXS_FT_POS(rev)]) & \
       APRXS_FT_MASK)
 
// unsupported rate
#define APRXS_UNSRATE_POS(rev)        APRXS_WD0_L_POS(rev)
#define APRXS_UNSRATE_MASK        0x10u
#define APRXS_UNSRATE_SHIFT        4u
#define APRXS_UNSRATE(rxh, rev, min_rev) \
   (((D11REV_MAJ_MIN_GE(rev, min_rev, 87, 1) ? \
       (rxh)->ge87_1.PHYRXSTATUS[APRXS_UNSRATE_POS(rev)] : \
       (rxh)->ge85.PHYRXSTATUS[APRXS_UNSRATE_POS(rev)]) & \
       APRXS_UNSRATE_MASK) >> APRXS_UNSRATE_SHIFT)
 
// band
#define APRXS_BAND_POS(rev)        APRXS_WD0_L_POS(rev)
#define APRXS_BAND_MASK            0x20u
#define APRXS_BAND_SHIFT        5u
#define APRXS_BAND(rxh, rev, min_rev) \
   (((D11REV_MAJ_MIN_GE(rev, min_rev, 87, 1) ? \
       (rxh)->ge87_1.PHYRXSTATUS[APRXS_BAND_POS(rev)] : \
       (rxh)->ge85.PHYRXSTATUS[APRXS_BAND_POS(rev)]) & \
       APRXS_BAND_MASK) >> APRXS_BAND_SHIFT)
 
// lost CRS
#define APRXS_LOSTCRS_POS(rev)        APRXS_WD0_L_POS(rev)
#define APRXS_LOSTCRS_MASK        0x40u
#define APRXS_LOSTCRS_SHIFT        6u
#define APRXS_LOSTCRS(rxh, rev, min_rev) \
   (((D11REV_MAJ_MIN_GE(rev, min_rev, 87, 1) ? \
       (rxh)->ge87_1.PHYRXSTATUS[APRXS_LOSTCRS_POS(rev)] : \
       (rxh)->ge85.PHYRXSTATUS[APRXS_LOSTCRS_POS(rev)]) & \
       APRXS_LOSTCRS_MASK) >> APRXS_LOSTCRS_SHIFT)
 
// short preamble
#define APRXS_SHORTH_POS(rev)        APRXS_WD0_L_POS(rev)
#define APRXS_SHORTH_MASK        0x80u
#define APRXS_SHORTH_SHIFT        7u
#define APRXS_SHORTH(rxh, rev, min_rev) \
   (((D11REV_MAJ_MIN_GE(rev, min_rev, 87, 1) ? \
       (rxh)->ge87_1.PHYRXSTATUS[APRXS_SHORTH_POS(rev)] : \
       (rxh)->ge85.PHYRXSTATUS[APRXS_SHORTH_POS(rev)]) & \
       APRXS_SHORTH_MASK) >> APRXS_SHORTH_SHIFT)
 
// plcp format violation
#define APRXS_PLCPFV_POS(rev)        APRXS_WD0_H_POS(rev)
#define APRXS_PLCPFV_MASK        0x1u
#define APRXS_PLCPFV(rxh, rev, min_rev) \
   ((D11REV_MAJ_MIN_GE(rev, min_rev, 87, 1) ? \
       (rxh)->ge87_1.PHYRXSTATUS[APRXS_PLCPFV_POS(rev)] : \
       (rxh)->ge85.PHYRXSTATUS[APRXS_PLCPFV_POS(rev)]) & \
       APRXS_PLCPFV_MASK)
 
// plcp header CRC failed
#define APRXS_PLCPHCF_POS(rev)        APRXS_WD0_H_POS(rev)
#define APRXS_PLCPHCF_MASK        0x2u
#define APRXS_PLCPHCF_SHIFT        1u
#define APRXS_PLCPHCF(rxh, rev, min_rev) \
   (((D11REV_MAJ_MIN_GE(rev, min_rev, 87, 1) ? \
       (rxh)->ge87_1.PHYRXSTATUS[APRXS_PLCPHCF_POS(rev)] : \
       (rxh)->ge85.PHYRXSTATUS[APRXS_PLCPHCF_POS(rev)]) & \
       APRXS_PLCPHCF_MASK) >> APRXS_PLCPHCF_SHIFT)
 
// MFCRS fired
#define APRXS_MFCRS_FIRED_POS(rev)    APRXS_WD0_H_POS(rev)
#define APRXS_MFCRS_FIRED_MASK        0x4u
#define APRXS_MFCRS_FIRED_SHIFT        2u
#define APRXS_MFCRS_FIRED(rxh, rev, min_rev) \
   (((D11REV_MAJ_MIN_GE(rev, min_rev, 87, 1) ? \
       (rxh)->ge87_1.PHYRXSTATUS[APRXS_MFCRS_FIRED_POS(rev)] : \
       (rxh)->ge85.PHYRXSTATUS[APRXS_MFCRS_FIRED_POS(rev)]) & \
       APRXS_MFCRS_FIRED_MASK) >> APRXS_MFCRS_FIRED_SHIFT)
 
// ACCRS fired
#define APRXS_ACCRS_FIRED_POS(rev)    APRXS_WD0_H_POS(rev)
#define APRXS_ACCRS_FIRED_MASK        0x8u
#define APRXS_ACCRS_FIRED_SHIFT        3u
#define APRXS_ACCRS_FIRED(rxh, rev, min_rev) \
   (((D11REV_MAJ_MIN_GE(rev, min_rev, 87, 1) ? \
       (rxh)->ge87_1.PHYRXSTATUS[APRXS_ACCRS_FIRED_POS(rev)] : \
       (rxh)->ge85.PHYRXSTATUS[APRXS_ACCRS_FIRED_POS(rev)]) & \
       APRXS_ACCRS_FIRED_MASK) >> APRXS_ACCRS_FIRED_SHIFT)
 
// MU PPDU
#define APRXS_MUPPDU_POS(rev)        APRXS_WD0_H_POS(rev)
#define APRXS_MUPPDU_MASK        0x10u
#define APRXS_MUPPDU_SHIFT        4u
#define APRXS_MUPPDU(rxh, rev, min_rev) \
   (((D11REV_MAJ_MIN_GE(rev, min_rev, 87, 1) ? \
       (rxh)->ge87_1.PHYRXSTATUS[APRXS_MUPPDU_POS(rev)] : \
       (rxh)->ge85.PHYRXSTATUS[APRXS_MUPPDU_POS(rev)]) & \
       APRXS_MUPPDU_MASK) >> APRXS_MUPPDU_SHIFT)
 
// OBSS status
#define APRXS_OBSS_STS_POS(rev)        APRXS_WD0_H_POS(rev)
#define APRXS_OBSS_STS_MASK        0xE0u
#define APRXS_OBSS_STS_SHIFT        5u
#define APRXS_OBSS_STS(rxh, rev, min_rev) \
   (((D11REV_MAJ_MIN_GE(rev, min_rev, 87, 1) ? \
       (rxh)->ge87_1.PHYRXSTATUS[APRXS_OBSS_STS_POS(rev)] : \
       (rxh)->ge85.PHYRXSTATUS[APRXS_OBSS_STS_POS(rev)]) & \
       APRXS_OBSS_STS_MASK) >> APRXS_OBSS_STS_SHIFT)
 
// coremask
#define APRXS_COREMASK_POS(rev)        APRXS_WD1_L_POS(rev)
#define APRXS_COREMASK_MASK        0xFu
#define APRXS_COREMASK(rxh, rev, min_rev) \
   ((D11REV_MAJ_MIN_GE(rev, min_rev, 87, 1) ? \
       (rxh)->ge87_1.PHYRXSTATUS[APRXS_COREMASK_POS(rev)] : \
       (rxh)->ge85.PHYRXSTATUS[APRXS_COREMASK_POS(rev)]) & \
       APRXS_COREMASK_MASK)
 
// antcfg
#define APRXS_ANTCFG_POS(rev)        APRXS_WD1_L_POS(rev)
#define APRXS_ANTCFG_MASK        0xF0u
#define APRXS_ANTCFG_SHIFT        4u
#define APRXS_ANTCFG(rxh, rev, min_rev) \
   (((D11REV_MAJ_MIN_GE(rev, min_rev, 87, 1) ? \
       (rxh)->ge87_1.PHYRXSTATUS[APRXS_ANTCFG_POS(rev)] : \
       (rxh)->ge85.PHYRXSTATUS[APRXS_ANTCFG_POS(rev)]) & \
       APRXS_ANTCFG_MASK) >> APRXS_ANTCFG_SHIFT)
 
// final BW classification
#define APRXS_SUBBAND_POS(rev)        APRXS_WD1_H_POS(rev)
#define APRXS_SUBBAND_MASK        0xFFu
#define APRXS_SUBBAND(rxh, rev, min_rev) \
   ((D11REV_MAJ_MIN_GE(rev, min_rev, 87, 1) ? \
       (rxh)->ge87_1.PHYRXSTATUS[APRXS_SUBBAND_POS(rev)] : \
       (rxh)->ge85.PHYRXSTATUS[APRXS_SUBBAND_POS(rev)]) & \
       APRXS_SUBBAND_MASK)
 
// Rx power Antenna0
#define APRXS_RXPWR_ANT0_POS(rev)    APRXS_WD2_L_POS(rev)
#define APRXS_RXPWR_ANT0_MASK        0xFFu
#define APRXS_RXPWR_ANT0(rxh, rev, min_rev) \
   ((D11REV_MAJ_MIN_GE(rev, min_rev, 87, 1) ? \
       (rxh)->ge87_1.PHYRXSTATUS[APRXS_RXPWR_ANT0_POS(rev)] : \
       (rxh)->ge85.PHYRXSTATUS[APRXS_RXPWR_ANT0_POS(rev)]) & \
       APRXS_RXPWR_ANT0_MASK)
 
// Rx power Antenna1
#define APRXS_RXPWR_ANT1_POS(rev)    APRXS_WD2_H_POS(rev)
#define APRXS_RXPWR_ANT1_MASK        0xFFu
#define APRXS_RXPWR_ANT1(rxh, rev, min_rev) \
   ((D11REV_MAJ_MIN_GE(rev, min_rev, 87, 1) ? \
       (rxh)->ge87_1.PHYRXSTATUS[APRXS_RXPWR_ANT1_POS(rev)] : \
       (rxh)->ge85.PHYRXSTATUS[APRXS_RXPWR_ANT1_POS(rev)]) & \
       APRXS_RXPWR_ANT1_MASK)
 
// Rx power Antenna2
#define APRXS_RXPWR_ANT2_POS(rev)    APRXS_WD3_L_POS(rev)
#define APRXS_RXPWR_ANT2_MASK        0xFFu
#define APRXS_RXPWR_ANT2(rxh, rev, min_rev) \
   ((D11REV_MAJ_MIN_GE(rev, min_rev, 87, 1) ? \
       (rxh)->ge87_1.PHYRXSTATUS[APRXS_RXPWR_ANT2_POS(rev)] : \
       (rxh)->ge85.PHYRXSTATUS[APRXS_RXPWR_ANT2_POS(rev)]) & \
       APRXS_RXPWR_ANT2_MASK)
 
// Rx power Antenna3
#define APRXS_RXPWR_ANT3_POS(rev)    APRXS_WD3_H_POS(rev)
#define APRXS_RXPWR_ANT3_MASK        0xFFu
#define APRXS_RXPWR_ANT3(rxh, rev, min_rev) \
   ((D11REV_MAJ_MIN_GE(rev, min_rev, 87, 1) ? \
       (rxh)->ge87_1.PHYRXSTATUS[APRXS_RXPWR_ANT3_POS(rev)] : \
       (rxh)->ge85.PHYRXSTATUS[APRXS_RXPWR_ANT3_POS(rev)]) & \
       APRXS_RXPWR_ANT3_MASK)
 
// RX ELNA INDEX ANT0
#define APRXS_ELNA_IDX_ANT0_POS(rev)    APRXS_WD20_L_POS(rev)
#define APRXS_ELNA_IDX_ANT0_MASK        0x2u
#define APRXS_ELNA_IDX_ANT0_SHIFT        1u
#define APRXS_ELNA_IDX_ANT0(rxh, rev, min_rev) \
   (((D11REV_MAJ_MIN_GE(rev, min_rev, 87, 1) ? \
       (rxh)->ge87_1.PHYRXSTATUS[APRXS_ELNA_IDX_ANT0_POS(rev)] : \
       (rxh)->ge85.PHYRXSTATUS[APRXS_ELNA_IDX_ANT0_POS(rev)]) & \
       APRXS_ELNA_IDX_ANT0_MASK) >> APRXS_ELNA_IDX_ANT0_SHIFT)
 
// RX ELNA INDEX ANT1
#define APRXS_ELNA_IDX_ANT1_POS(rev)    APRXS_WD20_L_POS(rev)
#define APRXS_ELNA_IDX_ANT1_MASK        0x20u
#define APRXS_ELNA_IDX_ANT1_SHIFT        5u
#define APRXS_ELNA_IDX_ANT1(rxh, rev, min_rev) \
   (((D11REV_MAJ_MIN_GE(rev, min_rev, 87, 1) ? \
       (rxh)->ge87_1.PHYRXSTATUS[APRXS_ELNA_IDX_ANT1_POS(rev)] : \
       (rxh)->ge85.PHYRXSTATUS[APRXS_ELNA_IDX_ANT1_POS(rev)]) & \
       APRXS_ELNA_IDX_ANT1_MASK) >> APRXS_ELNA_IDX_ANT1_SHIFT)
 
// RX TIA INDEX ANT0 LO
#define APRXS_TIA_IDX_ANT0_POS(rev)    APRXS_WD16_L_POS(rev)
#define APRXS_TIA_IDX_ANT0_MASK        0x1Cu
#define APRXS_TIA_IDX_ANT0_SHIFT    2u
#define APRXS_TIA_IDX_ANT0(rxh, rev, min_rev) \
   (((D11REV_MAJ_MIN_GE(rev, min_rev, 87, 1) ? \
       (rxh)->ge87_1.PHYRXSTATUS[APRXS_TIA_IDX_ANT0_POS(rev)] : \
       (rxh)->ge85.PHYRXSTATUS[APRXS_TIA_IDX_ANT0_POS(rev)]) & \
       APRXS_TIA_IDX_ANT0_MASK) >> APRXS_TIA_IDX_ANT0_SHIFT)
 
// RX TIA INDEX ANT1 LO
#define APRXS_TIA_IDX_ANT1_POS(rev)    APRXS_WD18_L_POS(rev)
#define APRXS_TIA_IDX_ANT1_MASK        0x1Cu
#define APRXS_TIA_IDX_ANT1_SHIFT        2u
#define APRXS_TIA_IDX_ANT1(rxh, rev, min_rev) \
   (((D11REV_MAJ_MIN_GE(rev, min_rev, 87, 1) ? \
       (rxh)->ge87_1.PHYRXSTATUS[APRXS_TIA_IDX_ANT1_POS(rev)] : \
       (rxh)->ge85.PHYRXSTATUS[APRXS_TIA_IDX_ANT1_POS(rev)]) & \
       APRXS_TIA_IDX_ANT1_MASK) >> APRXS_TIA_IDX_ANT1_SHIFT)
 
// RX VSW INDEX ANT0
#define APRXS_VSW_IDX_ANT0_POS(rev)    APRXS_WD20_L_POS(rev)
#define APRXS_VSW_IDX_ANT0_MASK        0x8u
#define APRXS_VSW_IDX_ANT0_SHIFT    3u
#define APRXS_VSW_IDX_ANT0(rxh, rev, min_rev) \
   (((D11REV_MAJ_MIN_GE(rev, min_rev, 87, 1) ? \
       (rxh)->ge87_1.PHYRXSTATUS[APRXS_VSW_IDX_ANT0_POS(rev)] : \
       (rxh)->ge85.PHYRXSTATUS[APRXS_VSW_IDX_ANT0_POS(rev)]) & \
       APRXS_VSW_IDX_ANT0_MASK) >> APRXS_VSW_IDX_ANT0_SHIFT)
 
// RX VSW INDEX ANT1
#define APRXS_VSW_IDX_ANT1_POS(rev)    APRXS_WD20_L_POS(rev)
#define APRXS_VSW_IDX_ANT1_MASK        0x80u
#define APRXS_VSW_IDX_ANT1_SHIFT    7u
#define APRXS_VSW_IDX_ANT1(rxh, rev, min_rev) \
   (((D11REV_MAJ_MIN_GE(rev, min_rev, 87, 1) ? \
       (rxh)->ge87_1.PHYRXSTATUS[APRXS_VSW_IDX_ANT1_POS(rev)] : \
       (rxh)->ge85.PHYRXSTATUS[APRXS_VSW_IDX_ANT1_POS(rev)]) & \
       APRXS_VSW_IDX_ANT1_MASK) >> APRXS_VSW_IDX_ANT1_SHIFT)
 
// RSSI fractional bits
#define APRXS_RXPWR_FRAC_POS(rev)    APRXS_WD4_L_POS(rev)
#define APRXS_RXPWR_FRAC_MASK        0xFFu
#define APRXS_RXPWR_FRAC(rxh, rev, min_rev) \
   ((D11REV_MAJ_MIN_GE(rev, min_rev, 87, 1) ? \
       (rxh)->ge87_1.PHYRXSTATUS[APRXS_RXPWR_FRAC_POS(rev)] : \
       (rxh)->ge85.PHYRXSTATUS[APRXS_RXPWR_FRAC_POS(rev)]) & \
       APRXS_RXPWR_FRAC_MASK)
 
// Ucode overwrites ClipCount with GILTF
#define APRXS_GILTF_POS(rev)        APRXS_WD4_H_POS(rev)
#define APRXS_GILTF_MASK        0x18u
#define APRXS_GILTF_SHIFT        3u
#define APRXS_GILTF(rxh, rev, min_rev) \
   (((D11REV_MAJ_MIN_GE(rev, min_rev, 87, 1) ? \
       (rxh)->ge87_1.PHYRXSTATUS[APRXS_GILTF_POS(rev)] : \
       (rxh)->ge85.PHYRXSTATUS[APRXS_GILTF_POS(rev)]) & \
       APRXS_GILTF_MASK) >> APRXS_GILTF_SHIFT)
 
#define APRXS_DYNBWINNONHT_POS(rev)    APRXS_WD4_H_POS(rev)
#define APRXS_DYNBWINNONHT_MASK        0x20u
#define APRXS_DYNBWINNONHT_SHIFT    5u
#define APRXS_DYNBWINNONHT(rxh, rev, min_rev) \
   (((D11REV_MAJ_MIN_GE(rev, min_rev, 87, 1) ? \
       (rxh)->ge87_1.PHYRXSTATUS[APRXS_DYNBWINNONHT_POS(rev)] : \
       (rxh)->ge85.PHYRXSTATUS[APRXS_DYNBWINNONHT_POS(rev)]) & \
       APRXS_DYNBWINNONHT_MASK) >> APRXS_DYNBWINNONHT_SHIFT)
 
#define APRXS_MCSSQSNR0_POS(rev)    APRXS_WD5_L_POS(rev)
#define APRXS_MCSSQSNR0_MASK        0xFFu
#define APRXS_MCSSQSNR0(rxh, rev, min_rev) \
   ((D11REV_MAJ_MIN_GE(rev, min_rev, 87, 1) ? \
       (rxh)->ge87_1.PHYRXSTATUS[APRXS_MCSSQSNR0_POS(rev)] : \
       (rxh)->ge85.PHYRXSTATUS[APRXS_MCSSQSNR0_POS(rev)]) & \
       APRXS_MCSSQSNR0_MASK)
 
#define APRXS_MCSSQSNR1_POS(rev)    APRXS_WD5_H_POS(rev)
#define APRXS_MCSSQSNR1_MASK        0xFFu
#define APRXS_MCSSQSNR1(rxh, rev, min_rev) \
   ((D11REV_MAJ_MIN_GE(rev, min_rev, 87, 1) ? \
       (rxh)->ge87_1.PHYRXSTATUS[APRXS_MCSSQSNR1_POS(rev)] : \
       (rxh)->ge85.PHYRXSTATUS[APRXS_MCSSQSNR1_POS(rev)]) & \
       APRXS_MCSSQSNR1_MASK)
 
#define APRXS_MCSSQSNR2_POS(rev)    APRXS_WD6_L_POS(rev)
#define APRXS_MCSSQSNR2_MASK        0xFFu
#define APRXS_MCSSQSNR2(rxh, rev, min_rev) \
   ((D11REV_MAJ_MIN_GE(rev, min_rev, 87, 1) ? \
       (rxh)->ge87_1.PHYRXSTATUS[APRXS_MCSSQSNR2_POS(rev)] : \
       (rxh)->ge85.PHYRXSTATUS[APRXS_MCSSQSNR2_POS(rev)]) & \
       APRXS_MCSSQSNR2_MASK)
 
#define APRXS_CHBWINNONHT_POS(rev)    APRXS_WD8_H_POS(rev)
#define APRXS_CHBWINNONHT_MASK        0x3u
#define APRXS_CHBWINNONHT(rxh, rev, min_rev) \
   ((D11REV_MAJ_MIN_GE(rev, min_rev, 87, 1) ? \
       (rxh)->ge87_1.PHYRXSTATUS[APRXS_CHBWINNONHT_POS(rev)] : \
       (rxh)->ge85.PHYRXSTATUS[APRXS_CHBWINNONHT_POS(rev)]) & \
       APRXS_CHBWINNONHT_MASK)
 
// User type
#define APRXS_USTY_POS(rev)        APRXS_WD23_H_POS(rev)
#define APRXS_USTY_MASK            0xE0u
#define APRXS_USTY_SHIFT        0x5u
#define APRXS_USTY(rxh, rev, min_rev) \
   (((D11REV_MAJ_MIN_GE(rev, min_rev, 87, 1) ? \
       (rxh)->ge87_1.PHYRXSTATUS[APRXS_USTY_POS(rev)] : \
       (rxh)->ge85.PHYRXSTATUS[APRXS_USTY_POS(rev)]) & \
       APRXS_USTY_MASK) >> APRXS_USTY_SHIFT)
 
// 11ax frame format
#define APRXS_AXFF_POS(rev)        APRXS_WD20_H_POS(rev)
#define APRXS_AXFF_MASK            0x7u
#define APRXS_AXFF(rxh, rev, min_rev) \
   ((D11REV_MAJ_MIN_GE(rev, min_rev, 87, 1) ? \
       (rxh)->ge87_1.PHYRXSTATUS[APRXS_AXFF_POS(rev)] : \
       (rxh)->ge85.PHYRXSTATUS[APRXS_AXFF_POS(rev)]) & \
       APRXS_AXFF_MASK)
 
// MCS
#define APRXS_AXMCS_POS(rev)        APRXS_WD21_H_POS(rev)
#define APRXS_AXMCS_MASK        0xFu
#define APRXS_AXMCS(rxh, rev, min_rev) \
   ((D11REV_MAJ_MIN_GE(rev, min_rev, 87, 1) ? \
       (rxh)->ge87_1.PHYRXSTATUS[APRXS_AXMCS_POS(rev)] : \
       (rxh)->ge85.PHYRXSTATUS[APRXS_AXMCS_POS(rev)]) & \
       APRXS_AXMCS_MASK)
 
// Coding
#define APRXS_CODING_POS(rev)        APRXS_WD21_H_POS(rev)
#define APRXS_CODING_MASK        0x10u
#define APRXS_CODING_SHIFT        4u
#define APRXS_CODING(rxh, rev, min_rev) \
   (((D11REV_MAJ_MIN_GE(rev, min_rev, 87, 1) ? \
       (rxh)->ge87_1.PHYRXSTATUS[APRXS_CODING_POS(rev)] : \
       (rxh)->ge85.PHYRXSTATUS[APRXS_CODING_POS(rev)]) & \
       APRXS_CODING_MASK) >> APRXS_CODING_SHIFT)
 
// STAID
#define APRXS_AX_STAID_L_POS(rev)        APRXS_WD22_L_POS(rev)
#define APRXS_AX_STAID_L_MASK        0xFFu
#define APRXS_AX_STAID_L(rxh, rev, min_rev) \
   ((D11REV_MAJ_MIN_GE(rev, min_rev, 87, 1) ? \
       (rxh)->ge87_1.PHYRXSTATUS[APRXS_AX_STAID_L_POS(rev)] : \
       (rxh)->ge85.PHYRXSTATUS[APRXS_AX_STAID_L_POS(rev)]) & \
       APRXS_AX_STAID_L_MASK)
 
#define APRXS_AX_STAID_H_POS(rev)        APRXS_WD22_H_POS(rev)
#define APRXS_AX_STAID_H_MASK        0x03u
#define APRXS_AX_STAID_H(rxh, rev, min_rev) \
   ((D11REV_MAJ_MIN_GE(rev, min_rev, 87, 1) ? \
       (rxh)->ge87_1.PHYRXSTATUS[APRXS_AX_STAID_H_POS(rev)] : \
       (rxh)->ge85.PHYRXSTATUS[APRXS_AX_STAID_H_POS(rev)]) & \
       APRXS_AX_STAID_H_MASK)
 
#define APRXS_AX_STAID(rxh, rev, min_rev)    ((APRXS_AX_STAID_H(rxh, rev, min_rev) << 1) |\
       APRXS_AX_STAID_L(rxh, rev, min_rev))
 
// NSTS
#define APRXS_NSTS_POS(rev)        APRXS_WD22_H_POS(rev)
#define APRXS_NSTS_MASK            0x38u
#define APRXS_NSTS_SHIFT        3u
#define APRXS_NSTS(rxh, rev, min_rev) \
   (((D11REV_MAJ_MIN_GE(rev, min_rev, 87, 1) ? \
       (rxh)->ge87_1.PHYRXSTATUS[APRXS_DCM_POS(rev)] : \
       (rxh)->ge85.PHYRXSTATUS[APRXS_DCM_POS(rev)]) & \
       APRXS_NSTS_MASK) >> APRXS_NSTS_SHIFT)
 
// TXBF
#define APRXS_TXBF_POS(rev)        APRXS_WD22_H_POS(rev)
#define APRXS_TXBF_MASK            0x40u
#define APRXS_TXBF_SHIFT        6u
#define APRXS_TXBF(rxh, rev, min_rev) \
   (((D11REV_MAJ_MIN_GE(rev, min_rev, 87, 1) ? \
       (rxh)->ge87_1.PHYRXSTATUS[APRXS_TXBF_POS(rev)] : \
       (rxh)->ge85.PHYRXSTATUS[APRXS_TXBF_POS(rev)]) & \
           APRXS_TXBF_MASK) >> APRXS_TXBF_SHIFT)
 
//DCM
#define APRXS_DCM_POS(rev)        APRXS_WD22_H_POS(rev)
#define APRXS_DCM_MASK            0x80u
#define APRXS_DCM_SHIFT            7u
#define APRXS_DCM(rxh, rev, min_rev) \
   (((D11REV_MAJ_MIN_GE(rev, min_rev, 87, 1) ? \
       (rxh)->ge87_1.PHYRXSTATUS[APRXS_DCM_POS(rev)] : \
       (rxh)->ge85.PHYRXSTATUS[APRXS_DCM_POS(rev)]) & \
       APRXS_DCM_MASK) >> APRXS_DCM_SHIFT)
 
// RU Offset
#define APRXS_AX_RUALLOC_POS(rev)    APRXS_WD23_L_POS(rev)
#define APRXS_AX_RUALLOC_MASK        0x7Fu
#define APRXS_AX_RUALLOC_SHIFT        0u
#define APRXS_AX_RUALLOC(rxh, rev, min_rev) \
   (((D11REV_MAJ_MIN_GE(rev, min_rev, 87, 1) ? \
       (rxh)->ge87_1.PHYRXSTATUS[APRXS_AX_RUALLOC_POS(rev)] : \
       (rxh)->ge85.PHYRXSTATUS[APRXS_AX_RUALLOC_POS(rev)]) & \
       APRXS_AX_RUALLOC_MASK) >> APRXS_AX_RUALLOC_SHIFT)
 
#define APRXS_PE_L_POS(rev)        APRXS_WD23_L_POS(rev)
#define APRXS_PE_L_MASK            0x80u
#define APRXS_PE_L_SHIFT        7u
#define APRXS_PE_L(rxh, rev, min_rev) \
   (((D11REV_MAJ_MIN_GE(rev, min_rev, 87, 1) ? \
       (rxh)->ge87_1.PHYRXSTATUS[APRXS_PE_L_POS(rev)] : \
       (rxh)->ge85.PHYRXSTATUS[APRXS_PE_L_POS(rev)]) & \
           APRXS_PE_L_MASK) >> APRXS_PE_L_SHIFT)
 
#define APRXS_PE_H_POS(rev)        APRXS_WD23_H_POS(rev)
#define APRXS_PE_H_MASK            0x3u
#define APRXS_PE_H(rxh, rev, min_rev) \
   ((D11REV_MAJ_MIN_GE(rev, min_rev, 87, 1) ? \
       (rxh)->ge87_1.PHYRXSTATUS[APRXS_PE_H_POS(rev)] : \
       (rxh)->ge85.PHYRXSTATUS[APRXS_PE_H_POS(rev)]) & \
       APRXS_PE_H_MASK)
 
#define APRXS_PE(rxh, rev, rev_min) \
   ((APRXS_PE_H(rxh, rev, rev_min) << 1) | APRXS_PE_L(rxh, rev, rev_min))
 
#define APRXS_RU_POS(rev)        APRXS_WD23_H_POS(rev)
#define APRXS_RU_MASK            0x1Cu
#define APRXS_RU_SHIFT            2u
#define APRXS_RU(rxh, rev, min_rev) \
   (((D11REV_MAJ_MIN_GE(rev, min_rev, 87, 1) ? \
       (rxh)->ge87_1.PHYRXSTATUS[APRXS_RU_POS(rev)] : \
       (rxh)->ge85.PHYRXSTATUS[APRXS_RU_POS(rev)]) & \
       APRXS_RU_MASK) >> APRXS_RU_SHIFT)
 
#endif /* _d11_autophyrxsts_ */
 
#if defined(AUTO_PHYRXSTS)
#define AUTO_PHYRXSTS_ENAB()        1u
#else
#define AUTO_PHYRXSTS_ENAB()        0u
#endif /* AUTO_PHYRXSTS */
 
/* PhyRxStatus_0: */
#define    PRXS0_FT_MASK        0x0003u    /**< [PRE-HE] NPHY only: CCK, OFDM, HT, VHT */
#define    PRXS0_CLIP_MASK        0x000Cu    /**< NPHY only: clip count adjustment steps by AGC */
#define    PRXS0_CLIP_SHIFT    2u    /**< SHIFT bits for clip count adjustment */
#define    PRXS0_UNSRATE        0x0010u    /**< PHY received a frame with unsupported rate */
#define PRXS0_UNSRATE_SHIFT    4u
#define    PRXS0_RXANT_UPSUBBAND    0x0020u    /**< GPHY: rx ant, NPHY: upper sideband */
#define    PRXS0_LCRS        0x0040u    /**< CCK frame only: lost crs during cck frame reception */
#define    PRXS0_SHORTH        0x0080u    /**< Short Preamble */
#define PRXS0_SHORTH_SHIFT    7u
#define    PRXS0_PLCPFV        0x0100u    /**< PLCP violation */
#define    PRXS0_PLCPFV_SHIFT    8u
#define    PRXS0_PLCPHCF        0x0200u    /**< PLCP header integrity check failed */
#define    PRXS0_PLCPHCF_SHIFT    9u
#define    PRXS0_GAIN_CTL        0x4000u    /**< legacy PHY gain control */
#define PRXS0_ANTSEL_MASK    0xF000u    /**< NPHY: Antennas used for received frame, bitmask */
#define PRXS0_ANTSEL_SHIFT    12u    /**< SHIFT bits for Antennas used for received frame */
#define PRXS0_PPDU_MASK         0x1000u  /**< PPDU type SU/MU */
 
/* subfield PRXS0_FT_MASK [PRXS0_PRE_HE_FT_MASK] */
#define    PRXS0_CCK        0x0000u
#define    PRXS0_OFDM        0x0001u    /**< valid only for G phy, use rxh->RxChan for A phy */
#define    PRXS0_PREN        0x0002u
#define    PRXS0_STDN        0x0003u
 
/* subfield PRXS0_ANTSEL_MASK */
#define PRXS0_ANTSEL_0        0x0u    /**< antenna 0 is used */
#define PRXS0_ANTSEL_1        0x2u    /**< antenna 1 is used */
#define PRXS0_ANTSEL_2        0x4u    /**< antenna 2 is used */
#define PRXS0_ANTSEL_3        0x8u    /**< antenna 3 is used */
 
/* PhyRxStatus_1: */
#define PRXS1_JSSI_MASK         0x00FFu
#define PRXS1_JSSI_SHIFT        0u
#define PRXS1_SQ_MASK           0xFF00u
#define PRXS1_SQ_SHIFT          8u
#define PRXS1_COREMAP           0x000Fu  /**< core enable bits for core 0/1/2/3 */
#define PRXS1_ANTCFG            0x00F0u  /**< anttenna configuration bits */
 
#define PHY_COREMAP_LT85(rxh, rev) \
   ((D11REV_GE(rev, 80) ? D11RXHDR_GE80_ACCESS_VAL(rxh, PhyRxStatus_1) : \
       D11RXHDR_LT80_ACCESS_VAL(rxh, PhyRxStatus_1)) & \
       PRXS1_COREMAP)
#define PHY_COREMAP(rev, rev_min, rxh)        (AUTO_PHYRXSTS_ENAB() ?        \
       APRXS_COREMASK(rxh, rev, rev_min) : PHY_COREMAP_LT85(rxh, rev))
 
#define PHY_ANTMAP_LT85(rxh, corerev) \
   (((D11REV_GE(corerev, 80) ? D11RXHDR_GE80_ACCESS_VAL(rxh, PhyRxStatus_1) : \
       D11RXHDR_LT80_ACCESS_VAL(rxh, PhyRxStatus_1)) & \
       PRXS1_ANTCFG) >> 4)
#define PHY_ANTMAP(rev, rev_min, rxh)        (AUTO_PHYRXSTS_ENAB() ?        \
       APRXS_ANTCFG(rxh, rev, rev_min) : PHY_ANTMAP_LT85(rxh, rev))
 
/* nphy PhyRxStatus_1: */
#define PRXS1_nphy_PWR0_MASK    0x00FF
#define PRXS1_nphy_PWR1_MASK    0xFF00
 
/* PhyRxStatus_2: */
#define    PRXS2_LNAGN_MASK    0xC000
#define    PRXS2_LNAGN_SHIFT    14
#define    PRXS2_PGAGN_MASK    0x3C00
#define    PRXS2_PGAGN_SHIFT    10
#define    PRXS2_FOFF_MASK        0x03FF
 
/* nphy PhyRxStatus_2: */
#define PRXS2_nphy_SQ_ANT0    0x000F    /**< nphy overall signal quality for antenna 0 */
#define PRXS2_nphy_SQ_ANT1    0x00F0    /**< nphy overall signal quality for antenna 0 */
#define PRXS2_nphy_cck_SQ    0x00FF    /**< bphy signal quality(when FT field is 0) */
#define PRXS3_nphy_SSQ_MASK    0xFF00    /**< spatial conditioning of the two receive channels */
#define PRXS3_nphy_SSQ_SHIFT    8
 
/* PhyRxStatus_3: */
#define    PRXS3_DIGGN_MASK    0x1800
#define    PRXS3_DIGGN_SHIFT    11
#define    PRXS3_TRSTATE        0x0400
 
/* nphy PhyRxStatus_3: */
#define PRXS3_nphy_MMPLCPLen_MASK    0x0FFF    /**< Mixed-mode preamble PLCP length */
#define PRXS3_nphy_MMPLCP_RATE_MASK    0xF000    /**< Mixed-mode preamble rate field */
#define PRXS3_nphy_MMPLCP_RATE_SHIFT    12
 
/* HTPHY Rx Status defines */
/* htphy PhyRxStatus_0: those bit are overlapped with PhyRxStatus_0 */
#define PRXS0_BAND            0x0400    /**< 0 = 2.4G, 1 = 5G */
#define PRXS0_RSVD            0x0800    /**< reserved; set to 0 */
#define PRXS0_UNUSED            0xF000    /**< unused and not defined; set to 0 */
 
/* htphy PhyRxStatus_1: */
#define PRXS1_HTPHY_MMPLCPLenL_MASK    0xFF00    /**< Mixmode PLCP Length low byte mask */
 
/* htphy PhyRxStatus_2: */
#define PRXS2_HTPHY_MMPLCPLenH_MASK    0x000F    /**< Mixmode PLCP Length high byte maskw */
#define PRXS2_HTPHY_MMPLCH_RATE_MASK    0x00F0    /**< Mixmode PLCP rate mask */
#define PRXS2_HTPHY_RXPWR_ANT0    0xFF00    /**< Rx power on core 0 */
 
/* htphy PhyRxStatus_3: */
#define PRXS3_HTPHY_RXPWR_ANT1    0x00FF    /**< Rx power on core 1 */
#define PRXS3_HTPHY_RXPWR_ANT2    0xFF00    /**< Rx power on core 2 */
 
/* htphy PhyRxStatus_4: */
#define PRXS4_HTPHY_RXPWR_ANT3    0x00FF    /**< Rx power on core 3 */
#define PRXS4_HTPHY_CFO        0xFF00    /**< Coarse frequency offset */
 
/* htphy PhyRxStatus_5: */
#define PRXS5_HTPHY_FFO            0x00FF    /**< Fine frequency offset */
#define PRXS5_HTPHY_AR            0xFF00    /**< Advance Retard */
 
/* ACPHY RxStatus defs */
 
/* ACPHY PhyRxStatus_0: */
#define PRXS0_ACPHY_FT_MASK      0x0003  /**< CCK, OFDM, HT, VHT */
#define PRXS0_ACPHY_CLIP_MASK    0x000C  /**< clip count adjustment steps by AGC */
#define PRXS0_ACPHY_CLIP_SHIFT        2
#define PRXS0_ACPHY_UNSRATE      0x0010  /**< PHY received a frame with unsupported rate */
#define PRXS0_ACPHY_BAND5G       0x0020  /**< Rx Band indication: 0 -> 2G, 1 -> 5G */
#define PRXS0_ACPHY_LCRS         0x0040  /**< CCK frame only: lost crs during cck frame reception */
#define PRXS0_ACPHY_SHORTH       0x0080  /**< Short Preamble (CCK), GF preamble (HT) */
#define PRXS0_ACPHY_PLCPFV       0x0100  /**< PLCP violation */
#define PRXS0_ACPHY_PLCPHCF      0x0200  /**< PLCP header integrity check failed */
#define PRXS0_ACPHY_MFCRS        0x0400  /**< Matched Filter CRS fired */
#define PRXS0_ACPHY_ACCRS        0x0800  /**< Autocorrelation CRS fired */
#define PRXS0_ACPHY_SUBBAND_MASK 0xF000  /**< FinalBWClassification:
                                     * lower nibble Bitfield of sub-bands occupied by Rx frame
                                     */
/* ACPHY PhyRxStatus_1: */
#define PRXS1_ACPHY_ANT_CORE0    0x0001    /* Antenna Config for core 0 */
#define PRXS1_ACPHY_SUBBAND_MASK_GEN2 0xFF00  /**< FinalBWClassification:
                    * lower byte Bitfield of sub-bands occupied by Rx frame
                    */
#define PRXS0_ACPHY_SUBBAND_SHIFT    12
#define PRXS1_ACPHY_SUBBAND_SHIFT_GEN2    8
 
/* acphy PhyRxStatus_3: */
#define PRXS2_ACPHY_RXPWR_ANT0    0xFF00    /**< Rx power on core 1 */
#define PRXS3_ACPHY_RXPWR_ANT1    0x00FF    /**< Rx power on core 1 */
#define PRXS3_ACPHY_RXPWR_ANT2    0xFF00    /**< Rx power on core 2 */
#define PRXS3_ACPHY_SNR_ANT0 0xFF00     /* SNR on core 0 */
 
/* acphy PhyRxStatus_4: */
/** FinalBWClassification:upper nibble of sub-bands occupied by Rx frame */
#define PRXS4_ACPHY_SUBBAND_MASK 0x000F
#define PRXS4_ACPHY_RXPWR_ANT3    0x00FF    /**< Rx power on core 3 */
#define PRXS4_ACPHY_SNR_ANT1 0xFF00     /* SNR on core 1 */
 
#define PRXS5_ACPHY_CHBWINNONHT_MASK 0x0003
#define PRXS5_ACPHY_CHBWINNONHT_20MHZ    0
#define PRXS5_ACPHY_CHBWINNONHT_40MHZ    1
#define PRXS5_ACPHY_CHBWINNONHT_80MHZ    2
#define PRXS5_ACPHY_CHBWINNONHT_160MHZ    3 /* includes 80+80 */
#define PRXS5_ACPHY_DYNBWINNONHT_MASK 0x0004
 
/** Get Rx power on core 0 */
#define ACPHY_RXPWR_ANT0(rxs)    (((rxs)->lt80.PhyRxStatus_2 & PRXS2_ACPHY_RXPWR_ANT0) >> 8)
/** Get Rx power on core 1 */
#define ACPHY_RXPWR_ANT1(rxs)    ((rxs)->lt80.PhyRxStatus_3 & PRXS3_ACPHY_RXPWR_ANT1)
/** Get Rx power on core 2 */
#define ACPHY_RXPWR_ANT2(rxs)    (((rxs)->lt80.PhyRxStatus_3 & PRXS3_ACPHY_RXPWR_ANT2) >> 8)
/** Get Rx power on core 3 */
#define ACPHY_RXPWR_ANT3(rxs)    ((rxs)->lt80.PhyRxStatus_4 & PRXS4_ACPHY_RXPWR_ANT3)
 
/** MCSSQSNR location access. MCSSQ usage is limited by chip specific impl,
 * and there is no way to commonize these status location yet.
 * TODO: When the storage locations are settled we need to revisit
 * this defs controls.
 */
 
/* exception handling */
#ifdef PHY_CORE_MAX
#if PHY_CORE_MAX > 4
#error "PHY_CORE_MAX is exceeded more than MCSSQSNR defs (4)"
#endif
#endif /* PHY_CORE_MAX */
 
/* rev 48/55/59 are obsoleted for SNR in trunk */
#define D11_PRXS_MCSSQ_SNR_SUPPORT(corerev)    (D11REV_GE((corerev), 80))
 
#define ACPHY_SNR_MASK    (0xFF)
#define ACPHY_SNR_SHIFT    (8)
 
#define PRXS5_ACPHY_DYNBWINNONHT(rxs) ((rxs)->lt80.PhyRxStatus_5 & PRXS5_ACPHY_DYNBWINNONHT_MASK)
#define PRXS5_ACPHY_CHBWINNONHT(rxs) ((rxs)->lt80.PhyRxStatus_5 & PRXS5_ACPHY_CHBWINNONHT_MASK)
 
#define D11N_MMPLCPLen(rxs)    ((rxs)->lt80.PhyRxStatus_3 & PRXS3_nphy_MMPLCPLen_MASK)
#define D11HT_MMPLCPLen(rxs) ((((rxs)->lt80.PhyRxStatus_1 & PRXS1_HTPHY_MMPLCPLenL_MASK) >> 8) | \
                 (((rxs)->lt80.PhyRxStatus_2 & PRXS2_HTPHY_MMPLCPLenH_MASK) << 8))
 
/* REV80 Defintions (corerev >= 80) */
 
/** Dma_flags Masks */
#define RXS_PHYRXST_VALID_REV_GE80    0x02
 
/** Get RxStatus1 */
#define RXSTATUS1_REV_GE87_1(rxs)    ((rxs)->ge87_1.RxStatus1)
#define RXSTATUS1_REV_GE80(rxs)        ((rxs)->ge80.RxStatus1)
#define RXSTATUS1_REV_LT80(rxs)        ((rxs)->lt80.RxStatus1)
 
#define PHY_RXSTATUS1(corerev, corerev_minor, rxs) \
   (D11REV_MAJ_MIN_GE(corerev, corerev_minor, 87, 1) ? RXSTATUS1_REV_GE87_1(rxs) : \
   D11REV_GE(corerev, 80) ? RXSTATUS1_REV_GE80(rxs) : \
   RXSTATUS1_REV_LT80(rxs))
 
/* (FT Mask) PhyRxStatus_0: */
#define PRXS0_FT_MASK_REV_LT80        PRXS0_FT_MASK    /**< (corerev < 80) frame type field mask */
 
#define    PRXS0_FT_SHIFT_REV_GE80        8
#define    PRXS0_FT_MASK_REV_GE80        0x0700        /**
                            * (corerev >= 80) frame type field mask.
                            *
                            * 0 = CCK, 1 = 11a/g legacy OFDM,
                            * 2 = HT, 3 = VHT, 4 = 11ah, 5 = HE,
                            * 6-15 Rsvd.
                            */
 
/* *
* Macro to find Frame type from RX Hdr based on corerev.
*
* Note: From rev80 onwards frame type is indicated only
* in the phyrxstatus, which is valid only for the last
* MPDU of an AMPDU. Since FT is required for every MPDU,
* frametype for core-revs >= 80, shall be
* provided in bits (8:10) of MuRate field in RXH.
*
*/
#define D11PPDU_FT(rxh, rev) (\
   (D11REV_GE(rev, 80) ? \
   ((D11RXHDR_ACCESS_VAL(rxh, rev, 0, MuRate) & PRXS_FT_MASK(rev)) >>    \
   (PRXS0_FT_SHIFT_REV_GE80)) : \
   (D11RXHDR_LT80_ACCESS_VAL(rxh, PhyRxStatus_0) & PRXS_FT_MASK(rev))))
 
#define PRXS_UNSRATE_LT85(rxh, rev) \
   (((D11REV_GE(rev, 80) ? D11RXHDR_GE80_ACCESS_VAL(rxh, PhyRxStatus_0) : \
   D11RXHDR_LT80_ACCESS_VAL(rxh, PhyRxStatus_0)) & \
       PRXS0_UNSRATE) >> PRXS0_UNSRATE_SHIFT)
 
#define PRXS_UNSRATE(rxh, rev, min_rev)        (AUTO_PHYRXSTS_ENAB() ? \
       APRXS_UNSRATE(rxh, rev, min_rev) : PRXS_UNSRATE_LT85(rxh, rev))
 
// 1: short (or GF) preamble, 0: long (or MM) preamble
#define PRXS_SHORTH_LT85(rxh, rev)    \
       (((D11REV_GE(rev, 80) ? D11RXHDR_GE80_ACCESS_VAL(rxh, PhyRxStatus_0) : \
           D11RXHDR_LT80_ACCESS_VAL(rxh, PhyRxStatus_0)) & \
       PRXS0_SHORTH) >> PRXS0_SHORTH_SHIFT)
#define PRXS_SHORTH(rxh, rev, min_rev)    \
       (AUTO_PHYRXSTS_ENAB() ? APRXS_SHORTH(rxh, rev, min_rev) : \
           PRXS_SHORTH_LT85(rxh, rev))
 
#define PRXS_PLCPFV_LT85(rxh, rev) \
   (((D11REV_GE(rev, 80) ? D11RXHDR_GE80_ACCESS_VAL(rxh, PhyRxStatus_0) : \
   D11RXHDR_LT80_ACCESS_VAL(rxh, PhyRxStatus_0)) & \
       PRXS0_PLCPFV) >> PRXS0_PLCPFV_SHIFT)
#define PRXS_PLCPFV(rxh, rev, rev_min)        (AUTO_PHYRXSTS_ENAB() ? \
       APRXS_PLCPFV(rxh, rev, rev_min) : PRXS_PLCPFV_LT85(rxh, rev))
 
#define PRXS_PLCPHCF_LT85(rxh, rev) \
   (((D11REV_GE(rev, 80) ? D11RXHDR_GE80_ACCESS_VAL(rxh, PhyRxStatus_0) : \
   D11RXHDR_LT80_ACCESS_VAL(rxh, PhyRxStatus_0)) & \
       PRXS0_PLCPHCF) >> PRXS0_PLCPHCF_SHIFT)
#define PRXS_PLCPHCF(rxh, rev, rev_min)        (AUTO_PHYRXSTS_ENAB() ? \
       APRXS_PLCPHCF(rxh, rev, rev_min) : PRXS_PLCPHCF_LT85(rxh, rev))
 
// final BW classification
#define PRXS_SUBBAND_ACPHY(rxh, rev, rev_min) \
   (((D11RXHDR_LT80_ACCESS_VAL(rxh, PhyRxStatus_0) & \
       PRXS0_ACPHY_SUBBAND_MASK) >> PRXS0_ACPHY_SUBBAND_SHIFT) | \
       ((D11RXHDR_LT80_ACCESS_VAL(rxh, PhyRxStatus_4) & \
       PRXS4_ACPHY_SUBBAND_MASK) << 4))
#define PRXS_SUBBAND_ACPHY2(rxh, rev, rev_min)    \
       (((D11REV_GE(rev, 80) ? D11RXHDR_GE80_ACCESS_VAL(rxh, PhyRxStatus_1) : \
       D11RXHDR_LT80_ACCESS_VAL(rxh, PhyRxStatus_1)) & PRXS1_ACPHY2_SUBBAND_MASK) >> \
       PRXS1_ACPHY2_SUBBAND_SHIFT)
 
#define PRXS_SUBBAND(rxh, rev, rev_min, phyrev)    (AUTO_PHYRXSTS_ENAB() ? \
       APRXS_SUBBAND(rxh, rev, rev_min) : (ACREV_GE(phyrev, 32) ? \
       PRXS_SUBBAND_ACPHY2(rxh, rev, rev_min) : \
       PRXS_SUBBAND_ACPHY(rxh, rev, rev_min)))
 
/* Macros to access MCS, NSTS and MU valididity from MuRate field in corerev > 80 RXH */
#define RXS_MU_VALID_MASK_REV80        0x0080
#define RXS_MU_VALID_SHIFT_REV80    7
#define RXS_MCS_MASK_REV80        0x000F
#define RXS_MCS_SHIFT_REV80        0
#define RXS_NSTS_MASK_REV80        0x0070
#define RXS_NSTS_SHIFT_REV80        4
 
#define D11PPDU_ISMU_REV80(rxh, corerev, corerev_minor) \
   ((D11RXHDR_ACCESS_VAL(rxh, corerev, corerev_minor, MuRate) & \
   (RXS_MU_VALID_MASK_REV80)) >> RXS_MU_VALID_SHIFT_REV80)
#define D11RXHDR_GE80_GET_MCS(rxh, corerev, corerev_minor) \
   ((D11RXHDR_ACCESS_VAL(rxh, corerev, corerev_minor, MuRate) & \
   (RXS_MCS_MASK_REV80)) >> RXS_MCS_SHIFT_REV80)
#define D11RXHDR_GE80_GET_NSTS(rxh, corerev, corerev_minor) \
   ((D11RXHDR_ACCESS_VAL(rxh, corerev, corerev_minor, MuRate) & \
   (RXS_NSTS_MASK_REV80)) >> RXS_NSTS_SHIFT_REV80)
 
/* subfield PRXS0_FT_MASK_REV_GE80 */
#define    PRXS0_HE            0x0004    /**< HE frame type */
 
/* (Corerev >= 80) PhyRxStatus_2: */
#define PRXS2_RXPWR_ANT0_REV_GE80    0x00FF    /**< (corerev >= 80) Rx power on first antenna */
#define PRXS2_RXPWR_ANT1_REV_GE80    0xFF00    /**< (corerev >= 80) Rx power on second antenna */
 
/* (Corerev >= 80) PhyRxStatus_3: */
#define PRXS3_RXPWR_ANT2_REV_GE80    0x00FF    /**< (corerev >= 80) Rx power on third antenna */
#define PRXS3_RXPWR_ANT3_REV_GE80    0xFF00    /**
                        * (corerev >= 80) Rx power on fourth antenna.
                        *
                        * Note: For PHY revs 3 and > 4, OCL Status
                        * byte 0 will be reported if PHY register
                        * OCL_RxStatus_Ctrl is set to 0x2 or 0x6.
                        */
#define PRXS3_RXPWR_FRAC_REV_GE80    0xFFu
 
/** Get Rx power on ANT 0 */
#define RXPWR_ANT0_REV_GE80(rxs)    ((rxs)->ge80.PhyRxStatus_2 & \
       (PRXS2_RXPWR_ANT0_REV_GE80))
 
#define PHY_RXPWR_ANT0(corerev, corerev_minor, rxs)    (AUTO_PHYRXSTS_ENAB() ? \
       APRXS_RXPWR_ANT0(rxs, corerev, corerev_minor) : (D11REV_GE(corerev, 80) ? \
       RXPWR_ANT0_REV_GE80(rxs) : ACPHY_RXPWR_ANT0(rxs)))
 
/** Get Rx power on ANT 1 */
#define RXPWR_ANT1_REV_GE80(rxs)    (((rxs)->ge80.PhyRxStatus_2 & \
       (PRXS2_RXPWR_ANT1_REV_GE80)) >> 8)
 
#define PHY_RXPWR_ANT1(corerev, corerev_minor, rxs)    (AUTO_PHYRXSTS_ENAB() ? \
       APRXS_RXPWR_ANT1(rxs, corerev, corerev_minor) : (D11REV_GE(corerev, 80) ? \
       RXPWR_ANT1_REV_GE80(rxs) : ACPHY_RXPWR_ANT1(rxs)))
 
/** Get Rx power on ANT 2 */
#define RXPWR_ANT2_REV_GE80(rxs)    ((rxs)->ge80.PhyRxStatus_3 & \
       (PRXS3_RXPWR_ANT2_REV_GE80))
 
#define PHY_RXPWR_ANT2(corerev, corerev_minor, rxs)    (AUTO_PHYRXSTS_ENAB() ? \
       APRXS_RXPWR_ANT2(rxs, corerev, corerev_minor) : (D11REV_GE(corerev, 80) ? \
       RXPWR_ANT2_REV_GE80(rxs) : ACPHY_RXPWR_ANT2(rxs)))
 
/** Get Rx power on ANT 3 */
#define RXPWR_ANT3_REV_GE80(rxs)    (((rxs)->ge80.PhyRxStatus_3 & \
       (PRXS3_RXPWR_ANT3_REV_GE80)) >> 8)
 
#define PHY_RXPWR_ANT3(corerev, corerev_minor, rxs)    (AUTO_PHYRXSTS_ENAB() ? \
       APRXS_RXPWR_ANT3(rxs, corerev, corerev_minor) : (D11REV_GE(corerev, 80) ? \
       RXPWR_ANT3_REV_GE80(rxs) : ACPHY_RXPWR_ANT3(rxs)))
 
/*    Get the following entries from RXStatus bytes
*    for RSSI compensation
*    based on factory calibration
*    TIA Index
*    eLNA Index
*    V_path Switch
*/
#define PHY_ELNA_IDX_ANT0_REV_GE85(corerev, corerev_min, rxs) \
       APRXS_ELNA_IDX_ANT0(rxs, corerev, corerev_min)
#define PHY_ELNA_IDX_ANT1_REV_GE85(corerev, corerev_min, rxs) \
       APRXS_ELNA_IDX_ANT1(rxs, corerev, corerev_min)
#define PHY_TIA_IDX_ANT0_REV_GE85(corerev, corerev_min, rxs) \
       APRXS_TIA_IDX_ANT0(rxs, corerev, corerev_min)
#define PHY_TIA_IDX_ANT1_REV_GE85(corerev, corerev_min, rxs) \
       APRXS_TIA_IDX_ANT1(rxs, corerev, corerev_min)
#define PHY_VSW_IDX_ANT0_REV_GE85(corerev, corerev_min, rxs) \
       APRXS_VSW_IDX_ANT0(rxs, corerev, corerev_min)
#define PHY_VSW_IDX_ANT1_REV_GE85(corerev, corerev_min, rxs) \
       APRXS_VSW_IDX_ANT1(rxs, corerev, corerev_min)
 
/** Get RSSI fractional bits */
#define RXPWR_FRAC_REV_GE80(rxs)    ((rxs)->ge80.PhyRxStatus_4 & \
       (PRXS3_RXPWR_FRAC_REV_GE80))
 
#define RXPWR_FRAC(corerev, corerev_minor, rxs)    (AUTO_PHYRXSTS_ENAB() ? \
       APRXS_RXPWR_FRAC(rxs, corerev, corerev_minor) : (D11REV_GE(corerev, 80) ? \
       RXPWR_FRAC_REV_GE80(rxs) : 0))
 
/* HECAPPHY PhyRxStatus_4: */
#define PRXS4_DYNBWINNONHT_MASK_REV_GE80    0x1000
#define PRXS4_DYNBWINNONHT_REV_GE80(rxs)    ((rxs)->ge80.PhyRxStatus_4 & \
                       PRXS4_DYNBWINNONHT_MASK_REV_GE80)
 
#define PRXS_PHY_DYNBWINNONHT(corerev, corerev_minor, rxs)    (AUTO_PHYRXSTS_ENAB() ? \
       APRXS_DYNBWINNONHT(rxs, corerev, corerev_minor) : (D11REV_GE(corerev, 80) ? \
       PRXS4_DYNBWINNONHT_REV_GE80(rxs) : PRXS5_ACPHY_DYNBWINNONHT(rxs)))
 
/** (corerev >= 80) PhyRxStatus_5: MCSSQ SNR for core 0 and 1 */
#define PRXS5_MCSSQ_SHIFT           (8u)
#define PRXS5_MCSSQ_CORE0_REV_GE80  (0x00FF)
#define PRXS5_MCSSQ_CORE1_REV_GE80  (0xFF00)
 
#define MCSSQ_SNR_ANT0_GE80(rxs)    ((rxs)->ge80.PhyRxStatus_5 & PRXS5_MCSSQ_CORE0_REV_GE80)
#define MCSSQ_SNR_ANT0(rxs, rev, rev_min)    (AUTO_PHYRXSTS_ENAB() ? \
       APRXS_MCSSQSNR0(rxs, rev, rev_min) : \
       ((rxs)->ge80.PhyRxStatus_5 & PRXS5_MCSSQ_CORE0_REV_GE80))
 
#define MCSSQ_SNR_ANT1_GE80(rxs)    (((rxs)->ge80.PhyRxStatus_5 & PRXS5_MCSSQ_CORE1_REV_GE80) \
   >> PRXS5_MCSSQ_SHIFT)
#define MCSSQ_SNR_ANT1(rxs, rev, rev_min)    (AUTO_PHYRXSTS_ENAB() ? \
       APRXS_MCSSQSNR1(rxs, rev, rev_min) : \
       (((rxs)->ge80.PhyRxStatus_5 & PRXS5_MCSSQ_CORE1_REV_GE80) \
           >> PRXS5_MCSSQ_SHIFT))
 
/** (corerev >= 80) PhyRxStatus_6: MCSSQ SNR for core 2 and 3 */
#define PRXS6_MCSSQ_SHIFT           (8u)
#define PRXS6_MCSSQ_CORE2_REV_GE80  (0x00FF)
#define PRXS6_MCSSQ_CORE3_REV_GE80  (0xFF00)
 
#define MCSSQ_SNR_ANT2_GE80(rxs)           (((rxs)->ge80.phyrxs_rem[0] &  \
   PRXS6_MCSSQ_CORE2_REV_GE80))
#define MCSSQ_SNR_ANT2(rxs, rev, rev_min)    (AUTO_PHYRXSTS_ENAB() ? \
       APRXS_MCSSQSNR2(rxs, rev, rev_min) : \
       (((rxs)->ge80.phyrxs_rem[0] & PRXS6_MCSSQ_CORE2_REV_GE80)))
 
/* HECAPPHY PhyRxStatus_8 (part of phyrxs_rem[2]) : */
#define PRXS8_CHBWINNONHT_MASK_REV_GE80        0x0100
#define PRXS8_CHBWINNONHT_REV_GE80(rxs)        ((rxs)->ge80.phyrxs_rem[2] & \
                       PRXS8_CHBWINNONHT_MASK_REV_GE80)
 
#define PRXS_PHY_CHBWINNONHT(corerev, corerev_minor, rxs)    (AUTO_PHYRXSTS_ENAB() ? \
       APRXS_CHBWINNONHT(rxs, corerev, corerev_minor) : (D11REV_GE(corerev, 80) ? \
       PRXS8_CHBWINNONHT_REV_GE80(rxs) : PRXS5_ACPHY_CHBWINNONHT(rxs)))
 
/* HE phyrxs_rem[4] */
#define PRXS_REM4_PE_MASK_REV80            0x0380
#define PRXS_REM4_PE_SHIFT_REV80        7u
#define PRXS_REM4_RU_TYPE_MASK_REV80        0x1c00
#define PRXS_REM4_RU_TYPE_SHIFT_REV80        10u
#define PRXS_REM4_NUM_USER_SHIFT_REV80          13u
#define PRXS_REM4_NUM_USER_BIT_MASK_REV80       0xe000
 
/* HE phyrxs_rem[5] */
#define PRXS_REM5_GI_LTF_MASK_REV80        0x0003
#define PRXS_REM5_GI_LTF_SHIFT_REV80        0u
#define PRXS_REM5_11AX_FF_MASK_REV80        0x0700
#define PRXS_REM5_11AX_FF_SHIFT_REV80        8u
 
/* HE phyrxs_rem[6] */
#define PRXS_REM6_MCS_MASK_REV80        0x0f00
#define PRXS_REM6_MCS_SHIFT_REV80        8u
#define PRXS_REM6_CODING_MASK_REV80        0x1000
#define PRXS_REM6_CODING_SHIFT_REV80        12u
 
/* HE phyrxs_rem[7] */
#define PRXS_REM7_DCM_MASK_REV80        0x8000
#define PRXS_REM7_DCM_SHIFT_REV80        15u
#define PRXS_REM7_TXBF_MASK_REV80        0x4000
#define PRXS_REM7_TXBF_SHIFT_REV80        14u
#define PRXS_REM7_NSTS_MASK_REV80        0x3800
#define PRXS_REM7_NSTS_SHIFT_REV80        11u
#define PRXS_REM7_RU_ALLOC_MASK_REV80        0x007f
#define PRXS_REM7_RU_ALLOC_SHIFT_REV80        0u
 
#define PRXS_STAID_MASK                0x07ff
#define PRXS_STAID_SHIFT            0u
 
enum {
   HE_RU_TYPE_26T     = 0, /* 26 tone RU, 0 - 36 */
   HE_RU_TYPE_52T     = 1, /* 52 tone RU, 37 - 52 */
   HE_RU_TYPE_106T    = 2, /* 106 tone RU, 53 - 60 */
   HE_RU_TYPE_242T    = 3, /* 242 tone RU, 61 - 64 */
   HE_RU_TYPE_484T    = 4, /* 484 tone RU, 65 - 66 */
   HE_RU_TYPE_996T    = 5, /* 996 tone RU, 67 - 68 */
   HE_RU_TYPE_2x996T  = 6,    /* 2x996 tone RU, 69 */
   HE_RU_TYPE_LAST    = 7  /* Reserved, Invalid */
};
 
#define HE_RU_TYPE_MAX                6
 
/* received PE duration is present in phyrxs_rem[4] bit position [7-9] */
#define D11PPDU_PE_GE80(rxh, corerev)    ((D11RXHDR_GE80_ACCESS_VAL(rxh, phyrxs_rem[4]) &         \
       (PRXS_REM4_PE_MASK_REV80)) >> PRXS_REM4_PE_SHIFT_REV80)
 
#define D11PPDU_PE(rxh, corerev, corerev_minor)    (AUTO_PHYRXSTS_ENAB() ?                          \
       APRXS_PE(rxh, corerev, corerev_minor) : D11PPDU_PE_GE80(rxh, corerev))
 
/* received RU type is present in phyrxs_rem[4] bit position [10-11] */
#define D11PPDU_RU_TYPE(rxh, corerev, corerev_minor)                                              \
   (AUTO_PHYRXSTS_ENAB() ? APRXS_RU(rxh, corerev, corerev_minor) :                           \
   (D11REV_GE(corerev, 80) ? ((D11RXHDR_GE80_ACCESS_VAL(rxh, phyrxs_rem[4]) &                \
   (PRXS_REM4_RU_TYPE_MASK_REV80)) >> PRXS_REM4_RU_TYPE_SHIFT_REV80) : 0))
 
/* received he num of user type is present in phyrxs_rem[4] bit position [13-15] */
#define D11PPDU_HE_NUM_USER_TYPE(rxh, corerev, corerev_min)                                       \
   (AUTO_PHYRXSTS_ENAB() ? APRXS_USTY(rxh, corerev, corerev_min) :                           \
   (D11REV_GE(corerev, 80) ? ((D11RXHDR_GE80_ACCESS_VAL(rxh, phyrxs_rem[4]) &                \
   (PRXS_REM4_NUM_USER_BIT_MASK_REV80)) >> PRXS_REM4_NUM_USER_SHIFT_REV80) : 0))
 
#define D11PPDU_FF_TYPE(rxh, corerev, corerev_minor)                                              \
   (AUTO_PHYRXSTS_ENAB() ? APRXS_AXFF(rxh, corerev, corerev_minor) :                         \
   (D11REV_GE(corerev, 80) ? ((D11RXHDR_GE80_ACCESS_VAL(rxh, phyrxs_rem[5]) &                \
   (PRXS_REM5_11AX_FF_MASK_REV80)) >> PRXS_REM5_11AX_FF_SHIFT_REV80) : 0))
 
/* DCM is present in phyrxs_rem[7] byte 27, bit position [7] */
#define D11PPDU_DCM(rxh, corerev, corerev_minor)                                                  \
   (AUTO_PHYRXSTS_ENAB() ? APRXS_DCM(rxh, corerev, corerev_minor) :                          \
   (D11REV_GE(corerev, 80) ? ((D11RXHDR_GE80_ACCESS_VAL(rxh, phyrxs_rem[7]) &                \
   (PRXS_REM7_DCM_MASK_REV80)) >> PRXS_REM7_DCM_SHIFT_REV80) : 0))
 
/* coding used is present in phyrxs_rem[6] byte:25, bit position [12] */
#define D11PPDU_CODING(rxh, corerev, corerev_minor)                                               \
   (AUTO_PHYRXSTS_ENAB() ? APRXS_CODING(rxh, corerev, corerev_minor) :                       \
   (D11REV_GE(corerev, 80) ? ((D11RXHDR_GE80_ACCESS_VAL(rxh, phyrxs_rem[6]) &                \
   (PRXS_REM6_CODING_MASK_REV80)) >> PRXS_REM6_CODING_SHIFT_REV80) : 0))
 
/* spatial reuse 2 / STA-ID */
#define D11PPDU_STAID(rxh, corerev, corerev_minor)                                                \
   (AUTO_PHYRXSTS_ENAB() ? APRXS_AX_STAID(rxh, corerev, corerev_minor) :                     \
   (D11REV_GE(corerev, 80) ? ((D11RXHDR_GE80_ACCESS_VAL(rxh, phyrxs_rem[7]) &                \
   (PRXS_STAID_MASK)) >> PRXS_STAID_SHIFT) : 0))
 
#define D11PPDU_TXBF(rxh, corerev, corerev_minor)                                                 \
   (AUTO_PHYRXSTS_ENAB() ? APRXS_TXBF(rxh, corerev, corerev_minor) :                         \
   (D11REV_GE(corerev, 80) ? ((D11RXHDR_GE80_ACCESS_VAL(rxh, phyrxs_rem[7]) &                \
   (PRXS_REM7_TXBF_MASK_REV80)) >> PRXS_REM7_TXBF_SHIFT_REV80) : 0))
 
/* GI_LTF is present in phyrxs_rem[5] bit position [0-1] */
#define D11PPDU_GI_LTF(rxh, corerev, corerev_minor)                                               \
   (AUTO_PHYRXSTS_ENAB() ? APRXS_GILTF(rxh, corerev, corerev_minor) :                        \
   (D11REV_GE(corerev, 80) ? ((D11RXHDR_GE80_ACCESS_VAL(rxh, phyrxs_rem[5]) &                \
   (PRXS_REM5_GI_LTF_MASK_REV80)) >> PRXS_REM5_GI_LTF_SHIFT_REV80) : 0))
 
/* MCS is present in phyrxs_rem[6] - byte 25, bit position [8-11] */
#define D11PPDU_MCS(rxh, corerev, corerev_minor)                                                  \
   (AUTO_PHYRXSTS_ENAB() ? APRXS_AXMCS(rxh, corerev, corerev_minor) :                        \
   (D11REV_GE(corerev, 80) ? ((D11RXHDR_GE80_ACCESS_VAL(rxh, phyrxs_rem[6]) &                \
   (PRXS_REM6_MCS_MASK_REV80)) >> PRXS_REM6_MCS_SHIFT_REV80) : 0))
 
/* NSTS present in phyrxs_rem[7] bit position [11-13] */
#define D11PPDU_NSTS(rxh, corerev, corerev_minor)                                                 \
   (AUTO_PHYRXSTS_ENAB() ? APRXS_NSTS(rxh, corerev, corerev_minor) :                         \
   (D11REV_GE(corerev, 80) ? ((D11RXHDR_GE80_ACCESS_VAL(rxh, phyrxs_rem[7]) &                \
   (PRXS_REM7_NSTS_MASK_REV80)) >> PRXS_REM7_NSTS_SHIFT_REV80) : 0))
 
/* RU ALLOC present in phyrxs_rem[7]- byte 26; bit position [6:0] */
#define D11PPDU_RU_ALLOC(rxh, corerev, corerev_minor)                                             \
   (AUTO_PHYRXSTS_ENAB() ? APRXS_AX_RUALLOC(rxh, corerev, corerev_minor) :                   \
   (D11REV_GE(corerev, 80) ? ((D11RXHDR_GE80_ACCESS_VAL(rxh, phyrxs_rem[7]) &                \
   (PRXS_REM7_RU_ALLOC_MASK_REV80)) >> PRXS_REM7_RU_ALLOC_SHIFT_REV80) : 0)
 
/* PHY RX status "Frame Type" field mask. */
#define PRXS_FT_MASK(corerev)                                                                     \
   (D11REV_GE(corerev, 80) ? (PRXS0_FT_MASK_REV_GE80) :                                      \
   (PRXS0_FT_MASK_REV_LT80))
 
/**
 * ACPHY PhyRxStatus0 SubBand (FinalBWClassification) bit defs
 * FinalBWClassification is a 4 bit field, each bit representing one 20MHz sub-band
 * of a channel.
 */
enum prxs_subband {
   PRXS_SUBBAND_20LL = 0x0001,
   PRXS_SUBBAND_20LU = 0x0002,
   PRXS_SUBBAND_20UL = 0x0004,
   PRXS_SUBBAND_20UU = 0x0008,
   PRXS_SUBBAND_40L  = 0x0003,
   PRXS_SUBBAND_40U  = 0x000C,
   PRXS_SUBBAND_80   = 0x000F,
   PRXS_SUBBAND_20LLL = 0x0001,
   PRXS_SUBBAND_20LLU = 0x0002,
   PRXS_SUBBAND_20LUL = 0x0004,
   PRXS_SUBBAND_20LUU = 0x0008,
   PRXS_SUBBAND_20ULL = 0x0010,
   PRXS_SUBBAND_20ULU = 0x0020,
   PRXS_SUBBAND_20UUL = 0x0040,
   PRXS_SUBBAND_20UUU = 0x0080,
   PRXS_SUBBAND_40LL = 0x0003,
   PRXS_SUBBAND_40LU = 0x000c,
   PRXS_SUBBAND_40UL = 0x0030,
   PRXS_SUBBAND_40UU = 0x00c0,
   PRXS_SUBBAND_80L = 0x000f,
   PRXS_SUBBAND_80U = 0x00f0,
   PRXS_SUBBAND_160 = 0x00ff
};
 
enum prxs_subband_bphy {
   PRXS_SUBBAND_BPHY_20L = 0x0000,
   PRXS_SUBBAND_BPHY_20U = 0x0001
};
 
/* ACPHY Gen2 RxStatus defs */
 
/* ACPHY Gen2 PhyRxStatus_0: */
#define PRXS0_ACPHY2_MUPPDU     0x1000    /**< 0: SU PPDU; 1: MU PPDU */
#define PRXS0_ACPHY2_OBSS       0xE000    /**< OBSS mitigation state */
 
/* ACPHY Gen2 PhyRxStatus_1: */
#define PRXS1_ACPHY2_SUBBAND_MASK 0xFF00  /**< FinalBWClassification:
                                      * 8-bit bitfield of sub-bands occupied by Rx frame
                                      */
#define PRXS1_ACPHY2_SUBBAND_SHIFT     8
 
/* ACPHY Gen2 PhyRxStatus_2: */
#define PRXS2_ACPHY2_MU_INT     0x003F    /**< MU interference processing type */
 
/* ACPHY Gen2 PhyRxStatus_5: */
#define PRXS5_ACPHY2_RSSI_FRAC  0xFF00    /**< RSSI fractional bits */
 
/* ucode RxStatus1: */
#define    RXS_BCNSENT        0x8000
#define    RXS_TOFINFO        0x4000        /**< Rxed measurement frame processed by ucode */
#define    RXS_GRANTBT        0x2000        /* Indicate medium given to BT */
#define    RXS_SECKINDX_MASK_GE64    0x1fe0
#define    RXS_SECKINDX_MASK    0x07e0
#define RXS_IS_DEFRAG        0x4
#define RXS_DEFRAG_SHIFT    2
#define    RXS_SECKINDX_SHIFT    5
#define    RXS_DECERR        (1 << 4)
#define    RXS_DECATMPT        (1 << 3)
#define    RXS_PBPRES        (1 << 2)    /**< PAD bytes to make IP data 4 bytes aligned */
#define    RXS_RESPFRAMETX        (1 << 1)
#define    RXS_FCSERR        (1 << 0)
 
/* ucode RxStatus2: */
#define RXS_AMSDU_MASK        1
#define RXS_AGGTYPE_MASK    0x6
#define RXS_AGGTYPE_SHIFT    1
#define RXS_AMSDU_FIRST        1
#define RXS_AMSDU_INTERMEDIATE    0
#define RXS_AMSDU_LAST        2
#define RXS_AMSDU_N_ONE        3
#define RXS_TKMICATMPT        (1 << 3)
#define RXS_TKMICERR        (1 << 4)
#define RXS_PHYRXST_PRISEL_CLR    (1 << 5)    /**< PR113291: When '1', Indicates that the Rx    */
                       /* packet was received while the antenna    */
                       /* (prisel) had been granted to BT.        */
#define RXS_PHYRXST_VALID    (1 << 8)
#define RXS_BCNCLSG        (1 << 9)    /**< Coleasced beacon packet */
#define RXS_RXANT_MASK        0x3
#define RXS_RXANT_SHIFT_LT80    12
#define RXS_RXANT_SHIFT_GE80    5
#define RXS_LOOPBACK_MODE    4
 
/* Bit definitions for MRXS word for short rx status. */
/* RXSS = RX Status Short */
#define RXSS_AMSDU_MASK         1    /**< 1: AMSDU */
#define RXSS_AGGTYPE_MASK     0x6    /**< 0 intermed, 1 first, 2 last, 3 single/non-AMSDU */
#define    RXSS_AGGTYPE_SHIFT      1
#define RXSS_PBPRES       (1 << 3)    /**< two-byte PAD prior to plcp */
#define RXSS_HDRSTS       (1 << 4)    /**< header conversion status. 1 enabled, 0 disabled */
#define RXSS_RES_MASK        0xE0    /**< reserved */
#define RXSS_MSDU_CNT_MASK 0xFF00    /**< index of this AMSDU sub-frame in the AMSDU */
#define RXSS_MSDU_CNT_SHIFT     8
 
/* RX signal control definitions */
/** PHYRXSTAUS validity checker; in-between ampdu, or rxs status isn't valid */
#define PRXS_IS_VALID(rxh, rev, rev_min)                                       \
   ((D11REV_GE(rev, 80) && \
       (D11RXHDR_ACCESS_VAL(rxh, rev, rev_min, dma_flags) &           \
           RXS_PHYRXST_VALID_REV_GE80)) || \
   (D11REV_GE(rev, 64) && !(D11RXHDR_ACCESS_VAL(rxh,                      \
           rev, rev_min, dma_flags) & RXS_SHORT_MASK)) || \
   (D11RXHDR_ACCESS_VAL(rxh, rev, rev_min, RxStatus2) & RXS_PHYRXST_VALID))
 
/* RxChan */
#define RXS_CHAN_40        0x1000
#define RXS_CHAN_5G        0x0800
#define    RXS_CHAN_ID_MASK    0x07f8
#define    RXS_CHAN_ID_SHIFT    3
 
#define C_BTCX_AGGOFF_BLE        (1 << 0)
#define C_BTCX_AGGOFF_A2DP        (1 << 1)
#define C_BTCX_AGGOFF_PER        (1 << 2)
#define C_BTCX_AGGOFF_MULTIHID        (1 << 3)
#define C_BTCX_AGG_LMT_SET_HIGH        (1 << 4)
#define C_BTCX_AGGOFF_ESCO_SLAVE    (1 << 5)
 
#define BTCX_HFLG_NO_A2DP_BFR        (1 << 0) /**< no check a2dp buffer */
#define BTCX_HFLG_NO_CCK        (1 << 1) /**< no cck rate for null or cts2self */
#define BTCX_HFLG_NO_OFDM_FBR        (1 << 2) /**< no ofdm fbr for null or cts2self */
#define    BTCX_HFLG_NO_INQ_DEF        (1 << 3) /**< no defer inquery */
#define    BTCX_HFLG_GRANT_BT        (1 << 4) /**< always grant bt */
#define BTCX_HFLG_ANT2WL        (1 << 5) /**< force prisel to wl */
#define BTCX_HFLG_PS4ACL        (1 << 7) /**< use ps null for unsniff acl */
#define BTCX_HFLG_DYAGG            (1 << 8) /**< dynamic tx aggregation */
#define BTCX_HFLG_SKIPLMP        (1 << 10) /**< no LMP check for 4331 (w 20702 A1/A3) */
#define BTCX_HFLG_ACL_BSD_BLE_SCAN_GRNT    (1 << 14) /**< ACL based grant for BLE scan */
                       /* indication to ucode */
#define BTCX_HFLG2_TRAP_RFACTIVE        (1 << 0) /* trap when RfActive too long */
#define BTCX_HFLG2_TRAP_TXCONF        (1 << 1) /* trap when coex grants txconf late */
#define BTCX_HFLG2_TRAP_ANTDLY        (1 << 2) /* trap when coex grants antdly late */
#define BTCX_HFLG2_TRAP_BTTYPE        (1 << 3) /* trap when illegal BT tasktype receive */
/* Bit definitions for M_BTCX_CONFIG */
#define BTCX_CONFIG_FORCE_TRAP        (1 << 13) /* Force a specific BTCoex TRAP when set */
 
/* BTCX_CONFIG bits */
#define C_BTCX_CONFIG_SLOTTED_STATE_1    (1 << 3)
#define C_BTCX_CONFIG_SLOTTED_STATE_2    (1 << 4)
#define C_BTCX_CONFIG_SLOTTED_STATE_3    (1 << 5)
#define    C_BTCX_CONFIG_LOW_RSSI        (1 << 7)
#define C_BTCX_CONFIG_BT_STROBE        (1 << 9)
#define C_BTCX_CONFIG_SCO_PROT        (1 << 10)
#define C_BTCX_CFG_CMN_CTS2SELF        (1 << 11)
#define C_BTCX_CONFIG_HPP_STATE        (1 << 15)
 
#define BTC_PARAMS_FW_START_IDX        1000    /**< starting index of FW only btc params */
/** BTC_PARAMS_FW definitions */
typedef enum
{
   // allow rx-agg to be re-enabled after SCO session completes
   BTC_FW_RX_REAGG_AFTER_SCO    = BTC_PARAMS_FW_START_IDX,
   // RSSI threshold at which SCO grant/deny limits are changed dynamically
   BTC_FW_RSSI_THRESH_SCO        = BTC_PARAMS_FW_START_IDX + 1,
   // Enable the dynamic LE scan priority
   BTC_FW_ENABLE_DYN_LESCAN_PRI    = BTC_PARAMS_FW_START_IDX + 2,
   // If Tput(mbps) is above this, then share antenna with BT's LE_SCAN packet type.
   BTC_FW_LESCAN_LO_TPUT_THRESH    = BTC_PARAMS_FW_START_IDX + 3,
   // If Tput(mbps) is below this, then share antenna with BT's LE_SCAN packet type.
   // sampled once a second.
   BTC_FW_LESCAN_HI_TPUT_THRESH    = BTC_PARAMS_FW_START_IDX + 4,
   // Numbers of denials before granting LS scans
   BTC_FW_LESCAN_GRANT_INT        = BTC_PARAMS_FW_START_IDX + 5,
   // number of times algorighm changes lescn pri
   BTC_FW_LESCAN_ALG_CNT        = BTC_PARAMS_FW_START_IDX + 6,
   // RSSI threshold at which aggregation will be disabled during frequent BLE activity
   BTC_FW_RSSI_THRESH_BLE        = BTC_PARAMS_FW_START_IDX + 7,
   // AMPDU Aggregation state requested by BTC
   BTC_FW_AGG_STATE_REQ        = BTC_PARAMS_FW_START_IDX + 8,
   // Reserving space for parameters used in other projects
   BTC_FW_RSVD_1            = BTC_PARAMS_FW_START_IDX + 9,
   BTC_FW_HOLDSCO_LIMIT        = BTC_PARAMS_FW_START_IDX + 10,    // Lower Limit
   BTC_FW_HOLDSCO_LIMIT_HI        = BTC_PARAMS_FW_START_IDX + 11,    // Higher Limit
   BTC_FW_SCO_GRANT_HOLD_RATIO    = BTC_PARAMS_FW_START_IDX + 12,    // Low Ratio
   BTC_FW_SCO_GRANT_HOLD_RATIO_HI    = BTC_PARAMS_FW_START_IDX + 13,    // High Ratio
   BTC_FW_HOLDSCO_HI_THRESH    = BTC_PARAMS_FW_START_IDX + 14,    // BT Period Threshold
   BTC_FW_MOD_RXAGG_PKT_SZ_FOR_SCO    = BTC_PARAMS_FW_START_IDX + 15,
   /* Modify Rx Aggregation size when SCO/eSCO detected */
   BTC_FW_AGG_SIZE_LOW    = BTC_PARAMS_FW_START_IDX + 16,
   /* Agg size when BT period < 7500 ms */
   BTC_FW_AGG_SIZE_HIGH    = BTC_PARAMS_FW_START_IDX + 17,
   /* Agg size when BT period >= 7500 ms */
   BTC_FW_MOD_RXAGG_PKT_SZ_FOR_A2DP = BTC_PARAMS_FW_START_IDX + 18,
   /* Enable COEX constraints for TWT scheduling */
   BTC_FW_TWT_COEX_CONSTRAINTS_EN = BTC_PARAMS_FW_START_IDX + 19,
   /* Enable Rx Aggregation for P2P_GO and SOFTAP when ACL/A2DP detected */
   BTC_FW_MOD_RXAGG_PKT_SZ_FOR_APMODE_ACL_A2DP = BTC_PARAMS_FW_START_IDX + 20,
   /* Disable amsdu dynamicaly during Rx limited aggregation */
   BTC_FW_DISABLE_AMSDU_DURING_LIM_AGG = BTC_PARAMS_FW_START_IDX + 21,
   /* Enable acl based grant for ble scan based on number of 2G slots */
   BTC_FW_ENABLE_ACL_GRNT_FOR_BLE_SCAN = BTC_PARAMS_FW_START_IDX + 22,
   /* Threshold slot count for 2g band to Enable acl based grant for ble scan during NAN */
   BTC_FW_NAN_THRESHOLD_SLOTS_FOR_2G = BTC_PARAMS_FW_START_IDX + 23,
   /*  BT task bm override for critical chansw slots */
   BTC_FW_CHANSW_CRT_OVR_BTTASK_BM_L    = BTC_PARAMS_FW_START_IDX + 24,
   BTC_FW_CHANSW_CRT_OVR_BTTASK_BM_H    = BTC_PARAMS_FW_START_IDX + 25,
   /* Limited Aggr AP check grace period, # of BTC watchdog timeout */
   BTC_FW_AGG_AP_GRACE_PERIOD        = BTC_PARAMS_FW_START_IDX + 26,
   /* Limited Aggr AP check buffer limit, sample interval, # of BTC watchdog timeout */
   BTC_FW_AGG_AP_BUFLIM_SMPLINTV        = BTC_PARAMS_FW_START_IDX + 27,
   /* Limited Aggr AP check excessive DELBA, sample interval, # of BTC watchdog timeout */
   BTC_FW_AGG_AP_DELBA_SMPLINTV        = BTC_PARAMS_FW_START_IDX + 28,
   /* Limited Aggr AP check excessive DELBA, threshold, # of DELBA */
   BTC_FW_AGG_AP_DELBA_THRESHOLD        = BTC_PARAMS_FW_START_IDX + 29,
   BTC_FW_MAX_INDICES            // Maximum number of btc_fw sw registers
} btcParamsFirmwareDefinitions;
 
#define BTC_FW_NUM_INDICES        (BTC_FW_MAX_INDICES - BTC_PARAMS_FW_START_IDX)
 
// 1: Re-enable aggregation after SCO
#define BTC_FW_RX_REAGG_AFTER_SCO_INIT_VAL    1
 
// 1: Enable limited aggregation for SCO
#define BTC_FW_MOD_RXAGG_PKT_SZ_FOR_SCO_INIT_VAL    0
 
/* Enable Limited aggregation for HI interval BT periodic task only (>=7.5ms) */
#ifdef WL_BTC_LIMAGG_HI_INT
/* RX aggregation packet size when SCO */
#define BTC_FW_AGG_SIZE_LOW_INIT_VAL            0
#else
/* RX aggregation packet size when SCO */
#define BTC_FW_AGG_SIZE_LOW_INIT_VAL            1
#endif
 
/* aggregation size when BT period < BT_AMPDU_RESIZE_THRESH */
#define BTC_FW_AGG_SIZE_HIGH_INIT_VAL            2
/* aggregation size when BT period > BT_AMPDU_RESIZE_THRESH */
// 0: disable weak-rssi SCO coex feature. If > 0, adjust SCO COEX algorithm for weak RSSI scenario.
#define BTC_FW_RSSI_THRESH_SCO_INIT_VAL            0
 
// 1: Enable limited aggregation for A2DP
#define BTC_FW_MOD_RXAGG_PKT_SZ_FOR_A2DP_INIT_VAL    0
 
// Enable LE Scan Priority Algorithm  0: Disable, 1: Enable
#define BTC_FW_ENABLE_DYN_LESCAN_PRI_INIT_VAL    0
// If WL Tput below 7 mbps, don't grant background LE Scans
#define BTC_FW_LESCAN_LO_TPUT_THRESH_INIT_VAL    7
// If WL Tput above 30 mbps, don't grant background LE Scans
#define BTC_FW_LESCAN_HI_TPUT_THRESH_INIT_VAL    30
// If LE Priority algorithm is triggered, grant one out of 2 LE_SCAN requests
#define BTC_FW_LESCAN_GRANT_INT_INIT_VAL    2
// If RSSI is weaker than -70 dBm and BLE activity is frequent, then disable
// RX aggregation, and clamp TX aggregation.
#ifdef WL_BTCX_UDM
#define    BTC_FW_RSSI_THRESH_BLE_INIT_VAL        100
#else
#define    BTC_FW_RSSI_THRESH_BLE_INIT_VAL        70
#endif
#define    BTC_FW_HOLDSCO_LIMIT_INIT_VAL        100
#define    BTC_FW_HOLDSCO_LIMIT_HI_INIT_VAL    10
#define    BTC_FW_SCO_GRANT_HOLD_RATIO_INIT_VAL    1500
#define    BTC_FW_SCO_GRANT_HOLD_RATIO_HI_INIT_VAL    1000
#define    BTC_FW_HOLDSCO_HI_THRESH_INIT_VAL    7400
#define BTC_FW_TWT_COEX_CONSTRAINTS_EN_INIT_VAL    1
/* Aggregation in AP mode (P2P_GO and SOFTAP) when ACL and A2DP  */
#define BTC_FW_MOD_RXAGG_PKT_SZ_FOR_APMODE_ACL_A2DP_INIT_VAL 16
/* Disable amsdu dynamicaly during Rx limited aggregation */
#define BTC_FW_DISABLE_AMSDU_DURING_LIM_AGG_INIT_VAL 1
/* Enable acl based grant for ble scan based on number of 2G slots during NAN */
#define BTC_FW_ENABLE_ACL_GRNT_FOR_BLE_SCAN_INIT_VAL 0
/* Threshold slot count for 2g band to Enable acl based grant for ble
 * scan during NAN. Setting current value to 8, considering time line is 512ms
 * Threshold changes dynamically based on different time line
 */
#define BTC_FW_NAN_THRESHOLD_SLOTS_FOR_2G_INIT_VAL 8
/* BT task bm override for critical chansw slots -initval */
#define BTC_FW_CHANSW_CRT_OVR_BTTASK_BM_L_INIT_VAL 0x0000
#define BTC_FW_CHANSW_CRT_OVR_BTTASK_BM_H_INIT_VAL 0x0020
#define BTC_FW_AGG_AP_GRACE_PERIOD_VAL        1
#define BTC_FW_AGG_AP_BUFLIM_SMPLINTV_VAL    1
#define BTC_FW_AGG_AP_DELBA_SMPLINTV_VAL    5
#define BTC_FW_AGG_AP_DELBA_THRESHOLD_VAL    3
 
/* NR Coex Params Set/Get via wl btc_params, starting index */
#define NR5GCX_PARAMS_FW_START_IDX        1200
 
typedef enum NR5GCX_Params {
   // Min # of PPDU to be tracked for hysteresis
   NR5GCX_FW_MIN_NUM_PPDU        = NR5GCX_PARAMS_FW_START_IDX,
   // Threshold for data stall detection, percentage
   NR5GCX_FW_DATA_STALL_TH        = NR5GCX_PARAMS_FW_START_IDX + 1,
   // max number of rate recovery attempts
   NR5GCX_FW_MAX_NUM_ATTEMPTS    = NR5GCX_PARAMS_FW_START_IDX + 2,
   // Rate recovery rate check duration
   NR5GCX_FW_RR_RATE_CHK_DUR    = NR5GCX_PARAMS_FW_START_IDX + 3,
   // Rate recovery attempt duration
   NR5GCX_FW_RR_ATTEMPT_DUR    = NR5GCX_PARAMS_FW_START_IDX + 4,
   // NR grant duration after a unsuccessful rate recovery
   NR5GCX_FW_RR_UNSC_DUR        = NR5GCX_PARAMS_FW_START_IDX + 5,
   // Threshold for rate recovery, percentage
   NR5GCX_FW_RECOVERY_TH        = NR5GCX_PARAMS_FW_START_IDX + 6,
   // Threshold for low RSSI
   NR5GCX_FW_LOWRSSI_TH        = NR5GCX_PARAMS_FW_START_IDX + 7,
   // Maximum number of nr5gcx fw params
   NR5GCX_FW_MAX_INDICES
} NR5GCXParamsFirmwareDefinitions;
 
#define NR5GCX_FW_NUM_INDICES        (NR5GCX_FW_MAX_INDICES - NR5GCX_PARAMS_FW_START_IDX)
 
#define NR5GCX_FW_MIN_NUM_PPDU_INIT        10u
#define NR5GCX_FW_DATA_STALL_TH_INIT        75u
#define NR5GCX_FW_MAX_NUM_ATTEMPTS_INIT        5u
#define NR5GCX_FW_RR_RATE_CHK_DUR_INIT_MS    60u    /* ms */
#define NR5GCX_FW_RR_ATTEMPT_DUR_INIT_MS    60u    /* ms */
#define NR5GCX_FW_RR_UNSC_DUR_INIT_MS        10000u    /* ms */
#define NR5GCX_FW_RECOVERY_TH_INIT        50u
#define NR5GCX_FW_LOWRSSI_TH_INIT        85u    /* dBm */
 
/* RC1 Coex Params Set/Get via wl btc_params, starting index */
#define RC1CX_PARAMS_FW_START_IDX        1200
 
typedef enum RC1CX_Params {
   // Min # of PPDU to be tracked for hysteresis
   RC1CX_FW_MIN_NUM_PPDU        = RC1CX_PARAMS_FW_START_IDX,
   // Threshold for data stall detection, percentage
   RC1CX_FW_DATA_STALL_TH        = RC1CX_PARAMS_FW_START_IDX + 1,
   // max number of rate recovery attempts
   RC1CX_FW_MAX_NUM_ATTEMPTS    = RC1CX_PARAMS_FW_START_IDX + 2,
   // Rate recovery rate check duration
   RC1CX_FW_RR_RATE_CHK_DUR    = RC1CX_PARAMS_FW_START_IDX + 3,
   // Rate recovery attempt duration
   RC1CX_FW_RR_ATTEMPT_DUR    = RC1CX_PARAMS_FW_START_IDX + 4,
   // NR grant duration after a unsuccessful rate recovery
   RC1CX_FW_RR_UNSC_DUR        = RC1CX_PARAMS_FW_START_IDX + 5,
   // Threshold for rate recovery, percentage
   RC1CX_FW_RECOVERY_TH        = RC1CX_PARAMS_FW_START_IDX + 6,
   // Threshold for low RSSI
   RC1CX_FW_LOWRSSI_TH        = RC1CX_PARAMS_FW_START_IDX + 7,
   // Maximum number of rc1cx fw params
   RC1CX_FW_MAX_INDICES
} RC1CXParamsFirmwareDefinitions;
 
#define RC1CX_FW_NUM_INDICES        (RC1CX_FW_MAX_INDICES - RC1CX_PARAMS_FW_START_IDX)
 
#define RC1CX_FW_MIN_NUM_PPDU_INIT        10u
#define RC1CX_FW_DATA_STALL_TH_INIT        75u
#define RC1CX_FW_MAX_NUM_ATTEMPTS_INIT        5u
#define RC1CX_FW_RR_RATE_CHK_DUR_INIT_MS    60u    /* ms */
#define RC1CX_FW_RR_ATTEMPT_DUR_INIT_MS    60u    /* ms */
#define RC1CX_FW_RR_UNSC_DUR_INIT_MS        10000u    /* ms */
#define RC1CX_FW_RECOVERY_TH_INIT        50u
#define RC1CX_FW_LOWRSSI_TH_INIT        85u    /* dBm */
 
#ifdef GPIO_TXINHIBIT
/* GPIO based TX_INHIBIT:SWWLAN-109270 */
typedef enum shm_macintstatus_ext_e {
   C_MISE_GPIO_TXINHIBIT_VAL_NBIT    = 0,
   C_MISE_GPIO_TXINHIBIT_INT_NBIT    = 1
} shm_macintstatus_ext_t;
#define C_MISE_GPIO_TXINHIBIT_VAL_MASK (1 << C_MISE_GPIO_TXINHIBIT_VAL_NBIT)
#define C_MISE_GPIO_TXINHIBIT_INT_MASK (1 << C_MISE_GPIO_TXINHIBIT_INT_NBIT)
#endif
#define M_PSM_SOFT_REGS 0x0
 
/** Scratch Reg defs */
typedef enum
{
   S_RSV0 = 0,
   S_RSV1,
   S_RSV2,
 
   /* scratch registers for Dot11-constants */
   S_DOT11_CWMIN,        /**< CW-minimum                    0x03 */
   S_DOT11_CWMAX,        /**< CW-maximum                    0x04 */
   S_DOT11_CWCUR,        /**< CW-current                    0x05 */
   S_DOT11_SRC_LMT,    /**< short retry count limit            0x06 */
   S_DOT11_LRC_LMT,    /**< long retry count limit            0x07 */
   S_DOT11_DTIMCOUNT,    /**< DTIM-count                    0x08 */
 
   /* Tx-side scratch registers */
   S_SEQ_NUM,        /**< hardware sequence number reg            0x09 */
   S_SEQ_NUM_FRAG,        /**< seq-num for frags (Set at the start os MSDU    0x0A */
   S_FRMRETX_CNT,        /**< frame retx count                0x0B */
   S_SSRC,            /**< Station short retry count            0x0C */
   S_SLRC,            /**< Station long retry count            0x0D */
   S_EXP_RSP,        /**< Expected response frame            0x0E */
   S_OLD_BREM,        /**< Remaining backoff ctr            0x0F */
   S_OLD_CWWIN,        /**< saved-off CW-cur                0x10 */
   S_TXECTL,        /**< TXE-Ctl word constructed in scr-pad        0x11 */
   S_CTXTST,        /**< frm type-subtype as read from Tx-descr    0x12 */
 
   /* Rx-side scratch registers */
   S_RXTST,        /**< Type and subtype in Rxframe            0x13 */
 
   /* Global state register */
   S_STREG,        /**< state storage actual bit maps below        0x14 */
 
   S_TXPWR_SUM,        /**< Tx power control: accumulator        0x15 */
   S_TXPWR_ITER,        /**< Tx power control: iteration            0x16 */
   S_RX_FRMTYPE,        /**< Rate and PHY type for frames            0x17 */
   S_THIS_AGG,        /**< Size of this AGG (A-MSDU)            0x18 */
 
   S_KEYINDX,        /*                        0x19 */
   S_RXFRMLEN,        /**< Receive MPDU length in bytes            0x1A */
 
   /* Receive TSF time stored in SCR */
   S_RXTSFTMRVAL_WD3,    /**< TSF value at the start of rx            0x1B */
   S_RXTSFTMRVAL_WD2,    /**< TSF value at the start of rx            0x1C */
   S_RXTSFTMRVAL_WD1,    /**< TSF value at the start of rx            0x1D */
   S_RXTSFTMRVAL_WD0,    /**< TSF value at the start of rx            0x1E */
   S_RXSSN,        /**< Received start seq number for A-MPDU BA    0x1F */
   S_RXQOSFLD,        /**< Rx-QoS field (if present)            0x20 */
 
   /* Scratch pad regs used in microcode as temp storage */
   S_TMP0,            /**< stmp0                    0x21 */
   S_TMP1,            /**< stmp1                    0x22 */
   S_TMP2,            /**< stmp2                    0x23 */
   S_TMP3,            /**< stmp3                    0x24 */
   S_TMP4,            /**< stmp4                    0x25 */
   S_TMP5,            /**< stmp5                    0x26 */
   S_PRQPENALTY_CTR,    /**< Probe response queue penalty counter        0x27 */
   S_ANTCNT,        /**< unsuccessful attempts on current ant.    0x28 */
   S_SYMBOL,        /**< flag for possible symbol ctl frames        0x29 */
   S_RXTP,            /**< rx frame type                0x2A */
   S_STREG2,        /**< extra state storage                0x2B */
   S_STREG3,        /**< even more extra state storage        0x2C */
   S_STREG4,        /**< ...                        0x2D */
   S_STREG5,        /**< remember to initialize it to zero        0x2E */
 
   S_UNUSED_0X2F,        /**< No longer used                0x2F */
   S_UPTR,            /* Use this to initialize utrace                0x30 */
   S_ADJPWR_IDX,        /**< PR 37101 WAR, adj_pwr_idx            0x31 */
   S_CUR_PTR,        /**< Temp pointer for A-MPDU re-Tx SHM table    0x32 */
   S_REVID4,        /**< 0x33 */
   S_INDX,            /**< 0x34 */
   S_ADDR0,        /**< 0x35 */
   S_ADDR1,        /**< 0x36 */
   S_ADDR2,        /**< 0x37 */
   S_ADDR3,        /**< 0x38 */
   S_ADDR4,        /**< 0x39 */
   S_ADDR5,        /**< 0x3A */
   S_TMP6,            /**< 0x3B */
   S_KEYINDX_BU,        /**< Backup for Key index             0x3C */
   S_MFGTEST_TMP0,        /**< Temp register used for RX test calculations    0x3D */
   S_RXESN,        /**< Received end sequence number for A-MPDU BA    0x3E */
   S_STREG6,        /**< 0x3F */
} ePsmScratchPadRegDefinitions;
 
#define C_STREG_SLOWCAL_PD_NBIT 0x00000004        /* BIT 2 slow clock cal is pending */
#define C_STREG_SLOWCAL_DN_NBIT 0x00000008        /* BIT 3 slow clock cal is done */
 
#define S_BEACON_INDX    S_OLD_BREM
#define S_PRS_INDX    S_OLD_CWWIN
#define S_BTCX_BT_DUR    S_REVID4
#define S_PHYTYPE    S_SSRC
#define S_PHYVER    S_SLRC
 
/* IHR GPT_2 is corerev >= 3 */
#define TSF_GPT_2_STAT        0x133
#define TSF_GPT_2_CTR_L        0x134
#define TSF_GPT_2_CTR_H        0x135
#define TSF_GPT_2_VAL_L        0x136
#define TSF_GPT_2_VAL_H        0x137
 
/* IHR TSF_GPT STAT values */
#define TSF_GPT_PERIODIC    (1 << 12)
#define TSF_GPT_ADJTSF        (1 << 13)
#define TSF_GPT_USETSF        (1 << 14)
#define TSF_GPT_ENABLE        (1 << 15)
 
/** ucode mac statistic counters in shared memory */
#define MACSTAT_OFFSET_SZ 64
#define MACSTAT_REV80_OFFSET_SZ 118
 
/* ucode macstat txfunflw offset */
#define UCODEMSTAT_TXFUNFL_BLK    ((0x70 * 2) + (0x76 * 2))
 
/* MACSTAT offset to SHM address */
#define MACSTAT_ADDR(x, offset) (M_PSM2HOST_STATS(x) + (offset))
 
/** ucode mac statistic counters in shared memory, base addr defined in M_UCODE_MACSTAT1 */
typedef struct macstat1 {
   uint16 txndpa;                  /* + 0 (0x0) */
   uint16 txndp;                   /* + 1*2 (0x2) */
   uint16 txsf;                    /* + 2*2 (0x4) */
   uint16 txcwrts;                 /* + 3*2 (0x6) */
   uint16 txcwcts;                 /* + 4*2 (0x8) */
   uint16 txbfm;                   /* + 5*2 (0xa) */
   uint16 rxndpaucast;             /* + 6*2 (0xc) */
   uint16 bferptrdy;               /* + 7*2 (0xe) */
   uint16 rxsfucast;               /* + 8*2 (0x10) */
   uint16 rxcwrtsucast;            /* + 9*2 (0x12) */
   uint16 rxcwctsucast;            /* +10*2 (0x14) */
   uint16 rx20s;                  /* +11*2 (0x16) */
   uint16 bcntrim;                  /* +12*2 (0x18) */
   uint16 btc_rfact_l;             /* +13*2 (0x1a) */
   uint16 btc_rfact_h;             /* +14*2 (0x1c) */
   uint16 btc_txconf_l;            /* +15*2 (0x1e) : cnt */
   uint16 btc_txconf_h;            /* +16*2 (0x20) : cnt */
   uint16 btc_txconf_durl;         /* +17*2 (0x22) : dur */
   uint16 btc_txconf_durh;         /* +18*2 (0x24) : dur */
   uint16 rxsecrssi0;              /* +19*2 (0x26) : high bin */
   uint16 rxsecrssi1;              /* +20*2 (0x28) : med bin */
   uint16 rxsecrssi2;              /* +21*2 (0x2a) : low bin */
   uint16 rxpri_durl;              /* +22*2 (0x2c) : dur */
   uint16 rxpri_durh;              /* +23*2 (0x2e) : dur */
   uint16 rxsec20_durl;            /* +24*2 (0x30) : dur */
   uint16 rxsec20_durh;            /* +25*2 (0x32) : dur */
   uint16 rxsec40_durl;            /* +26*2 (0x34) : dur */
   uint16 rxsec40_durh;            /* +27*2 (0x36) : dur */
} macstat1_t;
 
#define MX_UCODEX_MACSTAT (0x40 * 2)
/* ucodex mac statistic counters in shared memory */
#define MACXSTAT_OFFSET_SZ 6
 
/* psm2 statistic counters in shared memory, base addr defined in MX_PSM2HOST_STATS */
typedef enum {
   MCXSTOFF_MACXSUSP = 0,
   MCXSTOFF_M2VMSG = 1,
   MCXSTOFF_V2MMSG = 2,
   MCXSTOFF_MBOXOUT = 3,
   MCXSTOFF_MUSND = 4,
   MCXSTOFF_SFB2V = 5
} macxstat_offset_t;
 
/* dot11 core-specific control flags */
#define SICF_MCLKE        0x0001          /* Mac core clock Enable */
#define SICF_FCLKON        0x0002          /* Force clocks On */
#define    SICF_PCLKE        0x0004        /**< PHY clock enable */
#define    SICF_PRST        0x0008        /**< PHY reset */
#define    SICF_MPCLKE        0x0010        /**< MAC PHY clockcontrol enable */
#define    SICF_FREF        0x0020        /**< PLL FreqRefSelect (corerev >= 5) */
/* NOTE: the following bw bits only apply when the core is attached
 * to a NPHY (and corerev >= 11 which it will always be for NPHYs).
 */
#ifdef SICF_160M_BWMASK_DEF
#define    SICF_BWMASK(macrev)    (D11REV_GE(macrev, 86) ? 0x00e0 : 0x00c0)    /**< phy clkmsk */
#define    SICF_BW160(macrev)    (D11REV_GE(macrev, 86) ? 0x0080 : 0x00c0)    /**< 160MHz BW */
#define    SICF_BW80(macrev)    (D11REV_GE(macrev, 86) ? 0x0060 : 0x00c0)    /**< 80MHz BW */
#define    SICF_BW40(macrev)    (D11REV_GE(macrev, 86) ? 0x0040 : 0x0080)    /**< 40MHz BW */
#define    SICF_BW20(macrev)    (D11REV_GE(macrev, 86) ? 0x0020 : 0x0040)    /**< 20MHz BW */
#define    SICF_BW10(macrev)    (D11REV_GE(macrev, 86) ? 0x0000 : 0x0000)    /**< 10MHz BW */
#else
#define    SICF_BWMASK        0x00c0        /**< phy clock mask (b6 & b7) */
#define    SICF_BW160        0x00c0        /**< 160MHz BW */
#define    SICF_BW80        0x00c0        /**< 80MHz BW */
#define    SICF_BW40        0x0080        /**< 40MHz BW (160MHz phyclk) */
#define    SICF_BW20        0x0040        /**< 20MHz BW (80MHz phyclk) */
#define    SICF_BW10        0x0000        /**< 10MHz BW (40MHz phyclk) */
#endif
#define    SICF_DAC        0x0300        /**< Highspeed DAC mode control field */
#define    SICF_GMODE        0x2000        /**< gmode enable */
 
/* Macmode / Phymode / Opmode are used interchangebly sometimes
 * even though they all mean the same. Going ahead with the HW
 * signal name - using phymode here on (even though we know its
 * a misnomer). Applicable to d11 corerev >= 50 ---- ACPHY only
 */
#define SICF_PHYMODE_SHIFT    16
#define    SICF_PHYMODE        0xf0000        /**< mask */
 
#define SICF_160CLKSEL        0x100000u    /* main phy clock speed selection */
 
/* dot11 core-specific status flags */
#define    SISF_2G_PHY        0x0001        /**< 2.4G capable phy (corerev >= 5) */
#define    SISF_5G_PHY        0x0002        /**< 5G capable phy (corerev >= 5) */
#define    SISF_FCLKA        0x0004        /**< FastClkAvailable (corerev >= 5) */
#define    SISF_DB_PHY        0x0008        /**< Dualband phy (corerev >= 11) */
 
/* === End of MAC reg, Beginning of PHY(b/a/g/n) reg, radio and LPPHY regs are separated === */
 
/* Bits in phytest(0x0a): */
#define    TST_DDFS        0x2000
#define    TST_TXFILT1        0x0800
#define    TST_UNSCRAM        0x0400
#define    TST_CARR_SUPP        0x0200
#define    TST_DC_COMP_LOOP    0x0100
#define    TST_LOOPBACK        0x0080
#define    TST_TXFILT0        0x0040
#define    TST_TXTEST_ENABLE    0x0020
#define    TST_TXTEST_RATE        0x0018
#define    TST_TXTEST_PHASE    0x0007
 
/* phytest txTestRate values */
#define    TST_TXTEST_RATE_1MBPS    0
#define    TST_TXTEST_RATE_2MBPS    1
#define    TST_TXTEST_RATE_5_5MBPS    2
#define    TST_TXTEST_RATE_11MBPS    3
#define    TST_TXTEST_RATE_SHIFT    3
 
typedef struct shm_mbss_prq_entry_s shm_mbss_prq_entry_t;
BWL_PRE_PACKED_STRUCT struct shm_mbss_prq_entry_s {
   struct ether_addr ta;
   uint8 prq_info[2];
   uint8 time_stamp;
   uint8 flags;    /**< bit 0 HT STA Indication, bit 7:1 Reserved */
} BWL_POST_PACKED_STRUCT;
 
typedef enum shm_mbss_prq_ft_e {
   SHM_MBSS_PRQ_FT_CCK,
   SHM_MBSS_PRQ_FT_OFDM,
   SHM_MBSS_PRQ_FT_MIMO,
   SHM_MBSS_PRQ_FT_RESERVED
} shm_mbss_prq_ft_t;
 
#define SHM_MBSS_PRQ_FT_COUNT SHM_MBSS_PRQ_FT_RESERVED
 
#define SHM_MBSS_PRQ_ENT_FRAMETYPE(entry)      ((entry)->prq_info[0] & 0x3)
#define SHM_MBSS_PRQ_ENT_UPBAND(entry)         ((((entry)->prq_info[0] >> 2) & 0x1) != 0)
 
/** What was the index matched? */
#define SHM_MBSS_PRQ_ENT_UC_BSS_IDX(entry)     (((entry)->prq_info[0] >> 2) & 0x3)
#define SHM_MBSS_PRQ_ENT_PLCP0(entry)          ((entry)->prq_info[1])
 
/** Was this directed to a specific SSID or BSSID? If bit clear, quantity known */
#define SHM_MBSS_PRQ_ENT_DIR_SSID(entry) \
   ((((entry)->prq_info[0] >> 6) == 0) || ((entry)->prq_info[0] >> 6) == 1)
#define SHM_MBSS_PRQ_ENT_DIR_BSSID(entry) \
   ((((entry)->prq_info[0] >> 6) == 0) || ((entry)->prq_info[0] >> 6) == 2)
 
#define SHM_MBSS_PRQ_ENT_TIMESTAMP(entry)    ((entry)->time_stamp)
/** Was the probe request from a ht STA or a legacy STA */
#define SHM_MBSS_PRQ_ENT_HTSTA(entry)        ((entry)->flags & 0x1)
 
typedef struct d11ac_tso_s d11ac_tso_t;
 
BWL_PRE_PACKED_STRUCT struct d11ac_tso_s {
   uint8 flag[3];
   uint8 sfh_hdr_offset;
   uint16 tso_mss;        /**< tso segment size */
   uint16 msdu_siz;    /**< msdu size */
   uint32 tso_payload_siz;    /**< total byte cnt in tcp payload */
   uint16 ip_hdr_offset;    /**< relative to the start of txd header */
   uint16 tcp_hdr_offset;    /**< relative to start of txd header */
} BWL_POST_PACKED_STRUCT;
 
/* toe_ctl TCP offload engine register definitions */
#define TOE_CTL_DISAB        (1u << 0)
#define TOE_CTL_MASK        (1u << 0)
#define TOE_CTL_ENAB        (0xFFFEu)
#define TOE_CLK_GATING_DISAB    (1u << 1)
 
#define TSO_HDR_TOE_FLAG_OFFSET    (0u)
 
#define TOE_F0_HDRSIZ_NORMAL    (1u << 0)
#define TOE_F0_PASSTHROUGH    (1u << 1)
#define TOE_F0_TCPSEG_EN    (1u << 3)
#define TOE_F0_IPV4        (1u << 4)
#define TOE_F0_IPV6        (1u << 5)
#define TOE_F0_TCP        (1u << 6)
#define TOE_F0_UDP        (1u << 7)
 
#define TOE_F1_IPV4_CSUM_EN    (1u << 0)
#define TOE_F1_TCPUDP_CSUM_EN    (1u << 1)
#define TOE_F1_PSEUDO_CSUM_EN    (1u << 2)
#define TOE_F1_FRAG_ALLOW    (1u << 5)
#define TOE_F1_FRAMETYPE_1    (1u << 6)
#define TOE_F1_FRAMETYPE_2    (1u << 7)
#define TOE_F1_FT_MASK        (TOE_F1_FRAMETYPE_1 | TOE_F1_FRAMETYPE_2)
#define TOE_F1_FT_SHIFT        (6u)
 
#define TOE_F2_TXD_HEAD_SHORT    (1u << 0)
#define TOE_F2_EPOCH_SHIFT    (1u)
#define TOE_F2_EPOCH        (1u << TOE_F2_EPOCH_SHIFT)
#define TOE_F2_EPOCH_EXT    (1u << 2)
#define TOE_F2_EPOCH_EXT_MASK    (TOE_F2_EPOCH | TOE_F2_EPOCH_EXT)
#define TOE_F2_AMSDU_AGGR_EN    (1u << 4)
#define TOE_F2_AMSDU_CSUM_EN    (1u << 5)
#define TOE_F2_AMSDU_FS_MID    (1u << 6)
#define TOE_F2_AMSDU_FS_LAST    (1u << 7)
 
#define TOE_TXDMA_FLAGS_AMSDU_FIRST    (0x14u)
#define TOE_TXDMA_FLAGS_AMSDU_MID    (0x24u)
#define TOE_TXDMA_FLAGS_AMSDU_LAST    (0x34u)
 
/* This marks the end of a packed structure section. */
#include <packed_section_end.h>
 
#define SHM_BYT_CNT    0x2            /**< IHR location */
#define MAX_BYT_CNT    0x600            /**< Maximum frame len */
 
/* WOWL Template Regions */
#define WOWL_NS_CHKSUM         (0x57 * 2)
#define WOWL_PSP_TPL_BASE   (0x334 * 2)
#define WOWL_GTK_MSG2             (0x434 * 2)
#define WOWL_NS_OFFLOAD     (0x634 * 2)
#define T_KEEPALIVE_0       (0x6b4 * 2)
#define T_KEEPALIVE_1       ((0x6b4 + 0x40) * 2)
#define WOWL_ARP_OFFLOAD    (0x734 * 2)
#define WOWL_TX_FIFO_TXRAM_BASE (0x774 * 2)    /**< conservative, leave 1KB for GTKM2 */
 
/* template regions for 11ac */
#define D11AC_WOWL_PSP_TPL_BASE   (0x4c0 * 2)
#define D11AC_WOWL_GTK_MSG2       (0x5c0 * 2)    /**< for core rev >= 42 */
#define WOWL_NS_OFFLOAD_GE42     (0x7c0 * 2)
#define T_KEEPALIVE_0_GE42       (0x840 * 2)
#define T_KEEPALIVE_1_GE42       ((0x840 + 0x40) * 2)
#define WOWL_ARP_OFFLOAD_GE42    (0x8c0 * 2)
#define D11AC_WOWL_TX_FIFO_TXRAM_BASE   (0x900 * 2)    /**< GTKM2 for core rev >= 42 */
 
/* Event definitions */
#define WOWL_MAGIC       (1 << 0)    /**< Wakeup on Magic packet */
#define WOWL_NET         (1 << 1)    /**< Wakeup on Netpattern */
#define WOWL_DIS         (1 << 2)    /**< Wakeup on loss-of-link due to Disassoc/Deauth */
#define WOWL_RETR        (1 << 3)    /**< Wakeup on retrograde TSF */
#define WOWL_BCN         (1 << 4)    /**< Wakeup on loss of beacon */
#define WOWL_TST         (1 << 5)    /**< Wakeup after test */
#define WOWL_M1          (1 << 6)    /**< Wakeup after PTK refresh */
#define WOWL_EAPID       (1 << 7)    /**< Wakeup after receipt of EAP-Identity Req */
#define WOWL_PME_GPIO    (1 << 8)    /**< Wakeind via PME(0) or GPIO(1) */
#define WOWL_NEEDTKIP1   (1 << 9)    /**< need tkip phase 1 key to be updated by the driver */
#define WOWL_GTK_FAILURE (1 << 10)    /**< enable wakeup if GTK fails */
#define WOWL_EXTMAGPAT   (1 << 11)    /**< support extended magic packets */
#define WOWL_ARPOFFLOAD  (1 << 12)    /**< support ARP/NS offloading */
#define WOWL_WPA2        (1 << 13)    /**< read protocol version for EAPOL frames */
#define WOWL_KEYROT      (1 << 14)    /**< If the bit is set, use key rotaton */
#define WOWL_BCAST       (1 << 15)    /**< If the bit is set, frm received was bcast frame */
 
#define MAXBCNLOSS (1 << 13) - 1    /**< max 12-bit value for bcn loss */
 
/* UCODE shm view:
 * typedef struct {
 *         uint16 offset; // byte offset
 *         uint16 patternsize; // the length of value[.] in bytes
 *         uchar bitmask[MAXPATTERNSIZE/8]; // 16 bytes, the effect length is (patternsize+7)/8
 *         uchar value[MAXPATTERNSIZE]; // 128 bytes, the effect length is patternsize.
 *   } netpattern_t;
 */
#define NETPATTERNSIZE    (148) /* 128 value + 16 mask + 4 offset + 4 patternsize */
#define MAXPATTERNSIZE 128
#define MAXMASKSIZE    MAXPATTERNSIZE/8
 
/** Security Algorithm defines */
#define WOWL_TSCPN_SIZE 6
#define WOWL_TSCPN_COUNT  4            /**< 4 ACs */
#define WOWL_TSCPN_BLK_SIZE    (WOWL_TSCPN_SIZE * WOWL_TSCPN_COUNT)
 
#define    WOWL_SECSUITE_GRP_ALGO_MASK        0x0007
#define    WOWL_SECSUITE_GRP_ALGO_SHIFT    0
#define    WOWL_SECSUITE_ALGO_MASK            0x0700
#define    WOWL_SECSUITE_ALGO_SHIFT        8
 
#define EXPANDED_KEY_RNDS 10
#define EXPANDED_KEY_LEN  176 /* the expanded key from KEK (4*11*4, 16-byte state, 11 rounds) */
 
/* Organization of Template RAM is as follows
 *   typedef struct {
 *      uint8 AES_XTIME9DBE[1024];
 *    uint8 AES_INVSBOX[256];
 *    uint8 AES_KEYW[176];
 * } AES_TABLES_t;
 */
/* See dot11_firmware/diag/wmac_tcl/wmac_762_wowl_gtk_aes: proc write_aes_tables,
 *  for an example of writing those tables into the tx fifo buffer.
 */
 
typedef struct {
   uint16 MacTxControlLow;        /**< mac-tx-ctl-low word */
   uint16 MacTxControlHigh;    /**< mac-tx-ctl-high word */
   uint16 PhyTxControlWord;    /**< phy control word */
   uint16 PhyTxControlWord_1;    /**< extra phy control word for mimophy */
   union {
       uint16 XtraFrameTypes;    /**< frame type for RTS/FRAG fallback (used only for AES) */
       uint16 bssenc_pos;    /**< BssEnc includes key ID , for corerev >= 42 */
   } u1;
   uint8 plcp[6];            /**< plcp of template */
 
   uint16 mac_frmtype; /**< MAC frame type for GTK MSG2, can be
                * dot11_data frame (0x20) or dot11_QoS_Data frame (0x22).
                */
   uint16 frm_bytesize; /**< number of bytes in the template, it includes:
                 * PLCP, MAC header, IV/EIV, the data payload
                 * (eth-hdr and EAPOL-Key), TKIP MIC
                 */
   uint16 payload_wordoffset;    /**< the word offset of the data payload */
 
   /* ALIGN */
   uint16 seqnum;        /**< Sequence number for this frame */
   uint8  seciv[18]; /**< 10-byte TTAK used for TKIP, 8-byte IV/EIV.
              * See <SecurityInitVector> in the general tx descriptor.
              */
} wowl_templ_ctxt_t;
 
#define WOWL_TEMPL_CTXT_LEN 42    /**< For making sure that no PADs are needed */
#define WOWL_TEMPL_CTXT_FRMTYPE_DATA    0x2
#define WOWL_TEMPL_CTXT_FRMTYPE_QOS     0x22
 
/** constant tables required for AES key unwrapping for key rotation */
extern uint16 aes_invsbox[128];
extern uint16 aes_xtime9dbe[512];
 
#define MAX_MPDU_SPACE           (D11_TXH_LEN + 1538)
 
/* Bits in TXE_BMCCTL */
#define BMCCTL_INITREQ_SHIFT    0
#define BMC_CTL_DONE        (1 << BMCCTL_INITREQ_SHIFT)
#define BMCCTL_RESETSTATS_SHIFT    1
#define BMCCTL_TXBUFSIZE_SHIFT    2
#define BMCCTL_LOOPBACK_SHIFT    5
#define BMCCTL_TXBUFSZ_MASK    ((1 << BMCCTL_LOOPBACK_SHIFT) - (1 << BMCCTL_TXBUFSIZE_SHIFT))
#define BMCCTL_CLKGATEEN_SHIFT  8
 
/* Bits in TXE_BMCConfig */
#define BMCCONFIG_BUFCNT_SHIFT        0
#define BMCCONFIG_DISCLKGATE_SHIFT    13
#define BMCCONFIG_BUFCNT_MASK    ((1 << BMCCONFIG_DISCLKGATE_SHIFT) - (1 << BMCCONFIG_BUFCNT_SHIFT))
 
/* Bits in TXE_BMCStartAddr */
#define BMCSTARTADDR_STRTADDR_MASK    0x3ff
 
/* Bits in TXE_BMCDescrLen */
#define BMCDescrLen_ShortLen_SHIFT    0
#define BMCDescrLen_LongLen_SHIFT    8
 
/* Bits in TXE_BMCAllocCtl */
#define BMCAllocCtl_AllocCount_SHIFT        0
/* Rev==50 || Rev>52
*    BMCAllocCtl.AllocCount [0:10]
*    BMCAllocCtl.AllocThreshold [11:14]
* !Rev50
*    BMCAllocCtl.AllocCount [0:7]
*    BMCAllocCtl.AllocThreshold [8:15]
*/
#define BMCAllocCtl_AllocThreshold_SHIFT_Rev50    11
#define BMCAllocCtl_AllocThreshold_SHIFT    8
 
/* Bits in TXE_BMCCmd1 */
#define BMCCMD1_TIDSEL_SHIFT        1
#define BMCCMD1_RDSRC_SHIFT        6
#define BMCCmd1_RXMapPassThru_SHIFT    12
#define BMCCMD1_BQSelNum_SHIFT        1u
#define BMCCMD1_BQSelType_SHIFT        7u
#define BMCCMD1_RDSRC_Group0        0u    /* register itself */
#define BMCCMD1_RDSRC_Group1        1u    /* staged max/min */
#define BMCCMD1_RDSRC_Group2        2u    /* staged max/previous min */
#define BMCCMD1_RDSRC_Group3        3u    /* active max/min */
#define BMCCMD1_RDSRC_SHIFT_rev80    10u
#define BMCCMD1_CoreSel_SHIFT        13u
#define BMCCMD1_CoreSel_SHIFT_rev80    15u
 
/* Bits in TXE_BMCCmd */
#define BMCCmd_TIDSel_SHIFT        0
#define BMCCmd_Enable_SHIFT        4
#define BMCCmd_ReleasePreAlloc_SHIFT    5
#define BMCCmd_ReleasePreAllocAll_SHIFT    6
#define BMCCmd_UpdateBA_SHIFT        7
#define BMCCmd_Consume_SHIFT        8
#define BMCCmd_Aggregate_SHIFT        9
#define BMCCmd_UpdateRetryCount_SHIFT    10
#define BMCCmd_DisableTID_SHIFT        11
 
#define BMCCmd_BQSelType_TX    0
#define BMCCmd_BQSelType_RX    1
#define BMCCmd_BQSelType_Templ    2
 
/* Bits in TXE_BMCCMD for rev >= 80 */
#define BMCCmd_BQSelType_MASK_Rev80    0x00c0
#define BMCCmd_BQSelType_SHIFT_Rev80    6
#define BMCCmd_Enable_SHIFT_rev80    8
#define BMCCmd_ReleasePreAllocAll_SHIFT_rev80    10
 
/* Bits in TXE_BMCCmd1 */
#define BMCCmd1_Minmaxappall_SHIFT    0
#define BMCCmd1_Minmaxlden_SHIFT    5
#define BMCCmd1_Minmaxffszlden_SHIFT    8
#define BMCCmd_Core1_Sel_MASK        0x2000
 
/* Bits in TXE_BMCStatCtl */
#define BMCStatCtl_TIDSel_SHIFT        0u
#define BMCStatCtl_STATSel_SHIFT    4u
#define BMCStatCtl_BQSelNum_SHIFT    0u
#define BMCStatCtl_BQSelType_SHIFT    6u
#define BMCStatCtl_STATSel_SHIFT_rev80    8u
 
/* Bits in BMVpConfig */
#define BMCVPConfig_SingleVpModePortA_SHIFT    4
 
/* Bits in TXE_PsmMSDUAccess */
#define PsmMSDUAccess_TIDSel_SHIFT    0
#define PsmMSDUAccess_MSDUIdx_SHIFT    4
#define PsmMSDUAccess_ReadBusy_SHIFT    14
#define PsmMSDUAccess_WriteBusy_SHIFT    15
 
/* Bits in TXE_PsmMSDUAccess for rev >= 80 */
#define PsmMSDUAccess_BQSelType_SHIFT    5
#define PsmMSDUAccess_MSDUIdx_SHIFT_rev80    7
#define PsmMSDUAccess_BQSelType_Templ    2
#define PsmMSDUAccess_BQSelType_TX    0
 
#ifdef WLRSDB
#define MAX_RSDB_MAC_NUM 2
#else
#define MAX_RSDB_MAC_NUM 1
#endif
#define MAX_MIMO_MAC_NUM 1
 
#ifdef WL_SCAN_CORE
#define MAX_MAC_CORE_NUM    (MAX_RSDB_MAC_NUM + 1)
#else
#define MAX_MAC_CORE_NUM    (MAX_RSDB_MAC_NUM)
#endif /* WL_SCAN_CORE */
 
#define MAC_CORE_UNIT_0                0x0u /**< First mac core unit */
#define MAC_CORE_UNIT_1                0x1u /**< Second mac core unit */
 
/* HW unit of scan core.
 * This is used to overwrite the tunables specific to scan core
 */
#define SCAN_CORE_UNIT                0x2u
 
/* Supported phymodes / macmodes / opmodes */
#define SINGLE_MAC_MODE                0x0 /**< only single mac is enabled */
#define DUAL_MAC_MODE                0x1 /**< enables dual mac */
/* (JIRA: CRDOT11ACPHY-652) Following two #defines support
 * exclusive reg access to core 0/1 in MIMO mode
 */
#define SUPPORT_EXCLUSIVE_REG_ACCESS_CORE0    0x2
#define SUPPORT_EXCLUSIVE_REG_ACCESS_CORE1    0x4 /**< not functional in 4349A0 */
#define SUPPORT_CHANNEL_BONDING            0x8 /**< enables channel bonding,
                            * supported in single mac mode only
                            */
#define SCAN_CORE_ACTIVE            0x10 /* scan core enabled for background DFS */
 
#define PHYMODE_MIMO        (SINGLE_MAC_MODE)
#define PHYMODE_80P80        (SINGLE_MAC_MODE | SUPPORT_CHANNEL_BONDING)
#define PHYMODE_RSDB_SISO_0    (DUAL_MAC_MODE | SUPPORT_EXCLUSIVE_REG_ACCESS_CORE0)
#define PHYMODE_RSDB_SISO_1    (DUAL_MAC_MODE | SUPPORT_EXCLUSIVE_REG_ACCESS_CORE1)
#define PHYMODE_RSDB        (PHYMODE_RSDB_SISO_0 | PHYMODE_RSDB_SISO_1)
#define PHYMODE_BGDFS        31
#define PHYMODE_3x3_1x1        31
 
#define RX_INTR_FIFO_0        0x1        /**< FIFO-0 interrupt */
#define RX_INTR_FIFO_1        0x2        /**< FIFO-1 interrupt */
#define RX_INTR_FIFO_2        0x4        /**< FIFO-2 interrupt */
 
#define MAX_RX_FIFO        3
 
#define RX_CTL_FIFOSEL_SHIFT    8
#define RX_CTL_FIFOSEL_MASK    (0x3 << RX_CTL_FIFOSEL_SHIFT)
 
#define RCO_EN                (0x1u)  /**< Receive checksum offload */
 
/* MAC_PTM_CTRL1 bit definitions */
#define PTM_RX_TMSTMP_CAPTURE_EN    0x0001u
#define PTM_TX_TMSTMP_CAPTURE_EN    0x0001u
#define PTM_TMSTMP_OVERRIDE_EN        0x1000u
 
/* For corerev >= 64
 * Additional DMA descriptor flags for AQM Descriptor. These are used in
 * conjunction with the descriptor control flags defined in sbhnddma.h
 */
/* AQM DMA Descriptor control flags 1 */
#define D64_AQM_CTRL1_SOFPTR        0x0000FFFF    /* index of the descr which
                            * is SOF decriptor in DMA table
                            */
#define D64_AQM_CTRL1_EPOCH        0x00010000    /* Epoch bit for the frame */
#define D64_AQM_CTRL1_NUMD_MASK        0x00F00000    /* NumberofDescriptors(NUMD) */
#define D64_AQM_CTRL1_NUMD_SHIFT    20
#define D64_AQM_CTRL1_AC_MASK        0x0F000000    /* AC of the current frame */
#define D64_AQM_CTRL1_AC_SHIFT        24
 
/* AQM DMA Descriptor control flags 2 */
#define D64_AQM_CTRL2_MPDULEN_MASK    0x00003FFF    /* Length of the entire MPDU */
#define D64_AQM_CTRL2_TXDTYPE        0x00080000    /* When set to 1 the long form of the
                            * TXD is used for the frame.
                            */
/* For corerev >= 83
 * DMA descriptor flags for AQM Descriptor. These are used in
 * conjunction with the descriptor control flags defined in sbhnddma.h
 */
/* AQM DMA Descriptor control flags 1 */
#define D11_REV83_AQM_DESC_CTRL1_SOFPTR        0x0000FFFFu    /* index of the descr which
                                * is SOF decriptor in DMA table
                                */
#define D11_REV83_AQM_DESC_CTRL1_EPOCH_SHIFT        16u
#define D11_REV83_AQM_DESC_CTRL1_EPOCH            (1u << D11_REV83_AQM_DESC_CTRL1_EPOCH_SHIFT)
#define D11_REV83_AQM_DESC_CTRL1_EPOCH_EXT_SHIFT    17u
#define D11_REV83_AQM_DESC_CTRL1_EPOCH_EXT        (1u << \
                           D11_REV83_AQM_DESC_CTRL1_EPOCH_EXT_SHIFT)
#define D11_REV83_AQM_DESC_CTRL1_EPOCH_MASK    (D11_REV83_AQM_DESC_CTRL1_EPOCH | \
                           D11_REV83_AQM_DESC_CTRL1_EPOCH_EXT)
#define D11_REV83_AQM_DESC_CTRL1_RESV1        0x00040000u    /* RESERVED */
#define D11_REV83_AQM_DESC_CTRL1_FRAGALLOW_SHIFT    19u    /* Fragmentation allowance flag
                                * shift.
                                */
#define D11_REV83_AQM_DESC_CTRL1_FRAGALLOW    (1u << D11_REV83_AQM_DESC_CTRL1_FRAGALLOW_SHIFT)
                               /* Fragmentation allowance flag
                                * of the frame
                                */
#define D11_REV83_AQM_DESC_CTRL1_NUMD_SHIFT    20u        /* NumberofDescriptors(NUMD) */
#define D11_REV83_AQM_DESC_CTRL1_NUMD_MASK    (0xFu << D11_REV83_AQM_DESC_CTRL1_NUMD_SHIFT)
#define D11_REV83_AQM_DESC_CTRL1_AC_SHIFT    24u        /* AC of the current frame */
#define D11_REV83_AQM_DESC_CTRL1_AC_MASK    (0xFu << D11_REV83_AQM_DESC_CTRL1_AC_SHIFT)
#define D11_REV83_AQM_DESC_CTRL1_ET        0x10000000u    /* End of table */
#define D11_REV83_AQM_DESC_CTRL1_IC        0x20000000u    /* Interrupt on Completion */
#define D11_REV83_AQM_DESC_CTRL1_RESV2        0x40000000u    /* Used to be EF: End of frame,
                                * and would have been set to 1.
                                */
#define D11_REV83_AQM_DESC_CTRL1_RESV3        0x80000000u    /* Used to be SF: Start of Frame,
                                * and would have been set to 1
                                */
 
/* AQM DMA Descriptor control flags 2 */
#define D11_REV83_AQM_DESC_CTRL2_MPDULEN_MASK    0x00003FFFu    /* Length of the entire MPDU */
#define D11_REV83_AQM_DESC_CTRL2_FTYPE_SHIFT    14u        /* Frame Type, Indicate whether
                                * frame is Data, Management or
                                * Control Frame. 2 bits:
                                * 2'b00=Data, 2'b01=Management,
                                * 2'b10=Control, 2'b11=Invalid
                                * value
                                */
#define D11_REV83_AQM_DESC_CTRL2_FTYPE_MASK    (0x3u << D11_REV83_AQM_DESC_CTRL2_FTYPE_SHIFT)
#define D11_REV83_AQM_DESC_CTRL2_PTXDLENIDX_SHIFT    16u /* pTxD length index in 4-deep table */
#define D11_REV83_AQM_DESC_CTRL2_PTXDLENIDX_MASK    (0x3u << \
                           D11_REV83_AQM_DESC_CTRL2_PTXDLENIDX_SHIFT)
#define D11_REV83_AQM_DESC_CTRL2_PT        0x00040000u    /* Parity bit. Choose a
                                * value such that the entire
                                * descriptor haseven parity
                                */
#define D11_REV83_AQM_DESC_CTRL2_USERIT        0x00080000u    /* If set, the Rate Table Index and
                                * RIT entry are fetched into SHM by
                                * hardware. Otherwise, software
                                * uses pTxD to convey this
                                * information to ucode
                                */
#define D11_REV83_AQM_DESC_CTRL2_USELIT        0x00100000u    /* If set, the Link Info Table Index
                                * and LIT entry are fetched into
                                * SHM by hardware. Otherwise,
                                * software uses pTxD to convey this
                                * information to ucode
                                */
#define D11_REV83_AQM_DESC_CTRL2_LIT_SHIFT    21u    /* LTI(Link info Table Index) */
#define D11_REV83_AQM_DESC_CTRL2_LIT_MASK    (0x3Fu << D11_REV83_AQM_DESC_CTRL2_LIT_SHIFT)
#define D11_REV83_AQM_DESC_CTRL2_RIT_SHIFT    27u    /* bit[4:0] of RTI(Rate info Table Index) */
#define D11_REV83_AQM_DESC_CTRL2_RIT_MASK    (0x1Fu << D11_REV83_AQM_DESC_CTRL2_RIT_SHIFT)
 
/* AQM DMA Descriptor control flags 3 */
#define D11_REV86_AQM_DESC_CTRL3_RTI_BIT5    0x00000001u /* bit[5] of RTI (cont'd from ctrl2) */
#define D11_REV86_AQM_DESC_CTRL3_RTI_BIT5_MASK    1u          /* bit[5] of RTI (cont'd from ctrl2) */
#define D11_REV86_AQM_DESC_CTRL3_RTI_BIT5_SHIFT    0u
#define D11_REV83_AQM_DESC_CTRL3_AGGR_ID    0x0000000Eu    /* Aggregation ID */
#define D11_REV83_AQM_DESC_CTRL3_CO        0x00000010u    /* Coherency */
#define D11_REV84_AQM_DESC_CTRL3_TXDPTR_SHIFT    5u        /* TxD ptr */
#define D11_REV84_AQM_DESC_CTRL3_TXDPTR_MASK    0xFFFFFFu    /* bit[23:0] of TxD addr */
#define D11_REV86_AQM_DESC_CTRL3_TID_SHIFT    29u        /* TID for BSR */
#define D11_REV86_AQM_DESC_CTRL3_TID_MASK    (0x7u << D11_REV86_AQM_DESC_CTRL3_TID_SHIFT)
 
/* values for psm_patchcopy_ctrl (0x1AC) post corerev 60 */
#define PSM_PATCHCC_PMODE_MASK        (0x3)
#define PSM_PATCHCC_PMODE_RAM        (0)    /* default */
#define PSM_PATCHCC_PMODE_ROM_RO    (1)
#define PSM_PATCHCC_PMODE_ROM_PATCH    (2)
 
#define PSM_PATCHCC_PENG_TRIGGER_SHIFT    (2)
#define PSM_PATCHCC_PENG_TRIGGER_MASK    (1 << PSM_PATCHCC_PENG_TRIGGER_SHIFT)
#define PSM_PATCHCC_PENG_TRIGGER    (1 << PSM_PATCHCC_PENG_TRIGGER_SHIFT)
 
#define PSM_PATCHCC_PCTRL_RST_SHIFT    (3)
#define PSM_PATCHCC_PCTRL_RST_MASK    (0x3 << PSM_PATCHCC_PCTRL_RST_SHIFT)
#define PSM_PATCHCC_PCTRL_RST_RESET    (0x0 << PSM_PATCHCC_PCTRL_RST_SHIFT)
#define PSM_PATCHCC_PCTRL_RST_HW    (0x1 << PSM_PATCHCC_PCTRL_RST_SHIFT)
 
#define PSM_PATCHCC_COPYEN_SHIFT    (5)
#define PSM_PATCHCC_COPYEN_MASK        (1 << PSM_PATCHCC_COPYEN_SHIFT)
#define PSM_PATCHCC_COPYEN        (1 << PSM_PATCHCC_COPYEN_SHIFT)
 
#define PSM_PATCHCC_UCIMGSEL_SHIFT    (16)
#define PSM_PATCHCC_UCIMGSEL_MASK    (0x30000)
#define PSM_PATCHCC_UCIMGSEL_DS0    (0x00000)    /* default image */
#define PSM_PATCHCC_UCIMGSEL_DS1    (0x10000)    /* image 1 */
 
/* patch copy delay for psm: 2millisec */
#define PSM_PATCHCOPY_DELAY        (2000)
 
/* START-below WAS in d11_if_shm.h which we can move to auto shm.
 * Some of them are offsets, but some of them are not given by ucode [possibly legacy]
 * so, not taken care by autoshm.
 */
 
/* Addr is byte address used by SW; offset is word offset used by uCode */
 
/** Per AC TX limit settings */
#define M_AC_TXLMT_ADDR(x, _ac)         (M_AC_TXLMT_BLK(x) + (2 * (_ac)))
 
/** delay from end of PLCP reception to RxTSFTime */
#define    M_APHY_PLCPRX_DLY    3
#define    M_BPHY_PLCPRX_DLY    4
 
/* btcx debug shmem size */
#define C_BTCX_DBGBLK_SZ    6    /**< Number of 16bit words */
#define C_BTCX_DBGBLK2_SZ    11    /* size of statistics at 2nd SHM segment */
 
#define C_BTCX_STATS_DBGBLK_SZ    18 /* total size of statistics at A2DP stats */
#define C_BTCX_A2DP_PRI_SZ    6    /* size of a2dp priority counters stats */
#define C_BTCX_A2DP_BUFCNT_SZ    8    /* size of a2dp buffer counters stats */
#define C_BTCX_ANT_GRANT_SZ    4    /* size of ant granted duration to BT */
#define C_BTCX_STATS_ECNTR_BLK_SZ    C_BTCX_STATS_DBGBLK_SZ /* blk size for btcx ecounters */
 
#define D11_DMA_CHANNELS    6
 
/* WME shared memory */
#define M_EDCF_STATUS_OFF(x)    (0x007 * 2)
 
/* Beacon-related parameters */
#define M_BCN_LI(x)        M_PS_MORE_DTIM_TBTT(x)    /**< beacon listen interval */
 
/* prerev 40 defines */
#define    D11_PRE40_M_SECKINDXALGO_BLK(x)    (0x2ea * 2)
 
/* corerev 40 defines */
/* BLK SIZE needs to change for GE64 */
#define    D11_POST80_MAX_KEY_SIZE        32
#define    D11_PRE80_MAX_KEY_SIZE        16
 
#define D11_MAX_KEY_SIZE(_corerev) ((D11REV_GE(_corerev, 80)) ? \
       D11_POST80_MAX_KEY_SIZE : D11_PRE80_MAX_KEY_SIZE)
 
#define M_SECKINDXALGO_BLK_SZ(_corerev)   (AMT_SIZE(_corerev) + 4 /* default keys */)
 
#define    C_CTX_PCTLWD_POS    (0x4 * 2)
 
#define D11_MAX_TX_FRMS        32        /**< max frames allowed in tx fifo */
 
/* Current channel number plus upper bits */
#define D11_CURCHANNEL_5G    0x0100;
#define D11_CURCHANNEL_40    0x0200;
#define D11_CURCHANNEL_MAX    0x00FF;
 
#define INVALIDFID        0xffff
 
#define    D11_RT_DIRMAP_SIZE    16
 
/** Rate table entry offsets */
#define    M_RT_PRS_PLCP_POS(x)    10
#define    M_RT_PRS_DUR_POS(x)    16
#define    M_RT_OFDM_PCTL1_POS(x)    18
#define    M_RT_TXPWROFF_POS(x)    20
#define    M_REV40_RT_TXPWROFF_POS(x)    14
 
#define MIMO_MAXSYM_DEF        0x8000 /* 32k */
#define MIMO_MAXSYM_MAX        0xffff /* 64k */
 
#define WATCHDOG_8TU_DEF_LT42    5
#define WATCHDOG_8TU_MAX_LT42    10
#define WATCHDOG_8TU_DEF    3
#define WATCHDOG_8TU_MAX    4
 
#define M_PKTENG_RXAVGPWR_ANT(x, w)            (M_MFGTEST_RXAVGPWR_ANT0(x) + (w) * 2)
 
/* M_MFGTEST_NUM (pkt eng) bit definitions */
#define MFGTEST_TXMODE            0x0001 /* TX frames indefinitely */
#define MFGTEST_RXMODE            0x0002 /* RX frames */
#define MFGTEST_RXMODE_ACK        0x0402 /* RX frames with sending ACKs back */
#define MFGTEST_RXMODE_FWD2FW        0x8000 /* RX frames - forward packet to the fw */
#define MFGTEST_TXMODE_FRMCNT        0x0101 /* TX frames by frmcnt */
#define MFGTEST_RU_TXMODE        0x0011    /* RU frames TX indefinetly */
#define MFGTEST_RU_TXMODE_FRMCNT    0x0111 /* RU TX frames by frmcnt */
 
/* UOTA interface bit definitions */
enum {
   C_UOTA_CNTSRT_NBIT = 0,     /* 0 OTA rx frame count start bit (14 LSB's) */
   C_UOTA_RXFST_NBIT = 14,     /* 14 indicating first frame */
   C_UOTA_RSSION_NBIT = 15, /* 15 OTA rx ON bit position */
};
 
#define M_EDCF_QLEN(x)    (M_EDCF_QINFO1_OFFSET(x))
#define M_PWRIND_MAP(x, core)        (M_PWRIND_BLKS(x) + ((core)<<1))
 
#define M_BTCX_MAX_INDEX        320u
#define M_BTCX_BACKUP_SIZE        130
#define BTCX_AMPDU_MAX_DUR        2500
 
#define ADDR_STAMON_NBIT    (1 << 10) /* STA monitor bit in AMT_INFO_BLK entity */
 
#ifdef WLP2P_UCODE
 
/** The number of scheduling blocks */
#ifdef BCMFUZZ /* need more for fuzzing */
#define M_P2P_BSS_MAX        8
#else
#define M_P2P_BSS_MAX        4
#endif /* BCMFUZZ */
 
/** WiFi P2P interrupt block positions */
#define M_P2P_I_BLK_SZ        4
#define M_P2P_I_BLK_OFFSET(x)    (M_P2P_INTR_BLK(x) - M_P2P_INTF_BLK(x))
#define M_P2P_I_BLK(x, b)        (M_P2P_I_BLK_OFFSET(x) + (M_P2P_I_BLK_SZ * (b) * 2))
#define M_P2P_I(x, b, i)        (M_P2P_I_BLK(x, b) + ((i) * 2))
 
#define M_P2P_I_PRE_TBTT    0    /**< pretbtt, wake up just before beacon reception */
#define M_P2P_I_CTW_END        1    /**< CTWindow ends */
#define M_P2P_I_ABS        2    /**< absence period start, trigger for switching channels */
#define M_P2P_I_PRS        3    /**< presence period starts */
 
/** P2P hps flags */
#define M_P2P_HPS_CTW(b)    (1 << (b))
#define M_P2P_HPS_NOA(b)    (1 << ((b) + M_P2P_BSS_MAX))
 
/** WiFi P2P address attribute block */
#define M_ADDR_BMP_BLK_SZ        12
#define M_ADDR_RANDMAC_BMP_BLK_SZ    40u
 
#define M_ADDR_BMP_BLK(x, b)    (M_ADDR_BMP_BLK_OFFSET(x) + ((b) * 2))
 
#define ADDR_BMP_RA        (1 << 0)    /**< Receiver Address (RA) */
#define ADDR_BMP_TA        (1 << 1)    /**< Transmitter Address (TA) */
#define ADDR_BMP_BSSID        (1 << 2)    /**< BSSID */
#define ADDR_BMP_AP        (1 << 3)    /**< Infra-BSS Access Point (AP) */
#define ADDR_BMP_STA        (1 << 4)    /**< Infra-BSS Station (STA) */
#define ADDR_BMP_P2P_DISC    (1 << 5)    /**< P2P Device */
#define ADDR_BMP_P2P_GO        (1 << 6)    /**< P2P Group Owner */
#define ADDR_BMP_P2P_GC        (1 << 7)    /**< P2P Client */
#define ADDR_BMP_BSS_IDX_MASK    (3 << 8)    /**< BSS control block index */
#define ADDR_BMP_BSS_IDX_SHIFT    8
 
/** WiFi P2P address starts from this entry in RCMTA */
#define P2P_ADDR_STRT_INDX    (RCMTA_SIZE - M_ADDR_BMP_BLK_SZ)
 
/* WiFi P2P per BSS control block positions.
 * all time related fields are in units of (1<<P2P_UCODE_TIME_SHIFT)us unless noted otherwise.
 */
 
#define P2P_UCODE_TIME_SHIFT        7
#define M_P2P_BSS_BLK_SZ        12
#define M_P2P_BSS_BLK_OFFSET(x)        (M_P2P_PERBSS_BLK(x) - M_P2P_INTF_BLK(x))
#define M_P2P_BSS_BLK(x, b)        (M_P2P_BSS_BLK_OFFSET(x) + (M_P2P_BSS_BLK_SZ * (b) * 2))
#define M_P2P_BSS(x, b, p)        (M_P2P_BSS_BLK(x, b) + (p) * 2)
#define M_P2P_BSS_BCN_INT(x, b)        (M_P2P_BSS_BLK(x, b) + (0 * 2))    /**< beacon interval */
#define M_P2P_BSS_DTIM_PRD(x, b)    (M_P2P_BSS_BLK(x, b) + (1 * 2))    /**< DTIM period */
#define M_P2P_BSS_ST(x, b)        (M_P2P_BSS_BLK(x, b) + (2 * 2))    /**< current state */
#define M_P2P_BSS_N_PRE_TBTT(x, b)    (M_P2P_BSS_BLK(x, b) + (3 * 2))    /**< next pretbtt time */
#define M_P2P_BSS_CTW(x, b)        (M_P2P_BSS_BLK(x, b) + (4 * 2))    /**< CTWindow duration */
#define M_P2P_BSS_N_CTW_END(x, b)    (M_P2P_BSS_BLK(x, b) + (5 * 2))    /**< next CTWindow end */
#define M_P2P_BSS_NOA_CNT(x, b)        (M_P2P_BSS_BLK(x, b) + (6 * 2))    /**< NoA count */
#define M_P2P_BSS_N_NOA(x, b)        (M_P2P_BSS_BLK(x, b) + (7 * 2))    /**< next absence time */
#define M_P2P_BSS_NOA_DUR(x, b)        (M_P2P_BSS_BLK(x, b) + (8 * 2))    /**< absence period */
#define M_P2P_BSS_NOA_TD(x, b)        (M_P2P_BSS_BLK(x, b) + (9 * 2))
                               /**< presence period (int - dur) */
#define M_P2P_BSS_NOA_OFS(x, b)        (M_P2P_BSS_BLK(x, b) + (10 * 2))
                               /* last 7 bits of interval in us */
#define M_P2P_BSS_DTIM_CNT(x, b)    (M_P2P_BSS_BLK(x, b) + (11 * 2))
                               /**< DTIM count */
 
/* M_P2P_BSS_ST word positions. */
#define M_P2P_BSS_ST_CTW    (1 << 0)    /**< BSS is in CTWindow */
#define M_P2P_BSS_ST_SUPR    (1 << 1)    /**< BSS is suppressing frames */
#define M_P2P_BSS_ST_ABS    (1 << 2)    /**< BSS is in absence period */
#define M_P2P_BSS_ST_WAKE    (1 << 3)
#define M_P2P_BSS_ST_AP        (1 << 4)    /**< BSS is Infra-BSS AP */
#define M_P2P_BSS_ST_STA    (1 << 5)    /**< BSS is Infra-BSS STA */
#define M_P2P_BSS_ST_GO        (1 << 6)    /**< BSS is P2P Group Owner */
#define M_P2P_BSS_ST_GC        (1 << 7)    /**< BSS is P2P Client */
#define M_P2P_BSS_ST_IBSS    (1 << 8)    /**< BSS is an IBSS */
#define M_P2P_BSS_ST_AWDL    (1 << 9)    /* BSS is AWDL */
#define M_P2P_BSS_ST_NAN    (1 << 10)    /**< BSS is NAN */
#define M_P2P_BSS_ST_MULTIDTIM    (1 << 11)    /* BSS is Muti-DTIM enabled */
 
/** WiFi P2P TSF block positions */
#define M_P2P_TSF_BLK_SZ        4
#define M_P2P_TSF_BLK_OFFSET(x)        (M_P2P_TSF_OFFSET_BLK(x) - M_P2P_INTF_BLK(x))
#define M_P2P_TSF_BLK(x, b)        (M_P2P_TSF_BLK_OFFSET(x) + (M_P2P_TSF_BLK_SZ * (b) * 2))
#define M_P2P_TSF(x, b, w)        (M_P2P_TSF_BLK(x, b) + (w) * 2)
 
#define M_P2P_TSF_DRIFT_OFFSET(x)    (M_P2P_TSF_DRIFT_WD0(x) - M_P2P_INTF_BLK(x))
#define M_P2P_TSF_DRIFT(x, w)        (M_P2P_TSF_DRIFT_OFFSET(x) + (w) * 2)
 
#define M_P2P_GO_CHANNEL_OFFSET(x)    (M_P2P_GO_CHANNEL(x) - M_P2P_INTF_BLK(x))
#define M_P2P_GO_IND_BMP_OFFSET(x)    (M_P2P_GO_IND_BMP(x) - M_P2P_INTF_BLK(x))
 
/**
 * M_P2P_GO_IND_BMP now has multiple fields:
 *    7:0    - GO_IND_BMP
 *    10:8    - BSS Index
 *    15:11    - Reserved
*/
#define M_P2P_GO_IND_BMP_MASK        (0xFF)
#define M_P2P_BSS_INDEX_MASK        (0x700)
#define M_P2P_BSS_INDEX_SHIFT_BITS    (8)
 
/* per BSS PreTBTT */
/* BOM 768.0 and above */
#define M_P2P_PRE_TBTT_OFFSET(x)    (M_P2P_PRETBTT_BLK(x) - M_P2P_INTF_BLK(x))
#define M_P2P_PRE_TBTT(x, b)        (M_P2P_PRE_TBTT_OFFSET(x) + ((b) * 2))    /**< in us */
 
/* Reserve bottom of RCMTA for P2P Addresses */
#define    WSEC_MAX_RCMTA_KEYS    (54 - M_ADDR_BMP_BLK_SZ)
#else
#define    WSEC_MAX_RCMTA_KEYS    54
#endif    /* WLP2P_UCODE */
 
#define TXCOREMASK        0x0F
#define SPATIAL_SHIFT        8
#define MAX_COREMASK_BLK    5
#define COREMASK_BLK_TRIG_FRAMES    (MAX_COREMASK_BLK + 1)
 
#define BPHY_ONE_CORE_TX    (1 << 15)    /**< enable TX ant diversity for 11b frames */
 
#define M_WLCX_CONFIG_EN(x)    0x1                /**< 1: enable wifi coex */
#define M_WLCX_CONFIG_MASTER(x)    0x2                /**< 1: Coex Master(5357) */
 
/* ucode debug status codes */
#define    DBGST_INACTIVE        0        /**< not valid really */
#define    DBGST_INIT        1        /**< after zeroing SHM, before suspending at init */
#define    DBGST_ACTIVE        2        /**< "normal" state */
#define    DBGST_SUSPENDED        3        /**< suspended */
#define    DBGST_ASLEEP        4        /**< asleep (PS mode) */
#define DBGST_SLP2WAKE          7               /* On wake up path. */
 
/**
 * Defines for Self Mac address (used currently for CTS2SELF frames
 * generated by BTCX ucode for protection purposes) in SHM. GE40 only.
 */
#define M_MYMAC_ADDR_L(x)                (M_MYMAC_ADDR(x))
#define M_MYMAC_ADDR_M(x)                (M_MYMAC_ADDR(x) + (1*2))
#define M_MYMAC_ADDR_H(x)                (M_MYMAC_ADDR(x) + (2*2))
 
/* Re-uses M_SSID */
#define SHM_MBSS_BCNLEN0(x)        M_SSID(x)
 
#define SHM_MBSS_CLOSED_NET(x)        (0x80)    /**< indicates closed network */
 
/** SSID Search Engine entries */
#define SHM_MBSS_SSIDSE_BASE_ADDR(x)    (0)
#define SHM_MBSS_SSIDSE_BLKSZ(x)        (36)
#define SHM_MBSS_SSIDLEN_BLKSZ        (4)
#define SHM_MBSS_SSID_BLKSZ            (32)
 
/* END New for ucode template based mbss */
 
/** Definitions for PRQ fifo data */
 
#define SHM_MBSS_PRQ_ENTRY_BYTES 10    /**< Size of each PRQ entry */
#define SHM_MBSS_PRQ_ENTRY_COUNT 12    /**< Number of PRQ entries */
#define SHM_MBSS_PRQ_TOT_BYTES   (SHM_MBSS_PRQ_ENTRY_BYTES * SHM_MBSS_PRQ_ENTRY_COUNT)
 
#define M_WOWL_NOBCN    (0x06c * 2)        /**< loss of bcn value */
 
#define M_KEK(x)        M_EAPOLMICKEY_BLK(x) + (0x10 * 2) /* < KEK for WEP/TKIP */
 
#define M_ARPRESP_BYTESZ_OFFSET        0    /**< 2 bytes; ARP resp pkt size */
#define M_NA_BYTESZ_0_OFFSET        2    /**< 2 bytes ; NA pkt size */
#define M_NA_BYTESZ_1_OFFSET        4    /**< 2 bytes ; NA pkt size */
#define M_KEEPALIVE_BYTESZ_0_OFFSET    6    /**< 2 bytes; size of first keepalive */
#define M_KEEPALIVE_BYTESZ_1_OFFSET    8    /**< 2 bytes; size of second keepalive */
#define M_NPAT_ARPIDX_OFFSET        10    /**< 2 bytes; net pattern index of ARP */
#define M_NPAT_NS0IDX_OFFSET        12    /**< 2 bytes; net pattern index of NS 0 */
#define M_NPAT_NS1IDX_OFFSET        14    /**< 2 bytes; net pattern index of NS 1 */
#define M_EXTWAKEPATTERN_0_OFFSET    16    /**< 6 bytes; ext magic pattern */
#define M_EXTWAKEPATTERN_U0_OFFSET    22    /**< 8 bytes; unaligned ext magic pattern */
#define M_KEEPALIVE_INTVL_0_OFFSET    30    /**< 2 bytes; in no of beacon intervals */
#define M_KEEPALIVE_INTVL_1_OFFSET    32    /**< 2 bytes; in no of beacon intervals */
 
#define M_COREMASK_BLK_WOWL_L30     (0x298 * 2)
 
/* corerev > 29 && corerev < 40 */
#define M_COREMASK_BLK_WOWL         (0x7e8 *2)
 
/* corerev >= 42 */
#define D11AC_M_COREMASK_BLK_WOWL       (0x1b0*2)
 
#define    M_EXTLNA_PWRSAVE(x)    M_RADIO_PWR(x)    /**< External LNA power control support */
 
/* D11AC shm location changes */
#define    D11AC_T_NULL_TPL_BASE        (0x16 * 2)
#define D11AC_T_NULL_TPL_SIZE_BYTES    (24)
#define D11_T_BCN0_TPL_BASE    T_BCN0_TPL_BASE
#define D11AC_T_BCN0_TPL_BASE    (0x100 * 2)
#define D11_T_BCN1_TPL_BASE    T_BCN1_TPL_BASE
#define D11AC_T_BCN1_TPL_BASE    (0x240 * 2)
#define D11AC_T_GACT_TWT_INFO_TPL_BASE    (0xB0 * 2)
#define D11AC_T_GACT_TWT_INFO_TPL_SIZE_BYTES    (36)
 
/* The response (ACK/BA) phyctrl words */
#define D11AC_RSP_TXPCTL0      (0x4c * 2)
#define D11AC_RSP_TXPCTL1      (0x4d * 2)
 
#define D11AC_T_PRS_TPL_BASE    (0x380 * 2)
 
#define    D11_M_RT_PRS_PLCP_POS(x) M_RT_PRS_PLCP_POS(x)
#define    D11_M_RT_PRS_DUR_POS(x) M_RT_PRS_DUR_POS(x)
#define D11AC_M_RT_PRS_PLCP_POS 8
#define D11AC_M_RT_PRS_DUR_POS 12
 
/* Field definitions for M_REV40_RT_TXPWROFF_POS */
#define M_REV40_RT_HTTXPWR_OFFSET_MASK    0x01f8    /**< bit 8:3 */
#define M_REV40_RT_HTTXPWR_OFFSET_SHIFT    3
 
/* for axphy */
#define M_REV80_RT_TXPWR_OFFSET_MASK    0xff00    /* bit 15:8 */
#define M_REV80_RT_TXPWR_OFFSET_SHIFT    9    /* 8 (byte align) + 1 (convert from S5.1 to S5.2) */
 
/* shmem locations for Beamforming */
/* shmem defined with prefix M_ are in shmem */
#define shm_addr(base, offset)  (((base)+(offset))*2)
 
#define C_BFI_REFRESH_THR_OFFSET  (1u)
#define C_BFI_NDPA_TXLMT_OFFSET   (2u)
#define C_BFI_NRXC_OFFSET         (3u)
#define C_BFI_MLBF_LUT_OFFSET     (4u)  // for corerev < 64 only
 
#define C_BFI_BLK_SIZE(corerev)     ((D11REV_GE(corerev, 86) ? 18u: 16u))
 
/* BFI block definitions (Beamforming) */
#define C_BFI_BFRIDX_POS          (0)
#define    C_BFI_NDPA_TST_POS        (1)
#define    C_BFI_NDPA_TXCNT_POS      (2)
#define C_BFI_NDPA_SEQ_POS        (3)
#define C_BFI_NDPA_FCTST_POS      (4)
#define C_BFI_BFRCTL_POS          (5)
#define C_BFI_BFR_CONFIG0_POS     (6)
#define C_BFI_BFE_CONFIG0_POS     (7)
#define C_BFI_BFE_MIMOCTL_POS     (8)
#define C_BFI_BSSID0_POS          (9)
#define C_BFI_BSSID1_POS          (10)
#define C_BFI_BSSID2_POS          (11)
#define C_BFI_STAINFO_POS         (12)
#define C_BFI_STAINFO1_POS        (13)
#define C_BFI_BFE_MYAID_POS       (13) /* stainfo1 is mutually exclusive */
#define C_BFI_BFMSTAT_POS         (14)
#define C_BFI_BFE_MIMOCTL_EXT_POS (15)
/* below SHMs for rev >= 86 */
#define C_BFI_BFE_11AXMIMOCTL_POS (16) /* phyreg bfeMimoCtlReg for 11AX */
#define C_BFI_BFE_NDPNR_POS       (17)
/* used by BFR */
#define C_BFI_STA_ADDR_POS C_BFI_BSSID0_POS
 
/* to be removed -start */
#define M_BFI_BLK_SIZE            (16u)
#define BFI_BLK_SIZE  18
/* to be removed -end */
 
/* Phy cache index Bit<8> indicates the validity. Cleared during TxBf link Init
 * to trigger a new sounding sequence.
 */
#define C_BFRIDX_VLD_NBIT    8 /* valid */
#define C_BFRIDX_EN_NBIT    7 /* BFI block is enabled (has valid info),
                  * applicable only for MU BFI block in shmemx
                  */
#define C_BFRIDX_BW_NBIT    12
 
#define C_STAINFO_FBT_NBIT   12   /* 0: SU; 1: MU */
#define C_STAINFO_NCIDX_NBIT 13 /* Bits13-15: NC IDX; Reserved if Feedback Type is SU */
 
/* NDP control blk */
#define C_BFI_BFRCTL_POS_NDP_TYPE_SHIFT  (0)   /* 0: HT NDP; 1: VHT NDP; HE no need */
#define C_BFI_BFRCTL_POS_NSTS_SHIFT      (1)   /* 0: 2ss; 1: 3ss; 2: 4ss */
#define C_BFI_BFRCTL_POS_MLBF_SHIFT      (4)   /* 1  enable MLBF(used for corerev < 64) */
#define C_BFI_BFRCTL_POS_BFM_SHIFT       (8)   /* Bits15-8: BFM mask for BFM frame tx */
 
/** dynamic rflo ucode WAR defines */
#define UCODE_WAR_EN        1
#define UCODE_WAR_DIS        0
 
/** LTE coex definitions */
#define LTECX_FLAGS_LPBK_OFF 0
 
/** LTECX shares BTCX shmem block */
#define M_LTECX_BLK_PTR(x)                M_BTCX_BLK_PTR(x)
 
/** NR5GCX shares BTCX shmem block */
#define M_NR5GCX_BLK_PTR(x)                M_BTCX_BLK_PTR(x)
 
/** RC1CX shares BTCX shmem block */
#define M_RC1CX_BLK_PTR(x)                M_BTCX_BLK_PTR(x)
 
/** RC2CX shares BTCX shmem block */
#define M_RC2CX_BLK_PTR(x)                M_BTCX_BLK_PTR(x)
 
/* CORE0 MODE */
#define CORE0_MODE_RSDB        0x0
#define CORE0_MODE_MIMO        0x1
#define CORE0_MODE_80P80    0x2
 
#define CORE1_MODE_RSDB        0x100
 
#define HWACI_HOST_FLAG_ADDR        (0x186)
#define HWACI_SET_SW_MITIGATION_MODE    (0x0008)
 
/* split RX war shm locations  */
#define RXFIFO_0_OFFSET 0x1A0
#define RXFIFO_1_OFFSET 0x19E
#define HDRCONV_FIFO0_STSLEN    0x4    /* status length in header conversion mode */
 
/* GE80:
 * [15:8]: Phy status length
 *  [7:0]: Ucode status length
 */
#define DEFAULT_FIFO0_STSLEN(corerev, corerev_minor) \
   (D11REV_MAJ_MIN_GE(corerev, corerev_minor, 87, 1) ? 0x2018 : \
   D11REV_GE(corerev, 80) ? 0x2010: 0x24)
 
/* M_ULP_WAKEIND bits */
#define    C_WATCHDOG_EXPIRY    (1 << 0)
#define    C_FCBS_ERROR        (1 << 1)
#define    C_RETX_FAILURE        (1 << 2)
#define    C_HOST_WAKEUP        (1 << 3)
#define    C_INVALID_FCBS_BLOCK    (1 << 4)
#define    C_HUDI_DS1_EXIT        (1 << 5)
#define    C_LOB_SLEEP        (1 << 6)
 
/* values for M_ULP_FEATURES */
#define C_P2P_NOA            (0x0001)
#define C_INFINITE_NOA            (0x0002)
#define C_P2P_CTWIN            (0x0004)
#define C_P2P_GC            (0x0008)
#define C_BCN_TRIM            (0x0010)
#define C_BT_COEX            (0x0020)
#define C_LTE_COEX            (0x0040)
#define C_ADS1                (0x0080)
#define C_LTECX_PSPOLL_PRIO_EN        (0x0100)
#define C_ULP_SLOWCAL_SKIP        (0x0200)
#define C_HUDI_ENABLE            (0x0400)
 
#define M_WOWL_ULP_SW_DAT_BLK    (0xBFF * 2)    /* (0xFFF * 2) - 1024 */
#define M_WOWL_ULP_SW_DAT_BLK_MAX_SZ    (0x400)    /* 1024 bytes */
 
#define RX_INTR_FIFO_0        0x1        /* FIFO-0 interrupt */
#define RX_INTR_FIFO_1        0x2        /* FIFO-1 interrupt */
#define RX_INTR_FIFO_2        0x4        /* FIFO-2 interrupt */
 
/* M_TOF_FLAG bits */
typedef enum {
   TOF_RX_FTM_NBIT = 0,
   TOF_SEQ_DISRXENTX_RFCTL = 1,
   TOF_IS_TARGET = 2,
   TOF_TPC_FREEZE = 3
} eTOFFlags;
 
/* TOF feature flags */
#define M_UCODE_F2_TOF_BIT    7 /* part of features_2 shm */
#define M_UCODE_F3_AVB_BIT    2 /* part of features_3 shm */
#define M_UCODE_F3_SEQ_BIT    3 /* part of features_3 shm */
 
/* New SHM definitions required for tsync based time stamping of FTM frames.
* More details in below conf
* http://confluence.broadcom.com/display/WLAN/NewUcodeInterfaceForProxdFeature
*/
#define FTM_TIMESTAMP_SHIFT        16
#define TXS_ACK_INDEX_SHIFT        3
#define FTM_ACK_TS_BLOCK_SIZE        3
#define RXH_ACK_SHIFT(corerev)    (D11REV_GE((corerev), 80) ? 12u:8u)
#define FTM_INVALID_SHM_INDEX(corerev)    (D11REV_GE((corerev), 80) ? 0x04u:0x0Fu)
#define FTM_ACK_INDEX_MASK        0x0F
#define NUM_UCODE_ACK_TS_BLKS        4
 
#define FTM_TXSTATUS_ACK_RSPEC_BLOCK_MASK    0xFF
#define FTM_TXSTATUS_ACK_RSPEC_BW_MASK        0x3
#define FTM_TXSTATUS_ACK_RSPEC_BW_SHIFT        2
#define FTM_TXSTATUS_ACK_RSPEC_BW_20        0
#define FTM_TXSTATUS_ACK_RSPEC_BW_40        1
#define FTM_TXSTATUS_ACK_RSPEC_BW_80        2
#define FTM_TXSTATUS_ACK_RSPEC_BW_160        3
#define FTM_TXSTATUS_ACK_RSPEC_TYPE_SHIFT    4
#define FTM_TXSTATUS_ACK_RSPEC_TYPE_MASK    0x7
#define FTM_TXSTATUS_ACK_RSPEC_TYPE_CCK        0
#define FTM_TXSTATUS_ACK_RSPEC_TYPE_LEG        1 /* Legacy */
#define FTM_TXSTATUS_ACK_RSPEC_TYPE_HT        2
#define FTM_TXSTATUS_ACK_RSPEC_TYPE_VHT        3
#define FTM_TXSTATUS_ACK_RSPEC_TYPE_HE        4
#define FTM_TXSTATUS_ACK_RSPEC_RATE_6M(ackword)    (ackword >> 7)
/* Following are the offsets in M_DRVR_UCODE_IF_PTR block. Start address of
 * M_DRVR_UCODE_IF_PTR block is present in M_DRVR_UCODE_IF_PTR.
 */
#define M_ULP_FEATURES            (0x0 * 2)
 
/* M_HOST_FLAGS5 offset changed in ULP ucode */
#define M_ULP_HOST_FLAGS5   (0x3d * 2)
 
#define M_RADAR_REG_TMP            (0x033 * 2)
 
/* Bit masks for ClkGateUcodeReq2: Ucode MAC Clock Request2 (IHR Address 0x375)  register */
#define D11_FUNC16_MAC_CLOCKREQ_MASK (0x3)
 
/*
 * Clock gating registers
 */
#define CLKREQ_BLOCK    0
#define CLKREQ_MAC_ILP    1
#define CLKREQ_MAC_ALP    2
#define CLKREQ_MAC_HT    3
 
/* ClkGateSts */
#define CLKGTE_FORCE_MAC_CLK_REQ_SHIFT            0
#define CLKGTE_MAC_PHY_CLK_REQ_SHIFT            4
 
/* ClkGateReqCtrl0 */
#define CLKGTE_PSM_PATCHCOPY_CLK_REQ_SHIFT        0
#define CLKGTE_RXKEEP_OCP_CLK_REQ_SHIFT            2
#define CLKGTE_PSM_MAC_CLK_REQ_SHIFT            4
#define CLKGTE_TSF_CLK_REQ_SHIFT            6
#define CLKGTE_AQM_CLK_REQ_SHIFT            8
#define CLKGTE_SERIAL_CLK_REQ_SHIFT            10
#define CLKGTE_TX_CLK_REQ_SHIFT                12
#define CLKGTE_POSTTX_CLK_REQ_SHIFT            14
 
/* ClkGateReqCtrl1 */
#define CLKGTE_RX_CLK_REQ_SHIFT                0
#define CLKGTE_TXKEEP_OCP_CLK_REQ_SHIFT            2
#define CLKGTE_HOST_RW_CLK_REQ_SHIFT            4
#define CLKGTE_IHR_WR_CLK_REQ_SHIFT            6
#define CLKGTE_TKIP_KEY_CLK_REQ_SHIFT            8
#define CLKGTE_TKIP_MISC_CLK_REQ_SHIFT            10
#define CLKGTE_AES_CLK_REQ_SHIFT            12
#define CLKGTE_WAPI_CLK_REQ_SHIFT            14
 
/* ClkGateReqCtrl2 */
#define CLKGTE_WEP_CLK_REQ_SHIFT            0
#define CLKGTE_PSM_CLK_REQ_SHIFT            2
#define CLKGTE_MACPHY_CLK_REQ_BY_PHY_SHIFT        4
#define CLKGTE_FCBS_CLK_REQ_SHIFT            6
#define CLKGTE_HIN_AXI_MAC_CLK_REQ_SHIFT        8
 
/* ClkGateStretch0 */
#define CLKGTE_MAC_HT_CLOCK_STRETCH_SHIFT        0
#define CLKGTE_MAC_ALP_CLOCK_STRETCH_SHIFT        8
#define CLKGTE_MAC_HT_CLOCK_STRETCH_VAL            0x4
 
/* ClkGateStretch1 */
#define CLKGTE_MAC_PHY_CLOCK_STRETCH_SHIFT        13
 
/* ClkGateMisc */
#define CLKGTE_TPF_CLK_REQTHRESH            0xF
#define CLKGTE_AQM_CLK_REQEXT                0x70
 
/* ClkGateDivCtrl */
#define CLKGTE_MAC_ILP_OFF_COUNT_MASK            0x0007
#define CLKGTE_MAC_ILP_OFF_COUNT_SHIFT            0
#define CLKGTE_MAC_ILP_ON_COUNT_MASK            0x0020
#define CLKGTE_MAC_ILP_ON_COUNT_MASK_GE_REV80        0x0030
#define CLKGTE_MAC_ALP_OFF_COUNT_MASK            0x03C0
#define CLKGTE_MAC_ALP_OFF_COUNT_SHIFT            6
 
/* ClkGatePhyClkCtrl */
#define CLKGTE_PHY_MAC_PHY_CLK_REQ_EN_SHIFT        0
#define CLKGTE_O2C_HIN_PHY_CLK_EN_SHIFT            1
#define CLKGTE_HIN_PHY_CLK_EN_SHIFT            2
#define CLKGTE_IHRP_PHY_CLK_EN_SHIFT            3
#define CLKGTE_CCA_MAC_PHY_CLK_REQ_EN_SHIFT        4
#define CLKGTE_TX_MAC_PHY_CLK_REQ_EN_SHIFT        5
#define CLKGTE_HRP_MAC_PHY_CLK_REQ_EN_SHIFT        6
#define CLKGTE_SYNC_MAC_PHY_CLK_REQ_EN_SHIFT        7
#define CLKGTE_RX_FRAME_MAC_PHY_CLK_REQ_EN_SHIFT    8
#define CLKGTE_RX_START_MAC_PHY_CLK_REQ_EN_SHIFT    9
#define CLKGTE_FCBS_MAC_PHY_CLK_REQ_SHIFT        10
#define CLKGTE_POSTRX_MAC_PHY_CLK_REQ_EN_SHIFT        11
#define CLKGTE_DOT11_MAC_PHY_RXVALID_SHIFT        12
#define CLKGTE_NOT_PHY_FIFO_EMPTY_SHIFT            13
#define CLKGTE_DOT11_MAC_PHY_BFE_REPORT_DATA_READY    14
#define CLKGTE_DOT11_MAC_PHY_CLK_BIT15            15
 
/* ClkGateExtReq0 */
#define CLKGTE_TOE_SYNC_MAC_CLK_REQ_SHIFT        0
#define CLKGTE_TXBF_SYNC_MAC_CLK_REQ_SHIFT        2
#define CLKGTE_HIN_SYNC_MAC_CLK_REQ_SHIFT        4
#define CLKGTE_SLOW_SYNC_CLK_REQ_SHIFT            6
#define CLKGTE_ERCX_SYNC_CLK_REQ_SHIFT            8
#define CLKGTE_BTCX_SYNC_CLK_REQ_SHIFT            10
#define CLKGTE_IFS_CRS_SYNC_CLK_REQ_SHIFT        12
#define CLKGTE_IFS_GCI_SYNC_CLK_REQ_SHIFT        14
 
#define CLKGTE_TOE_SYNC_MAC_CLK_REQ_80_SHIFT        2
#define CLKGTE_TXBF_SYNC_MAC_CLK_REQ_80_SHIFT        4
#define CLKGTE_HIN_SYNC_MAC_CLK_REQ_80_SHIFT        6
#define CLKGTE_SLOW_SYNC_CLK_REQ_80_SHIFT        8
#define CLKGTE_ERCX_SYNC_CLK_REQ_80_SHIFT        10
#define CLKGTE_BTCX_SYNC_CLK_REQ_80_SHIFT        12
#define CLKGTE_IFS_CRS_SYNC_CLK_REQ_80_SHIFT        14
 
#define CLKGTE_TOE_SYNC_MAC_CLK_REQ_83_SHIFT        2
#define CLKGTE_TXBF_SYNC_MAC_CLK_REQ_83_SHIFT        4
#define CLKGTE_HIN_SYNC_MAC_CLK_REQ_83_SHIFT        6
#define CLKGTE_SLOW_SYNC_CLK_REQ_83_SHIFT        8
#define CLKGTE_ERCX_SYNC_CLK_REQ_83_SHIFT        10
#define CLKGTE_BTCX2_SYNC_CLK_REQ_83_SHIFT        12
#define CLKGTE_BTCX_SYNC_CLK_REQ_83_SHIFT        14
 
/* ClkGateExtReq1 */
#define CLKGTE_PHY_FIFO_SYNC_CLK_REQ_SHIFT        0
#define CLKGTE_RXE_CHAN_SYNC_CLK_REQ_SHIFT        2
#define CLKGTE_PMU_MDIS_SYNC_MAC_CLK_REQ_SHIFT        4
#define CLKGTE_PSM_IPC_SYNC_CLK_REQ_SHIFT        6
 
#define CLKGTE_IFS_GCI_SYNC_CLK_REQ_80_SHIFT        0
#define CLKGTE_PHY_FIFO_SYNC_CLK_REQ_80_SHIFT        2
#define CLKGTE_RXE_CHAN_SYNC_CLK_REQ_80_SHIFT        4
#define CLKGTE_PMU_MDIS_SYNC_MAC_CLK_REQ_80_SHIFT    6
#define CLKGTE_PSM_IPC_SYNC_CLK_REQ_80_SHIFT        8
 
#define CLKGTE_IFS_CRS_SYNC_CLK_REQ_83_SHIFT        0
#define CLKGTE_IFS_GCI_SYNC_CLK_REQ_83_SHIFT        2
#define CLKGTE_PHY_FIFO_SYNC_CLK_REQ_83_SHIFT        4
#define CLKGTE_RXE_CHAN_SYNC_CLK_REQ_83_SHIFT        6
#define CLKGTE_PMU_MDIS_SYNC_MAC_CLK_REQ_83_SHIFT    8
#define CLKGTE_PSM_IPC_SYNC_CLK_REQ_83_SHIFT        10
 
/* PFE CtlStat1 register */
#define PFE_CTLSTAT1_ROUTE_PFE_TO_BMSTAT    (1u << 15u)
#define PFE_CTLSTAT1_PFE_ENABLE            (1u << 0u)
 
/* PPR Ctrl1 register */
#define PPR_CTMODE_SHIFT            8u
#define PPR_CTMODE_MASK                (3u << PPR_CTMODE_SHIFT)
 
#define PPR_CTMODE_A                (0u << PPR_CTMODE_SHIFT)
#define PPR_CTMODE_B                (1u << PPR_CTMODE_SHIFT)
#define PPR_CTMODE_C                (2u << PPR_CTMODE_SHIFT)
 
/* Ptxd Len */
#define PTXD_LEN0_SHIFT                (0u)
#define PTXD_LEN1_SHIFT                (8u)
#define PTXD_LEN2_SHIFT                (0u)
#define PTXD_LEN3_SHIFT                (8u)
/* =========== LHL regs =========== */
/* WL ARM Timer0 Interrupt Status (lhl_wl_armtim0_st_adr) */
#define LHL_WL_ARMTIM0_ST_WL_ARMTIM_INT_ST    0x00000001
 
#define D11_AUTO_MEM_STBY_RET_SHIFT        (4u)
#define D11_AUTO_MEM_STBY_RET_83_SHIFT        (5u)
#define D11_AUTO_MEM_STBY_NON_RET_SHIFT        (6u)
#define D11_AUTO_MEM_STBY_BM_SHIFT        (9u)
 
#define D11_AUTO_MEM_STBY_RET_SHIFT_REV(d11rev) \
   (((d11rev) >= 83) ? D11_AUTO_MEM_STBY_RET_83_SHIFT : D11_AUTO_MEM_STBY_RET_SHIFT)
 
/* WiFi P2P TX stop timestamp block (only applicable with AC ucode) */
#define P2P_TXSTOP_SHMPERBSS        2u    /* 2 shmems per BSS */
#define M_P2P_TXSTOP_TS(x, b, w)    (M_P2P_TXSTOP_T_BLK(x) +\
           (P2P_TXSTOP_SHMPERBSS * (b) + (w)) * 2)
 
#define D11TXHDR_RATEINFO_ACCESS_VAL(txh, corerev, member) \
   ((((txh)->corerev).RateInfo[3]).member)
 
/* QoS + BSR information */
#define D11_QOS_BSR_TIDQS_SHIFT    0u
#define D11_QOS_BSR_TIDQS_SZ    8u
#define D11_QOS_BSR_TIDQS_MASK    (((1 << D11_QOS_BSR_TIDQS_SZ) - 1) << D11_QOS_BSR_TIDQS_SHIFT)
 
#define D11_QOS_BSR_UV_SHIFT    8u
#define D11_QOS_BSR_UV_SZ    6u
#define D11_QOS_BSR_UV_MASK    (((1 << D11_QOS_BSR_UV_SZ) - 1) << D11_QOS_BSR_UV_SHIFT)
 
#define D11_QOS_BSR_SF_SHIFT    14u
#define D11_QOS_BSR_SF_SZ    2u
#define D11_QOS_BSR_SF_MASK    (((1 << D11_QOS_BSR_SF_SZ) - 1) << D11_QOS_BSR_SF_SHIFT)
 
/* Queue size in QoS control */
#define D11_QOS_BSR_SF_0    0u
#define D11_QOS_BSR_SF_1    1u
#define D11_QOS_BSR_SF_2    2u
#define D11_QOS_BSR_SF_3    3u
 
#define D11_QS_OFFSET_SF_0    0u
#define D11_QS_OFFSET_SF_1    1024u
#define D11_QS_OFFSET_SF_2    17408u
#define D11_QS_OFFSET_SF_3    148480u
 
#define D11_QOS_BSR_SF_0_SHIFT    4u    /* Scale: 16 bytes */
#define D11_QOS_BSR_SF_1_SHIFT    8u    /* Scale: 256 bytes */
#define D11_QOS_BSR_SF_2_SHIFT    11u    /* Scale: 2048 bytes */
#define D11_QOS_BSR_SF_3_SHIFT    15u    /* Scale: 32768 bytes */
 
#define D11_MIN_QS_UV        0u
#define D11_MAX_QS_UV        63u
#define D11_MAX_QS_UV_SF3    ((D11_MAX_QS_UV) - 1)
 
/* 1008: 16 * UV when the Scaling Factor subfield is 0 */
#define D11_MAX_QS_SF_0    (D11_QS_OFFSET_SF_0 + (D11_MAX_QS_UV << D11_QOS_BSR_SF_0_SHIFT))
/* 17152: 1024 + 256 * UV when the Scaling Factor subfield is 1 */
#define D11_MAX_QS_SF_1    (D11_QS_OFFSET_SF_1 + (D11_MAX_QS_UV << D11_QOS_BSR_SF_1_SHIFT))
/* 146432: 17408 + 2048 * UV when the Scaling Factor subfield is 2 */
#define D11_MAX_QS_SF_2    (D11_QS_OFFSET_SF_2 + (D11_MAX_QS_UV << D11_QOS_BSR_SF_2_SHIFT))
/* 2147328: 148480 + 32768 * UV when the Scaling Factor subfield is 3 */
#define D11_MAX_QS_SF_3    (D11_QS_OFFSET_SF_3 + ((D11_MAX_QS_UV_SF3-1) << D11_QOS_BSR_SF_3_SHIFT))
 
/* 2 bits for HE signature and 4 bits for control ID */
#define D11_BSR_HE_SIG_SHIFT        6u
/* HE Variant with BSR control ID */
#define D11_BSR_HE_SIG            (0xf)
#define D11_BSR_ACI_BMAP_SHIFT        (0 + D11_BSR_HE_SIG_SHIFT)
#define D11_BSR_DELTA_TID_SHIFT        (4 + D11_BSR_HE_SIG_SHIFT)
#define D11_BSR_SF_SHIFT        (8 + D11_BSR_HE_SIG_SHIFT)
#define D11_BSR_QUEUE_SIZE_HIGH_SHIFT    (10 + D11_BSR_HE_SIG_SHIFT)
#define D11_BSR_QUEUE_SIZE_ALL_SHIFT    (18 + D11_BSR_HE_SIG_SHIFT)
 
#define D11_BSR_DELTA_TID_ALLTID_SIGNATURE    3u
 
#define D11_BSR_QUEUE_SIZE_WIDTH    8u
#define D11_BSR_QUEUE_SIZE_WIDTH_VAL    ((1 << D11_BSR_QUEUE_SIZE_WIDTH) - 1)
#define D11_BSR_QUEUE_SIZE_UNKNOWN    (255u)
#define D11_BSR_QUEUE_SIZE_MAX        (254u)
#define D11_BSR_QUEUE_SIZE_HIGH_MASK        (D11_BSR_QUEUE_SIZE_WIDTH_VAL <<\
       D11_BSR_QUEUE_SIZE_HIGH_SHIFT)
#define D11_BSR_QUEUE_SIZE_ALL_MASK        (D11_BSR_QUEUE_SIZE_WIDTH_VAL <<\
       D11_BSR_QUEUE_SIZE_ALL_SHIFT)
 
#define D11_BSR_WD1_SHIFT            16u
 
enum {
   D11_BSR_SF_ID_16 = 0,    /* 0 */
   D11_BSR_SF_ID_256 = 1,    /* 1 */
   D11_BSR_SF_ID_2048 = 2,    /* 2 */
   D11_BSR_SF_ID_32768 = 3    /* 3 */
};
 
enum {
   D11_PING_BLOCK_VALID = 0,        /* 0 */
   D11_PONG_BLOCK_VALID = 1,        /* 1 */
   D11_UC_READING_PING_BLOCK = 2,    /* 2 */
   D11_UC_READING_PONG_BLOCK = 3    /* 3 */
};
 
enum {
   D11_BSR_TID0_POS = 0,    /* 0  */
   D11_BSR_TID1_POS = 1,    /* 1 */
   D11_BSR_TID2_POS = 2,    /* 2 */
   D11_BSR_TID3_POS = 3,    /* 3 */
   D11_BSR_TID4_POS = 4,    /* 4 */
   D11_BSR_TID5_POS = 5,    /* 5 */
   D11_BSR_TID6_POS = 6,    /* 6 */
   D11_BSR_TID7_POS = 7,    /* 7 */
   D11_BSR_WD0_POS = 8,    /* 8 */
   D11_BSR_WD1_POS = 9,    /* 9 */
};
 
#define D11_IS_PING_PONG_IN_RESET(i)    (((i) & ((1 << D11_PING_BLOCK_VALID) |\
   (1 << D11_UC_READING_PING_BLOCK) | (1 << D11_PONG_BLOCK_VALID) |\
   (1 << D11_UC_READING_PONG_BLOCK))) == 0)
#define D11_PING_BLOCK_VALID_MASK        ((1 << D11_PONG_BLOCK_VALID) |\
       (1 << D11_UC_READING_PING_BLOCK))
#define D11_PONG_BLOCK_VALID_MASK        ((1 << D11_PING_BLOCK_VALID) |\
       (1 << D11_UC_READING_PONG_BLOCK))
#define D11_PING_PONG_UPDATE_MASK        ((1 << D11_PING_BLOCK_VALID) |\
       (1 << D11_PONG_BLOCK_VALID))
#define D11_IS_PING_BLOCK_WRITABLE(i)    (((i) & D11_PING_BLOCK_VALID_MASK) == \
       (1 << D11_PONG_BLOCK_VALID))
#define D11_IS_PONG_BLOCK_WRITABLE(i)    (((i) & D11_PONG_BLOCK_VALID_MASK) == \
       (1 << D11_PING_BLOCK_VALID))
#define D11_SET_PING_BLOCK_VALID(i)        (((i) & ~(1 << D11_PONG_BLOCK_VALID)) |\
       (1 << D11_PING_BLOCK_VALID))
#define D11_SET_PONG_BLOCK_VALID(i)        (((i) & ~(1 << D11_PING_BLOCK_VALID)) |\
       (1 << D11_PONG_BLOCK_VALID))
#define D11_SET_PING_PONG_INVALID(i)        (((i) & ~(1 << D11_PING_BLOCK_VALID)) |\
       ((i) & ~(1 << D11_PONG_BLOCK_VALID)))
 
/* valid rx plcp check */
#define PLCP_VALID(plcp) (((plcp)[0] | (plcp)[1] | (plcp)[2]) != 0)
enum {
   D11_TXTRIG_EN = 0, /* 0 */
   D11_TXTRIG_PROG = 1, /* 1 */
   D11_TXTRIG_DONE = 2, /* 2 */
   D11_TXTRIG_TYPE = 4, /* 4 */
};
 
#define D11_SET_TXTRIG_EN    (1 << D11_TXTRIG_EN)
#define D11_TXTRIG_TYPE_MASK    ((1 << D11_TXTRIG_TYPE) | (1 << (D11_TXTRIG_TYPE+1)))
#define D11_SET_TXTRIG_TYPE(i)    (((i) << D11_TXTRIG_TYPE) & D11_TXTRIG_TYPE_MASK)
 
enum {
   D11_MUEDCA_AIFSN = 0, /* 0 */
   D11_MUEDCA_CWMIN = 1, /* 1 */
   D11_MUEDCA_CWMAX = 2, /* 2 */
   D11_MUEDCA_TIMER = 3, /* 3 */
   D11_MUEDCA_SU_AIFSN = 4, /* 4 */
   D11_MUEDCA_SU_CWMIN = 5, /* 5 */
   D11_MUEDCA_SU_CWMAX = 6,  /* 6 */
   D11_MUEDCA_EXPIRY_TSF = 7, /* 7 */
   D11_MUEDCA_QINFO = 8, /* 8 */
   D11_MUEDCA_STAT = 9, /* 9 */
   D11_MUEDCA_BLK_SIZE = 10 /* 10 */
};
#define D11_MUEDCA_BLK(x, idx, offset) (M_MUEDCA_BLK((x)) +\
   (idx * (D11_MUEDCA_BLK_SIZE << 1)) + (offset << 1))
 
#define D11_BSSCOLOR_VALID_SHIFT    15u
#define D11_BSSCOLOR_VALID_MASK        (1 << D11_BSSCOLOR_VALID_SHIFT)
 
#ifdef BCMPCIE_HP2P
/* HP2P (High Priority P2P) shared memory EDCA parameters */
typedef struct shm_hp2p_edca_params {
   uint16    txop;
   uint16    cwmin;
   uint16    cwmax;
   uint16    cwcur;
   uint16    aifs;
   uint16    bslots;
   uint16    reggap;
   uint16    status;
} shm_hp2p_edca_params_t;
 
#define HP2P_STATUS_NEWPARAMS    (1u << 8u)
#endif /* BCMPCIE_HP2P */
 
#define MAX_D11_GPIOS            16
 
/* Workaround register */
#define WAR_TXDMA_NONMODIFIABLE_EN    0x00000010 /* For TxDMA initiated AXI reads */
#define WAR_AQMDMA_NONMODIFIABLE_EN    0x00000020 /* For AQMDMA initiated AXI reads */
 
/* noise cal timeout when NAN is enabled.
* 54 * 256 = ~14ms .
* smallest NAN CRB possible is 16ms..choose 14ms
* as timeout to ensure noise cal happens within this 16ms
*/
#define M_NOISE_CALTIMEOUT_FOR_NAN            54u
 
#define TXPU_CMD_SET        1u /**< txpu set command */
 
#endif    /* _D11_H */