1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 4905 4906 4907 4908 4909 4910 4911 4912 4913 4914 4915 4916 4917 4918 4919 4920 4921 4922 4923 4924 4925 4926 4927 4928 4929 4930 4931 4932 4933 4934 4935 4936 4937 4938 4939 4940 4941 4942 4943 4944 4945 4946 4947 4948 4949 4950 4951 4952 4953 4954 4955 4956 4957 4958 4959 4960 4961 4962 4963 4964 4965 4966 4967 4968 4969 4970 4971 4972 4973 4974 4975 4976 4977 4978 4979 4980 4981 4982 4983 4984 4985 4986 4987 4988 4989 4990 4991 4992 4993 4994 4995 4996 4997 4998 4999 5000 5001 5002 5003 5004 5005 5006 5007 5008 5009 5010 5011 5012 5013 5014 5015 5016 5017 5018 5019 5020 5021 5022 5023 5024 5025 5026 5027 5028 5029 5030 5031 5032 5033 5034 5035 5036 5037 5038 5039 5040 5041 5042 5043 5044 5045 5046 5047 5048 5049 5050 5051 5052 5053 5054 5055 5056 5057 5058 5059 5060 5061 5062 5063 5064 5065 5066 5067 5068 5069 5070 5071 5072 5073 5074 5075 5076 5077 5078 5079 5080 5081 5082 5083 5084 5085 5086 5087 5088 5089 5090 5091 5092 5093 5094 5095 5096 5097 5098 5099 5100 5101 5102 5103 5104 5105 5106 5107 5108 5109 5110 5111 5112 5113 5114 5115 5116 5117 5118 5119 5120 5121 5122 5123 5124 5125 5126 5127 5128 5129 5130 5131 5132 5133 5134 5135 5136 5137 5138 5139 5140 5141 5142 5143 5144 5145 5146 5147 5148 5149 5150 5151 5152 5153 5154 5155 5156 5157 5158 5159 5160 5161 5162 5163 5164 5165 5166 5167 5168 5169 5170 5171 5172 5173 5174 5175 5176 5177 5178 5179 5180 5181 5182 5183 5184 5185 5186 5187 5188 5189 5190 5191 5192 5193 5194 5195 5196 5197 5198 5199 5200 5201 5202 5203 5204 5205 5206 5207 5208 5209 5210 5211 5212 5213 5214 5215 5216 5217 5218 5219 5220 5221 5222 5223 5224 5225 5226 5227 5228 5229 5230 5231 5232 5233 5234 5235 5236 5237 5238 5239 5240 5241 5242 5243 5244 5245 5246 5247 5248 5249 5250 5251 5252 5253 5254 5255 5256 5257 5258 5259 5260 5261 5262 5263 5264 5265 5266 5267 5268 5269 5270 5271 5272 5273 5274 5275 5276 5277 5278 5279 5280 5281 5282 5283 5284 5285 5286 5287 5288 5289 5290 5291 5292 5293 5294 5295 5296 5297 5298 5299 5300 5301 5302 5303 5304 5305 5306 5307 5308 5309 5310 5311 5312 5313 5314 5315 5316 5317 5318 5319 5320 5321 5322 5323 5324 5325 5326 5327 5328 5329 5330 5331 5332 5333 5334 5335 5336 5337 5338 5339 5340 5341 5342 5343 5344 5345 5346 5347 5348 5349 5350 5351 5352 5353 5354 5355 5356 5357 5358 5359 5360 5361 5362 5363 5364 5365 5366 5367 5368 5369 5370 5371 5372 5373 5374 5375 5376 5377 5378 5379 5380 5381 5382 5383 5384 5385 5386 5387 5388 5389 5390 5391 5392 5393 5394 5395 5396 5397 5398 5399 5400 5401 5402 5403 5404 5405 5406 5407 5408 5409 5410 5411 5412 5413 5414 5415 5416 5417 5418 5419 5420 5421 5422 5423 5424 5425 5426 5427 5428 5429 5430 5431 5432 5433 5434 5435 5436 5437 5438 5439 5440 5441 5442 5443 5444 5445 5446 5447 5448 5449 5450 5451 5452 5453 5454 5455 5456 5457 5458 5459 5460 5461 5462 5463 5464 5465 5466 5467 5468 5469 5470 5471 5472 5473 5474 5475 5476 5477 5478 5479 5480 5481 5482 5483 5484 5485 5486 5487 5488 5489 5490 5491 5492 5493 5494 5495 5496 5497 5498 5499 5500 5501 5502 5503 5504 5505 5506 5507 5508 5509 5510 5511 5512 5513 5514 5515 5516 5517 5518 5519 5520 5521 5522 5523 5524 5525 5526 5527 5528 5529 5530 5531 5532 5533 5534 5535 5536 5537 5538 5539 5540 5541 5542 5543 5544 5545 5546 5547 5548 5549 5550 5551 5552 5553 5554 5555 5556 5557 5558 5559 5560 5561 5562 5563 5564 5565 5566 5567 5568 5569 5570 5571 5572 5573 5574 5575 5576 5577 5578 5579 5580 5581 5582 5583 5584 5585 5586 5587 5588 5589 5590 5591 5592 5593 5594 5595 5596 5597 5598 5599 5600 5601 5602 5603 5604 5605 5606 5607 5608 5609 5610 5611 5612 5613 5614 5615 5616 5617 5618 5619 5620 5621 5622 5623 5624 5625 5626 5627 5628 5629 5630 5631 5632 5633 5634 5635 5636 5637 5638 5639 5640 5641 5642 5643 5644 5645 5646 5647 5648 5649 5650 5651 5652 5653 5654 5655 5656 5657 5658 5659 5660 5661 5662 5663 5664 5665 5666 5667 5668 5669 5670 5671 5672 5673 5674 5675 5676 5677 5678 5679 5680 5681 5682 5683 5684 5685 5686 5687 5688 5689 5690 5691 5692 5693 5694 5695 5696 5697 5698 5699 5700 5701 5702 5703 5704 5705 5706 5707 5708 5709 5710 5711 5712 5713 5714 5715 5716 5717 5718 5719 5720 5721 5722 5723 5724 5725 5726 5727 5728 5729 5730 5731 5732 5733 5734 5735 5736 5737 5738 5739 5740 5741 5742 5743 5744 5745 5746 5747 5748 5749 5750 5751 5752 5753 5754 5755 5756 5757 5758 5759 5760 5761 5762 5763 5764 5765 5766 5767 5768 5769 5770 5771 5772 5773 5774 5775 5776 5777 5778 5779 5780 5781 5782 5783 5784 5785 5786 5787 5788 5789 5790 5791 5792 5793 5794 5795 5796 5797 5798 5799 5800 5801 5802 5803 5804 5805 5806 5807 5808 5809 5810 5811 5812 5813 5814 5815 5816 5817 5818 5819 5820 5821 5822 5823 5824 5825 5826 5827 5828 5829 5830 5831 5832 5833 5834 5835 5836 5837 5838 5839 5840 5841 5842 5843 5844 5845 5846 5847 5848 5849 5850 5851 5852 5853 5854 5855 5856 5857 5858 5859 5860 5861 5862 5863 5864 5865 5866 5867 5868 5869 5870 5871 5872 5873 5874 5875 5876 5877 5878 5879 5880 5881 5882 5883 5884 5885 5886 5887 5888 5889 5890 5891 5892 5893 5894 5895 5896 5897 5898 5899 5900 5901 5902 5903 5904 5905 5906 5907 5908 5909 5910 5911 5912 5913 5914 5915 5916 5917 5918 5919 5920 5921 5922 5923 5924 5925 5926 5927 5928 5929 5930 5931 5932 5933 5934 5935 5936 5937 5938 5939 5940 5941 5942 5943 5944 5945 5946 5947 5948 5949 5950 5951 5952 5953 5954 5955 5956 5957 5958 5959 5960 5961 5962 5963 5964 5965 5966 5967 5968 5969 5970 5971 5972 5973 5974 5975 5976 5977 5978 5979 5980 5981 5982 5983 5984 5985 5986 5987 5988 5989 5990 5991 5992 5993 5994 5995 5996 5997 5998 5999 6000 6001 6002 6003 6004 6005 6006 6007 6008 6009 6010 6011 6012 6013 6014 6015 6016 6017 6018 6019 6020 6021 6022 6023 6024 6025 6026 6027 6028 6029 6030 6031 6032 6033 6034 6035 6036 6037 6038 6039 6040 6041 6042 6043 6044 6045 6046 6047 6048 6049 6050 6051 6052 6053 6054 6055 6056 6057 6058 6059 6060 6061 6062 6063 6064 6065 6066 6067 6068 6069 6070 6071 6072 6073 6074 6075 6076 6077 6078 6079 6080 6081 6082 6083 6084 6085 6086 6087 6088 6089 6090 6091 6092 6093 6094 6095 6096 6097 6098 6099 6100 6101 6102 6103 6104 6105 6106 6107 6108 6109 6110 6111 6112 6113 6114 6115 6116 6117 6118 6119 6120 6121 6122 6123 6124 6125 6126 6127 6128 6129 6130 6131 6132 6133 6134 6135 6136 6137 6138 6139 6140 6141 6142 6143 6144 6145 6146 6147 6148 6149 6150 6151 6152 6153 6154 6155 6156 6157 6158 6159 6160 6161 6162 6163 6164 6165 6166 6167 6168 6169 6170 6171 6172 6173 6174 6175 6176 6177 6178 6179 6180 6181 6182 6183 6184 6185 6186 6187 6188 6189 6190 6191 6192 6193 6194 6195 6196 6197 6198 6199 6200 6201 6202 6203 6204 6205 6206 6207 6208 6209 6210 6211 6212 6213 6214 6215 6216 6217 6218 6219 6220 6221 6222 6223 6224 6225 6226 6227 6228 6229 6230 6231 6232 6233 6234 6235 6236 6237 6238 6239 6240 6241 6242 6243 6244 6245 6246 6247 6248 6249 6250 6251 6252 6253 6254 6255 6256 6257 6258 6259 6260 6261 6262 6263 6264 6265 6266 6267 6268 6269 6270 6271 6272 6273 6274 6275 6276 6277 6278 6279 6280 6281 6282 6283 6284 6285 6286 6287 6288 6289 6290 6291 6292 6293 6294 6295 6296 6297 6298 6299 6300 6301 6302 6303 6304 6305 6306 6307 6308 6309 6310 6311 6312 6313 6314 6315 6316 6317 6318 6319 6320 6321 6322 6323 6324 6325 6326 6327 6328 6329 6330 6331 6332 6333 6334 6335 6336 6337 6338 6339 6340 6341 6342 6343 6344 6345 6346 6347 6348 6349 6350 6351 6352 6353 6354 6355 6356 6357 6358 6359 6360 6361 6362 6363 6364 6365 6366 6367 6368 6369 6370 6371 6372 6373 6374 6375 6376 6377 6378 6379 6380 6381 6382 6383 6384 6385 6386 6387 6388 6389 6390 6391 6392 6393 6394 6395 6396 6397 6398 6399 6400 6401 6402 6403 6404 6405 6406 6407 6408 6409 6410 6411 6412 6413 6414 6415 6416 6417 6418 6419 6420 6421 6422 6423 6424 6425 6426 6427 6428 6429 6430 6431 6432 6433 6434 6435 6436 6437 6438 6439 6440 6441 6442 6443 6444 6445 6446 6447 6448 6449 6450 6451 6452 6453 6454 6455 6456 6457 6458 6459 6460 6461 6462 6463 6464 6465 6466 6467 6468 6469 6470 6471 6472 6473 6474 6475 6476 6477 6478 6479 6480 6481 6482 6483 6484 6485 6486 6487 6488 6489 6490 6491 6492 6493 6494 6495 6496 6497 6498 6499 6500 6501 6502 6503 6504 6505 6506 6507 6508 6509 6510 6511 6512 6513 6514 6515 6516 6517 6518 6519 6520 6521 6522 6523 6524 6525 6526 6527 6528 6529 6530 6531 6532 6533 6534 6535 6536 6537 6538 6539 6540 6541 6542 6543 6544 6545 6546 6547 6548 6549 6550 6551 6552 6553 6554 6555 6556 6557 6558 6559 6560 6561 6562 6563 6564 6565 6566 6567 6568 6569 6570 6571 6572 6573 6574 6575 6576 6577 6578 6579 6580 6581 6582 6583 6584 6585 6586 6587 6588 6589 6590 6591 6592 6593 6594 6595 6596 6597 6598 6599 6600 6601 6602 6603 6604 6605 6606 6607 6608 6609 6610 6611 6612 6613 6614 6615 6616 6617 6618 6619 6620 6621 6622 6623 6624 6625 6626 6627 6628 6629 6630 6631 6632 6633 6634 6635 6636 6637 6638 6639 6640 6641 6642 6643 6644 6645 6646 6647 6648 6649 6650 6651 6652 6653 6654 6655 6656 6657 6658 6659 6660 6661 6662 6663 6664 6665 6666 6667 6668 6669 6670 6671 6672 6673 6674 6675 6676 6677 6678 6679 6680 6681 6682 6683 6684 6685 6686 6687 6688 6689 6690 6691 6692 6693 6694 6695 6696 6697 6698 6699 6700 6701 6702 6703 6704 6705 6706 6707 6708 6709 6710 6711 6712 6713 6714 6715 6716 6717 6718 6719 6720 6721 6722 6723 6724 6725 6726 6727 6728 6729 6730 6731 6732 6733 6734 6735 6736 6737 6738 6739 6740 6741 6742 6743 6744 6745 6746 6747 6748 6749 6750 6751 6752 6753 6754 6755 6756 6757 6758 6759 6760 6761 6762 6763 6764 6765 6766 6767 6768 6769 6770 6771 6772 6773 6774 6775 6776 6777 6778 6779 6780 6781 6782 6783 6784 6785 6786 6787 6788 6789 6790 6791 6792 6793 6794 6795 6796 6797 6798 6799 6800 6801 6802 6803 6804 6805 6806 6807 6808 6809 6810 6811 6812 6813 6814 6815 6816 6817 6818 6819 6820 6821 6822 6823 6824 6825 6826 6827 6828 6829 6830 6831 6832 6833 6834 6835 6836 6837 6838 6839 6840 6841 6842 6843 6844 6845 6846 6847 6848 6849 6850 6851 6852 6853 6854 6855 6856 6857 6858 6859 6860 6861 6862 6863 6864 6865 6866 6867 6868 6869 6870 6871 6872 6873 6874 6875 6876 6877 6878 6879 6880 6881 6882 6883 6884 6885 6886 6887 6888 6889 6890 6891 6892 6893 6894 6895 6896 6897 6898 6899 6900 6901 6902 6903 6904 6905 6906 6907 6908 6909 6910 6911 6912 6913 6914 6915 6916 6917 6918 6919 6920 6921 6922 6923 6924 6925 6926 6927 6928 6929 6930 6931 6932 6933 6934 6935 6936 6937 6938 6939 6940 6941 6942 6943 6944 6945 6946 6947 6948 6949 6950 6951 6952 6953 6954 6955 6956 6957 6958 6959 6960 6961 6962 6963 6964 6965 6966 6967 6968 6969 6970 6971 6972 6973 6974 6975 6976 6977 6978 6979 6980 6981 6982 6983 6984 6985 6986 6987 6988 6989 6990 6991 6992 6993 6994 6995 6996 6997 6998 6999 7000 7001 7002 7003 7004 7005 7006 7007 7008 7009 7010 7011 7012 7013 7014 7015 7016 7017 7018 7019 7020 7021 7022 7023 7024 7025 7026 7027 7028 7029 7030 7031 7032 7033 7034 7035 7036 7037 7038 7039 7040 7041 7042 7043 7044 7045 7046 7047 7048 7049 7050 7051 7052 7053 7054 7055 7056 7057 7058 7059 7060 7061 7062 7063 7064 7065 7066 7067 7068 7069 7070 7071 7072 7073 7074 7075 7076 7077 7078 7079 7080 7081 7082 7083 7084 7085 7086 7087 7088 7089 7090 7091 7092 7093 7094 7095 7096 7097 7098 7099 7100 7101 7102 7103 7104 7105 7106 7107 7108 7109 7110 7111 7112 7113 7114 7115 7116 7117 7118 7119 7120 7121 7122 7123 7124 7125 7126 7127 7128 7129 7130 7131 7132 7133 7134 7135 7136 7137 7138 7139 7140 7141 7142 7143 7144 7145 7146 7147 7148 7149 7150 7151 7152 7153 7154 7155 7156 7157 7158 7159 7160 7161 7162 7163 7164 7165 7166 7167 7168 7169 7170 7171 7172 7173 7174 7175 7176 7177 7178 7179 7180 7181 7182 7183 7184 7185 7186 7187 7188 7189 7190 7191 7192 7193 7194 7195 7196 7197 7198 7199 7200 7201 7202 7203 7204 7205 7206 7207 7208 7209 7210 7211 7212 7213 7214 7215 7216 7217 7218 7219 7220 7221 7222 7223 7224 7225 7226 7227 7228 7229 7230 7231 7232 7233 7234 7235 7236 7237 7238 7239 7240 7241 7242 7243 7244 7245 7246 7247 7248 7249 7250 7251 7252 7253 7254 7255 7256 7257 7258 7259 7260 7261 7262 7263 7264 7265 7266 7267 7268 7269 7270 7271 7272 7273 7274 7275 7276 7277 7278 7279 7280 7281 7282 7283 7284 7285 7286 7287 7288 7289 7290 7291 7292 7293 7294 7295 7296 7297 7298 7299 7300 7301 7302 7303 7304 7305 7306 7307 7308 7309 7310 7311 7312 7313 7314 7315 7316 7317 7318 7319 7320 7321 7322 7323 7324 7325 7326 7327 7328 7329 7330 7331 7332 7333 7334 7335 7336
|
/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
/* Copyright(c) 2019-2020 Realtek Corporation
*/
#ifndef __RTW89_CORE_H__
#define __RTW89_CORE_H__
#include <linux/average.h>
#include <linux/bitfield.h>
#include <linux/dmi.h>
#include <linux/firmware.h>
#include <linux/iopoll.h>
#include <linux/workqueue.h>
#include <net/mac80211.h>
struct rtw89_dev;
struct rtw89_pci_info;
struct rtw89_mac_gen_def;
struct rtw89_phy_gen_def;
struct rtw89_fw_blacklist;
struct rtw89_efuse_block_cfg;
struct rtw89_h2c_rf_tssi;
struct rtw89_fw_txpwr_track_cfg;
struct rtw89_phy_rfk_log_fmt;
struct rtw89_debugfs;
struct rtw89_regd_data;
extern const struct ieee80211_ops rtw89_ops;
#define MASKBYTE0 0xff
#define MASKBYTE1 0xff00
#define MASKBYTE2 0xff0000
#define MASKBYTE3 0xff000000
#define MASKBYTE4 0xff00000000ULL
#define MASKHWORD 0xffff0000
#define MASKLWORD 0x0000ffff
#define MASKDWORD 0xffffffff
#define RFREG_MASK 0xfffff
#define INV_RF_DATA 0xffffffff
#define BYPASS_CR_DATA 0xbabecafe
#define RTW89_TRACK_WORK_PERIOD round_jiffies_relative(HZ * 2)
#define RTW89_FORBID_BA_TIMER round_jiffies_relative(HZ * 4)
#define CFO_TRACK_MAX_USER 64
#define MAX_RSSI 110
#define RSSI_FACTOR 1
#define RTW89_RSSI_RAW_TO_DBM(rssi) ((s8)((rssi) >> RSSI_FACTOR) - MAX_RSSI)
#define RTW89_TX_DIV_RSSI_RAW_TH (2 << RSSI_FACTOR)
#define DELTA_SWINGIDX_SIZE 30
#define RTW89_RADIOTAP_ROOM_HE sizeof(struct ieee80211_radiotap_he)
#define RTW89_RADIOTAP_ROOM_EHT \
(sizeof(struct ieee80211_radiotap_tlv) + \
ALIGN(struct_size((struct ieee80211_radiotap_eht *)0, user_info, 1), 4) + \
sizeof(struct ieee80211_radiotap_tlv) + \
ALIGN(sizeof(struct ieee80211_radiotap_eht_usig), 4))
#define RTW89_RADIOTAP_ROOM \
ALIGN(max(RTW89_RADIOTAP_ROOM_HE, RTW89_RADIOTAP_ROOM_EHT), 64)
#define RTW89_HTC_MASK_VARIANT GENMASK(1, 0)
#define RTW89_HTC_VARIANT_HE 3
#define RTW89_HTC_MASK_CTL_ID GENMASK(5, 2)
#define RTW89_HTC_VARIANT_HE_CID_OM 1
#define RTW89_HTC_VARIANT_HE_CID_CAS 6
#define RTW89_HTC_MASK_CTL_INFO GENMASK(31, 6)
#define RTW89_HTC_MASK_HTC_OM_RX_NSS GENMASK(8, 6)
enum htc_om_channel_width {
HTC_OM_CHANNEL_WIDTH_20 = 0,
HTC_OM_CHANNEL_WIDTH_40 = 1,
HTC_OM_CHANNEL_WIDTH_80 = 2,
HTC_OM_CHANNEL_WIDTH_160_OR_80_80 = 3,
};
#define RTW89_HTC_MASK_HTC_OM_CH_WIDTH GENMASK(10, 9)
#define RTW89_HTC_MASK_HTC_OM_UL_MU_DIS BIT(11)
#define RTW89_HTC_MASK_HTC_OM_TX_NSTS GENMASK(14, 12)
#define RTW89_HTC_MASK_HTC_OM_ER_SU_DIS BIT(15)
#define RTW89_HTC_MASK_HTC_OM_DL_MU_MIMO_RR BIT(16)
#define RTW89_HTC_MASK_HTC_OM_UL_MU_DATA_DIS BIT(17)
#define RTW89_TF_PAD GENMASK(11, 0)
#define RTW89_TF_BASIC_USER_INFO_SZ 6
#define RTW89_GET_TF_USER_INFO_AID12(data) \
le32_get_bits(*((const __le32 *)(data)), GENMASK(11, 0))
#define RTW89_GET_TF_USER_INFO_RUA(data) \
le32_get_bits(*((const __le32 *)(data)), GENMASK(19, 12))
#define RTW89_GET_TF_USER_INFO_UL_MCS(data) \
le32_get_bits(*((const __le32 *)(data)), GENMASK(24, 21))
enum rtw89_subband {
RTW89_CH_2G = 0,
RTW89_CH_5G_BAND_1 = 1,
/* RTW89_CH_5G_BAND_2 = 2, unused */
RTW89_CH_5G_BAND_3 = 3,
RTW89_CH_5G_BAND_4 = 4,
RTW89_CH_6G_BAND_IDX0, /* Low */
RTW89_CH_6G_BAND_IDX1, /* Low */
RTW89_CH_6G_BAND_IDX2, /* Mid */
RTW89_CH_6G_BAND_IDX3, /* Mid */
RTW89_CH_6G_BAND_IDX4, /* High */
RTW89_CH_6G_BAND_IDX5, /* High */
RTW89_CH_6G_BAND_IDX6, /* Ultra-high */
RTW89_CH_6G_BAND_IDX7, /* Ultra-high */
RTW89_SUBBAND_NR,
RTW89_SUBBAND_2GHZ_5GHZ_NR = RTW89_CH_5G_BAND_4 + 1,
};
enum rtw89_gain_offset {
RTW89_GAIN_OFFSET_2G_CCK,
RTW89_GAIN_OFFSET_2G_OFDM,
RTW89_GAIN_OFFSET_5G_LOW,
RTW89_GAIN_OFFSET_5G_MID,
RTW89_GAIN_OFFSET_5G_HIGH,
RTW89_GAIN_OFFSET_6G_L0,
RTW89_GAIN_OFFSET_6G_L1,
RTW89_GAIN_OFFSET_6G_M0,
RTW89_GAIN_OFFSET_6G_M1,
RTW89_GAIN_OFFSET_6G_H0,
RTW89_GAIN_OFFSET_6G_H1,
RTW89_GAIN_OFFSET_6G_UH0,
RTW89_GAIN_OFFSET_6G_UH1,
RTW89_GAIN_OFFSET_NR,
};
enum rtw89_hci_type {
RTW89_HCI_TYPE_PCIE,
RTW89_HCI_TYPE_USB,
RTW89_HCI_TYPE_SDIO,
};
enum rtw89_core_chip_id {
RTL8852A,
RTL8852B,
RTL8852BT,
RTL8852C,
RTL8851B,
RTL8922A,
};
enum rtw89_chip_gen {
RTW89_CHIP_AX,
RTW89_CHIP_BE,
RTW89_CHIP_GEN_NUM,
};
enum rtw89_cv {
CHIP_CAV,
CHIP_CBV,
CHIP_CCV,
CHIP_CDV,
CHIP_CEV,
CHIP_CFV,
CHIP_CV_MAX,
CHIP_CV_INVALID = CHIP_CV_MAX,
};
enum rtw89_bacam_ver {
RTW89_BACAM_V0,
RTW89_BACAM_V1,
RTW89_BACAM_V0_EXT = 99,
};
enum rtw89_core_tx_type {
RTW89_CORE_TX_TYPE_DATA,
RTW89_CORE_TX_TYPE_MGMT,
RTW89_CORE_TX_TYPE_FWCMD,
};
enum rtw89_core_rx_type {
RTW89_CORE_RX_TYPE_WIFI = 0,
RTW89_CORE_RX_TYPE_PPDU_STAT = 1,
RTW89_CORE_RX_TYPE_CHAN_INFO = 2,
RTW89_CORE_RX_TYPE_BB_SCOPE = 3,
RTW89_CORE_RX_TYPE_F2P_TXCMD = 4,
RTW89_CORE_RX_TYPE_SS2FW = 5,
RTW89_CORE_RX_TYPE_TX_REPORT = 6,
RTW89_CORE_RX_TYPE_TX_REL_HOST = 7,
RTW89_CORE_RX_TYPE_DFS_REPORT = 8,
RTW89_CORE_RX_TYPE_TX_REL_CPU = 9,
RTW89_CORE_RX_TYPE_C2H = 10,
RTW89_CORE_RX_TYPE_CSI = 11,
RTW89_CORE_RX_TYPE_CQI = 12,
RTW89_CORE_RX_TYPE_H2C = 13,
RTW89_CORE_RX_TYPE_FWDL = 14,
};
enum rtw89_txq_flags {
RTW89_TXQ_F_AMPDU = 0,
RTW89_TXQ_F_BLOCK_BA = 1,
RTW89_TXQ_F_FORBID_BA = 2,
};
enum rtw89_net_type {
RTW89_NET_TYPE_NO_LINK = 0,
RTW89_NET_TYPE_AD_HOC = 1,
RTW89_NET_TYPE_INFRA = 2,
RTW89_NET_TYPE_AP_MODE = 3,
};
enum rtw89_wifi_role {
RTW89_WIFI_ROLE_NONE,
RTW89_WIFI_ROLE_STATION,
RTW89_WIFI_ROLE_AP,
RTW89_WIFI_ROLE_AP_VLAN,
RTW89_WIFI_ROLE_ADHOC,
RTW89_WIFI_ROLE_ADHOC_MASTER,
RTW89_WIFI_ROLE_MESH_POINT,
RTW89_WIFI_ROLE_MONITOR,
RTW89_WIFI_ROLE_P2P_DEVICE,
RTW89_WIFI_ROLE_P2P_CLIENT,
RTW89_WIFI_ROLE_P2P_GO,
RTW89_WIFI_ROLE_NAN,
RTW89_WIFI_ROLE_MLME_MAX
};
enum rtw89_upd_mode {
RTW89_ROLE_CREATE,
RTW89_ROLE_REMOVE,
RTW89_ROLE_TYPE_CHANGE,
RTW89_ROLE_INFO_CHANGE,
RTW89_ROLE_CON_DISCONN,
RTW89_ROLE_BAND_SW,
RTW89_ROLE_FW_RESTORE,
};
enum rtw89_self_role {
RTW89_SELF_ROLE_CLIENT,
RTW89_SELF_ROLE_AP,
RTW89_SELF_ROLE_AP_CLIENT
};
enum rtw89_msk_sO_el {
RTW89_NO_MSK,
RTW89_SMA,
RTW89_TMA,
RTW89_BSSID
};
enum rtw89_sch_tx_sel {
RTW89_SCH_TX_SEL_ALL,
RTW89_SCH_TX_SEL_HIQ,
RTW89_SCH_TX_SEL_MG0,
RTW89_SCH_TX_SEL_MACID,
};
/* RTW89_ADDR_CAM_SEC_NONE : not enabled
* RTW89_ADDR_CAM_SEC_ALL_UNI : 0 - 6 unicast
* RTW89_ADDR_CAM_SEC_NORMAL : 0 - 1 unicast, 2 - 4 group, 5 - 6 BIP
* RTW89_ADDR_CAM_SEC_4GROUP : 0 - 1 unicast, 2 - 5 group, 6 BIP
*/
enum rtw89_add_cam_sec_mode {
RTW89_ADDR_CAM_SEC_NONE = 0,
RTW89_ADDR_CAM_SEC_ALL_UNI = 1,
RTW89_ADDR_CAM_SEC_NORMAL = 2,
RTW89_ADDR_CAM_SEC_4GROUP = 3,
};
enum rtw89_sec_key_type {
RTW89_SEC_KEY_TYPE_NONE = 0,
RTW89_SEC_KEY_TYPE_WEP40 = 1,
RTW89_SEC_KEY_TYPE_WEP104 = 2,
RTW89_SEC_KEY_TYPE_TKIP = 3,
RTW89_SEC_KEY_TYPE_WAPI = 4,
RTW89_SEC_KEY_TYPE_GCMSMS4 = 5,
RTW89_SEC_KEY_TYPE_CCMP128 = 6,
RTW89_SEC_KEY_TYPE_CCMP256 = 7,
RTW89_SEC_KEY_TYPE_GCMP128 = 8,
RTW89_SEC_KEY_TYPE_GCMP256 = 9,
RTW89_SEC_KEY_TYPE_BIP_CCMP128 = 10,
};
enum rtw89_port {
RTW89_PORT_0 = 0,
RTW89_PORT_1 = 1,
RTW89_PORT_2 = 2,
RTW89_PORT_3 = 3,
RTW89_PORT_4 = 4,
RTW89_PORT_NUM
};
enum rtw89_band {
RTW89_BAND_2G = 0,
RTW89_BAND_5G = 1,
RTW89_BAND_6G = 2,
RTW89_BAND_NUM,
};
enum rtw89_hw_rate {
RTW89_HW_RATE_CCK1 = 0x0,
RTW89_HW_RATE_CCK2 = 0x1,
RTW89_HW_RATE_CCK5_5 = 0x2,
RTW89_HW_RATE_CCK11 = 0x3,
RTW89_HW_RATE_OFDM6 = 0x4,
RTW89_HW_RATE_OFDM9 = 0x5,
RTW89_HW_RATE_OFDM12 = 0x6,
RTW89_HW_RATE_OFDM18 = 0x7,
RTW89_HW_RATE_OFDM24 = 0x8,
RTW89_HW_RATE_OFDM36 = 0x9,
RTW89_HW_RATE_OFDM48 = 0xA,
RTW89_HW_RATE_OFDM54 = 0xB,
RTW89_HW_RATE_MCS0 = 0x80,
RTW89_HW_RATE_MCS1 = 0x81,
RTW89_HW_RATE_MCS2 = 0x82,
RTW89_HW_RATE_MCS3 = 0x83,
RTW89_HW_RATE_MCS4 = 0x84,
RTW89_HW_RATE_MCS5 = 0x85,
RTW89_HW_RATE_MCS6 = 0x86,
RTW89_HW_RATE_MCS7 = 0x87,
RTW89_HW_RATE_MCS8 = 0x88,
RTW89_HW_RATE_MCS9 = 0x89,
RTW89_HW_RATE_MCS10 = 0x8A,
RTW89_HW_RATE_MCS11 = 0x8B,
RTW89_HW_RATE_MCS12 = 0x8C,
RTW89_HW_RATE_MCS13 = 0x8D,
RTW89_HW_RATE_MCS14 = 0x8E,
RTW89_HW_RATE_MCS15 = 0x8F,
RTW89_HW_RATE_MCS16 = 0x90,
RTW89_HW_RATE_MCS17 = 0x91,
RTW89_HW_RATE_MCS18 = 0x92,
RTW89_HW_RATE_MCS19 = 0x93,
RTW89_HW_RATE_MCS20 = 0x94,
RTW89_HW_RATE_MCS21 = 0x95,
RTW89_HW_RATE_MCS22 = 0x96,
RTW89_HW_RATE_MCS23 = 0x97,
RTW89_HW_RATE_MCS24 = 0x98,
RTW89_HW_RATE_MCS25 = 0x99,
RTW89_HW_RATE_MCS26 = 0x9A,
RTW89_HW_RATE_MCS27 = 0x9B,
RTW89_HW_RATE_MCS28 = 0x9C,
RTW89_HW_RATE_MCS29 = 0x9D,
RTW89_HW_RATE_MCS30 = 0x9E,
RTW89_HW_RATE_MCS31 = 0x9F,
RTW89_HW_RATE_VHT_NSS1_MCS0 = 0x100,
RTW89_HW_RATE_VHT_NSS1_MCS1 = 0x101,
RTW89_HW_RATE_VHT_NSS1_MCS2 = 0x102,
RTW89_HW_RATE_VHT_NSS1_MCS3 = 0x103,
RTW89_HW_RATE_VHT_NSS1_MCS4 = 0x104,
RTW89_HW_RATE_VHT_NSS1_MCS5 = 0x105,
RTW89_HW_RATE_VHT_NSS1_MCS6 = 0x106,
RTW89_HW_RATE_VHT_NSS1_MCS7 = 0x107,
RTW89_HW_RATE_VHT_NSS1_MCS8 = 0x108,
RTW89_HW_RATE_VHT_NSS1_MCS9 = 0x109,
RTW89_HW_RATE_VHT_NSS2_MCS0 = 0x110,
RTW89_HW_RATE_VHT_NSS2_MCS1 = 0x111,
RTW89_HW_RATE_VHT_NSS2_MCS2 = 0x112,
RTW89_HW_RATE_VHT_NSS2_MCS3 = 0x113,
RTW89_HW_RATE_VHT_NSS2_MCS4 = 0x114,
RTW89_HW_RATE_VHT_NSS2_MCS5 = 0x115,
RTW89_HW_RATE_VHT_NSS2_MCS6 = 0x116,
RTW89_HW_RATE_VHT_NSS2_MCS7 = 0x117,
RTW89_HW_RATE_VHT_NSS2_MCS8 = 0x118,
RTW89_HW_RATE_VHT_NSS2_MCS9 = 0x119,
RTW89_HW_RATE_VHT_NSS3_MCS0 = 0x120,
RTW89_HW_RATE_VHT_NSS3_MCS1 = 0x121,
RTW89_HW_RATE_VHT_NSS3_MCS2 = 0x122,
RTW89_HW_RATE_VHT_NSS3_MCS3 = 0x123,
RTW89_HW_RATE_VHT_NSS3_MCS4 = 0x124,
RTW89_HW_RATE_VHT_NSS3_MCS5 = 0x125,
RTW89_HW_RATE_VHT_NSS3_MCS6 = 0x126,
RTW89_HW_RATE_VHT_NSS3_MCS7 = 0x127,
RTW89_HW_RATE_VHT_NSS3_MCS8 = 0x128,
RTW89_HW_RATE_VHT_NSS3_MCS9 = 0x129,
RTW89_HW_RATE_VHT_NSS4_MCS0 = 0x130,
RTW89_HW_RATE_VHT_NSS4_MCS1 = 0x131,
RTW89_HW_RATE_VHT_NSS4_MCS2 = 0x132,
RTW89_HW_RATE_VHT_NSS4_MCS3 = 0x133,
RTW89_HW_RATE_VHT_NSS4_MCS4 = 0x134,
RTW89_HW_RATE_VHT_NSS4_MCS5 = 0x135,
RTW89_HW_RATE_VHT_NSS4_MCS6 = 0x136,
RTW89_HW_RATE_VHT_NSS4_MCS7 = 0x137,
RTW89_HW_RATE_VHT_NSS4_MCS8 = 0x138,
RTW89_HW_RATE_VHT_NSS4_MCS9 = 0x139,
RTW89_HW_RATE_HE_NSS1_MCS0 = 0x180,
RTW89_HW_RATE_HE_NSS1_MCS1 = 0x181,
RTW89_HW_RATE_HE_NSS1_MCS2 = 0x182,
RTW89_HW_RATE_HE_NSS1_MCS3 = 0x183,
RTW89_HW_RATE_HE_NSS1_MCS4 = 0x184,
RTW89_HW_RATE_HE_NSS1_MCS5 = 0x185,
RTW89_HW_RATE_HE_NSS1_MCS6 = 0x186,
RTW89_HW_RATE_HE_NSS1_MCS7 = 0x187,
RTW89_HW_RATE_HE_NSS1_MCS8 = 0x188,
RTW89_HW_RATE_HE_NSS1_MCS9 = 0x189,
RTW89_HW_RATE_HE_NSS1_MCS10 = 0x18A,
RTW89_HW_RATE_HE_NSS1_MCS11 = 0x18B,
RTW89_HW_RATE_HE_NSS2_MCS0 = 0x190,
RTW89_HW_RATE_HE_NSS2_MCS1 = 0x191,
RTW89_HW_RATE_HE_NSS2_MCS2 = 0x192,
RTW89_HW_RATE_HE_NSS2_MCS3 = 0x193,
RTW89_HW_RATE_HE_NSS2_MCS4 = 0x194,
RTW89_HW_RATE_HE_NSS2_MCS5 = 0x195,
RTW89_HW_RATE_HE_NSS2_MCS6 = 0x196,
RTW89_HW_RATE_HE_NSS2_MCS7 = 0x197,
RTW89_HW_RATE_HE_NSS2_MCS8 = 0x198,
RTW89_HW_RATE_HE_NSS2_MCS9 = 0x199,
RTW89_HW_RATE_HE_NSS2_MCS10 = 0x19A,
RTW89_HW_RATE_HE_NSS2_MCS11 = 0x19B,
RTW89_HW_RATE_HE_NSS3_MCS0 = 0x1A0,
RTW89_HW_RATE_HE_NSS3_MCS1 = 0x1A1,
RTW89_HW_RATE_HE_NSS3_MCS2 = 0x1A2,
RTW89_HW_RATE_HE_NSS3_MCS3 = 0x1A3,
RTW89_HW_RATE_HE_NSS3_MCS4 = 0x1A4,
RTW89_HW_RATE_HE_NSS3_MCS5 = 0x1A5,
RTW89_HW_RATE_HE_NSS3_MCS6 = 0x1A6,
RTW89_HW_RATE_HE_NSS3_MCS7 = 0x1A7,
RTW89_HW_RATE_HE_NSS3_MCS8 = 0x1A8,
RTW89_HW_RATE_HE_NSS3_MCS9 = 0x1A9,
RTW89_HW_RATE_HE_NSS3_MCS10 = 0x1AA,
RTW89_HW_RATE_HE_NSS3_MCS11 = 0x1AB,
RTW89_HW_RATE_HE_NSS4_MCS0 = 0x1B0,
RTW89_HW_RATE_HE_NSS4_MCS1 = 0x1B1,
RTW89_HW_RATE_HE_NSS4_MCS2 = 0x1B2,
RTW89_HW_RATE_HE_NSS4_MCS3 = 0x1B3,
RTW89_HW_RATE_HE_NSS4_MCS4 = 0x1B4,
RTW89_HW_RATE_HE_NSS4_MCS5 = 0x1B5,
RTW89_HW_RATE_HE_NSS4_MCS6 = 0x1B6,
RTW89_HW_RATE_HE_NSS4_MCS7 = 0x1B7,
RTW89_HW_RATE_HE_NSS4_MCS8 = 0x1B8,
RTW89_HW_RATE_HE_NSS4_MCS9 = 0x1B9,
RTW89_HW_RATE_HE_NSS4_MCS10 = 0x1BA,
RTW89_HW_RATE_HE_NSS4_MCS11 = 0x1BB,
RTW89_HW_RATE_V1_MCS0 = 0x100,
RTW89_HW_RATE_V1_MCS1 = 0x101,
RTW89_HW_RATE_V1_MCS2 = 0x102,
RTW89_HW_RATE_V1_MCS3 = 0x103,
RTW89_HW_RATE_V1_MCS4 = 0x104,
RTW89_HW_RATE_V1_MCS5 = 0x105,
RTW89_HW_RATE_V1_MCS6 = 0x106,
RTW89_HW_RATE_V1_MCS7 = 0x107,
RTW89_HW_RATE_V1_MCS8 = 0x108,
RTW89_HW_RATE_V1_MCS9 = 0x109,
RTW89_HW_RATE_V1_MCS10 = 0x10A,
RTW89_HW_RATE_V1_MCS11 = 0x10B,
RTW89_HW_RATE_V1_MCS12 = 0x10C,
RTW89_HW_RATE_V1_MCS13 = 0x10D,
RTW89_HW_RATE_V1_MCS14 = 0x10E,
RTW89_HW_RATE_V1_MCS15 = 0x10F,
RTW89_HW_RATE_V1_MCS16 = 0x110,
RTW89_HW_RATE_V1_MCS17 = 0x111,
RTW89_HW_RATE_V1_MCS18 = 0x112,
RTW89_HW_RATE_V1_MCS19 = 0x113,
RTW89_HW_RATE_V1_MCS20 = 0x114,
RTW89_HW_RATE_V1_MCS21 = 0x115,
RTW89_HW_RATE_V1_MCS22 = 0x116,
RTW89_HW_RATE_V1_MCS23 = 0x117,
RTW89_HW_RATE_V1_MCS24 = 0x118,
RTW89_HW_RATE_V1_MCS25 = 0x119,
RTW89_HW_RATE_V1_MCS26 = 0x11A,
RTW89_HW_RATE_V1_MCS27 = 0x11B,
RTW89_HW_RATE_V1_MCS28 = 0x11C,
RTW89_HW_RATE_V1_MCS29 = 0x11D,
RTW89_HW_RATE_V1_MCS30 = 0x11E,
RTW89_HW_RATE_V1_MCS31 = 0x11F,
RTW89_HW_RATE_V1_VHT_NSS1_MCS0 = 0x200,
RTW89_HW_RATE_V1_VHT_NSS1_MCS1 = 0x201,
RTW89_HW_RATE_V1_VHT_NSS1_MCS2 = 0x202,
RTW89_HW_RATE_V1_VHT_NSS1_MCS3 = 0x203,
RTW89_HW_RATE_V1_VHT_NSS1_MCS4 = 0x204,
RTW89_HW_RATE_V1_VHT_NSS1_MCS5 = 0x205,
RTW89_HW_RATE_V1_VHT_NSS1_MCS6 = 0x206,
RTW89_HW_RATE_V1_VHT_NSS1_MCS7 = 0x207,
RTW89_HW_RATE_V1_VHT_NSS1_MCS8 = 0x208,
RTW89_HW_RATE_V1_VHT_NSS1_MCS9 = 0x209,
RTW89_HW_RATE_V1_VHT_NSS1_MCS10 = 0x20A,
RTW89_HW_RATE_V1_VHT_NSS1_MCS11 = 0x20B,
RTW89_HW_RATE_V1_VHT_NSS2_MCS0 = 0x220,
RTW89_HW_RATE_V1_VHT_NSS2_MCS1 = 0x221,
RTW89_HW_RATE_V1_VHT_NSS2_MCS2 = 0x222,
RTW89_HW_RATE_V1_VHT_NSS2_MCS3 = 0x223,
RTW89_HW_RATE_V1_VHT_NSS2_MCS4 = 0x224,
RTW89_HW_RATE_V1_VHT_NSS2_MCS5 = 0x225,
RTW89_HW_RATE_V1_VHT_NSS2_MCS6 = 0x226,
RTW89_HW_RATE_V1_VHT_NSS2_MCS7 = 0x227,
RTW89_HW_RATE_V1_VHT_NSS2_MCS8 = 0x228,
RTW89_HW_RATE_V1_VHT_NSS2_MCS9 = 0x229,
RTW89_HW_RATE_V1_VHT_NSS2_MCS10 = 0x22A,
RTW89_HW_RATE_V1_VHT_NSS2_MCS11 = 0x22B,
RTW89_HW_RATE_V1_VHT_NSS3_MCS0 = 0x240,
RTW89_HW_RATE_V1_VHT_NSS3_MCS1 = 0x241,
RTW89_HW_RATE_V1_VHT_NSS3_MCS2 = 0x242,
RTW89_HW_RATE_V1_VHT_NSS3_MCS3 = 0x243,
RTW89_HW_RATE_V1_VHT_NSS3_MCS4 = 0x244,
RTW89_HW_RATE_V1_VHT_NSS3_MCS5 = 0x245,
RTW89_HW_RATE_V1_VHT_NSS3_MCS6 = 0x246,
RTW89_HW_RATE_V1_VHT_NSS3_MCS7 = 0x247,
RTW89_HW_RATE_V1_VHT_NSS3_MCS8 = 0x248,
RTW89_HW_RATE_V1_VHT_NSS3_MCS9 = 0x249,
RTW89_HW_RATE_V1_VHT_NSS3_MCS10 = 0x24A,
RTW89_HW_RATE_V1_VHT_NSS3_MCS11 = 0x24B,
RTW89_HW_RATE_V1_VHT_NSS4_MCS0 = 0x260,
RTW89_HW_RATE_V1_VHT_NSS4_MCS1 = 0x261,
RTW89_HW_RATE_V1_VHT_NSS4_MCS2 = 0x262,
RTW89_HW_RATE_V1_VHT_NSS4_MCS3 = 0x263,
RTW89_HW_RATE_V1_VHT_NSS4_MCS4 = 0x264,
RTW89_HW_RATE_V1_VHT_NSS4_MCS5 = 0x265,
RTW89_HW_RATE_V1_VHT_NSS4_MCS6 = 0x266,
RTW89_HW_RATE_V1_VHT_NSS4_MCS7 = 0x267,
RTW89_HW_RATE_V1_VHT_NSS4_MCS8 = 0x268,
RTW89_HW_RATE_V1_VHT_NSS4_MCS9 = 0x269,
RTW89_HW_RATE_V1_VHT_NSS4_MCS10 = 0x26A,
RTW89_HW_RATE_V1_VHT_NSS4_MCS11 = 0x26B,
RTW89_HW_RATE_V1_HE_NSS1_MCS0 = 0x300,
RTW89_HW_RATE_V1_HE_NSS1_MCS1 = 0x301,
RTW89_HW_RATE_V1_HE_NSS1_MCS2 = 0x302,
RTW89_HW_RATE_V1_HE_NSS1_MCS3 = 0x303,
RTW89_HW_RATE_V1_HE_NSS1_MCS4 = 0x304,
RTW89_HW_RATE_V1_HE_NSS1_MCS5 = 0x305,
RTW89_HW_RATE_V1_HE_NSS1_MCS6 = 0x306,
RTW89_HW_RATE_V1_HE_NSS1_MCS7 = 0x307,
RTW89_HW_RATE_V1_HE_NSS1_MCS8 = 0x308,
RTW89_HW_RATE_V1_HE_NSS1_MCS9 = 0x309,
RTW89_HW_RATE_V1_HE_NSS1_MCS10 = 0x30A,
RTW89_HW_RATE_V1_HE_NSS1_MCS11 = 0x30B,
RTW89_HW_RATE_V1_HE_NSS2_MCS0 = 0x320,
RTW89_HW_RATE_V1_HE_NSS2_MCS1 = 0x321,
RTW89_HW_RATE_V1_HE_NSS2_MCS2 = 0x322,
RTW89_HW_RATE_V1_HE_NSS2_MCS3 = 0x323,
RTW89_HW_RATE_V1_HE_NSS2_MCS4 = 0x324,
RTW89_HW_RATE_V1_HE_NSS2_MCS5 = 0x325,
RTW89_HW_RATE_V1_HE_NSS2_MCS6 = 0x326,
RTW89_HW_RATE_V1_HE_NSS2_MCS7 = 0x327,
RTW89_HW_RATE_V1_HE_NSS2_MCS8 = 0x328,
RTW89_HW_RATE_V1_HE_NSS2_MCS9 = 0x329,
RTW89_HW_RATE_V1_HE_NSS2_MCS10 = 0x32A,
RTW89_HW_RATE_V1_HE_NSS2_MCS11 = 0x32B,
RTW89_HW_RATE_V1_HE_NSS3_MCS0 = 0x340,
RTW89_HW_RATE_V1_HE_NSS3_MCS1 = 0x341,
RTW89_HW_RATE_V1_HE_NSS3_MCS2 = 0x342,
RTW89_HW_RATE_V1_HE_NSS3_MCS3 = 0x343,
RTW89_HW_RATE_V1_HE_NSS3_MCS4 = 0x344,
RTW89_HW_RATE_V1_HE_NSS3_MCS5 = 0x345,
RTW89_HW_RATE_V1_HE_NSS3_MCS6 = 0x346,
RTW89_HW_RATE_V1_HE_NSS3_MCS7 = 0x347,
RTW89_HW_RATE_V1_HE_NSS3_MCS8 = 0x348,
RTW89_HW_RATE_V1_HE_NSS3_MCS9 = 0x349,
RTW89_HW_RATE_V1_HE_NSS3_MCS10 = 0x34A,
RTW89_HW_RATE_V1_HE_NSS3_MCS11 = 0x34B,
RTW89_HW_RATE_V1_HE_NSS4_MCS0 = 0x360,
RTW89_HW_RATE_V1_HE_NSS4_MCS1 = 0x361,
RTW89_HW_RATE_V1_HE_NSS4_MCS2 = 0x362,
RTW89_HW_RATE_V1_HE_NSS4_MCS3 = 0x363,
RTW89_HW_RATE_V1_HE_NSS4_MCS4 = 0x364,
RTW89_HW_RATE_V1_HE_NSS4_MCS5 = 0x365,
RTW89_HW_RATE_V1_HE_NSS4_MCS6 = 0x366,
RTW89_HW_RATE_V1_HE_NSS4_MCS7 = 0x367,
RTW89_HW_RATE_V1_HE_NSS4_MCS8 = 0x368,
RTW89_HW_RATE_V1_HE_NSS4_MCS9 = 0x369,
RTW89_HW_RATE_V1_HE_NSS4_MCS10 = 0x36A,
RTW89_HW_RATE_V1_HE_NSS4_MCS11 = 0x36B,
RTW89_HW_RATE_V1_EHT_NSS1_MCS0 = 0x400,
RTW89_HW_RATE_V1_EHT_NSS1_MCS1 = 0x401,
RTW89_HW_RATE_V1_EHT_NSS1_MCS2 = 0x402,
RTW89_HW_RATE_V1_EHT_NSS1_MCS3 = 0x403,
RTW89_HW_RATE_V1_EHT_NSS1_MCS4 = 0x404,
RTW89_HW_RATE_V1_EHT_NSS1_MCS5 = 0x405,
RTW89_HW_RATE_V1_EHT_NSS1_MCS6 = 0x406,
RTW89_HW_RATE_V1_EHT_NSS1_MCS7 = 0x407,
RTW89_HW_RATE_V1_EHT_NSS1_MCS8 = 0x408,
RTW89_HW_RATE_V1_EHT_NSS1_MCS9 = 0x409,
RTW89_HW_RATE_V1_EHT_NSS1_MCS10 = 0x40A,
RTW89_HW_RATE_V1_EHT_NSS1_MCS11 = 0x40B,
RTW89_HW_RATE_V1_EHT_NSS1_MCS12 = 0x40C,
RTW89_HW_RATE_V1_EHT_NSS1_MCS13 = 0x40D,
RTW89_HW_RATE_V1_EHT_NSS1_MCS14 = 0x40E,
RTW89_HW_RATE_V1_EHT_NSS1_MCS15 = 0x40F,
RTW89_HW_RATE_V1_EHT_NSS2_MCS0 = 0x420,
RTW89_HW_RATE_V1_EHT_NSS2_MCS1 = 0x421,
RTW89_HW_RATE_V1_EHT_NSS2_MCS2 = 0x422,
RTW89_HW_RATE_V1_EHT_NSS2_MCS3 = 0x423,
RTW89_HW_RATE_V1_EHT_NSS2_MCS4 = 0x424,
RTW89_HW_RATE_V1_EHT_NSS2_MCS5 = 0x425,
RTW89_HW_RATE_V1_EHT_NSS2_MCS6 = 0x426,
RTW89_HW_RATE_V1_EHT_NSS2_MCS7 = 0x427,
RTW89_HW_RATE_V1_EHT_NSS2_MCS8 = 0x428,
RTW89_HW_RATE_V1_EHT_NSS2_MCS9 = 0x429,
RTW89_HW_RATE_V1_EHT_NSS2_MCS10 = 0x42A,
RTW89_HW_RATE_V1_EHT_NSS2_MCS11 = 0x42B,
RTW89_HW_RATE_V1_EHT_NSS2_MCS12 = 0x42C,
RTW89_HW_RATE_V1_EHT_NSS2_MCS13 = 0x42D,
RTW89_HW_RATE_V1_EHT_NSS3_MCS0 = 0x440,
RTW89_HW_RATE_V1_EHT_NSS3_MCS1 = 0x441,
RTW89_HW_RATE_V1_EHT_NSS3_MCS2 = 0x442,
RTW89_HW_RATE_V1_EHT_NSS3_MCS3 = 0x443,
RTW89_HW_RATE_V1_EHT_NSS3_MCS4 = 0x444,
RTW89_HW_RATE_V1_EHT_NSS3_MCS5 = 0x445,
RTW89_HW_RATE_V1_EHT_NSS3_MCS6 = 0x446,
RTW89_HW_RATE_V1_EHT_NSS3_MCS7 = 0x447,
RTW89_HW_RATE_V1_EHT_NSS3_MCS8 = 0x448,
RTW89_HW_RATE_V1_EHT_NSS3_MCS9 = 0x449,
RTW89_HW_RATE_V1_EHT_NSS3_MCS10 = 0x44A,
RTW89_HW_RATE_V1_EHT_NSS3_MCS11 = 0x44B,
RTW89_HW_RATE_V1_EHT_NSS3_MCS12 = 0x44C,
RTW89_HW_RATE_V1_EHT_NSS3_MCS13 = 0x44D,
RTW89_HW_RATE_V1_EHT_NSS4_MCS0 = 0x460,
RTW89_HW_RATE_V1_EHT_NSS4_MCS1 = 0x461,
RTW89_HW_RATE_V1_EHT_NSS4_MCS2 = 0x462,
RTW89_HW_RATE_V1_EHT_NSS4_MCS3 = 0x463,
RTW89_HW_RATE_V1_EHT_NSS4_MCS4 = 0x464,
RTW89_HW_RATE_V1_EHT_NSS4_MCS5 = 0x465,
RTW89_HW_RATE_V1_EHT_NSS4_MCS6 = 0x466,
RTW89_HW_RATE_V1_EHT_NSS4_MCS7 = 0x467,
RTW89_HW_RATE_V1_EHT_NSS4_MCS8 = 0x468,
RTW89_HW_RATE_V1_EHT_NSS4_MCS9 = 0x469,
RTW89_HW_RATE_V1_EHT_NSS4_MCS10 = 0x46A,
RTW89_HW_RATE_V1_EHT_NSS4_MCS11 = 0x46B,
RTW89_HW_RATE_V1_EHT_NSS4_MCS12 = 0x46C,
RTW89_HW_RATE_V1_EHT_NSS4_MCS13 = 0x46D,
RTW89_HW_RATE_NR,
RTW89_HW_RATE_INVAL,
RTW89_HW_RATE_MASK_MOD = GENMASK(8, 7),
RTW89_HW_RATE_MASK_VAL = GENMASK(6, 0),
RTW89_HW_RATE_V1_MASK_MOD = GENMASK(10, 8),
RTW89_HW_RATE_V1_MASK_VAL = GENMASK(7, 0),
};
/* 2G channels,
* 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14
*/
#define RTW89_2G_CH_NUM 14
/* 5G channels,
* 36, 38, 40, 42, 44, 46, 48, 50,
* 52, 54, 56, 58, 60, 62, 64,
* 100, 102, 104, 106, 108, 110, 112, 114,
* 116, 118, 120, 122, 124, 126, 128, 130,
* 132, 134, 136, 138, 140, 142, 144,
* 149, 151, 153, 155, 157, 159, 161, 163,
* 165, 167, 169, 171, 173, 175, 177
*/
#define RTW89_5G_CH_NUM 53
/* 6G channels,
* 1, 3, 5, 7, 9, 11, 13, 15,
* 17, 19, 21, 23, 25, 27, 29, 33,
* 35, 37, 39, 41, 43, 45, 47, 49,
* 51, 53, 55, 57, 59, 61, 65, 67,
* 69, 71, 73, 75, 77, 79, 81, 83,
* 85, 87, 89, 91, 93, 97, 99, 101,
* 103, 105, 107, 109, 111, 113, 115, 117,
* 119, 121, 123, 125, 129, 131, 133, 135,
* 137, 139, 141, 143, 145, 147, 149, 151,
* 153, 155, 157, 161, 163, 165, 167, 169,
* 171, 173, 175, 177, 179, 181, 183, 185,
* 187, 189, 193, 195, 197, 199, 201, 203,
* 205, 207, 209, 211, 213, 215, 217, 219,
* 221, 225, 227, 229, 231, 233, 235, 237,
* 239, 241, 243, 245, 247, 249, 251, 253,
*/
#define RTW89_6G_CH_NUM 120
enum rtw89_rate_section {
RTW89_RS_CCK,
RTW89_RS_OFDM,
RTW89_RS_MCS, /* for HT/VHT/HE */
RTW89_RS_HEDCM,
RTW89_RS_OFFSET,
RTW89_RS_NUM,
RTW89_RS_LMT_NUM = RTW89_RS_MCS + 1,
RTW89_RS_TX_SHAPE_NUM = RTW89_RS_OFDM + 1,
};
enum rtw89_rate_offset_indexes {
RTW89_RATE_OFFSET_HE,
RTW89_RATE_OFFSET_VHT,
RTW89_RATE_OFFSET_HT,
RTW89_RATE_OFFSET_OFDM,
RTW89_RATE_OFFSET_CCK,
RTW89_RATE_OFFSET_DLRU_EHT,
RTW89_RATE_OFFSET_DLRU_HE,
RTW89_RATE_OFFSET_EHT,
__RTW89_RATE_OFFSET_NUM,
RTW89_RATE_OFFSET_NUM_AX = RTW89_RATE_OFFSET_CCK + 1,
RTW89_RATE_OFFSET_NUM_BE = RTW89_RATE_OFFSET_EHT + 1,
};
enum rtw89_rate_num {
RTW89_RATE_CCK_NUM = 4,
RTW89_RATE_OFDM_NUM = 8,
RTW89_RATE_HEDCM_NUM = 4, /* for HEDCM MCS0/1/3/4 */
RTW89_RATE_MCS_NUM_AX = 12,
RTW89_RATE_MCS_NUM_BE = 16,
__RTW89_RATE_MCS_NUM = 16,
};
enum rtw89_nss {
RTW89_NSS_1 = 0,
RTW89_NSS_2 = 1,
/* HE DCM only support 1ss and 2ss */
RTW89_NSS_HEDCM_NUM = RTW89_NSS_2 + 1,
RTW89_NSS_3 = 2,
RTW89_NSS_4 = 3,
RTW89_NSS_NUM,
};
enum rtw89_ntx {
RTW89_1TX = 0,
RTW89_2TX = 1,
RTW89_NTX_NUM,
};
enum rtw89_beamforming_type {
RTW89_NONBF = 0,
RTW89_BF = 1,
RTW89_BF_NUM,
};
enum rtw89_ofdma_type {
RTW89_NON_OFDMA = 0,
RTW89_OFDMA = 1,
RTW89_OFDMA_NUM,
};
/* neither insert new in the middle, nor change any given definition */
enum rtw89_regulation_type {
RTW89_WW = 0,
RTW89_ETSI = 1,
RTW89_FCC = 2,
RTW89_MKK = 3,
RTW89_NA = 4,
RTW89_IC = 5,
RTW89_KCC = 6,
RTW89_ACMA = 7,
RTW89_NCC = 8,
RTW89_MEXICO = 9,
RTW89_CHILE = 10,
RTW89_UKRAINE = 11,
RTW89_CN = 12,
RTW89_QATAR = 13,
RTW89_UK = 14,
RTW89_THAILAND = 15,
RTW89_REGD_NUM,
};
enum rtw89_reg_6ghz_power {
RTW89_REG_6GHZ_POWER_VLP = 0,
RTW89_REG_6GHZ_POWER_LPI = 1,
RTW89_REG_6GHZ_POWER_STD = 2,
NUM_OF_RTW89_REG_6GHZ_POWER,
RTW89_REG_6GHZ_POWER_DFLT = RTW89_REG_6GHZ_POWER_VLP,
};
#define RTW89_MIN_VALID_POWER_CONSTRAINT (-10) /* unit: dBm */
/* calculate based on ieee80211 Transmit Power Envelope */
struct rtw89_reg_6ghz_tpe {
bool valid;
s8 constraint; /* unit: dBm */
};
enum rtw89_fw_pkt_ofld_type {
RTW89_PKT_OFLD_TYPE_PROBE_RSP = 0,
RTW89_PKT_OFLD_TYPE_PS_POLL = 1,
RTW89_PKT_OFLD_TYPE_NULL_DATA = 2,
RTW89_PKT_OFLD_TYPE_QOS_NULL = 3,
RTW89_PKT_OFLD_TYPE_CTS2SELF = 4,
RTW89_PKT_OFLD_TYPE_ARP_RSP = 5,
RTW89_PKT_OFLD_TYPE_NDP = 6,
RTW89_PKT_OFLD_TYPE_EAPOL_KEY = 7,
RTW89_PKT_OFLD_TYPE_SA_QUERY = 8,
RTW89_PKT_OFLD_TYPE_PROBE_REQ = 12,
RTW89_PKT_OFLD_TYPE_NUM,
};
struct rtw89_txpwr_byrate {
s8 cck[RTW89_RATE_CCK_NUM];
s8 ofdm[RTW89_RATE_OFDM_NUM];
s8 mcs[RTW89_OFDMA_NUM][RTW89_NSS_NUM][__RTW89_RATE_MCS_NUM];
s8 hedcm[RTW89_OFDMA_NUM][RTW89_NSS_HEDCM_NUM][RTW89_RATE_HEDCM_NUM];
s8 offset[__RTW89_RATE_OFFSET_NUM];
s8 trap;
};
struct rtw89_rate_desc {
enum rtw89_nss nss;
enum rtw89_rate_section rs;
enum rtw89_ofdma_type ofdma;
u8 idx;
};
#define PHY_STS_HDR_LEN 8
#define RF_PATH_MAX 4
#define RTW89_MAX_PPDU_CNT 8
struct rtw89_rx_phy_ppdu {
void *buf;
u32 len;
u8 rssi_avg;
u8 rssi[RF_PATH_MAX];
u8 mac_id;
u8 chan_idx;
u8 phy_idx;
u8 ie;
u16 rate;
u8 rpl_avg;
u8 rpl_path[RF_PATH_MAX];
u8 rpl_fd[RF_PATH_MAX];
u8 bw_idx;
u8 rx_path_en;
struct {
bool has;
u8 avg_snr;
u8 evm_max;
u8 evm_min;
} ofdm;
bool has_data;
bool has_bcn;
bool ldpc;
bool stbc;
bool to_self;
bool valid;
bool hdr_2_en;
};
enum rtw89_mac_idx {
RTW89_MAC_0 = 0,
RTW89_MAC_1 = 1,
RTW89_MAC_NUM,
};
enum rtw89_phy_idx {
RTW89_PHY_0 = 0,
RTW89_PHY_1 = 1,
RTW89_PHY_NUM,
};
#define __RTW89_MLD_MAX_LINK_NUM 2
#define RTW89_MLD_NON_STA_LINK_NUM 1
enum rtw89_chanctx_idx {
RTW89_CHANCTX_0 = 0,
RTW89_CHANCTX_1 = 1,
NUM_OF_RTW89_CHANCTX,
RTW89_CHANCTX_IDLE = NUM_OF_RTW89_CHANCTX,
};
enum rtw89_rf_path {
RF_PATH_A = 0,
RF_PATH_B = 1,
RF_PATH_C = 2,
RF_PATH_D = 3,
RF_PATH_AB,
RF_PATH_AC,
RF_PATH_AD,
RF_PATH_BC,
RF_PATH_BD,
RF_PATH_CD,
RF_PATH_ABC,
RF_PATH_ABD,
RF_PATH_ACD,
RF_PATH_BCD,
RF_PATH_ABCD,
};
enum rtw89_rf_path_bit {
RF_A = BIT(0),
RF_B = BIT(1),
RF_C = BIT(2),
RF_D = BIT(3),
RF_AB = (RF_A | RF_B),
RF_AC = (RF_A | RF_C),
RF_AD = (RF_A | RF_D),
RF_BC = (RF_B | RF_C),
RF_BD = (RF_B | RF_D),
RF_CD = (RF_C | RF_D),
RF_ABC = (RF_A | RF_B | RF_C),
RF_ABD = (RF_A | RF_B | RF_D),
RF_ACD = (RF_A | RF_C | RF_D),
RF_BCD = (RF_B | RF_C | RF_D),
RF_ABCD = (RF_A | RF_B | RF_C | RF_D),
};
enum rtw89_bandwidth {
RTW89_CHANNEL_WIDTH_20 = 0,
RTW89_CHANNEL_WIDTH_40 = 1,
RTW89_CHANNEL_WIDTH_80 = 2,
RTW89_CHANNEL_WIDTH_160 = 3,
RTW89_CHANNEL_WIDTH_320 = 4,
/* keep index order above */
RTW89_CHANNEL_WIDTH_ORDINARY_NUM = 5,
RTW89_CHANNEL_WIDTH_80_80 = 5,
RTW89_CHANNEL_WIDTH_5 = 6,
RTW89_CHANNEL_WIDTH_10 = 7,
};
enum rtw89_ps_mode {
RTW89_PS_MODE_NONE = 0,
RTW89_PS_MODE_RFOFF = 1,
RTW89_PS_MODE_CLK_GATED = 2,
RTW89_PS_MODE_PWR_GATED = 3,
};
#define RTW89_2G_BW_NUM (RTW89_CHANNEL_WIDTH_40 + 1)
#define RTW89_5G_BW_NUM (RTW89_CHANNEL_WIDTH_160 + 1)
#define RTW89_6G_BW_NUM (RTW89_CHANNEL_WIDTH_320 + 1)
#define RTW89_BYR_BW_NUM (RTW89_CHANNEL_WIDTH_320 + 1)
#define RTW89_PPE_BW_NUM (RTW89_CHANNEL_WIDTH_320 + 1)
enum rtw89_pe_duration {
RTW89_PE_DURATION_0 = 0,
RTW89_PE_DURATION_8 = 1,
RTW89_PE_DURATION_16 = 2,
RTW89_PE_DURATION_16_20 = 3,
};
enum rtw89_ru_bandwidth {
RTW89_RU26 = 0,
RTW89_RU52 = 1,
RTW89_RU106 = 2,
RTW89_RU52_26 = 3,
RTW89_RU106_26 = 4,
RTW89_RU_NUM,
};
enum rtw89_sc_offset {
RTW89_SC_DONT_CARE = 0,
RTW89_SC_20_UPPER = 1,
RTW89_SC_20_LOWER = 2,
RTW89_SC_20_UPMOST = 3,
RTW89_SC_20_LOWEST = 4,
RTW89_SC_20_UP2X = 5,
RTW89_SC_20_LOW2X = 6,
RTW89_SC_20_UP3X = 7,
RTW89_SC_20_LOW3X = 8,
RTW89_SC_40_UPPER = 9,
RTW89_SC_40_LOWER = 10,
};
/* only mgd features can be added to the enum */
enum rtw89_wow_flags {
RTW89_WOW_FLAG_EN_MAGIC_PKT,
RTW89_WOW_FLAG_EN_REKEY_PKT,
RTW89_WOW_FLAG_EN_DISCONNECT,
RTW89_WOW_FLAG_EN_PATTERN,
RTW89_WOW_FLAG_NUM,
};
struct rtw89_chan {
u8 channel;
u8 primary_channel;
enum rtw89_band band_type;
enum rtw89_bandwidth band_width;
/* The follow-up are derived from the above. We must ensure that it
* is assigned correctly in rtw89_chan_create() if new one is added.
*/
u32 freq;
enum rtw89_subband subband_type;
enum rtw89_sc_offset pri_ch_idx;
u8 pri_sb_idx;
};
struct rtw89_chan_rcd {
u8 prev_primary_channel;
enum rtw89_band prev_band_type;
bool band_changed;
};
struct rtw89_channel_help_params {
u32 tx_en;
};
struct rtw89_port_reg {
u32 port_cfg;
u32 tbtt_prohib;
u32 bcn_area;
u32 bcn_early;
u32 tbtt_early;
u32 tbtt_agg;
u32 bcn_space;
u32 bcn_forcetx;
u32 bcn_err_cnt;
u32 bcn_err_flag;
u32 dtim_ctrl;
u32 tbtt_shift;
u32 bcn_cnt_tmr;
u32 tsftr_l;
u32 tsftr_h;
u32 md_tsft;
u32 bss_color;
u32 mbssid;
u32 mbssid_drop;
u32 tsf_sync;
u32 ptcl_dbg;
u32 ptcl_dbg_info;
u32 bcn_drop_all;
u32 hiq_win[RTW89_PORT_NUM];
};
struct rtw89_txwd_body {
__le32 dword0;
__le32 dword1;
__le32 dword2;
__le32 dword3;
__le32 dword4;
__le32 dword5;
} __packed;
struct rtw89_txwd_body_v1 {
__le32 dword0;
__le32 dword1;
__le32 dword2;
__le32 dword3;
__le32 dword4;
__le32 dword5;
__le32 dword6;
__le32 dword7;
} __packed;
struct rtw89_txwd_body_v2 {
__le32 dword0;
__le32 dword1;
__le32 dword2;
__le32 dword3;
__le32 dword4;
__le32 dword5;
__le32 dword6;
__le32 dword7;
} __packed;
struct rtw89_txwd_info {
__le32 dword0;
__le32 dword1;
__le32 dword2;
__le32 dword3;
__le32 dword4;
__le32 dword5;
} __packed;
struct rtw89_txwd_info_v2 {
__le32 dword0;
__le32 dword1;
__le32 dword2;
__le32 dword3;
__le32 dword4;
__le32 dword5;
__le32 dword6;
__le32 dword7;
} __packed;
struct rtw89_rx_desc_info {
u16 pkt_size;
u8 pkt_type;
u8 drv_info_size;
u8 phy_rpt_size;
u8 hdr_cnv_size;
u8 shift;
u8 wl_hd_iv_len;
bool long_rxdesc;
bool bb_sel;
bool mac_info_valid;
u16 data_rate;
u8 gi_ltf;
u8 bw;
u32 free_run_cnt;
u8 user_id;
bool sr_en;
u8 ppdu_cnt;
u8 ppdu_type;
bool icv_err;
bool crc32_err;
bool hw_dec;
bool sw_dec;
bool addr1_match;
u8 frag;
u16 seq;
u8 frame_type;
u8 rx_pl_id;
bool addr_cam_valid;
u8 addr_cam_id;
u8 sec_cam_id;
u8 mac_id;
u16 offset;
u16 rxd_len;
bool ready;
u16 rssi;
};
struct rtw89_rxdesc_short {
__le32 dword0;
__le32 dword1;
__le32 dword2;
__le32 dword3;
} __packed;
struct rtw89_rxdesc_short_v2 {
__le32 dword0;
__le32 dword1;
__le32 dword2;
__le32 dword3;
__le32 dword4;
__le32 dword5;
} __packed;
struct rtw89_rxdesc_long {
__le32 dword0;
__le32 dword1;
__le32 dword2;
__le32 dword3;
__le32 dword4;
__le32 dword5;
__le32 dword6;
__le32 dword7;
} __packed;
struct rtw89_rxdesc_long_v2 {
__le32 dword0;
__le32 dword1;
__le32 dword2;
__le32 dword3;
__le32 dword4;
__le32 dword5;
__le32 dword6;
__le32 dword7;
__le32 dword8;
__le32 dword9;
} __packed;
struct rtw89_rxdesc_phy_rpt_v2 {
__le32 dword0;
__le32 dword1;
} __packed;
struct rtw89_tx_desc_info {
u16 pkt_size;
u8 wp_offset;
u8 mac_id;
u8 qsel;
u8 ch_dma;
u8 hdr_llc_len;
bool is_bmc;
bool en_wd_info;
bool wd_page;
bool use_rate;
bool dis_data_fb;
bool tid_indicate;
bool agg_en;
bool bk;
u8 ampdu_density;
u8 ampdu_num;
bool sec_en;
u8 addr_info_nr;
u8 sec_keyid;
u8 sec_type;
u8 sec_cam_idx;
u8 sec_seq[6];
u16 data_rate;
u16 data_retry_lowest_rate;
bool fw_dl;
u16 seq;
bool a_ctrl_bsr;
u8 hw_ssn_sel;
#define RTW89_MGMT_HW_SSN_SEL 1
u8 hw_seq_mode;
#define RTW89_MGMT_HW_SEQ_MODE 1
bool hiq;
u8 port;
bool er_cap;
bool stbc;
bool ldpc;
bool upd_wlan_hdr;
bool mlo;
bool sw_mld;
};
struct rtw89_core_tx_request {
enum rtw89_core_tx_type tx_type;
struct sk_buff *skb;
struct ieee80211_vif *vif;
struct ieee80211_sta *sta;
struct rtw89_vif_link *rtwvif_link;
struct rtw89_sta_link *rtwsta_link;
struct rtw89_tx_desc_info desc_info;
};
struct rtw89_txq {
struct list_head list;
unsigned long flags;
int wait_cnt;
};
struct rtw89_mac_ax_gnt {
u8 gnt_bt_sw_en;
u8 gnt_bt;
u8 gnt_wl_sw_en;
u8 gnt_wl;
} __packed;
struct rtw89_mac_ax_wl_act {
u8 wlan_act_en;
u8 wlan_act;
};
#define RTW89_MAC_AX_COEX_GNT_NR 2
struct rtw89_mac_ax_coex_gnt {
struct rtw89_mac_ax_gnt band[RTW89_MAC_AX_COEX_GNT_NR];
struct rtw89_mac_ax_wl_act bt[RTW89_MAC_AX_COEX_GNT_NR];
};
enum rtw89_btc_ncnt {
BTC_NCNT_POWER_ON = 0x0,
BTC_NCNT_POWER_OFF,
BTC_NCNT_INIT_COEX,
BTC_NCNT_SCAN_START,
BTC_NCNT_SCAN_FINISH,
BTC_NCNT_SPECIAL_PACKET,
BTC_NCNT_SWITCH_BAND,
BTC_NCNT_RFK_TIMEOUT,
BTC_NCNT_SHOW_COEX_INFO,
BTC_NCNT_ROLE_INFO,
BTC_NCNT_CONTROL,
BTC_NCNT_RADIO_STATE,
BTC_NCNT_CUSTOMERIZE,
BTC_NCNT_WL_RFK,
BTC_NCNT_WL_STA,
BTC_NCNT_WL_STA_LAST,
BTC_NCNT_FWINFO,
BTC_NCNT_TIMER,
BTC_NCNT_SWITCH_CHBW,
BTC_NCNT_RESUME_DL_FW,
BTC_NCNT_COUNTRYCODE,
BTC_NCNT_NUM,
};
enum rtw89_btc_btinfo {
BTC_BTINFO_L0 = 0,
BTC_BTINFO_L1,
BTC_BTINFO_L2,
BTC_BTINFO_L3,
BTC_BTINFO_H0,
BTC_BTINFO_H1,
BTC_BTINFO_H2,
BTC_BTINFO_H3,
BTC_BTINFO_MAX
};
enum rtw89_btc_dcnt {
BTC_DCNT_RUN = 0x0,
BTC_DCNT_CX_RUNINFO,
BTC_DCNT_RPT,
BTC_DCNT_RPT_HANG,
BTC_DCNT_CYCLE,
BTC_DCNT_CYCLE_HANG,
BTC_DCNT_W1,
BTC_DCNT_W1_HANG,
BTC_DCNT_B1,
BTC_DCNT_B1_HANG,
BTC_DCNT_TDMA_NONSYNC,
BTC_DCNT_SLOT_NONSYNC,
BTC_DCNT_BTCNT_HANG,
BTC_DCNT_BTTX_HANG,
BTC_DCNT_WL_SLOT_DRIFT,
BTC_DCNT_WL_STA_LAST,
BTC_DCNT_BT_SLOT_DRIFT,
BTC_DCNT_BT_SLOT_FLOOD,
BTC_DCNT_FDDT_TRIG,
BTC_DCNT_E2G,
BTC_DCNT_E2G_HANG,
BTC_DCNT_WL_FW_VER_MATCH,
BTC_DCNT_NULL_TX_FAIL,
BTC_DCNT_WL_STA_NTFY,
BTC_DCNT_NUM,
};
enum rtw89_btc_wl_state_cnt {
BTC_WCNT_SCANAP = 0x0,
BTC_WCNT_DHCP,
BTC_WCNT_EAPOL,
BTC_WCNT_ARP,
BTC_WCNT_SCBDUPDATE,
BTC_WCNT_RFK_REQ,
BTC_WCNT_RFK_GO,
BTC_WCNT_RFK_REJECT,
BTC_WCNT_RFK_TIMEOUT,
BTC_WCNT_CH_UPDATE,
BTC_WCNT_DBCC_ALL_2G,
BTC_WCNT_DBCC_CHG,
BTC_WCNT_RX_OK_LAST,
BTC_WCNT_RX_OK_LAST2S,
BTC_WCNT_RX_ERR_LAST,
BTC_WCNT_RX_ERR_LAST2S,
BTC_WCNT_RX_LAST,
BTC_WCNT_NUM
};
enum rtw89_btc_bt_state_cnt {
BTC_BCNT_RETRY = 0x0,
BTC_BCNT_REINIT,
BTC_BCNT_REENABLE,
BTC_BCNT_SCBDREAD,
BTC_BCNT_RELINK,
BTC_BCNT_IGNOWL,
BTC_BCNT_INQPAG,
BTC_BCNT_INQ,
BTC_BCNT_PAGE,
BTC_BCNT_ROLESW,
BTC_BCNT_AFH,
BTC_BCNT_INFOUPDATE,
BTC_BCNT_INFOSAME,
BTC_BCNT_SCBDUPDATE,
BTC_BCNT_HIPRI_TX,
BTC_BCNT_HIPRI_RX,
BTC_BCNT_LOPRI_TX,
BTC_BCNT_LOPRI_RX,
BTC_BCNT_POLUT,
BTC_BCNT_POLUT_NOW,
BTC_BCNT_POLUT_DIFF,
BTC_BCNT_RATECHG,
BTC_BCNT_NUM,
};
enum rtw89_btc_bt_profile {
BTC_BT_NOPROFILE = 0,
BTC_BT_HFP = BIT(0),
BTC_BT_HID = BIT(1),
BTC_BT_A2DP = BIT(2),
BTC_BT_PAN = BIT(3),
BTC_PROFILE_MAX = 4,
};
struct rtw89_btc_ant_info {
u8 type; /* shared, dedicated */
u8 num;
u8 isolation;
u8 single_pos: 1;/* Single antenna at S0 or S1 */
u8 diversity: 1;
u8 btg_pos: 2;
u8 stream_cnt: 4;
};
struct rtw89_btc_ant_info_v7 {
u8 type; /* shared, dedicated(non-shared) */
u8 num; /* antenna count */
u8 isolation;
u8 single_pos;/* wifi 1ss-1ant at 0:S0 or 1:S1 */
u8 diversity; /* only for wifi use 1-antenna */
u8 btg_pos; /* btg-circuit at 0:S0/1:S1/others:all */
u8 stream_cnt; /* spatial_stream count */
u8 rsvd;
} __packed;
enum rtw89_tfc_dir {
RTW89_TFC_UL,
RTW89_TFC_DL,
};
struct rtw89_btc_wl_smap {
u32 busy: 1;
u32 scan: 1;
u32 connecting: 1;
u32 roaming: 1;
u32 dbccing: 1;
u32 _4way: 1;
u32 rf_off: 1;
u32 lps: 2;
u32 ips: 1;
u32 init_ok: 1;
u32 traffic_dir : 2;
u32 rf_off_pre: 1;
u32 lps_pre: 2;
u32 lps_exiting: 1;
u32 emlsr: 1;
};
enum rtw89_tfc_lv {
RTW89_TFC_IDLE,
RTW89_TFC_ULTRA_LOW,
RTW89_TFC_LOW,
RTW89_TFC_MID,
RTW89_TFC_HIGH,
};
#define RTW89_TP_SHIFT 18 /* bytes/2s --> Mbps */
DECLARE_EWMA(tp, 10, 2);
struct rtw89_traffic_stats {
/* units in bytes */
u64 tx_unicast;
u64 rx_unicast;
u32 tx_avg_len;
u32 rx_avg_len;
/* count for packets */
u64 tx_cnt;
u64 rx_cnt;
/* units in Mbps */
u32 tx_throughput;
u32 rx_throughput;
u32 tx_throughput_raw;
u32 rx_throughput_raw;
u32 rx_tf_acc;
u32 rx_tf_periodic;
enum rtw89_tfc_lv tx_tfc_lv;
enum rtw89_tfc_lv rx_tfc_lv;
struct ewma_tp tx_ewma_tp;
struct ewma_tp rx_ewma_tp;
u16 tx_rate;
u16 rx_rate;
};
struct rtw89_btc_chdef {
u8 center_ch;
u8 band;
u8 chan;
enum rtw89_sc_offset offset;
enum rtw89_bandwidth bw;
};
struct rtw89_btc_statistic {
u8 rssi; /* 0%~110% (dBm = rssi -110) */
struct rtw89_traffic_stats traffic;
};
#define BTC_WL_RSSI_THMAX 4
struct rtw89_btc_wl_link_info {
struct rtw89_btc_chdef chdef;
struct rtw89_btc_statistic stat;
enum rtw89_tfc_dir dir;
u8 rssi_state[BTC_WL_RSSI_THMAX];
u8 mac_addr[ETH_ALEN];
u8 busy;
u8 ch;
u8 bw;
u8 band;
u8 role;
u8 pid;
u8 phy;
u8 dtim_period;
u8 mode;
u8 tx_1ss_limit;
u8 mac_id;
u8 tx_retry;
u32 bcn_period;
u32 busy_t;
u32 tx_time;
u32 client_cnt;
u32 rx_rate_drop_cnt;
u32 noa_duration;
u32 active: 1;
u32 noa: 1;
u32 client_ps: 1;
u32 connected: 2;
};
union rtw89_btc_wl_state_map {
u32 val;
struct rtw89_btc_wl_smap map;
};
struct rtw89_btc_bt_hfp_desc {
u32 exist: 1;
u32 type: 2;
u32 rsvd: 29;
};
struct rtw89_btc_bt_hid_desc {
u32 exist: 1;
u32 slot_info: 2;
u32 pair_cnt: 2;
u32 type: 8;
u32 rsvd: 19;
};
struct rtw89_btc_bt_a2dp_desc {
u8 exist: 1;
u8 exist_last: 1;
u8 play_latency: 1;
u8 type: 3;
u8 active: 1;
u8 sink: 1;
u32 handle_update: 1;
u32 devinfo_query: 1;
u32 no_empty_streak_2s: 8;
u32 no_empty_streak_max: 8;
u32 rsvd: 6;
u8 bitpool;
u16 vendor_id;
u32 device_name;
u32 flush_time;
};
struct rtw89_btc_bt_pan_desc {
u32 exist: 1;
u32 type: 1;
u32 active: 1;
u32 rsvd: 29;
};
struct rtw89_btc_bt_rfk_info {
u32 run: 1;
u32 req: 1;
u32 timeout: 1;
u32 rsvd: 29;
};
union rtw89_btc_bt_rfk_info_map {
u32 val;
struct rtw89_btc_bt_rfk_info map;
};
struct rtw89_btc_bt_ver_info {
u32 fw_coex; /* match with which coex_ver */
u32 fw;
};
struct rtw89_btc_bool_sta_chg {
u32 now: 1;
u32 last: 1;
u32 remain: 1;
u32 srvd: 29;
};
struct rtw89_btc_u8_sta_chg {
u8 now;
u8 last;
u8 remain;
u8 rsvd;
};
struct rtw89_btc_wl_scan_info {
u8 band[RTW89_PHY_NUM];
u8 phy_map;
u8 rsvd;
};
struct rtw89_btc_wl_dbcc_info {
u8 op_band[RTW89_PHY_NUM]; /* op band in each phy */
u8 scan_band[RTW89_PHY_NUM]; /* scan band in each phy */
u8 real_band[RTW89_PHY_NUM];
u8 role[RTW89_PHY_NUM]; /* role in each phy */
};
struct rtw89_btc_wl_active_role {
u8 connected: 1;
u8 pid: 3;
u8 phy: 1;
u8 noa: 1;
u8 band: 2;
u8 client_ps: 1;
u8 bw: 7;
u8 role;
u8 ch;
u16 tx_lvl;
u16 rx_lvl;
u16 tx_rate;
u16 rx_rate;
};
struct rtw89_btc_wl_active_role_v1 {
u8 connected: 1;
u8 pid: 3;
u8 phy: 1;
u8 noa: 1;
u8 band: 2;
u8 client_ps: 1;
u8 bw: 7;
u8 role;
u8 ch;
u16 tx_lvl;
u16 rx_lvl;
u16 tx_rate;
u16 rx_rate;
u32 noa_duration; /* ms */
};
struct rtw89_btc_wl_active_role_v2 {
u8 connected: 1;
u8 pid: 3;
u8 phy: 1;
u8 noa: 1;
u8 band: 2;
u8 client_ps: 1;
u8 bw: 7;
u8 role;
u8 ch;
u32 noa_duration; /* ms */
};
struct rtw89_btc_wl_active_role_v7 {
u8 connected;
u8 pid;
u8 phy;
u8 noa;
u8 band;
u8 client_ps;
u8 bw;
u8 role;
u8 ch;
u8 noa_dur;
u8 client_cnt;
u8 rsvd2;
} __packed;
struct rtw89_btc_wl_role_info_bpos {
u16 none: 1;
u16 station: 1;
u16 ap: 1;
u16 vap: 1;
u16 adhoc: 1;
u16 adhoc_master: 1;
u16 mesh: 1;
u16 moniter: 1;
u16 p2p_device: 1;
u16 p2p_gc: 1;
u16 p2p_go: 1;
u16 nan: 1;
};
struct rtw89_btc_wl_scc_ctrl {
u8 null_role1;
u8 null_role2;
u8 ebt_null; /* if tx null at EBT slot */
};
union rtw89_btc_wl_role_info_map {
u16 val;
struct rtw89_btc_wl_role_info_bpos role;
};
struct rtw89_btc_wl_role_info { /* struct size must be n*4 bytes */
u8 connect_cnt;
u8 link_mode;
union rtw89_btc_wl_role_info_map role_map;
struct rtw89_btc_wl_active_role active_role[RTW89_PORT_NUM];
};
struct rtw89_btc_wl_role_info_v1 { /* struct size must be n*4 bytes */
u8 connect_cnt;
u8 link_mode;
union rtw89_btc_wl_role_info_map role_map;
struct rtw89_btc_wl_active_role_v1 active_role_v1[RTW89_PORT_NUM];
u32 mrole_type; /* btc_wl_mrole_type */
u32 mrole_noa_duration; /* ms */
u32 dbcc_en: 1;
u32 dbcc_chg: 1;
u32 dbcc_2g_phy: 2; /* which phy operate in 2G, HW_PHY_0 or HW_PHY_1 */
u32 link_mode_chg: 1;
u32 rsvd: 27;
};
struct rtw89_btc_wl_role_info_v2 { /* struct size must be n*4 bytes */
u8 connect_cnt;
u8 link_mode;
union rtw89_btc_wl_role_info_map role_map;
struct rtw89_btc_wl_active_role_v2 active_role_v2[RTW89_PORT_NUM];
u32 mrole_type; /* btc_wl_mrole_type */
u32 mrole_noa_duration; /* ms */
u32 dbcc_en: 1;
u32 dbcc_chg: 1;
u32 dbcc_2g_phy: 2; /* which phy operate in 2G, HW_PHY_0 or HW_PHY_1 */
u32 link_mode_chg: 1;
u32 rsvd: 27;
};
struct rtw89_btc_wl_rlink { /* H2C info, struct size must be n*4 bytes */
u8 connected;
u8 pid;
u8 phy;
u8 noa;
u8 rf_band; /* enum band_type RF band: 2.4G/5G/6G */
u8 active; /* 0:rlink is under doze */
u8 bw; /* enum channel_width */
u8 role; /*enum role_type */
u8 ch;
u8 noa_dur; /* ms */
u8 client_cnt; /* for Role = P2P-Go/AP */
u8 mode; /* wifi protocol */
} __packed;
#define RTW89_BE_BTC_WL_MAX_ROLE_NUMBER 6
struct rtw89_btc_wl_role_info_v7 { /* struct size must be n*4 bytes */
u8 connect_cnt;
u8 link_mode;
u8 link_mode_chg;
u8 p2p_2g;
struct rtw89_btc_wl_active_role_v7 active_role[RTW89_BE_BTC_WL_MAX_ROLE_NUMBER];
u32 role_map;
u32 mrole_type; /* btc_wl_mrole_type */
u32 mrole_noa_duration; /* ms */
u32 dbcc_en;
u32 dbcc_chg;
u32 dbcc_2g_phy; /* which phy operate in 2G, HW_PHY_0 or HW_PHY_1 */
} __packed;
struct rtw89_btc_wl_role_info_v8 { /* H2C info, struct size must be n*4 bytes */
u8 connect_cnt;
u8 link_mode;
u8 link_mode_chg;
u8 p2p_2g;
u8 pta_req_band;
u8 dbcc_en; /* 1+1 and 2.4G-included */
u8 dbcc_chg;
u8 dbcc_2g_phy; /* which phy operate in 2G, HW_PHY_0 or HW_PHY_1 */
struct rtw89_btc_wl_rlink rlink[RTW89_BE_BTC_WL_MAX_ROLE_NUMBER][RTW89_MAC_NUM];
u32 role_map;
u32 mrole_type; /* btc_wl_mrole_type */
u32 mrole_noa_duration; /* ms */
} __packed;
struct rtw89_btc_wl_ver_info {
u32 fw_coex; /* match with which coex_ver */
u32 fw;
u32 mac;
u32 bb;
u32 rf;
};
struct rtw89_btc_wl_afh_info {
u8 en;
u8 ch;
u8 bw;
u8 rsvd;
} __packed;
struct rtw89_btc_wl_rfk_info {
u32 state: 2;
u32 path_map: 4;
u32 phy_map: 2;
u32 band: 2;
u32 type: 8;
u32 con_rfk: 1;
u32 rsvd: 13;
u32 start_time;
u32 proc_time;
};
struct rtw89_btc_bt_smap {
u32 connect: 1;
u32 ble_connect: 1;
u32 acl_busy: 1;
u32 sco_busy: 1;
u32 mesh_busy: 1;
u32 inq_pag: 1;
};
union rtw89_btc_bt_state_map {
u32 val;
struct rtw89_btc_bt_smap map;
};
#define BTC_BT_RSSI_THMAX 4
#define BTC_BT_AFH_GROUP 12
#define BTC_BT_AFH_LE_GROUP 5
struct rtw89_btc_bt_link_info {
struct rtw89_btc_u8_sta_chg profile_cnt;
struct rtw89_btc_bool_sta_chg multi_link;
struct rtw89_btc_bool_sta_chg relink;
struct rtw89_btc_bt_hfp_desc hfp_desc;
struct rtw89_btc_bt_hid_desc hid_desc;
struct rtw89_btc_bt_a2dp_desc a2dp_desc;
struct rtw89_btc_bt_pan_desc pan_desc;
union rtw89_btc_bt_state_map status;
u8 sut_pwr_level[BTC_PROFILE_MAX];
u8 golden_rx_shift[BTC_PROFILE_MAX];
u8 rssi_state[BTC_BT_RSSI_THMAX];
u8 afh_map[BTC_BT_AFH_GROUP];
u8 afh_map_le[BTC_BT_AFH_LE_GROUP];
u32 role_sw: 1;
u32 slave_role: 1;
u32 afh_update: 1;
u32 cqddr: 1;
u32 rssi: 8;
u32 tx_3m: 1;
u32 rsvd: 19;
};
struct rtw89_btc_3rdcx_info {
u8 type; /* 0: none, 1:zigbee, 2:LTE */
u8 hw_coex;
u16 rsvd;
};
struct rtw89_btc_dm_emap {
u32 init: 1;
u32 pta_owner: 1;
u32 wl_rfk_timeout: 1;
u32 bt_rfk_timeout: 1;
u32 wl_fw_hang: 1;
u32 cycle_hang: 1;
u32 w1_hang: 1;
u32 b1_hang: 1;
u32 tdma_no_sync: 1;
u32 slot_no_sync: 1;
u32 wl_slot_drift: 1;
u32 bt_slot_drift: 1;
u32 role_num_mismatch: 1;
u32 null1_tx_late: 1;
u32 bt_afh_conflict: 1;
u32 bt_leafh_conflict: 1;
u32 bt_slot_flood: 1;
u32 wl_e2g_hang: 1;
u32 wl_ver_mismatch: 1;
u32 bt_ver_mismatch: 1;
u32 rfe_type0: 1;
u32 h2c_buffer_over: 1;
u32 bt_tx_hang: 1; /* for SNR too low bug, BT has no Tx req*/
u32 wl_no_sta_ntfy: 1;
u32 h2c_bmap_mismatch: 1;
u32 c2h_bmap_mismatch: 1;
u32 h2c_struct_invalid: 1;
u32 c2h_struct_invalid: 1;
u32 h2c_c2h_buffer_mismatch: 1;
};
union rtw89_btc_dm_error_map {
u32 val;
struct rtw89_btc_dm_emap map;
};
struct rtw89_btc_rf_para {
u32 tx_pwr_freerun;
u32 rx_gain_freerun;
u32 tx_pwr_perpkt;
u32 rx_gain_perpkt;
};
struct rtw89_btc_wl_nhm {
u8 instant_wl_nhm_dbm;
u8 instant_wl_nhm_per_mhz;
u16 valid_record_times;
s8 record_pwr[16];
u8 record_ratio[16];
s8 pwr; /* dbm_per_MHz */
u8 ratio;
u8 current_status;
u8 refresh;
bool start_flag;
s8 pwr_max;
s8 pwr_min;
};
struct rtw89_btc_wl_info {
struct rtw89_btc_wl_link_info link_info[RTW89_PORT_NUM];
struct rtw89_btc_wl_link_info rlink_info[RTW89_BE_BTC_WL_MAX_ROLE_NUMBER][RTW89_MAC_NUM];
struct rtw89_btc_wl_rfk_info rfk_info;
struct rtw89_btc_wl_ver_info ver_info;
struct rtw89_btc_wl_afh_info afh_info;
struct rtw89_btc_wl_role_info role_info;
struct rtw89_btc_wl_role_info_v1 role_info_v1;
struct rtw89_btc_wl_role_info_v2 role_info_v2;
struct rtw89_btc_wl_role_info_v7 role_info_v7;
struct rtw89_btc_wl_role_info_v8 role_info_v8;
struct rtw89_btc_wl_scan_info scan_info;
struct rtw89_btc_wl_dbcc_info dbcc_info;
struct rtw89_btc_rf_para rf_para;
struct rtw89_btc_wl_nhm nhm;
union rtw89_btc_wl_state_map status;
u8 port_id[RTW89_WIFI_ROLE_MLME_MAX];
u8 rssi_level;
u8 cn_report;
u8 coex_mode;
u8 pta_req_mac;
u8 bt_polut_type[RTW89_PHY_NUM]; /* BT polluted WL-Tx type for phy0/1 */
bool is_5g_hi_channel;
bool pta_reg_mac_chg;
bool bg_mode;
bool he_mode;
bool scbd_change;
bool fw_ver_mismatch;
bool client_cnt_inc_2g;
u32 scbd;
};
struct rtw89_btc_module {
struct rtw89_btc_ant_info ant;
u8 rfe_type;
u8 cv;
u8 bt_solo: 1;
u8 bt_pos: 1;
u8 switch_type: 1;
u8 wa_type: 3;
u8 kt_ver_adie;
};
struct rtw89_btc_module_v7 {
u8 rfe_type;
u8 kt_ver;
u8 bt_solo;
u8 bt_pos; /* wl-end view: get from efuse, must compare bt.btg_type*/
u8 switch_type; /* WL/BT switch type: 0: internal, 1: external */
u8 wa_type; /* WA type: 0:none, 1: 51B 5G_Hi-Ch_Rx */
u8 kt_ver_adie;
u8 rsvd;
struct rtw89_btc_ant_info_v7 ant;
} __packed;
union rtw89_btc_module_info {
struct rtw89_btc_module md;
struct rtw89_btc_module_v7 md_v7;
};
#define RTW89_BTC_DM_MAXSTEP 30
#define RTW89_BTC_DM_CNT_MAX (RTW89_BTC_DM_MAXSTEP * 8)
struct rtw89_btc_dm_step {
u16 step[RTW89_BTC_DM_MAXSTEP];
u8 step_pos;
bool step_ov;
};
struct rtw89_btc_init_info {
struct rtw89_btc_module module;
u8 wl_guard_ch;
u8 wl_only: 1;
u8 wl_init_ok: 1;
u8 dbcc_en: 1;
u8 cx_other: 1;
u8 bt_only: 1;
u16 rsvd;
};
struct rtw89_btc_init_info_v7 {
u8 wl_guard_ch;
u8 wl_only;
u8 wl_init_ok;
u8 rsvd3;
u8 cx_other;
u8 bt_only;
u8 pta_mode;
u8 pta_direction;
struct rtw89_btc_module_v7 module;
} __packed;
union rtw89_btc_init_info_u {
struct rtw89_btc_init_info init;
struct rtw89_btc_init_info_v7 init_v7;
};
struct rtw89_btc_wl_tx_limit_para {
u16 enable;
u32 tx_time; /* unit: us */
u16 tx_retry;
};
enum rtw89_btc_bt_scan_type {
BTC_SCAN_INQ = 0,
BTC_SCAN_PAGE,
BTC_SCAN_BLE,
BTC_SCAN_INIT,
BTC_SCAN_TV,
BTC_SCAN_ADV,
BTC_SCAN_MAX1,
};
enum rtw89_btc_ble_scan_type {
CXSCAN_BG = 0,
CXSCAN_INIT,
CXSCAN_LE,
CXSCAN_MAX
};
#define RTW89_BTC_BTC_SCAN_V1_FLAG_ENABLE BIT(0)
#define RTW89_BTC_BTC_SCAN_V1_FLAG_INTERLACE BIT(1)
struct rtw89_btc_bt_scan_info_v1 {
__le16 win;
__le16 intvl;
__le32 flags;
} __packed;
struct rtw89_btc_bt_scan_info_v2 {
__le16 win;
__le16 intvl;
} __packed;
struct rtw89_btc_fbtc_btscan_v1 {
u8 fver; /* btc_ver::fcxbtscan */
u8 rsvd;
__le16 rsvd2;
struct rtw89_btc_bt_scan_info_v1 scan[BTC_SCAN_MAX1];
} __packed;
struct rtw89_btc_fbtc_btscan_v2 {
u8 fver; /* btc_ver::fcxbtscan */
u8 type;
__le16 rsvd2;
struct rtw89_btc_bt_scan_info_v2 para[CXSCAN_MAX];
} __packed;
struct rtw89_btc_fbtc_btscan_v7 {
u8 fver; /* btc_ver::fcxbtscan */
u8 type;
u8 rsvd0;
u8 rsvd1;
struct rtw89_btc_bt_scan_info_v2 para[CXSCAN_MAX];
} __packed;
union rtw89_btc_fbtc_btscan {
struct rtw89_btc_fbtc_btscan_v1 v1;
struct rtw89_btc_fbtc_btscan_v2 v2;
struct rtw89_btc_fbtc_btscan_v7 v7;
};
struct rtw89_btc_bt_info {
struct rtw89_btc_bt_link_info link_info;
struct rtw89_btc_bt_scan_info_v1 scan_info_v1[BTC_SCAN_MAX1];
struct rtw89_btc_bt_scan_info_v2 scan_info_v2[CXSCAN_MAX];
struct rtw89_btc_bt_ver_info ver_info;
struct rtw89_btc_bool_sta_chg enable;
struct rtw89_btc_bool_sta_chg inq_pag;
struct rtw89_btc_rf_para rf_para;
union rtw89_btc_bt_rfk_info_map rfk_info;
u8 raw_info[BTC_BTINFO_MAX]; /* raw bt info from mailbox */
u8 rssi_level;
u32 scbd;
u32 feature;
u32 mbx_avl: 1;
u32 whql_test: 1;
u32 igno_wl: 1;
u32 reinit: 1;
u32 ble_scan_en: 1;
u32 btg_type: 1;
u32 inq: 1;
u32 pag: 1;
u32 run_patch_code: 1;
u32 hi_lna_rx: 1;
u32 scan_rx_low_pri: 1;
u32 scan_info_update: 1;
u32 lna_constrain: 3;
u32 rsvd: 17;
};
struct rtw89_btc_cx {
struct rtw89_btc_wl_info wl;
struct rtw89_btc_bt_info bt;
struct rtw89_btc_3rdcx_info other;
u32 state_map;
u32 cnt_bt[BTC_BCNT_NUM];
u32 cnt_wl[BTC_WCNT_NUM];
};
struct rtw89_btc_fbtc_tdma {
u8 type; /* btc_ver::fcxtdma */
u8 rxflctrl;
u8 txpause;
u8 wtgle_n;
u8 leak_n;
u8 ext_ctrl;
u8 rxflctrl_role;
u8 option_ctrl;
} __packed;
struct rtw89_btc_fbtc_tdma_v3 {
u8 fver; /* btc_ver::fcxtdma */
u8 rsvd;
__le16 rsvd1;
struct rtw89_btc_fbtc_tdma tdma;
} __packed;
union rtw89_btc_fbtc_tdma_le32 {
struct rtw89_btc_fbtc_tdma v1;
struct rtw89_btc_fbtc_tdma_v3 v3;
};
#define CXMREG_MAX 30
#define CXMREG_MAX_V2 20
#define FCXMAX_STEP 255 /*STEP trace record cnt, Max:65535, default:255*/
#define BTC_CYCLE_SLOT_MAX 48 /* must be even number, non-zero */
enum rtw89_btc_bt_sta_counter {
BTC_BCNT_RFK_REQ = 0,
BTC_BCNT_RFK_GO = 1,
BTC_BCNT_RFK_REJECT = 2,
BTC_BCNT_RFK_FAIL = 3,
BTC_BCNT_RFK_TIMEOUT = 4,
BTC_BCNT_HI_TX = 5,
BTC_BCNT_HI_RX = 6,
BTC_BCNT_LO_TX = 7,
BTC_BCNT_LO_RX = 8,
BTC_BCNT_POLLUTED = 9,
BTC_BCNT_STA_MAX
};
enum rtw89_btc_bt_sta_counter_v105 {
BTC_BCNT_RFK_REQ_V105 = 0,
BTC_BCNT_HI_TX_V105 = 1,
BTC_BCNT_HI_RX_V105 = 2,
BTC_BCNT_LO_TX_V105 = 3,
BTC_BCNT_LO_RX_V105 = 4,
BTC_BCNT_POLLUTED_V105 = 5,
BTC_BCNT_STA_MAX_V105
};
struct rtw89_btc_fbtc_rpt_ctrl_v1 {
u16 fver; /* btc_ver::fcxbtcrpt */
u16 rpt_cnt; /* tmr counters */
u32 wl_fw_coex_ver; /* match which driver's coex version */
u32 wl_fw_cx_offload;
u32 wl_fw_ver;
u32 rpt_enable;
u32 rpt_para; /* ms */
u32 mb_send_fail_cnt; /* fw send mailbox fail counter */
u32 mb_send_ok_cnt; /* fw send mailbox ok counter */
u32 mb_recv_cnt; /* fw recv mailbox counter */
u32 mb_a2dp_empty_cnt; /* a2dp empty count */
u32 mb_a2dp_flct_cnt; /* a2dp empty flow control counter */
u32 mb_a2dp_full_cnt; /* a2dp empty full counter */
u32 bt_rfk_cnt[BTC_BCNT_HI_TX];
u32 c2h_cnt; /* fw send c2h counter */
u32 h2c_cnt; /* fw recv h2c counter */
} __packed;
struct rtw89_btc_fbtc_rpt_ctrl_info {
__le32 cnt; /* fw report counter */
__le32 en; /* report map */
__le32 para; /* not used */
__le32 cnt_c2h; /* fw send c2h counter */
__le32 cnt_h2c; /* fw recv h2c counter */
__le32 len_c2h; /* The total length of the last C2H */
__le32 cnt_aoac_rf_on; /* rf-on counter for aoac switch notify */
__le32 cnt_aoac_rf_off; /* rf-off counter for aoac switch notify */
} __packed;
struct rtw89_btc_fbtc_rpt_ctrl_info_v5 {
__le32 cx_ver; /* match which driver's coex version */
__le32 fw_ver;
__le32 en; /* report map */
__le16 cnt; /* fw report counter */
__le16 cnt_c2h; /* fw send c2h counter */
__le16 cnt_h2c; /* fw recv h2c counter */
__le16 len_c2h; /* The total length of the last C2H */
__le16 cnt_aoac_rf_on; /* rf-on counter for aoac switch notify */
__le16 cnt_aoac_rf_off; /* rf-off counter for aoac switch notify */
} __packed;
struct rtw89_btc_fbtc_rpt_ctrl_info_v8 {
__le16 cnt; /* fw report counter */
__le16 cnt_c2h; /* fw send c2h counter */
__le16 cnt_h2c; /* fw recv h2c counter */
__le16 len_c2h; /* The total length of the last C2H */
__le16 cnt_aoac_rf_on; /* rf-on counter for aoac switch notify */
__le16 cnt_aoac_rf_off; /* rf-off counter for aoac switch notify */
__le32 cx_ver; /* match which driver's coex version */
__le32 fw_ver;
__le32 en; /* report map */
} __packed;
struct rtw89_btc_fbtc_rpt_ctrl_wl_fw_info {
__le32 cx_ver; /* match which driver's coex version */
__le32 cx_offload;
__le32 fw_ver;
} __packed;
struct rtw89_btc_fbtc_rpt_ctrl_a2dp_empty {
__le32 cnt_empty; /* a2dp empty count */
__le32 cnt_flowctrl; /* a2dp empty flow control counter */
__le32 cnt_tx;
__le32 cnt_ack;
__le32 cnt_nack;
} __packed;
struct rtw89_btc_fbtc_rpt_ctrl_bt_mailbox {
__le32 cnt_send_ok; /* fw send mailbox ok counter */
__le32 cnt_send_fail; /* fw send mailbox fail counter */
__le32 cnt_recv; /* fw recv mailbox counter */
struct rtw89_btc_fbtc_rpt_ctrl_a2dp_empty a2dp;
} __packed;
struct rtw89_btc_fbtc_rpt_ctrl_v4 {
u8 fver;
u8 rsvd;
__le16 rsvd1;
struct rtw89_btc_fbtc_rpt_ctrl_info rpt_info;
struct rtw89_btc_fbtc_rpt_ctrl_wl_fw_info wl_fw_info;
struct rtw89_btc_fbtc_rpt_ctrl_bt_mailbox bt_mbx_info;
__le32 bt_cnt[BTC_BCNT_STA_MAX];
struct rtw89_mac_ax_gnt gnt_val[RTW89_PHY_NUM];
} __packed;
struct rtw89_btc_fbtc_rpt_ctrl_v5 {
u8 fver;
u8 rsvd;
__le16 rsvd1;
u8 gnt_val[RTW89_PHY_NUM][4];
__le16 bt_cnt[BTC_BCNT_STA_MAX];
struct rtw89_btc_fbtc_rpt_ctrl_info_v5 rpt_info;
struct rtw89_btc_fbtc_rpt_ctrl_bt_mailbox bt_mbx_info;
} __packed;
struct rtw89_btc_fbtc_rpt_ctrl_v105 {
u8 fver;
u8 rsvd;
__le16 rsvd1;
u8 gnt_val[RTW89_PHY_NUM][4];
__le16 bt_cnt[BTC_BCNT_STA_MAX_V105];
struct rtw89_btc_fbtc_rpt_ctrl_info_v5 rpt_info;
struct rtw89_btc_fbtc_rpt_ctrl_bt_mailbox bt_mbx_info;
} __packed;
struct rtw89_btc_fbtc_rpt_ctrl_v7 {
u8 fver;
u8 rsvd0;
u8 rsvd1;
u8 rsvd2;
u8 gnt_val[RTW89_PHY_NUM][4];
__le16 bt_cnt[BTC_BCNT_STA_MAX_V105];
struct rtw89_btc_fbtc_rpt_ctrl_info_v8 rpt_info;
struct rtw89_btc_fbtc_rpt_ctrl_bt_mailbox bt_mbx_info;
} __packed;
struct rtw89_btc_fbtc_rpt_ctrl_v8 {
u8 fver;
u8 rsvd0;
u8 rpt_len_max_l; /* BTC_RPT_MAX bit0~7 */
u8 rpt_len_max_h; /* BTC_RPT_MAX bit8~15 */
u8 gnt_val[RTW89_PHY_NUM][4];
__le16 bt_cnt[BTC_BCNT_STA_MAX_V105];
struct rtw89_btc_fbtc_rpt_ctrl_info_v8 rpt_info;
struct rtw89_btc_fbtc_rpt_ctrl_bt_mailbox bt_mbx_info;
} __packed;
union rtw89_btc_fbtc_rpt_ctrl_ver_info {
struct rtw89_btc_fbtc_rpt_ctrl_v1 v1;
struct rtw89_btc_fbtc_rpt_ctrl_v4 v4;
struct rtw89_btc_fbtc_rpt_ctrl_v5 v5;
struct rtw89_btc_fbtc_rpt_ctrl_v105 v105;
struct rtw89_btc_fbtc_rpt_ctrl_v7 v7;
struct rtw89_btc_fbtc_rpt_ctrl_v8 v8;
};
enum rtw89_fbtc_ext_ctrl_type {
CXECTL_OFF = 0x0, /* tdma off */
CXECTL_B2 = 0x1, /* allow B2 (beacon-early) */
CXECTL_EXT = 0x2,
CXECTL_MAX
};
union rtw89_btc_fbtc_rxflct {
u8 val;
u8 type: 3;
u8 tgln_n: 5;
};
enum rtw89_btc_cxst_state {
CXST_OFF = 0x0,
CXST_B2W = 0x1,
CXST_W1 = 0x2,
CXST_W2 = 0x3,
CXST_W2B = 0x4,
CXST_B1 = 0x5,
CXST_B2 = 0x6,
CXST_B3 = 0x7,
CXST_B4 = 0x8,
CXST_LK = 0x9,
CXST_BLK = 0xa,
CXST_E2G = 0xb,
CXST_E5G = 0xc,
CXST_EBT = 0xd,
CXST_ENULL = 0xe,
CXST_WLK = 0xf,
CXST_W1FDD = 0x10,
CXST_B1FDD = 0x11,
CXST_MAX = 0x12,
};
enum rtw89_btc_cxevnt {
CXEVNT_TDMA_ENTRY = 0x0,
CXEVNT_WL_TMR,
CXEVNT_B1_TMR,
CXEVNT_B2_TMR,
CXEVNT_B3_TMR,
CXEVNT_B4_TMR,
CXEVNT_W2B_TMR,
CXEVNT_B2W_TMR,
CXEVNT_BCN_EARLY,
CXEVNT_A2DP_EMPTY,
CXEVNT_LK_END,
CXEVNT_RX_ISR,
CXEVNT_RX_FC0,
CXEVNT_RX_FC1,
CXEVNT_BT_RELINK,
CXEVNT_BT_RETRY,
CXEVNT_E2G,
CXEVNT_E5G,
CXEVNT_EBT,
CXEVNT_ENULL,
CXEVNT_DRV_WLK,
CXEVNT_BCN_OK,
CXEVNT_BT_CHANGE,
CXEVNT_EBT_EXTEND,
CXEVNT_E2G_NULL1,
CXEVNT_B1FDD_TMR,
CXEVNT_MAX
};
enum {
CXBCN_ALL = 0x0,
CXBCN_ALL_OK,
CXBCN_BT_SLOT,
CXBCN_BT_OK,
CXBCN_MAX
};
enum btc_slot_type {
SLOT_MIX = 0x0, /* accept BT Lower-Pri Tx/Rx request 0x778 = 1 */
SLOT_ISO = 0x1, /* no accept BT Lower-Pri Tx/Rx request 0x778 = d*/
CXSTYPE_NUM,
};
enum { /* TIME */
CXT_BT = 0x0,
CXT_WL = 0x1,
CXT_MAX
};
enum { /* TIME-A2DP */
CXT_FLCTRL_OFF = 0x0,
CXT_FLCTRL_ON = 0x1,
CXT_FLCTRL_MAX
};
enum { /* STEP TYPE */
CXSTEP_NONE = 0x0,
CXSTEP_EVNT = 0x1,
CXSTEP_SLOT = 0x2,
CXSTEP_MAX,
};
enum rtw89_btc_afh_map_type { /*AFH MAP TYPE */
RPT_BT_AFH_SEQ_LEGACY = 0x10,
RPT_BT_AFH_SEQ_LE = 0x20
};
#define BTC_DBG_MAX1 32
struct rtw89_btc_fbtc_gpio_dbg_v1 {
u8 fver; /* btc_ver::fcxgpiodbg */
u8 rsvd;
__le16 rsvd2;
__le32 en_map; /* which debug signal (see btc_wl_gpio_debug) is enable */
__le32 pre_state; /* the debug signal is 1 or 0 */
u8 gpio_map[BTC_DBG_MAX1]; /*the debug signals to GPIO-Position */
} __packed;
struct rtw89_btc_fbtc_gpio_dbg_v7 {
u8 fver;
u8 rsvd0;
u8 rsvd1;
u8 rsvd2;
u8 gpio_map[BTC_DBG_MAX1];
__le32 en_map;
__le32 pre_state;
} __packed;
union rtw89_btc_fbtc_gpio_dbg {
struct rtw89_btc_fbtc_gpio_dbg_v1 v1;
struct rtw89_btc_fbtc_gpio_dbg_v7 v7;
};
struct rtw89_btc_fbtc_mreg_val_v1 {
u8 fver; /* btc_ver::fcxmreg */
u8 reg_num;
__le16 rsvd;
__le32 mreg_val[CXMREG_MAX];
} __packed;
struct rtw89_btc_fbtc_mreg_val_v2 {
u8 fver; /* btc_ver::fcxmreg */
u8 reg_num;
__le16 rsvd;
__le32 mreg_val[CXMREG_MAX_V2];
} __packed;
struct rtw89_btc_fbtc_mreg_val_v7 {
u8 fver;
u8 reg_num;
u8 rsvd0;
u8 rsvd1;
__le32 mreg_val[CXMREG_MAX_V2];
} __packed;
union rtw89_btc_fbtc_mreg_val {
struct rtw89_btc_fbtc_mreg_val_v1 v1;
struct rtw89_btc_fbtc_mreg_val_v2 v2;
struct rtw89_btc_fbtc_mreg_val_v7 v7;
};
#define RTW89_DEF_FBTC_MREG(__type, __bytes, __offset) \
{ .type = cpu_to_le16(__type), .bytes = cpu_to_le16(__bytes), \
.offset = cpu_to_le32(__offset), }
struct rtw89_btc_fbtc_mreg {
__le16 type;
__le16 bytes;
__le32 offset;
} __packed;
struct rtw89_btc_fbtc_slot {
__le16 dur;
__le32 cxtbl;
__le16 cxtype;
} __packed;
struct rtw89_btc_fbtc_slots {
u8 fver; /* btc_ver::fcxslots */
u8 tbl_num;
__le16 rsvd;
__le32 update_map;
struct rtw89_btc_fbtc_slot slot[CXST_MAX];
} __packed;
struct rtw89_btc_fbtc_slot_v7 {
__le16 dur; /* slot duration */
__le16 cxtype;
__le32 cxtbl;
} __packed;
struct rtw89_btc_fbtc_slot_u16 {
__le16 dur; /* slot duration */
__le16 cxtype;
__le16 cxtbl_l16; /* coex table [15:0] */
__le16 cxtbl_h16; /* coex table [31:16] */
} __packed;
struct rtw89_btc_fbtc_1slot_v7 {
u8 fver;
u8 sid; /* slot id */
__le16 rsvd;
struct rtw89_btc_fbtc_slot_v7 slot;
} __packed;
struct rtw89_btc_fbtc_slots_v7 {
u8 fver;
u8 slot_cnt;
u8 rsvd0;
u8 rsvd1;
struct rtw89_btc_fbtc_slot_u16 slot[CXST_MAX];
__le32 update_map;
} __packed;
union rtw89_btc_fbtc_slots_info {
struct rtw89_btc_fbtc_slots v1;
struct rtw89_btc_fbtc_slots_v7 v7;
} __packed;
struct rtw89_btc_fbtc_step {
u8 type;
u8 val;
__le16 difft;
} __packed;
struct rtw89_btc_fbtc_steps_v2 {
u8 fver; /* btc_ver::fcxstep */
u8 rsvd;
__le16 cnt;
__le16 pos_old;
__le16 pos_new;
struct rtw89_btc_fbtc_step step[FCXMAX_STEP];
} __packed;
struct rtw89_btc_fbtc_steps_v3 {
u8 fver;
u8 en;
__le16 rsvd;
__le32 cnt;
struct rtw89_btc_fbtc_step step[FCXMAX_STEP];
} __packed;
union rtw89_btc_fbtc_steps_info {
struct rtw89_btc_fbtc_steps_v2 v2;
struct rtw89_btc_fbtc_steps_v3 v3;
};
struct rtw89_btc_fbtc_cysta_v2 { /* statistics for cycles */
u8 fver; /* btc_ver::fcxcysta */
u8 rsvd;
__le16 cycles; /* total cycle number */
__le16 cycles_a2dp[CXT_FLCTRL_MAX];
__le16 a2dpept; /* a2dp empty cnt */
__le16 a2dpeptto; /* a2dp empty timeout cnt*/
__le16 tavg_cycle[CXT_MAX]; /* avg wl/bt cycle time */
__le16 tmax_cycle[CXT_MAX]; /* max wl/bt cycle time */
__le16 tmaxdiff_cycle[CXT_MAX]; /* max wl-wl bt-bt cycle diff time */
__le16 tavg_a2dp[CXT_FLCTRL_MAX]; /* avg a2dp PSTDMA/TDMA time */
__le16 tmax_a2dp[CXT_FLCTRL_MAX]; /* max a2dp PSTDMA/TDMA time */
__le16 tavg_a2dpept; /* avg a2dp empty time */
__le16 tmax_a2dpept; /* max a2dp empty time */
__le16 tavg_lk; /* avg leak-slot time */
__le16 tmax_lk; /* max leak-slot time */
__le32 slot_cnt[CXST_MAX]; /* slot count */
__le32 bcn_cnt[CXBCN_MAX];
__le32 leakrx_cnt; /* the rximr occur at leak slot */
__le32 collision_cnt; /* counter for event/timer occur at same time */
__le32 skip_cnt;
__le32 exception;
__le32 except_cnt;
__le16 tslot_cycle[BTC_CYCLE_SLOT_MAX];
} __packed;
struct rtw89_btc_fbtc_fdd_try_info {
__le16 cycles[CXT_FLCTRL_MAX];
__le16 tavg[CXT_FLCTRL_MAX]; /* avg try BT-Slot-TDD/BT-slot-FDD time */
__le16 tmax[CXT_FLCTRL_MAX]; /* max try BT-Slot-TDD/BT-slot-FDD time */
} __packed;
struct rtw89_btc_fbtc_cycle_time_info {
__le16 tavg[CXT_MAX]; /* avg wl/bt cycle time */
__le16 tmax[CXT_MAX]; /* max wl/bt cycle time */
__le16 tmaxdiff[CXT_MAX]; /* max wl-wl bt-bt cycle diff time */
} __packed;
struct rtw89_btc_fbtc_cycle_time_info_v5 {
__le16 tavg[CXT_MAX]; /* avg wl/bt cycle time */
__le16 tmax[CXT_MAX]; /* max wl/bt cycle time */
} __packed;
struct rtw89_btc_fbtc_a2dp_trx_stat {
u8 empty_cnt;
u8 retry_cnt;
u8 tx_rate;
u8 tx_cnt;
u8 ack_cnt;
u8 nack_cnt;
u8 rsvd1;
u8 rsvd2;
} __packed;
struct rtw89_btc_fbtc_a2dp_trx_stat_v4 {
u8 empty_cnt;
u8 retry_cnt;
u8 tx_rate;
u8 tx_cnt;
u8 ack_cnt;
u8 nack_cnt;
u8 no_empty_cnt;
u8 rsvd;
} __packed;
struct rtw89_btc_fbtc_cycle_a2dp_empty_info {
__le16 cnt; /* a2dp empty cnt */
__le16 cnt_timeout; /* a2dp empty timeout cnt*/
__le16 tavg; /* avg a2dp empty time */
__le16 tmax; /* max a2dp empty time */
} __packed;
struct rtw89_btc_fbtc_cycle_leak_info {
__le32 cnt_rximr; /* the rximr occur at leak slot */
__le16 tavg; /* avg leak-slot time */
__le16 tmax; /* max leak-slot time */
} __packed;
struct rtw89_btc_fbtc_cycle_leak_info_v7 {
__le16 tavg;
__le16 tamx;
__le32 cnt_rximr;
} __packed;
#define RTW89_BTC_FDDT_PHASE_CYCLE GENMASK(9, 0)
#define RTW89_BTC_FDDT_TRAIN_STEP GENMASK(15, 10)
struct rtw89_btc_fbtc_cycle_fddt_info {
__le16 train_cycle;
__le16 tp;
s8 tx_power; /* absolute Tx power (dBm), 0xff-> no BTC control */
s8 bt_tx_power; /* decrease Tx power (dB) */
s8 bt_rx_gain; /* LNA constrain level */
u8 no_empty_cnt;
u8 rssi; /* [7:4] -> bt_rssi_level, [3:0]-> wl_rssi_level */
u8 cn; /* condition_num */
u8 train_status; /* [7:4]-> train-state, [3:0]-> train-phase */
u8 train_result; /* refer to enum btc_fddt_check_map */
} __packed;
#define RTW89_BTC_FDDT_CELL_TRAIN_STATE GENMASK(3, 0)
#define RTW89_BTC_FDDT_CELL_TRAIN_PHASE GENMASK(7, 4)
struct rtw89_btc_fbtc_cycle_fddt_info_v5 {
__le16 train_cycle;
__le16 tp;
s8 tx_power; /* absolute Tx power (dBm), 0xff-> no BTC control */
s8 bt_tx_power; /* decrease Tx power (dB) */
s8 bt_rx_gain; /* LNA constrain level */
u8 no_empty_cnt;
u8 rssi; /* [7:4] -> bt_rssi_level, [3:0]-> wl_rssi_level */
u8 cn; /* condition_num */
u8 train_status; /* [7:4]-> train-state, [3:0]-> train-phase */
u8 train_result; /* refer to enum btc_fddt_check_map */
} __packed;
struct rtw89_btc_fbtc_fddt_cell_status {
s8 wl_tx_pwr;
s8 bt_tx_pwr;
s8 bt_rx_gain;
u8 state_phase; /* [0:3] train state, [4:7] train phase */
} __packed;
struct rtw89_btc_fbtc_cysta_v3 { /* statistics for cycles */
u8 fver;
u8 rsvd;
__le16 cycles; /* total cycle number */
__le16 slot_step_time[BTC_CYCLE_SLOT_MAX];
struct rtw89_btc_fbtc_cycle_time_info cycle_time;
struct rtw89_btc_fbtc_fdd_try_info fdd_try;
struct rtw89_btc_fbtc_cycle_a2dp_empty_info a2dp_ept;
struct rtw89_btc_fbtc_a2dp_trx_stat a2dp_trx[BTC_CYCLE_SLOT_MAX];
struct rtw89_btc_fbtc_cycle_leak_info leak_slot;
__le32 slot_cnt[CXST_MAX]; /* slot count */
__le32 bcn_cnt[CXBCN_MAX];
__le32 collision_cnt; /* counter for event/timer occur at the same time */
__le32 skip_cnt;
__le32 except_cnt;
__le32 except_map;
} __packed;
#define FDD_TRAIN_WL_DIRECTION 2
#define FDD_TRAIN_WL_RSSI_LEVEL 5
#define FDD_TRAIN_BT_RSSI_LEVEL 5
struct rtw89_btc_fbtc_cysta_v4 { /* statistics for cycles */
u8 fver;
u8 rsvd;
u8 collision_cnt; /* counter for event/timer occur at the same time */
u8 except_cnt;
__le16 skip_cnt;
__le16 cycles; /* total cycle number */
__le16 slot_step_time[BTC_CYCLE_SLOT_MAX]; /* record the wl/bt slot time */
__le16 slot_cnt[CXST_MAX]; /* slot count */
__le16 bcn_cnt[CXBCN_MAX];
struct rtw89_btc_fbtc_cycle_time_info cycle_time;
struct rtw89_btc_fbtc_cycle_leak_info leak_slot;
struct rtw89_btc_fbtc_cycle_a2dp_empty_info a2dp_ept;
struct rtw89_btc_fbtc_a2dp_trx_stat_v4 a2dp_trx[BTC_CYCLE_SLOT_MAX];
struct rtw89_btc_fbtc_cycle_fddt_info fddt_trx[BTC_CYCLE_SLOT_MAX];
struct rtw89_btc_fbtc_fddt_cell_status fddt_cells[FDD_TRAIN_WL_DIRECTION]
[FDD_TRAIN_WL_RSSI_LEVEL]
[FDD_TRAIN_BT_RSSI_LEVEL];
__le32 except_map;
} __packed;
struct rtw89_btc_fbtc_cysta_v5 { /* statistics for cycles */
u8 fver;
u8 rsvd;
u8 collision_cnt; /* counter for event/timer occur at the same time */
u8 except_cnt;
u8 wl_rx_err_ratio[BTC_CYCLE_SLOT_MAX];
__le16 skip_cnt;
__le16 cycles; /* total cycle number */
__le16 slot_step_time[BTC_CYCLE_SLOT_MAX]; /* record the wl/bt slot time */
__le16 slot_cnt[CXST_MAX]; /* slot count */
__le16 bcn_cnt[CXBCN_MAX];
struct rtw89_btc_fbtc_cycle_time_info_v5 cycle_time;
struct rtw89_btc_fbtc_cycle_leak_info leak_slot;
struct rtw89_btc_fbtc_cycle_a2dp_empty_info a2dp_ept;
struct rtw89_btc_fbtc_a2dp_trx_stat_v4 a2dp_trx[BTC_CYCLE_SLOT_MAX];
struct rtw89_btc_fbtc_cycle_fddt_info_v5 fddt_trx[BTC_CYCLE_SLOT_MAX];
struct rtw89_btc_fbtc_fddt_cell_status fddt_cells[FDD_TRAIN_WL_DIRECTION]
[FDD_TRAIN_WL_RSSI_LEVEL]
[FDD_TRAIN_BT_RSSI_LEVEL];
__le32 except_map;
} __packed;
struct rtw89_btc_fbtc_cysta_v7 { /* statistics for cycles */
u8 fver;
u8 rsvd;
u8 collision_cnt; /* counter for event/timer occur at the same time */
u8 except_cnt;
u8 wl_rx_err_ratio[BTC_CYCLE_SLOT_MAX];
struct rtw89_btc_fbtc_a2dp_trx_stat_v4 a2dp_trx[BTC_CYCLE_SLOT_MAX];
__le16 skip_cnt;
__le16 cycles; /* total cycle number */
__le16 slot_step_time[BTC_CYCLE_SLOT_MAX]; /* record the wl/bt slot time */
__le16 slot_cnt[CXST_MAX]; /* slot count */
__le16 bcn_cnt[CXBCN_MAX];
struct rtw89_btc_fbtc_cycle_time_info_v5 cycle_time;
struct rtw89_btc_fbtc_cycle_a2dp_empty_info a2dp_ept;
struct rtw89_btc_fbtc_cycle_leak_info_v7 leak_slot;
__le32 except_map;
} __packed;
union rtw89_btc_fbtc_cysta_info {
struct rtw89_btc_fbtc_cysta_v2 v2;
struct rtw89_btc_fbtc_cysta_v3 v3;
struct rtw89_btc_fbtc_cysta_v4 v4;
struct rtw89_btc_fbtc_cysta_v5 v5;
struct rtw89_btc_fbtc_cysta_v7 v7;
};
struct rtw89_btc_fbtc_cynullsta_v1 { /* cycle null statistics */
u8 fver; /* btc_ver::fcxnullsta */
u8 rsvd;
__le16 rsvd2;
__le32 max_t[2]; /* max_t for 0:null0/1:null1 */
__le32 avg_t[2]; /* avg_t for 0:null0/1:null1 */
__le32 result[2][4]; /* 0:fail, 1:ok, 2:on_time, 3:retry */
} __packed;
struct rtw89_btc_fbtc_cynullsta_v2 { /* cycle null statistics */
u8 fver; /* btc_ver::fcxnullsta */
u8 rsvd;
__le16 rsvd2;
__le32 max_t[2]; /* max_t for 0:null0/1:null1 */
__le32 avg_t[2]; /* avg_t for 0:null0/1:null1 */
__le32 result[2][5]; /* 0:fail, 1:ok, 2:on_time, 3:retry, 4:tx */
} __packed;
struct rtw89_btc_fbtc_cynullsta_v7 { /* cycle null statistics */
u8 fver;
u8 rsvd0;
u8 rsvd1;
u8 rsvd2;
__le32 tmax[2];
__le32 tavg[2];
__le32 result[2][5];
} __packed;
union rtw89_btc_fbtc_cynullsta_info {
struct rtw89_btc_fbtc_cynullsta_v1 v1; /* info from fw */
struct rtw89_btc_fbtc_cynullsta_v2 v2;
struct rtw89_btc_fbtc_cynullsta_v7 v7;
};
struct rtw89_btc_fbtc_btver_v1 {
u8 fver; /* btc_ver::fcxbtver */
u8 rsvd;
__le16 rsvd2;
__le32 coex_ver; /*bit[15:8]->shared, bit[7:0]->non-shared */
__le32 fw_ver;
__le32 feature;
} __packed;
struct rtw89_btc_fbtc_btver_v7 {
u8 fver;
u8 rsvd0;
u8 rsvd1;
u8 rsvd2;
__le32 coex_ver; /*bit[15:8]->shared, bit[7:0]->non-shared */
__le32 fw_ver;
__le32 feature;
} __packed;
union rtw89_btc_fbtc_btver {
struct rtw89_btc_fbtc_btver_v1 v1;
struct rtw89_btc_fbtc_btver_v7 v7;
} __packed;
struct rtw89_btc_fbtc_btafh {
u8 fver; /* btc_ver::fcxbtafh */
u8 rsvd;
__le16 rsvd2;
u8 afh_l[4]; /*bit0:2402, bit1: 2403.... bit31:2433 */
u8 afh_m[4]; /*bit0:2434, bit1: 2435.... bit31:2465 */
u8 afh_h[4]; /*bit0:2466, bit1:2467......bit14:2480 */
} __packed;
struct rtw89_btc_fbtc_btafh_v2 {
u8 fver; /* btc_ver::fcxbtafh */
u8 rsvd;
u8 rsvd2;
u8 map_type;
u8 afh_l[4];
u8 afh_m[4];
u8 afh_h[4];
u8 afh_le_a[4];
u8 afh_le_b[4];
} __packed;
struct rtw89_btc_fbtc_btafh_v7 {
u8 fver;
u8 map_type;
u8 rsvd0;
u8 rsvd1;
u8 afh_l[4]; /*bit0:2402, bit1:2403.... bit31:2433 */
u8 afh_m[4]; /*bit0:2434, bit1:2435.... bit31:2465 */
u8 afh_h[4]; /*bit0:2466, bit1:2467.....bit14:2480 */
u8 afh_le_a[4];
u8 afh_le_b[4];
} __packed;
struct rtw89_btc_fbtc_btdevinfo {
u8 fver; /* btc_ver::fcxbtdevinfo */
u8 rsvd;
__le16 vendor_id;
__le32 dev_name; /* only 24 bits valid */
__le32 flush_time;
} __packed;
#define RTW89_BTC_WL_DEF_TX_PWR GENMASK(7, 0)
struct rtw89_btc_rf_trx_para {
u32 wl_tx_power; /* absolute Tx power (dBm), 0xff-> no BTC control */
u32 wl_rx_gain; /* rx gain table index (TBD.) */
u8 bt_tx_power; /* decrease Tx power (dB) */
u8 bt_rx_gain; /* LNA constrain level */
};
struct rtw89_btc_trx_info {
u8 tx_lvl;
u8 rx_lvl;
u8 wl_rssi;
u8 bt_rssi;
s8 tx_power; /* absolute Tx power (dBm), 0xff-> no BTC control */
s8 rx_gain; /* rx gain table index (TBD.) */
s8 bt_tx_power; /* decrease Tx power (dB) */
s8 bt_rx_gain; /* LNA constrain level */
u8 cn; /* condition_num */
s8 nhm;
u8 bt_profile;
u8 rsvd2;
u16 tx_rate;
u16 rx_rate;
u32 tx_tp;
u32 rx_tp;
u32 rx_err_ratio;
};
union rtw89_btc_fbtc_slot_u {
struct rtw89_btc_fbtc_slot v1[CXST_MAX];
struct rtw89_btc_fbtc_slot_v7 v7[CXST_MAX];
};
struct rtw89_btc_dm {
union rtw89_btc_fbtc_slot_u slot;
union rtw89_btc_fbtc_slot_u slot_now;
struct rtw89_btc_fbtc_tdma tdma;
struct rtw89_btc_fbtc_tdma tdma_now;
struct rtw89_mac_ax_coex_gnt gnt;
union rtw89_btc_init_info_u init_info; /* pass to wl_fw if offload */
struct rtw89_btc_rf_trx_para rf_trx_para;
struct rtw89_btc_wl_tx_limit_para wl_tx_limit;
struct rtw89_btc_dm_step dm_step;
struct rtw89_btc_wl_scc_ctrl wl_scc;
struct rtw89_btc_trx_info trx_info;
union rtw89_btc_dm_error_map error;
u32 cnt_dm[BTC_DCNT_NUM];
u32 cnt_notify[BTC_NCNT_NUM];
u32 update_slot_map;
u32 set_ant_path;
u32 e2g_slot_limit;
u32 e2g_slot_nulltx_time;
u32 wl_only: 1;
u32 wl_fw_cx_offload: 1;
u32 freerun: 1;
u32 fddt_train: 1;
u32 wl_ps_ctrl: 2;
u32 wl_mimo_ps: 1;
u32 leak_ap: 1;
u32 noisy_level: 3;
u32 coex_info_map: 8;
u32 bt_only: 1;
u32 wl_btg_rx: 2;
u32 trx_para_level: 8;
u32 wl_stb_chg: 1;
u32 pta_owner: 1;
u32 tdma_instant_excute: 1;
u32 wl_btg_rx_rb: 2;
u16 slot_dur[CXST_MAX];
u16 bt_slot_flood;
u8 run_reason;
u8 run_action;
u8 wl_pre_agc: 2;
u8 wl_lna2: 1;
u8 freerun_chk: 1;
u8 wl_pre_agc_rb: 2;
u8 bt_select: 2; /* 0:s0, 1:s1, 2:s0 & s1, refer to enum btc_bt_index */
u8 slot_req_more: 1;
};
struct rtw89_btc_ctrl {
u32 manual: 1;
u32 igno_bt: 1;
u32 always_freerun: 1;
u32 trace_step: 16;
u32 rsvd: 12;
};
struct rtw89_btc_ctrl_v7 {
u8 manual;
u8 igno_bt;
u8 always_freerun;
u8 rsvd;
} __packed;
union rtw89_btc_ctrl_list {
struct rtw89_btc_ctrl ctrl;
struct rtw89_btc_ctrl_v7 ctrl_v7;
};
struct rtw89_btc_dbg {
/* cmd "rb" */
bool rb_done;
u32 rb_val;
};
enum rtw89_btc_btf_fw_event {
BTF_EVNT_RPT = 0,
BTF_EVNT_BT_INFO = 1,
BTF_EVNT_BT_SCBD = 2,
BTF_EVNT_BT_REG = 3,
BTF_EVNT_CX_RUNINFO = 4,
BTF_EVNT_BT_PSD = 5,
BTF_EVNT_BT_DEV_INFO = 6, /* fwc2hfunc > 0 */
BTF_EVNT_BT_LEAUDIO_INFO = 7, /* fwc2hfunc > 1 */
BTF_EVNT_BUF_OVERFLOW,
BTF_EVNT_C2H_LOOPBACK,
BTF_EVNT_MAX,
};
enum btf_fw_event_report {
BTC_RPT_TYPE_CTRL = 0x0,
BTC_RPT_TYPE_TDMA,
BTC_RPT_TYPE_SLOT,
BTC_RPT_TYPE_CYSTA,
BTC_RPT_TYPE_STEP,
BTC_RPT_TYPE_NULLSTA,
BTC_RPT_TYPE_FDDT, /* added by ver->fwevntrptl == 1 */
BTC_RPT_TYPE_MREG,
BTC_RPT_TYPE_GPIO_DBG,
BTC_RPT_TYPE_BT_VER,
BTC_RPT_TYPE_BT_SCAN,
BTC_RPT_TYPE_BT_AFH,
BTC_RPT_TYPE_BT_DEVICE,
BTC_RPT_TYPE_TEST,
BTC_RPT_TYPE_MAX = 31,
__BTC_RPT_TYPE_V0_SAME = BTC_RPT_TYPE_NULLSTA,
__BTC_RPT_TYPE_V0_MAX = 12,
};
enum rtw_btc_btf_reg_type {
REG_MAC = 0x0,
REG_BB = 0x1,
REG_RF = 0x2,
REG_BT_RF = 0x3,
REG_BT_MODEM = 0x4,
REG_BT_BLUEWIZE = 0x5,
REG_BT_VENDOR = 0x6,
REG_BT_LE = 0x7,
REG_MAX_TYPE,
};
struct rtw89_btc_rpt_cmn_info {
u32 rx_cnt;
u32 rx_len;
u32 req_len; /* expected rsp len */
u8 req_fver; /* expected rsp fver */
u8 rsp_fver; /* fver from fw */
u8 valid;
} __packed;
union rtw89_btc_fbtc_btafh_info {
struct rtw89_btc_fbtc_btafh v1;
struct rtw89_btc_fbtc_btafh_v2 v2;
struct rtw89_btc_fbtc_btafh_v7 v7;
};
struct rtw89_btc_report_ctrl_state {
struct rtw89_btc_rpt_cmn_info cinfo; /* common info, by driver */
union rtw89_btc_fbtc_rpt_ctrl_ver_info finfo;
};
struct rtw89_btc_rpt_fbtc_tdma {
struct rtw89_btc_rpt_cmn_info cinfo; /* common info, by driver */
union rtw89_btc_fbtc_tdma_le32 finfo;
};
struct rtw89_btc_rpt_fbtc_slots {
struct rtw89_btc_rpt_cmn_info cinfo; /* common info, by driver */
union rtw89_btc_fbtc_slots_info finfo; /* info from fw */
};
struct rtw89_btc_rpt_fbtc_cysta {
struct rtw89_btc_rpt_cmn_info cinfo; /* common info, by driver */
union rtw89_btc_fbtc_cysta_info finfo;
};
struct rtw89_btc_rpt_fbtc_step {
struct rtw89_btc_rpt_cmn_info cinfo; /* common info, by driver */
union rtw89_btc_fbtc_steps_info finfo; /* info from fw */
};
struct rtw89_btc_rpt_fbtc_nullsta {
struct rtw89_btc_rpt_cmn_info cinfo; /* common info, by driver */
union rtw89_btc_fbtc_cynullsta_info finfo;
};
struct rtw89_btc_rpt_fbtc_mreg {
struct rtw89_btc_rpt_cmn_info cinfo; /* common info, by driver */
union rtw89_btc_fbtc_mreg_val finfo; /* info from fw */
};
struct rtw89_btc_rpt_fbtc_gpio_dbg {
struct rtw89_btc_rpt_cmn_info cinfo; /* common info, by driver */
union rtw89_btc_fbtc_gpio_dbg finfo; /* info from fw */
};
struct rtw89_btc_rpt_fbtc_btver {
struct rtw89_btc_rpt_cmn_info cinfo; /* common info, by driver */
union rtw89_btc_fbtc_btver finfo; /* info from fw */
};
struct rtw89_btc_rpt_fbtc_btscan {
struct rtw89_btc_rpt_cmn_info cinfo; /* common info, by driver */
union rtw89_btc_fbtc_btscan finfo; /* info from fw */
};
struct rtw89_btc_rpt_fbtc_btafh {
struct rtw89_btc_rpt_cmn_info cinfo; /* common info, by driver */
union rtw89_btc_fbtc_btafh_info finfo;
};
struct rtw89_btc_rpt_fbtc_btdev {
struct rtw89_btc_rpt_cmn_info cinfo; /* common info, by driver */
struct rtw89_btc_fbtc_btdevinfo finfo; /* info from fw */
};
enum rtw89_btc_btfre_type {
BTFRE_INVALID_INPUT = 0x0, /* invalid input parameters */
BTFRE_UNDEF_TYPE,
BTFRE_EXCEPTION,
BTFRE_MAX,
};
struct rtw89_btc_btf_fwinfo {
u32 cnt_c2h;
u32 cnt_h2c;
u32 cnt_h2c_fail;
u32 event[BTF_EVNT_MAX];
u32 err[BTFRE_MAX];
u32 len_mismch;
u32 fver_mismch;
u32 rpt_en_map;
struct rtw89_btc_report_ctrl_state rpt_ctrl;
struct rtw89_btc_rpt_fbtc_tdma rpt_fbtc_tdma;
struct rtw89_btc_rpt_fbtc_slots rpt_fbtc_slots;
struct rtw89_btc_rpt_fbtc_cysta rpt_fbtc_cysta;
struct rtw89_btc_rpt_fbtc_step rpt_fbtc_step;
struct rtw89_btc_rpt_fbtc_nullsta rpt_fbtc_nullsta;
struct rtw89_btc_rpt_fbtc_mreg rpt_fbtc_mregval;
struct rtw89_btc_rpt_fbtc_gpio_dbg rpt_fbtc_gpio_dbg;
struct rtw89_btc_rpt_fbtc_btver rpt_fbtc_btver;
struct rtw89_btc_rpt_fbtc_btscan rpt_fbtc_btscan;
struct rtw89_btc_rpt_fbtc_btafh rpt_fbtc_btafh;
struct rtw89_btc_rpt_fbtc_btdev rpt_fbtc_btdev;
};
struct rtw89_btc_ver {
enum rtw89_core_chip_id chip_id;
u32 fw_ver_code;
u8 fcxbtcrpt;
u8 fcxtdma;
u8 fcxslots;
u8 fcxcysta;
u8 fcxstep;
u8 fcxnullsta;
u8 fcxmreg;
u8 fcxgpiodbg;
u8 fcxbtver;
u8 fcxbtscan;
u8 fcxbtafh;
u8 fcxbtdevinfo;
u8 fwlrole;
u8 frptmap;
u8 fcxctrl;
u8 fcxinit;
u8 fwevntrptl;
u8 fwc2hfunc;
u8 drvinfo_type;
u16 info_buf;
u8 max_role_num;
};
#define RTW89_BTC_POLICY_MAXLEN 512
struct rtw89_btc {
const struct rtw89_btc_ver *ver;
struct rtw89_btc_cx cx;
struct rtw89_btc_dm dm;
union rtw89_btc_ctrl_list ctrl;
union rtw89_btc_module_info mdinfo;
struct rtw89_btc_btf_fwinfo fwinfo;
struct rtw89_btc_dbg dbg;
struct wiphy_work eapol_notify_work;
struct wiphy_work arp_notify_work;
struct wiphy_work dhcp_notify_work;
struct wiphy_work icmp_notify_work;
u32 bt_req_len;
u8 policy[RTW89_BTC_POLICY_MAXLEN];
u8 ant_type;
u8 btg_pos;
u16 policy_len;
u16 policy_type;
u32 hubmsg_cnt;
bool bt_req_en;
bool update_policy_force;
bool lps;
bool manual_ctrl;
};
enum rtw89_btc_hmsg {
RTW89_BTC_HMSG_TMR_EN = 0x0,
RTW89_BTC_HMSG_BT_REG_READBACK = 0x1,
RTW89_BTC_HMSG_SET_BT_REQ_SLOT = 0x2,
RTW89_BTC_HMSG_FW_EV = 0x3,
RTW89_BTC_HMSG_BT_LINK_CHG = 0x4,
RTW89_BTC_HMSG_SET_BT_REQ_STBC = 0x5,
NUM_OF_RTW89_BTC_HMSG,
};
enum rtw89_ra_mode {
RTW89_RA_MODE_CCK = BIT(0),
RTW89_RA_MODE_OFDM = BIT(1),
RTW89_RA_MODE_HT = BIT(2),
RTW89_RA_MODE_VHT = BIT(3),
RTW89_RA_MODE_HE = BIT(4),
RTW89_RA_MODE_EHT = BIT(5),
};
enum rtw89_ra_report_mode {
RTW89_RA_RPT_MODE_LEGACY,
RTW89_RA_RPT_MODE_HT,
RTW89_RA_RPT_MODE_VHT,
RTW89_RA_RPT_MODE_HE,
RTW89_RA_RPT_MODE_EHT,
};
enum rtw89_dig_noisy_level {
RTW89_DIG_NOISY_LEVEL0 = -1,
RTW89_DIG_NOISY_LEVEL1 = 0,
RTW89_DIG_NOISY_LEVEL2 = 1,
RTW89_DIG_NOISY_LEVEL3 = 2,
RTW89_DIG_NOISY_LEVEL_MAX = 3,
};
enum rtw89_gi_ltf {
RTW89_GILTF_LGI_4XHE32 = 0,
RTW89_GILTF_SGI_4XHE08 = 1,
RTW89_GILTF_2XHE16 = 2,
RTW89_GILTF_2XHE08 = 3,
RTW89_GILTF_1XHE16 = 4,
RTW89_GILTF_1XHE08 = 5,
RTW89_GILTF_MAX
};
enum rtw89_rx_frame_type {
RTW89_RX_TYPE_MGNT = 0,
RTW89_RX_TYPE_CTRL = 1,
RTW89_RX_TYPE_DATA = 2,
RTW89_RX_TYPE_RSVD = 3,
};
enum rtw89_efuse_block {
RTW89_EFUSE_BLOCK_SYS = 0,
RTW89_EFUSE_BLOCK_RF = 1,
RTW89_EFUSE_BLOCK_HCI_DIG_PCIE_SDIO = 2,
RTW89_EFUSE_BLOCK_HCI_DIG_USB = 3,
RTW89_EFUSE_BLOCK_HCI_PHY_PCIE = 4,
RTW89_EFUSE_BLOCK_HCI_PHY_USB3 = 5,
RTW89_EFUSE_BLOCK_HCI_PHY_USB2 = 6,
RTW89_EFUSE_BLOCK_ADIE = 7,
RTW89_EFUSE_BLOCK_NUM,
RTW89_EFUSE_BLOCK_IGNORE,
};
struct rtw89_ra_info {
u8 is_dis_ra:1;
/* Bit0 : CCK
* Bit1 : OFDM
* Bit2 : HT
* Bit3 : VHT
* Bit4 : HE
* Bit5 : EHT
*/
u8 mode_ctrl:6;
u8 bw_cap:3; /* enum rtw89_bandwidth */
u8 macid;
u8 dcm_cap:1;
u8 er_cap:1;
u8 init_rate_lv:2;
u8 upd_all:1;
u8 en_sgi:1;
u8 ldpc_cap:1;
u8 stbc_cap:1;
u8 ss_num:3;
u8 giltf:3;
u8 upd_bw_nss_mask:1;
u8 upd_mask:1;
u64 ra_mask; /* 63 bits ra_mask + 1 bit CSI ctrl */
/* BFee CSI */
u8 band_num;
u8 ra_csi_rate_en:1;
u8 fixed_csi_rate_en:1;
u8 cr_tbl_sel:1;
u8 fix_giltf_en:1;
u8 fix_giltf:3;
u8 rsvd2:1;
u8 csi_mcs_ss_idx;
u8 csi_mode:2;
u8 csi_gi_ltf:3;
u8 csi_bw:3;
};
#define RTW89_PPDU_MAC_INFO_USR_SIZE 4
#define RTW89_PPDU_MAC_INFO_SIZE 8
#define RTW89_PPDU_MAC_RX_CNT_SIZE 96
#define RTW89_PPDU_MAC_RX_CNT_SIZE_V1 128
#define RTW89_MAX_RX_AGG_NUM 64
#define RTW89_MAX_TX_AGG_NUM 128
struct rtw89_ampdu_params {
u16 agg_num;
bool amsdu;
};
struct rtw89_ra_report {
struct rate_info txrate;
u32 bit_rate;
u16 hw_rate;
bool might_fallback_legacy;
};
DECLARE_EWMA(rssi, 10, 16);
DECLARE_EWMA(evm, 10, 16);
DECLARE_EWMA(snr, 10, 16);
struct rtw89_ba_cam_entry {
struct list_head list;
u8 tid;
};
#define RTW89_MAX_ADDR_CAM_NUM 128
#define RTW89_MAX_BSSID_CAM_NUM 20
#define RTW89_MAX_SEC_CAM_NUM 128
#define RTW89_MAX_BA_CAM_NUM 24
#define RTW89_SEC_CAM_IN_ADDR_CAM 7
struct rtw89_addr_cam_entry {
u8 addr_cam_idx;
u8 offset;
u8 len;
u8 valid : 1;
u8 addr_mask : 6;
u8 wapi : 1;
u8 mask_sel : 2;
u8 bssid_cam_idx: 6;
u8 sec_ent_mode;
DECLARE_BITMAP(sec_cam_map, RTW89_SEC_CAM_IN_ADDR_CAM);
u8 sec_ent_keyid[RTW89_SEC_CAM_IN_ADDR_CAM];
u8 sec_ent[RTW89_SEC_CAM_IN_ADDR_CAM];
};
struct rtw89_bssid_cam_entry {
u8 bssid[ETH_ALEN];
u8 phy_idx;
u8 bssid_cam_idx;
u8 offset;
u8 len;
u8 valid : 1;
u8 num;
};
struct rtw89_sec_cam_entry {
u8 sec_cam_idx;
u8 offset;
u8 len;
u8 type : 4;
u8 ext_key : 1;
u8 spp_mode : 1;
/* 256 bits */
u8 key[32];
struct ieee80211_key_conf *key_conf;
};
struct rtw89_sta_link {
struct rtw89_sta *rtwsta;
struct list_head dlink_schd;
unsigned int link_id;
u8 mac_id;
bool er_cap;
struct rtw89_vif_link *rtwvif_link;
struct rtw89_ra_info ra;
struct rtw89_ra_report ra_report;
int max_agg_wait;
u8 prev_rssi;
struct ewma_rssi avg_rssi;
struct ewma_rssi rssi[RF_PATH_MAX];
struct ewma_snr avg_snr;
struct ewma_evm evm_1ss;
struct ewma_evm evm_min[RF_PATH_MAX];
struct ewma_evm evm_max[RF_PATH_MAX];
struct ieee80211_rx_status rx_status;
u16 rx_hw_rate;
__le32 htc_template;
struct rtw89_addr_cam_entry addr_cam; /* AP mode or TDLS peer only */
struct rtw89_bssid_cam_entry bssid_cam; /* TDLS peer only */
struct list_head ba_cam_list;
bool use_cfg_mask;
struct cfg80211_bitrate_mask mask;
bool cctl_tx_time;
u32 ampdu_max_time:4;
bool cctl_tx_retry_limit;
u32 data_tx_cnt_lmt:6;
};
struct rtw89_efuse {
bool valid;
bool power_k_valid;
u8 xtal_cap;
u8 addr[ETH_ALEN];
u8 rfe_type;
char country_code[2];
};
struct rtw89_phy_rate_pattern {
u64 ra_mask;
u16 rate;
u8 ra_mode;
bool enable;
};
struct rtw89_tx_wait_info {
struct rcu_head rcu_head;
struct completion completion;
bool tx_done;
};
struct rtw89_tx_skb_data {
struct rtw89_tx_wait_info __rcu *wait;
u8 hci_priv[];
};
#define RTW89_ROC_IDLE_TIMEOUT 500
#define RTW89_ROC_TX_TIMEOUT 30
enum rtw89_roc_state {
RTW89_ROC_IDLE,
RTW89_ROC_NORMAL,
RTW89_ROC_MGMT,
};
struct rtw89_roc {
struct ieee80211_channel chan;
struct wiphy_delayed_work roc_work;
enum ieee80211_roc_type type;
enum rtw89_roc_state state;
int duration;
unsigned int link_id;
};
#define RTW89_P2P_MAX_NOA_NUM 2
struct rtw89_p2p_ie_head {
u8 eid;
u8 ie_len;
u8 oui[3];
u8 oui_type;
} __packed;
struct rtw89_noa_attr_head {
u8 attr_type;
__le16 attr_len;
u8 index;
u8 oppps_ctwindow;
} __packed;
struct rtw89_p2p_noa_ie {
struct rtw89_p2p_ie_head p2p_head;
struct rtw89_noa_attr_head noa_head;
struct ieee80211_p2p_noa_desc noa_desc[RTW89_P2P_MAX_NOA_NUM];
} __packed;
struct rtw89_p2p_noa_setter {
struct rtw89_p2p_noa_ie ie;
u8 noa_count;
u8 noa_index;
};
struct rtw89_ps_noa_once_handler {
bool in_duration;
u64 tsf_begin;
u64 tsf_end;
struct wiphy_delayed_work set_work;
struct wiphy_delayed_work clr_work;
};
struct rtw89_vif_link {
struct rtw89_vif *rtwvif;
struct list_head dlink_schd;
unsigned int link_id;
bool chanctx_assigned; /* only valid when running with chanctx_ops */
enum rtw89_chanctx_idx chanctx_idx;
enum rtw89_reg_6ghz_power reg_6ghz_power;
struct rtw89_reg_6ghz_tpe reg_6ghz_tpe;
u8 mac_id;
u8 port;
u8 mac_addr[ETH_ALEN];
u8 bssid[ETH_ALEN];
u8 phy_idx;
u8 mac_idx;
u8 net_type;
u8 wifi_role;
u8 self_role;
u8 wmm;
u8 bcn_hit_cond;
u8 bcn_bw_idx;
u8 hit_rule;
u8 last_noa_nr;
u64 sync_bcn_tsf;
bool rand_tsf_done;
bool trigger;
bool lsig_txop;
u8 tgt_ind;
u8 frm_tgt_ind;
bool wowlan_pattern;
bool wowlan_uc;
bool wowlan_magic;
bool is_hesta;
bool last_a_ctrl;
bool dyn_tb_bedge_en;
bool pre_pwr_diff_en;
bool pwr_diff_en;
u8 def_tri_idx;
struct wiphy_work update_beacon_work;
struct rtw89_addr_cam_entry addr_cam;
struct rtw89_bssid_cam_entry bssid_cam;
struct ieee80211_tx_queue_params tx_params[IEEE80211_NUM_ACS];
struct rtw89_phy_rate_pattern rate_pattern;
struct list_head general_pkt_list;
struct rtw89_p2p_noa_setter p2p_noa;
struct rtw89_ps_noa_once_handler noa_once;
};
enum rtw89_lv1_rcvy_step {
RTW89_LV1_RCVY_STEP_1,
RTW89_LV1_RCVY_STEP_2,
};
struct rtw89_hci_ops {
int (*tx_write)(struct rtw89_dev *rtwdev, struct rtw89_core_tx_request *tx_req);
void (*tx_kick_off)(struct rtw89_dev *rtwdev, u8 txch);
void (*flush_queues)(struct rtw89_dev *rtwdev, u32 queues, bool drop);
void (*reset)(struct rtw89_dev *rtwdev);
int (*start)(struct rtw89_dev *rtwdev);
void (*stop)(struct rtw89_dev *rtwdev);
void (*pause)(struct rtw89_dev *rtwdev, bool pause);
void (*switch_mode)(struct rtw89_dev *rtwdev, bool low_power);
void (*recalc_int_mit)(struct rtw89_dev *rtwdev);
u8 (*read8)(struct rtw89_dev *rtwdev, u32 addr);
u16 (*read16)(struct rtw89_dev *rtwdev, u32 addr);
u32 (*read32)(struct rtw89_dev *rtwdev, u32 addr);
void (*write8)(struct rtw89_dev *rtwdev, u32 addr, u8 data);
void (*write16)(struct rtw89_dev *rtwdev, u32 addr, u16 data);
void (*write32)(struct rtw89_dev *rtwdev, u32 addr, u32 data);
int (*mac_pre_init)(struct rtw89_dev *rtwdev);
int (*mac_pre_deinit)(struct rtw89_dev *rtwdev);
int (*mac_post_init)(struct rtw89_dev *rtwdev);
int (*deinit)(struct rtw89_dev *rtwdev);
u32 (*check_and_reclaim_tx_resource)(struct rtw89_dev *rtwdev, u8 txch);
int (*mac_lv1_rcvy)(struct rtw89_dev *rtwdev, enum rtw89_lv1_rcvy_step step);
void (*dump_err_status)(struct rtw89_dev *rtwdev);
int (*napi_poll)(struct napi_struct *napi, int budget);
/* Deal with locks inside recovery_start and recovery_complete callbacks
* by hci instance, and handle things which need to consider under SER.
* e.g. turn on/off interrupts except for the one for halt notification.
*/
void (*recovery_start)(struct rtw89_dev *rtwdev);
void (*recovery_complete)(struct rtw89_dev *rtwdev);
void (*ctrl_txdma_ch)(struct rtw89_dev *rtwdev, bool enable);
void (*ctrl_txdma_fw_ch)(struct rtw89_dev *rtwdev, bool enable);
void (*ctrl_trxhci)(struct rtw89_dev *rtwdev, bool enable);
int (*poll_txdma_ch_idle)(struct rtw89_dev *rtwdev);
void (*clr_idx_all)(struct rtw89_dev *rtwdev);
void (*clear)(struct rtw89_dev *rtwdev, struct pci_dev *pdev);
void (*disable_intr)(struct rtw89_dev *rtwdev);
void (*enable_intr)(struct rtw89_dev *rtwdev);
int (*rst_bdram)(struct rtw89_dev *rtwdev);
};
struct rtw89_hci_info {
const struct rtw89_hci_ops *ops;
enum rtw89_hci_type type;
u32 rpwm_addr;
u32 cpwm_addr;
bool paused;
};
struct rtw89_chip_ops {
int (*enable_bb_rf)(struct rtw89_dev *rtwdev);
int (*disable_bb_rf)(struct rtw89_dev *rtwdev);
void (*bb_preinit)(struct rtw89_dev *rtwdev, enum rtw89_phy_idx phy_idx);
void (*bb_postinit)(struct rtw89_dev *rtwdev, enum rtw89_phy_idx phy_idx);
void (*bb_reset)(struct rtw89_dev *rtwdev,
enum rtw89_phy_idx phy_idx);
void (*bb_sethw)(struct rtw89_dev *rtwdev);
u32 (*read_rf)(struct rtw89_dev *rtwdev, enum rtw89_rf_path rf_path,
u32 addr, u32 mask);
bool (*write_rf)(struct rtw89_dev *rtwdev, enum rtw89_rf_path rf_path,
u32 addr, u32 mask, u32 data);
void (*set_channel)(struct rtw89_dev *rtwdev,
const struct rtw89_chan *chan,
enum rtw89_mac_idx mac_idx,
enum rtw89_phy_idx phy_idx);
void (*set_channel_help)(struct rtw89_dev *rtwdev, bool enter,
struct rtw89_channel_help_params *p,
const struct rtw89_chan *chan,
enum rtw89_mac_idx mac_idx,
enum rtw89_phy_idx phy_idx);
int (*read_efuse)(struct rtw89_dev *rtwdev, u8 *log_map,
enum rtw89_efuse_block block);
int (*read_phycap)(struct rtw89_dev *rtwdev, u8 *phycap_map);
void (*fem_setup)(struct rtw89_dev *rtwdev);
void (*rfe_gpio)(struct rtw89_dev *rtwdev);
void (*rfk_hw_init)(struct rtw89_dev *rtwdev);
void (*rfk_init)(struct rtw89_dev *rtwdev);
void (*rfk_init_late)(struct rtw89_dev *rtwdev);
void (*rfk_channel)(struct rtw89_dev *rtwdev, struct rtw89_vif_link *rtwvif_link);
void (*rfk_band_changed)(struct rtw89_dev *rtwdev,
enum rtw89_phy_idx phy_idx,
const struct rtw89_chan *chan);
void (*rfk_scan)(struct rtw89_dev *rtwdev, struct rtw89_vif_link *rtwvif_link,
bool start);
void (*rfk_track)(struct rtw89_dev *rtwdev);
void (*power_trim)(struct rtw89_dev *rtwdev);
void (*set_txpwr)(struct rtw89_dev *rtwdev,
const struct rtw89_chan *chan,
enum rtw89_phy_idx phy_idx);
void (*set_txpwr_ctrl)(struct rtw89_dev *rtwdev,
enum rtw89_phy_idx phy_idx);
int (*init_txpwr_unit)(struct rtw89_dev *rtwdev, enum rtw89_phy_idx phy_idx);
u8 (*get_thermal)(struct rtw89_dev *rtwdev, enum rtw89_rf_path rf_path);
void (*ctrl_btg_bt_rx)(struct rtw89_dev *rtwdev, bool en,
enum rtw89_phy_idx phy_idx);
void (*query_ppdu)(struct rtw89_dev *rtwdev,
struct rtw89_rx_phy_ppdu *phy_ppdu,
struct ieee80211_rx_status *status);
void (*convert_rpl_to_rssi)(struct rtw89_dev *rtwdev,
struct rtw89_rx_phy_ppdu *phy_ppdu);
void (*phy_rpt_to_rssi)(struct rtw89_dev *rtwdev,
struct rtw89_rx_desc_info *desc_info,
struct ieee80211_rx_status *rx_status);
void (*ctrl_nbtg_bt_tx)(struct rtw89_dev *rtwdev, bool en,
enum rtw89_phy_idx phy_idx);
void (*cfg_txrx_path)(struct rtw89_dev *rtwdev);
void (*set_txpwr_ul_tb_offset)(struct rtw89_dev *rtwdev,
s8 pw_ofst, enum rtw89_mac_idx mac_idx);
void (*digital_pwr_comp)(struct rtw89_dev *rtwdev,
enum rtw89_phy_idx phy_idx);
int (*pwr_on_func)(struct rtw89_dev *rtwdev);
int (*pwr_off_func)(struct rtw89_dev *rtwdev);
void (*query_rxdesc)(struct rtw89_dev *rtwdev,
struct rtw89_rx_desc_info *desc_info,
u8 *data, u32 data_offset);
void (*fill_txdesc)(struct rtw89_dev *rtwdev,
struct rtw89_tx_desc_info *desc_info,
void *txdesc);
void (*fill_txdesc_fwcmd)(struct rtw89_dev *rtwdev,
struct rtw89_tx_desc_info *desc_info,
void *txdesc);
int (*cfg_ctrl_path)(struct rtw89_dev *rtwdev, bool wl);
int (*mac_cfg_gnt)(struct rtw89_dev *rtwdev,
const struct rtw89_mac_ax_coex_gnt *gnt_cfg);
int (*stop_sch_tx)(struct rtw89_dev *rtwdev, u8 mac_idx,
u32 *tx_en, enum rtw89_sch_tx_sel sel);
int (*resume_sch_tx)(struct rtw89_dev *rtwdev, u8 mac_idx, u32 tx_en);
int (*h2c_dctl_sec_cam)(struct rtw89_dev *rtwdev,
struct rtw89_vif_link *rtwvif_link,
struct rtw89_sta_link *rtwsta_link);
int (*h2c_default_cmac_tbl)(struct rtw89_dev *rtwdev,
struct rtw89_vif_link *rtwvif_link,
struct rtw89_sta_link *rtwsta_link);
int (*h2c_assoc_cmac_tbl)(struct rtw89_dev *rtwdev,
struct rtw89_vif_link *rtwvif_link,
struct rtw89_sta_link *rtwsta_link);
int (*h2c_ampdu_cmac_tbl)(struct rtw89_dev *rtwdev,
struct rtw89_vif_link *rtwvif_link,
struct rtw89_sta_link *rtwsta_link);
int (*h2c_txtime_cmac_tbl)(struct rtw89_dev *rtwdev,
struct rtw89_sta_link *rtwsta_link);
int (*h2c_default_dmac_tbl)(struct rtw89_dev *rtwdev,
struct rtw89_vif_link *rtwvif_link,
struct rtw89_sta_link *rtwsta_link);
int (*h2c_update_beacon)(struct rtw89_dev *rtwdev,
struct rtw89_vif_link *rtwvif_link);
int (*h2c_ba_cam)(struct rtw89_dev *rtwdev,
struct rtw89_vif_link *rtwvif_link,
struct rtw89_sta_link *rtwsta_link,
bool valid, struct ieee80211_ampdu_params *params);
void (*btc_set_rfe)(struct rtw89_dev *rtwdev);
void (*btc_init_cfg)(struct rtw89_dev *rtwdev);
void (*btc_set_wl_pri)(struct rtw89_dev *rtwdev, u8 map, bool state);
void (*btc_set_wl_txpwr_ctrl)(struct rtw89_dev *rtwdev, u32 txpwr_val);
s8 (*btc_get_bt_rssi)(struct rtw89_dev *rtwdev, s8 val);
void (*btc_update_bt_cnt)(struct rtw89_dev *rtwdev);
void (*btc_wl_s1_standby)(struct rtw89_dev *rtwdev, bool state);
void (*btc_set_policy)(struct rtw89_dev *rtwdev, u16 policy_type);
void (*btc_set_wl_rx_gain)(struct rtw89_dev *rtwdev, u32 level);
};
enum rtw89_dma_ch {
RTW89_DMA_ACH0 = 0,
RTW89_DMA_ACH1 = 1,
RTW89_DMA_ACH2 = 2,
RTW89_DMA_ACH3 = 3,
RTW89_DMA_ACH4 = 4,
RTW89_DMA_ACH5 = 5,
RTW89_DMA_ACH6 = 6,
RTW89_DMA_ACH7 = 7,
RTW89_DMA_B0MG = 8,
RTW89_DMA_B0HI = 9,
RTW89_DMA_B1MG = 10,
RTW89_DMA_B1HI = 11,
RTW89_DMA_H2C = 12,
RTW89_DMA_CH_NUM = 13
};
#define MLO_MODE_FOR_BB0_BB1_RF(bb0, bb1, rf) ((rf) << 12 | (bb1) << 4 | (bb0))
enum rtw89_mlo_dbcc_mode {
MLO_DBCC_NOT_SUPPORT = 1,
MLO_0_PLUS_2_1RF = MLO_MODE_FOR_BB0_BB1_RF(0, 2, 1),
MLO_0_PLUS_2_2RF = MLO_MODE_FOR_BB0_BB1_RF(0, 2, 2),
MLO_1_PLUS_1_1RF = MLO_MODE_FOR_BB0_BB1_RF(1, 1, 1),
MLO_1_PLUS_1_2RF = MLO_MODE_FOR_BB0_BB1_RF(1, 1, 2),
MLO_2_PLUS_0_1RF = MLO_MODE_FOR_BB0_BB1_RF(2, 0, 1),
MLO_2_PLUS_0_2RF = MLO_MODE_FOR_BB0_BB1_RF(2, 0, 2),
MLO_2_PLUS_2_2RF = MLO_MODE_FOR_BB0_BB1_RF(2, 2, 2),
DBCC_LEGACY = 0xffffffff,
};
enum rtw89_scan_be_operation {
RTW89_SCAN_OP_STOP,
RTW89_SCAN_OP_START,
RTW89_SCAN_OP_SETPARM,
RTW89_SCAN_OP_GETRPT,
RTW89_SCAN_OP_NUM
};
enum rtw89_scan_be_mode {
RTW89_SCAN_MODE_SA,
RTW89_SCAN_MODE_MACC,
RTW89_SCAN_MODE_NUM
};
enum rtw89_scan_be_opmode {
RTW89_SCAN_OPMODE_NONE,
RTW89_SCAN_OPMODE_TBTT,
RTW89_SCAN_OPMODE_INTV,
RTW89_SCAN_OPMODE_CNT,
RTW89_SCAN_OPMODE_NUM,
};
struct rtw89_scan_option {
bool enable;
bool target_ch_mode;
u8 num_macc_role;
u8 num_opch;
u8 repeat;
u16 norm_pd;
u16 slow_pd;
u16 norm_cy;
u8 opch_end;
u16 delay;
u64 prohib_chan;
enum rtw89_phy_idx band;
enum rtw89_scan_be_operation operation;
enum rtw89_scan_be_mode scan_mode;
enum rtw89_mlo_dbcc_mode mlo_mode;
};
enum rtw89_qta_mode {
RTW89_QTA_SCC,
RTW89_QTA_DBCC,
RTW89_QTA_DLFW,
RTW89_QTA_WOW,
/* keep last */
RTW89_QTA_INVALID,
};
struct rtw89_hfc_ch_cfg {
u16 min;
u16 max;
#define grp_0 0
#define grp_1 1
#define grp_num 2
u8 grp;
};
struct rtw89_hfc_ch_info {
u16 aval;
u16 used;
};
struct rtw89_hfc_pub_cfg {
u16 grp0;
u16 grp1;
u16 pub_max;
u16 wp_thrd;
};
struct rtw89_hfc_pub_info {
u16 g0_used;
u16 g1_used;
u16 g0_aval;
u16 g1_aval;
u16 pub_aval;
u16 wp_aval;
};
struct rtw89_hfc_prec_cfg {
u16 ch011_prec;
u16 h2c_prec;
u16 wp_ch07_prec;
u16 wp_ch811_prec;
u8 ch011_full_cond;
u8 h2c_full_cond;
u8 wp_ch07_full_cond;
u8 wp_ch811_full_cond;
};
struct rtw89_hfc_param {
bool en;
bool h2c_en;
u8 mode;
const struct rtw89_hfc_ch_cfg *ch_cfg;
struct rtw89_hfc_ch_info ch_info[RTW89_DMA_CH_NUM];
struct rtw89_hfc_pub_cfg pub_cfg;
struct rtw89_hfc_pub_info pub_info;
struct rtw89_hfc_prec_cfg prec_cfg;
};
struct rtw89_hfc_param_ini {
const struct rtw89_hfc_ch_cfg *ch_cfg;
const struct rtw89_hfc_pub_cfg *pub_cfg;
const struct rtw89_hfc_prec_cfg *prec_cfg;
u8 mode;
};
struct rtw89_dle_size {
u16 pge_size;
u16 lnk_pge_num;
u16 unlnk_pge_num;
/* for WiFi 7 chips below */
u32 srt_ofst;
};
struct rtw89_wde_quota {
u16 hif;
u16 wcpu;
u16 pkt_in;
u16 cpu_io;
};
struct rtw89_ple_quota {
u16 cma0_tx;
u16 cma1_tx;
u16 c2h;
u16 h2c;
u16 wcpu;
u16 mpdu_proc;
u16 cma0_dma;
u16 cma1_dma;
u16 bb_rpt;
u16 wd_rel;
u16 cpu_io;
u16 tx_rpt;
/* for WiFi 7 chips below */
u16 h2d;
};
struct rtw89_rsvd_quota {
u16 mpdu_info_tbl;
u16 b0_csi;
u16 b1_csi;
u16 b0_lmr;
u16 b1_lmr;
u16 b0_ftm;
u16 b1_ftm;
u16 b0_smr;
u16 b1_smr;
u16 others;
};
struct rtw89_dle_rsvd_size {
u32 srt_ofst;
u32 size;
};
struct rtw89_dle_mem {
enum rtw89_qta_mode mode;
const struct rtw89_dle_size *wde_size;
const struct rtw89_dle_size *ple_size;
const struct rtw89_wde_quota *wde_min_qt;
const struct rtw89_wde_quota *wde_max_qt;
const struct rtw89_ple_quota *ple_min_qt;
const struct rtw89_ple_quota *ple_max_qt;
/* for WiFi 7 chips below */
const struct rtw89_rsvd_quota *rsvd_qt;
const struct rtw89_dle_rsvd_size *rsvd0_size;
const struct rtw89_dle_rsvd_size *rsvd1_size;
};
struct rtw89_reg_def {
u32 addr;
u32 mask;
};
struct rtw89_reg2_def {
u32 addr;
u32 data;
};
struct rtw89_reg3_def {
u32 addr;
u32 mask;
u32 data;
};
struct rtw89_reg5_def {
u8 flag; /* recognized by parsers */
u8 path;
u32 addr;
u32 mask;
u32 data;
};
struct rtw89_reg_imr {
u32 addr;
u32 clr;
u32 set;
};
struct rtw89_phy_table {
const struct rtw89_reg2_def *regs;
u32 n_regs;
enum rtw89_rf_path rf_path;
void (*config)(struct rtw89_dev *rtwdev, const struct rtw89_reg2_def *reg,
enum rtw89_rf_path rf_path, void *data);
};
struct rtw89_txpwr_table {
const void *data;
u32 size;
void (*load)(struct rtw89_dev *rtwdev,
const struct rtw89_txpwr_table *tbl);
};
struct rtw89_txpwr_rule_2ghz {
const s8 (*lmt)[RTW89_2G_BW_NUM][RTW89_NTX_NUM]
[RTW89_RS_LMT_NUM][RTW89_BF_NUM]
[RTW89_REGD_NUM][RTW89_2G_CH_NUM];
const s8 (*lmt_ru)[RTW89_RU_NUM][RTW89_NTX_NUM]
[RTW89_REGD_NUM][RTW89_2G_CH_NUM];
};
struct rtw89_txpwr_rule_5ghz {
const s8 (*lmt)[RTW89_5G_BW_NUM][RTW89_NTX_NUM]
[RTW89_RS_LMT_NUM][RTW89_BF_NUM]
[RTW89_REGD_NUM][RTW89_5G_CH_NUM];
const s8 (*lmt_ru)[RTW89_RU_NUM][RTW89_NTX_NUM]
[RTW89_REGD_NUM][RTW89_5G_CH_NUM];
};
struct rtw89_txpwr_rule_6ghz {
const s8 (*lmt)[RTW89_6G_BW_NUM][RTW89_NTX_NUM]
[RTW89_RS_LMT_NUM][RTW89_BF_NUM]
[RTW89_REGD_NUM][NUM_OF_RTW89_REG_6GHZ_POWER]
[RTW89_6G_CH_NUM];
const s8 (*lmt_ru)[RTW89_RU_NUM][RTW89_NTX_NUM]
[RTW89_REGD_NUM][NUM_OF_RTW89_REG_6GHZ_POWER]
[RTW89_6G_CH_NUM];
};
struct rtw89_tx_shape {
const u8 (*lmt)[RTW89_BAND_NUM][RTW89_RS_TX_SHAPE_NUM][RTW89_REGD_NUM];
const u8 (*lmt_ru)[RTW89_BAND_NUM][RTW89_REGD_NUM];
};
struct rtw89_rfe_parms {
const struct rtw89_txpwr_table *byr_tbl;
struct rtw89_txpwr_rule_2ghz rule_2ghz;
struct rtw89_txpwr_rule_5ghz rule_5ghz;
struct rtw89_txpwr_rule_6ghz rule_6ghz;
struct rtw89_txpwr_rule_2ghz rule_da_2ghz;
struct rtw89_txpwr_rule_5ghz rule_da_5ghz;
struct rtw89_txpwr_rule_6ghz rule_da_6ghz;
struct rtw89_tx_shape tx_shape;
bool has_da;
};
struct rtw89_rfe_parms_conf {
const struct rtw89_rfe_parms *rfe_parms;
u8 rfe_type;
};
#define RTW89_TXPWR_CONF_DFLT_RFE_TYPE 0x0
struct rtw89_txpwr_conf {
u8 rfe_type;
u8 ent_sz;
u32 num_ents;
const void *data;
};
static inline bool rtw89_txpwr_entcpy(void *entry, const void *cursor, u8 size,
const struct rtw89_txpwr_conf *conf)
{
u8 valid_size = min(size, conf->ent_sz);
memcpy(entry, cursor, valid_size);
return true;
}
#define rtw89_txpwr_conf_valid(conf) (!!(conf)->data)
#define rtw89_for_each_in_txpwr_conf(entry, cursor, conf) \
for (typecheck(const void *, cursor), (cursor) = (conf)->data; \
(cursor) < (conf)->data + (conf)->num_ents * (conf)->ent_sz; \
(cursor) += (conf)->ent_sz) \
if (rtw89_txpwr_entcpy(&(entry), cursor, sizeof(entry), conf))
struct rtw89_txpwr_byrate_data {
struct rtw89_txpwr_conf conf;
struct rtw89_txpwr_table tbl;
};
struct rtw89_txpwr_lmt_2ghz_data {
struct rtw89_txpwr_conf conf;
s8 v[RTW89_2G_BW_NUM][RTW89_NTX_NUM]
[RTW89_RS_LMT_NUM][RTW89_BF_NUM]
[RTW89_REGD_NUM][RTW89_2G_CH_NUM];
};
struct rtw89_txpwr_lmt_5ghz_data {
struct rtw89_txpwr_conf conf;
s8 v[RTW89_5G_BW_NUM][RTW89_NTX_NUM]
[RTW89_RS_LMT_NUM][RTW89_BF_NUM]
[RTW89_REGD_NUM][RTW89_5G_CH_NUM];
};
struct rtw89_txpwr_lmt_6ghz_data {
struct rtw89_txpwr_conf conf;
s8 v[RTW89_6G_BW_NUM][RTW89_NTX_NUM]
[RTW89_RS_LMT_NUM][RTW89_BF_NUM]
[RTW89_REGD_NUM][NUM_OF_RTW89_REG_6GHZ_POWER]
[RTW89_6G_CH_NUM];
};
struct rtw89_txpwr_lmt_ru_2ghz_data {
struct rtw89_txpwr_conf conf;
s8 v[RTW89_RU_NUM][RTW89_NTX_NUM]
[RTW89_REGD_NUM][RTW89_2G_CH_NUM];
};
struct rtw89_txpwr_lmt_ru_5ghz_data {
struct rtw89_txpwr_conf conf;
s8 v[RTW89_RU_NUM][RTW89_NTX_NUM]
[RTW89_REGD_NUM][RTW89_5G_CH_NUM];
};
struct rtw89_txpwr_lmt_ru_6ghz_data {
struct rtw89_txpwr_conf conf;
s8 v[RTW89_RU_NUM][RTW89_NTX_NUM]
[RTW89_REGD_NUM][NUM_OF_RTW89_REG_6GHZ_POWER]
[RTW89_6G_CH_NUM];
};
struct rtw89_tx_shape_lmt_data {
struct rtw89_txpwr_conf conf;
u8 v[RTW89_BAND_NUM][RTW89_RS_TX_SHAPE_NUM][RTW89_REGD_NUM];
};
struct rtw89_tx_shape_lmt_ru_data {
struct rtw89_txpwr_conf conf;
u8 v[RTW89_BAND_NUM][RTW89_REGD_NUM];
};
struct rtw89_rfe_data {
struct rtw89_txpwr_byrate_data byrate;
struct rtw89_txpwr_lmt_2ghz_data lmt_2ghz;
struct rtw89_txpwr_lmt_5ghz_data lmt_5ghz;
struct rtw89_txpwr_lmt_6ghz_data lmt_6ghz;
struct rtw89_txpwr_lmt_2ghz_data da_lmt_2ghz;
struct rtw89_txpwr_lmt_5ghz_data da_lmt_5ghz;
struct rtw89_txpwr_lmt_6ghz_data da_lmt_6ghz;
struct rtw89_txpwr_lmt_ru_2ghz_data lmt_ru_2ghz;
struct rtw89_txpwr_lmt_ru_5ghz_data lmt_ru_5ghz;
struct rtw89_txpwr_lmt_ru_6ghz_data lmt_ru_6ghz;
struct rtw89_txpwr_lmt_ru_2ghz_data da_lmt_ru_2ghz;
struct rtw89_txpwr_lmt_ru_5ghz_data da_lmt_ru_5ghz;
struct rtw89_txpwr_lmt_ru_6ghz_data da_lmt_ru_6ghz;
struct rtw89_tx_shape_lmt_data tx_shape_lmt;
struct rtw89_tx_shape_lmt_ru_data tx_shape_lmt_ru;
struct rtw89_rfe_parms rfe_parms;
};
struct rtw89_page_regs {
u32 hci_fc_ctrl;
u32 ch_page_ctrl;
u32 ach_page_ctrl;
u32 ach_page_info;
u32 pub_page_info3;
u32 pub_page_ctrl1;
u32 pub_page_ctrl2;
u32 pub_page_info1;
u32 pub_page_info2;
u32 wp_page_ctrl1;
u32 wp_page_ctrl2;
u32 wp_page_info1;
};
struct rtw89_imr_info {
u32 wdrls_imr_set;
u32 wsec_imr_reg;
u32 wsec_imr_set;
u32 mpdu_tx_imr_set;
u32 mpdu_rx_imr_set;
u32 sta_sch_imr_set;
u32 txpktctl_imr_b0_reg;
u32 txpktctl_imr_b0_clr;
u32 txpktctl_imr_b0_set;
u32 txpktctl_imr_b1_reg;
u32 txpktctl_imr_b1_clr;
u32 txpktctl_imr_b1_set;
u32 wde_imr_clr;
u32 wde_imr_set;
u32 ple_imr_clr;
u32 ple_imr_set;
u32 host_disp_imr_clr;
u32 host_disp_imr_set;
u32 cpu_disp_imr_clr;
u32 cpu_disp_imr_set;
u32 other_disp_imr_clr;
u32 other_disp_imr_set;
u32 bbrpt_com_err_imr_reg;
u32 bbrpt_chinfo_err_imr_reg;
u32 bbrpt_err_imr_set;
u32 bbrpt_dfs_err_imr_reg;
u32 ptcl_imr_clr;
u32 ptcl_imr_set;
u32 cdma_imr_0_reg;
u32 cdma_imr_0_clr;
u32 cdma_imr_0_set;
u32 cdma_imr_1_reg;
u32 cdma_imr_1_clr;
u32 cdma_imr_1_set;
u32 phy_intf_imr_reg;
u32 phy_intf_imr_clr;
u32 phy_intf_imr_set;
u32 rmac_imr_reg;
u32 rmac_imr_clr;
u32 rmac_imr_set;
u32 tmac_imr_reg;
u32 tmac_imr_clr;
u32 tmac_imr_set;
};
struct rtw89_imr_table {
const struct rtw89_reg_imr *regs;
u32 n_regs;
};
struct rtw89_xtal_info {
u32 xcap_reg;
u32 sc_xo_mask;
u32 sc_xi_mask;
};
struct rtw89_rrsr_cfgs {
struct rtw89_reg3_def ref_rate;
struct rtw89_reg3_def rsc;
};
struct rtw89_rfkill_regs {
struct rtw89_reg3_def pinmux;
struct rtw89_reg3_def mode;
};
struct rtw89_dig_regs {
u32 seg0_pd_reg;
u32 pd_lower_bound_mask;
u32 pd_spatial_reuse_en;
u32 bmode_pd_reg;
u32 bmode_cca_rssi_limit_en;
u32 bmode_pd_lower_bound_reg;
u32 bmode_rssi_nocca_low_th_mask;
struct rtw89_reg_def p0_lna_init;
struct rtw89_reg_def p1_lna_init;
struct rtw89_reg_def p0_tia_init;
struct rtw89_reg_def p1_tia_init;
struct rtw89_reg_def p0_rxb_init;
struct rtw89_reg_def p1_rxb_init;
struct rtw89_reg_def p0_p20_pagcugc_en;
struct rtw89_reg_def p0_s20_pagcugc_en;
struct rtw89_reg_def p1_p20_pagcugc_en;
struct rtw89_reg_def p1_s20_pagcugc_en;
};
struct rtw89_edcca_regs {
u32 edcca_level;
u32 edcca_mask;
u32 edcca_p_mask;
u32 ppdu_level;
u32 ppdu_mask;
struct rtw89_edcca_p_regs {
u32 rpt_a;
u32 rpt_b;
u32 rpt_sel;
u32 rpt_sel_mask;
} p[RTW89_PHY_NUM];
u32 rpt_sel_be;
u32 rpt_sel_be_mask;
u32 tx_collision_t2r_st;
u32 tx_collision_t2r_st_mask;
};
struct rtw89_phy_ul_tb_info {
bool dyn_tb_tri_en;
u8 def_if_bandedge;
};
struct rtw89_antdiv_stats {
struct ewma_rssi cck_rssi_avg;
struct ewma_rssi ofdm_rssi_avg;
struct ewma_rssi non_legacy_rssi_avg;
u16 pkt_cnt_cck;
u16 pkt_cnt_ofdm;
u16 pkt_cnt_non_legacy;
u32 evm;
};
struct rtw89_antdiv_info {
struct rtw89_antdiv_stats target_stats;
struct rtw89_antdiv_stats main_stats;
struct rtw89_antdiv_stats aux_stats;
u8 training_count;
u8 rssi_pre;
bool get_stats;
};
enum rtw89_chanctx_state {
RTW89_CHANCTX_STATE_MCC_START,
RTW89_CHANCTX_STATE_MCC_STOP,
};
enum rtw89_chanctx_callbacks {
RTW89_CHANCTX_CALLBACK_PLACEHOLDER,
RTW89_CHANCTX_CALLBACK_RFK,
RTW89_CHANCTX_CALLBACK_TAS,
NUM_OF_RTW89_CHANCTX_CALLBACKS,
};
struct rtw89_chanctx_listener {
void (*callbacks[NUM_OF_RTW89_CHANCTX_CALLBACKS])
(struct rtw89_dev *rtwdev, enum rtw89_chanctx_state state);
};
struct rtw89_chip_info {
enum rtw89_core_chip_id chip_id;
enum rtw89_chip_gen chip_gen;
const struct rtw89_chip_ops *ops;
const struct rtw89_mac_gen_def *mac_def;
const struct rtw89_phy_gen_def *phy_def;
const char *fw_basename;
u8 fw_format_max;
bool try_ce_fw;
u8 bbmcu_nr;
u32 needed_fw_elms;
const struct rtw89_fw_blacklist *fw_blacklist;
u32 fifo_size;
bool small_fifo_size;
u32 dle_scc_rsvd_size;
u16 max_amsdu_limit;
bool dis_2g_40m_ul_ofdma;
u32 rsvd_ple_ofst;
const struct rtw89_hfc_param_ini *hfc_param_ini;
const struct rtw89_dle_mem *dle_mem;
u8 wde_qempty_acq_grpnum;
u8 wde_qempty_mgq_grpsel;
u32 rf_base_addr[2];
u8 thermal_th[2];
u8 support_macid_num;
u8 support_link_num;
u8 support_chanctx_num;
u8 support_bands;
u16 support_bandwidths;
bool support_unii4;
bool support_rnr;
bool support_ant_gain;
bool support_tas;
bool support_sar_by_ant;
bool ul_tb_waveform_ctrl;
bool ul_tb_pwr_diff;
bool rx_freq_frome_ie;
bool hw_sec_hdr;
bool hw_mgmt_tx_encrypt;
bool hw_tkip_crypto;
bool hw_mlo_bmc_crypto;
u8 rf_path_num;
u8 tx_nss;
u8 rx_nss;
u8 acam_num;
u8 bcam_num;
u8 scam_num;
u8 bacam_num;
u8 bacam_dynamic_num;
enum rtw89_bacam_ver bacam_ver;
u8 ppdu_max_usr;
u8 sec_ctrl_efuse_size;
u32 physical_efuse_size;
u32 logical_efuse_size;
u32 limit_efuse_size;
u32 dav_phy_efuse_size;
u32 dav_log_efuse_size;
u32 phycap_addr;
u32 phycap_size;
const struct rtw89_efuse_block_cfg *efuse_blocks;
const struct rtw89_pwr_cfg * const *pwr_on_seq;
const struct rtw89_pwr_cfg * const *pwr_off_seq;
const struct rtw89_phy_table *bb_table;
const struct rtw89_phy_table *bb_gain_table;
const struct rtw89_phy_table *rf_table[RF_PATH_MAX];
const struct rtw89_phy_table *nctl_table;
const struct rtw89_rfk_tbl *nctl_post_table;
const struct rtw89_phy_dig_gain_table *dig_table;
const struct rtw89_dig_regs *dig_regs;
const struct rtw89_phy_tssi_dbw_table *tssi_dbw_table;
/* NULL if no rfe-specific, or a null-terminated array by rfe_parms */
const struct rtw89_rfe_parms_conf *rfe_parms_conf;
const struct rtw89_rfe_parms *dflt_parms;
const struct rtw89_chanctx_listener *chanctx_listener;
u8 txpwr_factor_bb;
u8 txpwr_factor_rf;
u8 txpwr_factor_mac;
u32 para_ver;
u32 wlcx_desired;
u8 btcx_desired;
u8 scbd;
u8 mailbox;
u8 afh_guard_ch;
const u8 *wl_rssi_thres;
const u8 *bt_rssi_thres;
u8 rssi_tol;
u8 mon_reg_num;
const struct rtw89_btc_fbtc_mreg *mon_reg;
u8 rf_para_ulink_num;
const struct rtw89_btc_rf_trx_para *rf_para_ulink;
u8 rf_para_dlink_num;
const struct rtw89_btc_rf_trx_para *rf_para_dlink;
u8 ps_mode_supported;
u8 low_power_hci_modes;
u32 h2c_cctl_func_id;
u32 hci_func_en_addr;
u32 h2c_desc_size;
u32 txwd_body_size;
u32 txwd_info_size;
u32 h2c_ctrl_reg;
const u32 *h2c_regs;
struct rtw89_reg_def h2c_counter_reg;
u32 c2h_ctrl_reg;
const u32 *c2h_regs;
struct rtw89_reg_def c2h_counter_reg;
const struct rtw89_page_regs *page_regs;
const u32 *wow_reason_reg;
bool cfo_src_fd;
bool cfo_hw_comp;
const struct rtw89_reg_def *dcfo_comp;
u8 dcfo_comp_sft;
const struct rtw89_imr_info *imr_info;
const struct rtw89_imr_table *imr_dmac_table;
const struct rtw89_imr_table *imr_cmac_table;
const struct rtw89_rrsr_cfgs *rrsr_cfgs;
struct rtw89_reg_def bss_clr_vld;
u32 bss_clr_map_reg;
const struct rtw89_rfkill_regs *rfkill_init;
struct rtw89_reg_def rfkill_get;
u32 dma_ch_mask;
const struct rtw89_edcca_regs *edcca_regs;
const struct wiphy_wowlan_support *wowlan_stub;
const struct rtw89_xtal_info *xtal_info;
};
struct rtw89_chip_variant {
bool no_mcs_12_13: 1;
u32 fw_min_ver_code;
};
union rtw89_bus_info {
const struct rtw89_pci_info *pci;
};
struct rtw89_driver_info {
const struct rtw89_chip_info *chip;
const struct rtw89_chip_variant *variant;
const struct dmi_system_id *quirks;
union rtw89_bus_info bus;
};
enum rtw89_hcifc_mode {
RTW89_HCIFC_POH = 0,
RTW89_HCIFC_STF = 1,
RTW89_HCIFC_SDIO = 2,
/* keep last */
RTW89_HCIFC_MODE_INVALID,
};
struct rtw89_dle_info {
const struct rtw89_rsvd_quota *rsvd_qt;
enum rtw89_qta_mode qta_mode;
u16 ple_pg_size;
u16 ple_free_pg;
u16 c0_rx_qta;
u16 c1_rx_qta;
};
enum rtw89_host_rpr_mode {
RTW89_RPR_MODE_POH = 0,
RTW89_RPR_MODE_STF
};
#define RTW89_COMPLETION_BUF_SIZE 40
#define RTW89_WAIT_COND_IDLE UINT_MAX
struct rtw89_completion_data {
bool err;
u8 buf[RTW89_COMPLETION_BUF_SIZE];
};
struct rtw89_wait_info {
atomic_t cond;
struct completion completion;
struct rtw89_completion_data data;
};
#define RTW89_WAIT_FOR_COND_TIMEOUT msecs_to_jiffies(100)
static inline void rtw89_init_wait(struct rtw89_wait_info *wait)
{
init_completion(&wait->completion);
atomic_set(&wait->cond, RTW89_WAIT_COND_IDLE);
}
struct rtw89_mac_info {
struct rtw89_dle_info dle_info;
struct rtw89_hfc_param hfc_param;
enum rtw89_qta_mode qta_mode;
u8 rpwm_seq_num;
u8 cpwm_seq_num;
/* see RTW89_FW_OFLD_WAIT_COND series for wait condition */
struct rtw89_wait_info fw_ofld_wait;
/* see RTW89_PS_WAIT_COND series for wait condition */
struct rtw89_wait_info ps_wait;
};
enum rtw89_fwdl_check_type {
RTW89_FWDL_CHECK_FREERTOS_DONE,
RTW89_FWDL_CHECK_WCPU_FWDL_DONE,
RTW89_FWDL_CHECK_DCPU_FWDL_DONE,
RTW89_FWDL_CHECK_BB0_FWDL_DONE,
RTW89_FWDL_CHECK_BB1_FWDL_DONE,
};
enum rtw89_fw_type {
RTW89_FW_NORMAL = 1,
RTW89_FW_WOWLAN = 3,
RTW89_FW_NORMAL_CE = 5,
RTW89_FW_BBMCU0 = 64,
RTW89_FW_BBMCU1 = 65,
RTW89_FW_LOGFMT = 255,
};
enum rtw89_fw_feature {
RTW89_FW_FEATURE_OLD_HT_RA_FORMAT,
RTW89_FW_FEATURE_SCAN_OFFLOAD,
RTW89_FW_FEATURE_TX_WAKE,
RTW89_FW_FEATURE_CRASH_TRIGGER,
RTW89_FW_FEATURE_NO_PACKET_DROP,
RTW89_FW_FEATURE_NO_DEEP_PS,
RTW89_FW_FEATURE_NO_LPS_PG,
RTW89_FW_FEATURE_BEACON_FILTER,
RTW89_FW_FEATURE_MACID_PAUSE_SLEEP,
RTW89_FW_FEATURE_SCAN_OFFLOAD_BE_V0,
RTW89_FW_FEATURE_WOW_REASON_V1,
RTW89_FW_FEATURE_RFK_PRE_NOTIFY_V0,
RTW89_FW_FEATURE_RFK_PRE_NOTIFY_V1,
RTW89_FW_FEATURE_RFK_RXDCK_V0,
RTW89_FW_FEATURE_NO_WOW_CPU_IO_RX,
RTW89_FW_FEATURE_NOTIFY_AP_INFO,
RTW89_FW_FEATURE_CH_INFO_BE_V0,
RTW89_FW_FEATURE_LPS_CH_INFO,
RTW89_FW_FEATURE_NO_PHYCAP_P1,
RTW89_FW_FEATURE_NO_POWER_DIFFERENCE,
RTW89_FW_FEATURE_BEACON_LOSS_COUNT_V1,
};
struct rtw89_fw_suit {
enum rtw89_fw_type type;
const u8 *data;
u32 size;
u8 major_ver;
u8 minor_ver;
u8 sub_ver;
u8 sub_idex;
u16 build_year;
u16 build_mon;
u16 build_date;
u16 build_hour;
u16 build_min;
u8 cmd_ver;
u8 hdr_ver;
u32 commitid;
};
#define RTW89_FW_VER_CODE(major, minor, sub, idx) \
(((major) << 24) | ((minor) << 16) | ((sub) << 8) | (idx))
#define RTW89_FW_SUIT_VER_CODE(s) \
RTW89_FW_VER_CODE((s)->major_ver, (s)->minor_ver, (s)->sub_ver, (s)->sub_idex)
#define RTW89_MFW_HDR_VER_CODE(mfw_hdr) \
RTW89_FW_VER_CODE((mfw_hdr)->ver.major, \
(mfw_hdr)->ver.minor, \
(mfw_hdr)->ver.sub, \
(mfw_hdr)->ver.idx)
#define RTW89_FW_HDR_VER_CODE(fw_hdr) \
RTW89_FW_VER_CODE(le32_get_bits((fw_hdr)->w1, FW_HDR_W1_MAJOR_VERSION), \
le32_get_bits((fw_hdr)->w1, FW_HDR_W1_MINOR_VERSION), \
le32_get_bits((fw_hdr)->w1, FW_HDR_W1_SUBVERSION), \
le32_get_bits((fw_hdr)->w1, FW_HDR_W1_SUBINDEX))
struct rtw89_fw_req_info {
const struct firmware *firmware;
struct completion completion;
};
struct rtw89_fw_log {
struct rtw89_fw_suit suit;
bool enable;
u32 last_fmt_id;
u32 fmt_count;
const __le32 *fmt_ids;
const char *(*fmts)[];
};
struct rtw89_fw_elm_info {
struct rtw89_phy_table *bb_tbl;
struct rtw89_phy_table *bb_gain;
struct rtw89_phy_table *rf_radio[RF_PATH_MAX];
struct rtw89_phy_table *rf_nctl;
struct rtw89_fw_txpwr_track_cfg *txpwr_trk;
struct rtw89_phy_rfk_log_fmt *rfk_log_fmt;
const struct rtw89_regd_data *regd;
};
enum rtw89_fw_mss_dev_type {
RTW89_FW_MSS_DEV_TYPE_FWSEC_DEF = 0xF,
RTW89_FW_MSS_DEV_TYPE_FWSEC_INV = 0xFF,
};
struct rtw89_fw_secure {
bool secure_boot: 1;
bool can_mss_v1: 1;
bool can_mss_v0: 1;
u32 sb_sel_mgn;
u8 mss_dev_type;
u8 mss_cust_idx;
u8 mss_key_num;
u8 mss_idx; /* v0 */
};
struct rtw89_fw_info {
struct rtw89_fw_req_info req;
int fw_format;
u8 h2c_seq;
u8 rec_seq;
u8 h2c_counter;
u8 c2h_counter;
struct rtw89_fw_suit normal;
struct rtw89_fw_suit wowlan;
struct rtw89_fw_suit bbmcu0;
struct rtw89_fw_suit bbmcu1;
struct rtw89_fw_log log;
u32 feature_map;
struct rtw89_fw_elm_info elm_info;
struct rtw89_fw_secure sec;
};
#define RTW89_CHK_FW_FEATURE(_feat, _fw) \
(!!((_fw)->feature_map & BIT(RTW89_FW_FEATURE_ ## _feat)))
#define RTW89_SET_FW_FEATURE(_fw_feature, _fw) \
((_fw)->feature_map |= BIT(_fw_feature))
struct rtw89_cam_info {
DECLARE_BITMAP(addr_cam_map, RTW89_MAX_ADDR_CAM_NUM);
DECLARE_BITMAP(bssid_cam_map, RTW89_MAX_BSSID_CAM_NUM);
DECLARE_BITMAP(sec_cam_map, RTW89_MAX_SEC_CAM_NUM);
DECLARE_BITMAP(ba_cam_map, RTW89_MAX_BA_CAM_NUM);
struct rtw89_ba_cam_entry ba_cam_entry[RTW89_MAX_BA_CAM_NUM];
const struct rtw89_sec_cam_entry *sec_entries[RTW89_MAX_SEC_CAM_NUM];
};
enum rtw89_sar_sources {
RTW89_SAR_SOURCE_NONE,
RTW89_SAR_SOURCE_COMMON,
RTW89_SAR_SOURCE_ACPI,
RTW89_SAR_SOURCE_NR,
};
enum rtw89_sar_subband {
RTW89_SAR_2GHZ_SUBBAND,
RTW89_SAR_5GHZ_SUBBAND_1_2, /* U-NII-1 and U-NII-2 */
RTW89_SAR_5GHZ_SUBBAND_2_E, /* U-NII-2-Extended */
RTW89_SAR_5GHZ_SUBBAND_3_4, /* U-NII-3 and U-NII-4 */
RTW89_SAR_6GHZ_SUBBAND_5_L, /* U-NII-5 lower part */
RTW89_SAR_6GHZ_SUBBAND_5_H, /* U-NII-5 higher part */
RTW89_SAR_6GHZ_SUBBAND_6, /* U-NII-6 */
RTW89_SAR_6GHZ_SUBBAND_7_L, /* U-NII-7 lower part */
RTW89_SAR_6GHZ_SUBBAND_7_H, /* U-NII-7 higher part */
RTW89_SAR_6GHZ_SUBBAND_8, /* U-NII-8 */
RTW89_SAR_SUBBAND_NR,
};
struct rtw89_sar_cfg_common {
bool set[RTW89_SAR_SUBBAND_NR];
s32 cfg[RTW89_SAR_SUBBAND_NR];
};
enum rtw89_acpi_sar_subband {
RTW89_ACPI_SAR_2GHZ_SUBBAND,
RTW89_ACPI_SAR_5GHZ_SUBBAND_1, /* U-NII-1 */
RTW89_ACPI_SAR_5GHZ_SUBBAND_2, /* U-NII-2 */
RTW89_ACPI_SAR_5GHZ_SUBBAND_2E, /* U-NII-2-Extended */
RTW89_ACPI_SAR_5GHZ_SUBBAND_3_4, /* U-NII-3 and U-NII-4 */
RTW89_ACPI_SAR_6GHZ_SUBBAND_5_L, /* U-NII-5 lower part */
RTW89_ACPI_SAR_6GHZ_SUBBAND_5_H, /* U-NII-5 higher part */
RTW89_ACPI_SAR_6GHZ_SUBBAND_6, /* U-NII-6 */
RTW89_ACPI_SAR_6GHZ_SUBBAND_7_L, /* U-NII-7 lower part */
RTW89_ACPI_SAR_6GHZ_SUBBAND_7_H, /* U-NII-7 higher part */
RTW89_ACPI_SAR_6GHZ_SUBBAND_8, /* U-NII-8 */
NUM_OF_RTW89_ACPI_SAR_SUBBAND,
RTW89_ACPI_SAR_SUBBAND_NR_LEGACY = RTW89_ACPI_SAR_5GHZ_SUBBAND_3_4 + 1,
RTW89_ACPI_SAR_SUBBAND_NR_HAS_6GHZ = RTW89_ACPI_SAR_6GHZ_SUBBAND_8 + 1,
};
#define TXPWR_FACTOR_OF_RTW89_ACPI_SAR 3 /* unit: 0.125 dBm */
#define MAX_VAL_OF_RTW89_ACPI_SAR S16_MAX
#define MIN_VAL_OF_RTW89_ACPI_SAR S16_MIN
#define MAX_NUM_OF_RTW89_ACPI_SAR_TBL 6
#define NUM_OF_RTW89_ACPI_SAR_RF_PATH (RF_PATH_B + 1)
struct rtw89_sar_entry_from_acpi {
s16 v[NUM_OF_RTW89_ACPI_SAR_SUBBAND][NUM_OF_RTW89_ACPI_SAR_RF_PATH];
};
struct rtw89_sar_table_from_acpi {
/* If this table is active, must fill all fields according to either
* configuration in BIOS or some default values for SAR to work well.
*/
struct rtw89_sar_entry_from_acpi entries[RTW89_REGD_NUM];
};
struct rtw89_sar_indicator_from_acpi {
bool enable_sync;
unsigned int fields;
u8 (*rfpath_to_antidx)(enum rtw89_rf_path rfpath);
/* Select among @tables of container, rtw89_sar_cfg_acpi, by path.
* Not design with pointers since addresses will be invalid after
* sync content with local container instance.
*/
u8 tblsel[NUM_OF_RTW89_ACPI_SAR_RF_PATH];
};
struct rtw89_sar_cfg_acpi {
u8 downgrade_2tx;
unsigned int valid_num;
struct rtw89_sar_table_from_acpi tables[MAX_NUM_OF_RTW89_ACPI_SAR_TBL];
struct rtw89_sar_indicator_from_acpi indicator;
};
struct rtw89_sar_info {
/* used to decide how to access SAR cfg union */
enum rtw89_sar_sources src;
/* reserved for different knids of SAR cfg struct.
* supposed that a single cfg struct cannot handle various SAR sources.
*/
union {
struct rtw89_sar_cfg_common cfg_common;
struct rtw89_sar_cfg_acpi cfg_acpi;
};
};
enum rtw89_ant_gain_subband {
RTW89_ANT_GAIN_2GHZ_SUBBAND,
RTW89_ANT_GAIN_5GHZ_SUBBAND_1, /* U-NII-1 */
RTW89_ANT_GAIN_5GHZ_SUBBAND_2, /* U-NII-2 */
RTW89_ANT_GAIN_5GHZ_SUBBAND_2E, /* U-NII-2-Extended */
RTW89_ANT_GAIN_5GHZ_SUBBAND_3_4, /* U-NII-3 and U-NII-4 */
RTW89_ANT_GAIN_6GHZ_SUBBAND_5_L, /* U-NII-5 lower part */
RTW89_ANT_GAIN_6GHZ_SUBBAND_5_H, /* U-NII-5 higher part */
RTW89_ANT_GAIN_6GHZ_SUBBAND_6, /* U-NII-6 */
RTW89_ANT_GAIN_6GHZ_SUBBAND_7_L, /* U-NII-7 lower part */
RTW89_ANT_GAIN_6GHZ_SUBBAND_7_H, /* U-NII-7 higher part */
RTW89_ANT_GAIN_6GHZ_SUBBAND_8, /* U-NII-8 */
RTW89_ANT_GAIN_SUBBAND_NR,
};
enum rtw89_ant_gain_domain_type {
RTW89_ANT_GAIN_ETSI = 0,
RTW89_ANT_GAIN_DOMAIN_NUM,
};
#define RTW89_ANT_GAIN_CHAIN_NUM 2
struct rtw89_ant_gain_info {
s8 offset[RTW89_ANT_GAIN_CHAIN_NUM][RTW89_ANT_GAIN_SUBBAND_NR];
u32 regd_enabled;
bool block_country;
};
struct rtw89_6ghz_span {
enum rtw89_sar_subband sar_subband_low;
enum rtw89_sar_subband sar_subband_high;
enum rtw89_acpi_sar_subband acpi_sar_subband_low;
enum rtw89_acpi_sar_subband acpi_sar_subband_high;
enum rtw89_ant_gain_subband ant_gain_subband_low;
enum rtw89_ant_gain_subband ant_gain_subband_high;
};
#define RTW89_SAR_SPAN_VALID(span) ((span)->sar_subband_high)
#define RTW89_ACPI_SAR_SPAN_VALID(span) ((span)->acpi_sar_subband_high)
#define RTW89_ANT_GAIN_SPAN_VALID(span) ((span)->ant_gain_subband_high)
enum rtw89_tas_state {
RTW89_TAS_STATE_DPR_OFF,
RTW89_TAS_STATE_DPR_ON,
RTW89_TAS_STATE_STATIC_SAR,
};
#define RTW89_TAS_TX_RATIO_WINDOW 6
#define RTW89_TAS_TXPWR_WINDOW 180
struct rtw89_tas_info {
u16 tx_ratio_history[RTW89_TAS_TX_RATIO_WINDOW];
u64 txpwr_history[RTW89_TAS_TXPWR_WINDOW];
u8 enabled_countries;
u8 txpwr_head_idx;
u8 txpwr_tail_idx;
u8 tx_ratio_idx;
u16 total_tx_ratio;
u64 total_txpwr;
u64 instant_txpwr;
u32 window_size;
s8 dpr_on_threshold;
s8 dpr_off_threshold;
enum rtw89_tas_state backup_state;
enum rtw89_tas_state state;
bool keep_history;
bool block_regd;
bool enable;
bool pause;
};
struct rtw89_chanctx_cfg {
enum rtw89_chanctx_idx idx;
int ref_count;
};
enum rtw89_chanctx_changes {
RTW89_CHANCTX_REMOTE_STA_CHANGE,
RTW89_CHANCTX_BCN_OFFSET_CHANGE,
RTW89_CHANCTX_P2P_PS_CHANGE,
RTW89_CHANCTX_BT_SLOT_CHANGE,
RTW89_CHANCTX_TSF32_TOGGLE_CHANGE,
NUM_OF_RTW89_CHANCTX_CHANGES,
RTW89_CHANCTX_CHANGE_DFLT = NUM_OF_RTW89_CHANCTX_CHANGES,
};
enum rtw89_entity_mode {
RTW89_ENTITY_MODE_SCC_OR_SMLD,
RTW89_ENTITY_MODE_MCC_PREPARE,
RTW89_ENTITY_MODE_MCC,
NUM_OF_RTW89_ENTITY_MODE,
RTW89_ENTITY_MODE_INVALID = -EINVAL,
RTW89_ENTITY_MODE_UNHANDLED = -ESRCH,
};
#define RTW89_MAX_INTERFACE_NUM 2
/* only valid when running with chanctx_ops */
struct rtw89_entity_mgnt {
struct list_head active_list;
struct rtw89_vif *active_roles[RTW89_MAX_INTERFACE_NUM];
enum rtw89_chanctx_idx chanctx_tbl[RTW89_MAX_INTERFACE_NUM]
[__RTW89_MLD_MAX_LINK_NUM];
};
struct rtw89_chanctx {
struct cfg80211_chan_def chandef;
struct rtw89_chan chan;
struct rtw89_chan_rcd rcd;
/* only assigned when running with chanctx_ops */
struct rtw89_chanctx_cfg *cfg;
};
struct rtw89_edcca_bak {
u8 a;
u8 p;
u8 ppdu;
u8 th_old;
};
enum rtw89_dm_type {
RTW89_DM_DYNAMIC_EDCCA,
RTW89_DM_THERMAL_PROTECT,
RTW89_DM_TAS,
RTW89_DM_MLO,
};
#define RTW89_THERMAL_PROT_LV_MAX 5
#define RTW89_THERMAL_PROT_STEP 5 /* -5% for each level */
struct rtw89_hal {
u32 rx_fltr;
u8 cv;
u8 acv;
u32 antenna_tx;
u32 antenna_rx;
u8 tx_nss;
u8 rx_nss;
bool tx_path_diversity;
bool ant_diversity;
bool ant_diversity_fixed;
bool support_cckpd;
bool support_igi;
bool no_mcs_12_13;
atomic_t roc_chanctx_idx;
u8 roc_link_index;
DECLARE_BITMAP(changes, NUM_OF_RTW89_CHANCTX_CHANGES);
DECLARE_BITMAP(entity_map, NUM_OF_RTW89_CHANCTX);
struct rtw89_chanctx chanctx[NUM_OF_RTW89_CHANCTX];
struct cfg80211_chan_def roc_chandef;
bool entity_active[RTW89_PHY_NUM];
bool entity_pause;
enum rtw89_entity_mode entity_mode;
struct rtw89_entity_mgnt entity_mgnt;
u32 disabled_dm_bitmap; /* bitmap of enum rtw89_dm_type */
u8 thermal_prot_th;
u8 thermal_prot_lv; /* 0 ~ RTW89_THERMAL_PROT_LV_MAX */
};
#define RTW89_MAX_MAC_ID_NUM 128
#define RTW89_MAX_PKT_OFLD_NUM 255
enum rtw89_flags {
RTW89_FLAG_POWERON,
RTW89_FLAG_DMAC_FUNC,
RTW89_FLAG_CMAC0_FUNC,
RTW89_FLAG_CMAC1_FUNC,
RTW89_FLAG_FW_RDY,
RTW89_FLAG_RUNNING,
RTW89_FLAG_PROBE_DONE,
RTW89_FLAG_BFEE_MON,
RTW89_FLAG_BFEE_EN,
RTW89_FLAG_BFEE_TIMER_KEEP,
RTW89_FLAG_NAPI_RUNNING,
RTW89_FLAG_LEISURE_PS,
RTW89_FLAG_LOW_POWER_MODE,
RTW89_FLAG_INACTIVE_PS,
RTW89_FLAG_CRASH_SIMULATING,
RTW89_FLAG_SER_HANDLING,
RTW89_FLAG_WOWLAN,
RTW89_FLAG_FORBIDDEN_TRACK_WROK,
RTW89_FLAG_CHANGING_INTERFACE,
RTW89_FLAG_HW_RFKILL_STATE,
NUM_OF_RTW89_FLAGS,
};
enum rtw89_quirks {
RTW89_QUIRK_PCI_BER,
RTW89_QUIRK_THERMAL_PROT_120C,
RTW89_QUIRK_THERMAL_PROT_110C,
NUM_OF_RTW89_QUIRKS,
};
enum rtw89_custid {
RTW89_CUSTID_NONE,
RTW89_CUSTID_ACER,
RTW89_CUSTID_AMD,
RTW89_CUSTID_ASUS,
RTW89_CUSTID_DELL,
RTW89_CUSTID_HP,
RTW89_CUSTID_LENOVO,
};
enum rtw89_pkt_drop_sel {
RTW89_PKT_DROP_SEL_MACID_BE_ONCE,
RTW89_PKT_DROP_SEL_MACID_BK_ONCE,
RTW89_PKT_DROP_SEL_MACID_VI_ONCE,
RTW89_PKT_DROP_SEL_MACID_VO_ONCE,
RTW89_PKT_DROP_SEL_MACID_ALL,
RTW89_PKT_DROP_SEL_MG0_ONCE,
RTW89_PKT_DROP_SEL_HIQ_ONCE,
RTW89_PKT_DROP_SEL_HIQ_PORT,
RTW89_PKT_DROP_SEL_HIQ_MBSSID,
RTW89_PKT_DROP_SEL_BAND,
RTW89_PKT_DROP_SEL_BAND_ONCE,
RTW89_PKT_DROP_SEL_REL_MACID,
RTW89_PKT_DROP_SEL_REL_HIQ_PORT,
RTW89_PKT_DROP_SEL_REL_HIQ_MBSSID,
};
struct rtw89_pkt_drop_params {
enum rtw89_pkt_drop_sel sel;
enum rtw89_mac_idx mac_band;
u8 macid;
u8 port;
u8 mbssid;
bool tf_trs;
u32 macid_band_sel[4];
};
struct rtw89_pkt_stat {
u16 beacon_nr;
u8 beacon_rate;
u32 rx_rate_cnt[RTW89_HW_RATE_NR];
};
DECLARE_EWMA(thermal, 4, 4);
struct rtw89_phy_stat {
struct ewma_thermal avg_thermal[RF_PATH_MAX];
u8 last_thermal_max;
struct ewma_rssi bcn_rssi;
struct rtw89_pkt_stat cur_pkt_stat;
struct rtw89_pkt_stat last_pkt_stat;
};
enum rtw89_rfk_report_state {
RTW89_RFK_STATE_START = 0x0,
RTW89_RFK_STATE_OK = 0x1,
RTW89_RFK_STATE_FAIL = 0x2,
RTW89_RFK_STATE_TIMEOUT = 0x3,
RTW89_RFK_STATE_H2C_CMD_ERR = 0x4,
};
struct rtw89_rfk_wait_info {
struct completion completion;
ktime_t start_time;
enum rtw89_rfk_report_state state;
u8 version;
};
#define RTW89_DACK_PATH_NR 2
#define RTW89_DACK_IDX_NR 2
#define RTW89_DACK_MSBK_NR 16
struct rtw89_dack_info {
bool dack_done;
u8 msbk_d[RTW89_DACK_PATH_NR][RTW89_DACK_IDX_NR][RTW89_DACK_MSBK_NR];
u8 dadck_d[RTW89_DACK_PATH_NR][RTW89_DACK_IDX_NR];
u16 addck_d[RTW89_DACK_PATH_NR][RTW89_DACK_IDX_NR];
u16 biask_d[RTW89_DACK_PATH_NR][RTW89_DACK_IDX_NR];
u32 dack_cnt;
bool addck_timeout[RTW89_DACK_PATH_NR];
bool dadck_timeout[RTW89_DACK_PATH_NR];
bool msbk_timeout[RTW89_DACK_PATH_NR];
};
enum rtw89_rfk_chs_nrs {
__RTW89_RFK_CHS_NR_V0 = 2,
__RTW89_RFK_CHS_NR_V1 = 3,
RTW89_RFK_CHS_NR = __RTW89_RFK_CHS_NR_V1,
};
struct rtw89_rfk_mcc_info_data {
u8 ch[RTW89_RFK_CHS_NR];
u8 band[RTW89_RFK_CHS_NR];
u8 bw[RTW89_RFK_CHS_NR];
u8 table_idx;
};
struct rtw89_rfk_mcc_info {
struct rtw89_rfk_mcc_info_data data[2];
};
#define RTW89_IQK_CHS_NR 2
#define RTW89_IQK_PATH_NR 4
struct rtw89_lck_info {
u8 thermal[RF_PATH_MAX];
};
struct rtw89_rx_dck_info {
u8 thermal[RF_PATH_MAX];
};
struct rtw89_iqk_info {
bool lok_cor_fail[RTW89_IQK_CHS_NR][RTW89_IQK_PATH_NR];
bool lok_fin_fail[RTW89_IQK_CHS_NR][RTW89_IQK_PATH_NR];
bool lok_fail[RTW89_IQK_PATH_NR];
bool iqk_tx_fail[RTW89_IQK_CHS_NR][RTW89_IQK_PATH_NR];
bool iqk_rx_fail[RTW89_IQK_CHS_NR][RTW89_IQK_PATH_NR];
u32 iqk_fail_cnt;
bool is_iqk_init;
u32 iqk_channel[RTW89_IQK_CHS_NR];
u8 iqk_band[RTW89_IQK_PATH_NR];
u8 iqk_ch[RTW89_IQK_PATH_NR];
u8 iqk_bw[RTW89_IQK_PATH_NR];
u8 iqk_times;
u8 version;
u32 nb_txcfir[RTW89_IQK_PATH_NR];
u32 nb_rxcfir[RTW89_IQK_PATH_NR];
u32 bp_txkresult[RTW89_IQK_PATH_NR];
u32 bp_rxkresult[RTW89_IQK_PATH_NR];
u32 bp_iqkenable[RTW89_IQK_PATH_NR];
bool is_wb_txiqk[RTW89_IQK_PATH_NR];
bool is_wb_rxiqk[RTW89_IQK_PATH_NR];
bool is_nbiqk;
bool iqk_fft_en;
bool iqk_xym_en;
bool iqk_sram_en;
bool iqk_cfir_en;
u32 syn1to2;
u8 iqk_mcc_ch[RTW89_IQK_CHS_NR][RTW89_IQK_PATH_NR];
u8 iqk_table_idx[RTW89_IQK_PATH_NR];
u32 lok_idac[RTW89_IQK_CHS_NR][RTW89_IQK_PATH_NR];
u32 lok_vbuf[RTW89_IQK_CHS_NR][RTW89_IQK_PATH_NR];
};
#define RTW89_DPK_RF_PATH 2
#define RTW89_DPK_AVG_THERMAL_NUM 8
#define RTW89_DPK_BKUP_NUM 2
struct rtw89_dpk_bkup_para {
enum rtw89_band band;
enum rtw89_bandwidth bw;
u8 ch;
bool path_ok;
u8 mdpd_en;
u8 txagc_dpk;
u8 ther_dpk;
u8 gs;
u16 pwsf;
};
struct rtw89_dpk_info {
bool is_dpk_enable;
bool is_dpk_reload_en;
u8 dpk_gs[RTW89_PHY_NUM];
u16 dc_i[RTW89_DPK_RF_PATH][RTW89_DPK_BKUP_NUM];
u16 dc_q[RTW89_DPK_RF_PATH][RTW89_DPK_BKUP_NUM];
u8 corr_val[RTW89_DPK_RF_PATH][RTW89_DPK_BKUP_NUM];
u8 corr_idx[RTW89_DPK_RF_PATH][RTW89_DPK_BKUP_NUM];
u8 cur_idx[RTW89_DPK_RF_PATH];
u8 cur_k_set;
struct rtw89_dpk_bkup_para bp[RTW89_DPK_RF_PATH][RTW89_DPK_BKUP_NUM];
u8 max_dpk_txagc[RTW89_DPK_RF_PATH];
u32 dpk_order[RTW89_DPK_RF_PATH];
};
struct rtw89_fem_info {
bool elna_2g;
bool elna_5g;
bool epa_2g;
bool epa_5g;
bool epa_6g;
};
struct rtw89_phy_ch_info {
u8 rssi_min;
u16 rssi_min_macid;
u8 pre_rssi_min;
u8 rssi_max;
u16 rssi_max_macid;
u8 rxsc_160;
u8 rxsc_80;
u8 rxsc_40;
u8 rxsc_20;
u8 rxsc_l;
u8 is_noisy;
};
struct rtw89_agc_gaincode_set {
u8 lna_idx;
u8 tia_idx;
u8 rxb_idx;
};
#define IGI_RSSI_TH_NUM 5
#define FA_TH_NUM 4
#define TIA_LNA_OP1DB_NUM 8
#define LNA_GAIN_NUM 7
#define TIA_GAIN_NUM 2
struct rtw89_dig_info {
struct rtw89_agc_gaincode_set cur_gaincode;
bool force_gaincode_idx_en;
struct rtw89_agc_gaincode_set force_gaincode;
u8 igi_rssi_th[IGI_RSSI_TH_NUM];
u16 fa_th[FA_TH_NUM];
u8 igi_rssi;
u8 igi_fa_rssi;
u8 fa_rssi_ofst;
u8 dyn_igi_max;
u8 dyn_igi_min;
bool dyn_pd_th_en;
u8 dyn_pd_th_max;
u8 pd_low_th_ofst;
u8 ib_pbk;
s8 ib_pkpwr;
s8 lna_gain_a[LNA_GAIN_NUM];
s8 lna_gain_g[LNA_GAIN_NUM];
s8 *lna_gain;
s8 tia_gain_a[TIA_GAIN_NUM];
s8 tia_gain_g[TIA_GAIN_NUM];
s8 *tia_gain;
bool is_linked_pre;
bool bypass_dig;
};
enum rtw89_multi_cfo_mode {
RTW89_PKT_BASED_AVG_MODE = 0,
RTW89_ENTRY_BASED_AVG_MODE = 1,
RTW89_TP_BASED_AVG_MODE = 2,
};
enum rtw89_phy_cfo_status {
RTW89_PHY_DCFO_STATE_NORMAL = 0,
RTW89_PHY_DCFO_STATE_ENHANCE = 1,
RTW89_PHY_DCFO_STATE_HOLD = 2,
RTW89_PHY_DCFO_STATE_MAX
};
enum rtw89_phy_cfo_ul_ofdma_acc_mode {
RTW89_CFO_UL_OFDMA_ACC_DISABLE = 0,
RTW89_CFO_UL_OFDMA_ACC_ENABLE = 1
};
struct rtw89_cfo_tracking_info {
u16 cfo_timer_ms;
bool cfo_trig_by_timer_en;
enum rtw89_phy_cfo_status phy_cfo_status;
enum rtw89_phy_cfo_ul_ofdma_acc_mode cfo_ul_ofdma_acc_mode;
u8 phy_cfo_trk_cnt;
bool is_adjust;
enum rtw89_multi_cfo_mode rtw89_multi_cfo_mode;
bool apply_compensation;
u8 crystal_cap;
u8 crystal_cap_default;
u8 def_x_cap;
s8 x_cap_ofst;
u32 sta_cfo_tolerance;
s32 cfo_tail[CFO_TRACK_MAX_USER];
u16 cfo_cnt[CFO_TRACK_MAX_USER];
s32 cfo_avg_pre;
s32 cfo_avg[CFO_TRACK_MAX_USER];
s32 pre_cfo_avg[CFO_TRACK_MAX_USER];
s32 dcfo_avg;
s32 dcfo_avg_pre;
u32 packet_count;
u32 packet_count_pre;
s32 residual_cfo_acc;
u8 phy_cfotrk_state;
u8 phy_cfotrk_cnt;
bool divergence_lock_en;
u8 x_cap_lb;
u8 x_cap_ub;
u8 lock_cnt;
};
enum rtw89_tssi_mode {
RTW89_TSSI_NORMAL = 0,
RTW89_TSSI_SCAN = 1,
};
enum rtw89_tssi_alimk_band {
TSSI_ALIMK_2G = 0,
TSSI_ALIMK_5GL,
TSSI_ALIMK_5GM,
TSSI_ALIMK_5GH,
TSSI_ALIMK_MAX
};
/* 2GL, 2GH, 5GL1, 5GH1, 5GM1, 5GM2, 5GH1, 5GH2 */
#define TSSI_TRIM_CH_GROUP_NUM 8
#define TSSI_TRIM_CH_GROUP_NUM_6G 16
#define TSSI_CCK_CH_GROUP_NUM 6
#define TSSI_MCS_2G_CH_GROUP_NUM 5
#define TSSI_MCS_5G_CH_GROUP_NUM 14
#define TSSI_MCS_6G_CH_GROUP_NUM 32
#define TSSI_MCS_CH_GROUP_NUM \
(TSSI_MCS_2G_CH_GROUP_NUM + TSSI_MCS_5G_CH_GROUP_NUM)
#define TSSI_MAX_CH_NUM 67
#define TSSI_ALIMK_VALUE_NUM 8
struct rtw89_tssi_info {
u8 thermal[RF_PATH_MAX];
s8 tssi_trim[RF_PATH_MAX][TSSI_TRIM_CH_GROUP_NUM];
s8 tssi_trim_6g[RF_PATH_MAX][TSSI_TRIM_CH_GROUP_NUM_6G];
s8 tssi_cck[RF_PATH_MAX][TSSI_CCK_CH_GROUP_NUM];
s8 tssi_mcs[RF_PATH_MAX][TSSI_MCS_CH_GROUP_NUM];
s8 tssi_6g_mcs[RF_PATH_MAX][TSSI_MCS_6G_CH_GROUP_NUM];
s8 extra_ofst[RF_PATH_MAX];
bool tssi_tracking_check[RF_PATH_MAX];
u8 default_txagc_offset[RF_PATH_MAX];
u32 base_thermal[RF_PATH_MAX];
bool check_backup_aligmk[RF_PATH_MAX][TSSI_MAX_CH_NUM];
u32 alignment_backup_by_ch[RF_PATH_MAX][TSSI_MAX_CH_NUM][TSSI_ALIMK_VALUE_NUM];
u32 alignment_value[RF_PATH_MAX][TSSI_ALIMK_MAX][TSSI_ALIMK_VALUE_NUM];
bool alignment_done[RF_PATH_MAX][TSSI_ALIMK_MAX];
u64 tssi_alimk_time;
};
struct rtw89_power_trim_info {
bool pg_thermal_trim;
bool pg_pa_bias_trim;
u8 thermal_trim[RF_PATH_MAX];
u8 pa_bias_trim[RF_PATH_MAX];
u8 pad_bias_trim[RF_PATH_MAX];
};
enum rtw89_regd_func {
RTW89_REGD_FUNC_TAS = 0, /* TAS (Time Average SAR) */
RTW89_REGD_FUNC_DAG = 1, /* DAG (Dynamic Antenna Gain) */
NUM_OF_RTW89_REGD_FUNC,
};
struct rtw89_regd {
char alpha2[3];
u8 txpwr_regd[RTW89_BAND_NUM];
DECLARE_BITMAP(func_bitmap, NUM_OF_RTW89_REGD_FUNC);
};
struct rtw89_regd_data {
unsigned int nr;
struct rtw89_regd map[] __counted_by(nr);
};
struct rtw89_regd_ctrl {
unsigned int nr;
const struct rtw89_regd *map;
};
#define RTW89_REGD_MAX_COUNTRY_NUM U8_MAX
#define RTW89_5GHZ_UNII4_CHANNEL_NUM 3
#define RTW89_5GHZ_UNII4_START_INDEX 25
struct rtw89_regulatory_info {
struct rtw89_regd_ctrl ctrl;
const struct rtw89_regd *regd;
enum rtw89_reg_6ghz_power reg_6ghz_power;
struct rtw89_reg_6ghz_tpe reg_6ghz_tpe;
bool txpwr_uk_follow_etsi;
DECLARE_BITMAP(block_unii4, RTW89_REGD_MAX_COUNTRY_NUM);
DECLARE_BITMAP(block_6ghz, RTW89_REGD_MAX_COUNTRY_NUM);
DECLARE_BITMAP(block_6ghz_sp, RTW89_REGD_MAX_COUNTRY_NUM);
};
enum rtw89_ifs_clm_application {
RTW89_IFS_CLM_INIT = 0,
RTW89_IFS_CLM_BACKGROUND = 1,
RTW89_IFS_CLM_ACS = 2,
RTW89_IFS_CLM_DIG = 3,
RTW89_IFS_CLM_TDMA_DIG = 4,
RTW89_IFS_CLM_DBG = 5,
RTW89_IFS_CLM_DBG_MANUAL = 6
};
enum rtw89_env_racing_lv {
RTW89_RAC_RELEASE = 0,
RTW89_RAC_LV_1 = 1,
RTW89_RAC_LV_2 = 2,
RTW89_RAC_LV_3 = 3,
RTW89_RAC_LV_4 = 4,
RTW89_RAC_MAX_NUM = 5
};
struct rtw89_ccx_para_info {
enum rtw89_env_racing_lv rac_lv;
u16 mntr_time;
u8 nhm_manual_th_ofst;
u8 nhm_manual_th0;
enum rtw89_ifs_clm_application ifs_clm_app;
u32 ifs_clm_manual_th_times;
u32 ifs_clm_manual_th0;
u8 fahm_manual_th_ofst;
u8 fahm_manual_th0;
u8 fahm_numer_opt;
u8 fahm_denom_opt;
};
enum rtw89_ccx_edcca_opt_sc_idx {
RTW89_CCX_EDCCA_SEG0_P0 = 0,
RTW89_CCX_EDCCA_SEG0_S1 = 1,
RTW89_CCX_EDCCA_SEG0_S2 = 2,
RTW89_CCX_EDCCA_SEG0_S3 = 3,
RTW89_CCX_EDCCA_SEG1_P0 = 4,
RTW89_CCX_EDCCA_SEG1_S1 = 5,
RTW89_CCX_EDCCA_SEG1_S2 = 6,
RTW89_CCX_EDCCA_SEG1_S3 = 7
};
enum rtw89_ccx_edcca_opt_bw_idx {
RTW89_CCX_EDCCA_BW20_0 = 0,
RTW89_CCX_EDCCA_BW20_1 = 1,
RTW89_CCX_EDCCA_BW20_2 = 2,
RTW89_CCX_EDCCA_BW20_3 = 3,
RTW89_CCX_EDCCA_BW20_4 = 4,
RTW89_CCX_EDCCA_BW20_5 = 5,
RTW89_CCX_EDCCA_BW20_6 = 6,
RTW89_CCX_EDCCA_BW20_7 = 7
};
#define RTW89_NHM_TH_NUM 11
#define RTW89_FAHM_TH_NUM 11
#define RTW89_NHM_RPT_NUM 12
#define RTW89_FAHM_RPT_NUM 12
#define RTW89_IFS_CLM_NUM 4
struct rtw89_env_monitor_info {
u8 ccx_watchdog_result;
bool ccx_ongoing;
u8 ccx_rac_lv;
bool ccx_manual_ctrl;
u16 ifs_clm_mntr_time;
enum rtw89_ifs_clm_application ifs_clm_app;
u16 ccx_period;
u8 ccx_unit_idx;
u16 ifs_clm_th_l[RTW89_IFS_CLM_NUM];
u16 ifs_clm_th_h[RTW89_IFS_CLM_NUM];
u16 ifs_clm_tx;
u16 ifs_clm_edcca_excl_cca;
u16 ifs_clm_ofdmfa;
u16 ifs_clm_ofdmcca_excl_fa;
u16 ifs_clm_cckfa;
u16 ifs_clm_cckcca_excl_fa;
u16 ifs_clm_total_ifs;
u8 ifs_clm_his[RTW89_IFS_CLM_NUM];
u16 ifs_clm_avg[RTW89_IFS_CLM_NUM];
u16 ifs_clm_cca[RTW89_IFS_CLM_NUM];
u8 ifs_clm_tx_ratio;
u8 ifs_clm_edcca_excl_cca_ratio;
u8 ifs_clm_cck_fa_ratio;
u8 ifs_clm_ofdm_fa_ratio;
u8 ifs_clm_cck_cca_excl_fa_ratio;
u8 ifs_clm_ofdm_cca_excl_fa_ratio;
u16 ifs_clm_cck_fa_permil;
u16 ifs_clm_ofdm_fa_permil;
u32 ifs_clm_ifs_avg[RTW89_IFS_CLM_NUM];
u32 ifs_clm_cca_avg[RTW89_IFS_CLM_NUM];
};
enum rtw89_ser_rcvy_step {
RTW89_SER_DRV_STOP_TX,
RTW89_SER_DRV_STOP_RX,
RTW89_SER_DRV_STOP_RUN,
RTW89_SER_HAL_STOP_DMA,
RTW89_SER_SUPPRESS_LOG,
RTW89_NUM_OF_SER_FLAGS
};
struct rtw89_ser {
u8 state;
u8 alarm_event;
bool prehandle_l1;
struct work_struct ser_hdl_work;
struct delayed_work ser_alarm_work;
const struct state_ent *st_tbl;
const struct event_ent *ev_tbl;
struct list_head msg_q;
spinlock_t msg_q_lock; /* lock when read/write ser msg */
DECLARE_BITMAP(flags, RTW89_NUM_OF_SER_FLAGS);
};
enum rtw89_mac_ax_ps_mode {
RTW89_MAC_AX_PS_MODE_ACTIVE = 0,
RTW89_MAC_AX_PS_MODE_LEGACY = 1,
RTW89_MAC_AX_PS_MODE_WMMPS = 2,
RTW89_MAC_AX_PS_MODE_MAX = 3,
};
enum rtw89_last_rpwm_mode {
RTW89_LAST_RPWM_PS = 0x0,
RTW89_LAST_RPWM_ACTIVE = 0x6,
};
struct rtw89_lps_parm {
u8 macid;
u8 psmode; /* enum rtw89_mac_ax_ps_mode */
u8 lastrpwm; /* enum rtw89_last_rpwm_mode */
};
struct rtw89_ppdu_sts_info {
struct sk_buff_head rx_queue[RTW89_PHY_NUM];
u8 curr_rx_ppdu_cnt[RTW89_PHY_NUM];
};
struct rtw89_early_h2c {
struct list_head list;
u8 *h2c;
u16 h2c_len;
};
struct rtw89_hw_scan_info {
struct rtw89_vif_link *scanning_vif;
struct list_head pkt_list[NUM_NL80211_BANDS];
struct list_head chan_list;
struct rtw89_chan op_chan;
bool connected;
bool abort;
};
enum rtw89_phy_bb_gain_band {
RTW89_BB_GAIN_BAND_2G = 0,
RTW89_BB_GAIN_BAND_5G_L = 1,
RTW89_BB_GAIN_BAND_5G_M = 2,
RTW89_BB_GAIN_BAND_5G_H = 3,
RTW89_BB_GAIN_BAND_6G_L = 4,
RTW89_BB_GAIN_BAND_6G_M = 5,
RTW89_BB_GAIN_BAND_6G_H = 6,
RTW89_BB_GAIN_BAND_6G_UH = 7,
RTW89_BB_GAIN_BAND_NR,
};
enum rtw89_phy_gain_band_be {
RTW89_BB_GAIN_BAND_2G_BE = 0,
RTW89_BB_GAIN_BAND_5G_L_BE = 1,
RTW89_BB_GAIN_BAND_5G_M_BE = 2,
RTW89_BB_GAIN_BAND_5G_H_BE = 3,
RTW89_BB_GAIN_BAND_6G_L0_BE = 4,
RTW89_BB_GAIN_BAND_6G_L1_BE = 5,
RTW89_BB_GAIN_BAND_6G_M0_BE = 6,
RTW89_BB_GAIN_BAND_6G_M1_BE = 7,
RTW89_BB_GAIN_BAND_6G_H0_BE = 8,
RTW89_BB_GAIN_BAND_6G_H1_BE = 9,
RTW89_BB_GAIN_BAND_6G_UH0_BE = 10,
RTW89_BB_GAIN_BAND_6G_UH1_BE = 11,
RTW89_BB_GAIN_BAND_NR_BE,
};
enum rtw89_phy_bb_bw_be {
RTW89_BB_BW_20_40 = 0,
RTW89_BB_BW_80_160_320 = 1,
RTW89_BB_BW_NR_BE,
};
enum rtw89_bw20_sc {
RTW89_BW20_SC_20M = 1,
RTW89_BW20_SC_40M = 2,
RTW89_BW20_SC_80M = 4,
RTW89_BW20_SC_160M = 8,
RTW89_BW20_SC_320M = 16,
};
enum rtw89_cmac_table_bw {
RTW89_CMAC_BW_20M = 0,
RTW89_CMAC_BW_40M = 1,
RTW89_CMAC_BW_80M = 2,
RTW89_CMAC_BW_160M = 3,
RTW89_CMAC_BW_320M = 4,
RTW89_CMAC_BW_NR,
};
enum rtw89_phy_bb_rxsc_num {
RTW89_BB_RXSC_NUM_40 = 9, /* SC: 0, 1~8 */
RTW89_BB_RXSC_NUM_80 = 13, /* SC: 0, 1~8, 9~12 */
RTW89_BB_RXSC_NUM_160 = 15, /* SC: 0, 1~8, 9~12, 13~14 */
};
struct rtw89_phy_bb_gain_info {
s8 lna_gain[RTW89_BB_GAIN_BAND_NR][RF_PATH_MAX][LNA_GAIN_NUM];
s8 tia_gain[RTW89_BB_GAIN_BAND_NR][RF_PATH_MAX][TIA_GAIN_NUM];
s8 lna_gain_bypass[RTW89_BB_GAIN_BAND_NR][RF_PATH_MAX][LNA_GAIN_NUM];
s8 lna_op1db[RTW89_BB_GAIN_BAND_NR][RF_PATH_MAX][LNA_GAIN_NUM];
s8 tia_lna_op1db[RTW89_BB_GAIN_BAND_NR][RF_PATH_MAX]
[LNA_GAIN_NUM + 1]; /* TIA0_LNA0~6 + TIA1_LNA6 */
s8 rpl_ofst_20[RTW89_BB_GAIN_BAND_NR][RF_PATH_MAX];
s8 rpl_ofst_40[RTW89_BB_GAIN_BAND_NR][RF_PATH_MAX]
[RTW89_BB_RXSC_NUM_40];
s8 rpl_ofst_80[RTW89_BB_GAIN_BAND_NR][RF_PATH_MAX]
[RTW89_BB_RXSC_NUM_80];
s8 rpl_ofst_160[RTW89_BB_GAIN_BAND_NR][RF_PATH_MAX]
[RTW89_BB_RXSC_NUM_160];
};
struct rtw89_phy_bb_gain_info_be {
s8 lna_gain[RTW89_BB_GAIN_BAND_NR_BE][RTW89_BB_BW_NR_BE][RF_PATH_MAX]
[LNA_GAIN_NUM];
s8 tia_gain[RTW89_BB_GAIN_BAND_NR_BE][RTW89_BB_BW_NR_BE][RF_PATH_MAX]
[TIA_GAIN_NUM];
s8 lna_gain_bypass[RTW89_BB_GAIN_BAND_NR_BE][RTW89_BB_BW_NR_BE]
[RF_PATH_MAX][LNA_GAIN_NUM];
s8 lna_op1db[RTW89_BB_GAIN_BAND_NR_BE][RTW89_BB_BW_NR_BE]
[RF_PATH_MAX][LNA_GAIN_NUM];
s8 tia_lna_op1db[RTW89_BB_GAIN_BAND_NR_BE][RTW89_BB_BW_NR_BE]
[RF_PATH_MAX][LNA_GAIN_NUM + 1];
s8 rpl_ofst_20[RTW89_BB_GAIN_BAND_NR_BE][RF_PATH_MAX]
[RTW89_BW20_SC_20M];
s8 rpl_ofst_40[RTW89_BB_GAIN_BAND_NR_BE][RF_PATH_MAX]
[RTW89_BW20_SC_40M];
s8 rpl_ofst_80[RTW89_BB_GAIN_BAND_NR_BE][RF_PATH_MAX]
[RTW89_BW20_SC_80M];
s8 rpl_ofst_160[RTW89_BB_GAIN_BAND_NR_BE][RF_PATH_MAX]
[RTW89_BW20_SC_160M];
};
struct rtw89_phy_efuse_gain {
bool offset_valid;
bool comp_valid;
s8 offset[RF_PATH_MAX][RTW89_GAIN_OFFSET_NR]; /* S(8, 0) */
s8 offset_base[RTW89_PHY_NUM]; /* S(8, 4) */
s8 rssi_base[RTW89_PHY_NUM]; /* S(8, 4) */
s8 comp[RF_PATH_MAX][RTW89_SUBBAND_NR]; /* S(8, 0) */
};
#define RTW89_MAX_PATTERN_NUM 18
#define RTW89_MAX_PATTERN_MASK_SIZE 4
#define RTW89_MAX_PATTERN_SIZE 128
struct rtw89_wow_cam_info {
bool r_w;
u8 idx;
u32 mask[RTW89_MAX_PATTERN_MASK_SIZE];
u16 crc;
bool negative_pattern_match;
bool skip_mac_hdr;
bool uc;
bool mc;
bool bc;
bool valid;
};
struct rtw89_wow_key_info {
u8 ptk_tx_iv[8];
u8 valid_check;
u8 symbol_check_en;
u8 gtk_keyidx;
u8 rsvd[5];
u8 ptk_rx_iv[8];
u8 gtk_rx_iv[4][8];
} __packed;
struct rtw89_wow_gtk_info {
u8 kck[32];
u8 kek[32];
u8 tk1[16];
u8 txmickey[8];
u8 rxmickey[8];
__le32 igtk_keyid;
__le64 ipn;
u8 igtk[2][32];
u8 psk[32];
} __packed;
struct rtw89_wow_aoac_report {
u8 rpt_ver;
u8 sec_type;
u8 key_idx;
u8 pattern_idx;
u8 rekey_ok;
u8 ptk_tx_iv[8];
u8 eapol_key_replay_count[8];
u8 gtk[32];
u8 ptk_rx_iv[8];
u8 gtk_rx_iv[4][8];
u64 igtk_key_id;
u64 igtk_ipn;
u8 igtk[32];
u8 csa_pri_ch;
u8 csa_bw;
u8 csa_ch_offset;
u8 csa_chsw_failed;
u8 csa_ch_band;
};
struct rtw89_wow_param {
struct rtw89_vif_link *rtwvif_link;
DECLARE_BITMAP(flags, RTW89_WOW_FLAG_NUM);
struct rtw89_wow_cam_info patterns[RTW89_MAX_PATTERN_NUM];
struct rtw89_wow_key_info key_info;
struct rtw89_wow_gtk_info gtk_info;
struct rtw89_wow_aoac_report aoac_rpt;
u8 pattern_cnt;
u8 ptk_alg;
u8 gtk_alg;
u8 ptk_keyidx;
u8 akm;
/* see RTW89_WOW_WAIT_COND series for wait condition */
struct rtw89_wait_info wait;
bool pno_inited;
struct list_head pno_pkt_list;
struct cfg80211_sched_scan_request *nd_config;
};
struct rtw89_mcc_limit {
bool enable;
u16 max_tob; /* TU; max time offset behind */
u16 max_toa; /* TU; max time offset ahead */
u16 max_dur; /* TU */
};
struct rtw89_mcc_policy {
u8 c2h_rpt;
u8 tx_null_early;
u8 dis_tx_null;
u8 in_curr_ch;
u8 dis_sw_retry;
u8 sw_retry_count;
};
struct rtw89_mcc_role {
struct rtw89_vif_link *rtwvif_link;
struct rtw89_mcc_policy policy;
struct rtw89_mcc_limit limit;
const struct rtw89_mcc_courtesy_cfg *crtz;
/* only valid when running with FW MRC mechanism */
u8 slot_idx;
/* byte-array in LE order for FW */
u8 macid_bitmap[BITS_TO_BYTES(RTW89_MAX_MAC_ID_NUM)];
u16 duration; /* TU */
u16 beacon_interval; /* TU */
bool is_2ghz;
bool is_go;
bool is_gc;
};
struct rtw89_mcc_bt_role {
u16 duration; /* TU */
};
struct rtw89_mcc_courtesy_cfg {
u8 slot_num;
u8 macid_tgt;
};
struct rtw89_mcc_courtesy {
struct rtw89_mcc_courtesy_cfg ref;
struct rtw89_mcc_courtesy_cfg aux;
};
enum rtw89_mcc_plan {
RTW89_MCC_PLAN_TAIL_BT,
RTW89_MCC_PLAN_MID_BT,
RTW89_MCC_PLAN_NO_BT,
NUM_OF_RTW89_MCC_PLAN,
};
struct rtw89_mcc_pattern {
s16 tob_ref; /* TU; time offset behind of reference role */
s16 toa_ref; /* TU; time offset ahead of reference role */
s16 tob_aux; /* TU; time offset behind of auxiliary role */
s16 toa_aux; /* TU; time offset ahead of auxiliary role */
enum rtw89_mcc_plan plan;
struct rtw89_mcc_courtesy courtesy;
};
struct rtw89_mcc_sync {
bool enable;
u16 offset; /* TU */
u8 macid_src;
u8 band_src;
u8 port_src;
u8 macid_tgt;
u8 band_tgt;
u8 port_tgt;
};
struct rtw89_mcc_config {
struct rtw89_mcc_pattern pattern;
struct rtw89_mcc_sync sync;
u64 start_tsf;
u64 start_tsf_in_aux_domain;
u16 mcc_interval; /* TU */
u16 beacon_offset; /* TU */
};
enum rtw89_mcc_mode {
RTW89_MCC_MODE_GO_STA,
RTW89_MCC_MODE_GC_STA,
};
struct rtw89_mcc_info {
struct rtw89_wait_info wait;
u8 group;
enum rtw89_mcc_mode mode;
struct rtw89_mcc_role role_ref; /* reference role */
struct rtw89_mcc_role role_aux; /* auxiliary role */
struct rtw89_mcc_bt_role bt_role;
struct rtw89_mcc_config config;
};
enum rtw89_mlo_mode {
RTW89_MLO_MODE_MLSR = 0,
NUM_OF_RTW89_MLO_MODE,
};
struct rtw89_mlo_info {
struct rtw89_wait_info wait;
};
struct rtw89_dev {
struct ieee80211_hw *hw;
struct device *dev;
const struct ieee80211_ops *ops;
bool dbcc_en;
bool support_mlo;
enum rtw89_mlo_dbcc_mode mlo_dbcc_mode;
struct rtw89_hw_scan_info scan_info;
const struct rtw89_chip_info *chip;
const struct rtw89_chip_variant *variant;
const struct rtw89_pci_info *pci_info;
const struct rtw89_rfe_parms *rfe_parms;
struct rtw89_hal hal;
struct rtw89_mcc_info mcc;
struct rtw89_mlo_info mlo;
struct rtw89_mac_info mac;
struct rtw89_fw_info fw;
struct rtw89_hci_info hci;
struct rtw89_efuse efuse;
struct rtw89_traffic_stats stats;
struct rtw89_rfe_data *rfe_data;
enum rtw89_custid custid;
struct rtw89_sta_link __rcu *assoc_link_on_macid[RTW89_MAX_MAC_ID_NUM];
refcount_t refcount_ap_info;
struct list_head rtwvifs_list;
/* used to protect rf read write */
struct mutex rf_mutex;
struct workqueue_struct *txq_wq;
struct work_struct txq_work;
struct delayed_work txq_reinvoke_work;
/* used to protect ba_list and forbid_ba_list */
spinlock_t ba_lock;
/* txqs to setup ba session */
struct list_head ba_list;
/* txqs to forbid ba session */
struct list_head forbid_ba_list;
struct work_struct ba_work;
/* used to protect rpwm */
spinlock_t rpwm_lock;
struct rtw89_cam_info cam_info;
struct sk_buff_head c2h_queue;
struct wiphy_work c2h_work;
struct wiphy_work ips_work;
struct wiphy_work cancel_6ghz_probe_work;
struct work_struct load_firmware_work;
struct list_head early_h2c_list;
struct rtw89_ser ser;
DECLARE_BITMAP(hw_port, RTW89_PORT_NUM);
DECLARE_BITMAP(mac_id_map, RTW89_MAX_MAC_ID_NUM);
DECLARE_BITMAP(flags, NUM_OF_RTW89_FLAGS);
DECLARE_BITMAP(pkt_offload, RTW89_MAX_PKT_OFLD_NUM);
DECLARE_BITMAP(quirks, NUM_OF_RTW89_QUIRKS);
struct rtw89_phy_stat phystat;
struct rtw89_rfk_wait_info rfk_wait;
struct rtw89_dack_info dack;
struct rtw89_iqk_info iqk;
struct rtw89_dpk_info dpk;
struct rtw89_rfk_mcc_info rfk_mcc;
struct rtw89_lck_info lck;
struct rtw89_rx_dck_info rx_dck;
bool is_tssi_mode[RF_PATH_MAX];
bool is_bt_iqk_timeout;
struct rtw89_fem_info fem;
struct rtw89_txpwr_byrate byr[RTW89_BAND_NUM][RTW89_BYR_BW_NUM];
struct rtw89_tssi_info tssi;
struct rtw89_power_trim_info pwr_trim;
struct rtw89_cfo_tracking_info cfo_tracking;
union {
struct rtw89_phy_bb_gain_info ax;
struct rtw89_phy_bb_gain_info_be be;
} bb_gain;
struct rtw89_phy_efuse_gain efuse_gain;
struct rtw89_phy_ul_tb_info ul_tb_info;
struct rtw89_antdiv_info antdiv;
struct rtw89_bb_ctx {
enum rtw89_phy_idx phy_idx;
struct rtw89_env_monitor_info env_monitor;
struct rtw89_dig_info dig;
struct rtw89_phy_ch_info ch_info;
struct rtw89_edcca_bak edcca_bak;
} bbs[RTW89_PHY_NUM];
struct wiphy_delayed_work track_work;
struct wiphy_delayed_work chanctx_work;
struct wiphy_delayed_work coex_act1_work;
struct wiphy_delayed_work coex_bt_devinfo_work;
struct wiphy_delayed_work coex_rfk_chk_work;
struct wiphy_delayed_work cfo_track_work;
struct delayed_work forbid_ba_work;
struct wiphy_delayed_work antdiv_work;
struct rtw89_ppdu_sts_info ppdu_sts;
u8 total_sta_assoc;
bool scanning;
struct rtw89_regulatory_info regulatory;
struct rtw89_sar_info sar;
struct rtw89_tas_info tas;
struct rtw89_ant_gain_info ant_gain;
struct rtw89_btc btc;
enum rtw89_ps_mode ps_mode;
bool lps_enabled;
struct rtw89_wow_param wow;
/* napi structure */
struct net_device *netdev;
struct napi_struct napi;
int napi_budget_countdown;
struct rtw89_debugfs *debugfs;
/* HCI related data, keep last */
u8 priv[] __aligned(sizeof(void *));
};
struct rtw89_link_conf_container {
struct ieee80211_bss_conf *link_conf[IEEE80211_MLD_MAX_NUM_LINKS];
};
#define RTW89_VIF_IDLE_LINK_ID 0
struct rtw89_vif {
struct rtw89_dev *rtwdev;
struct list_head list;
struct list_head mgnt_entry;
struct rtw89_link_conf_container __rcu *snap_link_confs;
u8 mac_addr[ETH_ALEN];
__be32 ip_addr;
struct rtw89_traffic_stats stats;
u32 tdls_peer;
struct ieee80211_scan_ies *scan_ies;
struct cfg80211_scan_request *scan_req;
struct rtw89_roc roc;
bool offchan;
enum rtw89_mlo_mode mlo_mode;
struct list_head dlink_pool;
u8 links_inst_valid_num;
DECLARE_BITMAP(links_inst_map, __RTW89_MLD_MAX_LINK_NUM);
struct rtw89_vif_link *links[IEEE80211_MLD_MAX_NUM_LINKS];
struct rtw89_vif_link links_inst[] __counted_by(links_inst_valid_num);
};
static inline bool rtw89_vif_assign_link_is_valid(struct rtw89_vif_link **rtwvif_link,
const struct rtw89_vif *rtwvif,
unsigned int link_id)
{
*rtwvif_link = rtwvif->links[link_id];
return !!*rtwvif_link;
}
#define rtw89_vif_for_each_link(rtwvif, rtwvif_link, link_id) \
for (link_id = 0; link_id < IEEE80211_MLD_MAX_NUM_LINKS; link_id++) \
if (rtw89_vif_assign_link_is_valid(&(rtwvif_link), rtwvif, link_id))
enum rtw89_sta_flags {
RTW89_REMOTE_STA_IN_PS,
NUM_OF_RTW89_STA_FLAGS,
};
struct rtw89_sta {
struct rtw89_dev *rtwdev;
struct rtw89_vif *rtwvif;
DECLARE_BITMAP(flags, NUM_OF_RTW89_STA_FLAGS);
bool disassoc;
struct sk_buff_head roc_queue;
struct rtw89_ampdu_params ampdu_params[IEEE80211_NUM_TIDS];
DECLARE_BITMAP(ampdu_map, IEEE80211_NUM_TIDS);
DECLARE_BITMAP(pairwise_sec_cam_map, RTW89_MAX_SEC_CAM_NUM);
struct list_head dlink_pool;
u8 links_inst_valid_num;
DECLARE_BITMAP(links_inst_map, __RTW89_MLD_MAX_LINK_NUM);
struct rtw89_sta_link *links[IEEE80211_MLD_MAX_NUM_LINKS];
struct rtw89_sta_link links_inst[] __counted_by(links_inst_valid_num);
};
static inline bool rtw89_sta_assign_link_is_valid(struct rtw89_sta_link **rtwsta_link,
const struct rtw89_sta *rtwsta,
unsigned int link_id)
{
*rtwsta_link = rtwsta->links[link_id];
return !!*rtwsta_link;
}
#define rtw89_sta_for_each_link(rtwsta, rtwsta_link, link_id) \
for (link_id = 0; link_id < IEEE80211_MLD_MAX_NUM_LINKS; link_id++) \
if (rtw89_sta_assign_link_is_valid(&(rtwsta_link), rtwsta, link_id))
static inline u8 rtw89_vif_get_main_macid(struct rtw89_vif *rtwvif)
{
/* const after init, so no need to check if active first */
return rtwvif->links_inst[0].mac_id;
}
static inline u8 rtw89_vif_get_main_port(struct rtw89_vif *rtwvif)
{
/* const after init, so no need to check if active first */
return rtwvif->links_inst[0].port;
}
static inline struct rtw89_vif_link *
rtw89_vif_get_link_inst(struct rtw89_vif *rtwvif, u8 index)
{
if (index >= rtwvif->links_inst_valid_num ||
!test_bit(index, rtwvif->links_inst_map))
return NULL;
return &rtwvif->links_inst[index];
}
static inline
u8 rtw89_vif_link_inst_get_index(struct rtw89_vif_link *rtwvif_link)
{
struct rtw89_vif *rtwvif = rtwvif_link->rtwvif;
return rtwvif_link - rtwvif->links_inst;
}
static inline u8 rtw89_sta_get_main_macid(struct rtw89_sta *rtwsta)
{
/* const after init, so no need to check if active first */
return rtwsta->links_inst[0].mac_id;
}
static inline struct rtw89_sta_link *
rtw89_sta_get_link_inst(struct rtw89_sta *rtwsta, u8 index)
{
if (index >= rtwsta->links_inst_valid_num ||
!test_bit(index, rtwsta->links_inst_map))
return NULL;
return &rtwsta->links_inst[index];
}
static inline
u8 rtw89_sta_link_inst_get_index(struct rtw89_sta_link *rtwsta_link)
{
struct rtw89_sta *rtwsta = rtwsta_link->rtwsta;
return rtwsta_link - rtwsta->links_inst;
}
static inline void rtw89_assoc_link_set(struct rtw89_sta_link *rtwsta_link)
{
struct rtw89_sta *rtwsta = rtwsta_link->rtwsta;
struct rtw89_dev *rtwdev = rtwsta->rtwdev;
rcu_assign_pointer(rtwdev->assoc_link_on_macid[rtwsta_link->mac_id],
rtwsta_link);
}
static inline void rtw89_assoc_link_clr(struct rtw89_sta_link *rtwsta_link)
{
struct rtw89_sta *rtwsta = rtwsta_link->rtwsta;
struct rtw89_dev *rtwdev = rtwsta->rtwdev;
rcu_assign_pointer(rtwdev->assoc_link_on_macid[rtwsta_link->mac_id],
NULL);
synchronize_rcu();
}
static inline struct rtw89_sta_link *
rtw89_assoc_link_rcu_dereference(struct rtw89_dev *rtwdev, u8 macid)
{
return rcu_dereference(rtwdev->assoc_link_on_macid[macid]);
}
#define rtw89_get_designated_link(links_holder) \
({ \
typeof(links_holder) p = links_holder; \
list_first_entry_or_null(&p->dlink_pool, typeof(*p->links_inst), dlink_schd); \
})
static inline int rtw89_hci_tx_write(struct rtw89_dev *rtwdev,
struct rtw89_core_tx_request *tx_req)
{
return rtwdev->hci.ops->tx_write(rtwdev, tx_req);
}
static inline void rtw89_hci_reset(struct rtw89_dev *rtwdev)
{
rtwdev->hci.ops->reset(rtwdev);
}
static inline int rtw89_hci_start(struct rtw89_dev *rtwdev)
{
return rtwdev->hci.ops->start(rtwdev);
}
static inline void rtw89_hci_stop(struct rtw89_dev *rtwdev)
{
rtwdev->hci.ops->stop(rtwdev);
}
static inline int rtw89_hci_deinit(struct rtw89_dev *rtwdev)
{
return rtwdev->hci.ops->deinit(rtwdev);
}
static inline void rtw89_hci_pause(struct rtw89_dev *rtwdev, bool pause)
{
rtwdev->hci.ops->pause(rtwdev, pause);
}
static inline void rtw89_hci_switch_mode(struct rtw89_dev *rtwdev, bool low_power)
{
rtwdev->hci.ops->switch_mode(rtwdev, low_power);
}
static inline void rtw89_hci_recalc_int_mit(struct rtw89_dev *rtwdev)
{
rtwdev->hci.ops->recalc_int_mit(rtwdev);
}
static inline u32 rtw89_hci_check_and_reclaim_tx_resource(struct rtw89_dev *rtwdev, u8 txch)
{
return rtwdev->hci.ops->check_and_reclaim_tx_resource(rtwdev, txch);
}
static inline void rtw89_hci_tx_kick_off(struct rtw89_dev *rtwdev, u8 txch)
{
return rtwdev->hci.ops->tx_kick_off(rtwdev, txch);
}
static inline int rtw89_hci_mac_pre_deinit(struct rtw89_dev *rtwdev)
{
return rtwdev->hci.ops->mac_pre_deinit(rtwdev);
}
static inline void rtw89_hci_flush_queues(struct rtw89_dev *rtwdev, u32 queues,
bool drop)
{
if (!test_bit(RTW89_FLAG_POWERON, rtwdev->flags))
return;
if (rtwdev->hci.ops->flush_queues)
return rtwdev->hci.ops->flush_queues(rtwdev, queues, drop);
}
static inline void rtw89_hci_recovery_start(struct rtw89_dev *rtwdev)
{
if (rtwdev->hci.ops->recovery_start)
rtwdev->hci.ops->recovery_start(rtwdev);
}
static inline void rtw89_hci_recovery_complete(struct rtw89_dev *rtwdev)
{
if (rtwdev->hci.ops->recovery_complete)
rtwdev->hci.ops->recovery_complete(rtwdev);
}
static inline void rtw89_hci_enable_intr(struct rtw89_dev *rtwdev)
{
if (rtwdev->hci.ops->enable_intr)
rtwdev->hci.ops->enable_intr(rtwdev);
}
static inline void rtw89_hci_disable_intr(struct rtw89_dev *rtwdev)
{
if (rtwdev->hci.ops->disable_intr)
rtwdev->hci.ops->disable_intr(rtwdev);
}
static inline void rtw89_hci_ctrl_txdma_ch(struct rtw89_dev *rtwdev, bool enable)
{
if (rtwdev->hci.ops->ctrl_txdma_ch)
rtwdev->hci.ops->ctrl_txdma_ch(rtwdev, enable);
}
static inline void rtw89_hci_ctrl_txdma_fw_ch(struct rtw89_dev *rtwdev, bool enable)
{
if (rtwdev->hci.ops->ctrl_txdma_fw_ch)
rtwdev->hci.ops->ctrl_txdma_fw_ch(rtwdev, enable);
}
static inline void rtw89_hci_ctrl_trxhci(struct rtw89_dev *rtwdev, bool enable)
{
if (rtwdev->hci.ops->ctrl_trxhci)
rtwdev->hci.ops->ctrl_trxhci(rtwdev, enable);
}
static inline int rtw89_hci_poll_txdma_ch_idle(struct rtw89_dev *rtwdev)
{
int ret = 0;
if (rtwdev->hci.ops->poll_txdma_ch_idle)
ret = rtwdev->hci.ops->poll_txdma_ch_idle(rtwdev);
return ret;
}
static inline void rtw89_hci_clr_idx_all(struct rtw89_dev *rtwdev)
{
if (rtwdev->hci.ops->clr_idx_all)
rtwdev->hci.ops->clr_idx_all(rtwdev);
}
static inline int rtw89_hci_rst_bdram(struct rtw89_dev *rtwdev)
{
int ret = 0;
if (rtwdev->hci.ops->rst_bdram)
ret = rtwdev->hci.ops->rst_bdram(rtwdev);
return ret;
}
static inline void rtw89_hci_clear(struct rtw89_dev *rtwdev, struct pci_dev *pdev)
{
if (rtwdev->hci.ops->clear)
rtwdev->hci.ops->clear(rtwdev, pdev);
}
static inline
struct rtw89_tx_skb_data *RTW89_TX_SKB_CB(struct sk_buff *skb)
{
struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
return (struct rtw89_tx_skb_data *)info->status.status_driver_data;
}
static inline u8 rtw89_read8(struct rtw89_dev *rtwdev, u32 addr)
{
return rtwdev->hci.ops->read8(rtwdev, addr);
}
static inline u16 rtw89_read16(struct rtw89_dev *rtwdev, u32 addr)
{
return rtwdev->hci.ops->read16(rtwdev, addr);
}
static inline u32 rtw89_read32(struct rtw89_dev *rtwdev, u32 addr)
{
return rtwdev->hci.ops->read32(rtwdev, addr);
}
static inline void rtw89_write8(struct rtw89_dev *rtwdev, u32 addr, u8 data)
{
rtwdev->hci.ops->write8(rtwdev, addr, data);
}
static inline void rtw89_write16(struct rtw89_dev *rtwdev, u32 addr, u16 data)
{
rtwdev->hci.ops->write16(rtwdev, addr, data);
}
static inline void rtw89_write32(struct rtw89_dev *rtwdev, u32 addr, u32 data)
{
rtwdev->hci.ops->write32(rtwdev, addr, data);
}
static inline void
rtw89_write8_set(struct rtw89_dev *rtwdev, u32 addr, u8 bit)
{
u8 val;
val = rtw89_read8(rtwdev, addr);
rtw89_write8(rtwdev, addr, val | bit);
}
static inline void
rtw89_write16_set(struct rtw89_dev *rtwdev, u32 addr, u16 bit)
{
u16 val;
val = rtw89_read16(rtwdev, addr);
rtw89_write16(rtwdev, addr, val | bit);
}
static inline void
rtw89_write32_set(struct rtw89_dev *rtwdev, u32 addr, u32 bit)
{
u32 val;
val = rtw89_read32(rtwdev, addr);
rtw89_write32(rtwdev, addr, val | bit);
}
static inline void
rtw89_write8_clr(struct rtw89_dev *rtwdev, u32 addr, u8 bit)
{
u8 val;
val = rtw89_read8(rtwdev, addr);
rtw89_write8(rtwdev, addr, val & ~bit);
}
static inline void
rtw89_write16_clr(struct rtw89_dev *rtwdev, u32 addr, u16 bit)
{
u16 val;
val = rtw89_read16(rtwdev, addr);
rtw89_write16(rtwdev, addr, val & ~bit);
}
static inline void
rtw89_write32_clr(struct rtw89_dev *rtwdev, u32 addr, u32 bit)
{
u32 val;
val = rtw89_read32(rtwdev, addr);
rtw89_write32(rtwdev, addr, val & ~bit);
}
static inline u32
rtw89_read32_mask(struct rtw89_dev *rtwdev, u32 addr, u32 mask)
{
u32 shift = __ffs(mask);
u32 orig;
u32 ret;
orig = rtw89_read32(rtwdev, addr);
ret = (orig & mask) >> shift;
return ret;
}
static inline u16
rtw89_read16_mask(struct rtw89_dev *rtwdev, u32 addr, u32 mask)
{
u32 shift = __ffs(mask);
u32 orig;
u32 ret;
orig = rtw89_read16(rtwdev, addr);
ret = (orig & mask) >> shift;
return ret;
}
static inline u8
rtw89_read8_mask(struct rtw89_dev *rtwdev, u32 addr, u32 mask)
{
u32 shift = __ffs(mask);
u32 orig;
u32 ret;
orig = rtw89_read8(rtwdev, addr);
ret = (orig & mask) >> shift;
return ret;
}
static inline void
rtw89_write32_mask(struct rtw89_dev *rtwdev, u32 addr, u32 mask, u32 data)
{
u32 shift = __ffs(mask);
u32 orig;
u32 set;
WARN(addr & 0x3, "should be 4-byte aligned, addr = 0x%08x\n", addr);
orig = rtw89_read32(rtwdev, addr);
set = (orig & ~mask) | ((data << shift) & mask);
rtw89_write32(rtwdev, addr, set);
}
static inline void
rtw89_write16_mask(struct rtw89_dev *rtwdev, u32 addr, u32 mask, u16 data)
{
u32 shift;
u16 orig, set;
mask &= 0xffff;
shift = __ffs(mask);
orig = rtw89_read16(rtwdev, addr);
set = (orig & ~mask) | ((data << shift) & mask);
rtw89_write16(rtwdev, addr, set);
}
static inline void
rtw89_write8_mask(struct rtw89_dev *rtwdev, u32 addr, u32 mask, u8 data)
{
u32 shift;
u8 orig, set;
mask &= 0xff;
shift = __ffs(mask);
orig = rtw89_read8(rtwdev, addr);
set = (orig & ~mask) | ((data << shift) & mask);
rtw89_write8(rtwdev, addr, set);
}
static inline u32
rtw89_read_rf(struct rtw89_dev *rtwdev, enum rtw89_rf_path rf_path,
u32 addr, u32 mask)
{
u32 val;
mutex_lock(&rtwdev->rf_mutex);
val = rtwdev->chip->ops->read_rf(rtwdev, rf_path, addr, mask);
mutex_unlock(&rtwdev->rf_mutex);
return val;
}
static inline void
rtw89_write_rf(struct rtw89_dev *rtwdev, enum rtw89_rf_path rf_path,
u32 addr, u32 mask, u32 data)
{
mutex_lock(&rtwdev->rf_mutex);
rtwdev->chip->ops->write_rf(rtwdev, rf_path, addr, mask, data);
mutex_unlock(&rtwdev->rf_mutex);
}
static inline struct ieee80211_txq *rtw89_txq_to_txq(struct rtw89_txq *rtwtxq)
{
void *p = rtwtxq;
return container_of(p, struct ieee80211_txq, drv_priv);
}
static inline void rtw89_core_txq_init(struct rtw89_dev *rtwdev,
struct ieee80211_txq *txq)
{
struct rtw89_txq *rtwtxq;
if (!txq)
return;
rtwtxq = (struct rtw89_txq *)txq->drv_priv;
INIT_LIST_HEAD(&rtwtxq->list);
}
static inline struct ieee80211_vif *rtwvif_to_vif(struct rtw89_vif *rtwvif)
{
void *p = rtwvif;
return container_of(p, struct ieee80211_vif, drv_priv);
}
static inline struct ieee80211_vif *rtwvif_to_vif_safe(struct rtw89_vif *rtwvif)
{
return rtwvif ? rtwvif_to_vif(rtwvif) : NULL;
}
static inline
struct ieee80211_vif *rtwvif_link_to_vif(struct rtw89_vif_link *rtwvif_link)
{
return rtwvif_to_vif(rtwvif_link->rtwvif);
}
static inline
struct ieee80211_vif *rtwvif_link_to_vif_safe(struct rtw89_vif_link *rtwvif_link)
{
return rtwvif_link ? rtwvif_link_to_vif(rtwvif_link) : NULL;
}
static inline struct rtw89_vif *vif_to_rtwvif(struct ieee80211_vif *vif)
{
return (struct rtw89_vif *)vif->drv_priv;
}
static inline struct rtw89_vif *vif_to_rtwvif_safe(struct ieee80211_vif *vif)
{
return vif ? vif_to_rtwvif(vif) : NULL;
}
static inline struct ieee80211_sta *rtwsta_to_sta(struct rtw89_sta *rtwsta)
{
void *p = rtwsta;
return container_of(p, struct ieee80211_sta, drv_priv);
}
static inline struct ieee80211_sta *rtwsta_to_sta_safe(struct rtw89_sta *rtwsta)
{
return rtwsta ? rtwsta_to_sta(rtwsta) : NULL;
}
static inline
struct ieee80211_sta *rtwsta_link_to_sta(struct rtw89_sta_link *rtwsta_link)
{
return rtwsta_to_sta(rtwsta_link->rtwsta);
}
static inline
struct ieee80211_sta *rtwsta_link_to_sta_safe(struct rtw89_sta_link *rtwsta_link)
{
return rtwsta_link ? rtwsta_link_to_sta(rtwsta_link) : NULL;
}
static inline struct rtw89_sta *sta_to_rtwsta(struct ieee80211_sta *sta)
{
return (struct rtw89_sta *)sta->drv_priv;
}
static inline struct rtw89_sta *sta_to_rtwsta_safe(struct ieee80211_sta *sta)
{
return sta ? sta_to_rtwsta(sta) : NULL;
}
static inline struct ieee80211_bss_conf *
__rtw89_vif_rcu_dereference_link(struct rtw89_vif_link *rtwvif_link, bool *nolink)
{
struct ieee80211_vif *vif = rtwvif_link_to_vif(rtwvif_link);
struct rtw89_vif *rtwvif = rtwvif_link->rtwvif;
struct rtw89_link_conf_container *snap;
struct ieee80211_bss_conf *bss_conf;
snap = rcu_dereference(rtwvif->snap_link_confs);
if (snap) {
bss_conf = snap->link_conf[rtwvif_link->link_id];
goto out;
}
bss_conf = rcu_dereference(vif->link_conf[rtwvif_link->link_id]);
out:
if (unlikely(!bss_conf)) {
*nolink = true;
return &vif->bss_conf;
}
*nolink = false;
return bss_conf;
}
#define rtw89_vif_rcu_dereference_link(rtwvif_link, assert) \
({ \
typeof(rtwvif_link) p = rtwvif_link; \
struct ieee80211_bss_conf *bss_conf; \
bool nolink; \
\
bss_conf = __rtw89_vif_rcu_dereference_link(p, &nolink); \
if (unlikely(nolink) && (assert)) \
rtw89_err(p->rtwvif->rtwdev, \
"%s: cannot find exact bss_conf for link_id %u\n",\
__func__, p->link_id); \
bss_conf; \
})
static inline struct ieee80211_link_sta *
__rtw89_sta_rcu_dereference_link(struct rtw89_sta_link *rtwsta_link, bool *nolink)
{
struct ieee80211_sta *sta = rtwsta_link_to_sta(rtwsta_link);
struct ieee80211_link_sta *link_sta;
link_sta = rcu_dereference(sta->link[rtwsta_link->link_id]);
if (unlikely(!link_sta)) {
*nolink = true;
return &sta->deflink;
}
*nolink = false;
return link_sta;
}
#define rtw89_sta_rcu_dereference_link(rtwsta_link, assert) \
({ \
typeof(rtwsta_link) p = rtwsta_link; \
struct ieee80211_link_sta *link_sta; \
bool nolink; \
\
link_sta = __rtw89_sta_rcu_dereference_link(p, &nolink); \
if (unlikely(nolink) && (assert)) \
rtw89_err(p->rtwsta->rtwdev, \
"%s: cannot find exact link_sta for link_id %u\n",\
__func__, p->link_id); \
link_sta; \
})
static inline u8 rtw89_hw_to_rate_info_bw(enum rtw89_bandwidth hw_bw)
{
if (hw_bw == RTW89_CHANNEL_WIDTH_160)
return RATE_INFO_BW_160;
else if (hw_bw == RTW89_CHANNEL_WIDTH_80)
return RATE_INFO_BW_80;
else if (hw_bw == RTW89_CHANNEL_WIDTH_40)
return RATE_INFO_BW_40;
else
return RATE_INFO_BW_20;
}
static inline
enum nl80211_band rtw89_hw_to_nl80211_band(enum rtw89_band hw_band)
{
switch (hw_band) {
default:
case RTW89_BAND_2G:
return NL80211_BAND_2GHZ;
case RTW89_BAND_5G:
return NL80211_BAND_5GHZ;
case RTW89_BAND_6G:
return NL80211_BAND_6GHZ;
}
}
static inline
enum rtw89_band rtw89_nl80211_to_hw_band(enum nl80211_band nl_band)
{
switch (nl_band) {
default:
case NL80211_BAND_2GHZ:
return RTW89_BAND_2G;
case NL80211_BAND_5GHZ:
return RTW89_BAND_5G;
case NL80211_BAND_6GHZ:
return RTW89_BAND_6G;
}
}
static inline
enum rtw89_bandwidth nl_to_rtw89_bandwidth(enum nl80211_chan_width width)
{
switch (width) {
default:
WARN(1, "Not support bandwidth %d\n", width);
fallthrough;
case NL80211_CHAN_WIDTH_20_NOHT:
case NL80211_CHAN_WIDTH_20:
return RTW89_CHANNEL_WIDTH_20;
case NL80211_CHAN_WIDTH_40:
return RTW89_CHANNEL_WIDTH_40;
case NL80211_CHAN_WIDTH_80:
return RTW89_CHANNEL_WIDTH_80;
case NL80211_CHAN_WIDTH_160:
return RTW89_CHANNEL_WIDTH_160;
}
}
static inline
enum nl80211_he_ru_alloc rtw89_he_rua_to_ru_alloc(u16 rua)
{
switch (rua) {
default:
WARN(1, "Invalid RU allocation: %d\n", rua);
fallthrough;
case 0 ... 36:
return NL80211_RATE_INFO_HE_RU_ALLOC_26;
case 37 ... 52:
return NL80211_RATE_INFO_HE_RU_ALLOC_52;
case 53 ... 60:
return NL80211_RATE_INFO_HE_RU_ALLOC_106;
case 61 ... 64:
return NL80211_RATE_INFO_HE_RU_ALLOC_242;
case 65 ... 66:
return NL80211_RATE_INFO_HE_RU_ALLOC_484;
case 67:
return NL80211_RATE_INFO_HE_RU_ALLOC_996;
case 68:
return NL80211_RATE_INFO_HE_RU_ALLOC_2x996;
}
}
static inline
struct rtw89_addr_cam_entry *rtw89_get_addr_cam_of(struct rtw89_vif_link *rtwvif_link,
struct rtw89_sta_link *rtwsta_link)
{
if (rtwsta_link) {
struct ieee80211_sta *sta = rtwsta_link_to_sta(rtwsta_link);
if (rtwvif_link->net_type == RTW89_NET_TYPE_AP_MODE || sta->tdls)
return &rtwsta_link->addr_cam;
}
return &rtwvif_link->addr_cam;
}
static inline
struct rtw89_bssid_cam_entry *rtw89_get_bssid_cam_of(struct rtw89_vif_link *rtwvif_link,
struct rtw89_sta_link *rtwsta_link)
{
if (rtwsta_link) {
struct ieee80211_sta *sta = rtwsta_link_to_sta(rtwsta_link);
if (sta->tdls)
return &rtwsta_link->bssid_cam;
}
return &rtwvif_link->bssid_cam;
}
static inline
void rtw89_chip_set_channel_prepare(struct rtw89_dev *rtwdev,
struct rtw89_channel_help_params *p,
const struct rtw89_chan *chan,
enum rtw89_mac_idx mac_idx,
enum rtw89_phy_idx phy_idx)
{
rtwdev->chip->ops->set_channel_help(rtwdev, true, p, chan,
mac_idx, phy_idx);
}
static inline
void rtw89_chip_set_channel_done(struct rtw89_dev *rtwdev,
struct rtw89_channel_help_params *p,
const struct rtw89_chan *chan,
enum rtw89_mac_idx mac_idx,
enum rtw89_phy_idx phy_idx)
{
rtwdev->chip->ops->set_channel_help(rtwdev, false, p, chan,
mac_idx, phy_idx);
}
static inline
const struct cfg80211_chan_def *rtw89_chandef_get(struct rtw89_dev *rtwdev,
enum rtw89_chanctx_idx idx)
{
struct rtw89_hal *hal = &rtwdev->hal;
enum rtw89_chanctx_idx roc_idx = atomic_read(&hal->roc_chanctx_idx);
if (roc_idx == idx)
return &hal->roc_chandef;
return &hal->chanctx[idx].chandef;
}
static inline
const struct rtw89_chan *rtw89_chan_get(struct rtw89_dev *rtwdev,
enum rtw89_chanctx_idx idx)
{
struct rtw89_hal *hal = &rtwdev->hal;
return &hal->chanctx[idx].chan;
}
static inline
const struct rtw89_chan_rcd *rtw89_chan_rcd_get(struct rtw89_dev *rtwdev,
enum rtw89_chanctx_idx idx)
{
struct rtw89_hal *hal = &rtwdev->hal;
return &hal->chanctx[idx].rcd;
}
static inline
const struct rtw89_chan_rcd *rtw89_chan_rcd_get_by_chan(const struct rtw89_chan *chan)
{
const struct rtw89_chanctx *chanctx =
container_of_const(chan, struct rtw89_chanctx, chan);
return &chanctx->rcd;
}
static inline
const struct rtw89_chan *rtw89_scan_chan_get(struct rtw89_dev *rtwdev)
{
struct rtw89_vif_link *rtwvif_link = rtwdev->scan_info.scanning_vif;
if (rtwvif_link)
return rtw89_chan_get(rtwdev, rtwvif_link->chanctx_idx);
else
return rtw89_chan_get(rtwdev, RTW89_CHANCTX_0);
}
static inline void rtw89_chip_fem_setup(struct rtw89_dev *rtwdev)
{
const struct rtw89_chip_info *chip = rtwdev->chip;
if (chip->ops->fem_setup)
chip->ops->fem_setup(rtwdev);
}
static inline void rtw89_chip_rfe_gpio(struct rtw89_dev *rtwdev)
{
const struct rtw89_chip_info *chip = rtwdev->chip;
if (chip->ops->rfe_gpio)
chip->ops->rfe_gpio(rtwdev);
}
static inline void rtw89_chip_rfk_hw_init(struct rtw89_dev *rtwdev)
{
const struct rtw89_chip_info *chip = rtwdev->chip;
if (chip->ops->rfk_hw_init)
chip->ops->rfk_hw_init(rtwdev);
}
static inline
void rtw89_chip_bb_preinit(struct rtw89_dev *rtwdev, enum rtw89_phy_idx phy_idx)
{
const struct rtw89_chip_info *chip = rtwdev->chip;
if (chip->ops->bb_preinit)
chip->ops->bb_preinit(rtwdev, phy_idx);
}
static inline
void rtw89_chip_bb_postinit(struct rtw89_dev *rtwdev)
{
const struct rtw89_chip_info *chip = rtwdev->chip;
if (!chip->ops->bb_postinit)
return;
chip->ops->bb_postinit(rtwdev, RTW89_PHY_0);
if (rtwdev->dbcc_en)
chip->ops->bb_postinit(rtwdev, RTW89_PHY_1);
}
static inline void rtw89_chip_bb_sethw(struct rtw89_dev *rtwdev)
{
const struct rtw89_chip_info *chip = rtwdev->chip;
if (chip->ops->bb_sethw)
chip->ops->bb_sethw(rtwdev);
}
static inline void rtw89_chip_rfk_init(struct rtw89_dev *rtwdev)
{
const struct rtw89_chip_info *chip = rtwdev->chip;
if (chip->ops->rfk_init)
chip->ops->rfk_init(rtwdev);
}
static inline void rtw89_chip_rfk_init_late(struct rtw89_dev *rtwdev)
{
const struct rtw89_chip_info *chip = rtwdev->chip;
if (chip->ops->rfk_init_late)
chip->ops->rfk_init_late(rtwdev);
}
static inline void rtw89_chip_rfk_channel(struct rtw89_dev *rtwdev,
struct rtw89_vif_link *rtwvif_link)
{
const struct rtw89_chip_info *chip = rtwdev->chip;
if (chip->ops->rfk_channel)
chip->ops->rfk_channel(rtwdev, rtwvif_link);
}
static inline void rtw89_chip_rfk_band_changed(struct rtw89_dev *rtwdev,
enum rtw89_phy_idx phy_idx,
const struct rtw89_chan *chan)
{
const struct rtw89_chip_info *chip = rtwdev->chip;
if (chip->ops->rfk_band_changed)
chip->ops->rfk_band_changed(rtwdev, phy_idx, chan);
}
static inline void rtw89_chip_rfk_scan(struct rtw89_dev *rtwdev,
struct rtw89_vif_link *rtwvif_link, bool start)
{
const struct rtw89_chip_info *chip = rtwdev->chip;
if (chip->ops->rfk_scan)
chip->ops->rfk_scan(rtwdev, rtwvif_link, start);
}
static inline void rtw89_chip_rfk_track(struct rtw89_dev *rtwdev)
{
const struct rtw89_chip_info *chip = rtwdev->chip;
if (chip->ops->rfk_track)
chip->ops->rfk_track(rtwdev);
}
static inline void rtw89_chip_set_txpwr_ctrl(struct rtw89_dev *rtwdev)
{
const struct rtw89_chip_info *chip = rtwdev->chip;
if (!chip->ops->set_txpwr_ctrl)
return;
chip->ops->set_txpwr_ctrl(rtwdev, RTW89_PHY_0);
if (rtwdev->dbcc_en)
chip->ops->set_txpwr_ctrl(rtwdev, RTW89_PHY_1);
}
static inline void rtw89_chip_power_trim(struct rtw89_dev *rtwdev)
{
const struct rtw89_chip_info *chip = rtwdev->chip;
if (chip->ops->power_trim)
chip->ops->power_trim(rtwdev);
}
static inline void __rtw89_chip_init_txpwr_unit(struct rtw89_dev *rtwdev,
enum rtw89_phy_idx phy_idx)
{
const struct rtw89_chip_info *chip = rtwdev->chip;
if (chip->ops->init_txpwr_unit)
chip->ops->init_txpwr_unit(rtwdev, phy_idx);
}
static inline void rtw89_chip_init_txpwr_unit(struct rtw89_dev *rtwdev)
{
__rtw89_chip_init_txpwr_unit(rtwdev, RTW89_PHY_0);
if (rtwdev->dbcc_en)
__rtw89_chip_init_txpwr_unit(rtwdev, RTW89_PHY_1);
}
static inline u8 rtw89_chip_get_thermal(struct rtw89_dev *rtwdev,
enum rtw89_rf_path rf_path)
{
const struct rtw89_chip_info *chip = rtwdev->chip;
if (!chip->ops->get_thermal)
return 0x10;
return chip->ops->get_thermal(rtwdev, rf_path);
}
static inline void rtw89_chip_query_ppdu(struct rtw89_dev *rtwdev,
struct rtw89_rx_phy_ppdu *phy_ppdu,
struct ieee80211_rx_status *status)
{
const struct rtw89_chip_info *chip = rtwdev->chip;
if (chip->ops->query_ppdu)
chip->ops->query_ppdu(rtwdev, phy_ppdu, status);
}
static inline void rtw89_chip_convert_rpl_to_rssi(struct rtw89_dev *rtwdev,
struct rtw89_rx_phy_ppdu *phy_ppdu)
{
const struct rtw89_chip_info *chip = rtwdev->chip;
if (chip->ops->convert_rpl_to_rssi)
chip->ops->convert_rpl_to_rssi(rtwdev, phy_ppdu);
}
static inline void rtw89_chip_phy_rpt_to_rssi(struct rtw89_dev *rtwdev,
struct rtw89_rx_desc_info *desc_info,
struct ieee80211_rx_status *rx_status)
{
const struct rtw89_chip_info *chip = rtwdev->chip;
if (chip->ops->phy_rpt_to_rssi)
chip->ops->phy_rpt_to_rssi(rtwdev, desc_info, rx_status);
}
static inline void rtw89_ctrl_nbtg_bt_tx(struct rtw89_dev *rtwdev, bool en,
enum rtw89_phy_idx phy_idx)
{
const struct rtw89_chip_info *chip = rtwdev->chip;
if (chip->ops->ctrl_nbtg_bt_tx)
chip->ops->ctrl_nbtg_bt_tx(rtwdev, en, phy_idx);
}
static inline void rtw89_chip_cfg_txrx_path(struct rtw89_dev *rtwdev)
{
const struct rtw89_chip_info *chip = rtwdev->chip;
if (chip->ops->cfg_txrx_path)
chip->ops->cfg_txrx_path(rtwdev);
}
static inline void rtw89_chip_digital_pwr_comp(struct rtw89_dev *rtwdev,
enum rtw89_phy_idx phy_idx)
{
const struct rtw89_chip_info *chip = rtwdev->chip;
if (chip->ops->digital_pwr_comp)
chip->ops->digital_pwr_comp(rtwdev, phy_idx);
}
static inline void rtw89_load_txpwr_table(struct rtw89_dev *rtwdev,
const struct rtw89_txpwr_table *tbl)
{
tbl->load(rtwdev, tbl);
}
static inline u8 rtw89_regd_get(struct rtw89_dev *rtwdev, u8 band)
{
const struct rtw89_regulatory_info *regulatory = &rtwdev->regulatory;
const struct rtw89_regd *regd = regulatory->regd;
u8 txpwr_regd = regd->txpwr_regd[band];
if (regulatory->txpwr_uk_follow_etsi && txpwr_regd == RTW89_UK)
return RTW89_ETSI;
return txpwr_regd;
}
static inline void rtw89_ctrl_btg_bt_rx(struct rtw89_dev *rtwdev, bool en,
enum rtw89_phy_idx phy_idx)
{
const struct rtw89_chip_info *chip = rtwdev->chip;
if (chip->ops->ctrl_btg_bt_rx)
chip->ops->ctrl_btg_bt_rx(rtwdev, en, phy_idx);
}
static inline
void rtw89_chip_query_rxdesc(struct rtw89_dev *rtwdev,
struct rtw89_rx_desc_info *desc_info,
u8 *data, u32 data_offset)
{
const struct rtw89_chip_info *chip = rtwdev->chip;
chip->ops->query_rxdesc(rtwdev, desc_info, data, data_offset);
}
static inline
void rtw89_chip_fill_txdesc(struct rtw89_dev *rtwdev,
struct rtw89_tx_desc_info *desc_info,
void *txdesc)
{
const struct rtw89_chip_info *chip = rtwdev->chip;
chip->ops->fill_txdesc(rtwdev, desc_info, txdesc);
}
static inline
void rtw89_chip_fill_txdesc_fwcmd(struct rtw89_dev *rtwdev,
struct rtw89_tx_desc_info *desc_info,
void *txdesc)
{
const struct rtw89_chip_info *chip = rtwdev->chip;
chip->ops->fill_txdesc_fwcmd(rtwdev, desc_info, txdesc);
}
static inline
void rtw89_chip_mac_cfg_gnt(struct rtw89_dev *rtwdev,
const struct rtw89_mac_ax_coex_gnt *gnt_cfg)
{
const struct rtw89_chip_info *chip = rtwdev->chip;
chip->ops->mac_cfg_gnt(rtwdev, gnt_cfg);
}
static inline void rtw89_chip_cfg_ctrl_path(struct rtw89_dev *rtwdev, bool wl)
{
const struct rtw89_chip_info *chip = rtwdev->chip;
chip->ops->cfg_ctrl_path(rtwdev, wl);
}
static inline
int rtw89_chip_stop_sch_tx(struct rtw89_dev *rtwdev, u8 mac_idx,
u32 *tx_en, enum rtw89_sch_tx_sel sel)
{
const struct rtw89_chip_info *chip = rtwdev->chip;
return chip->ops->stop_sch_tx(rtwdev, mac_idx, tx_en, sel);
}
static inline
int rtw89_chip_resume_sch_tx(struct rtw89_dev *rtwdev, u8 mac_idx, u32 tx_en)
{
const struct rtw89_chip_info *chip = rtwdev->chip;
return chip->ops->resume_sch_tx(rtwdev, mac_idx, tx_en);
}
static inline
int rtw89_chip_h2c_dctl_sec_cam(struct rtw89_dev *rtwdev,
struct rtw89_vif_link *rtwvif_link,
struct rtw89_sta_link *rtwsta_link)
{
const struct rtw89_chip_info *chip = rtwdev->chip;
if (!chip->ops->h2c_dctl_sec_cam)
return 0;
return chip->ops->h2c_dctl_sec_cam(rtwdev, rtwvif_link, rtwsta_link);
}
static inline u8 *get_hdr_bssid(struct ieee80211_hdr *hdr)
{
__le16 fc = hdr->frame_control;
if (ieee80211_has_tods(fc))
return hdr->addr1;
else if (ieee80211_has_fromds(fc))
return hdr->addr2;
else
return hdr->addr3;
}
static inline
bool rtw89_sta_has_beamformer_cap(struct ieee80211_link_sta *link_sta)
{
if ((link_sta->vht_cap.cap & IEEE80211_VHT_CAP_MU_BEAMFORMER_CAPABLE) ||
(link_sta->vht_cap.cap & IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE) ||
(link_sta->he_cap.he_cap_elem.phy_cap_info[3] &
IEEE80211_HE_PHY_CAP3_SU_BEAMFORMER) ||
(link_sta->he_cap.he_cap_elem.phy_cap_info[4] &
IEEE80211_HE_PHY_CAP4_MU_BEAMFORMER))
return true;
return false;
}
static inline
bool rtw89_sta_link_has_su_mu_4xhe08(struct ieee80211_link_sta *link_sta)
{
if (link_sta->he_cap.he_cap_elem.phy_cap_info[7] &
IEEE80211_HE_PHY_CAP7_HE_SU_MU_PPDU_4XLTF_AND_08_US_GI)
return true;
return false;
}
static inline
bool rtw89_sta_link_has_er_su_4xhe08(struct ieee80211_link_sta *link_sta)
{
if (link_sta->he_cap.he_cap_elem.phy_cap_info[8] &
IEEE80211_HE_PHY_CAP8_HE_ER_SU_PPDU_4XLTF_AND_08_US_GI)
return true;
return false;
}
static inline struct rtw89_fw_suit *rtw89_fw_suit_get(struct rtw89_dev *rtwdev,
enum rtw89_fw_type type)
{
struct rtw89_fw_info *fw_info = &rtwdev->fw;
switch (type) {
case RTW89_FW_WOWLAN:
return &fw_info->wowlan;
case RTW89_FW_LOGFMT:
return &fw_info->log.suit;
case RTW89_FW_BBMCU0:
return &fw_info->bbmcu0;
case RTW89_FW_BBMCU1:
return &fw_info->bbmcu1;
default:
break;
}
return &fw_info->normal;
}
static inline struct sk_buff *rtw89_alloc_skb_for_rx(struct rtw89_dev *rtwdev,
unsigned int length)
{
struct sk_buff *skb;
if (rtwdev->hw->conf.flags & IEEE80211_CONF_MONITOR) {
skb = dev_alloc_skb(length + RTW89_RADIOTAP_ROOM);
if (!skb)
return NULL;
skb_reserve(skb, RTW89_RADIOTAP_ROOM);
return skb;
}
return dev_alloc_skb(length);
}
static inline void rtw89_core_tx_wait_complete(struct rtw89_dev *rtwdev,
struct rtw89_tx_skb_data *skb_data,
bool tx_done)
{
struct rtw89_tx_wait_info *wait;
rcu_read_lock();
wait = rcu_dereference(skb_data->wait);
if (!wait)
goto out;
wait->tx_done = tx_done;
complete(&wait->completion);
out:
rcu_read_unlock();
}
static inline bool rtw89_is_mlo_1_1(struct rtw89_dev *rtwdev)
{
switch (rtwdev->mlo_dbcc_mode) {
case MLO_1_PLUS_1_1RF:
case MLO_1_PLUS_1_2RF:
case DBCC_LEGACY:
return true;
default:
return false;
}
}
static inline u8 rtw89_get_active_phy_bitmap(struct rtw89_dev *rtwdev)
{
if (!rtwdev->dbcc_en)
return BIT(RTW89_PHY_0);
switch (rtwdev->mlo_dbcc_mode) {
case MLO_0_PLUS_2_1RF:
case MLO_0_PLUS_2_2RF:
return BIT(RTW89_PHY_1);
case MLO_1_PLUS_1_1RF:
case MLO_1_PLUS_1_2RF:
case MLO_2_PLUS_2_2RF:
case DBCC_LEGACY:
return BIT(RTW89_PHY_0) | BIT(RTW89_PHY_1);
case MLO_2_PLUS_0_1RF:
case MLO_2_PLUS_0_2RF:
default:
return BIT(RTW89_PHY_0);
}
}
#define rtw89_for_each_active_bb(rtwdev, bb) \
for (u8 __active_bb_bitmap = rtw89_get_active_phy_bitmap(rtwdev), \
__phy_idx = 0; __phy_idx < RTW89_PHY_NUM; __phy_idx++) \
if (__active_bb_bitmap & BIT(__phy_idx) && \
(bb = &rtwdev->bbs[__phy_idx]))
#define rtw89_for_each_capab_bb(rtwdev, bb) \
for (u8 __phy_idx_max = rtwdev->dbcc_en ? RTW89_PHY_1 : RTW89_PHY_0, \
__phy_idx = 0; __phy_idx <= __phy_idx_max; __phy_idx++) \
if ((bb = &rtwdev->bbs[__phy_idx]))
static inline
struct rtw89_bb_ctx *rtw89_get_bb_ctx(struct rtw89_dev *rtwdev,
enum rtw89_phy_idx phy_idx)
{
if (phy_idx >= RTW89_PHY_NUM)
return &rtwdev->bbs[RTW89_PHY_0];
return &rtwdev->bbs[phy_idx];
}
static inline bool rtw89_is_rtl885xb(struct rtw89_dev *rtwdev)
{
enum rtw89_core_chip_id chip_id = rtwdev->chip->chip_id;
if (chip_id == RTL8852B || chip_id == RTL8851B || chip_id == RTL8852BT)
return true;
return false;
}
int rtw89_core_tx_write(struct rtw89_dev *rtwdev, struct ieee80211_vif *vif,
struct ieee80211_sta *sta, struct sk_buff *skb, int *qsel);
int rtw89_h2c_tx(struct rtw89_dev *rtwdev,
struct sk_buff *skb, bool fwdl);
void rtw89_core_tx_kick_off(struct rtw89_dev *rtwdev, u8 qsel);
int rtw89_core_tx_kick_off_and_wait(struct rtw89_dev *rtwdev, struct sk_buff *skb,
int qsel, unsigned int timeout);
void rtw89_core_fill_txdesc(struct rtw89_dev *rtwdev,
struct rtw89_tx_desc_info *desc_info,
void *txdesc);
void rtw89_core_fill_txdesc_v1(struct rtw89_dev *rtwdev,
struct rtw89_tx_desc_info *desc_info,
void *txdesc);
void rtw89_core_fill_txdesc_v2(struct rtw89_dev *rtwdev,
struct rtw89_tx_desc_info *desc_info,
void *txdesc);
void rtw89_core_fill_txdesc_fwcmd_v1(struct rtw89_dev *rtwdev,
struct rtw89_tx_desc_info *desc_info,
void *txdesc);
void rtw89_core_fill_txdesc_fwcmd_v2(struct rtw89_dev *rtwdev,
struct rtw89_tx_desc_info *desc_info,
void *txdesc);
void rtw89_core_rx(struct rtw89_dev *rtwdev,
struct rtw89_rx_desc_info *desc_info,
struct sk_buff *skb);
void rtw89_core_query_rxdesc(struct rtw89_dev *rtwdev,
struct rtw89_rx_desc_info *desc_info,
u8 *data, u32 data_offset);
void rtw89_core_query_rxdesc_v2(struct rtw89_dev *rtwdev,
struct rtw89_rx_desc_info *desc_info,
u8 *data, u32 data_offset);
void rtw89_core_napi_start(struct rtw89_dev *rtwdev);
void rtw89_core_napi_stop(struct rtw89_dev *rtwdev);
int rtw89_core_napi_init(struct rtw89_dev *rtwdev);
void rtw89_core_napi_deinit(struct rtw89_dev *rtwdev);
int rtw89_core_sta_link_add(struct rtw89_dev *rtwdev,
struct rtw89_vif_link *rtwvif_link,
struct rtw89_sta_link *rtwsta_link);
int rtw89_core_sta_link_assoc(struct rtw89_dev *rtwdev,
struct rtw89_vif_link *rtwvif_link,
struct rtw89_sta_link *rtwsta_link);
int rtw89_core_sta_link_disassoc(struct rtw89_dev *rtwdev,
struct rtw89_vif_link *rtwvif_link,
struct rtw89_sta_link *rtwsta_link);
int rtw89_core_sta_link_disconnect(struct rtw89_dev *rtwdev,
struct rtw89_vif_link *rtwvif_link,
struct rtw89_sta_link *rtwsta_link);
int rtw89_core_sta_link_remove(struct rtw89_dev *rtwdev,
struct rtw89_vif_link *rtwvif_link,
struct rtw89_sta_link *rtwsta_link);
void rtw89_core_set_tid_config(struct rtw89_dev *rtwdev,
struct ieee80211_sta *sta,
struct cfg80211_tid_config *tid_config);
void rtw89_core_rfkill_poll(struct rtw89_dev *rtwdev, bool force);
void rtw89_check_quirks(struct rtw89_dev *rtwdev, const struct dmi_system_id *quirks);
int rtw89_core_init(struct rtw89_dev *rtwdev);
void rtw89_core_deinit(struct rtw89_dev *rtwdev);
int rtw89_core_register(struct rtw89_dev *rtwdev);
void rtw89_core_unregister(struct rtw89_dev *rtwdev);
struct rtw89_dev *rtw89_alloc_ieee80211_hw(struct device *device,
u32 bus_data_size,
const struct rtw89_chip_info *chip,
const struct rtw89_chip_variant *variant);
void rtw89_free_ieee80211_hw(struct rtw89_dev *rtwdev);
u8 rtw89_acquire_mac_id(struct rtw89_dev *rtwdev);
void rtw89_release_mac_id(struct rtw89_dev *rtwdev, u8 mac_id);
void rtw89_init_vif(struct rtw89_dev *rtwdev, struct rtw89_vif *rtwvif,
u8 mac_id, u8 port);
void rtw89_init_sta(struct rtw89_dev *rtwdev, struct rtw89_vif *rtwvif,
struct rtw89_sta *rtwsta, u8 mac_id);
struct rtw89_vif_link *rtw89_vif_set_link(struct rtw89_vif *rtwvif,
unsigned int link_id);
void rtw89_vif_unset_link(struct rtw89_vif *rtwvif, unsigned int link_id);
struct rtw89_sta_link *rtw89_sta_set_link(struct rtw89_sta *rtwsta,
unsigned int link_id);
void rtw89_sta_unset_link(struct rtw89_sta *rtwsta, unsigned int link_id);
void rtw89_core_set_chip_txpwr(struct rtw89_dev *rtwdev);
const struct rtw89_6ghz_span *
rtw89_get_6ghz_span(struct rtw89_dev *rtwdev, u32 center_freq);
void rtw89_get_default_chandef(struct cfg80211_chan_def *chandef);
void rtw89_get_channel_params(const struct cfg80211_chan_def *chandef,
struct rtw89_chan *chan);
int rtw89_set_channel(struct rtw89_dev *rtwdev);
u8 rtw89_core_acquire_bit_map(unsigned long *addr, unsigned long size);
void rtw89_core_release_bit_map(unsigned long *addr, u8 bit);
void rtw89_core_release_all_bits_map(unsigned long *addr, unsigned int nbits);
int rtw89_core_acquire_sta_ba_entry(struct rtw89_dev *rtwdev,
struct rtw89_sta_link *rtwsta_link, u8 tid,
u8 *cam_idx);
int rtw89_core_release_sta_ba_entry(struct rtw89_dev *rtwdev,
struct rtw89_sta_link *rtwsta_link, u8 tid,
u8 *cam_idx);
void rtw89_core_free_sta_pending_ba(struct rtw89_dev *rtwdev,
struct ieee80211_sta *sta);
void rtw89_core_free_sta_pending_forbid_ba(struct rtw89_dev *rtwdev,
struct ieee80211_sta *sta);
void rtw89_core_free_sta_pending_roc_tx(struct rtw89_dev *rtwdev,
struct ieee80211_sta *sta);
void rtw89_vif_type_mapping(struct rtw89_vif_link *rtwvif_link, bool assoc);
int rtw89_chip_info_setup(struct rtw89_dev *rtwdev);
void rtw89_chip_cfg_txpwr_ul_tb_offset(struct rtw89_dev *rtwdev,
struct rtw89_vif_link *rtwvif_link);
bool rtw89_ra_report_to_bitrate(struct rtw89_dev *rtwdev, u8 rpt_rate, u16 *bitrate);
int rtw89_regd_setup(struct rtw89_dev *rtwdev);
int rtw89_regd_init_hint(struct rtw89_dev *rtwdev);
const char *rtw89_regd_get_string(enum rtw89_regulation_type regd);
void rtw89_traffic_stats_init(struct rtw89_dev *rtwdev,
struct rtw89_traffic_stats *stats);
int rtw89_wait_for_cond(struct rtw89_wait_info *wait, unsigned int cond);
void rtw89_complete_cond(struct rtw89_wait_info *wait, unsigned int cond,
const struct rtw89_completion_data *data);
int rtw89_core_start(struct rtw89_dev *rtwdev);
void rtw89_core_stop(struct rtw89_dev *rtwdev);
void rtw89_core_update_beacon_work(struct wiphy *wiphy, struct wiphy_work *work);
void rtw89_roc_work(struct wiphy *wiphy, struct wiphy_work *work);
void rtw89_roc_start(struct rtw89_dev *rtwdev, struct rtw89_vif *rtwvif);
void rtw89_roc_end(struct rtw89_dev *rtwdev, struct rtw89_vif *rtwvif);
void rtw89_core_scan_start(struct rtw89_dev *rtwdev, struct rtw89_vif_link *rtwvif_link,
const u8 *mac_addr, bool hw_scan);
void rtw89_core_scan_complete(struct rtw89_dev *rtwdev,
struct rtw89_vif_link *rtwvif_link, bool hw_scan);
int rtw89_reg_6ghz_recalc(struct rtw89_dev *rtwdev, struct rtw89_vif_link *rtwvif_link,
bool active);
void rtw89_core_update_p2p_ps(struct rtw89_dev *rtwdev,
struct rtw89_vif_link *rtwvif_link,
struct ieee80211_bss_conf *bss_conf);
void rtw89_core_ntfy_btc_event(struct rtw89_dev *rtwdev, enum rtw89_btc_hmsg event);
int rtw89_core_mlsr_switch(struct rtw89_dev *rtwdev, struct rtw89_vif *rtwvif,
unsigned int link_id);
#endif
|