Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'wireless-drivers-next-for-davem-2016-05-02' of git://git.kernel.org/pub/scm/linux/kernel/git/kvalo/wireless-drivers-next

Kalle Valo says:

====================
wireless-drivers patches for 4.7

Major changes:

brcmfmac

* add support for nl80211 BSS_SELECT feature

mwifiex

* add platform specific wakeup interrupt support

ath10k

* implement set_tsf() for 10.2.4 branch
* remove rare MSI range support
* remove deprecated firmware API 1 support

ath9k

* add module parameter to invert LED polarity

wcn36xx

* fixes to get the driver properly working on Dragonboard 410c
====================

Signed-off-by: David S. Miller <davem@davemloft.net>

+3701 -1798
+63
Documentation/devicetree/bindings/net/wireless/marvell-sd8xxx.txt
··· 1 + Marvell 8897/8997 (sd8897/sd8997) SDIO devices 2 + ------ 3 + 4 + This node provides properties for controlling the marvell sdio wireless device. 5 + The node is expected to be specified as a child node to the SDIO controller that 6 + connects the device to the system. 7 + 8 + Required properties: 9 + 10 + - compatible : should be one of the following: 11 + * "marvell,sd8897" 12 + * "marvell,sd8997" 13 + 14 + Optional properties: 15 + 16 + - marvell,caldata* : A series of properties with marvell,caldata prefix, 17 + represent calibration data downloaded to the device during 18 + initialization. This is an array of unsigned 8-bit values. 19 + the properties should follow below property name and 20 + corresponding array length: 21 + "marvell,caldata-txpwrlimit-2g" (length = 566). 22 + "marvell,caldata-txpwrlimit-5g-sub0" (length = 502). 23 + "marvell,caldata-txpwrlimit-5g-sub1" (length = 688). 24 + "marvell,caldata-txpwrlimit-5g-sub2" (length = 750). 25 + "marvell,caldata-txpwrlimit-5g-sub3" (length = 502). 26 + - marvell,wakeup-pin : a wakeup pin number of wifi chip which will be configured 27 + to firmware. Firmware will wakeup the host using this pin 28 + during suspend/resume. 29 + - interrupt-parent: phandle of the parent interrupt controller 30 + - interrupts : interrupt pin number to the cpu. driver will request an irq based on 31 + this interrupt number. during system suspend, the irq will be enabled 32 + so that the wifi chip can wakeup host platform under certain condition. 33 + during system resume, the irq will be disabled to make sure 34 + unnecessary interrupt is not received. 35 + 36 + Example: 37 + 38 + Tx power limit calibration data is configured in below example. 39 + The calibration data is an array of unsigned values, the length 40 + can vary between hw versions. 41 + IRQ pin 38 is used as system wakeup source interrupt. wakeup pin 3 is configured 42 + so that firmware can wakeup host using this device side pin. 43 + 44 + &mmc3 { 45 + status = "okay"; 46 + vmmc-supply = <&wlan_en_reg>; 47 + bus-width = <4>; 48 + cap-power-off-card; 49 + keep-power-in-suspend; 50 + 51 + #address-cells = <1>; 52 + #size-cells = <0>; 53 + mwifiex: wifi@1 { 54 + compatible = "marvell,sd8897"; 55 + reg = <1>; 56 + interrupt-parent = <&pio>; 57 + interrupts = <38 IRQ_TYPE_LEVEL_LOW>; 58 + 59 + marvell,caldata_00_txpwrlimit_2g_cfg_set = /bits/ 8 < 60 + 0x01 0x00 0x06 0x00 0x08 0x02 0x89 0x01>; 61 + marvell,wakeup-pin = <3>; 62 + }; 63 + };
+1 -1
MAINTAINERS
··· 9490 9490 RTL8XXXU WIRELESS DRIVER (rtl8xxxu) 9491 9491 M: Jes Sorensen <Jes.Sorensen@redhat.com> 9492 9492 L: linux-wireless@vger.kernel.org 9493 - T: git git://git.kernel.org/pub/scm/linux/kernel/git/jes/linux.git rtl8723au-mac80211 9493 + T: git git://git.kernel.org/pub/scm/linux/kernel/git/jes/linux.git rtl8xxxu-devel 9494 9494 S: Maintained 9495 9495 F: drivers/net/wireless/realtek/rtl8xxxu/ 9496 9496
+3 -3
drivers/net/wireless/ath/ath10k/ce.c
··· 1050 1050 * 1051 1051 * For the lack of a better place do the check here. 1052 1052 */ 1053 - BUILD_BUG_ON(2*TARGET_NUM_MSDU_DESC > 1053 + BUILD_BUG_ON(2 * TARGET_NUM_MSDU_DESC > 1054 1054 (CE_HTT_H2T_MSG_SRC_NENTRIES - 1)); 1055 - BUILD_BUG_ON(2*TARGET_10X_NUM_MSDU_DESC > 1055 + BUILD_BUG_ON(2 * TARGET_10X_NUM_MSDU_DESC > 1056 1056 (CE_HTT_H2T_MSG_SRC_NENTRIES - 1)); 1057 - BUILD_BUG_ON(2*TARGET_TLV_NUM_MSDU_DESC > 1057 + BUILD_BUG_ON(2 * TARGET_TLV_NUM_MSDU_DESC > 1058 1058 (CE_HTT_H2T_MSG_SRC_NENTRIES - 1)); 1059 1059 1060 1060 ce_state->ar = ar;
+1 -1
drivers/net/wireless/ath/ath10k/ce.h
··· 408 408 409 409 /* Ring arithmetic (modulus number of entries in ring, which is a pwr of 2). */ 410 410 #define CE_RING_DELTA(nentries_mask, fromidx, toidx) \ 411 - (((int)(toidx)-(int)(fromidx)) & (nentries_mask)) 411 + (((int)(toidx) - (int)(fromidx)) & (nentries_mask)) 412 412 413 413 #define CE_RING_IDX_INCR(nentries_mask, idx) (((idx) + 1) & (nentries_mask)) 414 414 #define CE_RING_IDX_ADD(nentries_mask, idx, num) \
+133 -191
drivers/net/wireless/ath/ath10k/core.c
··· 63 63 .cal_data_len = 2116, 64 64 .fw = { 65 65 .dir = QCA988X_HW_2_0_FW_DIR, 66 - .fw = QCA988X_HW_2_0_FW_FILE, 67 - .otp = QCA988X_HW_2_0_OTP_FILE, 68 66 .board = QCA988X_HW_2_0_BOARD_DATA_FILE, 69 67 .board_size = QCA988X_BOARD_DATA_SZ, 70 68 .board_ext_size = QCA988X_BOARD_EXT_DATA_SZ, ··· 80 82 .cal_data_len = 8124, 81 83 .fw = { 82 84 .dir = QCA6174_HW_2_1_FW_DIR, 83 - .fw = QCA6174_HW_2_1_FW_FILE, 84 - .otp = QCA6174_HW_2_1_OTP_FILE, 85 85 .board = QCA6174_HW_2_1_BOARD_DATA_FILE, 86 86 .board_size = QCA6174_BOARD_DATA_SZ, 87 87 .board_ext_size = QCA6174_BOARD_EXT_DATA_SZ, ··· 98 102 .cal_data_len = 8124, 99 103 .fw = { 100 104 .dir = QCA6174_HW_2_1_FW_DIR, 101 - .fw = QCA6174_HW_2_1_FW_FILE, 102 - .otp = QCA6174_HW_2_1_OTP_FILE, 103 105 .board = QCA6174_HW_2_1_BOARD_DATA_FILE, 104 106 .board_size = QCA6174_BOARD_DATA_SZ, 105 107 .board_ext_size = QCA6174_BOARD_EXT_DATA_SZ, ··· 116 122 .cal_data_len = 8124, 117 123 .fw = { 118 124 .dir = QCA6174_HW_3_0_FW_DIR, 119 - .fw = QCA6174_HW_3_0_FW_FILE, 120 - .otp = QCA6174_HW_3_0_OTP_FILE, 121 125 .board = QCA6174_HW_3_0_BOARD_DATA_FILE, 122 126 .board_size = QCA6174_BOARD_DATA_SZ, 123 127 .board_ext_size = QCA6174_BOARD_EXT_DATA_SZ, ··· 135 143 .fw = { 136 144 /* uses same binaries as hw3.0 */ 137 145 .dir = QCA6174_HW_3_0_FW_DIR, 138 - .fw = QCA6174_HW_3_0_FW_FILE, 139 - .otp = QCA6174_HW_3_0_OTP_FILE, 140 146 .board = QCA6174_HW_3_0_BOARD_DATA_FILE, 141 147 .board_size = QCA6174_BOARD_DATA_SZ, 142 148 .board_ext_size = QCA6174_BOARD_EXT_DATA_SZ, ··· 157 167 .cal_data_len = 12064, 158 168 .fw = { 159 169 .dir = QCA99X0_HW_2_0_FW_DIR, 160 - .fw = QCA99X0_HW_2_0_FW_FILE, 161 - .otp = QCA99X0_HW_2_0_OTP_FILE, 162 170 .board = QCA99X0_HW_2_0_BOARD_DATA_FILE, 163 171 .board_size = QCA99X0_BOARD_DATA_SZ, 164 172 .board_ext_size = QCA99X0_BOARD_EXT_DATA_SZ, ··· 174 186 .cal_data_len = 8124, 175 187 .fw = { 176 188 .dir = QCA9377_HW_1_0_FW_DIR, 177 - .fw = QCA9377_HW_1_0_FW_FILE, 178 - .otp = QCA9377_HW_1_0_OTP_FILE, 179 189 .board = QCA9377_HW_1_0_BOARD_DATA_FILE, 180 190 .board_size = QCA9377_BOARD_DATA_SZ, 181 191 .board_ext_size = QCA9377_BOARD_EXT_DATA_SZ, ··· 191 205 .cal_data_len = 8124, 192 206 .fw = { 193 207 .dir = QCA9377_HW_1_0_FW_DIR, 194 - .fw = QCA9377_HW_1_0_FW_FILE, 195 - .otp = QCA9377_HW_1_0_OTP_FILE, 196 208 .board = QCA9377_HW_1_0_BOARD_DATA_FILE, 197 209 .board_size = QCA9377_BOARD_DATA_SZ, 198 210 .board_ext_size = QCA9377_BOARD_EXT_DATA_SZ, ··· 213 229 .cal_data_len = 12064, 214 230 .fw = { 215 231 .dir = QCA4019_HW_1_0_FW_DIR, 216 - .fw = QCA4019_HW_1_0_FW_FILE, 217 - .otp = QCA4019_HW_1_0_OTP_FILE, 218 232 .board = QCA4019_HW_1_0_BOARD_DATA_FILE, 219 233 .board_size = QCA4019_BOARD_DATA_SZ, 220 234 .board_ext_size = QCA4019_BOARD_EXT_DATA_SZ, ··· 261 279 int i; 262 280 263 281 for (i = 0; i < ATH10K_FW_FEATURE_COUNT; i++) { 264 - if (test_bit(i, ar->fw_features)) { 282 + if (test_bit(i, ar->normal_mode_fw.fw_file.fw_features)) { 265 283 if (len > 0) 266 284 len += scnprintf(buf + len, buf_len - len, ","); 267 285 ··· 538 556 539 557 address = ar->hw_params.patch_load_addr; 540 558 541 - if (!ar->otp_data || !ar->otp_len) { 559 + if (!ar->normal_mode_fw.fw_file.otp_data || 560 + !ar->normal_mode_fw.fw_file.otp_len) { 542 561 ath10k_warn(ar, 543 562 "failed to retrieve board id because of invalid otp\n"); 544 563 return -ENODATA; ··· 547 564 548 565 ath10k_dbg(ar, ATH10K_DBG_BOOT, 549 566 "boot upload otp to 0x%x len %zd for board id\n", 550 - address, ar->otp_len); 567 + address, ar->normal_mode_fw.fw_file.otp_len); 551 568 552 - ret = ath10k_bmi_fast_download(ar, address, ar->otp_data, ar->otp_len); 569 + ret = ath10k_bmi_fast_download(ar, address, 570 + ar->normal_mode_fw.fw_file.otp_data, 571 + ar->normal_mode_fw.fw_file.otp_len); 553 572 if (ret) { 554 573 ath10k_err(ar, "could not write otp for board id check: %d\n", 555 574 ret); ··· 589 604 u32 bmi_otp_exe_param = ar->hw_params.otp_exe_param; 590 605 int ret; 591 606 592 - ret = ath10k_download_board_data(ar, ar->board_data, ar->board_len); 607 + ret = ath10k_download_board_data(ar, 608 + ar->running_fw->board_data, 609 + ar->running_fw->board_len); 593 610 if (ret) { 594 611 ath10k_err(ar, "failed to download board data: %d\n", ret); 595 612 return ret; ··· 599 612 600 613 /* OTP is optional */ 601 614 602 - if (!ar->otp_data || !ar->otp_len) { 615 + if (!ar->running_fw->fw_file.otp_data || 616 + !ar->running_fw->fw_file.otp_len) { 603 617 ath10k_warn(ar, "Not running otp, calibration will be incorrect (otp-data %p otp_len %zd)!\n", 604 - ar->otp_data, ar->otp_len); 618 + ar->running_fw->fw_file.otp_data, 619 + ar->running_fw->fw_file.otp_len); 605 620 return 0; 606 621 } 607 622 608 623 ath10k_dbg(ar, ATH10K_DBG_BOOT, "boot upload otp to 0x%x len %zd\n", 609 - address, ar->otp_len); 624 + address, ar->running_fw->fw_file.otp_len); 610 625 611 - ret = ath10k_bmi_fast_download(ar, address, ar->otp_data, ar->otp_len); 626 + ret = ath10k_bmi_fast_download(ar, address, 627 + ar->running_fw->fw_file.otp_data, 628 + ar->running_fw->fw_file.otp_len); 612 629 if (ret) { 613 630 ath10k_err(ar, "could not write otp (%d)\n", ret); 614 631 return ret; ··· 627 636 ath10k_dbg(ar, ATH10K_DBG_BOOT, "boot otp execute result %d\n", result); 628 637 629 638 if (!(skip_otp || test_bit(ATH10K_FW_FEATURE_IGNORE_OTP_RESULT, 630 - ar->fw_features)) && 639 + ar->running_fw->fw_file.fw_features)) && 631 640 result != 0) { 632 641 ath10k_err(ar, "otp calibration failed: %d", result); 633 642 return -EINVAL; ··· 636 645 return 0; 637 646 } 638 647 639 - static int ath10k_download_fw(struct ath10k *ar, enum ath10k_firmware_mode mode) 648 + static int ath10k_download_fw(struct ath10k *ar) 640 649 { 641 650 u32 address, data_len; 642 - const char *mode_name; 643 651 const void *data; 644 652 int ret; 645 653 646 654 address = ar->hw_params.patch_load_addr; 647 655 648 - switch (mode) { 649 - case ATH10K_FIRMWARE_MODE_NORMAL: 650 - data = ar->firmware_data; 651 - data_len = ar->firmware_len; 652 - mode_name = "normal"; 653 - ret = ath10k_swap_code_seg_configure(ar, 654 - ATH10K_SWAP_CODE_SEG_BIN_TYPE_FW); 655 - if (ret) { 656 - ath10k_err(ar, "failed to configure fw code swap: %d\n", 657 - ret); 658 - return ret; 659 - } 660 - break; 661 - case ATH10K_FIRMWARE_MODE_UTF: 662 - data = ar->testmode.utf_firmware_data; 663 - data_len = ar->testmode.utf_firmware_len; 664 - mode_name = "utf"; 665 - break; 666 - default: 667 - ath10k_err(ar, "unknown firmware mode: %d\n", mode); 668 - return -EINVAL; 656 + data = ar->running_fw->fw_file.firmware_data; 657 + data_len = ar->running_fw->fw_file.firmware_len; 658 + 659 + ret = ath10k_swap_code_seg_configure(ar); 660 + if (ret) { 661 + ath10k_err(ar, "failed to configure fw code swap: %d\n", 662 + ret); 663 + return ret; 669 664 } 670 665 671 666 ath10k_dbg(ar, ATH10K_DBG_BOOT, 672 - "boot uploading firmware image %p len %d mode %s\n", 673 - data, data_len, mode_name); 667 + "boot uploading firmware image %p len %d\n", 668 + data, data_len); 674 669 675 670 ret = ath10k_bmi_fast_download(ar, address, data, data_len); 676 671 if (ret) { 677 - ath10k_err(ar, "failed to download %s firmware: %d\n", 678 - mode_name, ret); 672 + ath10k_err(ar, "failed to download firmware: %d\n", 673 + ret); 679 674 return ret; 680 675 } 681 676 ··· 670 693 671 694 static void ath10k_core_free_board_files(struct ath10k *ar) 672 695 { 673 - if (!IS_ERR(ar->board)) 674 - release_firmware(ar->board); 696 + if (!IS_ERR(ar->normal_mode_fw.board)) 697 + release_firmware(ar->normal_mode_fw.board); 675 698 676 - ar->board = NULL; 677 - ar->board_data = NULL; 678 - ar->board_len = 0; 699 + ar->normal_mode_fw.board = NULL; 700 + ar->normal_mode_fw.board_data = NULL; 701 + ar->normal_mode_fw.board_len = 0; 679 702 } 680 703 681 704 static void ath10k_core_free_firmware_files(struct ath10k *ar) 682 705 { 683 - if (!IS_ERR(ar->otp)) 684 - release_firmware(ar->otp); 685 - 686 - if (!IS_ERR(ar->firmware)) 687 - release_firmware(ar->firmware); 706 + if (!IS_ERR(ar->normal_mode_fw.fw_file.firmware)) 707 + release_firmware(ar->normal_mode_fw.fw_file.firmware); 688 708 689 709 if (!IS_ERR(ar->cal_file)) 690 710 release_firmware(ar->cal_file); 691 711 692 712 ath10k_swap_code_seg_release(ar); 693 713 694 - ar->otp = NULL; 695 - ar->otp_data = NULL; 696 - ar->otp_len = 0; 714 + ar->normal_mode_fw.fw_file.otp_data = NULL; 715 + ar->normal_mode_fw.fw_file.otp_len = 0; 697 716 698 - ar->firmware = NULL; 699 - ar->firmware_data = NULL; 700 - ar->firmware_len = 0; 717 + ar->normal_mode_fw.fw_file.firmware = NULL; 718 + ar->normal_mode_fw.fw_file.firmware_data = NULL; 719 + ar->normal_mode_fw.fw_file.firmware_len = 0; 701 720 702 721 ar->cal_file = NULL; 703 722 } ··· 732 759 return -EINVAL; 733 760 } 734 761 735 - ar->board = ath10k_fetch_fw_file(ar, 736 - ar->hw_params.fw.dir, 737 - ar->hw_params.fw.board); 738 - if (IS_ERR(ar->board)) 739 - return PTR_ERR(ar->board); 762 + ar->normal_mode_fw.board = ath10k_fetch_fw_file(ar, 763 + ar->hw_params.fw.dir, 764 + ar->hw_params.fw.board); 765 + if (IS_ERR(ar->normal_mode_fw.board)) 766 + return PTR_ERR(ar->normal_mode_fw.board); 740 767 741 - ar->board_data = ar->board->data; 742 - ar->board_len = ar->board->size; 768 + ar->normal_mode_fw.board_data = ar->normal_mode_fw.board->data; 769 + ar->normal_mode_fw.board_len = ar->normal_mode_fw.board->size; 743 770 744 771 return 0; 745 772 } ··· 799 826 "boot found board data for '%s'", 800 827 boardname); 801 828 802 - ar->board_data = board_ie_data; 803 - ar->board_len = board_ie_len; 829 + ar->normal_mode_fw.board_data = board_ie_data; 830 + ar->normal_mode_fw.board_len = board_ie_len; 804 831 805 832 ret = 0; 806 833 goto out; ··· 833 860 const u8 *data; 834 861 int ret, ie_id; 835 862 836 - ar->board = ath10k_fetch_fw_file(ar, ar->hw_params.fw.dir, filename); 837 - if (IS_ERR(ar->board)) 838 - return PTR_ERR(ar->board); 863 + ar->normal_mode_fw.board = ath10k_fetch_fw_file(ar, 864 + ar->hw_params.fw.dir, 865 + filename); 866 + if (IS_ERR(ar->normal_mode_fw.board)) 867 + return PTR_ERR(ar->normal_mode_fw.board); 839 868 840 - data = ar->board->data; 841 - len = ar->board->size; 869 + data = ar->normal_mode_fw.board->data; 870 + len = ar->normal_mode_fw.board->size; 842 871 843 872 /* magic has extra null byte padded */ 844 873 magic_len = strlen(ATH10K_BOARD_MAGIC) + 1; ··· 907 932 } 908 933 909 934 out: 910 - if (!ar->board_data || !ar->board_len) { 935 + if (!ar->normal_mode_fw.board_data || !ar->normal_mode_fw.board_len) { 911 936 ath10k_err(ar, 912 937 "failed to fetch board data for %s from %s/%s\n", 913 938 boardname, ar->hw_params.fw.dir, filename); ··· 975 1000 return 0; 976 1001 } 977 1002 978 - static int ath10k_core_fetch_firmware_api_1(struct ath10k *ar) 979 - { 980 - int ret = 0; 981 - 982 - if (ar->hw_params.fw.fw == NULL) { 983 - ath10k_err(ar, "firmware file not defined\n"); 984 - return -EINVAL; 985 - } 986 - 987 - ar->firmware = ath10k_fetch_fw_file(ar, 988 - ar->hw_params.fw.dir, 989 - ar->hw_params.fw.fw); 990 - if (IS_ERR(ar->firmware)) { 991 - ret = PTR_ERR(ar->firmware); 992 - ath10k_err(ar, "could not fetch firmware (%d)\n", ret); 993 - goto err; 994 - } 995 - 996 - ar->firmware_data = ar->firmware->data; 997 - ar->firmware_len = ar->firmware->size; 998 - 999 - /* OTP may be undefined. If so, don't fetch it at all */ 1000 - if (ar->hw_params.fw.otp == NULL) 1001 - return 0; 1002 - 1003 - ar->otp = ath10k_fetch_fw_file(ar, 1004 - ar->hw_params.fw.dir, 1005 - ar->hw_params.fw.otp); 1006 - if (IS_ERR(ar->otp)) { 1007 - ret = PTR_ERR(ar->otp); 1008 - ath10k_err(ar, "could not fetch otp (%d)\n", ret); 1009 - goto err; 1010 - } 1011 - 1012 - ar->otp_data = ar->otp->data; 1013 - ar->otp_len = ar->otp->size; 1014 - 1015 - return 0; 1016 - 1017 - err: 1018 - ath10k_core_free_firmware_files(ar); 1019 - return ret; 1020 - } 1021 - 1022 - static int ath10k_core_fetch_firmware_api_n(struct ath10k *ar, const char *name) 1003 + int ath10k_core_fetch_firmware_api_n(struct ath10k *ar, const char *name, 1004 + struct ath10k_fw_file *fw_file) 1023 1005 { 1024 1006 size_t magic_len, len, ie_len; 1025 1007 int ie_id, i, index, bit, ret; ··· 985 1053 __le32 *timestamp, *version; 986 1054 987 1055 /* first fetch the firmware file (firmware-*.bin) */ 988 - ar->firmware = ath10k_fetch_fw_file(ar, ar->hw_params.fw.dir, name); 989 - if (IS_ERR(ar->firmware)) { 1056 + fw_file->firmware = ath10k_fetch_fw_file(ar, ar->hw_params.fw.dir, 1057 + name); 1058 + if (IS_ERR(fw_file->firmware)) { 990 1059 ath10k_err(ar, "could not fetch firmware file '%s/%s': %ld\n", 991 - ar->hw_params.fw.dir, name, PTR_ERR(ar->firmware)); 992 - return PTR_ERR(ar->firmware); 1060 + ar->hw_params.fw.dir, name, 1061 + PTR_ERR(fw_file->firmware)); 1062 + return PTR_ERR(fw_file->firmware); 993 1063 } 994 1064 995 - data = ar->firmware->data; 996 - len = ar->firmware->size; 1065 + data = fw_file->firmware->data; 1066 + len = fw_file->firmware->size; 997 1067 998 1068 /* magic also includes the null byte, check that as well */ 999 1069 magic_len = strlen(ATH10K_FIRMWARE_MAGIC) + 1; ··· 1038 1104 1039 1105 switch (ie_id) { 1040 1106 case ATH10K_FW_IE_FW_VERSION: 1041 - if (ie_len > sizeof(ar->hw->wiphy->fw_version) - 1) 1107 + if (ie_len > sizeof(fw_file->fw_version) - 1) 1042 1108 break; 1043 1109 1044 - memcpy(ar->hw->wiphy->fw_version, data, ie_len); 1045 - ar->hw->wiphy->fw_version[ie_len] = '\0'; 1110 + memcpy(fw_file->fw_version, data, ie_len); 1111 + fw_file->fw_version[ie_len] = '\0'; 1046 1112 1047 1113 ath10k_dbg(ar, ATH10K_DBG_BOOT, 1048 1114 "found fw version %s\n", 1049 - ar->hw->wiphy->fw_version); 1115 + fw_file->fw_version); 1050 1116 break; 1051 1117 case ATH10K_FW_IE_TIMESTAMP: 1052 1118 if (ie_len != sizeof(u32)) ··· 1073 1139 ath10k_dbg(ar, ATH10K_DBG_BOOT, 1074 1140 "Enabling feature bit: %i\n", 1075 1141 i); 1076 - __set_bit(i, ar->fw_features); 1142 + __set_bit(i, fw_file->fw_features); 1077 1143 } 1078 1144 } 1079 1145 1080 1146 ath10k_dbg_dump(ar, ATH10K_DBG_BOOT, "features", "", 1081 - ar->fw_features, 1082 - sizeof(ar->fw_features)); 1147 + ar->running_fw->fw_file.fw_features, 1148 + sizeof(fw_file->fw_features)); 1083 1149 break; 1084 1150 case ATH10K_FW_IE_FW_IMAGE: 1085 1151 ath10k_dbg(ar, ATH10K_DBG_BOOT, 1086 1152 "found fw image ie (%zd B)\n", 1087 1153 ie_len); 1088 1154 1089 - ar->firmware_data = data; 1090 - ar->firmware_len = ie_len; 1155 + fw_file->firmware_data = data; 1156 + fw_file->firmware_len = ie_len; 1091 1157 1092 1158 break; 1093 1159 case ATH10K_FW_IE_OTP_IMAGE: ··· 1095 1161 "found otp image ie (%zd B)\n", 1096 1162 ie_len); 1097 1163 1098 - ar->otp_data = data; 1099 - ar->otp_len = ie_len; 1164 + fw_file->otp_data = data; 1165 + fw_file->otp_len = ie_len; 1100 1166 1101 1167 break; 1102 1168 case ATH10K_FW_IE_WMI_OP_VERSION: ··· 1105 1171 1106 1172 version = (__le32 *)data; 1107 1173 1108 - ar->wmi.op_version = le32_to_cpup(version); 1174 + fw_file->wmi_op_version = le32_to_cpup(version); 1109 1175 1110 1176 ath10k_dbg(ar, ATH10K_DBG_BOOT, "found fw ie wmi op version %d\n", 1111 - ar->wmi.op_version); 1177 + fw_file->wmi_op_version); 1112 1178 break; 1113 1179 case ATH10K_FW_IE_HTT_OP_VERSION: 1114 1180 if (ie_len != sizeof(u32)) ··· 1116 1182 1117 1183 version = (__le32 *)data; 1118 1184 1119 - ar->htt.op_version = le32_to_cpup(version); 1185 + fw_file->htt_op_version = le32_to_cpup(version); 1120 1186 1121 1187 ath10k_dbg(ar, ATH10K_DBG_BOOT, "found fw ie htt op version %d\n", 1122 - ar->htt.op_version); 1188 + fw_file->htt_op_version); 1123 1189 break; 1124 1190 case ATH10K_FW_IE_FW_CODE_SWAP_IMAGE: 1125 1191 ath10k_dbg(ar, ATH10K_DBG_BOOT, 1126 1192 "found fw code swap image ie (%zd B)\n", 1127 1193 ie_len); 1128 - ar->swap.firmware_codeswap_data = data; 1129 - ar->swap.firmware_codeswap_len = ie_len; 1194 + fw_file->codeswap_data = data; 1195 + fw_file->codeswap_len = ie_len; 1130 1196 break; 1131 1197 default: 1132 1198 ath10k_warn(ar, "Unknown FW IE: %u\n", ··· 1141 1207 data += ie_len; 1142 1208 } 1143 1209 1144 - if (!ar->firmware_data || !ar->firmware_len) { 1210 + if (!fw_file->firmware_data || 1211 + !fw_file->firmware_len) { 1145 1212 ath10k_warn(ar, "No ATH10K_FW_IE_FW_IMAGE found from '%s/%s', skipping\n", 1146 1213 ar->hw_params.fw.dir, name); 1147 1214 ret = -ENOMEDIUM; ··· 1166 1231 ar->fw_api = 5; 1167 1232 ath10k_dbg(ar, ATH10K_DBG_BOOT, "trying fw api %d\n", ar->fw_api); 1168 1233 1169 - ret = ath10k_core_fetch_firmware_api_n(ar, ATH10K_FW_API5_FILE); 1234 + ret = ath10k_core_fetch_firmware_api_n(ar, ATH10K_FW_API5_FILE, 1235 + &ar->normal_mode_fw.fw_file); 1170 1236 if (ret == 0) 1171 1237 goto success; 1172 1238 1173 1239 ar->fw_api = 4; 1174 1240 ath10k_dbg(ar, ATH10K_DBG_BOOT, "trying fw api %d\n", ar->fw_api); 1175 1241 1176 - ret = ath10k_core_fetch_firmware_api_n(ar, ATH10K_FW_API4_FILE); 1242 + ret = ath10k_core_fetch_firmware_api_n(ar, ATH10K_FW_API4_FILE, 1243 + &ar->normal_mode_fw.fw_file); 1177 1244 if (ret == 0) 1178 1245 goto success; 1179 1246 1180 1247 ar->fw_api = 3; 1181 1248 ath10k_dbg(ar, ATH10K_DBG_BOOT, "trying fw api %d\n", ar->fw_api); 1182 1249 1183 - ret = ath10k_core_fetch_firmware_api_n(ar, ATH10K_FW_API3_FILE); 1250 + ret = ath10k_core_fetch_firmware_api_n(ar, ATH10K_FW_API3_FILE, 1251 + &ar->normal_mode_fw.fw_file); 1184 1252 if (ret == 0) 1185 1253 goto success; 1186 1254 1187 1255 ar->fw_api = 2; 1188 1256 ath10k_dbg(ar, ATH10K_DBG_BOOT, "trying fw api %d\n", ar->fw_api); 1189 1257 1190 - ret = ath10k_core_fetch_firmware_api_n(ar, ATH10K_FW_API2_FILE); 1191 - if (ret == 0) 1192 - goto success; 1193 - 1194 - ar->fw_api = 1; 1195 - ath10k_dbg(ar, ATH10K_DBG_BOOT, "trying fw api %d\n", ar->fw_api); 1196 - 1197 - ret = ath10k_core_fetch_firmware_api_1(ar); 1258 + ret = ath10k_core_fetch_firmware_api_n(ar, ATH10K_FW_API2_FILE, 1259 + &ar->normal_mode_fw.fw_file); 1198 1260 if (ret) 1199 1261 return ret; 1200 1262 ··· 1429 1497 1430 1498 static int ath10k_core_init_firmware_features(struct ath10k *ar) 1431 1499 { 1432 - if (test_bit(ATH10K_FW_FEATURE_WMI_10_2, ar->fw_features) && 1433 - !test_bit(ATH10K_FW_FEATURE_WMI_10X, ar->fw_features)) { 1500 + struct ath10k_fw_file *fw_file = &ar->normal_mode_fw.fw_file; 1501 + 1502 + if (test_bit(ATH10K_FW_FEATURE_WMI_10_2, fw_file->fw_features) && 1503 + !test_bit(ATH10K_FW_FEATURE_WMI_10X, fw_file->fw_features)) { 1434 1504 ath10k_err(ar, "feature bits corrupted: 10.2 feature requires 10.x feature to be set as well"); 1435 1505 return -EINVAL; 1436 1506 } 1437 1507 1438 - if (ar->wmi.op_version >= ATH10K_FW_WMI_OP_VERSION_MAX) { 1508 + if (fw_file->wmi_op_version >= ATH10K_FW_WMI_OP_VERSION_MAX) { 1439 1509 ath10k_err(ar, "unsupported WMI OP version (max %d): %d\n", 1440 - ATH10K_FW_WMI_OP_VERSION_MAX, ar->wmi.op_version); 1510 + ATH10K_FW_WMI_OP_VERSION_MAX, fw_file->wmi_op_version); 1441 1511 return -EINVAL; 1442 1512 } 1443 1513 ··· 1451 1517 break; 1452 1518 case ATH10K_CRYPT_MODE_SW: 1453 1519 if (!test_bit(ATH10K_FW_FEATURE_RAW_MODE_SUPPORT, 1454 - ar->fw_features)) { 1520 + fw_file->fw_features)) { 1455 1521 ath10k_err(ar, "cryptmode > 0 requires raw mode support from firmware"); 1456 1522 return -EINVAL; 1457 1523 } ··· 1470 1536 1471 1537 if (rawmode) { 1472 1538 if (!test_bit(ATH10K_FW_FEATURE_RAW_MODE_SUPPORT, 1473 - ar->fw_features)) { 1539 + fw_file->fw_features)) { 1474 1540 ath10k_err(ar, "rawmode = 1 requires support from firmware"); 1475 1541 return -EINVAL; 1476 1542 } ··· 1495 1561 /* Backwards compatibility for firmwares without 1496 1562 * ATH10K_FW_IE_WMI_OP_VERSION. 1497 1563 */ 1498 - if (ar->wmi.op_version == ATH10K_FW_WMI_OP_VERSION_UNSET) { 1499 - if (test_bit(ATH10K_FW_FEATURE_WMI_10X, ar->fw_features)) { 1564 + if (fw_file->wmi_op_version == ATH10K_FW_WMI_OP_VERSION_UNSET) { 1565 + if (test_bit(ATH10K_FW_FEATURE_WMI_10X, fw_file->fw_features)) { 1500 1566 if (test_bit(ATH10K_FW_FEATURE_WMI_10_2, 1501 - ar->fw_features)) 1502 - ar->wmi.op_version = ATH10K_FW_WMI_OP_VERSION_10_2; 1567 + fw_file->fw_features)) 1568 + fw_file->wmi_op_version = ATH10K_FW_WMI_OP_VERSION_10_2; 1503 1569 else 1504 - ar->wmi.op_version = ATH10K_FW_WMI_OP_VERSION_10_1; 1570 + fw_file->wmi_op_version = ATH10K_FW_WMI_OP_VERSION_10_1; 1505 1571 } else { 1506 - ar->wmi.op_version = ATH10K_FW_WMI_OP_VERSION_MAIN; 1572 + fw_file->wmi_op_version = ATH10K_FW_WMI_OP_VERSION_MAIN; 1507 1573 } 1508 1574 } 1509 1575 1510 - switch (ar->wmi.op_version) { 1576 + switch (fw_file->wmi_op_version) { 1511 1577 case ATH10K_FW_WMI_OP_VERSION_MAIN: 1512 1578 ar->max_num_peers = TARGET_NUM_PEERS; 1513 1579 ar->max_num_stations = TARGET_NUM_STATIONS; ··· 1554 1620 ar->max_spatial_stream = ar->hw_params.max_spatial_stream; 1555 1621 1556 1622 if (test_bit(ATH10K_FW_FEATURE_PEER_FLOW_CONTROL, 1557 - ar->fw_features)) 1623 + fw_file->fw_features)) 1558 1624 ar->htt.max_num_pending_tx = TARGET_10_4_NUM_MSDU_DESC_PFC; 1559 1625 else 1560 1626 ar->htt.max_num_pending_tx = TARGET_10_4_NUM_MSDU_DESC; ··· 1568 1634 /* Backwards compatibility for firmwares without 1569 1635 * ATH10K_FW_IE_HTT_OP_VERSION. 1570 1636 */ 1571 - if (ar->htt.op_version == ATH10K_FW_HTT_OP_VERSION_UNSET) { 1572 - switch (ar->wmi.op_version) { 1637 + if (fw_file->htt_op_version == ATH10K_FW_HTT_OP_VERSION_UNSET) { 1638 + switch (fw_file->wmi_op_version) { 1573 1639 case ATH10K_FW_WMI_OP_VERSION_MAIN: 1574 - ar->htt.op_version = ATH10K_FW_HTT_OP_VERSION_MAIN; 1640 + fw_file->htt_op_version = ATH10K_FW_HTT_OP_VERSION_MAIN; 1575 1641 break; 1576 1642 case ATH10K_FW_WMI_OP_VERSION_10_1: 1577 1643 case ATH10K_FW_WMI_OP_VERSION_10_2: 1578 1644 case ATH10K_FW_WMI_OP_VERSION_10_2_4: 1579 - ar->htt.op_version = ATH10K_FW_HTT_OP_VERSION_10_1; 1645 + fw_file->htt_op_version = ATH10K_FW_HTT_OP_VERSION_10_1; 1580 1646 break; 1581 1647 case ATH10K_FW_WMI_OP_VERSION_TLV: 1582 - ar->htt.op_version = ATH10K_FW_HTT_OP_VERSION_TLV; 1648 + fw_file->htt_op_version = ATH10K_FW_HTT_OP_VERSION_TLV; 1583 1649 break; 1584 1650 case ATH10K_FW_WMI_OP_VERSION_10_4: 1585 1651 case ATH10K_FW_WMI_OP_VERSION_UNSET: ··· 1592 1658 return 0; 1593 1659 } 1594 1660 1595 - int ath10k_core_start(struct ath10k *ar, enum ath10k_firmware_mode mode) 1661 + int ath10k_core_start(struct ath10k *ar, enum ath10k_firmware_mode mode, 1662 + const struct ath10k_fw_components *fw) 1596 1663 { 1597 1664 int status; 1598 1665 u32 val; ··· 1601 1666 lockdep_assert_held(&ar->conf_mutex); 1602 1667 1603 1668 clear_bit(ATH10K_FLAG_CRASH_FLUSH, &ar->dev_flags); 1669 + 1670 + ar->running_fw = fw; 1604 1671 1605 1672 ath10k_bmi_start(ar); 1606 1673 ··· 1622 1685 * to set the clock source once the target is initialized. 1623 1686 */ 1624 1687 if (test_bit(ATH10K_FW_FEATURE_SUPPORTS_SKIP_CLOCK_INIT, 1625 - ar->fw_features)) { 1688 + ar->running_fw->fw_file.fw_features)) { 1626 1689 status = ath10k_bmi_write32(ar, hi_skip_clock_init, 1); 1627 1690 if (status) { 1628 1691 ath10k_err(ar, "could not write to skip_clock_init: %d\n", ··· 1631 1694 } 1632 1695 } 1633 1696 1634 - status = ath10k_download_fw(ar, mode); 1697 + status = ath10k_download_fw(ar); 1635 1698 if (status) 1636 1699 goto err; 1637 1700 ··· 1724 1787 if (ath10k_peer_stats_enabled(ar)) 1725 1788 val = WMI_10_4_PEER_STATS; 1726 1789 1727 - status = ath10k_wmi_ext_resource_config(ar, 1728 - WMI_HOST_PLATFORM_HIGH_PERF, val); 1790 + status = ath10k_mac_ext_resource_config(ar, val); 1729 1791 if (status) { 1730 1792 ath10k_err(ar, 1731 1793 "failed to send ext resource cfg command : %d\n", ··· 1867 1931 goto err_power_down; 1868 1932 } 1869 1933 1934 + BUILD_BUG_ON(sizeof(ar->hw->wiphy->fw_version) != 1935 + sizeof(ar->normal_mode_fw.fw_file.fw_version)); 1936 + memcpy(ar->hw->wiphy->fw_version, ar->normal_mode_fw.fw_file.fw_version, 1937 + sizeof(ar->hw->wiphy->fw_version)); 1938 + 1870 1939 ath10k_debug_print_hwfw_info(ar); 1871 1940 1872 1941 ret = ath10k_core_pre_cal_download(ar); ··· 1914 1973 1915 1974 mutex_lock(&ar->conf_mutex); 1916 1975 1917 - ret = ath10k_core_start(ar, ATH10K_FIRMWARE_MODE_NORMAL); 1976 + ret = ath10k_core_start(ar, ATH10K_FIRMWARE_MODE_NORMAL, 1977 + &ar->normal_mode_fw); 1918 1978 if (ret) { 1919 1979 ath10k_err(ar, "could not init core (%d)\n", ret); 1920 1980 goto err_unlock;
+43 -28
drivers/net/wireless/ath/ath10k/core.h
··· 44 44 45 45 #define ATH10K_SCAN_ID 0 46 46 #define WMI_READY_TIMEOUT (5 * HZ) 47 - #define ATH10K_FLUSH_TIMEOUT_HZ (5*HZ) 48 - #define ATH10K_CONNECTION_LOSS_HZ (3*HZ) 47 + #define ATH10K_FLUSH_TIMEOUT_HZ (5 * HZ) 48 + #define ATH10K_CONNECTION_LOSS_HZ (3 * HZ) 49 49 #define ATH10K_NUM_CHANS 39 50 50 51 51 /* Antenna noise floor */ ··· 139 139 }; 140 140 141 141 struct ath10k_wmi { 142 - enum ath10k_fw_wmi_op_version op_version; 143 142 enum ath10k_htc_ep_id eid; 144 143 struct completion service_ready; 145 144 struct completion unified_ready; ··· 333 334 #endif 334 335 }; 335 336 336 - #define ATH10K_VDEV_SETUP_TIMEOUT_HZ (5*HZ) 337 + #define ATH10K_VDEV_SETUP_TIMEOUT_HZ (5 * HZ) 337 338 338 339 enum ath10k_beacon_state { 339 340 ATH10K_BEACON_SCHEDULED = 0, ··· 626 627 ATH10K_TX_PAUSE_MAX, 627 628 }; 628 629 630 + struct ath10k_fw_file { 631 + const struct firmware *firmware; 632 + 633 + char fw_version[ETHTOOL_FWVERS_LEN]; 634 + 635 + DECLARE_BITMAP(fw_features, ATH10K_FW_FEATURE_COUNT); 636 + 637 + enum ath10k_fw_wmi_op_version wmi_op_version; 638 + enum ath10k_fw_htt_op_version htt_op_version; 639 + 640 + const void *firmware_data; 641 + size_t firmware_len; 642 + 643 + const void *otp_data; 644 + size_t otp_len; 645 + 646 + const void *codeswap_data; 647 + size_t codeswap_len; 648 + }; 649 + 650 + struct ath10k_fw_components { 651 + const struct firmware *board; 652 + const void *board_data; 653 + size_t board_len; 654 + 655 + struct ath10k_fw_file fw_file; 656 + }; 657 + 629 658 struct ath10k { 630 659 struct ath_common ath_common; 631 660 struct ieee80211_hw *hw; ··· 678 651 u32 max_spatial_stream; 679 652 /* protected by conf_mutex */ 680 653 bool ani_enabled; 681 - 682 - DECLARE_BITMAP(fw_features, ATH10K_FW_FEATURE_COUNT); 683 654 684 655 bool p2p; 685 656 ··· 733 708 734 709 struct ath10k_hw_params_fw { 735 710 const char *dir; 736 - const char *fw; 737 - const char *otp; 738 711 const char *board; 739 712 size_t board_size; 740 713 size_t board_ext_size; 741 714 } fw; 742 715 } hw_params; 743 716 744 - const struct firmware *board; 745 - const void *board_data; 746 - size_t board_len; 717 + /* contains the firmware images used with ATH10K_FIRMWARE_MODE_NORMAL */ 718 + struct ath10k_fw_components normal_mode_fw; 747 719 748 - const struct firmware *otp; 749 - const void *otp_data; 750 - size_t otp_len; 751 - 752 - const struct firmware *firmware; 753 - const void *firmware_data; 754 - size_t firmware_len; 720 + /* READ-ONLY images of the running firmware, which can be either 721 + * normal or UTF. Do not modify, release etc! 722 + */ 723 + const struct ath10k_fw_components *running_fw; 755 724 756 725 const struct firmware *pre_cal_file; 757 726 const struct firmware *cal_file; 758 727 759 728 struct { 760 - const void *firmware_codeswap_data; 761 - size_t firmware_codeswap_len; 762 729 struct ath10k_swap_code_seg_info *firmware_swap_code_seg_info; 763 730 } swap; 764 731 ··· 896 879 897 880 struct { 898 881 /* protected by conf_mutex */ 899 - const struct firmware *utf; 900 - char utf_version[32]; 901 - const void *utf_firmware_data; 902 - size_t utf_firmware_len; 903 - DECLARE_BITMAP(orig_fw_features, ATH10K_FW_FEATURE_COUNT); 904 - enum ath10k_fw_wmi_op_version orig_wmi_op_version; 905 - enum ath10k_fw_wmi_op_version op_version; 882 + struct ath10k_fw_components utf_mode_fw; 883 + 906 884 /* protected by data_lock */ 907 885 bool utf_monitor; 908 886 } testmode; ··· 933 921 void ath10k_core_get_fw_features_str(struct ath10k *ar, 934 922 char *buf, 935 923 size_t max_len); 924 + int ath10k_core_fetch_firmware_api_n(struct ath10k *ar, const char *name, 925 + struct ath10k_fw_file *fw_file); 936 926 937 - int ath10k_core_start(struct ath10k *ar, enum ath10k_firmware_mode mode); 927 + int ath10k_core_start(struct ath10k *ar, enum ath10k_firmware_mode mode, 928 + const struct ath10k_fw_components *fw_components); 938 929 int ath10k_wait_for_suspend(struct ath10k *ar, u32 suspend_opt); 939 930 void ath10k_core_stop(struct ath10k *ar); 940 931 int ath10k_core_register(struct ath10k *ar, u32 chip_id);
+28 -16
drivers/net/wireless/ath/ath10k/debug.c
··· 126 126 127 127 void ath10k_debug_print_hwfw_info(struct ath10k *ar) 128 128 { 129 + const struct firmware *firmware; 129 130 char fw_features[128] = {}; 130 131 u32 crc = 0; 131 132 ··· 145 144 config_enabled(CONFIG_ATH10K_DFS_CERTIFIED), 146 145 config_enabled(CONFIG_NL80211_TESTMODE)); 147 146 148 - if (ar->firmware) 149 - crc = crc32_le(0, ar->firmware->data, ar->firmware->size); 147 + firmware = ar->normal_mode_fw.fw_file.firmware; 148 + if (firmware) 149 + crc = crc32_le(0, firmware->data, firmware->size); 150 150 151 151 ath10k_info(ar, "firmware ver %s api %d features %s crc32 %08x\n", 152 152 ar->hw->wiphy->fw_version, ··· 169 167 ath10k_info(ar, "board_file api %d bmi_id %s crc32 %08x", 170 168 ar->bd_api, 171 169 boardinfo, 172 - crc32_le(0, ar->board->data, ar->board->size)); 170 + crc32_le(0, ar->normal_mode_fw.board->data, 171 + ar->normal_mode_fw.board->size)); 173 172 } 174 173 175 174 void ath10k_debug_print_boot_info(struct ath10k *ar) ··· 178 175 ath10k_info(ar, "htt-ver %d.%d wmi-op %d htt-op %d cal %s max-sta %d raw %d hwcrypto %d\n", 179 176 ar->htt.target_version_major, 180 177 ar->htt.target_version_minor, 181 - ar->wmi.op_version, 182 - ar->htt.op_version, 178 + ar->normal_mode_fw.fw_file.wmi_op_version, 179 + ar->normal_mode_fw.fw_file.htt_op_version, 183 180 ath10k_cal_mode_str(ar->cal_mode), 184 181 ar->max_num_stations, 185 182 test_bit(ATH10K_FLAG_RAW_MODE, &ar->dev_flags), ··· 2125 2122 struct ath10k *ar = file->private_data; 2126 2123 char buf[32]; 2127 2124 size_t buf_size; 2128 - int ret = 0; 2125 + int ret; 2129 2126 bool val; 2130 2127 2131 2128 buf_size = min(count, (sizeof(buf) - 1)); ··· 2145 2142 goto exit; 2146 2143 } 2147 2144 2148 - if (!(test_bit(ATH10K_FLAG_BTCOEX, &ar->dev_flags) ^ val)) 2145 + if (!(test_bit(ATH10K_FLAG_BTCOEX, &ar->dev_flags) ^ val)) { 2146 + ret = count; 2149 2147 goto exit; 2148 + } 2150 2149 2151 2150 if (val) 2152 2151 set_bit(ATH10K_FLAG_BTCOEX, &ar->dev_flags); ··· 2194 2189 struct ath10k *ar = file->private_data; 2195 2190 char buf[32]; 2196 2191 size_t buf_size; 2197 - int ret = 0; 2192 + int ret; 2198 2193 bool val; 2199 2194 2200 2195 buf_size = min(count, (sizeof(buf) - 1)); ··· 2214 2209 goto exit; 2215 2210 } 2216 2211 2217 - if (!(test_bit(ATH10K_FLAG_PEER_STATS, &ar->dev_flags) ^ val)) 2212 + if (!(test_bit(ATH10K_FLAG_PEER_STATS, &ar->dev_flags) ^ val)) { 2213 + ret = count; 2218 2214 goto exit; 2215 + } 2219 2216 2220 2217 if (val) 2221 2218 set_bit(ATH10K_FLAG_PEER_STATS, &ar->dev_flags); ··· 2273 2266 2274 2267 len += scnprintf(buf + len, buf_len - len, 2275 2268 "firmware-N.bin\t\t%08x\n", 2276 - crc32_le(0, ar->firmware->data, ar->firmware->size)); 2269 + crc32_le(0, ar->normal_mode_fw.fw_file.firmware->data, 2270 + ar->normal_mode_fw.fw_file.firmware->size)); 2277 2271 len += scnprintf(buf + len, buf_len - len, 2278 2272 "athwlan\t\t\t%08x\n", 2279 - crc32_le(0, ar->firmware_data, ar->firmware_len)); 2273 + crc32_le(0, ar->normal_mode_fw.fw_file.firmware_data, 2274 + ar->normal_mode_fw.fw_file.firmware_len)); 2280 2275 len += scnprintf(buf + len, buf_len - len, 2281 2276 "otp\t\t\t%08x\n", 2282 - crc32_le(0, ar->otp_data, ar->otp_len)); 2277 + crc32_le(0, ar->normal_mode_fw.fw_file.otp_data, 2278 + ar->normal_mode_fw.fw_file.otp_len)); 2283 2279 len += scnprintf(buf + len, buf_len - len, 2284 2280 "codeswap\t\t%08x\n", 2285 - crc32_le(0, ar->swap.firmware_codeswap_data, 2286 - ar->swap.firmware_codeswap_len)); 2281 + crc32_le(0, ar->normal_mode_fw.fw_file.codeswap_data, 2282 + ar->normal_mode_fw.fw_file.codeswap_len)); 2287 2283 len += scnprintf(buf + len, buf_len - len, 2288 2284 "board-N.bin\t\t%08x\n", 2289 - crc32_le(0, ar->board->data, ar->board->size)); 2285 + crc32_le(0, ar->normal_mode_fw.board->data, 2286 + ar->normal_mode_fw.board->size)); 2290 2287 len += scnprintf(buf + len, buf_len - len, 2291 2288 "board\t\t\t%08x\n", 2292 - crc32_le(0, ar->board_data, ar->board_len)); 2289 + crc32_le(0, ar->normal_mode_fw.board_data, 2290 + ar->normal_mode_fw.board_len)); 2293 2291 2294 2292 ret_cnt = simple_read_from_buffer(user_buf, count, ppos, buf, len); 2295 2293
+1 -1
drivers/net/wireless/ath/ath10k/debug.h
··· 57 57 }; 58 58 59 59 /* FIXME: How to calculate the buffer size sanely? */ 60 - #define ATH10K_FW_STATS_BUF_SIZE (1024*1024) 60 + #define ATH10K_FW_STATS_BUF_SIZE (1024 * 1024) 61 61 62 62 extern unsigned int ath10k_debug_mask; 63 63
+2 -2
drivers/net/wireless/ath/ath10k/htc.h
··· 297 297 #define ATH10K_NUM_CONTROL_TX_BUFFERS 2 298 298 #define ATH10K_HTC_MAX_LEN 4096 299 299 #define ATH10K_HTC_MAX_CTRL_MSG_LEN 256 300 - #define ATH10K_HTC_WAIT_TIMEOUT_HZ (1*HZ) 300 + #define ATH10K_HTC_WAIT_TIMEOUT_HZ (1 * HZ) 301 301 #define ATH10K_HTC_CONTROL_BUFFER_SIZE (ATH10K_HTC_MAX_CTRL_MSG_LEN + \ 302 302 sizeof(struct ath10k_htc_hdr)) 303 - #define ATH10K_HTC_CONN_SVC_TIMEOUT_HZ (1*HZ) 303 + #define ATH10K_HTC_CONN_SVC_TIMEOUT_HZ (1 * HZ) 304 304 305 305 struct ath10k_htc_ep { 306 306 struct ath10k_htc *htc;
+2 -2
drivers/net/wireless/ath/ath10k/htt.c
··· 183 183 8 + /* llc snap */ 184 184 2; /* ip4 dscp or ip6 priority */ 185 185 186 - switch (ar->htt.op_version) { 186 + switch (ar->running_fw->fw_file.htt_op_version) { 187 187 case ATH10K_FW_HTT_OP_VERSION_10_4: 188 188 ar->htt.t2h_msg_types = htt_10_4_t2h_msg_types; 189 189 ar->htt.t2h_msg_types_max = HTT_10_4_T2H_NUM_MSGS; ··· 208 208 return 0; 209 209 } 210 210 211 - #define HTT_TARGET_VERSION_TIMEOUT_HZ (3*HZ) 211 + #define HTT_TARGET_VERSION_TIMEOUT_HZ (3 * HZ) 212 212 213 213 static int ath10k_htt_verify_version(struct ath10k_htt *htt) 214 214 {
+2 -3
drivers/net/wireless/ath/ath10k/htt.h
··· 1475 1475 u32 pn24; 1476 1476 1477 1477 /* TKIP or CCMP: 48-bit PN */ 1478 - u_int64_t pn48; 1478 + u64 pn48; 1479 1479 1480 1480 /* WAPI: 128-bit PN */ 1481 - u_int64_t pn128[2]; 1481 + u64 pn128[2]; 1482 1482 }; 1483 1483 1484 1484 struct htt_cmd { ··· 1562 1562 u8 target_version_major; 1563 1563 u8 target_version_minor; 1564 1564 struct completion target_version_received; 1565 - enum ath10k_fw_htt_op_version op_version; 1566 1565 u8 max_num_amsdu; 1567 1566 u8 max_num_ampdu; 1568 1567
+1 -1
drivers/net/wireless/ath/ath10k/htt_rx.c
··· 966 966 int len = ieee80211_hdrlen(hdr->frame_control); 967 967 968 968 if (!test_bit(ATH10K_FW_FEATURE_NO_NWIFI_DECAP_4ADDR_PADDING, 969 - ar->fw_features)) 969 + ar->running_fw->fw_file.fw_features)) 970 970 len = round_up(len, 4); 971 971 972 972 return len;
+6 -3
drivers/net/wireless/ath/ath10k/htt_tx.c
··· 267 267 struct ath10k *ar = htt->ar; 268 268 size_t size; 269 269 270 - if (!test_bit(ATH10K_FW_FEATURE_PEER_FLOW_CONTROL, ar->fw_features)) 270 + if (!test_bit(ATH10K_FW_FEATURE_PEER_FLOW_CONTROL, 271 + ar->running_fw->fw_file.fw_features)) 271 272 return; 272 273 273 274 size = sizeof(*htt->tx_q_state.vaddr); ··· 283 282 size_t size; 284 283 int ret; 285 284 286 - if (!test_bit(ATH10K_FW_FEATURE_PEER_FLOW_CONTROL, ar->fw_features)) 285 + if (!test_bit(ATH10K_FW_FEATURE_PEER_FLOW_CONTROL, 286 + ar->running_fw->fw_file.fw_features)) 287 287 return 0; 288 288 289 289 htt->tx_q_state.num_peers = HTT_TX_Q_STATE_NUM_PEERS; ··· 515 513 info |= SM(htt->tx_q_state.type, 516 514 HTT_FRAG_DESC_BANK_CFG_INFO_Q_STATE_DEPTH_TYPE); 517 515 518 - if (test_bit(ATH10K_FW_FEATURE_PEER_FLOW_CONTROL, ar->fw_features)) 516 + if (test_bit(ATH10K_FW_FEATURE_PEER_FLOW_CONTROL, 517 + ar->running_fw->fw_file.fw_features)) 519 518 info |= HTT_FRAG_DESC_BANK_CFG_INFO_Q_STATE_VALID; 520 519 521 520 cfg = &cmd->frag_desc_bank_cfg;
-12
drivers/net/wireless/ath/ath10k/hw.h
··· 35 35 #define QCA988X_HW_2_0_VERSION 0x4100016c 36 36 #define QCA988X_HW_2_0_CHIP_ID_REV 0x2 37 37 #define QCA988X_HW_2_0_FW_DIR ATH10K_FW_DIR "/QCA988X/hw2.0" 38 - #define QCA988X_HW_2_0_FW_FILE "firmware.bin" 39 - #define QCA988X_HW_2_0_OTP_FILE "otp.bin" 40 38 #define QCA988X_HW_2_0_BOARD_DATA_FILE "board.bin" 41 39 #define QCA988X_HW_2_0_PATCH_LOAD_ADDR 0x1234 42 40 ··· 74 76 }; 75 77 76 78 #define QCA6174_HW_2_1_FW_DIR "ath10k/QCA6174/hw2.1" 77 - #define QCA6174_HW_2_1_FW_FILE "firmware.bin" 78 - #define QCA6174_HW_2_1_OTP_FILE "otp.bin" 79 79 #define QCA6174_HW_2_1_BOARD_DATA_FILE "board.bin" 80 80 #define QCA6174_HW_2_1_PATCH_LOAD_ADDR 0x1234 81 81 82 82 #define QCA6174_HW_3_0_FW_DIR "ath10k/QCA6174/hw3.0" 83 - #define QCA6174_HW_3_0_FW_FILE "firmware.bin" 84 - #define QCA6174_HW_3_0_OTP_FILE "otp.bin" 85 83 #define QCA6174_HW_3_0_BOARD_DATA_FILE "board.bin" 86 84 #define QCA6174_HW_3_0_PATCH_LOAD_ADDR 0x1234 87 85 ··· 88 94 #define QCA99X0_HW_2_0_DEV_VERSION 0x01000000 89 95 #define QCA99X0_HW_2_0_CHIP_ID_REV 0x1 90 96 #define QCA99X0_HW_2_0_FW_DIR ATH10K_FW_DIR "/QCA99X0/hw2.0" 91 - #define QCA99X0_HW_2_0_FW_FILE "firmware.bin" 92 - #define QCA99X0_HW_2_0_OTP_FILE "otp.bin" 93 97 #define QCA99X0_HW_2_0_BOARD_DATA_FILE "board.bin" 94 98 #define QCA99X0_HW_2_0_PATCH_LOAD_ADDR 0x1234 95 99 96 100 /* QCA9377 1.0 definitions */ 97 101 #define QCA9377_HW_1_0_FW_DIR ATH10K_FW_DIR "/QCA9377/hw1.0" 98 - #define QCA9377_HW_1_0_FW_FILE "firmware.bin" 99 - #define QCA9377_HW_1_0_OTP_FILE "otp.bin" 100 102 #define QCA9377_HW_1_0_BOARD_DATA_FILE "board.bin" 101 103 #define QCA9377_HW_1_0_PATCH_LOAD_ADDR 0x1234 102 104 103 105 /* QCA4019 1.0 definitions */ 104 106 #define QCA4019_HW_1_0_DEV_VERSION 0x01000000 105 107 #define QCA4019_HW_1_0_FW_DIR ATH10K_FW_DIR "/QCA4019/hw1.0" 106 - #define QCA4019_HW_1_0_FW_FILE "firmware.bin" 107 - #define QCA4019_HW_1_0_OTP_FILE "otp.bin" 108 108 #define QCA4019_HW_1_0_BOARD_DATA_FILE "board.bin" 109 109 #define QCA4019_HW_1_0_PATCH_LOAD_ADDR 0x1234 110 110
+72 -16
drivers/net/wireless/ath/ath10k/mac.c
··· 157 157 return 1; 158 158 } 159 159 160 + int ath10k_mac_ext_resource_config(struct ath10k *ar, u32 val) 161 + { 162 + enum wmi_host_platform_type platform_type; 163 + int ret; 164 + 165 + if (test_bit(WMI_SERVICE_TX_MODE_DYNAMIC, ar->wmi.svc_map)) 166 + platform_type = WMI_HOST_PLATFORM_LOW_PERF; 167 + else 168 + platform_type = WMI_HOST_PLATFORM_HIGH_PERF; 169 + 170 + ret = ath10k_wmi_ext_resource_config(ar, platform_type, val); 171 + 172 + if (ret && ret != -EOPNOTSUPP) { 173 + ath10k_warn(ar, "failed to configure ext resource: %d\n", ret); 174 + return ret; 175 + } 176 + 177 + return 0; 178 + } 179 + 160 180 /**********/ 161 181 /* Crypto */ 162 182 /**********/ ··· 469 449 lockdep_assert_held(&ar->conf_mutex); 470 450 471 451 list_for_each_entry(peer, &ar->peers, list) { 472 - if (!memcmp(peer->addr, arvif->vif->addr, ETH_ALEN)) 452 + if (ether_addr_equal(peer->addr, arvif->vif->addr)) 473 453 continue; 474 454 475 - if (!memcmp(peer->addr, arvif->bssid, ETH_ALEN)) 455 + if (ether_addr_equal(peer->addr, arvif->bssid)) 476 456 continue; 477 457 478 458 if (peer->keys[key->keyidx] == key) ··· 1772 1752 1773 1753 if (enable_ps && ath10k_mac_num_vifs_started(ar) > 1 && 1774 1754 !test_bit(ATH10K_FW_FEATURE_MULTI_VIF_PS_SUPPORT, 1775 - ar->fw_features)) { 1755 + ar->running_fw->fw_file.fw_features)) { 1776 1756 ath10k_warn(ar, "refusing to enable ps on vdev %i: not supported by fw\n", 1777 1757 arvif->vdev_id); 1778 1758 enable_ps = false; ··· 2060 2040 } 2061 2041 2062 2042 if (sta->mfp && 2063 - test_bit(ATH10K_FW_FEATURE_MFP_SUPPORT, ar->fw_features)) { 2043 + test_bit(ATH10K_FW_FEATURE_MFP_SUPPORT, 2044 + ar->running_fw->fw_file.fw_features)) { 2064 2045 arg->peer_flags |= ar->wmi.peer_flags->pmf; 2065 2046 } 2066 2047 } ··· 3208 3187 */ 3209 3188 if (ar->htt.target_version_major < 3 && 3210 3189 (ieee80211_is_nullfunc(fc) || ieee80211_is_qos_nullfunc(fc)) && 3211 - !test_bit(ATH10K_FW_FEATURE_HAS_WMI_MGMT_TX, ar->fw_features)) 3190 + !test_bit(ATH10K_FW_FEATURE_HAS_WMI_MGMT_TX, 3191 + ar->running_fw->fw_file.fw_features)) 3212 3192 return ATH10K_HW_TXRX_MGMT; 3213 3193 3214 3194 /* Workaround: ··· 3359 3337 */ 3360 3338 return (ar->htt.target_version_major >= 3 && 3361 3339 ar->htt.target_version_minor >= 4 && 3362 - ar->htt.op_version == ATH10K_FW_HTT_OP_VERSION_TLV); 3340 + ar->running_fw->fw_file.htt_op_version == ATH10K_FW_HTT_OP_VERSION_TLV); 3363 3341 } 3364 3342 3365 3343 static int ath10k_mac_tx_wmi_mgmt(struct ath10k *ar, struct sk_buff *skb) ··· 3396 3374 return ATH10K_MAC_TX_HTT; 3397 3375 case ATH10K_HW_TXRX_MGMT: 3398 3376 if (test_bit(ATH10K_FW_FEATURE_HAS_WMI_MGMT_TX, 3399 - ar->fw_features)) 3377 + ar->running_fw->fw_file.fw_features)) 3400 3378 return ATH10K_MAC_TX_WMI_MGMT; 3401 3379 else if (ar->htt.target_version_major >= 3) 3402 3380 return ATH10K_MAC_TX_HTT; ··· 3868 3846 goto out; 3869 3847 } 3870 3848 3871 - ret = wait_for_completion_timeout(&ar->scan.completed, 3*HZ); 3849 + ret = wait_for_completion_timeout(&ar->scan.completed, 3 * HZ); 3872 3850 if (ret == 0) { 3873 3851 ath10k_warn(ar, "failed to receive scan abortion completion: timed out\n"); 3874 3852 ret = -ETIMEDOUT; ··· 3948 3926 if (ret) 3949 3927 return ret; 3950 3928 3951 - ret = wait_for_completion_timeout(&ar->scan.started, 1*HZ); 3929 + ret = wait_for_completion_timeout(&ar->scan.started, 1 * HZ); 3952 3930 if (ret == 0) { 3953 3931 ret = ath10k_scan_stop(ar); 3954 3932 if (ret) ··· 4378 4356 goto err_off; 4379 4357 } 4380 4358 4381 - ret = ath10k_core_start(ar, ATH10K_FIRMWARE_MODE_NORMAL); 4359 + ret = ath10k_core_start(ar, ATH10K_FIRMWARE_MODE_NORMAL, 4360 + &ar->normal_mode_fw); 4382 4361 if (ret) { 4383 4362 ath10k_err(ar, "Could not init core: %d\n", ret); 4384 4363 goto err_power_down; ··· 4437 4414 } 4438 4415 4439 4416 if (test_bit(ATH10K_FW_FEATURE_SUPPORTS_ADAPTIVE_CCA, 4440 - ar->fw_features)) { 4417 + ar->running_fw->fw_file.fw_features)) { 4441 4418 ret = ath10k_wmi_pdev_enable_adaptive_cca(ar, 1, 4442 4419 WMI_CCA_DETECT_LEVEL_AUTO, 4443 4420 WMI_CCA_DETECT_MARGIN_AUTO); ··· 6191 6168 return ret; 6192 6169 } 6193 6170 6194 - #define ATH10K_ROC_TIMEOUT_HZ (2*HZ) 6171 + #define ATH10K_ROC_TIMEOUT_HZ (2 * HZ) 6195 6172 6196 6173 static int ath10k_remain_on_channel(struct ieee80211_hw *hw, 6197 6174 struct ieee80211_vif *vif, ··· 6255 6232 goto exit; 6256 6233 } 6257 6234 6258 - ret = wait_for_completion_timeout(&ar->scan.on_channel, 3*HZ); 6235 + ret = wait_for_completion_timeout(&ar->scan.on_channel, 3 * HZ); 6259 6236 if (ret == 0) { 6260 6237 ath10k_warn(ar, "failed to switch to channel for roc scan\n"); 6261 6238 ··· 6819 6796 return 0; 6820 6797 } 6821 6798 6799 + static void ath10k_set_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif, 6800 + u64 tsf) 6801 + { 6802 + struct ath10k *ar = hw->priv; 6803 + struct ath10k_vif *arvif = ath10k_vif_to_arvif(vif); 6804 + u32 tsf_offset, vdev_param = ar->wmi.vdev_param->set_tsf; 6805 + int ret; 6806 + 6807 + /* Workaround: 6808 + * 6809 + * Given tsf argument is entire TSF value, but firmware accepts 6810 + * only TSF offset to current TSF. 6811 + * 6812 + * get_tsf function is used to get offset value, however since 6813 + * ath10k_get_tsf is not implemented properly, it will return 0 always. 6814 + * Luckily all the caller functions to set_tsf, as of now, also rely on 6815 + * get_tsf function to get entire tsf value such get_tsf() + tsf_delta, 6816 + * final tsf offset value to firmware will be arithmetically correct. 6817 + */ 6818 + tsf_offset = tsf - ath10k_get_tsf(hw, vif); 6819 + ret = ath10k_wmi_vdev_set_param(ar, arvif->vdev_id, 6820 + vdev_param, tsf_offset); 6821 + if (ret && ret != -EOPNOTSUPP) 6822 + ath10k_warn(ar, "failed to set tsf offset: %d\n", ret); 6823 + } 6824 + 6822 6825 static int ath10k_ampdu_action(struct ieee80211_hw *hw, 6823 6826 struct ieee80211_vif *vif, 6824 6827 struct ieee80211_ampdu_params *params) ··· 6916 6867 def = &vifs[0].new_ctx->def; 6917 6868 6918 6869 ar->rx_channel = def->chan; 6919 - } else if (ctx && ath10k_mac_num_chanctxs(ar) == 0) { 6870 + } else if ((ctx && ath10k_mac_num_chanctxs(ar) == 0) || 6871 + (ctx && (ar->state == ATH10K_STATE_RESTARTED))) { 6872 + /* During driver restart due to firmware assert, since mac80211 6873 + * already has valid channel context for given radio, channel 6874 + * context iteration return num_chanctx > 0. So fix rx_channel 6875 + * when restart is in progress. 6876 + */ 6920 6877 ar->rx_channel = ctx->def.chan; 6921 6878 } else { 6922 6879 ar->rx_channel = NULL; ··· 7307 7252 .set_bitrate_mask = ath10k_mac_op_set_bitrate_mask, 7308 7253 .sta_rc_update = ath10k_sta_rc_update, 7309 7254 .get_tsf = ath10k_get_tsf, 7255 + .set_tsf = ath10k_set_tsf, 7310 7256 .ampdu_action = ath10k_ampdu_action, 7311 7257 .get_et_sset_count = ath10k_debug_get_et_sset_count, 7312 7258 .get_et_stats = ath10k_debug_get_et_stats, ··· 7696 7640 ar->hw->wiphy->available_antennas_rx = ar->cfg_rx_chainmask; 7697 7641 ar->hw->wiphy->available_antennas_tx = ar->cfg_tx_chainmask; 7698 7642 7699 - if (!test_bit(ATH10K_FW_FEATURE_NO_P2P, ar->fw_features)) 7643 + if (!test_bit(ATH10K_FW_FEATURE_NO_P2P, ar->normal_mode_fw.fw_file.fw_features)) 7700 7644 ar->hw->wiphy->interface_modes |= 7701 7645 BIT(NL80211_IFTYPE_P2P_DEVICE) | 7702 7646 BIT(NL80211_IFTYPE_P2P_CLIENT) | ··· 7786 7730 */ 7787 7731 ar->hw->offchannel_tx_hw_queue = IEEE80211_MAX_QUEUES - 1; 7788 7732 7789 - switch (ar->wmi.op_version) { 7733 + switch (ar->running_fw->fw_file.wmi_op_version) { 7790 7734 case ATH10K_FW_WMI_OP_VERSION_MAIN: 7791 7735 ar->hw->wiphy->iface_combinations = ath10k_if_comb; 7792 7736 ar->hw->wiphy->n_iface_combinations =
+1
drivers/net/wireless/ath/ath10k/mac.h
··· 81 81 struct ieee80211_txq *ath10k_mac_txq_lookup(struct ath10k *ar, 82 82 u16 peer_id, 83 83 u8 tid); 84 + int ath10k_mac_ext_resource_config(struct ath10k *ar, u32 val); 84 85 85 86 static inline struct ath10k_vif *ath10k_vif_to_arvif(struct ieee80211_vif *vif) 86 87 {
+16 -149
drivers/net/wireless/ath/ath10k/pci.c
··· 33 33 #include "ce.h" 34 34 #include "pci.h" 35 35 36 - enum ath10k_pci_irq_mode { 37 - ATH10K_PCI_IRQ_AUTO = 0, 38 - ATH10K_PCI_IRQ_LEGACY = 1, 39 - ATH10K_PCI_IRQ_MSI = 2, 40 - }; 41 - 42 36 enum ath10k_pci_reset_mode { 43 37 ATH10K_PCI_RESET_AUTO = 0, 44 38 ATH10K_PCI_RESET_WARM_ONLY = 1, ··· 739 745 { 740 746 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); 741 747 742 - if (ar_pci->num_msi_intrs > 1) 743 - return "msi-x"; 744 - 745 - if (ar_pci->num_msi_intrs == 1) 748 + if (ar_pci->oper_irq_mode == ATH10K_PCI_IRQ_MSI) 746 749 return "msi"; 747 750 748 751 return "legacy"; ··· 1493 1502 void ath10k_pci_kill_tasklet(struct ath10k *ar) 1494 1503 { 1495 1504 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); 1496 - int i; 1497 1505 1498 1506 tasklet_kill(&ar_pci->intr_tq); 1499 - tasklet_kill(&ar_pci->msi_fw_err); 1500 - 1501 - for (i = 0; i < CE_COUNT; i++) 1502 - tasklet_kill(&ar_pci->pipe_info[i].intr); 1503 1507 1504 1508 del_timer_sync(&ar_pci->rx_post_retry); 1505 1509 } ··· 1610 1624 static void ath10k_pci_irq_sync(struct ath10k *ar) 1611 1625 { 1612 1626 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); 1613 - int i; 1614 1627 1615 - for (i = 0; i < max(1, ar_pci->num_msi_intrs); i++) 1616 - synchronize_irq(ar_pci->pdev->irq + i); 1628 + synchronize_irq(ar_pci->pdev->irq); 1617 1629 } 1618 1630 1619 1631 static void ath10k_pci_irq_enable(struct ath10k *ar) ··· 2580 2596 #endif 2581 2597 }; 2582 2598 2583 - static void ath10k_pci_ce_tasklet(unsigned long ptr) 2584 - { 2585 - struct ath10k_pci_pipe *pipe = (struct ath10k_pci_pipe *)ptr; 2586 - struct ath10k_pci *ar_pci = pipe->ar_pci; 2587 - 2588 - ath10k_ce_per_engine_service(ar_pci->ar, pipe->pipe_num); 2589 - } 2590 - 2591 - static void ath10k_msi_err_tasklet(unsigned long data) 2592 - { 2593 - struct ath10k *ar = (struct ath10k *)data; 2594 - 2595 - if (!ath10k_pci_has_fw_crashed(ar)) { 2596 - ath10k_warn(ar, "received unsolicited fw crash interrupt\n"); 2597 - return; 2598 - } 2599 - 2600 - ath10k_pci_irq_disable(ar); 2601 - ath10k_pci_fw_crashed_clear(ar); 2602 - ath10k_pci_fw_crashed_dump(ar); 2603 - } 2604 - 2605 - /* 2606 - * Handler for a per-engine interrupt on a PARTICULAR CE. 2607 - * This is used in cases where each CE has a private MSI interrupt. 2608 - */ 2609 - static irqreturn_t ath10k_pci_per_engine_handler(int irq, void *arg) 2610 - { 2611 - struct ath10k *ar = arg; 2612 - struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); 2613 - int ce_id = irq - ar_pci->pdev->irq - MSI_ASSIGN_CE_INITIAL; 2614 - 2615 - if (ce_id < 0 || ce_id >= ARRAY_SIZE(ar_pci->pipe_info)) { 2616 - ath10k_warn(ar, "unexpected/invalid irq %d ce_id %d\n", irq, 2617 - ce_id); 2618 - return IRQ_HANDLED; 2619 - } 2620 - 2621 - /* 2622 - * NOTE: We are able to derive ce_id from irq because we 2623 - * use a one-to-one mapping for CE's 0..5. 2624 - * CE's 6 & 7 do not use interrupts at all. 2625 - * 2626 - * This mapping must be kept in sync with the mapping 2627 - * used by firmware. 2628 - */ 2629 - tasklet_schedule(&ar_pci->pipe_info[ce_id].intr); 2630 - return IRQ_HANDLED; 2631 - } 2632 - 2633 - static irqreturn_t ath10k_pci_msi_fw_handler(int irq, void *arg) 2634 - { 2635 - struct ath10k *ar = arg; 2636 - struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); 2637 - 2638 - tasklet_schedule(&ar_pci->msi_fw_err); 2639 - return IRQ_HANDLED; 2640 - } 2641 - 2642 2599 /* 2643 2600 * Top-level interrupt handler for all PCI interrupts from a Target. 2644 2601 * When a block of MSI interrupts is allocated, this top-level handler ··· 2597 2672 return IRQ_NONE; 2598 2673 } 2599 2674 2600 - if (ar_pci->num_msi_intrs == 0) { 2675 + if (ar_pci->oper_irq_mode == ATH10K_PCI_IRQ_LEGACY) { 2601 2676 if (!ath10k_pci_irq_pending(ar)) 2602 2677 return IRQ_NONE; 2603 2678 ··· 2624 2699 ath10k_ce_per_engine_service_any(ar); 2625 2700 2626 2701 /* Re-enable legacy irq that was disabled in the irq handler */ 2627 - if (ar_pci->num_msi_intrs == 0) 2702 + if (ar_pci->oper_irq_mode == ATH10K_PCI_IRQ_LEGACY) 2628 2703 ath10k_pci_enable_legacy_irq(ar); 2629 - } 2630 - 2631 - static int ath10k_pci_request_irq_msix(struct ath10k *ar) 2632 - { 2633 - struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); 2634 - int ret, i; 2635 - 2636 - ret = request_irq(ar_pci->pdev->irq + MSI_ASSIGN_FW, 2637 - ath10k_pci_msi_fw_handler, 2638 - IRQF_SHARED, "ath10k_pci", ar); 2639 - if (ret) { 2640 - ath10k_warn(ar, "failed to request MSI-X fw irq %d: %d\n", 2641 - ar_pci->pdev->irq + MSI_ASSIGN_FW, ret); 2642 - return ret; 2643 - } 2644 - 2645 - for (i = MSI_ASSIGN_CE_INITIAL; i <= MSI_ASSIGN_CE_MAX; i++) { 2646 - ret = request_irq(ar_pci->pdev->irq + i, 2647 - ath10k_pci_per_engine_handler, 2648 - IRQF_SHARED, "ath10k_pci", ar); 2649 - if (ret) { 2650 - ath10k_warn(ar, "failed to request MSI-X ce irq %d: %d\n", 2651 - ar_pci->pdev->irq + i, ret); 2652 - 2653 - for (i--; i >= MSI_ASSIGN_CE_INITIAL; i--) 2654 - free_irq(ar_pci->pdev->irq + i, ar); 2655 - 2656 - free_irq(ar_pci->pdev->irq + MSI_ASSIGN_FW, ar); 2657 - return ret; 2658 - } 2659 - } 2660 - 2661 - return 0; 2662 2704 } 2663 2705 2664 2706 static int ath10k_pci_request_irq_msi(struct ath10k *ar) ··· 2666 2774 { 2667 2775 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); 2668 2776 2669 - switch (ar_pci->num_msi_intrs) { 2670 - case 0: 2777 + switch (ar_pci->oper_irq_mode) { 2778 + case ATH10K_PCI_IRQ_LEGACY: 2671 2779 return ath10k_pci_request_irq_legacy(ar); 2672 - case 1: 2780 + case ATH10K_PCI_IRQ_MSI: 2673 2781 return ath10k_pci_request_irq_msi(ar); 2674 2782 default: 2675 - return ath10k_pci_request_irq_msix(ar); 2783 + return -EINVAL; 2676 2784 } 2677 2785 } 2678 2786 2679 2787 static void ath10k_pci_free_irq(struct ath10k *ar) 2680 2788 { 2681 2789 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); 2682 - int i; 2683 2790 2684 - /* There's at least one interrupt irregardless whether its legacy INTR 2685 - * or MSI or MSI-X */ 2686 - for (i = 0; i < max(1, ar_pci->num_msi_intrs); i++) 2687 - free_irq(ar_pci->pdev->irq + i, ar); 2791 + free_irq(ar_pci->pdev->irq, ar); 2688 2792 } 2689 2793 2690 2794 void ath10k_pci_init_irq_tasklets(struct ath10k *ar) 2691 2795 { 2692 2796 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); 2693 - int i; 2694 2797 2695 2798 tasklet_init(&ar_pci->intr_tq, ath10k_pci_tasklet, (unsigned long)ar); 2696 - tasklet_init(&ar_pci->msi_fw_err, ath10k_msi_err_tasklet, 2697 - (unsigned long)ar); 2698 - 2699 - for (i = 0; i < CE_COUNT; i++) { 2700 - ar_pci->pipe_info[i].ar_pci = ar_pci; 2701 - tasklet_init(&ar_pci->pipe_info[i].intr, ath10k_pci_ce_tasklet, 2702 - (unsigned long)&ar_pci->pipe_info[i]); 2703 - } 2704 2799 } 2705 2800 2706 2801 static int ath10k_pci_init_irq(struct ath10k *ar) ··· 2701 2822 ath10k_info(ar, "limiting irq mode to: %d\n", 2702 2823 ath10k_pci_irq_mode); 2703 2824 2704 - /* Try MSI-X */ 2705 - if (ath10k_pci_irq_mode == ATH10K_PCI_IRQ_AUTO) { 2706 - ar_pci->num_msi_intrs = MSI_ASSIGN_CE_MAX + 1; 2707 - ret = pci_enable_msi_range(ar_pci->pdev, ar_pci->num_msi_intrs, 2708 - ar_pci->num_msi_intrs); 2709 - if (ret > 0) 2710 - return 0; 2711 - 2712 - /* fall-through */ 2713 - } 2714 - 2715 2825 /* Try MSI */ 2716 2826 if (ath10k_pci_irq_mode != ATH10K_PCI_IRQ_LEGACY) { 2717 - ar_pci->num_msi_intrs = 1; 2827 + ar_pci->oper_irq_mode = ATH10K_PCI_IRQ_MSI; 2718 2828 ret = pci_enable_msi(ar_pci->pdev); 2719 2829 if (ret == 0) 2720 2830 return 0; ··· 2719 2851 * This write might get lost if target has NOT written BAR. 2720 2852 * For now, fix the race by repeating the write in below 2721 2853 * synchronization checking. */ 2722 - ar_pci->num_msi_intrs = 0; 2854 + ar_pci->oper_irq_mode = ATH10K_PCI_IRQ_LEGACY; 2723 2855 2724 2856 ath10k_pci_write32(ar, SOC_CORE_BASE_ADDRESS + PCIE_INTR_ENABLE_ADDRESS, 2725 2857 PCIE_INTR_FIRMWARE_MASK | PCIE_INTR_CE_MASK_ALL); ··· 2737 2869 { 2738 2870 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); 2739 2871 2740 - switch (ar_pci->num_msi_intrs) { 2741 - case 0: 2872 + switch (ar_pci->oper_irq_mode) { 2873 + case ATH10K_PCI_IRQ_LEGACY: 2742 2874 ath10k_pci_deinit_irq_legacy(ar); 2743 2875 break; 2744 2876 default: ··· 2776 2908 if (val & FW_IND_INITIALIZED) 2777 2909 break; 2778 2910 2779 - if (ar_pci->num_msi_intrs == 0) 2911 + if (ar_pci->oper_irq_mode == ATH10K_PCI_IRQ_LEGACY) 2780 2912 /* Fix potential race by repeating CORE_BASE writes */ 2781 2913 ath10k_pci_enable_legacy_irq(ar); 2782 2914 ··· 3054 3186 goto err_sleep; 3055 3187 } 3056 3188 3057 - ath10k_info(ar, "pci irq %s interrupts %d irq_mode %d reset_mode %d\n", 3058 - ath10k_pci_get_irq_method(ar), ar_pci->num_msi_intrs, 3189 + ath10k_info(ar, "pci irq %s oper_irq_mode %d irq_mode %d reset_mode %d\n", 3190 + ath10k_pci_get_irq_method(ar), ar_pci->oper_irq_mode, 3059 3191 ath10k_pci_irq_mode, ath10k_pci_reset_mode); 3060 3192 3061 3193 ret = ath10k_pci_request_irq(ar); ··· 3173 3305 MODULE_LICENSE("Dual BSD/GPL"); 3174 3306 3175 3307 /* QCA988x 2.0 firmware files */ 3176 - MODULE_FIRMWARE(QCA988X_HW_2_0_FW_DIR "/" QCA988X_HW_2_0_FW_FILE); 3177 3308 MODULE_FIRMWARE(QCA988X_HW_2_0_FW_DIR "/" ATH10K_FW_API2_FILE); 3178 3309 MODULE_FIRMWARE(QCA988X_HW_2_0_FW_DIR "/" ATH10K_FW_API3_FILE); 3179 3310 MODULE_FIRMWARE(QCA988X_HW_2_0_FW_DIR "/" ATH10K_FW_API4_FILE);
+8 -9
drivers/net/wireless/ath/ath10k/pci.h
··· 148 148 149 149 /* protects compl_free and num_send_allowed */ 150 150 spinlock_t pipe_lock; 151 - 152 - struct ath10k_pci *ar_pci; 153 - struct tasklet_struct intr; 154 151 }; 155 152 156 153 struct ath10k_pci_supp_chip { ··· 161 164 int (*get_num_banks)(struct ath10k *ar); 162 165 }; 163 166 167 + enum ath10k_pci_irq_mode { 168 + ATH10K_PCI_IRQ_AUTO = 0, 169 + ATH10K_PCI_IRQ_LEGACY = 1, 170 + ATH10K_PCI_IRQ_MSI = 2, 171 + }; 172 + 164 173 struct ath10k_pci { 165 174 struct pci_dev *pdev; 166 175 struct device *dev; ··· 174 171 void __iomem *mem; 175 172 size_t mem_len; 176 173 177 - /* 178 - * Number of MSI interrupts granted, 0 --> using legacy PCI line 179 - * interrupts. 180 - */ 181 - int num_msi_intrs; 174 + /* Operating interrupt mode */ 175 + enum ath10k_pci_irq_mode oper_irq_mode; 182 176 183 177 struct tasklet_struct intr_tq; 184 - struct tasklet_struct msi_fw_err; 185 178 186 179 struct ath10k_pci_pipe pipe_info[CE_COUNT_MAX]; 187 180
+21 -23
drivers/net/wireless/ath/ath10k/swap.c
··· 134 134 return seg_info; 135 135 } 136 136 137 - int ath10k_swap_code_seg_configure(struct ath10k *ar, 138 - enum ath10k_swap_code_seg_bin_type type) 137 + int ath10k_swap_code_seg_configure(struct ath10k *ar) 139 138 { 140 139 int ret; 141 140 struct ath10k_swap_code_seg_info *seg_info = NULL; 142 141 143 - switch (type) { 144 - case ATH10K_SWAP_CODE_SEG_BIN_TYPE_FW: 145 - if (!ar->swap.firmware_swap_code_seg_info) 146 - return 0; 147 - 148 - ath10k_dbg(ar, ATH10K_DBG_BOOT, "boot found firmware code swap binary\n"); 149 - seg_info = ar->swap.firmware_swap_code_seg_info; 150 - break; 151 - default: 152 - case ATH10K_SWAP_CODE_SEG_BIN_TYPE_OTP: 153 - case ATH10K_SWAP_CODE_SEG_BIN_TYPE_UTF: 154 - ath10k_warn(ar, "ignoring unknown code swap binary type %d\n", 155 - type); 142 + if (!ar->swap.firmware_swap_code_seg_info) 156 143 return 0; 157 - } 144 + 145 + ath10k_dbg(ar, ATH10K_DBG_BOOT, "boot found firmware code swap binary\n"); 146 + 147 + seg_info = ar->swap.firmware_swap_code_seg_info; 158 148 159 149 ret = ath10k_bmi_write_memory(ar, seg_info->target_addr, 160 150 &seg_info->seg_hw_info, ··· 161 171 void ath10k_swap_code_seg_release(struct ath10k *ar) 162 172 { 163 173 ath10k_swap_code_seg_free(ar, ar->swap.firmware_swap_code_seg_info); 164 - ar->swap.firmware_codeswap_data = NULL; 165 - ar->swap.firmware_codeswap_len = 0; 174 + 175 + /* FIXME: these two assignments look to bein wrong place! Shouldn't 176 + * they be in ath10k_core_free_firmware_files() like the rest? 177 + */ 178 + ar->normal_mode_fw.fw_file.codeswap_data = NULL; 179 + ar->normal_mode_fw.fw_file.codeswap_len = 0; 180 + 166 181 ar->swap.firmware_swap_code_seg_info = NULL; 167 182 } 168 183 ··· 175 180 { 176 181 int ret; 177 182 struct ath10k_swap_code_seg_info *seg_info; 183 + const void *codeswap_data; 184 + size_t codeswap_len; 178 185 179 - if (!ar->swap.firmware_codeswap_len || !ar->swap.firmware_codeswap_data) 186 + codeswap_data = ar->normal_mode_fw.fw_file.codeswap_data; 187 + codeswap_len = ar->normal_mode_fw.fw_file.codeswap_len; 188 + 189 + if (!codeswap_len || !codeswap_data) 180 190 return 0; 181 191 182 - seg_info = ath10k_swap_code_seg_alloc(ar, 183 - ar->swap.firmware_codeswap_len); 192 + seg_info = ath10k_swap_code_seg_alloc(ar, codeswap_len); 184 193 if (!seg_info) { 185 194 ath10k_err(ar, "failed to allocate fw code swap segment\n"); 186 195 return -ENOMEM; 187 196 } 188 197 189 198 ret = ath10k_swap_code_seg_fill(ar, seg_info, 190 - ar->swap.firmware_codeswap_data, 191 - ar->swap.firmware_codeswap_len); 199 + codeswap_data, codeswap_len); 192 200 193 201 if (ret) { 194 202 ath10k_warn(ar, "failed to initialize fw code swap segment: %d\n",
+1 -8
drivers/net/wireless/ath/ath10k/swap.h
··· 39 39 struct ath10k_swap_code_seg_tail tail; 40 40 } __packed; 41 41 42 - enum ath10k_swap_code_seg_bin_type { 43 - ATH10K_SWAP_CODE_SEG_BIN_TYPE_OTP, 44 - ATH10K_SWAP_CODE_SEG_BIN_TYPE_FW, 45 - ATH10K_SWAP_CODE_SEG_BIN_TYPE_UTF, 46 - }; 47 - 48 42 struct ath10k_swap_code_seg_hw_info { 49 43 /* Swap binary image size */ 50 44 __le32 swap_size; ··· 58 64 dma_addr_t paddr[ATH10K_SWAP_CODE_SEG_NUM_SUPPORTED]; 59 65 }; 60 66 61 - int ath10k_swap_code_seg_configure(struct ath10k *ar, 62 - enum ath10k_swap_code_seg_bin_type type); 67 + int ath10k_swap_code_seg_configure(struct ath10k *ar); 63 68 void ath10k_swap_code_seg_release(struct ath10k *ar); 64 69 int ath10k_swap_code_seg_init(struct ath10k *ar); 65 70
+1 -1
drivers/net/wireless/ath/ath10k/targaddrs.h
··· 438 438 ((HOST_INTEREST->hi_pwr_save_flags & HI_PWR_SAVE_LPL_ENABLED)) 439 439 #define HI_DEV_LPL_TYPE_GET(_devix) \ 440 440 (HOST_INTEREST->hi_pwr_save_flags & ((HI_PWR_SAVE_LPL_DEV_MASK) << \ 441 - (HI_PWR_SAVE_LPL_DEV0_LSB + (_devix)*2))) 441 + (HI_PWR_SAVE_LPL_DEV0_LSB + (_devix) * 2))) 442 442 443 443 #define HOST_INTEREST_SMPS_IS_ALLOWED() \ 444 444 ((HOST_INTEREST->hi_smps_options & HI_SMPS_ALLOW_MASK))
+39 -158
drivers/net/wireless/ath/ath10k/testmode.c
··· 139 139 return cfg80211_testmode_reply(skb); 140 140 } 141 141 142 - static int ath10k_tm_fetch_utf_firmware_api_2(struct ath10k *ar) 143 - { 144 - size_t len, magic_len, ie_len; 145 - struct ath10k_fw_ie *hdr; 146 - char filename[100]; 147 - __le32 *version; 148 - const u8 *data; 149 - int ie_id, ret; 150 - 151 - snprintf(filename, sizeof(filename), "%s/%s", 152 - ar->hw_params.fw.dir, ATH10K_FW_UTF_API2_FILE); 153 - 154 - /* load utf firmware image */ 155 - ret = request_firmware(&ar->testmode.utf, filename, ar->dev); 156 - if (ret) { 157 - ath10k_warn(ar, "failed to retrieve utf firmware '%s': %d\n", 158 - filename, ret); 159 - return ret; 160 - } 161 - 162 - data = ar->testmode.utf->data; 163 - len = ar->testmode.utf->size; 164 - 165 - /* FIXME: call release_firmware() in error cases */ 166 - 167 - /* magic also includes the null byte, check that as well */ 168 - magic_len = strlen(ATH10K_FIRMWARE_MAGIC) + 1; 169 - 170 - if (len < magic_len) { 171 - ath10k_err(ar, "utf firmware file is too small to contain magic\n"); 172 - ret = -EINVAL; 173 - goto err; 174 - } 175 - 176 - if (memcmp(data, ATH10K_FIRMWARE_MAGIC, magic_len) != 0) { 177 - ath10k_err(ar, "invalid firmware magic\n"); 178 - ret = -EINVAL; 179 - goto err; 180 - } 181 - 182 - /* jump over the padding */ 183 - magic_len = ALIGN(magic_len, 4); 184 - 185 - len -= magic_len; 186 - data += magic_len; 187 - 188 - /* loop elements */ 189 - while (len > sizeof(struct ath10k_fw_ie)) { 190 - hdr = (struct ath10k_fw_ie *)data; 191 - 192 - ie_id = le32_to_cpu(hdr->id); 193 - ie_len = le32_to_cpu(hdr->len); 194 - 195 - len -= sizeof(*hdr); 196 - data += sizeof(*hdr); 197 - 198 - if (len < ie_len) { 199 - ath10k_err(ar, "invalid length for FW IE %d (%zu < %zu)\n", 200 - ie_id, len, ie_len); 201 - ret = -EINVAL; 202 - goto err; 203 - } 204 - 205 - switch (ie_id) { 206 - case ATH10K_FW_IE_FW_VERSION: 207 - if (ie_len > sizeof(ar->testmode.utf_version) - 1) 208 - break; 209 - 210 - memcpy(ar->testmode.utf_version, data, ie_len); 211 - ar->testmode.utf_version[ie_len] = '\0'; 212 - 213 - ath10k_dbg(ar, ATH10K_DBG_TESTMODE, 214 - "testmode found fw utf version %s\n", 215 - ar->testmode.utf_version); 216 - break; 217 - case ATH10K_FW_IE_TIMESTAMP: 218 - /* ignore timestamp, but don't warn about it either */ 219 - break; 220 - case ATH10K_FW_IE_FW_IMAGE: 221 - ath10k_dbg(ar, ATH10K_DBG_TESTMODE, 222 - "testmode found fw image ie (%zd B)\n", 223 - ie_len); 224 - 225 - ar->testmode.utf_firmware_data = data; 226 - ar->testmode.utf_firmware_len = ie_len; 227 - break; 228 - case ATH10K_FW_IE_WMI_OP_VERSION: 229 - if (ie_len != sizeof(u32)) 230 - break; 231 - version = (__le32 *)data; 232 - ar->testmode.op_version = le32_to_cpup(version); 233 - ath10k_dbg(ar, ATH10K_DBG_TESTMODE, "testmode found fw ie wmi op version %d\n", 234 - ar->testmode.op_version); 235 - break; 236 - default: 237 - ath10k_warn(ar, "Unknown testmode FW IE: %u\n", 238 - le32_to_cpu(hdr->id)); 239 - break; 240 - } 241 - /* jump over the padding */ 242 - ie_len = ALIGN(ie_len, 4); 243 - 244 - len -= ie_len; 245 - data += ie_len; 246 - } 247 - 248 - if (!ar->testmode.utf_firmware_data || !ar->testmode.utf_firmware_len) { 249 - ath10k_err(ar, "No ATH10K_FW_IE_FW_IMAGE found\n"); 250 - ret = -EINVAL; 251 - goto err; 252 - } 253 - 254 - return 0; 255 - 256 - err: 257 - release_firmware(ar->testmode.utf); 258 - 259 - return ret; 260 - } 261 - 262 - static int ath10k_tm_fetch_utf_firmware_api_1(struct ath10k *ar) 142 + static int ath10k_tm_fetch_utf_firmware_api_1(struct ath10k *ar, 143 + struct ath10k_fw_file *fw_file) 263 144 { 264 145 char filename[100]; 265 146 int ret; ··· 149 268 ar->hw_params.fw.dir, ATH10K_FW_UTF_FILE); 150 269 151 270 /* load utf firmware image */ 152 - ret = request_firmware(&ar->testmode.utf, filename, ar->dev); 271 + ret = request_firmware(&fw_file->firmware, filename, ar->dev); 153 272 if (ret) { 154 273 ath10k_warn(ar, "failed to retrieve utf firmware '%s': %d\n", 155 274 filename, ret); ··· 162 281 * correct WMI interface. 163 282 */ 164 283 165 - ar->testmode.op_version = ATH10K_FW_WMI_OP_VERSION_10_1; 166 - ar->testmode.utf_firmware_data = ar->testmode.utf->data; 167 - ar->testmode.utf_firmware_len = ar->testmode.utf->size; 284 + fw_file->wmi_op_version = ATH10K_FW_WMI_OP_VERSION_10_1; 285 + fw_file->htt_op_version = ATH10K_FW_HTT_OP_VERSION_10_1; 286 + fw_file->firmware_data = fw_file->firmware->data; 287 + fw_file->firmware_len = fw_file->firmware->size; 168 288 169 289 return 0; 170 290 } 171 291 172 292 static int ath10k_tm_fetch_firmware(struct ath10k *ar) 173 293 { 294 + struct ath10k_fw_components *utf_mode_fw; 174 295 int ret; 175 296 176 - ret = ath10k_tm_fetch_utf_firmware_api_2(ar); 297 + ret = ath10k_core_fetch_firmware_api_n(ar, ATH10K_FW_UTF_API2_FILE, 298 + &ar->testmode.utf_mode_fw.fw_file); 177 299 if (ret == 0) { 178 300 ath10k_dbg(ar, ATH10K_DBG_TESTMODE, "testmode using fw utf api 2"); 179 - return 0; 301 + goto out; 180 302 } 181 303 182 - ret = ath10k_tm_fetch_utf_firmware_api_1(ar); 304 + ret = ath10k_tm_fetch_utf_firmware_api_1(ar, &ar->testmode.utf_mode_fw.fw_file); 183 305 if (ret) { 184 306 ath10k_err(ar, "failed to fetch utf firmware binary: %d", ret); 185 307 return ret; 186 308 } 187 309 188 310 ath10k_dbg(ar, ATH10K_DBG_TESTMODE, "testmode using utf api 1"); 311 + 312 + out: 313 + utf_mode_fw = &ar->testmode.utf_mode_fw; 314 + 315 + /* Use the same board data file as the normal firmware uses (but 316 + * it's still "owned" by normal_mode_fw so we shouldn't free it. 317 + */ 318 + utf_mode_fw->board_data = ar->normal_mode_fw.board_data; 319 + utf_mode_fw->board_len = ar->normal_mode_fw.board_len; 320 + 321 + if (!utf_mode_fw->fw_file.otp_data) { 322 + ath10k_info(ar, "utf.bin didn't contain otp binary, taking it from the normal mode firmware"); 323 + utf_mode_fw->fw_file.otp_data = ar->normal_mode_fw.fw_file.otp_data; 324 + utf_mode_fw->fw_file.otp_len = ar->normal_mode_fw.fw_file.otp_len; 325 + } 189 326 190 327 return 0; 191 328 } ··· 228 329 goto err; 229 330 } 230 331 231 - if (WARN_ON(ar->testmode.utf != NULL)) { 332 + if (WARN_ON(ar->testmode.utf_mode_fw.fw_file.firmware != NULL)) { 232 333 /* utf image is already downloaded, it shouldn't be */ 233 334 ret = -EEXIST; 234 335 goto err; ··· 243 344 spin_lock_bh(&ar->data_lock); 244 345 ar->testmode.utf_monitor = true; 245 346 spin_unlock_bh(&ar->data_lock); 246 - BUILD_BUG_ON(sizeof(ar->fw_features) != 247 - sizeof(ar->testmode.orig_fw_features)); 248 - 249 - memcpy(ar->testmode.orig_fw_features, ar->fw_features, 250 - sizeof(ar->fw_features)); 251 - ar->testmode.orig_wmi_op_version = ar->wmi.op_version; 252 - memset(ar->fw_features, 0, sizeof(ar->fw_features)); 253 - 254 - ar->wmi.op_version = ar->testmode.op_version; 255 347 256 348 ath10k_dbg(ar, ATH10K_DBG_TESTMODE, "testmode wmi version %d\n", 257 - ar->wmi.op_version); 349 + ar->testmode.utf_mode_fw.fw_file.wmi_op_version); 258 350 259 351 ret = ath10k_hif_power_up(ar); 260 352 if (ret) { 261 353 ath10k_err(ar, "failed to power up hif (testmode): %d\n", ret); 262 354 ar->state = ATH10K_STATE_OFF; 263 - goto err_fw_features; 355 + goto err_release_utf_mode_fw; 264 356 } 265 357 266 - ret = ath10k_core_start(ar, ATH10K_FIRMWARE_MODE_UTF); 358 + ret = ath10k_core_start(ar, ATH10K_FIRMWARE_MODE_UTF, 359 + &ar->testmode.utf_mode_fw); 267 360 if (ret) { 268 361 ath10k_err(ar, "failed to start core (testmode): %d\n", ret); 269 362 ar->state = ATH10K_STATE_OFF; ··· 264 373 265 374 ar->state = ATH10K_STATE_UTF; 266 375 267 - if (strlen(ar->testmode.utf_version) > 0) 268 - ver = ar->testmode.utf_version; 376 + if (strlen(ar->testmode.utf_mode_fw.fw_file.fw_version) > 0) 377 + ver = ar->testmode.utf_mode_fw.fw_file.fw_version; 269 378 else 270 379 ver = "API 1"; 271 380 ··· 278 387 err_power_down: 279 388 ath10k_hif_power_down(ar); 280 389 281 - err_fw_features: 282 - /* return the original firmware features */ 283 - memcpy(ar->fw_features, ar->testmode.orig_fw_features, 284 - sizeof(ar->fw_features)); 285 - ar->wmi.op_version = ar->testmode.orig_wmi_op_version; 286 - 287 - release_firmware(ar->testmode.utf); 288 - ar->testmode.utf = NULL; 390 + err_release_utf_mode_fw: 391 + release_firmware(ar->testmode.utf_mode_fw.fw_file.firmware); 392 + ar->testmode.utf_mode_fw.fw_file.firmware = NULL; 289 393 290 394 err: 291 395 mutex_unlock(&ar->conf_mutex); ··· 301 415 302 416 spin_unlock_bh(&ar->data_lock); 303 417 304 - /* return the original firmware features */ 305 - memcpy(ar->fw_features, ar->testmode.orig_fw_features, 306 - sizeof(ar->fw_features)); 307 - ar->wmi.op_version = ar->testmode.orig_wmi_op_version; 308 - 309 - release_firmware(ar->testmode.utf); 310 - ar->testmode.utf = NULL; 418 + release_firmware(ar->testmode.utf_mode_fw.fw_file.firmware); 419 + ar->testmode.utf_mode_fw.fw_file.firmware = NULL; 311 420 312 421 ar->state = ATH10K_STATE_OFF; 313 422 }
+1 -1
drivers/net/wireless/ath/ath10k/thermal.h
··· 20 20 #define ATH10K_QUIET_PERIOD_MIN 25 21 21 #define ATH10K_QUIET_START_OFFSET 10 22 22 #define ATH10K_HWMON_NAME_LEN 15 23 - #define ATH10K_THERMAL_SYNC_TIMEOUT_HZ (5*HZ) 23 + #define ATH10K_THERMAL_SYNC_TIMEOUT_HZ (5 * HZ) 24 24 #define ATH10K_THERMAL_THROTTLE_MAX 100 25 25 26 26 struct ath10k_thermal {
+16 -2
drivers/net/wireless/ath/ath10k/txrx.c
··· 130 130 list_for_each_entry(peer, &ar->peers, list) { 131 131 if (peer->vdev_id != vdev_id) 132 132 continue; 133 - if (memcmp(peer->addr, addr, ETH_ALEN)) 133 + if (!ether_addr_equal(peer->addr, addr)) 134 134 continue; 135 135 136 136 return peer; ··· 166 166 167 167 (mapped == expect_mapped || 168 168 test_bit(ATH10K_FLAG_CRASH_FLUSH, &ar->dev_flags)); 169 - }), 3*HZ); 169 + }), 3 * HZ); 170 170 171 171 if (time_left == 0) 172 172 return -ETIMEDOUT; ··· 189 189 { 190 190 struct ath10k *ar = htt->ar; 191 191 struct ath10k_peer *peer; 192 + 193 + if (ev->peer_id >= ATH10K_MAX_NUM_PEER_IDS) { 194 + ath10k_warn(ar, 195 + "received htt peer map event with idx out of bounds: %hu\n", 196 + ev->peer_id); 197 + return; 198 + } 192 199 193 200 spin_lock_bh(&ar->data_lock); 194 201 peer = ath10k_peer_find(ar, ev->vdev_id, ev->addr); ··· 224 217 { 225 218 struct ath10k *ar = htt->ar; 226 219 struct ath10k_peer *peer; 220 + 221 + if (ev->peer_id >= ATH10K_MAX_NUM_PEER_IDS) { 222 + ath10k_warn(ar, 223 + "received htt peer unmap event with idx out of bounds: %hu\n", 224 + ev->peer_id); 225 + return; 226 + } 227 227 228 228 spin_lock_bh(&ar->data_lock); 229 229 peer = ath10k_peer_find_by_id(ar, ev->peer_id);
+1
drivers/net/wireless/ath/ath10k/wmi-tlv.c
··· 3409 3409 .meru_vc = WMI_VDEV_PARAM_UNSUPPORTED, 3410 3410 .rx_decap_type = WMI_VDEV_PARAM_UNSUPPORTED, 3411 3411 .bw_nss_ratemask = WMI_VDEV_PARAM_UNSUPPORTED, 3412 + .set_tsf = WMI_VDEV_PARAM_UNSUPPORTED, 3412 3413 }; 3413 3414 3414 3415 static const struct wmi_ops wmi_tlv_ops = {
+2 -2
drivers/net/wireless/ath/ath10k/wmi-tlv.h
··· 968 968 969 969 #define WMI_SERVICE_IS_ENABLED(wmi_svc_bmap, svc_id, len) \ 970 970 ((svc_id) < (len) && \ 971 - __le32_to_cpu((wmi_svc_bmap)[(svc_id)/(sizeof(u32))]) & \ 972 - BIT((svc_id)%(sizeof(u32)))) 971 + __le32_to_cpu((wmi_svc_bmap)[(svc_id) / (sizeof(u32))]) & \ 972 + BIT((svc_id) % (sizeof(u32)))) 973 973 974 974 #define SVCMAP(x, y, len) \ 975 975 do { \
+12 -12
drivers/net/wireless/ath/ath10k/wmi.c
··· 781 781 .meru_vc = WMI_VDEV_PARAM_UNSUPPORTED, 782 782 .rx_decap_type = WMI_VDEV_PARAM_UNSUPPORTED, 783 783 .bw_nss_ratemask = WMI_VDEV_PARAM_UNSUPPORTED, 784 + .set_tsf = WMI_VDEV_PARAM_UNSUPPORTED, 784 785 }; 785 786 786 787 /* 10.X WMI VDEV param map */ ··· 857 856 .meru_vc = WMI_VDEV_PARAM_UNSUPPORTED, 858 857 .rx_decap_type = WMI_VDEV_PARAM_UNSUPPORTED, 859 858 .bw_nss_ratemask = WMI_VDEV_PARAM_UNSUPPORTED, 859 + .set_tsf = WMI_VDEV_PARAM_UNSUPPORTED, 860 860 }; 861 861 862 862 static struct wmi_vdev_param_map wmi_10_2_4_vdev_param_map = { ··· 932 930 .meru_vc = WMI_VDEV_PARAM_UNSUPPORTED, 933 931 .rx_decap_type = WMI_VDEV_PARAM_UNSUPPORTED, 934 932 .bw_nss_ratemask = WMI_VDEV_PARAM_UNSUPPORTED, 933 + .set_tsf = WMI_10X_VDEV_PARAM_TSF_INCREMENT, 935 934 }; 936 935 937 936 static struct wmi_vdev_param_map wmi_10_4_vdev_param_map = { ··· 1008 1005 .meru_vc = WMI_10_4_VDEV_PARAM_MERU_VC, 1009 1006 .rx_decap_type = WMI_10_4_VDEV_PARAM_RX_DECAP_TYPE, 1010 1007 .bw_nss_ratemask = WMI_10_4_VDEV_PARAM_BW_NSS_RATEMASK, 1008 + .set_tsf = WMI_10_4_VDEV_PARAM_TSF_INCREMENT, 1011 1009 }; 1012 1010 1013 1011 static struct wmi_pdev_param_map wmi_pdev_param_map = { ··· 1808 1804 ret = -ESHUTDOWN; 1809 1805 1810 1806 (ret != -EAGAIN); 1811 - }), 3*HZ); 1807 + }), 3 * HZ); 1812 1808 1813 1809 if (ret) 1814 1810 dev_kfree_skb_any(skb); ··· 2149 2145 u32 msdu_len; 2150 2146 u32 len; 2151 2147 2152 - if (test_bit(ATH10K_FW_FEATURE_EXT_WMI_MGMT_RX, ar->fw_features)) { 2148 + if (test_bit(ATH10K_FW_FEATURE_EXT_WMI_MGMT_RX, 2149 + ar->running_fw->fw_file.fw_features)) { 2153 2150 ev_v2 = (struct wmi_mgmt_rx_event_v2 *)skb->data; 2154 2151 ev_hdr = &ev_v2->hdr.v1; 2155 2152 pull_len = sizeof(*ev_v2); ··· 4605 4600 ath10k_dbg_dump(ar, ATH10K_DBG_WMI, NULL, "wmi svc: ", 4606 4601 arg.service_map, arg.service_map_len); 4607 4602 4608 - /* only manually set fw features when not using FW IE format */ 4609 - if (ar->fw_api == 1 && ar->fw_version_build > 636) 4610 - set_bit(ATH10K_FW_FEATURE_EXT_WMI_MGMT_RX, ar->fw_features); 4611 - 4612 4603 if (ar->num_rf_chains > ar->max_spatial_stream) { 4613 4604 ath10k_warn(ar, "hardware advertises support for more spatial streams than it should (%d > %d)\n", 4614 4605 ar->num_rf_chains, ar->max_spatial_stream); ··· 4635 4634 4636 4635 if (test_bit(WMI_SERVICE_PEER_CACHING, ar->wmi.svc_map)) { 4637 4636 if (test_bit(ATH10K_FW_FEATURE_PEER_FLOW_CONTROL, 4638 - ar->fw_features)) 4637 + ar->running_fw->fw_file.fw_features)) 4639 4638 ar->num_active_peers = TARGET_10_4_QCACHE_ACTIVE_PEERS_PFC + 4640 4639 ar->max_num_vdevs; 4641 4640 else ··· 5824 5823 bssids->num_bssid = __cpu_to_le32(arg->n_bssids); 5825 5824 5826 5825 for (i = 0; i < arg->n_bssids; i++) 5827 - memcpy(&bssids->bssid_list[i], 5828 - arg->bssids[i].bssid, 5829 - ETH_ALEN); 5826 + ether_addr_copy(bssids->bssid_list[i].addr, 5827 + arg->bssids[i].bssid); 5830 5828 5831 5829 ptr += sizeof(*bssids); 5832 5830 ptr += sizeof(struct wmi_mac_addr) * arg->n_bssids; ··· 7865 7865 7866 7866 int ath10k_wmi_attach(struct ath10k *ar) 7867 7867 { 7868 - switch (ar->wmi.op_version) { 7868 + switch (ar->running_fw->fw_file.wmi_op_version) { 7869 7869 case ATH10K_FW_WMI_OP_VERSION_10_4: 7870 7870 ar->wmi.ops = &wmi_10_4_ops; 7871 7871 ar->wmi.cmd = &wmi_10_4_cmd_map; ··· 7907 7907 case ATH10K_FW_WMI_OP_VERSION_UNSET: 7908 7908 case ATH10K_FW_WMI_OP_VERSION_MAX: 7909 7909 ath10k_err(ar, "unsupported WMI op version: %d\n", 7910 - ar->wmi.op_version); 7910 + ar->running_fw->fw_file.wmi_op_version); 7911 7911 return -EINVAL; 7912 7912 } 7913 7913
+38 -10
drivers/net/wireless/ath/ath10k/wmi.h
··· 180 180 WMI_SERVICE_MESH_NON_11S, 181 181 WMI_SERVICE_PEER_STATS, 182 182 WMI_SERVICE_RESTRT_CHNL_SUPPORT, 183 + WMI_SERVICE_TX_MODE_PUSH_ONLY, 184 + WMI_SERVICE_TX_MODE_PUSH_PULL, 185 + WMI_SERVICE_TX_MODE_DYNAMIC, 183 186 184 187 /* keep last */ 185 188 WMI_SERVICE_MAX, ··· 305 302 WMI_10_4_SERVICE_RESTRT_CHNL_SUPPORT, 306 303 WMI_10_4_SERVICE_PEER_STATS, 307 304 WMI_10_4_SERVICE_MESH_11S, 305 + WMI_10_4_SERVICE_TX_MODE_PUSH_ONLY, 306 + WMI_10_4_SERVICE_TX_MODE_PUSH_PULL, 307 + WMI_10_4_SERVICE_TX_MODE_DYNAMIC, 308 308 }; 309 309 310 310 static inline char *wmi_service_name(int service_id) ··· 402 396 SVCSTR(WMI_SERVICE_MESH_NON_11S); 403 397 SVCSTR(WMI_SERVICE_PEER_STATS); 404 398 SVCSTR(WMI_SERVICE_RESTRT_CHNL_SUPPORT); 399 + SVCSTR(WMI_SERVICE_TX_MODE_PUSH_ONLY); 400 + SVCSTR(WMI_SERVICE_TX_MODE_PUSH_PULL); 401 + SVCSTR(WMI_SERVICE_TX_MODE_DYNAMIC); 405 402 default: 406 403 return NULL; 407 404 } ··· 414 405 415 406 #define WMI_SERVICE_IS_ENABLED(wmi_svc_bmap, svc_id, len) \ 416 407 ((svc_id) < (len) && \ 417 - __le32_to_cpu((wmi_svc_bmap)[(svc_id)/(sizeof(u32))]) & \ 418 - BIT((svc_id)%(sizeof(u32)))) 408 + __le32_to_cpu((wmi_svc_bmap)[(svc_id) / (sizeof(u32))]) & \ 409 + BIT((svc_id) % (sizeof(u32)))) 419 410 420 411 #define SVCMAP(x, y, len) \ 421 412 do { \ ··· 652 643 WMI_SERVICE_PEER_STATS, len); 653 644 SVCMAP(WMI_10_4_SERVICE_MESH_11S, 654 645 WMI_SERVICE_MESH_11S, len); 646 + SVCMAP(WMI_10_4_SERVICE_TX_MODE_PUSH_ONLY, 647 + WMI_SERVICE_TX_MODE_PUSH_ONLY, len); 648 + SVCMAP(WMI_10_4_SERVICE_TX_MODE_PUSH_PULL, 649 + WMI_SERVICE_TX_MODE_PUSH_PULL, len); 650 + SVCMAP(WMI_10_4_SERVICE_TX_MODE_DYNAMIC, 651 + WMI_SERVICE_TX_MODE_DYNAMIC, len); 655 652 } 656 653 657 654 #undef SVCMAP ··· 1324 1309 WMI_10X_PDEV_TPC_CONFIG_EVENTID, 1325 1310 1326 1311 WMI_10X_GPIO_INPUT_EVENTID, 1327 - WMI_10X_PDEV_UTF_EVENTID = WMI_10X_END_EVENTID-1, 1312 + WMI_10X_PDEV_UTF_EVENTID = WMI_10X_END_EVENTID - 1, 1328 1313 }; 1329 1314 1330 1315 enum wmi_10_2_cmd_id { ··· 2057 2042 struct wlan_host_mem_req mem_reqs[0]; 2058 2043 } __packed; 2059 2044 2060 - #define WMI_SERVICE_READY_TIMEOUT_HZ (5*HZ) 2061 - #define WMI_UNIFIED_READY_TIMEOUT_HZ (5*HZ) 2045 + #define WMI_SERVICE_READY_TIMEOUT_HZ (5 * HZ) 2046 + #define WMI_UNIFIED_READY_TIMEOUT_HZ (5 * HZ) 2062 2047 2063 2048 struct wmi_ready_event { 2064 2049 __le32 sw_version; ··· 2676 2661 */ 2677 2662 __le32 iphdr_pad_config; 2678 2663 2679 - /* qwrap configuration 2664 + /* qwrap configuration (bits 15-0) 2680 2665 * 1 - This is qwrap configuration 2681 2666 * 0 - This is not qwrap 2667 + * 2668 + * Bits 31-16 is alloc_frag_desc_for_data_pkt (1 enables, 0 disables) 2669 + * In order to get ack-RSSI reporting and to specify the tx-rate for 2670 + * individual frames, this option must be enabled. This uses an extra 2671 + * 4 bytes per tx-msdu descriptor, so don't enable it unless you need it. 2682 2672 */ 2683 2673 __le32 qwrap_config; 2684 2674 } __packed; ··· 4404 4384 /* 4405 4385 * Indicates that AP VDEV uses hidden ssid. only valid for 4406 4386 * AP/GO */ 4407 - #define WMI_VDEV_START_HIDDEN_SSID (1<<0) 4387 + #define WMI_VDEV_START_HIDDEN_SSID (1 << 0) 4408 4388 /* 4409 4389 * Indicates if robust management frame/management frame 4410 4390 * protection is enabled. For GO/AP vdevs, it indicates that 4411 4391 * it may support station/client associations with RMF enabled. 4412 4392 * For STA/client vdevs, it indicates that sta will 4413 4393 * associate with AP with RMF enabled. */ 4414 - #define WMI_VDEV_START_PMF_ENABLED (1<<1) 4394 + #define WMI_VDEV_START_PMF_ENABLED (1 << 1) 4415 4395 4416 4396 struct wmi_p2p_noa_descriptor { 4417 4397 __le32 type_count; /* 255: continuous schedule, 0: reserved */ ··· 4650 4630 u32 meru_vc; 4651 4631 u32 rx_decap_type; 4652 4632 u32 bw_nss_ratemask; 4633 + u32 set_tsf; 4653 4634 }; 4654 4635 4655 4636 #define WMI_VDEV_PARAM_UNSUPPORTED 0 ··· 4907 4886 WMI_10X_VDEV_PARAM_RTS_FIXED_RATE, 4908 4887 WMI_10X_VDEV_PARAM_VHT_SGIMASK, 4909 4888 WMI_10X_VDEV_PARAM_VHT80_RATEMASK, 4889 + WMI_10X_VDEV_PARAM_TSF_INCREMENT, 4910 4890 }; 4911 4891 4912 4892 enum wmi_10_4_vdev_param { ··· 4977 4955 WMI_10_4_VDEV_PARAM_MERU_VC, 4978 4956 WMI_10_4_VDEV_PARAM_RX_DECAP_TYPE, 4979 4957 WMI_10_4_VDEV_PARAM_BW_NSS_RATEMASK, 4958 + WMI_10_4_VDEV_PARAM_SENSOR_AP, 4959 + WMI_10_4_VDEV_PARAM_BEACON_RATE, 4960 + WMI_10_4_VDEV_PARAM_DTIM_ENABLE_CTS, 4961 + WMI_10_4_VDEV_PARAM_STA_KICKOUT, 4962 + WMI_10_4_VDEV_PARAM_CAPABILITIES, 4963 + WMI_10_4_VDEV_PARAM_TSF_INCREMENT, 4980 4964 }; 4981 4965 4982 4966 #define WMI_VDEV_PARAM_TXBF_SU_TX_BFEE BIT(0) ··· 5357 5329 #define WMI_UAPSD_AC_TYPE_TRIG 1 5358 5330 5359 5331 #define WMI_UAPSD_AC_BIT_MASK(ac, type) \ 5360 - ((type == WMI_UAPSD_AC_TYPE_DELI) ? (1<<(ac<<1)) : (1<<((ac<<1)+1))) 5332 + ((type == WMI_UAPSD_AC_TYPE_DELI) ? (1 << (ac << 1)) : (1 << ((ac << 1) + 1))) 5361 5333 5362 5334 enum wmi_sta_ps_param_uapsd { 5363 5335 WMI_STA_PS_UAPSD_AC0_DELIVERY_EN = (1 << 0), ··· 5772 5744 * the rates are filled from least significant byte to most 5773 5745 * significant byte. 5774 5746 */ 5775 - __le32 rates[(MAX_SUPPORTED_RATES/4)+1]; 5747 + __le32 rates[(MAX_SUPPORTED_RATES / 4) + 1]; 5776 5748 } __packed; 5777 5749 5778 5750 struct wmi_rate_set_arg {
+4 -3
drivers/net/wireless/ath/ath10k/wow.c
··· 233 233 mutex_lock(&ar->conf_mutex); 234 234 235 235 if (WARN_ON(!test_bit(ATH10K_FW_FEATURE_WOWLAN_SUPPORT, 236 - ar->fw_features))) { 236 + ar->running_fw->fw_file.fw_features))) { 237 237 ret = 1; 238 238 goto exit; 239 239 } ··· 285 285 mutex_lock(&ar->conf_mutex); 286 286 287 287 if (WARN_ON(!test_bit(ATH10K_FW_FEATURE_WOWLAN_SUPPORT, 288 - ar->fw_features))) { 288 + ar->running_fw->fw_file.fw_features))) { 289 289 ret = 1; 290 290 goto exit; 291 291 } ··· 325 325 326 326 int ath10k_wow_init(struct ath10k *ar) 327 327 { 328 - if (!test_bit(ATH10K_FW_FEATURE_WOWLAN_SUPPORT, ar->fw_features)) 328 + if (!test_bit(ATH10K_FW_FEATURE_WOWLAN_SUPPORT, 329 + ar->running_fw->fw_file.fw_features)) 329 330 return 0; 330 331 331 332 if (WARN_ON(!test_bit(WMI_SERVICE_WOW, ar->wmi.svc_map)))
+2 -5
drivers/net/wireless/ath/ath9k/htc_drv_main.c
··· 246 246 struct ieee80211_conf *conf = &common->hw->conf; 247 247 bool fastcc; 248 248 struct ieee80211_channel *channel = hw->conf.chandef.chan; 249 - struct ath9k_hw_cal_data *caldata = NULL; 249 + struct ath9k_hw_cal_data *caldata; 250 250 enum htc_phymode mode; 251 251 __be16 htc_mode; 252 252 u8 cmd_rsp; ··· 274 274 priv->ah->curchan->channel, 275 275 channel->center_freq, conf_is_ht(conf), conf_is_ht40(conf), 276 276 fastcc); 277 - 278 - if (!fastcc) 279 - caldata = &priv->caldata; 280 - 277 + caldata = fastcc ? NULL : &priv->caldata; 281 278 ret = ath9k_hw_reset(ah, hchan, caldata, fastcc); 282 279 if (ret) { 283 280 ath_err(common,
+2 -8
drivers/net/wireless/ath/ath9k/hw.c
··· 2914 2914 { 2915 2915 struct ath_regulatory *reg = ath9k_hw_regulatory(ah); 2916 2916 struct ieee80211_channel *channel; 2917 - int chan_pwr, new_pwr, max_gain; 2918 - int ant_gain, ant_reduction = 0; 2917 + int chan_pwr, new_pwr; 2919 2918 2920 2919 if (!chan) 2921 2920 return; ··· 2922 2923 channel = chan->chan; 2923 2924 chan_pwr = min_t(int, channel->max_power * 2, MAX_RATE_POWER); 2924 2925 new_pwr = min_t(int, chan_pwr, reg->power_limit); 2925 - max_gain = chan_pwr - new_pwr + channel->max_antenna_gain * 2; 2926 - 2927 - ant_gain = get_antenna_gain(ah, chan); 2928 - if (ant_gain > max_gain) 2929 - ant_reduction = ant_gain - max_gain; 2930 2926 2931 2927 ah->eep_ops->set_txpower(ah, chan, 2932 2928 ath9k_regd_get_ctl(reg, chan), 2933 - ant_reduction, new_pwr, test); 2929 + get_antenna_gain(ah, chan), new_pwr, test); 2934 2930 } 2935 2931 2936 2932 void ath9k_hw_set_txpowerlimit(struct ath_hw *ah, u32 limit, bool test)
+8 -1
drivers/net/wireless/ath/ath9k/init.c
··· 49 49 module_param_named(blink, ath9k_led_blink, int, 0444); 50 50 MODULE_PARM_DESC(blink, "Enable LED blink on activity"); 51 51 52 + static int ath9k_led_active_high = -1; 53 + module_param_named(led_active_high, ath9k_led_active_high, int, 0444); 54 + MODULE_PARM_DESC(led_active_high, "Invert LED polarity"); 55 + 52 56 static int ath9k_btcoex_enable; 53 57 module_param_named(btcoex_enable, ath9k_btcoex_enable, int, 0444); 54 58 MODULE_PARM_DESC(btcoex_enable, "Enable wifi-BT coexistence"); ··· 481 477 static int ath9k_eeprom_request(struct ath_softc *sc, const char *name) 482 478 { 483 479 struct ath9k_eeprom_ctx ec; 484 - struct ath_hw *ah = ah = sc->sc_ah; 480 + struct ath_hw *ah = sc->sc_ah; 485 481 int err; 486 482 487 483 /* try to load the EEPROM content asynchronously */ ··· 603 599 ret = ath9k_init_soc_platform(sc); 604 600 if (ret) 605 601 return ret; 602 + 603 + if (ath9k_led_active_high != -1) 604 + ah->config.led_active_high = ath9k_led_active_high == 1; 606 605 607 606 /* 608 607 * Enable WLAN/BT RX Antenna diversity only when:
+10
drivers/net/wireless/ath/ath9k/pci.c
··· 28 28 { PCI_VDEVICE(ATHEROS, 0x0024) }, /* PCI-E */ 29 29 { PCI_VDEVICE(ATHEROS, 0x0027) }, /* PCI */ 30 30 { PCI_VDEVICE(ATHEROS, 0x0029) }, /* PCI */ 31 + 32 + #ifdef CONFIG_ATH9K_PCOEM 33 + /* Mini PCI AR9220 MB92 cards: Compex WLM200NX, Wistron DNMA-92 */ 34 + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, 35 + 0x0029, 36 + PCI_VENDOR_ID_ATHEROS, 37 + 0x2096), 38 + .driver_data = ATH9K_PCI_LED_ACT_HI }, 39 + #endif 40 + 31 41 { PCI_VDEVICE(ATHEROS, 0x002A) }, /* PCI-E */ 32 42 33 43 #ifdef CONFIG_ATH9K_PCOEM
+3 -9
drivers/net/wireless/ath/wcn36xx/debug.c
··· 33 33 char buf[3]; 34 34 35 35 list_for_each_entry(vif_priv, &wcn->vif_list, list) { 36 - vif = container_of((void *)vif_priv, 37 - struct ieee80211_vif, 38 - drv_priv); 36 + vif = wcn36xx_priv_to_vif(vif_priv); 39 37 if (NL80211_IFTYPE_STATION == vif->type) { 40 38 if (vif_priv->pw_state == WCN36XX_BMPS) 41 39 buf[0] = '1'; ··· 68 70 case 'Y': 69 71 case '1': 70 72 list_for_each_entry(vif_priv, &wcn->vif_list, list) { 71 - vif = container_of((void *)vif_priv, 72 - struct ieee80211_vif, 73 - drv_priv); 73 + vif = wcn36xx_priv_to_vif(vif_priv); 74 74 if (NL80211_IFTYPE_STATION == vif->type) { 75 75 wcn36xx_enable_keep_alive_null_packet(wcn, vif); 76 76 wcn36xx_pmc_enter_bmps_state(wcn, vif); ··· 79 83 case 'N': 80 84 case '0': 81 85 list_for_each_entry(vif_priv, &wcn->vif_list, list) { 82 - vif = container_of((void *)vif_priv, 83 - struct ieee80211_vif, 84 - drv_priv); 86 + vif = wcn36xx_priv_to_vif(vif_priv); 85 87 if (NL80211_IFTYPE_STATION == vif->type) 86 88 wcn36xx_pmc_exit_bmps_state(wcn, vif); 87 89 }
+50 -5
drivers/net/wireless/ath/wcn36xx/hal.h
··· 48 48 49 49 #define WCN36XX_HAL_IPV4_ADDR_LEN 4 50 50 51 - #define WALN_HAL_STA_INVALID_IDX 0xFF 51 + #define WCN36XX_HAL_STA_INVALID_IDX 0xFF 52 52 #define WCN36XX_HAL_BSS_INVALID_IDX 0xFF 53 53 54 54 /* Default Beacon template size */ 55 55 #define BEACON_TEMPLATE_SIZE 0x180 56 + 57 + /* Minimum PVM size that the FW expects. See comment in smd.c for details. */ 58 + #define TIM_MIN_PVM_SIZE 6 56 59 57 60 /* Param Change Bitmap sent to HAL */ 58 61 #define PARAM_BCN_INTERVAL_CHANGED (1 << 0) ··· 2887 2884 struct wcn36xx_hal_send_beacon_req_msg { 2888 2885 struct wcn36xx_hal_msg_header header; 2889 2886 2887 + /* length of the template + 6. Only qcom knows why */ 2888 + u32 beacon_length6; 2889 + 2890 2890 /* length of the template. */ 2891 2891 u32 beacon_length; 2892 2892 2893 2893 /* Beacon data. */ 2894 - u8 beacon[BEACON_TEMPLATE_SIZE]; 2894 + u8 beacon[BEACON_TEMPLATE_SIZE - sizeof(u32)]; 2895 2895 2896 2896 u8 bssid[ETH_ALEN]; 2897 2897 ··· 4267 4261 u8 data_offset; 4268 4262 4269 4263 u32 mc_addr_count; 4270 - u8 mc_addr[ETH_ALEN][WCN36XX_HAL_MAX_NUM_MULTICAST_ADDRESS]; 4264 + u8 mc_addr[WCN36XX_HAL_MAX_NUM_MULTICAST_ADDRESS][ETH_ALEN]; 4271 4265 u8 bss_index; 4272 - }; 4266 + } __packed; 4273 4267 4274 4268 struct wcn36xx_hal_set_pkt_filter_rsp_msg { 4275 4269 struct wcn36xx_hal_msg_header header; ··· 4323 4317 struct wcn36xx_hal_rcv_flt_pkt_set_mc_list_req_msg { 4324 4318 struct wcn36xx_hal_msg_header header; 4325 4319 struct wcn36xx_hal_rcv_flt_mc_addr_list_type mc_addr_list; 4326 - }; 4320 + } __packed; 4327 4321 4328 4322 struct wcn36xx_hal_rcv_flt_pkt_set_mc_list_rsp_msg { 4329 4323 struct wcn36xx_hal_msg_header header; ··· 4389 4383 RTT = 20, 4390 4384 RATECTRL = 21, 4391 4385 WOW = 22, 4386 + WLAN_ROAM_SCAN_OFFLOAD = 23, 4387 + SPECULATIVE_PS_POLL = 24, 4388 + SCAN_SCH = 25, 4389 + IBSS_HEARTBEAT_OFFLOAD = 26, 4390 + WLAN_SCAN_OFFLOAD = 27, 4391 + WLAN_PERIODIC_TX_PTRN = 28, 4392 + ADVANCE_TDLS = 29, 4393 + BATCH_SCAN = 30, 4394 + FW_IN_TX_PATH = 31, 4395 + EXTENDED_NSOFFLOAD_SLOT = 32, 4396 + CH_SWITCH_V1 = 33, 4397 + HT40_OBSS_SCAN = 34, 4398 + UPDATE_CHANNEL_LIST = 35, 4399 + WLAN_MCADDR_FLT = 36, 4400 + WLAN_CH144 = 37, 4401 + NAN = 38, 4402 + TDLS_SCAN_COEXISTENCE = 39, 4403 + LINK_LAYER_STATS_MEAS = 40, 4404 + MU_MIMO = 41, 4405 + EXTENDED_SCAN = 42, 4406 + DYNAMIC_WMM_PS = 43, 4407 + MAC_SPOOFED_SCAN = 44, 4408 + BMU_ERROR_GENERIC_RECOVERY = 45, 4409 + DISA = 46, 4410 + FW_STATS = 47, 4411 + WPS_PRBRSP_TMPL = 48, 4412 + BCN_IE_FLT_DELTA = 49, 4413 + TDLS_OFF_CHANNEL = 51, 4414 + RTT3 = 52, 4415 + MGMT_FRAME_LOGGING = 53, 4416 + ENHANCED_TXBD_COMPLETION = 54, 4417 + LOGGING_ENHANCEMENT = 55, 4418 + EXT_SCAN_ENHANCED = 56, 4419 + MEMORY_DUMP_SUPPORTED = 57, 4420 + PER_PKT_STATS_SUPPORTED = 58, 4421 + EXT_LL_STAT = 60, 4422 + WIFI_CONFIG = 61, 4423 + ANTENNA_DIVERSITY_SELECTION = 62, 4424 + 4392 4425 MAX_FEATURE_SUPPORTED = 128, 4393 4426 }; 4394 4427
+106 -27
drivers/net/wireless/ath/wcn36xx/main.c
··· 201 201 "BCN_FILTER", /* 19 */ 202 202 "RTT", /* 20 */ 203 203 "RATECTRL", /* 21 */ 204 - "WOW" /* 22 */ 204 + "WOW", /* 22 */ 205 + "WLAN_ROAM_SCAN_OFFLOAD", /* 23 */ 206 + "SPECULATIVE_PS_POLL", /* 24 */ 207 + "SCAN_SCH", /* 25 */ 208 + "IBSS_HEARTBEAT_OFFLOAD", /* 26 */ 209 + "WLAN_SCAN_OFFLOAD", /* 27 */ 210 + "WLAN_PERIODIC_TX_PTRN", /* 28 */ 211 + "ADVANCE_TDLS", /* 29 */ 212 + "BATCH_SCAN", /* 30 */ 213 + "FW_IN_TX_PATH", /* 31 */ 214 + "EXTENDED_NSOFFLOAD_SLOT", /* 32 */ 215 + "CH_SWITCH_V1", /* 33 */ 216 + "HT40_OBSS_SCAN", /* 34 */ 217 + "UPDATE_CHANNEL_LIST", /* 35 */ 218 + "WLAN_MCADDR_FLT", /* 36 */ 219 + "WLAN_CH144", /* 37 */ 220 + "NAN", /* 38 */ 221 + "TDLS_SCAN_COEXISTENCE", /* 39 */ 222 + "LINK_LAYER_STATS_MEAS", /* 40 */ 223 + "MU_MIMO", /* 41 */ 224 + "EXTENDED_SCAN", /* 42 */ 225 + "DYNAMIC_WMM_PS", /* 43 */ 226 + "MAC_SPOOFED_SCAN", /* 44 */ 227 + "BMU_ERROR_GENERIC_RECOVERY", /* 45 */ 228 + "DISA", /* 46 */ 229 + "FW_STATS", /* 47 */ 230 + "WPS_PRBRSP_TMPL", /* 48 */ 231 + "BCN_IE_FLT_DELTA", /* 49 */ 232 + "TDLS_OFF_CHANNEL", /* 51 */ 233 + "RTT3", /* 52 */ 234 + "MGMT_FRAME_LOGGING", /* 53 */ 235 + "ENHANCED_TXBD_COMPLETION", /* 54 */ 236 + "LOGGING_ENHANCEMENT", /* 55 */ 237 + "EXT_SCAN_ENHANCED", /* 56 */ 238 + "MEMORY_DUMP_SUPPORTED", /* 57 */ 239 + "PER_PKT_STATS_SUPPORTED", /* 58 */ 240 + "EXT_LL_STAT", /* 60 */ 241 + "WIFI_CONFIG", /* 61 */ 242 + "ANTENNA_DIVERSITY_SELECTION", /* 62 */ 205 243 }; 206 244 207 245 static const char *wcn36xx_get_cap_name(enum place_holder_in_cap_bitmap x) ··· 325 287 } 326 288 327 289 wcn36xx_detect_chip_version(wcn); 290 + wcn36xx_smd_update_cfg(wcn, WCN36XX_HAL_CFG_ENABLE_MC_ADDR_LIST, 1); 328 291 329 292 /* DMA channel initialization */ 330 293 ret = wcn36xx_dxe_init(wcn); ··· 385 346 wcn36xx_dbg(WCN36XX_DBG_MAC, "wcn36xx_config channel switch=%d\n", 386 347 ch); 387 348 list_for_each_entry(tmp, &wcn->vif_list, list) { 388 - vif = container_of((void *)tmp, 389 - struct ieee80211_vif, 390 - drv_priv); 349 + vif = wcn36xx_priv_to_vif(tmp); 391 350 wcn36xx_smd_switch_channel(wcn, vif, ch); 392 351 } 393 352 } ··· 393 356 return 0; 394 357 } 395 358 396 - #define WCN36XX_SUPPORTED_FILTERS (0) 397 - 398 359 static void wcn36xx_configure_filter(struct ieee80211_hw *hw, 399 360 unsigned int changed, 400 361 unsigned int *total, u64 multicast) 401 362 { 363 + struct wcn36xx_hal_rcv_flt_mc_addr_list_type *fp; 364 + struct wcn36xx *wcn = hw->priv; 365 + struct wcn36xx_vif *tmp; 366 + struct ieee80211_vif *vif = NULL; 367 + 402 368 wcn36xx_dbg(WCN36XX_DBG_MAC, "mac configure filter\n"); 403 369 404 - *total &= WCN36XX_SUPPORTED_FILTERS; 370 + *total &= FIF_ALLMULTI; 371 + 372 + fp = (void *)(unsigned long)multicast; 373 + list_for_each_entry(tmp, &wcn->vif_list, list) { 374 + vif = wcn36xx_priv_to_vif(tmp); 375 + 376 + /* FW handles MC filtering only when connected as STA */ 377 + if (*total & FIF_ALLMULTI) 378 + wcn36xx_smd_set_mc_list(wcn, vif, NULL); 379 + else if (NL80211_IFTYPE_STATION == vif->type && tmp->sta_assoc) 380 + wcn36xx_smd_set_mc_list(wcn, vif, fp); 381 + } 382 + kfree(fp); 383 + } 384 + 385 + static u64 wcn36xx_prepare_multicast(struct ieee80211_hw *hw, 386 + struct netdev_hw_addr_list *mc_list) 387 + { 388 + struct wcn36xx_hal_rcv_flt_mc_addr_list_type *fp; 389 + struct netdev_hw_addr *ha; 390 + 391 + wcn36xx_dbg(WCN36XX_DBG_MAC, "mac prepare multicast list\n"); 392 + fp = kzalloc(sizeof(*fp), GFP_ATOMIC); 393 + if (!fp) { 394 + wcn36xx_err("Out of memory setting filters.\n"); 395 + return 0; 396 + } 397 + 398 + fp->mc_addr_count = 0; 399 + /* update multicast filtering parameters */ 400 + if (netdev_hw_addr_list_count(mc_list) <= 401 + WCN36XX_HAL_MAX_NUM_MULTICAST_ADDRESS) { 402 + netdev_hw_addr_list_for_each(ha, mc_list) { 403 + memcpy(fp->mc_addr[fp->mc_addr_count], 404 + ha->addr, ETH_ALEN); 405 + fp->mc_addr_count++; 406 + } 407 + } 408 + 409 + return (u64)(unsigned long)fp; 405 410 } 406 411 407 412 static void wcn36xx_tx(struct ieee80211_hw *hw, ··· 454 375 struct wcn36xx_sta *sta_priv = NULL; 455 376 456 377 if (control->sta) 457 - sta_priv = (struct wcn36xx_sta *)control->sta->drv_priv; 378 + sta_priv = wcn36xx_sta_to_priv(control->sta); 458 379 459 380 if (wcn36xx_start_tx(wcn, sta_priv, skb)) 460 381 ieee80211_free_txskb(wcn->hw, skb); ··· 466 387 struct ieee80211_key_conf *key_conf) 467 388 { 468 389 struct wcn36xx *wcn = hw->priv; 469 - struct wcn36xx_vif *vif_priv = (struct wcn36xx_vif *)vif->drv_priv; 470 - struct wcn36xx_sta *sta_priv = vif_priv->sta; 390 + struct wcn36xx_vif *vif_priv = wcn36xx_vif_to_priv(vif); 391 + struct wcn36xx_sta *sta_priv = wcn36xx_sta_to_priv(sta); 471 392 int ret = 0; 472 393 u8 key[WLAN_MAX_KEY_LEN]; 473 394 ··· 552 473 break; 553 474 case DISABLE_KEY: 554 475 if (!(IEEE80211_KEY_FLAG_PAIRWISE & key_conf->flags)) { 476 + vif_priv->encrypt_type = WCN36XX_HAL_ED_NONE; 555 477 wcn36xx_smd_remove_bsskey(wcn, 556 478 vif_priv->encrypt_type, 557 479 key_conf->keyidx); ··· 600 520 { 601 521 int i, size; 602 522 u16 *rates_table; 603 - struct wcn36xx_sta *sta_priv = (struct wcn36xx_sta *)sta->drv_priv; 523 + struct wcn36xx_sta *sta_priv = wcn36xx_sta_to_priv(sta); 604 524 u32 rates = sta->supp_rates[band]; 605 525 606 526 memset(&sta_priv->supported_rates, 0, ··· 670 590 struct sk_buff *skb = NULL; 671 591 u16 tim_off, tim_len; 672 592 enum wcn36xx_hal_link_state link_state; 673 - struct wcn36xx_vif *vif_priv = (struct wcn36xx_vif *)vif->drv_priv; 593 + struct wcn36xx_vif *vif_priv = wcn36xx_vif_to_priv(vif); 674 594 675 595 wcn36xx_dbg(WCN36XX_DBG_MAC, "mac bss info changed vif %p changed 0x%08x\n", 676 596 vif, changed); ··· 700 620 701 621 if (!is_zero_ether_addr(bss_conf->bssid)) { 702 622 vif_priv->is_joining = true; 703 - vif_priv->bss_index = 0xff; 623 + vif_priv->bss_index = WCN36XX_HAL_BSS_INVALID_IDX; 704 624 wcn36xx_smd_join(wcn, bss_conf->bssid, 705 625 vif->addr, WCN36XX_HW_CHANNEL(wcn)); 706 626 wcn36xx_smd_config_bss(wcn, vif, NULL, ··· 708 628 } else { 709 629 vif_priv->is_joining = false; 710 630 wcn36xx_smd_delete_bss(wcn, vif); 631 + vif_priv->encrypt_type = WCN36XX_HAL_ED_NONE; 711 632 } 712 633 } 713 634 ··· 736 655 vif->addr, 737 656 bss_conf->aid); 738 657 658 + vif_priv->sta_assoc = true; 739 659 rcu_read_lock(); 740 660 sta = ieee80211_find_sta(vif, bss_conf->bssid); 741 661 if (!sta) { ··· 745 663 rcu_read_unlock(); 746 664 goto out; 747 665 } 748 - sta_priv = (struct wcn36xx_sta *)sta->drv_priv; 666 + sta_priv = wcn36xx_sta_to_priv(sta); 749 667 750 668 wcn36xx_update_allowed_rates(sta, WCN36XX_BAND(wcn)); 751 669 ··· 768 686 bss_conf->bssid, 769 687 vif->addr, 770 688 bss_conf->aid); 689 + vif_priv->sta_assoc = false; 771 690 wcn36xx_smd_set_link_st(wcn, 772 691 bss_conf->bssid, 773 692 vif->addr, ··· 796 713 797 714 if (bss_conf->enable_beacon) { 798 715 vif_priv->dtim_period = bss_conf->dtim_period; 799 - vif_priv->bss_index = 0xff; 716 + vif_priv->bss_index = WCN36XX_HAL_BSS_INVALID_IDX; 800 717 wcn36xx_smd_config_bss(wcn, vif, NULL, 801 718 vif->addr, false); 802 719 skb = ieee80211_beacon_get_tim(hw, vif, &tim_off, ··· 817 734 wcn36xx_smd_set_link_st(wcn, vif->addr, vif->addr, 818 735 link_state); 819 736 } else { 737 + wcn36xx_smd_delete_bss(wcn, vif); 820 738 wcn36xx_smd_set_link_st(wcn, vif->addr, vif->addr, 821 739 WCN36XX_HAL_LINK_IDLE_STATE); 822 - wcn36xx_smd_delete_bss(wcn, vif); 823 740 } 824 741 } 825 742 out: ··· 840 757 struct ieee80211_vif *vif) 841 758 { 842 759 struct wcn36xx *wcn = hw->priv; 843 - struct wcn36xx_vif *vif_priv = (struct wcn36xx_vif *)vif->drv_priv; 760 + struct wcn36xx_vif *vif_priv = wcn36xx_vif_to_priv(vif); 844 761 wcn36xx_dbg(WCN36XX_DBG_MAC, "mac remove interface vif %p\n", vif); 845 762 846 763 list_del(&vif_priv->list); ··· 851 768 struct ieee80211_vif *vif) 852 769 { 853 770 struct wcn36xx *wcn = hw->priv; 854 - struct wcn36xx_vif *vif_priv = (struct wcn36xx_vif *)vif->drv_priv; 771 + struct wcn36xx_vif *vif_priv = wcn36xx_vif_to_priv(vif); 855 772 856 773 wcn36xx_dbg(WCN36XX_DBG_MAC, "mac add interface vif %p type %d\n", 857 774 vif, vif->type); ··· 875 792 struct ieee80211_sta *sta) 876 793 { 877 794 struct wcn36xx *wcn = hw->priv; 878 - struct wcn36xx_vif *vif_priv = (struct wcn36xx_vif *)vif->drv_priv; 879 - struct wcn36xx_sta *sta_priv = (struct wcn36xx_sta *)sta->drv_priv; 795 + struct wcn36xx_vif *vif_priv = wcn36xx_vif_to_priv(vif); 796 + struct wcn36xx_sta *sta_priv = wcn36xx_sta_to_priv(sta); 880 797 wcn36xx_dbg(WCN36XX_DBG_MAC, "mac sta add vif %p sta %pM\n", 881 798 vif, sta->addr); 882 799 883 800 spin_lock_init(&sta_priv->ampdu_lock); 884 - vif_priv->sta = sta_priv; 885 801 sta_priv->vif = vif_priv; 886 802 /* 887 803 * For STA mode HW will be configured on BSS_CHANGED_ASSOC because ··· 899 817 struct ieee80211_sta *sta) 900 818 { 901 819 struct wcn36xx *wcn = hw->priv; 902 - struct wcn36xx_vif *vif_priv = (struct wcn36xx_vif *)vif->drv_priv; 903 - struct wcn36xx_sta *sta_priv = (struct wcn36xx_sta *)sta->drv_priv; 820 + struct wcn36xx_sta *sta_priv = wcn36xx_sta_to_priv(sta); 904 821 905 822 wcn36xx_dbg(WCN36XX_DBG_MAC, "mac sta remove vif %p sta %pM index %d\n", 906 823 vif, sta->addr, sta_priv->sta_index); 907 824 908 825 wcn36xx_smd_delete_sta(wcn, sta_priv->sta_index); 909 - vif_priv->sta = NULL; 910 826 sta_priv->vif = NULL; 911 827 return 0; 912 828 } ··· 940 860 struct ieee80211_ampdu_params *params) 941 861 { 942 862 struct wcn36xx *wcn = hw->priv; 943 - struct wcn36xx_sta *sta_priv = NULL; 863 + struct wcn36xx_sta *sta_priv = wcn36xx_sta_to_priv(params->sta); 944 864 struct ieee80211_sta *sta = params->sta; 945 865 enum ieee80211_ampdu_mlme_action action = params->action; 946 866 u16 tid = params->tid; ··· 948 868 949 869 wcn36xx_dbg(WCN36XX_DBG_MAC, "mac ampdu action action %d tid %d\n", 950 870 action, tid); 951 - 952 - sta_priv = (struct wcn36xx_sta *)sta->drv_priv; 953 871 954 872 switch (action) { 955 873 case IEEE80211_AMPDU_RX_START: ··· 1001 923 .resume = wcn36xx_resume, 1002 924 #endif 1003 925 .config = wcn36xx_config, 926 + .prepare_multicast = wcn36xx_prepare_multicast, 1004 927 .configure_filter = wcn36xx_configure_filter, 1005 928 .tx = wcn36xx_tx, 1006 929 .set_key = wcn36xx_set_key,
+2 -2
drivers/net/wireless/ath/wcn36xx/pmc.c
··· 22 22 struct ieee80211_vif *vif) 23 23 { 24 24 int ret = 0; 25 - struct wcn36xx_vif *vif_priv = (struct wcn36xx_vif *)vif->drv_priv; 25 + struct wcn36xx_vif *vif_priv = wcn36xx_vif_to_priv(vif); 26 26 /* TODO: Make sure the TX chain clean */ 27 27 ret = wcn36xx_smd_enter_bmps(wcn, vif); 28 28 if (!ret) { ··· 42 42 int wcn36xx_pmc_exit_bmps_state(struct wcn36xx *wcn, 43 43 struct ieee80211_vif *vif) 44 44 { 45 - struct wcn36xx_vif *vif_priv = (struct wcn36xx_vif *)vif->drv_priv; 45 + struct wcn36xx_vif *vif_priv = wcn36xx_vif_to_priv(vif); 46 46 47 47 if (WCN36XX_BMPS != vif_priv->pw_state) { 48 48 wcn36xx_err("Not in BMPS mode, no need to exit from BMPS mode!\n");
+151 -73
drivers/net/wireless/ath/wcn36xx/smd.c
··· 191 191 struct ieee80211_sta *sta, 192 192 struct wcn36xx_hal_config_sta_params *sta_params) 193 193 { 194 - struct wcn36xx_vif *priv_vif = (struct wcn36xx_vif *)vif->drv_priv; 195 - struct wcn36xx_sta *priv_sta = NULL; 194 + struct wcn36xx_vif *vif_priv = wcn36xx_vif_to_priv(vif); 195 + struct wcn36xx_sta *sta_priv = NULL; 196 196 if (vif->type == NL80211_IFTYPE_ADHOC || 197 197 vif->type == NL80211_IFTYPE_AP || 198 198 vif->type == NL80211_IFTYPE_MESH_POINT) { 199 199 sta_params->type = 1; 200 - sta_params->sta_index = 0xFF; 200 + sta_params->sta_index = WCN36XX_HAL_STA_INVALID_IDX; 201 201 } else { 202 202 sta_params->type = 0; 203 - sta_params->sta_index = 1; 203 + sta_params->sta_index = vif_priv->self_sta_index; 204 204 } 205 205 206 206 sta_params->listen_interval = WCN36XX_LISTEN_INTERVAL(wcn); ··· 215 215 else 216 216 memcpy(&sta_params->bssid, vif->addr, ETH_ALEN); 217 217 218 - sta_params->encrypt_type = priv_vif->encrypt_type; 218 + sta_params->encrypt_type = vif_priv->encrypt_type; 219 219 sta_params->short_preamble_supported = true; 220 220 221 221 sta_params->rifs_mode = 0; ··· 224 224 sta_params->uapsd = 0; 225 225 sta_params->mimo_ps = WCN36XX_HAL_HT_MIMO_PS_STATIC; 226 226 sta_params->max_ampdu_duration = 0; 227 - sta_params->bssid_index = priv_vif->bss_index; 227 + sta_params->bssid_index = vif_priv->bss_index; 228 228 sta_params->p2p = 0; 229 229 230 230 if (sta) { 231 - priv_sta = (struct wcn36xx_sta *)sta->drv_priv; 231 + sta_priv = wcn36xx_sta_to_priv(sta); 232 232 if (NL80211_IFTYPE_STATION == vif->type) 233 233 memcpy(&sta_params->bssid, sta->addr, ETH_ALEN); 234 234 else 235 235 memcpy(&sta_params->mac, sta->addr, ETH_ALEN); 236 236 sta_params->wmm_enabled = sta->wme; 237 237 sta_params->max_sp_len = sta->max_sp; 238 - sta_params->aid = priv_sta->aid; 238 + sta_params->aid = sta_priv->aid; 239 239 wcn36xx_smd_set_sta_ht_params(sta, sta_params); 240 - memcpy(&sta_params->supported_rates, &priv_sta->supported_rates, 241 - sizeof(priv_sta->supported_rates)); 240 + memcpy(&sta_params->supported_rates, &sta_priv->supported_rates, 241 + sizeof(sta_priv->supported_rates)); 242 242 } else { 243 243 wcn36xx_set_default_rates(&sta_params->supported_rates); 244 244 wcn36xx_smd_set_sta_default_ht_params(sta_params); ··· 271 271 return ret; 272 272 } 273 273 274 + static void init_hal_msg(struct wcn36xx_hal_msg_header *hdr, 275 + enum wcn36xx_hal_host_msg_type msg_type, 276 + size_t msg_size) 277 + { 278 + memset(hdr, 0, msg_size + sizeof(*hdr)); 279 + hdr->msg_type = msg_type; 280 + hdr->msg_version = WCN36XX_HAL_MSG_VERSION0; 281 + hdr->len = msg_size + sizeof(*hdr); 282 + } 283 + 274 284 #define INIT_HAL_MSG(msg_body, type) \ 275 285 do { \ 276 286 memset(&msg_body, 0, sizeof(msg_body)); \ ··· 305 295 306 296 rsp = (struct wcn36xx_fw_msg_status_rsp *) 307 297 (buf + sizeof(struct wcn36xx_hal_msg_header)); 308 - 309 - if (WCN36XX_FW_MSG_RESULT_SUCCESS != rsp->status) 310 - return rsp->status; 311 - 312 - return 0; 313 - } 314 - 315 - static int wcn36xx_smd_rsp_status_check_v2(struct wcn36xx *wcn, void *buf, 316 - size_t len) 317 - { 318 - struct wcn36xx_fw_msg_status_rsp_v2 *rsp; 319 - 320 - if (len < sizeof(struct wcn36xx_hal_msg_header) + sizeof(*rsp)) 321 - return wcn36xx_smd_rsp_status_check(buf, len); 322 - 323 - rsp = buf + sizeof(struct wcn36xx_hal_msg_header); 324 298 325 299 if (WCN36XX_FW_MSG_RESULT_SUCCESS != rsp->status) 326 300 return rsp->status; ··· 720 726 size_t len) 721 727 { 722 728 struct wcn36xx_hal_add_sta_self_rsp_msg *rsp; 723 - struct wcn36xx_vif *priv_vif = (struct wcn36xx_vif *)vif->drv_priv; 729 + struct wcn36xx_vif *vif_priv = wcn36xx_vif_to_priv(vif); 724 730 725 731 if (len < sizeof(*rsp)) 726 732 return -EINVAL; ··· 737 743 "hal add sta self status %d self_sta_index %d dpu_index %d\n", 738 744 rsp->status, rsp->self_sta_index, rsp->dpu_index); 739 745 740 - priv_vif->self_sta_index = rsp->self_sta_index; 741 - priv_vif->self_dpu_desc_index = rsp->dpu_index; 746 + vif_priv->self_sta_index = rsp->self_sta_index; 747 + vif_priv->self_dpu_desc_index = rsp->dpu_index; 742 748 743 749 return 0; 744 750 } ··· 943 949 memcpy(&v1->mac, orig->mac, ETH_ALEN); 944 950 v1->aid = orig->aid; 945 951 v1->type = orig->type; 952 + v1->short_preamble_supported = orig->short_preamble_supported; 946 953 v1->listen_interval = orig->listen_interval; 954 + v1->wmm_enabled = orig->wmm_enabled; 947 955 v1->ht_capable = orig->ht_capable; 948 - 956 + v1->tx_channel_width_set = orig->tx_channel_width_set; 957 + v1->rifs_mode = orig->rifs_mode; 958 + v1->lsig_txop_protection = orig->lsig_txop_protection; 949 959 v1->max_ampdu_size = orig->max_ampdu_size; 950 960 v1->max_ampdu_density = orig->max_ampdu_density; 951 961 v1->sgi_40mhz = orig->sgi_40mhz; 952 962 v1->sgi_20Mhz = orig->sgi_20Mhz; 953 - 963 + v1->rmf = orig->rmf; 964 + v1->encrypt_type = orig->encrypt_type; 965 + v1->action = orig->action; 966 + v1->uapsd = orig->uapsd; 967 + v1->max_sp_len = orig->max_sp_len; 968 + v1->green_field_capable = orig->green_field_capable; 969 + v1->mimo_ps = orig->mimo_ps; 970 + v1->delayed_ba_support = orig->delayed_ba_support; 971 + v1->max_ampdu_duration = orig->max_ampdu_duration; 972 + v1->dsss_cck_mode_40mhz = orig->dsss_cck_mode_40mhz; 954 973 memcpy(&v1->supported_rates, &orig->supported_rates, 955 974 sizeof(orig->supported_rates)); 956 975 v1->sta_index = orig->sta_index; 976 + v1->bssid_index = orig->bssid_index; 977 + v1->p2p = orig->p2p; 957 978 } 958 979 959 980 static int wcn36xx_smd_config_sta_rsp(struct wcn36xx *wcn, ··· 978 969 { 979 970 struct wcn36xx_hal_config_sta_rsp_msg *rsp; 980 971 struct config_sta_rsp_params *params; 981 - struct wcn36xx_sta *sta_priv = (struct wcn36xx_sta *)sta->drv_priv; 972 + struct wcn36xx_sta *sta_priv = wcn36xx_sta_to_priv(sta); 982 973 983 974 if (len < sizeof(*rsp)) 984 975 return -EINVAL; ··· 1179 1170 1180 1171 static int wcn36xx_smd_config_bss_rsp(struct wcn36xx *wcn, 1181 1172 struct ieee80211_vif *vif, 1173 + struct ieee80211_sta *sta, 1182 1174 void *buf, 1183 1175 size_t len) 1184 1176 { 1185 1177 struct wcn36xx_hal_config_bss_rsp_msg *rsp; 1186 1178 struct wcn36xx_hal_config_bss_rsp_params *params; 1187 - struct wcn36xx_vif *priv_vif = (struct wcn36xx_vif *)vif->drv_priv; 1179 + struct wcn36xx_vif *vif_priv = wcn36xx_vif_to_priv(vif); 1188 1180 1189 1181 if (len < sizeof(*rsp)) 1190 1182 return -EINVAL; ··· 1208 1198 params->bss_bcast_sta_idx, params->mac, 1209 1199 params->tx_mgmt_power, params->ucast_dpu_signature); 1210 1200 1211 - priv_vif->bss_index = params->bss_index; 1201 + vif_priv->bss_index = params->bss_index; 1212 1202 1213 - if (priv_vif->sta) { 1214 - priv_vif->sta->bss_sta_index = params->bss_sta_index; 1215 - priv_vif->sta->bss_dpu_desc_index = params->dpu_desc_index; 1203 + if (sta) { 1204 + struct wcn36xx_sta *sta_priv = wcn36xx_sta_to_priv(sta); 1205 + sta_priv->bss_sta_index = params->bss_sta_index; 1206 + sta_priv->bss_dpu_desc_index = params->dpu_desc_index; 1216 1207 } 1217 1208 1218 - priv_vif->self_ucast_dpu_sign = params->ucast_dpu_signature; 1209 + vif_priv->self_ucast_dpu_sign = params->ucast_dpu_signature; 1219 1210 1220 1211 return 0; 1221 1212 } ··· 1228 1217 struct wcn36xx_hal_config_bss_req_msg msg; 1229 1218 struct wcn36xx_hal_config_bss_params *bss; 1230 1219 struct wcn36xx_hal_config_sta_params *sta_params; 1231 - struct wcn36xx_vif *vif_priv = (struct wcn36xx_vif *)vif->drv_priv; 1220 + struct wcn36xx_vif *vif_priv = wcn36xx_vif_to_priv(vif); 1232 1221 int ret = 0; 1233 1222 1234 1223 mutex_lock(&wcn->hal_mutex); ··· 1340 1329 } 1341 1330 ret = wcn36xx_smd_config_bss_rsp(wcn, 1342 1331 vif, 1332 + sta, 1343 1333 wcn->hal_buf, 1344 1334 wcn->hal_rsp_len); 1345 1335 if (ret) { ··· 1355 1343 int wcn36xx_smd_delete_bss(struct wcn36xx *wcn, struct ieee80211_vif *vif) 1356 1344 { 1357 1345 struct wcn36xx_hal_delete_bss_req_msg msg_body; 1358 - struct wcn36xx_vif *priv_vif = (struct wcn36xx_vif *)vif->drv_priv; 1346 + struct wcn36xx_vif *vif_priv = wcn36xx_vif_to_priv(vif); 1359 1347 int ret = 0; 1360 1348 1361 1349 mutex_lock(&wcn->hal_mutex); 1362 1350 INIT_HAL_MSG(msg_body, WCN36XX_HAL_DELETE_BSS_REQ); 1363 1351 1364 - msg_body.bss_index = priv_vif->bss_index; 1352 + msg_body.bss_index = vif_priv->bss_index; 1365 1353 1366 1354 PREPARE_HAL_BUF(wcn->hal_buf, msg_body); 1367 1355 ··· 1387 1375 u16 p2p_off) 1388 1376 { 1389 1377 struct wcn36xx_hal_send_beacon_req_msg msg_body; 1390 - int ret = 0; 1378 + int ret = 0, pad, pvm_len; 1391 1379 1392 1380 mutex_lock(&wcn->hal_mutex); 1393 1381 INIT_HAL_MSG(msg_body, WCN36XX_HAL_SEND_BEACON_REQ); 1394 1382 1395 - /* TODO need to find out why this is needed? */ 1396 - msg_body.beacon_length = skb_beacon->len + 6; 1383 + pvm_len = skb_beacon->data[tim_off + 1] - 3; 1384 + pad = TIM_MIN_PVM_SIZE - pvm_len; 1397 1385 1398 - if (BEACON_TEMPLATE_SIZE > msg_body.beacon_length) { 1399 - memcpy(&msg_body.beacon, &skb_beacon->len, sizeof(u32)); 1400 - memcpy(&(msg_body.beacon[4]), skb_beacon->data, 1401 - skb_beacon->len); 1402 - } else { 1386 + /* Padding is irrelevant to mesh mode since tim_off is always 0. */ 1387 + if (vif->type == NL80211_IFTYPE_MESH_POINT) 1388 + pad = 0; 1389 + 1390 + msg_body.beacon_length = skb_beacon->len + pad; 1391 + /* TODO need to find out why + 6 is needed */ 1392 + msg_body.beacon_length6 = msg_body.beacon_length + 6; 1393 + 1394 + if (msg_body.beacon_length > BEACON_TEMPLATE_SIZE) { 1403 1395 wcn36xx_err("Beacon is to big: beacon size=%d\n", 1404 1396 msg_body.beacon_length); 1405 1397 ret = -ENOMEM; 1406 1398 goto out; 1407 1399 } 1400 + memcpy(msg_body.beacon, skb_beacon->data, skb_beacon->len); 1408 1401 memcpy(msg_body.bssid, vif->addr, ETH_ALEN); 1402 + 1403 + if (pad > 0) { 1404 + /* 1405 + * The wcn36xx FW has a fixed size for the PVM in the TIM. If 1406 + * given the beacon template from mac80211 with a PVM shorter 1407 + * than the FW expectes it will overwrite the data after the 1408 + * TIM. 1409 + */ 1410 + wcn36xx_dbg(WCN36XX_DBG_HAL, "Pad TIM PVM. %d bytes at %d\n", 1411 + pad, pvm_len); 1412 + memmove(&msg_body.beacon[tim_off + 5 + pvm_len + pad], 1413 + &msg_body.beacon[tim_off + 5 + pvm_len], 1414 + skb_beacon->len - (tim_off + 5 + pvm_len)); 1415 + memset(&msg_body.beacon[tim_off + 5 + pvm_len], 0, pad); 1416 + msg_body.beacon[tim_off + 1] += pad; 1417 + } 1409 1418 1410 1419 /* TODO need to find out why this is needed? */ 1411 1420 if (vif->type == NL80211_IFTYPE_MESH_POINT) ··· 1631 1598 wcn36xx_err("Sending hal_remove_bsskey failed\n"); 1632 1599 goto out; 1633 1600 } 1634 - ret = wcn36xx_smd_rsp_status_check_v2(wcn, wcn->hal_buf, 1635 - wcn->hal_rsp_len); 1601 + ret = wcn36xx_smd_rsp_status_check(wcn->hal_buf, wcn->hal_rsp_len); 1636 1602 if (ret) { 1637 1603 wcn36xx_err("hal_remove_bsskey response failed err=%d\n", ret); 1638 1604 goto out; ··· 1644 1612 int wcn36xx_smd_enter_bmps(struct wcn36xx *wcn, struct ieee80211_vif *vif) 1645 1613 { 1646 1614 struct wcn36xx_hal_enter_bmps_req_msg msg_body; 1647 - struct wcn36xx_vif *vif_priv = (struct wcn36xx_vif *)vif->drv_priv; 1615 + struct wcn36xx_vif *vif_priv = wcn36xx_vif_to_priv(vif); 1648 1616 int ret = 0; 1649 1617 1650 1618 mutex_lock(&wcn->hal_mutex); ··· 1673 1641 1674 1642 int wcn36xx_smd_exit_bmps(struct wcn36xx *wcn, struct ieee80211_vif *vif) 1675 1643 { 1676 - struct wcn36xx_hal_enter_bmps_req_msg msg_body; 1677 - struct wcn36xx_vif *vif_priv = (struct wcn36xx_vif *)vif->drv_priv; 1644 + struct wcn36xx_hal_exit_bmps_req_msg msg_body; 1645 + struct wcn36xx_vif *vif_priv = wcn36xx_vif_to_priv(vif); 1678 1646 int ret = 0; 1679 1647 1680 1648 mutex_lock(&wcn->hal_mutex); ··· 1735 1703 int packet_type) 1736 1704 { 1737 1705 struct wcn36xx_hal_keep_alive_req_msg msg_body; 1738 - struct wcn36xx_vif *vif_priv = (struct wcn36xx_vif *)vif->drv_priv; 1706 + struct wcn36xx_vif *vif_priv = wcn36xx_vif_to_priv(vif); 1739 1707 int ret = 0; 1740 1708 1741 1709 mutex_lock(&wcn->hal_mutex); ··· 1976 1944 return ret; 1977 1945 } 1978 1946 1947 + static int wcn36xx_smd_trigger_ba_rsp(void *buf, int len) 1948 + { 1949 + struct wcn36xx_hal_trigger_ba_rsp_msg *rsp; 1950 + 1951 + if (len < sizeof(*rsp)) 1952 + return -EINVAL; 1953 + 1954 + rsp = (struct wcn36xx_hal_trigger_ba_rsp_msg *) buf; 1955 + return rsp->status; 1956 + } 1957 + 1979 1958 int wcn36xx_smd_trigger_ba(struct wcn36xx *wcn, u8 sta_index) 1980 1959 { 1981 1960 struct wcn36xx_hal_trigger_ba_req_msg msg_body; ··· 2011 1968 wcn36xx_err("Sending hal_trigger_ba failed\n"); 2012 1969 goto out; 2013 1970 } 2014 - ret = wcn36xx_smd_rsp_status_check_v2(wcn, wcn->hal_buf, 2015 - wcn->hal_rsp_len); 1971 + ret = wcn36xx_smd_trigger_ba_rsp(wcn->hal_buf, wcn->hal_rsp_len); 2016 1972 if (ret) { 2017 1973 wcn36xx_err("hal_trigger_ba response failed err=%d\n", ret); 2018 1974 goto out; ··· 2048 2006 list_for_each_entry(tmp, &wcn->vif_list, list) { 2049 2007 wcn36xx_dbg(WCN36XX_DBG_HAL, "beacon missed bss_index %d\n", 2050 2008 tmp->bss_index); 2051 - vif = container_of((void *)tmp, 2052 - struct ieee80211_vif, 2053 - drv_priv); 2009 + vif = wcn36xx_priv_to_vif(tmp); 2054 2010 ieee80211_connection_loss(vif); 2055 2011 } 2056 2012 return 0; ··· 2063 2023 if (tmp->bss_index == rsp->bss_index) { 2064 2024 wcn36xx_dbg(WCN36XX_DBG_HAL, "beacon missed bss_index %d\n", 2065 2025 rsp->bss_index); 2066 - vif = container_of((void *)tmp, 2067 - struct ieee80211_vif, 2068 - drv_priv); 2026 + vif = wcn36xx_priv_to_vif(tmp); 2069 2027 ieee80211_connection_loss(vif); 2070 2028 return 0; 2071 2029 } ··· 2079 2041 { 2080 2042 struct wcn36xx_hal_delete_sta_context_ind_msg *rsp = buf; 2081 2043 struct wcn36xx_vif *tmp; 2082 - struct ieee80211_sta *sta = NULL; 2044 + struct ieee80211_sta *sta; 2083 2045 2084 2046 if (len != sizeof(*rsp)) { 2085 2047 wcn36xx_warn("Corrupted delete sta indication\n"); 2086 2048 return -EIO; 2087 2049 } 2088 2050 2051 + wcn36xx_dbg(WCN36XX_DBG_HAL, "delete station indication %pM index %d\n", 2052 + rsp->addr2, rsp->sta_id); 2053 + 2089 2054 list_for_each_entry(tmp, &wcn->vif_list, list) { 2090 - if (sta && (tmp->sta->sta_index == rsp->sta_id)) { 2091 - sta = container_of((void *)tmp->sta, 2092 - struct ieee80211_sta, 2093 - drv_priv); 2094 - wcn36xx_dbg(WCN36XX_DBG_HAL, 2095 - "delete station indication %pM index %d\n", 2096 - rsp->addr2, 2097 - rsp->sta_id); 2055 + rcu_read_lock(); 2056 + sta = ieee80211_find_sta(wcn36xx_priv_to_vif(tmp), rsp->addr2); 2057 + if (sta) 2098 2058 ieee80211_report_low_ack(sta, 0); 2059 + rcu_read_unlock(); 2060 + if (sta) 2099 2061 return 0; 2100 - } 2101 2062 } 2102 2063 2103 2064 wcn36xx_warn("STA with addr %pM and index %d not found\n", ··· 2137 2100 mutex_unlock(&wcn->hal_mutex); 2138 2101 return ret; 2139 2102 } 2103 + 2104 + int wcn36xx_smd_set_mc_list(struct wcn36xx *wcn, 2105 + struct ieee80211_vif *vif, 2106 + struct wcn36xx_hal_rcv_flt_mc_addr_list_type *fp) 2107 + { 2108 + struct wcn36xx_vif *vif_priv = wcn36xx_vif_to_priv(vif); 2109 + struct wcn36xx_hal_rcv_flt_pkt_set_mc_list_req_msg *msg_body = NULL; 2110 + int ret = 0; 2111 + 2112 + mutex_lock(&wcn->hal_mutex); 2113 + 2114 + msg_body = (struct wcn36xx_hal_rcv_flt_pkt_set_mc_list_req_msg *) 2115 + wcn->hal_buf; 2116 + init_hal_msg(&msg_body->header, WCN36XX_HAL_8023_MULTICAST_LIST_REQ, 2117 + sizeof(msg_body->mc_addr_list)); 2118 + 2119 + /* An empty list means all mc traffic will be received */ 2120 + if (fp) 2121 + memcpy(&msg_body->mc_addr_list, fp, 2122 + sizeof(msg_body->mc_addr_list)); 2123 + else 2124 + msg_body->mc_addr_list.mc_addr_count = 0; 2125 + 2126 + msg_body->mc_addr_list.bss_index = vif_priv->bss_index; 2127 + 2128 + ret = wcn36xx_smd_send_and_wait(wcn, msg_body->header.len); 2129 + if (ret) { 2130 + wcn36xx_err("Sending HAL_8023_MULTICAST_LIST failed\n"); 2131 + goto out; 2132 + } 2133 + ret = wcn36xx_smd_rsp_status_check(wcn->hal_buf, wcn->hal_rsp_len); 2134 + if (ret) { 2135 + wcn36xx_err("HAL_8023_MULTICAST_LIST rsp failed err=%d\n", ret); 2136 + goto out; 2137 + } 2138 + out: 2139 + mutex_unlock(&wcn->hal_mutex); 2140 + return ret; 2141 + } 2142 + 2140 2143 static void wcn36xx_smd_rsp_process(struct wcn36xx *wcn, void *buf, size_t len) 2141 2144 { 2142 2145 struct wcn36xx_hal_msg_header *msg_header = buf; ··· 2218 2141 case WCN36XX_HAL_UPDATE_SCAN_PARAM_RSP: 2219 2142 case WCN36XX_HAL_CH_SWITCH_RSP: 2220 2143 case WCN36XX_HAL_FEATURE_CAPS_EXCHANGE_RSP: 2144 + case WCN36XX_HAL_8023_MULTICAST_LIST_RSP: 2221 2145 memcpy(wcn->hal_buf, buf, len); 2222 2146 wcn->hal_rsp_len = len; 2223 2147 complete(&wcn->hal_rsp_compl);
+3 -9
drivers/net/wireless/ath/wcn36xx/smd.h
··· 44 44 u32 status; 45 45 } __packed; 46 46 47 - /* wcn3620 returns this for tigger_ba */ 48 - 49 - struct wcn36xx_fw_msg_status_rsp_v2 { 50 - u8 bss_id[6]; 51 - u32 status __packed; 52 - u16 count_following_candidates __packed; 53 - /* candidate list follows */ 54 - }; 55 - 56 47 struct wcn36xx_hal_ind_msg { 57 48 struct list_head list; 58 49 u8 *msg; ··· 127 136 int wcn36xx_smd_trigger_ba(struct wcn36xx *wcn, u8 sta_index); 128 137 129 138 int wcn36xx_smd_update_cfg(struct wcn36xx *wcn, u32 cfg_id, u32 value); 139 + int wcn36xx_smd_set_mc_list(struct wcn36xx *wcn, 140 + struct ieee80211_vif *vif, 141 + struct wcn36xx_hal_rcv_flt_mc_addr_list_type *fp); 130 142 #endif /* _SMD_H_ */
+2 -6
drivers/net/wireless/ath/wcn36xx/txrx.c
··· 102 102 struct wcn36xx_vif *vif_priv = NULL; 103 103 struct ieee80211_vif *vif = NULL; 104 104 list_for_each_entry(vif_priv, &wcn->vif_list, list) { 105 - vif = container_of((void *)vif_priv, 106 - struct ieee80211_vif, 107 - drv_priv); 105 + vif = wcn36xx_priv_to_vif(vif_priv); 108 106 if (memcmp(vif->addr, addr, ETH_ALEN) == 0) 109 107 return vif_priv; 110 108 } ··· 165 167 */ 166 168 if (sta_priv) { 167 169 __vif_priv = sta_priv->vif; 168 - vif = container_of((void *)__vif_priv, 169 - struct ieee80211_vif, 170 - drv_priv); 170 + vif = wcn36xx_priv_to_vif(__vif_priv); 171 171 172 172 bd->dpu_sign = sta_priv->ucast_dpu_sign; 173 173 if (vif->type == NL80211_IFTYPE_STATION) {
+19 -1
drivers/net/wireless/ath/wcn36xx/wcn36xx.h
··· 125 125 */ 126 126 struct wcn36xx_vif { 127 127 struct list_head list; 128 - struct wcn36xx_sta *sta; 129 128 u8 dtim_period; 130 129 enum ani_ed_type encrypt_type; 131 130 bool is_joining; 131 + bool sta_assoc; 132 132 struct wcn36xx_hal_mac_ssid ssid; 133 133 134 134 /* Power management */ ··· 261 261 struct ieee80211_sta *wcn36xx_priv_to_sta(struct wcn36xx_sta *sta_priv) 262 262 { 263 263 return container_of((void *)sta_priv, struct ieee80211_sta, drv_priv); 264 + } 265 + 266 + static inline 267 + struct wcn36xx_vif *wcn36xx_vif_to_priv(struct ieee80211_vif *vif) 268 + { 269 + return (struct wcn36xx_vif *) vif->drv_priv; 270 + } 271 + 272 + static inline 273 + struct ieee80211_vif *wcn36xx_priv_to_vif(struct wcn36xx_vif *vif_priv) 274 + { 275 + return container_of((void *) vif_priv, struct ieee80211_vif, drv_priv); 276 + } 277 + 278 + static inline 279 + struct wcn36xx_sta *wcn36xx_sta_to_priv(struct ieee80211_sta *sta) 280 + { 281 + return (struct wcn36xx_sta *)sta->drv_priv; 264 282 } 265 283 266 284 #endif /* _WCN36XX_H_ */
+9 -1
drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcdc.c
··· 321 321 if (pktbuf->len == 0) 322 322 return -ENODATA; 323 323 324 - *ifp = tmp_if; 324 + if (ifp != NULL) 325 + *ifp = tmp_if; 325 326 return 0; 326 327 } 327 328 ··· 352 351 { 353 352 } 354 353 354 + static void brcmf_proto_bcdc_rxreorder(struct brcmf_if *ifp, 355 + struct sk_buff *skb) 356 + { 357 + brcmf_fws_rxreorder(ifp, skb); 358 + } 359 + 355 360 int brcmf_proto_bcdc_attach(struct brcmf_pub *drvr) 356 361 { 357 362 struct brcmf_bcdc *bcdc; ··· 379 372 drvr->proto->configure_addr_mode = brcmf_proto_bcdc_configure_addr_mode; 380 373 drvr->proto->delete_peer = brcmf_proto_bcdc_delete_peer; 381 374 drvr->proto->add_tdls_peer = brcmf_proto_bcdc_add_tdls_peer; 375 + drvr->proto->rxreorder = brcmf_proto_bcdc_rxreorder; 382 376 drvr->proto->pd = bcdc; 383 377 384 378 drvr->hdrlen += BCDC_HEADER_LEN + BRCMF_PROT_FW_SIGNAL_MAX_TXBYTES;
+3 -1
drivers/net/wireless/broadcom/brcm80211/brcmfmac/bus.h
··· 216 216 int prec); 217 217 218 218 /* Receive frame for delivery to OS. Callee disposes of rxp. */ 219 - void brcmf_rx_frame(struct device *dev, struct sk_buff *rxp); 219 + void brcmf_rx_frame(struct device *dev, struct sk_buff *rxp, bool handle_event); 220 + /* Receive async event packet from firmware. Callee disposes of rxp. */ 221 + void brcmf_rx_event(struct device *dev, struct sk_buff *rxp); 220 222 221 223 /* Indication from bus module regarding presence/insertion of dongle. */ 222 224 int brcmf_attach(struct device *dev, struct brcmf_mp_device *settings);
+66 -1
drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
··· 250 250 struct parsed_vndr_ie_info ie_info[VNDR_IE_PARSE_LIMIT]; 251 251 }; 252 252 253 + static u8 nl80211_band_to_fwil(enum nl80211_band band) 254 + { 255 + switch (band) { 256 + case NL80211_BAND_2GHZ: 257 + return WLC_BAND_2G; 258 + case NL80211_BAND_5GHZ: 259 + return WLC_BAND_5G; 260 + default: 261 + WARN_ON(1); 262 + break; 263 + } 264 + return 0; 265 + } 266 + 253 267 static u16 chandef_to_chanspec(struct brcmu_d11inf *d11inf, 254 268 struct cfg80211_chan_def *ch) 255 269 { ··· 1810 1796 return type; 1811 1797 } 1812 1798 1799 + static void brcmf_set_join_pref(struct brcmf_if *ifp, 1800 + struct cfg80211_bss_selection *bss_select) 1801 + { 1802 + struct brcmf_join_pref_params join_pref_params[2]; 1803 + enum nl80211_band band; 1804 + int err, i = 0; 1805 + 1806 + join_pref_params[i].len = 2; 1807 + join_pref_params[i].rssi_gain = 0; 1808 + 1809 + if (bss_select->behaviour != NL80211_BSS_SELECT_ATTR_BAND_PREF) 1810 + brcmf_fil_cmd_int_set(ifp, BRCMF_C_SET_ASSOC_PREFER, WLC_BAND_AUTO); 1811 + 1812 + switch (bss_select->behaviour) { 1813 + case __NL80211_BSS_SELECT_ATTR_INVALID: 1814 + brcmf_c_set_joinpref_default(ifp); 1815 + return; 1816 + case NL80211_BSS_SELECT_ATTR_BAND_PREF: 1817 + join_pref_params[i].type = BRCMF_JOIN_PREF_BAND; 1818 + band = bss_select->param.band_pref; 1819 + join_pref_params[i].band = nl80211_band_to_fwil(band); 1820 + i++; 1821 + break; 1822 + case NL80211_BSS_SELECT_ATTR_RSSI_ADJUST: 1823 + join_pref_params[i].type = BRCMF_JOIN_PREF_RSSI_DELTA; 1824 + band = bss_select->param.adjust.band; 1825 + join_pref_params[i].band = nl80211_band_to_fwil(band); 1826 + join_pref_params[i].rssi_gain = bss_select->param.adjust.delta; 1827 + i++; 1828 + break; 1829 + case NL80211_BSS_SELECT_ATTR_RSSI: 1830 + default: 1831 + break; 1832 + } 1833 + join_pref_params[i].type = BRCMF_JOIN_PREF_RSSI; 1834 + join_pref_params[i].len = 2; 1835 + join_pref_params[i].rssi_gain = 0; 1836 + join_pref_params[i].band = 0; 1837 + err = brcmf_fil_iovar_data_set(ifp, "join_pref", join_pref_params, 1838 + sizeof(join_pref_params)); 1839 + if (err) 1840 + brcmf_err("Set join_pref error (%d)\n", err); 1841 + } 1842 + 1813 1843 static s32 1814 1844 brcmf_cfg80211_connect(struct wiphy *wiphy, struct net_device *ndev, 1815 1845 struct cfg80211_connect_params *sme) ··· 2009 1951 ext_join_params->scan_le.passive_time = cpu_to_le32(-1); 2010 1952 ext_join_params->scan_le.nprobes = cpu_to_le32(-1); 2011 1953 } 1954 + 1955 + brcmf_set_join_pref(ifp, &sme->bss_select); 2012 1956 2013 1957 err = brcmf_fil_bsscfg_data_set(ifp, "join", ext_join_params, 2014 1958 join_params_size); ··· 3668 3608 if (!test_bit(BRCMF_VIF_STATUS_CONNECTED, &ifp->vif->sme_state)) 3669 3609 wowl_config |= BRCMF_WOWL_UNASSOC; 3670 3610 3671 - brcmf_fil_iovar_data_set(ifp, "wowl_wakeind", "clear", strlen("clear")); 3611 + brcmf_fil_iovar_data_set(ifp, "wowl_wakeind", "clear", 3612 + sizeof(struct brcmf_wowl_wakeind_le)); 3672 3613 brcmf_fil_iovar_int_set(ifp, "wowl", wowl_config); 3673 3614 brcmf_fil_iovar_int_set(ifp, "wowl_activate", 1); 3674 3615 brcmf_bus_wowl_config(cfg->pub->bus_if, true); ··· 6340 6279 wiphy->n_cipher_suites = ARRAY_SIZE(brcmf_cipher_suites); 6341 6280 if (!brcmf_feat_is_enabled(ifp, BRCMF_FEAT_MFP)) 6342 6281 wiphy->n_cipher_suites--; 6282 + wiphy->bss_select_support = BIT(NL80211_BSS_SELECT_ATTR_RSSI) | 6283 + BIT(NL80211_BSS_SELECT_ATTR_BAND_PREF) | 6284 + BIT(NL80211_BSS_SELECT_ATTR_RSSI_ADJUST); 6285 + 6343 6286 wiphy->flags |= WIPHY_FLAG_PS_ON_BY_DEFAULT | 6344 6287 WIPHY_FLAG_OFFCHAN_TX | 6345 6288 WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL;
+23 -15
drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
··· 38 38 #define BRCMF_DEFAULT_SCAN_CHANNEL_TIME 40 39 39 #define BRCMF_DEFAULT_SCAN_UNASSOC_TIME 40 40 40 41 - /* boost value for RSSI_DELTA in preferred join selection */ 41 + /* default boost value for RSSI_DELTA in preferred join selection */ 42 42 #define BRCMF_JOIN_PREF_RSSI_BOOST 8 43 43 44 44 #define BRCMF_DEFAULT_TXGLOM_SIZE 32 /* max tx frames in glom chain */ ··· 83 83 static struct brcmfmac_platform_data *brcmfmac_pdata; 84 84 struct brcmf_mp_global_t brcmf_mp_global; 85 85 86 + void brcmf_c_set_joinpref_default(struct brcmf_if *ifp) 87 + { 88 + struct brcmf_join_pref_params join_pref_params[2]; 89 + int err; 90 + 91 + /* Setup join_pref to select target by RSSI (boost on 5GHz) */ 92 + join_pref_params[0].type = BRCMF_JOIN_PREF_RSSI_DELTA; 93 + join_pref_params[0].len = 2; 94 + join_pref_params[0].rssi_gain = BRCMF_JOIN_PREF_RSSI_BOOST; 95 + join_pref_params[0].band = WLC_BAND_5G; 96 + 97 + join_pref_params[1].type = BRCMF_JOIN_PREF_RSSI; 98 + join_pref_params[1].len = 2; 99 + join_pref_params[1].rssi_gain = 0; 100 + join_pref_params[1].band = 0; 101 + err = brcmf_fil_iovar_data_set(ifp, "join_pref", join_pref_params, 102 + sizeof(join_pref_params)); 103 + if (err) 104 + brcmf_err("Set join_pref error (%d)\n", err); 105 + } 106 + 86 107 int brcmf_c_preinit_dcmds(struct brcmf_if *ifp) 87 108 { 88 109 s8 eventmask[BRCMF_EVENTING_MASK_LEN]; 89 110 u8 buf[BRCMF_DCMD_SMLEN]; 90 - struct brcmf_join_pref_params join_pref_params[2]; 91 111 struct brcmf_rev_info_le revinfo; 92 112 struct brcmf_rev_info *ri; 93 113 char *ptr; ··· 174 154 goto done; 175 155 } 176 156 177 - /* Setup join_pref to select target by RSSI(with boost on 5GHz) */ 178 - join_pref_params[0].type = BRCMF_JOIN_PREF_RSSI_DELTA; 179 - join_pref_params[0].len = 2; 180 - join_pref_params[0].rssi_gain = BRCMF_JOIN_PREF_RSSI_BOOST; 181 - join_pref_params[0].band = WLC_BAND_5G; 182 - join_pref_params[1].type = BRCMF_JOIN_PREF_RSSI; 183 - join_pref_params[1].len = 2; 184 - join_pref_params[1].rssi_gain = 0; 185 - join_pref_params[1].band = 0; 186 - err = brcmf_fil_iovar_data_set(ifp, "join_pref", join_pref_params, 187 - sizeof(join_pref_params)); 188 - if (err) 189 - brcmf_err("Set join_pref error (%d)\n", err); 157 + brcmf_c_set_joinpref_default(ifp); 190 158 191 159 /* Setup event_msgs, enable E_IF */ 192 160 err = brcmf_fil_iovar_data_get(ifp, "event_msgs", eventmask,
+38 -223
drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
··· 40 40 41 41 #define MAX_WAIT_FOR_8021X_TX msecs_to_jiffies(950) 42 42 43 - /* AMPDU rx reordering definitions */ 44 - #define BRCMF_RXREORDER_FLOWID_OFFSET 0 45 - #define BRCMF_RXREORDER_MAXIDX_OFFSET 2 46 - #define BRCMF_RXREORDER_FLAGS_OFFSET 4 47 - #define BRCMF_RXREORDER_CURIDX_OFFSET 6 48 - #define BRCMF_RXREORDER_EXPIDX_OFFSET 8 49 - 50 - #define BRCMF_RXREORDER_DEL_FLOW 0x01 51 - #define BRCMF_RXREORDER_FLUSH_ALL 0x02 52 - #define BRCMF_RXREORDER_CURIDX_VALID 0x04 53 - #define BRCMF_RXREORDER_EXPIDX_VALID 0x08 54 - #define BRCMF_RXREORDER_NEW_HOLE 0x10 55 - 56 43 #define BRCMF_BSSIDX_INVALID -1 57 44 58 45 char *brcmf_ifname(struct brcmf_if *ifp) ··· 300 313 301 314 void brcmf_netif_rx(struct brcmf_if *ifp, struct sk_buff *skb) 302 315 { 303 - skb->dev = ifp->ndev; 304 - skb->protocol = eth_type_trans(skb, skb->dev); 305 - 306 316 if (skb->pkt_type == PACKET_MULTICAST) 307 317 ifp->stats.multicast++; 308 - 309 - /* Process special event packets */ 310 - brcmf_fweh_process_skb(ifp->drvr, skb); 311 318 312 319 if (!(ifp->ndev->flags & IFF_UP)) { 313 320 brcmu_pkt_buf_free_skb(skb); ··· 322 341 netif_rx_ni(skb); 323 342 } 324 343 325 - static void brcmf_rxreorder_get_skb_list(struct brcmf_ampdu_rx_reorder *rfi, 326 - u8 start, u8 end, 327 - struct sk_buff_head *skb_list) 344 + static int brcmf_rx_hdrpull(struct brcmf_pub *drvr, struct sk_buff *skb, 345 + struct brcmf_if **ifp) 328 346 { 329 - /* initialize return list */ 330 - __skb_queue_head_init(skb_list); 347 + int ret; 331 348 332 - if (rfi->pend_pkts == 0) { 333 - brcmf_dbg(INFO, "no packets in reorder queue\n"); 334 - return; 349 + /* process and remove protocol-specific header */ 350 + ret = brcmf_proto_hdrpull(drvr, true, skb, ifp); 351 + 352 + if (ret || !(*ifp) || !(*ifp)->ndev) { 353 + if (ret != -ENODATA && *ifp) 354 + (*ifp)->stats.rx_errors++; 355 + brcmu_pkt_buf_free_skb(skb); 356 + return -ENODATA; 335 357 } 336 358 337 - do { 338 - if (rfi->pktslots[start]) { 339 - __skb_queue_tail(skb_list, rfi->pktslots[start]); 340 - rfi->pktslots[start] = NULL; 341 - } 342 - start++; 343 - if (start > rfi->max_idx) 344 - start = 0; 345 - } while (start != end); 346 - rfi->pend_pkts -= skb_queue_len(skb_list); 359 + skb->protocol = eth_type_trans(skb, (*ifp)->ndev); 360 + return 0; 347 361 } 348 362 349 - static void brcmf_rxreorder_process_info(struct brcmf_if *ifp, u8 *reorder_data, 350 - struct sk_buff *pkt) 351 - { 352 - u8 flow_id, max_idx, cur_idx, exp_idx, end_idx; 353 - struct brcmf_ampdu_rx_reorder *rfi; 354 - struct sk_buff_head reorder_list; 355 - struct sk_buff *pnext; 356 - u8 flags; 357 - u32 buf_size; 358 - 359 - flow_id = reorder_data[BRCMF_RXREORDER_FLOWID_OFFSET]; 360 - flags = reorder_data[BRCMF_RXREORDER_FLAGS_OFFSET]; 361 - 362 - /* validate flags and flow id */ 363 - if (flags == 0xFF) { 364 - brcmf_err("invalid flags...so ignore this packet\n"); 365 - brcmf_netif_rx(ifp, pkt); 366 - return; 367 - } 368 - 369 - rfi = ifp->drvr->reorder_flows[flow_id]; 370 - if (flags & BRCMF_RXREORDER_DEL_FLOW) { 371 - brcmf_dbg(INFO, "flow-%d: delete\n", 372 - flow_id); 373 - 374 - if (rfi == NULL) { 375 - brcmf_dbg(INFO, "received flags to cleanup, but no flow (%d) yet\n", 376 - flow_id); 377 - brcmf_netif_rx(ifp, pkt); 378 - return; 379 - } 380 - 381 - brcmf_rxreorder_get_skb_list(rfi, rfi->exp_idx, rfi->exp_idx, 382 - &reorder_list); 383 - /* add the last packet */ 384 - __skb_queue_tail(&reorder_list, pkt); 385 - kfree(rfi); 386 - ifp->drvr->reorder_flows[flow_id] = NULL; 387 - goto netif_rx; 388 - } 389 - /* from here on we need a flow reorder instance */ 390 - if (rfi == NULL) { 391 - buf_size = sizeof(*rfi); 392 - max_idx = reorder_data[BRCMF_RXREORDER_MAXIDX_OFFSET]; 393 - 394 - buf_size += (max_idx + 1) * sizeof(pkt); 395 - 396 - /* allocate space for flow reorder info */ 397 - brcmf_dbg(INFO, "flow-%d: start, maxidx %d\n", 398 - flow_id, max_idx); 399 - rfi = kzalloc(buf_size, GFP_ATOMIC); 400 - if (rfi == NULL) { 401 - brcmf_err("failed to alloc buffer\n"); 402 - brcmf_netif_rx(ifp, pkt); 403 - return; 404 - } 405 - 406 - ifp->drvr->reorder_flows[flow_id] = rfi; 407 - rfi->pktslots = (struct sk_buff **)(rfi+1); 408 - rfi->max_idx = max_idx; 409 - } 410 - if (flags & BRCMF_RXREORDER_NEW_HOLE) { 411 - if (rfi->pend_pkts) { 412 - brcmf_rxreorder_get_skb_list(rfi, rfi->exp_idx, 413 - rfi->exp_idx, 414 - &reorder_list); 415 - WARN_ON(rfi->pend_pkts); 416 - } else { 417 - __skb_queue_head_init(&reorder_list); 418 - } 419 - rfi->cur_idx = reorder_data[BRCMF_RXREORDER_CURIDX_OFFSET]; 420 - rfi->exp_idx = reorder_data[BRCMF_RXREORDER_EXPIDX_OFFSET]; 421 - rfi->max_idx = reorder_data[BRCMF_RXREORDER_MAXIDX_OFFSET]; 422 - rfi->pktslots[rfi->cur_idx] = pkt; 423 - rfi->pend_pkts++; 424 - brcmf_dbg(DATA, "flow-%d: new hole %d (%d), pending %d\n", 425 - flow_id, rfi->cur_idx, rfi->exp_idx, rfi->pend_pkts); 426 - } else if (flags & BRCMF_RXREORDER_CURIDX_VALID) { 427 - cur_idx = reorder_data[BRCMF_RXREORDER_CURIDX_OFFSET]; 428 - exp_idx = reorder_data[BRCMF_RXREORDER_EXPIDX_OFFSET]; 429 - 430 - if ((exp_idx == rfi->exp_idx) && (cur_idx != rfi->exp_idx)) { 431 - /* still in the current hole */ 432 - /* enqueue the current on the buffer chain */ 433 - if (rfi->pktslots[cur_idx] != NULL) { 434 - brcmf_dbg(INFO, "HOLE: ERROR buffer pending..free it\n"); 435 - brcmu_pkt_buf_free_skb(rfi->pktslots[cur_idx]); 436 - rfi->pktslots[cur_idx] = NULL; 437 - } 438 - rfi->pktslots[cur_idx] = pkt; 439 - rfi->pend_pkts++; 440 - rfi->cur_idx = cur_idx; 441 - brcmf_dbg(DATA, "flow-%d: store pkt %d (%d), pending %d\n", 442 - flow_id, cur_idx, exp_idx, rfi->pend_pkts); 443 - 444 - /* can return now as there is no reorder 445 - * list to process. 446 - */ 447 - return; 448 - } 449 - if (rfi->exp_idx == cur_idx) { 450 - if (rfi->pktslots[cur_idx] != NULL) { 451 - brcmf_dbg(INFO, "error buffer pending..free it\n"); 452 - brcmu_pkt_buf_free_skb(rfi->pktslots[cur_idx]); 453 - rfi->pktslots[cur_idx] = NULL; 454 - } 455 - rfi->pktslots[cur_idx] = pkt; 456 - rfi->pend_pkts++; 457 - 458 - /* got the expected one. flush from current to expected 459 - * and update expected 460 - */ 461 - brcmf_dbg(DATA, "flow-%d: expected %d (%d), pending %d\n", 462 - flow_id, cur_idx, exp_idx, rfi->pend_pkts); 463 - 464 - rfi->cur_idx = cur_idx; 465 - rfi->exp_idx = exp_idx; 466 - 467 - brcmf_rxreorder_get_skb_list(rfi, cur_idx, exp_idx, 468 - &reorder_list); 469 - brcmf_dbg(DATA, "flow-%d: freeing buffers %d, pending %d\n", 470 - flow_id, skb_queue_len(&reorder_list), 471 - rfi->pend_pkts); 472 - } else { 473 - u8 end_idx; 474 - 475 - brcmf_dbg(DATA, "flow-%d (0x%x): both moved, old %d/%d, new %d/%d\n", 476 - flow_id, flags, rfi->cur_idx, rfi->exp_idx, 477 - cur_idx, exp_idx); 478 - if (flags & BRCMF_RXREORDER_FLUSH_ALL) 479 - end_idx = rfi->exp_idx; 480 - else 481 - end_idx = exp_idx; 482 - 483 - /* flush pkts first */ 484 - brcmf_rxreorder_get_skb_list(rfi, rfi->exp_idx, end_idx, 485 - &reorder_list); 486 - 487 - if (exp_idx == ((cur_idx + 1) % (rfi->max_idx + 1))) { 488 - __skb_queue_tail(&reorder_list, pkt); 489 - } else { 490 - rfi->pktslots[cur_idx] = pkt; 491 - rfi->pend_pkts++; 492 - } 493 - rfi->exp_idx = exp_idx; 494 - rfi->cur_idx = cur_idx; 495 - } 496 - } else { 497 - /* explicity window move updating the expected index */ 498 - exp_idx = reorder_data[BRCMF_RXREORDER_EXPIDX_OFFSET]; 499 - 500 - brcmf_dbg(DATA, "flow-%d (0x%x): change expected: %d -> %d\n", 501 - flow_id, flags, rfi->exp_idx, exp_idx); 502 - if (flags & BRCMF_RXREORDER_FLUSH_ALL) 503 - end_idx = rfi->exp_idx; 504 - else 505 - end_idx = exp_idx; 506 - 507 - brcmf_rxreorder_get_skb_list(rfi, rfi->exp_idx, end_idx, 508 - &reorder_list); 509 - __skb_queue_tail(&reorder_list, pkt); 510 - /* set the new expected idx */ 511 - rfi->exp_idx = exp_idx; 512 - } 513 - netif_rx: 514 - skb_queue_walk_safe(&reorder_list, pkt, pnext) { 515 - __skb_unlink(pkt, &reorder_list); 516 - brcmf_netif_rx(ifp, pkt); 517 - } 518 - } 519 - 520 - void brcmf_rx_frame(struct device *dev, struct sk_buff *skb) 363 + void brcmf_rx_frame(struct device *dev, struct sk_buff *skb, bool handle_event) 521 364 { 522 365 struct brcmf_if *ifp; 523 366 struct brcmf_bus *bus_if = dev_get_drvdata(dev); 524 367 struct brcmf_pub *drvr = bus_if->drvr; 525 - struct brcmf_skb_reorder_data *rd; 526 - int ret; 527 368 528 369 brcmf_dbg(DATA, "Enter: %s: rxp=%p\n", dev_name(dev), skb); 529 370 530 - /* process and remove protocol-specific header */ 531 - ret = brcmf_proto_hdrpull(drvr, true, skb, &ifp); 532 - 533 - if (ret || !ifp || !ifp->ndev) { 534 - if (ret != -ENODATA && ifp) 535 - ifp->stats.rx_errors++; 536 - brcmu_pkt_buf_free_skb(skb); 371 + if (brcmf_rx_hdrpull(drvr, skb, &ifp)) 537 372 return; 538 - } 539 373 540 - rd = (struct brcmf_skb_reorder_data *)skb->cb; 541 - if (rd->reorder) 542 - brcmf_rxreorder_process_info(ifp, rd->reorder, skb); 543 - else 374 + if (brcmf_proto_is_reorder_skb(skb)) { 375 + brcmf_proto_rxreorder(ifp, skb); 376 + } else { 377 + /* Process special event packets */ 378 + if (handle_event) 379 + brcmf_fweh_process_skb(ifp->drvr, skb); 380 + 544 381 brcmf_netif_rx(ifp, skb); 382 + } 383 + } 384 + 385 + void brcmf_rx_event(struct device *dev, struct sk_buff *skb) 386 + { 387 + struct brcmf_if *ifp; 388 + struct brcmf_bus *bus_if = dev_get_drvdata(dev); 389 + struct brcmf_pub *drvr = bus_if->drvr; 390 + 391 + brcmf_dbg(EVENT, "Enter: %s: rxp=%p\n", dev_name(dev), skb); 392 + 393 + if (brcmf_rx_hdrpull(drvr, skb, &ifp)) 394 + return; 395 + 396 + brcmf_fweh_process_skb(ifp->drvr, skb); 397 + brcmu_pkt_buf_free_skb(skb); 545 398 } 546 399 547 400 void brcmf_txfinalize(struct brcmf_if *ifp, struct sk_buff *txp, bool success)
+1 -4
drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.h
··· 208 208 u8 ipv6addr_idx; 209 209 }; 210 210 211 - struct brcmf_skb_reorder_data { 212 - u8 *reorder; 213 - }; 214 - 215 211 int brcmf_netdev_wait_pend8021x(struct brcmf_if *ifp); 216 212 217 213 /* Return pointer to interface name */ ··· 223 227 void brcmf_txfinalize(struct brcmf_if *ifp, struct sk_buff *txp, bool success); 224 228 void brcmf_netif_rx(struct brcmf_if *ifp, struct sk_buff *skb); 225 229 void brcmf_net_setcarrier(struct brcmf_if *ifp, bool on); 230 + void brcmf_c_set_joinpref_default(struct brcmf_if *ifp); 226 231 int __init brcmf_core_init(void); 227 232 void __exit brcmf_core_exit(void); 228 233
+28 -2
drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c
··· 29 29 #define BRCMF_FW_MAX_NVRAM_SIZE 64000 30 30 #define BRCMF_FW_NVRAM_DEVPATH_LEN 19 /* devpath0=pcie/1/4/ */ 31 31 #define BRCMF_FW_NVRAM_PCIEDEV_LEN 10 /* pcie/1/4/ + \0 */ 32 + #define BRCMF_FW_DEFAULT_BOARDREV "boardrev=0xff" 32 33 33 34 enum nvram_parser_state { 34 35 IDLE, ··· 52 51 * @entry: start position of key,value entry. 53 52 * @multi_dev_v1: detect pcie multi device v1 (compressed). 54 53 * @multi_dev_v2: detect pcie multi device v2. 54 + * @boardrev_found: nvram contains boardrev information. 55 55 */ 56 56 struct nvram_parser { 57 57 enum nvram_parser_state state; ··· 65 63 u32 entry; 66 64 bool multi_dev_v1; 67 65 bool multi_dev_v2; 66 + bool boardrev_found; 68 67 }; 69 68 70 69 /** ··· 128 125 nvp->multi_dev_v1 = true; 129 126 if (strncmp(&nvp->data[nvp->entry], "pcie/", 5) == 0) 130 127 nvp->multi_dev_v2 = true; 128 + if (strncmp(&nvp->data[nvp->entry], "boardrev", 8) == 0) 129 + nvp->boardrev_found = true; 131 130 } else if (!is_nvram_char(c) || c == ' ') { 132 131 brcmf_dbg(INFO, "warning: ln=%d:col=%d: '=' expected, skip invalid key entry\n", 133 132 nvp->line, nvp->column); ··· 289 284 while (i < nvp->nvram_len) { 290 285 if ((nvp->nvram[i] - '0' == id) && (nvp->nvram[i + 1] == ':')) { 291 286 i += 2; 287 + if (strncmp(&nvp->nvram[i], "boardrev", 8) == 0) 288 + nvp->boardrev_found = true; 292 289 while (nvp->nvram[i] != 0) { 293 290 nvram[j] = nvp->nvram[i]; 294 291 i++; ··· 342 335 while (i < nvp->nvram_len - len) { 343 336 if (strncmp(&nvp->nvram[i], prefix, len) == 0) { 344 337 i += len; 338 + if (strncmp(&nvp->nvram[i], "boardrev", 8) == 0) 339 + nvp->boardrev_found = true; 345 340 while (nvp->nvram[i] != 0) { 346 341 nvram[j] = nvp->nvram[i]; 347 342 i++; ··· 363 354 fail: 364 355 kfree(nvram); 365 356 nvp->nvram_len = 0; 357 + } 358 + 359 + static void brcmf_fw_add_defaults(struct nvram_parser *nvp) 360 + { 361 + if (nvp->boardrev_found) 362 + return; 363 + 364 + memcpy(&nvp->nvram[nvp->nvram_len], &BRCMF_FW_DEFAULT_BOARDREV, 365 + strlen(BRCMF_FW_DEFAULT_BOARDREV)); 366 + nvp->nvram_len += strlen(BRCMF_FW_DEFAULT_BOARDREV); 367 + nvp->nvram[nvp->nvram_len] = '\0'; 368 + nvp->nvram_len++; 366 369 } 367 370 368 371 /* brcmf_nvram_strip :Takes a buffer of "<var>=<value>\n" lines read from a fil ··· 398 377 if (nvp.state == END) 399 378 break; 400 379 } 401 - if (nvp.multi_dev_v1) 380 + if (nvp.multi_dev_v1) { 381 + nvp.boardrev_found = false; 402 382 brcmf_fw_strip_multi_v1(&nvp, domain_nr, bus_nr); 403 - else if (nvp.multi_dev_v2) 383 + } else if (nvp.multi_dev_v2) { 384 + nvp.boardrev_found = false; 404 385 brcmf_fw_strip_multi_v2(&nvp, domain_nr, bus_nr); 386 + } 405 387 406 388 if (nvp.nvram_len == 0) { 407 389 kfree(nvp.nvram); 408 390 return NULL; 409 391 } 392 + 393 + brcmf_fw_add_defaults(&nvp); 410 394 411 395 pad = nvp.nvram_len; 412 396 *new_length = roundup(nvp.nvram_len + 1, 4);
+1
drivers/net/wireless/broadcom/brcm80211/brcmfmac/fweh.c
··· 371 371 int i, err; 372 372 s8 eventmask[BRCMF_EVENTING_MASK_LEN]; 373 373 374 + memset(eventmask, 0, sizeof(eventmask)); 374 375 for (i = 0; i < BRCMF_E_LAST; i++) { 375 376 if (ifp->drvr->fweh.evt_handler[i]) { 376 377 brcmf_dbg(EVENT, "enable event %s\n",
+1
drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwil.h
··· 78 78 #define BRCMF_C_SET_SCAN_CHANNEL_TIME 185 79 79 #define BRCMF_C_SET_SCAN_UNASSOC_TIME 187 80 80 #define BRCMF_C_SCB_DEAUTHENTICATE_FOR_REASON 201 81 + #define BRCMF_C_SET_ASSOC_PREFER 205 81 82 #define BRCMF_C_GET_VALID_CHANNELS 217 82 83 #define BRCMF_C_GET_KEY_PRIMARY 235 83 84 #define BRCMF_C_SET_KEY_PRIMARY 236
+209
drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwsignal.c
··· 92 92 }; 93 93 #undef BRCMF_FWS_TLV_DEF 94 94 95 + /* AMPDU rx reordering definitions */ 96 + #define BRCMF_RXREORDER_FLOWID_OFFSET 0 97 + #define BRCMF_RXREORDER_MAXIDX_OFFSET 2 98 + #define BRCMF_RXREORDER_FLAGS_OFFSET 4 99 + #define BRCMF_RXREORDER_CURIDX_OFFSET 6 100 + #define BRCMF_RXREORDER_EXPIDX_OFFSET 8 101 + 102 + #define BRCMF_RXREORDER_DEL_FLOW 0x01 103 + #define BRCMF_RXREORDER_FLUSH_ALL 0x02 104 + #define BRCMF_RXREORDER_CURIDX_VALID 0x04 105 + #define BRCMF_RXREORDER_EXPIDX_VALID 0x08 106 + #define BRCMF_RXREORDER_NEW_HOLE 0x10 107 + 95 108 #ifdef DEBUG 96 109 /* 97 110 * brcmf_fws_tlv_names - array of tlv names. ··· 1625 1612 brcmf_fws_unlock(fws); 1626 1613 } 1627 1614 return 0; 1615 + } 1616 + 1617 + static void brcmf_rxreorder_get_skb_list(struct brcmf_ampdu_rx_reorder *rfi, 1618 + u8 start, u8 end, 1619 + struct sk_buff_head *skb_list) 1620 + { 1621 + /* initialize return list */ 1622 + __skb_queue_head_init(skb_list); 1623 + 1624 + if (rfi->pend_pkts == 0) { 1625 + brcmf_dbg(INFO, "no packets in reorder queue\n"); 1626 + return; 1627 + } 1628 + 1629 + do { 1630 + if (rfi->pktslots[start]) { 1631 + __skb_queue_tail(skb_list, rfi->pktslots[start]); 1632 + rfi->pktslots[start] = NULL; 1633 + } 1634 + start++; 1635 + if (start > rfi->max_idx) 1636 + start = 0; 1637 + } while (start != end); 1638 + rfi->pend_pkts -= skb_queue_len(skb_list); 1639 + } 1640 + 1641 + void brcmf_fws_rxreorder(struct brcmf_if *ifp, struct sk_buff *pkt) 1642 + { 1643 + u8 *reorder_data; 1644 + u8 flow_id, max_idx, cur_idx, exp_idx, end_idx; 1645 + struct brcmf_ampdu_rx_reorder *rfi; 1646 + struct sk_buff_head reorder_list; 1647 + struct sk_buff *pnext; 1648 + u8 flags; 1649 + u32 buf_size; 1650 + 1651 + reorder_data = ((struct brcmf_skb_reorder_data *)pkt->cb)->reorder; 1652 + flow_id = reorder_data[BRCMF_RXREORDER_FLOWID_OFFSET]; 1653 + flags = reorder_data[BRCMF_RXREORDER_FLAGS_OFFSET]; 1654 + 1655 + /* validate flags and flow id */ 1656 + if (flags == 0xFF) { 1657 + brcmf_err("invalid flags...so ignore this packet\n"); 1658 + brcmf_netif_rx(ifp, pkt); 1659 + return; 1660 + } 1661 + 1662 + rfi = ifp->drvr->reorder_flows[flow_id]; 1663 + if (flags & BRCMF_RXREORDER_DEL_FLOW) { 1664 + brcmf_dbg(INFO, "flow-%d: delete\n", 1665 + flow_id); 1666 + 1667 + if (rfi == NULL) { 1668 + brcmf_dbg(INFO, "received flags to cleanup, but no flow (%d) yet\n", 1669 + flow_id); 1670 + brcmf_netif_rx(ifp, pkt); 1671 + return; 1672 + } 1673 + 1674 + brcmf_rxreorder_get_skb_list(rfi, rfi->exp_idx, rfi->exp_idx, 1675 + &reorder_list); 1676 + /* add the last packet */ 1677 + __skb_queue_tail(&reorder_list, pkt); 1678 + kfree(rfi); 1679 + ifp->drvr->reorder_flows[flow_id] = NULL; 1680 + goto netif_rx; 1681 + } 1682 + /* from here on we need a flow reorder instance */ 1683 + if (rfi == NULL) { 1684 + buf_size = sizeof(*rfi); 1685 + max_idx = reorder_data[BRCMF_RXREORDER_MAXIDX_OFFSET]; 1686 + 1687 + buf_size += (max_idx + 1) * sizeof(pkt); 1688 + 1689 + /* allocate space for flow reorder info */ 1690 + brcmf_dbg(INFO, "flow-%d: start, maxidx %d\n", 1691 + flow_id, max_idx); 1692 + rfi = kzalloc(buf_size, GFP_ATOMIC); 1693 + if (rfi == NULL) { 1694 + brcmf_err("failed to alloc buffer\n"); 1695 + brcmf_netif_rx(ifp, pkt); 1696 + return; 1697 + } 1698 + 1699 + ifp->drvr->reorder_flows[flow_id] = rfi; 1700 + rfi->pktslots = (struct sk_buff **)(rfi + 1); 1701 + rfi->max_idx = max_idx; 1702 + } 1703 + if (flags & BRCMF_RXREORDER_NEW_HOLE) { 1704 + if (rfi->pend_pkts) { 1705 + brcmf_rxreorder_get_skb_list(rfi, rfi->exp_idx, 1706 + rfi->exp_idx, 1707 + &reorder_list); 1708 + WARN_ON(rfi->pend_pkts); 1709 + } else { 1710 + __skb_queue_head_init(&reorder_list); 1711 + } 1712 + rfi->cur_idx = reorder_data[BRCMF_RXREORDER_CURIDX_OFFSET]; 1713 + rfi->exp_idx = reorder_data[BRCMF_RXREORDER_EXPIDX_OFFSET]; 1714 + rfi->max_idx = reorder_data[BRCMF_RXREORDER_MAXIDX_OFFSET]; 1715 + rfi->pktslots[rfi->cur_idx] = pkt; 1716 + rfi->pend_pkts++; 1717 + brcmf_dbg(DATA, "flow-%d: new hole %d (%d), pending %d\n", 1718 + flow_id, rfi->cur_idx, rfi->exp_idx, rfi->pend_pkts); 1719 + } else if (flags & BRCMF_RXREORDER_CURIDX_VALID) { 1720 + cur_idx = reorder_data[BRCMF_RXREORDER_CURIDX_OFFSET]; 1721 + exp_idx = reorder_data[BRCMF_RXREORDER_EXPIDX_OFFSET]; 1722 + 1723 + if ((exp_idx == rfi->exp_idx) && (cur_idx != rfi->exp_idx)) { 1724 + /* still in the current hole */ 1725 + /* enqueue the current on the buffer chain */ 1726 + if (rfi->pktslots[cur_idx] != NULL) { 1727 + brcmf_dbg(INFO, "HOLE: ERROR buffer pending..free it\n"); 1728 + brcmu_pkt_buf_free_skb(rfi->pktslots[cur_idx]); 1729 + rfi->pktslots[cur_idx] = NULL; 1730 + } 1731 + rfi->pktslots[cur_idx] = pkt; 1732 + rfi->pend_pkts++; 1733 + rfi->cur_idx = cur_idx; 1734 + brcmf_dbg(DATA, "flow-%d: store pkt %d (%d), pending %d\n", 1735 + flow_id, cur_idx, exp_idx, rfi->pend_pkts); 1736 + 1737 + /* can return now as there is no reorder 1738 + * list to process. 1739 + */ 1740 + return; 1741 + } 1742 + if (rfi->exp_idx == cur_idx) { 1743 + if (rfi->pktslots[cur_idx] != NULL) { 1744 + brcmf_dbg(INFO, "error buffer pending..free it\n"); 1745 + brcmu_pkt_buf_free_skb(rfi->pktslots[cur_idx]); 1746 + rfi->pktslots[cur_idx] = NULL; 1747 + } 1748 + rfi->pktslots[cur_idx] = pkt; 1749 + rfi->pend_pkts++; 1750 + 1751 + /* got the expected one. flush from current to expected 1752 + * and update expected 1753 + */ 1754 + brcmf_dbg(DATA, "flow-%d: expected %d (%d), pending %d\n", 1755 + flow_id, cur_idx, exp_idx, rfi->pend_pkts); 1756 + 1757 + rfi->cur_idx = cur_idx; 1758 + rfi->exp_idx = exp_idx; 1759 + 1760 + brcmf_rxreorder_get_skb_list(rfi, cur_idx, exp_idx, 1761 + &reorder_list); 1762 + brcmf_dbg(DATA, "flow-%d: freeing buffers %d, pending %d\n", 1763 + flow_id, skb_queue_len(&reorder_list), 1764 + rfi->pend_pkts); 1765 + } else { 1766 + u8 end_idx; 1767 + 1768 + brcmf_dbg(DATA, "flow-%d (0x%x): both moved, old %d/%d, new %d/%d\n", 1769 + flow_id, flags, rfi->cur_idx, rfi->exp_idx, 1770 + cur_idx, exp_idx); 1771 + if (flags & BRCMF_RXREORDER_FLUSH_ALL) 1772 + end_idx = rfi->exp_idx; 1773 + else 1774 + end_idx = exp_idx; 1775 + 1776 + /* flush pkts first */ 1777 + brcmf_rxreorder_get_skb_list(rfi, rfi->exp_idx, end_idx, 1778 + &reorder_list); 1779 + 1780 + if (exp_idx == ((cur_idx + 1) % (rfi->max_idx + 1))) { 1781 + __skb_queue_tail(&reorder_list, pkt); 1782 + } else { 1783 + rfi->pktslots[cur_idx] = pkt; 1784 + rfi->pend_pkts++; 1785 + } 1786 + rfi->exp_idx = exp_idx; 1787 + rfi->cur_idx = cur_idx; 1788 + } 1789 + } else { 1790 + /* explicity window move updating the expected index */ 1791 + exp_idx = reorder_data[BRCMF_RXREORDER_EXPIDX_OFFSET]; 1792 + 1793 + brcmf_dbg(DATA, "flow-%d (0x%x): change expected: %d -> %d\n", 1794 + flow_id, flags, rfi->exp_idx, exp_idx); 1795 + if (flags & BRCMF_RXREORDER_FLUSH_ALL) 1796 + end_idx = rfi->exp_idx; 1797 + else 1798 + end_idx = exp_idx; 1799 + 1800 + brcmf_rxreorder_get_skb_list(rfi, rfi->exp_idx, end_idx, 1801 + &reorder_list); 1802 + __skb_queue_tail(&reorder_list, pkt); 1803 + /* set the new expected idx */ 1804 + rfi->exp_idx = exp_idx; 1805 + } 1806 + netif_rx: 1807 + skb_queue_walk_safe(&reorder_list, pkt, pnext) { 1808 + __skb_unlink(pkt, &reorder_list); 1809 + brcmf_netif_rx(ifp, pkt); 1810 + } 1628 1811 } 1629 1812 1630 1813 void brcmf_fws_hdrpull(struct brcmf_if *ifp, s16 siglen, struct sk_buff *skb)
+1
drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwsignal.h
··· 29 29 void brcmf_fws_del_interface(struct brcmf_if *ifp); 30 30 void brcmf_fws_bustxfail(struct brcmf_fws_info *fws, struct sk_buff *skb); 31 31 void brcmf_fws_bus_blocked(struct brcmf_pub *drvr, bool flow_blocked); 32 + void brcmf_fws_rxreorder(struct brcmf_if *ifp, struct sk_buff *skb); 32 33 33 34 #endif /* FWSIGNAL_H_ */
+28 -18
drivers/net/wireless/broadcom/brcm80211/brcmfmac/msgbuf.c
··· 20 20 21 21 #include <linux/types.h> 22 22 #include <linux/netdevice.h> 23 + #include <linux/etherdevice.h> 23 24 24 25 #include <brcmu_utils.h> 25 26 #include <brcmu_wifi.h> ··· 527 526 return -ENODEV; 528 527 } 529 528 529 + static void brcmf_msgbuf_rxreorder(struct brcmf_if *ifp, struct sk_buff *skb) 530 + { 531 + } 530 532 531 533 static void 532 534 brcmf_msgbuf_remove_flowring(struct brcmf_msgbuf *msgbuf, u16 flowid) ··· 1079 1075 } 1080 1076 1081 1077 1082 - static void 1083 - brcmf_msgbuf_rx_skb(struct brcmf_msgbuf *msgbuf, struct sk_buff *skb, 1084 - u8 ifidx) 1085 - { 1086 - struct brcmf_if *ifp; 1087 - 1088 - ifp = brcmf_get_ifp(msgbuf->drvr, ifidx); 1089 - if (!ifp || !ifp->ndev) { 1090 - brcmf_err("Received pkt for invalid ifidx %d\n", ifidx); 1091 - brcmu_pkt_buf_free_skb(skb); 1092 - return; 1093 - } 1094 - brcmf_netif_rx(ifp, skb); 1095 - } 1096 - 1097 - 1098 1078 static void brcmf_msgbuf_process_event(struct brcmf_msgbuf *msgbuf, void *buf) 1099 1079 { 1100 1080 struct msgbuf_rx_event *event; 1101 1081 u32 idx; 1102 1082 u16 buflen; 1103 1083 struct sk_buff *skb; 1084 + struct brcmf_if *ifp; 1104 1085 1105 1086 event = (struct msgbuf_rx_event *)buf; 1106 1087 idx = le32_to_cpu(event->msg.request_id); ··· 1105 1116 1106 1117 skb_trim(skb, buflen); 1107 1118 1108 - brcmf_msgbuf_rx_skb(msgbuf, skb, event->msg.ifidx); 1119 + ifp = brcmf_get_ifp(msgbuf->drvr, event->msg.ifidx); 1120 + if (!ifp || !ifp->ndev) { 1121 + brcmf_err("Received pkt for invalid ifidx %d\n", 1122 + event->msg.ifidx); 1123 + goto exit; 1124 + } 1125 + 1126 + skb->protocol = eth_type_trans(skb, ifp->ndev); 1127 + 1128 + brcmf_fweh_process_skb(ifp->drvr, skb); 1129 + 1130 + exit: 1131 + brcmu_pkt_buf_free_skb(skb); 1109 1132 } 1110 1133 1111 1134 ··· 1129 1128 u16 data_offset; 1130 1129 u16 buflen; 1131 1130 u32 idx; 1131 + struct brcmf_if *ifp; 1132 1132 1133 1133 brcmf_msgbuf_update_rxbufpost_count(msgbuf, 1); 1134 1134 ··· 1150 1148 1151 1149 skb_trim(skb, buflen); 1152 1150 1153 - brcmf_msgbuf_rx_skb(msgbuf, skb, rx_complete->msg.ifidx); 1151 + ifp = brcmf_get_ifp(msgbuf->drvr, rx_complete->msg.ifidx); 1152 + if (!ifp || !ifp->ndev) { 1153 + brcmf_err("Received pkt for invalid ifidx %d\n", 1154 + rx_complete->msg.ifidx); 1155 + brcmu_pkt_buf_free_skb(skb); 1156 + return; 1157 + } 1158 + brcmf_netif_rx(ifp, skb); 1154 1159 } 1155 1160 1156 1161 ··· 1469 1460 drvr->proto->configure_addr_mode = brcmf_msgbuf_configure_addr_mode; 1470 1461 drvr->proto->delete_peer = brcmf_msgbuf_delete_peer; 1471 1462 drvr->proto->add_tdls_peer = brcmf_msgbuf_add_tdls_peer; 1463 + drvr->proto->rxreorder = brcmf_msgbuf_rxreorder; 1472 1464 drvr->proto->pd = msgbuf; 1473 1465 1474 1466 init_waitqueue_head(&msgbuf->ioctl_resp_wait);
+1 -1
drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c
··· 1266 1266 brcmf_p2p_stop_wait_next_action_frame(struct brcmf_cfg80211_info *cfg) 1267 1267 { 1268 1268 struct brcmf_p2p_info *p2p = &cfg->p2p; 1269 - struct brcmf_if *ifp = cfg->escan_info.ifp; 1269 + struct brcmf_if *ifp = p2p->bss_idx[P2PAPI_BSSCFG_PRIMARY].vif->ifp; 1270 1270 1271 1271 if (test_bit(BRCMF_P2P_STATUS_SENDING_ACT_FRAME, &p2p->status) && 1272 1272 (test_bit(BRCMF_P2P_STATUS_ACTION_TX_COMPLETED, &p2p->status) ||
+16
drivers/net/wireless/broadcom/brcm80211/brcmfmac/proto.h
··· 22 22 ADDR_DIRECT 23 23 }; 24 24 25 + struct brcmf_skb_reorder_data { 26 + u8 *reorder; 27 + }; 25 28 26 29 struct brcmf_proto { 27 30 int (*hdrpull)(struct brcmf_pub *drvr, bool do_fws, ··· 41 38 u8 peer[ETH_ALEN]); 42 39 void (*add_tdls_peer)(struct brcmf_pub *drvr, int ifidx, 43 40 u8 peer[ETH_ALEN]); 41 + void (*rxreorder)(struct brcmf_if *ifp, struct sk_buff *skb); 44 42 void *pd; 45 43 }; 46 44 ··· 95 91 { 96 92 drvr->proto->add_tdls_peer(drvr, ifidx, peer); 97 93 } 94 + static inline bool brcmf_proto_is_reorder_skb(struct sk_buff *skb) 95 + { 96 + struct brcmf_skb_reorder_data *rd; 98 97 98 + rd = (struct brcmf_skb_reorder_data *)skb->cb; 99 + return !!rd->reorder; 100 + } 101 + 102 + static inline void 103 + brcmf_proto_rxreorder(struct brcmf_if *ifp, struct sk_buff *skb) 104 + { 105 + ifp->drvr->proto->rxreorder(ifp, skb); 106 + } 99 107 100 108 #endif /* BRCMFMAC_PROTO_H */
+24 -8
drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
··· 1294 1294 return (u8)((hdrvalue & SDPCM_DOFFSET_MASK) >> SDPCM_DOFFSET_SHIFT); 1295 1295 } 1296 1296 1297 + static inline bool brcmf_sdio_fromevntchan(u8 *swheader) 1298 + { 1299 + u32 hdrvalue; 1300 + u8 ret; 1301 + 1302 + hdrvalue = *(u32 *)swheader; 1303 + ret = (u8)((hdrvalue & SDPCM_CHANNEL_MASK) >> SDPCM_CHANNEL_SHIFT); 1304 + 1305 + return (ret == SDPCM_EVENT_CHANNEL); 1306 + } 1307 + 1297 1308 static int brcmf_sdio_hdparse(struct brcmf_sdio *bus, u8 *header, 1298 1309 struct brcmf_sdio_hdrinfo *rd, 1299 1310 enum brcmf_sdio_frmtype type) ··· 1652 1641 pfirst->len, pfirst->next, 1653 1642 pfirst->prev); 1654 1643 skb_unlink(pfirst, &bus->glom); 1655 - brcmf_rx_frame(bus->sdiodev->dev, pfirst); 1644 + if (brcmf_sdio_fromevntchan(pfirst->data)) 1645 + brcmf_rx_event(bus->sdiodev->dev, pfirst); 1646 + else 1647 + brcmf_rx_frame(bus->sdiodev->dev, pfirst, 1648 + false); 1656 1649 bus->sdcnt.rxglompkts++; 1657 1650 } 1658 1651 ··· 1982 1967 __skb_trim(pkt, rd->len); 1983 1968 skb_pull(pkt, rd->dat_offset); 1984 1969 1970 + if (pkt->len == 0) 1971 + brcmu_pkt_buf_free_skb(pkt); 1972 + else if (rd->channel == SDPCM_EVENT_CHANNEL) 1973 + brcmf_rx_event(bus->sdiodev->dev, pkt); 1974 + else 1975 + brcmf_rx_frame(bus->sdiodev->dev, pkt, 1976 + false); 1977 + 1985 1978 /* prepare the descriptor for the next read */ 1986 1979 rd->len = rd->len_nxtfrm << 4; 1987 1980 rd->len_nxtfrm = 0; 1988 1981 /* treat all packet as event if we don't know */ 1989 1982 rd->channel = SDPCM_EVENT_CHANNEL; 1990 - 1991 - if (pkt->len == 0) { 1992 - brcmu_pkt_buf_free_skb(pkt); 1993 - continue; 1994 - } 1995 - 1996 - brcmf_rx_frame(bus->sdiodev->dev, pkt); 1997 1983 } 1998 1984 1999 1985 rxcount = maxframes - rxleft;
+1 -1
drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c
··· 514 514 515 515 if (devinfo->bus_pub.state == BRCMFMAC_USB_STATE_UP) { 516 516 skb_put(skb, urb->actual_length); 517 - brcmf_rx_frame(devinfo->dev, skb); 517 + brcmf_rx_frame(devinfo->dev, skb, true); 518 518 brcmf_usb_rx_refill(devinfo, req); 519 519 } else { 520 520 brcmu_pkt_buf_free_skb(skb);
+4 -1
drivers/net/wireless/intel/iwlwifi/iwl-drv.c
··· 1280 1280 if (err) 1281 1281 goto try_again; 1282 1282 1283 - api_ver = drv->fw.ucode_ver; 1283 + if (fw_has_api(&drv->fw.ucode_capa, IWL_UCODE_TLV_API_NEW_VERSION)) 1284 + api_ver = drv->fw.ucode_ver; 1285 + else 1286 + api_ver = IWL_UCODE_API(drv->fw.ucode_ver); 1284 1287 1285 1288 /* 1286 1289 * api_ver should match the api version forming part of the
+2
drivers/net/wireless/intel/iwlwifi/iwl-fw-file.h
··· 251 251 * @IWL_UCODE_TLV_API_WIFI_MCC_UPDATE: ucode supports MCC updates with source. 252 252 * @IWL_UCODE_TLV_API_WIDE_CMD_HDR: ucode supports wide command header 253 253 * @IWL_UCODE_TLV_API_LQ_SS_PARAMS: Configure STBC/BFER via LQ CMD ss_params 254 + * @IWL_UCODE_TLV_API_NEW_VERSION: new versioning format 254 255 * @IWL_UCODE_TLV_API_EXT_SCAN_PRIORITY: scan APIs use 8-level priority 255 256 * instead of 3. 256 257 * @IWL_UCODE_TLV_API_TX_POWER_CHAIN: TX power API has larger command size ··· 264 263 IWL_UCODE_TLV_API_WIFI_MCC_UPDATE = (__force iwl_ucode_tlv_api_t)9, 265 264 IWL_UCODE_TLV_API_WIDE_CMD_HDR = (__force iwl_ucode_tlv_api_t)14, 266 265 IWL_UCODE_TLV_API_LQ_SS_PARAMS = (__force iwl_ucode_tlv_api_t)18, 266 + IWL_UCODE_TLV_API_NEW_VERSION = (__force iwl_ucode_tlv_api_t)20, 267 267 IWL_UCODE_TLV_API_EXT_SCAN_PRIORITY = (__force iwl_ucode_tlv_api_t)24, 268 268 IWL_UCODE_TLV_API_TX_POWER_CHAIN = (__force iwl_ucode_tlv_api_t)27, 269 269
+18 -17
drivers/net/wireless/intersil/prism54/isl_38xx.c
··· 19 19 #include <linux/module.h> 20 20 #include <linux/types.h> 21 21 #include <linux/delay.h> 22 + #include <linux/ktime.h> 22 23 23 24 #include <asm/uaccess.h> 24 25 #include <asm/io.h> ··· 114 113 115 114 #if VERBOSE > SHOW_ERROR_MESSAGES 116 115 u32 counter = 0; 117 - struct timeval current_time; 116 + struct timespec64 current_ts64; 118 117 DEBUG(SHOW_FUNCTION_CALLS, "isl38xx trigger device\n"); 119 118 #endif 120 119 ··· 122 121 if (asleep) { 123 122 /* device is in powersave, trigger the device for wakeup */ 124 123 #if VERBOSE > SHOW_ERROR_MESSAGES 125 - do_gettimeofday(&current_time); 126 - DEBUG(SHOW_TRACING, "%08li.%08li Device wakeup triggered\n", 127 - current_time.tv_sec, (long)current_time.tv_usec); 124 + ktime_get_real_ts64(&current_ts64); 125 + DEBUG(SHOW_TRACING, "%lld.%09ld Device wakeup triggered\n", 126 + (s64)current_ts64.tv_sec, current_ts64.tv_nsec); 128 127 129 - DEBUG(SHOW_TRACING, "%08li.%08li Device register read %08x\n", 130 - current_time.tv_sec, (long)current_time.tv_usec, 128 + DEBUG(SHOW_TRACING, "%lld.%09ld Device register read %08x\n", 129 + (s64)current_ts64.tv_sec, current_ts64.tv_nsec, 131 130 readl(device_base + ISL38XX_CTRL_STAT_REG)); 132 131 #endif 133 132 134 133 reg = readl(device_base + ISL38XX_INT_IDENT_REG); 135 134 if (reg == 0xabadface) { 136 135 #if VERBOSE > SHOW_ERROR_MESSAGES 137 - do_gettimeofday(&current_time); 136 + ktime_get_real_ts64(&current_ts64); 138 137 DEBUG(SHOW_TRACING, 139 - "%08li.%08li Device register abadface\n", 140 - current_time.tv_sec, (long)current_time.tv_usec); 138 + "%lld.%09ld Device register abadface\n", 139 + (s64)current_ts64.tv_sec, current_ts64.tv_nsec); 141 140 #endif 142 141 /* read the Device Status Register until Sleepmode bit is set */ 143 142 while (reg = readl(device_base + ISL38XX_CTRL_STAT_REG), ··· 150 149 151 150 #if VERBOSE > SHOW_ERROR_MESSAGES 152 151 DEBUG(SHOW_TRACING, 153 - "%08li.%08li Device register read %08x\n", 154 - current_time.tv_sec, (long)current_time.tv_usec, 152 + "%lld.%09ld Device register read %08x\n", 153 + (s64)current_ts64.tv_sec, current_ts64.tv_nsec, 155 154 readl(device_base + ISL38XX_CTRL_STAT_REG)); 156 - do_gettimeofday(&current_time); 155 + ktime_get_real_ts64(&current_ts64); 157 156 DEBUG(SHOW_TRACING, 158 - "%08li.%08li Device asleep counter %i\n", 159 - current_time.tv_sec, (long)current_time.tv_usec, 157 + "%lld.%09ld Device asleep counter %i\n", 158 + (s64)current_ts64.tv_sec, current_ts64.tv_nsec, 160 159 counter); 161 160 #endif 162 161 } ··· 169 168 170 169 /* perform another read on the Device Status Register */ 171 170 reg = readl(device_base + ISL38XX_CTRL_STAT_REG); 172 - do_gettimeofday(&current_time); 173 - DEBUG(SHOW_TRACING, "%08li.%08li Device register read %08x\n", 174 - current_time.tv_sec, (long)current_time.tv_usec, reg); 171 + ktime_get_real_ts64(&current_ts64); 172 + DEBUG(SHOW_TRACING, "%lld.%00ld Device register read %08x\n", 173 + (s64)current_ts64.tv_sec, current_ts64.tv_nsec, reg); 175 174 #endif 176 175 } else { 177 176 /* device is (still) awake */
+7 -6
drivers/net/wireless/marvell/mwifiex/cfg80211.c
··· 3344 3344 struct mwifiex_ds_wakeup_reason wakeup_reason; 3345 3345 struct cfg80211_wowlan_wakeup wakeup_report; 3346 3346 int i; 3347 + bool report_wakeup_reason = true; 3347 3348 3348 3349 for (i = 0; i < adapter->priv_num; i++) { 3349 3350 priv = adapter->priv[i]; ··· 3354 3353 mwifiex_wake_up_net_dev_queue(priv->netdev, adapter); 3355 3354 } 3356 3355 } 3356 + 3357 + if (!wiphy->wowlan_config) 3358 + goto done; 3357 3359 3358 3360 priv = mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_STA); 3359 3361 mwifiex_get_wakeup_reason(priv, HostCmd_ACT_GEN_GET, MWIFIEX_SYNC_CMD, ··· 3390 3386 if (wiphy->wowlan_config->n_patterns) 3391 3387 wakeup_report.pattern_idx = 1; 3392 3388 break; 3393 - case CONTROL_FRAME_MATCHED: 3394 - break; 3395 - case MANAGEMENT_FRAME_MATCHED: 3396 - break; 3397 3389 case GTK_REKEY_FAILURE: 3398 3390 if (wiphy->wowlan_config->gtk_rekey_failure) 3399 3391 wakeup_report.gtk_rekey_failure = true; 3400 3392 break; 3401 3393 default: 3394 + report_wakeup_reason = false; 3402 3395 break; 3403 3396 } 3404 3397 3405 - if ((wakeup_reason.hs_wakeup_reason > 0) && 3406 - (wakeup_reason.hs_wakeup_reason <= 7)) 3398 + if (report_wakeup_reason) 3407 3399 cfg80211_report_wowlan_wakeup(&priv->wdev, &wakeup_report, 3408 3400 GFP_KERNEL); 3409 3401 3402 + done: 3410 3403 if (adapter->nd_info) { 3411 3404 for (i = 0 ; i < adapter->nd_info->n_matches ; i++) 3412 3405 kfree(adapter->nd_info->matches[i]);
+62 -65
drivers/net/wireless/marvell/mwifiex/cmdevt.c
··· 105 105 } 106 106 107 107 /* 108 + * This function returns a command to the command free queue. 109 + * 110 + * The function also calls the completion callback if required, before 111 + * cleaning the command node and re-inserting it into the free queue. 112 + */ 113 + static void 114 + mwifiex_insert_cmd_to_free_q(struct mwifiex_adapter *adapter, 115 + struct cmd_ctrl_node *cmd_node) 116 + { 117 + unsigned long flags; 118 + 119 + if (!cmd_node) 120 + return; 121 + 122 + if (cmd_node->wait_q_enabled) 123 + mwifiex_complete_cmd(adapter, cmd_node); 124 + /* Clean the node */ 125 + mwifiex_clean_cmd_node(adapter, cmd_node); 126 + 127 + /* Insert node into cmd_free_q */ 128 + spin_lock_irqsave(&adapter->cmd_free_q_lock, flags); 129 + list_add_tail(&cmd_node->list, &adapter->cmd_free_q); 130 + spin_unlock_irqrestore(&adapter->cmd_free_q_lock, flags); 131 + } 132 + 133 + /* This function reuses a command node. */ 134 + void mwifiex_recycle_cmd_node(struct mwifiex_adapter *adapter, 135 + struct cmd_ctrl_node *cmd_node) 136 + { 137 + struct host_cmd_ds_command *host_cmd = (void *)cmd_node->cmd_skb->data; 138 + 139 + mwifiex_insert_cmd_to_free_q(adapter, cmd_node); 140 + 141 + atomic_dec(&adapter->cmd_pending); 142 + mwifiex_dbg(adapter, CMD, 143 + "cmd: FREE_CMD: cmd=%#x, cmd_pending=%d\n", 144 + le16_to_cpu(host_cmd->command), 145 + atomic_read(&adapter->cmd_pending)); 146 + } 147 + 148 + /* 108 149 * This function sends a host command to the firmware. 109 150 * 110 151 * The function copies the host command into the driver command ··· 655 614 } 656 615 657 616 /* 658 - * This function returns a command to the command free queue. 659 - * 660 - * The function also calls the completion callback if required, before 661 - * cleaning the command node and re-inserting it into the free queue. 662 - */ 663 - void 664 - mwifiex_insert_cmd_to_free_q(struct mwifiex_adapter *adapter, 665 - struct cmd_ctrl_node *cmd_node) 666 - { 667 - unsigned long flags; 668 - 669 - if (!cmd_node) 670 - return; 671 - 672 - if (cmd_node->wait_q_enabled) 673 - mwifiex_complete_cmd(adapter, cmd_node); 674 - /* Clean the node */ 675 - mwifiex_clean_cmd_node(adapter, cmd_node); 676 - 677 - /* Insert node into cmd_free_q */ 678 - spin_lock_irqsave(&adapter->cmd_free_q_lock, flags); 679 - list_add_tail(&cmd_node->list, &adapter->cmd_free_q); 680 - spin_unlock_irqrestore(&adapter->cmd_free_q_lock, flags); 681 - } 682 - 683 - /* This function reuses a command node. */ 684 - void mwifiex_recycle_cmd_node(struct mwifiex_adapter *adapter, 685 - struct cmd_ctrl_node *cmd_node) 686 - { 687 - struct host_cmd_ds_command *host_cmd = (void *)cmd_node->cmd_skb->data; 688 - 689 - mwifiex_insert_cmd_to_free_q(adapter, cmd_node); 690 - 691 - atomic_dec(&adapter->cmd_pending); 692 - mwifiex_dbg(adapter, CMD, 693 - "cmd: FREE_CMD: cmd=%#x, cmd_pending=%d\n", 694 - le16_to_cpu(host_cmd->command), 695 - atomic_read(&adapter->cmd_pending)); 696 - } 697 - 698 - /* 699 617 * This function queues a command to the command pending queue. 700 618 * 701 619 * This in effect adds the command to the command list to be executed. ··· 991 991 adapter->if_ops.card_reset(adapter); 992 992 } 993 993 994 + void 995 + mwifiex_cancel_pending_scan_cmd(struct mwifiex_adapter *adapter) 996 + { 997 + struct cmd_ctrl_node *cmd_node = NULL, *tmp_node; 998 + unsigned long flags; 999 + 1000 + /* Cancel all pending scan command */ 1001 + spin_lock_irqsave(&adapter->scan_pending_q_lock, flags); 1002 + list_for_each_entry_safe(cmd_node, tmp_node, 1003 + &adapter->scan_pending_q, list) { 1004 + list_del(&cmd_node->list); 1005 + cmd_node->wait_q_enabled = false; 1006 + mwifiex_insert_cmd_to_free_q(adapter, cmd_node); 1007 + } 1008 + spin_unlock_irqrestore(&adapter->scan_pending_q_lock, flags); 1009 + } 1010 + 994 1011 /* 995 1012 * This function cancels all the pending commands. 996 1013 * ··· 1026 1009 spin_lock_irqsave(&adapter->mwifiex_cmd_lock, cmd_flags); 1027 1010 /* Cancel current cmd */ 1028 1011 if ((adapter->curr_cmd) && (adapter->curr_cmd->wait_q_enabled)) { 1029 - adapter->curr_cmd->wait_q_enabled = false; 1030 1012 adapter->cmd_wait_q.status = -1; 1031 1013 mwifiex_complete_cmd(adapter, adapter->curr_cmd); 1014 + adapter->curr_cmd->wait_q_enabled = false; 1032 1015 /* no recycle probably wait for response */ 1033 1016 } 1034 1017 /* Cancel all pending command */ ··· 1046 1029 spin_unlock_irqrestore(&adapter->cmd_pending_q_lock, flags); 1047 1030 spin_unlock_irqrestore(&adapter->mwifiex_cmd_lock, cmd_flags); 1048 1031 1049 - /* Cancel all pending scan command */ 1050 - spin_lock_irqsave(&adapter->scan_pending_q_lock, flags); 1051 - list_for_each_entry_safe(cmd_node, tmp_node, 1052 - &adapter->scan_pending_q, list) { 1053 - list_del(&cmd_node->list); 1054 - 1055 - cmd_node->wait_q_enabled = false; 1056 - mwifiex_insert_cmd_to_free_q(adapter, cmd_node); 1057 - } 1058 - spin_unlock_irqrestore(&adapter->scan_pending_q_lock, flags); 1032 + mwifiex_cancel_pending_scan_cmd(adapter); 1059 1033 1060 1034 if (adapter->scan_processing) { 1061 1035 spin_lock_irqsave(&adapter->mwifiex_cmd_lock, cmd_flags); ··· 1078 1070 void 1079 1071 mwifiex_cancel_pending_ioctl(struct mwifiex_adapter *adapter) 1080 1072 { 1081 - struct cmd_ctrl_node *cmd_node = NULL, *tmp_node = NULL; 1073 + struct cmd_ctrl_node *cmd_node = NULL; 1082 1074 unsigned long cmd_flags; 1083 - unsigned long scan_pending_q_flags; 1084 1075 struct mwifiex_private *priv; 1085 1076 int i; 1086 1077 ··· 1101 1094 mwifiex_recycle_cmd_node(adapter, cmd_node); 1102 1095 } 1103 1096 1104 - /* Cancel all pending scan command */ 1105 - spin_lock_irqsave(&adapter->scan_pending_q_lock, 1106 - scan_pending_q_flags); 1107 - list_for_each_entry_safe(cmd_node, tmp_node, 1108 - &adapter->scan_pending_q, list) { 1109 - list_del(&cmd_node->list); 1110 - cmd_node->wait_q_enabled = false; 1111 - mwifiex_insert_cmd_to_free_q(adapter, cmd_node); 1112 - } 1113 - spin_unlock_irqrestore(&adapter->scan_pending_q_lock, 1114 - scan_pending_q_flags); 1097 + mwifiex_cancel_pending_scan_cmd(adapter); 1115 1098 1116 1099 if (adapter->scan_processing) { 1117 1100 spin_lock_irqsave(&adapter->mwifiex_cmd_lock, cmd_flags);
+8 -8
drivers/net/wireless/marvell/mwifiex/main.c
··· 702 702 priv->scan_aborting = true; 703 703 } 704 704 705 + if (priv->sched_scanning) { 706 + mwifiex_dbg(priv->adapter, INFO, 707 + "aborting bgscan on ndo_stop\n"); 708 + mwifiex_stop_bg_scan(priv); 709 + cfg80211_sched_scan_stopped(priv->wdev.wiphy); 710 + } 711 + 705 712 return 0; 706 713 } 707 714 ··· 759 752 } 760 753 761 754 mwifiex_queue_main_work(priv->adapter); 762 - 763 - if (priv->sched_scanning) { 764 - mwifiex_dbg(priv->adapter, INFO, 765 - "aborting bgscan on ndo_stop\n"); 766 - mwifiex_stop_bg_scan(priv); 767 - cfg80211_sched_scan_stopped(priv->wdev.wiphy); 768 - } 769 755 770 756 return 0; 771 757 } ··· 1434 1434 struct mwifiex_private *priv = NULL; 1435 1435 int i; 1436 1436 1437 - if (down_interruptible(sem)) 1437 + if (down_trylock(sem)) 1438 1438 goto exit_sem_err; 1439 1439 1440 1440 if (!adapter)
+14 -4
drivers/net/wireless/marvell/mwifiex/main.h
··· 37 37 #include <linux/idr.h> 38 38 #include <linux/inetdevice.h> 39 39 #include <linux/devcoredump.h> 40 + #include <linux/err.h> 41 + #include <linux/gpio.h> 42 + #include <linux/gfp.h> 43 + #include <linux/interrupt.h> 44 + #include <linux/io.h> 45 + #include <linux/of_gpio.h> 46 + #include <linux/of_platform.h> 47 + #include <linux/platform_device.h> 48 + #include <linux/pm_runtime.h> 49 + #include <linux/slab.h> 50 + #include <linux/of_irq.h> 40 51 41 52 #include "decl.h" 42 53 #include "ioctl.h" ··· 111 100 #define SCAN_BEACON_ENTRY_PAD 6 112 101 113 102 #define MWIFIEX_PASSIVE_SCAN_CHAN_TIME 110 114 - #define MWIFIEX_ACTIVE_SCAN_CHAN_TIME 30 115 - #define MWIFIEX_SPECIFIC_SCAN_CHAN_TIME 30 103 + #define MWIFIEX_ACTIVE_SCAN_CHAN_TIME 40 104 + #define MWIFIEX_SPECIFIC_SCAN_CHAN_TIME 40 116 105 #define MWIFIEX_DEF_SCAN_CHAN_GAP_TIME 50 117 106 118 107 #define SCAN_RSSI(RSSI) (0x100 - ((u8)(RSSI))) ··· 1053 1042 int mwifiex_free_cmd_buffer(struct mwifiex_adapter *adapter); 1054 1043 void mwifiex_cancel_all_pending_cmd(struct mwifiex_adapter *adapter); 1055 1044 void mwifiex_cancel_pending_ioctl(struct mwifiex_adapter *adapter); 1045 + void mwifiex_cancel_pending_scan_cmd(struct mwifiex_adapter *adapter); 1056 1046 1057 - void mwifiex_insert_cmd_to_free_q(struct mwifiex_adapter *adapter, 1058 - struct cmd_ctrl_node *cmd_node); 1059 1047 void mwifiex_recycle_cmd_node(struct mwifiex_adapter *adapter, 1060 1048 struct cmd_ctrl_node *cmd_node); 1061 1049
+19 -2
drivers/net/wireless/marvell/mwifiex/pcie.c
··· 2811 2811 static void mwifiex_pcie_get_fw_name(struct mwifiex_adapter *adapter) 2812 2812 { 2813 2813 int revision_id = 0; 2814 + int version; 2814 2815 struct pcie_service_card *card = adapter->card; 2815 2816 2816 2817 switch (card->dev->device) { ··· 2830 2829 strcpy(adapter->fw_name, PCIE8897_B0_FW_NAME); 2831 2830 break; 2832 2831 default: 2832 + strcpy(adapter->fw_name, PCIE8897_DEFAULT_FW_NAME); 2833 + 2833 2834 break; 2834 2835 } 2836 + break; 2835 2837 case PCIE_DEVICE_ID_MARVELL_88W8997: 2836 2838 mwifiex_read_reg(adapter, 0x0c48, &revision_id); 2839 + mwifiex_read_reg(adapter, 0x0cd0, &version); 2840 + version &= 0x7; 2837 2841 switch (revision_id) { 2838 2842 case PCIE8997_V2: 2839 - strcpy(adapter->fw_name, PCIE8997_FW_NAME_V2); 2843 + if (version == CHIP_VER_PCIEUSB) 2844 + strcpy(adapter->fw_name, 2845 + PCIEUSB8997_FW_NAME_V2); 2846 + else 2847 + strcpy(adapter->fw_name, 2848 + PCIEUART8997_FW_NAME_V2); 2840 2849 break; 2841 2850 case PCIE8997_Z: 2842 - strcpy(adapter->fw_name, PCIE8997_FW_NAME_Z); 2851 + if (version == CHIP_VER_PCIEUSB) 2852 + strcpy(adapter->fw_name, 2853 + PCIEUSB8997_FW_NAME_Z); 2854 + else 2855 + strcpy(adapter->fw_name, 2856 + PCIEUART8997_FW_NAME_Z); 2843 2857 break; 2844 2858 default: 2859 + strcpy(adapter->fw_name, PCIE8997_DEFAULT_FW_NAME); 2845 2860 break; 2846 2861 } 2847 2862 default:
+7 -2
drivers/net/wireless/marvell/mwifiex/pcie.h
··· 30 30 #include "main.h" 31 31 32 32 #define PCIE8766_DEFAULT_FW_NAME "mrvl/pcie8766_uapsta.bin" 33 + #define PCIE8897_DEFAULT_FW_NAME "mrvl/pcie8897_uapsta.bin" 33 34 #define PCIE8897_A0_FW_NAME "mrvl/pcie8897_uapsta_a0.bin" 34 35 #define PCIE8897_B0_FW_NAME "mrvl/pcie8897_uapsta.bin" 35 - #define PCIE8997_FW_NAME_Z "mrvl/pcieusb8997_combo.bin" 36 - #define PCIE8997_FW_NAME_V2 "mrvl/pcieusb8997_combo_v2.bin" 36 + #define PCIE8997_DEFAULT_FW_NAME "mrvl/pcieuart8997_combo_v2.bin" 37 + #define PCIEUART8997_FW_NAME_Z "mrvl/pcieuart8997_combo.bin" 38 + #define PCIEUART8997_FW_NAME_V2 "mrvl/pcieuart8997_combo_v2.bin" 39 + #define PCIEUSB8997_FW_NAME_Z "mrvl/pcieusb8997_combo.bin" 40 + #define PCIEUSB8997_FW_NAME_V2 "mrvl/pcieusb8997_combo_v2.bin" 37 41 38 42 #define PCIE_VENDOR_ID_MARVELL (0x11ab) 39 43 #define PCIE_VENDOR_ID_V2_MARVELL (0x1b4b) ··· 49 45 #define PCIE8897_B0 0x1200 50 46 #define PCIE8997_Z 0x0 51 47 #define PCIE8997_V2 0x471 48 + #define CHIP_VER_PCIEUSB 0x2 52 49 53 50 /* Constants for Buffer Descriptor (BD) rings */ 54 51 #define MWIFIEX_MAX_TXRX_BD 0x20
+70 -124
drivers/net/wireless/marvell/mwifiex/scan.c
··· 76 76 { 0x00, 0x0f, 0xac, 0x04 }, /* AES */ 77 77 }; 78 78 79 + static void 80 + _dbg_security_flags(int log_level, const char *func, const char *desc, 81 + struct mwifiex_private *priv, 82 + struct mwifiex_bssdescriptor *bss_desc) 83 + { 84 + _mwifiex_dbg(priv->adapter, log_level, 85 + "info: %s: %s:\twpa_ie=%#x wpa2_ie=%#x WEP=%s WPA=%s WPA2=%s\tEncMode=%#x privacy=%#x\n", 86 + func, desc, 87 + bss_desc->bcn_wpa_ie ? 88 + bss_desc->bcn_wpa_ie->vend_hdr.element_id : 0, 89 + bss_desc->bcn_rsn_ie ? 90 + bss_desc->bcn_rsn_ie->ieee_hdr.element_id : 0, 91 + priv->sec_info.wep_enabled ? "e" : "d", 92 + priv->sec_info.wpa_enabled ? "e" : "d", 93 + priv->sec_info.wpa2_enabled ? "e" : "d", 94 + priv->sec_info.encryption_mode, 95 + bss_desc->privacy); 96 + } 97 + #define dbg_security_flags(mask, desc, priv, bss_desc) \ 98 + _dbg_security_flags(MWIFIEX_DBG_##mask, desc, __func__, priv, bss_desc) 99 + 100 + static bool 101 + has_ieee_hdr(struct ieee_types_generic *ie, u8 key) 102 + { 103 + return (ie && ie->ieee_hdr.element_id == key); 104 + } 105 + 106 + static bool 107 + has_vendor_hdr(struct ieee_types_vendor_specific *ie, u8 key) 108 + { 109 + return (ie && ie->vend_hdr.element_id == key); 110 + } 111 + 79 112 /* 80 113 * This function parses a given IE for a given OUI. 81 114 * ··· 154 121 struct ie_body *iebody; 155 122 u8 ret = MWIFIEX_OUI_NOT_PRESENT; 156 123 157 - if (((bss_desc->bcn_rsn_ie) && ((*(bss_desc->bcn_rsn_ie)). 158 - ieee_hdr.element_id == WLAN_EID_RSN))) { 124 + if (has_ieee_hdr(bss_desc->bcn_rsn_ie, WLAN_EID_RSN)) { 159 125 iebody = (struct ie_body *) 160 126 (((u8 *) bss_desc->bcn_rsn_ie->data) + 161 127 RSN_GTK_OUI_OFFSET); ··· 180 148 struct ie_body *iebody; 181 149 u8 ret = MWIFIEX_OUI_NOT_PRESENT; 182 150 183 - if (((bss_desc->bcn_wpa_ie) && 184 - ((*(bss_desc->bcn_wpa_ie)).vend_hdr.element_id == 185 - WLAN_EID_VENDOR_SPECIFIC))) { 151 + if (has_vendor_hdr(bss_desc->bcn_wpa_ie, WLAN_EID_VENDOR_SPECIFIC)) { 186 152 iebody = (struct ie_body *) bss_desc->bcn_wpa_ie->data; 187 153 oui = &mwifiex_wpa_oui[cipher][0]; 188 154 ret = mwifiex_search_oui_in_ie(iebody, oui); ··· 210 180 struct mwifiex_bssdescriptor *bss_desc) 211 181 { 212 182 if (priv->sec_info.wapi_enabled && 213 - (bss_desc->bcn_wapi_ie && 214 - ((*(bss_desc->bcn_wapi_ie)).ieee_hdr.element_id == 215 - WLAN_EID_BSS_AC_ACCESS_DELAY))) { 183 + has_ieee_hdr(bss_desc->bcn_wapi_ie, WLAN_EID_BSS_AC_ACCESS_DELAY)) 216 184 return true; 217 - } 218 185 return false; 219 186 } 220 187 ··· 224 197 struct mwifiex_bssdescriptor *bss_desc) 225 198 { 226 199 if (!priv->sec_info.wep_enabled && !priv->sec_info.wpa_enabled && 227 - !priv->sec_info.wpa2_enabled && ((!bss_desc->bcn_wpa_ie) || 228 - ((*(bss_desc->bcn_wpa_ie)).vend_hdr.element_id != 229 - WLAN_EID_VENDOR_SPECIFIC)) && 230 - ((!bss_desc->bcn_rsn_ie) || 231 - ((*(bss_desc->bcn_rsn_ie)).ieee_hdr.element_id != 232 - WLAN_EID_RSN)) && 200 + !priv->sec_info.wpa2_enabled && 201 + !has_vendor_hdr(bss_desc->bcn_wpa_ie, WLAN_EID_VENDOR_SPECIFIC) && 202 + !has_ieee_hdr(bss_desc->bcn_rsn_ie, WLAN_EID_RSN) && 233 203 !priv->sec_info.encryption_mode && !bss_desc->privacy) { 234 204 return true; 235 205 } ··· 257 233 struct mwifiex_bssdescriptor *bss_desc) 258 234 { 259 235 if (!priv->sec_info.wep_enabled && priv->sec_info.wpa_enabled && 260 - !priv->sec_info.wpa2_enabled && ((bss_desc->bcn_wpa_ie) && 261 - ((*(bss_desc->bcn_wpa_ie)). 262 - vend_hdr.element_id == WLAN_EID_VENDOR_SPECIFIC)) 236 + !priv->sec_info.wpa2_enabled && 237 + has_vendor_hdr(bss_desc->bcn_wpa_ie, WLAN_EID_VENDOR_SPECIFIC) 263 238 /* 264 239 * Privacy bit may NOT be set in some APs like 265 240 * LinkSys WRT54G && bss_desc->privacy 266 241 */ 267 242 ) { 268 - mwifiex_dbg(priv->adapter, INFO, 269 - "info: %s: WPA:\t" 270 - "wpa_ie=%#x wpa2_ie=%#x WEP=%s WPA=%s WPA2=%s\t" 271 - "EncMode=%#x privacy=%#x\n", __func__, 272 - (bss_desc->bcn_wpa_ie) ? 273 - (*bss_desc->bcn_wpa_ie). 274 - vend_hdr.element_id : 0, 275 - (bss_desc->bcn_rsn_ie) ? 276 - (*bss_desc->bcn_rsn_ie). 277 - ieee_hdr.element_id : 0, 278 - (priv->sec_info.wep_enabled) ? "e" : "d", 279 - (priv->sec_info.wpa_enabled) ? "e" : "d", 280 - (priv->sec_info.wpa2_enabled) ? "e" : "d", 281 - priv->sec_info.encryption_mode, 282 - bss_desc->privacy); 243 + dbg_security_flags(INFO, "WPA", priv, bss_desc); 283 244 return true; 284 245 } 285 246 return false; ··· 278 269 mwifiex_is_bss_wpa2(struct mwifiex_private *priv, 279 270 struct mwifiex_bssdescriptor *bss_desc) 280 271 { 281 - if (!priv->sec_info.wep_enabled && 282 - !priv->sec_info.wpa_enabled && 272 + if (!priv->sec_info.wep_enabled && !priv->sec_info.wpa_enabled && 283 273 priv->sec_info.wpa2_enabled && 284 - ((bss_desc->bcn_rsn_ie) && 285 - ((*(bss_desc->bcn_rsn_ie)).ieee_hdr.element_id == WLAN_EID_RSN))) { 274 + has_ieee_hdr(bss_desc->bcn_rsn_ie, WLAN_EID_RSN)) { 286 275 /* 287 276 * Privacy bit may NOT be set in some APs like 288 277 * LinkSys WRT54G && bss_desc->privacy 289 278 */ 290 - mwifiex_dbg(priv->adapter, INFO, 291 - "info: %s: WPA2:\t" 292 - "wpa_ie=%#x wpa2_ie=%#x WEP=%s WPA=%s WPA2=%s\t" 293 - "EncMode=%#x privacy=%#x\n", __func__, 294 - (bss_desc->bcn_wpa_ie) ? 295 - (*bss_desc->bcn_wpa_ie). 296 - vend_hdr.element_id : 0, 297 - (bss_desc->bcn_rsn_ie) ? 298 - (*bss_desc->bcn_rsn_ie). 299 - ieee_hdr.element_id : 0, 300 - (priv->sec_info.wep_enabled) ? "e" : "d", 301 - (priv->sec_info.wpa_enabled) ? "e" : "d", 302 - (priv->sec_info.wpa2_enabled) ? "e" : "d", 303 - priv->sec_info.encryption_mode, 304 - bss_desc->privacy); 279 + dbg_security_flags(INFO, "WAP2", priv, bss_desc); 305 280 return true; 306 281 } 307 282 return false; ··· 301 308 { 302 309 if (!priv->sec_info.wep_enabled && !priv->sec_info.wpa_enabled && 303 310 !priv->sec_info.wpa2_enabled && 304 - ((!bss_desc->bcn_wpa_ie) || 305 - ((*(bss_desc->bcn_wpa_ie)). 306 - vend_hdr.element_id != WLAN_EID_VENDOR_SPECIFIC)) && 307 - ((!bss_desc->bcn_rsn_ie) || 308 - ((*(bss_desc->bcn_rsn_ie)).ieee_hdr.element_id != WLAN_EID_RSN)) && 311 + !has_vendor_hdr(bss_desc->bcn_wpa_ie, WLAN_EID_VENDOR_SPECIFIC) && 312 + !has_ieee_hdr(bss_desc->bcn_rsn_ie, WLAN_EID_RSN) && 309 313 !priv->sec_info.encryption_mode && bss_desc->privacy) { 310 314 return true; 311 315 } ··· 319 329 { 320 330 if (!priv->sec_info.wep_enabled && !priv->sec_info.wpa_enabled && 321 331 !priv->sec_info.wpa2_enabled && 322 - ((!bss_desc->bcn_wpa_ie) || 323 - ((*(bss_desc->bcn_wpa_ie)). 324 - vend_hdr.element_id != WLAN_EID_VENDOR_SPECIFIC)) && 325 - ((!bss_desc->bcn_rsn_ie) || 326 - ((*(bss_desc->bcn_rsn_ie)).ieee_hdr.element_id != WLAN_EID_RSN)) && 332 + !has_vendor_hdr(bss_desc->bcn_wpa_ie, WLAN_EID_VENDOR_SPECIFIC) && 333 + !has_ieee_hdr(bss_desc->bcn_rsn_ie, WLAN_EID_RSN) && 327 334 priv->sec_info.encryption_mode && bss_desc->privacy) { 328 - mwifiex_dbg(priv->adapter, INFO, 329 - "info: %s: dynamic\t" 330 - "WEP: wpa_ie=%#x wpa2_ie=%#x\t" 331 - "EncMode=%#x privacy=%#x\n", 332 - __func__, 333 - (bss_desc->bcn_wpa_ie) ? 334 - (*bss_desc->bcn_wpa_ie). 335 - vend_hdr.element_id : 0, 336 - (bss_desc->bcn_rsn_ie) ? 337 - (*bss_desc->bcn_rsn_ie). 338 - ieee_hdr.element_id : 0, 339 - priv->sec_info.encryption_mode, 340 - bss_desc->privacy); 335 + dbg_security_flags(INFO, "dynamic", priv, bss_desc); 341 336 return true; 342 337 } 343 338 return false; ··· 435 460 } 436 461 437 462 /* Security doesn't match */ 438 - mwifiex_dbg(adapter, ERROR, 439 - "info: %s: failed: wpa_ie=%#x wpa2_ie=%#x WEP=%s\t" 440 - "WPA=%s WPA2=%s EncMode=%#x privacy=%#x\n", 441 - __func__, 442 - (bss_desc->bcn_wpa_ie) ? 443 - (*bss_desc->bcn_wpa_ie).vend_hdr.element_id : 0, 444 - (bss_desc->bcn_rsn_ie) ? 445 - (*bss_desc->bcn_rsn_ie).ieee_hdr.element_id : 0, 446 - (priv->sec_info.wep_enabled) ? "e" : "d", 447 - (priv->sec_info.wpa_enabled) ? "e" : "d", 448 - (priv->sec_info.wpa2_enabled) ? "e" : "d", 449 - priv->sec_info.encryption_mode, bss_desc->privacy); 463 + dbg_security_flags(ERROR, "failed", priv, bss_desc); 450 464 return -1; 451 465 } 452 466 ··· 498 534 &= ~MWIFIEX_PASSIVE_SCAN; 499 535 scan_chan_list[chan_idx].chan_number = 500 536 (u32) ch->hw_value; 537 + 538 + scan_chan_list[chan_idx].chan_scan_mode_bitmap 539 + |= MWIFIEX_DISABLE_CHAN_FILT; 540 + 501 541 if (filtered_scan) { 502 542 scan_chan_list[chan_idx].max_scan_time = 503 543 cpu_to_le16(adapter->specific_scan_time); 504 - scan_chan_list[chan_idx].chan_scan_mode_bitmap 505 - |= MWIFIEX_DISABLE_CHAN_FILT; 506 544 } 507 545 chan_idx++; 508 546 } ··· 621 655 int ret = 0; 622 656 struct mwifiex_chan_scan_param_set *tmp_chan_list; 623 657 struct mwifiex_chan_scan_param_set *start_chan; 624 - struct cmd_ctrl_node *cmd_node, *tmp_node; 625 - unsigned long flags; 626 658 u32 tlv_idx, rates_size, cmd_no; 627 659 u32 total_scan_time; 628 660 u32 done_early; ··· 777 813 sizeof(struct mwifiex_ie_types_header) + rates_size; 778 814 779 815 if (ret) { 780 - spin_lock_irqsave(&adapter->scan_pending_q_lock, flags); 781 - list_for_each_entry_safe(cmd_node, tmp_node, 782 - &adapter->scan_pending_q, 783 - list) { 784 - list_del(&cmd_node->list); 785 - cmd_node->wait_q_enabled = false; 786 - mwifiex_insert_cmd_to_free_q(adapter, cmd_node); 787 - } 788 - spin_unlock_irqrestore(&adapter->scan_pending_q_lock, 789 - flags); 816 + mwifiex_cancel_pending_scan_cmd(adapter); 790 817 break; 791 818 } 792 819 } ··· 867 912 /* Set the BSS type scan filter, use Adapter setting if 868 913 unset */ 869 914 scan_cfg_out->bss_mode = 870 - (user_scan_in->bss_mode ? (u8) user_scan_in-> 871 - bss_mode : (u8) adapter->scan_mode); 915 + (u8)(user_scan_in->bss_mode ?: adapter->scan_mode); 872 916 873 917 /* Set the number of probes to send, use Adapter setting 874 918 if unset */ 875 - num_probes = 876 - (user_scan_in->num_probes ? user_scan_in-> 877 - num_probes : adapter->scan_probes); 919 + num_probes = user_scan_in->num_probes ?: adapter->scan_probes; 878 920 879 921 /* 880 922 * Set the BSSID filter to the incoming configuration, ··· 1046 1094 chan_idx++) { 1047 1095 1048 1096 channel = user_scan_in->chan_list[chan_idx].chan_number; 1049 - (scan_chan_list + chan_idx)->chan_number = channel; 1097 + scan_chan_list[chan_idx].chan_number = channel; 1050 1098 1051 1099 radio_type = 1052 1100 user_scan_in->chan_list[chan_idx].radio_type; 1053 - (scan_chan_list + chan_idx)->radio_type = radio_type; 1101 + scan_chan_list[chan_idx].radio_type = radio_type; 1054 1102 1055 1103 scan_type = user_scan_in->chan_list[chan_idx].scan_type; 1056 1104 1057 1105 if (scan_type == MWIFIEX_SCAN_TYPE_PASSIVE) 1058 - (scan_chan_list + 1059 - chan_idx)->chan_scan_mode_bitmap 1106 + scan_chan_list[chan_idx].chan_scan_mode_bitmap 1060 1107 |= (MWIFIEX_PASSIVE_SCAN | 1061 1108 MWIFIEX_HIDDEN_SSID_REPORT); 1062 1109 else 1063 - (scan_chan_list + 1064 - chan_idx)->chan_scan_mode_bitmap 1110 + scan_chan_list[chan_idx].chan_scan_mode_bitmap 1065 1111 &= ~MWIFIEX_PASSIVE_SCAN; 1066 1112 1067 - if (*filtered_scan) 1068 - (scan_chan_list + 1069 - chan_idx)->chan_scan_mode_bitmap 1070 - |= MWIFIEX_DISABLE_CHAN_FILT; 1113 + scan_chan_list[chan_idx].chan_scan_mode_bitmap 1114 + |= MWIFIEX_DISABLE_CHAN_FILT; 1071 1115 1072 1116 if (user_scan_in->chan_list[chan_idx].scan_time) { 1073 1117 scan_dur = (u16) user_scan_in-> ··· 1077 1129 scan_dur = adapter->active_scan_time; 1078 1130 } 1079 1131 1080 - (scan_chan_list + chan_idx)->min_scan_time = 1132 + scan_chan_list[chan_idx].min_scan_time = 1081 1133 cpu_to_le16(scan_dur); 1082 - (scan_chan_list + chan_idx)->max_scan_time = 1134 + scan_chan_list[chan_idx].max_scan_time = 1083 1135 cpu_to_le16(scan_dur); 1084 1136 } 1085 1137 ··· 1939 1991 static void mwifiex_check_next_scan_command(struct mwifiex_private *priv) 1940 1992 { 1941 1993 struct mwifiex_adapter *adapter = priv->adapter; 1942 - struct cmd_ctrl_node *cmd_node, *tmp_node; 1994 + struct cmd_ctrl_node *cmd_node; 1943 1995 unsigned long flags; 1944 1996 1945 1997 spin_lock_irqsave(&adapter->scan_pending_q_lock, flags); 1946 1998 if (list_empty(&adapter->scan_pending_q)) { 1947 1999 spin_unlock_irqrestore(&adapter->scan_pending_q_lock, flags); 2000 + 1948 2001 spin_lock_irqsave(&adapter->mwifiex_cmd_lock, flags); 1949 2002 adapter->scan_processing = false; 1950 2003 spin_unlock_irqrestore(&adapter->mwifiex_cmd_lock, flags); ··· 1967 2018 } 1968 2019 } else if ((priv->scan_aborting && !priv->scan_request) || 1969 2020 priv->scan_block) { 1970 - list_for_each_entry_safe(cmd_node, tmp_node, 1971 - &adapter->scan_pending_q, list) { 1972 - list_del(&cmd_node->list); 1973 - mwifiex_insert_cmd_to_free_q(adapter, cmd_node); 1974 - } 1975 2021 spin_unlock_irqrestore(&adapter->scan_pending_q_lock, flags); 2022 + 2023 + mwifiex_cancel_pending_scan_cmd(adapter); 1976 2024 1977 2025 spin_lock_irqsave(&adapter->mwifiex_cmd_lock, flags); 1978 2026 adapter->scan_processing = false;
+78 -2
drivers/net/wireless/marvell/mwifiex/sdio.c
··· 73 73 {"EXTLAST", NULL, 0, 0xFE}, 74 74 }; 75 75 76 + static const struct of_device_id mwifiex_sdio_of_match_table[] = { 77 + { .compatible = "marvell,sd8897" }, 78 + { .compatible = "marvell,sd8997" }, 79 + { } 80 + }; 81 + 82 + static irqreturn_t mwifiex_wake_irq_wifi(int irq, void *priv) 83 + { 84 + struct mwifiex_plt_wake_cfg *cfg = priv; 85 + 86 + if (cfg->irq_wifi >= 0) { 87 + pr_info("%s: wake by wifi", __func__); 88 + cfg->wake_by_wifi = true; 89 + disable_irq_nosync(irq); 90 + } 91 + 92 + return IRQ_HANDLED; 93 + } 94 + 95 + /* This function parse device tree node using mmc subnode devicetree API. 96 + * The device node is saved in card->plt_of_node. 97 + * if the device tree node exist and include interrupts attributes, this 98 + * function will also request platform specific wakeup interrupt. 99 + */ 100 + static int mwifiex_sdio_probe_of(struct device *dev, struct sdio_mmc_card *card) 101 + { 102 + struct mwifiex_plt_wake_cfg *cfg; 103 + int ret; 104 + 105 + if (!dev->of_node || 106 + !of_match_node(mwifiex_sdio_of_match_table, dev->of_node)) { 107 + pr_err("sdio platform data not available"); 108 + return -1; 109 + } 110 + 111 + card->plt_of_node = dev->of_node; 112 + card->plt_wake_cfg = devm_kzalloc(dev, sizeof(*card->plt_wake_cfg), 113 + GFP_KERNEL); 114 + cfg = card->plt_wake_cfg; 115 + if (cfg && card->plt_of_node) { 116 + cfg->irq_wifi = irq_of_parse_and_map(card->plt_of_node, 0); 117 + if (!cfg->irq_wifi) { 118 + dev_err(dev, "fail to parse irq_wifi from device tree"); 119 + } else { 120 + ret = devm_request_irq(dev, cfg->irq_wifi, 121 + mwifiex_wake_irq_wifi, 122 + IRQF_TRIGGER_LOW, 123 + "wifi_wake", cfg); 124 + if (ret) { 125 + dev_err(dev, 126 + "Failed to request irq_wifi %d (%d)\n", 127 + cfg->irq_wifi, ret); 128 + } 129 + disable_irq(cfg->irq_wifi); 130 + } 131 + } 132 + 133 + return 0; 134 + } 135 + 76 136 /* 77 137 * SDIO probe. 78 138 * ··· 186 126 kfree(card); 187 127 return -EIO; 188 128 } 129 + 130 + /* device tree node parsing and platform specific configuration*/ 131 + mwifiex_sdio_probe_of(&func->dev, card); 189 132 190 133 if (mwifiex_add_card(card, &add_remove_card_sem, &sdio_ops, 191 134 MWIFIEX_SDIO)) { ··· 245 182 /* Disable Host Sleep */ 246 183 mwifiex_cancel_hs(mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_STA), 247 184 MWIFIEX_SYNC_CMD); 185 + 186 + /* Disable platform specific wakeup interrupt */ 187 + if (card->plt_wake_cfg && card->plt_wake_cfg->irq_wifi >= 0) { 188 + disable_irq_wake(card->plt_wake_cfg->irq_wifi); 189 + if (!card->plt_wake_cfg->wake_by_wifi) 190 + disable_irq(card->plt_wake_cfg->irq_wifi); 191 + } 248 192 249 193 return 0; 250 194 } ··· 331 261 } 332 262 333 263 adapter = card->adapter; 264 + 265 + /* Enable platform specific wakeup interrupt */ 266 + if (card->plt_wake_cfg && card->plt_wake_cfg->irq_wifi >= 0) { 267 + card->plt_wake_cfg->wake_by_wifi = false; 268 + enable_irq(card->plt_wake_cfg->irq_wifi); 269 + enable_irq_wake(card->plt_wake_cfg->irq_wifi); 270 + } 334 271 335 272 /* Enable the Host Sleep */ 336 273 if (!mwifiex_enable_hs(adapter)) { ··· 1103 1026 offset += txlen; 1104 1027 } while (true); 1105 1028 1106 - sdio_release_host(card->func); 1107 - 1108 1029 mwifiex_dbg(adapter, MSG, 1109 1030 "info: FW download over, size %d bytes\n", offset); 1110 1031 1111 1032 ret = 0; 1112 1033 done: 1034 + sdio_release_host(card->func); 1113 1035 kfree(fwbuf); 1114 1036 return ret; 1115 1037 }
+7
drivers/net/wireless/marvell/mwifiex/sdio.h
··· 154 154 a->mpa_rx.start_port = 0; \ 155 155 } while (0) 156 156 157 + struct mwifiex_plt_wake_cfg { 158 + int irq_wifi; 159 + bool wake_by_wifi; 160 + }; 161 + 157 162 /* data structure for SDIO MPA TX */ 158 163 struct mwifiex_sdio_mpa_tx { 159 164 /* multiport tx aggregation buffer pointer */ ··· 242 237 struct sdio_mmc_card { 243 238 struct sdio_func *func; 244 239 struct mwifiex_adapter *adapter; 240 + struct device_node *plt_of_node; 241 + struct mwifiex_plt_wake_cfg *plt_wake_cfg; 245 242 246 243 const char *firmware; 247 244 const struct mwifiex_sdio_card_reg *reg;
+11 -3
drivers/net/wireless/marvell/mwifiex/sta_cmd.c
··· 2162 2162 enum state_11d_t state_11d; 2163 2163 struct mwifiex_ds_11n_tx_cfg tx_cfg; 2164 2164 u8 sdio_sp_rx_aggr_enable; 2165 + int data; 2165 2166 2166 2167 if (first_sta) { 2167 2168 if (priv->adapter->iface_type == MWIFIEX_PCIE) { ··· 2183 2182 * The cal-data can be read from device tree and/or 2184 2183 * a configuration file and downloaded to firmware. 2185 2184 */ 2186 - adapter->dt_node = 2187 - of_find_node_by_name(NULL, "marvell_cfgdata"); 2188 - if (adapter->dt_node) { 2185 + if (priv->adapter->iface_type == MWIFIEX_SDIO && 2186 + adapter->dev->of_node) { 2187 + adapter->dt_node = adapter->dev->of_node; 2188 + if (of_property_read_u32(adapter->dt_node, 2189 + "marvell,wakeup-pin", 2190 + &data) == 0) { 2191 + pr_debug("Wakeup pin = 0x%x\n", data); 2192 + adapter->hs_cfg.gpio = data; 2193 + } 2194 + 2189 2195 ret = mwifiex_dnld_dt_cfgdata(priv, adapter->dt_node, 2190 2196 "marvell,caldata"); 2191 2197 if (ret)
+1 -12
drivers/net/wireless/marvell/mwifiex/sta_cmdresp.c
··· 44 44 mwifiex_process_cmdresp_error(struct mwifiex_private *priv, 45 45 struct host_cmd_ds_command *resp) 46 46 { 47 - struct cmd_ctrl_node *cmd_node = NULL, *tmp_node; 48 47 struct mwifiex_adapter *adapter = priv->adapter; 49 48 struct host_cmd_ds_802_11_ps_mode_enh *pm; 50 49 unsigned long flags; ··· 70 71 break; 71 72 case HostCmd_CMD_802_11_SCAN: 72 73 case HostCmd_CMD_802_11_SCAN_EXT: 73 - /* Cancel all pending scan command */ 74 - spin_lock_irqsave(&adapter->scan_pending_q_lock, flags); 75 - list_for_each_entry_safe(cmd_node, tmp_node, 76 - &adapter->scan_pending_q, list) { 77 - list_del(&cmd_node->list); 78 - spin_unlock_irqrestore(&adapter->scan_pending_q_lock, 79 - flags); 80 - mwifiex_insert_cmd_to_free_q(adapter, cmd_node); 81 - spin_lock_irqsave(&adapter->scan_pending_q_lock, flags); 82 - } 83 - spin_unlock_irqrestore(&adapter->scan_pending_q_lock, flags); 74 + mwifiex_cancel_pending_scan_cmd(adapter); 84 75 85 76 spin_lock_irqsave(&adapter->mwifiex_cmd_lock, flags); 86 77 adapter->scan_processing = false;
+43 -1
drivers/net/wireless/marvell/mwifiex/sta_ioctl.c
··· 146 146 size_t beacon_ie_len; 147 147 struct mwifiex_bss_priv *bss_priv = (void *)bss->priv; 148 148 const struct cfg80211_bss_ies *ies; 149 + int ret; 149 150 150 151 rcu_read_lock(); 151 152 ies = rcu_dereference(bss->ies); ··· 190 189 if (bss_desc->cap_info_bitmap & WLAN_CAPABILITY_SPECTRUM_MGMT) 191 190 bss_desc->sensed_11h = true; 192 191 193 - return mwifiex_update_bss_desc_with_ie(priv->adapter, bss_desc); 192 + ret = mwifiex_update_bss_desc_with_ie(priv->adapter, bss_desc); 193 + if (ret) 194 + return ret; 195 + 196 + /* Update HT40 capability based on current channel information */ 197 + if (bss_desc->bcn_ht_oper && bss_desc->bcn_ht_cap) { 198 + u8 ht_param = bss_desc->bcn_ht_oper->ht_param; 199 + u8 radio = mwifiex_band_to_radio_type(bss_desc->bss_band); 200 + struct ieee80211_supported_band *sband = 201 + priv->wdev.wiphy->bands[radio]; 202 + int freq = ieee80211_channel_to_frequency(bss_desc->channel, 203 + radio); 204 + struct ieee80211_channel *chan = 205 + ieee80211_get_channel(priv->adapter->wiphy, freq); 206 + 207 + switch (ht_param & IEEE80211_HT_PARAM_CHA_SEC_OFFSET) { 208 + case IEEE80211_HT_PARAM_CHA_SEC_ABOVE: 209 + if (chan->flags & IEEE80211_CHAN_NO_HT40PLUS) { 210 + sband->ht_cap.cap &= 211 + ~IEEE80211_HT_CAP_SUP_WIDTH_20_40; 212 + sband->ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_40; 213 + } else { 214 + sband->ht_cap.cap |= 215 + IEEE80211_HT_CAP_SUP_WIDTH_20_40 | 216 + IEEE80211_HT_CAP_SGI_40; 217 + } 218 + break; 219 + case IEEE80211_HT_PARAM_CHA_SEC_BELOW: 220 + if (chan->flags & IEEE80211_CHAN_NO_HT40MINUS) { 221 + sband->ht_cap.cap &= 222 + ~IEEE80211_HT_CAP_SUP_WIDTH_20_40; 223 + sband->ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_40; 224 + } else { 225 + sband->ht_cap.cap |= 226 + IEEE80211_HT_CAP_SUP_WIDTH_20_40 | 227 + IEEE80211_HT_CAP_SGI_40; 228 + } 229 + break; 230 + } 231 + } 232 + 233 + return 0; 194 234 } 195 235 196 236 void mwifiex_dnld_txpwr_table(struct mwifiex_private *priv)
+7 -6
drivers/net/wireless/marvell/mwifiex/txrx.c
··· 297 297 goto done; 298 298 299 299 mwifiex_set_trans_start(priv->netdev); 300 + 301 + if (tx_info->flags & MWIFIEX_BUF_FLAG_BRIDGED_PKT) 302 + atomic_dec_return(&adapter->pending_bridged_pkts); 303 + 304 + if (tx_info->flags & MWIFIEX_BUF_FLAG_AGGR_PKT) 305 + goto done; 306 + 300 307 if (!status) { 301 308 priv->stats.tx_packets++; 302 309 priv->stats.tx_bytes += tx_info->pkt_len; ··· 312 305 } else { 313 306 priv->stats.tx_errors++; 314 307 } 315 - 316 - if (tx_info->flags & MWIFIEX_BUF_FLAG_BRIDGED_PKT) 317 - atomic_dec_return(&adapter->pending_bridged_pkts); 318 - 319 - if (tx_info->flags & MWIFIEX_BUF_FLAG_AGGR_PKT) 320 - goto done; 321 308 322 309 if (aggr) 323 310 /* For skb_aggr, do not wake up tx queue */
+4
drivers/net/wireless/marvell/mwifiex/uap_txrx.c
··· 102 102 int hdr_chop; 103 103 struct ethhdr *p_ethhdr; 104 104 struct mwifiex_sta_node *src_node; 105 + int index; 105 106 106 107 uap_rx_pd = (struct uap_rxpd *)(skb->data); 107 108 rx_pkt_hdr = (void *)uap_rx_pd + le16_to_cpu(uap_rx_pd->rx_pkt_offset); ··· 209 208 } 210 209 211 210 __net_timestamp(skb); 211 + 212 + index = mwifiex_1d_to_wmm_queue[skb->priority]; 213 + atomic_inc(&priv->wmm_tx_pending[index]); 212 214 mwifiex_wmm_add_buf_txqueue(priv, skb); 213 215 atomic_inc(&adapter->tx_pending); 214 216 atomic_inc(&adapter->pending_bridged_pkts);
+7 -4
drivers/net/wireless/marvell/mwifiex/usb.c
··· 995 995 { 996 996 int ret = 0; 997 997 u8 *firmware = fw->fw_buf, *recv_buff; 998 - u32 retries = USB8XXX_FW_MAX_RETRY, dlen; 998 + u32 retries = USB8XXX_FW_MAX_RETRY + 1; 999 + u32 dlen; 999 1000 u32 fw_seqnum = 0, tlen = 0, dnld_cmd = 0; 1000 1001 struct fw_data *fwdata; 1001 1002 struct fw_sync_header sync_fw; ··· 1018 1017 1019 1018 /* Allocate memory for receive */ 1020 1019 recv_buff = kzalloc(FW_DNLD_RX_BUF_SIZE, GFP_KERNEL); 1021 - if (!recv_buff) 1020 + if (!recv_buff) { 1021 + ret = -ENOMEM; 1022 1022 goto cleanup; 1023 + } 1023 1024 1024 1025 do { 1025 1026 /* Send pseudo data to check winner status first */ ··· 1044 1041 } 1045 1042 1046 1043 /* If the send/receive fails or CRC occurs then retry */ 1047 - while (retries--) { 1044 + while (--retries) { 1048 1045 u8 *buf = (u8 *)fwdata; 1049 1046 u32 len = FW_DATA_XMIT_SIZE; 1050 1047 ··· 1104 1101 continue; 1105 1102 } 1106 1103 1107 - retries = USB8XXX_FW_MAX_RETRY; 1104 + retries = USB8XXX_FW_MAX_RETRY + 1; 1108 1105 break; 1109 1106 } 1110 1107 fw_seqnum++;
+4
drivers/net/wireless/ralink/rt2x00/rt2800lib.c
··· 7492 7492 if (!rt2x00_is_usb(rt2x00dev)) 7493 7493 ieee80211_hw_set(rt2x00dev->hw, HOST_BROADCAST_PS_BUFFERING); 7494 7494 7495 + /* Set MFP if HW crypto is disabled. */ 7496 + if (rt2800_hwcrypt_disabled(rt2x00dev)) 7497 + ieee80211_hw_set(rt2x00dev->hw, MFP_CAPABLE); 7498 + 7495 7499 SET_IEEE80211_DEV(rt2x00dev->hw, rt2x00dev->dev); 7496 7500 SET_IEEE80211_PERM_ADDR(rt2x00dev->hw, 7497 7501 rt2800_eeprom_addr(rt2x00dev,
+4
drivers/net/wireless/realtek/rtl818x/rtl8180/dev.c
··· 1018 1018 dma_addr_t *mapping; 1019 1019 entry = priv->rx_ring + priv->rx_ring_sz*i; 1020 1020 if (!skb) { 1021 + pci_free_consistent(priv->pdev, priv->rx_ring_sz * 32, 1022 + priv->rx_ring, priv->rx_ring_dma); 1021 1023 wiphy_err(dev->wiphy, "Cannot allocate RX skb\n"); 1022 1024 return -ENOMEM; 1023 1025 } ··· 1030 1028 1031 1029 if (pci_dma_mapping_error(priv->pdev, *mapping)) { 1032 1030 kfree_skb(skb); 1031 + pci_free_consistent(priv->pdev, priv->rx_ring_sz * 32, 1032 + priv->rx_ring, priv->rx_ring_dma); 1033 1033 wiphy_err(dev->wiphy, "Cannot map DMA for RX skb\n"); 1034 1034 return -ENOMEM; 1035 1035 }
+1918 -432
drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.c
··· 1 1 /* 2 2 * RTL8XXXU mac80211 USB driver 3 3 * 4 - * Copyright (c) 2014 - 2015 Jes Sorensen <Jes.Sorensen@redhat.com> 4 + * Copyright (c) 2014 - 2016 Jes Sorensen <Jes.Sorensen@redhat.com> 5 5 * 6 6 * Portions, notably calibration code: 7 7 * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. ··· 128 128 .n_bitrates = ARRAY_SIZE(rtl8xxxu_rates), 129 129 }; 130 130 131 - static struct rtl8xxxu_reg8val rtl8723a_mac_init_table[] = { 131 + static struct rtl8xxxu_reg8val rtl8xxxu_gen1_mac_init_table[] = { 132 132 {0x420, 0x80}, {0x423, 0x00}, {0x430, 0x00}, {0x431, 0x00}, 133 133 {0x432, 0x00}, {0x433, 0x01}, {0x434, 0x04}, {0x435, 0x05}, 134 134 {0x436, 0x06}, {0x437, 0x07}, {0x438, 0x00}, {0x439, 0x00}, ··· 182 182 {0x702, 0x65}, {0x703, 0x87}, {0x708, 0x21}, {0x709, 0x43}, 183 183 {0x70a, 0x65}, {0x70b, 0x87}, {0x765, 0x18}, {0x76e, 0x04}, 184 184 {0xffff, 0xff}, 185 + }; 186 + 187 + static struct rtl8xxxu_reg8val rtl8192e_mac_init_table[] = { 188 + {0x011, 0xeb}, {0x012, 0x07}, {0x014, 0x75}, {0x303, 0xa7}, 189 + {0x428, 0x0a}, {0x429, 0x10}, {0x430, 0x00}, {0x431, 0x00}, 190 + {0x432, 0x00}, {0x433, 0x01}, {0x434, 0x04}, {0x435, 0x05}, 191 + {0x436, 0x07}, {0x437, 0x08}, {0x43c, 0x04}, {0x43d, 0x05}, 192 + {0x43e, 0x07}, {0x43f, 0x08}, {0x440, 0x5d}, {0x441, 0x01}, 193 + {0x442, 0x00}, {0x444, 0x10}, {0x445, 0x00}, {0x446, 0x00}, 194 + {0x447, 0x00}, {0x448, 0x00}, {0x449, 0xf0}, {0x44a, 0x0f}, 195 + {0x44b, 0x3e}, {0x44c, 0x10}, {0x44d, 0x00}, {0x44e, 0x00}, 196 + {0x44f, 0x00}, {0x450, 0x00}, {0x451, 0xf0}, {0x452, 0x0f}, 197 + {0x453, 0x00}, {0x456, 0x5e}, {0x460, 0x66}, {0x461, 0x66}, 198 + {0x4c8, 0xff}, {0x4c9, 0x08}, {0x4cc, 0xff}, {0x4cd, 0xff}, 199 + {0x4ce, 0x01}, {0x500, 0x26}, {0x501, 0xa2}, {0x502, 0x2f}, 200 + {0x503, 0x00}, {0x504, 0x28}, {0x505, 0xa3}, {0x506, 0x5e}, 201 + {0x507, 0x00}, {0x508, 0x2b}, {0x509, 0xa4}, {0x50a, 0x5e}, 202 + {0x50b, 0x00}, {0x50c, 0x4f}, {0x50d, 0xa4}, {0x50e, 0x00}, 203 + {0x50f, 0x00}, {0x512, 0x1c}, {0x514, 0x0a}, {0x516, 0x0a}, 204 + {0x525, 0x4f}, {0x540, 0x12}, {0x541, 0x64}, {0x550, 0x10}, 205 + {0x551, 0x10}, {0x559, 0x02}, {0x55c, 0x50}, {0x55d, 0xff}, 206 + {0x605, 0x30}, {0x608, 0x0e}, {0x609, 0x2a}, {0x620, 0xff}, 207 + {0x621, 0xff}, {0x622, 0xff}, {0x623, 0xff}, {0x624, 0xff}, 208 + {0x625, 0xff}, {0x626, 0xff}, {0x627, 0xff}, {0x638, 0x50}, 209 + {0x63c, 0x0a}, {0x63d, 0x0a}, {0x63e, 0x0e}, {0x63f, 0x0e}, 210 + {0x640, 0x40}, {0x642, 0x40}, {0x643, 0x00}, {0x652, 0xc8}, 211 + {0x66e, 0x05}, {0x700, 0x21}, {0x701, 0x43}, {0x702, 0x65}, 212 + {0x703, 0x87}, {0x708, 0x21}, {0x709, 0x43}, {0x70a, 0x65}, 213 + {0x70b, 0x87}, 214 + {0xffff, 0xff}, 215 + }; 216 + 217 + #ifdef CONFIG_RTL8XXXU_UNTESTED 218 + static struct rtl8xxxu_power_base rtl8188r_power_base = { 219 + .reg_0e00 = 0x06080808, 220 + .reg_0e04 = 0x00040406, 221 + .reg_0e08 = 0x00000000, 222 + .reg_086c = 0x00000000, 223 + 224 + .reg_0e10 = 0x04060608, 225 + .reg_0e14 = 0x00020204, 226 + .reg_0e18 = 0x04060608, 227 + .reg_0e1c = 0x00020204, 228 + 229 + .reg_0830 = 0x06080808, 230 + .reg_0834 = 0x00040406, 231 + .reg_0838 = 0x00000000, 232 + .reg_086c_2 = 0x00000000, 233 + 234 + .reg_083c = 0x04060608, 235 + .reg_0848 = 0x00020204, 236 + .reg_084c = 0x04060608, 237 + .reg_0868 = 0x00020204, 238 + }; 239 + 240 + static struct rtl8xxxu_power_base rtl8192c_power_base = { 241 + .reg_0e00 = 0x07090c0c, 242 + .reg_0e04 = 0x01020405, 243 + .reg_0e08 = 0x00000000, 244 + .reg_086c = 0x00000000, 245 + 246 + .reg_0e10 = 0x0b0c0c0e, 247 + .reg_0e14 = 0x01030506, 248 + .reg_0e18 = 0x0b0c0d0e, 249 + .reg_0e1c = 0x01030509, 250 + 251 + .reg_0830 = 0x07090c0c, 252 + .reg_0834 = 0x01020405, 253 + .reg_0838 = 0x00000000, 254 + .reg_086c_2 = 0x00000000, 255 + 256 + .reg_083c = 0x0b0c0d0e, 257 + .reg_0848 = 0x01030509, 258 + .reg_084c = 0x0b0c0d0e, 259 + .reg_0868 = 0x01030509, 260 + }; 261 + #endif 262 + 263 + static struct rtl8xxxu_power_base rtl8723a_power_base = { 264 + .reg_0e00 = 0x0a0c0c0c, 265 + .reg_0e04 = 0x02040608, 266 + .reg_0e08 = 0x00000000, 267 + .reg_086c = 0x00000000, 268 + 269 + .reg_0e10 = 0x0a0c0d0e, 270 + .reg_0e14 = 0x02040608, 271 + .reg_0e18 = 0x0a0c0d0e, 272 + .reg_0e1c = 0x02040608, 273 + 274 + .reg_0830 = 0x0a0c0c0c, 275 + .reg_0834 = 0x02040608, 276 + .reg_0838 = 0x00000000, 277 + .reg_086c_2 = 0x00000000, 278 + 279 + .reg_083c = 0x0a0c0d0e, 280 + .reg_0848 = 0x02040608, 281 + .reg_084c = 0x0a0c0d0e, 282 + .reg_0868 = 0x02040608, 185 283 }; 186 284 187 285 static struct rtl8xxxu_reg32val rtl8723a_phy_1t_init_table[] = { ··· 678 580 {0xffff, 0xffffffff}, 679 581 }; 680 582 583 + static struct rtl8xxxu_reg32val rtl8192eu_phy_init_table[] = { 584 + {0x800, 0x80040000}, {0x804, 0x00000003}, 585 + {0x808, 0x0000fc00}, {0x80c, 0x0000000a}, 586 + {0x810, 0x10001331}, {0x814, 0x020c3d10}, 587 + {0x818, 0x02220385}, {0x81c, 0x00000000}, 588 + {0x820, 0x01000100}, {0x824, 0x00390204}, 589 + {0x828, 0x01000100}, {0x82c, 0x00390204}, 590 + {0x830, 0x32323232}, {0x834, 0x30303030}, 591 + {0x838, 0x30303030}, {0x83c, 0x30303030}, 592 + {0x840, 0x00010000}, {0x844, 0x00010000}, 593 + {0x848, 0x28282828}, {0x84c, 0x28282828}, 594 + {0x850, 0x00000000}, {0x854, 0x00000000}, 595 + {0x858, 0x009a009a}, {0x85c, 0x01000014}, 596 + {0x860, 0x66f60000}, {0x864, 0x061f0000}, 597 + {0x868, 0x30303030}, {0x86c, 0x30303030}, 598 + {0x870, 0x00000000}, {0x874, 0x55004200}, 599 + {0x878, 0x08080808}, {0x87c, 0x00000000}, 600 + {0x880, 0xb0000c1c}, {0x884, 0x00000001}, 601 + {0x888, 0x00000000}, {0x88c, 0xcc0000c0}, 602 + {0x890, 0x00000800}, {0x894, 0xfffffffe}, 603 + {0x898, 0x40302010}, {0x900, 0x00000000}, 604 + {0x904, 0x00000023}, {0x908, 0x00000000}, 605 + {0x90c, 0x81121313}, {0x910, 0x806c0001}, 606 + {0x914, 0x00000001}, {0x918, 0x00000000}, 607 + {0x91c, 0x00010000}, {0x924, 0x00000001}, 608 + {0x928, 0x00000000}, {0x92c, 0x00000000}, 609 + {0x930, 0x00000000}, {0x934, 0x00000000}, 610 + {0x938, 0x00000000}, {0x93c, 0x00000000}, 611 + {0x940, 0x00000000}, {0x944, 0x00000000}, 612 + {0x94c, 0x00000008}, {0xa00, 0x00d0c7c8}, 613 + {0xa04, 0x81ff000c}, {0xa08, 0x8c838300}, 614 + {0xa0c, 0x2e68120f}, {0xa10, 0x95009b78}, 615 + {0xa14, 0x1114d028}, {0xa18, 0x00881117}, 616 + {0xa1c, 0x89140f00}, {0xa20, 0x1a1b0000}, 617 + {0xa24, 0x090e1317}, {0xa28, 0x00000204}, 618 + {0xa2c, 0x00d30000}, {0xa70, 0x101fff00}, 619 + {0xa74, 0x00000007}, {0xa78, 0x00000900}, 620 + {0xa7c, 0x225b0606}, {0xa80, 0x218075b1}, 621 + {0xb38, 0x00000000}, {0xc00, 0x48071d40}, 622 + {0xc04, 0x03a05633}, {0xc08, 0x000000e4}, 623 + {0xc0c, 0x6c6c6c6c}, {0xc10, 0x08800000}, 624 + {0xc14, 0x40000100}, {0xc18, 0x08800000}, 625 + {0xc1c, 0x40000100}, {0xc20, 0x00000000}, 626 + {0xc24, 0x00000000}, {0xc28, 0x00000000}, 627 + {0xc2c, 0x00000000}, {0xc30, 0x69e9ac47}, 628 + {0xc34, 0x469652af}, {0xc38, 0x49795994}, 629 + {0xc3c, 0x0a97971c}, {0xc40, 0x1f7c403f}, 630 + {0xc44, 0x000100b7}, {0xc48, 0xec020107}, 631 + {0xc4c, 0x007f037f}, 632 + #ifdef EXT_PA_8192EU 633 + /* External PA or external LNA */ 634 + {0xc50, 0x00340220}, 635 + #else 636 + {0xc50, 0x00340020}, 637 + #endif 638 + {0xc54, 0x0080801f}, 639 + #ifdef EXT_PA_8192EU 640 + /* External PA or external LNA */ 641 + {0xc58, 0x00000220}, 642 + #else 643 + {0xc58, 0x00000020}, 644 + #endif 645 + {0xc5c, 0x00248492}, {0xc60, 0x00000000}, 646 + {0xc64, 0x7112848b}, {0xc68, 0x47c00bff}, 647 + {0xc6c, 0x00000036}, {0xc70, 0x00000600}, 648 + {0xc74, 0x02013169}, {0xc78, 0x0000001f}, 649 + {0xc7c, 0x00b91612}, 650 + #ifdef EXT_PA_8192EU 651 + /* External PA or external LNA */ 652 + {0xc80, 0x2d4000b5}, 653 + #else 654 + {0xc80, 0x40000100}, 655 + #endif 656 + {0xc84, 0x21f60000}, 657 + #ifdef EXT_PA_8192EU 658 + /* External PA or external LNA */ 659 + {0xc88, 0x2d4000b5}, 660 + #else 661 + {0xc88, 0x40000100}, 662 + #endif 663 + {0xc8c, 0xa0e40000}, {0xc90, 0x00121820}, 664 + {0xc94, 0x00000000}, {0xc98, 0x00121820}, 665 + {0xc9c, 0x00007f7f}, {0xca0, 0x00000000}, 666 + {0xca4, 0x000300a0}, {0xca8, 0x00000000}, 667 + {0xcac, 0x00000000}, {0xcb0, 0x00000000}, 668 + {0xcb4, 0x00000000}, {0xcb8, 0x00000000}, 669 + {0xcbc, 0x28000000}, {0xcc0, 0x00000000}, 670 + {0xcc4, 0x00000000}, {0xcc8, 0x00000000}, 671 + {0xccc, 0x00000000}, {0xcd0, 0x00000000}, 672 + {0xcd4, 0x00000000}, {0xcd8, 0x64b22427}, 673 + {0xcdc, 0x00766932}, {0xce0, 0x00222222}, 674 + {0xce4, 0x00040000}, {0xce8, 0x77644302}, 675 + {0xcec, 0x2f97d40c}, {0xd00, 0x00080740}, 676 + {0xd04, 0x00020403}, {0xd08, 0x0000907f}, 677 + {0xd0c, 0x20010201}, {0xd10, 0xa0633333}, 678 + {0xd14, 0x3333bc43}, {0xd18, 0x7a8f5b6b}, 679 + {0xd1c, 0x0000007f}, {0xd2c, 0xcc979975}, 680 + {0xd30, 0x00000000}, {0xd34, 0x80608000}, 681 + {0xd38, 0x00000000}, {0xd3c, 0x00127353}, 682 + {0xd40, 0x00000000}, {0xd44, 0x00000000}, 683 + {0xd48, 0x00000000}, {0xd4c, 0x00000000}, 684 + {0xd50, 0x6437140a}, {0xd54, 0x00000000}, 685 + {0xd58, 0x00000282}, {0xd5c, 0x30032064}, 686 + {0xd60, 0x4653de68}, {0xd64, 0x04518a3c}, 687 + {0xd68, 0x00002101}, {0xd6c, 0x2a201c16}, 688 + {0xd70, 0x1812362e}, {0xd74, 0x322c2220}, 689 + {0xd78, 0x000e3c24}, {0xd80, 0x01081008}, 690 + {0xd84, 0x00000800}, {0xd88, 0xf0b50000}, 691 + {0xe00, 0x30303030}, {0xe04, 0x30303030}, 692 + {0xe08, 0x03903030}, {0xe10, 0x30303030}, 693 + {0xe14, 0x30303030}, {0xe18, 0x30303030}, 694 + {0xe1c, 0x30303030}, {0xe28, 0x00000000}, 695 + {0xe30, 0x1000dc1f}, {0xe34, 0x10008c1f}, 696 + {0xe38, 0x02140102}, {0xe3c, 0x681604c2}, 697 + {0xe40, 0x01007c00}, {0xe44, 0x01004800}, 698 + {0xe48, 0xfb000000}, {0xe4c, 0x000028d1}, 699 + {0xe50, 0x1000dc1f}, {0xe54, 0x10008c1f}, 700 + {0xe58, 0x02140102}, {0xe5c, 0x28160d05}, 701 + {0xe60, 0x00000008}, {0xe68, 0x0fc05656}, 702 + {0xe6c, 0x03c09696}, {0xe70, 0x03c09696}, 703 + {0xe74, 0x0c005656}, {0xe78, 0x0c005656}, 704 + {0xe7c, 0x0c005656}, {0xe80, 0x0c005656}, 705 + {0xe84, 0x03c09696}, {0xe88, 0x0c005656}, 706 + {0xe8c, 0x03c09696}, {0xed0, 0x03c09696}, 707 + {0xed4, 0x03c09696}, {0xed8, 0x03c09696}, 708 + {0xedc, 0x0000d6d6}, {0xee0, 0x0000d6d6}, 709 + {0xeec, 0x0fc01616}, {0xee4, 0xb0000c1c}, 710 + {0xee8, 0x00000001}, {0xf14, 0x00000003}, 711 + {0xf4c, 0x00000000}, {0xf00, 0x00000300}, 712 + {0xffff, 0xffffffff}, 713 + }; 714 + 681 715 static struct rtl8xxxu_reg32val rtl8xxx_agc_standard_table[] = { 682 716 {0xc78, 0x7b000001}, {0xc78, 0x7b010001}, 683 717 {0xc78, 0x7b020001}, {0xc78, 0x7b030001}, ··· 1049 819 {0xffff, 0xffffffff} 1050 820 }; 1051 821 822 + static struct rtl8xxxu_reg32val rtl8xxx_agc_8192eu_std_table[] = { 823 + {0xc78, 0xfb000001}, {0xc78, 0xfb010001}, 824 + {0xc78, 0xfb020001}, {0xc78, 0xfb030001}, 825 + {0xc78, 0xfb040001}, {0xc78, 0xfb050001}, 826 + {0xc78, 0xfa060001}, {0xc78, 0xf9070001}, 827 + {0xc78, 0xf8080001}, {0xc78, 0xf7090001}, 828 + {0xc78, 0xf60a0001}, {0xc78, 0xf50b0001}, 829 + {0xc78, 0xf40c0001}, {0xc78, 0xf30d0001}, 830 + {0xc78, 0xf20e0001}, {0xc78, 0xf10f0001}, 831 + {0xc78, 0xf0100001}, {0xc78, 0xef110001}, 832 + {0xc78, 0xee120001}, {0xc78, 0xed130001}, 833 + {0xc78, 0xec140001}, {0xc78, 0xeb150001}, 834 + {0xc78, 0xea160001}, {0xc78, 0xe9170001}, 835 + {0xc78, 0xe8180001}, {0xc78, 0xe7190001}, 836 + {0xc78, 0xc81a0001}, {0xc78, 0xc71b0001}, 837 + {0xc78, 0xc61c0001}, {0xc78, 0x071d0001}, 838 + {0xc78, 0x061e0001}, {0xc78, 0x051f0001}, 839 + {0xc78, 0x04200001}, {0xc78, 0x03210001}, 840 + {0xc78, 0xaa220001}, {0xc78, 0xa9230001}, 841 + {0xc78, 0xa8240001}, {0xc78, 0xa7250001}, 842 + {0xc78, 0xa6260001}, {0xc78, 0x85270001}, 843 + {0xc78, 0x84280001}, {0xc78, 0x83290001}, 844 + {0xc78, 0x252a0001}, {0xc78, 0x242b0001}, 845 + {0xc78, 0x232c0001}, {0xc78, 0x222d0001}, 846 + {0xc78, 0x672e0001}, {0xc78, 0x662f0001}, 847 + {0xc78, 0x65300001}, {0xc78, 0x64310001}, 848 + {0xc78, 0x63320001}, {0xc78, 0x62330001}, 849 + {0xc78, 0x61340001}, {0xc78, 0x45350001}, 850 + {0xc78, 0x44360001}, {0xc78, 0x43370001}, 851 + {0xc78, 0x42380001}, {0xc78, 0x41390001}, 852 + {0xc78, 0x403a0001}, {0xc78, 0x403b0001}, 853 + {0xc78, 0x403c0001}, {0xc78, 0x403d0001}, 854 + {0xc78, 0x403e0001}, {0xc78, 0x403f0001}, 855 + {0xc78, 0xfb400001}, {0xc78, 0xfb410001}, 856 + {0xc78, 0xfb420001}, {0xc78, 0xfb430001}, 857 + {0xc78, 0xfb440001}, {0xc78, 0xfb450001}, 858 + {0xc78, 0xfa460001}, {0xc78, 0xf9470001}, 859 + {0xc78, 0xf8480001}, {0xc78, 0xf7490001}, 860 + {0xc78, 0xf64a0001}, {0xc78, 0xf54b0001}, 861 + {0xc78, 0xf44c0001}, {0xc78, 0xf34d0001}, 862 + {0xc78, 0xf24e0001}, {0xc78, 0xf14f0001}, 863 + {0xc78, 0xf0500001}, {0xc78, 0xef510001}, 864 + {0xc78, 0xee520001}, {0xc78, 0xed530001}, 865 + {0xc78, 0xec540001}, {0xc78, 0xeb550001}, 866 + {0xc78, 0xea560001}, {0xc78, 0xe9570001}, 867 + {0xc78, 0xe8580001}, {0xc78, 0xe7590001}, 868 + {0xc78, 0xe65a0001}, {0xc78, 0xe55b0001}, 869 + {0xc78, 0xe45c0001}, {0xc78, 0xe35d0001}, 870 + {0xc78, 0xe25e0001}, {0xc78, 0xe15f0001}, 871 + {0xc78, 0x8a600001}, {0xc78, 0x89610001}, 872 + {0xc78, 0x88620001}, {0xc78, 0x87630001}, 873 + {0xc78, 0x86640001}, {0xc78, 0x85650001}, 874 + {0xc78, 0x84660001}, {0xc78, 0x83670001}, 875 + {0xc78, 0x82680001}, {0xc78, 0x6b690001}, 876 + {0xc78, 0x6a6a0001}, {0xc78, 0x696b0001}, 877 + {0xc78, 0x686c0001}, {0xc78, 0x676d0001}, 878 + {0xc78, 0x666e0001}, {0xc78, 0x656f0001}, 879 + {0xc78, 0x64700001}, {0xc78, 0x63710001}, 880 + {0xc78, 0x62720001}, {0xc78, 0x61730001}, 881 + {0xc78, 0x49740001}, {0xc78, 0x48750001}, 882 + {0xc78, 0x47760001}, {0xc78, 0x46770001}, 883 + {0xc78, 0x45780001}, {0xc78, 0x44790001}, 884 + {0xc78, 0x437a0001}, {0xc78, 0x427b0001}, 885 + {0xc78, 0x417c0001}, {0xc78, 0x407d0001}, 886 + {0xc78, 0x407e0001}, {0xc78, 0x407f0001}, 887 + {0xc50, 0x00040022}, {0xc50, 0x00040020}, 888 + {0xffff, 0xffffffff} 889 + }; 890 + 891 + static struct rtl8xxxu_reg32val rtl8xxx_agc_8192eu_highpa_table[] = { 892 + {0xc78, 0xfa000001}, {0xc78, 0xf9010001}, 893 + {0xc78, 0xf8020001}, {0xc78, 0xf7030001}, 894 + {0xc78, 0xf6040001}, {0xc78, 0xf5050001}, 895 + {0xc78, 0xf4060001}, {0xc78, 0xf3070001}, 896 + {0xc78, 0xf2080001}, {0xc78, 0xf1090001}, 897 + {0xc78, 0xf00a0001}, {0xc78, 0xef0b0001}, 898 + {0xc78, 0xee0c0001}, {0xc78, 0xed0d0001}, 899 + {0xc78, 0xec0e0001}, {0xc78, 0xeb0f0001}, 900 + {0xc78, 0xea100001}, {0xc78, 0xe9110001}, 901 + {0xc78, 0xe8120001}, {0xc78, 0xe7130001}, 902 + {0xc78, 0xe6140001}, {0xc78, 0xe5150001}, 903 + {0xc78, 0xe4160001}, {0xc78, 0xe3170001}, 904 + {0xc78, 0xe2180001}, {0xc78, 0xe1190001}, 905 + {0xc78, 0x8a1a0001}, {0xc78, 0x891b0001}, 906 + {0xc78, 0x881c0001}, {0xc78, 0x871d0001}, 907 + {0xc78, 0x861e0001}, {0xc78, 0x851f0001}, 908 + {0xc78, 0x84200001}, {0xc78, 0x83210001}, 909 + {0xc78, 0x82220001}, {0xc78, 0x6a230001}, 910 + {0xc78, 0x69240001}, {0xc78, 0x68250001}, 911 + {0xc78, 0x67260001}, {0xc78, 0x66270001}, 912 + {0xc78, 0x65280001}, {0xc78, 0x64290001}, 913 + {0xc78, 0x632a0001}, {0xc78, 0x622b0001}, 914 + {0xc78, 0x612c0001}, {0xc78, 0x602d0001}, 915 + {0xc78, 0x472e0001}, {0xc78, 0x462f0001}, 916 + {0xc78, 0x45300001}, {0xc78, 0x44310001}, 917 + {0xc78, 0x43320001}, {0xc78, 0x42330001}, 918 + {0xc78, 0x41340001}, {0xc78, 0x40350001}, 919 + {0xc78, 0x40360001}, {0xc78, 0x40370001}, 920 + {0xc78, 0x40380001}, {0xc78, 0x40390001}, 921 + {0xc78, 0x403a0001}, {0xc78, 0x403b0001}, 922 + {0xc78, 0x403c0001}, {0xc78, 0x403d0001}, 923 + {0xc78, 0x403e0001}, {0xc78, 0x403f0001}, 924 + {0xc78, 0xfa400001}, {0xc78, 0xf9410001}, 925 + {0xc78, 0xf8420001}, {0xc78, 0xf7430001}, 926 + {0xc78, 0xf6440001}, {0xc78, 0xf5450001}, 927 + {0xc78, 0xf4460001}, {0xc78, 0xf3470001}, 928 + {0xc78, 0xf2480001}, {0xc78, 0xf1490001}, 929 + {0xc78, 0xf04a0001}, {0xc78, 0xef4b0001}, 930 + {0xc78, 0xee4c0001}, {0xc78, 0xed4d0001}, 931 + {0xc78, 0xec4e0001}, {0xc78, 0xeb4f0001}, 932 + {0xc78, 0xea500001}, {0xc78, 0xe9510001}, 933 + {0xc78, 0xe8520001}, {0xc78, 0xe7530001}, 934 + {0xc78, 0xe6540001}, {0xc78, 0xe5550001}, 935 + {0xc78, 0xe4560001}, {0xc78, 0xe3570001}, 936 + {0xc78, 0xe2580001}, {0xc78, 0xe1590001}, 937 + {0xc78, 0x8a5a0001}, {0xc78, 0x895b0001}, 938 + {0xc78, 0x885c0001}, {0xc78, 0x875d0001}, 939 + {0xc78, 0x865e0001}, {0xc78, 0x855f0001}, 940 + {0xc78, 0x84600001}, {0xc78, 0x83610001}, 941 + {0xc78, 0x82620001}, {0xc78, 0x6a630001}, 942 + {0xc78, 0x69640001}, {0xc78, 0x68650001}, 943 + {0xc78, 0x67660001}, {0xc78, 0x66670001}, 944 + {0xc78, 0x65680001}, {0xc78, 0x64690001}, 945 + {0xc78, 0x636a0001}, {0xc78, 0x626b0001}, 946 + {0xc78, 0x616c0001}, {0xc78, 0x606d0001}, 947 + {0xc78, 0x476e0001}, {0xc78, 0x466f0001}, 948 + {0xc78, 0x45700001}, {0xc78, 0x44710001}, 949 + {0xc78, 0x43720001}, {0xc78, 0x42730001}, 950 + {0xc78, 0x41740001}, {0xc78, 0x40750001}, 951 + {0xc78, 0x40760001}, {0xc78, 0x40770001}, 952 + {0xc78, 0x40780001}, {0xc78, 0x40790001}, 953 + {0xc78, 0x407a0001}, {0xc78, 0x407b0001}, 954 + {0xc78, 0x407c0001}, {0xc78, 0x407d0001}, 955 + {0xc78, 0x407e0001}, {0xc78, 0x407f0001}, 956 + {0xc50, 0x00040222}, {0xc50, 0x00040220}, 957 + {0xffff, 0xffffffff} 958 + }; 959 + 1052 960 static struct rtl8xxxu_rfregval rtl8723au_radioa_1t_init_table[] = { 1053 961 {0x00, 0x00030159}, {0x01, 0x00031284}, 1054 962 {0x02, 0x00098000}, {0x03, 0x00039c63}, ··· 1331 963 {0xff, 0xffffffff} 1332 964 }; 1333 965 966 + #ifdef CONFIG_RTL8XXXU_UNTESTED 1334 967 static struct rtl8xxxu_rfregval rtl8192cu_radioa_2t_init_table[] = { 1335 968 {0x00, 0x00030159}, {0x01, 0x00031284}, 1336 969 {0x02, 0x00098000}, {0x03, 0x00018c63}, ··· 1580 1211 {0x00, 0x00030159}, 1581 1212 {0xff, 0xffffffff} 1582 1213 }; 1214 + #endif 1215 + 1216 + static struct rtl8xxxu_rfregval rtl8192eu_radioa_init_table[] = { 1217 + {0x7f, 0x00000082}, {0x81, 0x0003fc00}, 1218 + {0x00, 0x00030000}, {0x08, 0x00008400}, 1219 + {0x18, 0x00000407}, {0x19, 0x00000012}, 1220 + {0x1b, 0x00000064}, {0x1e, 0x00080009}, 1221 + {0x1f, 0x00000880}, {0x2f, 0x0001a060}, 1222 + {0x3f, 0x00000000}, {0x42, 0x000060c0}, 1223 + {0x57, 0x000d0000}, {0x58, 0x000be180}, 1224 + {0x67, 0x00001552}, {0x83, 0x00000000}, 1225 + {0xb0, 0x000ff9f1}, {0xb1, 0x00055418}, 1226 + {0xb2, 0x0008cc00}, {0xb4, 0x00043083}, 1227 + {0xb5, 0x00008166}, {0xb6, 0x0000803e}, 1228 + {0xb7, 0x0001c69f}, {0xb8, 0x0000407f}, 1229 + {0xb9, 0x00080001}, {0xba, 0x00040001}, 1230 + {0xbb, 0x00000400}, {0xbf, 0x000c0000}, 1231 + {0xc2, 0x00002400}, {0xc3, 0x00000009}, 1232 + {0xc4, 0x00040c91}, {0xc5, 0x00099999}, 1233 + {0xc6, 0x000000a3}, {0xc7, 0x00088820}, 1234 + {0xc8, 0x00076c06}, {0xc9, 0x00000000}, 1235 + {0xca, 0x00080000}, {0xdf, 0x00000180}, 1236 + {0xef, 0x000001a0}, {0x51, 0x00069545}, 1237 + {0x52, 0x0007e45e}, {0x53, 0x00000071}, 1238 + {0x56, 0x00051ff3}, {0x35, 0x000000a8}, 1239 + {0x35, 0x000001e2}, {0x35, 0x000002a8}, 1240 + {0x36, 0x00001c24}, {0x36, 0x00009c24}, 1241 + {0x36, 0x00011c24}, {0x36, 0x00019c24}, 1242 + {0x18, 0x00000c07}, {0x5a, 0x00048000}, 1243 + {0x19, 0x000739d0}, 1244 + #ifdef EXT_PA_8192EU 1245 + /* External PA or external LNA */ 1246 + {0x34, 0x0000a093}, {0x34, 0x0000908f}, 1247 + {0x34, 0x0000808c}, {0x34, 0x0000704d}, 1248 + {0x34, 0x0000604a}, {0x34, 0x00005047}, 1249 + {0x34, 0x0000400a}, {0x34, 0x00003007}, 1250 + {0x34, 0x00002004}, {0x34, 0x00001001}, 1251 + {0x34, 0x00000000}, 1252 + #else 1253 + /* Regular */ 1254 + {0x34, 0x0000add7}, {0x34, 0x00009dd4}, 1255 + {0x34, 0x00008dd1}, {0x34, 0x00007dce}, 1256 + {0x34, 0x00006dcb}, {0x34, 0x00005dc8}, 1257 + {0x34, 0x00004dc5}, {0x34, 0x000034cc}, 1258 + {0x34, 0x0000244f}, {0x34, 0x0000144c}, 1259 + {0x34, 0x00000014}, 1260 + #endif 1261 + {0x00, 0x00030159}, 1262 + {0x84, 0x00068180}, 1263 + {0x86, 0x0000014e}, 1264 + {0x87, 0x00048e00}, 1265 + {0x8e, 0x00065540}, 1266 + {0x8f, 0x00088000}, 1267 + {0xef, 0x000020a0}, 1268 + #ifdef EXT_PA_8192EU 1269 + /* External PA or external LNA */ 1270 + {0x3b, 0x000f07b0}, 1271 + #else 1272 + {0x3b, 0x000f02b0}, 1273 + #endif 1274 + {0x3b, 0x000ef7b0}, {0x3b, 0x000d4fb0}, 1275 + {0x3b, 0x000cf060}, {0x3b, 0x000b0090}, 1276 + {0x3b, 0x000a0080}, {0x3b, 0x00090080}, 1277 + {0x3b, 0x0008f780}, 1278 + #ifdef EXT_PA_8192EU 1279 + /* External PA or external LNA */ 1280 + {0x3b, 0x000787b0}, 1281 + #else 1282 + {0x3b, 0x00078730}, 1283 + #endif 1284 + {0x3b, 0x00060fb0}, {0x3b, 0x0005ffa0}, 1285 + {0x3b, 0x00040620}, {0x3b, 0x00037090}, 1286 + {0x3b, 0x00020080}, {0x3b, 0x0001f060}, 1287 + {0x3b, 0x0000ffb0}, {0xef, 0x000000a0}, 1288 + {0xfe, 0x00000000}, {0x18, 0x0000fc07}, 1289 + {0xfe, 0x00000000}, {0xfe, 0x00000000}, 1290 + {0xfe, 0x00000000}, {0xfe, 0x00000000}, 1291 + {0x1e, 0x00000001}, {0x1f, 0x00080000}, 1292 + {0x00, 0x00033e70}, 1293 + {0xff, 0xffffffff} 1294 + }; 1295 + 1296 + static struct rtl8xxxu_rfregval rtl8192eu_radiob_init_table[] = { 1297 + {0x7f, 0x00000082}, {0x81, 0x0003fc00}, 1298 + {0x00, 0x00030000}, {0x08, 0x00008400}, 1299 + {0x18, 0x00000407}, {0x19, 0x00000012}, 1300 + {0x1b, 0x00000064}, {0x1e, 0x00080009}, 1301 + {0x1f, 0x00000880}, {0x2f, 0x0001a060}, 1302 + {0x3f, 0x00000000}, {0x42, 0x000060c0}, 1303 + {0x57, 0x000d0000}, {0x58, 0x000be180}, 1304 + {0x67, 0x00001552}, {0x7f, 0x00000082}, 1305 + {0x81, 0x0003f000}, {0x83, 0x00000000}, 1306 + {0xdf, 0x00000180}, {0xef, 0x000001a0}, 1307 + {0x51, 0x00069545}, {0x52, 0x0007e42e}, 1308 + {0x53, 0x00000071}, {0x56, 0x00051ff3}, 1309 + {0x35, 0x000000a8}, {0x35, 0x000001e0}, 1310 + {0x35, 0x000002a8}, {0x36, 0x00001ca8}, 1311 + {0x36, 0x00009c24}, {0x36, 0x00011c24}, 1312 + {0x36, 0x00019c24}, {0x18, 0x00000c07}, 1313 + {0x5a, 0x00048000}, {0x19, 0x000739d0}, 1314 + #ifdef EXT_PA_8192EU 1315 + /* External PA or external LNA */ 1316 + {0x34, 0x0000a093}, {0x34, 0x0000908f}, 1317 + {0x34, 0x0000808c}, {0x34, 0x0000704d}, 1318 + {0x34, 0x0000604a}, {0x34, 0x00005047}, 1319 + {0x34, 0x0000400a}, {0x34, 0x00003007}, 1320 + {0x34, 0x00002004}, {0x34, 0x00001001}, 1321 + {0x34, 0x00000000}, 1322 + #else 1323 + {0x34, 0x0000add7}, {0x34, 0x00009dd4}, 1324 + {0x34, 0x00008dd1}, {0x34, 0x00007dce}, 1325 + {0x34, 0x00006dcb}, {0x34, 0x00005dc8}, 1326 + {0x34, 0x00004dc5}, {0x34, 0x000034cc}, 1327 + {0x34, 0x0000244f}, {0x34, 0x0000144c}, 1328 + {0x34, 0x00000014}, 1329 + #endif 1330 + {0x00, 0x00030159}, {0x84, 0x00068180}, 1331 + {0x86, 0x000000ce}, {0x87, 0x00048a00}, 1332 + {0x8e, 0x00065540}, {0x8f, 0x00088000}, 1333 + {0xef, 0x000020a0}, 1334 + #ifdef EXT_PA_8192EU 1335 + /* External PA or external LNA */ 1336 + {0x3b, 0x000f07b0}, 1337 + #else 1338 + {0x3b, 0x000f02b0}, 1339 + #endif 1340 + 1341 + {0x3b, 0x000ef7b0}, {0x3b, 0x000d4fb0}, 1342 + {0x3b, 0x000cf060}, {0x3b, 0x000b0090}, 1343 + {0x3b, 0x000a0080}, {0x3b, 0x00090080}, 1344 + {0x3b, 0x0008f780}, 1345 + #ifdef EXT_PA_8192EU 1346 + /* External PA or external LNA */ 1347 + {0x3b, 0x000787b0}, 1348 + #else 1349 + {0x3b, 0x00078730}, 1350 + #endif 1351 + {0x3b, 0x00060fb0}, {0x3b, 0x0005ffa0}, 1352 + {0x3b, 0x00040620}, {0x3b, 0x00037090}, 1353 + {0x3b, 0x00020080}, {0x3b, 0x0001f060}, 1354 + {0x3b, 0x0000ffb0}, {0xef, 0x000000a0}, 1355 + {0x00, 0x00010159}, {0xfe, 0x00000000}, 1356 + {0xfe, 0x00000000}, {0xfe, 0x00000000}, 1357 + {0xfe, 0x00000000}, {0x1e, 0x00000001}, 1358 + {0x1f, 0x00080000}, {0x00, 0x00033e70}, 1359 + {0xff, 0xffffffff} 1360 + }; 1583 1361 1584 1362 static struct rtl8xxxu_rfregs rtl8xxxu_rfregs[] = { 1585 1363 { /* RF_A */ ··· 1747 1231 }, 1748 1232 }; 1749 1233 1750 - static const u32 rtl8723au_iqk_phy_iq_bb_reg[RTL8XXXU_BB_REGS] = { 1234 + static const u32 rtl8xxxu_iqk_phy_iq_bb_reg[RTL8XXXU_BB_REGS] = { 1751 1235 REG_OFDM0_XA_RX_IQ_IMBALANCE, 1752 1236 REG_OFDM0_XB_RX_IQ_IMBALANCE, 1753 1237 REG_OFDM0_ENERGY_CCA_THRES, ··· 1966 1450 enum rtl8xxxu_rfpath path, u8 reg, u32 data) 1967 1451 { 1968 1452 int ret, retval; 1969 - u32 dataaddr; 1453 + u32 dataaddr, val32; 1970 1454 1971 1455 if (rtl8xxxu_debug & RTL8XXXU_DEBUG_RFREG_WRITE) 1972 1456 dev_info(&priv->udev->dev, "%s(%02x) = 0x%06x\n", ··· 1974 1458 1975 1459 data &= FPGA0_LSSI_PARM_DATA_MASK; 1976 1460 dataaddr = (reg << FPGA0_LSSI_PARM_ADDR_SHIFT) | data; 1461 + 1462 + if (priv->rtl_chip == RTL8192E) { 1463 + val32 = rtl8xxxu_read32(priv, REG_FPGA0_POWER_SAVE); 1464 + val32 &= ~0x20000; 1465 + rtl8xxxu_write32(priv, REG_FPGA0_POWER_SAVE, val32); 1466 + } 1977 1467 1978 1468 /* Use XB for path B */ 1979 1469 ret = rtl8xxxu_write32(priv, rtl8xxxu_rfregs[path].lssiparm, dataaddr); ··· 1989 1467 retval = 0; 1990 1468 1991 1469 udelay(1); 1470 + 1471 + if (priv->rtl_chip == RTL8192E) { 1472 + val32 = rtl8xxxu_read32(priv, REG_FPGA0_POWER_SAVE); 1473 + val32 |= 0x20000; 1474 + rtl8xxxu_write32(priv, REG_FPGA0_POWER_SAVE, val32); 1475 + } 1992 1476 1993 1477 return retval; 1994 1478 } ··· 2080 1552 rtl8723a_h2c_cmd(priv, &h2c, sizeof(h2c.bt_mp_oper)); 2081 1553 } 2082 1554 2083 - static void rtl8723a_enable_rf(struct rtl8xxxu_priv *priv) 1555 + static void rtl8xxxu_gen1_enable_rf(struct rtl8xxxu_priv *priv) 2084 1556 { 2085 1557 u8 val8; 2086 1558 u32 val32; ··· 2124 1596 rtl8xxxu_write8(priv, REG_TXPAUSE, 0x00); 2125 1597 } 2126 1598 2127 - static void rtl8723a_disable_rf(struct rtl8xxxu_priv *priv) 1599 + static void rtl8xxxu_gen1_disable_rf(struct rtl8xxxu_priv *priv) 2128 1600 { 2129 1601 u8 sps0; 2130 1602 u32 val32; 2131 - 2132 - rtl8xxxu_write8(priv, REG_TXPAUSE, 0xff); 2133 1603 2134 1604 sps0 = rtl8xxxu_read8(priv, REG_SPS0_CTRL); 2135 1605 ··· 2202 1676 return group; 2203 1677 } 2204 1678 2205 - static int rtl8723b_channel_to_group(int channel) 1679 + /* 1680 + * Valid for rtl8723bu and rtl8192eu 1681 + */ 1682 + static int rtl8xxxu_gen2_channel_to_group(int channel) 2206 1683 { 2207 1684 int group; 2208 1685 ··· 2223 1694 return group; 2224 1695 } 2225 1696 2226 - static void rtl8723au_config_channel(struct ieee80211_hw *hw) 1697 + static void rtl8xxxu_gen1_config_channel(struct ieee80211_hw *hw) 2227 1698 { 2228 1699 struct rtl8xxxu_priv *priv = hw->priv; 2229 1700 u32 val32, rsr; ··· 2345 1816 } 2346 1817 } 2347 1818 2348 - static void rtl8723bu_config_channel(struct ieee80211_hw *hw) 1819 + static void rtl8xxxu_gen2_config_channel(struct ieee80211_hw *hw) 2349 1820 { 2350 1821 struct rtl8xxxu_priv *priv = hw->priv; 2351 1822 u32 val32, rsr; ··· 2476 1947 } 2477 1948 2478 1949 static void 2479 - rtl8723a_set_tx_power(struct rtl8xxxu_priv *priv, int channel, bool ht40) 1950 + rtl8xxxu_gen1_set_tx_power(struct rtl8xxxu_priv *priv, int channel, bool ht40) 2480 1951 { 1952 + struct rtl8xxxu_power_base *power_base = priv->power_base; 2481 1953 u8 cck[RTL8723A_MAX_RF_PATHS], ofdm[RTL8723A_MAX_RF_PATHS]; 2482 1954 u8 ofdmbase[RTL8723A_MAX_RF_PATHS], mcsbase[RTL8723A_MAX_RF_PATHS]; 2483 1955 u32 val32, ofdm_a, ofdm_b, mcs_a, mcs_b; ··· 2487 1957 2488 1958 group = rtl8723a_channel_to_group(channel); 2489 1959 2490 - cck[0] = priv->cck_tx_power_index_A[group]; 2491 - cck[1] = priv->cck_tx_power_index_B[group]; 1960 + cck[0] = priv->cck_tx_power_index_A[group] - 1; 1961 + cck[1] = priv->cck_tx_power_index_B[group] - 1; 1962 + 1963 + if (priv->hi_pa) { 1964 + if (cck[0] > 0x20) 1965 + cck[0] = 0x20; 1966 + if (cck[1] > 0x20) 1967 + cck[1] = 0x20; 1968 + } 2492 1969 2493 1970 ofdm[0] = priv->ht40_1s_tx_power_index_A[group]; 2494 1971 ofdm[1] = priv->ht40_1s_tx_power_index_B[group]; 1972 + if (ofdm[0]) 1973 + ofdm[0] -= 1; 1974 + if (ofdm[1]) 1975 + ofdm[1] -= 1; 2495 1976 2496 1977 ofdmbase[0] = ofdm[0] + priv->ofdm_tx_power_index_diff[group].a; 2497 1978 ofdmbase[1] = ofdm[1] + priv->ofdm_tx_power_index_diff[group].b; ··· 2558 2017 ofdmbase[0] << 16 | ofdmbase[0] << 24; 2559 2018 ofdm_b = ofdmbase[1] | ofdmbase[1] << 8 | 2560 2019 ofdmbase[1] << 16 | ofdmbase[1] << 24; 2561 - rtl8xxxu_write32(priv, REG_TX_AGC_A_RATE18_06, ofdm_a); 2562 - rtl8xxxu_write32(priv, REG_TX_AGC_B_RATE18_06, ofdm_b); 2563 2020 2564 - rtl8xxxu_write32(priv, REG_TX_AGC_A_RATE54_24, ofdm_a); 2565 - rtl8xxxu_write32(priv, REG_TX_AGC_B_RATE54_24, ofdm_b); 2021 + rtl8xxxu_write32(priv, REG_TX_AGC_A_RATE18_06, 2022 + ofdm_a + power_base->reg_0e00); 2023 + rtl8xxxu_write32(priv, REG_TX_AGC_B_RATE18_06, 2024 + ofdm_b + power_base->reg_0830); 2025 + 2026 + rtl8xxxu_write32(priv, REG_TX_AGC_A_RATE54_24, 2027 + ofdm_a + power_base->reg_0e04); 2028 + rtl8xxxu_write32(priv, REG_TX_AGC_B_RATE54_24, 2029 + ofdm_b + power_base->reg_0834); 2566 2030 2567 2031 mcs_a = mcsbase[0] | mcsbase[0] << 8 | 2568 2032 mcsbase[0] << 16 | mcsbase[0] << 24; 2569 2033 mcs_b = mcsbase[1] | mcsbase[1] << 8 | 2570 2034 mcsbase[1] << 16 | mcsbase[1] << 24; 2571 2035 2572 - rtl8xxxu_write32(priv, REG_TX_AGC_A_MCS03_MCS00, mcs_a); 2573 - rtl8xxxu_write32(priv, REG_TX_AGC_B_MCS03_MCS00, mcs_b); 2036 + rtl8xxxu_write32(priv, REG_TX_AGC_A_MCS03_MCS00, 2037 + mcs_a + power_base->reg_0e10); 2038 + rtl8xxxu_write32(priv, REG_TX_AGC_B_MCS03_MCS00, 2039 + mcs_b + power_base->reg_083c); 2574 2040 2575 - rtl8xxxu_write32(priv, REG_TX_AGC_A_MCS07_MCS04, mcs_a); 2576 - rtl8xxxu_write32(priv, REG_TX_AGC_B_MCS07_MCS04, mcs_b); 2041 + rtl8xxxu_write32(priv, REG_TX_AGC_A_MCS07_MCS04, 2042 + mcs_a + power_base->reg_0e14); 2043 + rtl8xxxu_write32(priv, REG_TX_AGC_B_MCS07_MCS04, 2044 + mcs_b + power_base->reg_0848); 2577 2045 2578 - rtl8xxxu_write32(priv, REG_TX_AGC_A_MCS11_MCS08, mcs_a); 2579 - rtl8xxxu_write32(priv, REG_TX_AGC_B_MCS11_MCS08, mcs_b); 2046 + rtl8xxxu_write32(priv, REG_TX_AGC_A_MCS11_MCS08, 2047 + mcs_a + power_base->reg_0e18); 2048 + rtl8xxxu_write32(priv, REG_TX_AGC_B_MCS11_MCS08, 2049 + mcs_b + power_base->reg_084c); 2580 2050 2581 - rtl8xxxu_write32(priv, REG_TX_AGC_A_MCS15_MCS12, mcs_a); 2051 + rtl8xxxu_write32(priv, REG_TX_AGC_A_MCS15_MCS12, 2052 + mcs_a + power_base->reg_0e1c); 2582 2053 for (i = 0; i < 3; i++) { 2583 2054 if (i != 2) 2584 2055 val8 = (mcsbase[0] > 8) ? (mcsbase[0] - 8) : 0; ··· 2598 2045 val8 = (mcsbase[0] > 6) ? (mcsbase[0] - 6) : 0; 2599 2046 rtl8xxxu_write8(priv, REG_OFDM0_XC_TX_IQ_IMBALANCE + i, val8); 2600 2047 } 2601 - rtl8xxxu_write32(priv, REG_TX_AGC_B_MCS15_MCS12, mcs_b); 2048 + rtl8xxxu_write32(priv, REG_TX_AGC_B_MCS15_MCS12, 2049 + mcs_b + power_base->reg_0868); 2602 2050 for (i = 0; i < 3; i++) { 2603 2051 if (i != 2) 2604 2052 val8 = (mcsbase[1] > 8) ? (mcsbase[1] - 8) : 0; ··· 2617 2063 int group, tx_idx; 2618 2064 2619 2065 tx_idx = 0; 2620 - group = rtl8723b_channel_to_group(channel); 2066 + group = rtl8xxxu_gen2_channel_to_group(channel); 2621 2067 2622 2068 cck = priv->cck_tx_power_index_B[group]; 2623 2069 val32 = rtl8xxxu_read32(priv, REG_TX_AGC_A_CCK1_MCS32); ··· 2646 2092 2647 2093 rtl8xxxu_write32(priv, REG_TX_AGC_A_MCS03_MCS00, mcs); 2648 2094 rtl8xxxu_write32(priv, REG_TX_AGC_A_MCS07_MCS04, mcs); 2095 + } 2096 + 2097 + static void 2098 + rtl8192e_set_tx_power(struct rtl8xxxu_priv *priv, int channel, bool ht40) 2099 + { 2100 + u32 val32, ofdm, mcs; 2101 + u8 cck, ofdmbase, mcsbase; 2102 + int group, tx_idx; 2103 + 2104 + tx_idx = 0; 2105 + group = rtl8xxxu_gen2_channel_to_group(channel); 2106 + 2107 + cck = priv->cck_tx_power_index_A[group]; 2108 + 2109 + val32 = rtl8xxxu_read32(priv, REG_TX_AGC_A_CCK1_MCS32); 2110 + val32 &= 0xffff00ff; 2111 + val32 |= (cck << 8); 2112 + rtl8xxxu_write32(priv, REG_TX_AGC_A_CCK1_MCS32, val32); 2113 + 2114 + val32 = rtl8xxxu_read32(priv, REG_TX_AGC_B_CCK11_A_CCK2_11); 2115 + val32 &= 0xff; 2116 + val32 |= ((cck << 8) | (cck << 16) | (cck << 24)); 2117 + rtl8xxxu_write32(priv, REG_TX_AGC_B_CCK11_A_CCK2_11, val32); 2118 + 2119 + ofdmbase = priv->ht40_1s_tx_power_index_A[group]; 2120 + ofdmbase += priv->ofdm_tx_power_diff[tx_idx].a; 2121 + ofdm = ofdmbase | ofdmbase << 8 | ofdmbase << 16 | ofdmbase << 24; 2122 + 2123 + rtl8xxxu_write32(priv, REG_TX_AGC_A_RATE18_06, ofdm); 2124 + rtl8xxxu_write32(priv, REG_TX_AGC_A_RATE54_24, ofdm); 2125 + 2126 + mcsbase = priv->ht40_1s_tx_power_index_A[group]; 2127 + if (ht40) 2128 + mcsbase += priv->ht40_tx_power_diff[tx_idx++].a; 2129 + else 2130 + mcsbase += priv->ht20_tx_power_diff[tx_idx++].a; 2131 + mcs = mcsbase | mcsbase << 8 | mcsbase << 16 | mcsbase << 24; 2132 + 2133 + rtl8xxxu_write32(priv, REG_TX_AGC_A_MCS03_MCS00, mcs); 2134 + rtl8xxxu_write32(priv, REG_TX_AGC_A_MCS07_MCS04, mcs); 2135 + rtl8xxxu_write32(priv, REG_TX_AGC_A_MCS11_MCS08, mcs); 2136 + rtl8xxxu_write32(priv, REG_TX_AGC_A_MCS15_MCS12, mcs); 2137 + 2138 + if (priv->tx_paths > 1) { 2139 + cck = priv->cck_tx_power_index_B[group]; 2140 + 2141 + val32 = rtl8xxxu_read32(priv, REG_TX_AGC_B_CCK1_55_MCS32); 2142 + val32 &= 0xff; 2143 + val32 |= ((cck << 8) | (cck << 16) | (cck << 24)); 2144 + rtl8xxxu_write32(priv, REG_TX_AGC_B_CCK1_55_MCS32, val32); 2145 + 2146 + val32 = rtl8xxxu_read32(priv, REG_TX_AGC_B_CCK11_A_CCK2_11); 2147 + val32 &= 0xffffff00; 2148 + val32 |= cck; 2149 + rtl8xxxu_write32(priv, REG_TX_AGC_B_CCK11_A_CCK2_11, val32); 2150 + 2151 + ofdmbase = priv->ht40_1s_tx_power_index_B[group]; 2152 + ofdmbase += priv->ofdm_tx_power_diff[tx_idx].b; 2153 + ofdm = ofdmbase | ofdmbase << 8 | 2154 + ofdmbase << 16 | ofdmbase << 24; 2155 + 2156 + rtl8xxxu_write32(priv, REG_TX_AGC_B_RATE18_06, ofdm); 2157 + rtl8xxxu_write32(priv, REG_TX_AGC_B_RATE54_24, ofdm); 2158 + 2159 + mcsbase = priv->ht40_1s_tx_power_index_B[group]; 2160 + if (ht40) 2161 + mcsbase += priv->ht40_tx_power_diff[tx_idx++].b; 2162 + else 2163 + mcsbase += priv->ht20_tx_power_diff[tx_idx++].b; 2164 + mcs = mcsbase | mcsbase << 8 | mcsbase << 16 | mcsbase << 24; 2165 + 2166 + rtl8xxxu_write32(priv, REG_TX_AGC_B_MCS03_MCS00, mcs); 2167 + rtl8xxxu_write32(priv, REG_TX_AGC_B_MCS07_MCS04, mcs); 2168 + rtl8xxxu_write32(priv, REG_TX_AGC_B_MCS11_MCS08, mcs); 2169 + rtl8xxxu_write32(priv, REG_TX_AGC_B_MCS15_MCS12, mcs); 2170 + } 2649 2171 } 2650 2172 2651 2173 static void rtl8xxxu_set_linktype(struct rtl8xxxu_priv *priv, ··· 2851 2221 } else if (val32 & SYS_CFG_TYPE_ID) { 2852 2222 bonding = rtl8xxxu_read32(priv, REG_HPON_FSM); 2853 2223 bonding &= HPON_FSM_BONDING_MASK; 2854 - if (priv->fops->has_s0s1) { 2224 + if (priv->fops->tx_desc_size == 2225 + sizeof(struct rtl8xxxu_txdesc40)) { 2855 2226 if (bonding == HPON_FSM_BONDING_1T2R) { 2856 2227 sprintf(priv->chip_name, "8191EU"); 2857 2228 priv->rf_paths = 2; ··· 3006 2375 priv->has_xtalk = 1; 3007 2376 priv->xtalk = priv->efuse_wifi.efuse8723.xtal_k & 0x3f; 3008 2377 } 2378 + 2379 + priv->power_base = &rtl8723a_power_base; 2380 + 3009 2381 dev_info(&priv->udev->dev, "Vendor: %.7s\n", 3010 2382 efuse->vendor_name); 3011 2383 dev_info(&priv->udev->dev, "Product: %.41s\n", ··· 3141 2507 dev_info(&priv->udev->dev, "Product: %.20s\n", 3142 2508 efuse->device_name); 3143 2509 2510 + priv->power_base = &rtl8192c_power_base; 2511 + 3144 2512 if (efuse->rf_regulatory & 0x20) { 3145 2513 sprintf(priv->chip_name, "8188RU"); 2514 + priv->rtl_chip = RTL8188R; 3146 2515 priv->hi_pa = 1; 2516 + priv->no_pape = 1; 2517 + priv->power_base = &rtl8188r_power_base; 3147 2518 } 3148 2519 3149 2520 if (rtl8xxxu_debug & RTL8XXXU_DEBUG_EFUSE) { ··· 3180 2541 3181 2542 ether_addr_copy(priv->mac_addr, efuse->mac_addr); 3182 2543 2544 + memcpy(priv->cck_tx_power_index_A, efuse->tx_power_index_A.cck_base, 2545 + sizeof(efuse->tx_power_index_A.cck_base)); 2546 + memcpy(priv->cck_tx_power_index_B, efuse->tx_power_index_B.cck_base, 2547 + sizeof(efuse->tx_power_index_B.cck_base)); 2548 + 2549 + memcpy(priv->ht40_1s_tx_power_index_A, 2550 + efuse->tx_power_index_A.ht40_base, 2551 + sizeof(efuse->tx_power_index_A.ht40_base)); 2552 + memcpy(priv->ht40_1s_tx_power_index_B, 2553 + efuse->tx_power_index_B.ht40_base, 2554 + sizeof(efuse->tx_power_index_B.ht40_base)); 2555 + 2556 + priv->ht20_tx_power_diff[0].a = 2557 + efuse->tx_power_index_A.ht20_ofdm_1s_diff.b; 2558 + priv->ht20_tx_power_diff[0].b = 2559 + efuse->tx_power_index_B.ht20_ofdm_1s_diff.b; 2560 + 2561 + priv->ht40_tx_power_diff[0].a = 0; 2562 + priv->ht40_tx_power_diff[0].b = 0; 2563 + 2564 + for (i = 1; i < RTL8723B_TX_COUNT; i++) { 2565 + priv->ofdm_tx_power_diff[i].a = 2566 + efuse->tx_power_index_A.pwr_diff[i - 1].ofdm; 2567 + priv->ofdm_tx_power_diff[i].b = 2568 + efuse->tx_power_index_B.pwr_diff[i - 1].ofdm; 2569 + 2570 + priv->ht20_tx_power_diff[i].a = 2571 + efuse->tx_power_index_A.pwr_diff[i - 1].ht20; 2572 + priv->ht20_tx_power_diff[i].b = 2573 + efuse->tx_power_index_B.pwr_diff[i - 1].ht20; 2574 + 2575 + priv->ht40_tx_power_diff[i].a = 2576 + efuse->tx_power_index_A.pwr_diff[i - 1].ht40; 2577 + priv->ht40_tx_power_diff[i].b = 2578 + efuse->tx_power_index_B.pwr_diff[i - 1].ht40; 2579 + } 2580 + 3183 2581 priv->has_xtalk = 1; 3184 2582 priv->xtalk = priv->efuse_wifi.efuse8192eu.xtal_k & 0x3f; 3185 2583 ··· 3238 2562 raw[i + 6], raw[i + 7]); 3239 2563 } 3240 2564 } 3241 - /* 3242 - * Temporarily disable 8192eu support 3243 - */ 3244 - return -EINVAL; 3245 2565 return 0; 3246 2566 } 3247 2567 ··· 3724 3052 { 3725 3053 u32 val32; 3726 3054 3727 - val32 = rtl8xxxu_read32(priv, 0x64); 3055 + val32 = rtl8xxxu_read32(priv, REG_PAD_CTRL1); 3728 3056 val32 &= ~(BIT(20) | BIT(24)); 3729 - rtl8xxxu_write32(priv, 0x64, val32); 3057 + rtl8xxxu_write32(priv, REG_PAD_CTRL1, val32); 3730 3058 3731 3059 val32 = rtl8xxxu_read32(priv, REG_GPIO_MUXCFG); 3732 3060 val32 &= ~BIT(4); ··· 3759 3087 } 3760 3088 3761 3089 static int 3762 - rtl8xxxu_init_mac(struct rtl8xxxu_priv *priv, struct rtl8xxxu_reg8val *array) 3090 + rtl8xxxu_init_mac(struct rtl8xxxu_priv *priv) 3763 3091 { 3092 + struct rtl8xxxu_reg8val *array = priv->fops->mactable; 3764 3093 int i, ret; 3765 3094 u16 reg; 3766 3095 u8 val; ··· 3776 3103 ret = rtl8xxxu_write8(priv, reg, val); 3777 3104 if (ret != 1) { 3778 3105 dev_warn(&priv->udev->dev, 3779 - "Failed to initialize MAC\n"); 3106 + "Failed to initialize MAC " 3107 + "(reg: %04x, val %02x)\n", reg, val); 3780 3108 return -EAGAIN; 3781 3109 } 3782 3110 } 3783 3111 3784 - if (priv->rtl_chip != RTL8723B) 3112 + if (priv->rtl_chip != RTL8723B && priv->rtl_chip != RTL8192E) 3785 3113 rtl8xxxu_write8(priv, REG_MAX_AGGR_NUM, 0x0a); 3786 3114 3787 3115 return 0; ··· 3814 3140 return 0; 3815 3141 } 3816 3142 3817 - /* 3818 - * Most of this is black magic retrieved from the old rtl8723au driver 3819 - */ 3820 - static int rtl8xxxu_init_phy_bb(struct rtl8xxxu_priv *priv) 3143 + static void rtl8xxxu_gen1_init_phy_bb(struct rtl8xxxu_priv *priv) 3821 3144 { 3822 3145 u8 val8, ldoa15, ldov12d, lpldo, ldohci12; 3823 3146 u16 val16; 3824 3147 u32 val32; 3825 3148 3826 - /* 3827 - * Todo: The vendor driver maintains a table of PHY register 3828 - * addresses, which is initialized here. Do we need this? 3829 - */ 3149 + val8 = rtl8xxxu_read8(priv, REG_AFE_PLL_CTRL); 3150 + udelay(2); 3151 + val8 |= AFE_PLL_320_ENABLE; 3152 + rtl8xxxu_write8(priv, REG_AFE_PLL_CTRL, val8); 3153 + udelay(2); 3830 3154 3831 - if (priv->rtl_chip == RTL8723B) { 3832 - val16 = rtl8xxxu_read16(priv, REG_SYS_FUNC); 3833 - val16 |= SYS_FUNC_BB_GLB_RSTN | SYS_FUNC_BBRSTB | 3834 - SYS_FUNC_DIO_RF; 3835 - rtl8xxxu_write16(priv, REG_SYS_FUNC, val16); 3155 + rtl8xxxu_write8(priv, REG_AFE_PLL_CTRL + 1, 0xff); 3156 + udelay(2); 3836 3157 3837 - rtl8xxxu_write32(priv, REG_S0S1_PATH_SWITCH, 0x00); 3838 - } else { 3839 - val8 = rtl8xxxu_read8(priv, REG_AFE_PLL_CTRL); 3840 - udelay(2); 3841 - val8 |= AFE_PLL_320_ENABLE; 3842 - rtl8xxxu_write8(priv, REG_AFE_PLL_CTRL, val8); 3843 - udelay(2); 3158 + val16 = rtl8xxxu_read16(priv, REG_SYS_FUNC); 3159 + val16 |= SYS_FUNC_BB_GLB_RSTN | SYS_FUNC_BBRSTB; 3160 + rtl8xxxu_write16(priv, REG_SYS_FUNC, val16); 3844 3161 3845 - rtl8xxxu_write8(priv, REG_AFE_PLL_CTRL + 1, 0xff); 3846 - udelay(2); 3847 - 3848 - val16 = rtl8xxxu_read16(priv, REG_SYS_FUNC); 3849 - val16 |= SYS_FUNC_BB_GLB_RSTN | SYS_FUNC_BBRSTB; 3850 - rtl8xxxu_write16(priv, REG_SYS_FUNC, val16); 3851 - } 3852 - 3853 - if (priv->rtl_chip != RTL8723B) { 3854 - /* AFE_XTAL_RF_GATE (bit 14) if addressing as 32 bit register */ 3855 - val32 = rtl8xxxu_read32(priv, REG_AFE_XTAL_CTRL); 3856 - val32 &= ~AFE_XTAL_RF_GATE; 3857 - if (priv->has_bluetooth) 3858 - val32 &= ~AFE_XTAL_BT_GATE; 3859 - rtl8xxxu_write32(priv, REG_AFE_XTAL_CTRL, val32); 3860 - } 3162 + val32 = rtl8xxxu_read32(priv, REG_AFE_XTAL_CTRL); 3163 + val32 &= ~AFE_XTAL_RF_GATE; 3164 + if (priv->has_bluetooth) 3165 + val32 &= ~AFE_XTAL_BT_GATE; 3166 + rtl8xxxu_write32(priv, REG_AFE_XTAL_CTRL, val32); 3861 3167 3862 3168 /* 6. 0x1f[7:0] = 0x07 */ 3863 3169 val8 = RF_ENABLE | RF_RSTB | RF_SDMRSTB; ··· 3847 3193 rtl8xxxu_init_phy_regs(priv, rtl8188ru_phy_1t_highpa_table); 3848 3194 else if (priv->tx_paths == 2) 3849 3195 rtl8xxxu_init_phy_regs(priv, rtl8192cu_phy_2t_init_table); 3850 - else if (priv->rtl_chip == RTL8723B) { 3851 - /* 3852 - * Why? 3853 - */ 3854 - rtl8xxxu_write8(priv, REG_SYS_FUNC, 0xe3); 3855 - rtl8xxxu_write8(priv, REG_AFE_XTAL_CTRL + 1, 0x80); 3856 - rtl8xxxu_init_phy_regs(priv, rtl8723b_phy_1t_init_table); 3857 - } else 3196 + else 3858 3197 rtl8xxxu_init_phy_regs(priv, rtl8723a_phy_1t_init_table); 3859 3198 3860 - 3861 - if (priv->rtl_chip == RTL8188C && priv->hi_pa && 3199 + if (priv->rtl_chip == RTL8188R && priv->hi_pa && 3862 3200 priv->vendor_umc && priv->chip_cut == 1) 3863 3201 rtl8xxxu_write8(priv, REG_OFDM0_AGC_PARM1 + 2, 0x50); 3202 + 3203 + if (priv->hi_pa) 3204 + rtl8xxxu_init_phy_regs(priv, rtl8xxx_agc_highpa_table); 3205 + else 3206 + rtl8xxxu_init_phy_regs(priv, rtl8xxx_agc_standard_table); 3207 + 3208 + ldoa15 = LDOA15_ENABLE | LDOA15_OBUF; 3209 + ldov12d = LDOV12D_ENABLE | BIT(2) | (2 << LDOV12D_VADJ_SHIFT); 3210 + ldohci12 = 0x57; 3211 + lpldo = 1; 3212 + val32 = (lpldo << 24) | (ldohci12 << 16) | (ldov12d << 8) | ldoa15; 3213 + rtl8xxxu_write32(priv, REG_LDOA15_CTRL, val32); 3214 + } 3215 + 3216 + static void rtl8723bu_init_phy_bb(struct rtl8xxxu_priv *priv) 3217 + { 3218 + u8 val8; 3219 + u16 val16; 3220 + 3221 + val16 = rtl8xxxu_read16(priv, REG_SYS_FUNC); 3222 + val16 |= SYS_FUNC_BB_GLB_RSTN | SYS_FUNC_BBRSTB | SYS_FUNC_DIO_RF; 3223 + rtl8xxxu_write16(priv, REG_SYS_FUNC, val16); 3224 + 3225 + rtl8xxxu_write32(priv, REG_S0S1_PATH_SWITCH, 0x00); 3226 + 3227 + /* 6. 0x1f[7:0] = 0x07 */ 3228 + val8 = RF_ENABLE | RF_RSTB | RF_SDMRSTB; 3229 + rtl8xxxu_write8(priv, REG_RF_CTRL, val8); 3230 + 3231 + /* Why? */ 3232 + rtl8xxxu_write8(priv, REG_SYS_FUNC, 0xe3); 3233 + rtl8xxxu_write8(priv, REG_AFE_XTAL_CTRL + 1, 0x80); 3234 + rtl8xxxu_init_phy_regs(priv, rtl8723b_phy_1t_init_table); 3235 + 3236 + rtl8xxxu_init_phy_regs(priv, rtl8xxx_agc_8723bu_table); 3237 + } 3238 + 3239 + static void rtl8192eu_init_phy_bb(struct rtl8xxxu_priv *priv) 3240 + { 3241 + u8 val8; 3242 + u16 val16; 3243 + 3244 + val16 = rtl8xxxu_read16(priv, REG_SYS_FUNC); 3245 + val16 |= SYS_FUNC_BB_GLB_RSTN | SYS_FUNC_BBRSTB | SYS_FUNC_DIO_RF; 3246 + rtl8xxxu_write16(priv, REG_SYS_FUNC, val16); 3247 + 3248 + /* 6. 0x1f[7:0] = 0x07 */ 3249 + val8 = RF_ENABLE | RF_RSTB | RF_SDMRSTB; 3250 + rtl8xxxu_write8(priv, REG_RF_CTRL, val8); 3251 + 3252 + val16 = rtl8xxxu_read16(priv, REG_SYS_FUNC); 3253 + val16 |= (SYS_FUNC_USBA | SYS_FUNC_USBD | SYS_FUNC_DIO_RF | 3254 + SYS_FUNC_BB_GLB_RSTN | SYS_FUNC_BBRSTB); 3255 + rtl8xxxu_write16(priv, REG_SYS_FUNC, val16); 3256 + val8 = RF_ENABLE | RF_RSTB | RF_SDMRSTB; 3257 + rtl8xxxu_write8(priv, REG_RF_CTRL, val8); 3258 + rtl8xxxu_init_phy_regs(priv, rtl8192eu_phy_init_table); 3259 + 3260 + if (priv->hi_pa) 3261 + rtl8xxxu_init_phy_regs(priv, rtl8xxx_agc_8192eu_highpa_table); 3262 + else 3263 + rtl8xxxu_init_phy_regs(priv, rtl8xxx_agc_8192eu_std_table); 3264 + } 3265 + 3266 + /* 3267 + * Most of this is black magic retrieved from the old rtl8723au driver 3268 + */ 3269 + static int rtl8xxxu_init_phy_bb(struct rtl8xxxu_priv *priv) 3270 + { 3271 + u8 val8; 3272 + u32 val32; 3273 + 3274 + priv->fops->init_phy_bb(priv); 3864 3275 3865 3276 if (priv->tx_paths == 1 && priv->rx_paths == 2) { 3866 3277 /* ··· 3944 3225 rtl8xxxu_write32(priv, REG_FPGA1_TX_INFO, val32); 3945 3226 3946 3227 val32 = rtl8xxxu_read32(priv, REG_CCK0_AFE_SETTING); 3947 - val32 &= 0xff000000; 3948 - val32 |= 0x45000000; 3228 + val32 &= ~CCK0_AFE_RX_MASK; 3229 + val32 &= 0x00ffffff; 3230 + val32 |= 0x40000000; 3231 + val32 |= CCK0_AFE_RX_ANT_B; 3949 3232 rtl8xxxu_write32(priv, REG_CCK0_AFE_SETTING, val32); 3950 3233 3951 3234 val32 = rtl8xxxu_read32(priv, REG_OFDM0_TRX_PATH_ENABLE); ··· 3987 3266 rtl8xxxu_write32(priv, REG_TX_TO_TX, val32); 3988 3267 } 3989 3268 3990 - if (priv->rtl_chip == RTL8723B) 3991 - rtl8xxxu_init_phy_regs(priv, rtl8xxx_agc_8723bu_table); 3992 - else if (priv->hi_pa) 3993 - rtl8xxxu_init_phy_regs(priv, rtl8xxx_agc_highpa_table); 3994 - else 3995 - rtl8xxxu_init_phy_regs(priv, rtl8xxx_agc_standard_table); 3996 - 3997 3269 if (priv->has_xtalk) { 3998 3270 val32 = rtl8xxxu_read32(priv, REG_MAC_PHY_CTRL); 3999 3271 ··· 3997 3283 rtl8xxxu_write32(priv, REG_MAC_PHY_CTRL, val32); 3998 3284 } 3999 3285 4000 - if (priv->rtl_chip != RTL8723B && priv->rtl_chip != RTL8192E) { 4001 - ldoa15 = LDOA15_ENABLE | LDOA15_OBUF; 4002 - ldov12d = LDOV12D_ENABLE | BIT(2) | (2 << LDOV12D_VADJ_SHIFT); 4003 - ldohci12 = 0x57; 4004 - lpldo = 1; 4005 - val32 = (lpldo << 24) | (ldohci12 << 16) | 4006 - (ldov12d << 8) | ldoa15; 4007 - 4008 - rtl8xxxu_write32(priv, REG_LDOA15_CTRL, val32); 4009 - } 3286 + if (priv->rtl_chip == RTL8192E) 3287 + rtl8xxxu_write32(priv, REG_AFE_XTAL_CTRL, 0x000f81fb); 4010 3288 4011 3289 return 0; 4012 3290 } ··· 4114 3408 rtl8xxxu_write16(priv, reg_sw_ctrl, val16); 4115 3409 4116 3410 return 0; 3411 + } 3412 + 3413 + static int rtl8723au_init_phy_rf(struct rtl8xxxu_priv *priv) 3414 + { 3415 + int ret; 3416 + 3417 + ret = rtl8xxxu_init_phy_rf(priv, rtl8723au_radioa_1t_init_table, RF_A); 3418 + 3419 + /* Reduce 80M spur */ 3420 + rtl8xxxu_write32(priv, REG_AFE_XTAL_CTRL, 0x0381808d); 3421 + rtl8xxxu_write32(priv, REG_AFE_PLL_CTRL, 0xf0ffff83); 3422 + rtl8xxxu_write32(priv, REG_AFE_PLL_CTRL, 0xf0ffff82); 3423 + rtl8xxxu_write32(priv, REG_AFE_PLL_CTRL, 0xf0ffff83); 3424 + 3425 + return ret; 3426 + } 3427 + 3428 + static int rtl8723bu_init_phy_rf(struct rtl8xxxu_priv *priv) 3429 + { 3430 + int ret; 3431 + 3432 + ret = rtl8xxxu_init_phy_rf(priv, rtl8723bu_radioa_1t_init_table, RF_A); 3433 + /* 3434 + * PHY LCK 3435 + */ 3436 + rtl8xxxu_write_rfreg(priv, RF_A, 0xb0, 0xdfbe0); 3437 + rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_MODE_AG, 0x8c01); 3438 + msleep(200); 3439 + rtl8xxxu_write_rfreg(priv, RF_A, 0xb0, 0xdffe0); 3440 + 3441 + return ret; 3442 + } 3443 + 3444 + #ifdef CONFIG_RTL8XXXU_UNTESTED 3445 + static int rtl8192cu_init_phy_rf(struct rtl8xxxu_priv *priv) 3446 + { 3447 + struct rtl8xxxu_rfregval *rftable; 3448 + int ret; 3449 + 3450 + if (priv->rtl_chip == RTL8188R) { 3451 + rftable = rtl8188ru_radioa_1t_highpa_table; 3452 + ret = rtl8xxxu_init_phy_rf(priv, rftable, RF_A); 3453 + } else if (priv->rf_paths == 1) { 3454 + rftable = rtl8192cu_radioa_1t_init_table; 3455 + ret = rtl8xxxu_init_phy_rf(priv, rftable, RF_A); 3456 + } else { 3457 + rftable = rtl8192cu_radioa_2t_init_table; 3458 + ret = rtl8xxxu_init_phy_rf(priv, rftable, RF_A); 3459 + if (ret) 3460 + goto exit; 3461 + rftable = rtl8192cu_radiob_2t_init_table; 3462 + ret = rtl8xxxu_init_phy_rf(priv, rftable, RF_B); 3463 + } 3464 + 3465 + exit: 3466 + return ret; 3467 + } 3468 + #endif 3469 + 3470 + static int rtl8192eu_init_phy_rf(struct rtl8xxxu_priv *priv) 3471 + { 3472 + int ret; 3473 + 3474 + ret = rtl8xxxu_init_phy_rf(priv, rtl8192eu_radioa_init_table, RF_A); 3475 + if (ret) 3476 + goto exit; 3477 + 3478 + ret = rtl8xxxu_init_phy_rf(priv, rtl8192eu_radiob_init_table, RF_B); 3479 + 3480 + exit: 3481 + return ret; 4117 3482 } 4118 3483 4119 3484 static int rtl8xxxu_llt_write(struct rtl8xxxu_priv *priv, u8 address, u8 data) ··· 4595 3818 return false; 4596 3819 } 4597 3820 4598 - static bool rtl8723bu_simularity_compare(struct rtl8xxxu_priv *priv, 4599 - int result[][8], int c1, int c2) 3821 + static bool rtl8xxxu_gen2_simularity_compare(struct rtl8xxxu_priv *priv, 3822 + int result[][8], int c1, int c2) 4600 3823 { 4601 3824 u32 i, j, diff, simubitmap, bound = 0; 4602 3825 int candidate[2] = {-1, -1}; /* for path A and path B */ ··· 5166 4389 return result; 5167 4390 } 5168 4391 5169 - #ifdef RTL8723BU_PATH_B 5170 - static int rtl8723bu_iqk_path_b(struct rtl8xxxu_priv *priv) 4392 + static int rtl8192eu_iqk_path_a(struct rtl8xxxu_priv *priv) 5171 4393 { 5172 - u32 reg_eac, reg_eb4, reg_ebc, reg_ec4, reg_ecc, path_sel; 4394 + u32 reg_eac, reg_e94, reg_e9c; 5173 4395 int result = 0; 5174 4396 5175 - path_sel = rtl8xxxu_read32(priv, REG_S0S1_PATH_SWITCH); 4397 + /* 4398 + * TX IQK 4399 + * PA/PAD controlled by 0x0 4400 + */ 4401 + rtl8xxxu_write32(priv, REG_FPGA0_IQK, 0x00000000); 4402 + rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_UNKNOWN_DF, 0x00180); 4403 + rtl8xxxu_write32(priv, REG_FPGA0_IQK, 0x80800000); 5176 4404 5177 - val32 = rtl8xxxu_read32(priv, REG_FPGA0_IQK); 5178 - val32 &= 0x000000ff; 5179 - rtl8xxxu_write32(priv, REG_FPGA0_IQK, val32); 4405 + /* Path A IQK setting */ 4406 + rtl8xxxu_write32(priv, REG_TX_IQK_TONE_A, 0x18008c1c); 4407 + rtl8xxxu_write32(priv, REG_RX_IQK_TONE_A, 0x38008c1c); 4408 + rtl8xxxu_write32(priv, REG_TX_IQK_TONE_B, 0x38008c1c); 4409 + rtl8xxxu_write32(priv, REG_RX_IQK_TONE_B, 0x38008c1c); 5180 4410 5181 - /* One shot, path B LOK & IQK */ 5182 - rtl8xxxu_write32(priv, REG_IQK_AGC_CONT, 0x00000002); 5183 - rtl8xxxu_write32(priv, REG_IQK_AGC_CONT, 0x00000000); 4411 + rtl8xxxu_write32(priv, REG_TX_IQK_PI_A, 0x82140303); 4412 + rtl8xxxu_write32(priv, REG_RX_IQK_PI_A, 0x68160000); 4413 + 4414 + /* LO calibration setting */ 4415 + rtl8xxxu_write32(priv, REG_IQK_AGC_RSP, 0x00462911); 4416 + 4417 + /* One shot, path A LOK & IQK */ 4418 + rtl8xxxu_write32(priv, REG_IQK_AGC_PTS, 0xf9000000); 4419 + rtl8xxxu_write32(priv, REG_IQK_AGC_PTS, 0xf8000000); 4420 + 4421 + mdelay(10); 4422 + 4423 + /* Check failed */ 4424 + reg_eac = rtl8xxxu_read32(priv, REG_RX_POWER_AFTER_IQK_A_2); 4425 + reg_e94 = rtl8xxxu_read32(priv, REG_TX_POWER_BEFORE_IQK_A); 4426 + reg_e9c = rtl8xxxu_read32(priv, REG_TX_POWER_AFTER_IQK_A); 4427 + 4428 + if (!(reg_eac & BIT(28)) && 4429 + ((reg_e94 & 0x03ff0000) != 0x01420000) && 4430 + ((reg_e9c & 0x03ff0000) != 0x00420000)) 4431 + result |= 0x01; 4432 + 4433 + return result; 4434 + } 4435 + 4436 + static int rtl8192eu_rx_iqk_path_a(struct rtl8xxxu_priv *priv) 4437 + { 4438 + u32 reg_ea4, reg_eac, reg_e94, reg_e9c, val32; 4439 + int result = 0; 4440 + 4441 + /* Leave IQK mode */ 4442 + rtl8xxxu_write32(priv, REG_FPGA0_IQK, 0x00); 4443 + 4444 + /* Enable path A PA in TX IQK mode */ 4445 + rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_WE_LUT, 0x800a0); 4446 + rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_RCK_OS, 0x30000); 4447 + rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_TXPA_G1, 0x0000f); 4448 + rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_TXPA_G2, 0xf117b); 4449 + 4450 + /* PA/PAD control by 0x56, and set = 0x0 */ 4451 + rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_UNKNOWN_DF, 0x00980); 4452 + rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_UNKNOWN_56, 0x51000); 4453 + 4454 + /* Enter IQK mode */ 4455 + rtl8xxxu_write32(priv, REG_FPGA0_IQK, 0x80800000); 4456 + 4457 + /* TX IQK setting */ 4458 + rtl8xxxu_write32(priv, REG_TX_IQK, 0x01007c00); 4459 + rtl8xxxu_write32(priv, REG_RX_IQK, 0x01004800); 4460 + 4461 + /* path-A IQK setting */ 4462 + rtl8xxxu_write32(priv, REG_TX_IQK_TONE_A, 0x18008c1c); 4463 + rtl8xxxu_write32(priv, REG_RX_IQK_TONE_A, 0x38008c1c); 4464 + rtl8xxxu_write32(priv, REG_TX_IQK_TONE_B, 0x38008c1c); 4465 + rtl8xxxu_write32(priv, REG_RX_IQK_TONE_B, 0x38008c1c); 4466 + 4467 + rtl8xxxu_write32(priv, REG_TX_IQK_PI_A, 0x82160c1f); 4468 + rtl8xxxu_write32(priv, REG_RX_IQK_PI_A, 0x68160c1f); 4469 + 4470 + /* LO calibration setting */ 4471 + rtl8xxxu_write32(priv, REG_IQK_AGC_RSP, 0x0046a911); 4472 + 4473 + /* One shot, path A LOK & IQK */ 4474 + rtl8xxxu_write32(priv, REG_IQK_AGC_PTS, 0xfa000000); 4475 + rtl8xxxu_write32(priv, REG_IQK_AGC_PTS, 0xf8000000); 4476 + 4477 + mdelay(10); 4478 + 4479 + /* Check failed */ 4480 + reg_eac = rtl8xxxu_read32(priv, REG_RX_POWER_AFTER_IQK_A_2); 4481 + reg_e94 = rtl8xxxu_read32(priv, REG_TX_POWER_BEFORE_IQK_A); 4482 + reg_e9c = rtl8xxxu_read32(priv, REG_TX_POWER_AFTER_IQK_A); 4483 + 4484 + if (!(reg_eac & BIT(28)) && 4485 + ((reg_e94 & 0x03ff0000) != 0x01420000) && 4486 + ((reg_e9c & 0x03ff0000) != 0x00420000)) { 4487 + result |= 0x01; 4488 + } else { 4489 + /* PA/PAD controlled by 0x0 */ 4490 + rtl8xxxu_write32(priv, REG_FPGA0_IQK, 0x00000000); 4491 + rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_UNKNOWN_DF, 0x180); 4492 + goto out; 4493 + } 4494 + 4495 + val32 = 0x80007c00 | 4496 + (reg_e94 & 0x03ff0000) | ((reg_e9c >> 16) & 0x03ff); 4497 + rtl8xxxu_write32(priv, REG_TX_IQK, val32); 4498 + 4499 + /* Modify RX IQK mode table */ 4500 + rtl8xxxu_write32(priv, REG_FPGA0_IQK, 0x00000000); 4501 + 4502 + rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_WE_LUT, 0x800a0); 4503 + rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_RCK_OS, 0x30000); 4504 + rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_TXPA_G1, 0x0000f); 4505 + rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_TXPA_G2, 0xf7ffa); 4506 + 4507 + /* PA/PAD control by 0x56, and set = 0x0 */ 4508 + rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_UNKNOWN_DF, 0x00980); 4509 + rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_UNKNOWN_56, 0x51000); 4510 + 4511 + /* Enter IQK mode */ 4512 + rtl8xxxu_write32(priv, REG_FPGA0_IQK, 0x80800000); 4513 + 4514 + /* IQK setting */ 4515 + rtl8xxxu_write32(priv, REG_RX_IQK, 0x01004800); 4516 + 4517 + /* Path A IQK setting */ 4518 + rtl8xxxu_write32(priv, REG_TX_IQK_TONE_A, 0x38008c1c); 4519 + rtl8xxxu_write32(priv, REG_RX_IQK_TONE_A, 0x18008c1c); 4520 + rtl8xxxu_write32(priv, REG_TX_IQK_TONE_B, 0x38008c1c); 4521 + rtl8xxxu_write32(priv, REG_RX_IQK_TONE_B, 0x38008c1c); 4522 + 4523 + rtl8xxxu_write32(priv, REG_TX_IQK_PI_A, 0x82160c1f); 4524 + rtl8xxxu_write32(priv, REG_RX_IQK_PI_A, 0x28160c1f); 4525 + 4526 + /* LO calibration setting */ 4527 + rtl8xxxu_write32(priv, REG_IQK_AGC_RSP, 0x0046a891); 4528 + 4529 + /* One shot, path A LOK & IQK */ 4530 + rtl8xxxu_write32(priv, REG_IQK_AGC_PTS, 0xfa000000); 4531 + rtl8xxxu_write32(priv, REG_IQK_AGC_PTS, 0xf8000000); 4532 + 4533 + mdelay(10); 4534 + 4535 + reg_eac = rtl8xxxu_read32(priv, REG_RX_POWER_AFTER_IQK_A_2); 4536 + reg_ea4 = rtl8xxxu_read32(priv, REG_RX_POWER_BEFORE_IQK_A_2); 4537 + 4538 + rtl8xxxu_write32(priv, REG_FPGA0_IQK, 0x00000000); 4539 + rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_UNKNOWN_DF, 0x180); 4540 + 4541 + if (!(reg_eac & BIT(27)) && 4542 + ((reg_ea4 & 0x03ff0000) != 0x01320000) && 4543 + ((reg_eac & 0x03ff0000) != 0x00360000)) 4544 + result |= 0x02; 4545 + else 4546 + dev_warn(&priv->udev->dev, "%s: Path A RX IQK failed!\n", 4547 + __func__); 4548 + 4549 + out: 4550 + return result; 4551 + } 4552 + 4553 + static int rtl8192eu_iqk_path_b(struct rtl8xxxu_priv *priv) 4554 + { 4555 + u32 reg_eac, reg_eb4, reg_ebc; 4556 + int result = 0; 4557 + 4558 + rtl8xxxu_write32(priv, REG_FPGA0_IQK, 0x00000000); 4559 + rtl8xxxu_write_rfreg(priv, RF_B, RF6052_REG_UNKNOWN_DF, 0x00180); 4560 + rtl8xxxu_write32(priv, REG_FPGA0_IQK, 0x80800000); 4561 + 4562 + rtl8xxxu_write32(priv, REG_FPGA0_IQK, 0x00000000); 4563 + rtl8xxxu_write32(priv, REG_FPGA0_IQK, 0x80800000); 4564 + 4565 + /* Path B IQK setting */ 4566 + rtl8xxxu_write32(priv, REG_TX_IQK_TONE_A, 0x38008c1c); 4567 + rtl8xxxu_write32(priv, REG_RX_IQK_TONE_A, 0x38008c1c); 4568 + rtl8xxxu_write32(priv, REG_TX_IQK_TONE_B, 0x18008c1c); 4569 + rtl8xxxu_write32(priv, REG_RX_IQK_TONE_B, 0x38008c1c); 4570 + 4571 + rtl8xxxu_write32(priv, REG_TX_IQK_PI_B, 0x821403e2); 4572 + rtl8xxxu_write32(priv, REG_RX_IQK_PI_B, 0x68160000); 4573 + 4574 + /* LO calibration setting */ 4575 + rtl8xxxu_write32(priv, REG_IQK_AGC_RSP, 0x00492911); 4576 + 4577 + /* One shot, path A LOK & IQK */ 4578 + rtl8xxxu_write32(priv, REG_IQK_AGC_PTS, 0xfa000000); 4579 + rtl8xxxu_write32(priv, REG_IQK_AGC_PTS, 0xf8000000); 5184 4580 5185 4581 mdelay(1); 5186 4582 ··· 5361 4411 reg_eac = rtl8xxxu_read32(priv, REG_RX_POWER_AFTER_IQK_A_2); 5362 4412 reg_eb4 = rtl8xxxu_read32(priv, REG_TX_POWER_BEFORE_IQK_B); 5363 4413 reg_ebc = rtl8xxxu_read32(priv, REG_TX_POWER_AFTER_IQK_B); 5364 - reg_ec4 = rtl8xxxu_read32(priv, REG_RX_POWER_BEFORE_IQK_B_2); 5365 - reg_ecc = rtl8xxxu_read32(priv, REG_RX_POWER_AFTER_IQK_B_2); 5366 4414 5367 4415 if (!(reg_eac & BIT(31)) && 5368 4416 ((reg_eb4 & 0x03ff0000) != 0x01420000) && 5369 4417 ((reg_ebc & 0x03ff0000) != 0x00420000)) 5370 4418 result |= 0x01; 5371 4419 else 4420 + dev_warn(&priv->udev->dev, "%s: Path B IQK failed!\n", 4421 + __func__); 4422 + 4423 + return result; 4424 + } 4425 + 4426 + static int rtl8192eu_rx_iqk_path_b(struct rtl8xxxu_priv *priv) 4427 + { 4428 + u32 reg_eac, reg_eb4, reg_ebc, reg_ec4, reg_ecc, val32; 4429 + int result = 0; 4430 + 4431 + /* Leave IQK mode */ 4432 + rtl8xxxu_write32(priv, REG_FPGA0_IQK, 0x00000000); 4433 + 4434 + /* Enable path A PA in TX IQK mode */ 4435 + rtl8xxxu_write_rfreg(priv, RF_B, RF6052_REG_WE_LUT, 0x800a0); 4436 + rtl8xxxu_write_rfreg(priv, RF_B, RF6052_REG_RCK_OS, 0x30000); 4437 + rtl8xxxu_write_rfreg(priv, RF_B, RF6052_REG_TXPA_G1, 0x0000f); 4438 + rtl8xxxu_write_rfreg(priv, RF_B, RF6052_REG_TXPA_G2, 0xf117b); 4439 + 4440 + /* PA/PAD control by 0x56, and set = 0x0 */ 4441 + rtl8xxxu_write_rfreg(priv, RF_B, RF6052_REG_UNKNOWN_DF, 0x00980); 4442 + rtl8xxxu_write_rfreg(priv, RF_B, RF6052_REG_UNKNOWN_56, 0x51000); 4443 + 4444 + /* Enter IQK mode */ 4445 + rtl8xxxu_write32(priv, REG_FPGA0_IQK, 0x80800000); 4446 + 4447 + /* TX IQK setting */ 4448 + rtl8xxxu_write32(priv, REG_TX_IQK, 0x01007c00); 4449 + rtl8xxxu_write32(priv, REG_RX_IQK, 0x01004800); 4450 + 4451 + /* path-A IQK setting */ 4452 + rtl8xxxu_write32(priv, REG_TX_IQK_TONE_A, 0x38008c1c); 4453 + rtl8xxxu_write32(priv, REG_RX_IQK_TONE_A, 0x38008c1c); 4454 + rtl8xxxu_write32(priv, REG_TX_IQK_TONE_B, 0x18008c1c); 4455 + rtl8xxxu_write32(priv, REG_RX_IQK_TONE_B, 0x38008c1c); 4456 + 4457 + rtl8xxxu_write32(priv, REG_TX_IQK_PI_B, 0x82160c1f); 4458 + rtl8xxxu_write32(priv, REG_RX_IQK_PI_B, 0x68160c1f); 4459 + 4460 + /* LO calibration setting */ 4461 + rtl8xxxu_write32(priv, REG_IQK_AGC_RSP, 0x0046a911); 4462 + 4463 + /* One shot, path A LOK & IQK */ 4464 + rtl8xxxu_write32(priv, REG_IQK_AGC_PTS, 0xfa000000); 4465 + rtl8xxxu_write32(priv, REG_IQK_AGC_PTS, 0xf8000000); 4466 + 4467 + mdelay(10); 4468 + 4469 + /* Check failed */ 4470 + reg_eac = rtl8xxxu_read32(priv, REG_RX_POWER_AFTER_IQK_A_2); 4471 + reg_eb4 = rtl8xxxu_read32(priv, REG_TX_POWER_BEFORE_IQK_B); 4472 + reg_ebc = rtl8xxxu_read32(priv, REG_TX_POWER_AFTER_IQK_B); 4473 + 4474 + if (!(reg_eac & BIT(31)) && 4475 + ((reg_eb4 & 0x03ff0000) != 0x01420000) && 4476 + ((reg_ebc & 0x03ff0000) != 0x00420000)) { 4477 + result |= 0x01; 4478 + } else { 4479 + /* 4480 + * PA/PAD controlled by 0x0 4481 + * Vendor driver restores RF_A here which I believe is a bug 4482 + */ 4483 + rtl8xxxu_write32(priv, REG_FPGA0_IQK, 0x00000000); 4484 + rtl8xxxu_write_rfreg(priv, RF_B, RF6052_REG_UNKNOWN_DF, 0x180); 5372 4485 goto out; 4486 + } 4487 + 4488 + val32 = 0x80007c00 | 4489 + (reg_eb4 & 0x03ff0000) | ((reg_ebc >> 16) & 0x03ff); 4490 + rtl8xxxu_write32(priv, REG_TX_IQK, val32); 4491 + 4492 + /* Modify RX IQK mode table */ 4493 + rtl8xxxu_write32(priv, REG_FPGA0_IQK, 0x00000000); 4494 + 4495 + rtl8xxxu_write_rfreg(priv, RF_B, RF6052_REG_WE_LUT, 0x800a0); 4496 + rtl8xxxu_write_rfreg(priv, RF_B, RF6052_REG_RCK_OS, 0x30000); 4497 + rtl8xxxu_write_rfreg(priv, RF_B, RF6052_REG_TXPA_G1, 0x0000f); 4498 + rtl8xxxu_write_rfreg(priv, RF_B, RF6052_REG_TXPA_G2, 0xf7ffa); 4499 + 4500 + /* PA/PAD control by 0x56, and set = 0x0 */ 4501 + rtl8xxxu_write_rfreg(priv, RF_B, RF6052_REG_UNKNOWN_DF, 0x00980); 4502 + rtl8xxxu_write_rfreg(priv, RF_B, RF6052_REG_UNKNOWN_56, 0x51000); 4503 + 4504 + /* Enter IQK mode */ 4505 + rtl8xxxu_write32(priv, REG_FPGA0_IQK, 0x80800000); 4506 + 4507 + /* IQK setting */ 4508 + rtl8xxxu_write32(priv, REG_RX_IQK, 0x01004800); 4509 + 4510 + /* Path A IQK setting */ 4511 + rtl8xxxu_write32(priv, REG_TX_IQK_TONE_A, 0x38008c1c); 4512 + rtl8xxxu_write32(priv, REG_RX_IQK_TONE_A, 0x38008c1c); 4513 + rtl8xxxu_write32(priv, REG_TX_IQK_TONE_B, 0x38008c1c); 4514 + rtl8xxxu_write32(priv, REG_RX_IQK_TONE_B, 0x18008c1c); 4515 + 4516 + rtl8xxxu_write32(priv, REG_TX_IQK_PI_A, 0x82160c1f); 4517 + rtl8xxxu_write32(priv, REG_RX_IQK_PI_A, 0x28160c1f); 4518 + 4519 + /* LO calibration setting */ 4520 + rtl8xxxu_write32(priv, REG_IQK_AGC_RSP, 0x0046a891); 4521 + 4522 + /* One shot, path A LOK & IQK */ 4523 + rtl8xxxu_write32(priv, REG_IQK_AGC_PTS, 0xfa000000); 4524 + rtl8xxxu_write32(priv, REG_IQK_AGC_PTS, 0xf8000000); 4525 + 4526 + mdelay(10); 4527 + 4528 + reg_eac = rtl8xxxu_read32(priv, REG_RX_POWER_AFTER_IQK_A_2); 4529 + reg_ec4 = rtl8xxxu_read32(priv, REG_RX_POWER_BEFORE_IQK_B_2); 4530 + reg_ecc = rtl8xxxu_read32(priv, REG_RX_POWER_AFTER_IQK_B_2); 4531 + 4532 + rtl8xxxu_write32(priv, REG_FPGA0_IQK, 0x00000000); 4533 + rtl8xxxu_write_rfreg(priv, RF_B, RF6052_REG_UNKNOWN_DF, 0x180); 5373 4534 5374 4535 if (!(reg_eac & BIT(30)) && 5375 - (((reg_ec4 & 0x03ff0000) >> 16) != 0x132) && 5376 - (((reg_ecc & 0x03ff0000) >> 16) != 0x36)) 4536 + ((reg_ec4 & 0x03ff0000) != 0x01320000) && 4537 + ((reg_ecc & 0x03ff0000) != 0x00360000)) 5377 4538 result |= 0x02; 5378 4539 else 5379 4540 dev_warn(&priv->udev->dev, "%s: Path B RX IQK failed!\n", 5380 4541 __func__); 4542 + 5381 4543 out: 5382 4544 return result; 5383 4545 } 5384 - #endif 5385 4546 5386 4547 static void rtl8xxxu_phy_iqcalibrate(struct rtl8xxxu_priv *priv, 5387 4548 int result[][8], int t) ··· 5558 4497 rtl8xxxu_write32(priv, REG_OFDM0_TR_MUX_PAR, 0x000800e4); 5559 4498 rtl8xxxu_write32(priv, REG_FPGA0_XCD_RF_SW_CTRL, 0x22204000); 5560 4499 5561 - val32 = rtl8xxxu_read32(priv, REG_FPGA0_XAB_RF_SW_CTRL); 5562 - val32 |= (FPGA0_RF_PAPE | (FPGA0_RF_PAPE << FPGA0_RF_BD_CTRL_SHIFT)); 5563 - rtl8xxxu_write32(priv, REG_FPGA0_XAB_RF_SW_CTRL, val32); 4500 + if (!priv->no_pape) { 4501 + val32 = rtl8xxxu_read32(priv, REG_FPGA0_XAB_RF_SW_CTRL); 4502 + val32 |= (FPGA0_RF_PAPE | 4503 + (FPGA0_RF_PAPE << FPGA0_RF_BD_CTRL_SHIFT)); 4504 + rtl8xxxu_write32(priv, REG_FPGA0_XAB_RF_SW_CTRL, val32); 4505 + } 5564 4506 5565 4507 val32 = rtl8xxxu_read32(priv, REG_FPGA0_XA_RF_INT_OE); 5566 4508 val32 &= ~BIT(10); ··· 5756 4692 rtl8xxxu_write32(priv, REG_OFDM0_TR_MUX_PAR, 0x000800e4); 5757 4693 rtl8xxxu_write32(priv, REG_FPGA0_XCD_RF_SW_CTRL, 0x22204000); 5758 4694 5759 - #ifdef RTL8723BU_PATH_B 5760 - /* Set RF mode to standby Path B */ 5761 - if (priv->tx_paths > 1) 5762 - rtl8xxxu_write_rfreg(priv, RF_B, RF6052_REG_AC, 0x10000); 5763 - #endif 5764 - 5765 - #if 0 5766 - /* Page B init */ 5767 - rtl8xxxu_write32(priv, REG_CONFIG_ANT_A, 0x0f600000); 5768 - 5769 - if (priv->tx_paths > 1) 5770 - rtl8xxxu_write32(priv, REG_CONFIG_ANT_B, 0x0f600000); 5771 - #endif 5772 - 5773 4695 /* 5774 4696 * RX IQ calibration setting for 8723B D cut large current issue 5775 4697 * when leaving IPS ··· 5784 4734 val32 = rtl8xxxu_read32(priv, REG_FPGA0_IQK); 5785 4735 val32 &= 0x000000ff; 5786 4736 rtl8xxxu_write32(priv, REG_FPGA0_IQK, val32); 5787 - 5788 - #if 0 /* Only needed in restore case, we may need this when going to suspend */ 5789 - priv->RFCalibrateInfo.TxLOK[RF_A] = 5790 - rtl8xxxu_read_rfreg(priv, RF_A, 5791 - RF6052_REG_TXM_IDAC); 5792 - #endif 5793 4737 5794 4738 val32 = rtl8xxxu_read32(priv, 5795 4739 REG_TX_POWER_BEFORE_IQK_A); ··· 5907 4863 } 5908 4864 } 5909 4865 4866 + static void rtl8192eu_phy_iqcalibrate(struct rtl8xxxu_priv *priv, 4867 + int result[][8], int t) 4868 + { 4869 + struct device *dev = &priv->udev->dev; 4870 + u32 i, val32; 4871 + int path_a_ok, path_b_ok; 4872 + int retry = 2; 4873 + const u32 adda_regs[RTL8XXXU_ADDA_REGS] = { 4874 + REG_FPGA0_XCD_SWITCH_CTRL, REG_BLUETOOTH, 4875 + REG_RX_WAIT_CCA, REG_TX_CCK_RFON, 4876 + REG_TX_CCK_BBON, REG_TX_OFDM_RFON, 4877 + REG_TX_OFDM_BBON, REG_TX_TO_RX, 4878 + REG_TX_TO_TX, REG_RX_CCK, 4879 + REG_RX_OFDM, REG_RX_WAIT_RIFS, 4880 + REG_RX_TO_RX, REG_STANDBY, 4881 + REG_SLEEP, REG_PMPD_ANAEN 4882 + }; 4883 + const u32 iqk_mac_regs[RTL8XXXU_MAC_REGS] = { 4884 + REG_TXPAUSE, REG_BEACON_CTRL, 4885 + REG_BEACON_CTRL_1, REG_GPIO_MUXCFG 4886 + }; 4887 + const u32 iqk_bb_regs[RTL8XXXU_BB_REGS] = { 4888 + REG_OFDM0_TRX_PATH_ENABLE, REG_OFDM0_TR_MUX_PAR, 4889 + REG_FPGA0_XCD_RF_SW_CTRL, REG_CONFIG_ANT_A, REG_CONFIG_ANT_B, 4890 + REG_FPGA0_XAB_RF_SW_CTRL, REG_FPGA0_XA_RF_INT_OE, 4891 + REG_FPGA0_XB_RF_INT_OE, REG_CCK0_AFE_SETTING 4892 + }; 4893 + u8 xa_agc = rtl8xxxu_read32(priv, REG_OFDM0_XA_AGC_CORE1) & 0xff; 4894 + u8 xb_agc = rtl8xxxu_read32(priv, REG_OFDM0_XB_AGC_CORE1) & 0xff; 4895 + 4896 + /* 4897 + * Note: IQ calibration must be performed after loading 4898 + * PHY_REG.txt , and radio_a, radio_b.txt 4899 + */ 4900 + 4901 + if (t == 0) { 4902 + /* Save ADDA parameters, turn Path A ADDA on */ 4903 + rtl8xxxu_save_regs(priv, adda_regs, priv->adda_backup, 4904 + RTL8XXXU_ADDA_REGS); 4905 + rtl8xxxu_save_mac_regs(priv, iqk_mac_regs, priv->mac_backup); 4906 + rtl8xxxu_save_regs(priv, iqk_bb_regs, 4907 + priv->bb_backup, RTL8XXXU_BB_REGS); 4908 + } 4909 + 4910 + rtl8xxxu_path_adda_on(priv, adda_regs, true); 4911 + 4912 + /* MAC settings */ 4913 + rtl8xxxu_mac_calibration(priv, iqk_mac_regs, priv->mac_backup); 4914 + 4915 + val32 = rtl8xxxu_read32(priv, REG_CCK0_AFE_SETTING); 4916 + val32 |= 0x0f000000; 4917 + rtl8xxxu_write32(priv, REG_CCK0_AFE_SETTING, val32); 4918 + 4919 + rtl8xxxu_write32(priv, REG_OFDM0_TRX_PATH_ENABLE, 0x03a05600); 4920 + rtl8xxxu_write32(priv, REG_OFDM0_TR_MUX_PAR, 0x000800e4); 4921 + rtl8xxxu_write32(priv, REG_FPGA0_XCD_RF_SW_CTRL, 0x22208200); 4922 + 4923 + val32 = rtl8xxxu_read32(priv, REG_FPGA0_XAB_RF_SW_CTRL); 4924 + val32 |= (FPGA0_RF_PAPE | (FPGA0_RF_PAPE << FPGA0_RF_BD_CTRL_SHIFT)); 4925 + rtl8xxxu_write32(priv, REG_FPGA0_XAB_RF_SW_CTRL, val32); 4926 + 4927 + val32 = rtl8xxxu_read32(priv, REG_FPGA0_XA_RF_INT_OE); 4928 + val32 |= BIT(10); 4929 + rtl8xxxu_write32(priv, REG_FPGA0_XA_RF_INT_OE, val32); 4930 + val32 = rtl8xxxu_read32(priv, REG_FPGA0_XB_RF_INT_OE); 4931 + val32 |= BIT(10); 4932 + rtl8xxxu_write32(priv, REG_FPGA0_XB_RF_INT_OE, val32); 4933 + 4934 + rtl8xxxu_write32(priv, REG_FPGA0_IQK, 0x80800000); 4935 + rtl8xxxu_write32(priv, REG_TX_IQK, 0x01007c00); 4936 + rtl8xxxu_write32(priv, REG_RX_IQK, 0x01004800); 4937 + 4938 + for (i = 0; i < retry; i++) { 4939 + path_a_ok = rtl8192eu_iqk_path_a(priv); 4940 + if (path_a_ok == 0x01) { 4941 + val32 = rtl8xxxu_read32(priv, 4942 + REG_TX_POWER_BEFORE_IQK_A); 4943 + result[t][0] = (val32 >> 16) & 0x3ff; 4944 + val32 = rtl8xxxu_read32(priv, 4945 + REG_TX_POWER_AFTER_IQK_A); 4946 + result[t][1] = (val32 >> 16) & 0x3ff; 4947 + 4948 + break; 4949 + } 4950 + } 4951 + 4952 + if (!path_a_ok) 4953 + dev_dbg(dev, "%s: Path A TX IQK failed!\n", __func__); 4954 + 4955 + for (i = 0; i < retry; i++) { 4956 + path_a_ok = rtl8192eu_rx_iqk_path_a(priv); 4957 + if (path_a_ok == 0x03) { 4958 + val32 = rtl8xxxu_read32(priv, 4959 + REG_RX_POWER_BEFORE_IQK_A_2); 4960 + result[t][2] = (val32 >> 16) & 0x3ff; 4961 + val32 = rtl8xxxu_read32(priv, 4962 + REG_RX_POWER_AFTER_IQK_A_2); 4963 + result[t][3] = (val32 >> 16) & 0x3ff; 4964 + 4965 + break; 4966 + } 4967 + } 4968 + 4969 + if (!path_a_ok) 4970 + dev_dbg(dev, "%s: Path A RX IQK failed!\n", __func__); 4971 + 4972 + if (priv->rf_paths > 1) { 4973 + /* Path A into standby */ 4974 + rtl8xxxu_write32(priv, REG_FPGA0_IQK, 0x00000000); 4975 + rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_AC, 0x10000); 4976 + rtl8xxxu_write32(priv, REG_FPGA0_IQK, 0x80800000); 4977 + 4978 + /* Turn Path B ADDA on */ 4979 + rtl8xxxu_path_adda_on(priv, adda_regs, false); 4980 + 4981 + rtl8xxxu_write32(priv, REG_FPGA0_IQK, 0x80800000); 4982 + rtl8xxxu_write32(priv, REG_TX_IQK, 0x01007c00); 4983 + rtl8xxxu_write32(priv, REG_RX_IQK, 0x01004800); 4984 + 4985 + for (i = 0; i < retry; i++) { 4986 + path_b_ok = rtl8192eu_iqk_path_b(priv); 4987 + if (path_b_ok == 0x01) { 4988 + val32 = rtl8xxxu_read32(priv, REG_TX_POWER_BEFORE_IQK_B); 4989 + result[t][4] = (val32 >> 16) & 0x3ff; 4990 + val32 = rtl8xxxu_read32(priv, REG_TX_POWER_AFTER_IQK_B); 4991 + result[t][5] = (val32 >> 16) & 0x3ff; 4992 + break; 4993 + } 4994 + } 4995 + 4996 + if (!path_b_ok) 4997 + dev_dbg(dev, "%s: Path B IQK failed!\n", __func__); 4998 + 4999 + for (i = 0; i < retry; i++) { 5000 + path_b_ok = rtl8192eu_rx_iqk_path_b(priv); 5001 + if (path_a_ok == 0x03) { 5002 + val32 = rtl8xxxu_read32(priv, 5003 + REG_RX_POWER_BEFORE_IQK_B_2); 5004 + result[t][6] = (val32 >> 16) & 0x3ff; 5005 + val32 = rtl8xxxu_read32(priv, 5006 + REG_RX_POWER_AFTER_IQK_B_2); 5007 + result[t][7] = (val32 >> 16) & 0x3ff; 5008 + break; 5009 + } 5010 + } 5011 + 5012 + if (!path_b_ok) 5013 + dev_dbg(dev, "%s: Path B RX IQK failed!\n", __func__); 5014 + } 5015 + 5016 + /* Back to BB mode, load original value */ 5017 + rtl8xxxu_write32(priv, REG_FPGA0_IQK, 0x00000000); 5018 + 5019 + if (t) { 5020 + /* Reload ADDA power saving parameters */ 5021 + rtl8xxxu_restore_regs(priv, adda_regs, priv->adda_backup, 5022 + RTL8XXXU_ADDA_REGS); 5023 + 5024 + /* Reload MAC parameters */ 5025 + rtl8xxxu_restore_mac_regs(priv, iqk_mac_regs, priv->mac_backup); 5026 + 5027 + /* Reload BB parameters */ 5028 + rtl8xxxu_restore_regs(priv, iqk_bb_regs, 5029 + priv->bb_backup, RTL8XXXU_BB_REGS); 5030 + 5031 + /* Restore RX initial gain */ 5032 + val32 = rtl8xxxu_read32(priv, REG_OFDM0_XA_AGC_CORE1); 5033 + val32 &= 0xffffff00; 5034 + rtl8xxxu_write32(priv, REG_OFDM0_XA_AGC_CORE1, val32 | 0x50); 5035 + rtl8xxxu_write32(priv, REG_OFDM0_XA_AGC_CORE1, val32 | xa_agc); 5036 + 5037 + if (priv->rf_paths > 1) { 5038 + val32 = rtl8xxxu_read32(priv, REG_OFDM0_XB_AGC_CORE1); 5039 + val32 &= 0xffffff00; 5040 + rtl8xxxu_write32(priv, REG_OFDM0_XB_AGC_CORE1, 5041 + val32 | 0x50); 5042 + rtl8xxxu_write32(priv, REG_OFDM0_XB_AGC_CORE1, 5043 + val32 | xb_agc); 5044 + } 5045 + 5046 + /* Load 0xe30 IQC default value */ 5047 + rtl8xxxu_write32(priv, REG_TX_IQK_TONE_A, 0x01008c00); 5048 + rtl8xxxu_write32(priv, REG_RX_IQK_TONE_A, 0x01008c00); 5049 + } 5050 + } 5051 + 5910 5052 static void rtl8xxxu_prepare_calibrate(struct rtl8xxxu_priv *priv, u8 start) 5911 5053 { 5912 5054 struct h2c_cmd h2c; ··· 6107 4877 rtl8723a_h2c_cmd(priv, &h2c, sizeof(h2c.bt_wlan_calibration)); 6108 4878 } 6109 4879 6110 - static void rtl8723au_phy_iq_calibrate(struct rtl8xxxu_priv *priv) 4880 + static void rtl8xxxu_gen1_phy_iq_calibrate(struct rtl8xxxu_priv *priv) 6111 4881 { 6112 4882 struct device *dev = &priv->udev->dev; 6113 4883 int result[4][8]; /* last is final result */ ··· 6205 4975 rtl8xxxu_fill_iqk_matrix_b(priv, path_b_ok, result, 6206 4976 candidate, (reg_ec4 == 0)); 6207 4977 6208 - rtl8xxxu_save_regs(priv, rtl8723au_iqk_phy_iq_bb_reg, 4978 + rtl8xxxu_save_regs(priv, rtl8xxxu_iqk_phy_iq_bb_reg, 6209 4979 priv->bb_recovery_backup, RTL8XXXU_BB_REGS); 6210 4980 6211 4981 rtl8xxxu_prepare_calibrate(priv, 0); ··· 6237 5007 rtl8723bu_phy_iqcalibrate(priv, result, i); 6238 5008 6239 5009 if (i == 1) { 6240 - simu = rtl8723bu_simularity_compare(priv, result, 0, 1); 5010 + simu = rtl8xxxu_gen2_simularity_compare(priv, 5011 + result, 0, 1); 6241 5012 if (simu) { 6242 5013 candidate = 0; 6243 5014 break; ··· 6246 5015 } 6247 5016 6248 5017 if (i == 2) { 6249 - simu = rtl8723bu_simularity_compare(priv, result, 0, 2); 5018 + simu = rtl8xxxu_gen2_simularity_compare(priv, 5019 + result, 0, 2); 6250 5020 if (simu) { 6251 5021 candidate = 0; 6252 5022 break; 6253 5023 } 6254 5024 6255 - simu = rtl8723bu_simularity_compare(priv, result, 1, 2); 5025 + simu = rtl8xxxu_gen2_simularity_compare(priv, 5026 + result, 1, 2); 6256 5027 if (simu) { 6257 5028 candidate = 1; 6258 5029 } else { ··· 6313 5080 rtl8xxxu_fill_iqk_matrix_b(priv, path_b_ok, result, 6314 5081 candidate, (reg_ec4 == 0)); 6315 5082 6316 - rtl8xxxu_save_regs(priv, rtl8723au_iqk_phy_iq_bb_reg, 5083 + rtl8xxxu_save_regs(priv, rtl8xxxu_iqk_phy_iq_bb_reg, 6317 5084 priv->bb_recovery_backup, RTL8XXXU_BB_REGS); 6318 5085 6319 5086 rtl8xxxu_write32(priv, REG_BT_CONTROL_8723BU, bt_control); ··· 6329 5096 rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_UNKNOWN_ED, val32); 6330 5097 rtl8xxxu_write_rfreg(priv, RF_A, 0x43, 0x300bd); 6331 5098 6332 - if (priv->rf_paths > 1) { 6333 - dev_dbg(dev, "%s: beware 2T not yet supported\n", __func__); 6334 - #ifdef RTL8723BU_PATH_B 6335 - if (RF_Path == 0x0) //S1 6336 - ODM_SetIQCbyRFpath(pDM_Odm, 0); 6337 - else //S0 6338 - ODM_SetIQCbyRFpath(pDM_Odm, 1); 6339 - #endif 6340 - } 5099 + if (priv->rf_paths > 1) 5100 + dev_dbg(dev, "%s: 8723BU 2T not supported\n", __func__); 5101 + 6341 5102 rtl8xxxu_prepare_calibrate(priv, 0); 5103 + } 5104 + 5105 + static void rtl8192eu_phy_iq_calibrate(struct rtl8xxxu_priv *priv) 5106 + { 5107 + struct device *dev = &priv->udev->dev; 5108 + int result[4][8]; /* last is final result */ 5109 + int i, candidate; 5110 + bool path_a_ok, path_b_ok; 5111 + u32 reg_e94, reg_e9c, reg_ea4, reg_eac; 5112 + u32 reg_eb4, reg_ebc, reg_ec4, reg_ecc; 5113 + bool simu; 5114 + 5115 + memset(result, 0, sizeof(result)); 5116 + candidate = -1; 5117 + 5118 + path_a_ok = false; 5119 + path_b_ok = false; 5120 + 5121 + for (i = 0; i < 3; i++) { 5122 + rtl8192eu_phy_iqcalibrate(priv, result, i); 5123 + 5124 + if (i == 1) { 5125 + simu = rtl8xxxu_gen2_simularity_compare(priv, 5126 + result, 0, 1); 5127 + if (simu) { 5128 + candidate = 0; 5129 + break; 5130 + } 5131 + } 5132 + 5133 + if (i == 2) { 5134 + simu = rtl8xxxu_gen2_simularity_compare(priv, 5135 + result, 0, 2); 5136 + if (simu) { 5137 + candidate = 0; 5138 + break; 5139 + } 5140 + 5141 + simu = rtl8xxxu_gen2_simularity_compare(priv, 5142 + result, 1, 2); 5143 + if (simu) 5144 + candidate = 1; 5145 + else 5146 + candidate = 3; 5147 + } 5148 + } 5149 + 5150 + for (i = 0; i < 4; i++) { 5151 + reg_e94 = result[i][0]; 5152 + reg_e9c = result[i][1]; 5153 + reg_ea4 = result[i][2]; 5154 + reg_eac = result[i][3]; 5155 + reg_eb4 = result[i][4]; 5156 + reg_ebc = result[i][5]; 5157 + reg_ec4 = result[i][6]; 5158 + reg_ecc = result[i][7]; 5159 + } 5160 + 5161 + if (candidate >= 0) { 5162 + reg_e94 = result[candidate][0]; 5163 + priv->rege94 = reg_e94; 5164 + reg_e9c = result[candidate][1]; 5165 + priv->rege9c = reg_e9c; 5166 + reg_ea4 = result[candidate][2]; 5167 + reg_eac = result[candidate][3]; 5168 + reg_eb4 = result[candidate][4]; 5169 + priv->regeb4 = reg_eb4; 5170 + reg_ebc = result[candidate][5]; 5171 + priv->regebc = reg_ebc; 5172 + reg_ec4 = result[candidate][6]; 5173 + reg_ecc = result[candidate][7]; 5174 + dev_dbg(dev, "%s: candidate is %x\n", __func__, candidate); 5175 + dev_dbg(dev, 5176 + "%s: e94 =%x e9c=%x ea4=%x eac=%x eb4=%x ebc=%x ec4=%x " 5177 + "ecc=%x\n ", __func__, reg_e94, reg_e9c, 5178 + reg_ea4, reg_eac, reg_eb4, reg_ebc, reg_ec4, reg_ecc); 5179 + path_a_ok = true; 5180 + path_b_ok = true; 5181 + } else { 5182 + reg_e94 = reg_eb4 = priv->rege94 = priv->regeb4 = 0x100; 5183 + reg_e9c = reg_ebc = priv->rege9c = priv->regebc = 0x0; 5184 + } 5185 + 5186 + if (reg_e94 && candidate >= 0) 5187 + rtl8xxxu_fill_iqk_matrix_a(priv, path_a_ok, result, 5188 + candidate, (reg_ea4 == 0)); 5189 + 5190 + if (priv->rf_paths > 1) 5191 + rtl8xxxu_fill_iqk_matrix_b(priv, path_b_ok, result, 5192 + candidate, (reg_ec4 == 0)); 5193 + 5194 + rtl8xxxu_save_regs(priv, rtl8xxxu_iqk_phy_iq_bb_reg, 5195 + priv->bb_recovery_backup, RTL8XXXU_BB_REGS); 6342 5196 } 6343 5197 6344 5198 static void rtl8723a_phy_lc_calibrate(struct rtl8xxxu_priv *priv) ··· 6551 5231 static int rtl8xxxu_active_to_emu(struct rtl8xxxu_priv *priv) 6552 5232 { 6553 5233 u8 val8; 6554 - int count, ret; 5234 + int count, ret = 0; 6555 5235 6556 5236 /* Start of rtl8723AU_card_enable_flow */ 6557 5237 /* Act to Cardemu sequence*/ ··· 6601 5281 u8 val8; 6602 5282 u16 val16; 6603 5283 u32 val32; 6604 - int count, ret; 5284 + int count, ret = 0; 6605 5285 6606 5286 /* Turn off RF */ 6607 5287 rtl8xxxu_write8(priv, REG_RF_CTRL, 0); ··· 6612 5292 rtl8xxxu_write16(priv, REG_GPIO_INTM, val16); 6613 5293 6614 5294 /* Release WLON reset 0x04[16]= 1*/ 6615 - val32 = rtl8xxxu_read32(priv, REG_GPIO_INTM); 5295 + val32 = rtl8xxxu_read32(priv, REG_APS_FSMCO); 6616 5296 val32 |= APS_FSMCO_WLON_RESET; 6617 - rtl8xxxu_write32(priv, REG_GPIO_INTM, val32); 5297 + rtl8xxxu_write32(priv, REG_APS_FSMCO, val32); 6618 5298 6619 5299 /* 0x0005[1] = 1 turn off MAC by HW state machine*/ 6620 5300 val8 = rtl8xxxu_read8(priv, REG_APS_FSMCO + 1); ··· 6658 5338 { 6659 5339 u8 val8; 6660 5340 u8 val32; 6661 - int count, ret; 5341 + int count, ret = 0; 6662 5342 6663 5343 rtl8xxxu_write8(priv, REG_TXPAUSE, 0xff); 6664 5344 ··· 7076 5756 return retval; 7077 5757 } 7078 5758 5759 + static void rtl8xxxu_gen1_usb_quirks(struct rtl8xxxu_priv *priv) 5760 + { 5761 + /* Fix USB interface interference issue */ 5762 + rtl8xxxu_write8(priv, 0xfe40, 0xe0); 5763 + rtl8xxxu_write8(priv, 0xfe41, 0x8d); 5764 + rtl8xxxu_write8(priv, 0xfe42, 0x80); 5765 + /* 5766 + * This sets TXDMA_OFFSET_DROP_DATA_EN (bit 9) as well as bits 5767 + * 8 and 5, for which I have found no documentation. 5768 + */ 5769 + rtl8xxxu_write32(priv, REG_TXDMA_OFFSET_CHK, 0xfd0320); 5770 + 5771 + /* 5772 + * Solve too many protocol error on USB bus. 5773 + * Can't do this for 8188/8192 UMC A cut parts 5774 + */ 5775 + if (!(!priv->chip_cut && priv->vendor_umc)) { 5776 + rtl8xxxu_write8(priv, 0xfe40, 0xe6); 5777 + rtl8xxxu_write8(priv, 0xfe41, 0x94); 5778 + rtl8xxxu_write8(priv, 0xfe42, 0x80); 5779 + 5780 + rtl8xxxu_write8(priv, 0xfe40, 0xe0); 5781 + rtl8xxxu_write8(priv, 0xfe41, 0x19); 5782 + rtl8xxxu_write8(priv, 0xfe42, 0x80); 5783 + 5784 + rtl8xxxu_write8(priv, 0xfe40, 0xe5); 5785 + rtl8xxxu_write8(priv, 0xfe41, 0x91); 5786 + rtl8xxxu_write8(priv, 0xfe42, 0x80); 5787 + 5788 + rtl8xxxu_write8(priv, 0xfe40, 0xe2); 5789 + rtl8xxxu_write8(priv, 0xfe41, 0x81); 5790 + rtl8xxxu_write8(priv, 0xfe42, 0x80); 5791 + } 5792 + } 5793 + 5794 + static void rtl8xxxu_gen2_usb_quirks(struct rtl8xxxu_priv *priv) 5795 + { 5796 + u32 val32; 5797 + 5798 + val32 = rtl8xxxu_read32(priv, REG_TXDMA_OFFSET_CHK); 5799 + val32 |= TXDMA_OFFSET_DROP_DATA_EN; 5800 + rtl8xxxu_write32(priv, REG_TXDMA_OFFSET_CHK, val32); 5801 + } 5802 + 7079 5803 static int rtl8723au_power_on(struct rtl8xxxu_priv *priv) 7080 5804 { 7081 5805 u8 val8; ··· 7316 5952 CR_SCHEDULE_ENABLE | CR_MAC_TX_ENABLE | CR_MAC_RX_ENABLE; 7317 5953 rtl8xxxu_write16(priv, REG_CR, val16); 7318 5954 5955 + rtl8xxxu_write8(priv, 0xfe10, 0x19); 5956 + 7319 5957 /* 7320 5958 * Workaround for 8188RU LNA power leakage problem. 7321 5959 */ 7322 - if (priv->rtl_chip == RTL8188C && priv->hi_pa) { 5960 + if (priv->rtl_chip == RTL8188R) { 7323 5961 val32 = rtl8xxxu_read32(priv, REG_FPGA0_XCD_RF_PARM); 7324 5962 val32 &= ~BIT(1); 7325 5963 rtl8xxxu_write32(priv, REG_FPGA0_XCD_RF_PARM, val32); ··· 7330 5964 } 7331 5965 7332 5966 #endif 5967 + 5968 + /* 5969 + * This is needed for 8723bu as well, presumable 5970 + */ 5971 + static void rtl8192e_crystal_afe_adjust(struct rtl8xxxu_priv *priv) 5972 + { 5973 + u8 val8; 5974 + u32 val32; 5975 + 5976 + /* 5977 + * 40Mhz crystal source, MAC 0x28[2]=0 5978 + */ 5979 + val8 = rtl8xxxu_read8(priv, REG_AFE_PLL_CTRL); 5980 + val8 &= 0xfb; 5981 + rtl8xxxu_write8(priv, REG_AFE_PLL_CTRL, val8); 5982 + 5983 + val32 = rtl8xxxu_read32(priv, REG_AFE_CTRL4); 5984 + val32 &= 0xfffffc7f; 5985 + rtl8xxxu_write32(priv, REG_AFE_CTRL4, val32); 5986 + 5987 + /* 5988 + * 92e AFE parameter 5989 + * AFE PLL KVCO selection, MAC 0x28[6]=1 5990 + */ 5991 + val8 = rtl8xxxu_read8(priv, REG_AFE_PLL_CTRL); 5992 + val8 &= 0xbf; 5993 + rtl8xxxu_write8(priv, REG_AFE_PLL_CTRL, val8); 5994 + 5995 + /* 5996 + * AFE PLL KVCO selection, MAC 0x78[21]=0 5997 + */ 5998 + val32 = rtl8xxxu_read32(priv, REG_AFE_CTRL4); 5999 + val32 &= 0xffdfffff; 6000 + rtl8xxxu_write32(priv, REG_AFE_CTRL4, val32); 6001 + } 7333 6002 7334 6003 static int rtl8192eu_power_on(struct rtl8xxxu_priv *priv) 7335 6004 { ··· 7388 5987 rtl8xxxu_write8(priv, REG_LDO_SW_CTRL, 0x83); 7389 5988 } 7390 5989 5990 + /* 5991 + * Adjust AFE before enabling PLL 5992 + */ 5993 + rtl8192e_crystal_afe_adjust(priv); 7391 5994 rtl8192e_disabled_to_emu(priv); 7392 5995 7393 5996 ret = rtl8192e_emu_to_active(priv); ··· 7425 6020 /* 7426 6021 * Workaround for 8188RU LNA power leakage problem. 7427 6022 */ 7428 - if (priv->rtl_chip == RTL8188C && priv->hi_pa) { 6023 + if (priv->rtl_chip == RTL8188R) { 7429 6024 val32 = rtl8xxxu_read32(priv, REG_FPGA0_XCD_RF_PARM); 7430 6025 val32 |= BIT(1); 7431 6026 rtl8xxxu_write32(priv, REG_FPGA0_XCD_RF_PARM, val32); ··· 7480 6075 val8 &= ~TX_REPORT_CTRL_TIMER_ENABLE; 7481 6076 rtl8xxxu_write8(priv, REG_TX_REPORT_CTRL, val8); 7482 6077 7483 - rtl8xxxu_write16(priv, REG_CR, 0x0000); 6078 + rtl8xxxu_write8(priv, REG_CR, 0x0000); 7484 6079 7485 6080 rtl8xxxu_active_to_lps(priv); 7486 6081 ··· 7497 6092 rtl8xxxu_write8(priv, REG_MCU_FW_DL, 0x00); 7498 6093 7499 6094 rtl8723bu_active_to_emu(priv); 7500 - rtl8xxxu_emu_to_disabled(priv); 6095 + 6096 + val8 = rtl8xxxu_read8(priv, REG_APS_FSMCO + 1); 6097 + val8 |= BIT(3); /* APS_FSMCO_HW_SUSPEND */ 6098 + rtl8xxxu_write8(priv, REG_APS_FSMCO + 1, val8); 6099 + 6100 + /* 0x48[16] = 1 to enable GPIO9 as EXT wakeup */ 6101 + val8 = rtl8xxxu_read8(priv, REG_GPIO_INTM + 2); 6102 + val8 |= BIT(0); 6103 + rtl8xxxu_write8(priv, REG_GPIO_INTM + 2, val8); 7501 6104 } 7502 6105 7503 6106 #ifdef NEED_PS_TDMA ··· 7524 6111 rtl8723a_h2c_cmd(priv, &h2c, sizeof(h2c.b_type_dma)); 7525 6112 } 7526 6113 #endif 6114 + 6115 + static void rtl8192e_enable_rf(struct rtl8xxxu_priv *priv) 6116 + { 6117 + u32 val32; 6118 + u8 val8; 6119 + 6120 + val8 = rtl8xxxu_read8(priv, REG_GPIO_MUXCFG); 6121 + val8 |= BIT(5); 6122 + rtl8xxxu_write8(priv, REG_GPIO_MUXCFG, val8); 6123 + 6124 + /* 6125 + * WLAN action by PTA 6126 + */ 6127 + rtl8xxxu_write8(priv, REG_WLAN_ACT_CONTROL_8723B, 0x04); 6128 + 6129 + val32 = rtl8xxxu_read32(priv, REG_PWR_DATA); 6130 + val32 |= PWR_DATA_EEPRPAD_RFE_CTRL_EN; 6131 + rtl8xxxu_write32(priv, REG_PWR_DATA, val32); 6132 + 6133 + val32 = rtl8xxxu_read32(priv, REG_RFE_BUFFER); 6134 + val32 |= (BIT(0) | BIT(1)); 6135 + rtl8xxxu_write32(priv, REG_RFE_BUFFER, val32); 6136 + 6137 + rtl8xxxu_write8(priv, REG_RFE_CTRL_ANTA_SRC, 0x77); 6138 + 6139 + val32 = rtl8xxxu_read32(priv, REG_LEDCFG0); 6140 + val32 &= ~BIT(24); 6141 + val32 |= BIT(23); 6142 + rtl8xxxu_write32(priv, REG_LEDCFG0, val32); 6143 + 6144 + /* 6145 + * Fix external switch Main->S1, Aux->S0 6146 + */ 6147 + val8 = rtl8xxxu_read8(priv, REG_PAD_CTRL1); 6148 + val8 &= ~BIT(0); 6149 + rtl8xxxu_write8(priv, REG_PAD_CTRL1, val8); 6150 + } 7527 6151 7528 6152 static void rtl8723b_enable_rf(struct rtl8xxxu_priv *priv) 7529 6153 { ··· 7669 6219 rtl8723a_h2c_cmd(priv, &h2c, sizeof(h2c.ignore_wlan)); 7670 6220 } 7671 6221 7672 - static void rtl8723b_disable_rf(struct rtl8xxxu_priv *priv) 6222 + static void rtl8xxxu_gen2_disable_rf(struct rtl8xxxu_priv *priv) 7673 6223 { 7674 6224 u32 val32; 7675 - 7676 - rtl8xxxu_write8(priv, REG_TXPAUSE, 0xff); 7677 6225 7678 6226 val32 = rtl8xxxu_read32(priv, REG_RX_WAIT_CCA); 7679 6227 val32 &= ~(BIT(22) | BIT(23)); ··· 7720 6272 rtl8xxxu_write32(priv, REG_OFDM0_FA_RSTC, val32); 7721 6273 } 7722 6274 6275 + static void rtl8xxxu_old_init_queue_reserved_page(struct rtl8xxxu_priv *priv) 6276 + { 6277 + u8 val8; 6278 + u32 val32; 6279 + 6280 + if (priv->ep_tx_normal_queue) 6281 + val8 = TX_PAGE_NUM_NORM_PQ; 6282 + else 6283 + val8 = 0; 6284 + 6285 + rtl8xxxu_write8(priv, REG_RQPN_NPQ, val8); 6286 + 6287 + val32 = (TX_PAGE_NUM_PUBQ << RQPN_PUB_PQ_SHIFT) | RQPN_LOAD; 6288 + 6289 + if (priv->ep_tx_high_queue) 6290 + val32 |= (TX_PAGE_NUM_HI_PQ << RQPN_HI_PQ_SHIFT); 6291 + if (priv->ep_tx_low_queue) 6292 + val32 |= (TX_PAGE_NUM_LO_PQ << RQPN_LO_PQ_SHIFT); 6293 + 6294 + rtl8xxxu_write32(priv, REG_RQPN, val32); 6295 + } 6296 + 6297 + static void rtl8xxxu_init_queue_reserved_page(struct rtl8xxxu_priv *priv) 6298 + { 6299 + struct rtl8xxxu_fileops *fops = priv->fops; 6300 + u32 hq, lq, nq, eq, pubq; 6301 + u32 val32; 6302 + 6303 + hq = 0; 6304 + lq = 0; 6305 + nq = 0; 6306 + eq = 0; 6307 + pubq = 0; 6308 + 6309 + if (priv->ep_tx_high_queue) 6310 + hq = fops->page_num_hi; 6311 + if (priv->ep_tx_low_queue) 6312 + lq = fops->page_num_lo; 6313 + if (priv->ep_tx_normal_queue) 6314 + nq = fops->page_num_norm; 6315 + 6316 + val32 = (nq << RQPN_NPQ_SHIFT) | (eq << RQPN_EPQ_SHIFT); 6317 + rtl8xxxu_write32(priv, REG_RQPN_NPQ, val32); 6318 + 6319 + pubq = fops->total_page_num - hq - lq - nq; 6320 + 6321 + val32 = RQPN_LOAD; 6322 + val32 |= (hq << RQPN_HI_PQ_SHIFT); 6323 + val32 |= (lq << RQPN_LO_PQ_SHIFT); 6324 + val32 |= (pubq << RQPN_PUB_PQ_SHIFT); 6325 + 6326 + rtl8xxxu_write32(priv, REG_RQPN, val32); 6327 + } 6328 + 7723 6329 static int rtl8xxxu_init_device(struct ieee80211_hw *hw) 7724 6330 { 7725 6331 struct rtl8xxxu_priv *priv = hw->priv; 7726 6332 struct device *dev = &priv->udev->dev; 7727 - struct rtl8xxxu_rfregval *rftable; 7728 6333 bool macpower; 7729 6334 int ret; 7730 6335 u8 val8; ··· 7802 6301 goto exit; 7803 6302 } 7804 6303 6304 + if (!macpower) { 6305 + if (priv->fops->total_page_num) 6306 + rtl8xxxu_init_queue_reserved_page(priv); 6307 + else 6308 + rtl8xxxu_old_init_queue_reserved_page(priv); 6309 + } 6310 + 6311 + ret = rtl8xxxu_init_queue_priority(priv); 6312 + dev_dbg(dev, "%s: init_queue_priority %i\n", __func__, ret); 6313 + if (ret) 6314 + goto exit; 6315 + 6316 + /* 6317 + * Set RX page boundary 6318 + */ 6319 + rtl8xxxu_write16(priv, REG_TRXFF_BNDY + 2, priv->fops->trxff_boundary); 6320 + 6321 + ret = rtl8xxxu_download_firmware(priv); 6322 + dev_dbg(dev, "%s: download_fiwmare %i\n", __func__, ret); 6323 + if (ret) 6324 + goto exit; 6325 + ret = rtl8xxxu_start_firmware(priv); 6326 + dev_dbg(dev, "%s: start_fiwmare %i\n", __func__, ret); 6327 + if (ret) 6328 + goto exit; 6329 + 6330 + if (priv->fops->phy_init_antenna_selection) 6331 + priv->fops->phy_init_antenna_selection(priv); 6332 + 6333 + ret = rtl8xxxu_init_mac(priv); 6334 + 6335 + dev_dbg(dev, "%s: init_mac %i\n", __func__, ret); 6336 + if (ret) 6337 + goto exit; 6338 + 6339 + ret = rtl8xxxu_init_phy_bb(priv); 6340 + dev_dbg(dev, "%s: init_phy_bb %i\n", __func__, ret); 6341 + if (ret) 6342 + goto exit; 6343 + 6344 + ret = priv->fops->init_phy_rf(priv); 6345 + if (ret) 6346 + goto exit; 6347 + 6348 + /* RFSW Control - clear bit 14 ?? */ 6349 + if (priv->rtl_chip != RTL8723B && priv->rtl_chip != RTL8192E) 6350 + rtl8xxxu_write32(priv, REG_FPGA0_TX_INFO, 0x00000003); 6351 + 6352 + val32 = FPGA0_RF_TRSW | FPGA0_RF_TRSWB | FPGA0_RF_ANTSW | 6353 + FPGA0_RF_ANTSWB | 6354 + ((FPGA0_RF_ANTSW | FPGA0_RF_ANTSWB) << FPGA0_RF_BD_CTRL_SHIFT); 6355 + if (!priv->no_pape) { 6356 + val32 |= (FPGA0_RF_PAPE | 6357 + (FPGA0_RF_PAPE << FPGA0_RF_BD_CTRL_SHIFT)); 6358 + } 6359 + rtl8xxxu_write32(priv, REG_FPGA0_XAB_RF_SW_CTRL, val32); 6360 + 6361 + /* 0x860[6:5]= 00 - why? - this sets antenna B */ 6362 + if (priv->rtl_chip != RTL8192E) 6363 + rtl8xxxu_write32(priv, REG_FPGA0_XA_RF_INT_OE, 0x66f60210); 6364 + 6365 + if (!macpower) { 6366 + /* 6367 + * Set TX buffer boundary 6368 + */ 6369 + if (priv->rtl_chip == RTL8192E) 6370 + val8 = TX_TOTAL_PAGE_NUM_8192E + 1; 6371 + else 6372 + val8 = TX_TOTAL_PAGE_NUM + 1; 6373 + 6374 + if (priv->rtl_chip == RTL8723B) 6375 + val8 -= 1; 6376 + 6377 + rtl8xxxu_write8(priv, REG_TXPKTBUF_BCNQ_BDNY, val8); 6378 + rtl8xxxu_write8(priv, REG_TXPKTBUF_MGQ_BDNY, val8); 6379 + rtl8xxxu_write8(priv, REG_TXPKTBUF_WMAC_LBK_BF_HD, val8); 6380 + rtl8xxxu_write8(priv, REG_TRXFF_BNDY, val8); 6381 + rtl8xxxu_write8(priv, REG_TDECTRL + 1, val8); 6382 + } 6383 + 6384 + /* 6385 + * The vendor drivers set PBP for all devices, except 8192e. 6386 + * There is no explanation for this in any of the sources. 6387 + */ 6388 + val8 = (priv->fops->pbp_rx << PBP_PAGE_SIZE_RX_SHIFT) | 6389 + (priv->fops->pbp_tx << PBP_PAGE_SIZE_TX_SHIFT); 6390 + if (priv->rtl_chip != RTL8192E) 6391 + rtl8xxxu_write8(priv, REG_PBP, val8); 6392 + 7805 6393 dev_dbg(dev, "%s: macpower %i\n", __func__, macpower); 7806 6394 if (!macpower) { 7807 6395 ret = priv->fops->llt_init(priv, TX_TOTAL_PAGE_NUM); ··· 7898 6308 dev_warn(dev, "%s: LLT table init failed\n", __func__); 7899 6309 goto exit; 7900 6310 } 6311 + 6312 + /* 6313 + * Chip specific quirks 6314 + */ 6315 + priv->fops->usb_quirks(priv); 7901 6316 7902 6317 /* 7903 6318 * Presumably this is for 8188EU as well ··· 7924 6329 } 7925 6330 } 7926 6331 7927 - ret = rtl8xxxu_download_firmware(priv); 7928 - dev_dbg(dev, "%s: download_fiwmare %i\n", __func__, ret); 7929 - if (ret) 7930 - goto exit; 7931 - ret = rtl8xxxu_start_firmware(priv); 7932 - dev_dbg(dev, "%s: start_fiwmare %i\n", __func__, ret); 7933 - if (ret) 7934 - goto exit; 7935 - 7936 - /* Solve too many protocol error on USB bus */ 7937 - /* Can't do this for 8188/8192 UMC A cut parts */ 7938 - if (priv->rtl_chip == RTL8723A || 7939 - ((priv->rtl_chip == RTL8192C || priv->rtl_chip == RTL8191C || 7940 - priv->rtl_chip == RTL8188C) && 7941 - (priv->chip_cut || !priv->vendor_umc))) { 7942 - rtl8xxxu_write8(priv, 0xfe40, 0xe6); 7943 - rtl8xxxu_write8(priv, 0xfe41, 0x94); 7944 - rtl8xxxu_write8(priv, 0xfe42, 0x80); 7945 - 7946 - rtl8xxxu_write8(priv, 0xfe40, 0xe0); 7947 - rtl8xxxu_write8(priv, 0xfe41, 0x19); 7948 - rtl8xxxu_write8(priv, 0xfe42, 0x80); 7949 - 7950 - rtl8xxxu_write8(priv, 0xfe40, 0xe5); 7951 - rtl8xxxu_write8(priv, 0xfe41, 0x91); 7952 - rtl8xxxu_write8(priv, 0xfe42, 0x80); 7953 - 7954 - rtl8xxxu_write8(priv, 0xfe40, 0xe2); 7955 - rtl8xxxu_write8(priv, 0xfe41, 0x81); 7956 - rtl8xxxu_write8(priv, 0xfe42, 0x80); 7957 - } 7958 - 7959 - if (priv->rtl_chip == RTL8192E) { 7960 - rtl8xxxu_write32(priv, REG_HIMR0, 0x00); 7961 - rtl8xxxu_write32(priv, REG_HIMR1, 0x00); 7962 - } 7963 - 7964 - if (priv->fops->phy_init_antenna_selection) 7965 - priv->fops->phy_init_antenna_selection(priv); 7966 - 7967 - if (priv->rtl_chip == RTL8723B) 7968 - ret = rtl8xxxu_init_mac(priv, rtl8723b_mac_init_table); 7969 - else 7970 - ret = rtl8xxxu_init_mac(priv, rtl8723a_mac_init_table); 7971 - 7972 - dev_dbg(dev, "%s: init_mac %i\n", __func__, ret); 7973 - if (ret) 7974 - goto exit; 7975 - 7976 - ret = rtl8xxxu_init_phy_bb(priv); 7977 - dev_dbg(dev, "%s: init_phy_bb %i\n", __func__, ret); 7978 - if (ret) 7979 - goto exit; 7980 - 7981 - switch(priv->rtl_chip) { 7982 - case RTL8723A: 7983 - rftable = rtl8723au_radioa_1t_init_table; 7984 - ret = rtl8xxxu_init_phy_rf(priv, rftable, RF_A); 7985 - break; 7986 - case RTL8723B: 7987 - rftable = rtl8723bu_radioa_1t_init_table; 7988 - ret = rtl8xxxu_init_phy_rf(priv, rftable, RF_A); 7989 - /* 7990 - * PHY LCK 7991 - */ 7992 - rtl8xxxu_write_rfreg(priv, RF_A, 0xb0, 0xdfbe0); 7993 - rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_MODE_AG, 0x8c01); 7994 - msleep(200); 7995 - rtl8xxxu_write_rfreg(priv, RF_A, 0xb0, 0xdffe0); 7996 - break; 7997 - case RTL8188C: 7998 - if (priv->hi_pa) 7999 - rftable = rtl8188ru_radioa_1t_highpa_table; 8000 - else 8001 - rftable = rtl8192cu_radioa_1t_init_table; 8002 - ret = rtl8xxxu_init_phy_rf(priv, rftable, RF_A); 8003 - break; 8004 - case RTL8191C: 8005 - rftable = rtl8192cu_radioa_1t_init_table; 8006 - ret = rtl8xxxu_init_phy_rf(priv, rftable, RF_A); 8007 - break; 8008 - case RTL8192C: 8009 - rftable = rtl8192cu_radioa_2t_init_table; 8010 - ret = rtl8xxxu_init_phy_rf(priv, rftable, RF_A); 8011 - if (ret) 8012 - break; 8013 - rftable = rtl8192cu_radiob_2t_init_table; 8014 - ret = rtl8xxxu_init_phy_rf(priv, rftable, RF_B); 8015 - break; 8016 - default: 8017 - ret = -EINVAL; 8018 - } 8019 - 8020 - if (ret) 8021 - goto exit; 8022 - 8023 - /* 8024 - * Chip specific quirks 8025 - */ 8026 - if (priv->rtl_chip == RTL8723A) { 8027 - /* Fix USB interface interference issue */ 8028 - rtl8xxxu_write8(priv, 0xfe40, 0xe0); 8029 - rtl8xxxu_write8(priv, 0xfe41, 0x8d); 8030 - rtl8xxxu_write8(priv, 0xfe42, 0x80); 8031 - rtl8xxxu_write32(priv, REG_TXDMA_OFFSET_CHK, 0xfd0320); 8032 - 8033 - /* Reduce 80M spur */ 8034 - rtl8xxxu_write32(priv, REG_AFE_XTAL_CTRL, 0x0381808d); 8035 - rtl8xxxu_write32(priv, REG_AFE_PLL_CTRL, 0xf0ffff83); 8036 - rtl8xxxu_write32(priv, REG_AFE_PLL_CTRL, 0xf0ffff82); 8037 - rtl8xxxu_write32(priv, REG_AFE_PLL_CTRL, 0xf0ffff83); 8038 - } else { 8039 - val32 = rtl8xxxu_read32(priv, REG_TXDMA_OFFSET_CHK); 8040 - val32 |= TXDMA_OFFSET_DROP_DATA_EN; 8041 - rtl8xxxu_write32(priv, REG_TXDMA_OFFSET_CHK, val32); 8042 - } 8043 - 8044 - if (!macpower) { 8045 - if (priv->ep_tx_normal_queue) 8046 - val8 = TX_PAGE_NUM_NORM_PQ; 8047 - else 8048 - val8 = 0; 8049 - 8050 - rtl8xxxu_write8(priv, REG_RQPN_NPQ, val8); 8051 - 8052 - val32 = (TX_PAGE_NUM_PUBQ << RQPN_NORM_PQ_SHIFT) | RQPN_LOAD; 8053 - 8054 - if (priv->ep_tx_high_queue) 8055 - val32 |= (TX_PAGE_NUM_HI_PQ << RQPN_HI_PQ_SHIFT); 8056 - if (priv->ep_tx_low_queue) 8057 - val32 |= (TX_PAGE_NUM_LO_PQ << RQPN_LO_PQ_SHIFT); 8058 - 8059 - rtl8xxxu_write32(priv, REG_RQPN, val32); 8060 - 8061 - /* 8062 - * Set TX buffer boundary 8063 - */ 8064 - val8 = TX_TOTAL_PAGE_NUM + 1; 8065 - 8066 - if (priv->rtl_chip == RTL8723B) 8067 - val8 -= 1; 8068 - 8069 - rtl8xxxu_write8(priv, REG_TXPKTBUF_BCNQ_BDNY, val8); 8070 - rtl8xxxu_write8(priv, REG_TXPKTBUF_MGQ_BDNY, val8); 8071 - rtl8xxxu_write8(priv, REG_TXPKTBUF_WMAC_LBK_BF_HD, val8); 8072 - rtl8xxxu_write8(priv, REG_TRXFF_BNDY, val8); 8073 - rtl8xxxu_write8(priv, REG_TDECTRL + 1, val8); 8074 - } 8075 - 8076 - ret = rtl8xxxu_init_queue_priority(priv); 8077 - dev_dbg(dev, "%s: init_queue_priority %i\n", __func__, ret); 8078 - if (ret) 8079 - goto exit; 8080 - 8081 - /* RFSW Control - clear bit 14 ?? */ 8082 - if (priv->rtl_chip != RTL8723B) 8083 - rtl8xxxu_write32(priv, REG_FPGA0_TX_INFO, 0x00000003); 8084 - /* 0x07000760 */ 8085 - val32 = FPGA0_RF_TRSW | FPGA0_RF_TRSWB | FPGA0_RF_ANTSW | 8086 - FPGA0_RF_ANTSWB | FPGA0_RF_PAPE | 8087 - ((FPGA0_RF_ANTSW | FPGA0_RF_ANTSWB | FPGA0_RF_PAPE) << 8088 - FPGA0_RF_BD_CTRL_SHIFT); 8089 - rtl8xxxu_write32(priv, REG_FPGA0_XAB_RF_SW_CTRL, val32); 8090 - /* 0x860[6:5]= 00 - why? - this sets antenna B */ 8091 - rtl8xxxu_write32(priv, REG_FPGA0_XA_RF_INT_OE, 0x66F60210); 8092 - 8093 - priv->rf_mode_ag[0] = rtl8xxxu_read_rfreg(priv, RF_A, 8094 - RF6052_REG_MODE_AG); 8095 - 8096 - /* 8097 - * Set RX page boundary 8098 - */ 8099 - if (priv->rtl_chip == RTL8723B) 8100 - rtl8xxxu_write16(priv, REG_TRXFF_BNDY + 2, 0x3f7f); 8101 - else 8102 - rtl8xxxu_write16(priv, REG_TRXFF_BNDY + 2, 0x27ff); 8103 - /* 8104 - * Transfer page size is always 128 8105 - */ 8106 - if (priv->rtl_chip == RTL8723B) 8107 - val8 = (PBP_PAGE_SIZE_256 << PBP_PAGE_SIZE_RX_SHIFT) | 8108 - (PBP_PAGE_SIZE_256 << PBP_PAGE_SIZE_TX_SHIFT); 8109 - else 8110 - val8 = (PBP_PAGE_SIZE_128 << PBP_PAGE_SIZE_RX_SHIFT) | 8111 - (PBP_PAGE_SIZE_128 << PBP_PAGE_SIZE_TX_SHIFT); 8112 - rtl8xxxu_write8(priv, REG_PBP, val8); 8113 - 8114 6332 /* 8115 6333 * Unit in 8 bytes, not obvious what it is used for 8116 6334 */ 8117 6335 rtl8xxxu_write8(priv, REG_RX_DRVINFO_SZ, 4); 8118 6336 8119 - /* 8120 - * Enable all interrupts - not obvious USB needs to do this 8121 - */ 8122 - rtl8xxxu_write32(priv, REG_HISR, 0xffffffff); 8123 - rtl8xxxu_write32(priv, REG_HIMR, 0xffffffff); 6337 + if (priv->rtl_chip == RTL8192E) { 6338 + rtl8xxxu_write32(priv, REG_HIMR0, 0x00); 6339 + rtl8xxxu_write32(priv, REG_HIMR1, 0x00); 6340 + } else { 6341 + /* 6342 + * Enable all interrupts - not obvious USB needs to do this 6343 + */ 6344 + rtl8xxxu_write32(priv, REG_HISR, 0xffffffff); 6345 + rtl8xxxu_write32(priv, REG_HIMR, 0xffffffff); 6346 + } 8124 6347 8125 6348 rtl8xxxu_set_mac(priv); 8126 6349 rtl8xxxu_set_linktype(priv, NL80211_IFTYPE_STATION); ··· 8064 6651 priv->fops->set_tx_power(priv, 1, false); 8065 6652 8066 6653 /* Let the 8051 take control of antenna setting */ 8067 - val8 = rtl8xxxu_read8(priv, REG_LEDCFG2); 8068 - val8 |= LEDCFG2_DPDT_SELECT; 8069 - rtl8xxxu_write8(priv, REG_LEDCFG2, val8); 6654 + if (priv->rtl_chip != RTL8192E) { 6655 + val8 = rtl8xxxu_read8(priv, REG_LEDCFG2); 6656 + val8 |= LEDCFG2_DPDT_SELECT; 6657 + rtl8xxxu_write8(priv, REG_LEDCFG2, val8); 6658 + } 8070 6659 8071 6660 rtl8xxxu_write8(priv, REG_HWSEQ_CTRL, 0xff); 8072 6661 ··· 8080 6665 if (priv->fops->init_statistics) 8081 6666 priv->fops->init_statistics(priv); 8082 6667 6668 + if (priv->rtl_chip == RTL8192E) { 6669 + /* 6670 + * 0x4c6[3] 1: RTS BW = Data BW 6671 + * 0: RTS BW depends on CCA / secondary CCA result. 6672 + */ 6673 + val8 = rtl8xxxu_read8(priv, REG_QUEUE_CTRL); 6674 + val8 &= ~BIT(3); 6675 + rtl8xxxu_write8(priv, REG_QUEUE_CTRL, val8); 6676 + /* 6677 + * Reset USB mode switch setting 6678 + */ 6679 + rtl8xxxu_write8(priv, REG_ACLK_MON, 0x00); 6680 + } 6681 + 8083 6682 rtl8723a_phy_lc_calibrate(priv); 8084 6683 8085 6684 priv->fops->phy_iq_calibrate(priv); ··· 8101 6672 /* 8102 6673 * This should enable thermal meter 8103 6674 */ 8104 - if (priv->fops->has_s0s1) 6675 + if (priv->fops->tx_desc_size == sizeof(struct rtl8xxxu_txdesc40)) 8105 6676 rtl8xxxu_write_rfreg(priv, 8106 6677 RF_A, RF6052_REG_T_METER_8723B, 0x37cf8); 8107 6678 else ··· 8122 6693 val32 |= FPGA_RF_MODE_CCK; 8123 6694 rtl8xxxu_write32(priv, REG_FPGA0_RF_MODE, val32); 8124 6695 } 6696 + } else if (priv->rtl_chip == RTL8192E) { 6697 + rtl8xxxu_write8(priv, REG_USB_HRPWM, 0x00); 8125 6698 } 8126 6699 8127 6700 val32 = rtl8xxxu_read32(priv, REG_FWHW_TXQ_CTRL); ··· 8131 6700 /* ack for xmit mgmt frames. */ 8132 6701 rtl8xxxu_write32(priv, REG_FWHW_TXQ_CTRL, val32); 8133 6702 6703 + if (priv->rtl_chip == RTL8192E) { 6704 + /* 6705 + * Fix LDPC rx hang issue. 6706 + */ 6707 + val32 = rtl8xxxu_read32(priv, REG_AFE_MISC); 6708 + rtl8xxxu_write8(priv, REG_8192E_LDOV12_CTRL, 0x75); 6709 + val32 &= 0xfff00fff; 6710 + val32 |= 0x0007e000; 6711 + rtl8xxxu_write32(priv, REG_AFE_MISC, val32); 6712 + } 8134 6713 exit: 8135 6714 return ret; 8136 - } 8137 - 8138 - static void rtl8xxxu_disable_device(struct ieee80211_hw *hw) 8139 - { 8140 - struct rtl8xxxu_priv *priv = hw->priv; 8141 - 8142 - priv->fops->power_off(priv); 8143 6715 } 8144 6716 8145 6717 static void rtl8xxxu_cam_write(struct rtl8xxxu_priv *priv, ··· 8209 6775 rtl8xxxu_write8(priv, REG_BEACON_CTRL, val8); 8210 6776 } 8211 6777 8212 - static void rtl8723au_update_rate_mask(struct rtl8xxxu_priv *priv, 8213 - u32 ramask, int sgi) 6778 + static void rtl8xxxu_update_rate_mask(struct rtl8xxxu_priv *priv, 6779 + u32 ramask, int sgi) 8214 6780 { 8215 6781 struct h2c_cmd h2c; 8216 6782 ··· 8229 6795 rtl8723a_h2c_cmd(priv, &h2c, sizeof(h2c.ramask)); 8230 6796 } 8231 6797 8232 - static void rtl8723bu_update_rate_mask(struct rtl8xxxu_priv *priv, 8233 - u32 ramask, int sgi) 6798 + static void rtl8xxxu_gen2_update_rate_mask(struct rtl8xxxu_priv *priv, 6799 + u32 ramask, int sgi) 8234 6800 { 8235 6801 struct h2c_cmd h2c; 8236 6802 u8 bw = 0; ··· 8255 6821 rtl8723a_h2c_cmd(priv, &h2c, sizeof(h2c.b_macid_cfg)); 8256 6822 } 8257 6823 8258 - static void rtl8723au_report_connect(struct rtl8xxxu_priv *priv, 8259 - u8 macid, bool connect) 6824 + static void rtl8xxxu_gen1_report_connect(struct rtl8xxxu_priv *priv, 6825 + u8 macid, bool connect) 8260 6826 { 8261 6827 struct h2c_cmd h2c; 8262 6828 ··· 8272 6838 rtl8723a_h2c_cmd(priv, &h2c, sizeof(h2c.joinbss)); 8273 6839 } 8274 6840 8275 - static void rtl8723bu_report_connect(struct rtl8xxxu_priv *priv, 8276 - u8 macid, bool connect) 6841 + static void rtl8xxxu_gen2_report_connect(struct rtl8xxxu_priv *priv, 6842 + u8 macid, bool connect) 8277 6843 { 8278 6844 struct h2c_cmd h2c; 8279 6845 ··· 8926 7492 } 8927 7493 } 8928 7494 8929 - static int rtl8723au_parse_rx_desc(struct rtl8xxxu_priv *priv, 7495 + static int rtl8xxxu_parse_rxdesc16(struct rtl8xxxu_priv *priv, 8930 7496 struct sk_buff *skb, 8931 7497 struct ieee80211_rx_status *rx_status) 8932 7498 { 8933 - struct rtl8xxxu_rx_desc *rx_desc = (struct rtl8xxxu_rx_desc *)skb->data; 7499 + struct rtl8xxxu_rxdesc16 *rx_desc = 7500 + (struct rtl8xxxu_rxdesc16 *)skb->data; 8934 7501 struct rtl8723au_phy_stats *phy_stats; 7502 + __le32 *_rx_desc_le = (__le32 *)skb->data; 7503 + u32 *_rx_desc = (u32 *)skb->data; 8935 7504 int drvinfo_sz, desc_shift; 7505 + int i; 8936 7506 8937 - skb_pull(skb, sizeof(struct rtl8xxxu_rx_desc)); 7507 + for (i = 0; i < (sizeof(struct rtl8xxxu_rxdesc16) / sizeof(u32)); i++) 7508 + _rx_desc[i] = le32_to_cpu(_rx_desc_le[i]); 7509 + 7510 + skb_pull(skb, sizeof(struct rtl8xxxu_rxdesc16)); 8938 7511 8939 7512 phy_stats = (struct rtl8723au_phy_stats *)skb->data; 8940 7513 ··· 8973 7532 return RX_TYPE_DATA_PKT; 8974 7533 } 8975 7534 8976 - static int rtl8723bu_parse_rx_desc(struct rtl8xxxu_priv *priv, 7535 + static int rtl8xxxu_parse_rxdesc24(struct rtl8xxxu_priv *priv, 8977 7536 struct sk_buff *skb, 8978 7537 struct ieee80211_rx_status *rx_status) 8979 7538 { 8980 - struct rtl8723bu_rx_desc *rx_desc = 8981 - (struct rtl8723bu_rx_desc *)skb->data; 7539 + struct rtl8xxxu_rxdesc24 *rx_desc = 7540 + (struct rtl8xxxu_rxdesc24 *)skb->data; 8982 7541 struct rtl8723au_phy_stats *phy_stats; 7542 + __le32 *_rx_desc_le = (__le32 *)skb->data; 7543 + u32 *_rx_desc = (u32 *)skb->data; 8983 7544 int drvinfo_sz, desc_shift; 7545 + int i; 8984 7546 8985 - skb_pull(skb, sizeof(struct rtl8723bu_rx_desc)); 7547 + for (i = 0; i < (sizeof(struct rtl8xxxu_rxdesc24) / sizeof(u32)); i++) 7548 + _rx_desc[i] = le32_to_cpu(_rx_desc_le[i]); 7549 + 7550 + skb_pull(skb, sizeof(struct rtl8xxxu_rxdesc24)); 8986 7551 8987 7552 phy_stats = (struct rtl8723au_phy_stats *)skb->data; 8988 7553 ··· 9080 7633 struct sk_buff *skb = (struct sk_buff *)urb->context; 9081 7634 struct ieee80211_rx_status *rx_status = IEEE80211_SKB_RXCB(skb); 9082 7635 struct device *dev = &priv->udev->dev; 9083 - __le32 *_rx_desc_le = (__le32 *)skb->data; 9084 - u32 *_rx_desc = (u32 *)skb->data; 9085 - int rx_type, i; 9086 - 9087 - for (i = 0; i < (sizeof(struct rtl8xxxu_rx_desc) / sizeof(u32)); i++) 9088 - _rx_desc[i] = le32_to_cpu(_rx_desc_le[i]); 7636 + int rx_type; 9089 7637 9090 7638 skb_put(skb, urb->actual_length); 9091 7639 ··· 9119 7677 { 9120 7678 struct sk_buff *skb; 9121 7679 int skb_size; 9122 - int ret; 7680 + int ret, rx_desc_sz; 9123 7681 9124 - skb_size = sizeof(struct rtl8xxxu_rx_desc) + RTL_RX_BUFFER_SIZE; 7682 + rx_desc_sz = priv->fops->rx_desc_size; 7683 + skb_size = rx_desc_sz + RTL_RX_BUFFER_SIZE; 9125 7684 skb = __netdev_alloc_skb(NULL, skb_size, GFP_KERNEL); 9126 7685 if (!skb) 9127 7686 return -ENOMEM; 9128 7687 9129 - memset(skb->data, 0, sizeof(struct rtl8xxxu_rx_desc)); 7688 + memset(skb->data, 0, rx_desc_sz); 9130 7689 usb_fill_bulk_urb(&rx_urb->urb, priv->udev, priv->pipe_in, skb->data, 9131 7690 skb_size, rtl8xxxu_rx_complete, skb); 9132 7691 usb_anchor_urb(&rx_urb->urb, &priv->rx_anchor); ··· 9597 8154 if (priv->usb_interrupts) 9598 8155 usb_kill_anchored_urbs(&priv->int_anchor); 9599 8156 8157 + rtl8xxxu_write8(priv, REG_TXPAUSE, 0xff); 8158 + 9600 8159 priv->fops->disable_rf(priv); 9601 8160 9602 8161 /* ··· 9731 8286 if (id->idProduct == 0x7811) 9732 8287 untested = 0; 9733 8288 break; 8289 + case 0x050d: 8290 + if (id->idProduct == 0x1004) 8291 + untested = 0; 8292 + break; 9734 8293 default: 9735 8294 break; 9736 8295 } ··· 9863 8414 hw = usb_get_intfdata(interface); 9864 8415 priv = hw->priv; 9865 8416 9866 - rtl8xxxu_disable_device(hw); 8417 + ieee80211_unregister_hw(hw); 8418 + 8419 + priv->fops->power_off(priv); 8420 + 9867 8421 usb_set_intfdata(interface, NULL); 9868 8422 9869 8423 dev_info(&priv->udev->dev, "disconnecting\n"); 9870 - 9871 - ieee80211_unregister_hw(hw); 9872 8424 9873 8425 kfree(priv->fw_data); 9874 8426 mutex_destroy(&priv->usb_buf_mutex); ··· 9886 8436 .power_off = rtl8xxxu_power_off, 9887 8437 .reset_8051 = rtl8xxxu_reset_8051, 9888 8438 .llt_init = rtl8xxxu_init_llt_table, 9889 - .phy_iq_calibrate = rtl8723au_phy_iq_calibrate, 9890 - .config_channel = rtl8723au_config_channel, 9891 - .parse_rx_desc = rtl8723au_parse_rx_desc, 9892 - .enable_rf = rtl8723a_enable_rf, 9893 - .disable_rf = rtl8723a_disable_rf, 9894 - .set_tx_power = rtl8723a_set_tx_power, 9895 - .update_rate_mask = rtl8723au_update_rate_mask, 9896 - .report_connect = rtl8723au_report_connect, 8439 + .init_phy_bb = rtl8xxxu_gen1_init_phy_bb, 8440 + .init_phy_rf = rtl8723au_init_phy_rf, 8441 + .phy_iq_calibrate = rtl8xxxu_gen1_phy_iq_calibrate, 8442 + .config_channel = rtl8xxxu_gen1_config_channel, 8443 + .parse_rx_desc = rtl8xxxu_parse_rxdesc16, 8444 + .enable_rf = rtl8xxxu_gen1_enable_rf, 8445 + .disable_rf = rtl8xxxu_gen1_disable_rf, 8446 + .usb_quirks = rtl8xxxu_gen1_usb_quirks, 8447 + .set_tx_power = rtl8xxxu_gen1_set_tx_power, 8448 + .update_rate_mask = rtl8xxxu_update_rate_mask, 8449 + .report_connect = rtl8xxxu_gen1_report_connect, 9897 8450 .writeN_block_size = 1024, 9898 8451 .mbox_ext_reg = REG_HMBOX_EXT_0, 9899 8452 .mbox_ext_width = 2, 9900 8453 .tx_desc_size = sizeof(struct rtl8xxxu_txdesc32), 8454 + .rx_desc_size = sizeof(struct rtl8xxxu_rxdesc16), 9901 8455 .adda_1t_init = 0x0b1b25a0, 9902 8456 .adda_1t_path_on = 0x0bdb25a0, 9903 8457 .adda_2t_path_on_a = 0x04db25a4, 9904 8458 .adda_2t_path_on_b = 0x0b1b25a4, 8459 + .trxff_boundary = 0x27ff, 8460 + .pbp_rx = PBP_PAGE_SIZE_128, 8461 + .pbp_tx = PBP_PAGE_SIZE_128, 8462 + .mactable = rtl8xxxu_gen1_mac_init_table, 9905 8463 }; 9906 8464 9907 8465 static struct rtl8xxxu_fileops rtl8723bu_fops = { ··· 9919 8461 .power_off = rtl8723bu_power_off, 9920 8462 .reset_8051 = rtl8723bu_reset_8051, 9921 8463 .llt_init = rtl8xxxu_auto_llt_table, 8464 + .init_phy_bb = rtl8723bu_init_phy_bb, 8465 + .init_phy_rf = rtl8723bu_init_phy_rf, 9922 8466 .phy_init_antenna_selection = rtl8723bu_phy_init_antenna_selection, 9923 8467 .phy_iq_calibrate = rtl8723bu_phy_iq_calibrate, 9924 - .config_channel = rtl8723bu_config_channel, 9925 - .parse_rx_desc = rtl8723bu_parse_rx_desc, 8468 + .config_channel = rtl8xxxu_gen2_config_channel, 8469 + .parse_rx_desc = rtl8xxxu_parse_rxdesc24, 9926 8470 .init_aggregation = rtl8723bu_init_aggregation, 9927 8471 .init_statistics = rtl8723bu_init_statistics, 9928 8472 .enable_rf = rtl8723b_enable_rf, 9929 - .disable_rf = rtl8723b_disable_rf, 8473 + .disable_rf = rtl8xxxu_gen2_disable_rf, 8474 + .usb_quirks = rtl8xxxu_gen2_usb_quirks, 9930 8475 .set_tx_power = rtl8723b_set_tx_power, 9931 - .update_rate_mask = rtl8723bu_update_rate_mask, 9932 - .report_connect = rtl8723bu_report_connect, 8476 + .update_rate_mask = rtl8xxxu_gen2_update_rate_mask, 8477 + .report_connect = rtl8xxxu_gen2_report_connect, 9933 8478 .writeN_block_size = 1024, 9934 8479 .mbox_ext_reg = REG_HMBOX_EXT0_8723B, 9935 8480 .mbox_ext_width = 4, 9936 8481 .tx_desc_size = sizeof(struct rtl8xxxu_txdesc40), 8482 + .rx_desc_size = sizeof(struct rtl8xxxu_rxdesc24), 9937 8483 .has_s0s1 = 1, 9938 8484 .adda_1t_init = 0x01c00014, 9939 8485 .adda_1t_path_on = 0x01c00014, 9940 8486 .adda_2t_path_on_a = 0x01c00014, 9941 8487 .adda_2t_path_on_b = 0x01c00014, 8488 + .trxff_boundary = 0x3f7f, 8489 + .pbp_rx = PBP_PAGE_SIZE_256, 8490 + .pbp_tx = PBP_PAGE_SIZE_256, 8491 + .mactable = rtl8723b_mac_init_table, 9942 8492 }; 9943 8493 9944 8494 #ifdef CONFIG_RTL8XXXU_UNTESTED ··· 9958 8492 .power_off = rtl8xxxu_power_off, 9959 8493 .reset_8051 = rtl8xxxu_reset_8051, 9960 8494 .llt_init = rtl8xxxu_init_llt_table, 9961 - .phy_iq_calibrate = rtl8723au_phy_iq_calibrate, 9962 - .config_channel = rtl8723au_config_channel, 9963 - .parse_rx_desc = rtl8723au_parse_rx_desc, 9964 - .enable_rf = rtl8723a_enable_rf, 9965 - .disable_rf = rtl8723a_disable_rf, 9966 - .set_tx_power = rtl8723a_set_tx_power, 9967 - .update_rate_mask = rtl8723au_update_rate_mask, 9968 - .report_connect = rtl8723au_report_connect, 8495 + .init_phy_bb = rtl8xxxu_gen1_init_phy_bb, 8496 + .init_phy_rf = rtl8192cu_init_phy_rf, 8497 + .phy_iq_calibrate = rtl8xxxu_gen1_phy_iq_calibrate, 8498 + .config_channel = rtl8xxxu_gen1_config_channel, 8499 + .parse_rx_desc = rtl8xxxu_parse_rxdesc16, 8500 + .enable_rf = rtl8xxxu_gen1_enable_rf, 8501 + .disable_rf = rtl8xxxu_gen1_disable_rf, 8502 + .usb_quirks = rtl8xxxu_gen1_usb_quirks, 8503 + .set_tx_power = rtl8xxxu_gen1_set_tx_power, 8504 + .update_rate_mask = rtl8xxxu_update_rate_mask, 8505 + .report_connect = rtl8xxxu_gen1_report_connect, 9969 8506 .writeN_block_size = 128, 9970 8507 .mbox_ext_reg = REG_HMBOX_EXT_0, 9971 8508 .mbox_ext_width = 2, 9972 8509 .tx_desc_size = sizeof(struct rtl8xxxu_txdesc32), 8510 + .rx_desc_size = sizeof(struct rtl8xxxu_rxdesc16), 9973 8511 .adda_1t_init = 0x0b1b25a0, 9974 8512 .adda_1t_path_on = 0x0bdb25a0, 9975 8513 .adda_2t_path_on_a = 0x04db25a4, 9976 8514 .adda_2t_path_on_b = 0x0b1b25a4, 8515 + .trxff_boundary = 0x27ff, 8516 + .pbp_rx = PBP_PAGE_SIZE_128, 8517 + .pbp_tx = PBP_PAGE_SIZE_128, 8518 + .mactable = rtl8xxxu_gen1_mac_init_table, 9977 8519 }; 9978 8520 9979 8521 #endif ··· 9993 8519 .power_off = rtl8xxxu_power_off, 9994 8520 .reset_8051 = rtl8xxxu_reset_8051, 9995 8521 .llt_init = rtl8xxxu_auto_llt_table, 9996 - .phy_iq_calibrate = rtl8723bu_phy_iq_calibrate, 9997 - .config_channel = rtl8723bu_config_channel, 9998 - .parse_rx_desc = rtl8723bu_parse_rx_desc, 9999 - .enable_rf = rtl8723b_enable_rf, 10000 - .disable_rf = rtl8723b_disable_rf, 10001 - .set_tx_power = rtl8723b_set_tx_power, 10002 - .update_rate_mask = rtl8723bu_update_rate_mask, 10003 - .report_connect = rtl8723bu_report_connect, 8522 + .init_phy_bb = rtl8192eu_init_phy_bb, 8523 + .init_phy_rf = rtl8192eu_init_phy_rf, 8524 + .phy_iq_calibrate = rtl8192eu_phy_iq_calibrate, 8525 + .config_channel = rtl8xxxu_gen2_config_channel, 8526 + .parse_rx_desc = rtl8xxxu_parse_rxdesc24, 8527 + .enable_rf = rtl8192e_enable_rf, 8528 + .disable_rf = rtl8xxxu_gen2_disable_rf, 8529 + .usb_quirks = rtl8xxxu_gen2_usb_quirks, 8530 + .set_tx_power = rtl8192e_set_tx_power, 8531 + .update_rate_mask = rtl8xxxu_gen2_update_rate_mask, 8532 + .report_connect = rtl8xxxu_gen2_report_connect, 10004 8533 .writeN_block_size = 128, 10005 8534 .mbox_ext_reg = REG_HMBOX_EXT0_8723B, 10006 8535 .mbox_ext_width = 4, 10007 8536 .tx_desc_size = sizeof(struct rtl8xxxu_txdesc40), 10008 - .has_s0s1 = 1, 8537 + .rx_desc_size = sizeof(struct rtl8xxxu_rxdesc24), 8538 + .has_s0s1 = 0, 10009 8539 .adda_1t_init = 0x0fc01616, 10010 8540 .adda_1t_path_on = 0x0fc01616, 10011 8541 .adda_2t_path_on_a = 0x0fc01616, 10012 8542 .adda_2t_path_on_b = 0x0fc01616, 8543 + .trxff_boundary = 0x3cff, 8544 + .mactable = rtl8192e_mac_init_table, 8545 + .total_page_num = TX_TOTAL_PAGE_NUM_8192E, 8546 + .page_num_hi = TX_PAGE_NUM_HI_PQ_8192E, 8547 + .page_num_lo = TX_PAGE_NUM_LO_PQ_8192E, 8548 + .page_num_norm = TX_PAGE_NUM_NORM_PQ_8192E, 10013 8549 }; 10014 8550 10015 8551 static struct usb_device_id dev_table[] = { ··· 10043 8559 .driver_info = (unsigned long)&rtl8192cu_fops}, 10044 8560 /* Tested by Larry Finger */ 10045 8561 {USB_DEVICE_AND_INTERFACE_INFO(0x7392, 0x7811, 0xff, 0xff, 0xff), 8562 + .driver_info = (unsigned long)&rtl8192cu_fops}, 8563 + /* Tested by Andrea Merello */ 8564 + {USB_DEVICE_AND_INTERFACE_INFO(0x050d, 0x1004, 0xff, 0xff, 0xff), 10046 8565 .driver_info = (unsigned long)&rtl8192cu_fops}, 10047 8566 /* Currently untested 8188 series devices */ 10048 8567 {USB_DEVICE_AND_INTERFACE_INFO(USB_VENDOR_ID_REALTEK, 0x8191, 0xff, 0xff, 0xff), ··· 10131 8644 /* Currently untested 8192 series devices */ 10132 8645 {USB_DEVICE_AND_INTERFACE_INFO(0x04bb, 0x0950, 0xff, 0xff, 0xff), 10133 8646 .driver_info = (unsigned long)&rtl8192cu_fops}, 10134 - {USB_DEVICE_AND_INTERFACE_INFO(0x050d, 0x1004, 0xff, 0xff, 0xff), 10135 - .driver_info = (unsigned long)&rtl8192cu_fops}, 10136 8647 {USB_DEVICE_AND_INTERFACE_INFO(0x050d, 0x2102, 0xff, 0xff, 0xff), 10137 8648 .driver_info = (unsigned long)&rtl8192cu_fops}, 10138 8649 {USB_DEVICE_AND_INTERFACE_INFO(0x050d, 0x2103, 0xff, 0xff, 0xff), ··· 10186 8701 .probe = rtl8xxxu_probe, 10187 8702 .disconnect = rtl8xxxu_disconnect, 10188 8703 .id_table = dev_table, 8704 + .no_dynamic_id = 1, 10189 8705 .disable_hub_initiated_lpm = 1, 10190 8706 }; 10191 8707
+65 -27
drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h
··· 1 1 /* 2 - * Copyright (c) 2014 - 2015 Jes Sorensen <Jes.Sorensen@redhat.com> 2 + * Copyright (c) 2014 - 2016 Jes Sorensen <Jes.Sorensen@redhat.com> 3 3 * 4 4 * This program is free software; you can redistribute it and/or modify it 5 5 * under the terms of version 2 of the GNU General Public License as ··· 42 42 #define REALTEK_USB_CMD_IDX 0x00 43 43 44 44 #define TX_TOTAL_PAGE_NUM 0xf8 45 + #define TX_TOTAL_PAGE_NUM_8192E 0xf3 45 46 /* (HPQ + LPQ + NPQ + PUBQ) = TX_TOTAL_PAGE_NUM */ 46 47 #define TX_PAGE_NUM_PUBQ 0xe7 47 48 #define TX_PAGE_NUM_HI_PQ 0x0c 48 49 #define TX_PAGE_NUM_LO_PQ 0x02 49 50 #define TX_PAGE_NUM_NORM_PQ 0x02 51 + 52 + #define TX_PAGE_NUM_PUBQ_8192E 0xe7 53 + #define TX_PAGE_NUM_HI_PQ_8192E 0x08 54 + #define TX_PAGE_NUM_LO_PQ_8192E 0x0c 55 + #define TX_PAGE_NUM_NORM_PQ_8192E 0x00 50 56 51 57 #define RTL_FW_PAGE_SIZE 4096 52 58 #define RTL8XXXU_FIRMWARE_POLL_MAX 1000 ··· 101 95 RX_TYPE_ERROR = -1 102 96 }; 103 97 104 - struct rtl8xxxu_rx_desc { 98 + struct rtl8xxxu_rxdesc16 { 105 99 #ifdef __LITTLE_ENDIAN 106 100 u32 pktlen:14; 107 101 u32 crc32:1; ··· 237 231 #endif 238 232 }; 239 233 240 - struct rtl8723bu_rx_desc { 234 + struct rtl8xxxu_rxdesc24 { 241 235 #ifdef __LITTLE_ENDIAN 242 236 u32 pktlen:14; 243 237 u32 crc32:1; ··· 630 624 }; 631 625 632 626 /* 627 + * 8723au/8192cu/8188ru required base power index offset tables. 628 + */ 629 + struct rtl8xxxu_power_base { 630 + u32 reg_0e00; 631 + u32 reg_0e04; 632 + u32 reg_0e08; 633 + u32 reg_086c; 634 + 635 + u32 reg_0e10; 636 + u32 reg_0e14; 637 + u32 reg_0e18; 638 + u32 reg_0e1c; 639 + 640 + u32 reg_0830; 641 + u32 reg_0834; 642 + u32 reg_0838; 643 + u32 reg_086c_2; 644 + 645 + u32 reg_083c; 646 + u32 reg_0848; 647 + u32 reg_084c; 648 + u32 reg_0868; 649 + }; 650 + 651 + /* 633 652 * The 8723au has 3 channel groups: 1-3, 4-9, and 10-14 634 653 */ 635 654 struct rtl8723au_idx { ··· 818 787 u8 cck_base[6]; 819 788 u8 ht40_base[5]; 820 789 struct rtl8723au_idx ht20_ofdm_1s_diff; 821 - struct rtl8723au_idx ht40_ht20_2s_diff; 822 - struct rtl8723au_idx ofdm_cck_2s_diff; /* not used */ 823 - struct rtl8723au_idx ht40_ht20_3s_diff; 824 - struct rtl8723au_idx ofdm_cck_3s_diff; /* not used */ 825 - struct rtl8723au_idx ht40_ht20_4s_diff; 826 - struct rtl8723au_idx ofdm_cck_4s_diff; /* not used */ 790 + struct rtl8723bu_pwr_idx pwr_diff[3]; 791 + u8 dummy5g[24]; /* max channel group (14) + power diff offset (10) */ 827 792 }; 828 793 829 794 struct rtl8192eu_efuse { 830 795 __le16 rtl_id; 831 796 u8 res0[0x0e]; 832 797 struct rtl8192eu_efuse_tx_power tx_power_index_A; /* 0x10 */ 833 - struct rtl8192eu_efuse_tx_power tx_power_index_B; /* 0x22 */ 834 - struct rtl8192eu_efuse_tx_power tx_power_index_C; /* 0x34 */ 835 - struct rtl8192eu_efuse_tx_power tx_power_index_D; /* 0x46 */ 836 - u8 res1[0x60]; 798 + struct rtl8192eu_efuse_tx_power tx_power_index_B; /* 0x3a */ 799 + u8 res2[0x54]; 837 800 u8 channel_plan; /* 0xb8 */ 838 801 u8 xtal_k; 839 802 u8 thermal_meter; 840 803 u8 iqk_lck; 841 804 u8 pa_type; /* 0xbc */ 842 805 u8 lna_type_2g; /* 0xbd */ 843 - u8 res2[1]; 806 + u8 res3[1]; 844 807 u8 lna_type_5g; /* 0xbf */ 845 - u8 res13[1]; 808 + u8 res4[1]; 846 809 u8 rf_board_option; 847 810 u8 rf_feature_option; 848 811 u8 rf_bt_setting; 849 812 u8 eeprom_version; 850 813 u8 eeprom_customer_id; 851 - u8 res3[3]; 814 + u8 res5[3]; 852 815 u8 rf_antenna_option; /* 0xc9 */ 853 - u8 res4[6]; 816 + u8 res6[6]; 854 817 u8 vid; /* 0xd0 */ 855 - u8 res5[1]; 818 + u8 res7[1]; 856 819 u8 pid; /* 0xd2 */ 857 - u8 res6[1]; 820 + u8 res8[1]; 858 821 u8 usb_optional_function; 859 - u8 res7[2]; 860 - u8 mac_addr[ETH_ALEN]; /* 0xd7 */ 861 - u8 res8[2]; 862 - u8 vendor_name[7]; 863 822 u8 res9[2]; 864 - u8 device_name[0x0b]; /* 0xe8 */ 823 + u8 mac_addr[ETH_ALEN]; /* 0xd7 */ 865 824 u8 res10[2]; 825 + u8 vendor_name[7]; 826 + u8 res11[2]; 827 + u8 device_name[0x0b]; /* 0xe8 */ 828 + u8 res12[2]; 866 829 u8 serial[0x0b]; /* 0xf5 */ 867 - u8 res11[0x30]; 830 + u8 res13[0x30]; 868 831 u8 unknown[0x0d]; /* 0x130 */ 869 - u8 res12[0xc3]; 832 + u8 res14[0xc3]; 870 833 }; 871 834 872 835 struct rtl8xxxu_reg8val { ··· 1226 1201 struct rtl8723au_idx ofdm_tx_power_diff[RTL8723B_TX_COUNT]; 1227 1202 struct rtl8723au_idx ht20_tx_power_diff[RTL8723B_TX_COUNT]; 1228 1203 struct rtl8723au_idx ht40_tx_power_diff[RTL8723B_TX_COUNT]; 1204 + struct rtl8xxxu_power_base *power_base; 1229 1205 u32 chip_cut:4; 1230 1206 u32 rom_rev:4; 1231 1207 u32 is_multi_func:1; ··· 1254 1228 u8 rf_paths; 1255 1229 u8 rx_paths; 1256 1230 u8 tx_paths; 1257 - u32 rf_mode_ag[2]; 1258 1231 u32 rege94; 1259 1232 u32 rege9c; 1260 1233 u32 regeb4; ··· 1287 1262 u32 bb_recovery_backup[RTL8XXXU_BB_REGS]; 1288 1263 enum rtl8xxxu_rtl_chip rtl_chip; 1289 1264 u8 pi_enabled:1; 1265 + u8 no_pape:1; 1290 1266 u8 int_buf[USB_INTR_CONTENT_LENGTH]; 1291 1267 }; 1292 1268 ··· 1310 1284 void (*power_off) (struct rtl8xxxu_priv *priv); 1311 1285 void (*reset_8051) (struct rtl8xxxu_priv *priv); 1312 1286 int (*llt_init) (struct rtl8xxxu_priv *priv, u8 last_tx_page); 1287 + void (*init_phy_bb) (struct rtl8xxxu_priv *priv); 1288 + int (*init_phy_rf) (struct rtl8xxxu_priv *priv); 1313 1289 void (*phy_init_antenna_selection) (struct rtl8xxxu_priv *priv); 1314 1290 void (*phy_iq_calibrate) (struct rtl8xxxu_priv *priv); 1315 1291 void (*config_channel) (struct ieee80211_hw *hw); ··· 1321 1293 void (*init_statistics) (struct rtl8xxxu_priv *priv); 1322 1294 void (*enable_rf) (struct rtl8xxxu_priv *priv); 1323 1295 void (*disable_rf) (struct rtl8xxxu_priv *priv); 1296 + void (*usb_quirks) (struct rtl8xxxu_priv *priv); 1324 1297 void (*set_tx_power) (struct rtl8xxxu_priv *priv, int channel, 1325 1298 bool ht40); 1326 1299 void (*update_rate_mask) (struct rtl8xxxu_priv *priv, ··· 1332 1303 u16 mbox_ext_reg; 1333 1304 char mbox_ext_width; 1334 1305 char tx_desc_size; 1306 + char rx_desc_size; 1335 1307 char has_s0s1; 1336 1308 u32 adda_1t_init; 1337 1309 u32 adda_1t_path_on; 1338 1310 u32 adda_2t_path_on_a; 1339 1311 u32 adda_2t_path_on_b; 1312 + u16 trxff_boundary; 1313 + u8 pbp_rx; 1314 + u8 pbp_tx; 1315 + struct rtl8xxxu_reg8val *mactable; 1316 + u8 total_page_num; 1317 + u8 page_num_hi; 1318 + u8 page_num_lo; 1319 + u8 page_num_norm; 1340 1320 };
+13 -2
drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_regs.h
··· 1 1 /* 2 - * Copyright (c) 2014 - 2015 Jes Sorensen <Jes.Sorensen@redhat.com> 2 + * Copyright (c) 2014 - 2016 Jes Sorensen <Jes.Sorensen@redhat.com> 3 3 * 4 4 * This program is free software; you can redistribute it and/or modify it 5 5 * under the terms of version 2 of the GNU General Public License as ··· 109 109 #define AFE_XTAL_GATE_DIG BIT(17) 110 110 #define AFE_XTAL_BT_GATE BIT(20) 111 111 112 + /* 113 + * 0x0028 is also known as REG_AFE_CTRL2 on 8723bu/8192eu 114 + */ 112 115 #define REG_AFE_PLL_CTRL 0x0028 113 116 #define AFE_PLL_ENABLE BIT(0) 114 117 #define AFE_PLL_320_ENABLE BIT(1) ··· 195 192 control */ 196 193 #define MULTI_GPS_FUNC_EN BIT(22) /* GPS function enable */ 197 194 195 + #define REG_AFE_CTRL4 0x0078 /* 8192eu/8723bu */ 198 196 #define REG_LDO_SW_CTRL 0x007c /* 8192eu */ 199 197 200 198 #define REG_MCU_FW_DL 0x0080 ··· 387 383 #define REG_RQPN 0x0200 388 384 #define RQPN_HI_PQ_SHIFT 0 389 385 #define RQPN_LO_PQ_SHIFT 8 390 - #define RQPN_NORM_PQ_SHIFT 16 386 + #define RQPN_PUB_PQ_SHIFT 16 391 387 #define RQPN_LOAD BIT(31) 392 388 393 389 #define REG_FIFOPAGE 0x0204 ··· 516 512 #define REG_PKT_VO_VI_LIFE_TIME 0x04c0 517 513 #define REG_PKT_BE_BK_LIFE_TIME 0x04c2 518 514 #define REG_STBC_SETTING 0x04c4 515 + #define REG_QUEUE_CTRL 0x04c6 519 516 #define REG_HT_SINGLE_AMPDU_8723B 0x04c7 520 517 #define REG_PROT_MODE_CTRL 0x04c8 521 518 #define REG_MAX_AGGR_NUM 0x04ca ··· 882 877 #define CCK0_SIDEBAND BIT(4) 883 878 884 879 #define REG_CCK0_AFE_SETTING 0x0a04 880 + #define CCK0_AFE_RX_MASK 0x0f000000 881 + #define CCK0_AFE_RX_ANT_AB BIT(24) 882 + #define CCK0_AFE_RX_ANT_A 0 883 + #define CCK0_AFE_RX_ANT_B (BIT(24) | BIT(26)) 885 884 886 885 #define REG_CONFIG_ANT_A 0x0b68 887 886 #define REG_CONFIG_ANT_B 0x0b6c ··· 1052 1043 #define USB_HIMR_ROK BIT(0) /* Receive DMA OK Interrupt */ 1053 1044 1054 1045 #define REG_USB_SPECIAL_OPTION 0xfe55 1046 + #define REG_USB_HRPWM 0xfe58 1055 1047 #define REG_USB_DMA_AGG_TO 0xfe5b 1056 1048 #define REG_USB_AGG_TO 0xfe5c 1057 1049 #define REG_USB_AGG_TH 0xfe5d ··· 1138 1128 #define RF6052_REG_T_METER_8723B 0x42 1139 1129 #define RF6052_REG_UNKNOWN_43 0x43 1140 1130 #define RF6052_REG_UNKNOWN_55 0x55 1131 + #define RF6052_REG_UNKNOWN_56 0x56 1141 1132 #define RF6052_REG_S0S1 0xb0 1142 1133 #define RF6052_REG_UNKNOWN_DF 0xdf 1143 1134 #define RF6052_REG_UNKNOWN_ED 0xed
+1 -1
drivers/net/wireless/realtek/rtlwifi/rtl8821ae/phy.c
··· 959 959 static void _phy_convert_txpower_dbm_to_relative_value(u32 *data, u8 start, 960 960 u8 end, u8 base_val) 961 961 { 962 - char i = 0; 962 + int i; 963 963 u8 temp_value = 0; 964 964 u32 temp_data = 0; 965 965